@react-spectrum/breadcrumbs 3.2.4 → 3.2.7
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 +266 -299
- package/dist/main.js.map +1 -1
- package/dist/module.js +250 -247
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
- 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;AAEjCU,IAAAA,WAAW,EAAE,OAAOT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","./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} 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"],"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","currListRef","current","listItems","Array","from","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,EAA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rumbs/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,272 +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, useValueEffect, useResizeObserver } from "@react-aria/utils";
|
|
9
|
-
import { FocusRing } from "@react-aria/focus";
|
|
10
|
-
import { classNames, getWrappedElement, useDOMRef, useStyleProps } 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 $37781313afe0968e$re_export$Item} from "@react-stately/collections";
|
|
3
|
+
import {ActionButton as $koRP3$ActionButton} from "@react-spectrum/button";
|
|
4
|
+
import {useDOMRef as $koRP3$useDOMRef, useStyleProps as $koRP3$useStyleProps, classNames as $koRP3$classNames, getWrappedElement as $koRP3$getWrappedElement} from "@react-spectrum/utils";
|
|
5
|
+
import $koRP3$spectrumiconsuiFolderBreadcrumb from "@spectrum-icons/ui/FolderBreadcrumb";
|
|
6
|
+
import {MenuTrigger as $koRP3$MenuTrigger, Menu as $koRP3$Menu} from "@react-spectrum/menu";
|
|
7
|
+
import $koRP3$react, {useRef as $koRP3$useRef, useCallback as $koRP3$useCallback, Fragment as $koRP3$Fragment} from "react";
|
|
8
|
+
import {useBreadcrumbs as $koRP3$useBreadcrumbs, useBreadcrumbItem as $koRP3$useBreadcrumbItem} from "@react-aria/breadcrumbs";
|
|
9
|
+
import {useValueEffect as $koRP3$useValueEffect, useResizeObserver as $koRP3$useResizeObserver, useLayoutEffect as $koRP3$useLayoutEffect, mergeProps as $koRP3$mergeProps} from "@react-aria/utils";
|
|
10
|
+
import {useProviderProps as $koRP3$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
+
import $koRP3$spectrumiconsuiChevronRightSmall from "@spectrum-icons/ui/ChevronRightSmall";
|
|
12
|
+
import {FocusRing as $koRP3$FocusRing} from "@react-aria/focus";
|
|
13
|
+
import {useHover as $koRP3$useHover} from "@react-aria/interactions";
|
|
14
|
+
import {useLocale as $koRP3$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 $2adaf67aabd3300b$exports = {};
|
|
23
|
+
|
|
24
|
+
$parcel$export($2adaf67aabd3300b$exports, "Breadcrumbs", () => $2adaf67aabd3300b$export$2dc68d50d56fbbd);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var $48e85557f3729e3d$exports = {};
|
|
32
|
+
|
|
33
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs", () => $48e85557f3729e3d$export$8c6320d2db82081f, (v) => $48e85557f3729e3d$export$8c6320d2db82081f = v);
|
|
34
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemSeparator", () => $48e85557f3729e3d$export$f72910e36cd91d1e, (v) => $48e85557f3729e3d$export$f72910e36cd91d1e = v);
|
|
35
|
+
$parcel$export($48e85557f3729e3d$exports, "is-reversed", () => $48e85557f3729e3d$export$a4561bd665abb5db, (v) => $48e85557f3729e3d$export$a4561bd665abb5db = v);
|
|
36
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-item", () => $48e85557f3729e3d$export$492a5983c5fbf603, (v) => $48e85557f3729e3d$export$492a5983c5fbf603 = v);
|
|
37
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-ActionButton", () => $48e85557f3729e3d$export$53da69f51b770d3, (v) => $48e85557f3729e3d$export$53da69f51b770d3 = v);
|
|
38
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs-itemLink", () => $48e85557f3729e3d$export$5af6a1bcd207d9f6, (v) => $48e85557f3729e3d$export$5af6a1bcd207d9f6 = v);
|
|
39
|
+
$parcel$export($48e85557f3729e3d$exports, "is-hovered", () => $48e85557f3729e3d$export$b8813cd5d7824ce7, (v) => $48e85557f3729e3d$export$b8813cd5d7824ce7 = v);
|
|
40
|
+
$parcel$export($48e85557f3729e3d$exports, "focus-ring", () => $48e85557f3729e3d$export$f39a09f249340e2a, (v) => $48e85557f3729e3d$export$f39a09f249340e2a = v);
|
|
41
|
+
$parcel$export($48e85557f3729e3d$exports, "is-dragged", () => $48e85557f3729e3d$export$8778c911bed6c759, (v) => $48e85557f3729e3d$export$8778c911bed6c759 = v);
|
|
42
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--small", () => $48e85557f3729e3d$export$e01337e7944312f6, (v) => $48e85557f3729e3d$export$e01337e7944312f6 = v);
|
|
43
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--medium", () => $48e85557f3729e3d$export$19f957201d941895, (v) => $48e85557f3729e3d$export$19f957201d941895 = v);
|
|
44
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumbs--multiline", () => $48e85557f3729e3d$export$713961e8e432825b, (v) => $48e85557f3729e3d$export$713961e8e432825b = v);
|
|
45
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Heading--pageTitle", () => $48e85557f3729e3d$export$63e9e087a73f808b, (v) => $48e85557f3729e3d$export$63e9e087a73f808b = v);
|
|
46
|
+
$parcel$export($48e85557f3729e3d$exports, "is-disabled", () => $48e85557f3729e3d$export$d35bc1e505d1ebbf, (v) => $48e85557f3729e3d$export$d35bc1e505d1ebbf = v);
|
|
47
|
+
$parcel$export($48e85557f3729e3d$exports, "is-selected", () => $48e85557f3729e3d$export$1e0fb04f31d3c22a, (v) => $48e85557f3729e3d$export$1e0fb04f31d3c22a = v);
|
|
48
|
+
$parcel$export($48e85557f3729e3d$exports, "spectrum-Breadcrumb", () => $48e85557f3729e3d$export$45a5316056cfac3c, (v) => $48e85557f3729e3d$export$45a5316056cfac3c = v);
|
|
49
|
+
var $48e85557f3729e3d$export$8c6320d2db82081f;
|
|
50
|
+
var $48e85557f3729e3d$export$f72910e36cd91d1e;
|
|
51
|
+
var $48e85557f3729e3d$export$a4561bd665abb5db;
|
|
52
|
+
var $48e85557f3729e3d$export$492a5983c5fbf603;
|
|
53
|
+
var $48e85557f3729e3d$export$53da69f51b770d3;
|
|
54
|
+
var $48e85557f3729e3d$export$5af6a1bcd207d9f6;
|
|
55
|
+
var $48e85557f3729e3d$export$b8813cd5d7824ce7;
|
|
56
|
+
var $48e85557f3729e3d$export$f39a09f249340e2a;
|
|
57
|
+
var $48e85557f3729e3d$export$8778c911bed6c759;
|
|
58
|
+
var $48e85557f3729e3d$export$e01337e7944312f6;
|
|
59
|
+
var $48e85557f3729e3d$export$19f957201d941895;
|
|
60
|
+
var $48e85557f3729e3d$export$713961e8e432825b;
|
|
61
|
+
var $48e85557f3729e3d$export$63e9e087a73f808b;
|
|
62
|
+
var $48e85557f3729e3d$export$d35bc1e505d1ebbf;
|
|
63
|
+
var $48e85557f3729e3d$export$1e0fb04f31d3c22a;
|
|
64
|
+
var $48e85557f3729e3d$export$45a5316056cfac3c;
|
|
65
|
+
$48e85557f3729e3d$export$8c6320d2db82081f = "spectrum-Breadcrumbs_3fe6e8";
|
|
66
|
+
$48e85557f3729e3d$export$f72910e36cd91d1e = "spectrum-Breadcrumbs-itemSeparator_3fe6e8";
|
|
67
|
+
$48e85557f3729e3d$export$a4561bd665abb5db = "is-reversed_3fe6e8";
|
|
68
|
+
$48e85557f3729e3d$export$492a5983c5fbf603 = "spectrum-Breadcrumbs-item_3fe6e8";
|
|
69
|
+
$48e85557f3729e3d$export$53da69f51b770d3 = "spectrum-ActionButton_3fe6e8";
|
|
70
|
+
$48e85557f3729e3d$export$5af6a1bcd207d9f6 = "spectrum-Breadcrumbs-itemLink_3fe6e8";
|
|
71
|
+
$48e85557f3729e3d$export$b8813cd5d7824ce7 = "is-hovered_3fe6e8";
|
|
72
|
+
$48e85557f3729e3d$export$f39a09f249340e2a = "focus-ring_3fe6e8";
|
|
73
|
+
$48e85557f3729e3d$export$8778c911bed6c759 = "is-dragged_3fe6e8";
|
|
74
|
+
$48e85557f3729e3d$export$e01337e7944312f6 = "spectrum-Breadcrumbs--small_3fe6e8";
|
|
75
|
+
$48e85557f3729e3d$export$19f957201d941895 = "spectrum-Breadcrumbs--medium_3fe6e8";
|
|
76
|
+
$48e85557f3729e3d$export$713961e8e432825b = "spectrum-Breadcrumbs--multiline_3fe6e8";
|
|
77
|
+
$48e85557f3729e3d$export$63e9e087a73f808b = "spectrum-Heading--pageTitle_3fe6e8";
|
|
78
|
+
$48e85557f3729e3d$export$d35bc1e505d1ebbf = "is-disabled_3fe6e8";
|
|
79
|
+
$48e85557f3729e3d$export$1e0fb04f31d3c22a = "is-selected_3fe6e8";
|
|
80
|
+
$48e85557f3729e3d$export$45a5316056cfac3c = "spectrum-Breadcrumb_3fe6e8";
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
function $2bfa2c84c665c457$export$c13f210c706eb549(props) {
|
|
87
|
+
let { children: children , isCurrent: isCurrent , isDisabled: isDisabled } = props;
|
|
88
|
+
let { direction: direction } = $koRP3$useLocale();
|
|
89
|
+
let ref = $koRP3$useRef();
|
|
90
|
+
let { itemProps: itemProps } = $koRP3$useBreadcrumbItem({
|
|
91
|
+
...props,
|
|
92
|
+
elementType: typeof children === 'string' ? 'span' : 'a'
|
|
93
|
+
}, ref);
|
|
94
|
+
let { hoverProps: hoverProps , isHovered: isHovered } = $koRP3$useHover(props);
|
|
95
|
+
let element = /*#__PURE__*/ $koRP3$react.cloneElement($koRP3$getWrappedElement(children), {
|
|
96
|
+
...$koRP3$mergeProps(itemProps, hoverProps),
|
|
97
|
+
ref: ref,
|
|
98
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs-itemLink', {
|
|
99
|
+
'is-disabled': !isCurrent && isDisabled,
|
|
100
|
+
'is-hovered': isHovered
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
return(/*#__PURE__*/ $koRP3$react.createElement($koRP3$Fragment, null, /*#__PURE__*/ $koRP3$react.createElement($koRP3$FocusRing, {
|
|
104
|
+
focusRingClass: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'focus-ring')
|
|
105
|
+
}, element), isCurrent === false && /*#__PURE__*/ $koRP3$react.createElement($koRP3$spectrumiconsuiChevronRightSmall, {
|
|
106
|
+
UNSAFE_className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$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
|
-
// Refs can be null at runtime.
|
|
119
|
-
let currListRef = listRef.current;
|
|
120
|
-
|
|
121
|
-
if (!currListRef) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
let listItems = Array.from(currListRef.children);
|
|
126
|
-
let containerWidth = currListRef.offsetWidth;
|
|
127
|
-
let isShowingMenu = childArray.length > visibleItems;
|
|
128
|
-
let calculatedWidth = 0;
|
|
129
|
-
let newVisibleItems = 0;
|
|
130
|
-
let maxVisibleItems = $ca93a0b524bf6d5b2a180315b966bddc$var$MAX_VISIBLE_ITEMS;
|
|
131
|
-
|
|
132
|
-
if (showRoot) {
|
|
133
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
134
|
-
newVisibleItems++;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (isShowingMenu) {
|
|
138
|
-
calculatedWidth += listItems.shift().offsetWidth;
|
|
139
|
-
maxVisibleItems--;
|
|
140
|
-
}
|
|
141
112
|
|
|
142
|
-
if (showRoot && calculatedWidth >= containerWidth) {
|
|
143
|
-
newVisibleItems--;
|
|
144
|
-
} // TODO: what if multiline and only one breadcrumb??
|
|
145
113
|
|
|
146
114
|
|
|
147
|
-
if (isMultiline) {
|
|
148
|
-
listItems.pop();
|
|
149
|
-
newVisibleItems++;
|
|
150
|
-
} else {
|
|
151
|
-
// Ensure the last breadcrumb isn't truncated when we measure it.
|
|
152
|
-
let last = listItems.pop();
|
|
153
|
-
last.style.overflow = 'visible';
|
|
154
|
-
calculatedWidth += last.offsetWidth;
|
|
155
115
|
|
|
156
|
-
if (calculatedWidth < containerWidth) {
|
|
157
|
-
newVisibleItems++;
|
|
158
|
-
}
|
|
159
116
|
|
|
160
|
-
last.style.overflow = '';
|
|
161
|
-
}
|
|
162
117
|
|
|
163
|
-
for (let breadcrumb of listItems.reverse()) {
|
|
164
|
-
calculatedWidth += breadcrumb.offsetWidth;
|
|
165
118
|
|
|
166
|
-
if (calculatedWidth < containerWidth) {
|
|
167
|
-
newVisibleItems++;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
119
|
|
|
171
|
-
return Math.max($ca93a0b524bf6d5b2a180315b966bddc$var$MIN_VISIBLE_ITEMS, Math.min(maxVisibleItems, newVisibleItems));
|
|
172
|
-
};
|
|
173
120
|
|
|
174
|
-
setVisibleItems(function* () {
|
|
175
|
-
// Update to show all items.
|
|
176
|
-
yield childArray.length; // Measure, and update to show the items that fit.
|
|
177
121
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
122
|
+
const $2adaf67aabd3300b$var$MIN_VISIBLE_ITEMS = 1;
|
|
123
|
+
const $2adaf67aabd3300b$var$MAX_VISIBLE_ITEMS = 4;
|
|
124
|
+
function $2adaf67aabd3300b$var$Breadcrumbs(props, ref) {
|
|
125
|
+
props = $koRP3$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
|
+
$koRP3$react.Children.forEach(children, (child)=>{
|
|
130
|
+
if (/*#__PURE__*/ $koRP3$react.isValidElement(child)) childArray.push(child);
|
|
185
131
|
});
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
132
|
+
let domRef = $koRP3$useDOMRef(ref);
|
|
133
|
+
let listRef = $koRP3$useRef(null);
|
|
134
|
+
let [visibleItems1, setVisibleItems] = $koRP3$useValueEffect(childArray.length);
|
|
135
|
+
let { navProps: navProps } = $koRP3$useBreadcrumbs(props);
|
|
136
|
+
let { styleProps: styleProps } = $koRP3$useStyleProps(otherProps);
|
|
137
|
+
let updateOverflow = $koRP3$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 = $2adaf67aabd3300b$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($2adaf67aabd3300b$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
|
+
$koRP3$useResizeObserver({
|
|
193
|
+
ref: domRef,
|
|
194
|
+
onResize: updateOverflow
|
|
195
|
+
});
|
|
196
|
+
$koRP3$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__*/ $koRP3$react.createElement($2bfa2c84c665c457$export$c13f210c706eb549, {
|
|
209
|
+
key: "menu"
|
|
210
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$MenuTrigger, null, /*#__PURE__*/ $koRP3$react.createElement($koRP3$ActionButton, {
|
|
211
|
+
"aria-label": "…",
|
|
212
|
+
isQuiet: true,
|
|
213
|
+
isDisabled: isDisabled
|
|
214
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($koRP3$spectrumiconsuiFolderBreadcrumb, null)), /*#__PURE__*/ $koRP3$react.createElement($koRP3$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));
|
|
226
233
|
}
|
|
227
|
-
|
|
228
|
-
contents.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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));
|
|
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__*/ $koRP3$react.createElement("li", {
|
|
243
|
+
key: key,
|
|
244
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$exports)), 'spectrum-Breadcrumbs-item')
|
|
245
|
+
}, /*#__PURE__*/ $koRP3$react.createElement($2bfa2c84c665c457$export$c13f210c706eb549, {
|
|
246
|
+
isCurrent: isCurrent,
|
|
247
|
+
isDisabled: isDisabled,
|
|
248
|
+
onPress: onPress
|
|
249
|
+
}, child.props.children)));
|
|
250
|
+
});
|
|
251
|
+
return(/*#__PURE__*/ $koRP3$react.createElement("nav", {
|
|
252
|
+
...styleProps,
|
|
253
|
+
...navProps,
|
|
254
|
+
ref: domRef
|
|
255
|
+
}, /*#__PURE__*/ $koRP3$react.createElement("ul", {
|
|
256
|
+
ref: listRef,
|
|
257
|
+
className: $koRP3$classNames((/*@__PURE__*/$parcel$interopDefault($48e85557f3729e3d$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)));
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* Breadcrumbs show hierarchy and navigational context for a user’s location within an application.
|
|
268
|
-
*/
|
|
268
|
+
*/ let $2adaf67aabd3300b$export$2dc68d50d56fbbd = /*#__PURE__*/ $koRP3$react.forwardRef($2adaf67aabd3300b$var$Breadcrumbs);
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
269
272
|
|
|
270
273
|
|
|
271
|
-
export
|
|
274
|
+
export {$37781313afe0968e$re_export$Item as Item, $2adaf67aabd3300b$export$2dc68d50d56fbbd as Breadcrumbs};
|
|
272
275
|
//# sourceMappingURL=module.js.map
|