@measured/puck 0.17.0-canary.f71da6d → 0.17.0-canary.fe9321f
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +211 -156
- package/dist/index.mjs +123 -68
- package/dist/{resolve-all-data-C7aAQCY3.d.mts → resolve-all-data-zN5E6nBu.d.mts} +1 -1
- package/dist/{resolve-all-data-C7aAQCY3.d.ts → resolve-all-data-zN5E6nBu.d.ts} +1 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -23,35 +23,45 @@ var require_classnames = __commonJS({
|
|
|
23
23
|
(function() {
|
|
24
24
|
"use strict";
|
|
25
25
|
var hasOwn = {}.hasOwnProperty;
|
|
26
|
-
var nativeCodeString = "[native code]";
|
|
27
26
|
function classNames() {
|
|
28
|
-
var classes =
|
|
27
|
+
var classes = "";
|
|
29
28
|
for (var i = 0; i < arguments.length; i++) {
|
|
30
29
|
var arg = arguments[i];
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
if (argType === "string" || argType === "number") {
|
|
34
|
-
classes.push(arg);
|
|
35
|
-
} else if (Array.isArray(arg)) {
|
|
36
|
-
if (arg.length) {
|
|
37
|
-
var inner = classNames.apply(null, arg);
|
|
38
|
-
if (inner) {
|
|
39
|
-
classes.push(inner);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
} else if (argType === "object") {
|
|
43
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
44
|
-
classes.push(arg.toString());
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
for (var key in arg) {
|
|
48
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
49
|
-
classes.push(key);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
30
|
+
if (arg) {
|
|
31
|
+
classes = appendClass(classes, parseValue(arg));
|
|
52
32
|
}
|
|
53
33
|
}
|
|
54
|
-
return classes
|
|
34
|
+
return classes;
|
|
35
|
+
}
|
|
36
|
+
function parseValue(arg) {
|
|
37
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
38
|
+
return arg;
|
|
39
|
+
}
|
|
40
|
+
if (typeof arg !== "object") {
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(arg)) {
|
|
44
|
+
return classNames.apply(null, arg);
|
|
45
|
+
}
|
|
46
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
47
|
+
return arg.toString();
|
|
48
|
+
}
|
|
49
|
+
var classes = "";
|
|
50
|
+
for (var key in arg) {
|
|
51
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
52
|
+
classes = appendClass(classes, key);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return classes;
|
|
56
|
+
}
|
|
57
|
+
function appendClass(value, newClass) {
|
|
58
|
+
if (!newClass) {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
if (value) {
|
|
62
|
+
return value + " " + newClass;
|
|
63
|
+
}
|
|
64
|
+
return value + newClass;
|
|
55
65
|
}
|
|
56
66
|
if (typeof module !== "undefined" && module.exports) {
|
|
57
67
|
classNames.default = classNames;
|
|
@@ -184,7 +194,7 @@ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input":
|
|
|
184
194
|
import {
|
|
185
195
|
useCallback as useCallback5,
|
|
186
196
|
useEffect as useEffect9,
|
|
187
|
-
useMemo as
|
|
197
|
+
useMemo as useMemo4,
|
|
188
198
|
useState as useState10
|
|
189
199
|
} from "react";
|
|
190
200
|
|
|
@@ -1449,6 +1459,7 @@ var DefaultField = ({
|
|
|
1449
1459
|
className: getClassName6("input"),
|
|
1450
1460
|
autoComplete: "off",
|
|
1451
1461
|
type: field.type,
|
|
1462
|
+
title: label || name,
|
|
1452
1463
|
name,
|
|
1453
1464
|
value: typeof value === "undefined" ? "" : value.toString(),
|
|
1454
1465
|
onChange: (e) => {
|
|
@@ -1869,6 +1880,20 @@ var ExternalField = ({
|
|
|
1869
1880
|
|
|
1870
1881
|
// components/AutoField/fields/RadioField/index.tsx
|
|
1871
1882
|
init_react_import();
|
|
1883
|
+
import { useMemo as useMemo2 } from "react";
|
|
1884
|
+
|
|
1885
|
+
// lib/safe-json-parse.ts
|
|
1886
|
+
init_react_import();
|
|
1887
|
+
var safeJsonParse = (str) => {
|
|
1888
|
+
try {
|
|
1889
|
+
const jsonValue = JSON.parse(str);
|
|
1890
|
+
return jsonValue;
|
|
1891
|
+
} catch (e) {
|
|
1892
|
+
return str;
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
// components/AutoField/fields/RadioField/index.tsx
|
|
1872
1897
|
import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1873
1898
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
1874
1899
|
var RadioField = ({
|
|
@@ -1881,6 +1906,10 @@ var RadioField = ({
|
|
|
1881
1906
|
label,
|
|
1882
1907
|
Label
|
|
1883
1908
|
}) => {
|
|
1909
|
+
const flatOptions = useMemo2(
|
|
1910
|
+
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
1911
|
+
[field]
|
|
1912
|
+
);
|
|
1884
1913
|
if (field.type !== "radio" || !field.options) {
|
|
1885
1914
|
return null;
|
|
1886
1915
|
}
|
|
@@ -1904,11 +1933,12 @@ var RadioField = ({
|
|
|
1904
1933
|
value: option.value,
|
|
1905
1934
|
name,
|
|
1906
1935
|
onChange: (e) => {
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1936
|
+
const jsonValue = safeJsonParse(e.target.value) || e.target.value;
|
|
1937
|
+
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
1938
|
+
onChange(jsonValue);
|
|
1939
|
+
} else {
|
|
1940
|
+
onChange(e.target.value);
|
|
1910
1941
|
}
|
|
1911
|
-
onChange(e.currentTarget.value);
|
|
1912
1942
|
},
|
|
1913
1943
|
disabled: readOnly,
|
|
1914
1944
|
checked: value === option.value
|
|
@@ -1925,6 +1955,7 @@ var RadioField = ({
|
|
|
1925
1955
|
|
|
1926
1956
|
// components/AutoField/fields/SelectField/index.tsx
|
|
1927
1957
|
init_react_import();
|
|
1958
|
+
import { useMemo as useMemo3 } from "react";
|
|
1928
1959
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1929
1960
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
1930
1961
|
var SelectField = ({
|
|
@@ -1937,6 +1968,10 @@ var SelectField = ({
|
|
|
1937
1968
|
readOnly,
|
|
1938
1969
|
id
|
|
1939
1970
|
}) => {
|
|
1971
|
+
const flatOptions = useMemo3(
|
|
1972
|
+
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
1973
|
+
[field]
|
|
1974
|
+
);
|
|
1940
1975
|
if (field.type !== "select" || !field.options) {
|
|
1941
1976
|
return null;
|
|
1942
1977
|
}
|
|
@@ -1950,14 +1985,16 @@ var SelectField = ({
|
|
|
1950
1985
|
"select",
|
|
1951
1986
|
{
|
|
1952
1987
|
id,
|
|
1988
|
+
title: label || name,
|
|
1953
1989
|
className: getClassName12("input"),
|
|
1954
1990
|
disabled: readOnly,
|
|
1955
1991
|
onChange: (e) => {
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1992
|
+
const jsonValue = safeJsonParse(e.target.value) || e.target.value;
|
|
1993
|
+
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
1994
|
+
onChange(jsonValue);
|
|
1995
|
+
} else {
|
|
1996
|
+
onChange(e.target.value);
|
|
1959
1997
|
}
|
|
1960
|
-
onChange(e.currentTarget.value);
|
|
1961
1998
|
},
|
|
1962
1999
|
value,
|
|
1963
2000
|
children: field.options.map((option) => /* @__PURE__ */ jsx17(
|
|
@@ -2117,7 +2154,7 @@ var FieldLabelInternal2 = ({
|
|
|
2117
2154
|
readOnly
|
|
2118
2155
|
}) => {
|
|
2119
2156
|
const { overrides } = useAppContext();
|
|
2120
|
-
const Wrapper =
|
|
2157
|
+
const Wrapper = useMemo4(
|
|
2121
2158
|
() => overrides.fieldLabel || FieldLabel,
|
|
2122
2159
|
[overrides]
|
|
2123
2160
|
);
|
|
@@ -2203,7 +2240,18 @@ function AutoFieldInternal(props) {
|
|
|
2203
2240
|
}
|
|
2204
2241
|
const children = defaultFields[field.type](mergedProps);
|
|
2205
2242
|
const Render2 = render[field.type];
|
|
2206
|
-
return /* @__PURE__ */ jsx20(
|
|
2243
|
+
return /* @__PURE__ */ jsx20(
|
|
2244
|
+
"div",
|
|
2245
|
+
{
|
|
2246
|
+
className: getClassNameWrapper(),
|
|
2247
|
+
onFocus,
|
|
2248
|
+
onBlur,
|
|
2249
|
+
onClick: (e) => {
|
|
2250
|
+
e.stopPropagation();
|
|
2251
|
+
},
|
|
2252
|
+
children: /* @__PURE__ */ jsx20(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
2253
|
+
}
|
|
2254
|
+
);
|
|
2207
2255
|
}
|
|
2208
2256
|
function AutoFieldPrivate(props) {
|
|
2209
2257
|
const { state } = useAppContext();
|
|
@@ -2232,7 +2280,7 @@ function AutoFieldPrivate(props) {
|
|
|
2232
2280
|
return /* @__PURE__ */ jsx20(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
2233
2281
|
}
|
|
2234
2282
|
function AutoField(props) {
|
|
2235
|
-
const DefaultLabel =
|
|
2283
|
+
const DefaultLabel = useMemo4(() => {
|
|
2236
2284
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx20(
|
|
2237
2285
|
"div",
|
|
2238
2286
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -2255,7 +2303,7 @@ var styles_module_default10 = { "Drawer": "_Drawer_1oa7v_1", "DrawerItem--disabl
|
|
|
2255
2303
|
import {
|
|
2256
2304
|
createContext as createContext2,
|
|
2257
2305
|
useContext as useContext2,
|
|
2258
|
-
useMemo as
|
|
2306
|
+
useMemo as useMemo5
|
|
2259
2307
|
} from "react";
|
|
2260
2308
|
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2261
2309
|
var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
@@ -2293,7 +2341,7 @@ var DrawerItem = ({
|
|
|
2293
2341
|
}) => {
|
|
2294
2342
|
const ctx = useContext2(drawerContext);
|
|
2295
2343
|
const resolvedId = `${ctx.droppableId}::${id || name}`;
|
|
2296
|
-
const CustomInner =
|
|
2344
|
+
const CustomInner = useMemo5(
|
|
2297
2345
|
() => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ jsx21("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
2298
2346
|
[children]
|
|
2299
2347
|
);
|
|
@@ -2340,7 +2388,7 @@ import { useContext as useContext3, useEffect as useEffect12 } from "react";
|
|
|
2340
2388
|
init_react_import();
|
|
2341
2389
|
import {
|
|
2342
2390
|
useEffect as useEffect11,
|
|
2343
|
-
useMemo as
|
|
2391
|
+
useMemo as useMemo6,
|
|
2344
2392
|
useState as useState12
|
|
2345
2393
|
} from "react";
|
|
2346
2394
|
import { Draggable as Draggable2 } from "@measured/dnd";
|
|
@@ -2430,7 +2478,7 @@ var DraggableComponent = ({
|
|
|
2430
2478
|
setDisableSecondaryAnimation(true);
|
|
2431
2479
|
}
|
|
2432
2480
|
}, []);
|
|
2433
|
-
const CustomActionBar =
|
|
2481
|
+
const CustomActionBar = useMemo6(
|
|
2434
2482
|
() => overrides.actionBar || DefaultActionBar,
|
|
2435
2483
|
[overrides.actionBar]
|
|
2436
2484
|
);
|
|
@@ -2961,7 +3009,7 @@ init_react_import();
|
|
|
2961
3009
|
import {
|
|
2962
3010
|
useCallback as useCallback11,
|
|
2963
3011
|
useEffect as useEffect18,
|
|
2964
|
-
useMemo as
|
|
3012
|
+
useMemo as useMemo15,
|
|
2965
3013
|
useReducer,
|
|
2966
3014
|
useState as useState21
|
|
2967
3015
|
} from "react";
|
|
@@ -3036,7 +3084,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
|
|
|
3036
3084
|
|
|
3037
3085
|
// lib/use-breadcrumbs.ts
|
|
3038
3086
|
init_react_import();
|
|
3039
|
-
import { useContext as useContext4, useMemo as
|
|
3087
|
+
import { useContext as useContext4, useMemo as useMemo7 } from "react";
|
|
3040
3088
|
var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
|
|
3041
3089
|
const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
|
|
3042
3090
|
const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
|
|
@@ -3087,7 +3135,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
3087
3135
|
selectedItem
|
|
3088
3136
|
} = useAppContext();
|
|
3089
3137
|
const dzContext = useContext4(dropZoneContext);
|
|
3090
|
-
return
|
|
3138
|
+
return useMemo7(() => {
|
|
3091
3139
|
const breadcrumbs = convertPathDataToBreadcrumbs(
|
|
3092
3140
|
selectedItem,
|
|
3093
3141
|
dzContext == null ? void 0 : dzContext.pathData,
|
|
@@ -3571,7 +3619,7 @@ init_react_import();
|
|
|
3571
3619
|
var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
|
|
3572
3620
|
|
|
3573
3621
|
// components/Puck/components/Fields/index.tsx
|
|
3574
|
-
import { useCallback as useCallback7, useEffect as useEffect13, useMemo as
|
|
3622
|
+
import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo8, useState as useState15 } from "react";
|
|
3575
3623
|
|
|
3576
3624
|
// lib/use-parent.ts
|
|
3577
3625
|
init_react_import();
|
|
@@ -3605,7 +3653,7 @@ var useResolvedFields = () => {
|
|
|
3605
3653
|
const { data } = state;
|
|
3606
3654
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
|
3607
3655
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
|
3608
|
-
const defaultFields =
|
|
3656
|
+
const defaultFields = useMemo8(
|
|
3609
3657
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
|
3610
3658
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
|
3611
3659
|
);
|
|
@@ -3687,7 +3735,7 @@ var Fields = () => {
|
|
|
3687
3735
|
const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
|
|
3688
3736
|
const isLoading = fieldsResolving || componentResolving;
|
|
3689
3737
|
const rootProps = data.root.props || data.root;
|
|
3690
|
-
const Wrapper =
|
|
3738
|
+
const Wrapper = useMemo8(() => overrides.fields || DefaultFields, [overrides]);
|
|
3691
3739
|
return /* @__PURE__ */ jsxs15(
|
|
3692
3740
|
"form",
|
|
3693
3741
|
{
|
|
@@ -3766,34 +3814,36 @@ var Fields = () => {
|
|
|
3766
3814
|
const { edit } = getPermissions({
|
|
3767
3815
|
item: selectedItem
|
|
3768
3816
|
});
|
|
3817
|
+
const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
|
|
3769
3818
|
return /* @__PURE__ */ jsx27(
|
|
3770
3819
|
AutoFieldPrivate,
|
|
3771
3820
|
{
|
|
3772
3821
|
field,
|
|
3773
3822
|
name: fieldName,
|
|
3774
|
-
id
|
|
3823
|
+
id,
|
|
3775
3824
|
readOnly: !edit || readOnly[fieldName],
|
|
3776
3825
|
value: selectedItem.props[fieldName],
|
|
3777
3826
|
onChange
|
|
3778
3827
|
},
|
|
3779
|
-
|
|
3828
|
+
id
|
|
3780
3829
|
);
|
|
3781
3830
|
} else {
|
|
3782
3831
|
const readOnly = data.root.readOnly || {};
|
|
3783
3832
|
const { edit } = getPermissions({
|
|
3784
3833
|
root: true
|
|
3785
3834
|
});
|
|
3835
|
+
const id = `root_${field.type}_${fieldName}`;
|
|
3786
3836
|
return /* @__PURE__ */ jsx27(
|
|
3787
3837
|
AutoFieldPrivate,
|
|
3788
3838
|
{
|
|
3789
3839
|
field,
|
|
3790
3840
|
name: fieldName,
|
|
3791
|
-
id
|
|
3841
|
+
id,
|
|
3792
3842
|
readOnly: !edit || readOnly[fieldName],
|
|
3793
3843
|
value: rootProps[fieldName],
|
|
3794
3844
|
onChange
|
|
3795
3845
|
},
|
|
3796
|
-
|
|
3846
|
+
id
|
|
3797
3847
|
);
|
|
3798
3848
|
}
|
|
3799
3849
|
}) }),
|
|
@@ -3956,18 +4006,18 @@ var useComponentList = (config, ui) => {
|
|
|
3956
4006
|
};
|
|
3957
4007
|
|
|
3958
4008
|
// components/Puck/components/Components/index.tsx
|
|
3959
|
-
import { useMemo as
|
|
4009
|
+
import { useMemo as useMemo9 } from "react";
|
|
3960
4010
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
3961
4011
|
var Components = () => {
|
|
3962
4012
|
const { config, state, overrides } = useAppContext();
|
|
3963
4013
|
const componentList = useComponentList(config, state.ui);
|
|
3964
|
-
const Wrapper =
|
|
4014
|
+
const Wrapper = useMemo9(() => overrides.components || "div", [overrides]);
|
|
3965
4015
|
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
|
3966
4016
|
};
|
|
3967
4017
|
|
|
3968
4018
|
// components/Puck/components/Preview/index.tsx
|
|
3969
4019
|
init_react_import();
|
|
3970
|
-
import { useCallback as useCallback8, useMemo as
|
|
4020
|
+
import { useCallback as useCallback8, useMemo as useMemo10 } from "react";
|
|
3971
4021
|
|
|
3972
4022
|
// components/AutoFrame/index.tsx
|
|
3973
4023
|
init_react_import();
|
|
@@ -4247,7 +4297,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
|
4247
4297
|
},
|
|
4248
4298
|
[config.root]
|
|
4249
4299
|
);
|
|
4250
|
-
const Frame =
|
|
4300
|
+
const Frame = useMemo10(() => overrides.iframe, [overrides]);
|
|
4251
4301
|
const rootProps = state.data.root.props || state.data.root;
|
|
4252
4302
|
return /* @__PURE__ */ jsx32(
|
|
4253
4303
|
"div",
|
|
@@ -4469,7 +4519,7 @@ var LayerTree = ({
|
|
|
4469
4519
|
};
|
|
4470
4520
|
|
|
4471
4521
|
// components/Puck/components/Outline/index.tsx
|
|
4472
|
-
import { useCallback as useCallback9, useMemo as
|
|
4522
|
+
import { useCallback as useCallback9, useMemo as useMemo11 } from "react";
|
|
4473
4523
|
import { Fragment as Fragment16, jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4474
4524
|
var Outline = () => {
|
|
4475
4525
|
const { dispatch, state, overrides, config } = useAppContext();
|
|
@@ -4484,7 +4534,7 @@ var Outline = () => {
|
|
|
4484
4534
|
},
|
|
4485
4535
|
[]
|
|
4486
4536
|
);
|
|
4487
|
-
const Wrapper =
|
|
4537
|
+
const Wrapper = useMemo11(() => overrides.outline || "div", [overrides]);
|
|
4488
4538
|
return /* @__PURE__ */ jsx34(Wrapper, { children: /* @__PURE__ */ jsx34(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs18(Fragment16, { children: [
|
|
4489
4539
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx34(
|
|
4490
4540
|
LayerTree,
|
|
@@ -4748,14 +4798,14 @@ var getBox = function getBox2(el) {
|
|
|
4748
4798
|
import {
|
|
4749
4799
|
useCallback as useCallback10,
|
|
4750
4800
|
useEffect as useEffect17,
|
|
4751
|
-
useMemo as
|
|
4801
|
+
useMemo as useMemo13,
|
|
4752
4802
|
useRef as useRef4,
|
|
4753
4803
|
useState as useState20
|
|
4754
4804
|
} from "react";
|
|
4755
4805
|
|
|
4756
4806
|
// components/ViewportControls/index.tsx
|
|
4757
4807
|
init_react_import();
|
|
4758
|
-
import { useEffect as useEffect16, useMemo as
|
|
4808
|
+
import { useEffect as useEffect16, useMemo as useMemo12, useState as useState19 } from "react";
|
|
4759
4809
|
|
|
4760
4810
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
4761
4811
|
init_react_import();
|
|
@@ -4815,7 +4865,7 @@ var ViewportControls = ({
|
|
|
4815
4865
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
4816
4866
|
(option) => option.value === autoZoom
|
|
4817
4867
|
);
|
|
4818
|
-
const zoomOptions =
|
|
4868
|
+
const zoomOptions = useMemo12(
|
|
4819
4869
|
() => [
|
|
4820
4870
|
...defaultZoomOptions,
|
|
4821
4871
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -4940,11 +4990,11 @@ var Canvas = () => {
|
|
|
4940
4990
|
const { ui } = state;
|
|
4941
4991
|
const frameRef = useRef4(null);
|
|
4942
4992
|
const [showTransition, setShowTransition] = useState20(false);
|
|
4943
|
-
const defaultRender =
|
|
4993
|
+
const defaultRender = useMemo13(() => {
|
|
4944
4994
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment17, { children });
|
|
4945
4995
|
return PuckDefault;
|
|
4946
4996
|
}, []);
|
|
4947
|
-
const CustomPreview =
|
|
4997
|
+
const CustomPreview = useMemo13(
|
|
4948
4998
|
() => overrides.preview || defaultRender,
|
|
4949
4999
|
[overrides]
|
|
4950
5000
|
);
|
|
@@ -5100,7 +5150,7 @@ var insertComponent = (componentType, zone, index, {
|
|
|
5100
5150
|
|
|
5101
5151
|
// lib/use-loaded-overrides.ts
|
|
5102
5152
|
init_react_import();
|
|
5103
|
-
import { useMemo as
|
|
5153
|
+
import { useMemo as useMemo14 } from "react";
|
|
5104
5154
|
|
|
5105
5155
|
// lib/load-overrides.ts
|
|
5106
5156
|
init_react_import();
|
|
@@ -5139,7 +5189,7 @@ var useLoadedOverrides = ({
|
|
|
5139
5189
|
overrides,
|
|
5140
5190
|
plugins
|
|
5141
5191
|
}) => {
|
|
5142
|
-
return
|
|
5192
|
+
return useMemo14(() => {
|
|
5143
5193
|
return loadOverrides({ overrides, plugins });
|
|
5144
5194
|
}, [plugins, overrides]);
|
|
5145
5195
|
};
|
|
@@ -5320,7 +5370,7 @@ function Puck({
|
|
|
5320
5370
|
window.removeEventListener("resize", handleResize);
|
|
5321
5371
|
};
|
|
5322
5372
|
}, []);
|
|
5323
|
-
const defaultHeaderRender =
|
|
5373
|
+
const defaultHeaderRender = useMemo15(() => {
|
|
5324
5374
|
if (renderHeader) {
|
|
5325
5375
|
console.warn(
|
|
5326
5376
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -5334,7 +5384,7 @@ function Puck({
|
|
|
5334
5384
|
}
|
|
5335
5385
|
return DefaultOverride;
|
|
5336
5386
|
}, [renderHeader]);
|
|
5337
|
-
const defaultHeaderActionsRender =
|
|
5387
|
+
const defaultHeaderActionsRender = useMemo15(() => {
|
|
5338
5388
|
if (renderHeaderActions) {
|
|
5339
5389
|
console.warn(
|
|
5340
5390
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -5351,15 +5401,15 @@ function Puck({
|
|
|
5351
5401
|
overrides,
|
|
5352
5402
|
plugins
|
|
5353
5403
|
});
|
|
5354
|
-
const CustomPuck =
|
|
5404
|
+
const CustomPuck = useMemo15(
|
|
5355
5405
|
() => loadedOverrides.puck || DefaultOverride,
|
|
5356
5406
|
[loadedOverrides]
|
|
5357
5407
|
);
|
|
5358
|
-
const CustomHeader =
|
|
5408
|
+
const CustomHeader = useMemo15(
|
|
5359
5409
|
() => loadedOverrides.header || defaultHeaderRender,
|
|
5360
5410
|
[loadedOverrides]
|
|
5361
5411
|
);
|
|
5362
|
-
const CustomHeaderActions =
|
|
5412
|
+
const CustomHeaderActions = useMemo15(
|
|
5363
5413
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
|
5364
5414
|
[loadedOverrides]
|
|
5365
5415
|
);
|
|
@@ -5727,6 +5777,11 @@ var usePuck = () => {
|
|
|
5727
5777
|
getPermissions,
|
|
5728
5778
|
refreshPermissions
|
|
5729
5779
|
} = useAppContext();
|
|
5780
|
+
if (dispatch === defaultContext.dispatch) {
|
|
5781
|
+
throw new Error(
|
|
5782
|
+
"usePuck was used outside of the <Puck> component. The usePuck hook must be rendered within the <Puck> context as children, overrides or plugins as described in https://puckeditor.com/docs/api-reference/functions/use-puck."
|
|
5783
|
+
);
|
|
5784
|
+
}
|
|
5730
5785
|
return {
|
|
5731
5786
|
appState,
|
|
5732
5787
|
config,
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, D as Data } from './resolve-all-data-
|
|
3
|
-
export { a4 as resolveAllData } from './resolve-all-data-
|
|
2
|
+
import { C as Config, D as Data } from './resolve-all-data-zN5E6nBu.mjs';
|
|
3
|
+
export { a4 as resolveAllData } from './resolve-all-data-zN5E6nBu.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, D as Data } from './resolve-all-data-
|
|
3
|
-
export { a4 as resolveAllData } from './resolve-all-data-
|
|
2
|
+
import { C as Config, D as Data } from './resolve-all-data-zN5E6nBu.js';
|
|
3
|
+
export { a4 as resolveAllData } from './resolve-all-data-zN5E6nBu.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck",
|
|
3
|
-
"version": "0.17.0-canary.
|
|
3
|
+
"version": "0.17.0-canary.fe9321f",
|
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"react-server": {
|
|
14
|
+
"types": "./dist/rsc.d.ts",
|
|
14
15
|
"import": "./dist/rsc.mjs",
|
|
15
|
-
"require": "./dist/rsc.js"
|
|
16
|
-
"types": "./dist/rsc.d.ts"
|
|
16
|
+
"require": "./dist/rsc.js"
|
|
17
17
|
},
|
|
18
18
|
"default": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
19
20
|
"import": "./dist/index.mjs",
|
|
20
|
-
"require": "./dist/index.js"
|
|
21
|
-
"types": "./dist/index.d.ts"
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"./rsc": {
|
|
25
|
+
"types": "./dist/rsc.d.ts",
|
|
25
26
|
"import": "./dist/rsc.mjs",
|
|
26
|
-
"require": "./dist/rsc.js"
|
|
27
|
-
"types": "./dist/rsc.d.ts"
|
|
27
|
+
"require": "./dist/rsc.js"
|
|
28
28
|
},
|
|
29
29
|
"./puck.css": "./dist/index.css",
|
|
30
30
|
"./dist/index.css": "./dist/index.css"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@testing-library/react": "^
|
|
51
|
+
"@testing-library/react": "^16.1.0",
|
|
52
52
|
"@types/deep-diff": "^1.0.3",
|
|
53
53
|
"@types/jest": "^29.5.4",
|
|
54
54
|
"@types/object-hash": "^3.0.6",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"uuid": "^9.0.1"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"react": "^17.0.0 || ^18.0.0"
|
|
81
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
82
82
|
}
|
|
83
83
|
}
|