@coolms/ui-react 0.1.0-alpha.3 → 0.1.0-alpha.31
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/CHANGELOG.md +282 -4
- package/design-tokens.lock.json +10 -6
- package/dist/components/Button.d.ts +6 -3
- package/dist/components/Call.d.ts +33 -3
- package/dist/components/Collections.d.ts +15 -6
- package/dist/components/Dialogs.d.ts +11 -3
- package/dist/components/Fields.d.ts +48 -4
- package/dist/components/FilePicker.d.ts +91 -0
- package/dist/components/FileViewer.d.ts +106 -0
- package/dist/components/Icon.d.ts +18 -1
- package/dist/components/Notification.d.ts +38 -0
- package/dist/components/PaneToolbar.d.ts +77 -0
- package/dist/components/ScreenShell.d.ts +71 -0
- package/dist/components/SectionHeader.d.ts +43 -0
- package/dist/components/SignIn.d.ts +18 -2
- package/dist/components/Splitter.d.ts +38 -0
- package/dist/components/State.d.ts +33 -0
- package/dist/components/Status.d.ts +6 -2
- package/dist/components/Structure.d.ts +22 -4
- package/dist/components/Workspace.d.ts +102 -11
- package/dist/components/internal.d.ts +2 -0
- package/dist/components/pull.d.ts +21 -0
- package/dist/index.d.ts +24 -15
- package/dist/index.js +1993 -678
- package/kit.contract.json +15 -5
- package/package.json +9 -5
- package/src/kit.css +314 -34
- package/src/tokens/coolms-tokens.css +24 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** A space the person may read, such as their Drive or a shared space. */
|
|
3
|
+
export interface FilePickerSpace {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
/** One entry of a folder, as the host lists it: a folder opens, a file can be chosen. */
|
|
8
|
+
export interface FilePickerEntry {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly kind: 'folder' | 'file';
|
|
12
|
+
readonly size?: number | null;
|
|
13
|
+
readonly mimeType?: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** One page of a folder; `next` when more follow. */
|
|
16
|
+
export interface FilePickerPage {
|
|
17
|
+
readonly entries: readonly FilePickerEntry[];
|
|
18
|
+
readonly next?: string | null;
|
|
19
|
+
}
|
|
20
|
+
/** A chosen file, with the space and folder it was chosen in, so the host needs no second lookup. */
|
|
21
|
+
export interface FilePickerChoice extends FilePickerEntry {
|
|
22
|
+
readonly space: string;
|
|
23
|
+
readonly path: string;
|
|
24
|
+
}
|
|
25
|
+
/** What the host has spent of a limit before this choice; `cost` is what a file adds against it, its size by default. */
|
|
26
|
+
export interface FilePickerBudget {
|
|
27
|
+
readonly usedBytes: number;
|
|
28
|
+
readonly limitBytes: number;
|
|
29
|
+
readonly cost?: (entry: FilePickerEntry) => number;
|
|
30
|
+
}
|
|
31
|
+
/** A folder the person may not open: thrown by `list`, it is shown as denied in place. Anything else is an error. */
|
|
32
|
+
export declare class FilePickerDenied extends Error {
|
|
33
|
+
constructor(message?: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A next page the server refused because its page link is no longer valid (its declared problem,
|
|
37
|
+
* /errors/page-link-invalid, 409): thrown by `list`, the folder is read again from its first page, once, the selection
|
|
38
|
+
* kept. Throw it for that problem only; any other refusal is an error.
|
|
39
|
+
*/
|
|
40
|
+
export declare class FilePickerRestart extends Error {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
43
|
+
/** The picker's words, in the host's language. */
|
|
44
|
+
export interface FilePickerLabels {
|
|
45
|
+
readonly title: string;
|
|
46
|
+
readonly close: string;
|
|
47
|
+
readonly cancel: string;
|
|
48
|
+
/** The confirm action, carrying the count: "Attach 3 files". */
|
|
49
|
+
readonly confirm: (count: number) => string;
|
|
50
|
+
readonly space: string;
|
|
51
|
+
readonly path: string;
|
|
52
|
+
readonly up: string;
|
|
53
|
+
readonly files: string;
|
|
54
|
+
/** "3 selected", on the chip that lists the selection. */
|
|
55
|
+
readonly selected: (count: number) => string;
|
|
56
|
+
readonly clear: string;
|
|
57
|
+
readonly remove: (name: string) => string;
|
|
58
|
+
/** The whole selection: "3 files, 2.1 MB". */
|
|
59
|
+
readonly total: (count: number, size: string) => string;
|
|
60
|
+
/** With a budget: "1.2 MB of 25 MB left after these". */
|
|
61
|
+
readonly left: (left: string, limit: string) => string;
|
|
62
|
+
/** Why a file is not offered, or the selection cannot be sent: it would go over the limit. */
|
|
63
|
+
readonly overBudget: string;
|
|
64
|
+
readonly loading: string;
|
|
65
|
+
readonly empty: string;
|
|
66
|
+
readonly error: string;
|
|
67
|
+
readonly retry: string;
|
|
68
|
+
readonly denied: string;
|
|
69
|
+
}
|
|
70
|
+
export interface FilePickerProps {
|
|
71
|
+
readonly open: boolean;
|
|
72
|
+
/** The spaces the person may read, in the host's order; the first is shown first. With one, no switch is drawn. */
|
|
73
|
+
readonly spaces: readonly FilePickerSpace[];
|
|
74
|
+
/** One page of a folder of a space, in the host's order. Throws FilePickerDenied for a folder the person may not open. */
|
|
75
|
+
readonly list: (space: string, path: string, cursor?: string) => Promise<FilePickerPage>;
|
|
76
|
+
/** The host's own reason a file cannot be chosen (not readable, a type it will not send), or nothing. */
|
|
77
|
+
readonly disabledReason?: (entry: FilePickerEntry) => string | null | undefined;
|
|
78
|
+
readonly budget?: FilePickerBudget;
|
|
79
|
+
/** A size as the host says it, in the person's language. */
|
|
80
|
+
readonly formatSize: (bytes: number) => string;
|
|
81
|
+
readonly labels: FilePickerLabels;
|
|
82
|
+
readonly onConfirm: (chosen: readonly FilePickerChoice[]) => void;
|
|
83
|
+
readonly onCancel: () => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Choosing files a person already has, in their spaces (contract component `file-picker`). The kit knows no API: the
|
|
87
|
+
* host lists folders page by page and receives the chosen entries. The selection holds across folders and spaces; a
|
|
88
|
+
* budget, when given, is counted here, so every host disables the same files. Enter opens a folder, Space ticks a file,
|
|
89
|
+
* Backspace goes up, Escape cancels.
|
|
90
|
+
*/
|
|
91
|
+
export declare function FilePicker(props: FilePickerProps): ReactNode;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** One of the top bar's file actions, as Download, Print and Open separately are: the caller's words and handler. */
|
|
3
|
+
export interface FileViewerAction {
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly icon: ReactNode;
|
|
6
|
+
readonly onSelect: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The other files of a set, for previous and next. A side with no handler is that end of the list, and draws no arrow.
|
|
10
|
+
* Each label names where its arrow goes ("Next attachment: Receipt.pdf"), as its accessible name and its tooltip.
|
|
11
|
+
*/
|
|
12
|
+
export interface FileViewerSiblings {
|
|
13
|
+
readonly position: string;
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly total: number;
|
|
16
|
+
readonly previousLabel: string;
|
|
17
|
+
readonly nextLabel: string;
|
|
18
|
+
readonly onPrevious?: () => void;
|
|
19
|
+
readonly onNext?: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The file changed elsewhere while it was being edited: the viewer says so above the editor and asks whether to
|
|
23
|
+
* overwrite the other version or keep both, never saving over it silently. The words and both answers are the caller's.
|
|
24
|
+
*/
|
|
25
|
+
export interface FileViewerConflict {
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly overwriteLabel: string;
|
|
28
|
+
readonly onOverwrite: () => void;
|
|
29
|
+
readonly keepBothLabel: string;
|
|
30
|
+
readonly onKeepBoth: () => void;
|
|
31
|
+
}
|
|
32
|
+
/** The editing state: the content hosts the type's own editor, and the viewer has none of its own. */
|
|
33
|
+
export interface FileViewerEditing {
|
|
34
|
+
readonly status: ReactNode;
|
|
35
|
+
readonly doneLabel: string;
|
|
36
|
+
readonly onDone: () => void;
|
|
37
|
+
/** It holds unsaved work: Close calls onDirtyClose, which asks the person, rather than closing. */
|
|
38
|
+
readonly dirty?: boolean;
|
|
39
|
+
readonly onDirtyClose: () => void;
|
|
40
|
+
/** The file changed elsewhere meanwhile: the question above the editor until the caller has its answer. */
|
|
41
|
+
readonly conflict?: FileViewerConflict;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* What the content shows instead of the file, as the state component in page placement, the top bar staying (Close and
|
|
45
|
+
* Download remain): loading while the file is read; error in the caller's words, with Retry when trying again can
|
|
46
|
+
* help (none when the server says the file is gone or refused); no-preview, with Download as its action.
|
|
47
|
+
*/
|
|
48
|
+
export type FileViewerState = {
|
|
49
|
+
readonly kind: 'loading';
|
|
50
|
+
readonly title: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: 'error';
|
|
53
|
+
readonly title: string;
|
|
54
|
+
readonly description?: string;
|
|
55
|
+
readonly retry?: {
|
|
56
|
+
readonly label: string;
|
|
57
|
+
readonly onRetry: () => void;
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: 'no-preview';
|
|
61
|
+
readonly title: string;
|
|
62
|
+
readonly description?: string;
|
|
63
|
+
readonly download: {
|
|
64
|
+
readonly label: string;
|
|
65
|
+
readonly onDownload: () => void;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export interface FileViewerProps {
|
|
69
|
+
/** The file's name: the dialog's name, truncated where it does not fit, with the whole of it available. */
|
|
70
|
+
readonly name: string;
|
|
71
|
+
/** The file type's badge. */
|
|
72
|
+
readonly badge: ReactNode;
|
|
73
|
+
readonly closeLabel: string;
|
|
74
|
+
readonly onClose: () => void;
|
|
75
|
+
/** Download, Print and Open separately, as the file allows, in that order. */
|
|
76
|
+
readonly actions?: readonly FileViewerAction[];
|
|
77
|
+
/** The name of the menu holding the actions on a phone. */
|
|
78
|
+
readonly moreLabel?: string;
|
|
79
|
+
/** Only with the server's write permission for this file: absent, never disabled, without it. */
|
|
80
|
+
readonly edit?: {
|
|
81
|
+
readonly label: string;
|
|
82
|
+
readonly icon: ReactNode;
|
|
83
|
+
readonly onEdit: () => void;
|
|
84
|
+
};
|
|
85
|
+
readonly editing?: FileViewerEditing;
|
|
86
|
+
/** Instead of the file: loading, an error, or no preview. Without it the content is the adapter's. */
|
|
87
|
+
readonly state?: FileViewerState;
|
|
88
|
+
readonly siblings?: FileViewerSiblings;
|
|
89
|
+
/** What the viewer bar holds, from the adapter: page, zoom, fit. It never holds a file action. */
|
|
90
|
+
readonly bar?: ReactNode;
|
|
91
|
+
/** A paged file's pages, at a wide width. */
|
|
92
|
+
readonly thumbnails?: ReactNode;
|
|
93
|
+
/** A set of attachments, along the foot above the viewer bar at a wide width. */
|
|
94
|
+
readonly strip?: ReactNode;
|
|
95
|
+
/** Plus, minus and 0, where the adapter has zoom. */
|
|
96
|
+
readonly onZoom?: (how: 'in' | 'out' | 'reset') => void;
|
|
97
|
+
/** The adapter: it scrolls inside itself, and the overlay never scrolls as a document. */
|
|
98
|
+
readonly children: ReactNode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One way to look at a file (contract component `file-viewer`): over the page, dark whatever the scheme, with an
|
|
102
|
+
* adapter in the content. Close leaves the whole viewer, asking first with unsaved changes; Done returns from editing
|
|
103
|
+
* to viewing. Escape closes only while viewing: while editing it belongs to the editor. Focus starts on Close, stays
|
|
104
|
+
* inside, and returns to what opened it.
|
|
105
|
+
*/
|
|
106
|
+
export declare function FileViewer(props: FileViewerProps): ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
/** The icons the Workspace draws: one stroke style, 24 units, coloured by the text around them. */
|
|
3
|
-
export type IconName = 'mail' | 'chat' | 'phone' | 'calendar' | 'file' | 'image' | 'search' | 'bell' | 'pencil' | 'star' | 'send' | 'inbox' | 'archive' | 'trash' | 'paperclip' | 'mic' | 'speaker' | 'user-plus' | 'phone-off' | 'video' | 'info' | 'chevron-down' | 'chevron-left' | 'plus' | 'folder' | 'check' | 'server' | 'reply' | 'more';
|
|
3
|
+
export type IconName = 'mail' | 'chat' | 'phone' | 'calendar' | 'file' | 'image' | 'search' | 'bell' | 'pencil' | 'star' | 'send' | 'inbox' | 'archive' | 'trash' | 'paperclip' | 'mic' | 'speaker' | 'user-plus' | 'phone-off' | 'video' | 'info' | 'chevron-down' | 'chevron-left' | 'plus' | 'folder' | 'check' | 'server' | 'reply' | 'more' | 'download' | 'print' | 'open-separately' | 'important' | 'forward' | 'refresh' | 'file-code' | 'mail-open' | 'copy' | 'user' | 'folder-plus' | 'folder-x' | 'user-check' | 'user-x' | 'upload' | 'users' | 'settings' | 'hash';
|
|
4
4
|
export interface IconProps {
|
|
5
5
|
readonly name: IconName;
|
|
6
6
|
readonly size?: number;
|
|
@@ -10,3 +10,20 @@ export interface IconProps {
|
|
|
10
10
|
/** An icon from the Workspace's set; decorative unless given a label. */
|
|
11
11
|
export declare function Icon({ name, size, label }: IconProps): ReactNode;
|
|
12
12
|
export declare const ICON_NAMES: readonly IconName[];
|
|
13
|
+
/**
|
|
14
|
+
* The server's action icons, named as Bootstrap Icons names them, to the kit's own: the one table that turns a node's
|
|
15
|
+
* icon into what the kit draws. A name not here has no icon: a toolbar shows its action's label alone, and NamedIcon
|
|
16
|
+
* keeps the icon's space empty.
|
|
17
|
+
*/
|
|
18
|
+
export declare const BOOTSTRAP_ICONS: Readonly<Record<string, IconName>>;
|
|
19
|
+
/** The kit's icon for a server's (Bootstrap Icons) name; null for a name the table does not hold. */
|
|
20
|
+
export declare function iconForName(name: string): IconName | null;
|
|
21
|
+
/**
|
|
22
|
+
* A server's icon, by its (Bootstrap Icons) name, at the size a row of items draws them. A name the kit's table does not
|
|
23
|
+
* hold draws an empty space of the same size, so the labels beside it line up, and outside production says so once per
|
|
24
|
+
* name in the console. No name draws nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function NamedIcon({ name, size }: {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly size?: number;
|
|
29
|
+
}): ReactNode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A notification's action, as the server declares it, already resolved by the host: `row`, the whole row takes the
|
|
4
|
+
* person there; `button`, a button after the text does. `onAction` is absent when the host does not know where it leads:
|
|
5
|
+
* then nothing is drawn for it and pressing the row only reads the notification.
|
|
6
|
+
*/
|
|
7
|
+
export interface NotificationAction {
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly presentation: 'row' | 'button';
|
|
10
|
+
readonly onAction?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface NotificationProps {
|
|
13
|
+
/** The server's title, plain text. */
|
|
14
|
+
readonly title: string;
|
|
15
|
+
/** The server's body, plain text; collapsed to one line until expanded. */
|
|
16
|
+
readonly body?: string | null;
|
|
17
|
+
/** When, as the host words it. */
|
|
18
|
+
readonly time?: string | null;
|
|
19
|
+
readonly unread: boolean;
|
|
20
|
+
/** What the visually hidden word for an unread notification is, in the host's language. */
|
|
21
|
+
readonly unreadLabel: string;
|
|
22
|
+
/** The chevron's name while collapsed and while expanded, in the host's language. */
|
|
23
|
+
readonly expandLabel: string;
|
|
24
|
+
readonly collapseLabel: string;
|
|
25
|
+
readonly action?: NotificationAction | null;
|
|
26
|
+
/** The notification is read: the row pressed, its body expanded, or its button pressed. Called once while unread. */
|
|
27
|
+
readonly onRead: () => void;
|
|
28
|
+
/** A leading visual: an icon or an avatar. */
|
|
29
|
+
readonly leading?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One notification in the person's notification list (contract component `notification`: unread, read, collapsed,
|
|
33
|
+
* expanded, with-action, row-action). Pressing the row (a click, a tap or Enter) reads it, and takes the person
|
|
34
|
+
* somewhere only when its action is a row action the host can follow; a button action goes only from its button, a real
|
|
35
|
+
* button after the text, which reads it too. Expanding the body with the chevron reads it as well. The server's title
|
|
36
|
+
* and body are drawn as given, as text.
|
|
37
|
+
*/
|
|
38
|
+
export declare function Notification({ title, body, time, unread, unreadLabel, expandLabel, collapseLabel, action, onRead, leading }: NotificationProps): ReactNode;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** One entry of a menu button's menu: a child of the action's node, as the host resolved it. */
|
|
3
|
+
export interface PaneToolbarEntry {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
/** Its icon by its Bootstrap Icons name; one the kit's table lacks leaves its label alone. */
|
|
7
|
+
readonly icon?: string;
|
|
8
|
+
/** Shown, and doing nothing when chosen; `reason` is said beside it. */
|
|
9
|
+
readonly disabled?: boolean;
|
|
10
|
+
readonly reason?: string;
|
|
11
|
+
readonly danger?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One action of a pane's row, as the server's action node gives it: which actions exist, their order, groups, icons and
|
|
15
|
+
* danger are the server's; the row draws them and says which was chosen.
|
|
16
|
+
*/
|
|
17
|
+
export interface PaneToolbarAction {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
/** Its icon by its Bootstrap Icons name, as the server names it; one the kit's table lacks leaves its label alone. */
|
|
20
|
+
readonly icon: string;
|
|
21
|
+
/** Its accessible name always, its tooltip once labels hide. */
|
|
22
|
+
readonly label: string;
|
|
23
|
+
/** Actions of one group sit together, groups in the order their first action comes; a separator between two. */
|
|
24
|
+
readonly group: string;
|
|
25
|
+
/**
|
|
26
|
+
* When it goes behind ... as the row narrows: lower first; actions of the same priority go together (a toggle's
|
|
27
|
+
* pair). Without one it is pinned: it goes behind ... only in a row too narrow to hold it with the rest, the last in
|
|
28
|
+
* the row first, so that nothing is cut off. 0: menu only, behind ... at every width and never in the row.
|
|
29
|
+
*/
|
|
30
|
+
readonly overflow?: number;
|
|
31
|
+
/** Shown, kept in the focus order, and doing nothing when chosen; `reason` is its tooltip. */
|
|
32
|
+
readonly disabled?: boolean;
|
|
33
|
+
readonly reason?: string;
|
|
34
|
+
/** Its work is under way: a spinner in its icon's place after a moment, and a second press runs nothing. */
|
|
35
|
+
readonly busy?: boolean;
|
|
36
|
+
/** The delete kind: drawn as danger, the only action that is. */
|
|
37
|
+
readonly danger?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* A menu button (New with its chevron): its node's children, in the tree's order, as its menu's entries. The action
|
|
40
|
+
* opens the menu, and choosing an entry says the entry's id. With no entry to show the action is not drawn at all.
|
|
41
|
+
*/
|
|
42
|
+
readonly entries?: readonly PaneToolbarEntry[];
|
|
43
|
+
}
|
|
44
|
+
export interface PaneToolbarProps {
|
|
45
|
+
/** The toolbar's accessible name, in the host's words ("Message actions"). */
|
|
46
|
+
readonly label: string;
|
|
47
|
+
/** The actions in their order; the host passes only those it has a handler for. */
|
|
48
|
+
readonly actions: readonly PaneToolbarAction[];
|
|
49
|
+
/** An action was chosen, in the row or behind ...; never for a disabled or busy one. */
|
|
50
|
+
readonly onAction: (id: string) => void;
|
|
51
|
+
/** The trailing status, formatted by the host ("Synced at 14:32"); truncated with its whole text as its title. */
|
|
52
|
+
readonly status?: string;
|
|
53
|
+
/** The ... button's accessible name and tooltip, from the host's catalogue ("More actions"). */
|
|
54
|
+
readonly moreLabel: string;
|
|
55
|
+
/** Navigation that leads the row where one pane shows at a time (Back): before the first group, never behind .... */
|
|
56
|
+
readonly leading?: ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The one row of actions at the top of a pane (contract component `pane-toolbar`: default, labels-partly-hidden,
|
|
60
|
+
* labels-hidden, overflowing, menu-open, with-status, action-disabled, action-busy, phone). It is measured on its own
|
|
61
|
+
* width as its pane resizes:
|
|
62
|
+
* every label shows while all fit; then labels hide one by one in the overflow order (lower first, a priority's actions
|
|
63
|
+
* together), the pinned last, from the end of the row; only once every label is hidden do actions go behind ..., in
|
|
64
|
+
* the same order, the fewest that let the rest and ... fit, never one alone while another can go with it. Where the
|
|
65
|
+
* pinned and ... still do not fit, the pinned go behind ... too, from the end of the row: no action is ever cut off,
|
|
66
|
+
* and ... is always reached. They come back in the reverse order. One Tab stop; Left and Right, Home and End move
|
|
67
|
+
* inside it.
|
|
68
|
+
*
|
|
69
|
+
* Menu-only actions (overflow 0) are behind ... at every width, first in its menu, and take no part in the giving way:
|
|
70
|
+
* their labels are not counted, and "never one alone" counts only the actions that could have stayed in the row. ...
|
|
71
|
+
* is drawn for them even when one is alone.
|
|
72
|
+
*
|
|
73
|
+
* An action with `entries` is a menu button: its chevron after it, it opens the kit's context menu with its entries,
|
|
74
|
+
* each disabled with its own reason as the server says, and it gives way as any other action does (behind ..., choosing
|
|
75
|
+
* it opens its entries there). One whose entries are empty is not drawn; one that is itself disabled does not open.
|
|
76
|
+
*/
|
|
77
|
+
export declare function PaneToolbar({ label, actions: given, onAction, status, moreLabel, leading }: PaneToolbarProps): ReactNode;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type MenuItem } from './Collections.js';
|
|
3
|
+
import { type IconName } from './Icon.js';
|
|
4
|
+
import { type FilterOption } from './Workspace.js';
|
|
5
|
+
/** The screen's floating primary action: one action, or a menu of declared entries. */
|
|
6
|
+
export type ScreenPrimary = {
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly icon: IconName;
|
|
9
|
+
readonly onPress: () => void;
|
|
10
|
+
} | {
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly icon: IconName;
|
|
13
|
+
readonly menu: readonly MenuItem[];
|
|
14
|
+
};
|
|
15
|
+
export interface ScreenShellProps {
|
|
16
|
+
/** The current place's name. */
|
|
17
|
+
readonly title: string;
|
|
18
|
+
/** On a nested screen: where Back leads, named by the parent's name. Absent at a section's root. */
|
|
19
|
+
readonly back?: {
|
|
20
|
+
readonly label: string;
|
|
21
|
+
readonly href?: string;
|
|
22
|
+
readonly onBack?: () => void;
|
|
23
|
+
};
|
|
24
|
+
/** At a section's root: the section's own navigation (mail's folders), an icon button the host supplies. */
|
|
25
|
+
readonly navigation?: ReactNode;
|
|
26
|
+
/** The section's search, an icon button. */
|
|
27
|
+
readonly search?: {
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly onOpen: () => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* While the section's search is open: the bar is Close, then the host's search field in place of the title and the
|
|
33
|
+
* icons, until Close (or the host) ends it.
|
|
34
|
+
*/
|
|
35
|
+
readonly searching?: {
|
|
36
|
+
readonly field: ReactNode;
|
|
37
|
+
readonly closeLabel: string;
|
|
38
|
+
readonly onClose: () => void;
|
|
39
|
+
};
|
|
40
|
+
/** The shell's own icons, the same in every section: the bell, then the person's avatar. */
|
|
41
|
+
readonly globals?: ReactNode;
|
|
42
|
+
/** The place's filters, as chips under the bar, exactly one selected. */
|
|
43
|
+
readonly filters?: {
|
|
44
|
+
readonly label: string;
|
|
45
|
+
readonly options: readonly FilterOption[];
|
|
46
|
+
readonly selected: string;
|
|
47
|
+
readonly onSelect: (id: string) => void;
|
|
48
|
+
};
|
|
49
|
+
/** The floating primary action, given only when the server declares it; never on an item's own screen. */
|
|
50
|
+
readonly primary?: ScreenPrimary;
|
|
51
|
+
/** With it the content takes the pull: the refresh, and while it runs the refreshing state. */
|
|
52
|
+
readonly onRefresh?: () => Promise<unknown>;
|
|
53
|
+
/** What the pull says while pulled: the time of the last sync. */
|
|
54
|
+
readonly pullText?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the bar (and the filters under it) is out of view. Not given, the shell decides: out while the content, or
|
|
57
|
+
* any pane in it, scrolls down past the bar's own height; back on any scroll up, at the top, or when focus moves into
|
|
58
|
+
* the bar. Never while searching, pulling or refreshing, whatever is given.
|
|
59
|
+
*/
|
|
60
|
+
readonly barHidden?: boolean;
|
|
61
|
+
/** The screen's content: it scrolls on its own; a list in it draws the pull. */
|
|
62
|
+
readonly children: ReactNode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* One screen of a section at phone width (contract component `screen-shell`: root, nested, with-filters,
|
|
66
|
+
* with-primary-action, with-primary-menu, pulling, refreshing, searching, bar-hidden). One bar: the section's navigation or Back
|
|
67
|
+
* with the parent's name, the title, then search and the shell's own icons, or while searching, Close and the field; the filters under it; the content, which
|
|
68
|
+
* scrolls on its own and refreshes by a pull from its top; the primary action floating at the bottom right, its menu
|
|
69
|
+
* opening above it. What fills each slot is the host's, from the server's declared nodes.
|
|
70
|
+
*/
|
|
71
|
+
export declare function ScreenShell({ title, back, navigation, search, searching, globals, filters, primary: declared, onRefresh, pullText, barHidden, children }: ScreenShellProps): ReactNode;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type MenuItem } from './Collections.js';
|
|
3
|
+
import { type IconName } from './Icon.js';
|
|
4
|
+
import type { Offer } from '../server/capability.js';
|
|
5
|
+
/** The section's primary action: one action, or a split button whose menu lists the action's declared entries. */
|
|
6
|
+
export type SectionPrimary = {
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly icon: IconName;
|
|
9
|
+
readonly onPress: () => void;
|
|
10
|
+
readonly offer?: Offer;
|
|
11
|
+
} | {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly icon: IconName;
|
|
14
|
+
readonly onPress: () => void;
|
|
15
|
+
readonly offer?: Offer;
|
|
16
|
+
readonly menu: readonly MenuItem[];
|
|
17
|
+
/** The split menu button's accessible name. */
|
|
18
|
+
readonly menuLabel: string;
|
|
19
|
+
};
|
|
20
|
+
export interface SectionHeaderProps {
|
|
21
|
+
/** The section's declared title. */
|
|
22
|
+
readonly title: string;
|
|
23
|
+
/** An icon before the title. */
|
|
24
|
+
readonly icon?: IconName;
|
|
25
|
+
/** Given only when the section declares one. */
|
|
26
|
+
readonly primary?: SectionPrimary;
|
|
27
|
+
/** The section's other declared actions, in the tree's order; a refused one stays, with the server's reason. */
|
|
28
|
+
readonly more?: readonly MenuItem[];
|
|
29
|
+
/** More's accessible name and tooltip, from the host's catalogue. */
|
|
30
|
+
readonly moreLabel: string;
|
|
31
|
+
/** Row 2: the section's context (a mailbox card, filters, breadcrumbs); with none, no row 2. */
|
|
32
|
+
readonly context?: ReactNode;
|
|
33
|
+
/** The header spans a one-column page. */
|
|
34
|
+
readonly fullWidth?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The head of a section from tablet width up (contract component `section-header`: default, with-primary,
|
|
38
|
+
* with-primary-menu, with-more, action-disabled, with-context, full-width). Row 1: the title, then the primary action
|
|
39
|
+
* (icon and label, always shown; a split button while it has an entry to show, a plain button with none) and More for
|
|
40
|
+
* the other actions. Row 2: the context, only when given. No divider lines. Below tablet width the host draws the
|
|
41
|
+
* screen shell instead.
|
|
42
|
+
*/
|
|
43
|
+
export declare function SectionHeader({ title, icon, primary, more, moreLabel, context, fullWidth }: SectionHeaderProps): ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type IconName } from './Icon';
|
|
2
|
+
import { type IconName } from './Icon.js';
|
|
3
3
|
export interface SignInFeature {
|
|
4
4
|
readonly icon: IconName;
|
|
5
5
|
readonly label: string;
|
|
@@ -25,6 +25,22 @@ export interface SignInFormProps {
|
|
|
25
25
|
/** The server's refusal, in its words. */
|
|
26
26
|
readonly error?: string;
|
|
27
27
|
readonly busy?: boolean;
|
|
28
|
+
/** Its words, in the app's language; each left out is English. */
|
|
29
|
+
readonly labels?: Partial<SignInLabels>;
|
|
28
30
|
}
|
|
31
|
+
/** The words the sign-in form says, in the app's language; English by default. */
|
|
32
|
+
export interface SignInLabels {
|
|
33
|
+
readonly title: string;
|
|
34
|
+
readonly identifier: string;
|
|
35
|
+
readonly identifierPlaceholder: string;
|
|
36
|
+
readonly password: string;
|
|
37
|
+
readonly show: string;
|
|
38
|
+
readonly hide: string;
|
|
39
|
+
readonly forgot: string;
|
|
40
|
+
readonly submit: string;
|
|
41
|
+
readonly newHere: string;
|
|
42
|
+
readonly create: string;
|
|
43
|
+
}
|
|
44
|
+
export declare const SIGN_IN_LABELS: SignInLabels;
|
|
29
45
|
/** Signing in with an identifier and a password; the password can be shown while typed. */
|
|
30
|
-
export declare function SignInForm({ server, onSubmit, forgotHref, createHref, error, busy }: SignInFormProps): ReactNode;
|
|
46
|
+
export declare function SignInForm({ server, onSubmit, forgotHref, createHref, error, busy, labels }: SignInFormProps): ReactNode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface SplitterProps {
|
|
3
|
+
/**
|
|
4
|
+
* Where the width is remembered on this device (the screen and the split, such as "mail:folders"); never sent
|
|
5
|
+
* anywhere. Without one, nothing is remembered.
|
|
6
|
+
*/
|
|
7
|
+
readonly storageKey?: string;
|
|
8
|
+
/** The leading column's width in px, when the host keeps it; without one the splitter keeps it itself. */
|
|
9
|
+
readonly value?: number;
|
|
10
|
+
/** The leading column's default width in px: what a double-click puts it back to. */
|
|
11
|
+
readonly default: number;
|
|
12
|
+
/** The leading column's least width in px. */
|
|
13
|
+
readonly min: number;
|
|
14
|
+
/** The leading column's greatest width in px (or the width that leaves the trailing column its least). */
|
|
15
|
+
readonly max: number;
|
|
16
|
+
/** How far an arrow key moves it, in px; Shift with an arrow moves it 64. */
|
|
17
|
+
readonly step?: number;
|
|
18
|
+
/** The handle's accessible name, naming the columns it resizes ("Resize the folder list"). */
|
|
19
|
+
readonly label: string;
|
|
20
|
+
/**
|
|
21
|
+
* The new width: while it is dragged (`done` false), and once more when the drag ends, on each key, on a
|
|
22
|
+
* double-click and when a remembered width is read back (`done` true).
|
|
23
|
+
*/
|
|
24
|
+
readonly onChange: (width: number, done: boolean) => void;
|
|
25
|
+
readonly className?: string;
|
|
26
|
+
readonly style?: CSSProperties;
|
|
27
|
+
}
|
|
28
|
+
/** The width remembered on this device under `storageKey`, or null: none, or storage that cannot be read. */
|
|
29
|
+
export declare function readSplitterWidth(storageKey: string): number | null;
|
|
30
|
+
/**
|
|
31
|
+
* The handle between two columns (contract component `splitter`: default, hover, dragging, focused, at-min, at-max).
|
|
32
|
+
* A vertical strip at least 8px wide that draws nothing at rest and the accent line on hover, while dragged and with
|
|
33
|
+
* focus. A drag moves the leading column within min and max and remembers its width on release; a double-click puts it
|
|
34
|
+
* back to its default and forgets it. It is a focusable separator: Left and Right move it by step (Shift: 64), Home and
|
|
35
|
+
* End take it to min and max, Enter and Escape leave it; each key is remembered as a release is. A remembered width is
|
|
36
|
+
* read back, within today's limits, when it is first drawn.
|
|
37
|
+
*/
|
|
38
|
+
export declare function Splitter({ storageKey, value, default: initial, min, max, step, label, onChange, className, style }: SplitterProps): ReactNode;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What a page, a card or a line of text shows instead of its content. `elevation-required` is not offered here: the
|
|
4
|
+
* clients this kit serves never elevate (kit.contract.json, notOffered).
|
|
5
|
+
*/
|
|
6
|
+
export type StateKind = 'loading' | 'empty' | 'error' | 'denied';
|
|
7
|
+
/** page: centred in the content area; block: centred in its card; inline: small, beside text. */
|
|
8
|
+
export type StatePlacement = 'page' | 'block' | 'inline';
|
|
9
|
+
export interface StateProps {
|
|
10
|
+
readonly kind: StateKind;
|
|
11
|
+
/** What the state is, in the caller's words. */
|
|
12
|
+
readonly title: string;
|
|
13
|
+
/** Why, or what to do, in the caller's words. */
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
/** One thing to do about it: Retry for an error, say. Its label is the caller's word too. A refusal offers none. */
|
|
16
|
+
readonly action?: {
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly onAction: () => void;
|
|
19
|
+
};
|
|
20
|
+
readonly placement?: StatePlacement;
|
|
21
|
+
/** The empty kind only: an icon name from the icon list (as the server's nodes name them), drawn above the title, decorative. */
|
|
22
|
+
readonly icon?: string;
|
|
23
|
+
}
|
|
24
|
+
/** How long a loading state shows nothing, so a read answered sooner does not flash: the `state-delay` token. */
|
|
25
|
+
export declare const STATE_DELAY_MS = 300;
|
|
26
|
+
/**
|
|
27
|
+
* One component for every state instead of content (contract component `state`: loading, empty, error, denied, page,
|
|
28
|
+
* block, inline, with-action, delayed). It shows the caller's title and description as given and adds no words of
|
|
29
|
+
* its own beyond its action's label. Every kind is a polite status; loading shows nothing at all -- neither spinner
|
|
30
|
+
* nor title -- until the state delay has passed, then both together, while its title is in the live region from the
|
|
31
|
+
* start, visually hidden.
|
|
32
|
+
*/
|
|
33
|
+
export declare function State({ kind, title, description, action, placement, icon }: StateProps): ReactNode;
|
|
@@ -8,12 +8,14 @@ export interface ToastProps {
|
|
|
8
8
|
readonly onAction: () => void;
|
|
9
9
|
};
|
|
10
10
|
readonly onDismiss?: () => void;
|
|
11
|
+
/** The dismiss button's name, in the app's language ("Dismiss"). */
|
|
12
|
+
readonly dismissLabel?: string;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* A short report of what happened (contract component `toast`: success, error, info, with-action). An error is said
|
|
14
16
|
* assertively (role=alert); the others politely (role=status). Placement and timing are the page's (ToastRegion).
|
|
15
17
|
*/
|
|
16
|
-
export declare function Toast({ kind, message, action, onDismiss }: ToastProps): ReactNode;
|
|
18
|
+
export declare function Toast({ kind, message, action, onDismiss, dismissLabel }: ToastProps): ReactNode;
|
|
17
19
|
/** Where toasts stack: a fixed corner of the page. */
|
|
18
20
|
export declare function ToastRegion({ children }: {
|
|
19
21
|
readonly children: ReactNode;
|
|
@@ -39,6 +41,8 @@ export interface ErrorBannerProps {
|
|
|
39
41
|
readonly message: ReactNode;
|
|
40
42
|
/** Offered only when trying again can help (a timeout, a network failure), never for a refusal. */
|
|
41
43
|
readonly onRetry?: () => void;
|
|
44
|
+
/** The retry button's words, in the app's language ("Try again"). */
|
|
45
|
+
readonly retryLabel?: string;
|
|
42
46
|
}
|
|
43
47
|
/** A read failed; says why, offers retry when retrying can help (contract component `error-banner`: default, with-retry). */
|
|
44
|
-
export declare function ErrorBanner({ message, onRetry }: ErrorBannerProps): ReactNode;
|
|
48
|
+
export declare function ErrorBanner({ message, onRetry, retryLabel }: ErrorBannerProps): ReactNode;
|
|
@@ -36,13 +36,31 @@ export interface AvatarProps {
|
|
|
36
36
|
/** The person's or account's name: the initials, and the accessible name. */
|
|
37
37
|
readonly name: string;
|
|
38
38
|
readonly pictureUrl?: string;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Whether they are reachable now, where the server declares it (chat members): a dot at the bottom right. Busy is
|
|
41
|
+
* drawn as away. Left out where the server says nothing (mail senders).
|
|
42
|
+
*/
|
|
43
|
+
readonly presence?: AvatarPresence;
|
|
44
|
+
/**
|
|
45
|
+
* On the person's own avatar in a bar: the live connection, as its dot, in place of presence; `label` says the
|
|
46
|
+
* state in words (its accessible name and tooltip), for the host's menu to repeat on a press.
|
|
47
|
+
*/
|
|
48
|
+
readonly connection?: {
|
|
49
|
+
readonly state: AvatarConnection;
|
|
50
|
+
readonly label: string;
|
|
51
|
+
};
|
|
52
|
+
/** Their account is gone: a neutral person icon, never initials of the name stored for them. */
|
|
53
|
+
readonly deleted?: boolean;
|
|
41
54
|
readonly size?: number;
|
|
42
55
|
}
|
|
43
|
-
|
|
56
|
+
export type AvatarPresence = 'online' | 'away' | 'busy' | 'offline';
|
|
57
|
+
export type AvatarConnection = 'connected' | 'reconnecting' | 'offline';
|
|
58
|
+
/**
|
|
59
|
+
* Up to two initials from a name: "Ada Lovelace" -> "AL", "ada" -> "A". A sender named for the service that sent on
|
|
60
|
+
* their behalf keeps their own: "Valentina Zagnetova via LinkedIn" -> "VZ".
|
|
61
|
+
*/
|
|
44
62
|
export declare function initialsOf(name: string): string;
|
|
45
63
|
/** Which of the six avatar tints a name takes: the same name always the same tint. */
|
|
46
64
|
export declare function tintOf(name: string): number;
|
|
47
65
|
/** A person or an account, by picture or initials (contract component `avatar`: picture, initials, presence). */
|
|
48
|
-
export declare function Avatar({ name, pictureUrl, presence, size }: AvatarProps): ReactNode;
|
|
66
|
+
export declare function Avatar({ name, pictureUrl, presence, connection, deleted, size }: AvatarProps): ReactNode;
|