@react-aria/listbox 3.10.3-nightly.4149 → 3.10.3-nightly.4157

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/import.mjs CHANGED
@@ -54,12 +54,14 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
54
54
  let domProps = (0, $frWMC$filterDOMProps)(props, {
55
55
  labelable: true
56
56
  });
57
- let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === "replace" ? "action" : "override");
58
- if (state.selectionManager.selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
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
59
61
  // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
60
62
  // selectable in this configuration.
61
63
  linkBehavior = "override";
62
- let { listProps: listProps } = (0, $frWMC$useSelectableList)({
64
+ let { listProps: listProps } = (0, $frWMC$useSelectableList)({
63
65
  ...props,
64
66
  ref: ref,
65
67
  selectionManager: state.selectionManager,
@@ -67,7 +69,7 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
67
69
  disabledKeys: state.disabledKeys,
68
70
  linkBehavior: linkBehavior
69
71
  });
70
- let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
72
+ let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
71
73
  onFocusWithin: props.onFocus,
72
74
  onBlurWithin: props.onBlur,
73
75
  onFocusWithinChange: props.onFocusChange
@@ -83,7 +85,7 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
83
85
  onAction: props.onAction,
84
86
  linkBehavior: linkBehavior
85
87
  });
86
- let { labelProps: labelProps , fieldProps: fieldProps } = (0, $frWMC$useLabel)({
88
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $frWMC$useLabel)({
87
89
  ...props,
88
90
  id: id,
89
91
  // listbox is not an HTML input element so it
@@ -118,7 +120,8 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
118
120
 
119
121
 
120
122
  function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
121
- let { key: key } = props;
123
+ var _item_props;
124
+ let { key: key } = props;
122
125
  let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
123
126
  var _props_isDisabled;
124
127
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);
@@ -147,13 +150,13 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
147
150
  optionProps["aria-labelledby"] = labelId;
148
151
  optionProps["aria-describedby"] = descriptionId;
149
152
  }
153
+ let item = state.collection.getItem(key);
150
154
  if (isVirtualized) {
151
- var _state_collection_getItem;
152
- let index = Number((_state_collection_getItem = state.collection.getItem(key)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.index);
155
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
153
156
  optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
154
157
  optionProps["aria-setsize"] = (0, $frWMC$getItemCount)(state.collection);
155
158
  }
156
- let { itemProps: itemProps , isPressed: isPressed , isFocused: isFocused , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
159
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
157
160
  selectionManager: state.selectionManager,
158
161
  key: key,
159
162
  ref: ref,
@@ -168,7 +171,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
168
171
  } : undefined,
169
172
  linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
170
173
  });
171
- let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
174
+ let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
172
175
  isDisabled: isDisabled || !shouldFocusOnHover,
173
176
  onHoverStart () {
174
177
  if (!(0, $frWMC$isFocusVisible)()) {
@@ -177,10 +180,14 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
177
180
  }
178
181
  }
179
182
  });
183
+ let domProps = (0, $frWMC$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
184
+ isLink: !!(item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.href)
185
+ });
186
+ delete domProps.id;
180
187
  return {
181
188
  optionProps: {
182
189
  ...optionProps,
183
- ...(0, $frWMC$mergeProps)(itemProps, hoverProps),
190
+ ...(0, $frWMC$mergeProps)(domProps, itemProps, hoverProps),
184
191
  id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
185
192
  },
186
193
  labelProps: {
@@ -212,7 +219,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
212
219
  * governing permissions and limitations under the License.
213
220
  */
214
221
  function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
215
- let { heading: heading , "aria-label": ariaLabel } = props;
222
+ let { heading: heading, "aria-label": ariaLabel } = props;
216
223
  let headingId = (0, $frWMC$useId)();
217
224
  return {
218
225
  itemProps: {
package/dist/main.js CHANGED
@@ -63,12 +63,14 @@ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
63
63
  let domProps = (0, $eFCLV$reactariautils.filterDOMProps)(props, {
64
64
  labelable: true
65
65
  });
66
- let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === "replace" ? "action" : "override");
67
- if (state.selectionManager.selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
66
+ // Use props instead of state here. We don't want this to change due to long press.
67
+ let selectionBehavior = props.selectionBehavior || "toggle";
68
+ let linkBehavior = props.linkBehavior || (selectionBehavior === "replace" ? "action" : "override");
69
+ if (selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
68
70
  // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
69
71
  // selectable in this configuration.
70
72
  linkBehavior = "override";
71
- let { listProps: listProps } = (0, $eFCLV$reactariaselection.useSelectableList)({
73
+ let { listProps: listProps } = (0, $eFCLV$reactariaselection.useSelectableList)({
72
74
  ...props,
73
75
  ref: ref,
74
76
  selectionManager: state.selectionManager,
@@ -76,7 +78,7 @@ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
76
78
  disabledKeys: state.disabledKeys,
77
79
  linkBehavior: linkBehavior
78
80
  });
79
- let { focusWithinProps: focusWithinProps } = (0, $eFCLV$reactariainteractions.useFocusWithin)({
81
+ let { focusWithinProps: focusWithinProps } = (0, $eFCLV$reactariainteractions.useFocusWithin)({
80
82
  onFocusWithin: props.onFocus,
81
83
  onBlurWithin: props.onBlur,
82
84
  onFocusWithinChange: props.onFocusChange
@@ -92,7 +94,7 @@ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
92
94
  onAction: props.onAction,
93
95
  linkBehavior: linkBehavior
94
96
  });
95
- let { labelProps: labelProps , fieldProps: fieldProps } = (0, $eFCLV$reactarialabel.useLabel)({
97
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $eFCLV$reactarialabel.useLabel)({
96
98
  ...props,
97
99
  id: id,
98
100
  // listbox is not an HTML input element so it
@@ -127,7 +129,8 @@ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
127
129
 
128
130
 
129
131
  function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
130
- let { key: key } = props;
132
+ var _item_props;
133
+ let { key: key } = props;
131
134
  let data = (0, $87beb89ab4a308fd$export$3585ede4d035bf14).get(state);
132
135
  var _props_isDisabled;
133
136
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);
@@ -156,13 +159,13 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
156
159
  optionProps["aria-labelledby"] = labelId;
157
160
  optionProps["aria-describedby"] = descriptionId;
158
161
  }
162
+ let item = state.collection.getItem(key);
159
163
  if (isVirtualized) {
160
- var _state_collection_getItem;
161
- let index = Number((_state_collection_getItem = state.collection.getItem(key)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.index);
164
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
162
165
  optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
163
166
  optionProps["aria-setsize"] = (0, $eFCLV$reactstatelycollections.getItemCount)(state.collection);
164
167
  }
165
- let { itemProps: itemProps , isPressed: isPressed , isFocused: isFocused , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $eFCLV$reactariaselection.useSelectableItem)({
168
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $eFCLV$reactariaselection.useSelectableItem)({
166
169
  selectionManager: state.selectionManager,
167
170
  key: key,
168
171
  ref: ref,
@@ -177,7 +180,7 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
177
180
  } : undefined,
178
181
  linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
179
182
  });
180
- let { hoverProps: hoverProps } = (0, $eFCLV$reactariainteractions.useHover)({
183
+ let { hoverProps: hoverProps } = (0, $eFCLV$reactariainteractions.useHover)({
181
184
  isDisabled: isDisabled || !shouldFocusOnHover,
182
185
  onHoverStart () {
183
186
  if (!(0, $eFCLV$reactariainteractions.isFocusVisible)()) {
@@ -186,10 +189,14 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
186
189
  }
187
190
  }
188
191
  });
192
+ let domProps = (0, $eFCLV$reactariautils.filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
193
+ isLink: !!(item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.href)
194
+ });
195
+ delete domProps.id;
189
196
  return {
190
197
  optionProps: {
191
198
  ...optionProps,
192
- ...(0, $eFCLV$reactariautils.mergeProps)(itemProps, hoverProps),
199
+ ...(0, $eFCLV$reactariautils.mergeProps)(domProps, itemProps, hoverProps),
193
200
  id: (0, $87beb89ab4a308fd$export$9145995848b05025)(state, key)
194
201
  },
195
202
  labelProps: {
@@ -221,7 +228,7 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
221
228
  * governing permissions and limitations under the License.
222
229
  */
223
230
  function $f32afd5f225c3320$export$c3f9f39876e4bc7(props) {
224
- let { heading: heading , "aria-label": ariaLabel } = props;
231
+ let { heading: heading, "aria-label": ariaLabel } = props;
225
232
  let headingId = (0, $eFCLV$reactariautils.useId)();
226
233
  return {
227
234
  itemProps: {
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,QAAQ,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,IAAI;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;ADuBO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B;IAC1G,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,eAAe,MAAM,gBAAiB,CAAA,MAAM,iBAAiB,sBA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Y;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 let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === 'replace' ? 'action' : 'override');\n if (state.selectionManager.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';\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\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.disabledKeys.has(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 if (isVirtualized) {\n let index = Number(state.collection.getItem(key)?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\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: data?.onAction ? () => data?.onAction?.(key) : 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 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 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":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,QAAQ,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,IAAI;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;ADuBO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B;IAC1G,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,mFAAmF;IACnF,IAAI,oBAAoB,MAAM,qBAAqB;IACnD,IAAI,eAAe,MAAM,gBAAiB,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;QACxB,YAAY,MAAM;QAClB,cAAc,MAAM;sBACpB;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,eAAe,MAAM;QACrB,cAAc,MAAM;QACpB,qBAAqB,MAAM;IAC7B;IAEA,mDAAmD;IACnD,IAAI,KAAK,CAAA,GAAA,2BAAI,EAAE,MAAM;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AAc,CAAC;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,2CAAa,KAAK;gBACrB,MAAM,iBAAiB,WAAW;gBAClC,MAAM,iBAAiB,cAAc;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,iBAAA,kBAAA,KAAA,IAAA,KAAM,OAAO;QAAC,QAAQ,CAAC,CAAC,CAAA,iBAAA,kBAAA,KAAA,IAAA,CAAA,cAAA,KAAM,mBAAN,yBAAA,KAAA,IAAA,YAAa,IAAH;IAAO;IACvE,OAAO,SAAS;IAEhB,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,gCAAS,EAAE,UAAU,WAAW,WAAW;YAC9C,IAAI,CAAA,GAAA,yCAAQ,EAAE,OAAO;QACvB;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,CAAA,GAAA,2CAAa;oBAC1C;oBACA;mBACA;yBACA;mBACA;IACF;AACF;;;AC7KA;;;;;;;;;;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/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';\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\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.disabledKeys.has(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 {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: data?.onAction ? () => data?.onAction?.(key) : 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, {isLink: !!item?.props?.href});\n delete domProps.id;\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps),\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":"main.js.map"}
package/dist/module.js CHANGED
@@ -54,12 +54,14 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
54
54
  let domProps = (0, $frWMC$filterDOMProps)(props, {
55
55
  labelable: true
56
56
  });
57
- let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === "replace" ? "action" : "override");
58
- if (state.selectionManager.selectionBehavior === "toggle" && linkBehavior === "action") // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
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
59
61
  // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
60
62
  // selectable in this configuration.
61
63
  linkBehavior = "override";
62
- let { listProps: listProps } = (0, $frWMC$useSelectableList)({
64
+ let { listProps: listProps } = (0, $frWMC$useSelectableList)({
63
65
  ...props,
64
66
  ref: ref,
65
67
  selectionManager: state.selectionManager,
@@ -67,7 +69,7 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
67
69
  disabledKeys: state.disabledKeys,
68
70
  linkBehavior: linkBehavior
69
71
  });
70
- let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
72
+ let { focusWithinProps: focusWithinProps } = (0, $frWMC$useFocusWithin)({
71
73
  onFocusWithin: props.onFocus,
72
74
  onBlurWithin: props.onBlur,
73
75
  onFocusWithinChange: props.onFocusChange
@@ -83,7 +85,7 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
83
85
  onAction: props.onAction,
84
86
  linkBehavior: linkBehavior
85
87
  });
86
- let { labelProps: labelProps , fieldProps: fieldProps } = (0, $frWMC$useLabel)({
88
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $frWMC$useLabel)({
87
89
  ...props,
88
90
  id: id,
89
91
  // listbox is not an HTML input element so it
@@ -118,7 +120,8 @@ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
118
120
 
119
121
 
120
122
  function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
121
- let { key: key } = props;
123
+ var _item_props;
124
+ let { key: key } = props;
122
125
  let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
123
126
  var _props_isDisabled;
124
127
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.disabledKeys.has(key);
@@ -147,13 +150,13 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
147
150
  optionProps["aria-labelledby"] = labelId;
148
151
  optionProps["aria-describedby"] = descriptionId;
149
152
  }
153
+ let item = state.collection.getItem(key);
150
154
  if (isVirtualized) {
151
- var _state_collection_getItem;
152
- let index = Number((_state_collection_getItem = state.collection.getItem(key)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.index);
155
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
153
156
  optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
154
157
  optionProps["aria-setsize"] = (0, $frWMC$getItemCount)(state.collection);
155
158
  }
156
- let { itemProps: itemProps , isPressed: isPressed , isFocused: isFocused , hasAction: hasAction , allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
159
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $frWMC$useSelectableItem)({
157
160
  selectionManager: state.selectionManager,
158
161
  key: key,
159
162
  ref: ref,
@@ -168,7 +171,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
168
171
  } : undefined,
169
172
  linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
170
173
  });
171
- let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
174
+ let { hoverProps: hoverProps } = (0, $frWMC$useHover)({
172
175
  isDisabled: isDisabled || !shouldFocusOnHover,
173
176
  onHoverStart () {
174
177
  if (!(0, $frWMC$isFocusVisible)()) {
@@ -177,10 +180,14 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
177
180
  }
178
181
  }
179
182
  });
183
+ let domProps = (0, $frWMC$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
184
+ isLink: !!(item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.href)
185
+ });
186
+ delete domProps.id;
180
187
  return {
181
188
  optionProps: {
182
189
  ...optionProps,
183
- ...(0, $frWMC$mergeProps)(itemProps, hoverProps),
190
+ ...(0, $frWMC$mergeProps)(domProps, itemProps, hoverProps),
184
191
  id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
185
192
  },
186
193
  labelProps: {
@@ -212,7 +219,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
212
219
  * governing permissions and limitations under the License.
213
220
  */
214
221
  function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
215
- let { heading: heading , "aria-label": ariaLabel } = props;
222
+ let { heading: heading, "aria-label": ariaLabel } = props;
216
223
  let headingId = (0, $frWMC$useId)();
217
224
  return {
218
225
  itemProps: {
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,QAAQ,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,IAAI;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;ADuBO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GA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,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 let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === 'replace' ? 'action' : 'override');\n if (state.selectionManager.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';\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\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.disabledKeys.has(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 if (isVirtualized) {\n let index = Number(state.collection.getItem(key)?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\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: data?.onAction ? () => data?.onAction?.(key) : 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 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 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;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,QAAQ,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,IAAI;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD;;;;;;ADuBO,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAA2B;IAC1G,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,mFAAmF;IACnF,IAAI,oBAAoB,MAAM,qBAAqB;IACnD,IAAI,eAAe,MAAM,gBAAiB,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;QACxB,YAAY,MAAM;QAClB,cAAc,MAAM;sBACpB;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,eAAe,MAA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kBAAA,KAAA,IAAA,KAAM;IACtB;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,cAAc,CAAC;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,qBAAa,KAAK;gBACrB,MAAM,iBAAiB,WAAW;gBAClC,MAAM,iBAAiB,cAAc;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,iBAAA,kBAAA,KAAA,IAAA,KAAM,OAAO;QAAC,QAAQ,CAAC,CAAC,CAAA,iBAAA,kBAAA,KAAA,IAAA,CAAA,cAAA,KAAM,mBAAN,yBAAA,KAAA,IAAA,YAAa,IAAH;IAAO;IACvE,OAAO,SAAS;IAEhB,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,WAAW,WAAW;YAC9C,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;;;AC7KA;;;;;;;;;;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';\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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {Key, RefObject} from 'react';\nimport {ListState} from '@react-stately/list';\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.disabledKeys.has(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 {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: data?.onAction ? () => data?.onAction?.(key) : 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, {isLink: !!item?.props?.href});\n delete domProps.id;\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps),\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 +1 @@
1
- {"mappings":";;;;;AAeA;IACE,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAA;CACnD;AAED,OAAO,MAAM,+CAAsD,CAAC;AAUpE,0BAA0B,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,CAQtE;ACrBD;IACE,qCAAqC;IACrC,YAAY,EAAE,aAAa,CAAC;IAC5B,6DAA6D;IAC7D,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED,oCAAoC,CAAC,CAAE,SAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,UAAU,CAAC;IAClF,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAA;CACnD;AAED;;;;;GAKG;AACH,2BAA2B,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,UA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qBpF;AC3CD,YAAY,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBoxSection.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\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":"types.d.ts.map"}
1
+ {"mappings":";;;;;AAeA;IACE,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CA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IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qCAAqC;IACrC,GAAG,EAAE,GAAG,CAAC;IAET;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED;;;;;GAKG;AACH,0BAA0B,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,UAAU,CAqFtH;AC7JD;IACE,mCAAmC;IACnC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;IACE,uCAAuC;IACvC,SAAS,EAAE,aAAa,CAAC;IAEzB,6CAA6C;IAC7C,YAAY,EAAE,aAAa,CAAC;IAE5B,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;;GAIG;AACH,kCAAkC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CAqBpF;AC3CD,YAAY,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBoxSection.ts","packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/index.ts","packages/@react-aria/listbox/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\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":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/listbox",
3
- "version": "3.10.3-nightly.4149+a399db1e3",
3
+ "version": "3.10.3-nightly.4157+633bb4fb6",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,15 +22,15 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "3.0.0-nightly.2440+a399db1e3",
26
- "@react-aria/interactions": "3.0.0-nightly.2440+a399db1e3",
27
- "@react-aria/label": "3.0.0-nightly.2440+a399db1e3",
28
- "@react-aria/selection": "3.0.0-nightly.2440+a399db1e3",
29
- "@react-aria/utils": "3.0.0-nightly.2440+a399db1e3",
30
- "@react-stately/collections": "3.0.0-nightly.2440+a399db1e3",
31
- "@react-stately/list": "3.9.3-nightly.4149+a399db1e3",
32
- "@react-types/listbox": "3.4.5-nightly.4149+a399db1e3",
33
- "@react-types/shared": "3.0.0-nightly.2440+a399db1e3",
25
+ "@react-aria/focus": "3.0.0-nightly.2448+633bb4fb6",
26
+ "@react-aria/interactions": "3.0.0-nightly.2448+633bb4fb6",
27
+ "@react-aria/label": "3.0.0-nightly.2448+633bb4fb6",
28
+ "@react-aria/selection": "3.0.0-nightly.2448+633bb4fb6",
29
+ "@react-aria/utils": "3.0.0-nightly.2448+633bb4fb6",
30
+ "@react-stately/collections": "3.0.0-nightly.2448+633bb4fb6",
31
+ "@react-stately/list": "3.9.3-nightly.4157+633bb4fb6",
32
+ "@react-types/listbox": "3.4.5-nightly.4157+633bb4fb6",
33
+ "@react-types/shared": "3.0.0-nightly.2448+633bb4fb6",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "a399db1e314243a023f7b5c95e319eba4496604c"
43
+ "gitHead": "633bb4fb6cc205b9911a21fb81a7a70c662ec0ce"
44
44
  }
package/src/useListBox.ts CHANGED
@@ -66,8 +66,10 @@ export interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'childr
66
66
  */
67
67
  export function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {
68
68
  let domProps = filterDOMProps(props, {labelable: true});
69
- let linkBehavior = props.linkBehavior || (state.selectionManager.selectionBehavior === 'replace' ? 'action' : 'override');
70
- if (state.selectionManager.selectionBehavior === 'toggle' && linkBehavior === 'action') {
69
+ // Use props instead of state here. We don't want this to change due to long press.
70
+ let selectionBehavior = props.selectionBehavior || 'toggle';
71
+ let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');
72
+ if (selectionBehavior === 'toggle' && linkBehavior === 'action') {
71
73
  // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
72
74
  // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
73
75
  // selectable in this configuration.
package/src/useOption.ts CHANGED
@@ -11,10 +11,10 @@
11
11
  */
12
12
 
13
13
  import {DOMAttributes, FocusableElement} from '@react-types/shared';
14
+ import {filterDOMProps, isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';
14
15
  import {getItemCount} from '@react-stately/collections';
15
16
  import {getItemId, listData} from './utils';
16
17
  import {isFocusVisible, useHover} from '@react-aria/interactions';
17
- import {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';
18
18
  import {Key, RefObject} from 'react';
19
19
  import {ListState} from '@react-stately/list';
20
20
  import {SelectableItemStates, useSelectableItem} from '@react-aria/selection';
@@ -118,8 +118,9 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
118
118
  optionProps['aria-describedby'] = descriptionId;
119
119
  }
120
120
 
121
+ let item = state.collection.getItem(key);
121
122
  if (isVirtualized) {
122
- let index = Number(state.collection.getItem(key)?.index);
123
+ let index = Number(item?.index);
123
124
  optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;
124
125
  optionProps['aria-setsize'] = getItemCount(state.collection);
125
126
  }
@@ -147,10 +148,13 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
147
148
  }
148
149
  });
149
150
 
151
+ let domProps = filterDOMProps(item?.props, {isLink: !!item?.props?.href});
152
+ delete domProps.id;
153
+
150
154
  return {
151
155
  optionProps: {
152
156
  ...optionProps,
153
- ...mergeProps(itemProps, hoverProps),
157
+ ...mergeProps(domProps, itemProps, hoverProps),
154
158
  id: getItemId(state, key)
155
159
  },
156
160
  labelProps: {