{"version":3,"file":"Edit-f6e2a559.js","sources":["../../../common/resources/client/icons/material/ChevronRight.tsx","../../../common/resources/client/ui/breadcrumbs/breadcrumb-item.tsx","../../../common/resources/client/icons/material/MoreHoriz.tsx","../../../common/resources/client/ui/breadcrumbs/breadcrumb.tsx","../../../common/resources/client/icons/material/Edit.tsx"],"sourcesContent":["import {createSvgIcon} from '../create-svg-icon';\n\nexport const ChevronRightIcon = createSvgIcon(\n \n, 'ChevronRightOutlined');\n","import React, {HTMLAttributes, ReactElement, ReactNode} from 'react';\nimport clsx from 'clsx';\nimport {ChevronRightIcon} from '../../icons/material/ChevronRight';\nimport type {BreadcrumbSizeStyle} from './breadcrumb';\n\nexport interface BreadcrumbItemProps {\n sizeStyle?: BreadcrumbSizeStyle;\n isMenuTrigger?: boolean;\n isMenuItem?: boolean;\n children: ReactNode | ((state: {isMenuItem?: boolean}) => ReactNode);\n isCurrent?: boolean;\n onSelected?: () => void;\n isClickable?: boolean;\n isDisabled?: boolean;\n className?: string;\n isLink?: boolean;\n}\n\nexport function BreadcrumbItem(props: BreadcrumbItemProps) {\n const {\n isCurrent,\n sizeStyle,\n isMenuTrigger,\n isClickable,\n isDisabled,\n onSelected,\n className,\n isMenuItem,\n isLink,\n } = props;\n\n const children =\n typeof props.children === 'function'\n ? props.children({isMenuItem})\n : props.children;\n\n if (isMenuItem) {\n return children as ReactElement;\n }\n\n const domProps: HTMLAttributes = isMenuTrigger\n ? {}\n : {\n tabIndex: isLink && !isDisabled ? 0 : undefined,\n role: isLink ? 'link' : undefined,\n 'aria-disabled': isLink ? isDisabled : undefined,\n 'aria-current': isCurrent && isLink ? 'page' : undefined,\n onClick: () => onSelected?.(),\n };\n\n return (\n \n \n {children}\n
\n {isCurrent === false && (\n \n )}\n \n );\n}\n","import {createSvgIcon} from '../create-svg-icon';\n\nexport const MoreHorizIcon = createSvgIcon(\n \n, 'MoreHorizOutlined');\n","import React, {\n cloneElement,\n ReactElement,\n ReactNode,\n useCallback,\n useRef,\n} from 'react';\nimport {\n useLayoutEffect,\n useResizeObserver,\n useValueEffect,\n} from '@react-aria/utils';\nimport clsx from 'clsx';\nimport {IconButton} from '../buttons/icon-button';\nimport {BreadcrumbItem, BreadcrumbItemProps} from './breadcrumb-item';\nimport {MoreHorizIcon} from '../../icons/material/MoreHoriz';\nimport {ButtonSize} from '../buttons/button-size';\nimport {Menu, MenuItem, MenuTrigger} from '../navigation/menu/menu-trigger';\nimport {IconSize} from '../../icons/svg-icon';\nimport {useTrans} from '../../i18n/use-trans';\n\nconst MIN_VISIBLE_ITEMS = 1;\nconst MAX_VISIBLE_ITEMS = 10;\n\nexport interface BreadcrumbsProps {\n children?: ReactNode;\n isDisabled?: boolean;\n size?: 'sm' | 'md' | 'lg' | 'xl';\n className?: string;\n currentIsClickable?: boolean;\n isNavigation?: boolean;\n}\n\nexport function Breadcrumb(props: BreadcrumbsProps) {\n const {\n size = 'md',\n children,\n isDisabled,\n className,\n currentIsClickable,\n isNavigation,\n } = props;\n const {trans} = useTrans();\n const style = sizeStyle(size);\n\n // Not using React.Children.toArray because it mutates the key prop.\n const childArray: ReactElement[] = [];\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n childArray.push(child as ReactElement);\n }\n });\n\n const domRef = useRef(null);\n const listRef = useRef(null);\n\n const [visibleItems, setVisibleItems] = useValueEffect(childArray.length);\n\n const updateOverflow = useCallback(() => {\n const computeVisibleItems = (itemCount: number) => {\n // Refs can be null at runtime.\n const currListRef: HTMLUListElement | null = listRef.current;\n if (!currListRef) {\n return;\n }\n\n const listItems = Array.from(currListRef.children) as HTMLLIElement[];\n if (!listItems.length) return;\n\n const containerWidth = currListRef.offsetWidth;\n const isShowingMenu = childArray.length > itemCount;\n let calculatedWidth = 0;\n let newVisibleItems = 0;\n let maxVisibleItems = MAX_VISIBLE_ITEMS;\n\n calculatedWidth += listItems.shift()!.offsetWidth;\n newVisibleItems++;\n\n if (isShowingMenu) {\n calculatedWidth += listItems.shift()?.offsetWidth ?? 0;\n maxVisibleItems--;\n }\n\n if (calculatedWidth >= containerWidth) {\n newVisibleItems--;\n }\n\n // Ensure the last breadcrumb isn't truncated when we measure it.\n if (listItems.length > 0) {\n const 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 // eslint-disable-next-line no-restricted-syntax\n for (const breadcrumb of listItems.reverse()) {\n calculatedWidth += breadcrumb.offsetWidth;\n if (calculatedWidth < containerWidth) {\n newVisibleItems++;\n }\n }\n\n return Math.max(\n MIN_VISIBLE_ITEMS,\n Math.min(maxVisibleItems, newVisibleItems),\n );\n };\n\n // eslint-disable-next-line func-names\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 const 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 // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [listRef, children, setVisibleItems]);\n\n useResizeObserver({ref: domRef, onResize: updateOverflow});\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updateOverflow, [children]);\n\n let contents = childArray;\n if (childArray.length > visibleItems) {\n const selectedKey = childArray.length - 1;\n\n const menuItem = (\n \n \n \n \n \n \n \n \n );\n\n contents = [menuItem];\n const breadcrumbs = [...childArray];\n let endItems = visibleItems;\n if (visibleItems > 1) {\n contents.unshift(breadcrumbs.shift()!);\n endItems--;\n }\n contents.push(...breadcrumbs.slice(-endItems));\n }\n\n const lastIndex = contents.length - 1;\n const breadcrumbItems = contents.map((child, index) => {\n const isCurrent = index === lastIndex;\n const isClickable = !isCurrent || currentIsClickable;\n\n return cloneElement(child, {\n key: child.key || index,\n isCurrent,\n sizeStyle: style,\n isClickable,\n isDisabled,\n isLink: isNavigation && child.key !== 'menu',\n });\n });\n\n const Element = isNavigation ? 'nav' : 'div';\n\n return (\n \n \n {breadcrumbItems}\n
\n \n );\n}\n\nfunction sizeStyle(size: BreadcrumbsProps['size']): BreadcrumbSizeStyle {\n switch (size) {\n case 'sm':\n return {font: 'text-sm', icon: 'sm', btn: 'sm', minHeight: 'min-h-36'};\n case 'lg':\n return {font: 'text-lg', icon: 'md', btn: 'md', minHeight: 'min-h-42'};\n case 'xl':\n return {font: 'text-xl', icon: 'md', btn: 'md', minHeight: 'min-h-42'};\n default:\n return {font: 'text-base', icon: 'md', btn: 'md', minHeight: 'min-h-42'};\n }\n}\n\nexport interface BreadcrumbSizeStyle {\n font: string;\n icon: IconSize;\n btn: ButtonSize;\n minHeight: string;\n}\n","import {createSvgIcon} from '../create-svg-icon';\n\nexport const EditIcon = createSvgIcon(\n \n, 'EditOutlined');\n"],"names":["ChevronRightIcon","createSvgIcon","jsx","BreadcrumbItem","props","isCurrent","sizeStyle","isMenuTrigger","isClickable","isDisabled","onSelected","className","isMenuItem","isLink","children","domProps","jsxs","clsx","MoreHorizIcon","MIN_VISIBLE_ITEMS","MAX_VISIBLE_ITEMS","Breadcrumb","size","currentIsClickable","isNavigation","trans","useTrans","style","childArray","React","child","domRef","useRef","listRef","visibleItems","setVisibleItems","useValueEffect","updateOverflow","useCallback","computeVisibleItems","itemCount","currListRef","listItems","containerWidth","isShowingMenu","calculatedWidth","newVisibleItems","maxVisibleItems","_a","last","breadcrumb","useResizeObserver","useLayoutEffect","contents","selectedKey","MenuTrigger","IconButton","Menu","index","isLast","MenuItem","_b","cloneElement","breadcrumbs","endItems","lastIndex","breadcrumbItems","Element","EditIcon"],"mappings":"gIAEO,MAAMA,EAAmBC,EAC9BC,EAAAA,IAAC,OAAK,CAAA,EAAE,oDAAqD,CAAA,EAC7D,sBAAsB,ECcjB,SAASC,EAAeC,EAA4B,CACnD,KAAA,CACJ,UAAAC,EACA,UAAAC,EACA,cAAAC,EAC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