@react-spectrum/breadcrumbs 3.2.1 → 3.2.5
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.css +1 -2
- package/dist/main.js +264 -292
- package/dist/main.js.map +1 -1
- package/dist/module.js +248 -240
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/Breadcrumbs.tsx +10 -4
- package/dist/main.css.map +0 -1
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;AAEjC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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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AGAA,GAAsC;AACtC,GAAoD;AACpD,GAA6B;AAC7B,GAA2C;AAC3C,GAAuC;AACvC,GAA+C;AAC/C,GAA4B;AAC5B,GAA4B;AAC5B,GAA4B;AAC5B,GAA6C;AAC7C,GAA8C;AAC9C,GAAiD;AACjD,GAA6C;AAC7C,GAA6B;AAC7B,GAA6B;AAC7B,GAAqC;AAfrC,yCAAsC,GAAG,CAA6B;AACtE,yCAAoD,GAAG,CAA2C;AAClG,yCAA6B,GAAG,CAAoB;AACpD,yCAA2C,GAAG,CAAkC;AAChF,wCAAuC,GAAG,CAA8B;AACxE,yCAA+C,GAAG,CAAsC;AACxF,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA4B,GAAG,CAAmB;AAClD,yCAA6C,GAAG,CAAoC;AACpF,yCAA8C,GAAG,CAAqC;AACtF,yCAAiD,GAAG,CAAwC;AAC5F,yCAA6C,GAAG,CAAoC;AACpF,yCAA6B,GAAG,CAAoB;AACpD,yCAA6B,GAAG,CAAoB;AACpD,yCAAqC,GAAG,CAA4B;;;;;;SDQpD,yCAAc,CAAC,KAA0B,EAAE,CAAC;IAC1D,GAAG,CAAC,CAAC,WACH,QAAQ,cACR,SAAS,eACT,UAAU,EACZ,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,8BAAS;IAC3B,GAAG,CAAC,GAAG,GAAG,mBAAM;IAChB,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAA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eAAe,GAAG,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,GAAK,CAAC;QACpD,GAAG,CAAC,SAAS,GAAG,KAAK,KAAK,SAAS;QACnC,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,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,273 @@
|
|
|
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 $b77823a1e69091fb$re_export$Item} from "@react-stately/collections";
|
|
3
|
+
import {ActionButton as $2OMIA$ActionButton} from "@react-spectrum/button";
|
|
4
|
+
import {useDOMRef as $2OMIA$useDOMRef, useStyleProps as $2OMIA$useStyleProps, classNames as $2OMIA$classNames, getWrappedElement as $2OMIA$getWrappedElement} from "@react-spectrum/utils";
|
|
5
|
+
import $2OMIA$spectrumiconsuiFolderBreadcrumb from "@spectrum-icons/ui/FolderBreadcrumb";
|
|
6
|
+
import {MenuTrigger as $2OMIA$MenuTrigger, Menu as $2OMIA$Menu} from "@react-spectrum/menu";
|
|
7
|
+
import $2OMIA$react, {useRef as $2OMIA$useRef, useCallback as $2OMIA$useCallback, Fragment as $2OMIA$Fragment} from "react";
|
|
8
|
+
import {useBreadcrumbs as $2OMIA$useBreadcrumbs, useBreadcrumbItem as $2OMIA$useBreadcrumbItem} from "@react-aria/breadcrumbs";
|
|
9
|
+
import {useValueEffect as $2OMIA$useValueEffect, useResizeObserver as $2OMIA$useResizeObserver, useLayoutEffect as $2OMIA$useLayoutEffect, mergeProps as $2OMIA$mergeProps} from "@react-aria/utils";
|
|
10
|
+
import {useProviderProps as $2OMIA$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
+
import $2OMIA$spectrumiconsuiChevronRightSmall from "@spectrum-icons/ui/ChevronRightSmall";
|
|
12
|
+
import {FocusRing as $2OMIA$FocusRing} from "@react-aria/focus";
|
|
13
|
+
import {useHover as $2OMIA$useHover} from "@react-aria/interactions";
|
|
14
|
+
import {useLocale as $2OMIA$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
|
-
|
|
24
|
-
|
|
25
|
-
$
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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 $ad142e6c7f8dd846$exports = {};
|
|
23
|
+
|
|
24
|
+
$parcel$export($ad142e6c7f8dd846$exports, "Breadcrumbs", () => $ad142e6c7f8dd846$export$2dc68d50d56fbbd);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var $031ef6a0f075eadb$exports = {};
|
|
32
|
+
|
|
33
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs", () => $031ef6a0f075eadb$export$8c6320d2db82081f, (v) => $031ef6a0f075eadb$export$8c6320d2db82081f = v);
|
|
34
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs-itemSeparator", () => $031ef6a0f075eadb$export$f72910e36cd91d1e, (v) => $031ef6a0f075eadb$export$f72910e36cd91d1e = v);
|
|
35
|
+
$parcel$export($031ef6a0f075eadb$exports, "is-reversed", () => $031ef6a0f075eadb$export$a4561bd665abb5db, (v) => $031ef6a0f075eadb$export$a4561bd665abb5db = v);
|
|
36
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs-item", () => $031ef6a0f075eadb$export$492a5983c5fbf603, (v) => $031ef6a0f075eadb$export$492a5983c5fbf603 = v);
|
|
37
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-ActionButton", () => $031ef6a0f075eadb$export$53da69f51b770d3, (v) => $031ef6a0f075eadb$export$53da69f51b770d3 = v);
|
|
38
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs-itemLink", () => $031ef6a0f075eadb$export$5af6a1bcd207d9f6, (v) => $031ef6a0f075eadb$export$5af6a1bcd207d9f6 = v);
|
|
39
|
+
$parcel$export($031ef6a0f075eadb$exports, "is-hovered", () => $031ef6a0f075eadb$export$b8813cd5d7824ce7, (v) => $031ef6a0f075eadb$export$b8813cd5d7824ce7 = v);
|
|
40
|
+
$parcel$export($031ef6a0f075eadb$exports, "focus-ring", () => $031ef6a0f075eadb$export$f39a09f249340e2a, (v) => $031ef6a0f075eadb$export$f39a09f249340e2a = v);
|
|
41
|
+
$parcel$export($031ef6a0f075eadb$exports, "is-dragged", () => $031ef6a0f075eadb$export$8778c911bed6c759, (v) => $031ef6a0f075eadb$export$8778c911bed6c759 = v);
|
|
42
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs--small", () => $031ef6a0f075eadb$export$e01337e7944312f6, (v) => $031ef6a0f075eadb$export$e01337e7944312f6 = v);
|
|
43
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs--medium", () => $031ef6a0f075eadb$export$19f957201d941895, (v) => $031ef6a0f075eadb$export$19f957201d941895 = v);
|
|
44
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumbs--multiline", () => $031ef6a0f075eadb$export$713961e8e432825b, (v) => $031ef6a0f075eadb$export$713961e8e432825b = v);
|
|
45
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Heading--pageTitle", () => $031ef6a0f075eadb$export$63e9e087a73f808b, (v) => $031ef6a0f075eadb$export$63e9e087a73f808b = v);
|
|
46
|
+
$parcel$export($031ef6a0f075eadb$exports, "is-disabled", () => $031ef6a0f075eadb$export$d35bc1e505d1ebbf, (v) => $031ef6a0f075eadb$export$d35bc1e505d1ebbf = v);
|
|
47
|
+
$parcel$export($031ef6a0f075eadb$exports, "is-selected", () => $031ef6a0f075eadb$export$1e0fb04f31d3c22a, (v) => $031ef6a0f075eadb$export$1e0fb04f31d3c22a = v);
|
|
48
|
+
$parcel$export($031ef6a0f075eadb$exports, "spectrum-Breadcrumb", () => $031ef6a0f075eadb$export$45a5316056cfac3c, (v) => $031ef6a0f075eadb$export$45a5316056cfac3c = v);
|
|
49
|
+
var $031ef6a0f075eadb$export$8c6320d2db82081f;
|
|
50
|
+
var $031ef6a0f075eadb$export$f72910e36cd91d1e;
|
|
51
|
+
var $031ef6a0f075eadb$export$a4561bd665abb5db;
|
|
52
|
+
var $031ef6a0f075eadb$export$492a5983c5fbf603;
|
|
53
|
+
var $031ef6a0f075eadb$export$53da69f51b770d3;
|
|
54
|
+
var $031ef6a0f075eadb$export$5af6a1bcd207d9f6;
|
|
55
|
+
var $031ef6a0f075eadb$export$b8813cd5d7824ce7;
|
|
56
|
+
var $031ef6a0f075eadb$export$f39a09f249340e2a;
|
|
57
|
+
var $031ef6a0f075eadb$export$8778c911bed6c759;
|
|
58
|
+
var $031ef6a0f075eadb$export$e01337e7944312f6;
|
|
59
|
+
var $031ef6a0f075eadb$export$19f957201d941895;
|
|
60
|
+
var $031ef6a0f075eadb$export$713961e8e432825b;
|
|
61
|
+
var $031ef6a0f075eadb$export$63e9e087a73f808b;
|
|
62
|
+
var $031ef6a0f075eadb$export$d35bc1e505d1ebbf;
|
|
63
|
+
var $031ef6a0f075eadb$export$1e0fb04f31d3c22a;
|
|
64
|
+
var $031ef6a0f075eadb$export$45a5316056cfac3c;
|
|
65
|
+
$031ef6a0f075eadb$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
|
|
66
|
+
$031ef6a0f075eadb$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
|
|
67
|
+
$031ef6a0f075eadb$export$a4561bd665abb5db = "is-reversed_3fe6e8";
|
|
68
|
+
$031ef6a0f075eadb$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
|
|
69
|
+
$031ef6a0f075eadb$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
|
|
70
|
+
$031ef6a0f075eadb$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
|
|
71
|
+
$031ef6a0f075eadb$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
|
|
72
|
+
$031ef6a0f075eadb$export$f39a09f249340e2a = "focus-ring_3fe6e8";
|
|
73
|
+
$031ef6a0f075eadb$export$8778c911bed6c759 = "is-dragged_3fe6e8";
|
|
74
|
+
$031ef6a0f075eadb$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
|
|
75
|
+
$031ef6a0f075eadb$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
|
|
76
|
+
$031ef6a0f075eadb$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
|
|
77
|
+
$031ef6a0f075eadb$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
|
|
78
|
+
$031ef6a0f075eadb$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
|
|
79
|
+
$031ef6a0f075eadb$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
|
|
80
|
+
$031ef6a0f075eadb$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
function $5c319d6d9e7d47c6$export$c13f210c706eb549(props) {
|
|
87
|
+
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
88
|
+
let { direction: direction } = $2OMIA$useLocale();
|
|
89
|
+
let ref = $2OMIA$useRef();
|
|
90
|
+
let { itemProps: itemProps } = $2OMIA$useBreadcrumbItem({
|
|
91
|
+
...props,
|
|
92
|
+
elementType: typeof children === 'string' ? 'span' : 'a'
|
|
93
|
+
}, ref);
|
|
94
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $2OMIA$useHover(props);
|
|
95
|
+
let element = /*#__PURE__*/ $2OMIA$react.cloneElement($2OMIA$getWrappedElement(children), {
|
|
96
|
+
...$2OMIA$mergeProps(itemProps, hoverProps),
|
|
97
|
+
ref: ref,
|
|
98
|
+
className: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$exports)), 'spectrum-Breadcrumbs-itemLink', {
|
|
99
|
+
'is-disabled': !isCurrent && isDisabled,
|
|
100
|
+
'is-hovered': isHovered
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
return(/*#__PURE__*/ $2OMIA$react.createElement($2OMIA$Fragment, null, /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$FocusRing, {
|
|
104
|
+
focusRingClass: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$exports)), 'focus-ring')
|
|
105
|
+
}, element), isCurrent === false && /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$spectrumiconsuiChevronRightSmall, {
|
|
106
|
+
UNSAFE_className: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
122
|
+
const $ad142e6c7f8dd846$var$MIN_VISIBLE_ITEMS = 1;
|
|
123
|
+
const $ad142e6c7f8dd846$var$MAX_VISIBLE_ITEMS = 4;
|
|
124
|
+
function $ad142e6c7f8dd846$var$Breadcrumbs(props, ref) {
|
|
125
|
+
props = $2OMIA$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
|
+
$2OMIA$react.Children.forEach(children, (child)=>{
|
|
130
|
+
if (/*#__PURE__*/ $2OMIA$react.isValidElement(child)) childArray.push(child);
|
|
178
131
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
132
|
+
let domRef = $2OMIA$useDOMRef(ref);
|
|
133
|
+
let listRef = $2OMIA$useRef(null);
|
|
134
|
+
let [visibleItems1, setVisibleItems] = $2OMIA$useValueEffect(childArray.length);
|
|
135
|
+
let { navProps: navProps } = $2OMIA$useBreadcrumbs(props);
|
|
136
|
+
let { styleProps: styleProps } = $2OMIA$useStyleProps(otherProps);
|
|
137
|
+
let updateOverflow = $2OMIA$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 = $ad142e6c7f8dd846$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($ad142e6c7f8dd846$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
|
+
$2OMIA$useResizeObserver({
|
|
193
|
+
ref: domRef,
|
|
194
|
+
onResize: updateOverflow
|
|
195
|
+
});
|
|
196
|
+
$2OMIA$useLayoutEffect(updateOverflow, [
|
|
197
|
+
children
|
|
198
|
+
]);
|
|
199
|
+
let contents = childArray;
|
|
200
|
+
if (childArray.length > visibleItems1) {
|
|
201
|
+
let selectedItem = childArray[childArray.length - 1];
|
|
202
|
+
let selectedKey = selectedItem.key ?? childArray.length - 1;
|
|
203
|
+
let onMenuAction = (key)=>{
|
|
204
|
+
// Don't fire onAction when clicking on the last item
|
|
205
|
+
if (key !== selectedKey && onAction) onAction(key);
|
|
206
|
+
};
|
|
207
|
+
let menuItem = /*#__PURE__*/ $2OMIA$react.createElement($5c319d6d9e7d47c6$export$c13f210c706eb549, {
|
|
208
|
+
key: "menu"
|
|
209
|
+
}, /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$MenuTrigger, null, /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$ActionButton, {
|
|
210
|
+
"aria-label": "…",
|
|
211
|
+
isQuiet: true,
|
|
212
|
+
isDisabled: isDisabled
|
|
213
|
+
}, /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$spectrumiconsuiFolderBreadcrumb, null)), /*#__PURE__*/ $2OMIA$react.createElement($2OMIA$Menu, {
|
|
214
|
+
selectionMode: "single",
|
|
215
|
+
selectedKeys: [
|
|
216
|
+
selectedKey
|
|
217
|
+
],
|
|
218
|
+
onAction: onMenuAction
|
|
219
|
+
}, childArray)));
|
|
220
|
+
contents = [
|
|
221
|
+
menuItem
|
|
222
|
+
];
|
|
223
|
+
let breadcrumbs = [
|
|
224
|
+
...childArray
|
|
225
|
+
];
|
|
226
|
+
let endItems = visibleItems1;
|
|
227
|
+
if (showRoot && visibleItems1 > 1) {
|
|
228
|
+
contents.unshift(breadcrumbs.shift());
|
|
229
|
+
endItems--;
|
|
230
|
+
}
|
|
231
|
+
contents.push(...breadcrumbs.slice(-endItems));
|
|
219
232
|
}
|
|
220
|
-
|
|
221
|
-
contents.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}, /*#__PURE__*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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));
|
|
233
|
+
let lastIndex = contents.length - 1;
|
|
234
|
+
let breadcrumbItems = contents.map((child, index)=>{
|
|
235
|
+
let isCurrent = index === lastIndex;
|
|
236
|
+
let key = child.key ?? index;
|
|
237
|
+
let onPress = ()=>{
|
|
238
|
+
if (onAction) onAction(key);
|
|
239
|
+
};
|
|
240
|
+
return(/*#__PURE__*/ $2OMIA$react.createElement("li", {
|
|
241
|
+
key: key,
|
|
242
|
+
className: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$exports)), 'spectrum-Breadcrumbs-item')
|
|
243
|
+
}, /*#__PURE__*/ $2OMIA$react.createElement($5c319d6d9e7d47c6$export$c13f210c706eb549, {
|
|
244
|
+
isCurrent: isCurrent,
|
|
245
|
+
isDisabled: isDisabled,
|
|
246
|
+
onPress: onPress
|
|
247
|
+
}, child.props.children)));
|
|
248
|
+
});
|
|
249
|
+
return(/*#__PURE__*/ $2OMIA$react.createElement("nav", {
|
|
250
|
+
...styleProps,
|
|
251
|
+
...navProps,
|
|
252
|
+
ref: domRef
|
|
253
|
+
}, /*#__PURE__*/ $2OMIA$react.createElement("ul", {
|
|
254
|
+
ref: listRef,
|
|
255
|
+
className: $2OMIA$classNames((/*@__PURE__*/$parcel$interopDefault($031ef6a0f075eadb$exports)), 'spectrum-Breadcrumbs', {
|
|
256
|
+
'spectrum-Breadcrumbs--small': size === 'S',
|
|
257
|
+
'spectrum-Breadcrumbs--medium': size === 'M',
|
|
258
|
+
'spectrum-Breadcrumbs--multiline': isMultiline,
|
|
259
|
+
'spectrum-Breadcrumbs--showRoot': showRoot,
|
|
260
|
+
'is-disabled': isDisabled
|
|
261
|
+
}, styleProps.className)
|
|
262
|
+
}, breadcrumbItems)));
|
|
258
263
|
}
|
|
259
264
|
/**
|
|
260
265
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
261
|
-
*/
|
|
266
|
+
*/ let $ad142e6c7f8dd846$export$2dc68d50d56fbbd = /*#__PURE__*/ $2OMIA$react.forwardRef($ad142e6c7f8dd846$var$Breadcrumbs);
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
262
270
|
|
|
263
271
|
|
|
264
|
-
export
|
|
272
|
+
export {$b77823a1e69091fb$re_export$Item as Item, $ad142e6c7f8dd846$export$2dc68d50d56fbbd as Breadcrumbs};
|
|
265
273
|
//# sourceMappingURL=module.js.map
|