@measured/puck-plugin-heading-analyzer 0.20.0-canary.f768aab9 → 0.20.1-canary.d7404af9
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 +44 -44
- package/dist/index.d.mts +293 -25
- package/dist/index.d.ts +293 -25
- package/dist/index.js +239 -350
- package/dist/index.mjs +218 -329
- package/package.json +2 -2
package/dist/index.css
CHANGED
@@ -1,51 +1,51 @@
|
|
1
1
|
/* css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css/#css-module-data */
|
2
|
-
.
|
2
|
+
.HeadingAnalyzer {
|
3
3
|
display: block;
|
4
4
|
}
|
5
|
-
.
|
5
|
+
.HeadingAnalyzer-cssWarning {
|
6
6
|
display: none !important;
|
7
7
|
}
|
8
|
-
.
|
8
|
+
.HeadingAnalyzerItem {
|
9
9
|
display: inline;
|
10
10
|
}
|
11
|
-
.
|
11
|
+
.HeadingAnalyzerItem--missing {
|
12
12
|
color: var(--puck-color-red-04);
|
13
13
|
}
|
14
14
|
|
15
15
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css/#css-module-data */
|
16
|
-
.
|
16
|
+
.SidebarSection {
|
17
17
|
display: flex;
|
18
18
|
position: relative;
|
19
19
|
flex-direction: column;
|
20
20
|
color: var(--puck-color-black);
|
21
21
|
}
|
22
|
-
.
|
22
|
+
.SidebarSection:last-of-type {
|
23
23
|
flex-grow: 1;
|
24
24
|
}
|
25
|
-
.
|
25
|
+
.SidebarSection-title {
|
26
26
|
background: var(--puck-color-white);
|
27
27
|
padding: 16px;
|
28
28
|
border-bottom: 1px solid var(--puck-color-grey-09);
|
29
29
|
border-top: 1px solid var(--puck-color-grey-09);
|
30
30
|
overflow-x: auto;
|
31
31
|
}
|
32
|
-
.
|
32
|
+
.SidebarSection--noBorderTop > .SidebarSection-title {
|
33
33
|
border-top: 0px;
|
34
34
|
}
|
35
|
-
.
|
35
|
+
.SidebarSection-content {
|
36
36
|
padding: 16px;
|
37
37
|
}
|
38
|
-
.
|
38
|
+
.SidebarSection--noPadding > .SidebarSection-content {
|
39
39
|
padding: 0px;
|
40
40
|
}
|
41
|
-
.
|
41
|
+
.SidebarSection--noPadding > .SidebarSection-content:last-child {
|
42
42
|
padding-bottom: 4px;
|
43
43
|
}
|
44
|
-
.
|
44
|
+
.SidebarSection:last-of-type .SidebarSection-content {
|
45
45
|
border-bottom: none;
|
46
46
|
flex-grow: 1;
|
47
47
|
}
|
48
|
-
.
|
48
|
+
.SidebarSection-breadcrumbLabel {
|
49
49
|
background: none;
|
50
50
|
border: 0;
|
51
51
|
border-radius: 2px;
|
@@ -56,34 +56,34 @@
|
|
56
56
|
padding: 0;
|
57
57
|
transition: color 50ms ease-in;
|
58
58
|
}
|
59
|
-
.
|
59
|
+
.SidebarSection-breadcrumbLabel:focus-visible {
|
60
60
|
outline: 2px solid var(--puck-color-azure-05);
|
61
61
|
outline-offset: 2px;
|
62
62
|
}
|
63
63
|
@media (hover: hover) and (pointer: fine) {
|
64
|
-
.
|
64
|
+
.SidebarSection-breadcrumbLabel:hover {
|
65
65
|
color: var(--puck-color-azure-03);
|
66
66
|
transition: none;
|
67
67
|
}
|
68
68
|
}
|
69
|
-
.
|
69
|
+
.SidebarSection-breadcrumbLabel:active {
|
70
70
|
color: var(--puck-color-azure-02);
|
71
71
|
transition: none;
|
72
72
|
}
|
73
|
-
.
|
73
|
+
.SidebarSection-breadcrumbs {
|
74
74
|
align-items: center;
|
75
75
|
display: flex;
|
76
76
|
gap: 4px;
|
77
77
|
}
|
78
|
-
.
|
78
|
+
.SidebarSection-breadcrumb {
|
79
79
|
align-items: center;
|
80
80
|
display: flex;
|
81
81
|
gap: 4px;
|
82
82
|
}
|
83
|
-
.
|
83
|
+
.SidebarSection-heading {
|
84
84
|
padding-inline-end: 16px;
|
85
85
|
}
|
86
|
-
.
|
86
|
+
.SidebarSection-loadingOverlay {
|
87
87
|
background: var(--puck-color-white);
|
88
88
|
display: flex;
|
89
89
|
justify-content: center;
|
@@ -99,44 +99,44 @@
|
|
99
99
|
}
|
100
100
|
|
101
101
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css/#css-module-data */
|
102
|
-
.
|
102
|
+
.Heading {
|
103
103
|
display: block;
|
104
104
|
color: var(--puck-color-black);
|
105
105
|
font-weight: 700;
|
106
106
|
margin: 0;
|
107
107
|
}
|
108
|
-
.
|
108
|
+
.Heading b {
|
109
109
|
font-weight: 700;
|
110
110
|
}
|
111
|
-
.
|
111
|
+
.Heading--xxxxl {
|
112
112
|
font-size: var(--puck-font-size-xxxxl);
|
113
113
|
letter-spacing: 0.08ch;
|
114
114
|
font-weight: 800;
|
115
115
|
}
|
116
|
-
.
|
116
|
+
.Heading--xxxl {
|
117
117
|
font-size: var(--puck-font-size-xxxl);
|
118
118
|
}
|
119
|
-
.
|
119
|
+
.Heading--xxl {
|
120
120
|
font-size: var(--puck-font-size-xxl);
|
121
121
|
}
|
122
|
-
.
|
122
|
+
.Heading--xl {
|
123
123
|
font-size: var(--puck-font-size-xl);
|
124
124
|
}
|
125
|
-
.
|
125
|
+
.Heading--l {
|
126
126
|
font-size: var(--puck-font-size-l);
|
127
127
|
}
|
128
|
-
.
|
128
|
+
.Heading--m {
|
129
129
|
font-size: var(--puck-font-size-m);
|
130
130
|
}
|
131
|
-
.
|
131
|
+
.Heading--s {
|
132
132
|
font-size: var(--puck-font-size-s);
|
133
133
|
}
|
134
|
-
.
|
134
|
+
.Heading--xs {
|
135
135
|
font-size: var(--puck-font-size-xs);
|
136
136
|
}
|
137
137
|
|
138
138
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css/#css-module-data */
|
139
|
-
@keyframes
|
139
|
+
@keyframes loader-animation {
|
140
140
|
0% {
|
141
141
|
transform: rotate(0deg) scale(1);
|
142
142
|
}
|
@@ -147,18 +147,18 @@
|
|
147
147
|
transform: rotate(360deg) scale(1);
|
148
148
|
}
|
149
149
|
}
|
150
|
-
.
|
150
|
+
.Loader {
|
151
151
|
background: transparent;
|
152
152
|
border-radius: 100%;
|
153
153
|
border: 2px solid currentColor;
|
154
154
|
border-bottom-color: transparent;
|
155
155
|
display: inline-block;
|
156
|
-
animation:
|
156
|
+
animation: loader-animation 1s 0s infinite linear;
|
157
157
|
animation-fill-mode: both;
|
158
158
|
}
|
159
159
|
|
160
160
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css/#css-module-data */
|
161
|
-
.
|
161
|
+
.OutlineList {
|
162
162
|
color: var(--puck-color-grey-03);
|
163
163
|
font-family: var(--puck-font-family);
|
164
164
|
margin: 0;
|
@@ -166,7 +166,7 @@
|
|
166
166
|
position: relative;
|
167
167
|
list-style: none;
|
168
168
|
}
|
169
|
-
.
|
169
|
+
.OutlineList::before {
|
170
170
|
background: var(--puck-color-grey-08);
|
171
171
|
position: absolute;
|
172
172
|
left: -1px;
|
@@ -175,15 +175,15 @@
|
|
175
175
|
height: calc(100% - 9px);
|
176
176
|
content: "";
|
177
177
|
}
|
178
|
-
.
|
178
|
+
.OutlineList:dir(rtl)::before {
|
179
179
|
left: unset;
|
180
180
|
right: -1px;
|
181
181
|
}
|
182
|
-
.
|
182
|
+
.OutlineListItem {
|
183
183
|
position: relative;
|
184
184
|
margin-bottom: 4px;
|
185
185
|
}
|
186
|
-
.
|
186
|
+
.OutlineListItem::before {
|
187
187
|
background: var(--puck-color-grey-08);
|
188
188
|
position: absolute;
|
189
189
|
left: -17px;
|
@@ -192,28 +192,28 @@
|
|
192
192
|
height: 1px;
|
193
193
|
content: "";
|
194
194
|
}
|
195
|
-
.
|
195
|
+
.OutlineListItem:dir(rtl)::before {
|
196
196
|
left: unset;
|
197
197
|
right: -17px;
|
198
198
|
}
|
199
|
-
.
|
199
|
+
.OutlineListItem--clickable {
|
200
200
|
cursor: pointer;
|
201
201
|
transition: color 50ms ease-in;
|
202
202
|
}
|
203
|
-
.
|
203
|
+
.OutlineListItem--clickable:focus-visible {
|
204
204
|
outline: 2px solid var(--puck-color-azure-05);
|
205
205
|
outline-offset: 2px;
|
206
206
|
}
|
207
207
|
@media (hover: hover) and (pointer: fine) {
|
208
|
-
.
|
208
|
+
.OutlineListItem--clickable:hover {
|
209
209
|
color: var(--puck-color-azure-04);
|
210
210
|
transition: none;
|
211
211
|
}
|
212
212
|
}
|
213
|
-
.
|
213
|
+
.OutlineListItem--clickable:active {
|
214
214
|
color: var(--puck-color-azure-03);
|
215
215
|
transition: none;
|
216
216
|
}
|
217
|
-
.
|
217
|
+
.OutlineListItem > .OutlineList {
|
218
218
|
margin: 8px 0;
|
219
219
|
}
|
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;
|
@@ -7,7 +7,7 @@ type ItemSelector = {
|
|
7
7
|
|
8
8
|
type FieldOption = {
|
9
9
|
label: string;
|
10
|
-
value: string | number | boolean;
|
10
|
+
value: string | number | boolean | undefined | null | object;
|
11
11
|
};
|
12
12
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
13
13
|
type BaseField = {
|
@@ -19,6 +19,7 @@ type BaseField = {
|
|
19
19
|
type TextField = BaseField & {
|
20
20
|
type: "text";
|
21
21
|
placeholder?: string;
|
22
|
+
contentEditable?: boolean;
|
22
23
|
};
|
23
24
|
type NumberField = BaseField & {
|
24
25
|
type: "number";
|
@@ -30,6 +31,7 @@ type NumberField = BaseField & {
|
|
30
31
|
type TextareaField = BaseField & {
|
31
32
|
type: "textarea";
|
32
33
|
placeholder?: string;
|
34
|
+
contentEditable?: boolean;
|
33
35
|
};
|
34
36
|
type SelectField = BaseField & {
|
35
37
|
type: "select";
|
@@ -39,26 +41,30 @@ type RadioField = BaseField & {
|
|
39
41
|
type: "radio";
|
40
42
|
options: FieldOptions;
|
41
43
|
};
|
42
|
-
type ArrayField<Props extends
|
44
|
+
type ArrayField<Props extends {
|
43
45
|
[key: string]: any;
|
44
|
-
}
|
46
|
+
}[] = {
|
45
47
|
[key: string]: any;
|
46
|
-
}
|
48
|
+
}[], UserField extends {} = {}> = BaseField & {
|
47
49
|
type: "array";
|
48
50
|
arrayFields: {
|
49
|
-
[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>;
|
50
54
|
};
|
51
55
|
defaultItemProps?: Props[0];
|
52
56
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
53
57
|
max?: number;
|
54
58
|
min?: number;
|
55
|
-
}
|
59
|
+
};
|
56
60
|
type ObjectField<Props extends any = {
|
57
61
|
[key: string]: any;
|
58
|
-
}> = BaseField & {
|
62
|
+
}, UserField extends {} = {}> = BaseField & {
|
59
63
|
type: "object";
|
60
64
|
objectFields: {
|
61
|
-
[SubPropName in keyof Props]:
|
65
|
+
[SubPropName in keyof Props]: UserField extends {
|
66
|
+
type: PropertyKey;
|
67
|
+
} ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
|
62
68
|
};
|
63
69
|
};
|
64
70
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
@@ -107,13 +113,21 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
107
113
|
type CustomField<Value extends any> = BaseField & {
|
108
114
|
type: "custom";
|
109
115
|
render: CustomFieldRender<Value>;
|
116
|
+
contentEditable?: boolean;
|
110
117
|
};
|
111
118
|
type SlotField = BaseField & {
|
112
119
|
type: "slot";
|
113
120
|
allow?: string[];
|
114
121
|
disallow?: string[];
|
115
122
|
};
|
116
|
-
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
|
+
};
|
117
131
|
type FieldProps<F = Field<any>, ValueType = any> = {
|
118
132
|
field: F;
|
119
133
|
value: ValueType;
|
@@ -122,6 +136,164 @@ type FieldProps<F = Field<any>, ValueType = any> = {
|
|
122
136
|
readOnly?: boolean;
|
123
137
|
};
|
124
138
|
|
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, {
|
187
|
+
type: T;
|
188
|
+
}>;
|
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
|
+
};
|
125
297
|
type Metadata = {
|
126
298
|
[key: string]: any;
|
127
299
|
};
|
@@ -137,6 +309,8 @@ type ArrayState = {
|
|
137
309
|
type UiState = {
|
138
310
|
leftSideBarVisible: boolean;
|
139
311
|
rightSideBarVisible: boolean;
|
312
|
+
leftSideBarWidth?: number | null;
|
313
|
+
rightSideBarWidth?: number | null;
|
140
314
|
itemSelector: ItemSelector | null;
|
141
315
|
arrayState: Record<string, ArrayState | undefined>;
|
142
316
|
previewMode: "interactive" | "edit";
|
@@ -159,19 +333,89 @@ type UiState = {
|
|
159
333
|
focus?: string | null;
|
160
334
|
};
|
161
335
|
};
|
336
|
+
type AppState<UserData extends Data = Data> = {
|
337
|
+
data: UserData;
|
338
|
+
ui: UiState;
|
339
|
+
};
|
340
|
+
|
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;
|
384
|
+
|
385
|
+
type MapFnParams<ThisField = Field> = {
|
386
|
+
value: any;
|
387
|
+
parentId: string;
|
388
|
+
propName: string;
|
389
|
+
field: ThisField;
|
390
|
+
propPath: string;
|
391
|
+
};
|
392
|
+
|
393
|
+
type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
|
394
|
+
isReadOnly: boolean;
|
395
|
+
componentId: string;
|
396
|
+
};
|
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>>;
|
405
|
+
}>;
|
162
406
|
|
163
407
|
type RenderFunc<Props extends {
|
164
408
|
[key: string]: any;
|
165
409
|
} = {
|
166
410
|
children: ReactNode;
|
167
411
|
}> = (props: Props) => ReactElement;
|
168
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "
|
412
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
169
413
|
type OverrideKey = (typeof overrideKeys)[number];
|
170
414
|
type OverridesGeneric<Shape extends {
|
171
415
|
[key in OverrideKey]: any;
|
172
416
|
}> = Shape;
|
173
|
-
type Overrides = OverridesGeneric<{
|
174
|
-
fieldTypes: Partial<FieldRenderFunctions
|
417
|
+
type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
|
418
|
+
fieldTypes: Partial<FieldRenderFunctions<UserConfig>>;
|
175
419
|
header: RenderFunc<{
|
176
420
|
actions: ReactNode;
|
177
421
|
children: ReactNode;
|
@@ -203,26 +447,35 @@ type Overrides = OverridesGeneric<{
|
|
203
447
|
children: ReactNode;
|
204
448
|
name: string;
|
205
449
|
}>;
|
450
|
+
drawer: RenderFunc;
|
451
|
+
drawerItem: RenderFunc<{
|
452
|
+
children: ReactNode;
|
453
|
+
name: string;
|
454
|
+
}>;
|
206
455
|
iframe: RenderFunc<{
|
207
456
|
children: ReactNode;
|
208
457
|
document?: Document;
|
209
458
|
}>;
|
210
459
|
outline: RenderFunc;
|
211
|
-
|
212
|
-
}>;
|
213
|
-
type FieldRenderFunctions = Omit<{
|
214
|
-
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
215
|
-
type: Type;
|
216
|
-
}>, any> & {
|
460
|
+
componentOverlay: RenderFunc<{
|
217
461
|
children: ReactNode;
|
218
|
-
|
462
|
+
hover: boolean;
|
463
|
+
isSelected: boolean;
|
464
|
+
componentId: string;
|
465
|
+
componentType: string;
|
219
466
|
}>;
|
220
|
-
|
221
|
-
|
467
|
+
puck: RenderFunc;
|
468
|
+
}>;
|
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> & {
|
222
473
|
children: ReactNode;
|
223
474
|
name: string;
|
224
475
|
}>;
|
225
|
-
}
|
476
|
+
}, "custom">;
|
477
|
+
|
478
|
+
type DragAxis = "dynamic" | "y" | "x";
|
226
479
|
|
227
480
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
228
481
|
type Viewport = {
|
@@ -232,9 +485,24 @@ type Viewport = {
|
|
232
485
|
icon?: iconTypes | ReactNode;
|
233
486
|
};
|
234
487
|
|
235
|
-
type
|
236
|
-
|
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>;
|
237
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][];
|
238
506
|
|
239
507
|
declare const headingAnalyzer: Plugin;
|
240
508
|
|