@netlisian/softconfig 0.1.2 → 0.1.4
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 +50 -0
- package/dist/puck/index.css +69 -39
- package/dist/puck/index.d.mts +132 -85
- package/dist/puck/index.d.ts +132 -85
- package/dist/puck/index.js +347 -203
- package/dist/puck/index.mjs +361 -217
- package/package.json +2 -1
package/dist/puck/index.d.ts
CHANGED
|
@@ -1,10 +1,94 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
2
|
import { StoreApi } from 'zustand';
|
|
3
|
-
import
|
|
3
|
+
import * as _measured_puck from '@measured/puck';
|
|
4
|
+
import { DefaultComponentProps, Field, Config, Fields, History, AppState, PuckApi, ComponentData, ComponentConfig, RootData, AsFieldProps, WithChildren, Metadata, ResolveDataTrigger, PuckAction, Data } from '@measured/puck';
|
|
4
5
|
import * as React$1 from 'react';
|
|
5
6
|
import React__default, { ReactNode, ReactElement } from 'react';
|
|
6
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
8
|
|
|
9
|
+
type BuilderRootConfig = {
|
|
10
|
+
_name: string;
|
|
11
|
+
_category?: string;
|
|
12
|
+
_version?: string;
|
|
13
|
+
_versions?: string[];
|
|
14
|
+
_fields?: {
|
|
15
|
+
name: string;
|
|
16
|
+
type: Field["type"];
|
|
17
|
+
}[];
|
|
18
|
+
_fieldSettings?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
type BuilderComponentConfig = {
|
|
24
|
+
_slot?: {
|
|
25
|
+
slot: string;
|
|
26
|
+
}[];
|
|
27
|
+
_map?: {
|
|
28
|
+
to: string | string[];
|
|
29
|
+
from: string | string[];
|
|
30
|
+
transform?: (inputs: any[], props: DefaultComponentProps) => any;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}[];
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
type BuilderConfig = Config<any, BuilderRootConfig>;
|
|
36
|
+
|
|
37
|
+
type SoftSubComponent = {
|
|
38
|
+
type: string;
|
|
39
|
+
map: BuilderComponentConfig['_map'];
|
|
40
|
+
components: {
|
|
41
|
+
[slot: string]: SoftSubComponent;
|
|
42
|
+
};
|
|
43
|
+
fixedProps?: DefaultComponentProps;
|
|
44
|
+
enabledSlots: {
|
|
45
|
+
slot: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
}[];
|
|
48
|
+
}[];
|
|
49
|
+
type SoftComponent = {
|
|
50
|
+
name: string;
|
|
51
|
+
category?: string;
|
|
52
|
+
fields: Fields;
|
|
53
|
+
fieldSettings?: Record<string, any>;
|
|
54
|
+
defaultProps: DefaultComponentProps;
|
|
55
|
+
rootProps?: Record<string, any>;
|
|
56
|
+
components: SoftSubComponent;
|
|
57
|
+
slots: {
|
|
58
|
+
[slot: string]: DefaultComponentProps;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
type VersionedSoftComponent = {
|
|
62
|
+
defaultVersion: string;
|
|
63
|
+
name: string;
|
|
64
|
+
category?: string;
|
|
65
|
+
versions: {
|
|
66
|
+
[version: string]: {
|
|
67
|
+
fields: Fields;
|
|
68
|
+
fieldSettings?: Record<string, any>;
|
|
69
|
+
defaultProps: DefaultComponentProps;
|
|
70
|
+
rootProps?: Record<string, any>;
|
|
71
|
+
components: SoftSubComponent;
|
|
72
|
+
slots: {
|
|
73
|
+
[slot: string]: DefaultComponentProps;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Dependencies map: version -> Set of component names this component depends on
|
|
79
|
+
* Automatically inferred from component structure but can be overridden
|
|
80
|
+
*/
|
|
81
|
+
dependencies?: {
|
|
82
|
+
[version: string]: Set<string>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
type SoftComponents = Record<string, VersionedSoftComponent>;
|
|
86
|
+
|
|
87
|
+
type CompletedComponentResult = {
|
|
88
|
+
id: string;
|
|
89
|
+
version: string;
|
|
90
|
+
softComponent: VersionedSoftComponent["versions"][string];
|
|
91
|
+
};
|
|
8
92
|
type BuildersSlice = {
|
|
9
93
|
/**
|
|
10
94
|
* Build a new soft component based on the selected item in history.
|
|
@@ -61,7 +145,7 @@ type BuildersSlice = {
|
|
|
61
145
|
* - Strip the build settings fields
|
|
62
146
|
* - Apply modified history to puck data.
|
|
63
147
|
*/
|
|
64
|
-
complete: (appState: AppState<any>, setHistories: PuckApi["history"]["setHistories"], getItemBySelector: PuckApi["getItemBySelector"]) =>
|
|
148
|
+
complete: (appState: AppState<any>, setHistories: PuckApi["history"]["setHistories"], getItemBySelector: PuckApi["getItemBySelector"]) => CompletedComponentResult;
|
|
65
149
|
demolish: (componentName: string, data: AppState["data"], puckDispatch: PuckApi["dispatch"]) => void;
|
|
66
150
|
inspect: (componentName: string, puckDispatch: PuckApi["dispatch"]) => void;
|
|
67
151
|
/**
|
|
@@ -86,81 +170,6 @@ type BuildersSlice = {
|
|
|
86
170
|
decompose: (componentData: ComponentData) => ComponentData[];
|
|
87
171
|
};
|
|
88
172
|
|
|
89
|
-
type BuilderRootConfig = {
|
|
90
|
-
_name: string;
|
|
91
|
-
_category?: string;
|
|
92
|
-
_version?: string;
|
|
93
|
-
_versions?: string[];
|
|
94
|
-
_fields?: {
|
|
95
|
-
name: string;
|
|
96
|
-
type: Field["type"];
|
|
97
|
-
}[];
|
|
98
|
-
_fieldSettings?: {
|
|
99
|
-
[key: string]: any;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
type BuilderComponentConfig = {
|
|
103
|
-
_slot?: {
|
|
104
|
-
slot: string;
|
|
105
|
-
}[];
|
|
106
|
-
_map?: {
|
|
107
|
-
to: string | string[];
|
|
108
|
-
from: string | string[];
|
|
109
|
-
transform?: (inputs: any[], props: DefaultComponentProps) => any;
|
|
110
|
-
[key: string]: any;
|
|
111
|
-
}[];
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
};
|
|
114
|
-
type BuilderConfig = Config<any, BuilderRootConfig>;
|
|
115
|
-
|
|
116
|
-
type SoftSubComponent = {
|
|
117
|
-
type: string;
|
|
118
|
-
map: BuilderComponentConfig['_map'];
|
|
119
|
-
components: {
|
|
120
|
-
[slot: string]: SoftSubComponent;
|
|
121
|
-
};
|
|
122
|
-
fixedProps?: DefaultComponentProps;
|
|
123
|
-
enabledSlots: {
|
|
124
|
-
slot: string;
|
|
125
|
-
name?: string;
|
|
126
|
-
}[];
|
|
127
|
-
}[];
|
|
128
|
-
type SoftComponent = {
|
|
129
|
-
name: string;
|
|
130
|
-
category?: string;
|
|
131
|
-
fields: Fields;
|
|
132
|
-
fieldSettings?: Record<string, any>;
|
|
133
|
-
defaultProps: DefaultComponentProps;
|
|
134
|
-
components: SoftSubComponent;
|
|
135
|
-
slots: {
|
|
136
|
-
[slot: string]: DefaultComponentProps;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
type VersionedSoftComponent = {
|
|
140
|
-
defaultVersion: string;
|
|
141
|
-
name: string;
|
|
142
|
-
category?: string;
|
|
143
|
-
versions: {
|
|
144
|
-
[version: string]: {
|
|
145
|
-
fields: Fields;
|
|
146
|
-
fieldSettings?: Record<string, any>;
|
|
147
|
-
defaultProps: DefaultComponentProps;
|
|
148
|
-
components: SoftSubComponent;
|
|
149
|
-
slots: {
|
|
150
|
-
[slot: string]: DefaultComponentProps;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* Dependencies map: version -> Set of component names this component depends on
|
|
156
|
-
* Automatically inferred from component structure but can be overridden
|
|
157
|
-
*/
|
|
158
|
-
dependencies?: {
|
|
159
|
-
[version: string]: Set<string>;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
type SoftComponents = Record<string, VersionedSoftComponent>;
|
|
163
|
-
|
|
164
173
|
type ActionEventPayload = {
|
|
165
174
|
type: "build";
|
|
166
175
|
payload: {
|
|
@@ -170,11 +179,14 @@ type ActionEventPayload = {
|
|
|
170
179
|
type: "remodel";
|
|
171
180
|
payload: {
|
|
172
181
|
id: string;
|
|
182
|
+
version?: string;
|
|
183
|
+
softComponent?: VersionedSoftComponent["versions"][string];
|
|
173
184
|
};
|
|
174
185
|
} | {
|
|
175
186
|
type: "complete";
|
|
176
187
|
payload: {
|
|
177
188
|
id: string;
|
|
189
|
+
version: string;
|
|
178
190
|
componentData: Record<string, any>;
|
|
179
191
|
softComponent: VersionedSoftComponent["versions"][string];
|
|
180
192
|
};
|
|
@@ -192,10 +204,19 @@ type ActionEventPayload = {
|
|
|
192
204
|
id: string;
|
|
193
205
|
version: string;
|
|
194
206
|
};
|
|
207
|
+
} | {
|
|
208
|
+
type: "deleteVersion";
|
|
209
|
+
payload: {
|
|
210
|
+
id: string;
|
|
211
|
+
version: string;
|
|
212
|
+
migrateToVersion?: string;
|
|
213
|
+
};
|
|
195
214
|
} | {
|
|
196
215
|
type: "inspect";
|
|
197
216
|
payload: {
|
|
198
217
|
id: string;
|
|
218
|
+
version?: string;
|
|
219
|
+
softComponent?: VersionedSoftComponent["versions"][string];
|
|
199
220
|
};
|
|
200
221
|
} | {
|
|
201
222
|
type: "decompose";
|
|
@@ -217,10 +238,13 @@ type RenderFunc<Props extends {
|
|
|
217
238
|
children: ReactNode;
|
|
218
239
|
}> = (props: Props) => ReactElement;
|
|
219
240
|
type Overrides = {
|
|
220
|
-
componentNameToKey?: (displayName: string, context: {
|
|
241
|
+
componentNameToKey?: (displayName: string, context: Partial<BuilderRootConfig> & {
|
|
221
242
|
existingKeys: string[];
|
|
222
243
|
state: "building" | "remodeling" | "ready" | "inspecting";
|
|
223
244
|
}) => string;
|
|
245
|
+
componentKeyToName?: (key: string) => string;
|
|
246
|
+
onRemodel?: (key: string) => Record<string, any>;
|
|
247
|
+
additionalRootFields?: Record<string, Field>;
|
|
224
248
|
map?: RenderFunc<{
|
|
225
249
|
rootProps: BuilderRootConfig;
|
|
226
250
|
toOptions: {
|
|
@@ -247,14 +271,19 @@ type Overrides = {
|
|
|
247
271
|
onActions?: OnActionsCallback;
|
|
248
272
|
name?: Field<string>;
|
|
249
273
|
categories?: Field<string | undefined>;
|
|
250
|
-
|
|
274
|
+
resolveRootData?: (props: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>, params: {
|
|
251
275
|
changed: Partial<Record<keyof BuilderRootConfig, boolean> & {
|
|
252
276
|
id: string;
|
|
253
277
|
}>;
|
|
254
278
|
lastData: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | null;
|
|
255
279
|
metadata: Metadata;
|
|
256
280
|
trigger: ResolveDataTrigger;
|
|
257
|
-
}
|
|
281
|
+
}, context: {
|
|
282
|
+
editingComponent?: string;
|
|
283
|
+
}) => {
|
|
284
|
+
props: RootData<AsFieldProps<WithChildren<BuilderRootConfig>>> | Promise<RootData<AsFieldProps<WithChildren<BuilderRootConfig>>>>;
|
|
285
|
+
readOnly: Readonly<Record<string, boolean>> | undefined;
|
|
286
|
+
};
|
|
258
287
|
};
|
|
259
288
|
|
|
260
289
|
type Status = "building" | "remodeling" | "ready" | "inspecting";
|
|
@@ -295,6 +324,7 @@ type AppStore = {
|
|
|
295
324
|
hydrateTransforms: () => void;
|
|
296
325
|
setSoftComponentDefaultVersion: (key: string, version: string) => void;
|
|
297
326
|
removeSoftComponent: (key: string) => void;
|
|
327
|
+
editingComponent: string | null;
|
|
298
328
|
editingComponentId: string | null;
|
|
299
329
|
editableComponentIds: Set<string>;
|
|
300
330
|
setEditableComponentIds: (ids: Set<string>) => void;
|
|
@@ -367,15 +397,32 @@ declare const useBuild: (name?: string) => {
|
|
|
367
397
|
};
|
|
368
398
|
|
|
369
399
|
declare const useRemodel: () => {
|
|
370
|
-
handleRemodel: (componentName?: string) =>
|
|
400
|
+
handleRemodel: (componentName?: string) => {
|
|
401
|
+
id: string;
|
|
402
|
+
version: string;
|
|
403
|
+
softComponent: {
|
|
404
|
+
fields: _measured_puck.Fields;
|
|
405
|
+
fieldSettings?: Record<string, any>;
|
|
406
|
+
defaultProps: DefaultComponentProps;
|
|
407
|
+
rootProps?: Record<string, any>;
|
|
408
|
+
components: SoftSubComponent;
|
|
409
|
+
slots: {
|
|
410
|
+
[slot: string]: DefaultComponentProps;
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
} | {
|
|
414
|
+
id: string;
|
|
415
|
+
version: string;
|
|
416
|
+
softComponent?: undefined;
|
|
417
|
+
} | null;
|
|
371
418
|
canRemodel: (componentName?: string) => boolean;
|
|
372
419
|
};
|
|
373
420
|
|
|
374
421
|
declare const useComplete: () => {
|
|
375
|
-
handleComplete: () =>
|
|
422
|
+
handleComplete: () => CompletedComponentResult | null;
|
|
376
423
|
canComplete: boolean;
|
|
377
|
-
newComponent:
|
|
378
|
-
setNewComponent: React$1.Dispatch<React$1.SetStateAction<
|
|
424
|
+
newComponent: CompletedComponentResult | null;
|
|
425
|
+
setNewComponent: React$1.Dispatch<React$1.SetStateAction<CompletedComponentResult | null>>;
|
|
379
426
|
};
|
|
380
427
|
|
|
381
428
|
declare const useCancel: () => {
|
|
@@ -383,7 +430,7 @@ declare const useCancel: () => {
|
|
|
383
430
|
canCancel: boolean;
|
|
384
431
|
};
|
|
385
432
|
|
|
386
|
-
declare const useInspect: (
|
|
433
|
+
declare const useInspect: (component: CompletedComponentResult | null) => void;
|
|
387
434
|
|
|
388
435
|
declare const useDecompose: () => {
|
|
389
436
|
handleDecompose: (componentData?: ComponentData) => void;
|