@fanvue/ui 3.47.0 → 3.49.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/dist/charts.d.ts +39 -0
- package/dist/charts.mjs +2 -0
- package/dist/charts.mjs.map +1 -1
- package/dist/cjs/charts.cjs +2 -0
- package/dist/cjs/charts.cjs.map +1 -1
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs +7 -3
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartGrid.cjs +31 -0
- package/dist/cjs/components/Chart/ChartGrid.cjs.map +1 -0
- package/dist/cjs/components/ChatInput/ChatInput.cjs +21 -11
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +31 -34
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +5 -4
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +10 -10
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +12 -7
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs +9 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +2 -1
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/BaseIcon.cjs +5 -1
- package/dist/cjs/components/Icons/BaseIcon.cjs.map +1 -1
- package/dist/cjs/components/Icons/IconDefaults.cjs +26 -0
- package/dist/cjs/components/Icons/IconDefaults.cjs.map +1 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs +26 -0
- package/dist/cjs/components/Icons/MenuRowIcon.cjs.map +1 -0
- package/dist/cjs/components/Link/Link.cjs +7 -3
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs +56 -0
- package/dist/cjs/components/MediaPlayChip/MediaPlayChip.cjs.map +1 -0
- package/dist/cjs/components/Select/Select.cjs +13 -10
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +4 -2
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs +30 -0
- package/dist/cjs/components/Tabs/TabsListSkeleton.cjs.map +1 -0
- package/dist/cjs/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/UndoAlertPrompt/UndoAlertPrompt.cjs +66 -0
- package/dist/cjs/components/UndoAlertPrompt/UndoAlertPrompt.cjs.map +1 -0
- package/dist/cjs/components/UserItem/UserItem.cjs +6 -1
- package/dist/cjs/components/UserItem/UserItem.cjs.map +1 -1
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs +7 -3
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs.map +1 -1
- package/dist/components/Chart/ChartGrid.mjs +31 -0
- package/dist/components/Chart/ChartGrid.mjs.map +1 -0
- package/dist/components/ChatInput/ChatInput.mjs +21 -11
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +32 -35
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +5 -4
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +10 -10
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +12 -7
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.mjs +9 -1
- package/dist/components/EmptyState/EmptyState.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +2 -1
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/BaseIcon.mjs +5 -1
- package/dist/components/Icons/BaseIcon.mjs.map +1 -1
- package/dist/components/Icons/IconDefaults.mjs +9 -0
- package/dist/components/Icons/IconDefaults.mjs.map +1 -0
- package/dist/components/Icons/MenuRowIcon.mjs +26 -0
- package/dist/components/Icons/MenuRowIcon.mjs.map +1 -0
- package/dist/components/Link/Link.mjs +7 -3
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs +39 -0
- package/dist/components/MediaPlayChip/MediaPlayChip.mjs.map +1 -0
- package/dist/components/Select/Select.mjs +13 -10
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +4 -2
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tabs/TabsListSkeleton.mjs +13 -0
- package/dist/components/Tabs/TabsListSkeleton.mjs.map +1 -0
- package/dist/components/Tooltip/Tooltip.mjs +1 -1
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/components/UndoAlertPrompt/UndoAlertPrompt.mjs +48 -0
- package/dist/components/UndoAlertPrompt/UndoAlertPrompt.mjs.map +1 -0
- package/dist/components/UserItem/UserItem.mjs +6 -1
- package/dist/components/UserItem/UserItem.mjs.map +1 -1
- package/dist/index.d.ts +159 -9
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +23 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsList.cjs","sources":["../../../../src/components/Tabs/TabsList.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Breakpoint values for responsive props. */\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/** Visual style of a {@link TabsList}. */\nexport type TabsListAppearance = \"underline\" | \"pill\";\n\n/** Height in pixels of each tab in a pill {@link TabsList}. */\nexport type TabsListPillSize = \"32\" | \"36\";\n\nexport const TabsAppearanceContext = React.createContext<{\n appearance: TabsListAppearance;\n size: TabsListPillSize;\n}>({ appearance: \"underline\", size: \"32\" });\n\ntype TabBox = { left: number; top: number; width: number; height: number };\n\nconst PILL_EASE = \"cubic-bezier(0.22, 1, 0.36, 1)\";\nconst PILL_STEP_MS = 360;\nconst PILL_STEP_MS_TOUCH = 200;\nconst PILL_EXTRA_STEP_MS = 220;\nconst PILL_MAX_MS = 1000;\n/** Share of a slide by which the eased pill has covered 80% of the way, so the label recolours under it. */\nconst PILL_ARRIVAL_SHARE = 0.27;\n\nfunction pillStepMs(canHover: boolean) {\n return canHover ? PILL_STEP_MS : PILL_STEP_MS_TOUCH;\n}\n\nfunction pillSlideMs(distance: number, canHover: boolean) {\n if (!canHover) return PILL_STEP_MS_TOUCH;\n return Math.min(PILL_STEP_MS + Math.max(distance - 1, 0) * PILL_EXTRA_STEP_MS, PILL_MAX_MS);\n}\n\nconst prefersReducedMotion = () =>\n window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false;\n\nfunction pillTarget(list: HTMLElement, hovered: HTMLElement | null, activeTab: HTMLElement) {\n return (\n list.querySelector<HTMLElement>('[role=\"tab\"][aria-expanded=\"true\"]') ??\n (hovered?.isConnected ? hovered : activeTab)\n );\n}\n\nfunction measureTabs(list: HTMLElement, observer: ResizeObserver | null) {\n const boxes = new Map<Element, TabBox>();\n const order = new Map<Element, number>();\n for (const tab of list.querySelectorAll<HTMLElement>('[role=\"tab\"]')) {\n observer?.observe(tab);\n order.set(tab, order.size);\n boxes.set(tab, {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n });\n }\n return { boxes, order };\n}\n\nfunction slideFromPrevious(\n list: HTMLElement,\n previous: Map<Element, TabBox>,\n next: Map<Element, TabBox>,\n durationMs: number,\n) {\n const moved: HTMLElement[] = [];\n for (const [tab, box] of next) {\n const before = previous.get(tab);\n if (!before || before.left === box.left || !(tab instanceof HTMLElement)) continue;\n tab.style.transition = \"none\";\n tab.style.transform = `translateX(${before.left - box.left}px)`;\n moved.push(tab);\n }\n if (moved.length === 0) return;\n list.getBoundingClientRect();\n for (const tab of moved) {\n tab.style.transition = `transform ${durationMs}ms var(--pill-ease)`;\n tab.style.transform = \"\";\n const settle = (event: TransitionEvent) => {\n if (event.propertyName !== \"transform\") return;\n tab.style.transition = \"\";\n tab.removeEventListener(\"transitionend\", settle);\n };\n tab.addEventListener(\"transitionend\", settle);\n }\n}\n\nconst alignLeftClasses: Record<Breakpoint | \"always\", string> = {\n always: \"[&>[role=tab]]:flex-initial\",\n sm: \"[&>[role=tab]]:sm:flex-initial\",\n md: \"[&>[role=tab]]:md:flex-initial\",\n lg: \"[&>[role=tab]]:lg:flex-initial\",\n xl: \"[&>[role=tab]]:xl:flex-initial\",\n};\n\nfunction getLayoutClass(\n variant: \"fill\" | \"hug\" | undefined,\n fullWidth: boolean,\n alignLeft?: boolean | Breakpoint,\n): string {\n if (variant === \"hug\") return \"inline-flex\";\n if (variant === \"fill\") return \"flex w-full [&>[role=tab]]:flex-1\";\n\n if (!fullWidth) return \"inline-flex\";\n\n const base = \"flex w-full [&>[role=tab]]:flex-1\";\n if (alignLeft === true) return `${base} ${alignLeftClasses.always}`;\n if (typeof alignLeft === \"string\") return `${base} ${alignLeftClasses[alignLeft]}`;\n return base;\n}\n\n/** Props for the {@link TabsList} component. */\nexport type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & {\n /** When `true` (the default), the tab list spans the full width of its container and each tab grows equally. Set to `false` for inline sizing. */\n fullWidth?: boolean;\n /**\n * Controls tab alignment within a full-width container.\n * - `false` (default): tabs spread evenly\n * - `true`: tabs left-aligned, sized to content\n * - `\"md\"` (breakpoint): spread on mobile, left-aligned at breakpoint and up\n */\n alignLeft?: boolean | Breakpoint;\n /** Explicit layout variant. `\"hug\"` sizes the list to its content; `\"fill\"` stretches it full-width with equal-width tabs. Takes precedence over `fullWidth`/`alignLeft`. */\n variant?: \"fill\" | \"hug\";\n /**\n * Drops the leading padding on the first tab so its label sits flush with the\n * list's left edge, lining it up with page content above or below the bar\n * (a heading, for instance) rather than being indented by the tab's own\n * padding. Spacing between tabs is unaffected. Pair with `alignLeft` or\n * `variant=\"hug\"`. @default false\n */\n flushLeft?: boolean;\n /**\n * Scrolls the row horizontally when the tabs don't fit, instead of letting\n * them compress. By default a tab may shrink until its label ellipsises,\n * which on a narrow viewport can truncate every label at once; here each tab\n * keeps its natural width and the overflow scrolls. The scrollbar itself is\n * hidden — the clipped tab at the edge is the affordance.\n *\n * Because the tabs are content-sized, they no longer spread to fill the row:\n * a set that does fit sits left-aligned, as with `alignLeft`.\n *\n * Horizontal orientation only: a vertical list already grows downwards.\n * @default false\n */\n scrollable?: boolean;\n /**\n * `\"underline\"` marks the active tab with a line under the row. `\"pill\"` sits\n * the tabs in a rounded track, sized to its tabs, and slides a filled pill\n * behind the active one. A pill list is horizontal and ignores `fullWidth`,\n * `alignLeft`, `variant` and `flushLeft`; it scrolls when it doesn't fit.\n * @default \"underline\"\n */\n appearance?: TabsListAppearance;\n /** Height of each tab in a pill list. Ignored by the underline appearance. @default \"32\" */\n size?: TabsListPillSize;\n /**\n * Pill only: the pill follows the mouse across the tabs and settles back on the\n * selected one when the pointer leaves. Mouse only, and off when the user prefers\n * reduced motion. @default false\n */\n followHover?: boolean;\n};\n\n/** Container for {@link TabsTrigger} elements. Renders a sliding active-tab indicator that animates between tabs. */\nexport const TabsList = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.List>,\n TabsListProps\n>(\n (\n {\n className,\n children,\n fullWidth = true,\n alignLeft,\n variant,\n flushLeft = false,\n scrollable = false,\n appearance = \"underline\",\n size = \"32\",\n followHover = false,\n onPointerOver,\n onPointerLeave,\n style,\n ...props\n },\n ref,\n ) => {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const indicatorRef = React.useRef<HTMLSpanElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as HTMLDivElement);\n\n const tabBoxes = React.useRef(new Map<Element, TabBox>());\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\n const listWidth = React.useRef<number | null>(null);\n const hoveredTab = React.useRef<HTMLElement | null>(null);\n const pillTab = React.useRef<HTMLElement | null>(null);\n const tabOrder = React.useRef(new Map<Element, number>());\n const canHover = React.useRef(false);\n\n const placePill = React.useCallback((tab: HTMLElement) => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n const box = tabBoxes.current.get(tab);\n if (!box) return;\n const from = pillTab.current;\n pillTab.current = tab;\n const distance =\n from && from !== tab\n ? Math.abs((tabOrder.current.get(tab) ?? 0) - (tabOrder.current.get(from) ?? 0))\n : 0;\n const slideMs = pillSlideMs(distance, canHover.current);\n list.style.setProperty(\"--pill-slide\", `${slideMs}ms`);\n list.style.setProperty(\"--pill-arrive\", `${Math.round(slideMs * PILL_ARRIVAL_SHARE)}ms`);\n indicator.style.width = `${box.width}px`;\n indicator.style.height = `${box.height}px`;\n indicator.style.transform = `translate(${box.left}px, ${box.top}px)`;\n for (const marked of list.querySelectorAll(\"[data-pill]\")) {\n if (marked !== tab) marked.removeAttribute(\"data-pill\");\n }\n tab.setAttribute(\"data-pill\", \"\");\n }, []);\n\n const layoutPill = React.useCallback(\n (list: HTMLElement, indicator: HTMLElement, activeTab: HTMLElement) => {\n indicator.style.background = \"var(--color-content-primary)\";\n indicator.style.inset = \"0 auto auto 0\";\n const previous = tabBoxes.current;\n const rowResized = listWidth.current !== null && listWidth.current !== list.offsetWidth;\n listWidth.current = list.offsetWidth;\n const { boxes, order } = measureTabs(list, resizeObserverRef.current);\n tabBoxes.current = boxes;\n tabOrder.current = order;\n if (!rowResized && previous.size > 0 && !prefersReducedMotion()) {\n slideFromPrevious(list, previous, boxes, pillStepMs(canHover.current));\n }\n placePill(pillTarget(list, hoveredTab.current, activeTab));\n },\n [placePill],\n );\n\n const updateIndicator = React.useCallback(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) {\n indicator.style.opacity = \"0\";\n list.querySelector(\"[data-pill]\")?.removeAttribute(\"data-pill\");\n return;\n }\n\n const isVertical = list.dataset.orientation === \"vertical\";\n\n indicator.style.opacity = \"1\";\n\n if (appearance === \"pill\") {\n layoutPill(list, indicator, activeTab);\n } else if (isVertical) {\n indicator.style.background =\n \"linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = `0 -1px auto auto`;\n indicator.style.width = \"1px\";\n indicator.style.height = `${activeTab.offsetHeight}px`;\n indicator.style.transform = `translateY(${activeTab.offsetTop}px)`;\n } else {\n indicator.style.background =\n \"linear-gradient(90deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = \"auto auto 0 0\";\n indicator.style.height = \"1px\";\n indicator.style.width = `${activeTab.offsetWidth}px`;\n indicator.style.transform = `translateX(${activeTab.offsetLeft}px)`;\n }\n }, [appearance, layoutPill]);\n\n const followsHover = appearance === \"pill\" && followHover;\n\n const handlePointerOver = (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerOver?.(event);\n if (!followsHover || event.pointerType !== \"mouse\") return;\n if (prefersReducedMotion()) return;\n const tab = (event.target as Element).closest<HTMLElement>('[role=\"tab\"]');\n if (!tab || tab === hoveredTab.current || !event.currentTarget.contains(tab)) return;\n hoveredTab.current = tab;\n placePill(pillTarget(event.currentTarget, tab, tab));\n };\n\n const handlePointerLeave = (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerLeave?.(event);\n if (!hoveredTab.current) return;\n hoveredTab.current = null;\n const list = innerRef.current;\n const activeTab = list?.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (list && activeTab) placePill(pillTarget(list, null, activeTab));\n };\n\n // Radix scrolls a tab into view when it takes focus, and mount is not focus, so\n // URL-driven state can land on a tab that is off to the right with nothing on\n // screen to say so: no indicator, and tab one showing as though it were active.\n // Assigns `scrollLeft` rather than calling `scrollIntoView`, which would also\n // scroll every ancestor and the page with it. Only ever scrolls further right, so\n // re-running it after the webfont settles corrects a short initial scroll without\n // yanking the row back from wherever the user has since dragged it.\n const revealActiveTab = React.useCallback(() => {\n const list = innerRef.current;\n const scrolls = scrollable || appearance === \"pill\";\n if (!list || !scrolls || list.dataset.orientation === \"vertical\") return;\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) return;\n const overshoot = activeTab.offsetLeft + activeTab.offsetWidth - list.clientWidth;\n if (overshoot > list.scrollLeft) list.scrollLeft = overshoot;\n }, [scrollable, appearance]);\n\n React.useLayoutEffect(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n canHover.current = window.matchMedia?.(\"(hover: hover)\").matches ?? false;\n\n const resizeObserver = new ResizeObserver(updateIndicator);\n resizeObserver.observe(list);\n resizeObserverRef.current = resizeObserver;\n\n indicator.style.transitionDuration = \"0s\";\n updateIndicator();\n indicator.getBoundingClientRect();\n indicator.style.transitionDuration = \"\";\n revealActiveTab();\n\n const mutationObserver = new MutationObserver(updateIndicator);\n mutationObserver.observe(list, {\n attributes: true,\n attributeFilter: [\"data-state\", \"aria-expanded\"],\n childList: true,\n subtree: true,\n });\n\n let cancelled = false;\n if (document.fonts?.status !== \"loaded\") {\n document.fonts?.ready.then(() => {\n if (cancelled) return;\n updateIndicator();\n // The tabs are wider once the real font is in, so the mount-time scroll can\n // fall short of the active tab. Recomputed here against the settled layout.\n revealActiveTab();\n });\n }\n\n return () => {\n cancelled = true;\n mutationObserver.disconnect();\n resizeObserver.disconnect();\n resizeObserverRef.current = null;\n };\n }, [updateIndicator, revealActiveTab]);\n\n const isPill = appearance === \"pill\";\n const listStyle: React.CSSProperties & { \"--pill-ease\"?: string } = isPill\n ? { \"--pill-ease\": PILL_EASE, ...style }\n : { ...style };\n\n return (\n <TabsAppearanceContext.Provider value={{ appearance, size }}>\n <TabsPrimitive.List\n ref={innerRef}\n onPointerOver={handlePointerOver}\n onPointerLeave={handlePointerLeave}\n style={listStyle}\n className={cn(\n // `isolate` scopes the active indicator's `z-10` to a local stacking\n // context. Without it, `relative` alone creates no stacking context, so\n // the indicator escapes and paints above page chrome (e.g. the header).\n \"relative isolate\",\n isPill\n ? \"inline-flex w-fit max-w-full items-center gap-1 overflow-x-auto rounded-full bg-background-secondary p-1 shadow-md [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n : [\n getLayoutClass(variant, fullWidth, alignLeft),\n // Horizontal only: in the vertical orientation the leading padding is\n // the row's left inset, not a label offset, so zeroing it would pull\n // the first label out of line with the others.\n flushLeft && \"data-[orientation=horizontal]:[&>[role=tab]:first-child]:pl-0\",\n // `flex-none` is what stops the tabs compressing — without it they\n // share the row and never overflow, so there is nothing to scroll.\n // The scrollbar is hidden in both engines: Firefox reads\n // `scrollbar-width`, WebKit and Blink the pseudo-element.\n scrollable &&\n \"data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] data-[orientation=horizontal]:[&::-webkit-scrollbar]:hidden data-[orientation=horizontal]:[&>[role=tab]]:flex-none\",\n \"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]\",\n \"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]\",\n ],\n className,\n )}\n {...props}\n >\n {children}\n <span\n ref={indicatorRef}\n aria-hidden\n className={cn(\n \"pointer-events-none absolute rounded-full motion-safe:transition-[transform,width,height]\",\n isPill\n ? \"z-5 motion-safe:duration-(--pill-slide) motion-safe:ease-(--pill-ease)\"\n : \"z-10 motion-safe:duration-200 motion-safe:ease-in-out\",\n )}\n style={{ opacity: 0 }}\n />\n </TabsPrimitive.List>\n </TabsAppearanceContext.Provider>\n );\n },\n);\n\nTabsList.displayName = \"TabsList\";\n"],"names":["React","jsx","jsxs","TabsPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAaO,MAAM,wBAAwBA,iBAAM,cAGxC,EAAE,YAAY,aAAa,MAAM,MAAM;AAI1C,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AAEpB,MAAM,qBAAqB;AAE3B,SAAS,WAAW,UAAmB;AACrC,SAAO,WAAW,eAAe;AACnC;AAEA,SAAS,YAAY,UAAkB,UAAmB;AACxD,MAAI,CAAC,SAAU,QAAO;AACtB,SAAO,KAAK,IAAI,eAAe,KAAK,IAAI,WAAW,GAAG,CAAC,IAAI,oBAAoB,WAAW;AAC5F;AAEA,MAAM,uBAAuB,MAC3B,OAAO,aAAa,kCAAkC,EAAE,WAAW;AAErE,SAAS,WAAW,MAAmB,SAA6B,WAAwB;AAC1F,SACE,KAAK,cAA2B,oCAAoC,MACnE,SAAS,cAAc,UAAU;AAEtC;AAEA,SAAS,YAAY,MAAmB,UAAiC;AACvE,QAAM,4BAAY,IAAA;AAClB,QAAM,4BAAY,IAAA;AAClB,aAAW,OAAO,KAAK,iBAA8B,cAAc,GAAG;AACpE,cAAU,QAAQ,GAAG;AACrB,UAAM,IAAI,KAAK,MAAM,IAAI;AACzB,UAAM,IAAI,KAAK;AAAA,MACb,MAAM,IAAI;AAAA,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QACL,eAAe;AAAA,QACf,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,WAAWC,GAAAA;AAAAA;AAAAA;AAAAA;AAAAA,UAIT;AAAA,UACA,SACI,4KACA;AAAA,YACE,eAAe,SAAS,WAAW,SAAS;AAAA;AAAA;AAAA;AAAA,YAI5C,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,YAKb,cACE;AAAA,YACF;AAAA,YACA;AAAA,UAAA;AAAA,UAEN;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACDH,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,eAAW;AAAA,cACX,WAAWG,GAAAA;AAAAA,gBACT;AAAA,gBACA,SACI,2EACA;AAAA,cAAA;AAAA,cAEN,OAAO,EAAE,SAAS,EAAA;AAAA,YAAE;AAAA,UAAA;AAAA,QACtB;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;;;"}
|
|
1
|
+
{"version":3,"file":"TabsList.cjs","sources":["../../../../src/components/Tabs/TabsList.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Breakpoint values for responsive props. */\ntype Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/** Visual style of a {@link TabsList}. */\nexport type TabsListAppearance = \"underline\" | \"pill\";\n\n/** Height in pixels of each tab in a pill {@link TabsList}. */\nexport type TabsListPillSize = \"32\" | \"36\";\n\nexport const TabsAppearanceContext = React.createContext<{\n appearance: TabsListAppearance;\n size: TabsListPillSize;\n}>({ appearance: \"underline\", size: \"32\" });\n\ntype TabBox = { left: number; top: number; width: number; height: number };\n\n/** Track styling shared by the pill {@link TabsList} and {@link TabsListSkeleton}. */\nexport const PILL_TRACK_CLASS =\n \"bg-(image:--fv-raised-control-fill) inline-flex w-fit max-w-full items-center gap-1 overflow-x-auto rounded-full bg-background-secondary p-1 shadow-(--fv-raised-control-shadow) [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\";\n\nconst PILL_EASE = \"cubic-bezier(0.22, 1, 0.36, 1)\";\nconst PILL_STEP_MS = 360;\nconst PILL_STEP_MS_TOUCH = 200;\nconst PILL_EXTRA_STEP_MS = 220;\nconst PILL_MAX_MS = 1000;\n/** Share of a slide by which the eased pill has covered 80% of the way, so the label recolours under it. */\nconst PILL_ARRIVAL_SHARE = 0.27;\n\nfunction pillStepMs(canHover: boolean) {\n return canHover ? PILL_STEP_MS : PILL_STEP_MS_TOUCH;\n}\n\nfunction pillSlideMs(distance: number, canHover: boolean) {\n if (!canHover) return PILL_STEP_MS_TOUCH;\n return Math.min(PILL_STEP_MS + Math.max(distance - 1, 0) * PILL_EXTRA_STEP_MS, PILL_MAX_MS);\n}\n\nconst prefersReducedMotion = () =>\n window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false;\n\nfunction pillTarget(list: HTMLElement, hovered: HTMLElement | null, activeTab: HTMLElement) {\n return (\n list.querySelector<HTMLElement>('[role=\"tab\"][aria-expanded=\"true\"]') ??\n (hovered?.isConnected ? hovered : activeTab)\n );\n}\n\nfunction measureTabs(list: HTMLElement, observer: ResizeObserver | null) {\n const boxes = new Map<Element, TabBox>();\n const order = new Map<Element, number>();\n for (const tab of list.querySelectorAll<HTMLElement>('[role=\"tab\"]')) {\n observer?.observe(tab);\n order.set(tab, order.size);\n boxes.set(tab, {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n });\n }\n return { boxes, order };\n}\n\nfunction slideFromPrevious(\n list: HTMLElement,\n previous: Map<Element, TabBox>,\n next: Map<Element, TabBox>,\n durationMs: number,\n) {\n const moved: HTMLElement[] = [];\n for (const [tab, box] of next) {\n const before = previous.get(tab);\n if (!before || before.left === box.left || !(tab instanceof HTMLElement)) continue;\n tab.style.transition = \"none\";\n tab.style.transform = `translateX(${before.left - box.left}px)`;\n moved.push(tab);\n }\n if (moved.length === 0) return;\n list.getBoundingClientRect();\n for (const tab of moved) {\n tab.style.transition = `transform ${durationMs}ms var(--pill-ease)`;\n tab.style.transform = \"\";\n const settle = (event: TransitionEvent) => {\n if (event.propertyName !== \"transform\") return;\n tab.style.transition = \"\";\n tab.removeEventListener(\"transitionend\", settle);\n };\n tab.addEventListener(\"transitionend\", settle);\n }\n}\n\nconst alignLeftClasses: Record<Breakpoint | \"always\", string> = {\n always: \"[&>[role=tab]]:flex-initial\",\n sm: \"[&>[role=tab]]:sm:flex-initial\",\n md: \"[&>[role=tab]]:md:flex-initial\",\n lg: \"[&>[role=tab]]:lg:flex-initial\",\n xl: \"[&>[role=tab]]:xl:flex-initial\",\n};\n\nfunction getLayoutClass(\n variant: \"fill\" | \"hug\" | undefined,\n fullWidth: boolean,\n alignLeft?: boolean | Breakpoint,\n): string {\n if (variant === \"hug\") return \"inline-flex\";\n if (variant === \"fill\") return \"flex w-full [&>[role=tab]]:flex-1\";\n\n if (!fullWidth) return \"inline-flex\";\n\n const base = \"flex w-full [&>[role=tab]]:flex-1\";\n if (alignLeft === true) return `${base} ${alignLeftClasses.always}`;\n if (typeof alignLeft === \"string\") return `${base} ${alignLeftClasses[alignLeft]}`;\n return base;\n}\n\n/** Props for the {@link TabsList} component. */\nexport type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & {\n /** When `true` (the default), the tab list spans the full width of its container and each tab grows equally. Set to `false` for inline sizing. */\n fullWidth?: boolean;\n /**\n * Controls tab alignment within a full-width container.\n * - `false` (default): tabs spread evenly\n * - `true`: tabs left-aligned, sized to content\n * - `\"md\"` (breakpoint): spread on mobile, left-aligned at breakpoint and up\n */\n alignLeft?: boolean | Breakpoint;\n /** Explicit layout variant. `\"hug\"` sizes the list to its content; `\"fill\"` stretches it full-width with equal-width tabs. Takes precedence over `fullWidth`/`alignLeft`. */\n variant?: \"fill\" | \"hug\";\n /**\n * Drops the leading padding on the first tab so its label sits flush with the\n * list's left edge, lining it up with page content above or below the bar\n * (a heading, for instance) rather than being indented by the tab's own\n * padding. Spacing between tabs is unaffected. Pair with `alignLeft` or\n * `variant=\"hug\"`. @default false\n */\n flushLeft?: boolean;\n /**\n * Scrolls the row horizontally when the tabs don't fit, instead of letting\n * them compress. By default a tab may shrink until its label ellipsises,\n * which on a narrow viewport can truncate every label at once; here each tab\n * keeps its natural width and the overflow scrolls. The scrollbar itself is\n * hidden — the clipped tab at the edge is the affordance.\n *\n * Because the tabs are content-sized, they no longer spread to fill the row:\n * a set that does fit sits left-aligned, as with `alignLeft`.\n *\n * Horizontal orientation only: a vertical list already grows downwards.\n * @default false\n */\n scrollable?: boolean;\n /**\n * `\"underline\"` marks the active tab with a line under the row. `\"pill\"` sits\n * the tabs in a rounded track, sized to its tabs, and slides a filled pill\n * behind the active one. A pill list is horizontal and ignores `fullWidth`,\n * `alignLeft`, `variant` and `flushLeft`; it scrolls when it doesn't fit.\n * @default \"underline\"\n */\n appearance?: TabsListAppearance;\n /** Height of each tab in a pill list. Ignored by the underline appearance. @default \"32\" */\n size?: TabsListPillSize;\n /**\n * Pill only: the pill follows the mouse across the tabs and settles back on the\n * selected one when the pointer leaves. Mouse only, and off when the user prefers\n * reduced motion. @default false\n */\n followHover?: boolean;\n};\n\n/** Container for {@link TabsTrigger} elements. Renders a sliding active-tab indicator that animates between tabs. */\nexport const TabsList = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.List>,\n TabsListProps\n>(\n (\n {\n className,\n children,\n fullWidth = true,\n alignLeft,\n variant,\n flushLeft = false,\n scrollable = false,\n appearance = \"underline\",\n size = \"32\",\n followHover = false,\n onPointerOver,\n onPointerLeave,\n style,\n ...props\n },\n ref,\n ) => {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const indicatorRef = React.useRef<HTMLSpanElement>(null);\n\n React.useImperativeHandle(ref, () => innerRef.current as HTMLDivElement);\n\n const tabBoxes = React.useRef(new Map<Element, TabBox>());\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\n const listWidth = React.useRef<number | null>(null);\n const hoveredTab = React.useRef<HTMLElement | null>(null);\n const pillTab = React.useRef<HTMLElement | null>(null);\n const tabOrder = React.useRef(new Map<Element, number>());\n const canHover = React.useRef(false);\n\n const placePill = React.useCallback((tab: HTMLElement) => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n const box = tabBoxes.current.get(tab);\n if (!box) return;\n const from = pillTab.current;\n pillTab.current = tab;\n const distance =\n from && from !== tab\n ? Math.abs((tabOrder.current.get(tab) ?? 0) - (tabOrder.current.get(from) ?? 0))\n : 0;\n const slideMs = pillSlideMs(distance, canHover.current);\n list.style.setProperty(\"--pill-slide\", `${slideMs}ms`);\n list.style.setProperty(\"--pill-arrive\", `${Math.round(slideMs * PILL_ARRIVAL_SHARE)}ms`);\n indicator.style.width = `${box.width}px`;\n indicator.style.height = `${box.height}px`;\n indicator.style.transform = `translate(${box.left}px, ${box.top}px)`;\n for (const marked of list.querySelectorAll(\"[data-pill]\")) {\n if (marked !== tab) marked.removeAttribute(\"data-pill\");\n }\n tab.setAttribute(\"data-pill\", \"\");\n }, []);\n\n const layoutPill = React.useCallback(\n (list: HTMLElement, indicator: HTMLElement, activeTab: HTMLElement) => {\n indicator.style.background = \"var(--color-content-primary)\";\n indicator.style.inset = \"0 auto auto 0\";\n const previous = tabBoxes.current;\n const rowResized = listWidth.current !== null && listWidth.current !== list.offsetWidth;\n listWidth.current = list.offsetWidth;\n const { boxes, order } = measureTabs(list, resizeObserverRef.current);\n tabBoxes.current = boxes;\n tabOrder.current = order;\n if (!rowResized && previous.size > 0 && !prefersReducedMotion()) {\n slideFromPrevious(list, previous, boxes, pillStepMs(canHover.current));\n }\n placePill(pillTarget(list, hoveredTab.current, activeTab));\n },\n [placePill],\n );\n\n const updateIndicator = React.useCallback(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) {\n indicator.style.opacity = \"0\";\n list.querySelector(\"[data-pill]\")?.removeAttribute(\"data-pill\");\n return;\n }\n\n const isVertical = list.dataset.orientation === \"vertical\";\n\n indicator.style.opacity = \"1\";\n\n if (appearance === \"pill\") {\n layoutPill(list, indicator, activeTab);\n } else if (isVertical) {\n indicator.style.background =\n \"linear-gradient(180deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = `0 -1px auto auto`;\n indicator.style.width = \"1px\";\n indicator.style.height = `${activeTab.offsetHeight}px`;\n indicator.style.transform = `translateY(${activeTab.offsetTop}px)`;\n } else {\n indicator.style.background =\n \"linear-gradient(90deg, var(--color-buttons-tertiary-default) 0%, var(--color-tab-active) 50%, var(--color-buttons-tertiary-default) 100%)\";\n indicator.style.inset = \"auto auto 0 0\";\n indicator.style.height = \"1px\";\n indicator.style.width = `${activeTab.offsetWidth}px`;\n indicator.style.transform = `translateX(${activeTab.offsetLeft}px)`;\n }\n }, [appearance, layoutPill]);\n\n const followsHover = appearance === \"pill\" && followHover;\n\n const handlePointerOver = (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerOver?.(event);\n if (!followsHover || event.pointerType !== \"mouse\") return;\n if (prefersReducedMotion()) return;\n const tab = (event.target as Element).closest<HTMLElement>('[role=\"tab\"]');\n if (!tab || tab === hoveredTab.current || !event.currentTarget.contains(tab)) return;\n hoveredTab.current = tab;\n placePill(pillTarget(event.currentTarget, tab, tab));\n };\n\n const handlePointerLeave = (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerLeave?.(event);\n if (!hoveredTab.current) return;\n hoveredTab.current = null;\n const list = innerRef.current;\n const activeTab = list?.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (list && activeTab) placePill(pillTarget(list, null, activeTab));\n };\n\n // Radix scrolls a tab into view when it takes focus, and mount is not focus, so\n // URL-driven state can land on a tab that is off to the right with nothing on\n // screen to say so: no indicator, and tab one showing as though it were active.\n // Assigns `scrollLeft` rather than calling `scrollIntoView`, which would also\n // scroll every ancestor and the page with it. Only ever scrolls further right, so\n // re-running it after the webfont settles corrects a short initial scroll without\n // yanking the row back from wherever the user has since dragged it.\n const revealActiveTab = React.useCallback(() => {\n const list = innerRef.current;\n const scrolls = scrollable || appearance === \"pill\";\n if (!list || !scrolls || list.dataset.orientation === \"vertical\") return;\n const activeTab = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n if (!activeTab) return;\n const overshoot = activeTab.offsetLeft + activeTab.offsetWidth - list.clientWidth;\n if (overshoot > list.scrollLeft) list.scrollLeft = overshoot;\n }, [scrollable, appearance]);\n\n React.useLayoutEffect(() => {\n const list = innerRef.current;\n const indicator = indicatorRef.current;\n if (!list || !indicator) return;\n\n canHover.current = window.matchMedia?.(\"(hover: hover)\").matches ?? false;\n\n const resizeObserver = new ResizeObserver(updateIndicator);\n resizeObserver.observe(list);\n resizeObserverRef.current = resizeObserver;\n\n indicator.style.transitionDuration = \"0s\";\n updateIndicator();\n indicator.getBoundingClientRect();\n indicator.style.transitionDuration = \"\";\n revealActiveTab();\n\n const mutationObserver = new MutationObserver(updateIndicator);\n mutationObserver.observe(list, {\n attributes: true,\n attributeFilter: [\"data-state\", \"aria-expanded\"],\n childList: true,\n subtree: true,\n });\n\n let cancelled = false;\n if (document.fonts?.status !== \"loaded\") {\n document.fonts?.ready.then(() => {\n if (cancelled) return;\n updateIndicator();\n // The tabs are wider once the real font is in, so the mount-time scroll can\n // fall short of the active tab. Recomputed here against the settled layout.\n revealActiveTab();\n });\n }\n\n return () => {\n cancelled = true;\n mutationObserver.disconnect();\n resizeObserver.disconnect();\n resizeObserverRef.current = null;\n };\n }, [updateIndicator, revealActiveTab]);\n\n const isPill = appearance === \"pill\";\n const listStyle: React.CSSProperties & { \"--pill-ease\"?: string } = isPill\n ? { \"--pill-ease\": PILL_EASE, ...style }\n : { ...style };\n\n return (\n <TabsAppearanceContext.Provider value={{ appearance, size }}>\n <TabsPrimitive.List\n ref={innerRef}\n onPointerOver={handlePointerOver}\n onPointerLeave={handlePointerLeave}\n style={listStyle}\n className={cn(\n // `isolate` scopes the active indicator's `z-10` to a local stacking\n // context. Without it, `relative` alone creates no stacking context, so\n // the indicator escapes and paints above page chrome (e.g. the header).\n \"relative isolate\",\n isPill\n ? PILL_TRACK_CLASS\n : [\n getLayoutClass(variant, fullWidth, alignLeft),\n // Horizontal only: in the vertical orientation the leading padding is\n // the row's left inset, not a label offset, so zeroing it would pull\n // the first label out of line with the others.\n flushLeft && \"data-[orientation=horizontal]:[&>[role=tab]:first-child]:pl-0\",\n // `flex-none` is what stops the tabs compressing — without it they\n // share the row and never overflow, so there is nothing to scroll.\n // The scrollbar is hidden in both engines: Firefox reads\n // `scrollbar-width`, WebKit and Blink the pseudo-element.\n scrollable &&\n \"data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] data-[orientation=horizontal]:[&::-webkit-scrollbar]:hidden data-[orientation=horizontal]:[&>[role=tab]]:flex-none\",\n \"data-[orientation=horizontal]:items-center data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--color-border-primary)]\",\n \"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--color-border-primary)]\",\n ],\n className,\n )}\n {...props}\n >\n {children}\n <span\n ref={indicatorRef}\n aria-hidden\n className={cn(\n \"pointer-events-none absolute rounded-full motion-safe:transition-[transform,width,height]\",\n isPill\n ? \"z-5 shadow-(--fv-raised-control-thumb-shadow) motion-safe:duration-(--pill-slide) motion-safe:ease-(--pill-ease)\"\n : \"z-10 motion-safe:duration-200 motion-safe:ease-in-out\",\n )}\n style={{ opacity: 0 }}\n />\n </TabsPrimitive.List>\n </TabsAppearanceContext.Provider>\n );\n },\n);\n\nTabsList.displayName = \"TabsList\";\n"],"names":["React","jsx","jsxs","TabsPrimitive","cn"],"mappings":";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A,YAAA;AAAA,cACC,KAAK;AAAA,cACL,eAAW;AAAA,cACX,WAAWG,GAAAA;AAAAA,gBACT;AAAA,gBACA,SACI,qHACA;AAAA,cAAA;AAAA,cAEN,OAAO,EAAE,SAAS,EAAA;AAAA,YAAE;AAAA,UAAA;AAAA,QACtB;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const cn = require("../../utils/cn.cjs");
|
|
7
|
+
const TabsList = require("./TabsList.cjs");
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
10
|
+
if (e) {
|
|
11
|
+
for (const k in e) {
|
|
12
|
+
if (k !== "default") {
|
|
13
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => e[k]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
25
|
+
const TabsListSkeleton = React__namespace.forwardRef(
|
|
26
|
+
({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "aria-hidden": "true", className: cn.cn(TabsList.PILL_TRACK_CLASS, className), ...props, children })
|
|
27
|
+
);
|
|
28
|
+
TabsListSkeleton.displayName = "TabsListSkeleton";
|
|
29
|
+
exports.TabsListSkeleton = TabsListSkeleton;
|
|
30
|
+
//# sourceMappingURL=TabsListSkeleton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabsListSkeleton.cjs","sources":["../../../../src/components/Tabs/TabsListSkeleton.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { PILL_TRACK_CLASS } from \"./TabsList\";\n\n/** Props for the {@link TabsListSkeleton} component. */\nexport type TabsListSkeletonProps = React.HTMLAttributes<HTMLDivElement>;\n\n/**\n * Loading placeholder for a pill {@link TabsList}. Renders the same track, so\n * the row does not jump when the real tabs replace it. Pass placeholder items\n * (for example {@link Skeleton} pills) as children.\n *\n * The track is hidden from assistive technology; announce the loading state on\n * the surrounding region with `aria-busy`.\n *\n * @example\n * ```tsx\n * <TabsListSkeleton>\n * <Skeleton variant=\"rounded\" width={64} height={32} className=\"rounded-full\" />\n * <Skeleton variant=\"rounded\" width={80} height={32} className=\"rounded-full\" />\n * </TabsListSkeleton>\n * ```\n */\nexport const TabsListSkeleton = React.forwardRef<HTMLDivElement, TabsListSkeletonProps>(\n ({ className, children, ...props }, ref) => (\n <div ref={ref} aria-hidden=\"true\" className={cn(PILL_TRACK_CLASS, className)} {...props}>\n {children}\n </div>\n ),\n);\n\nTabsListSkeleton.displayName = \"TabsListSkeleton\";\n"],"names":["React","jsx","cn","PILL_TRACK_CLASS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBO,MAAM,mBAAmBA,iBAAM;AAAA,EACpC,CAAC,EAAE,WAAW,UAAU,GAAG,MAAA,GAAS,QAClCC,2BAAAA,IAAC,OAAA,EAAI,KAAU,eAAY,QAAO,WAAWC,MAAGC,SAAAA,kBAAkB,SAAS,GAAI,GAAG,OAC/E,SAAA,CACH;AAEJ;AAEA,iBAAiB,cAAc;;"}
|
|
@@ -50,7 +50,7 @@ const TooltipContent = React__namespace.forwardRef(
|
|
|
50
50
|
collisionPadding: 8,
|
|
51
51
|
style: { zIndex: "var(--fanvue-ui-portal-z-index, 50)", ...style },
|
|
52
52
|
className: cn.cn(
|
|
53
|
-
"typography-description-12px-semibold max-w-[320px] rounded-
|
|
53
|
+
"typography-description-12px-semibold max-w-[320px] rounded-xs border-[0.5px] border-border-strong bg-surface-secondary px-4 py-2 text-content-primary shadow-sm",
|
|
54
54
|
className
|
|
55
55
|
),
|
|
56
56
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.cjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link TooltipProvider}. Wraps Radix `Tooltip.Provider`. */\nexport type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>;\n\nconst DEFAULT_DELAY_DURATION = 200;\n\n/**\n * Provides tooltip delay and skip-delay context. Wrap your app or a subtree.\n *\n * Defaults `delayDuration` to 200ms rather than inheriting Radix's 700ms, which\n * reads as unresponsive on the short hint labels this library uses tooltips for.\n * Pass `delayDuration` to override.\n *\n * Note that `TooltipLabel`, `ChartCard`, `SwitchField` and `TableTruncatedText`\n * each mount their own provider internally, so they take this default but not an\n * app-level override.\n */\nexport const TooltipProvider = ({\n delayDuration = DEFAULT_DELAY_DURATION,\n ...props\n}: TooltipProviderProps) => <TooltipPrimitive.Provider delayDuration={delayDuration} {...props} />;\nTooltipProvider.displayName = \"TooltipProvider\";\n\n/** Props for the {@link Tooltip} root component. */\nexport interface TooltipProps extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n defaultOpen?: boolean;\n}\n\n/** Root component that manages open/close state for a single tooltip. */\nexport const Tooltip = TooltipPrimitive.Root;\n\n/** Props for the {@link TooltipTrigger} component. */\nexport type TooltipTriggerProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>;\n\n/** The element that triggers the tooltip on hover/focus. */\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\n/** Position of the tooltip relative to its trigger, combining side and alignment (MUI-style). */\nexport type TooltipPlacement =\n | \"top\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom-start\"\n | \"bottom-end\"\n | \"left\"\n | \"left-start\"\n | \"left-end\"\n | \"right\"\n | \"right-start\"\n | \"right-end\";\n\nexport interface TooltipContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>, \"title\"> {\n /**\n * Position of the tooltip relative to the trigger. Takes precedence over `side` and `align`.\n * @default \"top\"\n */\n placement?: TooltipPlacement;\n /**\n * Optional heading above the body, for the two-row tooltip: a bold label\n * naming the thing, then a plain-weight description of it. Without it the\n * tooltip is a single bold line.\n */\n title?: React.ReactNode;\n}\n\nexport const TooltipContent = React.forwardRef<\n React.ComponentRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(\n (\n { className, sideOffset = 8, style, placement, side, align, title, children, ...props },\n ref,\n ) => {\n let resolvedSide = side;\n let resolvedAlign: \"start\" | \"center\" | \"end\" = align ?? \"center\";\n if (placement) {\n const [parsedSide, parsedAlign] = placement.split(\"-\") as [\n \"top\" | \"right\" | \"bottom\" | \"left\",\n \"start\" | \"end\" | undefined,\n ];\n resolvedSide = parsedSide;\n resolvedAlign = parsedAlign ?? \"center\";\n }\n\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n side={resolvedSide}\n align={resolvedAlign}\n sideOffset={sideOffset}\n collisionPadding={8}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"typography-description-12px-semibold max-w-[320px] rounded-
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Props for the {@link TooltipProvider}. Wraps Radix `Tooltip.Provider`. */\nexport type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>;\n\nconst DEFAULT_DELAY_DURATION = 200;\n\n/**\n * Provides tooltip delay and skip-delay context. Wrap your app or a subtree.\n *\n * Defaults `delayDuration` to 200ms rather than inheriting Radix's 700ms, which\n * reads as unresponsive on the short hint labels this library uses tooltips for.\n * Pass `delayDuration` to override.\n *\n * Note that `TooltipLabel`, `ChartCard`, `SwitchField` and `TableTruncatedText`\n * each mount their own provider internally, so they take this default but not an\n * app-level override.\n */\nexport const TooltipProvider = ({\n delayDuration = DEFAULT_DELAY_DURATION,\n ...props\n}: TooltipProviderProps) => <TooltipPrimitive.Provider delayDuration={delayDuration} {...props} />;\nTooltipProvider.displayName = \"TooltipProvider\";\n\n/** Props for the {@link Tooltip} root component. */\nexport interface TooltipProps extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n defaultOpen?: boolean;\n}\n\n/** Root component that manages open/close state for a single tooltip. */\nexport const Tooltip = TooltipPrimitive.Root;\n\n/** Props for the {@link TooltipTrigger} component. */\nexport type TooltipTriggerProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>;\n\n/** The element that triggers the tooltip on hover/focus. */\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\n/** Position of the tooltip relative to its trigger, combining side and alignment (MUI-style). */\nexport type TooltipPlacement =\n | \"top\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom-start\"\n | \"bottom-end\"\n | \"left\"\n | \"left-start\"\n | \"left-end\"\n | \"right\"\n | \"right-start\"\n | \"right-end\";\n\nexport interface TooltipContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>, \"title\"> {\n /**\n * Position of the tooltip relative to the trigger. Takes precedence over `side` and `align`.\n * @default \"top\"\n */\n placement?: TooltipPlacement;\n /**\n * Optional heading above the body, for the two-row tooltip: a bold label\n * naming the thing, then a plain-weight description of it. Without it the\n * tooltip is a single bold line.\n */\n title?: React.ReactNode;\n}\n\n/**\n * The floating tooltip panel. It sits on a same-mode surface rather than an\n * inverted one, so it is dark in dark mode and light in light mode, set off by\n * a hairline border.\n */\nexport const TooltipContent = React.forwardRef<\n React.ComponentRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(\n (\n { className, sideOffset = 8, style, placement, side, align, title, children, ...props },\n ref,\n ) => {\n let resolvedSide = side;\n let resolvedAlign: \"start\" | \"center\" | \"end\" = align ?? \"center\";\n if (placement) {\n const [parsedSide, parsedAlign] = placement.split(\"-\") as [\n \"top\" | \"right\" | \"bottom\" | \"left\",\n \"start\" | \"end\" | undefined,\n ];\n resolvedSide = parsedSide;\n resolvedAlign = parsedAlign ?? \"center\";\n }\n\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n side={resolvedSide}\n align={resolvedAlign}\n sideOffset={sideOffset}\n collisionPadding={8}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"typography-description-12px-semibold max-w-[320px] rounded-xs border-[0.5px] border-border-strong bg-surface-secondary px-4 py-2 text-content-primary shadow-sm\",\n className,\n )}\n {...props}\n >\n {title ? (\n <span className=\"flex flex-col gap-1\">\n <span>{title}</span>\n <span className=\"typography-description-12px-regular\">{children}</span>\n </span>\n ) : (\n children\n )}\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n },\n);\nTooltipContent.displayName = \"TooltipContent\";\n"],"names":["TooltipPrimitive","React","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,yBAAyB;AAaxB,MAAM,kBAAkB,CAAC;AAAA,EAC9B,gBAAgB;AAAA,EAChB,GAAG;AACL,qCAA6BA,4BAAiB,UAAjB,EAA0B,eAA+B,GAAG,MAAA,CAAO;AAChG,gBAAgB,cAAc;AAUvB,MAAM,UAAUA,4BAAiB;AAMjC,MAAM,iBAAiBA,4BAAiB;AAqCxC,MAAM,iBAAiBC,iBAAM;AAAA,EAIlC,CACE,EAAE,WAAW,aAAa,GAAG,OAAO,WAAW,MAAM,OAAO,OAAO,UAAU,GAAG,MAAA,GAChF,QACG;AACH,QAAI,eAAe;AACnB,QAAI,gBAA4C,SAAS;AACzD,QAAI,WAAW;AACb,YAAM,CAAC,YAAY,WAAW,IAAI,UAAU,MAAM,GAAG;AAIrD,qBAAe;AACf,sBAAgB,eAAe;AAAA,IACjC;AAEA,WACEC,2BAAAA,IAACF,4BAAiB,QAAjB,EACC,UAAAE,2BAAAA;AAAAA,MAACF,4BAAiB;AAAA,MAAjB;AAAA,QACC;AAAA,QACA,MAAM;AAAA,QACN,OAAO;AAAA,QACP;AAAA,QACA,kBAAkB;AAAA,QAClB,OAAO,EAAE,QAAQ,uCAAuC,GAAG,MAAA;AAAA,QAC3D,WAAWG,GAAAA;AAAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA,QACCC,gCAAC,QAAA,EAAK,WAAU,uBACd,UAAA;AAAA,UAAAF,2BAAAA,IAAC,UAAM,UAAA,MAAA,CAAM;AAAA,UACbA,2BAAAA,IAAC,QAAA,EAAK,WAAU,uCAAuC,SAAA,CAAS;AAAA,QAAA,EAAA,CAClE,IAEA;AAAA,MAAA;AAAA,IAAA,GAGN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const ToastPrimitive = require("@radix-ui/react-toast");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const Button = require("../Button/Button.cjs");
|
|
9
|
+
const TickCircleIcon = require("../Icons/TickCircleIcon.cjs");
|
|
10
|
+
const TrashIcon = require("../Icons/TrashIcon.cjs");
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
12
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
|
+
if (e) {
|
|
14
|
+
for (const k in e) {
|
|
15
|
+
if (k !== "default") {
|
|
16
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => e[k]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
const ToastPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(ToastPrimitive);
|
|
28
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
29
|
+
const TypeIcon = ({ type }) => type === "removed" ? /* @__PURE__ */ jsxRuntime.jsx(TrashIcon.TrashIcon, { size: 16, filled: true, className: "text-alerts-toast-icon-error" }) : /* @__PURE__ */ jsxRuntime.jsx(TickCircleIcon.TickCircleIcon, { size: 16, filled: true, className: "text-alerts-toast-icon-success" });
|
|
30
|
+
const UndoAlertPrompt = React__namespace.forwardRef(
|
|
31
|
+
({ className, type = "positive", title, onUndo, undoLabel = "Undo", undoAltText, ...props }, ref) => {
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33
|
+
ToastPrimitive__namespace.Root,
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
"data-testid": "undo-alert-prompt",
|
|
37
|
+
className: cn.cn(
|
|
38
|
+
"group pointer-events-auto relative flex w-fit max-w-full items-center gap-6 overflow-hidden rounded-md bg-surface-primary-inverted py-3 pr-3 pl-4 text-content-primary-inverted shadow-md transition-all",
|
|
39
|
+
"data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-bottom-full data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[state=closed]:animate-out data-[state=open]:animate-in data-[swipe=end]:animate-out data-[swipe=move]:transition-none",
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...props,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-start gap-3 py-1 pr-1", children: [
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center pt-px", children: /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { type }) }),
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToastPrimitive__namespace.Title, { className: "typography-body-small-14px-semibold min-w-0", children: title })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToastPrimitive__namespace.Action, { altText: undoAltText ?? undoLabel, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
+
Button.Button,
|
|
50
|
+
{
|
|
51
|
+
variant: "secondary",
|
|
52
|
+
negative: true,
|
|
53
|
+
size: "24",
|
|
54
|
+
onClick: onUndo,
|
|
55
|
+
className: "typography-description-12px-semibold shrink-0 rounded-xs",
|
|
56
|
+
children: undoLabel
|
|
57
|
+
}
|
|
58
|
+
) })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
UndoAlertPrompt.displayName = "UndoAlertPrompt";
|
|
65
|
+
exports.UndoAlertPrompt = UndoAlertPrompt;
|
|
66
|
+
//# sourceMappingURL=UndoAlertPrompt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UndoAlertPrompt.cjs","sources":["../../../../src/components/UndoAlertPrompt/UndoAlertPrompt.tsx"],"sourcesContent":["import * as ToastPrimitive from \"@radix-ui/react-toast\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { TickCircleIcon } from \"../Icons/TickCircleIcon\";\nimport { TrashIcon } from \"../Icons/TrashIcon\";\n\n/** Outcome the prompt confirms: a completed change, or a removal. */\nexport type UndoAlertPromptType = \"positive\" | \"removed\";\n\nexport interface UndoAlertPromptProps\n extends Omit<React.ComponentPropsWithoutRef<typeof ToastPrimitive.Root>, \"type\" | \"title\"> {\n /** Outcome being confirmed. Drives the leading icon. @default \"positive\" */\n type?: UndoAlertPromptType;\n /**\n * Confirmation of the action that just completed. Write it for the action\n * being undone, e.g. \"Folder deleted\", \"Template moved\" or\n * \"3 messages archived\". Accepts rich content for emphasising an item name.\n */\n title: React.ReactNode;\n /** Called when the user activates the undo button. The prompt closes afterwards. */\n onUndo: () => void;\n /** Label for the undo button. @default \"Undo\" */\n undoLabel?: string;\n /**\n * Describes an alternative way to undo, announced to screen reader users\n * who cannot reach the button before the prompt dismisses. Word it for the\n * action, e.g. \"Restore the folder from Recently deleted\". @default undoLabel\n */\n undoAltText?: string;\n}\n\nconst TypeIcon = ({ type }: { type: UndoAlertPromptType }) =>\n type === \"removed\" ? (\n <TrashIcon size={16} filled className=\"text-alerts-toast-icon-error\" />\n ) : (\n <TickCircleIcon size={16} filled className=\"text-alerts-toast-icon-success\" />\n );\n\n/**\n * A compact, auto-dismissing confirmation with a single undo action. Use it\n * straight after a reversible change, such as moving or deleting an item, so\n * the user can reverse it without leaving their flow. The copy is not fixed:\n * pass a `title` describing the action that just happened, and pick `type`\n * by outcome (`removed` for deletions, `positive` for everything else).\n *\n * Use inside a {@link ToastProvider} with a {@link ToastViewport}.\n *\n * @example\n * ```tsx\n * <UndoAlertPrompt type=\"removed\" title=\"Folder deleted\" onUndo={restoreFolder} />\n * ```\n */\nexport const UndoAlertPrompt = React.forwardRef<\n React.ComponentRef<typeof ToastPrimitive.Root>,\n UndoAlertPromptProps\n>(\n (\n { className, type = \"positive\", title, onUndo, undoLabel = \"Undo\", undoAltText, ...props },\n ref,\n ) => {\n return (\n <ToastPrimitive.Root\n ref={ref}\n data-testid=\"undo-alert-prompt\"\n className={cn(\n \"group pointer-events-auto relative flex w-fit max-w-full items-center gap-6 overflow-hidden rounded-md bg-surface-primary-inverted py-3 pr-3 pl-4 text-content-primary-inverted shadow-md transition-all\",\n \"data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-bottom-full data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[state=closed]:animate-out data-[state=open]:animate-in data-[swipe=end]:animate-out data-[swipe=move]:transition-none\",\n className,\n )}\n {...props}\n >\n <div className=\"flex min-w-0 items-start gap-3 py-1 pr-1\">\n <div className=\"flex shrink-0 items-center pt-px\">\n <TypeIcon type={type} />\n </div>\n <ToastPrimitive.Title className=\"typography-body-small-14px-semibold min-w-0\">\n {title}\n </ToastPrimitive.Title>\n </div>\n <ToastPrimitive.Action altText={undoAltText ?? undoLabel} asChild>\n <Button\n variant=\"secondary\"\n negative\n size=\"24\"\n onClick={onUndo}\n className=\"typography-description-12px-semibold shrink-0 rounded-xs\"\n >\n {undoLabel}\n </Button>\n </ToastPrimitive.Action>\n </ToastPrimitive.Root>\n );\n },\n);\n\nUndoAlertPrompt.displayName = \"UndoAlertPrompt\";\n"],"names":["jsx","TrashIcon","TickCircleIcon","React","jsxs","ToastPrimitive","cn","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,WAAW,CAAC,EAAE,KAAA,MAClB,SAAS,YACPA,2BAAAA,IAACC,qBAAA,EAAU,MAAM,IAAI,QAAM,MAAC,WAAU,+BAAA,CAA+B,IAErED,2BAAAA,IAACE,eAAAA,gBAAA,EAAe,MAAM,IAAI,QAAM,MAAC,WAAU,iCAAA,CAAiC;AAiBzE,MAAM,kBAAkBC,iBAAM;AAAA,EAInC,CACE,EAAE,WAAW,OAAO,YAAY,OAAO,QAAQ,YAAY,QAAQ,aAAa,GAAG,MAAA,GACnF,QACG;AACH,WACEC,2BAAAA;AAAAA,MAACC,0BAAe;AAAA,MAAf;AAAA,QACC;AAAA,QACA,eAAY;AAAA,QACZ,WAAWC,GAAAA;AAAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAAF,2BAAAA,KAAC,OAAA,EAAI,WAAU,4CACb,UAAA;AAAA,YAAAJ,2BAAAA,IAAC,SAAI,WAAU,oCACb,UAAAA,2BAAAA,IAAC,UAAA,EAAS,MAAY,GACxB;AAAA,2CACCK,0BAAe,OAAf,EAAqB,WAAU,+CAC7B,UAAA,MAAA,CACH;AAAA,UAAA,GACF;AAAA,UACAL,+BAACK,0BAAe,QAAf,EAAsB,SAAS,eAAe,WAAW,SAAO,MAC/D,UAAAL,2BAAAA;AAAAA,YAACO,OAAAA;AAAAA,YAAA;AAAA,cACC,SAAQ;AAAA,cACR,UAAQ;AAAA,cACR,MAAK;AAAA,cACL,SAAS;AAAA,cACT,WAAU;AAAA,cAET,UAAA;AAAA,YAAA;AAAA,UAAA,EACH,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,gBAAgB,cAAc;;"}
|
|
@@ -33,6 +33,7 @@ const getNearestAvatarSize = (size) => AVATAR_SIZES.reduce(
|
|
|
33
33
|
const UserItem = React__namespace.forwardRef(
|
|
34
34
|
({
|
|
35
35
|
user,
|
|
36
|
+
padding = "md",
|
|
36
37
|
avatarSize,
|
|
37
38
|
isOnline = false,
|
|
38
39
|
isMuted = false,
|
|
@@ -53,7 +54,11 @@ const UserItem = React__namespace.forwardRef(
|
|
|
53
54
|
"div",
|
|
54
55
|
{
|
|
55
56
|
ref,
|
|
56
|
-
className: cn.cn(
|
|
57
|
+
className: cn.cn(
|
|
58
|
+
"relative flex w-full items-center justify-start",
|
|
59
|
+
padding === "md" && "px-2 py-1",
|
|
60
|
+
className
|
|
61
|
+
),
|
|
57
62
|
...props,
|
|
58
63
|
children: [
|
|
59
64
|
isMuted && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-0 left-0 z-1 flex rounded-xs bg-surface-primary p-1", children: /* @__PURE__ */ jsxRuntime.jsx(BellOffIcon.BellOffIcon, { size: 16 }) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserItem.cjs","sources":["../../../../src/components/UserItem/UserItem.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { getInitials } from \"../../utils/getInitials\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { BellOffIcon } from \"../Icons/BellOffIcon\";\nimport { UserDisplayName } from \"../UserDisplayName/UserDisplayName\";\nimport { UserHandle } from \"../UserHandle/UserHandle\";\n\nconst AVATAR_SIZES = [16, 24, 32, 40, 48, 64, 88, 148] as const;\ntype AvatarSizeToken = (typeof AVATAR_SIZES)[number];\n\n/** Snap an arbitrary pixel size to the nearest supported {@link Avatar} size token. */\nconst getNearestAvatarSize = (size: number): AvatarSizeToken =>\n AVATAR_SIZES.reduce((prev, curr) =>\n Math.abs(curr - size) < Math.abs(prev - size) ? curr : prev,\n );\n\n/** Minimal user shape consumed by {@link UserItem}. */\nexport type UserItemUser = {\n avatarUri?: { url: string; url2x?: string };\n displayName: string;\n handle: string;\n nickname?: string;\n};\n\nexport interface UserItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The user to display. */\n user: UserItemUser;\n /** Desired avatar size in px; snapped to the nearest supported token. @default 48 */\n avatarSize?: number;\n /** Show the muted indicator in the bottom-left corner. @default false */\n isMuted?: boolean;\n /** Whether the user is online (only shown when `showOnlineStatus` is also set). @default false */\n isOnline?: boolean;\n /** Render the avatar. @default true */\n showAvatar?: boolean;\n /** Render the handle line under the display name. @default true */\n showHandle?: boolean;\n /** Enable the avatar online indicator (combined with `isOnline`). */\n showOnlineStatus?: boolean;\n /** Render an AI-disclosure badge after the display name. @default false */\n aiDisclosure?: boolean;\n /** Accessible label for the AI-disclosure badge. @default \"AI creator\" */\n aiDisclosureLabel?: string;\n /** Render a verified badge after the display name. @default false */\n verified?: boolean;\n /** Accessible label for the verified badge. @default \"Verified\" */\n verifiedLabel?: string;\n /**\n * Content pinned to the end of the row — a value, count, timestamp or action.\n * It keeps its intrinsic width while the name block absorbs the remaining\n * space, so trailing content stays aligned down the rows of a list.\n *\n * Prefer {@link UserItemTrailing} over composing the lines yourself.\n */\n trailing?: React.ReactNode;\n /**\n * Replace the display-name line with arbitrary content, for rows that read as\n * a sentence about the user rather than their name — an activity feed entry,\n * for instance. Badges do not apply to custom content.\n */\n primary?: React.ReactNode;\n /**\n * A supporting line under the name, mirroring {@link UserItemTrailing}'s `meta`.\n * Both are block lines on the same 18px advance, so a row using `secondary` on\n * the left and `meta` on the right reads as two aligned tiers. Prefer it over\n * letting a long primary wrap, which mixes line heights and drifts out of step.\n */\n secondary?: React.ReactNode;\n}\n\n/**\n * A compact user row showing an avatar, display name (or nickname) and handle,\n * with optional verified and AI-disclosure badges and online and muted indicators.\n *\n * Pass {@link UserItemProps.trailing} to pin a value to the end of the row, the\n * shape most list rows need — top spenders, most active fans, a recent-activity\n * feed.\n *\n * @example\n * ```tsx\n * <UserItem user={{ displayName: \"Jane Doe\", handle: \"jane_doe\" }} />\n * ```\n *\n * @example A list row with a trailing value\n * ```tsx\n * <UserItem\n * user={user}\n * avatarSize={32}\n * showHandle={false}\n * trailing={<span className=\"typography-body-small-14px-semibold\">$14,523.59</span>}\n * />\n * ```\n */\nexport const UserItem = React.forwardRef<HTMLDivElement, UserItemProps>(\n (\n {\n user,\n avatarSize,\n isOnline = false,\n isMuted = false,\n showOnlineStatus,\n showHandle = true,\n showAvatar = true,\n aiDisclosure = false,\n aiDisclosureLabel,\n verified = false,\n verifiedLabel,\n trailing,\n primary,\n secondary,\n className,\n ...props\n },\n ref,\n ) => {\n return (\n <div\n ref={ref}\n className={cn(\"relative flex w-full items-center justify-start px-2 py-1\"
|
|
1
|
+
{"version":3,"file":"UserItem.cjs","sources":["../../../../src/components/UserItem/UserItem.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { getInitials } from \"../../utils/getInitials\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { BellOffIcon } from \"../Icons/BellOffIcon\";\nimport { UserDisplayName } from \"../UserDisplayName/UserDisplayName\";\nimport { UserHandle } from \"../UserHandle/UserHandle\";\n\nconst AVATAR_SIZES = [16, 24, 32, 40, 48, 64, 88, 148] as const;\ntype AvatarSizeToken = (typeof AVATAR_SIZES)[number];\n\n/** Snap an arbitrary pixel size to the nearest supported {@link Avatar} size token. */\nconst getNearestAvatarSize = (size: number): AvatarSizeToken =>\n AVATAR_SIZES.reduce((prev, curr) =>\n Math.abs(curr - size) < Math.abs(prev - size) ? curr : prev,\n );\n\n/** Minimal user shape consumed by {@link UserItem}. */\nexport type UserItemUser = {\n avatarUri?: { url: string; url2x?: string };\n displayName: string;\n handle: string;\n nickname?: string;\n};\n\n/**\n * Padding of the row. `\"md\"` insets it by 8px left and right and 4px top and bottom;\n * `\"none\"` removes the inset so the row aligns with its container's content edge.\n */\nexport type UserItemPadding = \"none\" | \"md\";\n\nexport interface UserItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The user to display. */\n user: UserItemUser;\n /** Padding of the row. @default \"md\" */\n padding?: UserItemPadding;\n /** Desired avatar size in px; snapped to the nearest supported token. @default 48 */\n avatarSize?: number;\n /** Show the muted indicator in the bottom-left corner. @default false */\n isMuted?: boolean;\n /** Whether the user is online (only shown when `showOnlineStatus` is also set). @default false */\n isOnline?: boolean;\n /** Render the avatar. @default true */\n showAvatar?: boolean;\n /** Render the handle line under the display name. @default true */\n showHandle?: boolean;\n /** Enable the avatar online indicator (combined with `isOnline`). */\n showOnlineStatus?: boolean;\n /** Render an AI-disclosure badge after the display name. @default false */\n aiDisclosure?: boolean;\n /** Accessible label for the AI-disclosure badge. @default \"AI creator\" */\n aiDisclosureLabel?: string;\n /** Render a verified badge after the display name. @default false */\n verified?: boolean;\n /** Accessible label for the verified badge. @default \"Verified\" */\n verifiedLabel?: string;\n /**\n * Content pinned to the end of the row — a value, count, timestamp or action.\n * It keeps its intrinsic width while the name block absorbs the remaining\n * space, so trailing content stays aligned down the rows of a list.\n *\n * Prefer {@link UserItemTrailing} over composing the lines yourself.\n */\n trailing?: React.ReactNode;\n /**\n * Replace the display-name line with arbitrary content, for rows that read as\n * a sentence about the user rather than their name — an activity feed entry,\n * for instance. Badges do not apply to custom content.\n */\n primary?: React.ReactNode;\n /**\n * A supporting line under the name, mirroring {@link UserItemTrailing}'s `meta`.\n * Both are block lines on the same 18px advance, so a row using `secondary` on\n * the left and `meta` on the right reads as two aligned tiers. Prefer it over\n * letting a long primary wrap, which mixes line heights and drifts out of step.\n */\n secondary?: React.ReactNode;\n}\n\n/**\n * A compact user row showing an avatar, display name (or nickname) and handle,\n * with optional verified and AI-disclosure badges and online and muted indicators.\n *\n * Pass {@link UserItemProps.trailing} to pin a value to the end of the row, the\n * shape most list rows need — top spenders, most active fans, a recent-activity\n * feed.\n *\n * @example\n * ```tsx\n * <UserItem user={{ displayName: \"Jane Doe\", handle: \"jane_doe\" }} />\n * ```\n *\n * @example A list row with a trailing value\n * ```tsx\n * <UserItem\n * user={user}\n * avatarSize={32}\n * showHandle={false}\n * trailing={<span className=\"typography-body-small-14px-semibold\">$14,523.59</span>}\n * />\n * ```\n */\nexport const UserItem = React.forwardRef<HTMLDivElement, UserItemProps>(\n (\n {\n user,\n padding = \"md\",\n avatarSize,\n isOnline = false,\n isMuted = false,\n showOnlineStatus,\n showHandle = true,\n showAvatar = true,\n aiDisclosure = false,\n aiDisclosureLabel,\n verified = false,\n verifiedLabel,\n trailing,\n primary,\n secondary,\n className,\n ...props\n },\n ref,\n ) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"relative flex w-full items-center justify-start\",\n padding === \"md\" && \"px-2 py-1\",\n className,\n )}\n {...props}\n >\n {isMuted && (\n <div className=\"absolute bottom-0 left-0 z-1 flex rounded-xs bg-surface-primary p-1\">\n <BellOffIcon size={16} />\n </div>\n )}\n {showAvatar && (\n <Avatar\n size={getNearestAvatarSize(avatarSize || 48)}\n src={user.avatarUri?.url}\n alt={user.displayName}\n fallback={getInitials(user.displayName)}\n onlineIndicator={Boolean(showOnlineStatus && isOnline)}\n />\n )}\n <div className=\"flex-1 overflow-hidden pl-2\">\n {primary ?? (\n <UserDisplayName\n aiDisclosure={aiDisclosure}\n aiDisclosureLabel={aiDisclosureLabel}\n verified={verified}\n verifiedLabel={verifiedLabel}\n className=\"typography-body-small-14px-semibold\"\n >\n {user.nickname || user.displayName}\n </UserDisplayName>\n )}\n {secondary && (\n <p className=\"typography-description-12px-regular truncate text-content-secondary\">\n {secondary}\n </p>\n )}\n {showHandle && <UserHandle>{user.handle}</UserHandle>}\n </div>\n {trailing && <div className=\"shrink-0 pl-2\">{trailing}</div>}\n </div>\n );\n },\n);\n\nUserItem.displayName = \"UserItem\";\n"],"names":["React","jsxs","cn","jsx","BellOffIcon","Avatar","getInitials","UserDisplayName","UserHandle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,eAAe,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAIrD,MAAM,uBAAuB,CAAC,SAC5B,aAAa;AAAA,EAAO,CAAC,MAAM,SACzB,KAAK,IAAI,OAAO,IAAI,IAAI,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO;AACzD;AAuFK,MAAM,WAAWA,iBAAM;AAAA,EAC5B,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA,aAAa;AAAA,IACb,aAAa;AAAA,IACb,eAA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package/dist/cjs/index.cjs
CHANGED
|
@@ -227,6 +227,7 @@ const Link = require("./components/Link/Link.cjs");
|
|
|
227
227
|
const LiveStatus = require("./components/LiveStatus/LiveStatus.cjs");
|
|
228
228
|
const Loader = require("./components/Loader/Loader.cjs");
|
|
229
229
|
const Logo = require("./components/Logo/Logo.cjs");
|
|
230
|
+
const MediaPlayChip = require("./components/MediaPlayChip/MediaPlayChip.cjs");
|
|
230
231
|
const MediaStatusIndicator = require("./components/MediaStatusIndicator/MediaStatusIndicator.cjs");
|
|
231
232
|
const MobileStepper = require("./components/MobileStepper/MobileStepper.cjs");
|
|
232
233
|
const OnlineBlinkingIcon = require("./components/OnlineBlinkingIcon/OnlineBlinkingIcon.cjs");
|
|
@@ -263,6 +264,7 @@ const TablePagination = require("./components/Table/TablePagination.cjs");
|
|
|
263
264
|
const Tabs = require("./components/Tabs/Tabs.cjs");
|
|
264
265
|
const TabsContent = require("./components/Tabs/TabsContent.cjs");
|
|
265
266
|
const TabsList = require("./components/Tabs/TabsList.cjs");
|
|
267
|
+
const TabsListSkeleton = require("./components/Tabs/TabsListSkeleton.cjs");
|
|
266
268
|
const TabsOverflow = require("./components/Tabs/TabsOverflow.cjs");
|
|
267
269
|
const TabsTrigger = require("./components/Tabs/TabsTrigger.cjs");
|
|
268
270
|
const TextArea = require("./components/TextArea/TextArea.cjs");
|
|
@@ -271,6 +273,7 @@ const Toast = require("./components/Toast/Toast.cjs");
|
|
|
271
273
|
const Tooltip = require("./components/Tooltip/Tooltip.cjs");
|
|
272
274
|
const TooltipLabel = require("./components/Tooltip/TooltipLabel.cjs");
|
|
273
275
|
const TrendPill = require("./components/TrendPill/TrendPill.cjs");
|
|
276
|
+
const UndoAlertPrompt = require("./components/UndoAlertPrompt/UndoAlertPrompt.cjs");
|
|
274
277
|
const UserDisplayName = require("./components/UserDisplayName/UserDisplayName.cjs");
|
|
275
278
|
const UserHandle = require("./components/UserHandle/UserHandle.cjs");
|
|
276
279
|
const UserItem = require("./components/UserItem/UserItem.cjs");
|
|
@@ -554,6 +557,8 @@ exports.Link = Link.Link;
|
|
|
554
557
|
exports.LiveStatus = LiveStatus.LiveStatus;
|
|
555
558
|
exports.Loader = Loader.Loader;
|
|
556
559
|
exports.Logo = Logo.Logo;
|
|
560
|
+
exports.MediaPlayChip = MediaPlayChip.MediaPlayChip;
|
|
561
|
+
exports.formatPlayChipDuration = MediaPlayChip.formatPlayChipDuration;
|
|
557
562
|
exports.MediaStatusIndicator = MediaStatusIndicator.MediaStatusIndicator;
|
|
558
563
|
exports.MobileStepper = MobileStepper.MobileStepper;
|
|
559
564
|
exports.OnlineBlinkingIcon = OnlineBlinkingIcon.OnlineBlinkingIcon;
|
|
@@ -619,6 +624,7 @@ exports.TableCardPagination = TablePagination.TableCardPagination;
|
|
|
619
624
|
exports.Tabs = Tabs.Tabs;
|
|
620
625
|
exports.TabsContent = TabsContent.TabsContent;
|
|
621
626
|
exports.TabsList = TabsList.TabsList;
|
|
627
|
+
exports.TabsListSkeleton = TabsListSkeleton.TabsListSkeleton;
|
|
622
628
|
exports.TabsOverflow = TabsOverflow.TabsOverflow;
|
|
623
629
|
exports.TabsOverflowItem = TabsOverflow.TabsOverflowItem;
|
|
624
630
|
exports.TabsTrigger = TabsTrigger.TabsTrigger;
|
|
@@ -633,6 +639,7 @@ exports.TooltipProvider = Tooltip.TooltipProvider;
|
|
|
633
639
|
exports.TooltipTrigger = Tooltip.TooltipTrigger;
|
|
634
640
|
exports.TooltipLabel = TooltipLabel.TooltipLabel;
|
|
635
641
|
exports.TrendPill = TrendPill.TrendPill;
|
|
642
|
+
exports.UndoAlertPrompt = UndoAlertPrompt.UndoAlertPrompt;
|
|
636
643
|
exports.UserDisplayName = UserDisplayName.UserDisplayName;
|
|
637
644
|
exports.UserHandle = UserHandle.UserHandle;
|
|
638
645
|
exports.UserItem = UserItem.UserItem;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -136,9 +136,13 @@ const RollingNumber = React.forwardRef(
|
|
|
136
136
|
)
|
|
137
137
|
},
|
|
138
138
|
`digit-${index}`
|
|
139
|
-
) : (
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
) : /* @__PURE__ */ jsx(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
style: { height: "1em", lineHeight: "1em" },
|
|
143
|
+
children: char
|
|
144
|
+
},
|
|
145
|
+
`separator-${index}`
|
|
142
146
|
)
|
|
143
147
|
) })
|
|
144
148
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedNumber.mjs","sources":["../../../src/components/AnimatedNumber/AnimatedNumber.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { usePrefersReducedMotion } from \"@/utils/usePrefersReducedMotion\";\n\n/** How a value change is animated. */\nexport type AnimatedNumberVariant =\n /**\n * Per-digit odometer: each digit column slides to its new value and the box\n * width eases when the digit count changes. Reads as mechanical, so it suits\n * a single headline figure rather than a grid of them.\n */\n | \"roll\"\n /**\n * Interpolates the value and re-formats it each frame, so the whole number\n * counts from old to new. Calmer than `roll` when several figures on a page\n * change at once.\n */\n | \"count\";\n\n/** Props for {@link AnimatedNumber}. */\nexport interface AnimatedNumberProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The value to display. Animates whenever this changes. */\n value: number;\n /**\n * Turns the value into the displayed string. Receives interpolated values in\n * the `count` variant, so it must handle non-integers.\n * @default String(Math.round(value))\n */\n format?: (value: number) => string;\n /** Which animation to run. @default \"count\" */\n variant?: AnimatedNumberVariant;\n /** Animation duration in milliseconds. @default 500 */\n durationMs?: number;\n}\n\nconst DEFAULT_DURATION_MS = 500;\n\nconst defaultFormat = (value: number) => String(Math.round(value));\n\n/** Decelerating ease, so the value settles rather than stopping abruptly. */\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst DIGITS = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\n\n/**\n * Animates a number when its value changes, either by rolling each digit like\n * an odometer or by counting through the intermediate values.\n *\n * Both variants collapse to an instant swap under\n * `prefers-reduced-motion: reduce`.\n *\n * The rolling variant stacks all ten digits in each column, so the visual is\n * hidden from assistive technology and the formatted value is exposed once as\n * text instead.\n *\n * @example\n * ```tsx\n * // Headline figure\n * <AnimatedNumber value={totalGross} format={formatPrice} variant=\"roll\" />\n *\n * // Supporting figure\n * <AnimatedNumber value={activeFans} variant=\"count\" />\n * ```\n */\nexport const AnimatedNumber = React.forwardRef<HTMLSpanElement, AnimatedNumberProps>(\n (\n {\n value,\n format = defaultFormat,\n variant = \"count\",\n durationMs = DEFAULT_DURATION_MS,\n className,\n ...props\n },\n ref,\n ) => {\n const reducedMotion = usePrefersReducedMotion();\n\n if (variant === \"roll\") {\n return (\n <RollingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n }\n\n return (\n <CountingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n },\n);\n\nAnimatedNumber.displayName = \"AnimatedNumber\";\n\ntype VariantProps = Omit<AnimatedNumberProps, \"variant\" | \"format\" | \"durationMs\"> & {\n format: (value: number) => string;\n durationMs: number;\n};\n\nconst CountingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const [displayValue, setDisplayValue] = React.useState(value);\n // Tracks what is on screen, so an interrupted tween resumes from there. Storing\n // the abandoned *target* instead would start the next tween from a number that\n // was never displayed, which shows as a jump to the old target before counting\n // on — a refetch or filter change landing mid-animation is enough to hit it.\n const displayRef = React.useRef(value);\n\n React.useEffect(() => {\n const from = displayRef.current;\n if (from === value || durationMs === 0) {\n displayRef.current = value;\n setDisplayValue(value);\n return;\n }\n\n let frame = 0;\n let start: number | undefined;\n\n const step = (now: number) => {\n start ??= now;\n const progress = Math.min((now - start) / durationMs, 1);\n const next = from + (value - from) * easeOutCubic(progress);\n displayRef.current = next;\n setDisplayValue(next);\n if (progress < 1) {\n frame = requestAnimationFrame(step);\n }\n };\n\n frame = requestAnimationFrame(step);\n return () => cancelAnimationFrame(frame);\n }, [value, durationMs]);\n\n return (\n <span ref={ref} className={cn(\"tabular-nums\", className)} {...props}>\n {format(displayValue)}\n </span>\n );\n },\n);\n\nCountingNumber.displayName = \"AnimatedNumber.Counting\";\n\nconst RollingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const display = format(value);\n const characters = React.useMemo(() => Array.from(display), [display]);\n\n // Lock the box to its measured width so a change in digit count eases\n // instead of snapping: `width: auto` cannot be transitioned.\n const contentRef = React.useRef<HTMLSpanElement>(null);\n const [boxWidth, setBoxWidth] = React.useState<number>();\n\n // On the render where the width is still `auto` there is nothing to\n // transition from, so the duration is zeroed. This is belt-and-braces rather\n // than load-bearing: `auto` to a length is not interpolatable, so no\n // transition would run either way.\n const hasMeasured = boxWidth !== undefined;\n\n // Re-measure rather than measuring once per `display`: the box is\n // `overflow-hidden`, so a web font landing after the first measurement leaves\n // the locked width too narrow for the wider glyphs and clips the number until\n // the value next changes, which for a headline figure may be never. Observing\n // covers a container change too. Same approach as `useCyclingTextTrackWidth`.\n React.useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node || !display) {\n return;\n }\n\n const measure = () => {\n const measured = node.scrollWidth;\n if (measured) {\n setBoxWidth(measured);\n }\n };\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [display]);\n\n return (\n <span\n ref={ref}\n className={cn(\"inline-flex overflow-hidden tabular-nums\", className)}\n style={{\n width: boxWidth,\n transitionProperty: \"width\",\n transitionDuration: hasMeasured ? `${durationMs}ms` : \"0ms\",\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n {...props}\n >\n {/* The digit columns list 0-9 apiece, which assistive tech would read\n out in full, so expose the formatted value as text instead. */}\n <span className=\"sr-only\">{display}</span>\n <span ref={contentRef} aria-hidden className=\"inline-flex whitespace-pre\">\n {characters.map((char, index) =>\n isDigit(char) ? (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: a column is a position in the number, so it must keep its identity (and animate) when its digit changes\n key={`digit-${index}`}\n className=\"relative inline-block overflow-hidden\"\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n <span\n className=\"flex flex-col\"\n style={{\n transform: `translateY(-${Number(char) * 10}%)`,\n transitionProperty: \"transform\",\n transitionDuration: `${durationMs}ms`,\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n >\n {DIGITS.map((digit) => (\n <span key={digit} style={{ height: \"1em\", lineHeight: \"1em\" }}>\n {digit}\n </span>\n ))}\n </span>\n </span>\n ) : (\n // biome-ignore lint/suspicious/noArrayIndexKey: same positional identity as the digit columns\n <span key={`separator-${index}`}>{char}</span>\n ),\n )}\n </span>\n </span>\n );\n },\n);\n\nRollingNumber.displayName = \"AnimatedNumber.Rolling\";\n"],"names":[],"mappings":";;;;;AAoCA,MAAM,sBAAsB;AAE5B,MAAM,gBAAgB,CAAC,UAAkB,OAAO,KAAK,MAAM,KAAK,CAAC;AAGjE,MAAM,eAAe,CAAC,MAAc,KAAK,IAAI,MAAM;AAEnD,MAAM,SAAS,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAEhE,MAAM,UAAU,CAAC,SAAiB,QAAQ,OAAO,QAAQ;AAsBlD,MAAM,iBAAiB,MAAM;AAAA,EAClC,CACE;AAAA,IACE;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,aAAa;AAAA,IACb;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,gBAAgB,wBAAA;AAEtB,QAAI,YAAY,QAAQ;AACtB,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA,YAAY,gBAAgB,IAAI;AAAA,UAChC;AAAA,UACC,GAAG;AAAA,QAAA;AAAA,MAAA;AAAA,IAGV;AAEA,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY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AA,oBAAA;AAAA,oBAG3B,UAAA,OAAO,IAAI,CAAC,8BACV,QAAA,EAAiB,OAAO,EAAE,QAAQ,OAAO,YAAY,MAAA,GACnD,UAAA,MAAA,GADQ,KAEX,CACD;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,cAlBK,SAAS,KAAK;AAAA,YAAA;AAAA;AAAA,cAsBrB,oBAAC,QAAA,EAAiC,UAAA,KAAA,GAAvB,aAAa,KAAK,EAAU;AAAA;AAAA,UAAA,EAE3C,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,cAAc,cAAc;"}
|
|
1
|
+
{"version":3,"file":"AnimatedNumber.mjs","sources":["../../../src/components/AnimatedNumber/AnimatedNumber.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { usePrefersReducedMotion } from \"@/utils/usePrefersReducedMotion\";\n\n/** How a value change is animated. */\nexport type AnimatedNumberVariant =\n /**\n * Per-digit odometer: each digit column slides to its new value and the box\n * width eases when the digit count changes. Reads as mechanical, so it suits\n * a single headline figure rather than a grid of them.\n */\n | \"roll\"\n /**\n * Interpolates the value and re-formats it each frame, so the whole number\n * counts from old to new. Calmer than `roll` when several figures on a page\n * change at once.\n */\n | \"count\";\n\n/** Props for {@link AnimatedNumber}. */\nexport interface AnimatedNumberProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** The value to display. Animates whenever this changes. */\n value: number;\n /**\n * Turns the value into the displayed string. Receives interpolated values in\n * the `count` variant, so it must handle non-integers.\n * @default String(Math.round(value))\n */\n format?: (value: number) => string;\n /** Which animation to run. @default \"count\" */\n variant?: AnimatedNumberVariant;\n /** Animation duration in milliseconds. @default 500 */\n durationMs?: number;\n}\n\nconst DEFAULT_DURATION_MS = 500;\n\nconst defaultFormat = (value: number) => String(Math.round(value));\n\n/** Decelerating ease, so the value settles rather than stopping abruptly. */\nconst easeOutCubic = (t: number) => 1 - (1 - t) ** 3;\n\nconst DIGITS = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"];\n\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\n\n/**\n * Animates a number when its value changes, either by rolling each digit like\n * an odometer or by counting through the intermediate values.\n *\n * Both variants collapse to an instant swap under\n * `prefers-reduced-motion: reduce`.\n *\n * The rolling variant stacks all ten digits in each column, so the visual is\n * hidden from assistive technology and the formatted value is exposed once as\n * text instead.\n *\n * @example\n * ```tsx\n * // Headline figure\n * <AnimatedNumber value={totalGross} format={formatPrice} variant=\"roll\" />\n *\n * // Supporting figure\n * <AnimatedNumber value={activeFans} variant=\"count\" />\n * ```\n */\nexport const AnimatedNumber = React.forwardRef<HTMLSpanElement, AnimatedNumberProps>(\n (\n {\n value,\n format = defaultFormat,\n variant = \"count\",\n durationMs = DEFAULT_DURATION_MS,\n className,\n ...props\n },\n ref,\n ) => {\n const reducedMotion = usePrefersReducedMotion();\n\n if (variant === \"roll\") {\n return (\n <RollingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n }\n\n return (\n <CountingNumber\n ref={ref}\n value={value}\n format={format}\n durationMs={reducedMotion ? 0 : durationMs}\n className={className}\n {...props}\n />\n );\n },\n);\n\nAnimatedNumber.displayName = \"AnimatedNumber\";\n\ntype VariantProps = Omit<AnimatedNumberProps, \"variant\" | \"format\" | \"durationMs\"> & {\n format: (value: number) => string;\n durationMs: number;\n};\n\nconst CountingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const [displayValue, setDisplayValue] = React.useState(value);\n // Tracks what is on screen, so an interrupted tween resumes from there. Storing\n // the abandoned *target* instead would start the next tween from a number that\n // was never displayed, which shows as a jump to the old target before counting\n // on — a refetch or filter change landing mid-animation is enough to hit it.\n const displayRef = React.useRef(value);\n\n React.useEffect(() => {\n const from = displayRef.current;\n if (from === value || durationMs === 0) {\n displayRef.current = value;\n setDisplayValue(value);\n return;\n }\n\n let frame = 0;\n let start: number | undefined;\n\n const step = (now: number) => {\n start ??= now;\n const progress = Math.min((now - start) / durationMs, 1);\n const next = from + (value - from) * easeOutCubic(progress);\n displayRef.current = next;\n setDisplayValue(next);\n if (progress < 1) {\n frame = requestAnimationFrame(step);\n }\n };\n\n frame = requestAnimationFrame(step);\n return () => cancelAnimationFrame(frame);\n }, [value, durationMs]);\n\n return (\n <span ref={ref} className={cn(\"tabular-nums\", className)} {...props}>\n {format(displayValue)}\n </span>\n );\n },\n);\n\nCountingNumber.displayName = \"AnimatedNumber.Counting\";\n\nconst RollingNumber = React.forwardRef<HTMLSpanElement, VariantProps>(\n ({ value, format, durationMs, className, ...props }, ref) => {\n const display = format(value);\n const characters = React.useMemo(() => Array.from(display), [display]);\n\n // Lock the box to its measured width so a change in digit count eases\n // instead of snapping: `width: auto` cannot be transitioned.\n const contentRef = React.useRef<HTMLSpanElement>(null);\n const [boxWidth, setBoxWidth] = React.useState<number>();\n\n // On the render where the width is still `auto` there is nothing to\n // transition from, so the duration is zeroed. This is belt-and-braces rather\n // than load-bearing: `auto` to a length is not interpolatable, so no\n // transition would run either way.\n const hasMeasured = boxWidth !== undefined;\n\n // Re-measure rather than measuring once per `display`: the box is\n // `overflow-hidden`, so a web font landing after the first measurement leaves\n // the locked width too narrow for the wider glyphs and clips the number until\n // the value next changes, which for a headline figure may be never. Observing\n // covers a container change too. Same approach as `useCyclingTextTrackWidth`.\n React.useLayoutEffect(() => {\n const node = contentRef.current;\n if (!node || !display) {\n return;\n }\n\n const measure = () => {\n const measured = node.scrollWidth;\n if (measured) {\n setBoxWidth(measured);\n }\n };\n\n measure();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [display]);\n\n return (\n <span\n ref={ref}\n className={cn(\"inline-flex overflow-hidden tabular-nums\", className)}\n style={{\n width: boxWidth,\n transitionProperty: \"width\",\n transitionDuration: hasMeasured ? `${durationMs}ms` : \"0ms\",\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n {...props}\n >\n {/* The digit columns list 0-9 apiece, which assistive tech would read\n out in full, so expose the formatted value as text instead. */}\n <span className=\"sr-only\">{display}</span>\n <span ref={contentRef} aria-hidden className=\"inline-flex whitespace-pre\">\n {characters.map((char, index) =>\n isDigit(char) ? (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: a column is a position in the number, so it must keep its identity (and animate) when its digit changes\n key={`digit-${index}`}\n className=\"relative inline-block overflow-hidden\"\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n <span\n className=\"flex flex-col\"\n style={{\n transform: `translateY(-${Number(char) * 10}%)`,\n transitionProperty: \"transform\",\n transitionDuration: `${durationMs}ms`,\n transitionTimingFunction: \"cubic-bezier(0.22, 1, 0.36, 1)\",\n }}\n >\n {DIGITS.map((digit) => (\n <span key={digit} style={{ height: \"1em\", lineHeight: \"1em\" }}>\n {digit}\n </span>\n ))}\n </span>\n </span>\n ) : (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: same positional identity as the digit columns\n key={`separator-${index}`}\n style={{ height: \"1em\", lineHeight: \"1em\" }}\n >\n {char}\n </span>\n ),\n )}\n </span>\n </span>\n );\n },\n);\n\nRollingNumber.displayName = \"AnimatedNumber.Rolling\";\n"],"names":[],"mappings":";;;;;AAoCA,MAAM,sBAAsB;AAE5B,MAAM,gBAAgB,CAAC,UAAkB,OAAO,KAAK,MAAM,KAAK,CAAC;AAGjE,MAAM,eAAe,CAAC,MAAc,KAAK,IAAI,MAAM;AAEnD,MAAM,SAAS,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAEhE,MAAM,UAAU,CAAC,SAAiB,QAAQ,OAAO,QAAQ;AAsBlD,MAAM,iBAAiB,MAAM;AAAA,EAClC,CACE;A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,UAAK,KAAK,YAAY,eAAW,MAAC,WAAU,8BAC1C,UAAA,WAAW;AAAA,YAAI,CAAC,MAAM,UACrB,QAAQ,IAAI,IACV;AAAA,cAAC;AAAA,cAAA;AAAA,gBAGC,WAAU;AAAA,gBACV,OAAO,EAAE,QAAQ,OAAO,YAAY,MAAA;AAAA,gBAEpC,UAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,OAAO;AAAA,sBACL,WAAW,eAAe,OAAO,IAAI,IAAI,EAAE;AAAA,sBAC3C,oBAAoB;AAAA,sBACpB,oBAAoB,GAAG,UAAU;AAAA,sBACjC,0BAA0B;AAAA,oBAAA;AAAA,oBAG3B,UAAA,OAAO,IAAI,CAAC,8BACV,QAAA,EAAiB,OAAO,EAAE,QAAQ,OAAO,YAAY,MAAA,GACnD,UAAA,MAAA,GADQ,KAEX,CACD;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,cAlBK,SAAS,KAAK;AAAA,YAAA,IAqBrB;AAAA,cAAC;AAAA,cAAA;AAAA,gBAGC,OAAO,EAAE,QAAQ,OAAO,YAAY,MAAA;AAAA,gBAEnC,UAAA;AAAA,cAAA;AAAA,cAHI,aAAa,KAAK;AAAA,YAAA;AAAA,UAIzB,EAEJ,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,cAAc,cAAc;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CartesianGrid, ReferenceLine } from "recharts";
|
|
4
|
+
function ChartGrid(props) {
|
|
5
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6
|
+
/* @__PURE__ */ jsx(
|
|
7
|
+
CartesianGrid,
|
|
8
|
+
{
|
|
9
|
+
vertical: false,
|
|
10
|
+
...props,
|
|
11
|
+
stroke: "var(--color-neutral-alphas-200)",
|
|
12
|
+
strokeDasharray: "2 4"
|
|
13
|
+
}
|
|
14
|
+
),
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
ReferenceLine,
|
|
17
|
+
{
|
|
18
|
+
y: 0,
|
|
19
|
+
xAxisId: props.xAxisId,
|
|
20
|
+
yAxisId: props.yAxisId,
|
|
21
|
+
stroke: "var(--color-border-strong)",
|
|
22
|
+
ifOverflow: "extendDomain"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
ChartGrid.displayName = "ChartGrid";
|
|
28
|
+
export {
|
|
29
|
+
ChartGrid
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=ChartGrid.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartGrid.mjs","sources":["../../../src/components/Chart/ChartGrid.tsx"],"sourcesContent":["import type * as React from \"react\";\nimport { CartesianGrid, ReferenceLine } from \"recharts\";\n\n/**\n * Props for {@link ChartGrid}. Forwarded to Recharts' `CartesianGrid`; `xAxisId` and\n * `yAxisId` also place the zero baseline. The line colour and dash are fixed by the\n * design system, so `stroke` and `strokeDasharray` are not accepted.\n */\nexport type ChartGridProps = Omit<\n React.ComponentProps<typeof CartesianGrid>,\n \"stroke\" | \"strokeDasharray\"\n>;\n\n/**\n * The design-system grid for cartesian charts: dotted horizontal lines and one solid\n * baseline at value 0, above and below which every other line stays dotted. Render\n * it as a direct child of a Recharts `<LineChart>`, `<AreaChart>` or `<BarChart>`.\n *\n * Grid lines use `neutral-alphas-200`, the colour `ChartContainer` gives Recharts'\n * default grid. The baseline uses `border-strong`.\n *\n * The baseline extends the y-axis domain to include zero, so it stays visible when\n * every value is negative. Leave `<YAxis domain>` at its default: the axis then starts\n * at zero, or at the lowest value when the data goes below zero.\n *\n * @example\n * ```tsx\n * <ChartContainer config={chartConfig}>\n * <LineChart data={data}>\n * <ChartGrid />\n * <XAxis dataKey=\"day\" />\n * <YAxis />\n * <Line dataKey=\"net\" stroke=\"var(--color-net)\" />\n * </LineChart>\n * </ChartContainer>\n * ```\n */\nexport function ChartGrid(props: ChartGridProps) {\n return (\n <>\n <CartesianGrid\n vertical={false}\n {...props}\n stroke=\"var(--color-neutral-alphas-200)\"\n strokeDasharray=\"2 4\"\n />\n <ReferenceLine\n y={0}\n xAxisId={props.xAxisId}\n yAxisId={props.yAxisId}\n stroke=\"var(--color-border-strong)\"\n ifOverflow=\"extendDomain\"\n />\n </>\n );\n}\n\nChartGrid.displayName = \"ChartGrid\";\n"],"names":[],"mappings":";;;AAqCO,SAAS,UAAU,OAAuB;AAC/C,SACE,qBAAA,UAAA,EACE,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,QAAO;AAAA,QACP,iBAAgB;AAAA,MAAA;AAAA,IAAA;AAAA,IAElB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,QACf,SAAS,MAAM;AAAA,QACf,QAAO;AAAA,QACP,YAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EACb,GACF;AAEJ;AAEA,UAAU,cAAc;"}
|
|
@@ -8,6 +8,7 @@ import { AddIcon } from "../Icons/AddIcon.mjs";
|
|
|
8
8
|
import { ArrowUpIcon } from "../Icons/ArrowUpIcon.mjs";
|
|
9
9
|
import { ChevronDownIcon } from "../Icons/ChevronDownIcon.mjs";
|
|
10
10
|
import { CloseIcon } from "../Icons/CloseIcon.mjs";
|
|
11
|
+
import { MenuRowIcon } from "../Icons/MenuRowIcon.mjs";
|
|
11
12
|
import { TickIcon } from "../Icons/TickIcon.mjs";
|
|
12
13
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from "../DropdownMenu/DropdownMenuRoot.mjs";
|
|
13
14
|
import { DropdownMenuItem } from "../DropdownMenu/DropdownMenuItem.mjs";
|
|
@@ -293,8 +294,9 @@ function InlineSelect({
|
|
|
293
294
|
/* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
294
295
|
/* @__PURE__ */ jsxs(DrawerContent, { position: "bottom", variant: "sheet", children: [
|
|
295
296
|
/* @__PURE__ */ jsx(DrawerHeader, { children: /* @__PURE__ */ jsx(DrawerTitle, { className: "typography-header-heading-xs", children: menuTitle ?? "Select an option" }) }),
|
|
296
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 overflow-y-auto px-
|
|
297
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 overflow-y-auto px-2 pb-2", role: "listbox", children: options.map((option) => {
|
|
297
298
|
const isSelected = option.value === value;
|
|
299
|
+
const hasDescription = !!option.description;
|
|
298
300
|
return /* @__PURE__ */ jsxs(
|
|
299
301
|
"button",
|
|
300
302
|
{
|
|
@@ -306,21 +308,29 @@ function InlineSelect({
|
|
|
306
308
|
setOpen(false);
|
|
307
309
|
},
|
|
308
310
|
className: cn(
|
|
309
|
-
"flex w-full
|
|
311
|
+
"group flex min-h-10 w-full gap-2 rounded-sm px-3 py-2 text-left outline-none",
|
|
312
|
+
hasDescription ? "items-start" : "items-center",
|
|
310
313
|
"focus-visible:shadow-focus-ring",
|
|
311
|
-
"typography-body-
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
// the selected option from a hovered-but-unselected one.
|
|
315
|
-
isSelected && ["bg-neutral-alphas-100", "hover:bg-neutral-alphas-200"]
|
|
314
|
+
"typography-body-small-14px-regular text-content-primary hover:bg-interaction-hover",
|
|
315
|
+
// The selected option shares the hover fill, as in DropdownMenuItem.
|
|
316
|
+
isSelected && "bg-interaction-hover"
|
|
316
317
|
),
|
|
317
318
|
children: [
|
|
318
|
-
option.icon && /* @__PURE__ */ jsx(
|
|
319
|
+
option.icon && /* @__PURE__ */ jsx(MenuRowIcon, { alignToTitle: hasDescription, children: option.icon }),
|
|
319
320
|
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
320
|
-
/* @__PURE__ */ jsx(
|
|
321
|
-
|
|
321
|
+
/* @__PURE__ */ jsx(
|
|
322
|
+
"span",
|
|
323
|
+
{
|
|
324
|
+
className: cn(
|
|
325
|
+
"truncate",
|
|
326
|
+
hasDescription && "typography-body-small-14px-semibold"
|
|
327
|
+
),
|
|
328
|
+
children: option.menuLabel ?? option.label
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
hasDescription && /* @__PURE__ */ jsx("span", { className: "typography-body-small-14px-regular truncate text-content-secondary", children: option.description })
|
|
322
332
|
] }),
|
|
323
|
-
isSelected && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center
|
|
333
|
+
isSelected && /* @__PURE__ */ jsx("span", { className: cn("flex shrink-0 items-center", hasDescription && "h-4.5"), children: /* @__PURE__ */ jsx(SelectedTick, {}) })
|
|
324
334
|
]
|
|
325
335
|
},
|
|
326
336
|
option.value
|