@measured/puck 0.21.0-canary.c0db75c1 → 0.21.0-canary.c78dc826

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.
Files changed (49) hide show
  1. package/dist/Editor-F2LSS6SE.css +403 -0
  2. package/dist/Editor-N46HUQEC.mjs +201 -0
  3. package/dist/Render-QEMDIDQC.css +101 -0
  4. package/dist/Render-Y567PGZ7.mjs +53 -0
  5. package/dist/chunk-3QHWXJEI.mjs +33 -0
  6. package/dist/chunk-7KY6RHEY.mjs +2230 -0
  7. package/dist/{chunk-PJYARUPI.mjs → chunk-C2TVYIYC.mjs} +76 -138
  8. package/dist/chunk-DCSQEDMK.mjs +194 -0
  9. package/dist/{chunk-S3RM5GHZ.mjs → chunk-DJSH5REF.mjs} +127 -93
  10. package/dist/chunk-DNF2EMM4.mjs +63 -0
  11. package/dist/chunk-FNWOH4R6.mjs +109 -0
  12. package/dist/chunk-GQKMOYLG.mjs +53 -0
  13. package/dist/chunk-K3V4LVUL.mjs +704 -0
  14. package/dist/chunk-R6CVX2IY.mjs +103 -0
  15. package/dist/{chunk-E4BOPJJV.mjs → chunk-TB3SSIAY.mjs} +3519 -5334
  16. package/dist/chunk-WUWXFMEM.mjs +11 -0
  17. package/dist/full-2GJTAAZE.css +301 -0
  18. package/dist/full-NLUNPJWS.mjs +90 -0
  19. package/dist/index.css +636 -759
  20. package/dist/index.d.mts +204 -21
  21. package/dist/index.d.ts +204 -21
  22. package/dist/index.js +7837 -5145
  23. package/dist/index.mjs +23 -16
  24. package/dist/loaded-EV34KGYJ.mjs +57 -0
  25. package/dist/loaded-HMSPJUZM.mjs +54 -0
  26. package/dist/loaded-RVWBFK7L.css +87 -0
  27. package/dist/loaded-ZXOU6S6R.mjs +54 -0
  28. package/dist/no-external.css +636 -759
  29. package/dist/no-external.d.mts +17 -4
  30. package/dist/no-external.d.ts +17 -4
  31. package/dist/no-external.js +7837 -5145
  32. package/dist/no-external.mjs +23 -16
  33. package/dist/rsc.css +101 -0
  34. package/dist/rsc.d.mts +17 -2
  35. package/dist/rsc.d.ts +17 -2
  36. package/dist/rsc.js +409 -25
  37. package/dist/rsc.mjs +13 -8
  38. package/dist/{actions-CaYAKtsG.d.mts → walk-tree-Ja9bNCM9.d.mts} +235 -23
  39. package/dist/{actions-CaYAKtsG.d.ts → walk-tree-Ja9bNCM9.d.ts} +235 -23
  40. package/package.json +24 -7
  41. package/dist/chunk-J32NOAUF.mjs +0 -524
  42. package/dist/index-C6QwyW4B.d.ts +0 -109
  43. package/dist/index-IMRjDHZk.d.mts +0 -109
  44. package/dist/internal.d.mts +0 -12
  45. package/dist/internal.d.ts +0 -12
  46. package/dist/internal.js +0 -906
  47. package/dist/internal.mjs +0 -12
  48. package/dist/walk-tree-B-Q2gpMX.d.mts +0 -29
  49. package/dist/walk-tree-ksvZ7C4q.d.ts +0 -29
@@ -1,58 +1,24 @@
1
+ import {
2
+ styles_module_default
3
+ } from "./chunk-WUWXFMEM.mjs";
4
+ import {
5
+ defaultAppState,
6
+ mapFields,
7
+ resolveComponentData,
8
+ walkAppState,
9
+ walkTree
10
+ } from "./chunk-DJSH5REF.mjs";
1
11
  import {
2
12
  __async,
3
13
  __objRest,
4
14
  __spreadProps,
5
15
  __spreadValues,
6
- init_react_import,
7
- mapFields,
8
- walkAppState,
9
- walkTree
10
- } from "./chunk-S3RM5GHZ.mjs";
16
+ get_class_name_factory_default,
17
+ init_react_import
18
+ } from "./chunk-DCSQEDMK.mjs";
11
19
 
12
20
  // lib/migrate.ts
13
21
  init_react_import();
14
-
15
- // store/default-app-state.ts
16
- init_react_import();
17
-
18
- // components/ViewportControls/default-viewports.ts
19
- init_react_import();
20
- var defaultViewports = [
21
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
22
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
23
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
24
- { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
25
- ];
26
-
27
- // store/default-app-state.ts
28
- var defaultAppState = {
29
- data: { content: [], root: {}, zones: {} },
30
- ui: {
31
- leftSideBarVisible: true,
32
- rightSideBarVisible: true,
33
- arrayState: {},
34
- itemSelector: null,
35
- componentList: {},
36
- isDragging: false,
37
- previewMode: "edit",
38
- viewports: {
39
- current: {
40
- width: defaultViewports[0].width,
41
- height: defaultViewports[0].height || "auto"
42
- },
43
- options: [],
44
- controlsVisible: true
45
- },
46
- field: { focus: null },
47
- plugin: { current: null }
48
- },
49
- indexes: {
50
- nodes: {},
51
- zones: {}
52
- }
53
- };
54
-
55
- // lib/migrate.ts
56
22
  var migrations = [
57
23
  // Migrate root to root.props
58
24
  (data) => {
@@ -216,86 +182,6 @@ function transformProps(data, propTransforms, config = { components: {} }) {
216
182
  // lib/resolve-all-data.ts
217
183
  init_react_import();
218
184
 
219
- // lib/resolve-component-data.ts
220
- init_react_import();
221
-
222
- // lib/get-changed.ts
223
- init_react_import();
224
- import { deepEqual } from "fast-equals";
225
- var getChanged = (newItem, oldItem) => {
226
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
227
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
228
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
229
- return __spreadProps(__spreadValues({}, acc), {
230
- [item]: !deepEqual(oldItemProps[item], newItemProps[item])
231
- });
232
- }, {}) : {};
233
- };
234
-
235
- // lib/resolve-component-data.ts
236
- import { deepEqual as deepEqual2 } from "fast-equals";
237
- var cache = { lastChange: {} };
238
- var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
239
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
240
- const resolvedItem = __spreadValues({}, item);
241
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
242
- const id = "id" in item.props ? item.props.id : "root";
243
- if (shouldRunResolver) {
244
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
245
- if (trigger !== "force" && item && deepEqual2(item, oldItem)) {
246
- return { node: resolved, didChange: false };
247
- }
248
- const changed = getChanged(item, oldItem);
249
- if (onResolveStart) {
250
- onResolveStart(item);
251
- }
252
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
253
- changed,
254
- lastData: oldItem,
255
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
256
- trigger
257
- });
258
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
259
- if (Object.keys(readOnly).length) {
260
- resolvedItem.readOnly = readOnly;
261
- }
262
- }
263
- let itemWithResolvedChildren = yield mapFields(
264
- resolvedItem,
265
- {
266
- slot: (_02) => __async(null, [_02], function* ({ value }) {
267
- const content = value;
268
- return yield Promise.all(
269
- content.map(
270
- (childItem) => __async(null, null, function* () {
271
- return (yield resolveComponentData(
272
- childItem,
273
- config,
274
- metadata,
275
- onResolveStart,
276
- onResolveEnd,
277
- trigger
278
- )).node;
279
- })
280
- )
281
- );
282
- })
283
- },
284
- config
285
- );
286
- if (shouldRunResolver && onResolveEnd) {
287
- onResolveEnd(resolvedItem);
288
- }
289
- cache.lastChange[id] = {
290
- item,
291
- resolved: itemWithResolvedChildren
292
- };
293
- return {
294
- node: itemWithResolvedChildren,
295
- didChange: !deepEqual2(item, itemWithResolvedChildren)
296
- };
297
- });
298
-
299
185
  // lib/data/to-component.ts
300
186
  init_react_import();
301
187
  var toComponent = (item) => {
@@ -419,21 +305,75 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
419
305
  );
420
306
  }
421
307
 
308
+ // components/RichTextEditor/lib/use-richtext-props.tsx
309
+ init_react_import();
310
+ import { lazy, Suspense, useMemo as useMemo2 } from "react";
311
+
312
+ // components/RichTextEditor/components/RenderFallback.tsx
313
+ init_react_import();
314
+ import { jsx } from "react/jsx-runtime";
315
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
316
+ function RichTextRenderFallback({ content }) {
317
+ return /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx(
318
+ "div",
319
+ {
320
+ className: "rich-text",
321
+ dangerouslySetInnerHTML: { __html: content }
322
+ }
323
+ ) });
324
+ }
325
+
326
+ // components/RichTextEditor/lib/use-richtext-props.tsx
327
+ import { jsx as jsx2 } from "react/jsx-runtime";
328
+ function useRichtextProps(fields, props) {
329
+ const findAllRichtextKeys = (fields2) => {
330
+ if (!fields2) return [];
331
+ const result = [];
332
+ for (const [key, field] of Object.entries(fields2)) {
333
+ if (field.type === "richtext") {
334
+ result.push(key);
335
+ }
336
+ }
337
+ return result;
338
+ };
339
+ const richtextKeys = useMemo2(() => findAllRichtextKeys(fields), [fields]);
340
+ const richtextProps = useMemo2(() => {
341
+ if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
342
+ const RichTextRender = lazy(
343
+ () => import("./Render-Y567PGZ7.mjs").then((m) => ({
344
+ default: m.RichTextRender
345
+ }))
346
+ );
347
+ return richtextKeys.reduce((acc, key) => {
348
+ acc[key] = /* @__PURE__ */ jsx2(Suspense, { fallback: /* @__PURE__ */ jsx2(RichTextRenderFallback, { content: props[key] }), children: /* @__PURE__ */ jsx2(
349
+ RichTextRender,
350
+ {
351
+ content: props[key],
352
+ field: fields[key]
353
+ }
354
+ ) });
355
+ return acc;
356
+ }, {});
357
+ }, [richtextKeys, props, fields]);
358
+ return richtextProps;
359
+ }
360
+
422
361
  // components/SlotRender/server.tsx
423
362
  init_react_import();
424
363
  import { forwardRef } from "react";
425
- import { jsx } from "react/jsx-runtime";
426
- var SlotRenderPure = (props) => /* @__PURE__ */ jsx(SlotRender, __spreadValues({}, props));
364
+ import { jsx as jsx3 } from "react/jsx-runtime";
365
+ var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, __spreadValues({}, props));
427
366
  var Item = ({
428
367
  config,
429
368
  item,
430
369
  metadata
431
370
  }) => {
432
371
  const Component = config.components[item.type];
433
- const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
434
- return /* @__PURE__ */ jsx(
372
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx3(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
373
+ const richtextProps = useRichtextProps(Component.fields, props);
374
+ return /* @__PURE__ */ jsx3(
435
375
  Component.render,
436
- __spreadProps(__spreadValues({}, props), {
376
+ __spreadProps(__spreadValues(__spreadValues({}, props), richtextProps), {
437
377
  puck: __spreadProps(__spreadValues({}, props.puck), {
438
378
  metadata: metadata || {}
439
379
  })
@@ -443,11 +383,11 @@ var Item = ({
443
383
  var SlotRender = forwardRef(
444
384
  function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
445
385
  const El = as != null ? as : "div";
446
- return /* @__PURE__ */ jsx(El, { className, style, ref, children: content.map((item) => {
386
+ return /* @__PURE__ */ jsx3(El, { className, style, ref, children: content.map((item) => {
447
387
  if (!config.components[item.type]) {
448
388
  return null;
449
389
  }
450
- return /* @__PURE__ */ jsx(
390
+ return /* @__PURE__ */ jsx3(
451
391
  Item,
452
392
  {
453
393
  config,
@@ -461,13 +401,11 @@ var SlotRender = forwardRef(
461
401
  );
462
402
 
463
403
  export {
464
- defaultViewports,
465
- getChanged,
466
- resolveComponentData,
467
- defaultAppState,
468
404
  useFieldTransforms,
469
405
  getSlotTransform,
470
406
  useSlots,
407
+ RichTextRenderFallback,
408
+ useRichtextProps,
471
409
  SlotRenderPure,
472
410
  SlotRender,
473
411
  toComponent,
@@ -0,0 +1,194 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ var __esm = (fn, res) => function __init() {
37
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
38
+ };
39
+ var __commonJS = (cb, mod) => function __require() {
40
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
41
+ };
42
+ var __copyProps = (to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames(from))
45
+ if (!__hasOwnProp.call(to, key) && key !== except)
46
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ };
50
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
+ // If the importer is in node compatibility mode or this is not an ESM
52
+ // file that has been converted to a CommonJS file using a Babel-
53
+ // compatible transform (i.e. "__esModule" has not been set), then set
54
+ // "default" to the CommonJS "module.exports" for node compatibility.
55
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
+ mod
57
+ ));
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
78
+
79
+ // ../tsup-config/react-import.js
80
+ import React from "react";
81
+ var init_react_import = __esm({
82
+ "../tsup-config/react-import.js"() {
83
+ "use strict";
84
+ }
85
+ });
86
+
87
+ // ../../node_modules/classnames/index.js
88
+ var require_classnames = __commonJS({
89
+ "../../node_modules/classnames/index.js"(exports, module) {
90
+ "use strict";
91
+ init_react_import();
92
+ (function() {
93
+ "use strict";
94
+ var hasOwn = {}.hasOwnProperty;
95
+ function classNames() {
96
+ var classes = "";
97
+ for (var i = 0; i < arguments.length; i++) {
98
+ var arg = arguments[i];
99
+ if (arg) {
100
+ classes = appendClass(classes, parseValue(arg));
101
+ }
102
+ }
103
+ return classes;
104
+ }
105
+ function parseValue(arg) {
106
+ if (typeof arg === "string" || typeof arg === "number") {
107
+ return arg;
108
+ }
109
+ if (typeof arg !== "object") {
110
+ return "";
111
+ }
112
+ if (Array.isArray(arg)) {
113
+ return classNames.apply(null, arg);
114
+ }
115
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
116
+ return arg.toString();
117
+ }
118
+ var classes = "";
119
+ for (var key in arg) {
120
+ if (hasOwn.call(arg, key) && arg[key]) {
121
+ classes = appendClass(classes, key);
122
+ }
123
+ }
124
+ return classes;
125
+ }
126
+ function appendClass(value, newClass) {
127
+ if (!newClass) {
128
+ return value;
129
+ }
130
+ if (value) {
131
+ return value + " " + newClass;
132
+ }
133
+ return value + newClass;
134
+ }
135
+ if (typeof module !== "undefined" && module.exports) {
136
+ classNames.default = classNames;
137
+ module.exports = classNames;
138
+ } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
139
+ define("classnames", [], function() {
140
+ return classNames;
141
+ });
142
+ } else {
143
+ window.classNames = classNames;
144
+ }
145
+ })();
146
+ }
147
+ });
148
+
149
+ // lib/get-class-name-factory.ts
150
+ init_react_import();
151
+ var import_classnames = __toESM(require_classnames());
152
+ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
153
+ if (typeof options === "string") {
154
+ const descendant = options;
155
+ const style = styles[`${rootClass}-${descendant}`];
156
+ if (style) {
157
+ return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
158
+ }
159
+ return "";
160
+ } else if (typeof options === "object") {
161
+ const modifiers = options;
162
+ const prefixedModifiers = {};
163
+ for (let modifier in modifiers) {
164
+ prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
165
+ }
166
+ const c = styles[rootClass];
167
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
168
+ [c]: !!c
169
+ }, prefixedModifiers));
170
+ } else {
171
+ return config.baseClass + styles[rootClass] || "";
172
+ }
173
+ };
174
+ var get_class_name_factory_default = getClassNameFactory;
175
+
176
+ export {
177
+ __spreadValues,
178
+ __spreadProps,
179
+ __objRest,
180
+ __commonJS,
181
+ __toESM,
182
+ __async,
183
+ init_react_import,
184
+ get_class_name_factory_default
185
+ };
186
+ /*! Bundled license information:
187
+
188
+ classnames/index.js:
189
+ (*!
190
+ Copyright (c) 2018 Jed Watson.
191
+ Licensed under the MIT License (MIT), see
192
+ http://jedwatson.github.io/classnames
193
+ *)
194
+ */
@@ -1,88 +1,9 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
- var __esm = (fn, res) => function __init() {
37
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
38
- };
39
- var __commonJS = (cb, mod) => function __require() {
40
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
41
- };
42
- var __copyProps = (to, from, except, desc) => {
43
- if (from && typeof from === "object" || typeof from === "function") {
44
- for (let key of __getOwnPropNames(from))
45
- if (!__hasOwnProp.call(to, key) && key !== except)
46
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
- }
48
- return to;
49
- };
50
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
- // If the importer is in node compatibility mode or this is not an ESM
52
- // file that has been converted to a CommonJS file using a Babel-
53
- // compatible transform (i.e. "__esModule" has not been set), then set
54
- // "default" to the CommonJS "module.exports" for node compatibility.
55
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
- mod
57
- ));
58
- var __async = (__this, __arguments, generator) => {
59
- return new Promise((resolve, reject) => {
60
- var fulfilled = (value) => {
61
- try {
62
- step(generator.next(value));
63
- } catch (e) {
64
- reject(e);
65
- }
66
- };
67
- var rejected = (value) => {
68
- try {
69
- step(generator.throw(value));
70
- } catch (e) {
71
- reject(e);
72
- }
73
- };
74
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
- step((generator = generator.apply(__this, __arguments)).next());
76
- });
77
- };
78
-
79
- // ../tsup-config/react-import.js
80
- import React from "react";
81
- var init_react_import = __esm({
82
- "../tsup-config/react-import.js"() {
83
- "use strict";
84
- }
85
- });
1
+ import {
2
+ __async,
3
+ __spreadProps,
4
+ __spreadValues,
5
+ init_react_import
6
+ } from "./chunk-DCSQEDMK.mjs";
86
7
 
87
8
  // lib/data/walk-tree.ts
88
9
  init_react_import();
@@ -482,14 +403,123 @@ var setupZone = (data, zoneKey) => {
482
403
  return newData;
483
404
  };
484
405
 
406
+ // components/ViewportControls/default-viewports.ts
407
+ init_react_import();
408
+ var defaultViewports = [
409
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
410
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
411
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
412
+ ];
413
+
414
+ // lib/resolve-component-data.ts
415
+ init_react_import();
416
+
417
+ // lib/get-changed.ts
418
+ init_react_import();
419
+ import { deepEqual } from "fast-equals";
420
+ var getChanged = (newItem, oldItem) => {
421
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
422
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
423
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
424
+ return __spreadProps(__spreadValues({}, acc), {
425
+ [item]: !deepEqual(oldItemProps[item], newItemProps[item])
426
+ });
427
+ }, {}) : {};
428
+ };
429
+
430
+ // lib/resolve-component-data.ts
431
+ import { deepEqual as deepEqual2 } from "fast-equals";
432
+ var cache = { lastChange: {} };
433
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
434
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
435
+ const resolvedItem = __spreadValues({}, item);
436
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
437
+ const id = "id" in item.props ? item.props.id : "root";
438
+ if (shouldRunResolver) {
439
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
440
+ if (trigger !== "force" && item && deepEqual2(item, oldItem)) {
441
+ return { node: resolved, didChange: false };
442
+ }
443
+ const changed = getChanged(item, oldItem);
444
+ if (onResolveStart) {
445
+ onResolveStart(item);
446
+ }
447
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
448
+ changed,
449
+ lastData: oldItem,
450
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
451
+ trigger
452
+ });
453
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
454
+ if (Object.keys(readOnly).length) {
455
+ resolvedItem.readOnly = readOnly;
456
+ }
457
+ }
458
+ let itemWithResolvedChildren = yield mapFields(
459
+ resolvedItem,
460
+ {
461
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
462
+ const content = value;
463
+ return yield Promise.all(
464
+ content.map(
465
+ (childItem) => __async(null, null, function* () {
466
+ return (yield resolveComponentData(
467
+ childItem,
468
+ config,
469
+ metadata,
470
+ onResolveStart,
471
+ onResolveEnd,
472
+ trigger
473
+ )).node;
474
+ })
475
+ )
476
+ );
477
+ })
478
+ },
479
+ config
480
+ );
481
+ if (shouldRunResolver && onResolveEnd) {
482
+ onResolveEnd(resolvedItem);
483
+ }
484
+ cache.lastChange[id] = {
485
+ item,
486
+ resolved: itemWithResolvedChildren
487
+ };
488
+ return {
489
+ node: itemWithResolvedChildren,
490
+ didChange: !deepEqual2(item, itemWithResolvedChildren)
491
+ };
492
+ });
493
+
494
+ // store/default-app-state.ts
495
+ init_react_import();
496
+ var defaultAppState = {
497
+ data: { content: [], root: {}, zones: {} },
498
+ ui: {
499
+ leftSideBarVisible: true,
500
+ rightSideBarVisible: true,
501
+ arrayState: {},
502
+ itemSelector: null,
503
+ componentList: {},
504
+ isDragging: false,
505
+ previewMode: "edit",
506
+ viewports: {
507
+ current: {
508
+ width: defaultViewports[0].width,
509
+ height: defaultViewports[0].height || "auto"
510
+ },
511
+ options: [],
512
+ controlsVisible: true
513
+ },
514
+ field: { focus: null }
515
+ },
516
+ indexes: {
517
+ nodes: {},
518
+ zones: {}
519
+ }
520
+ };
521
+
485
522
  export {
486
- __spreadValues,
487
- __spreadProps,
488
- __objRest,
489
- __commonJS,
490
- __toESM,
491
- __async,
492
- init_react_import,
493
523
  rootAreaId,
494
524
  rootZone,
495
525
  rootDroppableId,
@@ -499,5 +529,9 @@ export {
499
529
  expandNode,
500
530
  walkAppState,
501
531
  walkTree,
502
- setupZone
532
+ setupZone,
533
+ defaultViewports,
534
+ getChanged,
535
+ resolveComponentData,
536
+ defaultAppState
503
537
  };