@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.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +260 -2
- package/dist/CopySource.d.ts +4 -0
- package/dist/CopySource.d.ts.map +1 -0
- package/dist/CopySource.js +50 -0
- package/dist/CopySource.js.map +1 -0
- package/dist/DataTable.d.ts +77 -0
- package/dist/DataTable.d.ts.map +1 -0
- package/dist/DataTable.js +45 -0
- package/dist/DataTable.js.map +1 -0
- 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 +97 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +97 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/LiveRegion.d.ts +41 -0
- package/dist/LiveRegion.d.ts.map +1 -0
- package/dist/LiveRegion.js +76 -0
- package/dist/LiveRegion.js.map +1 -0
- package/dist/Markdown.d.ts +22 -0
- package/dist/Markdown.d.ts.map +1 -0
- package/dist/Markdown.js +56 -0
- package/dist/Markdown.js.map +1 -0
- package/dist/MarkdownInline.d.ts +53 -0
- package/dist/MarkdownInline.d.ts.map +1 -0
- package/dist/MarkdownInline.js +159 -0
- package/dist/MarkdownInline.js.map +1 -0
- package/dist/MenuIcon.d.ts +60 -0
- package/dist/MenuIcon.d.ts.map +1 -0
- package/dist/MenuIcon.js +102 -0
- package/dist/MenuIcon.js.map +1 -0
- package/dist/Mermaid.d.ts +40 -0
- package/dist/Mermaid.d.ts.map +1 -0
- package/dist/Mermaid.js +121 -0
- package/dist/Mermaid.js.map +1 -0
- package/dist/Monogram.d.ts +46 -0
- package/dist/Monogram.d.ts.map +1 -0
- package/dist/Monogram.js +96 -0
- package/dist/Monogram.js.map +1 -0
- package/dist/OverflowMenu.d.ts +60 -0
- package/dist/OverflowMenu.d.ts.map +1 -0
- package/dist/OverflowMenu.js +149 -0
- package/dist/OverflowMenu.js.map +1 -0
- package/dist/Shell.d.ts +67 -0
- package/dist/Shell.d.ts.map +1 -0
- package/dist/Shell.js +44 -0
- package/dist/Shell.js.map +1 -0
- package/dist/Skeleton.d.ts +62 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +56 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/Split.d.ts +85 -0
- package/dist/Split.d.ts.map +1 -0
- package/dist/Split.js +156 -0
- package/dist/Split.js.map +1 -0
- 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 +98 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +129 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +24 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +166 -0
- package/dist/Tooltip.js.map +1 -0
- 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/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 +26 -0
- package/dist/fenceInfo.d.ts.map +1 -0
- package/dist/fenceInfo.js +22 -0
- package/dist/fenceInfo.js.map +1 -0
- 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 +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- 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 +33 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +33 -0
- package/dist/primitives.js.map +1 -0
- 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 +56 -4
- package/src/CopySource.tsx +67 -0
- package/src/DataTable.tsx +120 -0
- package/src/Dialog.tsx +158 -0
- package/src/ErrorBoundary.tsx +137 -0
- package/src/LiveRegion.tsx +127 -0
- package/src/Markdown.tsx +75 -0
- package/src/MarkdownInline.tsx +177 -0
- package/src/MenuIcon.tsx +209 -0
- package/src/Mermaid.tsx +144 -0
- package/src/Monogram.tsx +112 -0
- package/src/OverflowMenu.tsx +359 -0
- package/src/Shell.tsx +99 -0
- package/src/Skeleton.tsx +98 -0
- package/src/Split.tsx +267 -0
- package/src/Tabs.tsx +194 -0
- package/src/Toast.tsx +269 -0
- package/src/Tooltip.tsx +213 -0
- package/src/controls.tsx +159 -0
- package/src/cx.ts +4 -0
- package/src/fenceInfo.ts +36 -0
- package/src/formControls.tsx +249 -0
- package/src/index.ts +149 -0
- package/src/layout.tsx +141 -0
- package/src/primitives.tsx +33 -0
- package/src/progress.tsx +129 -0
- package/src/text.tsx +99 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrappers over the CSS primitives.
|
|
3
|
+
*
|
|
4
|
+
* The classes already existed — `btn`, `ui-card`, `ui-row`,
|
|
5
|
+
* `ui-badge` — and an extension could write them by hand. These
|
|
6
|
+
* exist because writing them by hand is not an API: there is no
|
|
7
|
+
* autocomplete, no way to learn the variant names short of reading
|
|
8
|
+
* `theme.css`, and nothing stops `class="btn btn-primery"` from
|
|
9
|
+
* shipping as an invisible bug.
|
|
10
|
+
*
|
|
11
|
+
* Every one of these is a thin mapping from props to class names.
|
|
12
|
+
* They hold no state and make no decisions. That is deliberate: the
|
|
13
|
+
* appearance lives in CSS where the app and the extension share it,
|
|
14
|
+
* and a wrapper that started making layout choices would be a second
|
|
15
|
+
* place for the design to live.
|
|
16
|
+
*
|
|
17
|
+
* `Dialog` is the exception and says so at its own definition — a
|
|
18
|
+
* dialog is behaviour, not just a box.
|
|
19
|
+
*
|
|
20
|
+
* This module is the one name the primitives are imported by. Each
|
|
21
|
+
* group lives in its own file, re-exported here in reading order.
|
|
22
|
+
*
|
|
23
|
+
* **Under the compatibility floor.** A prop here is a promise; see
|
|
24
|
+
* EXTENSIBILITY.md §8.
|
|
25
|
+
*/
|
|
26
|
+
export * from "./controls.js";
|
|
27
|
+
export * from "./layout.js";
|
|
28
|
+
export * from "./Dialog.js";
|
|
29
|
+
export * from "./formControls.js";
|
|
30
|
+
export * from "./progress.js";
|
|
31
|
+
export * from "./Tabs.js";
|
|
32
|
+
export * from "./text.js";
|
|
33
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrappers over the CSS primitives.
|
|
3
|
+
*
|
|
4
|
+
* The classes already existed — `btn`, `ui-card`, `ui-row`,
|
|
5
|
+
* `ui-badge` — and an extension could write them by hand. These
|
|
6
|
+
* exist because writing them by hand is not an API: there is no
|
|
7
|
+
* autocomplete, no way to learn the variant names short of reading
|
|
8
|
+
* `theme.css`, and nothing stops `class="btn btn-primery"` from
|
|
9
|
+
* shipping as an invisible bug.
|
|
10
|
+
*
|
|
11
|
+
* Every one of these is a thin mapping from props to class names.
|
|
12
|
+
* They hold no state and make no decisions. That is deliberate: the
|
|
13
|
+
* appearance lives in CSS where the app and the extension share it,
|
|
14
|
+
* and a wrapper that started making layout choices would be a second
|
|
15
|
+
* place for the design to live.
|
|
16
|
+
*
|
|
17
|
+
* `Dialog` is the exception and says so at its own definition — a
|
|
18
|
+
* dialog is behaviour, not just a box.
|
|
19
|
+
*
|
|
20
|
+
* This module is the one name the primitives are imported by. Each
|
|
21
|
+
* group lives in its own file, re-exported here in reading order.
|
|
22
|
+
*
|
|
23
|
+
* **Under the compatibility floor.** A prop here is a promise; see
|
|
24
|
+
* EXTENSIBILITY.md §8.
|
|
25
|
+
*/
|
|
26
|
+
export * from "./controls.js";
|
|
27
|
+
export * from "./layout.js";
|
|
28
|
+
export * from "./Dialog.js";
|
|
29
|
+
export * from "./formControls.js";
|
|
30
|
+
export * from "./progress.js";
|
|
31
|
+
export * from "./Tabs.js";
|
|
32
|
+
export * from "./text.js";
|
|
33
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work in progress: a spinner for work of unknown length, and a bar
|
|
3
|
+
* for work that can say how far along it is.
|
|
4
|
+
*
|
|
5
|
+
* Part of the primitives; see `primitives.tsx`. **Under the
|
|
6
|
+
* compatibility floor.**
|
|
7
|
+
*/
|
|
8
|
+
import type { HTMLAttributes } from "react";
|
|
9
|
+
/**
|
|
10
|
+
* Work whose duration is unknown. `Skeleton` is for known shapes.
|
|
11
|
+
*
|
|
12
|
+
* `label` is required for the same reason `Progress.label` is: a
|
|
13
|
+
* `role="status"` with nothing in it gives a screen reader silence
|
|
14
|
+
* while a sighted user watches something spin.
|
|
15
|
+
*/
|
|
16
|
+
export interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
17
|
+
/** Required: a spinner with no name is a live region with nothing in it. */
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Work whose duration is unknown.
|
|
22
|
+
*
|
|
23
|
+
* See {@link SpinnerProps} for why `label` is required.
|
|
24
|
+
*
|
|
25
|
+
* @param label — required: a spinner with no name is a live region with
|
|
26
|
+
* nothing in it.
|
|
27
|
+
* @param className — added to the element's classes, beside the one the
|
|
28
|
+
* theme gives it.
|
|
29
|
+
* @param rest — the remaining props, spread onto the span.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Spinner({ label, className, ...rest }: SpinnerProps): import("react").JSX.Element;
|
|
32
|
+
/** What a {@link Progress} takes. */
|
|
33
|
+
export interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
/**
|
|
35
|
+
* How far along, against `max`. Omit for indeterminate, which
|
|
36
|
+
* slides rather than sits.
|
|
37
|
+
*
|
|
38
|
+
* A value against a max, as `<progress>` and the ARIA attributes
|
|
39
|
+
* take it, so `value={50}` means half way.
|
|
40
|
+
*/
|
|
41
|
+
value?: number;
|
|
42
|
+
/** Defaults to 100. */
|
|
43
|
+
max?: number;
|
|
44
|
+
/** Its name, for a screen reader. */
|
|
45
|
+
label: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A bar that fills.
|
|
49
|
+
*
|
|
50
|
+
* See {@link ProgressProps}. Without a `value` it slides, because a
|
|
51
|
+
* bar that sits still while unknown work is happening is a bar that
|
|
52
|
+
* looks broken.
|
|
53
|
+
*
|
|
54
|
+
* @param value — how far along, against `max`; omit it for
|
|
55
|
+
* indeterminate, which slides rather than sits.
|
|
56
|
+
* @param max — the value that counts as complete, against which `value`
|
|
57
|
+
* is measured; it defaults to 100.
|
|
58
|
+
* @param label — its name, for a screen reader.
|
|
59
|
+
* @param className — added to the element's classes, beside the one the
|
|
60
|
+
* theme gives it.
|
|
61
|
+
* @param rest — the remaining props, spread onto the element.
|
|
62
|
+
*/
|
|
63
|
+
export declare function Progress({ value, max, label, className, ...rest }: ProgressProps): import("react").JSX.Element;
|
|
64
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C;;;;;;GAMG;AACH,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,eAAe,CAAC;IACnE,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,+BAWlE;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAwBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,GAAS,EACT,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACR,EAAE,aAAa,+BAoBf"}
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Work whose duration is unknown.
|
|
5
|
+
*
|
|
6
|
+
* See {@link SpinnerProps} for why `label` is required.
|
|
7
|
+
*
|
|
8
|
+
* @param label — required: a spinner with no name is a live region with
|
|
9
|
+
* nothing in it.
|
|
10
|
+
* @param className — added to the element's classes, beside the one the
|
|
11
|
+
* theme gives it.
|
|
12
|
+
* @param rest — the remaining props, spread onto the span.
|
|
13
|
+
*/
|
|
14
|
+
export function Spinner({ label, className, ...rest }) {
|
|
15
|
+
return (_jsx("span", { ...rest, role: "status", "aria-live": "polite", className: cx("ui-spinner", className), children: _jsx("span", { className: "ui-visually-hidden", children: label }) }));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `value` measured against `max`, or `null` when there is nothing to
|
|
19
|
+
* measure and the bar is indeterminate.
|
|
20
|
+
*/
|
|
21
|
+
function measure(value, max) {
|
|
22
|
+
// NaN is not a measurement: it reads as unknown, like no value.
|
|
23
|
+
if (typeof value !== "number" || Number.isNaN(value))
|
|
24
|
+
return null;
|
|
25
|
+
const now = Math.max(0, Math.min(max, value));
|
|
26
|
+
// A `max` of zero or less has nothing to measure against; an empty
|
|
27
|
+
// bar is honest where `0 / 0` would write "NaN%".
|
|
28
|
+
const pct = max > 0 ? (now / max) * 100 : 0;
|
|
29
|
+
return { now, pct };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A bar that fills.
|
|
33
|
+
*
|
|
34
|
+
* See {@link ProgressProps}. Without a `value` it slides, because a
|
|
35
|
+
* bar that sits still while unknown work is happening is a bar that
|
|
36
|
+
* looks broken.
|
|
37
|
+
*
|
|
38
|
+
* @param value — how far along, against `max`; omit it for
|
|
39
|
+
* indeterminate, which slides rather than sits.
|
|
40
|
+
* @param max — the value that counts as complete, against which `value`
|
|
41
|
+
* is measured; it defaults to 100.
|
|
42
|
+
* @param label — its name, for a screen reader.
|
|
43
|
+
* @param className — added to the element's classes, beside the one the
|
|
44
|
+
* theme gives it.
|
|
45
|
+
* @param rest — the remaining props, spread onto the element.
|
|
46
|
+
*/
|
|
47
|
+
export function Progress({ value, max = 100, label, className, ...rest }) {
|
|
48
|
+
const reading = measure(value, max);
|
|
49
|
+
return (_jsx("div", { ...rest, className: cx("ui-progress", className), role: "progressbar", "aria-label": label, "aria-valuenow": reading?.now, "aria-valuemin": 0, "aria-valuemax": max, "aria-valuetext": reading ? `${Math.round(reading.pct)}%` : undefined, "data-indeterminate": reading === null, children: _jsx("div", { className: "ui-progress-fill", style: reading ? { width: `${reading.pct}%` } : undefined }) }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAc7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAgB;IACjE,OAAO,CACL,kBACM,IAAI,EACR,IAAI,EAAC,QAAQ,eACH,QAAQ,EAClB,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,YAEtC,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAQ,GAC9C,CACR,CAAC;AACJ,CAAC;AA0BD;;;GAGG;AACH,SAAS,OAAO,CAAC,KAAyB,EAAE,GAAW;IACrD,gEAAgE;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9C,mEAAmE;IACnE,kDAAkD;IAClD,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,KAAK,EACL,GAAG,GAAG,GAAG,EACT,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACO;IACd,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpC,OAAO,CACL,iBACM,IAAI,EACR,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EACvC,IAAI,EAAC,aAAa,gBACN,KAAK,mBACF,OAAO,EAAE,GAAG,mBACZ,CAAC,mBACD,GAAG,oBACF,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,wBAC/C,OAAO,KAAK,IAAI,YAEpC,cACE,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,GACzD,GACE,CACP,CAAC;AACJ,CAAC"}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text: a rule, a heading, a paragraph and inline code.
|
|
3
|
+
*
|
|
4
|
+
* Part of the primitives; see `primitives.tsx`. **Under the
|
|
5
|
+
* compatibility floor.**
|
|
6
|
+
*/
|
|
7
|
+
import type { HTMLAttributes } from "react";
|
|
8
|
+
/**
|
|
9
|
+
* A horizontal rule.
|
|
10
|
+
*
|
|
11
|
+
* @param className — added to the element's classes, beside the one the
|
|
12
|
+
* theme gives it.
|
|
13
|
+
* @param rest — the remaining props, spread onto the rule.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Divider({ className, ...rest }: HTMLAttributes<HTMLHRElement>): import("react").JSX.Element;
|
|
16
|
+
/** What a {@link Heading} takes. */
|
|
17
|
+
export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
18
|
+
/** The outline level. Also picks the size, so they cannot disagree. */
|
|
19
|
+
level?: 1 | 2 | 3 | 4;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A heading, at the level you say.
|
|
23
|
+
*
|
|
24
|
+
* The size follows the level, so the outline and the type cannot
|
|
25
|
+
* disagree — which is the whole reason there is no `Title`.
|
|
26
|
+
*
|
|
27
|
+
* @param level — the outline level; it also picks the size, so the two
|
|
28
|
+
* cannot disagree.
|
|
29
|
+
* @param className — added to the element's classes, beside the one the
|
|
30
|
+
* theme gives it.
|
|
31
|
+
* @param style — the element's inline style, merged over the size the
|
|
32
|
+
* level picks.
|
|
33
|
+
* @param rest — the remaining props, spread onto the heading.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Heading({ level, className, style, ...rest }: HeadingProps): import("react").JSX.Element;
|
|
36
|
+
/** How loud. Not {@link Tone}: this is emphasis, not status. */
|
|
37
|
+
export type TextTone = "default" | "muted" | "faint";
|
|
38
|
+
/** What a {@link Text} takes. */
|
|
39
|
+
export interface TextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
40
|
+
/** How loud it is. */
|
|
41
|
+
tone?: TextTone;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A paragraph.
|
|
45
|
+
*
|
|
46
|
+
* {@link TextTone} says how loud it is — emphasis, not status. A
|
|
47
|
+
* status is a {@link Badge}.
|
|
48
|
+
*
|
|
49
|
+
* @param tone — how loud it is: emphasis rather than status.
|
|
50
|
+
* @param className — added to the element's classes, beside the one the
|
|
51
|
+
* theme gives it.
|
|
52
|
+
* @param rest — the remaining props, spread onto the paragraph.
|
|
53
|
+
*/
|
|
54
|
+
export declare function Text({ tone, className, ...rest }: TextProps): import("react").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Inline code: a name, a path, a flag.
|
|
57
|
+
*
|
|
58
|
+
* @param className — added to the element's classes, beside the one the
|
|
59
|
+
* theme gives it.
|
|
60
|
+
* @param rest — the remaining props, spread onto the element.
|
|
61
|
+
*/
|
|
62
|
+
export declare function Code({ className, ...rest }: HTMLAttributes<HTMLElement>): import("react").JSX.Element;
|
|
63
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,aAAa,CAAC,+BAE5E;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,kBAAkB,CAAC;IACtE,uEAAuE;IACvE,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACvB;AASD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,EACtB,KAAS,EACT,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,YAAY,+BASd;AAED,gEAAgE;AAChE,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAErD,iCAAiC;AACjC,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,oBAAoB,CAAC;IACrE,sBAAsB;IACtB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,EAAE,IAAgB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,WAAW,CAAC,+BAEvE"}
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
/**
|
|
4
|
+
* A horizontal rule.
|
|
5
|
+
*
|
|
6
|
+
* @param className — added to the element's classes, beside the one the
|
|
7
|
+
* theme gives it.
|
|
8
|
+
* @param rest — the remaining props, spread onto the rule.
|
|
9
|
+
*/
|
|
10
|
+
export function Divider({ className, ...rest }) {
|
|
11
|
+
return _jsx("hr", { ...rest, className: cx("ui-divider", className) });
|
|
12
|
+
}
|
|
13
|
+
const HEADING_SIZE = {
|
|
14
|
+
1: "var(--text-2xl)",
|
|
15
|
+
2: "var(--text-xl)",
|
|
16
|
+
3: "var(--text-lg)",
|
|
17
|
+
4: "var(--text-sm)",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A heading, at the level you say.
|
|
21
|
+
*
|
|
22
|
+
* The size follows the level, so the outline and the type cannot
|
|
23
|
+
* disagree — which is the whole reason there is no `Title`.
|
|
24
|
+
*
|
|
25
|
+
* @param level — the outline level; it also picks the size, so the two
|
|
26
|
+
* cannot disagree.
|
|
27
|
+
* @param className — added to the element's classes, beside the one the
|
|
28
|
+
* theme gives it.
|
|
29
|
+
* @param style — the element's inline style, merged over the size the
|
|
30
|
+
* level picks.
|
|
31
|
+
* @param rest — the remaining props, spread onto the heading.
|
|
32
|
+
*/
|
|
33
|
+
export function Heading({ level = 2, className, style, ...rest }) {
|
|
34
|
+
const Tag = `h${level}`;
|
|
35
|
+
return (_jsx(Tag, { ...rest, className: cx("ui-heading", className), style: { fontSize: HEADING_SIZE[level], ...style } }));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A paragraph.
|
|
39
|
+
*
|
|
40
|
+
* {@link TextTone} says how loud it is — emphasis, not status. A
|
|
41
|
+
* status is a {@link Badge}.
|
|
42
|
+
*
|
|
43
|
+
* @param tone — how loud it is: emphasis rather than status.
|
|
44
|
+
* @param className — added to the element's classes, beside the one the
|
|
45
|
+
* theme gives it.
|
|
46
|
+
* @param rest — the remaining props, spread onto the paragraph.
|
|
47
|
+
*/
|
|
48
|
+
export function Text({ tone = "default", className, ...rest }) {
|
|
49
|
+
return _jsx("p", { ...rest, "data-tone": tone, className: cx("ui-text", className) });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Inline code: a name, a path, a flag.
|
|
53
|
+
*
|
|
54
|
+
* @param className — added to the element's classes, beside the one the
|
|
55
|
+
* theme gives it.
|
|
56
|
+
* @param rest — the remaining props, spread onto the element.
|
|
57
|
+
*/
|
|
58
|
+
export function Code({ className, ...rest }) {
|
|
59
|
+
return _jsx("code", { ...rest, className: cx("ui-code", className) });
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=text.js.map
|
package/dist/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAiC;IAC3E,OAAO,gBAAQ,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,GAAI,CAAC;AAClE,CAAC;AAQD,MAAM,YAAY,GAAG;IACnB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,gBAAgB;CACX,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,KAAK,GAAG,CAAC,EACT,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACM;IACb,MAAM,GAAG,GAAG,IAAI,KAAK,EAA+B,CAAC;IACrD,OAAO,CACL,KAAC,GAAG,OACE,IAAI,EACR,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,EACtC,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,GAClD,CACH,CAAC;AACJ,CAAC;AAWD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAa;IACtE,OAAO,eAAO,IAAI,eAAa,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,GAAI,CAAC;AAC/E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAA+B;IACtE,OAAO,kBAAU,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,GAAI,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignite-ember/ui-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
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://igni.sh/)",
|
|
14
|
+
"homepage": "https://igni.sh/docs/sdk/ui-react",
|
|
15
|
+
"documentation": "https://igni.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,67 @@
|
|
|
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 { useEffect, useRef, 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 timer = useRef<number | undefined>(undefined);
|
|
31
|
+
|
|
32
|
+
// A pending reset must not outlive the button, nor cut a later
|
|
33
|
+
// click's feedback short.
|
|
34
|
+
const alive = useRef(true);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
alive.current = true;
|
|
37
|
+
return () => {
|
|
38
|
+
alive.current = false;
|
|
39
|
+
window.clearTimeout(timer.current);
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
const copy = async () => {
|
|
44
|
+
try {
|
|
45
|
+
await navigator.clipboard.writeText(source);
|
|
46
|
+
setState("copied");
|
|
47
|
+
} catch {
|
|
48
|
+
setState("failed");
|
|
49
|
+
}
|
|
50
|
+
if (!alive.current) return;
|
|
51
|
+
window.clearTimeout(timer.current);
|
|
52
|
+
timer.current = window.setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
className="diagram-copy"
|
|
59
|
+
data-state={state}
|
|
60
|
+
title={LABEL[state]}
|
|
61
|
+
aria-label={LABEL[state]}
|
|
62
|
+
onClick={() => void copy()}
|
|
63
|
+
>
|
|
64
|
+
<MenuIcon name={state === "copied" ? "check" : "copy"} />
|
|
65
|
+
</button>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
* @param children — the heading.
|
|
54
|
+
* @param direction — how this column is currently sorted, or
|
|
55
|
+
* `undefined` when the table is sorted by another column.
|
|
56
|
+
* @param onSort — asked to sort by this column; it gets the direction
|
|
57
|
+
* to go to.
|
|
58
|
+
* @param numeric — right-align the column and use tabular figures.
|
|
59
|
+
* @param className — added to the element's classes, beside the one the
|
|
60
|
+
* theme gives it.
|
|
61
|
+
* @param rest — the remaining props, spread onto the `th`.
|
|
62
|
+
*/
|
|
63
|
+
export function SortableTh({
|
|
64
|
+
children,
|
|
65
|
+
direction,
|
|
66
|
+
onSort,
|
|
67
|
+
numeric = false,
|
|
68
|
+
className,
|
|
69
|
+
...rest
|
|
70
|
+
}: SortableThProps) {
|
|
71
|
+
// Clicking the sorted column reverses it; clicking any other
|
|
72
|
+
// column starts ascending. Starting descending is defensible for
|
|
73
|
+
// dates and wrong for everything else, so the caller re-sorts if
|
|
74
|
+
// it wants that.
|
|
75
|
+
const next: SortDirection = direction === "ascending" ? "descending" : "ascending";
|
|
76
|
+
return (
|
|
77
|
+
<th
|
|
78
|
+
{...rest}
|
|
79
|
+
scope="col"
|
|
80
|
+
aria-sort={direction ?? "none"}
|
|
81
|
+
className={cx(numeric && "ui-num", className)}
|
|
82
|
+
>
|
|
83
|
+
<button type="button" className="ui-th-sort" onClick={() => onSort(next)}>
|
|
84
|
+
{children}
|
|
85
|
+
<span className="ui-th-arrow" aria-hidden="true">
|
|
86
|
+
{direction === "descending" ? "▾" : "▴"}
|
|
87
|
+
</span>
|
|
88
|
+
</button>
|
|
89
|
+
</th>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** What a {@link Status} takes. */
|
|
94
|
+
export interface StatusProps {
|
|
95
|
+
/** The four states the health contract defines. */
|
|
96
|
+
state: "READY" | "PREPARING" | "DISABLED" | "FAILED";
|
|
97
|
+
/**
|
|
98
|
+
* What to show beside the dot. Defaults to the state itself.
|
|
99
|
+
*
|
|
100
|
+
* There is always a word. The dot is a colour, and a colour on its
|
|
101
|
+
* own is not a message — it says nothing when read aloud and
|
|
102
|
+
* nothing to somebody who cannot tell green from amber.
|
|
103
|
+
*/
|
|
104
|
+
children?: ReactNode;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A state, as a coloured dot and the word it stands for.
|
|
109
|
+
*
|
|
110
|
+
* @param state — the four states the health contract defines.
|
|
111
|
+
* @param children — what to show beside the dot; it defaults to the
|
|
112
|
+
* state itself.
|
|
113
|
+
*/
|
|
114
|
+
export function Status({ state, children }: StatusProps) {
|
|
115
|
+
return (
|
|
116
|
+
<span className="ui-status" data-state={state}>
|
|
117
|
+
{children ?? state}
|
|
118
|
+
</span>
|
|
119
|
+
);
|
|
120
|
+
}
|