@react-spectrum/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.
- package/README.md +3 -0
- package/dist/ListBox.main.js +48 -0
- package/dist/ListBox.main.js.map +1 -0
- package/dist/ListBox.mjs +39 -0
- package/dist/ListBox.module.js +39 -0
- package/dist/ListBox.module.js.map +1 -0
- package/dist/ListBoxBase.main.js +165 -0
- package/dist/ListBoxBase.main.js.map +1 -0
- package/dist/ListBoxBase.mjs +159 -0
- package/dist/ListBoxBase.module.js +159 -0
- package/dist/ListBoxBase.module.js.map +1 -0
- package/dist/ListBoxContext.main.js +27 -0
- package/dist/ListBoxContext.main.js.map +1 -0
- package/dist/ListBoxContext.mjs +18 -0
- package/dist/ListBoxContext.module.js +18 -0
- package/dist/ListBoxContext.module.js.map +1 -0
- package/dist/ListBoxLayout.main.js +79 -0
- package/dist/ListBoxLayout.main.js.map +1 -0
- package/dist/ListBoxLayout.mjs +74 -0
- package/dist/ListBoxLayout.module.js +74 -0
- package/dist/ListBoxLayout.module.js.map +1 -0
- package/dist/ListBoxOption.main.js +105 -0
- package/dist/ListBoxOption.main.js.map +1 -0
- package/dist/ListBoxOption.mjs +100 -0
- package/dist/ListBoxOption.module.js +100 -0
- package/dist/ListBoxOption.module.js.map +1 -0
- package/dist/ListBoxSection.main.js +69 -0
- package/dist/ListBoxSection.main.js.map +1 -0
- package/dist/ListBoxSection.mjs +64 -0
- package/dist/ListBoxSection.module.js +64 -0
- package/dist/ListBoxSection.module.js.map +1 -0
- package/dist/ar-AE.main.js +7 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +9 -0
- package/dist/ar-AE.module.js +9 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +7 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +9 -0
- package/dist/bg-BG.module.js +9 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +7 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +9 -0
- package/dist/cs-CZ.module.js +9 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +7 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +9 -0
- package/dist/da-DK.module.js +9 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +7 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +9 -0
- package/dist/de-DE.module.js +9 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +7 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +9 -0
- package/dist/el-GR.module.js +9 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +7 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +9 -0
- package/dist/en-US.module.js +9 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +7 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +9 -0
- package/dist/es-ES.module.js +9 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +7 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +9 -0
- package/dist/et-EE.module.js +9 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +7 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +9 -0
- package/dist/fi-FI.module.js +9 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +7 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +9 -0
- package/dist/fr-FR.module.js +9 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +7 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +9 -0
- package/dist/he-IL.module.js +9 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +7 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +9 -0
- package/dist/hr-HR.module.js +9 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +7 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +9 -0
- package/dist/hu-HU.module.js +9 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +22 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +7 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +9 -0
- package/dist/it-IT.module.js +9 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +7 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +9 -0
- package/dist/ja-JP.module.js +9 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +7 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +9 -0
- package/dist/ko-KR.module.js +9 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +7 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +9 -0
- package/dist/lt-LT.module.js +9 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +7 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +9 -0
- package/dist/lv-LV.module.js +9 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +22 -298
- package/dist/main.js.map +1 -0
- package/dist/menu_vars_css.main.js +177 -0
- package/dist/menu_vars_css.main.js.map +1 -0
- package/dist/menu_vars_css.mjs +179 -0
- package/dist/menu_vars_css.module.js +179 -0
- package/dist/menu_vars_css.module.js.map +1 -0
- package/dist/module.js +16 -250
- package/dist/module.js.map +1 -0
- package/dist/nb-NO.main.js +7 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +9 -0
- package/dist/nb-NO.module.js +9 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +7 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +9 -0
- package/dist/nl-NL.module.js +9 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +7 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +9 -0
- package/dist/pl-PL.module.js +9 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +7 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +9 -0
- package/dist/pt-BR.module.js +9 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +7 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +9 -0
- package/dist/pt-PT.module.js +9 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +7 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +9 -0
- package/dist/ro-RO.module.js +9 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +7 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +9 -0
- package/dist/ru-RU.module.js +9 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +7 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +9 -0
- package/dist/sk-SK.module.js +9 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +7 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +9 -0
- package/dist/sl-SI.module.js +9 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +7 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +9 -0
- package/dist/sr-SP.module.js +9 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +7 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +9 -0
- package/dist/sv-SE.module.js +9 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +7 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +9 -0
- package/dist/tr-TR.module.js +9 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +35 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +7 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +9 -0
- package/dist/uk-UA.module.js +9 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/vars.4c57e437.css +568 -0
- package/dist/vars.4c57e437.css.map +1 -0
- package/dist/zh-CN.main.js +7 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +9 -0
- package/dist/zh-CN.module.js +9 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +7 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +9 -0
- package/dist/zh-TW.module.js +9 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +36 -24
- package/src/ListBox.tsx +42 -0
- package/src/ListBoxBase.tsx +183 -0
- package/src/ListBoxContext.ts +23 -0
- package/src/ListBoxLayout.ts +87 -0
- package/src/ListBoxOption.tsx +113 -0
- package/src/ListBoxSection.tsx +84 -0
- package/src/index.ts +18 -0
- package/LICENSE +0 -201
- package/dist/main.css +0 -295
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import $gF3QK$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {ListBoxContext as $0c6f792811e33483$export$7ff8f37d2d81a48d} from "./ListBoxContext.module.js";
|
|
3
|
+
import {ListBoxLayout as $d20755daac213984$export$c7e5f5ea00052bf} from "./ListBoxLayout.module.js";
|
|
4
|
+
import {ListBoxOption as $86983ea1fa3f7312$export$feb3b6b552c14a12} from "./ListBoxOption.module.js";
|
|
5
|
+
import {ListBoxSection as $92d678ed88836094$export$dca12b0bb56e4fc} from "./ListBoxSection.module.js";
|
|
6
|
+
import "./vars.4c57e437.css";
|
|
7
|
+
import $gF3QK$menu_vars_cssmodulejs from "./menu_vars_css.module.js";
|
|
8
|
+
import {useListBox as $gF3QK$useListBox} from "@react-aria/listbox";
|
|
9
|
+
import {useStyleProps as $gF3QK$useStyleProps, classNames as $gF3QK$classNames} from "@react-spectrum/utils";
|
|
10
|
+
import {FocusScope as $gF3QK$FocusScope} from "@react-aria/focus";
|
|
11
|
+
import {mergeProps as $gF3QK$mergeProps} from "@react-aria/utils";
|
|
12
|
+
import {ProgressCircle as $gF3QK$ProgressCircle} from "@react-spectrum/progress";
|
|
13
|
+
import $gF3QK$react, {useMemo as $gF3QK$useMemo, useCallback as $gF3QK$useCallback, useContext as $gF3QK$useContext} from "react";
|
|
14
|
+
import {useLocalizedStringFormatter as $gF3QK$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
15
|
+
import {useProvider as $gF3QK$useProvider} from "@react-spectrum/provider";
|
|
16
|
+
import {VirtualizerItem as $gF3QK$VirtualizerItem, Virtualizer as $gF3QK$Virtualizer} from "@react-aria/virtualizer";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function $parcel$interopDefault(a) {
|
|
20
|
+
return a && a.__esModule ? a.default : a;
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
24
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
+
* governing permissions and limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function $3247d4a89e6094e9$export$25768ea656ae32a7() {
|
|
48
|
+
let { scale: scale } = (0, $gF3QK$useProvider)();
|
|
49
|
+
let layout = (0, $gF3QK$useMemo)(()=>new (0, $d20755daac213984$export$c7e5f5ea00052bf)({
|
|
50
|
+
estimatedRowHeight: scale === 'large' ? 48 : 32,
|
|
51
|
+
estimatedHeadingHeight: scale === 'large' ? 33 : 26,
|
|
52
|
+
padding: scale === 'large' ? 5 : 4,
|
|
53
|
+
placeholderHeight: scale === 'large' ? 48 : 32
|
|
54
|
+
}), [
|
|
55
|
+
scale
|
|
56
|
+
]);
|
|
57
|
+
return layout;
|
|
58
|
+
}
|
|
59
|
+
/** @private */ function $3247d4a89e6094e9$var$ListBoxBase(props, ref) {
|
|
60
|
+
let { layout: layout, state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus, domProps: domProps = {}, isLoading: isLoading, showLoadingSpinner: showLoadingSpinner = isLoading, onScroll: onScroll, renderEmptyState: renderEmptyState } = props;
|
|
61
|
+
let { listBoxProps: listBoxProps } = (0, $gF3QK$useListBox)({
|
|
62
|
+
...props,
|
|
63
|
+
layoutDelegate: layout,
|
|
64
|
+
isVirtualized: true
|
|
65
|
+
}, state, ref);
|
|
66
|
+
let { styleProps: styleProps } = (0, $gF3QK$useStyleProps)(props);
|
|
67
|
+
let renderWrapper = (0, $gF3QK$useCallback)((parent, reusableView, children, renderChildren)=>{
|
|
68
|
+
var _children_find;
|
|
69
|
+
if (reusableView.viewType === 'section') return /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $92d678ed88836094$export$dca12b0bb56e4fc), {
|
|
70
|
+
key: reusableView.key,
|
|
71
|
+
item: reusableView.content,
|
|
72
|
+
layoutInfo: reusableView.layoutInfo,
|
|
73
|
+
virtualizer: reusableView.virtualizer,
|
|
74
|
+
headerLayoutInfo: (_children_find = children.find((c)=>c.viewType === 'header')) === null || _children_find === void 0 ? void 0 : _children_find.layoutInfo
|
|
75
|
+
}, renderChildren(children.filter((c)=>c.viewType === 'item')));
|
|
76
|
+
return /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $gF3QK$VirtualizerItem), {
|
|
77
|
+
key: reusableView.key,
|
|
78
|
+
layoutInfo: reusableView.layoutInfo,
|
|
79
|
+
virtualizer: reusableView.virtualizer,
|
|
80
|
+
parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
|
|
81
|
+
}, reusableView.rendered);
|
|
82
|
+
}, []);
|
|
83
|
+
let focusedKey = state.selectionManager.focusedKey;
|
|
84
|
+
let persistedKeys = (0, $gF3QK$useMemo)(()=>focusedKey != null ? new Set([
|
|
85
|
+
focusedKey
|
|
86
|
+
]) : null, [
|
|
87
|
+
focusedKey
|
|
88
|
+
]);
|
|
89
|
+
return /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $0c6f792811e33483$export$7ff8f37d2d81a48d).Provider, {
|
|
90
|
+
value: {
|
|
91
|
+
state: state,
|
|
92
|
+
renderEmptyState: renderEmptyState,
|
|
93
|
+
shouldFocusOnHover: shouldFocusOnHover,
|
|
94
|
+
shouldUseVirtualFocus: shouldUseVirtualFocus
|
|
95
|
+
}
|
|
96
|
+
}, /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $gF3QK$FocusScope), null, /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $gF3QK$Virtualizer), {
|
|
97
|
+
...styleProps,
|
|
98
|
+
...(0, $gF3QK$mergeProps)(listBoxProps, domProps),
|
|
99
|
+
ref: ref,
|
|
100
|
+
persistedKeys: persistedKeys,
|
|
101
|
+
autoFocus: !!props.autoFocus || undefined,
|
|
102
|
+
scrollDirection: "vertical",
|
|
103
|
+
className: (0, $gF3QK$classNames)((0, ($parcel$interopDefault($gF3QK$menu_vars_cssmodulejs))), 'spectrum-Menu', styleProps.className),
|
|
104
|
+
layout: layout,
|
|
105
|
+
layoutOptions: (0, $gF3QK$useMemo)(()=>({
|
|
106
|
+
isLoading: showLoadingSpinner
|
|
107
|
+
}), [
|
|
108
|
+
showLoadingSpinner
|
|
109
|
+
]),
|
|
110
|
+
collection: state.collection,
|
|
111
|
+
renderWrapper: renderWrapper,
|
|
112
|
+
isLoading: isLoading,
|
|
113
|
+
onLoadMore: props.onLoadMore,
|
|
114
|
+
onScroll: onScroll
|
|
115
|
+
}, (0, $gF3QK$useCallback)((type, item)=>{
|
|
116
|
+
if (type === 'item') return /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $86983ea1fa3f7312$export$feb3b6b552c14a12), {
|
|
117
|
+
item: item
|
|
118
|
+
});
|
|
119
|
+
else if (type === 'loader') return /*#__PURE__*/ (0, $gF3QK$react).createElement($3247d4a89e6094e9$var$LoadingState, null);
|
|
120
|
+
else if (type === 'placeholder') return /*#__PURE__*/ (0, $gF3QK$react).createElement($3247d4a89e6094e9$var$EmptyState, null);
|
|
121
|
+
}, []))));
|
|
122
|
+
}
|
|
123
|
+
// forwardRef doesn't support generic parameters, so cast the result to the correct type
|
|
124
|
+
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
|
|
125
|
+
const $3247d4a89e6094e9$export$1afdcf349979fb7e = /*#__PURE__*/ (0, $gF3QK$react).forwardRef($3247d4a89e6094e9$var$ListBoxBase);
|
|
126
|
+
function $3247d4a89e6094e9$var$LoadingState() {
|
|
127
|
+
let { state: state } = (0, $gF3QK$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
|
|
128
|
+
let stringFormatter = (0, $gF3QK$useLocalizedStringFormatter)((0, ($parcel$interopDefault($gF3QK$intlStringsmodulejs))), '@react-spectrum/listbox');
|
|
129
|
+
return(// aria-selected isn't needed here since this option is not selectable.
|
|
130
|
+
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
131
|
+
/*#__PURE__*/ (0, $gF3QK$react).createElement("div", {
|
|
132
|
+
role: "option",
|
|
133
|
+
style: {
|
|
134
|
+
display: 'flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
height: '100%'
|
|
138
|
+
}
|
|
139
|
+
}, /*#__PURE__*/ (0, $gF3QK$react).createElement((0, $gF3QK$ProgressCircle), {
|
|
140
|
+
isIndeterminate: true,
|
|
141
|
+
size: "S",
|
|
142
|
+
"aria-label": state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading'),
|
|
143
|
+
UNSAFE_className: (0, $gF3QK$classNames)((0, ($parcel$interopDefault($gF3QK$menu_vars_cssmodulejs))), 'spectrum-Dropdown-progressCircle')
|
|
144
|
+
})));
|
|
145
|
+
}
|
|
146
|
+
function $3247d4a89e6094e9$var$EmptyState() {
|
|
147
|
+
let { renderEmptyState: renderEmptyState } = (0, $gF3QK$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
|
|
148
|
+
let emptyState = renderEmptyState ? renderEmptyState() : null;
|
|
149
|
+
if (emptyState == null) return null;
|
|
150
|
+
return /*#__PURE__*/ (0, $gF3QK$react).createElement("div", {
|
|
151
|
+
// aria-selected isn't needed here since this option is not selectable.
|
|
152
|
+
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
153
|
+
role: "option"
|
|
154
|
+
}, emptyState);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
export {$3247d4a89e6094e9$export$25768ea656ae32a7 as useListBoxLayout, $3247d4a89e6094e9$export$1afdcf349979fb7e as ListBoxBase};
|
|
159
|
+
//# sourceMappingURL=ListBoxBase.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS;IACd,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IACnB,IAAI,CAAA,GAAA,wCAAY,EAAK;YACnB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wBAAwB,UAAU,UAAU,KAAK;YACjD,SAAS,UAAU,UAAU,IAAI;YACjC,mBAAmB,UAAU,UAAU,KAAK;QAC9C,IACA;QAAC;KAAM;IAET,OAAO;AACT;AAEA,aAAa,GACb,SAAS,kCAAe,KAA0B,EAAE,GAAqC;IACvF,IAAI,UAAC,MAAM,SAAE,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,YAAE,WAAW,CAAC,cAAG,SAAS,sBAAE,qBAAqB,qBAAW,QAAQ,oBAAE,gBAAgB,EAAC,GAAG;IACvJ,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;QAC9B,GAAG,KAAK;QACR,gBAAgB;QAChB,eAAe;IACjB,GAAG,OAAO;IACV,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IAKjC,IAAI,gBAAgB,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAc,cAAoB,UAAkB;YAQ3D;QAPxB,IAAI,aAAa,QAAQ,KAAK,WAC5B,qBACE,gCAAC,CAAA,GAAA,wCAAa;YACZ,KAAK,aAAa,GAAG;YACrB,MAAM,aAAa,OAAO;YAC1B,YAAY,aAAa,UAAU;YACnC,aAAa,aAAa,WAAW;YACrC,gBAAgB,GAAE,iBAAA,S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AS,eAClB,qBAAO,gCAAC;IAEZ,GAAG,EAAE;AAKf;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGtC,SAAS;IACP,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACtC,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,OACE,uEAAuE;IACvE,iEAAiE;kBACjE,gCAAC;QAAI,MAAK;QAAS,OAAO;YAAC,SAAS;YAAQ,YAAY;YAAU,gBAAgB;YAAU,QAAQ;QAAM;qBACxG,gCAAC,CAAA,GAAA,qBAAa;QACZ,iBAAA;QACA,MAAK;QACL,cAAY,MAAM,UAAU,CAAC,IAAI,GAAG,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,gBAAgB,MAAM,CAAC;QACvG,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;;AAG7C;AAEA,SAAS;IACP,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACjD,IAAI,aAAa,mBAAmB,qBAAqB;IACzD,IAAI,cAAc,MAChB,OAAO;IAGT,qBACE,gCAAC;QACC,uEAAuE;QACvE,iEAAiE;QACjE,MAAK;OACJ;AAGP","sources":["packages/@react-spectrum/listbox/src/ListBoxBase.tsx"],"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 {AriaLabelingProps, DOMProps, FocusStrategy, Node, RefObject, StyleProps} from '@react-types/shared';\nimport {AriaListBoxOptions, useListBox} from '@react-aria/listbox';\nimport {classNames, useStyleProps} from '@react-spectrum/utils';\nimport {FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListBoxContext} from './ListBoxContext';\nimport {ListBoxLayout} from './ListBoxLayout';\nimport {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useContext, useMemo} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\ninterface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabelingProps, StyleProps {\n layout: ListBoxLayout<T>,\n state: ListState<T>,\n autoFocus?: boolean | FocusStrategy,\n shouldFocusWrap?: boolean,\n shouldSelectOnPressUp?: boolean,\n focusOnPointerEnter?: boolean,\n domProps?: HTMLAttributes<HTMLElement>,\n disallowEmptySelection?: boolean,\n shouldUseVirtualFocus?: boolean,\n isLoading?: boolean,\n showLoadingSpinner?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(): ListBoxLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListBoxLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n placeholderHeight: scale === 'large' ? 48 : 32\n })\n , [scale]);\n\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n layoutDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n\n // This overrides collection view's renderWrapper to support hierarchy of items in sections.\n // The header is extracted from the children so it can receive ARIA labeling properties.\n type View = ReusableView<Node<T>, ReactElement>;\n let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {\n if (reusableView.viewType === 'section') {\n return (\n <ListBoxSection\n key={reusableView.key}\n item={reusableView.content}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n headerLayoutInfo={children.find(c => c.viewType === 'header')?.layoutInfo}>\n {renderChildren(children.filter(c => c.viewType === 'item'))}\n </ListBoxSection>\n );\n }\n\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n }, []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n persistedKeys={persistedKeys}\n autoFocus={!!props.autoFocus || undefined}\n scrollDirection=\"vertical\"\n className={\n classNames(\n styles,\n 'spectrum-Menu',\n styleProps.className\n )\n }\n layout={layout}\n layoutOptions={useMemo(() => ({\n isLoading: showLoadingSpinner\n }), [showLoadingSpinner])}\n collection={state.collection}\n renderWrapper={renderWrapper}\n isLoading={isLoading}\n onLoadMore={props.onLoadMore}\n onScroll={onScroll}>\n {useCallback((type, item: Node<T>) => {\n if (type === 'item') {\n return <ListBoxOption item={item} />;\n } else if (type === 'loader') {\n return <LoadingState />;\n } else if (type === 'placeholder') {\n return <EmptyState />;\n }\n }, [])}\n </Virtualizer>\n </FocusScope>\n </ListBoxContext.Provider>\n );\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _ListBoxBase = React.forwardRef(ListBoxBase) as <T>(props: ListBoxBaseProps<T> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_ListBoxBase as ListBoxBase};\n\nfunction LoadingState() {\n let {state} = useContext(ListBoxContext);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/listbox');\n return (\n // aria-selected isn't needed here since this option is not selectable.\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props\n <div role=\"option\" style={{display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%'}}>\n <ProgressCircle\n isIndeterminate\n size=\"S\"\n aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')}\n UNSAFE_className={classNames(styles, 'spectrum-Dropdown-progressCircle')} />\n </div>\n );\n}\n\nfunction EmptyState() {\n let {renderEmptyState} = useContext(ListBoxContext);\n let emptyState = renderEmptyState ? renderEmptyState() : null;\n if (emptyState == null) {\n return null;\n }\n\n return (\n <div\n // aria-selected isn't needed here since this option is not selectable.\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props\n role=\"option\">\n {emptyState}\n </div>\n );\n}\n"],"names":[],"version":3,"file":"ListBoxBase.module.js.map"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var $497sr$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$interopDefault(a) {
|
|
5
|
+
return a && a.__esModule ? a.default : a;
|
|
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, "ListBoxContext", () => $611e93c7b7c0413c$export$7ff8f37d2d81a48d);
|
|
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
|
+
const $611e93c7b7c0413c$export$7ff8f37d2d81a48d = (0, ($parcel$interopDefault($497sr$react))).createContext(null);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ListBoxContext.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAYM,MAAM,4CAAiB,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAsB","sources":["packages/@react-spectrum/listbox/src/ListBoxContext.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 {ListState} from '@react-stately/list';\nimport React, {ReactNode} from 'react';\n\ninterface ListBoxContextValue {\n state: ListState<unknown>,\n renderEmptyState?: () => ReactNode,\n shouldFocusOnHover: boolean,\n shouldUseVirtualFocus: boolean\n}\n\nexport const ListBoxContext = React.createContext<ListBoxContextValue>(null);\n"],"names":[],"version":3,"file":"ListBoxContext.main.js.map"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import $8XLda$react from "react";
|
|
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
|
+
const $0c6f792811e33483$export$7ff8f37d2d81a48d = (0, $8XLda$react).createContext(null);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export {$0c6f792811e33483$export$7ff8f37d2d81a48d as ListBoxContext};
|
|
18
|
+
//# sourceMappingURL=ListBoxContext.module.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import $8XLda$react from "react";
|
|
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
|
+
const $0c6f792811e33483$export$7ff8f37d2d81a48d = (0, $8XLda$react).createContext(null);
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export {$0c6f792811e33483$export$7ff8f37d2d81a48d as ListBoxContext};
|
|
18
|
+
//# sourceMappingURL=ListBoxContext.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAYM,MAAM,4CAAiB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAsB","sources":["packages/@react-spectrum/listbox/src/ListBoxContext.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 {ListState} from '@react-stately/list';\nimport React, {ReactNode} from 'react';\n\ninterface ListBoxContextValue {\n state: ListState<unknown>,\n renderEmptyState?: () => ReactNode,\n shouldFocusOnHover: boolean,\n shouldUseVirtualFocus: boolean\n}\n\nexport const ListBoxContext = React.createContext<ListBoxContextValue>(null);\n"],"names":[],"version":3,"file":"ListBoxContext.module.js.map"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var $7VTYQ$reactstatelyvirtualizer = require("@react-stately/virtualizer");
|
|
2
|
+
var $7VTYQ$reactstatelylayout = require("@react-stately/layout");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "ListBoxLayout", () => $570d5c216669f686$export$c7e5f5ea00052bf);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class $570d5c216669f686$export$c7e5f5ea00052bf extends (0, $7VTYQ$reactstatelylayout.ListLayout) {
|
|
13
|
+
update(invalidationContext) {
|
|
14
|
+
var _invalidationContext_layoutOptions;
|
|
15
|
+
this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
|
|
16
|
+
super.update(invalidationContext);
|
|
17
|
+
}
|
|
18
|
+
buildCollection() {
|
|
19
|
+
let nodes = super.buildCollection(this.padding);
|
|
20
|
+
let y = this.contentSize.height;
|
|
21
|
+
if (this.isLoading) {
|
|
22
|
+
let rect = new (0, $7VTYQ$reactstatelyvirtualizer.Rect)(0, y, this.virtualizer.visibleRect.width, 40);
|
|
23
|
+
let loader = new (0, $7VTYQ$reactstatelyvirtualizer.LayoutInfo)('loader', 'loader', rect);
|
|
24
|
+
let node = {
|
|
25
|
+
layoutInfo: loader,
|
|
26
|
+
validRect: loader.rect
|
|
27
|
+
};
|
|
28
|
+
nodes.push(node);
|
|
29
|
+
this.layoutNodes.set(loader.key, node);
|
|
30
|
+
y = loader.rect.maxY;
|
|
31
|
+
}
|
|
32
|
+
if (nodes.length === 0) {
|
|
33
|
+
var _this_placeholderHeight;
|
|
34
|
+
let rect = new (0, $7VTYQ$reactstatelyvirtualizer.Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
|
|
35
|
+
let placeholder = new (0, $7VTYQ$reactstatelyvirtualizer.LayoutInfo)('placeholder', 'placeholder', rect);
|
|
36
|
+
let node = {
|
|
37
|
+
layoutInfo: placeholder,
|
|
38
|
+
validRect: placeholder.rect
|
|
39
|
+
};
|
|
40
|
+
nodes.push(node);
|
|
41
|
+
this.layoutNodes.set(placeholder.key, node);
|
|
42
|
+
y = placeholder.rect.maxY;
|
|
43
|
+
}
|
|
44
|
+
this.contentSize.height = y + this.padding;
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
buildSection(node, x, y) {
|
|
48
|
+
// Synthesize a collection node for the header.
|
|
49
|
+
let headerNode = {
|
|
50
|
+
type: 'header',
|
|
51
|
+
key: node.key + ':header',
|
|
52
|
+
parentKey: node.key,
|
|
53
|
+
value: null,
|
|
54
|
+
level: node.level,
|
|
55
|
+
hasChildNodes: false,
|
|
56
|
+
childNodes: [],
|
|
57
|
+
rendered: node.rendered,
|
|
58
|
+
textValue: node.textValue
|
|
59
|
+
};
|
|
60
|
+
// Build layout node for it and adjust y offset of section children.
|
|
61
|
+
let header = this.buildSectionHeader(headerNode, x, y);
|
|
62
|
+
header.node = headerNode;
|
|
63
|
+
header.layoutInfo.parentKey = node.key;
|
|
64
|
+
this.layoutNodes.set(headerNode.key, header);
|
|
65
|
+
y += header.layoutInfo.rect.height;
|
|
66
|
+
let section = super.buildSection(node, x, y);
|
|
67
|
+
section.children.unshift(header);
|
|
68
|
+
return section;
|
|
69
|
+
}
|
|
70
|
+
constructor(opts){
|
|
71
|
+
super(opts);
|
|
72
|
+
this.isLoading = false;
|
|
73
|
+
this.placeholderHeight = opts.placeholderHeight;
|
|
74
|
+
this.padding = opts.padding;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=ListBoxLayout.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAaO,MAAM,iDAAyB,CAAA,GAAA,oCAAS;IAW7C,OAAO,mBAA4D,EAAQ;YACxD;QAAjB,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,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MAAM;YACN,KAAK,KAAK,GAAG,GAAG;YAChB,WAAW,KAAK,GAAG;YACnB,OAAO;YACP,OAAO,KAAK,KAAK;YACjB,eAAe;YACf,YAAY,EAAE;YACd,UAAU,KAAK,QAAQ;YACvB,WAAW,KAAK,SAAS;QAC3B;QAEA,oEAAoE;QACpE,IAAI,SAAS,IAAI,CAAC,kBAAkB,CAAC,YAAY,GAAG;QACpD,OAAO,IAAI,GAAG;QACd,OAAO,UAAU,CAAC,SAAS,GAAG,KAAK,GAAG;QACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE;QACrC,KAAK,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM;QAElC,IAAI,UAAU,KAAK,CAAC,aAAa,MAAM,GAAG;QAC1C,QAAQ,QAAQ,CAAC,OAAO,CAAC;QACzB,OAAO;IACT;IAnEA,YAAY,IAA0B,CAAE;QACtC,KAAK,CAAC;aALA,YAAqB;QAM3B,IAAI,CAAC,iBAAiB,GAAG,KAAK,iBAAiB;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,OAAO;IAC7B;AAgEF","sources":["packages/@react-spectrum/listbox/src/ListBoxLayout.ts"],"sourcesContent":["import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';\nimport {Node} from '@react-types/shared';\n\ninterface ListBoxLayoutProps {\n isLoading?: boolean\n}\n\ninterface ListBoxLayoutOptions extends ListLayoutOptions {\n placeholderHeight: number,\n padding: number\n}\n\nexport class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {\n private isLoading: boolean = false;\n private placeholderHeight: number;\n private padding: number;\n\n constructor(opts: ListBoxLayoutOptions) {\n super(opts);\n this.placeholderHeight = opts.placeholderHeight;\n this.padding = opts.padding;\n }\n\n update(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n super.update(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n let nodes = super.buildCollection(this.padding);\n let y = this.contentSize.height;\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, 40);\n let loader = new LayoutInfo('loader', 'loader', rect);\n let node = {\n layoutInfo: loader,\n validRect: loader.rect\n };\n nodes.push(node);\n this.layoutNodes.set(loader.key, node);\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n let node = {\n layoutInfo: placeholder,\n validRect: placeholder.rect\n };\n nodes.push(node);\n this.layoutNodes.set(placeholder.key, node);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize.height = y + this.padding;\n return nodes;\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n // Synthesize a collection node for the header.\n let headerNode = {\n type: 'header',\n key: node.key + ':header',\n parentKey: node.key,\n value: null,\n level: node.level,\n hasChildNodes: false,\n childNodes: [],\n rendered: node.rendered,\n textValue: node.textValue\n };\n\n // Build layout node for it and adjust y offset of section children.\n let header = this.buildSectionHeader(headerNode, x, y);\n header.node = headerNode;\n header.layoutInfo.parentKey = node.key;\n this.layoutNodes.set(headerNode.key, header);\n y += header.layoutInfo.rect.height;\n\n let section = super.buildSection(node, x, y);\n section.children.unshift(header);\n return section;\n }\n}\n"],"names":[],"version":3,"file":"ListBoxLayout.main.js.map"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {Rect as $3YKfq$Rect, LayoutInfo as $3YKfq$LayoutInfo} from "@react-stately/virtualizer";
|
|
2
|
+
import {ListLayout as $3YKfq$ListLayout} from "@react-stately/layout";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class $d20755daac213984$export$c7e5f5ea00052bf extends (0, $3YKfq$ListLayout) {
|
|
7
|
+
update(invalidationContext) {
|
|
8
|
+
var _invalidationContext_layoutOptions;
|
|
9
|
+
this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
|
|
10
|
+
super.update(invalidationContext);
|
|
11
|
+
}
|
|
12
|
+
buildCollection() {
|
|
13
|
+
let nodes = super.buildCollection(this.padding);
|
|
14
|
+
let y = this.contentSize.height;
|
|
15
|
+
if (this.isLoading) {
|
|
16
|
+
let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, 40);
|
|
17
|
+
let loader = new (0, $3YKfq$LayoutInfo)('loader', 'loader', rect);
|
|
18
|
+
let node = {
|
|
19
|
+
layoutInfo: loader,
|
|
20
|
+
validRect: loader.rect
|
|
21
|
+
};
|
|
22
|
+
nodes.push(node);
|
|
23
|
+
this.layoutNodes.set(loader.key, node);
|
|
24
|
+
y = loader.rect.maxY;
|
|
25
|
+
}
|
|
26
|
+
if (nodes.length === 0) {
|
|
27
|
+
var _this_placeholderHeight;
|
|
28
|
+
let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
|
|
29
|
+
let placeholder = new (0, $3YKfq$LayoutInfo)('placeholder', 'placeholder', rect);
|
|
30
|
+
let node = {
|
|
31
|
+
layoutInfo: placeholder,
|
|
32
|
+
validRect: placeholder.rect
|
|
33
|
+
};
|
|
34
|
+
nodes.push(node);
|
|
35
|
+
this.layoutNodes.set(placeholder.key, node);
|
|
36
|
+
y = placeholder.rect.maxY;
|
|
37
|
+
}
|
|
38
|
+
this.contentSize.height = y + this.padding;
|
|
39
|
+
return nodes;
|
|
40
|
+
}
|
|
41
|
+
buildSection(node, x, y) {
|
|
42
|
+
// Synthesize a collection node for the header.
|
|
43
|
+
let headerNode = {
|
|
44
|
+
type: 'header',
|
|
45
|
+
key: node.key + ':header',
|
|
46
|
+
parentKey: node.key,
|
|
47
|
+
value: null,
|
|
48
|
+
level: node.level,
|
|
49
|
+
hasChildNodes: false,
|
|
50
|
+
childNodes: [],
|
|
51
|
+
rendered: node.rendered,
|
|
52
|
+
textValue: node.textValue
|
|
53
|
+
};
|
|
54
|
+
// Build layout node for it and adjust y offset of section children.
|
|
55
|
+
let header = this.buildSectionHeader(headerNode, x, y);
|
|
56
|
+
header.node = headerNode;
|
|
57
|
+
header.layoutInfo.parentKey = node.key;
|
|
58
|
+
this.layoutNodes.set(headerNode.key, header);
|
|
59
|
+
y += header.layoutInfo.rect.height;
|
|
60
|
+
let section = super.buildSection(node, x, y);
|
|
61
|
+
section.children.unshift(header);
|
|
62
|
+
return section;
|
|
63
|
+
}
|
|
64
|
+
constructor(opts){
|
|
65
|
+
super(opts);
|
|
66
|
+
this.isLoading = false;
|
|
67
|
+
this.placeholderHeight = opts.placeholderHeight;
|
|
68
|
+
this.padding = opts.padding;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export {$d20755daac213984$export$c7e5f5ea00052bf as ListBoxLayout};
|
|
74
|
+
//# sourceMappingURL=ListBoxLayout.module.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {Rect as $3YKfq$Rect, LayoutInfo as $3YKfq$LayoutInfo} from "@react-stately/virtualizer";
|
|
2
|
+
import {ListLayout as $3YKfq$ListLayout} from "@react-stately/layout";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class $d20755daac213984$export$c7e5f5ea00052bf extends (0, $3YKfq$ListLayout) {
|
|
7
|
+
update(invalidationContext) {
|
|
8
|
+
var _invalidationContext_layoutOptions;
|
|
9
|
+
this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
|
|
10
|
+
super.update(invalidationContext);
|
|
11
|
+
}
|
|
12
|
+
buildCollection() {
|
|
13
|
+
let nodes = super.buildCollection(this.padding);
|
|
14
|
+
let y = this.contentSize.height;
|
|
15
|
+
if (this.isLoading) {
|
|
16
|
+
let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, 40);
|
|
17
|
+
let loader = new (0, $3YKfq$LayoutInfo)('loader', 'loader', rect);
|
|
18
|
+
let node = {
|
|
19
|
+
layoutInfo: loader,
|
|
20
|
+
validRect: loader.rect
|
|
21
|
+
};
|
|
22
|
+
nodes.push(node);
|
|
23
|
+
this.layoutNodes.set(loader.key, node);
|
|
24
|
+
y = loader.rect.maxY;
|
|
25
|
+
}
|
|
26
|
+
if (nodes.length === 0) {
|
|
27
|
+
var _this_placeholderHeight;
|
|
28
|
+
let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
|
|
29
|
+
let placeholder = new (0, $3YKfq$LayoutInfo)('placeholder', 'placeholder', rect);
|
|
30
|
+
let node = {
|
|
31
|
+
layoutInfo: placeholder,
|
|
32
|
+
validRect: placeholder.rect
|
|
33
|
+
};
|
|
34
|
+
nodes.push(node);
|
|
35
|
+
this.layoutNodes.set(placeholder.key, node);
|
|
36
|
+
y = placeholder.rect.maxY;
|
|
37
|
+
}
|
|
38
|
+
this.contentSize.height = y + this.padding;
|
|
39
|
+
return nodes;
|
|
40
|
+
}
|
|
41
|
+
buildSection(node, x, y) {
|
|
42
|
+
// Synthesize a collection node for the header.
|
|
43
|
+
let headerNode = {
|
|
44
|
+
type: 'header',
|
|
45
|
+
key: node.key + ':header',
|
|
46
|
+
parentKey: node.key,
|
|
47
|
+
value: null,
|
|
48
|
+
level: node.level,
|
|
49
|
+
hasChildNodes: false,
|
|
50
|
+
childNodes: [],
|
|
51
|
+
rendered: node.rendered,
|
|
52
|
+
textValue: node.textValue
|
|
53
|
+
};
|
|
54
|
+
// Build layout node for it and adjust y offset of section children.
|
|
55
|
+
let header = this.buildSectionHeader(headerNode, x, y);
|
|
56
|
+
header.node = headerNode;
|
|
57
|
+
header.layoutInfo.parentKey = node.key;
|
|
58
|
+
this.layoutNodes.set(headerNode.key, header);
|
|
59
|
+
y += header.layoutInfo.rect.height;
|
|
60
|
+
let section = super.buildSection(node, x, y);
|
|
61
|
+
section.children.unshift(header);
|
|
62
|
+
return section;
|
|
63
|
+
}
|
|
64
|
+
constructor(opts){
|
|
65
|
+
super(opts);
|
|
66
|
+
this.isLoading = false;
|
|
67
|
+
this.placeholderHeight = opts.placeholderHeight;
|
|
68
|
+
this.padding = opts.padding;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export {$d20755daac213984$export$c7e5f5ea00052bf as ListBoxLayout};
|
|
74
|
+
//# sourceMappingURL=ListBoxLayout.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AAaO,MAAM,iDAAyB,CAAA,GAAA,iBAAS;IAW7C,OAAO,mBAA4D,EAAQ;YACxD;QAAjB,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,KAAK,CAAC,OAAO;IACf;IAEU,kBAAgC;QACxC,IAAI,QAAQ,KAAK,CAAC,gBAAgB,IAAI,CAAC,OAAO;QAC9C,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM;QAE/B,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,IAAI,OAAO,IAAI,CAAA,GAAA,WAAG,EAAE,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,EAAE;YAC9D,IAAI,SAAS,IAAI,CAAA,GAAA,iBAAS,EAAE,UAAU,UAAU;YAChD,IAAI,OAAO;gBACT,YAAY;gBACZ,WAAW,OAAO,IAAI;YACxB;YACA,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,UAAU,KAAK,CAAC,aAAa,MAAM,GAAG;QAC1C,QAAQ,QAAQ,CAAC,OAAO,CAAC;QACzB,OAAO;IACT;IAnEA,YAAY,IAA0B,CAAE;QACtC,KAAK,CAAC;aALA,YAAqB;QAM3B,IAAI,CAAC,iBAAiB,GAAG,KAAK,iBAAiB;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,OAAO;IAC7B;AAgEF","sources":["packages/@react-spectrum/listbox/src/ListBoxLayout.ts"],"sourcesContent":["import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';\nimport {Node} from '@react-types/shared';\n\ninterface ListBoxLayoutProps {\n isLoading?: boolean\n}\n\ninterface ListBoxLayoutOptions extends ListLayoutOptions {\n placeholderHeight: number,\n padding: number\n}\n\nexport class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {\n private isLoading: boolean = false;\n private placeholderHeight: number;\n private padding: number;\n\n constructor(opts: ListBoxLayoutOptions) {\n super(opts);\n this.placeholderHeight = opts.placeholderHeight;\n this.padding = opts.padding;\n }\n\n update(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n super.update(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n let nodes = super.buildCollection(this.padding);\n let y = this.contentSize.height;\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, 40);\n let loader = new LayoutInfo('loader', 'loader', rect);\n let node = {\n layoutInfo: loader,\n validRect: loader.rect\n };\n nodes.push(node);\n this.layoutNodes.set(loader.key, node);\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n let node = {\n layoutInfo: placeholder,\n validRect: placeholder.rect\n };\n nodes.push(node);\n this.layoutNodes.set(placeholder.key, node);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize.height = y + this.padding;\n return nodes;\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n // Synthesize a collection node for the header.\n let headerNode = {\n type: 'header',\n key: node.key + ':header',\n parentKey: node.key,\n value: null,\n level: node.level,\n hasChildNodes: false,\n childNodes: [],\n rendered: node.rendered,\n textValue: node.textValue\n };\n\n // Build layout node for it and adjust y offset of section children.\n let header = this.buildSectionHeader(headerNode, x, y);\n header.node = headerNode;\n header.layoutInfo.parentKey = node.key;\n this.layoutNodes.set(headerNode.key, header);\n y += header.layoutInfo.rect.height;\n\n let section = super.buildSection(node, x, y);\n section.children.unshift(header);\n return section;\n }\n}\n"],"names":[],"version":3,"file":"ListBoxLayout.module.js.map"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var $611e93c7b7c0413c$exports = require("./ListBoxContext.main.js");
|
|
2
|
+
require("./vars.4c57e437.css");
|
|
3
|
+
var $3deee0fd2b46e64f$exports = require("./menu_vars_css.main.js");
|
|
4
|
+
var $8xmxv$spectrumiconsuiCheckmarkMedium = require("@spectrum-icons/ui/CheckmarkMedium");
|
|
5
|
+
var $8xmxv$reactspectrumutils = require("@react-spectrum/utils");
|
|
6
|
+
var $8xmxv$reactariafocus = require("@react-aria/focus");
|
|
7
|
+
var $8xmxv$reactspectrumlayout = require("@react-spectrum/layout");
|
|
8
|
+
var $8xmxv$reactariainteractions = require("@react-aria/interactions");
|
|
9
|
+
var $8xmxv$reactariautils = require("@react-aria/utils");
|
|
10
|
+
var $8xmxv$react = require("react");
|
|
11
|
+
var $8xmxv$reactspectrumtext = require("@react-spectrum/text");
|
|
12
|
+
var $8xmxv$reactarialistbox = require("@react-aria/listbox");
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
function $parcel$interopDefault(a) {
|
|
16
|
+
return a && a.__esModule ? a.default : a;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function $parcel$export(e, n, v, s) {
|
|
20
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$parcel$export(module.exports, "ListBoxOption", () => $2205d250ee1cb1ac$export$feb3b6b552c14a12);
|
|
24
|
+
/*
|
|
25
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
26
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
27
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
28
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
+
*
|
|
30
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
31
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
32
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
33
|
+
* governing permissions and limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function $2205d250ee1cb1ac$export$feb3b6b552c14a12(props) {
|
|
46
|
+
let { item: item } = props;
|
|
47
|
+
let { rendered: rendered, key: key } = item;
|
|
48
|
+
let ElementType = item.props.href ? 'a' : 'div';
|
|
49
|
+
let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $8xmxv$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
|
|
50
|
+
let ref = (0, $8xmxv$react.useRef)(undefined);
|
|
51
|
+
let { optionProps: optionProps, labelProps: labelProps, descriptionProps: descriptionProps, isSelected: isSelected, isDisabled: isDisabled, isFocused: isFocused } = (0, $8xmxv$reactarialistbox.useOption)({
|
|
52
|
+
'aria-label': item['aria-label'],
|
|
53
|
+
key: key,
|
|
54
|
+
isVirtualized: true
|
|
55
|
+
}, state, ref);
|
|
56
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8xmxv$reactariainteractions.useHover)({
|
|
57
|
+
...props,
|
|
58
|
+
isDisabled: isDisabled
|
|
59
|
+
});
|
|
60
|
+
let contents = typeof rendered === 'string' ? /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, $8xmxv$reactspectrumtext.Text), null, rendered) : rendered;
|
|
61
|
+
let isKeyboardModality = (0, $8xmxv$reactariainteractions.isFocusVisible)();
|
|
62
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, $8xmxv$reactariafocus.FocusRing), {
|
|
63
|
+
focusRingClass: (0, $8xmxv$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'focus-ring')
|
|
64
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement(ElementType, {
|
|
65
|
+
...(0, $8xmxv$reactariautils.mergeProps)(optionProps, shouldFocusOnHover ? {} : hoverProps),
|
|
66
|
+
ref: ref,
|
|
67
|
+
className: (0, $8xmxv$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-item', {
|
|
68
|
+
// If using virtual focus, apply focused styles to the item when the user is interacting with keyboard modality
|
|
69
|
+
'is-focused': shouldUseVirtualFocus && isFocused && isKeyboardModality,
|
|
70
|
+
'is-disabled': isDisabled,
|
|
71
|
+
'is-selected': isSelected,
|
|
72
|
+
'is-selectable': state.selectionManager.selectionMode !== 'none',
|
|
73
|
+
// When shouldFocusOnHover is false, apply hover styles both when hovered with the mouse.
|
|
74
|
+
// Otherwise, apply hover styles when focused using non-keyboard modality.
|
|
75
|
+
'is-hovered': isHovered && !shouldFocusOnHover || isFocused && !isKeyboardModality
|
|
76
|
+
})
|
|
77
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, $8xmxv$reactspectrumlayout.Grid), {
|
|
78
|
+
UNSAFE_className: (0, $8xmxv$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-itemGrid')
|
|
79
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, $8xmxv$reactspectrumutils.ClearSlots), null, /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, $8xmxv$reactspectrumutils.SlotProvider), {
|
|
80
|
+
slots: {
|
|
81
|
+
text: {
|
|
82
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-itemLabel'],
|
|
83
|
+
...labelProps
|
|
84
|
+
},
|
|
85
|
+
icon: {
|
|
86
|
+
size: 'S',
|
|
87
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-icon']
|
|
88
|
+
},
|
|
89
|
+
avatar: {
|
|
90
|
+
size: 'avatar-size-100',
|
|
91
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-avatar']
|
|
92
|
+
},
|
|
93
|
+
description: {
|
|
94
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-description'],
|
|
95
|
+
...descriptionProps
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, contents, isSelected && /*#__PURE__*/ (0, ($parcel$interopDefault($8xmxv$react))).createElement((0, ($parcel$interopDefault($8xmxv$spectrumiconsuiCheckmarkMedium))), {
|
|
99
|
+
slot: "checkmark",
|
|
100
|
+
UNSAFE_className: (0, $8xmxv$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-checkmark')
|
|
101
|
+
}))))));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=ListBoxOption.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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,aAAa,CAAC,sBAAwB,aAAa,CAAC;QACrE;qBAEF,0DAAC,CAAA,GAAA,+BAAG;QACF,kBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL;qBAGJ,0DAAC,CAAA,GAAA,oCAAS,uBACR,0DAAC,CAAA,GAAA,sCAAW;QACV,OAAO;YACL,MAAM;gBAAC,kBAAkB,CAAA,GAAA,mDAAK,CAAC,CAAC,0BAA0B;gBAAE,GAAG,UAAU;YAAA;YACzE,MAAM;gBAAC,MAAM;gBAAK,kBAAkB,CAAA,GAAA,mDAAK,CAAC,CAAC,qBAAqB;YAAA;YAChE,QAAQ;gBAAC,MAAM;gBAAmB,kBAAkB,CAAA,GAAA,mDAAK,CAAC,CAAC,uBAAuB;YAAA;YAClF,aAAa;gBAAC,kBAAkB,CAAA,GAAA,mDAAK,CAAC,CAAC,4BAA4B;gBAAE,GAAG,gBAAgB;YAAA;QAC1F;OACC,UACA,4BACC,0DAAC,CAAA,GAAA,+DAAc;QACb,MAAK;QACL,kBACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL;;AAUtB","sources":["packages/@react-spectrum/listbox/src/ListBoxOption.tsx"],"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 CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium';\nimport {classNames, ClearSlots, SlotProvider} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {Grid} from '@react-spectrum/layout';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {ListBoxContext} from './ListBoxContext';\nimport {mergeProps} from '@react-aria/utils';\nimport {Node} from '@react-types/shared';\nimport React, {useContext, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {Text} from '@react-spectrum/text';\nimport {useOption} from '@react-aria/listbox';\n\ninterface OptionProps<T> {\n item: Node<T>\n}\n\n/** @private */\nexport function ListBoxOption<T>(props: OptionProps<T>) {\n let {item} = props;\n\n let {\n rendered,\n key\n } = item;\n let ElementType: React.ElementType = item.props.href ? 'a' : 'div';\n let {state, shouldFocusOnHover, shouldUseVirtualFocus} = useContext(ListBoxContext);\n\n let ref = useRef<any>(undefined);\n let {optionProps, labelProps, descriptionProps, isSelected, isDisabled, isFocused} = useOption(\n {\n 'aria-label': item['aria-label'],\n key,\n isVirtualized: true\n },\n state,\n ref\n );\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled\n });\n\n let contents = typeof rendered === 'string'\n ? <Text>{rendered}</Text>\n : rendered;\n\n let isKeyboardModality = isFocusVisible();\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <ElementType\n {...mergeProps(optionProps, shouldFocusOnHover ? {} : hoverProps)}\n ref={ref}\n className={classNames(\n styles,\n 'spectrum-Menu-item',\n {\n // If using virtual focus, apply focused styles to the item when the user is interacting with keyboard modality\n 'is-focused': shouldUseVirtualFocus && isFocused && isKeyboardModality,\n 'is-disabled': isDisabled,\n 'is-selected': isSelected,\n 'is-selectable': state.selectionManager.selectionMode !== 'none',\n // When shouldFocusOnHover is false, apply hover styles both when hovered with the mouse.\n // Otherwise, apply hover styles when focused using non-keyboard modality.\n 'is-hovered': (isHovered && !shouldFocusOnHover) || (isFocused && !isKeyboardModality)\n }\n )}>\n <Grid\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Menu-itemGrid'\n )\n }>\n <ClearSlots>\n <SlotProvider\n slots={{\n text: {UNSAFE_className: styles['spectrum-Menu-itemLabel'], ...labelProps},\n icon: {size: 'S', UNSAFE_className: styles['spectrum-Menu-icon']},\n avatar: {size: 'avatar-size-100', UNSAFE_className: styles['spectrum-Menu-avatar']},\n description: {UNSAFE_className: styles['spectrum-Menu-description'], ...descriptionProps}\n }}>\n {contents}\n {isSelected &&\n <CheckmarkMedium\n slot=\"checkmark\"\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Menu-checkmark'\n )\n } />\n }\n </SlotProvider>\n </ClearSlots>\n </Grid>\n </ElementType>\n </FocusRing>\n );\n}\n"],"names":[],"version":3,"file":"ListBoxOption.main.js.map"}
|