@measured/puck 0.15.0-canary.480467a → 0.15.0-canary.91dff22
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -4
- package/dist/{Config-550396e1.d.ts → Config-6344ec1b.d.ts} +35 -14
- package/dist/index.css +994 -990
- package/dist/index.d.ts +43 -28
- package/dist/index.js +2908 -2794
- package/dist/rsc.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -21,9 +21,6 @@ type Viewport = {
|
|
21
21
|
};
|
22
22
|
type Viewports = Viewport[];
|
23
23
|
|
24
|
-
type WithPuckProps<Props> = Props & {
|
25
|
-
id: string;
|
26
|
-
};
|
27
24
|
type FieldOption = {
|
28
25
|
label: string;
|
29
26
|
value: string | number | boolean;
|
@@ -114,17 +111,36 @@ type CustomField<Props extends any = {}> = BaseField & {
|
|
114
111
|
type: "custom";
|
115
112
|
render: (props: {
|
116
113
|
field: CustomField<Props>;
|
117
|
-
name
|
114
|
+
name?: string;
|
115
|
+
id: string;
|
118
116
|
value: Props;
|
119
117
|
onChange: (value: Props) => void;
|
120
118
|
readOnly?: boolean;
|
121
119
|
}) => ReactElement;
|
122
120
|
};
|
123
|
-
type Field<Props extends {
|
121
|
+
type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
|
124
122
|
[key: string]: any;
|
125
|
-
}
|
123
|
+
} ? Props : any> | ObjectField<Props extends {
|
124
|
+
[key: string]: any;
|
125
|
+
} ? Props : any> | ExternalField<Props extends {
|
126
126
|
[key: string]: any;
|
127
|
-
}
|
127
|
+
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
128
|
+
[key: string]: any;
|
129
|
+
} ? Props : any> | CustomField<Props>;
|
130
|
+
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
131
|
+
[PropName in keyof Omit<Required<ComponentProps>, "children" | "editMode">]: Field<ComponentProps[PropName]>;
|
132
|
+
};
|
133
|
+
type FieldProps<ValueType = any, F = Field<any>> = {
|
134
|
+
field: F;
|
135
|
+
value: ValueType;
|
136
|
+
id?: string;
|
137
|
+
onChange: (value: ValueType, uiState?: Partial<UiState>) => void;
|
138
|
+
readOnly?: boolean;
|
139
|
+
};
|
140
|
+
|
141
|
+
type WithPuckProps<Props> = Props & {
|
142
|
+
id: string;
|
143
|
+
};
|
128
144
|
type DefaultRootProps = {
|
129
145
|
title?: string;
|
130
146
|
[key: string]: any;
|
@@ -133,9 +149,6 @@ type DefaultComponentProps = {
|
|
133
149
|
[key: string]: any;
|
134
150
|
editMode?: boolean;
|
135
151
|
};
|
136
|
-
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
137
|
-
[PropName in keyof Omit<Required<ComponentProps>, "children" | "editMode">]: Field<ComponentProps[PropName]>;
|
138
|
-
};
|
139
152
|
type Content<Props extends {
|
140
153
|
[key: string]: any;
|
141
154
|
} = {
|
@@ -152,8 +165,16 @@ type ComponentConfig<ComponentProps extends DefaultComponentProps = DefaultCompo
|
|
152
165
|
label?: string;
|
153
166
|
defaultProps?: DefaultProps;
|
154
167
|
fields?: Fields<ComponentProps>;
|
168
|
+
resolveFields?: (data: DataShape, params: {
|
169
|
+
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
170
|
+
fields: Fields<ComponentProps>;
|
171
|
+
lastFields: Fields<ComponentProps>;
|
172
|
+
lastData: DataShape;
|
173
|
+
appState: AppState;
|
174
|
+
}) => Promise<Fields<ComponentProps>> | Fields<ComponentProps>;
|
155
175
|
resolveData?: (data: DataShape, params: {
|
156
176
|
changed: Partial<Record<keyof ComponentProps, boolean>>;
|
177
|
+
lastData: DataShape;
|
157
178
|
}) => Promise<{
|
158
179
|
props?: Partial<ComponentProps>;
|
159
180
|
readOnly?: Partial<Record<keyof ComponentProps, boolean>>;
|
@@ -179,7 +200,7 @@ type Config<Props extends Record<string, any> = Record<string, any>, RootProps e
|
|
179
200
|
children?: ReactNode;
|
180
201
|
}, Partial<RootProps & {
|
181
202
|
children?: ReactNode;
|
182
|
-
}>,
|
203
|
+
}>, RootData>>;
|
183
204
|
};
|
184
205
|
type BaseData<Props extends {
|
185
206
|
[key: string]: any;
|
@@ -192,11 +213,11 @@ type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps>
|
|
192
213
|
type: keyof Props;
|
193
214
|
props: WithPuckProps<Props>;
|
194
215
|
} & BaseData<Props>;
|
195
|
-
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = {
|
216
|
+
type RootDataWithProps<Props extends DefaultRootProps = DefaultRootProps> = BaseData<Props> & {
|
196
217
|
props: Props;
|
197
218
|
};
|
198
219
|
type RootDataWithoutProps<Props extends DefaultRootProps = DefaultRootProps> = Props;
|
199
|
-
type RootData<Props extends DefaultRootProps = DefaultRootProps> =
|
220
|
+
type RootData<Props extends DefaultRootProps = DefaultRootProps> = Partial<RootDataWithProps<Props>> & Partial<RootDataWithoutProps<Props>>;
|
200
221
|
type MappedItem = ComponentData;
|
201
222
|
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = {
|
202
223
|
root: RootData<RootProps>;
|
@@ -237,4 +258,4 @@ type AppState = {
|
|
237
258
|
ui: UiState;
|
238
259
|
};
|
239
260
|
|
240
|
-
export { AppState as A,
|
261
|
+
export { AppState as A, BaseData as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DefaultRootProps as b, DropZoneProps as c, DefaultComponentProps as d, RootData as e, ComponentData as f, Content as g, PuckContext as h, ComponentConfig as i, RootDataWithoutProps as j, ItemWithId as k, ArrayState as l, BaseField as m, TextareaField as n, RadioField as o, ArrayField as p, Adaptor as q, ExternalField as r, CustomField as s, Fields as t };
|