@measured/puck 0.19.0-canary.ad78e98 → 0.19.0-canary.b918900
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.js +167 -156
- package/dist/index.mjs +181 -170
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -2758,6 +2758,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2758
2758
|
var import_modifiers = require("@dnd-kit/dom/modifiers");
|
2759
2759
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2760
2760
|
var SortableProvider = ({
|
2761
|
+
container,
|
2761
2762
|
children,
|
2762
2763
|
onDragStart,
|
2763
2764
|
onDragEnd,
|
@@ -2772,7 +2773,7 @@ var SortableProvider = ({
|
|
2772
2773
|
modifiers: [
|
2773
2774
|
import_modifiers.RestrictToElement.configure({
|
2774
2775
|
element() {
|
2775
|
-
return
|
2776
|
+
return container.current;
|
2776
2777
|
}
|
2777
2778
|
})
|
2778
2779
|
],
|
@@ -2949,6 +2950,7 @@ var ArrayField = ({
|
|
2949
2950
|
}
|
2950
2951
|
}, []);
|
2951
2952
|
const [isDragging, setIsDragging] = (0, import_react16.useState)(false);
|
2953
|
+
const dndContainerRef = (0, import_react16.useRef)(null);
|
2952
2954
|
const canEdit = useAppStore(
|
2953
2955
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2954
2956
|
);
|
@@ -2967,6 +2969,7 @@ var ArrayField = ({
|
|
2967
2969
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
2968
2970
|
SortableProvider,
|
2969
2971
|
{
|
2972
|
+
container: dndContainerRef,
|
2970
2973
|
onDragStart: () => setIsDragging(true),
|
2971
2974
|
onDragEnd: () => setIsDragging(false),
|
2972
2975
|
onMove: (move) => {
|
@@ -2997,164 +3000,172 @@ var ArrayField = ({
|
|
2997
3000
|
addDisabled
|
2998
3001
|
}),
|
2999
3002
|
children: [
|
3000
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3004
|
+
"div",
|
3005
|
+
{
|
3006
|
+
ref: dndContainerRef,
|
3007
|
+
className: getClassName5("inner"),
|
3008
|
+
"data-dnd-container": true,
|
3009
|
+
children: localState.arrayState.items.map((item, i) => {
|
3010
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
3011
|
+
const data = Array.from(localState.value || [])[i] || {};
|
3012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3013
|
+
Sortable,
|
3011
3014
|
{
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3015
|
+
id: _arrayId,
|
3016
|
+
index: i,
|
3017
|
+
disabled: readOnly,
|
3018
|
+
children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3019
|
+
"div",
|
3020
|
+
{
|
3021
|
+
ref,
|
3022
|
+
className: getClassNameItem({
|
3023
|
+
isExpanded: arrayState.openId === _arrayId,
|
3024
|
+
isDragging: status === "dragging",
|
3025
|
+
readOnly
|
3026
|
+
}),
|
3027
|
+
children: [
|
3028
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3029
|
+
"div",
|
3030
|
+
{
|
3031
|
+
onClick: (e) => {
|
3032
|
+
if (isDragging) return;
|
3033
|
+
e.preventDefault();
|
3034
|
+
e.stopPropagation();
|
3035
|
+
if (arrayState.openId === _arrayId) {
|
3036
|
+
setUi(
|
3037
|
+
mapArrayStateToUi({
|
3038
|
+
openId: ""
|
3039
|
+
})
|
3040
|
+
);
|
3041
|
+
} else {
|
3042
|
+
setUi(
|
3043
|
+
mapArrayStateToUi({
|
3044
|
+
openId: _arrayId
|
3045
|
+
})
|
3046
|
+
);
|
3047
|
+
}
|
3048
|
+
},
|
3049
|
+
className: getClassNameItem("summary"),
|
3050
|
+
children: [
|
3051
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
3052
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3053
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3055
|
+
IconButton,
|
3056
|
+
{
|
3057
|
+
type: "button",
|
3058
|
+
disabled: !!addDisabled,
|
3059
|
+
onClick: (e) => {
|
3060
|
+
e.stopPropagation();
|
3061
|
+
const existingValue = [...value || []];
|
3062
|
+
existingValue.splice(
|
3063
|
+
i,
|
3064
|
+
0,
|
3065
|
+
existingValue[i]
|
3066
|
+
);
|
3067
|
+
onChange(
|
3068
|
+
existingValue,
|
3069
|
+
mapArrayStateToUi(
|
3070
|
+
regenerateArrayState(existingValue)
|
3071
|
+
)
|
3072
|
+
);
|
3073
|
+
},
|
3074
|
+
title: "Duplicate",
|
3075
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3076
|
+
}
|
3077
|
+
) }),
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3079
|
+
IconButton,
|
3080
|
+
{
|
3081
|
+
type: "button",
|
3082
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3083
|
+
onClick: (e) => {
|
3084
|
+
e.stopPropagation();
|
3085
|
+
const existingValue = [...value || []];
|
3086
|
+
const existingItems = [
|
3087
|
+
...arrayState.items || []
|
3088
|
+
];
|
3089
|
+
existingValue.splice(i, 1);
|
3090
|
+
existingItems.splice(i, 1);
|
3091
|
+
onChange(
|
3092
|
+
existingValue,
|
3093
|
+
mapArrayStateToUi({
|
3094
|
+
items: existingItems
|
3095
|
+
})
|
3096
|
+
);
|
3097
|
+
},
|
3098
|
+
title: "Delete",
|
3099
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
3100
|
+
}
|
3101
|
+
) })
|
3102
|
+
] }),
|
3103
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
3104
|
+
] })
|
3105
|
+
]
|
3038
3106
|
}
|
3039
|
-
|
3040
|
-
className: getClassNameItem("
|
3041
|
-
|
3042
|
-
|
3043
|
-
|
3044
|
-
|
3045
|
-
|
3046
|
-
IconButton,
|
3047
|
-
{
|
3048
|
-
type: "button",
|
3049
|
-
disabled: !!addDisabled,
|
3050
|
-
onClick: (e) => {
|
3051
|
-
e.stopPropagation();
|
3052
|
-
const existingValue = [...value || []];
|
3053
|
-
existingValue.splice(
|
3054
|
-
i,
|
3055
|
-
0,
|
3056
|
-
existingValue[i]
|
3057
|
-
);
|
3058
|
-
onChange(
|
3059
|
-
existingValue,
|
3060
|
-
mapArrayStateToUi(
|
3061
|
-
regenerateArrayState(existingValue)
|
3062
|
-
)
|
3063
|
-
);
|
3064
|
-
},
|
3065
|
-
title: "Duplicate",
|
3066
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
3067
|
-
}
|
3068
|
-
) }),
|
3069
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3070
|
-
IconButton,
|
3071
|
-
{
|
3072
|
-
type: "button",
|
3073
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
3074
|
-
onClick: (e) => {
|
3075
|
-
e.stopPropagation();
|
3076
|
-
const existingValue = [...value || []];
|
3077
|
-
const existingItems = [
|
3078
|
-
...arrayState.items || []
|
3079
|
-
];
|
3080
|
-
existingValue.splice(i, 1);
|
3081
|
-
existingItems.splice(i, 1);
|
3082
|
-
onChange(
|
3083
|
-
existingValue,
|
3084
|
-
mapArrayStateToUi({
|
3085
|
-
items: existingItems
|
3086
|
-
})
|
3087
|
-
);
|
3088
|
-
},
|
3089
|
-
title: "Delete",
|
3090
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
3091
|
-
}
|
3092
|
-
) })
|
3093
|
-
] }),
|
3094
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
3095
|
-
] })
|
3096
|
-
]
|
3097
|
-
}
|
3098
|
-
),
|
3099
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3100
|
-
"fieldset",
|
3101
|
-
{
|
3102
|
-
className: getClassNameItem("fieldset"),
|
3103
|
-
onPointerDownCapture: (e) => {
|
3104
|
-
e.stopPropagation();
|
3105
|
-
},
|
3106
|
-
children: Object.keys(field.arrayFields).map((subName) => {
|
3107
|
-
const subField = field.arrayFields[subName];
|
3108
|
-
const indexName = `${name}[${i}]`;
|
3109
|
-
const subPath = `${indexName}.${subName}`;
|
3110
|
-
const localIndexName = `${localName}[${i}]`;
|
3111
|
-
const localWildcardName = `${localName}[*]`;
|
3112
|
-
const localSubPath = `${localIndexName}.${subName}`;
|
3113
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3114
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3115
|
-
const label2 = subField.label || subName;
|
3116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3117
|
-
NestedFieldProvider,
|
3118
|
-
{
|
3119
|
-
name: localIndexName,
|
3120
|
-
wildcardName: localWildcardName,
|
3121
|
-
subName,
|
3122
|
-
readOnlyFields,
|
3123
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3124
|
-
AutoFieldPrivate,
|
3125
|
-
{
|
3126
|
-
name: subPath,
|
3127
|
-
label: label2,
|
3128
|
-
id: `${_arrayId}_${subName}`,
|
3129
|
-
readOnly: subReadOnly,
|
3130
|
-
field: __spreadProps(__spreadValues({}, subField), {
|
3131
|
-
label: label2
|
3132
|
-
// May be used by custom fields
|
3133
|
-
}),
|
3134
|
-
value: data[subName],
|
3135
|
-
onChange: (val, ui) => {
|
3136
|
-
onChange(
|
3137
|
-
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3138
|
-
[subName]: val
|
3139
|
-
})),
|
3140
|
-
ui
|
3141
|
-
);
|
3142
|
-
}
|
3143
|
-
}
|
3144
|
-
)
|
3107
|
+
),
|
3108
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3109
|
+
"fieldset",
|
3110
|
+
{
|
3111
|
+
className: getClassNameItem("fieldset"),
|
3112
|
+
onPointerDownCapture: (e) => {
|
3113
|
+
e.stopPropagation();
|
3145
3114
|
},
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3115
|
+
children: Object.keys(field.arrayFields).map((subName) => {
|
3116
|
+
const subField = field.arrayFields[subName];
|
3117
|
+
const indexName = `${name}[${i}]`;
|
3118
|
+
const subPath = `${indexName}.${subName}`;
|
3119
|
+
const localIndexName = `${localName}[${i}]`;
|
3120
|
+
const localWildcardName = `${localName}[*]`;
|
3121
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
3122
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3123
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3124
|
+
const label2 = subField.label || subName;
|
3125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3126
|
+
NestedFieldProvider,
|
3127
|
+
{
|
3128
|
+
name: localIndexName,
|
3129
|
+
wildcardName: localWildcardName,
|
3130
|
+
subName,
|
3131
|
+
readOnlyFields,
|
3132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3133
|
+
AutoFieldPrivate,
|
3134
|
+
{
|
3135
|
+
name: subPath,
|
3136
|
+
label: label2,
|
3137
|
+
id: `${_arrayId}_${subName}`,
|
3138
|
+
readOnly: subReadOnly,
|
3139
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
3140
|
+
label: label2
|
3141
|
+
// May be used by custom fields
|
3142
|
+
}),
|
3143
|
+
value: data[subName],
|
3144
|
+
onChange: (val, ui) => {
|
3145
|
+
onChange(
|
3146
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
3147
|
+
[subName]: val
|
3148
|
+
})),
|
3149
|
+
ui
|
3150
|
+
);
|
3151
|
+
}
|
3152
|
+
}
|
3153
|
+
)
|
3154
|
+
},
|
3155
|
+
subPath
|
3156
|
+
);
|
3157
|
+
})
|
3158
|
+
}
|
3159
|
+
) })
|
3160
|
+
]
|
3161
|
+
}
|
3162
|
+
)
|
3163
|
+
},
|
3164
|
+
_arrayId
|
3165
|
+
);
|
3166
|
+
})
|
3167
|
+
}
|
3168
|
+
),
|
3158
3169
|
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3159
3170
|
"button",
|
3160
3171
|
{
|
package/dist/index.mjs
CHANGED
@@ -676,7 +676,7 @@ var IconButton = ({
|
|
676
676
|
};
|
677
677
|
|
678
678
|
// components/AutoField/fields/ArrayField/index.tsx
|
679
|
-
import { useCallback as useCallback2, useEffect as useEffect6, useState as useState4 } from "react";
|
679
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef, useState as useState4 } from "react";
|
680
680
|
|
681
681
|
// components/DragIcon/index.tsx
|
682
682
|
init_react_import();
|
@@ -2566,6 +2566,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2566
2566
|
import { RestrictToElement } from "@dnd-kit/dom/modifiers";
|
2567
2567
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
2568
2568
|
var SortableProvider = ({
|
2569
|
+
container,
|
2569
2570
|
children,
|
2570
2571
|
onDragStart,
|
2571
2572
|
onDragEnd,
|
@@ -2580,7 +2581,7 @@ var SortableProvider = ({
|
|
2580
2581
|
modifiers: [
|
2581
2582
|
RestrictToElement.configure({
|
2582
2583
|
element() {
|
2583
|
-
return
|
2584
|
+
return container.current;
|
2584
2585
|
}
|
2585
2586
|
})
|
2586
2587
|
],
|
@@ -2757,6 +2758,7 @@ var ArrayField = ({
|
|
2757
2758
|
}
|
2758
2759
|
}, []);
|
2759
2760
|
const [isDragging, setIsDragging] = useState4(false);
|
2761
|
+
const dndContainerRef = useRef(null);
|
2760
2762
|
const canEdit = useAppStore(
|
2761
2763
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2762
2764
|
);
|
@@ -2775,6 +2777,7 @@ var ArrayField = ({
|
|
2775
2777
|
children: /* @__PURE__ */ jsx7(
|
2776
2778
|
SortableProvider,
|
2777
2779
|
{
|
2780
|
+
container: dndContainerRef,
|
2778
2781
|
onDragStart: () => setIsDragging(true),
|
2779
2782
|
onDragEnd: () => setIsDragging(false),
|
2780
2783
|
onMove: (move) => {
|
@@ -2805,164 +2808,172 @@ var ArrayField = ({
|
|
2805
2808
|
addDisabled
|
2806
2809
|
}),
|
2807
2810
|
children: [
|
2808
|
-
/* @__PURE__ */ jsx7(
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2811
|
+
/* @__PURE__ */ jsx7(
|
2812
|
+
"div",
|
2813
|
+
{
|
2814
|
+
ref: dndContainerRef,
|
2815
|
+
className: getClassName5("inner"),
|
2816
|
+
"data-dnd-container": true,
|
2817
|
+
children: localState.arrayState.items.map((item, i) => {
|
2818
|
+
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
2819
|
+
const data = Array.from(localState.value || [])[i] || {};
|
2820
|
+
return /* @__PURE__ */ jsx7(
|
2821
|
+
Sortable,
|
2819
2822
|
{
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2823
|
+
id: _arrayId,
|
2824
|
+
index: i,
|
2825
|
+
disabled: readOnly,
|
2826
|
+
children: ({ status, ref }) => /* @__PURE__ */ jsxs3(
|
2827
|
+
"div",
|
2828
|
+
{
|
2829
|
+
ref,
|
2830
|
+
className: getClassNameItem({
|
2831
|
+
isExpanded: arrayState.openId === _arrayId,
|
2832
|
+
isDragging: status === "dragging",
|
2833
|
+
readOnly
|
2834
|
+
}),
|
2835
|
+
children: [
|
2836
|
+
/* @__PURE__ */ jsxs3(
|
2837
|
+
"div",
|
2838
|
+
{
|
2839
|
+
onClick: (e) => {
|
2840
|
+
if (isDragging) return;
|
2841
|
+
e.preventDefault();
|
2842
|
+
e.stopPropagation();
|
2843
|
+
if (arrayState.openId === _arrayId) {
|
2844
|
+
setUi(
|
2845
|
+
mapArrayStateToUi({
|
2846
|
+
openId: ""
|
2847
|
+
})
|
2848
|
+
);
|
2849
|
+
} else {
|
2850
|
+
setUi(
|
2851
|
+
mapArrayStateToUi({
|
2852
|
+
openId: _arrayId
|
2853
|
+
})
|
2854
|
+
);
|
2855
|
+
}
|
2856
|
+
},
|
2857
|
+
className: getClassNameItem("summary"),
|
2858
|
+
children: [
|
2859
|
+
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
2860
|
+
/* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
|
2861
|
+
!readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
|
2862
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2863
|
+
IconButton,
|
2864
|
+
{
|
2865
|
+
type: "button",
|
2866
|
+
disabled: !!addDisabled,
|
2867
|
+
onClick: (e) => {
|
2868
|
+
e.stopPropagation();
|
2869
|
+
const existingValue = [...value || []];
|
2870
|
+
existingValue.splice(
|
2871
|
+
i,
|
2872
|
+
0,
|
2873
|
+
existingValue[i]
|
2874
|
+
);
|
2875
|
+
onChange(
|
2876
|
+
existingValue,
|
2877
|
+
mapArrayStateToUi(
|
2878
|
+
regenerateArrayState(existingValue)
|
2879
|
+
)
|
2880
|
+
);
|
2881
|
+
},
|
2882
|
+
title: "Duplicate",
|
2883
|
+
children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
|
2884
|
+
}
|
2885
|
+
) }),
|
2886
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2887
|
+
IconButton,
|
2888
|
+
{
|
2889
|
+
type: "button",
|
2890
|
+
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2891
|
+
onClick: (e) => {
|
2892
|
+
e.stopPropagation();
|
2893
|
+
const existingValue = [...value || []];
|
2894
|
+
const existingItems = [
|
2895
|
+
...arrayState.items || []
|
2896
|
+
];
|
2897
|
+
existingValue.splice(i, 1);
|
2898
|
+
existingItems.splice(i, 1);
|
2899
|
+
onChange(
|
2900
|
+
existingValue,
|
2901
|
+
mapArrayStateToUi({
|
2902
|
+
items: existingItems
|
2903
|
+
})
|
2904
|
+
);
|
2905
|
+
},
|
2906
|
+
title: "Delete",
|
2907
|
+
children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
|
2908
|
+
}
|
2909
|
+
) })
|
2910
|
+
] }),
|
2911
|
+
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
|
2912
|
+
] })
|
2913
|
+
]
|
2846
2914
|
}
|
2847
|
-
|
2848
|
-
className: getClassNameItem("
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
IconButton,
|
2855
|
-
{
|
2856
|
-
type: "button",
|
2857
|
-
disabled: !!addDisabled,
|
2858
|
-
onClick: (e) => {
|
2859
|
-
e.stopPropagation();
|
2860
|
-
const existingValue = [...value || []];
|
2861
|
-
existingValue.splice(
|
2862
|
-
i,
|
2863
|
-
0,
|
2864
|
-
existingValue[i]
|
2865
|
-
);
|
2866
|
-
onChange(
|
2867
|
-
existingValue,
|
2868
|
-
mapArrayStateToUi(
|
2869
|
-
regenerateArrayState(existingValue)
|
2870
|
-
)
|
2871
|
-
);
|
2872
|
-
},
|
2873
|
-
title: "Duplicate",
|
2874
|
-
children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
|
2875
|
-
}
|
2876
|
-
) }),
|
2877
|
-
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
|
2878
|
-
IconButton,
|
2879
|
-
{
|
2880
|
-
type: "button",
|
2881
|
-
disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
|
2882
|
-
onClick: (e) => {
|
2883
|
-
e.stopPropagation();
|
2884
|
-
const existingValue = [...value || []];
|
2885
|
-
const existingItems = [
|
2886
|
-
...arrayState.items || []
|
2887
|
-
];
|
2888
|
-
existingValue.splice(i, 1);
|
2889
|
-
existingItems.splice(i, 1);
|
2890
|
-
onChange(
|
2891
|
-
existingValue,
|
2892
|
-
mapArrayStateToUi({
|
2893
|
-
items: existingItems
|
2894
|
-
})
|
2895
|
-
);
|
2896
|
-
},
|
2897
|
-
title: "Delete",
|
2898
|
-
children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
|
2899
|
-
}
|
2900
|
-
) })
|
2901
|
-
] }),
|
2902
|
-
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
|
2903
|
-
] })
|
2904
|
-
]
|
2905
|
-
}
|
2906
|
-
),
|
2907
|
-
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7(
|
2908
|
-
"fieldset",
|
2909
|
-
{
|
2910
|
-
className: getClassNameItem("fieldset"),
|
2911
|
-
onPointerDownCapture: (e) => {
|
2912
|
-
e.stopPropagation();
|
2913
|
-
},
|
2914
|
-
children: Object.keys(field.arrayFields).map((subName) => {
|
2915
|
-
const subField = field.arrayFields[subName];
|
2916
|
-
const indexName = `${name}[${i}]`;
|
2917
|
-
const subPath = `${indexName}.${subName}`;
|
2918
|
-
const localIndexName = `${localName}[${i}]`;
|
2919
|
-
const localWildcardName = `${localName}[*]`;
|
2920
|
-
const localSubPath = `${localIndexName}.${subName}`;
|
2921
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2922
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2923
|
-
const label2 = subField.label || subName;
|
2924
|
-
return /* @__PURE__ */ jsx7(
|
2925
|
-
NestedFieldProvider,
|
2926
|
-
{
|
2927
|
-
name: localIndexName,
|
2928
|
-
wildcardName: localWildcardName,
|
2929
|
-
subName,
|
2930
|
-
readOnlyFields,
|
2931
|
-
children: /* @__PURE__ */ jsx7(
|
2932
|
-
AutoFieldPrivate,
|
2933
|
-
{
|
2934
|
-
name: subPath,
|
2935
|
-
label: label2,
|
2936
|
-
id: `${_arrayId}_${subName}`,
|
2937
|
-
readOnly: subReadOnly,
|
2938
|
-
field: __spreadProps(__spreadValues({}, subField), {
|
2939
|
-
label: label2
|
2940
|
-
// May be used by custom fields
|
2941
|
-
}),
|
2942
|
-
value: data[subName],
|
2943
|
-
onChange: (val, ui) => {
|
2944
|
-
onChange(
|
2945
|
-
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2946
|
-
[subName]: val
|
2947
|
-
})),
|
2948
|
-
ui
|
2949
|
-
);
|
2950
|
-
}
|
2951
|
-
}
|
2952
|
-
)
|
2915
|
+
),
|
2916
|
+
/* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7(
|
2917
|
+
"fieldset",
|
2918
|
+
{
|
2919
|
+
className: getClassNameItem("fieldset"),
|
2920
|
+
onPointerDownCapture: (e) => {
|
2921
|
+
e.stopPropagation();
|
2953
2922
|
},
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2923
|
+
children: Object.keys(field.arrayFields).map((subName) => {
|
2924
|
+
const subField = field.arrayFields[subName];
|
2925
|
+
const indexName = `${name}[${i}]`;
|
2926
|
+
const subPath = `${indexName}.${subName}`;
|
2927
|
+
const localIndexName = `${localName}[${i}]`;
|
2928
|
+
const localWildcardName = `${localName}[*]`;
|
2929
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
2930
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
2931
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
2932
|
+
const label2 = subField.label || subName;
|
2933
|
+
return /* @__PURE__ */ jsx7(
|
2934
|
+
NestedFieldProvider,
|
2935
|
+
{
|
2936
|
+
name: localIndexName,
|
2937
|
+
wildcardName: localWildcardName,
|
2938
|
+
subName,
|
2939
|
+
readOnlyFields,
|
2940
|
+
children: /* @__PURE__ */ jsx7(
|
2941
|
+
AutoFieldPrivate,
|
2942
|
+
{
|
2943
|
+
name: subPath,
|
2944
|
+
label: label2,
|
2945
|
+
id: `${_arrayId}_${subName}`,
|
2946
|
+
readOnly: subReadOnly,
|
2947
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
2948
|
+
label: label2
|
2949
|
+
// May be used by custom fields
|
2950
|
+
}),
|
2951
|
+
value: data[subName],
|
2952
|
+
onChange: (val, ui) => {
|
2953
|
+
onChange(
|
2954
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
2955
|
+
[subName]: val
|
2956
|
+
})),
|
2957
|
+
ui
|
2958
|
+
);
|
2959
|
+
}
|
2960
|
+
}
|
2961
|
+
)
|
2962
|
+
},
|
2963
|
+
subPath
|
2964
|
+
);
|
2965
|
+
})
|
2966
|
+
}
|
2967
|
+
) })
|
2968
|
+
]
|
2969
|
+
}
|
2970
|
+
)
|
2971
|
+
},
|
2972
|
+
_arrayId
|
2973
|
+
);
|
2974
|
+
})
|
2975
|
+
}
|
2976
|
+
),
|
2966
2977
|
!addDisabled && /* @__PURE__ */ jsx7(
|
2967
2978
|
"button",
|
2968
2979
|
{
|
@@ -3934,7 +3945,7 @@ import {
|
|
3934
3945
|
useContext as useContext7,
|
3935
3946
|
useEffect as useEffect17,
|
3936
3947
|
useId,
|
3937
|
-
useRef as
|
3948
|
+
useRef as useRef4,
|
3938
3949
|
useState as useState15
|
3939
3950
|
} from "react";
|
3940
3951
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -3947,7 +3958,7 @@ import {
|
|
3947
3958
|
useContext as useContext6,
|
3948
3959
|
useEffect as useEffect16,
|
3949
3960
|
useMemo as useMemo8,
|
3950
|
-
useRef as
|
3961
|
+
useRef as useRef3
|
3951
3962
|
} from "react";
|
3952
3963
|
|
3953
3964
|
// components/DraggableComponent/index.tsx
|
@@ -3957,7 +3968,7 @@ import {
|
|
3957
3968
|
useContext as useContext5,
|
3958
3969
|
useEffect as useEffect12,
|
3959
3970
|
useMemo as useMemo7,
|
3960
|
-
useRef,
|
3971
|
+
useRef as useRef2,
|
3961
3972
|
useState as useState11
|
3962
3973
|
} from "react";
|
3963
3974
|
|
@@ -4194,7 +4205,7 @@ var DraggableComponent = ({
|
|
4194
4205
|
}
|
4195
4206
|
});
|
4196
4207
|
const thisIsDragging = status === "dragging";
|
4197
|
-
const ref =
|
4208
|
+
const ref = useRef2(null);
|
4198
4209
|
const refSetter = useCallback6(
|
4199
4210
|
(el) => {
|
4200
4211
|
sortableRef(el);
|
@@ -4871,7 +4882,7 @@ var DropZoneEdit = forwardRef3(
|
|
4871
4882
|
return content.map(({ props }) => props.id);
|
4872
4883
|
})
|
4873
4884
|
);
|
4874
|
-
const ref =
|
4885
|
+
const ref = useRef3(null);
|
4875
4886
|
const acceptsTarget = useCallback9(
|
4876
4887
|
(componentType) => {
|
4877
4888
|
if (!componentType) {
|
@@ -5373,7 +5384,7 @@ function useDragListener(type, fn, deps = []) {
|
|
5373
5384
|
}
|
5374
5385
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5375
5386
|
var useTempDisableFallback = (timeout3) => {
|
5376
|
-
const lastFallbackDisable =
|
5387
|
+
const lastFallbackDisable = useRef4(null);
|
5377
5388
|
return useCallback10((manager) => {
|
5378
5389
|
collisionStore.setState({ fallbackEnabled: false });
|
5379
5390
|
const fallbackId = generateId();
|
@@ -5396,7 +5407,7 @@ var DragDropContextClient = ({
|
|
5396
5407
|
const metadata = useAppStore((s) => s.metadata);
|
5397
5408
|
const appStore = useAppStoreApi();
|
5398
5409
|
const id = useId();
|
5399
|
-
const debouncedParamsRef =
|
5410
|
+
const debouncedParamsRef = useRef4(null);
|
5400
5411
|
const tempDisableFallback = useTempDisableFallback(100);
|
5401
5412
|
const [zoneStore] = useState15(
|
5402
5413
|
() => createStore3(() => ({
|
@@ -5516,8 +5527,8 @@ var DragDropContextClient = ({
|
|
5516
5527
|
]);
|
5517
5528
|
const sensors = useSensors();
|
5518
5529
|
const [dragListeners, setDragListeners] = useState15({});
|
5519
|
-
const dragMode =
|
5520
|
-
const initialSelector =
|
5530
|
+
const dragMode = useRef4(null);
|
5531
|
+
const initialSelector = useRef4(void 0);
|
5521
5532
|
return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
|
5522
5533
|
dragListenerContext.Provider,
|
5523
5534
|
{
|
@@ -6331,7 +6342,7 @@ var Components = () => {
|
|
6331
6342
|
|
6332
6343
|
// components/Puck/components/Preview/index.tsx
|
6333
6344
|
init_react_import();
|
6334
|
-
import { useCallback as useCallback12, useEffect as useEffect20, useRef as
|
6345
|
+
import { useCallback as useCallback12, useEffect as useEffect20, useRef as useRef5, useMemo as useMemo13 } from "react";
|
6335
6346
|
|
6336
6347
|
// components/AutoFrame/index.tsx
|
6337
6348
|
init_react_import();
|
@@ -6683,7 +6694,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6683
6694
|
);
|
6684
6695
|
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
6685
6696
|
const rootProps = root.props || root;
|
6686
|
-
const ref =
|
6697
|
+
const ref = useRef5(null);
|
6687
6698
|
useBubbleIframeEvents(ref);
|
6688
6699
|
const inner = !renderData ? /* @__PURE__ */ jsx32(
|
6689
6700
|
Page,
|
@@ -7115,7 +7126,7 @@ import {
|
|
7115
7126
|
useCallback as useCallback14,
|
7116
7127
|
useEffect as useEffect22,
|
7117
7128
|
useMemo as useMemo16,
|
7118
|
-
useRef as
|
7129
|
+
useRef as useRef6,
|
7119
7130
|
useState as useState20
|
7120
7131
|
} from "react";
|
7121
7132
|
|
@@ -7328,7 +7339,7 @@ var Canvas = () => {
|
|
7328
7339
|
viewports: s.state.ui.viewports
|
7329
7340
|
}))
|
7330
7341
|
);
|
7331
|
-
const frameRef =
|
7342
|
+
const frameRef = useRef6(null);
|
7332
7343
|
const [showTransition, setShowTransition] = useState20(false);
|
7333
7344
|
const defaultRender = useMemo16(() => {
|
7334
7345
|
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.19.0-canary.
|
3
|
+
"version": "0.19.0-canary.b918900",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -27,7 +27,8 @@
|
|
27
27
|
"require": "./dist/rsc.js"
|
28
28
|
},
|
29
29
|
"./puck.css": "./dist/index.css",
|
30
|
-
"./dist/index.css": "./dist/index.css"
|
30
|
+
"./dist/index.css": "./dist/index.css",
|
31
|
+
"./package.json": "./package.json"
|
31
32
|
},
|
32
33
|
"typesVersions": {
|
33
34
|
"*": {
|