@akinon/akifilter 1.2.0-next.10 → 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 +18 -40
- package/dist/esm/akifilter.d.ts.map +1 -1
- package/dist/esm/akifilter.js +18 -40
- package/package.json +8 -8
|
@@ -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,7 @@ 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
|
-
const serialised = JSON.stringify(mergedDefaultValues);
|
|
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;
|
|
236
217
|
formMethods.reset(mergedDefaultValues);
|
|
237
218
|
}, [formMethods, mergedDefaultValues]);
|
|
238
219
|
const normalisedValues = react_1.default.useMemo(() => (0, values_1.normaliseOutputValues)(flattenedSchema, formValues), [flattenedSchema, formValues]);
|
|
@@ -317,16 +298,14 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
317
298
|
persistValues(currParsed, nextSerialised);
|
|
318
299
|
lastPersistedValuesRef.current = nextSerialised;
|
|
319
300
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
320
|
-
// Update persistedDefaults to prevent stale mergedDefaultValues on re-render
|
|
321
|
-
setPersistedDefaults(currParsed);
|
|
322
301
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
323
302
|
}
|
|
324
303
|
}, [serialisedValues, onValuesChange, persistValues]);
|
|
325
304
|
const handleClearAll = react_1.default.useCallback(() => {
|
|
326
|
-
const clearedDefaults = Object.assign({},
|
|
305
|
+
const clearedDefaults = Object.assign({}, baseDefaultValues);
|
|
327
306
|
flattenedSchema.forEach(field => {
|
|
328
307
|
const key = String(field.key);
|
|
329
|
-
const defaultValue =
|
|
308
|
+
const defaultValue = baseDefaultValues[key];
|
|
330
309
|
const resolved = resolveClearedFieldValue(field, defaultValue);
|
|
331
310
|
if (resolved === undefined) {
|
|
332
311
|
delete clearedDefaults[key];
|
|
@@ -347,7 +326,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
347
326
|
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
348
327
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
349
328
|
}, [
|
|
350
|
-
|
|
329
|
+
baseDefaultValues,
|
|
351
330
|
flattenedSchema,
|
|
352
331
|
formMethods,
|
|
353
332
|
onClearAll,
|
|
@@ -379,33 +358,32 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
379
358
|
if (!schemaField) {
|
|
380
359
|
return;
|
|
381
360
|
}
|
|
382
|
-
const defaultValue =
|
|
361
|
+
const defaultValue = baseDefaultValues[String(schemaField.key)];
|
|
362
|
+
const fieldPath = schemaField.key;
|
|
383
363
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, updatedFormValues);
|
|
390
|
-
// Update form state
|
|
391
|
-
formMethods.reset(updatedFormValues, {
|
|
392
|
-
keepDirty: false,
|
|
393
|
-
keepTouched: false,
|
|
394
|
-
keepValues: false
|
|
364
|
+
// Update the form value
|
|
365
|
+
formMethods.setValue(fieldPath, nextValue, {
|
|
366
|
+
shouldDirty: false,
|
|
367
|
+
shouldTouch: false,
|
|
368
|
+
shouldValidate: false
|
|
395
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);
|
|
396
374
|
const nextSerialised = JSON.stringify(nextValues);
|
|
397
375
|
// Persist immediately (bypass debounce for remove action)
|
|
398
|
-
persistValues(nextValues);
|
|
376
|
+
persistValues(nextValues, nextSerialised);
|
|
399
377
|
// Update refs to mark this as the latest persisted state
|
|
400
378
|
lastPersistedValuesRef.current = nextSerialised;
|
|
401
379
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
402
|
-
previousSerialisedValuesRef.current = nextSerialised;
|
|
380
|
+
previousSerialisedValuesRef.current = nextSerialised;
|
|
403
381
|
hasEmittedValuesRef.current = true;
|
|
404
382
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
405
383
|
// Emit the change to parent
|
|
406
384
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
407
385
|
}, [
|
|
408
|
-
|
|
386
|
+
baseDefaultValues,
|
|
409
387
|
flattenedSchema,
|
|
410
388
|
formMethods,
|
|
411
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;IAC1B;;OAEG;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AAE,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,7 @@ 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
|
-
const serialised = JSON.stringify(mergedDefaultValues);
|
|
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;
|
|
233
214
|
formMethods.reset(mergedDefaultValues);
|
|
234
215
|
}, [formMethods, mergedDefaultValues]);
|
|
235
216
|
const normalisedValues = React.useMemo(() => normaliseOutputValues(flattenedSchema, formValues), [flattenedSchema, formValues]);
|
|
@@ -314,16 +295,14 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
314
295
|
persistValues(currParsed, nextSerialised);
|
|
315
296
|
lastPersistedValuesRef.current = nextSerialised;
|
|
316
297
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
317
|
-
// Update persistedDefaults to prevent stale mergedDefaultValues on re-render
|
|
318
|
-
setPersistedDefaults(currParsed);
|
|
319
298
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(currParsed);
|
|
320
299
|
}
|
|
321
300
|
}, [serialisedValues, onValuesChange, persistValues]);
|
|
322
301
|
const handleClearAll = React.useCallback(() => {
|
|
323
|
-
const clearedDefaults = Object.assign({},
|
|
302
|
+
const clearedDefaults = Object.assign({}, baseDefaultValues);
|
|
324
303
|
flattenedSchema.forEach(field => {
|
|
325
304
|
const key = String(field.key);
|
|
326
|
-
const defaultValue =
|
|
305
|
+
const defaultValue = baseDefaultValues[key];
|
|
327
306
|
const resolved = resolveClearedFieldValue(field, defaultValue);
|
|
328
307
|
if (resolved === undefined) {
|
|
329
308
|
delete clearedDefaults[key];
|
|
@@ -344,7 +323,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
344
323
|
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
345
324
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
346
325
|
}, [
|
|
347
|
-
|
|
326
|
+
baseDefaultValues,
|
|
348
327
|
flattenedSchema,
|
|
349
328
|
formMethods,
|
|
350
329
|
onClearAll,
|
|
@@ -376,33 +355,32 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
376
355
|
if (!schemaField) {
|
|
377
356
|
return;
|
|
378
357
|
}
|
|
379
|
-
const defaultValue =
|
|
358
|
+
const defaultValue = baseDefaultValues[String(schemaField.key)];
|
|
359
|
+
const fieldPath = schemaField.key;
|
|
380
360
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
381
|
-
//
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const nextValues = normaliseOutputValues(flattenedSchema, updatedFormValues);
|
|
387
|
-
// Update form state
|
|
388
|
-
formMethods.reset(updatedFormValues, {
|
|
389
|
-
keepDirty: false,
|
|
390
|
-
keepTouched: false,
|
|
391
|
-
keepValues: false
|
|
361
|
+
// Update the form value
|
|
362
|
+
formMethods.setValue(fieldPath, nextValue, {
|
|
363
|
+
shouldDirty: false,
|
|
364
|
+
shouldTouch: false,
|
|
365
|
+
shouldValidate: false
|
|
392
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);
|
|
393
371
|
const nextSerialised = JSON.stringify(nextValues);
|
|
394
372
|
// Persist immediately (bypass debounce for remove action)
|
|
395
|
-
persistValues(nextValues);
|
|
373
|
+
persistValues(nextValues, nextSerialised);
|
|
396
374
|
// Update refs to mark this as the latest persisted state
|
|
397
375
|
lastPersistedValuesRef.current = nextSerialised;
|
|
398
376
|
currentSerialisedValuesRef.current = nextSerialised;
|
|
399
|
-
previousSerialisedValuesRef.current = nextSerialised;
|
|
377
|
+
previousSerialisedValuesRef.current = nextSerialised;
|
|
400
378
|
hasEmittedValuesRef.current = true;
|
|
401
379
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
402
380
|
// Emit the change to parent
|
|
403
381
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
404
382
|
}, [
|
|
405
|
-
|
|
383
|
+
baseDefaultValues,
|
|
406
384
|
flattenedSchema,
|
|
407
385
|
formMethods,
|
|
408
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,21 +12,21 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"antd": "^5.27.0",
|
|
14
14
|
"react-error-boundary": "^6.0.0",
|
|
15
|
-
"@akinon/akiform": "1.1.2",
|
|
16
15
|
"@akinon/akidate": "1.1.3-next.0",
|
|
17
|
-
"@akinon/
|
|
16
|
+
"@akinon/akiform": "1.1.2",
|
|
18
17
|
"@akinon/icons": "1.1.2-next.1",
|
|
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
|
-
"@akinon/akilocale": "1.2.1",
|
|
22
22
|
"@akinon/ui-collapse": "1.3.2-next.1",
|
|
23
|
-
"@akinon/ui-input": "1.1.3-next.1",
|
|
24
|
-
"@akinon/ui-modal": "1.1.3-next.1",
|
|
25
23
|
"@akinon/ui-date-picker": "1.3.3-next.1",
|
|
26
24
|
"@akinon/ui-input-number": "1.3.3-next.1",
|
|
27
|
-
"@akinon/ui-
|
|
25
|
+
"@akinon/ui-input": "1.1.3-next.1",
|
|
28
26
|
"@akinon/ui-pagination": "1.3.4-next.1",
|
|
27
|
+
"@akinon/ui-select": "1.3.4-next.1",
|
|
29
28
|
"@akinon/ui-typography": "1.1.2-next.0",
|
|
29
|
+
"@akinon/ui-modal": "1.1.3-next.1",
|
|
30
30
|
"@akinon/ui-space": "1.3.3-next.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"rimraf": "^5.0.5",
|
|
36
36
|
"typescript": "*",
|
|
37
37
|
"@akinon/akiform-builder": "1.3.5-next.1",
|
|
38
|
-
"@akinon/ui-theme": "1.1.3-next.1",
|
|
39
38
|
"@akinon/typescript-config": "1.1.1",
|
|
39
|
+
"@akinon/ui-theme": "1.1.3-next.1",
|
|
40
40
|
"@akinon/vitest-config": "1.1.1",
|
|
41
41
|
"@akinon/utils": "1.1.4-next.1"
|
|
42
42
|
},
|