@openwarelabs/ui 0.15.0 → 0.16.1
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/README.md +8 -8
- package/dist/components/ActivityHeatmap/ActivityHeatmap.d.cts +8 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.d.ts +8 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.cts +73 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.ts +73 -0
- package/dist/components/DiffViewer/DiffViewer.d.cts +8 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +8 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.cts +131 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +131 -0
- package/dist/components/DiffViewer/diff.d.cts +10 -0
- package/dist/components/DiffViewer/diff.d.ts +10 -0
- package/dist/components/Markdown/Markdown.d.cts +8 -0
- package/dist/components/Markdown/Markdown.d.ts +8 -0
- package/dist/components/Markdown/Markdown.types.d.cts +59 -0
- package/dist/components/Markdown/Markdown.types.d.ts +59 -0
- package/dist/components/MediaPlayer/MediaPlayer.d.cts +8 -0
- package/dist/components/MediaPlayer/MediaPlayer.d.ts +8 -0
- package/dist/components/MediaPlayer/MediaPlayer.types.d.cts +109 -0
- package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +109 -0
- package/dist/components/MentionInput/MentionInput.d.cts +9 -0
- package/dist/components/MentionInput/MentionInput.d.ts +9 -0
- package/dist/components/MentionInput/MentionInput.types.d.cts +125 -0
- package/dist/components/MentionInput/MentionInput.types.d.ts +125 -0
- package/dist/components/MentionInput/useMentions.d.cts +8 -0
- package/dist/components/MentionInput/useMentions.d.ts +8 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.cts +12 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +12 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.cts +129 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +129 -0
- package/dist/components/QRCode/QRCode.d.cts +18 -0
- package/dist/components/QRCode/QRCode.d.ts +18 -0
- package/dist/components/QRCode/QRCode.types.d.cts +53 -0
- package/dist/components/QRCode/QRCode.types.d.ts +53 -0
- package/dist/components/QRCode/qr.d.cts +8 -0
- package/dist/components/QRCode/qr.d.ts +8 -0
- package/dist/components/SignaturePad/SignaturePad.d.cts +8 -0
- package/dist/components/SignaturePad/SignaturePad.d.ts +8 -0
- package/dist/components/SignaturePad/SignaturePad.types.d.cts +102 -0
- package/dist/components/SignaturePad/SignaturePad.types.d.ts +102 -0
- package/dist/components/TransferList/TransferList.d.cts +7 -0
- package/dist/components/TransferList/TransferList.d.ts +7 -0
- package/dist/components/TransferList/TransferList.types.d.cts +75 -0
- package/dist/components/TransferList/TransferList.types.d.ts +75 -0
- package/dist/components/UploadList/UploadList.d.cts +9 -0
- package/dist/components/UploadList/UploadList.d.ts +9 -0
- package/dist/components/UploadList/UploadList.types.d.cts +113 -0
- package/dist/components/UploadList/UploadList.types.d.ts +113 -0
- package/dist/components/UploadList/useUploadQueue.d.cts +8 -0
- package/dist/components/UploadList/useUploadQueue.d.ts +8 -0
- package/dist/components.css +1194 -104
- package/dist/index.cjs +5489 -2267
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +5518 -2280
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +24 -9
- package/dist/styles.css +1194 -104
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ComponentType, ElementType, MouseEvent } from "react";
|
|
2
|
+
import type { ProseProps } from "../Prose/Prose.types.js";
|
|
3
|
+
/** The elements Markdown draws, each of which `components` can replace. */
|
|
4
|
+
export type MarkdownTag = "a" | "blockquote" | "code" | "del" | "em" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "hr" | "img" | "li" | "ol" | "p" | "strong" | "table" | "td" | "th" | "ul";
|
|
5
|
+
/** What a fenced code block's renderer gets. */
|
|
6
|
+
export interface MarkdownCodeBlockProps {
|
|
7
|
+
/** The code, without the fences. */
|
|
8
|
+
code: string;
|
|
9
|
+
/** The word after the opening fence, such as "tsx". */
|
|
10
|
+
language?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Your own renderers, by element: a router's Link for `a`, say. Each gets the element's props and children. */
|
|
13
|
+
export type MarkdownComponents = Partial<Record<MarkdownTag, ElementType>> & {
|
|
14
|
+
/** Renders fenced code. Defaults to the library's CodeBlock. */
|
|
15
|
+
codeBlock?: ComponentType<MarkdownCodeBlockProps>;
|
|
16
|
+
};
|
|
17
|
+
export interface MarkdownProps extends Omit<ProseProps, "size" | "children"> {
|
|
18
|
+
/** The Markdown, as a string. */
|
|
19
|
+
children?: string;
|
|
20
|
+
/** The Markdown, if you'd rather not pass it as children. It wins over children. */
|
|
21
|
+
content?: string;
|
|
22
|
+
/** While the text is still arriving. An unfinished construct at the end (an open code fence, half a `**bold`, a link
|
|
23
|
+
* without its URL yet, half a table row) shows as what it's becoming, never as raw syntax, and the finished blocks
|
|
24
|
+
* above it aren't rendered again. The element is aria-busy meanwhile.
|
|
25
|
+
* @default false */
|
|
26
|
+
streaming?: boolean;
|
|
27
|
+
/** Blinks a caret after the last character while it streams; it holds still for reduced motion. Leave it off inside
|
|
28
|
+
* a streaming ChatMessage, which draws its own.
|
|
29
|
+
* @default false */
|
|
30
|
+
caret?: boolean;
|
|
31
|
+
/** chat sets 14px text with a tight rhythm, for answers in a conversation; article the prose style, for documents.
|
|
32
|
+
* @default "chat" */
|
|
33
|
+
size?: "chat" | "article";
|
|
34
|
+
/** Shows images. Off, an image shows as a link to it, named by its alt text.
|
|
35
|
+
* @default false */
|
|
36
|
+
allowImages?: boolean;
|
|
37
|
+
/** Moves every heading down this many levels, so `#` under a page's own h1 and h2 can be an h3.
|
|
38
|
+
* @default 0 */
|
|
39
|
+
headingOffset?: number;
|
|
40
|
+
/** Replaces the elements it draws with your own renderers. Keep the object stable (outside the component or memoised)
|
|
41
|
+
* so finished blocks aren't rendered again. */
|
|
42
|
+
components?: MarkdownComponents;
|
|
43
|
+
/** Called when a link is clicked, before it's followed; call `event.preventDefault()` to handle it yourself. */
|
|
44
|
+
onLinkClick?(event: MouseEvent<HTMLAnchorElement>, href: string): void;
|
|
45
|
+
}
|
|
46
|
+
/** What every block's renderer reads. Internal. */
|
|
47
|
+
export interface MarkdownContext {
|
|
48
|
+
components: MarkdownComponents | undefined;
|
|
49
|
+
allowImages: boolean;
|
|
50
|
+
headingOffset: number;
|
|
51
|
+
caret: boolean;
|
|
52
|
+
click(event: MouseEvent<HTMLAnchorElement>, href: string): void;
|
|
53
|
+
}
|
|
54
|
+
/** One top-level block, rendered again only when its source or whether it's the streaming end changes. Internal. */
|
|
55
|
+
export interface MarkdownBlockProps {
|
|
56
|
+
source: string;
|
|
57
|
+
context: MarkdownContext;
|
|
58
|
+
tail: boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MediaPlayerHandle, MediaPlayerProps } from "./MediaPlayer.types.cjs";
|
|
2
|
+
export type { MediaPlayerHandle, MediaPlayerLabels, MediaPlayerProps, MediaPlayerSource, MediaPlayerTrack } from "./MediaPlayer.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Plays audio or video with controls built from the library's own buttons, sliders and menu: play, a timeline that shows
|
|
5
|
+
* what's loaded, volume, speed, captions, picture in picture and full screen. The native `<video>` or `<audio>` does the
|
|
6
|
+
* playing; the keys a video site uses work while focus is in the player.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MediaPlayer: import("react").ForwardRefExoticComponent<MediaPlayerProps & import("react").RefAttributes<MediaPlayerHandle>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MediaPlayerHandle, MediaPlayerProps } from "./MediaPlayer.types.js";
|
|
2
|
+
export type { MediaPlayerHandle, MediaPlayerLabels, MediaPlayerProps, MediaPlayerSource, MediaPlayerTrack } from "./MediaPlayer.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Plays audio or video with controls built from the library's own buttons, sliders and menu: play, a timeline that shows
|
|
5
|
+
* what's loaded, volume, speed, captions, picture in picture and full screen. The native `<video>` or `<audio>` does the
|
|
6
|
+
* playing; the keys a video site uses work while focus is in the player.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MediaPlayer: import("react").ForwardRefExoticComponent<MediaPlayerProps & import("react").RefAttributes<MediaPlayerHandle>>;
|
|
@@ -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;
|