@magicvr/schema-ui-renderer 0.2.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.
@@ -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;