@zeedhi/common 1.46.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';
@@ -3316,6 +3316,14 @@ class Date$1 extends TextInput {
3316
3316
  * Determines the type of the picker - date for date picker, month for month picker.
3317
3317
  */
3318
3318
  this.pickerType = 'date';
3319
+ /**
3320
+ * Helper options.
3321
+ */
3322
+ this.helperOptions = [];
3323
+ /**
3324
+ * Helper value.
3325
+ */
3326
+ this.helperValue = '';
3319
3327
  /**
3320
3328
  * Width of the picker.
3321
3329
  */
@@ -3324,6 +3332,8 @@ class Date$1 extends TextInput {
3324
3332
  this.dateError = false;
3325
3333
  this.formatterFn = FormatterParserProvider.getFormatter('ZdDate');
3326
3334
  this.parserFn = FormatterParserProvider.getParser('ZdDate');
3335
+ this.previousHint = '';
3336
+ this.previousPersistentHint = false;
3327
3337
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3328
3338
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3329
3339
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -3339,6 +3349,8 @@ class Date$1 extends TextInput {
3339
3349
  this.showDatePicker = this.getInitValue('showDatePicker', props.showDatePicker, this.showDatePicker);
3340
3350
  this.showWeek = this.getInitValue('showWeek', props.showWeek, this.showWeek);
3341
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);
3342
3354
  if (this.pickerType === 'month') {
3343
3355
  this.isoFormat = 'YYYY-MM';
3344
3356
  }
@@ -3515,6 +3527,20 @@ class Date$1 extends TextInput {
3515
3527
  const chars = replaced.split('');
3516
3528
  return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
3517
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
+ }
3518
3544
  }
3519
3545
  FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = Config.dateFormat, displayFormat = Config.displayFormat, inputFormat = Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
3520
3546
  if (!value) {
@@ -3644,10 +3670,20 @@ class DateRange extends TextInput {
3644
3670
  * Width of the picker.
3645
3671
  */
3646
3672
  this.width = 248;
3673
+ /**
3674
+ * Helper options.
3675
+ */
3676
+ this.helperOptions = [];
3677
+ /**
3678
+ * Helper value.
3679
+ */
3680
+ this.helperValue = '';
3647
3681
  this.isoFormat = 'YYYY-MM-DD';
3648
3682
  this.dateError = false;
3649
3683
  this.formatterFn = FormatterParserProvider.getFormatter('ZdDateRange');
3650
3684
  this.parserFn = FormatterParserProvider.getParser('ZdDateRange');
3685
+ this.previousHint = '';
3686
+ this.previousPersistentHint = false;
3651
3687
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3652
3688
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
3653
3689
  this.dateFormat = this.getInitValue('dateFormat', props.dateFormat, this.dateFormat);
@@ -3663,6 +3699,8 @@ class DateRange extends TextInput {
3663
3699
  this.splitter = this.getInitValue('splitter', props.splitter, this.splitter);
3664
3700
  this.width = this.getInitValue('width', props.width, this.width);
3665
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);
3666
3704
  this.createAccessors();
3667
3705
  this.unitMask = this.mask;
3668
3706
  this.initialMask = this.getInitialMask();
@@ -3866,6 +3904,20 @@ class DateRange extends TextInput {
3866
3904
  const chars = replaced.split('');
3867
3905
  return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
3868
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
+ }
3869
3921
  }
3870
3922
  FormatterParserProvider.registerFormatter('ZdDateRange', (value, { dateFormat = Config.dateFormat, displayFormat = Config.displayFormat, inputFormat = Config.dateInputFormat, initialMask, splitter = ' ~ ', unitMask = '', mask = '', isSimpleDisplay = false, } = {}) => {
3871
3923
  if (!value || value.length === 0 || (value.length === 1 && !value[0])) {
@@ -9789,13 +9841,26 @@ class Tabs extends ComponentRender {
9789
9841
  */
9790
9842
  constructor(props) {
9791
9843
  super(props);
9792
- this.activeTab = 0;
9844
+ this.activeTabValue = 0;
9793
9845
  this.tabs = [];
9794
9846
  this.tabs = this.getTabs(props.tabs || []);
9795
- this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTab);
9847
+ this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
9796
9848
  this.height = this.getInitValue('height', props.height, this.height);
9797
9849
  this.createAccessors();
9798
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
+ }
9799
9864
  getTabs(tabs) {
9800
9865
  return tabs.map((tab) => new Tab(tab));
9801
9866
  }
@@ -3323,6 +3323,14 @@
3323
3323
  * Determines the type of the picker - date for date picker, month for month picker.
3324
3324
  */
3325
3325
  this.pickerType = 'date';
3326
+ /**
3327
+ * Helper options.
3328
+ */
3329
+ this.helperOptions = [];
3330
+ /**
3331
+ * Helper value.
3332
+ */
3333
+ this.helperValue = '';
3326
3334
  /**
3327
3335
  * Width of the picker.
3328
3336
  */
@@ -3331,6 +3339,8 @@
3331
3339
  this.dateError = false;
3332
3340
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdDate');
3333
3341
  this.parserFn = core.FormatterParserProvider.getParser('ZdDate');
3342
+ this.previousHint = '';
3343
+ this.previousPersistentHint = false;
3334
3344
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3335
3345
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3336
3346
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -3346,6 +3356,8 @@
3346
3356
  this.showDatePicker = this.getInitValue('showDatePicker', props.showDatePicker, this.showDatePicker);
3347
3357
  this.showWeek = this.getInitValue('showWeek', props.showWeek, this.showWeek);
3348
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);
3349
3361
  if (this.pickerType === 'month') {
3350
3362
  this.isoFormat = 'YYYY-MM';
3351
3363
  }
@@ -3522,6 +3534,20 @@
3522
3534
  const chars = replaced.split('');
3523
3535
  return chars.length ? chars.every((char) => core.Mask.isMaskDelimiter(char)) : true;
3524
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
+ }
3525
3551
  }
3526
3552
  core.FormatterParserProvider.registerFormatter('ZdDate', (value, { dateFormat = core.Config.dateFormat, displayFormat = core.Config.displayFormat, inputFormat = core.Config.dateInputFormat, mask = '', initialMask, isSimpleDisplay = false, } = {}) => {
3527
3553
  if (!value) {
@@ -3651,10 +3677,20 @@
3651
3677
  * Width of the picker.
3652
3678
  */
3653
3679
  this.width = 248;
3680
+ /**
3681
+ * Helper options.
3682
+ */
3683
+ this.helperOptions = [];
3684
+ /**
3685
+ * Helper value.
3686
+ */
3687
+ this.helperValue = '';
3654
3688
  this.isoFormat = 'YYYY-MM-DD';
3655
3689
  this.dateError = false;
3656
3690
  this.formatterFn = core.FormatterParserProvider.getFormatter('ZdDateRange');
3657
3691
  this.parserFn = core.FormatterParserProvider.getParser('ZdDateRange');
3692
+ this.previousHint = '';
3693
+ this.previousPersistentHint = false;
3658
3694
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3659
3695
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
3660
3696
  this.dateFormat = this.getInitValue('dateFormat', props.dateFormat, this.dateFormat);
@@ -3670,6 +3706,8 @@
3670
3706
  this.splitter = this.getInitValue('splitter', props.splitter, this.splitter);
3671
3707
  this.width = this.getInitValue('width', props.width, this.width);
3672
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);
3673
3711
  this.createAccessors();
3674
3712
  this.unitMask = this.mask;
3675
3713
  this.initialMask = this.getInitialMask();
@@ -3873,6 +3911,20 @@
3873
3911
  const chars = replaced.split('');
3874
3912
  return chars.length ? chars.every((char) => core.Mask.isMaskDelimiter(char)) : true;
3875
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
+ }
3876
3928
  }
3877
3929
  core.FormatterParserProvider.registerFormatter('ZdDateRange', (value, { dateFormat = core.Config.dateFormat, displayFormat = core.Config.displayFormat, inputFormat = core.Config.dateInputFormat, initialMask, splitter = ' ~ ', unitMask = '', mask = '', isSimpleDisplay = false, } = {}) => {
3878
3930
  if (!value || value.length === 0 || (value.length === 1 && !value[0])) {
@@ -9796,13 +9848,26 @@
9796
9848
  */
9797
9849
  constructor(props) {
9798
9850
  super(props);
9799
- this.activeTab = 0;
9851
+ this.activeTabValue = 0;
9800
9852
  this.tabs = [];
9801
9853
  this.tabs = this.getTabs(props.tabs || []);
9802
- this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTab);
9854
+ this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
9803
9855
  this.height = this.getInitValue('height', props.height, this.height);
9804
9856
  this.createAccessors();
9805
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
+ }
9806
9871
  getTabs(tabs) {
9807
9872
  return tabs.map((tab) => new Tab(tab));
9808
9873
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.46.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": "0133e8028e0b9b5876c2bb24b9a8c4d687d22dd8"
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;
@@ -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
  /**