@barqjs/aria 0.2.0-next.0 → 0.2.0-next.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/README.md +24 -13
- package/package.json +127 -37
- package/src/autocomplete.tsx +581 -0
- package/src/breadcrumbs.tsx +21 -20
- package/src/button.tsx +151 -25
- package/src/calendar.tsx +1019 -92
- package/src/checkbox.tsx +214 -52
- package/src/collections.ts +88 -5
- package/src/color.ts +1580 -23
- package/src/colorpicker.tsx +698 -153
- package/src/colorswatchpicker.tsx +240 -0
- package/src/combobox.tsx +635 -113
- package/src/command.tsx +78 -59
- package/src/date.ts +31 -9
- package/src/datefield.tsx +1451 -336
- package/src/datepicker.tsx +465 -114
- package/src/dialog.tsx +302 -115
- package/src/disclosure.tsx +81 -29
- package/src/dnd/clipboard.ts +125 -0
- package/src/dnd/collection.ts +1265 -0
- package/src/dnd/data.ts +409 -0
- package/src/dnd/drag-drop.ts +801 -0
- package/src/dnd/index.ts +133 -0
- package/src/dnd/manager.ts +639 -0
- package/src/dnd/strings.ts +1279 -0
- package/src/dnd/targets.ts +726 -0
- package/src/dnd/types.ts +212 -0
- package/src/dom.ts +3 -6
- package/src/drag-and-drop.tsx +669 -0
- package/src/dropzone.tsx +208 -0
- package/src/file-trigger.tsx +103 -0
- package/src/form.tsx +18 -18
- package/src/gridlist.tsx +912 -121
- package/src/group.tsx +146 -0
- package/src/index.ts +402 -0
- package/src/interactions/focus-events.ts +13 -5
- package/src/interactions/keyboard.ts +195 -2
- package/src/interactions/modality.ts +18 -6
- package/src/interactions/open-link.ts +46 -13
- package/src/interactions/press.ts +35 -18
- package/src/label.ts +18 -6
- package/src/link.tsx +146 -50
- package/src/listbox.tsx +615 -89
- package/src/live.ts +4 -0
- package/src/menu.tsx +182 -89
- package/src/menubar.tsx +21 -17
- package/src/navigation-tree.tsx +357 -0
- package/src/numberfield.tsx +164 -60
- package/src/overlay-arrow.tsx +157 -0
- package/src/overlays.ts +364 -62
- package/src/platform.ts +2 -1
- package/src/preview-trigger.tsx +582 -0
- package/src/progress-bar-context.ts +15 -0
- package/src/questionnaire.tsx +109 -104
- package/src/radio.tsx +101 -27
- package/src/select.tsx +225 -145
- package/src/selection-indicator.tsx +74 -0
- package/src/selection.ts +73 -16
- package/src/shared-element-transition.tsx +316 -0
- package/src/sheet.tsx +1461 -0
- package/src/slider.tsx +139 -44
- package/src/switch.tsx +47 -21
- package/src/table.tsx +0 -0
- package/src/tabs.tsx +198 -89
- package/src/tag.tsx +217 -32
- package/src/textarea.tsx +186 -0
- package/src/textfield.tsx +103 -37
- package/src/toast-components.tsx +589 -0
- package/src/toggle-button-group.tsx +175 -0
- package/src/toggle-input.tsx +38 -0
- package/src/toggle.ts +68 -5
- package/src/tokenfield.tsx +1673 -0
- package/src/toolbar.tsx +15 -10
- package/src/tooltip.tsx +46 -29
- package/src/tree.tsx +2075 -0
- package/src/utils.ts +30 -1
- package/src/validation.ts +79 -22
- package/src/virtualizer.tsx +186 -23
package/src/group.tsx
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A group: a set of related controls that reads, and styles, as one.
|
|
3
|
+
*
|
|
4
|
+
* An input with a button stuck to it, a date field's segments, a toolbar's
|
|
5
|
+
* cluster of toggles. What the group adds is the state of the WHOLE: whether
|
|
6
|
+
* the pointer is over any of it, and whether focus is anywhere inside, so the
|
|
7
|
+
* border drawn around the set can follow the control the user is in.
|
|
8
|
+
*
|
|
9
|
+
* `role="group"` by default. `region` puts it in the page's landmarks, for a
|
|
10
|
+
* group important enough to be jumped to; `presentation` is for one that is
|
|
11
|
+
* only drawn and means nothing to a screen reader.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { cells, type Accessor, type Child } from "@barqjs/core";
|
|
15
|
+
import { mergeRefs, type RefTarget } from "@barqjs/primitives/refs";
|
|
16
|
+
import { focusRing } from "./focus.ts";
|
|
17
|
+
import { hover, type HoverEvent } from "./interactions/hover.ts";
|
|
18
|
+
import {
|
|
19
|
+
access,
|
|
20
|
+
type DOMProps,
|
|
21
|
+
filterDOMProps,
|
|
22
|
+
fromProps,
|
|
23
|
+
type MaybeAccessor,
|
|
24
|
+
mergeProps,
|
|
25
|
+
type StyleProps,
|
|
26
|
+
styleProps,
|
|
27
|
+
} from "./utils.ts";
|
|
28
|
+
|
|
29
|
+
export type GroupRole = "group" | "region" | "presentation";
|
|
30
|
+
|
|
31
|
+
export interface GroupOptions {
|
|
32
|
+
isDisabled?: MaybeAccessor<boolean | undefined>;
|
|
33
|
+
isInvalid?: MaybeAccessor<boolean | undefined>;
|
|
34
|
+
isReadOnly?: MaybeAccessor<boolean | undefined>;
|
|
35
|
+
/** @default "group" */
|
|
36
|
+
role?: MaybeAccessor<GroupRole | undefined>;
|
|
37
|
+
"aria-label"?: MaybeAccessor<string | undefined>;
|
|
38
|
+
"aria-labelledby"?: MaybeAccessor<string | undefined>;
|
|
39
|
+
"aria-describedby"?: MaybeAccessor<string | undefined>;
|
|
40
|
+
"aria-details"?: MaybeAccessor<string | undefined>;
|
|
41
|
+
/** Read as `isDisabled` when that is not given, as a caller writing ARIA directly expects. */
|
|
42
|
+
"aria-disabled"?: MaybeAccessor<boolean | "true" | "false" | undefined>;
|
|
43
|
+
/** Read as `isInvalid` when that is not given. */
|
|
44
|
+
"aria-invalid"?: MaybeAccessor<boolean | "true" | "false" | undefined>;
|
|
45
|
+
onHoverStart?: (event: HoverEvent) => void;
|
|
46
|
+
onHoverEnd?: (event: HoverEvent) => void;
|
|
47
|
+
onHoverChange?: (isHovered: boolean) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface GroupResult {
|
|
51
|
+
groupProps: DOMProps;
|
|
52
|
+
isHovered: Accessor<boolean>;
|
|
53
|
+
/** Whether focus is anywhere inside. */
|
|
54
|
+
isFocusWithin: Accessor<boolean>;
|
|
55
|
+
/** Whether focus inside arrived by keyboard. */
|
|
56
|
+
isFocusVisible: Accessor<boolean>;
|
|
57
|
+
isDisabled: Accessor<boolean>;
|
|
58
|
+
isInvalid: Accessor<boolean>;
|
|
59
|
+
isReadOnly: Accessor<boolean>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isTrue(value: boolean | "true" | "false" | undefined): boolean {
|
|
63
|
+
return value === true || value === "true";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function group(options: GroupOptions = {}): GroupResult {
|
|
67
|
+
const isDisabled = (): boolean =>
|
|
68
|
+
access(options.isDisabled) ?? isTrue(access(options["aria-disabled"]));
|
|
69
|
+
const isInvalid = (): boolean =>
|
|
70
|
+
access(options.isInvalid) ?? isTrue(access(options["aria-invalid"]));
|
|
71
|
+
const isReadOnly = (): boolean => access(options.isReadOnly) === true;
|
|
72
|
+
|
|
73
|
+
const { hoverProps, isHovered } = hover({
|
|
74
|
+
isDisabled,
|
|
75
|
+
onHoverStart: options.onHoverStart,
|
|
76
|
+
onHoverEnd: options.onHoverEnd,
|
|
77
|
+
onHoverChange: options.onHoverChange,
|
|
78
|
+
});
|
|
79
|
+
const { focusProps, isFocused, isFocusVisible } = focusRing({ within: true });
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
isHovered,
|
|
83
|
+
isFocusWithin: isFocused,
|
|
84
|
+
isFocusVisible,
|
|
85
|
+
isDisabled,
|
|
86
|
+
isInvalid,
|
|
87
|
+
isReadOnly,
|
|
88
|
+
groupProps: mergeProps(filterDOMProps(options, { labelable: true }), hoverProps, focusProps, {
|
|
89
|
+
role: () => access(options.role) ?? "group",
|
|
90
|
+
"aria-disabled": () => access(options["aria-disabled"]),
|
|
91
|
+
"aria-invalid": () => access(options["aria-invalid"]),
|
|
92
|
+
"data-hovered": isHovered,
|
|
93
|
+
"data-focus-within": isFocused,
|
|
94
|
+
"data-focus-visible": isFocusVisible,
|
|
95
|
+
"data-disabled": isDisabled,
|
|
96
|
+
"data-invalid": isInvalid,
|
|
97
|
+
"data-readonly": isReadOnly,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface GroupComponentProps extends Omit<StyleProps, "role"> {
|
|
103
|
+
children?: Child;
|
|
104
|
+
isDisabled?: boolean;
|
|
105
|
+
isInvalid?: boolean;
|
|
106
|
+
isReadOnly?: boolean;
|
|
107
|
+
/** @default "group" */
|
|
108
|
+
role?: GroupRole;
|
|
109
|
+
"aria-label"?: string;
|
|
110
|
+
"aria-labelledby"?: string;
|
|
111
|
+
"aria-describedby"?: string;
|
|
112
|
+
"aria-details"?: string;
|
|
113
|
+
"aria-disabled"?: boolean | "true" | "false";
|
|
114
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
115
|
+
ref?: RefTarget<HTMLDivElement>;
|
|
116
|
+
onHoverStart?: (event: HoverEvent) => void;
|
|
117
|
+
onHoverEnd?: (event: HoverEvent) => void;
|
|
118
|
+
onHoverChange?: (isHovered: boolean) => void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* ```tsx
|
|
123
|
+
* <Group aria-label="Quantity">
|
|
124
|
+
* <button>-</button>
|
|
125
|
+
* <input />
|
|
126
|
+
* <button>+</button>
|
|
127
|
+
* </Group>
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export function Group(props: GroupComponentProps) {
|
|
131
|
+
const options = fromProps(cells(props));
|
|
132
|
+
const { groupProps } = group(options);
|
|
133
|
+
|
|
134
|
+
const elementProps = mergeProps(
|
|
135
|
+
groupProps,
|
|
136
|
+
filterDOMProps(options, { global: true }),
|
|
137
|
+
styleProps(cells(props)),
|
|
138
|
+
{ "data-testid": () => props["data-testid"] },
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div {...elementProps} ref={mergeRefs(props.ref)}>
|
|
143
|
+
{props.children}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -92,6 +92,7 @@ export {
|
|
|
92
92
|
toFixedNumber,
|
|
93
93
|
type TriggerSlot,
|
|
94
94
|
triggerSlot,
|
|
95
|
+
clearTriggerSlot,
|
|
95
96
|
} from "./utils.ts";
|
|
96
97
|
export {
|
|
97
98
|
collator,
|
|
@@ -259,6 +260,7 @@ export {
|
|
|
259
260
|
type SingleSelectListState,
|
|
260
261
|
singleSelectListState,
|
|
261
262
|
type Size,
|
|
263
|
+
getItemCount,
|
|
262
264
|
} from "./collections.ts";
|
|
263
265
|
export {
|
|
264
266
|
type Direction,
|
|
@@ -634,6 +636,7 @@ export {
|
|
|
634
636
|
DateRangePicker,
|
|
635
637
|
type DateRangePickerComponentProps,
|
|
636
638
|
useDatePicker,
|
|
639
|
+
type DateTimeRange,
|
|
637
640
|
} from "./datepicker.tsx";
|
|
638
641
|
export {
|
|
639
642
|
Dialog,
|
|
@@ -661,6 +664,11 @@ export {
|
|
|
661
664
|
useDialogTrigger,
|
|
662
665
|
usePopoverGroup,
|
|
663
666
|
usePopoverPlacement,
|
|
667
|
+
DismissButton,
|
|
668
|
+
type DismissButtonComponentProps,
|
|
669
|
+
providePopoverTrigger,
|
|
670
|
+
usePopoverTrigger,
|
|
671
|
+
type PopoverTriggerValue,
|
|
664
672
|
} from "./dialog.tsx";
|
|
665
673
|
export {
|
|
666
674
|
Disclosure,
|
|
@@ -704,6 +712,17 @@ export {
|
|
|
704
712
|
rowIdFor,
|
|
705
713
|
useGridList,
|
|
706
714
|
useRowNode,
|
|
715
|
+
type GridListFocusMode,
|
|
716
|
+
GridListHeader,
|
|
717
|
+
type GridListHeaderProps,
|
|
718
|
+
type GridListRenderState,
|
|
719
|
+
GridListSection,
|
|
720
|
+
type GridListSectionProps,
|
|
721
|
+
GridListSelectionCheckbox,
|
|
722
|
+
gridListSelectionCheckbox,
|
|
723
|
+
type GridListSelectionCheckboxOptions,
|
|
724
|
+
type GridListSelectionCheckboxProps,
|
|
725
|
+
type GridListSelectionCheckboxResult,
|
|
707
726
|
} from "./gridlist.tsx";
|
|
708
727
|
export {
|
|
709
728
|
Link,
|
|
@@ -724,6 +743,7 @@ export {
|
|
|
724
743
|
type SeparatorComponentProps,
|
|
725
744
|
type SeparatorOptions,
|
|
726
745
|
} from "./link.tsx";
|
|
746
|
+
export { ProgressBarContext, type ProgressBarContextValue } from "./progress-bar-context.ts";
|
|
727
747
|
export {
|
|
728
748
|
idFragment,
|
|
729
749
|
listBox,
|
|
@@ -748,6 +768,7 @@ export {
|
|
|
748
768
|
useItemNode,
|
|
749
769
|
useListBox,
|
|
750
770
|
useSectionHeading,
|
|
771
|
+
type ListBoxRenderState,
|
|
751
772
|
} from "./listbox.tsx";
|
|
752
773
|
export {
|
|
753
774
|
ContextMenu,
|
|
@@ -949,6 +970,8 @@ export {
|
|
|
949
970
|
type SliderTrackComponentProps,
|
|
950
971
|
runsBackwards,
|
|
951
972
|
useSlider,
|
|
973
|
+
SliderFill,
|
|
974
|
+
type SliderFillComponentProps,
|
|
952
975
|
} from "./slider.tsx";
|
|
953
976
|
export {
|
|
954
977
|
provideStaticSection,
|
|
@@ -1008,6 +1031,13 @@ export {
|
|
|
1008
1031
|
useColumn,
|
|
1009
1032
|
useRow,
|
|
1010
1033
|
useTable,
|
|
1034
|
+
type TableCollectionOptions,
|
|
1035
|
+
TableExpandButton,
|
|
1036
|
+
type TableExpandButtonProps,
|
|
1037
|
+
TableFooter,
|
|
1038
|
+
type TableFooterComponentProps,
|
|
1039
|
+
type TableKeyboardNavigationBehavior,
|
|
1040
|
+
type TableRowPosition,
|
|
1011
1041
|
} from "./table.tsx";
|
|
1012
1042
|
export {
|
|
1013
1043
|
Tab,
|
|
@@ -1170,6 +1200,7 @@ export {
|
|
|
1170
1200
|
type ToggleElementType,
|
|
1171
1201
|
type ToggleOptions,
|
|
1172
1202
|
type ToggleResult,
|
|
1203
|
+
focusInput,
|
|
1173
1204
|
} from "./toggle.ts";
|
|
1174
1205
|
export {
|
|
1175
1206
|
adjustLayoutByDelta,
|
|
@@ -1268,3 +1299,374 @@ export {
|
|
|
1268
1299
|
type VirtualizerState,
|
|
1269
1300
|
type VirtualizerValue,
|
|
1270
1301
|
} from "./virtualizer.tsx";
|
|
1302
|
+
export {
|
|
1303
|
+
Sheet,
|
|
1304
|
+
SheetBackdrop,
|
|
1305
|
+
type SheetBackdropProps,
|
|
1306
|
+
SheetContent,
|
|
1307
|
+
type SheetContentProps,
|
|
1308
|
+
SheetOverlay,
|
|
1309
|
+
type SheetOverlayProps,
|
|
1310
|
+
type SheetPosition,
|
|
1311
|
+
type SheetProps,
|
|
1312
|
+
type SheetRenderState,
|
|
1313
|
+
type SheetSnapPoint,
|
|
1314
|
+
type SheetSwipeDirection,
|
|
1315
|
+
SheetTrigger,
|
|
1316
|
+
type SheetTriggerProps,
|
|
1317
|
+
useSheet,
|
|
1318
|
+
} from "./sheet.tsx";
|
|
1319
|
+
export {
|
|
1320
|
+
loadMoreSentinel,
|
|
1321
|
+
type LoadMoreSentinelOptions,
|
|
1322
|
+
tree,
|
|
1323
|
+
Tree,
|
|
1324
|
+
TreeCollection,
|
|
1325
|
+
type TreeComponentProps,
|
|
1326
|
+
type TreeFocusMode,
|
|
1327
|
+
TreeHeader,
|
|
1328
|
+
type TreeHeaderProps,
|
|
1329
|
+
treeItem,
|
|
1330
|
+
TreeItem,
|
|
1331
|
+
type TreeItemComponentProps,
|
|
1332
|
+
TreeItemContent,
|
|
1333
|
+
type TreeItemContentProps,
|
|
1334
|
+
TreeItemDescription,
|
|
1335
|
+
type TreeItemDescriptionProps,
|
|
1336
|
+
TreeItemExpandButton,
|
|
1337
|
+
type TreeItemExpandButtonProps,
|
|
1338
|
+
type TreeItemOptions,
|
|
1339
|
+
type TreeItemRenderState,
|
|
1340
|
+
type TreeItemResult,
|
|
1341
|
+
TreeItemSelectionCheckbox,
|
|
1342
|
+
type TreeItemSelectionCheckboxProps,
|
|
1343
|
+
TreeLoadMoreItem,
|
|
1344
|
+
type TreeLoadMoreItemProps,
|
|
1345
|
+
type TreeOptions,
|
|
1346
|
+
type TreeRenderState,
|
|
1347
|
+
type TreeResult,
|
|
1348
|
+
TreeSection,
|
|
1349
|
+
type TreeSectionProps,
|
|
1350
|
+
type TreeState,
|
|
1351
|
+
treeState,
|
|
1352
|
+
type TreeStateOptions,
|
|
1353
|
+
useTree,
|
|
1354
|
+
useTreeItem,
|
|
1355
|
+
useTreeNode,
|
|
1356
|
+
} from "./tree.tsx";
|
|
1357
|
+
export {
|
|
1358
|
+
NavigationTree,
|
|
1359
|
+
NavigationTreeHeader,
|
|
1360
|
+
type NavigationTreeHeaderProps,
|
|
1361
|
+
NavigationTreeItem,
|
|
1362
|
+
NavigationTreeItemContent,
|
|
1363
|
+
type NavigationTreeItemContentProps,
|
|
1364
|
+
type NavigationTreeItemProps,
|
|
1365
|
+
type NavigationTreeItemRenderState,
|
|
1366
|
+
NavigationTreeLink,
|
|
1367
|
+
type NavigationTreeLinkProps,
|
|
1368
|
+
type NavigationTreeProps,
|
|
1369
|
+
NavigationTreeSection,
|
|
1370
|
+
type NavigationTreeSectionProps,
|
|
1371
|
+
} from "./navigation-tree.tsx";
|
|
1372
|
+
export {
|
|
1373
|
+
afterDropIndicatorTargets,
|
|
1374
|
+
autoScroll,
|
|
1375
|
+
beginDragging,
|
|
1376
|
+
clipboard,
|
|
1377
|
+
CUSTOM_DRAG_TYPE,
|
|
1378
|
+
DataTransferTypes,
|
|
1379
|
+
DIRECTORY_DRAG_TYPE,
|
|
1380
|
+
dndStrings,
|
|
1381
|
+
drag,
|
|
1382
|
+
draggableCollection,
|
|
1383
|
+
draggableCollectionState,
|
|
1384
|
+
draggableItem,
|
|
1385
|
+
dragModality,
|
|
1386
|
+
DragSession,
|
|
1387
|
+
dragSession,
|
|
1388
|
+
drop,
|
|
1389
|
+
dropIndicator,
|
|
1390
|
+
droppableCollection,
|
|
1391
|
+
droppableCollectionState,
|
|
1392
|
+
droppableItem,
|
|
1393
|
+
GENERIC_TYPE,
|
|
1394
|
+
getDragModality,
|
|
1395
|
+
getTypes,
|
|
1396
|
+
isDirectoryDropItem,
|
|
1397
|
+
isEqualDropTarget,
|
|
1398
|
+
isFileDropItem,
|
|
1399
|
+
isInternalDropOperation,
|
|
1400
|
+
isTextDropItem,
|
|
1401
|
+
isValidDropTarget,
|
|
1402
|
+
isVirtualDragging,
|
|
1403
|
+
ListDropTargetDelegate,
|
|
1404
|
+
navigateDropTarget,
|
|
1405
|
+
nextSiblingNode,
|
|
1406
|
+
previousSiblingNode,
|
|
1407
|
+
readFromDataTransfer,
|
|
1408
|
+
registerDropItem,
|
|
1409
|
+
registerDropTarget,
|
|
1410
|
+
writeToDataTransfer,
|
|
1411
|
+
type AutoScroll,
|
|
1412
|
+
type ClipboardOptions,
|
|
1413
|
+
type ClipboardResult,
|
|
1414
|
+
type DirectoryDropItem,
|
|
1415
|
+
type DragDropEvent,
|
|
1416
|
+
type DragEndEvent,
|
|
1417
|
+
type DraggableCollectionEndEvent,
|
|
1418
|
+
type DraggableCollectionMoveEvent,
|
|
1419
|
+
type DraggableCollectionOptions,
|
|
1420
|
+
type DraggableCollectionProps,
|
|
1421
|
+
type DraggableCollectionStartEvent,
|
|
1422
|
+
type DraggableCollectionState,
|
|
1423
|
+
type DraggableCollectionStateOptions,
|
|
1424
|
+
type DraggableItemOptions,
|
|
1425
|
+
type DraggableItemResult,
|
|
1426
|
+
type DragItem,
|
|
1427
|
+
type DragModality,
|
|
1428
|
+
type DragMoveEvent,
|
|
1429
|
+
type DragOptions,
|
|
1430
|
+
type DragPreviewRenderer,
|
|
1431
|
+
type DragResult,
|
|
1432
|
+
type DragStartEvent,
|
|
1433
|
+
type DragTarget,
|
|
1434
|
+
type DragType,
|
|
1435
|
+
type DragTypes,
|
|
1436
|
+
type DropActivateEvent,
|
|
1437
|
+
type DropEnterEvent,
|
|
1438
|
+
type DropEvent,
|
|
1439
|
+
type DropExitEvent,
|
|
1440
|
+
type DropIndicatorOptions,
|
|
1441
|
+
type DropIndicatorResult,
|
|
1442
|
+
type DropItem,
|
|
1443
|
+
type DropMoveEvent,
|
|
1444
|
+
type DropNavigationDirection,
|
|
1445
|
+
type DropOperation,
|
|
1446
|
+
type DropOperationEvent,
|
|
1447
|
+
type DropOptions,
|
|
1448
|
+
type DropPosition,
|
|
1449
|
+
type DroppableCollectionActivateEvent,
|
|
1450
|
+
type DroppableCollectionBaseProps,
|
|
1451
|
+
type DroppableCollectionDropEvent,
|
|
1452
|
+
type DroppableCollectionEnterEvent,
|
|
1453
|
+
type DroppableCollectionExitEvent,
|
|
1454
|
+
type DroppableCollectionInsertDropEvent,
|
|
1455
|
+
type DroppableCollectionMoveEvent,
|
|
1456
|
+
type DroppableCollectionOnItemDropEvent,
|
|
1457
|
+
type DroppableCollectionOptions,
|
|
1458
|
+
type DroppableCollectionProps,
|
|
1459
|
+
type DroppableCollectionReorderEvent,
|
|
1460
|
+
type DroppableCollectionResult,
|
|
1461
|
+
type DroppableCollectionRootDropEvent,
|
|
1462
|
+
type DroppableCollectionState,
|
|
1463
|
+
type DroppableCollectionStateOptions,
|
|
1464
|
+
type DroppableCollectionUtilityOptions,
|
|
1465
|
+
type DroppableItemOptions,
|
|
1466
|
+
type DroppableItemResult,
|
|
1467
|
+
type DropResult,
|
|
1468
|
+
type DropTarget,
|
|
1469
|
+
type DropTargetDelegate,
|
|
1470
|
+
type FileDropItem,
|
|
1471
|
+
type ItemDropTarget,
|
|
1472
|
+
type ListDropTargetDelegateOptions,
|
|
1473
|
+
type ManagedDropItem,
|
|
1474
|
+
type ManagedDropTarget,
|
|
1475
|
+
type RootDropTarget,
|
|
1476
|
+
type TextDropItem,
|
|
1477
|
+
TreeDropTargetDelegate,
|
|
1478
|
+
type TreeDropTargetState,
|
|
1479
|
+
} from "./dnd/index.ts";
|
|
1480
|
+
export {
|
|
1481
|
+
collectionDragAndDrop,
|
|
1482
|
+
dragAndDrop,
|
|
1483
|
+
DragButton,
|
|
1484
|
+
draggableItemSlotProps,
|
|
1485
|
+
DragPreview,
|
|
1486
|
+
DropIndicator,
|
|
1487
|
+
provideDragButton,
|
|
1488
|
+
provideDropIndicator,
|
|
1489
|
+
useDragAndDropContext,
|
|
1490
|
+
useDragButton,
|
|
1491
|
+
type CollectionDragAndDrop,
|
|
1492
|
+
type CollectionDragAndDropOptions,
|
|
1493
|
+
type DragAndDrop,
|
|
1494
|
+
type DragAndDropContextValue,
|
|
1495
|
+
type DragAndDropHooks,
|
|
1496
|
+
type DragAndDropOptions,
|
|
1497
|
+
type DragButtonProps,
|
|
1498
|
+
type DragButtonSlot,
|
|
1499
|
+
type DraggableItemSlotProps,
|
|
1500
|
+
type DragPreviewContent,
|
|
1501
|
+
type DragPreviewProps,
|
|
1502
|
+
type DropIndicatorContextValue,
|
|
1503
|
+
type DropIndicatorProps,
|
|
1504
|
+
dropIndicatorStyle,
|
|
1505
|
+
} from "./drag-and-drop.tsx";
|
|
1506
|
+
export {
|
|
1507
|
+
DropZone,
|
|
1508
|
+
DropZoneLabel,
|
|
1509
|
+
useDropZoneLabel,
|
|
1510
|
+
type DropZoneLabelProps,
|
|
1511
|
+
type DropZoneProps,
|
|
1512
|
+
} from "./dropzone.tsx";
|
|
1513
|
+
export {
|
|
1514
|
+
autocomplete,
|
|
1515
|
+
Autocomplete,
|
|
1516
|
+
autocompleteState,
|
|
1517
|
+
useAutocompleteCollection,
|
|
1518
|
+
useAutocompleteInput,
|
|
1519
|
+
useAutocompleteState,
|
|
1520
|
+
type AutocompleteCollection,
|
|
1521
|
+
type AutocompleteCollectionProps,
|
|
1522
|
+
type AutocompleteCollectionValue,
|
|
1523
|
+
type AutocompleteComponentProps,
|
|
1524
|
+
type AutocompleteFilter,
|
|
1525
|
+
type AutocompleteInputOptions,
|
|
1526
|
+
type AutocompleteInputValue,
|
|
1527
|
+
type AutocompleteOptions,
|
|
1528
|
+
type AutocompleteResult,
|
|
1529
|
+
type AutocompleteState,
|
|
1530
|
+
type AutocompleteStateOptions,
|
|
1531
|
+
} from "./autocomplete.tsx";
|
|
1532
|
+
export {
|
|
1533
|
+
ColorSwatchPicker,
|
|
1534
|
+
ColorSwatchPickerItem,
|
|
1535
|
+
useColorSwatchPickerItem,
|
|
1536
|
+
type ColorSwatchPickerComponentProps,
|
|
1537
|
+
type ColorSwatchPickerItemComponentProps,
|
|
1538
|
+
type ColorSwatchPickerLayout,
|
|
1539
|
+
} from "./colorswatchpicker.tsx";
|
|
1540
|
+
export {
|
|
1541
|
+
FileTrigger,
|
|
1542
|
+
useFileTrigger,
|
|
1543
|
+
type FileTriggerComponentProps,
|
|
1544
|
+
type FileTriggerValue,
|
|
1545
|
+
} from "./file-trigger.tsx";
|
|
1546
|
+
export {
|
|
1547
|
+
group,
|
|
1548
|
+
Group,
|
|
1549
|
+
type GroupComponentProps,
|
|
1550
|
+
type GroupOptions,
|
|
1551
|
+
type GroupResult,
|
|
1552
|
+
type GroupRole,
|
|
1553
|
+
} from "./group.tsx";
|
|
1554
|
+
export {
|
|
1555
|
+
OverlayArrow,
|
|
1556
|
+
overlayArrow,
|
|
1557
|
+
OverlayArrowProvider,
|
|
1558
|
+
useOverlayArrow,
|
|
1559
|
+
type OverlayArrowComponentProps,
|
|
1560
|
+
type OverlayArrowOptions,
|
|
1561
|
+
type OverlayArrowProviderProps,
|
|
1562
|
+
type OverlayArrowResult,
|
|
1563
|
+
type OverlayArrowValue,
|
|
1564
|
+
} from "./overlay-arrow.tsx";
|
|
1565
|
+
export {
|
|
1566
|
+
isPointInSafeArea,
|
|
1567
|
+
PreviewPopover,
|
|
1568
|
+
PreviewTrigger,
|
|
1569
|
+
previewTrigger,
|
|
1570
|
+
safeArea,
|
|
1571
|
+
usePreviewTrigger,
|
|
1572
|
+
type PreviewPopoverComponentProps,
|
|
1573
|
+
type PreviewTriggerComponentProps,
|
|
1574
|
+
type PreviewTriggerOptions,
|
|
1575
|
+
type PreviewTriggerResult,
|
|
1576
|
+
type PreviewTriggerValue,
|
|
1577
|
+
type SafeAreaOptions,
|
|
1578
|
+
} from "./preview-trigger.tsx";
|
|
1579
|
+
export {
|
|
1580
|
+
SelectionIndicator,
|
|
1581
|
+
SelectionIndicatorProvider,
|
|
1582
|
+
useSelectionIndicator,
|
|
1583
|
+
type SelectionIndicatorComponentProps,
|
|
1584
|
+
type SelectionIndicatorProviderProps,
|
|
1585
|
+
type SelectionIndicatorValue,
|
|
1586
|
+
} from "./selection-indicator.tsx";
|
|
1587
|
+
export {
|
|
1588
|
+
SharedElement,
|
|
1589
|
+
sharedElement,
|
|
1590
|
+
SharedElementTransition,
|
|
1591
|
+
useSharedElementScope,
|
|
1592
|
+
type SharedElementComponentProps,
|
|
1593
|
+
type SharedElementOptions,
|
|
1594
|
+
type SharedElementPhase,
|
|
1595
|
+
type SharedElementResult,
|
|
1596
|
+
type SharedElementScope,
|
|
1597
|
+
type SharedElementTransitionComponentProps,
|
|
1598
|
+
} from "./shared-element-transition.tsx";
|
|
1599
|
+
export {
|
|
1600
|
+
TextArea,
|
|
1601
|
+
textArea,
|
|
1602
|
+
type TextAreaComponentProps,
|
|
1603
|
+
type TextAreaOptions,
|
|
1604
|
+
type TextAreaResult,
|
|
1605
|
+
} from "./textarea.tsx";
|
|
1606
|
+
export {
|
|
1607
|
+
ToastBody,
|
|
1608
|
+
ToastCloseButton,
|
|
1609
|
+
ToastDescription,
|
|
1610
|
+
ToastList,
|
|
1611
|
+
ToastRegion,
|
|
1612
|
+
toastRegion,
|
|
1613
|
+
ToastRoot,
|
|
1614
|
+
toastRoot,
|
|
1615
|
+
ToastTitle,
|
|
1616
|
+
useToastRoot,
|
|
1617
|
+
type ToastCloseButtonComponentProps,
|
|
1618
|
+
type ToastListComponentProps,
|
|
1619
|
+
type ToastPartComponentProps,
|
|
1620
|
+
type ToastRegionComponentProps,
|
|
1621
|
+
type ToastRegionOptions,
|
|
1622
|
+
type ToastRegionResult,
|
|
1623
|
+
type ToastRootComponentProps,
|
|
1624
|
+
type ToastRootOptions,
|
|
1625
|
+
type ToastRootResult,
|
|
1626
|
+
} from "./toast-components.tsx";
|
|
1627
|
+
export {
|
|
1628
|
+
ToggleButtonGroup,
|
|
1629
|
+
ToggleButtonGroupItem,
|
|
1630
|
+
useToggleButtonGroup,
|
|
1631
|
+
type ToggleButtonGroupComponentProps,
|
|
1632
|
+
type ToggleButtonGroupItemComponentProps,
|
|
1633
|
+
} from "./toggle-button-group.tsx";
|
|
1634
|
+
export {
|
|
1635
|
+
getTokenFieldSelectedRange,
|
|
1636
|
+
getTokenFieldSelection,
|
|
1637
|
+
SelectedRange,
|
|
1638
|
+
setTokenFieldSelection,
|
|
1639
|
+
token,
|
|
1640
|
+
Token,
|
|
1641
|
+
TokenDirection,
|
|
1642
|
+
TokenField,
|
|
1643
|
+
tokenField,
|
|
1644
|
+
tokenFieldPositionToDOMRange,
|
|
1645
|
+
tokenFieldState,
|
|
1646
|
+
TokenFieldValue,
|
|
1647
|
+
TokenInput,
|
|
1648
|
+
type Position,
|
|
1649
|
+
type TextSegment,
|
|
1650
|
+
type TokenComponentProps,
|
|
1651
|
+
type TokenFieldComponentProps,
|
|
1652
|
+
type TokenFieldOptions,
|
|
1653
|
+
type TokenFieldResult,
|
|
1654
|
+
type TokenFieldRole,
|
|
1655
|
+
type TokenFieldSegment,
|
|
1656
|
+
type TokenFieldState,
|
|
1657
|
+
type TokenFieldStateOptions,
|
|
1658
|
+
type TokenFieldValueOptions,
|
|
1659
|
+
type TokenInputComponentProps,
|
|
1660
|
+
type TokenResult,
|
|
1661
|
+
type TokenSegment,
|
|
1662
|
+
} from "./tokenfield.tsx";
|
|
1663
|
+
export {
|
|
1664
|
+
canonicalKeyboardShortcut,
|
|
1665
|
+
createKeyboardShortcutHandler,
|
|
1666
|
+
keyboardEventToCanonicalShortcut,
|
|
1667
|
+
type KeyboardShortcutAction,
|
|
1668
|
+
type KeyboardShortcutBindings,
|
|
1669
|
+
parseKeyboardShortcut,
|
|
1670
|
+
type ParsedKeyboardShortcut,
|
|
1671
|
+
} from "./interactions/keyboard.ts";
|
|
1672
|
+
export { type RouterConfig, type RouterOptions } from "./interactions/open-link.ts";
|
|
@@ -157,6 +157,14 @@ export interface FocusWithinResult {
|
|
|
157
157
|
*/
|
|
158
158
|
export function focusWithin(options: FocusWithinOptions = {}): FocusWithinResult {
|
|
159
159
|
const [isFocusWithin, setIsFocusWithin] = createSignal(false);
|
|
160
|
+
// What the handlers test. The signal is for readers: a write to it lands at
|
|
161
|
+
// the next flush, and a handler that passes focus on to a child sends a
|
|
162
|
+
// second arrival before then, which the signal would report as the first.
|
|
163
|
+
let within = false;
|
|
164
|
+
const setWithin = (next: boolean): void => {
|
|
165
|
+
within = next;
|
|
166
|
+
setIsFocusWithin(next);
|
|
167
|
+
};
|
|
160
168
|
const listeners = globalListeners();
|
|
161
169
|
|
|
162
170
|
const onBlur = (event: FocusEvent): void => {
|
|
@@ -165,9 +173,9 @@ export function focusWithin(options: FocusWithinOptions = {}): FocusWithinResult
|
|
|
165
173
|
|
|
166
174
|
// Focus moving between two children is not leaving. `relatedTarget` is
|
|
167
175
|
// where it is going.
|
|
168
|
-
if (!
|
|
176
|
+
if (!within || contains(currentTarget, event.relatedTarget as Element | null)) return;
|
|
169
177
|
|
|
170
|
-
|
|
178
|
+
setWithin(false);
|
|
171
179
|
listeners.removeAll();
|
|
172
180
|
options.onBlurWithin?.(event);
|
|
173
181
|
options.onFocusWithinChange?.(false);
|
|
@@ -179,11 +187,11 @@ export function focusWithin(options: FocusWithinOptions = {}): FocusWithinResult
|
|
|
179
187
|
|
|
180
188
|
const target = targetElement(event);
|
|
181
189
|
const doc = ownerDocument(target);
|
|
182
|
-
if (
|
|
190
|
+
if (within || activeElement(doc) !== target) return;
|
|
183
191
|
|
|
192
|
+
setWithin(true);
|
|
184
193
|
options.onFocusWithin?.(event);
|
|
185
194
|
options.onFocusWithinChange?.(true);
|
|
186
|
-
setIsFocusWithin(true);
|
|
187
195
|
|
|
188
196
|
// No blur fires when the focused element is removed. A focus landing
|
|
189
197
|
// outside is the evidence that it left.
|
|
@@ -192,7 +200,7 @@ export function focusWithin(options: FocusWithinOptions = {}): FocusWithinResult
|
|
|
192
200
|
"focus",
|
|
193
201
|
(moved: Event) => {
|
|
194
202
|
const next = targetElement(moved);
|
|
195
|
-
if (!
|
|
203
|
+
if (!within || contains(currentTarget, next)) return;
|
|
196
204
|
const synthetic = new FocusEvent("blur", { relatedTarget: next });
|
|
197
205
|
Object.defineProperty(synthetic, "target", { value: currentTarget });
|
|
198
206
|
Object.defineProperty(synthetic, "currentTarget", { value: currentTarget });
|