@akinon/akifilter 1.9.1 → 1.10.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.
Files changed (54) hide show
  1. package/README.md +24 -0
  2. package/dist/cjs/akifilter.d.ts +11 -0
  3. package/dist/cjs/akifilter.d.ts.map +1 -1
  4. package/dist/cjs/akifilter.js +5 -3
  5. package/dist/cjs/common/storage.d.ts +0 -1
  6. package/dist/cjs/common/storage.d.ts.map +1 -1
  7. package/dist/cjs/common/storage.js +1 -12
  8. package/dist/cjs/components/section-fieldset.d.ts +6 -1
  9. package/dist/cjs/components/section-fieldset.d.ts.map +1 -1
  10. package/dist/cjs/components/section-fieldset.js +18 -3
  11. package/dist/cjs/hooks/use-field-visibility.d.ts +7 -1
  12. package/dist/cjs/hooks/use-field-visibility.d.ts.map +1 -1
  13. package/dist/cjs/hooks/use-field-visibility.js +17 -9
  14. package/dist/cjs/hooks/use-visibility-cleanup.d.ts +10 -3
  15. package/dist/cjs/hooks/use-visibility-cleanup.d.ts.map +1 -1
  16. package/dist/cjs/hooks/use-visibility-cleanup.js +13 -9
  17. package/dist/cjs/i18n/translations/en.d.ts +0 -1
  18. package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
  19. package/dist/cjs/i18n/translations/en.js +0 -1
  20. package/dist/cjs/i18n/translations/tr.d.ts +0 -1
  21. package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
  22. package/dist/cjs/i18n/translations/tr.js +0 -1
  23. package/dist/cjs/types.d.ts +11 -3
  24. package/dist/cjs/types.d.ts.map +1 -1
  25. package/dist/cjs/utils/schema.d.ts +7 -1
  26. package/dist/cjs/utils/schema.d.ts.map +1 -1
  27. package/dist/cjs/utils/schema.js +34 -10
  28. package/dist/esm/akifilter.d.ts +11 -0
  29. package/dist/esm/akifilter.d.ts.map +1 -1
  30. package/dist/esm/akifilter.js +5 -3
  31. package/dist/esm/common/storage.d.ts +0 -1
  32. package/dist/esm/common/storage.d.ts.map +1 -1
  33. package/dist/esm/common/storage.js +0 -10
  34. package/dist/esm/components/section-fieldset.d.ts +6 -1
  35. package/dist/esm/components/section-fieldset.d.ts.map +1 -1
  36. package/dist/esm/components/section-fieldset.js +18 -3
  37. package/dist/esm/hooks/use-field-visibility.d.ts +7 -1
  38. package/dist/esm/hooks/use-field-visibility.d.ts.map +1 -1
  39. package/dist/esm/hooks/use-field-visibility.js +18 -10
  40. package/dist/esm/hooks/use-visibility-cleanup.d.ts +10 -3
  41. package/dist/esm/hooks/use-visibility-cleanup.d.ts.map +1 -1
  42. package/dist/esm/hooks/use-visibility-cleanup.js +13 -9
  43. package/dist/esm/i18n/translations/en.d.ts +0 -1
  44. package/dist/esm/i18n/translations/en.d.ts.map +1 -1
  45. package/dist/esm/i18n/translations/en.js +0 -1
  46. package/dist/esm/i18n/translations/tr.d.ts +0 -1
  47. package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
  48. package/dist/esm/i18n/translations/tr.js +0 -1
  49. package/dist/esm/types.d.ts +11 -3
  50. package/dist/esm/types.d.ts.map +1 -1
  51. package/dist/esm/utils/schema.d.ts +7 -1
  52. package/dist/esm/utils/schema.d.ts.map +1 -1
  53. package/dist/esm/utils/schema.js +32 -8
  54. package/package.json +17 -17
@@ -90,6 +90,17 @@ export type AkifilterProps<TFieldValues extends AkifilterFieldValues = Akifilter
90
90
  * The button only renders for sections that set `enableImportXls: true`.
91
91
  */
92
92
  onSectionImportXls?: (sectionKey: string, file: File) => void;
93
+ /**
94
+ * Notified whenever a section's visible field keys change, including on the
95
+ * first render. Receives the section's `key` and the keys of the fields it
96
+ * currently renders, so one handler can serve every section.
97
+ *
98
+ * For a `selectableFields` section this is the user's selection from the
99
+ * section's visibility modal; any other section renders all of its fields,
100
+ * so it reports every field key. Keep the handler's identity stable — a new
101
+ * function on every render re-notifies with an unchanged list.
102
+ */
103
+ onSectionVisibleFieldsChange?: (sectionKey: string, keys: Array<Path<TFieldValues>>) => void;
93
104
  };
94
105
  export declare const Akifilter: {
95
106
  <TFieldValues extends AkifilterFieldValues = FieldValues>(props: AkifilterProps<TFieldValues>): React.JSX.Element;
@@ -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;AAYzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAgBtC,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAYjB,KAAK,oBAAoB,GAAG,WAAW,CAAC;AAiLxC,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;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,eAAe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I,KAAK,IAAI,CAAC;IAC9D;;;;;;;;;OASG;IACH,4BAA4B,CAAC,EAAE,CAC7B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAC5B,IAAI,CAAC;CACX,CAAC;AAu9BF,eAAO,MAAM,SAAS;KACpB,YAAY,SAAS,oBAAoB,uBAElC,cAAc,CAAC,YAAY,CAAC;;CAoBpC,CAAC"}
@@ -131,7 +131,7 @@ const resolveClearedFieldValue = (field, defaultValue) => {
131
131
  return undefined;
132
132
  }
133
133
  };
134
- const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onValuesChange, onVisibleFieldsChange, onImportCsv, onImportXls, onClearAll, enableImportCsv, enableImportXls, filterActionsRef, externalAppliedFilters, onRemoveExternalFilter, filterButtons, onFilterButtonsChange, onSectionImportCsv, onSectionImportXls }) => {
134
+ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onValuesChange, onVisibleFieldsChange, onImportCsv, onImportXls, onClearAll, enableImportCsv, enableImportXls, filterActionsRef, externalAppliedFilters, onRemoveExternalFilter, filterButtons, onFilterButtonsChange, onSectionImportCsv, onSectionImportXls, onSectionVisibleFieldsChange }) => {
135
135
  // Separate regular fields from section fields
136
136
  const { regularFields, sectionFields } = React.useMemo(() => partitionSchema(filterSchema), [filterSchema]);
137
137
  const excludeSectionKeys = React.useMemo(() => deriveExcludeSectionKeys(sectionFields), [sectionFields]);
@@ -308,6 +308,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
308
308
  const { visibleKeys, setVisibleKeys, visibleFields, openModal, modalProps } = useFieldVisibility({
309
309
  fields: regularFields,
310
310
  storageKey,
311
+ initialValues: mergedDefaultValues,
311
312
  onVisibleKeysChange: handleVisibleKeysChange
312
313
  });
313
314
  const normalisedValues = React.useMemo(() => normaliseOutputValues(flattenedSchema, formValues), [flattenedSchema, formValues]);
@@ -556,6 +557,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
556
557
  useVisibilityCleanup({
557
558
  visibleKeys,
558
559
  regularFields,
560
+ initialValues: mergedDefaultValues,
559
561
  onRemove: handleRemoveFilter
560
562
  });
561
563
  const handleAppliedFilterRemove = React.useCallback((key) => {
@@ -610,7 +612,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
610
612
  case FIELD_TYPES.CHECKBOX:
611
613
  return React.createElement(Checkbox, { disabled: isDisabled }, field.label);
612
614
  case FIELD_TYPES.DATE:
613
- return (React.createElement(DatePicker, { placeholder: field.placeholder, showTime: field.showTime, suffixIcon: "calendar", suffixIconSize: "16px", "aria-label": ariaLabel, disabled: isDisabled }));
615
+ return (React.createElement(DatePicker, { placeholder: field.placeholder, size: "large", showTime: field.showTime, suffixIcon: "calendar", suffixIconSize: "16px", "aria-label": ariaLabel, disabled: isDisabled }));
614
616
  case FIELD_TYPES.TEXTAREA:
615
617
  return (React.createElement(InputTextArea, { placeholder: field.placeholder, autoSize: { minRows: 3, maxRows: 6 }, "aria-label": ariaLabel, disabled: isDisabled }));
616
618
  case FIELD_TYPES.FILE:
@@ -653,7 +655,7 @@ const AkifilterContent = ({ filterSchema, storageNamespace, defaultValues, onVal
653
655
  visibleFields.length === 0 && regularFields.length > 0 ? (React.createElement("div", { className: "akinon-filter__empty" }, i18n.t('form.noVisibleFields'))) : null),
654
656
  sectionFields.length > 0 && (React.createElement("div", { className: "akinon-filter__section-fields" }, sectionFields.map(section => (React.createElement(SectionFieldset, { key: String(section.key), section: section, storageKey: storageKey, renderFormField: renderFormField, onRemoveField: handleRemoveFilter, formValues: normalisedValues, onImportCsv: onSectionImportCsv &&
655
657
  (file => onSectionImportCsv(String(section.key), file)), onImportXls: onSectionImportXls &&
656
- (file => onSectionImportXls(String(section.key), file)) }))))))),
658
+ (file => onSectionImportXls(String(section.key), file)), onVisibleFieldsChange: onSectionVisibleFieldsChange }))))))),
657
659
  React.createElement(VisibilityModal, Object.assign({}, modalProps)))));
658
660
  };
659
661
  const AkifilterEmptyState = () => {
@@ -4,7 +4,6 @@ export declare const buildStorageKey: <TFieldValues extends FieldValues>(schema:
4
4
  export declare const readVisibleKeys: <TFieldValues extends FieldValues>(schema: AkifilterField<TFieldValues>[], storageKey: string) => string[] | null;
5
5
  export declare const writeVisibleKeys: (storageKey: string, keys: string[]) => void;
6
6
  export declare const buildSectionVisibilityKey: (storageKey: string, sectionKey: string | number) => string;
7
- export declare const clearVisibleKeys: (storageKey: string) => void;
8
7
  export declare const readStoredValues: <TFieldValues extends FieldValues>(schema: AkifilterField<TFieldValues>[], storageKey: string) => Partial<TFieldValues> | null;
9
8
  export declare const writeStoredValues: <TFieldValues extends FieldValues>(storageKey: string, values: Partial<TFieldValues>) => void;
10
9
  export declare const clearStoredValues: (storageKey: string) => void;
@@ -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;AAInD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA4B/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,yBAAyB,GACpC,YAAY,MAAM,EAClB,YAAY,MAAM,GAAG,MAAM,KAC1B,MAAuD,CAAC;AAE3D,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,IAQrD,CAAC;AA0D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AClB,YAAY,MAAM,GAAG,MAAM,KAC1B,MAAuD,CAAC;AA0D3D,eAAO,MAAM,gBAAgB,GAAI,YAAY,SAAS,WAAW,EAC/D,QAAQ,cAAc,CAAC,YAAY,CAAC,EAAE,EACtC,YAAY,MAAM,KACjB,OAAO,CAAC,YAAY,CAAC,GAAG,IAqC1B,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;AAKF,eAAO,MAAM,sBAAsB,GACjC,YAAY,MAAM,KACjB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,IAwB3B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,YAAY,MAAM,EAClB,QAAQ,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,KAC7B,IAcF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,YAAY,MAAM,KAAG,IAQ5D,CAAC"}
@@ -58,16 +58,6 @@ export const writeVisibleKeys = (storageKey, keys) => {
58
58
  }
59
59
  };
60
60
  export const buildSectionVisibilityKey = (storageKey, sectionKey) => `${storageKey}:section:${String(sectionKey)}`;
61
- export const clearVisibleKeys = (storageKey) => {
62
- if (!isBrowser)
63
- return;
64
- try {
65
- window.localStorage.removeItem(storageKey);
66
- }
67
- catch (error) {
68
- console.warn(i18n.t('errors.storage.clearVisibility'), error);
69
- }
70
- };
71
61
  const buildValuesStorageKey = (storageKey) => `${storageKey}${VALUES_SUFFIX}`;
72
62
  /**
73
63
  * Guards a persisted value against schema drift.
@@ -1,4 +1,4 @@
1
- import type { FieldValues } from '@akinon/akiform';
1
+ import type { FieldValues, Path } from '@akinon/akiform';
2
2
  import React from 'react';
3
3
  import type { AkifilterField, AkifilterSectionField } from '../types';
4
4
  type SectionImportHandlers = {
@@ -30,6 +30,11 @@ type SectionFieldsetProps<TFieldValues extends FieldValues = FieldValues> = Sect
30
30
  * Current normalised form values, needed to resolve dynamic visibility.
31
31
  */
32
32
  formValues: Partial<TFieldValues> | undefined;
33
+ /**
34
+ * Notified with the section's key and the keys of the fields it currently
35
+ * renders, on mount and whenever that list changes.
36
+ */
37
+ onVisibleFieldsChange?: (sectionKey: string, keys: Array<Path<TFieldValues>>) => void;
33
38
  };
34
39
  /**
35
40
  * Renders a single section field. Sections flagged with `selectableFields`
@@ -1 +1 @@
1
- {"version":3,"file":"section-fieldset.d.ts","sourceRoot":"","sources":["../../../src/components/section-fieldset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA+CtE,KAAK,qBAAqB,GAAG;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC,CAAC;AA8JF,KAAK,oBAAoB,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,IACtE,qBAAqB,GAAG;IACtB,OAAO,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAC7C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1E;;;OAGG;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;CAC/C,CAAC;AAiHJ;;;;;;GAMG;AACH,eAAO,MAA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C,YAAY,CAAC,sBAO1C,CAAC"}
@@ -2,6 +2,7 @@ import { Icon } from '@akinon/icons';
2
2
  import { Button } from '@akinon/ui-button';
3
3
  import { Collapse } from '@akinon/ui-collapse';
4
4
  import { Title } from '@akinon/ui-typography';
5
+ import { isEqual } from 'lodash-es';
5
6
  import React from 'react';
6
7
  import { buildSectionVisibilityKey } from '../common/storage';
7
8
  import { CSV_ACCEPT, XLS_ACCEPT } from '../constants';
@@ -108,11 +109,16 @@ const SectionActionsCollapse = ({ sectionKey, label, defaultExpanded, actions, i
108
109
  * mirroring the top-level filter field-selection behaviour. Import buttons are
109
110
  * rendered alongside the funnel when the section opts into them.
110
111
  */
111
- const SelectableSectionFieldset = ({ section, storageKey, renderFormField, onRemoveField, formValues, onImportCsv, onImportXls }) => {
112
+ const SelectableSectionFieldset = ({ section, storageKey, renderFormField, onRemoveField, formValues, onImportCsv, onImportXls, onVisibleFieldsChange }) => {
112
113
  const sectionStorageKey = React.useMemo(() => buildSectionVisibilityKey(storageKey, section.key), [storageKey, section.key]);
114
+ const handleVisibleKeysChange = React.useCallback((keys) => {
115
+ onVisibleFieldsChange === null || onVisibleFieldsChange === void 0 ? void 0 : onVisibleFieldsChange(String(section.key), keys);
116
+ }, [onVisibleFieldsChange, section.key]);
113
117
  const { visibleKeys, setVisibleKeys, visibleFields, openModal, modalProps } = useFieldVisibility({
114
118
  fields: section.fields,
115
- storageKey: sectionStorageKey
119
+ storageKey: sectionStorageKey,
120
+ initialValues: formValues,
121
+ onVisibleKeysChange: handleVisibleKeysChange
116
122
  });
117
123
  useDynamicVisibility({
118
124
  regularFields: section.fields,
@@ -122,6 +128,7 @@ const SelectableSectionFieldset = ({ section, storageKey, renderFormField, onRem
122
128
  useVisibilityCleanup({
123
129
  visibleKeys,
124
130
  regularFields: section.fields,
131
+ initialValues: formValues,
125
132
  onRemove: onRemoveField
126
133
  });
127
134
  const actions = resolveSectionHeaderActions({
@@ -138,7 +145,15 @@ const SelectableSectionFieldset = ({ section, storageKey, renderFormField, onRem
138
145
  * A section that always renders every one of its fields. Falls back to the
139
146
  * plain collapse markup unless the header needs action buttons (e.g. import).
140
147
  */
141
- const PlainSectionFieldset = ({ section, renderFormField, onImportCsv, onImportXls }) => {
148
+ const PlainSectionFieldset = ({ section, renderFormField, onImportCsv, onImportXls, onVisibleFieldsChange }) => {
149
+ const [fieldKeys, setFieldKeys] = React.useState(() => section.fields.map(field => String(field.key)));
150
+ React.useEffect(() => {
151
+ const nextFieldKeys = section.fields.map(field => String(field.key));
152
+ setFieldKeys(previous => isEqual(previous, nextFieldKeys) ? previous : nextFieldKeys);
153
+ }, [section.fields]);
154
+ React.useEffect(() => {
155
+ onVisibleFieldsChange === null || onVisibleFieldsChange === void 0 ? void 0 : onVisibleFieldsChange(String(section.key), fieldKeys);
156
+ }, [fieldKeys, onVisibleFieldsChange, section.key]);
142
157
  const actions = resolveSectionHeaderActions({
143
158
  section,
144
159
  onImportCsv,
@@ -12,6 +12,12 @@ type UseFieldVisibilityParams<TFieldValues extends FieldValues> = {
12
12
  * pass distinct keys per group so selections never collide.
13
13
  */
14
14
  storageKey: string;
15
+ /**
16
+ * Form values as of the first render. A `config.visible` function is resolved
17
+ * against these, so a field whose visibility depends on a restored value is
18
+ * visible from the very first render instead of appearing one commit later.
19
+ */
20
+ initialValues?: Partial<TFieldValues>;
15
21
  /**
16
22
  * Notified whenever the resolved visible keys change.
17
23
  */
@@ -22,7 +28,7 @@ type UseFieldVisibilityParams<TFieldValues extends FieldValues> = {
22
28
  * a single group of fields. Used both for the top-level filters and for each
23
29
  * selectable section so the two share one implementation.
24
30
  */
25
- export declare const useFieldVisibility: <TFieldValues extends FieldValues = FieldValues>({ fields, storageKey, onVisibleKeysChange }: UseFieldVisibilityParams<TFieldValues>) => {
31
+ export declare const useFieldVisibility: <TFieldValues extends FieldValues = FieldValues>({ fields, storageKey, initialValues, onVisibleKeysChange }: UseFieldVisibilityParams<TFieldValues>) => {
26
32
  visibleKeys: string[];
27
33
  setVisibleKeys: React.Dispatch<React.SetStateAction<string[]>>;
28
34
  visibleFields: import("../types").AkifilterField<TFieldValues>[];
@@ -1 +1 @@
1
- {"version":3,"file":"use-field-visibility.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-field-visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAOhD,KAAK,wBAAwB,CAAC,YAAY,SAAS,WAAW,IAAI;IAChE;;;OAGG;IACH,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACtC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,6CAIC,wBAAwB,CAAC,YAAY,CAAC;;;;;;;;;;;;oCA0HP,MAAM;kCA3D9B,MAAM;mCAgEiB,MAAM,YAAY,MAAM;;;;CA6BxD,CAAC"}
1
+ {"version":3,"file":"use-field-visibility.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-field-visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAQhD,KAAK,wBAAwB,CAAC,YAAY,SAAS,WAAW,IAAI;IAChE;;;OAGG;IACH,MAAM,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACtC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,4DAKC,wBAAwB,CAAC,YAAY,CAAC;;;;;;;;;;;;oCAsIP,MAAM;kCA7D9B,MAAM;mCAkEiB,MAAM,YAAY,MAAM;;;;CA6BxD,CAAC"}
@@ -1,32 +1,32 @@
1
+ import { isEqual } from 'lodash-es';
1
2
  import React from 'react';
2
3
  import { readVisibleKeys, writeVisibleKeys } from '../common/storage';
3
4
  import { DEFAULT_MODAL_PAGE_SIZE } from '../constants';
4
- import { deriveDefaultVisibleKeys, ensureSchemaOrder, resolveFieldVisibility } from '../utils/schema';
5
+ import { deriveDefaultVisibleKeys, ensureSchemaOrder, hasDynamicVisibility, resolveFieldVisibility } from '../utils/schema';
5
6
  /**
6
7
  * Encapsulates the visible-field selection and its accompanying modal state for
7
8
  * a single group of fields. Used both for the top-level filters and for each
8
9
  * selectable section so the two share one implementation.
9
10
  */
10
- export const useFieldVisibility = ({ fields, storageKey, onVisibleKeysChange }) => {
11
+ export const useFieldVisibility = ({ fields, storageKey, initialValues, onVisibleKeysChange }) => {
12
+ const initialValuesRef = React.useRef(initialValues);
11
13
  const [isModalOpen, setIsModalOpen] = React.useState(false);
12
14
  const [searchTerm, setSearchTerm] = React.useState('');
13
15
  const [modalPage, setModalPage] = React.useState(1);
14
16
  const [modalPageSize, setModalPageSize] = React.useState(DEFAULT_MODAL_PAGE_SIZE);
15
17
  const resolveInitialVisibleKeys = React.useCallback(() => {
16
18
  const storedKeys = readVisibleKeys(fields, storageKey);
17
- const defaultKeys = deriveDefaultVisibleKeys(fields);
18
19
  const baseKeys = storedKeys && storedKeys.length > 0
19
20
  ? ensureSchemaOrder(fields, storedKeys)
20
- : defaultKeys;
21
+ : deriveDefaultVisibleKeys(fields);
21
22
  return fields.reduce((acc, field) => {
22
23
  const key = String(field.key);
23
- const explicitVisibility = resolveFieldVisibility(field);
24
- if (explicitVisibility !== undefined) {
25
- if (explicitVisibility)
24
+ if (hasDynamicVisibility(field)) {
25
+ const visibility = resolveFieldVisibility(field, initialValuesRef.current);
26
+ if (visibility)
26
27
  acc.push(key);
27
28
  return acc;
28
29
  }
29
- // No explicit boolean visibility, use stored/default
30
30
  if (baseKeys.includes(key)) {
31
31
  acc.push(key);
32
32
  }
@@ -38,13 +38,20 @@ export const useFieldVisibility = ({ fields, storageKey, onVisibleKeysChange })
38
38
  setVisibleKeys(previous => {
39
39
  const ordered = ensureSchemaOrder(fields, previous);
40
40
  if (ordered.length) {
41
- return ordered;
41
+ return isEqual(ordered, previous) ? previous : ordered;
42
42
  }
43
43
  return resolveInitialVisibleKeys();
44
44
  });
45
45
  }, [fields, resolveInitialVisibleKeys]);
46
+ // Only a real toggle is persisted. Writing the derived set on mount would
47
+ // make every user look like they had made a choice, and the storage key is
48
+ // hashed from the field signature alone — so a later `config.visible` change
49
+ // would never reach anyone who had simply rendered the filter once.
50
+ const hasUserSelectionRef = React.useRef(false);
46
51
  React.useEffect(() => {
47
- writeVisibleKeys(storageKey, visibleKeys);
52
+ if (hasUserSelectionRef.current) {
53
+ writeVisibleKeys(storageKey, visibleKeys);
54
+ }
48
55
  onVisibleKeysChange === null || onVisibleKeysChange === void 0 ? void 0 : onVisibleKeysChange(visibleKeys);
49
56
  }, [visibleKeys, onVisibleKeysChange, storageKey]);
50
57
  const openModal = React.useCallback(() => {
@@ -56,6 +63,7 @@ export const useFieldVisibility = ({ fields, storageKey, onVisibleKeysChange })
56
63
  setIsModalOpen(false);
57
64
  }, []);
58
65
  const handleToggleVisibility = React.useCallback((key) => {
66
+ hasUserSelectionRef.current = true;
59
67
  setVisibleKeys(prev => {
60
68
  const exists = prev.includes(key);
61
69
  if (exists && prev.length === 1) {
@@ -2,12 +2,19 @@ import type { FieldValues } from '@akinon/akiform';
2
2
  import type { AkifilterSchema } from '../types';
3
3
  /**
4
4
  * Cleans up form values when fields become hidden.
5
- * On first render, clears fields explicitly marked as invisible.
6
- * On subsequent renders, clears fields that were removed from visibleKeys.
5
+ * On first render, clears fields resolving to `visible: false` that the user
6
+ * has not turned back on. On subsequent renders, clears fields that were
7
+ * removed from visibleKeys.
7
8
  */
8
- export declare const useVisibilityCleanup: <TFieldValues extends FieldValues = FieldValues>({ visibleKeys, regularFields, onRemove }: {
9
+ export declare const useVisibilityCleanup: <TFieldValues extends FieldValues = FieldValues>({ visibleKeys, regularFields, initialValues, onRemove }: {
9
10
  visibleKeys: string[];
10
11
  regularFields: AkifilterSchema<TFieldValues>;
12
+ /**
13
+ * Form values as of the first render, so a `config.visible` function is
14
+ * resolved against restored values rather than an empty object — otherwise
15
+ * the value that makes the field visible is the one this hook deletes.
16
+ */
17
+ initialValues?: Partial<TFieldValues>;
11
18
  onRemove: (key: string) => void;
12
19
  }) => void;
13
20
  //# sourceMappingURL=use-visibility-cleanup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-visibility-cleanup.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-visibility-cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+BhD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,0CAIC;IACD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,SAcA,CAAC"}
1
+ {"version":3,"file":"use-visibility-cleanup.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-visibility-cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAoChD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,yDAKC;IACD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,SAgBA,CAAC"}
@@ -1,34 +1,38 @@
1
1
  import { isEqual } from 'lodash-es';
2
2
  import { useEffect, useRef } from 'react';
3
3
  import { resolveFieldVisibility } from '../utils/schema';
4
- const getInitialKeysToClean = (fields) => fields
5
- .filter(field => resolveFieldVisibility(field) === false)
6
- .map(field => String(field.key));
4
+ const getInitialKeysToClean = (fields, visibleKeys, formValues) => fields
5
+ .filter(field => resolveFieldVisibility(field, formValues) === false)
6
+ .map(field => String(field.key))
7
+ .filter(key => !visibleKeys.includes(key));
7
8
  const getRemovedKeys = (prev, current) => prev.filter(key => !current.includes(key));
8
9
  const cleanupKeys = (keys, onRemove) => {
9
10
  keys.forEach(key => onRemove(key));
10
11
  };
11
- const resolveKeysToClean = ({ prev, current, fields }) => {
12
+ const resolveKeysToClean = ({ prev, current, fields, formValues }) => {
12
13
  if (prev === null)
13
- return getInitialKeysToClean(fields);
14
+ return getInitialKeysToClean(fields, current, formValues);
14
15
  if (isEqual(prev, current))
15
16
  return [];
16
17
  return getRemovedKeys(prev, current);
17
18
  };
18
19
  /**
19
20
  * Cleans up form values when fields become hidden.
20
- * On first render, clears fields explicitly marked as invisible.
21
- * On subsequent renders, clears fields that were removed from visibleKeys.
21
+ * On first render, clears fields resolving to `visible: false` that the user
22
+ * has not turned back on. On subsequent renders, clears fields that were
23
+ * removed from visibleKeys.
22
24
  */
23
- export const useVisibilityCleanup = ({ visibleKeys, regularFields, onRemove }) => {
25
+ export const useVisibilityCleanup = ({ visibleKeys, regularFields, initialValues, onRemove }) => {
24
26
  const previousVisibleKeysRef = useRef(null);
27
+ const initialValuesRef = useRef(initialValues);
25
28
  useEffect(() => {
26
29
  const prev = previousVisibleKeysRef.current;
27
30
  previousVisibleKeysRef.current = visibleKeys;
28
31
  const keysToClean = resolveKeysToClean({
29
32
  prev,
30
33
  current: visibleKeys,
31
- fields: regularFields
34
+ fields: regularFields,
35
+ formValues: initialValuesRef.current
32
36
  });
33
37
  cleanupKeys(keysToClean, onRemove);
34
38
  }, [visibleKeys, onRemove, regularFields]);
@@ -40,7 +40,6 @@ declare const translations: {
40
40
  readonly storage: {
41
41
  readonly readVisibility: "Akifilter: unable to read visibility state from storage";
42
42
  readonly writeVisibility: "Akifilter: unable to persist visibility state";
43
- readonly clearVisibility: "Akifilter: unable to clear visibility state";
44
43
  readonly readValues: "Akifilter: unable to read values from storage";
45
44
  readonly writeValues: "Akifilter: unable to persist values";
46
45
  readonly clearValues: "Akifilter: unable to clear stored values";
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDR,CAAC;AAEX,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -40,7 +40,6 @@ const translations = {
40
40
  storage: {
41
41
  readVisibility: 'Akifilter: unable to read visibility state from storage',
42
42
  writeVisibility: 'Akifilter: unable to persist visibility state',
43
- clearVisibility: 'Akifilter: unable to clear visibility state',
44
43
  readValues: 'Akifilter: unable to read values from storage',
45
44
  writeValues: 'Akifilter: unable to persist values',
46
45
  clearValues: 'Akifilter: unable to clear stored values',
@@ -40,7 +40,6 @@ declare const translations: {
40
40
  readonly storage: {
41
41
  readonly readVisibility: "Akifilter: görünürlük durumu depodan okunamadı";
42
42
  readonly writeVisibility: "Akifilter: görünürlük durumu kalıcı hale getirilemedi";
43
- readonly clearVisibility: "Akifilter: görünürlük durumu temizlenemedi";
44
43
  readonly readValues: "Akifilter: değerler depodan okunamadı";
45
44
  readonly writeValues: "Akifilter: değerler kalıcı hale getirilemedi";
46
45
  readonly clearValues: "Akifilter: kayıtlı değerler temizlenemedi";
@@ -1 +1 @@
1
- {"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDR,CAAC;AAEX,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -40,7 +40,6 @@ const translations = {
40
40
  storage: {
41
41
  readVisibility: 'Akifilter: görünürlük durumu depodan okunamadı',
42
42
  writeVisibility: 'Akifilter: görünürlük durumu kalıcı hale getirilemedi',
43
- clearVisibility: 'Akifilter: görünürlük durumu temizlenemedi',
44
43
  readValues: 'Akifilter: değerler depodan okunamadı',
45
44
  writeValues: 'Akifilter: değerler kalıcı hale getirilemedi',
46
45
  clearValues: 'Akifilter: kayıtlı değerler temizlenemedi',
@@ -9,7 +9,15 @@ export interface AkifilterFieldConfig<TFieldValues extends FieldValues = FieldVa
9
9
  disabled?: boolean | ((formValues: TFieldValues) => boolean);
10
10
  /**
11
11
  * Controls whether the field is visible.
12
- * Can be a boolean or a function that receives form values and returns a boolean.
12
+ *
13
+ * A boolean seeds the first render only: it decides whether the field is part
14
+ * of the default visible set, and from then on the user's selection in the
15
+ * "Select visible filters" modal wins and is restored on every later mount.
16
+ *
17
+ * A function is dynamic and stays authoritative: it is re-evaluated on every
18
+ * form value change and receives the field's current visibility. A constant
19
+ * function (`() => true`) is therefore how a field opts out of the picker
20
+ * altogether.
13
21
  */
14
22
  visible?: boolean | ((formValues: TFieldValues, currentVisible?: boolean) => boolean);
15
23
  }
@@ -106,14 +114,14 @@ type AkifilterFieldExtras<TFieldValues extends FieldValues = FieldValues> = {
106
114
  /**
107
115
  * Overrides `label` for this field's applied-filter chip only.
108
116
  *
109
- * The form input and the "select visible filters" modal keep using `label`.
117
+ * The form input and the "Select visible filters" modal keep using `label`.
110
118
  * Use this when the chip needs a shorter or more explicit name than the form
111
119
  * does (e.g. `label: 'Created At'` next to a date range, `appliedLabel:
112
120
  * 'Order date'` in the chip).
113
121
  */
114
122
  appliedLabel?: string;
115
123
  /**
116
- * Overrides `label` for this field's row in the "select visible filters"
124
+ * Overrides `label` for this field's row in the "Select visible filters"
117
125
  * modal only. Also what the modal's search box matches against.
118
126
  *
119
127
  * The form input and the applied-filter chip keep using `label`. Use this
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,oBAAoB,CACnC,YAAY,SAAS,WAAW,GAAG,WAAW;IAE9C;;;OAGG;IACH,QAAQ,CAAC,EAA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ACvB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;CAC/C;AAcD,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,eAAe;QACvB,uCAAuC;QACvC,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;QAC9C,0CAA0C;QAC1C,eAAe,CAAC,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACpD,uCAAuC;QACvC,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;QAC9C,8CAA8C;QAC9C,mBAAmB,CAAC,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;QAC5D,0CAA0C;QAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,0CAA0C;QAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;CACF"}
@@ -30,8 +30,14 @@ export declare const ensureSchemaOrder: <TFieldValues extends FieldValues = Fiel
30
30
  * Resolves the visibility of a field.
31
31
  */
32
32
  export declare const resolveFieldVisibility: <TFieldValues extends FieldValues = FieldValues>(field: AkifilterField<TFieldValues>, formValues?: TFieldValues, currentVisible?: boolean) => boolean | undefined;
33
+ export declare const hasDynamicVisibility: <TFieldValues extends FieldValues>(field: AkifilterField<TFieldValues>) => boolean;
34
+ /**
35
+ * The visible set of a first render: the fields statically marked
36
+ * `config.visible: true` if the schema marks any, otherwise the first
37
+ * `DEFAULT_VISIBLE_COUNT` fields. Fields with a dynamic `config.visible` take
38
+ * no part in it.
39
+ */
33
40
  export declare const deriveDefaultVisibleKeys: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>) => string[];
34
41
  export declare const extractDefaultValues: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>) => Partial<TFieldValues>;
35
- export declare const hasDynamicVisibility: <TFieldValues extends FieldValues>(field: AkifilterField<TFieldValues>) => boolean;
36
42
  export declare const normaliseValuesBySchema: <TFieldValues extends FieldValues = FieldValues>(schema: AkifilterSchema<TFieldValues>, values?: Partial<TFieldValues>) => Partial<TFieldValues>;
37
43
  //# sourceMappingURL=schema.d.ts.map
@@ -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;AAInD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAElB;;;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,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC;CAc3D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,eAAe,KAAK,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,KACxD,GAAG,CAAC,MAAM,CAKV,CAAC;AAEJ,eAAO,MAAM,eAAe,GAAI,YAAY,SAAS,WAAW,GAAG,WAAW,EAC5E,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,MAEF,CAAC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AAG,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;AAkBF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,OAAO,cAAc,CAAC,YAAY,CAAC,EACnC,aAAa,YAAY,EACzB,iBAAiB,OAAO,KACvB,OAAO,GAAG,SAC8D,CAAC;AAE5E,eAAO,MAAM,oBAAoB,GAAI,YAAY,SAAS,WAAW,EACnE,OAAO,cAAc,CAAC,YAAY,CAAC,KAClC,OAA4C,CAAC;AAsChD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,SAAS,WAAW,GAAG,WAAW,EAE9C,QAAQ,eAAe,CAAC,YAAY,CAAC,KACpC,MAAM,EAMR,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,CA0CtB,CAAC"}
@@ -67,14 +67,39 @@ const resolveVisibilityValue = (value, formValues, currentVisible) => {
67
67
  * Resolves the visibility of a field.
68
68
  */
69
69
  export const resolveFieldVisibility = (field, formValues, currentVisible) => { var _a; return resolveVisibilityValue((_a = field.config) === null || _a === void 0 ? void 0 : _a.visible, formValues, currentVisible); };
70
+ export const hasDynamicVisibility = (field) => { var _a; return isFunction((_a = field.config) === null || _a === void 0 ? void 0 : _a.visible); };
71
+ /*
72
+ * Both helpers below skip fields with a dynamic `config.visible`. Such a field
73
+ * declares nothing about the default set: `useFieldVisibility` resolves it from
74
+ * its own function and never consults the default set for it. Resolving the
75
+ * function here would only mean asking it the wrong question — its answer is
76
+ * "am I visible for these values", not "am I part of the default set" — and a
77
+ * `() => true` field would silently switch the whole schema to the explicit
78
+ * branch, dropping the fallback for every other field.
79
+ */
80
+ const explicitVisibleKeys = (schema) => schema
81
+ .filter(field => !hasDynamicVisibility(field) && resolveFieldVisibility(field) === true)
82
+ .map(field => String(field.key));
83
+ /**
84
+ * The first `DEFAULT_VISIBLE_COUNT` fields, minus the ones asking to be hidden.
85
+ * `config.visible: false` never reaches the picker's initial selection, so the
86
+ * fallback has to drop those keys itself.
87
+ */
88
+ const fallbackVisibleKeys = (schema) => schema
89
+ .slice(0, DEFAULT_VISIBLE_COUNT)
90
+ .filter(field => !hasDynamicVisibility(field) && resolveFieldVisibility(field) !== false)
91
+ .map(field => String(field.key));
92
+ /**
93
+ * The visible set of a first render: the fields statically marked
94
+ * `config.visible: true` if the schema marks any, otherwise the first
95
+ * `DEFAULT_VISIBLE_COUNT` fields. Fields with a dynamic `config.visible` take
96
+ * no part in it.
97
+ */
70
98
  export const deriveDefaultVisibleKeys = (schema) => {
71
- const explicitKeys = schema
72
- .filter(field => resolveFieldVisibility(field) === true)
73
- .map(field => String(field.key));
74
- if (explicitKeys.length > 0) {
75
- return ensureSchemaOrder(schema, explicitKeys);
76
- }
77
- return schema.slice(0, DEFAULT_VISIBLE_COUNT).map(field => String(field.key));
99
+ const explicitKeys = explicitVisibleKeys(schema);
100
+ return explicitKeys.length > 0
101
+ ? ensureSchemaOrder(schema, explicitKeys)
102
+ : fallbackVisibleKeys(schema);
78
103
  };
79
104
  export const extractDefaultValues = (schema) => {
80
105
  return schema.reduce((acc, field) => {
@@ -85,7 +110,6 @@ export const extractDefaultValues = (schema) => {
85
110
  return acc;
86
111
  }, {});
87
112
  };
88
- export const hasDynamicVisibility = (field) => { var _a; return isFunction((_a = field.config) === null || _a === void 0 ? void 0 : _a.visible); };
89
113
  export const normaliseValuesBySchema = (schema, values) => {
90
114
  if (!values) {
91
115
  return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/akifilter",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "private": false,
5
5
  "description": "Akifilter is a filtering library for Akinon frontend applications.",
6
6
  "type": "module",
@@ -15,21 +15,21 @@
15
15
  "lodash-es": "^4.17.21",
16
16
  "@akinon/akiform": "1.1.9",
17
17
  "@akinon/akidate": "1.2.7",
18
- "@akinon/akilocale": "1.2.8",
19
18
  "@akinon/icons": "1.5.0",
20
- "@akinon/ui-button": "1.5.5",
21
- "@akinon/ui-card": "1.2.10",
22
- "@akinon/ui-checkbox": "1.4.10",
19
+ "@akinon/akilocale": "1.2.8",
20
+ "@akinon/ui-button": "1.5.6",
21
+ "@akinon/ui-card": "1.2.11",
22
+ "@akinon/ui-checkbox": "1.4.11",
23
23
  "@akinon/ui-collapse": "1.4.8",
24
- "@akinon/ui-date-picker": "1.5.5",
25
- "@akinon/ui-input": "1.2.10",
26
- "@akinon/ui-input-number": "1.4.10",
27
- "@akinon/ui-modal": "1.2.11",
28
- "@akinon/ui-pagination": "1.4.16",
29
- "@akinon/ui-select": "1.4.16",
30
- "@akinon/ui-space": "1.4.10",
24
+ "@akinon/ui-date-picker": "1.5.6",
25
+ "@akinon/ui-input": "1.2.11",
26
+ "@akinon/ui-input-number": "1.4.11",
27
+ "@akinon/ui-modal": "1.2.12",
28
+ "@akinon/ui-pagination": "1.4.17",
29
+ "@akinon/ui-select": "1.4.17",
30
+ "@akinon/ui-space": "1.4.11",
31
31
  "@akinon/ui-typography": "1.2.7",
32
- "@akinon/ui-upload": "1.6.2"
32
+ "@akinon/ui-upload": "1.6.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/lodash-es": "^4.17.12",
@@ -37,11 +37,11 @@
37
37
  "copyfiles": "^2.4.1",
38
38
  "rimraf": "^5.0.5",
39
39
  "typescript": "*",
40
- "@akinon/akiform-builder": "1.8.1",
40
+ "@akinon/akiform-builder": "1.8.2",
41
41
  "@akinon/typescript-config": "1.1.8",
42
- "@akinon/utils": "1.2.11",
43
- "@akinon/ui-theme": "1.3.1",
44
- "@akinon/vitest-config": "1.1.8"
42
+ "@akinon/ui-theme": "1.3.2",
43
+ "@akinon/vitest-config": "1.1.8",
44
+ "@akinon/utils": "1.2.12"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "^18 || ^19",