@coolms/ui-react 0.0.0-stage → 0.1.0-alpha.10
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 +154 -0
- package/LICENSE +21 -0
- package/README.md +99 -2
- package/design-tokens.lock.json +47 -0
- package/dist/components/Button.d.ts +22 -0
- package/dist/components/Call.d.ts +71 -0
- package/dist/components/Collections.d.ts +64 -0
- package/dist/components/Dialogs.d.ts +48 -0
- package/dist/components/Fields.d.ts +50 -0
- package/dist/components/FilePicker.d.ts +83 -0
- package/dist/components/FileViewer.d.ts +63 -0
- package/dist/components/Icon.d.ts +19 -0
- package/dist/components/PaneToolbar.d.ts +48 -0
- package/dist/components/SignIn.d.ts +46 -0
- package/dist/components/State.d.ts +31 -0
- package/dist/components/Status.d.ts +48 -0
- package/dist/components/Structure.d.ts +48 -0
- package/dist/components/Workspace.d.ts +155 -0
- package/dist/components/internal.d.ts +9 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1574 -0
- package/dist/server/capability.d.ts +31 -0
- package/dist/server/client-update.d.ts +13 -0
- package/dist/server/conflict.d.ts +9 -0
- package/dist/server/refusal.d.ts +21 -0
- package/dist/server/reread.d.ts +9 -0
- package/kit.contract.json +35 -0
- package/package.json +66 -4
- package/src/fonts/OFL.txt +92 -0
- package/src/fonts/inter-cyrillic.woff2 +0 -0
- package/src/fonts/inter-latin-ext.woff2 +0 -0
- package/src/fonts/inter-latin.woff2 +0 -0
- package/src/fonts/inter.css +27 -0
- package/src/kit.css +673 -0
- package/src/tokens/coolms-tokens.css +246 -0
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
/** The picker's words, in the host's language. */
|
|
36
|
+
export interface FilePickerLabels {
|
|
37
|
+
readonly title: string;
|
|
38
|
+
readonly close: string;
|
|
39
|
+
readonly cancel: string;
|
|
40
|
+
/** The confirm action, carrying the count: "Attach 3 files". */
|
|
41
|
+
readonly confirm: (count: number) => string;
|
|
42
|
+
readonly space: string;
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly up: string;
|
|
45
|
+
readonly files: string;
|
|
46
|
+
/** "3 selected", on the chip that lists the selection. */
|
|
47
|
+
readonly selected: (count: number) => string;
|
|
48
|
+
readonly clear: string;
|
|
49
|
+
readonly remove: (name: string) => string;
|
|
50
|
+
/** The whole selection: "3 files, 2.1 MB". */
|
|
51
|
+
readonly total: (count: number, size: string) => string;
|
|
52
|
+
/** With a budget: "1.2 MB of 25 MB left after these". */
|
|
53
|
+
readonly left: (left: string, limit: string) => string;
|
|
54
|
+
/** Why a file is not offered, or the selection cannot be sent: it would go over the limit. */
|
|
55
|
+
readonly overBudget: string;
|
|
56
|
+
readonly loading: string;
|
|
57
|
+
readonly empty: string;
|
|
58
|
+
readonly error: string;
|
|
59
|
+
readonly retry: string;
|
|
60
|
+
readonly denied: string;
|
|
61
|
+
}
|
|
62
|
+
export interface FilePickerProps {
|
|
63
|
+
readonly open: boolean;
|
|
64
|
+
/** The spaces the person may read, in the host's order; the first is shown first. With one, no switch is drawn. */
|
|
65
|
+
readonly spaces: readonly FilePickerSpace[];
|
|
66
|
+
/** One page of a folder of a space, in the host's order. Throws FilePickerDenied for a folder the person may not open. */
|
|
67
|
+
readonly list: (space: string, path: string, cursor?: string) => Promise<FilePickerPage>;
|
|
68
|
+
/** The host's own reason a file cannot be chosen (not readable, a type it will not send), or nothing. */
|
|
69
|
+
readonly disabledReason?: (entry: FilePickerEntry) => string | null | undefined;
|
|
70
|
+
readonly budget?: FilePickerBudget;
|
|
71
|
+
/** A size as the host says it, in the person's language. */
|
|
72
|
+
readonly formatSize: (bytes: number) => string;
|
|
73
|
+
readonly labels: FilePickerLabels;
|
|
74
|
+
readonly onConfirm: (chosen: readonly FilePickerChoice[]) => void;
|
|
75
|
+
readonly onCancel: () => void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Choosing files a person already has, in their spaces (contract component `file-picker`). The kit knows no API: the
|
|
79
|
+
* host lists folders page by page and receives the chosen entries. The selection holds across folders and spaces; a
|
|
80
|
+
* budget, when given, is counted here, so every host disables the same files. Enter opens a folder, Space ticks a file,
|
|
81
|
+
* Backspace goes up, Escape cancels.
|
|
82
|
+
*/
|
|
83
|
+
export declare function FilePicker(props: FilePickerProps): ReactNode;
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
/** The other files of a set, for previous and next. A side with no handler is that end of the list. */
|
|
9
|
+
export interface FileViewerSiblings {
|
|
10
|
+
readonly position: string;
|
|
11
|
+
readonly index: number;
|
|
12
|
+
readonly total: number;
|
|
13
|
+
readonly previousLabel: string;
|
|
14
|
+
readonly nextLabel: string;
|
|
15
|
+
readonly onPrevious?: () => void;
|
|
16
|
+
readonly onNext?: () => void;
|
|
17
|
+
}
|
|
18
|
+
/** The editing state: the content hosts the type's own editor, and the viewer has none of its own. */
|
|
19
|
+
export interface FileViewerEditing {
|
|
20
|
+
readonly status: ReactNode;
|
|
21
|
+
readonly doneLabel: string;
|
|
22
|
+
readonly onDone: () => void;
|
|
23
|
+
/** It holds unsaved work: Close calls onDirtyClose, which asks the person, rather than closing. */
|
|
24
|
+
readonly dirty?: boolean;
|
|
25
|
+
readonly onDirtyClose: () => void;
|
|
26
|
+
}
|
|
27
|
+
export interface FileViewerProps {
|
|
28
|
+
/** The file's name: the dialog's name, truncated where it does not fit, with the whole of it available. */
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/** The file type's badge. */
|
|
31
|
+
readonly badge: ReactNode;
|
|
32
|
+
readonly closeLabel: string;
|
|
33
|
+
readonly onClose: () => void;
|
|
34
|
+
/** Download, Print and Open separately, as the file allows, in that order. */
|
|
35
|
+
readonly actions?: readonly FileViewerAction[];
|
|
36
|
+
/** The name of the menu holding the actions on a phone. */
|
|
37
|
+
readonly moreLabel?: string;
|
|
38
|
+
/** Only with the server's write permission for this file: absent, never disabled, without it. */
|
|
39
|
+
readonly edit?: {
|
|
40
|
+
readonly label: string;
|
|
41
|
+
readonly icon: ReactNode;
|
|
42
|
+
readonly onEdit: () => void;
|
|
43
|
+
};
|
|
44
|
+
readonly editing?: FileViewerEditing;
|
|
45
|
+
readonly siblings?: FileViewerSiblings;
|
|
46
|
+
/** What the viewer bar holds, from the adapter: page, zoom, fit. It never holds a file action. */
|
|
47
|
+
readonly bar?: ReactNode;
|
|
48
|
+
/** A paged file's pages, at a wide width. */
|
|
49
|
+
readonly thumbnails?: ReactNode;
|
|
50
|
+
/** A set of attachments, along the foot above the viewer bar at a wide width. */
|
|
51
|
+
readonly strip?: ReactNode;
|
|
52
|
+
/** Plus, minus and 0, where the adapter has zoom. */
|
|
53
|
+
readonly onZoom?: (how: 'in' | 'out' | 'reset') => void;
|
|
54
|
+
/** The adapter: it scrolls inside itself, and the overlay never scrolls as a document. */
|
|
55
|
+
readonly children: ReactNode;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One way to look at a file (contract component `file-viewer`): over the page, dark whatever the scheme, with an
|
|
59
|
+
* adapter in the content. Close leaves the whole viewer, asking first with unsaved changes; Done returns from editing
|
|
60
|
+
* to viewing. Escape closes only while viewing: while editing it belongs to the editor. Focus starts on Close, stays
|
|
61
|
+
* inside, and returns to what opened it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function FileViewer(props: FileViewerProps): ReactNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
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' | 'download' | 'print' | 'open-separately' | 'important' | 'forward' | 'refresh';
|
|
4
|
+
export interface IconProps {
|
|
5
|
+
readonly name: IconName;
|
|
6
|
+
readonly size?: number;
|
|
7
|
+
/** Only for an icon that stands alone and carries meaning; an icon beside its text is decorative. */
|
|
8
|
+
readonly label?: string;
|
|
9
|
+
}
|
|
10
|
+
/** An icon from the Workspace's set; decorative unless given a label. */
|
|
11
|
+
export declare function Icon({ name, size, label }: IconProps): ReactNode;
|
|
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, and its action shows its label alone.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BOOTSTRAP_ICONS: Readonly<Record<string, IconName>>;
|
|
18
|
+
/** The kit's icon for a server's (Bootstrap Icons) name; null for a name the table does not hold. */
|
|
19
|
+
export declare function iconForName(name: string): IconName | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* One action of a pane's row, as the server's action node gives it: which actions exist, their order, groups, icons and
|
|
4
|
+
* danger are the server's; the row draws them and says which was chosen.
|
|
5
|
+
*/
|
|
6
|
+
export interface PaneToolbarAction {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/** Its icon by its Bootstrap Icons name, as the server names it; one the kit's table lacks leaves its label alone. */
|
|
9
|
+
readonly icon: string;
|
|
10
|
+
/** Its accessible name always, its tooltip once labels hide. */
|
|
11
|
+
readonly label: string;
|
|
12
|
+
/** Actions of one group sit together, groups in the order their first action comes; a separator between two. */
|
|
13
|
+
readonly group: string;
|
|
14
|
+
/**
|
|
15
|
+
* When it goes behind ... as the row narrows: lower first; actions of the same priority go together (a toggle's
|
|
16
|
+
* pair). Without one it is pinned: it never goes behind ....
|
|
17
|
+
*/
|
|
18
|
+
readonly overflow?: number;
|
|
19
|
+
/** Shown, kept in the focus order, and doing nothing when chosen; `reason` is its tooltip. */
|
|
20
|
+
readonly disabled?: boolean;
|
|
21
|
+
readonly reason?: string;
|
|
22
|
+
/** Its work is under way: a spinner in its icon's place after a moment, and a second press runs nothing. */
|
|
23
|
+
readonly busy?: boolean;
|
|
24
|
+
/** The delete kind: drawn as danger, the only action that is. */
|
|
25
|
+
readonly danger?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PaneToolbarProps {
|
|
28
|
+
/** The toolbar's accessible name, in the host's words ("Message actions"). */
|
|
29
|
+
readonly label: string;
|
|
30
|
+
/** The actions in their order; the host passes only those it has a handler for. */
|
|
31
|
+
readonly actions: readonly PaneToolbarAction[];
|
|
32
|
+
/** An action was chosen, in the row or behind ...; never for a disabled or busy one. */
|
|
33
|
+
readonly onAction: (id: string) => void;
|
|
34
|
+
/** The trailing status, formatted by the host ("Synced at 14:32"); truncated with its whole text as its title. */
|
|
35
|
+
readonly status?: string;
|
|
36
|
+
/** The ... button's accessible name and tooltip, from the host's catalogue ("More actions"). */
|
|
37
|
+
readonly moreLabel: string;
|
|
38
|
+
/** Navigation that leads the row where one pane shows at a time (Back): before the first group, never behind .... */
|
|
39
|
+
readonly leading?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The one row of actions at the top of a pane (contract component `pane-toolbar`: default, labels-hidden, overflowing,
|
|
43
|
+
* menu-open, with-status, action-disabled, action-busy, phone). It is measured on its own width as its pane resizes:
|
|
44
|
+
* every label shows while all fit; then every label hides at once; then actions go behind ... in the overflow order,
|
|
45
|
+
* the fewest that let the rest and ... fit, never one alone; they come back in the reverse order, and the labels once
|
|
46
|
+
* every action is back and all of them fit. One Tab stop; Left and Right, Home and End move inside it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function PaneToolbar({ label, actions, onAction, status, moreLabel, leading }: PaneToolbarProps): ReactNode;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IconName } from './Icon';
|
|
3
|
+
export interface SignInFeature {
|
|
4
|
+
readonly icon: IconName;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SignInLayoutProps {
|
|
8
|
+
/** The brand mark: one letter, or an image. */
|
|
9
|
+
readonly mark: ReactNode;
|
|
10
|
+
readonly product: string;
|
|
11
|
+
readonly headline: string;
|
|
12
|
+
readonly lead: string;
|
|
13
|
+
readonly features?: readonly SignInFeature[];
|
|
14
|
+
/** The form, on the light side. */
|
|
15
|
+
readonly children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** The one sign-in page of the admin and the Workspace: the brand on the dark side, the form on the light side. */
|
|
18
|
+
export declare function SignInLayout({ mark, product, headline, lead, features, children }: SignInLayoutProps): ReactNode;
|
|
19
|
+
export interface SignInFormProps {
|
|
20
|
+
/** The server signed in to, as its host. */
|
|
21
|
+
readonly server: string;
|
|
22
|
+
readonly onSubmit: (identifier: string, password: string) => void;
|
|
23
|
+
readonly forgotHref?: string;
|
|
24
|
+
readonly createHref?: string;
|
|
25
|
+
/** The server's refusal, in its words. */
|
|
26
|
+
readonly error?: string;
|
|
27
|
+
readonly busy?: boolean;
|
|
28
|
+
/** Its words, in the app's language; each left out is English. */
|
|
29
|
+
readonly labels?: Partial<SignInLabels>;
|
|
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;
|
|
45
|
+
/** Signing in with an identifier and a password; the password can be shown while typed. */
|
|
46
|
+
export declare function SignInForm({ server, onSubmit, forgotHref, createHref, error, busy, labels }: SignInFormProps): ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
22
|
+
/** How long a loading state shows nothing, so a read answered sooner does not flash: the `state-delay` token. */
|
|
23
|
+
export declare const STATE_DELAY_MS = 300;
|
|
24
|
+
/**
|
|
25
|
+
* One component for every state instead of content (contract component `state`: loading, empty, error, denied, page,
|
|
26
|
+
* block, inline, with-action, delayed). It shows the caller's title and description as given and adds no words of
|
|
27
|
+
* its own beyond its action's label. Every kind is a polite status; loading shows nothing at all -- neither spinner
|
|
28
|
+
* nor title -- until the state delay has passed, then both together, while its title is in the live region from the
|
|
29
|
+
* start, visually hidden.
|
|
30
|
+
*/
|
|
31
|
+
export declare function State({ kind, title, description, action, placement }: StateProps): ReactNode;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ToastProps {
|
|
3
|
+
readonly kind: 'success' | 'error' | 'info';
|
|
4
|
+
readonly message: ReactNode;
|
|
5
|
+
/** One follow-up the person may want ("Undo", "Open"). */
|
|
6
|
+
readonly action?: {
|
|
7
|
+
readonly label: ReactNode;
|
|
8
|
+
readonly onAction: () => void;
|
|
9
|
+
};
|
|
10
|
+
readonly onDismiss?: () => void;
|
|
11
|
+
/** The dismiss button's name, in the app's language ("Dismiss"). */
|
|
12
|
+
readonly dismissLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A short report of what happened (contract component `toast`: success, error, info, with-action). An error is said
|
|
16
|
+
* assertively (role=alert); the others politely (role=status). Placement and timing are the page's (ToastRegion).
|
|
17
|
+
*/
|
|
18
|
+
export declare function Toast({ kind, message, action, onDismiss, dismissLabel }: ToastProps): ReactNode;
|
|
19
|
+
/** Where toasts stack: a fixed corner of the page. */
|
|
20
|
+
export declare function ToastRegion({ children }: {
|
|
21
|
+
readonly children: ReactNode;
|
|
22
|
+
}): ReactNode;
|
|
23
|
+
export interface LoadingProps {
|
|
24
|
+
/** What is being read ("Loading messages"): never a bare spinner. */
|
|
25
|
+
readonly what: ReactNode;
|
|
26
|
+
/** inline: beside other content; block: in place of a whole region. */
|
|
27
|
+
readonly layout?: 'inline' | 'block';
|
|
28
|
+
}
|
|
29
|
+
/** Something is being read, and says what (contract component `loading`: inline, block). */
|
|
30
|
+
export declare function Loading({ what, layout }: LoadingProps): ReactNode;
|
|
31
|
+
export interface EmptyStateProps {
|
|
32
|
+
readonly title: ReactNode;
|
|
33
|
+
/** Why there is nothing, and what would bring something. */
|
|
34
|
+
readonly hint?: ReactNode;
|
|
35
|
+
readonly action?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/** Nothing to show, and why; optionally what to do (contract component `empty-state`: default, with-action). */
|
|
38
|
+
export declare function EmptyState({ title, hint, action }: EmptyStateProps): ReactNode;
|
|
39
|
+
export interface ErrorBannerProps {
|
|
40
|
+
/** Why the read failed, in the person's words -- the server's own words when it gave them. */
|
|
41
|
+
readonly message: ReactNode;
|
|
42
|
+
/** Offered only when trying again can help (a timeout, a network failure), never for a refusal. */
|
|
43
|
+
readonly onRetry?: () => void;
|
|
44
|
+
/** The retry button's words, in the app's language ("Try again"). */
|
|
45
|
+
readonly retryLabel?: string;
|
|
46
|
+
}
|
|
47
|
+
/** A read failed; says why, offers retry when retrying can help (contract component `error-banner`: default, with-retry). */
|
|
48
|
+
export declare function ErrorBanner({ message, onRetry, retryLabel }: ErrorBannerProps): ReactNode;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface PageHeaderProps {
|
|
3
|
+
readonly title: ReactNode;
|
|
4
|
+
/** Whose or what this page is about ("Work mail · 3 folders"). */
|
|
5
|
+
readonly scope?: ReactNode;
|
|
6
|
+
/** The page's own actions, at the right. */
|
|
7
|
+
readonly actions?: ReactNode;
|
|
8
|
+
/** Back to where the page was opened from. */
|
|
9
|
+
readonly backLink?: {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly href?: string;
|
|
12
|
+
readonly onBack?: () => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The page's title, its scope line and its actions (contract component `page-header`: default, with-actions, with-back-link). */
|
|
16
|
+
export declare function PageHeader({ title, scope, actions, backLink }: PageHeaderProps): ReactNode;
|
|
17
|
+
export interface Tab {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly label: ReactNode;
|
|
20
|
+
/** How many things the section holds, when that helps choose it. */
|
|
21
|
+
readonly count?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface TabStripProps {
|
|
24
|
+
readonly tabs: readonly Tab[];
|
|
25
|
+
readonly active: string;
|
|
26
|
+
readonly onSelect: (id: string) => void;
|
|
27
|
+
/** What the tabs are sections of, for a screen reader. */
|
|
28
|
+
readonly label: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sections of one object, one at a time (contract component `tab-strip`: default, active, with-count). Arrow keys
|
|
32
|
+
* move between tabs, Home and End to the ends, as a tablist does.
|
|
33
|
+
*/
|
|
34
|
+
export declare function TabStrip({ tabs, active, onSelect, label }: TabStripProps): ReactNode;
|
|
35
|
+
export interface AvatarProps {
|
|
36
|
+
/** The person's or account's name: the initials, and the accessible name. */
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly pictureUrl?: string;
|
|
39
|
+
/** Whether they are reachable now, as the server said. */
|
|
40
|
+
readonly presence?: 'online' | 'away' | 'offline';
|
|
41
|
+
readonly size?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Up to two initials from a name: "Ada Lovelace" -> "AL", "ada" -> "A". */
|
|
44
|
+
export declare function initialsOf(name: string): string;
|
|
45
|
+
/** Which of the six avatar tints a name takes: the same name always the same tint. */
|
|
46
|
+
export declare function tintOf(name: string): number;
|
|
47
|
+
/** 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;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IconName } from './Icon';
|
|
3
|
+
export interface BadgeProps {
|
|
4
|
+
readonly count: number;
|
|
5
|
+
/** What the number counts, for a screen reader ("12 unread"). */
|
|
6
|
+
readonly label: string;
|
|
7
|
+
/** Over this, the badge reads "max+". */
|
|
8
|
+
readonly max?: number;
|
|
9
|
+
}
|
|
10
|
+
/** A count on the accent: unread messages, chats waiting. Nothing is drawn for zero. */
|
|
11
|
+
export declare function Badge({ count, label, max }: BadgeProps): ReactNode;
|
|
12
|
+
export interface RailItem {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly icon: IconName;
|
|
16
|
+
readonly href: string;
|
|
17
|
+
readonly badge?: {
|
|
18
|
+
readonly count: number;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface AppShellProps {
|
|
23
|
+
/** The product's name, beside the brand mark ("CoolMS Workspace"). */
|
|
24
|
+
readonly product: ReactNode;
|
|
25
|
+
/** The brand mark at the top of the rail: one letter, or an image. */
|
|
26
|
+
readonly mark: ReactNode;
|
|
27
|
+
readonly rail: readonly RailItem[];
|
|
28
|
+
readonly active: string;
|
|
29
|
+
/** Called instead of following the link, when given (a client-side router). */
|
|
30
|
+
readonly onNavigate?: (id: string) => void;
|
|
31
|
+
/** The server the page is signed in to, as a control that switches servers. */
|
|
32
|
+
readonly server?: ReactNode;
|
|
33
|
+
/** The global search field. */
|
|
34
|
+
readonly search?: ReactNode;
|
|
35
|
+
/** Notifications and the account, at the right of the top bar. */
|
|
36
|
+
readonly account?: ReactNode;
|
|
37
|
+
readonly children: ReactNode;
|
|
38
|
+
/** The rail's name for assistive technology, in the app's language ("Sections"). */
|
|
39
|
+
readonly railLabel?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The Workspace's frame: a dark rail of sections, each an icon over its name with its count, and a light top bar with
|
|
43
|
+
* the server, the search and the account. The open section is marked for assistive technology as the current page.
|
|
44
|
+
*/
|
|
45
|
+
export declare function AppShell({ product, mark, rail, active, onNavigate, server, search, account, children, railLabel }: AppShellProps): ReactNode;
|
|
46
|
+
export interface SearchFieldProps {
|
|
47
|
+
readonly label: string;
|
|
48
|
+
readonly placeholder?: string;
|
|
49
|
+
readonly value: string;
|
|
50
|
+
readonly onChange: (value: string) => void;
|
|
51
|
+
readonly onSearch?: (value: string) => void;
|
|
52
|
+
}
|
|
53
|
+
/** A search field with its icon; the label is for assistive technology, the placeholder shows what can be found. */
|
|
54
|
+
export declare function SearchField({ label, placeholder, value, onChange, onSearch }: SearchFieldProps): ReactNode;
|
|
55
|
+
export interface FilterOption {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly label: string;
|
|
58
|
+
}
|
|
59
|
+
export interface FilterChipsProps {
|
|
60
|
+
readonly options: readonly FilterOption[];
|
|
61
|
+
readonly value: string;
|
|
62
|
+
readonly onChange: (id: string) => void;
|
|
63
|
+
/** What the chips filter ("Show"). */
|
|
64
|
+
readonly label: string;
|
|
65
|
+
}
|
|
66
|
+
/** One of a few filters, as pills; arrow keys move between them, as a radio group does. */
|
|
67
|
+
export declare function FilterChips({ options, value, onChange, label }: FilterChipsProps): ReactNode;
|
|
68
|
+
export interface Pane {
|
|
69
|
+
/** What the pane holds, for assistive technology ("Folders", "Messages", "Message"). */
|
|
70
|
+
readonly label: string;
|
|
71
|
+
readonly content: ReactNode;
|
|
72
|
+
}
|
|
73
|
+
export interface SplitPanesProps {
|
|
74
|
+
/** Two panes (a list and what is open) or three (navigation, a list, what is open). */
|
|
75
|
+
readonly panes: readonly [Pane, Pane] | readonly [Pane, Pane, Pane];
|
|
76
|
+
/**
|
|
77
|
+
* The pane the person is in, by its index: where the selection has got to (the folders, a list, a message). At
|
|
78
|
+
* phone width only this pane shows; at tablet width it and the one before it. The last pane by default.
|
|
79
|
+
*/
|
|
80
|
+
readonly active?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Where Back goes from the active pane: the address of the pane before it, so the browser's own Back agrees. Shown
|
|
83
|
+
* only where that pane is hidden (phone, or tablet with three panes and the last one active).
|
|
84
|
+
*/
|
|
85
|
+
readonly back?: {
|
|
86
|
+
readonly label: string;
|
|
87
|
+
readonly href: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A section's panes: side by side on desktop, the active pane and the one before it on tablet, the active pane alone
|
|
92
|
+
* on phone, with Back to the one before it. The last visible pane takes the rest of the width.
|
|
93
|
+
*/
|
|
94
|
+
export declare function SplitPanes({ panes, active, back }: SplitPanesProps): ReactNode;
|
|
95
|
+
export interface MailRowProps {
|
|
96
|
+
readonly from: string;
|
|
97
|
+
readonly subject: string;
|
|
98
|
+
readonly preview: string;
|
|
99
|
+
/** When it arrived, as the reader reads it ("09:42", "Yesterday"). */
|
|
100
|
+
readonly time: string;
|
|
101
|
+
readonly unread?: boolean;
|
|
102
|
+
readonly hasAttachment?: boolean;
|
|
103
|
+
readonly selected?: boolean;
|
|
104
|
+
readonly onOpen: () => void;
|
|
105
|
+
/** Its words for assistive technology, in the app's language; each left out is English. */
|
|
106
|
+
readonly labels?: Partial<MailRowLabels>;
|
|
107
|
+
}
|
|
108
|
+
export interface MailRowLabels {
|
|
109
|
+
readonly attachment: string;
|
|
110
|
+
readonly unread: string;
|
|
111
|
+
}
|
|
112
|
+
export declare const MAIL_ROW_LABELS: MailRowLabels;
|
|
113
|
+
/** One message in a mailbox's list: who, what, the start of it, when; unread in bold with its dot. */
|
|
114
|
+
export declare function MailRow({ from, subject, preview, time, unread, hasAttachment, selected, onOpen, labels }: MailRowProps): ReactNode;
|
|
115
|
+
export interface ChatBubbleProps {
|
|
116
|
+
/** Received from someone else, or sent by this account. */
|
|
117
|
+
readonly direction: 'in' | 'out';
|
|
118
|
+
readonly children: ReactNode;
|
|
119
|
+
readonly time: string;
|
|
120
|
+
/** For a sent message: whether the other side has read it. */
|
|
121
|
+
readonly read?: boolean;
|
|
122
|
+
/** What a read message says beside its time, in the app's language ("Read"). */
|
|
123
|
+
readonly readLabel?: string;
|
|
124
|
+
}
|
|
125
|
+
/** One chat message; the corner nearest its sender is the tail. */
|
|
126
|
+
export declare function ChatBubble({ direction, children, time, read, readLabel }: ChatBubbleProps): ReactNode;
|
|
127
|
+
export interface ComposerProps {
|
|
128
|
+
/** What is being written and to whom ("Message Anna", "Quick reply to Anna Kowalska"). */
|
|
129
|
+
readonly label: string;
|
|
130
|
+
readonly value: string;
|
|
131
|
+
readonly onChange: (value: string) => void;
|
|
132
|
+
readonly onSend: () => void;
|
|
133
|
+
readonly onAttach?: () => void;
|
|
134
|
+
readonly placeholder?: string;
|
|
135
|
+
/** `chat`: one line beside its buttons; `reply`: a titled box under a message. */
|
|
136
|
+
readonly variant?: 'chat' | 'reply';
|
|
137
|
+
readonly sendLabel?: string;
|
|
138
|
+
/** The attach button's name, in the app's language ("Attach a file"). */
|
|
139
|
+
readonly attachLabel?: string;
|
|
140
|
+
/**
|
|
141
|
+
* A quick reply's own controls, at the start of its last row, before Send (an attach menu). A chat composer does not
|
|
142
|
+
* draw them. With `onAttach` as well, a reply draws both: these first, then the attach button.
|
|
143
|
+
*/
|
|
144
|
+
readonly leading?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Whether Send sends: by default, when the text is not empty. Given, it decides instead, as for a reply that may go
|
|
147
|
+
* with files and no text, or may not go over its mailbox's limit.
|
|
148
|
+
*/
|
|
149
|
+
readonly canSend?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Writing a message: the text, attaching a file, sending. Enter sends a chat message; Shift+Enter starts a new line.
|
|
153
|
+
* Enter while an input method is composing (Chinese, Japanese, Korean...) belongs to the composition and never sends.
|
|
154
|
+
*/
|
|
155
|
+
export declare function Composer({ label, value, onChange, onSend, onAttach, placeholder, variant, sendLabel, attachLabel, leading, canSend }: ComposerProps): ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** A component's words: the app's where it gives them, the default where it does not, a word given as undefined included. */
|
|
3
|
+
export declare function withDefaults<T extends object>(defaults: T, given: Partial<T> | undefined): T;
|
|
4
|
+
/** Class names, the falsy ones left out. */
|
|
5
|
+
export declare function cx(...names: ReadonlyArray<string | false | null | undefined>): string;
|
|
6
|
+
/** The kit's few glyphs, inline: no icon font, no dependency. Decorative -- the text beside them carries the meaning. */
|
|
7
|
+
export declare function Glyph({ name }: {
|
|
8
|
+
name: 'lock' | 'spinner' | 'back' | 'close' | 'warning' | 'check' | 'info';
|
|
9
|
+
}): ReactNode;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Button, type ButtonProps } from './components/Button';
|
|
2
|
+
export { TextField, Select, Toggle, type TextFieldProps, type SelectProps, type SelectOption, type ToggleProps } from './components/Fields';
|
|
3
|
+
export { Modal, ConfirmDialog, MODAL_CLOSE_MS, type ModalProps, type ConfirmDialogProps } from './components/Dialogs';
|
|
4
|
+
export { Toast, ToastRegion, Loading, EmptyState, ErrorBanner, type ToastProps, type LoadingProps, type EmptyStateProps, type ErrorBannerProps } from './components/Status';
|
|
5
|
+
export { State, STATE_DELAY_MS, type StateKind, type StatePlacement, type StateProps } from './components/State';
|
|
6
|
+
export { FileViewer, type FileViewerAction, type FileViewerEditing, type FileViewerProps, type FileViewerSiblings } from './components/FileViewer';
|
|
7
|
+
export { FilePicker, FilePickerDenied, type FilePickerBudget, type FilePickerChoice, type FilePickerEntry, type FilePickerLabels, type FilePickerPage, type FilePickerProps, type FilePickerSpace } from './components/FilePicker';
|
|
8
|
+
export { PageHeader, TabStrip, Avatar, initialsOf, tintOf, type PageHeaderProps, type Tab, type TabStripProps, type AvatarProps } from './components/Structure';
|
|
9
|
+
export { Icon, ICON_NAMES, BOOTSTRAP_ICONS, iconForName, type IconName, type IconProps } from './components/Icon';
|
|
10
|
+
export { AppShell, Badge, SearchField, FilterChips, SplitPanes, MailRow, ChatBubble, Composer, MAIL_ROW_LABELS, type MailRowLabels, type AppShellProps, type RailItem, type BadgeProps, type SearchFieldProps, type FilterChipsProps, type FilterOption, type SplitPanesProps, type Pane, type MailRowProps, type ChatBubbleProps, type ComposerProps } from './components/Workspace';
|
|
11
|
+
export { IncomingCall, CallPanel, CallBar, CALL_LABELS, type CallLabels, type IncomingCallProps, type CallPanelProps, type CallBarProps } from './components/Call';
|
|
12
|
+
export { SignInLayout, SignInForm, SIGN_IN_LABELS, type SignInLabels, type SignInLayoutProps, type SignInFormProps, type SignInFeature } from './components/SignIn';
|
|
13
|
+
export { List, ContextMenu, type ListRow, type ListProps, type MenuItem, type ContextMenuProps } from './components/Collections';
|
|
14
|
+
export { PaneToolbar, type PaneToolbarAction, type PaneToolbarProps } from './components/PaneToolbar';
|
|
15
|
+
export { offerFor, isCapability, type Capability, type Offer, type OfferOptions } from './server/capability';
|
|
16
|
+
export { readRefusal, refusalText, type Refusal } from './server/refusal';
|
|
17
|
+
export { useReread, rereadAll, type Reread } from './server/reread';
|
|
18
|
+
export { readConflict, type Conflict } from './server/conflict';
|
|
19
|
+
export { needsClientUpdate, versionBelow, CLIENT_UPDATE_REQUIRED } from './server/client-update';
|