@measured/puck 0.21.0-canary.16a3eee1 → 0.21.0-canary.17395b2c
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/Editor-CYTATURR.mjs +204 -0
- package/dist/Editor-F2LSS6SE.css +403 -0
- package/dist/Render-OFE6QLI2.mjs +55 -0
- package/dist/Render-QEMDIDQC.css +101 -0
- package/dist/{walk-tree-Ctf3FZQI.d.mts → actions-tsxxcX1z.d.mts} +285 -82
- package/dist/{walk-tree-Ctf3FZQI.d.ts → actions-tsxxcX1z.d.ts} +285 -82
- package/dist/chunk-72SA22GI.mjs +134 -0
- package/dist/chunk-CSSRLPHM.mjs +11 -0
- package/dist/chunk-M4QBB3JM.mjs +111 -0
- package/dist/chunk-M6W7YEVX.mjs +95 -0
- package/dist/chunk-MLTVJA2A.mjs +63 -0
- package/dist/chunk-MVJKIFF6.mjs +419 -0
- package/dist/chunk-NLUHDYVR.mjs +416 -0
- package/dist/chunk-NOJQSXRU.mjs +33 -0
- package/dist/chunk-QBGM4ELA.mjs +528 -0
- package/dist/chunk-UNQOU2OI.mjs +53 -0
- package/dist/chunk-UUOBSXZR.mjs +1807 -0
- package/dist/chunk-V5I7CVLT.mjs +103 -0
- package/dist/chunk-V7333LON.mjs +708 -0
- package/dist/{chunk-JZ2BPCUI.mjs → chunk-V73FDFDB.mjs} +6032 -7351
- package/dist/chunk-Y2EFNT5P.mjs +108 -0
- package/dist/full-2GJTAAZE.css +301 -0
- package/dist/full-GZ4L3XCF.mjs +93 -0
- package/dist/index-Ca6V6NQD.d.ts +118 -0
- package/dist/index-mQvUCH3C.d.mts +118 -0
- package/dist/index.css +1032 -387
- package/dist/index.d.mts +116 -114
- package/dist/index.d.ts +116 -114
- package/dist/index.js +8758 -4944
- package/dist/index.mjs +34 -12
- package/dist/internal.d.mts +27 -0
- package/dist/internal.d.ts +27 -0
- package/dist/internal.js +908 -0
- package/dist/internal.mjs +13 -0
- package/dist/loaded-2MNXXPJP.mjs +57 -0
- package/dist/loaded-6QT4HD2O.mjs +57 -0
- package/dist/loaded-RVWBFK7L.css +87 -0
- package/dist/loaded-ZVPBQVNE.mjs +60 -0
- package/dist/no-external.css +1165 -516
- package/dist/no-external.d.mts +19 -2
- package/dist/no-external.d.ts +19 -2
- package/dist/no-external.js +8760 -4943
- package/dist/no-external.mjs +36 -9
- package/dist/rsc.css +101 -0
- package/dist/rsc.d.mts +17 -2
- package/dist/rsc.d.ts +17 -2
- package/dist/rsc.js +421 -32
- package/dist/rsc.mjs +18 -9
- package/dist/walk-tree-Bh85NMeo.d.ts +29 -0
- package/dist/walk-tree-CDA3K5S3.d.mts +29 -0
- package/package.json +31 -4
- package/dist/chunk-X7YZ3YE7.mjs +0 -964
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css/#css-module-data */
|
|
2
|
+
._RichTextEditor_1elol_1 .ProseMirror {
|
|
3
|
+
white-space: pre-wrap;
|
|
4
|
+
word-wrap: break-word;
|
|
5
|
+
cursor: text;
|
|
6
|
+
outline: none;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
._RichTextEditor_1elol_1 .rich-text * {
|
|
10
|
+
white-space: pre-wrap;
|
|
11
|
+
user-select: auto;
|
|
12
|
+
-webkit-user-select: auto;
|
|
13
|
+
}
|
|
14
|
+
._RichTextEditor_1elol_1 .rich-text blockquote {
|
|
15
|
+
margin: 1em 0;
|
|
16
|
+
padding: 0 1em;
|
|
17
|
+
border-left: 4px solid var(--puck-color-grey-09);
|
|
18
|
+
}
|
|
19
|
+
._RichTextEditor_1elol_1 .rich-text code {
|
|
20
|
+
background-color: var(--puck-color-grey-11);
|
|
21
|
+
padding: 4px 8px;
|
|
22
|
+
border-radius: 4px;
|
|
23
|
+
}
|
|
24
|
+
._RichTextEditor_1elol_1 .rich-text p:empty::before {
|
|
25
|
+
content: "\a0";
|
|
26
|
+
}
|
|
27
|
+
._RichTextEditor_1elol_1 .rich-text pre code {
|
|
28
|
+
display: block;
|
|
29
|
+
padding: 8px 12px;
|
|
30
|
+
}
|
|
31
|
+
._RichTextEditor_1elol_1 .rich-text > *:first-child,
|
|
32
|
+
._RichTextEditor_1elol_1 .ProseMirror > *:first-child,
|
|
33
|
+
._RichTextEditor_1elol_1 .rich-text * p:first-of-type {
|
|
34
|
+
margin-top: 0;
|
|
35
|
+
}
|
|
36
|
+
._RichTextEditor_1elol_1 .rich-text > *:last-child,
|
|
37
|
+
._RichTextEditor_1elol_1 .ProseMirror > *:last-child,
|
|
38
|
+
._RichTextEditor_1elol_1 .rich-text * p:last-of-type {
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
}
|
|
41
|
+
._RichTextEditor--editor_1elol_50 {
|
|
42
|
+
background: var(--puck-color-white);
|
|
43
|
+
border-width: 1px;
|
|
44
|
+
border-style: solid;
|
|
45
|
+
border-color: var(--puck-color-grey-09);
|
|
46
|
+
border-radius: 4px;
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
font-family: inherit;
|
|
51
|
+
font-size: var(--puck-font-size-xxs);
|
|
52
|
+
resize: vertical;
|
|
53
|
+
transition: border-color 50ms ease-in;
|
|
54
|
+
width: 100%;
|
|
55
|
+
max-width: 100%;
|
|
56
|
+
min-height: 128px;
|
|
57
|
+
}
|
|
58
|
+
._RichTextEditor--editor_1elol_50 .rich-text {
|
|
59
|
+
flex-grow: 1;
|
|
60
|
+
}
|
|
61
|
+
._RichTextEditor--editor_1elol_50 .rich-text:not(:has(.ProseMirror)),
|
|
62
|
+
._RichTextEditor--editor_1elol_50 .rich-text .ProseMirror {
|
|
63
|
+
height: 100%;
|
|
64
|
+
padding: 12px 15px;
|
|
65
|
+
}
|
|
66
|
+
._RichTextEditor--editor_1elol_50 .rich-text ul,
|
|
67
|
+
._RichTextEditor--editor_1elol_50 .rich-text ol {
|
|
68
|
+
padding-left: 24px;
|
|
69
|
+
}
|
|
70
|
+
._RichTextEditor--editor_1elol_50 .rich-text li {
|
|
71
|
+
line-height: 1.5;
|
|
72
|
+
}
|
|
73
|
+
._RichTextEditor--editor_1elol_50 .rich-text p {
|
|
74
|
+
margin-block: 12px;
|
|
75
|
+
}
|
|
76
|
+
._RichTextEditor--editor_1elol_50 .rich-text ul {
|
|
77
|
+
list-style: disc;
|
|
78
|
+
}
|
|
79
|
+
._RichTextEditor--editor_1elol_50 .rich-text ol {
|
|
80
|
+
list-style: decimal;
|
|
81
|
+
}
|
|
82
|
+
._RichTextEditor--editor_1elol_50:focus-within {
|
|
83
|
+
border-color: var(--puck-color-grey-05);
|
|
84
|
+
outline: 2px solid var(--puck-color-azure-05);
|
|
85
|
+
transition: none;
|
|
86
|
+
}
|
|
87
|
+
._RichTextEditor--editor_1elol_50._RichTextEditor--disabled_1elol_106 {
|
|
88
|
+
background: var(--puck-color-grey-11);
|
|
89
|
+
}
|
|
90
|
+
._RichTextEditor_1elol_1:not(:focus-within):not(._RichTextEditor--isActive_1elol_110) .ProseMirror ::selection {
|
|
91
|
+
background-color: transparent;
|
|
92
|
+
}
|
|
93
|
+
._RichTextEditor-menu_1elol_116 {
|
|
94
|
+
border-bottom: 1px solid var(--puck-color-grey-10);
|
|
95
|
+
position: sticky;
|
|
96
|
+
top: 0;
|
|
97
|
+
z-index: 1;
|
|
98
|
+
}
|
|
99
|
+
._RichTextEditor--disabled_1elol_106 ._RichTextEditor-menu_1elol_116 {
|
|
100
|
+
border-bottom: 1px solid var(--puck-color-grey-09);
|
|
101
|
+
}
|
|
@@ -1,72 +1,269 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
|
|
1
|
+
import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
|
|
2
|
+
import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
|
|
3
|
+
import { BlockquoteOptions } from '@tiptap/extension-blockquote';
|
|
4
|
+
import { BoldOptions } from '@tiptap/extension-bold';
|
|
5
|
+
import { CodeOptions } from '@tiptap/extension-code';
|
|
6
|
+
import { CodeBlockOptions } from '@tiptap/extension-code-block';
|
|
7
|
+
import { HardBreakOptions } from '@tiptap/extension-hard-break';
|
|
8
|
+
import { HeadingOptions } from '@tiptap/extension-heading';
|
|
9
|
+
import { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule';
|
|
10
|
+
import { ItalicOptions } from '@tiptap/extension-italic';
|
|
11
|
+
import { LinkOptions } from '@tiptap/extension-link';
|
|
12
|
+
import { BulletListOptions, ListItemOptions, ListKeymapOptions, OrderedListOptions } from '@tiptap/extension-list';
|
|
13
|
+
import { ParagraphOptions } from '@tiptap/extension-paragraph';
|
|
14
|
+
import { StrikeOptions } from '@tiptap/extension-strike';
|
|
15
|
+
import { TextAlignOptions } from '@tiptap/extension-text-align';
|
|
16
|
+
import { UnderlineOptions } from '@tiptap/extension-underline';
|
|
2
17
|
|
|
3
18
|
type ItemSelector = {
|
|
4
19
|
index: number;
|
|
5
20
|
zone?: string;
|
|
6
21
|
};
|
|
7
22
|
|
|
23
|
+
declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
|
|
24
|
+
isAlignLeft?: undefined;
|
|
25
|
+
canAlignLeft?: undefined;
|
|
26
|
+
isAlignCenter?: undefined;
|
|
27
|
+
canAlignCenter?: undefined;
|
|
28
|
+
isAlignRight?: undefined;
|
|
29
|
+
canAlignRight?: undefined;
|
|
30
|
+
isAlignJustify?: undefined;
|
|
31
|
+
canAlignJustify?: undefined;
|
|
32
|
+
isBold?: undefined;
|
|
33
|
+
canBold?: undefined;
|
|
34
|
+
isItalic?: undefined;
|
|
35
|
+
canItalic?: undefined;
|
|
36
|
+
isUnderline?: undefined;
|
|
37
|
+
canUnderline?: undefined;
|
|
38
|
+
isStrike?: undefined;
|
|
39
|
+
canStrike?: undefined;
|
|
40
|
+
isInlineCode?: undefined;
|
|
41
|
+
canInlineCode?: undefined;
|
|
42
|
+
isBulletList?: undefined;
|
|
43
|
+
canBulletList?: undefined;
|
|
44
|
+
isOrderedList?: undefined;
|
|
45
|
+
canOrderedList?: undefined;
|
|
46
|
+
isCodeBlock?: undefined;
|
|
47
|
+
canCodeBlock?: undefined;
|
|
48
|
+
isBlockquote?: undefined;
|
|
49
|
+
canBlockquote?: undefined;
|
|
50
|
+
canHorizontalRule?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
isAlignLeft: boolean;
|
|
53
|
+
canAlignLeft: boolean;
|
|
54
|
+
isAlignCenter: boolean;
|
|
55
|
+
canAlignCenter: boolean;
|
|
56
|
+
isAlignRight: boolean;
|
|
57
|
+
canAlignRight: boolean;
|
|
58
|
+
isAlignJustify: boolean;
|
|
59
|
+
canAlignJustify: boolean;
|
|
60
|
+
isBold: boolean;
|
|
61
|
+
canBold: boolean;
|
|
62
|
+
isItalic: boolean;
|
|
63
|
+
canItalic: boolean;
|
|
64
|
+
isUnderline: boolean;
|
|
65
|
+
canUnderline: boolean;
|
|
66
|
+
isStrike: boolean;
|
|
67
|
+
canStrike: boolean;
|
|
68
|
+
isInlineCode: boolean;
|
|
69
|
+
canInlineCode: boolean;
|
|
70
|
+
isBulletList: boolean;
|
|
71
|
+
canBulletList: boolean;
|
|
72
|
+
isOrderedList: boolean;
|
|
73
|
+
canOrderedList: boolean;
|
|
74
|
+
isCodeBlock: boolean;
|
|
75
|
+
canCodeBlock: boolean;
|
|
76
|
+
isBlockquote: boolean;
|
|
77
|
+
canBlockquote: boolean;
|
|
78
|
+
canHorizontalRule: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type RichTextSelector = (ctx: EditorStateSnapshot, readOnly: boolean) => Partial<Record<string, boolean>>;
|
|
82
|
+
type DefaultEditorState = ReturnType<typeof defaultEditorState>;
|
|
83
|
+
type EditorState<Selector extends RichTextSelector = RichTextSelector> = DefaultEditorState & ReturnType<Selector> & Record<string, boolean | undefined>;
|
|
84
|
+
|
|
85
|
+
interface PuckRichTextOptions {
|
|
86
|
+
/**
|
|
87
|
+
* If set to false, the blockquote extension will not be registered
|
|
88
|
+
* @example blockquote: false
|
|
89
|
+
*/
|
|
90
|
+
blockquote: Partial<BlockquoteOptions> | false;
|
|
91
|
+
/**
|
|
92
|
+
* If set to false, the bold extension will not be registered
|
|
93
|
+
* @example bold: false
|
|
94
|
+
*/
|
|
95
|
+
bold: Partial<BoldOptions> | false;
|
|
96
|
+
/**
|
|
97
|
+
* If set to false, the bulletList extension will not be registered
|
|
98
|
+
* @example bulletList: false
|
|
99
|
+
*/
|
|
100
|
+
bulletList: Partial<BulletListOptions> | false;
|
|
101
|
+
/**
|
|
102
|
+
* If set to false, the code extension will not be registered
|
|
103
|
+
* @example code: false
|
|
104
|
+
*/
|
|
105
|
+
code: Partial<CodeOptions> | false;
|
|
106
|
+
/**
|
|
107
|
+
* If set to false, the codeBlock extension will not be registered
|
|
108
|
+
* @example codeBlock: false
|
|
109
|
+
*/
|
|
110
|
+
codeBlock: Partial<CodeBlockOptions> | false;
|
|
111
|
+
/**
|
|
112
|
+
* If set to false, the document extension will not be registered
|
|
113
|
+
* @example document: false
|
|
114
|
+
*/
|
|
115
|
+
document: false;
|
|
116
|
+
/**
|
|
117
|
+
* If set to false, the hardBreak extension will not be registered
|
|
118
|
+
* @example hardBreak: false
|
|
119
|
+
*/
|
|
120
|
+
hardBreak: Partial<HardBreakOptions> | false;
|
|
121
|
+
/**
|
|
122
|
+
* If set to false, the heading extension will not be registered
|
|
123
|
+
* @example heading: false
|
|
124
|
+
*/
|
|
125
|
+
heading: Partial<HeadingOptions> | false;
|
|
126
|
+
/**
|
|
127
|
+
* If set to false, the horizontalRule extension will not be registered
|
|
128
|
+
* @example horizontalRule: false
|
|
129
|
+
*/
|
|
130
|
+
horizontalRule: Partial<HorizontalRuleOptions> | false;
|
|
131
|
+
/**
|
|
132
|
+
* If set to false, the italic extension will not be registered
|
|
133
|
+
* @example italic: false
|
|
134
|
+
*/
|
|
135
|
+
italic: Partial<ItalicOptions> | false;
|
|
136
|
+
/**
|
|
137
|
+
* If set to false, the listItem extension will not be registered
|
|
138
|
+
* @example listItem: false
|
|
139
|
+
*/
|
|
140
|
+
listItem: Partial<ListItemOptions> | false;
|
|
141
|
+
/**
|
|
142
|
+
* If set to false, the listItemKeymap extension will not be registered
|
|
143
|
+
* @example listKeymap: false
|
|
144
|
+
*/
|
|
145
|
+
listKeymap: Partial<ListKeymapOptions> | false;
|
|
146
|
+
/**
|
|
147
|
+
* If set to false, the link extension will not be registered
|
|
148
|
+
* @example link: false
|
|
149
|
+
*/
|
|
150
|
+
link: Partial<LinkOptions> | false;
|
|
151
|
+
/**
|
|
152
|
+
* If set to false, the orderedList extension will not be registered
|
|
153
|
+
* @example orderedList: false
|
|
154
|
+
*/
|
|
155
|
+
orderedList: Partial<OrderedListOptions> | false;
|
|
156
|
+
/**
|
|
157
|
+
* If set to false, the paragraph extension will not be registered
|
|
158
|
+
* @example paragraph: false
|
|
159
|
+
*/
|
|
160
|
+
paragraph: Partial<ParagraphOptions> | false;
|
|
161
|
+
/**
|
|
162
|
+
* If set to false, the strike extension will not be registered
|
|
163
|
+
* @example strike: false
|
|
164
|
+
*/
|
|
165
|
+
strike: Partial<StrikeOptions> | false;
|
|
166
|
+
/**
|
|
167
|
+
* If set to false, the text extension will not be registered
|
|
168
|
+
* @example text: false
|
|
169
|
+
*/
|
|
170
|
+
text: false;
|
|
171
|
+
/**
|
|
172
|
+
* If set to false, the textAlign extension will not be registered
|
|
173
|
+
* @example text: false
|
|
174
|
+
*/
|
|
175
|
+
textAlign: Partial<TextAlignOptions> | false;
|
|
176
|
+
/**
|
|
177
|
+
* If set to false, the underline extension will not be registered
|
|
178
|
+
* @example underline: false
|
|
179
|
+
*/
|
|
180
|
+
underline: Partial<UnderlineOptions> | false;
|
|
181
|
+
}
|
|
182
|
+
|
|
8
183
|
type FieldOption = {
|
|
9
184
|
label: string;
|
|
10
185
|
value: string | number | boolean | undefined | null | object;
|
|
11
186
|
};
|
|
12
187
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
13
|
-
|
|
188
|
+
interface BaseField {
|
|
14
189
|
label?: string;
|
|
15
190
|
labelIcon?: ReactElement;
|
|
16
|
-
metadata?:
|
|
191
|
+
metadata?: FieldMetadata;
|
|
17
192
|
visible?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
193
|
+
}
|
|
194
|
+
interface TextField extends BaseField {
|
|
20
195
|
type: "text";
|
|
21
196
|
placeholder?: string;
|
|
22
197
|
contentEditable?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
198
|
+
}
|
|
199
|
+
interface NumberField extends BaseField {
|
|
25
200
|
type: "number";
|
|
26
201
|
placeholder?: string;
|
|
27
202
|
min?: number;
|
|
28
203
|
max?: number;
|
|
29
204
|
step?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
205
|
+
}
|
|
206
|
+
interface TextareaField extends BaseField {
|
|
32
207
|
type: "textarea";
|
|
33
208
|
placeholder?: string;
|
|
34
209
|
contentEditable?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
210
|
+
}
|
|
211
|
+
interface SelectField extends BaseField {
|
|
37
212
|
type: "select";
|
|
38
213
|
options: FieldOptions;
|
|
39
|
-
}
|
|
40
|
-
|
|
214
|
+
}
|
|
215
|
+
interface RadioField extends BaseField {
|
|
41
216
|
type: "radio";
|
|
42
217
|
options: FieldOptions;
|
|
43
|
-
}
|
|
44
|
-
|
|
218
|
+
}
|
|
219
|
+
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
220
|
+
type: "richtext";
|
|
221
|
+
contentEditable?: boolean;
|
|
222
|
+
initialHeight?: CSSProperties["height"];
|
|
223
|
+
options?: Partial<PuckRichTextOptions>;
|
|
224
|
+
renderMenu?: (props: {
|
|
225
|
+
children: ReactNode;
|
|
226
|
+
editor: Editor | null;
|
|
227
|
+
editorState: EditorState<UserSelector> | null;
|
|
228
|
+
readOnly: boolean;
|
|
229
|
+
}) => ReactNode;
|
|
230
|
+
renderInlineMenu?: (props: {
|
|
231
|
+
children: ReactNode;
|
|
232
|
+
editor: Editor | null;
|
|
233
|
+
editorState: EditorState<UserSelector> | null;
|
|
234
|
+
readOnly: boolean;
|
|
235
|
+
}) => ReactNode;
|
|
236
|
+
tiptap?: {
|
|
237
|
+
selector?: UserSelector;
|
|
238
|
+
extensions?: Extensions;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface ArrayField<Props extends {
|
|
45
242
|
[key: string]: any;
|
|
46
243
|
}[] = {
|
|
47
244
|
[key: string]: any;
|
|
48
|
-
}[], UserField extends {} = {}>
|
|
245
|
+
}[], UserField extends {} = {}> extends BaseField {
|
|
49
246
|
type: "array";
|
|
50
247
|
arrayFields: {
|
|
51
248
|
[SubPropName in keyof Props[0]]: UserField extends {
|
|
52
249
|
type: PropertyKey;
|
|
53
250
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
251
|
};
|
|
55
|
-
defaultItemProps?: Props[0];
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
252
|
+
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
253
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
254
|
max?: number;
|
|
58
255
|
min?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
256
|
+
}
|
|
257
|
+
interface ObjectField<Props extends any = {
|
|
61
258
|
[key: string]: any;
|
|
62
|
-
}, UserField extends {} = {}>
|
|
259
|
+
}, UserField extends {} = {}> extends BaseField {
|
|
63
260
|
type: "object";
|
|
64
261
|
objectFields: {
|
|
65
262
|
[SubPropName in keyof Props]: UserField extends {
|
|
66
263
|
type: PropertyKey;
|
|
67
264
|
} ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
|
|
68
265
|
};
|
|
69
|
-
}
|
|
266
|
+
}
|
|
70
267
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
|
71
268
|
name: string;
|
|
72
269
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
@@ -80,12 +277,16 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
277
|
placeholder?: string;
|
|
81
278
|
adaptor: Adaptor<any, any, Props>;
|
|
82
279
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
280
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
281
|
+
};
|
|
282
|
+
type CacheOpts = {
|
|
283
|
+
enabled?: boolean;
|
|
84
284
|
};
|
|
85
|
-
|
|
285
|
+
interface ExternalField<Props extends any = {
|
|
86
286
|
[key: string]: any;
|
|
87
|
-
}>
|
|
287
|
+
}> extends BaseField {
|
|
88
288
|
type: "external";
|
|
289
|
+
cache?: CacheOpts;
|
|
89
290
|
placeholder?: string;
|
|
90
291
|
fetchList: (params: {
|
|
91
292
|
query: string;
|
|
@@ -93,7 +294,7 @@ type ExternalField<Props extends any = {
|
|
|
93
294
|
}) => Promise<any[] | null>;
|
|
94
295
|
mapProp?: (value: any) => Props;
|
|
95
296
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
96
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
297
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
97
298
|
showSearch?: boolean;
|
|
98
299
|
renderFooter?: (props: {
|
|
99
300
|
items: any[];
|
|
@@ -101,7 +302,7 @@ type ExternalField<Props extends any = {
|
|
|
101
302
|
initialQuery?: string;
|
|
102
303
|
filterFields?: Record<string, Field>;
|
|
103
304
|
initialFilters?: Record<string, any>;
|
|
104
|
-
}
|
|
305
|
+
}
|
|
105
306
|
type CustomFieldRender<Value extends any> = (props: {
|
|
106
307
|
field: CustomField<Value>;
|
|
107
308
|
name: string;
|
|
@@ -110,17 +311,18 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
110
311
|
onChange: (value: Value) => void;
|
|
111
312
|
readOnly?: boolean;
|
|
112
313
|
}) => ReactElement;
|
|
113
|
-
|
|
314
|
+
interface CustomField<Value extends any> extends BaseField {
|
|
114
315
|
type: "custom";
|
|
115
316
|
render: CustomFieldRender<Value>;
|
|
116
317
|
contentEditable?: boolean;
|
|
117
|
-
|
|
118
|
-
|
|
318
|
+
key?: string;
|
|
319
|
+
}
|
|
320
|
+
interface SlotField extends BaseField {
|
|
119
321
|
type: "slot";
|
|
120
322
|
allow?: string[];
|
|
121
323
|
disallow?: string[];
|
|
122
|
-
}
|
|
123
|
-
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
324
|
+
}
|
|
325
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
124
326
|
[key: string]: any;
|
|
125
327
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
126
328
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -141,13 +343,15 @@ type DropZoneProps = {
|
|
|
141
343
|
allow?: string[];
|
|
142
344
|
disallow?: string[];
|
|
143
345
|
style?: CSSProperties;
|
|
144
|
-
minEmptyHeight?: number;
|
|
346
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
145
347
|
className?: string;
|
|
146
348
|
collisionAxis?: DragAxis;
|
|
349
|
+
as?: ElementType;
|
|
350
|
+
ref?: Ref<any>;
|
|
147
351
|
};
|
|
148
352
|
|
|
149
353
|
type PuckContext = {
|
|
150
|
-
renderDropZone: React.
|
|
354
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
151
355
|
metadata: Metadata;
|
|
152
356
|
isEditing: boolean;
|
|
153
357
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -197,6 +401,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
197
401
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
198
402
|
props?: Partial<Props>;
|
|
199
403
|
};
|
|
404
|
+
interface ComponentConfigExtensions {
|
|
405
|
+
}
|
|
200
406
|
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.
|
|
201
407
|
UserField extends BaseField = {}> = {
|
|
202
408
|
render: PuckComponent<RenderProps>;
|
|
@@ -212,7 +418,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
418
|
fields: Fields<FieldProps>;
|
|
213
419
|
lastFields: Fields<FieldProps>;
|
|
214
420
|
lastData: DataShape | null;
|
|
215
|
-
metadata:
|
|
421
|
+
metadata: ComponentMetadata;
|
|
216
422
|
appState: AppState;
|
|
217
423
|
parent: ComponentData | null;
|
|
218
424
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -221,7 +427,7 @@ UserField extends BaseField = {}> = {
|
|
|
221
427
|
id: string;
|
|
222
428
|
}>;
|
|
223
429
|
lastData: DataShape | null;
|
|
224
|
-
metadata:
|
|
430
|
+
metadata: ComponentMetadata;
|
|
225
431
|
trigger: ResolveDataTrigger;
|
|
226
432
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
227
433
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -232,9 +438,10 @@ UserField extends BaseField = {}> = {
|
|
|
232
438
|
permissions: Partial<Permissions>;
|
|
233
439
|
appState: AppState;
|
|
234
440
|
lastData: DataShape | null;
|
|
441
|
+
parent: ComponentData | null;
|
|
235
442
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
236
|
-
metadata?:
|
|
237
|
-
};
|
|
443
|
+
metadata?: ComponentMetadata;
|
|
444
|
+
} & ComponentConfigExtensions;
|
|
238
445
|
type ComponentConfig<RenderPropsOrParams extends LeftOrExactRight<RenderPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends {
|
|
239
446
|
props: any;
|
|
240
447
|
} ? RenderPropsOrParams["props"] : RenderPropsOrParams, DataShape = Omit<ComponentData<FieldProps>, "type">> = RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, never> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, {}> : RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, infer ParamsFields> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, ParamsFields[keyof ParamsFields] & BaseField> : ComponentConfigInternal<RenderPropsOrParams, FieldProps, DataShape>;
|
|
@@ -265,6 +472,16 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
265
472
|
type: string;
|
|
266
473
|
} ? UserField : Field;
|
|
267
474
|
} : never;
|
|
475
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
476
|
+
components?: Components;
|
|
477
|
+
root?: RootProps;
|
|
478
|
+
categories?: CategoryNames;
|
|
479
|
+
fields?: AssertHasValue<UserFields>;
|
|
480
|
+
};
|
|
481
|
+
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
482
|
+
props: Props;
|
|
483
|
+
fields?: AssertHasValue<UserFields>;
|
|
484
|
+
};
|
|
268
485
|
|
|
269
486
|
type BaseData<Props extends {
|
|
270
487
|
[key: string]: any;
|
|
@@ -305,10 +522,17 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
305
522
|
type Metadata = {
|
|
306
523
|
[key: string]: any;
|
|
307
524
|
};
|
|
525
|
+
interface PuckMetadata extends Metadata {
|
|
526
|
+
}
|
|
527
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
528
|
+
}
|
|
529
|
+
interface FieldMetadata extends Metadata {
|
|
530
|
+
}
|
|
308
531
|
|
|
309
532
|
type ItemWithId = {
|
|
310
533
|
_arrayId: string;
|
|
311
534
|
_originalIndex: number;
|
|
535
|
+
_currentIndex: number;
|
|
312
536
|
};
|
|
313
537
|
type ArrayState = {
|
|
314
538
|
items: ItemWithId[];
|
|
@@ -319,6 +543,7 @@ type UiState = {
|
|
|
319
543
|
rightSideBarVisible: boolean;
|
|
320
544
|
leftSideBarWidth?: number | null;
|
|
321
545
|
rightSideBarWidth?: number | null;
|
|
546
|
+
mobilePanelExpanded?: boolean;
|
|
322
547
|
itemSelector: ItemSelector | null;
|
|
323
548
|
arrayState: Record<string, ArrayState | undefined>;
|
|
324
549
|
previewMode: "interactive" | "edit";
|
|
@@ -331,7 +556,7 @@ type UiState = {
|
|
|
331
556
|
isDragging: boolean;
|
|
332
557
|
viewports: {
|
|
333
558
|
current: {
|
|
334
|
-
width: number;
|
|
559
|
+
width: number | "100%";
|
|
335
560
|
height: number | "auto";
|
|
336
561
|
};
|
|
337
562
|
controlsVisible: boolean;
|
|
@@ -339,6 +564,10 @@ type UiState = {
|
|
|
339
564
|
};
|
|
340
565
|
field: {
|
|
341
566
|
focus?: string | null;
|
|
567
|
+
metadata?: Record<string, any>;
|
|
568
|
+
};
|
|
569
|
+
plugin: {
|
|
570
|
+
current: string | null;
|
|
342
571
|
};
|
|
343
572
|
};
|
|
344
573
|
type AppState<UserData extends Data = Data> = {
|
|
@@ -373,26 +602,25 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
373
602
|
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 ? {
|
|
374
603
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
375
604
|
} : T;
|
|
376
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
377
|
-
components?: Components;
|
|
378
|
-
root?: RootProps;
|
|
379
|
-
categories?: CategoryNames;
|
|
380
|
-
fields?: AssertHasValue<UserFields>;
|
|
381
|
-
};
|
|
382
605
|
type FieldsExtension = {
|
|
383
606
|
[Type in string]: {
|
|
384
607
|
type: Type;
|
|
385
608
|
};
|
|
386
609
|
};
|
|
387
|
-
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
388
|
-
props: Props;
|
|
389
|
-
fields?: AssertHasValue<UserFields>;
|
|
390
|
-
};
|
|
391
610
|
type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
|
|
392
611
|
type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
|
|
393
612
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
394
613
|
never
|
|
395
614
|
] ? False : True;
|
|
615
|
+
type RenderFunc<Props extends {
|
|
616
|
+
[key: string]: any;
|
|
617
|
+
} = {
|
|
618
|
+
children: ReactNode;
|
|
619
|
+
}> = (props: Props) => ReactElement;
|
|
620
|
+
type PluginInternal = Plugin & {
|
|
621
|
+
mobileOnly?: boolean;
|
|
622
|
+
desktopOnly?: boolean;
|
|
623
|
+
};
|
|
396
624
|
|
|
397
625
|
type MapFnParams<ThisField = Field> = {
|
|
398
626
|
value: any;
|
|
@@ -416,11 +644,6 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
416
644
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
417
645
|
}>;
|
|
418
646
|
|
|
419
|
-
type RenderFunc<Props extends {
|
|
420
|
-
[key: string]: any;
|
|
421
|
-
} = {
|
|
422
|
-
children: ReactNode;
|
|
423
|
-
}> = (props: Props) => ReactElement;
|
|
424
647
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
425
648
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
426
649
|
type OverridesGeneric<Shape extends {
|
|
@@ -492,7 +715,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
492
715
|
|
|
493
716
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
494
717
|
type Viewport = {
|
|
495
|
-
width: number;
|
|
718
|
+
width: number | "100%";
|
|
496
719
|
height?: number | "auto";
|
|
497
720
|
label?: string;
|
|
498
721
|
icon?: iconTypes | ReactNode;
|
|
@@ -512,8 +735,13 @@ type IframeConfig = {
|
|
|
512
735
|
};
|
|
513
736
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
514
737
|
type Plugin<UserConfig extends Config = Config> = {
|
|
738
|
+
name?: string;
|
|
739
|
+
label?: string;
|
|
740
|
+
icon?: ReactNode;
|
|
741
|
+
render?: () => ReactElement;
|
|
515
742
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
516
743
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
744
|
+
mobilePanelHeight?: "toggle" | "min-content";
|
|
517
745
|
};
|
|
518
746
|
type History<D = any> = {
|
|
519
747
|
state: D;
|
|
@@ -538,6 +766,7 @@ type Slot<Props extends {
|
|
|
538
766
|
[K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
|
|
539
767
|
}[keyof Props][];
|
|
540
768
|
type WithSlotProps<Target extends Record<string, any>, Components extends DefaultComponents = DefaultComponents, SlotType extends Content<Components> = Content<Components>> = WithDeepSlots<Target, SlotType>;
|
|
769
|
+
type RichText = string | ReactNode;
|
|
541
770
|
|
|
542
771
|
type InsertAction = {
|
|
543
772
|
type: "insert";
|
|
@@ -605,30 +834,4 @@ type PuckAction = {
|
|
|
605
834
|
recordHistory?: boolean;
|
|
606
835
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
607
836
|
|
|
608
|
-
type
|
|
609
|
-
migrateDynamicZonesForComponent?: {
|
|
610
|
-
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
611
|
-
};
|
|
612
|
-
};
|
|
613
|
-
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
614
|
-
|
|
615
|
-
type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
616
|
-
[ComponentName in keyof Components]: (props: Components[ComponentName] & {
|
|
617
|
-
[key: string]: any;
|
|
618
|
-
}) => Components[ComponentName];
|
|
619
|
-
} & {
|
|
620
|
-
root: (props: RootProps & {
|
|
621
|
-
[key: string]: any;
|
|
622
|
-
}) => RootProps;
|
|
623
|
-
}>;
|
|
624
|
-
declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
|
|
625
|
-
|
|
626
|
-
declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
|
|
627
|
-
|
|
628
|
-
type WalkTreeOptions = {
|
|
629
|
-
parentId: string;
|
|
630
|
-
propName: string;
|
|
631
|
-
};
|
|
632
|
-
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
633
|
-
|
|
634
|
-
export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type ExternalField as a9, type CustomFieldRender as aa, type CustomField as ab, type SlotField as ac, type PuckContext as ad, type DefaultRootFieldProps as ae, type DefaultRootRenderProps as af, type DefaultRootProps as ag, type DefaultComponentProps as ah, type WithId as ai, type WithPuckProps as aj, type AsFieldProps as ak, type WithChildren as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
|
|
837
|
+
export { type ComponentConfigParams as $, type AppState as A, type FieldTransformFnParams as B, type Config as C, type Data as D, type FieldTransformFn as E, type Fields as F, overrideKeys as G, type History as H, type IframeConfig as I, type OverrideKey as J, type FieldRenderFunctions as K, type ItemWithId as L, type Metadata as M, type ArrayState as N, type OnAction as O, type PrivateAppState as P, type SlotComponent as Q, type RootData as R, type Slot as S, type PuckComponent as T, type UserGenerics as U, type Viewports as V, type WithId as W, type ComponentConfigExtensions as X, type RootConfig as Y, type ExtractConfigParams as Z, type ConfigParams as _, type PuckAction as a, type BaseData as a0, type RootDataWithoutProps as a1, type ComponentDataOptionalId as a2, type MappedItem as a3, type ComponentDataMap as a4, type PuckMetadata as a5, type ComponentMetadata as a6, type FieldMetadata as a7, type BaseField as a8, type TextField as a9, type NumberField as aa, type TextareaField as ab, type SelectField as ac, type RadioField as ad, type ArrayField as ae, type ObjectField as af, type Adaptor as ag, type ExternalFieldWithAdaptor as ah, type CacheOpts as ai, type ExternalField as aj, type CustomFieldRender as ak, type CustomField as al, type SlotField as am, type PuckContext as an, type DefaultRootRenderProps as ao, type DefaultRootProps as ap, type WithPuckProps as aq, type AsFieldProps as ar, type WithChildren as as, type ExtractField as at, type Content as b, type ComponentData as c, type DefaultComponents as d, type DefaultComponentProps as e, type DefaultRootFieldProps as f, type Permissions as g, type RootDataWithProps as h, type ResolveDataTrigger as i, type Plugin as j, type Overrides as k, type UiState as l, type ComponentConfig as m, type FieldTransforms as n, type RichtextField as o, type Field as p, type FieldProps as q, type DropZoneProps as r, type InitialHistory as s, type ItemSelector as t, type PluginInternal as u, type WithSlotProps as v, type RichText as w, type Direction as x, type DragAxis as y, type Viewport as z };
|