@measured/puck 0.19.4-canary.fde74e8a → 0.20.0-canary.274fe3d9
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 +30 -29
- package/dist/{chunk-IM42S4YL.mjs → chunk-32MJ3X3H.mjs} +295 -256
- package/dist/chunk-4KAREQPB.mjs +8436 -0
- package/dist/index.css +3 -1
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +1085 -1082
- package/dist/index.mjs +25 -8454
- package/dist/no-external.css +1895 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9315 -0
- package/dist/no-external.mjs +52 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +50 -8
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-DrNRq2FV.d.mts} +22 -29
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-DrNRq2FV.d.ts} +22 -29
- package/package.json +3 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Action,
|
|
3
|
+
ActionBar,
|
|
4
|
+
AutoField,
|
|
5
|
+
Button,
|
|
6
|
+
Drawer,
|
|
7
|
+
DropZone,
|
|
8
|
+
FieldLabel,
|
|
9
|
+
Group,
|
|
10
|
+
IconButton,
|
|
11
|
+
Label,
|
|
12
|
+
Puck,
|
|
13
|
+
Render,
|
|
14
|
+
createUsePuck,
|
|
15
|
+
overrideKeys,
|
|
16
|
+
renderContext,
|
|
17
|
+
useGetPuck,
|
|
18
|
+
usePuck
|
|
19
|
+
} from "./chunk-4KAREQPB.mjs";
|
|
20
|
+
import {
|
|
21
|
+
init_react_import,
|
|
22
|
+
migrate,
|
|
23
|
+
resolveAllData,
|
|
24
|
+
transformProps,
|
|
25
|
+
walkTree
|
|
26
|
+
} from "./chunk-32MJ3X3H.mjs";
|
|
27
|
+
|
|
28
|
+
// bundle/no-external.ts
|
|
29
|
+
init_react_import();
|
|
30
|
+
export {
|
|
31
|
+
Action,
|
|
32
|
+
ActionBar,
|
|
33
|
+
AutoField,
|
|
34
|
+
Button,
|
|
35
|
+
Drawer,
|
|
36
|
+
DropZone,
|
|
37
|
+
FieldLabel,
|
|
38
|
+
Group,
|
|
39
|
+
IconButton,
|
|
40
|
+
Label,
|
|
41
|
+
Puck,
|
|
42
|
+
Render,
|
|
43
|
+
createUsePuck,
|
|
44
|
+
migrate,
|
|
45
|
+
overrideKeys,
|
|
46
|
+
renderContext,
|
|
47
|
+
resolveAllData,
|
|
48
|
+
transformProps,
|
|
49
|
+
useGetPuck,
|
|
50
|
+
usePuck,
|
|
51
|
+
walkTree
|
|
52
|
+
};
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-DrNRq2FV.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-DrNRq2FV.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-DrNRq2FV.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-DrNRq2FV.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.js
CHANGED
|
@@ -64,7 +64,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
// rsc.tsx
|
|
67
|
+
// bundle/rsc.tsx
|
|
68
68
|
var rsc_exports = {};
|
|
69
69
|
__export(rsc_exports, {
|
|
70
70
|
Render: () => Render,
|
|
@@ -816,8 +816,8 @@ var migrations = [
|
|
|
816
816
|
return data;
|
|
817
817
|
},
|
|
818
818
|
// Migrate zones to slots
|
|
819
|
-
(data, config) => {
|
|
820
|
-
var _a;
|
|
819
|
+
(data, config, migrationOptions) => {
|
|
820
|
+
var _a, _b;
|
|
821
821
|
if (!config) return data;
|
|
822
822
|
console.log("Migrating DropZones to slots...");
|
|
823
823
|
const updatedItems = {};
|
|
@@ -825,13 +825,13 @@ var migrations = [
|
|
|
825
825
|
const { indexes } = walkAppState(appState, config);
|
|
826
826
|
const deletedCompounds = [];
|
|
827
827
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
828
|
-
var _a2,
|
|
828
|
+
var _a2, _b2, _c;
|
|
829
829
|
if (zoneType === "dropzone") {
|
|
830
830
|
const [id, slotName] = zoneCompound.split(":");
|
|
831
831
|
const nodeData = indexes.nodes[id].data;
|
|
832
832
|
const componentType = nodeData.type;
|
|
833
833
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
834
|
-
if (((
|
|
834
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
835
835
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
836
836
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
837
837
|
[slotName]: content
|
|
@@ -860,7 +860,49 @@ var migrations = [
|
|
|
860
860
|
);
|
|
861
861
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
862
862
|
});
|
|
863
|
-
|
|
863
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
864
|
+
const unmigratedZonesGrouped = {};
|
|
865
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
866
|
+
var _a2;
|
|
867
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
868
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
869
|
+
if (!content) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
873
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
874
|
+
}
|
|
875
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
876
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
880
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
881
|
+
return content.map((child) => {
|
|
882
|
+
var _a2;
|
|
883
|
+
if (child.props.id !== componentId) {
|
|
884
|
+
return child;
|
|
885
|
+
}
|
|
886
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
887
|
+
if (!migrateFn) {
|
|
888
|
+
return child;
|
|
889
|
+
}
|
|
890
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
891
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
892
|
+
Object.keys(zones).forEach((propName) => {
|
|
893
|
+
var _a3;
|
|
894
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
895
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
896
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
897
|
+
});
|
|
898
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
899
|
+
props: migratedProps
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
864
906
|
const [_, propName] = zoneCompound.split(":");
|
|
865
907
|
throw new Error(
|
|
866
908
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -870,9 +912,9 @@ var migrations = [
|
|
|
870
912
|
return updated.data;
|
|
871
913
|
}
|
|
872
914
|
];
|
|
873
|
-
function migrate(data, config) {
|
|
915
|
+
function migrate(data, config, migrationOptions) {
|
|
874
916
|
return migrations == null ? void 0 : migrations.reduce(
|
|
875
|
-
(acc, migration) => migration(acc, config),
|
|
917
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
876
918
|
data
|
|
877
919
|
);
|
|
878
920
|
}
|
package/dist/rsc.mjs
CHANGED
|
@@ -17,7 +17,7 @@ type DropZoneProps = {
|
|
|
17
17
|
|
|
18
18
|
type FieldOption = {
|
|
19
19
|
label: string;
|
|
20
|
-
value: string | number | boolean;
|
|
20
|
+
value: string | number | boolean | undefined | null | object;
|
|
21
21
|
};
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
|
@@ -49,11 +49,11 @@ type RadioField = BaseField & {
|
|
|
49
49
|
type: "radio";
|
|
50
50
|
options: FieldOptions;
|
|
51
51
|
};
|
|
52
|
-
type ArrayField<Props extends {
|
|
52
|
+
type ArrayField<Props extends any = {
|
|
53
53
|
[key: string]: any;
|
|
54
|
-
} = {
|
|
54
|
+
}> = Props extends {
|
|
55
55
|
[key: string]: any;
|
|
56
|
-
}
|
|
56
|
+
} ? BaseField & {
|
|
57
57
|
type: "array";
|
|
58
58
|
arrayFields: {
|
|
59
59
|
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
|
@@ -62,14 +62,12 @@ type ArrayField<Props extends {
|
|
|
62
62
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
63
63
|
max?: number;
|
|
64
64
|
min?: number;
|
|
65
|
-
};
|
|
66
|
-
type ObjectField<Props extends {
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
} = {
|
|
65
|
+
} : never;
|
|
66
|
+
type ObjectField<Props extends any = {
|
|
69
67
|
[key: string]: any;
|
|
70
68
|
}> = BaseField & {
|
|
71
69
|
type: "object";
|
|
72
|
-
objectFields:
|
|
70
|
+
objectFields: {
|
|
73
71
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
|
74
72
|
};
|
|
75
73
|
};
|
|
@@ -78,20 +76,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
|
|
|
78
76
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
79
77
|
mapProp?: (value: TableShape) => PropShape;
|
|
80
78
|
};
|
|
81
|
-
type
|
|
82
|
-
|
|
83
|
-
} = {
|
|
79
|
+
type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
|
|
80
|
+
type ExternalFieldWithAdaptor<Props extends any = {
|
|
84
81
|
[key: string]: any;
|
|
85
82
|
}> = BaseField & {
|
|
86
83
|
type: "external";
|
|
87
84
|
placeholder?: string;
|
|
88
85
|
adaptor: Adaptor<any, any, Props>;
|
|
89
86
|
adaptorParams?: object;
|
|
90
|
-
getItemSummary: (item: Props
|
|
87
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
91
88
|
};
|
|
92
|
-
type ExternalField<Props extends {
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
} = {
|
|
89
|
+
type ExternalField<Props extends any = {
|
|
95
90
|
[key: string]: any;
|
|
96
91
|
}> = BaseField & {
|
|
97
92
|
type: "external";
|
|
@@ -102,7 +97,7 @@ type ExternalField<Props extends {
|
|
|
102
97
|
}) => Promise<any[] | null>;
|
|
103
98
|
mapProp?: (value: any) => Props;
|
|
104
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
105
|
-
getItemSummary?: (item: Props
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
|
|
106
101
|
showSearch?: boolean;
|
|
107
102
|
renderFooter?: (props: {
|
|
108
103
|
items: any[];
|
|
@@ -128,15 +123,7 @@ type SlotField = BaseField & {
|
|
|
128
123
|
allow?: string[];
|
|
129
124
|
disallow?: string[];
|
|
130
125
|
};
|
|
131
|
-
type Field<
|
|
132
|
-
[key: string]: any;
|
|
133
|
-
} ? Props : any> | ObjectField<Props extends {
|
|
134
|
-
[key: string]: any;
|
|
135
|
-
} ? Props : any> | ExternalField<Props extends {
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
} ? Props : any> | CustomField<Props> | SlotField;
|
|
126
|
+
type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
140
127
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
|
141
128
|
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
|
142
129
|
};
|
|
@@ -222,12 +209,13 @@ type WithChildren<Props> = Props & {
|
|
|
222
209
|
};
|
|
223
210
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
|
224
211
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
|
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]> = {
|
|
212
|
+
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>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
226
213
|
UserConfig: UserConfig;
|
|
227
214
|
UserProps: UserProps;
|
|
228
215
|
UserRootProps: UserRootProps;
|
|
229
216
|
UserData: UserData;
|
|
230
217
|
UserAppState: UserAppState;
|
|
218
|
+
UserPublicAppState: UserPublicAppState;
|
|
231
219
|
UserComponentData: UserComponentData;
|
|
232
220
|
};
|
|
233
221
|
|
|
@@ -535,7 +523,12 @@ type PuckAction = {
|
|
|
535
523
|
recordHistory?: boolean;
|
|
536
524
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
525
|
|
|
538
|
-
|
|
526
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
527
|
+
migrateDynamicZonesForComponent?: {
|
|
528
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
532
|
|
|
540
533
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
534
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -556,4 +549,4 @@ type WalkTreeOptions = {
|
|
|
556
549
|
};
|
|
557
550
|
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;
|
|
558
551
|
|
|
559
|
-
export { type
|
|
552
|
+
export { type RadioField as $, type AppState as A, type RootConfig as B, type Config as C, type DropZoneProps as D, type BaseData as E, type Fields as F, type RootDataWithoutProps as G, type History as H, type IframeConfig as I, type RootData as J, type ComponentDataOptionalId as K, type MappedItem as L, type Metadata as M, type ComponentDataMap as N, type Overrides as O, type Permissions as P, type Content as Q, type RootDataWithProps as R, type Slot as S, type BaseField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type TextField as X, type NumberField as Y, type TextareaField as Z, type SelectField as _, type ComponentData as a, type ArrayField as a0, type ObjectField as a1, type Adaptor as a2, type ExternalFieldWithAdaptor as a3, type ExternalField as a4, type CustomFieldRender as a5, type CustomField as a6, type SlotField as a7, type PuckContext as a8, type DefaultRootFieldProps as a9, type DefaultRootRenderProps as aa, type DefaultRootProps as ab, type DefaultComponentProps as ac, type WithId as ad, type WithPuckProps as ae, type AsFieldProps as af, type WithChildren as ag, type ExtractPropsFromConfig as ah, type ExtractRootPropsFromConfig as ai, 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, migrate as m, type Direction as n, type DragAxis as o, type Viewport as p, overrideKeys as q, resolveAllData as r, type OverrideKey as s, transformProps as t, type FieldRenderFunctions as u, type ItemWithId as v, walkTree as w, type ArrayState as x, type SlotComponent as y, type PuckComponent as z };
|
|
@@ -17,7 +17,7 @@ type DropZoneProps = {
|
|
|
17
17
|
|
|
18
18
|
type FieldOption = {
|
|
19
19
|
label: string;
|
|
20
|
-
value: string | number | boolean;
|
|
20
|
+
value: string | number | boolean | undefined | null | object;
|
|
21
21
|
};
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
|
@@ -49,11 +49,11 @@ type RadioField = BaseField & {
|
|
|
49
49
|
type: "radio";
|
|
50
50
|
options: FieldOptions;
|
|
51
51
|
};
|
|
52
|
-
type ArrayField<Props extends {
|
|
52
|
+
type ArrayField<Props extends any = {
|
|
53
53
|
[key: string]: any;
|
|
54
|
-
} = {
|
|
54
|
+
}> = Props extends {
|
|
55
55
|
[key: string]: any;
|
|
56
|
-
}
|
|
56
|
+
} ? BaseField & {
|
|
57
57
|
type: "array";
|
|
58
58
|
arrayFields: {
|
|
59
59
|
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
|
@@ -62,14 +62,12 @@ type ArrayField<Props extends {
|
|
|
62
62
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
63
63
|
max?: number;
|
|
64
64
|
min?: number;
|
|
65
|
-
};
|
|
66
|
-
type ObjectField<Props extends {
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
} = {
|
|
65
|
+
} : never;
|
|
66
|
+
type ObjectField<Props extends any = {
|
|
69
67
|
[key: string]: any;
|
|
70
68
|
}> = BaseField & {
|
|
71
69
|
type: "object";
|
|
72
|
-
objectFields:
|
|
70
|
+
objectFields: {
|
|
73
71
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
|
74
72
|
};
|
|
75
73
|
};
|
|
@@ -78,20 +76,17 @@ type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, Pr
|
|
|
78
76
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
79
77
|
mapProp?: (value: TableShape) => PropShape;
|
|
80
78
|
};
|
|
81
|
-
type
|
|
82
|
-
|
|
83
|
-
} = {
|
|
79
|
+
type NotUndefined<T> = T extends undefined ? Record<string, any> : T;
|
|
80
|
+
type ExternalFieldWithAdaptor<Props extends any = {
|
|
84
81
|
[key: string]: any;
|
|
85
82
|
}> = BaseField & {
|
|
86
83
|
type: "external";
|
|
87
84
|
placeholder?: string;
|
|
88
85
|
adaptor: Adaptor<any, any, Props>;
|
|
89
86
|
adaptorParams?: object;
|
|
90
|
-
getItemSummary: (item: Props
|
|
87
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
|
|
91
88
|
};
|
|
92
|
-
type ExternalField<Props extends {
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
} = {
|
|
89
|
+
type ExternalField<Props extends any = {
|
|
95
90
|
[key: string]: any;
|
|
96
91
|
}> = BaseField & {
|
|
97
92
|
type: "external";
|
|
@@ -102,7 +97,7 @@ type ExternalField<Props extends {
|
|
|
102
97
|
}) => Promise<any[] | null>;
|
|
103
98
|
mapProp?: (value: any) => Props;
|
|
104
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
105
|
-
getItemSummary?: (item: Props
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
|
|
106
101
|
showSearch?: boolean;
|
|
107
102
|
renderFooter?: (props: {
|
|
108
103
|
items: any[];
|
|
@@ -128,15 +123,7 @@ type SlotField = BaseField & {
|
|
|
128
123
|
allow?: string[];
|
|
129
124
|
disallow?: string[];
|
|
130
125
|
};
|
|
131
|
-
type Field<
|
|
132
|
-
[key: string]: any;
|
|
133
|
-
} ? Props : any> | ObjectField<Props extends {
|
|
134
|
-
[key: string]: any;
|
|
135
|
-
} ? Props : any> | ExternalField<Props extends {
|
|
136
|
-
[key: string]: any;
|
|
137
|
-
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
} ? Props : any> | CustomField<Props> | SlotField;
|
|
126
|
+
type Field<ValueType = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType> | ObjectField<ValueType> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
140
127
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
|
141
128
|
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
|
142
129
|
};
|
|
@@ -222,12 +209,13 @@ type WithChildren<Props> = Props & {
|
|
|
222
209
|
};
|
|
223
210
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
|
224
211
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
|
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]> = {
|
|
212
|
+
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>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
226
213
|
UserConfig: UserConfig;
|
|
227
214
|
UserProps: UserProps;
|
|
228
215
|
UserRootProps: UserRootProps;
|
|
229
216
|
UserData: UserData;
|
|
230
217
|
UserAppState: UserAppState;
|
|
218
|
+
UserPublicAppState: UserPublicAppState;
|
|
231
219
|
UserComponentData: UserComponentData;
|
|
232
220
|
};
|
|
233
221
|
|
|
@@ -535,7 +523,12 @@ type PuckAction = {
|
|
|
535
523
|
recordHistory?: boolean;
|
|
536
524
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
525
|
|
|
538
|
-
|
|
526
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
527
|
+
migrateDynamicZonesForComponent?: {
|
|
528
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
532
|
|
|
540
533
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
534
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -556,4 +549,4 @@ type WalkTreeOptions = {
|
|
|
556
549
|
};
|
|
557
550
|
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;
|
|
558
551
|
|
|
559
|
-
export { type
|
|
552
|
+
export { type RadioField as $, type AppState as A, type RootConfig as B, type Config as C, type DropZoneProps as D, type BaseData as E, type Fields as F, type RootDataWithoutProps as G, type History as H, type IframeConfig as I, type RootData as J, type ComponentDataOptionalId as K, type MappedItem as L, type Metadata as M, type ComponentDataMap as N, type Overrides as O, type Permissions as P, type Content as Q, type RootDataWithProps as R, type Slot as S, type BaseField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type TextField as X, type NumberField as Y, type TextareaField as Z, type SelectField as _, type ComponentData as a, type ArrayField as a0, type ObjectField as a1, type Adaptor as a2, type ExternalFieldWithAdaptor as a3, type ExternalField as a4, type CustomFieldRender as a5, type CustomField as a6, type SlotField as a7, type PuckContext as a8, type DefaultRootFieldProps as a9, type DefaultRootRenderProps as aa, type DefaultRootProps as ab, type DefaultComponentProps as ac, type WithId as ad, type WithPuckProps as ae, type AsFieldProps as af, type WithChildren as ag, type ExtractPropsFromConfig as ah, type ExtractRootPropsFromConfig as ai, 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, migrate as m, type Direction as n, type DragAxis as o, type Viewport as p, overrideKeys as q, resolveAllData as r, type OverrideKey as s, transformProps as t, type FieldRenderFunctions as u, type ItemWithId as v, walkTree as w, type ArrayState as x, type SlotComponent as y, type PuckComponent as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-canary.274fe3d9",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"require": "./dist/rsc.js"
|
|
28
28
|
},
|
|
29
29
|
"./puck.css": "./dist/index.css",
|
|
30
|
+
"./no-external.css": "./dist/no-external.css",
|
|
30
31
|
"./dist/index.css": "./dist/index.css",
|
|
31
32
|
"./package.json": "./package.json"
|
|
32
33
|
},
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"license": "MIT",
|
|
41
42
|
"scripts": {
|
|
42
43
|
"lint": "eslint \"**/*.ts*\"",
|
|
43
|
-
"build": "rm -rf dist && tsup index.ts rsc.tsx",
|
|
44
|
+
"build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts",
|
|
44
45
|
"test": "jest",
|
|
45
46
|
"prepare": "cp ../../README.md . && yarn build",
|
|
46
47
|
"postpublish": "rm README.md"
|