@magicvr/schema-ui-shell 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/app/App.d.ts +23 -0
- package/app/AuthGate.d.ts +20 -0
- package/app/HostFailureScreen.d.ts +18 -0
- package/app/LoginPage.d.ts +11 -0
- package/app/ManifestFailure.d.ts +3 -0
- package/app/branding.d.ts +33 -0
- package/app/config-events.d.ts +18 -0
- package/app/index.d.ts +15 -0
- package/app/navigation.d.ts +27 -0
- package/app/notification-bell.d.ts +10 -0
- package/components/data-table.d.ts +43 -0
- package/components/force-password-change.d.ts +1 -0
- package/components/invite-accept.d.ts +6 -0
- package/components/locale-switcher.d.ts +23 -0
- package/components/theme-toggle.d.ts +10 -0
- package/components/timezone-switcher.d.ts +16 -0
- package/components/ui/async-state.d.ts +27 -0
- package/components/ui/breadcrumbs.d.ts +78 -0
- package/components/ui/button.d.ts +11 -0
- package/components/ui/card.d.ts +8 -0
- package/components/ui/input.d.ts +5 -0
- package/components/ui/label.d.ts +3 -0
- package/components/ui/skeleton.d.ts +2 -0
- package/components/ui/textarea.d.ts +5 -0
- package/host/boot.d.ts +64 -0
- package/host/bootstrap.d.ts +105 -0
- package/host/claim.d.ts +75 -0
- package/host/failure.d.ts +97 -0
- package/host/return-intent.d.ts +55 -0
- package/i18n/catalog.d.ts +51 -0
- package/i18n/format.d.ts +17 -0
- package/i18n/locale.d.ts +51 -0
- package/i18n/runtime.d.ts +90 -0
- package/i18n/timezone.d.ts +57 -0
- package/index.js +23764 -0
- package/lib/datetime.d.ts +14 -0
- package/lib/fetch-timeout.d.ts +13 -0
- package/lib/utils.d.ts +2 -0
- package/package.json +30 -0
- package/renderer/confirm.d.ts +17 -0
- package/renderer/custom-components.d.ts +14 -0
- package/renderer/form-controls.d.ts +45 -0
- package/renderer/form-controls.types.d.ts +135 -0
- package/renderer/modal.d.ts +6 -0
- package/renderer/permissions.d.ts +53 -0
- package/renderer/reaction-engine.d.ts +92 -0
- package/renderer/reaction-expression.d.ts +74 -0
- package/renderer/reactions.d.ts +64 -0
- package/renderer/render.d.ts +194 -0
- package/renderer/render.types.d.ts +289 -0
- package/renderer/resource.d.ts +114 -0
- package/renderer/schema-table.d.ts +90 -0
- package/theme/theme.d.ts +64 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type ResourceItem } from "@/renderer/resource";
|
|
2
|
+
import type { RenderTableNode } from "@/renderer/render.types";
|
|
3
|
+
/**
|
|
4
|
+
* Default schema-driven table surface (R1 · GOAL-004 / D-004) + S4 CRUD wiring
|
|
5
|
+
* + A-002 generic adapter (GOAL-010 S3).
|
|
6
|
+
*
|
|
7
|
+
* Renders a whitelisted table node's `props.columns` over its `props.dataSource`.
|
|
8
|
+
* Fails closed when the node declares no columns, no (valid) data source, or a
|
|
9
|
+
* response that violates the frozen rowKey invariant (F-001 / F-002).
|
|
10
|
+
*
|
|
11
|
+
* F-001 (I-010-001 v0.2.0 §2): `dataSource` must be a single-slash same-origin
|
|
12
|
+
* path; invalid/absent sources render an observable fail-closed state and never
|
|
13
|
+
* reach the (auth) fetcher.
|
|
14
|
+
*
|
|
15
|
+
* F-002 (I-010-001 v0.2.0 §3): `props.rowKey` (default `"id"`) is the direct
|
|
16
|
+
* field name of each row's unique, non-empty scalar key (string / finite
|
|
17
|
+
* number). A missing / empty / non-scalar / duplicate key stops rendering the
|
|
18
|
+
* table data and forbids row actions and selection.
|
|
19
|
+
*
|
|
20
|
+
* S4 (GOAL-007 · I-007-003 v0.2.2 §9): when rendered inside a `RenderPage`
|
|
21
|
+
* (which always wraps content in the SchemaCrudProvider), the table surfaces
|
|
22
|
+
* `props.toolbar` (create trigger) and `props.actions` (row edit/delete),
|
|
23
|
+
* participates in row selection for the page's recordView / edit-form prefill,
|
|
24
|
+
* reads its query from the shared per-table query state (so the search-form
|
|
25
|
+
* binding and the post-write reload both reach it), and registers its injected
|
|
26
|
+
* fetcher so modal form submits / row actions use the same transport. All of
|
|
27
|
+
* this is fixture-driven: no record-specific logic lives here.
|
|
28
|
+
*/
|
|
29
|
+
export interface SchemaTableProps {
|
|
30
|
+
node: RenderTableNode;
|
|
31
|
+
/** Injectable fetch (defaults to `globalThis.fetch`). */
|
|
32
|
+
fetcher?: typeof fetch;
|
|
33
|
+
}
|
|
34
|
+
export interface SchemaTableColumnSpec {
|
|
35
|
+
field: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
sortable?: boolean;
|
|
38
|
+
/** W4 · GOAL-005: single-line truncate + title affordance for long values. */
|
|
39
|
+
truncate?: boolean;
|
|
40
|
+
/** Column width hint (px number or CSS length). */
|
|
41
|
+
width?: number | string;
|
|
42
|
+
/** Minimum column width (px number or CSS length). */
|
|
43
|
+
minWidth?: number | string;
|
|
44
|
+
/** W16-F04: render a cent-valued number as a localized currency string. */
|
|
45
|
+
format?: "currency";
|
|
46
|
+
/** W16-F09: render this cell as a colored badge using the row field value. */
|
|
47
|
+
badgeStyleField?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Structured row predicate used by Schema actions; malformed predicates fail closed. */
|
|
50
|
+
export declare function rowActionDisabled(action: unknown, row: ResourceItem): boolean;
|
|
51
|
+
/** Extracts the table node's column specs, fail-closed on malformed entries. */
|
|
52
|
+
export declare function schemaTableColumns(node: RenderTableNode): SchemaTableColumnSpec[];
|
|
53
|
+
/**
|
|
54
|
+
* Resolves the table node's list endpoint (F-001). v2.9 prefers the node-level
|
|
55
|
+
* DataRef (ADR-0039, source:api url); the legacy props.dataSource string stays
|
|
56
|
+
* supported. Returns null when absent or not a single-slash same-origin path;
|
|
57
|
+
* the table then fails closed and never fetches (the fixture fallback was
|
|
58
|
+
* removed in GOAL-010 S3).
|
|
59
|
+
*/
|
|
60
|
+
export declare function schemaTableDataSource(node: RenderTableNode): string | null;
|
|
61
|
+
/** v2.9 node-level DataRef params (ADR-0039 route bindings), else empty. */
|
|
62
|
+
export declare function schemaTableDataParams(node: RenderTableNode): Record<string, unknown> | undefined;
|
|
63
|
+
/** F-002: the direct field name used as each row's unique key (default "id"). */
|
|
64
|
+
export declare function schemaTableRowKey(node: RenderTableNode): string;
|
|
65
|
+
/** One select option of a schema-driven table filter. */
|
|
66
|
+
export interface SchemaTableFilterOptionSpec {
|
|
67
|
+
value: string;
|
|
68
|
+
label?: string;
|
|
69
|
+
labelKey?: string;
|
|
70
|
+
}
|
|
71
|
+
/** A schema-driven table filter (table node `props.filters`; select-only). */
|
|
72
|
+
export interface SchemaTableFilterSpec {
|
|
73
|
+
field: string;
|
|
74
|
+
type: "select";
|
|
75
|
+
label?: string;
|
|
76
|
+
labelKey?: string;
|
|
77
|
+
options: SchemaTableFilterOptionSpec[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extracts the table node's filter specs (fail-closed on malformed entries).
|
|
81
|
+
* Only `select` filters are supported; other/unknown types are dropped so a
|
|
82
|
+
* schema typo never renders a broken control.
|
|
83
|
+
*/
|
|
84
|
+
export declare function schemaTableFilters(node: RenderTableNode): SchemaTableFilterSpec[];
|
|
85
|
+
/**
|
|
86
|
+
* Windowed pager page list: 1 … current±1 … total, with gap markers for
|
|
87
|
+
* long page runs (stable shape for tests and a11y).
|
|
88
|
+
*/
|
|
89
|
+
export declare function pagerPages(current: number, total: number): Array<number | "gap">;
|
|
90
|
+
export declare function SchemaTable({ node, fetcher }: SchemaTableProps): import("react").JSX.Element;
|
package/theme/theme.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme pure-logic unit (S1 · C3 + VP-007 S3 system default).
|
|
3
|
+
*
|
|
4
|
+
* `applyTheme` is a side-effect-free function that computes the desired theme
|
|
5
|
+
* and then applies it to the provided document root. Keeping the decision
|
|
6
|
+
* logic in a plain function lets vitest exercise it without a browser.
|
|
7
|
+
*
|
|
8
|
+
* `initTheme` is the top-level boot call used by the synchronous external
|
|
9
|
+
* `/theme-init.js` script in index.html and by main.tsx (the module call is
|
|
10
|
+
* kept as a safety net for test/storybook entry points).
|
|
11
|
+
*
|
|
12
|
+
* VP-007 S3 priority (D-002, user-confirmed): user explicit choice →
|
|
13
|
+
* system default theme (from the public startup configuration, non-auto) →
|
|
14
|
+
* OS preference. The user's explicit choice always wins.
|
|
15
|
+
*/
|
|
16
|
+
export type Theme = "light" | "dark";
|
|
17
|
+
export interface ThemeInput {
|
|
18
|
+
/** Value of `localStorage.getItem("theme")` — null when absent. */
|
|
19
|
+
stored: string | null;
|
|
20
|
+
/** `window.matchMedia("(prefers-color-scheme: dark)").matches` */
|
|
21
|
+
prefersDark: boolean;
|
|
22
|
+
/** System default theme from /api/branding (auto/light/dark); null = auto. */
|
|
23
|
+
systemDefault?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ThemeOutput {
|
|
26
|
+
theme: Theme;
|
|
27
|
+
/** CSS `color-scheme` value for the root element. */
|
|
28
|
+
colorScheme: "light" | "dark";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pure function: decides the effective theme from storage + system default +
|
|
32
|
+
* OS preference. No DOM side-effects — safe to call in vitest.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveTheme(input: ThemeInput): ThemeOutput;
|
|
35
|
+
/**
|
|
36
|
+
* Applies the resolved theme to a DOM element (typically
|
|
37
|
+
* `document.documentElement`). Adds or removes the `dark` class and sets
|
|
38
|
+
* the `color-scheme` style so native browser controls match.
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyThemeToElement(el: HTMLElement, output: ThemeOutput): void;
|
|
41
|
+
/**
|
|
42
|
+
* End-to-end theme boot: reads real browser APIs and mutates the DOM.
|
|
43
|
+
* Called from the synchronous external /theme-init.js script in index.html and from main.tsx.
|
|
44
|
+
*
|
|
45
|
+
* W4 P2-1: localStorage may throw when site storage is disabled (privacy
|
|
46
|
+
* mode). main.tsx calls initTheme at module top level — an uncaught throw
|
|
47
|
+
* would abort module evaluation and the app would never mount (white screen,
|
|
48
|
+
* not even the failure surface). Guard reads/writes exactly like tokens.ts.
|
|
49
|
+
*/
|
|
50
|
+
export declare function initTheme(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Applies the system default theme (from the public startup configuration)
|
|
53
|
+
* when the user has no explicit choice. VP-007 S3: the explicit user theme
|
|
54
|
+
* always wins; otherwise the system default (non-auto) beats the OS
|
|
55
|
+
* preference. Called after branding loads on the login page and the shell.
|
|
56
|
+
*/
|
|
57
|
+
export declare function applySystemDefaultTheme(systemDefault: string | null | undefined): void;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the user's preferred theme, persists it to localStorage, and applies
|
|
60
|
+
* it immediately. Pass `null` to revert to OS preference. W4 P2-1: storage
|
|
61
|
+
* writes are best-effort — a disabled-storage environment still applies the
|
|
62
|
+
* theme for the current page.
|
|
63
|
+
*/
|
|
64
|
+
export declare function setTheme(theme: Theme | null): void;
|