@dragonmastery/zinia-forms-core 0.5.1 → 0.5.3

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.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
  }
@@ -8573,6 +8576,14 @@ var EnumMultiSelectFilter = (props) => {
8573
8576
  };
8574
8577
  const applyPendingFilter = () => {
8575
8578
  if (state.pendingValues === void 0) return;
8579
+ const currentValues = Array.isArray(props.value) ? props.value : props.value ? [props.value] : [];
8580
+ const pendingSet = new Set(state.pendingValues.map((v) => String(v)));
8581
+ const currentSet = new Set(currentValues.map((v) => String(v)));
8582
+ const valuesChanged = pendingSet.size !== currentSet.size || !Array.from(pendingSet).every((v) => currentSet.has(v));
8583
+ if (!valuesChanged) {
8584
+ state.pendingValues = void 0;
8585
+ return;
8586
+ }
8576
8587
  if (state.pendingValues.length === 0) {
8577
8588
  if (props.onClearFilter) {
8578
8589
  props.onClearFilter(props.field);
@@ -9031,13 +9042,20 @@ function debounce(key, callback, delay = 300) {
9031
9042
  }, delay);
9032
9043
  timeoutStore.set(key, timeoutId);
9033
9044
  }
9045
+ function clearDebounce(key) {
9046
+ const existing = timeoutStore.get(key);
9047
+ if (existing) {
9048
+ clearTimeout(existing);
9049
+ timeoutStore.delete(key);
9050
+ }
9051
+ }
9034
9052
  var TextFilter = (props) => {
9035
9053
  const currentOperator = props.filterOperators.value[props.field] || OPERATORS.CONTAINS;
9036
9054
  const isArrayOperator = currentOperator === OPERATORS.IS_ONE_OF || currentOperator === OPERATORS.IS_NOT_ONE_OF;
9037
9055
  const isDefaultOperator = currentOperator === OPERATORS.CONTAINS;
9038
9056
  const showOperatorSelect = !isDefaultOperator;
9039
9057
  const filterInputValue = props.filterInputValues.value[props.field];
9040
- const displayValue = filterInputValue !== void 0 && filterInputValue !== "" ? filterInputValue : props.value || "";
9058
+ const displayValue = filterInputValue !== void 0 ? filterInputValue : props.value || "";
9041
9059
  const handleFilterChange = (value, operator = currentOperator) => {
9042
9060
  const filter = {
9043
9061
  operator,
@@ -9090,13 +9108,18 @@ var TextFilter = (props) => {
9090
9108
  onInput: (e) => {
9091
9109
  const value = e.target.value;
9092
9110
  props.filterInputValues.value[props.field] = value;
9093
- debounce(
9094
- `filter_${props.field}`,
9095
- () => {
9096
- handleFilterChange(value);
9097
- },
9098
- 300
9099
- );
9111
+ if (value === "") {
9112
+ clearDebounce(`filter_${props.field}`);
9113
+ handleFilterChange("");
9114
+ } else {
9115
+ debounce(
9116
+ `filter_${props.field}`,
9117
+ () => {
9118
+ handleFilterChange(value);
9119
+ },
9120
+ 300
9121
+ );
9122
+ }
9100
9123
  },
9101
9124
  onKeydown: (e) => {
9102
9125
  if (e.key === "Escape" && props.filterInputValues.value[props.field]) {
@@ -9121,7 +9144,7 @@ var NumberFilter = (props) => {
9121
9144
  const currentOperator = props.filterOperators.value[props.field] || OPERATORS.EQUALS;
9122
9145
  const isBetween = currentOperator === OPERATORS.BETWEEN;
9123
9146
  const filterInputValue = props.filterInputValues.value[props.field];
9124
- const displayValue = filterInputValue !== void 0 && filterInputValue !== "" ? filterInputValue : props.value !== void 0 && props.value !== null && props.value !== "" ? String(props.value) : "";
9147
+ const displayValue = filterInputValue !== void 0 ? filterInputValue : props.value !== void 0 && props.value !== null && props.value !== "" ? String(props.value) : "";
9125
9148
  const handleFilterChange = (value, operator = currentOperator) => {
9126
9149
  const filter = {
9127
9150
  operator
@@ -9178,13 +9201,18 @@ var NumberFilter = (props) => {
9178
9201
  onInput: (e) => {
9179
9202
  const value = e.target.value;
9180
9203
  props.filterInputValues.value[props.field] = value;
9181
- debounce(
9182
- `filter_${props.field}`,
9183
- () => {
9184
- handleFilterChange(value);
9185
- },
9186
- 300
9187
- );
9204
+ if (value === "") {
9205
+ clearDebounce(`filter_${props.field}`);
9206
+ handleFilterChange("");
9207
+ } else {
9208
+ debounce(
9209
+ `filter_${props.field}`,
9210
+ () => {
9211
+ handleFilterChange(value);
9212
+ },
9213
+ 300
9214
+ );
9215
+ }
9188
9216
  },
9189
9217
  onKeydown: (e) => {
9190
9218
  if (e.key === "Escape" && props.filterInputValues.value[props.field]) {
@@ -11582,6 +11610,10 @@ function useCursorDataTable(schema, options) {
11582
11610
  delete currentFilters[fieldName];
11583
11611
  tableState.setFilters(currentFilters);
11584
11612
  tableState.setCursorNavigation(void 0);
11613
+ delete filterInputValues.value[fieldName];
11614
+ delete filterInputValues.value[`${fieldName}_start`];
11615
+ delete filterInputValues.value[`${fieldName}_end`];
11616
+ await fetchData();
11585
11617
  return;
11586
11618
  }
11587
11619
  const validation = validateFilterValueObject(fieldName, filter, fieldRegistry);