@measured/puck
Version:
The open-source visual editor for React
1,553 lines (1,438 loc) • 356 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// ../tsup-config/react-import.js
var import_react;
var init_react_import = __esm({
"../tsup-config/react-import.js"() {
"use strict";
import_react = __toESM(require("react"));
}
});
// ../../node_modules/classnames/index.js
var require_classnames = __commonJS({
"../../node_modules/classnames/index.js"(exports2, module2) {
"use strict";
init_react_import();
(function() {
"use strict";
var hasOwn = {}.hasOwnProperty;
function classNames() {
var classes = "";
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (arg) {
classes = appendClass(classes, parseValue(arg));
}
}
return classes;
}
function parseValue(arg) {
if (typeof arg === "string" || typeof arg === "number") {
return arg;
}
if (typeof arg !== "object") {
return "";
}
if (Array.isArray(arg)) {
return classNames.apply(null, arg);
}
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
return arg.toString();
}
var classes = "";
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes = appendClass(classes, key);
}
}
return classes;
}
function appendClass(value, newClass) {
if (!newClass) {
return value;
}
if (value) {
return value + " " + newClass;
}
return value + newClass;
}
if (typeof module2 !== "undefined" && module2.exports) {
classNames.default = classNames;
module2.exports = classNames;
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
define("classnames", [], function() {
return classNames;
});
} else {
window.classNames = classNames;
}
})();
}
});
// bundle/no-external.ts
var no_external_exports = {};
__export(no_external_exports, {
Action: () => Action,
ActionBar: () => ActionBar,
AutoField: () => AutoField,
Button: () => Button,
Drawer: () => Drawer,
DropZone: () => DropZone,
FieldLabel: () => FieldLabel,
Group: () => Group,
IconButton: () => IconButton,
Label: () => Label,
Puck: () => Puck,
Render: () => Render,
createUsePuck: () => createUsePuck,
migrate: () => migrate,
overrideKeys: () => overrideKeys,
registerOverlayPortal: () => registerOverlayPortal,
renderContext: () => renderContext,
resolveAllData: () => resolveAllData,
setDeep: () => setDeep,
transformProps: () => transformProps,
useGetPuck: () => useGetPuck,
usePuck: () => usePuck,
walkTree: () => walkTree
});
module.exports = __toCommonJS(no_external_exports);
init_react_import();
// bundle/core.ts
init_react_import();
// types/API/index.ts
init_react_import();
// types/API/DropZone.ts
init_react_import();
// types/API/Viewports.ts
init_react_import();
// types/API/FieldTransforms.ts
init_react_import();
// types/index.ts
init_react_import();
// types/API/Overrides.ts
init_react_import();
var overrideKeys = [
"header",
"headerActions",
"fields",
"fieldLabel",
"drawer",
"drawerItem",
"componentOverlay",
"outline",
"puck",
"preview"
];
// types/AppState.tsx
init_react_import();
// types/Config.tsx
init_react_import();
// types/Data.tsx
init_react_import();
// types/Fields.ts
init_react_import();
// types/Props.tsx
init_react_import();
// types/Utils.tsx
init_react_import();
// components/ActionBar/index.tsx
init_react_import();
// lib/get-class-name-factory.ts
init_react_import();
var import_classnames = __toESM(require_classnames());
var getClassNameFactory = (rootClass, styles2, config = { baseClass: "" }) => (options = {}) => {
if (typeof options === "string") {
const descendant = options;
const style = styles2[`${rootClass}-${descendant}`];
if (style) {
return config.baseClass + styles2[`${rootClass}-${descendant}`] || "";
}
return "";
} else if (typeof options === "object") {
const modifiers = options;
const prefixedModifiers = {};
for (let modifier in modifiers) {
prefixedModifiers[styles2[`${rootClass}--${modifier}`]] = modifiers[modifier];
}
const c = styles2[rootClass];
return config.baseClass + (0, import_classnames.default)(__spreadValues({
[c]: !!c
}, prefixedModifiers));
} else {
return config.baseClass + styles2[rootClass] || "";
}
};
var get_class_name_factory_default = getClassNameFactory;
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
init_react_import();
var styles_module_default = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
// components/ActionBar/index.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var getClassName = get_class_name_factory_default("ActionBar", styles_module_default);
var ActionBar = ({
label,
children
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
"div",
{
className: getClassName(),
onClick: (e) => {
e.stopPropagation();
},
children: [
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionBar.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName("label"), children: label }) }),
children
]
}
);
var Action = ({
children,
label,
onClick
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"button",
{
type: "button",
className: getClassName("action"),
onClick,
title: label,
children
}
);
var Group = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName("group"), children });
var Label = ({ label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName("label"), children: label });
ActionBar.Action = Action;
ActionBar.Label = Label;
ActionBar.Group = Group;
// components/AutoField/index.tsx
init_react_import();
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
init_react_import();
var styles_module_default2 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-label": "_Input-label_bsxfo_5", "Input-labelIcon": "_Input-labelIcon_bsxfo_14", "Input-disabledIcon": "_Input-disabledIcon_bsxfo_21", "Input-input": "_Input-input_bsxfo_26", "Input": "_Input_bsxfo_1", "Input--readOnly": "_Input--readOnly_bsxfo_82", "Input-radioGroupItems": "_Input-radioGroupItems_bsxfo_93", "Input-radio": "_Input-radio_bsxfo_93", "Input-radioInner": "_Input-radioInner_bsxfo_110", "Input-radioInput": "_Input-radioInput_bsxfo_155" };
// components/AutoField/index.tsx
var import_react20 = require("react");
// components/AutoField/fields/index.tsx
init_react_import();
// components/AutoField/fields/ArrayField/index.tsx
init_react_import();
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/fields/ArrayField/styles.module.css#css-module
init_react_import();
var styles_module_default3 = { "ArrayField": "_ArrayField_14u8o_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_14u8o_13", "ArrayField-addButton": "_ArrayField-addButton_14u8o_18", "ArrayField--hasItems": "_ArrayField--hasItems_14u8o_33", "ArrayField-inner": "_ArrayField-inner_14u8o_59", "ArrayFieldItem": "_ArrayFieldItem_14u8o_67", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_14u8o_78", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_14u8o_82", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_14u8o_97", "ArrayField--addDisabled": "_ArrayField--addDisabled_14u8o_127", "ArrayFieldItem-body": "_ArrayFieldItem-body_14u8o_166", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_14u8o_175", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_14u8o_183", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_14u8o_189" };
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
init_react_import();
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
init_react_import();
var import_react3 = require("react");
// ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
init_react_import();
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
}).join(" ").trim();
// ../../node_modules/lucide-react/dist/esm/Icon.js
init_react_import();
var import_react2 = require("react");
// ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
init_react_import();
var defaultAttributes = {
xmlns: "http://www.w3.org/2000/svg",
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round"
};
// ../../node_modules/lucide-react/dist/esm/Icon.js
var Icon = (0, import_react2.forwardRef)(
(_a, ref) => {
var _b = _a, {
color = "currentColor",
size = 24,
strokeWidth = 2,
absoluteStrokeWidth,
className = "",
children,
iconNode
} = _b, rest = __objRest(_b, [
"color",
"size",
"strokeWidth",
"absoluteStrokeWidth",
"className",
"children",
"iconNode"
]);
return (0, import_react2.createElement)(
"svg",
__spreadValues(__spreadProps(__spreadValues({
ref
}, defaultAttributes), {
width: size,
height: size,
stroke: color,
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
className: mergeClasses("lucide", className)
}), rest),
[
...iconNode.map(([tag, attrs]) => (0, import_react2.createElement)(tag, attrs)),
...Array.isArray(children) ? children : [children]
]
);
}
);
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
var createLucideIcon = (iconName, iconNode) => {
const Component = (0, import_react3.forwardRef)(
(_a, ref) => {
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
return (0, import_react3.createElement)(Icon, __spreadValues({
ref,
iconNode,
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
}, props));
}
);
Component.displayName = `${iconName}`;
return Component;
};
// ../../node_modules/lucide-react/dist/esm/icons/chevron-down.js
init_react_import();
var ChevronDown = createLucideIcon("ChevronDown", [
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
init_react_import();
var ChevronRight = createLucideIcon("ChevronRight", [
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/chevron-up.js
init_react_import();
var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
// ../../node_modules/lucide-react/dist/esm/icons/circle-check-big.js
init_react_import();
var CircleCheckBig = createLucideIcon("CircleCheckBig", [
["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/copy.js
init_react_import();
var Copy = createLucideIcon("Copy", [
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
init_react_import();
var CornerLeftUp = createLucideIcon("CornerLeftUp", [
["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.js
init_react_import();
var EllipsisVertical = createLucideIcon("EllipsisVertical", [
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/globe.js
init_react_import();
var Globe = createLucideIcon("Globe", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
["path", { d: "M2 12h20", key: "9i4pu4" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/hash.js
init_react_import();
var Hash = createLucideIcon("Hash", [
["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/layers.js
init_react_import();
var Layers = createLucideIcon("Layers", [
[
"path",
{
d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
key: "zw3jo"
}
],
[
"path",
{
d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
key: "1wduqc"
}
],
[
"path",
{
d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
key: "kqbvx6"
}
]
]);
// ../../node_modules/lucide-react/dist/esm/icons/layout-grid.js
init_react_import();
var LayoutGrid = createLucideIcon("LayoutGrid", [
["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/link.js
init_react_import();
var Link = createLucideIcon("Link", [
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/list.js
init_react_import();
var List = createLucideIcon("List", [
["path", { d: "M3 12h.01", key: "nlz23k" }],
["path", { d: "M3 18h.01", key: "1tta3j" }],
["path", { d: "M3 6h.01", key: "1rqtza" }],
["path", { d: "M8 12h13", key: "1za7za" }],
["path", { d: "M8 18h13", key: "1lx6n3" }],
["path", { d: "M8 6h13", key: "ik3vkj" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/lock-open.js
init_react_import();
var LockOpen = createLucideIcon("LockOpen", [
["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
["path", { d: "M7 11V7a5 5 0 0 1 9.9-1", key: "1mm8w8" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/lock.js
init_react_import();
var Lock = createLucideIcon("Lock", [
["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/monitor.js
init_react_import();
var Monitor = createLucideIcon("Monitor", [
["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/panel-left.js
init_react_import();
var PanelLeft = createLucideIcon("PanelLeft", [
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
["path", { d: "M9 3v18", key: "fh3hqa" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/panel-right.js
init_react_import();
var PanelRight = createLucideIcon("PanelRight", [
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
["path", { d: "M15 3v18", key: "14nvp0" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/plus.js
init_react_import();
var Plus = createLucideIcon("Plus", [
["path", { d: "M5 12h14", key: "1ays0h" }],
["path", { d: "M12 5v14", key: "s699le" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
init_react_import();
var Redo2 = createLucideIcon("Redo2", [
["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/search.js
init_react_import();
var Search = createLucideIcon("Search", [
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/sliders-horizontal.js
init_react_import();
var SlidersHorizontal = createLucideIcon("SlidersHorizontal", [
["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
["line", { x1: "8", x2: "3", y1: "12", y2: "12", key: "ntss68" }],
["line", { x1: "21", x2: "16", y1: "20", y2: "20", key: "14d8ph" }],
["line", { x1: "12", x2: "3", y1: "20", y2: "20", key: "m0wm8r" }],
["line", { x1: "14", x2: "14", y1: "2", y2: "6", key: "14e1ph" }],
["line", { x1: "8", x2: "8", y1: "10", y2: "14", key: "1i6ji0" }],
["line", { x1: "16", x2: "16", y1: "18", y2: "22", key: "1lctlv" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/smartphone.js
init_react_import();
var Smartphone = createLucideIcon("Smartphone", [
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
["path", { d: "M12 18h.01", key: "mhygvu" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/tablet.js
init_react_import();
var Tablet = createLucideIcon("Tablet", [
["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/trash.js
init_react_import();
var Trash = createLucideIcon("Trash", [
["path", { d: "M3 6h18", key: "d0wm0j" }],
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/type.js
init_react_import();
var Type = createLucideIcon("Type", [
["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/undo-2.js
init_react_import();
var Undo2 = createLucideIcon("Undo2", [
["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
init_react_import();
var ZoomIn = createLucideIcon("ZoomIn", [
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
["line", { x1: "11", x2: "11", y1: "8", y2: "14", key: "1vmskp" }],
["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
]);
// ../../node_modules/lucide-react/dist/esm/icons/zoom-out.js
init_react_import();
var ZoomOut = createLucideIcon("ZoomOut", [
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
]);
// components/IconButton/index.ts
init_react_import();
// components/IconButton/IconButton.tsx
init_react_import();
var import_react9 = require("react");
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
init_react_import();
var IconButton_module_default = { "IconButton": "_IconButton_swpni_1", "IconButton--disabled": "_IconButton--disabled_swpni_20", "IconButton-title": "_IconButton-title_swpni_33" };
// components/Loader/index.tsx
init_react_import();
// lib/index.ts
init_react_import();
// lib/filter.ts
init_react_import();
// lib/data/reorder.ts
init_react_import();
var reorder = (list, startIndex, endIndex) => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);
return result;
};
// lib/data/replace.ts
init_react_import();
var replace = (list, index, newItem) => {
const result = Array.from(list);
result.splice(index, 1);
result.splice(index, 0, newItem);
return result;
};
// lib/use-reset-auto-zoom.ts
init_react_import();
// store/index.ts
init_react_import();
// reducer/index.ts
init_react_import();
// reducer/actions/set.ts
init_react_import();
// lib/data/walk-app-state.ts
init_react_import();
// lib/data/for-related-zones.ts
init_react_import();
// lib/get-zone-id.ts
init_react_import();
// lib/root-droppable-id.ts
init_react_import();
var rootAreaId = "root";
var rootZone = "default-zone";
var rootDroppableId = `${rootAreaId}:${rootZone}`;
// lib/get-zone-id.ts
var getZoneId = (zoneCompound) => {
if (!zoneCompound) {
return [];
}
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
return zoneCompound.split(":");
}
return [rootDroppableId, zoneCompound];
};
// lib/data/for-related-zones.ts
function forRelatedZones(item, data, cb, path = []) {
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
const [parentId] = getZoneId(zoneCompound);
if (parentId === item.props.id) {
cb(path, zoneCompound, content);
}
});
}
// lib/data/map-fields.ts
init_react_import();
// lib/data/default-slots.ts
init_react_import();
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
(acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
value
);
// lib/data/map-fields.ts
var isPromise = (v) => !!v && typeof v.then === "function";
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
var containsPromise = (arr) => arr.some(isPromise);
var walkField = ({
value,
fields,
mappers,
propKey = "",
propPath = "",
id = "",
config,
recurseSlots = false
}) => {
var _a, _b, _c;
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
const map = mappers[fieldType];
if (map && fieldType === "slot") {
const content = value || [];
const mappedContent = recurseSlots ? content.map((el) => {
var _a2;
const componentConfig = config.components[el.type];
if (!componentConfig) {
throw new Error(`Could not find component config for ${el.type}`);
}
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
return walkField({
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
fields: fields2,
mappers,
id: el.props.id,
config,
recurseSlots
});
}) : content;
if (containsPromise(mappedContent)) {
return Promise.all(mappedContent);
}
return map({
value: mappedContent,
parentId: id,
propName: propPath,
field: fields[propKey],
propPath
});
} else if (map && fields[propKey]) {
return map({
value,
parentId: id,
propName: propKey,
field: fields[propKey],
propPath
});
}
if (value && typeof value === "object") {
if (Array.isArray(value)) {
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
if (!arrayFields) return value;
const newValue = value.map(
(el, idx) => walkField({
value: el,
fields: arrayFields,
mappers,
propKey,
propPath: `${propPath}[${idx}]`,
id,
config,
recurseSlots
})
);
if (containsPromise(newValue)) {
return Promise.all(newValue);
}
return newValue;
} else if ("$$typeof" in value) {
return value;
} else {
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
return walkObject({
value,
fields: objectFields,
mappers,
id,
getPropPath: (k) => `${propPath}.${k}`,
config,
recurseSlots
});
}
}
return value;
};
var walkObject = ({
value,
fields,
mappers,
id,
getPropPath,
config,
recurseSlots
}) => {
const newProps = Object.entries(value).map(([k, v]) => {
const opts = {
value: v,
fields,
mappers,
propKey: k,
propPath: getPropPath(k),
id,
config,
recurseSlots
};
const newValue = walkField(opts);
if (isPromise(newValue)) {
return newValue.then((resolvedValue) => ({
[k]: resolvedValue
}));
}
return {
[k]: newValue
};
}, {});
if (containsPromise(newProps)) {
return Promise.all(newProps).then(flatten);
}
return flatten(newProps);
};
function mapFields(item, mappers, config, recurseSlots = false) {
var _a, _b, _c, _d, _e;
const itemType = "type" in item ? item.type : "root";
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
const newProps = walkObject({
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
mappers,
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
getPropPath: (k) => k,
config,
recurseSlots
});
if (isPromise(newProps)) {
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
props: resolvedProps
}));
}
return __spreadProps(__spreadValues({}, item), {
props: newProps
});
}
// lib/data/flatten-node.ts
init_react_import();
var import_flat = __toESM(require("flat"));
// lib/data/strip-slots.ts
init_react_import();
var stripSlots = (data, config) => {
return mapFields(data, { slot: () => null }, config);
};
// lib/data/flatten-node.ts
var { flatten: flatten2, unflatten } = import_flat.default;
var flattenNode = (node, config) => {
return __spreadProps(__spreadValues({}, node), {
props: flatten2(stripSlots(node, config).props)
});
};
var expandNode = (node) => {
const props = unflatten(node.props);
return __spreadProps(__spreadValues({}, node), {
props
});
};
// lib/data/walk-app-state.ts
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
var _a;
let newZones = {};
const newZoneIndex = {};
const newNodeIndex = {};
const processContent = (path, zoneCompound, content, zoneType, newId) => {
var _a2;
const [parentId] = zoneCompound.split(":");
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
const [_2, zone] = zoneCompound.split(":");
const newZoneCompound = `${newId || parentId}:${zone}`;
const newContent2 = mappedContent.map(
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
);
newZoneIndex[newZoneCompound] = {
contentIds: newContent2.map((item) => item.props.id),
type: zoneType
};
return [newZoneCompound, newContent2];
};
const processRelatedZones = (item, newId, initialPath) => {
forRelatedZones(
item,
state.data,
(relatedPath, relatedZoneCompound, relatedContent) => {
const [zoneCompound, newContent2] = processContent(
relatedPath,
relatedZoneCompound,
relatedContent,
"dropzone",
newId
);
newZones[zoneCompound] = newContent2;
},
initialPath
);
};
const processItem = (item, path, index) => {
const mappedItem = mapNodeOrSkip(item, path, index);
if (!mappedItem) return item;
const id = mappedItem.props.id;
const newProps = __spreadProps(__spreadValues({}, mapFields(
mappedItem,
{
slot: ({ value, parentId: parentId2, propPath }) => {
const content = value;
const zoneCompound = `${parentId2}:${propPath}`;
const [_2, newContent2] = processContent(
path,
zoneCompound,
content,
"slot",
parentId2
);
return newContent2;
}
},
config
).props), {
id
});
processRelatedZones(item, id, path);
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
const thisZoneCompound = path[path.length - 1];
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
newNodeIndex[id] = {
data: newItem,
flatData: flattenNode(newItem, config),
path,
parentId,
zone
};
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
if (newProps.id === "root") {
delete finalData["type"];
delete finalData.props["id"];
}
return finalData;
};
const zones = state.data.zones || {};
const [_, newContent] = processContent(
[],
rootDroppableId,
state.data.content,
"root"
);
const processedContent = newContent;
const zonesAlreadyProcessed = Object.keys(newZones);
Object.keys(zones || {}).forEach((zoneCompound) => {
const [parentId] = zoneCompound.split(":");
if (zonesAlreadyProcessed.includes(zoneCompound)) {
return;
}
const [_2, newContent2] = processContent(
[rootDroppableId],
zoneCompound,
zones[zoneCompound],
"dropzone",
parentId
);
newZones[zoneCompound] = newContent2;
}, newZones);
const processedRoot = processItem(
{
type: "root",
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
},
[],
-1
);
const root = __spreadProps(__spreadValues({}, state.data.root), {
props: processedRoot.props
});
return __spreadProps(__spreadValues({}, state), {
data: {
root,
content: processedContent,
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
},
indexes: {
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
}
});
}
// reducer/actions/set.ts
var setAction = (state, action, appStore) => {
if (typeof action.state === "object") {
const newState = __spreadValues(__spreadValues({}, state), action.state);
if (action.state.indexes) {
return newState;
}
console.warn(
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
);
return walkAppState(newState, appStore.config);
}
return __spreadValues(__spreadValues({}, state), action.state(state));
};
// reducer/actions/insert.ts
init_react_import();
// lib/data/insert.ts
init_react_import();
var insert = (list, index, item) => {
const result = Array.from(list || []);
result.splice(index, 0, item);
return result;
};
// lib/generate-id.ts
init_react_import();
var import_uuid = require("uuid");
var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
// lib/data/get-ids-for-parent.ts
init_react_import();
var getIdsForParent = (zoneCompound, state) => {
const [parentId] = zoneCompound.split(":");
const node = state.indexes.nodes[parentId];
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
};
// lib/data/populate-ids.ts
init_react_import();
// lib/data/walk-tree.ts
init_react_import();
function walkTree(data, config, callbackFn) {
var _a, _b;
const walkItem = (item) => {
return mapFields(
item,
{
slot: ({ value, parentId, propName }) => {
var _a2;
const content = value;
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
}
},
config,
true
);
};
if ("props" in data) {
return walkItem(data);
}
const _data = data;
const zones = (_a = _data.zones) != null ? _a : {};
const mappedContent = _data.content.map(walkItem);
return {
root: walkItem(_data.root),
content: (_b = callbackFn(mappedContent, {
parentId: "root",
propName: "default-zone"
})) != null ? _b : mappedContent,
zones: Object.keys(zones).reduce(
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
[zoneCompound]: zones[zoneCompound].map(walkItem)
}),
{}
)
};
}
// lib/data/populate-ids.ts
var populateIds = (data, config, override = false) => {
const id = generateId(data.type);
return walkTree(
__spreadProps(__spreadValues({}, data), {
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
}),
config,
(contents) => contents.map((item) => {
const id2 = generateId(item.type);
return __spreadProps(__spreadValues({}, item), {
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
});
})
);
};
// reducer/actions/insert.ts
function insertAction(state, action, appStore) {
const id = action.id || generateId(action.componentType);
const emptyComponentData = populateIds(
{
type: action.componentType,
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
id
})
},
appStore.config
);
const [parentId] = action.destinationZone.split(":");
const idsInPath = getIdsForParent(action.destinationZone, state);
return walkAppState(
state,
appStore.config,
(content, zoneCompound) => {
if (zoneCompound === action.destinationZone) {
return insert(
content || [],
action.destinationIndex,
emptyComponentData
);
}
return content;
},
(childItem, path) => {
if (childItem.props.id === id || childItem.props.id === parentId) {
return childItem;
} else if (idsInPath.includes(childItem.props.id)) {
return childItem;
} else if (path.includes(action.destinationZone)) {
return childItem;
}
return null;
}
);
}
// reducer/actions/replace.ts
init_react_import();
var replaceAction = (state, action, appStore) => {
const [parentId] = action.destinationZone.split(":");
const idsInPath = getIdsForParent(action.destinationZone, state);
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
const idChanged = originalId !== action.data.props.id;
if (idChanged) {
throw new Error(
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
);
}
const newSlotIds = [];
const data = walkTree(action.data, appStore.config, (contents, opts) => {
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
return contents.map((item) => {
const id = generateId(item.type);
return __spreadProps(__spreadValues({}, item), {
props: __spreadValues({ id }, item.props)
});
});
});
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
const id = zoneCompound.split(":")[0];
if (id === originalId) {
if (!newSlotIds.includes(zoneCompound)) {
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
}
}
});
return walkAppState(
stateWithDeepSlotsRemoved,
appStore.config,
(content, zoneCompound) => {
const newContent = [...content];
if (zoneCompound === action.destinationZone) {
newContent[action.destinationIndex] = data;
}
return newContent;
},
(childItem, path) => {
const pathIds = path.map((p) => p.split(":")[0]);
if (childItem.props.id === data.props.id) {
return data;
} else if (childItem.props.id === parentId) {
return childItem;
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
return childItem;
} else if (pathIds.indexOf(data.props.id) > -1) {
return childItem;
}
return null;
}
);
};
// reducer/actions/replace-root.ts
init_react_import();
var replaceRootAction = (state, action, appStore) => {
return walkAppState(
state,
appStore.config,
(content) => content,
(childItem) => {
if (childItem.props.id === "root") {
return __spreadProps(__spreadValues({}, childItem), {
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
readOnly: action.root.readOnly
});
}
return childItem;
}
);
};
// reducer/actions/duplicate.ts
init_react_import();
// lib/data/get-item.ts
init_react_import();
function getItem(selector, state) {
var _a, _b;
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
}
// reducer/actions/duplicate.ts
function duplicateAction(state, action, appStore) {
const item = getItem(
{ index: action.sourceIndex, zone: action.sourceZone },
state
);
const idsInPath = getIdsForParent(action.sourceZone, state);
const newItem = __spreadProps(__spreadValues({}, item), {
props: __spreadProps(__spreadValues({}, item.props), {
id: generateId(item.type)
})
});
const modified = walkAppState(
state,
appStore.config,
(content, zoneCompound) => {
if (zoneCompound === action.sourceZone) {
return insert(content, action.sourceIndex + 1, item);
}
return content;
},
(childItem, path, index) => {
const zoneCompound = path[path.length - 1];
const parents = path.map((p) => p.split(":")[0]);
if (parents.indexOf(newItem.props.id) > -1) {
return __spreadProps(__spreadValues({}, childItem), {
props: __spreadProps(__spreadValues({}, childItem.props), {
id: generateId(childItem.type)
})
});
}
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
return newItem;
}
const [sourceZoneParent] = action.sourceZone.split(":");
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
return childItem;
}
return null;
}
);
return __spreadProps(__spreadValues({}, modified), {
ui: __spreadProps(__spreadValues({}, modified.ui), {
itemSelector: {
index: action.sourceIndex + 1,
zone: action.sourceZone
}
})
});
}
// reducer/actions/reorder.ts
init_react_import();
// reducer/actions/move.ts
init_react_import();
// lib/data/remove.ts
init_react_import();
var remove = (list, index) => {
const result = Array.from(list);
result.splice(index, 1);
return result;
};
// reducer/actions/move.ts
var moveAction = (state, action, appStore) => {
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
return state;
}
const item = getItem(
{ zone: action.sourceZone, index: action.sourceIndex },
state
);
if (!item) return state;
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
return walkAppState(
state,
appStore.config,
(content, zoneCompound) => {
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
return insert(
remove(content, action.sourceIndex),
action.destinationIndex,
item
);
} else if (zoneCompound === action.sourceZone) {
return remove(content, action.sourceIndex);
} else if (zoneCompound === action.destinationZone) {
return insert(content, action.destinationIndex, item);
}
return content;
},
(childItem, path) => {
const [sourceZoneParent] = action.sourceZone.split(":");
const [destinationZoneParent] = action.destinationZone.split(":");
const childId = childItem.props.id;
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
return childItem;
}
return null;
}
);
};
// reducer/actions/reorder.ts
var reorderAction = (state, action, appStore) => {
return moveAction(
state,
{
type: "move",
sourceIndex: action.sourceIndex,
sourceZone: action.destinationZone,
destinationIndex: action.destinationIndex,
destinationZone: action.destinationZone
},
appStore
);
};
// reducer/actions/remove.ts
init_react_import();
var removeAction = (state, action, appStore) => {
const item = getItem({ index: action.index, zone: action.zone }, state);
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
(acc, [nodeId, nodeData]) => {
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
if (pathIds.includes(item.props.id)) {
return [...acc, nodeId];
}
return acc;
},
[item.props.id]
);
const newState = walkAppState(
state,
appStore.config,
(content, zoneCompound) => {
if (zoneCompound === action.zone) {
return remove(content, action.index);
}
return content;
}
);
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
const parentId = zoneCompound.split(":")[0];
if (nodesToDelete.includes(parentId) && newState.data.zones) {
delete newState.data.zones[zoneCompound];
}
});
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
const parentId = zoneCompound.split(":")[0];
if (nodesToDelete.includes(parentId)) {
delete newState.indexes.zones[zoneCompound];
}
});
nodesToDelete.forEach((id) => {
delete newState.indexes.nodes[id];
});
return newState;
};
// reducer/actions/register-zone.ts
init_react_import();
// lib/data/setup-zone.ts
init_react_import();
var setupZone = (data, zoneKey) => {
if (zoneKey === rootDroppableId) {
return data;
}
const newData = __spreadProps(__spreadValues({}, data), {
zones: data.zones ? __spreadValues({}, data.zones) : {}
});
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
return newData;
};
// reducer/actions/register-zone.ts
var zoneCache = {};
function registerZoneAction(state, action) {
if (zoneCache[action.zone]) {
return __spreadProps(__spreadValues({}, state), {
data: __spreadProps(__spreadValues({}, state.data), {
zones: __spreadProps(__spreadValues({}, state.data.zones), {
[action.zone]: zoneCache[action.zone]
})
}),
indexes: __spreadProps(__spreadValues({}, state.indexes), {
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
contentIds: zoneCache[action.zone].map((item) => item.props.id),
type: "dropzone"
})
})
})
});
}
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
}
function unregisterZoneAction(state, action) {
const _zones = __spreadValues({}, state.data.zones || {});
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
if (_zones[action.zone]) {
zoneCache[action.zone] = _zones[action.zone];
delete _zones[action.zone];
}
delete zoneIndex[action.zone];
return __spreadProps(__spreadValues({}, state), {
data: __spreadProps(__spreadValues({}, state.data), {
zones: _zones
}),
indexes: __spreadProps(__spreadValues({}, state.indexes), {
zones: zoneIndex
})
});
}
// reducer/actions/set-data.ts
init_react_import();
var setDataAction = (state, action, appStore) => {
if (typeof action.data === "object") {
console.warn(
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
);
return walkAppState(
__spreadProps(__spreadValues({}, state), {
data: __spreadValues(__spreadValues({}, state.data), action.data)
}),
appStore.config
);
}
return walkAppState(
__spreadProps(__spreadValues({}, state), {
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
}),
appStore.config
);
};
// reducer/actions/set-ui.ts
init_react_import();
var setUiAction = (state, action) => {
if (typeof action.ui === "object") {
return __spreadProps(__spreadValues({}, state), {
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
});
}
return __spreadProps(__spreadValues({}, state), {
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
});
};
// lib/data/make-state-public.ts
init_react_import();
var makeStatePublic = (state) => {
const { data, ui } = state;
return { data, ui };
};
// reducer/actions.tsx
init_react_import();
// reducer/index.ts
function storeInterceptor(reducer, record, onAction) {
return (state, action) => {
const newAppState = reducer(state, action);
const isValidType = ![
"registerZone",
"unregisterZone",
"setData",
"setUi",
"set"
].includes(action.type);
i