@ignite-ember/ui-react 0.2.0 → 0.2.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/NOTICE +1 -1
- package/README.md +56 -13
- package/dist/CopySource.d.ts.map +1 -1
- package/dist/CopySource.js +16 -2
- package/dist/CopySource.js.map +1 -1
- package/dist/DataTable.d.ts +17 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +17 -1
- package/dist/DataTable.js.map +1 -1
- package/dist/Dialog.d.ts +41 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +94 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +31 -2
- package/dist/ErrorBoundary.d.ts.map +1 -1
- package/dist/ErrorBoundary.js +38 -4
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/LiveRegion.d.ts +7 -1
- package/dist/LiveRegion.d.ts.map +1 -1
- package/dist/LiveRegion.js +7 -1
- package/dist/LiveRegion.js.map +1 -1
- package/dist/Markdown.d.ts +4 -0
- package/dist/Markdown.d.ts.map +1 -1
- package/dist/Markdown.js +4 -0
- package/dist/Markdown.js.map +1 -1
- package/dist/MarkdownInline.d.ts +13 -4
- package/dist/MarkdownInline.d.ts.map +1 -1
- package/dist/MarkdownInline.js +20 -5
- package/dist/MarkdownInline.js.map +1 -1
- package/dist/MenuIcon.d.ts +10 -4
- package/dist/MenuIcon.d.ts.map +1 -1
- package/dist/MenuIcon.js +8 -2
- package/dist/MenuIcon.js.map +1 -1
- package/dist/Mermaid.d.ts +2 -0
- package/dist/Mermaid.d.ts.map +1 -1
- package/dist/Mermaid.js +2 -0
- package/dist/Mermaid.js.map +1 -1
- package/dist/Monogram.d.ts +7 -3
- package/dist/Monogram.d.ts.map +1 -1
- package/dist/Monogram.js +14 -6
- package/dist/Monogram.js.map +1 -1
- package/dist/OverflowMenu.d.ts +6 -1
- package/dist/OverflowMenu.d.ts.map +1 -1
- package/dist/OverflowMenu.js +10 -2
- package/dist/OverflowMenu.js.map +1 -1
- package/dist/Shell.d.ts +13 -0
- package/dist/Shell.d.ts.map +1 -1
- package/dist/Shell.js +13 -0
- package/dist/Shell.js.map +1 -1
- package/dist/Skeleton.d.ts +30 -0
- package/dist/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton.js +30 -0
- package/dist/Skeleton.js.map +1 -1
- package/dist/Split.d.ts +24 -5
- package/dist/Split.d.ts.map +1 -1
- package/dist/Split.js +27 -4
- package/dist/Split.js.map +1 -1
- package/dist/Tabs.d.ts +77 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +91 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Toast.d.ts +12 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +11 -0
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.d.ts +12 -3
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +29 -7
- package/dist/Tooltip.js.map +1 -1
- package/dist/controls.d.ts +117 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +59 -0
- package/dist/controls.js.map +1 -0
- package/dist/fenceInfo.d.ts +4 -1
- package/dist/fenceInfo.d.ts.map +1 -1
- package/dist/fenceInfo.js +4 -1
- package/dist/fenceInfo.js.map +1 -1
- package/dist/formControls.d.ts +143 -0
- package/dist/formControls.d.ts.map +1 -0
- package/dist/formControls.js +108 -0
- package/dist/formControls.js.map +1 -0
- package/dist/index.d.ts +5 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +95 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +93 -0
- package/dist/layout.js.map +1 -0
- package/dist/primitives.d.ts +10 -360
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +31 -338
- package/dist/primitives.js.map +1 -1
- package/dist/progress.d.ts +64 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +51 -0
- package/dist/progress.js.map +1 -0
- package/dist/text.d.ts +63 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +61 -0
- package/dist/text.js.map +1 -0
- package/package.json +4 -4
- package/src/CopySource.tsx +17 -2
- package/src/DataTable.tsx +17 -1
- package/src/Dialog.tsx +158 -0
- package/src/ErrorBoundary.tsx +39 -4
- package/src/LiveRegion.tsx +7 -1
- package/src/Markdown.tsx +4 -0
- package/src/MarkdownInline.tsx +20 -7
- package/src/MenuIcon.tsx +10 -4
- package/src/Mermaid.tsx +2 -0
- package/src/Monogram.tsx +14 -5
- package/src/OverflowMenu.tsx +9 -2
- package/src/Shell.tsx +13 -0
- package/src/Skeleton.tsx +30 -0
- package/src/Split.tsx +32 -7
- package/src/Tabs.tsx +194 -0
- package/src/Toast.tsx +12 -1
- package/src/Tooltip.tsx +33 -8
- package/src/controls.tsx +159 -0
- package/src/fenceInfo.ts +5 -2
- package/src/formControls.tsx +249 -0
- package/src/index.ts +5 -9
- package/src/layout.tsx +141 -0
- package/src/primitives.tsx +10 -864
- package/src/progress.tsx +129 -0
- package/src/text.tsx +99 -0
package/dist/Split.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Split.d.ts","sourceRoot":"","sources":["../src/Split.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAML,KAAK,cAAc,EAGnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf,kCAAkC;AAClC,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,CACX;IACC,4BAA4B;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd
|
|
1
|
+
{"version":3,"file":"Split.d.ts","sourceRoot":"","sources":["../src/Split.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAML,KAAK,cAAc,EAGnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf,kCAAkC;AAClC,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,CACX;IACC,4BAA4B;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,IAAc,EACd,YAAkB,EAClB,GAAS,EACT,GAAS,EACT,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,UAAU,+BA8IZ"}
|
package/dist/Split.js
CHANGED
|
@@ -44,8 +44,25 @@ const MOST_OF_WINDOW = 0.6;
|
|
|
44
44
|
/**
|
|
45
45
|
* Two panes and a rule you can move.
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* It drives a CSS variable rather than React state, and it does not
|
|
48
|
+
* remember the width: `onResize` hands the width back, and an
|
|
49
|
+
* extension that wants it kept stores it somewhere that survives a
|
|
50
|
+
* restart (`bridge.setLocation`, or its own backend).
|
|
51
|
+
*
|
|
52
|
+
* @param aside — the fixed-width pane.
|
|
53
|
+
* @param children — the pane that takes what is left.
|
|
54
|
+
* @param side — which side `aside` is on; the left by default.
|
|
55
|
+
* @param defaultWidth — the starting width of `aside`, in pixels.
|
|
56
|
+
* @param min — the narrowest `aside` may be, in pixels.
|
|
57
|
+
* @param max — the widest `aside` may be, in pixels, and never more
|
|
58
|
+
* than 60% of the window.
|
|
59
|
+
* @param label — said to a screen reader, and shown on hover.
|
|
60
|
+
* @param onResize — the width changed; called on release, on each
|
|
61
|
+
* keypress and on a double-click back to `defaultWidth`, not on every
|
|
62
|
+
* pointer move.
|
|
63
|
+
* @param className — added to the element's classes, beside the one the
|
|
64
|
+
* theme gives it.
|
|
65
|
+
* @param rest — the remaining props, spread onto the element.
|
|
49
66
|
*/
|
|
50
67
|
export function Split({ aside, children, side = "start", defaultWidth = 280, min = 160, max = 640, label, onResize, className, ...rest }) {
|
|
51
68
|
// Scoped to this instance, so two splits on one page do not fight
|
|
@@ -116,12 +133,18 @@ export function Split({ aside, children, side = "start", defaultWidth = 280, min
|
|
|
116
133
|
if (next === null)
|
|
117
134
|
return;
|
|
118
135
|
event.preventDefault();
|
|
119
|
-
onResize?.(apply(next))
|
|
136
|
+
// Applied first: `onResize?.(apply(next))` skips the argument
|
|
137
|
+
// when there is no `onResize`, and the pane never moved.
|
|
138
|
+
const width = apply(next);
|
|
139
|
+
onResize?.(width);
|
|
120
140
|
};
|
|
121
141
|
const handle = (_jsx("div", { className: "ui-split-handle", role: "separator", "aria-orientation": "vertical", "aria-label": label, title: label, "aria-valuenow": announced, "aria-valuemin": min, "aria-valuemax": max, tabIndex: 0, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: finish, onPointerCancel: finish, onKeyDown: onKeyDown,
|
|
122
142
|
// Back to where it started. A pane dragged somewhere silly is
|
|
123
143
|
// otherwise a slow drag back to a width nobody remembers.
|
|
124
|
-
onDoubleClick: () =>
|
|
144
|
+
onDoubleClick: () => {
|
|
145
|
+
const width = apply(defaultWidth);
|
|
146
|
+
onResize?.(width);
|
|
147
|
+
} }, "handle"));
|
|
125
148
|
const asideElement = (_jsx("div", { ref: asidePane, className: "ui-split-aside", children: aside }, "aside"));
|
|
126
149
|
const mainElement = (_jsx("div", { className: "ui-split-main", children: children }, "main"));
|
|
127
150
|
// Keyed, so flipping `side` reorders the panes instead of remounting them.
|
package/dist/Split.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Split.js","sourceRoot":"","sources":["../src/Split.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACL,WAAW,EACX,KAAK,EACL,MAAM,EACN,QAAQ,GAMT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,yDAAyD;AACzD,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"Split.js","sourceRoot":"","sources":["../src/Split.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACL,WAAW,EACX,KAAK,EACL,MAAM,EACN,QAAQ,GAMT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,yDAAyD;AACzD,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;;GAMG;AACH,M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,YAAY,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,EAAmB,oBAErD,QAAQ,YAEvB,KAAK,GACF,CACP,CAAC;AACJ,CAAC"}
|
package/dist/Tabs.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tab strip and the panels it controls.
|
|
3
|
+
*
|
|
4
|
+
* Part of the primitives; see `primitives.tsx`. **Under the
|
|
5
|
+
* compatibility floor.**
|
|
6
|
+
*/
|
|
7
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
8
|
+
/** What a {@link Tabs} takes. */
|
|
9
|
+
export interface TabsProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
10
|
+
/** The tabs. The `id` is what {@link TabPanel}s match on. */
|
|
11
|
+
tabs: {
|
|
12
|
+
id: string;
|
|
13
|
+
label: ReactNode;
|
|
14
|
+
}[];
|
|
15
|
+
/** Which tab is showing. */
|
|
16
|
+
active: string;
|
|
17
|
+
/** Called with the id of the tab the reader chose. */
|
|
18
|
+
onChange: (id: string) => void;
|
|
19
|
+
/** The strip's name, for a screen reader. */
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* The id prefix shared with this strip's {@link TabPanel}s.
|
|
23
|
+
*
|
|
24
|
+
* Optional, and generated when it is absent — but a `TabPanel`
|
|
25
|
+
* *requires* one, so a caller that renders panels passes the same
|
|
26
|
+
* `base` to both: a generated one is never visible to the panels.
|
|
27
|
+
*/
|
|
28
|
+
base?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tabs with the arrow keys wired, because a tab strip that only
|
|
32
|
+
* responds to clicks is a tab strip half the people cannot use.
|
|
33
|
+
*
|
|
34
|
+
* @param tabs — the tabs; the `id` is what the panels match on.
|
|
35
|
+
* @param active — which tab is showing.
|
|
36
|
+
* @param onChange — called with the id of the tab the reader chose.
|
|
37
|
+
* @param label — the strip's name, for a screen reader.
|
|
38
|
+
* @param base — the id prefix shared with this strip's panels; one is
|
|
39
|
+
* generated when it is left out, and the panels need the same one.
|
|
40
|
+
* @param className — added to the element's classes, beside the one the
|
|
41
|
+
* theme gives it.
|
|
42
|
+
* @param rest — the remaining props, spread onto the element.
|
|
43
|
+
*/
|
|
44
|
+
export declare function Tabs({ tabs, active, onChange, label, base: givenBase, className, ...rest }: TabsProps): import("react").JSX.Element;
|
|
45
|
+
/**
|
|
46
|
+
* The panel a tab controls. Needs the same `base` the strip used.
|
|
47
|
+
*
|
|
48
|
+
* `Tabs` without it is half the ARIA pattern: a strip that announces
|
|
49
|
+
* it controls something needs something for it to control.
|
|
50
|
+
*/
|
|
51
|
+
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
52
|
+
/** The id prefix shared with its {@link Tabs}, so the two agree. */
|
|
53
|
+
base: string;
|
|
54
|
+
/** Which tab this panel belongs to. */
|
|
55
|
+
id: string;
|
|
56
|
+
/** Which tab is showing. The panel renders only when they match. */
|
|
57
|
+
active: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The panel a tab controls.
|
|
61
|
+
*
|
|
62
|
+
* See {@link TabPanelProps}. It renders nothing at all when its tab is
|
|
63
|
+
* not the active one, so the content of a panel that is not showing
|
|
64
|
+
* is not in the page.
|
|
65
|
+
*
|
|
66
|
+
* @param base — the id prefix shared with its tabs, so the two agree.
|
|
67
|
+
* @param id — which tab this panel belongs to.
|
|
68
|
+
* @param active — which tab is showing; the panel renders only when
|
|
69
|
+
* they match.
|
|
70
|
+
* @param children — the content of the panel, shown while its tab is
|
|
71
|
+
* the active one.
|
|
72
|
+
* @param className — the panel's own class; the theme gives it
|
|
73
|
+
* none.
|
|
74
|
+
* @param rest — the remaining props, spread onto the element.
|
|
75
|
+
*/
|
|
76
|
+
export declare function TabPanel({ base, id, active, children, className, ...rest }: TabPanelProps): import("react").JSX.Element | null;
|
|
77
|
+
//# sourceMappingURL=Tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../src/Tabs.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAyBtE,iCAAiC;AACjC,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,cAAc,CAAC,cAAc,CAAC,EAC9B,UAAU,CACX;IACC,6DAA6D;IAC7D,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;IACzC,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,EACnB,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,SAAS,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,SAAS,+BA6DX;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,EAAE,EACF,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,aAAa,sCAcf"}
|
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef } from "react";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
/**
|
|
5
|
+
* The index a navigation key moves the selection to, from tab `i` of
|
|
6
|
+
* `count`, or `null` for a key the strip does not handle. The arrows
|
|
7
|
+
* wrap at either end.
|
|
8
|
+
*/
|
|
9
|
+
function tabAfterKey(key, i, count) {
|
|
10
|
+
switch (key) {
|
|
11
|
+
case "ArrowRight":
|
|
12
|
+
return (i + 1) % count;
|
|
13
|
+
case "ArrowLeft":
|
|
14
|
+
return (i - 1 + count) % count;
|
|
15
|
+
case "Home":
|
|
16
|
+
return 0;
|
|
17
|
+
case "End":
|
|
18
|
+
return count - 1;
|
|
19
|
+
default:
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tabs with the arrow keys wired, because a tab strip that only
|
|
25
|
+
* responds to clicks is a tab strip half the people cannot use.
|
|
26
|
+
*
|
|
27
|
+
* @param tabs — the tabs; the `id` is what the panels match on.
|
|
28
|
+
* @param active — which tab is showing.
|
|
29
|
+
* @param onChange — called with the id of the tab the reader chose.
|
|
30
|
+
* @param label — the strip's name, for a screen reader.
|
|
31
|
+
* @param base — the id prefix shared with this strip's panels; one is
|
|
32
|
+
* generated when it is left out, and the panels need the same one.
|
|
33
|
+
* @param className — added to the element's classes, beside the one the
|
|
34
|
+
* theme gives it.
|
|
35
|
+
* @param rest — the remaining props, spread onto the element.
|
|
36
|
+
*/
|
|
37
|
+
export function Tabs({ tabs, active, onChange, label, base: givenBase, className, ...rest }) {
|
|
38
|
+
// Hooks run unconditionally; the generated id is simply unused
|
|
39
|
+
// when a caller supplied one.
|
|
40
|
+
const generated = useId();
|
|
41
|
+
const base = givenBase ?? generated;
|
|
42
|
+
const strip = useRef(null);
|
|
43
|
+
// Focus follows selection, as the ARIA practices require: otherwise
|
|
44
|
+
// the focus ring sits on a tab that is now tabIndex={-1} while a
|
|
45
|
+
// different one is selected, and the next Tab leaves the strip from
|
|
46
|
+
// somewhere the reader cannot see.
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const el = strip.current?.querySelector('[aria-selected="true"]');
|
|
49
|
+
if (el && strip.current?.contains(document.activeElement))
|
|
50
|
+
el.focus();
|
|
51
|
+
}, [active]);
|
|
52
|
+
const onKeyDown = (event) => {
|
|
53
|
+
if (tabs.length === 0)
|
|
54
|
+
return;
|
|
55
|
+
const i = Math.max(tabs.findIndex((t) => t.id === active), 0);
|
|
56
|
+
const next = tabAfterKey(event.key, i, tabs.length);
|
|
57
|
+
if (next === null)
|
|
58
|
+
return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
onChange(tabs[next].id);
|
|
61
|
+
};
|
|
62
|
+
return (_jsx("div", { ...rest, ref: strip, role: "tablist", "aria-label": label, "aria-orientation": "horizontal", className: cx("ui-tabs", className), onKeyDown: onKeyDown, children: tabs.map((tab) => (_jsx("button", {
|
|
63
|
+
// Real DOM ids, so a panel can point back with
|
|
64
|
+
// aria-labelledby and this one can point at it. Without
|
|
65
|
+
// them a screen reader announces "tab, 1 of 2" controlling
|
|
66
|
+
// nothing.
|
|
67
|
+
id: `${base}-${tab.id}`, "aria-controls": `${base}-${tab.id}-panel`, type: "button", role: "tab", "aria-selected": tab.id === active, tabIndex: tab.id === active ? 0 : -1, className: "ui-tab", onClick: () => onChange(tab.id), children: tab.label }, tab.id))) }));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The panel a tab controls.
|
|
71
|
+
*
|
|
72
|
+
* See {@link TabPanelProps}. It renders nothing at all when its tab is
|
|
73
|
+
* not the active one, so the content of a panel that is not showing
|
|
74
|
+
* is not in the page.
|
|
75
|
+
*
|
|
76
|
+
* @param base — the id prefix shared with its tabs, so the two agree.
|
|
77
|
+
* @param id — which tab this panel belongs to.
|
|
78
|
+
* @param active — which tab is showing; the panel renders only when
|
|
79
|
+
* they match.
|
|
80
|
+
* @param children — the content of the panel, shown while its tab is
|
|
81
|
+
* the active one.
|
|
82
|
+
* @param className — the panel's own class; the theme gives it
|
|
83
|
+
* none.
|
|
84
|
+
* @param rest — the remaining props, spread onto the element.
|
|
85
|
+
*/
|
|
86
|
+
export function TabPanel({ base, id, active, children, className, ...rest }) {
|
|
87
|
+
if (id !== active)
|
|
88
|
+
return null;
|
|
89
|
+
return (_jsx("div", { ...rest, id: `${base}-${id}-panel`, role: "tabpanel", "aria-labelledby": `${base}-${id}`, tabIndex: 0, className: className, children: children }));
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=Tabs.js.map
|
package/dist/Tabs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../src/Tabs.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAW,EAAE,CAAS,EAAE,KAAa;IACxD,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,YAAY;YACf,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACzB,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;QACjC,KAAK,MAAM;YACT,OAAO,CAAC,CAAC;QACX,KAAK,KAAK;YACR,OAAO,KAAK,GAAG,CAAC,CAAC;QACnB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAyBD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,SAAS,EACf,SAAS,EACT,GAAG,IAAI,EACG;IACV,+DAA+D;IAC/D,8BAA8B;IAC9B,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1B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/C,wDAAwD;YACxD,2DAA2D;YAC3D,WAAW;YACX,EAAE,EAAE,GAAG,IAAI,IAAI,GAAG,CAAC,EAAE,EAAE,mBACR,GAAG,IAAI,IAAI,GAAG,CAAC,EAAE,QAAQ,EACxC,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,KAAK,mBACK,GAAG,CAAC,EAAE,KAAK,MAAM,EAChC,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACpC,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,YAE9B,GAAG,CAAC,KAAK,IAdL,GAAG,CAAC,EAAE,CAeJ,CACV,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAiBD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,EACJ,EAAE,EACF,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACO;IACd,IAAI,EAAE,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,CACL,iBACM,IAAI,EACR,EAAE,EAAE,GAAG,IAAI,IAAI,EAAE,QAAQ,EACzB,IAAI,EAAC,UAAU,qBACE,GAAG,IAAI,IAAI,EAAE,EAAE,EAChC,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,SAAS,YAEnB,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
|
package/dist/Toast.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* for its button is a message that was never actionable.
|
|
24
24
|
*/
|
|
25
25
|
import { type HTMLAttributes, type ReactNode } from "react";
|
|
26
|
-
import type { Tone } from "./
|
|
26
|
+
import type { Tone } from "./controls.js";
|
|
27
27
|
/** What a toast says and how long it stays. */
|
|
28
28
|
export interface ToastOptions {
|
|
29
29
|
/** How loud it is. `danger` interrupts; the rest wait for a pause. */
|
|
@@ -57,6 +57,8 @@ export interface ToastApi {
|
|
|
57
57
|
*
|
|
58
58
|
* Renders the stack itself, so there is nothing to place and no way
|
|
59
59
|
* to forget to place it.
|
|
60
|
+
*
|
|
61
|
+
* @param children — the part of the app that raises toasts.
|
|
60
62
|
*/
|
|
61
63
|
export declare function ToastHost({ children }: {
|
|
62
64
|
children: ReactNode;
|
|
@@ -82,6 +84,15 @@ export interface BannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
82
84
|
* Not a toast: a toast is about something that just happened and
|
|
83
85
|
* goes away, a banner is about a state — offline, read-only, licence
|
|
84
86
|
* expiring — and stays until the state does not.
|
|
87
|
+
*
|
|
88
|
+
* @param tone — how loud it is: `neutral` for a state nothing is wrong
|
|
89
|
+
* with, and the three that mean something.
|
|
90
|
+
* @param onDismiss — asked to dismiss the banner; the affordance
|
|
91
|
+
* appears when this is given.
|
|
92
|
+
* @param children — the message the banner says.
|
|
93
|
+
* @param className — added to the element's classes, beside the one the
|
|
94
|
+
* theme gives it.
|
|
95
|
+
* @param rest — the remaining props, spread onto the element.
|
|
85
96
|
*/
|
|
86
97
|
export declare function Banner({ tone, onDismiss, children, className, ...rest }: BannerProps): import("react").JSX.Element;
|
|
87
98
|
//# sourceMappingURL=Toast.d.ts.map
|
package/dist/Toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAQL,KAAK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,+BAqBb"}
|
package/dist/Toast.js
CHANGED
|
@@ -38,6 +38,8 @@ let counter = 0;
|
|
|
38
38
|
*
|
|
39
39
|
* Renders the stack itself, so there is nothing to place and no way
|
|
40
40
|
* to forget to place it.
|
|
41
|
+
*
|
|
42
|
+
* @param children — the part of the app that raises toasts.
|
|
41
43
|
*/
|
|
42
44
|
export function ToastHost({ children }) {
|
|
43
45
|
const [toasts, setToasts] = useState([]);
|
|
@@ -111,6 +113,15 @@ export function useToast() {
|
|
|
111
113
|
* Not a toast: a toast is about something that just happened and
|
|
112
114
|
* goes away, a banner is about a state — offline, read-only, licence
|
|
113
115
|
* expiring — and stays until the state does not.
|
|
116
|
+
*
|
|
117
|
+
* @param tone — how loud it is: `neutral` for a state nothing is wrong
|
|
118
|
+
* with, and the three that mean something.
|
|
119
|
+
* @param onDismiss — asked to dismiss the banner; the affordance
|
|
120
|
+
* appears when this is given.
|
|
121
|
+
* @param children — the message the banner says.
|
|
122
|
+
* @param className — added to the element's classes, beside the one the
|
|
123
|
+
* theme gives it.
|
|
124
|
+
* @param rest — the remaining props, spread onto the element.
|
|
114
125
|
*/
|
|
115
126
|
export function Banner({ tone = "neutral", onDismiss, children, className, ...rest }) {
|
|
116
127
|
return (_jsxs("div", { ...rest, className: cx("ui-banner", className), "data-tone": tone, role: tone === "danger" ? "alert" : "status", children: [_jsx("div", { className: "ui-banner-body", children: children }), onDismiss === undefined ? null : (_jsx("button", { type: "button", className: "ui-toast-dismiss", "aria-label": "Dismiss message", onClick: onDismiss, children: "\u00D7" }))] }));
|
package/dist/Toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;A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1,6 +1,9 @@
|
|
|
1
1
|
/** What a {@link Tooltip} takes. */
|
|
2
2
|
export interface TooltipProps {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The word. When it is empty, the control's own `title` is used
|
|
5
|
+
* instead; nothing is rendered when there is neither.
|
|
6
|
+
*/
|
|
4
7
|
text: string;
|
|
5
8
|
/** The control the word is about. */
|
|
6
9
|
children: React.ReactNode;
|
|
@@ -8,8 +11,14 @@ export interface TooltipProps {
|
|
|
8
11
|
/**
|
|
9
12
|
* What an icon means, on hover and on focus.
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
* `title`
|
|
14
|
+
* It replaces the browser's own `title` rather than sitting beside it:
|
|
15
|
+
* a `title` on the control is removed from it, so the browser never
|
|
16
|
+
* shows a second tooltip, and is the word when `text` is empty. Focus
|
|
17
|
+
* shows it at once; hover waits 350 ms.
|
|
18
|
+
*
|
|
19
|
+
* @param text — the word; when it is empty the control's `title` is
|
|
20
|
+
* used, and nothing is rendered when there is neither.
|
|
21
|
+
* @param children — the control the word is about.
|
|
13
22
|
*/
|
|
14
23
|
export declare function Tooltip({ text, children }: TooltipProps): import("react").JSX.Element;
|
|
15
24
|
//# sourceMappingURL=Tooltip.d.ts.map
|
package/dist/Tooltip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":"AAwCA,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,YAAY,+BAqJvD"}
|
package/dist/Tooltip.js
CHANGED
|
@@ -10,8 +10,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
10
10
|
* somebody on a keyboard. That is not an explanation, it is a
|
|
11
11
|
* consolation prize.
|
|
12
12
|
*
|
|
13
|
-
* **It replaces ``title``, it does not sit beside it.**
|
|
14
|
-
* on
|
|
13
|
+
* **It replaces ``title``, it does not sit beside it.** A ``title`` left
|
|
14
|
+
* on the control would give two tooltips saying the same thing a second
|
|
15
|
+
* apart, so the Tooltip takes it off the control while it is in charge,
|
|
16
|
+
* and says it itself when it was given no ``text``.
|
|
15
17
|
*
|
|
16
18
|
* **Focus shows it immediately; hover waits.** A pointer crossing a
|
|
17
19
|
* row of buttons on its way somewhere else should not leave a trail
|
|
@@ -29,15 +31,35 @@ const MARGIN = 8;
|
|
|
29
31
|
/**
|
|
30
32
|
* What an icon means, on hover and on focus.
|
|
31
33
|
*
|
|
32
|
-
*
|
|
33
|
-
* `title`
|
|
34
|
+
* It replaces the browser's own `title` rather than sitting beside it:
|
|
35
|
+
* a `title` on the control is removed from it, so the browser never
|
|
36
|
+
* shows a second tooltip, and is the word when `text` is empty. Focus
|
|
37
|
+
* shows it at once; hover waits 350 ms.
|
|
38
|
+
*
|
|
39
|
+
* @param text — the word; when it is empty the control's `title` is
|
|
40
|
+
* used, and nothing is rendered when there is neither.
|
|
41
|
+
* @param children — the control the word is about.
|
|
34
42
|
*/
|
|
35
43
|
export function Tooltip({ text, children }) {
|
|
44
|
+
const [fromTitle, setFromTitle] = useState("");
|
|
45
|
+
const label = text || fromTitle;
|
|
36
46
|
const wrap = useRef(null);
|
|
37
47
|
const bubble = useRef(null);
|
|
38
48
|
const timer = useRef(null);
|
|
39
49
|
const [at, setAt] = useState(null);
|
|
40
50
|
const id = useId();
|
|
51
|
+
// The control's own ``title`` is taken off it, and kept as the word
|
|
52
|
+
// for when none was given. Run after every render, because React
|
|
53
|
+
// writes the attribute back whenever the control's ``title`` prop
|
|
54
|
+
// changes.
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const control = wrap.current?.firstElementChild;
|
|
57
|
+
const title = control?.getAttribute("title");
|
|
58
|
+
if (title === null || title === undefined)
|
|
59
|
+
return;
|
|
60
|
+
control?.removeAttribute("title");
|
|
61
|
+
setFromTitle(title);
|
|
62
|
+
});
|
|
41
63
|
const hide = useCallback(() => {
|
|
42
64
|
if (timer.current !== null)
|
|
43
65
|
window.clearTimeout(timer.current);
|
|
@@ -59,7 +81,7 @@ export function Tooltip({ text, children }) {
|
|
|
59
81
|
});
|
|
60
82
|
}, []);
|
|
61
83
|
const show = useCallback((immediately) => {
|
|
62
|
-
if (!
|
|
84
|
+
if (!label)
|
|
63
85
|
return;
|
|
64
86
|
if (timer.current !== null)
|
|
65
87
|
window.clearTimeout(timer.current);
|
|
@@ -68,7 +90,7 @@ export function Tooltip({ text, children }) {
|
|
|
68
90
|
return;
|
|
69
91
|
}
|
|
70
92
|
timer.current = window.setTimeout(place, DWELL_MS);
|
|
71
|
-
}, [
|
|
93
|
+
}, [label, place]);
|
|
72
94
|
useEffect(() => () => {
|
|
73
95
|
if (timer.current !== null)
|
|
74
96
|
window.clearTimeout(timer.current);
|
|
@@ -139,6 +161,6 @@ export function Tooltip({ text, children }) {
|
|
|
139
161
|
left: at.left,
|
|
140
162
|
top: at.top,
|
|
141
163
|
transform: `translate(-50%, ${at.below ? "0" : "-100%"})`,
|
|
142
|
-
}, children:
|
|
164
|
+
}, children: label }), document.body)] }));
|
|
143
165
|
}
|
|
144
166
|
//# sourceMappingURL=Tooltip.js.map
|
package/dist/Tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;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AE,IAAI,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,mBAAmB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YACnD,OAAO,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YAClD,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACjD,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAC1C,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,8BACE,eACE,GAAG,EAAE,IAAI,EACT,SAAS,EAAC,YAAY,sBACJ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAEpC,QAAQ,GACJ,EACN,EAAE;gBACD,YAAY,CACV,cACE,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,KAAK,EACf,KAAK,EAAE;wBACL,IAAI,EAAE,EAAE,CAAC,IAAI;wBACb,GAAG,EAAE,EAAE,CAAC,GAAG;wBACX,SAAS,EAAE,mBAAmB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG;qBAC1D,YAEA,KAAK,GACF,EACN,QAAQ,CAAC,IAAI,CACd,IACF,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The controls a reader acts on or scans past: a button, a text field,
|
|
3
|
+
* a chip and a badge, and the tone the last two share.
|
|
4
|
+
*
|
|
5
|
+
* Part of the primitives; see `primitives.tsx`. **Under the
|
|
6
|
+
* compatibility floor.**
|
|
7
|
+
*/
|
|
8
|
+
import type { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from "react";
|
|
9
|
+
/**
|
|
10
|
+
* How a button reads.
|
|
11
|
+
*
|
|
12
|
+
* `default` is a plain button, `primary` is the one action on the
|
|
13
|
+
* panel, `danger` is the one that destroys something, `warn` says the
|
|
14
|
+
* action is not what it sounds like, and `quiet` is a button that
|
|
15
|
+
* should not be the first thing the eye lands on.
|
|
16
|
+
*/
|
|
17
|
+
export type ButtonVariant = "default" | "primary" | "danger" | "warn" | "quiet";
|
|
18
|
+
/** `md` unless the row is dense, in which case `sm` or `xs`. */
|
|
19
|
+
export type ButtonSize = "md" | "sm" | "xs";
|
|
20
|
+
/** What a {@link Button} takes. */
|
|
21
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
22
|
+
/** How it reads. */
|
|
23
|
+
variant?: ButtonVariant;
|
|
24
|
+
/** Its size. */
|
|
25
|
+
size?: ButtonSize;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A button.
|
|
29
|
+
*
|
|
30
|
+
* The variant is a prop rather than a class name you spell:
|
|
31
|
+
* `btn-primery` is a typo that renders as a plain button and looks
|
|
32
|
+
* like nothing at all, which is exactly why the name is one the
|
|
33
|
+
* compiler checks.
|
|
34
|
+
*
|
|
35
|
+
* @param variant — how it reads: plain, the one action on the panel,
|
|
36
|
+
* the one that destroys something, a warning, or one that should not
|
|
37
|
+
* be the first thing the eye lands on.
|
|
38
|
+
* @param size — its size: `md` unless the row is dense, in which case
|
|
39
|
+
* `sm` or `xs`.
|
|
40
|
+
* @param className — added to the element's classes, beside the one the
|
|
41
|
+
* theme gives it.
|
|
42
|
+
* @param rest — the remaining props, spread onto the button.
|
|
43
|
+
*/
|
|
44
|
+
export declare function Button({ variant, size, className, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
45
|
+
/** What an {@link Input} takes. */
|
|
46
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A single-line text field.
|
|
50
|
+
*
|
|
51
|
+
* @param className — added to the element's classes, beside the one the
|
|
52
|
+
* theme gives it.
|
|
53
|
+
* @param rest — the remaining props, spread onto the input.
|
|
54
|
+
*/
|
|
55
|
+
export declare function Input({ className, ...rest }: InputProps): import("react").JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* How loud a status is.
|
|
58
|
+
*
|
|
59
|
+
* `neutral` for a state nothing is wrong with, and the three that
|
|
60
|
+
* mean something.
|
|
61
|
+
*/
|
|
62
|
+
export type Tone = "neutral" | "success" | "warning" | "danger";
|
|
63
|
+
/**
|
|
64
|
+
* A tag the reader can scan past.
|
|
65
|
+
*
|
|
66
|
+
* Bordered, pill-shaped, muted, `--text-sm`. Use it for a filter, a
|
|
67
|
+
* label, a piece of metadata — something that describes the row it
|
|
68
|
+
* sits on.
|
|
69
|
+
*
|
|
70
|
+
* `Chip` and `Badge` take the same props and are not
|
|
71
|
+
* interchangeable. If the thing you are showing is a *state* that
|
|
72
|
+
* changes — ready, failed, three unread — it is a {@link Badge},
|
|
73
|
+
* which is filled by tone and bold so it is noticed. If it is a fact
|
|
74
|
+
* about the thing, it is a `Chip`.
|
|
75
|
+
*/
|
|
76
|
+
export interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
|
|
77
|
+
/** How loud it is. */
|
|
78
|
+
tone?: Tone;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A tag the reader can scan past. See {@link ChipProps} for when to
|
|
82
|
+
* reach for a chip and when for a badge.
|
|
83
|
+
*
|
|
84
|
+
* @param tone — how loud it is: `neutral` for a state nothing is wrong
|
|
85
|
+
* with, and the three that mean something.
|
|
86
|
+
* @param className — added to the element's classes, beside the one the
|
|
87
|
+
* theme gives it.
|
|
88
|
+
* @param rest — the remaining props, spread onto the span.
|
|
89
|
+
*/
|
|
90
|
+
export declare function Chip({ tone, className, ...rest }: ChipProps): import("react").JSX.Element;
|
|
91
|
+
/**
|
|
92
|
+
* A state the reader is meant to notice.
|
|
93
|
+
*
|
|
94
|
+
* Filled by tone, bold, `--text-xs`, no border. See {@link ChipProps}
|
|
95
|
+
* for which of the two to reach for.
|
|
96
|
+
*
|
|
97
|
+
* The tone is colour, and colour alone is not a message: put the
|
|
98
|
+
* state in the text too. "Failed" in a danger badge survives being
|
|
99
|
+
* read aloud and being looked at by somebody who cannot tell it from
|
|
100
|
+
* the success one; an empty red badge does not.
|
|
101
|
+
*/
|
|
102
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
103
|
+
/** How loud it is. */
|
|
104
|
+
tone?: Tone;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A state the reader is meant to notice. See {@link BadgeProps} for
|
|
108
|
+
* what the tone does and does not say.
|
|
109
|
+
*
|
|
110
|
+
* @param tone — how loud it is: `neutral` for a state nothing is wrong
|
|
111
|
+
* with, and the three that mean something.
|
|
112
|
+
* @param className — added to the element's classes, beside the one the
|
|
113
|
+
* theme gives it.
|
|
114
|
+
* @param rest — the remaining props, spread onto the span.
|
|
115
|
+
*/
|
|
116
|
+
export declare function Badge({ tone, className, ...rest }: BadgeProps): import("react").JSX.Element;
|
|
117
|
+
//# sourceMappingURL=controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACpB,MAAM,OAAO,CAAC;AAIf;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhF,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,mCAAmC;AACnC,MAAM,WAAW,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC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