@react-aria/listbox 3.4.1-nightly.3100 → 3.4.2
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/main.js +57 -51
- package/dist/main.js.map +1 -1
- package/dist/module.js +54 -48
- package/dist/module.js.map +1 -1
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
1
|
+
var $2DMzk$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $2DMzk$reactariainteractions = require("@react-aria/interactions");
|
|
3
|
+
var $2DMzk$reactarialabel = require("@react-aria/label");
|
|
4
|
+
var $2DMzk$reactariaselection = require("@react-aria/selection");
|
|
5
|
+
var $2DMzk$reactstatelycollections = require("@react-stately/collections");
|
|
6
6
|
|
|
7
7
|
function $parcel$exportWildcard(dest, source) {
|
|
8
8
|
Object.keys(source).forEach(function(key) {
|
|
@@ -23,23 +23,23 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
23
23
|
function $parcel$export(e, n, v, s) {
|
|
24
24
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
25
25
|
}
|
|
26
|
-
var $
|
|
26
|
+
var $50e07b4958ef8269$exports = {};
|
|
27
27
|
|
|
28
|
-
$parcel$export($
|
|
28
|
+
$parcel$export($50e07b4958ef8269$exports, "useListBox", () => $50e07b4958ef8269$export$50eacbbf140a3141);
|
|
29
29
|
|
|
30
|
-
var $
|
|
30
|
+
var $29f6a4f44d3a6168$exports = {};
|
|
31
31
|
|
|
32
|
-
$parcel$export($
|
|
33
|
-
$parcel$export($
|
|
34
|
-
const $
|
|
35
|
-
function $
|
|
32
|
+
$parcel$export($29f6a4f44d3a6168$exports, "listData", () => $29f6a4f44d3a6168$export$3585ede4d035bf14);
|
|
33
|
+
$parcel$export($29f6a4f44d3a6168$exports, "getItemId", () => $29f6a4f44d3a6168$export$9145995848b05025);
|
|
34
|
+
const $29f6a4f44d3a6168$export$3585ede4d035bf14 = new WeakMap();
|
|
35
|
+
function $29f6a4f44d3a6168$var$normalizeKey(key) {
|
|
36
36
|
if (typeof key === 'string') return key.replace(/\s*/g, '');
|
|
37
37
|
return '' + key;
|
|
38
38
|
}
|
|
39
|
-
function $
|
|
40
|
-
let data = $
|
|
39
|
+
function $29f6a4f44d3a6168$export$9145995848b05025(state, itemKey) {
|
|
40
|
+
let data = $29f6a4f44d3a6168$export$3585ede4d035bf14.get(state);
|
|
41
41
|
if (!data) throw new Error('Unknown list');
|
|
42
|
-
return `${data.id}-option-${$
|
|
42
|
+
return `${data.id}-option-${$29f6a4f44d3a6168$var$normalizeKey(itemKey)}`;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
@@ -47,32 +47,32 @@ function $55ba9445af8053ba$export$9145995848b05025(state, itemKey) {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
function $
|
|
51
|
-
let domProps = $
|
|
50
|
+
function $50e07b4958ef8269$export$50eacbbf140a3141(props, state, ref) {
|
|
51
|
+
let domProps = $2DMzk$reactariautils.filterDOMProps(props, {
|
|
52
52
|
labelable: true
|
|
53
53
|
});
|
|
54
|
-
let { listProps: listProps } = $
|
|
54
|
+
let { listProps: listProps } = $2DMzk$reactariaselection.useSelectableList({
|
|
55
55
|
...props,
|
|
56
56
|
ref: ref,
|
|
57
57
|
selectionManager: state.selectionManager,
|
|
58
58
|
collection: state.collection,
|
|
59
59
|
disabledKeys: state.disabledKeys
|
|
60
60
|
});
|
|
61
|
-
let { focusWithinProps: focusWithinProps } = $
|
|
61
|
+
let { focusWithinProps: focusWithinProps } = $2DMzk$reactariainteractions.useFocusWithin({
|
|
62
62
|
onFocusWithin: props.onFocus,
|
|
63
63
|
onBlurWithin: props.onBlur,
|
|
64
64
|
onFocusWithinChange: props.onFocusChange
|
|
65
65
|
});
|
|
66
66
|
// Share list id and some props with child options.
|
|
67
|
-
let id = $
|
|
68
|
-
$
|
|
67
|
+
let id = $2DMzk$reactariautils.useId(props.id);
|
|
68
|
+
$29f6a4f44d3a6168$export$3585ede4d035bf14.set(state, {
|
|
69
69
|
id: id,
|
|
70
70
|
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
71
71
|
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
72
72
|
shouldFocusOnHover: props.shouldFocusOnHover,
|
|
73
73
|
isVirtualized: props.isVirtualized
|
|
74
74
|
});
|
|
75
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
75
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $2DMzk$reactarialabel.useLabel({
|
|
76
76
|
...props,
|
|
77
77
|
id: id,
|
|
78
78
|
// listbox is not an HTML input element so it
|
|
@@ -81,37 +81,43 @@ function $791342f030d1fc2c$export$50eacbbf140a3141(props, state, ref) {
|
|
|
81
81
|
});
|
|
82
82
|
return {
|
|
83
83
|
labelProps: labelProps,
|
|
84
|
-
listBoxProps: $
|
|
84
|
+
listBoxProps: $2DMzk$reactariautils.mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
|
|
85
85
|
'aria-multiselectable': 'true'
|
|
86
86
|
} : {
|
|
87
87
|
}, {
|
|
88
88
|
role: 'listbox',
|
|
89
|
-
...$
|
|
89
|
+
...$2DMzk$reactariautils.mergeProps(fieldProps, listProps)
|
|
90
90
|
})
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
var $
|
|
95
|
+
var $29933ad53619f82f$exports = {};
|
|
96
96
|
|
|
97
|
-
$parcel$export($
|
|
97
|
+
$parcel$export($29933ad53619f82f$exports, "useOption", () => $29933ad53619f82f$export$497855f14858aa34);
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
function $
|
|
103
|
+
function $29933ad53619f82f$export$497855f14858aa34(props, state, ref) {
|
|
104
104
|
let { key: key } = props;
|
|
105
|
-
let data = $
|
|
106
|
-
|
|
107
|
-
let
|
|
105
|
+
let data = $29f6a4f44d3a6168$export$3585ede4d035bf14.get(state);
|
|
106
|
+
var _isDisabled;
|
|
107
|
+
let isDisabled = (_isDisabled = props.isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : state.disabledKeys.has(key);
|
|
108
|
+
var _isSelected;
|
|
109
|
+
let isSelected = (_isSelected = props.isSelected) !== null && _isSelected !== void 0 ? _isSelected : state.selectionManager.isSelected(key);
|
|
108
110
|
let isFocused = state.selectionManager.focusedKey === key;
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
let
|
|
113
|
-
|
|
114
|
-
let
|
|
111
|
+
var _shouldSelectOnPressUp;
|
|
112
|
+
let shouldSelectOnPressUp = (_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _shouldSelectOnPressUp !== void 0 ? _shouldSelectOnPressUp : data.shouldSelectOnPressUp;
|
|
113
|
+
var _shouldFocusOnHover;
|
|
114
|
+
let shouldFocusOnHover = (_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _shouldFocusOnHover !== void 0 ? _shouldFocusOnHover : data.shouldFocusOnHover;
|
|
115
|
+
var _shouldUseVirtualFocus;
|
|
116
|
+
let shouldUseVirtualFocus = (_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _shouldUseVirtualFocus !== void 0 ? _shouldUseVirtualFocus : data.shouldUseVirtualFocus;
|
|
117
|
+
var _isVirtualized;
|
|
118
|
+
let isVirtualized = (_isVirtualized = props.isVirtualized) !== null && _isVirtualized !== void 0 ? _isVirtualized : data.isVirtualized;
|
|
119
|
+
let labelId = $2DMzk$reactariautils.useSlotId();
|
|
120
|
+
let descriptionId = $2DMzk$reactariautils.useSlotId();
|
|
115
121
|
let optionProps = {
|
|
116
122
|
role: 'option',
|
|
117
123
|
'aria-disabled': isDisabled,
|
|
@@ -120,16 +126,16 @@ function $379f8fed3835a355$export$497855f14858aa34(props, state, ref) {
|
|
|
120
126
|
// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
|
|
121
127
|
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
|
|
122
128
|
// https://bugs.webkit.org/show_bug.cgi?id=209279
|
|
123
|
-
if (!($
|
|
129
|
+
if (!($2DMzk$reactariautils.isMac() && $2DMzk$reactariautils.isWebKit())) {
|
|
124
130
|
optionProps['aria-label'] = props['aria-label'];
|
|
125
131
|
optionProps['aria-labelledby'] = labelId;
|
|
126
132
|
optionProps['aria-describedby'] = descriptionId;
|
|
127
133
|
}
|
|
128
134
|
if (isVirtualized) {
|
|
129
135
|
optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;
|
|
130
|
-
optionProps['aria-setsize'] = $
|
|
136
|
+
optionProps['aria-setsize'] = $2DMzk$reactstatelycollections.getItemCount(state.collection);
|
|
131
137
|
}
|
|
132
|
-
let { itemProps: itemProps , isPressed: isPressed } = $
|
|
138
|
+
let { itemProps: itemProps , isPressed: isPressed } = $2DMzk$reactariaselection.useSelectableItem({
|
|
133
139
|
selectionManager: state.selectionManager,
|
|
134
140
|
key: key,
|
|
135
141
|
ref: ref,
|
|
@@ -138,10 +144,10 @@ function $379f8fed3835a355$export$497855f14858aa34(props, state, ref) {
|
|
|
138
144
|
shouldUseVirtualFocus: shouldUseVirtualFocus,
|
|
139
145
|
isDisabled: isDisabled
|
|
140
146
|
});
|
|
141
|
-
let { hoverProps: hoverProps } = $
|
|
147
|
+
let { hoverProps: hoverProps } = $2DMzk$reactariainteractions.useHover({
|
|
142
148
|
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
143
149
|
onHoverStart () {
|
|
144
|
-
if (!$
|
|
150
|
+
if (!$2DMzk$reactariainteractions.isFocusVisible()) {
|
|
145
151
|
state.selectionManager.setFocused(true);
|
|
146
152
|
state.selectionManager.setFocusedKey(key);
|
|
147
153
|
}
|
|
@@ -150,8 +156,8 @@ function $379f8fed3835a355$export$497855f14858aa34(props, state, ref) {
|
|
|
150
156
|
return {
|
|
151
157
|
optionProps: {
|
|
152
158
|
...optionProps,
|
|
153
|
-
...$
|
|
154
|
-
id: $
|
|
159
|
+
...$2DMzk$reactariautils.mergeProps(itemProps, hoverProps),
|
|
160
|
+
id: $29f6a4f44d3a6168$export$9145995848b05025(state, key)
|
|
155
161
|
},
|
|
156
162
|
labelProps: {
|
|
157
163
|
id: labelId
|
|
@@ -167,13 +173,13 @@ function $379f8fed3835a355$export$497855f14858aa34(props, state, ref) {
|
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
|
|
170
|
-
var $
|
|
176
|
+
var $8262af1bc01e22eb$exports = {};
|
|
171
177
|
|
|
172
|
-
$parcel$export($
|
|
178
|
+
$parcel$export($8262af1bc01e22eb$exports, "useListBoxSection", () => $8262af1bc01e22eb$export$c3f9f39876e4bc7);
|
|
173
179
|
|
|
174
|
-
function $
|
|
180
|
+
function $8262af1bc01e22eb$export$c3f9f39876e4bc7(props) {
|
|
175
181
|
let { heading: heading , 'aria-label': ariaLabel } = props;
|
|
176
|
-
let headingId = $
|
|
182
|
+
let headingId = $2DMzk$reactariautils.useId();
|
|
177
183
|
return {
|
|
178
184
|
itemProps: {
|
|
179
185
|
role: 'presentation'
|
|
@@ -196,10 +202,10 @@ function $701722104b57f7b1$export$c3f9f39876e4bc7(props) {
|
|
|
196
202
|
|
|
197
203
|
|
|
198
204
|
|
|
199
|
-
$parcel$exportWildcard(module.exports, $
|
|
200
|
-
$parcel$exportWildcard(module.exports, $
|
|
201
|
-
$parcel$exportWildcard(module.exports, $
|
|
202
|
-
$parcel$exportWildcard(module.exports, $
|
|
205
|
+
$parcel$exportWildcard(module.exports, $50e07b4958ef8269$exports);
|
|
206
|
+
$parcel$exportWildcard(module.exports, $29933ad53619f82f$exports);
|
|
207
|
+
$parcel$exportWildcard(module.exports, $8262af1bc01e22eb$exports);
|
|
208
|
+
$parcel$exportWild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nC,EAAE,EAAE,SAAS;YACb,CAAa,cAAE,IAAI;QACrB,CAAC,GAAG,CAAC;QAAA,CAAC;QACN,UAAU,EAAE,CAAC;YACX,IAAI,EAAE,CAAO;YACb,CAAY,aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useListBox';\nexport * from './useOption';\nexport * from './useListBoxSection';\nexport * from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, ReactNode, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\ninterface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: HTMLAttributes<HTMLElement>,\n /** Props for the listbox's visual label element (if any). */\n labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {HTMLAttributes, Key, RefObject} from 'react';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface OptionAria {\n /** Props for the option element. */\n optionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the main text element inside the option. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n /** Whether the option is currently selected. */\n isSelected: boolean,\n /** Whether the option is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the option is disabled. */\n isDisabled: boolean\n}\n\ninterface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<HTMLElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {HTMLAttributes, ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\ninterface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\ninterface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the heading element, if any. */\n headingProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the group element. */\n groupProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEuBO,KAAK,CAAC,yCAAQ,GAAG,GAAG,CAAC,OAAO;SAE1B,kCAAY,CAAC,GAAQ,EAAU,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;SAEe,yCAAS,CAAI,KAAmB,EAAE,OAAY,EAAU,CAAC;IACvE,GAAG,CAAC,IAA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aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useListBox';\nexport * from './useOption';\nexport * from './useListBoxSection';\nexport * from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, ReactNode, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\ninterface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: HTMLAttributes<HTMLElement>,\n /** Props for the listbox's visual label element (if any). */\n labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {HTMLAttributes, Key, RefObject} from 'react';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface OptionAria {\n /** Props for the option element. */\n optionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the main text element inside the option. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n /** Whether the option is currently selected. */\n isSelected: boolean,\n /** Whether the option is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the option is disabled. */\n isDisabled: boolean\n}\n\ninterface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<HTMLElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {HTMLAttributes, ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\ninterface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\ninterface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the heading element, if any. */\n headingProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the group element. */\n groupProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {filterDOMProps as $
|
|
2
|
-
import {useFocusWithin as $
|
|
3
|
-
import {useLabel as $
|
|
4
|
-
import {useSelectableList as $
|
|
5
|
-
import {getItemCount as $
|
|
1
|
+
import {filterDOMProps as $9XpHW$filterDOMProps, useId as $9XpHW$useId, mergeProps as $9XpHW$mergeProps, useSlotId as $9XpHW$useSlotId, isMac as $9XpHW$isMac, isWebKit as $9XpHW$isWebKit} from "@react-aria/utils";
|
|
2
|
+
import {useFocusWithin as $9XpHW$useFocusWithin, useHover as $9XpHW$useHover, isFocusVisible as $9XpHW$isFocusVisible} from "@react-aria/interactions";
|
|
3
|
+
import {useLabel as $9XpHW$useLabel} from "@react-aria/label";
|
|
4
|
+
import {useSelectableList as $9XpHW$useSelectableList, useSelectableItem as $9XpHW$useSelectableItem} from "@react-aria/selection";
|
|
5
|
+
import {getItemCount as $9XpHW$getItemCount} from "@react-stately/collections";
|
|
6
6
|
|
|
7
7
|
function $parcel$export(e, n, v, s) {
|
|
8
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
9
|
}
|
|
10
|
-
var $
|
|
10
|
+
var $4599f731efac101a$exports = {};
|
|
11
11
|
|
|
12
|
-
$parcel$export($
|
|
12
|
+
$parcel$export($4599f731efac101a$exports, "useListBox", () => $4599f731efac101a$export$50eacbbf140a3141);
|
|
13
13
|
|
|
14
|
-
var $
|
|
14
|
+
var $fc40a93251bc17d1$exports = {};
|
|
15
15
|
|
|
16
|
-
$parcel$export($
|
|
17
|
-
$parcel$export($
|
|
18
|
-
const $
|
|
19
|
-
function $
|
|
16
|
+
$parcel$export($fc40a93251bc17d1$exports, "listData", () => $fc40a93251bc17d1$export$3585ede4d035bf14);
|
|
17
|
+
$parcel$export($fc40a93251bc17d1$exports, "getItemId", () => $fc40a93251bc17d1$export$9145995848b05025);
|
|
18
|
+
const $fc40a93251bc17d1$export$3585ede4d035bf14 = new WeakMap();
|
|
19
|
+
function $fc40a93251bc17d1$var$normalizeKey(key) {
|
|
20
20
|
if (typeof key === 'string') return key.replace(/\s*/g, '');
|
|
21
21
|
return '' + key;
|
|
22
22
|
}
|
|
23
|
-
function $
|
|
24
|
-
let data = $
|
|
23
|
+
function $fc40a93251bc17d1$export$9145995848b05025(state, itemKey) {
|
|
24
|
+
let data = $fc40a93251bc17d1$export$3585ede4d035bf14.get(state);
|
|
25
25
|
if (!data) throw new Error('Unknown list');
|
|
26
|
-
return `${data.id}-option-${$
|
|
26
|
+
return `${data.id}-option-${$fc40a93251bc17d1$var$normalizeKey(itemKey)}`;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
|
@@ -31,32 +31,32 @@ function $d786742a15de2e64$export$9145995848b05025(state, itemKey) {
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
function $
|
|
35
|
-
let domProps = $
|
|
34
|
+
function $4599f731efac101a$export$50eacbbf140a3141(props, state, ref) {
|
|
35
|
+
let domProps = $9XpHW$filterDOMProps(props, {
|
|
36
36
|
labelable: true
|
|
37
37
|
});
|
|
38
|
-
let { listProps: listProps } = $
|
|
38
|
+
let { listProps: listProps } = $9XpHW$useSelectableList({
|
|
39
39
|
...props,
|
|
40
40
|
ref: ref,
|
|
41
41
|
selectionManager: state.selectionManager,
|
|
42
42
|
collection: state.collection,
|
|
43
43
|
disabledKeys: state.disabledKeys
|
|
44
44
|
});
|
|
45
|
-
let { focusWithinProps: focusWithinProps } = $
|
|
45
|
+
let { focusWithinProps: focusWithinProps } = $9XpHW$useFocusWithin({
|
|
46
46
|
onFocusWithin: props.onFocus,
|
|
47
47
|
onBlurWithin: props.onBlur,
|
|
48
48
|
onFocusWithinChange: props.onFocusChange
|
|
49
49
|
});
|
|
50
50
|
// Share list id and some props with child options.
|
|
51
|
-
let id = $
|
|
52
|
-
$
|
|
51
|
+
let id = $9XpHW$useId(props.id);
|
|
52
|
+
$fc40a93251bc17d1$export$3585ede4d035bf14.set(state, {
|
|
53
53
|
id: id,
|
|
54
54
|
shouldUseVirtualFocus: props.shouldUseVirtualFocus,
|
|
55
55
|
shouldSelectOnPressUp: props.shouldSelectOnPressUp,
|
|
56
56
|
shouldFocusOnHover: props.shouldFocusOnHover,
|
|
57
57
|
isVirtualized: props.isVirtualized
|
|
58
58
|
});
|
|
59
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
59
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $9XpHW$useLabel({
|
|
60
60
|
...props,
|
|
61
61
|
id: id,
|
|
62
62
|
// listbox is not an HTML input element so it
|
|
@@ -65,37 +65,43 @@ function $b6a6a3879de3c160$export$50eacbbf140a3141(props, state, ref) {
|
|
|
65
65
|
});
|
|
66
66
|
return {
|
|
67
67
|
labelProps: labelProps,
|
|
68
|
-
listBoxProps: $
|
|
68
|
+
listBoxProps: $9XpHW$mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
|
|
69
69
|
'aria-multiselectable': 'true'
|
|
70
70
|
} : {
|
|
71
71
|
}, {
|
|
72
72
|
role: 'listbox',
|
|
73
|
-
...$
|
|
73
|
+
...$9XpHW$mergeProps(fieldProps, listProps)
|
|
74
74
|
})
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var $
|
|
79
|
+
var $320d38f7a0623e79$exports = {};
|
|
80
80
|
|
|
81
|
-
$parcel$export($
|
|
81
|
+
$parcel$export($320d38f7a0623e79$exports, "useOption", () => $320d38f7a0623e79$export$497855f14858aa34);
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
function $
|
|
87
|
+
function $320d38f7a0623e79$export$497855f14858aa34(props, state, ref) {
|
|
88
88
|
let { key: key } = props;
|
|
89
|
-
let data = $
|
|
90
|
-
|
|
91
|
-
let
|
|
89
|
+
let data = $fc40a93251bc17d1$export$3585ede4d035bf14.get(state);
|
|
90
|
+
var _isDisabled;
|
|
91
|
+
let isDisabled = (_isDisabled = props.isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : state.disabledKeys.has(key);
|
|
92
|
+
var _isSelected;
|
|
93
|
+
let isSelected = (_isSelected = props.isSelected) !== null && _isSelected !== void 0 ? _isSelected : state.selectionManager.isSelected(key);
|
|
92
94
|
let isFocused = state.selectionManager.focusedKey === key;
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
let
|
|
95
|
+
var _shouldSelectOnPressUp;
|
|
96
|
+
let shouldSelectOnPressUp = (_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _shouldSelectOnPressUp !== void 0 ? _shouldSelectOnPressUp : data.shouldSelectOnPressUp;
|
|
97
|
+
var _shouldFocusOnHover;
|
|
98
|
+
let shouldFocusOnHover = (_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _shouldFocusOnHover !== void 0 ? _shouldFocusOnHover : data.shouldFocusOnHover;
|
|
99
|
+
var _shouldUseVirtualFocus;
|
|
100
|
+
let shouldUseVirtualFocus = (_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _shouldUseVirtualFocus !== void 0 ? _shouldUseVirtualFocus : data.shouldUseVirtualFocus;
|
|
101
|
+
var _isVirtualized;
|
|
102
|
+
let isVirtualized = (_isVirtualized = props.isVirtualized) !== null && _isVirtualized !== void 0 ? _isVirtualized : data.isVirtualized;
|
|
103
|
+
let labelId = $9XpHW$useSlotId();
|
|
104
|
+
let descriptionId = $9XpHW$useSlotId();
|
|
99
105
|
let optionProps = {
|
|
100
106
|
role: 'option',
|
|
101
107
|
'aria-disabled': isDisabled,
|
|
@@ -104,16 +110,16 @@ function $ffbe2720d8d792ce$export$497855f14858aa34(props, state, ref) {
|
|
|
104
110
|
// Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
|
|
105
111
|
// We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
|
|
106
112
|
// https://bugs.webkit.org/show_bug.cgi?id=209279
|
|
107
|
-
if (!($
|
|
113
|
+
if (!($9XpHW$isMac() && $9XpHW$isWebKit())) {
|
|
108
114
|
optionProps['aria-label'] = props['aria-label'];
|
|
109
115
|
optionProps['aria-labelledby'] = labelId;
|
|
110
116
|
optionProps['aria-describedby'] = descriptionId;
|
|
111
117
|
}
|
|
112
118
|
if (isVirtualized) {
|
|
113
119
|
optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;
|
|
114
|
-
optionProps['aria-setsize'] = $
|
|
120
|
+
optionProps['aria-setsize'] = $9XpHW$getItemCount(state.collection);
|
|
115
121
|
}
|
|
116
|
-
let { itemProps: itemProps , isPressed: isPressed } = $
|
|
122
|
+
let { itemProps: itemProps , isPressed: isPressed } = $9XpHW$useSelectableItem({
|
|
117
123
|
selectionManager: state.selectionManager,
|
|
118
124
|
key: key,
|
|
119
125
|
ref: ref,
|
|
@@ -122,10 +128,10 @@ function $ffbe2720d8d792ce$export$497855f14858aa34(props, state, ref) {
|
|
|
122
128
|
shouldUseVirtualFocus: shouldUseVirtualFocus,
|
|
123
129
|
isDisabled: isDisabled
|
|
124
130
|
});
|
|
125
|
-
let { hoverProps: hoverProps } = $
|
|
131
|
+
let { hoverProps: hoverProps } = $9XpHW$useHover({
|
|
126
132
|
isDisabled: isDisabled || !shouldFocusOnHover,
|
|
127
133
|
onHoverStart () {
|
|
128
|
-
if (!$
|
|
134
|
+
if (!$9XpHW$isFocusVisible()) {
|
|
129
135
|
state.selectionManager.setFocused(true);
|
|
130
136
|
state.selectionManager.setFocusedKey(key);
|
|
131
137
|
}
|
|
@@ -134,8 +140,8 @@ function $ffbe2720d8d792ce$export$497855f14858aa34(props, state, ref) {
|
|
|
134
140
|
return {
|
|
135
141
|
optionProps: {
|
|
136
142
|
...optionProps,
|
|
137
|
-
...$
|
|
138
|
-
id: $
|
|
143
|
+
...$9XpHW$mergeProps(itemProps, hoverProps),
|
|
144
|
+
id: $fc40a93251bc17d1$export$9145995848b05025(state, key)
|
|
139
145
|
},
|
|
140
146
|
labelProps: {
|
|
141
147
|
id: labelId
|
|
@@ -151,13 +157,13 @@ function $ffbe2720d8d792ce$export$497855f14858aa34(props, state, ref) {
|
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
|
|
154
|
-
var $
|
|
160
|
+
var $da55f015385fe4fc$exports = {};
|
|
155
161
|
|
|
156
|
-
$parcel$export($
|
|
162
|
+
$parcel$export($da55f015385fe4fc$exports, "useListBoxSection", () => $da55f015385fe4fc$export$c3f9f39876e4bc7);
|
|
157
163
|
|
|
158
|
-
function $
|
|
164
|
+
function $da55f015385fe4fc$export$c3f9f39876e4bc7(props) {
|
|
159
165
|
let { heading: heading , 'aria-label': ariaLabel } = props;
|
|
160
|
-
let headingId = $
|
|
166
|
+
let headingId = $9XpHW$useId();
|
|
161
167
|
return {
|
|
162
168
|
itemProps: {
|
|
163
169
|
role: 'presentation'
|
|
@@ -182,5 +188,5 @@ function $60eb9482f3936d5e$export$c3f9f39876e4bc7(props) {
|
|
|
182
188
|
|
|
183
189
|
|
|
184
190
|
|
|
185
|
-
export {$
|
|
191
|
+
export {$4599f731efac101a$export$50eacbbf140a3141 as useListBox, $320d38f7a0623e79$export$497855f14858aa34 as useOption, $da55f015385fe4fc$export$c3f9f39876e4bc7 as useListBoxSection, $fc40a93251bc17d1$export$3585ede4d035bf14 as listData, $fc40a93251bc17d1$export$9145995848b05025 as getItemId};
|
|
186
192
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AEuBO,KAAK,CAAC,yCAAQ,GAAG,GAAG,CAAC,OAAO;SAE1B,kCAAY,CAAC,GAAQ,EAAU,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;SAEe,yCAAS,CAAI,KAAmB,EAAE,OAAY,EAAU,CAAC;IACvE,GAAG,CAAC,IAAI,GAAG,yCAAQ,CAAC,GAAG,CAAC,KAAK;IAE7B,EAAE,GAAG,IAAI,EACP,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,kCAAY,CAAC,OAAO;AAClD,CAAC;;;;;;;SDsBe,yCAAU,CAAI,KAA4B,EAAE,KAAmB,EAAE,GAA2B,EAAe,CAAC;IAC1H,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IACtD,GAAG,CAAC,C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AAC;IACrF,GAAG,CAAC,CAAC,UAAA,OAAO,GAAE,CAAY,aAAE,SAAS,EAAA,CAAC,GAAG,KAAK;IAC9C,GAAG,CAAC,SAAS,GAAG,YAAK;IAErB,MAAM,CAAC,CAAC;QACN,SAAS,EAAE,CAAC;YACV,IAAI,EAAE,CAAc;QACtB,CAAC;QACD,YAAY,EAAE,OAAO,GAAG,CAAC;YACvB,EAAkE,AAAlE,gEAAkE;YAClE,EAAiE,AAAjE,+DAAiE;YACjE,EAAmC,AAAnC,iCAAmC;YACnC,EAAE,EAAE,SAAS;YACb,CAAa,cAAE,IAAI;QACrB,CAAC,GAAG,CAAC;QAAA,CAAC;QACN,UAAU,EAAE,CAAC;YACX,IAAI,EAAE,CAAO;YACb,CAAY,aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useListBox';\nexport * from './useOption';\nexport * from './useListBoxSection';\nexport * from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, ReactNode, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\ninterface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: HTMLAttributes<HTMLElement>,\n /** Props for the listbox's visual label element (if any). */\n labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {HTMLAttributes, Key, RefObject} from 'react';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface OptionAria {\n /** Props for the option element. */\n optionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the main text element inside the option. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n /** Whether the option is currently selected. */\n isSelected: boolean,\n /** Whether the option is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the option is disabled. */\n isDisabled: boolean\n}\n\ninterface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<HTMLElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {HTMLAttributes, ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\ninterface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\ninterface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the heading element, if any. */\n headingProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the group element. */\n groupProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;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AE,CAAC;YACV,IAAI,EAAE,CAAc;QACtB,CAAC;QACD,YAAY,EAAE,OAAO,GAAG,CAAC;YACvB,EAAkE,AAAlE,gEAAkE;YAClE,EAAiE,AAAjE,+DAAiE;YACjE,EAAmC,AAAnC,iCAAmC;YACnC,EAAE,EAAE,SAAS;YACb,CAAa,cAAE,IAAI;QACrB,CAAC,GAAG,CAAC;QAAA,CAAC;QACN,UAAU,EAAE,CAAC;YACX,IAAI,EAAE,CAAO;YACb,CAAY,aAAE,SAAS;YACvB,CAAiB,kBAAE,OAAO,GAAG,SAAS,GAAG,SAAS;QACpD,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useListBox';\nexport * from './useOption';\nexport * from './useListBoxSection';\nexport * from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, ReactNode, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\ninterface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: HTMLAttributes<HTMLElement>,\n /** Props for the listbox's visual label element (if any). */\n labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n /** Whether the listbox uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n\n /**\n * Whether the listbox items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean,\n\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean,\n\n /** Whether options should be focused when the user hovers over them. */\n shouldFocusOnHover?: boolean,\n\n /**\n * An optional visual label for the listbox.\n */\n label?: ReactNode\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\n })\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {HTMLAttributes, Key, RefObject} from 'react';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface OptionAria {\n /** Props for the option element. */\n optionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the main text element inside the option. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n /** Whether the option is currently selected. */\n isSelected: boolean,\n /** Whether the option is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the option is disabled. */\n isDisabled: boolean\n}\n\ninterface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<HTMLElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let isFocused = state.selectionManager.focusedKey === key;\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n if (isVirtualized) {\n optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(itemProps, hoverProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isSelected,\n isDisabled,\n isPressed\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {HTMLAttributes, ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\ninterface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\ninterface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the heading element, if any. */\n headingProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the group element. */\n groupProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, and only use it\n // as a label for the nested group.\n id: headingId,\n 'aria-hidden': true\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/listbox",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "3.
|
|
22
|
-
"@react-aria/interactions": "3.
|
|
23
|
-
"@react-aria/label": "3.
|
|
24
|
-
"@react-aria/selection": "3.
|
|
25
|
-
"@react-aria/utils": "3.
|
|
26
|
-
"@react-stately/collections": "3.
|
|
27
|
-
"@react-stately/list": "3.4.
|
|
28
|
-
"@react-types/listbox": "3.2.
|
|
29
|
-
"@react-types/shared": "3.
|
|
21
|
+
"@react-aria/focus": "^3.5.2",
|
|
22
|
+
"@react-aria/interactions": "^3.8.1",
|
|
23
|
+
"@react-aria/label": "^3.2.3",
|
|
24
|
+
"@react-aria/selection": "^3.7.3",
|
|
25
|
+
"@react-aria/utils": "^3.11.2",
|
|
26
|
+
"@react-stately/collections": "^3.3.6",
|
|
27
|
+
"@react-stately/list": "^3.4.3",
|
|
28
|
+
"@react-types/listbox": "^3.2.3",
|
|
29
|
+
"@react-types/shared": "^3.11.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
38
38
|
}
|