@voyant-travel/admin 0.111.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 +201 -0
- package/README.md +285 -0
- package/dist/app/extension-routes.d.ts +99 -0
- package/dist/app/extension-routes.d.ts.map +1 -0
- package/dist/app/extension-routes.js +134 -0
- package/dist/app/index.d.ts +9 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +4 -0
- package/dist/app/root.d.ts +47 -0
- package/dist/app/root.d.ts.map +1 -0
- package/dist/app/root.js +55 -0
- package/dist/app/router.d.ts +30 -0
- package/dist/app/router.d.ts.map +1 -0
- package/dist/app/router.js +51 -0
- package/dist/app/workspace.d.ts +84 -0
- package/dist/app/workspace.d.ts.map +1 -0
- package/dist/app/workspace.js +87 -0
- package/dist/components/admin-breadcrumbs.d.ts +18 -0
- package/dist/components/admin-breadcrumbs.d.ts.map +1 -0
- package/dist/components/admin-breadcrumbs.js +84 -0
- package/dist/components/admin-nav-group.d.ts +11 -0
- package/dist/components/admin-nav-group.d.ts.map +1 -0
- package/dist/components/admin-nav-group.js +49 -0
- package/dist/components/admin-nav-link.d.ts +10 -0
- package/dist/components/admin-nav-link.d.ts.map +1 -0
- package/dist/components/admin-nav-link.js +5 -0
- package/dist/components/admin-page-head.d.ts +17 -0
- package/dist/components/admin-page-head.d.ts.map +1 -0
- package/dist/components/admin-page-head.js +107 -0
- package/dist/components/admin-widget-slot.d.ts +8 -0
- package/dist/components/admin-widget-slot.d.ts.map +1 -0
- package/dist/components/admin-widget-slot.js +19 -0
- package/dist/components/brand/voyant-mark.d.ts +3 -0
- package/dist/components/brand/voyant-mark.d.ts.map +1 -0
- package/dist/components/brand/voyant-mark.js +4 -0
- package/dist/components/brand/voyant-wordmark.d.ts +3 -0
- package/dist/components/brand/voyant-wordmark.d.ts.map +1 -0
- package/dist/components/brand/voyant-wordmark.js +4 -0
- package/dist/components/operator-admin-bootstrap-gate.d.ts +26 -0
- package/dist/components/operator-admin-bootstrap-gate.d.ts.map +1 -0
- package/dist/components/operator-admin-bootstrap-gate.js +22 -0
- package/dist/components/operator-admin-page-shell.d.ts +13 -0
- package/dist/components/operator-admin-page-shell.d.ts.map +1 -0
- package/dist/components/operator-admin-page-shell.js +6 -0
- package/dist/components/operator-admin-sidebar.d.ts +57 -0
- package/dist/components/operator-admin-sidebar.d.ts.map +1 -0
- package/dist/components/operator-admin-sidebar.js +104 -0
- package/dist/components/operator-admin-user-menu.d.ts +10 -0
- package/dist/components/operator-admin-user-menu.d.ts.map +1 -0
- package/dist/components/operator-admin-user-menu.js +19 -0
- package/dist/components/team-settings-page.d.ts +10 -0
- package/dist/components/team-settings-page.d.ts.map +1 -0
- package/dist/components/team-settings-page.js +149 -0
- package/dist/dashboard/dashboard-empty-states.d.ts +67 -0
- package/dist/dashboard/dashboard-empty-states.d.ts.map +1 -0
- package/dist/dashboard/dashboard-empty-states.js +65 -0
- package/dist/dashboard/dashboard-kpi-card.d.ts +13 -0
- package/dist/dashboard/dashboard-kpi-card.d.ts.map +1 -0
- package/dist/dashboard/dashboard-kpi-card.js +12 -0
- package/dist/dashboard/dashboard-page.d.ts +7 -0
- package/dist/dashboard/dashboard-page.d.ts.map +1 -0
- package/dist/dashboard/dashboard-page.js +150 -0
- package/dist/dashboard/dashboard-query-options.d.ts +224 -0
- package/dist/dashboard/dashboard-query-options.d.ts.map +1 -0
- package/dist/dashboard/dashboard-query-options.js +153 -0
- package/dist/dashboard/dashboard-skeleton.d.ts +13 -0
- package/dist/dashboard/dashboard-skeleton.d.ts.map +1 -0
- package/dist/dashboard/dashboard-skeleton.js +28 -0
- package/dist/extensions.d.ts +254 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +139 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/lib/i18n.d.ts +2 -0
- package/dist/lib/i18n.d.ts.map +1 -0
- package/dist/lib/i18n.js +1 -0
- package/dist/lib/initials.d.ts +24 -0
- package/dist/lib/initials.d.ts.map +1 -0
- package/dist/lib/initials.js +45 -0
- package/dist/navigation/destinations.d.ts +83 -0
- package/dist/navigation/destinations.d.ts.map +1 -0
- package/dist/navigation/destinations.js +65 -0
- package/dist/navigation/operator-navigation.d.ts +10 -0
- package/dist/navigation/operator-navigation.d.ts.map +1 -0
- package/dist/navigation/operator-navigation.js +191 -0
- package/dist/providers/admin-extensions.d.ts +9 -0
- package/dist/providers/admin-extensions.d.ts.map +1 -0
- package/dist/providers/admin-extensions.js +10 -0
- package/dist/providers/admin-provider.d.ts +53 -0
- package/dist/providers/admin-provider.d.ts.map +1 -0
- package/dist/providers/admin-provider.js +26 -0
- package/dist/providers/locale-preferences.d.ts +12 -0
- package/dist/providers/locale-preferences.d.ts.map +1 -0
- package/dist/providers/locale-preferences.js +32 -0
- package/dist/providers/locale.d.ts +23 -0
- package/dist/providers/locale.d.ts.map +1 -0
- package/dist/providers/locale.js +98 -0
- package/dist/providers/operator-admin-messages.d.ts +14 -0
- package/dist/providers/operator-admin-messages.d.ts.map +1 -0
- package/dist/providers/operator-admin-messages.js +16 -0
- package/dist/providers/operator-admin-shell.d.ts +35 -0
- package/dist/providers/operator-admin-shell.d.ts.map +1 -0
- package/dist/providers/operator-admin-shell.js +20 -0
- package/dist/providers/query-client.d.ts +19 -0
- package/dist/providers/query-client.d.ts.map +1 -0
- package/dist/providers/query-client.js +34 -0
- package/dist/providers/theme.d.ts +29 -0
- package/dist/providers/theme.d.ts.map +1 -0
- package/dist/providers/theme.js +63 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/package.json +222 -0
- package/src/styles.css +11 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
import type { AdminDestinationKey } from "./navigation/destinations.js";
|
|
4
|
+
import type { NavItem } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* App-supplied runtime handed to route loaders: where the API lives and how
|
|
7
|
+
* to reach it (the host's cookie-forwarding fetcher in SSR setups).
|
|
8
|
+
*
|
|
9
|
+
* The fetcher takes a string URL — the `VoyantFetcher` convention every
|
|
10
|
+
* `*-react` data client uses — so host fetchers typed against that contract
|
|
11
|
+
* (and the global `fetch`, which accepts a superset of inputs) bind directly.
|
|
12
|
+
*/
|
|
13
|
+
export interface AdminRouteRuntime {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
fetcher?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
16
|
+
}
|
|
17
|
+
export interface AdminRouteLoaderContext {
|
|
18
|
+
queryClient: QueryClient;
|
|
19
|
+
runtime: AdminRouteRuntime;
|
|
20
|
+
/**
|
|
21
|
+
* Path params of the matched route (e.g. `{ id: "book_..." }`). Empty for
|
|
22
|
+
* param-less routes. Hosts that bind contributions into a router supply
|
|
23
|
+
* the matched params so package loaders can prefetch detail data.
|
|
24
|
+
*/
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props a packaged route page receives from the host's route binder
|
|
29
|
+
* (packaged-admin RFC §4.2 endgame). The binder reads route state off the
|
|
30
|
+
* matched route — `useParams`/`useSearch` — and hands it to the page, which
|
|
31
|
+
* is what dissolves the old "zero-prop components only" restriction: a
|
|
32
|
+
* param-taking page is just a page that reads `params`/`search` from props.
|
|
33
|
+
*/
|
|
34
|
+
export interface AdminRoutePageProps {
|
|
35
|
+
/** Path params of the matched route (e.g. `{ id: "book_..." }`). */
|
|
36
|
+
params: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Search params of the matched route, already validated by the
|
|
39
|
+
* contribution's `validateSearch`. Pages narrow this to their own search
|
|
40
|
+
* contract (the same schema the contribution carries).
|
|
41
|
+
*/
|
|
42
|
+
search: Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Patch the route's URL search state in place (same-route navigation).
|
|
45
|
+
* Defaults to `replace: true` — filter/tab state shouldn't grow history.
|
|
46
|
+
*/
|
|
47
|
+
updateSearch: (updater: (prev: Record<string, unknown>) => Record<string, unknown>, options?: {
|
|
48
|
+
replace?: boolean;
|
|
49
|
+
}) => void;
|
|
50
|
+
/** Localized route title from the contribution (factory `labels`). */
|
|
51
|
+
title?: string;
|
|
52
|
+
}
|
|
53
|
+
export type AdminRoutePageComponent = React.ComponentType<AdminRoutePageProps>;
|
|
54
|
+
/** Module shape `AdminUiRouteContribution.page` loaders resolve to. */
|
|
55
|
+
export interface AdminRoutePageModule {
|
|
56
|
+
default: AdminRoutePageComponent;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Adapt a component into an {@link AdminRoutePageModule}. Use inside `page`
|
|
60
|
+
* loaders for components that ignore route props entirely (zero-prop hosts)
|
|
61
|
+
* or take an all-optional props bag — both of which TypeScript's weak-type
|
|
62
|
+
* rule rejects as `AdminRoutePageComponent` despite being safe to mount.
|
|
63
|
+
*/
|
|
64
|
+
export declare function adminRoutePageModule<P>(component: React.ComponentType<P>): AdminRoutePageModule;
|
|
65
|
+
/**
|
|
66
|
+
* A named route contribution for the admin shell.
|
|
67
|
+
*
|
|
68
|
+
* Originally metadata only; as of the packaged-admin RFC Phase 2
|
|
69
|
+
* (docs/architecture/packaged-admin-rfc.md §4.2) contributions may carry the
|
|
70
|
+
* route IMPLEMENTATION — everything a starter route file can express — so
|
|
71
|
+
* domain packages can ship pages. All implementation fields are optional:
|
|
72
|
+
* metadata-only contributions remain valid, and hosts decide how the fields
|
|
73
|
+
* map onto their router (TanStack hosts spread them into route options).
|
|
74
|
+
*/
|
|
75
|
+
export interface AdminUiRouteContribution {
|
|
76
|
+
id: string;
|
|
77
|
+
path: string;
|
|
78
|
+
title: string;
|
|
79
|
+
/** The page. Keep it lazy-importable for code-splitting. */
|
|
80
|
+
component?: React.ComponentType;
|
|
81
|
+
/**
|
|
82
|
+
* The page as a LAZY module loader (preferred over `component`). The host
|
|
83
|
+
* binder wraps it in the router's lazy-component machinery, so the page
|
|
84
|
+
* lands in its own chunk instead of the workspace-chrome chunk, and
|
|
85
|
+
* hover/intent preloading fetches it ahead of navigation. The resolved
|
|
86
|
+
* component receives {@link AdminRoutePageProps} (params/search/title), so
|
|
87
|
+
* param-taking pages need no host route file.
|
|
88
|
+
*/
|
|
89
|
+
page?: () => Promise<AdminRoutePageModule>;
|
|
90
|
+
/** Data loader; receives the host QueryClient + app runtime. */
|
|
91
|
+
loader?: (ctx: AdminRouteLoaderContext) => unknown;
|
|
92
|
+
/** Typed search-param validation (e.g. a zod schema's parse). */
|
|
93
|
+
validateSearch?: (search: Record<string, unknown>) => unknown;
|
|
94
|
+
/** Per-route SSR mode, mirroring the host router's option. */
|
|
95
|
+
ssr?: boolean | "data-only";
|
|
96
|
+
pendingComponent?: React.ComponentType;
|
|
97
|
+
errorComponent?: React.ComponentType<{
|
|
98
|
+
error: unknown;
|
|
99
|
+
reset: () => void;
|
|
100
|
+
}>;
|
|
101
|
+
/** Capability/permission key the shell checks before rendering. */
|
|
102
|
+
capability?: string;
|
|
103
|
+
/** Preload policy override, mirroring the host router's option. */
|
|
104
|
+
preload?: false | "intent" | "render" | "viewport";
|
|
105
|
+
/**
|
|
106
|
+
* The semantic destination key this route SATISFIES (packaged-admin RFC
|
|
107
|
+
* §4.7 endgame). Declare it only when the destination's semantics map 1:1
|
|
108
|
+
* onto this route's path with pure param interpolation — the binding lets
|
|
109
|
+
* `voyant admin generate --destinations` emit the host's resolver for the
|
|
110
|
+
* key instead of the host hand-writing it. Destinations that need search
|
|
111
|
+
* params, multiple candidate routes, or any construction beyond path
|
|
112
|
+
* interpolation must NOT be bound here; their resolvers stay hand-written
|
|
113
|
+
* in the host map. The key must be declared on {@link AdminDestinations}
|
|
114
|
+
* (by this package or one whose augmentation is in scope), which keeps the
|
|
115
|
+
* annotation typo-proof.
|
|
116
|
+
*/
|
|
117
|
+
destination?: AdminDestinationKey;
|
|
118
|
+
/**
|
|
119
|
+
* Route param name → destination param name, for params whose names
|
|
120
|
+
* differ (e.g. route `/suppliers/$id` satisfying
|
|
121
|
+
* `"supplier.detail": { supplierId: string }` maps `{ id: "supplierId" }`).
|
|
122
|
+
* Params absent from the map keep their route name. Only meaningful next
|
|
123
|
+
* to {@link AdminUiRouteContribution.destination}.
|
|
124
|
+
*/
|
|
125
|
+
destinationParams?: Record<string, string>;
|
|
126
|
+
/**
|
|
127
|
+
* Redirect target: the route navigates here instead of rendering
|
|
128
|
+
* (host binders emit a `beforeLoad`-style redirect, which also covers
|
|
129
|
+
* SSR). A redirect contribution needs no `page`/`component` — it counts
|
|
130
|
+
* as implemented on its own. Used for the index redirects that used to be
|
|
131
|
+
* host route files (e.g. `/catalog` → `/catalog/products`).
|
|
132
|
+
*/
|
|
133
|
+
redirectTo?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Nested child contributions rendered inside this route's layout (this
|
|
136
|
+
* contribution becomes a LAYOUT route — its page renders an outlet).
|
|
137
|
+
* Child `path`s are RELATIVE to the parent path and start with `/`;
|
|
138
|
+
* a child path of exactly `"/"` is the parent's index route. Hosts bind
|
|
139
|
+
* children under the parent's code-based route (packaged-admin RFC §4.8 —
|
|
140
|
+
* see `attachAdminExtensionRoutes` / `adminExtensionChildRoutes` in
|
|
141
|
+
* `@voyant-travel/admin/app`).
|
|
142
|
+
*/
|
|
143
|
+
children?: ReadonlyArray<AdminUiRouteContribution>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Contribute one or more navigation items to the shared admin shell.
|
|
147
|
+
*
|
|
148
|
+
* Contributions are appended after the starter's base navigation and sorted
|
|
149
|
+
* by `order`. Set `insertAfter` to a base nav item id to splice the
|
|
150
|
+
* contribution's items in directly after that item instead — useful when
|
|
151
|
+
* the extension's items belong logically next to a built-in entry (e.g.
|
|
152
|
+
* Trips below Bookings).
|
|
153
|
+
*/
|
|
154
|
+
export interface AdminNavigationContribution {
|
|
155
|
+
items: ReadonlyArray<NavItem>;
|
|
156
|
+
order?: number;
|
|
157
|
+
insertAfter?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Named widget slot identifier.
|
|
161
|
+
*
|
|
162
|
+
* Starters define the slots they expose on specific admin pages and modules
|
|
163
|
+
* or extensions can target them with React components.
|
|
164
|
+
*/
|
|
165
|
+
export type AdminWidgetSlot = string;
|
|
166
|
+
/**
|
|
167
|
+
* A widget contribution that can be rendered inside a starter-defined slot.
|
|
168
|
+
*/
|
|
169
|
+
export interface AdminWidgetContribution<Props = Record<string, unknown>> {
|
|
170
|
+
id: string;
|
|
171
|
+
slot: AdminWidgetSlot;
|
|
172
|
+
order?: number;
|
|
173
|
+
component: React.ComponentType<Props>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Shared admin extension bundle.
|
|
177
|
+
*
|
|
178
|
+
* This keeps the extension surface explicit and typed without forcing a more
|
|
179
|
+
* dynamic plugin runtime into starters.
|
|
180
|
+
*/
|
|
181
|
+
export interface AdminExtension {
|
|
182
|
+
id: string;
|
|
183
|
+
navigation?: ReadonlyArray<AdminNavigationContribution>;
|
|
184
|
+
routes?: ReadonlyArray<AdminUiRouteContribution>;
|
|
185
|
+
widgets?: ReadonlyArray<AdminWidgetContribution>;
|
|
186
|
+
}
|
|
187
|
+
export declare function defineAdminExtension<T extends AdminExtension>(extension: T): T;
|
|
188
|
+
/**
|
|
189
|
+
* A route contribution whose `component` is guaranteed present, typed as a
|
|
190
|
+
* function component so it attaches directly to router `component:` options
|
|
191
|
+
* (router component types reject the class side of `React.ComponentType`).
|
|
192
|
+
*/
|
|
193
|
+
export type BindableAdminRoute = Omit<AdminUiRouteContribution, "component"> & {
|
|
194
|
+
component: React.FunctionComponent;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Look up a route contribution by id and assert it carries a component.
|
|
198
|
+
*
|
|
199
|
+
* This is the binding contract generated thin route files rely on
|
|
200
|
+
* (`voyant admin generate --routes`, packaged-admin RFC §4.2): the generator
|
|
201
|
+
* only emits hosts for zero-prop contributions whose `component` is present,
|
|
202
|
+
* and the emitted file resolves the contribution through this helper so a
|
|
203
|
+
* contribution that later loses its id or component fails loudly at module
|
|
204
|
+
* evaluation (build/dev start) instead of rendering an empty route.
|
|
205
|
+
*/
|
|
206
|
+
export declare function requireAdminRoute(extension: AdminExtension, routeId: string): BindableAdminRoute;
|
|
207
|
+
/**
|
|
208
|
+
* A route contribution guaranteed to carry an implementation — a lazy
|
|
209
|
+
* `page` module loader, an eager zero-prop `component`, or a `redirectTo`
|
|
210
|
+
* target (redirect routes render nothing).
|
|
211
|
+
*/
|
|
212
|
+
export type ImplementedAdminRoute = AdminUiRouteContribution & ({
|
|
213
|
+
page: () => Promise<AdminRoutePageModule>;
|
|
214
|
+
} | {
|
|
215
|
+
component: React.FunctionComponent;
|
|
216
|
+
} | {
|
|
217
|
+
redirectTo: string;
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* Depth-first lookup of a route contribution by id, descending into
|
|
221
|
+
* {@link AdminUiRouteContribution.children} so nested contributions (e.g.
|
|
222
|
+
* settings pages under the settings layout) resolve like top-level ones.
|
|
223
|
+
*/
|
|
224
|
+
export declare function findAdminRouteContribution(routes: ReadonlyArray<AdminUiRouteContribution> | undefined, routeId: string): AdminUiRouteContribution | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Look up a route contribution by id (including nested `children`) and
|
|
227
|
+
* assert it carries an implementation (`page`, `component`, or
|
|
228
|
+
* `redirectTo`).
|
|
229
|
+
*
|
|
230
|
+
* This is the binding contract of the code-assembled admin route tree
|
|
231
|
+
* (packaged-admin RFC §4.8 endgame): the host's generated route module
|
|
232
|
+
* resolves every extension route through this helper, so a contribution
|
|
233
|
+
* that later loses its id or implementation fails loudly at module
|
|
234
|
+
* evaluation (build/dev start) instead of rendering an empty route.
|
|
235
|
+
*/
|
|
236
|
+
export declare function requireImplementedAdminRoute(extension: AdminExtension, routeId: string): ImplementedAdminRoute;
|
|
237
|
+
/**
|
|
238
|
+
* Compose an explicit admin extension registry for a starter or app shell.
|
|
239
|
+
*
|
|
240
|
+
* The admin surface stays source-controlled and typed while still routing
|
|
241
|
+
* all contributions through the shared admin runtime package.
|
|
242
|
+
*/
|
|
243
|
+
export declare function createAdminExtensionRegistry(...extensions: ReadonlyArray<AdminExtension>): ReadonlyArray<AdminExtension>;
|
|
244
|
+
export interface ResolveAdminNavigationOptions {
|
|
245
|
+
baseItems: ReadonlyArray<NavItem>;
|
|
246
|
+
extensions?: ReadonlyArray<AdminExtension>;
|
|
247
|
+
}
|
|
248
|
+
export declare function resolveAdminNavigation({ baseItems, extensions, }: ResolveAdminNavigationOptions): NavItem[];
|
|
249
|
+
export interface ResolveAdminWidgetsOptions {
|
|
250
|
+
slot: AdminWidgetSlot;
|
|
251
|
+
extensions?: ReadonlyArray<AdminExtension>;
|
|
252
|
+
}
|
|
253
|
+
export declare function resolveAdminWidgets({ slot, extensions, }: ResolveAdminWidgetsOptions): AdminWidgetContribution[];
|
|
254
|
+
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAEnC,OAAO,KAAK,EAAE,mBAAmB,EAAqB,MAAM,8BAA8B,CAAA;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,uBAAuB;IACtC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CAAC,cAAc,CAAC,GAC3C,aAAa,CAAC,cAAc,CAAC,CAE/B;AAoBD,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CAC3C;AAED,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,UAAe,GAChB,EAAE,6BAA6B,GAAG,OAAO,EAAE,CAmC3C;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,eAAe,CAAA;IACrB,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CAC3C;AAED,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,UAAe,GAChB,EAAE,0BAA0B,GAAG,uBAAuB,EAAE,CAYxD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapt a component into an {@link AdminRoutePageModule}. Use inside `page`
|
|
3
|
+
* loaders for components that ignore route props entirely (zero-prop hosts)
|
|
4
|
+
* or take an all-optional props bag — both of which TypeScript's weak-type
|
|
5
|
+
* rule rejects as `AdminRoutePageComponent` despite being safe to mount.
|
|
6
|
+
*/
|
|
7
|
+
export function adminRoutePageModule(component) {
|
|
8
|
+
const Component = component;
|
|
9
|
+
return { default: Component };
|
|
10
|
+
}
|
|
11
|
+
export function defineAdminExtension(extension) {
|
|
12
|
+
return extension;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Look up a route contribution by id and assert it carries a component.
|
|
16
|
+
*
|
|
17
|
+
* This is the binding contract generated thin route files rely on
|
|
18
|
+
* (`voyant admin generate --routes`, packaged-admin RFC §4.2): the generator
|
|
19
|
+
* only emits hosts for zero-prop contributions whose `component` is present,
|
|
20
|
+
* and the emitted file resolves the contribution through this helper so a
|
|
21
|
+
* contribution that later loses its id or component fails loudly at module
|
|
22
|
+
* evaluation (build/dev start) instead of rendering an empty route.
|
|
23
|
+
*/
|
|
24
|
+
export function requireAdminRoute(extension, routeId) {
|
|
25
|
+
const route = extension.routes?.find((candidate) => candidate.id === routeId);
|
|
26
|
+
if (!route) {
|
|
27
|
+
throw new Error(`[voyant-admin] Extension "${extension.id}" has no route contribution "${routeId}". ` +
|
|
28
|
+
`Regenerate the host's route files with \`voyant admin generate --routes\`.`);
|
|
29
|
+
}
|
|
30
|
+
if (!route.component) {
|
|
31
|
+
throw new Error(`[voyant-admin] Route contribution "${routeId}" of extension "${extension.id}" carries no component. ` +
|
|
32
|
+
`Generated thin hosts require zero-prop components — regenerate with \`voyant admin generate --routes\`.`);
|
|
33
|
+
}
|
|
34
|
+
return route;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Depth-first lookup of a route contribution by id, descending into
|
|
38
|
+
* {@link AdminUiRouteContribution.children} so nested contributions (e.g.
|
|
39
|
+
* settings pages under the settings layout) resolve like top-level ones.
|
|
40
|
+
*/
|
|
41
|
+
export function findAdminRouteContribution(routes, routeId) {
|
|
42
|
+
for (const route of routes ?? []) {
|
|
43
|
+
if (route.id === routeId)
|
|
44
|
+
return route;
|
|
45
|
+
const nested = findAdminRouteContribution(route.children, routeId);
|
|
46
|
+
if (nested)
|
|
47
|
+
return nested;
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Look up a route contribution by id (including nested `children`) and
|
|
53
|
+
* assert it carries an implementation (`page`, `component`, or
|
|
54
|
+
* `redirectTo`).
|
|
55
|
+
*
|
|
56
|
+
* This is the binding contract of the code-assembled admin route tree
|
|
57
|
+
* (packaged-admin RFC §4.8 endgame): the host's generated route module
|
|
58
|
+
* resolves every extension route through this helper, so a contribution
|
|
59
|
+
* that later loses its id or implementation fails loudly at module
|
|
60
|
+
* evaluation (build/dev start) instead of rendering an empty route.
|
|
61
|
+
*/
|
|
62
|
+
export function requireImplementedAdminRoute(extension, routeId) {
|
|
63
|
+
const route = findAdminRouteContribution(extension.routes, routeId);
|
|
64
|
+
if (!route) {
|
|
65
|
+
throw new Error(`[voyant-admin] Extension "${extension.id}" has no route contribution "${routeId}". ` +
|
|
66
|
+
`Regenerate the host's admin route module with \`voyant admin generate --routes\`.`);
|
|
67
|
+
}
|
|
68
|
+
if (!route.page && !route.component && !route.redirectTo) {
|
|
69
|
+
throw new Error(`[voyant-admin] Route contribution "${routeId}" of extension "${extension.id}" carries no ` +
|
|
70
|
+
`implementation (neither \`page\`, \`component\`, nor \`redirectTo\`). Add one to the ` +
|
|
71
|
+
`extension, or keep the route as a hand-written host route file.`);
|
|
72
|
+
}
|
|
73
|
+
return route;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Compose an explicit admin extension registry for a starter or app shell.
|
|
77
|
+
*
|
|
78
|
+
* The admin surface stays source-controlled and typed while still routing
|
|
79
|
+
* all contributions through the shared admin runtime package.
|
|
80
|
+
*/
|
|
81
|
+
export function createAdminExtensionRegistry(...extensions) {
|
|
82
|
+
return extensions;
|
|
83
|
+
}
|
|
84
|
+
function sortOrderedValues(values) {
|
|
85
|
+
return [...values]
|
|
86
|
+
.sort((a, b) => {
|
|
87
|
+
if (a.order !== b.order) {
|
|
88
|
+
return a.order - b.order;
|
|
89
|
+
}
|
|
90
|
+
return a.index - b.index;
|
|
91
|
+
})
|
|
92
|
+
.map((entry) => entry.value);
|
|
93
|
+
}
|
|
94
|
+
export function resolveAdminNavigation({ baseItems, extensions = [], }) {
|
|
95
|
+
const contributions = extensions.flatMap((extension) => extension.navigation ?? []);
|
|
96
|
+
const orderedContributions = sortOrderedValues(contributions.map((contribution, index) => ({
|
|
97
|
+
index,
|
|
98
|
+
order: contribution.order ?? 0,
|
|
99
|
+
value: contribution,
|
|
100
|
+
})));
|
|
101
|
+
const anchoredByBaseId = new Map();
|
|
102
|
+
const appended = [];
|
|
103
|
+
for (const contribution of orderedContributions) {
|
|
104
|
+
if (contribution.insertAfter) {
|
|
105
|
+
const bucket = anchoredByBaseId.get(contribution.insertAfter) ?? [];
|
|
106
|
+
bucket.push(...contribution.items);
|
|
107
|
+
anchoredByBaseId.set(contribution.insertAfter, bucket);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
appended.push(...contribution.items);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const merged = [];
|
|
114
|
+
for (const item of baseItems) {
|
|
115
|
+
merged.push(item);
|
|
116
|
+
if (!item.id)
|
|
117
|
+
continue;
|
|
118
|
+
const anchored = anchoredByBaseId.get(item.id);
|
|
119
|
+
if (anchored)
|
|
120
|
+
merged.push(...anchored);
|
|
121
|
+
}
|
|
122
|
+
// Items anchored to a base id that no longer exists fall through to the
|
|
123
|
+
// tail so they're still discoverable rather than silently dropped.
|
|
124
|
+
for (const [baseId, items] of anchoredByBaseId.entries()) {
|
|
125
|
+
if (!baseItems.some((item) => item.id === baseId))
|
|
126
|
+
appended.push(...items);
|
|
127
|
+
}
|
|
128
|
+
return [...merged, ...appended];
|
|
129
|
+
}
|
|
130
|
+
export function resolveAdminWidgets({ slot, extensions = [], }) {
|
|
131
|
+
const widgets = extensions
|
|
132
|
+
.flatMap((extension) => extension.widgets ?? [])
|
|
133
|
+
.filter((widget) => widget.slot === slot);
|
|
134
|
+
return sortOrderedValues(widgets.map((widget, index) => ({
|
|
135
|
+
index,
|
|
136
|
+
order: widget.order ?? 0,
|
|
137
|
+
value: widget,
|
|
138
|
+
})));
|
|
139
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @voyant-travel/admin — shared admin-dashboard shell for Voyant starters.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - Theme provider: zero-dependency ThemeProvider + useTheme that toggles
|
|
6
|
+
* `light`/`dark` classes on `document.documentElement` and honors
|
|
7
|
+
* `prefers-color-scheme` for the "system" mode.
|
|
8
|
+
* - Locale provider: useLocale + LocaleProvider for admin locale/timezone
|
|
9
|
+
* resolution and persistence.
|
|
10
|
+
* - Query client factory: `makeQueryClient()` with Voyant's admin defaults.
|
|
11
|
+
* - `AdminProvider` composing QueryClient + ThemeProvider + LocaleProvider.
|
|
12
|
+
* - Operator admin shell helpers for API, i18n, and domain provider wiring.
|
|
13
|
+
* - Dashboard page composition, skeletons, aggregate query helpers, and extension context.
|
|
14
|
+
* - Operator admin sidebar, navigation, and workspace layout helpers.
|
|
15
|
+
* - Admin extension helpers for navigation contributions and widget slots.
|
|
16
|
+
* - Semantic destinations: `AdminDestinations` + `AdminNavigationProvider` +
|
|
17
|
+
* `useAdminHref`/`useAdminNavigate` for package-owned pages that navigate
|
|
18
|
+
* to routes they don't own (packaged-admin RFC §4.7).
|
|
19
|
+
* - User utilities: `getInitials`, `getDisplayName`.
|
|
20
|
+
* - Types: `AdminUser`, `NavItem`, `NavSubItem`, `AuthActions`, `ThemeMode`.
|
|
21
|
+
*/
|
|
22
|
+
export { type AdminBreadcrumbSegment, AdminBreadcrumbsProvider, type AdminBreadcrumbsProviderProps, AdminBreadcrumbsTrail, type AdminBreadcrumbsTrailProps, useAdminBreadcrumbs, useAdminBreadcrumbsValue, } from "./components/admin-breadcrumbs.js";
|
|
23
|
+
export { AdminNavGroup, type AdminNavGroupProps, } from "./components/admin-nav-group.js";
|
|
24
|
+
export { type AdminNavLinkComponent, type AdminNavLinkProps, DefaultAdminNavLink, } from "./components/admin-nav-link.js";
|
|
25
|
+
export { AdminPageHead, type AdminPageHeadOptions, type AdminPageHeadProps, AdminPageHeadProvider, type AdminPageHeadProviderProps, useAdminPageHead, } from "./components/admin-page-head.js";
|
|
26
|
+
export { AdminWidgetSlotRenderer, type AdminWidgetSlotRendererProps, } from "./components/admin-widget-slot.js";
|
|
27
|
+
export { VoyantMark } from "./components/brand/voyant-mark.js";
|
|
28
|
+
export { VoyantWordmark } from "./components/brand/voyant-wordmark.js";
|
|
29
|
+
export { OperatorAdminBootstrapGate, type OperatorAdminBootstrapGateProps, type OperatorAdminBootstrapMode, type OperatorAdminBootstrapRenderState, } from "./components/operator-admin-bootstrap-gate.js";
|
|
30
|
+
export { OperatorAdminPageShell, type OperatorAdminPageShellProps, } from "./components/operator-admin-page-shell.js";
|
|
31
|
+
export { DefaultOperatorAdminBrand, type DefaultOperatorAdminBrandProps, OperatorAdminSidebar, type OperatorAdminSidebarProps, OperatorAdminWorkspaceLayout, type OperatorAdminWorkspaceLayoutProps, resolveAdminPageTitle, } from "./components/operator-admin-sidebar.js";
|
|
32
|
+
export { OperatorAdminUserMenu, type OperatorAdminUserMenuProps, } from "./components/operator-admin-user-menu.js";
|
|
33
|
+
export { TeamSettingsPage, type TeamSettingsPageApi, type TeamSettingsPageProps, } from "./components/team-settings-page.js";
|
|
34
|
+
export type { DashboardEmptyAction, DashboardEmptyStateConfig, DashboardEmptyStateKey, DashboardPageProps, } from "./dashboard/dashboard-page.js";
|
|
35
|
+
export { type BookingsAggregates, bookingStatusConfig, buildDashboardSixMonthWindow, buildMonthSeries, DashboardApiError, type DashboardQueryClient, dashboardQueryKeys, type FinanceAggregates, formatCurrency, getDashboardBookingsAggregatesQueryOptions, getDashboardFinanceAggregatesQueryOptions, getDashboardProductsAggregatesQueryOptions, getDashboardSuppliersAggregatesQueryOptions, getStatusColor, monthlyBookingsConfig, type ProductsAggregates, pickPrimaryCurrency, revenueChartConfig, type SuppliersAggregates, } from "./dashboard/dashboard-query-options.js";
|
|
36
|
+
export { DashboardAreaChartSkeleton, DashboardBarChartSkeleton, DashboardKpiRowSkeleton, DashboardKpiSkeleton, DashboardOutstandingInvoicesSkeleton, DashboardPieChartSkeleton, DashboardSkeleton, DashboardUpcomingListSkeleton, } from "./dashboard/dashboard-skeleton.js";
|
|
37
|
+
export { type AdminExtension, type AdminNavigationContribution, type AdminRouteLoaderContext, type AdminRoutePageComponent, type AdminRoutePageModule, type AdminRoutePageProps, type AdminRouteRuntime, type AdminUiRouteContribution, type AdminWidgetContribution, type AdminWidgetSlot, adminRoutePageModule, type BindableAdminRoute, createAdminExtensionRegistry, defineAdminExtension, findAdminRouteContribution, type ImplementedAdminRoute, type ResolveAdminNavigationOptions, type ResolveAdminWidgetsOptions, requireAdminRoute, requireImplementedAdminRoute, resolveAdminNavigation, resolveAdminWidgets, } from "./extensions.js";
|
|
38
|
+
export { composeLocaleMessageDefinitions, type DeepPartial, formatMessage, type LocaleMessageDefinitions, type LocaleMessageOverrides, MessagesProvider, resolveLocaleMessages, useMessages, } from "./lib/i18n.js";
|
|
39
|
+
export { getDisplayName, getInitials } from "./lib/initials.js";
|
|
40
|
+
export { type AdminDestinationKey, type AdminDestinationNavigator, type AdminDestinationResolvers, type AdminDestinations, type AdminHrefResolver, type AdminNavigateOptions, AdminNavigationProvider, type AdminNavigationProviderProps, useAdminHref, useAdminNavigate, } from "./navigation/destinations.js";
|
|
41
|
+
export { type CreateOperatorAdminNavigationOptions, createOperatorAdminNavigation, type OperatorAdminNavigationIconName, type OperatorAdminNavigationIcons, } from "./navigation/operator-navigation.js";
|
|
42
|
+
export { AdminExtensionsProvider, type AdminExtensionsProviderProps, useAdminExtensions, } from "./providers/admin-extensions.js";
|
|
43
|
+
export { AdminProvider, type AdminProviderProps } from "./providers/admin-provider.js";
|
|
44
|
+
export { DEFAULT_ADMIN_LOCALE, DEFAULT_ADMIN_LOCALES, type LocaleContextValue, LocaleProvider, type LocaleProviderProps, resolveAdminLocale, useLocale, } from "./providers/locale.js";
|
|
45
|
+
export { type AdminLocalePreferenceSource, AdminLocalePreferenceSync, type AdminLocalePreferenceSyncProps, } from "./providers/locale-preferences.js";
|
|
46
|
+
export { getOperatorAdminMessageOverridesFromUiPrefs, type OperatorAdminMessageOverrides, type OperatorAdminMessages, OperatorAdminMessagesProvider, useOperatorAdminI18n, useOperatorAdminMessages, useOptionalOperatorAdminI18n, useOptionalOperatorAdminMessages, } from "./providers/operator-admin-messages.js";
|
|
47
|
+
export { type AdminChildProvider, type AdminDomainMessagesProvider, type AdminDomainMessagesProviderProps, AdminDomainMessagesProviderStack, AdminProviderSequence, type AdminProviderSequenceProps, OperatorAdminShellProvider, type OperatorAdminShellProviderProps, } from "./providers/operator-admin-shell.js";
|
|
48
|
+
export { makeQueryClient } from "./providers/query-client.js";
|
|
49
|
+
export { type ThemeContextValue, ThemeProvider, type ThemeProviderProps, useTheme, } from "./providers/theme.js";
|
|
50
|
+
export { type AdminUser, type AuthActions, BETA, COMING_SOON, type NavItem, type NavItemStatus, type NavSubItem, type ThemeMode, } from "./types.js";
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,KAAK,sBAAsB,EAC3B,wBAAwB,EACxB,KAAK,6BAA6B,EAClC,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,mBAAmB,GACpB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,gBAAgB,GACjB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACL,uBAAuB,EACvB,KAAK,4BAA4B,GAClC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EACL,0BAA0B,EAC1B,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,iCAAiC,GACvC,MAAM,+CAA+C,CAAA;AACtD,OAAO,EACL,sBAAsB,EACt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AAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,gCAAgC,EAChC,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,0BAA0B,EAC1B,KAAK,+BAA+B,GACrC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EACL,KAAK,iBAAiB,EACtB,aAAa,EACb,KAAK,kBAAkB,EACvB,QAAQ,GACT,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,IAAI,EACJ,WAAW,EACX,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @voyant-travel/admin — shared admin-dashboard shell for Voyant starters.
|
|
3
|
+
*
|
|
4
|
+
* Exports:
|
|
5
|
+
* - Theme provider: zero-dependency ThemeProvider + useTheme that toggles
|
|
6
|
+
* `light`/`dark` classes on `document.documentElement` and honors
|
|
7
|
+
* `prefers-color-scheme` for the "system" mode.
|
|
8
|
+
* - Locale provider: useLocale + LocaleProvider for admin locale/timezone
|
|
9
|
+
* resolution and persistence.
|
|
10
|
+
* - Query client factory: `makeQueryClient()` with Voyant's admin defaults.
|
|
11
|
+
* - `AdminProvider` composing QueryClient + ThemeProvider + LocaleProvider.
|
|
12
|
+
* - Operator admin shell helpers for API, i18n, and domain provider wiring.
|
|
13
|
+
* - Dashboard page composition, skeletons, aggregate query helpers, and extension context.
|
|
14
|
+
* - Operator admin sidebar, navigation, and workspace layout helpers.
|
|
15
|
+
* - Admin extension helpers for navigation contributions and widget slots.
|
|
16
|
+
* - Semantic destinations: `AdminDestinations` + `AdminNavigationProvider` +
|
|
17
|
+
* `useAdminHref`/`useAdminNavigate` for package-owned pages that navigate
|
|
18
|
+
* to routes they don't own (packaged-admin RFC §4.7).
|
|
19
|
+
* - User utilities: `getInitials`, `getDisplayName`.
|
|
20
|
+
* - Types: `AdminUser`, `NavItem`, `NavSubItem`, `AuthActions`, `ThemeMode`.
|
|
21
|
+
*/
|
|
22
|
+
export { AdminBreadcrumbsProvider, AdminBreadcrumbsTrail, useAdminBreadcrumbs, useAdminBreadcrumbsValue, } from "./components/admin-breadcrumbs.js";
|
|
23
|
+
export { AdminNavGroup, } from "./components/admin-nav-group.js";
|
|
24
|
+
export { DefaultAdminNavLink, } from "./components/admin-nav-link.js";
|
|
25
|
+
export { AdminPageHead, AdminPageHeadProvider, useAdminPageHead, } from "./components/admin-page-head.js";
|
|
26
|
+
export { AdminWidgetSlotRenderer, } from "./components/admin-widget-slot.js";
|
|
27
|
+
export { VoyantMark } from "./components/brand/voyant-mark.js";
|
|
28
|
+
export { VoyantWordmark } from "./components/brand/voyant-wordmark.js";
|
|
29
|
+
export { OperatorAdminBootstrapGate, } from "./components/operator-admin-bootstrap-gate.js";
|
|
30
|
+
export { OperatorAdminPageShell, } from "./components/operator-admin-page-shell.js";
|
|
31
|
+
export { DefaultOperatorAdminBrand, OperatorAdminSidebar, OperatorAdminWorkspaceLayout, resolveAdminPageTitle, } from "./components/operator-admin-sidebar.js";
|
|
32
|
+
export { OperatorAdminUserMenu, } from "./components/operator-admin-user-menu.js";
|
|
33
|
+
export { TeamSettingsPage, } from "./components/team-settings-page.js";
|
|
34
|
+
// DashboardPage pulls recharts (~390 KB) — intentionally NOT re-exported
|
|
35
|
+
// here so consumers of this barrel for non-dashboard concerns (sidebar,
|
|
36
|
+
// providers, hooks) don't transitively pull the chart bundle. Import
|
|
37
|
+
// directly from "@voyant-travel/admin/dashboard/dashboard-page" instead.
|
|
38
|
+
export { bookingStatusConfig, buildDashboardSixMonthWindow, buildMonthSeries, DashboardApiError, dashboardQueryKeys, formatCurrency, getDashboardBookingsAggregatesQueryOptions, getDashboardFinanceAggregatesQueryOptions, getDashboardProductsAggregatesQueryOptions, getDashboardSuppliersAggregatesQueryOptions, getStatusColor, monthlyBookingsConfig, pickPrimaryCurrency, revenueChartConfig, } from "./dashboard/dashboard-query-options.js";
|
|
39
|
+
export { DashboardAreaChartSkeleton, DashboardBarChartSkeleton, DashboardKpiRowSkeleton, DashboardKpiSkeleton, DashboardOutstandingInvoicesSkeleton, DashboardPieChartSkeleton, DashboardSkeleton, DashboardUpcomingListSkeleton, } from "./dashboard/dashboard-skeleton.js";
|
|
40
|
+
export { adminRoutePageModule, createAdminExtensionRegistry, defineAdminExtension, findAdminRouteContribution, requireAdminRoute, requireImplementedAdminRoute, resolveAdminNavigation, resolveAdminWidgets, } from "./extensions.js";
|
|
41
|
+
export { composeLocaleMessageDefinitions, formatMessage, MessagesProvider, resolveLocaleMessages, useMessages, } from "./lib/i18n.js";
|
|
42
|
+
export { getDisplayName, getInitials } from "./lib/initials.js";
|
|
43
|
+
export { AdminNavigationProvider, useAdminHref, useAdminNavigate, } from "./navigation/destinations.js";
|
|
44
|
+
export { createOperatorAdminNavigation, } from "./navigation/operator-navigation.js";
|
|
45
|
+
export { AdminExtensionsProvider, useAdminExtensions, } from "./providers/admin-extensions.js";
|
|
46
|
+
export { AdminProvider } from "./providers/admin-provider.js";
|
|
47
|
+
export { DEFAULT_ADMIN_LOCALE, DEFAULT_ADMIN_LOCALES, LocaleProvider, resolveAdminLocale, useLocale, } from "./providers/locale.js";
|
|
48
|
+
export { AdminLocalePreferenceSync, } from "./providers/locale-preferences.js";
|
|
49
|
+
export { getOperatorAdminMessageOverridesFromUiPrefs, OperatorAdminMessagesProvider, useOperatorAdminI18n, useOperatorAdminMessages, useOptionalOperatorAdminI18n, useOptionalOperatorAdminMessages, } from "./providers/operator-admin-messages.js";
|
|
50
|
+
export { AdminDomainMessagesProviderStack, AdminProviderSequence, OperatorAdminShellProvider, } from "./providers/operator-admin-shell.js";
|
|
51
|
+
export { makeQueryClient } from "./providers/query-client.js";
|
|
52
|
+
export { ThemeProvider, useTheme, } from "./providers/theme.js";
|
|
53
|
+
export { BETA, COMING_SOON, } from "./types.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { composeLocaleMessageDefinitions, createLocaleFormatters, createPackageMessagesContext, type DeepPartial, dmcAdminMessageDefinitions, formatMessage, getLocaleMessageOverridesFromUiPrefs, type LocaleFormatters, type LocaleMessageDefinitions, type LocaleMessageOverrides, type LocaleMessageSchema, MessagesProvider, operatorAdminMessageDefinitions, type PackageI18nValue, type PackageMessagesProviderProps, type ResolvedPackageMessagesProviderProps, resolveLocaleMessages, resolvePackageMessages, useMessages, useResolvedLocaleMessages, } from "@voyant-travel/i18n";
|
|
2
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/lib/i18n.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,KAAK,WAAW,EAChB,0BAA0B,EAC1B,aAAa,EACb,oCAAoC,EACpC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,+BAA+B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,oCAAoC,EACzC,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACX,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA"}
|
package/dist/lib/i18n.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { composeLocaleMessageDefinitions, createLocaleFormatters, createPackageMessagesContext, dmcAdminMessageDefinitions, formatMessage, getLocaleMessageOverridesFromUiPrefs, MessagesProvider, operatorAdminMessageDefinitions, resolveLocaleMessages, resolvePackageMessages, useMessages, useResolvedLocaleMessages, } from "@voyant-travel/i18n";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives a two-character uppercase initials string from a user's name or
|
|
3
|
+
* email address. Used by avatar fallbacks.
|
|
4
|
+
*
|
|
5
|
+
* Rules (in priority order):
|
|
6
|
+
* 1. If `firstName` + `lastName` are available → "FL"
|
|
7
|
+
* 2. If only `firstName` → first two characters of first name
|
|
8
|
+
* 3. If only `lastName` → first two characters of last name
|
|
9
|
+
* 4. If `email` has a prefix of ≥2 chars → first two characters of prefix
|
|
10
|
+
* 5. If `email` prefix is 1 char → that character
|
|
11
|
+
* 6. Otherwise → "?"
|
|
12
|
+
*/
|
|
13
|
+
export declare function getInitials(firstName?: string | null, lastName?: string | null, email?: string | null): string;
|
|
14
|
+
/**
|
|
15
|
+
* Computes display name for a user, preferring `firstName + lastName`, falling
|
|
16
|
+
* back to `name`, then `email`, then "Unknown User".
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDisplayName(user: {
|
|
19
|
+
firstName?: string | null;
|
|
20
|
+
lastName?: string | null;
|
|
21
|
+
name?: string | null;
|
|
22
|
+
email?: string | null;
|
|
23
|
+
}): string;
|
|
24
|
+
//# sourceMappingURL=initials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../src/lib/initials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAkBR;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB,GAAG,MAAM,CAMT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives a two-character uppercase initials string from a user's name or
|
|
3
|
+
* email address. Used by avatar fallbacks.
|
|
4
|
+
*
|
|
5
|
+
* Rules (in priority order):
|
|
6
|
+
* 1. If `firstName` + `lastName` are available → "FL"
|
|
7
|
+
* 2. If only `firstName` → first two characters of first name
|
|
8
|
+
* 3. If only `lastName` → first two characters of last name
|
|
9
|
+
* 4. If `email` has a prefix of ≥2 chars → first two characters of prefix
|
|
10
|
+
* 5. If `email` prefix is 1 char → that character
|
|
11
|
+
* 6. Otherwise → "?"
|
|
12
|
+
*/
|
|
13
|
+
export function getInitials(firstName, lastName, email) {
|
|
14
|
+
const f = (firstName ?? "").trim();
|
|
15
|
+
const l = (lastName ?? "").trim();
|
|
16
|
+
if (f && l) {
|
|
17
|
+
return (f.charAt(0) + l.charAt(0)).toUpperCase();
|
|
18
|
+
}
|
|
19
|
+
if (f) {
|
|
20
|
+
return f.slice(0, 2).toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
if (l) {
|
|
23
|
+
return l.slice(0, 2).toUpperCase();
|
|
24
|
+
}
|
|
25
|
+
const prefix = (email ?? "").split("@")[0] ?? "";
|
|
26
|
+
if (prefix.length >= 2)
|
|
27
|
+
return prefix.slice(0, 2).toUpperCase();
|
|
28
|
+
if (prefix.length === 1)
|
|
29
|
+
return prefix.toUpperCase();
|
|
30
|
+
return "?";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Computes display name for a user, preferring `firstName + lastName`, falling
|
|
34
|
+
* back to `name`, then `email`, then "Unknown User".
|
|
35
|
+
*/
|
|
36
|
+
export function getDisplayName(user) {
|
|
37
|
+
const combined = [user.firstName, user.lastName].filter(Boolean).join(" ").trim();
|
|
38
|
+
if (combined)
|
|
39
|
+
return combined;
|
|
40
|
+
if (user.name?.trim())
|
|
41
|
+
return user.name.trim();
|
|
42
|
+
if (user.email?.trim())
|
|
43
|
+
return user.email.trim();
|
|
44
|
+
return "Unknown User";
|
|
45
|
+
}
|