c353b9665c9039b6236ba95f161edb3db2d5f898f53f3c31a3988633dde1d957d298c76c8ca1020991c9cb30f856073bc1de2ee9f56b2832d271fbb8ec2524 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var lodashUnified = require('lodash-unified');
  5. var index = require('./index.js');
  6. var shared = require('@vue/shared');
  7. const InitialStateMap = {
  8. rowKey: "rowKey",
  9. defaultExpandAll: "defaultExpandAll",
  10. selectOnIndeterminate: "selectOnIndeterminate",
  11. indent: "indent",
  12. lazy: "lazy",
  13. data: "data",
  14. ["treeProps.hasChildren"]: {
  15. key: "lazyColumnIdentifier",
  16. default: "hasChildren"
  17. },
  18. ["treeProps.children"]: {
  19. key: "childrenColumnName",
  20. default: "children"
  21. },
  22. ["treeProps.checkStrictly"]: {
  23. key: "checkStrictly",
  24. default: false
  25. }
  26. };
  27. function createStore(table, props) {
  28. if (!table) {
  29. throw new Error("Table is required.");
  30. }
  31. const store = index["default"]();
  32. store.toggleAllSelection = lodashUnified.debounce(store._toggleAllSelection, 10);
  33. Object.keys(InitialStateMap).forEach((key) => {
  34. handleValue(getArrKeysValue(props, key), key, store);
  35. });
  36. proxyTableProps(store, props);
  37. return store;
  38. }
  39. function proxyTableProps(store, props) {
  40. Object.keys(InitialStateMap).forEach((key) => {
  41. vue.watch(() => getArrKeysValue(props, key), (value) => {
  42. handleValue(value, key, store);
  43. });
  44. });
  45. }
  46. function handleValue(value, propsKey, store) {
  47. let newVal = value;
  48. let storeKey = InitialStateMap[propsKey];
  49. if (shared.isObject(storeKey)) {
  50. newVal = newVal || storeKey.default;
  51. storeKey = storeKey.key;
  52. }
  53. store.states[storeKey].value = newVal;
  54. }
  55. function getArrKeysValue(props, key) {
  56. if (key.includes(".")) {
  57. const keyList = key.split(".");
  58. let value = props;
  59. keyList.forEach((k) => {
  60. value = value[k];
  61. });
  62. return value;
  63. } else {
  64. return props[key];
  65. }
  66. }
  67. exports.createStore = createStore;
  68. //# sourceMappingURL=helper.js.map