@measured/puck-plugin-heading-analyzer 0.20.0-canary.8c56aa8b → 0.20.0-canary.8ffbfdad

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.js CHANGED
@@ -313,7 +313,7 @@ init_react_import();
313
313
 
314
314
  // src/HeadingAnalyzer.tsx
315
315
  init_react_import();
316
- var import_react12 = require("react");
316
+ var import_react10 = require("react");
317
317
 
318
318
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
319
319
  init_react_import();
@@ -322,12 +322,12 @@ var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v
322
322
  // src/HeadingAnalyzer.tsx
323
323
  var import_puck = require("@measured/puck");
324
324
 
325
- // ../core/components/SidebarSection/index.tsx
325
+ // ../core/components/OutlineList/index.tsx
326
326
  init_react_import();
327
327
 
328
- // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
328
+ // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
329
329
  init_react_import();
330
- 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" };
330
+ var styles_module_default = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
331
331
 
332
332
  // ../core/lib/get-class-name-factory.ts
333
333
  init_react_import();
@@ -356,29 +356,50 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
356
356
  };
357
357
  var get_class_name_factory_default = getClassNameFactory;
358
358
 
359
- // ../core/components/Heading/index.tsx
360
- init_react_import();
361
-
362
- // css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
363
- init_react_import();
364
- 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" };
365
-
366
- // ../core/components/Heading/index.tsx
359
+ // ../core/components/OutlineList/index.tsx
367
360
  var import_jsx_runtime = require("react/jsx-runtime");
368
- var getClassName = get_class_name_factory_default("Heading", styles_module_default2);
369
- var Heading = ({ children, rank, size = "m" }) => {
370
- const Tag = rank ? `h${rank}` : "span";
361
+ var getClassName = get_class_name_factory_default("OutlineList", styles_module_default);
362
+ var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default);
363
+ var OutlineList = ({ children }) => {
364
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: getClassName(), children });
365
+ };
366
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
367
+ OutlineList.Item = ({
368
+ children,
369
+ onClick
370
+ }) => {
371
371
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
372
- Tag,
372
+ "li",
373
373
  {
374
- className: getClassName({
375
- [size]: true
376
- }),
374
+ className: getClassNameItem({ clickable: !!onClick }),
375
+ onClick,
377
376
  children
378
377
  }
379
378
  );
380
379
  };
381
380
 
381
+ // ../core/lib/scroll-into-view.ts
382
+ init_react_import();
383
+ var scrollIntoView = (el) => {
384
+ const oldStyle = __spreadValues({}, el.style);
385
+ el.style.scrollMargin = "256px";
386
+ if (el) {
387
+ el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
388
+ el.style.scrollMargin = oldStyle.scrollMargin || "";
389
+ }
390
+ };
391
+
392
+ // ../core/lib/get-frame.ts
393
+ init_react_import();
394
+ var getFrame = () => {
395
+ if (typeof window === "undefined") return;
396
+ let frameEl = document.querySelector("#preview-frame");
397
+ if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
398
+ return frameEl.contentDocument || document;
399
+ }
400
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
401
+ };
402
+
382
403
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
383
404
  init_react_import();
384
405
 
@@ -466,15 +487,29 @@ var createLucideIcon = (iconName, iconNode) => {
466
487
  return Component;
467
488
  };
468
489
 
469
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
490
+ // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
470
491
  init_react_import();
471
- var ChevronRight = createLucideIcon("ChevronRight", [
472
- ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
492
+ var Heading1 = createLucideIcon("Heading1", [
493
+ ["path", { d: "M4 12h8", key: "17cfdx" }],
494
+ ["path", { d: "M4 18V6", key: "1rz3zl" }],
495
+ ["path", { d: "M12 18V6", key: "zqpxq5" }],
496
+ ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
473
497
  ]);
474
498
 
475
- // ../core/lib/use-breadcrumbs.ts
499
+ // ../core/lib/index.ts
500
+ init_react_import();
501
+
502
+ // ../core/lib/filter.ts
503
+ init_react_import();
504
+
505
+ // ../core/lib/data/reorder.ts
506
+ init_react_import();
507
+
508
+ // ../core/lib/data/replace.ts
509
+ init_react_import();
510
+
511
+ // ../core/lib/use-reset-auto-zoom.ts
476
512
  init_react_import();
477
- var import_react10 = require("react");
478
513
 
479
514
  // ../core/store/index.ts
480
515
  init_react_import();
@@ -521,7 +556,7 @@ function forRelatedZones(item, data, cb, path = []) {
521
556
  });
522
557
  }
523
558
 
524
- // ../core/lib/data/map-slots.ts
559
+ // ../core/lib/data/map-fields.ts
525
560
  init_react_import();
526
561
 
527
562
  // ../core/lib/data/default-slots.ts
@@ -531,14 +566,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
531
566
  value
532
567
  );
533
568
 
534
- // ../core/lib/data/map-slots.ts
569
+ // ../core/lib/data/map-fields.ts
535
570
  var isPromise = (v) => !!v && typeof v.then === "function";
536
571
  var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
537
572
  var containsPromise = (arr) => arr.some(isPromise);
538
573
  var walkField = ({
539
574
  value,
540
575
  fields,
541
- map,
576
+ mappers,
542
577
  propKey = "",
543
578
  propPath = "",
544
579
  id = "",
@@ -546,7 +581,9 @@ var walkField = ({
546
581
  recurseSlots = false
547
582
  }) => {
548
583
  var _a, _b, _c;
549
- if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
584
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
585
+ const map = mappers[fieldType];
586
+ if (map && fieldType === "slot") {
550
587
  const content = value || [];
551
588
  const mappedContent = recurseSlots ? content.map((el) => {
552
589
  var _a2;
@@ -558,7 +595,7 @@ var walkField = ({
558
595
  return walkField({
559
596
  value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
560
597
  fields: fields2,
561
- map,
598
+ mappers,
562
599
  id: el.props.id,
563
600
  config,
564
601
  recurseSlots
@@ -567,7 +604,21 @@ var walkField = ({
567
604
  if (containsPromise(mappedContent)) {
568
605
  return Promise.all(mappedContent);
569
606
  }
570
- return map(mappedContent, id, propPath, fields[propKey], propPath);
607
+ return map({
608
+ value: mappedContent,
609
+ parentId: id,
610
+ propName: propKey,
611
+ field: fields[propKey],
612
+ propPath
613
+ });
614
+ } else if (map && fields[propKey]) {
615
+ return map({
616
+ value,
617
+ parentId: id,
618
+ propName: propKey,
619
+ field: fields[propKey],
620
+ propPath
621
+ });
571
622
  }
572
623
  if (value && typeof value === "object") {
573
624
  if (Array.isArray(value)) {
@@ -577,7 +628,7 @@ var walkField = ({
577
628
  (el, idx) => walkField({
578
629
  value: el,
579
630
  fields: arrayFields,
580
- map,
631
+ mappers,
581
632
  propKey,
582
633
  propPath: `${propPath}[${idx}]`,
583
634
  id,
@@ -596,7 +647,7 @@ var walkField = ({
596
647
  return walkObject({
597
648
  value,
598
649
  fields: objectFields,
599
- map,
650
+ mappers,
600
651
  id,
601
652
  getPropPath: (k) => `${propPath}.${k}`,
602
653
  config,
@@ -609,7 +660,7 @@ var walkField = ({
609
660
  var walkObject = ({
610
661
  value,
611
662
  fields,
612
- map,
663
+ mappers,
613
664
  id,
614
665
  getPropPath,
615
666
  config,
@@ -619,7 +670,7 @@ var walkObject = ({
619
670
  const opts = {
620
671
  value: v,
621
672
  fields,
622
- map,
673
+ mappers,
623
674
  propKey: k,
624
675
  propPath: getPropPath(k),
625
676
  id,
@@ -641,14 +692,14 @@ var walkObject = ({
641
692
  }
642
693
  return flatten(newProps);
643
694
  };
644
- function mapSlots(item, map, config, recurseSlots = false) {
695
+ function mapFields(item, mappers, config, recurseSlots = false) {
645
696
  var _a, _b, _c, _d, _e;
646
697
  const itemType = "type" in item ? item.type : "root";
647
698
  const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
648
699
  const newProps = walkObject({
649
700
  value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
650
701
  fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
651
- map,
702
+ mappers,
652
703
  id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
653
704
  getPropPath: (k) => k,
654
705
  config,
@@ -671,7 +722,7 @@ var import_flat = __toESM(require_flat());
671
722
  // ../core/lib/data/strip-slots.ts
672
723
  init_react_import();
673
724
  var stripSlots = (data, config) => {
674
- return mapSlots(data, () => null, config);
725
+ return mapFields(data, { slot: () => null }, config);
675
726
  };
676
727
 
677
728
  // ../core/lib/data/flatten-node.ts
@@ -724,18 +775,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
724
775
  const mappedItem = mapNodeOrSkip(item, path, index);
725
776
  if (!mappedItem) return item;
726
777
  const id = mappedItem.props.id;
727
- const newProps = __spreadProps(__spreadValues({}, mapSlots(
778
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
728
779
  mappedItem,
729
- (content, parentId2, slotId) => {
730
- const zoneCompound = `${parentId2}:${slotId}`;
731
- const [_2, newContent2] = processContent(
732
- path,
733
- zoneCompound,
734
- content,
735
- "slot",
736
- parentId2
737
- );
738
- return newContent2;
780
+ {
781
+ slot: ({ value, parentId: parentId2, propPath }) => {
782
+ const content = value;
783
+ const zoneCompound = `${parentId2}:${propPath}`;
784
+ const [_2, newContent2] = processContent(
785
+ path,
786
+ zoneCompound,
787
+ content,
788
+ "slot",
789
+ parentId2
790
+ );
791
+ return newContent2;
792
+ }
739
793
  },
740
794
  config
741
795
  ).props), {
@@ -910,11 +964,14 @@ init_react_import();
910
964
  function walkTree(data, config, callbackFn) {
911
965
  var _a, _b;
912
966
  const walkItem = (item) => {
913
- return mapSlots(
967
+ return mapFields(
914
968
  item,
915
- (content, parentId, propName) => {
916
- var _a2;
917
- return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
969
+ {
970
+ slot: ({ value, parentId, propName }) => {
971
+ var _a2;
972
+ const content = value;
973
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
974
+ }
918
975
  },
919
976
  config,
920
977
  true
@@ -1834,24 +1891,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1834
1891
  resolvedItem.readOnly = readOnly;
1835
1892
  }
1836
1893
  }
1837
- let itemWithResolvedChildren = yield mapSlots(
1894
+ let itemWithResolvedChildren = yield mapFields(
1838
1895
  resolvedItem,
1839
- (content) => __async(void 0, null, function* () {
1840
- return yield Promise.all(
1841
- content.map(
1842
- (childItem) => __async(void 0, null, function* () {
1843
- return (yield resolveComponentData(
1844
- childItem,
1845
- config,
1846
- metadata,
1847
- onResolveStart,
1848
- onResolveEnd,
1849
- trigger
1850
- )).node;
1851
- })
1852
- )
1853
- );
1854
- }),
1896
+ {
1897
+ slot: (_02) => __async(void 0, [_02], function* ({ value }) {
1898
+ const content = value;
1899
+ return yield Promise.all(
1900
+ content.map(
1901
+ (childItem) => __async(void 0, null, function* () {
1902
+ return (yield resolveComponentData(
1903
+ childItem,
1904
+ config,
1905
+ metadata,
1906
+ onResolveStart,
1907
+ onResolveEnd,
1908
+ trigger
1909
+ )).node;
1910
+ })
1911
+ )
1912
+ );
1913
+ })
1914
+ },
1855
1915
  config
1856
1916
  );
1857
1917
  if (shouldRunResolver && onResolveEnd) {
@@ -1933,7 +1993,8 @@ var createAppStore = (initialAppStore) => create()(
1933
1993
  },
1934
1994
  status: "LOADING",
1935
1995
  iframe: {},
1936
- metadata: {}
1996
+ metadata: {},
1997
+ fieldTransforms: {}
1937
1998
  }, initialAppStore), {
1938
1999
  fields: createFieldsSlice(set, get),
1939
2000
  history: createHistorySlice(set, get),
@@ -2089,204 +2150,14 @@ var createAppStore = (initialAppStore) => create()(
2089
2150
  })
2090
2151
  );
2091
2152
  var appStoreContext = (0, import_react9.createContext)(createAppStore());
2092
- function useAppStore(selector) {
2093
- const context = (0, import_react9.useContext)(appStoreContext);
2094
- return useStore(context, selector);
2095
- }
2096
- function useAppStoreApi() {
2097
- return (0, import_react9.useContext)(appStoreContext);
2098
- }
2099
-
2100
- // ../core/lib/use-breadcrumbs.ts
2101
- var useBreadcrumbs = (renderCount) => {
2102
- const selectedId = useAppStore((s) => {
2103
- var _a;
2104
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
2105
- });
2106
- const config = useAppStore((s) => s.config);
2107
- const path = useAppStore((s) => {
2108
- var _a;
2109
- return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
2110
- });
2111
- const appStore = useAppStoreApi();
2112
- return (0, import_react10.useMemo)(() => {
2113
- const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
2114
- var _a, _b, _c;
2115
- const [componentId] = zoneCompound.split(":");
2116
- if (componentId === "root") {
2117
- return {
2118
- label: "Page",
2119
- selector: null
2120
- };
2121
- }
2122
- const node = appStore.getState().state.indexes.nodes[componentId];
2123
- const parentId = node.path[node.path.length - 1];
2124
- const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
2125
- const index = contentIds.indexOf(componentId);
2126
- const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
2127
- return {
2128
- label,
2129
- selector: node ? {
2130
- index,
2131
- zone: node.path[node.path.length - 1]
2132
- } : null
2133
- };
2134
- })) || [];
2135
- if (renderCount) {
2136
- return breadcrumbs.slice(breadcrumbs.length - renderCount);
2137
- }
2138
- return breadcrumbs;
2139
- }, [path, renderCount]);
2140
- };
2141
-
2142
- // ../core/components/Loader/index.tsx
2143
- init_react_import();
2144
-
2145
- // ../core/lib/index.ts
2146
- init_react_import();
2147
-
2148
- // ../core/lib/filter.ts
2149
- init_react_import();
2150
-
2151
- // ../core/lib/data/reorder.ts
2152
- init_react_import();
2153
-
2154
- // ../core/lib/data/replace.ts
2155
- init_react_import();
2156
-
2157
- // ../core/lib/use-reset-auto-zoom.ts
2158
- init_react_import();
2159
- var import_react11 = require("react");
2160
2153
 
2161
2154
  // ../core/lib/get-zoom-config.ts
2162
2155
  init_react_import();
2163
2156
 
2164
- // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
2165
- init_react_import();
2166
- var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
2167
-
2168
- // ../core/components/Loader/index.tsx
2169
- var import_jsx_runtime2 = require("react/jsx-runtime");
2170
- var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
2171
- var Loader = (_a) => {
2172
- var _b = _a, {
2173
- color,
2174
- size = 16
2175
- } = _b, props = __objRest(_b, [
2176
- "color",
2177
- "size"
2178
- ]);
2179
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2180
- "span",
2181
- __spreadValues({
2182
- className: getClassName2(),
2183
- style: {
2184
- width: size,
2185
- height: size,
2186
- color
2187
- },
2188
- "aria-label": "loading"
2189
- }, props)
2190
- );
2191
- };
2192
-
2193
- // ../core/components/SidebarSection/index.tsx
2194
- var import_jsx_runtime3 = require("react/jsx-runtime");
2195
- var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
2196
- var SidebarSection = ({
2197
- children,
2198
- title,
2199
- background,
2200
- showBreadcrumbs,
2201
- noBorderTop,
2202
- noPadding,
2203
- isLoading
2204
- }) => {
2205
- const setUi = useAppStore((s) => s.setUi);
2206
- const breadcrumbs = useBreadcrumbs(1);
2207
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2208
- "div",
2209
- {
2210
- className: getClassName3({ noBorderTop, noPadding }),
2211
- style: { background },
2212
- children: [
2213
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("title"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumbs"), children: [
2214
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumb"), children: [
2215
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2216
- "button",
2217
- {
2218
- type: "button",
2219
- className: getClassName3("breadcrumbLabel"),
2220
- onClick: () => setUi({ itemSelector: breadcrumb.selector }),
2221
- children: breadcrumb.label
2222
- }
2223
- ),
2224
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronRight, { size: 16 })
2225
- ] }, i)) : null,
2226
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
2227
- ] }) }),
2228
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("content"), children }),
2229
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 32 }) })
2230
- ]
2231
- }
2232
- );
2233
- };
2234
-
2235
- // ../core/components/OutlineList/index.tsx
2236
- init_react_import();
2237
-
2238
- // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
2239
- init_react_import();
2240
- var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
2241
-
2242
- // ../core/components/OutlineList/index.tsx
2243
- var import_jsx_runtime4 = require("react/jsx-runtime");
2244
- var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
2245
- var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
2246
- var OutlineList = ({ children }) => {
2247
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: getClassName4(), children });
2248
- };
2249
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
2250
- OutlineList.Item = ({
2251
- children,
2252
- onClick
2253
- }) => {
2254
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2255
- "li",
2256
- {
2257
- className: getClassNameItem({ clickable: !!onClick }),
2258
- onClick,
2259
- children
2260
- }
2261
- );
2262
- };
2263
-
2264
- // ../core/lib/scroll-into-view.ts
2265
- init_react_import();
2266
- var scrollIntoView = (el) => {
2267
- const oldStyle = __spreadValues({}, el.style);
2268
- el.style.scrollMargin = "256px";
2269
- if (el) {
2270
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
2271
- el.style.scrollMargin = oldStyle.scrollMargin || "";
2272
- }
2273
- };
2274
-
2275
- // ../core/lib/get-frame.ts
2276
- init_react_import();
2277
- var getFrame = () => {
2278
- if (typeof window === "undefined") return;
2279
- let frameEl = document.querySelector("#preview-frame");
2280
- if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
2281
- return frameEl.contentDocument || document;
2282
- }
2283
- return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
2284
- };
2285
-
2286
2157
  // src/HeadingAnalyzer.tsx
2287
2158
  var import_react_from_json = __toESM(require("react-from-json"));
2288
- var import_jsx_runtime5 = require("react/jsx-runtime");
2289
- var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2159
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2160
+ var getClassName2 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2290
2161
  var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
2291
2162
  var ReactFromJSON = import_react_from_json.default.default || import_react_from_json.default;
2292
2163
  var getOutline = ({ frame } = {}) => {
@@ -2341,8 +2212,8 @@ function buildHierarchy(frame) {
2341
2212
  var usePuck = (0, import_puck.createUsePuck)();
2342
2213
  var HeadingAnalyzer = () => {
2343
2214
  const data = usePuck((s) => s.appState.data);
2344
- const [hierarchy, setHierarchy] = (0, import_react12.useState)([]);
2345
- (0, import_react12.useEffect)(() => {
2215
+ const [hierarchy, setHierarchy] = (0, import_react10.useState)([]);
2216
+ (0, import_react10.useEffect)(() => {
2346
2217
  const frame = getFrame();
2347
2218
  let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
2348
2219
  const createHierarchy = () => {
@@ -2377,11 +2248,11 @@ var HeadingAnalyzer = () => {
2377
2248
  frameObserver.disconnect();
2378
2249
  };
2379
2250
  }, [data]);
2380
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
2381
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2251
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: getClassName2(), children: [
2252
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2382
2253
  "small",
2383
2254
  {
2384
- className: getClassName5("cssWarning"),
2255
+ className: getClassName2("cssWarning"),
2385
2256
  style: {
2386
2257
  color: "var(--puck-color-red-04)",
2387
2258
  display: "block",
@@ -2390,19 +2261,19 @@ var HeadingAnalyzer = () => {
2390
2261
  children: [
2391
2262
  "Heading analyzer styles not loaded. Please review the",
2392
2263
  " ",
2393
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2264
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2394
2265
  "."
2395
2266
  ]
2396
2267
  }
2397
2268
  ),
2398
- hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No headings." }),
2399
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2269
+ hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: "No headings." }),
2270
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2400
2271
  ReactFromJSON,
2401
2272
  {
2402
2273
  mapping: {
2403
- Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: props.children }),
2404
- OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OutlineList.Item, { children: [
2405
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2274
+ Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: props.children }),
2275
+ OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(OutlineList.Item, { children: [
2276
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2406
2277
  "small",
2407
2278
  {
2408
2279
  className: getClassNameItem2({ missing: props.missing }),
@@ -2420,14 +2291,14 @@ var HeadingAnalyzer = () => {
2420
2291
  }, 2e3);
2421
2292
  }
2422
2293
  },
2423
- children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2424
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2294
+ children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("b", { children: [
2425
2296
  "H",
2426
2297
  props.rank
2427
2298
  ] }),
2428
2299
  ": Missing"
2429
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2430
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2300
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2301
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("b", { children: [
2431
2302
  "H",
2432
2303
  props.rank
2433
2304
  ] }),
@@ -2436,7 +2307,7 @@ var HeadingAnalyzer = () => {
2436
2307
  ] })
2437
2308
  }
2438
2309
  ) }),
2439
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: props.children })
2310
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList, { children: props.children })
2440
2311
  ] })
2441
2312
  },
2442
2313
  entry: {
@@ -2457,12 +2328,10 @@ var HeadingAnalyzer = () => {
2457
2328
  ] });
2458
2329
  };
2459
2330
  var headingAnalyzer = {
2460
- overrides: {
2461
- fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2462
- children,
2463
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeadingAnalyzer, {}) }) })
2464
- ] })
2465
- }
2331
+ name: "heading-analyzer",
2332
+ label: "Audit",
2333
+ render: HeadingAnalyzer,
2334
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Heading1, {})
2466
2335
  };
2467
2336
  var HeadingAnalyzer_default = headingAnalyzer;
2468
2337
  /*! Bundled license information:
@@ -2506,7 +2375,7 @@ lucide-react/dist/esm/createLucideIcon.js:
2506
2375
  * See the LICENSE file in the root directory of this source tree.
2507
2376
  *)
2508
2377
 
2509
- lucide-react/dist/esm/icons/chevron-right.js:
2378
+ lucide-react/dist/esm/icons/heading-1.js:
2510
2379
  (**
2511
2380
  * @license lucide-react v0.468.0 - ISC
2512
2381
  *