@ignite-ember/ui-react 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +56 -13
- package/dist/CopySource.d.ts.map +1 -1
- package/dist/CopySource.js +16 -2
- package/dist/CopySource.js.map +1 -1
- package/dist/DataTable.d.ts +17 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +17 -1
- package/dist/DataTable.js.map +1 -1
- package/dist/Dialog.d.ts +41 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +94 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +31 -2
- package/dist/ErrorBoundary.d.ts.map +1 -1
- package/dist/ErrorBoundary.js +38 -4
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/LiveRegion.d.ts +7 -1
- package/dist/LiveRegion.d.ts.map +1 -1
- package/dist/LiveRegion.js +7 -1
- package/dist/LiveRegion.js.map +1 -1
- package/dist/Markdown.d.ts +4 -0
- package/dist/Markdown.d.ts.map +1 -1
- package/dist/Markdown.js +4 -0
- package/dist/Markdown.js.map +1 -1
- package/dist/MarkdownInline.d.ts +13 -4
- package/dist/MarkdownInline.d.ts.map +1 -1
- package/dist/MarkdownInline.js +20 -5
- package/dist/MarkdownInline.js.map +1 -1
- package/dist/MenuIcon.d.ts +10 -4
- package/dist/MenuIcon.d.ts.map +1 -1
- package/dist/MenuIcon.js +8 -2
- package/dist/MenuIcon.js.map +1 -1
- package/dist/Mermaid.d.ts +2 -0
- package/dist/Mermaid.d.ts.map +1 -1
- package/dist/Mermaid.js +2 -0
- package/dist/Mermaid.js.map +1 -1
- package/dist/Monogram.d.ts +7 -3
- package/dist/Monogram.d.ts.map +1 -1
- package/dist/Monogram.js +14 -6
- package/dist/Monogram.js.map +1 -1
- package/dist/OverflowMenu.d.ts +6 -1
- package/dist/OverflowMenu.d.ts.map +1 -1
- package/dist/OverflowMenu.js +10 -2
- package/dist/OverflowMenu.js.map +1 -1
- package/dist/Shell.d.ts +13 -0
- package/dist/Shell.d.ts.map +1 -1
- package/dist/Shell.js +13 -0
- package/dist/Shell.js.map +1 -1
- package/dist/Skeleton.d.ts +30 -0
- package/dist/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton.js +30 -0
- package/dist/Skeleton.js.map +1 -1
- package/dist/Split.d.ts +24 -5
- package/dist/Split.d.ts.map +1 -1
- package/dist/Split.js +27 -4
- package/dist/Split.js.map +1 -1
- package/dist/Tabs.d.ts +77 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +91 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Toast.d.ts +12 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +11 -0
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.d.ts +12 -3
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +29 -7
- package/dist/Tooltip.js.map +1 -1
- package/dist/controls.d.ts +117 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +59 -0
- package/dist/controls.js.map +1 -0
- package/dist/fenceInfo.d.ts +4 -1
- package/dist/fenceInfo.d.ts.map +1 -1
- package/dist/fenceInfo.js +4 -1
- package/dist/fenceInfo.js.map +1 -1
- package/dist/formControls.d.ts +143 -0
- package/dist/formControls.d.ts.map +1 -0
- package/dist/formControls.js +108 -0
- package/dist/formControls.js.map +1 -0
- package/dist/index.d.ts +5 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +95 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +93 -0
- package/dist/layout.js.map +1 -0
- package/dist/primitives.d.ts +10 -360
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +31 -338
- package/dist/primitives.js.map +1 -1
- package/dist/progress.d.ts +64 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +51 -0
- package/dist/progress.js.map +1 -0
- package/dist/text.d.ts +63 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +61 -0
- package/dist/text.js.map +1 -0
- package/package.json +4 -4
- package/src/CopySource.tsx +17 -2
- package/src/DataTable.tsx +17 -1
- package/src/Dialog.tsx +158 -0
- package/src/ErrorBoundary.tsx +39 -4
- package/src/LiveRegion.tsx +7 -1
- package/src/Markdown.tsx +4 -0
- package/src/MarkdownInline.tsx +20 -7
- package/src/MenuIcon.tsx +10 -4
- package/src/Mermaid.tsx +2 -0
- package/src/Monogram.tsx +14 -5
- package/src/OverflowMenu.tsx +9 -2
- package/src/Shell.tsx +13 -0
- package/src/Skeleton.tsx +30 -0
- package/src/Split.tsx +32 -7
- package/src/Tabs.tsx +194 -0
- package/src/Toast.tsx +12 -1
- package/src/Tooltip.tsx +33 -8
- package/src/controls.tsx +159 -0
- package/src/fenceInfo.ts +5 -2
- package/src/formControls.tsx +249 -0
- package/src/index.ts +5 -9
- package/src/layout.tsx +141 -0
- package/src/primitives.tsx +10 -864
- package/src/progress.tsx +129 -0
- package/src/text.tsx +99 -0
package/src/progress.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
|
|
9
|
+
import type { HTMLAttributes } from "react";
|
|
10
|
+
|
|
11
|
+
import { cx } from "./cx.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Work whose duration is unknown. `Skeleton` is for known shapes.
|
|
15
|
+
*
|
|
16
|
+
* `label` is required for the same reason `Progress.label` is: a
|
|
17
|
+
* `role="status"` with nothing in it gives a screen reader silence
|
|
18
|
+
* while a sighted user watches something spin.
|
|
19
|
+
*/
|
|
20
|
+
export interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
21
|
+
/** Required: a spinner with no name is a live region with nothing in it. */
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Work whose duration is unknown.
|
|
27
|
+
*
|
|
28
|
+
* See {@link SpinnerProps} for why `label` is required.
|
|
29
|
+
*
|
|
30
|
+
* @param label — required: a spinner with no name is a live region with
|
|
31
|
+
* nothing in it.
|
|
32
|
+
* @param className — added to the element's classes, beside the one the
|
|
33
|
+
* theme gives it.
|
|
34
|
+
* @param rest — the remaining props, spread onto the span.
|
|
35
|
+
*/
|
|
36
|
+
export function Spinner({ label, className, ...rest }: SpinnerProps) {
|
|
37
|
+
return (
|
|
38
|
+
<span
|
|
39
|
+
{...rest}
|
|
40
|
+
role="status"
|
|
41
|
+
aria-live="polite"
|
|
42
|
+
className={cx("ui-spinner", className)}
|
|
43
|
+
>
|
|
44
|
+
<span className="ui-visually-hidden">{label}</span>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** What a {@link Progress} takes. */
|
|
50
|
+
export interface ProgressProps extends HTMLAttributes<HTMLDivElement> {
|
|
51
|
+
/**
|
|
52
|
+
* How far along, against `max`. Omit for indeterminate, which
|
|
53
|
+
* slides rather than sits.
|
|
54
|
+
*
|
|
55
|
+
* A value against a max, as `<progress>` and the ARIA attributes
|
|
56
|
+
* take it, so `value={50}` means half way.
|
|
57
|
+
*/
|
|
58
|
+
value?: number;
|
|
59
|
+
/** Defaults to 100. */
|
|
60
|
+
max?: number;
|
|
61
|
+
/** Its name, for a screen reader. */
|
|
62
|
+
label: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Where a determinate bar stands: its clamped value and how full it is. */
|
|
66
|
+
interface Reading {
|
|
67
|
+
/** `value`, clamped to `0..max`. */
|
|
68
|
+
now: number;
|
|
69
|
+
/** How full the bar is, as a percentage. */
|
|
70
|
+
pct: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `value` measured against `max`, or `null` when there is nothing to
|
|
75
|
+
* measure and the bar is indeterminate.
|
|
76
|
+
*/
|
|
77
|
+
function measure(value: number | undefined, max: number): Reading | null {
|
|
78
|
+
// NaN is not a measurement: it reads as unknown, like no value.
|
|
79
|
+
if (typeof value !== "number" || Number.isNaN(value)) return null;
|
|
80
|
+
const now = Math.max(0, Math.min(max, value));
|
|
81
|
+
// A `max` of zero or less has nothing to measure against; an empty
|
|
82
|
+
// bar is honest where `0 / 0` would write "NaN%".
|
|
83
|
+
const pct = max > 0 ? (now / max) * 100 : 0;
|
|
84
|
+
return { now, pct };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A bar that fills.
|
|
89
|
+
*
|
|
90
|
+
* See {@link ProgressProps}. Without a `value` it slides, because a
|
|
91
|
+
* bar that sits still while unknown work is happening is a bar that
|
|
92
|
+
* looks broken.
|
|
93
|
+
*
|
|
94
|
+
* @param value — how far along, against `max`; omit it for
|
|
95
|
+
* indeterminate, which slides rather than sits.
|
|
96
|
+
* @param max — the value that counts as complete, against which `value`
|
|
97
|
+
* is measured; it defaults to 100.
|
|
98
|
+
* @param label — its name, for a screen reader.
|
|
99
|
+
* @param className — added to the element's classes, beside the one the
|
|
100
|
+
* theme gives it.
|
|
101
|
+
* @param rest — the remaining props, spread onto the element.
|
|
102
|
+
*/
|
|
103
|
+
export function Progress({
|
|
104
|
+
value,
|
|
105
|
+
max = 100,
|
|
106
|
+
label,
|
|
107
|
+
className,
|
|
108
|
+
...rest
|
|
109
|
+
}: ProgressProps) {
|
|
110
|
+
const reading = measure(value, max);
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
{...rest}
|
|
114
|
+
className={cx("ui-progress", className)}
|
|
115
|
+
role="progressbar"
|
|
116
|
+
aria-label={label}
|
|
117
|
+
aria-valuenow={reading?.now}
|
|
118
|
+
aria-valuemin={0}
|
|
119
|
+
aria-valuemax={max}
|
|
120
|
+
aria-valuetext={reading ? `${Math.round(reading.pct)}%` : undefined}
|
|
121
|
+
data-indeterminate={reading === null}
|
|
122
|
+
>
|
|
123
|
+
<div
|
|
124
|
+
className="ui-progress-fill"
|
|
125
|
+
style={reading ? { width: `${reading.pct}%` } : undefined}
|
|
126
|
+
/>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
package/src/text.tsx
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
|
|
8
|
+
import type { HTMLAttributes } from "react";
|
|
9
|
+
|
|
10
|
+
import { cx } from "./cx.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A horizontal rule.
|
|
14
|
+
*
|
|
15
|
+
* @param className — added to the element's classes, beside the one the
|
|
16
|
+
* theme gives it.
|
|
17
|
+
* @param rest — the remaining props, spread onto the rule.
|
|
18
|
+
*/
|
|
19
|
+
export function Divider({ className, ...rest }: HTMLAttributes<HTMLHRElement>) {
|
|
20
|
+
return <hr {...rest} className={cx("ui-divider", className)} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What a {@link Heading} takes. */
|
|
24
|
+
export interface HeadingProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
25
|
+
/** The outline level. Also picks the size, so they cannot disagree. */
|
|
26
|
+
level?: 1 | 2 | 3 | 4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const HEADING_SIZE = {
|
|
30
|
+
1: "var(--text-2xl)",
|
|
31
|
+
2: "var(--text-xl)",
|
|
32
|
+
3: "var(--text-lg)",
|
|
33
|
+
4: "var(--text-sm)",
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A heading, at the level you say.
|
|
38
|
+
*
|
|
39
|
+
* The size follows the level, so the outline and the type cannot
|
|
40
|
+
* disagree — which is the whole reason there is no `Title`.
|
|
41
|
+
*
|
|
42
|
+
* @param level — the outline level; it also picks the size, so the two
|
|
43
|
+
* cannot disagree.
|
|
44
|
+
* @param className — added to the element's classes, beside the one the
|
|
45
|
+
* theme gives it.
|
|
46
|
+
* @param style — the element's inline style, merged over the size the
|
|
47
|
+
* level picks.
|
|
48
|
+
* @param rest — the remaining props, spread onto the heading.
|
|
49
|
+
*/
|
|
50
|
+
export function Heading({
|
|
51
|
+
level = 2,
|
|
52
|
+
className,
|
|
53
|
+
style,
|
|
54
|
+
...rest
|
|
55
|
+
}: HeadingProps) {
|
|
56
|
+
const Tag = `h${level}` as "h1" | "h2" | "h3" | "h4";
|
|
57
|
+
return (
|
|
58
|
+
<Tag
|
|
59
|
+
{...rest}
|
|
60
|
+
className={cx("ui-heading", className)}
|
|
61
|
+
style={{ fontSize: HEADING_SIZE[level], ...style }}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** How loud. Not {@link Tone}: this is emphasis, not status. */
|
|
67
|
+
export type TextTone = "default" | "muted" | "faint";
|
|
68
|
+
|
|
69
|
+
/** What a {@link Text} takes. */
|
|
70
|
+
export interface TextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
71
|
+
/** How loud it is. */
|
|
72
|
+
tone?: TextTone;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A paragraph.
|
|
77
|
+
*
|
|
78
|
+
* {@link TextTone} says how loud it is — emphasis, not status. A
|
|
79
|
+
* status is a {@link Badge}.
|
|
80
|
+
*
|
|
81
|
+
* @param tone — how loud it is: emphasis rather than status.
|
|
82
|
+
* @param className — added to the element's classes, beside the one the
|
|
83
|
+
* theme gives it.
|
|
84
|
+
* @param rest — the remaining props, spread onto the paragraph.
|
|
85
|
+
*/
|
|
86
|
+
export function Text({ tone = "default", className, ...rest }: TextProps) {
|
|
87
|
+
return <p {...rest} data-tone={tone} className={cx("ui-text", className)} />;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Inline code: a name, a path, a flag.
|
|
92
|
+
*
|
|
93
|
+
* @param className — added to the element's classes, beside the one the
|
|
94
|
+
* theme gives it.
|
|
95
|
+
* @param rest — the remaining props, spread onto the element.
|
|
96
|
+
*/
|
|
97
|
+
export function Code({ className, ...rest }: HTMLAttributes<HTMLElement>) {
|
|
98
|
+
return <code {...rest} className={cx("ui-code", className)} />;
|
|
99
|
+
}
|