@measured/puck-plugin-heading-analyzer 0.19.1-canary.c0055df8 → 0.19.1
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 +338 -176
- package/dist/index.mjs +317 -155
- 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
|
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
|
477
|
+
var import_react12 = require("react");
|
478
478
|
|
479
479
|
// ../core/store/index.ts
|
480
480
|
init_react_import();
|
@@ -675,9 +675,10 @@ var stripSlots = (data, config) => {
|
|
675
675
|
};
|
676
676
|
|
677
677
|
// ../core/lib/data/flatten-node.ts
|
678
|
+
var { flatten: flatten2, unflatten } = import_flat.default;
|
678
679
|
var flattenNode = (node, config) => {
|
679
680
|
return __spreadProps(__spreadValues({}, node), {
|
680
|
-
props: (
|
681
|
+
props: flatten2(stripSlots(node, config).props)
|
681
682
|
});
|
682
683
|
};
|
683
684
|
|
@@ -999,6 +1000,275 @@ function insertAction(state, action, appStore) {
|
|
999
1000
|
|
1000
1001
|
// ../core/reducer/actions/replace.ts
|
1001
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
|
1002
1272
|
var replaceAction = (state, action, appStore) => {
|
1003
1273
|
const [parentId] = action.destinationZone.split(":");
|
1004
1274
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
@@ -1009,9 +1279,27 @@ var replaceAction = (state, action, appStore) => {
|
|
1009
1279
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1010
1280
|
);
|
1011
1281
|
}
|
1012
|
-
const
|
1282
|
+
const newSlotIds = [];
|
1283
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
1284
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
1285
|
+
return contents.map((item) => {
|
1286
|
+
const id = generateId(item.type);
|
1287
|
+
return __spreadProps(__spreadValues({}, item), {
|
1288
|
+
props: __spreadValues({ id }, item.props)
|
1289
|
+
});
|
1290
|
+
});
|
1291
|
+
});
|
1292
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
1293
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
1294
|
+
const id = zoneCompound.split(":")[0];
|
1295
|
+
if (id === originalId) {
|
1296
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
1297
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
1298
|
+
}
|
1299
|
+
}
|
1300
|
+
});
|
1013
1301
|
return walkAppState(
|
1014
|
-
|
1302
|
+
stateWithDeepSlotsRemoved,
|
1015
1303
|
appStore.config,
|
1016
1304
|
(content, zoneCompound) => {
|
1017
1305
|
const newContent = [...content];
|
@@ -1231,21 +1519,6 @@ var removeAction = (state, action, appStore) => {
|
|
1231
1519
|
|
1232
1520
|
// ../core/reducer/actions/register-zone.ts
|
1233
1521
|
init_react_import();
|
1234
|
-
|
1235
|
-
// ../core/lib/data/setup-zone.ts
|
1236
|
-
init_react_import();
|
1237
|
-
var setupZone = (data, zoneKey) => {
|
1238
|
-
if (zoneKey === rootDroppableId) {
|
1239
|
-
return data;
|
1240
|
-
}
|
1241
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
1242
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1243
|
-
});
|
1244
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1245
|
-
return newData;
|
1246
|
-
};
|
1247
|
-
|
1248
|
-
// ../core/reducer/actions/register-zone.ts
|
1249
1522
|
var zoneCache = {};
|
1250
1523
|
function registerZoneAction(state, action) {
|
1251
1524
|
if (zoneCache[action.zone]) {
|
@@ -1398,14 +1671,6 @@ function createReducer({
|
|
1398
1671
|
);
|
1399
1672
|
}
|
1400
1673
|
|
1401
|
-
// ../core/components/ViewportControls/default-viewports.ts
|
1402
|
-
init_react_import();
|
1403
|
-
var defaultViewports = [
|
1404
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1405
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1406
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1407
|
-
];
|
1408
|
-
|
1409
1674
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
1410
1675
|
init_react_import();
|
1411
1676
|
var createStoreImpl = (createState) => {
|
@@ -1433,15 +1698,15 @@ var createStore = (createState) => createState ? createStoreImpl(createState) :
|
|
1433
1698
|
|
1434
1699
|
// ../../node_modules/zustand/esm/react.mjs
|
1435
1700
|
init_react_import();
|
1436
|
-
var
|
1701
|
+
var import_react6 = __toESM(require("react"), 1);
|
1437
1702
|
var identity = (arg) => arg;
|
1438
1703
|
function useStore(api, selector = identity) {
|
1439
|
-
const slice =
|
1704
|
+
const slice = import_react6.default.useSyncExternalStore(
|
1440
1705
|
api.subscribe,
|
1441
1706
|
() => selector(api.getState()),
|
1442
1707
|
() => selector(api.getInitialState())
|
1443
1708
|
);
|
1444
|
-
|
1709
|
+
import_react6.default.useDebugValue(slice);
|
1445
1710
|
return slice;
|
1446
1711
|
}
|
1447
1712
|
var createImpl = (createState) => {
|
@@ -1480,15 +1745,15 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1480
1745
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1481
1746
|
|
1482
1747
|
// ../core/store/index.ts
|
1483
|
-
var
|
1748
|
+
var import_react11 = require("react");
|
1484
1749
|
|
1485
1750
|
// ../core/store/slices/history.ts
|
1486
1751
|
init_react_import();
|
1487
|
-
var
|
1752
|
+
var import_react8 = require("react");
|
1488
1753
|
|
1489
1754
|
// ../core/lib/use-hotkey.ts
|
1490
1755
|
init_react_import();
|
1491
|
-
var
|
1756
|
+
var import_react7 = require("react");
|
1492
1757
|
var useHotkeyStore = create()(
|
1493
1758
|
subscribeWithSelector((set) => ({
|
1494
1759
|
held: {},
|
@@ -1637,7 +1902,7 @@ var createNodesSlice = (set, get) => ({
|
|
1637
1902
|
|
1638
1903
|
// ../core/store/slices/permissions.ts
|
1639
1904
|
init_react_import();
|
1640
|
-
var
|
1905
|
+
var import_react9 = require("react");
|
1641
1906
|
|
1642
1907
|
// ../core/lib/data/flatten-data.ts
|
1643
1908
|
init_react_import();
|
@@ -1655,19 +1920,6 @@ var flattenData = (state, config) => {
|
|
1655
1920
|
return data;
|
1656
1921
|
};
|
1657
1922
|
|
1658
|
-
// ../core/lib/get-changed.ts
|
1659
|
-
init_react_import();
|
1660
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1661
|
-
var getChanged = (newItem, oldItem) => {
|
1662
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1663
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1664
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1665
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1666
|
-
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1667
|
-
});
|
1668
|
-
}, {}) : {};
|
1669
|
-
};
|
1670
|
-
|
1671
1923
|
// ../core/store/slices/permissions.ts
|
1672
1924
|
var createPermissionsSlice = (set, get) => {
|
1673
1925
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
@@ -1776,7 +2028,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1776
2028
|
|
1777
2029
|
// ../core/store/slices/fields.ts
|
1778
2030
|
init_react_import();
|
1779
|
-
var
|
2031
|
+
var import_react10 = require("react");
|
1780
2032
|
var createFieldsSlice = (_set, _get) => {
|
1781
2033
|
return {
|
1782
2034
|
fields: {},
|
@@ -1786,68 +2038,6 @@ var createFieldsSlice = (_set, _get) => {
|
|
1786
2038
|
};
|
1787
2039
|
};
|
1788
2040
|
|
1789
|
-
// ../core/lib/resolve-component-data.ts
|
1790
|
-
init_react_import();
|
1791
|
-
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1792
|
-
var cache = { lastChange: {} };
|
1793
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1794
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1795
|
-
const resolvedItem = __spreadValues({}, item);
|
1796
|
-
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1797
|
-
const id = "id" in item.props ? item.props.id : "root";
|
1798
|
-
if (shouldRunResolver) {
|
1799
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1800
|
-
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1801
|
-
return { node: resolved, didChange: false };
|
1802
|
-
}
|
1803
|
-
const changed = getChanged(item, oldItem);
|
1804
|
-
if (onResolveStart) {
|
1805
|
-
onResolveStart(item);
|
1806
|
-
}
|
1807
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1808
|
-
changed,
|
1809
|
-
lastData: oldItem,
|
1810
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1811
|
-
trigger
|
1812
|
-
});
|
1813
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1814
|
-
if (Object.keys(readOnly).length) {
|
1815
|
-
resolvedItem.readOnly = readOnly;
|
1816
|
-
}
|
1817
|
-
}
|
1818
|
-
let itemWithResolvedChildren = yield mapSlots(
|
1819
|
-
resolvedItem,
|
1820
|
-
(content) => __async(void 0, null, function* () {
|
1821
|
-
return yield Promise.all(
|
1822
|
-
content.map(
|
1823
|
-
(childItem) => __async(void 0, null, function* () {
|
1824
|
-
return (yield resolveComponentData(
|
1825
|
-
childItem,
|
1826
|
-
config,
|
1827
|
-
metadata,
|
1828
|
-
onResolveStart,
|
1829
|
-
onResolveEnd,
|
1830
|
-
trigger
|
1831
|
-
)).node;
|
1832
|
-
})
|
1833
|
-
)
|
1834
|
-
);
|
1835
|
-
}),
|
1836
|
-
config
|
1837
|
-
);
|
1838
|
-
if (shouldRunResolver && onResolveEnd) {
|
1839
|
-
onResolveEnd(resolvedItem);
|
1840
|
-
}
|
1841
|
-
cache.lastChange[id] = {
|
1842
|
-
item,
|
1843
|
-
resolved: itemWithResolvedChildren
|
1844
|
-
};
|
1845
|
-
return {
|
1846
|
-
node: itemWithResolvedChildren,
|
1847
|
-
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1848
|
-
};
|
1849
|
-
});
|
1850
|
-
|
1851
2041
|
// ../core/lib/data/to-root.ts
|
1852
2042
|
init_react_import();
|
1853
2043
|
var toRoot = (item) => {
|
@@ -1865,34 +2055,6 @@ var toRoot = (item) => {
|
|
1865
2055
|
return { props: {}, readOnly };
|
1866
2056
|
};
|
1867
2057
|
|
1868
|
-
// ../core/store/default-app-state.ts
|
1869
|
-
init_react_import();
|
1870
|
-
var defaultAppState = {
|
1871
|
-
data: { content: [], root: {}, zones: {} },
|
1872
|
-
ui: {
|
1873
|
-
leftSideBarVisible: true,
|
1874
|
-
rightSideBarVisible: true,
|
1875
|
-
arrayState: {},
|
1876
|
-
itemSelector: null,
|
1877
|
-
componentList: {},
|
1878
|
-
isDragging: false,
|
1879
|
-
previewMode: "edit",
|
1880
|
-
viewports: {
|
1881
|
-
current: {
|
1882
|
-
width: defaultViewports[0].width,
|
1883
|
-
height: defaultViewports[0].height || "auto"
|
1884
|
-
},
|
1885
|
-
options: [],
|
1886
|
-
controlsVisible: true
|
1887
|
-
},
|
1888
|
-
field: { focus: null }
|
1889
|
-
},
|
1890
|
-
indexes: {
|
1891
|
-
nodes: {},
|
1892
|
-
zones: {}
|
1893
|
-
}
|
1894
|
-
};
|
1895
|
-
|
1896
2058
|
// ../core/store/index.ts
|
1897
2059
|
var defaultPageFields = {
|
1898
2060
|
title: { type: "text" }
|
@@ -2069,13 +2231,13 @@ var createAppStore = (initialAppStore) => create()(
|
|
2069
2231
|
});
|
2070
2232
|
})
|
2071
2233
|
);
|
2072
|
-
var appStoreContext = (0,
|
2234
|
+
var appStoreContext = (0, import_react11.createContext)(createAppStore());
|
2073
2235
|
function useAppStore(selector) {
|
2074
|
-
const context = (0,
|
2236
|
+
const context = (0, import_react11.useContext)(appStoreContext);
|
2075
2237
|
return useStore(context, selector);
|
2076
2238
|
}
|
2077
2239
|
function useAppStoreApi() {
|
2078
|
-
return (0,
|
2240
|
+
return (0, import_react11.useContext)(appStoreContext);
|
2079
2241
|
}
|
2080
2242
|
|
2081
2243
|
// ../core/lib/use-breadcrumbs.ts
|
@@ -2090,7 +2252,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
2090
2252
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
2091
2253
|
});
|
2092
2254
|
const appStore = useAppStoreApi();
|
2093
|
-
return (0,
|
2255
|
+
return (0, import_react12.useMemo)(() => {
|
2094
2256
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
2095
2257
|
var _a, _b, _c;
|
2096
2258
|
const [componentId] = zoneCompound.split(":");
|
@@ -2140,7 +2302,7 @@ init_react_import();
|
|
2140
2302
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
2141
2303
|
|
2142
2304
|
// ../core/components/Loader/index.tsx
|
2143
|
-
var
|
2305
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
2144
2306
|
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
|
2145
2307
|
var Loader = (_a) => {
|
2146
2308
|
var _b = _a, {
|
@@ -2150,7 +2312,7 @@ var Loader = (_a) => {
|
|
2150
2312
|
"color",
|
2151
2313
|
"size"
|
2152
2314
|
]);
|
2153
|
-
return /* @__PURE__ */ (0,
|
2315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
2154
2316
|
"span",
|
2155
2317
|
__spreadValues({
|
2156
2318
|
className: getClassName2(),
|
@@ -2165,7 +2327,7 @@ var Loader = (_a) => {
|
|
2165
2327
|
};
|
2166
2328
|
|
2167
2329
|
// ../core/components/SidebarSection/index.tsx
|
2168
|
-
var
|
2330
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2169
2331
|
var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
|
2170
2332
|
var SidebarSection = ({
|
2171
2333
|
children,
|
@@ -2178,15 +2340,15 @@ var SidebarSection = ({
|
|
2178
2340
|
}) => {
|
2179
2341
|
const setUi = useAppStore((s) => s.setUi);
|
2180
2342
|
const breadcrumbs = useBreadcrumbs(1);
|
2181
|
-
return /* @__PURE__ */ (0,
|
2343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
2182
2344
|
"div",
|
2183
2345
|
{
|
2184
2346
|
className: getClassName3({ noBorderTop, noPadding }),
|
2185
2347
|
style: { background },
|
2186
2348
|
children: [
|
2187
|
-
/* @__PURE__ */ (0,
|
2188
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0,
|
2189
|
-
/* @__PURE__ */ (0,
|
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)(
|
2190
2352
|
"button",
|
2191
2353
|
{
|
2192
2354
|
type: "button",
|
@@ -2195,12 +2357,12 @@ var SidebarSection = ({
|
|
2195
2357
|
children: breadcrumb.label
|
2196
2358
|
}
|
2197
2359
|
),
|
2198
|
-
/* @__PURE__ */ (0,
|
2360
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronRight, { size: 16 })
|
2199
2361
|
] }, i)) : null,
|
2200
|
-
/* @__PURE__ */ (0,
|
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 }) })
|
2201
2363
|
] }) }),
|
2202
|
-
/* @__PURE__ */ (0,
|
2203
|
-
isLoading && /* @__PURE__ */ (0,
|
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 }) })
|
2204
2366
|
]
|
2205
2367
|
}
|
2206
2368
|
);
|
@@ -2214,18 +2376,18 @@ init_react_import();
|
|
2214
2376
|
var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
|
2215
2377
|
|
2216
2378
|
// ../core/components/OutlineList/index.tsx
|
2217
|
-
var
|
2379
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
2218
2380
|
var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
|
2219
2381
|
var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
|
2220
2382
|
var OutlineList = ({ children }) => {
|
2221
|
-
return /* @__PURE__ */ (0,
|
2383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: getClassName4(), children });
|
2222
2384
|
};
|
2223
|
-
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0,
|
2385
|
+
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
|
2224
2386
|
OutlineList.Item = ({
|
2225
2387
|
children,
|
2226
2388
|
onClick
|
2227
2389
|
}) => {
|
2228
|
-
return /* @__PURE__ */ (0,
|
2390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
2229
2391
|
"li",
|
2230
2392
|
{
|
2231
2393
|
className: getClassNameItem({ clickable: !!onClick }),
|
@@ -2259,7 +2421,7 @@ var getFrame = () => {
|
|
2259
2421
|
|
2260
2422
|
// src/HeadingAnalyzer.tsx
|
2261
2423
|
var import_react_from_json = __toESM(require("react-from-json"));
|
2262
|
-
var
|
2424
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
2263
2425
|
var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
|
2264
2426
|
var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
|
2265
2427
|
var ReactFromJSON = import_react_from_json.default.default || import_react_from_json.default;
|
@@ -2315,8 +2477,8 @@ function buildHierarchy(frame) {
|
|
2315
2477
|
var usePuck = (0, import_puck.createUsePuck)();
|
2316
2478
|
var HeadingAnalyzer = () => {
|
2317
2479
|
const data = usePuck((s) => s.appState.data);
|
2318
|
-
const [hierarchy, setHierarchy] = (0,
|
2319
|
-
(0,
|
2480
|
+
const [hierarchy, setHierarchy] = (0, import_react13.useState)([]);
|
2481
|
+
(0, import_react13.useEffect)(() => {
|
2320
2482
|
const frame = getFrame();
|
2321
2483
|
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2322
2484
|
const createHierarchy = () => {
|
@@ -2351,8 +2513,8 @@ var HeadingAnalyzer = () => {
|
|
2351
2513
|
frameObserver.disconnect();
|
2352
2514
|
};
|
2353
2515
|
}, [data]);
|
2354
|
-
return /* @__PURE__ */ (0,
|
2355
|
-
/* @__PURE__ */ (0,
|
2516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassName5(), children: [
|
2517
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
2356
2518
|
"small",
|
2357
2519
|
{
|
2358
2520
|
className: getClassName5("cssWarning"),
|
@@ -2364,19 +2526,19 @@ var HeadingAnalyzer = () => {
|
|
2364
2526
|
children: [
|
2365
2527
|
"Heading analyzer styles not loaded. Please review the",
|
2366
2528
|
" ",
|
2367
|
-
/* @__PURE__ */ (0,
|
2529
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
|
2368
2530
|
"."
|
2369
2531
|
]
|
2370
2532
|
}
|
2371
2533
|
),
|
2372
|
-
hierarchy.length === 0 && /* @__PURE__ */ (0,
|
2373
|
-
/* @__PURE__ */ (0,
|
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)(
|
2374
2536
|
ReactFromJSON,
|
2375
2537
|
{
|
2376
2538
|
mapping: {
|
2377
|
-
Root: (props) => /* @__PURE__ */ (0,
|
2378
|
-
OutlineListItem: (props) => /* @__PURE__ */ (0,
|
2379
|
-
/* @__PURE__ */ (0,
|
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)(
|
2380
2542
|
"small",
|
2381
2543
|
{
|
2382
2544
|
className: getClassNameItem2({ missing: props.missing }),
|
@@ -2394,14 +2556,14 @@ var HeadingAnalyzer = () => {
|
|
2394
2556
|
}, 2e3);
|
2395
2557
|
}
|
2396
2558
|
},
|
2397
|
-
children: props.missing ? /* @__PURE__ */ (0,
|
2398
|
-
/* @__PURE__ */ (0,
|
2559
|
+
children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("b", { children: [
|
2399
2561
|
"H",
|
2400
2562
|
props.rank
|
2401
2563
|
] }),
|
2402
2564
|
": Missing"
|
2403
|
-
] }) : /* @__PURE__ */ (0,
|
2404
|
-
/* @__PURE__ */ (0,
|
2565
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
2566
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("b", { children: [
|
2405
2567
|
"H",
|
2406
2568
|
props.rank
|
2407
2569
|
] }),
|
@@ -2410,7 +2572,7 @@ var HeadingAnalyzer = () => {
|
|
2410
2572
|
] })
|
2411
2573
|
}
|
2412
2574
|
) }),
|
2413
|
-
/* @__PURE__ */ (0,
|
2575
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OutlineList, { children: props.children })
|
2414
2576
|
] })
|
2415
2577
|
},
|
2416
2578
|
entry: {
|
@@ -2432,9 +2594,9 @@ var HeadingAnalyzer = () => {
|
|
2432
2594
|
};
|
2433
2595
|
var headingAnalyzer = {
|
2434
2596
|
overrides: {
|
2435
|
-
fields: ({ children, itemSelector }) => /* @__PURE__ */ (0,
|
2597
|
+
fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
2436
2598
|
children,
|
2437
|
-
/* @__PURE__ */ (0,
|
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, {}) }) })
|
2438
2600
|
] })
|
2439
2601
|
}
|
2440
2602
|
};
|