@akinon/akifilter 1.2.0-next.2 → 1.2.0-next.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akifilter.d.ts","sourceRoot":"","sources":["../../src/akifilter.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,EAIL,WAAW,EAEX,IAAI,EAGL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,MAAM,OAAO,CAAC;AA0B1B,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/D,KAAK,oBAAoB,GAAG,WAAW,CAAC;AA2DxC,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,oBAAoB,GAAG,oBAAoB,IAC9D;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,IAAI,CAAC;IAClE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;
|
|
1
|
+
{"version":3,"file":"akifilter.d.ts","sourceRoot":"","sources":["../../src/akifilter.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,EAIL,WAAW,EAEX,IAAI,EAGL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,MAAM,OAAO,CAAC;AA0B1B,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/D,KAAK,oBAAoB,GAAG,WAAW,CAAC;AA2DxC,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,oBAAoB,GAAG,oBAAoB,IAC9D;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,IAAI,CAAC;IAClE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAyuBF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAmBpC,CAAC"}
|
package/dist/cjs/akifilter.js
CHANGED
|
@@ -245,6 +245,36 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
245
245
|
react_1.default.useEffect(() => {
|
|
246
246
|
lastPersistedValuesRef.current = null;
|
|
247
247
|
}, [storageKey]);
|
|
248
|
+
// Track previous serialised values to detect field removals
|
|
249
|
+
const previousSerialisedValuesRef = react_1.default.useRef(serialisedValues);
|
|
250
|
+
// Immediate effect for field removals (bypasses debounce)
|
|
251
|
+
react_1.default.useEffect(() => {
|
|
252
|
+
const previous = previousSerialisedValuesRef.current;
|
|
253
|
+
const current = serialisedValues;
|
|
254
|
+
previousSerialisedValuesRef.current = current;
|
|
255
|
+
// Skip if this is the initial render
|
|
256
|
+
if (!hasEmittedValuesRef.current) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
// Skip if values haven't actually changed
|
|
260
|
+
if (previous === current) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const prevParsed = JSON.parse(previous);
|
|
264
|
+
const currParsed = JSON.parse(current);
|
|
265
|
+
// Detect if a field was removed (existed in prev but not in current)
|
|
266
|
+
const prevKeys = Object.keys(prevParsed);
|
|
267
|
+
const currKeys = Object.keys(currParsed);
|
|
268
|
+
const removedKeys = prevKeys.filter(key => !currKeys.includes(key));
|
|
269
|
+
// If a field was removed, immediately persist and emit (bypass debounce)
|
|
270
|
+
if (removedKeys.length > 0) {
|
|
271
|
+
const nextSerialised = current;
|
|
272
|
+
persistValues(currParsed, nextSerialised);
|
|
273
|
+
lastPersistedValuesRef.current = nextSerialised;
|
|
274
|
+
currentSerialisedValuesRef.current = nextSerialised;
|
|
275
|
+
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
276
|
+
}
|
|
277
|
+
}, [serialisedValues, onValuesChange, persistValues]);
|
|
248
278
|
const handleClearAll = react_1.default.useCallback(() => {
|
|
249
279
|
const clearedDefaults = Object.assign({}, schemaDefaults);
|
|
250
280
|
flattenedSchema.forEach(field => {
|
|
@@ -303,17 +333,19 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
303
333
|
return;
|
|
304
334
|
}
|
|
305
335
|
const defaultValue = schemaDefaults[String(schemaField.key)];
|
|
306
|
-
const fieldPath = schemaField.key;
|
|
307
336
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
337
|
+
// Manually construct the updated form values instead of relying on setValue + getValues
|
|
338
|
+
// because setValue is batched and getValues() wouldn't reflect the change immediately
|
|
339
|
+
const currentFormValues = formMethods.getValues();
|
|
340
|
+
const updatedFormValues = Object.assign(Object.assign({}, currentFormValues), { [String(schemaField.key)]: nextValue });
|
|
341
|
+
// Normalize the values (removes empty/undefined entries)
|
|
342
|
+
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, updatedFormValues);
|
|
343
|
+
// Update form state
|
|
344
|
+
formMethods.reset(updatedFormValues, {
|
|
345
|
+
keepDirty: false,
|
|
346
|
+
keepTouched: false,
|
|
347
|
+
keepValues: false
|
|
313
348
|
});
|
|
314
|
-
// Get all current form values (includes the updated field)
|
|
315
|
-
const allFormValues = formMethods.getValues();
|
|
316
|
-
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, allFormValues);
|
|
317
349
|
const nextSerialised = JSON.stringify(nextValues);
|
|
318
350
|
// Persist immediately (bypass debounce for remove action)
|
|
319
351
|
persistValues(nextValues);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akifilter.d.ts","sourceRoot":"","sources":["../../src/akifilter.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,EAIL,WAAW,EAEX,IAAI,EAGL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,MAAM,OAAO,CAAC;AA0B1B,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/D,KAAK,oBAAoB,GAAG,WAAW,CAAC;AA2DxC,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,oBAAoB,GAAG,oBAAoB,IAC9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AAC;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACzD;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,IAAI,CAAC;IAClE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAyuBF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAmBpC,CAAC"}
|
package/dist/esm/akifilter.js
CHANGED
|
@@ -242,6 +242,36 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
242
242
|
React.useEffect(() => {
|
|
243
243
|
lastPersistedValuesRef.current = null;
|
|
244
244
|
}, [storageKey]);
|
|
245
|
+
// Track previous serialised values to detect field removals
|
|
246
|
+
const previousSerialisedValuesRef = React.useRef(serialisedValues);
|
|
247
|
+
// Immediate effect for field removals (bypasses debounce)
|
|
248
|
+
React.useEffect(() => {
|
|
249
|
+
const previous = previousSerialisedValuesRef.current;
|
|
250
|
+
const current = serialisedValues;
|
|
251
|
+
previousSerialisedValuesRef.current = current;
|
|
252
|
+
// Skip if this is the initial render
|
|
253
|
+
if (!hasEmittedValuesRef.current) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// Skip if values haven't actually changed
|
|
257
|
+
if (previous === current) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const prevParsed = JSON.parse(previous);
|
|
261
|
+
const currParsed = JSON.parse(current);
|
|
262
|
+
// Detect if a field was removed (existed in prev but not in current)
|
|
263
|
+
const prevKeys = Object.keys(prevParsed);
|
|
264
|
+
const currKeys = Object.keys(currParsed);
|
|
265
|
+
const removedKeys = prevKeys.filter(key => !currKeys.includes(key));
|
|
266
|
+
// If a field was removed, immediately persist and emit (bypass debounce)
|
|
267
|
+
if (removedKeys.length > 0) {
|
|
268
|
+
const nextSerialised = current;
|
|
269
|
+
persistValues(currParsed, nextSerialised);
|
|
270
|
+
lastPersistedValuesRef.current = nextSerialised;
|
|
271
|
+
currentSerialisedValuesRef.current = nextSerialised;
|
|
272
|
+
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
273
|
+
}
|
|
274
|
+
}, [serialisedValues, onValuesChange, persistValues]);
|
|
245
275
|
const handleClearAll = React.useCallback(() => {
|
|
246
276
|
const clearedDefaults = Object.assign({}, schemaDefaults);
|
|
247
277
|
flattenedSchema.forEach(field => {
|
|
@@ -300,17 +330,19 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
300
330
|
return;
|
|
301
331
|
}
|
|
302
332
|
const defaultValue = schemaDefaults[String(schemaField.key)];
|
|
303
|
-
const fieldPath = schemaField.key;
|
|
304
333
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
334
|
+
// Manually construct the updated form values instead of relying on setValue + getValues
|
|
335
|
+
// because setValue is batched and getValues() wouldn't reflect the change immediately
|
|
336
|
+
const currentFormValues = formMethods.getValues();
|
|
337
|
+
const updatedFormValues = Object.assign(Object.assign({}, currentFormValues), { [String(schemaField.key)]: nextValue });
|
|
338
|
+
// Normalize the values (removes empty/undefined entries)
|
|
339
|
+
const nextValues = normaliseOutputValues(flattenedSchema, updatedFormValues);
|
|
340
|
+
// Update form state
|
|
341
|
+
formMethods.reset(updatedFormValues, {
|
|
342
|
+
keepDirty: false,
|
|
343
|
+
keepTouched: false,
|
|
344
|
+
keepValues: false
|
|
310
345
|
});
|
|
311
|
-
// Get all current form values (includes the updated field)
|
|
312
|
-
const allFormValues = formMethods.getValues();
|
|
313
|
-
const nextValues = normaliseOutputValues(flattenedSchema, allFormValues);
|
|
314
346
|
const nextSerialised = JSON.stringify(nextValues);
|
|
315
347
|
// Persist immediately (bypass debounce for remove action)
|
|
316
348
|
persistValues(nextValues);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/akifilter",
|
|
3
|
-
"version": "1.2.0-next.
|
|
3
|
+
"version": "1.2.0-next.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Akifilter is a filtering library for Akinon frontend applications.",
|
|
6
6
|
"type": "module",
|
|
@@ -17,27 +17,27 @@
|
|
|
17
17
|
"@akinon/akilocale": "1.2.1",
|
|
18
18
|
"@akinon/icons": "1.1.2-next.1",
|
|
19
19
|
"@akinon/ui-button": "1.4.0-next.1",
|
|
20
|
-
"@akinon/ui-checkbox": "1.3.3-next.1",
|
|
21
20
|
"@akinon/ui-card": "1.1.3-next.1",
|
|
22
|
-
"@akinon/ui-
|
|
21
|
+
"@akinon/ui-checkbox": "1.3.3-next.1",
|
|
23
22
|
"@akinon/ui-collapse": "1.3.2-next.1",
|
|
23
|
+
"@akinon/ui-date-picker": "1.3.3-next.1",
|
|
24
|
+
"@akinon/ui-input": "1.1.3-next.1",
|
|
24
25
|
"@akinon/ui-input-number": "1.3.3-next.1",
|
|
25
|
-
"@akinon/ui-typography": "1.1.2-next.0",
|
|
26
26
|
"@akinon/ui-modal": "1.1.3-next.1",
|
|
27
|
-
"@akinon/ui-input": "1.1.3-next.1",
|
|
28
|
-
"@akinon/ui-select": "1.3.4-next.1",
|
|
29
27
|
"@akinon/ui-pagination": "1.3.4-next.1",
|
|
30
|
-
"@akinon/ui-
|
|
28
|
+
"@akinon/ui-select": "1.3.4-next.1",
|
|
29
|
+
"@akinon/ui-space": "1.3.3-next.1",
|
|
30
|
+
"@akinon/ui-typography": "1.1.2-next.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"clean-package": "2.2.0",
|
|
34
34
|
"copyfiles": "^2.4.1",
|
|
35
35
|
"rimraf": "^5.0.5",
|
|
36
36
|
"typescript": "*",
|
|
37
|
-
"@akinon/utils": "1.1.4-next.1",
|
|
38
37
|
"@akinon/akiform-builder": "1.3.5-next.1",
|
|
39
38
|
"@akinon/ui-theme": "1.1.3-next.1",
|
|
40
39
|
"@akinon/typescript-config": "1.1.1",
|
|
40
|
+
"@akinon/utils": "1.1.4-next.1",
|
|
41
41
|
"@akinon/vitest-config": "1.1.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|