@coolms/ui-react 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +212 -4
- package/design-tokens.lock.json +26 -6
- package/dist/components/Call.d.ts +71 -0
- package/dist/components/Collections.d.ts +14 -5
- package/dist/components/Dialogs.d.ts +11 -3
- package/dist/components/Fields.d.ts +48 -4
- package/dist/components/FilePicker.d.ts +83 -0
- package/dist/components/FileViewer.d.ts +106 -0
- package/dist/components/Icon.d.ts +29 -0
- package/dist/components/Notification.d.ts +38 -0
- package/dist/components/PaneToolbar.d.ts +57 -0
- package/dist/components/ScreenShell.d.ts +65 -0
- package/dist/components/SignIn.d.ts +46 -0
- package/dist/components/State.d.ts +31 -0
- package/dist/components/Status.d.ts +6 -2
- package/dist/components/Structure.d.ts +24 -4
- package/dist/components/Workspace.d.ts +185 -0
- package/dist/components/internal.d.ts +2 -0
- package/dist/components/pull.d.ts +21 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.js +1842 -380
- package/kit.contract.json +9 -3
- package/package.json +9 -6
- 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 +478 -6
- package/src/tokens/coolms-tokens.css +95 -3
|
@@ -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;
|
|
@@ -0,0 +1,29 @@
|
|
|
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' | 'file-code' | 'mail-open' | 'copy' | 'user' | 'folder-plus' | 'folder-x' | 'user-check' | 'user-x';
|
|
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: 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,57 @@
|
|
|
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 goes behind ... only in a row too narrow to hold it with the rest, the last in
|
|
17
|
+
* the row first, so that nothing is cut off. 0: menu only, behind ... at every width and never in the row.
|
|
18
|
+
*/
|
|
19
|
+
readonly overflow?: number;
|
|
20
|
+
/** Shown, kept in the focus order, and doing nothing when chosen; `reason` is its tooltip. */
|
|
21
|
+
readonly disabled?: boolean;
|
|
22
|
+
readonly reason?: string;
|
|
23
|
+
/** Its work is under way: a spinner in its icon's place after a moment, and a second press runs nothing. */
|
|
24
|
+
readonly busy?: boolean;
|
|
25
|
+
/** The delete kind: drawn as danger, the only action that is. */
|
|
26
|
+
readonly danger?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PaneToolbarProps {
|
|
29
|
+
/** The toolbar's accessible name, in the host's words ("Message actions"). */
|
|
30
|
+
readonly label: string;
|
|
31
|
+
/** The actions in their order; the host passes only those it has a handler for. */
|
|
32
|
+
readonly actions: readonly PaneToolbarAction[];
|
|
33
|
+
/** An action was chosen, in the row or behind ...; never for a disabled or busy one. */
|
|
34
|
+
readonly onAction: (id: string) => void;
|
|
35
|
+
/** The trailing status, formatted by the host ("Synced at 14:32"); truncated with its whole text as its title. */
|
|
36
|
+
readonly status?: string;
|
|
37
|
+
/** The ... button's accessible name and tooltip, from the host's catalogue ("More actions"). */
|
|
38
|
+
readonly moreLabel: string;
|
|
39
|
+
/** Navigation that leads the row where one pane shows at a time (Back): before the first group, never behind .... */
|
|
40
|
+
readonly leading?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The one row of actions at the top of a pane (contract component `pane-toolbar`: default, labels-partly-hidden,
|
|
44
|
+
* labels-hidden, overflowing, menu-open, with-status, action-disabled, action-busy, phone). It is measured on its own
|
|
45
|
+
* width as its pane resizes:
|
|
46
|
+
* every label shows while all fit; then labels hide one by one in the overflow order (lower first, a priority's actions
|
|
47
|
+
* together), the pinned last, from the end of the row; only once every label is hidden do actions go behind ..., in
|
|
48
|
+
* the same order, the fewest that let the rest and ... fit, never one alone while another can go with it. Where the
|
|
49
|
+
* pinned and ... still do not fit, the pinned go behind ... too, from the end of the row: no action is ever cut off,
|
|
50
|
+
* and ... is always reached. They come back in the reverse order. One Tab stop; Left and Right, Home and End move
|
|
51
|
+
* inside it.
|
|
52
|
+
*
|
|
53
|
+
* Menu-only actions (overflow 0) are behind ... at every width, first in its menu, and take no part in the giving way:
|
|
54
|
+
* their labels are not counted, and "never one alone" counts only the actions that could have stayed in the row. ...
|
|
55
|
+
* is drawn for them even when one is alone.
|
|
56
|
+
*/
|
|
57
|
+
export declare function PaneToolbar({ label, actions, onAction, status, moreLabel, leading }: PaneToolbarProps): ReactNode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type MenuItem } from './Collections';
|
|
3
|
+
import { type IconName } from './Icon';
|
|
4
|
+
import { type FilterOption } from './Workspace';
|
|
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
|
+
/** The screen's content: it scrolls on its own; a list in it draws the pull. */
|
|
56
|
+
readonly children: ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One screen of a section at phone width (contract component `screen-shell`: root, nested, with-filters,
|
|
60
|
+
* with-primary-action, with-primary-menu, pulling, refreshing, searching). One bar: the section's navigation or Back
|
|
61
|
+
* 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
|
|
62
|
+
* scrolls on its own and refreshes by a pull from its top; the primary action floating at the bottom right, its menu
|
|
63
|
+
* opening above it. What fills each slot is the host's, from the server's declared nodes.
|
|
64
|
+
*/
|
|
65
|
+
export declare function ScreenShell({ title, back, navigation, search, searching, globals, filters, primary, onRefresh, pullText, children }: ScreenShellProps): 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;
|
|
@@ -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,11 +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;
|
|
63
|
+
/** Which of the six avatar tints a name takes: the same name always the same tint. */
|
|
64
|
+
export declare function tintOf(name: string): number;
|
|
45
65
|
/** A person or an account, by picture or initials (contract component `avatar`: picture, initials, presence). */
|
|
46
|
-
export declare function Avatar({ name, pictureUrl, presence, size }: AvatarProps): ReactNode;
|
|
66
|
+
export declare function Avatar({ name, pictureUrl, presence, connection, deleted, size }: AvatarProps): ReactNode;
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
/** A pane the person may make wider or narrower, in px: where it is, its limits, its default, and its splitter's name. */
|
|
74
|
+
export interface PaneSize {
|
|
75
|
+
readonly width: number;
|
|
76
|
+
readonly min: number;
|
|
77
|
+
readonly max: number;
|
|
78
|
+
/** The width a double-click or Enter on its splitter puts it back to. */
|
|
79
|
+
readonly reset: number;
|
|
80
|
+
/** The splitter's name, in the app's language ("Resize folders"). */
|
|
81
|
+
readonly label: string;
|
|
82
|
+
}
|
|
83
|
+
export interface SplitPanesProps {
|
|
84
|
+
/** Two panes (a list and what is open) or three (navigation, a list, what is open). */
|
|
85
|
+
readonly panes: readonly [Pane, Pane] | readonly [Pane, Pane, Pane];
|
|
86
|
+
/**
|
|
87
|
+
* The pane the person is in, by its index: where the selection has got to (the folders, a list, a message). At
|
|
88
|
+
* phone width only this pane shows; at tablet width it and the one before it. The last pane by default.
|
|
89
|
+
*/
|
|
90
|
+
readonly active?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Where Back goes from the active pane: the address of the pane before it, so the browser's own Back agrees. Shown
|
|
93
|
+
* only where that pane is hidden (phone, or tablet with three panes and the last one active).
|
|
94
|
+
*/
|
|
95
|
+
readonly back?: {
|
|
96
|
+
readonly label: string;
|
|
97
|
+
readonly href: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Sizes for the panes before the last, by index: each one given draws a splitter after its pane where every pane
|
|
101
|
+
* shows (the desktop grid). The caller keeps the widths; the last pane takes the rest.
|
|
102
|
+
*/
|
|
103
|
+
readonly sizes?: readonly (PaneSize | undefined)[];
|
|
104
|
+
/** The last pane's least width while splitters move and the window narrows (360 by default). */
|
|
105
|
+
readonly lastMin?: number;
|
|
106
|
+
/**
|
|
107
|
+
* A splitter moved pane `index` to `width`: while it is dragged (`done` false), and once more when the drag or the
|
|
108
|
+
* key ends (`done` true), which is when a width is worth keeping.
|
|
109
|
+
*/
|
|
110
|
+
readonly onResize?: (index: number, width: number, done: boolean) => void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The widths the panes take in `room` px: each as wanted within its limits; when the last pane would be under its
|
|
114
|
+
* least width, the pane nearest it gives way first, down to its own least, then the one before.
|
|
115
|
+
*/
|
|
116
|
+
export declare function fitPanes(wanted: readonly PaneSize[], room: number, lastMin: number): number[];
|
|
117
|
+
/**
|
|
118
|
+
* Two or three panes side by side (contract `split-panes`), showing fewer as the window narrows. With `sizes`, the
|
|
119
|
+
* panes before the last are resizable where all of them show (contract `pane splitter`): each has a splitter, a
|
|
120
|
+
* separator dragged by mouse or touch, moved 16 px by the arrow keys, taken to its limits by Home and End, and put back
|
|
121
|
+
* by a double-click or Enter. The last pane is never narrower than `lastMin`; as the window narrows the pane nearest it
|
|
122
|
+
* gives way first.
|
|
123
|
+
*/
|
|
124
|
+
export declare function SplitPanes({ panes, active, back, sizes, lastMin, onResize }: SplitPanesProps): ReactNode;
|
|
125
|
+
export interface MailRowProps {
|
|
126
|
+
readonly from: string;
|
|
127
|
+
readonly subject: string;
|
|
128
|
+
readonly preview: string;
|
|
129
|
+
/** When it arrived, as the reader reads it ("09:42", "Yesterday"). */
|
|
130
|
+
readonly time: string;
|
|
131
|
+
readonly unread?: boolean;
|
|
132
|
+
readonly hasAttachment?: boolean;
|
|
133
|
+
readonly selected?: boolean;
|
|
134
|
+
readonly onOpen: () => void;
|
|
135
|
+
/** Its words for assistive technology, in the app's language; each left out is English. */
|
|
136
|
+
readonly labels?: Partial<MailRowLabels>;
|
|
137
|
+
}
|
|
138
|
+
export interface MailRowLabels {
|
|
139
|
+
readonly attachment: string;
|
|
140
|
+
readonly unread: string;
|
|
141
|
+
}
|
|
142
|
+
export declare const MAIL_ROW_LABELS: MailRowLabels;
|
|
143
|
+
/** One message in a mailbox's list: who, what, the start of it, when; unread in bold with its dot. */
|
|
144
|
+
export declare function MailRow({ from, subject, preview, time, unread, hasAttachment, selected, onOpen, labels }: MailRowProps): ReactNode;
|
|
145
|
+
export interface ChatBubbleProps {
|
|
146
|
+
/** Received from someone else, or sent by this account. */
|
|
147
|
+
readonly direction: 'in' | 'out';
|
|
148
|
+
readonly children: ReactNode;
|
|
149
|
+
readonly time: string;
|
|
150
|
+
/** For a sent message: whether the other side has read it. */
|
|
151
|
+
readonly read?: boolean;
|
|
152
|
+
/** What a read message says beside its time, in the app's language ("Read"). */
|
|
153
|
+
readonly readLabel?: string;
|
|
154
|
+
}
|
|
155
|
+
/** One chat message; the corner nearest its sender is the tail. */
|
|
156
|
+
export declare function ChatBubble({ direction, children, time, read, readLabel }: ChatBubbleProps): ReactNode;
|
|
157
|
+
export interface ComposerProps {
|
|
158
|
+
/** What is being written and to whom ("Message Anna", "Quick reply to Anna Kowalska"). */
|
|
159
|
+
readonly label: string;
|
|
160
|
+
readonly value: string;
|
|
161
|
+
readonly onChange: (value: string) => void;
|
|
162
|
+
readonly onSend: () => void;
|
|
163
|
+
readonly onAttach?: () => void;
|
|
164
|
+
readonly placeholder?: string;
|
|
165
|
+
/** `chat`: one line beside its buttons; `reply`: a titled box under a message. */
|
|
166
|
+
readonly variant?: 'chat' | 'reply';
|
|
167
|
+
readonly sendLabel?: string;
|
|
168
|
+
/** The attach button's name, in the app's language ("Attach a file"). */
|
|
169
|
+
readonly attachLabel?: string;
|
|
170
|
+
/**
|
|
171
|
+
* A quick reply's own controls, at the start of its last row, before Send (an attach menu). A chat composer does not
|
|
172
|
+
* draw them. With `onAttach` as well, a reply draws both: these first, then the attach button.
|
|
173
|
+
*/
|
|
174
|
+
readonly leading?: ReactNode;
|
|
175
|
+
/**
|
|
176
|
+
* Whether Send sends: by default, when the text is not empty. Given, it decides instead, as for a reply that may go
|
|
177
|
+
* with files and no text, or may not go over its mailbox's limit.
|
|
178
|
+
*/
|
|
179
|
+
readonly canSend?: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Writing a message: the text, attaching a file, sending. Enter sends a chat message; Shift+Enter starts a new line.
|
|
183
|
+
* Enter while an input method is composing (Chinese, Japanese, Korean...) belongs to the composition and never sends.
|
|
184
|
+
*/
|
|
185
|
+
export declare function Composer({ label, value, onChange, onSend, onAttach, placeholder, variant, sendLabel, attachLabel, leading, canSend }: ComposerProps): ReactNode;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
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;
|
|
2
4
|
/** Class names, the falsy ones left out. */
|
|
3
5
|
export declare function cx(...names: ReadonlyArray<string | false | null | undefined>): string;
|
|
4
6
|
/** The kit's few glyphs, inline: no icon font, no dependency. Decorative -- the text beside them carries the meaning. */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode, type RefObject } from 'react';
|
|
2
|
+
/** How far down a pull has to go before letting go refreshes, in px (contract screen-shell, pull). */
|
|
3
|
+
export declare const PULL_AT = 64;
|
|
4
|
+
/**
|
|
5
|
+
* Pull to refresh on a scroll region at its top: a touch dragged down from the very top shows how far it has gone (up
|
|
6
|
+
* to half again the threshold) and, let go past the threshold, calls `onPull`. A drag that starts lower, or goes up,
|
|
7
|
+
* is the region's own scroll. Returns how far it is pulled now, 0 at rest.
|
|
8
|
+
*/
|
|
9
|
+
export declare function usePull(region: RefObject<HTMLElement | null>, onPull: (() => void) | null): number;
|
|
10
|
+
/** The content's pull, as the shell has it: a list inside draws it as its `pulled` state. */
|
|
11
|
+
export interface PullState {
|
|
12
|
+
/** How far it is pulled now, in px; 0 at rest. */
|
|
13
|
+
readonly distance: number;
|
|
14
|
+
/** The refresh it started is under way. */
|
|
15
|
+
readonly refreshing: boolean;
|
|
16
|
+
/** What the pull says while pulled: the time of the last sync. */
|
|
17
|
+
readonly text: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const PullContext: import("react").Context<PullState | null>;
|
|
20
|
+
/** The pull of the screen around a list, or null outside a screen that takes one. */
|
|
21
|
+
export declare function usePullState(): PullState | null;
|