@coolms/ui-react 0.1.0-alpha.3 → 0.1.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type IconName } from './Icon';
2
+ import { type IconName } from './Icon.js';
3
3
  export interface BadgeProps {
4
4
  readonly count: number;
5
5
  /** What the number counts, for a screen reader ("12 unread"). */
@@ -35,12 +35,14 @@ export interface AppShellProps {
35
35
  /** Notifications and the account, at the right of the top bar. */
36
36
  readonly account?: ReactNode;
37
37
  readonly children: ReactNode;
38
+ /** The rail's name for assistive technology, in the app's language ("Sections"). */
39
+ readonly railLabel?: string;
38
40
  }
39
41
  /**
40
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
41
43
  * the server, the search and the account. The open section is marked for assistive technology as the current page.
42
44
  */
43
- export declare function AppShell({ product, mark, rail, active, onNavigate, server, search, account, children }: AppShellProps): ReactNode;
45
+ export declare function AppShell({ product, mark, rail, active, onNavigate, server, search, account, children, railLabel }: AppShellProps): ReactNode;
44
46
  export interface SearchFieldProps {
45
47
  readonly label: string;
46
48
  readonly placeholder?: string;
@@ -61,13 +63,26 @@ export interface FilterChipsProps {
61
63
  /** What the chips filter ("Show"). */
62
64
  readonly label: string;
63
65
  }
64
- /** One of a few filters, as pills; arrow keys move between them, as a radio group does. */
66
+ /**
67
+ * One of a few filters, as pills; arrow keys move between them, as a radio group does. Chips are never cut off: those
68
+ * that do not fit the row wrap onto the next line, each chip whole.
69
+ */
65
70
  export declare function FilterChips({ options, value, onChange, label }: FilterChipsProps): ReactNode;
66
71
  export interface Pane {
67
72
  /** What the pane holds, for assistive technology ("Folders", "Messages", "Message"). */
68
73
  readonly label: string;
69
74
  readonly content: ReactNode;
70
75
  }
76
+ /** A pane the person may make wider or narrower, in px: where it is, its limits, its default, and its splitter's name. */
77
+ export interface PaneSize {
78
+ readonly width: number;
79
+ readonly min: number;
80
+ readonly max: number;
81
+ /** The width a double-click on its splitter puts it back to. */
82
+ readonly reset: number;
83
+ /** The splitter's name, in the app's language ("Resize folders"). */
84
+ readonly label: string;
85
+ }
71
86
  export interface SplitPanesProps {
72
87
  /** Two panes (a list and what is open) or three (navigation, a list, what is open). */
73
88
  readonly panes: readonly [Pane, Pane] | readonly [Pane, Pane, Pane];
@@ -84,12 +99,38 @@ export interface SplitPanesProps {
84
99
  readonly label: string;
85
100
  readonly href: string;
86
101
  };
102
+ /**
103
+ * Sizes for the panes before the last, by index: each one given draws a splitter after its pane where every pane
104
+ * shows (the desktop grid). The caller keeps the widths (or the device does, with `storageKey`); the last pane takes
105
+ * the rest.
106
+ */
107
+ readonly sizes?: readonly (PaneSize | undefined)[];
108
+ /** The last pane's least width while splitters move and the window narrows (360 by default). */
109
+ readonly lastMin?: number;
110
+ /**
111
+ * A splitter moved pane `index` to `width`: while it is dragged (`done` false), and once more when the drag or the
112
+ * key ends (`done` true), which is when a width is worth keeping.
113
+ */
114
+ readonly onResize?: (index: number, width: number, done: boolean) => void;
115
+ /**
116
+ * Where the widths are remembered on this device (the screen, such as "mail"): each splitter keeps its own under
117
+ * `${storageKey}:${index}`, and the panes open at the widths remembered there. Without one, the caller keeps them.
118
+ */
119
+ readonly storageKey?: string;
87
120
  }
88
121
  /**
89
- * A section's panes: side by side on desktop, the active pane and the one before it on tablet, the active pane alone
90
- * on phone, with Back to the one before it. The last visible pane takes the rest of the width.
122
+ * The widths the panes take in `room` px: each as wanted within its limits; when the last pane would be under its
123
+ * least width, the pane nearest it gives way first, down to its own least, then the one before.
91
124
  */
92
- export declare function SplitPanes({ panes, active, back }: SplitPanesProps): ReactNode;
125
+ export declare function fitPanes(wanted: readonly PaneSize[], room: number, lastMin: number): number[];
126
+ /**
127
+ * Two or three panes side by side (contract `split-panes`), showing fewer as the window narrows. With `sizes`, the
128
+ * panes before the last are resizable where all of them show (contract `pane splitter`): each has the kit's one
129
+ * Splitter after it, within the pane's limits and never leaving the last pane under `lastMin`. The last pane is never
130
+ * narrower than `lastMin`; as the window narrows the pane nearest it gives way first. With `storageKey` the widths are
131
+ * remembered on the device; the caller still hears each move through `onResize`.
132
+ */
133
+ export declare function SplitPanes({ panes, active, back, sizes, lastMin, onResize, storageKey }: SplitPanesProps): ReactNode;
93
134
  export interface MailRowProps {
94
135
  readonly from: string;
95
136
  readonly subject: string;
@@ -100,9 +141,42 @@ export interface MailRowProps {
100
141
  readonly hasAttachment?: boolean;
101
142
  readonly selected?: boolean;
102
143
  readonly onOpen: () => void;
144
+ /**
145
+ * The row's checkbox, in the avatar's place (contract list, part avatar checkbox); with none, the avatar alone (a
146
+ * row the host does not let be checked). `label` is its accessible name, in the host's
147
+ * words: "Select: {sender}, {subject}". `onCheck` is called for a click, a tap and Space alike, with Shift and with
148
+ * Ctrl/Cmd (`toggle`), and the row is never opened by it. `pending`: the check is on its way, the box busy and not
149
+ * pressable; `disabled`: it cannot be checked now.
150
+ */
151
+ readonly check?: {
152
+ readonly checked: boolean;
153
+ readonly onCheck: (e: {
154
+ readonly shift: boolean;
155
+ readonly toggle: boolean;
156
+ }) => void;
157
+ readonly label: string;
158
+ readonly pending?: boolean;
159
+ readonly disabled?: boolean;
160
+ };
161
+ /** Something in the list is checked: every row shows its checkbox, until nothing is. */
162
+ readonly selecting?: boolean;
163
+ /** Its words for assistive technology, in the app's language; each left out is English. */
164
+ readonly labels?: Partial<MailRowLabels>;
103
165
  }
104
- /** One message in a mailbox's list: who, what, the start of it, when; unread in bold with its dot. */
105
- export declare function MailRow({ from, subject, preview, time, unread, hasAttachment, selected, onOpen }: MailRowProps): ReactNode;
166
+ export interface MailRowLabels {
167
+ readonly attachment: string;
168
+ readonly unread: string;
169
+ }
170
+ export declare const MAIL_ROW_LABELS: MailRowLabels;
171
+ /**
172
+ * One message in a mailbox's list: who, what, the start of it, when; unread in bold with its dot. Three lines at every
173
+ * width: the sender and the time, the subject, the preview. The row (`cms-mail-row`, carrying is-unread and
174
+ * is-selected) holds the open button (`cms-mail-row__open`, aria-current when selected) and, with `check`, the
175
+ * checkbox in the avatar's place (`cms-mail-row__check`): shown as the checkbox while `selecting` (something is
176
+ * selected), while checked, on keyboard focus within the row, and under a fine pointer's hover; the avatar otherwise,
177
+ * so a touch screen with nothing selected shows every avatar. The avatar's top is on the sender line's top.
178
+ */
179
+ export declare function MailRow({ from, subject, preview, time, unread, hasAttachment, selected, onOpen, check, selecting, labels }: MailRowProps): ReactNode;
106
180
  export interface ChatBubbleProps {
107
181
  /** Received from someone else, or sent by this account. */
108
182
  readonly direction: 'in' | 'out';
@@ -110,9 +184,11 @@ export interface ChatBubbleProps {
110
184
  readonly time: string;
111
185
  /** For a sent message: whether the other side has read it. */
112
186
  readonly read?: boolean;
187
+ /** What a read message says beside its time, in the app's language ("Read"). */
188
+ readonly readLabel?: string;
113
189
  }
114
190
  /** One chat message; the corner nearest its sender is the tail. */
115
- export declare function ChatBubble({ direction, children, time, read }: ChatBubbleProps): ReactNode;
191
+ export declare function ChatBubble({ direction, children, time, read, readLabel }: ChatBubbleProps): ReactNode;
116
192
  export interface ComposerProps {
117
193
  /** What is being written and to whom ("Message Anna", "Quick reply to Anna Kowalska"). */
118
194
  readonly label: string;
@@ -124,6 +200,21 @@ export interface ComposerProps {
124
200
  /** `chat`: one line beside its buttons; `reply`: a titled box under a message. */
125
201
  readonly variant?: 'chat' | 'reply';
126
202
  readonly sendLabel?: string;
203
+ /** The attach button's name, in the app's language ("Attach a file"). */
204
+ readonly attachLabel?: string;
205
+ /**
206
+ * A quick reply's own controls, at the start of its last row, before Send (an attach menu). A chat composer does not
207
+ * draw them. With `onAttach` as well, a reply draws both: these first, then the attach button.
208
+ */
209
+ readonly leading?: ReactNode;
210
+ /**
211
+ * Whether Send sends: by default, when the text is not empty. Given, it decides instead, as for a reply that may go
212
+ * with files and no text, or may not go over its mailbox's limit.
213
+ */
214
+ readonly canSend?: boolean;
127
215
  }
128
- /** Writing a message: the text, attaching a file, sending. Enter sends a chat message; Shift+Enter starts a new line. */
129
- export declare function Composer({ label, value, onChange, onSend, onAttach, placeholder, variant, sendLabel }: ComposerProps): ReactNode;
216
+ /**
217
+ * Writing a message: the text, attaching a file, sending. Enter sends a chat message; Shift+Enter starts a new line.
218
+ * Enter while an input method is composing (Chinese, Japanese, Korean...) belongs to the composition and never sends.
219
+ */
220
+ 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, in the region or
7
+ * in a list scrolling inside it, or goes up, is that scroll's own. 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;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,24 @@
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 { PageHeader, TabStrip, Avatar, initialsOf, tintOf, type PageHeaderProps, type Tab, type TabStripProps, type AvatarProps } from './components/Structure';
6
- export { Icon, ICON_NAMES, type IconName, type IconProps } from './components/Icon';
7
- export { AppShell, Badge, SearchField, FilterChips, SplitPanes, MailRow, ChatBubble, Composer, 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';
8
- export { IncomingCall, CallPanel, CallBar, type IncomingCallProps, type CallPanelProps, type CallBarProps } from './components/Call';
9
- export { SignInLayout, SignInForm, type SignInLayoutProps, type SignInFormProps, type SignInFeature } from './components/SignIn';
10
- export { List, ContextMenu, type ListRow, type ListProps, type MenuItem, type ContextMenuProps } from './components/Collections';
11
- export { offerFor, isCapability, type Capability, type Offer, type OfferOptions } from './server/capability';
12
- export { readRefusal, refusalText, type Refusal } from './server/refusal';
13
- export { useReread, rereadAll, type Reread } from './server/reread';
14
- export { readConflict, type Conflict } from './server/conflict';
15
- export { needsClientUpdate, versionBelow, CLIENT_UPDATE_REQUIRED } from './server/client-update';
1
+ export { Button, type ButtonProps } from './components/Button.js';
2
+ export { TextField, TextArea, Select, Toggle, writtenOut, type TextFieldProps, type TextFieldType, type TextAreaProps, type SelectProps, type SelectOption, type ToggleProps } from './components/Fields.js';
3
+ export { Modal, ConfirmDialog, MODAL_CLOSE_MS, type ModalProps, type ConfirmDialogProps } from './components/Dialogs.js';
4
+ export { Toast, ToastRegion, Loading, EmptyState, ErrorBanner, type ToastProps, type LoadingProps, type EmptyStateProps, type ErrorBannerProps } from './components/Status.js';
5
+ export { State, STATE_DELAY_MS, type StateKind, type StatePlacement, type StateProps } from './components/State.js';
6
+ export { FileViewer, type FileViewerAction, type FileViewerConflict, type FileViewerEditing, type FileViewerProps, type FileViewerSiblings, type FileViewerState } from './components/FileViewer.js';
7
+ export { FilePicker, FilePickerDenied, FilePickerRestart, type FilePickerBudget, type FilePickerChoice, type FilePickerEntry, type FilePickerLabels, type FilePickerPage, type FilePickerProps, type FilePickerSpace } from './components/FilePicker.js';
8
+ export { SectionHeader, type SectionHeaderProps, type SectionPrimary } from './components/SectionHeader.js';
9
+ export { PageHeader, TabStrip, Avatar, initialsOf, tintOf, type PageHeaderProps, type Tab, type TabStripProps, type AvatarProps, type AvatarPresence, type AvatarConnection } from './components/Structure.js';
10
+ export { Icon, ICON_NAMES, BOOTSTRAP_ICONS, NamedIcon, iconForName, type IconName, type IconProps } from './components/Icon.js';
11
+ export { AppShell, Badge, SearchField, FilterChips, SplitPanes, fitPanes, MailRow, ChatBubble, Composer, MAIL_ROW_LABELS, type MailRowLabels, type AppShellProps, type RailItem, type BadgeProps, type SearchFieldProps, type FilterChipsProps, type FilterOption, type SplitPanesProps, type PaneSize, type Pane, type MailRowProps, type ChatBubbleProps, type ComposerProps } from './components/Workspace.js';
12
+ export { IncomingCall, CallPanel, CallBar, CALL_LABELS, type CallLabels, type IncomingCallProps, type CallPanelProps, type CallBarProps } from './components/Call.js';
13
+ export { SignInLayout, SignInForm, SIGN_IN_LABELS, type SignInLabels, type SignInLayoutProps, type SignInFormProps, type SignInFeature } from './components/SignIn.js';
14
+ export { List, ContextMenu, type ListRow, type ListProps, type MenuItem, type ContextMenuProps } from './components/Collections.js';
15
+ export { PaneToolbar, type PaneToolbarAction, type PaneToolbarEntry, type PaneToolbarProps } from './components/PaneToolbar.js';
16
+ export { Splitter, type SplitterProps } from './components/Splitter.js';
17
+ export { Notification, type NotificationAction, type NotificationProps } from './components/Notification.js';
18
+ export { offerFor, isCapability, type Capability, type Offer, type OfferOptions } from './server/capability.js';
19
+ export { readRefusal, refusalText, type Refusal } from './server/refusal.js';
20
+ export { useReread, rereadAll, type Reread } from './server/reread.js';
21
+ export { readConflict, type Conflict } from './server/conflict.js';
22
+ export { needsClientUpdate, versionBelow, CLIENT_UPDATE_REQUIRED } from './server/client-update.js';
23
+ export { ScreenShell, type ScreenShellProps, type ScreenPrimary } from './components/ScreenShell.js';
24
+ export { PULL_AT, usePull, usePullState, type PullState } from './components/pull.js';