@zeedhi/common 1.45.0 → 1.47.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.
@@ -1,4 +1,4 @@
1
- import { AccessorManager, Event, KeyMap, Metadata, FormatterParserProvider, Validation, Accessor, DatasourceFactory, I18n, MethodNotAssignedError, Loader, Mask, Config, dayjs, Utils, Router, InstanceNotFoundError, Http, Cookie, URL as URL$1 } from '@zeedhi/core';
1
+ import { AccessorManager, Event, KeyMap, Metadata, FormatterParserProvider, Validation, Accessor, DatasourceFactory, I18n, MethodNotAssignedError, Loader, Mask, Config, dayjs, DateHelper, Utils, Router, InstanceNotFoundError, Http, Cookie, URL as URL$1 } from '@zeedhi/core';
2
2
  import merge from 'lodash.merge';
3
3
  import debounce from 'lodash.debounce';
4
4
  import isUndefined from 'lodash.isundefined';
@@ -495,7 +495,7 @@ class ApexChart extends ComponentRender {
495
495
  * @param options New options
496
496
  */
497
497
  updateChart(options) {
498
- this.options = Object.assign(Object.assign({}, this.options), options);
498
+ merge(this.options, options);
499
499
  if (options.series) {
500
500
  this.series = this.options.series;
501
501
  }
@@ -1757,7 +1757,8 @@ class Input extends ComponentRender {
1757
1757
  * Removes all input validation.
1758
1758
  */
1759
1759
  clearValidations() {
1760
- Object.keys(this.validations).forEach((name) => this.removeValidation(name));
1760
+ this.validations = {};
1761
+ this.rules = [];
1761
1762
  }
1762
1763
  /**
1763
1764
  * Updates input rules.
@@ -3315,6 +3316,14 @@ class Date$1 extends TextInput {
3315
3316
  * Determines the type of the picker - date for date picker, month for month picker.
3316
3317
  */
3317
3318
  this.pickerType = 'date';
3319
+ /**
3320
+ * Helper options.
3321
+ */
3322
+ this.helperOptions = [];
3323
+ /**
3324
+ * Helper value.
3325
+ */
3326
+ this.helperValue = '';
3318
3327
  /**
3319
3328
  * Width of the picker.
3320
3329
  */
@@ -3323,6 +3332,8 @@ class Date$1 extends TextInput {
3323
3332
  this.dateError = false;
3324
3333
  this.formatterFn = FormatterParserProvider.getFormatter('ZdDate');
3325
3334
  this.parserFn = FormatterParserProvider.getParser('ZdDate');
3335
+ this.previousHint = '';
3336
+ this.previousPersistentHint = false;
3326
3337
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3327
3338
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3328
3339
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -3338,6 +3349,8 @@ class Date$1 extends TextInput {
3338
3349
  this.showDatePicker = this.getInitValue('showDatePicker', props.showDatePicker, this.showDatePicker);
3339
3350
  this.showWeek = this.getInitValue('showWeek', props.showWeek, this.showWeek);
3340
3351
  this.pickerType = this.getInitValue('pickerType', props.pickerType, this.pickerType);
3352
+ this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3353
+ this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3341
3354
  if (this.pickerType === 'month') {
3342
3355
  this.isoFormat = 'YYYY-MM';
3343
3356
  }
@@ -3514,6 +3527,20 @@ class Date$1 extends TextInput {
3514
3527
  const chars = replaced.split('');
3515
3528
  return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
3516
3529
  }
3530
+ updateHelperHint() {
3531
+ if (this.helperValue) {
3532
+ this.previousHint = this.hint;
3533
+ this.previousPersistentHint = this.persistentHint;
3534
+ this.hint = DateHelper.getLabel(this.helperValue);
3535
+ this.persistentHint = true;
3536
+ }
3537
+ }
3538
+ change(event, element) {
3539
+ super.change(event, element);
3540
+ this.helperValue = '';
3541
+ this.hint = this.previousHint;
3542
+ this.persistentHint = this.previousPersistentHint;
3543
+ }
3517
3544
  }
3518
3545
  FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = Config.dateFormat, displayFormat = Config.displayFormat, inputFormat = Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
3519
3546
  if (!value) {
@@ -3643,10 +3670,20 @@ class DateRange extends TextInput {
3643
3670
  * Width of the picker.
3644
3671
  */
3645
3672
  this.width = 248;
3673
+ /**
3674
+ * Helper options.
3675
+ */
3676
+ this.helperOptions = [];
3677
+ /**
3678
+ * Helper value.
3679
+ */
3680
+ this.helperValue = '';
3646
3681
  this.isoFormat = 'YYYY-MM-DD';
3647
3682
  this.dateError = false;
3648
3683
  this.formatterFn = FormatterParserProvider.getFormatter('ZdDateRange');
3649
3684
  this.parserFn = FormatterParserProvider.getParser('ZdDateRange');
3685
+ this.previousHint = '';
3686
+ this.previousPersistentHint = false;
3650
3687
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3651
3688
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
3652
3689
  this.dateFormat = this.getInitValue('dateFormat', props.dateFormat, this.dateFormat);
@@ -3662,6 +3699,8 @@ class DateRange extends TextInput {
3662
3699
  this.splitter = this.getInitValue('splitter', props.splitter, this.splitter);
3663
3700
  this.width = this.getInitValue('width', props.width, this.width);
3664
3701
  this.mask = this.getInitValue('mask', props.mask, undefined);
3702
+ this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3703
+ this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3665
3704
  this.createAccessors();
3666
3705
  this.unitMask = this.mask;
3667
3706
  this.initialMask = this.getInitialMask();
@@ -3865,6 +3904,20 @@ class DateRange extends TextInput {
3865
3904
  const chars = replaced.split('');
3866
3905
  return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
3867
3906
  }
3907
+ updateHelperHint() {
3908
+ if (this.helperValue) {
3909
+ this.previousHint = this.hint;
3910
+ this.previousPersistentHint = this.persistentHint;
3911
+ this.hint = DateHelper.getLabel(this.helperValue);
3912
+ this.persistentHint = true;
3913
+ }
3914
+ }
3915
+ change(event, element) {
3916
+ super.change(event, element);
3917
+ this.helperValue = '';
3918
+ this.hint = this.previousHint;
3919
+ this.persistentHint = this.previousPersistentHint;
3920
+ }
3868
3921
  }
3869
3922
  FormatterParserProvider.registerFormatter('ZdDateRange', (value, { dateFormat = Config.dateFormat, displayFormat = Config.displayFormat, inputFormat = Config.dateInputFormat, initialMask, splitter = ' ~ ', unitMask = '', mask = '', isSimpleDisplay = false, } = {}) => {
3870
3923
  if (!value || value.length === 0 || (value.length === 1 && !value[0])) {
@@ -4947,6 +5000,9 @@ class Grid extends Iterable {
4947
5000
  this.toolbarSlot = [
4948
5001
  { name: '<<NAME>>_gridSearch', component: 'ZdSearch' },
4949
5002
  ];
5003
+ this.loadingText = 'LOADING';
5004
+ this.noDataText = 'NO_DATA';
5005
+ this.noResultsText = 'NO_RESULT';
4950
5006
  /**
4951
5007
  * Components that will be rendered in no-data case
4952
5008
  */
@@ -4955,7 +5011,7 @@ class Grid extends Iterable {
4955
5011
  name: '<<NAME>>_no-data',
4956
5012
  component: 'ZdText',
4957
5013
  cssClass: 'no-data',
4958
- text: 'NO_DATA',
5014
+ text: this.noDataText,
4959
5015
  },
4960
5016
  ];
4961
5017
  /**
@@ -4966,7 +5022,7 @@ class Grid extends Iterable {
4966
5022
  name: '<<NAME>>_no-result',
4967
5023
  component: 'ZdText',
4968
5024
  cssClass: 'no-result',
4969
- text: 'NO_RESULT',
5025
+ text: this.noResultsText,
4970
5026
  },
4971
5027
  ];
4972
5028
  /**
@@ -5070,6 +5126,7 @@ class Grid extends Iterable {
5070
5126
  this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
5071
5127
  this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
5072
5128
  this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
5129
+ this.loadingText = this.getInitValue('loadingText', props.loadingText, this.loadingText);
5073
5130
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
5074
5131
  this.footerSlot = props.footerSlot || this.footerSlot;
5075
5132
  this.noDataSlot = props.noDataSlot || this.noDataSlot;
@@ -5079,6 +5136,8 @@ class Grid extends Iterable {
5079
5136
  this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
5080
5137
  this.toolbarSlot = this.changeDefaultSlotNames(this.toolbarSlot);
5081
5138
  this.noResultSlot = this.changeDefaultSlotNames(this.noResultSlot);
5139
+ this.noDataText = this.getInitValue('noDataText', props.noDataText, this.noDataText);
5140
+ this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
5082
5141
  this.createAccessors();
5083
5142
  }
5084
5143
  onMounted(element) {
@@ -8267,6 +8326,12 @@ class RangeSlider extends Input {
8267
8326
  this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
8268
8327
  this.createAccessors();
8269
8328
  }
8329
+ get value() {
8330
+ return this.rangeSliderValue === null ? undefined : this.rangeSliderValue;
8331
+ }
8332
+ set value(value) {
8333
+ this.rangeSliderValue = value;
8334
+ }
8270
8335
  }
8271
8336
 
8272
8337
  /**
@@ -8310,11 +8375,16 @@ class SelectMultiple extends Select {
8310
8375
  * Number of hidden items
8311
8376
  */
8312
8377
  this.moreChip = 0;
8378
+ /**
8379
+ * Max number of rows the component can have
8380
+ */
8381
+ this.maxRows = undefined;
8313
8382
  this.showSelectAll = false;
8314
8383
  if (!this.selectedValue) {
8315
8384
  this.selectedValue = [];
8316
8385
  }
8317
8386
  this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
8387
+ this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
8318
8388
  this.createAccessors();
8319
8389
  }
8320
8390
  afterFocus() {
@@ -8490,6 +8560,21 @@ class SelectMultiple extends Select {
8490
8560
  removePushedValue() {
8491
8561
  this.removeInserts();
8492
8562
  }
8563
+ doSearch(value) {
8564
+ return __awaiter(this, void 0, void 0, function* () {
8565
+ if (this.manualMode || value) {
8566
+ yield this.updateSearch(value);
8567
+ }
8568
+ else {
8569
+ if (!this.manualMode) {
8570
+ this.datasource.data = [...this.cachedData];
8571
+ this.datasource.total = this.cachedTotal;
8572
+ }
8573
+ this.removeInserts();
8574
+ this.insertSelected();
8575
+ }
8576
+ });
8577
+ }
8493
8578
  /**
8494
8579
  * Removes unselected inserts from datasource
8495
8580
  */
@@ -9756,13 +9841,26 @@ class Tabs extends ComponentRender {
9756
9841
  */
9757
9842
  constructor(props) {
9758
9843
  super(props);
9759
- this.activeTab = 0;
9844
+ this.activeTabValue = 0;
9760
9845
  this.tabs = [];
9761
9846
  this.tabs = this.getTabs(props.tabs || []);
9762
- this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTab);
9847
+ this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
9763
9848
  this.height = this.getInitValue('height', props.height, this.height);
9764
9849
  this.createAccessors();
9765
9850
  }
9851
+ get activeTab() {
9852
+ var _a;
9853
+ if (this.activeTabValue >= 0 && !((_a = this.tabs[this.activeTabValue]) === null || _a === void 0 ? void 0 : _a.isVisible)) {
9854
+ const firstTabIndex = this.tabs.findIndex((tab) => tab.isVisible);
9855
+ if (firstTabIndex > -1) {
9856
+ this.activeTabValue = firstTabIndex;
9857
+ }
9858
+ }
9859
+ return this.activeTabValue;
9860
+ }
9861
+ set activeTab(index) {
9862
+ this.activeTabValue = index;
9863
+ }
9766
9864
  getTabs(tabs) {
9767
9865
  return tabs.map((tab) => new Tab(tab));
9768
9866
  }
@@ -10296,6 +10394,8 @@ class Tree extends ComponentRender {
10296
10394
  this.titleField = '';
10297
10395
  /** Datasource data field */
10298
10396
  this.dataField = '';
10397
+ /** Datasource checked field */
10398
+ this.checkedField = 'checked';
10299
10399
  /**
10300
10400
  * Defines if the tree will be opened or not (true/false) or if it should open only until a specific level
10301
10401
  */
@@ -10314,7 +10414,6 @@ class Tree extends ComponentRender {
10314
10414
  this.appliedConditions = {};
10315
10415
  /* Conditions of tree */
10316
10416
  this.factoredConditions = {};
10317
- this.nodes = this.initNodes(props.nodes || this.nodes);
10318
10417
  this.itemIconName = this.getInitValue('itemIconName', props.itemIconName, this.itemIconName);
10319
10418
  this.groupIconName = this.getInitValue('groupIconName', props.groupIconName, this.groupIconName);
10320
10419
  this.openedIconName = this.getInitValue('openedIconName', props.openedIconName, this.openedIconName);
@@ -10324,6 +10423,7 @@ class Tree extends ComponentRender {
10324
10423
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10325
10424
  this.titleField = this.getInitValue('titleField', props.titleField, this.titleField);
10326
10425
  this.dataField = this.getInitValue('dataField', props.dataField, this.dataField);
10426
+ this.checkedField = this.getInitValue('checkedField', props.checkedField, this.checkedField);
10327
10427
  this.openLevelOnLoad = this.getInitValue('openLevelOnLoad', props.openLevelOnLoad, this.openLevelOnLoad);
10328
10428
  this.checkbox = this.getInitValue('checkbox', props.checkbox, this.checkbox);
10329
10429
  this.afterTitleSlot = props.afterTitleSlot || this.afterTitleSlot;
@@ -10341,29 +10441,46 @@ class Tree extends ComponentRender {
10341
10441
  this.createDataStructure();
10342
10442
  }
10343
10443
  this.createAccessors();
10444
+ this.nodes = props.nodes || this.nodes;
10344
10445
  }
10345
10446
  /**
10346
10447
  * Initialize all the properties of the declared nodes (reactivity)
10347
10448
  */
10348
- initNodes(nodes) {
10349
- return nodes.map((node) => (Object.assign(Object.assign({ isLeaf: false, isExpanded: true, isSelected: false, isDraggable: true, isSelectable: true, isChecked: false }, node), { children: this.initNodes(node.children || []) })));
10449
+ initNodes(nodes, override) {
10450
+ return nodes.map((node) => {
10451
+ let newNode = {
10452
+ title: '',
10453
+ isLeaf: false,
10454
+ isExpanded: true,
10455
+ isSelected: false,
10456
+ isDraggable: true,
10457
+ isSelectable: true,
10458
+ data: {
10459
+ [this.checkedField]: false,
10460
+ },
10461
+ children: [],
10462
+ };
10463
+ newNode = merge(newNode, node, override);
10464
+ newNode.children = this.initNodes(node.children || [], override);
10465
+ return newNode;
10466
+ });
10350
10467
  }
10351
10468
  /** Nodes */
10352
10469
  get nodes() {
10353
10470
  return this.nodesValue;
10354
10471
  }
10355
10472
  set nodes(value) {
10473
+ let override = {};
10356
10474
  if (!this.allowDragDrop) {
10357
- this.removeDraggable(value);
10475
+ override = { isDraggable: false };
10358
10476
  }
10359
- this.nodesValue = value;
10477
+ this.nodesValue = this.initNodes(value, override);
10360
10478
  }
10361
10479
  getCheckedNodes() {
10362
10480
  const selectedNodes = [];
10363
10481
  this.tree.traverse((node) => {
10364
- const instanceNode = this.getNode(node.path || []);
10365
- if (instanceNode === null || instanceNode === void 0 ? void 0 : instanceNode.isChecked) {
10366
- selectedNodes.push(instanceNode);
10482
+ if (node.data && node.data[this.checkedField]) {
10483
+ selectedNodes.push(node);
10367
10484
  }
10368
10485
  });
10369
10486
  return selectedNodes;
@@ -10416,15 +10533,16 @@ class Tree extends ComponentRender {
10416
10533
  }
10417
10534
  /** Insert nodes by the current cursor position */
10418
10535
  insertNode(newNode) {
10536
+ const initNode = this.initNodes([newNode])[0];
10419
10537
  if (this.selectedNodes.length) {
10420
10538
  const cursorPosition = {
10421
10539
  node: this.selectedNodes[0],
10422
10540
  placement: 'inside',
10423
10541
  };
10424
- this.tree.insert(cursorPosition, newNode);
10542
+ this.tree.insert(cursorPosition, initNode);
10425
10543
  }
10426
10544
  else {
10427
- this.nodes.push(newNode);
10545
+ this.nodes.push(initNode);
10428
10546
  }
10429
10547
  }
10430
10548
  importNodes(nodes) {
@@ -10454,15 +10572,6 @@ class Tree extends ComponentRender {
10454
10572
  updateNodeData(node, value) {
10455
10573
  this.tree.updateNode(node.path, value);
10456
10574
  }
10457
- removeDraggable(items) {
10458
- items.forEach((item) => {
10459
- var _a;
10460
- item.isDraggable = false;
10461
- if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
10462
- this.removeDraggable(item.children);
10463
- }
10464
- });
10465
- }
10466
10575
  setTree(tree) {
10467
10576
  this.tree = tree;
10468
10577
  }
@@ -10594,7 +10703,7 @@ class Tree extends ComponentRender {
10594
10703
  }
10595
10704
  getParentNode(node) {
10596
10705
  var _a;
10597
- return this.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10706
+ return this.tree.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10598
10707
  }
10599
10708
  searchPath(nodes, path) {
10600
10709
  const currentNode = (path[0] > -1 && path[0] < nodes.length) ? nodes[path[0]] : undefined;
@@ -10789,6 +10898,7 @@ class TreeGridEditable extends TreeGrid {
10789
10898
  },
10790
10899
  };
10791
10900
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
10901
+ this.noDataSlot = this.changeDefaultSlotNames(this.noDataSlot);
10792
10902
  this.createAccessors();
10793
10903
  }
10794
10904
  onMounted(element) {
@@ -502,7 +502,7 @@
502
502
  * @param options New options
503
503
  */
504
504
  updateChart(options) {
505
- this.options = Object.assign(Object.assign({}, this.options), options);
505
+ merge__default["default"](this.options, options);
506
506
  if (options.series) {
507
507
  this.series = this.options.series;
508
508
  }
@@ -1764,7 +1764,8 @@
1764
1764
  * Removes all input validation.
1765
1765
  */
1766
1766
  clearValidations() {
1767
- Object.keys(this.validations).forEach((name) => this.removeValidation(name));
1767
+ this.validations = {};
1768
+ this.rules = [];
1768
1769
  }
1769
1770
  /**
1770
1771
  * Updates input rules.
@@ -3322,6 +3323,14 @@
3322
3323
  * Determines the type of the picker - date for date picker, month for month picker.
3323
3324
  */
3324
3325
  this.pickerType = 'date';
3326
+ /**
3327
+ * Helper options.
3328
+ */
3329
+ this.helperOptions = [];
3330
+ /**
3331
+ * Helper value.
3332
+ */
3333
+ this.helperValue = '';
3325
3334
  /**
3326
3335
  * Width of the picker.
3327
3336
  */
@@ -3330,6 +3339,8 @@
3330
3339
  this.dateError = false;
3331
3340
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdDate');
3332
3341
  this.parserFn = core.FormatterParserProvider.getParser('ZdDate');
3342
+ this.previousHint = '';
3343
+ this.previousPersistentHint = false;
3333
3344
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3334
3345
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3335
3346
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -3345,6 +3356,8 @@
3345
3356
  this.showDatePicker = this.getInitValue('showDatePicker', props.showDatePicker, this.showDatePicker);
3346
3357
  this.showWeek = this.getInitValue('showWeek', props.showWeek, this.showWeek);
3347
3358
  this.pickerType = this.getInitValue('pickerType', props.pickerType, this.pickerType);
3359
+ this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3360
+ this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3348
3361
  if (this.pickerType === 'month') {
3349
3362
  this.isoFormat = 'YYYY-MM';
3350
3363
  }
@@ -3521,6 +3534,20 @@
3521
3534
  const chars = replaced.split('');
3522
3535
  return chars.length ? chars.every((char) => core.Mask.isMaskDelimiter(char)) : true;
3523
3536
  }
3537
+ updateHelperHint() {
3538
+ if (this.helperValue) {
3539
+ this.previousHint = this.hint;
3540
+ this.previousPersistentHint = this.persistentHint;
3541
+ this.hint = core.DateHelper.getLabel(this.helperValue);
3542
+ this.persistentHint = true;
3543
+ }
3544
+ }
3545
+ change(event, element) {
3546
+ super.change(event, element);
3547
+ this.helperValue = '';
3548
+ this.hint = this.previousHint;
3549
+ this.persistentHint = this.previousPersistentHint;
3550
+ }
3524
3551
  }
3525
3552
  core.FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = core.Config.dateFormat, displayFormat = core.Config.displayFormat, inputFormat = core.Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
3526
3553
  if (!value) {
@@ -3650,10 +3677,20 @@
3650
3677
  * Width of the picker.
3651
3678
  */
3652
3679
  this.width = 248;
3680
+ /**
3681
+ * Helper options.
3682
+ */
3683
+ this.helperOptions = [];
3684
+ /**
3685
+ * Helper value.
3686
+ */
3687
+ this.helperValue = '';
3653
3688
  this.isoFormat = 'YYYY-MM-DD';
3654
3689
  this.dateError = false;
3655
3690
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdDateRange');
3656
3691
  this.parserFn = core.FormatterParserProvider.getParser('ZdDateRange');
3692
+ this.previousHint = '';
3693
+ this.previousPersistentHint = false;
3657
3694
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3658
3695
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
3659
3696
  this.dateFormat = this.getInitValue('dateFormat', props.dateFormat, this.dateFormat);
@@ -3669,6 +3706,8 @@
3669
3706
  this.splitter = this.getInitValue('splitter', props.splitter, this.splitter);
3670
3707
  this.width = this.getInitValue('width', props.width, this.width);
3671
3708
  this.mask = this.getInitValue('mask', props.mask, undefined);
3709
+ this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3710
+ this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3672
3711
  this.createAccessors();
3673
3712
  this.unitMask = this.mask;
3674
3713
  this.initialMask = this.getInitialMask();
@@ -3872,6 +3911,20 @@
3872
3911
  const chars = replaced.split('');
3873
3912
  return chars.length ? chars.every((char) => core.Mask.isMaskDelimiter(char)) : true;
3874
3913
  }
3914
+ updateHelperHint() {
3915
+ if (this.helperValue) {
3916
+ this.previousHint = this.hint;
3917
+ this.previousPersistentHint = this.persistentHint;
3918
+ this.hint = core.DateHelper.getLabel(this.helperValue);
3919
+ this.persistentHint = true;
3920
+ }
3921
+ }
3922
+ change(event, element) {
3923
+ super.change(event, element);
3924
+ this.helperValue = '';
3925
+ this.hint = this.previousHint;
3926
+ this.persistentHint = this.previousPersistentHint;
3927
+ }
3875
3928
  }
3876
3929
  core.FormatterParserProvider.registerFormatter('ZdDateRange', (value, { dateFormat = core.Config.dateFormat, displayFormat = core.Config.displayFormat, inputFormat = core.Config.dateInputFormat, initialMask, splitter = ' ~ ', unitMask = '', mask = '', isSimpleDisplay = false, } = {}) => {
3877
3930
  if (!value || value.length === 0 || (value.length === 1 && !value[0])) {
@@ -4954,6 +5007,9 @@
4954
5007
  this.toolbarSlot = [
4955
5008
  { name: '<<NAME>>_gridSearch', component: 'ZdSearch' },
4956
5009
  ];
5010
+ this.loadingText = 'LOADING';
5011
+ this.noDataText = 'NO_DATA';
5012
+ this.noResultsText = 'NO_RESULT';
4957
5013
  /**
4958
5014
  * Components that will be rendered in no-data case
4959
5015
  */
@@ -4962,7 +5018,7 @@
4962
5018
  name: '<<NAME>>_no-data',
4963
5019
  component: 'ZdText',
4964
5020
  cssClass: 'no-data',
4965
- text: 'NO_DATA',
5021
+ text: this.noDataText,
4966
5022
  },
4967
5023
  ];
4968
5024
  /**
@@ -4973,7 +5029,7 @@
4973
5029
  name: '<<NAME>>_no-result',
4974
5030
  component: 'ZdText',
4975
5031
  cssClass: 'no-result',
4976
- text: 'NO_RESULT',
5032
+ text: this.noResultsText,
4977
5033
  },
4978
5034
  ];
4979
5035
  /**
@@ -5077,6 +5133,7 @@
5077
5133
  this.headerCellTextColor = this.getInitValue('headerCellTextColor', props.headerCellTextColor, this.headerCellTextColor);
5078
5134
  this.dragColumns = this.getInitValue('dragColumns', props.dragColumns, this.dragColumns);
5079
5135
  this.resizeColumns = this.getInitValue('resizeColumns', props.resizeColumns, this.resizeColumns);
5136
+ this.loadingText = this.getInitValue('loadingText', props.loadingText, this.loadingText);
5080
5137
  this.toolbarSlot = props.toolbarSlot || this.toolbarSlot;
5081
5138
  this.footerSlot = props.footerSlot || this.footerSlot;
5082
5139
  this.noDataSlot = props.noDataSlot || this.noDataSlot;
@@ -5086,6 +5143,8 @@
5086
5143
  this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
5087
5144
  this.toolbarSlot = this.changeDefaultSlotNames(this.toolbarSlot);
5088
5145
  this.noResultSlot = this.changeDefaultSlotNames(this.noResultSlot);
5146
+ this.noDataText = this.getInitValue('noDataText', props.noDataText, this.noDataText);
5147
+ this.noResultsText = this.getInitValue('noResultsText', props.noResultsText, this.noResultsText);
5089
5148
  this.createAccessors();
5090
5149
  }
5091
5150
  onMounted(element) {
@@ -8274,6 +8333,12 @@
8274
8333
  this.vertical = this.getInitValue('vertical', props.vertical, this.vertical);
8275
8334
  this.createAccessors();
8276
8335
  }
8336
+ get value() {
8337
+ return this.rangeSliderValue === null ? undefined : this.rangeSliderValue;
8338
+ }
8339
+ set value(value) {
8340
+ this.rangeSliderValue = value;
8341
+ }
8277
8342
  }
8278
8343
 
8279
8344
  /**
@@ -8317,11 +8382,16 @@
8317
8382
  * Number of hidden items
8318
8383
  */
8319
8384
  this.moreChip = 0;
8385
+ /**
8386
+ * Max number of rows the component can have
8387
+ */
8388
+ this.maxRows = undefined;
8320
8389
  this.showSelectAll = false;
8321
8390
  if (!this.selectedValue) {
8322
8391
  this.selectedValue = [];
8323
8392
  }
8324
8393
  this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
8394
+ this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
8325
8395
  this.createAccessors();
8326
8396
  }
8327
8397
  afterFocus() {
@@ -8497,6 +8567,21 @@
8497
8567
  removePushedValue() {
8498
8568
  this.removeInserts();
8499
8569
  }
8570
+ doSearch(value) {
8571
+ return __awaiter(this, void 0, void 0, function* () {
8572
+ if (this.manualMode || value) {
8573
+ yield this.updateSearch(value);
8574
+ }
8575
+ else {
8576
+ if (!this.manualMode) {
8577
+ this.datasource.data = [...this.cachedData];
8578
+ this.datasource.total = this.cachedTotal;
8579
+ }
8580
+ this.removeInserts();
8581
+ this.insertSelected();
8582
+ }
8583
+ });
8584
+ }
8500
8585
  /**
8501
8586
  * Removes unselected inserts from datasource
8502
8587
  */
@@ -9763,13 +9848,26 @@
9763
9848
  */
9764
9849
  constructor(props) {
9765
9850
  super(props);
9766
- this.activeTab = 0;
9851
+ this.activeTabValue = 0;
9767
9852
  this.tabs = [];
9768
9853
  this.tabs = this.getTabs(props.tabs || []);
9769
- this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTab);
9854
+ this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
9770
9855
  this.height = this.getInitValue('height', props.height, this.height);
9771
9856
  this.createAccessors();
9772
9857
  }
9858
+ get activeTab() {
9859
+ var _a;
9860
+ if (this.activeTabValue >= 0 && !((_a = this.tabs[this.activeTabValue]) === null || _a === void 0 ? void 0 : _a.isVisible)) {
9861
+ const firstTabIndex = this.tabs.findIndex((tab) => tab.isVisible);
9862
+ if (firstTabIndex > -1) {
9863
+ this.activeTabValue = firstTabIndex;
9864
+ }
9865
+ }
9866
+ return this.activeTabValue;
9867
+ }
9868
+ set activeTab(index) {
9869
+ this.activeTabValue = index;
9870
+ }
9773
9871
  getTabs(tabs) {
9774
9872
  return tabs.map((tab) => new Tab(tab));
9775
9873
  }
@@ -10303,6 +10401,8 @@
10303
10401
  this.titleField = '';
10304
10402
  /** Datasource data field */
10305
10403
  this.dataField = '';
10404
+ /** Datasource checked field */
10405
+ this.checkedField = 'checked';
10306
10406
  /**
10307
10407
  * Defines if the tree will be opened or not (true/false) or if it should open only until a specific level
10308
10408
  */
@@ -10321,7 +10421,6 @@
10321
10421
  this.appliedConditions = {};
10322
10422
  /* Conditions of tree */
10323
10423
  this.factoredConditions = {};
10324
- this.nodes = this.initNodes(props.nodes || this.nodes);
10325
10424
  this.itemIconName = this.getInitValue('itemIconName', props.itemIconName, this.itemIconName);
10326
10425
  this.groupIconName = this.getInitValue('groupIconName', props.groupIconName, this.groupIconName);
10327
10426
  this.openedIconName = this.getInitValue('openedIconName', props.openedIconName, this.openedIconName);
@@ -10331,6 +10430,7 @@
10331
10430
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
10332
10431
  this.titleField = this.getInitValue('titleField', props.titleField, this.titleField);
10333
10432
  this.dataField = this.getInitValue('dataField', props.dataField, this.dataField);
10433
+ this.checkedField = this.getInitValue('checkedField', props.checkedField, this.checkedField);
10334
10434
  this.openLevelOnLoad = this.getInitValue('openLevelOnLoad', props.openLevelOnLoad, this.openLevelOnLoad);
10335
10435
  this.checkbox = this.getInitValue('checkbox', props.checkbox, this.checkbox);
10336
10436
  this.afterTitleSlot = props.afterTitleSlot || this.afterTitleSlot;
@@ -10348,29 +10448,46 @@
10348
10448
  this.createDataStructure();
10349
10449
  }
10350
10450
  this.createAccessors();
10451
+ this.nodes = props.nodes || this.nodes;
10351
10452
  }
10352
10453
  /**
10353
10454
  * Initialize all the properties of the declared nodes (reactivity)
10354
10455
  */
10355
- initNodes(nodes) {
10356
- return nodes.map((node) => (Object.assign(Object.assign({ isLeaf: false, isExpanded: true, isSelected: false, isDraggable: true, isSelectable: true, isChecked: false }, node), { children: this.initNodes(node.children || []) })));
10456
+ initNodes(nodes, override) {
10457
+ return nodes.map((node) => {
10458
+ let newNode = {
10459
+ title: '',
10460
+ isLeaf: false,
10461
+ isExpanded: true,
10462
+ isSelected: false,
10463
+ isDraggable: true,
10464
+ isSelectable: true,
10465
+ data: {
10466
+ [this.checkedField]: false,
10467
+ },
10468
+ children: [],
10469
+ };
10470
+ newNode = merge__default["default"](newNode, node, override);
10471
+ newNode.children = this.initNodes(node.children || [], override);
10472
+ return newNode;
10473
+ });
10357
10474
  }
10358
10475
  /** Nodes */
10359
10476
  get nodes() {
10360
10477
  return this.nodesValue;
10361
10478
  }
10362
10479
  set nodes(value) {
10480
+ let override = {};
10363
10481
  if (!this.allowDragDrop) {
10364
- this.removeDraggable(value);
10482
+ override = { isDraggable: false };
10365
10483
  }
10366
- this.nodesValue = value;
10484
+ this.nodesValue = this.initNodes(value, override);
10367
10485
  }
10368
10486
  getCheckedNodes() {
10369
10487
  const selectedNodes = [];
10370
10488
  this.tree.traverse((node) => {
10371
- const instanceNode = this.getNode(node.path || []);
10372
- if (instanceNode === null || instanceNode === void 0 ? void 0 : instanceNode.isChecked) {
10373
- selectedNodes.push(instanceNode);
10489
+ if (node.data && node.data[this.checkedField]) {
10490
+ selectedNodes.push(node);
10374
10491
  }
10375
10492
  });
10376
10493
  return selectedNodes;
@@ -10423,15 +10540,16 @@
10423
10540
  }
10424
10541
  /** Insert nodes by the current cursor position */
10425
10542
  insertNode(newNode) {
10543
+ const initNode = this.initNodes([newNode])[0];
10426
10544
  if (this.selectedNodes.length) {
10427
10545
  const cursorPosition = {
10428
10546
  node: this.selectedNodes[0],
10429
10547
  placement: 'inside',
10430
10548
  };
10431
- this.tree.insert(cursorPosition, newNode);
10549
+ this.tree.insert(cursorPosition, initNode);
10432
10550
  }
10433
10551
  else {
10434
- this.nodes.push(newNode);
10552
+ this.nodes.push(initNode);
10435
10553
  }
10436
10554
  }
10437
10555
  importNodes(nodes) {
@@ -10461,15 +10579,6 @@
10461
10579
  updateNodeData(node, value) {
10462
10580
  this.tree.updateNode(node.path, value);
10463
10581
  }
10464
- removeDraggable(items) {
10465
- items.forEach((item) => {
10466
- var _a;
10467
- item.isDraggable = false;
10468
- if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
10469
- this.removeDraggable(item.children);
10470
- }
10471
- });
10472
- }
10473
10582
  setTree(tree) {
10474
10583
  this.tree = tree;
10475
10584
  }
@@ -10601,7 +10710,7 @@
10601
10710
  }
10602
10711
  getParentNode(node) {
10603
10712
  var _a;
10604
- return this.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10713
+ return this.tree.getNode(((_a = node.path) === null || _a === void 0 ? void 0 : _a.slice(0, -1)) || []);
10605
10714
  }
10606
10715
  searchPath(nodes, path) {
10607
10716
  const currentNode = (path[0] > -1 && path[0] < nodes.length) ? nodes[path[0]] : undefined;
@@ -10796,6 +10905,7 @@
10796
10905
  },
10797
10906
  };
10798
10907
  this.doubleClickEdit = this.getInitValue('doubleClickEdit', props.doubleClickEdit, this.doubleClickEdit);
10908
+ this.noDataSlot = this.changeDefaultSlotNames(this.noDataSlot);
10799
10909
  this.createAccessors();
10800
10910
  }
10801
10911
  onMounted(element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.45.0",
3
+ "version": "1.47.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": "b5841549f61c539c52f2438b72e21ccd72156f73"
40
+ "gitHead": "69b4f8f97adbd991270b536b5fa59fa8fa138aa7"
41
41
  }
@@ -53,6 +53,14 @@ export declare class DateRange extends TextInput implements IDateRange {
53
53
  * Width of the picker.
54
54
  */
55
55
  width: number | string;
56
+ /**
57
+ * Helper options.
58
+ */
59
+ helperOptions?: string[];
60
+ /**
61
+ * Helper value.
62
+ */
63
+ helperValue?: string;
56
64
  protected isoFormat: string;
57
65
  protected dateError: boolean;
58
66
  protected formatterFn: Function;
@@ -117,4 +125,8 @@ export declare class DateRange extends TextInput implements IDateRange {
117
125
  * @returns true if it is simple, false otherwise
118
126
  */
119
127
  protected isSimpleFormat(format: string): boolean;
128
+ private previousHint;
129
+ private previousPersistentHint;
130
+ updateHelperHint(): void;
131
+ change(event?: Event, element?: any): void;
120
132
  }
@@ -56,6 +56,14 @@ export declare class Date extends TextInput implements IDate {
56
56
  * Determines the type of the picker - date for date picker, month for month picker.
57
57
  */
58
58
  pickerType: string;
59
+ /**
60
+ * Helper options.
61
+ */
62
+ helperOptions?: string[];
63
+ /**
64
+ * Helper value.
65
+ */
66
+ helperValue?: string;
59
67
  /**
60
68
  * Width of the picker.
61
69
  */
@@ -126,4 +134,8 @@ export declare class Date extends TextInput implements IDate {
126
134
  * @returns true if it is simple, false otherwise
127
135
  */
128
136
  protected isSimpleFormat(format: string): boolean;
137
+ private previousHint;
138
+ private previousPersistentHint;
139
+ updateHelperHint(): void;
140
+ change(event?: Event, element?: any): void;
129
141
  }
@@ -22,6 +22,8 @@ export interface IDate extends ITextInput {
22
22
  showWeek?: boolean;
23
23
  width?: number | string;
24
24
  orderedDates?: boolean;
25
+ helperOptions?: string[];
26
+ helperValue?: string;
25
27
  }
26
28
  export interface IDateRange extends IDate {
27
29
  splitter?: string;
@@ -11,6 +11,9 @@ export declare class Grid extends Iterable implements IGrid {
11
11
  * Components that will be rendered on toolbar slot
12
12
  */
13
13
  toolbarSlot: IComponentRender[];
14
+ loadingText: string;
15
+ noDataText: string;
16
+ noResultsText: string;
14
17
  /**
15
18
  * Components that will be rendered in no-data case
16
19
  */
@@ -163,5 +166,5 @@ export declare class Grid extends Iterable implements IGrid {
163
166
  protected navigatePageDown(): void;
164
167
  deleteRows(): Promise<any[]>;
165
168
  getActionComponent(actionComponent: IComponent, column: GridColumn, row: IDictionary, parentPath?: string): IComponent;
166
- private changeDefaultSlotNames;
169
+ protected changeDefaultSlotNames(slot: IComponentRender[]): IComponentRender[];
167
170
  }
@@ -37,6 +37,9 @@ export interface IGrid extends IIterable {
37
37
  toolbarSlot?: IComponentRender[];
38
38
  dragColumns?: boolean;
39
39
  resizeColumns?: boolean;
40
+ loadingText?: string;
41
+ noDataText?: string;
42
+ noResultsText?: string;
40
43
  }
41
44
  export interface IGridColumn extends IColumn {
42
45
  children?: IChildrenActionColumn[];
@@ -58,9 +58,12 @@ export declare class RangeSlider extends Input implements IRangeSlider {
58
58
  * Defines the range-slider ticks
59
59
  */
60
60
  ticks: IRangeSliderTicks;
61
+ private rangeSliderValue;
61
62
  /**
62
63
  * Create a new Range Slider
63
64
  * @param props Range Slider properties
64
65
  */
65
66
  constructor(props: IRangeSlider);
67
+ get value(): any;
68
+ set value(value: any);
66
69
  }
@@ -176,7 +176,7 @@ export declare class Select extends TextInput implements ISelect {
176
176
  * Update datasource items
177
177
  */
178
178
  updateItems(items: (string | number)[]): Promise<any>;
179
- private doSearch;
179
+ protected doSearch(value: string): Promise<void>;
180
180
  private debounceSearch;
181
181
  /**
182
182
  * Load more data
@@ -11,4 +11,5 @@ export interface ISelectMultiple extends ISelect {
11
11
  moreChip?: number;
12
12
  showSelectAll?: boolean;
13
13
  events?: ISelectMultipleEvents;
14
+ maxRows?: string | number;
14
15
  }
@@ -15,6 +15,10 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
15
15
  * Number of hidden items
16
16
  */
17
17
  moreChip: number;
18
+ /**
19
+ * Max number of rows the component can have
20
+ */
21
+ maxRows?: string | number;
18
22
  protected afterFocus(): Promise<void>;
19
23
  private setCache;
20
24
  showSelectAll: boolean;
@@ -61,6 +65,7 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
61
65
  */
62
66
  private insertSelected;
63
67
  protected removePushedValue(): void;
68
+ protected doSearch(value: string): Promise<void>;
64
69
  /**
65
70
  * Removes unselected inserts from datasource
66
71
  */
@@ -5,7 +5,7 @@ import { ComponentRender } from '../zd-component/component-render';
5
5
  * Base class for Tabs component.
6
6
  */
7
7
  export declare class Tabs extends ComponentRender implements ITabs {
8
- activeTab: number;
8
+ activeTabValue: number;
9
9
  events: ITabsEvents;
10
10
  tabs: Tab[];
11
11
  /**
@@ -17,6 +17,8 @@ export declare class Tabs extends ComponentRender implements ITabs {
17
17
  * @param props Tabs properties
18
18
  */
19
19
  constructor(props: ITabs);
20
+ get activeTab(): number;
21
+ set activeTab(index: number);
20
22
  private getTabs;
21
23
  getTab(name: string): Tab;
22
24
  /**
@@ -9,7 +9,6 @@ export interface ITreeNodeModel<T> {
9
9
  isSelected?: boolean;
10
10
  isDraggable?: boolean;
11
11
  isSelectable?: boolean;
12
- isChecked?: boolean;
13
12
  data?: T;
14
13
  }
15
14
  export interface ITreeNode<T> extends ITreeNodeModel<T> {
@@ -62,6 +61,7 @@ export interface ITree extends IComponentRender {
62
61
  parentField?: string;
63
62
  titleField?: string;
64
63
  dataField?: string;
64
+ checkedField?: string;
65
65
  openLevelOnLoad?: number | boolean;
66
66
  checkbox?: boolean;
67
67
  }
@@ -37,6 +37,8 @@ export declare class Tree extends ComponentRender implements ITree {
37
37
  titleField: string;
38
38
  /** Datasource data field */
39
39
  dataField: string;
40
+ /** Datasource checked field */
41
+ checkedField: string;
40
42
  /**
41
43
  * Defines if the tree will be opened or not (true/false) or if it should open only until a specific level
42
44
  */
@@ -66,11 +68,11 @@ export declare class Tree extends ComponentRender implements ITree {
66
68
  /**
67
69
  * Initialize all the properties of the declared nodes (reactivity)
68
70
  */
69
- protected initNodes(nodes: ITreeNodeModel<IDictionary>[]): ITreeNodeModel<IDictionary>[];
71
+ protected initNodes(nodes: ITreeNodeModel<IDictionary>[], override?: IDictionary): ITreeNodeModel<IDictionary>[];
70
72
  /** Nodes */
71
73
  get nodes(): ITreeNodeModel<IDictionary>[];
72
74
  set nodes(value: ITreeNodeModel<IDictionary>[]);
73
- getCheckedNodes(): ITreeNodeModel<IDictionary<any>>[];
75
+ getCheckedNodes(): ITreeNode<IDictionary<any>>[];
74
76
  /** Returns the selected nodes */
75
77
  get selectedNodes(): ITreeNode<IDictionary>[];
76
78
  private createDataStructure;
@@ -85,7 +87,6 @@ export declare class Tree extends ComponentRender implements ITree {
85
87
  removeSelected(): void;
86
88
  /** Update selected node */
87
89
  updateNodeData(node: ITreeNode<IDictionary>, value: IDictionary): void;
88
- private removeDraggable;
89
90
  setTree(tree: any): void;
90
91
  /**
91
92
  * Return plain conditions object
@@ -110,6 +111,6 @@ export declare class Tree extends ComponentRender implements ITree {
110
111
  nodeCheck(node: ITreeNode<IDictionary>, event?: Event, element?: HTMLElement): void;
111
112
  clearSelection(nodes?: ITreeNodeModel<IDictionary<any>>[]): void;
112
113
  getNode(path: number[]): ITreeNodeModel<IDictionary<any>> | undefined;
113
- getParentNode(node: ITreeNode<IDictionary>): ITreeNodeModel<IDictionary<any>> | undefined;
114
+ getParentNode(node: ITreeNode<IDictionary>): any;
114
115
  private searchPath;
115
116
  }