import type { ComponentType } from 'react'; import { TaskState } from '@wix/bex-core'; import type { FieldsSource, CustomFieldOrigin, Field, Schema, WixPatternsErrorCode } from '@wix/bex-core'; import type { Column } from '../model'; import type { ToolbarCollectionState } from './ToolbarCollectionState'; import { ColumnOverridesContext } from './buildFieldColumns'; import { type FieldFilterConfig } from './buildFieldFilters'; import type { FilterElement, CollectionToolbarFiltersProps } from '../components/CollectionToolbarFilters'; import type { MoreActionItemFactory } from '../components/MoreActions/MoreActionsBase'; import { CustomFieldsPanelState, type FieldActionsMenuBuilder } from './CustomFields/CustomFieldsPanelState'; import type { FieldActionHandlersConfig } from '../components/FieldActions'; import type { CustomColumnsBaseProps } from '../components/CustomColumns/CustomColumns'; /** Builds the raw field-management for one field (handlers + registry metadata). */ type FieldActionHandlersBuilder = (args: { fieldId: string; origin: CustomFieldOrigin; location: string; }) => FieldActionHandlersConfig | null; /** * Components the source attaches at construction time so the table chunk can * render them via `source.components.X` instead of statically importing them. * Each source's rendering file (dataExtensionRendering / schemaRendering) is * the only place these are imported — those files are reachable only from the * source's feature module, so the components ship in that chunk, not the * table chunk. */ export interface FieldsSourceComponents { FieldManagementModals: ComponentType<{ source: CollectionFieldsSourceState; }>; CustomColumns: ComponentType; CollectionToolbarFilters: ComponentType; } /** * The source-specific behavior a collection supplies on top of its FieldsSource * (data) — column tweaks, filter behavior, the manage-fields panel, page actions, * field actions, and the field-management modal states. A source builds one of * these (dataExtensionRendering / schemaRendering); it is spread onto * CollectionFieldsSourceState, which owns the pieces directly. The collection * renders these with shared, source-neutral components. */ export interface FieldsSourceRendering { /** * Lets a source replace any column property the shared builder produces, * including the render function for media types. Called per field. */ columnOverrides?(field: Field, ctx: ColumnOverridesContext): Partial; /** Per-source filter behavior (text operators, decimal, type icon). */ filterConfig: FieldFilterConfig; /** * Builds the source's per-field actions menu for the panel it belongs to. The * spine builds the panel and passes it in; the resulting menu drives both the * manage-fields panel and the customize-columns header. */ createFieldActionsMenu: (panel: CustomFieldsPanelState) => FieldActionsMenuBuilder; /** * Builds the raw field-management for one field (handlers + registry metadata) * for the panel it belongs to, before grouping. The header merges these with * its table-intrinsic actions (sort / hide / filter). Omitted by sources with * no field actions. */ createFieldActionHandlers?: (panel: CustomFieldsPanelState) => FieldActionHandlersBuilder; featuredPageActions: MoreActionItemFactory[]; props?: { disableDefaultPageAction?: boolean; }; /** BI error code reported when the source's load fails. Default: 'InitCustomFieldsDataExtensionFailed'. */ errorCode?: WixPatternsErrorCode; /** The source provides these so the table chunk renders them via DI rather * than static import. See FieldsSourceComponents. */ components: FieldsSourceComponents; } /** * A collection's field source: the FieldsSource (data) plus the source's UI, * held as flat members. The toolbar holds one of these rather than a specific * source. It owns the load status (initTask); field and filter reads pass * through to the FieldsSource's own observables. */ export declare class CollectionFieldsSourceState { readonly fieldsSource: FieldsSource; /** The field-management state (modals + per-field menu). Built here from the * source's config so every source gets the same panel. */ readonly customFieldsPanel: CustomFieldsPanelState; readonly featuredPageActions: MoreActionItemFactory[]; readonly props?: { disableDefaultPageAction?: boolean; }; readonly filterConfig: FieldFilterConfig; readonly openFieldModal: (opts?: { fieldId?: string; origin?: CustomFieldOrigin; customOrigin?: string; }) => void; readonly fieldActionsMenu: FieldActionsMenuBuilder; readonly fieldActionHandlers?: FieldActionHandlersBuilder; readonly components: FieldsSourceComponents; private readonly columnOverrides?; private readonly toolbar; private readonly errorCode; private hasBuiltColumns; constructor(params: { fieldsSource: FieldsSource; toolbar: ToolbarCollectionState; } & FieldsSourceRendering); /** * Attaches a source to a table's toolbar. Builds the wrapper once; calling it * again (e.g. on re-render) is a no-op. */ static setOnTable(toolbar: ToolbarCollectionState, source: { fieldsSource: FieldsSource; } & FieldsSourceRendering): void; readonly initTask: TaskState; buildFilters(): FilterElement[]; /** Registers a filter state per filterable field on the collection query. */ registerFilters(): void; /** * Builds the columns from the fields, or null while the source is still * loading so existing columns are kept. */ buildColumns(firstBuild: boolean): Column[] | null; syncColumns(): void; /** Merges a returned fields map into the source (no refetch). No-ops for sources * that don't support in-place merging. The fields reaction rebuilds columns. */ mergeFields(fields: Schema['fields']): void; init(): () => void; private handleLoadError; /** Re-runs the source load after a failure (the retry toast). */ private retryLoad; } export {}; //# sourceMappingURL=CollectionFieldsSourceState.d.ts.map