@measured/puck 0.11.0-canary.4613df4 → 0.11.0-canary.7f13efc
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 +51 -68
- package/dist/index.css +228 -173
- package/dist/index.d.ts +49 -57
- package/dist/index.js +30528 -1026
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -8,16 +8,8 @@ type ItemSelector = {
|
|
8
8
|
zone?: string;
|
9
9
|
};
|
10
10
|
|
11
|
-
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
12
|
-
name: string;
|
13
|
-
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
14
|
-
mapProp?: (value: TableShape) => PropShape;
|
15
|
-
};
|
16
11
|
type WithPuckProps<Props> = Props & {
|
17
12
|
id: string;
|
18
|
-
_meta?: {
|
19
|
-
readOnly: Partial<Record<keyof Props, boolean>>;
|
20
|
-
};
|
21
13
|
};
|
22
14
|
type BaseField = {
|
23
15
|
label?: string;
|
@@ -50,8 +42,9 @@ type ExternalField<Props extends {
|
|
50
42
|
[key: string]: any;
|
51
43
|
}> = BaseField & {
|
52
44
|
type: "external";
|
53
|
-
|
54
|
-
|
45
|
+
placeholder?: string;
|
46
|
+
fetchList: () => Promise<any[] | null>;
|
47
|
+
mapProp?: (value: any) => Props;
|
55
48
|
getItemSummary: (item: Props, index?: number) => string;
|
56
49
|
};
|
57
50
|
type CustomField<Props extends {
|
@@ -74,11 +67,12 @@ type Field<Props extends {
|
|
74
67
|
[key: string]: any;
|
75
68
|
}> = TextField | SelectField | ArrayField<Props> | ExternalField<Props> | CustomField;
|
76
69
|
type DefaultRootProps = {
|
77
|
-
|
78
|
-
title: string;
|
79
|
-
editMode: boolean;
|
70
|
+
title?: string;
|
80
71
|
[key: string]: any;
|
81
72
|
};
|
73
|
+
type DefaultRootRenderProps = {
|
74
|
+
editMode: boolean;
|
75
|
+
} & DefaultRootProps;
|
82
76
|
type DefaultComponentProps = {
|
83
77
|
[key: string]: any;
|
84
78
|
editMode?: boolean;
|
@@ -90,15 +84,14 @@ type Content<Props extends {
|
|
90
84
|
[key: string]: any;
|
91
85
|
} = {
|
92
86
|
[key: string]: any;
|
93
|
-
}> =
|
94
|
-
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps
|
87
|
+
}> = ComponentData<Props>[];
|
88
|
+
type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps, DataShape = ComponentData<ComponentProps>> = {
|
95
89
|
render: (props: WithPuckProps<ComponentProps>) => ReactElement;
|
96
90
|
defaultProps?: DefaultProps;
|
97
91
|
fields?: Fields<ComponentProps>;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}>;
|
92
|
+
resolveData?: (data: DataShape, params: {
|
93
|
+
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
94
|
+
}) => Promise<Partial<ComponentDataWithOptionalProps<ComponentProps>>> | Partial<ComponentDataWithOptionalProps<ComponentProps>>;
|
102
95
|
};
|
103
96
|
type Category<ComponentName> = {
|
104
97
|
components?: ComponentName[];
|
@@ -115,38 +108,42 @@ type Config<Props extends {
|
|
115
108
|
other?: Category<Props>;
|
116
109
|
};
|
117
110
|
components: {
|
118
|
-
[ComponentName in keyof Props]: ComponentConfig<Props[ComponentName], Props[ComponentName]>;
|
111
|
+
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
119
112
|
};
|
120
|
-
root?: ComponentConfig<RootProps & {
|
113
|
+
root?: Partial<ComponentConfig<RootProps & {
|
121
114
|
children: ReactNode;
|
122
115
|
}, Partial<RootProps & {
|
123
116
|
children: ReactNode;
|
124
|
-
}
|
117
|
+
}>, RootDataWithProps<RootProps>>>;
|
125
118
|
};
|
126
|
-
type
|
119
|
+
type BaseData<Props extends {
|
127
120
|
[key: string]: any;
|
128
121
|
} = {
|
129
122
|
[key: string]: any;
|
130
123
|
}> = {
|
131
|
-
|
132
|
-
props: WithPuckProps<{
|
133
|
-
[key: string]: any;
|
134
|
-
}>;
|
124
|
+
readOnly?: Partial<Record<keyof Props, boolean>>;
|
135
125
|
};
|
136
|
-
type
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
126
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
127
|
+
type: keyof Props;
|
128
|
+
props: WithPuckProps<Props>;
|
129
|
+
} & BaseData<Props>;
|
130
|
+
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
131
|
+
props: Props;
|
132
|
+
};
|
133
|
+
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
134
|
+
type RootData<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
135
|
+
type ComponentDataWithOptionalProps<Props extends {
|
142
136
|
[key: string]: any;
|
143
137
|
} = {
|
144
|
-
title: string;
|
145
138
|
[key: string]: any;
|
146
|
-
}> = {
|
147
|
-
|
148
|
-
|
149
|
-
|
139
|
+
}> = Omit<ComponentData, "props"> & {
|
140
|
+
props: Partial<WithPuckProps<Props>>;
|
141
|
+
};
|
142
|
+
type MappedItem = ComponentData;
|
143
|
+
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
144
|
+
root: RootData<RootProps>;
|
145
|
+
content: Content<WithPuckProps<Props>>;
|
146
|
+
zones?: Record<string, Content<WithPuckProps<Props>>>;
|
150
147
|
};
|
151
148
|
type ItemWithId = {
|
152
149
|
_arrayId: string;
|
@@ -221,13 +218,13 @@ type RemoveAction = {
|
|
221
218
|
index: number;
|
222
219
|
zone: string;
|
223
220
|
};
|
224
|
-
type
|
221
|
+
type SetUiAction = {
|
225
222
|
type: "setUi";
|
226
|
-
ui: Partial<UiState
|
223
|
+
ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
|
227
224
|
};
|
228
225
|
type SetDataAction = {
|
229
226
|
type: "setData";
|
230
|
-
data: Partial<Data
|
227
|
+
data: Partial<Data> | ((previous: Data) => Partial<Data>);
|
231
228
|
};
|
232
229
|
type SetAction = {
|
233
230
|
type: "set";
|
@@ -243,7 +240,7 @@ type UnregisterZoneAction = {
|
|
243
240
|
};
|
244
241
|
type PuckAction = {
|
245
242
|
recordHistory?: boolean;
|
246
|
-
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction |
|
243
|
+
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
247
244
|
|
248
245
|
type PathData = Record<string, {
|
249
246
|
path: string[];
|
@@ -252,7 +249,7 @@ type PathData = Record<string, {
|
|
252
249
|
type DropZoneContext = {
|
253
250
|
data: Data;
|
254
251
|
config: Config;
|
255
|
-
|
252
|
+
componentState?: Record<string, any>;
|
256
253
|
itemSelector?: ItemSelector | null;
|
257
254
|
setItemSelector?: (newIndex: ItemSelector | null) => void;
|
258
255
|
dispatch?: (action: PuckAction) => void;
|
@@ -346,24 +343,19 @@ declare function Render({ config, data }: {
|
|
346
343
|
data: Data;
|
347
344
|
}): react_jsx_runtime.JSX.Element;
|
348
345
|
|
349
|
-
declare const
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
}[];
|
354
|
-
zones: Record<string, MappedItem<{
|
355
|
-
[key: string]: any;
|
356
|
-
}>[]>;
|
357
|
-
root: {
|
358
|
-
[key: string]: any;
|
359
|
-
title: string;
|
360
|
-
};
|
346
|
+
declare const resolveAllData: (data: Data, config: Config, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
|
347
|
+
root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
|
348
|
+
content: any[];
|
349
|
+
zones: Record<string, MappedItem[]>;
|
361
350
|
}>;
|
362
351
|
|
363
|
-
declare const FieldLabel: ({ children, icon, label, }: {
|
352
|
+
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
364
353
|
children?: ReactNode;
|
365
354
|
icon?: ReactNode;
|
366
355
|
label: string;
|
356
|
+
el?: "div" | "label" | undefined;
|
357
|
+
readOnly?: boolean | undefined;
|
358
|
+
className?: string | undefined;
|
367
359
|
}) => react_jsx_runtime.JSX.Element;
|
368
360
|
|
369
|
-
export {
|
361
|
+
export { AppState, ArrayField, ArrayState, BaseData, BaseField, Button, ComponentConfig, ComponentData, Config, Content, CustomField, Data, DefaultComponentProps, DefaultRootProps, DefaultRootRenderProps, DropZone, DropZoneProvider, ExternalField, Field, FieldLabel, Fields, IconButton, ItemWithId, MappedItem, Puck, Render, RootData, RootDataWithProps, RootDataWithoutProps, SelectField, TextField, UiState, dropZoneContext, resolveAllData };
|