@akinon/akifilter 1.2.0-next.11 → 1.2.0-next.12
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/cjs/akifilter.d.ts.map +1 -1
- package/dist/cjs/akifilter.js +19 -40
- package/dist/esm/akifilter.d.ts.map +1 -1
- package/dist/esm/akifilter.js +19 -40
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akifilter.d.ts","sourceRoot":"","sources":["../../src/akifilter.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,EAIL,WAAW,EACX,IAAI,EAIL,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;AA0HxC,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,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AC"}
|
package/dist/cjs/akifilter.js
CHANGED
|
@@ -112,15 +112,9 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
112
112
|
const schemaDefaults = react_1.default.useMemo(() => (0, schema_1.normaliseValuesBySchema)(flattenedSchema, (0, schema_1.extractDefaultValues)(flattenedSchema)), [flattenedSchema]);
|
|
113
113
|
const externalDefaults = react_1.default.useMemo(() => (0, schema_1.normaliseValuesBySchema)(flattenedSchema, defaultValues), [flattenedSchema, defaultValues]);
|
|
114
114
|
const baseDefaultValues = react_1.default.useMemo(() => (Object.assign(Object.assign({}, schemaDefaults), externalDefaults)), [schemaDefaults, externalDefaults]);
|
|
115
|
-
|
|
116
|
-
const [persistedDefaults, setPersistedDefaults] = react_1.default.useState(() => {
|
|
115
|
+
const persistedDefaults = react_1.default.useMemo(() => {
|
|
117
116
|
var _a;
|
|
118
117
|
return (0, schema_1.normaliseValuesBySchema)(flattenedSchema, (_a = (0, storage_1.readStoredValues)(regularFields, storageKey)) !== null && _a !== void 0 ? _a : undefined);
|
|
119
|
-
});
|
|
120
|
-
// Re-read from localStorage when storageKey changes
|
|
121
|
-
react_1.default.useEffect(() => {
|
|
122
|
-
var _a;
|
|
123
|
-
setPersistedDefaults((0, schema_1.normaliseValuesBySchema)(flattenedSchema, (_a = (0, storage_1.readStoredValues)(regularFields, storageKey)) !== null && _a !== void 0 ? _a : undefined));
|
|
124
118
|
}, [flattenedSchema, regularFields, storageKey]);
|
|
125
119
|
const mergedDefaultValues = react_1.default.useMemo(() => (Object.assign(Object.assign({}, baseDefaultValues), persistedDefaults)), [baseDefaultValues, persistedDefaults]);
|
|
126
120
|
const formMethods = (0, akiform_1.useForm)({
|
|
@@ -219,20 +213,8 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
219
213
|
(0, storage_1.writeVisibleKeys)(storageKey, visibleKeys);
|
|
220
214
|
onVisibleFieldsChange === null || onVisibleFieldsChange === void 0 ? void 0 : onVisibleFieldsChange(visibleKeys);
|
|
221
215
|
}, [visibleKeys, onVisibleFieldsChange, storageKey]);
|
|
222
|
-
// Track previous mergedDefaultValues to avoid unnecessary resets
|
|
223
|
-
const previousMergedDefaultValuesRef = react_1.default.useRef(null);
|
|
224
216
|
react_1.default.useEffect(() => {
|
|
225
|
-
|
|
226
|
-
// Skip if the values haven't actually changed (deep comparison)
|
|
227
|
-
if (previousMergedDefaultValuesRef.current === serialised) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
// Skip reset on initial mount - useForm already uses defaultValues
|
|
231
|
-
if (previousMergedDefaultValuesRef.current === null) {
|
|
232
|
-
previousMergedDefaultValuesRef.current = serialised;
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
previousMergedDefaultValuesRef.current = serialised;
|
|
217
|
+
formMethods.reset(mergedDefaultValues);
|
|
236
218
|
}, [formMethods, mergedDefaultValues]);
|
|
237
219
|
const normalisedValues = react_1.default.useMemo(() => (0, values_1.normaliseOutputValues)(flattenedSchema, formValues), [flattenedSchema, formValues]);
|
|
238
220
|
const hasInitialValuesRef = react_1.default.useRef(false);
|
|
@@ -316,16 +298,14 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
316
298
|
persistValues(currParsed, nextSerialised);
|
|
317
299
|
lastPersistedValuesRef.current = nextSerialised;
|
|
318
300
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
319
|
-
// Update persistedDefaults to prevent stale mergedDefaultValues on re-render
|
|
320
|
-
setPersistedDefaults(currParsed);
|
|
321
301
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
322
302
|
}
|
|
323
303
|
}, [serialisedValues, onValuesChange, persistValues]);
|
|
324
304
|
const handleClearAll = react_1.default.useCallback(() => {
|
|
325
|
-
const clearedDefaults = Object.assign({},
|
|
305
|
+
const clearedDefaults = Object.assign({}, baseDefaultValues);
|
|
326
306
|
flattenedSchema.forEach(field => {
|
|
327
307
|
const key = String(field.key);
|
|
328
|
-
const defaultValue =
|
|
308
|
+
const defaultValue = baseDefaultValues[key];
|
|
329
309
|
const resolved = resolveClearedFieldValue(field, defaultValue);
|
|
330
310
|
if (resolved === undefined) {
|
|
331
311
|
delete clearedDefaults[key];
|
|
@@ -346,7 +326,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
346
326
|
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
347
327
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
348
328
|
}, [
|
|
349
|
-
|
|
329
|
+
baseDefaultValues,
|
|
350
330
|
flattenedSchema,
|
|
351
331
|
formMethods,
|
|
352
332
|
onClearAll,
|
|
@@ -378,33 +358,32 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
378
358
|
if (!schemaField) {
|
|
379
359
|
return;
|
|
380
360
|
}
|
|
381
|
-
const defaultValue =
|
|
361
|
+
const defaultValue = baseDefaultValues[String(schemaField.key)];
|
|
362
|
+
const fieldPath = schemaField.key;
|
|
382
363
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
383
|
-
//
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, updatedFormValues);
|
|
389
|
-
// Update form state
|
|
390
|
-
formMethods.reset(updatedFormValues, {
|
|
391
|
-
keepDirty: false,
|
|
392
|
-
keepTouched: false,
|
|
393
|
-
keepValues: false
|
|
364
|
+
// Update the form value
|
|
365
|
+
formMethods.setValue(fieldPath, nextValue, {
|
|
366
|
+
shouldDirty: false,
|
|
367
|
+
shouldTouch: false,
|
|
368
|
+
shouldValidate: false
|
|
394
369
|
});
|
|
370
|
+
// Compute the updated values immediately (don't wait for debounce)
|
|
371
|
+
const currentValues = formMethods.getValues() || {};
|
|
372
|
+
const updatedFormValues = Object.assign(Object.assign({}, currentValues), { [fieldPath]: nextValue });
|
|
373
|
+
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, updatedFormValues);
|
|
395
374
|
const nextSerialised = JSON.stringify(nextValues);
|
|
396
375
|
// Persist immediately (bypass debounce for remove action)
|
|
397
|
-
persistValues(nextValues);
|
|
376
|
+
persistValues(nextValues, nextSerialised);
|
|
398
377
|
// Update refs to mark this as the latest persisted state
|
|
399
378
|
lastPersistedValuesRef.current = nextSerialised;
|
|
400
379
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
401
|
-
previousSerialisedValuesRef.current = nextSerialised;
|
|
380
|
+
previousSerialisedValuesRef.current = nextSerialised;
|
|
402
381
|
hasEmittedValuesRef.current = true;
|
|
403
382
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
404
383
|
// Emit the change to parent
|
|
405
384
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
406
385
|
}, [
|
|
407
|
-
|
|
386
|
+
baseDefaultValues,
|
|
408
387
|
flattenedSchema,
|
|
409
388
|
formMethods,
|
|
410
389
|
onValuesChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akifilter.d.ts","sourceRoot":"","sources":["../../src/akifilter.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,EAIL,WAAW,EACX,IAAI,EAIL,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;AA0HxC,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;I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AAqB,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;AAuuBF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAmBpC,CAAC"}
|
package/dist/esm/akifilter.js
CHANGED
|
@@ -109,15 +109,9 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
109
109
|
const schemaDefaults = React.useMemo(() => normaliseValuesBySchema(flattenedSchema, extractDefaultValues(flattenedSchema)), [flattenedSchema]);
|
|
110
110
|
const externalDefaults = React.useMemo(() => normaliseValuesBySchema(flattenedSchema, defaultValues), [flattenedSchema, defaultValues]);
|
|
111
111
|
const baseDefaultValues = React.useMemo(() => (Object.assign(Object.assign({}, schemaDefaults), externalDefaults)), [schemaDefaults, externalDefaults]);
|
|
112
|
-
|
|
113
|
-
const [persistedDefaults, setPersistedDefaults] = React.useState(() => {
|
|
112
|
+
const persistedDefaults = React.useMemo(() => {
|
|
114
113
|
var _a;
|
|
115
114
|
return normaliseValuesBySchema(flattenedSchema, (_a = readStoredValues(regularFields, storageKey)) !== null && _a !== void 0 ? _a : undefined);
|
|
116
|
-
});
|
|
117
|
-
// Re-read from localStorage when storageKey changes
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
var _a;
|
|
120
|
-
setPersistedDefaults(normaliseValuesBySchema(flattenedSchema, (_a = readStoredValues(regularFields, storageKey)) !== null && _a !== void 0 ? _a : undefined));
|
|
121
115
|
}, [flattenedSchema, regularFields, storageKey]);
|
|
122
116
|
const mergedDefaultValues = React.useMemo(() => (Object.assign(Object.assign({}, baseDefaultValues), persistedDefaults)), [baseDefaultValues, persistedDefaults]);
|
|
123
117
|
const formMethods = useForm({
|
|
@@ -216,20 +210,8 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
216
210
|
writeVisibleKeys(storageKey, visibleKeys);
|
|
217
211
|
onVisibleFieldsChange === null || onVisibleFieldsChange === void 0 ? void 0 : onVisibleFieldsChange(visibleKeys);
|
|
218
212
|
}, [visibleKeys, onVisibleFieldsChange, storageKey]);
|
|
219
|
-
// Track previous mergedDefaultValues to avoid unnecessary resets
|
|
220
|
-
const previousMergedDefaultValuesRef = React.useRef(null);
|
|
221
213
|
React.useEffect(() => {
|
|
222
|
-
|
|
223
|
-
// Skip if the values haven't actually changed (deep comparison)
|
|
224
|
-
if (previousMergedDefaultValuesRef.current === serialised) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
// Skip reset on initial mount - useForm already uses defaultValues
|
|
228
|
-
if (previousMergedDefaultValuesRef.current === null) {
|
|
229
|
-
previousMergedDefaultValuesRef.current = serialised;
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
previousMergedDefaultValuesRef.current = serialised;
|
|
214
|
+
formMethods.reset(mergedDefaultValues);
|
|
233
215
|
}, [formMethods, mergedDefaultValues]);
|
|
234
216
|
const normalisedValues = React.useMemo(() => normaliseOutputValues(flattenedSchema, formValues), [flattenedSchema, formValues]);
|
|
235
217
|
const hasInitialValuesRef = React.useRef(false);
|
|
@@ -313,16 +295,14 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
313
295
|
persistValues(currParsed, nextSerialised);
|
|
314
296
|
lastPersistedValuesRef.current = nextSerialised;
|
|
315
297
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
316
|
-
// Update persistedDefaults to prevent stale mergedDefaultValues on re-render
|
|
317
|
-
setPersistedDefaults(currParsed);
|
|
318
298
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
319
299
|
}
|
|
320
300
|
}, [serialisedValues, onValuesChange, persistValues]);
|
|
321
301
|
const handleClearAll = React.useCallback(() => {
|
|
322
|
-
const clearedDefaults = Object.assign({},
|
|
302
|
+
const clearedDefaults = Object.assign({}, baseDefaultValues);
|
|
323
303
|
flattenedSchema.forEach(field => {
|
|
324
304
|
const key = String(field.key);
|
|
325
|
-
const defaultValue =
|
|
305
|
+
const defaultValue = baseDefaultValues[key];
|
|
326
306
|
const resolved = resolveClearedFieldValue(field, defaultValue);
|
|
327
307
|
if (resolved === undefined) {
|
|
328
308
|
delete clearedDefaults[key];
|
|
@@ -343,7 +323,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
343
323
|
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
344
324
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
345
325
|
}, [
|
|
346
|
-
|
|
326
|
+
baseDefaultValues,
|
|
347
327
|
flattenedSchema,
|
|
348
328
|
formMethods,
|
|
349
329
|
onClearAll,
|
|
@@ -375,33 +355,32 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
375
355
|
if (!schemaField) {
|
|
376
356
|
return;
|
|
377
357
|
}
|
|
378
|
-
const defaultValue =
|
|
358
|
+
const defaultValue = baseDefaultValues[String(schemaField.key)];
|
|
359
|
+
const fieldPath = schemaField.key;
|
|
379
360
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const nextValues = normaliseOutputValues(flattenedSchema, updatedFormValues);
|
|
386
|
-
// Update form state
|
|
387
|
-
formMethods.reset(updatedFormValues, {
|
|
388
|
-
keepDirty: false,
|
|
389
|
-
keepTouched: false,
|
|
390
|
-
keepValues: false
|
|
361
|
+
// Update the form value
|
|
362
|
+
formMethods.setValue(fieldPath, nextValue, {
|
|
363
|
+
shouldDirty: false,
|
|
364
|
+
shouldTouch: false,
|
|
365
|
+
shouldValidate: false
|
|
391
366
|
});
|
|
367
|
+
// Compute the updated values immediately (don't wait for debounce)
|
|
368
|
+
const currentValues = formMethods.getValues() || {};
|
|
369
|
+
const updatedFormValues = Object.assign(Object.assign({}, currentValues), { [fieldPath]: nextValue });
|
|
370
|
+
const nextValues = normaliseOutputValues(flattenedSchema, updatedFormValues);
|
|
392
371
|
const nextSerialised = JSON.stringify(nextValues);
|
|
393
372
|
// Persist immediately (bypass debounce for remove action)
|
|
394
|
-
persistValues(nextValues);
|
|
373
|
+
persistValues(nextValues, nextSerialised);
|
|
395
374
|
// Update refs to mark this as the latest persisted state
|
|
396
375
|
lastPersistedValuesRef.current = nextSerialised;
|
|
397
376
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
398
|
-
previousSerialisedValuesRef.current = nextSerialised;
|
|
377
|
+
previousSerialisedValuesRef.current = nextSerialised;
|
|
399
378
|
hasEmittedValuesRef.current = true;
|
|
400
379
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
401
380
|
// Emit the change to parent
|
|
402
381
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
403
382
|
}, [
|
|
404
|
-
|
|
383
|
+
baseDefaultValues,
|
|
405
384
|
flattenedSchema,
|
|
406
385
|
formMethods,
|
|
407
386
|
onValuesChange,
|
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.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Akifilter is a filtering library for Akinon frontend applications.",
|
|
6
6
|
"type": "module",
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"antd": "^5.27.0",
|
|
14
14
|
"react-error-boundary": "^6.0.0",
|
|
15
|
+
"@akinon/akidate": "1.1.3-next.0",
|
|
15
16
|
"@akinon/akiform": "1.1.2",
|
|
16
|
-
"@akinon/akilocale": "1.2.1",
|
|
17
17
|
"@akinon/icons": "1.1.2-next.1",
|
|
18
18
|
"@akinon/ui-button": "1.4.0-next.1",
|
|
19
|
+
"@akinon/akilocale": "1.2.1",
|
|
19
20
|
"@akinon/ui-card": "1.1.3-next.1",
|
|
20
21
|
"@akinon/ui-checkbox": "1.3.3-next.1",
|
|
21
22
|
"@akinon/ui-collapse": "1.3.2-next.1",
|
|
22
23
|
"@akinon/ui-date-picker": "1.3.3-next.1",
|
|
23
|
-
"@akinon/akidate": "1.1.3-next.0",
|
|
24
|
-
"@akinon/ui-input": "1.1.3-next.1",
|
|
25
24
|
"@akinon/ui-input-number": "1.3.3-next.1",
|
|
26
|
-
"@akinon/ui-
|
|
27
|
-
"@akinon/ui-space": "1.3.3-next.1",
|
|
28
|
-
"@akinon/ui-select": "1.3.4-next.1",
|
|
25
|
+
"@akinon/ui-input": "1.1.3-next.1",
|
|
29
26
|
"@akinon/ui-pagination": "1.3.4-next.1",
|
|
30
|
-
"@akinon/ui-
|
|
27
|
+
"@akinon/ui-select": "1.3.4-next.1",
|
|
28
|
+
"@akinon/ui-typography": "1.1.2-next.0",
|
|
29
|
+
"@akinon/ui-modal": "1.1.3-next.1",
|
|
30
|
+
"@akinon/ui-space": "1.3.3-next.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"clean-package": "2.2.0",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@akinon/akiform-builder": "1.3.5-next.1",
|
|
38
38
|
"@akinon/typescript-config": "1.1.1",
|
|
39
39
|
"@akinon/ui-theme": "1.1.3-next.1",
|
|
40
|
-
"@akinon/
|
|
41
|
-
"@akinon/
|
|
40
|
+
"@akinon/vitest-config": "1.1.1",
|
|
41
|
+
"@akinon/utils": "1.1.4-next.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^18 || ^19",
|