@simpleplatform/sdk 3.1.1 → 4.0.1
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/README.md +5 -28
- package/dist/space/browser-transport.d.ts +2 -2
- package/dist/space/browser-transport.js +0 -3
- package/dist/space/core.d.ts +4 -5
- package/dist/space/core.js +3 -3
- package/dist/space/index.d.ts +3 -3
- package/dist/space/index.js +2 -4
- package/dist/space/tabs.d.ts +0 -3
- package/dist/space/tabs.js +0 -6
- package/dist/space/ui.d.ts +1 -17
- package/dist/space/ui.js +2 -38
- package/package.json +1 -1
- package/dist/space/status.d.ts +0 -2
- package/dist/space/status.js +0 -7
package/README.md
CHANGED
|
@@ -196,8 +196,8 @@ public APIs. When a Space needs fully custom presentation, keep using the
|
|
|
196
196
|
record handle's `snapshot()`, `update()`, and `submit()` commands.
|
|
197
197
|
|
|
198
198
|
For collections, the UI Kit also provides database-backed `ListView`,
|
|
199
|
-
`DataGrid`, and `Board`. Their private bridge
|
|
200
|
-
|
|
199
|
+
`DataGrid`, and `Board`. Their private bridge first shipped in SDK `4.0.0`, and
|
|
200
|
+
the UI Kit requires `^4.0.0`. Inbox remains platform-only;
|
|
201
201
|
standalone filter-builder components are private. See the
|
|
202
202
|
[UI Kit collection contracts](../space-ui/README.md#managed-database-backed-views).
|
|
203
203
|
|
|
@@ -227,24 +227,6 @@ state without choosing UI; call `simple.ui.toast.show()` when the Space should
|
|
|
227
227
|
also show a platform toast. `RecordForm` continues to display detailed field
|
|
228
228
|
and form messages inline.
|
|
229
229
|
|
|
230
|
-
A Record Space can also show one status beside the record title:
|
|
231
|
-
|
|
232
|
-
```ts
|
|
233
|
-
simple.ui.header.status.set({
|
|
234
|
-
description: 'A reviewer needs to check this record.',
|
|
235
|
-
label: 'Needs review',
|
|
236
|
-
tone: 'warning',
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
simple.ui.header.status.set(null) // Clear the status
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
The label is non-blank and limited to 80 characters. Tones are `neutral`,
|
|
243
|
-
`info`, `success`, `warning`, and `danger`; the optional description is for
|
|
244
|
-
screen readers. Hosts that do not negotiate `headerStatus` reject this call
|
|
245
|
-
with an `unavailable` error. Header status is negotiated separately, so an
|
|
246
|
-
older host can continue to support header actions without supporting status.
|
|
247
|
-
|
|
248
230
|
### Show a platform toast
|
|
249
231
|
|
|
250
232
|
Any Space can show feedback with Simple's existing toast presenter and theme:
|
|
@@ -277,7 +259,7 @@ const { selectedTabId } = await simple.ui.tabs.set({
|
|
|
277
259
|
},
|
|
278
260
|
tabs: [
|
|
279
261
|
{ icon: 'layout-dashboard', id: 'overview', title: 'Overview' },
|
|
280
|
-
{ badge: 3,
|
|
262
|
+
{ badge: 3, icon: 'message-square', id: 'messages', title: 'Messages' },
|
|
281
263
|
{ badge: 'New', icon: 'file-text', id: 'documents', title: 'Documents' },
|
|
282
264
|
],
|
|
283
265
|
})
|
|
@@ -292,13 +274,8 @@ empty list clears the current declaration and resolves with
|
|
|
292
274
|
Each tab requires an `id` (1–64 characters matching `^[a-z0-9][a-z0-9_-]{0,63}$`)
|
|
293
275
|
and a non-blank `title` (up to 80 characters), with optional `default: true`,
|
|
294
276
|
optional kebab-case Lucide `icon`, and optional `badge` (non-blank text up to 20
|
|
295
|
-
characters or a finite non-negative integer).
|
|
296
|
-
|
|
297
|
-
keeps its neutral appearance. At most one tab may set `default: true`; if none
|
|
298
|
-
is specified, the first tab defaults to active.
|
|
299
|
-
|
|
300
|
-
Older hosts that do not recognize `badgeTone` ignore it and display the count
|
|
301
|
-
with the neutral appearance.
|
|
277
|
+
characters or a finite non-negative integer). At most one tab may set `default: true`;
|
|
278
|
+
if none is specified, the first tab defaults to active.
|
|
302
279
|
|
|
303
280
|
The host negotiates `protocols.tabs: [1]` and owns selection and URL state.
|
|
304
281
|
Registration uses `ui.tabs.set`, which assigns a `registrationRequestId` and
|
|
@@ -3,7 +3,7 @@ import type { SpaceNavigationTransport } from './navigation.js';
|
|
|
3
3
|
import type { SpaceTransport } from './protocol.js';
|
|
4
4
|
import type { RecordFormCapabilities } from './record-form.js';
|
|
5
5
|
import type { SpaceThemeSnapshot } from './theme.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SpaceHeaderTransport, SpaceTabsTransport, SpaceToastTransport } from './ui.js';
|
|
7
7
|
export interface MessagePortLike {
|
|
8
8
|
close?: () => void;
|
|
9
9
|
onmessage: null | ((event: {
|
|
@@ -12,7 +12,7 @@ export interface MessagePortLike {
|
|
|
12
12
|
postMessage: (message: unknown, transfer?: ArrayBuffer[]) => void;
|
|
13
13
|
start?: () => void;
|
|
14
14
|
}
|
|
15
|
-
export interface BrowserSpaceTransport extends SpaceDataTransport,
|
|
15
|
+
export interface BrowserSpaceTransport extends SpaceDataTransport, SpaceHeaderTransport, SpaceNavigationTransport, SpaceTabsTransport, SpaceToastTransport, SpaceTransport {
|
|
16
16
|
capabilities: RecordFormCapabilities;
|
|
17
17
|
subscribeFormModel: (listener: (form: unknown) => void) => () => void;
|
|
18
18
|
}
|
|
@@ -264,9 +264,6 @@ export function createMessagePortTransport(port, targetOrigin, onThemeChanged, f
|
|
|
264
264
|
type: 'SPACE_HEADER_ACTIONS_SET',
|
|
265
265
|
});
|
|
266
266
|
},
|
|
267
|
-
setStatus: (status) => {
|
|
268
|
-
port.postMessage({ status, type: 'SPACE_HEADER_STATUS_SET' });
|
|
269
|
-
},
|
|
270
267
|
showToast: (options) => {
|
|
271
268
|
port.postMessage({ options, type: 'SPACE_TOAST_SHOW' });
|
|
272
269
|
},
|
package/dist/space/core.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { SpaceTransport } from './protocol.js';
|
|
|
6
6
|
import type { RecordFormCapabilities, RecordFormModelTransport, UiRuntimeDescriptor } from './record-form.js';
|
|
7
7
|
import type { SimpleRecordsClient } from './record.js';
|
|
8
8
|
import type { SimpleTasksClient } from './tasks.js';
|
|
9
|
-
import type { SimpleHeaderClient, SimpleTabsClient, SimpleToastClient,
|
|
9
|
+
import type { SimpleHeaderClient, SimpleTabsClient, SimpleToastClient, SpaceHeaderTransport, SpaceTabsTransport, SpaceToastTransport } from './ui.js';
|
|
10
10
|
export type { ActionFailedDetails, ActionRunOptions, SimpleActionsClient, } from './actions.js';
|
|
11
11
|
export type { DocumentStageInput, DocumentStageResult, SimpleDocumentsClient, StagedDocumentHandle, } from './documents.js';
|
|
12
12
|
export type { NavigationOpenOptions, NavigationTarget, SimpleNavigationClient, SpaceNavigationTransport, } from './navigation.js';
|
|
@@ -17,8 +17,8 @@ export type { ManagedRecordFormField, ManagedRecordFormModel, RecordFormCapabili
|
|
|
17
17
|
export { RECORDS_PROTOCOL_VERSION } from './record.js';
|
|
18
18
|
export type { CurrentRecordRequest, CurrentRecordResult, OpenRecordOptions, RecordErrorSnapshot, RecordFieldSnapshot, RecordFormError, RecordHandle, RecordOpenRequest, RecordOpenResult, RecordReference, RecordSnapshot, RecordSubmitResult, RecordUpdateResult, SimpleRecordsClient, } from './record.js';
|
|
19
19
|
export type { JsonObject, JsonValue, SimpleTasksClient, TaskCreateInput, TaskCreateResult, TaskReplyInput, TaskReplyResult, TaskStatus, } from './tasks.js';
|
|
20
|
-
export { DEFAULT_TABS_TIMEOUT_MS, HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
21
|
-
export type { HeaderAction, HeaderActionType, SetTabsOptions, SimpleHeaderActionsClient, SimpleHeaderClient,
|
|
20
|
+
export { DEFAULT_TABS_TIMEOUT_MS, HEADER_ACTIONS_PROTOCOL_VERSION, LUCIDE_ICON_NAME, TAB_ID, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION, validateTabs } from './ui.js';
|
|
21
|
+
export type { HeaderAction, HeaderActionType, SetTabsOptions, SimpleHeaderActionsClient, SimpleHeaderClient, SimpleTabsClient, SimpleToastClient, SpaceTab, SpaceTabsSelectionEvent, SpaceTabsTransport, SpaceToastOptions, SpaceToastVariant, TabsSelectPayload, TabsSelectRequest, TabsSelectResult, TabsSetPayload, TabsSetRequest, TabsSetResult, WireTab, } from './ui.js';
|
|
22
22
|
export type SpaceContext = {
|
|
23
23
|
applicationId: string;
|
|
24
24
|
kind: 'record';
|
|
@@ -69,7 +69,6 @@ export interface SimpleClientOptions {
|
|
|
69
69
|
formModelTransport?: RecordFormModelTransport;
|
|
70
70
|
hostOrigin?: string;
|
|
71
71
|
headerTransport?: SpaceHeaderTransport;
|
|
72
|
-
headerStatusTransport?: SpaceHeaderStatusTransport;
|
|
73
72
|
navigationTransport?: SpaceNavigationTransport;
|
|
74
73
|
nextRequestId?: () => string;
|
|
75
74
|
/** Present only when the host negotiated the records protocol. */
|
|
@@ -81,5 +80,5 @@ export interface SimpleClientOptions {
|
|
|
81
80
|
transport?: SpaceTransport;
|
|
82
81
|
}
|
|
83
82
|
/** Composes Space capabilities around the host transports supplied by `connect`. */
|
|
84
|
-
export declare function createSimpleClient({ actionTransport, capabilities, context, dataTransport, documentTransport, formModelTransport,
|
|
83
|
+
export declare function createSimpleClient({ actionTransport, capabilities, context, dataTransport, documentTransport, formModelTransport, headerTransport, hostOrigin, navigationTransport, nextRequestId, recordsTransport, runtime, tabsTransport, taskTransport, toastTransport, transport, }: SimpleClientOptions): SimpleClient;
|
|
85
84
|
export declare function isSpaceContext(value: unknown): value is SpaceContext;
|
package/dist/space/core.js
CHANGED
|
@@ -8,10 +8,10 @@ import { createHeaderClient, createTabsClient, createToastClient, validateSpaceT
|
|
|
8
8
|
export { PROTOCOL_VERSION, SpaceDataError, SpaceProtocolError } from './protocol.js';
|
|
9
9
|
export { MANAGED_RECORD_FORM_PROTOCOL_VERSION } from './record-form.js';
|
|
10
10
|
export { RECORDS_PROTOCOL_VERSION } from './record.js';
|
|
11
|
-
export { DEFAULT_TABS_TIMEOUT_MS, HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
11
|
+
export { DEFAULT_TABS_TIMEOUT_MS, HEADER_ACTIONS_PROTOCOL_VERSION, LUCIDE_ICON_NAME, TAB_ID, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION, validateTabs } from './ui.js';
|
|
12
12
|
const MANAGED_UI_SYMBOL = Symbol.for('@simpleplatform/sdk/space/managed-ui/v1');
|
|
13
13
|
/** Composes Space capabilities around the host transports supplied by `connect`. */
|
|
14
|
-
export function createSimpleClient({ actionTransport, capabilities, context = { kind: 'standalone' }, dataTransport, documentTransport, formModelTransport,
|
|
14
|
+
export function createSimpleClient({ actionTransport, capabilities, context = { kind: 'standalone' }, dataTransport, documentTransport, formModelTransport, headerTransport, hostOrigin, navigationTransport, nextRequestId = createRequestId, recordsTransport, runtime, tabsTransport, taskTransport, toastTransport, transport, }) {
|
|
15
15
|
const immutableContext = deepFreeze(structuredClone(context));
|
|
16
16
|
const recordFormCapabilities = capabilities && toastTransport
|
|
17
17
|
? {
|
|
@@ -64,7 +64,7 @@ export function createSimpleClient({ actionTransport, capabilities, context = {
|
|
|
64
64
|
records,
|
|
65
65
|
tasks: createTasksClient(taskTransport, nextRequestId),
|
|
66
66
|
ui: {
|
|
67
|
-
header: createHeaderClient(immutableContext.kind === 'record', headerTransport
|
|
67
|
+
header: createHeaderClient(immutableContext.kind === 'record', headerTransport),
|
|
68
68
|
tabs: createTabsClient(immutableContext.kind === 'record', tabsTransport, nextRequestId),
|
|
69
69
|
toast: createToastClient(toastTransport),
|
|
70
70
|
},
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SimpleClient } from './core.js';
|
|
2
|
-
import { HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
3
|
-
export { HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
4
|
-
export type { ActionFailedDetails, ActionRunOptions, DocumentStageInput, DocumentStageResult, GraphQLVariables, HeaderAction, HeaderActionType, JsonObject, JsonValue, NavigationOpenOptions, NavigationTarget, OpenRecordOptions, RecordErrorSnapshot, RecordFieldSnapshot, RecordFormError, RecordHandle, RecordOpenRequest, RecordOpenResult, RecordReference, RecordSnapshot, RecordSubmitResult, RecordUpdateResult, SetTabsOptions, SimpleActionsClient, SimpleClient, SimpleDataClient, SimpleDocumentsClient, SimpleHeaderActionsClient, SimpleHeaderClient,
|
|
2
|
+
import { HEADER_ACTIONS_PROTOCOL_VERSION, PROTOCOL_VERSION, RECORDS_PROTOCOL_VERSION, SpaceDataError, SpaceProtocolError, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION } from './core.js';
|
|
3
|
+
export { HEADER_ACTIONS_PROTOCOL_VERSION, PROTOCOL_VERSION, RECORDS_PROTOCOL_VERSION, SpaceDataError, SpaceProtocolError, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION };
|
|
4
|
+
export type { ActionFailedDetails, ActionRunOptions, DocumentStageInput, DocumentStageResult, GraphQLVariables, HeaderAction, HeaderActionType, JsonObject, JsonValue, NavigationOpenOptions, NavigationTarget, OpenRecordOptions, RecordErrorSnapshot, RecordFieldSnapshot, RecordFormError, RecordHandle, RecordOpenRequest, RecordOpenResult, RecordReference, RecordSnapshot, RecordSubmitResult, RecordUpdateResult, SetTabsOptions, SimpleActionsClient, SimpleClient, SimpleDataClient, SimpleDocumentsClient, SimpleHeaderActionsClient, SimpleHeaderClient, SimpleNavigationClient, SimpleRecordsClient, SimpleTabsClient, SimpleTasksClient, SimpleToastClient, SpaceContext, SpaceDataErrorPayload, SpaceNavigationTransport, SpaceProtocolErrorPayload, SpaceTab, SpaceTabsSelectionEvent, SpaceTabsTransport, SpaceToastOptions, SpaceToastVariant, StagedDocumentHandle, TaskCreateInput, TaskCreateResult, TaskReplyInput, TaskReplyResult, TaskStatus, } from './core.js';
|
|
5
5
|
export interface ConnectOptions {
|
|
6
6
|
targetOrigin: string;
|
|
7
7
|
}
|
package/dist/space/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createMessagePortTransport } from './browser-transport.js';
|
|
2
|
-
import { createSimpleClient, HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
2
|
+
import { createSimpleClient, HEADER_ACTIONS_PROTOCOL_VERSION, isSpaceContext, MANAGED_RECORD_FORM_PROTOCOL_VERSION, PROTOCOL_VERSION, RECORDS_PROTOCOL_VERSION, SpaceDataError, SpaceProtocolError, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION, } from './core.js';
|
|
3
3
|
import { isObjectRecord } from './protocol.js';
|
|
4
4
|
import { applyThemeSnapshot, parseThemeSnapshot, THEME_PROTOCOL_VERSION } from './theme.js';
|
|
5
|
-
export { HEADER_ACTIONS_PROTOCOL_VERSION,
|
|
5
|
+
export { HEADER_ACTIONS_PROTOCOL_VERSION, PROTOCOL_VERSION, RECORDS_PROTOCOL_VERSION, SpaceDataError, SpaceProtocolError, TABS_PROTOCOL_VERSION, TOAST_PROTOCOL_VERSION };
|
|
6
6
|
const connections = new WeakMap();
|
|
7
7
|
/** Connects this Space to its host using the explicitly supplied host origin. */
|
|
8
8
|
export function connect({ targetOrigin }) {
|
|
@@ -76,7 +76,6 @@ export function connect({ targetOrigin }) {
|
|
|
76
76
|
dataTransport: transport,
|
|
77
77
|
documentTransport: protocols?.document === PROTOCOL_VERSION ? transport : undefined,
|
|
78
78
|
formModelTransport: protocols?.form === MANAGED_RECORD_FORM_PROTOCOL_VERSION || protocols?.form === 2 ? transport : undefined,
|
|
79
|
-
headerStatusTransport: hasRecord && protocols?.headerStatus === HEADER_STATUS_PROTOCOL_VERSION ? transport : undefined,
|
|
80
79
|
headerTransport: hasRecord && protocols?.header === HEADER_ACTIONS_PROTOCOL_VERSION ? transport : undefined,
|
|
81
80
|
hostOrigin: targetOrigin,
|
|
82
81
|
navigationTransport: transport,
|
|
@@ -95,7 +94,6 @@ export function connect({ targetOrigin }) {
|
|
|
95
94
|
document: [PROTOCOL_VERSION],
|
|
96
95
|
form: [MANAGED_RECORD_FORM_PROTOCOL_VERSION, 2],
|
|
97
96
|
header: [HEADER_ACTIONS_PROTOCOL_VERSION],
|
|
98
|
-
headerStatus: [HEADER_STATUS_PROTOCOL_VERSION],
|
|
99
97
|
record: [PROTOCOL_VERSION],
|
|
100
98
|
records: [RECORDS_PROTOCOL_VERSION],
|
|
101
99
|
tabs: [TABS_PROTOCOL_VERSION],
|
package/dist/space/tabs.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { ProtocolRequest, SpaceTransport } from './protocol.js';
|
|
2
|
-
import type { SpaceStatusTone } from './status.js';
|
|
3
2
|
export declare const TABS_PROTOCOL_VERSION: 1;
|
|
4
3
|
export declare const DEFAULT_TABS_TIMEOUT_MS = 10000;
|
|
5
4
|
export declare const LUCIDE_ICON_NAME: RegExp;
|
|
6
5
|
export declare const TAB_ID: RegExp;
|
|
7
6
|
export interface SpaceTab {
|
|
8
7
|
badge?: number | string;
|
|
9
|
-
badgeTone?: SpaceStatusTone;
|
|
10
8
|
default?: boolean;
|
|
11
9
|
icon?: string;
|
|
12
10
|
id: string;
|
|
@@ -32,7 +30,6 @@ export interface SpaceTabsTransport extends SpaceTransport {
|
|
|
32
30
|
}
|
|
33
31
|
export interface WireTab {
|
|
34
32
|
badge?: number | string;
|
|
35
|
-
badgeTone?: SpaceStatusTone;
|
|
36
33
|
default?: true;
|
|
37
34
|
icon?: string;
|
|
38
35
|
id: string;
|
package/dist/space/tabs.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { invalidRequest, invalidResponse, isNonBlankString, isNonNegativeInteger, isObjectRecord, PROTOCOL_VERSION, readResponse, requestWithin, SpaceProtocolError, } from './protocol.js';
|
|
2
|
-
import { SPACE_STATUS_TONES } from './status.js';
|
|
3
2
|
export const TABS_PROTOCOL_VERSION = 1;
|
|
4
3
|
export const DEFAULT_TABS_TIMEOUT_MS = 10000;
|
|
5
4
|
export const LUCIDE_ICON_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
@@ -50,10 +49,6 @@ export function validateTabs(options) {
|
|
|
50
49
|
throw invalidRequest(`Tab "${tab.id}" badge must be a non-empty string or a non-negative integer.`);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
|
-
if (tab.badgeTone !== undefined
|
|
54
|
-
&& (typeof tab.badgeTone !== 'string' || !SPACE_STATUS_TONES.includes(tab.badgeTone))) {
|
|
55
|
-
throw invalidRequest(`Tab "${tab.id}" badgeTone must be one of: ${SPACE_STATUS_TONES.join(', ')}.`);
|
|
56
|
-
}
|
|
57
52
|
}
|
|
58
53
|
if (defaultCount > 1)
|
|
59
54
|
throw invalidRequest('Only one tab may be marked as default.');
|
|
@@ -61,7 +56,6 @@ export function validateTabs(options) {
|
|
|
61
56
|
const isDefault = Boolean(tab.default || (defaultCount === 0 && index === 0));
|
|
62
57
|
return {
|
|
63
58
|
...(tab.badge !== undefined ? { badge: tab.badge } : {}),
|
|
64
|
-
...(tab.badgeTone !== undefined ? { badgeTone: tab.badgeTone } : {}),
|
|
65
59
|
...(isDefault ? { default: true } : {}),
|
|
66
60
|
...(tab.icon !== undefined ? { icon: tab.icon } : {}),
|
|
67
61
|
id: tab.id,
|
package/dist/space/ui.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { SpaceStatusTone } from './status.js';
|
|
2
1
|
export declare const HEADER_ACTIONS_PROTOCOL_VERSION: 1;
|
|
3
|
-
export declare const HEADER_STATUS_PROTOCOL_VERSION: 1;
|
|
4
2
|
export declare const TOAST_PROTOCOL_VERSION: 1;
|
|
5
|
-
export type { SpaceStatusTone } from './status.js';
|
|
6
3
|
export { createTabsClient, DEFAULT_TABS_TIMEOUT_MS, LUCIDE_ICON_NAME, TAB_ID, TABS_PROTOCOL_VERSION, validateTabs, } from './tabs.js';
|
|
7
4
|
export type { SetTabsOptions, SimpleTabsClient, SpaceTab, SpaceTabsSelectionEvent, SpaceTabsTransport, TabsSelectPayload, TabsSelectRequest, TabsSelectResult, TabsSetPayload, TabsSetRequest, TabsSetResult, WireTab, } from './tabs.js';
|
|
8
5
|
export type HeaderActionType = 'destructive' | 'outline' | 'primary' | 'secondary';
|
|
@@ -24,24 +21,12 @@ export interface HeaderAction {
|
|
|
24
21
|
export interface SimpleHeaderActionsClient {
|
|
25
22
|
set: (actions: readonly HeaderAction[]) => void;
|
|
26
23
|
}
|
|
27
|
-
export interface SpaceHeaderStatus {
|
|
28
|
-
description?: string;
|
|
29
|
-
label: string;
|
|
30
|
-
tone: SpaceStatusTone;
|
|
31
|
-
}
|
|
32
|
-
export interface SimpleHeaderStatusClient {
|
|
33
|
-
set: (status: SpaceHeaderStatus | null) => void;
|
|
34
|
-
}
|
|
35
24
|
export interface SimpleHeaderClient {
|
|
36
25
|
actions: SimpleHeaderActionsClient;
|
|
37
|
-
status: SimpleHeaderStatusClient;
|
|
38
26
|
}
|
|
39
27
|
export interface SpaceHeaderTransport {
|
|
40
28
|
setActions: (actions: readonly HeaderAction[]) => void;
|
|
41
29
|
}
|
|
42
|
-
export interface SpaceHeaderStatusTransport {
|
|
43
|
-
setStatus: (status: SpaceHeaderStatus | null) => void;
|
|
44
|
-
}
|
|
45
30
|
export type SpaceToastVariant = 'default' | 'destructive';
|
|
46
31
|
export type SpaceToastOptions = {
|
|
47
32
|
variant?: SpaceToastVariant;
|
|
@@ -62,6 +47,5 @@ export declare function validateHeaderActions(actions: readonly HeaderAction[]):
|
|
|
62
47
|
export declare const MAX_TOAST_TITLE_LENGTH = 160;
|
|
63
48
|
export declare const MAX_TOAST_DESCRIPTION_LENGTH = 1000;
|
|
64
49
|
export declare function validateSpaceToastOptions(options: SpaceToastOptions): SpaceToastOptions;
|
|
65
|
-
export declare function createHeaderClient(isRecordSpace: boolean, headerTransport?: SpaceHeaderTransport
|
|
66
|
-
export declare function validateHeaderStatus(status: SpaceHeaderStatus | null): SpaceHeaderStatus | null;
|
|
50
|
+
export declare function createHeaderClient(isRecordSpace: boolean, headerTransport?: SpaceHeaderTransport): SimpleHeaderClient;
|
|
67
51
|
export declare function createToastClient(toastTransport?: SpaceToastTransport): SimpleToastClient;
|
package/dist/space/ui.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SPACE_STATUS_TONES } from './status.js';
|
|
1
|
+
import { SpaceProtocolError } from './protocol.js';
|
|
3
2
|
export const HEADER_ACTIONS_PROTOCOL_VERSION = 1;
|
|
4
|
-
export const HEADER_STATUS_PROTOCOL_VERSION = 1;
|
|
5
3
|
export const TOAST_PROTOCOL_VERSION = 1;
|
|
6
4
|
export { createTabsClient, DEFAULT_TABS_TIMEOUT_MS, LUCIDE_ICON_NAME, TAB_ID, TABS_PROTOCOL_VERSION, validateTabs, } from './tabs.js';
|
|
7
5
|
export function validateHeaderActions(actions) {
|
|
@@ -53,7 +51,7 @@ export function validateSpaceToastOptions(options) {
|
|
|
53
51
|
...(candidate.variant === undefined ? {} : { variant: candidate.variant }),
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
|
-
export function createHeaderClient(isRecordSpace, headerTransport
|
|
54
|
+
export function createHeaderClient(isRecordSpace, headerTransport) {
|
|
57
55
|
return {
|
|
58
56
|
actions: {
|
|
59
57
|
set(actions) {
|
|
@@ -72,40 +70,6 @@ export function createHeaderClient(isRecordSpace, headerTransport, headerStatusT
|
|
|
72
70
|
headerTransport.setActions(validateHeaderActions(actions));
|
|
73
71
|
},
|
|
74
72
|
},
|
|
75
|
-
status: {
|
|
76
|
-
set(status) {
|
|
77
|
-
if (!isRecordSpace) {
|
|
78
|
-
throw new SpaceProtocolError({
|
|
79
|
-
code: 'unavailable',
|
|
80
|
-
message: 'Header status is available only when this Space is configured as a record view.',
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (!headerStatusTransport) {
|
|
84
|
-
throw new SpaceProtocolError({
|
|
85
|
-
code: 'unavailable',
|
|
86
|
-
message: 'The header-status bridge is unavailable for this record Space.',
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
headerStatusTransport.setStatus(validateHeaderStatus(status));
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function validateHeaderStatus(status) {
|
|
95
|
-
if (status === null)
|
|
96
|
-
return null;
|
|
97
|
-
if (!isObjectRecord(status))
|
|
98
|
-
throw invalidRequest('Header status must be an object or null.');
|
|
99
|
-
if (typeof status.label !== 'string' || !status.label.trim() || status.label.length > 80)
|
|
100
|
-
throw invalidRequest('Header status label must be a non-empty string of at most 80 characters.');
|
|
101
|
-
if (typeof status.tone !== 'string' || !SPACE_STATUS_TONES.includes(status.tone))
|
|
102
|
-
throw invalidRequest(`Header status tone must be one of: ${SPACE_STATUS_TONES.join(', ')}.`);
|
|
103
|
-
if (status.description !== undefined && typeof status.description !== 'string')
|
|
104
|
-
throw invalidRequest('Header status description must be a string.');
|
|
105
|
-
return {
|
|
106
|
-
...(status.description === undefined ? {} : { description: status.description }),
|
|
107
|
-
label: status.label,
|
|
108
|
-
tone: status.tone,
|
|
109
73
|
};
|
|
110
74
|
}
|
|
111
75
|
export function createToastClient(toastTransport) {
|
package/package.json
CHANGED
package/dist/space/status.d.ts
DELETED