@lidofinance/lido-app-ui 1.14.0 → 1.16.0
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/README.md +33 -14
- package/dist/README.md +33 -14
- package/dist/cjs/breadcrumbs/Breadcrumbs.cjs +10 -3
- package/dist/cjs/breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/cjs/button/Button.cjs +7 -7
- package/dist/cjs/button/Button.cjs.map +1 -1
- package/dist/cjs/button/ButtonContent.cjs +0 -2
- package/dist/cjs/button/ButtonContent.cjs.map +1 -1
- package/dist/cjs/button/LinkButton.cjs +6 -35
- package/dist/cjs/button/LinkButton.cjs.map +1 -1
- package/dist/cjs/counter/Counter.module.css.cjs +1 -1
- package/dist/cjs/disclaimer/Disclaimer.cjs +0 -1
- package/dist/cjs/disclaimer/Disclaimer.cjs.map +1 -1
- package/dist/cjs/hidden/Hidden.cjs.map +1 -1
- package/dist/cjs/hidden/Hidden.module.css.cjs +1 -1
- package/dist/cjs/icon-button/CloseButton.cjs.map +1 -1
- package/dist/cjs/icon-button/IconButton.cjs +7 -7
- package/dist/cjs/icon-button/IconButton.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.css +14 -6
- package/dist/cjs/info-tooltip/InfoTooltip.cjs +4 -4
- package/dist/cjs/info-tooltip/InfoTooltip.cjs.map +1 -1
- package/dist/cjs/info-tooltip/InfoTooltip.module.css.cjs +1 -1
- package/dist/cjs/input/Input.cjs +23 -11
- package/dist/cjs/input/Input.cjs.map +1 -1
- package/dist/cjs/input/Input.module.css.cjs +1 -1
- package/dist/cjs/link-provider/Anchor.cjs +19 -6
- package/dist/cjs/link-provider/Anchor.cjs.map +1 -1
- package/dist/cjs/link-provider/LinkProvider.cjs +1 -1
- package/dist/cjs/link-provider/LinkProvider.cjs.map +1 -1
- package/dist/cjs/logo/Logo.cjs.map +1 -1
- package/dist/cjs/nav-link/NavLink.cjs +7 -3
- package/dist/cjs/nav-link/NavLink.cjs.map +1 -1
- package/dist/cjs/rich-input/RichInput.cjs +46 -16
- package/dist/cjs/rich-input/RichInput.cjs.map +1 -1
- package/dist/cjs/rich-input/RichInput.module.css.cjs +1 -1
- package/dist/cjs/sidebar/Sidebar.cjs +2 -2
- package/dist/cjs/sidebar/Sidebar.cjs.map +1 -1
- package/dist/cjs/sidebar/SidebarToggle.cjs +1 -1
- package/dist/cjs/sidebar/SidebarToggle.cjs.map +1 -1
- package/dist/cjs/small-card/SmallCard.cjs.map +1 -1
- package/dist/cjs/stack/Stack.cjs +1 -1
- package/dist/cjs/stack/Stack.cjs.map +1 -1
- package/dist/cjs/tag/Tag.cjs.map +1 -1
- package/dist/cjs/tag/Tag.module.css.cjs +1 -1
- package/dist/cjs/text-link/TextLink.cjs +1 -3
- package/dist/cjs/text-link/TextLink.cjs.map +1 -1
- package/dist/cjs/theme-switcher/ThemeSwitcher.cjs.map +1 -1
- package/dist/cjs/typography/Typography.cjs +21 -8
- package/dist/cjs/typography/Typography.cjs.map +1 -1
- package/dist/cjs/typography/Typography.module.css.cjs +1 -1
- package/dist/cjs/utils/ActionElement.cjs +1 -1
- package/dist/cjs/utils/ActionElement.cjs.map +1 -1
- package/dist/cjs/utils/breakpoints.cjs +11 -12
- package/dist/cjs/utils/breakpoints.cjs.map +1 -1
- package/dist/cjs/utils/joinAriaLabel.cjs +8 -0
- package/dist/cjs/utils/joinAriaLabel.cjs.map +1 -0
- package/dist/cjs/utils/responsive.cjs.map +1 -1
- package/dist/esm/breadcrumbs/Breadcrumbs.mjs +10 -3
- package/dist/esm/breadcrumbs/Breadcrumbs.mjs.map +1 -1
- package/dist/esm/button/Button.mjs +7 -7
- package/dist/esm/button/Button.mjs.map +1 -1
- package/dist/esm/button/ButtonContent.mjs +1 -2
- package/dist/esm/button/ButtonContent.mjs.map +1 -1
- package/dist/esm/button/LinkButton.mjs +6 -35
- package/dist/esm/button/LinkButton.mjs.map +1 -1
- package/dist/esm/counter/Counter.module.css.mjs +1 -1
- package/dist/esm/disclaimer/Disclaimer.mjs +0 -1
- package/dist/esm/disclaimer/Disclaimer.mjs.map +1 -1
- package/dist/esm/hidden/Hidden.mjs.map +1 -1
- package/dist/esm/hidden/Hidden.module.css.mjs +1 -1
- package/dist/esm/icon-button/CloseButton.mjs.map +1 -1
- package/dist/esm/icon-button/IconButton.mjs +7 -7
- package/dist/esm/icon-button/IconButton.mjs.map +1 -1
- package/dist/esm/index.css +14 -6
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/info-tooltip/InfoTooltip.mjs +4 -4
- package/dist/esm/info-tooltip/InfoTooltip.mjs.map +1 -1
- package/dist/esm/info-tooltip/InfoTooltip.module.css.mjs +1 -1
- package/dist/esm/input/Input.mjs +23 -11
- package/dist/esm/input/Input.mjs.map +1 -1
- package/dist/esm/input/Input.module.css.mjs +1 -1
- package/dist/esm/link-provider/Anchor.mjs +19 -7
- package/dist/esm/link-provider/Anchor.mjs.map +1 -1
- package/dist/esm/link-provider/LinkProvider.mjs +1 -1
- package/dist/esm/link-provider/LinkProvider.mjs.map +1 -1
- package/dist/esm/logo/Logo.mjs.map +1 -1
- package/dist/esm/nav-link/NavLink.mjs +8 -4
- package/dist/esm/nav-link/NavLink.mjs.map +1 -1
- package/dist/esm/rich-input/RichInput.mjs +46 -16
- package/dist/esm/rich-input/RichInput.mjs.map +1 -1
- package/dist/esm/rich-input/RichInput.module.css.mjs +1 -1
- package/dist/esm/sidebar/Sidebar.mjs +2 -2
- package/dist/esm/sidebar/Sidebar.mjs.map +1 -1
- package/dist/esm/sidebar/SidebarToggle.mjs +1 -1
- package/dist/esm/sidebar/SidebarToggle.mjs.map +1 -1
- package/dist/esm/small-card/SmallCard.mjs.map +1 -1
- package/dist/esm/stack/Stack.mjs +1 -1
- package/dist/esm/stack/Stack.mjs.map +1 -1
- package/dist/esm/tag/Tag.mjs.map +1 -1
- package/dist/esm/tag/Tag.module.css.mjs +1 -1
- package/dist/esm/text-link/TextLink.mjs +1 -3
- package/dist/esm/text-link/TextLink.mjs.map +1 -1
- package/dist/esm/theme-switcher/ThemeSwitcher.mjs.map +1 -1
- package/dist/esm/typography/Typography.mjs +19 -9
- package/dist/esm/typography/Typography.mjs.map +1 -1
- package/dist/esm/typography/Typography.module.css.mjs +1 -1
- package/dist/esm/utils/ActionElement.mjs +1 -1
- package/dist/esm/utils/ActionElement.mjs.map +1 -1
- package/dist/esm/utils/breakpoints.mjs +10 -11
- package/dist/esm/utils/breakpoints.mjs.map +1 -1
- package/dist/esm/utils/joinAriaLabel.mjs +4 -0
- package/dist/esm/utils/joinAriaLabel.mjs.map +1 -0
- package/dist/esm/utils/responsive.mjs.map +1 -1
- package/dist/index.css +14 -6
- package/dist/styles/breakpoints.css +10 -16
- package/dist/styles/typography-mixins.css +14 -4
- package/dist/types/breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/types/button/Button.d.ts +4 -10
- package/dist/types/button/Button.d.ts.map +1 -1
- package/dist/types/button/ButtonContent.d.ts +0 -1
- package/dist/types/button/ButtonContent.d.ts.map +1 -1
- package/dist/types/button/LinkButton.d.ts +9 -8
- package/dist/types/button/LinkButton.d.ts.map +1 -1
- package/dist/types/button/index.d.ts +1 -1
- package/dist/types/button/index.d.ts.map +1 -1
- package/dist/types/button/types.d.ts +4 -0
- package/dist/types/button/types.d.ts.map +1 -1
- package/dist/types/hidden/Hidden.d.ts +4 -4
- package/dist/types/hidden/Hidden.d.ts.map +1 -1
- package/dist/types/icon-button/CloseButton.d.ts +3 -3
- package/dist/types/icon-button/CloseButton.d.ts.map +1 -1
- package/dist/types/icon-button/IconButton.d.ts +4 -38
- package/dist/types/icon-button/IconButton.d.ts.map +1 -1
- package/dist/types/icon-button/index.d.ts +1 -1
- package/dist/types/icon-button/index.d.ts.map +1 -1
- package/dist/types/icon-button/types.d.ts +26 -0
- package/dist/types/icon-button/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/info-tooltip/InfoTooltip.d.ts +4 -1
- package/dist/types/info-tooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/types/input/Input.d.ts +5 -1
- package/dist/types/input/Input.d.ts.map +1 -1
- package/dist/types/link-provider/Anchor.d.ts +3 -2
- package/dist/types/link-provider/Anchor.d.ts.map +1 -1
- package/dist/types/link-provider/LinkProvider.d.ts +1 -1
- package/dist/types/link-provider/LinkProvider.d.ts.map +1 -1
- package/dist/types/logo/Logo.d.ts +5 -8
- package/dist/types/logo/Logo.d.ts.map +1 -1
- package/dist/types/nav-link/NavLink.d.ts +2 -2
- package/dist/types/nav-link/NavLink.d.ts.map +1 -1
- package/dist/types/rich-input/RichInput.d.ts +9 -2
- package/dist/types/rich-input/RichInput.d.ts.map +1 -1
- package/dist/types/sidebar/Sidebar.d.ts +2 -2
- package/dist/types/sidebar/Sidebar.d.ts.map +1 -1
- package/dist/types/sidebar/SidebarToggle.d.ts +4 -4
- package/dist/types/sidebar/SidebarToggle.d.ts.map +1 -1
- package/dist/types/small-card/SmallCard.d.ts +2 -8
- package/dist/types/small-card/SmallCard.d.ts.map +1 -1
- package/dist/types/stack/Stack.d.ts +1 -1
- package/dist/types/stack/Stack.d.ts.map +1 -1
- package/dist/types/tag/Tag.d.ts +3 -1
- package/dist/types/tag/Tag.d.ts.map +1 -1
- package/dist/types/text-link/TextLink.d.ts +3 -9
- package/dist/types/text-link/TextLink.d.ts.map +1 -1
- package/dist/types/theme-switcher/ThemeSwitcher.d.ts +3 -3
- package/dist/types/theme-switcher/ThemeSwitcher.d.ts.map +1 -1
- package/dist/types/typography/Typography.d.ts +15 -6
- package/dist/types/typography/Typography.d.ts.map +1 -1
- package/dist/types/utils/ActionElement.d.ts +11 -1
- package/dist/types/utils/ActionElement.d.ts.map +1 -1
- package/dist/types/utils/breakpoints.d.ts +9 -10
- package/dist/types/utils/breakpoints.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +3 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/joinAriaLabel.d.ts +2 -0
- package/dist/types/utils/joinAriaLabel.d.ts.map +1 -0
- package/dist/types/utils/responsive.d.ts +12 -16
- package/dist/types/utils/responsive.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.cjs","sources":["../../../src/sidebar/Sidebar.tsx"],"sourcesContent":["import {\n useEffect,\n useContext,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ReactNode,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport {\n useBodyScrollLock,\n useEscape,\n useFocusTrap,\n useIsomorphicLayoutEffect,\n} from '../hooks'\nimport { CloseButton } from '../icon-button'\nimport { sidebarBreakpointWidth } from '../utils'\nimport styles from './Sidebar.module.css'\nimport { SidebarContext } from './SidebarContext'\n\nexport const DRAWER_QUERY = `(width < ${sidebarBreakpointWidth}px)`\n\nconst OFFSET_VAR = '--local-measured-offset'\n\nconst useIsDrawerViewport = () => {\n const [matches, setMatches] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n if (typeof window.matchMedia !== 'function') return\n const mql = window.matchMedia(DRAWER_QUERY)\n const update = () => setMatches(mql.matches)\n update()\n mql.addEventListener('change', update)\n return () => mql.removeEventListener('change', update)\n }, [])\n\n return matches\n}\n\nconst isPlainLinkClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.button !== 0) return false\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n return false\n const link = (event.target as Element).closest?.('a[href]')\n if (!link || !event.currentTarget.contains(link)) return false\n const target = link.getAttribute('target') ?? ''\n return target === '' || target === '_self'\n}\n\nexport type SidebarProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'> & {\n logo?: ReactNode\n footer?: ReactNode\n children?: ReactNode\n /** Drawer state; only has an effect at `sidebar-down` widths. Defaults to the SidebarLayout's. */\n open?: boolean\n onClose?: () => void\n navLabel?: string\n /** Close the drawer when a link inside is clicked. */\n closeOnNavigate?: boolean\n}\n\nexport const Sidebar = ({\n logo,\n footer,\n children,\n open: openProp,\n onClose: onCloseProp,\n id: idProp,\n navLabel = 'Primary',\n closeOnNavigate = true,\n className,\n onClick,\n 'aria-label': ariaLabel = 'Main navigation',\n ...rest\n}: SidebarProps) => {\n const context = useContext(SidebarContext)\n const open = openProp ?? context?.sidebarProps.open ?? false\n const onClose = onCloseProp ?? context?.sidebarProps.onClose\n const id = idProp ?? context?.sidebarProps.id\n const [root, setRoot] = useState<HTMLElement | null>(null)\n const isDrawerViewport = useIsDrawerViewport()\n\n useIsomorphicLayoutEffect(() => {\n const parent = root?.parentElement\n if (!root || !parent) return\n\n let last = ''\n const measure = () => {\n const top = parent.getBoundingClientRect().top + window.scrollY\n const value = `${Math.max(0, Math.round(top))}px`\n if (value === last) return\n last = value\n root.style.setProperty(OFFSET_VAR, value)\n }\n\n measure()\n window.addEventListener('resize', measure)\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure)\n observer?.observe(document.documentElement)\n return () => {\n window.removeEventListener('resize', measure)\n observer?.disconnect()\n }\n }, [root])\n\n const drawerActive = open && isDrawerViewport\n\n const wasDrawerViewport = useRef(isDrawerViewport)\n useEffect(() => {\n if (wasDrawerViewport.current && !isDrawerViewport && open) onClose?.()\n wasDrawerViewport.current = isDrawerViewport\n }, [isDrawerViewport, open, onClose])\n\n useBodyScrollLock({ enabled: drawerActive })\n useFocusTrap(root, { enabled: drawerActive })\n useEscape(() => onClose?.(), { enabled: drawerActive && !!onClose })\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (closeOnNavigate && drawerActive && onClose && isPlainLinkClick(event))\n onClose()\n }\n\n return (\n <>\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- scrim is a pointer-only dismiss target; Escape closes via useEscape */}\n <div\n className={cn(styles.scrim, open && styles.scrimOpen)}\n onClick={onClose}\n aria-hidden='true'\n />\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions -- delegated link-click handler; links are natively keyboard-activatable */}\n <div\n ref={setRoot}\n id={id}\n role={drawerActive ? 'dialog' : undefined}\n aria-modal={drawerActive || undefined}\n aria-label={drawerActive ? ariaLabel : undefined}\n data-open={open}\n className={cn(styles.sidebar, className)}\n onClick={handleClick}\n {...rest}\n >\n {logo != null || onClose ? (\n <div\n className={cn(\n styles.logoRow,\n logo == null && styles.logoRowCloseOnly,\n )}\n >\n <div className={styles.logo}>{logo}</div>\n {onClose ? (\n <CloseButton\n aria-label='Close menu'\n onClick={onClose}\n className={styles.closeButton}\n />\n ) : null}\n </div>\n ) : null}\n <div className={styles.scroll}>\n <nav aria-label={navLabel} className={styles.menu}>\n {children}\n </nav>\n </div>\n {footer != null ? <div className={styles.footer}>{footer}</div> : null}\n </div>\n </>\n )\n}\n"],"names":["DRAWER_QUERY","sidebarBreakpointWidth","OFFSET_VAR","useIsDrawerViewport","matches","setMatches","useState","useIsomorphicLayoutEffect","window","matchMedia","mql","update","addEventListener","removeEventListener","isPlainLinkClick","event","button","metaKey","ctrlKey","shiftKey","altKey","link","target","closest","currentTarget","contains","getAttribute","Sidebar","_ref","logo","footer","children","open","openProp","onClose","onCloseProp","id","idProp","navLabel","closeOnNavigate","className","onClick","ariaLabel","rest","context","useContext","SidebarContext","sidebarProps","root","setRoot","isDrawerViewport","parent","parentElement","last","measure","top","getBoundingClientRect","scrollY","value","Math","max","round","style","setProperty","observer","ResizeObserver","observe","document","documentElement","disconnect","drawerActive","wasDrawerViewport","useRef","useEffect","current","useBodyScrollLock","enabled","useFocusTrap","useEscape","handleClick","_jsxs","_Fragment","_jsx","cn","styles","scrim","scrimOpen","ref","role","undefined","sidebar","logoRow","logoRowCloseOnly","CloseButton","closeButton","scroll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ffect,\n useContext,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ReactNode,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport {\n useBodyScrollLock,\n useEscape,\n useFocusTrap,\n useIsomorphicLayoutEffect,\n} from '../hooks'\nimport { CloseButton } from '../icon-button'\nimport { downQuery } from '../utils'\nimport styles from './Sidebar.module.css'\nimport { SidebarContext } from './SidebarContext'\n\nexport const DRAWER_QUERY = downQuery('lg')\n\nconst OFFSET_VAR = '--local-measured-offset'\n\nconst useIsDrawerViewport = () => {\n const [matches, setMatches] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n if (typeof window.matchMedia !== 'function') return\n const mql = window.matchMedia(DRAWER_QUERY)\n const update = () => setMatches(mql.matches)\n update()\n mql.addEventListener('change', update)\n return () => mql.removeEventListener('change', update)\n }, [])\n\n return matches\n}\n\nconst isPlainLinkClick = (event: MouseEvent<HTMLDivElement>) => {\n if (event.button !== 0) return false\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)\n return false\n const link = (event.target as Element).closest?.('a[href]')\n if (!link || !event.currentTarget.contains(link)) return false\n const target = link.getAttribute('target') ?? ''\n return target === '' || target === '_self'\n}\n\nexport type SidebarProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'> & {\n logo?: ReactNode\n footer?: ReactNode\n children?: ReactNode\n /** Drawer state; only has an effect at `lg-down` widths. Defaults to the SidebarLayout's. */\n open?: boolean\n onClose?: () => void\n navLabel?: string\n /** Close the drawer when a link inside is clicked. */\n closeOnNavigate?: boolean\n}\n\nexport const Sidebar = ({\n logo,\n footer,\n children,\n open: openProp,\n onClose: onCloseProp,\n id: idProp,\n navLabel = 'Primary',\n closeOnNavigate = true,\n className,\n onClick,\n 'aria-label': ariaLabel = 'Main navigation',\n ...rest\n}: SidebarProps) => {\n const context = useContext(SidebarContext)\n const open = openProp ?? context?.sidebarProps.open ?? false\n const onClose = onCloseProp ?? context?.sidebarProps.onClose\n const id = idProp ?? context?.sidebarProps.id\n const [root, setRoot] = useState<HTMLElement | null>(null)\n const isDrawerViewport = useIsDrawerViewport()\n\n useIsomorphicLayoutEffect(() => {\n const parent = root?.parentElement\n if (!root || !parent) return\n\n let last = ''\n const measure = () => {\n const top = parent.getBoundingClientRect().top + window.scrollY\n const value = `${Math.max(0, Math.round(top))}px`\n if (value === last) return\n last = value\n root.style.setProperty(OFFSET_VAR, value)\n }\n\n measure()\n window.addEventListener('resize', measure)\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure)\n observer?.observe(document.documentElement)\n return () => {\n window.removeEventListener('resize', measure)\n observer?.disconnect()\n }\n }, [root])\n\n const drawerActive = open && isDrawerViewport\n\n const wasDrawerViewport = useRef(isDrawerViewport)\n useEffect(() => {\n if (wasDrawerViewport.current && !isDrawerViewport && open) onClose?.()\n wasDrawerViewport.current = isDrawerViewport\n }, [isDrawerViewport, open, onClose])\n\n useBodyScrollLock({ enabled: drawerActive })\n useFocusTrap(root, { enabled: drawerActive })\n useEscape(() => onClose?.(), { enabled: drawerActive && !!onClose })\n\n const handleClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (closeOnNavigate && drawerActive && onClose && isPlainLinkClick(event))\n onClose()\n }\n\n return (\n <>\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- scrim is a pointer-only dismiss target; Escape closes via useEscape */}\n <div\n className={cn(styles.scrim, open && styles.scrimOpen)}\n onClick={onClose}\n aria-hidden='true'\n />\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions -- delegated link-click handler; links are natively keyboard-activatable */}\n <div\n ref={setRoot}\n id={id}\n role={drawerActive ? 'dialog' : undefined}\n aria-modal={drawerActive || undefined}\n aria-label={drawerActive ? ariaLabel : undefined}\n data-open={open}\n className={cn(styles.sidebar, className)}\n onClick={handleClick}\n {...rest}\n >\n {logo != null || onClose ? (\n <div\n className={cn(\n styles.logoRow,\n logo == null && styles.logoRowCloseOnly,\n )}\n >\n <div className={styles.logo}>{logo}</div>\n {onClose ? (\n <CloseButton\n aria-label='Close menu'\n onClick={onClose}\n className={styles.closeButton}\n />\n ) : null}\n </div>\n ) : null}\n <div className={styles.scroll}>\n <nav aria-label={navLabel} className={styles.menu}>\n {children}\n </nav>\n </div>\n {footer != null ? <div className={styles.footer}>{footer}</div> : null}\n </div>\n </>\n )\n}\n"],"names":["DRAWER_QUERY","downQuery","OFFSET_VAR","useIsDrawerViewport","matches","setMatches","useState","useIsomorphicLayoutEffect","window","matchMedia","mql","update","addEventListener","removeEventListener","isPlainLinkClick","event","button","metaKey","ctrlKey","shiftKey","altKey","link","target","closest","currentTarget","contains","getAttribute","Sidebar","_ref","logo","footer","children","open","openProp","onClose","onCloseProp","id","idProp","navLabel","closeOnNavigate","className","onClick","ariaLabel","rest","context","useContext","SidebarContext","sidebarProps","root","setRoot","isDrawerViewport","parent","parentElement","last","measure","top","getBoundingClientRect","scrollY","value","Math","max","round","style","setProperty","observer","ResizeObserver","observe","document","documentElement","disconnect","drawerActive","wasDrawerViewport","useRef","useEffect","current","useBodyScrollLock","enabled","useFocusTrap","useEscape","handleClick","_jsxs","_Fragment","_jsx","cn","styles","scrim","scrimOpen","ref","role","undefined","sidebar","logoRow","logoRowCloseOnly","CloseButton","closeButton","scroll","menu"],"mappings":";;;;;;;;;;;;;;;;MAuBaA,YAAY,GAAGC,qBAAS,CAAC,IAAI,EAAC;AAE3C,MAAMC,UAAU,GAAG,yBAAyB,CAAA;AAE5C,MAAMC,mBAAmB,GAAGA,MAAM;EAChC,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAA;AAE7CC,EAAAA,mDAAyB,CAAC,MAAM;AAC9B,IAAA,IAAI,OAAOC,MAAM,CAACC,UAAU,KAAK,UAAU,EAAE,OAAA;AAC7C,IAAA,MAAMC,GAAG,GAAGF,MAAM,CAACC,UAAU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AEF,IAAAA;AAAI,SAAM,CAAC,EACxCK,OAAO,gBACNgD,cAAA,CAACW,uBAAW,EAAA;AACV,UAAA,YAAA,EAAW,YAAY;AACvBpD,UAAAA,OAAO,EAAEP,OAAQ;UACjBM,SAAS,EAAE4C,cAAM,CAACU,WAAAA;SACnB,CAAC,GACA,IAAI,CAAA;AAAA,OACL,CAAC,GACJ,IAAI,eACRZ,cAAA,CAAA,KAAA,EAAA;QAAK1C,SAAS,EAAE4C,cAAM,CAACW,MAAO;AAAAhE,QAAAA,QAAA,eAC5BmD,cAAA,CAAA,KAAA,EAAA;AAAK,UAAA,YAAA,EAAY5C,QAAS;UAACE,SAAS,EAAE4C,cAAM,CAACY,IAAK;AAAAjE,UAAAA,QAAA,EAC/CA,QAAAA;SACE,CAAA;AAAC,OACH,CAAC,EACLD,MAAM,IAAI,IAAI,gBAAGoD,cAAA,CAAA,KAAA,EAAA;QAAK1C,SAAS,EAAE4C,cAAM,CAACtD,MAAO;AAAAC,QAAAA,QAAA,EAAED,MAAAA;OAAY,CAAC,GAAG,IAAI,CAAA;AAAA,KACnE,CAAC,CAAA;AAAA,GACN,CAAC,CAAA;AAEP;;;;;"}
|
|
@@ -11,7 +11,7 @@ const IconButton = require('../icon-button/IconButton.cjs');
|
|
|
11
11
|
const IconMenu = require('../icons/components/base/IconMenu.cjs');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Burger that opens the Sidebar drawer; visible only at `
|
|
14
|
+
* Burger that opens the Sidebar drawer; visible only at `lg-down` widths.
|
|
15
15
|
* Inside a SidebarLayout it wires `aria-*` (explicit props win) and toggles after your
|
|
16
16
|
* `onClick`, unless that calls `event.preventDefault()`.
|
|
17
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarToggle.cjs","sources":["../../../src/sidebar/SidebarToggle.tsx"],"sourcesContent":["import { forwardRef, useContext, type MouseEvent } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconButton, type
|
|
1
|
+
{"version":3,"file":"SidebarToggle.cjs","sources":["../../../src/sidebar/SidebarToggle.tsx"],"sourcesContent":["import { forwardRef, useContext, type MouseEvent } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconButton, type IconButtonAsButtonProps } from '../icon-button'\nimport { IconMenu } from '../icons'\nimport { SidebarContext } from './SidebarContext'\nimport styles from './SidebarToggle.module.css'\n\nexport type SidebarToggleProps = Omit<\n IconButtonAsButtonProps,\n 'icon' | 'aria-label'\n> & {\n 'aria-label'?: string\n}\n\n/**\n * Burger that opens the Sidebar drawer; visible only at `lg-down` widths.\n * Inside a SidebarLayout it wires `aria-*` (explicit props win) and toggles after your\n * `onClick`, unless that calls `event.preventDefault()`.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n (\n { className, 'aria-label': ariaLabel = 'Open menu', onClick, ...rest },\n ref,\n ) => {\n const toggleProps = useContext(SidebarContext)?.toggleProps\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) toggleProps?.onClick()\n }\n return (\n <IconButton\n ref={ref}\n variant='ghost'\n icon={<IconMenu />}\n aria-label={ariaLabel}\n {...toggleProps}\n {...rest}\n onClick={handleClick}\n className={cn(styles.toggle, className)}\n />\n )\n },\n)\n\nSidebarToggle.displayName = 'SidebarToggle'\n"],"names":["SidebarToggle","forwardRef","_ref","ref","className","ariaLabel","onClick","rest","toggleProps","useContext","SidebarContext","handleClick","event","defaultPrevented","_jsx","IconButton","variant","icon","IconMenu","cn","styles","toggle","displayName"],"mappings":";;;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,gBAAGC,gBAAU,CACrC,CAAAC,IAAA,EAEEC,GAAG,KACA;EAAA,IAFH;IAAEC,SAAS;IAAE,YAAY,EAAEC,SAAS,GAAG,WAAW;IAAEC,OAAO;IAAE,GAAGC,IAAAA;AAAK,GAAC,GAAAL,IAAA,CAAA;AAGtE,EAAA,MAAMM,WAAW,GAAGC,gBAAU,CAACC,6BAAc,CAAC,EAAEF,WAAW,CAAA;EAC3D,MAAMG,WAAW,GAAIC,KAAoC,IAAK;IAC5DN,OAAO,GAAGM,KAAK,CAAC,CAAA;IAChB,IAAI,CAACA,KAAK,CAACC,gBAAgB,EAAEL,WAAW,EAAEF,OAAO,EAAE,CAAA;GACpD,CAAA;EACD,oBACEQ,cAAA,CAACC,qBAAU,EAAA;AACTZ,IAAAA,GAAG,EAAEA,GAAI;AACTa,IAAAA,OAAO,EAAC,OAAO;AACfC,IAAAA,IAAI,eAAEH,cAAA,CAACI,iBAAQ,IAAE,CAAE;AACnB,IAAA,YAAA,EAAYb,SAAU;AAAA,IAAA,GAClBG,WAAW;AAAA,IAAA,GACXD,IAAI;AACRD,IAAAA,OAAO,EAAEK,WAAY;AACrBP,IAAAA,SAAS,EAAEe,EAAE,CAACC,oBAAM,CAACC,MAAM,EAAEjB,SAAS,CAAA;AAAE,GACzC,CAAC,CAAA;AAEN,CACF,EAAC;AAEDJ,aAAa,CAACsB,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmallCard.cjs","sources":["../../../src/small-card/SmallCard.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './SmallCard.module.css'\n\nexport type SmallCardDataTestId = {\n root?: string\n image?: string\n logo?: string\n icon?: string\n title?: string\n description?: string\n footer?: string\n}\n\nexport type SmallCardProps = Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n 'title'\n> & {\n /** Fixed-height (120px) media slot above the header — an image or illustration. */\n image?: ReactNode\n logo?: ReactNode\n /** Trailing glyph next to the title — an external-link arrow, a badge, etc. */\n icon?: ReactNode\n title: ReactNode\n
|
|
1
|
+
{"version":3,"file":"SmallCard.cjs","sources":["../../../src/small-card/SmallCard.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './SmallCard.module.css'\n\nexport type SmallCardDataTestId = {\n root?: string\n image?: string\n logo?: string\n icon?: string\n title?: string\n description?: string\n footer?: string\n}\n\nexport type SmallCardProps = Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n 'title'\n> & {\n /** Fixed-height (120px) media slot above the header — an image or illustration. */\n image?: ReactNode\n logo?: ReactNode\n /** Trailing glyph next to the title — an external-link arrow, a badge, etc. */\n icon?: ReactNode\n title: ReactNode\n description?: ReactNode\n /** Arbitrary content below the description — wraps in a row, e.g. a list of `Tag`s. */\n footer?: ReactNode\n dataTestId?: SmallCardDataTestId\n} & Pick<AnchorProps, 'external' | 'linkProps'>\n\n/** Clickable card that always renders as a link: optional `image`, `logo`, title with trailing `icon`, `description` and `footer`; title and description wrap instead of truncating. */\nexport const SmallCard = forwardRef<HTMLAnchorElement, SmallCardProps>(\n (\n {\n image,\n logo,\n icon,\n title,\n description,\n footer,\n className,\n dataTestId,\n ...rest\n },\n ref,\n ) => (\n <Anchor\n ref={ref}\n className={cn(styles.card, className)}\n data-testid={dataTestId?.root}\n {...rest}\n >\n <div className={styles.content}>\n {image != null ? (\n <div className={styles.image} data-testid={dataTestId?.image}>\n {image}\n </div>\n ) : null}\n <div className={styles.header}>\n {logo != null ? (\n <span className={styles.logo} data-testid={dataTestId?.logo}>\n {logo}\n </span>\n ) : null}\n <span className={styles.title} data-testid={dataTestId?.title}>\n {title}\n </span>\n {icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null}\n </div>\n {description != null ? (\n <p\n className={styles.description}\n data-testid={dataTestId?.description}\n >\n {description}\n </p>\n ) : null}\n </div>\n {footer != null ? (\n <div className={styles.footer} data-testid={dataTestId?.footer}>\n {footer}\n </div>\n ) : null}\n </Anchor>\n ),\n)\n\nSmallCard.displayName = 'SmallCard'\n"],"names":["SmallCard","forwardRef","_ref","ref","image","logo","icon","title","description","footer","className","dataTestId","rest","_jsxs","Anchor","cn","styles","card","root","children","content","_jsx","header","displayName"],"mappings":";;;;;;;;;;AAiCA;AACO,MAAMA,SAAS,gBAAGC,gBAAU,CACjC,CAAAC,IAAA,EAYEC,GAAG,KAAA;EAAA,IAXH;IACEC,KAAK;IACLC,IAAI;IACJC,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,MAAM;IACNC,SAAS;IACTC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAV,IAAA,CAAA;EAAA,oBAGDW,eAAA,CAACC,aAAM,EAAA;AACLX,IAAAA,GAAG,EAAEA,GAAI;IACTO,SAAS,EAAEK,EAAE,CAACC,gBAAM,CAACC,IAAI,EAAEP,SAAS,CAAE;IACtC,aAAaC,EAAAA,UAAU,EAAEO,IAAK;AAAA,IAAA,GAC1BN,IAAI;AAAAO,IAAAA,QAAA,gBAERN,eAAA,CAAA,KAAA,EAAA;MAAKH,SAAS,EAAEM,gBAAM,CAACI,OAAQ;AAAAD,MAAAA,QAAA,EAC5Bf,CAAAA,KAAK,IAAI,IAAI,gBACZiB,cAAA,CAAA,KAAA,EAAA;QAAKX,SAAS,EAAEM,gBAAM,CAACZ,KAAM;QAAC,aAAaO,EAAAA,UAAU,EAAEP,KAAM;AAAAe,QAAAA,QAAA,EAC1Df,KAAAA;AAAK,OACH,CAAC,GACJ,IAAI,eACRS,eAAA,CAAA,KAAA,EAAA;QAAKH,SAAS,EAAEM,gBAAM,CAACM,MAAO;AAAAH,QAAAA,QAAA,EAC3Bd,CAAAA,IAAI,IAAI,IAAI,gBACXgB,cAAA,CAAA,MAAA,EAAA;UAAMX,SAAS,EAAEM,gBAAM,CAACX,IAAK;UAAC,aAAaM,EAAAA,UAAU,EAAEN,IAAK;AAAAc,UAAAA,QAAA,EACzDd,IAAAA;AAAI,SACD,CAAC,GACL,IAAI,eACRgB,cAAA,CAAA,MAAA,EAAA;UAAMX,SAAS,EAAEM,gBAAM,CAACT,KAAM;UAAC,aAAaI,EAAAA,UAAU,EAAEJ,KAAM;AAAAY,UAAAA,QAAA,EAC3DZ,KAAAA;AAAK,SACF,CAAC,EACND,IAAI,IAAI,IAAI,gBACXe,cAAA,CAAA,MAAA,EAAA;UACEX,SAAS,EAAEM,gBAAM,CAACV,IAAK;AACvB,UAAA,aAAA,EAAY,MAAM;UAClB,aAAaK,EAAAA,UAAU,EAAEL,IAAK;AAAAa,UAAAA,QAAA,EAE7Bb,IAAAA;SACG,CAAC,GACL,IAAI,CAAA;AAAA,OACL,CAAC,EACLE,WAAW,IAAI,IAAI,gBAClBa,cAAA,CAAA,GAAA,EAAA;QACEX,SAAS,EAAEM,gBAAM,CAACR,WAAY;QAC9B,aAAaG,EAAAA,UAAU,EAAEH,WAAY;AAAAW,QAAAA,QAAA,EAEpCX,WAAAA;OACA,CAAC,GACF,IAAI,CAAA;AAAA,KACL,CAAC,EACLC,MAAM,IAAI,IAAI,gBACbY,cAAA,CAAA,KAAA,EAAA;MAAKX,SAAS,EAAEM,gBAAM,CAACP,MAAO;MAAC,aAAaE,EAAAA,UAAU,EAAEF,MAAO;AAAAU,MAAAA,QAAA,EAC5DV,MAAAA;KACE,CAAC,GACJ,IAAI,CAAA;AAAA,GACF,CAAC,CAAA;AAAA,CAEb,EAAC;AAEDT,SAAS,CAACuB,WAAW,GAAG,WAAW;;;;"}
|
package/dist/cjs/stack/Stack.cjs
CHANGED
|
@@ -23,7 +23,7 @@ const justifyToCss = justify => ({
|
|
|
23
23
|
around: 'space-around',
|
|
24
24
|
evenly: 'space-evenly'
|
|
25
25
|
})[justify];
|
|
26
|
-
/** Flex container; `direction`, `gap`, `align`, `justify` and `wrap` take a value or a desktop-first per-breakpoint object like `{ base: 'row', smDown: 'column' }`, where `smDown` applies
|
|
26
|
+
/** Flex container; `direction`, `gap`, `align`, `justify` and `wrap` take a value or a desktop-first per-breakpoint object like `{ base: 'row', smDown: 'column' }`, where `smDown` applies at `breakpointWidths.sm` (600px) and below. */
|
|
27
27
|
const Stack = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
28
28
|
let {
|
|
29
29
|
as: Component = 'div',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.cjs","sources":["../../../src/stack/Stack.tsx"],"sourcesContent":["import { forwardRef, type ElementType, type HTMLAttributes } from 'react'\n\nimport cn from 'classnames'\n\nimport {\n responsiveVars,\n spaceToCss,\n type PolymorphicComponent,\n type PolymorphicProps,\n type Responsive,\n type Space,\n} from '../utils'\nimport styles from './Stack.module.css'\n\nexport type StackDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse'\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline'\nexport type StackJustify =\n | 'start'\n | 'center'\n | 'end'\n | 'between'\n | 'around'\n | 'evenly'\n\nexport const alignToCss = (align: StackAlign) =>\n ({\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n baseline: 'baseline',\n })[align]\n\nconst justifyToCss = (justify: StackJustify) =>\n ({\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n between: 'space-between',\n around: 'space-around',\n evenly: 'space-evenly',\n })[justify]\n\nexport type StackDataTestId = { root?: string }\n\ntype StackOwnProps = {\n /** Flex direction (`column` when omitted). Per-breakpoint, desktop-first (see breakpointWidths). */\n direction?: Responsive<StackDirection>\n /** Gap from the spacing scale in px. Per-breakpoint, desktop-first (see breakpointWidths). */\n gap?: Responsive<Space>\n /** Cross-axis alignment, per-breakpoint, desktop-first (see breakpointWidths). */\n align?: Responsive<StackAlign>\n /** Main-axis distribution, per-breakpoint, desktop-first (see breakpointWidths). */\n justify?: Responsive<StackJustify>\n /** Allows items to wrap onto new lines. Per-breakpoint, desktop-first (see breakpointWidths). */\n wrap?: Responsive<boolean>\n /** Renders `inline-flex` instead of `flex`. */\n inline?: boolean\n /** Fills the remaining space in a parent flex row and lets content shrink. */\n grow?: boolean\n dataTestId?: StackDataTestId\n}\n\ntype StackImplProps = HTMLAttributes<HTMLElement> &\n StackOwnProps & { as?: ElementType }\n\nexport type StackProps<E extends ElementType = never> = [E] extends [never]\n ? StackImplProps\n : PolymorphicProps<E, StackOwnProps>\n\n/** Flex container; `direction`, `gap`, `align`, `justify` and `wrap` take a value or a desktop-first per-breakpoint object like `{ base: 'row', smDown: 'column' }`, where `smDown` applies
|
|
1
|
+
{"version":3,"file":"Stack.cjs","sources":["../../../src/stack/Stack.tsx"],"sourcesContent":["import { forwardRef, type ElementType, type HTMLAttributes } from 'react'\n\nimport cn from 'classnames'\n\nimport {\n responsiveVars,\n spaceToCss,\n type PolymorphicComponent,\n type PolymorphicProps,\n type Responsive,\n type Space,\n} from '../utils'\nimport styles from './Stack.module.css'\n\nexport type StackDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse'\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline'\nexport type StackJustify =\n | 'start'\n | 'center'\n | 'end'\n | 'between'\n | 'around'\n | 'evenly'\n\nexport const alignToCss = (align: StackAlign) =>\n ({\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n stretch: 'stretch',\n baseline: 'baseline',\n })[align]\n\nconst justifyToCss = (justify: StackJustify) =>\n ({\n start: 'flex-start',\n center: 'center',\n end: 'flex-end',\n between: 'space-between',\n around: 'space-around',\n evenly: 'space-evenly',\n })[justify]\n\nexport type StackDataTestId = { root?: string }\n\ntype StackOwnProps = {\n /** Flex direction (`column` when omitted). Per-breakpoint, desktop-first (see breakpointWidths). */\n direction?: Responsive<StackDirection>\n /** Gap from the spacing scale in px. Per-breakpoint, desktop-first (see breakpointWidths). */\n gap?: Responsive<Space>\n /** Cross-axis alignment, per-breakpoint, desktop-first (see breakpointWidths). */\n align?: Responsive<StackAlign>\n /** Main-axis distribution, per-breakpoint, desktop-first (see breakpointWidths). */\n justify?: Responsive<StackJustify>\n /** Allows items to wrap onto new lines. Per-breakpoint, desktop-first (see breakpointWidths). */\n wrap?: Responsive<boolean>\n /** Renders `inline-flex` instead of `flex`. */\n inline?: boolean\n /** Fills the remaining space in a parent flex row and lets content shrink. */\n grow?: boolean\n dataTestId?: StackDataTestId\n}\n\ntype StackImplProps = HTMLAttributes<HTMLElement> &\n StackOwnProps & { as?: ElementType }\n\nexport type StackProps<E extends ElementType = never> = [E] extends [never]\n ? StackImplProps\n : PolymorphicProps<E, StackOwnProps>\n\n/** Flex container; `direction`, `gap`, `align`, `justify` and `wrap` take a value or a desktop-first per-breakpoint object like `{ base: 'row', smDown: 'column' }`, where `smDown` applies at `breakpointWidths.sm` (600px) and below. */\nexport const Stack = forwardRef<HTMLElement, StackImplProps>(\n (\n {\n as: Component = 'div',\n direction,\n gap,\n align,\n justify,\n wrap,\n inline = false,\n grow = false,\n className,\n style,\n dataTestId,\n ...rest\n },\n ref,\n ) => (\n <Component\n ref={ref}\n className={cn(\n styles.root,\n inline && styles.inline,\n grow && styles.grow,\n className,\n )}\n style={{\n ...responsiveVars('direction', direction, String),\n ...responsiveVars('gap', gap, spaceToCss),\n ...responsiveVars('align', align, alignToCss),\n ...responsiveVars('justify', justify, justifyToCss),\n ...responsiveVars('wrap', wrap, (value) => (value ? 'wrap' : 'nowrap')),\n ...style,\n }}\n data-testid={dataTestId?.root}\n {...rest}\n />\n ),\n) as PolymorphicComponent<'div', StackOwnProps>\n\nStack.displayName = 'Stack'\n"],"names":["alignToCss","align","start","center","end","stretch","baseline","justifyToCss","justify","between","around","evenly","Stack","forwardRef","_ref","ref","as","Component","direction","gap","wrap","inline","grow","className","style","dataTestId","rest","_jsx","cn","styles","root","responsiveVars","String","spaceToCss","value","displayName"],"mappings":";;;;;;;;;;AAwBaA,MAAAA,UAAU,GAAIC,KAAiB,IAC1C,CAAC;AACCC,EAAAA,KAAK,EAAE,YAAY;AACnBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,GAAG,EAAE,U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AAED,YAAY,CAAC;AACnD,MAAA,GAAGwB,yBAAc,CAAC,MAAM,EAAEX,IAAI,EAAGc,KAAK,IAAMA,KAAK,GAAG,MAAM,GAAG,QAAS,CAAC;MACvE,GAAGV,KAAAA;KACH;IACF,aAAaC,EAAAA,UAAU,EAAEK,IAAK;IAAA,GAC1BJ,IAAAA;AAAI,GACT,CAAC,CAAA;AAAA,CAEN,EAA+C;AAE/Cd,KAAK,CAACuB,WAAW,GAAG,OAAO;;;;;"}
|
package/dist/cjs/tag/Tag.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.cjs","sources":["../../../src/tag/Tag.tsx"],"sourcesContent":["import {\n forwardRef,\n useId,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport { IconCross } from '../icons'\nimport { ActionElement, type ActionElementProps } from '../utils'\nimport styles from './Tag.module.css'\n\nexport type TagVariant =\n | 'default'\n | 'neutral'\n | 'success'\n | 'warning'\n | 'error'\n | 'info'\n | 'active'\n | 'action'\n\nexport type TagDataTestId = {\n root?: string\n icon?: string\n closeButton?: string\n}\n\nexport type TagIconPosition = 'left' | 'right'\n\nexport type TagProps = Omit<HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n variant?: TagVariant\n /** Shows the variant-coloured active border. */\n active?: boolean\n icon?: ReactNode\n iconPosition?: TagIconPosition\n /** Renders a trailing close button when set. */\n onClose?: () => void\n /** Renders a link (`<a>` via LinkProvider) instead of a span. */\n href?: string\n /** Click handler; a span with it becomes a keyboard-operable `role=\"button\"`, except with `onClose` where it stays passive. */\n onClick?: MouseEventHandler<HTMLElement>\n /** Disables the button or link form; on its own always renders a native disabled button, whatever `as` is. Ignored with `onClose`. */\n disabled?: boolean\n /** `button` renders a native `<button>` only together with `onClick`; the default `span` (`role=\"button\"` with `onClick`) avoids nesting a button inside another button or link. `href` and `disabled` always render the native form. */\n as?: 'span' | 'button'\n dataTestId?: TagDataTestId\n}\n\n/** Compact pill for filters, labels and removable selections; text only by default, with room for a leading icon and a trailing close button. */\nexport const Tag = forwardRef<HTMLElement, TagProps>(\n (\n {\n variant = 'default',\n active = false,\n icon,\n iconPosition = 'left',\n onClose,\n href,\n onClick,\n disabled,\n as = 'span',\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const labelId = useId()\n const iconElement =\n icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null\n\n const isAction =\n !onClose &&\n (href != null || disabled || (as === 'button' && onClick != null))\n const isSpanAction = !onClose && !isAction && onClick != null\n const classes = cn(\n styles.tag,\n styles[variant],\n (isAction || isSpanAction) && styles.interactive,\n active && styles.isActive,\n className,\n )\n\n const content = (\n <>\n {iconPosition === 'left' ? iconElement : null}\n {onClose ? <span id={labelId}>{children}</span> : children}\n {iconPosition === 'right' ? iconElement : null}\n {onClose ? (\n <button\n type='button'\n className={styles.closeButton}\n aria-label='Remove'\n aria-describedby={labelId}\n onClick={(event) => {\n event.stopPropagation()\n onClose()\n }}\n data-testid={dataTestId?.closeButton}\n >\n <IconCross aria-hidden='true' className={styles.crossIcon} />\n </button>\n ) : null}\n </>\n )\n\n if (isAction) {\n return (\n <ActionElement\n ref={ref as Ref<HTMLAnchorElement | HTMLButtonElement>}\n className={classes}\n data-testid={dataTestId?.root}\n {...({ href, onClick, disabled, ...rest } as ActionElementProps)}\n >\n {content}\n </ActionElement>\n )\n }\n\n if (isSpanAction) {\n const { onKeyDown, tabIndex = 0, ...spanRest } = rest\n return (\n <span\n ref={ref as Ref<HTMLSpanElement>}\n role='button'\n tabIndex={tabIndex}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented || event.target !== event.currentTarget)\n return\n if (event.key !== 'Enter' && event.key !== ' ') return\n event.preventDefault()\n event.currentTarget.click()\n }}\n {...spanRest}\n >\n {content}\n </span>\n )\n }\n\n return (\n // removable tags keep a passive onClick; the close button is the control\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <span\n ref={ref as Ref<HTMLSpanElement>}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n {...rest}\n >\n {content}\n </span>\n )\n },\n)\n\nTag.displayName = 'Tag'\n"],"names":["Tag","forwardRef","_ref","ref","variant","active","icon","iconPosition","onClose","href","onClick","disabled","as","className","children","dataTestId","rest","labelId","useId","iconElement","_jsx","styles","isAction","isSpanAction","classes","cn","tag","interactive","isActive","content","_jsxs","_Fragment","id","type","closeButton","event","stopPropagation","IconCross","crossIcon","ActionElement","root","onKeyDown","tabIndex","spanRest","role","defaultPrevented","target","currentTarget","key","preventDefault","click","displayName"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Tag.cjs","sources":["../../../src/tag/Tag.tsx"],"sourcesContent":["import {\n forwardRef,\n useId,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport { IconCross } from '../icons'\nimport { ActionElement, type ActionElementProps } from '../utils'\nimport styles from './Tag.module.css'\n\nexport type TagVariant =\n | 'default'\n | 'neutral'\n | 'success'\n | 'warning'\n | 'error'\n | 'info'\n | 'active'\n | 'action'\n | 'custom'\n\nexport type TagDataTestId = {\n root?: string\n icon?: string\n closeButton?: string\n}\n\nexport type TagIconPosition = 'left' | 'right'\n\nexport type TagProps = Omit<HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n /** `custom` takes colors from the `--lido-app-ui-tag-*` CSS vars. */\n variant?: TagVariant\n /** Shows the variant-coloured active border. */\n active?: boolean\n icon?: ReactNode\n iconPosition?: TagIconPosition\n /** Renders a trailing close button when set. */\n onClose?: () => void\n /** Renders a link (`<a>` via LinkProvider) instead of a span. */\n href?: string\n /** Click handler; a span with it becomes a keyboard-operable `role=\"button\"`, except with `onClose` where it stays passive. */\n onClick?: MouseEventHandler<HTMLElement>\n /** Disables the button or link form; on its own always renders a native disabled button, whatever `as` is. Ignored with `onClose`. */\n disabled?: boolean\n /** `button` renders a native `<button>` only together with `onClick`; the default `span` (`role=\"button\"` with `onClick`) avoids nesting a button inside another button or link. `href` and `disabled` always render the native form. */\n as?: 'span' | 'button'\n dataTestId?: TagDataTestId\n}\n\n/** Compact pill for filters, labels and removable selections; text only by default, with room for a leading icon and a trailing close button. */\nexport const Tag = forwardRef<HTMLElement, TagProps>(\n (\n {\n variant = 'default',\n active = false,\n icon,\n iconPosition = 'left',\n onClose,\n href,\n onClick,\n disabled,\n as = 'span',\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const labelId = useId()\n const iconElement =\n icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null\n\n const isAction =\n !onClose &&\n (href != null || disabled || (as === 'button' && onClick != null))\n const isSpanAction = !onClose && !isAction && onClick != null\n const classes = cn(\n styles.tag,\n styles[variant],\n (isAction || isSpanAction) && styles.interactive,\n active && styles.isActive,\n className,\n )\n\n const content = (\n <>\n {iconPosition === 'left' ? iconElement : null}\n {onClose ? <span id={labelId}>{children}</span> : children}\n {iconPosition === 'right' ? iconElement : null}\n {onClose ? (\n <button\n type='button'\n className={styles.closeButton}\n aria-label='Remove'\n aria-describedby={labelId}\n onClick={(event) => {\n event.stopPropagation()\n onClose()\n }}\n data-testid={dataTestId?.closeButton}\n >\n <IconCross aria-hidden='true' className={styles.crossIcon} />\n </button>\n ) : null}\n </>\n )\n\n if (isAction) {\n return (\n <ActionElement\n ref={ref as Ref<HTMLAnchorElement | HTMLButtonElement>}\n className={classes}\n data-testid={dataTestId?.root}\n {...({ href, onClick, disabled, ...rest } as ActionElementProps)}\n >\n {content}\n </ActionElement>\n )\n }\n\n if (isSpanAction) {\n const { onKeyDown, tabIndex = 0, ...spanRest } = rest\n return (\n <span\n ref={ref as Ref<HTMLSpanElement>}\n role='button'\n tabIndex={tabIndex}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented || event.target !== event.currentTarget)\n return\n if (event.key !== 'Enter' && event.key !== ' ') return\n event.preventDefault()\n event.currentTarget.click()\n }}\n {...spanRest}\n >\n {content}\n </span>\n )\n }\n\n return (\n // removable tags keep a passive onClick; the close button is the control\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <span\n ref={ref as Ref<HTMLSpanElement>}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n {...rest}\n >\n {content}\n </span>\n )\n },\n)\n\nTag.displayName = 'Tag'\n"],"names":["Tag","forwardRef","_ref","ref","variant","active","icon","iconPosition","onClose","href","onClick","disabled","as","className","children","dataTestId","rest","labelId","useId","iconElement","_jsx","styles","isAction","isSpanAction","classes","cn","tag","interactive","isActive","content","_jsxs","_Fragment","id","type","closeButton","event","stopPropagation","IconCross","crossIcon","ActionElement","root","onKeyDown","tabIndex","spanRest","role","defaultPrevented","target","currentTarget","key","preventDefault","click","displayName"],"mappings":";;;;;;;;;;;AAuDA;AACO,MAAMA,GAAG,gBAAGC,gBAAU,CAC3B,CAAAC,IAAA,EAgBEC,GAAG,KACA;EAAA,IAhBH;AACEC,IAAAA,OAAO,GAAG,SAAS;AACnBC,IAAAA,MAAM,GAAG,KAAK;IACdC,IAAI;AACJC,IAAAA,YAAY,GAAG,MAAM;IACrBC,OAAO;IACPC,IAAI;IACJC,OAAO;IACPC,QAAQ;AACRC,IAAAA,EAAE,GAAG,MAAM;IACXC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAd,IAAA,CAAA;AAGD,EAAA,MAAMe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,CAACY,aAAa,EAChE,OAAA;QACF,IAAIZ,KAAK,CAACa,GAAG,KAAK,OAAO,IAAIb,KAAK,CAACa,GAAG,KAAK,GAAG,EAAE,OAAA;QAChDb,KAAK,CAACc,cAAc,EAAE,CAAA;AACtBd,QAAAA,KAAK,CAACY,aAAa,CAACG,KAAK,EAAE,CAAA;OAC3B;AAAA,MAAA,GACEP,QAAQ;AAAA7B,MAAAA,QAAA,EAEXe,OAAAA;AAAO,KACJ,CAAC,CAAA;AAEX,GAAA;AAEA,EAAA;AAAA;AACE;AACA;IACAT,cAAA,CAAA,MAAA,EAAA;AACEjB,MAAAA,GAAG,EAAEA,GAA4B;AACjCU,MAAAA,SAAS,EAAEW,OAAQ;MACnB,aAAaT,EAAAA,UAAU,EAAEyB,IAAK;AAC9B9B,MAAAA,OAAO,EAAEA,OAAQ;AAAA,MAAA,GACbM,IAAI;AAAAF,MAAAA,QAAA,EAEPe,OAAAA;KACG,CAAA;AAAC,IAAA;AAEX,CACF,EAAC;AAED7B,GAAG,CAACmD,WAAW,GAAG,KAAK;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const styles = {"tag":"Tag-module_tag__dpq60","interactive":"Tag-module_interactive__jpb40","closeButton":"Tag-module_closeButton__d5-N3","isActive":"Tag-module_isActive__h4p9Z","icon":"Tag-module_icon__7I-oU","crossIcon":"Tag-module_crossIcon__LDgT7","neutral":"Tag-module_neutral__D18sJ","success":"Tag-module_success__JX1nP","warning":"Tag-module_warning__0pWSo","error":"Tag-module_error__o3vZs","info":"Tag-module_info__TJ9YE","active":"Tag-module_active__C6eCL","action":"Tag-module_action__6xjY6"};
|
|
3
|
+
const styles = {"tag":"Tag-module_tag__dpq60","interactive":"Tag-module_interactive__jpb40","closeButton":"Tag-module_closeButton__d5-N3","isActive":"Tag-module_isActive__h4p9Z","icon":"Tag-module_icon__7I-oU","crossIcon":"Tag-module_crossIcon__LDgT7","neutral":"Tag-module_neutral__D18sJ","success":"Tag-module_success__JX1nP","warning":"Tag-module_warning__0pWSo","error":"Tag-module_error__o3vZs","info":"Tag-module_info__TJ9YE","active":"Tag-module_active__C6eCL","action":"Tag-module_action__6xjY6","custom":"Tag-module_custom__NO3kN"};
|
|
4
4
|
|
|
5
5
|
module.exports = styles;
|
|
6
6
|
//# sourceMappingURL=Tag.module.css.cjs.map
|
|
@@ -8,13 +8,12 @@ const Anchor = require('../link-provider/Anchor.cjs');
|
|
|
8
8
|
const TextLink_module = require('./TextLink.module.css.cjs');
|
|
9
9
|
const jsxRuntime = require('react/jsx-runtime');
|
|
10
10
|
|
|
11
|
-
/** Inline link, blue by default. `
|
|
11
|
+
/** Inline link, blue by default. Absolute `http(s)` URLs open in a new tab; `LinkProvider` sends relative hrefs to `component` and absolute ones to `externalComponent`. */
|
|
12
12
|
const TextLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
13
13
|
let {
|
|
14
14
|
variant = 'primary',
|
|
15
15
|
size = 'body',
|
|
16
16
|
icon,
|
|
17
|
-
external = false,
|
|
18
17
|
disabled = false,
|
|
19
18
|
className,
|
|
20
19
|
children,
|
|
@@ -24,7 +23,6 @@ const TextLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
24
23
|
return /*#__PURE__*/jsxRuntime.jsxs(Anchor.Anchor, {
|
|
25
24
|
ref: ref,
|
|
26
25
|
className: cn(TextLink_module.link, TextLink_module[variant], TextLink_module[size], icon != null && TextLink_module.withIcon, className),
|
|
27
|
-
external: external,
|
|
28
26
|
disabled: disabled,
|
|
29
27
|
"data-testid": dataTestId?.root,
|
|
30
28
|
...rest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLink.cjs","sources":["../../../src/text-link/TextLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './TextLink.module.css'\n\nexport type TextLinkVariant = 'primary' | 'secondary'\n\nexport type TextLinkSize = 'body' | 'inherit'\n\nexport type TextLinkDataTestId = {\n root?: string\n icon?: string\n}\n\nexport type TextLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** `secondary` is muted gray, blue on hover; for footers and meta links. */\n variant?: TextLinkVariant\n /** `inherit` takes font and display from the surrounding text so the link wraps with it; `body` is 14/24. */\n size?: TextLinkSize\n /** Trailing icon (e.g. arrow). */\n icon?: ReactNode\n /**
|
|
1
|
+
{"version":3,"file":"TextLink.cjs","sources":["../../../src/text-link/TextLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './TextLink.module.css'\n\nexport type TextLinkVariant = 'primary' | 'secondary'\n\nexport type TextLinkSize = 'body' | 'inherit'\n\nexport type TextLinkDataTestId = {\n root?: string\n icon?: string\n}\n\nexport type TextLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** `secondary` is muted gray, blue on hover; for footers and meta links. */\n variant?: TextLinkVariant\n /** `inherit` takes font and display from the surrounding text so the link wraps with it; `body` is 14/24. */\n size?: TextLinkSize\n /** Trailing icon (e.g. arrow). */\n icon?: ReactNode\n /** Drops the href and blocks clicks and keyboard focus. */\n disabled?: boolean\n dataTestId?: TextLinkDataTestId\n} & Pick<AnchorProps, 'external' | 'linkProps'>\n\n/** Inline link, blue by default. Absolute `http(s)` URLs open in a new tab; `LinkProvider` sends relative hrefs to `component` and absolute ones to `externalComponent`. */\nexport const TextLink = forwardRef<HTMLAnchorElement, TextLinkProps>(\n (\n {\n variant = 'primary',\n size = 'body',\n icon,\n disabled = false,\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => (\n <Anchor\n ref={ref}\n className={cn(\n styles.link,\n styles[variant],\n styles[size],\n icon != null && styles.withIcon,\n className,\n )}\n disabled={disabled}\n data-testid={dataTestId?.root}\n {...rest}\n >\n {children}\n {icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null}\n </Anchor>\n ),\n)\n\nTextLink.displayName = 'TextLink'\n"],"names":["TextLink","forwardRef","_ref","ref","variant","size","icon","disabled","className","children","dataTestId","rest","_jsxs","Anchor","cn","styles","link","withIcon","root","_jsx","displayName"],"mappings":";;;;;;;;;;AA4BA;AACO,MAAMA,QAAQ,gBAAGC,gBAAU,CAChC,CAAAC,IAAA,EAWEC,GAAG,KAAA;EAAA,IAVH;AACEC,IAAAA,OAAO,GAAG,SAAS;AACnBC,IAAAA,IAAI,GAAG,MAAM;IACbC,IAAI;AACJC,IAAAA,QAAQ,GAAG,KAAK;IAChBC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAT,IAAA,CAAA;EAAA,oBAGDU,eAAA,CAACC,aAAM,EAAA;AACLV,IAAAA,GAAG,EAAEA,GAAI;IACTK,SAAS,EAAEM,EAAE,CACXC,eAAM,CAACC,IAAI,EACXD,eAAM,CAACX,OAAO,CAAC,EACfW,eAAM,CAACV,IAAI,CAAC,EACZC,IAAI,IAAI,IAAI,IAAIS,eAAM,CAACE,QAAQ,EAC/BT,SACF,CAAE;AACFD,IAAAA,QAAQ,EAAEA,QAAS;IACnB,aAAaG,EAAAA,UAAU,EAAEQ,IAAK;AAAA,IAAA,GAC1BP,IAAI;AAAAF,IAAAA,QAAA,GAEPA,QAAQ,EACRH,IAAI,IAAI,IAAI,gBACXa,cAAA,CAAA,MAAA,EAAA;MACEX,SAAS,EAAEO,eAAM,CAACT,IAAK;AACvB,MAAA,aAAA,EAAY,MAAM;MAClB,aAAaI,EAAAA,UAAU,EAAEJ,IAAK;AAAAG,MAAAA,QAAA,EAE7BH,IAAAA;KACG,CAAC,GACL,IAAI,CAAA;AAAA,GACF,CAAC,CAAA;AAAA,CAEb,EAAC;AAEDN,QAAQ,CAACoB,WAAW,GAAG,UAAU;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeSwitcher.cjs","sources":["../../../src/theme-switcher/ThemeSwitcher.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react'\n\nimport { ThemeName, useThemeToggle } from '@lidofinance/lido-shared-ui'\n\nimport { IconButton, type
|
|
1
|
+
{"version":3,"file":"ThemeSwitcher.cjs","sources":["../../../src/theme-switcher/ThemeSwitcher.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react'\n\nimport { ThemeName, useThemeToggle } from '@lidofinance/lido-shared-ui'\n\nimport { IconButton, type IconButtonAsButtonProps } from '../icon-button'\nimport { IconDay, IconNight } from '../icons'\nimport styles from './ThemeSwitcher.module.css'\n\nexport type ThemeSwitcherProps = Omit<\n IconButtonAsButtonProps,\n 'icon' | 'variant' | 'aria-label'\n> & {\n /** Overrides the default English label, e.g. for localization. */\n 'aria-label'?: string\n}\n\n/** Round icon button that toggles the light/dark theme; needs `CookieThemeProvider`, without it the click does nothing. The icon follows the theme in CSS, the label follows the provider state, so pass `initialThemeName` from the request cookie in SSR apps. */\nexport const ThemeSwitcher = forwardRef<HTMLButtonElement, ThemeSwitcherProps>(\n ({ onClick, 'aria-label': ariaLabel, ...rest }, ref) => {\n const { themeName, toggleTheme } = useThemeToggle()\n const isDark = themeName === ThemeName.dark\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n toggleTheme?.()\n onClick?.(event)\n }\n\n return (\n <IconButton\n {...rest}\n ref={ref}\n variant='surface'\n aria-label={\n ariaLabel ??\n (isDark ? 'Switch to light theme' : 'Switch to dark theme')\n }\n icon={\n <>\n <IconNight className={styles.toDark} />\n <IconDay className={styles.toLight} />\n </>\n }\n onClick={handleClick}\n />\n )\n },\n)\n\nThemeSwitcher.displayName = 'ThemeSwitcher'\n"],"names":["ThemeSwitcher","forwardRef","_ref","ref","onClick","ariaLabel","rest","themeName","toggleTheme","useThemeToggle","isDark","ThemeName","dark","handleClick","event","_jsx","IconButton","variant","icon","_jsxs","_Fragment","children","IconNight","className","styles","toDark","IconDay","toLight","displayName"],"mappings":";;;;;;;;;;;;AAgBA;AACO,MAAMA,aAAa,gBAAGC,gBAAU,CACrC,CAAAC,IAAA,EAAgDC,GAAG,KAAK;EAAA,IAAvD;IAAEC,OAAO;AAAE,IAAA,YAAY,EAAEC,SAAS;IAAE,GAAGC,IAAAA;AAAK,GAAC,GAAAJ,IAAA,CAAA;EAC5C,MAAM;IAAEK,SAAS;AAAEC,IAAAA,WAAAA;GAAa,GAAGC,2BAAc,EAAE,CAAA;AACnD,EAAA,MAAMC,MAAM,GAAGH,SAAS,KAAKI,sBAAS,CAACC,IAAI,CAAA;EAE3C,MAAMC,WAAW,GAAIC,KAAoC,IAAK;AAC5DN,IAAAA,WAAW,IAAI,CAAA;IACfJ,OAAO,GAAGU,KAAK,CAAC,CAAA;GACjB,CAAA;EAED,oBACEC,cAAA,CAACC,qBAAU,EAAA;AAAA,IAAA,GACLV,IAAI;AACRH,IAAAA,GAAG,EAAEA,GAAI;AACTc,IAAAA,OAAO,EAAC,SAAS;AACjB,IAAA,YAAA,EACEZ,SAAS,KACRK,MAAM,GAAG,uBAAuB,GAAG,sBAAsB,CAC3D;IACDQ,IAAI,eACFC,eAAA,CAAAC,mBAAA,EAAA;MAAAC,QAAA,EAAA,cACEN,cAAA,CAACO,mBAAS,EAAA;QAACC,SAAS,EAAEC,oBAAM,CAACC,MAAAA;AAAO,OAAE,CAAC,eACvCV,cAAA,CAACW,eAAO,EAAA;QAACH,SAAS,EAAEC,oBAAM,CAACG,OAAAA;AAAQ,OAAE,CAAC,CAAA;AAAA,KACtC,CACH;AACDvB,IAAAA,OAAO,EAAES,WAAAA;AAAY,GACtB,CAAC,CAAA;AAEN,CACF,EAAC;AAEDb,aAAa,CAAC4B,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -6,32 +6,39 @@ const cn = require('classnames');
|
|
|
6
6
|
const Typography_module = require('./Typography.module.css.cjs');
|
|
7
7
|
const jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
|
+
const typographyColors = ['default', 'secondary', 'tertiary', 'neutral', 'active', 'success', 'warning', 'error', 'info', 'inverse', 'disabled'];
|
|
10
|
+
const typographyWeights = ['thin', 'regular', 'medium', 'semibold', 'bold'];
|
|
11
|
+
|
|
12
|
+
/** @deprecated `richInput` → `amount`, `groupName` → `caption` */
|
|
13
|
+
|
|
14
|
+
const resolveVariant = variant => variant === 'richInput' ? 'amount' : variant === 'groupName' ? 'caption' : variant;
|
|
9
15
|
const variantTag = {
|
|
10
16
|
h1: 'h1',
|
|
11
17
|
h2: 'h2',
|
|
12
18
|
h3: 'h3',
|
|
13
|
-
|
|
19
|
+
amount: 'p',
|
|
14
20
|
bodyLarge: 'p',
|
|
15
21
|
body: 'p',
|
|
16
22
|
description: 'p',
|
|
17
|
-
|
|
23
|
+
caption: 'p'
|
|
18
24
|
};
|
|
19
|
-
const isBodyVariant = variant => variant === 'bodyLarge' || variant === 'body' || variant === 'description';
|
|
20
25
|
|
|
21
26
|
/** Typed text in Manrope; use the shortcuts (`H1`, `Body`, ...) in app code and `Typography` when the variant is dynamic. The same styles ship as PostCSS mixins from `@lidofinance/lido-app-ui/styles`. */
|
|
22
27
|
const Typography = _ref => {
|
|
23
28
|
let {
|
|
24
|
-
variant,
|
|
29
|
+
variant = 'body',
|
|
25
30
|
weight,
|
|
31
|
+
color,
|
|
26
32
|
as,
|
|
27
33
|
className,
|
|
28
34
|
children,
|
|
29
35
|
dataTestId,
|
|
30
36
|
...rest
|
|
31
37
|
} = _ref;
|
|
32
|
-
const
|
|
38
|
+
const resolved = resolveVariant(variant);
|
|
39
|
+
const Component = as ?? variantTag[resolved];
|
|
33
40
|
return /*#__PURE__*/jsxRuntime.jsx(Component, {
|
|
34
|
-
className: cn(Typography_module.root, Typography_module[
|
|
41
|
+
className: cn(Typography_module.root, Typography_module[resolved], color && Typography_module[`color-${color}`], weight && Typography_module[`weight-${weight}`], className),
|
|
35
42
|
"data-testid": dataTestId?.root,
|
|
36
43
|
...rest,
|
|
37
44
|
children: children
|
|
@@ -61,17 +68,23 @@ const Description = props => /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
|
61
68
|
...props,
|
|
62
69
|
variant: "description"
|
|
63
70
|
});
|
|
64
|
-
const
|
|
71
|
+
const Caption = props => /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
65
72
|
...props,
|
|
66
|
-
variant: "
|
|
73
|
+
variant: "caption"
|
|
67
74
|
});
|
|
68
75
|
|
|
76
|
+
/** @deprecated use Caption */
|
|
77
|
+
const GroupName = Caption;
|
|
78
|
+
|
|
69
79
|
exports.Body = Body;
|
|
70
80
|
exports.BodyLarge = BodyLarge;
|
|
81
|
+
exports.Caption = Caption;
|
|
71
82
|
exports.Description = Description;
|
|
72
83
|
exports.GroupName = GroupName;
|
|
73
84
|
exports.H1 = H1;
|
|
74
85
|
exports.H2 = H2;
|
|
75
86
|
exports.H3 = H3;
|
|
76
87
|
exports.Typography = Typography;
|
|
88
|
+
exports.typographyColors = typographyColors;
|
|
89
|
+
exports.typographyWeights = typographyWeights;
|
|
77
90
|
//# sourceMappingURL=Typography.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.cjs","sources":["../../../src/typography/Typography.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes } from 'react'\n\nimport cn from 'classnames'\n\nimport styles from './Typography.module.css'\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | '
|
|
1
|
+
{"version":3,"file":"Typography.cjs","sources":["../../../src/typography/Typography.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes } from 'react'\n\nimport cn from 'classnames'\n\nimport styles from './Typography.module.css'\n\nexport const typographyColors = [\n 'default',\n 'secondary',\n 'tertiary',\n 'neutral',\n 'active',\n 'success',\n 'warning',\n 'error',\n 'info',\n 'inverse',\n 'disabled',\n] as const\n\nexport type TypographyColor = (typeof typographyColors)[number]\n\nexport const typographyWeights = [\n 'thin',\n 'regular',\n 'medium',\n 'semibold',\n 'bold',\n] as const\n\nexport type TypographyWeight = (typeof typographyWeights)[number]\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'amount'\n | 'bodyLarge'\n | 'body'\n | 'description'\n | 'caption'\n\n/** @deprecated `richInput` → `amount`, `groupName` → `caption` */\ntype DeprecatedTypographyVariant = 'richInput' | 'groupName'\n\nexport type TypographyDataTestId = {\n root?: string\n}\n\nexport type TypographyProps = Omit<HTMLAttributes<HTMLElement>, 'color'> & {\n /** Type style; also decides the default tag. */\n variant?: TypographyVariant | DeprecatedTypographyVariant\n /** Overrides the variant's font weight. */\n weight?: TypographyWeight\n /** Text color token; omit to inherit. */\n color?: TypographyColor\n /** Overrides the rendered tag without changing the style. */\n as?: ElementType\n dataTestId?: TypographyDataTestId\n}\n\nconst resolveVariant = (\n variant: TypographyVariant | DeprecatedTypographyVariant,\n): TypographyVariant =>\n variant === 'richInput'\n ? 'amount'\n : variant === 'groupName'\n ? 'caption'\n : variant\n\nconst variantTag: Record<TypographyVariant, ElementType> = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n amount: 'p',\n bodyLarge: 'p',\n body: 'p',\n description: 'p',\n caption: 'p',\n}\n\n/** Typed text in Manrope; use the shortcuts (`H1`, `Body`, ...) in app code and `Typography` when the variant is dynamic. The same styles ship as PostCSS mixins from `@lidofinance/lido-app-ui/styles`. */\nexport const Typography = ({\n variant = 'body',\n weight,\n color,\n as,\n className,\n children,\n dataTestId,\n ...rest\n}: TypographyProps) => {\n const resolved = resolveVariant(variant)\n const Component = as ?? variantTag[resolved]\n\n return (\n <Component\n className={cn(\n styles.root,\n styles[resolved],\n color && styles[`color-${color}`],\n weight && styles[`weight-${weight}`],\n className,\n )}\n data-testid={dataTestId?.root}\n {...rest}\n >\n {children}\n </Component>\n )\n}\n\ntype ShorthandProps = Omit<TypographyProps, 'variant'>\n\nexport const H1 = (props: ShorthandProps) => (\n <Typography {...props} variant='h1' />\n)\n\nexport const H2 = (props: ShorthandProps) => (\n <Typography {...props} variant='h2' />\n)\n\nexport const H3 = (props: ShorthandProps) => (\n <Typography {...props} variant='h3' />\n)\n\nexport const BodyLarge = (props: ShorthandProps) => (\n <Typography {...props} variant='bodyLarge' />\n)\n\nexport const Body = (props: ShorthandProps) => (\n <Typography {...props} variant='body' />\n)\n\nexport const Description = (props: ShorthandProps) => (\n <Typography {...props} variant='description' />\n)\n\nexport const Caption = (props: ShorthandProps) => (\n <Typography {...props} variant='caption' />\n)\n\n/** @deprecated use Caption */\nexport const GroupName = Caption\n"],"names":["typographyColors","typographyWeights","resolveVariant","variant","variantTag","h1","h2","h3","amount","bodyLarge","body","description","caption","Typography","_ref","weight","color","as","className","children","dataTestId","rest","resolved","Component","_jsx","cn","styles","root","H1","props","H2","H3","BodyLarge","Body","Description","Caption","GroupName"],"mappings":";;;;;;;;AAMO,MAAMA,gBAAgB,GAAG,CAC9B,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACF;AAIGC,MAAAA,iBAAiB,GAAG,CAC/B,MAAM,EACN,SAAS,EACT,QAAQ,EACR,UAAU,EACV,MAAM,EACE;;AAcV;;AAmBA,MAAMC,cAAc,GAClBC,OAAwD,IAExDA,OAAO,KAAK,WAAW,GACnB,QAAQ,GACRA,OAAO,KAAK,WAAW,GACrB,SAAS,GACTA,OAAO,CAAA;AAEf,MAAMC,UAAkD,GAAG;AACzDC,EAAAA,EAAE,EAAE,IAAI;AACRC,EAAAA,EAAE,EAAE,IAAI;AACRC,EAAAA,EAAE,EAAE,IAAI;AACRC,EAAAA,MAAM,EAAE,GAAG;AACXC,EAAAA,SAAS,EAAE,GAAG;AACdC,EAAAA,IAAI,EAAE,GAAG;AACT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AK;AAAE1B,EAAAA,OAAO,EAAC,IAAA;AAAI,CAAE,EACtC;MAEY6B,SAAS,GAAIH,KAAqB,iBAC7CL,cAAA,CAACX,UAAU,EAAA;AAAA,EAAA,GAAKgB,KAAK;AAAE1B,EAAAA,OAAO,EAAC,WAAA;AAAW,CAAE,EAC7C;MAEY8B,IAAI,GAAIJ,KAAqB,iBACxCL,cAAA,CAACX,UAAU,EAAA;AAAA,EAAA,GAAKgB,KAAK;AAAE1B,EAAAA,OAAO,EAAC,MAAA;AAAM,CAAE,EACxC;MAEY+B,WAAW,GAAIL,KAAqB,iBAC/CL,cAAA,CAACX,UAAU,EAAA;AAAA,EAAA,GAAKgB,KAAK;AAAE1B,EAAAA,OAAO,EAAC,aAAA;AAAa,CAAE,EAC/C;MAEYgC,OAAO,GAAIN,KAAqB,iBAC3CL,cAAA,CAACX,UAAU,EAAA;AAAA,EAAA,GAAKgB,KAAK;AAAE1B,EAAAA,OAAO,EAAC,SAAA;AAAS,CAAE,EAC3C;;AAED;AACO,MAAMiC,SAAS,GAAGD;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const styles = {"root":"Typography-module_root__2cRgG","h1":"Typography-module_h1__Owx3Q","h2":"Typography-module_h2__PGKur","h3":"Typography-module_h3__SyRpZ","
|
|
3
|
+
const styles = {"root":"Typography-module_root__2cRgG","h1":"Typography-module_h1__Owx3Q","h2":"Typography-module_h2__PGKur","h3":"Typography-module_h3__SyRpZ","amount":"Typography-module_amount__drtq0","bodyLarge":"Typography-module_bodyLarge__ziLsk","body":"Typography-module_body__fowlB","description":"Typography-module_description__5mtlx","caption":"Typography-module_caption__ftWKE","weight-thin":"Typography-module_weight-thin__55oL6","weight-regular":"Typography-module_weight-regular__m5NNo","weight-medium":"Typography-module_weight-medium__CQ2Eb","weight-semibold":"Typography-module_weight-semibold__n7eLX","weight-bold":"Typography-module_weight-bold__CeKLl","color-default":"Typography-module_color-default__7FQuh","color-secondary":"Typography-module_color-secondary__HtGK2","color-tertiary":"Typography-module_color-tertiary__c-6R5","color-neutral":"Typography-module_color-neutral__VDBOX","color-active":"Typography-module_color-active__PcBdi","color-success":"Typography-module_color-success__j7XIf","color-warning":"Typography-module_color-warning__q1VU-","color-error":"Typography-module_color-error__ABRrW","color-info":"Typography-module_color-info__BzlBj","color-inverse":"Typography-module_color-inverse__9urcs","color-disabled":"Typography-module_color-disabled__1XM9m"};
|
|
4
4
|
|
|
5
5
|
module.exports = styles;
|
|
6
6
|
//# sourceMappingURL=Typography.module.css.cjs.map
|
|
@@ -6,7 +6,7 @@ const react = require('react');
|
|
|
6
6
|
const Anchor = require('../link-provider/Anchor.cjs');
|
|
7
7
|
const jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
|
-
/** Internal, not exported from the package. Renders `Anchor` when `href` is set (see `AnchorProps` for `disabled`
|
|
9
|
+
/** Internal, not exported from the package. Renders `Anchor` when `href` is set (see `AnchorProps` for `disabled`), otherwise `<button type='button'>`. */
|
|
10
10
|
const ActionElement = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
11
11
|
if (props.href !== undefined) {
|
|
12
12
|
return /*#__PURE__*/jsxRuntime.jsx(Anchor.Anchor, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionElement.cjs","sources":["../../../src/utils/ActionElement.tsx"],"sourcesContent":["import { forwardRef, type ButtonHTMLAttributes, type ForwardedRef } from 'react'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\n\nexport type ActionElementProps =\n | (AnchorProps & { href: string })\n | (ButtonHTMLAttributes<HTMLButtonElement> & { href?: undefined })\n\n/** Internal, not exported from the package. Renders `Anchor` when `href` is set (see `AnchorProps` for `disabled`
|
|
1
|
+
{"version":3,"file":"ActionElement.cjs","sources":["../../../src/utils/ActionElement.tsx"],"sourcesContent":["import { forwardRef, type ButtonHTMLAttributes, type ForwardedRef } from 'react'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\n\nexport type ActionElementProps =\n | (AnchorProps & { href: string })\n | (ButtonHTMLAttributes<HTMLButtonElement> & { href?: undefined })\n\nexport type ActionAsButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n href?: never\n linkProps?: never\n loading?: boolean\n}\n\nexport type ActionAsLinkProps = Omit<AnchorProps, 'href' | 'external'> & {\n href: string\n loading?: never\n type?: never\n}\n\n/** Internal, not exported from the package. Renders `Anchor` when `href` is set (see `AnchorProps` for `disabled`), otherwise `<button type='button'>`. */\nexport const ActionElement = forwardRef<\n HTMLAnchorElement | HTMLButtonElement,\n ActionElementProps\n>((props, ref) => {\n if (props.href !== undefined) {\n return <Anchor ref={ref as ForwardedRef<HTMLAnchorElement>} {...props} />\n }\n\n const { type = 'button', ...rest } = props\n return (\n <button\n ref={ref as ForwardedRef<HTMLButtonElement>}\n type={type}\n {...rest}\n />\n )\n})\n\nActionElement.displayName = 'ActionElement'\n"],"names":["ActionElement","forwardRef","props","ref","href","undefined","_jsx","Anchor","type","rest","displayName"],"mappings":";;;;;;;;AAoBA;AACO,MAAMA,aAAa,gBAAGC,gBAAU,CAGrC,CAACC,KAAK,EAAEC,GAAG,KAAK;AAChB,EAAA,IAAID,KAAK,CAACE,IAAI,KAAKC,SAAS,EAAE;IAC5B,oBAAOC,cAAA,CAACC,aAAM,EAAA;AAACJ,MAAAA,GAAG,EAAEA,GAAuC;MAAA,GAAKD,KAAAA;AAAK,KAAG,CAAC,CAAA;AAC3E,GAAA;EAEA,MAAM;AAAEM,IAAAA,IAAI,GAAG,QAAQ;IAAE,GAAGC,IAAAA;AAAK,GAAC,GAAGP,KAAK,CAAA;AAC1C,EAAA,oBACEI,cAAA,CAAA,QAAA,EAAA;AACEH,IAAAA,GAAG,EAAEA,GAAuC;AAC5CK,IAAAA,IAAI,EAAEA,IAAK;IAAA,GACPC,IAAAA;AAAI,GACT,CAAC,CAAA;AAEN,CAAC,EAAC;AAEFT,aAAa,CAACU,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
/** Desktop-first: a key applies
|
|
5
|
+
/** Desktop-first: a key applies at this width in px and below; `base` covers everything above `xl`. */
|
|
6
6
|
const breakpointWidths = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
xl: 1280,
|
|
8
|
+
lg: 1024,
|
|
9
9
|
md: 900,
|
|
10
|
-
sm:
|
|
11
|
-
xs:
|
|
12
|
-
xxs: 400
|
|
10
|
+
sm: 600,
|
|
11
|
+
xs: 400
|
|
13
12
|
};
|
|
14
13
|
const breakpoints = Object.keys(breakpointWidths);
|
|
15
14
|
|
|
16
|
-
/**
|
|
17
|
-
const
|
|
15
|
+
/** Media query matching widths at and below the breakpoint. */
|
|
16
|
+
const downQuery = key => `(width <= ${breakpointWidths[key]}px)`;
|
|
18
17
|
|
|
19
|
-
/**
|
|
20
|
-
const
|
|
18
|
+
/** Media query matching widths above the breakpoint. */
|
|
19
|
+
const upQuery = key => `(width > ${breakpointWidths[key]}px)`;
|
|
21
20
|
|
|
22
21
|
exports.breakpointWidths = breakpointWidths;
|
|
23
22
|
exports.breakpoints = breakpoints;
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
23
|
+
exports.downQuery = downQuery;
|
|
24
|
+
exports.upQuery = upQuery;
|
|
26
25
|
//# sourceMappingURL=breakpoints.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breakpoints.cjs","sources":["../../../src/utils/breakpoints.ts"],"sourcesContent":["/** Desktop-first: a key applies
|
|
1
|
+
{"version":3,"file":"breakpoints.cjs","sources":["../../../src/utils/breakpoints.ts"],"sourcesContent":["/** Desktop-first: a key applies at this width in px and below; `base` covers everything above `xl`. */\nexport const breakpointWidths = {\n xl: 1280,\n lg: 1024,\n md: 900,\n sm: 600,\n xs: 400,\n} as const\n\nexport type Breakpoint = keyof typeof breakpointWidths\n\nexport const breakpoints = Object.keys(\n breakpointWidths,\n) as readonly Breakpoint[]\n\n/** Media query matching widths at and below the breakpoint. */\nexport const downQuery = (key: Breakpoint) =>\n `(width <= ${breakpointWidths[key]}px)`\n\n/** Media query matching widths above the breakpoint. */\nexport const upQuery = (key: Breakpoint) =>\n `(width > ${breakpointWidths[key]}px)`\n"],"names":["breakpointWidths","xl","lg","md","sm","xs","breakpoints","Object","keys","downQuery","key","upQuery"],"mappings":";;;;AAAA;AACO,MAAMA,gBAAgB,GAAG;AAC9BC,EAAAA,EAAE,EAAE,IAAI;AACRC,EAAAA,EAAE,EAAE,IAAI;AACRC,EAAAA,EAAE,EAAE,GAAG;AACPC,EAAAA,EAAE,EAAE,GAAG;AACPC,EAAAA,EAAE,EAAE,GAAA;AACN,EAAU;AAIH,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CACpCR,gBACF,EAA0B;;AAE1B;AACO,MAAMS,SAAS,GAAIC,GAAe,IACvC,aAAaV,gBAAgB,CAACU,GAAG,CAAC,CAAK,GAAA,EAAA;;AAEzC;AACO,MAAMC,OAAO,GAAID,GAAe,IACrC,YAAYV,gBAAgB,CAACU,GAAG,CAAC,CAAK,GAAA;;;;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const joinAriaLabel = (ariaLabel, counterLabel) => ariaLabel && counterLabel ? `${ariaLabel}, ${counterLabel}` : ariaLabel;
|
|
6
|
+
|
|
7
|
+
exports.joinAriaLabel = joinAriaLabel;
|
|
8
|
+
//# sourceMappingURL=joinAriaLabel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinAriaLabel.cjs","sources":["../../../src/utils/joinAriaLabel.ts"],"sourcesContent":["export const joinAriaLabel = (\n ariaLabel: string | undefined,\n counterLabel: string | undefined,\n) => (ariaLabel && counterLabel ? `${ariaLabel}, ${counterLabel}` : ariaLabel)\n"],"names":["joinAriaLabel","ariaLabel","counterLabel"],"mappings":";;;;MAAaA,aAAa,GAAGA,CAC3BC,SAA6B,EAC7BC,YAAgC,KAC5BD,SAAS,IAAIC,YAAY,GAAG,CAAGD,EAAAA,SAAS,KAAKC,YAAY,CAAA,CAAE,GAAGD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsive.cjs","sources":["../../../src/utils/responsive.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\n\nimport { breakpoints, type Breakpoint } from './breakpoints'\n\ntype DownKey = `${Breakpoint}Down`\n\ntype ResponsiveObject<T> = {\n /** Applies at every width unless a breakpoint key overrides it. */\n base?: T\n /** Applies at
|
|
1
|
+
{"version":3,"file":"responsive.cjs","sources":["../../../src/utils/responsive.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\n\nimport { breakpoints, type Breakpoint } from './breakpoints'\n\ntype DownKey = `${Breakpoint}Down`\n\ntype ResponsiveObject<T> = {\n /** Applies at every width unless a breakpoint key overrides it. */\n base?: T\n /** Applies at 1280px and below. */\n xlDown?: T\n /** Applies at 1024px and below. */\n lgDown?: T\n /** Applies at 900px and below. */\n mdDown?: T\n /** Applies at 600px and below. */\n smDown?: T\n /** Applies at 400px and below. */\n xsDown?: T\n /** Alias of `xlDown`: applies at 1280px and below. */\n xl?: T\n /** Alias of `lgDown`: applies at 1024px and below. */\n lg?: T\n /** Alias of `mdDown`: applies at 900px and below. */\n md?: T\n /** Alias of `smDown`: applies at 600px and below. */\n sm?: T\n /** Alias of `xsDown`: applies at 400px and below. */\n xs?: T\n}\n\n/** Desktop-first: `base` applies everywhere, `<bp>Down` (alias `<bp>`) applies at that breakpoint's width and below, see `breakpointWidths`. */\nexport type Responsive<T> = T | ResponsiveObject<T>\n\n/** Spacing scale in px. */\nexport const spaces = [0, 2, 4, 6, 8, 12, 16, 20, 24, 32, 40, 52] as const\nexport type Space = (typeof spaces)[number]\n\nexport const capitalize = (value: string) =>\n value.charAt(0).toUpperCase() + value.slice(1)\n\nexport const spaceToCss = (space: Space) =>\n space === 0 ? '0' : `var(--lido-app-ui-space-${space}, ${space}px)`\n\nconst toKebab = (value: string) =>\n value.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)\n\ntype NormalizedResponsive<T> = { base?: T } & Partial<Record<Breakpoint, T>>\n\nconst toObject = <T>(value: Responsive<T>): NormalizedResponsive<T> => {\n if (typeof value !== 'object' || value === null) return { base: value }\n\n const object = value as ResponsiveObject<T>\n const result: NormalizedResponsive<T> = {}\n if (object.base !== undefined) result.base = object.base\n for (const bp of breakpoints) {\n const item = object[`${bp}Down` as DownKey] ?? object[bp]\n if (item !== undefined) result[bp] = item\n }\n return result\n}\n\n/** Merges per key; `b` wins over `a`. */\nexport const mergeResponsive = <T>(\n a?: Responsive<T>,\n b?: Responsive<T>,\n): Responsive<T> | undefined => {\n if (a === undefined && b === undefined) return undefined\n return {\n ...(a === undefined ? {} : toObject(a)),\n ...(b === undefined ? {} : toObject(b)),\n }\n}\n\n/** Turns a responsive prop into inline `--local-<prop>[-<bp>]` vars, for roots that declare the fallback chain with the `responsive-prop` mixin. */\nexport const responsiveVars = <T>(\n prop: string,\n value: Responsive<T> | undefined,\n toCss: (value: T) => string,\n): CSSProperties => {\n if (value === undefined) return {}\n\n const values = toObject(value)\n const varName = `--local-${toKebab(prop)}`\n const style: Record<string, string> = {}\n\n if (values.base !== undefined) style[varName] = toCss(values.base)\n\n for (const bp of breakpoints) {\n const item = values[bp]\n if (item !== undefined) style[`${varName}-${bp}`] = toCss(item)\n }\n\n return style as CSSProperties\n}\n"],"names":["spaces","capitalize","value","charAt","toUpperCase","slice","spaceToCss","space","toKebab","replace","char","toLowerCase","toObject","base","object","result","undefined","bp","breakpoints","item","mergeResponsive","a","b","responsiveVars","prop","toCss","values","varName","style"],"mappings":";;;;;;AA+B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@@ const syncTitle = e => {
|
|
|
20
20
|
if (!el) return;
|
|
21
21
|
if (el.scrollWidth > el.clientWidth) el.setAttribute('title', el.textContent ?? '');else el.removeAttribute('title');
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
/** Trail of ancestors ending in the current page (`aria-current="page"`); scrolls horizontally with an edge fade when it overflows. */
|
|
25
|
-
const Breadcrumbs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
23
|
+
const BreadcrumbsTrail = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
26
24
|
let {
|
|
27
25
|
items,
|
|
28
26
|
className,
|
|
@@ -111,6 +109,15 @@ const Breadcrumbs = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
111
109
|
})
|
|
112
110
|
});
|
|
113
111
|
});
|
|
112
|
+
BreadcrumbsTrail.displayName = 'BreadcrumbsTrail';
|
|
113
|
+
|
|
114
|
+
/** Trail of ancestors ending in the current page (`aria-current="page"`); scrolls horizontally with an edge fade when it overflows. */
|
|
115
|
+
const Breadcrumbs = /*#__PURE__*/forwardRef((props, ref) =>
|
|
116
|
+
// Separate component so its mount effects attach once the list exists.
|
|
117
|
+
props.items.length === 0 ? null : /*#__PURE__*/jsx(BreadcrumbsTrail, {
|
|
118
|
+
ref: ref,
|
|
119
|
+
...props
|
|
120
|
+
}));
|
|
114
121
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
|
115
122
|
|
|
116
123
|
export { Breadcrumbs };
|