@simpleplatform/ui-kit 0.0.0-stage → 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.
Files changed (41) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +488 -2
  3. package/custom-elements.json +24 -0
  4. package/dist/contracts/index.d.ts +2 -0
  5. package/dist/contracts/index.d.ts.map +1 -0
  6. package/dist/contracts/index.js +1 -0
  7. package/dist/contracts/status-badge.d.ts +4 -0
  8. package/dist/contracts/status-badge.d.ts.map +1 -0
  9. package/dist/contracts/status-badge.js +8 -0
  10. package/dist/elements/index.d.ts +2 -0
  11. package/dist/elements/index.d.ts.map +1 -0
  12. package/dist/elements/index.js +1 -0
  13. package/dist/elements/status-badge.d.ts +19 -0
  14. package/dist/elements/status-badge.d.ts.map +1 -0
  15. package/dist/elements/status-badge.js +123 -0
  16. package/dist/index.d.ts +3 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +2 -0
  19. package/dist/react/index.d.ts +4 -0
  20. package/dist/react/index.d.ts.map +1 -0
  21. package/dist/react/index.js +3 -0
  22. package/dist/react/mount-boundary.d.ts +13 -0
  23. package/dist/react/mount-boundary.d.ts.map +1 -0
  24. package/dist/react/mount-boundary.js +70 -0
  25. package/dist/react/record-activity.d.ts +11 -0
  26. package/dist/react/record-activity.d.ts.map +1 -0
  27. package/dist/react/record-activity.js +144 -0
  28. package/dist/react/record-bridge.d.ts +34 -0
  29. package/dist/react/record-bridge.d.ts.map +1 -0
  30. package/dist/react/record-bridge.js +8 -0
  31. package/dist/react/record-form.d.ts +11 -0
  32. package/dist/react/record-form.d.ts.map +1 -0
  33. package/dist/react/record-form.js +112 -0
  34. package/dist/react/status-badge.d.ts +15 -0
  35. package/dist/react/status-badge.d.ts.map +1 -0
  36. package/dist/react/status-badge.js +6 -0
  37. package/dist/runtime.d.ts +22 -0
  38. package/dist/runtime.d.ts.map +1 -0
  39. package/dist/runtime.js +46 -0
  40. package/package.json +59 -3
  41. package/theme.css +56 -0
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/webcomponents/custom-elements-manifest/master/schema.json",
3
+ "schemaVersion": "1.0.0",
4
+ "readme": "README.md",
5
+ "modules": [
6
+ {
7
+ "kind": "javascript-module",
8
+ "path": "dist/elements/status-badge.js",
9
+ "declarations": [
10
+ {
11
+ "kind": "class",
12
+ "name": "SimpleStatusBadge",
13
+ "tagName": "simple-status-badge",
14
+ "customElement": true,
15
+ "members": [
16
+ { "kind": "field", "name": "description", "type": { "text": "string" } },
17
+ { "kind": "field", "name": "label", "type": { "text": "string" } },
18
+ { "kind": "field", "name": "tone", "type": { "text": "SimpleStatusBadgeTone" } }
19
+ ]
20
+ }
21
+ ]
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,2 @@
1
+ export { SIMPLE_STATUS_BADGE_TONES, type SimpleStatusBadgeTone, } from './status-badge.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export { SIMPLE_STATUS_BADGE_TONES, } from './status-badge.js';
@@ -0,0 +1,4 @@
1
+ /** The semantic state categories supported by the public StatusBadge contract. */
2
+ export declare const SIMPLE_STATUS_BADGE_TONES: readonly ["neutral", "info", "success", "warning", "danger"];
3
+ export type SimpleStatusBadgeTone = typeof SIMPLE_STATUS_BADGE_TONES[number];
4
+ //# sourceMappingURL=status-badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-badge.d.ts","sourceRoot":"","sources":["../../src/contracts/status-badge.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,8DAM5B,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ /** The semantic state categories supported by the public StatusBadge contract. */
2
+ export const SIMPLE_STATUS_BADGE_TONES = [
3
+ 'neutral',
4
+ 'info',
5
+ 'success',
6
+ 'warning',
7
+ 'danger',
8
+ ];
@@ -0,0 +1,2 @@
1
+ export { defineSimpleStatusBadge, SimpleStatusBadge } from './status-badge.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export { defineSimpleStatusBadge, SimpleStatusBadge } from './status-badge.js';
@@ -0,0 +1,19 @@
1
+ import type { SimpleStatusBadgeTone } from '../contracts/status-badge.js';
2
+ declare const HTMLElementBase: typeof HTMLElement;
3
+ /** A semantic state label for platform and Space surfaces. */
4
+ export declare class SimpleStatusBadge extends HTMLElementBase {
5
+ static get observedAttributes(): string[];
6
+ get description(): string;
7
+ set description(value: string);
8
+ get label(): string;
9
+ set label(value: string);
10
+ get tone(): SimpleStatusBadgeTone;
11
+ set tone(value: SimpleStatusBadgeTone);
12
+ constructor();
13
+ attributeChangedCallback(): void;
14
+ connectedCallback(): void;
15
+ private render;
16
+ }
17
+ export declare function defineSimpleStatusBadge(): void;
18
+ export {};
19
+ //# sourceMappingURL=status-badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-badge.d.ts","sourceRoot":"","sources":["../../src/elements/status-badge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAgEzE,QAAA,MAAM,eAAe,EAAE,OAAO,WAAsE,CAAA;AAEpG,8DAA8D;AAC9D,qBAAa,iBAAkB,SAAQ,eAAe;IACpD,MAAM,KAAK,kBAAkB,aAE5B;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,EAE5B;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED,IAAI,IAAI,IAAI,qBAAqB,CAGhC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,qBAAqB,EAEpC;;IAOD,wBAAwB,IAAI,IAAI;IAIhC,iBAAiB,IAAI,IAAI;IAIzB,OAAO,CAAC,MAAM;CAqBf;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAK9C"}
@@ -0,0 +1,123 @@
1
+ import { SIMPLE_STATUS_BADGE_TONES } from '../contracts/status-badge.js';
2
+ const STATUS_BADGE_TAG_NAME = 'simple-status-badge';
3
+ const STATUS_BADGE_STYLES = `
4
+ :host {
5
+ display: inline-block;
6
+ font-family: var(--simple-status-badge-font-family);
7
+ }
8
+
9
+ [part="base"] {
10
+ align-items: center;
11
+ background: var(--simple-status-badge-neutral-background);
12
+ border: 1px solid var(--simple-status-badge-neutral-border);
13
+ border-radius: var(--simple-status-badge-radius);
14
+ box-sizing: border-box;
15
+ color: var(--simple-status-badge-neutral-foreground);
16
+ display: inline-flex;
17
+ font-size: var(--simple-status-badge-font-size);
18
+ font-weight: var(--simple-status-badge-font-weight);
19
+ line-height: var(--simple-status-badge-line-height);
20
+ max-width: 100%;
21
+ min-height: var(--simple-status-badge-min-height);
22
+ overflow-wrap: anywhere;
23
+ padding: 0 var(--simple-status-badge-padding-inline);
24
+ }
25
+
26
+ [part="base"][data-tone="info"] {
27
+ background: var(--simple-status-badge-info-background);
28
+ border-color: var(--simple-status-badge-info-border);
29
+ color: var(--simple-status-badge-info-foreground);
30
+ }
31
+
32
+ [part="base"][data-tone="success"] {
33
+ background: var(--simple-status-badge-success-background);
34
+ border-color: var(--simple-status-badge-success-border);
35
+ color: var(--simple-status-badge-success-foreground);
36
+ }
37
+
38
+ [part="base"][data-tone="warning"] {
39
+ background: var(--simple-status-badge-warning-background);
40
+ border-color: var(--simple-status-badge-warning-border);
41
+ color: var(--simple-status-badge-warning-foreground);
42
+ }
43
+
44
+ [part="base"][data-tone="danger"] {
45
+ background: var(--simple-status-badge-danger-background);
46
+ border-color: var(--simple-status-badge-danger-border);
47
+ color: var(--simple-status-badge-danger-foreground);
48
+ }
49
+
50
+ [part="description"] {
51
+ clip: rect(0 0 0 0);
52
+ clip-path: inset(50%);
53
+ height: 1px;
54
+ overflow: hidden;
55
+ position: absolute;
56
+ white-space: nowrap;
57
+ width: 1px;
58
+ }
59
+ `;
60
+ const HTMLElementBase = globalThis.HTMLElement ?? class {
61
+ };
62
+ /** A semantic state label for platform and Space surfaces. */
63
+ export class SimpleStatusBadge extends HTMLElementBase {
64
+ static get observedAttributes() {
65
+ return ['description', 'label', 'tone'];
66
+ }
67
+ get description() {
68
+ return this.getAttribute('description') ?? '';
69
+ }
70
+ set description(value) {
71
+ this.setAttribute('description', value);
72
+ }
73
+ get label() {
74
+ return this.getAttribute('label') ?? '';
75
+ }
76
+ set label(value) {
77
+ this.setAttribute('label', value);
78
+ }
79
+ get tone() {
80
+ const tone = this.getAttribute('tone');
81
+ return isStatusBadgeTone(tone) ? tone : 'neutral';
82
+ }
83
+ set tone(value) {
84
+ this.setAttribute('tone', value);
85
+ }
86
+ constructor() {
87
+ super();
88
+ this.attachShadow({ mode: 'open' });
89
+ }
90
+ attributeChangedCallback() {
91
+ this.render();
92
+ }
93
+ connectedCallback() {
94
+ this.render();
95
+ }
96
+ render() {
97
+ const style = document.createElement('style');
98
+ style.textContent = STATUS_BADGE_STYLES;
99
+ const badge = document.createElement('span');
100
+ badge.dataset.tone = this.tone;
101
+ badge.setAttribute('part', 'base');
102
+ badge.textContent = this.label;
103
+ const children = [style, badge];
104
+ if (this.description) {
105
+ const description = document.createElement('span');
106
+ description.id = 'description';
107
+ description.setAttribute('part', 'description');
108
+ description.textContent = this.description;
109
+ badge.setAttribute('aria-describedby', description.id);
110
+ children.push(description);
111
+ }
112
+ this.shadowRoot?.replaceChildren(...children);
113
+ }
114
+ }
115
+ export function defineSimpleStatusBadge() {
116
+ if (typeof customElements === 'undefined' || customElements.get(STATUS_BADGE_TAG_NAME))
117
+ return;
118
+ customElements.define(STATUS_BADGE_TAG_NAME, SimpleStatusBadge);
119
+ }
120
+ function isStatusBadgeTone(value) {
121
+ return typeof value === 'string' && SIMPLE_STATUS_BADGE_TONES.includes(value);
122
+ }
123
+ defineSimpleStatusBadge();
@@ -0,0 +1,3 @@
1
+ /** Framework-neutral contracts. Import renderers from explicit subpaths. */
2
+ export * from './contracts/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,sBAAsB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /** Framework-neutral contracts. Import renderers from explicit subpaths. */
2
+ export * from './contracts/index.js';
@@ -0,0 +1,4 @@
1
+ export { RecordActivity, type RecordActivityProps } from './record-activity.js';
2
+ export { RecordForm, type RecordFormProps } from './record-form.js';
3
+ export { StatusBadge, type StatusBadgeProps } from './status-badge.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { RecordActivity } from './record-activity.js';
2
+ export { RecordForm } from './record-form.js';
3
+ export { StatusBadge } from './status-badge.js';
@@ -0,0 +1,13 @@
1
+ export interface WaitForElementMountOptions {
2
+ element: HTMLElement;
3
+ errorEventName: string;
4
+ fallbackErrorMessage: string;
5
+ onPostMountError: (error: Error) => void;
6
+ readyEventName: string;
7
+ signal: AbortSignal;
8
+ timeoutMessage: string;
9
+ timeoutMs?: number;
10
+ }
11
+ /** Watches a private custom element through readiness, later failures, or teardown. */
12
+ export declare function waitForElementMount({ element, errorEventName, fallbackErrorMessage, onPostMountError, readyEventName, signal, timeoutMessage, timeoutMs, }: WaitForElementMountOptions): Promise<() => void>;
13
+ //# sourceMappingURL=mount-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-boundary.d.ts","sourceRoot":"","sources":["../../src/react/mount-boundary.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,WAAW,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACxC,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,WAAW,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,cAAc,EACd,SAAkB,GACnB,EAAE,0BAA0B,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CA+ElD"}
@@ -0,0 +1,70 @@
1
+ /** Watches a private custom element through readiness, later failures, or teardown. */
2
+ export function waitForElementMount({ element, errorEventName, fallbackErrorMessage, onPostMountError, readyEventName, signal, timeoutMessage, timeoutMs = 15_000, }) {
3
+ return new Promise((resolve, reject) => {
4
+ let isReady = false;
5
+ let isSettled = false;
6
+ let isCleaned = false;
7
+ let timeout;
8
+ let onReady;
9
+ let onError;
10
+ let onAbort;
11
+ const cleanup = () => {
12
+ if (isCleaned)
13
+ return;
14
+ isCleaned = true;
15
+ if (timeout)
16
+ clearTimeout(timeout);
17
+ element.removeEventListener(readyEventName, onReady);
18
+ element.removeEventListener(errorEventName, onError);
19
+ signal.removeEventListener('abort', onAbort);
20
+ };
21
+ const failBeforeReady = (error) => {
22
+ if (isSettled)
23
+ return;
24
+ isSettled = true;
25
+ cleanup();
26
+ reject(error);
27
+ };
28
+ onReady = () => {
29
+ if (isSettled)
30
+ return;
31
+ isReady = true;
32
+ isSettled = true;
33
+ if (timeout)
34
+ clearTimeout(timeout);
35
+ element.removeEventListener(readyEventName, onReady);
36
+ resolve(cleanup);
37
+ };
38
+ onError = (event) => {
39
+ const detail = event.detail;
40
+ const message = typeof detail?.message === 'string' ? detail.message : fallbackErrorMessage;
41
+ const error = new Error(message);
42
+ if (isReady) {
43
+ cleanup();
44
+ onPostMountError(error);
45
+ return;
46
+ }
47
+ if (isSettled)
48
+ return;
49
+ failBeforeReady(error);
50
+ };
51
+ onAbort = () => {
52
+ if (!isSettled) {
53
+ failBeforeReady(new DOMException('Private UI mount was cancelled.', 'AbortError'));
54
+ }
55
+ else {
56
+ cleanup();
57
+ }
58
+ };
59
+ if (signal.aborted) {
60
+ failBeforeReady(new DOMException('Private UI mount was cancelled.', 'AbortError'));
61
+ return;
62
+ }
63
+ timeout = setTimeout(() => {
64
+ failBeforeReady(new Error(timeoutMessage));
65
+ }, timeoutMs);
66
+ element.addEventListener(readyEventName, onReady, { once: true });
67
+ element.addEventListener(errorEventName, onError);
68
+ signal.addEventListener('abort', onAbort, { once: true });
69
+ });
70
+ }
@@ -0,0 +1,11 @@
1
+ import type { RecordHandle } from '@simpleplatform/sdk/space';
2
+ interface RecordActivityProps {
3
+ record: RecordHandle;
4
+ }
5
+ /**
6
+ * Renders the host-owned RecordActivity without exposing its field registry or
7
+ * activity query internals as customer extension points.
8
+ */
9
+ export declare function RecordActivity({ record }: RecordActivityProps): import("react/jsx-runtime").JSX.Element;
10
+ export type { RecordActivityProps };
11
+ //# sourceMappingURL=record-activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-activity.d.ts","sourceRoot":"","sources":["../../src/react/record-activity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAO7D,UAAU,mBAAmB;IAC3B,MAAM,EAAE,YAAY,CAAA;CACrB;AAmBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE,mBAAmB,2CAE7D;AAoKD,YAAY,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,144 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { loadRuntime, RuntimeLoadError } from '../runtime.js';
4
+ import { waitForElementMount } from './mount-boundary.js';
5
+ import { getManagedRecordBridge } from './record-bridge.js';
6
+ const ACTIVITY_READY_EVENT = 'simple-record-activity-ready';
7
+ const ACTIVITY_ERROR_EVENT = 'simple-record-activity-error';
8
+ /**
9
+ * Renders the host-owned RecordActivity without exposing its field registry or
10
+ * activity query internals as customer extension points.
11
+ */
12
+ export function RecordActivity({ record }) {
13
+ return _jsx(RecordActivityInstance, { record: record }, record.id);
14
+ }
15
+ function RecordActivityInstance({ record }) {
16
+ const containerRef = useRef(null);
17
+ const elementRef = useRef(undefined);
18
+ const [state, setState] = useState({ kind: 'loading' });
19
+ const [attempt, setAttempt] = useState(0);
20
+ const bridge = getManagedRecordBridge(record);
21
+ const [metadata, setMetadata] = useState(() => bridge?.metadata);
22
+ const metadataRef = useRef(metadata);
23
+ const isErrorVisibleRef = useRef(false);
24
+ metadataRef.current = metadata;
25
+ isErrorVisibleRef.current = state.kind === 'error';
26
+ const metadataStatus = metadata === undefined
27
+ ? 'missing'
28
+ : metadata.tableId?.trim() && metadata.recordId?.trim()
29
+ ? 'ready'
30
+ : 'invalid';
31
+ useEffect(() => {
32
+ if (!bridge)
33
+ return;
34
+ setMetadata(bridge.metadata);
35
+ return bridge.subscribeMetadata(setMetadata);
36
+ }, [bridge]);
37
+ useEffect(() => {
38
+ const element = elementRef.current;
39
+ if (!element || !metadata || metadataStatus !== 'ready')
40
+ return;
41
+ element.tableId = metadata.tableId?.trim();
42
+ element.recordId = metadata.recordId?.trim();
43
+ element.fields = metadata.fields;
44
+ }, [metadata, metadataStatus]);
45
+ useEffect(() => {
46
+ if (!bridge || !bridge.applicationId) {
47
+ setState({
48
+ error: new Error('The managed record activity is unavailable for this Record Space.'),
49
+ kind: 'error',
50
+ });
51
+ return;
52
+ }
53
+ if (metadataStatus === 'missing')
54
+ return;
55
+ if (metadataStatus === 'invalid') {
56
+ const message = !metadata?.tableId?.trim()
57
+ ? 'The managed record activity is missing a table ID.'
58
+ : 'The managed record activity is missing a record ID.';
59
+ setState({ error: new Error(message), kind: 'error' });
60
+ return;
61
+ }
62
+ if (!containerRef.current) {
63
+ if (metadataStatus === 'ready' && isErrorVisibleRef.current) {
64
+ setState({ kind: 'loading' });
65
+ setAttempt(current => current + 1);
66
+ return;
67
+ }
68
+ setState({ error: new Error('The managed record activity could not initialize its mount point.'), kind: 'error' });
69
+ return;
70
+ }
71
+ let disposed = false;
72
+ let failed = false;
73
+ let element;
74
+ let disposeMount;
75
+ const mountController = new AbortController();
76
+ const mount = async () => {
77
+ try {
78
+ if (bridge.runtime)
79
+ await loadRuntime(bridge.runtime);
80
+ if (!customElements.get('simple-record-activity')) {
81
+ throw new Error('The Simple UI Runtime did not register RecordActivity.');
82
+ }
83
+ if (disposed || !containerRef.current)
84
+ return;
85
+ const latestMetadata = metadataRef.current;
86
+ const tableId = latestMetadata?.tableId?.trim();
87
+ const recordId = latestMetadata?.recordId?.trim();
88
+ if (!latestMetadata || !tableId || !recordId) {
89
+ throw new Error('The managed record activity is missing its record metadata.');
90
+ }
91
+ element = document.createElement('simple-record-activity');
92
+ element.applicationId = bridge.applicationId;
93
+ element.tableId = tableId;
94
+ element.recordId = recordId;
95
+ element.fields = latestMetadata.fields;
96
+ element.decrypt = bridge.capabilities?.decrypt;
97
+ element.graphql = bridge.graphql;
98
+ elementRef.current = element;
99
+ const ready = waitForElementMount({
100
+ element,
101
+ errorEventName: ACTIVITY_ERROR_EVENT,
102
+ fallbackErrorMessage: 'The RecordActivity could not be rendered.',
103
+ onPostMountError: (error) => {
104
+ failed = true;
105
+ if (!disposed)
106
+ setState({ error, kind: 'error' });
107
+ },
108
+ readyEventName: ACTIVITY_READY_EVENT,
109
+ signal: mountController.signal,
110
+ timeoutMessage: 'The RecordActivity did not become ready in time.',
111
+ });
112
+ containerRef.current.replaceChildren(element);
113
+ disposeMount = await ready;
114
+ if (!disposed && !failed)
115
+ setState({ kind: 'ready' });
116
+ }
117
+ catch (error) {
118
+ if (!disposed) {
119
+ const failure = error instanceof RuntimeLoadError || error instanceof Error
120
+ ? error
121
+ : new Error('The Simple UI Runtime could not be loaded.');
122
+ setState({ error: failure, kind: 'error' });
123
+ }
124
+ }
125
+ };
126
+ void mount();
127
+ return () => {
128
+ disposed = true;
129
+ mountController.abort();
130
+ disposeMount?.();
131
+ if (elementRef.current === element)
132
+ elementRef.current = undefined;
133
+ if (containerRef.current && element && containerRef.current.contains(element))
134
+ containerRef.current.replaceChildren();
135
+ };
136
+ }, [attempt, bridge, metadataStatus, record]);
137
+ if (state.kind === 'error') {
138
+ return (_jsxs("div", { role: "alert", children: [_jsx("p", { children: state.error.message }), _jsx("button", { onClick: () => {
139
+ setState({ kind: 'loading' });
140
+ setAttempt(current => current + 1);
141
+ }, type: "button", children: "Try again" })] }));
142
+ }
143
+ return (_jsx("div", { "aria-busy": state.kind === 'loading' ? 'true' : undefined, "data-simple-managed-record-activity": "", ref: containerRef }));
144
+ }
@@ -0,0 +1,34 @@
1
+ import type { RecordHandle } from '@simpleplatform/sdk/space';
2
+ import type { RuntimeDescriptor } from '../runtime.js';
3
+ interface ManagedRecordMetadata {
4
+ fields: unknown;
5
+ recordId?: string;
6
+ tableId?: string;
7
+ }
8
+ interface ManagedRecordCapabilities {
9
+ decrypt?: (request: {
10
+ appId: string;
11
+ fieldName: string;
12
+ recordId: string;
13
+ tableName: string;
14
+ }) => Promise<string>;
15
+ navigate?: (path: string) => Promise<void>;
16
+ }
17
+ interface ManagedRecordBridge {
18
+ applicationId?: string;
19
+ blurField: (fieldName: string) => Promise<void>;
20
+ capabilities?: ManagedRecordCapabilities;
21
+ focusField: (fieldName: string) => Promise<void>;
22
+ form?: unknown;
23
+ graphql: (document: string, variables?: Readonly<Record<string, unknown>>) => Promise<unknown>;
24
+ metadata?: ManagedRecordMetadata;
25
+ registerSubmitPreparation: (preparation: () => Promise<Readonly<Record<string, unknown>> | undefined>) => () => void;
26
+ runtime?: RuntimeDescriptor;
27
+ subscribe: (listener: (snapshot: unknown) => void) => () => void;
28
+ subscribeFormModel: (listener: (form: unknown) => void) => () => void;
29
+ subscribeMetadata: (listener: (metadata: ManagedRecordMetadata) => void) => () => void;
30
+ }
31
+ /** Finds the SDK-owned bridge without adding a package export or RecordHandle member. */
32
+ export declare function getManagedRecordBridge(record: RecordHandle): ManagedRecordBridge | undefined;
33
+ export {};
34
+ //# sourceMappingURL=record-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-bridge.d.ts","sourceRoot":"","sources":["../../src/react/record-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAItD,UAAU,qBAAqB;IAC7B,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,yBAAyB;IACjC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IACjH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C;AAED,UAAU,mBAAmB;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,YAAY,CAAC,EAAE,yBAAyB,CAAA;IACxC,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9F,QAAQ,CAAC,EAAE,qBAAqB,CAAA;IAChC,yBAAyB,EAAE,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,MAAM,IAAI,CAAA;IACpH,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IAChE,kBAAkB,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IACrE,iBAAiB,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;CACvF;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,mBAAmB,GAAG,SAAS,CAM5F"}
@@ -0,0 +1,8 @@
1
+ const MANAGED_RECORD_UI_SYMBOL = Symbol.for('@simpleplatform/sdk/space/managed-record-ui/v1');
2
+ /** Finds the SDK-owned bridge without adding a package export or RecordHandle member. */
3
+ export function getManagedRecordBridge(record) {
4
+ if (!record || typeof record !== 'object')
5
+ return undefined;
6
+ const bridge = record[MANAGED_RECORD_UI_SYMBOL];
7
+ return bridge && typeof bridge === 'object' ? bridge : undefined;
8
+ }
@@ -0,0 +1,11 @@
1
+ import type { RecordHandle } from '@simpleplatform/sdk/space';
2
+ interface RecordFormProps {
3
+ record: RecordHandle;
4
+ }
5
+ /**
6
+ * Renders the host-owned RecordForm without exposing its field registry or
7
+ * form model as customer extension points.
8
+ */
9
+ export declare function RecordForm({ record }: RecordFormProps): import("react/jsx-runtime").JSX.Element;
10
+ export type { RecordFormProps };
11
+ //# sourceMappingURL=record-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-form.d.ts","sourceRoot":"","sources":["../../src/react/record-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAQ7D,UAAU,eAAe;IACvB,MAAM,EAAE,YAAY,CAAA;CACrB;AAsBD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,2CAErD;AAiID,YAAY,EAAE,eAAe,EAAE,CAAA"}