@netlisian/softconfig 0.0.0-alpha-20251026130436
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/README.md +83 -0
- package/dist/index.css +337 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +1 -0
- package/dist/puck/index.css +337 -0
- package/dist/puck/index.d.mts +345 -0
- package/dist/puck/index.d.ts +345 -0
- package/dist/puck/index.js +2842 -0
- package/dist/puck/index.mjs +2792 -0
- package/package.json +65 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/* src/puck/components/error-boundary/styles.module.css */
|
|
2
|
+
.ErrorBoundary {
|
|
3
|
+
padding: 20px;
|
|
4
|
+
border: 1px solid #ff5858;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
background-color: #fff0f0;
|
|
7
|
+
margin: 10px 0;
|
|
8
|
+
}
|
|
9
|
+
.ErrorBoundary-title {
|
|
10
|
+
color: #d32f2f;
|
|
11
|
+
margin: 0 0 10px 0;
|
|
12
|
+
}
|
|
13
|
+
.ErrorBoundary-details {
|
|
14
|
+
white-space: pre-wrap;
|
|
15
|
+
}
|
|
16
|
+
.ErrorBoundary-button {
|
|
17
|
+
margin-top: 10px;
|
|
18
|
+
padding: 5px 10px;
|
|
19
|
+
background-color: #d32f2f;
|
|
20
|
+
color: white;
|
|
21
|
+
border: none;
|
|
22
|
+
border-radius: 4px;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
.ErrorBoundary-button:hover {
|
|
26
|
+
background-color: #b71c1c;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* src/puck/overrides/Header.module.css */
|
|
30
|
+
.Header {
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 0.5rem;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* src/puck/overrides/ActionBar.module.css */
|
|
39
|
+
.ActionBar {
|
|
40
|
+
align-items: center;
|
|
41
|
+
cursor: default;
|
|
42
|
+
display: flex;
|
|
43
|
+
width: auto;
|
|
44
|
+
padding: 4px;
|
|
45
|
+
padding-inline-start: 0;
|
|
46
|
+
padding-inline-end: 0;
|
|
47
|
+
border-top-left-radius: 8px;
|
|
48
|
+
border-top-right-radius: 8px;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
background: var(--puck-color-grey-01);
|
|
51
|
+
color: var(--puck-color-white);
|
|
52
|
+
font-family: var(--puck-font-family);
|
|
53
|
+
min-height: 26px;
|
|
54
|
+
}
|
|
55
|
+
.ActionBar-label {
|
|
56
|
+
color: var(--puck-color-grey-08);
|
|
57
|
+
font-size: var(--puck-font-size-xxxs);
|
|
58
|
+
font-weight: 500;
|
|
59
|
+
padding-inline-start: 8px;
|
|
60
|
+
padding-inline-end: 8px;
|
|
61
|
+
margin-inline-start: 4px;
|
|
62
|
+
margin-inline-end: 4px;
|
|
63
|
+
text-overflow: ellipsis;
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
}
|
|
66
|
+
.ActionBar-action + .ActionBar-label {
|
|
67
|
+
padding-inline-start: 0;
|
|
68
|
+
}
|
|
69
|
+
.ActionBar-label + .ActionBar-action {
|
|
70
|
+
margin-inline-start: -4px;
|
|
71
|
+
}
|
|
72
|
+
.ActionBar-group {
|
|
73
|
+
align-items: center;
|
|
74
|
+
border-inline-start: 0.5px solid var(--puck-color-grey-05);
|
|
75
|
+
display: flex;
|
|
76
|
+
height: 100%;
|
|
77
|
+
padding-inline-start: 4px;
|
|
78
|
+
padding-inline-end: 4px;
|
|
79
|
+
}
|
|
80
|
+
.ActionBar-group:first-of-type {
|
|
81
|
+
border-inline-start: 0;
|
|
82
|
+
}
|
|
83
|
+
.ActionBar-group:empty {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
.ActionBar-action {
|
|
87
|
+
background: transparent;
|
|
88
|
+
border: none;
|
|
89
|
+
color: var(--puck-color-grey-08);
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
padding: 6px 8px;
|
|
92
|
+
margin-inline-start: 4px;
|
|
93
|
+
margin-inline-end: 4px;
|
|
94
|
+
border-radius: 4px;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
transition: color 50ms ease-in;
|
|
100
|
+
}
|
|
101
|
+
.ActionBar-action svg {
|
|
102
|
+
max-width: none !important;
|
|
103
|
+
}
|
|
104
|
+
.ActionBar-action:focus-visible {
|
|
105
|
+
outline: 2px solid var(--puck-color-azure-05);
|
|
106
|
+
outline-offset: -2px;
|
|
107
|
+
}
|
|
108
|
+
@media (hover: hover) and (pointer: fine) {
|
|
109
|
+
.ActionBar-action:hover {
|
|
110
|
+
color: var(--puck-color-azure-06);
|
|
111
|
+
transition: none;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
.ActionBar-action:active {
|
|
115
|
+
color: var(--puck-color-azure-07);
|
|
116
|
+
transition: none;
|
|
117
|
+
}
|
|
118
|
+
.ActionBar-group * {
|
|
119
|
+
margin: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* src/puck/overrides/ComponentItem.module.css */
|
|
123
|
+
.ComponentItem {
|
|
124
|
+
background: var(--puck-color-white);
|
|
125
|
+
cursor: grab;
|
|
126
|
+
border: 1px solid var(--puck-color-grey-09);
|
|
127
|
+
font-size: var(--puck-font-size-xxs);
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
align-items: center;
|
|
131
|
+
padding: 12px;
|
|
132
|
+
transition: background-color 50ms ease-in, color 50ms ease-in;
|
|
133
|
+
display: flex;
|
|
134
|
+
}
|
|
135
|
+
.ComponentItem-content {
|
|
136
|
+
flex: 1;
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
gap: 2px;
|
|
140
|
+
text-overflow: ellipsis;
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
overflow-x: hidden;
|
|
143
|
+
}
|
|
144
|
+
.ComponentItem-name {
|
|
145
|
+
font-weight: 500;
|
|
146
|
+
}
|
|
147
|
+
.ComponentItem-version {
|
|
148
|
+
font-size: 10px;
|
|
149
|
+
color: var(--puck-color-grey-05);
|
|
150
|
+
}
|
|
151
|
+
.ComponentItem-actions {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: 8px;
|
|
155
|
+
}
|
|
156
|
+
.ComponentItem-settingsButton {
|
|
157
|
+
opacity: 0;
|
|
158
|
+
transition: opacity 120ms ease;
|
|
159
|
+
color: var(--puck-color-grey-05);
|
|
160
|
+
}
|
|
161
|
+
.ComponentItem:hover .ComponentItem-settingsButton {
|
|
162
|
+
opacity: 1;
|
|
163
|
+
}
|
|
164
|
+
.ComponentItem-grip {
|
|
165
|
+
color: var(--puck-color-grey-05);
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
}
|
|
169
|
+
.ComponentItem-modal {
|
|
170
|
+
background: var(--puck-color-white);
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
height: 100%;
|
|
174
|
+
}
|
|
175
|
+
.ComponentItem-modalHeader {
|
|
176
|
+
padding: 24px 32px;
|
|
177
|
+
border-bottom: 1px solid var(--puck-color-grey-09);
|
|
178
|
+
}
|
|
179
|
+
.ComponentItem-modalTitle {
|
|
180
|
+
margin: 0 0 4px 0;
|
|
181
|
+
font-size: 24px;
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
color: var(--puck-color-black);
|
|
184
|
+
}
|
|
185
|
+
.ComponentItem-modalSubtitle {
|
|
186
|
+
margin: 0;
|
|
187
|
+
font-size: 14px;
|
|
188
|
+
color: var(--puck-color-grey-04);
|
|
189
|
+
}
|
|
190
|
+
.ComponentItem-modalBody {
|
|
191
|
+
flex: 1;
|
|
192
|
+
padding: 32px;
|
|
193
|
+
overflow-y: auto;
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: column;
|
|
196
|
+
gap: 32px;
|
|
197
|
+
}
|
|
198
|
+
.ComponentItem-section {
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: column;
|
|
201
|
+
gap: 16px;
|
|
202
|
+
}
|
|
203
|
+
.ComponentItem-sectionTitle {
|
|
204
|
+
margin: 0;
|
|
205
|
+
font-size: 16px;
|
|
206
|
+
font-weight: 600;
|
|
207
|
+
color: var(--puck-color-black);
|
|
208
|
+
}
|
|
209
|
+
.ComponentItem-sectionDescription {
|
|
210
|
+
margin: 0;
|
|
211
|
+
font-size: 14px;
|
|
212
|
+
color: var(--puck-color-grey-04);
|
|
213
|
+
}
|
|
214
|
+
.ComponentItem-versionList {
|
|
215
|
+
display: flex;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: 8px;
|
|
218
|
+
}
|
|
219
|
+
.ComponentItem-versionRow {
|
|
220
|
+
display: flex;
|
|
221
|
+
justify-content: space-between;
|
|
222
|
+
align-items: center;
|
|
223
|
+
padding: 16px;
|
|
224
|
+
border-radius: 6px;
|
|
225
|
+
border: 1px solid var(--puck-color-grey-09);
|
|
226
|
+
background: var(--puck-color-white);
|
|
227
|
+
transition: all 150ms ease;
|
|
228
|
+
}
|
|
229
|
+
.ComponentItem-versionRow--isDefault {
|
|
230
|
+
border-color: var(--puck-color-azure-07);
|
|
231
|
+
background: var(--puck-color-azure-10);
|
|
232
|
+
}
|
|
233
|
+
.ComponentItem-versionRow--isMarkedForDeletion {
|
|
234
|
+
opacity: 0.6;
|
|
235
|
+
background: var(--puck-color-grey-11);
|
|
236
|
+
}
|
|
237
|
+
.ComponentItem-versionInfo {
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
gap: 12px;
|
|
241
|
+
flex: 1;
|
|
242
|
+
}
|
|
243
|
+
.ComponentItem-versionNumber {
|
|
244
|
+
font-size: 14px;
|
|
245
|
+
font-weight: 500;
|
|
246
|
+
color: var(--puck-color-black);
|
|
247
|
+
}
|
|
248
|
+
.ComponentItem-defaultBadge {
|
|
249
|
+
font-size: 11px;
|
|
250
|
+
padding: 3px 8px;
|
|
251
|
+
border-radius: 4px;
|
|
252
|
+
background: var(--puck-color-azure-07);
|
|
253
|
+
color: var(--puck-color-white);
|
|
254
|
+
font-weight: 500;
|
|
255
|
+
text-transform: uppercase;
|
|
256
|
+
letter-spacing: 0.5px;
|
|
257
|
+
}
|
|
258
|
+
.ComponentItem-deleteBadge {
|
|
259
|
+
font-size: 11px;
|
|
260
|
+
padding: 3px 8px;
|
|
261
|
+
border-radius: 4px;
|
|
262
|
+
background: var(--puck-color-grey-07);
|
|
263
|
+
color: var(--puck-color-white);
|
|
264
|
+
font-weight: 500;
|
|
265
|
+
text-transform: uppercase;
|
|
266
|
+
letter-spacing: 0.5px;
|
|
267
|
+
}
|
|
268
|
+
.ComponentItem-versionActions {
|
|
269
|
+
display: flex;
|
|
270
|
+
gap: 8px;
|
|
271
|
+
align-items: center;
|
|
272
|
+
}
|
|
273
|
+
.ComponentItem-migrationOptions {
|
|
274
|
+
width: 100%;
|
|
275
|
+
}
|
|
276
|
+
.ComponentItem-select {
|
|
277
|
+
width: 100%;
|
|
278
|
+
padding: 10px 12px;
|
|
279
|
+
border: 1px solid var(--puck-color-grey-09);
|
|
280
|
+
border-radius: 6px;
|
|
281
|
+
font-size: 14px;
|
|
282
|
+
background: var(--puck-color-white);
|
|
283
|
+
color: var(--puck-color-black);
|
|
284
|
+
cursor: pointer;
|
|
285
|
+
transition: border-color 150ms ease;
|
|
286
|
+
}
|
|
287
|
+
.ComponentItem-select:hover {
|
|
288
|
+
border-color: var(--puck-color-grey-07);
|
|
289
|
+
}
|
|
290
|
+
.ComponentItem-select:focus {
|
|
291
|
+
outline: none;
|
|
292
|
+
border-color: var(--puck-color-azure-07);
|
|
293
|
+
}
|
|
294
|
+
.ComponentItem-modalFooter {
|
|
295
|
+
padding: 20px 32px;
|
|
296
|
+
border-top: 1px solid var(--puck-color-grey-09);
|
|
297
|
+
display: flex;
|
|
298
|
+
justify-content: space-between;
|
|
299
|
+
align-items: center;
|
|
300
|
+
background: var(--puck-color-grey-11);
|
|
301
|
+
}
|
|
302
|
+
.ComponentItem-footerLeft {
|
|
303
|
+
display: flex;
|
|
304
|
+
gap: 12px;
|
|
305
|
+
}
|
|
306
|
+
.ComponentItem-footerRight {
|
|
307
|
+
display: flex;
|
|
308
|
+
gap: 12px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/* src/puck/components/modal/styles.module.css */
|
|
312
|
+
.Modal {
|
|
313
|
+
background: color-mix(in srgb, var(--puck-color-black) 75%, transparent);
|
|
314
|
+
display: none;
|
|
315
|
+
justify-content: center;
|
|
316
|
+
align-items: center;
|
|
317
|
+
position: fixed;
|
|
318
|
+
top: 0;
|
|
319
|
+
left: 0;
|
|
320
|
+
bottom: 0;
|
|
321
|
+
right: 0;
|
|
322
|
+
z-index: 1;
|
|
323
|
+
padding: 32px;
|
|
324
|
+
}
|
|
325
|
+
.Modal--isOpen {
|
|
326
|
+
display: flex;
|
|
327
|
+
}
|
|
328
|
+
.Modal-inner {
|
|
329
|
+
width: 100%;
|
|
330
|
+
max-width: 1024px;
|
|
331
|
+
border-radius: 8px;
|
|
332
|
+
overflow: hidden;
|
|
333
|
+
background: var(--puck-color-white);
|
|
334
|
+
display: flex;
|
|
335
|
+
flex-direction: column;
|
|
336
|
+
max-height: 90dvh;
|
|
337
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { StoreApi } from 'zustand';
|
|
3
|
+
import { History, AppState, PuckApi, ComponentConfig, ComponentData, DefaultComponentProps, Field, Fields, Config, Data } from '@measured/puck';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import react__default, { ReactNode, ReactElement } from 'react';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
type BuildersSlice = {
|
|
9
|
+
/**
|
|
10
|
+
* Build a new soft component based on the selected item in history.
|
|
11
|
+
*
|
|
12
|
+
* Steps:
|
|
13
|
+
* 1. Data Modifications:
|
|
14
|
+
* - Store History
|
|
15
|
+
* - Set currently selected item to the root
|
|
16
|
+
* 2. Soft Config Modifications:
|
|
17
|
+
* - Update root to include: name, fields, fieldSettings, for soft component
|
|
18
|
+
* - Update each component config to map the soft fields to component fields
|
|
19
|
+
* - Update each component for slot settings (Dropzone enable/disable)
|
|
20
|
+
*/
|
|
21
|
+
build: (history: History<AppState>[], selectedItem: PuckApi["selectedItem"], itemSelector: {
|
|
22
|
+
index: number;
|
|
23
|
+
zone?: string;
|
|
24
|
+
} | null, puckDispatch: PuckApi["dispatch"]) => void | null;
|
|
25
|
+
/**
|
|
26
|
+
* Remodel the selected soft component by decomposing it and resetting as root.
|
|
27
|
+
*
|
|
28
|
+
* Steps:
|
|
29
|
+
* 1. Data Modifications:
|
|
30
|
+
* - Store History
|
|
31
|
+
* - Decompose and set selected soft component to root
|
|
32
|
+
* 2. Soft Config Modifications:
|
|
33
|
+
* - Update root with name, fields, fieldSettings for soft component
|
|
34
|
+
* - Update each component config to map soft fields to component fields
|
|
35
|
+
* - Update each component for slot settings (Dropzone enable/disable)
|
|
36
|
+
* - Remove selected component or dependencies to avoid circular dependencies
|
|
37
|
+
*/
|
|
38
|
+
remodel: (history: History<AppState>[], selectedItem: PuckApi["selectedItem"], itemSelector: {
|
|
39
|
+
index: number;
|
|
40
|
+
zone?: string;
|
|
41
|
+
} | null, puckDispatch: PuckApi["dispatch"]) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Switch to a different version of the soft component being remodeled.
|
|
44
|
+
*
|
|
45
|
+
* Steps:
|
|
46
|
+
* 1. Get the soft component for the selected version
|
|
47
|
+
* 2. Convert it back to AppState format
|
|
48
|
+
* 3. Update the puck data with the new version's content
|
|
49
|
+
*/
|
|
50
|
+
setVersion: (componentName: string, newVersion: string, currentProps: Record<string, any>, puckDispatch: PuckApi["dispatch"]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Mark the current build/remodel as complete.
|
|
53
|
+
*
|
|
54
|
+
* Steps:
|
|
55
|
+
* 1. Config Modifications:
|
|
56
|
+
* - Compose the build settings into soft component
|
|
57
|
+
* - Set the component to the config
|
|
58
|
+
* - Restore permissions, resolve fields and resolve data of all components
|
|
59
|
+
* 2. Data Modifications:
|
|
60
|
+
* - Transform the last item of history to replace the source components into composed soft component
|
|
61
|
+
* - Strip the build settings fields
|
|
62
|
+
* - Apply modified history to puck data.
|
|
63
|
+
*/
|
|
64
|
+
complete: (appState: AppState<any>, setHistories: PuckApi["history"]["setHistories"]) => string;
|
|
65
|
+
demolish: (componentName: string, data: AppState["data"], puckDispatch: PuckApi["dispatch"]) => void;
|
|
66
|
+
inspect: (componentName: string, puckDispatch: PuckApi["dispatch"]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Mark the current build/remodel as complete.
|
|
69
|
+
*
|
|
70
|
+
* Steps:
|
|
71
|
+
* 1. Config Modifications:
|
|
72
|
+
* - Restore permissions, resolve fields and resolve data of all components
|
|
73
|
+
* 2. Data Modifications:
|
|
74
|
+
* - Restore history to puck data.
|
|
75
|
+
*/
|
|
76
|
+
cancel: (setHistories: PuckApi["history"]["setHistories"]) => void;
|
|
77
|
+
/** Compose multiple components into a soft component.
|
|
78
|
+
* 1. SoftComponent: Get soft fields + default values from the appState.root + sub-component maps + fixedProps
|
|
79
|
+
*/
|
|
80
|
+
compose: (appState: AppState, componentName: string) => [ComponentConfig, string] | undefined;
|
|
81
|
+
/** Break down a composed component into its parts.
|
|
82
|
+
* 1. Get softComponentProps
|
|
83
|
+
* 2. Create a virtual component with all the props from soft-component.
|
|
84
|
+
* 3. Replace the softComponent with hardComponent
|
|
85
|
+
*/
|
|
86
|
+
decompose: (componentData: ComponentData) => ComponentData[];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type BuilderRootConfig = {
|
|
90
|
+
_name: string;
|
|
91
|
+
_version?: string;
|
|
92
|
+
_versions?: string[];
|
|
93
|
+
_fields?: {
|
|
94
|
+
name: string;
|
|
95
|
+
type: Field["type"];
|
|
96
|
+
}[];
|
|
97
|
+
_fieldSettings?: {
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
type BuilderComponentConfig = {
|
|
102
|
+
_slot?: {
|
|
103
|
+
slot: string;
|
|
104
|
+
}[];
|
|
105
|
+
_map?: {
|
|
106
|
+
from: string | string[];
|
|
107
|
+
to: string | string[];
|
|
108
|
+
transform?: (inputs: any, props: DefaultComponentProps) => any;
|
|
109
|
+
graphState?: {
|
|
110
|
+
nodes: any[];
|
|
111
|
+
edges: any[];
|
|
112
|
+
};
|
|
113
|
+
}[];
|
|
114
|
+
[key: string]: any;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
type SoftSubComponent = {
|
|
118
|
+
type: string;
|
|
119
|
+
map: BuilderComponentConfig['_map'];
|
|
120
|
+
components: {
|
|
121
|
+
[slot: string]: SoftSubComponent;
|
|
122
|
+
};
|
|
123
|
+
fixedProps?: DefaultComponentProps;
|
|
124
|
+
enabledSlots: {
|
|
125
|
+
slot: string;
|
|
126
|
+
name?: string;
|
|
127
|
+
}[];
|
|
128
|
+
}[];
|
|
129
|
+
type SoftComponent = {
|
|
130
|
+
fields: Fields;
|
|
131
|
+
defaultProps: DefaultComponentProps;
|
|
132
|
+
components: SoftSubComponent;
|
|
133
|
+
slots: {
|
|
134
|
+
[slot: string]: DefaultComponentProps;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
type VersionedSoftComponent = {
|
|
138
|
+
defaultVersion: string;
|
|
139
|
+
versions: {
|
|
140
|
+
[version: string]: {
|
|
141
|
+
fields: Fields;
|
|
142
|
+
defaultProps: DefaultComponentProps;
|
|
143
|
+
components: SoftSubComponent;
|
|
144
|
+
slots: {
|
|
145
|
+
[slot: string]: DefaultComponentProps;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
type SoftComponents = Record<string, VersionedSoftComponent>;
|
|
151
|
+
|
|
152
|
+
type RenderFunc<Props extends {
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
} = {
|
|
155
|
+
children: ReactNode;
|
|
156
|
+
}> = (props: Props) => ReactElement;
|
|
157
|
+
type Overrides = {
|
|
158
|
+
map?: RenderFunc<{
|
|
159
|
+
rootProps: BuilderRootConfig;
|
|
160
|
+
toOptions: {
|
|
161
|
+
label: string;
|
|
162
|
+
value: string;
|
|
163
|
+
type: Field["type"];
|
|
164
|
+
}[];
|
|
165
|
+
fromOptions: {
|
|
166
|
+
label: string;
|
|
167
|
+
value: string;
|
|
168
|
+
type: Field["type"];
|
|
169
|
+
}[];
|
|
170
|
+
props: DefaultComponentProps;
|
|
171
|
+
value: BuilderComponentConfig["_map"];
|
|
172
|
+
onChange: (value: BuilderComponentConfig["_map"]) => void;
|
|
173
|
+
id: string;
|
|
174
|
+
}>;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
type Status = "building" | "remodeling" | "ready" | "inspecting";
|
|
178
|
+
type AppStore = {
|
|
179
|
+
softConfig: Config;
|
|
180
|
+
softComponents: SoftComponents;
|
|
181
|
+
state: Status;
|
|
182
|
+
originalHistory: History[];
|
|
183
|
+
storedConfig?: Config;
|
|
184
|
+
overrides: Overrides;
|
|
185
|
+
itemSelector: {
|
|
186
|
+
index: number;
|
|
187
|
+
zone: string;
|
|
188
|
+
} | null;
|
|
189
|
+
setItemSelector: (selector: {
|
|
190
|
+
index: number;
|
|
191
|
+
zone: string;
|
|
192
|
+
} | null) => void;
|
|
193
|
+
originalItem: DefaultComponentProps | null;
|
|
194
|
+
setOriginalItem: (item: DefaultComponentProps | null) => void;
|
|
195
|
+
storeHistory: (history: History[]) => void;
|
|
196
|
+
removeHistory: () => void;
|
|
197
|
+
setSoftComponentConfig: (key: string, config: ComponentConfig, category?: string) => void;
|
|
198
|
+
removeSoftComponentConfig: (key: string) => void;
|
|
199
|
+
removeSoftComponentVersion: (key: string, version: string) => void;
|
|
200
|
+
setSoftCategoryConfig: (key: string, category: {
|
|
201
|
+
components?: string[];
|
|
202
|
+
visible?: boolean;
|
|
203
|
+
defaultExpanded?: boolean;
|
|
204
|
+
title?: string;
|
|
205
|
+
}) => void;
|
|
206
|
+
removeSoftCategoryConfig: (key: string) => void;
|
|
207
|
+
builder: BuildersSlice;
|
|
208
|
+
setSoftComponent: (key: string, version: string, component: SoftComponent) => void;
|
|
209
|
+
setSoftComponentDefaultVersion: (key: string, version: string) => void;
|
|
210
|
+
removeSoftComponent: (key: string) => void;
|
|
211
|
+
};
|
|
212
|
+
type AppStoreApi = StoreApi<AppStore>;
|
|
213
|
+
declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: SoftComponents, overrides?: Overrides) => zustand.UseBoundStore<Omit<Omit<StoreApi<AppStore>, "subscribe"> & {
|
|
214
|
+
subscribe: {
|
|
215
|
+
(listener: (selectedState: AppStore, previousSelectedState: AppStore) => void): () => void;
|
|
216
|
+
<U>(selector: (state: AppStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
217
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
218
|
+
fireImmediately?: boolean;
|
|
219
|
+
} | undefined): () => void;
|
|
220
|
+
};
|
|
221
|
+
}, "setState" | "devtools"> & {
|
|
222
|
+
setState(partial: AppStore | Partial<AppStore> | ((state: AppStore) => AppStore | Partial<AppStore>), replace?: false | undefined, action?: (string | {
|
|
223
|
+
[x: string]: unknown;
|
|
224
|
+
[x: number]: unknown;
|
|
225
|
+
[x: symbol]: unknown;
|
|
226
|
+
type: string;
|
|
227
|
+
}) | undefined): void;
|
|
228
|
+
setState(state: AppStore | ((state: AppStore) => AppStore), replace: true, action?: (string | {
|
|
229
|
+
[x: string]: unknown;
|
|
230
|
+
[x: number]: unknown;
|
|
231
|
+
[x: symbol]: unknown;
|
|
232
|
+
type: string;
|
|
233
|
+
}) | undefined): void;
|
|
234
|
+
devtools: {
|
|
235
|
+
cleanup: () => void;
|
|
236
|
+
};
|
|
237
|
+
}>;
|
|
238
|
+
|
|
239
|
+
declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overrides }: {
|
|
240
|
+
children: (softConfig: Config, softComponents: SoftComponents) => ReactNode;
|
|
241
|
+
hardConfig: Config;
|
|
242
|
+
softComponents: SoftComponents;
|
|
243
|
+
overrides: Overrides;
|
|
244
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
245
|
+
|
|
246
|
+
declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T) => T;
|
|
247
|
+
declare const useSoftConfig: <T>(selector: (state: AppStore) => T) => T;
|
|
248
|
+
|
|
249
|
+
declare const useBuild: () => {
|
|
250
|
+
handleBuild: () => void;
|
|
251
|
+
canBuild: boolean;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
declare const useRemodel: () => {
|
|
255
|
+
handleRemodel: (componentName?: string) => void;
|
|
256
|
+
canRemodel: (componentName?: string) => boolean;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
declare const useComplete: () => {
|
|
260
|
+
handleComplete: () => string | null;
|
|
261
|
+
canComplete: boolean;
|
|
262
|
+
newComponent: string | null;
|
|
263
|
+
setNewComponent: react.Dispatch<react.SetStateAction<string | null>>;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
declare const useCancel: () => {
|
|
267
|
+
handleCancel: () => void;
|
|
268
|
+
canCancel: boolean;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
declare const useInspect: (componentName: string | null) => void;
|
|
272
|
+
|
|
273
|
+
declare const useDecompose: () => {
|
|
274
|
+
handleDecompose: (componentData?: ComponentData) => void;
|
|
275
|
+
canDecompose: (componentData?: ComponentData) => boolean;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
declare const useDemolish: () => {
|
|
279
|
+
handleDemolish: (componentName: string) => void;
|
|
280
|
+
canDemolish: (componentName: string) => boolean;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare const useSetDefaultVersion: () => {
|
|
284
|
+
handleSetDefaultVersion: (componentName: string, version: string) => void;
|
|
285
|
+
canSetDefaultVersion: (componentName: string, version: string) => boolean;
|
|
286
|
+
getVersions: (componentName: string) => string[];
|
|
287
|
+
getDefaultVersion: (componentName: string) => string;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
declare const Header: ({ onPublish, children, }: {
|
|
291
|
+
onPublish?: (data: Data, softComponents: SoftComponents) => void;
|
|
292
|
+
children: react__default.ReactNode;
|
|
293
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
294
|
+
|
|
295
|
+
declare const ActionBarOverride: (props: {
|
|
296
|
+
label?: string;
|
|
297
|
+
parentAction?: react__default.ReactNode;
|
|
298
|
+
children?: react__default.ReactNode;
|
|
299
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
300
|
+
|
|
301
|
+
declare const ComponentItem: (props: {
|
|
302
|
+
name: string;
|
|
303
|
+
children: React.ReactNode;
|
|
304
|
+
}) => React.ReactElement;
|
|
305
|
+
|
|
306
|
+
type NotificationHandler = (message: string, type: "error" | "success") => void;
|
|
307
|
+
declare const setNotificationHandler: (handler: NotificationHandler) => void;
|
|
308
|
+
declare const notify: {
|
|
309
|
+
error: (message: string) => void;
|
|
310
|
+
success: (message: string) => void;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
type ConfirmHandler = (message: string) => Promise<boolean> | boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Set a custom confirmation handler
|
|
316
|
+
* @param handler - Function that shows confirmation dialog and returns boolean or Promise<boolean>
|
|
317
|
+
*/
|
|
318
|
+
declare const setConfirmHandler: (handler: ConfirmHandler) => void;
|
|
319
|
+
/**
|
|
320
|
+
* Show a confirmation dialog
|
|
321
|
+
* @param message - The confirmation message
|
|
322
|
+
* @returns Promise<boolean> - true if confirmed, false otherwise
|
|
323
|
+
*/
|
|
324
|
+
declare const confirm: (message: string) => Promise<boolean>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Resolves soft components in data by dissolving them to hard components only.
|
|
328
|
+
*
|
|
329
|
+
* This function uses reverse topological sorting to ensure components are dissolved
|
|
330
|
+
* in the correct order (composite → leaf), guaranteeing that only hard components
|
|
331
|
+
* remain in the final output.
|
|
332
|
+
*
|
|
333
|
+
* @param data - The Puck data structure to resolve
|
|
334
|
+
* @param softComponents - The registry of soft components with their versions
|
|
335
|
+
* @param config - The Puck config containing component definitions
|
|
336
|
+
* @returns New data with all soft components fully dissolved to hard components
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* const resolvedData = resolveSoftConfig(appState.data, softComponents, config);
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare const resolveSoftConfig: (data: Data, softComponents: SoftComponents, config: Config) => Data;
|
|
344
|
+
|
|
345
|
+
export { ActionBarOverride as ActionBar, type AppStore, type AppStoreApi, ComponentItem, Header, type SoftComponent, type SoftComponents, SoftConfigProvider, confirm, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|