/* eslint-disable @typescript-eslint/no-explicit-any */ import { ToolbarOptions } from "../../../type"; /** * The custom-view field table: which parts of the toolbar model participate in a * saved view, and which property of each carries the applicable value. * * This table is the contract between this package and the Grid — the Grid * contributes its `localSearch`/`pagination`/`sort` entries through * `relativeWidgetFilterFields`. It was copy-pasted verbatim into * filterCustomViewData, hasUnsavedChanges and replaceCustomViewData, so the * save/compare/restore triple could drift apart silently. One definition keeps * them provably consistent. * * `data` is whichever model the caller holds (`uiElementGroupData` or the * current data) — only its `relativeWidgetFilterFields` is read here. */ export const getCustomViewFields = ( data: Record, toolBarOptions: ToolbarOptions, ): Array> => [ ...(data.relativeWidgetFilterFields ?? []), { field: "globalSearch", enableCustomView: toolBarOptions.globalSearch.enableCustomView, applicableValueProperty: "appliedQuery", }, { field: "advancedSearch", enableCustomView: toolBarOptions.advancedSearch.enableCustomView, applicableValueProperty: "appliedQuery", }, { field: "quickFilter", enableCustomView: toolBarOptions.quickFilter.enableCustomView, applicableValueProperty: "appliedQuery", }, { field: "groupedBy", enableCustomView: toolBarOptions.groupBy.enableCustomView, applicableValueProperty: "appliedGroups", }, { field: "setting", enableCustomView: toolBarOptions.setting.enableCustomView, applicableValueProperty: null, }, ]; export default getCustomViewFields;