@openwarelabs/ui 0.14.1 → 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/README.md +5 -5
- 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/InlineEdit/InlineEdit.d.cts +8 -0
- package/dist/components/InlineEdit/InlineEdit.d.ts +8 -0
- package/dist/components/InlineEdit/InlineEdit.types.d.cts +74 -0
- package/dist/components/InlineEdit/InlineEdit.types.d.ts +74 -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/NavigationMenu/NavigationMenu.d.cts +14 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.ts +14 -0
- package/dist/components/NavigationMenu/NavigationMenu.types.d.cts +84 -0
- package/dist/components/NavigationMenu/NavigationMenu.types.d.ts +84 -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/SortableList/SortableList.d.cts +7 -0
- package/dist/components/SortableList/SortableList.d.ts +7 -0
- package/dist/components/SortableList/SortableList.types.d.cts +82 -0
- package/dist/components/SortableList/SortableList.types.d.ts +82 -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/TreeView/TreeView.d.cts +8 -0
- package/dist/components/TreeView/TreeView.d.ts +8 -0
- package/dist/components/TreeView/TreeView.types.d.cts +88 -0
- package/dist/components/TreeView/TreeView.types.d.ts +88 -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/VirtualList/VirtualList.d.cts +9 -0
- package/dist/components/VirtualList/VirtualList.d.ts +9 -0
- package/dist/components/VirtualList/VirtualList.types.d.cts +80 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +80 -0
- package/dist/components/VirtualList/useVirtualizer.d.cts +60 -0
- package/dist/components/VirtualList/useVirtualizer.d.ts +60 -0
- package/dist/components.css +1840 -113
- package/dist/index.cjs +6770 -2144
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +6790 -2124
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +24 -8
- package/dist/styles.css +1840 -113
- package/package.json +1 -1
|
@@ -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 { SortableListProps } from "./SortableList.types.cjs";
|
|
2
|
+
export type { SortableListItemState, SortableListLabels, SortableListProps } from "./SortableList.types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A list people put in order: drag an item (by the whole row, or by its grip with `handle`) and the others move to
|
|
5
|
+
* make room, or focus it, press Space, move it with the arrow keys and press Space again. Each step is read out.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SortableList<Item>({ items, defaultItems, onReorder, renderItem, getKey, itemLabel, label, handle, orientation, disabled, labels: labelsProp, className, ...props }: SortableListProps<Item>): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SortableListProps } from "./SortableList.types.js";
|
|
2
|
+
export type { SortableListItemState, SortableListLabels, SortableListProps } from "./SortableList.types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A list people put in order: drag an item (by the whole row, or by its grip with `handle`) and the others move to
|
|
5
|
+
* make room, or focus it, press Space, move it with the arrow keys and press Space again. Each step is read out.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SortableList<Item>({ items, defaultItems, onReorder, renderItem, getKey, itemLabel, label, handle, orientation, disabled, labels: labelsProp, className, ...props }: SortableListProps<Item>): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { HTMLAttributes, Key, ReactNode } from "react";
|
|
2
|
+
export interface SortableListLabels {
|
|
3
|
+
/** Read out when an item is picked up.
|
|
4
|
+
* @default (item, position, total) => `Picked up ${item}. Position ${position} of ${total}.` */
|
|
5
|
+
pickedUp?(item: string, position: number, total: number): string;
|
|
6
|
+
/** Read out at each step while it's carried.
|
|
7
|
+
* @default (item, position, total) => `${item}, position ${position} of ${total}.` */
|
|
8
|
+
moved?(item: string, position: number, total: number): string;
|
|
9
|
+
/** Read out when it's put down.
|
|
10
|
+
* @default (item, position, total) => `Dropped ${item} at position ${position} of ${total}.` */
|
|
11
|
+
dropped?(item: string, position: number, total: number): string;
|
|
12
|
+
/** Read out when Escape puts it back.
|
|
13
|
+
* @default (item, position, total) => `Cancelled. ${item} is back at position ${position} of ${total}.` */
|
|
14
|
+
cancelled?(item: string, position: number, total: number): string;
|
|
15
|
+
/** Each item's description, telling screen reader users how to move it.
|
|
16
|
+
* @default "Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel." */
|
|
17
|
+
instructions?: string;
|
|
18
|
+
/** The grip's name, before the item's own text: "Reorder Columns".
|
|
19
|
+
* @default "Reorder" */
|
|
20
|
+
handle?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SortableListItemState {
|
|
23
|
+
/** Where the item is in the list, from 0. */
|
|
24
|
+
index: number;
|
|
25
|
+
/** It's picked up: being dragged, or carried with the keyboard. */
|
|
26
|
+
isDragging: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface SortableListProps<Item> extends Omit<HTMLAttributes<HTMLOListElement>, "children" | "onChange" | "defaultValue"> {
|
|
29
|
+
/** The items in order, when you control them. */
|
|
30
|
+
items?: Item[];
|
|
31
|
+
/** The items at first, when it keeps the order itself.
|
|
32
|
+
* @default [] */
|
|
33
|
+
defaultItems?: Item[];
|
|
34
|
+
/** Called with the items in their new order, and where the moved one was and went (indexes from 0). */
|
|
35
|
+
onReorder?(items: Item[], move: {
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
}): void;
|
|
39
|
+
/** What each item shows. */
|
|
40
|
+
renderItem(item: Item, state: SortableListItemState): ReactNode;
|
|
41
|
+
/** Gives each item a unique key.
|
|
42
|
+
* @default (item) => item.id, or the item itself when it's a string or a number */
|
|
43
|
+
getKey?(item: Item): Key;
|
|
44
|
+
/** Names an item in what's read out as it moves ("Picked up Email"). Defaults to the item when it's a string
|
|
45
|
+
* or a number, else the text it shows. */
|
|
46
|
+
itemLabel?(item: Item): string;
|
|
47
|
+
/** Names the list for screen readers: "Column order". Required unless `aria-labelledby` points at a heading. */
|
|
48
|
+
label?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Only a grip at the start of each row picks it up, rather than the whole row. Use it when rows hold their own
|
|
51
|
+
* buttons, switches or links, or on long lists people scroll by touch.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
handle?: boolean;
|
|
55
|
+
/** `horizontal` lays the items in a row that scrolls sideways; the arrow keys follow the text direction.
|
|
56
|
+
* @default "vertical" */
|
|
57
|
+
orientation?: "vertical" | "horizontal";
|
|
58
|
+
/** @default false */
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/** The words it reads out, for other languages. */
|
|
61
|
+
labels?: SortableListLabels;
|
|
62
|
+
}
|
|
63
|
+
/** Where the items were when the drag started, along the list's axis, in viewport pixels. Internal. */
|
|
64
|
+
export interface SortableGeometry {
|
|
65
|
+
lo: number[];
|
|
66
|
+
hi: number[];
|
|
67
|
+
/** -1 when the list runs backwards on screen: a row in right-to-left text. */
|
|
68
|
+
dir: number;
|
|
69
|
+
/** How far the others move to make room: the picked-up item's size and the gap after it. */
|
|
70
|
+
step: number;
|
|
71
|
+
scroller: Element;
|
|
72
|
+
scroll: number;
|
|
73
|
+
}
|
|
74
|
+
/** A drag in progress, by pointer or keyboard. Internal. */
|
|
75
|
+
export interface SortableDrag {
|
|
76
|
+
from: number;
|
|
77
|
+
to: number;
|
|
78
|
+
/** How far a dragged item has followed the pointer. */
|
|
79
|
+
offset: number;
|
|
80
|
+
keyboard: boolean;
|
|
81
|
+
geo: SortableGeometry;
|
|
82
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { HTMLAttributes, Key, ReactNode } from "react";
|
|
2
|
+
export interface SortableListLabels {
|
|
3
|
+
/** Read out when an item is picked up.
|
|
4
|
+
* @default (item, position, total) => `Picked up ${item}. Position ${position} of ${total}.` */
|
|
5
|
+
pickedUp?(item: string, position: number, total: number): string;
|
|
6
|
+
/** Read out at each step while it's carried.
|
|
7
|
+
* @default (item, position, total) => `${item}, position ${position} of ${total}.` */
|
|
8
|
+
moved?(item: string, position: number, total: number): string;
|
|
9
|
+
/** Read out when it's put down.
|
|
10
|
+
* @default (item, position, total) => `Dropped ${item} at position ${position} of ${total}.` */
|
|
11
|
+
dropped?(item: string, position: number, total: number): string;
|
|
12
|
+
/** Read out when Escape puts it back.
|
|
13
|
+
* @default (item, position, total) => `Cancelled. ${item} is back at position ${position} of ${total}.` */
|
|
14
|
+
cancelled?(item: string, position: number, total: number): string;
|
|
15
|
+
/** Each item's description, telling screen reader users how to move it.
|
|
16
|
+
* @default "Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel." */
|
|
17
|
+
instructions?: string;
|
|
18
|
+
/** The grip's name, before the item's own text: "Reorder Columns".
|
|
19
|
+
* @default "Reorder" */
|
|
20
|
+
handle?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SortableListItemState {
|
|
23
|
+
/** Where the item is in the list, from 0. */
|
|
24
|
+
index: number;
|
|
25
|
+
/** It's picked up: being dragged, or carried with the keyboard. */
|
|
26
|
+
isDragging: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface SortableListProps<Item> extends Omit<HTMLAttributes<HTMLOListElement>, "children" | "onChange" | "defaultValue"> {
|
|
29
|
+
/** The items in order, when you control them. */
|
|
30
|
+
items?: Item[];
|
|
31
|
+
/** The items at first, when it keeps the order itself.
|
|
32
|
+
* @default [] */
|
|
33
|
+
defaultItems?: Item[];
|
|
34
|
+
/** Called with the items in their new order, and where the moved one was and went (indexes from 0). */
|
|
35
|
+
onReorder?(items: Item[], move: {
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
}): void;
|
|
39
|
+
/** What each item shows. */
|
|
40
|
+
renderItem(item: Item, state: SortableListItemState): ReactNode;
|
|
41
|
+
/** Gives each item a unique key.
|
|
42
|
+
* @default (item) => item.id, or the item itself when it's a string or a number */
|
|
43
|
+
getKey?(item: Item): Key;
|
|
44
|
+
/** Names an item in what's read out as it moves ("Picked up Email"). Defaults to the item when it's a string
|
|
45
|
+
* or a number, else the text it shows. */
|
|
46
|
+
itemLabel?(item: Item): string;
|
|
47
|
+
/** Names the list for screen readers: "Column order". Required unless `aria-labelledby` points at a heading. */
|
|
48
|
+
label?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Only a grip at the start of each row picks it up, rather than the whole row. Use it when rows hold their own
|
|
51
|
+
* buttons, switches or links, or on long lists people scroll by touch.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
handle?: boolean;
|
|
55
|
+
/** `horizontal` lays the items in a row that scrolls sideways; the arrow keys follow the text direction.
|
|
56
|
+
* @default "vertical" */
|
|
57
|
+
orientation?: "vertical" | "horizontal";
|
|
58
|
+
/** @default false */
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/** The words it reads out, for other languages. */
|
|
61
|
+
labels?: SortableListLabels;
|
|
62
|
+
}
|
|
63
|
+
/** Where the items were when the drag started, along the list's axis, in viewport pixels. Internal. */
|
|
64
|
+
export interface SortableGeometry {
|
|
65
|
+
lo: number[];
|
|
66
|
+
hi: number[];
|
|
67
|
+
/** -1 when the list runs backwards on screen: a row in right-to-left text. */
|
|
68
|
+
dir: number;
|
|
69
|
+
/** How far the others move to make room: the picked-up item's size and the gap after it. */
|
|
70
|
+
step: number;
|
|
71
|
+
scroller: Element;
|
|
72
|
+
scroll: number;
|
|
73
|
+
}
|
|
74
|
+
/** A drag in progress, by pointer or keyboard. Internal. */
|
|
75
|
+
export interface SortableDrag {
|
|
76
|
+
from: number;
|
|
77
|
+
to: number;
|
|
78
|
+
/** How far a dragged item has followed the pointer. */
|
|
79
|
+
offset: number;
|
|
80
|
+
keyboard: boolean;
|
|
81
|
+
geo: SortableGeometry;
|
|
82
|
+
}
|
|
@@ -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
|
+
}
|