@coolms/ui-react 0.1.0-alpha.4 → 0.1.0-alpha.40
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 +364 -4
- package/design-tokens.lock.json +14 -6
- package/dist/components/Button.d.ts +6 -3
- package/dist/components/Call.d.ts +3 -1
- package/dist/components/Collections.d.ts +24 -6
- package/dist/components/Column.d.ts +21 -0
- package/dist/components/Dialogs.d.ts +6 -2
- package/dist/components/Fields.d.ts +59 -4
- package/dist/components/FilePicker.d.ts +91 -0
- package/dist/components/FileViewer.d.ts +106 -0
- package/dist/components/FilterMenu.d.ts +51 -0
- package/dist/components/Icon.d.ts +18 -1
- package/dist/components/ListHead.d.ts +15 -0
- package/dist/components/Notification.d.ts +38 -0
- package/dist/components/PaneToolbar.d.ts +83 -0
- package/dist/components/ScreenShell.d.ts +110 -0
- package/dist/components/SectionHeader.d.ts +95 -0
- package/dist/components/SignIn.d.ts +1 -1
- package/dist/components/Splitter.d.ts +38 -0
- package/dist/components/State.d.ts +33 -0
- package/dist/components/Structure.d.ts +34 -4
- package/dist/components/Workspace.d.ts +84 -20
- package/dist/components/pull.d.ts +21 -0
- package/dist/components/tipDismissal.d.ts +14 -0
- package/dist/index.d.ts +27 -15
- package/dist/index.js +2511 -732
- package/kit.contract.json +15 -5
- package/package.json +10 -5
- package/src/kit.css +401 -41
- package/src/tokens/coolms-tokens.css +26 -0
|
@@ -9,20 +9,75 @@ interface FieldFrame {
|
|
|
9
9
|
/** Shown, focusable and copyable, but not changed here. */
|
|
10
10
|
readonly readOnly?: boolean;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
/** The native kinds of one line: each brings the device's own keyboard or picker and its accessibility. */
|
|
13
|
+
export type TextFieldType = 'text' | 'email' | 'url' | 'search' | 'tel' | 'password' | 'number' | 'date' | 'time' | 'datetime-local';
|
|
14
|
+
/** What the server declares about a value: its bounds, its step and its length. */
|
|
15
|
+
interface Constraints {
|
|
16
|
+
/** The least value: a number, or an ISO date or time for the date and time types. */
|
|
17
|
+
readonly min?: string | number;
|
|
18
|
+
/** The greatest value, as `min`. */
|
|
19
|
+
readonly max?: string | number;
|
|
20
|
+
/** The step between values (`any` for none): seconds for `time` and `datetime-local`, days for `date`. */
|
|
21
|
+
readonly step?: number | 'any';
|
|
22
|
+
readonly minLength?: number;
|
|
23
|
+
readonly maxLength?: number;
|
|
24
|
+
/** A value is needed: marked for assistive technology, and checked by the browser on submit. */
|
|
25
|
+
readonly required?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface TextFieldProps extends FieldFrame, Constraints {
|
|
28
|
+
/** The value as the input holds it: digits for `number`, ISO for the date and time types (`2026-11-18`, `14:30`, `2026-11-18T14:30`). */
|
|
13
29
|
readonly value: string;
|
|
14
30
|
readonly onChange?: (value: string) => void;
|
|
15
31
|
readonly placeholder?: string;
|
|
16
|
-
readonly type?:
|
|
32
|
+
readonly type?: TextFieldType;
|
|
33
|
+
/**
|
|
34
|
+
* The person's locale (BCP 47, from their settings): the field's language, and how a read-only or pinned date or
|
|
35
|
+
* time is written out. An editable date or time is the device's own picker.
|
|
36
|
+
*/
|
|
37
|
+
readonly locale?: string;
|
|
17
38
|
/**
|
|
18
39
|
* The value is set by the environment, not here (a pinned setting): shown read-only with why, the way the admin
|
|
19
40
|
* shows a key the deployment pins.
|
|
20
41
|
*/
|
|
21
42
|
readonly pinned?: ReactNode;
|
|
22
43
|
readonly name?: string;
|
|
44
|
+
/** What the browser may fill the field with (`new-password`, `email`, `off`), as the server declares it. */
|
|
45
|
+
readonly autoComplete?: string;
|
|
46
|
+
/**
|
|
47
|
+
* A password field's show and hide button, by its two names: an eye at the field's end that shows what is typed and
|
|
48
|
+
* hides it again. Its name says what a press does next (show, then hide), so it is a plain button, not a pressed
|
|
49
|
+
* toggle. Without the names a password field has none.
|
|
50
|
+
*/
|
|
51
|
+
readonly reveal?: {
|
|
52
|
+
readonly show: string;
|
|
53
|
+
readonly hide: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A date or time value written out in a locale, as the wall-clock value it is (no time zone is applied); the value
|
|
58
|
+
* itself when it is not one the type holds, or names no real date or time (a 30 February, a 25th hour).
|
|
59
|
+
*/
|
|
60
|
+
export declare function writtenOut(type: TextFieldType, value: string, locale: string | undefined): string;
|
|
61
|
+
/**
|
|
62
|
+
* One line of text (contract component `text-field`: default, focused, disabled, read-only, invalid, pinned), of any
|
|
63
|
+
* native kind: a number, a date, a time or both bring the device's keyboard or picker. The server's constraints are the
|
|
64
|
+
* input's own (`min`, `max`, `step`, `minlength`, `maxlength`, `required`). A date or time that is read-only or pinned
|
|
65
|
+
* is written out in the person's locale, and keeps its ISO value in `data-value`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function TextField({ label, help, error, disabled, readOnly, pinned, value, onChange, placeholder, type, name, locale, min, max, step, minLength, maxLength, required, autoComplete, reveal }: TextFieldProps): ReactNode;
|
|
68
|
+
export interface TextAreaProps extends FieldFrame, Pick<Constraints, 'minLength' | 'maxLength' | 'required'> {
|
|
69
|
+
readonly value: string;
|
|
70
|
+
readonly onChange?: (value: string) => void;
|
|
71
|
+
readonly placeholder?: string;
|
|
72
|
+
/** The lines it shows before it scrolls (4 by default); the person may make it taller. */
|
|
73
|
+
readonly rows?: number;
|
|
74
|
+
/** The person's locale (BCP 47): the field's language, for spelling and the input method. */
|
|
75
|
+
readonly locale?: string;
|
|
76
|
+
readonly pinned?: ReactNode;
|
|
77
|
+
readonly name?: string;
|
|
23
78
|
}
|
|
24
|
-
/**
|
|
25
|
-
export declare function
|
|
79
|
+
/** Several lines of text: the text field's frame and states (`text-field`), with the server's length and need. */
|
|
80
|
+
export declare function TextArea({ label, help, error, disabled, readOnly, pinned, value, onChange, placeholder, rows, name, locale, minLength, maxLength, required }: TextAreaProps): ReactNode;
|
|
26
81
|
export interface SelectOption {
|
|
27
82
|
readonly value: string;
|
|
28
83
|
readonly label: string;
|
|
@@ -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;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type MenuItem } from './Collections.js';
|
|
3
|
+
export interface FilterOption {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FilterMenuLabels {
|
|
8
|
+
/** The button's accessible name and tooltip: what it filters and the current choice. */
|
|
9
|
+
readonly name: (label: string, choice: string) => string;
|
|
10
|
+
}
|
|
11
|
+
/** The English words; an app passes its own. */
|
|
12
|
+
export declare const FILTER_MENU_LABELS: FilterMenuLabels;
|
|
13
|
+
/** A list's one filter: its choices and the current one. */
|
|
14
|
+
export interface ListFilter {
|
|
15
|
+
/** What it filters, in the accessible name before the current choice ("Show"). */
|
|
16
|
+
readonly label: string;
|
|
17
|
+
/** The choices shown, in the declared order; the host keeps the current one in them while it is current. */
|
|
18
|
+
readonly options: readonly FilterOption[];
|
|
19
|
+
/**
|
|
20
|
+
* The current choice's id. One that names no option reads as the default one, and says so once, by `onChange`; while
|
|
21
|
+
* there are no options at all the choices are not known yet, and nothing is said.
|
|
22
|
+
*/
|
|
23
|
+
readonly value: string;
|
|
24
|
+
/** The id of the choice that shows every row; not given, or naming no option, the first. */
|
|
25
|
+
readonly defaultValue?: string;
|
|
26
|
+
/** The chosen choice's id, when it differs from the current one. */
|
|
27
|
+
readonly onChange: (id: string) => void;
|
|
28
|
+
readonly labels?: Partial<FilterMenuLabels>;
|
|
29
|
+
}
|
|
30
|
+
export interface FilterMenuProps extends ListFilter {
|
|
31
|
+
/** The funnel alone, in the accent on a choice other than the default: for a bar whose title says the choice. */
|
|
32
|
+
readonly iconOnly?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The choice other than the default one, or null: on the default choice, or with no other to choose from. */
|
|
35
|
+
export declare function activeChoice(filter: ListFilter): FilterOption | null;
|
|
36
|
+
/** What the filter filters and its current choice, in the host's words. */
|
|
37
|
+
export declare function filterName(filter: ListFilter): string;
|
|
38
|
+
/** The choices as a menu's items, a single choice; `group` draws them under its name, among other items. */
|
|
39
|
+
export declare function choiceItems(filter: ListFilter, group?: string): readonly MenuItem[];
|
|
40
|
+
/** Says the default choice to the host, once for each value that names no option; with no options, nothing yet. */
|
|
41
|
+
export declare function useStaleChoice(filter: ListFilter | undefined): void;
|
|
42
|
+
/** The menu button with its menu; nothing with fewer than two choices. Who draws it calls useStaleChoice. */
|
|
43
|
+
export declare function FilterButton({ iconOnly, onOpenChange, ...filter }: FilterMenuProps & {
|
|
44
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
45
|
+
}): ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* A list's one filter as a menu button (contract component `filter-menu`: default, active, open, focused). On the
|
|
48
|
+
* default choice the funnel alone; on any other that choice's name and a chevron in the accent, so a filtered list
|
|
49
|
+
* always says so. Its menu is a single choice, the current one marked. With fewer than two choices nothing is drawn.
|
|
50
|
+
*/
|
|
51
|
+
export declare function FilterMenu(props: FilterMenuProps): 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' | 'funnel' | 'eye' | 'eye-off';
|
|
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,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type ListFilter } from './FilterMenu.js';
|
|
3
|
+
export interface ListHeadProps {
|
|
4
|
+
/** Before the name: the list's select-all box. */
|
|
5
|
+
readonly leading?: ReactNode;
|
|
6
|
+
/** The list's name: a folder's, or what the list holds. */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** The list's filter, at the row's end. */
|
|
9
|
+
readonly filter?: ListFilter;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A list's second row (contract pane-toolbar, header row): the name on one line at the start, cut with an ellipsis, its
|
|
13
|
+
* whole text as its title, and the list's filter at the end, whole at every width. The row's padding is the host's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ListHead({ leading, name, filter }: ListHeadProps): 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,83 @@
|
|
|
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, unless it
|
|
29
|
+
* is the only action behind ...: then it is a button at the end of the row.
|
|
30
|
+
*/
|
|
31
|
+
readonly overflow?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The row's declared primary (a folder's Upload): it keeps its label longest and goes behind ... last, first in its
|
|
34
|
+
* menu. One per row: where more than one says so, the first is.
|
|
35
|
+
*/
|
|
36
|
+
readonly primary?: boolean;
|
|
37
|
+
/** Shown, kept in the focus order, and doing nothing when chosen; `reason` is its tooltip. */
|
|
38
|
+
readonly disabled?: boolean;
|
|
39
|
+
readonly reason?: string;
|
|
40
|
+
/** Its work is under way: a spinner in its icon's place after a moment, and a second press runs nothing. */
|
|
41
|
+
readonly busy?: boolean;
|
|
42
|
+
/** The delete kind: drawn as danger, the only action that is. */
|
|
43
|
+
readonly danger?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* A menu button (New with its chevron): its node's children, in the tree's order, as its menu's entries. The action
|
|
46
|
+
* opens the menu, and choosing an entry says the entry's id. With no entry to show the action is not drawn at all.
|
|
47
|
+
*/
|
|
48
|
+
readonly entries?: readonly PaneToolbarEntry[];
|
|
49
|
+
}
|
|
50
|
+
export interface PaneToolbarProps {
|
|
51
|
+
/** The toolbar's accessible name, in the host's words ("Message actions"). */
|
|
52
|
+
readonly label: string;
|
|
53
|
+
/** The actions in their order; the host passes only those it has a handler for. */
|
|
54
|
+
readonly actions: readonly PaneToolbarAction[];
|
|
55
|
+
/** An action was chosen, in the row or behind ...; never for a disabled or busy one. */
|
|
56
|
+
readonly onAction: (id: string) => void;
|
|
57
|
+
/** The trailing status, formatted by the host ("Synced at 14:32"); truncated with its whole text as its title. */
|
|
58
|
+
readonly status?: string;
|
|
59
|
+
/** The ... button's accessible name and tooltip, from the host's catalogue ("More actions"). */
|
|
60
|
+
readonly moreLabel: string;
|
|
61
|
+
/** Navigation that leads the row where one pane shows at a time (Back): before the first group, never behind .... */
|
|
62
|
+
readonly leading?: ReactNode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The one row of actions at the top of a pane (contract component `pane-toolbar`: default, labels-partly-hidden,
|
|
66
|
+
* labels-hidden, overflowing, menu-open, with-status, action-disabled, action-busy, phone, lone-menu-only). It is
|
|
67
|
+
* measured on its own width as its pane resizes, and gives way in this order:
|
|
68
|
+
* every label shows while all fit; then the labels of the actions that are not the primary hide one by one in the
|
|
69
|
+
* giving-way order (by overflow, lower first, a priority's actions together; then the pinned, from the end of the row
|
|
70
|
+
* back); then the primary's label; only once every label is hidden do actions go behind ..., in the same order, the
|
|
71
|
+
* fewest that let the rest and ... fit, and the primary last. No action is ever cut off, and ... is always reached.
|
|
72
|
+
* They come back in the reverse order. One Tab stop; Left and Right, Home and End move inside it.
|
|
73
|
+
*
|
|
74
|
+
* ... never holds one action: the first move into it takes two, or one beside a menu-only action, and where only one
|
|
75
|
+
* could go, it stays in the row at its icon width. Its menu lists the primary first, then those that gave way, in their
|
|
76
|
+
* order, then the menu-only actions (overflow 0) last. Menu-only actions are behind ... at every width, except a single
|
|
77
|
+
* one with nothing else behind ...: that one is a button at the end of the row, giving way first.
|
|
78
|
+
*
|
|
79
|
+
* An action with `entries` is a menu button: its chevron after it, it opens the kit's context menu with its entries,
|
|
80
|
+
* each disabled with its own reason as the server says, and it gives way as any other action does (behind ..., choosing
|
|
81
|
+
* it opens its entries there). One whose entries are empty is not drawn; one that is itself disabled does not open.
|
|
82
|
+
*/
|
|
83
|
+
export declare function PaneToolbar({ label, actions: given, onAction, status, moreLabel, leading }: PaneToolbarProps): ReactNode;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type MenuItem } from './Collections.js';
|
|
3
|
+
import { type IconName } from './Icon.js';
|
|
4
|
+
import { type ListFilter } from './FilterMenu.js';
|
|
5
|
+
import type { Offer } from '../server/capability.js';
|
|
6
|
+
/**
|
|
7
|
+
* The screen's floating primary action: one action, or a menu of declared entries. A single action carries the server's
|
|
8
|
+
* answer: not offered, it is not drawn; refused, it stays, greyed, and a press shows the server's sentence instead of
|
|
9
|
+
* running it.
|
|
10
|
+
*/
|
|
11
|
+
export type ScreenPrimary = {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly icon: IconName;
|
|
14
|
+
readonly onPress: () => void;
|
|
15
|
+
readonly offer?: Offer;
|
|
16
|
+
} | {
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly icon: IconName;
|
|
19
|
+
readonly menu: readonly MenuItem[];
|
|
20
|
+
};
|
|
21
|
+
export interface ScreenShellProps {
|
|
22
|
+
/** The current place's name. */
|
|
23
|
+
readonly title: string;
|
|
24
|
+
/** On a nested screen: where Back leads, named by the parent's name. Absent at a section's root. */
|
|
25
|
+
readonly back?: {
|
|
26
|
+
readonly label: string;
|
|
27
|
+
readonly href?: string;
|
|
28
|
+
readonly onBack?: () => void;
|
|
29
|
+
};
|
|
30
|
+
/** At a section's root: the section's own navigation (mail's folders), an icon button the host supplies. */
|
|
31
|
+
readonly navigation?: ReactNode;
|
|
32
|
+
/** The section's search, an icon button. */
|
|
33
|
+
readonly search?: {
|
|
34
|
+
readonly label: string;
|
|
35
|
+
readonly onOpen: () => void;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* While the section's search is open: the bar is Close, then the host's search field in place of the title and the
|
|
39
|
+
* icons, until Close (or the host) ends it.
|
|
40
|
+
*/
|
|
41
|
+
readonly searching?: {
|
|
42
|
+
readonly field: ReactNode;
|
|
43
|
+
readonly closeLabel: string;
|
|
44
|
+
readonly onClose: () => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The section's secondary actions, the entries the section header shows under its More, in the tree's order; a
|
|
48
|
+
* refused one stays, with the server's reason. With none shown, no More; never on an item's own screen.
|
|
49
|
+
*/
|
|
50
|
+
readonly more?: readonly MenuItem[];
|
|
51
|
+
/** More's accessible name and tooltip, from the host's catalogue. */
|
|
52
|
+
readonly moreLabel?: string;
|
|
53
|
+
/** The shell's own icons, the same in every section: the bell, then the person's avatar. */
|
|
54
|
+
readonly globals?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* The list's filter: an icon in the bar, after the search. On a choice other than the default the icon takes the
|
|
57
|
+
* accent, and the title reads the place's name and the choice's. In a bar too narrow to show 64px of the name
|
|
58
|
+
* (or all of a shorter one) beside the choice's, it moves into More, while More is drawn for other actions.
|
|
59
|
+
*/
|
|
60
|
+
readonly filter?: ListFilter;
|
|
61
|
+
/** The floating primary action, given only when the server declares it; never on an item's own screen. */
|
|
62
|
+
readonly primary?: ScreenPrimary;
|
|
63
|
+
/** With it the content takes the pull: the refresh, and while it runs the refreshing state. */
|
|
64
|
+
readonly onRefresh?: () => Promise<unknown>;
|
|
65
|
+
/** What the pull says while pulled: the time of the last sync. */
|
|
66
|
+
readonly pullText?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the bar is out of view. Not given, the shell decides: out while the content, or any pane in it, scrolls
|
|
69
|
+
* down past the bar's own height; back on any scroll up, at the top, or when focus moves into the bar. Never while
|
|
70
|
+
* searching, pulling or refreshing, or while the filter's menu or More's is open, whatever is given.
|
|
71
|
+
*/
|
|
72
|
+
readonly barHidden?: boolean;
|
|
73
|
+
/** The screen's content: it scrolls on its own; a list in it draws the pull. */
|
|
74
|
+
readonly children: ReactNode;
|
|
75
|
+
}
|
|
76
|
+
/** A bar's widths, none of them the widths its parts have been given: the same bar always has the same ones. */
|
|
77
|
+
export interface BarWidths {
|
|
78
|
+
/** The bar's room, its padding left out. */
|
|
79
|
+
readonly bar: number;
|
|
80
|
+
/** The least width of what leads, 0 for nothing. */
|
|
81
|
+
readonly leading: number;
|
|
82
|
+
/** The gap between what leads, the title and the icons. */
|
|
83
|
+
readonly gap: number;
|
|
84
|
+
/** One icon of the bar, and the gap between two. */
|
|
85
|
+
readonly icon: number;
|
|
86
|
+
readonly iconGap: number;
|
|
87
|
+
/** The icons the bar has beside the filter's. */
|
|
88
|
+
readonly search: boolean;
|
|
89
|
+
readonly more: boolean;
|
|
90
|
+
readonly globals: readonly number[];
|
|
91
|
+
/** The place's name, whole. */
|
|
92
|
+
readonly name: number;
|
|
93
|
+
/** The choice's name with its middle dot, whole; 0 while the list is not filtered. */
|
|
94
|
+
readonly choice: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether the filter goes into More: the bar with the filter in it leaves the title less than its least (64px of the
|
|
98
|
+
* place's name, or all of a shorter one, and the choice's name whole while the list is filtered), and More is drawn for
|
|
99
|
+
* other actions. It reads no width that the answer changes, so one width of the bar has one answer.
|
|
100
|
+
*/
|
|
101
|
+
export declare function filterGoesIntoMore({ bar, leading, gap, icon, iconGap, search, more, globals, name, choice }: BarWidths): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* One screen of a section at phone width (contract component `screen-shell`: root, nested, with-filter, filtered,
|
|
104
|
+
* filter-in-more, with-primary-action, with-primary-menu, with-more, pulling, refreshing, searching, bar-hidden). One bar: the section's
|
|
105
|
+
* navigation or Back with the parent's name, the title (with the filter's choice while it is not the default), then
|
|
106
|
+
* search, the filter, More and the shell's own icons, or while searching, Close and the field; the content, which
|
|
107
|
+
* scrolls on its own and refreshes by a pull from its top; the primary action floating at the bottom right, its menu
|
|
108
|
+
* opening above it. What fills each slot is the host's, from the server's declared nodes.
|
|
109
|
+
*/
|
|
110
|
+
export declare function ScreenShell({ title, back, navigation, search, searching, more, moreLabel, globals, filter, primary: declared, onRefresh, pullText, barHidden, children }: ScreenShellProps): ReactNode;
|