@zeedhi/common 1.94.3 → 1.96.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 +105 -22
- package/dist/zd-common.umd.js +105 -22
- package/package.json +2 -2
- package/types/components/zd-component/component.d.ts +2 -1
- package/types/components/zd-component/interfaces.d.ts +2 -1
- package/types/components/zd-file-input/file-input.d.ts +3 -0
- package/types/components/zd-form/form.d.ts +1 -0
- package/types/components/zd-grid/grid-column.d.ts +1 -0
- package/types/components/zd-grid/grid-editable.d.ts +1 -1
- package/types/components/zd-image/image.d.ts +6 -1
- package/types/components/zd-image/interfaces.d.ts +5 -1
- package/types/components/zd-input/input.d.ts +4 -4
- package/types/components/zd-menu/interfaces.d.ts +1 -0
- package/types/components/zd-menu/menu.d.ts +2 -0
- package/types/components/zd-select/interfaces.d.ts +1 -1
- package/types/components/zd-select/select.d.ts +10 -1
- package/types/components/zd-select-multiple/interfaces.d.ts +2 -0
- package/types/components/zd-select-multiple/select-multiple.d.ts +8 -0
- package/types/components/zd-tree-grid/tree-grid-editable.d.ts +1 -1
- package/types/services/zd-json-cache/json-cache-service.d.ts +12 -0
package/dist/zd-common.esm.js
CHANGED
|
@@ -83,6 +83,7 @@ class Component {
|
|
|
83
83
|
* Return if component can receive focus using tab
|
|
84
84
|
*/
|
|
85
85
|
this.tabStop = true;
|
|
86
|
+
this.userProperties = {};
|
|
86
87
|
this.accessorManager = new AccessorManager();
|
|
87
88
|
this.parent = props.parent;
|
|
88
89
|
this.name = props.name;
|
|
@@ -96,6 +97,7 @@ class Component {
|
|
|
96
97
|
this.dark = this.getInitValue('dark', props.dark, this.dark);
|
|
97
98
|
this.light = this.getInitValue('light', props.light, this.light);
|
|
98
99
|
this.tabStop = this.getInitValue('tabStop', props.tabStop, this.tabStop);
|
|
100
|
+
this.userProperties = this.getInitValue('userProperties', props.userProperties, this.userProperties);
|
|
99
101
|
this.children = Array.isArray(props.children) ? props.children : this.children;
|
|
100
102
|
this.keyMap = KeyMap.factory(props.keyMap || this.keyMap);
|
|
101
103
|
this.createAccessors();
|
|
@@ -1973,7 +1975,9 @@ class Input extends ComponentRender {
|
|
|
1973
1975
|
*/
|
|
1974
1976
|
addValidation(name, config) {
|
|
1975
1977
|
const validation = Validation.get(name)(config);
|
|
1976
|
-
|
|
1978
|
+
if (config) {
|
|
1979
|
+
this.validations[name] = config;
|
|
1980
|
+
}
|
|
1977
1981
|
this.parsedValidations[name] = validation;
|
|
1978
1982
|
this.updateRules();
|
|
1979
1983
|
}
|
|
@@ -4931,7 +4935,37 @@ class FileInput extends TextInput {
|
|
|
4931
4935
|
}
|
|
4932
4936
|
}
|
|
4933
4937
|
}
|
|
4934
|
-
|
|
4938
|
+
setViewGetFileSizes(getFileSizes) {
|
|
4939
|
+
this.viewGetFileSizes = getFileSizes;
|
|
4940
|
+
}
|
|
4941
|
+
updateRules() {
|
|
4942
|
+
this.rules = Object.keys(this.parsedValidations)
|
|
4943
|
+
.map((key) => {
|
|
4944
|
+
const validation = this.parsedValidations[key];
|
|
4945
|
+
if (key !== 'maxFileSize')
|
|
4946
|
+
return () => validation(this.value);
|
|
4947
|
+
return () => {
|
|
4948
|
+
if (this.viewGetFileSizes) {
|
|
4949
|
+
const fileSizes = this.viewGetFileSizes();
|
|
4950
|
+
return validation(fileSizes);
|
|
4951
|
+
}
|
|
4952
|
+
return true;
|
|
4953
|
+
};
|
|
4954
|
+
});
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
Validation.register('maxFileSize', (config) => (fileSizes) => {
|
|
4958
|
+
let fileError = '';
|
|
4959
|
+
Object.keys(fileSizes).some((fileName) => {
|
|
4960
|
+
if (fileSizes[fileName] > config.limit) {
|
|
4961
|
+
fileError = fileName;
|
|
4962
|
+
return true;
|
|
4963
|
+
}
|
|
4964
|
+
return false;
|
|
4965
|
+
});
|
|
4966
|
+
const message = I18n.translate((config.message || 'VALIDATION_FILE_SIZE'), { fileError });
|
|
4967
|
+
return (fileError === '') || message;
|
|
4968
|
+
});
|
|
4935
4969
|
|
|
4936
4970
|
/**
|
|
4937
4971
|
* Base class for Footer component.
|
|
@@ -7210,6 +7244,10 @@ class Image extends ComponentRender {
|
|
|
7210
7244
|
this.validImage = true;
|
|
7211
7245
|
this.srcValue = src;
|
|
7212
7246
|
}
|
|
7247
|
+
load(event, element) {
|
|
7248
|
+
this.loadImage();
|
|
7249
|
+
this.callEvent('load', { event, element, component: this });
|
|
7250
|
+
}
|
|
7213
7251
|
}
|
|
7214
7252
|
|
|
7215
7253
|
/**
|
|
@@ -7493,6 +7531,12 @@ class Select extends TextInput {
|
|
|
7493
7531
|
[searchIn]: value,
|
|
7494
7532
|
},
|
|
7495
7533
|
}),
|
|
7534
|
+
DYNAMIC_FILTER: (value, search_in) => {
|
|
7535
|
+
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
7536
|
+
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
7537
|
+
const dynamicFilter = { [search_in]: filter };
|
|
7538
|
+
return { dynamicFilter };
|
|
7539
|
+
},
|
|
7496
7540
|
};
|
|
7497
7541
|
/**
|
|
7498
7542
|
* Input search value
|
|
@@ -7635,13 +7679,16 @@ class Select extends TextInput {
|
|
|
7635
7679
|
*/
|
|
7636
7680
|
getItemsBySearchValue(value, searchIn) {
|
|
7637
7681
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7638
|
-
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true });
|
|
7682
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
|
|
7639
7683
|
this.datasource.loading = true;
|
|
7640
7684
|
const datasource = DatasourceFactory.factory(config);
|
|
7641
7685
|
const items = yield datasource.get();
|
|
7642
7686
|
this.datasource.loading = false;
|
|
7643
7687
|
datasource.destroy();
|
|
7644
|
-
|
|
7688
|
+
if (Array.isArray(value)) {
|
|
7689
|
+
return items.filter((item) => value.includes(item[this.dataValue]));
|
|
7690
|
+
}
|
|
7691
|
+
return items.filter(this.getCondition(value));
|
|
7645
7692
|
});
|
|
7646
7693
|
}
|
|
7647
7694
|
getCondition(filterValue) {
|
|
@@ -7746,7 +7793,7 @@ class Select extends TextInput {
|
|
|
7746
7793
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
7747
7794
|
let searchValue = foundInData;
|
|
7748
7795
|
if (!foundInData && !this.manualMode) {
|
|
7749
|
-
searchValue = yield this.getItemsBySearchValue(filterValue, searchIn);
|
|
7796
|
+
[searchValue] = yield this.getItemsBySearchValue(filterValue, searchIn);
|
|
7750
7797
|
}
|
|
7751
7798
|
if (!searchValue) {
|
|
7752
7799
|
this.setFieldRowValue(null);
|
|
@@ -8907,6 +8954,8 @@ class Menu extends ComponentRender {
|
|
|
8907
8954
|
/** Store the current item focused */
|
|
8908
8955
|
this.currentItem = null;
|
|
8909
8956
|
this.cache = false;
|
|
8957
|
+
/** Disable watcher that close menu when route changes */
|
|
8958
|
+
this.disableRouteWatcher = false;
|
|
8910
8959
|
this.app = this.getInitValue('app', props.app, this.app);
|
|
8911
8960
|
this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
|
|
8912
8961
|
this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
|
|
@@ -8926,8 +8975,9 @@ class Menu extends ComponentRender {
|
|
|
8926
8975
|
this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
|
|
8927
8976
|
this.width = this.getInitValue('width', props.width, this.width);
|
|
8928
8977
|
this.cache = this.getInitValue('cache', props.cache, this.cache);
|
|
8978
|
+
this.disableRouteWatcher = this.getInitValue('disableRouteWatcher', props.disableRouteWatcher, this.disableRouteWatcher);
|
|
8929
8979
|
this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
|
|
8930
|
-
this.drawer = window.innerWidth > this.mobileBreakpoint;
|
|
8980
|
+
this.drawer = window.innerWidth > parseInt(this.mobileBreakpoint.toString(), 10);
|
|
8931
8981
|
this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
|
|
8932
8982
|
if (this.openedInitialValue !== undefined) {
|
|
8933
8983
|
this.opened = this.openedInitialValue;
|
|
@@ -9008,7 +9058,7 @@ class Menu extends ComponentRender {
|
|
|
9008
9058
|
* Toggle menu
|
|
9009
9059
|
*/
|
|
9010
9060
|
toggleMenu() {
|
|
9011
|
-
const isMobile = window.innerWidth <= this.mobileBreakpoint;
|
|
9061
|
+
const isMobile = window.innerWidth <= parseInt(this.mobileBreakpoint.toString(), 10);
|
|
9012
9062
|
if (this.closeToMini && !isMobile) {
|
|
9013
9063
|
this.miniState = !this.miniState;
|
|
9014
9064
|
if (this.miniState) {
|
|
@@ -9843,12 +9893,16 @@ class SelectMultiple extends Select {
|
|
|
9843
9893
|
*/
|
|
9844
9894
|
this.limit = null;
|
|
9845
9895
|
this.showSelectAll = false;
|
|
9896
|
+
this.showCheckboxAll = false;
|
|
9897
|
+
this.checkboxAllValue = false;
|
|
9846
9898
|
if (!this.selectedValue) {
|
|
9847
9899
|
this.selectedValue = [];
|
|
9848
9900
|
}
|
|
9849
9901
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
9850
9902
|
this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
|
|
9851
9903
|
this.limit = this.getInitValue('limit', props.limit, this.limit);
|
|
9904
|
+
this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
|
|
9905
|
+
this.checkboxAll = this.getInitValue('checkboxAll', props.checkboxAll, this.checkboxAll);
|
|
9852
9906
|
if (!Array.isArray(this.dataText))
|
|
9853
9907
|
this.dataText = [this.dataText];
|
|
9854
9908
|
this.internalDisplayValue = this.getDisplayValue();
|
|
@@ -9878,6 +9932,13 @@ class SelectMultiple extends Select {
|
|
|
9878
9932
|
this.selectedValue = rows;
|
|
9879
9933
|
this.setFieldValue(this.getValues(rows));
|
|
9880
9934
|
}
|
|
9935
|
+
get checkboxAll() {
|
|
9936
|
+
return this.checkboxAllValue;
|
|
9937
|
+
}
|
|
9938
|
+
set checkboxAll(value) {
|
|
9939
|
+
this.disabled = value;
|
|
9940
|
+
this.checkboxAllValue = value;
|
|
9941
|
+
}
|
|
9881
9942
|
/**
|
|
9882
9943
|
* Removes item from array a and add it to array b if condition is satisfied
|
|
9883
9944
|
*/
|
|
@@ -9889,8 +9950,8 @@ class SelectMultiple extends Select {
|
|
|
9889
9950
|
}
|
|
9890
9951
|
setFieldValue(value) {
|
|
9891
9952
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9892
|
-
const
|
|
9893
|
-
const
|
|
9953
|
+
const foundValues = [];
|
|
9954
|
+
const searchedValues = [];
|
|
9894
9955
|
let pushed = false;
|
|
9895
9956
|
value.forEach((row) => {
|
|
9896
9957
|
let filterValue;
|
|
@@ -9900,27 +9961,37 @@ class SelectMultiple extends Select {
|
|
|
9900
9961
|
else {
|
|
9901
9962
|
filterValue = row;
|
|
9902
9963
|
}
|
|
9903
|
-
const searchIn = this.dataValue;
|
|
9904
9964
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
9905
9965
|
if (foundInData) {
|
|
9906
|
-
|
|
9966
|
+
foundValues.push(foundInData);
|
|
9907
9967
|
}
|
|
9908
9968
|
else if (!this.manualMode) {
|
|
9909
|
-
|
|
9910
|
-
if (item) {
|
|
9911
|
-
searchValues.push(item);
|
|
9912
|
-
this.datasource.data.unshift(item);
|
|
9913
|
-
this.insertedValues.push(item);
|
|
9914
|
-
pushed = true;
|
|
9915
|
-
}
|
|
9916
|
-
}));
|
|
9969
|
+
searchedValues.push(filterValue);
|
|
9917
9970
|
}
|
|
9918
9971
|
});
|
|
9919
|
-
|
|
9972
|
+
const insertItem = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
9973
|
+
if (!item)
|
|
9974
|
+
return;
|
|
9975
|
+
foundValues.push(item);
|
|
9976
|
+
this.datasource.data.unshift(item);
|
|
9977
|
+
this.insertedValues.push(item);
|
|
9978
|
+
pushed = true;
|
|
9979
|
+
});
|
|
9980
|
+
// using filter/find/dynamicFilter should make only 1 request
|
|
9981
|
+
// using normal search should make one request per search value
|
|
9982
|
+
if (this.searchParam !== 'SEARCH') {
|
|
9983
|
+
const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
|
|
9984
|
+
items.forEach(insertItem);
|
|
9985
|
+
}
|
|
9986
|
+
else {
|
|
9987
|
+
const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
|
|
9988
|
+
const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
|
|
9989
|
+
insertItem(item);
|
|
9990
|
+
}));
|
|
9920
9991
|
yield Promise.all(promises);
|
|
9921
9992
|
}
|
|
9922
|
-
if (
|
|
9923
|
-
this.setFieldRowValue(
|
|
9993
|
+
if (foundValues.length > 0) {
|
|
9994
|
+
this.setFieldRowValue(foundValues);
|
|
9924
9995
|
}
|
|
9925
9996
|
else {
|
|
9926
9997
|
this.setFieldRowValue([]);
|
|
@@ -10169,6 +10240,18 @@ class SelectMultiple extends Select {
|
|
|
10169
10240
|
}
|
|
10170
10241
|
this.cachedTotal = this.datasource.total;
|
|
10171
10242
|
}
|
|
10243
|
+
/**
|
|
10244
|
+
* Updates input rules.
|
|
10245
|
+
*/
|
|
10246
|
+
updateRules() {
|
|
10247
|
+
this.rules = Object.keys(this.parsedValidations)
|
|
10248
|
+
.map((key) => () => {
|
|
10249
|
+
const validation = this.parsedValidations[key];
|
|
10250
|
+
if (key !== 'required')
|
|
10251
|
+
return validation(this.value);
|
|
10252
|
+
return validation((this.checkboxAll && 'all') || this.value);
|
|
10253
|
+
});
|
|
10254
|
+
}
|
|
10172
10255
|
}
|
|
10173
10256
|
|
|
10174
10257
|
class TreeDataStructure {
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
* Return if component can receive focus using tab
|
|
91
91
|
*/
|
|
92
92
|
this.tabStop = true;
|
|
93
|
+
this.userProperties = {};
|
|
93
94
|
this.accessorManager = new core.AccessorManager();
|
|
94
95
|
this.parent = props.parent;
|
|
95
96
|
this.name = props.name;
|
|
@@ -103,6 +104,7 @@
|
|
|
103
104
|
this.dark = this.getInitValue('dark', props.dark, this.dark);
|
|
104
105
|
this.light = this.getInitValue('light', props.light, this.light);
|
|
105
106
|
this.tabStop = this.getInitValue('tabStop', props.tabStop, this.tabStop);
|
|
107
|
+
this.userProperties = this.getInitValue('userProperties', props.userProperties, this.userProperties);
|
|
106
108
|
this.children = Array.isArray(props.children) ? props.children : this.children;
|
|
107
109
|
this.keyMap = core.KeyMap.factory(props.keyMap || this.keyMap);
|
|
108
110
|
this.createAccessors();
|
|
@@ -1980,7 +1982,9 @@
|
|
|
1980
1982
|
*/
|
|
1981
1983
|
addValidation(name, config) {
|
|
1982
1984
|
const validation = core.Validation.get(name)(config);
|
|
1983
|
-
|
|
1985
|
+
if (config) {
|
|
1986
|
+
this.validations[name] = config;
|
|
1987
|
+
}
|
|
1984
1988
|
this.parsedValidations[name] = validation;
|
|
1985
1989
|
this.updateRules();
|
|
1986
1990
|
}
|
|
@@ -4938,7 +4942,37 @@
|
|
|
4938
4942
|
}
|
|
4939
4943
|
}
|
|
4940
4944
|
}
|
|
4941
|
-
|
|
4945
|
+
setViewGetFileSizes(getFileSizes) {
|
|
4946
|
+
this.viewGetFileSizes = getFileSizes;
|
|
4947
|
+
}
|
|
4948
|
+
updateRules() {
|
|
4949
|
+
this.rules = Object.keys(this.parsedValidations)
|
|
4950
|
+
.map((key) => {
|
|
4951
|
+
const validation = this.parsedValidations[key];
|
|
4952
|
+
if (key !== 'maxFileSize')
|
|
4953
|
+
return () => validation(this.value);
|
|
4954
|
+
return () => {
|
|
4955
|
+
if (this.viewGetFileSizes) {
|
|
4956
|
+
const fileSizes = this.viewGetFileSizes();
|
|
4957
|
+
return validation(fileSizes);
|
|
4958
|
+
}
|
|
4959
|
+
return true;
|
|
4960
|
+
};
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
core.Validation.register('maxFileSize', (config) => (fileSizes) => {
|
|
4965
|
+
let fileError = '';
|
|
4966
|
+
Object.keys(fileSizes).some((fileName) => {
|
|
4967
|
+
if (fileSizes[fileName] > config.limit) {
|
|
4968
|
+
fileError = fileName;
|
|
4969
|
+
return true;
|
|
4970
|
+
}
|
|
4971
|
+
return false;
|
|
4972
|
+
});
|
|
4973
|
+
const message = core.I18n.translate((config.message || 'VALIDATION_FILE_SIZE'), { fileError });
|
|
4974
|
+
return (fileError === '') || message;
|
|
4975
|
+
});
|
|
4942
4976
|
|
|
4943
4977
|
/**
|
|
4944
4978
|
* Base class for Footer component.
|
|
@@ -7217,6 +7251,10 @@
|
|
|
7217
7251
|
this.validImage = true;
|
|
7218
7252
|
this.srcValue = src;
|
|
7219
7253
|
}
|
|
7254
|
+
load(event, element) {
|
|
7255
|
+
this.loadImage();
|
|
7256
|
+
this.callEvent('load', { event, element, component: this });
|
|
7257
|
+
}
|
|
7220
7258
|
}
|
|
7221
7259
|
|
|
7222
7260
|
/**
|
|
@@ -7500,6 +7538,12 @@
|
|
|
7500
7538
|
[searchIn]: value,
|
|
7501
7539
|
},
|
|
7502
7540
|
}),
|
|
7541
|
+
DYNAMIC_FILTER: (value, search_in) => {
|
|
7542
|
+
const arrayValue = Array.isArray(value) ? value : Array.of(value);
|
|
7543
|
+
const filter = arrayValue.map((item) => ({ operation: 'EQUALS', relation: 'OR', value: item }));
|
|
7544
|
+
const dynamicFilter = { [search_in]: filter };
|
|
7545
|
+
return { dynamicFilter };
|
|
7546
|
+
},
|
|
7503
7547
|
};
|
|
7504
7548
|
/**
|
|
7505
7549
|
* Input search value
|
|
@@ -7642,13 +7686,16 @@
|
|
|
7642
7686
|
*/
|
|
7643
7687
|
getItemsBySearchValue(value, searchIn) {
|
|
7644
7688
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7645
|
-
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true });
|
|
7689
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.datasource.clone()), this.dsSearch[this.searchParam](value, searchIn)), { lazyLoad: true, loadAll: Array.isArray(value) });
|
|
7646
7690
|
this.datasource.loading = true;
|
|
7647
7691
|
const datasource = core.DatasourceFactory.factory(config);
|
|
7648
7692
|
const items = yield datasource.get();
|
|
7649
7693
|
this.datasource.loading = false;
|
|
7650
7694
|
datasource.destroy();
|
|
7651
|
-
|
|
7695
|
+
if (Array.isArray(value)) {
|
|
7696
|
+
return items.filter((item) => value.includes(item[this.dataValue]));
|
|
7697
|
+
}
|
|
7698
|
+
return items.filter(this.getCondition(value));
|
|
7652
7699
|
});
|
|
7653
7700
|
}
|
|
7654
7701
|
getCondition(filterValue) {
|
|
@@ -7753,7 +7800,7 @@
|
|
|
7753
7800
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
7754
7801
|
let searchValue = foundInData;
|
|
7755
7802
|
if (!foundInData && !this.manualMode) {
|
|
7756
|
-
searchValue = yield this.getItemsBySearchValue(filterValue, searchIn);
|
|
7803
|
+
[searchValue] = yield this.getItemsBySearchValue(filterValue, searchIn);
|
|
7757
7804
|
}
|
|
7758
7805
|
if (!searchValue) {
|
|
7759
7806
|
this.setFieldRowValue(null);
|
|
@@ -8914,6 +8961,8 @@
|
|
|
8914
8961
|
/** Store the current item focused */
|
|
8915
8962
|
this.currentItem = null;
|
|
8916
8963
|
this.cache = false;
|
|
8964
|
+
/** Disable watcher that close menu when route changes */
|
|
8965
|
+
this.disableRouteWatcher = false;
|
|
8917
8966
|
this.app = this.getInitValue('app', props.app, this.app);
|
|
8918
8967
|
this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
|
|
8919
8968
|
this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
|
|
@@ -8933,8 +8982,9 @@
|
|
|
8933
8982
|
this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
|
|
8934
8983
|
this.width = this.getInitValue('width', props.width, this.width);
|
|
8935
8984
|
this.cache = this.getInitValue('cache', props.cache, this.cache);
|
|
8985
|
+
this.disableRouteWatcher = this.getInitValue('disableRouteWatcher', props.disableRouteWatcher, this.disableRouteWatcher);
|
|
8936
8986
|
this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
|
|
8937
|
-
this.drawer = window.innerWidth > this.mobileBreakpoint;
|
|
8987
|
+
this.drawer = window.innerWidth > parseInt(this.mobileBreakpoint.toString(), 10);
|
|
8938
8988
|
this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
|
|
8939
8989
|
if (this.openedInitialValue !== undefined) {
|
|
8940
8990
|
this.opened = this.openedInitialValue;
|
|
@@ -9015,7 +9065,7 @@
|
|
|
9015
9065
|
* Toggle menu
|
|
9016
9066
|
*/
|
|
9017
9067
|
toggleMenu() {
|
|
9018
|
-
const isMobile = window.innerWidth <= this.mobileBreakpoint;
|
|
9068
|
+
const isMobile = window.innerWidth <= parseInt(this.mobileBreakpoint.toString(), 10);
|
|
9019
9069
|
if (this.closeToMini && !isMobile) {
|
|
9020
9070
|
this.miniState = !this.miniState;
|
|
9021
9071
|
if (this.miniState) {
|
|
@@ -9850,12 +9900,16 @@
|
|
|
9850
9900
|
*/
|
|
9851
9901
|
this.limit = null;
|
|
9852
9902
|
this.showSelectAll = false;
|
|
9903
|
+
this.showCheckboxAll = false;
|
|
9904
|
+
this.checkboxAllValue = false;
|
|
9853
9905
|
if (!this.selectedValue) {
|
|
9854
9906
|
this.selectedValue = [];
|
|
9855
9907
|
}
|
|
9856
9908
|
this.showSelectAll = this.getInitValue('showSelectAll', props.showSelectAll, this.showSelectAll);
|
|
9857
9909
|
this.maxRows = this.getInitValue('maxRows', props.maxRows, this.maxRows);
|
|
9858
9910
|
this.limit = this.getInitValue('limit', props.limit, this.limit);
|
|
9911
|
+
this.showCheckboxAll = this.getInitValue('showCheckboxAll', props.showCheckboxAll, this.showCheckboxAll);
|
|
9912
|
+
this.checkboxAll = this.getInitValue('checkboxAll', props.checkboxAll, this.checkboxAll);
|
|
9859
9913
|
if (!Array.isArray(this.dataText))
|
|
9860
9914
|
this.dataText = [this.dataText];
|
|
9861
9915
|
this.internalDisplayValue = this.getDisplayValue();
|
|
@@ -9885,6 +9939,13 @@
|
|
|
9885
9939
|
this.selectedValue = rows;
|
|
9886
9940
|
this.setFieldValue(this.getValues(rows));
|
|
9887
9941
|
}
|
|
9942
|
+
get checkboxAll() {
|
|
9943
|
+
return this.checkboxAllValue;
|
|
9944
|
+
}
|
|
9945
|
+
set checkboxAll(value) {
|
|
9946
|
+
this.disabled = value;
|
|
9947
|
+
this.checkboxAllValue = value;
|
|
9948
|
+
}
|
|
9888
9949
|
/**
|
|
9889
9950
|
* Removes item from array a and add it to array b if condition is satisfied
|
|
9890
9951
|
*/
|
|
@@ -9896,8 +9957,8 @@
|
|
|
9896
9957
|
}
|
|
9897
9958
|
setFieldValue(value) {
|
|
9898
9959
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9899
|
-
const
|
|
9900
|
-
const
|
|
9960
|
+
const foundValues = [];
|
|
9961
|
+
const searchedValues = [];
|
|
9901
9962
|
let pushed = false;
|
|
9902
9963
|
value.forEach((row) => {
|
|
9903
9964
|
let filterValue;
|
|
@@ -9907,27 +9968,37 @@
|
|
|
9907
9968
|
else {
|
|
9908
9969
|
filterValue = row;
|
|
9909
9970
|
}
|
|
9910
|
-
const searchIn = this.dataValue;
|
|
9911
9971
|
const foundInData = this.datasource.data.find(this.getCondition(filterValue));
|
|
9912
9972
|
if (foundInData) {
|
|
9913
|
-
|
|
9973
|
+
foundValues.push(foundInData);
|
|
9914
9974
|
}
|
|
9915
9975
|
else if (!this.manualMode) {
|
|
9916
|
-
|
|
9917
|
-
if (item) {
|
|
9918
|
-
searchValues.push(item);
|
|
9919
|
-
this.datasource.data.unshift(item);
|
|
9920
|
-
this.insertedValues.push(item);
|
|
9921
|
-
pushed = true;
|
|
9922
|
-
}
|
|
9923
|
-
}));
|
|
9976
|
+
searchedValues.push(filterValue);
|
|
9924
9977
|
}
|
|
9925
9978
|
});
|
|
9926
|
-
|
|
9979
|
+
const insertItem = (item) => __awaiter(this, void 0, void 0, function* () {
|
|
9980
|
+
if (!item)
|
|
9981
|
+
return;
|
|
9982
|
+
foundValues.push(item);
|
|
9983
|
+
this.datasource.data.unshift(item);
|
|
9984
|
+
this.insertedValues.push(item);
|
|
9985
|
+
pushed = true;
|
|
9986
|
+
});
|
|
9987
|
+
// using filter/find/dynamicFilter should make only 1 request
|
|
9988
|
+
// using normal search should make one request per search value
|
|
9989
|
+
if (this.searchParam !== 'SEARCH') {
|
|
9990
|
+
const items = yield this.getItemsBySearchValue(searchedValues, this.dataValue);
|
|
9991
|
+
items.forEach(insertItem);
|
|
9992
|
+
}
|
|
9993
|
+
else {
|
|
9994
|
+
const promises = searchedValues.map((searchedValue) => __awaiter(this, void 0, void 0, function* () {
|
|
9995
|
+
const [item] = yield this.getItemsBySearchValue(searchedValue, this.dataValue);
|
|
9996
|
+
insertItem(item);
|
|
9997
|
+
}));
|
|
9927
9998
|
yield Promise.all(promises);
|
|
9928
9999
|
}
|
|
9929
|
-
if (
|
|
9930
|
-
this.setFieldRowValue(
|
|
10000
|
+
if (foundValues.length > 0) {
|
|
10001
|
+
this.setFieldRowValue(foundValues);
|
|
9931
10002
|
}
|
|
9932
10003
|
else {
|
|
9933
10004
|
this.setFieldRowValue([]);
|
|
@@ -10176,6 +10247,18 @@
|
|
|
10176
10247
|
}
|
|
10177
10248
|
this.cachedTotal = this.datasource.total;
|
|
10178
10249
|
}
|
|
10250
|
+
/**
|
|
10251
|
+
* Updates input rules.
|
|
10252
|
+
*/
|
|
10253
|
+
updateRules() {
|
|
10254
|
+
this.rules = Object.keys(this.parsedValidations)
|
|
10255
|
+
.map((key) => () => {
|
|
10256
|
+
const validation = this.parsedValidations[key];
|
|
10257
|
+
if (key !== 'required')
|
|
10258
|
+
return validation(this.value);
|
|
10259
|
+
return validation((this.checkboxAll && 'all') || this.value);
|
|
10260
|
+
});
|
|
10261
|
+
}
|
|
10179
10262
|
}
|
|
10180
10263
|
|
|
10181
10264
|
class TreeDataStructure {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.96.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": "4df47f4fde302b75598f5744945c86fb3aad4b6a"
|
|
47
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IKeyMap } from '@zeedhi/core';
|
|
1
|
+
import { IKeyMap, IDictionary } from '@zeedhi/core';
|
|
2
2
|
import { IComponent, IComponentDirectives, IComponentEvents } from './interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* Base class for all Zeedhi components.
|
|
@@ -75,6 +75,7 @@ export declare class Component implements IComponent {
|
|
|
75
75
|
* Return if component can receive focus using tab
|
|
76
76
|
*/
|
|
77
77
|
tabStop: boolean;
|
|
78
|
+
userProperties: IDictionary<any>;
|
|
78
79
|
/**
|
|
79
80
|
* Properties accessors to controller.
|
|
80
81
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IEvent, IEvents, IEventParam, IKeyMap } from '@zeedhi/core';
|
|
1
|
+
import { IEvent, IEvents, IEventParam, IKeyMap, IDictionary } from '@zeedhi/core';
|
|
2
2
|
import { Component } from './component';
|
|
3
3
|
export interface IPropAccessor {
|
|
4
4
|
[key: string]: {
|
|
@@ -22,6 +22,7 @@ export interface IComponent {
|
|
|
22
22
|
name: string;
|
|
23
23
|
parent?: Component;
|
|
24
24
|
tabStop?: boolean;
|
|
25
|
+
userProperties?: IDictionary;
|
|
25
26
|
[key: string]: any;
|
|
26
27
|
}
|
|
27
28
|
export interface IComponentRender extends IComponent {
|
|
@@ -65,6 +65,7 @@ export declare class FileInput extends TextInput implements IFileInput {
|
|
|
65
65
|
*/
|
|
66
66
|
protected internalValue: any;
|
|
67
67
|
selectFileButton: IButton;
|
|
68
|
+
private viewGetFileSizes;
|
|
68
69
|
/**
|
|
69
70
|
* Create a new FileInput
|
|
70
71
|
* @param props FileInput definition
|
|
@@ -95,4 +96,6 @@ export declare class FileInput extends TextInput implements IFileInput {
|
|
|
95
96
|
* @param files File array
|
|
96
97
|
*/
|
|
97
98
|
dropFiles(files: File[]): void;
|
|
99
|
+
setViewGetFileSizes(getFileSizes: () => object): void;
|
|
100
|
+
protected updateRules(): void;
|
|
98
101
|
}
|
|
@@ -115,6 +115,7 @@ export declare class Form extends ComponentRender implements IForm {
|
|
|
115
115
|
name: string;
|
|
116
116
|
parent?: import("..").Component | undefined;
|
|
117
117
|
tabStop?: boolean | undefined;
|
|
118
|
+
userProperties?: IDictionary<any> | undefined;
|
|
118
119
|
}[];
|
|
119
120
|
/**
|
|
120
121
|
* Grid system for each child.
|
|
@@ -32,6 +32,7 @@ export declare class GridColumn extends Column implements IGridColumn {
|
|
|
32
32
|
name: string;
|
|
33
33
|
parent?: import("..").Component | undefined;
|
|
34
34
|
tabStop?: boolean | undefined;
|
|
35
|
+
userProperties?: IDictionary<any> | undefined;
|
|
35
36
|
}[];
|
|
36
37
|
/**
|
|
37
38
|
* Get the Column without the conditions object
|
|
@@ -135,7 +135,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
135
135
|
* @param column Column
|
|
136
136
|
* @param row Row
|
|
137
137
|
*/
|
|
138
|
-
isValid(column: IGridColumnEditable, row: IDictionary, revalidate?: boolean): boolean;
|
|
138
|
+
isValid(column: IGridColumnEditable, row: IDictionary, revalidate?: boolean): string | boolean;
|
|
139
139
|
private newRowIdentifier;
|
|
140
140
|
/**
|
|
141
141
|
* Cancels all edited rows and enable grid components
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IImage } from './interfaces';
|
|
1
|
+
import { IImage, IImageEvents } from './interfaces';
|
|
2
2
|
import { ComponentRender } from '../zd-component/component-render';
|
|
3
3
|
/**
|
|
4
4
|
* The Image component <code>zd-image</code> is used to show images.
|
|
@@ -62,6 +62,10 @@ export declare class Image extends ComponentRender implements IImage {
|
|
|
62
62
|
*/
|
|
63
63
|
private srcValue;
|
|
64
64
|
validImage: any;
|
|
65
|
+
/**
|
|
66
|
+
* Defines image events.
|
|
67
|
+
*/
|
|
68
|
+
events: IImageEvents;
|
|
65
69
|
/**
|
|
66
70
|
* Creates a new Image.
|
|
67
71
|
* @param props Image properties
|
|
@@ -77,4 +81,5 @@ export declare class Image extends ComponentRender implements IImage {
|
|
|
77
81
|
errorImage(): void;
|
|
78
82
|
get src(): string;
|
|
79
83
|
set src(src: string);
|
|
84
|
+
load(event?: Event, element?: HTMLElement): void;
|
|
80
85
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { IEventParam } from '@zeedhi/core';
|
|
2
2
|
import { Image } from './image';
|
|
3
|
-
import { IComponentRender } from '../zd-component/interfaces';
|
|
3
|
+
import { EventDef, IComponentEvents, IComponentRender } from '../zd-component/interfaces';
|
|
4
4
|
export declare type IImageEvent = IEventParam<Image>;
|
|
5
|
+
export interface IImageEvents<T = IEventParam<any>> extends IComponentEvents<T> {
|
|
6
|
+
load?: EventDef<T>;
|
|
7
|
+
}
|
|
5
8
|
export interface IImage extends IComponentRender {
|
|
6
9
|
alt?: string;
|
|
7
10
|
errorImagePath?: string;
|
|
@@ -15,4 +18,5 @@ export interface IImage extends IComponentRender {
|
|
|
15
18
|
width?: number | string;
|
|
16
19
|
maxWidth?: number | string;
|
|
17
20
|
minWidth?: number | string;
|
|
21
|
+
events?: IImageEvents;
|
|
18
22
|
}
|
|
@@ -110,7 +110,7 @@ export declare class Input extends ComponentRender implements IInput {
|
|
|
110
110
|
/**
|
|
111
111
|
* Parsed field rules.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
protected parsedValidations: IDictionary<((value: any) => boolean | string)>;
|
|
114
114
|
protected formatterFn: Function;
|
|
115
115
|
protected parserFn: Function;
|
|
116
116
|
protected internalDisplayValue: string;
|
|
@@ -124,11 +124,11 @@ export declare class Input extends ComponentRender implements IInput {
|
|
|
124
124
|
/**
|
|
125
125
|
* Validates input.
|
|
126
126
|
*/
|
|
127
|
-
validate(): boolean;
|
|
127
|
+
validate(): string | boolean;
|
|
128
128
|
/**
|
|
129
129
|
* Sets view validation method.
|
|
130
130
|
*/
|
|
131
|
-
setViewValidate(viewValidate: () => boolean): void;
|
|
131
|
+
setViewValidate(viewValidate: () => boolean | string): void;
|
|
132
132
|
/**
|
|
133
133
|
* Sets view reset validation method.
|
|
134
134
|
*/
|
|
@@ -161,7 +161,7 @@ export declare class Input extends ComponentRender implements IInput {
|
|
|
161
161
|
/**
|
|
162
162
|
* Updates input rules.
|
|
163
163
|
*/
|
|
164
|
-
|
|
164
|
+
protected updateRules(): void;
|
|
165
165
|
/**
|
|
166
166
|
* Input value.
|
|
167
167
|
*/
|
|
@@ -118,6 +118,8 @@ export declare class Menu extends ComponentRender implements IMenu {
|
|
|
118
118
|
/** Store the current item focused */
|
|
119
119
|
currentItem: IMenuItem | null;
|
|
120
120
|
cache?: boolean;
|
|
121
|
+
/** Disable watcher that close menu when route changes */
|
|
122
|
+
disableRouteWatcher?: boolean;
|
|
121
123
|
/**
|
|
122
124
|
* Creates a new Menu.
|
|
123
125
|
* @param props Menu properties
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IDatasource } from '@zeedhi/core';
|
|
2
2
|
import { ITextInput } from '../zd-text-input/interfaces';
|
|
3
3
|
import { IComponentRender } from '../zd-component/interfaces';
|
|
4
|
-
export declare type SearchParam = 'SEARCH' | 'FILTER' | 'FIND';
|
|
4
|
+
export declare type SearchParam = 'SEARCH' | 'FILTER' | 'FIND' | 'DYNAMIC_FILTER';
|
|
5
5
|
export interface ISelect extends ITextInput {
|
|
6
6
|
autocomplete?: boolean;
|
|
7
7
|
autoSelection?: boolean;
|
|
@@ -97,6 +97,15 @@ export declare class Select extends TextInput implements ISelect {
|
|
|
97
97
|
[x: string]: any;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
+
DYNAMIC_FILTER: (value: unknown, search_in: string) => {
|
|
101
|
+
dynamicFilter: {
|
|
102
|
+
[x: string]: {
|
|
103
|
+
operation: string;
|
|
104
|
+
relation: string;
|
|
105
|
+
value: any;
|
|
106
|
+
}[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
100
109
|
};
|
|
101
110
|
/**
|
|
102
111
|
* Input search value
|
|
@@ -135,7 +144,7 @@ export declare class Select extends TextInput implements ISelect {
|
|
|
135
144
|
* Finds and retrieves items searching by value
|
|
136
145
|
* @param value Default value
|
|
137
146
|
*/
|
|
138
|
-
protected getItemsBySearchValue(value: any, searchIn: string): Promise<any>;
|
|
147
|
+
protected getItemsBySearchValue(value: any, searchIn: string): Promise<any[]>;
|
|
139
148
|
protected getCondition(filterValue: any): (row: any) => boolean;
|
|
140
149
|
focus(event: Event, element: any): Promise<void>;
|
|
141
150
|
protected afterFocus(): Promise<void>;
|
|
@@ -24,6 +24,7 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
|
|
|
24
24
|
*/
|
|
25
25
|
limit: number | null;
|
|
26
26
|
showSelectAll: boolean;
|
|
27
|
+
showCheckboxAll: boolean;
|
|
27
28
|
/**
|
|
28
29
|
* Create a new Select.
|
|
29
30
|
* @param props Select properties
|
|
@@ -34,6 +35,9 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
|
|
|
34
35
|
*/
|
|
35
36
|
get selectValue(): IDictionary<any>[];
|
|
36
37
|
set selectValue(rows: IDictionary<any>[]);
|
|
38
|
+
private checkboxAllValue;
|
|
39
|
+
get checkboxAll(): boolean;
|
|
40
|
+
set checkboxAll(value: boolean);
|
|
37
41
|
/**
|
|
38
42
|
* Removes item from array a and add it to array b if condition is satisfied
|
|
39
43
|
*/
|
|
@@ -104,4 +108,8 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
|
|
|
104
108
|
protected checkValueOnBlur(): void;
|
|
105
109
|
protected afterFocus(): Promise<void>;
|
|
106
110
|
private setCache;
|
|
111
|
+
/**
|
|
112
|
+
* Updates input rules.
|
|
113
|
+
*/
|
|
114
|
+
protected updateRules(): void;
|
|
107
115
|
}
|
|
@@ -126,7 +126,7 @@ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEdita
|
|
|
126
126
|
* @param column Column
|
|
127
127
|
* @param row Row
|
|
128
128
|
*/
|
|
129
|
-
isValid(column: IGridColumnEditable, row: IDictionary, revalidate?: boolean): boolean;
|
|
129
|
+
isValid(column: IGridColumnEditable, row: IDictionary, revalidate?: boolean): string | boolean;
|
|
130
130
|
/**
|
|
131
131
|
* Cancels all edited rows and enable grid components
|
|
132
132
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IJSONObject {
|
|
2
|
+
path: string;
|
|
3
|
+
}
|
|
4
|
+
export declare class JsonCacheService {
|
|
5
|
+
/**
|
|
6
|
+
* jsons collection
|
|
7
|
+
*/
|
|
8
|
+
static jsonCollection: IJSONObject[];
|
|
9
|
+
static saveJSONCache(jsonCollection: IJSONObject[]): Promise<void>;
|
|
10
|
+
static getJSONCache(path: string): any;
|
|
11
|
+
static clearJSONCache(jsonCollection: IJSONObject[]): void;
|
|
12
|
+
}
|