UNPKG

tinacms

Version:

> The Fastest Way to Edit Next.js Content

85 lines (84 loc) 2.4 kB
import { Form } from './react-tinacms'; import { TinaCMS } from './tina-cms'; declare type FormListItem = { type: 'document'; path: string; formId: string; subItems: FormListItem[]; } | { type: 'list'; label: string; }; declare type FormList = { label: string; id: string; items: FormListItem[]; formIds: string[]; }; export declare type TinaAction = { type: 'forms:add'; value: Form; } | { type: 'forms:remove'; value: string; } | { type: 'forms:clear'; } | { type: 'form-lists:add'; value: FormList; } | { type: 'form-lists:remove'; value: string; } | { type: 'forms:set-active-form-id'; value: string; } | { type: 'forms:set-active-field-name'; value: { formId: string; fieldName: string; }; } | { type: 'form-lists:clear'; } | { type: 'set-edit-mode'; value: 'visual' | 'basic'; } | { type: 'increment-operation-index'; } | { type: 'set-quick-editing-supported'; value: boolean; } | { type: 'set-quick-editing-enabled'; value?: boolean; } | { type: 'toggle-quick-editing-enabled'; } | { type: 'toggle-edit-state'; } | { type: 'sidebar:set-display-state'; value: TinaState['sidebarDisplayState'] | 'openOrFull'; }; export interface TinaState { activeFormId: string | null; /** * Forms are wrapped here because we need `activeFieldName` to be reactive, so adding it as a propery * on the Form class won't work, unfortunately. So "form" at this level means tinaForm + activeFieldName * * The activeFieldName should probably not be in global state, and having it here means that forms * only work if they're registered as part of this top-level state. At the risk of touching too much code * all at once, putting state this high up at least allows us to not have to touch the Form class too much. * Longer term, replaceing Form with something stateful seems like the right approach */ forms: { activeFieldName?: string | null; tinaForm: Form; }[]; formLists: FormList[]; editingMode: 'visual' | 'basic'; quickEditSupported: boolean; sidebarDisplayState: 'closed' | 'open' | 'fullscreen'; } export declare const initialState: (cms: TinaCMS) => TinaState; export declare function tinaReducer(state: TinaState, action: TinaAction): TinaState; export {};