@coolms/ui-react 0.1.0-alpha.1 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -42,5 +42,7 @@ export interface AvatarProps {
42
42
  }
43
43
  /** Up to two initials from a name: "Ada Lovelace" -> "AL", "ada" -> "A". */
44
44
  export declare function initialsOf(name: string): string;
45
+ /** Which of the six avatar tints a name takes: the same name always the same tint. */
46
+ export declare function tintOf(name: string): number;
45
47
  /** A person or an account, by picture or initials (contract component `avatar`: picture, initials, presence). */
46
48
  export declare function Avatar({ name, pictureUrl, presence, size }: AvatarProps): ReactNode;
@@ -0,0 +1,155 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type IconName } from './Icon';
3
+ export interface BadgeProps {
4
+ readonly count: number;
5
+ /** What the number counts, for a screen reader ("12 unread"). */
6
+ readonly label: string;
7
+ /** Over this, the badge reads "max+". */
8
+ readonly max?: number;
9
+ }
10
+ /** A count on the accent: unread messages, chats waiting. Nothing is drawn for zero. */
11
+ export declare function Badge({ count, label, max }: BadgeProps): ReactNode;
12
+ export interface RailItem {
13
+ readonly id: string;
14
+ readonly label: string;
15
+ readonly icon: IconName;
16
+ readonly href: string;
17
+ readonly badge?: {
18
+ readonly count: number;
19
+ readonly label: string;
20
+ };
21
+ }
22
+ export interface AppShellProps {
23
+ /** The product's name, beside the brand mark ("CoolMS Workspace"). */
24
+ readonly product: ReactNode;
25
+ /** The brand mark at the top of the rail: one letter, or an image. */
26
+ readonly mark: ReactNode;
27
+ readonly rail: readonly RailItem[];
28
+ readonly active: string;
29
+ /** Called instead of following the link, when given (a client-side router). */
30
+ readonly onNavigate?: (id: string) => void;
31
+ /** The server the page is signed in to, as a control that switches servers. */
32
+ readonly server?: ReactNode;
33
+ /** The global search field. */
34
+ readonly search?: ReactNode;
35
+ /** Notifications and the account, at the right of the top bar. */
36
+ readonly account?: ReactNode;
37
+ readonly children: ReactNode;
38
+ /** The rail's name for assistive technology, in the app's language ("Sections"). */
39
+ readonly railLabel?: string;
40
+ }
41
+ /**
42
+ * The Workspace's frame: a dark rail of sections, each an icon over its name with its count, and a light top bar with
43
+ * the server, the search and the account. The open section is marked for assistive technology as the current page.
44
+ */
45
+ export declare function AppShell({ product, mark, rail, active, onNavigate, server, search, account, children, railLabel }: AppShellProps): ReactNode;
46
+ export interface SearchFieldProps {
47
+ readonly label: string;
48
+ readonly placeholder?: string;
49
+ readonly value: string;
50
+ readonly onChange: (value: string) => void;
51
+ readonly onSearch?: (value: string) => void;
52
+ }
53
+ /** A search field with its icon; the label is for assistive technology, the placeholder shows what can be found. */
54
+ export declare function SearchField({ label, placeholder, value, onChange, onSearch }: SearchFieldProps): ReactNode;
55
+ export interface FilterOption {
56
+ readonly id: string;
57
+ readonly label: string;
58
+ }
59
+ export interface FilterChipsProps {
60
+ readonly options: readonly FilterOption[];
61
+ readonly value: string;
62
+ readonly onChange: (id: string) => void;
63
+ /** What the chips filter ("Show"). */
64
+ readonly label: string;
65
+ }
66
+ /** One of a few filters, as pills; arrow keys move between them, as a radio group does. */
67
+ export declare function FilterChips({ options, value, onChange, label }: FilterChipsProps): ReactNode;
68
+ export interface Pane {
69
+ /** What the pane holds, for assistive technology ("Folders", "Messages", "Message"). */
70
+ readonly label: string;
71
+ readonly content: ReactNode;
72
+ }
73
+ export interface SplitPanesProps {
74
+ /** Two panes (a list and what is open) or three (navigation, a list, what is open). */
75
+ readonly panes: readonly [Pane, Pane] | readonly [Pane, Pane, Pane];
76
+ /**
77
+ * The pane the person is in, by its index: where the selection has got to (the folders, a list, a message). At
78
+ * phone width only this pane shows; at tablet width it and the one before it. The last pane by default.
79
+ */
80
+ readonly active?: number;
81
+ /**
82
+ * Where Back goes from the active pane: the address of the pane before it, so the browser's own Back agrees. Shown
83
+ * only where that pane is hidden (phone, or tablet with three panes and the last one active).
84
+ */
85
+ readonly back?: {
86
+ readonly label: string;
87
+ readonly href: string;
88
+ };
89
+ }
90
+ /**
91
+ * A section's panes: side by side on desktop, the active pane and the one before it on tablet, the active pane alone
92
+ * on phone, with Back to the one before it. The last visible pane takes the rest of the width.
93
+ */
94
+ export declare function SplitPanes({ panes, active, back }: SplitPanesProps): ReactNode;
95
+ export interface MailRowProps {
96
+ readonly from: string;
97
+ readonly subject: string;
98
+ readonly preview: string;
99
+ /** When it arrived, as the reader reads it ("09:42", "Yesterday"). */
100
+ readonly time: string;
101
+ readonly unread?: boolean;
102
+ readonly hasAttachment?: boolean;
103
+ readonly selected?: boolean;
104
+ readonly onOpen: () => void;
105
+ /** Its words for assistive technology, in the app's language; each left out is English. */
106
+ readonly labels?: Partial<MailRowLabels>;
107
+ }
108
+ export interface MailRowLabels {
109
+ readonly attachment: string;
110
+ readonly unread: string;
111
+ }
112
+ export declare const MAIL_ROW_LABELS: MailRowLabels;
113
+ /** One message in a mailbox's list: who, what, the start of it, when; unread in bold with its dot. */
114
+ export declare function MailRow({ from, subject, preview, time, unread, hasAttachment, selected, onOpen, labels }: MailRowProps): ReactNode;
115
+ export interface ChatBubbleProps {
116
+ /** Received from someone else, or sent by this account. */
117
+ readonly direction: 'in' | 'out';
118
+ readonly children: ReactNode;
119
+ readonly time: string;
120
+ /** For a sent message: whether the other side has read it. */
121
+ readonly read?: boolean;
122
+ /** What a read message says beside its time, in the app's language ("Read"). */
123
+ readonly readLabel?: string;
124
+ }
125
+ /** One chat message; the corner nearest its sender is the tail. */
126
+ export declare function ChatBubble({ direction, children, time, read, readLabel }: ChatBubbleProps): ReactNode;
127
+ export interface ComposerProps {
128
+ /** What is being written and to whom ("Message Anna", "Quick reply to Anna Kowalska"). */
129
+ readonly label: string;
130
+ readonly value: string;
131
+ readonly onChange: (value: string) => void;
132
+ readonly onSend: () => void;
133
+ readonly onAttach?: () => void;
134
+ readonly placeholder?: string;
135
+ /** `chat`: one line beside its buttons; `reply`: a titled box under a message. */
136
+ readonly variant?: 'chat' | 'reply';
137
+ readonly sendLabel?: string;
138
+ /** The attach button's name, in the app's language ("Attach a file"). */
139
+ readonly attachLabel?: string;
140
+ /**
141
+ * A quick reply's own controls, at the start of its last row, before Send (an attach menu). A chat composer does not
142
+ * draw them. With `onAttach` as well, a reply draws both: these first, then the attach button.
143
+ */
144
+ readonly leading?: ReactNode;
145
+ /**
146
+ * Whether Send sends: by default, when the text is not empty. Given, it decides instead, as for a reply that may go
147
+ * with files and no text, or may not go over its mailbox's limit.
148
+ */
149
+ readonly canSend?: boolean;
150
+ }
151
+ /**
152
+ * Writing a message: the text, attaching a file, sending. Enter sends a chat message; Shift+Enter starts a new line.
153
+ * Enter while an input method is composing (Chinese, Japanese, Korean...) belongs to the composition and never sends.
154
+ */
155
+ export declare function Composer({ label, value, onChange, onSend, onAttach, placeholder, variant, sendLabel, attachLabel, leading, canSend }: ComposerProps): ReactNode;
@@ -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. */
package/dist/index.d.ts CHANGED
@@ -2,8 +2,16 @@ export { Button, type ButtonProps } from './components/Button';
2
2
  export { TextField, Select, Toggle, type TextFieldProps, type SelectProps, type SelectOption, type ToggleProps } from './components/Fields';
3
3
  export { Modal, ConfirmDialog, MODAL_CLOSE_MS, type ModalProps, type ConfirmDialogProps } from './components/Dialogs';
4
4
  export { Toast, ToastRegion, Loading, EmptyState, ErrorBanner, type ToastProps, type LoadingProps, type EmptyStateProps, type ErrorBannerProps } from './components/Status';
5
- export { PageHeader, TabStrip, Avatar, initialsOf, type PageHeaderProps, type Tab, type TabStripProps, type AvatarProps } from './components/Structure';
5
+ export { State, STATE_DELAY_MS, type StateKind, type StatePlacement, type StateProps } from './components/State';
6
+ export { FileViewer, type FileViewerAction, type FileViewerEditing, type FileViewerProps, type FileViewerSiblings } from './components/FileViewer';
7
+ export { FilePicker, FilePickerDenied, type FilePickerBudget, type FilePickerChoice, type FilePickerEntry, type FilePickerLabels, type FilePickerPage, type FilePickerProps, type FilePickerSpace } from './components/FilePicker';
8
+ export { PageHeader, TabStrip, Avatar, initialsOf, tintOf, type PageHeaderProps, type Tab, type TabStripProps, type AvatarProps } from './components/Structure';
9
+ export { Icon, ICON_NAMES, BOOTSTRAP_ICONS, iconForName, type IconName, type IconProps } from './components/Icon';
10
+ export { AppShell, Badge, SearchField, FilterChips, SplitPanes, MailRow, ChatBubble, Composer, MAIL_ROW_LABELS, type MailRowLabels, type AppShellProps, type RailItem, type BadgeProps, type SearchFieldProps, type FilterChipsProps, type FilterOption, type SplitPanesProps, type Pane, type MailRowProps, type ChatBubbleProps, type ComposerProps } from './components/Workspace';
11
+ export { IncomingCall, CallPanel, CallBar, CALL_LABELS, type CallLabels, type IncomingCallProps, type CallPanelProps, type CallBarProps } from './components/Call';
12
+ export { SignInLayout, SignInForm, SIGN_IN_LABELS, type SignInLabels, type SignInLayoutProps, type SignInFormProps, type SignInFeature } from './components/SignIn';
6
13
  export { List, ContextMenu, type ListRow, type ListProps, type MenuItem, type ContextMenuProps } from './components/Collections';
14
+ export { PaneToolbar, type PaneToolbarAction, type PaneToolbarProps } from './components/PaneToolbar';
7
15
  export { offerFor, isCapability, type Capability, type Offer, type OfferOptions } from './server/capability';
8
16
  export { readRefusal, refusalText, type Refusal } from './server/refusal';
9
17
  export { useReread, rereadAll, type Reread } from './server/reread';