@sentry/scraps 0.4.0 → 0.5.0
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 +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +242 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -6
- package/dist/menu/menu.js +160 -56
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/package.json +115 -16
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useGridListItem, useGridListSelectionCheckbox } from "@react-aria/gridlist";
|
|
4
|
+
import { useFocusWithin, useHover } from "@react-aria/interactions";
|
|
5
|
+
import { mergeProps } from "@react-aria/utils";
|
|
6
|
+
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
7
|
+
import { Checkbox } from "../../checkbox/index.js";
|
|
8
|
+
import { HighlightText } from "../highlightText.js";
|
|
9
|
+
import { LeadWrap, getOptionPaddingLeft } from "../styles.js";
|
|
10
|
+
import { ControlContext, ListItem, useReserveLeadingSlot } from "../../menu/index.js";
|
|
11
|
+
function GridListOption({ node, listState, size }) {
|
|
12
|
+
const ref = useRef(null);
|
|
13
|
+
const { label, details, trailingItems, priority, hideCheck, tooltip, tooltipOptions, selectionMode } = node.props;
|
|
14
|
+
const multiple = selectionMode ? 'multiple' === selectionMode : 'multiple' === listState.selectionManager.selectionMode;
|
|
15
|
+
const { rowProps, gridCellProps, isSelected, isDisabled, isPressed, isFocused } = useGridListItem({
|
|
16
|
+
node,
|
|
17
|
+
shouldSelectOnPressUp: true
|
|
18
|
+
}, listState, ref);
|
|
19
|
+
const { search, highlightSearch } = useContext(ControlContext);
|
|
20
|
+
const renderedLabel = highlightSearch && search && 'string' == typeof label ? /*#__PURE__*/ jsx(HighlightText, {
|
|
21
|
+
text: label,
|
|
22
|
+
query: search
|
|
23
|
+
}) : label;
|
|
24
|
+
const { checkboxProps: { isDisabled: _isDisabled, isSelected: _isSelected, onChange: _onChange, ...checkboxProps } } = useGridListSelectionCheckbox({
|
|
25
|
+
key: node.key
|
|
26
|
+
}, listState);
|
|
27
|
+
const { hoverProps } = useHover({
|
|
28
|
+
onHoverStart: ()=>ref.current?.focus({
|
|
29
|
+
preventScroll: true
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
const [isFocusWithin, setFocusWithin] = useState(false);
|
|
33
|
+
const { focusWithinProps } = useFocusWithin({
|
|
34
|
+
onFocusWithinChange: setFocusWithin
|
|
35
|
+
});
|
|
36
|
+
const rowPropsMerged = mergeProps(rowProps, hoverProps, focusWithinProps);
|
|
37
|
+
const labelPropsMemo = useMemo(()=>({
|
|
38
|
+
as: 'string' == typeof label ? 'p' : 'div'
|
|
39
|
+
}), [
|
|
40
|
+
label
|
|
41
|
+
]);
|
|
42
|
+
const reserveLeadingSlot = useReserveLeadingSlot();
|
|
43
|
+
const { leadingItems } = node.props;
|
|
44
|
+
const leadingItemsMemo = useMemo(()=>{
|
|
45
|
+
const checkboxSize = 'xs' === size ? 'xs' : 'sm';
|
|
46
|
+
const leading = 'function' == typeof leadingItems ? leadingItems({
|
|
47
|
+
disabled: isDisabled,
|
|
48
|
+
isFocused,
|
|
49
|
+
isSelected
|
|
50
|
+
}) : leadingItems;
|
|
51
|
+
if (hideCheck) return leading;
|
|
52
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsx(LeadWrap, {
|
|
55
|
+
role: "presentation",
|
|
56
|
+
children: multiple ? /*#__PURE__*/ jsx(Checkbox, {
|
|
57
|
+
...checkboxProps,
|
|
58
|
+
size: checkboxSize,
|
|
59
|
+
checked: isSelected,
|
|
60
|
+
disabled: isDisabled,
|
|
61
|
+
readOnly: true
|
|
62
|
+
}) : isSelected && /*#__PURE__*/ jsx(IconCheckmark, {
|
|
63
|
+
size: checkboxSize,
|
|
64
|
+
variant: "accent",
|
|
65
|
+
...checkboxProps
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
leading || reserveLeadingSlot ? /*#__PURE__*/ jsx(LeadWrap, {
|
|
69
|
+
role: "presentation",
|
|
70
|
+
minWidth: reserveLeadingSlot ? '16px' : void 0,
|
|
71
|
+
children: leading
|
|
72
|
+
}) : null
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}, [
|
|
76
|
+
multiple,
|
|
77
|
+
isSelected,
|
|
78
|
+
isDisabled,
|
|
79
|
+
isFocused,
|
|
80
|
+
size,
|
|
81
|
+
leadingItems,
|
|
82
|
+
hideCheck,
|
|
83
|
+
reserveLeadingSlot
|
|
84
|
+
]);
|
|
85
|
+
return /*#__PURE__*/ jsx(ListItem, {
|
|
86
|
+
...rowPropsMerged,
|
|
87
|
+
ref: ref,
|
|
88
|
+
size: size,
|
|
89
|
+
label: renderedLabel,
|
|
90
|
+
details: details,
|
|
91
|
+
disabled: isDisabled,
|
|
92
|
+
isSelected: isSelected,
|
|
93
|
+
isPressed: isPressed,
|
|
94
|
+
isFocused: isFocusWithin,
|
|
95
|
+
priority: priority ? 'primary' : 'default',
|
|
96
|
+
innerWrapProps: {
|
|
97
|
+
...gridCellProps,
|
|
98
|
+
paddingLeft: getOptionPaddingLeft({
|
|
99
|
+
hasCheck: !hideCheck,
|
|
100
|
+
hasLeadingItems: Boolean(leadingItems) || reserveLeadingSlot
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
labelProps: labelPropsMemo,
|
|
104
|
+
leadingItems: leadingItemsMemo,
|
|
105
|
+
trailingItems: trailingItems,
|
|
106
|
+
tooltip: tooltip,
|
|
107
|
+
tooltipOptions: tooltipOptions,
|
|
108
|
+
"data-test-id": node.key
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export { GridListOption };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ListState } from '@react-stately/list';
|
|
2
|
+
import type { Node } from '@react-types/shared';
|
|
3
|
+
import type { ListItemBase } from '../types.js';
|
|
4
|
+
import { type GridListOptionProps } from './option.js';
|
|
5
|
+
interface GridListSectionProps<T extends ListItemBase> {
|
|
6
|
+
listState: ListState<T>;
|
|
7
|
+
node: Node<T>;
|
|
8
|
+
size: GridListOptionProps<T>['size'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A <li /> element that functions as a grid list section (renders a nested <ul />
|
|
12
|
+
* inside). https://react-spectrum.adobe.com/react-aria/useGridList.html
|
|
13
|
+
*/
|
|
14
|
+
export declare function GridListSection<T extends ListItemBase>({ node, listState, size, }: GridListSectionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useContext, useId, useMemo } from "react";
|
|
3
|
+
import { useSeparator } from "@react-aria/separator";
|
|
4
|
+
import { SelectFilterContext } from "../selectFilterContext.js";
|
|
5
|
+
import { SectionSeparator } from "../styles.js";
|
|
6
|
+
import { SectionToggle } from "../utils.js";
|
|
7
|
+
import { SectionGroup, SectionHeader, SectionLabel, SectionList } from "../../menu/index.js";
|
|
8
|
+
import { GridListOption } from "./option.js";
|
|
9
|
+
function GridListSection({ node, listState, size }) {
|
|
10
|
+
const titleId = useId();
|
|
11
|
+
const { separatorProps } = useSeparator({
|
|
12
|
+
elementType: 'li'
|
|
13
|
+
});
|
|
14
|
+
const showToggleAllButton = 'multiple' === listState.selectionManager.selectionMode && node.value?.showToggleAllButton;
|
|
15
|
+
const hiddenOptions = useContext(SelectFilterContext);
|
|
16
|
+
const childNodes = useMemo(()=>[
|
|
17
|
+
...node.childNodes
|
|
18
|
+
].filter((child)=>!hiddenOptions.has(child.key)), [
|
|
19
|
+
node.childNodes,
|
|
20
|
+
hiddenOptions
|
|
21
|
+
]);
|
|
22
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ jsx(SectionSeparator, {
|
|
25
|
+
...separatorProps
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsxs(SectionGroup, {
|
|
28
|
+
role: "rowgroup",
|
|
29
|
+
...node['aria-label'] ? {
|
|
30
|
+
'aria-label': node['aria-label']
|
|
31
|
+
} : {
|
|
32
|
+
'aria-labelledby': titleId
|
|
33
|
+
},
|
|
34
|
+
children: [
|
|
35
|
+
(node.rendered || showToggleAllButton) && /*#__PURE__*/ jsx(SectionHeader, {
|
|
36
|
+
trailingAction: showToggleAllButton ? /*#__PURE__*/ jsx(SectionToggle, {
|
|
37
|
+
item: node,
|
|
38
|
+
listState: listState
|
|
39
|
+
}) : null,
|
|
40
|
+
children: node.rendered && /*#__PURE__*/ jsx(SectionLabel, {
|
|
41
|
+
id: titleId,
|
|
42
|
+
"aria-hidden": true,
|
|
43
|
+
children: node.rendered
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ jsx(SectionList, {
|
|
47
|
+
children: childNodes.map((child)=>/*#__PURE__*/ jsx(GridListOption, {
|
|
48
|
+
node: child,
|
|
49
|
+
listState: listState,
|
|
50
|
+
size: size
|
|
51
|
+
}, child.key))
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export { GridListSection };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Text } from "../text/index.js";
|
|
4
|
+
function HighlightText({ query, text }) {
|
|
5
|
+
const trimmedQuery = query.trim();
|
|
6
|
+
if (!trimmedQuery || !text) return text;
|
|
7
|
+
const matchIndex = text.toLowerCase().indexOf(trimmedQuery.toLowerCase());
|
|
8
|
+
if (-1 === matchIndex) return text;
|
|
9
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
10
|
+
as: "span",
|
|
11
|
+
"aria-label": text,
|
|
12
|
+
children: /*#__PURE__*/ jsxs(Text, {
|
|
13
|
+
as: "span",
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: [
|
|
16
|
+
text.slice(0, matchIndex),
|
|
17
|
+
/*#__PURE__*/ jsx(HighlightedMatch, {
|
|
18
|
+
as: "span",
|
|
19
|
+
variant: "warning",
|
|
20
|
+
"data-test-id": "sqb-highlighted-match",
|
|
21
|
+
children: text.slice(matchIndex, matchIndex + trimmedQuery.length)
|
|
22
|
+
}),
|
|
23
|
+
text.slice(matchIndex + trimmedQuery.length)
|
|
24
|
+
]
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const HighlightedMatch = styled(Text)`
|
|
29
|
+
background: ${(p)=>p.theme.tokens.background.transparent.warning.muted};
|
|
30
|
+
border-radius: ${(p)=>p.theme.radius.sm};
|
|
31
|
+
padding: 0 1px;
|
|
32
|
+
`;
|
|
33
|
+
export { HighlightText };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { CompactSelect, type SelectProps, type SingleSelectProps, type MultipleSelectProps, type SelectOption, type SelectOptionOrSection, type SelectSection, type SelectKey, } from './compactSelect.js';
|
|
2
|
+
export { CompositeSelect } from './composite.js';
|
|
3
|
+
export { HighlightText } from './highlightText.js';
|
|
4
|
+
export { MenuComponents } from './menuComponents.js';
|
|
5
|
+
export { LeadWrap, ListWrap } from './styles.js';
|
|
6
|
+
export type { SelectOptionOrSectionWithKey, SelectOptionWithKey, SelectSectionWithKey, SearchMatchResult, } from './types.js';
|
|
7
|
+
export { getItemsWithKeys, getDisabledOptions, getHiddenOptions, itemIsSectionWithKey, getEscapedKey, } from './utils.js';
|
|
8
|
+
export { TriggerLabel } from './control.js';
|
|
9
|
+
export { ListBox } from './listBox/index.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CompactSelect } from "./compactSelect.js";
|
|
2
|
+
export { CompositeSelect } from "./composite.js";
|
|
3
|
+
export { HighlightText } from "./highlightText.js";
|
|
4
|
+
export { MenuComponents } from "./menuComponents.js";
|
|
5
|
+
export { LeadWrap, ListWrap } from "./styles.js";
|
|
6
|
+
export { getDisabledOptions, getEscapedKey, getHiddenOptions, getItemsWithKeys, itemIsSectionWithKey } from "./utils.js";
|
|
7
|
+
export { TriggerLabel } from "./control.js";
|
|
8
|
+
export { ListBox } from "./listBox/index.js";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AriaGridListOptions } from '@react-aria/gridlist';
|
|
3
|
+
import type { AriaListBoxOptions } from '@react-aria/listbox';
|
|
4
|
+
import type { ListProps } from '@react-stately/list';
|
|
5
|
+
import type { FormSize } from '../theme/index.js';
|
|
6
|
+
import type { SelectKey, SelectOption, SelectOptionOrSectionWithKey, SelectOptionWithKey } from './types.js';
|
|
7
|
+
interface BaseListProps<Value extends SelectKey> extends Omit<ListProps<any>, 'disallowEmptySelection'>, Omit<AriaListBoxOptions<any>, 'disallowEmptySelection' | 'disabledKeys' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'autoFocus' | 'shouldUseVirtualFocus' | 'isVirtualized'>, Omit<AriaGridListOptions<any>, 'disallowEmptySelection' | 'disabledKeys' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'autoFocus' | 'shouldUseVirtualFocus' | 'isVirtualized'> {
|
|
8
|
+
items: Array<SelectOptionOrSectionWithKey<Value>>;
|
|
9
|
+
/**
|
|
10
|
+
* Custom function to determine whether an option is disabled. By default, an option
|
|
11
|
+
* is considered disabled when it has {disabled: true}.
|
|
12
|
+
*/
|
|
13
|
+
isOptionDisabled?: (opt: SelectOptionWithKey<Value>) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Text label to be rendered as heading on top of grid list.
|
|
16
|
+
*/
|
|
17
|
+
label?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Controls the selection widget type.
|
|
20
|
+
*
|
|
21
|
+
* - `'list'` (default) — a one-dimensional listbox navigated with Arrow Up/Down.
|
|
22
|
+
* - `'grid'` — a two-dimensional grid list where Arrow Up/Down moves between rows
|
|
23
|
+
* and Arrow Left/Right moves between columns. Use this when options contain
|
|
24
|
+
* interactive child elements (buttons/links) that need to be keyboard-reachable.
|
|
25
|
+
*/
|
|
26
|
+
mode?: 'list' | 'grid';
|
|
27
|
+
size?: FormSize;
|
|
28
|
+
/**
|
|
29
|
+
* Upper limit for the number of options to display in the menu at a time. Users can
|
|
30
|
+
* still find overflowing options by using the search box (if `searchable` is true).
|
|
31
|
+
* If used, make sure to hoist selected options to the top, otherwise they may be
|
|
32
|
+
* hidden from view.
|
|
33
|
+
*/
|
|
34
|
+
sizeLimit?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Message to be displayed when some options are hidden due to `sizeLimit`.
|
|
37
|
+
*/
|
|
38
|
+
sizeLimitMessage?: string;
|
|
39
|
+
/**
|
|
40
|
+
* If true, virtualization will be enabled for the list
|
|
41
|
+
*/
|
|
42
|
+
virtualized?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A single-selection (only one option can be selected at a time) list that allows
|
|
46
|
+
* clearing the selection.
|
|
47
|
+
* `value` can be `undefined` to represent no selection.
|
|
48
|
+
*/
|
|
49
|
+
interface SingleClearableListProps<Value extends SelectKey> extends BaseListProps<Value> {
|
|
50
|
+
/**
|
|
51
|
+
* If true, there will be a "Clear" button in the menu header.
|
|
52
|
+
*/
|
|
53
|
+
clearable: true;
|
|
54
|
+
onChange: (selectedOption: SelectOption<Value> | undefined) => void;
|
|
55
|
+
value: Value | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to close the menu. Accepts either a boolean value or a callback function
|
|
58
|
+
* that receives the newly selected option and returns whether to close the menu.
|
|
59
|
+
*/
|
|
60
|
+
closeOnSelect?: boolean | ((selectedOption: SelectOption<Value> | undefined) => boolean);
|
|
61
|
+
multiple?: false;
|
|
62
|
+
}
|
|
63
|
+
export type SingleListProps<Value extends SelectKey> = SingleClearableListProps<Value> | SingleUnclearableListProps<Value>;
|
|
64
|
+
interface SingleUnclearableListProps<Value extends SelectKey> extends BaseListProps<Value> {
|
|
65
|
+
onChange: (selectedOption: SelectOption<Value>) => void;
|
|
66
|
+
value: Value | undefined;
|
|
67
|
+
clearable?: false;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to close the menu. Accepts either a boolean value or a callback function
|
|
70
|
+
* that receives the newly selected option and returns whether to close the menu.
|
|
71
|
+
*/
|
|
72
|
+
closeOnSelect?: boolean | ((selectedOption: SelectOption<Value>) => boolean);
|
|
73
|
+
multiple?: false;
|
|
74
|
+
}
|
|
75
|
+
export interface MultipleListProps<Value extends SelectKey> extends BaseListProps<Value> {
|
|
76
|
+
multiple: true;
|
|
77
|
+
onChange: (selectedOptions: Array<SelectOption<Value>>) => void;
|
|
78
|
+
value: Value[] | undefined;
|
|
79
|
+
clearable?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Whether to close the menu. Accepts either a boolean value or a callback function
|
|
82
|
+
* that receives the newly selected options and returns whether to close the menu.
|
|
83
|
+
*/
|
|
84
|
+
closeOnSelect?: boolean | ((selectedOptions: Array<SelectOption<Value>>) => boolean);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A list containing selectable options. Depending on the `mode` prop, this may be a
|
|
88
|
+
* grid list or list box.
|
|
89
|
+
*
|
|
90
|
+
* In composite selectors, there may be multiple self-contained lists, each
|
|
91
|
+
* representing a select "region".
|
|
92
|
+
*/
|
|
93
|
+
export declare function List<Value extends SelectKey>({ items, value, onChange, mode, multiple, clearable, isOptionDisabled, shouldFocusWrap, shouldFocusOnHover, sizeLimit, sizeLimitMessage, closeOnSelect, ...props }: SingleListProps<Value> | MultipleListProps<Value>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useContext, useId, useMemo } from "react";
|
|
3
|
+
import { useFocusManager } from "@react-aria/focus";
|
|
4
|
+
import { useListState } from "@react-stately/list";
|
|
5
|
+
import { ControlContext } from "../menu/index.js";
|
|
6
|
+
import { GridList } from "./gridList/index.js";
|
|
7
|
+
import { ListBox } from "./listBox/index.js";
|
|
8
|
+
import { SelectFilterContext } from "./selectFilterContext.js";
|
|
9
|
+
import { HiddenSectionToggle, getDisabledOptions, getEscapedKey, getHiddenOptions, getSelectedOptions, getSortedItems, shouldCloseOnSelect } from "./utils.js";
|
|
10
|
+
function List({ items, value, onChange, mode = 'list', multiple, clearable, isOptionDisabled, shouldFocusWrap = true, shouldFocusOnHover = true, sizeLimit, sizeLimitMessage, closeOnSelect, ...props }) {
|
|
11
|
+
const { overlayState, search, searchable, overlayIsOpen, searchMatcher } = useContext(ControlContext);
|
|
12
|
+
const hasSections = useMemo(()=>items.some((item)=>'options' in item), [
|
|
13
|
+
items
|
|
14
|
+
]);
|
|
15
|
+
const isFlatCollectionTruncated = searchable && !hasSections && !search && void 0 !== sizeLimit && items.length > sizeLimit;
|
|
16
|
+
const { hidden: hiddenOptions, scores } = useMemo(()=>isFlatCollectionTruncated ? {
|
|
17
|
+
hidden: new Set(),
|
|
18
|
+
scores: new Map()
|
|
19
|
+
} : getHiddenOptions(items, search, sizeLimit, searchMatcher), [
|
|
20
|
+
isFlatCollectionTruncated,
|
|
21
|
+
items,
|
|
22
|
+
search,
|
|
23
|
+
sizeLimit,
|
|
24
|
+
searchMatcher
|
|
25
|
+
]);
|
|
26
|
+
const sortedItems = useMemo(()=>scores.size > 0 ? getSortedItems(items, scores) : items, [
|
|
27
|
+
items,
|
|
28
|
+
scores
|
|
29
|
+
]);
|
|
30
|
+
const collectionItems = useMemo(()=>isFlatCollectionTruncated ? sortedItems.slice(0, sizeLimit) : sortedItems, [
|
|
31
|
+
isFlatCollectionTruncated,
|
|
32
|
+
sizeLimit,
|
|
33
|
+
sortedItems
|
|
34
|
+
]);
|
|
35
|
+
const listStateProps = useMemo(()=>{
|
|
36
|
+
const disabledKeys = [
|
|
37
|
+
...getDisabledOptions(collectionItems, isOptionDisabled),
|
|
38
|
+
...hiddenOptions
|
|
39
|
+
];
|
|
40
|
+
if (multiple) return {
|
|
41
|
+
selectionMode: 'multiple',
|
|
42
|
+
disabledKeys,
|
|
43
|
+
selectedKeys: value?.map(getEscapedKey) ?? [],
|
|
44
|
+
allowDuplicateSelectionEvents: true,
|
|
45
|
+
onSelectionChange: (selection)=>{
|
|
46
|
+
const selectedOptions = getSelectedOptions(items, selection);
|
|
47
|
+
onChange?.(selectedOptions);
|
|
48
|
+
if (shouldCloseOnSelect({
|
|
49
|
+
multiple,
|
|
50
|
+
closeOnSelect,
|
|
51
|
+
selectedOptions
|
|
52
|
+
})) overlayState?.close();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
selectionMode: 'single',
|
|
57
|
+
disabledKeys,
|
|
58
|
+
selectedKeys: null == value ? [] : [
|
|
59
|
+
getEscapedKey(value)
|
|
60
|
+
],
|
|
61
|
+
disallowEmptySelection: !clearable,
|
|
62
|
+
allowDuplicateSelectionEvents: true,
|
|
63
|
+
onSelectionChange: (selection)=>{
|
|
64
|
+
const selectedOption = getSelectedOptions(items, selection)[0];
|
|
65
|
+
onChange?.(selectedOption);
|
|
66
|
+
if (shouldCloseOnSelect({
|
|
67
|
+
multiple,
|
|
68
|
+
closeOnSelect,
|
|
69
|
+
selectedOptions: [
|
|
70
|
+
selectedOption
|
|
71
|
+
]
|
|
72
|
+
})) overlayState?.close();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
value,
|
|
77
|
+
onChange,
|
|
78
|
+
items,
|
|
79
|
+
collectionItems,
|
|
80
|
+
isOptionDisabled,
|
|
81
|
+
hiddenOptions,
|
|
82
|
+
multiple,
|
|
83
|
+
clearable,
|
|
84
|
+
closeOnSelect,
|
|
85
|
+
overlayState
|
|
86
|
+
]);
|
|
87
|
+
const listState = useListState({
|
|
88
|
+
...props,
|
|
89
|
+
...listStateProps,
|
|
90
|
+
items: collectionItems
|
|
91
|
+
});
|
|
92
|
+
const focusManager = useFocusManager();
|
|
93
|
+
const firstFocusableKey = useMemo(()=>{
|
|
94
|
+
let firstKey = listState.collection.getFirstKey();
|
|
95
|
+
while(firstKey && (listState.collection.getItem(firstKey)?.type === 'section' || listState.selectionManager.isDisabled(firstKey)))firstKey = listState.collection.getKeyAfter(firstKey);
|
|
96
|
+
return firstKey;
|
|
97
|
+
}, [
|
|
98
|
+
listState.collection,
|
|
99
|
+
listState.selectionManager
|
|
100
|
+
]);
|
|
101
|
+
const lastFocusableKey = useMemo(()=>{
|
|
102
|
+
let lastKey = listState.collection.getLastKey();
|
|
103
|
+
while(lastKey && (listState.collection.getItem(lastKey)?.type === 'section' || listState.selectionManager.isDisabled(lastKey)))lastKey = listState.collection.getKeyBefore(lastKey);
|
|
104
|
+
return lastKey;
|
|
105
|
+
}, [
|
|
106
|
+
listState.collection,
|
|
107
|
+
listState.selectionManager
|
|
108
|
+
]);
|
|
109
|
+
const keyDownHandler = (e)=>{
|
|
110
|
+
if (shouldFocusWrap && 'grid' !== mode) return true;
|
|
111
|
+
if ('ArrowDown' === e.key && listState.selectionManager.focusedKey === lastFocusableKey) {
|
|
112
|
+
focusManager?.focusNext({
|
|
113
|
+
wrap: true,
|
|
114
|
+
accept: (element)=>('option' === element.getAttribute('role') || 'row' === element.getAttribute('role')) && 'true' !== element.getAttribute('aria-disabled')
|
|
115
|
+
});
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if ('ArrowUp' === e.key && listState.selectionManager.focusedKey === firstFocusableKey) {
|
|
119
|
+
focusManager?.focusPrevious({
|
|
120
|
+
wrap: true,
|
|
121
|
+
accept: (element)=>('option' === element.getAttribute('role') || 'row' === element.getAttribute('role')) && 'true' !== element.getAttribute('aria-disabled')
|
|
122
|
+
});
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
};
|
|
127
|
+
const listId = useId();
|
|
128
|
+
const sections = useMemo(()=>[
|
|
129
|
+
...listState.collection
|
|
130
|
+
].filter((item)=>'section' === item.type && ![
|
|
131
|
+
...item.childNodes
|
|
132
|
+
].every((child)=>hiddenOptions.has(child.key))), [
|
|
133
|
+
listState.collection,
|
|
134
|
+
hiddenOptions
|
|
135
|
+
]);
|
|
136
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
137
|
+
children: [
|
|
138
|
+
'grid' === mode ? /*#__PURE__*/ jsx(SelectFilterContext, {
|
|
139
|
+
value: hiddenOptions,
|
|
140
|
+
children: /*#__PURE__*/ jsx(GridList, {
|
|
141
|
+
...props,
|
|
142
|
+
id: listId,
|
|
143
|
+
listState: listState,
|
|
144
|
+
sizeLimitMessage: sizeLimitMessage,
|
|
145
|
+
keyDownHandler: keyDownHandler
|
|
146
|
+
})
|
|
147
|
+
}) : /*#__PURE__*/ jsx(ListBox, {
|
|
148
|
+
...props,
|
|
149
|
+
searchable: searchable,
|
|
150
|
+
overlayIsOpen: overlayIsOpen,
|
|
151
|
+
hiddenOptions: hiddenOptions,
|
|
152
|
+
id: listId,
|
|
153
|
+
listState: listState,
|
|
154
|
+
shouldFocusWrap: shouldFocusWrap,
|
|
155
|
+
shouldFocusOnHover: shouldFocusOnHover,
|
|
156
|
+
sizeLimitMessage: sizeLimitMessage,
|
|
157
|
+
keyDownHandler: keyDownHandler
|
|
158
|
+
}),
|
|
159
|
+
multiple && sections.map((section)=>section.value?.showToggleAllButton ? /*#__PURE__*/ jsx(HiddenSectionToggle, {
|
|
160
|
+
item: section,
|
|
161
|
+
listState: listState,
|
|
162
|
+
listId: listId
|
|
163
|
+
}, section.key) : null)
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
export { List };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AriaListBoxOptions } from '@react-aria/listbox';
|
|
3
|
+
import type { ListState } from '@react-stately/list';
|
|
4
|
+
import type { CollectionChildren } from '@react-types/shared';
|
|
5
|
+
import type { SelectKey, ListItemBase } from '../types.js';
|
|
6
|
+
import type { FormSize } from '../../theme/index.js';
|
|
7
|
+
interface ListBoxProps<T extends ListItemBase> extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onBlur' | 'onFocus' | 'autoFocus' | 'children'>, Omit<AriaListBoxOptions<any>, 'children' | 'items' | 'disabledKeys' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'isVirtualized'> {
|
|
8
|
+
/**
|
|
9
|
+
* Object containing the selection state and focus position, needed for
|
|
10
|
+
* `useListBox()`.
|
|
11
|
+
*/
|
|
12
|
+
listState: ListState<T>;
|
|
13
|
+
children?: CollectionChildren<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the list is filtered by search query or not.
|
|
16
|
+
* Used to determine whether to show the size limit message or not.
|
|
17
|
+
*/
|
|
18
|
+
hasSearch?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Set of keys that are hidden from the user (e.g. because not matching search query)
|
|
21
|
+
*/
|
|
22
|
+
hiddenOptions?: Set<SelectKey>;
|
|
23
|
+
/**
|
|
24
|
+
* Keyboard event handler, to be attached to the list (`ul`) element, to seamlessly
|
|
25
|
+
* move focus from one composite list to another when an arrow key is pressed. Returns
|
|
26
|
+
* a boolean indicating whether the keyboard event was intercepted. If yes, then no
|
|
27
|
+
* further callback function should be run.
|
|
28
|
+
*/
|
|
29
|
+
keyDownHandler?: (e: React.KeyboardEvent<HTMLUListElement>) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Text label to be rendered as heading on top of grid list.
|
|
32
|
+
*/
|
|
33
|
+
label?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Used to determine whether to render the list box items or not
|
|
36
|
+
*/
|
|
37
|
+
overlayIsOpen?: boolean;
|
|
38
|
+
ref?: React.Ref<HTMLUListElement>;
|
|
39
|
+
/**
|
|
40
|
+
* Ref forwarded to the inner scroll container div (the element the virtualizer
|
|
41
|
+
* uses as its scroll element). Useful for callers that need to reset scrollTop.
|
|
42
|
+
*/
|
|
43
|
+
scrollContainerRef?: React.Ref<HTMLDivElement>;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the select has a search input field.
|
|
46
|
+
*/
|
|
47
|
+
searchable?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When false, hides option details.
|
|
50
|
+
*/
|
|
51
|
+
showDetails?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When false, hides section headers in the list box.
|
|
54
|
+
*/
|
|
55
|
+
showSectionHeaders?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Size of the list box and its items.
|
|
58
|
+
*/
|
|
59
|
+
size?: FormSize;
|
|
60
|
+
/**
|
|
61
|
+
* Message to be displayed when some options are hidden due to `sizeLimit`.
|
|
62
|
+
*/
|
|
63
|
+
sizeLimitMessage?: string;
|
|
64
|
+
/**
|
|
65
|
+
* If true, virtualization will be enabled for the list
|
|
66
|
+
*/
|
|
67
|
+
virtualized?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Vertical padding (in px) added to the virtualizer height. Defaults to 4 (theme.space.xs).
|
|
70
|
+
*/
|
|
71
|
+
virtualizedListPadding?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A list box with accessibile behaviors & attributes.
|
|
75
|
+
* https://react-spectrum.adobe.com/react-aria/useListBox.html
|
|
76
|
+
*
|
|
77
|
+
* Unlike grid lists, list boxes are one-dimensional. Users can press Arrow Up/Down to
|
|
78
|
+
* move between options. All interactive elements (buttons/links) inside list box
|
|
79
|
+
* options are unreachable via keyboard (only the options themselves can be focused on).
|
|
80
|
+
* If interactive children are necessary, consider using grid lists instead (by setting
|
|
81
|
+
* `mode="grid"` on CompactSelect).
|
|
82
|
+
*/
|
|
83
|
+
export declare function ListBox<T extends ListItemBase>({ ref, listState, autoFocus, size, shouldFocusWrap, shouldFocusOnHover, sizeLimitMessage, keyDownHandler, label, hiddenOptions, hasSearch, searchable, overlayIsOpen, showSectionHeaders, showDetails, onAction, virtualized, virtualizedListPadding, scrollContainerRef, className, ...props }: ListBoxProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
84
|
+
export {};
|