@akinon/akifilter 1.0.4 → 1.1.0
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 +86 -35
- package/dist/cjs/common/storage.d.ts.map +1 -1
- package/dist/cjs/common/storage.js +7 -6
- package/dist/cjs/constants.d.ts +6 -0
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/i18n/translations/en.d.ts +8 -0
- package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
- package/dist/cjs/i18n/translations/en.js +9 -1
- package/dist/cjs/i18n/translations/tr.d.ts +8 -0
- package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
- package/dist/cjs/i18n/translations/tr.js +9 -1
- package/dist/cjs/styles.css +30 -0
- package/dist/cjs/utils/schema.d.ts +14 -0
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +35 -1
- package/dist/cjs/utils/values.d.ts.map +1 -1
- package/dist/cjs/utils/values.js +5 -1
- package/dist/esm/akifilter.d.ts.map +1 -1
- package/dist/esm/akifilter.js +88 -37
- package/dist/esm/common/storage.d.ts.map +1 -1
- package/dist/esm/common/storage.js +7 -6
- package/dist/esm/constants.d.ts +6 -0
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +6 -0
- package/dist/esm/i18n/translations/en.d.ts +8 -0
- package/dist/esm/i18n/translations/en.d.ts.map +1 -1
- package/dist/esm/i18n/translations/en.js +9 -1
- package/dist/esm/i18n/translations/tr.d.ts +8 -0
- package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
- package/dist/esm/i18n/translations/tr.js +9 -1
- package/dist/esm/styles.css +30 -0
- package/dist/esm/utils/schema.d.ts +14 -0
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +32 -0
- package/dist/esm/utils/values.d.ts.map +1 -1
- package/dist/esm/utils/values.js +5 -1
- package/package.json +22 -21
|
@@ -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;
|
|
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;AA2B1B,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/D,KAAK,oBAAoB,GAAG,WAAW,CAAC;AA2BxC,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;AAirBF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAmBpC,CAAC"}
|
package/dist/cjs/akifilter.js
CHANGED
|
@@ -18,6 +18,7 @@ const akiform_1 = require("@akinon/akiform");
|
|
|
18
18
|
const ui_button_1 = require("@akinon/ui-button");
|
|
19
19
|
const ui_card_1 = require("@akinon/ui-card");
|
|
20
20
|
const ui_checkbox_1 = require("@akinon/ui-checkbox");
|
|
21
|
+
const ui_collapse_1 = require("@akinon/ui-collapse");
|
|
21
22
|
const ui_date_picker_1 = require("@akinon/ui-date-picker");
|
|
22
23
|
const ui_input_1 = require("@akinon/ui-input");
|
|
23
24
|
const ui_input_number_1 = require("@akinon/ui-input-number");
|
|
@@ -55,14 +56,18 @@ const resolveClearedFieldValue = (field, defaultValue) => {
|
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onValuesChange, onVisibleFieldsChange, onImportCsv, onImportXls, onClearAll, enableImportCsv, enableImportXls }) => {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
// Separate regular fields from section fields
|
|
60
|
+
const { regularFields, sectionFields } = react_1.default.useMemo(() => (0, schema_1.partitionSchema)(filterSchema), [filterSchema]);
|
|
61
|
+
// Flatten schema for storage and form value operations
|
|
62
|
+
const flattenedSchema = react_1.default.useMemo(() => (0, schema_1.flattenSchema)(filterSchema), [filterSchema]);
|
|
63
|
+
const storageKey = react_1.default.useMemo(() => (0, storage_1.buildStorageKey)(regularFields, storageNamespace), [regularFields, storageNamespace]);
|
|
64
|
+
const schemaDefaults = react_1.default.useMemo(() => (0, schema_1.normaliseValuesBySchema)(flattenedSchema, (0, schema_1.extractDefaultValues)(flattenedSchema)), [flattenedSchema]);
|
|
65
|
+
const externalDefaults = react_1.default.useMemo(() => (0, schema_1.normaliseValuesBySchema)(flattenedSchema, defaultValues), [flattenedSchema, defaultValues]);
|
|
61
66
|
const baseDefaultValues = react_1.default.useMemo(() => (Object.assign(Object.assign({}, schemaDefaults), externalDefaults)), [schemaDefaults, externalDefaults]);
|
|
62
67
|
const persistedDefaults = react_1.default.useMemo(() => {
|
|
63
68
|
var _a;
|
|
64
|
-
return (0, schema_1.normaliseValuesBySchema)(
|
|
65
|
-
}, [
|
|
69
|
+
return (0, schema_1.normaliseValuesBySchema)(flattenedSchema, (_a = (0, storage_1.readStoredValues)(regularFields, storageKey)) !== null && _a !== void 0 ? _a : undefined);
|
|
70
|
+
}, [flattenedSchema, regularFields, storageKey]);
|
|
66
71
|
const mergedDefaultValues = react_1.default.useMemo(() => (Object.assign(Object.assign({}, baseDefaultValues), persistedDefaults)), [baseDefaultValues, persistedDefaults]);
|
|
67
72
|
const formMethods = (0, akiform_1.useForm)({
|
|
68
73
|
defaultValues: mergedDefaultValues
|
|
@@ -76,7 +81,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
76
81
|
if (!formValues) {
|
|
77
82
|
return [];
|
|
78
83
|
}
|
|
79
|
-
return
|
|
84
|
+
return flattenedSchema.reduce((acc, field) => {
|
|
80
85
|
const key = String(field.key);
|
|
81
86
|
const currentValue = formValues[key];
|
|
82
87
|
if (currentValue === undefined || currentValue === null) {
|
|
@@ -107,14 +112,17 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
107
112
|
if (field.type === 'date') {
|
|
108
113
|
const iso = akidate_1.akidate.toIsoDate(currentValue);
|
|
109
114
|
if (iso) {
|
|
110
|
-
|
|
115
|
+
// Use localized format with time if showTime is enabled
|
|
116
|
+
const hasShowTime = 'showTime' in field && field.showTime;
|
|
117
|
+
const format = hasShowTime ? 'L LTS' : 'YYYY-MM-DD';
|
|
118
|
+
return akidate_1.akidate.formatIsoDate(iso, format);
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
121
|
if (Array.isArray(currentValue)) {
|
|
114
122
|
return currentValue.map((value) => String(value)).join(', ');
|
|
115
123
|
}
|
|
116
124
|
if (typeof currentValue === 'boolean') {
|
|
117
|
-
return currentValue ?
|
|
125
|
+
return currentValue ? constants_1.BOOLEAN_STRING.TRUE : constants_1.BOOLEAN_STRING.FALSE;
|
|
118
126
|
}
|
|
119
127
|
if (typeof currentValue === 'string' ||
|
|
120
128
|
typeof currentValue === 'number') {
|
|
@@ -122,31 +130,31 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
122
130
|
}
|
|
123
131
|
const iso = akidate_1.akidate.toIsoDate(currentValue);
|
|
124
132
|
if (iso) {
|
|
125
|
-
return akidate_1.akidate.formatIsoDate(iso,
|
|
133
|
+
return akidate_1.akidate.formatIsoDate(iso, constants_1.DATE_FORMAT);
|
|
126
134
|
}
|
|
127
135
|
return String(currentValue);
|
|
128
136
|
};
|
|
129
137
|
acc.push({ key, label, value: resolveValue() });
|
|
130
138
|
return acc;
|
|
131
139
|
}, []);
|
|
132
|
-
}, [
|
|
140
|
+
}, [flattenedSchema, formValues]);
|
|
133
141
|
const resolveInitialVisibleKeys = react_1.default.useCallback(() => {
|
|
134
|
-
const storedKeys = (0, storage_1.readVisibleKeys)(
|
|
142
|
+
const storedKeys = (0, storage_1.readVisibleKeys)(regularFields, storageKey);
|
|
135
143
|
if (storedKeys && storedKeys.length > 0) {
|
|
136
|
-
return (0, schema_1.ensureSchemaOrder)(
|
|
144
|
+
return (0, schema_1.ensureSchemaOrder)(regularFields, storedKeys);
|
|
137
145
|
}
|
|
138
|
-
return (0, schema_1.deriveDefaultVisibleKeys)(
|
|
139
|
-
}, [
|
|
146
|
+
return (0, schema_1.deriveDefaultVisibleKeys)(regularFields);
|
|
147
|
+
}, [regularFields, storageKey]);
|
|
140
148
|
const [visibleKeys, setVisibleKeys] = react_1.default.useState(resolveInitialVisibleKeys);
|
|
141
149
|
react_1.default.useEffect(() => {
|
|
142
150
|
setVisibleKeys(previous => {
|
|
143
|
-
const ordered = (0, schema_1.ensureSchemaOrder)(
|
|
151
|
+
const ordered = (0, schema_1.ensureSchemaOrder)(regularFields, previous);
|
|
144
152
|
if (ordered.length) {
|
|
145
153
|
return ordered;
|
|
146
154
|
}
|
|
147
155
|
return resolveInitialVisibleKeys();
|
|
148
156
|
});
|
|
149
|
-
}, [
|
|
157
|
+
}, [regularFields, resolveInitialVisibleKeys]);
|
|
150
158
|
react_1.default.useEffect(() => {
|
|
151
159
|
(0, storage_1.writeVisibleKeys)(storageKey, visibleKeys);
|
|
152
160
|
onVisibleFieldsChange === null || onVisibleFieldsChange === void 0 ? void 0 : onVisibleFieldsChange(visibleKeys);
|
|
@@ -154,12 +162,12 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
154
162
|
react_1.default.useEffect(() => {
|
|
155
163
|
formMethods.reset(mergedDefaultValues);
|
|
156
164
|
}, [formMethods, mergedDefaultValues]);
|
|
157
|
-
const normalisedValues = react_1.default.useMemo(() => (0, values_1.normaliseOutputValues)(
|
|
165
|
+
const normalisedValues = react_1.default.useMemo(() => (0, values_1.normaliseOutputValues)(flattenedSchema, formValues), [flattenedSchema, formValues]);
|
|
158
166
|
const hasInitialValuesRef = react_1.default.useRef(false);
|
|
159
167
|
react_1.default.useEffect(() => {
|
|
160
|
-
const initialValues = (0, values_1.normaliseOutputValues)(
|
|
168
|
+
const initialValues = (0, values_1.normaliseOutputValues)(flattenedSchema, mergedDefaultValues);
|
|
161
169
|
hasInitialValuesRef.current = Object.keys(initialValues).length > 0;
|
|
162
|
-
}, [
|
|
170
|
+
}, [flattenedSchema, mergedDefaultValues]);
|
|
163
171
|
const serialisedValues = react_1.default.useMemo(() => JSON.stringify(normalisedValues), [normalisedValues]);
|
|
164
172
|
const debouncedSerialisedValues = (0, use_debounced_value_1.useDebouncedValue)(serialisedValues, constants_1.FILTER_DEBOUNCE_DELAY);
|
|
165
173
|
const lastPersistedValuesRef = react_1.default.useRef(null);
|
|
@@ -174,14 +182,25 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
174
182
|
(0, storage_1.writeStoredValues)(storageKey, values);
|
|
175
183
|
return nextSerialised;
|
|
176
184
|
}, [storageKey]);
|
|
185
|
+
// Use a ref to track the current serialised values for staleness checks
|
|
186
|
+
const currentSerialisedValuesRef = react_1.default.useRef(serialisedValues);
|
|
187
|
+
react_1.default.useEffect(() => {
|
|
188
|
+
currentSerialisedValuesRef.current = serialisedValues;
|
|
189
|
+
}, [serialisedValues]);
|
|
177
190
|
react_1.default.useEffect(() => {
|
|
178
191
|
if (debouncedSerialisedValues == null) {
|
|
179
192
|
return;
|
|
180
193
|
}
|
|
194
|
+
// Skip if we've already processed this exact debounced value
|
|
181
195
|
if (hasEmittedValuesRef.current &&
|
|
182
196
|
lastPersistedValuesRef.current === debouncedSerialisedValues) {
|
|
183
197
|
return;
|
|
184
198
|
}
|
|
199
|
+
// Skip if the debounced value is stale (doesn't match current state)
|
|
200
|
+
// This prevents old debounced values from overwriting manual updates
|
|
201
|
+
if (currentSerialisedValuesRef.current !== debouncedSerialisedValues) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
185
204
|
const parsedValues = JSON.parse(debouncedSerialisedValues);
|
|
186
205
|
const isEmpty = Object.keys(parsedValues).length === 0;
|
|
187
206
|
if (!hasEmittedValuesRef.current &&
|
|
@@ -200,7 +219,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
200
219
|
}, [storageKey]);
|
|
201
220
|
const handleClearAll = react_1.default.useCallback(() => {
|
|
202
221
|
const clearedDefaults = Object.assign({}, baseDefaultValues);
|
|
203
|
-
|
|
222
|
+
flattenedSchema.forEach(field => {
|
|
204
223
|
const key = String(field.key);
|
|
205
224
|
const defaultValue = baseDefaultValues[key];
|
|
206
225
|
const resolved = resolveClearedFieldValue(field, defaultValue);
|
|
@@ -216,13 +235,20 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
216
235
|
keepTouched: false
|
|
217
236
|
});
|
|
218
237
|
onClearAll === null || onClearAll === void 0 ? void 0 : onClearAll();
|
|
219
|
-
const nextValues = (0, values_1.normaliseOutputValues)(
|
|
238
|
+
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, clearedDefaults);
|
|
220
239
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
221
240
|
const nextSerialised = persistValues(nextValues);
|
|
222
241
|
hasEmittedValuesRef.current = true;
|
|
223
242
|
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
224
243
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
225
|
-
}, [
|
|
244
|
+
}, [
|
|
245
|
+
baseDefaultValues,
|
|
246
|
+
flattenedSchema,
|
|
247
|
+
formMethods,
|
|
248
|
+
onClearAll,
|
|
249
|
+
onValuesChange,
|
|
250
|
+
persistValues
|
|
251
|
+
]);
|
|
226
252
|
const handleOpenModal = react_1.default.useCallback(() => {
|
|
227
253
|
setIsModalOpen(true);
|
|
228
254
|
setSearchTerm('');
|
|
@@ -240,31 +266,40 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
240
266
|
const nextKeys = exists
|
|
241
267
|
? prev.filter(item => item !== key)
|
|
242
268
|
: [...prev, key];
|
|
243
|
-
return (0, schema_1.ensureSchemaOrder)(
|
|
269
|
+
return (0, schema_1.ensureSchemaOrder)(regularFields, nextKeys);
|
|
244
270
|
});
|
|
245
|
-
}, [
|
|
271
|
+
}, [regularFields]);
|
|
246
272
|
const handleRemoveFilter = react_1.default.useCallback((key) => {
|
|
247
|
-
const schemaField =
|
|
273
|
+
const schemaField = flattenedSchema.find(field => String(field.key) === key);
|
|
248
274
|
if (!schemaField) {
|
|
249
275
|
return;
|
|
250
276
|
}
|
|
251
277
|
const defaultValue = baseDefaultValues[String(schemaField.key)];
|
|
252
278
|
const fieldPath = schemaField.key;
|
|
253
279
|
const nextValue = resolveClearedFieldValue(schemaField, defaultValue);
|
|
280
|
+
// Update the form value
|
|
254
281
|
formMethods.setValue(fieldPath, nextValue, {
|
|
255
282
|
shouldDirty: false,
|
|
256
283
|
shouldTouch: false,
|
|
257
284
|
shouldValidate: false
|
|
258
285
|
});
|
|
259
|
-
|
|
260
|
-
const
|
|
286
|
+
// Compute the updated values immediately (don't wait for debounce)
|
|
287
|
+
const currentValues = formMethods.getValues() || {};
|
|
288
|
+
const updatedFormValues = Object.assign(Object.assign({}, currentValues), { [fieldPath]: nextValue });
|
|
289
|
+
const nextValues = (0, values_1.normaliseOutputValues)(flattenedSchema, updatedFormValues);
|
|
290
|
+
const nextSerialised = JSON.stringify(nextValues);
|
|
291
|
+
// Persist immediately (bypass debounce for remove action)
|
|
292
|
+
persistValues(nextValues);
|
|
293
|
+
// Update refs to mark this as the latest persisted state
|
|
294
|
+
lastPersistedValuesRef.current = nextSerialised;
|
|
295
|
+
currentSerialisedValuesRef.current = nextSerialised;
|
|
261
296
|
hasEmittedValuesRef.current = true;
|
|
262
|
-
lastPersistedValuesRef.current = nextSerialised !== null && nextSerialised !== void 0 ? nextSerialised : null;
|
|
263
297
|
hasInitialValuesRef.current = Object.keys(nextValues).length > 0;
|
|
298
|
+
// Emit the change to parent
|
|
264
299
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(nextValues);
|
|
265
300
|
}, [
|
|
266
301
|
baseDefaultValues,
|
|
267
|
-
|
|
302
|
+
flattenedSchema,
|
|
268
303
|
formMethods,
|
|
269
304
|
onValuesChange,
|
|
270
305
|
persistValues
|
|
@@ -272,20 +307,20 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
272
307
|
const filteredFields = react_1.default.useMemo(() => {
|
|
273
308
|
const normalisedTerm = searchTerm.trim().toLowerCase();
|
|
274
309
|
if (!normalisedTerm) {
|
|
275
|
-
return
|
|
310
|
+
return regularFields;
|
|
276
311
|
}
|
|
277
|
-
return
|
|
312
|
+
return regularFields.filter(field => {
|
|
278
313
|
const searchable = [field.label, field.placeholder, String(field.key)]
|
|
279
314
|
.filter(Boolean)
|
|
280
315
|
.map(value => String(value).toLowerCase());
|
|
281
316
|
return searchable.some(text => text.includes(normalisedTerm));
|
|
282
317
|
});
|
|
283
|
-
}, [
|
|
318
|
+
}, [regularFields, searchTerm]);
|
|
284
319
|
const paginatedFields = react_1.default.useMemo(() => {
|
|
285
320
|
const start = (modalPage - 1) * modalPageSize;
|
|
286
321
|
return filteredFields.slice(start, start + modalPageSize);
|
|
287
322
|
}, [filteredFields, modalPage, modalPageSize]);
|
|
288
|
-
const visibleFields = react_1.default.useMemo(() =>
|
|
323
|
+
const visibleFields = react_1.default.useMemo(() => regularFields.filter(field => visibleKeys.includes(String(field.key))), [regularFields, visibleKeys]);
|
|
289
324
|
const renderFieldComponent = (field) => {
|
|
290
325
|
const ariaLabel = (0, schema_1.getFieldAriaLabel)(field);
|
|
291
326
|
switch (field.type) {
|
|
@@ -312,10 +347,17 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
312
347
|
});
|
|
313
348
|
}
|
|
314
349
|
return (react_1.default.createElement(ui_typography_1.Text, { type: "secondary", className: "akinon-filter__unsupported" }, i18n_1.i18n.t('form.unsupportedField', { field: String(field.type) })));
|
|
350
|
+
case 'section':
|
|
351
|
+
// Section fields should not be rendered inline
|
|
352
|
+
// They are rendered separately after the main grid
|
|
353
|
+
return null;
|
|
315
354
|
default:
|
|
316
355
|
return (react_1.default.createElement(ui_typography_1.Text, { type: "secondary", className: "akinon-filter__unsupported" }, i18n_1.i18n.t('form.unsupportedField', { field: String(field.type) })));
|
|
317
356
|
}
|
|
318
357
|
};
|
|
358
|
+
const renderFormField = (field) => {
|
|
359
|
+
return (react_1.default.createElement(akiform_1.FormItem, { key: String(field.key), control: formMethods.control, name: field.key, tooltip: field.tooltip, help: field.help, labelDescription: field.labelDescription, required: Boolean(field.validation), className: "mb-0", valuePropName: field.type === 'checkbox' ? 'checked' : undefined }, renderFieldComponent(field)));
|
|
360
|
+
};
|
|
319
361
|
return (react_1.default.createElement(ui_card_1.Card, { size: "small", className: "akinon-filter shadow", "data-testid": "akifilter-root" },
|
|
320
362
|
react_1.default.createElement(antd_1.ConfigProvider, { theme: theme_overrides_1.themeOverrides },
|
|
321
363
|
react_1.default.createElement(filter_toolbar_1.FilterToolbar, { onOpenModal: handleOpenModal, enableImportCsv: enableImportCsv, enableImportXls: enableImportXls, onImportCsv: onImportCsv, onImportXls: onImportXls }),
|
|
@@ -323,8 +365,17 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
|
|
|
323
365
|
react_1.default.createElement("div", { className: "akinon-filter__body" },
|
|
324
366
|
react_1.default.createElement(akiform_1.Akiform, { layout: "vertical", className: "akinon-filter__form" },
|
|
325
367
|
react_1.default.createElement("div", { className: "akinon-filter__form-grid", "data-testid": "akifilter-form-grid" },
|
|
326
|
-
visibleFields.map(
|
|
327
|
-
visibleFields.length === 0 ? (react_1.default.createElement("div", { className: "akinon-filter__empty" }, i18n_1.i18n.t('form.noVisibleFields'))) : null)
|
|
368
|
+
visibleFields.map(renderFormField),
|
|
369
|
+
visibleFields.length === 0 ? (react_1.default.createElement("div", { className: "akinon-filter__empty" }, i18n_1.i18n.t('form.noVisibleFields'))) : null),
|
|
370
|
+
sectionFields.length > 0 && (react_1.default.createElement("div", { className: "akinon-filter__section-fields" }, sectionFields.map(section => {
|
|
371
|
+
return (react_1.default.createElement(ui_collapse_1.Collapse, { key: section.key, defaultActiveKey: section.key, ghost: true, items: [
|
|
372
|
+
{
|
|
373
|
+
key: section.key,
|
|
374
|
+
label: section.label,
|
|
375
|
+
children: (react_1.default.createElement("div", { className: "akinon-filter__form-grid" }, section.fields.map(renderFormField)))
|
|
376
|
+
}
|
|
377
|
+
] }));
|
|
378
|
+
}))))),
|
|
328
379
|
react_1.default.createElement(visibility_modal_1.VisibilityModal, { open: isModalOpen, onClose: handleCloseModal, searchTerm: searchTerm, paginatedFields: paginatedFields, filteredCount: filteredFields.length, visibleKeys: visibleKeys, onSearchTermChange: value => {
|
|
329
380
|
setSearchTerm(value);
|
|
330
381
|
setModalPage(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/common/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/common/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAqB/C,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,EAC9D,QAAQ,cAAc,CAAC,YAAY,CAAC,EAAE,EACtC,YAAY,MAAM,KACjB,MAKF,CAAC;AAIF,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,EAC9D,QAAQ,cAAc,CAAC,YAAY,CAAC,EAAE,EACtC,YAAY,MAAM,KACjB,MAAM,EAAE,GAAG,IAoBb,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,EAAE,MAAM,MAAM,EAAE,KAAG,IAQrE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,IAQrD,CAAC;AAKF,eAAO,MAAM,gBAAgB,GAAI,YAAY,SAAS,WAAW,EAC/D,QAAQ,cAAc,CAAC,YAAY,CAAC,EAAE,EACtC,YAAY,MAAM,KACjB,OAAO,CAAC,YAAY,CAAC,GAAG,IA+B1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAY,SAAS,WAAW,EAChE,YAAY,MAAM,EAClB,QAAQ,OAAO,CAAC,YAAY,CAAC,KAC5B,IAeF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,IAQtD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clearStoredValues = exports.writeStoredValues = exports.readStoredValues = exports.clearVisibleKeys = exports.writeVisibleKeys = exports.readVisibleKeys = exports.buildStorageKey = void 0;
|
|
4
|
+
const i18n_1 = require("../i18n");
|
|
4
5
|
const STORAGE_PREFIX = 'akifilter:v1';
|
|
5
6
|
const VALUES_SUFFIX = ':values';
|
|
6
7
|
const hashString = (value) => {
|
|
@@ -39,7 +40,7 @@ const readVisibleKeys = (schema, storageKey) => {
|
|
|
39
40
|
return parsed.filter(key => schemaKeys.has(String(key)));
|
|
40
41
|
}
|
|
41
42
|
catch (error) {
|
|
42
|
-
console.warn('
|
|
43
|
+
console.warn(i18n_1.i18n.t('errors.storage.readVisibility'), error);
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
45
46
|
};
|
|
@@ -51,7 +52,7 @@ const writeVisibleKeys = (storageKey, keys) => {
|
|
|
51
52
|
window.localStorage.setItem(storageKey, JSON.stringify(keys));
|
|
52
53
|
}
|
|
53
54
|
catch (error) {
|
|
54
|
-
console.warn('
|
|
55
|
+
console.warn(i18n_1.i18n.t('errors.storage.writeVisibility'), error);
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
exports.writeVisibleKeys = writeVisibleKeys;
|
|
@@ -62,7 +63,7 @@ const clearVisibleKeys = (storageKey) => {
|
|
|
62
63
|
window.localStorage.removeItem(storageKey);
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
|
-
console.warn('
|
|
66
|
+
console.warn(i18n_1.i18n.t('errors.storage.clearVisibility'), error);
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
exports.clearVisibleKeys = clearVisibleKeys;
|
|
@@ -89,7 +90,7 @@ const readStoredValues = (schema, storageKey) => {
|
|
|
89
90
|
}, {});
|
|
90
91
|
}
|
|
91
92
|
catch (error) {
|
|
92
|
-
console.warn('
|
|
93
|
+
console.warn(i18n_1.i18n.t('errors.storage.readValues'), error);
|
|
93
94
|
return null;
|
|
94
95
|
}
|
|
95
96
|
};
|
|
@@ -107,7 +108,7 @@ const writeStoredValues = (storageKey, values) => {
|
|
|
107
108
|
window.localStorage.setItem(valuesKey, JSON.stringify(values));
|
|
108
109
|
}
|
|
109
110
|
catch (error) {
|
|
110
|
-
console.warn('
|
|
111
|
+
console.warn(i18n_1.i18n.t('errors.storage.writeValues'), error);
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
114
|
exports.writeStoredValues = writeStoredValues;
|
|
@@ -118,7 +119,7 @@ const clearStoredValues = (storageKey) => {
|
|
|
118
119
|
window.localStorage.removeItem(buildValuesStorageKey(storageKey));
|
|
119
120
|
}
|
|
120
121
|
catch (error) {
|
|
121
|
-
console.warn('
|
|
122
|
+
console.warn(i18n_1.i18n.t('errors.storage.clearValues'), error);
|
|
122
123
|
}
|
|
123
124
|
};
|
|
124
125
|
exports.clearStoredValues = clearStoredValues;
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare const DEFAULT_VISIBLE_COUNT = 8;
|
|
2
2
|
export declare const DEFAULT_MODAL_PAGE_SIZE = 40;
|
|
3
3
|
export declare const FILTER_DEBOUNCE_DELAY = 300;
|
|
4
|
+
export declare const DATE_FORMAT = "YYYY-MM-DD";
|
|
5
|
+
export declare const DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
6
|
+
export declare const BOOLEAN_STRING: {
|
|
7
|
+
readonly TRUE: "true";
|
|
8
|
+
readonly FALSE: "false";
|
|
9
|
+
};
|
|
4
10
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,eAAO,MAAM,WAAW,eAAe,CAAC;AACxC,eAAO,MAAM,eAAe,wBAAwB,CAAC;AAErD,eAAO,MAAM,cAAc;;;CAGjB,CAAC"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FILTER_DEBOUNCE_DELAY = exports.DEFAULT_MODAL_PAGE_SIZE = exports.DEFAULT_VISIBLE_COUNT = void 0;
|
|
3
|
+
exports.BOOLEAN_STRING = exports.DATETIME_FORMAT = exports.DATE_FORMAT = exports.FILTER_DEBOUNCE_DELAY = exports.DEFAULT_MODAL_PAGE_SIZE = exports.DEFAULT_VISIBLE_COUNT = void 0;
|
|
4
4
|
exports.DEFAULT_VISIBLE_COUNT = 8;
|
|
5
5
|
exports.DEFAULT_MODAL_PAGE_SIZE = 40;
|
|
6
6
|
exports.FILTER_DEBOUNCE_DELAY = 300;
|
|
7
|
+
exports.DATE_FORMAT = 'YYYY-MM-DD';
|
|
8
|
+
exports.DATETIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
|
9
|
+
exports.BOOLEAN_STRING = {
|
|
10
|
+
TRUE: 'true',
|
|
11
|
+
FALSE: 'false'
|
|
12
|
+
};
|
|
@@ -29,6 +29,14 @@ declare const translations: {
|
|
|
29
29
|
readonly title: "Akifilter failed to load";
|
|
30
30
|
readonly description: "An unexpected error occurred while rendering the filters. Try again or refresh the page.";
|
|
31
31
|
readonly retry: "Try again";
|
|
32
|
+
readonly storage: {
|
|
33
|
+
readonly readVisibility: "Akifilter: unable to read visibility state from storage";
|
|
34
|
+
readonly writeVisibility: "Akifilter: unable to persist visibility state";
|
|
35
|
+
readonly clearVisibility: "Akifilter: unable to clear visibility state";
|
|
36
|
+
readonly readValues: "Akifilter: unable to read values from storage";
|
|
37
|
+
readonly writeValues: "Akifilter: unable to persist values";
|
|
38
|
+
readonly clearValues: "Akifilter: unable to clear stored values";
|
|
39
|
+
};
|
|
32
40
|
};
|
|
33
41
|
};
|
|
34
42
|
export default translations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -30,7 +30,15 @@ const translations = {
|
|
|
30
30
|
errors: {
|
|
31
31
|
title: 'Akifilter failed to load',
|
|
32
32
|
description: 'An unexpected error occurred while rendering the filters. Try again or refresh the page.',
|
|
33
|
-
retry: 'Try again'
|
|
33
|
+
retry: 'Try again',
|
|
34
|
+
storage: {
|
|
35
|
+
readVisibility: 'Akifilter: unable to read visibility state from storage',
|
|
36
|
+
writeVisibility: 'Akifilter: unable to persist visibility state',
|
|
37
|
+
clearVisibility: 'Akifilter: unable to clear visibility state',
|
|
38
|
+
readValues: 'Akifilter: unable to read values from storage',
|
|
39
|
+
writeValues: 'Akifilter: unable to persist values',
|
|
40
|
+
clearValues: 'Akifilter: unable to clear stored values'
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
};
|
|
36
44
|
exports.default = translations;
|
|
@@ -29,6 +29,14 @@ declare const translations: {
|
|
|
29
29
|
readonly title: "Akifilter yüklenemedi";
|
|
30
30
|
readonly description: "Filtreler render edilirken beklenmeyen bir hata oluştu. Lütfen tekrar deneyin veya sayfayı yenileyin.";
|
|
31
31
|
readonly retry: "Tekrar dene";
|
|
32
|
+
readonly storage: {
|
|
33
|
+
readonly readVisibility: "Akifilter: görünürlük durumu depodan okunamadı";
|
|
34
|
+
readonly writeVisibility: "Akifilter: görünürlük durumu kalıcı hale getirilemedi";
|
|
35
|
+
readonly clearVisibility: "Akifilter: görünürlük durumu temizlenemedi";
|
|
36
|
+
readonly readValues: "Akifilter: değerler depodan okunamadı";
|
|
37
|
+
readonly writeValues: "Akifilter: değerler kalıcı hale getirilemedi";
|
|
38
|
+
readonly clearValues: "Akifilter: kayıtlı değerler temizlenemedi";
|
|
39
|
+
};
|
|
32
40
|
};
|
|
33
41
|
};
|
|
34
42
|
export default translations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -30,7 +30,15 @@ const translations = {
|
|
|
30
30
|
errors: {
|
|
31
31
|
title: 'Akifilter yüklenemedi',
|
|
32
32
|
description: 'Filtreler render edilirken beklenmeyen bir hata oluştu. Lütfen tekrar deneyin veya sayfayı yenileyin.',
|
|
33
|
-
retry: 'Tekrar dene'
|
|
33
|
+
retry: 'Tekrar dene',
|
|
34
|
+
storage: {
|
|
35
|
+
readVisibility: 'Akifilter: görünürlük durumu depodan okunamadı',
|
|
36
|
+
writeVisibility: 'Akifilter: görünürlük durumu kalıcı hale getirilemedi',
|
|
37
|
+
clearVisibility: 'Akifilter: görünürlük durumu temizlenemedi',
|
|
38
|
+
readValues: 'Akifilter: değerler depodan okunamadı',
|
|
39
|
+
writeValues: 'Akifilter: değerler kalıcı hale getirilemedi',
|
|
40
|
+
clearValues: 'Akifilter: kayıtlı değerler temizlenemedi'
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
};
|
|
36
44
|
exports.default = translations;
|
package/dist/cjs/styles.css
CHANGED
|
@@ -51,6 +51,15 @@
|
|
|
51
51
|
top: 1px;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
.akinon-filter__common-filters {
|
|
55
|
+
margin-top: 2rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.akinon-filter__common-filters-title {
|
|
59
|
+
color: var(--color-gray-500);
|
|
60
|
+
margin-bottom: 1rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
.akinon-filter__form-grid {
|
|
55
64
|
display: grid;
|
|
56
65
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
@@ -65,6 +74,27 @@
|
|
|
65
74
|
width: 100%;
|
|
66
75
|
}
|
|
67
76
|
|
|
77
|
+
.akinon-filter__section-fields {
|
|
78
|
+
margin-top: 2rem;
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: 1rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.akinon-filter__section-fields .akinon-collapse-header {
|
|
85
|
+
padding-bottom: 0 !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.akinon-filter__section-fields .akinon-collapse-header-text {
|
|
89
|
+
color: var(--color-gray-500);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.akinon-filter__section-fields .akinon-collapse-expand-icon .akinon-collapse-arrow {
|
|
93
|
+
font-size: 1rem !important;
|
|
94
|
+
color: var(--color-gray-500) !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
68
98
|
@media (max-width: 1024px) {
|
|
69
99
|
.akinon-filter__form-grid {
|
|
70
100
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { FieldValues } from '@akinon/akiform';
|
|
2
2
|
import type { AkifilterField, AkifilterSchema } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Flattens schema by extracting all nested fields from section fields.
|
|
5
|
+
* This is used for storage operations and form value management.
|
|
6
|
+
*/
|
|
7
|
+
export declare const flattenSchema: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>) => AkifilterSchema<TFieldValues>;
|
|
8
|
+
/**
|
|
9
|
+
* Separates section fields from regular fields.
|
|
10
|
+
*/
|
|
11
|
+
export declare const partitionSchema: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>) => {
|
|
12
|
+
regularFields: AkifilterSchema<TFieldValues>;
|
|
13
|
+
sectionFields: Array<AkifilterField<TFieldValues> & {
|
|
14
|
+
fields: AkifilterSchema<TFieldValues>;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
3
17
|
export declare const getDisplayLabel: <TFieldValues extends FieldValues = FieldValues>(field: AkifilterField<TFieldValues>) => string;
|
|
4
18
|
export declare const getFieldAriaLabel: <TFieldValues extends FieldValues = FieldValues>(field: AkifilterField<TFieldValues>) => string;
|
|
5
19
|
export declare const ensureSchemaOrder: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>, keys: string[]) => string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,GAAG,WAAW,EAC5E,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,MAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,MAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,EACrC,MAAM,MAAM,EAAE,KACb,MAAM,EAGR,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,OAAO,CAAC,YAAY,CAQtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,EACrC,SAAS,OAAO,CAAC,YAAY,CAAC,KAC7B,OAAO,CAAC,YAAY,CA+BtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,SAAS,WAAW,GAAG,WAAW,EAC1E,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,eAAe,CAAC,YAAY,CAW9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,GAAG,WAAW,EAC5E,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC;IACD,aAAa,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C,aAAa,EAAE,KAAK,CAClB,cAAc,CAAC,YAAY,CAAC,GAAG;QAC7B,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;KACvC,CACF,CAAC;CAwBH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,GAAG,WAAW,EAC5E,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,MAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,MAEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,EACrC,MAAM,MAAM,EAAE,KACb,MAAM,EAGR,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,OAAO,CAAC,YAAY,CAQtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,EACrC,SAAS,OAAO,CAAC,YAAY,CAAC,KAC7B,OAAO,CAAC,YAAY,CA+BtB,CAAC"}
|
package/dist/cjs/utils/schema.js
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normaliseValuesBySchema = exports.extractDefaultValues = exports.deriveDefaultVisibleKeys = exports.ensureSchemaOrder = exports.getFieldAriaLabel = exports.getDisplayLabel = void 0;
|
|
3
|
+
exports.normaliseValuesBySchema = exports.extractDefaultValues = exports.deriveDefaultVisibleKeys = exports.ensureSchemaOrder = exports.getFieldAriaLabel = exports.getDisplayLabel = exports.partitionSchema = exports.flattenSchema = void 0;
|
|
4
4
|
const akidate_1 = require("@akinon/akidate");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
|
+
/**
|
|
7
|
+
* Flattens schema by extracting all nested fields from section fields.
|
|
8
|
+
* This is used for storage operations and form value management.
|
|
9
|
+
*/
|
|
10
|
+
const flattenSchema = (schema) => {
|
|
11
|
+
return schema.reduce((acc, field) => {
|
|
12
|
+
if (field.type === 'section' && 'fields' in field) {
|
|
13
|
+
// Recursively flatten nested section fields
|
|
14
|
+
return [
|
|
15
|
+
...acc,
|
|
16
|
+
...(0, exports.flattenSchema)(field.fields)
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
return [...acc, field];
|
|
20
|
+
}, []);
|
|
21
|
+
};
|
|
22
|
+
exports.flattenSchema = flattenSchema;
|
|
23
|
+
/**
|
|
24
|
+
* Separates section fields from regular fields.
|
|
25
|
+
*/
|
|
26
|
+
const partitionSchema = (schema) => {
|
|
27
|
+
const regularFields = [];
|
|
28
|
+
const sectionFields = [];
|
|
29
|
+
schema.forEach(field => {
|
|
30
|
+
if (field.type === 'section') {
|
|
31
|
+
sectionFields.push(field);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
regularFields.push(field);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return { regularFields, sectionFields };
|
|
38
|
+
};
|
|
39
|
+
exports.partitionSchema = partitionSchema;
|
|
6
40
|
const getDisplayLabel = (field) => {
|
|
7
41
|
return field.label || field.placeholder || String(field.key);
|
|
8
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/utils/values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/utils/values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,kBAAkB,GAC7B,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,OAAO,cAAc,CAAC,YAAY,CAAC,GAAG,SAAS,EAC/C,OAAO,OAAO,KACb,OAkBF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,EACrC,SAAS,OAAO,CAAC,YAAY,CAAC,GAAG,WAAW,KAC3C,OAAO,CAAC,YAAY,CAkCtB,CAAC"}
|
package/dist/cjs/utils/values.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normaliseOutputValues = exports.shouldPersistValue = void 0;
|
|
4
4
|
const akidate_1 = require("@akinon/akidate");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
5
6
|
const shouldPersistValue = (field, value) => {
|
|
6
7
|
if (value === undefined || value === null) {
|
|
7
8
|
return false;
|
|
@@ -34,7 +35,10 @@ const normaliseOutputValues = (schema, values) => {
|
|
|
34
35
|
if (!normalised) {
|
|
35
36
|
return acc;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
// Format with time if showTime is enabled, otherwise date only
|
|
39
|
+
const hasShowTime = 'showTime' in field && field.showTime;
|
|
40
|
+
const format = hasShowTime ? constants_1.DATETIME_FORMAT : constants_1.DATE_FORMAT;
|
|
41
|
+
normalisedValue = akidate_1.akidate.formatIsoDate(normalised, format);
|
|
38
42
|
}
|
|
39
43
|
acc[key] =
|
|
40
44
|
normalisedValue;
|
|
@@ -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;
|
|
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;AA2B1B,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAC;AAY/D,KAAK,oBAAoB,GAAG,WAAW,CAAC;AA2BxC,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;AAirBF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAmBpC,CAAC"}
|