@measured/puck 0.15.0-canary.480467a → 0.15.0-canary.aedd401
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +31 -15
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
@@ -232,7 +232,7 @@ type IframeConfig = {
|
|
232
232
|
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, }: {
|
233
233
|
children?: ReactNode;
|
234
234
|
config: UserConfig;
|
235
|
-
data: Data
|
235
|
+
data: Partial<Data>;
|
236
236
|
ui?: Partial<UiState>;
|
237
237
|
onChange?: (data: Data) => void;
|
238
238
|
onPublish?: (data: Data) => void;
|
@@ -266,7 +266,7 @@ declare namespace Puck {
|
|
266
266
|
|
267
267
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
268
268
|
config: UserConfig;
|
269
|
-
data: Data
|
269
|
+
data: Partial<Data>;
|
270
270
|
}): react_jsx_runtime.JSX.Element;
|
271
271
|
|
272
272
|
declare function migrate(data: Data): Data;
|
@@ -280,9 +280,9 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
280
280
|
[key: string]: any;
|
281
281
|
}) => RootProps;
|
282
282
|
}>;
|
283
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data
|
283
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
284
284
|
|
285
|
-
declare function resolveAllData(data: Data
|
285
|
+
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
|
286
286
|
root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
|
287
287
|
content: any[];
|
288
288
|
zones: Record<string, MappedItem[]>;
|
package/dist/index.js
CHANGED
@@ -33644,7 +33644,7 @@ function Puck({
|
|
33644
33644
|
() => createReducer({ config, record: historyStore.record })
|
33645
33645
|
);
|
33646
33646
|
const [initialAppState] = (0, import_react29.useState)(() => {
|
33647
|
-
var _a2, _b, _c, _d, _e;
|
33647
|
+
var _a2, _b, _c, _d, _e, _f;
|
33648
33648
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
33649
33649
|
let clientUiState = {};
|
33650
33650
|
if (typeof window !== "undefined") {
|
@@ -33671,11 +33671,12 @@ function Puck({
|
|
33671
33671
|
};
|
33672
33672
|
}
|
33673
33673
|
}
|
33674
|
-
const rootProps2 = initialData.root.props || initialData.root;
|
33675
|
-
const defaultedRootProps = __spreadValues(__spreadValues({}, (
|
33674
|
+
const rootProps2 = ((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props) || initialData.root || {};
|
33675
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_f = config.root) == null ? void 0 : _f.defaultProps), rootProps2);
|
33676
33676
|
return __spreadProps(__spreadValues({}, defaultAppState), {
|
33677
33677
|
data: __spreadProps(__spreadValues({}, initialData), {
|
33678
|
-
root: defaultedRootProps
|
33678
|
+
root: defaultedRootProps,
|
33679
|
+
content: initialData.content || []
|
33679
33680
|
}),
|
33680
33681
|
ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
|
33681
33682
|
// Store categories under componentList on state to allow render functions and plugins to modify
|
@@ -34043,10 +34044,14 @@ function Render({
|
|
34043
34044
|
data
|
34044
34045
|
}) {
|
34045
34046
|
var _a;
|
34046
|
-
const
|
34047
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
34048
|
+
root: data.root || {},
|
34049
|
+
content: data.content || []
|
34050
|
+
});
|
34051
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
34047
34052
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
34048
34053
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
34049
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
34054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
34050
34055
|
config.root.render,
|
34051
34056
|
__spreadProps(__spreadValues({}, rootProps), {
|
34052
34057
|
puck: {
|
@@ -34059,7 +34064,7 @@ function Render({
|
|
34059
34064
|
})
|
34060
34065
|
) });
|
34061
34066
|
}
|
34062
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId }) });
|
34067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId }) });
|
34063
34068
|
}
|
34064
34069
|
|
34065
34070
|
// lib/migrate.ts
|
@@ -34087,6 +34092,15 @@ function migrate(data) {
|
|
34087
34092
|
|
34088
34093
|
// lib/transform-props.ts
|
34089
34094
|
init_react_import();
|
34095
|
+
|
34096
|
+
// lib/default-data.ts
|
34097
|
+
init_react_import();
|
34098
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
34099
|
+
root: data.root || {},
|
34100
|
+
content: data.content || []
|
34101
|
+
});
|
34102
|
+
|
34103
|
+
// lib/transform-props.ts
|
34090
34104
|
function transformProps(data, propTransforms) {
|
34091
34105
|
const mapItem = (item) => {
|
34092
34106
|
if (propTransforms[item.type]) {
|
@@ -34096,18 +34110,19 @@ function transformProps(data, propTransforms) {
|
|
34096
34110
|
}
|
34097
34111
|
return item;
|
34098
34112
|
};
|
34099
|
-
const
|
34100
|
-
|
34113
|
+
const defaultedData = defaultData(data);
|
34114
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
34115
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
34101
34116
|
if (propTransforms["root"]) {
|
34102
|
-
if (
|
34117
|
+
if (defaultedData.root.props) {
|
34103
34118
|
newRoot.props = propTransforms["root"](rootProps);
|
34104
34119
|
} else {
|
34105
34120
|
newRoot = propTransforms["root"](rootProps);
|
34106
34121
|
}
|
34107
34122
|
}
|
34108
|
-
const afterPropTransforms = __spreadProps(__spreadValues({},
|
34123
|
+
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
34109
34124
|
root: newRoot,
|
34110
|
-
content:
|
34125
|
+
content: defaultedData.content.map(mapItem),
|
34111
34126
|
zones: Object.keys(data.zones || {}).reduce(
|
34112
34127
|
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
34113
34128
|
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
@@ -34122,7 +34137,8 @@ function transformProps(data, propTransforms) {
|
|
34122
34137
|
init_react_import();
|
34123
34138
|
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
34124
34139
|
return __async(this, null, function* () {
|
34125
|
-
const
|
34140
|
+
const defaultedData = defaultData(data);
|
34141
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
34126
34142
|
const { zones = {} } = data;
|
34127
34143
|
const zoneKeys = Object.keys(zones);
|
34128
34144
|
const resolvedZones = {};
|
@@ -34135,10 +34151,10 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
34135
34151
|
onResolveEnd
|
34136
34152
|
);
|
34137
34153
|
}
|
34138
|
-
return __spreadProps(__spreadValues({},
|
34154
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
34139
34155
|
root: dynamicRoot,
|
34140
34156
|
content: yield resolveAllComponentData(
|
34141
|
-
|
34157
|
+
defaultedData.content,
|
34142
34158
|
config,
|
34143
34159
|
onResolveStart,
|
34144
34160
|
onResolveEnd
|
package/package.json
CHANGED