@orion-studios/payload-studio 0.5.0-beta.25 → 0.5.0-beta.26
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/index.d.mts +1 -1
- package/dist/admin/index.d.ts +1 -1
- package/dist/admin/index.js +37 -0
- package/dist/admin/index.mjs +3 -1
- package/dist/admin-app/client.js +180 -2
- package/dist/admin-app/client.mjs +178 -1
- package/dist/admin-app/index.d.mts +1 -1
- package/dist/admin-app/index.d.ts +1 -1
- package/dist/admin-app/index.js +50 -0
- package/dist/admin-app/index.mjs +5 -1
- package/dist/admin-app/styles.css +104 -0
- package/dist/{chunk-J7W5EE3B.mjs → chunk-7IGLXLUB.mjs} +37 -0
- package/dist/{chunk-3CO6ZBR2.mjs → chunk-TVQPMM6Y.mjs} +50 -0
- package/dist/{index-Ge9Rh94G.d.ts → index-BheEmI3q.d.mts} +24 -2
- package/dist/{index-Ge9Rh94G.d.mts → index-BheEmI3q.d.ts} +24 -2
- package/dist/{index-DJFhANvJ.d.mts → index-Dj21uD_B.d.mts} +5 -2
- package/dist/{index-DJFhANvJ.d.ts → index-Dj21uD_B.d.ts} +5 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +84 -0
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
package/dist/admin/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AdminConfig, c as configureAdmin, a as createThemePreferenceField, t as themePreferenceField, w as withTooltips } from '../index-
|
|
1
|
+
export { A as AdminConfig, c as configureAdmin, a as createHeaderNavItemsField, b as createThemePreferenceField, t as themePreferenceField, w as withTooltips } from '../index-Dj21uD_B.mjs';
|
|
2
2
|
import 'payload';
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AdminConfig, c as configureAdmin, a as createThemePreferenceField, t as themePreferenceField, w as withTooltips } from '../index-
|
|
1
|
+
export { A as AdminConfig, c as configureAdmin, a as createHeaderNavItemsField, b as createThemePreferenceField, t as themePreferenceField, w as withTooltips } from '../index-Dj21uD_B.js';
|
|
2
2
|
import 'payload';
|
package/dist/admin/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var admin_exports = {};
|
|
32
32
|
__export(admin_exports, {
|
|
33
33
|
configureAdmin: () => configureAdmin,
|
|
34
|
+
createHeaderNavItemsField: () => createHeaderNavItemsField,
|
|
34
35
|
createThemePreferenceField: () => createThemePreferenceField,
|
|
35
36
|
themePreferenceField: () => themePreferenceField,
|
|
36
37
|
withTooltips: () => withTooltips
|
|
@@ -294,9 +295,45 @@ function addTooltipToField(field, tooltips) {
|
|
|
294
295
|
}
|
|
295
296
|
return field;
|
|
296
297
|
}
|
|
298
|
+
|
|
299
|
+
// src/admin/fields/headerNav.ts
|
|
300
|
+
var createHeaderNavItemsField = () => ({
|
|
301
|
+
name: "navItems",
|
|
302
|
+
type: "array",
|
|
303
|
+
labels: { singular: "Navigation Link", plural: "Navigation Links" },
|
|
304
|
+
admin: {
|
|
305
|
+
description: "The links displayed in your website's main navigation menu."
|
|
306
|
+
},
|
|
307
|
+
fields: [
|
|
308
|
+
{
|
|
309
|
+
name: "label",
|
|
310
|
+
type: "text",
|
|
311
|
+
required: true,
|
|
312
|
+
admin: {
|
|
313
|
+
description: "The text shown for this navigation link."
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: "href",
|
|
318
|
+
type: "text",
|
|
319
|
+
required: true,
|
|
320
|
+
admin: {
|
|
321
|
+
description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "parentHref",
|
|
326
|
+
type: "text",
|
|
327
|
+
admin: {
|
|
328
|
+
description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
});
|
|
297
333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
298
334
|
0 && (module.exports = {
|
|
299
335
|
configureAdmin,
|
|
336
|
+
createHeaderNavItemsField,
|
|
300
337
|
createThemePreferenceField,
|
|
301
338
|
themePreferenceField,
|
|
302
339
|
withTooltips
|
package/dist/admin/index.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
configureAdmin,
|
|
3
|
+
createHeaderNavItemsField,
|
|
3
4
|
createThemePreferenceField,
|
|
4
5
|
themePreferenceField,
|
|
5
6
|
withTooltips
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-7IGLXLUB.mjs";
|
|
7
8
|
import "../chunk-6BWS3CLP.mjs";
|
|
8
9
|
export {
|
|
9
10
|
configureAdmin,
|
|
11
|
+
createHeaderNavItemsField,
|
|
10
12
|
createThemePreferenceField,
|
|
11
13
|
themePreferenceField,
|
|
12
14
|
withTooltips
|
package/dist/admin-app/client.js
CHANGED
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/admin-app/client.ts
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
|
-
AdminShellClient: () => AdminShellClient
|
|
24
|
+
AdminShellClient: () => AdminShellClient,
|
|
25
|
+
HeaderNavItemsEditor: () => HeaderNavItemsEditor
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(client_exports);
|
|
27
28
|
|
|
@@ -130,7 +131,184 @@ function AdminShellClient({
|
|
|
130
131
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", { className: "orion-admin-main", children })
|
|
131
132
|
] });
|
|
132
133
|
}
|
|
134
|
+
|
|
135
|
+
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
136
|
+
var import_react2 = require("react");
|
|
137
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
138
|
+
var toRow = (item, index) => ({
|
|
139
|
+
id: `row-${index}-${item.href || "empty"}`,
|
|
140
|
+
href: item.href || "",
|
|
141
|
+
label: item.label || "",
|
|
142
|
+
parentHref: item.parentHref || ""
|
|
143
|
+
});
|
|
144
|
+
var moveRow = (rows, fromIndex, toIndex) => {
|
|
145
|
+
if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= rows.length || toIndex >= rows.length) {
|
|
146
|
+
return rows;
|
|
147
|
+
}
|
|
148
|
+
const next = [...rows];
|
|
149
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
150
|
+
if (!moved) {
|
|
151
|
+
return rows;
|
|
152
|
+
}
|
|
153
|
+
next.splice(toIndex, 0, moved);
|
|
154
|
+
return next;
|
|
155
|
+
};
|
|
156
|
+
function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
157
|
+
const [rows, setRows] = (0, import_react2.useState)(() => initialItems.map(toRow));
|
|
158
|
+
const [nextRowID, setNextRowID] = (0, import_react2.useState)(initialItems.length);
|
|
159
|
+
const [draggingRowID, setDraggingRowID] = (0, import_react2.useState)(null);
|
|
160
|
+
const pageOptionByHref = (0, import_react2.useMemo)(() => new Map(pageOptions.map((option) => [option.href, option])), [pageOptions]);
|
|
161
|
+
const serializedState = (0, import_react2.useMemo)(
|
|
162
|
+
() => JSON.stringify(
|
|
163
|
+
rows.map((row) => ({
|
|
164
|
+
href: row.href.trim(),
|
|
165
|
+
label: row.label.trim(),
|
|
166
|
+
parentHref: row.parentHref.trim() || void 0
|
|
167
|
+
}))
|
|
168
|
+
),
|
|
169
|
+
[rows]
|
|
170
|
+
);
|
|
171
|
+
const setRowValue = (rowID, changes) => {
|
|
172
|
+
setRows(
|
|
173
|
+
(currentRows) => currentRows.map((row) => {
|
|
174
|
+
if (row.id !== rowID) {
|
|
175
|
+
return row;
|
|
176
|
+
}
|
|
177
|
+
const nextRow = { ...row, ...changes };
|
|
178
|
+
if (nextRow.parentHref === nextRow.href) {
|
|
179
|
+
nextRow.parentHref = "";
|
|
180
|
+
}
|
|
181
|
+
return nextRow;
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
const removeRow = (rowID) => {
|
|
186
|
+
setRows((currentRows) => {
|
|
187
|
+
const removedRow = currentRows.find((candidate) => candidate.id === rowID);
|
|
188
|
+
const removedHref = removedRow?.href || "";
|
|
189
|
+
return currentRows.filter((row) => row.id !== rowID).map((row) => removedHref && row.parentHref === removedHref ? { ...row, parentHref: "" } : row);
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
const addRow = () => {
|
|
193
|
+
setRows((currentRows) => [
|
|
194
|
+
...currentRows,
|
|
195
|
+
{
|
|
196
|
+
id: `row-new-${nextRowID}`,
|
|
197
|
+
href: "",
|
|
198
|
+
label: "",
|
|
199
|
+
parentHref: ""
|
|
200
|
+
}
|
|
201
|
+
]);
|
|
202
|
+
setNextRowID((current) => current + 1);
|
|
203
|
+
};
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-nav-editor", children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { name: "navItemsState", readOnly: true, type: "hidden", value: serializedState }),
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-nav-editor-head", children: [
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-nav-editor-title", children: "Navigation Items" }),
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "orion-admin-nav-editor-add", onClick: addRow, type: "button", children: "Add Item" })
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-nav-editor-help", children: "Add only links you want in the menu. Drag rows to reorder. Set a parent to create dropdown items." }),
|
|
211
|
+
rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-nav-editor-empty", children: 'No navigation items yet. Click "Add Item" to start.' }) : null,
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-nav-editor-list", children: rows.map((row, rowIndex) => {
|
|
213
|
+
const parentCandidates = rows.filter((candidate) => candidate.id !== row.id && candidate.href.trim().length > 0).map((candidate) => {
|
|
214
|
+
const resolved = pageOptionByHref.get(candidate.href);
|
|
215
|
+
return {
|
|
216
|
+
href: candidate.href,
|
|
217
|
+
label: candidate.label.trim() || resolved?.title || candidate.href
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
const selectedPage = pageOptionByHref.get(row.href);
|
|
221
|
+
const labelPlaceholder = selectedPage?.title || "Navigation Label";
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
className: "orion-admin-nav-editor-row",
|
|
226
|
+
draggable: true,
|
|
227
|
+
onDragEnd: () => setDraggingRowID(null),
|
|
228
|
+
onDragOver: (event) => event.preventDefault(),
|
|
229
|
+
onDragStart: (event) => {
|
|
230
|
+
setDraggingRowID(row.id);
|
|
231
|
+
event.dataTransfer.effectAllowed = "move";
|
|
232
|
+
},
|
|
233
|
+
onDrop: (event) => {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
if (!draggingRowID || draggingRowID === row.id) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
setRows((currentRows) => {
|
|
239
|
+
const fromIndex = currentRows.findIndex((entry) => entry.id === draggingRowID);
|
|
240
|
+
const toIndex = currentRows.findIndex((entry) => entry.id === row.id);
|
|
241
|
+
return moveRow(currentRows, fromIndex, toIndex);
|
|
242
|
+
});
|
|
243
|
+
setDraggingRowID(null);
|
|
244
|
+
},
|
|
245
|
+
children: [
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-nav-editor-row-head", children: [
|
|
247
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "orion-admin-nav-editor-drag", children: "Drag" }),
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "orion-admin-nav-editor-row-index", children: [
|
|
249
|
+
"#",
|
|
250
|
+
rowIndex + 1
|
|
251
|
+
] }),
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "orion-admin-nav-editor-remove", onClick: () => removeRow(row.id), type: "button", children: "Remove" })
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-nav-editor-row-grid", children: [
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
256
|
+
"Label",
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
258
|
+
"input",
|
|
259
|
+
{
|
|
260
|
+
name: `navLabel_${rowIndex}`,
|
|
261
|
+
onChange: (event) => setRowValue(row.id, { label: event.target.value }),
|
|
262
|
+
placeholder: labelPlaceholder,
|
|
263
|
+
type: "text",
|
|
264
|
+
value: row.label
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
269
|
+
"Page",
|
|
270
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
271
|
+
"select",
|
|
272
|
+
{
|
|
273
|
+
name: `navPage_${rowIndex}`,
|
|
274
|
+
onChange: (event) => {
|
|
275
|
+
const nextHref = event.target.value;
|
|
276
|
+
const nextParent = row.parentHref && row.parentHref === nextHref ? "" : row.parentHref;
|
|
277
|
+
setRowValue(row.id, { href: nextHref, parentHref: nextParent });
|
|
278
|
+
},
|
|
279
|
+
value: row.href,
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "Select page..." }),
|
|
282
|
+
pageOptions.map((pageOption) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: pageOption.href, children: pageOption.label }, `${pageOption.href}-${pageOption.title}`))
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
288
|
+
"Parent (dropdown under)",
|
|
289
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
290
|
+
"select",
|
|
291
|
+
{
|
|
292
|
+
name: `navParentHref_${rowIndex}`,
|
|
293
|
+
onChange: (event) => setRowValue(row.id, { parentHref: event.target.value }),
|
|
294
|
+
value: row.parentHref,
|
|
295
|
+
children: [
|
|
296
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "Top-level item" }),
|
|
297
|
+
parentCandidates.map((candidate) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: candidate.href, children: candidate.label }, `${row.id}-parent-${candidate.href}`))
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
] })
|
|
302
|
+
] })
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
row.id
|
|
306
|
+
);
|
|
307
|
+
}) })
|
|
308
|
+
] });
|
|
309
|
+
}
|
|
133
310
|
// Annotate the CommonJS export names for ESM import in node:
|
|
134
311
|
0 && (module.exports = {
|
|
135
|
-
AdminShellClient
|
|
312
|
+
AdminShellClient,
|
|
313
|
+
HeaderNavItemsEditor
|
|
136
314
|
});
|
|
@@ -105,6 +105,183 @@ function AdminShellClient({
|
|
|
105
105
|
/* @__PURE__ */ jsx("main", { className: "orion-admin-main", children })
|
|
106
106
|
] });
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
// src/admin-app/components/HeaderNavItemsEditor.tsx
|
|
110
|
+
import { useMemo, useState as useState2 } from "react";
|
|
111
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
112
|
+
var toRow = (item, index) => ({
|
|
113
|
+
id: `row-${index}-${item.href || "empty"}`,
|
|
114
|
+
href: item.href || "",
|
|
115
|
+
label: item.label || "",
|
|
116
|
+
parentHref: item.parentHref || ""
|
|
117
|
+
});
|
|
118
|
+
var moveRow = (rows, fromIndex, toIndex) => {
|
|
119
|
+
if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= rows.length || toIndex >= rows.length) {
|
|
120
|
+
return rows;
|
|
121
|
+
}
|
|
122
|
+
const next = [...rows];
|
|
123
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
124
|
+
if (!moved) {
|
|
125
|
+
return rows;
|
|
126
|
+
}
|
|
127
|
+
next.splice(toIndex, 0, moved);
|
|
128
|
+
return next;
|
|
129
|
+
};
|
|
130
|
+
function HeaderNavItemsEditor({ initialItems, pageOptions }) {
|
|
131
|
+
const [rows, setRows] = useState2(() => initialItems.map(toRow));
|
|
132
|
+
const [nextRowID, setNextRowID] = useState2(initialItems.length);
|
|
133
|
+
const [draggingRowID, setDraggingRowID] = useState2(null);
|
|
134
|
+
const pageOptionByHref = useMemo(() => new Map(pageOptions.map((option) => [option.href, option])), [pageOptions]);
|
|
135
|
+
const serializedState = useMemo(
|
|
136
|
+
() => JSON.stringify(
|
|
137
|
+
rows.map((row) => ({
|
|
138
|
+
href: row.href.trim(),
|
|
139
|
+
label: row.label.trim(),
|
|
140
|
+
parentHref: row.parentHref.trim() || void 0
|
|
141
|
+
}))
|
|
142
|
+
),
|
|
143
|
+
[rows]
|
|
144
|
+
);
|
|
145
|
+
const setRowValue = (rowID, changes) => {
|
|
146
|
+
setRows(
|
|
147
|
+
(currentRows) => currentRows.map((row) => {
|
|
148
|
+
if (row.id !== rowID) {
|
|
149
|
+
return row;
|
|
150
|
+
}
|
|
151
|
+
const nextRow = { ...row, ...changes };
|
|
152
|
+
if (nextRow.parentHref === nextRow.href) {
|
|
153
|
+
nextRow.parentHref = "";
|
|
154
|
+
}
|
|
155
|
+
return nextRow;
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
const removeRow = (rowID) => {
|
|
160
|
+
setRows((currentRows) => {
|
|
161
|
+
const removedRow = currentRows.find((candidate) => candidate.id === rowID);
|
|
162
|
+
const removedHref = removedRow?.href || "";
|
|
163
|
+
return currentRows.filter((row) => row.id !== rowID).map((row) => removedHref && row.parentHref === removedHref ? { ...row, parentHref: "" } : row);
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const addRow = () => {
|
|
167
|
+
setRows((currentRows) => [
|
|
168
|
+
...currentRows,
|
|
169
|
+
{
|
|
170
|
+
id: `row-new-${nextRowID}`,
|
|
171
|
+
href: "",
|
|
172
|
+
label: "",
|
|
173
|
+
parentHref: ""
|
|
174
|
+
}
|
|
175
|
+
]);
|
|
176
|
+
setNextRowID((current) => current + 1);
|
|
177
|
+
};
|
|
178
|
+
return /* @__PURE__ */ jsxs2("div", { className: "orion-admin-nav-editor", children: [
|
|
179
|
+
/* @__PURE__ */ jsx2("input", { name: "navItemsState", readOnly: true, type: "hidden", value: serializedState }),
|
|
180
|
+
/* @__PURE__ */ jsxs2("div", { className: "orion-admin-nav-editor-head", children: [
|
|
181
|
+
/* @__PURE__ */ jsx2("div", { className: "orion-admin-nav-editor-title", children: "Navigation Items" }),
|
|
182
|
+
/* @__PURE__ */ jsx2("button", { className: "orion-admin-nav-editor-add", onClick: addRow, type: "button", children: "Add Item" })
|
|
183
|
+
] }),
|
|
184
|
+
/* @__PURE__ */ jsx2("div", { className: "orion-admin-nav-editor-help", children: "Add only links you want in the menu. Drag rows to reorder. Set a parent to create dropdown items." }),
|
|
185
|
+
rows.length === 0 ? /* @__PURE__ */ jsx2("div", { className: "orion-admin-nav-editor-empty", children: 'No navigation items yet. Click "Add Item" to start.' }) : null,
|
|
186
|
+
/* @__PURE__ */ jsx2("div", { className: "orion-admin-nav-editor-list", children: rows.map((row, rowIndex) => {
|
|
187
|
+
const parentCandidates = rows.filter((candidate) => candidate.id !== row.id && candidate.href.trim().length > 0).map((candidate) => {
|
|
188
|
+
const resolved = pageOptionByHref.get(candidate.href);
|
|
189
|
+
return {
|
|
190
|
+
href: candidate.href,
|
|
191
|
+
label: candidate.label.trim() || resolved?.title || candidate.href
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
const selectedPage = pageOptionByHref.get(row.href);
|
|
195
|
+
const labelPlaceholder = selectedPage?.title || "Navigation Label";
|
|
196
|
+
return /* @__PURE__ */ jsxs2(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
className: "orion-admin-nav-editor-row",
|
|
200
|
+
draggable: true,
|
|
201
|
+
onDragEnd: () => setDraggingRowID(null),
|
|
202
|
+
onDragOver: (event) => event.preventDefault(),
|
|
203
|
+
onDragStart: (event) => {
|
|
204
|
+
setDraggingRowID(row.id);
|
|
205
|
+
event.dataTransfer.effectAllowed = "move";
|
|
206
|
+
},
|
|
207
|
+
onDrop: (event) => {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
if (!draggingRowID || draggingRowID === row.id) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
setRows((currentRows) => {
|
|
213
|
+
const fromIndex = currentRows.findIndex((entry) => entry.id === draggingRowID);
|
|
214
|
+
const toIndex = currentRows.findIndex((entry) => entry.id === row.id);
|
|
215
|
+
return moveRow(currentRows, fromIndex, toIndex);
|
|
216
|
+
});
|
|
217
|
+
setDraggingRowID(null);
|
|
218
|
+
},
|
|
219
|
+
children: [
|
|
220
|
+
/* @__PURE__ */ jsxs2("div", { className: "orion-admin-nav-editor-row-head", children: [
|
|
221
|
+
/* @__PURE__ */ jsx2("span", { className: "orion-admin-nav-editor-drag", children: "Drag" }),
|
|
222
|
+
/* @__PURE__ */ jsxs2("span", { className: "orion-admin-nav-editor-row-index", children: [
|
|
223
|
+
"#",
|
|
224
|
+
rowIndex + 1
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsx2("button", { className: "orion-admin-nav-editor-remove", onClick: () => removeRow(row.id), type: "button", children: "Remove" })
|
|
227
|
+
] }),
|
|
228
|
+
/* @__PURE__ */ jsxs2("div", { className: "orion-admin-nav-editor-row-grid", children: [
|
|
229
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
230
|
+
"Label",
|
|
231
|
+
/* @__PURE__ */ jsx2(
|
|
232
|
+
"input",
|
|
233
|
+
{
|
|
234
|
+
name: `navLabel_${rowIndex}`,
|
|
235
|
+
onChange: (event) => setRowValue(row.id, { label: event.target.value }),
|
|
236
|
+
placeholder: labelPlaceholder,
|
|
237
|
+
type: "text",
|
|
238
|
+
value: row.label
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }),
|
|
242
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
243
|
+
"Page",
|
|
244
|
+
/* @__PURE__ */ jsxs2(
|
|
245
|
+
"select",
|
|
246
|
+
{
|
|
247
|
+
name: `navPage_${rowIndex}`,
|
|
248
|
+
onChange: (event) => {
|
|
249
|
+
const nextHref = event.target.value;
|
|
250
|
+
const nextParent = row.parentHref && row.parentHref === nextHref ? "" : row.parentHref;
|
|
251
|
+
setRowValue(row.id, { href: nextHref, parentHref: nextParent });
|
|
252
|
+
},
|
|
253
|
+
value: row.href,
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ jsx2("option", { value: "", children: "Select page..." }),
|
|
256
|
+
pageOptions.map((pageOption) => /* @__PURE__ */ jsx2("option", { value: pageOption.href, children: pageOption.label }, `${pageOption.href}-${pageOption.title}`))
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
] }),
|
|
261
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
262
|
+
"Parent (dropdown under)",
|
|
263
|
+
/* @__PURE__ */ jsxs2(
|
|
264
|
+
"select",
|
|
265
|
+
{
|
|
266
|
+
name: `navParentHref_${rowIndex}`,
|
|
267
|
+
onChange: (event) => setRowValue(row.id, { parentHref: event.target.value }),
|
|
268
|
+
value: row.parentHref,
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ jsx2("option", { value: "", children: "Top-level item" }),
|
|
271
|
+
parentCandidates.map((candidate) => /* @__PURE__ */ jsx2("option", { value: candidate.href, children: candidate.label }, `${row.id}-parent-${candidate.href}`))
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
] })
|
|
276
|
+
] })
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
row.id
|
|
280
|
+
);
|
|
281
|
+
}) })
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
108
284
|
export {
|
|
109
|
-
AdminShellClient
|
|
285
|
+
AdminShellClient,
|
|
286
|
+
HeaderNavItemsEditor
|
|
110
287
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as AdminNavItem, c as AdminNavLinkItem, d as AdminPage, e as AdminPageLinkOption, f as AdminPageRecord, g as AdminRole, h as
|
|
1
|
+
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as AdminNavItem, c as AdminNavLinkItem, d as AdminPage, e as AdminPageLinkOption, f as AdminPageRecord, g as AdminRole, N as NestedNavItem, h as NestedNavItemInput, j as NestedNavTree, k as buildAdminPageLinkOptions, l as buildNestedNavTree, m as getAdminNavRows, n as navItemIsActive, o as normalizeNestedNavItems, p as parseAdminHeaderNavFromForm, r as roleCanAccessNav } from '../index-BheEmI3q.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 AdminNavItem, c as AdminNavLinkItem, d as AdminPage, e as AdminPageLinkOption, f as AdminPageRecord, g as AdminRole, h as
|
|
1
|
+
export { A as AdminBreadcrumbItem, a as AdminBreadcrumbs, b as AdminNavItem, c as AdminNavLinkItem, d as AdminPage, e as AdminPageLinkOption, f as AdminPageRecord, g as AdminRole, N as NestedNavItem, h as NestedNavItemInput, j as NestedNavTree, k as buildAdminPageLinkOptions, l as buildNestedNavTree, m as getAdminNavRows, n as navItemIsActive, o as normalizeNestedNavItems, p as parseAdminHeaderNavFromForm, r as roleCanAccessNav } from '../index-BheEmI3q.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
package/dist/admin-app/index.js
CHANGED
|
@@ -23,8 +23,10 @@ __export(admin_app_exports, {
|
|
|
23
23
|
AdminBreadcrumbs: () => AdminBreadcrumbs,
|
|
24
24
|
AdminPage: () => AdminPage,
|
|
25
25
|
buildAdminPageLinkOptions: () => buildAdminPageLinkOptions,
|
|
26
|
+
buildNestedNavTree: () => buildNestedNavTree,
|
|
26
27
|
getAdminNavRows: () => getAdminNavRows,
|
|
27
28
|
navItemIsActive: () => navItemIsActive,
|
|
29
|
+
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
28
30
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
29
31
|
roleCanAccessNav: () => roleCanAccessNav
|
|
30
32
|
});
|
|
@@ -60,6 +62,52 @@ function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
|
60
62
|
] });
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
// src/admin-app/nestedNavigation.ts
|
|
66
|
+
var normalizeNestedNavItems = (items) => {
|
|
67
|
+
const deduped = [];
|
|
68
|
+
const seen = /* @__PURE__ */ new Set();
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
71
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
72
|
+
const parentHref = typeof item.parentHref === "string" ? item.parentHref.trim() : "";
|
|
73
|
+
if (!href || !label || seen.has(href)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
seen.add(href);
|
|
77
|
+
deduped.push({
|
|
78
|
+
href,
|
|
79
|
+
label,
|
|
80
|
+
...parentHref ? { parentHref } : {}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
84
|
+
return deduped.map((item) => ({
|
|
85
|
+
href: item.href,
|
|
86
|
+
label: item.label,
|
|
87
|
+
...item.parentHref && item.parentHref !== item.href && hrefs.has(item.parentHref) ? { parentHref: item.parentHref } : {}
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
var buildNestedNavTree = (items) => {
|
|
91
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
92
|
+
const topLevel = [];
|
|
93
|
+
for (const item of items) {
|
|
94
|
+
if (!item.parentHref) {
|
|
95
|
+
topLevel.push(item);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const children = childrenByParent.get(item.parentHref) || [];
|
|
99
|
+
children.push(item);
|
|
100
|
+
childrenByParent.set(item.parentHref, children);
|
|
101
|
+
}
|
|
102
|
+
if (topLevel.length === 0 && items.length > 0) {
|
|
103
|
+
return {
|
|
104
|
+
topLevel: items.map((item) => ({ href: item.href, label: item.label })),
|
|
105
|
+
childrenByParent: /* @__PURE__ */ new Map()
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return { childrenByParent, topLevel };
|
|
109
|
+
};
|
|
110
|
+
|
|
63
111
|
// src/admin-app/navigationLinks.ts
|
|
64
112
|
var fallbackHomeOption = {
|
|
65
113
|
href: "/",
|
|
@@ -190,8 +238,10 @@ var navItemIsActive = (pathname, item) => {
|
|
|
190
238
|
AdminBreadcrumbs,
|
|
191
239
|
AdminPage,
|
|
192
240
|
buildAdminPageLinkOptions,
|
|
241
|
+
buildNestedNavTree,
|
|
193
242
|
getAdminNavRows,
|
|
194
243
|
navItemIsActive,
|
|
244
|
+
normalizeNestedNavItems,
|
|
195
245
|
parseAdminHeaderNavFromForm,
|
|
196
246
|
roleCanAccessNav
|
|
197
247
|
});
|
package/dist/admin-app/index.mjs
CHANGED
|
@@ -2,18 +2,22 @@ import {
|
|
|
2
2
|
AdminBreadcrumbs,
|
|
3
3
|
AdminPage,
|
|
4
4
|
buildAdminPageLinkOptions,
|
|
5
|
+
buildNestedNavTree,
|
|
5
6
|
getAdminNavRows,
|
|
6
7
|
navItemIsActive,
|
|
8
|
+
normalizeNestedNavItems,
|
|
7
9
|
parseAdminHeaderNavFromForm,
|
|
8
10
|
roleCanAccessNav
|
|
9
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-TVQPMM6Y.mjs";
|
|
10
12
|
import "../chunk-6BWS3CLP.mjs";
|
|
11
13
|
export {
|
|
12
14
|
AdminBreadcrumbs,
|
|
13
15
|
AdminPage,
|
|
14
16
|
buildAdminPageLinkOptions,
|
|
17
|
+
buildNestedNavTree,
|
|
15
18
|
getAdminNavRows,
|
|
16
19
|
navItemIsActive,
|
|
20
|
+
normalizeNestedNavItems,
|
|
17
21
|
parseAdminHeaderNavFromForm,
|
|
18
22
|
roleCanAccessNav
|
|
19
23
|
};
|
|
@@ -120,3 +120,107 @@
|
|
|
120
120
|
max-width: none;
|
|
121
121
|
width: 100%;
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
.orion-admin-nav-editor {
|
|
125
|
+
border: 1px solid var(--orion-admin-card-border);
|
|
126
|
+
border-radius: 12px;
|
|
127
|
+
display: grid;
|
|
128
|
+
gap: 0.65rem;
|
|
129
|
+
padding: 0.75rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.orion-admin-nav-editor-head {
|
|
133
|
+
align-items: center;
|
|
134
|
+
display: flex;
|
|
135
|
+
justify-content: space-between;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.orion-admin-nav-editor-title {
|
|
139
|
+
font-weight: 800;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.orion-admin-nav-editor-add {
|
|
143
|
+
background: #111;
|
|
144
|
+
border: 0;
|
|
145
|
+
border-radius: 999px;
|
|
146
|
+
color: #fff;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
font-size: 0.86rem;
|
|
149
|
+
font-weight: 800;
|
|
150
|
+
padding: 0.35rem 0.7rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.orion-admin-nav-editor-help {
|
|
154
|
+
color: var(--orion-admin-muted);
|
|
155
|
+
font-size: 0.84rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.orion-admin-nav-editor-empty {
|
|
159
|
+
background: #f2f5f3;
|
|
160
|
+
border: 1px dashed var(--orion-admin-border);
|
|
161
|
+
border-radius: 10px;
|
|
162
|
+
color: var(--orion-admin-muted);
|
|
163
|
+
font-size: 0.9rem;
|
|
164
|
+
padding: 0.7rem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.orion-admin-nav-editor-list {
|
|
168
|
+
display: grid;
|
|
169
|
+
gap: 0.55rem;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.orion-admin-nav-editor-row {
|
|
173
|
+
background: #fff;
|
|
174
|
+
border: 1px solid var(--orion-admin-border);
|
|
175
|
+
border-radius: 10px;
|
|
176
|
+
display: grid;
|
|
177
|
+
gap: 0.5rem;
|
|
178
|
+
padding: 0.65rem;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.orion-admin-nav-editor-row-head {
|
|
182
|
+
align-items: center;
|
|
183
|
+
display: flex;
|
|
184
|
+
gap: 0.6rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.orion-admin-nav-editor-drag {
|
|
188
|
+
background: #e8efeb;
|
|
189
|
+
border-radius: 999px;
|
|
190
|
+
color: #255543;
|
|
191
|
+
cursor: grab;
|
|
192
|
+
font-size: 0.75rem;
|
|
193
|
+
font-weight: 800;
|
|
194
|
+
padding: 0.2rem 0.5rem;
|
|
195
|
+
text-transform: uppercase;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.orion-admin-nav-editor-row-index {
|
|
199
|
+
color: var(--orion-admin-muted);
|
|
200
|
+
font-size: 0.82rem;
|
|
201
|
+
font-weight: 700;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.orion-admin-nav-editor-remove {
|
|
205
|
+
background: #8c1f1f;
|
|
206
|
+
border: 0;
|
|
207
|
+
border-radius: 999px;
|
|
208
|
+
color: #fff;
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
font-size: 0.8rem;
|
|
211
|
+
font-weight: 700;
|
|
212
|
+
margin-left: auto;
|
|
213
|
+
padding: 0.25rem 0.6rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.orion-admin-nav-editor-row-grid {
|
|
217
|
+
display: grid;
|
|
218
|
+
gap: 0.5rem;
|
|
219
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@media (max-width: 1024px) {
|
|
223
|
+
.orion-admin-nav-editor-row-grid {
|
|
224
|
+
grid-template-columns: 1fr;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
var admin_exports = {};
|
|
8
8
|
__export(admin_exports, {
|
|
9
9
|
configureAdmin: () => configureAdmin,
|
|
10
|
+
createHeaderNavItemsField: () => createHeaderNavItemsField,
|
|
10
11
|
createThemePreferenceField: () => createThemePreferenceField,
|
|
11
12
|
themePreferenceField: () => themePreferenceField,
|
|
12
13
|
withTooltips: () => withTooltips
|
|
@@ -269,10 +270,46 @@ function addTooltipToField(field, tooltips) {
|
|
|
269
270
|
return field;
|
|
270
271
|
}
|
|
271
272
|
|
|
273
|
+
// src/admin/fields/headerNav.ts
|
|
274
|
+
var createHeaderNavItemsField = () => ({
|
|
275
|
+
name: "navItems",
|
|
276
|
+
type: "array",
|
|
277
|
+
labels: { singular: "Navigation Link", plural: "Navigation Links" },
|
|
278
|
+
admin: {
|
|
279
|
+
description: "The links displayed in your website's main navigation menu."
|
|
280
|
+
},
|
|
281
|
+
fields: [
|
|
282
|
+
{
|
|
283
|
+
name: "label",
|
|
284
|
+
type: "text",
|
|
285
|
+
required: true,
|
|
286
|
+
admin: {
|
|
287
|
+
description: "The text shown for this navigation link."
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: "href",
|
|
292
|
+
type: "text",
|
|
293
|
+
required: true,
|
|
294
|
+
admin: {
|
|
295
|
+
description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "parentHref",
|
|
300
|
+
type: "text",
|
|
301
|
+
admin: {
|
|
302
|
+
description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
});
|
|
307
|
+
|
|
272
308
|
export {
|
|
273
309
|
createThemePreferenceField,
|
|
274
310
|
themePreferenceField,
|
|
275
311
|
configureAdmin,
|
|
276
312
|
withTooltips,
|
|
313
|
+
createHeaderNavItemsField,
|
|
277
314
|
admin_exports
|
|
278
315
|
};
|
|
@@ -8,8 +8,10 @@ __export(admin_app_exports, {
|
|
|
8
8
|
AdminBreadcrumbs: () => AdminBreadcrumbs,
|
|
9
9
|
AdminPage: () => AdminPage,
|
|
10
10
|
buildAdminPageLinkOptions: () => buildAdminPageLinkOptions,
|
|
11
|
+
buildNestedNavTree: () => buildNestedNavTree,
|
|
11
12
|
getAdminNavRows: () => getAdminNavRows,
|
|
12
13
|
navItemIsActive: () => navItemIsActive,
|
|
14
|
+
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
13
15
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
14
16
|
roleCanAccessNav: () => roleCanAccessNav
|
|
15
17
|
});
|
|
@@ -44,6 +46,52 @@ function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
|
44
46
|
] });
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
// src/admin-app/nestedNavigation.ts
|
|
50
|
+
var normalizeNestedNavItems = (items) => {
|
|
51
|
+
const deduped = [];
|
|
52
|
+
const seen = /* @__PURE__ */ new Set();
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
55
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
56
|
+
const parentHref = typeof item.parentHref === "string" ? item.parentHref.trim() : "";
|
|
57
|
+
if (!href || !label || seen.has(href)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
seen.add(href);
|
|
61
|
+
deduped.push({
|
|
62
|
+
href,
|
|
63
|
+
label,
|
|
64
|
+
...parentHref ? { parentHref } : {}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
68
|
+
return deduped.map((item) => ({
|
|
69
|
+
href: item.href,
|
|
70
|
+
label: item.label,
|
|
71
|
+
...item.parentHref && item.parentHref !== item.href && hrefs.has(item.parentHref) ? { parentHref: item.parentHref } : {}
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
var buildNestedNavTree = (items) => {
|
|
75
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
76
|
+
const topLevel = [];
|
|
77
|
+
for (const item of items) {
|
|
78
|
+
if (!item.parentHref) {
|
|
79
|
+
topLevel.push(item);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const children = childrenByParent.get(item.parentHref) || [];
|
|
83
|
+
children.push(item);
|
|
84
|
+
childrenByParent.set(item.parentHref, children);
|
|
85
|
+
}
|
|
86
|
+
if (topLevel.length === 0 && items.length > 0) {
|
|
87
|
+
return {
|
|
88
|
+
topLevel: items.map((item) => ({ href: item.href, label: item.label })),
|
|
89
|
+
childrenByParent: /* @__PURE__ */ new Map()
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return { childrenByParent, topLevel };
|
|
93
|
+
};
|
|
94
|
+
|
|
47
95
|
// src/admin-app/navigationLinks.ts
|
|
48
96
|
var fallbackHomeOption = {
|
|
49
97
|
href: "/",
|
|
@@ -173,6 +221,8 @@ var navItemIsActive = (pathname, item) => {
|
|
|
173
221
|
export {
|
|
174
222
|
AdminBreadcrumbs,
|
|
175
223
|
AdminPage,
|
|
224
|
+
normalizeNestedNavItems,
|
|
225
|
+
buildNestedNavTree,
|
|
176
226
|
buildAdminPageLinkOptions,
|
|
177
227
|
getAdminNavRows,
|
|
178
228
|
parseAdminHeaderNavFromForm,
|
|
@@ -29,6 +29,23 @@ type AdminPageProps = {
|
|
|
29
29
|
};
|
|
30
30
|
declare function AdminPage({ title, description, breadcrumbs, actions, children }: AdminPageProps): react_jsx_runtime.JSX.Element;
|
|
31
31
|
|
|
32
|
+
type NestedNavItemInput = {
|
|
33
|
+
href?: string;
|
|
34
|
+
label?: string;
|
|
35
|
+
parentHref?: string;
|
|
36
|
+
};
|
|
37
|
+
type NestedNavItem = {
|
|
38
|
+
href: string;
|
|
39
|
+
label: string;
|
|
40
|
+
parentHref?: string;
|
|
41
|
+
};
|
|
42
|
+
type NestedNavTree = {
|
|
43
|
+
topLevel: NestedNavItem[];
|
|
44
|
+
childrenByParent: Map<string, NestedNavItem[]>;
|
|
45
|
+
};
|
|
46
|
+
declare const normalizeNestedNavItems: <T extends NestedNavItemInput>(items: T[]) => NestedNavItem[];
|
|
47
|
+
declare const buildNestedNavTree: (items: NestedNavItem[]) => NestedNavTree;
|
|
48
|
+
|
|
32
49
|
type AdminNavLinkItem = {
|
|
33
50
|
href: string;
|
|
34
51
|
label: string;
|
|
@@ -55,13 +72,18 @@ declare const index_AdminPage: typeof AdminPage;
|
|
|
55
72
|
type index_AdminPageLinkOption = AdminPageLinkOption;
|
|
56
73
|
type index_AdminPageRecord = AdminPageRecord;
|
|
57
74
|
type index_AdminRole = AdminRole;
|
|
75
|
+
type index_NestedNavItem = NestedNavItem;
|
|
76
|
+
type index_NestedNavItemInput = NestedNavItemInput;
|
|
77
|
+
type index_NestedNavTree = NestedNavTree;
|
|
58
78
|
declare const index_buildAdminPageLinkOptions: typeof buildAdminPageLinkOptions;
|
|
79
|
+
declare const index_buildNestedNavTree: typeof buildNestedNavTree;
|
|
59
80
|
declare const index_getAdminNavRows: typeof getAdminNavRows;
|
|
60
81
|
declare const index_navItemIsActive: typeof navItemIsActive;
|
|
82
|
+
declare const index_normalizeNestedNavItems: typeof normalizeNestedNavItems;
|
|
61
83
|
declare const index_parseAdminHeaderNavFromForm: typeof parseAdminHeaderNavFromForm;
|
|
62
84
|
declare const index_roleCanAccessNav: typeof roleCanAccessNav;
|
|
63
85
|
declare namespace index {
|
|
64
|
-
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, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
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 };
|
|
65
87
|
}
|
|
66
88
|
|
|
67
|
-
export { type AdminBreadcrumbItem as A, AdminBreadcrumbs as a, type AdminNavItem as b, type AdminNavLinkItem as c, AdminPage as d, type AdminPageLinkOption as e, type AdminPageRecord as f, type AdminRole as g,
|
|
89
|
+
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type AdminNavItem as b, type AdminNavLinkItem as c, AdminPage as d, type AdminPageLinkOption as e, type AdminPageRecord as f, type AdminRole as g, type NestedNavItemInput as h, index as i, type NestedNavTree as j, buildAdminPageLinkOptions as k, buildNestedNavTree as l, getAdminNavRows as m, navItemIsActive as n, normalizeNestedNavItems as o, parseAdminHeaderNavFromForm as p, roleCanAccessNav as r };
|
|
@@ -29,6 +29,23 @@ type AdminPageProps = {
|
|
|
29
29
|
};
|
|
30
30
|
declare function AdminPage({ title, description, breadcrumbs, actions, children }: AdminPageProps): react_jsx_runtime.JSX.Element;
|
|
31
31
|
|
|
32
|
+
type NestedNavItemInput = {
|
|
33
|
+
href?: string;
|
|
34
|
+
label?: string;
|
|
35
|
+
parentHref?: string;
|
|
36
|
+
};
|
|
37
|
+
type NestedNavItem = {
|
|
38
|
+
href: string;
|
|
39
|
+
label: string;
|
|
40
|
+
parentHref?: string;
|
|
41
|
+
};
|
|
42
|
+
type NestedNavTree = {
|
|
43
|
+
topLevel: NestedNavItem[];
|
|
44
|
+
childrenByParent: Map<string, NestedNavItem[]>;
|
|
45
|
+
};
|
|
46
|
+
declare const normalizeNestedNavItems: <T extends NestedNavItemInput>(items: T[]) => NestedNavItem[];
|
|
47
|
+
declare const buildNestedNavTree: (items: NestedNavItem[]) => NestedNavTree;
|
|
48
|
+
|
|
32
49
|
type AdminNavLinkItem = {
|
|
33
50
|
href: string;
|
|
34
51
|
label: string;
|
|
@@ -55,13 +72,18 @@ declare const index_AdminPage: typeof AdminPage;
|
|
|
55
72
|
type index_AdminPageLinkOption = AdminPageLinkOption;
|
|
56
73
|
type index_AdminPageRecord = AdminPageRecord;
|
|
57
74
|
type index_AdminRole = AdminRole;
|
|
75
|
+
type index_NestedNavItem = NestedNavItem;
|
|
76
|
+
type index_NestedNavItemInput = NestedNavItemInput;
|
|
77
|
+
type index_NestedNavTree = NestedNavTree;
|
|
58
78
|
declare const index_buildAdminPageLinkOptions: typeof buildAdminPageLinkOptions;
|
|
79
|
+
declare const index_buildNestedNavTree: typeof buildNestedNavTree;
|
|
59
80
|
declare const index_getAdminNavRows: typeof getAdminNavRows;
|
|
60
81
|
declare const index_navItemIsActive: typeof navItemIsActive;
|
|
82
|
+
declare const index_normalizeNestedNavItems: typeof normalizeNestedNavItems;
|
|
61
83
|
declare const index_parseAdminHeaderNavFromForm: typeof parseAdminHeaderNavFromForm;
|
|
62
84
|
declare const index_roleCanAccessNav: typeof roleCanAccessNav;
|
|
63
85
|
declare namespace index {
|
|
64
|
-
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, index_buildAdminPageLinkOptions as buildAdminPageLinkOptions, index_getAdminNavRows as getAdminNavRows, index_navItemIsActive as navItemIsActive, index_parseAdminHeaderNavFromForm as parseAdminHeaderNavFromForm, index_roleCanAccessNav as roleCanAccessNav };
|
|
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 };
|
|
65
87
|
}
|
|
66
88
|
|
|
67
|
-
export { type AdminBreadcrumbItem as A, AdminBreadcrumbs as a, type AdminNavItem as b, type AdminNavLinkItem as c, AdminPage as d, type AdminPageLinkOption as e, type AdminPageRecord as f, type AdminRole as g,
|
|
89
|
+
export { type AdminBreadcrumbItem as A, type NestedNavItem as N, AdminBreadcrumbs as a, type AdminNavItem as b, type AdminNavLinkItem as c, AdminPage as d, type AdminPageLinkOption as e, type AdminPageRecord as f, type AdminRole as g, type NestedNavItemInput as h, index as i, type NestedNavTree as j, buildAdminPageLinkOptions as k, buildNestedNavTree as l, getAdminNavRows as m, navItemIsActive as n, normalizeNestedNavItems as o, parseAdminHeaderNavFromForm as p, roleCanAccessNav as r };
|
|
@@ -116,13 +116,16 @@ declare function configureAdmin(config: AdminConfig): {
|
|
|
116
116
|
|
|
117
117
|
declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
|
|
118
118
|
|
|
119
|
+
declare const createHeaderNavItemsField: () => Field;
|
|
120
|
+
|
|
119
121
|
type index_AdminConfig = AdminConfig;
|
|
120
122
|
declare const index_configureAdmin: typeof configureAdmin;
|
|
123
|
+
declare const index_createHeaderNavItemsField: typeof createHeaderNavItemsField;
|
|
121
124
|
declare const index_createThemePreferenceField: typeof createThemePreferenceField;
|
|
122
125
|
declare const index_themePreferenceField: typeof themePreferenceField;
|
|
123
126
|
declare const index_withTooltips: typeof withTooltips;
|
|
124
127
|
declare namespace index {
|
|
125
|
-
export { type index_AdminConfig as AdminConfig, index_configureAdmin as configureAdmin, index_createThemePreferenceField as createThemePreferenceField, index_themePreferenceField as themePreferenceField, index_withTooltips as withTooltips };
|
|
128
|
+
export { type index_AdminConfig as AdminConfig, index_configureAdmin as configureAdmin, index_createHeaderNavItemsField as createHeaderNavItemsField, index_createThemePreferenceField as createThemePreferenceField, index_themePreferenceField as themePreferenceField, index_withTooltips as withTooltips };
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
export { type AdminConfig as A,
|
|
131
|
+
export { type AdminConfig as A, createHeaderNavItemsField as a, createThemePreferenceField as b, configureAdmin as c, index as i, themePreferenceField as t, withTooltips as w };
|
|
@@ -116,13 +116,16 @@ declare function configureAdmin(config: AdminConfig): {
|
|
|
116
116
|
|
|
117
117
|
declare function withTooltips(fields: Field[], customTooltips?: Record<string, string>): Field[];
|
|
118
118
|
|
|
119
|
+
declare const createHeaderNavItemsField: () => Field;
|
|
120
|
+
|
|
119
121
|
type index_AdminConfig = AdminConfig;
|
|
120
122
|
declare const index_configureAdmin: typeof configureAdmin;
|
|
123
|
+
declare const index_createHeaderNavItemsField: typeof createHeaderNavItemsField;
|
|
121
124
|
declare const index_createThemePreferenceField: typeof createThemePreferenceField;
|
|
122
125
|
declare const index_themePreferenceField: typeof themePreferenceField;
|
|
123
126
|
declare const index_withTooltips: typeof withTooltips;
|
|
124
127
|
declare namespace index {
|
|
125
|
-
export { type index_AdminConfig as AdminConfig, index_configureAdmin as configureAdmin, index_createThemePreferenceField as createThemePreferenceField, index_themePreferenceField as themePreferenceField, index_withTooltips as withTooltips };
|
|
128
|
+
export { type index_AdminConfig as AdminConfig, index_configureAdmin as configureAdmin, index_createHeaderNavItemsField as createHeaderNavItemsField, index_createThemePreferenceField as createThemePreferenceField, index_themePreferenceField as themePreferenceField, index_withTooltips as withTooltips };
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
export { type AdminConfig as A,
|
|
131
|
+
export { type AdminConfig as A, createHeaderNavItemsField as a, createThemePreferenceField as b, configureAdmin as c, index as i, themePreferenceField as t, withTooltips as w };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { i as admin } from './index-
|
|
2
|
-
export { i as adminApp } from './index-
|
|
1
|
+
export { i as admin } from './index-Dj21uD_B.mjs';
|
|
2
|
+
export { i as adminApp } from './index-BheEmI3q.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
|
-
export { i as admin } from './index-
|
|
2
|
-
export { i as adminApp } from './index-
|
|
1
|
+
export { i as admin } from './index-Dj21uD_B.js';
|
|
2
|
+
export { i as adminApp } from './index-BheEmI3q.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
|
@@ -43,6 +43,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
43
43
|
var admin_exports = {};
|
|
44
44
|
__export(admin_exports, {
|
|
45
45
|
configureAdmin: () => configureAdmin,
|
|
46
|
+
createHeaderNavItemsField: () => createHeaderNavItemsField,
|
|
46
47
|
createThemePreferenceField: () => createThemePreferenceField,
|
|
47
48
|
themePreferenceField: () => themePreferenceField,
|
|
48
49
|
withTooltips: () => withTooltips
|
|
@@ -306,14 +307,51 @@ function addTooltipToField(field, tooltips) {
|
|
|
306
307
|
return field;
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
// src/admin/fields/headerNav.ts
|
|
311
|
+
var createHeaderNavItemsField = () => ({
|
|
312
|
+
name: "navItems",
|
|
313
|
+
type: "array",
|
|
314
|
+
labels: { singular: "Navigation Link", plural: "Navigation Links" },
|
|
315
|
+
admin: {
|
|
316
|
+
description: "The links displayed in your website's main navigation menu."
|
|
317
|
+
},
|
|
318
|
+
fields: [
|
|
319
|
+
{
|
|
320
|
+
name: "label",
|
|
321
|
+
type: "text",
|
|
322
|
+
required: true,
|
|
323
|
+
admin: {
|
|
324
|
+
description: "The text shown for this navigation link."
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "href",
|
|
329
|
+
type: "text",
|
|
330
|
+
required: true,
|
|
331
|
+
admin: {
|
|
332
|
+
description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "parentHref",
|
|
337
|
+
type: "text",
|
|
338
|
+
admin: {
|
|
339
|
+
description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
|
|
309
345
|
// src/admin-app/index.ts
|
|
310
346
|
var admin_app_exports = {};
|
|
311
347
|
__export(admin_app_exports, {
|
|
312
348
|
AdminBreadcrumbs: () => AdminBreadcrumbs,
|
|
313
349
|
AdminPage: () => AdminPage,
|
|
314
350
|
buildAdminPageLinkOptions: () => buildAdminPageLinkOptions,
|
|
351
|
+
buildNestedNavTree: () => buildNestedNavTree,
|
|
315
352
|
getAdminNavRows: () => getAdminNavRows,
|
|
316
353
|
navItemIsActive: () => navItemIsActive,
|
|
354
|
+
normalizeNestedNavItems: () => normalizeNestedNavItems,
|
|
317
355
|
parseAdminHeaderNavFromForm: () => parseAdminHeaderNavFromForm,
|
|
318
356
|
roleCanAccessNav: () => roleCanAccessNav
|
|
319
357
|
});
|
|
@@ -348,6 +386,52 @@ function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
|
348
386
|
] });
|
|
349
387
|
}
|
|
350
388
|
|
|
389
|
+
// src/admin-app/nestedNavigation.ts
|
|
390
|
+
var normalizeNestedNavItems = (items) => {
|
|
391
|
+
const deduped = [];
|
|
392
|
+
const seen = /* @__PURE__ */ new Set();
|
|
393
|
+
for (const item of items) {
|
|
394
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
395
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
396
|
+
const parentHref = typeof item.parentHref === "string" ? item.parentHref.trim() : "";
|
|
397
|
+
if (!href || !label || seen.has(href)) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
seen.add(href);
|
|
401
|
+
deduped.push({
|
|
402
|
+
href,
|
|
403
|
+
label,
|
|
404
|
+
...parentHref ? { parentHref } : {}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
const hrefs = new Set(deduped.map((item) => item.href));
|
|
408
|
+
return deduped.map((item) => ({
|
|
409
|
+
href: item.href,
|
|
410
|
+
label: item.label,
|
|
411
|
+
...item.parentHref && item.parentHref !== item.href && hrefs.has(item.parentHref) ? { parentHref: item.parentHref } : {}
|
|
412
|
+
}));
|
|
413
|
+
};
|
|
414
|
+
var buildNestedNavTree = (items) => {
|
|
415
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
416
|
+
const topLevel = [];
|
|
417
|
+
for (const item of items) {
|
|
418
|
+
if (!item.parentHref) {
|
|
419
|
+
topLevel.push(item);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
const children = childrenByParent.get(item.parentHref) || [];
|
|
423
|
+
children.push(item);
|
|
424
|
+
childrenByParent.set(item.parentHref, children);
|
|
425
|
+
}
|
|
426
|
+
if (topLevel.length === 0 && items.length > 0) {
|
|
427
|
+
return {
|
|
428
|
+
topLevel: items.map((item) => ({ href: item.href, label: item.label })),
|
|
429
|
+
childrenByParent: /* @__PURE__ */ new Map()
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
return { childrenByParent, topLevel };
|
|
433
|
+
};
|
|
434
|
+
|
|
351
435
|
// src/admin-app/navigationLinks.ts
|
|
352
436
|
var fallbackHomeOption = {
|
|
353
437
|
href: "/",
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
admin_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7IGLXLUB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
nextjs_exports
|
|
6
6
|
} from "./chunk-GPQPDEB5.mjs";
|
|
7
|
-
import {
|
|
8
|
-
studio_exports
|
|
9
|
-
} from "./chunk-N67KVM2S.mjs";
|
|
10
7
|
import {
|
|
11
8
|
admin_app_exports
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TVQPMM6Y.mjs";
|
|
13
10
|
import {
|
|
14
11
|
blocks_exports
|
|
15
12
|
} from "./chunk-H7DSTEVT.mjs";
|
|
13
|
+
import {
|
|
14
|
+
studio_exports
|
|
15
|
+
} from "./chunk-N67KVM2S.mjs";
|
|
16
16
|
import {
|
|
17
17
|
studio_pages_exports
|
|
18
18
|
} from "./chunk-QW24Y4UH.mjs";
|