@openwarelabs/ui 0.15.0 → 0.16.0

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.
Files changed (58) hide show
  1. package/dist/components/ActivityHeatmap/ActivityHeatmap.d.cts +8 -0
  2. package/dist/components/ActivityHeatmap/ActivityHeatmap.d.ts +8 -0
  3. package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.cts +73 -0
  4. package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.ts +73 -0
  5. package/dist/components/DiffViewer/DiffViewer.d.cts +8 -0
  6. package/dist/components/DiffViewer/DiffViewer.d.ts +8 -0
  7. package/dist/components/DiffViewer/DiffViewer.types.d.cts +131 -0
  8. package/dist/components/DiffViewer/DiffViewer.types.d.ts +131 -0
  9. package/dist/components/DiffViewer/diff.d.cts +10 -0
  10. package/dist/components/DiffViewer/diff.d.ts +10 -0
  11. package/dist/components/Markdown/Markdown.d.cts +8 -0
  12. package/dist/components/Markdown/Markdown.d.ts +8 -0
  13. package/dist/components/Markdown/Markdown.types.d.cts +59 -0
  14. package/dist/components/Markdown/Markdown.types.d.ts +59 -0
  15. package/dist/components/MediaPlayer/MediaPlayer.d.cts +8 -0
  16. package/dist/components/MediaPlayer/MediaPlayer.d.ts +8 -0
  17. package/dist/components/MediaPlayer/MediaPlayer.types.d.cts +109 -0
  18. package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +109 -0
  19. package/dist/components/MentionInput/MentionInput.d.cts +9 -0
  20. package/dist/components/MentionInput/MentionInput.d.ts +9 -0
  21. package/dist/components/MentionInput/MentionInput.types.d.cts +125 -0
  22. package/dist/components/MentionInput/MentionInput.types.d.ts +125 -0
  23. package/dist/components/MentionInput/useMentions.d.cts +8 -0
  24. package/dist/components/MentionInput/useMentions.d.ts +8 -0
  25. package/dist/components/NotificationCenter/NotificationCenter.d.cts +12 -0
  26. package/dist/components/NotificationCenter/NotificationCenter.d.ts +12 -0
  27. package/dist/components/NotificationCenter/NotificationCenter.types.d.cts +129 -0
  28. package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +129 -0
  29. package/dist/components/QRCode/QRCode.d.cts +18 -0
  30. package/dist/components/QRCode/QRCode.d.ts +18 -0
  31. package/dist/components/QRCode/QRCode.types.d.cts +53 -0
  32. package/dist/components/QRCode/QRCode.types.d.ts +53 -0
  33. package/dist/components/QRCode/qr.d.cts +8 -0
  34. package/dist/components/QRCode/qr.d.ts +8 -0
  35. package/dist/components/SignaturePad/SignaturePad.d.cts +8 -0
  36. package/dist/components/SignaturePad/SignaturePad.d.ts +8 -0
  37. package/dist/components/SignaturePad/SignaturePad.types.d.cts +102 -0
  38. package/dist/components/SignaturePad/SignaturePad.types.d.ts +102 -0
  39. package/dist/components/TransferList/TransferList.d.cts +7 -0
  40. package/dist/components/TransferList/TransferList.d.ts +7 -0
  41. package/dist/components/TransferList/TransferList.types.d.cts +75 -0
  42. package/dist/components/TransferList/TransferList.types.d.ts +75 -0
  43. package/dist/components/UploadList/UploadList.d.cts +9 -0
  44. package/dist/components/UploadList/UploadList.d.ts +9 -0
  45. package/dist/components/UploadList/UploadList.types.d.cts +113 -0
  46. package/dist/components/UploadList/UploadList.types.d.ts +113 -0
  47. package/dist/components/UploadList/useUploadQueue.d.cts +8 -0
  48. package/dist/components/UploadList/useUploadQueue.d.ts +8 -0
  49. package/dist/components.css +1194 -104
  50. package/dist/index.cjs +5489 -2267
  51. package/dist/index.cjs.map +4 -4
  52. package/dist/index.d.cts +20 -0
  53. package/dist/index.d.ts +20 -0
  54. package/dist/index.js +5550 -2312
  55. package/dist/index.js.map +4 -4
  56. package/dist/openware-ui.iife.js +24 -9
  57. package/dist/styles.css +1194 -104
  58. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ import type { CSSProperties } from "react";
2
+ /** One file of the same media, for browsers to pick the first they can play. */
3
+ export interface MediaPlayerSource {
4
+ /** The file's URL. */
5
+ src: string;
6
+ /** Its MIME type, such as "video/webm" or "audio/mpeg". It also tells the player whether it's audio or video. */
7
+ type?: string;
8
+ }
9
+ /** A captions or subtitles file (WebVTT) for a video. */
10
+ export interface MediaPlayerTrack {
11
+ /** The .vtt file's URL. */
12
+ src: string;
13
+ /** Its language, such as "en". */
14
+ srcLang: string;
15
+ /** Its name in the captions menu, such as "English". */
16
+ label: string;
17
+ /** Shows these captions from the start.
18
+ * @default false */
19
+ default?: boolean;
20
+ }
21
+ /** What a ref to a MediaPlayer can do. */
22
+ export interface MediaPlayerHandle {
23
+ /** Starts playing. Resolves once it does; rejects if the browser blocks it (autoplay rules). */
24
+ play(): Promise<void>;
25
+ pause(): void;
26
+ /** Goes to this many seconds in. */
27
+ seek(time: number): void;
28
+ /** The `<video>` or `<audio>` element, for anything else. */
29
+ readonly media: HTMLMediaElement | null;
30
+ }
31
+ export interface MediaPlayerLabels {
32
+ /** Names the player when there's no `title`. @default "Video player" or "Audio player" */
33
+ player?: string;
34
+ /** @default "Play" */
35
+ play?: string;
36
+ /** @default "Pause" */
37
+ pause?: string;
38
+ /** Names the timeline. @default "Seek" */
39
+ seek?: string;
40
+ /** @default "Volume" */
41
+ volume?: string;
42
+ /** @default "Mute" */
43
+ mute?: string;
44
+ /** @default "Unmute" */
45
+ unmute?: string;
46
+ /** Names the speed menu; its button shows the speed, like "1×". @default "Playback speed" */
47
+ speed?: string;
48
+ /** @default "Captions" */
49
+ captions?: string;
50
+ /** The captions menu's item that turns them off, when there's more than one language. @default "Off" */
51
+ captionsOff?: string;
52
+ /** @default "Full screen" */
53
+ fullscreen?: string;
54
+ /** @default "Exit full screen" */
55
+ exitFullscreen?: string;
56
+ /** @default "Picture in picture" */
57
+ pictureInPicture?: string;
58
+ /** Reads out where it is on the timeline. @default (time, duration) => `${time} of ${duration}`, as "1:05 of 3:40" */
59
+ position?(time: string, duration: string): string;
60
+ }
61
+ export interface MediaPlayerProps {
62
+ /** The file's URL, or several formats of it (`{ src, type }`), best first. */
63
+ src: string | MediaPlayerSource[];
64
+ /** Audio is a bar of controls; video is a picture with the controls over it. Left out, it's taken from the
65
+ * source's type or file extension, and is video when it can't tell. */
66
+ kind?: "audio" | "video";
67
+ /** A picture shown before a video plays. */
68
+ poster?: string;
69
+ /** What's playing. It names the player for screen readers, and an audio player shows it above the controls. */
70
+ title?: string;
71
+ /** Captions or subtitles for a video. With one, the captions button turns them on and off; with more, it opens a
72
+ * menu of languages. */
73
+ tracks?: MediaPlayerTrack[];
74
+ /** Starts playing as soon as it can. Browsers only allow this when it's `muted`, or after the person has
75
+ * interacted with the page.
76
+ * @default false */
77
+ autoPlay?: boolean;
78
+ /** Starts again from the beginning when it ends.
79
+ * @default false */
80
+ loop?: boolean;
81
+ /** Starts muted.
82
+ * @default false */
83
+ muted?: boolean;
84
+ /** The speeds in the speed menu; an empty list hides it.
85
+ * @default [0.5, 0.75, 1, 1.25, 1.5, 2] */
86
+ playbackRates?: number[];
87
+ /** A video's shape, width over height.
88
+ * @default 16 / 9 */
89
+ ratio?: number;
90
+ /** `minimal` keeps only play, the timeline and the time, for a small player or a short clip.
91
+ * @default "full" */
92
+ controls?: "full" | "minimal";
93
+ /** How much to load before it plays: `metadata` is enough to show the length.
94
+ * @default "metadata" */
95
+ preload?: "none" | "metadata" | "auto";
96
+ /** Called as it plays and when it's moved, with the time and the length in seconds. */
97
+ onTimeUpdate?(time: number, duration: number): void;
98
+ /** Called when it starts or stops playing. */
99
+ onPlayingChange?(playing: boolean): void;
100
+ /** Called when it reaches the end (not when it loops). */
101
+ onEnded?(): void;
102
+ /** The words it uses, for other languages. */
103
+ labels?: MediaPlayerLabels;
104
+ /** Names the player for screen readers, in place of `title`. */
105
+ "aria-label"?: string;
106
+ id?: string;
107
+ className?: string;
108
+ style?: CSSProperties;
109
+ }
@@ -0,0 +1,109 @@
1
+ import type { CSSProperties } from "react";
2
+ /** One file of the same media, for browsers to pick the first they can play. */
3
+ export interface MediaPlayerSource {
4
+ /** The file's URL. */
5
+ src: string;
6
+ /** Its MIME type, such as "video/webm" or "audio/mpeg". It also tells the player whether it's audio or video. */
7
+ type?: string;
8
+ }
9
+ /** A captions or subtitles file (WebVTT) for a video. */
10
+ export interface MediaPlayerTrack {
11
+ /** The .vtt file's URL. */
12
+ src: string;
13
+ /** Its language, such as "en". */
14
+ srcLang: string;
15
+ /** Its name in the captions menu, such as "English". */
16
+ label: string;
17
+ /** Shows these captions from the start.
18
+ * @default false */
19
+ default?: boolean;
20
+ }
21
+ /** What a ref to a MediaPlayer can do. */
22
+ export interface MediaPlayerHandle {
23
+ /** Starts playing. Resolves once it does; rejects if the browser blocks it (autoplay rules). */
24
+ play(): Promise<void>;
25
+ pause(): void;
26
+ /** Goes to this many seconds in. */
27
+ seek(time: number): void;
28
+ /** The `<video>` or `<audio>` element, for anything else. */
29
+ readonly media: HTMLMediaElement | null;
30
+ }
31
+ export interface MediaPlayerLabels {
32
+ /** Names the player when there's no `title`. @default "Video player" or "Audio player" */
33
+ player?: string;
34
+ /** @default "Play" */
35
+ play?: string;
36
+ /** @default "Pause" */
37
+ pause?: string;
38
+ /** Names the timeline. @default "Seek" */
39
+ seek?: string;
40
+ /** @default "Volume" */
41
+ volume?: string;
42
+ /** @default "Mute" */
43
+ mute?: string;
44
+ /** @default "Unmute" */
45
+ unmute?: string;
46
+ /** Names the speed menu; its button shows the speed, like "1×". @default "Playback speed" */
47
+ speed?: string;
48
+ /** @default "Captions" */
49
+ captions?: string;
50
+ /** The captions menu's item that turns them off, when there's more than one language. @default "Off" */
51
+ captionsOff?: string;
52
+ /** @default "Full screen" */
53
+ fullscreen?: string;
54
+ /** @default "Exit full screen" */
55
+ exitFullscreen?: string;
56
+ /** @default "Picture in picture" */
57
+ pictureInPicture?: string;
58
+ /** Reads out where it is on the timeline. @default (time, duration) => `${time} of ${duration}`, as "1:05 of 3:40" */
59
+ position?(time: string, duration: string): string;
60
+ }
61
+ export interface MediaPlayerProps {
62
+ /** The file's URL, or several formats of it (`{ src, type }`), best first. */
63
+ src: string | MediaPlayerSource[];
64
+ /** Audio is a bar of controls; video is a picture with the controls over it. Left out, it's taken from the
65
+ * source's type or file extension, and is video when it can't tell. */
66
+ kind?: "audio" | "video";
67
+ /** A picture shown before a video plays. */
68
+ poster?: string;
69
+ /** What's playing. It names the player for screen readers, and an audio player shows it above the controls. */
70
+ title?: string;
71
+ /** Captions or subtitles for a video. With one, the captions button turns them on and off; with more, it opens a
72
+ * menu of languages. */
73
+ tracks?: MediaPlayerTrack[];
74
+ /** Starts playing as soon as it can. Browsers only allow this when it's `muted`, or after the person has
75
+ * interacted with the page.
76
+ * @default false */
77
+ autoPlay?: boolean;
78
+ /** Starts again from the beginning when it ends.
79
+ * @default false */
80
+ loop?: boolean;
81
+ /** Starts muted.
82
+ * @default false */
83
+ muted?: boolean;
84
+ /** The speeds in the speed menu; an empty list hides it.
85
+ * @default [0.5, 0.75, 1, 1.25, 1.5, 2] */
86
+ playbackRates?: number[];
87
+ /** A video's shape, width over height.
88
+ * @default 16 / 9 */
89
+ ratio?: number;
90
+ /** `minimal` keeps only play, the timeline and the time, for a small player or a short clip.
91
+ * @default "full" */
92
+ controls?: "full" | "minimal";
93
+ /** How much to load before it plays: `metadata` is enough to show the length.
94
+ * @default "metadata" */
95
+ preload?: "none" | "metadata" | "auto";
96
+ /** Called as it plays and when it's moved, with the time and the length in seconds. */
97
+ onTimeUpdate?(time: number, duration: number): void;
98
+ /** Called when it starts or stops playing. */
99
+ onPlayingChange?(playing: boolean): void;
100
+ /** Called when it reaches the end (not when it loops). */
101
+ onEnded?(): void;
102
+ /** The words it uses, for other languages. */
103
+ labels?: MediaPlayerLabels;
104
+ /** Names the player for screen readers, in place of `title`. */
105
+ "aria-label"?: string;
106
+ id?: string;
107
+ className?: string;
108
+ style?: CSSProperties;
109
+ }
@@ -0,0 +1,9 @@
1
+ import type { MentionInputProps } from "./MentionInput.types.cjs";
2
+ export type { Mention, MentionInputProps, MentionLabels, MentionOption, MentionTrigger, UseMentionsOptions, UseMentionsResult } from "./MentionInput.types.cjs";
3
+ export { useMentions } from "./useMentions.cjs";
4
+ /**
5
+ * A text field that suggests people after `@` and commands after `/` (or any trigger you give), at the caret.
6
+ * Picking one puts it in the text as "@Ada Lovelace ", and `onMentionsChange` reports the mentions with their ids.
7
+ * One line by default; `multiline` makes it a Textarea that grows. For another text box, use `useMentions`.
8
+ */
9
+ export declare const MentionInput: import("react").ForwardRefExoticComponent<MentionInputProps & import("react").RefAttributes<HTMLTextAreaElement | HTMLInputElement>>;
@@ -0,0 +1,9 @@
1
+ import type { MentionInputProps } from "./MentionInput.types.js";
2
+ export type { Mention, MentionInputProps, MentionLabels, MentionOption, MentionTrigger, UseMentionsOptions, UseMentionsResult } from "./MentionInput.types.js";
3
+ export { useMentions } from "./useMentions.js";
4
+ /**
5
+ * A text field that suggests people after `@` and commands after `/` (or any trigger you give), at the caret.
6
+ * Picking one puts it in the text as "@Ada Lovelace ", and `onMentionsChange` reports the mentions with their ids.
7
+ * One line by default; `multiline` makes it a Textarea that grows. For another text box, use `useMentions`.
8
+ */
9
+ export declare const MentionInput: import("react").ForwardRefExoticComponent<MentionInputProps & import("react").RefAttributes<HTMLTextAreaElement | HTMLInputElement>>;
@@ -0,0 +1,125 @@
1
+ import type { KeyboardEvent, ReactNode, RefCallback } from "react";
2
+ export interface MentionOption {
3
+ /** Identifies what was picked, in `mentions`: a user id, a command name. */
4
+ id: string;
5
+ /** The text shown in the list, matched as people type, and put in the text after the trigger: "@Ada Lovelace". */
6
+ label: string;
7
+ /** A muted line under the label in the list; matched too when it's a string. */
8
+ description?: ReactNode;
9
+ /** A small icon or avatar before the label. */
10
+ icon?: ReactNode;
11
+ disabled?: boolean;
12
+ }
13
+ export interface MentionTrigger {
14
+ /** What opens the list when it's typed at the start of a word: "@", "/", "#". */
15
+ char: string;
16
+ /**
17
+ * What to suggest. A list is filtered by what's typed after the trigger. A function gets that text and returns
18
+ * the options to show, itself or in a promise (to search a server); the list shows a spinner while it waits.
19
+ */
20
+ options: MentionOption[] | ((query: string) => MentionOption[] | Promise<MentionOption[]>);
21
+ /** Called after an option is put in the text. */
22
+ onSelect?(option: MentionOption): void;
23
+ /** Draws an option's row in the list in place of its icon, label and description. */
24
+ render?(option: MentionOption): ReactNode;
25
+ /** Names the list for screen readers while this trigger has it open, such as "People".
26
+ * @default labels.suggestions */
27
+ label?: string;
28
+ }
29
+ /** A mention in the text, found from the options picked (and every option of a trigger with a list). */
30
+ export interface Mention {
31
+ /** The option's id. */
32
+ id: string;
33
+ label: string;
34
+ /** The trigger it was typed with: "@". */
35
+ trigger: string;
36
+ /** Where it starts in the text, at the trigger. */
37
+ start: number;
38
+ /** Where it ends, after the label. */
39
+ end: number;
40
+ }
41
+ /** The words it uses, for other languages. */
42
+ export interface MentionLabels {
43
+ /** Names the list when its trigger has no `label`. @default "Suggestions" */
44
+ suggestions?: string;
45
+ /** Shown and read out while options load. @default "Loading…" */
46
+ loading?: string;
47
+ /** Shown and read out when nothing matches. @default "No matches" */
48
+ empty?: string;
49
+ /** Read out with the number of options. @default (count) => `${count} results` */
50
+ results?(count: number): string;
51
+ }
52
+ export interface UseMentionsOptions {
53
+ triggers: MentionTrigger[];
54
+ /** The text, when you control it, so `mentions` follows changes made from outside (clearing it after a send).
55
+ * Without it, the hook reads the text box as people type. */
56
+ value?: string;
57
+ /** Called with the mentions in the text when they change. */
58
+ onMentionsChange?(mentions: Mention[]): void;
59
+ /** Turns the suggestions off.
60
+ * @default false */
61
+ disabled?: boolean;
62
+ /** The list's rows: md 36px, sm 32px.
63
+ * @default "md" */
64
+ size?: "sm" | "md";
65
+ labels?: MentionLabels;
66
+ }
67
+ export interface UseMentionsResult {
68
+ /** Put on the text box: a <textarea> or <input>, a Textarea, an Input, or PromptInput (its ref is the textarea). */
69
+ ref: RefCallback<HTMLTextAreaElement | HTMLInputElement>;
70
+ /** Render it anywhere, such as right after the text box: the floating list and its live region. */
71
+ list: ReactNode;
72
+ /** The mentions in the text, in order. */
73
+ mentions: Mention[];
74
+ /** Whether the list is open. */
75
+ isOpen: boolean;
76
+ }
77
+ export interface MentionInputProps {
78
+ /** The characters that open suggestions, with their options. */
79
+ triggers: MentionTrigger[];
80
+ /** The text, when you control it. */
81
+ value?: string;
82
+ /** The text at first, when it controls it itself.
83
+ * @default "" */
84
+ defaultValue?: string;
85
+ /** Called with the text on every change. */
86
+ onChange?(value: string): void;
87
+ /** Called with the mentions in the text when they change: each one's id, label, trigger and place. */
88
+ onMentionsChange?(mentions: Mention[]): void;
89
+ /** A Textarea that grows with its text, in place of a one-line Input.
90
+ * @default false */
91
+ multiline?: boolean;
92
+ /** The rows a multiline box shows when it's empty.
93
+ * @default 3 */
94
+ rows?: number;
95
+ /** The tallest a multiline box grows before it scrolls. A number is pixels.
96
+ * @default 180 */
97
+ maxHeight?: number | string;
98
+ placeholder?: string;
99
+ /** The text box and the list: sm 32px for toolbars, md 40px in forms. A multiline box keeps its own size.
100
+ * @default "md" */
101
+ size?: "sm" | "md";
102
+ /** Shows the field as wrong. Field sets it when there's an error.
103
+ * @default false */
104
+ isInvalid?: boolean;
105
+ /** @default false */
106
+ disabled?: boolean;
107
+ /** Submits the text under this name, so a Form or a plain form sends it. */
108
+ name?: string;
109
+ /** The text box's id, which a Field's label points at. */
110
+ id?: string;
111
+ autoFocus?: boolean;
112
+ /** Called for each key the open list doesn't take, such as Enter to send while it's closed. */
113
+ onKeyDown?(event: KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>): void;
114
+ "aria-label"?: string;
115
+ "aria-labelledby"?: string;
116
+ "aria-describedby"?: string;
117
+ labels?: MentionLabels;
118
+ className?: string;
119
+ }
120
+ /** The trigger being typed: which one, where it starts, and the text after it. Internal. */
121
+ export interface MentionMatch {
122
+ trigger: MentionTrigger;
123
+ start: number;
124
+ query: string;
125
+ }
@@ -0,0 +1,125 @@
1
+ import type { KeyboardEvent, ReactNode, RefCallback } from "react";
2
+ export interface MentionOption {
3
+ /** Identifies what was picked, in `mentions`: a user id, a command name. */
4
+ id: string;
5
+ /** The text shown in the list, matched as people type, and put in the text after the trigger: "@Ada Lovelace". */
6
+ label: string;
7
+ /** A muted line under the label in the list; matched too when it's a string. */
8
+ description?: ReactNode;
9
+ /** A small icon or avatar before the label. */
10
+ icon?: ReactNode;
11
+ disabled?: boolean;
12
+ }
13
+ export interface MentionTrigger {
14
+ /** What opens the list when it's typed at the start of a word: "@", "/", "#". */
15
+ char: string;
16
+ /**
17
+ * What to suggest. A list is filtered by what's typed after the trigger. A function gets that text and returns
18
+ * the options to show, itself or in a promise (to search a server); the list shows a spinner while it waits.
19
+ */
20
+ options: MentionOption[] | ((query: string) => MentionOption[] | Promise<MentionOption[]>);
21
+ /** Called after an option is put in the text. */
22
+ onSelect?(option: MentionOption): void;
23
+ /** Draws an option's row in the list in place of its icon, label and description. */
24
+ render?(option: MentionOption): ReactNode;
25
+ /** Names the list for screen readers while this trigger has it open, such as "People".
26
+ * @default labels.suggestions */
27
+ label?: string;
28
+ }
29
+ /** A mention in the text, found from the options picked (and every option of a trigger with a list). */
30
+ export interface Mention {
31
+ /** The option's id. */
32
+ id: string;
33
+ label: string;
34
+ /** The trigger it was typed with: "@". */
35
+ trigger: string;
36
+ /** Where it starts in the text, at the trigger. */
37
+ start: number;
38
+ /** Where it ends, after the label. */
39
+ end: number;
40
+ }
41
+ /** The words it uses, for other languages. */
42
+ export interface MentionLabels {
43
+ /** Names the list when its trigger has no `label`. @default "Suggestions" */
44
+ suggestions?: string;
45
+ /** Shown and read out while options load. @default "Loading…" */
46
+ loading?: string;
47
+ /** Shown and read out when nothing matches. @default "No matches" */
48
+ empty?: string;
49
+ /** Read out with the number of options. @default (count) => `${count} results` */
50
+ results?(count: number): string;
51
+ }
52
+ export interface UseMentionsOptions {
53
+ triggers: MentionTrigger[];
54
+ /** The text, when you control it, so `mentions` follows changes made from outside (clearing it after a send).
55
+ * Without it, the hook reads the text box as people type. */
56
+ value?: string;
57
+ /** Called with the mentions in the text when they change. */
58
+ onMentionsChange?(mentions: Mention[]): void;
59
+ /** Turns the suggestions off.
60
+ * @default false */
61
+ disabled?: boolean;
62
+ /** The list's rows: md 36px, sm 32px.
63
+ * @default "md" */
64
+ size?: "sm" | "md";
65
+ labels?: MentionLabels;
66
+ }
67
+ export interface UseMentionsResult {
68
+ /** Put on the text box: a <textarea> or <input>, a Textarea, an Input, or PromptInput (its ref is the textarea). */
69
+ ref: RefCallback<HTMLTextAreaElement | HTMLInputElement>;
70
+ /** Render it anywhere, such as right after the text box: the floating list and its live region. */
71
+ list: ReactNode;
72
+ /** The mentions in the text, in order. */
73
+ mentions: Mention[];
74
+ /** Whether the list is open. */
75
+ isOpen: boolean;
76
+ }
77
+ export interface MentionInputProps {
78
+ /** The characters that open suggestions, with their options. */
79
+ triggers: MentionTrigger[];
80
+ /** The text, when you control it. */
81
+ value?: string;
82
+ /** The text at first, when it controls it itself.
83
+ * @default "" */
84
+ defaultValue?: string;
85
+ /** Called with the text on every change. */
86
+ onChange?(value: string): void;
87
+ /** Called with the mentions in the text when they change: each one's id, label, trigger and place. */
88
+ onMentionsChange?(mentions: Mention[]): void;
89
+ /** A Textarea that grows with its text, in place of a one-line Input.
90
+ * @default false */
91
+ multiline?: boolean;
92
+ /** The rows a multiline box shows when it's empty.
93
+ * @default 3 */
94
+ rows?: number;
95
+ /** The tallest a multiline box grows before it scrolls. A number is pixels.
96
+ * @default 180 */
97
+ maxHeight?: number | string;
98
+ placeholder?: string;
99
+ /** The text box and the list: sm 32px for toolbars, md 40px in forms. A multiline box keeps its own size.
100
+ * @default "md" */
101
+ size?: "sm" | "md";
102
+ /** Shows the field as wrong. Field sets it when there's an error.
103
+ * @default false */
104
+ isInvalid?: boolean;
105
+ /** @default false */
106
+ disabled?: boolean;
107
+ /** Submits the text under this name, so a Form or a plain form sends it. */
108
+ name?: string;
109
+ /** The text box's id, which a Field's label points at. */
110
+ id?: string;
111
+ autoFocus?: boolean;
112
+ /** Called for each key the open list doesn't take, such as Enter to send while it's closed. */
113
+ onKeyDown?(event: KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>): void;
114
+ "aria-label"?: string;
115
+ "aria-labelledby"?: string;
116
+ "aria-describedby"?: string;
117
+ labels?: MentionLabels;
118
+ className?: string;
119
+ }
120
+ /** The trigger being typed: which one, where it starts, and the text after it. Internal. */
121
+ export interface MentionMatch {
122
+ trigger: MentionTrigger;
123
+ start: number;
124
+ query: string;
125
+ }
@@ -0,0 +1,8 @@
1
+ import type { UseMentionsOptions, UseMentionsResult } from "./MentionInput.types.cjs";
2
+ /**
3
+ * `@` mentions and `/` commands for any text box. Put `ref` on a textarea or input (a Textarea, an Input, or
4
+ * PromptInput) and render `list`: typing a trigger at the start of a word opens suggestions at the caret, and picking
5
+ * one puts "@Label " in the text. The box becomes a combobox; the hook listens to it directly, so the component that
6
+ * owns it needs no changes.
7
+ */
8
+ export declare function useMentions({ triggers, value, onMentionsChange, disabled, size, labels }: UseMentionsOptions): UseMentionsResult;
@@ -0,0 +1,8 @@
1
+ import type { UseMentionsOptions, UseMentionsResult } from "./MentionInput.types.js";
2
+ /**
3
+ * `@` mentions and `/` commands for any text box. Put `ref` on a textarea or input (a Textarea, an Input, or
4
+ * PromptInput) and render `list`: typing a trigger at the start of a word opens suggestions at the caret, and picking
5
+ * one puts "@Label " in the text. The box becomes a combobox; the hook listens to it directly, so the component that
6
+ * owns it needs no changes.
7
+ */
8
+ export declare function useMentions({ triggers, value, onMentionsChange, disabled, size, labels }: UseMentionsOptions): UseMentionsResult;
@@ -0,0 +1,12 @@
1
+ import type { NotificationCenterProps, NotificationListProps } from "./NotificationCenter.types.cjs";
2
+ export type { NotificationCenterProps, NotificationFilter, NotificationItem, NotificationLabels, NotificationListProps, } from "./NotificationCenter.types.cjs";
3
+ /**
4
+ * The notifications as a list, newest first, optionally under Today, Yesterday and Earlier. NotificationCenter shows it
5
+ * in its popover; use it on its own for a full page of them.
6
+ */
7
+ export declare function NotificationList({ items, onRead, onDismiss, onItemClick, groupByDay, empty, locale, labels, "aria-label": ariaLabel, className, }: NotificationListProps): import("react").JSX.Element;
8
+ /**
9
+ * A bell with the unread count that opens the latest notifications in a popover: All and Unread tabs, "Mark all as
10
+ * read", and a footer for a link to the full page. New ones that arrive while it's closed are announced once.
11
+ */
12
+ export declare function NotificationCenter({ items, onRead, onReadAll, onDismiss, onItemClick, open, defaultOpen, onOpenChange, tabs, filter, defaultFilter, onFilterChange, footer, empty, maxCount, trigger, width, groupByDay, locale, labels, className, }: NotificationCenterProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { NotificationCenterProps, NotificationListProps } from "./NotificationCenter.types.js";
2
+ export type { NotificationCenterProps, NotificationFilter, NotificationItem, NotificationLabels, NotificationListProps, } from "./NotificationCenter.types.js";
3
+ /**
4
+ * The notifications as a list, newest first, optionally under Today, Yesterday and Earlier. NotificationCenter shows it
5
+ * in its popover; use it on its own for a full page of them.
6
+ */
7
+ export declare function NotificationList({ items, onRead, onDismiss, onItemClick, groupByDay, empty, locale, labels, "aria-label": ariaLabel, className, }: NotificationListProps): import("react").JSX.Element;
8
+ /**
9
+ * A bell with the unread count that opens the latest notifications in a popover: All and Unread tabs, "Mark all as
10
+ * read", and a footer for a link to the full page. New ones that arrive while it's closed are announced once.
11
+ */
12
+ export declare function NotificationCenter({ items, onRead, onReadAll, onDismiss, onItemClick, open, defaultOpen, onOpenChange, tabs, filter, defaultFilter, onFilterChange, footer, empty, maxCount, trigger, width, groupByDay, locale, labels, className, }: NotificationCenterProps): import("react").JSX.Element;
@@ -0,0 +1,129 @@
1
+ import type { MouseEvent, ReactElement, ReactNode } from "react";
2
+ export interface NotificationItem {
3
+ /** Unique among the items. */
4
+ id: string;
5
+ /** What happened, in a line: "Clara mentioned you in Pricing". It names the item for screen readers. */
6
+ title: ReactNode;
7
+ /** A second line: a quote, or where it happened. */
8
+ description?: ReactNode;
9
+ /** When it happened: a Date or an ISO string. It shows as "5 min ago", with the full date on hover. */
10
+ time: Date | string;
11
+ /** Seen already. Unread items are bold, with a dot and a hidden "Unread" for screen readers. */
12
+ read?: boolean;
13
+ /** Who it's from, usually an `<Avatar>`. Hidden from screen readers: say who in the title. */
14
+ avatar?: ReactNode;
15
+ /** A 16px icon on a round tile, for things no person did (a deploy, a reminder), when there's no avatar. */
16
+ icon?: ReactNode;
17
+ /** Makes the item a link to what it's about. Without it, the item is a button. */
18
+ href?: string;
19
+ /** A button or two beside the item, such as Accept and Decline. They sit outside the item's own link. */
20
+ actions?: ReactNode;
21
+ /** The heading it's listed under. Set it to group by your own sections; it wins over `groupByDay`. */
22
+ group?: string;
23
+ }
24
+ export interface NotificationLabels {
25
+ /** The popover's heading and name. @default "Notifications" */
26
+ title?: string;
27
+ /** The bell's name with the count. @default (unread) => unread ? `Notifications, ${unread} unread` : "Notifications" */
28
+ trigger?(unread: number): string;
29
+ /** @default "Mark all as read" */
30
+ markAllRead?: string;
31
+ /** The tab list's name. @default "Show" */
32
+ filter?: string;
33
+ /** @default "All" */
34
+ all?: string;
35
+ /** @default "Unread" */
36
+ unreadTab?: string;
37
+ /** Read before each unread item. @default "Unread" */
38
+ unread?: string;
39
+ /** The ✕ on each item, followed by its title. @default "Dismiss" */
40
+ dismiss?: string;
41
+ /** Said once when new ones arrive while it's closed. @default (count) => count === 1 ? "1 new notification" : `${count} new notifications` */
42
+ announce?(count: number): string;
43
+ /** @default "Today" */
44
+ today?: string;
45
+ /** @default "Yesterday" */
46
+ yesterday?: string;
47
+ /** @default "Earlier" */
48
+ earlier?: string;
49
+ /** The empty list's title. @default "You're all caught up" */
50
+ empty?: string;
51
+ /** The empty Unread tab's title. @default "No unread notifications" */
52
+ emptyUnread?: string;
53
+ }
54
+ export interface NotificationListProps {
55
+ /** The notifications, newest first. */
56
+ items: NotificationItem[];
57
+ /** Called with an unread item's id when it's opened. */
58
+ onRead?(id: string): void;
59
+ /** Shows a ✕ on each item that calls this with its id; remove the item from `items`. */
60
+ onDismiss?(id: string): void;
61
+ /** Called when an item is clicked, before its link is followed. */
62
+ onItemClick?(item: NotificationItem, event: MouseEvent<HTMLElement>): void;
63
+ /** Lists the items under Today, Yesterday and Earlier. An item's own `group` wins.
64
+ * @default false */
65
+ groupByDay?: boolean;
66
+ /** What shows when there are no items.
67
+ * @default an EmptyState saying "You're all caught up" */
68
+ empty?: ReactNode;
69
+ /** The locale for "5 min ago" and dates. Defaults to the browser's. */
70
+ locale?: string;
71
+ /** The words it uses, for other languages. */
72
+ labels?: NotificationLabels;
73
+ /** Names the list for screen readers, when it has no heading of its own. */
74
+ "aria-label"?: string;
75
+ className?: string;
76
+ }
77
+ export interface NotificationCenterProps extends Omit<NotificationListProps, "aria-label"> {
78
+ /** Called when "Mark all as read" is pressed; mark every item read. */
79
+ onReadAll?(): void;
80
+ /** Shown, when you control it. */
81
+ open?: boolean;
82
+ /** Shown at first, when it controls itself. Opened on load, it doesn't pull focus into it.
83
+ * @default false */
84
+ defaultOpen?: boolean;
85
+ /** Called when it opens or closes. */
86
+ onOpenChange?(open: boolean): void;
87
+ /** All and Unread tabs above the list.
88
+ * @default true */
89
+ tabs?: boolean;
90
+ /** The tab showing, when you control it. */
91
+ filter?: NotificationFilter;
92
+ /** The tab it starts on, when it controls itself.
93
+ * @default "all" */
94
+ defaultFilter?: NotificationFilter;
95
+ /** Called when the tab changes. */
96
+ onFilterChange?(filter: NotificationFilter): void;
97
+ /** Under the list, such as a "View all" link to a full page. */
98
+ footer?: ReactNode;
99
+ /** The badge shows "9+" above this.
100
+ * @default 9 */
101
+ maxCount?: number;
102
+ /** Your own button in place of the bell. Give it an aria-label with the unread count. */
103
+ trigger?: ReactElement;
104
+ /** Pixels, or any CSS width. It never gets wider than the window, less a margin.
105
+ * @default 380 */
106
+ width?: number | string;
107
+ }
108
+ /** Which items a NotificationCenter lists. */
109
+ export type NotificationFilter = "all" | "unread";
110
+ /** Internal: a run of items under one heading. */
111
+ export interface NotificationGroup {
112
+ key: string;
113
+ label?: string;
114
+ items: NotificationItem[];
115
+ }
116
+ /** Internal: one row of the list. */
117
+ export interface NotificationRowProps {
118
+ item: NotificationItem;
119
+ /** "5 min ago", or the date when it's older than a week. */
120
+ relative: string;
121
+ /** The full date and time, for the hover title. */
122
+ full: string;
123
+ /** The machine-readable time, for `<time dateTime>`. */
124
+ iso?: string;
125
+ labels: NotificationLabels;
126
+ onRead?(id: string): void;
127
+ onDismiss?(id: string): void;
128
+ onItemClick?(item: NotificationItem, event: MouseEvent<HTMLElement>): void;
129
+ }