@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
@@ -192,6 +192,7 @@ class Component {
192
192
  * @param element Element mounted reference
193
193
  */
194
194
  onMounted(element) {
195
+ this.element = element;
195
196
  if (Object.keys(this.keyMap).length) {
196
197
  KeyMap.bind(this.keyMap, this, element);
197
198
  }
@@ -219,7 +220,11 @@ class Component {
219
220
  * @param element Element clicked
220
221
  */
221
222
  click(event, element) {
222
- this.callEvent('click', { event, element, component: this });
223
+ this.callEvent('click', {
224
+ event: (event || new MouseEvent('click')),
225
+ element: (element || this.element),
226
+ component: this,
227
+ });
223
228
  }
224
229
  /**
225
230
  * Triggered when the component is focused.
@@ -490,7 +495,7 @@ class ApexChart extends ComponentRender {
490
495
  * @param options New options
491
496
  */
492
497
  updateChart(options) {
493
- this.options = Object.assign(Object.assign({}, this.options), options);
498
+ merge(this.options, options);
494
499
  if (options.series) {
495
500
  this.series = this.options.series;
496
501
  }
@@ -552,7 +557,10 @@ class ApexChart extends ComponentRender {
552
557
  */
553
558
  clickEvent(event, chartContext, config) {
554
559
  this.callEvent('chartClick', {
555
- event, component: this, chartContext, config,
560
+ event: (event || new MouseEvent('click')),
561
+ component: this,
562
+ chartContext,
563
+ config,
556
564
  });
557
565
  }
558
566
  /**
@@ -1642,9 +1650,9 @@ class Input extends ComponentRender {
1642
1650
  */
1643
1651
  this.storePath = '';
1644
1652
  /**
1645
- * Input value.
1646
- */
1647
- this.value = undefined;
1653
+ * Internal input value.
1654
+ */
1655
+ this.value = null;
1648
1656
  /**
1649
1657
  * Input validations.
1650
1658
  */
@@ -1749,7 +1757,8 @@ class Input extends ComponentRender {
1749
1757
  * Removes all input validation.
1750
1758
  */
1751
1759
  clearValidations() {
1752
- Object.keys(this.validations).forEach((name) => this.removeValidation(name));
1760
+ this.validations = {};
1761
+ this.rules = [];
1753
1762
  }
1754
1763
  /**
1755
1764
  * Updates input rules.
@@ -1792,6 +1801,8 @@ class Input extends ComponentRender {
1792
1801
  * @param element Element clicked
1793
1802
  */
1794
1803
  change(event, element) {
1804
+ if (this.value === '')
1805
+ this.value = null;
1795
1806
  if (this.events.change && typeof this.events.change === 'function') {
1796
1807
  this.events.change({ event, element, component: this });
1797
1808
  }
@@ -2804,61 +2815,34 @@ class ModalService {
2804
2815
  */
2805
2816
  ModalService.modals = [];
2806
2817
 
2807
- class Loading extends Component {
2808
- /*
2809
- * Creates a new Loading Overlay
2810
- * @param props Modal structure
2811
- */
2812
- constructor(props) {
2813
- super(props);
2814
- /**
2815
- * text to show in Loader Overlay
2816
- */
2817
- this.text = 'Loading';
2818
- this.isVisible = false;
2819
- this.zIndex = 999;
2820
- this.text = this.getInitValue('text', props.text, this.text);
2821
- this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
2822
- this.defaultText = this.text;
2823
- }
2824
- /**
2825
- * Displays overlay
2826
- */
2827
- show(text) {
2828
- if (text)
2829
- this.text = text;
2830
- else
2831
- this.text = this.defaultText;
2832
- this.isVisible = true;
2833
- }
2834
- /**
2835
- * Close overlay
2836
- */
2837
- hide() {
2838
- this.isVisible = false;
2839
- }
2840
- }
2841
-
2842
2818
  /**
2843
2819
  * Loading Service Class
2844
2820
  */
2845
2821
  class LoadingService {
2822
+ /**
2823
+ * Creates a new loading instance
2824
+ * @param loading loading structure
2825
+ */
2826
+ static create(CreateLoading, props) {
2827
+ const instance = new CreateLoading(props);
2828
+ this.loading = instance;
2829
+ return instance;
2830
+ }
2846
2831
  /**
2847
2832
  * Displays a Loading.
2848
2833
  * If has an opened Loading it will be closed.
2849
2834
  * @param Loading loading structure
2850
2835
  */
2851
2836
  static show(text) {
2852
- this.instance.show(text);
2837
+ this.loading.show(text);
2853
2838
  }
2854
2839
  /**
2855
2840
  * Hides current Loading
2856
2841
  */
2857
2842
  static hide() {
2858
- this.instance.hide();
2843
+ this.loading.hide();
2859
2844
  }
2860
- }
2861
- LoadingService.instance = new Loading({ name: 'loading-instance' });
2845
+ }
2862
2846
 
2863
2847
  /**
2864
2848
  * Base class for Dashboard component.
@@ -3465,8 +3449,9 @@ class Date$1 extends TextInput {
3465
3449
  return !this.dateError || I18n.translate('VALIDATION_INVALID_DATE');
3466
3450
  }
3467
3451
  click(event, element) {
3468
- super.click(event, element);
3469
- if (!event.defaultPrevented) {
3452
+ const clickEvent = event || new MouseEvent('click');
3453
+ super.click(clickEvent, element);
3454
+ if (!clickEvent.defaultPrevented) {
3470
3455
  this.showDatePicker = !this.showDatePicker;
3471
3456
  }
3472
3457
  }
@@ -3814,8 +3799,9 @@ class DateRange extends TextInput {
3814
3799
  return !this.dateError || I18n.translate('VALIDATION_INVALID_DATE');
3815
3800
  }
3816
3801
  click(event, element) {
3817
- super.click(event, element);
3818
- if (!event.defaultPrevented) {
3802
+ const clickEvent = event || new MouseEvent('click');
3803
+ super.click(clickEvent, element);
3804
+ if (!clickEvent.defaultPrevented) {
3819
3805
  this.showDatePicker = !this.showDatePicker;
3820
3806
  }
3821
3807
  }
@@ -4188,7 +4174,7 @@ class FileInput extends TextInput {
4188
4174
  * Triggered when a removable chip is clicked
4189
4175
  * @param event DOM event
4190
4176
  * @param index Chip index
4191
- * @param element HTMLElement
4177
+ * @param element any
4192
4178
  */
4193
4179
  chipClick(event, index, element) {
4194
4180
  event.stopImmediatePropagation();
@@ -4962,6 +4948,9 @@ class Grid extends Iterable {
4962
4948
  this.toolbarSlot = [
4963
4949
  { name: '<<NAME>>_gridSearch', component: 'ZdSearch' },
4964
4950
  ];
4951
+ this.loadingText = 'LOADING';
4952
+ this.noDataText = 'NO_DATA';
4953
+ this.noResultsText = 'NO_RESULT';
4965
4954
  /**
4966
4955
  * Components that will be rendered in no-data case
4967
4956
  */
@@ -4970,7 +4959,7 @@ class Grid extends Iterable {
4970
4959
  name: '<<NAME>>_no-data',
4971
4960
  component: 'ZdText',
4972
4961
  cssClass: 'no-data',
4973
- text: 'NO_DATA',
4962
+ text: this.noDataText,
4974
4963
  },
4975
4964
  ];
4976
4965
  /**
@@ -4981,7 +4970,7 @@ class Grid extends Iterable {
4981
4970
  name: '<<NAME>>_no-result',
4982
4971
  component: 'ZdText',
4983
4972
  cssClass: 'no-result',
4984
- text: 'NO_RESULT',
4973
+ text: this.noResultsText,
4985
4974
  },
4986
4975
  ];
4987
4976
  /**
@@ -5085,6 +5074,7 @@ class Grid extends Iterable {
5085
5074
  this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
5086
5075
  this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
5087
5076
  this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
5077
+ this.loadingText = this.getInitValue('loadingText', props.loadingText, this.loadingText);
5088
5078
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
5089
5079
  this.footerSlot = props.footerSlot || this.footerSlot;
5090
5080
  this.noDataSlot = props.noDataSlot || this.noDataSlot;
@@ -5094,6 +5084,8 @@ class Grid extends Iterable {
5094
5084
  this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
5095
5085
  this.toolbarSlot = this.changeDefaultSlotNames(this.toolbarSlot);
5096
5086
  this.noResultSlot = this.changeDefaultSlotNames(this.noResultSlot);
5087
+ this.noDataText = this.getInitValue('noDataText', props.noDataText, this.noDataText);
5088
+ this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
5097
5089
  this.createAccessors();
5098
5090
  }
5099
5091
  onMounted(element) {
@@ -7039,6 +7031,41 @@ class ListGroup extends ListItem {
7039
7031
  }
7040
7032
  }
7041
7033
 
7034
+ class Loading extends Component {
7035
+ /*
7036
+ * Creates a new Loading Overlay
7037
+ * @param props Modal structure
7038
+ */
7039
+ constructor(props) {
7040
+ super(props);
7041
+ /**
7042
+ * text to show in Loader Overlay
7043
+ */
7044
+ this.text = 'Loading';
7045
+ this.isVisible = false;
7046
+ this.zIndex = 999;
7047
+ this.text = this.getInitValue('text', props.text, this.text);
7048
+ this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
7049
+ this.defaultText = this.text;
7050
+ }
7051
+ /**
7052
+ * Displays overlay
7053
+ */
7054
+ show(text) {
7055
+ if (text)
7056
+ this.text = text;
7057
+ else
7058
+ this.text = this.defaultText;
7059
+ this.isVisible = true;
7060
+ }
7061
+ /**
7062
+ * Close overlay
7063
+ */
7064
+ hide() {
7065
+ this.isVisible = false;
7066
+ }
7067
+ }
7068
+
7042
7069
  /**
7043
7070
  * Base class for Login component.
7044
7071
  */
@@ -7672,9 +7699,12 @@ class MenuLink extends ComponentRender {
7672
7699
  */
7673
7700
  click(event) {
7674
7701
  let preventDefault = false;
7675
- preventDefault = this.callEvent('click', { event, component: this });
7702
+ preventDefault = this.callEvent('click', {
7703
+ event: (event || new MouseEvent('click')),
7704
+ component: this,
7705
+ });
7676
7706
  if (preventDefault) {
7677
- event.preventDefault();
7707
+ event === null || event === void 0 ? void 0 : event.preventDefault();
7678
7708
  }
7679
7709
  this.setFocus();
7680
7710
  }
@@ -7757,9 +7787,12 @@ class MenuGroup extends ComponentRender {
7757
7787
  */
7758
7788
  click(event) {
7759
7789
  let preventDefault = false;
7760
- preventDefault = this.callEvent('click', { event, component: this });
7790
+ preventDefault = this.callEvent('click', {
7791
+ event: (event || new MouseEvent('click')),
7792
+ component: this,
7793
+ });
7761
7794
  if (preventDefault) {
7762
- event.preventDefault();
7795
+ event === null || event === void 0 ? void 0 : event.preventDefault();
7763
7796
  }
7764
7797
  this.setFocus();
7765
7798
  }
@@ -8241,6 +8274,12 @@ class RangeSlider extends Input {
8241
8274
  this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
8242
8275
  this.createAccessors();
8243
8276
  }
8277
+ get value() {
8278
+ return this.rangeSliderValue === null ? undefined : this.rangeSliderValue;
8279
+ }
8280
+ set value(value) {
8281
+ this.rangeSliderValue = value;
8282
+ }
8244
8283
  }
8245
8284
 
8246
8285
  /**
@@ -8284,11 +8323,16 @@ class SelectMultiple extends Select {
8284
8323
  * Number of hidden items
8285
8324
  */
8286
8325
  this.moreChip = 0;
8326
+ /**
8327
+ * Max number of rows the component can have
8328
+ */
8329
+ this.maxRows = undefined;
8287
8330
  this.showSelectAll = false;
8288
8331
  if (!this.selectedValue) {
8289
8332
  this.selectedValue = [];
8290
8333
  }
8291
8334
  this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
8335
+ this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
8292
8336
  this.createAccessors();
8293
8337
  }
8294
8338
  afterFocus() {
@@ -8464,6 +8508,21 @@ class SelectMultiple extends Select {
8464
8508
  removePushedValue() {
8465
8509
  this.removeInserts();
8466
8510
  }
8511
+ doSearch(value) {
8512
+ return __awaiter(this, void 0, void 0, function* () {
8513
+ if (this.manualMode || value) {
8514
+ yield this.updateSearch(value);
8515
+ }
8516
+ else {
8517
+ if (!this.manualMode) {
8518
+ this.datasource.data = [...this.cachedData];
8519
+ this.datasource.total = this.cachedTotal;
8520
+ }
8521
+ this.removeInserts();
8522
+ this.insertSelected();
8523
+ }
8524
+ });
8525
+ }
8467
8526
  /**
8468
8527
  * Removes unselected inserts from datasource
8469
8528
  */
@@ -10130,8 +10189,11 @@ class Time extends TextInput {
10130
10189
  || I18n.translate('VALIDATION_TIME_NOT_ALLOWED');
10131
10190
  }
10132
10191
  click(event) {
10133
- this.callEvent('click', { event, component: this });
10134
- if (!event.defaultPrevented) {
10192
+ this.callEvent('click', {
10193
+ event: (event || new MouseEvent('click')),
10194
+ component: this,
10195
+ });
10196
+ if (!(event === null || event === void 0 ? void 0 : event.defaultPrevented)) {
10135
10197
  this.showTimePicker = !this.showTimePicker;
10136
10198
  }
10137
10199
  }
@@ -10257,21 +10319,36 @@ class Tree extends ComponentRender {
10257
10319
  * Components that will be rendered on toolbar slot
10258
10320
  */
10259
10321
  this.toolbarSlot = [];
10322
+ /**
10323
+ * Components that will be rendered on title slot
10324
+ */
10325
+ this.titleSlot = [];
10260
10326
  /** Datasource parent field */
10261
10327
  this.parentField = '';
10262
10328
  /** Datasource title field */
10263
10329
  this.titleField = '';
10264
10330
  /** Datasource data field */
10265
10331
  this.dataField = '';
10332
+ /** Datasource checked field */
10333
+ this.checkedField = 'checked';
10266
10334
  /**
10267
10335
  * Defines if the tree will be opened or not (true/false) or if it should open only until a specific level
10268
10336
  */
10269
10337
  this.openLevelOnLoad = false;
10338
+ /**
10339
+ * Allow row check
10340
+ */
10341
+ this.checkbox = false;
10270
10342
  /**
10271
10343
  * Defines if should wait and not execute GET method when Datasource is created
10272
10344
  */
10273
10345
  this.lazyLoad = true;
10274
- this.nodes = props.nodes || this.nodes;
10346
+ /**
10347
+ * Dictionary of nodePath ponting to Dictionary of path pointing to the condition (applied) return value
10348
+ */
10349
+ this.appliedConditions = {};
10350
+ /* Conditions of tree */
10351
+ this.factoredConditions = {};
10275
10352
  this.itemIconName = this.getInitValue('itemIconName', props.itemIconName, this.itemIconName);
10276
10353
  this.groupIconName = this.getInitValue('groupIconName', props.groupIconName, this.groupIconName);
10277
10354
  this.openedIconName = this.getInitValue('openedIconName', props.openedIconName, this.openedIconName);
@@ -10281,25 +10358,67 @@ class Tree extends ComponentRender {
10281
10358
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10282
10359
  this.titleField = this.getInitValue('titleField', props.titleField, this.titleField);
10283
10360
  this.dataField = this.getInitValue('dataField', props.dataField, this.dataField);
10361
+ this.checkedField = this.getInitValue('checkedField', props.checkedField, this.checkedField);
10284
10362
  this.openLevelOnLoad = this.getInitValue('openLevelOnLoad', props.openLevelOnLoad, this.openLevelOnLoad);
10363
+ this.checkbox = this.getInitValue('checkbox', props.checkbox, this.checkbox);
10285
10364
  this.afterTitleSlot = props.afterTitleSlot || this.afterTitleSlot;
10286
10365
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
10366
+ this.titleSlot = props.titleSlot || this.titleSlot;
10367
+ if (props.afterTitleSlot) {
10368
+ this.createConditions([props.afterTitleSlot]);
10369
+ }
10370
+ if (props.titleSlot) {
10371
+ this.createConditions(props.titleSlot);
10372
+ }
10287
10373
  if (props.datasource && Object.keys(props.datasource).length) {
10288
10374
  this.lazyLoad = props.datasource.lazyLoad !== false;
10289
10375
  this.datasource = DatasourceFactory.factory(Object.assign(Object.assign({}, props.datasource), { searchIn: props.datasource.searchIn || [this.titleField, this.dataField].filter(Boolean), lazyLoad: true, loadAll: true }));
10290
10376
  this.createDataStructure();
10291
10377
  }
10292
10378
  this.createAccessors();
10379
+ this.nodes = props.nodes || this.nodes;
10380
+ }
10381
+ /**
10382
+ * Initialize all the properties of the declared nodes (reactivity)
10383
+ */
10384
+ initNodes(nodes, override) {
10385
+ return nodes.map((node) => {
10386
+ let newNode = {
10387
+ title: '',
10388
+ isLeaf: false,
10389
+ isExpanded: true,
10390
+ isSelected: false,
10391
+ isDraggable: true,
10392
+ isSelectable: true,
10393
+ data: {
10394
+ [this.checkedField]: false,
10395
+ },
10396
+ children: [],
10397
+ };
10398
+ newNode = merge(newNode, node, override);
10399
+ newNode.children = this.initNodes(node.children || [], override);
10400
+ return newNode;
10401
+ });
10293
10402
  }
10294
10403
  /** Nodes */
10295
10404
  get nodes() {
10296
10405
  return this.nodesValue;
10297
10406
  }
10298
10407
  set nodes(value) {
10408
+ let override = {};
10299
10409
  if (!this.allowDragDrop) {
10300
- this.removeDraggable(value);
10410
+ override = { isDraggable: false };
10301
10411
  }
10302
- this.nodesValue = value;
10412
+ this.nodesValue = this.initNodes(value, override);
10413
+ }
10414
+ getCheckedNodes() {
10415
+ const selectedNodes = [];
10416
+ this.tree.traverse((node) => {
10417
+ if (node.data && node.data[this.checkedField]) {
10418
+ selectedNodes.push(node);
10419
+ }
10420
+ });
10421
+ return selectedNodes;
10303
10422
  }
10304
10423
  /** Returns the selected nodes */
10305
10424
  get selectedNodes() {
@@ -10349,15 +10468,16 @@ class Tree extends ComponentRender {
10349
10468
  }
10350
10469
  /** Insert nodes by the current cursor position */
10351
10470
  insertNode(newNode) {
10471
+ const initNode = this.initNodes([newNode])[0];
10352
10472
  if (this.selectedNodes.length) {
10353
10473
  const cursorPosition = {
10354
10474
  node: this.selectedNodes[0],
10355
10475
  placement: 'inside',
10356
10476
  };
10357
- this.tree.insert(cursorPosition, newNode);
10477
+ this.tree.insert(cursorPosition, initNode);
10358
10478
  }
10359
10479
  else {
10360
- this.nodes.push(newNode);
10480
+ this.nodes.push(initNode);
10361
10481
  }
10362
10482
  }
10363
10483
  importNodes(nodes) {
@@ -10387,28 +10507,90 @@ class Tree extends ComponentRender {
10387
10507
  updateNodeData(node, value) {
10388
10508
  this.tree.updateNode(node.path, value);
10389
10509
  }
10390
- removeDraggable(items) {
10391
- items.forEach((item) => {
10392
- var _a;
10393
- item.isDraggable = false;
10394
- if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
10395
- this.removeDraggable(item.children);
10510
+ setTree(tree) {
10511
+ this.tree = tree;
10512
+ }
10513
+ /**
10514
+ * Return plain conditions object
10515
+ * @param conditions Conditions object
10516
+ * @param parentPath Path to parent property
10517
+ */
10518
+ getPlainConditions(conditions, parentPath = '') {
10519
+ let plainData = {};
10520
+ Object.keys(conditions).forEach((key) => {
10521
+ const fullKey = parentPath ? [parentPath, key].join('.') : key;
10522
+ if (typeof conditions[key] === 'object') {
10523
+ plainData = Object.assign(Object.assign({}, plainData), this.getPlainConditions(conditions[key], fullKey));
10524
+ }
10525
+ else {
10526
+ plainData[fullKey] = conditions[key];
10396
10527
  }
10397
10528
  });
10529
+ return plainData;
10398
10530
  }
10399
- setTree(tree) {
10400
- this.tree = tree;
10531
+ createConditions(children, parentPath = '') {
10532
+ children.forEach((child) => {
10533
+ const path = parentPath ? `${parentPath}.${child.name}` : child.name;
10534
+ if (child.conditions) {
10535
+ const plainConditions = this.getPlainConditions(child.conditions);
10536
+ this.factoredConditions[path] = Event.factory(plainConditions);
10537
+ }
10538
+ if (child.children) {
10539
+ this.createConditions(child.children, path);
10540
+ }
10541
+ });
10401
10542
  }
10402
- /** Get the conditions function to be applied to each column depending on the node */
10403
- getConditions(conditions) {
10404
- const cond = Event.factory(conditions);
10405
- return (node) => {
10406
- const appliedConditions = {};
10407
- Object.keys(conditions).forEach((condition) => {
10408
- appliedConditions[condition] = cond[condition](node);
10409
- });
10410
- return appliedConditions;
10411
- };
10543
+ applyCondition(node, factoredConditions) {
10544
+ const appliedConditions = {};
10545
+ Object.keys(factoredConditions).forEach((condition) => {
10546
+ const conditionFunction = factoredConditions[condition];
10547
+ set(appliedConditions, condition, conditionFunction(node));
10548
+ });
10549
+ return appliedConditions;
10550
+ }
10551
+ applyChildCondition(node, factoredConditions = this.factoredConditions) {
10552
+ const appliedConditions = {};
10553
+ Object.keys(factoredConditions).forEach((comp) => {
10554
+ const conditions = this.factoredConditions[comp];
10555
+ appliedConditions[comp] = Object.assign({}, this.applyCondition(node, conditions));
10556
+ });
10557
+ return appliedConditions;
10558
+ }
10559
+ reapplyConditions(node) {
10560
+ const nodePath = node.pathStr;
10561
+ if (!nodePath)
10562
+ return {};
10563
+ const appliedConditions = Object.assign({}, this.appliedConditions);
10564
+ appliedConditions[nodePath] = this.applyChildCondition(node);
10565
+ this.appliedConditions = appliedConditions;
10566
+ return this.appliedConditions[nodePath];
10567
+ }
10568
+ getSlotComponent(slot, node, parentPath = '') {
10569
+ const slotArr = Array.isArray(slot) ? slot : [slot];
10570
+ const newComponents = [];
10571
+ slotArr.forEach((component) => {
10572
+ var _a;
10573
+ if (!component)
10574
+ return;
10575
+ const nodePath = node.pathStr;
10576
+ if (!nodePath)
10577
+ return;
10578
+ const compName = component.name;
10579
+ const instanceName = `${compName}_${nodePath}`;
10580
+ const path = parentPath ? `${parentPath}.${compName}` : compName;
10581
+ const newComponent = merge({}, component, (_a = this.appliedConditions[nodePath]) === null || _a === void 0 ? void 0 : _a[path]);
10582
+ const newChildren = this.getSlotComponent(newComponent.children || [], node, path);
10583
+ newComponent.name = instanceName;
10584
+ newComponent.children = newChildren;
10585
+ try {
10586
+ Metadata.updateInstance(instanceName, newComponent);
10587
+ }
10588
+ catch (e) {
10589
+ // do nothing
10590
+ }
10591
+ newComponents.push(newComponent);
10592
+ });
10593
+ return newComponents;
10412
10594
  }
10413
10595
  /** Triggers when dragging nodes have been dropped */
10414
10596
  nodeDrop(nodes, position, event, element) {
@@ -10436,6 +10618,12 @@ class Tree extends ComponentRender {
10436
10618
  event, element, component: this, node,
10437
10619
  });
10438
10620
  }
10621
+ /** Triggers when a node has been checked/unchecked */
10622
+ nodeCheck(node, event, element) {
10623
+ this.callEvent('onNodeCheck', {
10624
+ event, element, component: this, node,
10625
+ });
10626
+ }
10439
10627
  clearSelection(nodes) {
10440
10628
  const nodesArray = nodes || this.nodes;
10441
10629
  nodesArray.forEach((node) => {
@@ -10445,6 +10633,19 @@ class Tree extends ComponentRender {
10445
10633
  }
10446
10634
  });
10447
10635
  }
10636
+ getNode(path) {
10637
+ return this.searchPath(this.nodes, path);
10638
+ }
10639
+ getParentNode(node) {
10640
+ var _a;
10641
+ return this.tree.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10642
+ }
10643
+ searchPath(nodes, path) {
10644
+ const currentNode = (path[0] > -1 && path[0] < nodes.length) ? nodes[path[0]] : undefined;
10645
+ if (currentNode && path.length > 1)
10646
+ return this.searchPath(currentNode.children || [], path.slice(1));
10647
+ return currentNode;
10648
+ }
10448
10649
  }
10449
10650
 
10450
10651
  /**
@@ -10632,6 +10833,7 @@ class TreeGridEditable extends TreeGrid {
10632
10833
  },
10633
10834
  };
10634
10835
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
10836
+ this.noDataSlot = this.changeDefaultSlotNames(this.noDataSlot);
10635
10837
  this.createAccessors();
10636
10838
  }
10637
10839
  onMounted(element) {
@@ -11182,15 +11384,23 @@ const defaultTheme = {
11182
11384
  zeedhi: {
11183
11385
  light: {
11184
11386
  'font-color': 'var(--v-grey-darken2)',
11185
- 'background-base': '#F6F6F6',
11387
+ 'background-base': '#FDFDFD',
11388
+ 'background-base-2': '#F6F6F6',
11389
+ 'background-base-3': '#EEE',
11186
11390
  'scrollbar-track': 'var(--v-grey-lighten5)',
11187
11391
  'scrollbar-thumb': 'var(--v-grey-lighten4)',
11392
+ 'badge-background-color': '#f44336',
11393
+ 'badge-text-color': '#fff',
11188
11394
  },
11189
11395
  dark: {
11190
11396
  'font-color': 'var(--v-grey-lighten3)',
11191
- 'background-base': '#121212',
11397
+ 'background-base': '#1E1E1E',
11398
+ 'background-base-2': 'var(--v-grey-darken2)',
11399
+ 'background-base-3': 'var(--v-grey-darken4)',
11192
11400
  'scrollbar-track': 'var(--v-grey-darken3)',
11193
11401
  'scrollbar-thumb': 'var(--v-grey-base)',
11402
+ 'badge-background-color': '#f44336',
11403
+ 'badge-text-color': '#fff',
11194
11404
  },
11195
11405
  variables: {
11196
11406
  'default-padding': '16px',
@@ -11208,8 +11418,6 @@ const defaultTheme = {
11208
11418
  'font-body4-weight': '500',
11209
11419
  'font-caption-size': '11px',
11210
11420
  'font-caption-weight': '400',
11211
- 'badge-background-color': '#f44336',
11212
- 'badge-text-color': '#fff',
11213
11421
  },
11214
11422
  },
11215
11423
  };