@measured/puck 0.16.1-canary.ed282b9 → 0.16.2-canary.18657a4
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/chunk-YNVK2PUD.mjs +248 -0
- package/dist/index.css +23 -21
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +45 -21
- package/dist/index.mjs +61 -158
- package/dist/{actions-9pHbVtMU.d.mts → resolve-all-data-CaDAfEAK.d.mts} +3 -1
- package/dist/{actions-9pHbVtMU.d.ts → resolve-all-data-CaDAfEAK.d.ts} +3 -1
- package/dist/rsc.d.mts +2 -1
- package/dist/rsc.d.ts +2 -1
- package/dist/rsc.js +144 -2
- package/dist/rsc.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-LM7YWFFF.mjs +0 -114
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __esm = (fn, res) => function __init() {
|
|
37
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
38
|
+
};
|
|
39
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
40
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
41
|
+
};
|
|
42
|
+
var __copyProps = (to, from, except, desc) => {
|
|
43
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
44
|
+
for (let key of __getOwnPropNames(from))
|
|
45
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
46
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
47
|
+
}
|
|
48
|
+
return to;
|
|
49
|
+
};
|
|
50
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
51
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
52
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
53
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
54
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
55
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
56
|
+
mod
|
|
57
|
+
));
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ../tsup-config/react-import.js
|
|
80
|
+
import React from "react";
|
|
81
|
+
var init_react_import = __esm({
|
|
82
|
+
"../tsup-config/react-import.js"() {
|
|
83
|
+
"use strict";
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// lib/resolve-all-data.ts
|
|
88
|
+
init_react_import();
|
|
89
|
+
|
|
90
|
+
// lib/resolve-component-data.ts
|
|
91
|
+
init_react_import();
|
|
92
|
+
|
|
93
|
+
// lib/get-changed.ts
|
|
94
|
+
init_react_import();
|
|
95
|
+
var getChanged = (newItem, oldItem) => {
|
|
96
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
97
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
98
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
99
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
100
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
|
101
|
+
});
|
|
102
|
+
}, {}) : {};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// lib/resolve-component-data.ts
|
|
106
|
+
var cache = { lastChange: {} };
|
|
107
|
+
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
|
108
|
+
return yield Promise.all(
|
|
109
|
+
content.map((item) => __async(void 0, null, function* () {
|
|
110
|
+
return yield resolveComponentData(
|
|
111
|
+
item,
|
|
112
|
+
config,
|
|
113
|
+
onResolveStart,
|
|
114
|
+
onResolveEnd
|
|
115
|
+
);
|
|
116
|
+
}))
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
|
120
|
+
const configForItem = config.components[item.type];
|
|
121
|
+
if (configForItem.resolveData) {
|
|
122
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
|
123
|
+
if (item && item === oldItem) {
|
|
124
|
+
return resolved;
|
|
125
|
+
}
|
|
126
|
+
const changed = getChanged(item, oldItem);
|
|
127
|
+
if (onResolveStart) {
|
|
128
|
+
onResolveStart(item);
|
|
129
|
+
}
|
|
130
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
|
131
|
+
const { readOnly: existingReadOnly = {} } = item || {};
|
|
132
|
+
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
|
133
|
+
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
|
134
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
|
135
|
+
});
|
|
136
|
+
if (Object.keys(newReadOnly).length) {
|
|
137
|
+
resolvedItem.readOnly = newReadOnly;
|
|
138
|
+
}
|
|
139
|
+
cache.lastChange[item.props.id] = {
|
|
140
|
+
item,
|
|
141
|
+
resolved: resolvedItem
|
|
142
|
+
};
|
|
143
|
+
if (onResolveEnd) {
|
|
144
|
+
onResolveEnd(resolvedItem);
|
|
145
|
+
}
|
|
146
|
+
return resolvedItem;
|
|
147
|
+
}
|
|
148
|
+
return item;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// lib/resolve-root-data.ts
|
|
152
|
+
init_react_import();
|
|
153
|
+
var cache2 = {};
|
|
154
|
+
function resolveRootData(data, config) {
|
|
155
|
+
return __async(this, null, function* () {
|
|
156
|
+
var _a, _b, _c, _d, _e;
|
|
157
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
|
158
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
|
159
|
+
return cache2.lastChange.resolved;
|
|
160
|
+
}
|
|
161
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
|
162
|
+
const rootWithProps = data.root;
|
|
163
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
|
164
|
+
changed,
|
|
165
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
|
166
|
+
});
|
|
167
|
+
cache2.lastChange = {
|
|
168
|
+
original: data.root,
|
|
169
|
+
resolved: resolvedRoot
|
|
170
|
+
};
|
|
171
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
|
172
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return data.root;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// lib/default-data.ts
|
|
180
|
+
init_react_import();
|
|
181
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
182
|
+
root: data.root || {},
|
|
183
|
+
content: data.content || []
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// lib/resolve-all-data.ts
|
|
187
|
+
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
188
|
+
return __async(this, null, function* () {
|
|
189
|
+
const defaultedData = defaultData(data);
|
|
190
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
|
191
|
+
const { zones = {} } = data;
|
|
192
|
+
const zoneKeys = Object.keys(zones);
|
|
193
|
+
const resolvedZones = {};
|
|
194
|
+
for (let i = 0; i < zoneKeys.length; i++) {
|
|
195
|
+
const zoneKey = zoneKeys[i];
|
|
196
|
+
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
|
197
|
+
zones[zoneKey],
|
|
198
|
+
config,
|
|
199
|
+
onResolveStart,
|
|
200
|
+
onResolveEnd
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
|
204
|
+
root: dynamicRoot,
|
|
205
|
+
content: yield resolveAllComponentData(
|
|
206
|
+
defaultedData.content,
|
|
207
|
+
config,
|
|
208
|
+
onResolveStart,
|
|
209
|
+
onResolveEnd
|
|
210
|
+
),
|
|
211
|
+
zones: resolvedZones
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// lib/root-droppable-id.ts
|
|
217
|
+
init_react_import();
|
|
218
|
+
var rootDroppableId = "default-zone";
|
|
219
|
+
|
|
220
|
+
// lib/setup-zone.ts
|
|
221
|
+
init_react_import();
|
|
222
|
+
var setupZone = (data, zoneKey) => {
|
|
223
|
+
if (zoneKey === rootDroppableId) {
|
|
224
|
+
return data;
|
|
225
|
+
}
|
|
226
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
227
|
+
zones: data.zones || {}
|
|
228
|
+
});
|
|
229
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
230
|
+
return newData;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
__spreadValues,
|
|
235
|
+
__spreadProps,
|
|
236
|
+
__objRest,
|
|
237
|
+
__commonJS,
|
|
238
|
+
__toESM,
|
|
239
|
+
__async,
|
|
240
|
+
init_react_import,
|
|
241
|
+
rootDroppableId,
|
|
242
|
+
setupZone,
|
|
243
|
+
getChanged,
|
|
244
|
+
resolveComponentData,
|
|
245
|
+
resolveRootData,
|
|
246
|
+
defaultData,
|
|
247
|
+
resolveAllData
|
|
248
|
+
};
|
package/dist/index.css
CHANGED
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
/* styles.css */
|
|
138
138
|
|
|
139
139
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css/#css-module-data */
|
|
140
|
-
.
|
|
140
|
+
._ActionBar_151w5_1 {
|
|
141
141
|
display: flex;
|
|
142
142
|
width: auto;
|
|
143
143
|
padding: 4px;
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
gap: 4px;
|
|
152
152
|
min-height: 26px;
|
|
153
153
|
}
|
|
154
|
-
._ActionBar-
|
|
154
|
+
._ActionBar-actionsLabel_151w5_16 {
|
|
155
155
|
color: var(--puck-color-grey-08);
|
|
156
156
|
display: flex;
|
|
157
157
|
font-size: var(--puck-font-size-xxxs);
|
|
@@ -163,19 +163,19 @@
|
|
|
163
163
|
text-overflow: ellipsis;
|
|
164
164
|
white-space: nowrap;
|
|
165
165
|
}
|
|
166
|
-
._ActionBar-
|
|
167
|
-
border-
|
|
166
|
+
._ActionBar-group_151w5_29 {
|
|
167
|
+
border-inline-start: 0.5px solid var(--puck-color-grey-05);
|
|
168
168
|
display: flex;
|
|
169
169
|
padding-left: 4px;
|
|
170
170
|
padding-right: 4px;
|
|
171
171
|
}
|
|
172
|
-
._ActionBar-
|
|
172
|
+
._ActionBar-group_151w5_29:last-of-type {
|
|
173
173
|
padding-right: 0;
|
|
174
174
|
}
|
|
175
|
-
._ActionBar-
|
|
175
|
+
._ActionBar-group_151w5_29:empty {
|
|
176
176
|
display: none;
|
|
177
177
|
}
|
|
178
|
-
._ActionBar-
|
|
178
|
+
._ActionBar-action_151w5_16 {
|
|
179
179
|
background: transparent;
|
|
180
180
|
border: none;
|
|
181
181
|
color: var(--puck-color-grey-08);
|
|
@@ -188,17 +188,17 @@
|
|
|
188
188
|
justify-content: center;
|
|
189
189
|
transition: color 50ms ease-in;
|
|
190
190
|
}
|
|
191
|
-
._ActionBar-
|
|
191
|
+
._ActionBar-action_151w5_16:focus-visible {
|
|
192
192
|
outline: 2px solid var(--puck-color-azure-05);
|
|
193
193
|
outline-offset: -2px;
|
|
194
194
|
}
|
|
195
195
|
@media (hover: hover) and (pointer: fine) {
|
|
196
|
-
._ActionBar-
|
|
196
|
+
._ActionBar-action_151w5_16:hover {
|
|
197
197
|
color: var(--puck-color-azure-06);
|
|
198
198
|
transition: none;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
._ActionBar-
|
|
201
|
+
._ActionBar-action_151w5_16:active {
|
|
202
202
|
color: var(--puck-color-azure-07);
|
|
203
203
|
transition: none;
|
|
204
204
|
}
|
|
@@ -1741,7 +1741,7 @@ textarea._Input-input_3pq3z_47 {
|
|
|
1741
1741
|
}
|
|
1742
1742
|
|
|
1743
1743
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css/#css-module-data */
|
|
1744
|
-
.
|
|
1744
|
+
._PuckCanvas_avf1c_1 {
|
|
1745
1745
|
background: var(--puck-color-grey-11);
|
|
1746
1746
|
display: flex;
|
|
1747
1747
|
grid-area: editor;
|
|
@@ -1750,15 +1750,15 @@ textarea._Input-input_3pq3z_47 {
|
|
|
1750
1750
|
overflow: auto;
|
|
1751
1751
|
}
|
|
1752
1752
|
@media (min-width: 1198px) {
|
|
1753
|
-
.
|
|
1753
|
+
._PuckCanvas_avf1c_1 {
|
|
1754
1754
|
padding: calc(var(--puck-space-px) * 1.5);
|
|
1755
1755
|
padding-top: var(--puck-space-px);
|
|
1756
1756
|
}
|
|
1757
|
-
.
|
|
1757
|
+
._PuckCanvas_avf1c_1:not(._PuckCanvas_avf1c_1:has(._PuckCanvas-controls_avf1c_16)) {
|
|
1758
1758
|
padding-top: calc(var(--puck-space-px) * 1.5);
|
|
1759
1759
|
}
|
|
1760
1760
|
}
|
|
1761
|
-
._PuckCanvas-
|
|
1761
|
+
._PuckCanvas-inner_avf1c_21 {
|
|
1762
1762
|
box-sizing: border-box;
|
|
1763
1763
|
display: flex;
|
|
1764
1764
|
height: 100%;
|
|
@@ -1768,31 +1768,33 @@ textarea._Input-input_3pq3z_47 {
|
|
|
1768
1768
|
position: relative;
|
|
1769
1769
|
width: 100%;
|
|
1770
1770
|
}
|
|
1771
|
-
._PuckCanvas-
|
|
1771
|
+
._PuckCanvas-root_avf1c_32 {
|
|
1772
1772
|
background: white;
|
|
1773
1773
|
border: 1px solid var(--puck-color-grey-09);
|
|
1774
1774
|
box-sizing: border-box;
|
|
1775
1775
|
min-width: 321px;
|
|
1776
1776
|
position: absolute;
|
|
1777
|
+
pointer-events: none;
|
|
1777
1778
|
transform-origin: top;
|
|
1778
1779
|
top: 0;
|
|
1779
1780
|
bottom: 0;
|
|
1780
1781
|
opacity: 0;
|
|
1781
1782
|
}
|
|
1782
1783
|
@media (min-width: 1198px) {
|
|
1783
|
-
._PuckCanvas-
|
|
1784
|
+
._PuckCanvas-root_avf1c_32 {
|
|
1784
1785
|
min-width: unset;
|
|
1785
1786
|
}
|
|
1786
1787
|
}
|
|
1787
1788
|
@media (prefers-reduced-motion: reduce) {
|
|
1788
|
-
._PuckCanvas-
|
|
1789
|
+
._PuckCanvas-root_avf1c_32 {
|
|
1789
1790
|
transition: none !important;
|
|
1790
1791
|
}
|
|
1791
1792
|
}
|
|
1792
|
-
._PuckCanvas--
|
|
1793
|
+
._PuckCanvas--ready_avf1c_57 ._PuckCanvas-root_avf1c_32 {
|
|
1794
|
+
pointer-events: unset;
|
|
1793
1795
|
opacity: 1;
|
|
1794
1796
|
}
|
|
1795
|
-
._PuckCanvas-
|
|
1797
|
+
._PuckCanvas-loader_avf1c_62 {
|
|
1796
1798
|
align-items: center;
|
|
1797
1799
|
color: var(--puck-color-grey-06);
|
|
1798
1800
|
display: flex;
|
|
@@ -1801,10 +1803,10 @@ textarea._Input-input_3pq3z_47 {
|
|
|
1801
1803
|
transition: opacity 250ms ease-out;
|
|
1802
1804
|
opacity: 0;
|
|
1803
1805
|
}
|
|
1804
|
-
._PuckCanvas--
|
|
1806
|
+
._PuckCanvas--showLoader_avf1c_72 ._PuckCanvas-loader_avf1c_62 {
|
|
1805
1807
|
opacity: 1;
|
|
1806
1808
|
}
|
|
1807
|
-
._PuckCanvas--
|
|
1809
|
+
._PuckCanvas--showLoader_avf1c_72._PuckCanvas--ready_avf1c_57 ._PuckCanvas-loader_avf1c_62 {
|
|
1808
1810
|
opacity: 0;
|
|
1809
1811
|
height: 0;
|
|
1810
1812
|
transition: none;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps,
|
|
2
|
-
export { L as Adaptor, J as ArrayField,
|
|
1
|
+
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-CaDAfEAK.mjs';
|
|
2
|
+
export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
|
|
@@ -202,8 +202,6 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
|
202
202
|
}>;
|
|
203
203
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
|
204
204
|
|
|
205
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
|
206
|
-
|
|
207
205
|
type HistoryStore<D = any> = {
|
|
208
206
|
index: number;
|
|
209
207
|
hasPast: boolean;
|
|
@@ -247,4 +245,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
|
247
245
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
|
248
246
|
};
|
|
249
247
|
|
|
250
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button,
|
|
248
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, transformProps, usePuck };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps,
|
|
2
|
-
export { L as Adaptor, J as ArrayField,
|
|
1
|
+
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-CaDAfEAK.js';
|
|
2
|
+
export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
|
|
@@ -202,8 +202,6 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
|
202
202
|
}>;
|
|
203
203
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
|
204
204
|
|
|
205
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
|
206
|
-
|
|
207
205
|
type HistoryStore<D = any> = {
|
|
208
206
|
index: number;
|
|
209
207
|
hasPast: boolean;
|
|
@@ -247,4 +245,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
|
247
245
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
|
248
246
|
};
|
|
249
247
|
|
|
250
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button,
|
|
248
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, transformProps, usePuck };
|
package/dist/index.js
CHANGED
|
@@ -243,7 +243,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
|
243
243
|
|
|
244
244
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
|
245
245
|
init_react_import();
|
|
246
|
-
var styles_module_default = { "ActionBar": "
|
|
246
|
+
var styles_module_default = { "ActionBar": "_ActionBar_151w5_1", "ActionBar-actionsLabel": "_ActionBar-actionsLabel_151w5_16", "ActionBar-group": "_ActionBar-group_151w5_29", "ActionBar-action": "_ActionBar-action_151w5_16" };
|
|
247
247
|
|
|
248
248
|
// components/ActionBar/index.tsx
|
|
249
249
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -764,16 +764,15 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
|
764
764
|
const resolveDataForItem = (0, import_react4.useCallback)(
|
|
765
765
|
(item, force = false) => __async(void 0, null, function* () {
|
|
766
766
|
var _a, _b, _c;
|
|
767
|
-
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
|
768
767
|
const componentConfig = item.type === "root" ? config.root : config.components[item.type];
|
|
769
768
|
if (!componentConfig) {
|
|
770
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
|
771
769
|
return;
|
|
772
770
|
}
|
|
773
771
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
774
772
|
if (componentConfig.resolvePermissions) {
|
|
775
773
|
const changed = getChanged(item, (_a = cache3[item.props.id]) == null ? void 0 : _a.lastData);
|
|
776
774
|
if (Object.values(changed).some((el) => el === true) || force) {
|
|
775
|
+
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
|
777
776
|
const resolvedPermissions2 = yield componentConfig.resolvePermissions(
|
|
778
777
|
item,
|
|
779
778
|
{
|
|
@@ -793,9 +792,9 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
|
793
792
|
setResolvedPermissions((p) => __spreadProps(__spreadValues({}, p), {
|
|
794
793
|
[item.props.id]: resolvedPermissions2
|
|
795
794
|
}));
|
|
795
|
+
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
798
|
-
unsetComponentLoading == null ? void 0 : unsetComponentLoading(item.props.id);
|
|
799
798
|
}),
|
|
800
799
|
[config, globalPermissions, appState, cache3]
|
|
801
800
|
);
|
|
@@ -841,12 +840,12 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
|
841
840
|
({ item, type, root } = {}) => {
|
|
842
841
|
if (item) {
|
|
843
842
|
const componentConfig = config.components[item.type];
|
|
844
|
-
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
843
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
|
845
844
|
const resolvedForItem = resolvedPermissions[item.props.id];
|
|
846
845
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
|
847
846
|
} else if (type) {
|
|
848
847
|
const componentConfig = config.components[type];
|
|
849
|
-
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
848
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
|
850
849
|
} else if (root) {
|
|
851
850
|
const rootConfig = config.root;
|
|
852
851
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
|
@@ -2328,9 +2327,12 @@ function AutoFieldInternal(props) {
|
|
|
2328
2327
|
const Render2 = render[field.type];
|
|
2329
2328
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
|
|
2330
2329
|
}
|
|
2330
|
+
var RECENT_CHANGE_TIMEOUT = 200;
|
|
2331
2331
|
function AutoFieldPrivate(props) {
|
|
2332
2332
|
const { value, onChange } = props;
|
|
2333
2333
|
const [localValue, setLocalValue] = (0, import_react13.useState)(value);
|
|
2334
|
+
const [recentlyChanged, setRecentlyChanged] = (0, import_react13.useState)(false);
|
|
2335
|
+
const timeoutRef = (0, import_react13.useRef)();
|
|
2334
2336
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
|
2335
2337
|
(val, ui) => {
|
|
2336
2338
|
onChange(val, ui);
|
|
@@ -2340,10 +2342,17 @@ function AutoFieldPrivate(props) {
|
|
|
2340
2342
|
);
|
|
2341
2343
|
const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
|
|
2342
2344
|
setLocalValue(val);
|
|
2345
|
+
setRecentlyChanged(true);
|
|
2346
|
+
clearTimeout(timeoutRef.current);
|
|
2347
|
+
timeoutRef.current = setTimeout(() => {
|
|
2348
|
+
setRecentlyChanged(false);
|
|
2349
|
+
}, RECENT_CHANGE_TIMEOUT);
|
|
2343
2350
|
onChangeDb(val, ui);
|
|
2344
2351
|
}, []);
|
|
2345
2352
|
(0, import_react13.useEffect)(() => {
|
|
2346
|
-
|
|
2353
|
+
if (!recentlyChanged) {
|
|
2354
|
+
setLocalValue(value);
|
|
2355
|
+
}
|
|
2347
2356
|
}, [value]);
|
|
2348
2357
|
const localProps = {
|
|
2349
2358
|
value: localValue,
|
|
@@ -2351,8 +2360,16 @@ function AutoFieldPrivate(props) {
|
|
|
2351
2360
|
};
|
|
2352
2361
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
2353
2362
|
}
|
|
2354
|
-
var DefaultLabel = (props) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", __spreadValues({}, props));
|
|
2355
2363
|
function AutoField(props) {
|
|
2364
|
+
const DefaultLabel = (0, import_react13.useMemo)(() => {
|
|
2365
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2366
|
+
"div",
|
|
2367
|
+
__spreadProps(__spreadValues({}, labelProps), {
|
|
2368
|
+
className: getClassName15({ readOnly: props.readOnly })
|
|
2369
|
+
})
|
|
2370
|
+
);
|
|
2371
|
+
return DefaultLabel2;
|
|
2372
|
+
}, [props.readOnly]);
|
|
2356
2373
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
|
2357
2374
|
}
|
|
2358
2375
|
|
|
@@ -3677,7 +3694,7 @@ var DefaultFields = ({
|
|
|
3677
3694
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
|
|
3678
3695
|
};
|
|
3679
3696
|
var useResolvedFields = () => {
|
|
3680
|
-
var _a;
|
|
3697
|
+
var _a, _b;
|
|
3681
3698
|
const { selectedItem, state, config } = useAppContext();
|
|
3682
3699
|
const { data } = state;
|
|
3683
3700
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
|
@@ -3689,14 +3706,17 @@ var useResolvedFields = () => {
|
|
|
3689
3706
|
const [fieldsLoading, setFieldsLoading] = (0, import_react21.useState)(false);
|
|
3690
3707
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
|
3691
3708
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
|
3709
|
+
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
|
3710
|
+
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
|
3711
|
+
const hasResolver = hasComponentResolver || hasRootResolver;
|
|
3692
3712
|
const resolveFields = (0, import_react21.useCallback)(
|
|
3693
3713
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
|
3694
|
-
var _a2
|
|
3714
|
+
var _a2;
|
|
3695
3715
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
|
3696
3716
|
const changed = getChanged(componentData, lastData);
|
|
3697
3717
|
setLastSelectedData(componentData);
|
|
3698
|
-
if (
|
|
3699
|
-
return yield componentConfig
|
|
3718
|
+
if (hasComponentResolver) {
|
|
3719
|
+
return yield componentConfig.resolveFields(
|
|
3700
3720
|
componentData,
|
|
3701
3721
|
{
|
|
3702
3722
|
changed,
|
|
@@ -3707,8 +3727,8 @@ var useResolvedFields = () => {
|
|
|
3707
3727
|
}
|
|
3708
3728
|
);
|
|
3709
3729
|
}
|
|
3710
|
-
if (
|
|
3711
|
-
return yield
|
|
3730
|
+
if (hasRootResolver) {
|
|
3731
|
+
return yield config.root.resolveFields(componentData, {
|
|
3712
3732
|
changed,
|
|
3713
3733
|
fields,
|
|
3714
3734
|
lastFields: resolvedFields,
|
|
@@ -3726,12 +3746,16 @@ var useResolvedFields = () => {
|
|
|
3726
3746
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
|
3727
3747
|
);
|
|
3728
3748
|
(0, import_react21.useEffect)(() => {
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3749
|
+
if (hasResolver) {
|
|
3750
|
+
setFieldsLoading(true);
|
|
3751
|
+
resolveFields(defaultFields).then((fields) => {
|
|
3752
|
+
setResolvedFields(fields || {});
|
|
3753
|
+
setFieldsLoading(false);
|
|
3754
|
+
});
|
|
3755
|
+
} else {
|
|
3756
|
+
setResolvedFields(defaultFields);
|
|
3757
|
+
}
|
|
3758
|
+
}, [data, defaultFields, state.ui.itemSelector, hasResolver]);
|
|
3735
3759
|
return [resolvedFields, fieldsLoading];
|
|
3736
3760
|
};
|
|
3737
3761
|
var Fields = () => {
|
|
@@ -4951,7 +4975,7 @@ var ViewportControls = ({
|
|
|
4951
4975
|
|
|
4952
4976
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
4953
4977
|
init_react_import();
|
|
4954
|
-
var styles_module_default21 = { "PuckCanvas": "
|
|
4978
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_avf1c_1", "PuckCanvas-controls": "_PuckCanvas-controls_avf1c_16", "PuckCanvas-inner": "_PuckCanvas-inner_avf1c_21", "PuckCanvas-root": "_PuckCanvas-root_avf1c_32", "PuckCanvas--ready": "_PuckCanvas--ready_avf1c_57", "PuckCanvas-loader": "_PuckCanvas-loader_avf1c_62", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_avf1c_72" };
|
|
4955
4979
|
|
|
4956
4980
|
// lib/get-zoom-config.ts
|
|
4957
4981
|
init_react_import();
|