@shival99/z-ui 1.2.22 → 1.2.23
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/fesm2022/shival99-z-ui-components-z-table.mjs +116 -109
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-services.mjs +3 -5
- package/fesm2022/shival99-z-ui-services.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-popover.d.ts +1 -1
|
@@ -1032,121 +1032,128 @@ function columnConfigToColumnDef(config) {
|
|
|
1032
1032
|
if (sortConfig?.sortFn) {
|
|
1033
1033
|
columnDef.sortingFn = sortConfig.sortFn;
|
|
1034
1034
|
}
|
|
1035
|
-
|
|
1035
|
+
// Only apply local filter functions when filter mode is 'local' (default)
|
|
1036
|
+
// When mode is 'server', filtering is handled externally via zOnChange events
|
|
1037
|
+
const isLocalFilterMode = !filterConfig?.mode || filterConfig.mode === 'local';
|
|
1038
|
+
if (isLocalFilterMode && filterConfig?.filterFn) {
|
|
1036
1039
|
columnDef.filterFn = filterConfig.filterFn;
|
|
1037
1040
|
}
|
|
1038
|
-
if (filterConfig?.
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
const filterDate = filterValue instanceof Date ? filterValue : new Date(filterValue);
|
|
1077
|
-
if (isNaN(cellDate.getTime()) || isNaN(filterDate.getTime())) {
|
|
1078
|
-
return false;
|
|
1079
|
-
}
|
|
1080
|
-
return (cellDate.getFullYear() === filterDate.getFullYear() &&
|
|
1081
|
-
cellDate.getMonth() === filterDate.getMonth() &&
|
|
1082
|
-
cellDate.getDate() === filterDate.getDate());
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
if (filterConfig?.type === 'date-range') {
|
|
1086
|
-
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1087
|
-
if (!filterValue || typeof filterValue !== 'object') {
|
|
1088
|
-
return true;
|
|
1089
|
-
}
|
|
1090
|
-
const { start, end } = filterValue;
|
|
1091
|
-
if (!start && !end) {
|
|
1092
|
-
return true;
|
|
1093
|
-
}
|
|
1094
|
-
const cellValue = row.getValue(columnId);
|
|
1095
|
-
if (!cellValue) {
|
|
1096
|
-
return false;
|
|
1097
|
-
}
|
|
1098
|
-
const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
|
|
1099
|
-
if (isNaN(cellDate.getTime())) {
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
// Normalize cell date to start of day for comparison
|
|
1103
|
-
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
1104
|
-
if (start) {
|
|
1105
|
-
const startDate = start instanceof Date ? start : new Date(start);
|
|
1106
|
-
if (!isNaN(startDate.getTime())) {
|
|
1107
|
-
const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
|
|
1108
|
-
if (cellDateOnly < startDateOnly) {
|
|
1041
|
+
if (isLocalFilterMode && !filterConfig?.filterFn && filterConfig?.type) {
|
|
1042
|
+
switch (filterConfig.type) {
|
|
1043
|
+
case 'select':
|
|
1044
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1045
|
+
if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
|
|
1046
|
+
return true;
|
|
1047
|
+
}
|
|
1048
|
+
const cellValue = row.getValue(columnId);
|
|
1049
|
+
if (Array.isArray(filterValue)) {
|
|
1050
|
+
return filterValue.includes(cellValue);
|
|
1051
|
+
}
|
|
1052
|
+
return cellValue === filterValue;
|
|
1053
|
+
};
|
|
1054
|
+
break;
|
|
1055
|
+
case 'multi-select':
|
|
1056
|
+
case 'tags':
|
|
1057
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1058
|
+
if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1061
|
+
const cellValue = row.getValue(columnId);
|
|
1062
|
+
if (!Array.isArray(filterValue)) {
|
|
1063
|
+
return cellValue === filterValue;
|
|
1064
|
+
}
|
|
1065
|
+
const filterSet = new Set(filterValue);
|
|
1066
|
+
if (Array.isArray(cellValue)) {
|
|
1067
|
+
return cellValue.some(cv => filterSet.has(cv));
|
|
1068
|
+
}
|
|
1069
|
+
return filterSet.has(cellValue);
|
|
1070
|
+
};
|
|
1071
|
+
break;
|
|
1072
|
+
case 'date':
|
|
1073
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1074
|
+
if (!filterValue) {
|
|
1075
|
+
return true;
|
|
1076
|
+
}
|
|
1077
|
+
const cellValue = row.getValue(columnId);
|
|
1078
|
+
if (!cellValue) {
|
|
1109
1079
|
return false;
|
|
1110
1080
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
const endDate = end instanceof Date ? end : new Date(end);
|
|
1115
|
-
if (!isNaN(endDate.getTime())) {
|
|
1116
|
-
const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
|
|
1117
|
-
if (cellDateOnly > endDateOnly) {
|
|
1081
|
+
const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
|
|
1082
|
+
const filterDate = filterValue instanceof Date ? filterValue : new Date(filterValue);
|
|
1083
|
+
if (isNaN(cellDate.getTime()) || isNaN(filterDate.getTime())) {
|
|
1118
1084
|
return false;
|
|
1119
1085
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1086
|
+
return (cellDate.getFullYear() === filterDate.getFullYear() &&
|
|
1087
|
+
cellDate.getMonth() === filterDate.getMonth() &&
|
|
1088
|
+
cellDate.getDate() === filterDate.getDate());
|
|
1089
|
+
};
|
|
1090
|
+
break;
|
|
1091
|
+
case 'date-range':
|
|
1092
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1093
|
+
if (!filterValue || typeof filterValue !== 'object') {
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
const { start, end } = filterValue;
|
|
1097
|
+
if (!start && !end) {
|
|
1098
|
+
return true;
|
|
1099
|
+
}
|
|
1100
|
+
const cellValue = row.getValue(columnId);
|
|
1101
|
+
if (!cellValue) {
|
|
1102
|
+
return false;
|
|
1103
|
+
}
|
|
1104
|
+
const cellDate = cellValue instanceof Date ? cellValue : new Date(cellValue);
|
|
1105
|
+
if (isNaN(cellDate.getTime())) {
|
|
1106
|
+
return false;
|
|
1107
|
+
}
|
|
1108
|
+
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
1109
|
+
if (start) {
|
|
1110
|
+
const startDate = start instanceof Date ? start : new Date(start);
|
|
1111
|
+
if (!isNaN(startDate.getTime())) {
|
|
1112
|
+
const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
|
|
1113
|
+
if (cellDateOnly < startDateOnly) {
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
if (end) {
|
|
1119
|
+
const endDate = end instanceof Date ? end : new Date(end);
|
|
1120
|
+
if (!isNaN(endDate.getTime())) {
|
|
1121
|
+
const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
|
|
1122
|
+
if (cellDateOnly > endDateOnly) {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
return true;
|
|
1128
|
+
};
|
|
1129
|
+
break;
|
|
1130
|
+
case 'range':
|
|
1131
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
1132
|
+
if (!filterValue || !Array.isArray(filterValue)) {
|
|
1133
|
+
return true;
|
|
1134
|
+
}
|
|
1135
|
+
const [min, max] = filterValue;
|
|
1136
|
+
if (min === undefined && max === undefined) {
|
|
1137
|
+
return true;
|
|
1138
|
+
}
|
|
1139
|
+
const cellValue = row.getValue(columnId);
|
|
1140
|
+
if (cellValue === null || cellValue === undefined) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
const numValue = typeof cellValue === 'number' ? cellValue : Number(cellValue);
|
|
1144
|
+
if (isNaN(numValue)) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
if (min !== undefined && numValue < min) {
|
|
1148
|
+
return false;
|
|
1149
|
+
}
|
|
1150
|
+
if (max !== undefined && numValue > max) {
|
|
1151
|
+
return false;
|
|
1152
|
+
}
|
|
1153
|
+
return true;
|
|
1154
|
+
};
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1150
1157
|
}
|
|
1151
1158
|
if (config.columns && config.columns.length > 0) {
|
|
1152
1159
|
columnDef.columns = config.columns.map(subConfig => columnConfigToColumnDef(subConfig));
|