@react-spectrum/listbox 3.12.10-nightly.4673 → 3.12.10-nightly.4681
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/dist/ListBox.main.js +1 -1
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +1 -1
- package/dist/ListBox.module.js +1 -1
- package/dist/ListBox.module.js.map +1 -1
- package/dist/ListBoxBase.main.js +5 -12
- package/dist/ListBoxBase.main.js.map +1 -1
- package/dist/ListBoxBase.mjs +6 -13
- package/dist/ListBoxBase.module.js +6 -13
- package/dist/ListBoxBase.module.js.map +1 -1
- package/dist/ListBoxOption.main.js +1 -1
- package/dist/ListBoxOption.main.js.map +1 -1
- package/dist/ListBoxOption.mjs +1 -1
- package/dist/ListBoxOption.module.js +1 -1
- package/dist/ListBoxOption.module.js.map +1 -1
- package/dist/ListBoxSection.main.js +1 -1
- package/dist/ListBoxSection.main.js.map +1 -1
- package/dist/ListBoxSection.mjs +1 -1
- package/dist/ListBoxSection.module.js +1 -1
- package/dist/ListBoxSection.module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/ListBox.tsx +1 -1
- package/src/ListBoxBase.tsx +9 -12
- package/src/ListBoxOption.tsx +1 -1
- package/src/ListBoxSection.tsx +1 -1
package/dist/ListBox.main.js
CHANGED
|
@@ -29,7 +29,7 @@ $parcel$export(module.exports, "ListBox", () => $582d86e45be55635$export$41f1335
|
|
|
29
29
|
|
|
30
30
|
function $582d86e45be55635$var$ListBox(props, ref) {
|
|
31
31
|
let state = (0, $kvNjb$reactstatelylist.useListState)(props);
|
|
32
|
-
let layout = (0, $60eb4b34c53310cb$exports.useListBoxLayout)(
|
|
32
|
+
let layout = (0, $60eb4b34c53310cb$exports.useListBoxLayout)();
|
|
33
33
|
let domRef = (0, $kvNjb$reactspectrumutils.useDOMRef)(ref);
|
|
34
34
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($kvNjb$react))).createElement((0, $60eb4b34c53310cb$exports.ListBoxBase), {
|
|
35
35
|
...props,
|
package/dist/ListBox.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AASD,SAAS,8BAA0B,KAA8B,EAAE,GAA2B;IAC5F,IAAI,QAAQ,CAAA,GAAA,oCAAW,EAAE;IACzB,IAAI,SAAS,CAAA,GAAA,0CAAe
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AASD,SAAS,8BAA0B,KAA8B,EAAE,GAA2B;IAC5F,IAAI,QAAQ,CAAA,GAAA,oCAAW,EAAE;IACzB,IAAI,SAAS,CAAA,GAAA,0CAAe;IAC5B,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IAEvB,qBACE,0DAAC,CAAA,GAAA,qCAAU;QACR,GAAG,KAAK;QACT,KAAK;QACL,OAAO;QACP,QAAQ;;AAEd;AAEA,wFAAwF;AACxF,2GAA2G;AAG3G;;CAEC,GACD,MAAM,0DAAW,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/listbox/src/ListBox.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 {DOMRef} from '@react-types/shared';\nimport {ListBoxBase, useListBoxLayout} from './ListBoxBase';\nimport React, {ReactElement} from 'react';\nimport {SpectrumListBoxProps} from '@react-types/listbox';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useListState} from '@react-stately/list';\n\nfunction ListBox<T extends object>(props: SpectrumListBoxProps<T>, ref: DOMRef<HTMLDivElement>) {\n let state = useListState(props);\n let layout = useListBoxLayout();\n let domRef = useDOMRef(ref);\n\n return (\n <ListBoxBase\n {...props}\n ref={domRef}\n state={state}\n layout={layout} />\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\n\n\n/**\n * A list of options that can allow selection of one or more.\n */\nconst _ListBox = React.forwardRef(ListBox) as <T>(props: SpectrumListBoxProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_ListBox as ListBox};\n"],"names":[],"version":3,"file":"ListBox.main.js.map"}
|
package/dist/ListBox.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {useListState as $7rJGh$useListState} from "@react-stately/list";
|
|
|
19
19
|
|
|
20
20
|
function $3136257018b1a220$var$ListBox(props, ref) {
|
|
21
21
|
let state = (0, $7rJGh$useListState)(props);
|
|
22
|
-
let layout = (0, $3247d4a89e6094e9$export$25768ea656ae32a7)(
|
|
22
|
+
let layout = (0, $3247d4a89e6094e9$export$25768ea656ae32a7)();
|
|
23
23
|
let domRef = (0, $7rJGh$useDOMRef)(ref);
|
|
24
24
|
return /*#__PURE__*/ (0, $7rJGh$react).createElement((0, $3247d4a89e6094e9$export$1afdcf349979fb7e), {
|
|
25
25
|
...props,
|
package/dist/ListBox.module.js
CHANGED
|
@@ -19,7 +19,7 @@ import {useListState as $7rJGh$useListState} from "@react-stately/list";
|
|
|
19
19
|
|
|
20
20
|
function $3136257018b1a220$var$ListBox(props, ref) {
|
|
21
21
|
let state = (0, $7rJGh$useListState)(props);
|
|
22
|
-
let layout = (0, $3247d4a89e6094e9$export$25768ea656ae32a7)(
|
|
22
|
+
let layout = (0, $3247d4a89e6094e9$export$25768ea656ae32a7)();
|
|
23
23
|
let domRef = (0, $7rJGh$useDOMRef)(ref);
|
|
24
24
|
return /*#__PURE__*/ (0, $7rJGh$react).createElement((0, $3247d4a89e6094e9$export$1afdcf349979fb7e), {
|
|
25
25
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AASD,SAAS,8BAA0B,KAA8B,EAAE,GAA2B;IAC5F,IAAI,QAAQ,CAAA,GAAA,mBAAW,EAAE;IACzB,IAAI,SAAS,CAAA,GAAA,yCAAe
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AASD,SAAS,8BAA0B,KAA8B,EAAE,GAA2B;IAC5F,IAAI,QAAQ,CAAA,GAAA,mBAAW,EAAE;IACzB,IAAI,SAAS,CAAA,GAAA,yCAAe;IAC5B,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,qBACE,gCAAC,CAAA,GAAA,yCAAU;QACR,GAAG,KAAK;QACT,KAAK;QACL,OAAO;QACP,QAAQ;;AAEd;AAEA,wFAAwF;AACxF,2GAA2G;AAG3G;;CAEC,GACD,MAAM,0DAAW,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/listbox/src/ListBox.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 {DOMRef} from '@react-types/shared';\nimport {ListBoxBase, useListBoxLayout} from './ListBoxBase';\nimport React, {ReactElement} from 'react';\nimport {SpectrumListBoxProps} from '@react-types/listbox';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useListState} from '@react-stately/list';\n\nfunction ListBox<T extends object>(props: SpectrumListBoxProps<T>, ref: DOMRef<HTMLDivElement>) {\n let state = useListState(props);\n let layout = useListBoxLayout();\n let domRef = useDOMRef(ref);\n\n return (\n <ListBoxBase\n {...props}\n ref={domRef}\n state={state}\n layout={layout} />\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\n\n\n/**\n * A list of options that can allow selection of one or more.\n */\nconst _ListBox = React.forwardRef(ListBox) as <T>(props: SpectrumListBoxProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_ListBox as ListBox};\n"],"names":[],"version":3,"file":"ListBox.module.js.map"}
|
package/dist/ListBoxBase.main.js
CHANGED
|
@@ -51,33 +51,26 @@ $parcel$export(module.exports, "ListBoxBase", () => $60eb4b34c53310cb$export$1af
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
function $60eb4b34c53310cb$export$25768ea656ae32a7(
|
|
54
|
+
function $60eb4b34c53310cb$export$25768ea656ae32a7() {
|
|
55
55
|
let { scale: scale } = (0, $7w19U$reactspectrumprovider.useProvider)();
|
|
56
|
-
let collator = (0, $7w19U$reactariai18n.useCollator)({
|
|
57
|
-
usage: 'search',
|
|
58
|
-
sensitivity: 'base'
|
|
59
|
-
});
|
|
60
56
|
let layout = (0, $7w19U$react.useMemo)(()=>new (0, $7w19U$reactstatelylayout.ListLayout)({
|
|
61
57
|
estimatedRowHeight: scale === 'large' ? 48 : 32,
|
|
62
58
|
estimatedHeadingHeight: scale === 'large' ? 33 : 26,
|
|
63
59
|
padding: scale === 'large' ? 5 : 4,
|
|
64
60
|
loaderHeight: 40,
|
|
65
61
|
placeholderHeight: scale === 'large' ? 48 : 32,
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
forceSectionHeaders: true,
|
|
63
|
+
enableEmptyState: true
|
|
68
64
|
}), [
|
|
69
|
-
collator,
|
|
70
65
|
scale
|
|
71
66
|
]);
|
|
72
|
-
layout.collection = state.collection;
|
|
73
|
-
layout.disabledKeys = state.disabledKeys;
|
|
74
67
|
return layout;
|
|
75
68
|
}
|
|
76
69
|
/** @private */ function $60eb4b34c53310cb$var$ListBoxBase(props, ref) {
|
|
77
70
|
let { layout: layout, state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus, domProps: domProps = {}, isLoading: isLoading, showLoadingSpinner: showLoadingSpinner = isLoading, onScroll: onScroll, renderEmptyState: renderEmptyState } = props;
|
|
78
71
|
let { listBoxProps: listBoxProps } = (0, $7w19U$reactarialistbox.useListBox)({
|
|
79
72
|
...props,
|
|
80
|
-
|
|
73
|
+
layoutDelegate: layout,
|
|
81
74
|
isVirtualized: true
|
|
82
75
|
}, state, ref);
|
|
83
76
|
let { styleProps: styleProps } = (0, $7w19U$reactspectrumutils.useStyleProps)(props);
|
|
@@ -109,7 +102,7 @@ function $60eb4b34c53310cb$export$25768ea656ae32a7(state) {
|
|
|
109
102
|
...(0, $7w19U$reactariautils.mergeProps)(listBoxProps, domProps),
|
|
110
103
|
ref: ref,
|
|
111
104
|
focusedKey: state.selectionManager.focusedKey,
|
|
112
|
-
autoFocus: !!props.autoFocus,
|
|
105
|
+
autoFocus: !!props.autoFocus || undefined,
|
|
113
106
|
sizeToFit: "height",
|
|
114
107
|
scrollDirection: "vertical",
|
|
115
108
|
className: (0, $7w19U$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu', styleProps.className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS,0CAAoB,KAAmB;IACrD,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,wCAAU;IACxB,IAAI,WAAW,CAAA,GAAA,gCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,SA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;kBACjE,0DAAC;QAAI,MAAK;QAAS,OAAO;YAAC,SAAS;YAAQ,YAAY;YAAU,gBAAgB;YAAU,QAAQ;QAAM;qBACxG,0DAAC,CAAA,GAAA,2CAAa;QACZ,iBAAA;QACA,MAAK;QACL,cAAY,MAAM,UAAU,CAAC,IAAI,GAAG,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,gBAAgB,MAAM,CAAC;QACvG,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;AAG7C;AAEA,SAAS;IACP,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IACjD,IAAI,aAAa,mBAAmB,qBAAqB;IACzD,IAAI,cAAc,MAChB,OAAO;IAGT,qBACE,0DAAC;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, 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 {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListLayout} from '@react-stately/layout';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useContext, useMemo} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useCollator, 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: ListLayout<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>(state: ListState<T>): ListLayout<T> {\n let {scale} = useProvider();\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let layout = useMemo(() =>\n new ListLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n loaderHeight: 40,\n placeholderHeight: scale === 'large' ? 48 : 32,\n collator,\n forceSectionHeaders: true\n })\n , [collator, scale]);\n\n layout.collection = state.collection;\n layout.disabledKeys = state.disabledKeys;\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n keyboardDelegate: 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 return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n focusedKey={state.selectionManager.focusedKey}\n autoFocus={!!props.autoFocus}\n sizeToFit=\"height\"\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>}) => 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.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS;IACd,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,wCAAU;IACxB,IAAI,SAAS,CAAA,GAAA,oBAAM,EAAE,IACnB,IAAI,CAAA,GAAA,oCAAS,EAAK;YAChB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wBAAwB,UAAU,UAAU,KAAK;YACjD,SAAS,UAAU,UAAU,IAAI;YACjC,cAAc;YACd,mBAAmB,UAAU,UAAU,KAAK;YAC5C,qBAAqB;YACrB,kBAAkB;QACpB,IACA;QAAC;KAAM;IAET,OAAO;AACT;AA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AAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IACjD,IAAI,aAAa,mBAAmB,qBAAqB;IACzD,IAAI,cAAc,MAChB,OAAO;IAGT,qBACE,0DAAC;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, 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 {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListLayout} from '@react-stately/layout';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, RefObject, 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: ListLayout<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>(): ListLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n loaderHeight: 40,\n placeholderHeight: scale === 'large' ? 48 : 32,\n forceSectionHeaders: true,\n enableEmptyState: true\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 return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n focusedKey={state.selectionManager.focusedKey}\n autoFocus={!!props.autoFocus || undefined}\n sizeToFit=\"height\"\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.main.js.map"}
|
package/dist/ListBoxBase.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {ListLayout as $gF3QK$ListLayout} from "@react-stately/layout";
|
|
|
11
11
|
import {mergeProps as $gF3QK$mergeProps} from "@react-aria/utils";
|
|
12
12
|
import {ProgressCircle as $gF3QK$ProgressCircle} from "@react-spectrum/progress";
|
|
13
13
|
import $gF3QK$react, {useMemo as $gF3QK$useMemo, useCallback as $gF3QK$useCallback, useContext as $gF3QK$useContext} from "react";
|
|
14
|
-
import {
|
|
14
|
+
import {useLocalizedStringFormatter as $gF3QK$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
15
15
|
import {useProvider as $gF3QK$useProvider} from "@react-spectrum/provider";
|
|
16
16
|
import {VirtualizerItem as $gF3QK$VirtualizerItem, Virtualizer as $gF3QK$Virtualizer} from "@react-aria/virtualizer";
|
|
17
17
|
|
|
@@ -44,33 +44,26 @@ function $parcel$interopDefault(a) {
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
function $3247d4a89e6094e9$export$25768ea656ae32a7(
|
|
47
|
+
function $3247d4a89e6094e9$export$25768ea656ae32a7() {
|
|
48
48
|
let { scale: scale } = (0, $gF3QK$useProvider)();
|
|
49
|
-
let collator = (0, $gF3QK$useCollator)({
|
|
50
|
-
usage: 'search',
|
|
51
|
-
sensitivity: 'base'
|
|
52
|
-
});
|
|
53
49
|
let layout = (0, $gF3QK$useMemo)(()=>new (0, $gF3QK$ListLayout)({
|
|
54
50
|
estimatedRowHeight: scale === 'large' ? 48 : 32,
|
|
55
51
|
estimatedHeadingHeight: scale === 'large' ? 33 : 26,
|
|
56
52
|
padding: scale === 'large' ? 5 : 4,
|
|
57
53
|
loaderHeight: 40,
|
|
58
54
|
placeholderHeight: scale === 'large' ? 48 : 32,
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
forceSectionHeaders: true,
|
|
56
|
+
enableEmptyState: true
|
|
61
57
|
}), [
|
|
62
|
-
collator,
|
|
63
58
|
scale
|
|
64
59
|
]);
|
|
65
|
-
layout.collection = state.collection;
|
|
66
|
-
layout.disabledKeys = state.disabledKeys;
|
|
67
60
|
return layout;
|
|
68
61
|
}
|
|
69
62
|
/** @private */ function $3247d4a89e6094e9$var$ListBoxBase(props, ref) {
|
|
70
63
|
let { layout: layout, state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus, domProps: domProps = {}, isLoading: isLoading, showLoadingSpinner: showLoadingSpinner = isLoading, onScroll: onScroll, renderEmptyState: renderEmptyState } = props;
|
|
71
64
|
let { listBoxProps: listBoxProps } = (0, $gF3QK$useListBox)({
|
|
72
65
|
...props,
|
|
73
|
-
|
|
66
|
+
layoutDelegate: layout,
|
|
74
67
|
isVirtualized: true
|
|
75
68
|
}, state, ref);
|
|
76
69
|
let { styleProps: styleProps } = (0, $gF3QK$useStyleProps)(props);
|
|
@@ -102,7 +95,7 @@ function $3247d4a89e6094e9$export$25768ea656ae32a7(state) {
|
|
|
102
95
|
...(0, $gF3QK$mergeProps)(listBoxProps, domProps),
|
|
103
96
|
ref: ref,
|
|
104
97
|
focusedKey: state.selectionManager.focusedKey,
|
|
105
|
-
autoFocus: !!props.autoFocus,
|
|
98
|
+
autoFocus: !!props.autoFocus || undefined,
|
|
106
99
|
sizeToFit: "height",
|
|
107
100
|
scrollDirection: "vertical",
|
|
108
101
|
className: (0, $gF3QK$classNames)((0, ($parcel$interopDefault($gF3QK$menu_vars_cssmodulejs))), 'spectrum-Menu', styleProps.className),
|
|
@@ -11,7 +11,7 @@ import {ListLayout as $gF3QK$ListLayout} from "@react-stately/layout";
|
|
|
11
11
|
import {mergeProps as $gF3QK$mergeProps} from "@react-aria/utils";
|
|
12
12
|
import {ProgressCircle as $gF3QK$ProgressCircle} from "@react-spectrum/progress";
|
|
13
13
|
import $gF3QK$react, {useMemo as $gF3QK$useMemo, useCallback as $gF3QK$useCallback, useContext as $gF3QK$useContext} from "react";
|
|
14
|
-
import {
|
|
14
|
+
import {useLocalizedStringFormatter as $gF3QK$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
15
15
|
import {useProvider as $gF3QK$useProvider} from "@react-spectrum/provider";
|
|
16
16
|
import {VirtualizerItem as $gF3QK$VirtualizerItem, Virtualizer as $gF3QK$Virtualizer} from "@react-aria/virtualizer";
|
|
17
17
|
|
|
@@ -44,33 +44,26 @@ function $parcel$interopDefault(a) {
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
function $3247d4a89e6094e9$export$25768ea656ae32a7(
|
|
47
|
+
function $3247d4a89e6094e9$export$25768ea656ae32a7() {
|
|
48
48
|
let { scale: scale } = (0, $gF3QK$useProvider)();
|
|
49
|
-
let collator = (0, $gF3QK$useCollator)({
|
|
50
|
-
usage: 'search',
|
|
51
|
-
sensitivity: 'base'
|
|
52
|
-
});
|
|
53
49
|
let layout = (0, $gF3QK$useMemo)(()=>new (0, $gF3QK$ListLayout)({
|
|
54
50
|
estimatedRowHeight: scale === 'large' ? 48 : 32,
|
|
55
51
|
estimatedHeadingHeight: scale === 'large' ? 33 : 26,
|
|
56
52
|
padding: scale === 'large' ? 5 : 4,
|
|
57
53
|
loaderHeight: 40,
|
|
58
54
|
placeholderHeight: scale === 'large' ? 48 : 32,
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
forceSectionHeaders: true,
|
|
56
|
+
enableEmptyState: true
|
|
61
57
|
}), [
|
|
62
|
-
collator,
|
|
63
58
|
scale
|
|
64
59
|
]);
|
|
65
|
-
layout.collection = state.collection;
|
|
66
|
-
layout.disabledKeys = state.disabledKeys;
|
|
67
60
|
return layout;
|
|
68
61
|
}
|
|
69
62
|
/** @private */ function $3247d4a89e6094e9$var$ListBoxBase(props, ref) {
|
|
70
63
|
let { layout: layout, state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus, domProps: domProps = {}, isLoading: isLoading, showLoadingSpinner: showLoadingSpinner = isLoading, onScroll: onScroll, renderEmptyState: renderEmptyState } = props;
|
|
71
64
|
let { listBoxProps: listBoxProps } = (0, $gF3QK$useListBox)({
|
|
72
65
|
...props,
|
|
73
|
-
|
|
66
|
+
layoutDelegate: layout,
|
|
74
67
|
isVirtualized: true
|
|
75
68
|
}, state, ref);
|
|
76
69
|
let { styleProps: styleProps } = (0, $gF3QK$useStyleProps)(props);
|
|
@@ -102,7 +95,7 @@ function $3247d4a89e6094e9$export$25768ea656ae32a7(state) {
|
|
|
102
95
|
...(0, $gF3QK$mergeProps)(listBoxProps, domProps),
|
|
103
96
|
ref: ref,
|
|
104
97
|
focusedKey: state.selectionManager.focusedKey,
|
|
105
|
-
autoFocus: !!props.autoFocus,
|
|
98
|
+
autoFocus: !!props.autoFocus || undefined,
|
|
106
99
|
sizeToFit: "height",
|
|
107
100
|
scrollDirection: "vertical",
|
|
108
101
|
className: (0, $gF3QK$classNames)((0, ($parcel$interopDefault($gF3QK$menu_vars_cssmodulejs))), 'spectrum-Menu', styleProps.className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS,0CAAoB,KAAmB;IACrD,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;I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E;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, 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 {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListLayout} from '@react-stately/layout';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useContext, useMemo} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useCollator, 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: ListLayout<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>(state: ListState<T>): ListLayout<T> {\n let {scale} = useProvider();\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let layout = useMemo(() =>\n new ListLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n loaderHeight: 40,\n placeholderHeight: scale === 'large' ? 48 : 32,\n collator,\n forceSectionHeaders: true\n })\n , [collator, scale]);\n\n layout.collection = state.collection;\n layout.disabledKeys = state.disabledKeys;\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n keyboardDelegate: 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 return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n focusedKey={state.selectionManager.focusedKey}\n autoFocus={!!props.autoFocus}\n sizeToFit=\"height\"\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>}) => 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"}
|
|
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,iBAAS,EAAK;YAChB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wBAAwB,UAAU,UAAU,KAAK;YACjD,SAAS,UAAU,UAAU,IAAI;YACjC,cAAc;YACd,mBAAmB,UAAU,UAAU,KAAK;YAC5C,qBAAqB;YACrB,kBAAkB;QACpB,IACA;QAAC;KAAM;IAET,OAAO;A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P,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, 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 {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListLayout} from '@react-stately/layout';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, RefObject, 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: ListLayout<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>(): ListLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n loaderHeight: 40,\n placeholderHeight: scale === 'large' ? 48 : 32,\n forceSectionHeaders: true,\n enableEmptyState: true\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 return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n focusedKey={state.selectionManager.focusedKey}\n autoFocus={!!props.autoFocus || undefined}\n sizeToFit=\"height\"\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"}
|
|
@@ -47,7 +47,7 @@ function $2205d250ee1cb1ac$export$feb3b6b552c14a12(props) {
|
|
|
47
47
|
let { rendered: rendered, key: key } = item;
|
|
48
48
|
let ElementType = item.props.href ? 'a' : 'div';
|
|
49
49
|
let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $8xmxv$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
|
|
50
|
-
let ref = (0, $8xmxv$react.useRef)();
|
|
50
|
+
let ref = (0, $8xmxv$react.useRef)(undefined);
|
|
51
51
|
let { optionProps: optionProps, labelProps: labelProps, descriptionProps: descriptionProps, isSelected: isSelected, isDisabled: isDisabled, isFocused: isFocused } = (0, $8xmxv$reactarialistbox.useOption)({
|
|
52
52
|
'aria-label': item['aria-label'],
|
|
53
53
|
key: key,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QAAC,IAAI,EAAC,GAAG;IAEb,IAAI,YACF,QAAQ,OACR,GAAG,EACJ,GAAG;IACJ,IAAI,cAAiC,KAAK,KAAK,CAAC,IAAI,GAAG,MAAM;IAC7D,IAAI,SAAC,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,EAAC,GAAG,CAAA,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AAiB,MAAM,gBAAgB,CAAC,aAAa,KAAK;YAC1D,yFAAyF;YACzF,0EAA0E;YAC1E,cAAc,AAAC,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"}
|
package/dist/ListBoxOption.mjs
CHANGED
|
@@ -41,7 +41,7 @@ function $86983ea1fa3f7312$export$feb3b6b552c14a12(props) {
|
|
|
41
41
|
let { rendered: rendered, key: key } = item;
|
|
42
42
|
let ElementType = item.props.href ? 'a' : 'div';
|
|
43
43
|
let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
|
|
44
|
-
let ref = (0, $6TrMC$useRef)();
|
|
44
|
+
let ref = (0, $6TrMC$useRef)(undefined);
|
|
45
45
|
let { optionProps: optionProps, labelProps: labelProps, descriptionProps: descriptionProps, isSelected: isSelected, isDisabled: isDisabled, isFocused: isFocused } = (0, $6TrMC$useOption)({
|
|
46
46
|
'aria-label': item['aria-label'],
|
|
47
47
|
key: key,
|
|
@@ -41,7 +41,7 @@ function $86983ea1fa3f7312$export$feb3b6b552c14a12(props) {
|
|
|
41
41
|
let { rendered: rendered, key: key } = item;
|
|
42
42
|
let ElementType = item.props.href ? 'a' : 'div';
|
|
43
43
|
let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
|
|
44
|
-
let ref = (0, $6TrMC$useRef)();
|
|
44
|
+
let ref = (0, $6TrMC$useRef)(undefined);
|
|
45
45
|
let { optionProps: optionProps, labelProps: labelProps, descriptionProps: descriptionProps, isSelected: isSelected, isDisabled: isDisabled, isFocused: isFocused } = (0, $6TrMC$useOption)({
|
|
46
46
|
'aria-label': item['aria-label'],
|
|
47
47
|
key: key,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QAAC,IAAI,EAAC,GAAG;IAEb,IAAI,YACF,QAAQ,OACR,GAAG,EACJ,GAAG;IACJ,IAAI,cAAiC,KAAK,KAAK,CAAC,IAAI,GAAG,MAAM;IAC7D,IAAI,SAAC,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IAEjF,IAAI,MAAM,CAAA,GAAA,aAAK;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QAAC,IAAI,EAAC,GAAG;IAEb,IAAI,YACF,QAAQ,OACR,GAAG,EACJ,GAAG;IACJ,IAAI,cAAiC,KAAK,KAAK,CAAC,IAAI,GAAG,MAAM;IAC7D,IAAI,SAAC,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IAEjF,IAAI,MAAM,CAAA,GAAA,aAAK,EAAO;IACtB,IAAI,eAAC,WAAW,cAAE,UAAU,oBAAE,gBAAgB,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAC3F;QACE,cAAc,IAAI,CAAC,aAAa;aAChC;QACA,eAAe;IACjB,G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C,UACA,4BACC,gCAAC,CAAA,GAAA,qCAAc;QACb,MAAK;QACL,kBACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,sDAAK,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.module.js.map"}
|
|
@@ -40,7 +40,7 @@ function $0f5fd8483f48ef09$export$dca12b0bb56e4fc(props) {
|
|
|
40
40
|
heading: item.rendered,
|
|
41
41
|
'aria-label': item['aria-label']
|
|
42
42
|
});
|
|
43
|
-
let headerRef = (0, $cCu2p$react.useRef)();
|
|
43
|
+
let headerRef = (0, $cCu2p$react.useRef)(undefined);
|
|
44
44
|
(0, $cCu2p$re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oBACxC,0DAAC;QACC,MAAK;QACL,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAK,GACL;QAGL,KAAK,QAAQ,kBACZ,0DAAC;QACE,GAAG,YAAY;QAChB,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL;OAGH,KAAK,QAAQ,kBAIpB,0DAAC;QACE,GAAG,UAAU;QACd,OAAO,CAAA,GAAA,6CAAgB,EAAE,YAAY;QACrC,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,mDAAK,GACL;OAGH;AAIT","sources":["packages/@react-spectrum/listbox/src/ListBoxSection.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 {classNames} from '@react-spectrum/utils';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport {layoutInfoToStyle, useVirtualizerItem, VirtualizerItemOptions} from '@react-aria/virtualizer';\nimport {ListBoxContext} from './ListBoxContext';\nimport {Node} from '@react-types/shared';\nimport React, {Fragment, ReactNode, useContext, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useListBoxSection} from '@react-aria/listbox';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ListBoxSectionProps<T> extends Omit<VirtualizerItemOptions, 'ref'> {\n headerLayoutInfo: LayoutInfo,\n item: Node<T>,\n children?: ReactNode\n}\n\n/** @private */\nexport function ListBoxSection<T>(props: ListBoxSectionProps<T>) {\n let {children, layoutInfo, headerLayoutInfo, virtualizer, item} = props;\n let {headingProps, groupProps} = useListBoxSection({\n heading: item.rendered,\n 'aria-label': item['aria-label']\n });\n\n let headerRef = useRef(undefined);\n useVirtualizerItem({\n layoutInfo: headerLayoutInfo,\n virtualizer,\n ref: headerRef\n });\n\n let {direction} = useLocale();\n let {state} = useContext(ListBoxContext);\n\n return (\n <Fragment>\n {headerLayoutInfo && <div role=\"presentation\" ref={headerRef} style={layoutInfoToStyle(headerLayoutInfo, direction)}>\n {item.key !== state.collection.getFirstKey() &&\n <div\n role=\"presentation\"\n className={classNames(\n styles,\n 'spectrum-Menu-divider'\n )} />\n }\n {item.rendered &&\n <div\n {...headingProps}\n className={\n classNames(\n styles,\n 'spectrum-Menu-sectionHeading'\n )\n }>\n {item.rendered}\n </div>\n }\n </div>}\n <div\n {...groupProps}\n style={layoutInfoToStyle(layoutInfo, direction)}\n className={\n classNames(\n styles,\n 'spectrum-Menu'\n )\n }>\n {children}\n </div>\n </Fragment>\n );\n}\n"],"names":[],"version":3,"file":"ListBoxSection.main.js.map"}
|
package/dist/ListBoxSection.mjs
CHANGED
|
@@ -34,7 +34,7 @@ function $92d678ed88836094$export$dca12b0bb56e4fc(props) {
|
|
|
34
34
|
heading: item.rendered,
|
|
35
35
|
'aria-label': item['aria-label']
|
|
36
36
|
});
|
|
37
|
-
let headerRef = (0, $dzUX8$useRef)();
|
|
37
|
+
let headerRef = (0, $dzUX8$useRef)(undefined);
|
|
38
38
|
(0, $dzUX8$useVirtualizerItem)({
|
|
39
39
|
layoutInfo: headerLayoutInfo,
|
|
40
40
|
virtualizer: virtualizer,
|
|
@@ -34,7 +34,7 @@ function $92d678ed88836094$export$dca12b0bb56e4fc(props) {
|
|
|
34
34
|
heading: item.rendered,
|
|
35
35
|
'aria-label': item['aria-label']
|
|
36
36
|
});
|
|
37
|
-
let headerRef = (0, $dzUX8$useRef)();
|
|
37
|
+
let headerRef = (0, $dzUX8$useRef)(undefined);
|
|
38
38
|
(0, $dzUX8$useVirtualizerItem)({
|
|
39
39
|
layoutInfo: headerLayoutInfo,
|
|
40
40
|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GL,KAAK,QAAQ,kBACZ,gCAAC;QACE,GAAG,YAAY;QAChB,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,sDAAK,GACL;OAGH,KAAK,QAAQ,kBAIpB,gCAAC;QACE,GAAG,UAAU;QACd,OAAO,CAAA,GAAA,wBAAgB,EAAE,YAAY;QACrC,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,sDAAK,GACL;OAGH;AAIT","sources":["packages/@react-spectrum/listbox/src/ListBoxSection.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 {classNames} from '@react-spectrum/utils';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport {layoutInfoToStyle, useVirtualizerItem, VirtualizerItemOptions} from '@react-aria/virtualizer';\nimport {ListBoxContext} from './ListBoxContext';\nimport {Node} from '@react-types/shared';\nimport React, {Fragment, ReactNode, useContext, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useListBoxSection} from '@react-aria/listbox';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ListBoxSectionProps<T> extends Omit<VirtualizerItemOptions, 'ref'> {\n headerLayoutInfo: LayoutInfo,\n item: Node<T>,\n children?: ReactNode\n}\n\n/** @private */\nexport function ListBoxSection<T>(props: ListBoxSectionProps<T>) {\n let {children, layoutInfo, headerLayoutInfo, virtualizer, item} = props;\n let {headingProps, groupProps} = useListBoxSection({\n heading: item.rendered,\n 'aria-label': item['aria-label']\n });\n\n let headerRef = useRef(undefined);\n useVirtualizerItem({\n layoutInfo: headerLayoutInfo,\n virtualizer,\n ref: headerRef\n });\n\n let {direction} = useLocale();\n let {state} = useContext(ListBoxContext);\n\n return (\n <Fragment>\n {headerLayoutInfo && <div role=\"presentation\" ref={headerRef} style={layoutInfoToStyle(headerLayoutInfo, direction)}>\n {item.key !== state.collection.getFirstKey() &&\n <div\n role=\"presentation\"\n className={classNames(\n styles,\n 'spectrum-Menu-divider'\n )} />\n }\n {item.rendered &&\n <div\n {...headingProps}\n className={\n classNames(\n styles,\n 'spectrum-Menu-sectionHeading'\n )\n }>\n {item.rendered}\n </div>\n }\n </div>}\n <div\n {...groupProps}\n style={layoutInfoToStyle(layoutInfo, direction)}\n className={\n classNames(\n styles,\n 'spectrum-Menu'\n )\n }>\n {children}\n </div>\n </Fragment>\n );\n}\n"],"names":[],"version":3,"file":"ListBoxSection.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
|
|
|
21
21
|
onScroll?: () => void;
|
|
22
22
|
}
|
|
23
23
|
/** @private */
|
|
24
|
-
export function useListBoxLayout<T>(
|
|
24
|
+
export function useListBoxLayout<T>(): ListLayout<T>;
|
|
25
25
|
export const ListBoxBase: <T>(props: ListBoxBaseProps<T> & {
|
|
26
|
-
ref?: RefObject<HTMLDivElement>;
|
|
26
|
+
ref?: RefObject<HTMLDivElement | null>;
|
|
27
27
|
}) => ReactElement;
|
|
28
28
|
/**
|
|
29
29
|
* A list of options that can allow selection of one or more.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AGgCA,2BAA2B,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU;IAClG,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,GAAG,aAAa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AK,WAAW,CAAC,CAAC,CAenD;AAoFD,OAAA,MAAM;UAAwF,UAAU,cAAc,GAAG,IAAI,CAAC;MAAM,YAAY,CAAC;AChHjJ;;GAEG;AACH,OAAA,MAAM;UAAoF,OAAO,cAAc,CAAC;MAAM,YAAY,CAAC;ACxBnI,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,4BAA4B,CAAC;AACzD,YAAY,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBoxContext.ts","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBoxOption.tsx","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBoxSection.tsx","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBoxBase.tsx","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBox.tsx","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/index.ts","packages/@react-spectrum/listbox/src/index.ts"],"sourcesContent":[null,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\n/// <reference types=\"css-module-types\" />\n\nexport {ListBox} from './ListBox';\nexport {useListBoxLayout, ListBoxBase} from './ListBoxBase';\nexport {Item, Section} from '@react-stately/collections';\nexport type {SpectrumListBoxProps} from '@react-types/listbox';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/listbox",
|
|
3
|
-
"version": "3.12.10-nightly.
|
|
3
|
+
"version": "3.12.10-nightly.4681+2fd87d9f1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,35 +36,35 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
40
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
41
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
42
|
-
"@react-aria/listbox": "3.12.2-nightly.
|
|
43
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
44
|
-
"@react-aria/virtualizer": "3.10.2-nightly.
|
|
45
|
-
"@react-spectrum/layout": "3.6.6-nightly.
|
|
46
|
-
"@react-spectrum/progress": "3.0.0-nightly.
|
|
47
|
-
"@react-spectrum/text": "3.5.6-nightly.
|
|
48
|
-
"@react-spectrum/utils": "3.0.0-nightly.
|
|
49
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
50
|
-
"@react-stately/layout": "3.13.10-nightly.
|
|
51
|
-
"@react-stately/list": "3.10.6-nightly.
|
|
52
|
-
"@react-stately/virtualizer": "3.7.2-nightly.
|
|
53
|
-
"@react-types/listbox": "3.4.10-nightly.
|
|
54
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
55
|
-
"@spectrum-icons/ui": "3.0.0-nightly.
|
|
39
|
+
"@react-aria/focus": "3.0.0-nightly.2969+2fd87d9f1",
|
|
40
|
+
"@react-aria/i18n": "3.0.0-nightly.2969+2fd87d9f1",
|
|
41
|
+
"@react-aria/interactions": "3.0.0-nightly.2969+2fd87d9f1",
|
|
42
|
+
"@react-aria/listbox": "3.12.2-nightly.4681+2fd87d9f1",
|
|
43
|
+
"@react-aria/utils": "3.0.0-nightly.2969+2fd87d9f1",
|
|
44
|
+
"@react-aria/virtualizer": "3.10.2-nightly.4681+2fd87d9f1",
|
|
45
|
+
"@react-spectrum/layout": "3.6.6-nightly.4681+2fd87d9f1",
|
|
46
|
+
"@react-spectrum/progress": "3.0.0-nightly.2969+2fd87d9f1",
|
|
47
|
+
"@react-spectrum/text": "3.5.6-nightly.4681+2fd87d9f1",
|
|
48
|
+
"@react-spectrum/utils": "3.0.0-nightly.2969+2fd87d9f1",
|
|
49
|
+
"@react-stately/collections": "3.0.0-nightly.2969+2fd87d9f1",
|
|
50
|
+
"@react-stately/layout": "3.13.10-nightly.4681+2fd87d9f1",
|
|
51
|
+
"@react-stately/list": "3.10.6-nightly.4681+2fd87d9f1",
|
|
52
|
+
"@react-stately/virtualizer": "3.7.2-nightly.4681+2fd87d9f1",
|
|
53
|
+
"@react-types/listbox": "3.4.10-nightly.4681+2fd87d9f1",
|
|
54
|
+
"@react-types/shared": "3.0.0-nightly.2969+2fd87d9f1",
|
|
55
|
+
"@spectrum-icons/ui": "3.0.0-nightly.2969+2fd87d9f1",
|
|
56
56
|
"@swc/helpers": "^0.5.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
59
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.2969+2fd87d9f1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@react-spectrum/provider": "^3.2.0",
|
|
63
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
|
|
64
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
63
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
64
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "2fd87d9f1d894e6b00a595cce73c6e8828029132"
|
|
70
70
|
}
|
package/src/ListBox.tsx
CHANGED
|
@@ -19,7 +19,7 @@ import {useListState} from '@react-stately/list';
|
|
|
19
19
|
|
|
20
20
|
function ListBox<T extends object>(props: SpectrumListBoxProps<T>, ref: DOMRef<HTMLDivElement>) {
|
|
21
21
|
let state = useListState(props);
|
|
22
|
-
let layout = useListBoxLayout(
|
|
22
|
+
let layout = useListBoxLayout();
|
|
23
23
|
let domRef = useDOMRef(ref);
|
|
24
24
|
|
|
25
25
|
return (
|
package/src/ListBoxBase.tsx
CHANGED
|
@@ -26,7 +26,7 @@ import {ProgressCircle} from '@react-spectrum/progress';
|
|
|
26
26
|
import React, {HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useContext, useMemo} from 'react';
|
|
27
27
|
import {ReusableView} from '@react-stately/virtualizer';
|
|
28
28
|
import styles from '@adobe/spectrum-css-temp/components/menu/vars.css';
|
|
29
|
-
import {
|
|
29
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
30
30
|
import {useProvider} from '@react-spectrum/provider';
|
|
31
31
|
import {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';
|
|
32
32
|
|
|
@@ -48,9 +48,8 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** @private */
|
|
51
|
-
export function useListBoxLayout<T>(
|
|
51
|
+
export function useListBoxLayout<T>(): ListLayout<T> {
|
|
52
52
|
let {scale} = useProvider();
|
|
53
|
-
let collator = useCollator({usage: 'search', sensitivity: 'base'});
|
|
54
53
|
let layout = useMemo(() =>
|
|
55
54
|
new ListLayout<T>({
|
|
56
55
|
estimatedRowHeight: scale === 'large' ? 48 : 32,
|
|
@@ -58,22 +57,20 @@ export function useListBoxLayout<T>(state: ListState<T>): ListLayout<T> {
|
|
|
58
57
|
padding: scale === 'large' ? 5 : 4, // TODO: get from DNA
|
|
59
58
|
loaderHeight: 40,
|
|
60
59
|
placeholderHeight: scale === 'large' ? 48 : 32,
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
forceSectionHeaders: true,
|
|
61
|
+
enableEmptyState: true
|
|
63
62
|
})
|
|
64
|
-
, [
|
|
63
|
+
, [scale]);
|
|
65
64
|
|
|
66
|
-
layout.collection = state.collection;
|
|
67
|
-
layout.disabledKeys = state.disabledKeys;
|
|
68
65
|
return layout;
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
/** @private */
|
|
72
|
-
function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement>) {
|
|
69
|
+
function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {
|
|
73
70
|
let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;
|
|
74
71
|
let {listBoxProps} = useListBox({
|
|
75
72
|
...props,
|
|
76
|
-
|
|
73
|
+
layoutDelegate: layout,
|
|
77
74
|
isVirtualized: true
|
|
78
75
|
}, state, ref);
|
|
79
76
|
let {styleProps} = useStyleProps(props);
|
|
@@ -114,7 +111,7 @@ function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElemen
|
|
|
114
111
|
{...mergeProps(listBoxProps, domProps)}
|
|
115
112
|
ref={ref}
|
|
116
113
|
focusedKey={state.selectionManager.focusedKey}
|
|
117
|
-
autoFocus={!!props.autoFocus}
|
|
114
|
+
autoFocus={!!props.autoFocus || undefined}
|
|
118
115
|
sizeToFit="height"
|
|
119
116
|
scrollDirection="vertical"
|
|
120
117
|
className={
|
|
@@ -150,7 +147,7 @@ function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElemen
|
|
|
150
147
|
|
|
151
148
|
// forwardRef doesn't support generic parameters, so cast the result to the correct type
|
|
152
149
|
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
|
|
153
|
-
const _ListBoxBase = React.forwardRef(ListBoxBase) as <T>(props: ListBoxBaseProps<T> & {ref?: RefObject<HTMLDivElement>}) => ReactElement;
|
|
150
|
+
const _ListBoxBase = React.forwardRef(ListBoxBase) as <T>(props: ListBoxBaseProps<T> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;
|
|
154
151
|
export {_ListBoxBase as ListBoxBase};
|
|
155
152
|
|
|
156
153
|
function LoadingState() {
|
package/src/ListBoxOption.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export function ListBoxOption<T>(props: OptionProps<T>) {
|
|
|
38
38
|
let ElementType: React.ElementType = item.props.href ? 'a' : 'div';
|
|
39
39
|
let {state, shouldFocusOnHover, shouldUseVirtualFocus} = useContext(ListBoxContext);
|
|
40
40
|
|
|
41
|
-
let ref = useRef<any>();
|
|
41
|
+
let ref = useRef<any>(undefined);
|
|
42
42
|
let {optionProps, labelProps, descriptionProps, isSelected, isDisabled, isFocused} = useOption(
|
|
43
43
|
{
|
|
44
44
|
'aria-label': item['aria-label'],
|
package/src/ListBoxSection.tsx
CHANGED