@measured/puck-plugin-heading-analyzer 0.20.0-canary.3da831b0 → 0.20.0-canary.5cc56415

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -310,12 +310,12 @@ var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v
310
310
  // src/HeadingAnalyzer.tsx
311
311
  import { createUsePuck } from "@measured/puck";
312
312
 
313
- // ../core/components/SidebarSection/index.tsx
313
+ // ../core/components/OutlineList/index.tsx
314
314
  init_react_import();
315
315
 
316
- // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
316
+ // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
317
317
  init_react_import();
318
- var styles_module_default = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
318
+ var styles_module_default = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
319
319
 
320
320
  // ../core/lib/get-class-name-factory.ts
321
321
  init_react_import();
@@ -344,29 +344,50 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
344
344
  };
345
345
  var get_class_name_factory_default = getClassNameFactory;
346
346
 
347
- // ../core/components/Heading/index.tsx
348
- init_react_import();
349
-
350
- // css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
351
- init_react_import();
352
- var styles_module_default2 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
353
-
354
- // ../core/components/Heading/index.tsx
347
+ // ../core/components/OutlineList/index.tsx
355
348
  import { jsx } from "react/jsx-runtime";
356
- var getClassName = get_class_name_factory_default("Heading", styles_module_default2);
357
- var Heading = ({ children, rank, size = "m" }) => {
358
- const Tag = rank ? `h${rank}` : "span";
349
+ var getClassName = get_class_name_factory_default("OutlineList", styles_module_default);
350
+ var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default);
351
+ var OutlineList = ({ children }) => {
352
+ return /* @__PURE__ */ jsx("ul", { className: getClassName(), children });
353
+ };
354
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassNameItem({ clickable: true }), children });
355
+ OutlineList.Item = ({
356
+ children,
357
+ onClick
358
+ }) => {
359
359
  return /* @__PURE__ */ jsx(
360
- Tag,
360
+ "li",
361
361
  {
362
- className: getClassName({
363
- [size]: true
364
- }),
362
+ className: getClassNameItem({ clickable: !!onClick }),
363
+ onClick,
365
364
  children
366
365
  }
367
366
  );
368
367
  };
369
368
 
369
+ // ../core/lib/scroll-into-view.ts
370
+ init_react_import();
371
+ var scrollIntoView = (el) => {
372
+ const oldStyle = __spreadValues({}, el.style);
373
+ el.style.scrollMargin = "256px";
374
+ if (el) {
375
+ el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
376
+ el.style.scrollMargin = oldStyle.scrollMargin || "";
377
+ }
378
+ };
379
+
380
+ // ../core/lib/get-frame.ts
381
+ init_react_import();
382
+ var getFrame = () => {
383
+ if (typeof window === "undefined") return;
384
+ let frameEl = document.querySelector("#preview-frame");
385
+ if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
386
+ return frameEl.contentDocument || document;
387
+ }
388
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
389
+ };
390
+
370
391
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
371
392
  init_react_import();
372
393
 
@@ -454,15 +475,30 @@ var createLucideIcon = (iconName, iconNode) => {
454
475
  return Component;
455
476
  };
456
477
 
457
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
478
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
458
479
  init_react_import();
459
- var ChevronRight = createLucideIcon("ChevronRight", [
460
- ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
480
+ var Heading1 = createLucideIcon("Heading1", [
481
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
482
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
483
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
484
+ ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
461
485
  ]);
462
486
 
463
- // ../core/lib/use-breadcrumbs.ts
487
+ // ../core/lib/index.ts
488
+ init_react_import();
489
+
490
+ // ../core/lib/filter.ts
464
491
  init_react_import();
465
- import { useMemo as useMemo2 } from "react";
492
+
493
+ // ../core/lib/data/reorder.ts
494
+ init_react_import();
495
+
496
+ // ../core/lib/data/replace.ts
497
+ init_react_import();
498
+
499
+ // ../core/lib/use-reset-auto-zoom.ts
500
+ init_react_import();
501
+ import { useCallback as useCallback2 } from "react";
466
502
 
467
503
  // ../core/store/index.ts
468
504
  init_react_import();
@@ -509,7 +545,7 @@ function forRelatedZones(item, data, cb, path = []) {
509
545
  });
510
546
  }
511
547
 
512
- // ../core/lib/data/map-slots.ts
548
+ // ../core/lib/data/map-fields.ts
513
549
  init_react_import();
514
550
 
515
551
  // ../core/lib/data/default-slots.ts
@@ -519,14 +555,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
519
555
  value
520
556
  );
521
557
 
522
- // ../core/lib/data/map-slots.ts
558
+ // ../core/lib/data/map-fields.ts
523
559
  var isPromise = (v) => !!v && typeof v.then === "function";
524
560
  var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
525
561
  var containsPromise = (arr) => arr.some(isPromise);
526
562
  var walkField = ({
527
563
  value,
528
564
  fields,
529
- map,
565
+ mappers,
530
566
  propKey = "",
531
567
  propPath = "",
532
568
  id = "",
@@ -534,7 +570,9 @@ var walkField = ({
534
570
  recurseSlots = false
535
571
  }) => {
536
572
  var _a, _b, _c;
537
- if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
573
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
574
+ const map = mappers[fieldType];
575
+ if (map && fieldType === "slot") {
538
576
  const content = value || [];
539
577
  const mappedContent = recurseSlots ? content.map((el) => {
540
578
  var _a2;
@@ -546,7 +584,7 @@ var walkField = ({
546
584
  return walkField({
547
585
  value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
548
586
  fields: fields2,
549
- map,
587
+ mappers,
550
588
  id: el.props.id,
551
589
  config,
552
590
  recurseSlots
@@ -555,7 +593,21 @@ var walkField = ({
555
593
  if (containsPromise(mappedContent)) {
556
594
  return Promise.all(mappedContent);
557
595
  }
558
- return map(mappedContent, id, propPath, fields[propKey], propPath);
596
+ return map({
597
+ value: mappedContent,
598
+ parentId: id,
599
+ propName: propKey,
600
+ field: fields[propKey],
601
+ propPath
602
+ });
603
+ } else if (map && fields[propKey]) {
604
+ return map({
605
+ value,
606
+ parentId: id,
607
+ propName: propKey,
608
+ field: fields[propKey],
609
+ propPath
610
+ });
559
611
  }
560
612
  if (value && typeof value === "object") {
561
613
  if (Array.isArray(value)) {
@@ -565,7 +617,7 @@ var walkField = ({
565
617
  (el, idx) => walkField({
566
618
  value: el,
567
619
  fields: arrayFields,
568
- map,
620
+ mappers,
569
621
  propKey,
570
622
  propPath: `${propPath}[${idx}]`,
571
623
  id,
@@ -584,7 +636,7 @@ var walkField = ({
584
636
  return walkObject({
585
637
  value,
586
638
  fields: objectFields,
587
- map,
639
+ mappers,
588
640
  id,
589
641
  getPropPath: (k) => `${propPath}.${k}`,
590
642
  config,
@@ -597,7 +649,7 @@ var walkField = ({
597
649
  var walkObject = ({
598
650
  value,
599
651
  fields,
600
- map,
652
+ mappers,
601
653
  id,
602
654
  getPropPath,
603
655
  config,
@@ -607,7 +659,7 @@ var walkObject = ({
607
659
  const opts = {
608
660
  value: v,
609
661
  fields,
610
- map,
662
+ mappers,
611
663
  propKey: k,
612
664
  propPath: getPropPath(k),
613
665
  id,
@@ -629,14 +681,14 @@ var walkObject = ({
629
681
  }
630
682
  return flatten(newProps);
631
683
  };
632
- function mapSlots(item, map, config, recurseSlots = false) {
684
+ function mapFields(item, mappers, config, recurseSlots = false) {
633
685
  var _a, _b, _c, _d, _e;
634
686
  const itemType = "type" in item ? item.type : "root";
635
687
  const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
636
688
  const newProps = walkObject({
637
689
  value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
638
690
  fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
639
- map,
691
+ mappers,
640
692
  id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
641
693
  getPropPath: (k) => k,
642
694
  config,
@@ -659,7 +711,7 @@ var import_flat = __toESM(require_flat());
659
711
  // ../core/lib/data/strip-slots.ts
660
712
  init_react_import();
661
713
  var stripSlots = (data, config) => {
662
- return mapSlots(data, () => null, config);
714
+ return mapFields(data, { slot: () => null }, config);
663
715
  };
664
716
 
665
717
  // ../core/lib/data/flatten-node.ts
@@ -712,18 +764,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
712
764
  const mappedItem = mapNodeOrSkip(item, path, index);
713
765
  if (!mappedItem) return item;
714
766
  const id = mappedItem.props.id;
715
- const newProps = __spreadProps(__spreadValues({}, mapSlots(
767
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
716
768
  mappedItem,
717
- (content, parentId2, slotId) => {
718
- const zoneCompound = `${parentId2}:${slotId}`;
719
- const [_2, newContent2] = processContent(
720
- path,
721
- zoneCompound,
722
- content,
723
- "slot",
724
- parentId2
725
- );
726
- return newContent2;
769
+ {
770
+ slot: ({ value, parentId: parentId2, propPath }) => {
771
+ const content = value;
772
+ const zoneCompound = `${parentId2}:${propPath}`;
773
+ const [_2, newContent2] = processContent(
774
+ path,
775
+ zoneCompound,
776
+ content,
777
+ "slot",
778
+ parentId2
779
+ );
780
+ return newContent2;
781
+ }
727
782
  },
728
783
  config
729
784
  ).props), {
@@ -898,11 +953,14 @@ init_react_import();
898
953
  function walkTree(data, config, callbackFn) {
899
954
  var _a, _b;
900
955
  const walkItem = (item) => {
901
- return mapSlots(
956
+ return mapFields(
902
957
  item,
903
- (content, parentId, propName) => {
904
- var _a2;
905
- return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
958
+ {
959
+ slot: ({ value, parentId, propName }) => {
960
+ var _a2;
961
+ const content = value;
962
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
963
+ }
906
964
  },
907
965
  config,
908
966
  true
@@ -988,275 +1046,6 @@ function insertAction(state, action, appStore) {
988
1046
 
989
1047
  // ../core/reducer/actions/replace.ts
990
1048
  init_react_import();
991
-
992
- // ../core/rsc.tsx
993
- init_react_import();
994
-
995
- // ../core/components/ServerRender/index.tsx
996
- init_react_import();
997
-
998
- // ../core/lib/data/setup-zone.ts
999
- init_react_import();
1000
- var setupZone = (data, zoneKey) => {
1001
- if (zoneKey === rootDroppableId) {
1002
- return data;
1003
- }
1004
- const newData = __spreadProps(__spreadValues({}, data), {
1005
- zones: data.zones ? __spreadValues({}, data.zones) : {}
1006
- });
1007
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1008
- return newData;
1009
- };
1010
-
1011
- // ../core/lib/use-slots.tsx
1012
- init_react_import();
1013
- import { useMemo } from "react";
1014
- function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
1015
- const slotProps = useMemo(() => {
1016
- const mapped = mapSlots(
1017
- item,
1018
- (content, _parentId, propName, field, propPath) => {
1019
- const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
1020
- const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
1021
- const render = isReadOnly ? renderSlotRender : renderSlotEdit;
1022
- const Slot = (dzProps) => render(__spreadProps(__spreadValues({
1023
- allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
1024
- disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
1025
- }, dzProps), {
1026
- zone: propName,
1027
- content
1028
- }));
1029
- return Slot;
1030
- },
1031
- config
1032
- ).props;
1033
- return mapped;
1034
- }, [config, item, readOnly, forceReadOnly]);
1035
- const mergedProps = useMemo(
1036
- () => __spreadValues(__spreadValues({}, item.props), slotProps),
1037
- [item.props, slotProps]
1038
- );
1039
- return mergedProps;
1040
- }
1041
-
1042
- // ../core/components/SlotRender/server.tsx
1043
- init_react_import();
1044
- import { forwardRef as forwardRef3 } from "react";
1045
- import { jsx as jsx2 } from "react/jsx-runtime";
1046
- var SlotRenderPure = (props) => /* @__PURE__ */ jsx2(SlotRender, __spreadValues({}, props));
1047
- var Item = ({
1048
- config,
1049
- item,
1050
- metadata
1051
- }) => {
1052
- const Component = config.components[item.type];
1053
- const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx2(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
1054
- return /* @__PURE__ */ jsx2(
1055
- Component.render,
1056
- __spreadProps(__spreadValues({}, props), {
1057
- puck: __spreadProps(__spreadValues({}, props.puck), {
1058
- renderDropZone: DropZoneRender,
1059
- metadata: metadata || {}
1060
- })
1061
- })
1062
- );
1063
- };
1064
- var SlotRender = forwardRef3(
1065
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
1066
- return /* @__PURE__ */ jsx2("div", { className, style, ref, children: content.map((item) => {
1067
- if (!config.components[item.type]) {
1068
- return null;
1069
- }
1070
- return /* @__PURE__ */ jsx2(
1071
- Item,
1072
- {
1073
- config,
1074
- item,
1075
- metadata
1076
- },
1077
- item.props.id
1078
- );
1079
- }) });
1080
- }
1081
- );
1082
-
1083
- // ../core/components/ServerRender/index.tsx
1084
- import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
1085
- function DropZoneRender({
1086
- zone,
1087
- data,
1088
- areaId = "root",
1089
- config,
1090
- metadata = {}
1091
- }) {
1092
- let zoneCompound = rootDroppableId;
1093
- let content = (data == null ? void 0 : data.content) || [];
1094
- if (!data || !config) {
1095
- return null;
1096
- }
1097
- if (areaId !== rootAreaId && zone !== rootZone) {
1098
- zoneCompound = `${areaId}:${zone}`;
1099
- content = setupZone(data, zoneCompound).zones[zoneCompound];
1100
- }
1101
- return /* @__PURE__ */ jsx3(Fragment, { children: content.map((item) => {
1102
- const Component = config.components[item.type];
1103
- const props = __spreadProps(__spreadValues({}, item.props), {
1104
- puck: {
1105
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ jsx3(
1106
- DropZoneRender,
1107
- {
1108
- zone: zone2,
1109
- data,
1110
- areaId: item.props.id,
1111
- config,
1112
- metadata
1113
- }
1114
- ),
1115
- metadata,
1116
- dragRef: null,
1117
- isEditing: false
1118
- }
1119
- });
1120
- const renderItem = __spreadProps(__spreadValues({}, item), { props });
1121
- const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ jsx3(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
1122
- if (Component) {
1123
- return /* @__PURE__ */ jsx3(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
1124
- }
1125
- return null;
1126
- }) });
1127
- }
1128
-
1129
- // ../core/lib/resolve-all-data.ts
1130
- init_react_import();
1131
-
1132
- // ../core/lib/resolve-component-data.ts
1133
- init_react_import();
1134
-
1135
- // ../core/lib/get-changed.ts
1136
- init_react_import();
1137
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1138
- var getChanged = (newItem, oldItem) => {
1139
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1140
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1141
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1142
- return __spreadProps(__spreadValues({}, acc), {
1143
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1144
- });
1145
- }, {}) : {};
1146
- };
1147
-
1148
- // ../core/lib/resolve-component-data.ts
1149
- var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1150
- var cache = { lastChange: {} };
1151
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1152
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1153
- const resolvedItem = __spreadValues({}, item);
1154
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1155
- const id = "id" in item.props ? item.props.id : "root";
1156
- if (shouldRunResolver) {
1157
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1158
- if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1159
- return { node: resolved, didChange: false };
1160
- }
1161
- const changed = getChanged(item, oldItem);
1162
- if (onResolveStart) {
1163
- onResolveStart(item);
1164
- }
1165
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1166
- changed,
1167
- lastData: oldItem,
1168
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1169
- trigger
1170
- });
1171
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1172
- if (Object.keys(readOnly).length) {
1173
- resolvedItem.readOnly = readOnly;
1174
- }
1175
- }
1176
- let itemWithResolvedChildren = yield mapSlots(
1177
- resolvedItem,
1178
- (content) => __async(void 0, null, function* () {
1179
- return yield Promise.all(
1180
- content.map(
1181
- (childItem) => __async(void 0, null, function* () {
1182
- return (yield resolveComponentData(
1183
- childItem,
1184
- config,
1185
- metadata,
1186
- onResolveStart,
1187
- onResolveEnd,
1188
- trigger
1189
- )).node;
1190
- })
1191
- )
1192
- );
1193
- }),
1194
- config
1195
- );
1196
- if (shouldRunResolver && onResolveEnd) {
1197
- onResolveEnd(resolvedItem);
1198
- }
1199
- cache.lastChange[id] = {
1200
- item,
1201
- resolved: itemWithResolvedChildren
1202
- };
1203
- return {
1204
- node: itemWithResolvedChildren,
1205
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1206
- };
1207
- });
1208
-
1209
- // ../core/lib/data/default-data.ts
1210
- init_react_import();
1211
-
1212
- // ../core/lib/data/to-component.ts
1213
- init_react_import();
1214
-
1215
- // ../core/lib/transform-props.ts
1216
- init_react_import();
1217
-
1218
- // ../core/lib/migrate.ts
1219
- init_react_import();
1220
-
1221
- // ../core/store/default-app-state.ts
1222
- init_react_import();
1223
-
1224
- // ../core/components/ViewportControls/default-viewports.ts
1225
- init_react_import();
1226
- var defaultViewports = [
1227
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1228
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1229
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1230
- ];
1231
-
1232
- // ../core/store/default-app-state.ts
1233
- var defaultAppState = {
1234
- data: { content: [], root: {}, zones: {} },
1235
- ui: {
1236
- leftSideBarVisible: true,
1237
- rightSideBarVisible: true,
1238
- arrayState: {},
1239
- itemSelector: null,
1240
- componentList: {},
1241
- isDragging: false,
1242
- previewMode: "edit",
1243
- viewports: {
1244
- current: {
1245
- width: defaultViewports[0].width,
1246
- height: defaultViewports[0].height || "auto"
1247
- },
1248
- options: [],
1249
- controlsVisible: true
1250
- },
1251
- field: { focus: null }
1252
- },
1253
- indexes: {
1254
- nodes: {},
1255
- zones: {}
1256
- }
1257
- };
1258
-
1259
- // ../core/reducer/actions/replace.ts
1260
1049
  var replaceAction = (state, action, appStore) => {
1261
1050
  const [parentId] = action.destinationZone.split(":");
1262
1051
  const idsInPath = getIdsForParent(action.destinationZone, state);
@@ -1507,6 +1296,21 @@ var removeAction = (state, action, appStore) => {
1507
1296
 
1508
1297
  // ../core/reducer/actions/register-zone.ts
1509
1298
  init_react_import();
1299
+
1300
+ // ../core/lib/data/setup-zone.ts
1301
+ init_react_import();
1302
+ var setupZone = (data, zoneKey) => {
1303
+ if (zoneKey === rootDroppableId) {
1304
+ return data;
1305
+ }
1306
+ const newData = __spreadProps(__spreadValues({}, data), {
1307
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1308
+ });
1309
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1310
+ return newData;
1311
+ };
1312
+
1313
+ // ../core/reducer/actions/register-zone.ts
1510
1314
  var zoneCache = {};
1511
1315
  function registerZoneAction(state, action) {
1512
1316
  if (zoneCache[action.zone]) {
@@ -1659,6 +1463,14 @@ function createReducer({
1659
1463
  );
1660
1464
  }
1661
1465
 
1466
+ // ../core/components/ViewportControls/default-viewports.ts
1467
+ init_react_import();
1468
+ var defaultViewports = [
1469
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1470
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1471
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1472
+ ];
1473
+
1662
1474
  // ../../node_modules/zustand/esm/vanilla.mjs
1663
1475
  init_react_import();
1664
1476
  var createStoreImpl = (createState) => {
@@ -1908,6 +1720,19 @@ var flattenData = (state, config) => {
1908
1720
  return data;
1909
1721
  };
1910
1722
 
1723
+ // ../core/lib/get-changed.ts
1724
+ init_react_import();
1725
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1726
+ var getChanged = (newItem, oldItem) => {
1727
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1728
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1729
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1730
+ return __spreadProps(__spreadValues({}, acc), {
1731
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1732
+ });
1733
+ }, {}) : {};
1734
+ };
1735
+
1911
1736
  // ../core/store/slices/permissions.ts
1912
1737
  var createPermissionsSlice = (set, get) => {
1913
1738
  const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
@@ -2026,6 +1851,71 @@ var createFieldsSlice = (_set, _get) => {
2026
1851
  };
2027
1852
  };
2028
1853
 
1854
+ // ../core/lib/resolve-component-data.ts
1855
+ init_react_import();
1856
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1857
+ var cache = { lastChange: {} };
1858
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1859
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1860
+ const resolvedItem = __spreadValues({}, item);
1861
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1862
+ const id = "id" in item.props ? item.props.id : "root";
1863
+ if (shouldRunResolver) {
1864
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1865
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1866
+ return { node: resolved, didChange: false };
1867
+ }
1868
+ const changed = getChanged(item, oldItem);
1869
+ if (onResolveStart) {
1870
+ onResolveStart(item);
1871
+ }
1872
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1873
+ changed,
1874
+ lastData: oldItem,
1875
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1876
+ trigger
1877
+ });
1878
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1879
+ if (Object.keys(readOnly).length) {
1880
+ resolvedItem.readOnly = readOnly;
1881
+ }
1882
+ }
1883
+ let itemWithResolvedChildren = yield mapFields(
1884
+ resolvedItem,
1885
+ {
1886
+ slot: (_02) => __async(void 0, [_02], function* ({ value }) {
1887
+ const content = value;
1888
+ return yield Promise.all(
1889
+ content.map(
1890
+ (childItem) => __async(void 0, null, function* () {
1891
+ return (yield resolveComponentData(
1892
+ childItem,
1893
+ config,
1894
+ metadata,
1895
+ onResolveStart,
1896
+ onResolveEnd,
1897
+ trigger
1898
+ )).node;
1899
+ })
1900
+ )
1901
+ );
1902
+ })
1903
+ },
1904
+ config
1905
+ );
1906
+ if (shouldRunResolver && onResolveEnd) {
1907
+ onResolveEnd(resolvedItem);
1908
+ }
1909
+ cache.lastChange[id] = {
1910
+ item,
1911
+ resolved: itemWithResolvedChildren
1912
+ };
1913
+ return {
1914
+ node: itemWithResolvedChildren,
1915
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1916
+ };
1917
+ });
1918
+
2029
1919
  // ../core/lib/data/to-root.ts
2030
1920
  init_react_import();
2031
1921
  var toRoot = (item) => {
@@ -2043,6 +1933,34 @@ var toRoot = (item) => {
2043
1933
  return { props: {}, readOnly };
2044
1934
  };
2045
1935
 
1936
+ // ../core/store/default-app-state.ts
1937
+ init_react_import();
1938
+ var defaultAppState = {
1939
+ data: { content: [], root: {}, zones: {} },
1940
+ ui: {
1941
+ leftSideBarVisible: true,
1942
+ rightSideBarVisible: true,
1943
+ arrayState: {},
1944
+ itemSelector: null,
1945
+ componentList: {},
1946
+ isDragging: false,
1947
+ previewMode: "edit",
1948
+ viewports: {
1949
+ current: {
1950
+ width: defaultViewports[0].width,
1951
+ height: defaultViewports[0].height || "auto"
1952
+ },
1953
+ options: [],
1954
+ controlsVisible: true
1955
+ },
1956
+ field: { focus: null }
1957
+ },
1958
+ indexes: {
1959
+ nodes: {},
1960
+ zones: {}
1961
+ }
1962
+ };
1963
+
2046
1964
  // ../core/store/index.ts
2047
1965
  var defaultPageFields = {
2048
1966
  title: { type: "text" }
@@ -2064,7 +1982,8 @@ var createAppStore = (initialAppStore) => create()(
2064
1982
  },
2065
1983
  status: "LOADING",
2066
1984
  iframe: {},
2067
- metadata: {}
1985
+ metadata: {},
1986
+ fieldTransforms: {}
2068
1987
  }, initialAppStore), {
2069
1988
  fields: createFieldsSlice(set, get),
2070
1989
  history: createHistorySlice(set, get),
@@ -2220,197 +2139,14 @@ var createAppStore = (initialAppStore) => create()(
2220
2139
  })
2221
2140
  );
2222
2141
  var appStoreContext = createContext(createAppStore());
2223
- function useAppStore(selector) {
2224
- const context = useContext(appStoreContext);
2225
- return useStore(context, selector);
2226
- }
2227
- function useAppStoreApi() {
2228
- return useContext(appStoreContext);
2229
- }
2230
2142
 
2231
- // ../core/lib/use-breadcrumbs.ts
2232
- var useBreadcrumbs = (renderCount) => {
2233
- const selectedId = useAppStore((s) => {
2234
- var _a;
2235
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
2236
- });
2237
- const config = useAppStore((s) => s.config);
2238
- const path = useAppStore((s) => {
2239
- var _a;
2240
- return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
2241
- });
2242
- const appStore = useAppStoreApi();
2243
- return useMemo2(() => {
2244
- const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
2245
- var _a, _b, _c;
2246
- const [componentId] = zoneCompound.split(":");
2247
- if (componentId === "root") {
2248
- return {
2249
- label: "Page",
2250
- selector: null
2251
- };
2252
- }
2253
- const node = appStore.getState().state.indexes.nodes[componentId];
2254
- const parentId = node.path[node.path.length - 1];
2255
- const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
2256
- const index = contentIds.indexOf(componentId);
2257
- const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
2258
- return {
2259
- label,
2260
- selector: node ? {
2261
- index,
2262
- zone: node.path[node.path.length - 1]
2263
- } : null
2264
- };
2265
- })) || [];
2266
- if (renderCount) {
2267
- return breadcrumbs.slice(breadcrumbs.length - renderCount);
2268
- }
2269
- return breadcrumbs;
2270
- }, [path, renderCount]);
2271
- };
2272
-
2273
- // ../core/components/Loader/index.tsx
2274
- init_react_import();
2275
-
2276
- // ../core/lib/index.ts
2277
- init_react_import();
2278
-
2279
- // ../core/lib/filter.ts
2280
- init_react_import();
2281
-
2282
- // ../core/lib/data/reorder.ts
2143
+ // ../core/lib/get-zoom-config.ts
2283
2144
  init_react_import();
2284
2145
 
2285
- // ../core/lib/data/replace.ts
2286
- init_react_import();
2287
-
2288
- // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
2289
- init_react_import();
2290
- var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
2291
-
2292
- // ../core/components/Loader/index.tsx
2293
- import { jsx as jsx4 } from "react/jsx-runtime";
2294
- var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
2295
- var Loader = (_a) => {
2296
- var _b = _a, {
2297
- color,
2298
- size = 16
2299
- } = _b, props = __objRest(_b, [
2300
- "color",
2301
- "size"
2302
- ]);
2303
- return /* @__PURE__ */ jsx4(
2304
- "span",
2305
- __spreadValues({
2306
- className: getClassName2(),
2307
- style: {
2308
- width: size,
2309
- height: size,
2310
- color
2311
- },
2312
- "aria-label": "loading"
2313
- }, props)
2314
- );
2315
- };
2316
-
2317
- // ../core/components/SidebarSection/index.tsx
2318
- import { jsx as jsx5, jsxs } from "react/jsx-runtime";
2319
- var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
2320
- var SidebarSection = ({
2321
- children,
2322
- title,
2323
- background,
2324
- showBreadcrumbs,
2325
- noBorderTop,
2326
- noPadding,
2327
- isLoading
2328
- }) => {
2329
- const setUi = useAppStore((s) => s.setUi);
2330
- const breadcrumbs = useBreadcrumbs(1);
2331
- return /* @__PURE__ */ jsxs(
2332
- "div",
2333
- {
2334
- className: getClassName3({ noBorderTop, noPadding }),
2335
- style: { background },
2336
- children: [
2337
- /* @__PURE__ */ jsx5("div", { className: getClassName3("title"), children: /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumbs"), children: [
2338
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumb"), children: [
2339
- /* @__PURE__ */ jsx5(
2340
- "button",
2341
- {
2342
- type: "button",
2343
- className: getClassName3("breadcrumbLabel"),
2344
- onClick: () => setUi({ itemSelector: breadcrumb.selector }),
2345
- children: breadcrumb.label
2346
- }
2347
- ),
2348
- /* @__PURE__ */ jsx5(ChevronRight, { size: 16 })
2349
- ] }, i)) : null,
2350
- /* @__PURE__ */ jsx5("div", { className: getClassName3("heading"), children: /* @__PURE__ */ jsx5(Heading, { rank: "2", size: "xs", children: title }) })
2351
- ] }) }),
2352
- /* @__PURE__ */ jsx5("div", { className: getClassName3("content"), children }),
2353
- isLoading && /* @__PURE__ */ jsx5("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx5(Loader, { size: 32 }) })
2354
- ]
2355
- }
2356
- );
2357
- };
2358
-
2359
- // ../core/components/OutlineList/index.tsx
2360
- init_react_import();
2361
-
2362
- // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
2363
- init_react_import();
2364
- var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
2365
-
2366
- // ../core/components/OutlineList/index.tsx
2367
- import { jsx as jsx6 } from "react/jsx-runtime";
2368
- var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
2369
- var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
2370
- var OutlineList = ({ children }) => {
2371
- return /* @__PURE__ */ jsx6("ul", { className: getClassName4(), children });
2372
- };
2373
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx6("div", { className: getClassNameItem({ clickable: true }), children });
2374
- OutlineList.Item = ({
2375
- children,
2376
- onClick
2377
- }) => {
2378
- return /* @__PURE__ */ jsx6(
2379
- "li",
2380
- {
2381
- className: getClassNameItem({ clickable: !!onClick }),
2382
- onClick,
2383
- children
2384
- }
2385
- );
2386
- };
2387
-
2388
- // ../core/lib/scroll-into-view.ts
2389
- init_react_import();
2390
- var scrollIntoView = (el) => {
2391
- const oldStyle = __spreadValues({}, el.style);
2392
- el.style.scrollMargin = "256px";
2393
- if (el) {
2394
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
2395
- el.style.scrollMargin = oldStyle.scrollMargin || "";
2396
- }
2397
- };
2398
-
2399
- // ../core/lib/get-frame.ts
2400
- init_react_import();
2401
- var getFrame = () => {
2402
- if (typeof window === "undefined") return;
2403
- let frameEl = document.querySelector("#preview-frame");
2404
- if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
2405
- return frameEl.contentDocument || document;
2406
- }
2407
- return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
2408
- };
2409
-
2410
2146
  // src/HeadingAnalyzer.tsx
2411
2147
  import ReactFromJSONModule from "react-from-json";
2412
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
2413
- var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2148
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
2149
+ var getClassName2 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2414
2150
  var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
2415
2151
  var ReactFromJSON = ReactFromJSONModule.default || ReactFromJSONModule;
2416
2152
  var getOutline = ({ frame } = {}) => {
@@ -2501,11 +2237,11 @@ var HeadingAnalyzer = () => {
2501
2237
  frameObserver.disconnect();
2502
2238
  };
2503
2239
  }, [data]);
2504
- return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
2505
- /* @__PURE__ */ jsxs2(
2240
+ return /* @__PURE__ */ jsxs("div", { className: getClassName2(), children: [
2241
+ /* @__PURE__ */ jsxs(
2506
2242
  "small",
2507
2243
  {
2508
- className: getClassName5("cssWarning"),
2244
+ className: getClassName2("cssWarning"),
2509
2245
  style: {
2510
2246
  color: "var(--puck-color-red-04)",
2511
2247
  display: "block",
@@ -2514,19 +2250,19 @@ var HeadingAnalyzer = () => {
2514
2250
  children: [
2515
2251
  "Heading analyzer styles not loaded. Please review the",
2516
2252
  " ",
2517
- /* @__PURE__ */ jsx7("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2253
+ /* @__PURE__ */ jsx2("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2518
2254
  "."
2519
2255
  ]
2520
2256
  }
2521
2257
  ),
2522
- hierarchy.length === 0 && /* @__PURE__ */ jsx7("div", { children: "No headings." }),
2523
- /* @__PURE__ */ jsx7(OutlineList, { children: /* @__PURE__ */ jsx7(
2258
+ hierarchy.length === 0 && /* @__PURE__ */ jsx2("div", { children: "No headings." }),
2259
+ /* @__PURE__ */ jsx2(OutlineList, { children: /* @__PURE__ */ jsx2(
2524
2260
  ReactFromJSON,
2525
2261
  {
2526
2262
  mapping: {
2527
- Root: (props) => /* @__PURE__ */ jsx7(Fragment2, { children: props.children }),
2528
- OutlineListItem: (props) => /* @__PURE__ */ jsxs2(OutlineList.Item, { children: [
2529
- /* @__PURE__ */ jsx7(OutlineList.Clickable, { children: /* @__PURE__ */ jsx7(
2263
+ Root: (props) => /* @__PURE__ */ jsx2(Fragment, { children: props.children }),
2264
+ OutlineListItem: (props) => /* @__PURE__ */ jsxs(OutlineList.Item, { children: [
2265
+ /* @__PURE__ */ jsx2(OutlineList.Clickable, { children: /* @__PURE__ */ jsx2(
2530
2266
  "small",
2531
2267
  {
2532
2268
  className: getClassNameItem2({ missing: props.missing }),
@@ -2544,14 +2280,14 @@ var HeadingAnalyzer = () => {
2544
2280
  }, 2e3);
2545
2281
  }
2546
2282
  },
2547
- children: props.missing ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
2548
- /* @__PURE__ */ jsxs2("b", { children: [
2283
+ children: props.missing ? /* @__PURE__ */ jsxs(Fragment, { children: [
2284
+ /* @__PURE__ */ jsxs("b", { children: [
2549
2285
  "H",
2550
2286
  props.rank
2551
2287
  ] }),
2552
2288
  ": Missing"
2553
- ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2554
- /* @__PURE__ */ jsxs2("b", { children: [
2289
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2290
+ /* @__PURE__ */ jsxs("b", { children: [
2555
2291
  "H",
2556
2292
  props.rank
2557
2293
  ] }),
@@ -2560,7 +2296,7 @@ var HeadingAnalyzer = () => {
2560
2296
  ] })
2561
2297
  }
2562
2298
  ) }),
2563
- /* @__PURE__ */ jsx7(OutlineList, { children: props.children })
2299
+ /* @__PURE__ */ jsx2(OutlineList, { children: props.children })
2564
2300
  ] })
2565
2301
  },
2566
2302
  entry: {
@@ -2581,12 +2317,10 @@ var HeadingAnalyzer = () => {
2581
2317
  ] });
2582
2318
  };
2583
2319
  var headingAnalyzer = {
2584
- overrides: {
2585
- fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
2586
- children,
2587
- /* @__PURE__ */ jsx7("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ jsx7(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ jsx7(HeadingAnalyzer, {}) }) })
2588
- ] })
2589
- }
2320
+ name: "heading-analyzer",
2321
+ label: "Audit",
2322
+ render: HeadingAnalyzer,
2323
+ icon: /* @__PURE__ */ jsx2(Heading1, {})
2590
2324
  };
2591
2325
  var HeadingAnalyzer_default = headingAnalyzer;
2592
2326
  export {
@@ -2633,7 +2367,7 @@ lucide-react/dist/esm/createLucideIcon.js:
2633
2367
  * See the LICENSE file in the root directory of this source tree.
2634
2368
  *)
2635
2369
 
2636
- lucide-react/dist/esm/icons/chevron-right.js:
2370
+ lucide-react/dist/esm/icons/heading-1.js:
2637
2371
  (**
2638
2372
  * @license lucide-react v0.468.0 - ISC
2639
2373
  *