@react-spectrum/breadcrumbs 3.2.2 → 3.2.6

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/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;;;ACFD,4CAAiB;AACf,0BAAwB,6BADT;AAEf,wCAAsC,2CAFvB;AAGf,iBAAe,oBAHA;AAIf,+BAA6B,kCAJd;AAKf,2BAAyB,8BALV;AAMf,mCAAiC,sCANlB;AAOf,gBAAc,mBAPC;AAQf,gBAAc,mBARC;AASf,gBAAc,mBATC;AAUf,iCAA+B,oCAVhB;AAWf,kCAAgC,qCAXjB;AAYf,qCAAmC,wCAZpB;AAaf,iCAA+B,oCAbhB;AAcf,iBAAe,oBAdA;AAef,iBAAe,oBAfA;AAgBf,yBAAuB;AAhBR,CAAjB;;;ACuBO,SAASG,uDAAT,CAAwBC,KAAxB,EAAoD;AACzD,MAAI;AACFC,IAAAA,QADE;AAEFC,IAAAA,SAFE;AAGFC,IAAAA;AAHE,MAIAH,KAJJ;AAMA,MAAI;AAACI,IAAAA;AAAD,MAAcC,SAAS,EAA3B;AACA,MAAIC,GAAG,GAAGC,MAAM,EAAhB;AACA,MAAI;AAACC,IAAAA;AAAD,MAAcC,iBAAiB,iCAC9BT,KAD8B;AAEjCU,IAAAA,WAAW,EAAE,OAAOT,QAAP,KAAoB,QAApB,GAA+B,MAA/B,GAAwC;AAFpB,MAGhCK,GAHgC,CAAnC;AAIA,MAAI;AAACK,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA0BC,QAAQ,CAACb,KAAD,CAAtC;;AAEA,MA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AkB;AAAA;;AACnD,QAAIpF,SAAS,GAAGoF,KAAK,KAAKH,SAA1B;AACA,QAAIP,GAAG,iBAAG3C,KAAK,CAAC2C,GAAT,yBAAgBU,KAAvB;;AACA,QAAIC,OAAO,GAAG,MAAM;AAClB,UAAI3D,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAACgD,GAAD,CAAR;AACD;AACF,KAJD;;AAMA,wBACE;AACE,MAAA,GAAG,EAAEA,GADP;AAEE,MAAA,SAAS,EACPxD,UAAU,qDAER,2BAFQ;AAHd,oBAQE;AACE,MAAA,SAAS,EAAElB,SADb;AAEE,MAAA,UAAU,EAAEC,UAFd;AAGE,MAAA,OAAO,EAAEoF;AAHX,OAIGtD,KAAK,CAACjC,KAAN,CAAYC,QAJf,CARF,CADF;AAiBD,GA1BqB,CAAtB;AA4BA,sBACE,4DACM4C,UADN,EAEMF,QAFN;AAGE,IAAA,GAAG,EAAEP;AAHP,mBAIE;AACE,IAAA,GAAG,EAAEE,OADP;AAEE,IAAA,SAAS,EACPlB,UAAU,qDAER,sBAFQ,EAGR;AACE,qCAA+BK,IAAI,KAAK,GAD1C;AAEE,sCAAgCA,IAAI,KAAK,GAF3C;AAGE,yCAAmCC,WAHrC;AAIE,wCAAkCC,QAJpC;AAKE,qBAAexB;AALjB,KAHQ,EAUR0C,UAAU,CAAC1B,SAVH;AAHd,KAgBGiE,eAhBH,CAJF,CADF;AAyBD;AAED;;;;;AAGA,IAAII,WAAY,gBAAGzE,MAAK,CAAC0E,UAAN,CAAiBlE,gDAAjB,CAAnB","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./node_modules/@adobe/spectrum-css-temp/components/breadcrumb/vars.css","./packages/@react-spectrum/breadcrumbs/src/BreadcrumbItem.tsx","./packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\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@import './index.css';\n@import './skin.css';\n","/*\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 {BreadcrumbItemProps} from '@react-types/breadcrumbs';\nimport ChevronRightSmall from '@spectrum-icons/ui/ChevronRightSmall';\nimport {classNames, getWrappedElement} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {Fragment, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbItem} from '@react-aria/breadcrumbs';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef();\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\n )\n } />\n }\n </Fragment>\n );\n}\n","/*\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 */\nimport {ActionButton} from '@react-spectrum/button';\nimport {BreadcrumbItem} from './BreadcrumbItem';\nimport {classNames, useDOMRef, useStyleProps, useValueEffect} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, ReactElement, useCallback, useRef} from 'react';\nimport {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbs} from '@react-aria/breadcrumbs';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\n\nconst MIN_VISIBLE_ITEMS = 1;\nconst MAX_VISIBLE_ITEMS = 4;\n\nfunction Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {\n props = useProviderProps(props);\n let {\n size = 'L',\n isMultiline,\n children,\n showRoot,\n isDisabled,\n onAction,\n ...otherProps\n } = props;\n\n // Not using React.Children.toArray because it mutates the key prop.\n let childArray: ReactElement[] = [];\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n childArray.push(child);\n }\n });\n\n let domRef = useDOMRef(ref);\n let listRef = useRef<HTMLUListElement>(null);\n\n let [visibleItems, setVisibleItems] = useValueEffect(childArray.length);\n\n let {navProps} = useBreadcrumbs(props);\n let {styleProps} = useStyleProps(otherProps);\n\n let updateOverflow = useCallback(() => {\n let computeVisibleItems = (visibleItems: number) => {\n let listItems = Array.from(listRef.current.children) as HTMLLIElement[];\n let containerWidth = listRef.current.offsetWidth;\n let isShowingMenu = childArray.length > visibleItems;\n let calculatedWidth = 0;\n let newVisibleItems = 0;\n let maxVisibleItems = MAX_VISIBLE_ITEMS;\n\n if (showRoot) {\n calculatedWidth += listItems.shift().offsetWidth;\n newVisibleItems++;\n }\n\n if (isShowingMenu) {\n calculatedWidth += listItems.shift().offsetWidth;\n maxVisibleItems--;\n }\n\n if (showRoot && calculatedWidth >= containerWidth) {\n newVisibleItems--;\n }\n\n // TODO: what if multiline and only one breadcrumb??\n if (isMultiline) {\n listItems.pop();\n newVisibleItems++;\n } else {\n // Ensure the last breadcrumb isn't truncated when we measure it.\n let last = listItems.pop();\n last.style.overflow = 'visible';\n\n calculatedWidth += last.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n\n last.style.overflow = '';\n }\n\n for (let breadcrumb of listItems.reverse()) {\n calculatedWidth += breadcrumb.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n }\n\n return Math.max(MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));\n };\n\n setVisibleItems(function *() {\n // Update to show all items.\n yield childArray.length;\n\n // Measure, and update to show the items that fit.\n let newVisibleItems = computeVisibleItems(childArray.length);\n yield newVisibleItems;\n\n // If the number of items is less than the number of children,\n // then update again to ensure that the menu fits.\n if (newVisibleItems < childArray.length && newVisibleItems > 1) {\n yield computeVisibleItems(newVisibleItems);\n }\n });\n }, [listRef, children, setVisibleItems, showRoot, isMultiline]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\n useLayoutEffect(updateOverflow, [children]);\n\n let contents = childArray;\n if (childArray.length > visibleItems) {\n let selectedItem = childArray[childArray.length - 1];\n let selectedKey = selectedItem.key ?? childArray.length - 1;\n let onMenuAction = (key: Key) => {\n // Don't fire onAction when clicking on the last item\n if (key !== selectedKey && onAction) {\n onAction(key);\n }\n };\n\n let menuItem = (\n <BreadcrumbItem key=\"menu\">\n <MenuTrigger>\n <ActionButton\n aria-label=\"…\"\n isQuiet\n isDisabled={isDisabled}>\n <FolderBreadcrumb />\n </ActionButton>\n <Menu selectionMode=\"single\" selectedKeys={[selectedKey]} onAction={onMenuAction}>\n {childArray}\n </Menu>\n </MenuTrigger>\n </BreadcrumbItem>\n );\n\n contents = [menuItem];\n let breadcrumbs = [...childArray];\n let endItems = visibleItems;\n if (showRoot && visibleItems > 1) {\n contents.unshift(breadcrumbs.shift());\n endItems--;\n }\n contents.push(...breadcrumbs.slice(-endItems));\n }\n\n let lastIndex = contents.length - 1;\n let breadcrumbItems = contents.map((child, index) => {\n let isCurrent = index === lastIndex;\n let key = child.key ?? index;\n let onPress = () => {\n if (onAction) {\n onAction(key);\n }\n };\n\n return (\n <li\n key={key}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-item'\n )\n }>\n <BreadcrumbItem\n isCurrent={isCurrent}\n isDisabled={isDisabled}\n onPress={onPress}>\n {child.props.children}\n </BreadcrumbItem>\n </li>\n );\n });\n\n return (\n <nav\n {...styleProps}\n {...navProps}\n ref={domRef}>\n <ul\n ref={listRef}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs',\n {\n 'spectrum-Breadcrumbs--small': size === 'S',\n 'spectrum-Breadcrumbs--medium': size === 'M',\n 'spectrum-Breadcrumbs--multiline': isMultiline,\n 'spectrum-Breadcrumbs--showRoot': showRoot,\n 'is-disabled': isDisabled\n },\n styleProps.className\n )\n }>\n {breadcrumbItems}\n </ul>\n </nav>\n );\n}\n\n/**\n * Breadcrumbs show hierarchy and navigational context for a user’s location within an application.\n */\nlet _Breadcrumbs = React.forwardRef(Breadcrumbs);\nexport {_Breadcrumbs as Breadcrumbs};\n"],"names":["$parcel$interopDefault","a","__esModule","default","BreadcrumbItem","props","children","isCurrent","isDisabled","direction","useLocale","ref","useRef","itemProps","useBreadcrumbItem","elementType","hoverProps","isHovered","useHover","element","React","cloneElement","getWrappedElement","mergeProps","className","classNames","MIN_VISIBLE_ITEMS","MAX_VISIBLE_ITEMS","Breadcrumbs","useProviderProps","size","isMultiline","showRoot","onAction","otherProps","childArray","Children","forEach","child","isValidElement","push","domRef","useDOMRef","listRef","visibleItems","setVisibleItems","useValueEffect","length","navProps","useBreadcrumbs","styleProps","useStyleProps","updateOverflow","useCallback","computeVisibleItems","listItems","Array","from","current","containerWidth","offsetWidth","isShowingMenu","calculatedWidth","newVisibleItems","maxVisibleItems","shift","pop","last","style","overflow","breadcrumb","reverse","Math","max","min","useResizeObserver","onResize","useLayoutEffect","contents","selectedItem","selectedKey","key","onMenuAction","menuItem","breadcrumbs","endItems","unshift","slice","lastIndex","breadcrumbItems","map","index","onPress","_Breadcrumbs","forwardRef"],"version":3,"file":"main.js.map"}
1
+ {"mappings":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,GAAG,IAAG,IAAS,GAAT,KAAK,CAAC,GAAG,cAAT,IAAS,cAAT,IAAS,GAAI,KAAK;QAC5B,GAAG,CAAC,OAAO,OAAS,CAAC;YACnB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,GAAG;QAEhB,CAAC;QAED,MAAM,oEACH,CAAE;YACD,GAAG,EAAE,GAAG;YACR,SAAS,EACP,oCAAU,CACR,gEAAM,EACN,CAA2B;8EAG9B,yCAAc;YACb,SAAS,EAAE,SAAS;YACpB,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,OAAO;WACf,KAAK,CAAC,KAAK,CAAC,QAAQ;IAI7B,CAAC;IAED,MAAM,oEACH,CAAG;WACE,UAAU;WACV,QAAQ;QACZ,GAAG,EAAE,MAAM;0EACV,CAAE;QACD,GAAG,EAAE,OAAO;QACZ,SAAS,EACP,oCAAU,CACR,gEAAM,EACN,CAAsB,uBACtB,CAAC;YACC,CAA6B,8BAAE,IAAI,KAAK,CAAG;YAC3C,CAA8B,+BAAE,IAAI,KAAK,CAAG;YAC5C,CAAiC,kCAAE,WAAW;YAC9C,CAAgC,iCAAE,QAAQ;YAC1C,CAAa,cAAE,UAAU;QAC3B,CAAC,EACD,UAAU,CAAC,SAAS;OAGvB,eAAe;AAIxB,CAAC;AAED,EAEG,AAFH;;CAEG,AAFH,EAEG,CACH,GAAG,CAAC,wCAAY,iBAAG,sCAAK,CAAC,UAAU,CAAC,iCAAW","sources":["packages/@react-spectrum/breadcrumbs/src/index.ts","packages/@react-spectrum/breadcrumbs/src/Breadcrumbs.tsx","packages/@react-spectrum/breadcrumbs/src/BreadcrumbItem.tsx","packages/@adobe/spectrum-css-temp/components/breadcrumb/vars.css"],"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\n/// <reference types=\"css-module-types\" />\n\nexport * from './Breadcrumbs';\nexport {Item} from '@react-stately/collections';\n","/*\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 */\nimport {ActionButton} from '@react-spectrum/button';\nimport {BreadcrumbItem} from './BreadcrumbItem';\nimport {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport FolderBreadcrumb from '@spectrum-icons/ui/FolderBreadcrumb';\nimport {Menu, MenuTrigger} from '@react-spectrum/menu';\nimport React, {Key, ReactElement, useCallback, useRef} from 'react';\nimport {SpectrumBreadcrumbsProps} from '@react-types/breadcrumbs';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbs} from '@react-aria/breadcrumbs';\nimport {useLayoutEffect, useValueEffect} from '@react-aria/utils';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useResizeObserver} from '@react-aria/utils';\n\nconst MIN_VISIBLE_ITEMS = 1;\nconst MAX_VISIBLE_ITEMS = 4;\n\nfunction Breadcrumbs<T>(props: SpectrumBreadcrumbsProps<T>, ref: DOMRef) {\n props = useProviderProps(props);\n let {\n size = 'L',\n isMultiline,\n children,\n showRoot,\n isDisabled,\n onAction,\n ...otherProps\n } = props;\n\n // Not using React.Children.toArray because it mutates the key prop.\n let childArray: ReactElement[] = [];\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n childArray.push(child);\n }\n });\n\n let domRef = useDOMRef(ref);\n let listRef = useRef<HTMLUListElement>(null);\n\n let [visibleItems, setVisibleItems] = useValueEffect(childArray.length);\n\n let {navProps} = useBreadcrumbs(props);\n let {styleProps} = useStyleProps(otherProps);\n\n let updateOverflow = useCallback(() => {\n let computeVisibleItems = (visibleItems: number) => {\n // Refs can be null at runtime.\n let currListRef: HTMLUListElement | null = listRef.current;\n if (!currListRef) {\n return;\n }\n\n let listItems = Array.from(currListRef.children) as HTMLLIElement[];\n let containerWidth = currListRef.offsetWidth;\n let isShowingMenu = childArray.length > visibleItems;\n let calculatedWidth = 0;\n let newVisibleItems = 0;\n let maxVisibleItems = MAX_VISIBLE_ITEMS;\n\n if (showRoot) {\n calculatedWidth += listItems.shift().offsetWidth;\n newVisibleItems++;\n }\n\n if (isShowingMenu) {\n calculatedWidth += listItems.shift().offsetWidth;\n maxVisibleItems--;\n }\n\n if (showRoot && calculatedWidth >= containerWidth) {\n newVisibleItems--;\n }\n\n // TODO: what if multiline and only one breadcrumb??\n if (isMultiline) {\n listItems.pop();\n newVisibleItems++;\n } else {\n // Ensure the last breadcrumb isn't truncated when we measure it.\n let last = listItems.pop();\n last.style.overflow = 'visible';\n\n calculatedWidth += last.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n\n last.style.overflow = '';\n }\n\n for (let breadcrumb of listItems.reverse()) {\n calculatedWidth += breadcrumb.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n }\n\n return Math.max(MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));\n };\n\n setVisibleItems(function *() {\n // Update to show all items.\n yield childArray.length;\n\n // Measure, and update to show the items that fit.\n let newVisibleItems = computeVisibleItems(childArray.length);\n yield newVisibleItems;\n\n // If the number of items is less than the number of children,\n // then update again to ensure that the menu fits.\n if (newVisibleItems < childArray.length && newVisibleItems > 1) {\n yield computeVisibleItems(newVisibleItems);\n }\n });\n }, [listRef, children, setVisibleItems, showRoot, isMultiline]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\n useLayoutEffect(updateOverflow, [children]);\n\n let contents = childArray;\n if (childArray.length > visibleItems) {\n let selectedItem = childArray[childArray.length - 1];\n let selectedKey = selectedItem.key ?? childArray.length - 1;\n let onMenuAction = (key: Key) => {\n // Don't fire onAction when clicking on the last item\n if (key !== selectedKey && onAction) {\n onAction(key);\n }\n };\n\n let menuItem = (\n <BreadcrumbItem key=\"menu\">\n <MenuTrigger>\n <ActionButton\n aria-label=\"…\"\n isQuiet\n isDisabled={isDisabled}>\n <FolderBreadcrumb />\n </ActionButton>\n <Menu selectionMode=\"single\" selectedKeys={[selectedKey]} onAction={onMenuAction}>\n {childArray}\n </Menu>\n </MenuTrigger>\n </BreadcrumbItem>\n );\n\n contents = [menuItem];\n let breadcrumbs = [...childArray];\n let endItems = visibleItems;\n if (showRoot && visibleItems > 1) {\n contents.unshift(breadcrumbs.shift());\n endItems--;\n }\n contents.push(...breadcrumbs.slice(-endItems));\n }\n\n let lastIndex = contents.length - 1;\n let breadcrumbItems = contents.map((child, index) => {\n let isCurrent = index === lastIndex;\n let key = child.key ?? index;\n let onPress = () => {\n if (onAction) {\n onAction(key);\n }\n };\n\n return (\n <li\n key={key}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-item'\n )\n }>\n <BreadcrumbItem\n isCurrent={isCurrent}\n isDisabled={isDisabled}\n onPress={onPress}>\n {child.props.children}\n </BreadcrumbItem>\n </li>\n );\n });\n\n return (\n <nav\n {...styleProps}\n {...navProps}\n ref={domRef}>\n <ul\n ref={listRef}\n className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs',\n {\n 'spectrum-Breadcrumbs--small': size === 'S',\n 'spectrum-Breadcrumbs--medium': size === 'M',\n 'spectrum-Breadcrumbs--multiline': isMultiline,\n 'spectrum-Breadcrumbs--showRoot': showRoot,\n 'is-disabled': isDisabled\n },\n styleProps.className\n )\n }>\n {breadcrumbItems}\n </ul>\n </nav>\n );\n}\n\n/**\n * Breadcrumbs show hierarchy and navigational context for a user’s location within an application.\n */\nlet _Breadcrumbs = React.forwardRef(Breadcrumbs);\nexport {_Breadcrumbs as Breadcrumbs};\n","/*\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 {BreadcrumbItemProps} from '@react-types/breadcrumbs';\nimport ChevronRightSmall from '@spectrum-icons/ui/ChevronRightSmall';\nimport {classNames, getWrappedElement} from '@react-spectrum/utils';\nimport {FocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {Fragment, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/breadcrumb/vars.css';\nimport {useBreadcrumbItem} from '@react-aria/breadcrumbs';\nimport {useHover} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n let {\n children,\n isCurrent,\n isDisabled\n } = props;\n\n let {direction} = useLocale();\n let ref = useRef();\n let {itemProps} = useBreadcrumbItem({\n ...props,\n elementType: typeof children === 'string' ? 'span' : 'a'\n }, ref);\n let {hoverProps, isHovered} = useHover(props);\n\n let element = React.cloneElement(\n getWrappedElement(children),\n {\n ...mergeProps(itemProps, hoverProps),\n ref,\n className:\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemLink',\n {\n 'is-disabled': !isCurrent && isDisabled,\n 'is-hovered': isHovered\n }\n )\n }\n );\n\n return (\n <Fragment>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n {element}\n </FocusRing>\n {isCurrent === false &&\n <ChevronRightSmall\n UNSAFE_className={\n classNames(\n styles,\n 'spectrum-Breadcrumbs-itemSeparator',\n {\n 'is-reversed': direction === 'rtl'\n }\n )\n } />\n }\n </Fragment>\n );\n}\n","/*\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@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,265 +1,275 @@
1
- import { useProviderProps } from "@react-spectrum/provider";
2
- import { Menu, MenuTrigger } from "@react-spectrum/menu";
3
- import _spectrumIconsUiFolderBreadcrumb from "@spectrum-icons/ui/FolderBreadcrumb";
4
- import { useLocale } from "@react-aria/i18n";
5
- import { useHover } from "@react-aria/interactions";
6
- import { useBreadcrumbItem, useBreadcrumbs } from "@react-aria/breadcrumbs";
7
- import _react, { Fragment, useRef, useCallback } from "react";
8
- import { mergeProps, useLayoutEffect, useResizeObserver } from "@react-aria/utils";
9
- import { FocusRing } from "@react-aria/focus";
10
- import { classNames, getWrappedElement, useDOMRef, useStyleProps, useValueEffect } from "@react-spectrum/utils";
11
- import _spectrumIconsUiChevronRightSmall from "@spectrum-icons/ui/ChevronRightSmall";
12
- import { ActionButton } from "@react-spectrum/button";
13
- import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
14
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
15
- import { Item } from "@react-stately/collections";
16
- export { Item };
17
1
  import "./main.css";
2
+ import {Item as $7affa7233923f57e$re_export$Item} from "@react-stately/collections";
3
+ import {ActionButton as $5Ji3d$ActionButton} from "@react-spectrum/button";
4
+ import {useDOMRef as $5Ji3d$useDOMRef, useStyleProps as $5Ji3d$useStyleProps, classNames as $5Ji3d$classNames, getWrappedElement as $5Ji3d$getWrappedElement} from "@react-spectrum/utils";
5
+ import $5Ji3d$spectrumiconsuiFolderBreadcrumb from "@spectrum-icons/ui/FolderBreadcrumb";
6
+ import {MenuTrigger as $5Ji3d$MenuTrigger, Menu as $5Ji3d$Menu} from "@react-spectrum/menu";
7
+ import $5Ji3d$react, {useRef as $5Ji3d$useRef, useCallback as $5Ji3d$useCallback, Fragment as $5Ji3d$Fragment} from "react";
8
+ import {useBreadcrumbs as $5Ji3d$useBreadcrumbs, useBreadcrumbItem as $5Ji3d$useBreadcrumbItem} from "@react-aria/breadcrumbs";
9
+ import {useValueEffect as $5Ji3d$useValueEffect, useResizeObserver as $5Ji3d$useResizeObserver, useLayoutEffect as $5Ji3d$useLayoutEffect, mergeProps as $5Ji3d$mergeProps} from "@react-aria/utils";
10
+ import {useProviderProps as $5Ji3d$useProviderProps} from "@react-spectrum/provider";
11
+ import $5Ji3d$spectrumiconsuiChevronRightSmall from "@spectrum-icons/ui/ChevronRightSmall";
12
+ import {FocusRing as $5Ji3d$FocusRing} from "@react-aria/focus";
13
+ import {useHover as $5Ji3d$useHover} from "@react-aria/interactions";
14
+ import {useLocale as $5Ji3d$useLocale} from "@react-aria/i18n";
18
15
 
19
16
  function $parcel$interopDefault(a) {
20
17
  return a && a.__esModule ? a.default : a;
21
18
  }
22
-
23
- // ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/breadcrumb/vars.css
24
- var $a5baa762b556403ac2f1cf2374238631$exports = {};
25
- $a5baa762b556403ac2f1cf2374238631$exports = {
26
- "spectrum-Breadcrumbs": "_spectrum-Breadcrumbs_e7b3e",
27
- "spectrum-Breadcrumbs-itemSeparator": "_spectrum-Breadcrumbs-itemSeparator_e7b3e",
28
- "is-reversed": "_is-reversed_e7b3e",
29
- "spectrum-Breadcrumbs-item": "_spectrum-Breadcrumbs-item_e7b3e",
30
- "spectrum-ActionButton": "_spectrum-ActionButton_e7b3e",
31
- "spectrum-Breadcrumbs-itemLink": "_spectrum-Breadcrumbs-itemLink_e7b3e",
32
- "is-hovered": "_is-hovered_e7b3e",
33
- "focus-ring": "_focus-ring_e7b3e",
34
- "is-dragged": "_is-dragged_e7b3e",
35
- "spectrum-Breadcrumbs--small": "_spectrum-Breadcrumbs--small_e7b3e",
36
- "spectrum-Breadcrumbs--medium": "_spectrum-Breadcrumbs--medium_e7b3e",
37
- "spectrum-Breadcrumbs--multiline": "_spectrum-Breadcrumbs--multiline_e7b3e",
38
- "spectrum-Heading--pageTitle": "_spectrum-Heading--pageTitle_e7b3e",
39
- "is-disabled": "_is-disabled_e7b3e",
40
- "is-selected": "_is-selected_e7b3e",
41
- "spectrum-Breadcrumb": "_spectrum-Breadcrumb_e7b3e"
42
- };
43
- var $a5baa762b556403ac2f1cf2374238631$$interop$default = $parcel$interopDefault($a5baa762b556403ac2f1cf2374238631$exports);
44
-
45
- function $dacda927994e51fbe8a71ffbc$export$BreadcrumbItem(props) {
46
- let {
47
- children,
48
- isCurrent,
49
- isDisabled
50
- } = props;
51
- let {
52
- direction
53
- } = useLocale();
54
- let ref = useRef();
55
- let {
56
- itemProps
57
- } = useBreadcrumbItem(_babelRuntimeHelpersEsmExtends({}, props, {
58
- elementType: typeof children === 'string' ? 'span' : 'a'
59
- }), ref);
60
- let {
61
- hoverProps,
62
- isHovered
63
- } = useHover(props);
64
-
65
- let element = /*#__PURE__*/_react.cloneElement(getWrappedElement(children), _babelRuntimeHelpersEsmExtends({}, mergeProps(itemProps, hoverProps), {
66
- ref,
67
- className: classNames($a5baa762b556403ac2f1cf2374238631$$interop$default, 'spectrum-Breadcrumbs-itemLink', {
68
- 'is-disabled': !isCurrent && isDisabled,
69
- 'is-hovered': isHovered
70
- })
71
- }));
72
-
73
- return /*#__PURE__*/_react.createElement(Fragment, null, /*#__PURE__*/_react.createElement(FocusRing, {
74
- focusRingClass: classNames($a5baa762b556403ac2f1cf2374238631$$interop$default, 'focus-ring')
75
- }, element), isCurrent === false && /*#__PURE__*/_react.createElement(_spectrumIconsUiChevronRightSmall, {
76
- UNSAFE_className: classNames($a5baa762b556403ac2f1cf2374238631$$interop$default, 'spectrum-Breadcrumbs-itemSeparator', {
77
- 'is-reversed': direction === 'rtl'
78
- })
79
- }));
19
+ function $parcel$export(e, n, v, s) {
20
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
21
+ }
22
+ var $017653b257c6ca18$exports = {};
23
+
24
+ $parcel$export($017653b257c6ca18$exports, "Breadcrumbs", () => $017653b257c6ca18$export$2dc68d50d56fbbd);
25
+
26
+
27
+
28
+
29
+
30
+
31
+ var $2512255f54f395b7$exports = {};
32
+
33
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs", () => $2512255f54f395b7$export$8c6320d2db82081f, (v) => $2512255f54f395b7$export$8c6320d2db82081f = v);
34
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs-itemSeparator", () => $2512255f54f395b7$export$f72910e36cd91d1e, (v) => $2512255f54f395b7$export$f72910e36cd91d1e = v);
35
+ $parcel$export($2512255f54f395b7$exports, "is-reversed", () => $2512255f54f395b7$export$a4561bd665abb5db, (v) => $2512255f54f395b7$export$a4561bd665abb5db = v);
36
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs-item", () => $2512255f54f395b7$export$492a5983c5fbf603, (v) => $2512255f54f395b7$export$492a5983c5fbf603 = v);
37
+ $parcel$export($2512255f54f395b7$exports, "spectrum-ActionButton", () => $2512255f54f395b7$export$53da69f51b770d3, (v) => $2512255f54f395b7$export$53da69f51b770d3 = v);
38
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs-itemLink", () => $2512255f54f395b7$export$5af6a1bcd207d9f6, (v) => $2512255f54f395b7$export$5af6a1bcd207d9f6 = v);
39
+ $parcel$export($2512255f54f395b7$exports, "is-hovered", () => $2512255f54f395b7$export$b8813cd5d7824ce7, (v) => $2512255f54f395b7$export$b8813cd5d7824ce7 = v);
40
+ $parcel$export($2512255f54f395b7$exports, "focus-ring", () => $2512255f54f395b7$export$f39a09f249340e2a, (v) => $2512255f54f395b7$export$f39a09f249340e2a = v);
41
+ $parcel$export($2512255f54f395b7$exports, "is-dragged", () => $2512255f54f395b7$export$8778c911bed6c759, (v) => $2512255f54f395b7$export$8778c911bed6c759 = v);
42
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs--small", () => $2512255f54f395b7$export$e01337e7944312f6, (v) => $2512255f54f395b7$export$e01337e7944312f6 = v);
43
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs--medium", () => $2512255f54f395b7$export$19f957201d941895, (v) => $2512255f54f395b7$export$19f957201d941895 = v);
44
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumbs--multiline", () => $2512255f54f395b7$export$713961e8e432825b, (v) => $2512255f54f395b7$export$713961e8e432825b = v);
45
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Heading--pageTitle", () => $2512255f54f395b7$export$63e9e087a73f808b, (v) => $2512255f54f395b7$export$63e9e087a73f808b = v);
46
+ $parcel$export($2512255f54f395b7$exports, "is-disabled", () => $2512255f54f395b7$export$d35bc1e505d1ebbf, (v) => $2512255f54f395b7$export$d35bc1e505d1ebbf = v);
47
+ $parcel$export($2512255f54f395b7$exports, "is-selected", () => $2512255f54f395b7$export$1e0fb04f31d3c22a, (v) => $2512255f54f395b7$export$1e0fb04f31d3c22a = v);
48
+ $parcel$export($2512255f54f395b7$exports, "spectrum-Breadcrumb", () => $2512255f54f395b7$export$45a5316056cfac3c, (v) => $2512255f54f395b7$export$45a5316056cfac3c = v);
49
+ var $2512255f54f395b7$export$8c6320d2db82081f;
50
+ var $2512255f54f395b7$export$f72910e36cd91d1e;
51
+ var $2512255f54f395b7$export$a4561bd665abb5db;
52
+ var $2512255f54f395b7$export$492a5983c5fbf603;
53
+ var $2512255f54f395b7$export$53da69f51b770d3;
54
+ var $2512255f54f395b7$export$5af6a1bcd207d9f6;
55
+ var $2512255f54f395b7$export$b8813cd5d7824ce7;
56
+ var $2512255f54f395b7$export$f39a09f249340e2a;
57
+ var $2512255f54f395b7$export$8778c911bed6c759;
58
+ var $2512255f54f395b7$export$e01337e7944312f6;
59
+ var $2512255f54f395b7$export$19f957201d941895;
60
+ var $2512255f54f395b7$export$713961e8e432825b;
61
+ var $2512255f54f395b7$export$63e9e087a73f808b;
62
+ var $2512255f54f395b7$export$d35bc1e505d1ebbf;
63
+ var $2512255f54f395b7$export$1e0fb04f31d3c22a;
64
+ var $2512255f54f395b7$export$45a5316056cfac3c;
65
+ $2512255f54f395b7$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
66
+ $2512255f54f395b7$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
67
+ $2512255f54f395b7$export$a4561bd665abb5db = "is-reversed_3fe6e8";
68
+ $2512255f54f395b7$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
69
+ $2512255f54f395b7$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
70
+ $2512255f54f395b7$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
71
+ $2512255f54f395b7$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
72
+ $2512255f54f395b7$export$f39a09f249340e2a = "focus-ring_3fe6e8";
73
+ $2512255f54f395b7$export$8778c911bed6c759 = "is-dragged_3fe6e8";
74
+ $2512255f54f395b7$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
75
+ $2512255f54f395b7$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
76
+ $2512255f54f395b7$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
77
+ $2512255f54f395b7$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
78
+ $2512255f54f395b7$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
79
+ $2512255f54f395b7$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
80
+ $2512255f54f395b7$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
81
+
82
+
83
+
84
+
85
+
86
+ function $0a7d4924239a1c00$export$c13f210c706eb549(props) {
87
+ let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
88
+ let { direction: direction } = $5Ji3d$useLocale();
89
+ let ref = $5Ji3d$useRef();
90
+ let { itemProps: itemProps } = $5Ji3d$useBreadcrumbItem({
91
+ ...props,
92
+ elementType: typeof children === 'string' ? 'span' : 'a'
93
+ }, ref);
94
+ let { hoverProps: hoverProps , isHovered: isHovered } = $5Ji3d$useHover(props);
95
+ let element = /*#__PURE__*/ $5Ji3d$react.cloneElement($5Ji3d$getWrappedElement(children), {
96
+ ...$5Ji3d$mergeProps(itemProps, hoverProps),
97
+ ref: ref,
98
+ className: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'spectrum-Breadcrumbs-itemLink', {
99
+ 'is-disabled': !isCurrent && isDisabled,
100
+ 'is-hovered': isHovered
101
+ })
102
+ });
103
+ return(/*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$Fragment, null, /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$FocusRing, {
104
+ focusRingClass: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'focus-ring')
105
+ }, element), isCurrent === false && /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$spectrumiconsuiChevronRightSmall, {
106
+ UNSAFE_className: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'spectrum-Breadcrumbs-itemSeparator', {
107
+ 'is-reversed': direction === 'rtl'
108
+ })
109
+ })));
80
110
  }
81
111
 
82
- const $ca93a0b524bf6d5b2a180315b966bddc$var$MIN_VISIBLE_ITEMS = 1;
83
- const $ca93a0b524bf6d5b2a180315b966bddc$var$MAX_VISIBLE_ITEMS = 4;
84
-
85
- function $ca93a0b524bf6d5b2a180315b966bddc$var$Breadcrumbs(props, ref) {
86
- props = useProviderProps(props);
87
-
88
- let {
89
- size = 'L',
90
- isMultiline,
91
- children,
92
- showRoot,
93
- isDisabled,
94
- onAction
95
- } = props,
96
- otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["size", "isMultiline", "children", "showRoot", "isDisabled", "onAction"]); // Not using React.Children.toArray because it mutates the key prop.
97
-
98
-
99
- let childArray = [];
100
-
101
- _react.Children.forEach(children, child => {
102
- if ( /*#__PURE__*/_react.isValidElement(child)) {
103
- childArray.push(child);
104
- }
105
- });
106
-
107
- let domRef = useDOMRef(ref);
108
- let listRef = useRef(null);
109
- let [visibleItems, setVisibleItems] = useValueEffect(childArray.length);
110
- let {
111
- navProps
112
- } = useBreadcrumbs(props);
113
- let {
114
- styleProps
115
- } = useStyleProps(otherProps);
116
- let updateOverflow = useCallback(() => {
117
- let computeVisibleItems = visibleItems => {
118
- let listItems = Array.from(listRef.current.children);
119
- let containerWidth = listRef.current.offsetWidth;
120
- let isShowingMenu = childArray.length > visibleItems;
121
- let calculatedWidth = 0;
122
- let newVisibleItems = 0;
123
- let maxVisibleItems = $ca93a0b524bf6d5b2a180315b966bddc$var$MAX_VISIBLE_ITEMS;
124
-
125
- if (showRoot) {
126
- calculatedWidth += listItems.shift().offsetWidth;
127
- newVisibleItems++;
128
- }
129
-
130
- if (isShowingMenu) {
131
- calculatedWidth += listItems.shift().offsetWidth;
132
- maxVisibleItems--;
133
- }
134
-
135
- if (showRoot && calculatedWidth >= containerWidth) {
136
- newVisibleItems--;
137
- } // TODO: what if multiline and only one breadcrumb??
138
112
 
139
113
 
140
- if (isMultiline) {
141
- listItems.pop();
142
- newVisibleItems++;
143
- } else {
144
- // Ensure the last breadcrumb isn't truncated when we measure it.
145
- let last = listItems.pop();
146
- last.style.overflow = 'visible';
147
- calculatedWidth += last.offsetWidth;
148
114
 
149
- if (calculatedWidth < containerWidth) {
150
- newVisibleItems++;
151
- }
152
115
 
153
- last.style.overflow = '';
154
- }
155
116
 
156
- for (let breadcrumb of listItems.reverse()) {
157
- calculatedWidth += breadcrumb.offsetWidth;
158
117
 
159
- if (calculatedWidth < containerWidth) {
160
- newVisibleItems++;
161
- }
162
- }
163
118
 
164
- return Math.max($ca93a0b524bf6d5b2a180315b966bddc$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
165
- };
166
119
 
167
- setVisibleItems(function* () {
168
- // Update to show all items.
169
- yield childArray.length; // Measure, and update to show the items that fit.
170
120
 
171
- let newVisibleItems = computeVisibleItems(childArray.length);
172
- yield newVisibleItems; // If the number of items is less than the number of children,
173
- // then update again to ensure that the menu fits.
174
121
 
175
- if (newVisibleItems < childArray.length && newVisibleItems > 1) {
176
- yield computeVisibleItems(newVisibleItems);
177
- }
122
+ const $017653b257c6ca18$var$MIN_VISIBLE_ITEMS = 1;
123
+ const $017653b257c6ca18$var$MAX_VISIBLE_ITEMS = 4;
124
+ function $017653b257c6ca18$var$Breadcrumbs(props, ref) {
125
+ props = $5Ji3d$useProviderProps(props);
126
+ let { size: size = 'L' , isMultiline: isMultiline , children: children , showRoot: showRoot , isDisabled: isDisabled , onAction: onAction , ...otherProps } = props;
127
+ // Not using React.Children.toArray because it mutates the key prop.
128
+ let childArray = [];
129
+ $5Ji3d$react.Children.forEach(children, (child)=>{
130
+ if (/*#__PURE__*/ $5Ji3d$react.isValidElement(child)) childArray.push(child);
178
131
  });
179
- }, [listRef, children, setVisibleItems, showRoot, isMultiline]);
180
- useResizeObserver({
181
- ref: domRef,
182
- onResize: updateOverflow
183
- });
184
- useLayoutEffect(updateOverflow, [children]);
185
- let contents = childArray;
186
-
187
- if (childArray.length > visibleItems) {
188
- var _selectedItem$key;
189
-
190
- let selectedItem = childArray[childArray.length - 1];
191
- let selectedKey = (_selectedItem$key = selectedItem.key) != null ? _selectedItem$key : childArray.length - 1;
192
-
193
- let onMenuAction = key => {
194
- // Don't fire onAction when clicking on the last item
195
- if (key !== selectedKey && onAction) {
196
- onAction(key);
197
- }
198
- };
199
-
200
- let menuItem = /*#__PURE__*/_react.createElement($dacda927994e51fbe8a71ffbc$export$BreadcrumbItem, {
201
- key: "menu"
202
- }, /*#__PURE__*/_react.createElement(MenuTrigger, null, /*#__PURE__*/_react.createElement(ActionButton, {
203
- "aria-label": "\u2026",
204
- isQuiet: true,
205
- isDisabled: isDisabled
206
- }, /*#__PURE__*/_react.createElement(_spectrumIconsUiFolderBreadcrumb, null)), /*#__PURE__*/_react.createElement(Menu, {
207
- selectionMode: "single",
208
- selectedKeys: [selectedKey],
209
- onAction: onMenuAction
210
- }, childArray)));
211
-
212
- contents = [menuItem];
213
- let breadcrumbs = [...childArray];
214
- let endItems = visibleItems;
215
-
216
- if (showRoot && visibleItems > 1) {
217
- contents.unshift(breadcrumbs.shift());
218
- endItems--;
132
+ let domRef = $5Ji3d$useDOMRef(ref);
133
+ let listRef = $5Ji3d$useRef(null);
134
+ let [visibleItems1, setVisibleItems] = $5Ji3d$useValueEffect(childArray.length);
135
+ let { navProps: navProps } = $5Ji3d$useBreadcrumbs(props);
136
+ let { styleProps: styleProps } = $5Ji3d$useStyleProps(otherProps);
137
+ let updateOverflow = $5Ji3d$useCallback(()=>{
138
+ let computeVisibleItems = (visibleItems)=>{
139
+ // Refs can be null at runtime.
140
+ let currListRef = listRef.current;
141
+ if (!currListRef) return;
142
+ let listItems = Array.from(currListRef.children);
143
+ let containerWidth = currListRef.offsetWidth;
144
+ let isShowingMenu = childArray.length > visibleItems;
145
+ let calculatedWidth = 0;
146
+ let newVisibleItems = 0;
147
+ let maxVisibleItems = $017653b257c6ca18$var$MAX_VISIBLE_ITEMS;
148
+ if (showRoot) {
149
+ calculatedWidth += listItems.shift().offsetWidth;
150
+ newVisibleItems++;
151
+ }
152
+ if (isShowingMenu) {
153
+ calculatedWidth += listItems.shift().offsetWidth;
154
+ maxVisibleItems--;
155
+ }
156
+ if (showRoot && calculatedWidth >= containerWidth) newVisibleItems--;
157
+ // TODO: what if multiline and only one breadcrumb??
158
+ if (isMultiline) {
159
+ listItems.pop();
160
+ newVisibleItems++;
161
+ } else {
162
+ // Ensure the last breadcrumb isn't truncated when we measure it.
163
+ let last = listItems.pop();
164
+ last.style.overflow = 'visible';
165
+ calculatedWidth += last.offsetWidth;
166
+ if (calculatedWidth < containerWidth) newVisibleItems++;
167
+ last.style.overflow = '';
168
+ }
169
+ for (let breadcrumb of listItems.reverse()){
170
+ calculatedWidth += breadcrumb.offsetWidth;
171
+ if (calculatedWidth < containerWidth) newVisibleItems++;
172
+ }
173
+ return Math.max($017653b257c6ca18$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
174
+ };
175
+ setVisibleItems(function*() {
176
+ // Update to show all items.
177
+ yield childArray.length;
178
+ // Measure, and update to show the items that fit.
179
+ let newVisibleItems = computeVisibleItems(childArray.length);
180
+ yield newVisibleItems;
181
+ // If the number of items is less than the number of children,
182
+ // then update again to ensure that the menu fits.
183
+ if (newVisibleItems < childArray.length && newVisibleItems > 1) yield computeVisibleItems(newVisibleItems);
184
+ });
185
+ }, [
186
+ listRef,
187
+ children,
188
+ setVisibleItems,
189
+ showRoot,
190
+ isMultiline
191
+ ]);
192
+ $5Ji3d$useResizeObserver({
193
+ ref: domRef,
194
+ onResize: updateOverflow
195
+ });
196
+ $5Ji3d$useLayoutEffect(updateOverflow, [
197
+ children
198
+ ]);
199
+ let contents = childArray;
200
+ if (childArray.length > visibleItems1) {
201
+ let selectedItem = childArray[childArray.length - 1];
202
+ var _key;
203
+ let selectedKey = (_key = selectedItem.key) !== null && _key !== void 0 ? _key : childArray.length - 1;
204
+ let onMenuAction = (key)=>{
205
+ // Don't fire onAction when clicking on the last item
206
+ if (key !== selectedKey && onAction) onAction(key);
207
+ };
208
+ let menuItem = /*#__PURE__*/ $5Ji3d$react.createElement($0a7d4924239a1c00$export$c13f210c706eb549, {
209
+ key: "menu"
210
+ }, /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$MenuTrigger, null, /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$ActionButton, {
211
+ "aria-label": "…",
212
+ isQuiet: true,
213
+ isDisabled: isDisabled
214
+ }, /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$spectrumiconsuiFolderBreadcrumb, null)), /*#__PURE__*/ $5Ji3d$react.createElement($5Ji3d$Menu, {
215
+ selectionMode: "single",
216
+ selectedKeys: [
217
+ selectedKey
218
+ ],
219
+ onAction: onMenuAction
220
+ }, childArray)));
221
+ contents = [
222
+ menuItem
223
+ ];
224
+ let breadcrumbs = [
225
+ ...childArray
226
+ ];
227
+ let endItems = visibleItems1;
228
+ if (showRoot && visibleItems1 > 1) {
229
+ contents.unshift(breadcrumbs.shift());
230
+ endItems--;
231
+ }
232
+ contents.push(...breadcrumbs.slice(-endItems));
219
233
  }
220
-
221
- contents.push(...breadcrumbs.slice(-endItems));
222
- }
223
-
224
- let lastIndex = contents.length - 1;
225
- let breadcrumbItems = contents.map((child, index) => {
226
- var _child$key;
227
-
228
- let isCurrent = index === lastIndex;
229
- let key = (_child$key = child.key) != null ? _child$key : index;
230
-
231
- let onPress = () => {
232
- if (onAction) {
233
- onAction(key);
234
- }
235
- };
236
-
237
- return /*#__PURE__*/_react.createElement("li", {
238
- key: key,
239
- className: classNames($a5baa762b556403ac2f1cf2374238631$$interop$default, 'spectrum-Breadcrumbs-item')
240
- }, /*#__PURE__*/_react.createElement($dacda927994e51fbe8a71ffbc$export$BreadcrumbItem, {
241
- isCurrent: isCurrent,
242
- isDisabled: isDisabled,
243
- onPress: onPress
244
- }, child.props.children));
245
- });
246
- return /*#__PURE__*/_react.createElement("nav", _babelRuntimeHelpersEsmExtends({}, styleProps, navProps, {
247
- ref: domRef
248
- }), /*#__PURE__*/_react.createElement("ul", {
249
- ref: listRef,
250
- className: classNames($a5baa762b556403ac2f1cf2374238631$$interop$default, 'spectrum-Breadcrumbs', {
251
- 'spectrum-Breadcrumbs--small': size === 'S',
252
- 'spectrum-Breadcrumbs--medium': size === 'M',
253
- 'spectrum-Breadcrumbs--multiline': isMultiline,
254
- 'spectrum-Breadcrumbs--showRoot': showRoot,
255
- 'is-disabled': isDisabled
256
- }, styleProps.className)
257
- }, breadcrumbItems));
234
+ let lastIndex = contents.length - 1;
235
+ let breadcrumbItems = contents.map((child, index)=>{
236
+ let isCurrent = index === lastIndex;
237
+ var _key;
238
+ let key = (_key = child.key) !== null && _key !== void 0 ? _key : index;
239
+ let onPress = ()=>{
240
+ if (onAction) onAction(key);
241
+ };
242
+ return(/*#__PURE__*/ $5Ji3d$react.createElement("li", {
243
+ key: key,
244
+ className: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'spectrum-Breadcrumbs-item')
245
+ }, /*#__PURE__*/ $5Ji3d$react.createElement($0a7d4924239a1c00$export$c13f210c706eb549, {
246
+ isCurrent: isCurrent,
247
+ isDisabled: isDisabled,
248
+ onPress: onPress
249
+ }, child.props.children)));
250
+ });
251
+ return(/*#__PURE__*/ $5Ji3d$react.createElement("nav", {
252
+ ...styleProps,
253
+ ...navProps,
254
+ ref: domRef
255
+ }, /*#__PURE__*/ $5Ji3d$react.createElement("ul", {
256
+ ref: listRef,
257
+ className: $5Ji3d$classNames((/*@__PURE__*/$parcel$interopDefault($2512255f54f395b7$exports)), 'spectrum-Breadcrumbs', {
258
+ 'spectrum-Breadcrumbs--small': size === 'S',
259
+ 'spectrum-Breadcrumbs--medium': size === 'M',
260
+ 'spectrum-Breadcrumbs--multiline': isMultiline,
261
+ 'spectrum-Breadcrumbs--showRoot': showRoot,
262
+ 'is-disabled': isDisabled
263
+ }, styleProps.className)
264
+ }, breadcrumbItems)));
258
265
  }
259
266
  /**
260
267
  * Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
261
- */
268
+ */ let $017653b257c6ca18$export$2dc68d50d56fbbd = /*#__PURE__*/ $5Ji3d$react.forwardRef($017653b257c6ca18$var$Breadcrumbs);
269
+
270
+
271
+
262
272
 
263
273
 
264
- export let Breadcrumbs = /*#__PURE__*/_react.forwardRef($ca93a0b524bf6d5b2a180315b966bddc$var$Breadcrumbs);
274
+ export {$7affa7233923f57e$re_export$Item as Item, $017653b257c6ca18$export$2dc68d50d56fbbd as Breadcrumbs};
265
275
  //# sourceMappingURL=module.js.map