@measured/puck-plugin-heading-analyzer 0.20.0-canary.f73c8fa0 → 0.20.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.
- package/dist/index.css +149 -5
- package/dist/index.d.mts +261 -41
- package/dist/index.d.ts +261 -41
- package/dist/index.js +240 -85
- package/dist/index.mjs +237 -82
- package/package.json +2 -2
package/dist/index.css
CHANGED
@@ -1,18 +1,162 @@
|
|
1
1
|
/* css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css/#css-module-data */
|
2
|
-
.
|
2
|
+
._HeadingAnalyzer_116v6_1 {
|
3
3
|
display: block;
|
4
|
-
padding: 16px;
|
5
4
|
}
|
6
|
-
._HeadingAnalyzer-
|
5
|
+
._HeadingAnalyzer-cssWarning_116v6_5 {
|
7
6
|
display: none !important;
|
8
7
|
}
|
9
|
-
.
|
8
|
+
._HeadingAnalyzerItem_116v6_9 {
|
10
9
|
display: inline;
|
11
10
|
}
|
12
|
-
._HeadingAnalyzerItem--
|
11
|
+
._HeadingAnalyzerItem--missing_116v6_13 {
|
13
12
|
color: var(--puck-color-red-04);
|
14
13
|
}
|
15
14
|
|
15
|
+
/* css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css/#css-module-data */
|
16
|
+
._SidebarSection_8boj8_1 {
|
17
|
+
display: flex;
|
18
|
+
position: relative;
|
19
|
+
flex-direction: column;
|
20
|
+
color: var(--puck-color-black);
|
21
|
+
}
|
22
|
+
._SidebarSection_8boj8_1:last-of-type {
|
23
|
+
flex-grow: 1;
|
24
|
+
}
|
25
|
+
._SidebarSection-title_8boj8_12 {
|
26
|
+
background: var(--puck-color-white);
|
27
|
+
padding: 16px;
|
28
|
+
border-bottom: 1px solid var(--puck-color-grey-09);
|
29
|
+
border-top: 1px solid var(--puck-color-grey-09);
|
30
|
+
overflow-x: auto;
|
31
|
+
}
|
32
|
+
._SidebarSection--noBorderTop_8boj8_20 > ._SidebarSection-title_8boj8_12 {
|
33
|
+
border-top: 0px;
|
34
|
+
}
|
35
|
+
._SidebarSection-content_8boj8_24 {
|
36
|
+
padding: 16px;
|
37
|
+
}
|
38
|
+
._SidebarSection--noPadding_8boj8_28 > ._SidebarSection-content_8boj8_24 {
|
39
|
+
padding: 0px;
|
40
|
+
}
|
41
|
+
._SidebarSection--noPadding_8boj8_28 > ._SidebarSection-content_8boj8_24:last-child {
|
42
|
+
padding-bottom: 4px;
|
43
|
+
}
|
44
|
+
._SidebarSection_8boj8_1:last-of-type ._SidebarSection-content_8boj8_24 {
|
45
|
+
border-bottom: none;
|
46
|
+
flex-grow: 1;
|
47
|
+
}
|
48
|
+
._SidebarSection-breadcrumbLabel_8boj8_41 {
|
49
|
+
background: none;
|
50
|
+
border: 0;
|
51
|
+
border-radius: 2px;
|
52
|
+
color: var(--puck-color-azure-04);
|
53
|
+
cursor: pointer;
|
54
|
+
font: inherit;
|
55
|
+
flex-shrink: 0;
|
56
|
+
padding: 0;
|
57
|
+
transition: color 50ms ease-in;
|
58
|
+
}
|
59
|
+
._SidebarSection-breadcrumbLabel_8boj8_41:focus-visible {
|
60
|
+
outline: 2px solid var(--puck-color-azure-05);
|
61
|
+
outline-offset: 2px;
|
62
|
+
}
|
63
|
+
@media (hover: hover) and (pointer: fine) {
|
64
|
+
._SidebarSection-breadcrumbLabel_8boj8_41:hover {
|
65
|
+
color: var(--puck-color-azure-03);
|
66
|
+
transition: none;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
._SidebarSection-breadcrumbLabel_8boj8_41:active {
|
70
|
+
color: var(--puck-color-azure-02);
|
71
|
+
transition: none;
|
72
|
+
}
|
73
|
+
._SidebarSection-breadcrumbs_8boj8_70 {
|
74
|
+
align-items: center;
|
75
|
+
display: flex;
|
76
|
+
gap: 4px;
|
77
|
+
}
|
78
|
+
._SidebarSection-breadcrumb_8boj8_41 {
|
79
|
+
align-items: center;
|
80
|
+
display: flex;
|
81
|
+
gap: 4px;
|
82
|
+
}
|
83
|
+
._SidebarSection-heading_8boj8_82 {
|
84
|
+
padding-inline-end: 16px;
|
85
|
+
}
|
86
|
+
._SidebarSection-loadingOverlay_8boj8_86 {
|
87
|
+
background: var(--puck-color-white);
|
88
|
+
display: flex;
|
89
|
+
justify-content: center;
|
90
|
+
align-items: center;
|
91
|
+
height: 100%;
|
92
|
+
width: 100%;
|
93
|
+
top: 0;
|
94
|
+
position: absolute;
|
95
|
+
z-index: 1;
|
96
|
+
pointer-events: all;
|
97
|
+
box-sizing: border-box;
|
98
|
+
opacity: 0.8;
|
99
|
+
}
|
100
|
+
|
101
|
+
/* css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css/#css-module-data */
|
102
|
+
._Heading_qxrry_1 {
|
103
|
+
display: block;
|
104
|
+
color: var(--puck-color-black);
|
105
|
+
font-weight: 700;
|
106
|
+
margin: 0;
|
107
|
+
}
|
108
|
+
._Heading_qxrry_1 b {
|
109
|
+
font-weight: 700;
|
110
|
+
}
|
111
|
+
._Heading--xxxxl_qxrry_12 {
|
112
|
+
font-size: var(--puck-font-size-xxxxl);
|
113
|
+
letter-spacing: 0.08ch;
|
114
|
+
font-weight: 800;
|
115
|
+
}
|
116
|
+
._Heading--xxxl_qxrry_18 {
|
117
|
+
font-size: var(--puck-font-size-xxxl);
|
118
|
+
}
|
119
|
+
._Heading--xxl_qxrry_22 {
|
120
|
+
font-size: var(--puck-font-size-xxl);
|
121
|
+
}
|
122
|
+
._Heading--xl_qxrry_26 {
|
123
|
+
font-size: var(--puck-font-size-xl);
|
124
|
+
}
|
125
|
+
._Heading--l_qxrry_30 {
|
126
|
+
font-size: var(--puck-font-size-l);
|
127
|
+
}
|
128
|
+
._Heading--m_qxrry_34 {
|
129
|
+
font-size: var(--puck-font-size-m);
|
130
|
+
}
|
131
|
+
._Heading--s_qxrry_38 {
|
132
|
+
font-size: var(--puck-font-size-s);
|
133
|
+
}
|
134
|
+
._Heading--xs_qxrry_42 {
|
135
|
+
font-size: var(--puck-font-size-xs);
|
136
|
+
}
|
137
|
+
|
138
|
+
/* css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css/#css-module-data */
|
139
|
+
@keyframes _loader-animation_nacdm_1 {
|
140
|
+
0% {
|
141
|
+
transform: rotate(0deg) scale(1);
|
142
|
+
}
|
143
|
+
50% {
|
144
|
+
transform: rotate(180deg) scale(0.8);
|
145
|
+
}
|
146
|
+
100% {
|
147
|
+
transform: rotate(360deg) scale(1);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
._Loader_nacdm_13 {
|
151
|
+
background: transparent;
|
152
|
+
border-radius: 100%;
|
153
|
+
border: 2px solid currentColor;
|
154
|
+
border-bottom-color: transparent;
|
155
|
+
display: inline-block;
|
156
|
+
animation: _loader-animation_nacdm_1 1s 0s infinite linear;
|
157
|
+
animation-fill-mode: both;
|
158
|
+
}
|
159
|
+
|
16
160
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css/#css-module-data */
|
17
161
|
._OutlineList_w4lzv_1 {
|
18
162
|
color: var(--puck-color-grey-03);
|
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
1
|
+
import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
|
2
2
|
|
3
3
|
type ItemSelector = {
|
4
4
|
index: number;
|
@@ -41,26 +41,30 @@ type RadioField = BaseField & {
|
|
41
41
|
type: "radio";
|
42
42
|
options: FieldOptions;
|
43
43
|
};
|
44
|
-
type ArrayField<Props extends
|
44
|
+
type ArrayField<Props extends {
|
45
45
|
[key: string]: any;
|
46
|
-
}
|
46
|
+
}[] = {
|
47
47
|
[key: string]: any;
|
48
|
-
}
|
48
|
+
}[], UserField extends {} = {}> = BaseField & {
|
49
49
|
type: "array";
|
50
50
|
arrayFields: {
|
51
|
-
[SubPropName in keyof Props[0]]:
|
51
|
+
[SubPropName in keyof Props[0]]: UserField extends {
|
52
|
+
type: PropertyKey;
|
53
|
+
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
52
54
|
};
|
53
55
|
defaultItemProps?: Props[0];
|
54
56
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
55
57
|
max?: number;
|
56
58
|
min?: number;
|
57
|
-
}
|
59
|
+
};
|
58
60
|
type ObjectField<Props extends any = {
|
59
61
|
[key: string]: any;
|
60
|
-
}> = BaseField & {
|
62
|
+
}, UserField extends {} = {}> = BaseField & {
|
61
63
|
type: "object";
|
62
64
|
objectFields: {
|
63
|
-
[SubPropName in keyof Props]:
|
65
|
+
[SubPropName in keyof Props]: UserField extends {
|
66
|
+
type: PropertyKey;
|
67
|
+
} ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
|
64
68
|
};
|
65
69
|
};
|
66
70
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
@@ -116,7 +120,14 @@ type SlotField = BaseField & {
|
|
116
120
|
allow?: string[];
|
117
121
|
disallow?: string[];
|
118
122
|
};
|
119
|
-
type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType
|
123
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
124
|
+
[key: string]: any;
|
125
|
+
}[] ? ValueType : {}[], UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
126
|
+
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
127
|
+
[PropName in keyof Omit<ComponentProps, "editMode">]: UserField extends {
|
128
|
+
type: PropertyKey;
|
129
|
+
} ? Field<ComponentProps[PropName], UserField> | UserField : Field<ComponentProps[PropName]>;
|
130
|
+
};
|
120
131
|
type FieldProps<F = Field<any>, ValueType = any> = {
|
121
132
|
field: F;
|
122
133
|
value: ValueType;
|
@@ -125,10 +136,164 @@ type FieldProps<F = Field<any>, ValueType = any> = {
|
|
125
136
|
readOnly?: boolean;
|
126
137
|
};
|
127
138
|
|
128
|
-
type
|
139
|
+
type DropZoneProps = {
|
140
|
+
zone: string;
|
141
|
+
allow?: string[];
|
142
|
+
disallow?: string[];
|
143
|
+
style?: CSSProperties;
|
144
|
+
minEmptyHeight?: number;
|
145
|
+
className?: string;
|
146
|
+
collisionAxis?: DragAxis;
|
147
|
+
};
|
148
|
+
|
149
|
+
type PuckContext = {
|
150
|
+
renderDropZone: React.FC<DropZoneProps>;
|
151
|
+
metadata: Metadata;
|
152
|
+
isEditing: boolean;
|
153
|
+
dragRef: ((element: Element | null) => void) | null;
|
154
|
+
};
|
155
|
+
type DefaultRootFieldProps = {
|
156
|
+
title?: string;
|
157
|
+
};
|
158
|
+
type DefaultComponentProps = {
|
159
|
+
[key: string]: any;
|
160
|
+
};
|
161
|
+
|
162
|
+
type WithId<Props> = Props & {
|
163
|
+
id: string;
|
164
|
+
};
|
165
|
+
type WithPuckProps<Props> = Props & {
|
166
|
+
puck: PuckContext;
|
167
|
+
editMode?: boolean;
|
168
|
+
};
|
169
|
+
type AsFieldProps<Props> = Omit<Props, "children" | "puck" | "editMode">;
|
170
|
+
type WithChildren<Props> = Props & {
|
171
|
+
children: ReactNode;
|
172
|
+
};
|
173
|
+
type UserGenerics<UserConfig extends Config = Config, UserParams extends ExtractConfigParams<UserConfig> = ExtractConfigParams<UserConfig>, UserData extends Data<UserParams["props"], UserParams["rootProps"]> | Data = Data<UserParams["props"], UserParams["rootProps"]>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
174
|
+
UserConfig: UserConfig;
|
175
|
+
UserParams: UserParams;
|
176
|
+
UserProps: UserParams["props"];
|
177
|
+
UserRootProps: UserParams["rootProps"] & DefaultRootFieldProps;
|
178
|
+
UserData: UserData;
|
179
|
+
UserAppState: UserAppState;
|
180
|
+
UserPublicAppState: UserPublicAppState;
|
181
|
+
UserComponentData: UserComponentData;
|
182
|
+
UserField: UserParams["field"];
|
183
|
+
};
|
184
|
+
type ExtractField<UserField extends {
|
185
|
+
type: PropertyKey;
|
186
|
+
}, T extends UserField["type"]> = Extract<UserField, {
|
129
187
|
type: T;
|
130
188
|
}>;
|
131
189
|
|
190
|
+
type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
|
191
|
+
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
192
|
+
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
193
|
+
}>>) => JSX.Element;
|
194
|
+
type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
195
|
+
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
196
|
+
props?: Partial<Props>;
|
197
|
+
};
|
198
|
+
type ComponentConfigInternal<RenderProps extends DefaultComponentProps, FieldProps extends DefaultComponentProps, DataShape = Omit<ComponentData<FieldProps>, "type">, // NB this doesn't include AllProps, so types will not contain deep slot types. To fix, we require a breaking change.
|
199
|
+
UserField extends BaseField = {}> = {
|
200
|
+
render: PuckComponent<RenderProps>;
|
201
|
+
label?: string;
|
202
|
+
defaultProps?: FieldProps;
|
203
|
+
fields?: Fields<FieldProps, UserField>;
|
204
|
+
permissions?: Partial<Permissions>;
|
205
|
+
inline?: boolean;
|
206
|
+
resolveFields?: (data: DataShape, params: {
|
207
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
208
|
+
id: string;
|
209
|
+
}>;
|
210
|
+
fields: Fields<FieldProps>;
|
211
|
+
lastFields: Fields<FieldProps>;
|
212
|
+
lastData: DataShape | null;
|
213
|
+
appState: AppState;
|
214
|
+
parent: ComponentData | null;
|
215
|
+
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
216
|
+
resolveData?: (data: DataShape, params: {
|
217
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
218
|
+
id: string;
|
219
|
+
}>;
|
220
|
+
lastData: DataShape | null;
|
221
|
+
metadata: Metadata;
|
222
|
+
trigger: ResolveDataTrigger;
|
223
|
+
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
224
|
+
resolvePermissions?: (data: DataShape, params: {
|
225
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
226
|
+
id: string;
|
227
|
+
}>;
|
228
|
+
lastPermissions: Partial<Permissions>;
|
229
|
+
permissions: Partial<Permissions>;
|
230
|
+
appState: AppState;
|
231
|
+
lastData: DataShape | null;
|
232
|
+
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
233
|
+
metadata?: Metadata;
|
234
|
+
};
|
235
|
+
type RootConfigInternal<RootProps extends DefaultComponentProps = DefaultComponentProps, UserField extends BaseField = {}> = Partial<ComponentConfigInternal<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>, UserField>>;
|
236
|
+
type Category<ComponentName> = {
|
237
|
+
components?: ComponentName[];
|
238
|
+
title?: string;
|
239
|
+
visible?: boolean;
|
240
|
+
defaultExpanded?: boolean;
|
241
|
+
};
|
242
|
+
type ConfigInternal<Props extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultComponentProps, CategoryName extends string = string, UserField extends {} = {}> = {
|
243
|
+
categories?: Record<CategoryName, Category<keyof Props>> & {
|
244
|
+
other?: Category<keyof Props>;
|
245
|
+
};
|
246
|
+
components: {
|
247
|
+
[ComponentName in keyof Props]: Omit<ComponentConfigInternal<Props[ComponentName], Props[ComponentName], Omit<ComponentData<Props[ComponentName]>, "type">, UserField>, "type">;
|
248
|
+
};
|
249
|
+
root?: RootConfigInternal<RootProps, UserField>;
|
250
|
+
};
|
251
|
+
type DefaultComponents = Record<string, any>;
|
252
|
+
type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = DefaultComponentProps, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
|
253
|
+
type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
|
254
|
+
props: PropsOrParams;
|
255
|
+
rootProps: RootProps & DefaultRootFieldProps;
|
256
|
+
categoryNames: CategoryName;
|
257
|
+
field: UserField extends {
|
258
|
+
type: string;
|
259
|
+
} ? UserField : Field;
|
260
|
+
} : never;
|
261
|
+
|
262
|
+
type BaseData<Props extends {
|
263
|
+
[key: string]: any;
|
264
|
+
} = {
|
265
|
+
[key: string]: any;
|
266
|
+
}> = {
|
267
|
+
readOnly?: Partial<Record<keyof Props, boolean>>;
|
268
|
+
};
|
269
|
+
type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
|
270
|
+
props: Props;
|
271
|
+
};
|
272
|
+
type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
|
273
|
+
type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
|
274
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string, Components extends Record<string, DefaultComponentProps> = Record<string, DefaultComponentProps>> = {
|
275
|
+
type: Name;
|
276
|
+
props: WithDeepSlots<WithId<Props>, Content<Components>>;
|
277
|
+
} & BaseData<Props>;
|
278
|
+
type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
|
279
|
+
type: Name;
|
280
|
+
props: Props & {
|
281
|
+
id?: string;
|
282
|
+
};
|
283
|
+
} & BaseData<Props>;
|
284
|
+
type ComponentDataMap<Components extends DefaultComponents = DefaultComponents> = {
|
285
|
+
[K in keyof Components]: ComponentData<Components[K], K extends string ? K : never, Components>;
|
286
|
+
}[keyof Components];
|
287
|
+
type Content<PropsMap extends {
|
288
|
+
[key: string]: DefaultComponentProps;
|
289
|
+
} = {
|
290
|
+
[key: string]: DefaultComponentProps;
|
291
|
+
}> = ComponentDataMap<PropsMap>[];
|
292
|
+
type Data<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
|
293
|
+
root: WithDeepSlots<RootData<RootProps>, Content<Components>>;
|
294
|
+
content: Content<Components>;
|
295
|
+
zones?: Record<string, Content<Components>>;
|
296
|
+
};
|
132
297
|
type Metadata = {
|
133
298
|
[key: string]: any;
|
134
299
|
};
|
@@ -136,7 +301,6 @@ type Metadata = {
|
|
136
301
|
type ItemWithId = {
|
137
302
|
_arrayId: string;
|
138
303
|
_originalIndex: number;
|
139
|
-
_currentIndex: number;
|
140
304
|
};
|
141
305
|
type ArrayState = {
|
142
306
|
items: ItemWithId[];
|
@@ -168,16 +332,55 @@ type UiState = {
|
|
168
332
|
field: {
|
169
333
|
focus?: string | null;
|
170
334
|
};
|
171
|
-
|
172
|
-
|
173
|
-
|
335
|
+
};
|
336
|
+
type AppState<UserData extends Data = Data> = {
|
337
|
+
data: UserData;
|
338
|
+
ui: UiState;
|
174
339
|
};
|
175
340
|
|
176
|
-
type
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
341
|
+
type ZoneType = "root" | "dropzone" | "slot";
|
342
|
+
type PuckNodeData = {
|
343
|
+
data: ComponentData;
|
344
|
+
flatData: ComponentData;
|
345
|
+
parentId: string | null;
|
346
|
+
zone: string;
|
347
|
+
path: string[];
|
348
|
+
};
|
349
|
+
type PuckZoneData = {
|
350
|
+
contentIds: string[];
|
351
|
+
type: ZoneType;
|
352
|
+
};
|
353
|
+
type NodeIndex = Record<string, PuckNodeData>;
|
354
|
+
type ZoneIndex = Record<string, PuckZoneData>;
|
355
|
+
type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
|
356
|
+
indexes: {
|
357
|
+
nodes: NodeIndex;
|
358
|
+
zones: ZoneIndex;
|
359
|
+
};
|
360
|
+
};
|
361
|
+
type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined;
|
362
|
+
/**
|
363
|
+
* Recursively walk T and replace Slots with SlotComponents
|
364
|
+
*/
|
365
|
+
type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
|
366
|
+
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
367
|
+
} : T;
|
368
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultComponentProps, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
369
|
+
components?: Components;
|
370
|
+
root?: RootProps;
|
371
|
+
categories?: CategoryNames;
|
372
|
+
fields?: AssertHasValue<UserFields>;
|
373
|
+
};
|
374
|
+
type FieldsExtension = {
|
375
|
+
[Type in string]: {
|
376
|
+
type: Type;
|
377
|
+
};
|
378
|
+
};
|
379
|
+
type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
|
380
|
+
type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
|
381
|
+
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
382
|
+
never
|
383
|
+
] ? False : True;
|
181
384
|
|
182
385
|
type MapFnParams<ThisField = Field> = {
|
183
386
|
value: any;
|
@@ -191,18 +394,28 @@ type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
|
|
191
394
|
isReadOnly: boolean;
|
192
395
|
componentId: string;
|
193
396
|
};
|
194
|
-
type FieldTransformFn<T
|
195
|
-
type FieldTransforms =
|
196
|
-
|
397
|
+
type FieldTransformFn<T> = (params: FieldTransformFnParams<T>) => any;
|
398
|
+
type FieldTransforms<UserConfig extends Config = Config<{
|
399
|
+
fields: {};
|
400
|
+
}>, // Setting fields: {} helps TS choose default field types
|
401
|
+
G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
402
|
+
type: string;
|
403
|
+
} = Field | G["UserField"]> = Partial<{
|
404
|
+
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
197
405
|
}>;
|
198
406
|
|
407
|
+
type RenderFunc<Props extends {
|
408
|
+
[key: string]: any;
|
409
|
+
} = {
|
410
|
+
children: ReactNode;
|
411
|
+
}> = (props: Props) => ReactElement;
|
199
412
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
200
413
|
type OverrideKey = (typeof overrideKeys)[number];
|
201
414
|
type OverridesGeneric<Shape extends {
|
202
415
|
[key in OverrideKey]: any;
|
203
416
|
}> = Shape;
|
204
|
-
type Overrides = OverridesGeneric<{
|
205
|
-
fieldTypes: Partial<FieldRenderFunctions
|
417
|
+
type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
418
|
+
fieldTypes: Partial<FieldRenderFunctions<UserConfig>>;
|
206
419
|
header: RenderFunc<{
|
207
420
|
actions: ReactNode;
|
208
421
|
children: ReactNode;
|
@@ -253,19 +466,16 @@ type Overrides = OverridesGeneric<{
|
|
253
466
|
}>;
|
254
467
|
puck: RenderFunc;
|
255
468
|
}>;
|
256
|
-
type FieldRenderFunctions =
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
children: ReactNode;
|
261
|
-
name: string;
|
262
|
-
}>;
|
263
|
-
}, "custom"> & {
|
264
|
-
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
469
|
+
type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
|
470
|
+
type: string;
|
471
|
+
} = Field | G["UserField"]> = Omit<{
|
472
|
+
[Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
|
265
473
|
children: ReactNode;
|
266
474
|
name: string;
|
267
475
|
}>;
|
268
|
-
}
|
476
|
+
}, "custom">;
|
477
|
+
|
478
|
+
type DragAxis = "dynamic" | "y" | "x";
|
269
479
|
|
270
480
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
271
481
|
type Viewport = {
|
@@ -275,14 +485,24 @@ type Viewport = {
|
|
275
485
|
icon?: iconTypes | ReactNode;
|
276
486
|
};
|
277
487
|
|
278
|
-
type
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
488
|
+
type Permissions = {
|
489
|
+
drag: boolean;
|
490
|
+
duplicate: boolean;
|
491
|
+
delete: boolean;
|
492
|
+
edit: boolean;
|
493
|
+
insert: boolean;
|
494
|
+
} & Record<string, boolean>;
|
495
|
+
type Plugin<UserConfig extends Config = Config> = {
|
496
|
+
overrides?: Partial<Overrides<UserConfig>>;
|
497
|
+
fieldTransforms?: FieldTransforms<UserConfig>;
|
285
498
|
};
|
499
|
+
type Slot<Props extends {
|
500
|
+
[key: string]: DefaultComponentProps;
|
501
|
+
} = {
|
502
|
+
[key: string]: DefaultComponentProps;
|
503
|
+
}> = {
|
504
|
+
[K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
|
505
|
+
}[keyof Props][];
|
286
506
|
|
287
507
|
declare const headingAnalyzer: Plugin;
|
288
508
|
|