@react-spectrum/listbox 3.12.10-nightly.4649 → 3.12.10-nightly.4654

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.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS,0CAAoB,KAAmB,EAAE,SAAkB;IACzE,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,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;sBAC5C;QACF,IACA;QAAC;QAAU;KAAM;IAEnB,OAAO,UAAU,GAAG,MAAM,UAAU;IACpC,OAAO,YAAY,GAAG,MAAM,YAAY;IAExC,CAAA,GAAA,sBAAc,EAAE;QACd,sCAAsC;QACtC,IAAI,OAAO,SAAS,KAAK,WAAW;gBAElC;YADA,OAAO,SAAS,GAAG;aACnB,sBAAA,OAAO,WAAW,cAAlB,0CAAA,oBAAoB,WAAW;QACjC;IACF,GAAG;QAAC;QAAQ;KAAU;IACtB,OAAO;AACT;AAEA,aAAa,GACb,SAAS,kCAAe,KAA0B,EAAE,GAA8B;IAChF,IAAI,UAAC,MAAM,SAAE,KAAK,yBAAE,qBAAqB,uBAAE,mBAAmB,yBAAE,qBAAqB,YAAE,WAAW,CAAC,uBAAG,qBAAqB,aAAG,QAAQ,EAAC,GAAG;IAC1I,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;QAC9B,GAAG,KAAK;QACR,kBAAkB;QAClB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;QAC5B,uBAAuB;QACvB,UAAU;OACT,CAAC,MAAM;QACN,IAAI,SAAS,QACX,qBACE,gCAAC,CAAA,GAAA,yCAAY;YACX,MAAM;YACN,uBAAuB;YACvB,oBAAoB;YACpB,uBAAuB;;aAEtB,IAAI,SAAS,UAClB,OACE,uEAAuE;QACvE,iEAAiE;sBACjE,gCAAC;YAAI,MAAK;YAAS,OAAO;gBAAC,SAAS;gBAAQ,YAAY;gBAAU,gBAAgB;gBAAU,QAAQ;YAAM;yBACxG,gCAAC,CAAA,GAAA,qBAAa;YACZ,iBAAA;YACA,MAAK;YACL,cAAY,MAAM,UAAU,CAAC,IAAI,GAAG,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,gBAAgB,MAAM,CAAC;YACvG,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;;aAGtC,IAAI,SAAS,eAAe;YACjC,IAAI,aAAa,MAAM,gBAAgB,GAAG,MAAM,gBAAgB,KAAK;YACrE,IAAI,cAAc,MAChB,OAAO;YAGT,qBACE,gCAAC;gBACC,uEAAuE;gBACvE,iEAAiE;gBACjE,MAAK;eACJ;QAGP;IACF;AAKV;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","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, useLayoutEffect} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, RefObject, 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 transitionDuration?: number,\n isLoading?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(state: ListState<T>, isLoading: boolean): 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 })\n , [collator, scale]);\n\n layout.collection = state.collection;\n layout.disabledKeys = state.disabledKeys;\n\n useLayoutEffect(() => {\n // Sync loading state into the layout.\n if (layout.isLoading !== isLoading) {\n layout.isLoading = isLoading;\n layout.virtualizer?.relayoutNow();\n }\n }, [layout, isLoading]);\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement>) {\n let {layout, state, shouldSelectOnPressUp, focusOnPointerEnter, shouldUseVirtualFocus, domProps = {}, transitionDuration = 0, onScroll} = props;\n let {listBoxProps} = useListBox({\n ...props,\n keyboardDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/listbox');\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>, ReactNode>;\n let renderWrapper = (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}>\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 collection={state.collection}\n renderWrapper={renderWrapper}\n transitionDuration={transitionDuration}\n isLoading={props.isLoading}\n onLoadMore={props.onLoadMore}\n shouldUseVirtualFocus={shouldUseVirtualFocus}\n onScroll={onScroll}>\n {(type, item: Node<T>) => {\n if (type === 'item') {\n return (\n <ListBoxOption\n item={item}\n shouldSelectOnPressUp={shouldSelectOnPressUp}\n shouldFocusOnHover={focusOnPointerEnter}\n shouldUseVirtualFocus={shouldUseVirtualFocus} />\n );\n } else if (type === 'loader') {\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 } else if (type === 'placeholder') {\n let emptyState = props.renderEmptyState ? props.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 }}\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"],"names":[],"version":3,"file":"ListBoxBase.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS,0CAAoB,KAAmB;IACrD,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACx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B,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, 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 })\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 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAiB,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAqB","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 from 'react';\n\nexport const ListBoxContext = React.createContext<ListState<unknown>>(null);\n"],"names":[],"version":3,"file":"ListBoxContext.main.js.map"}
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"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAiB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAqB","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 from 'react';\n\nexport const ListBoxContext = React.createContext<ListState<unknown>>(null);\n"],"names":[],"version":3,"file":"ListBoxContext.module.js.map"}
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"}
@@ -43,18 +43,15 @@ $parcel$export(module.exports, "ListBoxOption", () => $2205d250ee1cb1ac$export$f
43
43
 
44
44
 
45
45
  function $2205d250ee1cb1ac$export$feb3b6b552c14a12(props) {
46
- let { item: item, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
46
+ let { item: item } = props;
47
47
  let { rendered: rendered, key: key } = item;
48
48
  let ElementType = item.props.href ? 'a' : 'div';
49
- let state = (0, $8xmxv$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
49
+ let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $8xmxv$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
50
50
  let ref = (0, $8xmxv$react.useRef)();
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,
54
- shouldSelectOnPressUp: shouldSelectOnPressUp,
55
- shouldFocusOnHover: shouldFocusOnHover,
56
- isVirtualized: true,
57
- shouldUseVirtualFocus: shouldUseVirtualFocus
54
+ isVirtualized: true
58
55
  }, state, ref);
59
56
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8xmxv$reactariainteractions.useHover)({
60
57
  ...props,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QACF,IAAI,yBACJ,qBAAqB,sBACrB,kBAAkB,yBAClB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,YACF,QAAQ,OACR,GAAG,EACJ,GAAG;IACJ,IAAI,cAAiC,KAAK,KAAK,CAAC,IAAI,GAAG,MAAM;IAC7D,IAAI,QAAQ,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IAEpC,IAAI,MAAM,CAAA,GAAA,mBAAK;IACf,IAAI,eAAC,WAAW,cAAE,UAAU,oBAAE,gBAAgB,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,iCAAQ,EAC3F;QACE,cAAc,IAAI,CAAC,aAAa;aAChC;+BACA;4BACA;QACA,eAAe;+BACf;IACF,GACA,OACA;IAEF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QACrC,GAAG,KAAK;oBACR;IACF;IAEA,IA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B","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 shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean\n}\n\n/** @private */\nexport function ListBoxOption<T>(props: OptionProps<T>) {\n let {\n item,\n shouldSelectOnPressUp,\n shouldFocusOnHover,\n shouldUseVirtualFocus\n } = props;\n\n let {\n rendered,\n key\n } = item;\n let ElementType: React.ElementType = item.props.href ? 'a' : 'div';\n let state = useContext(ListBoxContext);\n\n let ref = useRef<any>();\n let {optionProps, labelProps, descriptionProps, isSelected, isDisabled, isFocused} = useOption(\n {\n 'aria-label': item['aria-label'],\n key,\n shouldSelectOnPressUp,\n shouldFocusOnHover,\n isVirtualized: true,\n shouldUseVirtualFocus\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"}
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,CA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C,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>();\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"}
@@ -37,18 +37,15 @@ function $parcel$interopDefault(a) {
37
37
 
38
38
 
39
39
  function $86983ea1fa3f7312$export$feb3b6b552c14a12(props) {
40
- let { item: item, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
40
+ let { item: item } = props;
41
41
  let { rendered: rendered, key: key } = item;
42
42
  let ElementType = item.props.href ? 'a' : 'div';
43
- let state = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
43
+ let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
44
44
  let ref = (0, $6TrMC$useRef)();
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,
48
- shouldSelectOnPressUp: shouldSelectOnPressUp,
49
- shouldFocusOnHover: shouldFocusOnHover,
50
- isVirtualized: true,
51
- shouldUseVirtualFocus: shouldUseVirtualFocus
48
+ isVirtualized: true
52
49
  }, state, ref);
53
50
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $6TrMC$useHover)({
54
51
  ...props,
@@ -37,18 +37,15 @@ function $parcel$interopDefault(a) {
37
37
 
38
38
 
39
39
  function $86983ea1fa3f7312$export$feb3b6b552c14a12(props) {
40
- let { item: item, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
40
+ let { item: item } = props;
41
41
  let { rendered: rendered, key: key } = item;
42
42
  let ElementType = item.props.href ? 'a' : 'div';
43
- let state = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
43
+ let { state: state, shouldFocusOnHover: shouldFocusOnHover, shouldUseVirtualFocus: shouldUseVirtualFocus } = (0, $6TrMC$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
44
44
  let ref = (0, $6TrMC$useRef)();
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,
48
- shouldSelectOnPressUp: shouldSelectOnPressUp,
49
- shouldFocusOnHover: shouldFocusOnHover,
50
- isVirtualized: true,
51
- shouldUseVirtualFocus: shouldUseVirtualFocus
48
+ isVirtualized: true
52
49
  }, state, ref);
53
50
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $6TrMC$useHover)({
54
51
  ...props,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QACF,IAAI,yBACJ,qBAAqB,sBACrB,kBAAkB,yBAClB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,YACF,QAAQ,OACR,GAAG,EACJ,GAAG;IACJ,IAAI,cAAiC,KAAK,KAAK,CAAC,IAAI,GAAG,MAAM;IAC7D,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IAEpC,IAAI,MAAM,CAAA,GAAA,aAAK;IACf,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;+BACA;4BACA;QACA,eAAe;+BACf;IACF,GACA,OACA;IAEF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,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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 shouldSelectOnPressUp?: boolean,\n shouldFocusOnHover?: boolean,\n shouldUseVirtualFocus?: boolean\n}\n\n/** @private */\nexport function ListBoxOption<T>(props: OptionProps<T>) {\n let {\n item,\n shouldSelectOnPressUp,\n shouldFocusOnHover,\n shouldUseVirtualFocus\n } = props;\n\n let {\n rendered,\n key\n } = item;\n let ElementType: React.ElementType = item.props.href ? 'a' : 'div';\n let state = useContext(ListBoxContext);\n\n let ref = useRef<any>();\n let {optionProps, labelProps, descriptionProps, isSelected, isDisabled, isFocused} = useOption(\n {\n 'aria-label': item['aria-label'],\n key,\n shouldSelectOnPressUp,\n shouldFocusOnHover,\n isVirtualized: true,\n shouldUseVirtualFocus\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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoBM,SAAS,0CAAiB,KAAqB;IACpD,IAAI,QAAC,IAAI,EAAC,GAAG;IAEb,IAAI,YACF,QAAQ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gCAAC,CAAA,GAAA,mBAAW;QACV,OAAO;YACL,MAAM;gBAAC,kBAAkB,CAAA,GAAA,sDAAK,CAAC,CAAC,0BAA0B;gBAAE,GAAG,UAAU;YAAA;YACzE,MAAM;gBAAC,MAAM;gBAAK,kBAAkB,CAAA,GAAA,sDAAK,CAAC,CAAC,qBAAqB;YAAA;YAChE,QAAQ;gBAAC,MAAM;gBAAmB,kBAAkB,CAAA,GAAA,sDAAK,CAAC,CAAC,uBAAuB;YAAA;YAClF,aAAa;gBAAC,kBAAkB,CAAA,GAAA,sDAAK,CAAC,CAAC,4BAA4B;gBAAE,GAAG,gBAAgB;YAAA;QAC1F;OACC,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>();\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"}
@@ -47,7 +47,7 @@ function $0f5fd8483f48ef09$export$dca12b0bb56e4fc(props) {
47
47
  ref: headerRef
48
48
  });
49
49
  let { direction: direction } = (0, $cCu2p$reactariai18n.useLocale)();
50
- let state = (0, $cCu2p$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
50
+ let { state: state } = (0, $cCu2p$react.useContext)((0, $611e93c7b7c0413c$exports.ListBoxContext));
51
51
  return /*#__PURE__*/ (0, ($parcel$interopDefault($cCu2p$react))).createElement((0, $cCu2p$react.Fragment), null, headerLayoutInfo && /*#__PURE__*/ (0, ($parcel$interopDefault($cCu2p$react))).createElement("div", {
52
52
  role: "presentation",
53
53
  ref: headerRef,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmBM,SAAS,yCAAkB,KAA6B;IAC7D,IAAI,YAAC,QAAQ,cAAE,UAAU,oBAAE,gBAAgB,eAAE,WAAW,QAAE,IAAI,EAAC,GAAG;IAClE,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QACjD,SAAS,KAAK,QAAQ;QACtB,cAAc,IAAI,CAAC,aAAa;IAClC;IAEA,IAAI,YAAY,CAAA,GAAA,mBAAK;IACrB,CAAA,GAAA,8CAAiB,EAAE;QACjB,YAAY;qBACZ;QACA,KAAK;IACP;IAEA,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,QAAQ,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IAEpC,qBACE,0DAAC,CAAA,GAAA,qBAAO,SACL,kCAAoB,0DAAC;QAAI,MAAK;QAAe,KAAK;QAAW,OAAO,CAAA,GAAA,6CAAgB,EAAE,kBAAkB;OACtG,KAAK,GAAG,KAAK,MAAM,UAAU,CAAC,WAAW,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();\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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmBM,SAAS,yCAAkB,KAA6B;IAC7D,IAAI,YAAC,QAAQ,cAAE,UAAU,oBAAE,gBAAgB,eAAE,WAAW,QAAE,IAAI,EAAC,GAAG;IAClE,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QACjD,SAAS,KAAK,QAAQ;QACtB,cAAc,IAAI,CAAC,aAAa;IAClC;IAEA,IAAI,YAAY,CAAA,GAAA,mBAAK;IACrB,CAAA,GAAA,8CAAiB,EAAE;QACjB,YAAY;qBACZ;QACA,KAAK;IACP;IAEA,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IAEtC,qBACE,0DAAC,CAAA,GAAA,qBAAO,SACL,kCAAoB,0DAAC;QAAI,MAAK;QAAe,KAAK;QAAW,OAAO,CAAA,GAAA,6CAAgB,EAAE,kBAAkB;OACtG,KAAK,GAAG,KAAK,MAAM,UAAU,CAAC,WAAW,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();\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"}
@@ -41,7 +41,7 @@ function $92d678ed88836094$export$dca12b0bb56e4fc(props) {
41
41
  ref: headerRef
42
42
  });
43
43
  let { direction: direction } = (0, $dzUX8$useLocale)();
44
- let state = (0, $dzUX8$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
44
+ let { state: state } = (0, $dzUX8$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
45
45
  return /*#__PURE__*/ (0, $dzUX8$react).createElement((0, $dzUX8$Fragment), null, headerLayoutInfo && /*#__PURE__*/ (0, $dzUX8$react).createElement("div", {
46
46
  role: "presentation",
47
47
  ref: headerRef,
@@ -41,7 +41,7 @@ function $92d678ed88836094$export$dca12b0bb56e4fc(props) {
41
41
  ref: headerRef
42
42
  });
43
43
  let { direction: direction } = (0, $dzUX8$useLocale)();
44
- let state = (0, $dzUX8$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
44
+ let { state: state } = (0, $dzUX8$useContext)((0, $0c6f792811e33483$export$7ff8f37d2d81a48d));
45
45
  return /*#__PURE__*/ (0, $dzUX8$react).createElement((0, $dzUX8$Fragment), null, headerLayoutInfo && /*#__PURE__*/ (0, $dzUX8$react).createElement("div", {
46
46
  role: "presentation",
47
47
  ref: headerRef,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmBM,SAAS,yCAAkB,KAA6B;IAC7D,IAAI,YAAC,QAAQ,cAAE,UAAU,oBAAE,gBAAgB,eAAE,WAAW,QAAE,IAAI,EAAC,GAAG;IAClE,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QACjD,SAAS,KAAK,QAAQ;QACtB,cAAc,IAAI,CAAC,aAAa;IAClC;IAEA,IAAI,YAAY,CAAA,GAAA,aAAK;IACrB,CAAA,GAAA,yBAAiB,EAAE;QACjB,YAAY;qBACZ;QACA,KAAK;IACP;IAEA,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IAEpC,qBACE,gCAAC,CAAA,GAAA,eAAO,SACL,kCAAoB,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAW,OAAO,CAAA,GAAA,wBAAgB,EAAE,kBAAkB;OACtG,KAAK,GAAG,KAAK,MAAM,UAAU,CAAC,WAAW,oBACxC,gCAAC;QACC,MAAK;QACL,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,sDAAK,GACL;QAGL,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();\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"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmBM,SAAS,yCAAkB,KAA6B;IAC7D,IAAI,YAAC,QAAQ,cAAE,UAAU,oBAAE,gBAAgB,eAAE,WAAW,QAAE,IAAI,EAAC,GAAG;IAClE,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QACjD,SAAS,KAAK,QAAQ;QACtB,cAAc,IAAI,CAAC,aAAa;IAClC;IAEA,IAAI,YAAY,CAAA,GAAA,aAAK;IACrB,CAAA,GAAA,yBAAiB,EAAE;QACjB,YAAY;qBACZ;QACA,KAAK;IACP;IAEA,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IAEtC,qBACE,gCAAC,CAAA,GAAA,eAAO,SACL,kCAAoB,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAW,OAAO,CAAA,GAAA,wBAAgB,EAAE,kBAAkB;OACtG,KAAK,GAAG,KAAK,MAAM,UAAU,CAAC,WAAW,oBACxC,gCAAC;QACC,MAAK;QACL,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,sDAAK,GACL;QAGL,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();\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
@@ -14,14 +14,14 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
14
14
  domProps?: HTMLAttributes<HTMLElement>;
15
15
  disallowEmptySelection?: boolean;
16
16
  shouldUseVirtualFocus?: boolean;
17
- transitionDuration?: number;
18
17
  isLoading?: boolean;
18
+ showLoadingSpinner?: boolean;
19
19
  onLoadMore?: () => void;
20
20
  renderEmptyState?: () => ReactNode;
21
21
  onScroll?: () => void;
22
22
  }
23
23
  /** @private */
24
- export function useListBoxLayout<T>(state: ListState<T>, isLoading: boolean): ListLayout<T>;
24
+ export function useListBoxLayout<T>(state: ListState<T>): ListLayout<T>;
25
25
  export const ListBoxBase: <T>(props: ListBoxBaseProps<T> & {
26
26
  ref?: RefObject<HTMLDivElement>;
27
27
  }) => ReactElement;
@@ -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,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,SAAS,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAe;AACf,iCAAiC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,WAAW,CAAC,CAAC,CAyB1F;AAgHD,OAAA,MAAM;UAAwF,UAAU,cAAc,CAAC;MAAM,YAAY,CAAC;ACtJ1I;;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"}
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,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,SAAS,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAe;AACf,iCAAiC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAiBtE;AAoFD,OAAA,MAAM;UAAwF,UAAU,cAAc,CAAC;MAAM,YAAY,CAAC;AClH1I;;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.4649+02f242f41",
3
+ "version": "3.12.10-nightly.4654+8577c4d8b",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -36,27 +36,27 @@
36
36
  "url": "https://github.com/adobe/react-spectrum"
37
37
  },
38
38
  "dependencies": {
39
- "@react-aria/focus": "3.0.0-nightly.2937+02f242f41",
40
- "@react-aria/i18n": "3.0.0-nightly.2937+02f242f41",
41
- "@react-aria/interactions": "3.0.0-nightly.2937+02f242f41",
42
- "@react-aria/listbox": "3.12.2-nightly.4649+02f242f41",
43
- "@react-aria/utils": "3.0.0-nightly.2937+02f242f41",
44
- "@react-aria/virtualizer": "3.10.2-nightly.4649+02f242f41",
45
- "@react-spectrum/layout": "3.6.6-nightly.4649+02f242f41",
46
- "@react-spectrum/progress": "3.0.0-nightly.2937+02f242f41",
47
- "@react-spectrum/text": "3.5.6-nightly.4649+02f242f41",
48
- "@react-spectrum/utils": "3.0.0-nightly.2937+02f242f41",
49
- "@react-stately/collections": "3.0.0-nightly.2937+02f242f41",
50
- "@react-stately/layout": "3.13.10-nightly.4649+02f242f41",
51
- "@react-stately/list": "3.10.6-nightly.4649+02f242f41",
52
- "@react-stately/virtualizer": "3.7.2-nightly.4649+02f242f41",
53
- "@react-types/listbox": "3.4.10-nightly.4649+02f242f41",
54
- "@react-types/shared": "3.0.0-nightly.2937+02f242f41",
55
- "@spectrum-icons/ui": "3.0.0-nightly.2937+02f242f41",
39
+ "@react-aria/focus": "3.0.0-nightly.2942+8577c4d8b",
40
+ "@react-aria/i18n": "3.0.0-nightly.2942+8577c4d8b",
41
+ "@react-aria/interactions": "3.0.0-nightly.2942+8577c4d8b",
42
+ "@react-aria/listbox": "3.12.2-nightly.4654+8577c4d8b",
43
+ "@react-aria/utils": "3.0.0-nightly.2942+8577c4d8b",
44
+ "@react-aria/virtualizer": "3.10.2-nightly.4654+8577c4d8b",
45
+ "@react-spectrum/layout": "3.6.6-nightly.4654+8577c4d8b",
46
+ "@react-spectrum/progress": "3.0.0-nightly.2942+8577c4d8b",
47
+ "@react-spectrum/text": "3.5.6-nightly.4654+8577c4d8b",
48
+ "@react-spectrum/utils": "3.0.0-nightly.2942+8577c4d8b",
49
+ "@react-stately/collections": "3.0.0-nightly.2942+8577c4d8b",
50
+ "@react-stately/layout": "3.13.10-nightly.4654+8577c4d8b",
51
+ "@react-stately/list": "3.10.6-nightly.4654+8577c4d8b",
52
+ "@react-stately/virtualizer": "3.7.2-nightly.4654+8577c4d8b",
53
+ "@react-types/listbox": "3.4.10-nightly.4654+8577c4d8b",
54
+ "@react-types/shared": "3.0.0-nightly.2942+8577c4d8b",
55
+ "@spectrum-icons/ui": "3.0.0-nightly.2942+8577c4d8b",
56
56
  "@swc/helpers": "^0.5.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@adobe/spectrum-css-temp": "3.0.0-nightly.2937+02f242f41"
59
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2942+8577c4d8b"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@react-spectrum/provider": "^3.2.0",
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "02f242f41f0347b3f11e50b019c197127b7d0a08"
69
+ "gitHead": "8577c4d8bed1f37db3c840f230e844fd877d084a"
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(state, props.isLoading);
22
+ let layout = useListBoxLayout(state);
23
23
  let domRef = useDOMRef(ref);
24
24
 
25
25
  return (
@@ -21,9 +21,9 @@ import {ListBoxOption} from './ListBoxOption';
21
21
  import {ListBoxSection} from './ListBoxSection';
22
22
  import {ListLayout} from '@react-stately/layout';
23
23
  import {ListState} from '@react-stately/list';
24
- import {mergeProps, useLayoutEffect} from '@react-aria/utils';
24
+ import {mergeProps} from '@react-aria/utils';
25
25
  import {ProgressCircle} from '@react-spectrum/progress';
26
- import React, {HTMLAttributes, ReactElement, ReactNode, RefObject, useMemo} from 'react';
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
29
  import {useCollator, useLocalizedStringFormatter} from '@react-aria/i18n';
@@ -40,15 +40,15 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
40
40
  domProps?: HTMLAttributes<HTMLElement>,
41
41
  disallowEmptySelection?: boolean,
42
42
  shouldUseVirtualFocus?: boolean,
43
- transitionDuration?: number,
44
43
  isLoading?: boolean,
44
+ showLoadingSpinner?: boolean,
45
45
  onLoadMore?: () => void,
46
46
  renderEmptyState?: () => ReactNode,
47
47
  onScroll?: () => void
48
48
  }
49
49
 
50
50
  /** @private */
51
- export function useListBoxLayout<T>(state: ListState<T>, isLoading: boolean): ListLayout<T> {
51
+ export function useListBoxLayout<T>(state: ListState<T>): ListLayout<T> {
52
52
  let {scale} = useProvider();
53
53
  let collator = useCollator({usage: 'search', sensitivity: 'base'});
54
54
  let layout = useMemo(() =>
@@ -64,32 +64,23 @@ export function useListBoxLayout<T>(state: ListState<T>, isLoading: boolean): Li
64
64
 
65
65
  layout.collection = state.collection;
66
66
  layout.disabledKeys = state.disabledKeys;
67
-
68
- useLayoutEffect(() => {
69
- // Sync loading state into the layout.
70
- if (layout.isLoading !== isLoading) {
71
- layout.isLoading = isLoading;
72
- layout.virtualizer?.relayoutNow();
73
- }
74
- }, [layout, isLoading]);
75
67
  return layout;
76
68
  }
77
69
 
78
70
  /** @private */
79
71
  function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement>) {
80
- let {layout, state, shouldSelectOnPressUp, focusOnPointerEnter, shouldUseVirtualFocus, domProps = {}, transitionDuration = 0, onScroll} = props;
72
+ let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;
81
73
  let {listBoxProps} = useListBox({
82
74
  ...props,
83
75
  keyboardDelegate: layout,
84
76
  isVirtualized: true
85
77
  }, state, ref);
86
78
  let {styleProps} = useStyleProps(props);
87
- let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/listbox');
88
79
 
89
80
  // This overrides collection view's renderWrapper to support hierarchy of items in sections.
90
81
  // The header is extracted from the children so it can receive ARIA labeling properties.
91
- type View = ReusableView<Node<T>, ReactNode>;
92
- let renderWrapper = (parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {
82
+ type View = ReusableView<Node<T>, ReactElement>;
83
+ let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {
93
84
  if (reusableView.viewType === 'section') {
94
85
  return (
95
86
  <ListBoxSection
@@ -112,10 +103,10 @@ function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElemen
112
103
  {reusableView.rendered}
113
104
  </VirtualizerItem>
114
105
  );
115
- };
106
+ }, []);
116
107
 
117
108
  return (
118
- <ListBoxContext.Provider value={state}>
109
+ <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>
119
110
  <FocusScope>
120
111
  <Virtualizer
121
112
  {...styleProps}
@@ -133,50 +124,23 @@ function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElemen
133
124
  )
134
125
  }
135
126
  layout={layout}
127
+ layoutOptions={useMemo(() => ({
128
+ isLoading: showLoadingSpinner
129
+ }), [showLoadingSpinner])}
136
130
  collection={state.collection}
137
131
  renderWrapper={renderWrapper}
138
- transitionDuration={transitionDuration}
139
- isLoading={props.isLoading}
132
+ isLoading={isLoading}
140
133
  onLoadMore={props.onLoadMore}
141
- shouldUseVirtualFocus={shouldUseVirtualFocus}
142
134
  onScroll={onScroll}>
143
- {(type, item: Node<T>) => {
135
+ {useCallback((type, item: Node<T>) => {
144
136
  if (type === 'item') {
145
- return (
146
- <ListBoxOption
147
- item={item}
148
- shouldSelectOnPressUp={shouldSelectOnPressUp}
149
- shouldFocusOnHover={focusOnPointerEnter}
150
- shouldUseVirtualFocus={shouldUseVirtualFocus} />
151
- );
137
+ return <ListBoxOption item={item} />;
152
138
  } else if (type === 'loader') {
153
- return (
154
- // aria-selected isn't needed here since this option is not selectable.
155
- // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
156
- <div role="option" style={{display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%'}}>
157
- <ProgressCircle
158
- isIndeterminate
159
- size="S"
160
- aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')}
161
- UNSAFE_className={classNames(styles, 'spectrum-Dropdown-progressCircle')} />
162
- </div>
163
- );
139
+ return <LoadingState />;
164
140
  } else if (type === 'placeholder') {
165
- let emptyState = props.renderEmptyState ? props.renderEmptyState() : null;
166
- if (emptyState == null) {
167
- return null;
168
- }
169
-
170
- return (
171
- <div
172
- // aria-selected isn't needed here since this option is not selectable.
173
- // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
174
- role="option">
175
- {emptyState}
176
- </div>
177
- );
141
+ return <EmptyState />;
178
142
  }
179
- }}
143
+ }, [])}
180
144
  </Virtualizer>
181
145
  </FocusScope>
182
146
  </ListBoxContext.Provider>
@@ -187,3 +151,36 @@ function ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElemen
187
151
  // https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
188
152
  const _ListBoxBase = React.forwardRef(ListBoxBase) as <T>(props: ListBoxBaseProps<T> & {ref?: RefObject<HTMLDivElement>}) => ReactElement;
189
153
  export {_ListBoxBase as ListBoxBase};
154
+
155
+ function LoadingState() {
156
+ let {state} = useContext(ListBoxContext);
157
+ let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/listbox');
158
+ return (
159
+ // aria-selected isn't needed here since this option is not selectable.
160
+ // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
161
+ <div role="option" style={{display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%'}}>
162
+ <ProgressCircle
163
+ isIndeterminate
164
+ size="S"
165
+ aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')}
166
+ UNSAFE_className={classNames(styles, 'spectrum-Dropdown-progressCircle')} />
167
+ </div>
168
+ );
169
+ }
170
+
171
+ function EmptyState() {
172
+ let {renderEmptyState} = useContext(ListBoxContext);
173
+ let emptyState = renderEmptyState ? renderEmptyState() : null;
174
+ if (emptyState == null) {
175
+ return null;
176
+ }
177
+
178
+ return (
179
+ <div
180
+ // aria-selected isn't needed here since this option is not selectable.
181
+ // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
182
+ role="option">
183
+ {emptyState}
184
+ </div>
185
+ );
186
+ }
@@ -11,6 +11,13 @@
11
11
  */
12
12
 
13
13
  import {ListState} from '@react-stately/list';
14
- import React from 'react';
14
+ import React, {ReactNode} from 'react';
15
15
 
16
- export const ListBoxContext = React.createContext<ListState<unknown>>(null);
16
+ interface ListBoxContextValue {
17
+ state: ListState<unknown>,
18
+ renderEmptyState?: () => ReactNode,
19
+ shouldFocusOnHover: boolean,
20
+ shouldUseVirtualFocus: boolean
21
+ }
22
+
23
+ export const ListBoxContext = React.createContext<ListBoxContextValue>(null);