@zeedhi/common 1.85.0 → 1.86.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.
- package/dist/zd-common.esm.js +87 -53
- package/dist/zd-common.umd.js +87 -53
- package/package.json +2 -2
- package/types/components/zd-grid/grid.d.ts +4 -3
- package/types/components/zd-header/header.d.ts +1 -1
- package/types/components/zd-input/input.d.ts +4 -1
- package/types/components/zd-iterable/interfaces.d.ts +1 -0
- package/types/components/zd-iterable/search.d.ts +2 -1
- package/types/components/zd-select/interfaces.d.ts +2 -0
- package/types/components/zd-select/select.d.ts +4 -0
- package/types/components/zd-select-multiple/select-multiple.d.ts +2 -2
package/dist/zd-common.esm.js
CHANGED
|
@@ -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.
|
|
1926
|
-
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);
|
|
@@ -5604,6 +5612,17 @@ class Iterable extends ComponentRender {
|
|
|
5604
5612
|
}
|
|
5605
5613
|
}
|
|
5606
5614
|
|
|
5615
|
+
/**
|
|
5616
|
+
* Delete rows error
|
|
5617
|
+
*/
|
|
5618
|
+
class DeleteRowsError extends Error {
|
|
5619
|
+
constructor() {
|
|
5620
|
+
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5621
|
+
+ ' You should delete them manually');
|
|
5622
|
+
this.name = 'DeleteRowsError';
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
|
|
5607
5626
|
/**
|
|
5608
5627
|
* Base class for Grid column
|
|
5609
5628
|
*/
|
|
@@ -5766,17 +5785,6 @@ const toggleableFormatter = ({ value, componentProps }) => {
|
|
|
5766
5785
|
FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5767
5786
|
FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5768
5787
|
|
|
5769
|
-
/**
|
|
5770
|
-
* Delete rows error
|
|
5771
|
-
*/
|
|
5772
|
-
class DeleteRowsError extends Error {
|
|
5773
|
-
constructor() {
|
|
5774
|
-
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5775
|
-
+ ' You should delete them manually');
|
|
5776
|
-
this.name = 'DeleteRowsError';
|
|
5777
|
-
}
|
|
5778
|
-
}
|
|
5779
|
-
|
|
5780
5788
|
/**
|
|
5781
5789
|
* Base class for Grid component
|
|
5782
5790
|
*/
|
|
@@ -6218,16 +6226,9 @@ class Grid extends Iterable {
|
|
|
6218
6226
|
const compName = actionComponent.name;
|
|
6219
6227
|
const instanceName = `${compName}_${rowKey}`;
|
|
6220
6228
|
const path = parentPath ? `${parentPath}.${compName}` : compName;
|
|
6221
|
-
const
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
const compEvents = Event.factory(props.events);
|
|
6225
|
-
if (typeof compEvents.click === 'function') {
|
|
6226
|
-
newClickEvt = ({ component, event, element }) => compEvents.click({
|
|
6227
|
-
component, event, element, row, column,
|
|
6228
|
-
});
|
|
6229
|
-
}
|
|
6230
|
-
}
|
|
6229
|
+
const compActivator = (_a = actionComponent.activator) !== null && _a !== void 0 ? _a : undefined;
|
|
6230
|
+
const props = merge({}, actionComponent, (_c = (_b = this.actionsApplied[rowKey]) === null || _b === void 0 ? void 0 : _b[column.name]) === null || _c === void 0 ? void 0 : _c[path]);
|
|
6231
|
+
const newClickEvt = this.setGridRowsInEvents(props, column, row);
|
|
6231
6232
|
const children = props.children || [];
|
|
6232
6233
|
const newChildren = children.map((child) => this.getActionProps(child, column, row, path).props);
|
|
6233
6234
|
props.children = newChildren;
|
|
@@ -6247,6 +6248,12 @@ class Grid extends Iterable {
|
|
|
6247
6248
|
}
|
|
6248
6249
|
if (newClickEvt)
|
|
6249
6250
|
props.events.click = newClickEvt;
|
|
6251
|
+
if (compActivator) {
|
|
6252
|
+
const newActivatorClickEvt = this.setGridRowsInEvents(compActivator, column, row);
|
|
6253
|
+
if (newActivatorClickEvt) {
|
|
6254
|
+
props.activator.events.click = newActivatorClickEvt;
|
|
6255
|
+
}
|
|
6256
|
+
}
|
|
6250
6257
|
return { props, instance };
|
|
6251
6258
|
}
|
|
6252
6259
|
updateActionInstance(instanceName, newComponent) {
|
|
@@ -6278,6 +6285,18 @@ class Grid extends Iterable {
|
|
|
6278
6285
|
}
|
|
6279
6286
|
return {};
|
|
6280
6287
|
}
|
|
6288
|
+
setGridRowsInEvents(comp, column, row) {
|
|
6289
|
+
var _a;
|
|
6290
|
+
if ((_a = comp.events) === null || _a === void 0 ? void 0 : _a.click) {
|
|
6291
|
+
const compEvents = Event.factory(comp.events);
|
|
6292
|
+
if (typeof compEvents.click === 'function') {
|
|
6293
|
+
return ({ component, event, element }) => compEvents.click({
|
|
6294
|
+
component, event, element, row, column,
|
|
6295
|
+
});
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
6298
|
+
return undefined;
|
|
6299
|
+
}
|
|
6281
6300
|
}
|
|
6282
6301
|
|
|
6283
6302
|
/**
|
|
@@ -6871,7 +6890,7 @@ class Header extends ComponentRender {
|
|
|
6871
6890
|
/**
|
|
6872
6891
|
* Sets the height for header.
|
|
6873
6892
|
*/
|
|
6874
|
-
this.height = '
|
|
6893
|
+
this.height = '';
|
|
6875
6894
|
/**
|
|
6876
6895
|
* Render components on the left of header.
|
|
6877
6896
|
*/
|
|
@@ -7302,6 +7321,10 @@ class Select extends TextInput {
|
|
|
7302
7321
|
* Enables search input
|
|
7303
7322
|
*/
|
|
7304
7323
|
this.autocomplete = true;
|
|
7324
|
+
/**
|
|
7325
|
+
* Automatically select option if only one is filtered
|
|
7326
|
+
*/
|
|
7327
|
+
this.autoSelection = true;
|
|
7305
7328
|
/**
|
|
7306
7329
|
* Prevents load select data when the input is focused
|
|
7307
7330
|
*/
|
|
@@ -7380,6 +7403,7 @@ class Select extends TextInput {
|
|
|
7380
7403
|
this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
|
|
7381
7404
|
this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
|
|
7382
7405
|
this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
|
|
7406
|
+
this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
|
|
7383
7407
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
7384
7408
|
this.manualMode = this.getInitValue('manualMode', props.manualMode, this.manualMode);
|
|
7385
7409
|
this.attach = this.getInitValue('attach', props.attach, this.attach);
|
|
@@ -7728,6 +7752,9 @@ class Select extends TextInput {
|
|
|
7728
7752
|
*/
|
|
7729
7753
|
blur(event, element) {
|
|
7730
7754
|
if (this.autocomplete) {
|
|
7755
|
+
if (this.search && this.autoSelection && this.datasource.data.length === 1) {
|
|
7756
|
+
this.setValue(this.datasource.data[0]);
|
|
7757
|
+
}
|
|
7731
7758
|
this.datasource.search = '';
|
|
7732
7759
|
this.dirtySearchValue = '';
|
|
7733
7760
|
if (!this.manualMode) {
|
|
@@ -7950,6 +7977,7 @@ class Search extends TextInput {
|
|
|
7950
7977
|
*/
|
|
7951
7978
|
constructor(props) {
|
|
7952
7979
|
super(props);
|
|
7980
|
+
this.lazyAttach = false;
|
|
7953
7981
|
this.debounceSetSearch = debounce(this.setSearch, 500);
|
|
7954
7982
|
this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
|
|
7955
7983
|
this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
|
|
@@ -7957,10 +7985,13 @@ class Search extends TextInput {
|
|
|
7957
7985
|
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'magnify');
|
|
7958
7986
|
this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
|
|
7959
7987
|
this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
|
|
7960
|
-
this.
|
|
7988
|
+
this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
|
|
7989
|
+
if (!this.lazyAttach)
|
|
7990
|
+
this.setIterableComponent();
|
|
7961
7991
|
this.createAccessors();
|
|
7962
7992
|
}
|
|
7963
|
-
setIterableComponent() {
|
|
7993
|
+
setIterableComponent(name) {
|
|
7994
|
+
this.iterableComponentName = name || this.iterableComponentName;
|
|
7964
7995
|
if (this.iterableComponentName && Metadata.getInstances(this.iterableComponentName).length > 0) {
|
|
7965
7996
|
this.iterableComponent = Metadata.getInstance(this.iterableComponentName);
|
|
7966
7997
|
}
|
|
@@ -9682,33 +9713,7 @@ class SelectMultiple extends Select {
|
|
|
9682
9713
|
this.dataText = [this.dataText];
|
|
9683
9714
|
this.internalDisplayValue = this.getDisplayValue();
|
|
9684
9715
|
this.createAccessors();
|
|
9685
|
-
|
|
9686
|
-
afterFocus() {
|
|
9687
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9688
|
-
if (!this.preventLoadOnFocus) {
|
|
9689
|
-
yield this.datasource.get();
|
|
9690
|
-
const values = this.datasource.data.map((row) => row[this.dataValue]);
|
|
9691
|
-
// remove inserted items that are already in datasource
|
|
9692
|
-
this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
|
|
9693
|
-
this.preventLoadOnFocus = true;
|
|
9694
|
-
}
|
|
9695
|
-
this.setCache();
|
|
9696
|
-
this.updateSearch(this.dirtySearchValue);
|
|
9697
|
-
});
|
|
9698
|
-
}
|
|
9699
|
-
setCache() {
|
|
9700
|
-
if (this.manualMode)
|
|
9701
|
-
return;
|
|
9702
|
-
if (this.insertedValues.length) {
|
|
9703
|
-
this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
|
|
9704
|
-
const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
|
|
9705
|
-
// prevent caching insertedValues
|
|
9706
|
-
this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
|
|
9707
|
-
}
|
|
9708
|
-
else {
|
|
9709
|
-
this.cachedData = this.datasource.data;
|
|
9710
|
-
}
|
|
9711
|
-
this.cachedTotal = this.datasource.total;
|
|
9716
|
+
this.autoSelection = false;
|
|
9712
9717
|
}
|
|
9713
9718
|
/**
|
|
9714
9719
|
* Field selected rows
|
|
@@ -10016,6 +10021,33 @@ class SelectMultiple extends Select {
|
|
|
10016
10021
|
});
|
|
10017
10022
|
}
|
|
10018
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
|
+
}
|
|
10019
10051
|
}
|
|
10020
10052
|
|
|
10021
10053
|
class TreeDataStructure {
|
|
@@ -12558,6 +12590,8 @@ class TreeGrid extends Grid {
|
|
|
12558
12590
|
this.flat = this.getInitValue('flat', props.flat, this.flat);
|
|
12559
12591
|
this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
|
|
12560
12592
|
this.detach = this.getInitValue('detach', props.detach, this.detach);
|
|
12593
|
+
this.footerSlot = props.footerSlot || this.footerSlot;
|
|
12594
|
+
this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
|
|
12561
12595
|
this.treeDataStructure = new TreeDataStructure(this);
|
|
12562
12596
|
this.createAccessors();
|
|
12563
12597
|
}
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -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.
|
|
1933
|
-
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);
|
|
@@ -5611,6 +5619,17 @@
|
|
|
5611
5619
|
}
|
|
5612
5620
|
}
|
|
5613
5621
|
|
|
5622
|
+
/**
|
|
5623
|
+
* Delete rows error
|
|
5624
|
+
*/
|
|
5625
|
+
class DeleteRowsError extends Error {
|
|
5626
|
+
constructor() {
|
|
5627
|
+
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5628
|
+
+ ' You should delete them manually');
|
|
5629
|
+
this.name = 'DeleteRowsError';
|
|
5630
|
+
}
|
|
5631
|
+
}
|
|
5632
|
+
|
|
5614
5633
|
/**
|
|
5615
5634
|
* Base class for Grid column
|
|
5616
5635
|
*/
|
|
@@ -5773,17 +5792,6 @@
|
|
|
5773
5792
|
core.FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
|
|
5774
5793
|
core.FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
|
|
5775
5794
|
|
|
5776
|
-
/**
|
|
5777
|
-
* Delete rows error
|
|
5778
|
-
*/
|
|
5779
|
-
class DeleteRowsError extends Error {
|
|
5780
|
-
constructor() {
|
|
5781
|
-
super('Grid can\'t automatically delete rows when selectAllPages property is true.'
|
|
5782
|
-
+ ' You should delete them manually');
|
|
5783
|
-
this.name = 'DeleteRowsError';
|
|
5784
|
-
}
|
|
5785
|
-
}
|
|
5786
|
-
|
|
5787
5795
|
/**
|
|
5788
5796
|
* Base class for Grid component
|
|
5789
5797
|
*/
|
|
@@ -6225,16 +6233,9 @@
|
|
|
6225
6233
|
const compName = actionComponent.name;
|
|
6226
6234
|
const instanceName = `${compName}_${rowKey}`;
|
|
6227
6235
|
const path = parentPath ? `${parentPath}.${compName}` : compName;
|
|
6228
|
-
const
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
const compEvents = core.Event.factory(props.events);
|
|
6232
|
-
if (typeof compEvents.click === 'function') {
|
|
6233
|
-
newClickEvt = ({ component, event, element }) => compEvents.click({
|
|
6234
|
-
component, event, element, row, column,
|
|
6235
|
-
});
|
|
6236
|
-
}
|
|
6237
|
-
}
|
|
6236
|
+
const compActivator = (_a = actionComponent.activator) !== null && _a !== void 0 ? _a : undefined;
|
|
6237
|
+
const props = merge__default["default"]({}, actionComponent, (_c = (_b = this.actionsApplied[rowKey]) === null || _b === void 0 ? void 0 : _b[column.name]) === null || _c === void 0 ? void 0 : _c[path]);
|
|
6238
|
+
const newClickEvt = this.setGridRowsInEvents(props, column, row);
|
|
6238
6239
|
const children = props.children || [];
|
|
6239
6240
|
const newChildren = children.map((child) => this.getActionProps(child, column, row, path).props);
|
|
6240
6241
|
props.children = newChildren;
|
|
@@ -6254,6 +6255,12 @@
|
|
|
6254
6255
|
}
|
|
6255
6256
|
if (newClickEvt)
|
|
6256
6257
|
props.events.click = newClickEvt;
|
|
6258
|
+
if (compActivator) {
|
|
6259
|
+
const newActivatorClickEvt = this.setGridRowsInEvents(compActivator, column, row);
|
|
6260
|
+
if (newActivatorClickEvt) {
|
|
6261
|
+
props.activator.events.click = newActivatorClickEvt;
|
|
6262
|
+
}
|
|
6263
|
+
}
|
|
6257
6264
|
return { props, instance };
|
|
6258
6265
|
}
|
|
6259
6266
|
updateActionInstance(instanceName, newComponent) {
|
|
@@ -6285,6 +6292,18 @@
|
|
|
6285
6292
|
}
|
|
6286
6293
|
return {};
|
|
6287
6294
|
}
|
|
6295
|
+
setGridRowsInEvents(comp, column, row) {
|
|
6296
|
+
var _a;
|
|
6297
|
+
if ((_a = comp.events) === null || _a === void 0 ? void 0 : _a.click) {
|
|
6298
|
+
const compEvents = core.Event.factory(comp.events);
|
|
6299
|
+
if (typeof compEvents.click === 'function') {
|
|
6300
|
+
return ({ component, event, element }) => compEvents.click({
|
|
6301
|
+
component, event, element, row, column,
|
|
6302
|
+
});
|
|
6303
|
+
}
|
|
6304
|
+
}
|
|
6305
|
+
return undefined;
|
|
6306
|
+
}
|
|
6288
6307
|
}
|
|
6289
6308
|
|
|
6290
6309
|
/**
|
|
@@ -6878,7 +6897,7 @@
|
|
|
6878
6897
|
/**
|
|
6879
6898
|
* Sets the height for header.
|
|
6880
6899
|
*/
|
|
6881
|
-
this.height = '
|
|
6900
|
+
this.height = '';
|
|
6882
6901
|
/**
|
|
6883
6902
|
* Render components on the left of header.
|
|
6884
6903
|
*/
|
|
@@ -7309,6 +7328,10 @@
|
|
|
7309
7328
|
* Enables search input
|
|
7310
7329
|
*/
|
|
7311
7330
|
this.autocomplete = true;
|
|
7331
|
+
/**
|
|
7332
|
+
* Automatically select option if only one is filtered
|
|
7333
|
+
*/
|
|
7334
|
+
this.autoSelection = true;
|
|
7312
7335
|
/**
|
|
7313
7336
|
* Prevents load select data when the input is focused
|
|
7314
7337
|
*/
|
|
@@ -7387,6 +7410,7 @@
|
|
|
7387
7410
|
this.menuMaxWidth = this.getInitValue('menuMaxWidth', props.menuMaxWidth, this.menuMaxWidth);
|
|
7388
7411
|
this.returnObject = this.getInitValue('returnObject', props.returnObject, this.returnObject);
|
|
7389
7412
|
this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
|
|
7413
|
+
this.autoSelection = this.getInitValue('autoSelection', props.autoSelection, this.autoSelection);
|
|
7390
7414
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
7391
7415
|
this.manualMode = this.getInitValue('manualMode', props.manualMode, this.manualMode);
|
|
7392
7416
|
this.attach = this.getInitValue('attach', props.attach, this.attach);
|
|
@@ -7735,6 +7759,9 @@
|
|
|
7735
7759
|
*/
|
|
7736
7760
|
blur(event, element) {
|
|
7737
7761
|
if (this.autocomplete) {
|
|
7762
|
+
if (this.search && this.autoSelection && this.datasource.data.length === 1) {
|
|
7763
|
+
this.setValue(this.datasource.data[0]);
|
|
7764
|
+
}
|
|
7738
7765
|
this.datasource.search = '';
|
|
7739
7766
|
this.dirtySearchValue = '';
|
|
7740
7767
|
if (!this.manualMode) {
|
|
@@ -7957,6 +7984,7 @@
|
|
|
7957
7984
|
*/
|
|
7958
7985
|
constructor(props) {
|
|
7959
7986
|
super(props);
|
|
7987
|
+
this.lazyAttach = false;
|
|
7960
7988
|
this.debounceSetSearch = debounce__default["default"](this.setSearch, 500);
|
|
7961
7989
|
this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
|
|
7962
7990
|
this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
|
|
@@ -7964,10 +7992,13 @@
|
|
|
7964
7992
|
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'magnify');
|
|
7965
7993
|
this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
|
|
7966
7994
|
this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
|
|
7967
|
-
this.
|
|
7995
|
+
this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
|
|
7996
|
+
if (!this.lazyAttach)
|
|
7997
|
+
this.setIterableComponent();
|
|
7968
7998
|
this.createAccessors();
|
|
7969
7999
|
}
|
|
7970
|
-
setIterableComponent() {
|
|
8000
|
+
setIterableComponent(name) {
|
|
8001
|
+
this.iterableComponentName = name || this.iterableComponentName;
|
|
7971
8002
|
if (this.iterableComponentName && core.Metadata.getInstances(this.iterableComponentName).length > 0) {
|
|
7972
8003
|
this.iterableComponent = core.Metadata.getInstance(this.iterableComponentName);
|
|
7973
8004
|
}
|
|
@@ -9689,33 +9720,7 @@
|
|
|
9689
9720
|
this.dataText = [this.dataText];
|
|
9690
9721
|
this.internalDisplayValue = this.getDisplayValue();
|
|
9691
9722
|
this.createAccessors();
|
|
9692
|
-
|
|
9693
|
-
afterFocus() {
|
|
9694
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9695
|
-
if (!this.preventLoadOnFocus) {
|
|
9696
|
-
yield this.datasource.get();
|
|
9697
|
-
const values = this.datasource.data.map((row) => row[this.dataValue]);
|
|
9698
|
-
// remove inserted items that are already in datasource
|
|
9699
|
-
this.insertedValues = this.insertedValues.filter((inserted) => !values.includes(inserted[this.dataValue]));
|
|
9700
|
-
this.preventLoadOnFocus = true;
|
|
9701
|
-
}
|
|
9702
|
-
this.setCache();
|
|
9703
|
-
this.updateSearch(this.dirtySearchValue);
|
|
9704
|
-
});
|
|
9705
|
-
}
|
|
9706
|
-
setCache() {
|
|
9707
|
-
if (this.manualMode)
|
|
9708
|
-
return;
|
|
9709
|
-
if (this.insertedValues.length) {
|
|
9710
|
-
this.datasource.data = this.uniqueBy(this.insertedValues.concat(this.datasource.data), this.datasource.uniqueKey);
|
|
9711
|
-
const values = this.insertedValues.map((inserted) => inserted[this.dataValue]);
|
|
9712
|
-
// prevent caching insertedValues
|
|
9713
|
-
this.cachedData = this.datasource.data.filter((row) => !values.includes(row[this.dataValue]));
|
|
9714
|
-
}
|
|
9715
|
-
else {
|
|
9716
|
-
this.cachedData = this.datasource.data;
|
|
9717
|
-
}
|
|
9718
|
-
this.cachedTotal = this.datasource.total;
|
|
9723
|
+
this.autoSelection = false;
|
|
9719
9724
|
}
|
|
9720
9725
|
/**
|
|
9721
9726
|
* Field selected rows
|
|
@@ -10023,6 +10028,33 @@
|
|
|
10023
10028
|
});
|
|
10024
10029
|
}
|
|
10025
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
|
+
}
|
|
10026
10058
|
}
|
|
10027
10059
|
|
|
10028
10060
|
class TreeDataStructure {
|
|
@@ -12565,6 +12597,8 @@
|
|
|
12565
12597
|
this.flat = this.getInitValue('flat', props.flat, this.flat);
|
|
12566
12598
|
this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
|
|
12567
12599
|
this.detach = this.getInitValue('detach', props.detach, this.detach);
|
|
12600
|
+
this.footerSlot = props.footerSlot || this.footerSlot;
|
|
12601
|
+
this.footerSlot = this.changeDefaultSlotNames(this.footerSlot);
|
|
12568
12602
|
this.treeDataStructure = new TreeDataStructure(this);
|
|
12569
12603
|
this.createAccessors();
|
|
12570
12604
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.86.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": "
|
|
46
|
+
"gitHead": "2f8e32655e215c690b1dabb81bc8b3f5cfa213d7"
|
|
47
47
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IDictionary } from '@zeedhi/core';
|
|
2
|
-
import {
|
|
3
|
-
import { Iterable } from '../zd-iterable/iterable';
|
|
2
|
+
import { Component } from '../zd-component/component';
|
|
4
3
|
import { IComponent, IComponentRender } from '../zd-component/interfaces';
|
|
4
|
+
import { Iterable } from '../zd-iterable/iterable';
|
|
5
5
|
import { GridColumn } from './grid-column';
|
|
6
|
-
import {
|
|
6
|
+
import { IGrid, IGridColumn, IGridEvents } from './interfaces';
|
|
7
7
|
/**
|
|
8
8
|
* Base class for Grid component
|
|
9
9
|
*/
|
|
@@ -212,4 +212,5 @@ export declare class Grid extends Iterable implements IGrid {
|
|
|
212
212
|
protected changeDefaultSlotNames(slot: IComponentRender[]): any;
|
|
213
213
|
callDisableSelection(row: IDictionary<any>): boolean;
|
|
214
214
|
getRowStyleConditions(row: IDictionary<any>): IDictionary<any>;
|
|
215
|
+
private setGridRowsInEvents;
|
|
215
216
|
}
|
|
@@ -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
|
}
|
|
@@ -13,12 +13,13 @@ export declare class Search extends TextInput implements ISearch {
|
|
|
13
13
|
* Iterable component name
|
|
14
14
|
*/
|
|
15
15
|
iterableComponent: Iterable;
|
|
16
|
+
lazyAttach: boolean;
|
|
16
17
|
/**
|
|
17
18
|
* Creates a new Iterable Page component.
|
|
18
19
|
* @param props Iterable page component properties
|
|
19
20
|
*/
|
|
20
21
|
constructor(props: ISearch);
|
|
21
|
-
|
|
22
|
+
setIterableComponent(name?: string): void;
|
|
22
23
|
protected setSearch(search: string): Promise<void>;
|
|
23
24
|
debounceSetSearch: (search: string) => void;
|
|
24
25
|
}
|
|
@@ -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
|
}
|