@zeedhi/common 1.106.1 → 1.107.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.
@@ -1900,7 +1900,9 @@ class Input extends ComponentRender {
1900
1900
  /**
1901
1901
  * Input validations.
1902
1902
  */
1903
- this.validations = {};
1903
+ this.validations = {
1904
+ required: false,
1905
+ };
1904
1906
  /**
1905
1907
  * Defines if the input should be automatically registered in the closest parent Form
1906
1908
  */
@@ -1983,7 +1985,10 @@ class Input extends ComponentRender {
1983
1985
  * @param validations Field validations
1984
1986
  */
1985
1987
  parseValidations(validations) {
1986
- Object.keys(validations).forEach((name) => this.addValidation(name, validations[name]));
1988
+ Object.keys(validations).forEach((name) => {
1989
+ if (validations[name])
1990
+ this.addValidation(name, validations[name]);
1991
+ });
1987
1992
  }
1988
1993
  /**
1989
1994
  * Adds input validation.
@@ -9677,7 +9682,7 @@ class Select extends TextInput {
9677
9682
  /* Defines if should open modal with grid to make the selection */
9678
9683
  this.modalSelection = false;
9679
9684
  /* Defines fields to show on modal */
9680
- this.modalSelectionFields = [];
9685
+ this.modalSelectionColumns = [];
9681
9686
  this.dsSearch = {
9682
9687
  SEARCH: (value, searchIn) => ({
9683
9688
  searchIn: [searchIn],
@@ -9733,7 +9738,7 @@ class Select extends TextInput {
9733
9738
  this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
9734
9739
  this.closeOnScroll = this.getInitValue('closeOnScroll', props.closeOnScroll, this.closeOnScroll);
9735
9740
  this.modalSelection = this.getInitValue('modalSelection', props.modalSelection, this.modalSelection);
9736
- this.modalSelectionFields = this.getInitValue('modalSelectionFields', props.modalSelectionFields, this.modalSelectionFields);
9741
+ this.modalSelectionColumns = this.getInitValue('modalSelectionColumns', props.modalSelectionColumns, this.modalSelectionColumns);
9737
9742
  if (((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.type) === 'simple') {
9738
9743
  this.dataValue = 'value';
9739
9744
  this.dataText = this.dataText || this.dataValue;
@@ -9771,7 +9776,7 @@ class Select extends TextInput {
9771
9776
  }
9772
9777
  onMounted(element) {
9773
9778
  super.onMounted(element);
9774
- if (this.modalSelection && this.modalSelectionFields.length) {
9779
+ if (this.modalSelection && this.modalSelectionColumns.length) {
9775
9780
  KeyMap.bind({
9776
9781
  'shift+enter': {
9777
9782
  active: true,
@@ -9786,12 +9791,14 @@ class Select extends TextInput {
9786
9791
  onBeforeDestroy() {
9787
9792
  super.onBeforeDestroy();
9788
9793
  this.datasource.destroy();
9789
- if (this.modalSelection && this.modalSelectionFields.length) {
9794
+ if (this.modalSelection && this.modalSelectionColumns.length) {
9790
9795
  KeyMap.unbind({
9791
9796
  'shift+enter': {
9792
9797
  event: this.openModalSelection.bind(this),
9793
9798
  },
9794
9799
  }, this);
9800
+ if (this.modalSelectionObj)
9801
+ this.modalSelectionObj.destroy();
9795
9802
  }
9796
9803
  }
9797
9804
  /**
@@ -10187,7 +10194,7 @@ class Select extends TextInput {
10187
10194
  this.viewCloseMenu();
10188
10195
  }, 200);
10189
10196
  }
10190
- openModalSelection() {
10197
+ getModalSelectionDef() {
10191
10198
  const modalSelectionDef = {
10192
10199
  name: `${this.name}-modal-selection`,
10193
10200
  persistent: true,
@@ -10203,7 +10210,7 @@ class Select extends TextInput {
10203
10210
  name: `${this.name}-modal-selection-grid`,
10204
10211
  component: 'ZdGrid',
10205
10212
  cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
10206
- columns: this.modalSelectionFields,
10213
+ columns: this.modalSelectionColumns,
10207
10214
  datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
10208
10215
  toolbarSlot: [
10209
10216
  {
@@ -10271,6 +10278,10 @@ class Select extends TextInput {
10271
10278
  },
10272
10279
  },
10273
10280
  };
10281
+ return modalSelectionDef;
10282
+ }
10283
+ openModalSelection() {
10284
+ const modalSelectionDef = this.getModalSelectionDef();
10274
10285
  if (this.modalSelectionObj)
10275
10286
  this.modalSelectionObj.destroy();
10276
10287
  ViewService.nextTick(() => {
@@ -10623,7 +10634,8 @@ class IterableComponentRender extends Iterable {
10623
10634
  * Returns the iterable component metadata based on row data
10624
10635
  */
10625
10636
  getComponentMetadata(row) {
10626
- const exp = new RegExp(`<<${this.rowPropName}\\.([A-z_.]+?)>>|"<<${this.rowPropName}.(.[A-z_.]+?)>>"`, 'g');
10637
+ const pattern = `${this.rowPropName}\\.([A-Za-z0-9_.]+?)`;
10638
+ const exp = new RegExp(`<<${pattern}>>|"<<${pattern}>>"`, 'g');
10627
10639
  const rowExp = new RegExp(`"<<${this.rowPropName}>>"`, 'g');
10628
10640
  const metadata = JSON.stringify(this.componentMetadata)
10629
10641
  .replace(rowExp, JSON.stringify(row))
@@ -10635,6 +10647,8 @@ class IterableComponentRender extends Iterable {
10635
10647
  return `"${value}"`;
10636
10648
  return value;
10637
10649
  }
10650
+ if (value === undefined)
10651
+ return '""';
10638
10652
  return value;
10639
10653
  });
10640
10654
  return JSON.parse(metadata);
@@ -12599,6 +12613,109 @@ class SelectMultiple extends Select {
12599
12613
  return validation((this.checkboxAll && 'all') || testValue);
12600
12614
  });
12601
12615
  }
12616
+ confirmModalSelection() {
12617
+ const grid = Metadata.getInstance(`${this.name}-modal-selection-grid`);
12618
+ this.setValue(grid.selectedRows);
12619
+ this.hideModalSelection();
12620
+ setTimeout(() => {
12621
+ if (this.viewCloseMenu)
12622
+ this.viewCloseMenu();
12623
+ }, 200);
12624
+ }
12625
+ getModalSelectionDef() {
12626
+ const modalSelectionDef = {
12627
+ name: `${this.name}-modal-selection`,
12628
+ persistent: true,
12629
+ escKeydownStop: false,
12630
+ children: [
12631
+ {
12632
+ name: `${this.name}-modal-selection-content-container`,
12633
+ component: 'ZdContainer',
12634
+ scrollView: true,
12635
+ cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-content-container',
12636
+ children: [
12637
+ {
12638
+ name: `${this.name}-modal-selection-grid`,
12639
+ component: 'ZdGrid',
12640
+ selectable: true,
12641
+ cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
12642
+ columns: this.modalSelectionColumns,
12643
+ datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
12644
+ toolbarSlot: [
12645
+ {
12646
+ name: `${this.name}-modal-selection-title`,
12647
+ component: 'ZdText',
12648
+ cssStyle: `color: ${'var(--v-primary-base);'}`,
12649
+ text: this.label,
12650
+ tag: 'h3',
12651
+ },
12652
+ {
12653
+ name: `${this.name}-modal-selection-spacer`,
12654
+ component: 'VSpacer',
12655
+ },
12656
+ {
12657
+ name: `${this.name}-modal-selection_gridSearch`,
12658
+ component: 'ZdSearch',
12659
+ cssClass: 'zd-grid-search',
12660
+ autofocus: true,
12661
+ },
12662
+ ],
12663
+ },
12664
+ ],
12665
+ },
12666
+ {
12667
+ name: `${this.name}-modal-selection-footer-container`,
12668
+ component: 'ZdContainer',
12669
+ cssClass: 'zd-pa-0',
12670
+ children: [
12671
+ {
12672
+ name: `${this.name}-modal-selection-footer`,
12673
+ component: 'ZdFooter',
12674
+ color: 'transparent',
12675
+ padless: true,
12676
+ rightSlot: [
12677
+ {
12678
+ name: `${this.name}-modal-selection-cancelButton`,
12679
+ component: 'ZdButton',
12680
+ label: 'CANCEL',
12681
+ keyMap: {
12682
+ esc: {
12683
+ event: this.hideModalSelection.bind(this),
12684
+ focus: true,
12685
+ visible: true,
12686
+ input: true,
12687
+ stop: true,
12688
+ },
12689
+ },
12690
+ outline: true,
12691
+ events: {
12692
+ click: this.hideModalSelection.bind(this),
12693
+ },
12694
+ },
12695
+ {
12696
+ name: `${this.name}-modal-selection-confirmButton`,
12697
+ component: 'ZdButton',
12698
+ label: 'OK',
12699
+ outline: false,
12700
+ events: {
12701
+ click: this.confirmModalSelection.bind(this),
12702
+ },
12703
+ },
12704
+ ],
12705
+ },
12706
+ ],
12707
+ },
12708
+ ],
12709
+ events: {
12710
+ onShow: () => {
12711
+ const grid = Metadata.getInstance(`${this.name}-modal-selection-grid`);
12712
+ grid.selectedRows = this.selectedValue;
12713
+ grid.datasource.currentRow = {};
12714
+ },
12715
+ },
12716
+ };
12717
+ return modalSelectionDef;
12718
+ }
12602
12719
  }
12603
12720
 
12604
12721
  /**
@@ -1907,7 +1907,9 @@
1907
1907
  /**
1908
1908
  * Input validations.
1909
1909
  */
1910
- this.validations = {};
1910
+ this.validations = {
1911
+ required: false,
1912
+ };
1911
1913
  /**
1912
1914
  * Defines if the input should be automatically registered in the closest parent Form
1913
1915
  */
@@ -1990,7 +1992,10 @@
1990
1992
  * @param validations Field validations
1991
1993
  */
1992
1994
  parseValidations(validations) {
1993
- Object.keys(validations).forEach((name) => this.addValidation(name, validations[name]));
1995
+ Object.keys(validations).forEach((name) => {
1996
+ if (validations[name])
1997
+ this.addValidation(name, validations[name]);
1998
+ });
1994
1999
  }
1995
2000
  /**
1996
2001
  * Adds input validation.
@@ -9684,7 +9689,7 @@
9684
9689
  /* Defines if should open modal with grid to make the selection */
9685
9690
  this.modalSelection = false;
9686
9691
  /* Defines fields to show on modal */
9687
- this.modalSelectionFields = [];
9692
+ this.modalSelectionColumns = [];
9688
9693
  this.dsSearch = {
9689
9694
  SEARCH: (value, searchIn) => ({
9690
9695
  searchIn: [searchIn],
@@ -9740,7 +9745,7 @@
9740
9745
  this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
9741
9746
  this.closeOnScroll = this.getInitValue('closeOnScroll', props.closeOnScroll, this.closeOnScroll);
9742
9747
  this.modalSelection = this.getInitValue('modalSelection', props.modalSelection, this.modalSelection);
9743
- this.modalSelectionFields = this.getInitValue('modalSelectionFields', props.modalSelectionFields, this.modalSelectionFields);
9748
+ this.modalSelectionColumns = this.getInitValue('modalSelectionColumns', props.modalSelectionColumns, this.modalSelectionColumns);
9744
9749
  if (((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.type) === 'simple') {
9745
9750
  this.dataValue = 'value';
9746
9751
  this.dataText = this.dataText || this.dataValue;
@@ -9778,7 +9783,7 @@
9778
9783
  }
9779
9784
  onMounted(element) {
9780
9785
  super.onMounted(element);
9781
- if (this.modalSelection && this.modalSelectionFields.length) {
9786
+ if (this.modalSelection && this.modalSelectionColumns.length) {
9782
9787
  core.KeyMap.bind({
9783
9788
  'shift+enter': {
9784
9789
  active: true,
@@ -9793,12 +9798,14 @@
9793
9798
  onBeforeDestroy() {
9794
9799
  super.onBeforeDestroy();
9795
9800
  this.datasource.destroy();
9796
- if (this.modalSelection && this.modalSelectionFields.length) {
9801
+ if (this.modalSelection && this.modalSelectionColumns.length) {
9797
9802
  core.KeyMap.unbind({
9798
9803
  'shift+enter': {
9799
9804
  event: this.openModalSelection.bind(this),
9800
9805
  },
9801
9806
  }, this);
9807
+ if (this.modalSelectionObj)
9808
+ this.modalSelectionObj.destroy();
9802
9809
  }
9803
9810
  }
9804
9811
  /**
@@ -10194,7 +10201,7 @@
10194
10201
  this.viewCloseMenu();
10195
10202
  }, 200);
10196
10203
  }
10197
- openModalSelection() {
10204
+ getModalSelectionDef() {
10198
10205
  const modalSelectionDef = {
10199
10206
  name: `${this.name}-modal-selection`,
10200
10207
  persistent: true,
@@ -10210,7 +10217,7 @@
10210
10217
  name: `${this.name}-modal-selection-grid`,
10211
10218
  component: 'ZdGrid',
10212
10219
  cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
10213
- columns: this.modalSelectionFields,
10220
+ columns: this.modalSelectionColumns,
10214
10221
  datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
10215
10222
  toolbarSlot: [
10216
10223
  {
@@ -10278,6 +10285,10 @@
10278
10285
  },
10279
10286
  },
10280
10287
  };
10288
+ return modalSelectionDef;
10289
+ }
10290
+ openModalSelection() {
10291
+ const modalSelectionDef = this.getModalSelectionDef();
10281
10292
  if (this.modalSelectionObj)
10282
10293
  this.modalSelectionObj.destroy();
10283
10294
  core.ViewService.nextTick(() => {
@@ -10630,7 +10641,8 @@
10630
10641
  * Returns the iterable component metadata based on row data
10631
10642
  */
10632
10643
  getComponentMetadata(row) {
10633
- const exp = new RegExp(`<<${this.rowPropName}\\.([A-z_.]+?)>>|"<<${this.rowPropName}.(.[A-z_.]+?)>>"`, 'g');
10644
+ const pattern = `${this.rowPropName}\\.([A-Za-z0-9_.]+?)`;
10645
+ const exp = new RegExp(`<<${pattern}>>|"<<${pattern}>>"`, 'g');
10634
10646
  const rowExp = new RegExp(`"<<${this.rowPropName}>>"`, 'g');
10635
10647
  const metadata = JSON.stringify(this.componentMetadata)
10636
10648
  .replace(rowExp, JSON.stringify(row))
@@ -10642,6 +10654,8 @@
10642
10654
  return `"${value}"`;
10643
10655
  return value;
10644
10656
  }
10657
+ if (value === undefined)
10658
+ return '""';
10645
10659
  return value;
10646
10660
  });
10647
10661
  return JSON.parse(metadata);
@@ -12606,6 +12620,109 @@
12606
12620
  return validation((this.checkboxAll && 'all') || testValue);
12607
12621
  });
12608
12622
  }
12623
+ confirmModalSelection() {
12624
+ const grid = core.Metadata.getInstance(`${this.name}-modal-selection-grid`);
12625
+ this.setValue(grid.selectedRows);
12626
+ this.hideModalSelection();
12627
+ setTimeout(() => {
12628
+ if (this.viewCloseMenu)
12629
+ this.viewCloseMenu();
12630
+ }, 200);
12631
+ }
12632
+ getModalSelectionDef() {
12633
+ const modalSelectionDef = {
12634
+ name: `${this.name}-modal-selection`,
12635
+ persistent: true,
12636
+ escKeydownStop: false,
12637
+ children: [
12638
+ {
12639
+ name: `${this.name}-modal-selection-content-container`,
12640
+ component: 'ZdContainer',
12641
+ scrollView: true,
12642
+ cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-content-container',
12643
+ children: [
12644
+ {
12645
+ name: `${this.name}-modal-selection-grid`,
12646
+ component: 'ZdGrid',
12647
+ selectable: true,
12648
+ cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
12649
+ columns: this.modalSelectionColumns,
12650
+ datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
12651
+ toolbarSlot: [
12652
+ {
12653
+ name: `${this.name}-modal-selection-title`,
12654
+ component: 'ZdText',
12655
+ cssStyle: `color: ${'var(--v-primary-base);'}`,
12656
+ text: this.label,
12657
+ tag: 'h3',
12658
+ },
12659
+ {
12660
+ name: `${this.name}-modal-selection-spacer`,
12661
+ component: 'VSpacer',
12662
+ },
12663
+ {
12664
+ name: `${this.name}-modal-selection_gridSearch`,
12665
+ component: 'ZdSearch',
12666
+ cssClass: 'zd-grid-search',
12667
+ autofocus: true,
12668
+ },
12669
+ ],
12670
+ },
12671
+ ],
12672
+ },
12673
+ {
12674
+ name: `${this.name}-modal-selection-footer-container`,
12675
+ component: 'ZdContainer',
12676
+ cssClass: 'zd-pa-0',
12677
+ children: [
12678
+ {
12679
+ name: `${this.name}-modal-selection-footer`,
12680
+ component: 'ZdFooter',
12681
+ color: 'transparent',
12682
+ padless: true,
12683
+ rightSlot: [
12684
+ {
12685
+ name: `${this.name}-modal-selection-cancelButton`,
12686
+ component: 'ZdButton',
12687
+ label: 'CANCEL',
12688
+ keyMap: {
12689
+ esc: {
12690
+ event: this.hideModalSelection.bind(this),
12691
+ focus: true,
12692
+ visible: true,
12693
+ input: true,
12694
+ stop: true,
12695
+ },
12696
+ },
12697
+ outline: true,
12698
+ events: {
12699
+ click: this.hideModalSelection.bind(this),
12700
+ },
12701
+ },
12702
+ {
12703
+ name: `${this.name}-modal-selection-confirmButton`,
12704
+ component: 'ZdButton',
12705
+ label: 'OK',
12706
+ outline: false,
12707
+ events: {
12708
+ click: this.confirmModalSelection.bind(this),
12709
+ },
12710
+ },
12711
+ ],
12712
+ },
12713
+ ],
12714
+ },
12715
+ ],
12716
+ events: {
12717
+ onShow: () => {
12718
+ const grid = core.Metadata.getInstance(`${this.name}-modal-selection-grid`);
12719
+ grid.selectedRows = this.selectedValue;
12720
+ grid.datasource.currentRow = {};
12721
+ },
12722
+ },
12723
+ };
12724
+ return modalSelectionDef;
12725
+ }
12609
12726
  }
12610
12727
 
12611
12728
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.106.1",
3
+ "version": "1.107.0",
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": "466f25f5bf00183a2c22ef94eecb47d997ac4bab"
46
+ "gitHead": "de37eeff43ce90aa7d0fb08ca85c6706aced0927"
47
47
  }
@@ -98,7 +98,7 @@ export declare class Input extends ComponentRender implements IInput {
98
98
  /**
99
99
  * Input validations.
100
100
  */
101
- validations: IDictionary<IDictionary<string | number>>;
101
+ validations: IDictionary<IDictionary<string | number> | boolean>;
102
102
  /**
103
103
  * Defines if the input should be automatically registered in the closest parent Form
104
104
  */
@@ -33,7 +33,7 @@ export interface IInput extends IComponentRender {
33
33
  showHelper?: boolean;
34
34
  showLabel?: boolean;
35
35
  storePath?: string;
36
- validations?: IDictionary<IDictionary<string | number>>;
36
+ validations?: IDictionary<IDictionary<string | number> | boolean>;
37
37
  value?: any;
38
38
  autoRegister?: boolean;
39
39
  }
@@ -25,5 +25,5 @@ export interface ISelect extends ITextInput, ISelectDataValueOut {
25
25
  searchParam?: string;
26
26
  closeOnScroll?: boolean;
27
27
  modalSelection?: boolean;
28
- modalSelectionFields?: IColumn[];
28
+ modalSelectionColumns?: IColumn[];
29
29
  }
@@ -4,6 +4,7 @@ import { ISelect, SearchParam } from './interfaces';
4
4
  import { TextInput } from '../zd-text-input/text-input';
5
5
  import { ISelectDataValueOutItem } from '../../utils';
6
6
  import { IColumn } from '../zd-iterable/interfaces';
7
+ import { IModal } from '../zd-modal/interfaces';
7
8
  /**
8
9
  * Base class for Select component.
9
10
  */
@@ -94,7 +95,7 @@ export declare class Select extends TextInput implements ISelect {
94
95
  dataValueOutFormName: string;
95
96
  closeOnScroll: boolean;
96
97
  modalSelection?: boolean | undefined;
97
- modalSelectionFields: IColumn[];
98
+ modalSelectionColumns: IColumn[];
98
99
  protected dsSearch: {
99
100
  SEARCH: (value: any, searchIn: string) => {
100
101
  searchIn: string[];
@@ -240,7 +241,8 @@ export declare class Select extends TextInput implements ISelect {
240
241
  indexOf(search: IDictionary | string | number): number;
241
242
  protected isFilledObj(obj: any): number | false;
242
243
  private modalSelectionObj?;
243
- private hideModalSelection;
244
+ protected hideModalSelection(): void;
244
245
  private modalSelectionGridClick;
246
+ protected getModalSelectionDef(): IModal;
245
247
  openModalSelection(): void;
246
248
  }
@@ -1,6 +1,7 @@
1
1
  import { IDictionary } from '@zeedhi/core';
2
2
  import { ISelectMultiple } from './interfaces';
3
3
  import { Select } from '../zd-select/select';
4
+ import { IModal } from '../zd-modal/interfaces';
4
5
  export declare class SelectMultiple extends Select implements ISelectMultiple {
5
6
  private selectedValue;
6
7
  /**
@@ -112,4 +113,6 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
112
113
  * Updates input rules.
113
114
  */
114
115
  protected updateRules(): void;
116
+ private confirmModalSelection;
117
+ protected getModalSelectionDef(): IModal;
115
118
  }