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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import {useId as $8pE4M$useId} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
15
+ let { heading: heading, "aria-label": ariaLabel } = props;
16
+ let headingId = (0, $8pE4M$useId)();
17
+ return {
18
+ itemProps: {
19
+ role: "presentation"
20
+ },
21
+ headingProps: heading ? {
22
+ // Techincally, listbox cannot contain headings according to ARIA.
23
+ // We hide the heading from assistive technology, using role="presentation",
24
+ // and only use it as a visual label for the nested group.
25
+ id: headingId,
26
+ role: "presentation"
27
+ } : {},
28
+ groupProps: {
29
+ role: "group",
30
+ "aria-label": ariaLabel,
31
+ "aria-labelledby": heading ? headingId : undefined
32
+ }
33
+ };
34
+ }
35
+
36
+
37
+ export {$af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection};
38
+ //# sourceMappingURL=useListBoxSection.mjs.map
@@ -0,0 +1,38 @@
1
+ import {useId as $8pE4M$useId} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $af383d3bef1cfdc9$export$c3f9f39876e4bc7(props) {
15
+ let { heading: heading, "aria-label": ariaLabel } = props;
16
+ let headingId = (0, $8pE4M$useId)();
17
+ return {
18
+ itemProps: {
19
+ role: "presentation"
20
+ },
21
+ headingProps: heading ? {
22
+ // Techincally, listbox cannot contain headings according to ARIA.
23
+ // We hide the heading from assistive technology, using role="presentation",
24
+ // and only use it as a visual label for the nested group.
25
+ id: headingId,
26
+ role: "presentation"
27
+ } : {},
28
+ groupProps: {
29
+ role: "group",
30
+ "aria-label": ariaLabel,
31
+ "aria-labelledby": heading ? headingId : undefined
32
+ }
33
+ };
34
+ }
35
+
36
+
37
+ export {$af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection};
38
+ //# sourceMappingURL=useListBoxSection.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AA6BM,SAAS,yCAAkB,KAA8B;IAC9D,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,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/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, using role=\"presentation\",\n // and only use it as a visual label for the nested group.\n id: headingId,\n role: 'presentation'\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useListBoxSection.module.js.map"}
@@ -0,0 +1,116 @@
1
+ var $87beb89ab4a308fd$exports = require("./utils.main.js");
2
+ var $bOFHO$reactariautils = require("@react-aria/utils");
3
+ var $bOFHO$reactstatelycollections = require("@react-stately/collections");
4
+ var $bOFHO$reactariainteractions = require("@react-aria/interactions");
5
+ var $bOFHO$reactariaselection = require("@react-aria/selection");
6
+
7
+
8
+ function $parcel$export(e, n, v, s) {
9
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
+ }
11
+
12
+ $parcel$export(module.exports, "useOption", () => $c164f9f79f4cef2d$export$497855f14858aa34);
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
24
+
25
+
26
+
27
+
28
+ function $c164f9f79f4cef2d$export$497855f14858aa34(props, state, ref) {
29
+ var _item_props, _item_props1;
30
+ let { key: key } = props;
31
+ let data = (0, $87beb89ab4a308fd$exports.listData).get(state);
32
+ var _props_isDisabled;
33
+ let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
34
+ var _props_isSelected;
35
+ let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
36
+ var _props_shouldSelectOnPressUp;
37
+ let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data === null || data === void 0 ? void 0 : data.shouldSelectOnPressUp;
38
+ var _props_shouldFocusOnHover;
39
+ let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data === null || data === void 0 ? void 0 : data.shouldFocusOnHover;
40
+ var _props_shouldUseVirtualFocus;
41
+ let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data === null || data === void 0 ? void 0 : data.shouldUseVirtualFocus;
42
+ var _props_isVirtualized;
43
+ let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data === null || data === void 0 ? void 0 : data.isVirtualized;
44
+ let labelId = (0, $bOFHO$reactariautils.useSlotId)();
45
+ let descriptionId = (0, $bOFHO$reactariautils.useSlotId)();
46
+ let optionProps = {
47
+ role: "option",
48
+ "aria-disabled": isDisabled || undefined,
49
+ "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
50
+ };
51
+ // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
52
+ // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
53
+ // https://bugs.webkit.org/show_bug.cgi?id=209279
54
+ if (!((0, $bOFHO$reactariautils.isMac)() && (0, $bOFHO$reactariautils.isWebKit)())) {
55
+ optionProps["aria-label"] = props["aria-label"];
56
+ optionProps["aria-labelledby"] = labelId;
57
+ optionProps["aria-describedby"] = descriptionId;
58
+ }
59
+ let item = state.collection.getItem(key);
60
+ if (isVirtualized) {
61
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
62
+ optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
63
+ optionProps["aria-setsize"] = (0, $bOFHO$reactstatelycollections.getItemCount)(state.collection);
64
+ }
65
+ let onAction = (data === null || data === void 0 ? void 0 : data.onAction) ? ()=>{
66
+ var _data_onAction;
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
+ } : undefined;
69
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $bOFHO$reactariaselection.useSelectableItem)({
70
+ selectionManager: state.selectionManager,
71
+ key: key,
72
+ ref: ref,
73
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
74
+ allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
75
+ isVirtualized: isVirtualized,
76
+ shouldUseVirtualFocus: shouldUseVirtualFocus,
77
+ isDisabled: isDisabled,
78
+ 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
+ });
81
+ let { hoverProps: hoverProps } = (0, $bOFHO$reactariainteractions.useHover)({
82
+ isDisabled: isDisabled || !shouldFocusOnHover,
83
+ onHoverStart () {
84
+ if (!(0, $bOFHO$reactariainteractions.isFocusVisible)()) {
85
+ state.selectionManager.setFocused(true);
86
+ state.selectionManager.setFocusedKey(key);
87
+ }
88
+ }
89
+ });
90
+ let domProps = (0, $bOFHO$reactariautils.filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
91
+ delete domProps.id;
92
+ let linkProps = (0, $bOFHO$reactariautils.useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
93
+ return {
94
+ optionProps: {
95
+ ...optionProps,
96
+ ...(0, $bOFHO$reactariautils.mergeProps)(domProps, itemProps, hoverProps, linkProps),
97
+ id: (0, $87beb89ab4a308fd$exports.getItemId)(state, key)
98
+ },
99
+ labelProps: {
100
+ id: labelId
101
+ },
102
+ descriptionProps: {
103
+ id: descriptionId
104
+ },
105
+ isFocused: isFocused,
106
+ isFocusVisible: isFocused && (0, $bOFHO$reactariainteractions.isFocusVisible)(),
107
+ isSelected: isSelected,
108
+ isDisabled: isDisabled,
109
+ isPressed: isPressed,
110
+ allowsSelection: allowsSelection,
111
+ hasAction: hasAction
112
+ };
113
+ }
114
+
115
+
116
+ //# sourceMappingURL=useOption.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8EM,SAAS,0CAAa,KAAsB,EAAE,KAAmB,EAAE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d,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} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n\n /** Whether the option is keyboard focused. */\n isFocusVisible: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isFocusVisible: isFocused && isFocusVisible(),\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\n };\n}\n"],"names":[],"version":3,"file":"useOption.main.js.map"}
@@ -0,0 +1,111 @@
1
+ import {getItemId as $b1f0cad8af73213b$export$9145995848b05025, listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.mjs";
2
+ import {useSlotId as $fcwmx$useSlotId, isMac as $fcwmx$isMac, isWebKit as $fcwmx$isWebKit, chain as $fcwmx$chain, filterDOMProps as $fcwmx$filterDOMProps, useLinkProps as $fcwmx$useLinkProps, mergeProps as $fcwmx$mergeProps} from "@react-aria/utils";
3
+ import {getItemCount as $fcwmx$getItemCount} from "@react-stately/collections";
4
+ import {useHover as $fcwmx$useHover, isFocusVisible as $fcwmx$isFocusVisible} from "@react-aria/interactions";
5
+ import {useSelectableItem as $fcwmx$useSelectableItem} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
23
+ var _item_props, _item_props1;
24
+ let { key: key } = props;
25
+ let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
26
+ var _props_isDisabled;
27
+ let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
28
+ var _props_isSelected;
29
+ let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
30
+ var _props_shouldSelectOnPressUp;
31
+ let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data === null || data === void 0 ? void 0 : data.shouldSelectOnPressUp;
32
+ var _props_shouldFocusOnHover;
33
+ let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data === null || data === void 0 ? void 0 : data.shouldFocusOnHover;
34
+ var _props_shouldUseVirtualFocus;
35
+ let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data === null || data === void 0 ? void 0 : data.shouldUseVirtualFocus;
36
+ var _props_isVirtualized;
37
+ let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data === null || data === void 0 ? void 0 : data.isVirtualized;
38
+ let labelId = (0, $fcwmx$useSlotId)();
39
+ let descriptionId = (0, $fcwmx$useSlotId)();
40
+ let optionProps = {
41
+ role: "option",
42
+ "aria-disabled": isDisabled || undefined,
43
+ "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
44
+ };
45
+ // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
46
+ // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
47
+ // https://bugs.webkit.org/show_bug.cgi?id=209279
48
+ if (!((0, $fcwmx$isMac)() && (0, $fcwmx$isWebKit)())) {
49
+ optionProps["aria-label"] = props["aria-label"];
50
+ optionProps["aria-labelledby"] = labelId;
51
+ optionProps["aria-describedby"] = descriptionId;
52
+ }
53
+ let item = state.collection.getItem(key);
54
+ if (isVirtualized) {
55
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
56
+ optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
57
+ optionProps["aria-setsize"] = (0, $fcwmx$getItemCount)(state.collection);
58
+ }
59
+ let onAction = (data === null || data === void 0 ? void 0 : data.onAction) ? ()=>{
60
+ var _data_onAction;
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
+ } : undefined;
63
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $fcwmx$useSelectableItem)({
64
+ selectionManager: state.selectionManager,
65
+ key: key,
66
+ ref: ref,
67
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
68
+ allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
69
+ isVirtualized: isVirtualized,
70
+ shouldUseVirtualFocus: shouldUseVirtualFocus,
71
+ isDisabled: isDisabled,
72
+ 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
+ });
75
+ let { hoverProps: hoverProps } = (0, $fcwmx$useHover)({
76
+ isDisabled: isDisabled || !shouldFocusOnHover,
77
+ onHoverStart () {
78
+ if (!(0, $fcwmx$isFocusVisible)()) {
79
+ state.selectionManager.setFocused(true);
80
+ state.selectionManager.setFocusedKey(key);
81
+ }
82
+ }
83
+ });
84
+ let domProps = (0, $fcwmx$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
85
+ delete domProps.id;
86
+ let linkProps = (0, $fcwmx$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
87
+ return {
88
+ optionProps: {
89
+ ...optionProps,
90
+ ...(0, $fcwmx$mergeProps)(domProps, itemProps, hoverProps, linkProps),
91
+ id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
92
+ },
93
+ labelProps: {
94
+ id: labelId
95
+ },
96
+ descriptionProps: {
97
+ id: descriptionId
98
+ },
99
+ isFocused: isFocused,
100
+ isFocusVisible: isFocused && (0, $fcwmx$isFocusVisible)(),
101
+ isSelected: isSelected,
102
+ isDisabled: isDisabled,
103
+ isPressed: isPressed,
104
+ allowsSelection: allowsSelection,
105
+ hasAction: hasAction
106
+ };
107
+ }
108
+
109
+
110
+ export {$293f70390ea03370$export$497855f14858aa34 as useOption};
111
+ //# sourceMappingURL=useOption.mjs.map
@@ -0,0 +1,111 @@
1
+ import {getItemId as $b1f0cad8af73213b$export$9145995848b05025, listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.module.js";
2
+ import {useSlotId as $fcwmx$useSlotId, isMac as $fcwmx$isMac, isWebKit as $fcwmx$isWebKit, chain as $fcwmx$chain, filterDOMProps as $fcwmx$filterDOMProps, useLinkProps as $fcwmx$useLinkProps, mergeProps as $fcwmx$mergeProps} from "@react-aria/utils";
3
+ import {getItemCount as $fcwmx$getItemCount} from "@react-stately/collections";
4
+ import {useHover as $fcwmx$useHover, isFocusVisible as $fcwmx$isFocusVisible} from "@react-aria/interactions";
5
+ import {useSelectableItem as $fcwmx$useSelectableItem} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $293f70390ea03370$export$497855f14858aa34(props, state, ref) {
23
+ var _item_props, _item_props1;
24
+ let { key: key } = props;
25
+ let data = (0, $b1f0cad8af73213b$export$3585ede4d035bf14).get(state);
26
+ var _props_isDisabled;
27
+ let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
28
+ var _props_isSelected;
29
+ let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
30
+ var _props_shouldSelectOnPressUp;
31
+ let shouldSelectOnPressUp = (_props_shouldSelectOnPressUp = props.shouldSelectOnPressUp) !== null && _props_shouldSelectOnPressUp !== void 0 ? _props_shouldSelectOnPressUp : data === null || data === void 0 ? void 0 : data.shouldSelectOnPressUp;
32
+ var _props_shouldFocusOnHover;
33
+ let shouldFocusOnHover = (_props_shouldFocusOnHover = props.shouldFocusOnHover) !== null && _props_shouldFocusOnHover !== void 0 ? _props_shouldFocusOnHover : data === null || data === void 0 ? void 0 : data.shouldFocusOnHover;
34
+ var _props_shouldUseVirtualFocus;
35
+ let shouldUseVirtualFocus = (_props_shouldUseVirtualFocus = props.shouldUseVirtualFocus) !== null && _props_shouldUseVirtualFocus !== void 0 ? _props_shouldUseVirtualFocus : data === null || data === void 0 ? void 0 : data.shouldUseVirtualFocus;
36
+ var _props_isVirtualized;
37
+ let isVirtualized = (_props_isVirtualized = props.isVirtualized) !== null && _props_isVirtualized !== void 0 ? _props_isVirtualized : data === null || data === void 0 ? void 0 : data.isVirtualized;
38
+ let labelId = (0, $fcwmx$useSlotId)();
39
+ let descriptionId = (0, $fcwmx$useSlotId)();
40
+ let optionProps = {
41
+ role: "option",
42
+ "aria-disabled": isDisabled || undefined,
43
+ "aria-selected": state.selectionManager.selectionMode !== "none" ? isSelected : undefined
44
+ };
45
+ // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply "text".
46
+ // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.
47
+ // https://bugs.webkit.org/show_bug.cgi?id=209279
48
+ if (!((0, $fcwmx$isMac)() && (0, $fcwmx$isWebKit)())) {
49
+ optionProps["aria-label"] = props["aria-label"];
50
+ optionProps["aria-labelledby"] = labelId;
51
+ optionProps["aria-describedby"] = descriptionId;
52
+ }
53
+ let item = state.collection.getItem(key);
54
+ if (isVirtualized) {
55
+ let index = Number(item === null || item === void 0 ? void 0 : item.index);
56
+ optionProps["aria-posinset"] = Number.isNaN(index) ? undefined : index + 1;
57
+ optionProps["aria-setsize"] = (0, $fcwmx$getItemCount)(state.collection);
58
+ }
59
+ let onAction = (data === null || data === void 0 ? void 0 : data.onAction) ? ()=>{
60
+ var _data_onAction;
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
+ } : undefined;
63
+ let { itemProps: itemProps, isPressed: isPressed, isFocused: isFocused, hasAction: hasAction, allowsSelection: allowsSelection } = (0, $fcwmx$useSelectableItem)({
64
+ selectionManager: state.selectionManager,
65
+ key: key,
66
+ ref: ref,
67
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
68
+ allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,
69
+ isVirtualized: isVirtualized,
70
+ shouldUseVirtualFocus: shouldUseVirtualFocus,
71
+ isDisabled: isDisabled,
72
+ 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
+ });
75
+ let { hoverProps: hoverProps } = (0, $fcwmx$useHover)({
76
+ isDisabled: isDisabled || !shouldFocusOnHover,
77
+ onHoverStart () {
78
+ if (!(0, $fcwmx$isFocusVisible)()) {
79
+ state.selectionManager.setFocused(true);
80
+ state.selectionManager.setFocusedKey(key);
81
+ }
82
+ }
83
+ });
84
+ let domProps = (0, $fcwmx$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
85
+ delete domProps.id;
86
+ let linkProps = (0, $fcwmx$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
87
+ return {
88
+ optionProps: {
89
+ ...optionProps,
90
+ ...(0, $fcwmx$mergeProps)(domProps, itemProps, hoverProps, linkProps),
91
+ id: (0, $b1f0cad8af73213b$export$9145995848b05025)(state, key)
92
+ },
93
+ labelProps: {
94
+ id: labelId
95
+ },
96
+ descriptionProps: {
97
+ id: descriptionId
98
+ },
99
+ isFocused: isFocused,
100
+ isFocusVisible: isFocused && (0, $fcwmx$isFocusVisible)(),
101
+ isSelected: isSelected,
102
+ isDisabled: isDisabled,
103
+ isPressed: isPressed,
104
+ allowsSelection: allowsSelection,
105
+ hasAction: hasAction
106
+ };
107
+ }
108
+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AAA,qBAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,mBAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,aAAa;YACX,GAAG,WAAW;YACd,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,WAAW,YAAY,UAAU;YACzD,IAAI,CAAA,GAAA,yCAAQ,EAAE,OAAO;QACvB;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,CAAA,GAAA,qBAAa;oBAC1C;oBACA;mBACA;yBACA;mBACA;IACF;AACF","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} from '@react-types/shared';\nimport {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\n\nexport interface OptionAria extends SelectableItemStates {\n /** Props for the option element. */\n optionProps: DOMAttributes,\n\n /** Props for the main text element inside the option. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the option, if any. */\n descriptionProps: DOMAttributes,\n\n /** Whether the option is currently focused. */\n isFocused: boolean,\n\n /** Whether the option is keyboard focused. */\n isFocusVisible: boolean\n}\n\nexport interface AriaOptionProps {\n /**\n * Whether the option is disabled.\n * @deprecated\n */\n isDisabled?: boolean,\n\n /**\n * Whether the option is selected.\n * @deprecated\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the option. */\n 'aria-label'?: string,\n\n /** The unique key for the option. */\n key: Key,\n\n /**\n * Whether selection should occur on press up instead of press down.\n * @deprecated\n */\n shouldSelectOnPressUp?: boolean,\n\n /**\n * Whether the option should be focused when the user hovers over it.\n * @deprecated\n */\n shouldFocusOnHover?: boolean,\n\n /**\n * Whether the option is contained in a virtual scrolling listbox.\n * @deprecated\n */\n isVirtualized?: boolean,\n\n /**\n * Whether the option should use virtual focus instead of being focused directly.\n * @deprecated\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement>): OptionAria {\n let {\n key\n } = props;\n\n let data = listData.get(state);\n\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data?.shouldSelectOnPressUp;\n let shouldFocusOnHover = props.shouldFocusOnHover ?? data?.shouldFocusOnHover;\n let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data?.shouldUseVirtualFocus;\n let isVirtualized = props.isVirtualized ?? data?.isVirtualized;\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n\n let optionProps = {\n role: 'option',\n 'aria-disabled': isDisabled || undefined,\n 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n };\n\n // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n // https://bugs.webkit.org/show_bug.cgi?id=209279\n if (!(isMac() && isWebKit())) {\n optionProps['aria-label'] = props['aria-label'];\n optionProps['aria-labelledby'] = labelId;\n optionProps['aria-describedby'] = descriptionId;\n }\n\n let item = state.collection.getItem(key);\n if (isVirtualized) {\n let index = Number(item?.index);\n optionProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n optionProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onAction = data?.onAction ? () => data?.onAction?.(key) : undefined;\n let {itemProps, isPressed, isFocused, hasAction, allowsSelection} = useSelectableItem({\n selectionManager: state.selectionManager,\n key,\n ref,\n shouldSelectOnPressUp,\n allowsDifferentPressOrigin: shouldSelectOnPressUp && shouldFocusOnHover,\n isVirtualized,\n shouldUseVirtualFocus,\n isDisabled,\n onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,\n linkBehavior: data?.linkBehavior\n });\n\n let {hoverProps} = useHover({\n isDisabled: isDisabled || !shouldFocusOnHover,\n onHoverStart() {\n if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(key);\n }\n }\n });\n\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n optionProps: {\n ...optionProps,\n ...mergeProps(domProps, itemProps, hoverProps, linkProps),\n id: getItemId(state, key)\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n isFocused,\n isFocusVisible: isFocused && isFocusVisible(),\n isSelected,\n isDisabled,\n isPressed,\n allowsSelection,\n hasAction\n };\n}\n"],"names":[],"version":3,"file":"useOption.module.js.map"}
@@ -0,0 +1,30 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "listData", () => $87beb89ab4a308fd$export$3585ede4d035bf14);
7
+ $parcel$export(module.exports, "getItemId", () => $87beb89ab4a308fd$export$9145995848b05025);
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */ const $87beb89ab4a308fd$export$3585ede4d035bf14 = new WeakMap();
19
+ function $87beb89ab4a308fd$var$normalizeKey(key) {
20
+ if (typeof key === "string") return key.replace(/\s*/g, "");
21
+ return "" + key;
22
+ }
23
+ function $87beb89ab4a308fd$export$9145995848b05025(state, itemKey) {
24
+ let data = $87beb89ab4a308fd$export$3585ede4d035bf14.get(state);
25
+ if (!data) throw new Error("Unknown list");
26
+ return `${data.id}-option-${$87beb89ab4a308fd$var$normalizeKey(itemKey)}`;
27
+ }
28
+
29
+
30
+ //# sourceMappingURL=utils.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,GAAG,CAAC;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD","sources":["packages/@react-aria/listbox/src/utils.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 {Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void,\n linkBehavior?: 'action' | 'selection' | 'override'\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
package/dist/utils.mjs ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ const $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
12
+ function $b1f0cad8af73213b$var$normalizeKey(key) {
13
+ if (typeof key === "string") return key.replace(/\s*/g, "");
14
+ return "" + key;
15
+ }
16
+ function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
17
+ let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
18
+ if (!data) throw new Error("Unknown list");
19
+ return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
20
+ }
21
+
22
+
23
+ export {$b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId};
24
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ const $b1f0cad8af73213b$export$3585ede4d035bf14 = new WeakMap();
12
+ function $b1f0cad8af73213b$var$normalizeKey(key) {
13
+ if (typeof key === "string") return key.replace(/\s*/g, "");
14
+ return "" + key;
15
+ }
16
+ function $b1f0cad8af73213b$export$9145995848b05025(state, itemKey) {
17
+ let data = $b1f0cad8af73213b$export$3585ede4d035bf14.get(state);
18
+ if (!data) throw new Error("Unknown list");
19
+ return `${data.id}-option-${$b1f0cad8af73213b$var$normalizeKey(itemKey)}`;
20
+ }
21
+
22
+
23
+ export {$b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId};
24
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAeM,MAAM,4CAAW,IAAI;AAE5B,SAAS,mCAAa,GAAQ;IAC5B,IAAI,OAAO,QAAQ,UACjB,OAAO,IAAI,OAAO,CAAC,QAAQ;IAG7B,OAAO,KAAK;AACd;AAEO,SAAS,0CAAa,KAAmB,EAAE,OAAY;IAC5D,IAAI,OAAO,0CAAS,GAAG,CAAC;IAExB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM;IAGlB,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,mCAAa,SAAS,CAAC;AACrD","sources":["packages/@react-aria/listbox/src/utils.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 {Key} from '@react-types/shared';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n id: string,\n shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean,\n isVirtualized?: boolean,\n onAction?: (key: Key) => void,\n linkBehavior?: 'action' | 'selection' | 'override'\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n let data = listData.get(state);\n\n if (!data) {\n throw new Error('Unknown list');\n }\n\n return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/listbox",
3
- "version": "3.11.6-nightly.4555+81162ea39",
3
+ "version": "3.11.6-nightly.4560+72775d272",
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.0.0-nightly.2843+81162ea39",
26
- "@react-aria/label": "3.0.0-nightly.2843+81162ea39",
27
- "@react-aria/selection": "3.0.0-nightly.2843+81162ea39",
28
- "@react-aria/utils": "3.0.0-nightly.2843+81162ea39",
29
- "@react-stately/collections": "3.0.0-nightly.2843+81162ea39",
30
- "@react-stately/list": "3.10.4-nightly.4555+81162ea39",
31
- "@react-types/listbox": "3.4.8-nightly.4555+81162ea39",
32
- "@react-types/shared": "3.0.0-nightly.2843+81162ea39",
25
+ "@react-aria/interactions": "3.0.0-nightly.2848+72775d272",
26
+ "@react-aria/label": "3.0.0-nightly.2848+72775d272",
27
+ "@react-aria/selection": "3.0.0-nightly.2848+72775d272",
28
+ "@react-aria/utils": "3.0.0-nightly.2848+72775d272",
29
+ "@react-stately/collections": "3.0.0-nightly.2848+72775d272",
30
+ "@react-stately/list": "3.10.4-nightly.4560+72775d272",
31
+ "@react-types/listbox": "3.4.8-nightly.4560+72775d272",
32
+ "@react-types/shared": "3.0.0-nightly.2848+72775d272",
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": "81162ea392926d06ec3d25c228e6f9b6b5479d59"
42
+ "gitHead": "72775d272be04cfa32d26ec821bc68513d92a72b"
43
43
  }