@react-aria/listbox 3.0.0-alpha.1 → 3.0.0-nightly-4980928d3-240906

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,77 @@
1
+ import {listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.mjs";
2
+ import {filterDOMProps as $by1yQ$filterDOMProps, useId as $by1yQ$useId, mergeProps as $by1yQ$mergeProps} from "@react-aria/utils";
3
+ import {useFocusWithin as $by1yQ$useFocusWithin} from "@react-aria/interactions";
4
+ import {useLabel as $by1yQ$useLabel} from "@react-aria/label";
5
+ import {useSelectableList as $by1yQ$useSelectableList} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
23
+ let domProps = (0, $by1yQ$filterDOMProps)(props, {
24
+ labelable: true
25
+ });
26
+ // Use props instead of state here. We don't want this to change due to long press.
27
+ let selectionBehavior = props.selectionBehavior || 'toggle';
28
+ let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');
29
+ if (selectionBehavior === 'toggle' && linkBehavior === 'action') // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
30
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
31
+ // selectable in this configuration.
32
+ linkBehavior = 'override';
33
+ let { listProps: listProps } = (0, $by1yQ$useSelectableList)({
34
+ ...props,
35
+ ref: ref,
36
+ selectionManager: state.selectionManager,
37
+ collection: state.collection,
38
+ disabledKeys: state.disabledKeys,
39
+ linkBehavior: linkBehavior
40
+ });
41
+ let { focusWithinProps: focusWithinProps } = (0, $by1yQ$useFocusWithin)({
42
+ onFocusWithin: props.onFocus,
43
+ onBlurWithin: props.onBlur,
44
+ onFocusWithinChange: props.onFocusChange
45
+ });
46
+ // Share list id and some props with child options.
47
+ let id = (0, $by1yQ$useId)(props.id);
48
+ (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
49
+ id: id,
50
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
51
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
52
+ shouldFocusOnHover: props.shouldFocusOnHover,
53
+ isVirtualized: props.isVirtualized,
54
+ onAction: props.onAction,
55
+ linkBehavior: linkBehavior
56
+ });
57
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $by1yQ$useLabel)({
58
+ ...props,
59
+ id: id,
60
+ // listbox is not an HTML input element so it
61
+ // shouldn't be labeled by a <label> element.
62
+ labelElementType: 'span'
63
+ });
64
+ return {
65
+ labelProps: labelProps,
66
+ listBoxProps: (0, $by1yQ$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
67
+ 'aria-multiselectable': 'true'
68
+ } : {}, {
69
+ role: 'listbox',
70
+ ...(0, $by1yQ$mergeProps)(fieldProps, listProps)
71
+ })
72
+ };
73
+ }
74
+
75
+
76
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox};
77
+ //# sourceMappingURL=useListBox.module.js.map
@@ -0,0 +1,77 @@
1
+ import {listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.module.js";
2
+ import {filterDOMProps as $by1yQ$filterDOMProps, useId as $by1yQ$useId, mergeProps as $by1yQ$mergeProps} from "@react-aria/utils";
3
+ import {useFocusWithin as $by1yQ$useFocusWithin} from "@react-aria/interactions";
4
+ import {useLabel as $by1yQ$useLabel} from "@react-aria/label";
5
+ import {useSelectableList as $by1yQ$useSelectableList} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $c132121280ec012d$export$50eacbbf140a3141(props, state, ref) {
23
+ let domProps = (0, $by1yQ$filterDOMProps)(props, {
24
+ labelable: true
25
+ });
26
+ // Use props instead of state here. We don't want this to change due to long press.
27
+ let selectionBehavior = props.selectionBehavior || 'toggle';
28
+ let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');
29
+ if (selectionBehavior === 'toggle' && linkBehavior === 'action') // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
30
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
31
+ // selectable in this configuration.
32
+ linkBehavior = 'override';
33
+ let { listProps: listProps } = (0, $by1yQ$useSelectableList)({
34
+ ...props,
35
+ ref: ref,
36
+ selectionManager: state.selectionManager,
37
+ collection: state.collection,
38
+ disabledKeys: state.disabledKeys,
39
+ linkBehavior: linkBehavior
40
+ });
41
+ let { focusWithinProps: focusWithinProps } = (0, $by1yQ$useFocusWithin)({
42
+ onFocusWithin: props.onFocus,
43
+ onBlurWithin: props.onBlur,
44
+ onFocusWithinChange: props.onFocusChange
45
+ });
46
+ // Share list id and some props with child options.
47
+ let id = (0, $by1yQ$useId)(props.id);
48
+ (0, $b1f0cad8af73213b$export$3585ede4d035bf14).set(state, {
49
+ id: id,
50
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
51
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
52
+ shouldFocusOnHover: props.shouldFocusOnHover,
53
+ isVirtualized: props.isVirtualized,
54
+ onAction: props.onAction,
55
+ linkBehavior: linkBehavior
56
+ });
57
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $by1yQ$useLabel)({
58
+ ...props,
59
+ id: id,
60
+ // listbox is not an HTML input element so it
61
+ // shouldn't be labeled by a <label> element.
62
+ labelElementType: 'span'
63
+ });
64
+ return {
65
+ labelProps: labelProps,
66
+ listBoxProps: (0, $by1yQ$mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
67
+ 'aria-multiselectable': 'true'
68
+ } : {}, {
69
+ role: 'listbox',
70
+ ...(0, $by1yQ$mergeProps)(fieldProps, listProps)
71
+ })
72
+ };
73
+ }
74
+
75
+
76
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox};
77
+ //# sourceMappingURL=useListBox.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8DM,SAAS,0CAAc,KAA4B,EAAE,KAAmB,EAAE,GAAkC;IACjH,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,mFAAmF;IACnF,IAAI,oBAAoB,MAAM,iBAAiB,IAAI;IACnD,IAAI,eAAe,MAAM,YAAY,IAAK,CAAA,sBAAsB,YAAY,WAAW,UAAS;IAChG,IAAI,sBAAsB,YAAY,iBAAiB,UACrD,8FAA8F;IAC9F,8FAA8F;IAC9F,oCAAoC;IACpC,eAAe;IAGjB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,GAAG,KAAK;aACR;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;sBAChC;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,eAAe,MAAM,OAAO;QAC5B,cAAc,MAAM,MAAM;QAC1B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,mDAAmD;IACnD,IAAI,KAAK,CAAA,GAAA,YAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;YAClB;QACA,uBAAuB,MAAM,qBAAqB;QAClD,uBAAuB,MAAM,qBAAqB;QAClD,oBAAoB,MAAM,kBAAkB;QAC5C,eAAe,MAAM,aAAa;QAClC,UAAU,MAAM,QAAQ;sBACxB;IACF;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACtC,GAAG,KAAK;YACR;QACA,6CAA6C;QAC7C,6CAA6C;QAC7C,kBAAkB;IACpB;IAEA,OAAO;oBACL;QACA,cAAc,CAAA,GAAA,iBAAS,EAAE,UAAU,kBAAkB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa;YACzG,wBAAwB;QAC1B,IAAI,CAAC,GAAG;YACN,MAAM;YACN,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/listbox/src/useListBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate, LayoutDelegate, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\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 * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate,\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 | null>): ListBoxAria {\n let domProps = filterDOMProps(props, {labelable: true});\n // Use props instead of state here. We don't want this to change due to long press.\n let selectionBehavior = props.selectionBehavior || 'toggle';\n let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');\n if (selectionBehavior === 'toggle' && linkBehavior === 'action') {\n // linkBehavior=\"action\" does not work with selectionBehavior=\"toggle\" because there is no way\n // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be\n // selectable in this configuration.\n linkBehavior = 'override';\n }\n\n let {listProps} = useSelectableList({\n ...props,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n linkBehavior\n });\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: props.onFocus,\n onBlurWithin: props.onBlur,\n onFocusWithinChange: props.onFocusChange\n });\n\n // Share list id and some props with child options.\n let id = useId(props.id);\n listData.set(state, {\n id,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n shouldFocusOnHover: props.shouldFocusOnHover,\n isVirtualized: props.isVirtualized,\n onAction: props.onAction,\n linkBehavior\n });\n\n let {labelProps, fieldProps} = useLabel({\n ...props,\n id,\n // listbox is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n return {\n labelProps,\n listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n 'aria-multiselectable': 'true'\n } : {}, {\n role: 'listbox',\n ...mergeProps(fieldProps, listProps)\n })\n };\n}\n"],"names":[],"version":3,"file":"useListBox.module.js.map"}
@@ -0,0 +1,43 @@
1
+ var $bAsD1$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useListBoxSection", () => $f32afd5f225c3320$export$c3f9f39876e4bc7);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ function $f32afd5f225c3320$export$c3f9f39876e4bc7(props) {
21
+ let { heading: heading, 'aria-label': ariaLabel } = props;
22
+ let headingId = (0, $bAsD1$reactariautils.useId)();
23
+ return {
24
+ itemProps: {
25
+ role: 'presentation'
26
+ },
27
+ headingProps: heading ? {
28
+ // Techincally, listbox cannot contain headings according to ARIA.
29
+ // We hide the heading from assistive technology, using role="presentation",
30
+ // and only use it as a visual label for the nested group.
31
+ id: headingId,
32
+ role: 'presentation'
33
+ } : {},
34
+ groupProps: {
35
+ role: 'group',
36
+ 'aria-label': ariaLabel,
37
+ 'aria-labelledby': heading ? headingId : undefined
38
+ }
39
+ };
40
+ }
41
+
42
+
43
+ //# sourceMappingURL=useListBoxSection.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA6BM,SAAS,yCAAkB,KAA8B;IAC9D,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,2BAAI;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,kEAAkE;YAClE,4EAA4E;YAC5E,0DAA0D;YAC1D,IAAI;YACJ,MAAM;QACR,IAAI,CAAC;QACL,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY;QAC3C;IACF;AACF","sources":["packages/@react-aria/listbox/src/useListBoxSection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaListBoxSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface ListBoxSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, listbox cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, using role=\"presentation\",\n // and only use it as a visual label for the nested group.\n id: headingId,\n role: 'presentation'\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useListBoxSection.main.js.map"}
@@ -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,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":"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","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"}
@@ -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.module.js.map