@measured/puck-plugin-heading-analyzer 0.20.0-canary.3badc0ce → 0.20.0-canary.5780043

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +316 -173
  2. package/dist/index.mjs +295 -152
  3. package/package.json +2 -2
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_react11 = require("react");
316
+ var import_react13 = 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();
@@ -474,7 +474,7 @@ var ChevronRight = createLucideIcon("ChevronRight", [
474
474
 
475
475
  // ../core/lib/use-breadcrumbs.ts
476
476
  init_react_import();
477
- var import_react10 = require("react");
477
+ var import_react12 = require("react");
478
478
 
479
479
  // ../core/store/index.ts
480
480
  init_react_import();
@@ -1000,6 +1000,275 @@ function insertAction(state, action, appStore) {
1000
1000
 
1001
1001
  // ../core/reducer/actions/replace.ts
1002
1002
  init_react_import();
1003
+
1004
+ // ../core/rsc.tsx
1005
+ init_react_import();
1006
+
1007
+ // ../core/components/ServerRender/index.tsx
1008
+ init_react_import();
1009
+
1010
+ // ../core/lib/data/setup-zone.ts
1011
+ init_react_import();
1012
+ var setupZone = (data, zoneKey) => {
1013
+ if (zoneKey === rootDroppableId) {
1014
+ return data;
1015
+ }
1016
+ const newData = __spreadProps(__spreadValues({}, data), {
1017
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1018
+ });
1019
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1020
+ return newData;
1021
+ };
1022
+
1023
+ // ../core/lib/use-slots.tsx
1024
+ init_react_import();
1025
+ var import_react4 = require("react");
1026
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
1027
+ const slotProps = (0, import_react4.useMemo)(() => {
1028
+ const mapped = mapSlots(
1029
+ item,
1030
+ (content, _parentId, propName, field, propPath) => {
1031
+ const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
1032
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
1033
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
1034
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
1035
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
1036
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
1037
+ }, dzProps), {
1038
+ zone: propName,
1039
+ content
1040
+ }));
1041
+ return Slot;
1042
+ },
1043
+ config
1044
+ ).props;
1045
+ return mapped;
1046
+ }, [config, item, readOnly, forceReadOnly]);
1047
+ const mergedProps = (0, import_react4.useMemo)(
1048
+ () => __spreadValues(__spreadValues({}, item.props), slotProps),
1049
+ [item.props, slotProps]
1050
+ );
1051
+ return mergedProps;
1052
+ }
1053
+
1054
+ // ../core/components/SlotRender/server.tsx
1055
+ init_react_import();
1056
+ var import_react5 = require("react");
1057
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1058
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRender, __spreadValues({}, props));
1059
+ var Item = ({
1060
+ config,
1061
+ item,
1062
+ metadata
1063
+ }) => {
1064
+ const Component = config.components[item.type];
1065
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
1066
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1067
+ Component.render,
1068
+ __spreadProps(__spreadValues({}, props), {
1069
+ puck: __spreadProps(__spreadValues({}, props.puck), {
1070
+ renderDropZone: DropZoneRender,
1071
+ metadata: metadata || {}
1072
+ })
1073
+ })
1074
+ );
1075
+ };
1076
+ var SlotRender = (0, import_react5.forwardRef)(
1077
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
1078
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, style, ref, children: content.map((item) => {
1079
+ if (!config.components[item.type]) {
1080
+ return null;
1081
+ }
1082
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1083
+ Item,
1084
+ {
1085
+ config,
1086
+ item,
1087
+ metadata
1088
+ },
1089
+ item.props.id
1090
+ );
1091
+ }) });
1092
+ }
1093
+ );
1094
+
1095
+ // ../core/components/ServerRender/index.tsx
1096
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1097
+ function DropZoneRender({
1098
+ zone,
1099
+ data,
1100
+ areaId = "root",
1101
+ config,
1102
+ metadata = {}
1103
+ }) {
1104
+ let zoneCompound = rootDroppableId;
1105
+ let content = (data == null ? void 0 : data.content) || [];
1106
+ if (!data || !config) {
1107
+ return null;
1108
+ }
1109
+ if (areaId !== rootAreaId && zone !== rootZone) {
1110
+ zoneCompound = `${areaId}:${zone}`;
1111
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
1112
+ }
1113
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: content.map((item) => {
1114
+ const Component = config.components[item.type];
1115
+ const props = __spreadProps(__spreadValues({}, item.props), {
1116
+ puck: {
1117
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1118
+ DropZoneRender,
1119
+ {
1120
+ zone: zone2,
1121
+ data,
1122
+ areaId: item.props.id,
1123
+ config,
1124
+ metadata
1125
+ }
1126
+ ),
1127
+ metadata,
1128
+ dragRef: null,
1129
+ isEditing: false
1130
+ }
1131
+ });
1132
+ const renderItem = __spreadProps(__spreadValues({}, item), { props });
1133
+ const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
1134
+ if (Component) {
1135
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
1136
+ }
1137
+ return null;
1138
+ }) });
1139
+ }
1140
+
1141
+ // ../core/lib/resolve-all-data.ts
1142
+ init_react_import();
1143
+
1144
+ // ../core/lib/resolve-component-data.ts
1145
+ init_react_import();
1146
+
1147
+ // ../core/lib/get-changed.ts
1148
+ init_react_import();
1149
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1150
+ var getChanged = (newItem, oldItem) => {
1151
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1152
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1153
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1154
+ return __spreadProps(__spreadValues({}, acc), {
1155
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1156
+ });
1157
+ }, {}) : {};
1158
+ };
1159
+
1160
+ // ../core/lib/resolve-component-data.ts
1161
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1162
+ var cache = { lastChange: {} };
1163
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1164
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1165
+ const resolvedItem = __spreadValues({}, item);
1166
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1167
+ const id = "id" in item.props ? item.props.id : "root";
1168
+ if (shouldRunResolver) {
1169
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1170
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1171
+ return { node: resolved, didChange: false };
1172
+ }
1173
+ const changed = getChanged(item, oldItem);
1174
+ if (onResolveStart) {
1175
+ onResolveStart(item);
1176
+ }
1177
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1178
+ changed,
1179
+ lastData: oldItem,
1180
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1181
+ trigger
1182
+ });
1183
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1184
+ if (Object.keys(readOnly).length) {
1185
+ resolvedItem.readOnly = readOnly;
1186
+ }
1187
+ }
1188
+ let itemWithResolvedChildren = yield mapSlots(
1189
+ resolvedItem,
1190
+ (content) => __async(void 0, null, function* () {
1191
+ return yield Promise.all(
1192
+ content.map(
1193
+ (childItem) => __async(void 0, null, function* () {
1194
+ return (yield resolveComponentData(
1195
+ childItem,
1196
+ config,
1197
+ metadata,
1198
+ onResolveStart,
1199
+ onResolveEnd,
1200
+ trigger
1201
+ )).node;
1202
+ })
1203
+ )
1204
+ );
1205
+ }),
1206
+ config
1207
+ );
1208
+ if (shouldRunResolver && onResolveEnd) {
1209
+ onResolveEnd(resolvedItem);
1210
+ }
1211
+ cache.lastChange[id] = {
1212
+ item,
1213
+ resolved: itemWithResolvedChildren
1214
+ };
1215
+ return {
1216
+ node: itemWithResolvedChildren,
1217
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1218
+ };
1219
+ });
1220
+
1221
+ // ../core/lib/data/default-data.ts
1222
+ init_react_import();
1223
+
1224
+ // ../core/lib/data/to-component.ts
1225
+ init_react_import();
1226
+
1227
+ // ../core/lib/transform-props.ts
1228
+ init_react_import();
1229
+
1230
+ // ../core/lib/migrate.ts
1231
+ init_react_import();
1232
+
1233
+ // ../core/store/default-app-state.ts
1234
+ init_react_import();
1235
+
1236
+ // ../core/components/ViewportControls/default-viewports.ts
1237
+ init_react_import();
1238
+ var defaultViewports = [
1239
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1240
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1241
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1242
+ ];
1243
+
1244
+ // ../core/store/default-app-state.ts
1245
+ var defaultAppState = {
1246
+ data: { content: [], root: {}, zones: {} },
1247
+ ui: {
1248
+ leftSideBarVisible: true,
1249
+ rightSideBarVisible: true,
1250
+ arrayState: {},
1251
+ itemSelector: null,
1252
+ componentList: {},
1253
+ isDragging: false,
1254
+ previewMode: "edit",
1255
+ viewports: {
1256
+ current: {
1257
+ width: defaultViewports[0].width,
1258
+ height: defaultViewports[0].height || "auto"
1259
+ },
1260
+ options: [],
1261
+ controlsVisible: true
1262
+ },
1263
+ field: { focus: null }
1264
+ },
1265
+ indexes: {
1266
+ nodes: {},
1267
+ zones: {}
1268
+ }
1269
+ };
1270
+
1271
+ // ../core/reducer/actions/replace.ts
1003
1272
  var replaceAction = (state, action, appStore) => {
1004
1273
  const [parentId] = action.destinationZone.split(":");
1005
1274
  const idsInPath = getIdsForParent(action.destinationZone, state);
@@ -1250,21 +1519,6 @@ var removeAction = (state, action, appStore) => {
1250
1519
 
1251
1520
  // ../core/reducer/actions/register-zone.ts
1252
1521
  init_react_import();
1253
-
1254
- // ../core/lib/data/setup-zone.ts
1255
- init_react_import();
1256
- var setupZone = (data, zoneKey) => {
1257
- if (zoneKey === rootDroppableId) {
1258
- return data;
1259
- }
1260
- const newData = __spreadProps(__spreadValues({}, data), {
1261
- zones: data.zones ? __spreadValues({}, data.zones) : {}
1262
- });
1263
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1264
- return newData;
1265
- };
1266
-
1267
- // ../core/reducer/actions/register-zone.ts
1268
1522
  var zoneCache = {};
1269
1523
  function registerZoneAction(state, action) {
1270
1524
  if (zoneCache[action.zone]) {
@@ -1417,14 +1671,6 @@ function createReducer({
1417
1671
  );
1418
1672
  }
1419
1673
 
1420
- // ../core/components/ViewportControls/default-viewports.ts
1421
- init_react_import();
1422
- var defaultViewports = [
1423
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1424
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1425
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1426
- ];
1427
-
1428
1674
  // ../../node_modules/zustand/esm/vanilla.mjs
1429
1675
  init_react_import();
1430
1676
  var createStoreImpl = (createState) => {
@@ -1452,15 +1698,15 @@ var createStore = (createState) => createState ? createStoreImpl(createState) :
1452
1698
 
1453
1699
  // ../../node_modules/zustand/esm/react.mjs
1454
1700
  init_react_import();
1455
- var import_react4 = __toESM(require("react"), 1);
1701
+ var import_react6 = __toESM(require("react"), 1);
1456
1702
  var identity = (arg) => arg;
1457
1703
  function useStore(api, selector = identity) {
1458
- const slice = import_react4.default.useSyncExternalStore(
1704
+ const slice = import_react6.default.useSyncExternalStore(
1459
1705
  api.subscribe,
1460
1706
  () => selector(api.getState()),
1461
1707
  () => selector(api.getInitialState())
1462
1708
  );
1463
- import_react4.default.useDebugValue(slice);
1709
+ import_react6.default.useDebugValue(slice);
1464
1710
  return slice;
1465
1711
  }
1466
1712
  var createImpl = (createState) => {
@@ -1499,15 +1745,15 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
1499
1745
  var subscribeWithSelector = subscribeWithSelectorImpl;
1500
1746
 
1501
1747
  // ../core/store/index.ts
1502
- var import_react9 = require("react");
1748
+ var import_react11 = require("react");
1503
1749
 
1504
1750
  // ../core/store/slices/history.ts
1505
1751
  init_react_import();
1506
- var import_react6 = require("react");
1752
+ var import_react8 = require("react");
1507
1753
 
1508
1754
  // ../core/lib/use-hotkey.ts
1509
1755
  init_react_import();
1510
- var import_react5 = require("react");
1756
+ var import_react7 = require("react");
1511
1757
  var useHotkeyStore = create()(
1512
1758
  subscribeWithSelector((set) => ({
1513
1759
  held: {},
@@ -1656,7 +1902,7 @@ var createNodesSlice = (set, get) => ({
1656
1902
 
1657
1903
  // ../core/store/slices/permissions.ts
1658
1904
  init_react_import();
1659
- var import_react7 = require("react");
1905
+ var import_react9 = require("react");
1660
1906
 
1661
1907
  // ../core/lib/data/flatten-data.ts
1662
1908
  init_react_import();
@@ -1674,19 +1920,6 @@ var flattenData = (state, config) => {
1674
1920
  return data;
1675
1921
  };
1676
1922
 
1677
- // ../core/lib/get-changed.ts
1678
- init_react_import();
1679
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1680
- var getChanged = (newItem, oldItem) => {
1681
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1682
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1683
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1684
- return __spreadProps(__spreadValues({}, acc), {
1685
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1686
- });
1687
- }, {}) : {};
1688
- };
1689
-
1690
1923
  // ../core/store/slices/permissions.ts
1691
1924
  var createPermissionsSlice = (set, get) => {
1692
1925
  const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
@@ -1795,7 +2028,7 @@ var createPermissionsSlice = (set, get) => {
1795
2028
 
1796
2029
  // ../core/store/slices/fields.ts
1797
2030
  init_react_import();
1798
- var import_react8 = require("react");
2031
+ var import_react10 = require("react");
1799
2032
  var createFieldsSlice = (_set, _get) => {
1800
2033
  return {
1801
2034
  fields: {},
@@ -1805,68 +2038,6 @@ var createFieldsSlice = (_set, _get) => {
1805
2038
  };
1806
2039
  };
1807
2040
 
1808
- // ../core/lib/resolve-component-data.ts
1809
- init_react_import();
1810
- var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1811
- var cache = { lastChange: {} };
1812
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1813
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1814
- const resolvedItem = __spreadValues({}, item);
1815
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1816
- const id = "id" in item.props ? item.props.id : "root";
1817
- if (shouldRunResolver) {
1818
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1819
- if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1820
- return { node: resolved, didChange: false };
1821
- }
1822
- const changed = getChanged(item, oldItem);
1823
- if (onResolveStart) {
1824
- onResolveStart(item);
1825
- }
1826
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1827
- changed,
1828
- lastData: oldItem,
1829
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1830
- trigger
1831
- });
1832
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1833
- if (Object.keys(readOnly).length) {
1834
- resolvedItem.readOnly = readOnly;
1835
- }
1836
- }
1837
- let itemWithResolvedChildren = yield mapSlots(
1838
- 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
- }),
1855
- config
1856
- );
1857
- if (shouldRunResolver && onResolveEnd) {
1858
- onResolveEnd(resolvedItem);
1859
- }
1860
- cache.lastChange[id] = {
1861
- item,
1862
- resolved: itemWithResolvedChildren
1863
- };
1864
- return {
1865
- node: itemWithResolvedChildren,
1866
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1867
- };
1868
- });
1869
-
1870
2041
  // ../core/lib/data/to-root.ts
1871
2042
  init_react_import();
1872
2043
  var toRoot = (item) => {
@@ -1884,34 +2055,6 @@ var toRoot = (item) => {
1884
2055
  return { props: {}, readOnly };
1885
2056
  };
1886
2057
 
1887
- // ../core/store/default-app-state.ts
1888
- init_react_import();
1889
- var defaultAppState = {
1890
- data: { content: [], root: {}, zones: {} },
1891
- ui: {
1892
- leftSideBarVisible: true,
1893
- rightSideBarVisible: true,
1894
- arrayState: {},
1895
- itemSelector: null,
1896
- componentList: {},
1897
- isDragging: false,
1898
- previewMode: "edit",
1899
- viewports: {
1900
- current: {
1901
- width: defaultViewports[0].width,
1902
- height: defaultViewports[0].height || "auto"
1903
- },
1904
- options: [],
1905
- controlsVisible: true
1906
- },
1907
- field: { focus: null }
1908
- },
1909
- indexes: {
1910
- nodes: {},
1911
- zones: {}
1912
- }
1913
- };
1914
-
1915
2058
  // ../core/store/index.ts
1916
2059
  var defaultPageFields = {
1917
2060
  title: { type: "text" }
@@ -2088,13 +2231,13 @@ var createAppStore = (initialAppStore) => create()(
2088
2231
  });
2089
2232
  })
2090
2233
  );
2091
- var appStoreContext = (0, import_react9.createContext)(createAppStore());
2234
+ var appStoreContext = (0, import_react11.createContext)(createAppStore());
2092
2235
  function useAppStore(selector) {
2093
- const context = (0, import_react9.useContext)(appStoreContext);
2236
+ const context = (0, import_react11.useContext)(appStoreContext);
2094
2237
  return useStore(context, selector);
2095
2238
  }
2096
2239
  function useAppStoreApi() {
2097
- return (0, import_react9.useContext)(appStoreContext);
2240
+ return (0, import_react11.useContext)(appStoreContext);
2098
2241
  }
2099
2242
 
2100
2243
  // ../core/lib/use-breadcrumbs.ts
@@ -2109,7 +2252,7 @@ var useBreadcrumbs = (renderCount) => {
2109
2252
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
2110
2253
  });
2111
2254
  const appStore = useAppStoreApi();
2112
- return (0, import_react10.useMemo)(() => {
2255
+ return (0, import_react12.useMemo)(() => {
2113
2256
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
2114
2257
  var _a, _b, _c;
2115
2258
  const [componentId] = zoneCompound.split(":");
@@ -2159,7 +2302,7 @@ init_react_import();
2159
2302
  var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
2160
2303
 
2161
2304
  // ../core/components/Loader/index.tsx
2162
- var import_jsx_runtime2 = require("react/jsx-runtime");
2305
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2163
2306
  var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
2164
2307
  var Loader = (_a) => {
2165
2308
  var _b = _a, {
@@ -2169,7 +2312,7 @@ var Loader = (_a) => {
2169
2312
  "color",
2170
2313
  "size"
2171
2314
  ]);
2172
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2315
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2173
2316
  "span",
2174
2317
  __spreadValues({
2175
2318
  className: getClassName2(),
@@ -2184,7 +2327,7 @@ var Loader = (_a) => {
2184
2327
  };
2185
2328
 
2186
2329
  // ../core/components/SidebarSection/index.tsx
2187
- var import_jsx_runtime3 = require("react/jsx-runtime");
2330
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2188
2331
  var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
2189
2332
  var SidebarSection = ({
2190
2333
  children,
@@ -2197,15 +2340,15 @@ var SidebarSection = ({
2197
2340
  }) => {
2198
2341
  const setUi = useAppStore((s) => s.setUi);
2199
2342
  const breadcrumbs = useBreadcrumbs(1);
2200
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2343
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2201
2344
  "div",
2202
2345
  {
2203
2346
  className: getClassName3({ noBorderTop, noPadding }),
2204
2347
  style: { background },
2205
2348
  children: [
2206
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("title"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumbs"), children: [
2207
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumb"), children: [
2208
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2349
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName3("title"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName3("breadcrumbs"), children: [
2350
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName3("breadcrumb"), children: [
2351
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2209
2352
  "button",
2210
2353
  {
2211
2354
  type: "button",
@@ -2214,12 +2357,12 @@ var SidebarSection = ({
2214
2357
  children: breadcrumb.label
2215
2358
  }
2216
2359
  ),
2217
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronRight, { size: 16 })
2360
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronRight, { size: 16 })
2218
2361
  ] }, i)) : null,
2219
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
2362
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName3("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
2220
2363
  ] }) }),
2221
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("content"), children }),
2222
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 32 }) })
2364
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName3("content"), children }),
2365
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Loader, { size: 32 }) })
2223
2366
  ]
2224
2367
  }
2225
2368
  );
@@ -2233,18 +2376,18 @@ init_react_import();
2233
2376
  var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
2234
2377
 
2235
2378
  // ../core/components/OutlineList/index.tsx
2236
- var import_jsx_runtime4 = require("react/jsx-runtime");
2379
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2237
2380
  var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
2238
2381
  var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
2239
2382
  var OutlineList = ({ children }) => {
2240
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: getClassName4(), children });
2383
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: getClassName4(), children });
2241
2384
  };
2242
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
2385
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
2243
2386
  OutlineList.Item = ({
2244
2387
  children,
2245
2388
  onClick
2246
2389
  }) => {
2247
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2390
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2248
2391
  "li",
2249
2392
  {
2250
2393
  className: getClassNameItem({ clickable: !!onClick }),
@@ -2278,7 +2421,7 @@ var getFrame = () => {
2278
2421
 
2279
2422
  // src/HeadingAnalyzer.tsx
2280
2423
  var import_react_from_json = __toESM(require("react-from-json"));
2281
- var import_jsx_runtime5 = require("react/jsx-runtime");
2424
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2282
2425
  var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2283
2426
  var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
2284
2427
  var ReactFromJSON = import_react_from_json.default.default || import_react_from_json.default;
@@ -2334,8 +2477,8 @@ function buildHierarchy(frame) {
2334
2477
  var usePuck = (0, import_puck.createUsePuck)();
2335
2478
  var HeadingAnalyzer = () => {
2336
2479
  const data = usePuck((s) => s.appState.data);
2337
- const [hierarchy, setHierarchy] = (0, import_react11.useState)([]);
2338
- (0, import_react11.useEffect)(() => {
2480
+ const [hierarchy, setHierarchy] = (0, import_react13.useState)([]);
2481
+ (0, import_react13.useEffect)(() => {
2339
2482
  const frame = getFrame();
2340
2483
  let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
2341
2484
  const createHierarchy = () => {
@@ -2370,8 +2513,8 @@ var HeadingAnalyzer = () => {
2370
2513
  frameObserver.disconnect();
2371
2514
  };
2372
2515
  }, [data]);
2373
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
2374
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2516
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassName5(), children: [
2517
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2375
2518
  "small",
2376
2519
  {
2377
2520
  className: getClassName5("cssWarning"),
@@ -2383,19 +2526,19 @@ var HeadingAnalyzer = () => {
2383
2526
  children: [
2384
2527
  "Heading analyzer styles not loaded. Please review the",
2385
2528
  " ",
2386
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2529
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2387
2530
  "."
2388
2531
  ]
2389
2532
  }
2390
2533
  ),
2391
- hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No headings." }),
2392
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2534
+ hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: "No headings." }),
2535
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2393
2536
  ReactFromJSON,
2394
2537
  {
2395
2538
  mapping: {
2396
- Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: props.children }),
2397
- OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OutlineList.Item, { children: [
2398
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2539
+ Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: props.children }),
2540
+ OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(OutlineList.Item, { children: [
2541
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2399
2542
  "small",
2400
2543
  {
2401
2544
  className: getClassNameItem2({ missing: props.missing }),
@@ -2413,14 +2556,14 @@ var HeadingAnalyzer = () => {
2413
2556
  }, 2e3);
2414
2557
  }
2415
2558
  },
2416
- children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2417
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2559
+ children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2560
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("b", { children: [
2418
2561
  "H",
2419
2562
  props.rank
2420
2563
  ] }),
2421
2564
  ": Missing"
2422
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2423
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
2565
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2566
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("b", { children: [
2424
2567
  "H",
2425
2568
  props.rank
2426
2569
  ] }),
@@ -2429,7 +2572,7 @@ var HeadingAnalyzer = () => {
2429
2572
  ] })
2430
2573
  }
2431
2574
  ) }),
2432
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: props.children })
2575
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OutlineList, { children: props.children })
2433
2576
  ] })
2434
2577
  },
2435
2578
  entry: {
@@ -2451,9 +2594,9 @@ var HeadingAnalyzer = () => {
2451
2594
  };
2452
2595
  var headingAnalyzer = {
2453
2596
  overrides: {
2454
- fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2597
+ fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2455
2598
  children,
2456
- /* @__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, {}) }) })
2599
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeadingAnalyzer, {}) }) })
2457
2600
  ] })
2458
2601
  }
2459
2602
  };
package/dist/index.mjs CHANGED
@@ -462,7 +462,7 @@ var ChevronRight = createLucideIcon("ChevronRight", [
462
462
 
463
463
  // ../core/lib/use-breadcrumbs.ts
464
464
  init_react_import();
465
- import { useMemo } from "react";
465
+ import { useMemo as useMemo2 } from "react";
466
466
 
467
467
  // ../core/store/index.ts
468
468
  init_react_import();
@@ -988,6 +988,275 @@ function insertAction(state, action, appStore) {
988
988
 
989
989
  // ../core/reducer/actions/replace.ts
990
990
  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
991
1260
  var replaceAction = (state, action, appStore) => {
992
1261
  const [parentId] = action.destinationZone.split(":");
993
1262
  const idsInPath = getIdsForParent(action.destinationZone, state);
@@ -1238,21 +1507,6 @@ var removeAction = (state, action, appStore) => {
1238
1507
 
1239
1508
  // ../core/reducer/actions/register-zone.ts
1240
1509
  init_react_import();
1241
-
1242
- // ../core/lib/data/setup-zone.ts
1243
- init_react_import();
1244
- var setupZone = (data, zoneKey) => {
1245
- if (zoneKey === rootDroppableId) {
1246
- return data;
1247
- }
1248
- const newData = __spreadProps(__spreadValues({}, data), {
1249
- zones: data.zones ? __spreadValues({}, data.zones) : {}
1250
- });
1251
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1252
- return newData;
1253
- };
1254
-
1255
- // ../core/reducer/actions/register-zone.ts
1256
1510
  var zoneCache = {};
1257
1511
  function registerZoneAction(state, action) {
1258
1512
  if (zoneCache[action.zone]) {
@@ -1405,14 +1659,6 @@ function createReducer({
1405
1659
  );
1406
1660
  }
1407
1661
 
1408
- // ../core/components/ViewportControls/default-viewports.ts
1409
- init_react_import();
1410
- var defaultViewports = [
1411
- { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1412
- { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1413
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1414
- ];
1415
-
1416
1662
  // ../../node_modules/zustand/esm/vanilla.mjs
1417
1663
  init_react_import();
1418
1664
  var createStoreImpl = (createState) => {
@@ -1662,19 +1908,6 @@ var flattenData = (state, config) => {
1662
1908
  return data;
1663
1909
  };
1664
1910
 
1665
- // ../core/lib/get-changed.ts
1666
- init_react_import();
1667
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1668
- var getChanged = (newItem, oldItem) => {
1669
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1670
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1671
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1672
- return __spreadProps(__spreadValues({}, acc), {
1673
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1674
- });
1675
- }, {}) : {};
1676
- };
1677
-
1678
1911
  // ../core/store/slices/permissions.ts
1679
1912
  var createPermissionsSlice = (set, get) => {
1680
1913
  const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
@@ -1793,68 +2026,6 @@ var createFieldsSlice = (_set, _get) => {
1793
2026
  };
1794
2027
  };
1795
2028
 
1796
- // ../core/lib/resolve-component-data.ts
1797
- init_react_import();
1798
- var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1799
- var cache = { lastChange: {} };
1800
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1801
- const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1802
- const resolvedItem = __spreadValues({}, item);
1803
- const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1804
- const id = "id" in item.props ? item.props.id : "root";
1805
- if (shouldRunResolver) {
1806
- const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1807
- if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1808
- return { node: resolved, didChange: false };
1809
- }
1810
- const changed = getChanged(item, oldItem);
1811
- if (onResolveStart) {
1812
- onResolveStart(item);
1813
- }
1814
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1815
- changed,
1816
- lastData: oldItem,
1817
- metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1818
- trigger
1819
- });
1820
- resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1821
- if (Object.keys(readOnly).length) {
1822
- resolvedItem.readOnly = readOnly;
1823
- }
1824
- }
1825
- let itemWithResolvedChildren = yield mapSlots(
1826
- resolvedItem,
1827
- (content) => __async(void 0, null, function* () {
1828
- return yield Promise.all(
1829
- content.map(
1830
- (childItem) => __async(void 0, null, function* () {
1831
- return (yield resolveComponentData(
1832
- childItem,
1833
- config,
1834
- metadata,
1835
- onResolveStart,
1836
- onResolveEnd,
1837
- trigger
1838
- )).node;
1839
- })
1840
- )
1841
- );
1842
- }),
1843
- config
1844
- );
1845
- if (shouldRunResolver && onResolveEnd) {
1846
- onResolveEnd(resolvedItem);
1847
- }
1848
- cache.lastChange[id] = {
1849
- item,
1850
- resolved: itemWithResolvedChildren
1851
- };
1852
- return {
1853
- node: itemWithResolvedChildren,
1854
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1855
- };
1856
- });
1857
-
1858
2029
  // ../core/lib/data/to-root.ts
1859
2030
  init_react_import();
1860
2031
  var toRoot = (item) => {
@@ -1872,34 +2043,6 @@ var toRoot = (item) => {
1872
2043
  return { props: {}, readOnly };
1873
2044
  };
1874
2045
 
1875
- // ../core/store/default-app-state.ts
1876
- init_react_import();
1877
- var defaultAppState = {
1878
- data: { content: [], root: {}, zones: {} },
1879
- ui: {
1880
- leftSideBarVisible: true,
1881
- rightSideBarVisible: true,
1882
- arrayState: {},
1883
- itemSelector: null,
1884
- componentList: {},
1885
- isDragging: false,
1886
- previewMode: "edit",
1887
- viewports: {
1888
- current: {
1889
- width: defaultViewports[0].width,
1890
- height: defaultViewports[0].height || "auto"
1891
- },
1892
- options: [],
1893
- controlsVisible: true
1894
- },
1895
- field: { focus: null }
1896
- },
1897
- indexes: {
1898
- nodes: {},
1899
- zones: {}
1900
- }
1901
- };
1902
-
1903
2046
  // ../core/store/index.ts
1904
2047
  var defaultPageFields = {
1905
2048
  title: { type: "text" }
@@ -2097,7 +2240,7 @@ var useBreadcrumbs = (renderCount) => {
2097
2240
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
2098
2241
  });
2099
2242
  const appStore = useAppStoreApi();
2100
- return useMemo(() => {
2243
+ return useMemo2(() => {
2101
2244
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
2102
2245
  var _a, _b, _c;
2103
2246
  const [componentId] = zoneCompound.split(":");
@@ -2147,7 +2290,7 @@ init_react_import();
2147
2290
  var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
2148
2291
 
2149
2292
  // ../core/components/Loader/index.tsx
2150
- import { jsx as jsx2 } from "react/jsx-runtime";
2293
+ import { jsx as jsx4 } from "react/jsx-runtime";
2151
2294
  var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
2152
2295
  var Loader = (_a) => {
2153
2296
  var _b = _a, {
@@ -2157,7 +2300,7 @@ var Loader = (_a) => {
2157
2300
  "color",
2158
2301
  "size"
2159
2302
  ]);
2160
- return /* @__PURE__ */ jsx2(
2303
+ return /* @__PURE__ */ jsx4(
2161
2304
  "span",
2162
2305
  __spreadValues({
2163
2306
  className: getClassName2(),
@@ -2172,7 +2315,7 @@ var Loader = (_a) => {
2172
2315
  };
2173
2316
 
2174
2317
  // ../core/components/SidebarSection/index.tsx
2175
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
2318
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
2176
2319
  var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
2177
2320
  var SidebarSection = ({
2178
2321
  children,
@@ -2191,9 +2334,9 @@ var SidebarSection = ({
2191
2334
  className: getClassName3({ noBorderTop, noPadding }),
2192
2335
  style: { background },
2193
2336
  children: [
2194
- /* @__PURE__ */ jsx3("div", { className: getClassName3("title"), children: /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumbs"), children: [
2337
+ /* @__PURE__ */ jsx5("div", { className: getClassName3("title"), children: /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumbs"), children: [
2195
2338
  showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumb"), children: [
2196
- /* @__PURE__ */ jsx3(
2339
+ /* @__PURE__ */ jsx5(
2197
2340
  "button",
2198
2341
  {
2199
2342
  type: "button",
@@ -2202,12 +2345,12 @@ var SidebarSection = ({
2202
2345
  children: breadcrumb.label
2203
2346
  }
2204
2347
  ),
2205
- /* @__PURE__ */ jsx3(ChevronRight, { size: 16 })
2348
+ /* @__PURE__ */ jsx5(ChevronRight, { size: 16 })
2206
2349
  ] }, i)) : null,
2207
- /* @__PURE__ */ jsx3("div", { className: getClassName3("heading"), children: /* @__PURE__ */ jsx3(Heading, { rank: "2", size: "xs", children: title }) })
2350
+ /* @__PURE__ */ jsx5("div", { className: getClassName3("heading"), children: /* @__PURE__ */ jsx5(Heading, { rank: "2", size: "xs", children: title }) })
2208
2351
  ] }) }),
2209
- /* @__PURE__ */ jsx3("div", { className: getClassName3("content"), children }),
2210
- isLoading && /* @__PURE__ */ jsx3("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx3(Loader, { size: 32 }) })
2352
+ /* @__PURE__ */ jsx5("div", { className: getClassName3("content"), children }),
2353
+ isLoading && /* @__PURE__ */ jsx5("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx5(Loader, { size: 32 }) })
2211
2354
  ]
2212
2355
  }
2213
2356
  );
@@ -2221,18 +2364,18 @@ init_react_import();
2221
2364
  var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
2222
2365
 
2223
2366
  // ../core/components/OutlineList/index.tsx
2224
- import { jsx as jsx4 } from "react/jsx-runtime";
2367
+ import { jsx as jsx6 } from "react/jsx-runtime";
2225
2368
  var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
2226
2369
  var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
2227
2370
  var OutlineList = ({ children }) => {
2228
- return /* @__PURE__ */ jsx4("ul", { className: getClassName4(), children });
2371
+ return /* @__PURE__ */ jsx6("ul", { className: getClassName4(), children });
2229
2372
  };
2230
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx4("div", { className: getClassNameItem({ clickable: true }), children });
2373
+ OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx6("div", { className: getClassNameItem({ clickable: true }), children });
2231
2374
  OutlineList.Item = ({
2232
2375
  children,
2233
2376
  onClick
2234
2377
  }) => {
2235
- return /* @__PURE__ */ jsx4(
2378
+ return /* @__PURE__ */ jsx6(
2236
2379
  "li",
2237
2380
  {
2238
2381
  className: getClassNameItem({ clickable: !!onClick }),
@@ -2266,7 +2409,7 @@ var getFrame = () => {
2266
2409
 
2267
2410
  // src/HeadingAnalyzer.tsx
2268
2411
  import ReactFromJSONModule from "react-from-json";
2269
- import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
2412
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
2270
2413
  var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
2271
2414
  var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
2272
2415
  var ReactFromJSON = ReactFromJSONModule.default || ReactFromJSONModule;
@@ -2371,19 +2514,19 @@ var HeadingAnalyzer = () => {
2371
2514
  children: [
2372
2515
  "Heading analyzer styles not loaded. Please review the",
2373
2516
  " ",
2374
- /* @__PURE__ */ jsx5("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2517
+ /* @__PURE__ */ jsx7("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
2375
2518
  "."
2376
2519
  ]
2377
2520
  }
2378
2521
  ),
2379
- hierarchy.length === 0 && /* @__PURE__ */ jsx5("div", { children: "No headings." }),
2380
- /* @__PURE__ */ jsx5(OutlineList, { children: /* @__PURE__ */ jsx5(
2522
+ hierarchy.length === 0 && /* @__PURE__ */ jsx7("div", { children: "No headings." }),
2523
+ /* @__PURE__ */ jsx7(OutlineList, { children: /* @__PURE__ */ jsx7(
2381
2524
  ReactFromJSON,
2382
2525
  {
2383
2526
  mapping: {
2384
- Root: (props) => /* @__PURE__ */ jsx5(Fragment, { children: props.children }),
2527
+ Root: (props) => /* @__PURE__ */ jsx7(Fragment2, { children: props.children }),
2385
2528
  OutlineListItem: (props) => /* @__PURE__ */ jsxs2(OutlineList.Item, { children: [
2386
- /* @__PURE__ */ jsx5(OutlineList.Clickable, { children: /* @__PURE__ */ jsx5(
2529
+ /* @__PURE__ */ jsx7(OutlineList.Clickable, { children: /* @__PURE__ */ jsx7(
2387
2530
  "small",
2388
2531
  {
2389
2532
  className: getClassNameItem2({ missing: props.missing }),
@@ -2401,13 +2544,13 @@ var HeadingAnalyzer = () => {
2401
2544
  }, 2e3);
2402
2545
  }
2403
2546
  },
2404
- children: props.missing ? /* @__PURE__ */ jsxs2(Fragment, { children: [
2547
+ children: props.missing ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
2405
2548
  /* @__PURE__ */ jsxs2("b", { children: [
2406
2549
  "H",
2407
2550
  props.rank
2408
2551
  ] }),
2409
2552
  ": Missing"
2410
- ] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
2553
+ ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
2411
2554
  /* @__PURE__ */ jsxs2("b", { children: [
2412
2555
  "H",
2413
2556
  props.rank
@@ -2417,7 +2560,7 @@ var HeadingAnalyzer = () => {
2417
2560
  ] })
2418
2561
  }
2419
2562
  ) }),
2420
- /* @__PURE__ */ jsx5(OutlineList, { children: props.children })
2563
+ /* @__PURE__ */ jsx7(OutlineList, { children: props.children })
2421
2564
  ] })
2422
2565
  },
2423
2566
  entry: {
@@ -2439,9 +2582,9 @@ var HeadingAnalyzer = () => {
2439
2582
  };
2440
2583
  var headingAnalyzer = {
2441
2584
  overrides: {
2442
- fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(Fragment, { children: [
2585
+ fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
2443
2586
  children,
2444
- /* @__PURE__ */ jsx5("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ jsx5(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ jsx5(HeadingAnalyzer, {}) }) })
2587
+ /* @__PURE__ */ jsx7("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ jsx7(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ jsx7(HeadingAnalyzer, {}) }) })
2445
2588
  ] })
2446
2589
  }
2447
2590
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.20.0-canary.3badc0ce",
3
+ "version": "0.20.0-canary.5780043",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "devDependencies": {
28
- "@measured/puck": "^0.20.0-canary.3badc0ce",
28
+ "@measured/puck": "^0.20.0-canary.5780043",
29
29
  "@types/react": "^19.0.1",
30
30
  "@types/react-dom": "^19.0.2",
31
31
  "eslint": "^7.32.0",