@react-spectrum/listbox 3.12.10-nightly.4700 → 3.12.10-nightly.4704
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ListBoxBase.main.js.map +1 -1
- package/dist/ListBoxBase.module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +20 -20
- package/src/ListBoxBase.tsx +2 -2
|
@@ -1 +1 @@
|
|
|
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,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,kCAAS,EAAE;QAC9B,GAAG,KAAK;QACR,gBAAgB;QAChB,eAAe;IACjB,GAAG,OAAO;IACV,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IAKjC,IAAI,gBAAgB,CAAA,GAAA,wBAAU,EAAE,CAAC,QAAc,cAAoB,UAAkB;YAQ3D;QAPxB,IAAI,aAAa,QAAQ,KAAK,WAC5B,qBACE,0DAAC,CAAA,GAAA,wCAAa;YACZ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E,CAAC,MAAM;QAClB,IAAI,SAAS,QACX,qBAAO,0DAAC,CAAA,GAAA,uCAAY;YAAE,MAAM;;aACvB,IAAI,SAAS,UAClB,qBAAO,0DAAC;aACH,IAAI,SAAS,eAClB,qBAAO,0DAAC;IAEZ,GAAG,EAAE;AAKf;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAGtC,SAAS;IACP,IAAI,SAAC,KAAK,EAAC,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 {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 let focusedKey = state.selectionManager.focusedKey;\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n persistedKeys={persistedKeys}\n autoFocus={!!props.autoFocus || undefined}\n 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
|
+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;IACP,IAAI,SAAC,KAAK,EAAC,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, RefObject, StyleProps} from '@react-types/shared';\nimport {AriaListBoxOptions, useListBox} from '@react-aria/listbox';\nimport {classNames, useStyleProps} from '@react-spectrum/utils';\nimport {FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListBoxContext} from './ListBoxContext';\nimport {ListBoxLayout} from './ListBoxLayout';\nimport {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useContext, useMemo} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\ninterface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabelingProps, StyleProps {\n layout: ListBoxLayout<T>,\n state: ListState<T>,\n autoFocus?: boolean | FocusStrategy,\n shouldFocusWrap?: boolean,\n shouldSelectOnPressUp?: boolean,\n focusOnPointerEnter?: boolean,\n domProps?: HTMLAttributes<HTMLElement>,\n disallowEmptySelection?: boolean,\n shouldUseVirtualFocus?: boolean,\n isLoading?: boolean,\n showLoadingSpinner?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(): ListBoxLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListBoxLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n placeholderHeight: scale === 'large' ? 48 : 32\n })\n , [scale]);\n\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n layoutDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n\n // This overrides collection view's renderWrapper to support hierarchy of items in sections.\n // The header is extracted from the children so it can receive ARIA labeling properties.\n type View = ReusableView<Node<T>, ReactElement>;\n let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {\n if (reusableView.viewType === 'section') {\n return (\n <ListBoxSection\n key={reusableView.key}\n item={reusableView.content}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n headerLayoutInfo={children.find(c => c.viewType === 'header')?.layoutInfo}>\n {renderChildren(children.filter(c => c.viewType === 'item'))}\n </ListBoxSection>\n );\n }\n\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n }, []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n persistedKeys={persistedKeys}\n autoFocus={!!props.autoFocus || undefined}\n 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 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AAwCM,SAAS;IACd,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE,IACnB,IAAI,CAAA,GAAA,wCAAY,EAAK;YACnB,oBAAoB,UAAU,UAAU,KAAK;YAC7C,wB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;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 let focusedKey = state.selectionManager.focusedKey;\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n persistedKeys={persistedKeys}\n autoFocus={!!props.autoFocus || undefined}\n 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,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,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACjD,IAAI,aAAa,mBAAmB,qBAAqB;IACzD,IAAI,cAAc,MAChB,OAAO;IAGT,qBACE,gCAAC;QACC,uEAAuE;QACvE,iEAAiE;QACjE,MAAK;OACJ;AAGP","sources":["packages/@react-spectrum/listbox/src/ListBoxBase.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaLabelingProps, DOMProps, FocusStrategy, Node, RefObject, StyleProps} from '@react-types/shared';\nimport {AriaListBoxOptions, useListBox} from '@react-aria/listbox';\nimport {classNames, useStyleProps} from '@react-spectrum/utils';\nimport {FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListBoxContext} from './ListBoxContext';\nimport {ListBoxLayout} from './ListBoxLayout';\nimport {ListBoxOption} from './ListBoxOption';\nimport {ListBoxSection} from './ListBoxSection';\nimport {ListState} from '@react-stately/list';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useContext, useMemo} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\ninterface ListBoxBaseProps<T> extends AriaListBoxOptions<T>, DOMProps, AriaLabelingProps, StyleProps {\n layout: ListBoxLayout<T>,\n state: ListState<T>,\n autoFocus?: boolean | FocusStrategy,\n shouldFocusWrap?: boolean,\n shouldSelectOnPressUp?: boolean,\n focusOnPointerEnter?: boolean,\n domProps?: HTMLAttributes<HTMLElement>,\n disallowEmptySelection?: boolean,\n shouldUseVirtualFocus?: boolean,\n isLoading?: boolean,\n showLoadingSpinner?: boolean,\n onLoadMore?: () => void,\n renderEmptyState?: () => ReactNode,\n onScroll?: () => void\n}\n\n/** @private */\nexport function useListBoxLayout<T>(): ListBoxLayout<T> {\n let {scale} = useProvider();\n let layout = useMemo(() =>\n new ListBoxLayout<T>({\n estimatedRowHeight: scale === 'large' ? 48 : 32,\n estimatedHeadingHeight: scale === 'large' ? 33 : 26,\n padding: scale === 'large' ? 5 : 4, // TODO: get from DNA\n placeholderHeight: scale === 'large' ? 48 : 32\n })\n , [scale]);\n\n return layout;\n}\n\n/** @private */\nfunction ListBoxBase<T>(props: ListBoxBaseProps<T>, ref: RefObject<HTMLDivElement | null>) {\n let {layout, state, shouldFocusOnHover, shouldUseVirtualFocus, domProps = {}, isLoading, showLoadingSpinner = isLoading, onScroll, renderEmptyState} = props;\n let {listBoxProps} = useListBox({\n ...props,\n layoutDelegate: layout,\n isVirtualized: true\n }, state, ref);\n let {styleProps} = useStyleProps(props);\n\n // This overrides collection view's renderWrapper to support hierarchy of items in sections.\n // The header is extracted from the children so it can receive ARIA labeling properties.\n type View = ReusableView<Node<T>, ReactElement>;\n let renderWrapper = useCallback((parent: View, reusableView: View, children: View[], renderChildren: (views: View[]) => ReactElement[]) => {\n if (reusableView.viewType === 'section') {\n return (\n <ListBoxSection\n key={reusableView.key}\n item={reusableView.content}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n headerLayoutInfo={children.find(c => c.viewType === 'header')?.layoutInfo}>\n {renderChildren(children.filter(c => c.viewType === 'item'))}\n </ListBoxSection>\n );\n }\n\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n }, []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n return (\n <ListBoxContext.Provider value={{state, renderEmptyState, shouldFocusOnHover, shouldUseVirtualFocus}}>\n <FocusScope>\n <Virtualizer\n {...styleProps}\n {...mergeProps(listBoxProps, domProps)}\n ref={ref}\n persistedKeys={persistedKeys}\n autoFocus={!!props.autoFocus || undefined}\n 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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InvalidationContext } from "@react-stately/virtualizer";
|
|
2
2
|
import { LayoutNode, ListLayout, ListLayoutOptions } from "@react-stately/layout";
|
|
3
|
-
import { Node, AriaLabelingProps, DOMProps, FocusStrategy, StyleProps, DOMRef } from "@react-types/shared";
|
|
3
|
+
import { Node, AriaLabelingProps, DOMProps, FocusStrategy, RefObject, StyleProps, DOMRef } from "@react-types/shared";
|
|
4
4
|
import { AriaListBoxOptions } from "@react-aria/listbox";
|
|
5
5
|
import { ListState } from "@react-stately/list";
|
|
6
|
-
import { HTMLAttributes, ReactElement, ReactNode
|
|
6
|
+
import { HTMLAttributes, ReactElement, ReactNode } from "react";
|
|
7
7
|
import { SpectrumListBoxProps } from "@react-types/listbox";
|
|
8
8
|
interface ListBoxLayoutProps {
|
|
9
9
|
isLoading?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/listbox",
|
|
3
|
-
"version": "3.12.10-nightly.
|
|
3
|
+
"version": "3.12.10-nightly.4704+546ffa41f",
|
|
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.
|
|
40
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
41
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
42
|
-
"@react-aria/listbox": "3.12.2-nightly.
|
|
43
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
44
|
-
"@react-aria/virtualizer": "3.10.2-nightly.
|
|
45
|
-
"@react-spectrum/layout": "3.6.6-nightly.
|
|
46
|
-
"@react-spectrum/progress": "3.0.0-nightly.
|
|
47
|
-
"@react-spectrum/text": "3.5.6-nightly.
|
|
48
|
-
"@react-spectrum/utils": "3.0.0-nightly.
|
|
49
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
50
|
-
"@react-stately/layout": "3.13.10-nightly.
|
|
51
|
-
"@react-stately/list": "3.10.6-nightly.
|
|
52
|
-
"@react-stately/virtualizer": "3.7.2-nightly.
|
|
53
|
-
"@react-types/listbox": "3.4.10-nightly.
|
|
54
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
55
|
-
"@spectrum-icons/ui": "3.0.0-nightly.
|
|
39
|
+
"@react-aria/focus": "3.0.0-nightly.2992+546ffa41f",
|
|
40
|
+
"@react-aria/i18n": "3.0.0-nightly.2992+546ffa41f",
|
|
41
|
+
"@react-aria/interactions": "3.0.0-nightly.2992+546ffa41f",
|
|
42
|
+
"@react-aria/listbox": "3.12.2-nightly.4704+546ffa41f",
|
|
43
|
+
"@react-aria/utils": "3.0.0-nightly.2992+546ffa41f",
|
|
44
|
+
"@react-aria/virtualizer": "3.10.2-nightly.4704+546ffa41f",
|
|
45
|
+
"@react-spectrum/layout": "3.6.6-nightly.4704+546ffa41f",
|
|
46
|
+
"@react-spectrum/progress": "3.0.0-nightly.2992+546ffa41f",
|
|
47
|
+
"@react-spectrum/text": "3.5.6-nightly.4704+546ffa41f",
|
|
48
|
+
"@react-spectrum/utils": "3.0.0-nightly.2992+546ffa41f",
|
|
49
|
+
"@react-stately/collections": "3.0.0-nightly.2992+546ffa41f",
|
|
50
|
+
"@react-stately/layout": "3.13.10-nightly.4704+546ffa41f",
|
|
51
|
+
"@react-stately/list": "3.10.6-nightly.4704+546ffa41f",
|
|
52
|
+
"@react-stately/virtualizer": "3.7.2-nightly.4704+546ffa41f",
|
|
53
|
+
"@react-types/listbox": "3.4.10-nightly.4704+546ffa41f",
|
|
54
|
+
"@react-types/shared": "3.0.0-nightly.2992+546ffa41f",
|
|
55
|
+
"@spectrum-icons/ui": "3.0.0-nightly.2992+546ffa41f",
|
|
56
56
|
"@swc/helpers": "^0.5.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@adobe/spectrum-css-temp": "3.0.0-nightly.
|
|
59
|
+
"@adobe/spectrum-css-temp": "3.0.0-nightly.2992+546ffa41f"
|
|
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": "
|
|
69
|
+
"gitHead": "546ffa41f7d1d3a566950a14d8f46cf726891220"
|
|
70
70
|
}
|
package/src/ListBoxBase.tsx
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {AriaLabelingProps, DOMProps, FocusStrategy, Node, StyleProps} from '@react-types/shared';
|
|
13
|
+
import {AriaLabelingProps, DOMProps, FocusStrategy, Node, RefObject, StyleProps} from '@react-types/shared';
|
|
14
14
|
import {AriaListBoxOptions, useListBox} from '@react-aria/listbox';
|
|
15
15
|
import {classNames, useStyleProps} from '@react-spectrum/utils';
|
|
16
16
|
import {FocusScope} from '@react-aria/focus';
|
|
@@ -23,7 +23,7 @@ import {ListBoxSection} from './ListBoxSection';
|
|
|
23
23
|
import {ListState} from '@react-stately/list';
|
|
24
24
|
import {mergeProps} from '@react-aria/utils';
|
|
25
25
|
import {ProgressCircle} from '@react-spectrum/progress';
|
|
26
|
-
import React, {HTMLAttributes, ReactElement, ReactNode,
|
|
26
|
+
import React, {HTMLAttributes, ReactElement, ReactNode, 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 {useLocalizedStringFormatter} from '@react-aria/i18n';
|