@react-spectrum/listbox 3.12.10-nightly.4685 → 3.12.10-nightly.4691

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,5 +1,6 @@
1
1
  var $3d9fe9b46e2d649a$exports = require("./intlStrings.main.js");
2
2
  var $611e93c7b7c0413c$exports = require("./ListBoxContext.main.js");
3
+ var $570d5c216669f686$exports = require("./ListBoxLayout.main.js");
3
4
  var $2205d250ee1cb1ac$exports = require("./ListBoxOption.main.js");
4
5
  var $0f5fd8483f48ef09$exports = require("./ListBoxSection.main.js");
5
6
  require("./vars.4c57e437.css");
@@ -7,7 +8,6 @@ var $3deee0fd2b46e64f$exports = require("./menu_vars_css.main.js");
7
8
  var $7w19U$reactarialistbox = require("@react-aria/listbox");
8
9
  var $7w19U$reactspectrumutils = require("@react-spectrum/utils");
9
10
  var $7w19U$reactariafocus = require("@react-aria/focus");
10
- var $7w19U$reactstatelylayout = require("@react-stately/layout");
11
11
  var $7w19U$reactariautils = require("@react-aria/utils");
12
12
  var $7w19U$reactspectrumprogress = require("@react-spectrum/progress");
13
13
  var $7w19U$react = require("react");
@@ -53,14 +53,11 @@ $parcel$export(module.exports, "ListBoxBase", () => $60eb4b34c53310cb$export$1af
53
53
 
54
54
  function $60eb4b34c53310cb$export$25768ea656ae32a7() {
55
55
  let { scale: scale } = (0, $7w19U$reactspectrumprovider.useProvider)();
56
- let layout = (0, $7w19U$react.useMemo)(()=>new (0, $7w19U$reactstatelylayout.ListLayout)({
56
+ let layout = (0, $7w19U$react.useMemo)(()=>new (0, $570d5c216669f686$exports.ListBoxLayout)({
57
57
  estimatedRowHeight: scale === 'large' ? 48 : 32,
58
58
  estimatedHeadingHeight: scale === 'large' ? 33 : 26,
59
59
  padding: scale === 'large' ? 5 : 4,
60
- loaderHeight: 40,
61
- placeholderHeight: scale === 'large' ? 48 : 32,
62
- forceSectionHeaders: true,
63
- enableEmptyState: true
60
+ placeholderHeight: scale === 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AC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IACtC,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,OACE,uEAAuE;IACvE,iEAAiE;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 {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"}
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,uCAAY,EAAK;YACnB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wBAAwB,UAAU,UAAU,KAAK;YACjD,SAAS,UAAU,UAAU,IAAI;YACjC,mBAAmB,UAAU,UAAU,KAAK;QAC9C,I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,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 {ListBoxLayout} from './ListBoxLayout';\nimport {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, 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: ListBoxLayout<T>,\n state: ListState<T>,\n autoFocus?: boolean | FocusStrategy,\n shouldFocusWrap?: boolean,\n shouldSelectOnPressUp?: boolean,\n focusOnPointerEnter?: boolean,\n domProps?: HTMLAttributes<HTMLElement>,\n disallowEmptySelection?: boolean,\n shouldUseVirtualFocus?: boolean,\n isLoading?: boolean,\n showLoadingSpinner?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(): ListBoxLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListBoxLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n placeholderHeight: scale === 'large' ? 48 : 32\n })\n , [scale]);\n\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n layoutDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n\n // This overrides collection view's renderWrapper to support hierarchy of items in sections.\n // The header is extracted from the children so it can receive ARIA labeling properties.\n type View = ReusableView<Node<T>, ReactElement>;\n let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {\n if (reusableView.viewType === 'section') {\n return (\n <ListBoxSection\n key={reusableView.key}\n item={reusableView.content}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n headerLayoutInfo={children.find(c => c.viewType === 'header')?.layoutInfo}>\n {renderChildren(children.filter(c => c.viewType === 'item'))}\n </ListBoxSection>\n );\n }\n\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n }, []);\n\n 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"}
@@ -1,5 +1,6 @@
1
1
  import $gF3QK$intlStringsmodulejs from "./intlStrings.mjs";
2
2
  import {ListBoxContext as $0c6f792811e33483$export$7ff8f37d2d81a48d} from "./ListBoxContext.mjs";
3
+ import {ListBoxLayout as $d20755daac213984$export$c7e5f5ea00052bf} from "./ListBoxLayout.mjs";
3
4
  import {ListBoxOption as $86983ea1fa3f7312$export$feb3b6b552c14a12} from "./ListBoxOption.mjs";
4
5
  import {ListBoxSection as $92d678ed88836094$export$dca12b0bb56e4fc} from "./ListBoxSection.mjs";
5
6
  import "./vars.4c57e437.css";
@@ -7,7 +8,6 @@ import $gF3QK$menu_vars_cssmodulejs from "./menu_vars_css.mjs";
7
8
  import {useListBox as $gF3QK$useListBox} from "@react-aria/listbox";
8
9
  import {useStyleProps as $gF3QK$useStyleProps, classNames as $gF3QK$classNames} from "@react-spectrum/utils";
9
10
  import {FocusScope as $gF3QK$FocusScope} from "@react-aria/focus";
10
- 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";
@@ -46,14 +46,11 @@ function $parcel$interopDefault(a) {
46
46
 
47
47
  function $3247d4a89e6094e9$export$25768ea656ae32a7() {
48
48
  let { scale: scale } = (0, $gF3QK$useProvider)();
49
- let layout = (0, $gF3QK$useMemo)(()=>new (0, $gF3QK$ListLayout)({
49
+ let layout = (0, $gF3QK$useMemo)(()=>new (0, $d20755daac213984$export$c7e5f5ea00052bf)({
50
50
  estimatedRowHeight: scale === 'large' ? 48 : 32,
51
51
  estimatedHeadingHeight: scale === 'large' ? 33 : 26,
52
52
  padding: scale === 'large' ? 5 : 4,
53
- loaderHeight: 40,
54
- placeholderHeight: scale === 'large' ? 48 : 32,
55
- forceSectionHeaders: true,
56
- enableEmptyState: true
53
+ placeholderHeight: scale === 'large' ? 48 : 32
57
54
  }), [
58
55
  scale
59
56
  ]);
@@ -1,5 +1,6 @@
1
1
  import $gF3QK$intlStringsmodulejs from "./intlStrings.module.js";
2
2
  import {ListBoxContext as $0c6f792811e33483$export$7ff8f37d2d81a48d} from "./ListBoxContext.module.js";
3
+ import {ListBoxLayout as $d20755daac213984$export$c7e5f5ea00052bf} from "./ListBoxLayout.module.js";
3
4
  import {ListBoxOption as $86983ea1fa3f7312$export$feb3b6b552c14a12} from "./ListBoxOption.module.js";
4
5
  import {ListBoxSection as $92d678ed88836094$export$dca12b0bb56e4fc} from "./ListBoxSection.module.js";
5
6
  import "./vars.4c57e437.css";
@@ -7,7 +8,6 @@ import $gF3QK$menu_vars_cssmodulejs from "./menu_vars_css.module.js";
7
8
  import {useListBox as $gF3QK$useListBox} from "@react-aria/listbox";
8
9
  import {useStyleProps as $gF3QK$useStyleProps, classNames as $gF3QK$classNames} from "@react-spectrum/utils";
9
10
  import {FocusScope as $gF3QK$FocusScope} from "@react-aria/focus";
10
- 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";
@@ -46,14 +46,11 @@ function $parcel$interopDefault(a) {
46
46
 
47
47
  function $3247d4a89e6094e9$export$25768ea656ae32a7() {
48
48
  let { scale: scale } = (0, $gF3QK$useProvider)();
49
- let layout = (0, $gF3QK$useMemo)(()=>new (0, $gF3QK$ListLayout)({
49
+ let layout = (0, $gF3QK$useMemo)(()=>new (0, $d20755daac213984$export$c7e5f5ea00052bf)({
50
50
  estimatedRowHeight: scale === 'large' ? 48 : 32,
51
51
  estimatedHeadingHeight: scale === 'large' ? 33 : 26,
52
52
  padding: scale === 'large' ? 5 : 4,
53
- loaderHeight: 40,
54
- placeholderHeight: scale === 'large' ? 48 : 32,
55
- forceSectionHeaders: true,
56
- enableEmptyState: true
53
+ placeholderHeight: scale === 'large' ? 48 : 32
57
54
  }), [
58
55
  scale
59
56
  ]);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS;IACd,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IACnB,IAAI,CAAA,GAAA,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;AACT;AAEA,aAAa,GACb,SAAS,kCAAe,KAA0B,EAAE,GAAqC;IACvF,IAAI,UAAC,MAAM,SAAE,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,YAAE,WAAW,CAAC,cAAG,SAAS,sBAAE,qBAAqB,qBAAW,QAAQ,oBAAE,gBAAgB,EAAC,GAAG;IACvJ,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA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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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS;IACd,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IACnB,IAAI,CAAA,GAAA,wCAAY,EAAK;YACnB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wBAAwB,UAAU,UAAU,KAAK;YACjD,SAAS,UAAU,UAAU,IAAI;YACjC,mBAAmB,UAAU,UAAU,KAAK;QAC9C,IACA;QAAC;KAAM;IAET,OAAO;AACT;AAEA,aAAa,GACb,SAAS,kCAAe,KAA0B,EAAE,GAAqC;IACvF,IAAI,UAAC,MAAM,SAAE,KAAK,sBAAE,kBAAkB,yBAAE,qBAAqB,YAAE,WAAW,CAAC,cAAG,SAAS,sBAAE,qBAAqB,qBAAW,QAAQ,oBAAE,gBAAgB,EAAC,GAAG;IACvJ,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;QAC9B,GAAG,KAAK;QACR,gBAAgB;QAChB,eAAe;IACjB,GAAG,OAAO;IACV,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IAKjC,IAAI,gBAAgB,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAc,cAAoB,UAAkB;YAQ3D;QAPxB,IAAI,aAAa,QAAQ,KAAK,WAC5B,qBACE,gCAAC,CAAA,GAAA,wCAAa;YACZ,KAAK,aAAa,GAAG;YACrB,MAAM,aAAa,OAAO;YAC1B,YAAY,aAAa,UAAU;YACnC,aAAa,aAAa,WAAW;YACrC,gBAAgB,GAAE,iBAAA,SAAS,IAAI,CAAC,CAAA,IAAK,EAAE,QAAQ,KAAK,uBAAlC,qCAAA,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G,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACtC,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,OACE,uEAAuE;IACvE,iEAAiE;kBACjE,gCAAC;QAAI,MAAK;QAAS,OAAO;YAAC,SAAS;YAAQ,YAAY;YAAU,gBAAgB;YAAU,QAAQ;QAAM;qBACxG,gCAAC,CAAA,GAAA,qBAAa;QACZ,iBAAA;QACA,MAAK;QACL,cAAY,MAAM,UAAU,CAAC,IAAI,GAAG,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,gBAAgB,MAAM,CAAC;QACvG,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;;AAG7C;AAEA,SAAS;IACP,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACjD,IAAI,aAAa,mBAAmB,qBAAqB;IACzD,IAAI,cAAc,MAChB,OAAO;IAGT,qBACE,gCAAC;QACC,uEAAuE;QACvE,iEAAiE;QACjE,MAAK;OACJ;AAGP","sources":["packages/@react-spectrum/listbox/src/ListBoxBase.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaLabelingProps, DOMProps, FocusStrategy, Node, StyleProps} from '@react-types/shared';\nimport {AriaListBoxOptions, useListBox} from '@react-aria/listbox';\nimport {classNames, useStyleProps} from '@react-spectrum/utils';\nimport {FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListBoxContext} from './ListBoxContext';\nimport {ListBoxLayout} from './ListBoxLayout';\nimport {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, 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: ListBoxLayout<T>,\n state: ListState<T>,\n autoFocus?: boolean | FocusStrategy,\n shouldFocusWrap?: boolean,\n shouldSelectOnPressUp?: boolean,\n focusOnPointerEnter?: boolean,\n domProps?: HTMLAttributes<HTMLElement>,\n disallowEmptySelection?: boolean,\n shouldUseVirtualFocus?: boolean,\n isLoading?: boolean,\n showLoadingSpinner?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(): ListBoxLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListBoxLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n placeholderHeight: scale === 'large' ? 48 : 32\n })\n , [scale]);\n\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n layoutDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n\n // This overrides collection view's renderWrapper to support hierarchy of items in sections.\n // The header is extracted from the children so it can receive ARIA labeling properties.\n type View = ReusableView<Node<T>, ReactElement>;\n let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {\n if (reusableView.viewType === 'section') {\n return (\n <ListBoxSection\n key={reusableView.key}\n item={reusableView.content}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n headerLayoutInfo={children.find(c => c.viewType === 'header')?.layoutInfo}>\n {renderChildren(children.filter(c => c.viewType === 'item'))}\n </ListBoxSection>\n );\n }\n\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n }, []);\n\n 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"}
@@ -0,0 +1,79 @@
1
+ var $7VTYQ$reactstatelyvirtualizer = require("@react-stately/virtualizer");
2
+ var $7VTYQ$reactstatelylayout = require("@react-stately/layout");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "ListBoxLayout", () => $570d5c216669f686$export$c7e5f5ea00052bf);
10
+
11
+
12
+ class $570d5c216669f686$export$c7e5f5ea00052bf extends (0, $7VTYQ$reactstatelylayout.ListLayout) {
13
+ validate(invalidationContext) {
14
+ var _invalidationContext_layoutOptions;
15
+ this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
16
+ super.validate(invalidationContext);
17
+ }
18
+ buildCollection() {
19
+ let nodes = super.buildCollection(this.padding);
20
+ let y = this.contentSize.height;
21
+ if (this.isLoading) {
22
+ let rect = new (0, $7VTYQ$reactstatelyvirtualizer.Rect)(0, y, this.virtualizer.visibleRect.width, 40);
23
+ let loader = new (0, $7VTYQ$reactstatelyvirtualizer.LayoutInfo)('loader', 'loader', rect);
24
+ let node = {
25
+ layoutInfo: loader,
26
+ validRect: loader.rect
27
+ };
28
+ nodes.push(node);
29
+ this.layoutNodes.set(loader.key, node);
30
+ y = loader.rect.maxY;
31
+ }
32
+ if (nodes.length === 0) {
33
+ var _this_placeholderHeight;
34
+ let rect = new (0, $7VTYQ$reactstatelyvirtualizer.Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
35
+ let placeholder = new (0, $7VTYQ$reactstatelyvirtualizer.LayoutInfo)('placeholder', 'placeholder', rect);
36
+ let node = {
37
+ layoutInfo: placeholder,
38
+ validRect: placeholder.rect
39
+ };
40
+ nodes.push(node);
41
+ this.layoutNodes.set(placeholder.key, node);
42
+ y = placeholder.rect.maxY;
43
+ }
44
+ this.contentSize.height = y + this.padding;
45
+ return nodes;
46
+ }
47
+ buildSection(node, x, y) {
48
+ // Synthesize a collection node for the header.
49
+ let headerNode = {
50
+ type: 'header',
51
+ key: node.key + ':header',
52
+ parentKey: node.key,
53
+ value: null,
54
+ level: node.level,
55
+ hasChildNodes: false,
56
+ childNodes: [],
57
+ rendered: node.rendered,
58
+ textValue: node.textValue
59
+ };
60
+ // Build layout node for it and adjust y offset of section children.
61
+ let header = this.buildSectionHeader(headerNode, x, y);
62
+ header.node = headerNode;
63
+ header.layoutInfo.parentKey = node.key;
64
+ this.layoutNodes.set(headerNode.key, header);
65
+ y += header.layoutInfo.rect.height;
66
+ let section = super.buildSection(node, x, y);
67
+ section.children.unshift(header);
68
+ return section;
69
+ }
70
+ constructor(opts){
71
+ super(opts);
72
+ this.isLoading = false;
73
+ this.placeholderHeight = opts.placeholderHeight;
74
+ this.padding = opts.padding;
75
+ }
76
+ }
77
+
78
+
79
+ //# sourceMappingURL=ListBoxLayout.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAaO,MAAM,iDAAyB,CAAA,GAAA,oCAAS;IAW7C,SAAS,mBAA4D,EAAQ;YAC1D;QAAjB,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,KAAK,CAAC,SAAS;IACjB;IAEU,kBAAgC;QACxC,IAAI,QAAQ,KAAK,CAAC,gBAAgB,IAAI,CAAC,OAAO;QAC9C,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM;QAE/B,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,EAAE;YAC9D,IAAI,SAAS,IAAI,CAAA,GAAA,yCAAS,EAAE,UAAU,UAAU;YAChD,IAAI,OAAO;gBACT,YAAY;gBACZ,WAAW,OAAO,IAAI;YACxB;YACA,MAAM,IAAI,CAAC;YACX,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,GAAG,EAAE;YACjC,IAAI,OAAO,IAAI,CAAC,IAAI;QACtB;QAEA,IAAI,MAAM,MAAM,KAAK,GAAG;gBACwC;YAA9D,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA,0BAAA,IAAI,CAAC,iBAAiB,cAAtB,qCAAA,0B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outInfo, Rect} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';\nimport {Node} from '@react-types/shared';\n\ninterface ListBoxLayoutProps {\n isLoading?: boolean\n}\n\ninterface ListBoxLayoutOptions extends ListLayoutOptions {\n placeholderHeight: number,\n padding: number\n}\n\nexport class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {\n private isLoading: boolean = false;\n private placeholderHeight: number;\n private padding: number;\n\n constructor(opts: ListBoxLayoutOptions) {\n super(opts);\n this.placeholderHeight = opts.placeholderHeight;\n this.padding = opts.padding;\n }\n\n validate(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n super.validate(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n let nodes = super.buildCollection(this.padding);\n let y = this.contentSize.height;\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, 40);\n let loader = new LayoutInfo('loader', 'loader', rect);\n let node = {\n layoutInfo: loader,\n validRect: loader.rect\n };\n nodes.push(node);\n this.layoutNodes.set(loader.key, node);\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n let node = {\n layoutInfo: placeholder,\n validRect: placeholder.rect\n };\n nodes.push(node);\n this.layoutNodes.set(placeholder.key, node);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize.height = y + this.padding;\n return nodes;\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n // Synthesize a collection node for the header.\n let headerNode = {\n type: 'header',\n key: node.key + ':header',\n parentKey: node.key,\n value: null,\n level: node.level,\n hasChildNodes: false,\n childNodes: [],\n rendered: node.rendered,\n textValue: node.textValue\n };\n\n // Build layout node for it and adjust y offset of section children.\n let header = this.buildSectionHeader(headerNode, x, y);\n header.node = headerNode;\n header.layoutInfo.parentKey = node.key;\n this.layoutNodes.set(headerNode.key, header);\n y += header.layoutInfo.rect.height;\n\n let section = super.buildSection(node, x, y);\n section.children.unshift(header);\n return section;\n }\n}\n"],"names":[],"version":3,"file":"ListBoxLayout.main.js.map"}
@@ -0,0 +1,74 @@
1
+ import {Rect as $3YKfq$Rect, LayoutInfo as $3YKfq$LayoutInfo} from "@react-stately/virtualizer";
2
+ import {ListLayout as $3YKfq$ListLayout} from "@react-stately/layout";
3
+
4
+
5
+
6
+ class $d20755daac213984$export$c7e5f5ea00052bf extends (0, $3YKfq$ListLayout) {
7
+ validate(invalidationContext) {
8
+ var _invalidationContext_layoutOptions;
9
+ this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
10
+ super.validate(invalidationContext);
11
+ }
12
+ buildCollection() {
13
+ let nodes = super.buildCollection(this.padding);
14
+ let y = this.contentSize.height;
15
+ if (this.isLoading) {
16
+ let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, 40);
17
+ let loader = new (0, $3YKfq$LayoutInfo)('loader', 'loader', rect);
18
+ let node = {
19
+ layoutInfo: loader,
20
+ validRect: loader.rect
21
+ };
22
+ nodes.push(node);
23
+ this.layoutNodes.set(loader.key, node);
24
+ y = loader.rect.maxY;
25
+ }
26
+ if (nodes.length === 0) {
27
+ var _this_placeholderHeight;
28
+ let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
29
+ let placeholder = new (0, $3YKfq$LayoutInfo)('placeholder', 'placeholder', rect);
30
+ let node = {
31
+ layoutInfo: placeholder,
32
+ validRect: placeholder.rect
33
+ };
34
+ nodes.push(node);
35
+ this.layoutNodes.set(placeholder.key, node);
36
+ y = placeholder.rect.maxY;
37
+ }
38
+ this.contentSize.height = y + this.padding;
39
+ return nodes;
40
+ }
41
+ buildSection(node, x, y) {
42
+ // Synthesize a collection node for the header.
43
+ let headerNode = {
44
+ type: 'header',
45
+ key: node.key + ':header',
46
+ parentKey: node.key,
47
+ value: null,
48
+ level: node.level,
49
+ hasChildNodes: false,
50
+ childNodes: [],
51
+ rendered: node.rendered,
52
+ textValue: node.textValue
53
+ };
54
+ // Build layout node for it and adjust y offset of section children.
55
+ let header = this.buildSectionHeader(headerNode, x, y);
56
+ header.node = headerNode;
57
+ header.layoutInfo.parentKey = node.key;
58
+ this.layoutNodes.set(headerNode.key, header);
59
+ y += header.layoutInfo.rect.height;
60
+ let section = super.buildSection(node, x, y);
61
+ section.children.unshift(header);
62
+ return section;
63
+ }
64
+ constructor(opts){
65
+ super(opts);
66
+ this.isLoading = false;
67
+ this.placeholderHeight = opts.placeholderHeight;
68
+ this.padding = opts.padding;
69
+ }
70
+ }
71
+
72
+
73
+ export {$d20755daac213984$export$c7e5f5ea00052bf as ListBoxLayout};
74
+ //# sourceMappingURL=ListBoxLayout.module.js.map
@@ -0,0 +1,74 @@
1
+ import {Rect as $3YKfq$Rect, LayoutInfo as $3YKfq$LayoutInfo} from "@react-stately/virtualizer";
2
+ import {ListLayout as $3YKfq$ListLayout} from "@react-stately/layout";
3
+
4
+
5
+
6
+ class $d20755daac213984$export$c7e5f5ea00052bf extends (0, $3YKfq$ListLayout) {
7
+ validate(invalidationContext) {
8
+ var _invalidationContext_layoutOptions;
9
+ this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
10
+ super.validate(invalidationContext);
11
+ }
12
+ buildCollection() {
13
+ let nodes = super.buildCollection(this.padding);
14
+ let y = this.contentSize.height;
15
+ if (this.isLoading) {
16
+ let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, 40);
17
+ let loader = new (0, $3YKfq$LayoutInfo)('loader', 'loader', rect);
18
+ let node = {
19
+ layoutInfo: loader,
20
+ validRect: loader.rect
21
+ };
22
+ nodes.push(node);
23
+ this.layoutNodes.set(loader.key, node);
24
+ y = loader.rect.maxY;
25
+ }
26
+ if (nodes.length === 0) {
27
+ var _this_placeholderHeight;
28
+ let rect = new (0, $3YKfq$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
29
+ let placeholder = new (0, $3YKfq$LayoutInfo)('placeholder', 'placeholder', rect);
30
+ let node = {
31
+ layoutInfo: placeholder,
32
+ validRect: placeholder.rect
33
+ };
34
+ nodes.push(node);
35
+ this.layoutNodes.set(placeholder.key, node);
36
+ y = placeholder.rect.maxY;
37
+ }
38
+ this.contentSize.height = y + this.padding;
39
+ return nodes;
40
+ }
41
+ buildSection(node, x, y) {
42
+ // Synthesize a collection node for the header.
43
+ let headerNode = {
44
+ type: 'header',
45
+ key: node.key + ':header',
46
+ parentKey: node.key,
47
+ value: null,
48
+ level: node.level,
49
+ hasChildNodes: false,
50
+ childNodes: [],
51
+ rendered: node.rendered,
52
+ textValue: node.textValue
53
+ };
54
+ // Build layout node for it and adjust y offset of section children.
55
+ let header = this.buildSectionHeader(headerNode, x, y);
56
+ header.node = headerNode;
57
+ header.layoutInfo.parentKey = node.key;
58
+ this.layoutNodes.set(headerNode.key, header);
59
+ y += header.layoutInfo.rect.height;
60
+ let section = super.buildSection(node, x, y);
61
+ section.children.unshift(header);
62
+ return section;
63
+ }
64
+ constructor(opts){
65
+ super(opts);
66
+ this.isLoading = false;
67
+ this.placeholderHeight = opts.placeholderHeight;
68
+ this.padding = opts.padding;
69
+ }
70
+ }
71
+
72
+
73
+ export {$d20755daac213984$export$c7e5f5ea00052bf as ListBoxLayout};
74
+ //# sourceMappingURL=ListBoxLayout.module.js.map
@@ -0,0 +1 @@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C3B;QAEA,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO;QAC1C,OAAO;IACT;IAEU,aAAa,IAAa,EAAE,CAAS,EAAE,CAAS,EAAc;QACtE,+CAA+C;QAC/C,IAAI,aAAa;YACf,MAAM;YACN,KAAK,KAAK,GAAG,GAAG;YAChB,WAAW,KAAK,GAAG;YACnB,OAAO;YACP,OAAO,KAAK,KAAK;YACjB,eAAe;YACf,YAAY,EAAE;YACd,UAAU,KAAK,QAAQ;YACvB,WAAW,KAAK,SAAS;QAC3B;QAEA,oEAAoE;QACpE,IAAI,SAAS,IAAI,CAAC,kBAAkB,CAAC,YAAY,GAAG;QACpD,OAAO,IAAI,GAAG;QACd,OAAO,UAAU,CAAC,SAAS,GAAG,KAAK,GAAG;QACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE;QACrC,KAAK,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM;QAElC,IAAI,UAAU,KAAK,CAAC,aAAa,MAAM,GAAG;QAC1C,QAAQ,QAAQ,CAAC,OAAO,CAAC;QACzB,OAAO;IACT;IAnEA,YAAY,IAA0B,CAAE;QACtC,KAAK,CAAC;aALA,YAAqB;QAM3B,IAAI,CAAC,iBAAiB,GAAG,KAAK,iBAAiB;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,OAAO;IAC7B;AAgEF","sources":["packages/@react-spectrum/listbox/src/ListBoxLayout.ts"],"sourcesContent":["import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';\nimport {Node} from '@react-types/shared';\n\ninterface ListBoxLayoutProps {\n isLoading?: boolean\n}\n\ninterface ListBoxLayoutOptions extends ListLayoutOptions {\n placeholderHeight: number,\n padding: number\n}\n\nexport class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {\n private isLoading: boolean = false;\n private placeholderHeight: number;\n private padding: number;\n\n constructor(opts: ListBoxLayoutOptions) {\n super(opts);\n this.placeholderHeight = opts.placeholderHeight;\n this.padding = opts.padding;\n }\n\n validate(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n super.validate(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n let nodes = super.buildCollection(this.padding);\n let y = this.contentSize.height;\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, 40);\n let loader = new LayoutInfo('loader', 'loader', rect);\n let node = {\n layoutInfo: loader,\n validRect: loader.rect\n };\n nodes.push(node);\n this.layoutNodes.set(loader.key, node);\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width, this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n let node = {\n layoutInfo: placeholder,\n validRect: placeholder.rect\n };\n nodes.push(node);\n this.layoutNodes.set(placeholder.key, node);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize.height = y + this.padding;\n return nodes;\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n // Synthesize a collection node for the header.\n let headerNode = {\n type: 'header',\n key: node.key + ':header',\n parentKey: node.key,\n value: null,\n level: node.level,\n hasChildNodes: false,\n childNodes: [],\n rendered: node.rendered,\n textValue: node.textValue\n };\n\n // Build layout node for it and adjust y offset of section children.\n let header = this.buildSectionHeader(headerNode, x, y);\n header.node = headerNode;\n header.layoutInfo.parentKey = node.key;\n this.layoutNodes.set(headerNode.key, header);\n y += header.layoutInfo.rect.height;\n\n let section = super.buildSection(node, x, y);\n section.children.unshift(header);\n return section;\n }\n}\n"],"names":[],"version":3,"file":"ListBoxLayout.module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,11 +1,25 @@
1
- import { AriaLabelingProps, DOMProps, FocusStrategy, StyleProps, DOMRef } from "@react-types/shared";
1
+ import { InvalidationContext } from "@react-stately/virtualizer";
2
+ import { LayoutNode, ListLayout, ListLayoutOptions } from "@react-stately/layout";
3
+ import { Node, AriaLabelingProps, DOMProps, FocusStrategy, StyleProps, DOMRef } from "@react-types/shared";
2
4
  import { AriaListBoxOptions } from "@react-aria/listbox";
3
- import { ListLayout } from "@react-stately/layout";
4
5
  import { ListState } from "@react-stately/list";
5
6
  import { HTMLAttributes, ReactElement, ReactNode, RefObject } from "react";
6
7
  import { SpectrumListBoxProps } from "@react-types/listbox";
8
+ interface ListBoxLayoutProps {
9
+ isLoading?: boolean;
10
+ }
11
+ interface ListBoxLayoutOptions extends ListLayoutOptions {
12
+ placeholderHeight: number;
13
+ padding: number;
14
+ }
15
+ declare class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {
16
+ constructor(opts: ListBoxLayoutOptions);
17
+ validate(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void;
18
+ protected buildCollection(): LayoutNode[];
19
+ protected buildSection(node: Node<T>, x: number, y: number): LayoutNode;
20
+ }
7
21
  interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabelingProps, StyleProps {
8
- layout: ListLayout<T>;
22
+ layout: ListBoxLayout<T>;
9
23
  state: ListState<T>;
10
24
  autoFocus?: boolean | FocusStrategy;
11
25
  shouldFocusWrap?: boolean;
@@ -21,7 +35,7 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
21
35
  onScroll?: () => void;
22
36
  }
23
37
  /** @private */
24
- export function useListBoxLayout<T>(): ListLayout<T>;
38
+ export function useListBoxLayout<T>(): ListBoxLayout<T>;
25
39
  export const ListBoxBase: <T>(props: ListBoxBaseProps<T> & {
26
40
  ref?: RefObject<HTMLDivElement | null>;
27
41
  }) => 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,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,KAAK,WAAW,CAAC,CAAC,CAenD;AAoFD,OAAA,MAAM,aAAgD,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC;AChHjJ;;GAEG;AACH,OAAA,MAAM,SAAwC,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,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":";;;;;;;ACIA;IACE,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,8BAA+B,SAAQ,iBAAiB;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,4BAA2B,CAAC,CAAE,SAAQ,WAAW,CAAC,EAAE,kBAAkB,CAAC;gBAKzD,IAAI,EAAE,oBAAoB;IAMtC,QAAQ,CAAC,mBAAmB,EAAE,oBAAoB,kBAAkB,CAAC,GAAG,IAAI;IAK5E,SAAS,CAAC,eAAe,IAAI,UAAU,EAAE;IAgCzC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;CAyBxE;AGtDD,2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src/ListBoxContext.ts","packages/@react-spectrum/listbox/src/packages/@react-spectrum/listbox/src/ListBoxLayout.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,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.4685+a48d1673f",
3
+ "version": "3.12.10-nightly.4691+fabca84b9",
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.2973+a48d1673f",
40
- "@react-aria/i18n": "3.0.0-nightly.2973+a48d1673f",
41
- "@react-aria/interactions": "3.0.0-nightly.2973+a48d1673f",
42
- "@react-aria/listbox": "3.12.2-nightly.4685+a48d1673f",
43
- "@react-aria/utils": "3.0.0-nightly.2973+a48d1673f",
44
- "@react-aria/virtualizer": "3.10.2-nightly.4685+a48d1673f",
45
- "@react-spectrum/layout": "3.6.6-nightly.4685+a48d1673f",
46
- "@react-spectrum/progress": "3.0.0-nightly.2973+a48d1673f",
47
- "@react-spectrum/text": "3.5.6-nightly.4685+a48d1673f",
48
- "@react-spectrum/utils": "3.0.0-nightly.2973+a48d1673f",
49
- "@react-stately/collections": "3.0.0-nightly.2973+a48d1673f",
50
- "@react-stately/layout": "3.13.10-nightly.4685+a48d1673f",
51
- "@react-stately/list": "3.10.6-nightly.4685+a48d1673f",
52
- "@react-stately/virtualizer": "3.7.2-nightly.4685+a48d1673f",
53
- "@react-types/listbox": "3.4.10-nightly.4685+a48d1673f",
54
- "@react-types/shared": "3.0.0-nightly.2973+a48d1673f",
55
- "@spectrum-icons/ui": "3.0.0-nightly.2973+a48d1673f",
39
+ "@react-aria/focus": "3.0.0-nightly.2979+fabca84b9",
40
+ "@react-aria/i18n": "3.0.0-nightly.2979+fabca84b9",
41
+ "@react-aria/interactions": "3.0.0-nightly.2979+fabca84b9",
42
+ "@react-aria/listbox": "3.12.2-nightly.4691+fabca84b9",
43
+ "@react-aria/utils": "3.0.0-nightly.2979+fabca84b9",
44
+ "@react-aria/virtualizer": "3.10.2-nightly.4691+fabca84b9",
45
+ "@react-spectrum/layout": "3.6.6-nightly.4691+fabca84b9",
46
+ "@react-spectrum/progress": "3.0.0-nightly.2979+fabca84b9",
47
+ "@react-spectrum/text": "3.5.6-nightly.4691+fabca84b9",
48
+ "@react-spectrum/utils": "3.0.0-nightly.2979+fabca84b9",
49
+ "@react-stately/collections": "3.0.0-nightly.2979+fabca84b9",
50
+ "@react-stately/layout": "3.13.10-nightly.4691+fabca84b9",
51
+ "@react-stately/list": "3.10.6-nightly.4691+fabca84b9",
52
+ "@react-stately/virtualizer": "3.7.2-nightly.4691+fabca84b9",
53
+ "@react-types/listbox": "3.4.10-nightly.4691+fabca84b9",
54
+ "@react-types/shared": "3.0.0-nightly.2979+fabca84b9",
55
+ "@spectrum-icons/ui": "3.0.0-nightly.2979+fabca84b9",
56
56
  "@swc/helpers": "^0.5.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@adobe/spectrum-css-temp": "3.0.0-nightly.2973+a48d1673f"
59
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2979+fabca84b9"
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": "a48d1673f2144714e31712e38310a8801edab550"
69
+ "gitHead": "fabca84b95c9c61f9062d5f1e66ebe2c920a2a5d"
70
70
  }
@@ -17,9 +17,9 @@ import {FocusScope} from '@react-aria/focus';
17
17
  // @ts-ignore
18
18
  import intlMessages from '../intl/*.json';
19
19
  import {ListBoxContext} from './ListBoxContext';
20
+ import {ListBoxLayout} from './ListBoxLayout';
20
21
  import {ListBoxOption} from './ListBoxOption';
21
22
  import {ListBoxSection} from './ListBoxSection';
22
- import {ListLayout} from '@react-stately/layout';
23
23
  import {ListState} from '@react-stately/list';
24
24
  import {mergeProps} from '@react-aria/utils';
25
25
  import {ProgressCircle} from '@react-spectrum/progress';
@@ -31,7 +31,7 @@ import {useProvider} from '@react-spectrum/provider';
31
31
  import {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';
32
32
 
33
33
  interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabelingProps, StyleProps {
34
- layout: ListLayout<T>,
34
+ layout: ListBoxLayout<T>,
35
35
  state: ListState<T>,
36
36
  autoFocus?: boolean | FocusStrategy,
37
37
  shouldFocusWrap?: boolean,
@@ -48,17 +48,14 @@ interface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabel
48
48
  }
49
49
 
50
50
  /** @private */
51
- export function useListBoxLayout<T>(): ListLayout<T> {
51
+ export function useListBoxLayout<T>(): ListBoxLayout<T> {
52
52
  let {scale} = useProvider();
53
53
  let layout = useMemo(() =>
54
- new ListLayout<T>({
54
+ new ListBoxLayout<T>({
55
55
  estimatedRowHeight: scale === 'large' ? 48 : 32,
56
56
  estimatedHeadingHeight: scale === 'large' ? 33 : 26,
57
57
  padding: scale === 'large' ? 5 : 4, // TODO: get from DNA
58
- loaderHeight: 40,
59
- placeholderHeight: scale === 'large' ? 48 : 32,
60
- forceSectionHeaders: true,
61
- enableEmptyState: true
58
+ placeholderHeight: scale === 'large' ? 48 : 32
62
59
  })
63
60
  , [scale]);
64
61
 
@@ -0,0 +1,87 @@
1
+ import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer';
2
+ import {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';
3
+ import {Node} from '@react-types/shared';
4
+
5
+ interface ListBoxLayoutProps {
6
+ isLoading?: boolean
7
+ }
8
+
9
+ interface ListBoxLayoutOptions extends ListLayoutOptions {
10
+ placeholderHeight: number,
11
+ padding: number
12
+ }
13
+
14
+ export class ListBoxLayout<T> extends ListLayout<T, ListBoxLayoutProps> {
15
+ private isLoading: boolean = false;
16
+ private placeholderHeight: number;
17
+ private padding: number;
18
+
19
+ constructor(opts: ListBoxLayoutOptions) {
20
+ super(opts);
21
+ this.placeholderHeight = opts.placeholderHeight;
22
+ this.padding = opts.padding;
23
+ }
24
+
25
+ validate(invalidationContext: InvalidationContext<ListBoxLayoutProps>): void {
26
+ this.isLoading = invalidationContext.layoutOptions?.isLoading || false;
27
+ super.validate(invalidationContext);
28
+ }
29
+
30
+ protected buildCollection(): LayoutNode[] {
31
+ let nodes = super.buildCollection(this.padding);
32
+ let y = this.contentSize.height;
33
+
34
+ if (this.isLoading) {
35
+ let rect = new Rect(0, y, this.virtualizer.visibleRect.width, 40);
36
+ let loader = new LayoutInfo('loader', 'loader', rect);
37
+ let node = {
38
+ layoutInfo: loader,
39
+ validRect: loader.rect
40
+ };
41
+ nodes.push(node);
42
+ this.layoutNodes.set(loader.key, node);
43
+ y = loader.rect.maxY;
44
+ }
45
+
46
+ if (nodes.length === 0) {
47
+ let rect = new Rect(0, y, this.virtualizer.visibleRect.width, this.placeholderHeight ?? this.virtualizer.visibleRect.height);
48
+ let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);
49
+ let node = {
50
+ layoutInfo: placeholder,
51
+ validRect: placeholder.rect
52
+ };
53
+ nodes.push(node);
54
+ this.layoutNodes.set(placeholder.key, node);
55
+ y = placeholder.rect.maxY;
56
+ }
57
+
58
+ this.contentSize.height = y + this.padding;
59
+ return nodes;
60
+ }
61
+
62
+ protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {
63
+ // Synthesize a collection node for the header.
64
+ let headerNode = {
65
+ type: 'header',
66
+ key: node.key + ':header',
67
+ parentKey: node.key,
68
+ value: null,
69
+ level: node.level,
70
+ hasChildNodes: false,
71
+ childNodes: [],
72
+ rendered: node.rendered,
73
+ textValue: node.textValue
74
+ };
75
+
76
+ // Build layout node for it and adjust y offset of section children.
77
+ let header = this.buildSectionHeader(headerNode, x, y);
78
+ header.node = headerNode;
79
+ header.layoutInfo.parentKey = node.key;
80
+ this.layoutNodes.set(headerNode.key, header);
81
+ y += header.layoutInfo.rect.height;
82
+
83
+ let section = super.buildSection(node, x, y);
84
+ section.children.unshift(header);
85
+ return section;
86
+ }
87
+ }