@zeedhi/common 1.111.0 → 1.112.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 +65 -37
- package/dist/zd-common.umd.js +65 -37
- package/package.json +2 -2
- package/types/components/zd-date/date.d.ts +1 -1
- package/types/components/zd-grid/grid-editable.d.ts +5 -5
- package/types/components/zd-increment/increment.d.ts +2 -2
- package/types/components/zd-iterable/column.d.ts +2 -0
- package/types/components/zd-iterable/interfaces.d.ts +3 -0
- package/types/components/zd-iterable/search.d.ts +4 -0
- package/types/components/zd-tree-grid/tree-grid-editable.d.ts +4 -4
package/dist/zd-common.esm.js
CHANGED
|
@@ -3990,7 +3990,6 @@ class Date$1 extends TextInput {
|
|
|
3990
3990
|
this.parserFn = FormatterParserProvider.getParser('ZdDate');
|
|
3991
3991
|
this.previousHint = '';
|
|
3992
3992
|
this.previousPersistentHint = false;
|
|
3993
|
-
this.lastChangeValue = null;
|
|
3994
3993
|
this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
|
|
3995
3994
|
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
|
|
3996
3995
|
this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
|
|
@@ -5448,6 +5447,8 @@ class Column extends Component {
|
|
|
5448
5447
|
this.defaultData = [];
|
|
5449
5448
|
/* Column search mode */
|
|
5450
5449
|
this.searchMode = 'any';
|
|
5450
|
+
/* Column can be used to search */
|
|
5451
|
+
this.searchable = true;
|
|
5451
5452
|
this.lookup = debounce((lookupColumn) => {
|
|
5452
5453
|
this.loading = true;
|
|
5453
5454
|
const dataToLookup = Array.from(new Set(this.dataToLookup)); // remove duplicates
|
|
@@ -5479,7 +5480,9 @@ class Column extends Component {
|
|
|
5479
5480
|
this.xlsType = this.getInitValue('xlsType', props.xlsType, this.xlsType);
|
|
5480
5481
|
this.conditions = this.getInitValue('conditions', props.conditions, this.conditions);
|
|
5481
5482
|
this.searchMode = this.getInitValue('searchMode', props.searchMode, this.searchMode);
|
|
5483
|
+
this.searchable = this.getInitValue('searchable', props.searchable, this.searchable);
|
|
5482
5484
|
this.helperText = this.getInitValue('', props.helperText, this.helperText);
|
|
5485
|
+
this.valueIn = this.getInitValue('valueIn', props.valueIn, this.name);
|
|
5483
5486
|
this.createConditions();
|
|
5484
5487
|
this.createActionConditions();
|
|
5485
5488
|
if (this.componentProps.datasource) {
|
|
@@ -5511,7 +5514,7 @@ class Column extends Component {
|
|
|
5511
5514
|
throw new MethodNotAssignedError('viewGetWidth');
|
|
5512
5515
|
}
|
|
5513
5516
|
formatterByRow(row, cellProps) {
|
|
5514
|
-
const value = row[this.
|
|
5517
|
+
const value = row[this.valueIn];
|
|
5515
5518
|
const formatterFn = FormatterParserProvider.getFormatter(`column_${this.componentProps.component}`);
|
|
5516
5519
|
if (formatterFn) {
|
|
5517
5520
|
return formatterFn({
|
|
@@ -5846,7 +5849,9 @@ class Iterable extends ComponentRender {
|
|
|
5846
5849
|
});
|
|
5847
5850
|
}
|
|
5848
5851
|
isColumnSearchable(column) {
|
|
5849
|
-
return
|
|
5852
|
+
return column.searchable
|
|
5853
|
+
&& (!this.searchVisibleOnly || column.isVisible)
|
|
5854
|
+
&& (this.searchIn === undefined || this.searchIn === column.name);
|
|
5850
5855
|
}
|
|
5851
5856
|
}
|
|
5852
5857
|
|
|
@@ -7049,10 +7054,10 @@ class GridEditable extends Grid {
|
|
|
7049
7054
|
}
|
|
7050
7055
|
getVisibleValue(row, column) {
|
|
7051
7056
|
const key = row[this.datasource.uniqueKey];
|
|
7052
|
-
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.
|
|
7053
|
-
return this.editedRows[key][column.
|
|
7057
|
+
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
7058
|
+
return this.editedRows[key][column.valueIn];
|
|
7054
7059
|
}
|
|
7055
|
-
return row[column.
|
|
7060
|
+
return row[column.valueIn];
|
|
7056
7061
|
}
|
|
7057
7062
|
/**
|
|
7058
7063
|
* Returns editable component properties based on the column definition
|
|
@@ -7111,13 +7116,13 @@ class GridEditable extends Grid {
|
|
|
7111
7116
|
* If the row[column.name] has a selected value, pushes it
|
|
7112
7117
|
*/
|
|
7113
7118
|
checkLookupData(column, row, componentProps) {
|
|
7114
|
-
if (!row[column.
|
|
7119
|
+
if (!row[column.valueIn] || !column.lookupData || !componentProps.datasource)
|
|
7115
7120
|
return;
|
|
7116
7121
|
componentProps.datasource.data = componentProps.datasource.data || [];
|
|
7117
7122
|
// prevent pushing lookup values when using accessor in data
|
|
7118
7123
|
if (!Array.isArray(componentProps.datasource.data))
|
|
7119
7124
|
return;
|
|
7120
|
-
const colValue = row[column.
|
|
7125
|
+
const colValue = row[column.valueIn];
|
|
7121
7126
|
if (Array.isArray(colValue)) {
|
|
7122
7127
|
colValue.forEach((item) => {
|
|
7123
7128
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
@@ -7154,7 +7159,7 @@ class GridEditable extends Grid {
|
|
|
7154
7159
|
*/
|
|
7155
7160
|
changeEditableComponent(column, row, value, component) {
|
|
7156
7161
|
const key = row[this.datasource.uniqueKey];
|
|
7157
|
-
const columnName = column.
|
|
7162
|
+
const columnName = column.valueIn;
|
|
7158
7163
|
if (!Utils.isEqual(value, row[columnName])) {
|
|
7159
7164
|
const newRow = {};
|
|
7160
7165
|
newRow[key] = Object.assign({}, this.editedRows[key]);
|
|
@@ -7201,7 +7206,7 @@ class GridEditable extends Grid {
|
|
|
7201
7206
|
isEdited(column, row) {
|
|
7202
7207
|
const key = row[this.datasource.uniqueKey];
|
|
7203
7208
|
return this.editedRows[key]
|
|
7204
|
-
&& this.editedRows[key][column.
|
|
7209
|
+
&& this.editedRows[key][column.valueIn] !== this.editedRows[key][`${column.valueIn}_original`];
|
|
7205
7210
|
}
|
|
7206
7211
|
/**
|
|
7207
7212
|
* Checks if row is an added row
|
|
@@ -7385,7 +7390,7 @@ class GridEditable extends Grid {
|
|
|
7385
7390
|
const key = row[this.datasource.uniqueKey];
|
|
7386
7391
|
editableColumns.forEach((column) => {
|
|
7387
7392
|
const instance = componentInstances[column.name];
|
|
7388
|
-
if (!instance.isValid(row[column.
|
|
7393
|
+
if (!instance.isValid(row[column.valueIn])) {
|
|
7389
7394
|
invalidCompNames.push(this.getCompName(key, column.name));
|
|
7390
7395
|
}
|
|
7391
7396
|
});
|
|
@@ -7478,7 +7483,7 @@ class GridEditable extends Grid {
|
|
|
7478
7483
|
throw new RowNotFoundError(newRow[uniqueKey], this.name);
|
|
7479
7484
|
}
|
|
7480
7485
|
this.columns.forEach((column) => {
|
|
7481
|
-
const columnName = column.
|
|
7486
|
+
const columnName = column.valueIn;
|
|
7482
7487
|
this.changeCell(newRow[uniqueKey], rowIdx, column, newRow[columnName]);
|
|
7483
7488
|
});
|
|
7484
7489
|
}
|
|
@@ -7895,27 +7900,45 @@ class Increment extends Number$1 {
|
|
|
7895
7900
|
super.change(event, element);
|
|
7896
7901
|
}
|
|
7897
7902
|
/**
|
|
7898
|
-
*
|
|
7903
|
+
* Increases the component's value by the step amount.
|
|
7899
7904
|
*/
|
|
7900
7905
|
increment() {
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7906
|
+
const currentValue = Number(this.value);
|
|
7907
|
+
const isValueInvalid = this.value === null || this.value === '' || Number.isNaN(currentValue);
|
|
7908
|
+
// First, handle the case where the input is empty or not a number.
|
|
7909
|
+
if (isValueInvalid) {
|
|
7910
|
+
// Determine the starting value. Default to `minValue` if it's positive, otherwise start from `step`.
|
|
7911
|
+
const startValue = (this.minValue !== undefined && this.minValue > 0) ? this.minValue : this.step;
|
|
7912
|
+
// Set the value, but clamp it to the maximum limit if one exists.
|
|
7913
|
+
this.value = (this.maxValue !== undefined) ? Math.min(startValue, this.maxValue) : startValue;
|
|
7914
|
+
return;
|
|
7904
7915
|
}
|
|
7905
|
-
|
|
7906
|
-
|
|
7916
|
+
// If the input is a valid number, calculate the next value.
|
|
7917
|
+
const nextValue = currentValue + this.step;
|
|
7918
|
+
// Only update if the new value does not exceed the maximum boundary.
|
|
7919
|
+
if (this.maxValue === undefined || nextValue <= this.maxValue) {
|
|
7920
|
+
this.value = nextValue;
|
|
7907
7921
|
}
|
|
7908
7922
|
}
|
|
7909
7923
|
/**
|
|
7910
|
-
*
|
|
7924
|
+
* Decreases the component's value by the step amount.
|
|
7911
7925
|
*/
|
|
7912
7926
|
decrement() {
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7927
|
+
const currentValue = Number(this.value);
|
|
7928
|
+
const isValueInvalid = this.value === null || this.value === '' || Number.isNaN(currentValue);
|
|
7929
|
+
// First, handle the case where the input is empty or not a number.
|
|
7930
|
+
if (isValueInvalid) {
|
|
7931
|
+
// Determine the starting value. Handles the edge case where the max value is negative.
|
|
7932
|
+
const startValue = (this.maxValue !== undefined && this.maxValue < 0) ? this.maxValue : -this.step;
|
|
7933
|
+
// Set the value, but clamp it to the minimum limit if one exists.
|
|
7934
|
+
this.value = (this.minValue !== undefined) ? Math.max(startValue, this.minValue) : startValue;
|
|
7935
|
+
return;
|
|
7916
7936
|
}
|
|
7917
|
-
|
|
7918
|
-
|
|
7937
|
+
// If the input is a valid number, calculate the next value.
|
|
7938
|
+
const nextValue = currentValue - this.step;
|
|
7939
|
+
// Only update if the new value does not go below the minimum boundary.
|
|
7940
|
+
if (this.minValue === undefined || nextValue >= this.minValue) {
|
|
7941
|
+
this.value = nextValue;
|
|
7919
7942
|
}
|
|
7920
7943
|
}
|
|
7921
7944
|
}
|
|
@@ -10433,7 +10456,7 @@ class Select extends TextInput {
|
|
|
10433
10456
|
component: 'ZdGrid',
|
|
10434
10457
|
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
10435
10458
|
columns: this.modalSelectionColumns,
|
|
10436
|
-
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
10459
|
+
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { limit: this.defaultDatasource.limit, lazyLoad: false, searchIn: undefined }),
|
|
10437
10460
|
toolbarSlot: [
|
|
10438
10461
|
{
|
|
10439
10462
|
name: `${this.name}-modal-selection-title`,
|
|
@@ -10706,6 +10729,10 @@ class Search extends TextInput {
|
|
|
10706
10729
|
constructor(props) {
|
|
10707
10730
|
super(props);
|
|
10708
10731
|
this.lazyAttach = false;
|
|
10732
|
+
/**
|
|
10733
|
+
* * hide the option to select search field
|
|
10734
|
+
*/
|
|
10735
|
+
this.hideSearchField = false;
|
|
10709
10736
|
this.debounceSetSearch = debounce(this.setSearch, 500);
|
|
10710
10737
|
this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
|
|
10711
10738
|
this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
|
|
@@ -10714,6 +10741,7 @@ class Search extends TextInput {
|
|
|
10714
10741
|
this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
|
|
10715
10742
|
this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
|
|
10716
10743
|
this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
|
|
10744
|
+
this.hideSearchField = this.getInitValue('hideSearchField', props.hideSearchField, this.hideSearchField);
|
|
10717
10745
|
this.debounceSetSearch = this.debounceSetSearch.bind(this);
|
|
10718
10746
|
if (!this.lazyAttach)
|
|
10719
10747
|
this.setIterableComponent();
|
|
@@ -15561,10 +15589,10 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15561
15589
|
}
|
|
15562
15590
|
getVisibleValue(row, column) {
|
|
15563
15591
|
const key = row[this.datasource.uniqueKey];
|
|
15564
|
-
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.
|
|
15565
|
-
return this.editedRows[key][column.
|
|
15592
|
+
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
15593
|
+
return this.editedRows[key][column.valueIn];
|
|
15566
15594
|
}
|
|
15567
|
-
return row[column.
|
|
15595
|
+
return row[column.valueIn];
|
|
15568
15596
|
}
|
|
15569
15597
|
/**
|
|
15570
15598
|
* Returns editable component properties based on the column definition
|
|
@@ -15618,13 +15646,13 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15618
15646
|
* If the row[column.name] has a selected value, pushes it
|
|
15619
15647
|
*/
|
|
15620
15648
|
checkLookupData(column, row, componentProps) {
|
|
15621
|
-
if (!row[column.
|
|
15649
|
+
if (!row[column.valueIn] || !column.lookupData || !componentProps.datasource)
|
|
15622
15650
|
return;
|
|
15623
15651
|
componentProps.datasource.data = componentProps.datasource.data || [];
|
|
15624
15652
|
// prevent pushing lookup values when using accessor in data
|
|
15625
15653
|
if (!Array.isArray(componentProps.datasource.data))
|
|
15626
15654
|
return;
|
|
15627
|
-
const colValue = row[column.
|
|
15655
|
+
const colValue = row[column.valueIn];
|
|
15628
15656
|
if (Array.isArray(colValue)) {
|
|
15629
15657
|
colValue.forEach((item) => {
|
|
15630
15658
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
@@ -15661,7 +15689,7 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15661
15689
|
*/
|
|
15662
15690
|
changeEditableComponent(column, row, value, component) {
|
|
15663
15691
|
const key = row[this.datasource.uniqueKey];
|
|
15664
|
-
const columnName = column.
|
|
15692
|
+
const columnName = column.valueIn;
|
|
15665
15693
|
if (!Utils.isEqual(value, row[columnName])) {
|
|
15666
15694
|
const newRow = {};
|
|
15667
15695
|
newRow[key] = Object.assign({}, this.editedRows[key]);
|
|
@@ -15696,7 +15724,7 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15696
15724
|
isEdited(column, row) {
|
|
15697
15725
|
const key = row[this.datasource.uniqueKey];
|
|
15698
15726
|
return this.editedRows[key]
|
|
15699
|
-
&& this.editedRows[key][column.
|
|
15727
|
+
&& this.editedRows[key][column.valueIn] !== this.editedRows[key][`${column.valueIn}_original`];
|
|
15700
15728
|
}
|
|
15701
15729
|
/**
|
|
15702
15730
|
* Checks if column is valid
|
|
@@ -15833,7 +15861,7 @@ class TreeGridEditable extends TreeGrid {
|
|
|
15833
15861
|
throw new RowNotFoundError(newRow[uniqueKey], this.name);
|
|
15834
15862
|
}
|
|
15835
15863
|
this.columns.forEach((column) => {
|
|
15836
|
-
const columnName = column.
|
|
15864
|
+
const columnName = column.valueIn;
|
|
15837
15865
|
this.changeCell(newRow[uniqueKey], rowIdx, column, newRow[columnName]);
|
|
15838
15866
|
});
|
|
15839
15867
|
}
|
|
@@ -15918,7 +15946,7 @@ const getForeignLookupRow = (column, row, dataValue, dataTextColumns, foreignCol
|
|
|
15918
15946
|
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
15919
15947
|
lookupRow[dataTextName] = row[foreignColumns[dataTextName] || dataTextName];
|
|
15920
15948
|
});
|
|
15921
|
-
lookupRow[dataValue] = row[column.
|
|
15949
|
+
lookupRow[dataValue] = row[column.valueIn];
|
|
15922
15950
|
return lookupRow;
|
|
15923
15951
|
};
|
|
15924
15952
|
const getFormatterLookupRow = (column, row, dataValue, formatterDataTextColumns, dataTextColumns) => {
|
|
@@ -15929,7 +15957,7 @@ const getFormatterLookupRow = (column, row, dataValue, formatterDataTextColumns,
|
|
|
15929
15957
|
const formatterDataTextColumn = typeof item === 'string' ? item : item.name;
|
|
15930
15958
|
lookupRow[dataTextName] = row[formatterDataTextColumn];
|
|
15931
15959
|
});
|
|
15932
|
-
lookupRow[dataValue] = row[column.
|
|
15960
|
+
lookupRow[dataValue] = row[column.valueIn];
|
|
15933
15961
|
return lookupRow;
|
|
15934
15962
|
};
|
|
15935
15963
|
/**
|
|
@@ -15943,7 +15971,7 @@ const storeOrRetrieveLookup = (column, row, value, dataValue, componentProps) =>
|
|
|
15943
15971
|
const dataTextColumns = asArray(dataText);
|
|
15944
15972
|
// when using foreignColumns, should store foreign keys information in lookupData
|
|
15945
15973
|
if (foreignColumns) {
|
|
15946
|
-
column.lookupData[row[column.
|
|
15974
|
+
column.lookupData[row[column.valueIn]] = getForeignLookupRow(column, row, dataValue, dataTextColumns, foreignColumns);
|
|
15947
15975
|
return row;
|
|
15948
15976
|
}
|
|
15949
15977
|
// when not using formatterDataText, should fetch data from datasource to be able to format this cell
|
|
@@ -15953,7 +15981,7 @@ const storeOrRetrieveLookup = (column, row, value, dataValue, componentProps) =>
|
|
|
15953
15981
|
const formatterDataTextColumns = asArray(formatterDataText);
|
|
15954
15982
|
// when using formatterDataText, should store dataText information in lookupData
|
|
15955
15983
|
if (formatterDataTextColumns.length === dataTextColumns.length) {
|
|
15956
|
-
const rowColumn = row[column.
|
|
15984
|
+
const rowColumn = row[column.valueIn];
|
|
15957
15985
|
column.lookupData[rowColumn] = getFormatterLookupRow(column, row, dataValue, formatterDataTextColumns, dataTextColumns);
|
|
15958
15986
|
return row;
|
|
15959
15987
|
}
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -3997,7 +3997,6 @@
|
|
|
3997
3997
|
this.parserFn = core.FormatterParserProvider.getParser('ZdDate');
|
|
3998
3998
|
this.previousHint = '';
|
|
3999
3999
|
this.previousPersistentHint = false;
|
|
4000
|
-
this.lastChangeValue = null;
|
|
4001
4000
|
this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
|
|
4002
4001
|
this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
|
|
4003
4002
|
this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
|
|
@@ -5455,6 +5454,8 @@
|
|
|
5455
5454
|
this.defaultData = [];
|
|
5456
5455
|
/* Column search mode */
|
|
5457
5456
|
this.searchMode = 'any';
|
|
5457
|
+
/* Column can be used to search */
|
|
5458
|
+
this.searchable = true;
|
|
5458
5459
|
this.lookup = debounce__default["default"]((lookupColumn) => {
|
|
5459
5460
|
this.loading = true;
|
|
5460
5461
|
const dataToLookup = Array.from(new Set(this.dataToLookup)); // remove duplicates
|
|
@@ -5486,7 +5487,9 @@
|
|
|
5486
5487
|
this.xlsType = this.getInitValue('xlsType', props.xlsType, this.xlsType);
|
|
5487
5488
|
this.conditions = this.getInitValue('conditions', props.conditions, this.conditions);
|
|
5488
5489
|
this.searchMode = this.getInitValue('searchMode', props.searchMode, this.searchMode);
|
|
5490
|
+
this.searchable = this.getInitValue('searchable', props.searchable, this.searchable);
|
|
5489
5491
|
this.helperText = this.getInitValue('', props.helperText, this.helperText);
|
|
5492
|
+
this.valueIn = this.getInitValue('valueIn', props.valueIn, this.name);
|
|
5490
5493
|
this.createConditions();
|
|
5491
5494
|
this.createActionConditions();
|
|
5492
5495
|
if (this.componentProps.datasource) {
|
|
@@ -5518,7 +5521,7 @@
|
|
|
5518
5521
|
throw new core.MethodNotAssignedError('viewGetWidth');
|
|
5519
5522
|
}
|
|
5520
5523
|
formatterByRow(row, cellProps) {
|
|
5521
|
-
const value = row[this.
|
|
5524
|
+
const value = row[this.valueIn];
|
|
5522
5525
|
const formatterFn = core.FormatterParserProvider.getFormatter(`column_${this.componentProps.component}`);
|
|
5523
5526
|
if (formatterFn) {
|
|
5524
5527
|
return formatterFn({
|
|
@@ -5853,7 +5856,9 @@
|
|
|
5853
5856
|
});
|
|
5854
5857
|
}
|
|
5855
5858
|
isColumnSearchable(column) {
|
|
5856
|
-
return
|
|
5859
|
+
return column.searchable
|
|
5860
|
+
&& (!this.searchVisibleOnly || column.isVisible)
|
|
5861
|
+
&& (this.searchIn === undefined || this.searchIn === column.name);
|
|
5857
5862
|
}
|
|
5858
5863
|
}
|
|
5859
5864
|
|
|
@@ -7056,10 +7061,10 @@
|
|
|
7056
7061
|
}
|
|
7057
7062
|
getVisibleValue(row, column) {
|
|
7058
7063
|
const key = row[this.datasource.uniqueKey];
|
|
7059
|
-
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.
|
|
7060
|
-
return this.editedRows[key][column.
|
|
7064
|
+
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
7065
|
+
return this.editedRows[key][column.valueIn];
|
|
7061
7066
|
}
|
|
7062
|
-
return row[column.
|
|
7067
|
+
return row[column.valueIn];
|
|
7063
7068
|
}
|
|
7064
7069
|
/**
|
|
7065
7070
|
* Returns editable component properties based on the column definition
|
|
@@ -7118,13 +7123,13 @@
|
|
|
7118
7123
|
* If the row[column.name] has a selected value, pushes it
|
|
7119
7124
|
*/
|
|
7120
7125
|
checkLookupData(column, row, componentProps) {
|
|
7121
|
-
if (!row[column.
|
|
7126
|
+
if (!row[column.valueIn] || !column.lookupData || !componentProps.datasource)
|
|
7122
7127
|
return;
|
|
7123
7128
|
componentProps.datasource.data = componentProps.datasource.data || [];
|
|
7124
7129
|
// prevent pushing lookup values when using accessor in data
|
|
7125
7130
|
if (!Array.isArray(componentProps.datasource.data))
|
|
7126
7131
|
return;
|
|
7127
|
-
const colValue = row[column.
|
|
7132
|
+
const colValue = row[column.valueIn];
|
|
7128
7133
|
if (Array.isArray(colValue)) {
|
|
7129
7134
|
colValue.forEach((item) => {
|
|
7130
7135
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
@@ -7161,7 +7166,7 @@
|
|
|
7161
7166
|
*/
|
|
7162
7167
|
changeEditableComponent(column, row, value, component) {
|
|
7163
7168
|
const key = row[this.datasource.uniqueKey];
|
|
7164
|
-
const columnName = column.
|
|
7169
|
+
const columnName = column.valueIn;
|
|
7165
7170
|
if (!core.Utils.isEqual(value, row[columnName])) {
|
|
7166
7171
|
const newRow = {};
|
|
7167
7172
|
newRow[key] = Object.assign({}, this.editedRows[key]);
|
|
@@ -7208,7 +7213,7 @@
|
|
|
7208
7213
|
isEdited(column, row) {
|
|
7209
7214
|
const key = row[this.datasource.uniqueKey];
|
|
7210
7215
|
return this.editedRows[key]
|
|
7211
|
-
&& this.editedRows[key][column.
|
|
7216
|
+
&& this.editedRows[key][column.valueIn] !== this.editedRows[key][`${column.valueIn}_original`];
|
|
7212
7217
|
}
|
|
7213
7218
|
/**
|
|
7214
7219
|
* Checks if row is an added row
|
|
@@ -7392,7 +7397,7 @@
|
|
|
7392
7397
|
const key = row[this.datasource.uniqueKey];
|
|
7393
7398
|
editableColumns.forEach((column) => {
|
|
7394
7399
|
const instance = componentInstances[column.name];
|
|
7395
|
-
if (!instance.isValid(row[column.
|
|
7400
|
+
if (!instance.isValid(row[column.valueIn])) {
|
|
7396
7401
|
invalidCompNames.push(this.getCompName(key, column.name));
|
|
7397
7402
|
}
|
|
7398
7403
|
});
|
|
@@ -7485,7 +7490,7 @@
|
|
|
7485
7490
|
throw new RowNotFoundError(newRow[uniqueKey], this.name);
|
|
7486
7491
|
}
|
|
7487
7492
|
this.columns.forEach((column) => {
|
|
7488
|
-
const columnName = column.
|
|
7493
|
+
const columnName = column.valueIn;
|
|
7489
7494
|
this.changeCell(newRow[uniqueKey], rowIdx, column, newRow[columnName]);
|
|
7490
7495
|
});
|
|
7491
7496
|
}
|
|
@@ -7902,27 +7907,45 @@
|
|
|
7902
7907
|
super.change(event, element);
|
|
7903
7908
|
}
|
|
7904
7909
|
/**
|
|
7905
|
-
*
|
|
7910
|
+
* Increases the component's value by the step amount.
|
|
7906
7911
|
*/
|
|
7907
7912
|
increment() {
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7913
|
+
const currentValue = Number(this.value);
|
|
7914
|
+
const isValueInvalid = this.value === null || this.value === '' || Number.isNaN(currentValue);
|
|
7915
|
+
// First, handle the case where the input is empty or not a number.
|
|
7916
|
+
if (isValueInvalid) {
|
|
7917
|
+
// Determine the starting value. Default to `minValue` if it's positive, otherwise start from `step`.
|
|
7918
|
+
const startValue = (this.minValue !== undefined && this.minValue > 0) ? this.minValue : this.step;
|
|
7919
|
+
// Set the value, but clamp it to the maximum limit if one exists.
|
|
7920
|
+
this.value = (this.maxValue !== undefined) ? Math.min(startValue, this.maxValue) : startValue;
|
|
7921
|
+
return;
|
|
7911
7922
|
}
|
|
7912
|
-
|
|
7913
|
-
|
|
7923
|
+
// If the input is a valid number, calculate the next value.
|
|
7924
|
+
const nextValue = currentValue + this.step;
|
|
7925
|
+
// Only update if the new value does not exceed the maximum boundary.
|
|
7926
|
+
if (this.maxValue === undefined || nextValue <= this.maxValue) {
|
|
7927
|
+
this.value = nextValue;
|
|
7914
7928
|
}
|
|
7915
7929
|
}
|
|
7916
7930
|
/**
|
|
7917
|
-
*
|
|
7931
|
+
* Decreases the component's value by the step amount.
|
|
7918
7932
|
*/
|
|
7919
7933
|
decrement() {
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7934
|
+
const currentValue = Number(this.value);
|
|
7935
|
+
const isValueInvalid = this.value === null || this.value === '' || Number.isNaN(currentValue);
|
|
7936
|
+
// First, handle the case where the input is empty or not a number.
|
|
7937
|
+
if (isValueInvalid) {
|
|
7938
|
+
// Determine the starting value. Handles the edge case where the max value is negative.
|
|
7939
|
+
const startValue = (this.maxValue !== undefined && this.maxValue < 0) ? this.maxValue : -this.step;
|
|
7940
|
+
// Set the value, but clamp it to the minimum limit if one exists.
|
|
7941
|
+
this.value = (this.minValue !== undefined) ? Math.max(startValue, this.minValue) : startValue;
|
|
7942
|
+
return;
|
|
7923
7943
|
}
|
|
7924
|
-
|
|
7925
|
-
|
|
7944
|
+
// If the input is a valid number, calculate the next value.
|
|
7945
|
+
const nextValue = currentValue - this.step;
|
|
7946
|
+
// Only update if the new value does not go below the minimum boundary.
|
|
7947
|
+
if (this.minValue === undefined || nextValue >= this.minValue) {
|
|
7948
|
+
this.value = nextValue;
|
|
7926
7949
|
}
|
|
7927
7950
|
}
|
|
7928
7951
|
}
|
|
@@ -10440,7 +10463,7 @@
|
|
|
10440
10463
|
component: 'ZdGrid',
|
|
10441
10464
|
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
10442
10465
|
columns: this.modalSelectionColumns,
|
|
10443
|
-
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
10466
|
+
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { limit: this.defaultDatasource.limit, lazyLoad: false, searchIn: undefined }),
|
|
10444
10467
|
toolbarSlot: [
|
|
10445
10468
|
{
|
|
10446
10469
|
name: `${this.name}-modal-selection-title`,
|
|
@@ -10713,6 +10736,10 @@
|
|
|
10713
10736
|
constructor(props) {
|
|
10714
10737
|
super(props);
|
|
10715
10738
|
this.lazyAttach = false;
|
|
10739
|
+
/**
|
|
10740
|
+
* * hide the option to select search field
|
|
10741
|
+
*/
|
|
10742
|
+
this.hideSearchField = false;
|
|
10716
10743
|
this.debounceSetSearch = debounce__default["default"](this.setSearch, 500);
|
|
10717
10744
|
this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
|
|
10718
10745
|
this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
|
|
@@ -10721,6 +10748,7 @@
|
|
|
10721
10748
|
this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
|
|
10722
10749
|
this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
|
|
10723
10750
|
this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
|
|
10751
|
+
this.hideSearchField = this.getInitValue('hideSearchField', props.hideSearchField, this.hideSearchField);
|
|
10724
10752
|
this.debounceSetSearch = this.debounceSetSearch.bind(this);
|
|
10725
10753
|
if (!this.lazyAttach)
|
|
10726
10754
|
this.setIterableComponent();
|
|
@@ -15568,10 +15596,10 @@
|
|
|
15568
15596
|
}
|
|
15569
15597
|
getVisibleValue(row, column) {
|
|
15570
15598
|
const key = row[this.datasource.uniqueKey];
|
|
15571
|
-
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.
|
|
15572
|
-
return this.editedRows[key][column.
|
|
15599
|
+
if (this.editedRows[key] && Object.prototype.hasOwnProperty.call(this.editedRows[key], column.valueIn)) {
|
|
15600
|
+
return this.editedRows[key][column.valueIn];
|
|
15573
15601
|
}
|
|
15574
|
-
return row[column.
|
|
15602
|
+
return row[column.valueIn];
|
|
15575
15603
|
}
|
|
15576
15604
|
/**
|
|
15577
15605
|
* Returns editable component properties based on the column definition
|
|
@@ -15625,13 +15653,13 @@
|
|
|
15625
15653
|
* If the row[column.name] has a selected value, pushes it
|
|
15626
15654
|
*/
|
|
15627
15655
|
checkLookupData(column, row, componentProps) {
|
|
15628
|
-
if (!row[column.
|
|
15656
|
+
if (!row[column.valueIn] || !column.lookupData || !componentProps.datasource)
|
|
15629
15657
|
return;
|
|
15630
15658
|
componentProps.datasource.data = componentProps.datasource.data || [];
|
|
15631
15659
|
// prevent pushing lookup values when using accessor in data
|
|
15632
15660
|
if (!Array.isArray(componentProps.datasource.data))
|
|
15633
15661
|
return;
|
|
15634
|
-
const colValue = row[column.
|
|
15662
|
+
const colValue = row[column.valueIn];
|
|
15635
15663
|
if (Array.isArray(colValue)) {
|
|
15636
15664
|
colValue.forEach((item) => {
|
|
15637
15665
|
const value = typeof item === 'object' ? item[componentProps.dataValue] : item;
|
|
@@ -15668,7 +15696,7 @@
|
|
|
15668
15696
|
*/
|
|
15669
15697
|
changeEditableComponent(column, row, value, component) {
|
|
15670
15698
|
const key = row[this.datasource.uniqueKey];
|
|
15671
|
-
const columnName = column.
|
|
15699
|
+
const columnName = column.valueIn;
|
|
15672
15700
|
if (!core.Utils.isEqual(value, row[columnName])) {
|
|
15673
15701
|
const newRow = {};
|
|
15674
15702
|
newRow[key] = Object.assign({}, this.editedRows[key]);
|
|
@@ -15703,7 +15731,7 @@
|
|
|
15703
15731
|
isEdited(column, row) {
|
|
15704
15732
|
const key = row[this.datasource.uniqueKey];
|
|
15705
15733
|
return this.editedRows[key]
|
|
15706
|
-
&& this.editedRows[key][column.
|
|
15734
|
+
&& this.editedRows[key][column.valueIn] !== this.editedRows[key][`${column.valueIn}_original`];
|
|
15707
15735
|
}
|
|
15708
15736
|
/**
|
|
15709
15737
|
* Checks if column is valid
|
|
@@ -15840,7 +15868,7 @@
|
|
|
15840
15868
|
throw new RowNotFoundError(newRow[uniqueKey], this.name);
|
|
15841
15869
|
}
|
|
15842
15870
|
this.columns.forEach((column) => {
|
|
15843
|
-
const columnName = column.
|
|
15871
|
+
const columnName = column.valueIn;
|
|
15844
15872
|
this.changeCell(newRow[uniqueKey], rowIdx, column, newRow[columnName]);
|
|
15845
15873
|
});
|
|
15846
15874
|
}
|
|
@@ -15925,7 +15953,7 @@
|
|
|
15925
15953
|
const dataTextName = typeof item === 'string' ? item : item.name;
|
|
15926
15954
|
lookupRow[dataTextName] = row[foreignColumns[dataTextName] || dataTextName];
|
|
15927
15955
|
});
|
|
15928
|
-
lookupRow[dataValue] = row[column.
|
|
15956
|
+
lookupRow[dataValue] = row[column.valueIn];
|
|
15929
15957
|
return lookupRow;
|
|
15930
15958
|
};
|
|
15931
15959
|
const getFormatterLookupRow = (column, row, dataValue, formatterDataTextColumns, dataTextColumns) => {
|
|
@@ -15936,7 +15964,7 @@
|
|
|
15936
15964
|
const formatterDataTextColumn = typeof item === 'string' ? item : item.name;
|
|
15937
15965
|
lookupRow[dataTextName] = row[formatterDataTextColumn];
|
|
15938
15966
|
});
|
|
15939
|
-
lookupRow[dataValue] = row[column.
|
|
15967
|
+
lookupRow[dataValue] = row[column.valueIn];
|
|
15940
15968
|
return lookupRow;
|
|
15941
15969
|
};
|
|
15942
15970
|
/**
|
|
@@ -15950,7 +15978,7 @@
|
|
|
15950
15978
|
const dataTextColumns = asArray(dataText);
|
|
15951
15979
|
// when using foreignColumns, should store foreign keys information in lookupData
|
|
15952
15980
|
if (foreignColumns) {
|
|
15953
|
-
column.lookupData[row[column.
|
|
15981
|
+
column.lookupData[row[column.valueIn]] = getForeignLookupRow(column, row, dataValue, dataTextColumns, foreignColumns);
|
|
15954
15982
|
return row;
|
|
15955
15983
|
}
|
|
15956
15984
|
// when not using formatterDataText, should fetch data from datasource to be able to format this cell
|
|
@@ -15960,7 +15988,7 @@
|
|
|
15960
15988
|
const formatterDataTextColumns = asArray(formatterDataText);
|
|
15961
15989
|
// when using formatterDataText, should store dataText information in lookupData
|
|
15962
15990
|
if (formatterDataTextColumns.length === dataTextColumns.length) {
|
|
15963
|
-
const rowColumn = row[column.
|
|
15991
|
+
const rowColumn = row[column.valueIn];
|
|
15964
15992
|
column.lookupData[rowColumn] = getFormatterLookupRow(column, row, dataValue, formatterDataTextColumns, dataTextColumns);
|
|
15965
15993
|
return row;
|
|
15966
15994
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.112.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": "bcf25802928f8264bc7810b19a903364f3e371c9"
|
|
47
47
|
}
|
|
@@ -149,7 +149,7 @@ export declare class Date extends TextInput implements IDate {
|
|
|
149
149
|
private previousHint;
|
|
150
150
|
private previousPersistentHint;
|
|
151
151
|
updateHelperHint(): void;
|
|
152
|
-
private lastChangeValue
|
|
152
|
+
private lastChangeValue?;
|
|
153
153
|
changeEvent(event?: Event, element?: any): void;
|
|
154
154
|
change(event?: Event, element?: any, callEvent?: boolean): void;
|
|
155
155
|
}
|
|
@@ -119,7 +119,7 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
119
119
|
* @param element DOM Element
|
|
120
120
|
*/
|
|
121
121
|
selectAllClick(isSelected: boolean, event: Event, element: any): void;
|
|
122
|
-
getVisibleValue(row: IDictionary, column:
|
|
122
|
+
getVisibleValue(row: IDictionary, column: GridColumnEditable): any;
|
|
123
123
|
/**
|
|
124
124
|
* Returns editable component properties based on the column definition
|
|
125
125
|
* @param column Column definition
|
|
@@ -127,10 +127,10 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
127
127
|
* @param cellProps Column conditional props
|
|
128
128
|
* @param events Component events
|
|
129
129
|
*/
|
|
130
|
-
getEditableComponent(column:
|
|
130
|
+
getEditableComponent(column: GridColumnEditable, row: IDictionary<any>, cellProps: IDictionary<any> | null, events: any): {
|
|
131
131
|
name: string;
|
|
132
132
|
parent: GridEditable;
|
|
133
|
-
align: "
|
|
133
|
+
align: import("..").ColumnAlign;
|
|
134
134
|
showLabel: boolean;
|
|
135
135
|
showHelper: boolean;
|
|
136
136
|
dense: boolean;
|
|
@@ -150,14 +150,14 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
150
150
|
/**
|
|
151
151
|
* change event of editable components
|
|
152
152
|
*/
|
|
153
|
-
protected changeEditableComponent(column:
|
|
153
|
+
protected changeEditableComponent(column: GridColumnEditable, row: IDictionary<any>, value: any, component?: Input): void;
|
|
154
154
|
private updateOriginalRow;
|
|
155
155
|
/**
|
|
156
156
|
* Checks if column is edited
|
|
157
157
|
* @param column Column
|
|
158
158
|
* @param row Row
|
|
159
159
|
*/
|
|
160
|
-
isEdited(column:
|
|
160
|
+
isEdited(column: GridColumnEditable, row: IDictionary): boolean;
|
|
161
161
|
/**
|
|
162
162
|
* Checks if row is an added row
|
|
163
163
|
* @param row Row
|
|
@@ -43,11 +43,11 @@ export declare class Increment extends ZdNumber implements IIncrement {
|
|
|
43
43
|
*/
|
|
44
44
|
plusClick(event: Event, element: any): void;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Increases the component's value by the step amount.
|
|
47
47
|
*/
|
|
48
48
|
increment(): void;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Decreases the component's value by the step amount.
|
|
51
51
|
*/
|
|
52
52
|
decrement(): void;
|
|
53
53
|
}
|
|
@@ -43,6 +43,8 @@ export declare class Column extends Component implements IColumn {
|
|
|
43
43
|
helperText: string;
|
|
44
44
|
protected defaultData: IDictionary[];
|
|
45
45
|
searchMode: ColumnSearchMode;
|
|
46
|
+
searchable: boolean;
|
|
47
|
+
valueIn: string;
|
|
46
48
|
/**
|
|
47
49
|
* Creates a new Column.
|
|
48
50
|
* @param props Column properties
|
|
@@ -28,6 +28,8 @@ export interface IColumn extends IComponent {
|
|
|
28
28
|
events?: IIterableEvents;
|
|
29
29
|
xlsType?: string;
|
|
30
30
|
searchMode?: ColumnSearchMode;
|
|
31
|
+
searchable?: boolean;
|
|
32
|
+
valueIn?: string;
|
|
31
33
|
}
|
|
32
34
|
export interface IIterable extends IComponentRender {
|
|
33
35
|
columns?: IColumn[];
|
|
@@ -65,6 +67,7 @@ export interface ISearch extends ITextInput {
|
|
|
65
67
|
showHelper?: boolean;
|
|
66
68
|
appendIcon?: string;
|
|
67
69
|
lazyAttach?: boolean;
|
|
70
|
+
hideSearchField?: boolean;
|
|
68
71
|
}
|
|
69
72
|
export interface IIterableColumnsButton extends IButton {
|
|
70
73
|
iterableComponentName?: string;
|
|
@@ -14,6 +14,10 @@ export declare class Search extends TextInput implements ISearch {
|
|
|
14
14
|
*/
|
|
15
15
|
iterableComponent: Iterable;
|
|
16
16
|
lazyAttach: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* * hide the option to select search field
|
|
19
|
+
*/
|
|
20
|
+
hideSearchField: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Creates a new Iterable Page component.
|
|
19
23
|
* @param props Iterable page component properties
|
|
@@ -91,7 +91,7 @@ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEdita
|
|
|
91
91
|
* @param element DOM Element
|
|
92
92
|
*/
|
|
93
93
|
selectAllClick(isSelected: boolean, event?: Event, element?: any): void;
|
|
94
|
-
getVisibleValue(row: IDictionary, column:
|
|
94
|
+
getVisibleValue(row: IDictionary, column: GridColumnEditable): any;
|
|
95
95
|
/**
|
|
96
96
|
* Returns editable component properties based on the column definition
|
|
97
97
|
* @param column Column definition
|
|
@@ -99,10 +99,10 @@ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEdita
|
|
|
99
99
|
* @param cellProps Column conditional props
|
|
100
100
|
* @param events Component events
|
|
101
101
|
*/
|
|
102
|
-
getEditableComponent(column:
|
|
102
|
+
getEditableComponent(column: GridColumnEditable, row: IDictionary<any>, cellProps: IDictionary<any>, events: any): {
|
|
103
103
|
name: string;
|
|
104
104
|
parent: TreeGridEditable;
|
|
105
|
-
align: "
|
|
105
|
+
align: import("..").ColumnAlign;
|
|
106
106
|
showLabel: boolean;
|
|
107
107
|
showHelper: boolean;
|
|
108
108
|
dense: boolean;
|
|
@@ -128,7 +128,7 @@ export declare class TreeGridEditable extends TreeGrid implements ITreeGridEdita
|
|
|
128
128
|
* @param column Column
|
|
129
129
|
* @param row Row
|
|
130
130
|
*/
|
|
131
|
-
isEdited(column:
|
|
131
|
+
isEdited(column: GridColumnEditable, row: IDictionary): boolean;
|
|
132
132
|
/**
|
|
133
133
|
* Checks if column is valid
|
|
134
134
|
* @param column Column
|