@riducms/admin 0.1.0
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/LICENSE +21 -0
- package/README.md +31 -0
- package/THIRD_PARTY_NOTICES.md +217 -0
- package/package.json +62 -0
- package/src/app/admin-core-view-route.svelte +89 -0
- package/src/app/admin-layout.svelte +457 -0
- package/src/app/admin-navigation-progress.svelte +204 -0
- package/src/app/admin-page-title.svelte +94 -0
- package/src/app/admin-provider-layer.svelte +26 -0
- package/src/app/admin-router-root.svelte +9 -0
- package/src/app/admin-routes.svelte +116 -0
- package/src/app/deferred-redirect.svelte +23 -0
- package/src/app/loading-boundary.svelte +70 -0
- package/src/app/not-found-route.svelte +29 -0
- package/src/app-meta.ts +2 -0
- package/src/app.css +467 -0
- package/src/app.svelte +88 -0
- package/src/assets/ridu-logo-arch.svg +3 -0
- package/src/assets/ridu-word-logo.svg +7 -0
- package/src/components/brand/ridu-logo.svelte +24 -0
- package/src/components/code-block/code-block.svelte +107 -0
- package/src/components/json-tree/json-tree-node.svelte +77 -0
- package/src/components/json-tree/json-viewer.svelte +113 -0
- package/src/components/ui/banner/banner.svelte +41 -0
- package/src/components/ui/banner/index.ts +5 -0
- package/src/components/ui/bulk-action-bar/bulk-action-bar.svelte +50 -0
- package/src/components/ui/bulk-action-bar/index.ts +1 -0
- package/src/components/ui/button/index.ts +8 -0
- package/src/components/ui/calendar/calendar-caption.svelte +72 -0
- package/src/components/ui/calendar/calendar-cell.svelte +20 -0
- package/src/components/ui/calendar/calendar-day.svelte +27 -0
- package/src/components/ui/calendar/calendar-grid-row.svelte +13 -0
- package/src/components/ui/calendar/calendar-grid.svelte +17 -0
- package/src/components/ui/calendar/calendar-head-cell.svelte +20 -0
- package/src/components/ui/calendar/calendar-header.svelte +20 -0
- package/src/components/ui/calendar/calendar-heading.svelte +17 -0
- package/src/components/ui/calendar/calendar-month-select.svelte +45 -0
- package/src/components/ui/calendar/calendar-month.svelte +16 -0
- package/src/components/ui/calendar/calendar-months.svelte +20 -0
- package/src/components/ui/calendar/calendar-nav.svelte +20 -0
- package/src/components/ui/calendar/calendar-next-button.svelte +30 -0
- package/src/components/ui/calendar/calendar-prev-button.svelte +30 -0
- package/src/components/ui/calendar/calendar-year-select.svelte +44 -0
- package/src/components/ui/calendar/calendar.svelte +118 -0
- package/src/components/ui/calendar/index.ts +1 -0
- package/src/components/ui/checkbox/checkbox.svelte +35 -0
- package/src/components/ui/checkbox/index.ts +1 -0
- package/src/components/ui/confirmation-dialog/confirmation-dialog.svelte +37 -0
- package/src/components/ui/confirmation-dialog/index.ts +1 -0
- package/src/components/ui/date-value-control/date-value-calendar.svelte +37 -0
- package/src/components/ui/date-value-control/date-value-control-loader.svelte +36 -0
- package/src/components/ui/date-value-control/date-value-control.svelte +177 -0
- package/src/components/ui/date-value-control/index.ts +3 -0
- package/src/components/ui/dialog/dialog-close.svelte +11 -0
- package/src/components/ui/dialog/dialog-content.svelte +52 -0
- package/src/components/ui/dialog/dialog-description.svelte +20 -0
- package/src/components/ui/dialog/dialog-footer.svelte +20 -0
- package/src/components/ui/dialog/dialog-header.svelte +20 -0
- package/src/components/ui/dialog/dialog-overlay.svelte +20 -0
- package/src/components/ui/dialog/dialog-title.svelte +17 -0
- package/src/components/ui/dialog/dialog-trigger.svelte +11 -0
- package/src/components/ui/dialog/dialog.svelte +7 -0
- package/src/components/ui/dialog/index.ts +8 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-content.svelte +27 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-item.svelte +20 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-separator.svelte +17 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +16 -0
- package/src/components/ui/dropdown-menu/dropdown-menu.svelte +7 -0
- package/src/components/ui/dropdown-menu/index.ts +5 -0
- package/src/components/ui/empty-state/empty-state.svelte +34 -0
- package/src/components/ui/empty-state/index.ts +1 -0
- package/src/components/ui/input/index.ts +1 -0
- package/src/components/ui/kbd/index.ts +1 -0
- package/src/components/ui/kbd/kbd.svelte +24 -0
- package/src/components/ui/pagination/index.ts +1 -0
- package/src/components/ui/pagination/pagination.svelte +88 -0
- package/src/components/ui/popover/index.ts +3 -0
- package/src/components/ui/popover/popover-content.svelte +29 -0
- package/src/components/ui/popover/popover-trigger.svelte +11 -0
- package/src/components/ui/popover/popover.svelte +7 -0
- package/src/components/ui/radio-group/index.ts +3 -0
- package/src/components/ui/radio-group/radio-card-item.svelte +38 -0
- package/src/components/ui/radio-group/radio-group-item.svelte +17 -0
- package/src/components/ui/radio-group/radio-group.svelte +19 -0
- package/src/components/ui/select/index.ts +4 -0
- package/src/components/ui/select/select-content.svelte +38 -0
- package/src/components/ui/select/select-item.svelte +40 -0
- package/src/components/ui/select/select-scroll-down-button.svelte +23 -0
- package/src/components/ui/select/select-scroll-up-button.svelte +23 -0
- package/src/components/ui/select/select-trigger.svelte +29 -0
- package/src/components/ui/select/select.svelte +11 -0
- package/src/components/ui/sheet/index.ts +6 -0
- package/src/components/ui/sheet/sheet-close.svelte +7 -0
- package/src/components/ui/sheet/sheet-content.svelte +77 -0
- package/src/components/ui/sheet/sheet-description.svelte +17 -0
- package/src/components/ui/sheet/sheet-overlay.svelte +36 -0
- package/src/components/ui/sheet/sheet-title.svelte +17 -0
- package/src/components/ui/sheet/sheet-trigger.svelte +7 -0
- package/src/components/ui/sheet/sheet.svelte +7 -0
- package/src/components/ui/skeleton/index.ts +1 -0
- package/src/components/ui/skeleton/skeleton.svelte +31 -0
- package/src/components/ui/slider/index.ts +3 -0
- package/src/components/ui/slider/slider-content.svelte +59 -0
- package/src/components/ui/slider/slider.svelte +35 -0
- package/src/components/ui/sonner/index.ts +1 -0
- package/src/components/ui/sonner/sonner.svelte +55 -0
- package/src/components/ui/status-indicator/index.ts +5 -0
- package/src/components/ui/status-indicator/status-indicator.svelte +54 -0
- package/src/components/ui/table/index.ts +6 -0
- package/src/components/ui/table/table-body.svelte +20 -0
- package/src/components/ui/table/table-cell.svelte +23 -0
- package/src/components/ui/table/table-head.svelte +23 -0
- package/src/components/ui/table/table-header.svelte +20 -0
- package/src/components/ui/table/table-row.svelte +23 -0
- package/src/components/ui/table/table.svelte +22 -0
- package/src/components/ui/tabs/index.ts +8 -0
- package/src/components/ui/tabs/tabs-content.svelte +17 -0
- package/src/components/ui/tabs/tabs-list.svelte +40 -0
- package/src/components/ui/tabs/tabs-trigger.svelte +23 -0
- package/src/components/ui/tabs/tabs.svelte +19 -0
- package/src/components/ui/textarea/index.ts +1 -0
- package/src/components/ui/tooltip/index.ts +4 -0
- package/src/components/ui/tooltip/tooltip-content.svelte +50 -0
- package/src/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/src/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/src/components/ui/tooltip/tooltip.svelte +7 -0
- package/src/core/api/admin-client.ts +45 -0
- package/src/core/forms/field-condition.ts +63 -0
- package/src/core/forms/form-controller.svelte.ts +369 -0
- package/src/core/forms/form-draft-recovery.ts +80 -0
- package/src/core/forms/form-schema.ts +609 -0
- package/src/core/forms/form-validation.ts +750 -0
- package/src/core/i18n/admin-i18n.svelte.ts +364 -0
- package/src/core/i18n/localized-schema.ts +111 -0
- package/src/core/notifications/notification-center.svelte.ts +69 -0
- package/src/core/notifications/validation-toast.svelte +18 -0
- package/src/core/plugins/field-registry.ts +60 -0
- package/src/core/plugins/row-label-registry.ts +62 -0
- package/src/core/preferences/preference-write-queue.ts +107 -0
- package/src/core/routing/admin-paths.ts +137 -0
- package/src/core/runtime/admin-runtime.svelte.ts +625 -0
- package/src/features/auth/account-menu.svelte +159 -0
- package/src/features/auth/account-navigation.svelte +44 -0
- package/src/features/auth/account-route.svelte +395 -0
- package/src/features/auth/account-security-controller.svelte.ts +119 -0
- package/src/features/auth/account-security-route.svelte +460 -0
- package/src/features/auth/auth-brand.svelte +17 -0
- package/src/features/auth/auth-frame.svelte +18 -0
- package/src/features/auth/create-first-user-controller.svelte.ts +220 -0
- package/src/features/auth/create-first-user-route.svelte +174 -0
- package/src/features/auth/forgot-password-route.svelte +78 -0
- package/src/features/auth/login-route.svelte +221 -0
- package/src/features/auth/request-verification-route.svelte +73 -0
- package/src/features/auth/reset-password-route.svelte +107 -0
- package/src/features/auth/verify-email-route.svelte +60 -0
- package/src/features/collections/collection-list-bulk-actions.svelte +143 -0
- package/src/features/collections/collection-list-bulk-editor.svelte +157 -0
- package/src/features/collections/collection-list-controller.svelte.ts +717 -0
- package/src/features/collections/collection-list-filter-popover.svelte +238 -0
- package/src/features/collections/collection-list-preferences-controller.svelte.ts +393 -0
- package/src/features/collections/collection-list-results.svelte +410 -0
- package/src/features/collections/collection-list-route.svelte +951 -0
- package/src/features/collections/collection-list-workspace-toolbar.svelte +409 -0
- package/src/features/collections/collection-table-skeleton.svelte +44 -0
- package/src/features/collections/list-workspace.ts +265 -0
- package/src/features/dashboard/dashboard-route.svelte +141 -0
- package/src/features/development/development-tools.svelte +217 -0
- package/src/features/documents/document-api-view-loader.svelte +31 -0
- package/src/features/documents/document-api-view.svelte +547 -0
- package/src/features/documents/document-controller.svelte.ts +1252 -0
- package/src/features/documents/document-field-partition.ts +18 -0
- package/src/features/documents/document-field-sections.svelte +46 -0
- package/src/features/documents/document-heading.ts +20 -0
- package/src/features/documents/document-route-dirty.ts +43 -0
- package/src/features/documents/document-route-loader.svelte +22 -0
- package/src/features/documents/document-route.svelte +1124 -0
- package/src/features/documents/live-preview-panel.svelte +390 -0
- package/src/features/documents/live-preview.ts +61 -0
- package/src/features/documents/upload-document-preview-loader.svelte +40 -0
- package/src/features/documents/upload-document-preview.svelte +525 -0
- package/src/features/localization/content-locale-switcher.svelte +93 -0
- package/src/features/navigation/admin-breadcrumbs.svelte +124 -0
- package/src/features/navigation/admin-command-menu.svelte +245 -0
- package/src/features/navigation/admin-resource-groups.ts +72 -0
- package/src/features/reference-browser/reference-browser-loader.svelte +15 -0
- package/src/features/reference-browser/reference-browser-workflow.svelte.ts +691 -0
- package/src/features/reference-browser/reference-browser.svelte +844 -0
- package/src/features/uploads/bulk-upload-route.svelte +624 -0
- package/src/features/uploads/bulk-upload.ts +39 -0
- package/src/features/uploads/upload-metadata-fields.svelte +112 -0
- package/src/features/versions/version-diff.ts +72 -0
- package/src/features/versions/version-history-route.svelte +581 -0
- package/src/fields/field-clipboard.ts +132 -0
- package/src/fields/field-layout.svelte +60 -0
- package/src/fields/field-layout.ts +57 -0
- package/src/fields/field-messages.svelte +29 -0
- package/src/fields/field-renderer.svelte +152 -0
- package/src/fields/field-shell.svelte +30 -0
- package/src/fields/field-tab-layout.svelte +99 -0
- package/src/fields/join/join-field.svelte +358 -0
- package/src/fields/localized-field-presentation.ts +17 -0
- package/src/fields/nested/nested-field.svelte +602 -0
- package/src/fields/nested/scoped-field.ts +78 -0
- package/src/fields/nested/sortable-row.svelte +32 -0
- package/src/fields/point/point-field.svelte +52 -0
- package/src/fields/radio/radio-field.svelte +34 -0
- package/src/fields/relationship/relationship-field-controller.svelte.ts +245 -0
- package/src/fields/relationship/relationship-field.svelte +258 -0
- package/src/fields/relationship/relationship-lookup-controller.svelte.ts +129 -0
- package/src/fields/relationship/relationship-query.ts +88 -0
- package/src/fields/relationship/relationship-quick-picker-controller.svelte.ts +198 -0
- package/src/fields/relationship/relationship-quick-picker.svelte +327 -0
- package/src/fields/relationship/relationship-value.ts +47 -0
- package/src/fields/scalar/date-control-value.ts +60 -0
- package/src/fields/scalar/date-value.ts +26 -0
- package/src/fields/scalar/scalar-field.svelte +137 -0
- package/src/fields/select/select-field.svelte +132 -0
- package/src/fields/select/select-value.ts +14 -0
- package/src/fields/text/slug-field.svelte +87 -0
- package/src/fields/text/slug.ts +38 -0
- package/src/fields/text/text-field.svelte +41 -0
- package/src/fields/ui/ui-field.svelte +12 -0
- package/src/fields/virtual/virtual-field.svelte +28 -0
- package/src/index.ts +49 -0
- package/src/main.ts +12 -0
- package/src/vite-env.d.ts +9 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Link, useLocation } from "@hvniel/svelte-router";
|
|
3
|
+
|
|
4
|
+
import RiduLogo from "@admin/components/brand/ridu-logo.svelte";
|
|
5
|
+
import { collectionPath, globalPath } from "@admin/core/routing/admin-paths";
|
|
6
|
+
import { getAdminRuntime } from "@admin/core/runtime/admin-runtime.svelte";
|
|
7
|
+
|
|
8
|
+
interface Breadcrumb {
|
|
9
|
+
label: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const runtime = getAdminRuntime();
|
|
14
|
+
const location = $derived(useLocation());
|
|
15
|
+
const segments = $derived(
|
|
16
|
+
location.pathname
|
|
17
|
+
.split("/")
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.map((segment) => decodeURIComponent(segment))
|
|
20
|
+
);
|
|
21
|
+
const breadcrumbs = $derived.by<Breadcrumb[]>(() => {
|
|
22
|
+
if (segments.length === 0) return [{ label: runtime.i18n.t("dashboard:heading") }];
|
|
23
|
+
|
|
24
|
+
if (segments[0] === "account") {
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
label: runtime.i18n.t("account:account"),
|
|
28
|
+
to: segments.length > 1 ? "/account" : undefined,
|
|
29
|
+
},
|
|
30
|
+
...(segments[1] === "security" ? [{ label: runtime.i18n.t("account:security") }] : []),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (segments[0] === "collections" && segments[1] !== undefined) {
|
|
35
|
+
const collection = runtime.visibleCollections.find(
|
|
36
|
+
(candidate) => candidate.slug === segments[1]
|
|
37
|
+
);
|
|
38
|
+
const label =
|
|
39
|
+
collection === undefined
|
|
40
|
+
? humanize(segments[1])
|
|
41
|
+
: runtime.i18n.text(collection.labels.plural, collection.labels.pluralTranslations);
|
|
42
|
+
if (segments.length > 2 && segments[2] !== "trash" && segments[2] !== "upload") {
|
|
43
|
+
const creating = segments[2] === "create";
|
|
44
|
+
const versions = segments[3] === "versions";
|
|
45
|
+
return [
|
|
46
|
+
{ label, to: collectionPath(segments[1]) },
|
|
47
|
+
{
|
|
48
|
+
label: creating
|
|
49
|
+
? runtime.i18n.t("general:create")
|
|
50
|
+
: versions
|
|
51
|
+
? runtime.i18n.t("documents:versions")
|
|
52
|
+
: runtime.i18n.t("general:edit"),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
label,
|
|
59
|
+
to: segments.length > 2 ? collectionPath(segments[1]) : undefined,
|
|
60
|
+
},
|
|
61
|
+
...(segments[2] === "trash"
|
|
62
|
+
? [{ label: runtime.i18n.t("collections:trash") }]
|
|
63
|
+
: segments[2] === "upload"
|
|
64
|
+
? [{ label: runtime.i18n.t("collections:bulkUpload") }]
|
|
65
|
+
: []),
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (segments[0] === "globals" && segments[1] !== undefined) {
|
|
70
|
+
const global = runtime.visibleGlobals.find((candidate) => candidate.slug === segments[1]);
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
label:
|
|
74
|
+
global === undefined
|
|
75
|
+
? humanize(segments[1])
|
|
76
|
+
: runtime.i18n.text(global.labels.singular, global.labels.singularTranslations),
|
|
77
|
+
to: segments.length > 2 ? globalPath(segments[1]) : undefined,
|
|
78
|
+
},
|
|
79
|
+
...(segments[2] === "versions" ? [{ label: runtime.i18n.t("documents:versions") }] : []),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const pluginRoute = runtime.pluginRoutes.find((route) => route.path === segments.join("/"));
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
label:
|
|
87
|
+
pluginRoute?.navigation?.labelKey !== undefined
|
|
88
|
+
? runtime.i18n.t(pluginRoute.navigation.labelKey)
|
|
89
|
+
: (pluginRoute?.navigation?.label ??
|
|
90
|
+
humanize(segments.at(-1) ?? runtime.i18n.t("navigation:page"))),
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
function humanize(value: string): string {
|
|
96
|
+
const words = value.replaceAll(/[-_]+/g, " ");
|
|
97
|
+
return words.charAt(0).toLocaleUpperCase(runtime.i18n.language) + words.slice(1);
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<nav
|
|
102
|
+
class="flex min-w-0 items-center gap-3 text-[13px]"
|
|
103
|
+
aria-label={runtime.i18n.t("navigation:breadcrumb")}
|
|
104
|
+
>
|
|
105
|
+
<Link
|
|
106
|
+
class="grid size-7 shrink-0 place-items-center"
|
|
107
|
+
to="/"
|
|
108
|
+
aria-label={runtime.i18n.t("dashboard:heading")}
|
|
109
|
+
>
|
|
110
|
+
<RiduLogo variant="arch" class="h-4" />
|
|
111
|
+
</Link>
|
|
112
|
+
{#each breadcrumbs as breadcrumb, index (`${breadcrumb.label}-${index}`)}
|
|
113
|
+
<span class="shrink-0" aria-hidden="true">/</span>
|
|
114
|
+
{#if breadcrumb.to !== undefined}
|
|
115
|
+
<Link class="min-w-0 truncate" to={breadcrumb.to}>
|
|
116
|
+
{breadcrumb.label}
|
|
117
|
+
</Link>
|
|
118
|
+
{:else}
|
|
119
|
+
<span class="min-w-0 truncate font-medium text-foreground-strong" aria-current="page">
|
|
120
|
+
{breadcrumb.label}
|
|
121
|
+
</span>
|
|
122
|
+
{/if}
|
|
123
|
+
{/each}
|
|
124
|
+
</nav>
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useNavigate } from "@hvniel/svelte-router";
|
|
3
|
+
import type { SchemaCollection } from "@riducms/protocol";
|
|
4
|
+
import SearchIcon from "~icons/lucide/search";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
CommandEmpty,
|
|
8
|
+
CommandGroup,
|
|
9
|
+
CommandGroupHeading,
|
|
10
|
+
CommandGroupItems,
|
|
11
|
+
CommandInput,
|
|
12
|
+
CommandItem,
|
|
13
|
+
CommandList,
|
|
14
|
+
CommandRoot,
|
|
15
|
+
CommandSeparator,
|
|
16
|
+
CommandViewport,
|
|
17
|
+
} from "@riducms/ui";
|
|
18
|
+
import {
|
|
19
|
+
Dialog,
|
|
20
|
+
DialogContent,
|
|
21
|
+
DialogDescription,
|
|
22
|
+
DialogTitle,
|
|
23
|
+
} from "@admin/components/ui/dialog";
|
|
24
|
+
import { Kbd } from "@admin/components/ui/kbd";
|
|
25
|
+
import type { AdminDocument } from "@admin/core/api/admin-client";
|
|
26
|
+
import {
|
|
27
|
+
collectionPath,
|
|
28
|
+
createDocumentPath,
|
|
29
|
+
documentPath,
|
|
30
|
+
} from "@admin/core/routing/admin-paths";
|
|
31
|
+
import { getAdminRuntime } from "@admin/core/runtime/admin-runtime.svelte";
|
|
32
|
+
|
|
33
|
+
interface CommandDocument {
|
|
34
|
+
collection: SchemaCollection;
|
|
35
|
+
document: AdminDocument;
|
|
36
|
+
title: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Props {
|
|
40
|
+
open?: boolean;
|
|
41
|
+
collections: readonly SchemaCollection[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let { open = $bindable(false), collections }: Props = $props();
|
|
45
|
+
const runtime = getAdminRuntime();
|
|
46
|
+
const navigate = useNavigate();
|
|
47
|
+
let query = $state("");
|
|
48
|
+
let documents = $state.raw<CommandDocument[]>([]);
|
|
49
|
+
let documentsLoading = $state(false);
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
if (!open || collections.length === 0) return;
|
|
53
|
+
const request = new AbortController();
|
|
54
|
+
loadDocuments(collections, request.signal);
|
|
55
|
+
return () => request.abort();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
59
|
+
if (event.key.toLocaleLowerCase() !== "k" || (!event.metaKey && !event.ctrlKey)) return;
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
open = !open;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function go(path: string) {
|
|
65
|
+
open = false;
|
|
66
|
+
query = "";
|
|
67
|
+
navigate(path);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function singularLabel(collection: SchemaCollection) {
|
|
71
|
+
return runtime.i18n.text(collection.labels.singular, collection.labels.singularTranslations);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function pluralLabel(collection: SchemaCollection) {
|
|
75
|
+
return runtime.i18n.text(collection.labels.plural, collection.labels.pluralTranslations);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function loadDocuments(
|
|
79
|
+
availableCollections: readonly SchemaCollection[],
|
|
80
|
+
signal: AbortSignal
|
|
81
|
+
) {
|
|
82
|
+
documentsLoading = true;
|
|
83
|
+
try {
|
|
84
|
+
const pages = await Promise.all(
|
|
85
|
+
availableCollections.map(async (collection) => {
|
|
86
|
+
const titleField =
|
|
87
|
+
collection.fields.find((field) => field.type === "text") ??
|
|
88
|
+
collection.fields.find((field) => field.type === "select");
|
|
89
|
+
const page = await runtime.client.list(collection.slug, { limit: 6, signal });
|
|
90
|
+
return page.docs.map((document) => ({
|
|
91
|
+
collection,
|
|
92
|
+
document,
|
|
93
|
+
title: String(
|
|
94
|
+
(titleField === undefined ? undefined : document[titleField.name]) ?? document.id
|
|
95
|
+
),
|
|
96
|
+
}));
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
if (!signal.aborted) documents = pages.flat().slice(0, 8);
|
|
100
|
+
} catch {
|
|
101
|
+
if (!signal.aborted) documents = [];
|
|
102
|
+
} finally {
|
|
103
|
+
if (!signal.aborted) documentsLoading = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<svelte:document onkeydown={handleKeydown} />
|
|
109
|
+
|
|
110
|
+
<Dialog bind:open>
|
|
111
|
+
<DialogContent
|
|
112
|
+
class="ridu-command-dialog top-[16vh] w-[min(calc(100vw-32px),560px)] max-w-none -translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-none"
|
|
113
|
+
showCloseButton={false}
|
|
114
|
+
>
|
|
115
|
+
<DialogTitle class="sr-only">{runtime.i18n.t("navigation:navigateRidu")}</DialogTitle>
|
|
116
|
+
<DialogDescription class="sr-only">
|
|
117
|
+
{runtime.i18n.t("navigation:commandDescription")}
|
|
118
|
+
</DialogDescription>
|
|
119
|
+
|
|
120
|
+
<CommandRoot>
|
|
121
|
+
<div class="flex items-center gap-2.5 border-b border-control-border px-4">
|
|
122
|
+
<SearchIcon
|
|
123
|
+
class="pointer-events-none size-3.75 shrink-0 text-foreground-tag"
|
|
124
|
+
aria-hidden="true"
|
|
125
|
+
/>
|
|
126
|
+
<CommandInput
|
|
127
|
+
bind:value={query}
|
|
128
|
+
class="h-12 text-[13px]"
|
|
129
|
+
placeholder={runtime.i18n.t("navigation:commandSearchPlaceholder")}
|
|
130
|
+
aria-label={runtime.i18n.t("navigation:commandSearch")}
|
|
131
|
+
/>
|
|
132
|
+
<Kbd class="shrink-0">{runtime.i18n.t("general:escape")}</Kbd>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<CommandList class="max-h-[350px] p-2">
|
|
136
|
+
<CommandViewport>
|
|
137
|
+
{const emptyMessage = $derived(
|
|
138
|
+
query === ""
|
|
139
|
+
? runtime.i18n.t("navigation:nothingMatches")
|
|
140
|
+
: runtime.i18n.t("navigation:nothingMatchesQuery", { query })
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
<CommandEmpty>{emptyMessage}</CommandEmpty>
|
|
144
|
+
|
|
145
|
+
{#if documents.length > 0}
|
|
146
|
+
<CommandGroup>
|
|
147
|
+
<CommandGroupItems class="grid gap-0.5">
|
|
148
|
+
{#each documents as result (result.collection.id + ":" + result.document.id)}
|
|
149
|
+
<CommandItem
|
|
150
|
+
class="min-h-9 px-2.5 py-1.5 text-[13px]"
|
|
151
|
+
value="{result.title} {pluralLabel(result.collection)} {runtime.i18n.t(
|
|
152
|
+
'navigation:document'
|
|
153
|
+
)}"
|
|
154
|
+
onSelect={() => go(documentPath(result.collection.slug, result.document.id))}
|
|
155
|
+
>
|
|
156
|
+
<span
|
|
157
|
+
class="font-mono w-9 shrink-0 rounded-[4px] border border-control-border py-0.5 text-center text-[8.5px] tracking-[0.08em] text-foreground-tag"
|
|
158
|
+
>
|
|
159
|
+
{runtime.i18n.t("navigation:documentBadge")}
|
|
160
|
+
</span>
|
|
161
|
+
<span class="min-w-0 flex-1 truncate">{result.title}</span>
|
|
162
|
+
<span class="text-[11px] text-foreground-faint">
|
|
163
|
+
{pluralLabel(result.collection)}
|
|
164
|
+
</span>
|
|
165
|
+
</CommandItem>
|
|
166
|
+
{/each}
|
|
167
|
+
</CommandGroupItems>
|
|
168
|
+
</CommandGroup>
|
|
169
|
+
<CommandSeparator class="my-2 h-px bg-control-border" />
|
|
170
|
+
{:else if documentsLoading}
|
|
171
|
+
<p
|
|
172
|
+
class="font-mono px-2.5 py-3 text-[9px] tracking-[0.12em] text-foreground-faint uppercase"
|
|
173
|
+
>
|
|
174
|
+
{runtime.i18n.t("navigation:loadingDocuments")}
|
|
175
|
+
</p>
|
|
176
|
+
{/if}
|
|
177
|
+
|
|
178
|
+
<CommandGroup>
|
|
179
|
+
<CommandGroupHeading
|
|
180
|
+
class="font-mono px-2.5 pt-2 pb-1.5 text-[9.5px] tracking-[0.14em] text-foreground-faint uppercase"
|
|
181
|
+
>
|
|
182
|
+
{runtime.i18n.t("navigation:navigate")}
|
|
183
|
+
</CommandGroupHeading>
|
|
184
|
+
<CommandGroupItems class="grid gap-0.5">
|
|
185
|
+
{#each collections as collection (collection.id)}
|
|
186
|
+
<CommandItem
|
|
187
|
+
class="min-h-9 px-2.5 py-1.5 text-[13px]"
|
|
188
|
+
value="{pluralLabel(collection)} {collection.slug} {runtime.i18n.t(
|
|
189
|
+
'navigation:collection'
|
|
190
|
+
)}"
|
|
191
|
+
onSelect={() => go(collectionPath(collection.slug))}
|
|
192
|
+
>
|
|
193
|
+
<span
|
|
194
|
+
class="font-mono w-10 shrink-0 rounded-[4px] border border-control-border py-0.5 text-center text-[9.5px] tracking-[0.08em] text-foreground-tag"
|
|
195
|
+
>
|
|
196
|
+
{runtime.i18n.t("navigation:collectionBadge")}
|
|
197
|
+
</span>
|
|
198
|
+
<span class="min-w-0 flex-1 truncate">{pluralLabel(collection)}</span>
|
|
199
|
+
<span class="text-[12px] text-foreground-faint">
|
|
200
|
+
{runtime.i18n.t("navigation:collection")}
|
|
201
|
+
</span>
|
|
202
|
+
</CommandItem>
|
|
203
|
+
{/each}
|
|
204
|
+
</CommandGroupItems>
|
|
205
|
+
</CommandGroup>
|
|
206
|
+
|
|
207
|
+
<CommandSeparator class="my-2 h-px bg-control-border" />
|
|
208
|
+
|
|
209
|
+
<CommandGroup>
|
|
210
|
+
<CommandGroupHeading
|
|
211
|
+
class="font-mono px-2.5 pt-1 pb-1.5 text-[9.5px] tracking-[0.14em] text-foreground-faint uppercase"
|
|
212
|
+
>
|
|
213
|
+
{runtime.i18n.t("general:create")}
|
|
214
|
+
</CommandGroupHeading>
|
|
215
|
+
<CommandGroupItems class="grid gap-0.5">
|
|
216
|
+
{#each collections as collection (collection.id)}
|
|
217
|
+
<CommandItem
|
|
218
|
+
class="min-h-9 px-2.5 py-1.5 text-[13px]"
|
|
219
|
+
value="{runtime.i18n.t('navigation:newBadge')} {runtime.i18n.t(
|
|
220
|
+
'general:create'
|
|
221
|
+
)} {singularLabel(collection)} {collection.slug}"
|
|
222
|
+
onSelect={() => go(createDocumentPath(collection.slug))}
|
|
223
|
+
>
|
|
224
|
+
<span
|
|
225
|
+
class="font-mono w-10 shrink-0 rounded-[4px] border border-primary/25 py-0.5 text-center text-[9.5px] tracking-[0.08em] text-primary"
|
|
226
|
+
>
|
|
227
|
+
{runtime.i18n.t("navigation:newBadge")}
|
|
228
|
+
</span>
|
|
229
|
+
<span class="min-w-0 flex-1 truncate">
|
|
230
|
+
{runtime.i18n.t("collections:createNew", {
|
|
231
|
+
label: singularLabel(collection).toLocaleLowerCase(runtime.i18n.language),
|
|
232
|
+
})}
|
|
233
|
+
</span>
|
|
234
|
+
<span class="text-[12px] text-foreground-faint">
|
|
235
|
+
{runtime.i18n.t("general:create")}
|
|
236
|
+
</span>
|
|
237
|
+
</CommandItem>
|
|
238
|
+
{/each}
|
|
239
|
+
</CommandGroupItems>
|
|
240
|
+
</CommandGroup>
|
|
241
|
+
</CommandViewport>
|
|
242
|
+
</CommandList>
|
|
243
|
+
</CommandRoot>
|
|
244
|
+
</DialogContent>
|
|
245
|
+
</Dialog>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { SchemaCollection } from "@riducms/protocol";
|
|
2
|
+
|
|
3
|
+
export interface AdminResourceGroup {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
translations?: Readonly<Record<string, string>>;
|
|
7
|
+
collections: readonly SchemaCollection[];
|
|
8
|
+
globals: readonly SchemaCollection[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface MutableAdminResourceGroup {
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
translations?: Readonly<Record<string, string>>;
|
|
15
|
+
collections: SchemaCollection[];
|
|
16
|
+
globals: SchemaCollection[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function groupAdminResources(
|
|
20
|
+
collections: readonly SchemaCollection[],
|
|
21
|
+
globals: readonly SchemaCollection[],
|
|
22
|
+
fallbackLabels = { collections: "Collections", globals: "Globals" }
|
|
23
|
+
): readonly AdminResourceGroup[] {
|
|
24
|
+
const groups = new Map<string, MutableAdminResourceGroup>();
|
|
25
|
+
|
|
26
|
+
for (const collection of collections) {
|
|
27
|
+
addResource(
|
|
28
|
+
groups,
|
|
29
|
+
collection.admin.group,
|
|
30
|
+
collection.admin.groupTranslations,
|
|
31
|
+
fallbackLabels.collections,
|
|
32
|
+
"collections",
|
|
33
|
+
collection
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
for (const global of globals) {
|
|
37
|
+
addResource(
|
|
38
|
+
groups,
|
|
39
|
+
global.admin.group,
|
|
40
|
+
global.admin.groupTranslations,
|
|
41
|
+
fallbackLabels.globals,
|
|
42
|
+
"globals",
|
|
43
|
+
global
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return [...groups.values()];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function addResource(
|
|
51
|
+
groups: Map<string, MutableAdminResourceGroup>,
|
|
52
|
+
configuredGroup: string | undefined,
|
|
53
|
+
translations: Readonly<Record<string, string>> | undefined,
|
|
54
|
+
fallbackGroup: string,
|
|
55
|
+
kind: "collections" | "globals",
|
|
56
|
+
resource: SchemaCollection
|
|
57
|
+
) {
|
|
58
|
+
const label = configuredGroup?.trim() || fallbackGroup;
|
|
59
|
+
const key = (configuredGroup?.trim() || kind).toLowerCase();
|
|
60
|
+
let group = groups.get(key);
|
|
61
|
+
if (group === undefined) {
|
|
62
|
+
group = {
|
|
63
|
+
key,
|
|
64
|
+
label,
|
|
65
|
+
...(translations === undefined ? {} : { translations }),
|
|
66
|
+
collections: [],
|
|
67
|
+
globals: [],
|
|
68
|
+
};
|
|
69
|
+
groups.set(key, group);
|
|
70
|
+
}
|
|
71
|
+
group[kind].push(resource);
|
|
72
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FieldReferenceBrowserProps } from "@riducms/plugin";
|
|
3
|
+
import type { Component } from "svelte";
|
|
4
|
+
|
|
5
|
+
let { open = $bindable(false), ...props }: FieldReferenceBrowserProps = $props();
|
|
6
|
+
let Browser = $state<Component<FieldReferenceBrowserProps> | undefined>(undefined);
|
|
7
|
+
|
|
8
|
+
void import("@admin/features/reference-browser/reference-browser.svelte").then(
|
|
9
|
+
({ default: component }) => (Browser = component)
|
|
10
|
+
);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
{#if Browser !== undefined}
|
|
14
|
+
<Browser bind:open {...props} />
|
|
15
|
+
{/if}
|