@zeedhi/common 1.85.1 → 1.86.1

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.
@@ -1895,6 +1895,7 @@ class Input extends ComponentRender {
1895
1895
  this.parserFn = FormatterParserProvider.getParser('ZdInput');
1896
1896
  this.internalDisplayValue = '';
1897
1897
  this.internalValue = null;
1898
+ this.formParent = this.getFormParent();
1898
1899
  this.lastInputValue = undefined;
1899
1900
  this.callInputEvent = debounce(({ event, element, component }) => {
1900
1901
  this.callEvent('input', { event, element, component });
@@ -1922,8 +1923,8 @@ class Input extends ComponentRender {
1922
1923
  this.value = this.getInitValue('value', props.value, this.value);
1923
1924
  this.validations = this.getInitValue('validations', props.validations, this.validations);
1924
1925
  this.parseValidations(props.validations || {});
1925
- if (this.parent instanceof Form) {
1926
- this.parent.registerInput(this);
1926
+ if (this.formParent) {
1927
+ this.formParent.registerInput(this);
1927
1928
  }
1928
1929
  this.createAccessors();
1929
1930
  }
@@ -2093,6 +2094,13 @@ class Input extends ComponentRender {
2093
2094
  keydown(event, element) {
2094
2095
  this.callEvent('keydown', { event, element, component: this });
2095
2096
  }
2097
+ getFormParent() {
2098
+ let { parent } = this;
2099
+ while (parent && !(parent instanceof Form)) {
2100
+ parent = parent.parent;
2101
+ }
2102
+ return parent;
2103
+ }
2096
2104
  }
2097
2105
  FormatterParserProvider.registerFormatter('ZdInput', (value) => value);
2098
2106
  FormatterParserProvider.registerParser('ZdInput', (value) => value);
@@ -6882,7 +6890,7 @@ class Header extends ComponentRender {
6882
6890
  /**
6883
6891
  * Sets the height for header.
6884
6892
  */
6885
- this.height = 'auto';
6893
+ this.height = '';
6886
6894
  /**
6887
6895
  * Render components on the left of header.
6888
6896
  */
@@ -7313,6 +7321,10 @@ class Select extends TextInput {
7313
7321
  * Enables search input
7314
7322
  */
7315
7323
  this.autocomplete = true;
7324
+ /**
7325
+ * Automatically select option if only one is filtered
7326
+ */
7327
+ this.autoSelection = true;
7316
7328
  /**
7317
7329
  * Prevents load select data when the input is focused
7318
7330
  */
@@ -7391,6 +7403,7 @@ class Select extends TextInput {
7391
7403
  this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
7392
7404
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
7393
7405
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
7406
+ this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
7394
7407
  this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
7395
7408
  this.manualMode = this.getInitValue('manualMode', props.manualMode, this.manualMode);
7396
7409
  this.attach = this.getInitValue('attach', props.attach, this.attach);
@@ -7739,6 +7752,9 @@ class Select extends TextInput {
7739
7752
  */
7740
7753
  blur(event, element) {
7741
7754
  if (this.autocomplete) {
7755
+ if (this.search && this.autoSelection && this.datasource.data.length === 1) {
7756
+ this.setValue(this.datasource.data[0]);
7757
+ }
7742
7758
  this.datasource.search = '';
7743
7759
  this.dirtySearchValue = '';
7744
7760
  if (!this.manualMode) {
@@ -9697,33 +9713,7 @@ class SelectMultiple extends Select {
9697
9713
  this.dataText = [this.dataText];
9698
9714
  this.internalDisplayValue = this.getDisplayValue();
9699
9715
  this.createAccessors();
9700
- }
9701
- afterFocus() {
9702
- return __awaiter(this, void 0, void 0, function* () {
9703
- if (!this.preventLoadOnFocus) {
9704
- yield this.datasource.get();
9705
- const values = this.datasource.data.map((row) => row[this.dataValue]);
9706
- // remove inserted items that are already in datasource
9707
- this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
9708
- this.preventLoadOnFocus = true;
9709
- }
9710
- this.setCache();
9711
- this.updateSearch(this.dirtySearchValue);
9712
- });
9713
- }
9714
- setCache() {
9715
- if (this.manualMode)
9716
- return;
9717
- if (this.insertedValues.length) {
9718
- this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
9719
- const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
9720
- // prevent caching insertedValues
9721
- this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
9722
- }
9723
- else {
9724
- this.cachedData = this.datasource.data;
9725
- }
9726
- this.cachedTotal = this.datasource.total;
9716
+ this.autoSelection = false;
9727
9717
  }
9728
9718
  /**
9729
9719
  * Field selected rows
@@ -10031,6 +10021,33 @@ class SelectMultiple extends Select {
10031
10021
  });
10032
10022
  }
10033
10023
  checkValueOnBlur() { }
10024
+ afterFocus() {
10025
+ return __awaiter(this, void 0, void 0, function* () {
10026
+ if (!this.preventLoadOnFocus) {
10027
+ yield this.datasource.get();
10028
+ const values = this.datasource.data.map((row) => row[this.dataValue]);
10029
+ // remove inserted items that are already in datasource
10030
+ this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
10031
+ this.preventLoadOnFocus = true;
10032
+ }
10033
+ this.setCache();
10034
+ this.updateSearch(this.dirtySearchValue);
10035
+ });
10036
+ }
10037
+ setCache() {
10038
+ if (this.manualMode)
10039
+ return;
10040
+ if (this.insertedValues.length) {
10041
+ this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
10042
+ const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
10043
+ // prevent caching insertedValues
10044
+ this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
10045
+ }
10046
+ else {
10047
+ this.cachedData = this.datasource.data;
10048
+ }
10049
+ this.cachedTotal = this.datasource.total;
10050
+ }
10034
10051
  }
10035
10052
 
10036
10053
  class TreeDataStructure {
@@ -12573,6 +12590,8 @@ class TreeGrid extends Grid {
12573
12590
  this.flat = this.getInitValue('flat', props.flat, this.flat);
12574
12591
  this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
12575
12592
  this.detach = this.getInitValue('detach', props.detach, this.detach);
12593
+ this.footerSlot = props.footerSlot || this.footerSlot;
12594
+ this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
12576
12595
  this.treeDataStructure = new TreeDataStructure(this);
12577
12596
  this.createAccessors();
12578
12597
  }
@@ -1902,6 +1902,7 @@
1902
1902
  this.parserFn = core.FormatterParserProvider.getParser('ZdInput');
1903
1903
  this.internalDisplayValue = '';
1904
1904
  this.internalValue = null;
1905
+ this.formParent = this.getFormParent();
1905
1906
  this.lastInputValue = undefined;
1906
1907
  this.callInputEvent = debounce__default["default"](({ event, element, component }) => {
1907
1908
  this.callEvent('input', { event, element, component });
@@ -1929,8 +1930,8 @@
1929
1930
  this.value = this.getInitValue('value', props.value, this.value);
1930
1931
  this.validations = this.getInitValue('validations', props.validations, this.validations);
1931
1932
  this.parseValidations(props.validations || {});
1932
- if (this.parent instanceof Form) {
1933
- this.parent.registerInput(this);
1933
+ if (this.formParent) {
1934
+ this.formParent.registerInput(this);
1934
1935
  }
1935
1936
  this.createAccessors();
1936
1937
  }
@@ -2100,6 +2101,13 @@
2100
2101
  keydown(event, element) {
2101
2102
  this.callEvent('keydown', { event, element, component: this });
2102
2103
  }
2104
+ getFormParent() {
2105
+ let { parent } = this;
2106
+ while (parent && !(parent instanceof Form)) {
2107
+ parent = parent.parent;
2108
+ }
2109
+ return parent;
2110
+ }
2103
2111
  }
2104
2112
  core.FormatterParserProvider.registerFormatter('ZdInput', (value) => value);
2105
2113
  core.FormatterParserProvider.registerParser('ZdInput', (value) => value);
@@ -6889,7 +6897,7 @@
6889
6897
  /**
6890
6898
  * Sets the height for header.
6891
6899
  */
6892
- this.height = 'auto';
6900
+ this.height = '';
6893
6901
  /**
6894
6902
  * Render components on the left of header.
6895
6903
  */
@@ -7320,6 +7328,10 @@
7320
7328
  * Enables search input
7321
7329
  */
7322
7330
  this.autocomplete = true;
7331
+ /**
7332
+ * Automatically select option if only one is filtered
7333
+ */
7334
+ this.autoSelection = true;
7323
7335
  /**
7324
7336
  * Prevents load select data when the input is focused
7325
7337
  */
@@ -7398,6 +7410,7 @@
7398
7410
  this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
7399
7411
  this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
7400
7412
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
7413
+ this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
7401
7414
  this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
7402
7415
  this.manualMode = this.getInitValue('manualMode', props.manualMode, this.manualMode);
7403
7416
  this.attach = this.getInitValue('attach', props.attach, this.attach);
@@ -7746,6 +7759,9 @@
7746
7759
  */
7747
7760
  blur(event, element) {
7748
7761
  if (this.autocomplete) {
7762
+ if (this.search && this.autoSelection && this.datasource.data.length === 1) {
7763
+ this.setValue(this.datasource.data[0]);
7764
+ }
7749
7765
  this.datasource.search = '';
7750
7766
  this.dirtySearchValue = '';
7751
7767
  if (!this.manualMode) {
@@ -9704,33 +9720,7 @@
9704
9720
  this.dataText = [this.dataText];
9705
9721
  this.internalDisplayValue = this.getDisplayValue();
9706
9722
  this.createAccessors();
9707
- }
9708
- afterFocus() {
9709
- return __awaiter(this, void 0, void 0, function* () {
9710
- if (!this.preventLoadOnFocus) {
9711
- yield this.datasource.get();
9712
- const values = this.datasource.data.map((row) => row[this.dataValue]);
9713
- // remove inserted items that are already in datasource
9714
- this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
9715
- this.preventLoadOnFocus = true;
9716
- }
9717
- this.setCache();
9718
- this.updateSearch(this.dirtySearchValue);
9719
- });
9720
- }
9721
- setCache() {
9722
- if (this.manualMode)
9723
- return;
9724
- if (this.insertedValues.length) {
9725
- this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
9726
- const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
9727
- // prevent caching insertedValues
9728
- this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
9729
- }
9730
- else {
9731
- this.cachedData = this.datasource.data;
9732
- }
9733
- this.cachedTotal = this.datasource.total;
9723
+ this.autoSelection = false;
9734
9724
  }
9735
9725
  /**
9736
9726
  * Field selected rows
@@ -10038,6 +10028,33 @@
10038
10028
  });
10039
10029
  }
10040
10030
  checkValueOnBlur() { }
10031
+ afterFocus() {
10032
+ return __awaiter(this, void 0, void 0, function* () {
10033
+ if (!this.preventLoadOnFocus) {
10034
+ yield this.datasource.get();
10035
+ const values = this.datasource.data.map((row) => row[this.dataValue]);
10036
+ // remove inserted items that are already in datasource
10037
+ this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
10038
+ this.preventLoadOnFocus = true;
10039
+ }
10040
+ this.setCache();
10041
+ this.updateSearch(this.dirtySearchValue);
10042
+ });
10043
+ }
10044
+ setCache() {
10045
+ if (this.manualMode)
10046
+ return;
10047
+ if (this.insertedValues.length) {
10048
+ this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
10049
+ const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
10050
+ // prevent caching insertedValues
10051
+ this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
10052
+ }
10053
+ else {
10054
+ this.cachedData = this.datasource.data;
10055
+ }
10056
+ this.cachedTotal = this.datasource.total;
10057
+ }
10041
10058
  }
10042
10059
 
10043
10060
  class TreeDataStructure {
@@ -12580,6 +12597,8 @@
12580
12597
  this.flat = this.getInitValue('flat', props.flat, this.flat);
12581
12598
  this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
12582
12599
  this.detach = this.getInitValue('detach', props.detach, this.detach);
12600
+ this.footerSlot = props.footerSlot || this.footerSlot;
12601
+ this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
12583
12602
  this.treeDataStructure = new TreeDataStructure(this);
12584
12603
  this.createAccessors();
12585
12604
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.85.1",
3
+ "version": "1.86.1",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "13bfb6936e5027a14c02d4ecde838100992a57d0"
46
+ "gitHead": "96c1d8fad419409f16c17a3ec72f0bca1748002c"
47
47
  }
@@ -1,6 +1,6 @@
1
- import { IHeader, IHeaderEvents } from './interfaces';
2
1
  import { ComponentRender } from '../zd-component/component-render';
3
2
  import { IComponentRender } from '../zd-component/interfaces';
3
+ import { IHeader, IHeaderEvents } from './interfaces';
4
4
  /**
5
5
  * Base class for Header component.
6
6
  */
@@ -1,6 +1,7 @@
1
1
  import { IDictionary } from '@zeedhi/core';
2
- import { IInput, IInputEvents } from './interfaces';
3
2
  import { ComponentRender } from '../zd-component/component-render';
3
+ import { Form } from '../zd-form/form';
4
+ import { IInput, IInputEvents } from './interfaces';
4
5
  /**
5
6
  * Base class for Input component.
6
7
  */
@@ -114,6 +115,7 @@ export declare class Input extends ComponentRender implements IInput {
114
115
  protected parserFn: Function;
115
116
  protected internalDisplayValue: string;
116
117
  protected internalValue: any;
118
+ protected formParent?: Form;
117
119
  /**
118
120
  * Creates a new Input.
119
121
  * @param props Input properties
@@ -213,4 +215,5 @@ export declare class Input extends ComponentRender implements IInput {
213
215
  * @param element Element that lost the focus
214
216
  */
215
217
  keydown(event?: Event, element?: any): void;
218
+ private getFormParent;
216
219
  }
@@ -3,6 +3,8 @@ import { ITextInput } from '../zd-text-input/interfaces';
3
3
  import { IComponentRender } from '../zd-component/interfaces';
4
4
  export declare type SearchParam = 'SEARCH' | 'FILTER' | 'FIND';
5
5
  export interface ISelect extends ITextInput {
6
+ autocomplete?: boolean;
7
+ autoSelection?: boolean;
6
8
  datasource?: IDatasource;
7
9
  dataText?: string | any[];
8
10
  dataTextSeparator?: string;
@@ -34,6 +34,10 @@ export declare class Select extends TextInput implements ISelect {
34
34
  * Enables search input
35
35
  */
36
36
  autocomplete: boolean;
37
+ /**
38
+ * Automatically select option if only one is filtered
39
+ */
40
+ autoSelection: boolean;
37
41
  /**
38
42
  * Prevents load select data when the input is focused
39
43
  */
@@ -23,8 +23,6 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
23
23
  * Limit the display of selected options. The rest will be hidden within the 'limitText' string
24
24
  */
25
25
  limit: number | null;
26
- protected afterFocus(): Promise<void>;
27
- private setCache;
28
26
  showSelectAll: boolean;
29
27
  /**
30
28
  * Create a new Select.
@@ -104,4 +102,6 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
104
102
  selectAllItems(): Promise<void>;
105
103
  unSelectAllItems(): Promise<void>;
106
104
  protected checkValueOnBlur(): void;
105
+ protected afterFocus(): Promise<void>;
106
+ private setCache;
107
107
  }