@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.
- 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 +5550 -2312
- 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,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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QRCodeDataURLOptions, QRCodeProps } from "./QRCode.types.cjs";
|
|
2
|
+
export type { QRCodeDataURLOptions, QRCodeProps, QRLevel, QROptions } from "./QRCode.types.cjs";
|
|
3
|
+
export { encodeQR } from "./qr.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* A QR code, drawn as one SVG path: for sharing a link, setting up two-factor authentication or pairing a device.
|
|
6
|
+
* The encoder is built in. It's near black on near white in both themes, because scanners need a light ground.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QRCode: import("react").ForwardRefExoticComponent<QRCodeProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
9
|
+
/**
|
|
10
|
+
* The SVG markup of a rendered QR code, with its colours written in, ready to save as a .svg file. Pass the element
|
|
11
|
+
* from the QRCode's ref.
|
|
12
|
+
*/
|
|
13
|
+
export declare function qrCodeToSVG(svg: SVGSVGElement): string;
|
|
14
|
+
/**
|
|
15
|
+
* A rendered QR code as an image data URL, PNG by default, for a download link or a canvas. `scale` multiplies its
|
|
16
|
+
* size for a sharper image. A logo from another origin that doesn't allow CORS is left out; the code still scans.
|
|
17
|
+
*/
|
|
18
|
+
export declare function qrCodeToDataURL(svg: SVGSVGElement, { type, scale }?: QRCodeDataURLOptions): Promise<string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QRCodeDataURLOptions, QRCodeProps } from "./QRCode.types.js";
|
|
2
|
+
export type { QRCodeDataURLOptions, QRCodeProps, QRLevel, QROptions } from "./QRCode.types.js";
|
|
3
|
+
export { encodeQR } from "./qr.js";
|
|
4
|
+
/**
|
|
5
|
+
* A QR code, drawn as one SVG path: for sharing a link, setting up two-factor authentication or pairing a device.
|
|
6
|
+
* The encoder is built in. It's near black on near white in both themes, because scanners need a light ground.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QRCode: import("react").ForwardRefExoticComponent<QRCodeProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
9
|
+
/**
|
|
10
|
+
* The SVG markup of a rendered QR code, with its colours written in, ready to save as a .svg file. Pass the element
|
|
11
|
+
* from the QRCode's ref.
|
|
12
|
+
*/
|
|
13
|
+
export declare function qrCodeToSVG(svg: SVGSVGElement): string;
|
|
14
|
+
/**
|
|
15
|
+
* A rendered QR code as an image data URL, PNG by default, for a download link or a canvas. `scale` multiplies its
|
|
16
|
+
* size for a sharper image. A logo from another origin that doesn't allow CORS is left out; the code still scans.
|
|
17
|
+
*/
|
|
18
|
+
export declare function qrCodeToDataURL(svg: SVGSVGElement, { type, scale }?: QRCodeDataURLOptions): Promise<string>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
/** How much of the code can be damaged or covered and still scan: about 7% (L), 15% (M), 25% (Q) or 30% (H). Higher levels make a denser code. */
|
|
3
|
+
export type QRLevel = "L" | "M" | "Q" | "H";
|
|
4
|
+
export interface QROptions {
|
|
5
|
+
/** The error correction level.
|
|
6
|
+
* @default "M" */
|
|
7
|
+
level?: QRLevel;
|
|
8
|
+
/** The smallest version (1–40) to use, so codes for texts of different lengths can share a size. A longer text still gets a bigger version.
|
|
9
|
+
* @default 1 */
|
|
10
|
+
minVersion?: number;
|
|
11
|
+
/** Forces one of the eight masks (0–7) instead of the one with the lowest penalty. For testing; leave it out. */
|
|
12
|
+
mask?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface QRCodeProps extends Omit<ComponentPropsWithoutRef<"svg">, "color" | "children"> {
|
|
15
|
+
/** The text to encode: a link, an `otpauth://` URI, any text. Encoded as UTF-8, or more densely when it's only digits or upper-case letters. */
|
|
16
|
+
value: string;
|
|
17
|
+
/** The width and height, in pixels. It shrinks to fit a narrower container.
|
|
18
|
+
* @default 160 */
|
|
19
|
+
size?: number;
|
|
20
|
+
/** The error correction level: how much of the code can be damaged and still scan. `image` raises it to H.
|
|
21
|
+
* @default "M" */
|
|
22
|
+
level?: QRLevel;
|
|
23
|
+
/** The smallest version (1–40), so codes for different texts can share the same grid. */
|
|
24
|
+
minVersion?: number;
|
|
25
|
+
/** The quiet zone around the code, in modules. Scanners need about 4; go lower only when the code sits on a plain light ground.
|
|
26
|
+
* @default 4 */
|
|
27
|
+
margin?: number;
|
|
28
|
+
/** The colour of the dark modules: any CSS colour or token, like `"var(--ow-text)"`. Keep it dark and the background light: most scanners can't read inverted codes.
|
|
29
|
+
* @default "var(--ow-gray-950)", near black in both themes */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** The colour behind the modules and in the quiet zone. It stays light in the dark theme, because scanners need a light ground and strong contrast.
|
|
32
|
+
* @default "var(--ow-gray-50)", near white in both themes */
|
|
33
|
+
background?: string;
|
|
34
|
+
/** The accessible name: "QR code for openware.dev". Say where it leads or what it's for.
|
|
35
|
+
* @default "QR code for" and the link's host, or the text when it's short; otherwise "QR code" */
|
|
36
|
+
label?: string;
|
|
37
|
+
/** A logo for the centre, by URL. The modules under it are cleared and the level is raised to H, so the code still scans. */
|
|
38
|
+
image?: string;
|
|
39
|
+
/** The logo's width as a share of the code's, up to 0.3.
|
|
40
|
+
* @default 0.22 */
|
|
41
|
+
imageSize?: number;
|
|
42
|
+
/** Draws each run of dark modules with rounded ends. Still scans, but square modules are the safest.
|
|
43
|
+
* @default false */
|
|
44
|
+
rounded?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface QRCodeDataURLOptions {
|
|
47
|
+
/** The image format, such as `"image/jpeg"`.
|
|
48
|
+
* @default "image/png" */
|
|
49
|
+
type?: string;
|
|
50
|
+
/** Multiplies the code's size in pixels, for a sharper image.
|
|
51
|
+
* @default 4 */
|
|
52
|
+
scale?: number;
|
|
53
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
/** How much of the code can be damaged or covered and still scan: about 7% (L), 15% (M), 25% (Q) or 30% (H). Higher levels make a denser code. */
|
|
3
|
+
export type QRLevel = "L" | "M" | "Q" | "H";
|
|
4
|
+
export interface QROptions {
|
|
5
|
+
/** The error correction level.
|
|
6
|
+
* @default "M" */
|
|
7
|
+
level?: QRLevel;
|
|
8
|
+
/** The smallest version (1–40) to use, so codes for texts of different lengths can share a size. A longer text still gets a bigger version.
|
|
9
|
+
* @default 1 */
|
|
10
|
+
minVersion?: number;
|
|
11
|
+
/** Forces one of the eight masks (0–7) instead of the one with the lowest penalty. For testing; leave it out. */
|
|
12
|
+
mask?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface QRCodeProps extends Omit<ComponentPropsWithoutRef<"svg">, "color" | "children"> {
|
|
15
|
+
/** The text to encode: a link, an `otpauth://` URI, any text. Encoded as UTF-8, or more densely when it's only digits or upper-case letters. */
|
|
16
|
+
value: string;
|
|
17
|
+
/** The width and height, in pixels. It shrinks to fit a narrower container.
|
|
18
|
+
* @default 160 */
|
|
19
|
+
size?: number;
|
|
20
|
+
/** The error correction level: how much of the code can be damaged and still scan. `image` raises it to H.
|
|
21
|
+
* @default "M" */
|
|
22
|
+
level?: QRLevel;
|
|
23
|
+
/** The smallest version (1–40), so codes for different texts can share the same grid. */
|
|
24
|
+
minVersion?: number;
|
|
25
|
+
/** The quiet zone around the code, in modules. Scanners need about 4; go lower only when the code sits on a plain light ground.
|
|
26
|
+
* @default 4 */
|
|
27
|
+
margin?: number;
|
|
28
|
+
/** The colour of the dark modules: any CSS colour or token, like `"var(--ow-text)"`. Keep it dark and the background light: most scanners can't read inverted codes.
|
|
29
|
+
* @default "var(--ow-gray-950)", near black in both themes */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** The colour behind the modules and in the quiet zone. It stays light in the dark theme, because scanners need a light ground and strong contrast.
|
|
32
|
+
* @default "var(--ow-gray-50)", near white in both themes */
|
|
33
|
+
background?: string;
|
|
34
|
+
/** The accessible name: "QR code for openware.dev". Say where it leads or what it's for.
|
|
35
|
+
* @default "QR code for" and the link's host, or the text when it's short; otherwise "QR code" */
|
|
36
|
+
label?: string;
|
|
37
|
+
/** A logo for the centre, by URL. The modules under it are cleared and the level is raised to H, so the code still scans. */
|
|
38
|
+
image?: string;
|
|
39
|
+
/** The logo's width as a share of the code's, up to 0.3.
|
|
40
|
+
* @default 0.22 */
|
|
41
|
+
imageSize?: number;
|
|
42
|
+
/** Draws each run of dark modules with rounded ends. Still scans, but square modules are the safest.
|
|
43
|
+
* @default false */
|
|
44
|
+
rounded?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface QRCodeDataURLOptions {
|
|
47
|
+
/** The image format, such as `"image/jpeg"`.
|
|
48
|
+
* @default "image/png" */
|
|
49
|
+
type?: string;
|
|
50
|
+
/** Multiplies the code's size in pixels, for a sharper image.
|
|
51
|
+
* @default 4 */
|
|
52
|
+
scale?: number;
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QROptions } from "./QRCode.types.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Encodes text as a QR code and returns its modules, row by row: `true` is dark. There is no quiet zone around it. Text
|
|
4
|
+
* of only digits, or only `0–9 A–Z $%*+-./:` and space, uses the denser numeric or alphanumeric mode; anything else is
|
|
5
|
+
* UTF-8 bytes. Picks the smallest version that fits, from `minVersion`, and throws a RangeError when the text is too
|
|
6
|
+
* long even for version 40.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeQR(text: string, { level, minVersion, mask: forcedMask }?: QROptions): boolean[][];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { QROptions } from "./QRCode.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encodes text as a QR code and returns its modules, row by row: `true` is dark. There is no quiet zone around it. Text
|
|
4
|
+
* of only digits, or only `0–9 A–Z $%*+-./:` and space, uses the denser numeric or alphanumeric mode; anything else is
|
|
5
|
+
* UTF-8 bytes. Picks the smallest version that fits, from `minVersion`, and throws a RangeError when the text is too
|
|
6
|
+
* long even for version 40.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeQR(text: string, { level, minVersion, mask: forcedMask }?: QROptions): boolean[][];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SignaturePadHandle, SignaturePadProps } from "./SignaturePad.types.cjs";
|
|
2
|
+
export type { SignaturePadHandle, SignaturePadLabels, SignaturePadProps } from "./SignaturePad.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A box to sign in with a mouse, a finger or a pen, for forms and onboarding. Strokes follow the pen's pressure and are
|
|
5
|
+
* smoothed into curves; Undo takes back the last one. "Type instead" sets a typed name in a script face, for people who
|
|
6
|
+
* can't draw. The value is a PNG (or SVG) data URL, sent with a form under its `name`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SignaturePadHandle, SignaturePadProps } from "./SignaturePad.types.js";
|
|
2
|
+
export type { SignaturePadHandle, SignaturePadLabels, SignaturePadProps } from "./SignaturePad.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A box to sign in with a mouse, a finger or a pen, for forms and onboarding. Strokes follow the pen's pressure and are
|
|
5
|
+
* smoothed into curves; Undo takes back the last one. "Type instead" sets a typed name in a script face, for people who
|
|
6
|
+
* can't draw. The value is a PNG (or SVG) data URL, sent with a form under its `name`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export interface SignaturePadLabels {
|
|
2
|
+
/** The prompt on the empty pad.
|
|
3
|
+
* @default "Sign here" */
|
|
4
|
+
signHere?: string;
|
|
5
|
+
/** @default "Clear" */
|
|
6
|
+
clear?: string;
|
|
7
|
+
/** Takes back the last stroke.
|
|
8
|
+
* @default "Undo" */
|
|
9
|
+
undo?: string;
|
|
10
|
+
/** Switches to typing a name, for people who can't draw (with a keyboard, say).
|
|
11
|
+
* @default "Type instead" */
|
|
12
|
+
typeInstead?: string;
|
|
13
|
+
/** Switches back to drawing.
|
|
14
|
+
* @default "Draw instead" */
|
|
15
|
+
drawInstead?: string;
|
|
16
|
+
/** The typed name's placeholder, and its label when there's no Field.
|
|
17
|
+
* @default "Type your name" */
|
|
18
|
+
typeName?: string;
|
|
19
|
+
/** Reads out the pad, which is an image, for screen readers.
|
|
20
|
+
* @default (signed) => signed ? "Signature, signed" : "Signature, empty" */
|
|
21
|
+
state?(signed: boolean): string;
|
|
22
|
+
}
|
|
23
|
+
export interface SignaturePadProps {
|
|
24
|
+
/**
|
|
25
|
+
* The signature, when you control it: a data URL, "data:image/png;base64,…" (or "data:image/svg+xml,…" with
|
|
26
|
+
* `format="svg"`), ready for an <img src>. "" is no signature. A value that didn't come from the pad, such as a saved
|
|
27
|
+
* one, is drawn in, to show or sign over.
|
|
28
|
+
*/
|
|
29
|
+
value?: string;
|
|
30
|
+
/** The signature at first, when uncontrolled.
|
|
31
|
+
* @default "" */
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
/** Called with the new data URL when a stroke ends, a stroke is undone, the typed name changes, or it's cleared (""). */
|
|
34
|
+
onChange?(value: string): void;
|
|
35
|
+
/** What the value holds: a PNG at twice the pad's size, or an SVG of the strokes (each at its average width).
|
|
36
|
+
* @default "png" */
|
|
37
|
+
format?: "png" | "svg";
|
|
38
|
+
/** The form field name: the data URL is sent under it (nothing when it's empty). */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Asks for a signature before the form can be sent. Needs a `name`. */
|
|
41
|
+
required?: boolean;
|
|
42
|
+
/** Marks it invalid, with an error colour; Field sets this. */
|
|
43
|
+
isInvalid?: boolean;
|
|
44
|
+
/** The ink on screen, as any CSS colour (a token too). It's also the exported ink when set.
|
|
45
|
+
* @default the text colour, so it follows the theme */
|
|
46
|
+
penColor?: string;
|
|
47
|
+
/** The ink in the exported value when there's no `penColor`, so a signature drawn in dark mode isn't saved white.
|
|
48
|
+
* @default "#111111" */
|
|
49
|
+
exportColor?: string;
|
|
50
|
+
/** A colour to fill the exported image's background with. Without it, the export is transparent, and a saved
|
|
51
|
+
* signature shown in the pad is re-inked in the pen colour, so it reads in either theme.
|
|
52
|
+
* @default undefined */
|
|
53
|
+
background?: string;
|
|
54
|
+
/** The stroke width in pixels. A pen's pressure makes it thinner or up to 1.6 times thicker.
|
|
55
|
+
* @default 2.5 */
|
|
56
|
+
penWidth?: number;
|
|
57
|
+
/** The drawing area's height, in pixels or any CSS length.
|
|
58
|
+
* @default 160 */
|
|
59
|
+
height?: number | string;
|
|
60
|
+
/** Offers "Type instead": a text box whose name is set in a script face as the signature.
|
|
61
|
+
* @default true */
|
|
62
|
+
allowTyping?: boolean;
|
|
63
|
+
/** @default false */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Shows the signature without the buttons, and nothing can be drawn.
|
|
66
|
+
* @default false */
|
|
67
|
+
readOnly?: boolean;
|
|
68
|
+
/** Called when Clear is pressed. */
|
|
69
|
+
onClear?(): void;
|
|
70
|
+
/** The words it uses, for other languages. */
|
|
71
|
+
labels?: SignaturePadLabels;
|
|
72
|
+
/** Names the pad for screen readers when there's no Field label, ahead of its state: "Your signature". */
|
|
73
|
+
"aria-label"?: string;
|
|
74
|
+
/** Names the pad by another element's id, such as a Field's label; Field sets this. */
|
|
75
|
+
"aria-labelledby"?: string;
|
|
76
|
+
/** Ids of the hint or error that describe it; Field sets this. */
|
|
77
|
+
"aria-describedby"?: string;
|
|
78
|
+
/** The id of the pad (or of the text box, when typing), so a Field's label points at it; Field sets this. */
|
|
79
|
+
id?: string;
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
/** What a ref to a SignaturePad can do. */
|
|
83
|
+
export interface SignaturePadHandle {
|
|
84
|
+
/** Empties the pad (and calls onChange with ""). */
|
|
85
|
+
clear(): void;
|
|
86
|
+
/** The signature as a data URL, in `format` or the one given; "" when it's empty. */
|
|
87
|
+
toDataURL(format?: "png" | "svg"): string;
|
|
88
|
+
/** True when nothing has been drawn or typed. */
|
|
89
|
+
isEmpty(): boolean;
|
|
90
|
+
}
|
|
91
|
+
/** One sampled point of a stroke: where it is, in pixels, and its width as a share of penWidth. Internal. */
|
|
92
|
+
export interface SignaturePoint {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
w: number;
|
|
96
|
+
}
|
|
97
|
+
/** What paints the pad, on screen or into an export. Internal. */
|
|
98
|
+
export interface SignaturePaint {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
color: string;
|
|
102
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export interface SignaturePadLabels {
|
|
2
|
+
/** The prompt on the empty pad.
|
|
3
|
+
* @default "Sign here" */
|
|
4
|
+
signHere?: string;
|
|
5
|
+
/** @default "Clear" */
|
|
6
|
+
clear?: string;
|
|
7
|
+
/** Takes back the last stroke.
|
|
8
|
+
* @default "Undo" */
|
|
9
|
+
undo?: string;
|
|
10
|
+
/** Switches to typing a name, for people who can't draw (with a keyboard, say).
|
|
11
|
+
* @default "Type instead" */
|
|
12
|
+
typeInstead?: string;
|
|
13
|
+
/** Switches back to drawing.
|
|
14
|
+
* @default "Draw instead" */
|
|
15
|
+
drawInstead?: string;
|
|
16
|
+
/** The typed name's placeholder, and its label when there's no Field.
|
|
17
|
+
* @default "Type your name" */
|
|
18
|
+
typeName?: string;
|
|
19
|
+
/** Reads out the pad, which is an image, for screen readers.
|
|
20
|
+
* @default (signed) => signed ? "Signature, signed" : "Signature, empty" */
|
|
21
|
+
state?(signed: boolean): string;
|
|
22
|
+
}
|
|
23
|
+
export interface SignaturePadProps {
|
|
24
|
+
/**
|
|
25
|
+
* The signature, when you control it: a data URL, "data:image/png;base64,…" (or "data:image/svg+xml,…" with
|
|
26
|
+
* `format="svg"`), ready for an <img src>. "" is no signature. A value that didn't come from the pad, such as a saved
|
|
27
|
+
* one, is drawn in, to show or sign over.
|
|
28
|
+
*/
|
|
29
|
+
value?: string;
|
|
30
|
+
/** The signature at first, when uncontrolled.
|
|
31
|
+
* @default "" */
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
/** Called with the new data URL when a stroke ends, a stroke is undone, the typed name changes, or it's cleared (""). */
|
|
34
|
+
onChange?(value: string): void;
|
|
35
|
+
/** What the value holds: a PNG at twice the pad's size, or an SVG of the strokes (each at its average width).
|
|
36
|
+
* @default "png" */
|
|
37
|
+
format?: "png" | "svg";
|
|
38
|
+
/** The form field name: the data URL is sent under it (nothing when it's empty). */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Asks for a signature before the form can be sent. Needs a `name`. */
|
|
41
|
+
required?: boolean;
|
|
42
|
+
/** Marks it invalid, with an error colour; Field sets this. */
|
|
43
|
+
isInvalid?: boolean;
|
|
44
|
+
/** The ink on screen, as any CSS colour (a token too). It's also the exported ink when set.
|
|
45
|
+
* @default the text colour, so it follows the theme */
|
|
46
|
+
penColor?: string;
|
|
47
|
+
/** The ink in the exported value when there's no `penColor`, so a signature drawn in dark mode isn't saved white.
|
|
48
|
+
* @default "#111111" */
|
|
49
|
+
exportColor?: string;
|
|
50
|
+
/** A colour to fill the exported image's background with. Without it, the export is transparent, and a saved
|
|
51
|
+
* signature shown in the pad is re-inked in the pen colour, so it reads in either theme.
|
|
52
|
+
* @default undefined */
|
|
53
|
+
background?: string;
|
|
54
|
+
/** The stroke width in pixels. A pen's pressure makes it thinner or up to 1.6 times thicker.
|
|
55
|
+
* @default 2.5 */
|
|
56
|
+
penWidth?: number;
|
|
57
|
+
/** The drawing area's height, in pixels or any CSS length.
|
|
58
|
+
* @default 160 */
|
|
59
|
+
height?: number | string;
|
|
60
|
+
/** Offers "Type instead": a text box whose name is set in a script face as the signature.
|
|
61
|
+
* @default true */
|
|
62
|
+
allowTyping?: boolean;
|
|
63
|
+
/** @default false */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Shows the signature without the buttons, and nothing can be drawn.
|
|
66
|
+
* @default false */
|
|
67
|
+
readOnly?: boolean;
|
|
68
|
+
/** Called when Clear is pressed. */
|
|
69
|
+
onClear?(): void;
|
|
70
|
+
/** The words it uses, for other languages. */
|
|
71
|
+
labels?: SignaturePadLabels;
|
|
72
|
+
/** Names the pad for screen readers when there's no Field label, ahead of its state: "Your signature". */
|
|
73
|
+
"aria-label"?: string;
|
|
74
|
+
/** Names the pad by another element's id, such as a Field's label; Field sets this. */
|
|
75
|
+
"aria-labelledby"?: string;
|
|
76
|
+
/** Ids of the hint or error that describe it; Field sets this. */
|
|
77
|
+
"aria-describedby"?: string;
|
|
78
|
+
/** The id of the pad (or of the text box, when typing), so a Field's label points at it; Field sets this. */
|
|
79
|
+
id?: string;
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
/** What a ref to a SignaturePad can do. */
|
|
83
|
+
export interface SignaturePadHandle {
|
|
84
|
+
/** Empties the pad (and calls onChange with ""). */
|
|
85
|
+
clear(): void;
|
|
86
|
+
/** The signature as a data URL, in `format` or the one given; "" when it's empty. */
|
|
87
|
+
toDataURL(format?: "png" | "svg"): string;
|
|
88
|
+
/** True when nothing has been drawn or typed. */
|
|
89
|
+
isEmpty(): boolean;
|
|
90
|
+
}
|
|
91
|
+
/** One sampled point of a stroke: where it is, in pixels, and its width as a share of penWidth. Internal. */
|
|
92
|
+
export interface SignaturePoint {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
w: number;
|
|
96
|
+
}
|
|
97
|
+
/** What paints the pad, on screen or into an export. Internal. */
|
|
98
|
+
export interface SignaturePaint {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
color: string;
|
|
102
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransferListProps } from "./TransferList.types.cjs";
|
|
2
|
+
export type { TransferListOption, TransferListProps } from "./TransferList.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Two lists side by side, the available items and the chosen ones, with buttons between them that move the selected
|
|
5
|
+
* items across: permissions, the columns a table shows, a team's members. Double-click or Enter moves an item too.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TransferList: import("react").ForwardRefExoticComponent<TransferListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransferListProps } from "./TransferList.types.js";
|
|
2
|
+
export type { TransferListOption, TransferListProps } from "./TransferList.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Two lists side by side, the available items and the chosen ones, with buttons between them that move the selected
|
|
5
|
+
* items across: permissions, the columns a table shows, a team's members. Double-click or Enter moves an item too.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TransferList: import("react").ForwardRefExoticComponent<TransferListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface TransferListOption {
|
|
3
|
+
/** What goes in the value when it's chosen. Unique among the options. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** The text in the list, matched by the search and read out when it moves. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** A muted line under the label; matched by the search when it's a string. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** Stays on its side: it can't be selected or moved. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** A heading to show it under. Options with the same group are listed together, groups in the order they first appear. */
|
|
12
|
+
group?: string;
|
|
13
|
+
}
|
|
14
|
+
/** One side of the transfer list. Internal. */
|
|
15
|
+
export type TransferListSide = "source" | "target";
|
|
16
|
+
export interface TransferListProps {
|
|
17
|
+
/** Everything that can be chosen. The available side lists them in this order. */
|
|
18
|
+
options: TransferListOption[];
|
|
19
|
+
/** The chosen values, in order, when you control them. */
|
|
20
|
+
value?: string[];
|
|
21
|
+
/** The chosen values at first, when it controls them itself.
|
|
22
|
+
* @default [] */
|
|
23
|
+
defaultValue?: string[];
|
|
24
|
+
/** Called with the chosen values when they move or are reordered. Moved values join the end. */
|
|
25
|
+
onChange?(value: string[]): void;
|
|
26
|
+
/** The heading over the available list, which also names it.
|
|
27
|
+
* @default "Available" */
|
|
28
|
+
sourceLabel?: string;
|
|
29
|
+
/** The heading over the chosen list, which also names it.
|
|
30
|
+
* @default "Selected" */
|
|
31
|
+
targetLabel?: string;
|
|
32
|
+
/** A search box over each list that filters it by label and description.
|
|
33
|
+
* @default false */
|
|
34
|
+
searchable?: boolean;
|
|
35
|
+
/** Adds buttons that move every item (that the search shows) from one side to the other.
|
|
36
|
+
* @default false */
|
|
37
|
+
showMoveAll?: boolean;
|
|
38
|
+
/** Adds Move up and Move down buttons under the chosen list (and Alt+Up/Down in it), for an order that matters.
|
|
39
|
+
* The chosen list is then shown without group headings, in the value's order.
|
|
40
|
+
* @default false */
|
|
41
|
+
orderable?: boolean;
|
|
42
|
+
/** Submits each chosen value under this name, in a hidden input, so a Form or a plain form sends them as a list. */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Fades both lists and the buttons, and takes them out of the tab order.
|
|
45
|
+
* @default false */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** The lists' height, e.g. 320 or "40vh"; they scroll past it.
|
|
48
|
+
* @default 280 */
|
|
49
|
+
height?: number | string;
|
|
50
|
+
id?: string;
|
|
51
|
+
/** The words it uses, for other languages. `to` is the side's label. */
|
|
52
|
+
labels?: {
|
|
53
|
+
/** The count under each heading. @default (selected, total) => `${selected} of ${total} selected` */
|
|
54
|
+
count?(selected: number, total: number): string;
|
|
55
|
+
/** The button that moves the selected items. @default (count, to) => `Move 2 selected to ${to}`, or `Move selected to ${to}` with none */
|
|
56
|
+
moveSelected?(count: number, to: string): string;
|
|
57
|
+
/** The button that moves them all, with `showMoveAll`. @default (to) => `Move all to ${to}` */
|
|
58
|
+
moveAll?(to: string): string;
|
|
59
|
+
/** Read out after a move. @default (names, to) => `Moved Ada and Grace to ${to}`, or `Moved 7 items to ${to}` past five */
|
|
60
|
+
moved?(names: string[], to: string): string;
|
|
61
|
+
/** With `orderable`. @default "Move up" */
|
|
62
|
+
moveUp?: string;
|
|
63
|
+
/** With `orderable`. @default "Move down" */
|
|
64
|
+
moveDown?: string;
|
|
65
|
+
/** Read out after reordering. @default (names, direction) => `Moved Ada up` */
|
|
66
|
+
reordered?(names: string[], direction: "up" | "down"): string;
|
|
67
|
+
/** Names a side's search box. @default (side) => `Search ${side}` */
|
|
68
|
+
search?(side: string): string;
|
|
69
|
+
/** Shown in an empty list. @default "No items" */
|
|
70
|
+
empty?: ReactNode;
|
|
71
|
+
/** Shown when the search matches nothing. @default "No matches" */
|
|
72
|
+
noMatches?: ReactNode;
|
|
73
|
+
};
|
|
74
|
+
className?: string;
|
|
75
|
+
}
|