@dragonmastery/zinia-forms-core 0.5.2 → 0.5.4
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/index.d.ts +1 -0
- package/dist/index.js +64 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2864,6 +2864,7 @@ interface UrlSyncOptions {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
interface DataTable {
|
|
2866
2866
|
setFilter: (field: any, filter: any) => Promise<void>;
|
|
2867
|
+
clearFilter: (field: any) => Promise<void>;
|
|
2867
2868
|
clearAllFilters: () => Promise<void>;
|
|
2868
2869
|
setFiltersFromQueryParams: (params: Record<string, string | string[]>) => Promise<void>;
|
|
2869
2870
|
load: () => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -7839,6 +7839,9 @@ function useDataTable(schema, options) {
|
|
|
7839
7839
|
delete currentFilters[fieldName];
|
|
7840
7840
|
tableState.setFilters(currentFilters);
|
|
7841
7841
|
tableState.setPagination(0);
|
|
7842
|
+
delete filterInputValues.value[fieldName];
|
|
7843
|
+
delete filterInputValues.value[`${fieldName}_start`];
|
|
7844
|
+
delete filterInputValues.value[`${fieldName}_end`];
|
|
7842
7845
|
await fetchData();
|
|
7843
7846
|
return;
|
|
7844
7847
|
}
|
|
@@ -8215,6 +8218,14 @@ function getFilterOptions(field, column, fieldsMetadata, filterOptionsState) {
|
|
|
8215
8218
|
}
|
|
8216
8219
|
return [];
|
|
8217
8220
|
}
|
|
8221
|
+
function isBooleanOperator(operator) {
|
|
8222
|
+
if (!operator) return true;
|
|
8223
|
+
return OPERATORS_BY_TYPE.boolean.includes(operator);
|
|
8224
|
+
}
|
|
8225
|
+
function isEnumOperator(operator) {
|
|
8226
|
+
if (!operator) return true;
|
|
8227
|
+
return OPERATORS_BY_TYPE.enum.includes(operator);
|
|
8228
|
+
}
|
|
8218
8229
|
function getSortLabels(field, column, fieldsMetadata) {
|
|
8219
8230
|
if (column?.sortLabels) {
|
|
8220
8231
|
return column.sortLabels;
|
|
@@ -8913,7 +8924,7 @@ var EnumMultiSelectFilter = (props) => {
|
|
|
8913
8924
|
}
|
|
8914
8925
|
) })
|
|
8915
8926
|
] }),
|
|
8916
|
-
/* @__PURE__ */ jsx("div", { class: "text-xs text-base-content/60", children: props.operator ===
|
|
8927
|
+
/* @__PURE__ */ jsx("div", { class: "text-xs text-base-content/60", children: props.operator === OPERATORS.IS_ONE_OF ? "Select one or more values" : "Show rows that do not match these values" })
|
|
8917
8928
|
] });
|
|
8918
8929
|
};
|
|
8919
8930
|
var SelectFilter = (props) => {
|
|
@@ -9039,13 +9050,20 @@ function debounce(key, callback, delay = 300) {
|
|
|
9039
9050
|
}, delay);
|
|
9040
9051
|
timeoutStore.set(key, timeoutId);
|
|
9041
9052
|
}
|
|
9053
|
+
function clearDebounce(key) {
|
|
9054
|
+
const existing = timeoutStore.get(key);
|
|
9055
|
+
if (existing) {
|
|
9056
|
+
clearTimeout(existing);
|
|
9057
|
+
timeoutStore.delete(key);
|
|
9058
|
+
}
|
|
9059
|
+
}
|
|
9042
9060
|
var TextFilter = (props) => {
|
|
9043
9061
|
const currentOperator = props.filterOperators.value[props.field] || OPERATORS.CONTAINS;
|
|
9044
9062
|
const isArrayOperator = currentOperator === OPERATORS.IS_ONE_OF || currentOperator === OPERATORS.IS_NOT_ONE_OF;
|
|
9045
9063
|
const isDefaultOperator = currentOperator === OPERATORS.CONTAINS;
|
|
9046
9064
|
const showOperatorSelect = !isDefaultOperator;
|
|
9047
9065
|
const filterInputValue = props.filterInputValues.value[props.field];
|
|
9048
|
-
const displayValue = filterInputValue !== void 0
|
|
9066
|
+
const displayValue = filterInputValue !== void 0 ? filterInputValue : props.value || "";
|
|
9049
9067
|
const handleFilterChange = (value, operator = currentOperator) => {
|
|
9050
9068
|
const filter = {
|
|
9051
9069
|
operator,
|
|
@@ -9098,13 +9116,18 @@ var TextFilter = (props) => {
|
|
|
9098
9116
|
onInput: (e) => {
|
|
9099
9117
|
const value = e.target.value;
|
|
9100
9118
|
props.filterInputValues.value[props.field] = value;
|
|
9101
|
-
|
|
9102
|
-
`filter_${props.field}
|
|
9103
|
-
()
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9119
|
+
if (value === "") {
|
|
9120
|
+
clearDebounce(`filter_${props.field}`);
|
|
9121
|
+
handleFilterChange("");
|
|
9122
|
+
} else {
|
|
9123
|
+
debounce(
|
|
9124
|
+
`filter_${props.field}`,
|
|
9125
|
+
() => {
|
|
9126
|
+
handleFilterChange(value);
|
|
9127
|
+
},
|
|
9128
|
+
300
|
|
9129
|
+
);
|
|
9130
|
+
}
|
|
9108
9131
|
},
|
|
9109
9132
|
onKeydown: (e) => {
|
|
9110
9133
|
if (e.key === "Escape" && props.filterInputValues.value[props.field]) {
|
|
@@ -9129,7 +9152,7 @@ var NumberFilter = (props) => {
|
|
|
9129
9152
|
const currentOperator = props.filterOperators.value[props.field] || OPERATORS.EQUALS;
|
|
9130
9153
|
const isBetween = currentOperator === OPERATORS.BETWEEN;
|
|
9131
9154
|
const filterInputValue = props.filterInputValues.value[props.field];
|
|
9132
|
-
const displayValue = filterInputValue !== void 0
|
|
9155
|
+
const displayValue = filterInputValue !== void 0 ? filterInputValue : props.value !== void 0 && props.value !== null && props.value !== "" ? String(props.value) : "";
|
|
9133
9156
|
const handleFilterChange = (value, operator = currentOperator) => {
|
|
9134
9157
|
const filter = {
|
|
9135
9158
|
operator
|
|
@@ -9186,13 +9209,18 @@ var NumberFilter = (props) => {
|
|
|
9186
9209
|
onInput: (e) => {
|
|
9187
9210
|
const value = e.target.value;
|
|
9188
9211
|
props.filterInputValues.value[props.field] = value;
|
|
9189
|
-
|
|
9190
|
-
`filter_${props.field}
|
|
9191
|
-
()
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9212
|
+
if (value === "") {
|
|
9213
|
+
clearDebounce(`filter_${props.field}`);
|
|
9214
|
+
handleFilterChange("");
|
|
9215
|
+
} else {
|
|
9216
|
+
debounce(
|
|
9217
|
+
`filter_${props.field}`,
|
|
9218
|
+
() => {
|
|
9219
|
+
handleFilterChange(value);
|
|
9220
|
+
},
|
|
9221
|
+
300
|
|
9222
|
+
);
|
|
9223
|
+
}
|
|
9196
9224
|
},
|
|
9197
9225
|
onKeydown: (e) => {
|
|
9198
9226
|
if (e.key === "Escape" && props.filterInputValues.value[props.field]) {
|
|
@@ -10160,7 +10188,7 @@ var FilterDrawer = (props) => {
|
|
|
10160
10188
|
isOptionsLoading: filterOptionsLoading?.value?.[field] ?? false,
|
|
10161
10189
|
allOptionText: column.filterAllOptionText,
|
|
10162
10190
|
showAllOption: column.filterShowAllOption,
|
|
10163
|
-
operator: currentFilter?.operator,
|
|
10191
|
+
operator: isEnumOperator(currentFilter?.operator) ? currentFilter?.operator : void 0,
|
|
10164
10192
|
fieldType: convertToDataType(props.fieldsMetadata[field]?.type || "enum"),
|
|
10165
10193
|
onFilterChange: props.onFilterChange,
|
|
10166
10194
|
onClearFilter: props.onClearFilter
|
|
@@ -10200,7 +10228,7 @@ var FilterDrawer = (props) => {
|
|
|
10200
10228
|
isLoading: props.isLoading,
|
|
10201
10229
|
allOptionText: column.filterAllOptionText,
|
|
10202
10230
|
showAllOption: column.filterShowAllOption,
|
|
10203
|
-
operator: currentFilter?.operator,
|
|
10231
|
+
operator: isBooleanOperator(currentFilter?.operator) ? currentFilter?.operator : void 0,
|
|
10204
10232
|
fieldType: convertToDataType(props.fieldsMetadata[field]?.type || "boolean"),
|
|
10205
10233
|
options: getFilterOptions(
|
|
10206
10234
|
field,
|
|
@@ -11590,6 +11618,10 @@ function useCursorDataTable(schema, options) {
|
|
|
11590
11618
|
delete currentFilters[fieldName];
|
|
11591
11619
|
tableState.setFilters(currentFilters);
|
|
11592
11620
|
tableState.setCursorNavigation(void 0);
|
|
11621
|
+
delete filterInputValues.value[fieldName];
|
|
11622
|
+
delete filterInputValues.value[`${fieldName}_start`];
|
|
11623
|
+
delete filterInputValues.value[`${fieldName}_end`];
|
|
11624
|
+
await fetchData();
|
|
11593
11625
|
return;
|
|
11594
11626
|
}
|
|
11595
11627
|
const validation = validateFilterValueObject(fieldName, filter, fieldRegistry);
|
|
@@ -11909,6 +11941,7 @@ function useDataTableUrlSync(table, router, options = {}) {
|
|
|
11909
11941
|
const { loadOnMount = true } = options;
|
|
11910
11942
|
const isUpdatingFromRoute = ref(false);
|
|
11911
11943
|
const originalSetFilter = table.setFilter.bind(table);
|
|
11944
|
+
const originalClearFilter = table.clearFilter.bind(table);
|
|
11912
11945
|
const originalClearAllFilters = table.clearAllFilters.bind(table);
|
|
11913
11946
|
const extractFilterParams = (query) => {
|
|
11914
11947
|
const filterParams = {};
|
|
@@ -11932,12 +11965,22 @@ function useDataTableUrlSync(table, router, options = {}) {
|
|
|
11932
11965
|
router.push({ query });
|
|
11933
11966
|
};
|
|
11934
11967
|
table.setFilter = async (field, filter) => {
|
|
11935
|
-
|
|
11968
|
+
const filterPromise = originalSetFilter(field, filter);
|
|
11969
|
+
await nextTick();
|
|
11970
|
+
updateUrlFromFilters();
|
|
11971
|
+
await filterPromise;
|
|
11972
|
+
};
|
|
11973
|
+
table.clearFilter = async (field) => {
|
|
11974
|
+
const filterPromise = originalClearFilter(field);
|
|
11975
|
+
await nextTick();
|
|
11936
11976
|
updateUrlFromFilters();
|
|
11977
|
+
await filterPromise;
|
|
11937
11978
|
};
|
|
11938
11979
|
table.clearAllFilters = async () => {
|
|
11939
|
-
|
|
11980
|
+
const filterPromise = originalClearAllFilters();
|
|
11981
|
+
await nextTick();
|
|
11940
11982
|
updateUrlFromFilters();
|
|
11983
|
+
await filterPromise;
|
|
11941
11984
|
};
|
|
11942
11985
|
watch(
|
|
11943
11986
|
() => router.currentRoute.value.query,
|