@astryxdesign/core 0.1.2-canary.bd8c3d3 → 0.1.2-canary.bfcbf64
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/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +11 -5
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +20 -4
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +11 -11
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +4 -2
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +12 -4
- package/dist/ContextMenu/ContextMenu.d.ts +6 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +58 -7
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +17 -2
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +9 -4
- package/dist/DateTimeInput/DateTimeInput.d.ts +7 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +15 -3
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +12 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +25 -4
- package/dist/Field/Field.d.ts +19 -2
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +4 -0
- package/dist/Field/FieldLabel.d.ts +21 -2
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +37 -22
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +27 -6
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +4 -1
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +33 -1
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +36 -5
- package/dist/Layout/padding.stylex.d.ts +51 -0
- package/dist/Layout/padding.stylex.d.ts.map +1 -1
- package/dist/Layout/padding.stylex.js +63 -0
- package/dist/Link/Link.d.ts +7 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +12 -4
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +35 -6
- package/dist/MultiSelector/hooks.d.ts +12 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +14 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenu.js +17 -2
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +7 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +8 -0
- package/dist/ProgressBar/ProgressBar.js +1 -1
- package/dist/RadioList/RadioList.d.ts +1 -1
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +76 -3
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +6 -2
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +15 -8
- package/dist/Selector/hooks.d.ts +8 -1
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +14 -1
- package/dist/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.js +8 -2
- package/dist/Stack/Stack.d.ts +28 -1
- package/dist/Stack/Stack.d.ts.map +1 -1
- package/dist/Stack/Stack.js +17 -1
- package/dist/Stack/StackItem.d.ts +12 -1
- package/dist/Stack/StackItem.d.ts.map +1 -1
- package/dist/Stack/StackItem.js +8 -1
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +6 -0
- package/dist/TabList/TabList.d.ts +15 -4
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +58 -4
- package/dist/TabList/TabListContext.d.ts +5 -0
- package/dist/TabList/TabListContext.d.ts.map +1 -1
- package/dist/TabList/TabListContext.js +5 -0
- package/dist/TabList/TabMenu.js +2 -0
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +14 -0
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +132 -3
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +7 -3
- package/dist/TreeList/TreeList.d.ts +1 -1
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +78 -2
- package/dist/TreeList/TreeListItem.d.ts +10 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +44 -10
- package/dist/TreeList/treeListItem.markers.stylex.d.ts +16 -0
- package/dist/TreeList/treeListItem.markers.stylex.d.ts.map +1 -0
- package/dist/TreeList/treeListItem.markers.stylex.js +22 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +41 -3
- package/dist/astryx.css +3 -0
- package/dist/astryx.umd.js +47 -47
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/index.d.ts +10 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +6 -2
- package/dist/hooks/useAnnounce.d.ts +40 -0
- package/dist/hooks/useAnnounce.d.ts.map +1 -0
- package/dist/hooks/useAnnounce.js +142 -0
- package/dist/hooks/useClickableContainer.d.ts +16 -1
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +16 -4
- package/dist/hooks/useFocusTrap.d.ts +18 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +65 -0
- package/dist/hooks/useListFocus.d.ts +79 -8
- package/dist/hooks/useListFocus.d.ts.map +1 -1
- package/dist/hooks/useListFocus.js +262 -48
- package/dist/hooks/useLongPress.d.ts +21 -0
- package/dist/hooks/useLongPress.d.ts.map +1 -0
- package/dist/hooks/useLongPress.js +89 -0
- package/dist/hooks/useTreeFocus.d.ts +133 -0
- package/dist/hooks/useTreeFocus.d.ts.map +1 -0
- package/dist/hooks/useTreeFocus.js +274 -0
- package/dist/hooks/useTypeahead.d.ts +63 -0
- package/dist/hooks/useTypeahead.d.ts.map +1 -0
- package/dist/hooks/useTypeahead.js +117 -0
- package/package.json +1 -1
- package/src/Avatar/Avatar.test.tsx +37 -0
- package/src/Avatar/Avatar.tsx +10 -5
- package/src/Breadcrumbs/BreadcrumbItem.tsx +20 -5
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +31 -10
- package/src/Calendar/Calendar.test.tsx +25 -0
- package/src/Calendar/Calendar.tsx +10 -12
- package/src/CheckboxInput/CheckboxInput.test.tsx +14 -25
- package/src/CheckboxInput/CheckboxInput.tsx +4 -2
- package/src/CheckboxList/CheckboxList.test.tsx +30 -14
- package/src/CheckboxList/CheckboxList.tsx +18 -3
- package/src/ContextMenu/ContextMenu.doc.mjs +6 -0
- package/src/ContextMenu/ContextMenu.test.tsx +115 -1
- package/src/ContextMenu/ContextMenu.tsx +75 -4
- package/src/DateInput/DateInput.test.tsx +59 -0
- package/src/DateInput/DateInput.tsx +24 -7
- package/src/DateRangeInput/DateRangeInput.test.tsx +69 -18
- package/src/DateRangeInput/DateRangeInput.tsx +7 -3
- package/src/DateTimeInput/DateTimeInput.doc.mjs +7 -0
- package/src/DateTimeInput/DateTimeInput.test.tsx +99 -6
- package/src/DateTimeInput/DateTimeInput.tsx +32 -3
- package/src/Dialog/Dialog.tsx +12 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +26 -4
- package/src/DropdownMenu/DropdownMenu.tsx +36 -2
- package/src/Field/Field.test.tsx +32 -0
- package/src/Field/Field.tsx +23 -5
- package/src/Field/FieldLabel.tsx +53 -17
- package/src/FileInput/FileInput.test.tsx +104 -49
- package/src/FileInput/FileInput.tsx +27 -3
- package/src/InputGroup/InputGroup.test.tsx +21 -63
- package/src/InputGroup/InputGroup.tsx +4 -1
- package/src/Kbd/Kbd.test.tsx +22 -4
- package/src/Kbd/Kbd.tsx +35 -3
- package/src/Layer/useLayer.tsx +52 -5
- package/src/Layout/padding.stylex.ts +52 -0
- package/src/Link/Link.doc.mjs +14 -0
- package/src/Link/Link.test.tsx +32 -0
- package/src/Link/Link.tsx +23 -1
- package/src/MultiSelector/MultiSelector.test.tsx +124 -2
- package/src/MultiSelector/MultiSelector.tsx +50 -9
- package/src/MultiSelector/hooks.ts +27 -0
- package/src/NavMenu/NavHeadingMenu.test.tsx +32 -1
- package/src/NavMenu/NavHeadingMenu.tsx +30 -2
- package/src/NumberInput/NumberInput.test.tsx +72 -38
- package/src/NumberInput/NumberInput.tsx +12 -1
- package/src/Pagination/Pagination.test.tsx +58 -5
- package/src/Pagination/Pagination.tsx +12 -0
- package/src/ProgressBar/ProgressBar.test.tsx +34 -26
- package/src/ProgressBar/ProgressBar.tsx +1 -1
- package/src/RadioList/RadioList.test.tsx +129 -14
- package/src/RadioList/RadioList.tsx +103 -8
- package/src/SegmentedControl/SegmentedControl.test.tsx +35 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +4 -1
- package/src/Selector/Selector.test.tsx +53 -0
- package/src/Selector/Selector.tsx +15 -8
- package/src/Selector/hooks.ts +23 -0
- package/src/Skeleton/Skeleton.test.tsx +25 -0
- package/src/Skeleton/Skeleton.tsx +11 -1
- package/src/Stack/Stack.doc.mjs +57 -0
- package/src/Stack/Stack.test.tsx +55 -5
- package/src/Stack/Stack.tsx +53 -1
- package/src/Stack/StackItem.test.tsx +23 -0
- package/src/Stack/StackItem.tsx +20 -0
- package/src/TabList/Tab.tsx +6 -0
- package/src/TabList/TabList.doc.mjs +6 -0
- package/src/TabList/TabList.test.tsx +167 -0
- package/src/TabList/TabList.tsx +72 -9
- package/src/TabList/TabListContext.ts +7 -3
- package/src/TabList/TabMenu.tsx +3 -3
- package/src/Toast/Toast.tsx +14 -0
- package/src/Toast/ToastViewport.test.tsx +204 -0
- package/src/Toast/ToastViewport.tsx +167 -21
- package/src/Toolbar/Toolbar.test.tsx +45 -0
- package/src/Toolbar/Toolbar.tsx +5 -2
- package/src/TreeList/TreeList.test.tsx +273 -0
- package/src/TreeList/TreeList.tsx +84 -1
- package/src/TreeList/TreeListItem.tsx +42 -2
- package/src/TreeList/treeListItem.markers.stylex.ts +20 -0
- package/src/Typeahead/BaseTypeahead.tsx +48 -2
- package/src/Typeahead/Typeahead.test.tsx +125 -0
- package/src/hooks/index.ts +21 -2
- package/src/hooks/useAnnounce.test.tsx +101 -0
- package/src/hooks/useAnnounce.ts +168 -0
- package/src/hooks/useClickableContainer.ts +16 -4
- package/src/hooks/useFocusTrap.test.tsx +67 -3
- package/src/hooks/useFocusTrap.ts +75 -0
- package/src/hooks/useListFocus.doc.mjs +49 -10
- package/src/hooks/useListFocus.test.tsx +269 -0
- package/src/hooks/useListFocus.ts +339 -54
- package/src/hooks/useLongPress.test.tsx +134 -0
- package/src/hooks/useLongPress.ts +119 -0
- package/src/hooks/useTreeFocus.doc.mjs +126 -0
- package/src/hooks/useTreeFocus.test.tsx +214 -0
- package/src/hooks/useTreeFocus.ts +464 -0
- package/src/hooks/useTypeahead.test.tsx +109 -0
- package/src/hooks/useTypeahead.ts +183 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/Dialog/Dialog.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAA6B,KAAK,SAAS,EAAC,M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,MAAM,CAAC;IAExB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,QAAgB,EAChB,YAAY,EACZ,KAAW,EACX,SAAkB,EAClB,QAAQ,EACR,OAAoB,EACpB,OAAgB,EAChB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,WAAW,sCAyOb;yBAzPe,MAAM"}
|
package/dist/Dialog/Dialog.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { useEffect, useMemo, useRef } from 'react';
|
|
19
19
|
import * as stylex from '@stylexjs/stylex';
|
|
20
20
|
import { useScrollLock } from "../hooks/useScrollLock.js";
|
|
21
|
+
import { hasActiveFocusTrapEscape, isImeKeyEvent } from "../hooks/useFocusTrap.js";
|
|
21
22
|
import "../theme/tokens.stylex.js";
|
|
22
23
|
import { colorVars, radiusVars, durationVars, easeVars, shadowVars } from "../theme/tokens.stylex.js";
|
|
23
24
|
import { container } from "../Layout/container.stylex.js";
|
|
@@ -300,6 +301,12 @@ export function Dialog({
|
|
|
300
301
|
}
|
|
301
302
|
const handleKeyDown = event => {
|
|
302
303
|
if (event.key === 'Escape') {
|
|
304
|
+
// Ignore IME composition-cancel, and defer to any popover/menu layered
|
|
305
|
+
// on top of this dialog so a single Escape closes only the top-most
|
|
306
|
+
// layer (the popover's own focus trap handles it and stops propagation).
|
|
307
|
+
if (isImeKeyEvent(event) || hasActiveFocusTrapEscape()) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
303
310
|
event.preventDefault();
|
|
304
311
|
if (allowEscape) {
|
|
305
312
|
onOpenChange(false);
|
|
@@ -324,6 +331,11 @@ export function Dialog({
|
|
|
324
331
|
// Handle native cancel event (browser Escape handling)
|
|
325
332
|
const handleCancel = event => {
|
|
326
333
|
event.preventDefault();
|
|
334
|
+
// Defer to a popover/menu layered on top of this dialog; it will dismiss
|
|
335
|
+
// itself on the same Escape press.
|
|
336
|
+
if (hasActiveFocusTrapEscape()) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
327
339
|
if (allowEscape) {
|
|
328
340
|
onOpenChange(false);
|
|
329
341
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAS,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAEnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAS,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAEnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAUtC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAQtD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAA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,MAAM,MAAM,iBAAiB,GACzB,qBAAqB,GACrB,yBAAyB,CAAC;AA4B9B,wBAAgB,YAAY,CAAC,EAC3B,MAAuB,EACvB,UAAU,EAAE,gBAAgB,EAC5B,YAAY,EACZ,SAAS,EACT,OAAO,EACP,UAAiB,EACjB,SAAmB,EACnB,YAAmB,EACnB,SAAS,EACT,KAAK,EACL,MAAM,EACN,aAAa,EAAE,MAAM,EACrB,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAyQnB;yBAvRe,YAAY"}
|
|
@@ -29,6 +29,7 @@ import { Icon } from "../Icon/index.js";
|
|
|
29
29
|
import { renderDropdownItems } from "./renderDropdownItems.js";
|
|
30
30
|
import { DropdownMenuContext } from "./DropdownMenuContext.js";
|
|
31
31
|
import { useListFocus } from "../hooks/useListFocus.js";
|
|
32
|
+
import { useTypeahead } from "../hooks/useTypeahead.js";
|
|
32
33
|
import { layerAnimations } from "../Layer/layerAnimations.stylex.js";
|
|
33
34
|
import "../theme/tokens.stylex.js";
|
|
34
35
|
import { spacingVars, radiusVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
|
|
@@ -184,13 +185,23 @@ export function DropdownMenu({
|
|
|
184
185
|
const {
|
|
185
186
|
listRef,
|
|
186
187
|
handleKeyDown: listNavKeyDown,
|
|
187
|
-
focusFirst
|
|
188
|
+
focusFirst,
|
|
189
|
+
focusItem
|
|
188
190
|
} = useListFocus({
|
|
189
191
|
itemSelector: '[role="menuitem"]:not([aria-disabled="true"])',
|
|
190
192
|
wrap: false,
|
|
191
193
|
onEscape: closeMenu
|
|
192
194
|
});
|
|
193
195
|
|
|
196
|
+
// First-character typeahead over the (enabled) menu items — jump to the next
|
|
197
|
+
// item whose label starts with the typed text (menus-11).
|
|
198
|
+
const getMenuItems = useCallback(() => listRef.current ? Array.from(listRef.current.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) : [], [listRef]);
|
|
199
|
+
const typeahead = useTypeahead({
|
|
200
|
+
getItemLabels: () => getMenuItems().map(el => el.textContent),
|
|
201
|
+
onMatch: focusItem,
|
|
202
|
+
getCurrentIndex: () => getMenuItems().findIndex(el => el === document.activeElement || el.contains(document.activeElement))
|
|
203
|
+
});
|
|
204
|
+
|
|
194
205
|
// Sync controlled open state → popover, and focus first item on open
|
|
195
206
|
useEffect(() => {
|
|
196
207
|
if (isControlled) {
|
|
@@ -205,7 +216,7 @@ export function DropdownMenu({
|
|
|
205
216
|
}
|
|
206
217
|
}, [controlledIsOpen, isControlled, popover, hasAutoFocus, focusFirst]);
|
|
207
218
|
|
|
208
|
-
// Extend useListFocus with Enter/Space activation
|
|
219
|
+
// Extend useListFocus with Enter/Space activation + typeahead
|
|
209
220
|
const listKeyDown = useCallback(e => {
|
|
210
221
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
211
222
|
e.preventDefault();
|
|
@@ -224,8 +235,13 @@ export function DropdownMenu({
|
|
|
224
235
|
closeMenu();
|
|
225
236
|
return;
|
|
226
237
|
}
|
|
238
|
+
// Type-to-focus next; if it consumed a printable key, stop here.
|
|
239
|
+
if (typeahead.onKeyDown(e)) {
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
227
243
|
listNavKeyDown(e);
|
|
228
|
-
}, [listNavKeyDown, closeMenu]);
|
|
244
|
+
}, [listNavKeyDown, closeMenu, typeahead]);
|
|
229
245
|
const openAndFocus = useCallback(() => {
|
|
230
246
|
popover.show();
|
|
231
247
|
if (hasAutoFocus) {
|
|
@@ -304,7 +320,12 @@ export function DropdownMenu({
|
|
|
304
320
|
}), popover.render(/*#__PURE__*/_jsx("div", {
|
|
305
321
|
ref: listRef,
|
|
306
322
|
id: menuId,
|
|
307
|
-
role: "menu"
|
|
323
|
+
role: "menu"
|
|
324
|
+
// Give the menu an accessible name from its trigger's label, so
|
|
325
|
+
// screen readers announce e.g. "Actions menu" rather than an unnamed
|
|
326
|
+
// menu (menus-13).
|
|
327
|
+
,
|
|
328
|
+
"aria-label": button.label,
|
|
308
329
|
onKeyDown: listKeyDown,
|
|
309
330
|
...mergeProps(themeProps('dropdown-menu'), stylex.props(styles.dropdown, xstyle), className, style),
|
|
310
331
|
children: /*#__PURE__*/_jsx(DropdownMenuContext, {
|
package/dist/Field/Field.d.ts
CHANGED
|
@@ -49,9 +49,26 @@ export interface FieldProps extends Omit<BaseProps<HTMLDivElement>, 'children'>
|
|
|
49
49
|
*/
|
|
50
50
|
description?: string;
|
|
51
51
|
/**
|
|
52
|
-
* ID
|
|
52
|
+
* ID of the input element this label points AT (used as the label's
|
|
53
|
+
* `htmlFor`). This is the id of the *control*, not of the label element —
|
|
54
|
+
* see `labelElementID` for the latter.
|
|
53
55
|
*/
|
|
54
56
|
inputID: string;
|
|
57
|
+
/**
|
|
58
|
+
* The `id` applied TO the label element itself (distinct from `inputID`,
|
|
59
|
+
* which is the control the label points at). A grouping control
|
|
60
|
+
* (radiogroup, checkbox group) references this via `aria-labelledby` to take
|
|
61
|
+
* the label as its accessible name. Pair with `isGroupLabel`.
|
|
62
|
+
*/
|
|
63
|
+
labelElementID?: string;
|
|
64
|
+
/**
|
|
65
|
+
* When the field wraps a group of controls rather than a single input, set
|
|
66
|
+
* this so the label renders as a non-`<label>` element (a `<span>`): a
|
|
67
|
+
* `<label>` semantically names one control and can't be associated with a
|
|
68
|
+
* group. Pair with `labelElementID` + `aria-labelledby` on the group.
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
isGroupLabel?: boolean;
|
|
55
72
|
/**
|
|
56
73
|
* ID for the description element (use for aria-describedby on the input).
|
|
57
74
|
*/
|
|
@@ -116,7 +133,7 @@ export interface FieldProps extends Omit<BaseProps<HTMLDivElement>, 'children'>
|
|
|
116
133
|
* </Field>
|
|
117
134
|
* ```
|
|
118
135
|
*/
|
|
119
|
-
export declare function Field({ label, isLabelHidden, description, inputID, descriptionID, isOptional, isRequired, isDisabled, labelIcon, status, labelTooltip, statusVariant, width, xstyle, children, className, style, ref, ...props }: FieldProps): import("react").JSX.Element;
|
|
136
|
+
export declare function Field({ label, isLabelHidden, description, inputID, labelElementID, isGroupLabel, descriptionID, isOptional, isRequired, isDisabled, labelIcon, status, labelTooltip, statusVariant, width, xstyle, children, className, style, ref, ...props }: FieldProps): import("react").JSX.Element;
|
|
120
137
|
export declare namespace Field {
|
|
121
138
|
var displayName: string;
|
|
122
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/Field/Field.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,KAAK,SAAS,EAAM,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAI9C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAoCtC,YAAY,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,SAAS,CAAC,cAAc,CAAC,EACzB,UAAU,CACX;IACC,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/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,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACxC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,OAAO,EACP,cAAc,EACd,YAAoB,EACpB,aAAa,EACb,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAA0B,EAC1B,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,UAAU,+BAqGZ;yBA3He,KAAK"}
|
package/dist/Field/Field.js
CHANGED
|
@@ -69,6 +69,8 @@ export function Field({
|
|
|
69
69
|
isLabelHidden = false,
|
|
70
70
|
description,
|
|
71
71
|
inputID,
|
|
72
|
+
labelElementID,
|
|
73
|
+
isGroupLabel = false,
|
|
72
74
|
descriptionID,
|
|
73
75
|
isOptional = false,
|
|
74
76
|
isRequired = false,
|
|
@@ -97,6 +99,8 @@ export function Field({
|
|
|
97
99
|
const labelNode = /*#__PURE__*/_jsx(FieldLabel, {
|
|
98
100
|
label: label,
|
|
99
101
|
inputID: inputID,
|
|
102
|
+
labelElementID: labelElementID,
|
|
103
|
+
isGroupLabel: isGroupLabel,
|
|
100
104
|
isLabelHidden: isLabelHidden,
|
|
101
105
|
isDisabled: isDisabled,
|
|
102
106
|
isOptional: isOptional,
|
|
@@ -20,9 +20,28 @@ export interface FieldLabelProps extends BaseProps<HTMLLabelElement> {
|
|
|
20
20
|
*/
|
|
21
21
|
label: string;
|
|
22
22
|
/**
|
|
23
|
-
* ID of the input element this label
|
|
23
|
+
* ID of the input element this label points AT (rendered as `htmlFor` on the
|
|
24
|
+
* label). This is *not* the id of the label element itself — see
|
|
25
|
+
* `labelElementID` for that.
|
|
24
26
|
*/
|
|
25
27
|
inputID: string;
|
|
28
|
+
/**
|
|
29
|
+
* The `id` applied TO the label element itself (not the element it points
|
|
30
|
+
* at — that's `inputID`). A grouping control (e.g. `role="radiogroup"`) can
|
|
31
|
+
* reference this via `aria-labelledby` to take the label as its accessible
|
|
32
|
+
* name.
|
|
33
|
+
*/
|
|
34
|
+
labelElementID?: string;
|
|
35
|
+
/**
|
|
36
|
+
* When true, the field wraps a *group* of controls (e.g. a radiogroup)
|
|
37
|
+
* rather than a single input. In that case the label is rendered as a
|
|
38
|
+
* `<span>` instead of a `<label>` — a `<label>` semantically names one form
|
|
39
|
+
* control and can't be associated with a group, so it must not be a literal
|
|
40
|
+
* label element. The group takes the label as its name via
|
|
41
|
+
* `labelElementID` + `aria-labelledby`.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
isGroupLabel?: boolean;
|
|
26
45
|
/**
|
|
27
46
|
* Whether to visually hide the label and description (still accessible
|
|
28
47
|
* to screen readers). When hidden, the entire label group is rendered
|
|
@@ -76,7 +95,7 @@ export interface FieldLabelProps extends BaseProps<HTMLLabelElement> {
|
|
|
76
95
|
* <FieldLabel label="Search" inputID={inputId} isLabelHidden />
|
|
77
96
|
* ```
|
|
78
97
|
*/
|
|
79
|
-
export declare function FieldLabel({ label, inputID, isLabelHidden, isDisabled, isOptional, isRequired, labelIcon, labelTooltip, description, descriptionID, ref, }: FieldLabelProps): import("react").JSX.Element;
|
|
98
|
+
export declare function FieldLabel({ label, inputID, labelElementID, isGroupLabel, isLabelHidden, isDisabled, isOptional, isRequired, labelIcon, labelTooltip, description, descriptionID, ref, }: FieldLabelProps): import("react").JSX.Element;
|
|
80
99
|
export declare namespace FieldLabel {
|
|
81
100
|
var displayName: string;
|
|
82
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldLabel.d.ts","sourceRoot":"","sources":["../../src/Field/FieldLabel.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAU5C,OAAO,EAAuB,KAAK,QAAQ,EAAC,MAAM,SAAS,CAAC;AAkD5D,MAAM,WAAW,eAAgB,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAClE,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd
|
|
1
|
+
{"version":3,"file":"FieldLabel.d.ts","sourceRoot":"","sources":["../../src/Field/FieldLabel.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAU5C,OAAO,EAAuB,KAAK,QAAQ,EAAC,MAAM,SAAS,CAAC;AAkD5D,MAAM,WAAW,eAAgB,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAClE,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,OAAO,EACP,cAAc,EACd,YAAoB,EACpB,aAAqB,EACrB,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACb,GAAG,GACJ,EAAE,eAAe,+BAsDjB;yBApEe,UAAU"}
|
package/dist/Field/FieldLabel.js
CHANGED
|
@@ -36,6 +36,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
36
36
|
export function FieldLabel({
|
|
37
37
|
label,
|
|
38
38
|
inputID,
|
|
39
|
+
labelElementID,
|
|
40
|
+
isGroupLabel = false,
|
|
39
41
|
isLabelHidden = false,
|
|
40
42
|
isDisabled = false,
|
|
41
43
|
isOptional = false,
|
|
@@ -47,10 +49,42 @@ export function FieldLabel({
|
|
|
47
49
|
ref
|
|
48
50
|
}) {
|
|
49
51
|
const statusText = isOptional ? 'Optional' : isRequired ? 'Required' : null;
|
|
52
|
+
|
|
53
|
+
// A group label (e.g. for a radiogroup) must not be a literal `<label>`
|
|
54
|
+
// element: a `<label>` semantically names a single form control and can't be
|
|
55
|
+
// associated with a group. Render it as a `<span>` instead, keeping all the
|
|
56
|
+
// label styling and slots. The group references it via `aria-labelledby`.
|
|
57
|
+
const LabelElement = isGroupLabel ? 'span' : 'label';
|
|
58
|
+
const labelContent = /*#__PURE__*/_jsxs(_Fragment, {
|
|
59
|
+
children: [labelIcon && renderIconSlot(labelIcon, {
|
|
60
|
+
size: 'sm',
|
|
61
|
+
color: 'inherit'
|
|
62
|
+
}), label, statusText && /*#__PURE__*/_jsxs("span", {
|
|
63
|
+
...{
|
|
64
|
+
className: "x1sodnla x141an7d x1ltkj2j xv1l7n4"
|
|
65
|
+
},
|
|
66
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
children: " \u2219 "
|
|
69
|
+
}), statusText]
|
|
70
|
+
}), labelTooltip && /*#__PURE__*/_jsx(Tooltip, {
|
|
71
|
+
content: labelTooltip,
|
|
72
|
+
placement: "above",
|
|
73
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
74
|
+
icon: "info",
|
|
75
|
+
size: "sm",
|
|
76
|
+
color: "inherit"
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
50
80
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
51
|
-
children: [/*#__PURE__*/
|
|
81
|
+
children: [/*#__PURE__*/_jsx(LabelElement, {
|
|
52
82
|
ref: ref,
|
|
53
|
-
|
|
83
|
+
id: labelElementID
|
|
84
|
+
// `htmlFor` only applies to a real `<label>` associating with a single
|
|
85
|
+
// control; a group label (span) has no `htmlFor`.
|
|
86
|
+
,
|
|
87
|
+
htmlFor: isGroupLabel ? undefined : inputID,
|
|
54
88
|
...mergeProps(themeProps('field-label'), {
|
|
55
89
|
0: {
|
|
56
90
|
className: "x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xv1l7n4 x1ypdohk"
|
|
@@ -65,26 +99,7 @@ export function FieldLabel({
|
|
|
65
99
|
className: "x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xnbbluu x1h6gzvc xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"
|
|
66
100
|
}
|
|
67
101
|
}[!!isDisabled << 1 | !!isLabelHidden << 0]),
|
|
68
|
-
children:
|
|
69
|
-
size: 'sm',
|
|
70
|
-
color: 'inherit'
|
|
71
|
-
}), label, statusText && /*#__PURE__*/_jsxs("span", {
|
|
72
|
-
...{
|
|
73
|
-
className: "x1sodnla x141an7d x1ltkj2j xv1l7n4"
|
|
74
|
-
},
|
|
75
|
-
children: [/*#__PURE__*/_jsx("span", {
|
|
76
|
-
"aria-hidden": "true",
|
|
77
|
-
children: " \u2219 "
|
|
78
|
-
}), statusText]
|
|
79
|
-
}), labelTooltip && /*#__PURE__*/_jsx(Tooltip, {
|
|
80
|
-
content: labelTooltip,
|
|
81
|
-
placement: "above",
|
|
82
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
83
|
-
icon: "info",
|
|
84
|
-
size: "sm",
|
|
85
|
-
color: "inherit"
|
|
86
|
-
})
|
|
87
|
-
})]
|
|
102
|
+
children: labelContent
|
|
88
103
|
}), description && /*#__PURE__*/_jsx("span", {
|
|
89
104
|
id: descriptionID,
|
|
90
105
|
...{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAsCA,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../src/FileInput/FileInput.tsx"],"names":[],"mappings":"AAsCA,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AAKlB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,eAAe,IAAI,mBAAmB,GACvC,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAyN9C,MAAM,WAAW,cAAe,SA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;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAkB,EAClB,OAAO,EACP,QAAQ,EACR,UAAkB,EAClB,UAAkB,EAClB,SAAiB,EACjB,MAAM,EAAE,UAAU,EAClB,WAAW,EACX,WAAW,EACX,IAAc,EACd,UAAkB,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,+BAmVhB;yBA5We,SAAS"}
|
|
@@ -22,6 +22,7 @@ import { colorVars, sizeVars, spacingVars, radiusVars, typographyVars, typeScale
|
|
|
22
22
|
import { Field, InputClearButton } from "../Field/index.js";
|
|
23
23
|
import { Icon } from "../Icon/index.js";
|
|
24
24
|
import { Spinner } from "../Spinner/index.js";
|
|
25
|
+
import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
25
26
|
import { mergeProps, mergeRefs } from "../utils/index.js";
|
|
26
27
|
import { themeProps } from "../utils/themeProps.js";
|
|
27
28
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -198,6 +199,11 @@ export function FileInput({
|
|
|
198
199
|
const [isDragOver, setIsDragOver] = useState(false);
|
|
199
200
|
const [validationError, setValidationError] = useState(null);
|
|
200
201
|
const [, startTransition] = useTransition();
|
|
202
|
+
|
|
203
|
+
// Announce successful file selection to screen readers via a persistent
|
|
204
|
+
// live region (forms-17). The component's own role="status" region only
|
|
205
|
+
// carries validation errors, so a successful attach was previously silent.
|
|
206
|
+
const announce = useAnnounce();
|
|
201
207
|
const status = statusProp ?? (validationError ? {
|
|
202
208
|
type: 'error',
|
|
203
209
|
message: validationError
|
|
@@ -234,12 +240,19 @@ export function FileInput({
|
|
|
234
240
|
}
|
|
235
241
|
const result = isMultiple ? valid : valid[0];
|
|
236
242
|
onChange(result);
|
|
243
|
+
|
|
244
|
+
// Announce the successful selection politely. Validation errors are
|
|
245
|
+
// handled by the role="status" region below, so only announce the
|
|
246
|
+
// attach here (do not double-announce errors).
|
|
247
|
+
if (errors.length === 0) {
|
|
248
|
+
announce(valid.length === 1 ? `1 file selected: ${valid[0].name}` : `${valid.length} files selected`);
|
|
249
|
+
}
|
|
237
250
|
if (changeAction) {
|
|
238
251
|
startTransition(async () => {
|
|
239
252
|
await changeAction(result);
|
|
240
253
|
});
|
|
241
254
|
}
|
|
242
|
-
}, [accept, isDisabled, isMultiple, maxFiles, maxSize, onChange, changeAction, startTransition]);
|
|
255
|
+
}, [accept, isDisabled, isMultiple, maxFiles, maxSize, onChange, changeAction, startTransition, announce]);
|
|
243
256
|
const handleInputChange = useCallback(e => {
|
|
244
257
|
const fileList = Array.from(e.target.files ?? []);
|
|
245
258
|
handleFiles(fileList);
|
|
@@ -397,7 +410,14 @@ export function FileInput({
|
|
|
397
410
|
onClick: handleClick,
|
|
398
411
|
onKeyDown: handleKeyDown,
|
|
399
412
|
"aria-label": label,
|
|
400
|
-
"aria-busy": isLoading || undefined
|
|
413
|
+
"aria-busy": isLoading || undefined
|
|
414
|
+
// These describe the operable control, so they belong on the focusable
|
|
415
|
+
// role="button" wrapper — not the hidden tabIndex={-1} file input the
|
|
416
|
+
// user never focuses (forms-6).
|
|
417
|
+
,
|
|
418
|
+
"aria-describedby": ariaDescribedBy,
|
|
419
|
+
"aria-required": isRequired ? 'true' : undefined,
|
|
420
|
+
"aria-invalid": status?.type === 'error' ? 'true' : undefined,
|
|
401
421
|
...dragDropProps,
|
|
402
422
|
...mergeProps(themeProps('file-input', {
|
|
403
423
|
mode,
|
|
@@ -411,10 +431,11 @@ export function FileInput({
|
|
|
411
431
|
accept: accept,
|
|
412
432
|
multiple: isMultiple,
|
|
413
433
|
disabled: isDisabled,
|
|
414
|
-
onChange: handleInputChange
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
onChange: handleInputChange
|
|
435
|
+
// The visually-hidden native input is never focused (tabIndex={-1});
|
|
436
|
+
// its describedby/required/invalid live on the role="button" wrapper.
|
|
437
|
+
,
|
|
438
|
+
"aria-hidden": "true",
|
|
418
439
|
tabIndex: -1,
|
|
419
440
|
...{
|
|
420
441
|
className: "x10l6tqk x1i1rx1s xjm9jq1 x1717udv xkdpibf xb3r6kr xzpqnlu xuxw1ft xc342km"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputGroup.d.ts","sourceRoot":"","sources":["../../src/InputGroup/InputGroup.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAQ,KAAK,WAAW,EAAC,MAAM,UAAU,CAAC;AAGjD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAI5C,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AA0BhD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,SAAS,CAAC,cAAc,CAAC,EACzB,UAAU,CACX;IACC,mDAAmD;IACnD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAEhC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IAEtB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;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AAE,OAAO,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IAEtB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,aAAqB,EACrB,WAAW,EACX,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,YAAY,EACZ,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,aAAa,EAAE,MAAM,EACrB,GAAG,IAAI,EACR,EAAE,eAAe,+BA0DjB;yBA3Ee,UAAU"}
|
|
@@ -88,6 +88,7 @@ export function InputGroup({
|
|
|
88
88
|
}) {
|
|
89
89
|
const size = useSize(sizeProp, 'md');
|
|
90
90
|
const inputId = useId();
|
|
91
|
+
const labelElementId = useId();
|
|
91
92
|
const statusMessageId = useId();
|
|
92
93
|
const contextValue = useMemo(() => ({
|
|
93
94
|
isInGroup: true
|
|
@@ -101,6 +102,8 @@ export function InputGroup({
|
|
|
101
102
|
isLabelHidden: isLabelHidden,
|
|
102
103
|
description: description,
|
|
103
104
|
inputID: inputId,
|
|
105
|
+
labelElementID: labelElementId,
|
|
106
|
+
isGroupLabel: true,
|
|
104
107
|
isOptional: isOptional,
|
|
105
108
|
isRequired: isRequired,
|
|
106
109
|
isDisabled: isDisabled,
|
|
@@ -114,7 +117,7 @@ export function InputGroup({
|
|
|
114
117
|
children: /*#__PURE__*/_jsx("div", {
|
|
115
118
|
ref: ref,
|
|
116
119
|
role: "group",
|
|
117
|
-
"aria-
|
|
120
|
+
"aria-labelledby": labelElementId,
|
|
118
121
|
"data-testid": testId,
|
|
119
122
|
...rest,
|
|
120
123
|
...mergeProps(themeProps('input-group', {
|
package/dist/Kbd/Kbd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Kbd.d.ts","sourceRoot":"","sources":["../../src/Kbd/Kbd.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Kbd.d.ts","sourceRoot":"","sources":["../../src/Kbd/Kbd.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AA4H5C,MAAM,WAAW,QAAS,SAAQ,SAAS,CAAC,eAAe,CAAC;IAC1D,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,GAAG,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAC,EAAE,QAAQ,qBAgC3E;yBAhCe,GAAG"}
|
package/dist/Kbd/Kbd.js
CHANGED
|
@@ -66,6 +66,32 @@ function getKeyDisplay(key, isMac) {
|
|
|
66
66
|
}
|
|
67
67
|
return KEY_DISPLAY[key] ?? key.toUpperCase();
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Spoken-word labels for screen readers. The visual `KEY_DISPLAY` uses glyphs
|
|
72
|
+
* (⌘, ⇧, ↵, …) that assistive tech cannot announce meaningfully, so the
|
|
73
|
+
* accessible name for the shortcut is built from these words instead.
|
|
74
|
+
*/
|
|
75
|
+
const KEY_LABEL = {
|
|
76
|
+
ctrl: 'Control',
|
|
77
|
+
alt: 'Alt',
|
|
78
|
+
shift: 'Shift',
|
|
79
|
+
enter: 'Enter',
|
|
80
|
+
backspace: 'Backspace',
|
|
81
|
+
escape: 'Escape',
|
|
82
|
+
tab: 'Tab',
|
|
83
|
+
up: 'Up arrow',
|
|
84
|
+
down: 'Down arrow',
|
|
85
|
+
left: 'Left arrow',
|
|
86
|
+
right: 'Right arrow',
|
|
87
|
+
plus: 'Plus'
|
|
88
|
+
};
|
|
89
|
+
function getKeyLabel(key, isMac) {
|
|
90
|
+
if (key === 'mod') {
|
|
91
|
+
return isMac ? 'Command' : 'Control';
|
|
92
|
+
}
|
|
93
|
+
return KEY_LABEL[key] ?? key.toUpperCase();
|
|
94
|
+
}
|
|
69
95
|
function subscribeToPlatformChanges() {
|
|
70
96
|
return () => {};
|
|
71
97
|
}
|
|
@@ -115,12 +141,18 @@ export function Kbd({
|
|
|
115
141
|
}) {
|
|
116
142
|
const isMac = useSyncExternalStore(subscribeToPlatformChanges, detectMac, getServerPlatformSnapshot);
|
|
117
143
|
const parts = keys.split('+').map(key => key.trim().toLowerCase());
|
|
144
|
+
|
|
145
|
+
// Screen-reader name: the joined spoken labels (e.g. "Command + K"), since
|
|
146
|
+
// the visual glyphs below are announced meaninglessly by assistive tech.
|
|
147
|
+
const accessibleName = parts.map(key => getKeyLabel(key, isMac)).join(' + ');
|
|
118
148
|
return /*#__PURE__*/_jsx("span", {
|
|
119
149
|
ref: ref,
|
|
150
|
+
role: "img",
|
|
151
|
+
"aria-label": accessibleName,
|
|
120
152
|
...rest,
|
|
121
153
|
...mergeProps(themeProps('kbd'), stylex.props(styles.wrapper, xstyle), className, style),
|
|
122
|
-
"aria-hidden": "true",
|
|
123
154
|
children: parts.map(key => /*#__PURE__*/_jsx("kbd", {
|
|
155
|
+
"aria-hidden": "true",
|
|
124
156
|
...{
|
|
125
157
|
className: "x3nfvp2 x6s0dn4 xl56j7k x16asifk x1grt7ep x7a5moj xx3sua9 x17x4s8c xlxy82 x1q0q8m5 xib2hle xv1l7n4 x9ynric x141an7d x1e4wzip x1ltkj2j x87ps6o"
|
|
126
158
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,EAMZ,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AA4BnD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B;;;;;;;;;;;OAWG;IACH,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpD;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/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G;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;CACrE;AAuCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC;AAC3E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAC"}
|
package/dist/Layer/useLayer.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - /packages/core/src/Layer/Layer.doc.mjs
|
|
13
13
|
* - /packages/core/src/Layer/index.ts
|
|
14
14
|
*/
|
|
15
|
-
import React, { useCallback, useId, useRef, useState } from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
16
16
|
import * as stylex from '@stylexjs/stylex';
|
|
17
17
|
import { addAnchorName, removeAnchorName } from "./anchorName.js";
|
|
18
18
|
import "../theme/tokens.stylex.js";
|
|
@@ -191,13 +191,44 @@ export function useLayer(options) {
|
|
|
191
191
|
}
|
|
192
192
|
}, [onHide]);
|
|
193
193
|
|
|
194
|
-
// Ref callback for popover element — sets up toggle listener
|
|
194
|
+
// Ref callback for popover element — sets up the `toggle` listener.
|
|
195
|
+
// Tracks the element + handler currently bound so the listener is removed
|
|
196
|
+
// when the element detaches or when `handleToggle`'s identity changes (a new
|
|
197
|
+
// `onHide` prop), preventing stale-closure listeners from accumulating on the
|
|
198
|
+
// same element (infra-10).
|
|
199
|
+
const listenedElRef = useRef(null);
|
|
200
|
+
const listenedHandlerRef = useRef(null);
|
|
201
|
+
const bindToggleListener = useCallback((el, handler) => {
|
|
202
|
+
if (listenedElRef.current && listenedHandlerRef.current && (listenedElRef.current !== el || listenedHandlerRef.current !== handler)) {
|
|
203
|
+
listenedElRef.current.removeEventListener('toggle', listenedHandlerRef.current);
|
|
204
|
+
listenedElRef.current = null;
|
|
205
|
+
listenedHandlerRef.current = null;
|
|
206
|
+
}
|
|
207
|
+
if (el && listenedElRef.current !== el) {
|
|
208
|
+
el.addEventListener('toggle', handler);
|
|
209
|
+
listenedElRef.current = el;
|
|
210
|
+
listenedHandlerRef.current = handler;
|
|
211
|
+
}
|
|
212
|
+
}, []);
|
|
195
213
|
const popoverRefCallback = useCallback(el => {
|
|
196
214
|
popoverRef.current = el;
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
bindToggleListener(el, handleToggle);
|
|
216
|
+
}, [handleToggle, bindToggleListener]);
|
|
217
|
+
|
|
218
|
+
// Re-bind when the handler identity changes while the element stays mounted,
|
|
219
|
+
// and detach on unmount.
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
if (popoverRef.current) {
|
|
222
|
+
bindToggleListener(popoverRef.current, handleToggle);
|
|
199
223
|
}
|
|
200
|
-
|
|
224
|
+
return () => {
|
|
225
|
+
if (listenedElRef.current && listenedHandlerRef.current) {
|
|
226
|
+
listenedElRef.current.removeEventListener('toggle', listenedHandlerRef.current);
|
|
227
|
+
listenedElRef.current = null;
|
|
228
|
+
listenedHandlerRef.current = null;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}, [handleToggle, bindToggleListener]);
|
|
201
232
|
|
|
202
233
|
// Render function for context mode
|
|
203
234
|
const renderContext = useCallback((children, props) => {
|
|
@@ -284,6 +284,57 @@ export declare const layoutPaddingOuterYVarStyles: Readonly<{
|
|
|
284
284
|
readonly '--layout-padding-outer-y': stylex.StyleXClassNameFor<"--layout-padding-outer-y", "40px">;
|
|
285
285
|
}>;
|
|
286
286
|
}>;
|
|
287
|
+
/**
|
|
288
|
+
* Inline-only padding styles.
|
|
289
|
+
* Use when a component needs to set inline (horizontal) padding independently
|
|
290
|
+
* of block padding — e.g. the `paddingX` prop on Stack.
|
|
291
|
+
*/
|
|
292
|
+
export declare const paddingInlineStyles: Readonly<{
|
|
293
|
+
readonly 0: Readonly<{
|
|
294
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "0px">;
|
|
295
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "0px">;
|
|
296
|
+
}>;
|
|
297
|
+
readonly 0.5: Readonly<{
|
|
298
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "2px">;
|
|
299
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "2px">;
|
|
300
|
+
}>;
|
|
301
|
+
readonly 1: Readonly<{
|
|
302
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "4px">;
|
|
303
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "4px">;
|
|
304
|
+
}>;
|
|
305
|
+
readonly 1.5: Readonly<{
|
|
306
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "6px">;
|
|
307
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "6px">;
|
|
308
|
+
}>;
|
|
309
|
+
readonly 2: Readonly<{
|
|
310
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "8px">;
|
|
311
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "8px">;
|
|
312
|
+
}>;
|
|
313
|
+
readonly 3: Readonly<{
|
|
314
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "12px">;
|
|
315
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "12px">;
|
|
316
|
+
}>;
|
|
317
|
+
readonly 4: Readonly<{
|
|
318
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "16px">;
|
|
319
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "16px">;
|
|
320
|
+
}>;
|
|
321
|
+
readonly 5: Readonly<{
|
|
322
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "20px">;
|
|
323
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "20px">;
|
|
324
|
+
}>;
|
|
325
|
+
readonly 6: Readonly<{
|
|
326
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "24px">;
|
|
327
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "24px">;
|
|
328
|
+
}>;
|
|
329
|
+
readonly 8: Readonly<{
|
|
330
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "32px">;
|
|
331
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "32px">;
|
|
332
|
+
}>;
|
|
333
|
+
readonly 10: Readonly<{
|
|
334
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", "40px">;
|
|
335
|
+
readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", "40px">;
|
|
336
|
+
}>;
|
|
337
|
+
}>;
|
|
287
338
|
/**
|
|
288
339
|
* Block-only padding override styles.
|
|
289
340
|
* Use when a component needs to override block padding independently
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"padding.stylex.d.ts","sourceRoot":"","sources":["../../src/Layout/padding.stylex.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAY1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmExB,CAAC;A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