@measured/puck 0.18.3 → 0.19.0-canary.01a27f78
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 +2 -4
- package/dist/chunk-HGAPIQP5.mjs +949 -0
- package/dist/index.css +188 -184
- package/dist/index.d.mts +155 -45
- package/dist/index.d.ts +155 -45
- package/dist/index.js +4313 -3460
- package/dist/index.mjs +3421 -3183
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +707 -141
- package/dist/rsc.mjs +8 -72
- package/dist/{resolve-all-data-ChsqfT2w.d.mts → walk-tree-DBd3aQ_5.d.mts} +127 -42
- package/dist/{resolve-all-data-ChsqfT2w.d.ts → walk-tree-DBd3aQ_5.d.ts} +127 -42
- package/package.json +17 -10
- package/dist/chunk-4QIG6FWS.mjs +0 -292
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CSSProperties, ReactElement,
|
1
|
+
import { CSSProperties, ReactElement, ReactNode, JSX } from 'react';
|
2
2
|
|
3
3
|
type ItemSelector = {
|
4
4
|
index: number;
|
@@ -22,17 +22,24 @@ type FieldOption = {
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
23
23
|
type BaseField = {
|
24
24
|
label?: string;
|
25
|
+
labelIcon?: ReactElement;
|
26
|
+
metadata?: Metadata;
|
27
|
+
visible?: boolean;
|
25
28
|
};
|
26
29
|
type TextField = BaseField & {
|
27
30
|
type: "text";
|
31
|
+
placeholder?: string;
|
28
32
|
};
|
29
33
|
type NumberField = BaseField & {
|
30
34
|
type: "number";
|
35
|
+
placeholder?: string;
|
31
36
|
min?: number;
|
32
37
|
max?: number;
|
38
|
+
step?: number;
|
33
39
|
};
|
34
40
|
type TextareaField = BaseField & {
|
35
41
|
type: "textarea";
|
42
|
+
placeholder?: string;
|
36
43
|
};
|
37
44
|
type SelectField = BaseField & {
|
38
45
|
type: "select";
|
@@ -104,16 +111,22 @@ type ExternalField<Props extends {
|
|
104
111
|
filterFields?: Record<string, Field>;
|
105
112
|
initialFilters?: Record<string, any>;
|
106
113
|
};
|
107
|
-
type
|
114
|
+
type CustomFieldRender<Value extends any> = (props: {
|
115
|
+
field: CustomField<Value>;
|
116
|
+
name: string;
|
117
|
+
id: string;
|
118
|
+
value: Value;
|
119
|
+
onChange: (value: Value) => void;
|
120
|
+
readOnly?: boolean;
|
121
|
+
}) => ReactElement;
|
122
|
+
type CustomField<Value extends any> = BaseField & {
|
108
123
|
type: "custom";
|
109
|
-
render:
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
readOnly?: boolean;
|
116
|
-
}) => ReactElement;
|
124
|
+
render: CustomFieldRender<Value>;
|
125
|
+
};
|
126
|
+
type SlotField = BaseField & {
|
127
|
+
type: "slot";
|
128
|
+
allow?: string[];
|
129
|
+
disallow?: string[];
|
117
130
|
};
|
118
131
|
type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
|
119
132
|
[key: string]: any;
|
@@ -123,7 +136,7 @@ type Field<Props extends any = any> = TextField | NumberField | TextareaField |
|
|
123
136
|
[key: string]: any;
|
124
137
|
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
125
138
|
[key: string]: any;
|
126
|
-
} ? Props : any> | CustomField<Props
|
139
|
+
} ? Props : any> | CustomField<Props> | SlotField;
|
127
140
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
128
141
|
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
129
142
|
};
|
@@ -135,7 +148,14 @@ type FieldProps<F = Field<any>, ValueType = any> = {
|
|
135
148
|
readOnly?: boolean;
|
136
149
|
};
|
137
150
|
|
138
|
-
type
|
151
|
+
type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
|
152
|
+
type PuckComponent<Props> = (props: WithId<WithPuckProps<{
|
153
|
+
[K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
|
154
|
+
}>>) => JSX.Element;
|
155
|
+
type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
156
|
+
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
157
|
+
props?: Partial<Props>;
|
158
|
+
};
|
139
159
|
type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderProps, DataShape = Omit<ComponentData<FieldProps>, "type">> = {
|
140
160
|
render: PuckComponent<RenderProps>;
|
141
161
|
label?: string;
|
@@ -144,7 +164,9 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
144
164
|
permissions?: Partial<Permissions>;
|
145
165
|
inline?: boolean;
|
146
166
|
resolveFields?: (data: DataShape, params: {
|
147
|
-
changed: Partial<Record<keyof FieldProps, boolean
|
167
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
168
|
+
id: string;
|
169
|
+
}>;
|
148
170
|
fields: Fields<FieldProps>;
|
149
171
|
lastFields: Fields<FieldProps>;
|
150
172
|
lastData: DataShape | null;
|
@@ -152,23 +174,25 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
152
174
|
parent: ComponentData | null;
|
153
175
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
154
176
|
resolveData?: (data: DataShape, params: {
|
155
|
-
changed: Partial<Record<keyof FieldProps, boolean
|
177
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
178
|
+
id: string;
|
179
|
+
}>;
|
156
180
|
lastData: DataShape | null;
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
}> | {
|
161
|
-
props?: Partial<FieldProps>;
|
162
|
-
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
163
|
-
};
|
181
|
+
metadata: Metadata;
|
182
|
+
trigger: ResolveDataTrigger;
|
183
|
+
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
164
184
|
resolvePermissions?: (data: DataShape, params: {
|
165
|
-
changed: Partial<Record<keyof FieldProps, boolean
|
185
|
+
changed: Partial<Record<keyof FieldProps, boolean> & {
|
186
|
+
id: string;
|
187
|
+
}>;
|
166
188
|
lastPermissions: Partial<Permissions>;
|
167
189
|
permissions: Partial<Permissions>;
|
168
190
|
appState: AppState;
|
169
191
|
lastData: DataShape | null;
|
170
192
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
193
|
+
metadata?: Metadata;
|
171
194
|
};
|
195
|
+
type RootConfig<RootProps extends DefaultComponentProps = any> = Partial<ComponentConfig<WithChildren<RootProps>, AsFieldProps<RootProps>, RootData<AsFieldProps<RootProps>>>>;
|
172
196
|
type Category<ComponentName> = {
|
173
197
|
components?: ComponentName[];
|
174
198
|
title?: string;
|
@@ -182,7 +206,7 @@ type Config<Props extends DefaultComponentProps = DefaultComponentProps, RootPro
|
|
182
206
|
components: {
|
183
207
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
184
208
|
};
|
185
|
-
root?:
|
209
|
+
root?: RootConfig<RootProps>;
|
186
210
|
};
|
187
211
|
|
188
212
|
type WithId<Props> = Props & {
|
@@ -198,7 +222,7 @@ type WithChildren<Props> = Props & {
|
|
198
222
|
};
|
199
223
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
200
224
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
201
|
-
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends
|
225
|
+
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
202
226
|
UserConfig: UserConfig;
|
203
227
|
UserProps: UserProps;
|
204
228
|
UserRootProps: UserRootProps;
|
@@ -209,10 +233,12 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
|
|
209
233
|
|
210
234
|
type PuckContext = {
|
211
235
|
renderDropZone: React.FC<DropZoneProps>;
|
236
|
+
metadata: Metadata;
|
212
237
|
isEditing: boolean;
|
213
238
|
dragRef: ((element: Element | null) => void) | null;
|
214
239
|
};
|
215
240
|
type DefaultRootFieldProps = {
|
241
|
+
[key: string]: any;
|
216
242
|
title?: string;
|
217
243
|
};
|
218
244
|
type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithPuckProps<WithChildren<Props>>;
|
@@ -233,23 +259,32 @@ type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldPro
|
|
233
259
|
};
|
234
260
|
type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
|
235
261
|
type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
|
236
|
-
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
|
262
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string, AllProps extends Record<string, DefaultComponentProps> = Record<string, DefaultComponentProps>> = {
|
237
263
|
type: Name;
|
238
|
-
props: WithId<Props
|
264
|
+
props: WithDeepSlots<WithId<Props>, Content<AllProps>>;
|
265
|
+
} & BaseData<Props>;
|
266
|
+
type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
|
267
|
+
type: Name;
|
268
|
+
props: Props & {
|
269
|
+
id?: string;
|
270
|
+
};
|
239
271
|
} & BaseData<Props>;
|
240
272
|
type MappedItem = ComponentData;
|
241
|
-
type ComponentDataMap<
|
242
|
-
[K in keyof
|
243
|
-
}[keyof
|
273
|
+
type ComponentDataMap<AllProps extends DefaultAllProps = DefaultAllProps> = {
|
274
|
+
[K in keyof AllProps]: ComponentData<AllProps[K], K extends string ? K : never, AllProps>;
|
275
|
+
}[keyof AllProps];
|
244
276
|
type Content<PropsMap extends {
|
245
|
-
[key: string]:
|
277
|
+
[key: string]: DefaultComponentProps;
|
246
278
|
} = {
|
247
|
-
[key: string]:
|
279
|
+
[key: string]: DefaultComponentProps;
|
248
280
|
}> = ComponentDataMap<PropsMap>[];
|
249
|
-
type Data<
|
250
|
-
root: RootData<RootProps
|
251
|
-
content: Content<
|
252
|
-
zones?: Record<string, Content<
|
281
|
+
type Data<AllProps extends DefaultAllProps = DefaultAllProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
|
282
|
+
root: WithDeepSlots<RootData<RootProps>, Content<AllProps>>;
|
283
|
+
content: Content<AllProps>;
|
284
|
+
zones?: Record<string, Content<AllProps>>;
|
285
|
+
};
|
286
|
+
type Metadata = {
|
287
|
+
[key: string]: any;
|
253
288
|
};
|
254
289
|
|
255
290
|
type ItemWithId = {
|
@@ -290,6 +325,34 @@ type AppState<UserData extends Data = Data> = {
|
|
290
325
|
ui: UiState;
|
291
326
|
};
|
292
327
|
|
328
|
+
type ZoneType = "root" | "dropzone" | "slot";
|
329
|
+
type PuckNodeData = {
|
330
|
+
data: ComponentData;
|
331
|
+
flatData: ComponentData;
|
332
|
+
parentId: string | null;
|
333
|
+
zone: string;
|
334
|
+
path: string[];
|
335
|
+
};
|
336
|
+
type PuckZoneData = {
|
337
|
+
contentIds: string[];
|
338
|
+
type: ZoneType;
|
339
|
+
};
|
340
|
+
type NodeIndex = Record<string, PuckNodeData>;
|
341
|
+
type ZoneIndex = Record<string, PuckZoneData>;
|
342
|
+
type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
|
343
|
+
indexes: {
|
344
|
+
nodes: NodeIndex;
|
345
|
+
zones: ZoneIndex;
|
346
|
+
};
|
347
|
+
};
|
348
|
+
type DefaultAllProps = Record<string, DefaultComponentProps>;
|
349
|
+
/**
|
350
|
+
* Recursively walk T and replace Slots with SlotComponents
|
351
|
+
*/
|
352
|
+
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 object ? {
|
353
|
+
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
354
|
+
} : T;
|
355
|
+
|
293
356
|
type RenderFunc<Props extends {
|
294
357
|
[key: string]: any;
|
295
358
|
} = {
|
@@ -396,6 +459,14 @@ type InitialHistoryNoAppend<AS = Partial<AppState>> = {
|
|
396
459
|
appendData?: false;
|
397
460
|
};
|
398
461
|
type InitialHistory<AS = Partial<AppState>> = InitialHistoryAppend<AS> | InitialHistoryNoAppend<AS>;
|
462
|
+
type Slot<Props extends {
|
463
|
+
[key: string]: DefaultComponentProps;
|
464
|
+
} = {
|
465
|
+
[key: string]: DefaultComponentProps;
|
466
|
+
}> = {
|
467
|
+
[K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
|
468
|
+
}[keyof Props][];
|
469
|
+
type WithSlotProps<Target extends Record<string, any>, AllProps extends DefaultAllProps = DefaultAllProps, SlotType extends Content<AllProps> = Content<AllProps>> = WithDeepSlots<Target, SlotType>;
|
399
470
|
|
400
471
|
type InsertAction = {
|
401
472
|
type: "insert";
|
@@ -409,11 +480,17 @@ type DuplicateAction = {
|
|
409
480
|
sourceIndex: number;
|
410
481
|
sourceZone: string;
|
411
482
|
};
|
412
|
-
type ReplaceAction = {
|
483
|
+
type ReplaceAction<UserData extends Data = Data> = {
|
413
484
|
type: "replace";
|
414
485
|
destinationIndex: number;
|
415
486
|
destinationZone: string;
|
416
|
-
data:
|
487
|
+
data: ComponentData;
|
488
|
+
ui?: Partial<AppState<UserData>["ui"]>;
|
489
|
+
};
|
490
|
+
type ReplaceRootAction<UserData extends Data = Data> = {
|
491
|
+
type: "replaceRoot";
|
492
|
+
root: RootData;
|
493
|
+
ui?: Partial<AppState<UserData>["ui"]>;
|
417
494
|
};
|
418
495
|
type ReorderAction = {
|
419
496
|
type: "reorder";
|
@@ -443,7 +520,7 @@ type SetDataAction = {
|
|
443
520
|
};
|
444
521
|
type SetAction<UserData extends Data = Data> = {
|
445
522
|
type: "set";
|
446
|
-
state: Partial<
|
523
|
+
state: Partial<PrivateAppState<UserData>> | ((previous: PrivateAppState<UserData>) => Partial<PrivateAppState<UserData>>);
|
447
524
|
};
|
448
525
|
type RegisterZoneAction = {
|
449
526
|
type: "registerZone";
|
@@ -455,7 +532,9 @@ type UnregisterZoneAction = {
|
|
455
532
|
};
|
456
533
|
type PuckAction = {
|
457
534
|
recordHistory?: boolean;
|
458
|
-
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
535
|
+
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
536
|
+
|
537
|
+
declare function migrate(data: Data, config?: Config): Data;
|
459
538
|
|
460
539
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
461
540
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
@@ -466,8 +545,14 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
466
545
|
[key: string]: any;
|
467
546
|
}) => RootProps;
|
468
547
|
}>;
|
469
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps
|
548
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>, config?: Config): Data;
|
470
549
|
|
471
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
550
|
+
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
551
|
+
|
552
|
+
type WalkTreeOptions = {
|
553
|
+
parentId: string;
|
554
|
+
propName: string;
|
555
|
+
};
|
556
|
+
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;
|
472
557
|
|
473
|
-
export { type
|
558
|
+
export { type ExternalFieldWithAdaptor as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type MappedItem as E, type Fields as F, type ComponentDataMap as G, type History as H, type IframeConfig as I, type Content as J, type BaseField as K, type TextareaField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type SelectField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type RadioField as X, type ArrayField as Y, type ObjectField as Z, type Adaptor as _, type Config as a, type ExternalField as a0, type CustomFieldRender as a1, type CustomField as a2, type SlotField as a3, type PuckContext as a4, type DefaultRootFieldProps as a5, type DefaultRootRenderProps as a6, type DefaultRootProps as a7, type DefaultComponentProps as a8, type WithId as a9, type WithPuckProps as aa, type AsFieldProps as ab, type WithChildren as ac, type ExtractPropsFromConfig as ad, type ExtractRootPropsFromConfig as ae, migrate as af, transformProps as ag, resolveAllData as ah, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type ItemSelector as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootConfig as v, walkTree as w, type RootDataWithoutProps as x, type RootData as y, type ComponentDataOptionalId as z };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.
|
4
|
-
"author": "
|
3
|
+
"version": "0.19.0-canary.01a27f78",
|
4
|
+
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
7
7
|
"homepage": "https://puckeditor.com",
|
@@ -27,7 +27,8 @@
|
|
27
27
|
"require": "./dist/rsc.js"
|
28
28
|
},
|
29
29
|
"./puck.css": "./dist/index.css",
|
30
|
-
"./dist/index.css": "./dist/index.css"
|
30
|
+
"./dist/index.css": "./dist/index.css",
|
31
|
+
"./package.json": "./package.json"
|
31
32
|
},
|
32
33
|
"typesVersions": {
|
33
34
|
"*": {
|
@@ -48,9 +49,12 @@
|
|
48
49
|
"dist"
|
49
50
|
],
|
50
51
|
"devDependencies": {
|
52
|
+
"@juggle/resize-observer": "^3.4.0",
|
53
|
+
"@testing-library/jest-dom": "^6.6.3",
|
51
54
|
"@testing-library/react": "^16.1.0",
|
52
55
|
"@types/deep-diff": "^1.0.3",
|
53
|
-
"@types/
|
56
|
+
"@types/flat": "^5.0.5",
|
57
|
+
"@types/jest": "^29.5.14",
|
54
58
|
"@types/object-hash": "^3.0.6",
|
55
59
|
"@types/react": "^19.0.1",
|
56
60
|
"@types/react-dom": "^19.0.2",
|
@@ -58,24 +62,27 @@
|
|
58
62
|
"css-box-model": "^1.2.1",
|
59
63
|
"eslint": "^7.32.0",
|
60
64
|
"eslint-config-custom": "*",
|
61
|
-
"
|
62
|
-
"jest
|
65
|
+
"identity-obj-proxy": "^3.0.0",
|
66
|
+
"jest": "^29.7.0",
|
67
|
+
"jest-environment-jsdom": "^30.0.0-beta.3",
|
63
68
|
"lucide-react": "^0.468.0",
|
64
|
-
"ts-jest": "^29.
|
69
|
+
"ts-jest": "^29.3.4",
|
65
70
|
"tsconfig": "*",
|
66
71
|
"tsup": "^8.2.4",
|
67
72
|
"tsup-config": "*",
|
68
73
|
"typescript": "^5.5.4"
|
69
74
|
},
|
70
75
|
"dependencies": {
|
71
|
-
"@dnd-kit/helpers": "0.
|
72
|
-
"@dnd-kit/react": "0.
|
76
|
+
"@dnd-kit/helpers": "0.1.18",
|
77
|
+
"@dnd-kit/react": "0.1.18",
|
73
78
|
"deep-diff": "^1.0.2",
|
79
|
+
"fast-deep-equal": "^3.1.3",
|
80
|
+
"flat": "^5.0.2",
|
74
81
|
"object-hash": "^3.0.0",
|
75
82
|
"react-hotkeys-hook": "^4.6.1",
|
76
83
|
"use-debounce": "^9.0.4",
|
77
84
|
"uuid": "^9.0.1",
|
78
|
-
"zustand": "^5.0.
|
85
|
+
"zustand": "^5.0.3"
|
79
86
|
},
|
80
87
|
"peerDependencies": {
|
81
88
|
"react": "^18.0.0 || ^19.0.0"
|
package/dist/chunk-4QIG6FWS.mjs
DELETED
@@ -1,292 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __defProps = Object.defineProperties;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
-
var __typeError = (msg) => {
|
12
|
-
throw TypeError(msg);
|
13
|
-
};
|
14
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
15
|
-
var __spreadValues = (a, b) => {
|
16
|
-
for (var prop in b || (b = {}))
|
17
|
-
if (__hasOwnProp.call(b, prop))
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
19
|
-
if (__getOwnPropSymbols)
|
20
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
21
|
-
if (__propIsEnum.call(b, prop))
|
22
|
-
__defNormalProp(a, prop, b[prop]);
|
23
|
-
}
|
24
|
-
return a;
|
25
|
-
};
|
26
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
27
|
-
var __objRest = (source, exclude) => {
|
28
|
-
var target = {};
|
29
|
-
for (var prop in source)
|
30
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
31
|
-
target[prop] = source[prop];
|
32
|
-
if (source != null && __getOwnPropSymbols)
|
33
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
34
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
35
|
-
target[prop] = source[prop];
|
36
|
-
}
|
37
|
-
return target;
|
38
|
-
};
|
39
|
-
var __esm = (fn, res) => function __init() {
|
40
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
41
|
-
};
|
42
|
-
var __commonJS = (cb, mod) => function __require() {
|
43
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
44
|
-
};
|
45
|
-
var __copyProps = (to, from, except, desc) => {
|
46
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
47
|
-
for (let key of __getOwnPropNames(from))
|
48
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
49
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
50
|
-
}
|
51
|
-
return to;
|
52
|
-
};
|
53
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
54
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
55
|
-
// file that has been converted to a CommonJS file using a Babel-
|
56
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
57
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
58
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
59
|
-
mod
|
60
|
-
));
|
61
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
62
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
63
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
64
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
65
|
-
var __async = (__this, __arguments, generator) => {
|
66
|
-
return new Promise((resolve, reject) => {
|
67
|
-
var fulfilled = (value) => {
|
68
|
-
try {
|
69
|
-
step(generator.next(value));
|
70
|
-
} catch (e) {
|
71
|
-
reject(e);
|
72
|
-
}
|
73
|
-
};
|
74
|
-
var rejected = (value) => {
|
75
|
-
try {
|
76
|
-
step(generator.throw(value));
|
77
|
-
} catch (e) {
|
78
|
-
reject(e);
|
79
|
-
}
|
80
|
-
};
|
81
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
82
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
83
|
-
});
|
84
|
-
};
|
85
|
-
|
86
|
-
// ../tsup-config/react-import.js
|
87
|
-
import React from "react";
|
88
|
-
var init_react_import = __esm({
|
89
|
-
"../tsup-config/react-import.js"() {
|
90
|
-
"use strict";
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
// lib/transform-props.ts
|
95
|
-
init_react_import();
|
96
|
-
|
97
|
-
// lib/default-data.ts
|
98
|
-
init_react_import();
|
99
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
100
|
-
root: data.root || {},
|
101
|
-
content: data.content || []
|
102
|
-
});
|
103
|
-
|
104
|
-
// lib/transform-props.ts
|
105
|
-
function transformProps(data, propTransforms) {
|
106
|
-
const mapItem = (item) => {
|
107
|
-
if (propTransforms[item.type]) {
|
108
|
-
return __spreadProps(__spreadValues({}, item), {
|
109
|
-
props: propTransforms[item.type](item.props)
|
110
|
-
});
|
111
|
-
}
|
112
|
-
return item;
|
113
|
-
};
|
114
|
-
const defaultedData = defaultData(data);
|
115
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
116
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
117
|
-
if (propTransforms["root"]) {
|
118
|
-
if (defaultedData.root.props) {
|
119
|
-
newRoot.props = propTransforms["root"](rootProps);
|
120
|
-
} else {
|
121
|
-
newRoot = propTransforms["root"](rootProps);
|
122
|
-
}
|
123
|
-
}
|
124
|
-
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
125
|
-
root: newRoot,
|
126
|
-
content: defaultedData.content.map(mapItem),
|
127
|
-
zones: Object.keys(data.zones || {}).reduce(
|
128
|
-
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
129
|
-
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
130
|
-
}),
|
131
|
-
{}
|
132
|
-
)
|
133
|
-
});
|
134
|
-
return afterPropTransforms;
|
135
|
-
}
|
136
|
-
|
137
|
-
// lib/resolve-all-data.ts
|
138
|
-
init_react_import();
|
139
|
-
|
140
|
-
// lib/resolve-component-data.ts
|
141
|
-
init_react_import();
|
142
|
-
|
143
|
-
// lib/get-changed.ts
|
144
|
-
init_react_import();
|
145
|
-
var getChanged = (newItem, oldItem) => {
|
146
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
147
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
148
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
149
|
-
return __spreadProps(__spreadValues({}, acc), {
|
150
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
151
|
-
});
|
152
|
-
}, {}) : {};
|
153
|
-
};
|
154
|
-
|
155
|
-
// lib/resolve-component-data.ts
|
156
|
-
var cache = { lastChange: {} };
|
157
|
-
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
158
|
-
return yield Promise.all(
|
159
|
-
content.map((item) => __async(void 0, null, function* () {
|
160
|
-
return yield resolveComponentData(
|
161
|
-
item,
|
162
|
-
config,
|
163
|
-
onResolveStart,
|
164
|
-
onResolveEnd
|
165
|
-
);
|
166
|
-
}))
|
167
|
-
);
|
168
|
-
});
|
169
|
-
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
170
|
-
const configForItem = config.components[item.type];
|
171
|
-
if (configForItem.resolveData) {
|
172
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
173
|
-
if (item && item === oldItem) {
|
174
|
-
return resolved;
|
175
|
-
}
|
176
|
-
const changed = getChanged(item, oldItem);
|
177
|
-
if (onResolveStart) {
|
178
|
-
onResolveStart(item);
|
179
|
-
}
|
180
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
181
|
-
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
182
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
183
|
-
});
|
184
|
-
if (Object.keys(readOnly).length) {
|
185
|
-
resolvedItem.readOnly = readOnly;
|
186
|
-
}
|
187
|
-
cache.lastChange[item.props.id] = {
|
188
|
-
item,
|
189
|
-
resolved: resolvedItem
|
190
|
-
};
|
191
|
-
if (onResolveEnd) {
|
192
|
-
onResolveEnd(resolvedItem);
|
193
|
-
}
|
194
|
-
return resolvedItem;
|
195
|
-
}
|
196
|
-
return item;
|
197
|
-
});
|
198
|
-
|
199
|
-
// lib/resolve-root-data.ts
|
200
|
-
init_react_import();
|
201
|
-
var cache2 = {};
|
202
|
-
function resolveRootData(data, config) {
|
203
|
-
return __async(this, null, function* () {
|
204
|
-
var _a, _b, _c, _d, _e;
|
205
|
-
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
206
|
-
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
207
|
-
return cache2.lastChange.resolved;
|
208
|
-
}
|
209
|
-
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
210
|
-
const rootWithProps = data.root;
|
211
|
-
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
212
|
-
changed,
|
213
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
214
|
-
});
|
215
|
-
cache2.lastChange = {
|
216
|
-
original: data.root,
|
217
|
-
resolved: resolvedRoot
|
218
|
-
};
|
219
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
220
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
221
|
-
});
|
222
|
-
}
|
223
|
-
return data.root;
|
224
|
-
});
|
225
|
-
}
|
226
|
-
|
227
|
-
// lib/resolve-all-data.ts
|
228
|
-
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
229
|
-
return __async(this, null, function* () {
|
230
|
-
const defaultedData = defaultData(data);
|
231
|
-
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
232
|
-
const { zones = {} } = data;
|
233
|
-
const zoneKeys = Object.keys(zones);
|
234
|
-
const resolvedZones = {};
|
235
|
-
for (let i = 0; i < zoneKeys.length; i++) {
|
236
|
-
const zoneKey = zoneKeys[i];
|
237
|
-
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
238
|
-
zones[zoneKey],
|
239
|
-
config,
|
240
|
-
onResolveStart,
|
241
|
-
onResolveEnd
|
242
|
-
);
|
243
|
-
}
|
244
|
-
return __spreadProps(__spreadValues({}, defaultedData), {
|
245
|
-
root: dynamicRoot,
|
246
|
-
content: yield resolveAllComponentData(
|
247
|
-
defaultedData.content,
|
248
|
-
config,
|
249
|
-
onResolveStart,
|
250
|
-
onResolveEnd
|
251
|
-
),
|
252
|
-
zones: resolvedZones
|
253
|
-
});
|
254
|
-
});
|
255
|
-
}
|
256
|
-
|
257
|
-
// lib/root-droppable-id.ts
|
258
|
-
init_react_import();
|
259
|
-
var rootDroppableId = "default-zone";
|
260
|
-
|
261
|
-
// lib/setup-zone.ts
|
262
|
-
init_react_import();
|
263
|
-
var setupZone = (data, zoneKey) => {
|
264
|
-
if (zoneKey === rootDroppableId) {
|
265
|
-
return data;
|
266
|
-
}
|
267
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
268
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
269
|
-
});
|
270
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
271
|
-
return newData;
|
272
|
-
};
|
273
|
-
|
274
|
-
export {
|
275
|
-
__spreadValues,
|
276
|
-
__spreadProps,
|
277
|
-
__objRest,
|
278
|
-
__commonJS,
|
279
|
-
__toESM,
|
280
|
-
__privateGet,
|
281
|
-
__privateAdd,
|
282
|
-
__privateSet,
|
283
|
-
__async,
|
284
|
-
init_react_import,
|
285
|
-
rootDroppableId,
|
286
|
-
setupZone,
|
287
|
-
getChanged,
|
288
|
-
resolveComponentData,
|
289
|
-
resolveRootData,
|
290
|
-
transformProps,
|
291
|
-
resolveAllData
|
292
|
-
};
|