@netlisian/softconfig 0.1.0 → 0.1.2
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/puck/index.css +95 -38
- package/dist/puck/index.d.mts +54 -13
- package/dist/puck/index.d.ts +54 -13
- package/dist/puck/index.js +358 -110
- package/dist/puck/index.mjs +346 -101
- package/package.json +1 -1
package/dist/puck/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* css-module:/media/
|
|
1
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/error-boundary/styles.module.css/#css-module-data */
|
|
2
2
|
._ErrorBoundary_1xl05_5 {
|
|
3
3
|
padding: 20px;
|
|
4
4
|
border: 1px solid #ff5858;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
background-color: #b71c1c;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/* css-module:/media/
|
|
29
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css/#css-module-data */
|
|
30
30
|
._Header_19oj9_1 {
|
|
31
31
|
display: flex;
|
|
32
32
|
justify-content: space-between;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
flex-wrap: wrap;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/* css-module:/media/
|
|
38
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css/#css-module-data */
|
|
39
39
|
._ActionBar_pvuie_5 {
|
|
40
40
|
align-items: center;
|
|
41
41
|
cursor: default;
|
|
@@ -119,8 +119,8 @@
|
|
|
119
119
|
margin: 0;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/* css-module:/media/
|
|
123
|
-
.
|
|
122
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/DrawerItem.module.css/#css-module-data */
|
|
123
|
+
._DrawerItem_29z19_1 {
|
|
124
124
|
background: var(--puck-color-white);
|
|
125
125
|
cursor: grab;
|
|
126
126
|
border: 1px solid var(--puck-color-grey-09);
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
transition: background-color 50ms ease-in, color 50ms ease-in;
|
|
133
133
|
display: flex;
|
|
134
134
|
}
|
|
135
|
-
.
|
|
135
|
+
._DrawerItem--insertDisabled_29z19_14 {
|
|
136
136
|
cursor: not-allowed;
|
|
137
137
|
color: var(--puck-color-grey-5);
|
|
138
138
|
background: var(--puck-color-grey-11);
|
|
139
139
|
pointer-events: none;
|
|
140
140
|
}
|
|
141
|
-
.
|
|
141
|
+
._DrawerItem-content_29z19_21 {
|
|
142
142
|
flex: 1;
|
|
143
143
|
display: flex;
|
|
144
144
|
flex-direction: column;
|
|
@@ -147,53 +147,53 @@
|
|
|
147
147
|
white-space: nowrap;
|
|
148
148
|
overflow-x: hidden;
|
|
149
149
|
}
|
|
150
|
-
.
|
|
150
|
+
._DrawerItem-name_29z19_31 {
|
|
151
151
|
font-weight: 400;
|
|
152
152
|
}
|
|
153
|
-
.
|
|
153
|
+
._DrawerItem-version_29z19_35 {
|
|
154
154
|
font-size: 10px;
|
|
155
155
|
color: var(--puck-color-grey-05);
|
|
156
156
|
}
|
|
157
|
-
.
|
|
157
|
+
._DrawerItem-actions_29z19_40 {
|
|
158
158
|
display: flex;
|
|
159
159
|
align-items: center;
|
|
160
160
|
gap: 8px;
|
|
161
161
|
}
|
|
162
|
-
.
|
|
162
|
+
._DrawerItem-settingsButton_29z19_46 {
|
|
163
163
|
opacity: 0;
|
|
164
164
|
transition: opacity 120ms ease;
|
|
165
165
|
color: var(--puck-color-grey-05);
|
|
166
166
|
}
|
|
167
|
-
.
|
|
167
|
+
._DrawerItem_29z19_1:hover ._DrawerItem-settingsButton_29z19_46 {
|
|
168
168
|
opacity: 1;
|
|
169
169
|
}
|
|
170
|
-
.
|
|
170
|
+
._DrawerItem-grip_29z19_56 {
|
|
171
171
|
color: var(--puck-color-grey-05);
|
|
172
172
|
display: flex;
|
|
173
173
|
align-items: center;
|
|
174
174
|
}
|
|
175
|
-
.
|
|
175
|
+
._DrawerItem-modal_29z19_63 {
|
|
176
176
|
background: var(--puck-color-white);
|
|
177
177
|
display: flex;
|
|
178
178
|
flex-direction: column;
|
|
179
179
|
height: 100%;
|
|
180
180
|
}
|
|
181
|
-
.
|
|
181
|
+
._DrawerItem-modalHeader_29z19_70 {
|
|
182
182
|
padding: 24px 32px;
|
|
183
183
|
border-bottom: 1px solid var(--puck-color-grey-09);
|
|
184
184
|
}
|
|
185
|
-
.
|
|
185
|
+
._DrawerItem-modalTitle_29z19_75 {
|
|
186
186
|
margin: 0 0 4px 0;
|
|
187
187
|
font-size: 24px;
|
|
188
188
|
font-weight: 600;
|
|
189
189
|
color: var(--puck-color-black);
|
|
190
190
|
}
|
|
191
|
-
.
|
|
191
|
+
._DrawerItem-modalSubtitle_29z19_82 {
|
|
192
192
|
margin: 0;
|
|
193
193
|
font-size: 14px;
|
|
194
194
|
color: var(--puck-color-grey-04);
|
|
195
195
|
}
|
|
196
|
-
.
|
|
196
|
+
._DrawerItem-modalBody_29z19_88 {
|
|
197
197
|
flex: 1;
|
|
198
198
|
padding: 32px;
|
|
199
199
|
overflow-y: auto;
|
|
@@ -201,28 +201,28 @@
|
|
|
201
201
|
flex-direction: column;
|
|
202
202
|
gap: 32px;
|
|
203
203
|
}
|
|
204
|
-
.
|
|
204
|
+
._DrawerItem-section_29z19_97 {
|
|
205
205
|
display: flex;
|
|
206
206
|
flex-direction: column;
|
|
207
207
|
gap: 16px;
|
|
208
208
|
}
|
|
209
|
-
.
|
|
209
|
+
._DrawerItem-sectionTitle_29z19_103 {
|
|
210
210
|
margin: 0;
|
|
211
211
|
font-size: 16px;
|
|
212
212
|
font-weight: 600;
|
|
213
213
|
color: var(--puck-color-black);
|
|
214
214
|
}
|
|
215
|
-
.
|
|
215
|
+
._DrawerItem-sectionDescription_29z19_110 {
|
|
216
216
|
margin: 0;
|
|
217
217
|
font-size: 14px;
|
|
218
218
|
color: var(--puck-color-grey-04);
|
|
219
219
|
}
|
|
220
|
-
.
|
|
220
|
+
._DrawerItem-versionList_29z19_116 {
|
|
221
221
|
display: flex;
|
|
222
222
|
flex-direction: column;
|
|
223
223
|
gap: 8px;
|
|
224
224
|
}
|
|
225
|
-
.
|
|
225
|
+
._DrawerItem-versionRow_29z19_122 {
|
|
226
226
|
display: flex;
|
|
227
227
|
justify-content: space-between;
|
|
228
228
|
align-items: center;
|
|
@@ -232,26 +232,26 @@
|
|
|
232
232
|
background: var(--puck-color-white);
|
|
233
233
|
transition: all 150ms ease;
|
|
234
234
|
}
|
|
235
|
-
.
|
|
235
|
+
._DrawerItem-versionRow--isDefault_29z19_133 {
|
|
236
236
|
border-color: var(--puck-color-azure-07);
|
|
237
237
|
background: var(--puck-color-azure-10);
|
|
238
238
|
}
|
|
239
|
-
.
|
|
239
|
+
._DrawerItem-versionRow--isMarkedForDeletion_29z19_138 {
|
|
240
240
|
opacity: 0.6;
|
|
241
241
|
background: var(--puck-color-grey-11);
|
|
242
242
|
}
|
|
243
|
-
.
|
|
243
|
+
._DrawerItem-versionInfo_29z19_143 {
|
|
244
244
|
display: flex;
|
|
245
245
|
align-items: center;
|
|
246
246
|
gap: 12px;
|
|
247
247
|
flex: 1;
|
|
248
248
|
}
|
|
249
|
-
.
|
|
249
|
+
._DrawerItem-versionNumber_29z19_150 {
|
|
250
250
|
font-size: 14px;
|
|
251
251
|
font-weight: 500;
|
|
252
252
|
color: var(--puck-color-black);
|
|
253
253
|
}
|
|
254
|
-
.
|
|
254
|
+
._DrawerItem-defaultBadge_29z19_156 {
|
|
255
255
|
font-size: 11px;
|
|
256
256
|
padding: 3px 8px;
|
|
257
257
|
border-radius: 4px;
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
text-transform: uppercase;
|
|
262
262
|
letter-spacing: 0.5px;
|
|
263
263
|
}
|
|
264
|
-
.
|
|
264
|
+
._DrawerItem-deleteBadge_29z19_167 {
|
|
265
265
|
font-size: 11px;
|
|
266
266
|
padding: 3px 8px;
|
|
267
267
|
border-radius: 4px;
|
|
@@ -271,15 +271,15 @@
|
|
|
271
271
|
text-transform: uppercase;
|
|
272
272
|
letter-spacing: 0.5px;
|
|
273
273
|
}
|
|
274
|
-
.
|
|
274
|
+
._DrawerItem-versionActions_29z19_178 {
|
|
275
275
|
display: flex;
|
|
276
276
|
gap: 8px;
|
|
277
277
|
align-items: center;
|
|
278
278
|
}
|
|
279
|
-
.
|
|
279
|
+
._DrawerItem-migrationOptions_29z19_184 {
|
|
280
280
|
width: 100%;
|
|
281
281
|
}
|
|
282
|
-
.
|
|
282
|
+
._DrawerItem-select_29z19_188 {
|
|
283
283
|
width: 100%;
|
|
284
284
|
padding: 10px 12px;
|
|
285
285
|
border: 1px solid var(--puck-color-grey-09);
|
|
@@ -290,14 +290,14 @@
|
|
|
290
290
|
cursor: pointer;
|
|
291
291
|
transition: border-color 150ms ease;
|
|
292
292
|
}
|
|
293
|
-
.
|
|
293
|
+
._DrawerItem-select_29z19_188:hover {
|
|
294
294
|
border-color: var(--puck-color-grey-07);
|
|
295
295
|
}
|
|
296
|
-
.
|
|
296
|
+
._DrawerItem-select_29z19_188:focus {
|
|
297
297
|
outline: none;
|
|
298
298
|
border-color: var(--puck-color-azure-07);
|
|
299
299
|
}
|
|
300
|
-
.
|
|
300
|
+
._DrawerItem-modalFooter_29z19_209 {
|
|
301
301
|
padding: 20px 32px;
|
|
302
302
|
border-top: 1px solid var(--puck-color-grey-09);
|
|
303
303
|
display: flex;
|
|
@@ -305,16 +305,16 @@
|
|
|
305
305
|
align-items: center;
|
|
306
306
|
background: var(--puck-color-grey-11);
|
|
307
307
|
}
|
|
308
|
-
.
|
|
308
|
+
._DrawerItem-footerLeft_29z19_218 {
|
|
309
309
|
display: flex;
|
|
310
310
|
gap: 12px;
|
|
311
311
|
}
|
|
312
|
-
.
|
|
312
|
+
._DrawerItem-footerRight_29z19_223 {
|
|
313
313
|
display: flex;
|
|
314
314
|
gap: 12px;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
/* css-module:/media/
|
|
317
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css/#css-module-data */
|
|
318
318
|
._Modal_pvj02_1 {
|
|
319
319
|
background: color-mix(in srgb, var(--puck-color-black) 75%, transparent);
|
|
320
320
|
display: none;
|
|
@@ -341,3 +341,60 @@
|
|
|
341
341
|
flex-direction: column;
|
|
342
342
|
max-height: 90dvh;
|
|
343
343
|
}
|
|
344
|
+
|
|
345
|
+
/* css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Drawer.module.css/#css-module-data */
|
|
346
|
+
._Drawer_12zq5_1 {
|
|
347
|
+
display: flex;
|
|
348
|
+
flex-direction: column;
|
|
349
|
+
gap: 0;
|
|
350
|
+
}
|
|
351
|
+
._Drawer-category_12zq5_7 {
|
|
352
|
+
max-width: 100%;
|
|
353
|
+
}
|
|
354
|
+
._Drawer-category_12zq5_7 + ._Drawer-category_12zq5_7 {
|
|
355
|
+
margin-top: 4px;
|
|
356
|
+
}
|
|
357
|
+
._Drawer-category--isExpanded_12zq5_15 + ._Drawer-category_12zq5_7 {
|
|
358
|
+
margin-top: 12px;
|
|
359
|
+
}
|
|
360
|
+
._Drawer-categoryContent_12zq5_19 {
|
|
361
|
+
display: none;
|
|
362
|
+
}
|
|
363
|
+
._Drawer-category--isExpanded_12zq5_15 > ._Drawer-categoryContent_12zq5_19 {
|
|
364
|
+
display: block;
|
|
365
|
+
}
|
|
366
|
+
._Drawer-categoryTitle_12zq5_27 {
|
|
367
|
+
background-color: transparent;
|
|
368
|
+
border: 0;
|
|
369
|
+
color: var(--puck-color-grey-05);
|
|
370
|
+
cursor: pointer;
|
|
371
|
+
display: flex;
|
|
372
|
+
font: inherit;
|
|
373
|
+
font-size: var(--puck-font-size-xxxs);
|
|
374
|
+
list-style: none;
|
|
375
|
+
margin-bottom: 6px;
|
|
376
|
+
padding: 8px;
|
|
377
|
+
text-transform: uppercase;
|
|
378
|
+
transition: background-color 50ms ease-in, color 50ms ease-in;
|
|
379
|
+
gap: 4px;
|
|
380
|
+
border-radius: 4px;
|
|
381
|
+
width: 100%;
|
|
382
|
+
}
|
|
383
|
+
._Drawer-categoryTitle_12zq5_27:focus-visible {
|
|
384
|
+
outline: 2px solid var(--puck-color-azure-05);
|
|
385
|
+
outline-offset: 2px;
|
|
386
|
+
}
|
|
387
|
+
@media (hover: hover) and (pointer: fine) {
|
|
388
|
+
._Drawer-categoryTitle_12zq5_27:hover {
|
|
389
|
+
background-color: var(--puck-color-azure-11);
|
|
390
|
+
color: var(--puck-color-azure-04);
|
|
391
|
+
transition: none;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
._Drawer-categoryTitle_12zq5_27:active {
|
|
395
|
+
background-color: var(--puck-color-azure-10);
|
|
396
|
+
transition: none;
|
|
397
|
+
}
|
|
398
|
+
._Drawer-categoryTitleIcon_12zq5_63 {
|
|
399
|
+
margin-inline-start: auto;
|
|
400
|
+
}
|
package/dist/puck/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
2
|
import { StoreApi } from 'zustand';
|
|
3
|
-
import { History, AppState, PuckApi, ComponentData, ComponentConfig, DefaultComponentProps, Field, Config, Fields, PuckAction, Data } from '@measured/puck';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
3
|
+
import { History, AppState, PuckApi, ComponentData, ComponentConfig, DefaultComponentProps, Field, Config, Fields, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data } from '@measured/puck';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
import React__default, { ReactNode, ReactElement } from 'react';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
type BuildersSlice = {
|
|
@@ -21,7 +21,7 @@ type BuildersSlice = {
|
|
|
21
21
|
build: (history: History<AppState>[], selectedItem: PuckApi["selectedItem"], itemSelector: {
|
|
22
22
|
index: number;
|
|
23
23
|
zone?: string;
|
|
24
|
-
} | null, puckDispatch: PuckApi["dispatch"]) => void | null;
|
|
24
|
+
} | null, puckDispatch: PuckApi["dispatch"], name?: string) => void | null;
|
|
25
25
|
/**
|
|
26
26
|
* Remodel the selected soft component by decomposing it and resetting as root.
|
|
27
27
|
*
|
|
@@ -77,7 +77,7 @@ type BuildersSlice = {
|
|
|
77
77
|
/** Compose multiple components into a soft component.
|
|
78
78
|
* 1. SoftComponent: Get soft fields + default values from the appState.root + sub-component maps + fixedProps
|
|
79
79
|
*/
|
|
80
|
-
compose: (appState: AppState, componentName: string, editedItem: ComponentData) => [ComponentConfig, string] | undefined;
|
|
80
|
+
compose: (appState: AppState, componentName: string, editedItem: ComponentData, displayName: string, category?: string) => [ComponentConfig, string] | undefined;
|
|
81
81
|
/** Break down a composed component into its parts.
|
|
82
82
|
* 1. Get softComponentProps
|
|
83
83
|
* 2. Create a virtual component with all the props from soft-component.
|
|
@@ -88,6 +88,7 @@ type BuildersSlice = {
|
|
|
88
88
|
|
|
89
89
|
type BuilderRootConfig = {
|
|
90
90
|
_name: string;
|
|
91
|
+
_category?: string;
|
|
91
92
|
_version?: string;
|
|
92
93
|
_versions?: string[];
|
|
93
94
|
_fields?: {
|
|
@@ -125,6 +126,8 @@ type SoftSubComponent = {
|
|
|
125
126
|
}[];
|
|
126
127
|
}[];
|
|
127
128
|
type SoftComponent = {
|
|
129
|
+
name: string;
|
|
130
|
+
category?: string;
|
|
128
131
|
fields: Fields;
|
|
129
132
|
fieldSettings?: Record<string, any>;
|
|
130
133
|
defaultProps: DefaultComponentProps;
|
|
@@ -135,6 +138,8 @@ type SoftComponent = {
|
|
|
135
138
|
};
|
|
136
139
|
type VersionedSoftComponent = {
|
|
137
140
|
defaultVersion: string;
|
|
141
|
+
name: string;
|
|
142
|
+
category?: string;
|
|
138
143
|
versions: {
|
|
139
144
|
[version: string]: {
|
|
140
145
|
fields: Fields;
|
|
@@ -170,8 +175,8 @@ type ActionEventPayload = {
|
|
|
170
175
|
type: "complete";
|
|
171
176
|
payload: {
|
|
172
177
|
id: string;
|
|
173
|
-
componentData:
|
|
174
|
-
softComponent:
|
|
178
|
+
componentData: Record<string, any>;
|
|
179
|
+
softComponent: VersionedSoftComponent["versions"][string];
|
|
175
180
|
};
|
|
176
181
|
} | {
|
|
177
182
|
type: "cancel";
|
|
@@ -212,6 +217,10 @@ type RenderFunc<Props extends {
|
|
|
212
217
|
children: ReactNode;
|
|
213
218
|
}> = (props: Props) => ReactElement;
|
|
214
219
|
type Overrides = {
|
|
220
|
+
componentNameToKey?: (displayName: string, context: {
|
|
221
|
+
existingKeys: string[];
|
|
222
|
+
state: "building" | "remodeling" | "ready" | "inspecting";
|
|
223
|
+
}) => string;
|
|
215
224
|
map?: RenderFunc<{
|
|
216
225
|
rootProps: BuilderRootConfig;
|
|
217
226
|
toOptions: {
|
|
@@ -236,6 +245,16 @@ type Overrides = {
|
|
|
236
245
|
softComponent: VersionedSoftComponent["versions"][string];
|
|
237
246
|
}) => ((inputs: any[], props: DefaultComponentProps) => any) | undefined;
|
|
238
247
|
onActions?: OnActionsCallback;
|
|
248
|
+
name?: Field<string>;
|
|
249
|
+
categories?: Field<string | undefined>;
|
|
250
|
+
onRootsDataChange?: (data: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>, params: {
|
|
251
|
+
changed: Partial<Record<keyof BuilderRootConfig, boolean> & {
|
|
252
|
+
id: string;
|
|
253
|
+
}>;
|
|
254
|
+
lastData: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | null;
|
|
255
|
+
metadata: Metadata;
|
|
256
|
+
trigger: ResolveDataTrigger;
|
|
257
|
+
}) => void;
|
|
239
258
|
};
|
|
240
259
|
|
|
241
260
|
type Status = "building" | "remodeling" | "ready" | "inspecting";
|
|
@@ -342,7 +361,7 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overr
|
|
|
342
361
|
declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
343
362
|
declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
344
363
|
|
|
345
|
-
declare const useBuild: () => {
|
|
364
|
+
declare const useBuild: (name?: string) => {
|
|
346
365
|
handleBuild: () => void;
|
|
347
366
|
canBuild: boolean;
|
|
348
367
|
};
|
|
@@ -356,7 +375,7 @@ declare const useComplete: () => {
|
|
|
356
375
|
handleComplete: () => string | null;
|
|
357
376
|
canComplete: boolean;
|
|
358
377
|
newComponent: string | null;
|
|
359
|
-
setNewComponent:
|
|
378
|
+
setNewComponent: React$1.Dispatch<React$1.SetStateAction<string | null>>;
|
|
360
379
|
};
|
|
361
380
|
|
|
362
381
|
declare const useCancel: () => {
|
|
@@ -385,20 +404,42 @@ declare const useSetDefaultVersion: () => {
|
|
|
385
404
|
|
|
386
405
|
declare const Header: ({ onPublish, children, }: {
|
|
387
406
|
onPublish?: (data: Data, softComponents: SoftComponents) => void;
|
|
388
|
-
children:
|
|
407
|
+
children: React__default.ReactNode;
|
|
389
408
|
}) => react_jsx_runtime.JSX.Element;
|
|
390
409
|
|
|
391
410
|
declare const ActionBarOverride: (props: {
|
|
392
411
|
label?: string;
|
|
393
|
-
parentAction?:
|
|
394
|
-
children?:
|
|
412
|
+
parentAction?: React__default.ReactNode;
|
|
413
|
+
children?: React__default.ReactNode;
|
|
395
414
|
}) => react_jsx_runtime.JSX.Element;
|
|
396
415
|
|
|
416
|
+
declare const DrawerItem: (props: {
|
|
417
|
+
name: string;
|
|
418
|
+
children: React.ReactNode;
|
|
419
|
+
}) => React.ReactElement;
|
|
420
|
+
/** @deprecated Use DrawerItem instead */
|
|
397
421
|
declare const ComponentItem: (props: {
|
|
398
422
|
name: string;
|
|
399
423
|
children: React.ReactNode;
|
|
400
424
|
}) => React.ReactElement;
|
|
401
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Drawer — custom drawer override for the Puck editor.
|
|
428
|
+
*
|
|
429
|
+
* Reads config.categories from puck and renders a collapsible section per
|
|
430
|
+
* category, each containing a PuckDrawer with DrawerItem as the item
|
|
431
|
+
* renderer (soft-config versioning, demolish, and settings modal included).
|
|
432
|
+
* Components not assigned to any category render under "Other components".
|
|
433
|
+
*
|
|
434
|
+
* Falls back to a flat list when no categories are defined.
|
|
435
|
+
*
|
|
436
|
+
* Usage:
|
|
437
|
+
* overrides={{ drawer: Drawer }}
|
|
438
|
+
*/
|
|
439
|
+
declare const Drawer: (_props: {
|
|
440
|
+
children?: React__default.ReactNode;
|
|
441
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
442
|
+
|
|
402
443
|
type NotificationHandler = (message: string, type: "error" | "success") => void;
|
|
403
444
|
declare const setNotificationHandler: (handler: NotificationHandler) => void;
|
|
404
445
|
declare const notify: {
|
|
@@ -453,4 +494,4 @@ declare const Modal: ({ children, onClose, isOpen, }: {
|
|
|
453
494
|
isOpen: boolean;
|
|
454
495
|
}) => react_jsx_runtime.JSX.Element;
|
|
455
496
|
|
|
456
|
-
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Header, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type VersionedSoftComponent, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|
|
497
|
+
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, Drawer, DrawerItem, Header, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type VersionedSoftComponent, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|
package/dist/puck/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
2
|
import { StoreApi } from 'zustand';
|
|
3
|
-
import { History, AppState, PuckApi, ComponentData, ComponentConfig, DefaultComponentProps, Field, Config, Fields, PuckAction, Data } from '@measured/puck';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
3
|
+
import { History, AppState, PuckApi, ComponentData, ComponentConfig, DefaultComponentProps, Field, Config, Fields, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data } from '@measured/puck';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
import React__default, { ReactNode, ReactElement } from 'react';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
type BuildersSlice = {
|
|
@@ -21,7 +21,7 @@ type BuildersSlice = {
|
|
|
21
21
|
build: (history: History<AppState>[], selectedItem: PuckApi["selectedItem"], itemSelector: {
|
|
22
22
|
index: number;
|
|
23
23
|
zone?: string;
|
|
24
|
-
} | null, puckDispatch: PuckApi["dispatch"]) => void | null;
|
|
24
|
+
} | null, puckDispatch: PuckApi["dispatch"], name?: string) => void | null;
|
|
25
25
|
/**
|
|
26
26
|
* Remodel the selected soft component by decomposing it and resetting as root.
|
|
27
27
|
*
|
|
@@ -77,7 +77,7 @@ type BuildersSlice = {
|
|
|
77
77
|
/** Compose multiple components into a soft component.
|
|
78
78
|
* 1. SoftComponent: Get soft fields + default values from the appState.root + sub-component maps + fixedProps
|
|
79
79
|
*/
|
|
80
|
-
compose: (appState: AppState, componentName: string, editedItem: ComponentData) => [ComponentConfig, string] | undefined;
|
|
80
|
+
compose: (appState: AppState, componentName: string, editedItem: ComponentData, displayName: string, category?: string) => [ComponentConfig, string] | undefined;
|
|
81
81
|
/** Break down a composed component into its parts.
|
|
82
82
|
* 1. Get softComponentProps
|
|
83
83
|
* 2. Create a virtual component with all the props from soft-component.
|
|
@@ -88,6 +88,7 @@ type BuildersSlice = {
|
|
|
88
88
|
|
|
89
89
|
type BuilderRootConfig = {
|
|
90
90
|
_name: string;
|
|
91
|
+
_category?: string;
|
|
91
92
|
_version?: string;
|
|
92
93
|
_versions?: string[];
|
|
93
94
|
_fields?: {
|
|
@@ -125,6 +126,8 @@ type SoftSubComponent = {
|
|
|
125
126
|
}[];
|
|
126
127
|
}[];
|
|
127
128
|
type SoftComponent = {
|
|
129
|
+
name: string;
|
|
130
|
+
category?: string;
|
|
128
131
|
fields: Fields;
|
|
129
132
|
fieldSettings?: Record<string, any>;
|
|
130
133
|
defaultProps: DefaultComponentProps;
|
|
@@ -135,6 +138,8 @@ type SoftComponent = {
|
|
|
135
138
|
};
|
|
136
139
|
type VersionedSoftComponent = {
|
|
137
140
|
defaultVersion: string;
|
|
141
|
+
name: string;
|
|
142
|
+
category?: string;
|
|
138
143
|
versions: {
|
|
139
144
|
[version: string]: {
|
|
140
145
|
fields: Fields;
|
|
@@ -170,8 +175,8 @@ type ActionEventPayload = {
|
|
|
170
175
|
type: "complete";
|
|
171
176
|
payload: {
|
|
172
177
|
id: string;
|
|
173
|
-
componentData:
|
|
174
|
-
softComponent:
|
|
178
|
+
componentData: Record<string, any>;
|
|
179
|
+
softComponent: VersionedSoftComponent["versions"][string];
|
|
175
180
|
};
|
|
176
181
|
} | {
|
|
177
182
|
type: "cancel";
|
|
@@ -212,6 +217,10 @@ type RenderFunc<Props extends {
|
|
|
212
217
|
children: ReactNode;
|
|
213
218
|
}> = (props: Props) => ReactElement;
|
|
214
219
|
type Overrides = {
|
|
220
|
+
componentNameToKey?: (displayName: string, context: {
|
|
221
|
+
existingKeys: string[];
|
|
222
|
+
state: "building" | "remodeling" | "ready" | "inspecting";
|
|
223
|
+
}) => string;
|
|
215
224
|
map?: RenderFunc<{
|
|
216
225
|
rootProps: BuilderRootConfig;
|
|
217
226
|
toOptions: {
|
|
@@ -236,6 +245,16 @@ type Overrides = {
|
|
|
236
245
|
softComponent: VersionedSoftComponent["versions"][string];
|
|
237
246
|
}) => ((inputs: any[], props: DefaultComponentProps) => any) | undefined;
|
|
238
247
|
onActions?: OnActionsCallback;
|
|
248
|
+
name?: Field<string>;
|
|
249
|
+
categories?: Field<string | undefined>;
|
|
250
|
+
onRootsDataChange?: (data: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>, params: {
|
|
251
|
+
changed: Partial<Record<keyof BuilderRootConfig, boolean> & {
|
|
252
|
+
id: string;
|
|
253
|
+
}>;
|
|
254
|
+
lastData: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | null;
|
|
255
|
+
metadata: Metadata;
|
|
256
|
+
trigger: ResolveDataTrigger;
|
|
257
|
+
}) => void;
|
|
239
258
|
};
|
|
240
259
|
|
|
241
260
|
type Status = "building" | "remodeling" | "ready" | "inspecting";
|
|
@@ -342,7 +361,7 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overr
|
|
|
342
361
|
declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
343
362
|
declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
344
363
|
|
|
345
|
-
declare const useBuild: () => {
|
|
364
|
+
declare const useBuild: (name?: string) => {
|
|
346
365
|
handleBuild: () => void;
|
|
347
366
|
canBuild: boolean;
|
|
348
367
|
};
|
|
@@ -356,7 +375,7 @@ declare const useComplete: () => {
|
|
|
356
375
|
handleComplete: () => string | null;
|
|
357
376
|
canComplete: boolean;
|
|
358
377
|
newComponent: string | null;
|
|
359
|
-
setNewComponent:
|
|
378
|
+
setNewComponent: React$1.Dispatch<React$1.SetStateAction<string | null>>;
|
|
360
379
|
};
|
|
361
380
|
|
|
362
381
|
declare const useCancel: () => {
|
|
@@ -385,20 +404,42 @@ declare const useSetDefaultVersion: () => {
|
|
|
385
404
|
|
|
386
405
|
declare const Header: ({ onPublish, children, }: {
|
|
387
406
|
onPublish?: (data: Data, softComponents: SoftComponents) => void;
|
|
388
|
-
children:
|
|
407
|
+
children: React__default.ReactNode;
|
|
389
408
|
}) => react_jsx_runtime.JSX.Element;
|
|
390
409
|
|
|
391
410
|
declare const ActionBarOverride: (props: {
|
|
392
411
|
label?: string;
|
|
393
|
-
parentAction?:
|
|
394
|
-
children?:
|
|
412
|
+
parentAction?: React__default.ReactNode;
|
|
413
|
+
children?: React__default.ReactNode;
|
|
395
414
|
}) => react_jsx_runtime.JSX.Element;
|
|
396
415
|
|
|
416
|
+
declare const DrawerItem: (props: {
|
|
417
|
+
name: string;
|
|
418
|
+
children: React.ReactNode;
|
|
419
|
+
}) => React.ReactElement;
|
|
420
|
+
/** @deprecated Use DrawerItem instead */
|
|
397
421
|
declare const ComponentItem: (props: {
|
|
398
422
|
name: string;
|
|
399
423
|
children: React.ReactNode;
|
|
400
424
|
}) => React.ReactElement;
|
|
401
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Drawer — custom drawer override for the Puck editor.
|
|
428
|
+
*
|
|
429
|
+
* Reads config.categories from puck and renders a collapsible section per
|
|
430
|
+
* category, each containing a PuckDrawer with DrawerItem as the item
|
|
431
|
+
* renderer (soft-config versioning, demolish, and settings modal included).
|
|
432
|
+
* Components not assigned to any category render under "Other components".
|
|
433
|
+
*
|
|
434
|
+
* Falls back to a flat list when no categories are defined.
|
|
435
|
+
*
|
|
436
|
+
* Usage:
|
|
437
|
+
* overrides={{ drawer: Drawer }}
|
|
438
|
+
*/
|
|
439
|
+
declare const Drawer: (_props: {
|
|
440
|
+
children?: React__default.ReactNode;
|
|
441
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
442
|
+
|
|
402
443
|
type NotificationHandler = (message: string, type: "error" | "success") => void;
|
|
403
444
|
declare const setNotificationHandler: (handler: NotificationHandler) => void;
|
|
404
445
|
declare const notify: {
|
|
@@ -453,4 +494,4 @@ declare const Modal: ({ children, onClose, isOpen, }: {
|
|
|
453
494
|
isOpen: boolean;
|
|
454
495
|
}) => react_jsx_runtime.JSX.Element;
|
|
455
496
|
|
|
456
|
-
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Header, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type VersionedSoftComponent, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|
|
497
|
+
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, Drawer, DrawerItem, Header, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type VersionedSoftComponent, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|