@measured/puck-plugin-heading-analyzer 0.21.0-canary.2e1b5267 → 0.21.0-canary.38e79ba8

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
@@ -268,30 +268,30 @@ var require_flat = __commonJS({
268
268
  });
269
269
 
270
270
  // index.ts
271
- var plugin_heading_analyzer_exports = {};
272
- __export(plugin_heading_analyzer_exports, {
271
+ var index_exports = {};
272
+ __export(index_exports, {
273
273
  default: () => HeadingAnalyzer_default
274
274
  });
275
- module.exports = __toCommonJS(plugin_heading_analyzer_exports);
275
+ module.exports = __toCommonJS(index_exports);
276
276
  init_react_import();
277
277
 
278
278
  // src/HeadingAnalyzer.tsx
279
279
  init_react_import();
280
- var import_react10 = require("react");
280
+ var import_react11 = require("react");
281
281
 
282
282
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
283
283
  init_react_import();
284
- var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_yg0s7_1", "HeadingAnalyzer-cssWarning": "_HeadingAnalyzer-cssWarning_yg0s7_6", "HeadingAnalyzerItem": "_HeadingAnalyzerItem_yg0s7_10", "HeadingAnalyzerItem--missing": "_HeadingAnalyzerItem--missing_yg0s7_14" };
284
+ var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v6_1", "HeadingAnalyzer-cssWarning": "_HeadingAnalyzer-cssWarning_116v6_5", "HeadingAnalyzerItem": "_HeadingAnalyzerItem_116v6_9", "HeadingAnalyzerItem--missing": "_HeadingAnalyzerItem--missing_116v6_13" };
285
285
 
286
286
  // src/HeadingAnalyzer.tsx
287
287
  var import_puck = require("@measured/puck");
288
288
 
289
- // ../core/components/OutlineList/index.tsx
289
+ // ../core/components/SidebarSection/index.tsx
290
290
  init_react_import();
291
291
 
292
- // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
292
+ // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
293
293
  init_react_import();
294
- var styles_module_default = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
294
+ 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" };
295
295
 
296
296
  // ../core/lib/get-class-name-factory.ts
297
297
  init_react_import();
@@ -320,50 +320,29 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
320
320
  };
321
321
  var get_class_name_factory_default = getClassNameFactory;
322
322
 
323
- // ../core/components/OutlineList/index.tsx
323
+ // ../core/components/Heading/index.tsx
324
+ init_react_import();
325
+
326
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
327
+ init_react_import();
328
+ 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" };
329
+
330
+ // ../core/components/Heading/index.tsx
324
331
  var import_jsx_runtime = require("react/jsx-runtime");
325
- var getClassName = get_class_name_factory_default("OutlineList", styles_module_default);
326
- var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default);
327
- var OutlineList = ({ children }) => {
328
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: getClassName(), children });
329
- };
330
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
331
- OutlineList.Item = ({
332
- children,
333
- onClick
334
- }) => {
332
+ var getClassName = get_class_name_factory_default("Heading", styles_module_default2);
333
+ var Heading = ({ children, rank, size = "m" }) => {
334
+ const Tag = rank ? `h${rank}` : "span";
335
335
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
336
- "li",
336
+ Tag,
337
337
  {
338
- className: getClassNameItem({ clickable: !!onClick }),
339
- onClick,
338
+ className: getClassName({
339
+ [size]: true
340
+ }),
340
341
  children
341
342
  }
342
343
  );
343
344
  };
344
345
 
345
- // ../core/lib/scroll-into-view.ts
346
- init_react_import();
347
- var scrollIntoView = (el) => {
348
- const oldStyle = __spreadValues({}, el.style);
349
- el.style.scrollMargin = "256px";
350
- if (el) {
351
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
352
- el.style.scrollMargin = oldStyle.scrollMargin || "";
353
- }
354
- };
355
-
356
- // ../core/lib/get-frame.ts
357
- init_react_import();
358
- var getFrame = () => {
359
- if (typeof window === "undefined") return;
360
- let frameEl = document.querySelector("#preview-frame");
361
- if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
362
- return frameEl.contentDocument || document;
363
- }
364
- return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
365
- };
366
-
367
346
  // ../../node_modules/lucide-react/dist/esm/lucide-react.js
368
347
  init_react_import();
369
348
 
@@ -451,29 +430,15 @@ var createLucideIcon = (iconName, iconNode) => {
451
430
  return Component;
452
431
  };
453
432
 
454
- // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
433
+ // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
455
434
  init_react_import();
456
- var Heading1 = createLucideIcon("Heading1", [
457
- ["path", { d: "M4 12h8", key: "17cfdx" }],
458
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
459
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
460
- ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
435
+ var ChevronRight = createLucideIcon("ChevronRight", [
436
+ ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
461
437
  ]);
462
438
 
463
- // ../core/lib/index.ts
464
- init_react_import();
465
-
466
- // ../core/lib/filter.ts
467
- init_react_import();
468
-
469
- // ../core/lib/data/reorder.ts
470
- init_react_import();
471
-
472
- // ../core/lib/data/replace.ts
473
- init_react_import();
474
-
475
- // ../core/lib/use-reset-auto-zoom.ts
439
+ // ../core/lib/use-breadcrumbs.ts
476
440
  init_react_import();
441
+ var import_react10 = require("react");
477
442
 
478
443
  // ../core/store/index.ts
479
444
  init_react_import();
@@ -853,10 +818,10 @@ var insert = (list, index, item) => {
853
818
  // ../core/lib/generate-id.ts
854
819
  init_react_import();
855
820
 
856
- // ../../node_modules/uuid/dist/esm-node/index.js
821
+ // ../core/node_modules/uuid/dist/esm-node/index.js
857
822
  init_react_import();
858
823
 
859
- // ../../node_modules/uuid/dist/esm-node/rng.js
824
+ // ../core/node_modules/uuid/dist/esm-node/rng.js
860
825
  init_react_import();
861
826
  var import_crypto = __toESM(require("crypto"));
862
827
  var rnds8Pool = new Uint8Array(256);
@@ -869,7 +834,7 @@ function rng() {
869
834
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
870
835
  }
871
836
 
872
- // ../../node_modules/uuid/dist/esm-node/stringify.js
837
+ // ../core/node_modules/uuid/dist/esm-node/stringify.js
873
838
  init_react_import();
874
839
  var byteToHex = [];
875
840
  for (let i = 0; i < 256; ++i) {
@@ -879,17 +844,17 @@ function unsafeStringify(arr, offset = 0) {
879
844
  return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
880
845
  }
881
846
 
882
- // ../../node_modules/uuid/dist/esm-node/v4.js
847
+ // ../core/node_modules/uuid/dist/esm-node/v4.js
883
848
  init_react_import();
884
849
 
885
- // ../../node_modules/uuid/dist/esm-node/native.js
850
+ // ../core/node_modules/uuid/dist/esm-node/native.js
886
851
  init_react_import();
887
852
  var import_crypto2 = __toESM(require("crypto"));
888
853
  var native_default = {
889
854
  randomUUID: import_crypto2.default.randomUUID
890
855
  };
891
856
 
892
- // ../../node_modules/uuid/dist/esm-node/v4.js
857
+ // ../core/node_modules/uuid/dist/esm-node/v4.js
893
858
  function v4(options, buf, offset) {
894
859
  if (native_default.randomUUID && !buf && !options) {
895
860
  return native_default.randomUUID();
@@ -1443,8 +1408,7 @@ init_react_import();
1443
1408
  var defaultViewports = [
1444
1409
  { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1445
1410
  { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1446
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
1447
- { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
1411
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1448
1412
  ];
1449
1413
 
1450
1414
  // ../../node_modules/zustand/esm/vanilla.mjs
@@ -1470,7 +1434,7 @@ var createStoreImpl = (createState) => {
1470
1434
  const initialState = state = createState(setState, getState, api);
1471
1435
  return api;
1472
1436
  };
1473
- var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1437
+ var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
1474
1438
 
1475
1439
  // ../../node_modules/zustand/esm/react.mjs
1476
1440
  init_react_import();
@@ -1479,8 +1443,8 @@ var identity = (arg) => arg;
1479
1443
  function useStore(api, selector = identity) {
1480
1444
  const slice = import_react4.default.useSyncExternalStore(
1481
1445
  api.subscribe,
1482
- () => selector(api.getState()),
1483
- () => selector(api.getInitialState())
1446
+ import_react4.default.useCallback(() => selector(api.getState()), [api, selector]),
1447
+ import_react4.default.useCallback(() => selector(api.getInitialState()), [api, selector])
1484
1448
  );
1485
1449
  import_react4.default.useDebugValue(slice);
1486
1450
  return slice;
@@ -1491,13 +1455,13 @@ var createImpl = (createState) => {
1491
1455
  Object.assign(useBoundStore, api);
1492
1456
  return useBoundStore;
1493
1457
  };
1494
- var create = (createState) => createState ? createImpl(createState) : createImpl;
1458
+ var create = ((createState) => createState ? createImpl(createState) : createImpl);
1495
1459
 
1496
1460
  // ../../node_modules/zustand/esm/middleware.mjs
1497
1461
  init_react_import();
1498
1462
  var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
1499
1463
  const origSubscribe = api.subscribe;
1500
- api.subscribe = (selector, optListener, options) => {
1464
+ api.subscribe = ((selector, optListener, options) => {
1501
1465
  let listener = selector;
1502
1466
  if (optListener) {
1503
1467
  const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
@@ -1514,7 +1478,7 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
1514
1478
  }
1515
1479
  }
1516
1480
  return origSubscribe(listener);
1517
- };
1481
+ });
1518
1482
  const initialState = fn(set, get, api);
1519
1483
  return initialState;
1520
1484
  };
@@ -1731,9 +1695,9 @@ function createIsCircular(areItemsEqual) {
1731
1695
  function getStrictProperties(object) {
1732
1696
  return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
1733
1697
  }
1734
- var hasOwn = Object.hasOwn || function(object, property) {
1698
+ var hasOwn = Object.hasOwn || (function(object, property) {
1735
1699
  return hasOwnProperty.call(object, property);
1736
- };
1700
+ });
1737
1701
  function sameValueZeroEqual(a, b) {
1738
1702
  return a === b || !a && !b && a !== a && b !== b;
1739
1703
  }
@@ -2123,29 +2087,37 @@ var getChanged = (newItem, oldItem) => {
2123
2087
 
2124
2088
  // ../core/store/slices/permissions.ts
2125
2089
  var createPermissionsSlice = (set, get) => {
2126
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
2090
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
2127
2091
  const { state, permissions, config } = get();
2128
2092
  const { cache: cache2, globalPermissions } = permissions;
2129
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
2130
- var _a, _b, _c;
2093
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
2094
+ var _a, _b;
2131
2095
  const { config: config2, state: appState, setComponentLoading } = get();
2096
+ const itemCache = cache2[item2.props.id];
2097
+ const nodes = appState.indexes.nodes;
2098
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
2099
+ const parentNode = parentId ? nodes[parentId] : null;
2100
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
2132
2101
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
2133
2102
  if (!componentConfig) {
2134
2103
  return;
2135
2104
  }
2136
2105
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
2137
2106
  if (componentConfig.resolvePermissions) {
2138
- const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
2139
- if (Object.values(changed).some((el) => el === true) || force2) {
2107
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
2108
+ const propsChanged = Object.values(changed).some((el) => el === true);
2109
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
2110
+ if (propsChanged || parentChanged || force2) {
2140
2111
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
2141
2112
  const resolvedPermissions = yield componentConfig.resolvePermissions(
2142
2113
  item2,
2143
2114
  {
2144
2115
  changed,
2145
- lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
2116
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
2146
2117
  permissions: initialPermissions,
2147
2118
  appState: makeStatePublic(appState),
2148
- lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
2119
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
2120
+ parent: parentData
2149
2121
  }
2150
2122
  );
2151
2123
  const latest = get().permissions;
@@ -2153,6 +2125,7 @@ var createPermissionsSlice = (set, get) => {
2153
2125
  permissions: __spreadProps(__spreadValues({}, latest), {
2154
2126
  cache: __spreadProps(__spreadValues({}, latest.cache), {
2155
2127
  [item2.props.id]: {
2128
+ lastParentId: parentId,
2156
2129
  lastData: item2,
2157
2130
  lastPermissions: resolvedPermissions
2158
2131
  }
@@ -2166,9 +2139,9 @@ var createPermissionsSlice = (set, get) => {
2166
2139
  }
2167
2140
  }
2168
2141
  });
2169
- const resolveDataForRoot = (force2 = false) => {
2142
+ const resolvePermissionsForRoot = (force2 = false) => {
2170
2143
  const { state: appState } = get();
2171
- resolveDataForItem(
2144
+ resolvePermissionsForItem(
2172
2145
  // Shim the root data in by conforming to component data shape
2173
2146
  {
2174
2147
  type: "root",
@@ -2179,16 +2152,16 @@ var createPermissionsSlice = (set, get) => {
2179
2152
  };
2180
2153
  const { item, type, root } = params;
2181
2154
  if (item) {
2182
- yield resolveDataForItem(item, force);
2155
+ yield resolvePermissionsForItem(item, force);
2183
2156
  } else if (type) {
2184
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
2185
- yield resolveDataForItem(item2, force);
2157
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
2158
+ yield resolvePermissionsForItem(item2, force);
2186
2159
  }));
2187
2160
  } else if (root) {
2188
- resolveDataForRoot(force);
2161
+ resolvePermissionsForRoot(force);
2189
2162
  } else {
2190
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
2191
- yield resolveDataForItem(item2, force);
2163
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
2164
+ yield resolvePermissionsForItem(item2, force);
2192
2165
  }));
2193
2166
  }
2194
2167
  });
@@ -2242,7 +2215,7 @@ var createFieldsSlice = (_set, _get) => {
2242
2215
  // ../core/lib/resolve-component-data.ts
2243
2216
  init_react_import();
2244
2217
  var cache = { lastChange: {} };
2245
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2218
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2246
2219
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2247
2220
  const resolvedItem = __spreadValues({}, item);
2248
2221
  const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
@@ -2270,11 +2243,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2270
2243
  let itemWithResolvedChildren = yield mapFields(
2271
2244
  resolvedItem,
2272
2245
  {
2273
- slot: (_02) => __async(void 0, [_02], function* ({ value }) {
2246
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
2274
2247
  const content = value;
2275
2248
  return yield Promise.all(
2276
2249
  content.map(
2277
- (childItem) => __async(void 0, null, function* () {
2250
+ (childItem) => __async(null, null, function* () {
2278
2251
  return (yield resolveComponentData(
2279
2252
  childItem,
2280
2253
  config,
@@ -2340,8 +2313,7 @@ var defaultAppState = {
2340
2313
  options: [],
2341
2314
  controlsVisible: true
2342
2315
  },
2343
- field: { focus: null },
2344
- plugin: { current: null }
2316
+ field: { focus: null }
2345
2317
  },
2346
2318
  indexes: {
2347
2319
  nodes: {},
@@ -2357,7 +2329,6 @@ var createAppStore = (initialAppStore) => create()(
2357
2329
  subscribeWithSelector((set, get) => {
2358
2330
  var _a, _b;
2359
2331
  return __spreadProps(__spreadValues({
2360
- instanceId: generateId(),
2361
2332
  state: defaultAppState,
2362
2333
  config: { components: {} },
2363
2334
  componentState: {},
@@ -2466,7 +2437,7 @@ var createAppStore = (initialAppStore) => create()(
2466
2437
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2467
2438
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2468
2439
  }),
2469
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2440
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
2470
2441
  const { config, metadata, setComponentLoading, permissions } = get();
2471
2442
  const timeouts = {};
2472
2443
  return yield resolveComponentData(
@@ -2477,7 +2448,7 @@ var createAppStore = (initialAppStore) => create()(
2477
2448
  const id = "id" in item.props ? item.props.id : "root";
2478
2449
  timeouts[id] = setComponentLoading(id, true, 50);
2479
2450
  },
2480
- (item) => __async(void 0, null, function* () {
2451
+ (item) => __async(null, null, function* () {
2481
2452
  const id = "id" in item.props ? item.props.id : "root";
2482
2453
  if ("type" in item) {
2483
2454
  yield permissions.refreshPermissions({ item });
@@ -2489,7 +2460,7 @@ var createAppStore = (initialAppStore) => create()(
2489
2460
  trigger
2490
2461
  );
2491
2462
  }),
2492
- resolveAndCommitData: () => __async(void 0, null, function* () {
2463
+ resolveAndCommitData: () => __async(null, null, function* () {
2493
2464
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2494
2465
  walkAppState(
2495
2466
  state,
@@ -2528,14 +2499,203 @@ var createAppStore = (initialAppStore) => create()(
2528
2499
  })
2529
2500
  );
2530
2501
  var appStoreContext = (0, import_react9.createContext)(createAppStore());
2502
+ function useAppStore(selector) {
2503
+ const context = (0, import_react9.useContext)(appStoreContext);
2504
+ return useStore(context, selector);
2505
+ }
2506
+ function useAppStoreApi() {
2507
+ return (0, import_react9.useContext)(appStoreContext);
2508
+ }
2509
+
2510
+ // ../core/lib/use-breadcrumbs.ts
2511
+ var useBreadcrumbs = (renderCount) => {
2512
+ const selectedId = useAppStore((s) => {
2513
+ var _a;
2514
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
2515
+ });
2516
+ const config = useAppStore((s) => s.config);
2517
+ const path = useAppStore((s) => {
2518
+ var _a;
2519
+ return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
2520
+ });
2521
+ const appStore = useAppStoreApi();
2522
+ return (0, import_react10.useMemo)(() => {
2523
+ const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
2524
+ var _a, _b, _c;
2525
+ const [componentId] = zoneCompound.split(":");
2526
+ if (componentId === "root") {
2527
+ return {
2528
+ label: "Page",
2529
+ selector: null
2530
+ };
2531
+ }
2532
+ const node = appStore.getState().state.indexes.nodes[componentId];
2533
+ const parentId = node.path[node.path.length - 1];
2534
+ const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
2535
+ const index = contentIds.indexOf(componentId);
2536
+ const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
2537
+ return {
2538
+ label,
2539
+ selector: node ? {
2540
+ index,
2541
+ zone: node.path[node.path.length - 1]
2542
+ } : null
2543
+ };
2544
+ })) || [];
2545
+ if (renderCount) {
2546
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
2547
+ }
2548
+ return breadcrumbs;
2549
+ }, [path, renderCount]);
2550
+ };
2551
+
2552
+ // ../core/components/Loader/index.tsx
2553
+ init_react_import();
2554
+
2555
+ // ../core/lib/index.ts
2556
+ init_react_import();
2557
+
2558
+ // ../core/lib/filter.ts
2559
+ init_react_import();
2560
+
2561
+ // ../core/lib/data/reorder.ts
2562
+ init_react_import();
2563
+
2564
+ // ../core/lib/data/replace.ts
2565
+ init_react_import();
2566
+
2567
+ // ../core/lib/use-reset-auto-zoom.ts
2568
+ init_react_import();
2531
2569
 
2532
2570
  // ../core/lib/get-zoom-config.ts
2533
2571
  init_react_import();
2534
2572
 
2573
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
2574
+ init_react_import();
2575
+ var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
2576
+
2577
+ // ../core/components/Loader/index.tsx
2578
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2579
+ var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
2580
+ var Loader = (_a) => {
2581
+ var _b = _a, {
2582
+ color,
2583
+ size = 16
2584
+ } = _b, props = __objRest(_b, [
2585
+ "color",
2586
+ "size"
2587
+ ]);
2588
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2589
+ "span",
2590
+ __spreadValues({
2591
+ className: getClassName2(),
2592
+ style: {
2593
+ width: size,
2594
+ height: size,
2595
+ color
2596
+ },
2597
+ "aria-label": "loading"
2598
+ }, props)
2599
+ );
2600
+ };
2601
+
2602
+ // ../core/components/SidebarSection/index.tsx
2603
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2604
+ var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
2605
+ var SidebarSection = ({
2606
+ children,
2607
+ title,
2608
+ background,
2609
+ showBreadcrumbs,
2610
+ noBorderTop,
2611
+ noPadding,
2612
+ isLoading
2613
+ }) => {
2614
+ const setUi = useAppStore((s) => s.setUi);
2615
+ const breadcrumbs = useBreadcrumbs(1);
2616
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2617
+ "div",
2618
+ {
2619
+ className: getClassName3({ noBorderTop, noPadding }),
2620
+ style: { background },
2621
+ children: [
2622
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("title"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumbs"), children: [
2623
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumb"), children: [
2624
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2625
+ "button",
2626
+ {
2627
+ type: "button",
2628
+ className: getClassName3("breadcrumbLabel"),
2629
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
2630
+ children: breadcrumb.label
2631
+ }
2632
+ ),
2633
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronRight, { size: 16 })
2634
+ ] }, i)) : null,
2635
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
2636
+ ] }) }),
2637
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("content"), children }),
2638
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 32 }) })
2639
+ ]
2640
+ }
2641
+ );
2642
+ };
2643
+
2644
+ // ../core/components/OutlineList/index.tsx
2645
+ init_react_import();
2646
+
2647
+ // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
2648
+ init_react_import();
2649
+ var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
2650
+
2651
+ // ../core/components/OutlineList/index.tsx
2652
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2653
+ var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
2654
+ var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
2655
+ var OutlineList = ({ children }) => {
2656
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: getClassName4(), children });
2657
+ };
2658
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
2659
+ OutlineList.Item = ({
2660
+ children,
2661
+ onClick
2662
+ }) => {
2663
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2664
+ "li",
2665
+ {
2666
+ className: getClassNameItem({ clickable: !!onClick }),
2667
+ onClick,
2668
+ children
2669
+ }
2670
+ );
2671
+ };
2672
+
2673
+ // ../core/lib/scroll-into-view.ts
2674
+ init_react_import();
2675
+ var scrollIntoView = (el) => {
2676
+ const oldStyle = __spreadValues({}, el.style);
2677
+ el.style.scrollMargin = "256px";
2678
+ if (el) {
2679
+ el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
2680
+ el.style.scrollMargin = oldStyle.scrollMargin || "";
2681
+ }
2682
+ };
2683
+
2684
+ // ../core/lib/get-frame.ts
2685
+ init_react_import();
2686
+ var getFrame = () => {
2687
+ if (typeof window === "undefined") return;
2688
+ let frameEl = document.querySelector("#preview-frame");
2689
+ if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
2690
+ return frameEl.contentDocument || document;
2691
+ }
2692
+ return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
2693
+ };
2694
+
2535
2695
  // src/HeadingAnalyzer.tsx
2536
2696
  var import_react_from_json = __toESM(require("react-from-json"));
2537
- var import_jsx_runtime2 = require("react/jsx-runtime");
2538
- var getClassName2 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2697
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2698
+ var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2539
2699
  var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
2540
2700
  var ReactFromJSON = import_react_from_json.default.default || import_react_from_json.default;
2541
2701
  var getOutline = ({ frame } = {}) => {
@@ -2590,8 +2750,8 @@ function buildHierarchy(frame) {
2590
2750
  var usePuck = (0, import_puck.createUsePuck)();
2591
2751
  var HeadingAnalyzer = () => {
2592
2752
  const data = usePuck((s) => s.appState.data);
2593
- const [hierarchy, setHierarchy] = (0, import_react10.useState)([]);
2594
- (0, import_react10.useEffect)(() => {
2753
+ const [hierarchy, setHierarchy] = (0, import_react11.useState)([]);
2754
+ (0, import_react11.useEffect)(() => {
2595
2755
  const frame = getFrame();
2596
2756
  let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
2597
2757
  const createHierarchy = () => {
@@ -2626,11 +2786,11 @@ var HeadingAnalyzer = () => {
2626
2786
  frameObserver.disconnect();
2627
2787
  };
2628
2788
  }, [data]);
2629
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: getClassName2(), children: [
2630
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2789
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
2790
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2631
2791
  "small",
2632
2792
  {
2633
- className: getClassName2("cssWarning"),
2793
+ className: getClassName5("cssWarning"),
2634
2794
  style: {
2635
2795
  color: "var(--puck-color-red-04)",
2636
2796
  display: "block",
@@ -2639,19 +2799,19 @@ var HeadingAnalyzer = () => {
2639
2799
  children: [
2640
2800
  "Heading analyzer styles not loaded. Please review the",
2641
2801
  " ",
2642
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2802
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2643
2803
  "."
2644
2804
  ]
2645
2805
  }
2646
2806
  ),
2647
- hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: "No headings." }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2807
+ hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No headings." }),
2808
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2649
2809
  ReactFromJSON,
2650
2810
  {
2651
2811
  mapping: {
2652
- Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: props.children }),
2653
- OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(OutlineList.Item, { children: [
2654
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2812
+ Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: props.children }),
2813
+ OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OutlineList.Item, { children: [
2814
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2655
2815
  "small",
2656
2816
  {
2657
2817
  className: getClassNameItem2({ missing: props.missing }),
@@ -2669,14 +2829,14 @@ var HeadingAnalyzer = () => {
2669
2829
  }, 2e3);
2670
2830
  }
2671
2831
  },
2672
- children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2673
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("b", { children: [
2832
+ children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2833
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2674
2834
  "H",
2675
2835
  props.rank
2676
2836
  ] }),
2677
2837
  ": Missing"
2678
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2679
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("b", { children: [
2838
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2839
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2680
2840
  "H",
2681
2841
  props.rank
2682
2842
  ] }),
@@ -2685,7 +2845,7 @@ var HeadingAnalyzer = () => {
2685
2845
  ] })
2686
2846
  }
2687
2847
  ) }),
2688
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OutlineList, { children: props.children })
2848
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: props.children })
2689
2849
  ] })
2690
2850
  },
2691
2851
  entry: {
@@ -2706,10 +2866,12 @@ var HeadingAnalyzer = () => {
2706
2866
  ] });
2707
2867
  };
2708
2868
  var headingAnalyzer = {
2709
- name: "heading-analyzer",
2710
- label: "Audit",
2711
- render: HeadingAnalyzer,
2712
- icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Heading1, {})
2869
+ overrides: {
2870
+ fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2871
+ children,
2872
+ /* @__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, {}) }) })
2873
+ ] })
2874
+ }
2713
2875
  };
2714
2876
  var HeadingAnalyzer_default = headingAnalyzer;
2715
2877
  /*! Bundled license information:
@@ -2722,45 +2884,10 @@ classnames/index.js:
2722
2884
  *)
2723
2885
 
2724
2886
  lucide-react/dist/esm/shared/src/utils.js:
2725
- (**
2726
- * @license lucide-react v0.468.0 - ISC
2727
- *
2728
- * This source code is licensed under the ISC license.
2729
- * See the LICENSE file in the root directory of this source tree.
2730
- *)
2731
-
2732
2887
  lucide-react/dist/esm/defaultAttributes.js:
2733
- (**
2734
- * @license lucide-react v0.468.0 - ISC
2735
- *
2736
- * This source code is licensed under the ISC license.
2737
- * See the LICENSE file in the root directory of this source tree.
2738
- *)
2739
-
2740
2888
  lucide-react/dist/esm/Icon.js:
2741
- (**
2742
- * @license lucide-react v0.468.0 - ISC
2743
- *
2744
- * This source code is licensed under the ISC license.
2745
- * See the LICENSE file in the root directory of this source tree.
2746
- *)
2747
-
2748
2889
  lucide-react/dist/esm/createLucideIcon.js:
2749
- (**
2750
- * @license lucide-react v0.468.0 - ISC
2751
- *
2752
- * This source code is licensed under the ISC license.
2753
- * See the LICENSE file in the root directory of this source tree.
2754
- *)
2755
-
2756
- lucide-react/dist/esm/icons/heading-1.js:
2757
- (**
2758
- * @license lucide-react v0.468.0 - ISC
2759
- *
2760
- * This source code is licensed under the ISC license.
2761
- * See the LICENSE file in the root directory of this source tree.
2762
- *)
2763
-
2890
+ lucide-react/dist/esm/icons/chevron-right.js:
2764
2891
  lucide-react/dist/esm/lucide-react.js:
2765
2892
  (**
2766
2893
  * @license lucide-react v0.468.0 - ISC