@orion-studios/payload-studio 0.5.0-beta.27 → 0.5.0-beta.29
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/admin-app/client.d.mts +1 -0
- package/dist/admin-app/client.d.ts +1 -0
- package/dist/admin-app/client.js +189 -4
- package/dist/admin-app/client.mjs +189 -5
- package/dist/admin-app/index.d.mts +1 -1
- package/dist/admin-app/index.d.ts +1 -1
- package/dist/admin-app/index.js +5 -3
- package/dist/admin-app/index.mjs +3 -1
- package/dist/admin-app/styles.css +13 -0
- package/dist/{chunk-TVQPMM6Y.mjs → chunk-XVH5SCBD.mjs} +5 -3
- package/dist/{index-BheEmI3q.d.mts → index-BBvk9b9i.d.mts} +10 -2
- package/dist/{index-BheEmI3q.d.ts → index-BBvk9b9i.d.ts} +10 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/admin-app/client.js
CHANGED
|
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
24
|
AdminShellClient: () => AdminShellClient,
|
|
25
|
+
HeaderNavEditorWithPreview: () => HeaderNavEditorWithPreview,
|
|
25
26
|
HeaderNavItemsEditor: () => HeaderNavItemsEditor
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(client_exports);
|
|
@@ -134,6 +135,54 @@ function AdminShellClient({
|
|
|
134
135
|
|
|
135
136
|
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
136
137
|
var import_react2 = require("react");
|
|
138
|
+
|
|
139
|
+
// src/admin-app/navigationLinks.ts
|
|
140
|
+
var normalizeAdminNavInputs = (rows, pageOptions) => {
|
|
141
|
+
const allowedLinks = new Map(pageOptions.map((option) => [option.href, option.title]));
|
|
142
|
+
const deduped = [];
|
|
143
|
+
const seen = /* @__PURE__ */ new Set();
|
|
144
|
+
for (const row of rows) {
|
|
145
|
+
const href = typeof row.href === "string" ? row.href.trim() : "";
|
|
146
|
+
const defaultLabel = allowedLinks.get(href);
|
|
147
|
+
const explicitLabel = typeof row.label === "string" ? row.label.trim() : "";
|
|
148
|
+
const parentHref = typeof row.parentHref === "string" ? row.parentHref.trim() : "";
|
|
149
|
+
if (!href || !defaultLabel || seen.has(href)) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
seen.add(href);
|
|
153
|
+
deduped.push({
|
|
154
|
+
href,
|
|
155
|
+
label: explicitLabel.length > 0 ? explicitLabel : defaultLabel,
|
|
156
|
+
...parentHref.length > 0 ? { parentHref } : {}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
160
|
+
const parentByHref = new Map(deduped.map((item) => [item.href, item.parentHref || ""]));
|
|
161
|
+
const createsCycle = (href, parentHref) => {
|
|
162
|
+
const visited = /* @__PURE__ */ new Set([href]);
|
|
163
|
+
let current = parentHref;
|
|
164
|
+
while (current) {
|
|
165
|
+
if (visited.has(current)) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
visited.add(current);
|
|
169
|
+
current = parentByHref.get(current) || "";
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
};
|
|
173
|
+
return deduped.map((item) => {
|
|
174
|
+
const parentHref = item.parentHref;
|
|
175
|
+
if (!parentHref || parentHref === item.href || !hrefs.has(parentHref) || createsCycle(item.href, parentHref)) {
|
|
176
|
+
return {
|
|
177
|
+
href: item.href,
|
|
178
|
+
label: item.label
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return item;
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
137
186
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
138
187
|
var toRow = (item, index) => ({
|
|
139
188
|
id: `row-${index}-${item.href || "empty"}`,
|
|
@@ -153,10 +202,11 @@ var moveRow = (rows, fromIndex, toIndex) => {
|
|
|
153
202
|
next.splice(toIndex, 0, moved);
|
|
154
203
|
return next;
|
|
155
204
|
};
|
|
156
|
-
function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
205
|
+
function HeaderNavItemsEditor({ initialItems, pageOptions, onItemsChange }) {
|
|
157
206
|
const [rows, setRows] = (0, import_react2.useState)(() => initialItems.map(toRow));
|
|
158
207
|
const [nextRowID, setNextRowID] = (0, import_react2.useState)(initialItems.length);
|
|
159
208
|
const [draggingRowID, setDraggingRowID] = (0, import_react2.useState)(null);
|
|
209
|
+
const [dragOverRowID, setDragOverRowID] = (0, import_react2.useState)(null);
|
|
160
210
|
const pageOptionByHref = (0, import_react2.useMemo)(() => new Map(pageOptions.map((option) => [option.href, option])), [pageOptions]);
|
|
161
211
|
const serializedState = (0, import_react2.useMemo)(
|
|
162
212
|
() => JSON.stringify(
|
|
@@ -168,6 +218,17 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
168
218
|
),
|
|
169
219
|
[rows]
|
|
170
220
|
);
|
|
221
|
+
const normalizedItems = (0, import_react2.useMemo)(() => {
|
|
222
|
+
const inputs = rows.map((row) => ({
|
|
223
|
+
href: row.href,
|
|
224
|
+
label: row.label,
|
|
225
|
+
parentHref: row.parentHref
|
|
226
|
+
}));
|
|
227
|
+
return normalizeAdminNavInputs(inputs, pageOptions);
|
|
228
|
+
}, [rows, pageOptions]);
|
|
229
|
+
(0, import_react2.useEffect)(() => {
|
|
230
|
+
onItemsChange?.(normalizedItems);
|
|
231
|
+
}, [normalizedItems, onItemsChange]);
|
|
171
232
|
const setRowValue = (rowID, changes) => {
|
|
172
233
|
setRows(
|
|
173
234
|
(currentRows) => currentRows.map((row) => {
|
|
@@ -222,10 +283,28 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
222
283
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
223
284
|
"div",
|
|
224
285
|
{
|
|
225
|
-
className:
|
|
286
|
+
className: `orion-admin-nav-editor-row${draggingRowID === row.id ? " is-dragging" : ""}${dragOverRowID === row.id && draggingRowID !== row.id ? " is-drop-target" : ""}`,
|
|
226
287
|
draggable: true,
|
|
227
|
-
onDragEnd: () =>
|
|
228
|
-
|
|
288
|
+
onDragEnd: () => {
|
|
289
|
+
setDraggingRowID(null);
|
|
290
|
+
setDragOverRowID(null);
|
|
291
|
+
},
|
|
292
|
+
onDragEnter: () => {
|
|
293
|
+
if (draggingRowID && draggingRowID !== row.id) {
|
|
294
|
+
setDragOverRowID(row.id);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
onDragLeave: () => {
|
|
298
|
+
if (dragOverRowID === row.id) {
|
|
299
|
+
setDragOverRowID(null);
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
onDragOver: (event) => {
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
if (draggingRowID && draggingRowID !== row.id && dragOverRowID !== row.id) {
|
|
305
|
+
setDragOverRowID(row.id);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
229
308
|
onDragStart: (event) => {
|
|
230
309
|
setDraggingRowID(row.id);
|
|
231
310
|
event.dataTransfer.effectAllowed = "move";
|
|
@@ -241,6 +320,7 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
241
320
|
return moveRow(currentRows, fromIndex, toIndex);
|
|
242
321
|
});
|
|
243
322
|
setDraggingRowID(null);
|
|
323
|
+
setDragOverRowID(null);
|
|
244
324
|
},
|
|
245
325
|
children: [
|
|
246
326
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-nav-editor-row-head", children: [
|
|
@@ -307,8 +387,113 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
307
387
|
}) })
|
|
308
388
|
] });
|
|
309
389
|
}
|
|
390
|
+
|
|
391
|
+
// src/admin-app/components/HeaderNavEditorWithPreview.tsx
|
|
392
|
+
var import_react3 = require("react");
|
|
393
|
+
|
|
394
|
+
// src/admin-app/nestedNavigation.ts
|
|
395
|
+
var normalizeNestedNavItems = (items) => {
|
|
396
|
+
const deduped = [];
|
|
397
|
+
const seen = /* @__PURE__ */ new Set();
|
|
398
|
+
for (const item of items) {
|
|
399
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
400
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
401
|
+
const parentHref = typeof item.parentHref === "string" ? item.parentHref.trim() : "";
|
|
402
|
+
if (!href || !label || seen.has(href)) {
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
seen.add(href);
|
|
406
|
+
deduped.push({
|
|
407
|
+
href,
|
|
408
|
+
label,
|
|
409
|
+
...parentHref ? { parentHref } : {}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
413
|
+
return deduped.map((item) => ({
|
|
414
|
+
href: item.href,
|
|
415
|
+
label: item.label,
|
|
416
|
+
...item.parentHref && item.parentHref !== item.href && hrefs.has(item.parentHref) ? { parentHref: item.parentHref } : {}
|
|
417
|
+
}));
|
|
418
|
+
};
|
|
419
|
+
var buildNestedNavTree = (items) => {
|
|
420
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
421
|
+
const topLevel = [];
|
|
422
|
+
for (const item of items) {
|
|
423
|
+
if (!item.parentHref) {
|
|
424
|
+
topLevel.push(item);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
const children = childrenByParent.get(item.parentHref) || [];
|
|
428
|
+
children.push(item);
|
|
429
|
+
childrenByParent.set(item.parentHref, children);
|
|
430
|
+
}
|
|
431
|
+
if (topLevel.length === 0 && items.length > 0) {
|
|
432
|
+
return {
|
|
433
|
+
topLevel: items.map((item) => ({ href: item.href, label: item.label })),
|
|
434
|
+
childrenByParent: /* @__PURE__ */ new Map()
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
return { childrenByParent, topLevel };
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// src/admin-app/components/HeaderNavEditorWithPreview.tsx
|
|
441
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
442
|
+
var fallbackNav = [{ href: "/", label: "Home" }];
|
|
443
|
+
function HeaderNavEditorWithPreview({
|
|
444
|
+
brandName,
|
|
445
|
+
initialItems,
|
|
446
|
+
logoUrl,
|
|
447
|
+
pageOptions,
|
|
448
|
+
tagline = ""
|
|
449
|
+
}) {
|
|
450
|
+
const [liveItems, setLiveItems] = (0, import_react3.useState)(initialItems);
|
|
451
|
+
const previewItems = (0, import_react3.useMemo)(() => {
|
|
452
|
+
const normalized = normalizeNestedNavItems(liveItems);
|
|
453
|
+
const tree = buildNestedNavTree(normalized);
|
|
454
|
+
return tree.topLevel.length > 0 ? tree : buildNestedNavTree(fallbackNav);
|
|
455
|
+
}, [liveItems]);
|
|
456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HeaderNavItemsEditor, { initialItems, onItemsChange: setLiveItems, pageOptions }),
|
|
458
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { color: "#5d6664", fontSize: "0.88rem", fontWeight: 700 }, children: "Header Preview" }),
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
style: {
|
|
463
|
+
border: "1px solid #dce2e0",
|
|
464
|
+
borderRadius: 14,
|
|
465
|
+
overflow: "hidden"
|
|
466
|
+
},
|
|
467
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("header", { className: "site-header", style: { position: "relative", top: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "container container-content header-wrap", children: [
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("a", { className: "brand", href: "#", children: [
|
|
469
|
+
logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { alt: `${brandName} logo`, src: logoUrl }) : null,
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "brand-title", children: brandName }),
|
|
472
|
+
tagline ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "brand-subtitle", children: tagline }) : null
|
|
473
|
+
] })
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("nav", { className: "site-nav open", children: previewItems.topLevel.map((item, index) => {
|
|
476
|
+
const children = previewItems.childrenByParent.get(item.href) || [];
|
|
477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
478
|
+
"div",
|
|
479
|
+
{
|
|
480
|
+
className: children.length > 0 ? "site-nav-item has-children" : "site-nav-item",
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: index === 0 ? "active" : "", href: item.href, children: item.label }),
|
|
483
|
+
children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-subnav", children: children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: child.href, children: child.label }, `${item.href}-${child.href}`)) }) : null
|
|
484
|
+
]
|
|
485
|
+
},
|
|
486
|
+
`${item.href}-${index}`
|
|
487
|
+
);
|
|
488
|
+
}) })
|
|
489
|
+
] }) })
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
] });
|
|
493
|
+
}
|
|
310
494
|
// Annotate the CommonJS export names for ESM import in node:
|
|
311
495
|
0 && (module.exports = {
|
|
312
496
|
AdminShellClient,
|
|
497
|
+
HeaderNavEditorWithPreview,
|
|
313
498
|
HeaderNavItemsEditor
|
|
314
499
|
});
|
|
@@ -107,7 +107,55 @@ function AdminShellClient({
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
110
|
-
import { useMemo, useState as useState2 } from "react";
|
|
110
|
+
import { useEffect as useEffect2, useMemo, useState as useState2 } from "react";
|
|
111
|
+
|
|
112
|
+
// src/admin-app/navigationLinks.ts
|
|
113
|
+
var normalizeAdminNavInputs = (rows, pageOptions) => {
|
|
114
|
+
const allowedLinks = new Map(pageOptions.map((option) => [option.href, option.title]));
|
|
115
|
+
const deduped = [];
|
|
116
|
+
const seen = /* @__PURE__ */ new Set();
|
|
117
|
+
for (const row of rows) {
|
|
118
|
+
const href = typeof row.href === "string" ? row.href.trim() : "";
|
|
119
|
+
const defaultLabel = allowedLinks.get(href);
|
|
120
|
+
const explicitLabel = typeof row.label === "string" ? row.label.trim() : "";
|
|
121
|
+
const parentHref = typeof row.parentHref === "string" ? row.parentHref.trim() : "";
|
|
122
|
+
if (!href || !defaultLabel || seen.has(href)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
seen.add(href);
|
|
126
|
+
deduped.push({
|
|
127
|
+
href,
|
|
128
|
+
label: explicitLabel.length > 0 ? explicitLabel : defaultLabel,
|
|
129
|
+
...parentHref.length > 0 ? { parentHref } : {}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
133
|
+
const parentByHref = new Map(deduped.map((item) => [item.href, item.parentHref || ""]));
|
|
134
|
+
const createsCycle = (href, parentHref) => {
|
|
135
|
+
const visited = /* @__PURE__ */ new Set([href]);
|
|
136
|
+
let current = parentHref;
|
|
137
|
+
while (current) {
|
|
138
|
+
if (visited.has(current)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
visited.add(current);
|
|
142
|
+
current = parentByHref.get(current) || "";
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
return deduped.map((item) => {
|
|
147
|
+
const parentHref = item.parentHref;
|
|
148
|
+
if (!parentHref || parentHref === item.href || !hrefs.has(parentHref) || createsCycle(item.href, parentHref)) {
|
|
149
|
+
return {
|
|
150
|
+
href: item.href,
|
|
151
|
+
label: item.label
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return item;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
111
159
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
112
160
|
var toRow = (item, index) => ({
|
|
113
161
|
id: `row-${index}-${item.href || "empty"}`,
|
|
@@ -127,10 +175,11 @@ var moveRow = (rows, fromIndex, toIndex) => {
|
|
|
127
175
|
next.splice(toIndex, 0, moved);
|
|
128
176
|
return next;
|
|
129
177
|
};
|
|
130
|
-
function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
178
|
+
function HeaderNavItemsEditor({ initialItems, pageOptions, onItemsChange }) {
|
|
131
179
|
const [rows, setRows] = useState2(() => initialItems.map(toRow));
|
|
132
180
|
const [nextRowID, setNextRowID] = useState2(initialItems.length);
|
|
133
181
|
const [draggingRowID, setDraggingRowID] = useState2(null);
|
|
182
|
+
const [dragOverRowID, setDragOverRowID] = useState2(null);
|
|
134
183
|
const pageOptionByHref = useMemo(() => new Map(pageOptions.map((option) => [option.href, option])), [pageOptions]);
|
|
135
184
|
const serializedState = useMemo(
|
|
136
185
|
() => JSON.stringify(
|
|
@@ -142,6 +191,17 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
142
191
|
),
|
|
143
192
|
[rows]
|
|
144
193
|
);
|
|
194
|
+
const normalizedItems = useMemo(() => {
|
|
195
|
+
const inputs = rows.map((row) => ({
|
|
196
|
+
href: row.href,
|
|
197
|
+
label: row.label,
|
|
198
|
+
parentHref: row.parentHref
|
|
199
|
+
}));
|
|
200
|
+
return normalizeAdminNavInputs(inputs, pageOptions);
|
|
201
|
+
}, [rows, pageOptions]);
|
|
202
|
+
useEffect2(() => {
|
|
203
|
+
onItemsChange?.(normalizedItems);
|
|
204
|
+
}, [normalizedItems, onItemsChange]);
|
|
145
205
|
const setRowValue = (rowID, changes) => {
|
|
146
206
|
setRows(
|
|
147
207
|
(currentRows) => currentRows.map((row) => {
|
|
@@ -196,10 +256,28 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
196
256
|
return /* @__PURE__ */ jsxs2(
|
|
197
257
|
"div",
|
|
198
258
|
{
|
|
199
|
-
className:
|
|
259
|
+
className: `orion-admin-nav-editor-row${draggingRowID === row.id ? " is-dragging" : ""}${dragOverRowID === row.id && draggingRowID !== row.id ? " is-drop-target" : ""}`,
|
|
200
260
|
draggable: true,
|
|
201
|
-
onDragEnd: () =>
|
|
202
|
-
|
|
261
|
+
onDragEnd: () => {
|
|
262
|
+
setDraggingRowID(null);
|
|
263
|
+
setDragOverRowID(null);
|
|
264
|
+
},
|
|
265
|
+
onDragEnter: () => {
|
|
266
|
+
if (draggingRowID && draggingRowID !== row.id) {
|
|
267
|
+
setDragOverRowID(row.id);
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
onDragLeave: () => {
|
|
271
|
+
if (dragOverRowID === row.id) {
|
|
272
|
+
setDragOverRowID(null);
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
onDragOver: (event) => {
|
|
276
|
+
event.preventDefault();
|
|
277
|
+
if (draggingRowID && draggingRowID !== row.id && dragOverRowID !== row.id) {
|
|
278
|
+
setDragOverRowID(row.id);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
203
281
|
onDragStart: (event) => {
|
|
204
282
|
setDraggingRowID(row.id);
|
|
205
283
|
event.dataTransfer.effectAllowed = "move";
|
|
@@ -215,6 +293,7 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
215
293
|
return moveRow(currentRows, fromIndex, toIndex);
|
|
216
294
|
});
|
|
217
295
|
setDraggingRowID(null);
|
|
296
|
+
setDragOverRowID(null);
|
|
218
297
|
},
|
|
219
298
|
children: [
|
|
220
299
|
/* @__PURE__ */ jsxs2("div", { className: "orion-admin-nav-editor-row-head", children: [
|
|
@@ -281,7 +360,112 @@ function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
|
281
360
|
}) })
|
|
282
361
|
] });
|
|
283
362
|
}
|
|
363
|
+
|
|
364
|
+
// src/admin-app/components/HeaderNavEditorWithPreview.tsx
|
|
365
|
+
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
366
|
+
|
|
367
|
+
// src/admin-app/nestedNavigation.ts
|
|
368
|
+
var normalizeNestedNavItems = (items) => {
|
|
369
|
+
const deduped = [];
|
|
370
|
+
const seen = /* @__PURE__ */ new Set();
|
|
371
|
+
for (const item of items) {
|
|
372
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
373
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
374
|
+
const parentHref = typeof item.parentHref === "string" ? item.parentHref.trim() : "";
|
|
375
|
+
if (!href || !label || seen.has(href)) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
seen.add(href);
|
|
379
|
+
deduped.push({
|
|
380
|
+
href,
|
|
381
|
+
label,
|
|
382
|
+
...parentHref ? { parentHref } : {}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
386
|
+
return deduped.map((item) => ({
|
|
387
|
+
href: item.href,
|
|
388
|
+
label: item.label,
|
|
389
|
+
...item.parentHref && item.parentHref !== item.href && hrefs.has(item.parentHref) ? { parentHref: item.parentHref } : {}
|
|
390
|
+
}));
|
|
391
|
+
};
|
|
392
|
+
var buildNestedNavTree = (items) => {
|
|
393
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
394
|
+
const topLevel = [];
|
|
395
|
+
for (const item of items) {
|
|
396
|
+
if (!item.parentHref) {
|
|
397
|
+
topLevel.push(item);
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
const children = childrenByParent.get(item.parentHref) || [];
|
|
401
|
+
children.push(item);
|
|
402
|
+
childrenByParent.set(item.parentHref, children);
|
|
403
|
+
}
|
|
404
|
+
if (topLevel.length === 0 && items.length > 0) {
|
|
405
|
+
return {
|
|
406
|
+
topLevel: items.map((item) => ({ href: item.href, label: item.label })),
|
|
407
|
+
childrenByParent: /* @__PURE__ */ new Map()
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return { childrenByParent, topLevel };
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// src/admin-app/components/HeaderNavEditorWithPreview.tsx
|
|
414
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
415
|
+
var fallbackNav = [{ href: "/", label: "Home" }];
|
|
416
|
+
function HeaderNavEditorWithPreview({
|
|
417
|
+
brandName,
|
|
418
|
+
initialItems,
|
|
419
|
+
logoUrl,
|
|
420
|
+
pageOptions,
|
|
421
|
+
tagline = ""
|
|
422
|
+
}) {
|
|
423
|
+
const [liveItems, setLiveItems] = useState3(initialItems);
|
|
424
|
+
const previewItems = useMemo2(() => {
|
|
425
|
+
const normalized = normalizeNestedNavItems(liveItems);
|
|
426
|
+
const tree = buildNestedNavTree(normalized);
|
|
427
|
+
return tree.topLevel.length > 0 ? tree : buildNestedNavTree(fallbackNav);
|
|
428
|
+
}, [liveItems]);
|
|
429
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
430
|
+
/* @__PURE__ */ jsx3(HeaderNavItemsEditor, { initialItems, onItemsChange: setLiveItems, pageOptions }),
|
|
431
|
+
/* @__PURE__ */ jsx3("div", { style: { color: "#5d6664", fontSize: "0.88rem", fontWeight: 700 }, children: "Header Preview" }),
|
|
432
|
+
/* @__PURE__ */ jsx3(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
style: {
|
|
436
|
+
border: "1px solid #dce2e0",
|
|
437
|
+
borderRadius: 14,
|
|
438
|
+
overflow: "hidden"
|
|
439
|
+
},
|
|
440
|
+
children: /* @__PURE__ */ jsx3("header", { className: "site-header", style: { position: "relative", top: "auto" }, children: /* @__PURE__ */ jsxs3("div", { className: "container container-content header-wrap", children: [
|
|
441
|
+
/* @__PURE__ */ jsxs3("a", { className: "brand", href: "#", children: [
|
|
442
|
+
logoUrl ? /* @__PURE__ */ jsx3("img", { alt: `${brandName} logo`, src: logoUrl }) : null,
|
|
443
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
444
|
+
/* @__PURE__ */ jsx3("div", { className: "brand-title", children: brandName }),
|
|
445
|
+
tagline ? /* @__PURE__ */ jsx3("div", { className: "brand-subtitle", children: tagline }) : null
|
|
446
|
+
] })
|
|
447
|
+
] }),
|
|
448
|
+
/* @__PURE__ */ jsx3("nav", { className: "site-nav open", children: previewItems.topLevel.map((item, index) => {
|
|
449
|
+
const children = previewItems.childrenByParent.get(item.href) || [];
|
|
450
|
+
return /* @__PURE__ */ jsxs3(
|
|
451
|
+
"div",
|
|
452
|
+
{
|
|
453
|
+
className: children.length > 0 ? "site-nav-item has-children" : "site-nav-item",
|
|
454
|
+
children: [
|
|
455
|
+
/* @__PURE__ */ jsx3("a", { className: index === 0 ? "active" : "", href: item.href, children: item.label }),
|
|
456
|
+
children.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "site-subnav", children: children.map((child) => /* @__PURE__ */ jsx3("a", { href: child.href, children: child.label }, `${item.href}-${child.href}`)) }) : null
|
|
457
|
+
]
|
|
458
|
+
},
|
|
459
|
+
`${item.href}-${index}`
|
|
460
|
+
);
|
|
461
|
+
}) })
|
|
462
|
+
] }) })
|
|
463
|
+
}
|
|
464
|
+
)
|
|
465
|
+
] });
|
|
466
|
+
}
|
|
284
467
|
export {
|
|
285
468
|
AdminShellClient,
|
|
469
|
+
HeaderNavEditorWithPreview,
|
|
286
470
|
HeaderNavItemsEditor
|
|
287
471
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as
|
|
1
|
+
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as AdminNavInput, c as AdminNavItem, d as AdminNavLinkItem, e as AdminPage, f as AdminPageLinkOption, g as AdminPageRecord, h as AdminRole, N as NestedNavItem, j as NestedNavItemInput, k as NestedNavTree, l as buildAdminPageLinkOptions, m as buildNestedNavTree, n as getAdminNavRows, o as navItemIsActive, p as normalizeAdminNavInputs, q as normalizeNestedNavItems, r as parseAdminHeaderNavFromForm, s as roleCanAccessNav } from '../index-BBvk9b9i.mjs';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as
|
|
1
|
+
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as AdminNavInput, c as AdminNavItem, d as AdminNavLinkItem, e as AdminPage, f as AdminPageLinkOption, g as AdminPageRecord, h as AdminRole, N as NestedNavItem, j as NestedNavItemInput, k as NestedNavTree, l as buildAdminPageLinkOptions, m as buildNestedNavTree, n as getAdminNavRows, o as navItemIsActive, p as normalizeAdminNavInputs, q as normalizeNestedNavItems, r as parseAdminHeaderNavFromForm, s as roleCanAccessNav } from '../index-BBvk9b9i.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
package/dist/admin-app/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(admin_app_exports, {
|
|
|
26
26
|
buildNestedNavTree: () => buildNestedNavTree,
|
|
27
27
|
getAdminNavRows: () => getAdminNavRows,
|
|
28
28
|
navItemIsActive: () => navItemIsActive,
|
|
29
|
+
normalizeAdminNavInputs: () => normalizeAdminNavInputs,
|
|
29
30
|
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
30
31
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
31
32
|
roleCanAccessNav: () => roleCanAccessNav
|
|
@@ -143,7 +144,7 @@ var getAdminNavRows = (navItems, pageOptions, minRows = 6, maxRows = 20) => {
|
|
|
143
144
|
const preferredRows = Math.max(navItems.length + 2, Math.min(8, pageOptions.length));
|
|
144
145
|
return Math.min(Math.max(minRows, preferredRows), maxRows);
|
|
145
146
|
};
|
|
146
|
-
var
|
|
147
|
+
var normalizeAdminNavInputs = (rows, pageOptions) => {
|
|
147
148
|
const allowedLinks = new Map(pageOptions.map((option) => [option.href, option.title]));
|
|
148
149
|
const deduped = [];
|
|
149
150
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -193,7 +194,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
193
194
|
try {
|
|
194
195
|
const parsed = JSON.parse(serialized);
|
|
195
196
|
if (Array.isArray(parsed)) {
|
|
196
|
-
return
|
|
197
|
+
return normalizeAdminNavInputs(parsed.slice(0, maxRows), pageOptions);
|
|
197
198
|
}
|
|
198
199
|
} catch {
|
|
199
200
|
}
|
|
@@ -212,7 +213,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
215
|
if (navRows.length > 0) {
|
|
215
|
-
return
|
|
216
|
+
return normalizeAdminNavInputs(navRows, pageOptions);
|
|
216
217
|
}
|
|
217
218
|
return [];
|
|
218
219
|
};
|
|
@@ -241,6 +242,7 @@ var navItemIsActive = (pathname, item) => {
|
|
|
241
242
|
buildNestedNavTree,
|
|
242
243
|
getAdminNavRows,
|
|
243
244
|
navItemIsActive,
|
|
245
|
+
normalizeAdminNavInputs,
|
|
244
246
|
normalizeNestedNavItems,
|
|
245
247
|
parseAdminHeaderNavFromForm,
|
|
246
248
|
roleCanAccessNav
|
package/dist/admin-app/index.mjs
CHANGED
|
@@ -5,10 +5,11 @@ import {
|
|
|
5
5
|
buildNestedNavTree,
|
|
6
6
|
getAdminNavRows,
|
|
7
7
|
navItemIsActive,
|
|
8
|
+
normalizeAdminNavInputs,
|
|
8
9
|
normalizeNestedNavItems,
|
|
9
10
|
parseAdminHeaderNavFromForm,
|
|
10
11
|
roleCanAccessNav
|
|
11
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-XVH5SCBD.mjs";
|
|
12
13
|
import "../chunk-6BWS3CLP.mjs";
|
|
13
14
|
export {
|
|
14
15
|
AdminBreadcrumbs,
|
|
@@ -17,6 +18,7 @@ export {
|
|
|
17
18
|
buildNestedNavTree,
|
|
18
19
|
getAdminNavRows,
|
|
19
20
|
navItemIsActive,
|
|
21
|
+
normalizeAdminNavInputs,
|
|
20
22
|
normalizeNestedNavItems,
|
|
21
23
|
parseAdminHeaderNavFromForm,
|
|
22
24
|
roleCanAccessNav
|
|
@@ -176,6 +176,18 @@
|
|
|
176
176
|
display: grid;
|
|
177
177
|
gap: 0.5rem;
|
|
178
178
|
padding: 0.65rem;
|
|
179
|
+
transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.orion-admin-nav-editor-row.is-dragging {
|
|
183
|
+
border-color: rgba(24, 95, 69, 0.55);
|
|
184
|
+
box-shadow: 0 10px 24px rgba(15, 42, 33, 0.16);
|
|
185
|
+
transform: scale(0.996);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.orion-admin-nav-editor-row.is-drop-target {
|
|
189
|
+
border-color: rgba(24, 95, 69, 0.7);
|
|
190
|
+
box-shadow: inset 0 0 0 2px rgba(24, 95, 69, 0.12);
|
|
179
191
|
}
|
|
180
192
|
|
|
181
193
|
.orion-admin-nav-editor-row-head {
|
|
@@ -193,6 +205,7 @@
|
|
|
193
205
|
font-weight: 800;
|
|
194
206
|
padding: 0.2rem 0.5rem;
|
|
195
207
|
text-transform: uppercase;
|
|
208
|
+
user-select: none;
|
|
196
209
|
}
|
|
197
210
|
|
|
198
211
|
.orion-admin-nav-editor-row-index {
|
|
@@ -11,6 +11,7 @@ __export(admin_app_exports, {
|
|
|
11
11
|
buildNestedNavTree: () => buildNestedNavTree,
|
|
12
12
|
getAdminNavRows: () => getAdminNavRows,
|
|
13
13
|
navItemIsActive: () => navItemIsActive,
|
|
14
|
+
normalizeAdminNavInputs: () => normalizeAdminNavInputs,
|
|
14
15
|
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
15
16
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
16
17
|
roleCanAccessNav: () => roleCanAccessNav
|
|
@@ -127,7 +128,7 @@ var getAdminNavRows = (navItems, pageOptions, minRows = 6, maxRows = 20) => {
|
|
|
127
128
|
const preferredRows = Math.max(navItems.length + 2, Math.min(8, pageOptions.length));
|
|
128
129
|
return Math.min(Math.max(minRows, preferredRows), maxRows);
|
|
129
130
|
};
|
|
130
|
-
var
|
|
131
|
+
var normalizeAdminNavInputs = (rows, pageOptions) => {
|
|
131
132
|
const allowedLinks = new Map(pageOptions.map((option) => [option.href, option.title]));
|
|
132
133
|
const deduped = [];
|
|
133
134
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -177,7 +178,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
177
178
|
try {
|
|
178
179
|
const parsed = JSON.parse(serialized);
|
|
179
180
|
if (Array.isArray(parsed)) {
|
|
180
|
-
return
|
|
181
|
+
return normalizeAdminNavInputs(parsed.slice(0, maxRows), pageOptions);
|
|
181
182
|
}
|
|
182
183
|
} catch {
|
|
183
184
|
}
|
|
@@ -196,7 +197,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
199
|
if (navRows.length > 0) {
|
|
199
|
-
return
|
|
200
|
+
return normalizeAdminNavInputs(navRows, pageOptions);
|
|
200
201
|
}
|
|
201
202
|
return [];
|
|
202
203
|
};
|
|
@@ -225,6 +226,7 @@ export {
|
|
|
225
226
|
buildNestedNavTree,
|
|
226
227
|
buildAdminPageLinkOptions,
|
|
227
228
|
getAdminNavRows,
|
|
229
|
+
normalizeAdminNavInputs,
|
|
228
230
|
parseAdminHeaderNavFromForm,
|
|
229
231
|
roleCanAccessNav,
|
|
230
232
|
navItemIsActive,
|
|
@@ -62,10 +62,17 @@ type AdminPageLinkOption = {
|
|
|
62
62
|
};
|
|
63
63
|
declare const buildAdminPageLinkOptions: (pages: AdminPageRecord[]) => AdminPageLinkOption[];
|
|
64
64
|
declare const getAdminNavRows: (navItems: AdminNavLinkItem[], pageOptions: AdminPageLinkOption[], minRows?: number, maxRows?: number) => number;
|
|
65
|
+
type AdminNavInput = {
|
|
66
|
+
href?: string;
|
|
67
|
+
label?: string;
|
|
68
|
+
parentHref?: string;
|
|
69
|
+
};
|
|
70
|
+
declare const normalizeAdminNavInputs: (rows: AdminNavInput[], pageOptions: AdminPageLinkOption[]) => AdminNavLinkItem[];
|
|
65
71
|
declare const parseAdminHeaderNavFromForm: (formData: FormData, pageOptions: AdminPageLinkOption[], maxRows?: number) => AdminNavLinkItem[];
|
|
66
72
|
|
|
67
73
|
type index_AdminBreadcrumbItem = AdminBreadcrumbItem;
|
|
68
74
|
declare const index_AdminBreadcrumbs: typeof AdminBreadcrumbs;
|
|
75
|
+
type index_AdminNavInput = AdminNavInput;
|
|
69
76
|
type index_AdminNavItem = AdminNavItem;
|
|
70
77
|
type index_AdminNavLinkItem = AdminNavLinkItem;
|
|
71
78
|
declare const index_AdminPage: typeof AdminPage;
|
|
@@ -79,11 +86,12 @@ declare const index_buildAdminPageLinkOptions: typeof buildAdminPageLinkOptions;
|
|
|
79
86
|
declare const index_buildNestedNavTree: typeof buildNestedNavTree;
|
|
80
87
|
declare const index_getAdminNavRows: typeof getAdminNavRows;
|
|
81
88
|
declare const index_navItemIsActive: typeof navItemIsActive;
|
|
89
|
+
declare const index_normalizeAdminNavInputs: typeof normalizeAdminNavInputs;
|
|
82
90
|
declare const index_normalizeNestedNavItems: typeof normalizeNestedNavItems;
|
|
83
91
|
declare const index_parseAdminHeaderNavFromForm: typeof parseAdminHeaderNavFromForm;
|
|
84
92
|
declare const index_roleCanAccessNav: typeof roleCanAccessNav;
|
|
85
93
|
declare namespace index {
|
|
86
|
-
export { type index_AdminBreadcrumbItem as AdminBreadcrumbItem, index_AdminBreadcrumbs as AdminBreadcrumbs, type index_AdminNavItem as AdminNavItem, type index_AdminNavLinkItem as AdminNavLinkItem, index_AdminPage as AdminPage, type index_AdminPageLinkOption as AdminPageLinkOption, type index_AdminPageRecord as AdminPageRecord, type index_AdminRole as AdminRole, type index_NestedNavItem as NestedNavItem, type index_NestedNavItemInput as NestedNavItemInput, type index_NestedNavTree as NestedNavTree, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_buildNestedNavTree as buildNestedNavTree, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_normalizeNestedNavItems as normalizeNestedNavItems, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
94
|
+
export { type index_AdminBreadcrumbItem as AdminBreadcrumbItem, index_AdminBreadcrumbs as AdminBreadcrumbs, type index_AdminNavInput as AdminNavInput, type index_AdminNavItem as AdminNavItem, type index_AdminNavLinkItem as AdminNavLinkItem, index_AdminPage as AdminPage, type index_AdminPageLinkOption as AdminPageLinkOption, type index_AdminPageRecord as AdminPageRecord, type index_AdminRole as AdminRole, type index_NestedNavItem as NestedNavItem, type index_NestedNavItemInput as NestedNavItemInput, type index_NestedNavTree as NestedNavTree, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_buildNestedNavTree as buildNestedNavTree, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_normalizeAdminNavInputs as normalizeAdminNavInputs, index_normalizeNestedNavItems as normalizeNestedNavItems, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type
|
|
97
|
+
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type AdminNavInput as b, type AdminNavItem as c, type AdminNavLinkItem as d, AdminPage as e, type AdminPageLinkOption as f, type AdminPageRecord as g, type AdminRole as h, index as i, type NestedNavItemInput as j, type NestedNavTree as k, buildAdminPageLinkOptions as l, buildNestedNavTree as m, getAdminNavRows as n, navItemIsActive as o, normalizeAdminNavInputs as p, normalizeNestedNavItems as q, parseAdminHeaderNavFromForm as r, roleCanAccessNav as s };
|
|
@@ -62,10 +62,17 @@ type AdminPageLinkOption = {
|
|
|
62
62
|
};
|
|
63
63
|
declare const buildAdminPageLinkOptions: (pages: AdminPageRecord[]) => AdminPageLinkOption[];
|
|
64
64
|
declare const getAdminNavRows: (navItems: AdminNavLinkItem[], pageOptions: AdminPageLinkOption[], minRows?: number, maxRows?: number) => number;
|
|
65
|
+
type AdminNavInput = {
|
|
66
|
+
href?: string;
|
|
67
|
+
label?: string;
|
|
68
|
+
parentHref?: string;
|
|
69
|
+
};
|
|
70
|
+
declare const normalizeAdminNavInputs: (rows: AdminNavInput[], pageOptions: AdminPageLinkOption[]) => AdminNavLinkItem[];
|
|
65
71
|
declare const parseAdminHeaderNavFromForm: (formData: FormData, pageOptions: AdminPageLinkOption[], maxRows?: number) => AdminNavLinkItem[];
|
|
66
72
|
|
|
67
73
|
type index_AdminBreadcrumbItem = AdminBreadcrumbItem;
|
|
68
74
|
declare const index_AdminBreadcrumbs: typeof AdminBreadcrumbs;
|
|
75
|
+
type index_AdminNavInput = AdminNavInput;
|
|
69
76
|
type index_AdminNavItem = AdminNavItem;
|
|
70
77
|
type index_AdminNavLinkItem = AdminNavLinkItem;
|
|
71
78
|
declare const index_AdminPage: typeof AdminPage;
|
|
@@ -79,11 +86,12 @@ declare const index_buildAdminPageLinkOptions: typeof buildAdminPageLinkOptions;
|
|
|
79
86
|
declare const index_buildNestedNavTree: typeof buildNestedNavTree;
|
|
80
87
|
declare const index_getAdminNavRows: typeof getAdminNavRows;
|
|
81
88
|
declare const index_navItemIsActive: typeof navItemIsActive;
|
|
89
|
+
declare const index_normalizeAdminNavInputs: typeof normalizeAdminNavInputs;
|
|
82
90
|
declare const index_normalizeNestedNavItems: typeof normalizeNestedNavItems;
|
|
83
91
|
declare const index_parseAdminHeaderNavFromForm: typeof parseAdminHeaderNavFromForm;
|
|
84
92
|
declare const index_roleCanAccessNav: typeof roleCanAccessNav;
|
|
85
93
|
declare namespace index {
|
|
86
|
-
export { type index_AdminBreadcrumbItem as AdminBreadcrumbItem, index_AdminBreadcrumbs as AdminBreadcrumbs, type index_AdminNavItem as AdminNavItem, type index_AdminNavLinkItem as AdminNavLinkItem, index_AdminPage as AdminPage, type index_AdminPageLinkOption as AdminPageLinkOption, type index_AdminPageRecord as AdminPageRecord, type index_AdminRole as AdminRole, type index_NestedNavItem as NestedNavItem, type index_NestedNavItemInput as NestedNavItemInput, type index_NestedNavTree as NestedNavTree, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_buildNestedNavTree as buildNestedNavTree, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_normalizeNestedNavItems as normalizeNestedNavItems, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
94
|
+
export { type index_AdminBreadcrumbItem as AdminBreadcrumbItem, index_AdminBreadcrumbs as AdminBreadcrumbs, type index_AdminNavInput as AdminNavInput, type index_AdminNavItem as AdminNavItem, type index_AdminNavLinkItem as AdminNavLinkItem, index_AdminPage as AdminPage, type index_AdminPageLinkOption as AdminPageLinkOption, type index_AdminPageRecord as AdminPageRecord, type index_AdminRole as AdminRole, type index_NestedNavItem as NestedNavItem, type index_NestedNavItemInput as NestedNavItemInput, type index_NestedNavTree as NestedNavTree, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_buildNestedNavTree as buildNestedNavTree, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_normalizeAdminNavInputs as normalizeAdminNavInputs, index_normalizeNestedNavItems as normalizeNestedNavItems, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type
|
|
97
|
+
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type AdminNavInput as b, type AdminNavItem as c, type AdminNavLinkItem as d, AdminPage as e, type AdminPageLinkOption as f, type AdminPageRecord as g, type AdminRole as h, index as i, type NestedNavItemInput as j, type NestedNavTree as k, buildAdminPageLinkOptions as l, buildNestedNavTree as m, getAdminNavRows as n, navItemIsActive as o, normalizeAdminNavInputs as p, normalizeNestedNavItems as q, parseAdminHeaderNavFromForm as r, roleCanAccessNav as s };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { i as admin } from './index-Dj21uD_B.mjs';
|
|
2
|
-
export { i as adminApp } from './index-
|
|
2
|
+
export { i as adminApp } from './index-BBvk9b9i.mjs';
|
|
3
3
|
export { i as blocks } from './index-CluwY0ZQ.mjs';
|
|
4
4
|
export { i as nextjs } from './index-CpG3UHcS.mjs';
|
|
5
5
|
export { i as studio } from './index-CmR6NInu.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { i as admin } from './index-Dj21uD_B.js';
|
|
2
|
-
export { i as adminApp } from './index-
|
|
2
|
+
export { i as adminApp } from './index-BBvk9b9i.js';
|
|
3
3
|
export { i as blocks } from './index-CluwY0ZQ.js';
|
|
4
4
|
export { i as nextjs } from './index-CpG3UHcS.js';
|
|
5
5
|
export { i as studio } from './index-CmR6NInu.js';
|
package/dist/index.js
CHANGED
|
@@ -351,6 +351,7 @@ __export(admin_app_exports, {
|
|
|
351
351
|
buildNestedNavTree: () => buildNestedNavTree,
|
|
352
352
|
getAdminNavRows: () => getAdminNavRows,
|
|
353
353
|
navItemIsActive: () => navItemIsActive,
|
|
354
|
+
normalizeAdminNavInputs: () => normalizeAdminNavInputs,
|
|
354
355
|
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
355
356
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
356
357
|
roleCanAccessNav: () => roleCanAccessNav
|
|
@@ -467,7 +468,7 @@ var getAdminNavRows = (navItems, pageOptions, minRows = 6, maxRows = 20) => {
|
|
|
467
468
|
const preferredRows = Math.max(navItems.length + 2, Math.min(8, pageOptions.length));
|
|
468
469
|
return Math.min(Math.max(minRows, preferredRows), maxRows);
|
|
469
470
|
};
|
|
470
|
-
var
|
|
471
|
+
var normalizeAdminNavInputs = (rows, pageOptions) => {
|
|
471
472
|
const allowedLinks = new Map(pageOptions.map((option) => [option.href, option.title]));
|
|
472
473
|
const deduped = [];
|
|
473
474
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -517,7 +518,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
517
518
|
try {
|
|
518
519
|
const parsed = JSON.parse(serialized);
|
|
519
520
|
if (Array.isArray(parsed)) {
|
|
520
|
-
return
|
|
521
|
+
return normalizeAdminNavInputs(parsed.slice(0, maxRows), pageOptions);
|
|
521
522
|
}
|
|
522
523
|
} catch {
|
|
523
524
|
}
|
|
@@ -536,7 +537,7 @@ var parseAdminHeaderNavFromForm = (formData, pageOptions, maxRows = 24) => {
|
|
|
536
537
|
});
|
|
537
538
|
}
|
|
538
539
|
if (navRows.length > 0) {
|
|
539
|
-
return
|
|
540
|
+
return normalizeAdminNavInputs(navRows, pageOptions);
|
|
540
541
|
}
|
|
541
542
|
return [];
|
|
542
543
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
} from "./chunk-7IGLXLUB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
admin_app_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XVH5SCBD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
nextjs_exports
|
|
9
9
|
} from "./chunk-GPQPDEB5.mjs";
|
|
10
10
|
import {
|
|
11
11
|
studio_exports
|
|
12
12
|
} from "./chunk-N67KVM2S.mjs";
|
|
13
|
-
import {
|
|
14
|
-
studio_pages_exports
|
|
15
|
-
} from "./chunk-QW24Y4UH.mjs";
|
|
16
13
|
import {
|
|
17
14
|
blocks_exports
|
|
18
15
|
} from "./chunk-H7DSTEVT.mjs";
|
|
16
|
+
import {
|
|
17
|
+
studio_pages_exports
|
|
18
|
+
} from "./chunk-QW24Y4UH.mjs";
|
|
19
19
|
import "./chunk-SIL2J5MF.mjs";
|
|
20
20
|
import "./chunk-6BWS3CLP.mjs";
|
|
21
21
|
export {
|