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