@ignite-ember/ui-react 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +217 -2
- package/dist/CopySource.d.ts +4 -0
- package/dist/CopySource.d.ts.map +1 -0
- package/dist/CopySource.js +36 -0
- package/dist/CopySource.js.map +1 -0
- package/dist/DataTable.d.ts +61 -0
- package/dist/DataTable.d.ts.map +1 -0
- package/dist/DataTable.js +29 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +68 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +63 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/LiveRegion.d.ts +35 -0
- package/dist/LiveRegion.d.ts.map +1 -0
- package/dist/LiveRegion.js +70 -0
- package/dist/LiveRegion.js.map +1 -0
- package/dist/Markdown.d.ts +18 -0
- package/dist/Markdown.d.ts.map +1 -0
- package/dist/Markdown.js +52 -0
- package/dist/Markdown.js.map +1 -0
- package/dist/MarkdownInline.d.ts +44 -0
- package/dist/MarkdownInline.d.ts.map +1 -0
- package/dist/MarkdownInline.js +144 -0
- package/dist/MarkdownInline.js.map +1 -0
- package/dist/MenuIcon.d.ts +54 -0
- package/dist/MenuIcon.d.ts.map +1 -0
- package/dist/MenuIcon.js +96 -0
- package/dist/MenuIcon.js.map +1 -0
- package/dist/Mermaid.d.ts +38 -0
- package/dist/Mermaid.d.ts.map +1 -0
- package/dist/Mermaid.js +119 -0
- package/dist/Mermaid.js.map +1 -0
- package/dist/Monogram.d.ts +42 -0
- package/dist/Monogram.d.ts.map +1 -0
- package/dist/Monogram.js +88 -0
- package/dist/Monogram.js.map +1 -0
- package/dist/OverflowMenu.d.ts +55 -0
- package/dist/OverflowMenu.d.ts.map +1 -0
- package/dist/OverflowMenu.js +141 -0
- package/dist/OverflowMenu.js.map +1 -0
- package/dist/Shell.d.ts +54 -0
- package/dist/Shell.d.ts.map +1 -0
- package/dist/Shell.js +31 -0
- package/dist/Shell.js.map +1 -0
- package/dist/Skeleton.d.ts +32 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +26 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/Split.d.ts +66 -0
- package/dist/Split.d.ts.map +1 -0
- package/dist/Split.js +133 -0
- package/dist/Split.js.map +1 -0
- package/dist/Toast.d.ts +87 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +118 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +15 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +144 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/cx.d.ts +3 -0
- package/dist/cx.d.ts.map +1 -0
- package/dist/cx.js +5 -0
- package/dist/cx.js.map +1 -0
- package/dist/fenceInfo.d.ts +23 -0
- package/dist/fenceInfo.d.ts.map +1 -0
- package/dist/fenceInfo.js +19 -0
- package/dist/fenceInfo.js.map +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives.d.ts +383 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +340 -0
- package/dist/primitives.js.map +1 -0
- package/package.json +56 -4
- package/src/CopySource.tsx +52 -0
- package/src/DataTable.tsx +104 -0
- package/src/ErrorBoundary.tsx +102 -0
- package/src/LiveRegion.tsx +121 -0
- package/src/Markdown.tsx +71 -0
- package/src/MarkdownInline.tsx +164 -0
- package/src/MenuIcon.tsx +203 -0
- package/src/Mermaid.tsx +142 -0
- package/src/Monogram.tsx +103 -0
- package/src/OverflowMenu.tsx +352 -0
- package/src/Shell.tsx +86 -0
- package/src/Skeleton.tsx +68 -0
- package/src/Split.tsx +242 -0
- package/src/Toast.tsx +258 -0
- package/src/Tooltip.tsx +188 -0
- package/src/cx.ts +4 -0
- package/src/fenceInfo.ts +33 -0
- package/src/index.ts +153 -0
- package/src/primitives.tsx +887 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, isValidElement, useCallback, useEffect, useId, useRef, } from "react";
|
|
3
|
+
/** Joins class names, skipping anything falsy. */
|
|
4
|
+
function cx(...parts) {
|
|
5
|
+
return parts.filter(Boolean).join(" ");
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A button.
|
|
9
|
+
*
|
|
10
|
+
* The variant is a prop rather than a class name you spell:
|
|
11
|
+
* `btn-primery` is a typo that renders as a plain button and looks
|
|
12
|
+
* like nothing at all, which is exactly why the name is one the
|
|
13
|
+
* compiler checks.
|
|
14
|
+
*/
|
|
15
|
+
export function Button({ variant = "default", size = "md", className, ...rest }) {
|
|
16
|
+
return (_jsx("button", { type: "button", ...rest, className: cx("btn", variant !== "default" && `btn-${variant}`, size !== "md" && `btn-${size}`, className) }));
|
|
17
|
+
}
|
|
18
|
+
/** A single-line text field. */
|
|
19
|
+
export function Input({ className, ...rest }) {
|
|
20
|
+
return _jsx("input", { ...rest, className: cx("panel-input", className) });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A tag the reader can scan past. See {@link ChipProps} for when to
|
|
24
|
+
* reach for a chip and when for a badge.
|
|
25
|
+
*/
|
|
26
|
+
export function Chip({ tone = "neutral", className, ...rest }) {
|
|
27
|
+
return _jsx("span", { ...rest, "data-tone": tone, className: cx("chip", className) });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A state the reader is meant to notice. See {@link BadgeProps} for
|
|
31
|
+
* what the tone does and does not say.
|
|
32
|
+
*/
|
|
33
|
+
export function Badge({ tone = "neutral", className, ...rest }) {
|
|
34
|
+
return (_jsx("span", { ...rest, "data-tone": tone, className: cx("ui-badge", className) }));
|
|
35
|
+
}
|
|
36
|
+
// ── Layout ──────────────────────────────────────────────────────────
|
|
37
|
+
/** A horizontal run of things, vertically centred. */
|
|
38
|
+
export function Row({ className, ...rest }) {
|
|
39
|
+
return _jsx("div", { ...rest, className: cx("ui-row", className) });
|
|
40
|
+
}
|
|
41
|
+
/** A horizontal run of buttons. Separate from `Row` because it is
|
|
42
|
+
* what a reader looks for at the foot of a panel. */
|
|
43
|
+
export function Actions({ className, ...rest }) {
|
|
44
|
+
return _jsx("div", { ...rest, className: cx("ui-actions", className) });
|
|
45
|
+
}
|
|
46
|
+
/** A vertical stack. */
|
|
47
|
+
export function List({ className, ...rest }) {
|
|
48
|
+
return _jsx("div", { ...rest, className: cx("ui-list", className) });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A row of controls at the top of a panel: what the panel is, and what
|
|
52
|
+
* you can do to it.
|
|
53
|
+
*/
|
|
54
|
+
export function Toolbar({ className, ...rest }) {
|
|
55
|
+
return _jsx("div", { ...rest, className: cx("ui-toolbar", className) });
|
|
56
|
+
}
|
|
57
|
+
// ── Containers ──────────────────────────────────────────────────────
|
|
58
|
+
/** A surface: background, border, radius, padding. */
|
|
59
|
+
export function Card({ className, ...rest }) {
|
|
60
|
+
return _jsx("div", { ...rest, className: cx("ui-card", className) });
|
|
61
|
+
}
|
|
62
|
+
/** One selectable row inside a list. Renders a button, because
|
|
63
|
+
* something clickable that is not a button is a keyboard trap. */
|
|
64
|
+
export function Item({ className, ...rest }) {
|
|
65
|
+
return (_jsx("button", { type: "button", ...rest, className: cx("ui-item", className) }));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A table.
|
|
69
|
+
*
|
|
70
|
+
* The class only; the head, the rows and the cells are yours, because
|
|
71
|
+
* a table that decides its own columns is a table you cannot use for
|
|
72
|
+
* anything the app has not already seen.
|
|
73
|
+
*/
|
|
74
|
+
export function Table({ className, ...rest }) {
|
|
75
|
+
return _jsx("table", { ...rest, className: cx("ui-table", className) });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* What to show where there is nothing.
|
|
79
|
+
*
|
|
80
|
+
* See {@link EmptyProps} for why the `action` slot exists.
|
|
81
|
+
*/
|
|
82
|
+
export function Empty({ children, action, className, ...rest }) {
|
|
83
|
+
return (_jsxs("div", { ...rest, className: cx("ui-empty", className), children: [children, action] }));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The one primitive here that is behaviour rather than a box.
|
|
87
|
+
*
|
|
88
|
+
* A dialog has to trap focus, close on Escape, restore focus to
|
|
89
|
+
* whatever opened it, and not let a click inside the panel count as a
|
|
90
|
+
* click on the backdrop. Every extension that built its own would get
|
|
91
|
+
* some of that wrong, and the ones they get wrong are the ones only
|
|
92
|
+
* keyboard and screen-reader users notice.
|
|
93
|
+
*/
|
|
94
|
+
export function Dialog({ title, sub, children, actions, onClose, className, ...rest }) {
|
|
95
|
+
const panel = useRef(null);
|
|
96
|
+
const opener = useRef(null);
|
|
97
|
+
const titleId = useId();
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
opener.current = document.activeElement;
|
|
100
|
+
// Focus the panel itself rather than the first control: reading
|
|
101
|
+
// the title before the buttons is the point of having one.
|
|
102
|
+
panel.current?.focus();
|
|
103
|
+
return () => {
|
|
104
|
+
// Only if it is still in the document: an opener that has
|
|
105
|
+
// unmounted drops focus to <body> silently, which is worse than
|
|
106
|
+
// leaving it where the closing action put it.
|
|
107
|
+
const back = opener.current;
|
|
108
|
+
if (back instanceof HTMLElement && back.isConnected)
|
|
109
|
+
back.focus();
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
const onKeyDown = useCallback((event) => {
|
|
113
|
+
if (event.key === "Escape") {
|
|
114
|
+
event.stopPropagation();
|
|
115
|
+
onClose();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (event.key !== "Tab")
|
|
119
|
+
return;
|
|
120
|
+
// `:not([disabled])` matters more than it looks: a modal whose
|
|
121
|
+
// confirm button is disabled until a field is typed is the
|
|
122
|
+
// commonest pattern there is, and without this the wrap targets
|
|
123
|
+
// a disabled element, preventDefault fires, focus() is a no-op
|
|
124
|
+
// and Tab appears dead. Dead Tab is worse than escaping Tab.
|
|
125
|
+
// `iframe` is here because an extension *is* one.
|
|
126
|
+
const focusable = panel.current?.querySelectorAll([
|
|
127
|
+
"button:not([disabled])",
|
|
128
|
+
"a[href]",
|
|
129
|
+
"input:not([disabled]):not([type=hidden])",
|
|
130
|
+
"select:not([disabled])",
|
|
131
|
+
"textarea:not([disabled])",
|
|
132
|
+
"iframe",
|
|
133
|
+
"summary",
|
|
134
|
+
"[contenteditable]",
|
|
135
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
136
|
+
].join(", "));
|
|
137
|
+
if (!focusable || focusable.length === 0) {
|
|
138
|
+
// Nothing to move to, so hold the focus here rather than let
|
|
139
|
+
// Tab walk into the page behind a modal with no way back.
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const first = focusable[0];
|
|
144
|
+
const last = focusable[focusable.length - 1];
|
|
145
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
last.focus();
|
|
148
|
+
}
|
|
149
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
first.focus();
|
|
152
|
+
}
|
|
153
|
+
}, [onClose]);
|
|
154
|
+
return (_jsx("div", { className: "overlay", onMouseDown: (e) => {
|
|
155
|
+
// Primary button only, and only on the backdrop itself. A
|
|
156
|
+
// right-click raising a context menu used to dismiss the
|
|
157
|
+
// modal underneath it.
|
|
158
|
+
if (e.button === 0 && e.target === e.currentTarget)
|
|
159
|
+
onClose();
|
|
160
|
+
}, children: _jsxs("div", { ...rest, ref: panel, className: cx("dialog", className), role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, onKeyDown: onKeyDown,
|
|
161
|
+
// Without this a drag that starts inside and ends outside
|
|
162
|
+
// closes the dialog, which eats a selection.
|
|
163
|
+
onMouseDown: (e) => e.stopPropagation(), children: [_jsx("h2", { className: "dialog-title", id: titleId, children: title }), sub ? _jsx("p", { className: "dialog-sub", children: sub }) : null, children, actions ? (_jsx(Actions, { className: "dialog-actions", children: actions })) : null] }) }));
|
|
164
|
+
}
|
|
165
|
+
/** A drop-down. */
|
|
166
|
+
export function Select({ className, ...rest }) {
|
|
167
|
+
return _jsx("select", { ...rest, className: cx("ui-select", className) });
|
|
168
|
+
}
|
|
169
|
+
/** A multi-line text field. */
|
|
170
|
+
export function Textarea({ className, ...rest }) {
|
|
171
|
+
return _jsx("textarea", { ...rest, className: cx("ui-textarea", className) });
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A native checkbox, wrapped in its own label.
|
|
175
|
+
*
|
|
176
|
+
* Wrapped rather than associated by `id`, because an `id` an
|
|
177
|
+
* extension forgets to make unique is a label that checks somebody
|
|
178
|
+
* else's box — and nothing about the page looks wrong when it does.
|
|
179
|
+
*/
|
|
180
|
+
export function Checkbox({ label, className, ...rest }) {
|
|
181
|
+
return (_jsxs("label", { className: cx("ui-check", className), children: [_jsx("input", { type: "checkbox", ...rest }), _jsx("span", { children: label })] }));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A native radio, wrapped in its own label.
|
|
185
|
+
*
|
|
186
|
+
* Wrapped for the same reason a {@link Checkbox} is: an `id` an
|
|
187
|
+
* extension forgets to make unique is a label that picks somebody
|
|
188
|
+
* else's radio.
|
|
189
|
+
*/
|
|
190
|
+
export function Radio({ label, className, ...rest }) {
|
|
191
|
+
return (_jsxs("label", { className: cx("ui-check", className), children: [_jsx("input", { type: "radio", ...rest }), _jsx("span", { children: label })] }));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A switch, which is a button rather than a checkbox.
|
|
195
|
+
*
|
|
196
|
+
* The difference is not cosmetic. A checkbox is a value you submit; a
|
|
197
|
+
* switch takes effect the moment it moves. `role="switch"` is what
|
|
198
|
+
* tells a screen reader which of those it is looking at.
|
|
199
|
+
*/
|
|
200
|
+
export function Switch({ checked, onChange, label, className, ...rest }) {
|
|
201
|
+
const id = useId();
|
|
202
|
+
return (_jsxs("span", { className: "ui-check", children: [_jsx("button", { ...rest, type: "button", role: "switch", "aria-checked": checked, "aria-labelledby": id, onClick: () => onChange(!checked), className: cx("ui-switch", className) }), _jsx("span", { id: id, children: label })] }));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A label, a control, and room for the reason it is wrong.
|
|
206
|
+
*
|
|
207
|
+
* See {@link FieldProps}. The error slot is the part that gets left
|
|
208
|
+
* out, and a form that rejects input without saying why is the one
|
|
209
|
+
* people abandon.
|
|
210
|
+
*/
|
|
211
|
+
export function Field({ label, hint, error, htmlFor, children, className, ...rest }) {
|
|
212
|
+
const describedBy = htmlFor ? `${htmlFor}-note` : undefined;
|
|
213
|
+
// Cloned, not merely rendered beside. The first version put the id
|
|
214
|
+
// on the note and stopped, while the docstring claimed the control
|
|
215
|
+
// was wired to it — a claim its own test did not check, because the
|
|
216
|
+
// test asserted the id existed and never that anything referenced
|
|
217
|
+
// it. Nothing was announced. A Field cannot set an attribute on an
|
|
218
|
+
// opaque child without doing this.
|
|
219
|
+
const control = isValidElement(children) && describedBy && (error || hint)
|
|
220
|
+
? cloneElement(children, {
|
|
221
|
+
"aria-describedby": describedBy,
|
|
222
|
+
...(error ? { "aria-invalid": true } : {}),
|
|
223
|
+
})
|
|
224
|
+
: children;
|
|
225
|
+
return (_jsxs("div", { ...rest, className: cx("ui-field", className), children: [_jsx("label", { className: "ui-label", htmlFor: htmlFor, children: label }), control, error ? (_jsx("span", { className: "ui-error", id: describedBy, role: "alert", children: error })) : hint ? (_jsx("span", { className: "ui-hint", id: describedBy, children: hint })) : null] }));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Work whose duration is unknown.
|
|
229
|
+
*
|
|
230
|
+
* See {@link SpinnerProps} for why `label` is required.
|
|
231
|
+
*/
|
|
232
|
+
export function Spinner({ label, className, ...rest }) {
|
|
233
|
+
return (_jsx("span", { ...rest, role: "status", "aria-live": "polite", className: cx("ui-spinner", className), children: _jsx("span", { className: "ui-visually-hidden", children: label }) }));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A bar that fills.
|
|
237
|
+
*
|
|
238
|
+
* See {@link ProgressProps}. Without a `value` it slides, because a
|
|
239
|
+
* bar that sits still while unknown work is happening is a bar that
|
|
240
|
+
* looks broken.
|
|
241
|
+
*/
|
|
242
|
+
export function Progress({ value, max = 100, label, className, ...rest }) {
|
|
243
|
+
const determinate = typeof value === "number";
|
|
244
|
+
const clamped = determinate
|
|
245
|
+
? Math.max(0, Math.min(max, value))
|
|
246
|
+
: undefined;
|
|
247
|
+
const pct = determinate ? (clamped / max) * 100 : undefined;
|
|
248
|
+
return (_jsx("div", { ...rest, className: cx("ui-progress", className), role: "progressbar", "aria-label": label, "aria-valuenow": clamped, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuetext": determinate ? `${Math.round(pct)}%` : undefined, "data-indeterminate": !determinate, children: _jsx("div", { className: "ui-progress-fill", style: determinate ? { width: `${pct}%` } : undefined }) }));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Tabs with the arrow keys wired, because a tab strip that only
|
|
252
|
+
* responds to clicks is a tab strip half the people cannot use.
|
|
253
|
+
*/
|
|
254
|
+
export function Tabs({ tabs, active, onChange, label, base: givenBase, className, ...rest }) {
|
|
255
|
+
// Hooks run unconditionally; the generated id is simply unused
|
|
256
|
+
// when a caller supplied one.
|
|
257
|
+
const generated = useId();
|
|
258
|
+
const base = givenBase ?? generated;
|
|
259
|
+
const strip = useRef(null);
|
|
260
|
+
// Focus follows selection, which the ARIA practices require and
|
|
261
|
+
// this did not do. Without it the focus ring sits on a tab that is
|
|
262
|
+
// now tabIndex={-1} while a different one is selected, and the next
|
|
263
|
+
// Tab leaves the strip from somewhere the reader cannot see.
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
const el = strip.current?.querySelector('[aria-selected="true"]');
|
|
266
|
+
if (el && strip.current?.contains(document.activeElement))
|
|
267
|
+
el.focus();
|
|
268
|
+
}, [active]);
|
|
269
|
+
const onKeyDown = (event) => {
|
|
270
|
+
if (tabs.length === 0)
|
|
271
|
+
return;
|
|
272
|
+
const i = tabs.findIndex((t) => t.id === active);
|
|
273
|
+
let next = null;
|
|
274
|
+
if (event.key === "ArrowRight")
|
|
275
|
+
next = (Math.max(i, 0) + 1) % tabs.length;
|
|
276
|
+
else if (event.key === "ArrowLeft")
|
|
277
|
+
next = (Math.max(i, 0) - 1 + tabs.length) % tabs.length;
|
|
278
|
+
else if (event.key === "Home")
|
|
279
|
+
next = 0;
|
|
280
|
+
else if (event.key === "End")
|
|
281
|
+
next = tabs.length - 1;
|
|
282
|
+
if (next === null)
|
|
283
|
+
return;
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
onChange(tabs[next].id);
|
|
286
|
+
};
|
|
287
|
+
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", {
|
|
288
|
+
// Real DOM ids, so a panel can point back with
|
|
289
|
+
// aria-labelledby and this one can point at it. Without
|
|
290
|
+
// them a screen reader announces "tab, 1 of 2" controlling
|
|
291
|
+
// nothing.
|
|
292
|
+
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))) }));
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The panel a tab controls.
|
|
296
|
+
*
|
|
297
|
+
* See {@link TabPanelProps}. It renders nothing at all when its tab is
|
|
298
|
+
* not the active one, so the content of a panel that is not showing
|
|
299
|
+
* is not in the page.
|
|
300
|
+
*/
|
|
301
|
+
export function TabPanel({ base, id, active, children, className, ...rest }) {
|
|
302
|
+
if (id !== active)
|
|
303
|
+
return null;
|
|
304
|
+
return (_jsx("div", { ...rest, id: `${base}-${id}-panel`, role: "tabpanel", "aria-labelledby": `${base}-${id}`, tabIndex: 0, className: className, children: children }));
|
|
305
|
+
}
|
|
306
|
+
// ── Text ────────────────────────────────────────────────────────────
|
|
307
|
+
/** A horizontal rule. */
|
|
308
|
+
export function Divider({ className, ...rest }) {
|
|
309
|
+
return _jsx("hr", { ...rest, className: cx("ui-divider", className) });
|
|
310
|
+
}
|
|
311
|
+
const HEADING_SIZE = {
|
|
312
|
+
1: "var(--text-2xl)",
|
|
313
|
+
2: "var(--text-xl)",
|
|
314
|
+
3: "var(--text-lg)",
|
|
315
|
+
4: "var(--text-sm)",
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* A heading, at the level you say.
|
|
319
|
+
*
|
|
320
|
+
* The size follows the level, so the outline and the type cannot
|
|
321
|
+
* disagree — which is the whole reason there is no `Title`.
|
|
322
|
+
*/
|
|
323
|
+
export function Heading({ level = 2, className, style, ...rest }) {
|
|
324
|
+
const Tag = `h${level}`;
|
|
325
|
+
return (_jsx(Tag, { ...rest, className: cx("ui-heading", className), style: { fontSize: HEADING_SIZE[level], ...style } }));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* A paragraph.
|
|
329
|
+
*
|
|
330
|
+
* {@link TextTone} says how loud it is — emphasis, not status. A
|
|
331
|
+
* status is a {@link Badge}.
|
|
332
|
+
*/
|
|
333
|
+
export function Text({ tone = "default", className, ...rest }) {
|
|
334
|
+
return _jsx("p", { ...rest, "data-tone": tone, className: cx("ui-text", className) });
|
|
335
|
+
}
|
|
336
|
+
/** Inline code: a name, a path, a flag. */
|
|
337
|
+
export function Code({ className, ...rest }) {
|
|
338
|
+
return _jsx("code", { ...rest, className: cx("ui-code", className) });
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=primit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@ignite-ember/ui-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The React components an igni extension is allowed to build on. Everything exported here is under the compatibility floor.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"igni",
|
|
7
|
+
"extension",
|
|
8
|
+
"react",
|
|
9
|
+
"components",
|
|
10
|
+
"ui"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"author": "Ignite Ember (https://ignite-ember.sh/)",
|
|
14
|
+
"homepage": "https://ignite-ember.sh/docs/sdk/ui-react",
|
|
15
|
+
"documentation": "https://ignite-ember.sh/docs/sdk/ui-react",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/ignite-ember/igni-sdk/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ignite-ember/igni-sdk.git",
|
|
22
|
+
"directory": "packages/ui-react"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"node": "./dist/index.js",
|
|
31
|
+
"default": "./src/index.ts"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"src",
|
|
36
|
+
"dist",
|
|
37
|
+
"!src/**/*.test.ts",
|
|
38
|
+
"!src/**/*.test.tsx",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"NOTICE"
|
|
42
|
+
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
45
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
46
|
+
"react-markdown": "^9.0.0 || ^10.0.0",
|
|
47
|
+
"remark-gfm": "^4.0.0",
|
|
48
|
+
"mermaid": "^11.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"mermaid": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies a diagram's fenced source, not the rendered SVG.
|
|
3
|
+
*
|
|
4
|
+
* What somebody wants from a diagram is the text that made it —
|
|
5
|
+
* to paste into another document, or to fix. Nobody wants the
|
|
6
|
+
* markup a renderer produced.
|
|
7
|
+
*
|
|
8
|
+
* A blocked clipboard says so, on the button itself: a click that
|
|
9
|
+
* appears to work and leaves nothing to paste is worse than one
|
|
10
|
+
* that admits it failed.
|
|
11
|
+
*/
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
|
|
14
|
+
import { MenuIcon } from "./MenuIcon.js";
|
|
15
|
+
|
|
16
|
+
type CopyState = "idle" | "copied" | "failed";
|
|
17
|
+
|
|
18
|
+
/** How long "Copied" or "Copy failed" stays before the button resets. */
|
|
19
|
+
const FEEDBACK_MS = 1300;
|
|
20
|
+
|
|
21
|
+
const LABEL: Record<CopyState, string> = {
|
|
22
|
+
idle: "Copy source",
|
|
23
|
+
copied: "Copied",
|
|
24
|
+
failed: "Copy failed — the clipboard is blocked",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function CopySource({ source }: { source: string }) {
|
|
28
|
+
const [state, setState] = useState<CopyState>("idle");
|
|
29
|
+
|
|
30
|
+
const copy = async () => {
|
|
31
|
+
try {
|
|
32
|
+
await navigator.clipboard.writeText(source);
|
|
33
|
+
setState("copied");
|
|
34
|
+
} catch {
|
|
35
|
+
setState("failed");
|
|
36
|
+
}
|
|
37
|
+
window.setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="diagram-copy"
|
|
44
|
+
data-state={state}
|
|
45
|
+
title={LABEL[state]}
|
|
46
|
+
aria-label={LABEL[state]}
|
|
47
|
+
onClick={() => void copy()}
|
|
48
|
+
>
|
|
49
|
+
<MenuIcon name={state === "copied" ? "check" : "copy"} />
|
|
50
|
+
</button>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a table the floor was missing.
|
|
3
|
+
*
|
|
4
|
+
* `Table` is a bare `<table>` and stays one — the markup inside is
|
|
5
|
+
* the extension's, per EXTENSIBILITY §8, and a `DataTable` that owns
|
|
6
|
+
* rows would have to own sorting, selection, paging and
|
|
7
|
+
* virtualisation with it. What was missing is narrower and entirely
|
|
8
|
+
* behaviour: a sortable header nobody announces wrongly, and a
|
|
9
|
+
* selection state that reads as selected.
|
|
10
|
+
*
|
|
11
|
+
* `.ui-table` was three CSS declarations until now — width,
|
|
12
|
+
* border-collapse, font-size — so cell padding, the header rule and
|
|
13
|
+
* the sticky header were every extension's problem too. Those are in
|
|
14
|
+
* `igni-ui.css` now; these are the components that drive them.
|
|
15
|
+
*/
|
|
16
|
+
import type { ReactNode, ThHTMLAttributes } from "react";
|
|
17
|
+
|
|
18
|
+
function cx(...parts: (string | false | null | undefined)[]): string {
|
|
19
|
+
return parts.filter(Boolean).join(" ");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Which way a column is sorted, or not. */
|
|
23
|
+
export type SortDirection = "ascending" | "descending";
|
|
24
|
+
|
|
25
|
+
/** What a {@link SortableTh} takes. */
|
|
26
|
+
export interface SortableThProps
|
|
27
|
+
extends Omit<ThHTMLAttributes<HTMLTableCellElement>, "onClick" | "aria-sort"> {
|
|
28
|
+
/** The heading. */
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* How this column is currently sorted, or `undefined` when the
|
|
32
|
+
* table is sorted by some other column.
|
|
33
|
+
*/
|
|
34
|
+
direction?: SortDirection;
|
|
35
|
+
/** Asked to sort by this column. Gets the direction to go to. */
|
|
36
|
+
onSort: (direction: SortDirection) => void;
|
|
37
|
+
/** Right-align and use tabular figures. */
|
|
38
|
+
numeric?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A column heading you can sort by.
|
|
43
|
+
*
|
|
44
|
+
* `aria-sort` goes on the `th` and nowhere else, which is what a
|
|
45
|
+
* screen reader reads; the arrow is `aria-hidden` so the state is
|
|
46
|
+
* not announced twice. Hand-rolled versions usually do the reverse —
|
|
47
|
+
* an arrow glyph with no `aria-sort` — and the sort is then
|
|
48
|
+
* invisible to the people most reliant on being told.
|
|
49
|
+
*
|
|
50
|
+
* The button fills the cell so the whole heading is the target
|
|
51
|
+
* rather than a word inside it.
|
|
52
|
+
*/
|
|
53
|
+
export function SortableTh({
|
|
54
|
+
children,
|
|
55
|
+
direction,
|
|
56
|
+
onSort,
|
|
57
|
+
numeric = false,
|
|
58
|
+
className,
|
|
59
|
+
...rest
|
|
60
|
+
}: SortableThProps) {
|
|
61
|
+
// Clicking the sorted column reverses it; clicking any other
|
|
62
|
+
// column starts ascending. Starting descending is defensible for
|
|
63
|
+
// dates and wrong for everything else, so the caller re-sorts if
|
|
64
|
+
// it wants that.
|
|
65
|
+
const next: SortDirection = direction === "ascending" ? "descending" : "ascending";
|
|
66
|
+
return (
|
|
67
|
+
<th
|
|
68
|
+
{...rest}
|
|
69
|
+
scope="col"
|
|
70
|
+
aria-sort={direction ?? "none"}
|
|
71
|
+
className={cx(numeric && "ui-num", className)}
|
|
72
|
+
>
|
|
73
|
+
<button type="button" className="ui-th-sort" onClick={() => onSort(next)}>
|
|
74
|
+
{children}
|
|
75
|
+
<span className="ui-th-arrow" aria-hidden="true">
|
|
76
|
+
{direction === "descending" ? "▾" : "▴"}
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
</th>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** What a {@link Status} takes. */
|
|
84
|
+
export interface StatusProps {
|
|
85
|
+
/** The four states the health contract defines. */
|
|
86
|
+
state: "READY" | "PREPARING" | "DISABLED" | "FAILED";
|
|
87
|
+
/**
|
|
88
|
+
* What to show beside the dot. Defaults to the state itself.
|
|
89
|
+
*
|
|
90
|
+
* There is always a word. The dot is a colour, and a colour on its
|
|
91
|
+
* own is not a message — it says nothing when read aloud and
|
|
92
|
+
* nothing to somebody who cannot tell green from amber.
|
|
93
|
+
*/
|
|
94
|
+
children?: ReactNode;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A state, as a coloured dot and the word it stands for. */
|
|
98
|
+
export function Status({ state, children }: StatusProps) {
|
|
99
|
+
return (
|
|
100
|
+
<span className="ui-status" data-state={state}>
|
|
101
|
+
{children ?? state}
|
|
102
|
+
</span>
|
|
103
|
+
);
|
|
104
|
+
}
|