UNPKG

5.92 kBTypeScriptView Raw
1import { Field, ModelBlock } from './SiteApiSchema';
2import { ContentAreaSidebarItem, FieldExtensionOverride, InitPropertiesAndMethods, ItemFormSidebarPanel, MainNavigationTab, ManualFieldExtension, OnBootPropertiesAndMethods, RenderConfigScreenPropertiesAndMethods, RenderFieldExtensionPropertiesAndMethods, RenderManualFieldExtensionConfigScreenPropertiesAndMethods, RenderModalPropertiesAndMethods, RenderPagePropertiesAndMethods, RenderSidebarPanePropertiesAndMethods, SettingsAreaSidebarItemGroup } from './types';
3export declare type SizingUtilities = {
4 /**
5 * Listens for DOM changes and automatically calls `setHeight` when it detects a change.
6 * If you're using `datocms-react-ui` package, the `<Canvas />` component already takes
7 * care of calling this method for you.
8 */
9 startAutoResizer: () => void;
10 /** Stops resizing the iframe automatically */
11 stopAutoResizer: () => void;
12 /**
13 * Triggers a change in the size of the iframe. If you don't explicitely pass a
14 * `newHeight` it will be automatically calculated using the iframe content at the moment
15 */
16 updateHeight: (newHeight?: number) => void;
17};
18export type { Field, ModelBlock };
19export declare type IntentCtx = InitPropertiesAndMethods;
20export declare type OnBootCtx = OnBootPropertiesAndMethods;
21export declare type FieldIntentCtx = InitPropertiesAndMethods & {
22 itemType: ModelBlock;
23};
24export declare type RenderPageCtx = RenderPagePropertiesAndMethods;
25export declare type RenderModalCtx = RenderModalPropertiesAndMethods & SizingUtilities;
26export declare type RenderItemFormSidebarPanelCtx = RenderSidebarPanePropertiesAndMethods & SizingUtilities;
27export declare type RenderFieldExtensionCtx = RenderFieldExtensionPropertiesAndMethods & SizingUtilities;
28export declare type RenderManualFieldExtensionConfigScreenCtx = RenderManualFieldExtensionConfigScreenPropertiesAndMethods & SizingUtilities;
29export declare type RenderConfigScreenCtx = RenderConfigScreenPropertiesAndMethods & SizingUtilities;
30/** The full options you can pass to the `connect` function */
31export declare type FullConnectParameters = {
32 /**
33 * This function will be called once at boot time and can be used to perform ie. some
34 * initial integrity checks on the configuration.
35 *
36 * @group boot
37 */
38 onBoot: (ctx: OnBootCtx) => void;
39 /**
40 * Use this function to declare new tabs you want to add in the top-bar of the UI
41 *
42 * @group pages
43 */
44 mainNavigationTabs: (ctx: IntentCtx) => MainNavigationTab[];
45 /**
46 * Use this function to declare new navigation sections in the Settings Area sidebar
47 *
48 * @group pages
49 */
50 settingsAreaSidebarItemGroups: (ctx: IntentCtx) => SettingsAreaSidebarItemGroup[];
51 /**
52 * Use this function to declare new navigation items in the Content Area sidebar
53 *
54 * @group pages
55 */
56 contentAreaSidebarItems: (ctx: IntentCtx) => ContentAreaSidebarItem[];
57 /**
58 * Use this function to declare new field extensions that users will be able to install
59 * manually in some field
60 *
61 * @group manualFieldExtensions
62 */
63 manualFieldExtensions: (ctx: IntentCtx) => ManualFieldExtension[];
64 /**
65 * Use this function to declare new sidebar panels to be shown when the user edits
66 * records of a particular model
67 *
68 * @group sidebarPanels
69 */
70 itemFormSidebarPanels: (itemType: ModelBlock, ctx: IntentCtx) => ItemFormSidebarPanel[];
71 /**
72 * Use this function to automatically force one or more field extensions to a particular field
73 *
74 * @group forcedFieldExtensions
75 */
76 overrideFieldExtensions: (field: Field, ctx: FieldIntentCtx) => FieldExtensionOverride | void;
77 /**
78 * This function will be called when the plugin needs to render the plugin's configuration form
79 *
80 * @group configScreen
81 */
82 renderConfigScreen: (ctx: RenderConfigScreenCtx) => void;
83 /**
84 * This function will be called when the plugin needs to render a specific page (see the
85 * `mainNavigationTabs`, `settingsAreaSidebarItemGroups` and `contentAreaSidebarItems` functions)
86 *
87 * @group pages
88 */
89 renderPage: (pageId: string, ctx: RenderPageCtx) => void;
90 /**
91 * This function will be called when the plugin requested to open a modal (see the
92 * `openModal` function)
93 *
94 * @group modals
95 */
96 renderModal: (modalId: string, ctx: RenderModalCtx) => void;
97 /**
98 * This function will be called when the plugin needs to render a sidebar panel (see the
99 * `itemFormSidebarPanels` function)
100 *
101 * @group sidebarPanels
102 */
103 renderItemFormSidebarPanel: (sidebarPaneId: string, ctx: RenderItemFormSidebarPanelCtx) => void;
104 /**
105 * This function will be called when the plugin needs to render a field extension (see
106 * the `manualFieldExtensions` and `overrideFieldExtensions` functions)
107 *
108 * @group forcedFieldExtensions
109 */
110 renderFieldExtension: (fieldExtensionId: string, ctx: RenderFieldExtensionCtx) => void;
111 /**
112 * This function will be called when the plugin needs to render the configuration form
113 * for installing a field extension inside a particular field
114 *
115 * @group manualFieldExtensions
116 */
117 renderManualFieldExtensionConfigScreen: (fieldExtensionId: string, ctx: RenderManualFieldExtensionConfigScreenCtx) => void;
118 /**
119 * This function will be called each time the configuration object changes. It must
120 * return an object containing possible validation errors
121 *
122 * @group manualFieldExtensions
123 */
124 validateManualFieldExtensionParameters: (fieldExtensionId: string, parameters: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
125};
126export declare function connect(configuration?: Partial<FullConnectParameters>): Promise<void>;