@react-aria/listbox 3.0.0-alpha.1 → 3.0.0-nightly-641446f65-240905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-aria/listbox
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,23 @@
1
+ import {useListBox as $c132121280ec012d$export$50eacbbf140a3141} from "./useListBox.mjs";
2
+ import {useOption as $293f70390ea03370$export$497855f14858aa34} from "./useOption.mjs";
3
+ import {useListBoxSection as $af383d3bef1cfdc9$export$c3f9f39876e4bc7} from "./useListBoxSection.mjs";
4
+ import {getItemId as $b1f0cad8af73213b$export$9145995848b05025, listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.mjs";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+
21
+
22
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox, $293f70390ea03370$export$497855f14858aa34 as useOption, $af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection, $b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId};
23
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,118 +1,32 @@
1
- var _babelRuntimeHelpersObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/objectSpread2"));
1
+ var $a3ce5bb3074610af$exports = require("./useListBox.main.js");
2
+ var $c164f9f79f4cef2d$exports = require("./useOption.main.js");
3
+ var $f32afd5f225c3320$exports = require("./useListBoxSection.main.js");
4
+ var $87beb89ab4a308fd$exports = require("./utils.main.js");
2
5
 
3
- var _temp = require("@react-aria/selection");
4
6
 
5
- var useSelectableList = _temp.useSelectableList;
6
- var useSelectableItem = _temp.useSelectableItem;
7
-
8
- var _temp2 = require("@react-aria/interactions");
9
-
10
- var useHover = _temp2.useHover;
11
- var usePress = _temp2.usePress;
12
-
13
- var _temp3 = require("@react-aria/utils");
14
-
15
- var useSlotId = _temp3.useSlotId;
16
- var useId = _temp3.useId;
17
-
18
- function $parcel$interopDefault(a) {
19
- return a && a.__esModule ? a.default : a;
20
- }
21
-
22
- function useListBox(props, state) {
23
- var _useSelectableList = useSelectableList(_babelRuntimeHelpersObjectSpread({}, props, {
24
- selectionManager: state.selectionManager,
25
- collection: state.collection
26
- })),
27
- listProps = _useSelectableList.listProps;
28
-
29
- return {
30
- listBoxProps: _babelRuntimeHelpersObjectSpread({
31
- role: 'listbox',
32
- 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined
33
- }, listProps)
34
- };
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
35
9
  }
36
10
 
37
- exports.useListBox = useListBox;
38
-
39
- function useOption(props, state) {
40
- var isSelected = props.isSelected,
41
- isDisabled = props.isDisabled,
42
- key = props.key,
43
- ref = props.ref,
44
- shouldSelectOnPressUp = props.shouldSelectOnPressUp,
45
- shouldFocusOnHover = props.shouldFocusOnHover,
46
- isVirtualized = props.isVirtualized;
47
- var labelId = useSlotId();
48
- var descriptionId = useSlotId();
49
- var optionProps = {
50
- role: 'option',
51
- 'aria-disabled': isDisabled,
52
- 'aria-selected': isSelected,
53
- 'aria-label': props['aria-label'],
54
- 'aria-labelledby': labelId,
55
- 'aria-describedby': descriptionId
56
- };
11
+ $parcel$export(module.exports, "useListBox", () => $a3ce5bb3074610af$exports.useListBox);
12
+ $parcel$export(module.exports, "useOption", () => $c164f9f79f4cef2d$exports.useOption);
13
+ $parcel$export(module.exports, "useListBoxSection", () => $f32afd5f225c3320$exports.useListBoxSection);
14
+ $parcel$export(module.exports, "listData", () => $87beb89ab4a308fd$exports.listData);
15
+ $parcel$export(module.exports, "getItemId", () => $87beb89ab4a308fd$exports.getItemId);
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
57
27
 
58
- if (isVirtualized) {
59
- optionProps['aria-posinset'] = state.collection.getItem(key).index;
60
- optionProps['aria-setsize'] = state.collection.size;
61
- }
62
28
 
63
- var _useSelectableItem = useSelectableItem({
64
- selectionManager: state.selectionManager,
65
- itemKey: key,
66
- itemRef: ref,
67
- shouldSelectOnPressUp: shouldSelectOnPressUp,
68
- isVirtualized: isVirtualized
69
- }),
70
- itemProps = _useSelectableItem.itemProps;
71
29
 
72
- var _usePress = usePress(_babelRuntimeHelpersObjectSpread({}, itemProps, {
73
- isDisabled: isDisabled
74
- })),
75
- pressProps = _usePress.pressProps;
76
30
 
77
- var _useHover = useHover({
78
- isDisabled: isDisabled || !shouldFocusOnHover,
79
- onHover: function onHover() {
80
- state.selectionManager.setFocusedKey(key);
81
- }
82
- }),
83
- hoverProps = _useHover.hoverProps;
84
-
85
- return {
86
- optionProps: _babelRuntimeHelpersObjectSpread({}, optionProps, {}, pressProps, {}, hoverProps),
87
- labelProps: {
88
- id: labelId
89
- },
90
- descriptionProps: {
91
- id: descriptionId
92
- }
93
- };
94
- }
95
-
96
- exports.useOption = useOption;
97
-
98
- function useListBoxSection(props) {
99
- var heading = props.heading,
100
- ariaLabel = props['aria-label'];
101
- var headingId = useId();
102
- return {
103
- headingProps: heading ? {
104
- // Techincally, listbox cannot contain headings according to ARIA.
105
- // We hide the heading from assistive technology, and only use it
106
- // as a label for the nested group.
107
- id: headingId,
108
- 'aria-hidden': true
109
- } : {},
110
- groupProps: {
111
- role: 'group',
112
- 'aria-label': ariaLabel,
113
- 'aria-labelledby': heading ? headingId : undefined
114
- }
115
- };
116
- }
117
31
 
118
- exports.useListBoxSection = useListBoxSection;
32
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/listbox/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxProps} from '@react-types/listbox';\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,99 +1,23 @@
1
- import _babelRuntimeHelpersEsmObjectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { useSelectableList, useSelectableItem } from "@react-aria/selection";
3
- import { useHover, usePress } from "@react-aria/interactions";
4
- import { useSlotId, useId } from "@react-aria/utils";
5
- export function useListBox(props, state) {
6
- let {
7
- listProps
8
- } = useSelectableList(_babelRuntimeHelpersEsmObjectSpread({}, props, {
9
- selectionManager: state.selectionManager,
10
- collection: state.collection
11
- }));
12
- return {
13
- listBoxProps: _babelRuntimeHelpersEsmObjectSpread({
14
- role: 'listbox',
15
- 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined
16
- }, listProps)
17
- };
18
- }
19
- export function useOption(props, state) {
20
- let {
21
- isSelected,
22
- isDisabled,
23
- key,
24
- ref,
25
- shouldSelectOnPressUp,
26
- shouldFocusOnHover,
27
- isVirtualized
28
- } = props;
29
- let labelId = useSlotId();
30
- let descriptionId = useSlotId();
31
- let optionProps = {
32
- role: 'option',
33
- 'aria-disabled': isDisabled,
34
- 'aria-selected': isSelected,
35
- 'aria-label': props['aria-label'],
36
- 'aria-labelledby': labelId,
37
- 'aria-describedby': descriptionId
38
- };
1
+ import {useListBox as $c132121280ec012d$export$50eacbbf140a3141} from "./useListBox.module.js";
2
+ import {useOption as $293f70390ea03370$export$497855f14858aa34} from "./useOption.module.js";
3
+ import {useListBoxSection as $af383d3bef1cfdc9$export$c3f9f39876e4bc7} from "./useListBoxSection.module.js";
4
+ import {getItemId as $b1f0cad8af73213b$export$9145995848b05025, listData as $b1f0cad8af73213b$export$3585ede4d035bf14} from "./utils.module.js";
39
5
 
40
- if (isVirtualized) {
41
- optionProps['aria-posinset'] = state.collection.getItem(key).index;
42
- optionProps['aria-setsize'] = state.collection.size;
43
- }
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
44
17
 
45
- let {
46
- itemProps
47
- } = useSelectableItem({
48
- selectionManager: state.selectionManager,
49
- itemKey: key,
50
- itemRef: ref,
51
- shouldSelectOnPressUp,
52
- isVirtualized
53
- });
54
- let {
55
- pressProps
56
- } = usePress(_babelRuntimeHelpersEsmObjectSpread({}, itemProps, {
57
- isDisabled
58
- }));
59
- let {
60
- hoverProps
61
- } = useHover({
62
- isDisabled: isDisabled || !shouldFocusOnHover,
63
18
 
64
- onHover() {
65
- state.selectionManager.setFocusedKey(key);
66
- }
67
19
 
68
- });
69
- return {
70
- optionProps: _babelRuntimeHelpersEsmObjectSpread({}, optionProps, {}, pressProps, {}, hoverProps),
71
- labelProps: {
72
- id: labelId
73
- },
74
- descriptionProps: {
75
- id: descriptionId
76
- }
77
- };
78
- }
79
- export function useListBoxSection(props) {
80
- let {
81
- heading,
82
- 'aria-label': ariaLabel
83
- } = props;
84
- let headingId = useId();
85
- return {
86
- headingProps: heading ? {
87
- // Techincally, listbox cannot contain headings according to ARIA.
88
- // We hide the heading from assistive technology, and only use it
89
- // as a label for the nested group.
90
- id: headingId,
91
- 'aria-hidden': true
92
- } : {},
93
- groupProps: {
94
- role: 'group',
95
- 'aria-label': ariaLabel,
96
- 'aria-labelledby': heading ? headingId : undefined
97
- }
98
- };
99
- }
20
+
21
+
22
+ export {$c132121280ec012d$export$50eacbbf140a3141 as useListBox, $293f70390ea03370$export$497855f14858aa34 as useOption, $af383d3bef1cfdc9$export$c3f9f39876e4bc7 as useListBoxSection, $b1f0cad8af73213b$export$3585ede4d035bf14 as listData, $b1f0cad8af73213b$export$9145995848b05025 as getItemId};
23
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/listbox/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useListBox} from './useListBox';\nexport {useOption} from './useOption';\nexport {useListBoxSection} from './useListBoxSection';\nexport {listData, getItemId} from './utils';\n\nexport type {AriaListBoxProps} from '@react-types/listbox';\nexport type {AriaListBoxOptions, ListBoxAria} from './useListBox';\nexport type {AriaOptionProps, OptionAria} from './useOption';\nexport type {AriaListBoxSectionProps, ListBoxSectionAria} from './useListBoxSection';\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,42 +1,138 @@
1
- import { FocusStrategy } from "@react-types/listbox";
2
- import { HTMLAttributes, RefObject, Key, ReactNode } from "react";
3
- import { KeyboardDelegate } from "@react-types/shared";
1
+ import { Key, DOMAttributes, KeyboardDelegate, LayoutDelegate, RefObject, FocusableElement } from "@react-types/shared";
4
2
  import { ListState } from "@react-stately/list";
5
- interface ListBoxAria {
6
- listBoxProps: HTMLAttributes<HTMLElement>;
3
+ import { AriaListBoxProps } from "@react-types/listbox";
4
+ import { SelectableItemStates } from "@react-aria/selection";
5
+ import { ReactNode } from "react";
6
+ interface ListData {
7
+ id: string;
8
+ shouldSelectOnPressUp?: boolean;
9
+ shouldFocusOnHover?: boolean;
10
+ shouldUseVirtualFocus?: boolean;
11
+ isVirtualized?: boolean;
12
+ onAction?: (key: Key) => void;
13
+ linkBehavior?: 'action' | 'selection' | 'override';
14
+ }
15
+ export const listData: WeakMap<ListState<unknown>, ListData>;
16
+ export function getItemId<T>(state: ListState<T>, itemKey: Key): string;
17
+ export interface ListBoxAria {
18
+ /** Props for the listbox element. */
19
+ listBoxProps: DOMAttributes;
20
+ /** Props for the listbox's visual label element (if any). */
21
+ labelProps: DOMAttributes;
7
22
  }
8
- interface AriaListBoxProps {
9
- ref?: RefObject<HTMLDivElement>;
23
+ export interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {
24
+ /** Whether the listbox uses virtual scrolling. */
10
25
  isVirtualized?: boolean;
26
+ /**
27
+ * An optional keyboard delegate implementation for type to select,
28
+ * to override the default.
29
+ */
11
30
  keyboardDelegate?: KeyboardDelegate;
12
- autoFocus?: boolean | FocusStrategy;
13
- shouldFocusWrap?: boolean;
31
+ /**
32
+ * A delegate object that provides layout information for items in the collection.
33
+ * By default this uses the DOM, but this can be overridden to implement things like
34
+ * virtualized scrolling.
35
+ */
36
+ layoutDelegate?: LayoutDelegate;
37
+ /**
38
+ * Whether the listbox items should use virtual focus instead of being focused directly.
39
+ */
40
+ shouldUseVirtualFocus?: boolean;
41
+ /** Whether selection should occur on press up instead of press down. */
42
+ shouldSelectOnPressUp?: boolean;
43
+ /** Whether options should be focused when the user hovers over them. */
44
+ shouldFocusOnHover?: boolean;
45
+ /**
46
+ * The behavior of links in the collection.
47
+ * - 'action': link behaves like onAction.
48
+ * - 'selection': link follows selection interactions (e.g. if URL drives selection).
49
+ * - 'override': links override all other interactions (link items are not selectable).
50
+ * @default 'override'
51
+ */
52
+ linkBehavior?: 'action' | 'selection' | 'override';
14
53
  }
15
- export function useListBox<T>(props: AriaListBoxProps, state: ListState<T>): ListBoxAria;
16
- interface OptionProps {
54
+ /**
55
+ * Provides the behavior and accessibility implementation for a listbox component.
56
+ * A listbox displays a list of options and allows a user to select one or more of them.
57
+ * @param props - Props for the listbox.
58
+ * @param state - State for the listbox, as returned by `useListState`.
59
+ */
60
+ export function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement | null>): ListBoxAria;
61
+ export interface OptionAria extends SelectableItemStates {
62
+ /** Props for the option element. */
63
+ optionProps: DOMAttributes;
64
+ /** Props for the main text element inside the option. */
65
+ labelProps: DOMAttributes;
66
+ /** Props for the description text element inside the option, if any. */
67
+ descriptionProps: DOMAttributes;
68
+ /** Whether the option is currently focused. */
69
+ isFocused: boolean;
70
+ /** Whether the option is keyboard focused. */
71
+ isFocusVisible: boolean;
72
+ }
73
+ export interface AriaOptionProps {
74
+ /**
75
+ * Whether the option is disabled.
76
+ * @deprecated
77
+ */
17
78
  isDisabled?: boolean;
79
+ /**
80
+ * Whether the option is selected.
81
+ * @deprecated
82
+ */
18
83
  isSelected?: boolean;
84
+ /** A screen reader only label for the option. */
19
85
  'aria-label'?: string;
20
- key?: Key;
21
- ref?: RefObject<HTMLElement>;
86
+ /** The unique key for the option. */
87
+ key: Key;
88
+ /**
89
+ * Whether selection should occur on press up instead of press down.
90
+ * @deprecated
91
+ */
22
92
  shouldSelectOnPressUp?: boolean;
93
+ /**
94
+ * Whether the option should be focused when the user hovers over it.
95
+ * @deprecated
96
+ */
23
97
  shouldFocusOnHover?: boolean;
98
+ /**
99
+ * Whether the option is contained in a virtual scrolling listbox.
100
+ * @deprecated
101
+ */
24
102
  isVirtualized?: boolean;
103
+ /**
104
+ * Whether the option should use virtual focus instead of being focused directly.
105
+ * @deprecated
106
+ */
107
+ shouldUseVirtualFocus?: boolean;
25
108
  }
26
- interface OptionAria {
27
- optionProps: HTMLAttributes<HTMLElement>;
28
- labelProps: HTMLAttributes<HTMLElement>;
29
- descriptionProps: HTMLAttributes<HTMLElement>;
30
- }
31
- export function useOption<T>(props: OptionProps, state: ListState<T>): OptionAria;
32
- interface ListBoxSectionProps {
109
+ /**
110
+ * Provides the behavior and accessibility implementation for an option in a listbox.
111
+ * See `useListBox` for more details about listboxes.
112
+ * @param props - Props for the option.
113
+ * @param state - State for the listbox, as returned by `useListState`.
114
+ */
115
+ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<FocusableElement | null>): OptionAria;
116
+ export interface AriaListBoxSectionProps {
117
+ /** The heading for the section. */
33
118
  heading?: ReactNode;
119
+ /** An accessibility label for the section. Required if `heading` is not present. */
34
120
  'aria-label'?: string;
35
121
  }
36
- interface ListBoxSectionAria {
37
- headingProps: HTMLAttributes<HTMLElement>;
38
- groupProps: HTMLAttributes<HTMLElement>;
122
+ export interface ListBoxSectionAria {
123
+ /** Props for the wrapper list item. */
124
+ itemProps: DOMAttributes;
125
+ /** Props for the heading element, if any. */
126
+ headingProps: DOMAttributes;
127
+ /** Props for the group element. */
128
+ groupProps: DOMAttributes;
39
129
  }
40
- export function useListBoxSection(props: ListBoxSectionProps): ListBoxSectionAria;
130
+ /**
131
+ * Provides the behavior and accessibility implementation for a section in a listbox.
132
+ * See `useListBox` for more details about listboxes.
133
+ * @param props - Props for the section.
134
+ */
135
+ export function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria;
136
+ export type { AriaListBoxProps } from '@react-types/listbox';
41
137
 
42
138
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/govett/dev/react-spectrum/packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBox.ts","/Users/govett/dev/react-spectrum/packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useOption.ts","/Users/govett/dev/react-spectrum/packages/@react-aria/listbox/src/packages/@react-aria/listbox/src/useListBoxSection.ts"],"names":[],"mappings":";;;;AAkBA;IACE,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED;IACE,GAAG,CAAC,EAAE,UAAU,cAAc,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,2BAA2B,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,GAAG,WAAW,CAcvF;AC1BD;IACE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAA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ACH,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,CAuF7H;AC9JD;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"}
@@ -0,0 +1,82 @@
1
+ var $87beb89ab4a308fd$exports = require("./utils.main.js");
2
+ var $eCULP$reactariautils = require("@react-aria/utils");
3
+ var $eCULP$reactariainteractions = require("@react-aria/interactions");
4
+ var $eCULP$reactarialabel = require("@react-aria/label");
5
+ var $eCULP$reactariaselection = require("@react-aria/selection");
6
+
7
+
8
+ function $parcel$export(e, n, v, s) {
9
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
+ }
11
+
12
+ $parcel$export(module.exports, "useListBox", () => $a3ce5bb3074610af$export$50eacbbf140a3141);
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
24
+
25
+
26
+
27
+
28
+ function $a3ce5bb3074610af$export$50eacbbf140a3141(props, state, ref) {
29
+ let domProps = (0, $eCULP$reactariautils.filterDOMProps)(props, {
30
+ labelable: true
31
+ });
32
+ // Use props instead of state here. We don't want this to change due to long press.
33
+ let selectionBehavior = props.selectionBehavior || 'toggle';
34
+ let linkBehavior = props.linkBehavior || (selectionBehavior === 'replace' ? 'action' : 'override');
35
+ if (selectionBehavior === 'toggle' && linkBehavior === 'action') // linkBehavior="action" does not work with selectionBehavior="toggle" because there is no way
36
+ // to initiate selection (checkboxes are not allowed inside a listbox). Link items will not be
37
+ // selectable in this configuration.
38
+ linkBehavior = 'override';
39
+ let { listProps: listProps } = (0, $eCULP$reactariaselection.useSelectableList)({
40
+ ...props,
41
+ ref: ref,
42
+ selectionManager: state.selectionManager,
43
+ collection: state.collection,
44
+ disabledKeys: state.disabledKeys,
45
+ linkBehavior: linkBehavior
46
+ });
47
+ let { focusWithinProps: focusWithinProps } = (0, $eCULP$reactariainteractions.useFocusWithin)({
48
+ onFocusWithin: props.onFocus,
49
+ onBlurWithin: props.onBlur,
50
+ onFocusWithinChange: props.onFocusChange
51
+ });
52
+ // Share list id and some props with child options.
53
+ let id = (0, $eCULP$reactariautils.useId)(props.id);
54
+ (0, $87beb89ab4a308fd$exports.listData).set(state, {
55
+ id: id,
56
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus,
57
+ shouldSelectOnPressUp: props.shouldSelectOnPressUp,
58
+ shouldFocusOnHover: props.shouldFocusOnHover,
59
+ isVirtualized: props.isVirtualized,
60
+ onAction: props.onAction,
61
+ linkBehavior: linkBehavior
62
+ });
63
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $eCULP$reactarialabel.useLabel)({
64
+ ...props,
65
+ id: id,
66
+ // listbox is not an HTML input element so it
67
+ // shouldn't be labeled by a <label> element.
68
+ labelElementType: 'span'
69
+ });
70
+ return {
71
+ labelProps: labelProps,
72
+ listBoxProps: (0, $eCULP$reactariautils.mergeProps)(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {
73
+ 'aria-multiselectable': 'true'
74
+ } : {}, {
75
+ role: 'listbox',
76
+ ...(0, $eCULP$reactariautils.mergeProps)(fieldProps, listProps)
77
+ })
78
+ };
79
+ }
80
+
81
+
82
+ //# source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U,kBAAkB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa;YACzG,wBAAwB;QAC1B,IAAI,CAAC,GAAG;YACN,MAAM;YACN,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/listbox/src/useListBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaListBoxProps} from '@react-types/listbox';\nimport {DOMAttributes, KeyboardDelegate, 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.main.js.map"}