@itwin/itwinui-react 5.0.0-alpha.1 → 5.0.0-alpha.11

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 (116) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +6 -6
  4. package/dist/DEV/bricks/Anchor.js +5 -10
  5. package/dist/DEV/bricks/Avatar.js +24 -0
  6. package/dist/DEV/bricks/Badge.js +22 -0
  7. package/dist/DEV/bricks/Button.js +11 -4
  8. package/dist/DEV/bricks/Checkbox.js +17 -9
  9. package/dist/DEV/bricks/Chip.js +42 -0
  10. package/dist/DEV/bricks/Description.js +29 -0
  11. package/dist/DEV/bricks/Divider.js +3 -2
  12. package/dist/DEV/bricks/DropdownMenu.js +109 -30
  13. package/dist/DEV/bricks/Field.js +115 -14
  14. package/dist/DEV/bricks/Icon.js +177 -10
  15. package/dist/DEV/bricks/IconButton.js +14 -3
  16. package/dist/DEV/bricks/Kbd.internal.js +19 -0
  17. package/dist/DEV/bricks/Kbd.js +23 -6
  18. package/dist/DEV/bricks/Label.js +11 -8
  19. package/dist/DEV/bricks/ProgressBar.js +25 -0
  20. package/dist/DEV/bricks/Radio.js +17 -9
  21. package/dist/DEV/bricks/Root.internal.js +17 -0
  22. package/dist/DEV/bricks/Root.js +103 -26
  23. package/dist/DEV/bricks/Select.js +17 -11
  24. package/dist/DEV/bricks/Skeleton.js +24 -0
  25. package/dist/DEV/bricks/Spinner.js +55 -0
  26. package/dist/DEV/bricks/Switch.js +18 -10
  27. package/dist/DEV/bricks/Table.js +114 -0
  28. package/dist/DEV/bricks/Tabs.js +6 -6
  29. package/dist/DEV/bricks/Text.js +2 -2
  30. package/dist/DEV/bricks/TextBox.js +54 -16
  31. package/dist/DEV/bricks/Tooltip.js +17 -25
  32. package/dist/DEV/bricks/Tree.js +15 -107
  33. package/dist/DEV/bricks/TreeItem.js +227 -0
  34. package/dist/DEV/bricks/VisuallyHidden.js +2 -2
  35. package/dist/DEV/bricks/index.js +16 -0
  36. package/dist/DEV/bricks/styles.css.js +2 -2
  37. package/dist/DEV/bricks/~hooks.js +57 -3
  38. package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
  39. package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +19 -3
  40. package/dist/DEV/bricks/~utils.js +17 -0
  41. package/dist/DEV/foundations/styles.css.js +2 -2
  42. package/dist/bricks/Anchor.js +5 -10
  43. package/dist/bricks/Avatar.d.ts +47 -0
  44. package/dist/bricks/Avatar.js +23 -0
  45. package/dist/bricks/Badge.d.ts +28 -0
  46. package/dist/bricks/Badge.js +21 -0
  47. package/dist/bricks/Button.js +11 -4
  48. package/dist/bricks/Checkbox.d.ts +2 -2
  49. package/dist/bricks/Checkbox.js +17 -9
  50. package/dist/bricks/Chip.d.ts +31 -0
  51. package/dist/bricks/Chip.js +41 -0
  52. package/dist/bricks/Description.d.ts +19 -0
  53. package/dist/bricks/Description.js +29 -0
  54. package/dist/bricks/Divider.d.ts +2 -2
  55. package/dist/bricks/Divider.js +3 -2
  56. package/dist/bricks/DropdownMenu.d.ts +41 -14
  57. package/dist/bricks/DropdownMenu.js +106 -30
  58. package/dist/bricks/Field.d.ts +23 -1
  59. package/dist/bricks/Field.js +115 -14
  60. package/dist/bricks/Icon.d.ts +43 -4
  61. package/dist/bricks/Icon.js +174 -10
  62. package/dist/bricks/IconButton.d.ts +20 -4
  63. package/dist/bricks/IconButton.js +14 -3
  64. package/dist/bricks/Kbd.d.ts +15 -0
  65. package/dist/bricks/Kbd.internal.d.ts +17 -0
  66. package/dist/bricks/Kbd.internal.js +19 -0
  67. package/dist/bricks/Kbd.js +16 -6
  68. package/dist/bricks/Label.js +11 -8
  69. package/dist/bricks/ProgressBar.d.ts +31 -0
  70. package/dist/bricks/ProgressBar.js +24 -0
  71. package/dist/bricks/Radio.d.ts +2 -2
  72. package/dist/bricks/Radio.js +17 -9
  73. package/dist/bricks/Root.d.ts +12 -0
  74. package/dist/bricks/Root.internal.d.ts +6 -0
  75. package/dist/bricks/Root.internal.js +17 -0
  76. package/dist/bricks/Root.js +103 -26
  77. package/dist/bricks/Select.d.ts +9 -3
  78. package/dist/bricks/Select.js +17 -11
  79. package/dist/bricks/Skeleton.d.ts +25 -0
  80. package/dist/bricks/Skeleton.js +23 -0
  81. package/dist/bricks/Spinner.d.ts +31 -0
  82. package/dist/bricks/Spinner.js +54 -0
  83. package/dist/bricks/Switch.d.ts +2 -2
  84. package/dist/bricks/Switch.js +18 -10
  85. package/dist/bricks/Table.d.ts +115 -0
  86. package/dist/bricks/Table.js +108 -0
  87. package/dist/bricks/Tabs.d.ts +4 -4
  88. package/dist/bricks/Tabs.js +6 -6
  89. package/dist/bricks/Text.d.ts +1 -1
  90. package/dist/bricks/Text.js +2 -2
  91. package/dist/bricks/TextBox.d.ts +23 -2
  92. package/dist/bricks/TextBox.js +53 -16
  93. package/dist/bricks/Tooltip.d.ts +2 -2
  94. package/dist/bricks/Tooltip.js +17 -25
  95. package/dist/bricks/Tree.d.ts +19 -20
  96. package/dist/bricks/Tree.js +14 -102
  97. package/dist/bricks/TreeItem.d.ts +129 -0
  98. package/dist/bricks/TreeItem.js +222 -0
  99. package/dist/bricks/VisuallyHidden.js +2 -2
  100. package/dist/bricks/index.d.ts +8 -0
  101. package/dist/bricks/index.js +16 -0
  102. package/dist/bricks/styles.css.js +2 -2
  103. package/dist/bricks/~hooks.d.ts +63 -0
  104. package/dist/bricks/~hooks.js +57 -3
  105. package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
  106. package/dist/bricks/~utils.GhostAligner.js +13 -0
  107. package/dist/bricks/~utils.ListItem.d.ts +14 -0
  108. package/dist/bricks/{ListItem.js → ~utils.ListItem.js} +18 -3
  109. package/dist/bricks/~utils.d.ts +14 -3
  110. package/dist/bricks/~utils.js +17 -0
  111. package/dist/foundations/styles.css.js +2 -2
  112. package/package.json +14 -13
  113. package/dist/DEV/bricks/Textarea.js +0 -30
  114. package/dist/bricks/ListItem.d.ts +0 -10
  115. package/dist/bricks/Textarea.d.ts +0 -24
  116. package/dist/bricks/Textarea.js +0 -29
@@ -1,27 +1,128 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import * as Ariakit from "@ariakit/react";
4
3
  import cx from "classnames";
4
+ import { Role } from "@ariakit/react/role";
5
+ import {
6
+ useCollectionStore,
7
+ Collection,
8
+ useCollectionContext,
9
+ CollectionItem
10
+ } from "@ariakit/react/collection";
11
+ import { useStoreState } from "@ariakit/react/store";
5
12
  import { forwardRef } from "./~utils.js";
6
13
  const Field = forwardRef((props, forwardedRef) => {
7
- const fieldId = React.useId();
8
- const { className, layout, ...rest } = props;
9
- return /* @__PURE__ */ jsx(FieldIdContext.Provider, { value: fieldId, children: /* @__PURE__ */ jsx(
10
- Ariakit.Role,
14
+ const { layout, ...rest } = props;
15
+ return /* @__PURE__ */ jsx(
16
+ FieldCollection,
11
17
  {
12
- ...rest,
13
- className: cx("\u{1F95D}-field", className),
14
- "data-kiwi-layout": layout,
15
- ref: forwardedRef
18
+ render: /* @__PURE__ */ jsx(
19
+ Role.div,
20
+ {
21
+ ...rest,
22
+ className: cx("\u{1F95D}-field", props.className),
23
+ "data-kiwi-layout": layout,
24
+ ref: forwardedRef
25
+ }
26
+ )
16
27
  }
17
- ) });
28
+ );
18
29
  });
19
30
  DEV: Field.displayName = "Field";
20
- const FieldIdContext = React.createContext(void 0);
21
- function useFieldId() {
22
- return React.useContext(FieldIdContext);
31
+ function FieldCollection(props) {
32
+ const fieldElementCollection = useCollectionStore({
33
+ defaultItems: []
34
+ });
35
+ const renderedItems = useStoreState(fieldElementCollection, "renderedItems");
36
+ const [controlType, controlIndex] = React.useMemo(() => {
37
+ const controlIndex2 = renderedItems.findIndex(
38
+ (item) => item.elementType === "control"
39
+ );
40
+ return [renderedItems[controlIndex2]?.controlType, controlIndex2];
41
+ }, [renderedItems]);
42
+ const labelPlacement = React.useMemo(() => {
43
+ const labelIndex = renderedItems.findIndex(
44
+ (item) => item.elementType === "label"
45
+ );
46
+ if (controlIndex === -1 || labelIndex === -1) return;
47
+ return labelIndex < controlIndex ? "before" : "after";
48
+ }, [renderedItems, controlIndex]);
49
+ return /* @__PURE__ */ jsx(
50
+ Collection,
51
+ {
52
+ ...props,
53
+ store: fieldElementCollection,
54
+ "data-kiwi-label-placement": labelPlacement,
55
+ "data-kiwi-control-type": controlType
56
+ }
57
+ );
58
+ }
59
+ function FieldControl(props) {
60
+ const store = useCollectionContext();
61
+ const generatedId = React.useId();
62
+ const { id = store ? generatedId : void 0, type, ...rest } = props;
63
+ const renderedItems = useStoreState(store, "renderedItems");
64
+ const describedBy = React.useMemo(() => {
65
+ const idRefList = renderedItems?.filter(
66
+ (item) => item.elementType === "description"
67
+ )?.map((item) => item.id).join(" ");
68
+ return idRefList || void 0;
69
+ }, [renderedItems]);
70
+ const getData = React.useCallback(
71
+ (data) => ({
72
+ ...data,
73
+ elementType: "control",
74
+ controlType: type
75
+ }),
76
+ [type]
77
+ );
78
+ return /* @__PURE__ */ jsx(
79
+ CollectionItem,
80
+ {
81
+ id,
82
+ getItem: getData,
83
+ render: /* @__PURE__ */ jsx(Role, { ...rest, "aria-describedby": describedBy })
84
+ }
85
+ );
86
+ }
87
+ function FieldLabel(props) {
88
+ const store = useCollectionContext();
89
+ const renderedItems = useStoreState(store, "renderedItems");
90
+ const fieldId = React.useMemo(
91
+ () => renderedItems?.find(
92
+ (item) => item.elementType === "control"
93
+ )?.id,
94
+ [renderedItems]
95
+ );
96
+ const getData = React.useCallback(
97
+ (data) => ({
98
+ ...data,
99
+ elementType: "label"
100
+ }),
101
+ []
102
+ );
103
+ return /* @__PURE__ */ jsx(
104
+ CollectionItem,
105
+ {
106
+ getItem: getData,
107
+ render: /* @__PURE__ */ jsx(Role.label, { ...props, htmlFor: fieldId })
108
+ }
109
+ );
110
+ }
111
+ function FieldDescription(props) {
112
+ const generatedId = React.useId();
113
+ const { id = generatedId, ...rest } = props;
114
+ const getData = React.useCallback(
115
+ (data) => ({
116
+ ...data,
117
+ elementType: "description"
118
+ }),
119
+ []
120
+ );
121
+ return /* @__PURE__ */ jsx(CollectionItem, { ...rest, id, getItem: getData });
23
122
  }
24
123
  export {
25
124
  Field,
26
- useFieldId
125
+ FieldControl,
126
+ FieldDescription,
127
+ FieldLabel
27
128
  };
@@ -1,28 +1,108 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- import { forwardRef } from "./~utils.js";
4
+ import { Role } from "@ariakit/react/role";
5
+ import {
6
+ forwardRef,
7
+ getOwnerDocument,
8
+ parseDOM
9
+ } from "./~utils.js";
10
+ import {
11
+ HtmlSanitizerContext,
12
+ spriteSheetId,
13
+ useRootNode
14
+ } from "./Root.internal.js";
15
+ import { useLatestRef, useSafeContext } from "./~hooks.js";
6
16
  const Icon = forwardRef((props, forwardedRef) => {
7
- const { href, size = "regular", ...rest } = props;
8
- const iconId = toIconId(size);
17
+ const { href: hrefProp, size, alt, ...rest } = props;
18
+ const isDecorative = !alt;
19
+ const hrefBase = useNormalizedHrefBase(hrefProp);
9
20
  return /* @__PURE__ */ jsx(
10
- Ariakit.Role.svg,
21
+ Role.svg,
11
22
  {
12
- "data-kiwi-size": size,
13
- "aria-hidden": true,
23
+ "aria-hidden": isDecorative ? "true" : void 0,
24
+ role: isDecorative ? void 0 : "img",
25
+ "aria-label": isDecorative ? void 0 : alt,
14
26
  ...rest,
27
+ "data-kiwi-size": size,
15
28
  className: cx("\u{1F95D}-icon", props.className),
16
29
  ref: forwardedRef,
17
- children: /* @__PURE__ */ jsx("use", { href: `${props.href}#${iconId}` })
30
+ children: hrefBase ? /* @__PURE__ */ jsx("use", { href: toIconHref(hrefBase, size) }) : null
18
31
  }
19
32
  );
20
33
  });
21
34
  DEV: Icon.displayName = "Icon";
35
+ function toIconHref(hrefBase, size) {
36
+ const separator = hrefBase.includes("#") ? "--" : "#";
37
+ const suffix = toIconId(size);
38
+ return `${hrefBase}${separator}${suffix}`;
39
+ }
22
40
  function toIconId(size) {
23
41
  if (size === "large") return "icon-large";
24
42
  return "icon";
25
43
  }
44
+ function useNormalizedHrefBase(rawHref) {
45
+ const generatedId = React.useId();
46
+ const sanitizeHtml = useLatestRef(useSafeContext(HtmlSanitizerContext));
47
+ const rootNode = useRootNode();
48
+ const inlineHref = React.useRef(void 0);
49
+ const getClientSnapshot = () => {
50
+ const ownerDocument = getOwnerDocument(rootNode);
51
+ if (!rawHref || !ownerDocument) return void 0;
52
+ if (isHttpProtocol(rawHref, ownerDocument)) return rawHref;
53
+ return inlineHref.current;
54
+ };
55
+ const subscribe = React.useCallback(
56
+ (notify) => {
57
+ const ownerDocument = getOwnerDocument(rootNode);
58
+ const spriteSheet = ownerDocument?.getElementById(spriteSheetId);
59
+ if (!rawHref || !ownerDocument || !spriteSheet) return () => {
60
+ };
61
+ if (isHttpProtocol(rawHref, ownerDocument)) return () => {
62
+ };
63
+ const cache = spriteSheet[Symbol.for("\u{1F95D}")]?.icons;
64
+ if (!cache) return () => {
65
+ };
66
+ const prefix = `\u{1F95D}${generatedId}`;
67
+ if (cache.has(rawHref)) {
68
+ inlineHref.current = cache.get(rawHref);
69
+ notify();
70
+ return () => {
71
+ };
72
+ }
73
+ const abortController = new AbortController();
74
+ const { signal } = abortController;
75
+ (async () => {
76
+ const response = await fetch(rawHref, { signal });
77
+ if (!response.ok) throw new Error(`Failed to fetch ${rawHref}`);
78
+ const fetchedSvgString = sanitizeHtml.current(await response.text());
79
+ const parsedSvgContent = parseDOM(fetchedSvgString, {
80
+ ownerDocument
81
+ });
82
+ const symbols = parsedSvgContent.querySelectorAll("symbol");
83
+ for (const symbol of symbols) {
84
+ symbol.id = `${prefix}--${symbol.id}`;
85
+ if (ownerDocument.getElementById(symbol.id)) continue;
86
+ spriteSheet.appendChild(symbol.cloneNode(true));
87
+ }
88
+ inlineHref.current = `#${prefix}`;
89
+ cache.set(rawHref, inlineHref.current);
90
+ if (!signal.aborted) notify();
91
+ })();
92
+ return () => abortController.abort();
93
+ },
94
+ [rawHref, rootNode, sanitizeHtml, generatedId]
95
+ );
96
+ return React.useSyncExternalStore(
97
+ subscribe,
98
+ getClientSnapshot,
99
+ () => rawHref
100
+ );
101
+ }
102
+ function isHttpProtocol(url, ownerDocument) {
103
+ const { protocol } = new URL(url, ownerDocument.baseURI);
104
+ return ["http:", "https:"].includes(protocol);
105
+ }
26
106
  const DisclosureArrow = forwardRef(
27
107
  (props, forwardedRef) => {
28
108
  const { direction = "down", ...rest } = props;
@@ -39,7 +119,7 @@ const DisclosureArrow = forwardRef(
39
119
  {
40
120
  ...rest,
41
121
  render: /* @__PURE__ */ jsx(
42
- Ariakit.Role.svg,
122
+ Role.svg,
43
123
  {
44
124
  width: "16",
45
125
  height: "16",
@@ -56,7 +136,94 @@ const DisclosureArrow = forwardRef(
56
136
  }
57
137
  );
58
138
  DEV: DisclosureArrow.displayName = "DisclosureArrow";
139
+ const Checkmark = forwardRef(
140
+ (props, forwardedRef) => {
141
+ return /* @__PURE__ */ jsx(
142
+ Icon,
143
+ {
144
+ ...props,
145
+ render: /* @__PURE__ */ jsx(
146
+ Role.svg,
147
+ {
148
+ width: "16",
149
+ height: "16",
150
+ fill: "currentColor",
151
+ viewBox: "0 0 16 16",
152
+ render: props.render,
153
+ children: /* @__PURE__ */ jsx(
154
+ "path",
155
+ {
156
+ fillRule: "evenodd",
157
+ d: "M13.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3-3a.5.5 0 1 1 .708-.708L6.5 10.793l6.646-6.647a.5.5 0 0 1 .708 0Z",
158
+ clipRule: "evenodd"
159
+ }
160
+ )
161
+ }
162
+ ),
163
+ ref: forwardedRef
164
+ }
165
+ );
166
+ }
167
+ );
168
+ DEV: Checkmark.displayName = "Checkmark";
169
+ const Dismiss = forwardRef(
170
+ (props, forwardedRef) => {
171
+ return /* @__PURE__ */ jsx(
172
+ Icon,
173
+ {
174
+ ...props,
175
+ render: /* @__PURE__ */ jsx(
176
+ Role.svg,
177
+ {
178
+ width: "16",
179
+ height: "16",
180
+ viewBox: "0 0 16 16",
181
+ fill: "currentColor",
182
+ render: props.render,
183
+ children: /* @__PURE__ */ jsx("path", { d: "M4.853 4.146a.5.5 0 1 0-.707.708L7.293 8l-3.147 3.146a.5.5 0 0 0 .707.708L8 8.707l3.146 3.147a.5.5 0 0 0 .707-.708L8.707 8l3.146-3.146a.5.5 0 1 0-.707-.708L8 7.293 4.853 4.146Z" })
184
+ }
185
+ ),
186
+ ref: forwardedRef
187
+ }
188
+ );
189
+ }
190
+ );
191
+ DEV: Dismiss.displayName = "Dismiss";
192
+ const StatusWarning = forwardRef(
193
+ (props, forwardedRef) => {
194
+ return /* @__PURE__ */ jsx(
195
+ Icon,
196
+ {
197
+ ...props,
198
+ render: /* @__PURE__ */ jsx(
199
+ Role.svg,
200
+ {
201
+ width: "16",
202
+ height: "16",
203
+ fill: "currentColor",
204
+ viewBox: "0 0 16 16",
205
+ render: props.render,
206
+ children: /* @__PURE__ */ jsx(
207
+ "path",
208
+ {
209
+ fill: "currentColor",
210
+ fillRule: "evenodd",
211
+ d: "M8.354 2.06a.5.5 0 0 0-.708 0L2.061 7.647a.5.5 0 0 0 0 .707l5.585 5.586a.5.5 0 0 0 .708 0l5.585-5.586a.5.5 0 0 0 0-.707L8.354 2.061Zm-1.415-.707a1.5 1.5 0 0 1 2.122 0l5.585 5.586a1.5 1.5 0 0 1 0 2.122l-5.585 5.585a1.5 1.5 0 0 1-2.122 0L1.354 9.061a1.5 1.5 0 0 1 0-2.122l5.585-5.586ZM8.75 10.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM8.5 8.5v-3a.5.5 0 0 0-1 0v3a.5.5 0 0 0 1 0Z",
212
+ clipRule: "evenodd"
213
+ }
214
+ )
215
+ }
216
+ ),
217
+ ref: forwardedRef
218
+ }
219
+ );
220
+ }
221
+ );
222
+ DEV: StatusWarning.displayName = "StatusWarning";
59
223
  export {
224
+ Checkmark,
60
225
  DisclosureArrow,
61
- Icon
226
+ Dismiss,
227
+ Icon,
228
+ StatusWarning
62
229
  };
@@ -1,5 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
2
3
  import cx from "classnames";
4
+ import { useToolbarContext, ToolbarItem } from "@ariakit/react/toolbar";
3
5
  import { Button } from "./Button.js";
4
6
  import { VisuallyHidden } from "./VisuallyHidden.js";
5
7
  import { Icon } from "./Icon.js";
@@ -7,17 +9,26 @@ import { Tooltip } from "./Tooltip.js";
7
9
  import { forwardRef } from "./~utils.js";
8
10
  const IconButton = forwardRef(
9
11
  (props, forwardedRef) => {
10
- const { label, icon, isActive, labelVariant, ...rest } = props;
12
+ const { label, icon, isActive, labelVariant, dot, ...rest } = props;
13
+ const baseId = React.useId();
14
+ const labelId = `${baseId}-label`;
15
+ const dotId = `${baseId}-dot`;
16
+ const toolbar = useToolbarContext();
11
17
  const button = /* @__PURE__ */ jsxs(
12
18
  Button,
13
19
  {
14
20
  "aria-pressed": isActive,
21
+ "aria-labelledby": labelId,
22
+ "aria-describedby": dot ? dotId : void 0,
15
23
  ...rest,
24
+ "data-kiwi-dot": dot ? "true" : void 0,
25
+ render: toolbar ? /* @__PURE__ */ jsx(ToolbarItem, { render: props.render }) : props.render,
16
26
  className: cx("\u{1F95D}-icon-button", props.className),
17
27
  ref: forwardedRef,
18
28
  children: [
19
- /* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
20
- typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
29
+ /* @__PURE__ */ jsx(VisuallyHidden, { id: labelId, children: label }),
30
+ typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
31
+ dot ? /* @__PURE__ */ jsx(VisuallyHidden, { id: dotId, "aria-hidden": "true", children: dot }) : null
21
32
  ]
22
33
  }
23
34
  );
@@ -0,0 +1,19 @@
1
+ const predefinedSymbols = {
2
+ Backspace: "\u232B",
3
+ Command: "\u2318",
4
+ Control: "Ctrl",
5
+ Down: "\u2193",
6
+ Eject: "\u23CF",
7
+ Enter: "\u21B5",
8
+ Escape: "Esc",
9
+ Left: "\u2190",
10
+ Option: "\u2325",
11
+ Right: "\u2192",
12
+ Shift: "\u21E7",
13
+ Space: "\u2423",
14
+ Tab: "Tab",
15
+ Up: "\u2191"
16
+ };
17
+ export {
18
+ predefinedSymbols
19
+ };
@@ -1,17 +1,34 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
3
+ import { Role } from "@ariakit/react/role";
4
4
  import { forwardRef } from "./~utils.js";
5
+ import { VisuallyHidden } from "./VisuallyHidden.js";
6
+ import { predefinedSymbols } from "./Kbd.internal.js";
5
7
  const Kbd = forwardRef((props, forwardedRef) => {
6
- const { variant = "solid", ...rest } = props;
8
+ const { variant = "solid", symbol, children, ...rest } = props;
9
+ DEV: {
10
+ if (symbol && !(symbol in predefinedSymbols)) {
11
+ console.error(
12
+ `Kbd: Invalid symbol "${symbol}". Must be one of: ${Object.keys(predefinedSymbols).join(", ")}`
13
+ );
14
+ }
15
+ }
16
+ let content = children;
17
+ if (symbol) {
18
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: predefinedSymbols[symbol] }),
20
+ children || /* @__PURE__ */ jsx(VisuallyHidden, { children: symbol })
21
+ ] });
22
+ }
7
23
  return /* @__PURE__ */ jsx(
8
- Ariakit.Role,
24
+ Role,
9
25
  {
10
- "data-kiwi-variant": variant,
11
26
  ...rest,
27
+ "data-kiwi-variant": variant,
12
28
  className: cx("\u{1F95D}-kbd", props.className),
13
29
  render: props.render || /* @__PURE__ */ jsx("kbd", {}),
14
- ref: forwardedRef
30
+ ref: forwardedRef,
31
+ children: content
15
32
  }
16
33
  );
17
34
  });
@@ -1,17 +1,20 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
4
- import { useFieldId } from "./Field.js";
3
+ import { Role } from "@ariakit/react/role";
5
4
  import { forwardRef } from "./~utils.js";
5
+ import { FieldLabel } from "./Field.js";
6
6
  const Label = forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
8
7
  return /* @__PURE__ */ jsx(
9
- Ariakit.Role.label,
8
+ FieldLabel,
10
9
  {
11
- htmlFor: fieldId,
12
- ...props,
13
- className: cx("\u{1F95D}-label", props.className),
14
- ref: forwardedRef
10
+ render: /* @__PURE__ */ jsx(
11
+ Role.label,
12
+ {
13
+ ...props,
14
+ className: cx("\u{1F95D}-label", props.className),
15
+ ref: forwardedRef
16
+ }
17
+ )
15
18
  }
16
19
  );
17
20
  });
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Role } from "@ariakit/react/role";
3
+ import cx from "classnames";
4
+ import { forwardRef } from "./~utils.js";
5
+ const ProgressBar = forwardRef(
6
+ (props, forwardedRef) => {
7
+ const { size = "medium", tone = "neutral", ...rest } = props;
8
+ return /* @__PURE__ */ jsx(
9
+ Role,
10
+ {
11
+ role: "progressbar",
12
+ ...rest,
13
+ "data-kiwi-size": size,
14
+ "data-kiwi-tone": tone,
15
+ "data-kiwi-variant": "indeterminate",
16
+ className: cx("\u{1F95D}-progress-bar", props.className),
17
+ ref: forwardedRef
18
+ }
19
+ );
20
+ }
21
+ );
22
+ DEV: ProgressBar.displayName = "ProgressBar";
23
+ export {
24
+ ProgressBar
25
+ };
@@ -1,18 +1,26 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import cx from "classnames";
3
- import * as Ariakit from "@ariakit/react";
4
- import { useFieldId } from "./Field.js";
3
+ import {
4
+ Radio as AkRadio
5
+ } from "@ariakit/react/radio";
6
+ import { FieldControl } from "./Field.js";
5
7
  import { forwardRef } from "./~utils.js";
6
8
  const Radio = forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
9
+ const { id, ...rest } = props;
8
10
  return /* @__PURE__ */ jsx(
9
- Ariakit.Radio,
11
+ FieldControl,
10
12
  {
11
- accessibleWhenDisabled: true,
12
- id: fieldId,
13
- ...props,
14
- className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
15
- ref: forwardedRef
13
+ type: "checkable",
14
+ id,
15
+ render: /* @__PURE__ */ jsx(
16
+ AkRadio,
17
+ {
18
+ accessibleWhenDisabled: true,
19
+ ...rest,
20
+ className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
21
+ ref: forwardedRef
22
+ }
23
+ )
16
24
  }
17
25
  );
18
26
  });
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { useIsClient } from "./~hooks.js";
3
+ const RootNodeContext = React.createContext(null);
4
+ function useRootNode() {
5
+ const maybeRootNode = React.useContext(RootNodeContext);
6
+ const isClient = useIsClient();
7
+ if (!isClient) return void 0;
8
+ return maybeRootNode;
9
+ }
10
+ const spriteSheetId = "\u{1F95D}-inline-sprites";
11
+ const HtmlSanitizerContext = React.createContext(void 0);
12
+ export {
13
+ HtmlSanitizerContext,
14
+ RootNodeContext,
15
+ spriteSheetId,
16
+ useRootNode
17
+ };