@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.
Files changed (127) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +56 -13
  3. package/dist/CopySource.d.ts.map +1 -1
  4. package/dist/CopySource.js +16 -2
  5. package/dist/CopySource.js.map +1 -1
  6. package/dist/DataTable.d.ts +17 -1
  7. package/dist/DataTable.d.ts.map +1 -1
  8. package/dist/DataTable.js +17 -1
  9. package/dist/DataTable.js.map +1 -1
  10. package/dist/Dialog.d.ts +41 -0
  11. package/dist/Dialog.d.ts.map +1 -0
  12. package/dist/Dialog.js +94 -0
  13. package/dist/Dialog.js.map +1 -0
  14. package/dist/ErrorBoundary.d.ts +31 -2
  15. package/dist/ErrorBoundary.d.ts.map +1 -1
  16. package/dist/ErrorBoundary.js +38 -4
  17. package/dist/ErrorBoundary.js.map +1 -1
  18. package/dist/LiveRegion.d.ts +7 -1
  19. package/dist/LiveRegion.d.ts.map +1 -1
  20. package/dist/LiveRegion.js +7 -1
  21. package/dist/LiveRegion.js.map +1 -1
  22. package/dist/Markdown.d.ts +4 -0
  23. package/dist/Markdown.d.ts.map +1 -1
  24. package/dist/Markdown.js +4 -0
  25. package/dist/Markdown.js.map +1 -1
  26. package/dist/MarkdownInline.d.ts +13 -4
  27. package/dist/MarkdownInline.d.ts.map +1 -1
  28. package/dist/MarkdownInline.js +20 -5
  29. package/dist/MarkdownInline.js.map +1 -1
  30. package/dist/MenuIcon.d.ts +10 -4
  31. package/dist/MenuIcon.d.ts.map +1 -1
  32. package/dist/MenuIcon.js +8 -2
  33. package/dist/MenuIcon.js.map +1 -1
  34. package/dist/Mermaid.d.ts +2 -0
  35. package/dist/Mermaid.d.ts.map +1 -1
  36. package/dist/Mermaid.js +2 -0
  37. package/dist/Mermaid.js.map +1 -1
  38. package/dist/Monogram.d.ts +7 -3
  39. package/dist/Monogram.d.ts.map +1 -1
  40. package/dist/Monogram.js +14 -6
  41. package/dist/Monogram.js.map +1 -1
  42. package/dist/OverflowMenu.d.ts +6 -1
  43. package/dist/OverflowMenu.d.ts.map +1 -1
  44. package/dist/OverflowMenu.js +10 -2
  45. package/dist/OverflowMenu.js.map +1 -1
  46. package/dist/Shell.d.ts +13 -0
  47. package/dist/Shell.d.ts.map +1 -1
  48. package/dist/Shell.js +13 -0
  49. package/dist/Shell.js.map +1 -1
  50. package/dist/Skeleton.d.ts +30 -0
  51. package/dist/Skeleton.d.ts.map +1 -1
  52. package/dist/Skeleton.js +30 -0
  53. package/dist/Skeleton.js.map +1 -1
  54. package/dist/Split.d.ts +24 -5
  55. package/dist/Split.d.ts.map +1 -1
  56. package/dist/Split.js +27 -4
  57. package/dist/Split.js.map +1 -1
  58. package/dist/Tabs.d.ts +77 -0
  59. package/dist/Tabs.d.ts.map +1 -0
  60. package/dist/Tabs.js +91 -0
  61. package/dist/Tabs.js.map +1 -0
  62. package/dist/Toast.d.ts +12 -1
  63. package/dist/Toast.d.ts.map +1 -1
  64. package/dist/Toast.js +11 -0
  65. package/dist/Toast.js.map +1 -1
  66. package/dist/Tooltip.d.ts +12 -3
  67. package/dist/Tooltip.d.ts.map +1 -1
  68. package/dist/Tooltip.js +29 -7
  69. package/dist/Tooltip.js.map +1 -1
  70. package/dist/controls.d.ts +117 -0
  71. package/dist/controls.d.ts.map +1 -0
  72. package/dist/controls.js +59 -0
  73. package/dist/controls.js.map +1 -0
  74. package/dist/fenceInfo.d.ts +4 -1
  75. package/dist/fenceInfo.d.ts.map +1 -1
  76. package/dist/fenceInfo.js +4 -1
  77. package/dist/fenceInfo.js.map +1 -1
  78. package/dist/formControls.d.ts +143 -0
  79. package/dist/formControls.d.ts.map +1 -0
  80. package/dist/formControls.js +108 -0
  81. package/dist/formControls.js.map +1 -0
  82. package/dist/index.d.ts +5 -9
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +5 -9
  85. package/dist/index.js.map +1 -1
  86. package/dist/layout.d.ts +95 -0
  87. package/dist/layout.d.ts.map +1 -0
  88. package/dist/layout.js +93 -0
  89. package/dist/layout.js.map +1 -0
  90. package/dist/primitives.d.ts +10 -360
  91. package/dist/primitives.d.ts.map +1 -1
  92. package/dist/primitives.js +31 -338
  93. package/dist/primitives.js.map +1 -1
  94. package/dist/progress.d.ts +64 -0
  95. package/dist/progress.d.ts.map +1 -0
  96. package/dist/progress.js +51 -0
  97. package/dist/progress.js.map +1 -0
  98. package/dist/text.d.ts +63 -0
  99. package/dist/text.d.ts.map +1 -0
  100. package/dist/text.js +61 -0
  101. package/dist/text.js.map +1 -0
  102. package/package.json +4 -4
  103. package/src/CopySource.tsx +17 -2
  104. package/src/DataTable.tsx +17 -1
  105. package/src/Dialog.tsx +158 -0
  106. package/src/ErrorBoundary.tsx +39 -4
  107. package/src/LiveRegion.tsx +7 -1
  108. package/src/Markdown.tsx +4 -0
  109. package/src/MarkdownInline.tsx +20 -7
  110. package/src/MenuIcon.tsx +10 -4
  111. package/src/Mermaid.tsx +2 -0
  112. package/src/Monogram.tsx +14 -5
  113. package/src/OverflowMenu.tsx +9 -2
  114. package/src/Shell.tsx +13 -0
  115. package/src/Skeleton.tsx +30 -0
  116. package/src/Split.tsx +32 -7
  117. package/src/Tabs.tsx +194 -0
  118. package/src/Toast.tsx +12 -1
  119. package/src/Tooltip.tsx +33 -8
  120. package/src/controls.tsx +159 -0
  121. package/src/fenceInfo.ts +5 -2
  122. package/src/formControls.tsx +249 -0
  123. package/src/index.ts +5 -9
  124. package/src/layout.tsx +141 -0
  125. package/src/primitives.tsx +10 -864
  126. package/src/progress.tsx +129 -0
  127. package/src/text.tsx +99 -0
@@ -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
+ }