@zeedhi/common 1.79.1 → 1.80.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, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
1
+ import { AccessorManager, Event, KeyMap, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, MethodNotAssignedError, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, MemoryDatasource, Cookie, Http, URL as URL$1, VersionService } from '@zeedhi/core';
2
2
  import merge from 'lodash.merge';
3
3
  import cloneDeep from 'lodash.clonedeep';
4
4
  import debounce from 'lodash.debounce';
@@ -3746,6 +3746,14 @@ class Date$1 extends TextInput {
3746
3746
  * Helper value.
3747
3747
  */
3748
3748
  this.helperValue = '';
3749
+ /**
3750
+ * Max value allowed.
3751
+ */
3752
+ this.max = '';
3753
+ /**
3754
+ * Min value allowed.
3755
+ */
3756
+ this.min = '';
3749
3757
  /**
3750
3758
  * Width of the picker.
3751
3759
  */
@@ -3773,6 +3781,8 @@ class Date$1 extends TextInput {
3773
3781
  this.pickerType = this.getInitValue('pickerType', props.pickerType, this.pickerType);
3774
3782
  this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3775
3783
  this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3784
+ this.min = this.getInitValue('min', props.min, this.min);
3785
+ this.max = this.getInitValue('max', props.max, this.max);
3776
3786
  this.width = this.getInitValue('width', props.width, this.width);
3777
3787
  this.mask = this.getInitValue('mask', props.mask, undefined);
3778
3788
  this.createAccessors();
@@ -3856,6 +3866,28 @@ class Date$1 extends TextInput {
3856
3866
  this.value = this.internalValue; // forces value accessor to be called if necessary
3857
3867
  }
3858
3868
  isValidDate(value, format, strict = true) {
3869
+ const date = dayjs(value, format, strict);
3870
+ const isValidFormat = date.isValid();
3871
+ if (!isValidFormat)
3872
+ return false;
3873
+ const minDate = this.min ? dayjs(this.min, this.dateFormat) : null;
3874
+ const isValidMin = !minDate || date.isAfter(minDate) || date.isSame(minDate);
3875
+ if (!isValidMin)
3876
+ return false;
3877
+ const maxDate = this.max ? dayjs(this.max, this.dateFormat) : null;
3878
+ const isValidMax = !maxDate || date.isBefore(maxDate) || date.isSame(maxDate);
3879
+ if (!isValidMax)
3880
+ return false;
3881
+ const isAllowedDate = this.allowedDates === undefined
3882
+ || (this.allowedDates instanceof Function
3883
+ && this.allowedDates(dayjs(value, format).format(this.dateFormat)))
3884
+ || (Array.isArray(this.allowedDates)
3885
+ && this.allowedDates.indexOf(dayjs(value, format).format(this.dateFormat)) !== -1);
3886
+ if (!isAllowedDate)
3887
+ return false;
3888
+ return true;
3889
+ }
3890
+ isValidFormatDate(value, format, strict = true) {
3859
3891
  return dayjs(value, format, strict).isValid();
3860
3892
  }
3861
3893
  get isoValue() {
@@ -3869,13 +3901,13 @@ class Date$1 extends TextInput {
3869
3901
  this.change(this.value);
3870
3902
  }
3871
3903
  formatISODateValue(value) {
3872
- if (value && this.isValidDate(value, this.dateFormat)) {
3904
+ if (value && this.isValidFormatDate(value, this.dateFormat)) {
3873
3905
  return dayjs(value, this.dateFormat).format(this.isoFormat);
3874
3906
  }
3875
3907
  return '';
3876
3908
  }
3877
3909
  parseISODateValue(value) {
3878
- if (value && this.isValidDate(value, this.isoFormat)) {
3910
+ if (value && this.isValidFormatDate(value, this.isoFormat)) {
3879
3911
  return dayjs(value, this.isoFormat).format(this.dateFormat);
3880
3912
  }
3881
3913
  return null;
@@ -4100,6 +4132,14 @@ class DateRange extends TextInput {
4100
4132
  * Helper options.
4101
4133
  */
4102
4134
  this.helperOptions = [];
4135
+ /**
4136
+ * Max value allowed.
4137
+ */
4138
+ this.max = '';
4139
+ /**
4140
+ * Min value allowed.
4141
+ */
4142
+ this.min = '';
4103
4143
  /**
4104
4144
  * Helper value.
4105
4145
  */
@@ -4127,6 +4167,8 @@ class DateRange extends TextInput {
4127
4167
  this.mask = this.getInitValue('mask', props.mask, undefined);
4128
4168
  this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
4129
4169
  this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
4170
+ this.min = this.getInitValue('min', props.min, this.min);
4171
+ this.max = this.getInitValue('max', props.max, this.max);
4130
4172
  this.createAccessors();
4131
4173
  this.unitMask = this.mask;
4132
4174
  this.initialMask = this.getInitialMask();
@@ -4223,6 +4265,21 @@ class DateRange extends TextInput {
4223
4265
  return [value];
4224
4266
  }
4225
4267
  isValidDate(value, format, strict = true) {
4268
+ const date = dayjs(value, format, strict);
4269
+ const isValidFormat = date.isValid();
4270
+ if (!isValidFormat)
4271
+ return false;
4272
+ const minDate = this.min ? dayjs(this.min, this.dateFormat) : null;
4273
+ const isValidMin = !minDate || date.isAfter(minDate) || date.isSame(minDate);
4274
+ if (!isValidMin)
4275
+ return false;
4276
+ const maxDate = this.max ? dayjs(this.max, this.dateFormat) : null;
4277
+ const isValidMax = !maxDate || date.isBefore(maxDate) || date.isSame(maxDate);
4278
+ if (!isValidMax)
4279
+ return false;
4280
+ return true;
4281
+ }
4282
+ isValidFormatDate(value, format, strict = true) {
4226
4283
  return dayjs(value, format, strict).isValid();
4227
4284
  }
4228
4285
  get isoRangeValue() {
@@ -4243,7 +4300,7 @@ class DateRange extends TextInput {
4243
4300
  splitedValue = this.splitValues(dates);
4244
4301
  const formattedValue = [];
4245
4302
  splitedValue.forEach((value) => {
4246
- if (value && this.isValidDate(value, this.dateFormat)) {
4303
+ if (value && this.isValidFormatDate(value, this.dateFormat)) {
4247
4304
  formattedValue.push(dayjs(value, this.dateFormat, true).format(this.isoFormat));
4248
4305
  }
4249
4306
  });
@@ -4253,7 +4310,7 @@ class DateRange extends TextInput {
4253
4310
  const parsedValue = [];
4254
4311
  if (values.length) {
4255
4312
  values.forEach((value) => {
4256
- if (value && this.isValidDate(value, this.isoFormat)) {
4313
+ if (value && this.isValidFormatDate(value, this.isoFormat)) {
4257
4314
  parsedValue.push(dayjs(value, this.isoFormat, true).format(this.dateFormat));
4258
4315
  }
4259
4316
  });
@@ -6526,7 +6583,13 @@ class GridEditable extends Grid {
6526
6583
  */
6527
6584
  addNewRow(row, position = 'end') {
6528
6585
  return __awaiter(this, void 0, void 0, function* () {
6529
- const { data } = this.datasource;
6586
+ let data;
6587
+ if (this.datasource instanceof MemoryDatasource) {
6588
+ data = this.datasource.allData;
6589
+ }
6590
+ else {
6591
+ data = this.datasource.data;
6592
+ }
6530
6593
  row[this.newRowIdentifier] = true;
6531
6594
  if (position === 'start') {
6532
6595
  data.unshift(row);
@@ -11183,12 +11246,17 @@ class Tabs extends ComponentRender {
11183
11246
  * Set component height to fill all space available
11184
11247
  */
11185
11248
  this.fillHeight = false;
11249
+ /**
11250
+ * Disable touch support.
11251
+ */
11252
+ this.touchless = false;
11186
11253
  this.tabs = this.getTabs(props.tabs || []);
11187
11254
  this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
11188
11255
  this.height = this.getInitValue('height', props.height, this.height);
11189
11256
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
11190
11257
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
11191
11258
  this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
11259
+ this.touchless = this.getInitValue('touchless', props.touchless, this.touchless);
11192
11260
  this.createAccessors();
11193
11261
  }
11194
11262
  get activeTab() {
@@ -11294,6 +11362,7 @@ class Text extends ComponentRender {
11294
11362
  this.compile = props.compile === true;
11295
11363
  this.tag = this.getInitValue('tag', props.tag, this.tag);
11296
11364
  this.text = this.getInitValue('text', props.text, this.text);
11365
+ this.textResize = this.getInitValue('textResize', props.textResize, this.textResize);
11297
11366
  this.createAccessors();
11298
11367
  }
11299
11368
  }
@@ -3753,6 +3753,14 @@
3753
3753
  * Helper value.
3754
3754
  */
3755
3755
  this.helperValue = '';
3756
+ /**
3757
+ * Max value allowed.
3758
+ */
3759
+ this.max = '';
3760
+ /**
3761
+ * Min value allowed.
3762
+ */
3763
+ this.min = '';
3756
3764
  /**
3757
3765
  * Width of the picker.
3758
3766
  */
@@ -3780,6 +3788,8 @@
3780
3788
  this.pickerType = this.getInitValue('pickerType', props.pickerType, this.pickerType);
3781
3789
  this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
3782
3790
  this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
3791
+ this.min = this.getInitValue('min', props.min, this.min);
3792
+ this.max = this.getInitValue('max', props.max, this.max);
3783
3793
  this.width = this.getInitValue('width', props.width, this.width);
3784
3794
  this.mask = this.getInitValue('mask', props.mask, undefined);
3785
3795
  this.createAccessors();
@@ -3863,6 +3873,28 @@
3863
3873
  this.value = this.internalValue; // forces value accessor to be called if necessary
3864
3874
  }
3865
3875
  isValidDate(value, format, strict = true) {
3876
+ const date = core.dayjs(value, format, strict);
3877
+ const isValidFormat = date.isValid();
3878
+ if (!isValidFormat)
3879
+ return false;
3880
+ const minDate = this.min ? core.dayjs(this.min, this.dateFormat) : null;
3881
+ const isValidMin = !minDate || date.isAfter(minDate) || date.isSame(minDate);
3882
+ if (!isValidMin)
3883
+ return false;
3884
+ const maxDate = this.max ? core.dayjs(this.max, this.dateFormat) : null;
3885
+ const isValidMax = !maxDate || date.isBefore(maxDate) || date.isSame(maxDate);
3886
+ if (!isValidMax)
3887
+ return false;
3888
+ const isAllowedDate = this.allowedDates === undefined
3889
+ || (this.allowedDates instanceof Function
3890
+ && this.allowedDates(core.dayjs(value, format).format(this.dateFormat)))
3891
+ || (Array.isArray(this.allowedDates)
3892
+ && this.allowedDates.indexOf(core.dayjs(value, format).format(this.dateFormat)) !== -1);
3893
+ if (!isAllowedDate)
3894
+ return false;
3895
+ return true;
3896
+ }
3897
+ isValidFormatDate(value, format, strict = true) {
3866
3898
  return core.dayjs(value, format, strict).isValid();
3867
3899
  }
3868
3900
  get isoValue() {
@@ -3876,13 +3908,13 @@
3876
3908
  this.change(this.value);
3877
3909
  }
3878
3910
  formatISODateValue(value) {
3879
- if (value && this.isValidDate(value, this.dateFormat)) {
3911
+ if (value && this.isValidFormatDate(value, this.dateFormat)) {
3880
3912
  return core.dayjs(value, this.dateFormat).format(this.isoFormat);
3881
3913
  }
3882
3914
  return '';
3883
3915
  }
3884
3916
  parseISODateValue(value) {
3885
- if (value && this.isValidDate(value, this.isoFormat)) {
3917
+ if (value && this.isValidFormatDate(value, this.isoFormat)) {
3886
3918
  return core.dayjs(value, this.isoFormat).format(this.dateFormat);
3887
3919
  }
3888
3920
  return null;
@@ -4107,6 +4139,14 @@
4107
4139
  * Helper options.
4108
4140
  */
4109
4141
  this.helperOptions = [];
4142
+ /**
4143
+ * Max value allowed.
4144
+ */
4145
+ this.max = '';
4146
+ /**
4147
+ * Min value allowed.
4148
+ */
4149
+ this.min = '';
4110
4150
  /**
4111
4151
  * Helper value.
4112
4152
  */
@@ -4134,6 +4174,8 @@
4134
4174
  this.mask = this.getInitValue('mask', props.mask, undefined);
4135
4175
  this.helperOptions = this.getInitValue('helperOptions', props.helperOptions, this.helperOptions);
4136
4176
  this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
4177
+ this.min = this.getInitValue('min', props.min, this.min);
4178
+ this.max = this.getInitValue('max', props.max, this.max);
4137
4179
  this.createAccessors();
4138
4180
  this.unitMask = this.mask;
4139
4181
  this.initialMask = this.getInitialMask();
@@ -4230,6 +4272,21 @@
4230
4272
  return [value];
4231
4273
  }
4232
4274
  isValidDate(value, format, strict = true) {
4275
+ const date = core.dayjs(value, format, strict);
4276
+ const isValidFormat = date.isValid();
4277
+ if (!isValidFormat)
4278
+ return false;
4279
+ const minDate = this.min ? core.dayjs(this.min, this.dateFormat) : null;
4280
+ const isValidMin = !minDate || date.isAfter(minDate) || date.isSame(minDate);
4281
+ if (!isValidMin)
4282
+ return false;
4283
+ const maxDate = this.max ? core.dayjs(this.max, this.dateFormat) : null;
4284
+ const isValidMax = !maxDate || date.isBefore(maxDate) || date.isSame(maxDate);
4285
+ if (!isValidMax)
4286
+ return false;
4287
+ return true;
4288
+ }
4289
+ isValidFormatDate(value, format, strict = true) {
4233
4290
  return core.dayjs(value, format, strict).isValid();
4234
4291
  }
4235
4292
  get isoRangeValue() {
@@ -4250,7 +4307,7 @@
4250
4307
  splitedValue = this.splitValues(dates);
4251
4308
  const formattedValue = [];
4252
4309
  splitedValue.forEach((value) => {
4253
- if (value && this.isValidDate(value, this.dateFormat)) {
4310
+ if (value && this.isValidFormatDate(value, this.dateFormat)) {
4254
4311
  formattedValue.push(core.dayjs(value, this.dateFormat, true).format(this.isoFormat));
4255
4312
  }
4256
4313
  });
@@ -4260,7 +4317,7 @@
4260
4317
  const parsedValue = [];
4261
4318
  if (values.length) {
4262
4319
  values.forEach((value) => {
4263
- if (value && this.isValidDate(value, this.isoFormat)) {
4320
+ if (value && this.isValidFormatDate(value, this.isoFormat)) {
4264
4321
  parsedValue.push(core.dayjs(value, this.isoFormat, true).format(this.dateFormat));
4265
4322
  }
4266
4323
  });
@@ -6533,7 +6590,13 @@
6533
6590
  */
6534
6591
  addNewRow(row, position = 'end') {
6535
6592
  return __awaiter(this, void 0, void 0, function* () {
6536
- const { data } = this.datasource;
6593
+ let data;
6594
+ if (this.datasource instanceof core.MemoryDatasource) {
6595
+ data = this.datasource.allData;
6596
+ }
6597
+ else {
6598
+ data = this.datasource.data;
6599
+ }
6537
6600
  row[this.newRowIdentifier] = true;
6538
6601
  if (position === 'start') {
6539
6602
  data.unshift(row);
@@ -11190,12 +11253,17 @@
11190
11253
  * Set component height to fill all space available
11191
11254
  */
11192
11255
  this.fillHeight = false;
11256
+ /**
11257
+ * Disable touch support.
11258
+ */
11259
+ this.touchless = false;
11193
11260
  this.tabs = this.getTabs(props.tabs || []);
11194
11261
  this.activeTab = this.getInitValue('activeTab', props.activeTab, this.activeTabValue);
11195
11262
  this.height = this.getInitValue('height', props.height, this.height);
11196
11263
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
11197
11264
  this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
11198
11265
  this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
11266
+ this.touchless = this.getInitValue('touchless', props.touchless, this.touchless);
11199
11267
  this.createAccessors();
11200
11268
  }
11201
11269
  get activeTab() {
@@ -11301,6 +11369,7 @@
11301
11369
  this.compile = props.compile === true;
11302
11370
  this.tag = this.getInitValue('tag', props.tag, this.tag);
11303
11371
  this.text = this.getInitValue('text', props.text, this.text);
11372
+ this.textResize = this.getInitValue('textResize', props.textResize, this.textResize);
11304
11373
  this.createAccessors();
11305
11374
  }
11306
11375
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.79.1",
3
+ "version": "1.80.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -41,5 +41,5 @@
41
41
  "lodash.times": "4.3.*",
42
42
  "mockdate": "3.0.*"
43
43
  },
44
- "gitHead": "b4bf265016337a00b453394e11176f0ce770b63f"
44
+ "gitHead": "475e792a47bd61e8b083078ea84dbae954992339"
45
45
  }
@@ -57,6 +57,14 @@ export declare class DateRange extends TextInput implements IDateRange {
57
57
  * Helper options.
58
58
  */
59
59
  helperOptions?: string[];
60
+ /**
61
+ * Max value allowed.
62
+ */
63
+ max?: string;
64
+ /**
65
+ * Min value allowed.
66
+ */
67
+ min?: string;
60
68
  /**
61
69
  * Helper value.
62
70
  */
@@ -91,6 +99,7 @@ export declare class DateRange extends TextInput implements IDateRange {
91
99
  isValidDateArray(format: string, values?: string[]): boolean;
92
100
  private splitValues;
93
101
  isValidDate(value: string, format: string, strict?: boolean): boolean;
102
+ isValidFormatDate(value: string, format: string, strict?: boolean): boolean;
94
103
  get isoRangeValue(): string[];
95
104
  set isoRangeValue(newValue: string[]);
96
105
  formatISODateRangeValue(dates: string[] | string): string[];
@@ -64,6 +64,14 @@ export declare class Date extends TextInput implements IDate {
64
64
  * Helper value.
65
65
  */
66
66
  helperValue?: string;
67
+ /**
68
+ * Max value allowed.
69
+ */
70
+ max?: string;
71
+ /**
72
+ * Min value allowed.
73
+ */
74
+ min?: string;
67
75
  /**
68
76
  * Width of the picker.
69
77
  */
@@ -101,6 +109,7 @@ export declare class Date extends TextInput implements IDate {
101
109
  protected maskFormat(format: string): string;
102
110
  setDateValue(displayValue: string): void;
103
111
  isValidDate(value: string, format: string, strict?: boolean): boolean;
112
+ isValidFormatDate(value: string, format: string, strict?: boolean): boolean;
104
113
  get isoValue(): string;
105
114
  set isoValue(newValue: string);
106
115
  formatISODateValue(value: string): string;
@@ -23,6 +23,8 @@ export interface IDate extends ITextInput {
23
23
  orderedDates?: boolean;
24
24
  helperOptions?: string[];
25
25
  helperValue?: string;
26
+ max?: string;
27
+ min?: string;
26
28
  }
27
29
  export interface IDateRange extends IDate {
28
30
  splitter?: string;
@@ -22,4 +22,5 @@ export interface ITabs extends IComponentRender {
22
22
  maxHeight?: number | string;
23
23
  minHeight?: number | string;
24
24
  fillHeight?: boolean;
25
+ touchless?: boolean;
25
26
  }
@@ -27,6 +27,10 @@ export declare class Tabs extends ComponentRender implements ITabs {
27
27
  * Set component height to fill all space available
28
28
  */
29
29
  fillHeight: boolean;
30
+ /**
31
+ * Disable touch support.
32
+ */
33
+ touchless: boolean;
30
34
  /**
31
35
  * Create a new Tabs.
32
36
  * @param props Tabs properties
@@ -6,4 +6,10 @@ export interface IText extends IComponentRender {
6
6
  tag?: string;
7
7
  text: string | string[];
8
8
  compile?: boolean;
9
+ textResize?: ITextResize;
10
+ }
11
+ export interface ITextResize {
12
+ fontSize?: number;
13
+ min?: number;
14
+ max?: number;
9
15
  }
@@ -1,4 +1,4 @@
1
- import { IText } from './interfaces';
1
+ import { IText, ITextResize } from './interfaces';
2
2
  import { ComponentRender } from '../zd-component/component-render';
3
3
  /**
4
4
  * Base class for Text component.
@@ -7,6 +7,7 @@ export declare class Text extends ComponentRender implements IText {
7
7
  compile: boolean;
8
8
  tag: string;
9
9
  text: string | string[];
10
+ textResize?: ITextResize;
10
11
  /**
11
12
  * Creates a new Text.
12
13
  * @param props Text properties