@measured/puck 0.1.1 → 0.1.3
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/package.json +3 -2
- package/dist/index.css +0 -611
- package/dist/index.d.ts +0 -117
- package/dist/index.js +0 -1188
package/dist/index.js
DELETED
|
@@ -1,1188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
38
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
|
-
};
|
|
40
|
-
var __export = (target, all) => {
|
|
41
|
-
for (var name in all)
|
|
42
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
43
|
-
};
|
|
44
|
-
var __copyProps = (to, from, except, desc) => {
|
|
45
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
46
|
-
for (let key of __getOwnPropNames(from))
|
|
47
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
48
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
49
|
-
}
|
|
50
|
-
return to;
|
|
51
|
-
};
|
|
52
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
53
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
54
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
55
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
56
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
57
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
58
|
-
mod
|
|
59
|
-
));
|
|
60
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
61
|
-
var __async = (__this, __arguments, generator) => {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
var fulfilled = (value) => {
|
|
64
|
-
try {
|
|
65
|
-
step(generator.next(value));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
reject(e);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var rejected = (value) => {
|
|
71
|
-
try {
|
|
72
|
-
step(generator.throw(value));
|
|
73
|
-
} catch (e) {
|
|
74
|
-
reject(e);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
78
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// ../../node_modules/classnames/index.js
|
|
83
|
-
var require_classnames = __commonJS({
|
|
84
|
-
"../../node_modules/classnames/index.js"(exports, module2) {
|
|
85
|
-
(function() {
|
|
86
|
-
"use strict";
|
|
87
|
-
var hasOwn = {}.hasOwnProperty;
|
|
88
|
-
var nativeCodeString = "[native code]";
|
|
89
|
-
function classNames() {
|
|
90
|
-
var classes = [];
|
|
91
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
92
|
-
var arg = arguments[i];
|
|
93
|
-
if (!arg)
|
|
94
|
-
continue;
|
|
95
|
-
var argType = typeof arg;
|
|
96
|
-
if (argType === "string" || argType === "number") {
|
|
97
|
-
classes.push(arg);
|
|
98
|
-
} else if (Array.isArray(arg)) {
|
|
99
|
-
if (arg.length) {
|
|
100
|
-
var inner = classNames.apply(null, arg);
|
|
101
|
-
if (inner) {
|
|
102
|
-
classes.push(inner);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} else if (argType === "object") {
|
|
106
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
107
|
-
classes.push(arg.toString());
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
for (var key in arg) {
|
|
111
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
112
|
-
classes.push(key);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return classes.join(" ");
|
|
118
|
-
}
|
|
119
|
-
if (typeof module2 !== "undefined" && module2.exports) {
|
|
120
|
-
classNames.default = classNames;
|
|
121
|
-
module2.exports = classNames;
|
|
122
|
-
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
123
|
-
define("classnames", [], function() {
|
|
124
|
-
return classNames;
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
window.classNames = classNames;
|
|
128
|
-
}
|
|
129
|
-
})();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// index.tsx
|
|
134
|
-
var core_exports = {};
|
|
135
|
-
__export(core_exports, {
|
|
136
|
-
Puck: () => Puck,
|
|
137
|
-
Render: () => Render
|
|
138
|
-
});
|
|
139
|
-
module.exports = __toCommonJS(core_exports);
|
|
140
|
-
|
|
141
|
-
// Puck/index.tsx
|
|
142
|
-
var import_react6 = require("react");
|
|
143
|
-
var import_react_beautiful_dnd4 = require("react-beautiful-dnd");
|
|
144
|
-
|
|
145
|
-
// DroppableStrictMode/index.tsx
|
|
146
|
-
var import_react = require("react");
|
|
147
|
-
var import_react_beautiful_dnd = require("react-beautiful-dnd");
|
|
148
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
149
|
-
var DroppableStrictMode = (_a) => {
|
|
150
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
151
|
-
const [enabled, setEnabled] = (0, import_react.useState)(false);
|
|
152
|
-
(0, import_react.useEffect)(() => {
|
|
153
|
-
const animation = requestAnimationFrame(() => setEnabled(true));
|
|
154
|
-
return () => {
|
|
155
|
-
cancelAnimationFrame(animation);
|
|
156
|
-
setEnabled(false);
|
|
157
|
-
};
|
|
158
|
-
}, []);
|
|
159
|
-
if (!enabled) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_beautiful_dnd.Droppable, __spreadProps(__spreadValues({}, props), { children }));
|
|
163
|
-
};
|
|
164
|
-
var DroppableStrictMode_default = DroppableStrictMode;
|
|
165
|
-
|
|
166
|
-
// DraggableComponent/index.tsx
|
|
167
|
-
var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
|
|
168
|
-
|
|
169
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/DraggableComponent/styles.module.css#css-module
|
|
170
|
-
var styles_module_default = { "DraggableComponent": "_DraggableComponent_10y0g_1", "DraggableComponent-contents": "_DraggableComponent-contents_10y0g_5", "DraggableComponent-overlay": "_DraggableComponent-overlay_10y0g_9", "DraggableComponent--isModifierHeld": "_DraggableComponent--isModifierHeld_10y0g_25", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_10y0g_29", "DraggableComponent-actions": "_DraggableComponent-actions_10y0g_34", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_10y0g_49", "DraggableComponent-action": "_DraggableComponent-action_10y0g_34" };
|
|
171
|
-
|
|
172
|
-
// lib/get-class-name-factory.ts
|
|
173
|
-
var import_classnames = __toESM(require_classnames());
|
|
174
|
-
var getClassNameFactory = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
|
|
175
|
-
let descendant = false;
|
|
176
|
-
let modifiers = false;
|
|
177
|
-
if (typeof options === "string") {
|
|
178
|
-
descendant = options;
|
|
179
|
-
} else if (typeof options === "object") {
|
|
180
|
-
modifiers = options;
|
|
181
|
-
}
|
|
182
|
-
if (descendant) {
|
|
183
|
-
return baseClass + styles[`${rootClass}-${descendant}`] || "";
|
|
184
|
-
} else if (modifiers) {
|
|
185
|
-
const prefixedModifiers = {};
|
|
186
|
-
for (let modifier in modifiers) {
|
|
187
|
-
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
188
|
-
}
|
|
189
|
-
const c = styles[rootClass];
|
|
190
|
-
return baseClass + (0, import_classnames.default)(__spreadValues({
|
|
191
|
-
[c]: !!c
|
|
192
|
-
}, prefixedModifiers));
|
|
193
|
-
} else {
|
|
194
|
-
return baseClass + styles[rootClass] || "";
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
var get_class_name_factory_default = getClassNameFactory;
|
|
198
|
-
|
|
199
|
-
// DraggableComponent/index.tsx
|
|
200
|
-
var import_react_feather = require("react-feather");
|
|
201
|
-
|
|
202
|
-
// lib/use-modifier-held.ts
|
|
203
|
-
var import_react2 = require("react");
|
|
204
|
-
var useModifierHeld = (modifier) => {
|
|
205
|
-
const [modifierHeld, setModifierHeld] = (0, import_react2.useState)(false);
|
|
206
|
-
function downHandler({ key }) {
|
|
207
|
-
if (key === modifier) {
|
|
208
|
-
setModifierHeld(true);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function upHandler({ key }) {
|
|
212
|
-
if (key === modifier) {
|
|
213
|
-
setModifierHeld(false);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
(0, import_react2.useEffect)(() => {
|
|
217
|
-
window.addEventListener("keydown", downHandler);
|
|
218
|
-
window.addEventListener("keyup", upHandler);
|
|
219
|
-
return () => {
|
|
220
|
-
window.removeEventListener("keydown", downHandler);
|
|
221
|
-
window.removeEventListener("keyup", upHandler);
|
|
222
|
-
};
|
|
223
|
-
}, []);
|
|
224
|
-
return modifierHeld;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// DraggableComponent/index.tsx
|
|
228
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
229
|
-
var getClassName = get_class_name_factory_default("DraggableComponent", styles_module_default);
|
|
230
|
-
var DraggableComponent = ({
|
|
231
|
-
children,
|
|
232
|
-
id,
|
|
233
|
-
index,
|
|
234
|
-
isSelected = false,
|
|
235
|
-
onClick = () => null,
|
|
236
|
-
onDelete = () => null,
|
|
237
|
-
onDuplicate = () => null,
|
|
238
|
-
debug,
|
|
239
|
-
label
|
|
240
|
-
}) => {
|
|
241
|
-
const isModifierHeld = useModifierHeld("Alt");
|
|
242
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_beautiful_dnd2.Draggable, { draggableId: id, index, children: (provided) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
243
|
-
"div",
|
|
244
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
245
|
-
ref: provided.innerRef
|
|
246
|
-
}, provided.draggableProps), provided.dragHandleProps), {
|
|
247
|
-
className: getClassName({ isSelected, isModifierHeld }),
|
|
248
|
-
style: __spreadProps(__spreadValues({}, provided.draggableProps.style), {
|
|
249
|
-
cursor: isModifierHeld ? "initial" : "grab"
|
|
250
|
-
}),
|
|
251
|
-
children: [
|
|
252
|
-
debug,
|
|
253
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName("contents"), children }),
|
|
254
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName("overlay"), onClick, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: getClassName("actions"), children: [
|
|
255
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName("actionsLabel"), children: label }),
|
|
256
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: getClassName("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_feather.Copy, {}) }),
|
|
257
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: getClassName("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_feather.Trash, {}) })
|
|
258
|
-
] }) })
|
|
259
|
-
]
|
|
260
|
-
})
|
|
261
|
-
) }, id);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// ExternalInput/index.tsx
|
|
265
|
-
var import_react3 = require("react");
|
|
266
|
-
|
|
267
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/ExternalInput/styles.module.css#css-module
|
|
268
|
-
var styles_module_default2 = { "ExternalInput": "_ExternalInput_v316c_1", "ExternalInput-actions": "_ExternalInput-actions_v316c_5", "ExternalInput-button": "_ExternalInput-button_v316c_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_v316c_23", "ExternalInput--hasData": "_ExternalInput--hasData_v316c_30", "ExternalInput-modal": "_ExternalInput-modal_v316c_45", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_v316c_59", "ExternalInput-modalInner": "_ExternalInput-modalInner_v316c_63", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_v316c_74", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_v316c_79" };
|
|
269
|
-
|
|
270
|
-
// ExternalInput/index.tsx
|
|
271
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
272
|
-
var getClassName2 = get_class_name_factory_default("ExternalInput", styles_module_default2);
|
|
273
|
-
var ExternalInput = ({
|
|
274
|
-
field,
|
|
275
|
-
onChange,
|
|
276
|
-
value = null
|
|
277
|
-
}) => {
|
|
278
|
-
const [data, setData] = (0, import_react3.useState)([]);
|
|
279
|
-
const [isOpen, setOpen] = (0, import_react3.useState)(false);
|
|
280
|
-
const [selectedData, setSelectedData] = (0, import_react3.useState)(value);
|
|
281
|
-
(0, import_react3.useEffect)(() => {
|
|
282
|
-
(() => __async(void 0, null, function* () {
|
|
283
|
-
if (field.adaptor) {
|
|
284
|
-
const listData = yield field.adaptor.fetchList(field.adaptorParams);
|
|
285
|
-
if (listData) {
|
|
286
|
-
setData(listData);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}))();
|
|
290
|
-
}, [field.adaptor, field.adaptorParams]);
|
|
291
|
-
if (!field.adaptor) {
|
|
292
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Incorrectly configured" });
|
|
293
|
-
}
|
|
294
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
295
|
-
"div",
|
|
296
|
-
{
|
|
297
|
-
className: getClassName2({
|
|
298
|
-
hasData: !!selectedData,
|
|
299
|
-
modalVisible: isOpen
|
|
300
|
-
}),
|
|
301
|
-
children: [
|
|
302
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName2("actions"), children: [
|
|
303
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
304
|
-
"button",
|
|
305
|
-
{
|
|
306
|
-
onClick: () => setOpen(true),
|
|
307
|
-
className: getClassName2("button"),
|
|
308
|
-
children: selectedData ? selectedData.attributes.title : `Select from ${field.adaptor.name}`
|
|
309
|
-
}
|
|
310
|
-
),
|
|
311
|
-
selectedData && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
312
|
-
"button",
|
|
313
|
-
{
|
|
314
|
-
className: getClassName2("detachButton"),
|
|
315
|
-
onClick: () => {
|
|
316
|
-
setSelectedData(null);
|
|
317
|
-
onChange(null);
|
|
318
|
-
},
|
|
319
|
-
children: "Detach"
|
|
320
|
-
}
|
|
321
|
-
)
|
|
322
|
-
] }),
|
|
323
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("modal"), onClick: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
324
|
-
"div",
|
|
325
|
-
{
|
|
326
|
-
className: getClassName2("modalInner"),
|
|
327
|
-
onClick: (e) => e.stopPropagation(),
|
|
328
|
-
children: [
|
|
329
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: getClassName2("modalHeading"), children: "Select content" }),
|
|
330
|
-
data.length ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName2("modalTableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { children: [
|
|
331
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: Object.keys(data[0].attributes).map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { style: { textAlign: "left" }, children: key }, key)) }) }),
|
|
332
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: data.map((item) => {
|
|
333
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
334
|
-
"tr",
|
|
335
|
-
{
|
|
336
|
-
style: { whiteSpace: "nowrap" },
|
|
337
|
-
onClick: (e) => {
|
|
338
|
-
onChange(item);
|
|
339
|
-
setOpen(false);
|
|
340
|
-
setSelectedData(item);
|
|
341
|
-
},
|
|
342
|
-
children: Object.keys(item.attributes).map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { children: item.attributes[key] }, key))
|
|
343
|
-
},
|
|
344
|
-
item.id
|
|
345
|
-
);
|
|
346
|
-
}) })
|
|
347
|
-
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "No content" })
|
|
348
|
-
]
|
|
349
|
-
}
|
|
350
|
-
) })
|
|
351
|
-
]
|
|
352
|
-
}
|
|
353
|
-
);
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/InputOrGroup/styles.module.css#css-module
|
|
357
|
-
var styles_module_default3 = { "Input": "_Input_1vwgb_1", "Input-label": "_Input-label_1vwgb_14", "Input-input": "_Input-input_1vwgb_20", "Input--readOnly": "_Input--readOnly_1vwgb_41", "Input-group": "_Input-group_1vwgb_50", "Input-action": "_Input-action_1vwgb_72", "Input-addButton": "_Input-addButton_1vwgb_93", "Input-item": "_Input-item_1vwgb_107", "Input-radioGroup": "_Input-radioGroup_1vwgb_114", "Input-radioGroupItems": "_Input-radioGroupItems_1vwgb_119", "Input-radio": "_Input-radio_1vwgb_114" };
|
|
358
|
-
|
|
359
|
-
// lib/filter.ts
|
|
360
|
-
var filter = (obj, validKeys) => {
|
|
361
|
-
return validKeys.reduce((acc, item) => {
|
|
362
|
-
if (typeof obj[item] !== "undefined") {
|
|
363
|
-
return __spreadProps(__spreadValues({}, acc), { [item]: obj[item] });
|
|
364
|
-
}
|
|
365
|
-
return acc;
|
|
366
|
-
}, {});
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
// lib/reorder.ts
|
|
370
|
-
var reorder = (list, startIndex, endIndex) => {
|
|
371
|
-
const result = Array.from(list);
|
|
372
|
-
const [removed] = result.splice(startIndex, 1);
|
|
373
|
-
result.splice(endIndex, 0, removed);
|
|
374
|
-
return result;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// lib/replace.ts
|
|
378
|
-
var replace = (list, index, newItem) => {
|
|
379
|
-
const result = Array.from(list);
|
|
380
|
-
result.splice(index, 1);
|
|
381
|
-
result.splice(index, 0, newItem);
|
|
382
|
-
return result;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
// InputOrGroup/index.tsx
|
|
386
|
-
var import_react_feather2 = require("react-feather");
|
|
387
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
388
|
-
var getClassName3 = get_class_name_factory_default("Input", styles_module_default3);
|
|
389
|
-
var InputOrGroup = ({
|
|
390
|
-
name,
|
|
391
|
-
field,
|
|
392
|
-
value,
|
|
393
|
-
label,
|
|
394
|
-
onChange,
|
|
395
|
-
readOnly
|
|
396
|
-
}) => {
|
|
397
|
-
if (field.type === "group") {
|
|
398
|
-
if (!field.groupFields) {
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassName3(), children: [
|
|
402
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { className: getClassName3("label"), children: label || name }),
|
|
403
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassName3("item"), children: [
|
|
404
|
-
Array.isArray(value) ? value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: getClassName3("group"), children: [
|
|
405
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
|
|
406
|
-
field.getItemSummary ? field.getItemSummary(item, i) : `Item #${i}`,
|
|
407
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
408
|
-
"button",
|
|
409
|
-
{
|
|
410
|
-
className: getClassName3("action"),
|
|
411
|
-
onClick: () => {
|
|
412
|
-
const existingValue = value || [];
|
|
413
|
-
existingValue.splice(i, 1);
|
|
414
|
-
onChange(existingValue);
|
|
415
|
-
},
|
|
416
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_feather2.Trash, {})
|
|
417
|
-
}
|
|
418
|
-
)
|
|
419
|
-
] }),
|
|
420
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("fieldset", { children: Object.keys(field.groupFields).map((fieldName) => {
|
|
421
|
-
const subField = field.groupFields[fieldName];
|
|
422
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
423
|
-
InputOrGroup,
|
|
424
|
-
{
|
|
425
|
-
name: `${name}_${i}_${fieldName}`,
|
|
426
|
-
label: fieldName,
|
|
427
|
-
field: subField,
|
|
428
|
-
value: item[fieldName],
|
|
429
|
-
onChange: (val) => onChange(
|
|
430
|
-
replace(value, i, __spreadProps(__spreadValues({}, item), { [fieldName]: val }))
|
|
431
|
-
)
|
|
432
|
-
},
|
|
433
|
-
`${name}_${i}_${fieldName}`
|
|
434
|
-
);
|
|
435
|
-
}) })
|
|
436
|
-
] }, `${name}_${i}`)) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", {}),
|
|
437
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
438
|
-
"button",
|
|
439
|
-
{
|
|
440
|
-
className: getClassName3("addButton"),
|
|
441
|
-
onClick: () => {
|
|
442
|
-
const existingValue = value || [];
|
|
443
|
-
onChange([...existingValue, field.defaultItemProps || {}]);
|
|
444
|
-
},
|
|
445
|
-
children: "Add item"
|
|
446
|
-
}
|
|
447
|
-
)
|
|
448
|
-
] })
|
|
449
|
-
] });
|
|
450
|
-
}
|
|
451
|
-
if (field.type === "external") {
|
|
452
|
-
if (!field.adaptor) {
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassName3(""), children: [
|
|
456
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("label"), children: name === "_data" ? "External content" : label || name }),
|
|
457
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ExternalInput, { field, onChange, value })
|
|
458
|
-
] });
|
|
459
|
-
}
|
|
460
|
-
if (field.type === "select") {
|
|
461
|
-
if (!field.options) {
|
|
462
|
-
return null;
|
|
463
|
-
}
|
|
464
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: getClassName3(), children: [
|
|
465
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("label"), children: label || name }),
|
|
466
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
467
|
-
"select",
|
|
468
|
-
{
|
|
469
|
-
className: getClassName3("input"),
|
|
470
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
|
471
|
-
value,
|
|
472
|
-
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
473
|
-
"option",
|
|
474
|
-
{
|
|
475
|
-
label: option.label,
|
|
476
|
-
value: option.value
|
|
477
|
-
},
|
|
478
|
-
option.label + option.value
|
|
479
|
-
))
|
|
480
|
-
}
|
|
481
|
-
)
|
|
482
|
-
] });
|
|
483
|
-
}
|
|
484
|
-
if (field.type === "textarea") {
|
|
485
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: getClassName3({ readOnly }), children: [
|
|
486
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("label"), children: label || name }),
|
|
487
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
488
|
-
"textarea",
|
|
489
|
-
{
|
|
490
|
-
className: getClassName3("input"),
|
|
491
|
-
autoComplete: "off",
|
|
492
|
-
name,
|
|
493
|
-
value,
|
|
494
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
|
495
|
-
readOnly,
|
|
496
|
-
rows: 5
|
|
497
|
-
}
|
|
498
|
-
)
|
|
499
|
-
] });
|
|
500
|
-
}
|
|
501
|
-
if (field.type === "radio") {
|
|
502
|
-
if (!field.options) {
|
|
503
|
-
return null;
|
|
504
|
-
}
|
|
505
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassName3("radioGroup"), children: [
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("label"), children: field.label || name }),
|
|
507
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
508
|
-
"label",
|
|
509
|
-
{
|
|
510
|
-
className: getClassName3("radio"),
|
|
511
|
-
children: [
|
|
512
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
513
|
-
"input",
|
|
514
|
-
{
|
|
515
|
-
type: "radio",
|
|
516
|
-
value: option.value,
|
|
517
|
-
name,
|
|
518
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
|
519
|
-
readOnly,
|
|
520
|
-
defaultChecked: value === option.value
|
|
521
|
-
}
|
|
522
|
-
),
|
|
523
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: option.label || option.value })
|
|
524
|
-
]
|
|
525
|
-
},
|
|
526
|
-
option.label + option.value
|
|
527
|
-
)) })
|
|
528
|
-
] });
|
|
529
|
-
}
|
|
530
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: getClassName3({ readOnly }), children: [
|
|
531
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("label"), children: label || name }),
|
|
532
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
533
|
-
"input",
|
|
534
|
-
{
|
|
535
|
-
className: getClassName3("input"),
|
|
536
|
-
autoComplete: "off",
|
|
537
|
-
type: field.type,
|
|
538
|
-
name,
|
|
539
|
-
value,
|
|
540
|
-
onChange: (e) => onChange(e.currentTarget.value),
|
|
541
|
-
readOnly
|
|
542
|
-
}
|
|
543
|
-
)
|
|
544
|
-
] });
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
// ComponentList/index.tsx
|
|
548
|
-
var import_react_beautiful_dnd3 = require("react-beautiful-dnd");
|
|
549
|
-
|
|
550
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/ComponentList/styles.module.css#css-module
|
|
551
|
-
var styles_module_default4 = { "ComponentList": "_ComponentList_91nmt_1", "ComponentList-item": "_ComponentList-item_91nmt_9", "ComponentList-itemShadow": "_ComponentList-itemShadow_91nmt_10", "ComponentList-itemIcon": "_ComponentList-itemIcon_91nmt_24" };
|
|
552
|
-
|
|
553
|
-
// ComponentList/index.tsx
|
|
554
|
-
var import_react_feather3 = require("react-feather");
|
|
555
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
556
|
-
var getClassName4 = get_class_name_factory_default("ComponentList", styles_module_default4);
|
|
557
|
-
var ComponentList = ({ config }) => {
|
|
558
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DroppableStrictMode_default, { droppableId: "component-list", isDropDisabled: true, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
559
|
-
"div",
|
|
560
|
-
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
|
561
|
-
ref: provided.innerRef,
|
|
562
|
-
className: getClassName4(),
|
|
563
|
-
children: Object.keys(config.components).map((componentKey, i) => {
|
|
564
|
-
const componentConfig = config[componentKey];
|
|
565
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
566
|
-
import_react_beautiful_dnd3.Draggable,
|
|
567
|
-
{
|
|
568
|
-
draggableId: componentKey,
|
|
569
|
-
index: i,
|
|
570
|
-
children: (provided2, snapshot2) => {
|
|
571
|
-
var _a;
|
|
572
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
573
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
574
|
-
"div",
|
|
575
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
576
|
-
ref: provided2.innerRef
|
|
577
|
-
}, provided2.draggableProps), provided2.dragHandleProps), {
|
|
578
|
-
className: getClassName4("item"),
|
|
579
|
-
style: __spreadProps(__spreadValues({}, provided2.draggableProps.style), {
|
|
580
|
-
transform: snapshot2.isDragging ? (_a = provided2.draggableProps.style) == null ? void 0 : _a.transform : "translate(0px, 0px)"
|
|
581
|
-
}),
|
|
582
|
-
children: [
|
|
583
|
-
componentKey,
|
|
584
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_feather3.Grid, { size: 18 }) })
|
|
585
|
-
]
|
|
586
|
-
})
|
|
587
|
-
),
|
|
588
|
-
snapshot2.isDragging && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
589
|
-
"div",
|
|
590
|
-
{
|
|
591
|
-
className: getClassName4("itemShadow"),
|
|
592
|
-
style: { transform: "none !important" },
|
|
593
|
-
children: [
|
|
594
|
-
componentKey,
|
|
595
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_feather3.Grid, { size: 18 }) })
|
|
596
|
-
]
|
|
597
|
-
}
|
|
598
|
-
)
|
|
599
|
-
] });
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
componentKey
|
|
603
|
-
);
|
|
604
|
-
})
|
|
605
|
-
})
|
|
606
|
-
) });
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/OutlineList/styles.module.css#css-module
|
|
610
|
-
var styles_module_default5 = { "OutlineList": "_OutlineList_gor6f_1", "OutlineList-clickableItem": "_OutlineList-clickableItem_gor6f_36" };
|
|
611
|
-
|
|
612
|
-
// OutlineList/index.tsx
|
|
613
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
614
|
-
var getClassName5 = get_class_name_factory_default("OutlineList", styles_module_default5);
|
|
615
|
-
var OutlineList = ({ children }) => {
|
|
616
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: getClassName5(), children });
|
|
617
|
-
};
|
|
618
|
-
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("clickableItem"), children });
|
|
619
|
-
OutlineList.Item = ({
|
|
620
|
-
children,
|
|
621
|
-
onClick
|
|
622
|
-
}) => {
|
|
623
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
624
|
-
"li",
|
|
625
|
-
{
|
|
626
|
-
className: onClick ? getClassName5("clickableItem") : "",
|
|
627
|
-
onClick,
|
|
628
|
-
children
|
|
629
|
-
}
|
|
630
|
-
);
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
// Button/Button.tsx
|
|
634
|
-
var import_react4 = require("react");
|
|
635
|
-
|
|
636
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/Button/Button.module.css#css-module
|
|
637
|
-
var Button_module_default = { "Button": "_Button_1bqmn_1", "Button--primary": "_Button--primary_1bqmn_25", "Button--secondary": "_Button--secondary_1bqmn_34", "Button--flush": "_Button--flush_1bqmn_45", "Button--disabled": "_Button--disabled_1bqmn_49", "Button--fullWidth": "_Button--fullWidth_1bqmn_59" };
|
|
638
|
-
|
|
639
|
-
// Button/Button.tsx
|
|
640
|
-
var import_react_spinners = require("react-spinners");
|
|
641
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
642
|
-
var getClassName6 = get_class_name_factory_default("Button", Button_module_default);
|
|
643
|
-
var Button = ({
|
|
644
|
-
children,
|
|
645
|
-
href,
|
|
646
|
-
onClick,
|
|
647
|
-
variant = "primary",
|
|
648
|
-
type,
|
|
649
|
-
disabled,
|
|
650
|
-
tabIndex,
|
|
651
|
-
newTab,
|
|
652
|
-
fullWidth
|
|
653
|
-
}) => {
|
|
654
|
-
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
655
|
-
const ElementType = href ? "a" : "button";
|
|
656
|
-
const el = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
657
|
-
ElementType,
|
|
658
|
-
{
|
|
659
|
-
className: getClassName6({
|
|
660
|
-
primary: variant === "primary",
|
|
661
|
-
secondary: variant === "secondary",
|
|
662
|
-
disabled,
|
|
663
|
-
fullWidth
|
|
664
|
-
}),
|
|
665
|
-
onClick: (e) => {
|
|
666
|
-
if (!onClick)
|
|
667
|
-
return;
|
|
668
|
-
setLoading(true);
|
|
669
|
-
Promise.resolve(onClick(e)).then(() => {
|
|
670
|
-
setLoading(false);
|
|
671
|
-
});
|
|
672
|
-
},
|
|
673
|
-
type,
|
|
674
|
-
disabled: disabled || loading,
|
|
675
|
-
tabIndex,
|
|
676
|
-
target: newTab ? "_blank" : void 0,
|
|
677
|
-
rel: newTab ? "noreferrer" : void 0,
|
|
678
|
-
href,
|
|
679
|
-
children: [
|
|
680
|
-
children,
|
|
681
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
682
|
-
"\xA0\xA0",
|
|
683
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_spinners.ClipLoader, { color: "inherit", size: "14px" })
|
|
684
|
-
] })
|
|
685
|
-
]
|
|
686
|
-
}
|
|
687
|
-
);
|
|
688
|
-
return el;
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
// lib/use-placeholder-style.ts
|
|
692
|
-
var import_react5 = require("react");
|
|
693
|
-
var usePlaceholderStyle = () => {
|
|
694
|
-
const queryAttr = "data-rbd-drag-handle-draggable-id";
|
|
695
|
-
const [placeholderStyle, setPlaceholderStyle] = (0, import_react5.useState)();
|
|
696
|
-
const onDragUpdate = (update) => {
|
|
697
|
-
if (!update.destination) {
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
const draggableId = update.draggableId;
|
|
701
|
-
const destinationIndex = update.destination.index;
|
|
702
|
-
const domQuery = `[${queryAttr}='${draggableId}']`;
|
|
703
|
-
const draggedDOM = document.querySelector(domQuery);
|
|
704
|
-
if (!draggedDOM) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
const targetListElement = document.querySelector("#puck-drop-zone");
|
|
708
|
-
const { clientHeight } = draggedDOM;
|
|
709
|
-
if (!targetListElement) {
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
let clientY = 0;
|
|
713
|
-
if (destinationIndex > 0) {
|
|
714
|
-
const children = Array.from(targetListElement.children).filter((item) => item !== draggedDOM).slice(0, destinationIndex);
|
|
715
|
-
clientY = children.reduce(
|
|
716
|
-
(total, item) => total + item.clientHeight + parseInt(window.getComputedStyle(item).marginTop.replace("px", "")),
|
|
717
|
-
0
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
setPlaceholderStyle({
|
|
721
|
-
position: "absolute",
|
|
722
|
-
top: clientY,
|
|
723
|
-
left: 0,
|
|
724
|
-
height: clientHeight,
|
|
725
|
-
width: "100%"
|
|
726
|
-
});
|
|
727
|
-
};
|
|
728
|
-
return { onDragUpdate, placeholderStyle };
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/SidebarSection/styles.module.css#css-module
|
|
732
|
-
var styles_module_default6 = { "SidebarSection": "_SidebarSection_jsf8x_1", "SidebarSection-content": "_SidebarSection-content_jsf8x_1", "SidebarSection-title": "_SidebarSection-title_jsf8x_6" };
|
|
733
|
-
|
|
734
|
-
// css-module:/Users/chrisvilla/Projects/puck/packages/core/Heading/styles.module.css#css-module
|
|
735
|
-
var styles_module_default7 = { "Heading": "_Heading_1y35v_1", "Heading--xxxxl": "_Heading--xxxxl_1y35v_12", "Heading--xxxl": "_Heading--xxxl_1y35v_18", "Heading--xxl": "_Heading--xxl_1y35v_22", "Heading--xl": "_Heading--xl_1y35v_26", "Heading--l": "_Heading--l_1y35v_30", "Heading--m": "_Heading--m_1y35v_34", "Heading--s": "_Heading--s_1y35v_38", "Heading--xs": "_Heading--xs_1y35v_42" };
|
|
736
|
-
|
|
737
|
-
// Heading/index.tsx
|
|
738
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
739
|
-
var getClassName7 = get_class_name_factory_default("Heading", styles_module_default7);
|
|
740
|
-
var Heading = ({ children, rank, size = "m" }) => {
|
|
741
|
-
const Tag = rank ? `h${rank}` : "span";
|
|
742
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
743
|
-
Tag,
|
|
744
|
-
{
|
|
745
|
-
className: getClassName7({
|
|
746
|
-
[size]: true
|
|
747
|
-
}),
|
|
748
|
-
children
|
|
749
|
-
}
|
|
750
|
-
);
|
|
751
|
-
};
|
|
752
|
-
|
|
753
|
-
// SidebarSection/index.tsx
|
|
754
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
755
|
-
var getClassName8 = get_class_name_factory_default("SidebarSection", styles_module_default6);
|
|
756
|
-
var SidebarSection = ({
|
|
757
|
-
children,
|
|
758
|
-
title
|
|
759
|
-
}) => {
|
|
760
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: getClassName8({}), open: true, children: [
|
|
761
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { className: getClassName8("title"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading, { rank: 2, size: "xs", children: title }) }),
|
|
762
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName8("content"), children })
|
|
763
|
-
] });
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// lib/scroll-into-view.ts
|
|
767
|
-
var scrollIntoView = (el) => {
|
|
768
|
-
const oldStyle = __spreadValues({}, el.style);
|
|
769
|
-
el.style.scrollMargin = "256px";
|
|
770
|
-
if (el) {
|
|
771
|
-
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
|
772
|
-
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
// Puck/index.tsx
|
|
777
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
778
|
-
var defaultPageFields = {
|
|
779
|
-
title: { type: "text" }
|
|
780
|
-
};
|
|
781
|
-
var PluginRenderer = ({
|
|
782
|
-
children,
|
|
783
|
-
data,
|
|
784
|
-
plugins,
|
|
785
|
-
renderMethod
|
|
786
|
-
}) => {
|
|
787
|
-
return plugins.filter((item) => item[renderMethod]).map((item) => item[renderMethod]).reduce(
|
|
788
|
-
(accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Item, { data, children: accChildren }),
|
|
789
|
-
children
|
|
790
|
-
);
|
|
791
|
-
};
|
|
792
|
-
function Puck({
|
|
793
|
-
config,
|
|
794
|
-
data: initialData = { content: [], page: { title: "" } },
|
|
795
|
-
onChange,
|
|
796
|
-
onPublish,
|
|
797
|
-
plugins = [],
|
|
798
|
-
renderHeader
|
|
799
|
-
}) {
|
|
800
|
-
var _a, _b;
|
|
801
|
-
const [data, setData] = (0, import_react6.useState)(initialData);
|
|
802
|
-
const [selectedIndex, setSelectedIndex] = (0, import_react6.useState)(null);
|
|
803
|
-
const Page = (0, import_react6.useCallback)(
|
|
804
|
-
(pageProps) => {
|
|
805
|
-
var _a2, _b2;
|
|
806
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
807
|
-
PluginRenderer,
|
|
808
|
-
{
|
|
809
|
-
plugins,
|
|
810
|
-
renderMethod: "renderPage",
|
|
811
|
-
data: pageProps.data,
|
|
812
|
-
children: ((_a2 = config.page) == null ? void 0 : _a2.render) ? (_b2 = config.page) == null ? void 0 : _b2.render(__spreadProps(__spreadValues({}, pageProps), { editMode: true })) : pageProps.children
|
|
813
|
-
}
|
|
814
|
-
);
|
|
815
|
-
},
|
|
816
|
-
[config.page]
|
|
817
|
-
);
|
|
818
|
-
const PageFieldWrapper = (0, import_react6.useCallback)(
|
|
819
|
-
(props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
820
|
-
PluginRenderer,
|
|
821
|
-
{
|
|
822
|
-
plugins,
|
|
823
|
-
renderMethod: "renderPageFields",
|
|
824
|
-
data: props.data,
|
|
825
|
-
children: props.children
|
|
826
|
-
}
|
|
827
|
-
),
|
|
828
|
-
[]
|
|
829
|
-
);
|
|
830
|
-
const ComponentFieldWrapper = (0, import_react6.useCallback)(
|
|
831
|
-
(props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
832
|
-
PluginRenderer,
|
|
833
|
-
{
|
|
834
|
-
plugins,
|
|
835
|
-
renderMethod: "renderFields",
|
|
836
|
-
data: props.data,
|
|
837
|
-
children: props.children
|
|
838
|
-
}
|
|
839
|
-
),
|
|
840
|
-
[]
|
|
841
|
-
);
|
|
842
|
-
const FieldWrapper = selectedIndex !== null ? ComponentFieldWrapper : PageFieldWrapper;
|
|
843
|
-
const pageFields = ((_a = config.page) == null ? void 0 : _a.fields) || defaultPageFields;
|
|
844
|
-
let fields = selectedIndex !== null ? ((_b = config.components[data.content[selectedIndex].type]) == null ? void 0 : _b.fields) || {} : pageFields;
|
|
845
|
-
(0, import_react6.useEffect)(() => {
|
|
846
|
-
if (onChange)
|
|
847
|
-
onChange(data);
|
|
848
|
-
}, [data]);
|
|
849
|
-
const { onDragUpdate, placeholderStyle } = usePlaceholderStyle();
|
|
850
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
851
|
-
import_react_beautiful_dnd4.DragDropContext,
|
|
852
|
-
{
|
|
853
|
-
onDragUpdate,
|
|
854
|
-
onDragEnd: (droppedItem) => {
|
|
855
|
-
if (!droppedItem.destination) {
|
|
856
|
-
console.warn("No destination specified");
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
|
-
if (droppedItem.source.droppableId === "component-list") {
|
|
860
|
-
const emptyComponentData = {
|
|
861
|
-
type: droppedItem.draggableId,
|
|
862
|
-
props: __spreadProps(__spreadValues({}, config.components[droppedItem.draggableId].defaultProps || {}), {
|
|
863
|
-
id: `${droppedItem.draggableId}-${(/* @__PURE__ */ new Date()).getTime()}`
|
|
864
|
-
// TODO make random string
|
|
865
|
-
})
|
|
866
|
-
};
|
|
867
|
-
const newData = __spreadValues({}, data);
|
|
868
|
-
newData.content.splice(
|
|
869
|
-
droppedItem.destination.index,
|
|
870
|
-
0,
|
|
871
|
-
emptyComponentData
|
|
872
|
-
);
|
|
873
|
-
setData(newData);
|
|
874
|
-
setSelectedIndex(droppedItem.destination.index);
|
|
875
|
-
} else {
|
|
876
|
-
setData(__spreadProps(__spreadValues({}, data), {
|
|
877
|
-
content: reorder(
|
|
878
|
-
data.content,
|
|
879
|
-
droppedItem.source.index,
|
|
880
|
-
droppedItem.destination.index
|
|
881
|
-
)
|
|
882
|
-
}));
|
|
883
|
-
setSelectedIndex(null);
|
|
884
|
-
}
|
|
885
|
-
},
|
|
886
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
887
|
-
"div",
|
|
888
|
-
{
|
|
889
|
-
style: {
|
|
890
|
-
display: "grid",
|
|
891
|
-
gridTemplateAreas: '"header header header" "left editor right"',
|
|
892
|
-
gridTemplateColumns: "256px auto 256px",
|
|
893
|
-
gridTemplateRows: "min-content auto",
|
|
894
|
-
height: "100vh",
|
|
895
|
-
position: "fixed",
|
|
896
|
-
top: 0,
|
|
897
|
-
bottom: 0,
|
|
898
|
-
left: 0,
|
|
899
|
-
right: 0
|
|
900
|
-
},
|
|
901
|
-
children: [
|
|
902
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
903
|
-
"header",
|
|
904
|
-
{
|
|
905
|
-
style: {
|
|
906
|
-
background: "var(--puck-color-grey-0)",
|
|
907
|
-
color: "white",
|
|
908
|
-
gridArea: "header",
|
|
909
|
-
borderBottom: "1px solid #cccccc"
|
|
910
|
-
},
|
|
911
|
-
children: renderHeader ? renderHeader({
|
|
912
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
913
|
-
Button,
|
|
914
|
-
{
|
|
915
|
-
onClick: () => {
|
|
916
|
-
onPublish(data);
|
|
917
|
-
},
|
|
918
|
-
children: "Publish"
|
|
919
|
-
}
|
|
920
|
-
),
|
|
921
|
-
data,
|
|
922
|
-
setData
|
|
923
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
924
|
-
"div",
|
|
925
|
-
{
|
|
926
|
-
style: {
|
|
927
|
-
display: "flex",
|
|
928
|
-
justifyContent: "flex-end",
|
|
929
|
-
padding: 16
|
|
930
|
-
},
|
|
931
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
932
|
-
Button,
|
|
933
|
-
{
|
|
934
|
-
onClick: () => {
|
|
935
|
-
onPublish(data);
|
|
936
|
-
},
|
|
937
|
-
children: "Publish"
|
|
938
|
-
}
|
|
939
|
-
)
|
|
940
|
-
}
|
|
941
|
-
)
|
|
942
|
-
}
|
|
943
|
-
),
|
|
944
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
945
|
-
"div",
|
|
946
|
-
{
|
|
947
|
-
style: {
|
|
948
|
-
gridArea: "left",
|
|
949
|
-
background: "var(--puck-color-grey-10)",
|
|
950
|
-
overflowY: "auto"
|
|
951
|
-
},
|
|
952
|
-
children: [
|
|
953
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComponentList, { config }) }),
|
|
954
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OutlineList, { children: data.content.map((item, i) => {
|
|
955
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
956
|
-
OutlineList.Item,
|
|
957
|
-
{
|
|
958
|
-
onClick: () => {
|
|
959
|
-
setSelectedIndex(i);
|
|
960
|
-
const id = data.content[i].props.id;
|
|
961
|
-
scrollIntoView(
|
|
962
|
-
document.querySelector(
|
|
963
|
-
`[data-rbd-drag-handle-draggable-id="draggable-${id}"]`
|
|
964
|
-
)
|
|
965
|
-
);
|
|
966
|
-
},
|
|
967
|
-
children: item.type
|
|
968
|
-
},
|
|
969
|
-
i
|
|
970
|
-
);
|
|
971
|
-
}) }) })
|
|
972
|
-
]
|
|
973
|
-
}
|
|
974
|
-
),
|
|
975
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
976
|
-
"div",
|
|
977
|
-
{
|
|
978
|
-
style: {
|
|
979
|
-
background: "var(--puck-color-grey-8)",
|
|
980
|
-
padding: 32,
|
|
981
|
-
overflowY: "auto",
|
|
982
|
-
gridArea: "editor"
|
|
983
|
-
},
|
|
984
|
-
onClick: () => setSelectedIndex(null),
|
|
985
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
986
|
-
"div",
|
|
987
|
-
{
|
|
988
|
-
className: "puck-root",
|
|
989
|
-
style: {
|
|
990
|
-
background: "white",
|
|
991
|
-
borderRadius: 16,
|
|
992
|
-
overflow: "hidden",
|
|
993
|
-
zoom: 0.75
|
|
994
|
-
},
|
|
995
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Page, __spreadProps(__spreadValues({ data }, data.page), { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DroppableStrictMode_default, { droppableId: "droppable", children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
996
|
-
"div",
|
|
997
|
-
__spreadProps(__spreadValues({}, provided.droppableProps), {
|
|
998
|
-
ref: provided.innerRef,
|
|
999
|
-
style: {
|
|
1000
|
-
minHeight: 128,
|
|
1001
|
-
position: "relative",
|
|
1002
|
-
zoom: 1.33
|
|
1003
|
-
},
|
|
1004
|
-
id: "puck-drop-zone",
|
|
1005
|
-
children: [
|
|
1006
|
-
data.content.map((item, i) => {
|
|
1007
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1008
|
-
DraggableComponent,
|
|
1009
|
-
{
|
|
1010
|
-
label: item.type.toString(),
|
|
1011
|
-
id: `draggable-${item.props.id}`,
|
|
1012
|
-
index: i,
|
|
1013
|
-
isSelected: selectedIndex === i,
|
|
1014
|
-
onClick: (e) => {
|
|
1015
|
-
setSelectedIndex(i);
|
|
1016
|
-
e.stopPropagation();
|
|
1017
|
-
},
|
|
1018
|
-
onDelete: (e) => {
|
|
1019
|
-
const newData = __spreadValues({}, data);
|
|
1020
|
-
newData.content.splice(i, 1);
|
|
1021
|
-
setSelectedIndex(null);
|
|
1022
|
-
setData(newData);
|
|
1023
|
-
e.stopPropagation();
|
|
1024
|
-
},
|
|
1025
|
-
onDuplicate: (e) => {
|
|
1026
|
-
const newData = __spreadValues({}, data);
|
|
1027
|
-
const newItem = __spreadProps(__spreadValues({}, newData.content[i]), {
|
|
1028
|
-
props: __spreadProps(__spreadValues({}, newData.content[i].props), {
|
|
1029
|
-
id: `${newData.content[i].type}-${(/* @__PURE__ */ new Date()).getTime()}`
|
|
1030
|
-
})
|
|
1031
|
-
});
|
|
1032
|
-
newData.content.splice(i + 1, 0, newItem);
|
|
1033
|
-
setData(newData);
|
|
1034
|
-
e.stopPropagation();
|
|
1035
|
-
},
|
|
1036
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { zoom: 0.75 }, children: config.components[item.type] ? config.components[item.type].render(__spreadProps(__spreadValues(__spreadValues({}, config.components[item.type].defaultProps), item.props), {
|
|
1037
|
-
editMode: true
|
|
1038
|
-
})) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
|
|
1039
|
-
"No configuration for ",
|
|
1040
|
-
item.type
|
|
1041
|
-
] }) })
|
|
1042
|
-
},
|
|
1043
|
-
item.props.id
|
|
1044
|
-
);
|
|
1045
|
-
}),
|
|
1046
|
-
provided.placeholder,
|
|
1047
|
-
snapshot.isDraggingOver && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1048
|
-
"div",
|
|
1049
|
-
{
|
|
1050
|
-
style: __spreadProps(__spreadValues({}, placeholderStyle), {
|
|
1051
|
-
background: "var(--puck-color-azure-8)",
|
|
1052
|
-
zIndex: 0
|
|
1053
|
-
})
|
|
1054
|
-
}
|
|
1055
|
-
)
|
|
1056
|
-
]
|
|
1057
|
-
})
|
|
1058
|
-
) }) }))
|
|
1059
|
-
}
|
|
1060
|
-
)
|
|
1061
|
-
}
|
|
1062
|
-
),
|
|
1063
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1064
|
-
"div",
|
|
1065
|
-
{
|
|
1066
|
-
style: {
|
|
1067
|
-
background: "var(--puck-color-grey-10)",
|
|
1068
|
-
overflowY: "auto",
|
|
1069
|
-
gridArea: "right",
|
|
1070
|
-
fontFamily: "var(--puck-font-stack)"
|
|
1071
|
-
},
|
|
1072
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldWrapper, { data, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1073
|
-
SidebarSection,
|
|
1074
|
-
{
|
|
1075
|
-
title: selectedIndex !== null ? data.content[selectedIndex].type : "Page",
|
|
1076
|
-
children: Object.keys(fields).map((fieldName) => {
|
|
1077
|
-
var _a2, _b2, _c, _d;
|
|
1078
|
-
const field = fields[fieldName];
|
|
1079
|
-
const onChange2 = (value) => {
|
|
1080
|
-
let currentProps;
|
|
1081
|
-
let newProps;
|
|
1082
|
-
if (selectedIndex !== null) {
|
|
1083
|
-
currentProps = data.content[selectedIndex].props;
|
|
1084
|
-
} else {
|
|
1085
|
-
currentProps = data.page;
|
|
1086
|
-
}
|
|
1087
|
-
if (fieldName === "_data") {
|
|
1088
|
-
if (!value) {
|
|
1089
|
-
const _a3 = currentProps._meta || {}, { locked } = _a3, _meta = __objRest(_a3, ["locked"]);
|
|
1090
|
-
newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
1091
|
-
_data: void 0,
|
|
1092
|
-
_meta
|
|
1093
|
-
});
|
|
1094
|
-
} else {
|
|
1095
|
-
const changedFields = filter(
|
|
1096
|
-
// filter out anything not supported by this component
|
|
1097
|
-
value.attributes,
|
|
1098
|
-
// TODO type properly after getting proper state library
|
|
1099
|
-
Object.keys(fields)
|
|
1100
|
-
);
|
|
1101
|
-
newProps = __spreadProps(__spreadValues(__spreadValues({}, currentProps), changedFields), {
|
|
1102
|
-
_data: value,
|
|
1103
|
-
// TODO perf - this is duplicative and will make payload larger
|
|
1104
|
-
_meta: {
|
|
1105
|
-
locked: Object.keys(changedFields)
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
} else {
|
|
1110
|
-
newProps = __spreadProps(__spreadValues({}, currentProps), {
|
|
1111
|
-
[fieldName]: value
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
if (selectedIndex !== null) {
|
|
1115
|
-
setData(__spreadProps(__spreadValues({}, data), {
|
|
1116
|
-
content: replace(data.content, selectedIndex, __spreadProps(__spreadValues({}, data.content[selectedIndex]), {
|
|
1117
|
-
props: newProps
|
|
1118
|
-
}))
|
|
1119
|
-
}));
|
|
1120
|
-
} else {
|
|
1121
|
-
setData(__spreadProps(__spreadValues({}, data), { page: newProps }));
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
if (selectedIndex !== null) {
|
|
1125
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1126
|
-
InputOrGroup,
|
|
1127
|
-
{
|
|
1128
|
-
field,
|
|
1129
|
-
name: fieldName,
|
|
1130
|
-
label: field.label,
|
|
1131
|
-
readOnly: ((_b2 = (_a2 = data.content[selectedIndex].props._meta) == null ? void 0 : _a2.locked) == null ? void 0 : _b2.indexOf(fieldName)) > -1,
|
|
1132
|
-
value: data.content[selectedIndex].props[fieldName],
|
|
1133
|
-
onChange: onChange2
|
|
1134
|
-
},
|
|
1135
|
-
`${data.content[selectedIndex].props.id}_${fieldName}`
|
|
1136
|
-
);
|
|
1137
|
-
} else {
|
|
1138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1139
|
-
InputOrGroup,
|
|
1140
|
-
{
|
|
1141
|
-
field,
|
|
1142
|
-
name: fieldName,
|
|
1143
|
-
label: field.label,
|
|
1144
|
-
readOnly: ((_d = (_c = data.page._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(fieldName)) > -1,
|
|
1145
|
-
value: data.page[fieldName],
|
|
1146
|
-
onChange: onChange2
|
|
1147
|
-
},
|
|
1148
|
-
`page_${fieldName}`
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
})
|
|
1152
|
-
}
|
|
1153
|
-
) })
|
|
1154
|
-
}
|
|
1155
|
-
)
|
|
1156
|
-
]
|
|
1157
|
-
}
|
|
1158
|
-
)
|
|
1159
|
-
}
|
|
1160
|
-
) });
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
// Render/index.tsx
|
|
1164
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1165
|
-
function Render({ config, data }) {
|
|
1166
|
-
const children = data.content.map((item) => {
|
|
1167
|
-
const Component = config.components[item.type].render;
|
|
1168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, __spreadValues({}, item.props), item.props.id);
|
|
1169
|
-
});
|
|
1170
|
-
if (config.page) {
|
|
1171
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(config.page.render, __spreadProps(__spreadValues({}, data.page), { editMode: false, children }));
|
|
1172
|
-
}
|
|
1173
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children });
|
|
1174
|
-
}
|
|
1175
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1176
|
-
0 && (module.exports = {
|
|
1177
|
-
Puck,
|
|
1178
|
-
Render
|
|
1179
|
-
});
|
|
1180
|
-
/*! Bundled license information:
|
|
1181
|
-
|
|
1182
|
-
classnames/index.js:
|
|
1183
|
-
(*!
|
|
1184
|
-
Copyright (c) 2018 Jed Watson.
|
|
1185
|
-
Licensed under the MIT License (MIT), see
|
|
1186
|
-
http://jedwatson.github.io/classnames
|
|
1187
|
-
*)
|
|
1188
|
-
*/
|