@ignite-ember/ui-react 0.0.0-stage → 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.
Files changed (134) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +260 -2
  4. package/dist/CopySource.d.ts +4 -0
  5. package/dist/CopySource.d.ts.map +1 -0
  6. package/dist/CopySource.js +50 -0
  7. package/dist/CopySource.js.map +1 -0
  8. package/dist/DataTable.d.ts +77 -0
  9. package/dist/DataTable.d.ts.map +1 -0
  10. package/dist/DataTable.js +45 -0
  11. package/dist/DataTable.js.map +1 -0
  12. package/dist/Dialog.d.ts +41 -0
  13. package/dist/Dialog.d.ts.map +1 -0
  14. package/dist/Dialog.js +94 -0
  15. package/dist/Dialog.js.map +1 -0
  16. package/dist/ErrorBoundary.d.ts +97 -0
  17. package/dist/ErrorBoundary.d.ts.map +1 -0
  18. package/dist/ErrorBoundary.js +97 -0
  19. package/dist/ErrorBoundary.js.map +1 -0
  20. package/dist/LiveRegion.d.ts +41 -0
  21. package/dist/LiveRegion.d.ts.map +1 -0
  22. package/dist/LiveRegion.js +76 -0
  23. package/dist/LiveRegion.js.map +1 -0
  24. package/dist/Markdown.d.ts +22 -0
  25. package/dist/Markdown.d.ts.map +1 -0
  26. package/dist/Markdown.js +56 -0
  27. package/dist/Markdown.js.map +1 -0
  28. package/dist/MarkdownInline.d.ts +53 -0
  29. package/dist/MarkdownInline.d.ts.map +1 -0
  30. package/dist/MarkdownInline.js +159 -0
  31. package/dist/MarkdownInline.js.map +1 -0
  32. package/dist/MenuIcon.d.ts +60 -0
  33. package/dist/MenuIcon.d.ts.map +1 -0
  34. package/dist/MenuIcon.js +102 -0
  35. package/dist/MenuIcon.js.map +1 -0
  36. package/dist/Mermaid.d.ts +40 -0
  37. package/dist/Mermaid.d.ts.map +1 -0
  38. package/dist/Mermaid.js +121 -0
  39. package/dist/Mermaid.js.map +1 -0
  40. package/dist/Monogram.d.ts +46 -0
  41. package/dist/Monogram.d.ts.map +1 -0
  42. package/dist/Monogram.js +96 -0
  43. package/dist/Monogram.js.map +1 -0
  44. package/dist/OverflowMenu.d.ts +60 -0
  45. package/dist/OverflowMenu.d.ts.map +1 -0
  46. package/dist/OverflowMenu.js +149 -0
  47. package/dist/OverflowMenu.js.map +1 -0
  48. package/dist/Shell.d.ts +67 -0
  49. package/dist/Shell.d.ts.map +1 -0
  50. package/dist/Shell.js +44 -0
  51. package/dist/Shell.js.map +1 -0
  52. package/dist/Skeleton.d.ts +62 -0
  53. package/dist/Skeleton.d.ts.map +1 -0
  54. package/dist/Skeleton.js +56 -0
  55. package/dist/Skeleton.js.map +1 -0
  56. package/dist/Split.d.ts +85 -0
  57. package/dist/Split.d.ts.map +1 -0
  58. package/dist/Split.js +156 -0
  59. package/dist/Split.js.map +1 -0
  60. package/dist/Tabs.d.ts +77 -0
  61. package/dist/Tabs.d.ts.map +1 -0
  62. package/dist/Tabs.js +91 -0
  63. package/dist/Tabs.js.map +1 -0
  64. package/dist/Toast.d.ts +98 -0
  65. package/dist/Toast.d.ts.map +1 -0
  66. package/dist/Toast.js +129 -0
  67. package/dist/Toast.js.map +1 -0
  68. package/dist/Tooltip.d.ts +24 -0
  69. package/dist/Tooltip.d.ts.map +1 -0
  70. package/dist/Tooltip.js +166 -0
  71. package/dist/Tooltip.js.map +1 -0
  72. package/dist/controls.d.ts +117 -0
  73. package/dist/controls.d.ts.map +1 -0
  74. package/dist/controls.js +59 -0
  75. package/dist/controls.js.map +1 -0
  76. package/dist/cx.d.ts +3 -0
  77. package/dist/cx.d.ts.map +1 -0
  78. package/dist/cx.js +5 -0
  79. package/dist/cx.js.map +1 -0
  80. package/dist/fenceInfo.d.ts +26 -0
  81. package/dist/fenceInfo.d.ts.map +1 -0
  82. package/dist/fenceInfo.js +22 -0
  83. package/dist/fenceInfo.js.map +1 -0
  84. package/dist/formControls.d.ts +143 -0
  85. package/dist/formControls.d.ts.map +1 -0
  86. package/dist/formControls.js +108 -0
  87. package/dist/formControls.js.map +1 -0
  88. package/dist/index.d.ts +78 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/index.js +78 -0
  91. package/dist/index.js.map +1 -0
  92. package/dist/layout.d.ts +95 -0
  93. package/dist/layout.d.ts.map +1 -0
  94. package/dist/layout.js +93 -0
  95. package/dist/layout.js.map +1 -0
  96. package/dist/primitives.d.ts +33 -0
  97. package/dist/primitives.d.ts.map +1 -0
  98. package/dist/primitives.js +33 -0
  99. package/dist/primitives.js.map +1 -0
  100. package/dist/progress.d.ts +64 -0
  101. package/dist/progress.d.ts.map +1 -0
  102. package/dist/progress.js +51 -0
  103. package/dist/progress.js.map +1 -0
  104. package/dist/text.d.ts +63 -0
  105. package/dist/text.d.ts.map +1 -0
  106. package/dist/text.js +61 -0
  107. package/dist/text.js.map +1 -0
  108. package/package.json +56 -4
  109. package/src/CopySource.tsx +67 -0
  110. package/src/DataTable.tsx +120 -0
  111. package/src/Dialog.tsx +158 -0
  112. package/src/ErrorBoundary.tsx +137 -0
  113. package/src/LiveRegion.tsx +127 -0
  114. package/src/Markdown.tsx +75 -0
  115. package/src/MarkdownInline.tsx +177 -0
  116. package/src/MenuIcon.tsx +209 -0
  117. package/src/Mermaid.tsx +144 -0
  118. package/src/Monogram.tsx +112 -0
  119. package/src/OverflowMenu.tsx +359 -0
  120. package/src/Shell.tsx +99 -0
  121. package/src/Skeleton.tsx +98 -0
  122. package/src/Split.tsx +267 -0
  123. package/src/Tabs.tsx +194 -0
  124. package/src/Toast.tsx +269 -0
  125. package/src/Tooltip.tsx +213 -0
  126. package/src/controls.tsx +159 -0
  127. package/src/cx.ts +4 -0
  128. package/src/fenceInfo.ts +36 -0
  129. package/src/formControls.tsx +249 -0
  130. package/src/index.ts +149 -0
  131. package/src/layout.tsx +141 -0
  132. package/src/primitives.tsx +33 -0
  133. package/src/progress.tsx +129 -0
  134. package/src/text.tsx +99 -0
package/dist/Toast.js ADDED
@@ -0,0 +1,129 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * "It saved." — the message every extension needs and none had.
4
+ *
5
+ * EXTENSIBILITY §5 names `notify` in the list of bridge APIs that do
6
+ * not exist. A specified-and-absent API is worse than a missing one,
7
+ * because a partner designs against it and finds out on demo day.
8
+ *
9
+ * This is the in-frame half: an extension's own toasts, in its own
10
+ * frame. It is not `bridge.notify` — that would put a message in
11
+ * igni's chrome, outside the frame, and needs a host envelope that
12
+ * does not exist yet. The distinction matters because they are not
13
+ * interchangeable: a toast about something inside this panel belongs
14
+ * inside this panel, and only something the user must see after
15
+ * navigating away belongs to the host.
16
+ *
17
+ * **Announced, not just drawn.** The stack is a polite live region,
18
+ * so a toast reaches somebody who is not looking at that corner. A
19
+ * `danger` toast is assertive instead: it is the one case where
20
+ * interrupting is correct.
21
+ *
22
+ * Toasts do not stack indefinitely and do not auto-dismiss when they
23
+ * carry an action — a message that disappears while you are reaching
24
+ * for its button is a message that was never actionable.
25
+ */
26
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
27
+ function cx(...parts) {
28
+ return parts.filter(Boolean).join(" ");
29
+ }
30
+ /** How long a toast stays, when it stays at all. */
31
+ const DEFAULT_MS = 5_000;
32
+ /** Beyond this, the oldest goes. A wall of toasts is not a message. */
33
+ const MAX_VISIBLE = 4;
34
+ const ToastContext = createContext(null);
35
+ let counter = 0;
36
+ /**
37
+ * Wrap the part of the app that raises toasts.
38
+ *
39
+ * Renders the stack itself, so there is nothing to place and no way
40
+ * to forget to place it.
41
+ *
42
+ * @param children — the part of the app that raises toasts.
43
+ */
44
+ export function ToastHost({ children }) {
45
+ const [toasts, setToasts] = useState([]);
46
+ const timers = useRef(new Map());
47
+ const dismiss = useCallback((id) => {
48
+ const timer = timers.current.get(id);
49
+ if (timer !== undefined) {
50
+ clearTimeout(timer);
51
+ timers.current.delete(id);
52
+ }
53
+ setToasts((current) => current.filter((t) => t.id !== id));
54
+ }, []);
55
+ const show = useCallback((message, options = {}) => {
56
+ const id = `toast-${++counter}`;
57
+ // A toast with something to do stays until it is dealt with.
58
+ // Auto-dismissing it means the button can vanish mid-reach.
59
+ const duration = options.duration !== undefined
60
+ ? options.duration
61
+ : options.action !== undefined
62
+ ? null
63
+ : DEFAULT_MS;
64
+ setToasts((current) => [...current, { ...options, id, message }].slice(-MAX_VISIBLE));
65
+ if (duration !== null) {
66
+ timers.current.set(id, setTimeout(() => dismiss(id), duration));
67
+ }
68
+ return id;
69
+ }, [dismiss]);
70
+ const clear = useCallback(() => {
71
+ for (const timer of timers.current.values())
72
+ clearTimeout(timer);
73
+ timers.current.clear();
74
+ setToasts([]);
75
+ }, []);
76
+ // Timers outlive the component otherwise, and fire `setToasts` on
77
+ // something unmounted.
78
+ useEffect(() => {
79
+ const pending = timers.current;
80
+ return () => {
81
+ for (const timer of pending.values())
82
+ clearTimeout(timer);
83
+ pending.clear();
84
+ };
85
+ }, []);
86
+ const api = useMemo(() => ({ show, dismiss, clear }), [show, dismiss, clear]);
87
+ return (_jsxs(ToastContext.Provider, { value: api, children: [children, _jsx(ToastList, { toasts: toasts, onDismiss: dismiss })] }));
88
+ }
89
+ function ToastList({ toasts, onDismiss, }) {
90
+ return (_jsx("div", { className: "ui-toasts", children: toasts.map((toast) => (_jsxs("div", { className: "ui-toast", "data-tone": toast.tone ?? "neutral",
91
+ // A failure interrupts; everything else waits for a pause.
92
+ role: toast.tone === "danger" ? "alert" : "status", "aria-live": toast.tone === "danger" ? "assertive" : "polite", children: [_jsxs("div", { className: "ui-toast-body", children: [toast.message, toast.action] }), _jsx("button", { type: "button", className: "ui-toast-dismiss", "aria-label": "Dismiss notification", onClick: () => onDismiss(toast.id), children: "\u00D7" })] }, toast.id))) }));
93
+ }
94
+ /**
95
+ * Raise a toast.
96
+ *
97
+ * Throws outside a {@link ToastHost} rather than returning a no-op.
98
+ * A silent no-op here means a save that reports success by showing
99
+ * nothing, which looks exactly like a save that did not happen.
100
+ */
101
+ export function useToast() {
102
+ const api = useContext(ToastContext);
103
+ if (api === null) {
104
+ throw new Error("useToast was called outside a <ToastHost>. Wrap your app in one — " +
105
+ "without it a toast would be silently dropped, which looks the " +
106
+ "same as the action never happening.");
107
+ }
108
+ return api;
109
+ }
110
+ /**
111
+ * A condition that is still true.
112
+ *
113
+ * Not a toast: a toast is about something that just happened and
114
+ * goes away, a banner is about a state — offline, read-only, licence
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.
125
+ */
126
+ export function Banner({ tone = "neutral", onDismiss, children, className, ...rest }) {
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" }))] }));
128
+ }
129
+ //# sourceMappingURL=Toast.js.map
@@ -0,0 +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;AAIf,SAAS,EAAE,CAAC,GAAG,KAA4C;IACzD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,uEAAuE;AACvE,MAAM,WAAW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,IAAI,EACR,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,eAC1B,IAAI,EACf,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,aAE5C,cAAK,SAAS,EAAC,gBAAgB,YAAE,QAAQ,GAAO,EAC/C,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChC,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,kBAAkB,gBACjB,iBAAiB,EAC5B,OAAO,EAAE,SAAS,uBAGX,CACV,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /** What a {@link Tooltip} takes. */
2
+ export interface TooltipProps {
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
+ */
7
+ text: string;
8
+ /** The control the word is about. */
9
+ children: React.ReactNode;
10
+ }
11
+ /**
12
+ * What an icon means, on hover and on focus.
13
+ *
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.
22
+ */
23
+ export declare function Tooltip({ text, children }: TooltipProps): import("react").JSX.Element;
24
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,166 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * What an icon means, on hover and on focus.
4
+ *
5
+ * A toolbar of glyphs is quicker to scan and slower to learn, and
6
+ * the moment somebody needs the word is the moment their pointer is
7
+ * already on the thing. The browser's own ``title`` does technically
8
+ * say it — after a second and a half, in the operating system's
9
+ * font, at the pointer rather than at the control, and never for
10
+ * somebody on a keyboard. That is not an explanation, it is a
11
+ * consolation prize.
12
+ *
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``.
17
+ *
18
+ * **Focus shows it immediately; hover waits.** A pointer crossing a
19
+ * row of buttons on its way somewhere else should not leave a trail
20
+ * of popups, but a keyboard user arriving at a control has asked for
21
+ * it by arriving.
22
+ */
23
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
24
+ import { createPortal } from "react-dom";
25
+ /** How long a pointer must rest before the word appears. */
26
+ const DWELL_MS = 350;
27
+ /** Gap between the control and the bubble. */
28
+ const OFFSET = 8;
29
+ /** Keeps the bubble off the window edges. */
30
+ const MARGIN = 8;
31
+ /**
32
+ * What an icon means, on hover and on focus.
33
+ *
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.
42
+ */
43
+ export function Tooltip({ text, children }) {
44
+ const [fromTitle, setFromTitle] = useState("");
45
+ const label = text || fromTitle;
46
+ const wrap = useRef(null);
47
+ const bubble = useRef(null);
48
+ const timer = useRef(null);
49
+ const [at, setAt] = useState(null);
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
+ });
63
+ const hide = useCallback(() => {
64
+ if (timer.current !== null)
65
+ window.clearTimeout(timer.current);
66
+ timer.current = null;
67
+ setAt(null);
68
+ }, []);
69
+ const place = useCallback(() => {
70
+ // The control, not the pointer. A bubble that follows the cursor
71
+ // is a bubble that covers the next control along.
72
+ const anchor = wrap.current?.firstElementChild ?? wrap.current;
73
+ const box = anchor?.getBoundingClientRect();
74
+ if (!box)
75
+ return;
76
+ const below = box.bottom + OFFSET + 34 < window.innerHeight;
77
+ setAt({
78
+ left: box.left + box.width / 2,
79
+ top: below ? box.bottom + OFFSET : box.top - OFFSET,
80
+ below,
81
+ });
82
+ }, []);
83
+ const show = useCallback((immediately) => {
84
+ if (!label)
85
+ return;
86
+ if (timer.current !== null)
87
+ window.clearTimeout(timer.current);
88
+ if (immediately) {
89
+ place();
90
+ return;
91
+ }
92
+ timer.current = window.setTimeout(place, DWELL_MS);
93
+ }, [label, place]);
94
+ useEffect(() => () => {
95
+ if (timer.current !== null)
96
+ window.clearTimeout(timer.current);
97
+ }, []);
98
+ // Escape closes it, and so does anything that scrolls it away from
99
+ // the control it belongs to.
100
+ useEffect(() => {
101
+ if (!at)
102
+ return;
103
+ const onKey = (e) => {
104
+ if (e.key === "Escape")
105
+ hide();
106
+ };
107
+ window.addEventListener("keydown", onKey);
108
+ window.addEventListener("scroll", hide, true);
109
+ window.addEventListener("resize", hide);
110
+ return () => {
111
+ window.removeEventListener("keydown", onKey);
112
+ window.removeEventListener("scroll", hide, true);
113
+ window.removeEventListener("resize", hide);
114
+ };
115
+ }, [at, hide]);
116
+ // Nudged back inside the window once its width is known. Measured
117
+ // rather than guessed: the text is a sentence in some places and a
118
+ // word in others.
119
+ useEffect(() => {
120
+ const el = bubble.current;
121
+ if (!at || !el)
122
+ return;
123
+ const box = el.getBoundingClientRect();
124
+ const over = box.right - (window.innerWidth - MARGIN);
125
+ const under = MARGIN - box.left;
126
+ if (over > 0)
127
+ el.style.transform = `translate(calc(-50% - ${over}px), ${at.below ? "0" : "-100%"})`;
128
+ else if (under > 0)
129
+ el.style.transform = `translate(calc(-50% + ${under}px), ${at.below ? "0" : "-100%"})`;
130
+ }, [at]);
131
+ // Listened for on the control itself, not on the wrapper.
132
+ //
133
+ // The wrapper is ``display: contents`` so it does not become a box
134
+ // in a flex row — every toolbar it is used in would otherwise gain
135
+ // a layer of spacing nobody designed. But an element with no box
136
+ // is an element the browser never hits with a pointer, so React's
137
+ // onPointerEnter on the wrapper fired in jsdom, where there is no
138
+ // hit-testing, and never once in a real browser. Focus worked the
139
+ // whole time, which is what made it look like a timing problem.
140
+ useEffect(() => {
141
+ const control = wrap.current?.firstElementChild;
142
+ if (!control)
143
+ return;
144
+ const enter = () => show(false);
145
+ const now = () => show(true);
146
+ control.addEventListener("pointerenter", enter);
147
+ control.addEventListener("pointerleave", hide);
148
+ control.addEventListener("pointerdown", hide);
149
+ control.addEventListener("focus", now);
150
+ control.addEventListener("blur", hide);
151
+ return () => {
152
+ control.removeEventListener("pointerenter", enter);
153
+ control.removeEventListener("pointerleave", hide);
154
+ control.removeEventListener("pointerdown", hide);
155
+ control.removeEventListener("focus", now);
156
+ control.removeEventListener("blur", hide);
157
+ };
158
+ }, [show, hide]);
159
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: wrap, className: "tip-anchor", "aria-describedby": at ? id : undefined, children: children }), at &&
160
+ createPortal(_jsx("div", { ref: bubble, id: id, role: "tooltip", className: "tip", style: {
161
+ left: at.left,
162
+ top: at.top,
163
+ transform: `translate(-50%, ${at.below ? "0" : "-100%"})`,
164
+ }, children: label }), document.body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AAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACvC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,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;IAC1E,oBAAoB;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,gBAAgB;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,EACrB,OAAmB,EACnB,IAAW,EACX,SAAS,EACT,GAAG,IAAI,EACR,EAAE,WAAW,+BAab;AAED,mCAAmC;AACnC,MAAM,WAAW,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;CAAG;AAE5E;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,UAAU,+BAEvD;AAED;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,eAAe,CAAC;IAChE,sBAAsB;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,EAAE,IAAgB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAEvE;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,eAAe,CAAC;IACjE,sBAAsB;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAgB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,UAAU,+BAIzE"}
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ /**
4
+ * A button.
5
+ *
6
+ * The variant is a prop rather than a class name you spell:
7
+ * `btn-primery` is a typo that renders as a plain button and looks
8
+ * like nothing at all, which is exactly why the name is one the
9
+ * compiler checks.
10
+ *
11
+ * @param variant — how it reads: plain, the one action on the panel,
12
+ * the one that destroys something, a warning, or one that should not
13
+ * be the first thing the eye lands on.
14
+ * @param size — its size: `md` unless the row is dense, in which case
15
+ * `sm` or `xs`.
16
+ * @param className — added to the element's classes, beside the one the
17
+ * theme gives it.
18
+ * @param rest — the remaining props, spread onto the button.
19
+ */
20
+ export function Button({ variant = "default", size = "md", className, ...rest }) {
21
+ return (_jsx("button", { type: "button", ...rest, className: cx("btn", variant !== "default" && `btn-${variant}`, size !== "md" && `btn-${size}`, className) }));
22
+ }
23
+ /**
24
+ * A single-line text field.
25
+ *
26
+ * @param className — added to the element's classes, beside the one the
27
+ * theme gives it.
28
+ * @param rest — the remaining props, spread onto the input.
29
+ */
30
+ export function Input({ className, ...rest }) {
31
+ return _jsx("input", { ...rest, className: cx("panel-input", className) });
32
+ }
33
+ /**
34
+ * A tag the reader can scan past. See {@link ChipProps} for when to
35
+ * reach for a chip and when for a badge.
36
+ *
37
+ * @param tone — how loud it is: `neutral` for a state nothing is wrong
38
+ * with, and the three that mean something.
39
+ * @param className — added to the element's classes, beside the one the
40
+ * theme gives it.
41
+ * @param rest — the remaining props, spread onto the span.
42
+ */
43
+ export function Chip({ tone = "neutral", className, ...rest }) {
44
+ return _jsx("span", { ...rest, "data-tone": tone, className: cx("chip", className) });
45
+ }
46
+ /**
47
+ * A state the reader is meant to notice. See {@link BadgeProps} for
48
+ * what the tone does and does not say.
49
+ *
50
+ * @param tone — how loud it is: `neutral` for a state nothing is wrong
51
+ * with, and the three that mean something.
52
+ * @param className — added to the element's classes, beside the one the
53
+ * theme gives it.
54
+ * @param rest — the remaining props, spread onto the span.
55
+ */
56
+ export function Badge({ tone = "neutral", className, ...rest }) {
57
+ return (_jsx("span", { ...rest, "data-tone": tone, className: cx("ui-badge", className) }));
58
+ }
59
+ //# sourceMappingURL=controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controls.js","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAuB7B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,SAAS,EACT,GAAG,IAAI,EACK;IACZ,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,KACT,IAAI,EACR,SAAS,EAAE,EAAE,CACX,KAAK,EACL,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,EAAE,EACzC,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,EAAE,EAC9B,SAAS,CACV,GACD,CACH,CAAC;AACJ,CAAC;AAKD;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAc;IACtD,OAAO,mBAAW,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,GAAI,CAAC;AACtE,CAAC;AA4BD;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAa;IACtE,OAAO,kBAAU,IAAI,eAAa,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,GAAI,CAAC;AAC/E,CAAC;AAkBD;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAc;IACxE,OAAO,CACL,kBAAU,IAAI,eAAa,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI,CAC1E,CAAC;AACJ,CAAC"}
package/dist/cx.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Joins the class names that are set, skipping the ones that are not. */
2
+ export declare function cx(...parts: (string | false | null | undefined)[]): string;
3
+ //# sourceMappingURL=cx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cx.d.ts","sourceRoot":"","sources":["../src/cx.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAE1E"}
package/dist/cx.js ADDED
@@ -0,0 +1,5 @@
1
+ /** Joins the class names that are set, skipping the ones that are not. */
2
+ export function cx(...parts) {
3
+ return parts.filter(Boolean).join(" ");
4
+ }
5
+ //# sourceMappingURL=cx.js.map
package/dist/cx.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cx.js","sourceRoot":"","sources":["../src/cx.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,EAAE,CAAC,GAAG,KAA4C;IAChE,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The language on a fenced block, or null.
3
+ *
4
+ * ReactMarkdown hands a ``<pre>`` a single ``<code>`` child carrying
5
+ * ``className="language-mermaid"``; this reads that without
6
+ * assuming any particular child shape survives a plugin.
7
+ */
8
+ import type { ReactNode } from "react";
9
+ /** The language on a fenced block, and the block's source. */
10
+ export interface Fence {
11
+ /** The language, lower-cased. `mermaid`, `ts`, `python`, `c++`. */
12
+ lang: string;
13
+ /** The text inside the fence. */
14
+ source: string;
15
+ }
16
+ /**
17
+ * The language on a fenced block, or null.
18
+ *
19
+ * Null when the child is not a code element, or carries no
20
+ * `language-` class — an unfenced block, or a fence with no language.
21
+ *
22
+ * @param children — the `<pre>` a fenced block renders as; its `<code>`
23
+ * child carries the language class.
24
+ */
25
+ export declare function fenceInfo(children: ReactNode): Fence | null;
26
+ //# sourceMappingURL=fenceInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fenceInfo.d.ts","sourceRoot":"","sources":["../src/fenceInfo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,8DAA8D;AAC9D,MAAM,WAAW,KAAK;IACpB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI,CAQ3D"}
@@ -0,0 +1,22 @@
1
+ import { isValidElement } from "react";
2
+ /**
3
+ * The language on a fenced block, or null.
4
+ *
5
+ * Null when the child is not a code element, or carries no
6
+ * `language-` class — an unfenced block, or a fence with no language.
7
+ *
8
+ * @param children — the `<pre>` a fenced block renders as; its `<code>`
9
+ * child carries the language class.
10
+ */
11
+ export function fenceInfo(children) {
12
+ const only = Array.isArray(children) ? children[0] : children;
13
+ if (!isValidElement(only))
14
+ return null;
15
+ const props = only.props;
16
+ const match = /\blanguage-([\w+#.-]+)/.exec(props.className ?? "");
17
+ if (!match)
18
+ return null;
19
+ const source = typeof props.children === "string" ? props.children : "";
20
+ return { lang: match[1].toLowerCase(), source: source.replace(/\n$/, "") };
21
+ }
22
+ //# sourceMappingURL=fenceInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fenceInfo.js","sourceRoot":"","sources":["../src/fenceInfo.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAUvC;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,QAAmB;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9D,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAqD,CAAC;IACzE,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACnE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;AAC7E,CAAC"}