@zeedhi/common 1.44.0 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/zd-common.esm.js +294 -86
  2. package/dist/zd-common.umd.js +294 -86
  3. package/package.json +2 -2
  4. package/types/components/zd-button-group/button-group.d.ts +1 -1
  5. package/types/components/zd-carousel/carousel.d.ts +2 -2
  6. package/types/components/zd-carousel/interfaces.d.ts +1 -1
  7. package/types/components/zd-collapse-card/collapse-card.d.ts +1 -1
  8. package/types/components/zd-component/component.d.ts +5 -4
  9. package/types/components/zd-dashboard/dashboard.d.ts +1 -1
  10. package/types/components/zd-date/date-range.d.ts +4 -4
  11. package/types/components/zd-date/date.d.ts +5 -5
  12. package/types/components/zd-file-input/file-input.d.ts +3 -3
  13. package/types/components/zd-form/form.d.ts +2 -2
  14. package/types/components/zd-frame/frame.d.ts +1 -1
  15. package/types/components/zd-grid/grid-editable.d.ts +6 -6
  16. package/types/components/zd-grid/grid.d.ts +9 -6
  17. package/types/components/zd-grid/interfaces.d.ts +3 -0
  18. package/types/components/zd-increment/increment.d.ts +2 -2
  19. package/types/components/zd-input/input.d.ts +6 -6
  20. package/types/components/zd-iterable/iterable-page-component.d.ts +1 -1
  21. package/types/components/zd-iterable/iterable-page-size.d.ts +2 -2
  22. package/types/components/zd-iterable/iterable.d.ts +1 -1
  23. package/types/components/zd-login/login-button.d.ts +1 -1
  24. package/types/components/zd-master-detail/master-detail.d.ts +1 -1
  25. package/types/components/zd-menu/menu-group.d.ts +1 -1
  26. package/types/components/zd-menu/menu-link.d.ts +1 -1
  27. package/types/components/zd-menu/menu.d.ts +1 -1
  28. package/types/components/zd-range-slider/range-slider.d.ts +3 -0
  29. package/types/components/zd-select/select.d.ts +6 -6
  30. package/types/components/zd-select-multiple/interfaces.d.ts +1 -0
  31. package/types/components/zd-select-multiple/select-multiple.d.ts +7 -2
  32. package/types/components/zd-select-tree/select-tree.d.ts +6 -6
  33. package/types/components/zd-select-tree-multiple/select-tree-multiple.d.ts +2 -2
  34. package/types/components/zd-selectable-list/selectable-list.d.ts +1 -1
  35. package/types/components/zd-svg-map/svg-map.d.ts +1 -1
  36. package/types/components/zd-tabs/tabs.d.ts +2 -2
  37. package/types/components/zd-text-input/text-input.d.ts +4 -4
  38. package/types/components/zd-time/time.d.ts +1 -1
  39. package/types/components/zd-tree/interfaces.d.ts +4 -0
  40. package/types/components/zd-tree/tree.d.ts +41 -12
  41. package/types/components/zd-tree-grid/tree-grid-editable.d.ts +6 -6
  42. package/types/components/zd-tree-grid/tree-grid.d.ts +2 -2
  43. package/types/services/zd-loading/loading-service.d.ts +7 -1
  44. package/types/utils/themes/themes.d.ts +8 -2
@@ -199,6 +199,7 @@
199
199
  * @param element Element mounted reference
200
200
  */
201
201
  onMounted(element) {
202
+ this.element = element;
202
203
  if (Object.keys(this.keyMap).length) {
203
204
  core.KeyMap.bind(this.keyMap, this, element);
204
205
  }
@@ -226,7 +227,11 @@
226
227
  * @param element Element clicked
227
228
  */
228
229
  click(event, element) {
229
- this.callEvent('click', { event, element, component: this });
230
+ this.callEvent('click', {
231
+ event: (event || new MouseEvent('click')),
232
+ element: (element || this.element),
233
+ component: this,
234
+ });
230
235
  }
231
236
  /**
232
237
  * Triggered when the component is focused.
@@ -497,7 +502,7 @@
497
502
  * @param options New options
498
503
  */
499
504
  updateChart(options) {
500
- this.options = Object.assign(Object.assign({}, this.options), options);
505
+ merge__default["default"](this.options, options);
501
506
  if (options.series) {
502
507
  this.series = this.options.series;
503
508
  }
@@ -559,7 +564,10 @@
559
564
  */
560
565
  clickEvent(event, chartContext, config) {
561
566
  this.callEvent('chartClick', {
562
- event, component: this, chartContext, config,
567
+ event: (event || new MouseEvent('click')),
568
+ component: this,
569
+ chartContext,
570
+ config,
563
571
  });
564
572
  }
565
573
  /**
@@ -1649,9 +1657,9 @@
1649
1657
  */
1650
1658
  this.storePath = '';
1651
1659
  /**
1652
- * Input value.
1653
- */
1654
- this.value = undefined;
1660
+ * Internal input value.
1661
+ */
1662
+ this.value = null;
1655
1663
  /**
1656
1664
  * Input validations.
1657
1665
  */
@@ -1756,7 +1764,8 @@
1756
1764
  * Removes all input validation.
1757
1765
  */
1758
1766
  clearValidations() {
1759
- Object.keys(this.validations).forEach((name) => this.removeValidation(name));
1767
+ this.validations = {};
1768
+ this.rules = [];
1760
1769
  }
1761
1770
  /**
1762
1771
  * Updates input rules.
@@ -1799,6 +1808,8 @@
1799
1808
  * @param element Element clicked
1800
1809
  */
1801
1810
  change(event, element) {
1811
+ if (this.value === '')
1812
+ this.value = null;
1802
1813
  if (this.events.change && typeof this.events.change === 'function') {
1803
1814
  this.events.change({ event, element, component: this });
1804
1815
  }
@@ -2811,61 +2822,34 @@
2811
2822
  */
2812
2823
  ModalService.modals = [];
2813
2824
 
2814
- class Loading extends Component {
2815
- /*
2816
- * Creates a new Loading Overlay
2817
- * @param props Modal structure
2818
- */
2819
- constructor(props) {
2820
- super(props);
2821
- /**
2822
- * text to show in Loader Overlay
2823
- */
2824
- this.text = 'Loading';
2825
- this.isVisible = false;
2826
- this.zIndex = 999;
2827
- this.text = this.getInitValue('text', props.text, this.text);
2828
- this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
2829
- this.defaultText = this.text;
2830
- }
2831
- /**
2832
- * Displays overlay
2833
- */
2834
- show(text) {
2835
- if (text)
2836
- this.text = text;
2837
- else
2838
- this.text = this.defaultText;
2839
- this.isVisible = true;
2840
- }
2841
- /**
2842
- * Close overlay
2843
- */
2844
- hide() {
2845
- this.isVisible = false;
2846
- }
2847
- }
2848
-
2849
2825
  /**
2850
2826
  * Loading Service Class
2851
2827
  */
2852
2828
  class LoadingService {
2829
+ /**
2830
+ * Creates a new loading instance
2831
+ * @param loading loading structure
2832
+ */
2833
+ static create(CreateLoading, props) {
2834
+ const instance = new CreateLoading(props);
2835
+ this.loading = instance;
2836
+ return instance;
2837
+ }
2853
2838
  /**
2854
2839
  * Displays a Loading.
2855
2840
  * If has an opened Loading it will be closed.
2856
2841
  * @param Loading loading structure
2857
2842
  */
2858
2843
  static show(text) {
2859
- this.instance.show(text);
2844
+ this.loading.show(text);
2860
2845
  }
2861
2846
  /**
2862
2847
  * Hides current Loading
2863
2848
  */
2864
2849
  static hide() {
2865
- this.instance.hide();
2850
+ this.loading.hide();
2866
2851
  }
2867
- }
2868
- LoadingService.instance = new Loading({ name: 'loading-instance' });
2852
+ }
2869
2853
 
2870
2854
  /**
2871
2855
  * Base class for Dashboard component.
@@ -3472,8 +3456,9 @@
3472
3456
  return !this.dateError || core.I18n.translate('VALIDATION_INVALID_DATE');
3473
3457
  }
3474
3458
  click(event, element) {
3475
- super.click(event, element);
3476
- if (!event.defaultPrevented) {
3459
+ const clickEvent = event || new MouseEvent('click');
3460
+ super.click(clickEvent, element);
3461
+ if (!clickEvent.defaultPrevented) {
3477
3462
  this.showDatePicker = !this.showDatePicker;
3478
3463
  }
3479
3464
  }
@@ -3821,8 +3806,9 @@
3821
3806
  return !this.dateError || core.I18n.translate('VALIDATION_INVALID_DATE');
3822
3807
  }
3823
3808
  click(event, element) {
3824
- super.click(event, element);
3825
- if (!event.defaultPrevented) {
3809
+ const clickEvent = event || new MouseEvent('click');
3810
+ super.click(clickEvent, element);
3811
+ if (!clickEvent.defaultPrevented) {
3826
3812
  this.showDatePicker = !this.showDatePicker;
3827
3813
  }
3828
3814
  }
@@ -4195,7 +4181,7 @@
4195
4181
  * Triggered when a removable chip is clicked
4196
4182
  * @param event DOM event
4197
4183
  * @param index Chip index
4198
- * @param element HTMLElement
4184
+ * @param element any
4199
4185
  */
4200
4186
  chipClick(event, index, element) {
4201
4187
  event.stopImmediatePropagation();
@@ -4969,6 +4955,9 @@
4969
4955
  this.toolbarSlot = [
4970
4956
  { name: '<<NAME>>_gridSearch', component: 'ZdSearch' },
4971
4957
  ];
4958
+ this.loadingText = 'LOADING';
4959
+ this.noDataText = 'NO_DATA';
4960
+ this.noResultsText = 'NO_RESULT';
4972
4961
  /**
4973
4962
  * Components that will be rendered in no-data case
4974
4963
  */
@@ -4977,7 +4966,7 @@
4977
4966
  name: '<<NAME>>_no-data',
4978
4967
  component: 'ZdText',
4979
4968
  cssClass: 'no-data',
4980
- text: 'NO_DATA',
4969
+ text: this.noDataText,
4981
4970
  },
4982
4971
  ];
4983
4972
  /**
@@ -4988,7 +4977,7 @@
4988
4977
  name: '<<NAME>>_no-result',
4989
4978
  component: 'ZdText',
4990
4979
  cssClass: 'no-result',
4991
- text: 'NO_RESULT',
4980
+ text: this.noResultsText,
4992
4981
  },
4993
4982
  ];
4994
4983
  /**
@@ -5092,6 +5081,7 @@
5092
5081
  this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
5093
5082
  this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
5094
5083
  this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
5084
+ this.loadingText = this.getInitValue('loadingText', props.loadingText, this.loadingText);
5095
5085
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
5096
5086
  this.footerSlot = props.footerSlot || this.footerSlot;
5097
5087
  this.noDataSlot = props.noDataSlot || this.noDataSlot;
@@ -5101,6 +5091,8 @@
5101
5091
  this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
5102
5092
  this.toolbarSlot = this.changeDefaultSlotNames(this.toolbarSlot);
5103
5093
  this.noResultSlot = this.changeDefaultSlotNames(this.noResultSlot);
5094
+ this.noDataText = this.getInitValue('noDataText', props.noDataText, this.noDataText);
5095
+ this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
5104
5096
  this.createAccessors();
5105
5097
  }
5106
5098
  onMounted(element) {
@@ -7046,6 +7038,41 @@
7046
7038
  }
7047
7039
  }
7048
7040
 
7041
+ class Loading extends Component {
7042
+ /*
7043
+ * Creates a new Loading Overlay
7044
+ * @param props Modal structure
7045
+ */
7046
+ constructor(props) {
7047
+ super(props);
7048
+ /**
7049
+ * text to show in Loader Overlay
7050
+ */
7051
+ this.text = 'Loading';
7052
+ this.isVisible = false;
7053
+ this.zIndex = 999;
7054
+ this.text = this.getInitValue('text', props.text, this.text);
7055
+ this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
7056
+ this.defaultText = this.text;
7057
+ }
7058
+ /**
7059
+ * Displays overlay
7060
+ */
7061
+ show(text) {
7062
+ if (text)
7063
+ this.text = text;
7064
+ else
7065
+ this.text = this.defaultText;
7066
+ this.isVisible = true;
7067
+ }
7068
+ /**
7069
+ * Close overlay
7070
+ */
7071
+ hide() {
7072
+ this.isVisible = false;
7073
+ }
7074
+ }
7075
+
7049
7076
  /**
7050
7077
  * Base class for Login component.
7051
7078
  */
@@ -7679,9 +7706,12 @@
7679
7706
  */
7680
7707
  click(event) {
7681
7708
  let preventDefault = false;
7682
- preventDefault = this.callEvent('click', { event, component: this });
7709
+ preventDefault = this.callEvent('click', {
7710
+ event: (event || new MouseEvent('click')),
7711
+ component: this,
7712
+ });
7683
7713
  if (preventDefault) {
7684
- event.preventDefault();
7714
+ event === null || event === void 0 ? void 0 : event.preventDefault();
7685
7715
  }
7686
7716
  this.setFocus();
7687
7717
  }
@@ -7764,9 +7794,12 @@
7764
7794
  */
7765
7795
  click(event) {
7766
7796
  let preventDefault = false;
7767
- preventDefault = this.callEvent('click', { event, component: this });
7797
+ preventDefault = this.callEvent('click', {
7798
+ event: (event || new MouseEvent('click')),
7799
+ component: this,
7800
+ });
7768
7801
  if (preventDefault) {
7769
- event.preventDefault();
7802
+ event === null || event === void 0 ? void 0 : event.preventDefault();
7770
7803
  }
7771
7804
  this.setFocus();
7772
7805
  }
@@ -8248,6 +8281,12 @@
8248
8281
  this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
8249
8282
  this.createAccessors();
8250
8283
  }
8284
+ get value() {
8285
+ return this.rangeSliderValue === null ? undefined : this.rangeSliderValue;
8286
+ }
8287
+ set value(value) {
8288
+ this.rangeSliderValue = value;
8289
+ }
8251
8290
  }
8252
8291
 
8253
8292
  /**
@@ -8291,11 +8330,16 @@
8291
8330
  * Number of hidden items
8292
8331
  */
8293
8332
  this.moreChip = 0;
8333
+ /**
8334
+ * Max number of rows the component can have
8335
+ */
8336
+ this.maxRows = undefined;
8294
8337
  this.showSelectAll = false;
8295
8338
  if (!this.selectedValue) {
8296
8339
  this.selectedValue = [];
8297
8340
  }
8298
8341
  this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
8342
+ this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
8299
8343
  this.createAccessors();
8300
8344
  }
8301
8345
  afterFocus() {
@@ -8471,6 +8515,21 @@
8471
8515
  removePushedValue() {
8472
8516
  this.removeInserts();
8473
8517
  }
8518
+ doSearch(value) {
8519
+ return __awaiter(this, void 0, void 0, function* () {
8520
+ if (this.manualMode || value) {
8521
+ yield this.updateSearch(value);
8522
+ }
8523
+ else {
8524
+ if (!this.manualMode) {
8525
+ this.datasource.data = [...this.cachedData];
8526
+ this.datasource.total = this.cachedTotal;
8527
+ }
8528
+ this.removeInserts();
8529
+ this.insertSelected();
8530
+ }
8531
+ });
8532
+ }
8474
8533
  /**
8475
8534
  * Removes unselected inserts from datasource
8476
8535
  */
@@ -10137,8 +10196,11 @@
10137
10196
  || core.I18n.translate('VALIDATION_TIME_NOT_ALLOWED');
10138
10197
  }
10139
10198
  click(event) {
10140
- this.callEvent('click', { event, component: this });
10141
- if (!event.defaultPrevented) {
10199
+ this.callEvent('click', {
10200
+ event: (event || new MouseEvent('click')),
10201
+ component: this,
10202
+ });
10203
+ if (!(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {
10142
10204
  this.showTimePicker = !this.showTimePicker;
10143
10205
  }
10144
10206
  }
@@ -10264,21 +10326,36 @@
10264
10326
  * Components that will be rendered on toolbar slot
10265
10327
  */
10266
10328
  this.toolbarSlot = [];
10329
+ /**
10330
+ * Components that will be rendered on title slot
10331
+ */
10332
+ this.titleSlot = [];
10267
10333
  /** Datasource parent field */
10268
10334
  this.parentField = '';
10269
10335
  /** Datasource title field */
10270
10336
  this.titleField = '';
10271
10337
  /** Datasource data field */
10272
10338
  this.dataField = '';
10339
+ /** Datasource checked field */
10340
+ this.checkedField = 'checked';
10273
10341
  /**
10274
10342
  * Defines if the tree will be opened or not (true/false) or if it should open only until a specific level
10275
10343
  */
10276
10344
  this.openLevelOnLoad = false;
10345
+ /**
10346
+ * Allow row check
10347
+ */
10348
+ this.checkbox = false;
10277
10349
  /**
10278
10350
  * Defines if should wait and not execute GET method when Datasource is created
10279
10351
  */
10280
10352
  this.lazyLoad = true;
10281
- this.nodes = props.nodes || this.nodes;
10353
+ /**
10354
+ * Dictionary of nodePath ponting to Dictionary of path pointing to the condition (applied) return value
10355
+ */
10356
+ this.appliedConditions = {};
10357
+ /* Conditions of tree */
10358
+ this.factoredConditions = {};
10282
10359
  this.itemIconName = this.getInitValue('itemIconName', props.itemIconName, this.itemIconName);
10283
10360
  this.groupIconName = this.getInitValue('groupIconName', props.groupIconName, this.groupIconName);
10284
10361
  this.openedIconName = this.getInitValue('openedIconName', props.openedIconName, this.openedIconName);
@@ -10288,25 +10365,67 @@
10288
10365
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10289
10366
  this.titleField = this.getInitValue('titleField', props.titleField, this.titleField);
10290
10367
  this.dataField = this.getInitValue('dataField', props.dataField, this.dataField);
10368
+ this.checkedField = this.getInitValue('checkedField', props.checkedField, this.checkedField);
10291
10369
  this.openLevelOnLoad = this.getInitValue('openLevelOnLoad', props.openLevelOnLoad, this.openLevelOnLoad);
10370
+ this.checkbox = this.getInitValue('checkbox', props.checkbox, this.checkbox);
10292
10371
  this.afterTitleSlot = props.afterTitleSlot || this.afterTitleSlot;
10293
10372
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
10373
+ this.titleSlot = props.titleSlot || this.titleSlot;
10374
+ if (props.afterTitleSlot) {
10375
+ this.createConditions([props.afterTitleSlot]);
10376
+ }
10377
+ if (props.titleSlot) {
10378
+ this.createConditions(props.titleSlot);
10379
+ }
10294
10380
  if (props.datasource && Object.keys(props.datasource).length) {
10295
10381
  this.lazyLoad = props.datasource.lazyLoad !== false;
10296
10382
  this.datasource = core.DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: props.datasource.searchIn || [this.titleField, this.dataField].filter(Boolean), lazyLoad: true, loadAll: true }));
10297
10383
  this.createDataStructure();
10298
10384
  }
10299
10385
  this.createAccessors();
10386
+ this.nodes = props.nodes || this.nodes;
10387
+ }
10388
+ /**
10389
+ * Initialize all the properties of the declared nodes (reactivity)
10390
+ */
10391
+ initNodes(nodes, override) {
10392
+ return nodes.map((node) => {
10393
+ let newNode = {
10394
+ title: '',
10395
+ isLeaf: false,
10396
+ isExpanded: true,
10397
+ isSelected: false,
10398
+ isDraggable: true,
10399
+ isSelectable: true,
10400
+ data: {
10401
+ [this.checkedField]: false,
10402
+ },
10403
+ children: [],
10404
+ };
10405
+ newNode = merge__default["default"](newNode, node, override);
10406
+ newNode.children = this.initNodes(node.children || [], override);
10407
+ return newNode;
10408
+ });
10300
10409
  }
10301
10410
  /** Nodes */
10302
10411
  get nodes() {
10303
10412
  return this.nodesValue;
10304
10413
  }
10305
10414
  set nodes(value) {
10415
+ let override = {};
10306
10416
  if (!this.allowDragDrop) {
10307
- this.removeDraggable(value);
10417
+ override = { isDraggable: false };
10308
10418
  }
10309
- this.nodesValue = value;
10419
+ this.nodesValue = this.initNodes(value, override);
10420
+ }
10421
+ getCheckedNodes() {
10422
+ const selectedNodes = [];
10423
+ this.tree.traverse((node) => {
10424
+ if (node.data && node.data[this.checkedField]) {
10425
+ selectedNodes.push(node);
10426
+ }
10427
+ });
10428
+ return selectedNodes;
10310
10429
  }
10311
10430
  /** Returns the selected nodes */
10312
10431
  get selectedNodes() {
@@ -10356,15 +10475,16 @@
10356
10475
  }
10357
10476
  /** Insert nodes by the current cursor position */
10358
10477
  insertNode(newNode) {
10478
+ const initNode = this.initNodes([newNode])[0];
10359
10479
  if (this.selectedNodes.length) {
10360
10480
  const cursorPosition = {
10361
10481
  node: this.selectedNodes[0],
10362
10482
  placement: 'inside',
10363
10483
  };
10364
- this.tree.insert(cursorPosition, newNode);
10484
+ this.tree.insert(cursorPosition, initNode);
10365
10485
  }
10366
10486
  else {
10367
- this.nodes.push(newNode);
10487
+ this.nodes.push(initNode);
10368
10488
  }
10369
10489
  }
10370
10490
  importNodes(nodes) {
@@ -10394,28 +10514,90 @@
10394
10514
  updateNodeData(node, value) {
10395
10515
  this.tree.updateNode(node.path, value);
10396
10516
  }
10397
- removeDraggable(items) {
10398
- items.forEach((item) => {
10399
- var _a;
10400
- item.isDraggable = false;
10401
- if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
10402
- this.removeDraggable(item.children);
10517
+ setTree(tree) {
10518
+ this.tree = tree;
10519
+ }
10520
+ /**
10521
+ * Return plain conditions object
10522
+ * @param conditions Conditions object
10523
+ * @param parentPath Path to parent property
10524
+ */
10525
+ getPlainConditions(conditions, parentPath = '') {
10526
+ let plainData = {};
10527
+ Object.keys(conditions).forEach((key) => {
10528
+ const fullKey = parentPath ? [parentPath, key].join('.') : key;
10529
+ if (typeof conditions[key] === 'object') {
10530
+ plainData = Object.assign(Object.assign({}, plainData), this.getPlainConditions(conditions[key], fullKey));
10531
+ }
10532
+ else {
10533
+ plainData[fullKey] = conditions[key];
10403
10534
  }
10404
10535
  });
10536
+ return plainData;
10405
10537
  }
10406
- setTree(tree) {
10407
- this.tree = tree;
10538
+ createConditions(children, parentPath = '') {
10539
+ children.forEach((child) => {
10540
+ const path = parentPath ? `${parentPath}.${child.name}` : child.name;
10541
+ if (child.conditions) {
10542
+ const plainConditions = this.getPlainConditions(child.conditions);
10543
+ this.factoredConditions[path] = core.Event.factory(plainConditions);
10544
+ }
10545
+ if (child.children) {
10546
+ this.createConditions(child.children, path);
10547
+ }
10548
+ });
10408
10549
  }
10409
- /** Get the conditions function to be applied to each column depending on the node */
10410
- getConditions(conditions) {
10411
- const cond = core.Event.factory(conditions);
10412
- return (node) => {
10413
- const appliedConditions = {};
10414
- Object.keys(conditions).forEach((condition) => {
10415
- appliedConditions[condition] = cond[condition](node);
10416
- });
10417
- return appliedConditions;
10418
- };
10550
+ applyCondition(node, factoredConditions) {
10551
+ const appliedConditions = {};
10552
+ Object.keys(factoredConditions).forEach((condition) => {
10553
+ const conditionFunction = factoredConditions[condition];
10554
+ set__default["default"](appliedConditions, condition, conditionFunction(node));
10555
+ });
10556
+ return appliedConditions;
10557
+ }
10558
+ applyChildCondition(node, factoredConditions = this.factoredConditions) {
10559
+ const appliedConditions = {};
10560
+ Object.keys(factoredConditions).forEach((comp) => {
10561
+ const conditions = this.factoredConditions[comp];
10562
+ appliedConditions[comp] = Object.assign({}, this.applyCondition(node, conditions));
10563
+ });
10564
+ return appliedConditions;
10565
+ }
10566
+ reapplyConditions(node) {
10567
+ const nodePath = node.pathStr;
10568
+ if (!nodePath)
10569
+ return {};
10570
+ const appliedConditions = Object.assign({}, this.appliedConditions);
10571
+ appliedConditions[nodePath] = this.applyChildCondition(node);
10572
+ this.appliedConditions = appliedConditions;
10573
+ return this.appliedConditions[nodePath];
10574
+ }
10575
+ getSlotComponent(slot, node, parentPath = '') {
10576
+ const slotArr = Array.isArray(slot) ? slot : [slot];
10577
+ const newComponents = [];
10578
+ slotArr.forEach((component) => {
10579
+ var _a;
10580
+ if (!component)
10581
+ return;
10582
+ const nodePath = node.pathStr;
10583
+ if (!nodePath)
10584
+ return;
10585
+ const compName = component.name;
10586
+ const instanceName = `${compName}_${nodePath}`;
10587
+ const path = parentPath ? `${parentPath}.${compName}` : compName;
10588
+ const newComponent = merge__default["default"]({}, component, (_a = this.appliedConditions[nodePath]) === null || _a === void 0 ? void 0 : _a[path]);
10589
+ const newChildren = this.getSlotComponent(newComponent.children || [], node, path);
10590
+ newComponent.name = instanceName;
10591
+ newComponent.children = newChildren;
10592
+ try {
10593
+ core.Metadata.updateInstance(instanceName, newComponent);
10594
+ }
10595
+ catch (e) {
10596
+ // do nothing
10597
+ }
10598
+ newComponents.push(newComponent);
10599
+ });
10600
+ return newComponents;
10419
10601
  }
10420
10602
  /** Triggers when dragging nodes have been dropped */
10421
10603
  nodeDrop(nodes, position, event, element) {
@@ -10443,6 +10625,12 @@
10443
10625
  event, element, component: this, node,
10444
10626
  });
10445
10627
  }
10628
+ /** Triggers when a node has been checked/unchecked */
10629
+ nodeCheck(node, event, element) {
10630
+ this.callEvent('onNodeCheck', {
10631
+ event, element, component: this, node,
10632
+ });
10633
+ }
10446
10634
  clearSelection(nodes) {
10447
10635
  const nodesArray = nodes || this.nodes;
10448
10636
  nodesArray.forEach((node) => {
@@ -10452,6 +10640,19 @@
10452
10640
  }
10453
10641
  });
10454
10642
  }
10643
+ getNode(path) {
10644
+ return this.searchPath(this.nodes, path);
10645
+ }
10646
+ getParentNode(node) {
10647
+ var _a;
10648
+ return this.tree.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10649
+ }
10650
+ searchPath(nodes, path) {
10651
+ const currentNode = (path[0] > -1 && path[0] < nodes.length) ? nodes[path[0]] : undefined;
10652
+ if (currentNode && path.length > 1)
10653
+ return this.searchPath(currentNode.children || [], path.slice(1));
10654
+ return currentNode;
10655
+ }
10455
10656
  }
10456
10657
 
10457
10658
  /**
@@ -10639,6 +10840,7 @@
10639
10840
  },
10640
10841
  };
10641
10842
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
10843
+ this.noDataSlot = this.changeDefaultSlotNames(this.noDataSlot);
10642
10844
  this.createAccessors();
10643
10845
  }
10644
10846
  onMounted(element) {
@@ -11189,15 +11391,23 @@
11189
11391
  zeedhi: {
11190
11392
  light: {
11191
11393
  'font-color': 'var(--v-grey-darken2)',
11192
- 'background-base': '#F6F6F6',
11394
+ 'background-base': '#FDFDFD',
11395
+ 'background-base-2': '#F6F6F6',
11396
+ 'background-base-3': '#EEE',
11193
11397
  'scrollbar-track': 'var(--v-grey-lighten5)',
11194
11398
  'scrollbar-thumb': 'var(--v-grey-lighten4)',
11399
+ 'badge-background-color': '#f44336',
11400
+ 'badge-text-color': '#fff',
11195
11401
  },
11196
11402
  dark: {
11197
11403
  'font-color': 'var(--v-grey-lighten3)',
11198
- 'background-base': '#121212',
11404
+ 'background-base': '#1E1E1E',
11405
+ 'background-base-2': 'var(--v-grey-darken2)',
11406
+ 'background-base-3': 'var(--v-grey-darken4)',
11199
11407
  'scrollbar-track': 'var(--v-grey-darken3)',
11200
11408
  'scrollbar-thumb': 'var(--v-grey-base)',
11409
+ 'badge-background-color': '#f44336',
11410
+ 'badge-text-color': '#fff',
11201
11411
  },
11202
11412
  variables: {
11203
11413
  'default-padding': '16px',
@@ -11215,8 +11425,6 @@
11215
11425
  'font-body4-weight': '500',
11216
11426
  'font-caption-size': '11px',
11217
11427
  'font-caption-weight': '400',
11218
- 'badge-background-color': '#f44336',
11219
- 'badge-text-color': '#fff',
11220
11428
  },
11221
11429
  },
11222
11430
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.44.0",
3
+ "version": "1.46.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -37,5 +37,5 @@
37
37
  "lodash.times": "^4.3.2",
38
38
  "mockdate": "^3.0.2"
39
39
  },
40
- "gitHead": "cfe94f85ab62e7e30d7bb09ea8178edf2b75fd59"
40
+ "gitHead": "0133e8028e0b9b5876c2bb24b9a8c4d687d22dd8"
41
41
  }
@@ -71,5 +71,5 @@ export declare class ButtonGroup extends ComponentRender implements IButtonGroup
71
71
  * @param event DOM event
72
72
  * @param element Element clicked
73
73
  */
74
- change(event?: Event, element?: HTMLElement): void;
74
+ change(event?: Event, element?: any): void;
75
75
  }