@react-aria/listbox 3.11.6-nightly.4555 → 3.11.6-nightly.4560

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/module.js CHANGED
@@ -1,211 +1,7 @@
1
- import {filterDOMProps as $frWMC$filterDOMProps, useId as $frWMC$useId, mergeProps as $frWMC$mergeProps, useSlotId as $frWMC$useSlotId, isMac as $frWMC$isMac, isWebKit as $frWMC$isWebKit, chain as $frWMC$chain, useLinkProps as $frWMC$useLinkProps} from "@react-aria/utils";
2
- import {useFocusWithin as $frWMC$useFocusWithin, useHover as $frWMC$useHover, isFocusVisible as $frWMC$isFocusVisible} from "@react-aria/interactions";
3
- import {useLabel as $frWMC$useLabel} from "@react-aria/label";
4
- import {useSelectableList as $frWMC$useSelectableList, useSelectableItem as $frWMC$useSelectableItem} from "@react-aria/selection";
5
- import {getItemCount as $frWMC$getItemCount} from "@react-stately/collections";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */ /*
18
- * Copyright 2020 Adobe. All rights reserved.
19
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20
- * you may not use this file except in compliance with the License. You may obtain a copy
21
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
22
- *
23
- * Unless required by applicable law or agreed to in writing, software distributed under
24
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
25
- * OF ANY KIND, either express or implied. See the License for the specific language
26
- * governing permissions and limitations under the License.
27
- */
28
- /*
29
- * Copyright 2020 Adobe. All rights reserved.
30
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
31
- * you may not use this file except in compliance with the License. You may obtain a copy
32
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
33
- *
34
- * Unless required by applicable law or agreed to in writing, software distributed under
35
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
36
- * OF ANY KIND, either express or implied. See the License for the specific language
37
- * governing permissions and limitations under the License.
38
- */ const $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
39
- function $b1f0cad8af73213b$var$normalizeKey(key) {
40
- if (typeof key === "string") return key.replace(/\s*/g, "");
41
- return "" + key;
42
- }
43
- function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
44
- let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
45
- if (!data) throw new Error("Unknown list");
46
- return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
47
- }
48
-
49
-
50
-
51
-
52
-
53
- function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
54
- let domProps = (0, $frWMC$filterDOMProps)(props, {
55
- labelable: true
56
- });
57
- // Use props instead of state here. We don't want this to change due to long press.
58
- let selectionBehavior = props.selectionBehavior || "toggle";
59
- let linkBehavior = props.linkBehavior || (selectionBehavior === "replace" ? "action" : "override");
60
- if (selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
61
- // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
62
- // selectable in this configuration.
63
- linkBehavior = "override";
64
- let { listProps: listProps } = (0, $frWMC$useSelectableList)({
65
- ...props,
66
- ref: ref,
67
- selectionManager: state.selectionManager,
68
- collection: state.collection,
69
- disabledKeys: state.disabledKeys,
70
- linkBehavior: linkBehavior
71
- });
72
- let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
73
- onFocusWithin: props.onFocus,
74
- onBlurWithin: props.onBlur,
75
- onFocusWithinChange: props.onFocusChange
76
- });
77
- // Share list id and some props with child options.
78
- let id = (0, $frWMC$useId)(props.id);
79
- (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
80
- id: id,
81
- shouldUseVirtualFocus: props.shouldUseVirtualFocus,
82
- shouldSelectOnPressUp: props.shouldSelectOnPressUp,
83
- shouldFocusOnHover: props.shouldFocusOnHover,
84
- isVirtualized: props.isVirtualized,
85
- onAction: props.onAction,
86
- linkBehavior: linkBehavior
87
- });
88
- let { labelProps: labelProps, fieldProps: fieldProps } = (0, $frWMC$useLabel)({
89
- ...props,
90
- id: id,
91
- // listbox is not an HTML input element so it
92
- // shouldn't be labeled by a <label> element.
93
- labelElementType: "span"
94
- });
95
- return {
96
- labelProps: labelProps,
97
- listBoxProps: (0, $frWMC$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
98
- "aria-multiselectable": "true"
99
- } : {}, {
100
- role: "listbox",
101
- ...(0, $frWMC$mergeProps)(fieldProps, listProps)
102
- })
103
- };
104
- }
105
-
106
-
107
- /*
108
- * Copyright 2020 Adobe. All rights reserved.
109
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
110
- * you may not use this file except in compliance with the License. You may obtain a copy
111
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
112
- *
113
- * Unless required by applicable law or agreed to in writing, software distributed under
114
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
115
- * OF ANY KIND, either express or implied. See the License for the specific language
116
- * governing permissions and limitations under the License.
117
- */
118
-
119
-
120
-
121
-
122
- function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
123
- var _item_props, _item_props1;
124
- let { key: key } = props;
125
- let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
126
- var _props_isDisabled;
127
- let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
128
- var _props_isSelected;
129
- let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
130
- var _props_shouldSelectOnPressUp;
131
- let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data === null || data === void 0 ? void 0 : data.shouldSelectOnPressUp;
132
- var _props_shouldFocusOnHover;
133
- let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data === null || data === void 0 ? void 0 : data.shouldFocusOnHover;
134
- var _props_shouldUseVirtualFocus;
135
- let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data === null || data === void 0 ? void 0 : data.shouldUseVirtualFocus;
136
- var _props_isVirtualized;
137
- let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data === null || data === void 0 ? void 0 : data.isVirtualized;
138
- let labelId = (0, $frWMC$useSlotId)();
139
- let descriptionId = (0, $frWMC$useSlotId)();
140
- let optionProps = {
141
- role: "option",
142
- "aria-disabled": isDisabled || undefined,
143
- "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
144
- };
145
- // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
146
- // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
147
- // https://bugs.webkit.org/show_bug.cgi?id=209279
148
- if (!((0, $frWMC$isMac)() && (0, $frWMC$isWebKit)())) {
149
- optionProps["aria-label"] = props["aria-label"];
150
- optionProps["aria-labelledby"] = labelId;
151
- optionProps["aria-describedby"] = descriptionId;
152
- }
153
- let item = state.collection.getItem(key);
154
- if (isVirtualized) {
155
- let index = Number(item === null || item === void 0 ? void 0 : item.index);
156
- optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
157
- optionProps["aria-setsize"] = (0, $frWMC$getItemCount)(state.collection);
158
- }
159
- let onAction = (data === null || data === void 0 ? void 0 : data.onAction) ? ()=>{
160
- var _data_onAction;
161
- return data === null || data === void 0 ? void 0 : (_data_onAction = data.onAction) === null || _data_onAction === void 0 ? void 0 : _data_onAction.call(data, key);
162
- } : undefined;
163
- let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
164
- selectionManager: state.selectionManager,
165
- key: key,
166
- ref: ref,
167
- shouldSelectOnPressUp: shouldSelectOnPressUp,
168
- allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
169
- isVirtualized: isVirtualized,
170
- shouldUseVirtualFocus: shouldUseVirtualFocus,
171
- isDisabled: isDisabled,
172
- onAction: onAction || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) ? (0, $frWMC$chain)(item === null || item === void 0 ? void 0 : (_item_props1 = item.props) === null || _item_props1 === void 0 ? void 0 : _item_props1.onAction, onAction) : undefined,
173
- linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
174
- });
175
- let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
176
- isDisabled: isDisabled || !shouldFocusOnHover,
177
- onHoverStart () {
178
- if (!(0, $frWMC$isFocusVisible)()) {
179
- state.selectionManager.setFocused(true);
180
- state.selectionManager.setFocusedKey(key);
181
- }
182
- }
183
- });
184
- let domProps = (0, $frWMC$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
185
- delete domProps.id;
186
- let linkProps = (0, $frWMC$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
187
- return {
188
- optionProps: {
189
- ...optionProps,
190
- ...(0, $frWMC$mergeProps)(domProps, itemProps, hoverProps, linkProps),
191
- id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
192
- },
193
- labelProps: {
194
- id: labelId
195
- },
196
- descriptionProps: {
197
- id: descriptionId
198
- },
199
- isFocused: isFocused,
200
- isFocusVisible: isFocused && (0, $frWMC$isFocusVisible)(),
201
- isSelected: isSelected,
202
- isDisabled: isDisabled,
203
- isPressed: isPressed,
204
- allowsSelection: allowsSelection,
205
- hasAction: hasAction
206
- };
207
- }
208
-
1
+ import {useListBox as $c132121280ec012d$export$50eacbbf140a3141} from "./useListBox.module.js";
2
+ import {useOption as $293f70390ea03370$export$497855f14858aa34} from "./useOption.module.js";
3
+ import {useListBoxSection as $af383d3bef1cfdc9$export$c3f9f39876e4bc7} from "./useListBoxSection.module.js";
4
+ import {getItemId as $b1f0cad8af73213b$export$9145995848b05025, listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.module.js";
209
5
 
210
6
  /*
211
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -218,27 +14,6 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
218
14
  * OF ANY KIND, either express or implied. See the License for the specific language
219
15
  * governing permissions and limitations under the License.
220
16
  */
221
- function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
222
- let { heading: heading, "aria-label": ariaLabel } = props;
223
- let headingId = (0, $frWMC$useId)();
224
- return {
225
- itemProps: {
226
- role: "presentation"
227
- },
228
- headingProps: heading ? {
229
- // Techincally, listbox cannot contain headings according to ARIA.
230
- // We hide the heading from assistive technology, using role="presentation",
231
- // and only use it as a visual label for the nested group.
232
- id: headingId,
233
- role: "presentation"
234
- } : {},
235
- groupProps: {
236
- role: "group",
237
- "aria-label": ariaLabel,
238
- "aria-labelledby": heading ? headingId : undefined
239
- }
240
- };
241
- }
242
17
 
243
18
 
244
19
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ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UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,cAAc,CAAC;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,qBAAa,KAAK;gBACrB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,mBAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,WAAW,YAAY,UAAU;YACzD,IAAI,CAAA,GAAA,yCAAQ,EAAE,OAAO;QACvB;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,CAAA,GAAA,qBAAa;oBAC1C;oBACA;mBACA;yBACA;mBACA;IACF;AACF;;;AC/KA;;;;;;;;;;CAUC;AA6BM,SAAS,yCAAkB,KAA8B;IAC9D,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,YAAI;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,kEAAkE;YAClE,4EAA4E;YAC5E,0DAA0D;YAC1D,IAAI;YACJ,MAAM;QACR,IAAI,CAAC;QACL,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY;QAC3C;IACF;AACF;;","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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxProps} from '@react-types/listbox';\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\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 {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\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 * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * @default 'override'\n */\n linkBehavior?: 'action' | 'selection' | 'override'\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 // Use props instead of state here. We don't want this to change due to long press.\n let selectionBehavior = props.selectionBehavior || 'toggle';\n let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');\n if (selectionBehavior === 'toggle' && linkBehavior === 'action') {\n // linkBehavior=\"action\" does not work with selectionBehavior=\"toggle\" because there is no way\n // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be\n // selectable in this configuration.\n linkBehavior = 'override';\n }\n\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n linkBehavior\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 onAction: props.onAction,\n linkBehavior\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-types/shared';\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 onAction?: (key: Key) => void,\n linkBehavior?: 'action' | 'selection' | 'override'\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 {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, Key} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n\n /** Whether the option is keyboard focused. */\n isFocusVisible: boolean\n}\n\nexport interface 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<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(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 || undefined,\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 let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior\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 let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isFocusVisible: isFocused && isFocusVisible(),\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\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 {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface 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\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\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, using role=\"presentation\",\n // and only use it as a visual label for the nested group.\n id: headingId,\n role: 'presentation'\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":";;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/listbox/src/index.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 {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxProps} from '@react-types/listbox';\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,82 @@
1
+ var $87beb89ab4a308fd$exports = require("./utils.main.js");
2
+ var $eCULP$reactariautils = require("@react-aria/utils");
3
+ var $eCULP$reactariainteractions = require("@react-aria/interactions");
4
+ var $eCULP$reactarialabel = require("@react-aria/label");
5
+ var $eCULP$reactariaselection = require("@react-aria/selection");
6
+
7
+
8
+ function $parcel$export(e, n, v, s) {
9
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
+ }
11
+
12
+ $parcel$export(module.exports, "useListBox", () => $a3ce5bb3074610af$export$50eacbbf140a3141);
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
24
+
25
+
26
+
27
+
28
+ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
29
+ let domProps = (0, $eCULP$reactariautils.filterDOMProps)(props, {
30
+ labelable: true
31
+ });
32
+ // Use props instead of state here. We don't want this to change due to long press.
33
+ let selectionBehavior = props.selectionBehavior || "toggle";
34
+ let linkBehavior = props.linkBehavior || (selectionBehavior === "replace" ? "action" : "override");
35
+ if (selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
36
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
37
+ // selectable in this configuration.
38
+ linkBehavior = "override";
39
+ let { listProps: listProps } = (0, $eCULP$reactariaselection.useSelectableList)({
40
+ ...props,
41
+ ref: ref,
42
+ selectionManager: state.selectionManager,
43
+ collection: state.collection,
44
+ disabledKeys: state.disabledKeys,
45
+ linkBehavior: linkBehavior
46
+ });
47
+ let { focusWithinProps: focusWithinProps } = (0, $eCULP$reactariainteractions.useFocusWithin)({
48
+ onFocusWithin: props.onFocus,
49
+ onBlurWithin: props.onBlur,
50
+ onFocusWithinChange: props.onFocusChange
51
+ });
52
+ // Share list id and some props with child options.
53
+ let id = (0, $eCULP$reactariautils.useId)(props.id);
54
+ (0, $87beb89ab4a308fd$exports.listData).set(state, {
55
+ id: id,
56
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
57
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
58
+ shouldFocusOnHover: props.shouldFocusOnHover,
59
+ isVirtualized: props.isVirtualized,
60
+ onAction: props.onAction,
61
+ linkBehavior: linkBehavior
62
+ });
63
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $eCULP$reactarialabel.useLabel)({
64
+ ...props,
65
+ id: id,
66
+ // listbox is not an HTML input element so it
67
+ // shouldn't be labeled by a <label> element.
68
+ labelElementType: "span"
69
+ });
70
+ return {
71
+ labelProps: labelProps,
72
+ listBoxProps: (0, $eCULP$reactariautils.mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
73
+ "aria-multiselectable": "true"
74
+ } : {}, {
75
+ role: "listbox",
76
+ ...(0, $eCULP$reactariautils.mergeProps)(fieldProps, listProps)
77
+ })
78
+ };
79
+ }
80
+
81
+
82
+ //# sourceMappingURL=useListBox.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAwDM,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B;IAC1G,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,mFAAmF;IACnF,IAAI,oBAAoB,MAAM,iBAAiB,IAAI;IACnD,IAAI,eAAe,MAAM,YAAY,IAAK,CAAA,sBAAsB,YAAY,WAAW,UAAS;IAChG,IAAI,sBAAsB,YAAY,iBAAiB,UACrD,8FAA8F;IAC9F,8FAA8F;IAC9F,oCAAoC;IACpC,eAAe;IAGjB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAClC,GAAG,KAAK;aACR;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;sBAChC;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,eAAe,MAAM,OAAO;QAC5B,cAAc,MAAM,MAAM;QAC1B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,mDAAmD;IACnD,IAAI,KAAK,CAAA,GAAA,2BAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC,OAAO;YAClB;QACA,uBAAuB,MAAM,qBAAqB;QAClD,uBAAuB,MAAM,qBAAqB;QAClD,oBAAoB,MAAM,kBAAkB;QAC5C,eAAe,MAAM,aAAa;QAClC,UAAU,MAAM,QAAQ;sBACxB;IACF;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QACtC,GAAG,KAAK;YACR;QACA,6CAA6C;QAC7C,6CAA6C;QAC7C,kBAAkB;IACpB;IAEA,OAAO;oBACL;QACA,cAAc,CAAA,GAAA,gCAAS,EAAE,UAAU,kBAAkB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa;YACzG,wBAAwB;QAC1B,IAAI,CAAC,GAAG;YACN,MAAM;YACN,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/listbox/src/useListBox.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\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\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 * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * @default 'override'\n */\n linkBehavior?: 'action' | 'selection' | 'override'\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 // Use props instead of state here. We don't want this to change due to long press.\n let selectionBehavior = props.selectionBehavior || 'toggle';\n let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');\n if (selectionBehavior === 'toggle' && linkBehavior === 'action') {\n // linkBehavior=\"action\" does not work with selectionBehavior=\"toggle\" because there is no way\n // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be\n // selectable in this configuration.\n linkBehavior = 'override';\n }\n\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n linkBehavior\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 onAction: props.onAction,\n linkBehavior\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"],"names":[],"version":3,"file":"useListBox.main.js.map"}
@@ -0,0 +1,77 @@
1
+ import {listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.mjs";
2
+ import {filterDOMProps as $by1yQ$filterDOMProps, useId as $by1yQ$useId, mergeProps as $by1yQ$mergeProps} from "@react-aria/utils";
3
+ import {useFocusWithin as $by1yQ$useFocusWithin} from "@react-aria/interactions";
4
+ import {useLabel as $by1yQ$useLabel} from "@react-aria/label";
5
+ import {useSelectableList as $by1yQ$useSelectableList} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
23
+ let domProps = (0, $by1yQ$filterDOMProps)(props, {
24
+ labelable: true
25
+ });
26
+ // Use props instead of state here. We don't want this to change due to long press.
27
+ let selectionBehavior = props.selectionBehavior || "toggle";
28
+ let linkBehavior = props.linkBehavior || (selectionBehavior === "replace" ? "action" : "override");
29
+ if (selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
30
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
31
+ // selectable in this configuration.
32
+ linkBehavior = "override";
33
+ let { listProps: listProps } = (0, $by1yQ$useSelectableList)({
34
+ ...props,
35
+ ref: ref,
36
+ selectionManager: state.selectionManager,
37
+ collection: state.collection,
38
+ disabledKeys: state.disabledKeys,
39
+ linkBehavior: linkBehavior
40
+ });
41
+ let { focusWithinProps: focusWithinProps } = (0, $by1yQ$useFocusWithin)({
42
+ onFocusWithin: props.onFocus,
43
+ onBlurWithin: props.onBlur,
44
+ onFocusWithinChange: props.onFocusChange
45
+ });
46
+ // Share list id and some props with child options.
47
+ let id = (0, $by1yQ$useId)(props.id);
48
+ (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
49
+ id: id,
50
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
51
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
52
+ shouldFocusOnHover: props.shouldFocusOnHover,
53
+ isVirtualized: props.isVirtualized,
54
+ onAction: props.onAction,
55
+ linkBehavior: linkBehavior
56
+ });
57
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $by1yQ$useLabel)({
58
+ ...props,
59
+ id: id,
60
+ // listbox is not an HTML input element so it
61
+ // shouldn't be labeled by a <label> element.
62
+ labelElementType: "span"
63
+ });
64
+ return {
65
+ labelProps: labelProps,
66
+ listBoxProps: (0, $by1yQ$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
67
+ "aria-multiselectable": "true"
68
+ } : {}, {
69
+ role: "listbox",
70
+ ...(0, $by1yQ$mergeProps)(fieldProps, listProps)
71
+ })
72
+ };
73
+ }
74
+
75
+
76
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox};
77
+ //# sourceMappingURL=useListBox.mjs.map
@@ -0,0 +1,77 @@
1
+ import {listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.module.js";
2
+ import {filterDOMProps as $by1yQ$filterDOMProps, useId as $by1yQ$useId, mergeProps as $by1yQ$mergeProps} from "@react-aria/utils";
3
+ import {useFocusWithin as $by1yQ$useFocusWithin} from "@react-aria/interactions";
4
+ import {useLabel as $by1yQ$useLabel} from "@react-aria/label";
5
+ import {useSelectableList as $by1yQ$useSelectableList} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
23
+ let domProps = (0, $by1yQ$filterDOMProps)(props, {
24
+ labelable: true
25
+ });
26
+ // Use props instead of state here. We don't want this to change due to long press.
27
+ let selectionBehavior = props.selectionBehavior || "toggle";
28
+ let linkBehavior = props.linkBehavior || (selectionBehavior === "replace" ? "action" : "override");
29
+ if (selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
30
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
31
+ // selectable in this configuration.
32
+ linkBehavior = "override";
33
+ let { listProps: listProps } = (0, $by1yQ$useSelectableList)({
34
+ ...props,
35
+ ref: ref,
36
+ selectionManager: state.selectionManager,
37
+ collection: state.collection,
38
+ disabledKeys: state.disabledKeys,
39
+ linkBehavior: linkBehavior
40
+ });
41
+ let { focusWithinProps: focusWithinProps } = (0, $by1yQ$useFocusWithin)({
42
+ onFocusWithin: props.onFocus,
43
+ onBlurWithin: props.onBlur,
44
+ onFocusWithinChange: props.onFocusChange
45
+ });
46
+ // Share list id and some props with child options.
47
+ let id = (0, $by1yQ$useId)(props.id);
48
+ (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
49
+ id: id,
50
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
51
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
52
+ shouldFocusOnHover: props.shouldFocusOnHover,
53
+ isVirtualized: props.isVirtualized,
54
+ onAction: props.onAction,
55
+ linkBehavior: linkBehavior
56
+ });
57
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $by1yQ$useLabel)({
58
+ ...props,
59
+ id: id,
60
+ // listbox is not an HTML input element so it
61
+ // shouldn't be labeled by a <label> element.
62
+ labelElementType: "span"
63
+ });
64
+ return {
65
+ labelProps: labelProps,
66
+ listBoxProps: (0, $by1yQ$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === "multiple" ? {
67
+ "aria-multiselectable": "true"
68
+ } : {}, {
69
+ role: "listbox",
70
+ ...(0, $by1yQ$mergeProps)(fieldProps, listProps)
71
+ })
72
+ };
73
+ }
74
+
75
+
76
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox};
77
+ //# sourceMappingURL=useListBox.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAwDM,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B;IAC1G,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,mFAAmF;IACnF,IAAI,oBAAoB,MAAM,iBAAiB,IAAI;IACnD,IAAI,eAAe,MAAM,YAAY,IAAK,CAAA,sBAAsB,YAAY,WAAW,UAAS;IAChG,IAAI,sBAAsB,YAAY,iBAAiB,UACrD,8FAA8F;IAC9F,8FAA8F;IAC9F,oCAAoC;IACpC,eAAe;IAGjB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,GAAG,KAAK;aACR;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;sBAChC;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,eAAe,MAAM,OAAO;QAC5B,cAAc,MAAM,MAAM;QAC1B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,mDAAmD;IACnD,IAAI,KAAK,CAAA,GAAA,YAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;YAClB;QACA,uBAAuB,MAAM,qBAAqB;QAClD,uBAAuB,MAAM,qBAAqB;QAClD,oBAAoB,MAAM,kBAAkB;QAC5C,eAAe,MAAM,aAAa;QAClC,UAAU,MAAM,QAAQ;sBACxB;IACF;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACtC,GAAG,KAAK;YACR;QACA,6CAA6C;QAC7C,6CAA6C;QAC7C,kBAAkB;IACpB;IAEA,OAAO;oBACL;QACA,cAAc,CAAA,GAAA,iBAAS,EAAE,UAAU,kBAAkB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa;YACzG,wBAAwB;QAC1B,IAAI,CAAC,GAAG;YACN,MAAM;YACN,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/listbox/src/useListBox.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\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface ListBoxAria {\n /** Props for the listbox element. */\n listBoxProps: DOMAttributes,\n /** Props for the listbox's visual label element (if any). */\n labelProps: DOMAttributes\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 * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * @default 'override'\n */\n linkBehavior?: 'action' | 'selection' | 'override'\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 // Use props instead of state here. We don't want this to change due to long press.\n let selectionBehavior = props.selectionBehavior || 'toggle';\n let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');\n if (selectionBehavior === 'toggle' && linkBehavior === 'action') {\n // linkBehavior=\"action\" does not work with selectionBehavior=\"toggle\" because there is no way\n // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be\n // selectable in this configuration.\n linkBehavior = 'override';\n }\n\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n linkBehavior\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 onAction: props.onAction,\n linkBehavior\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"],"names":[],"version":3,"file":"useListBox.module.js.map"}
@@ -0,0 +1,43 @@
1
+ var $bAsD1$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useListBoxSection", () => $f32afd5f225c3320$export$c3f9f39876e4bc7);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ function $f32afd5f225c3320$export$c3f9f39876e4bc7(props) {
21
+ let { heading: heading, "aria-label": ariaLabel } = props;
22
+ let headingId = (0, $bAsD1$reactariautils.useId)();
23
+ return {
24
+ itemProps: {
25
+ role: "presentation"
26
+ },
27
+ headingProps: heading ? {
28
+ // Techincally, listbox cannot contain headings according to ARIA.
29
+ // We hide the heading from assistive technology, using role="presentation",
30
+ // and only use it as a visual label for the nested group.
31
+ id: headingId,
32
+ role: "presentation"
33
+ } : {},
34
+ groupProps: {
35
+ role: "group",
36
+ "aria-label": ariaLabel,
37
+ "aria-labelledby": heading ? headingId : undefined
38
+ }
39
+ };
40
+ }
41
+
42
+
43
+ //# sourceMappingURL=useListBoxSection.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA6BM,SAAS,yCAAkB,KAA8B;IAC9D,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,2BAAI;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,kEAAkE;YAClE,4EAA4E;YAC5E,0DAA0D;YAC1D,IAAI;YACJ,MAAM;QACR,IAAI,CAAC;QACL,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY;QAC3C;IACF;AACF","sources":["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\nimport {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface 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\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\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, using role=\"presentation\",\n // and only use it as a visual label for the nested group.\n id: headingId,\n role: 'presentation'\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useListBoxSection.main.js.map"}