@react-aria/listbox 3.13.6 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"mappings":";;;;;AAeA;IACE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,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;ACtBD;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;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;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,EA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a,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"}
1
+ {"mappings":";;;;;AAeA;IACE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,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,E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C9C,cAAc,EAAE,OAAO,CAAA;CACxB;AAED;IACE;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,iDAAiD;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,GAAG,IAAI,CAAC,GAAG,UAAU,CAyF7H;AChKD;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"}
@@ -66,6 +66,7 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
66
66
  var _data_onAction;
67
67
  return data === null || data === void 0 ? void 0 : (_data_onAction = data.onAction) === null || _data_onAction === void 0 ? void 0 : _data_onAction.call(data, key);
68
68
  } : undefined;
69
+ let id = (0, $87beb89ab4a308fd$exports.getItemId)(state, key);
69
70
  let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $bOFHO$reactariaselection.useSelectableItem)({
70
71
  selectionManager: state.selectionManager,
71
72
  key: key,
@@ -76,7 +77,8 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
76
77
  shouldUseVirtualFocus: shouldUseVirtualFocus,
77
78
  isDisabled: isDisabled,
78
79
  onAction: onAction || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) ? (0, $bOFHO$reactariautils.chain)(item === null || item === void 0 ? void 0 : (_item_props1 = item.props) === null || _item_props1 === void 0 ? void 0 : _item_props1.onAction, onAction) : undefined,
79
- linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
80
+ linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior,
81
+ id: id
80
82
  });
81
83
  let { hoverProps: hoverProps } = (0, $bOFHO$reactariainteractions.useHover)({
82
84
  isDisabled: isDisabled || !shouldFocusOnHover,
@@ -94,7 +96,7 @@ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
94
96
  optionProps: {
95
97
  ...optionProps,
96
98
  ...(0, $bOFHO$reactariautils.mergeProps)(domProps, itemProps, hoverProps, linkProps),
97
- id: (0, $87beb89ab4a308fd$exports.getItemId)(state, key)
99
+ id: id
98
100
  },
99
101
  labelProps: {
100
102
  id: labelId
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6EM,SAAS,0CAAa,KAAsB,EAAE,KAAmB,EAAE,GAAuC;QAiDvF,aAA8B;IAhDtD,IAAI,OACF,GAAG,EACJ,GAAG;IAEJ,IAAI,OAAO,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC;QAEP;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QACtD;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QAC3C;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA,+BAA+B,iBAAA,2BAAA,KAAM,qBAAqB;QAC7D;IAAzB,IAAI,qBAAqB,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,iBAAA,2BAAA,KAAM,kBAAkB;QACjD;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA,+BAA+B,iB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A,YAAa,QAAQ,IAAG,CAAA,GAAA,2BAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,YAAY;QACvF,YAAY,EAAE,iBAAA,2BAAA,KAAM,YAAY;IAClC;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,YAAY,cAAc,CAAC;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,2CAAa,KAAK;gBACrB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,kCAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,gCAAS,EAAE,UAAU,WAAW,YAAY,UAAU;YACzD,IAAI,CAAA,GAAA,mCAAQ,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","sources":["packages/@react-aria/listbox/src/useOption.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {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 | null>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isFocusVisible: isFocused && isFocusVisible(),\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\n };\n}\n"],"names":[],"version":3,"file":"useOption.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6EM,SAAS,0CAAa,KAAsB,EAAE,KAAmB,EAAE,GAAuC;QAkDvF,aAA8B;IAjDtD,IAAI,OACF,GAAG,EACJ,GAAG;IAEJ,IAAI,OAAO,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC;QAEP;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QACtD;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QAC3C;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA,+BAA+B,iBAAA,2BAAA,KAAM,qBAAqB;QAC7D;IAAzB,IAAI,qBAAqB,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,iBAAA,2BAAA,KAAM,kBAAkB;QACjD;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA,+BAA+B,iBAAA,2BAAA,KAAM,qBAAqB;QAClE;IAApB,IAAI,gBAAgB,CAAA,uBAAA,MAAM,aAAa,cAAnB,kCAAA,uBAAuB,iBAAA,2BAAA,KAAM,aAAa;IAE9D,IAAI,UAAU,CAAA,GAAA,+BAAQ;IACtB,IAAI,gBAAgB,CAAA,GAAA,+BAAQ;IAE5B,IAAI,cAAc;QAChB,MAAM;QACN,iBAAiB,cAAc;QAC/B,iBAAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAA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;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,2CAAa,KAAK;gBACrB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,kCAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,gCAAS,EAAE,UAAU,WAAW,YAAY,UAAU;gBACzD;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,CAAA,GAAA,2CAAa;oBAC1C;oBACA;mBACA;yBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/listbox/src/useOption.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {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 | null>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let id = getItemId(state, key);\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior,\n id\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id\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"],"names":[],"version":3,"file":"useOption.main.js.map"}
@@ -60,6 +60,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
60
60
  var _data_onAction;
61
61
  return data === null || data === void 0 ? void 0 : (_data_onAction = data.onAction) === null || _data_onAction === void 0 ? void 0 : _data_onAction.call(data, key);
62
62
  } : undefined;
63
+ let id = (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key);
63
64
  let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $fcwmx$useSelectableItem)({
64
65
  selectionManager: state.selectionManager,
65
66
  key: key,
@@ -70,7 +71,8 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
70
71
  shouldUseVirtualFocus: shouldUseVirtualFocus,
71
72
  isDisabled: isDisabled,
72
73
  onAction: onAction || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) ? (0, $fcwmx$chain)(item === null || item === void 0 ? void 0 : (_item_props1 = item.props) === null || _item_props1 === void 0 ? void 0 : _item_props1.onAction, onAction) : undefined,
73
- linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
74
+ linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior,
75
+ id: id
74
76
  });
75
77
  let { hoverProps: hoverProps } = (0, $fcwmx$useHover)({
76
78
  isDisabled: isDisabled || !shouldFocusOnHover,
@@ -88,7 +90,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
88
90
  optionProps: {
89
91
  ...optionProps,
90
92
  ...(0, $fcwmx$mergeProps)(domProps, itemProps, hoverProps, linkProps),
91
- id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
93
+ id: id
92
94
  },
93
95
  labelProps: {
94
96
  id: labelId
@@ -60,6 +60,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
60
60
  var _data_onAction;
61
61
  return data === null || data === void 0 ? void 0 : (_data_onAction = data.onAction) === null || _data_onAction === void 0 ? void 0 : _data_onAction.call(data, key);
62
62
  } : undefined;
63
+ let id = (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key);
63
64
  let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $fcwmx$useSelectableItem)({
64
65
  selectionManager: state.selectionManager,
65
66
  key: key,
@@ -70,7 +71,8 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
70
71
  shouldUseVirtualFocus: shouldUseVirtualFocus,
71
72
  isDisabled: isDisabled,
72
73
  onAction: onAction || (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) ? (0, $fcwmx$chain)(item === null || item === void 0 ? void 0 : (_item_props1 = item.props) === null || _item_props1 === void 0 ? void 0 : _item_props1.onAction, onAction) : undefined,
73
- linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior
74
+ linkBehavior: data === null || data === void 0 ? void 0 : data.linkBehavior,
75
+ id: id
74
76
  });
75
77
  let { hoverProps: hoverProps } = (0, $fcwmx$useHover)({
76
78
  isDisabled: isDisabled || !shouldFocusOnHover,
@@ -88,7 +90,7 @@ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
88
90
  optionProps: {
89
91
  ...optionProps,
90
92
  ...(0, $fcwmx$mergeProps)(domProps, itemProps, hoverProps, linkProps),
91
- id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
93
+ id: id
92
94
  },
93
95
  labelProps: {
94
96
  id: labelId
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6EM,SAAS,0CAAa,KAAsB,EAAE,KAAmB,EAAE,GAAuC;QAiDvF,aAA8B;IAhDtD,IAAI,OACF,GAAG,EACJ,GAAG;IAEJ,IAAI,OAAO,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;QAEP;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QACtD;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBA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\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {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 | null>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isFocusVisible: isFocused && isFocusVisible(),\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\n };\n}\n"],"names":[],"version":3,"file":"useOption.module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6EM,SAAS,0CAAa,KAAsB,EAAE,KAAmB,EAAE,GAAuC;QAkDvF,aAA8B;IAjDtD,IAAI,OACF,GAAG,EACJ,GAAG;IAEJ,IAAI,OAAO,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;QAEP;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QACtD;IAAjB,IAAI,aAAa,CAAA,oBAAA,MAAM,UAAU,cAAhB,+BAAA,oBAAoB,MAAM,gBAAgB,CAAC,UAAU,CAAC;QAC3C;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA,+BAA+B,iBAAA,2BAAA,KAAM,qBAAqB;QAC7D;IAAzB,IAAI,qBAAqB,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,iBAAA,2BAAA,KAAM,kBAAkB;QACjD;IAA5B,IAAI,wBAAwB,CAAA,+BAAA,MAAM,qBAAqB,cAA3B,0CAAA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;QACA,UAAU,aAAY,iBAAA,4BAAA,cAAA,KAAM,KAAK,cAAX,kCAAA,YAAa,QAAQ,IAAG,CAAA,GAAA,YAAI,EAAE,iBAAA,4BAAA,eAAA,KAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,EAAE,YAAY;QACvF,YAAY,EAAE,iBAAA,2BAAA,KAAM,YAAY;YAChC;IACF;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,cAAc,CAAC;QAC3B;YACE,IAAI,CAAC,CAAA,GAAA,qBAAa,KAAK;gBACrB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC;YACvC;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,mBAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,WAAW,YAAY,UAAU;gBACzD;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,CAAA,GAAA,qBAAa;oBAC1C;oBACA;mBACA;yBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/listbox/src/useOption.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {chain, filterDOMProps, isMac, isWebKit, mergeProps, useLinkProps, useSlotId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {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 | null>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let id = getItemId(state, key);\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior,\n id\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id\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"],"names":[],"version":3,"file":"useOption.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/listbox",
3
- "version": "3.13.6",
3
+ "version": "3.14.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,14 +22,14 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/interactions": "^3.22.5",
26
- "@react-aria/label": "^3.7.13",
27
- "@react-aria/selection": "^3.21.0",
28
- "@react-aria/utils": "^3.26.0",
29
- "@react-stately/collections": "^3.12.0",
30
- "@react-stately/list": "^3.11.1",
31
- "@react-types/listbox": "^3.5.3",
32
- "@react-types/shared": "^3.26.0",
25
+ "@react-aria/interactions": "^3.23.0",
26
+ "@react-aria/label": "^3.7.14",
27
+ "@react-aria/selection": "^3.22.0",
28
+ "@react-aria/utils": "^3.27.0",
29
+ "@react-stately/collections": "^3.12.1",
30
+ "@react-stately/list": "^3.11.2",
31
+ "@react-types/listbox": "^3.5.4",
32
+ "@react-types/shared": "^3.27.0",
33
33
  "@swc/helpers": "^0.5.0"
34
34
  },
35
35
  "peerDependencies": {
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
42
+ "gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
43
43
  }
package/src/useOption.ts CHANGED
@@ -125,6 +125,7 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
125
125
  }
126
126
 
127
127
  let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;
128
+ let id = getItemId(state, key);
128
129
  let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({
129
130
  selectionManager: state.selectionManager,
130
131
  key,
@@ -135,7 +136,8 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
135
136
  shouldUseVirtualFocus,
136
137
  isDisabled,
137
138
  onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,
138
- linkBehavior: data?.linkBehavior
139
+ linkBehavior: data?.linkBehavior,
140
+ id
139
141
  });
140
142
 
141
143
  let {hoverProps} = useHover({
@@ -156,7 +158,7 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
156
158
  optionProps: {
157
159
  ...optionProps,
158
160
  ...mergeProps(domProps, itemProps, hoverProps, linkProps),
159
- id: getItemId(state, key)
161
+ id
160
162
  },
161
163
  labelProps: {
162
164
  id: labelId