@fanvue/ui 3.23.0 → 3.25.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 +94 -4
- package/dist/charts.mjs +4 -0
- package/dist/charts.mjs.map +1 -1
- package/dist/cjs/charts.cjs +4 -0
- package/dist/cjs/charts.cjs.map +1 -1
- package/dist/cjs/components/AiButton/AiButton.cjs +170 -0
- package/dist/cjs/components/AiButton/AiButton.cjs.map +1 -0
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs +170 -0
- package/dist/cjs/components/AnimatedNumber/AnimatedNumber.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +24 -2
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartMetricTrend.cjs +71 -0
- package/dist/cjs/components/Chart/ChartMetricTrend.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartSkeleton.cjs +95 -0
- package/dist/cjs/components/Chart/ChartSkeleton.cjs.map +1 -0
- package/dist/cjs/components/Chip/Chip.cjs +40 -11
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/CountryFlag/CountryFlag.cjs +91 -0
- package/dist/cjs/components/CountryFlag/CountryFlag.cjs.map +1 -0
- package/dist/cjs/components/CountryFlag/flagShapes.cjs +3358 -0
- package/dist/cjs/components/CountryFlag/flagShapes.cjs.map +1 -0
- package/dist/cjs/components/CyclingText/CyclingText.cjs +9 -26
- package/dist/cjs/components/CyclingText/CyclingText.cjs.map +1 -1
- package/dist/cjs/components/CyclingText/useCyclingMotion.cjs +53 -0
- package/dist/cjs/components/CyclingText/useCyclingMotion.cjs.map +1 -0
- package/dist/cjs/components/Demographics/Demographics.cjs +39 -0
- package/dist/cjs/components/Demographics/Demographics.cjs.map +1 -0
- package/dist/cjs/components/Drawer/Drawer.cjs +9 -1
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +115 -16
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +11 -1
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs +9 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs.map +1 -1
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs +14 -4
- package/dist/cjs/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsList.cjs +123 -91
- package/dist/cjs/components/Tabs/TabsList.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +36 -25
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/TooltipLabel.cjs +71 -0
- package/dist/cjs/components/Tooltip/TooltipLabel.cjs.map +1 -0
- package/dist/cjs/components/TrendPill/TrendPill.cjs +46 -0
- package/dist/cjs/components/TrendPill/TrendPill.cjs.map +1 -0
- package/dist/cjs/components/UserItem/UserItem.cjs +7 -2
- package/dist/cjs/components/UserItem/UserItem.cjs.map +1 -1
- package/dist/cjs/components/UserItem/UserItemTrailing.cjs +34 -0
- package/dist/cjs/components/UserItem/UserItemTrailing.cjs.map +1 -0
- package/dist/cjs/flags.cjs +6 -0
- package/dist/cjs/flags.cjs.map +1 -0
- package/dist/cjs/index.cjs +13 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{components/CyclingText → utils}/usePrefersReducedMotion.cjs +14 -14
- package/dist/cjs/utils/usePrefersReducedMotion.cjs.map +1 -0
- package/dist/components/AiButton/AiButton.mjs +153 -0
- package/dist/components/AiButton/AiButton.mjs.map +1 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs +153 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.mjs.map +1 -0
- package/dist/components/Chart/ChartLoadingOverlay.mjs +24 -2
- package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -1
- package/dist/components/Chart/ChartMetricTrend.mjs +54 -0
- package/dist/components/Chart/ChartMetricTrend.mjs.map +1 -0
- package/dist/components/Chart/ChartSkeleton.mjs +78 -0
- package/dist/components/Chart/ChartSkeleton.mjs.map +1 -0
- package/dist/components/Chip/Chip.mjs +40 -11
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/CountryFlag/CountryFlag.mjs +74 -0
- package/dist/components/CountryFlag/CountryFlag.mjs.map +1 -0
- package/dist/components/CountryFlag/flagShapes.mjs +3358 -0
- package/dist/components/CountryFlag/flagShapes.mjs.map +1 -0
- package/dist/components/CyclingText/CyclingText.mjs +9 -26
- package/dist/components/CyclingText/CyclingText.mjs.map +1 -1
- package/dist/components/CyclingText/useCyclingMotion.mjs +36 -0
- package/dist/components/CyclingText/useCyclingMotion.mjs.map +1 -0
- package/dist/components/Demographics/Demographics.mjs +22 -0
- package/dist/components/Demographics/Demographics.mjs.map +1 -0
- package/dist/components/Drawer/Drawer.mjs +9 -1
- package/dist/components/Drawer/Drawer.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.mjs +115 -16
- package/dist/components/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +11 -1
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.mjs +9 -1
- package/dist/components/ProgressBar/ProgressBar.mjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.mjs +15 -5
- package/dist/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/components/Tabs/TabsList.mjs +123 -91
- package/dist/components/Tabs/TabsList.mjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.mjs +37 -26
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/components/Tooltip/TooltipLabel.mjs +54 -0
- package/dist/components/Tooltip/TooltipLabel.mjs.map +1 -0
- package/dist/components/TrendPill/TrendPill.mjs +29 -0
- package/dist/components/TrendPill/TrendPill.mjs.map +1 -0
- package/dist/components/UserItem/UserItem.mjs +7 -2
- package/dist/components/UserItem/UserItem.mjs.map +1 -1
- package/dist/components/UserItem/UserItemTrailing.mjs +17 -0
- package/dist/components/UserItem/UserItemTrailing.mjs.map +1 -0
- package/dist/flags.d.ts +59 -0
- package/dist/flags.mjs +6 -0
- package/dist/flags.mjs.map +1 -0
- package/dist/index.d.ts +406 -17
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +166 -0
- package/dist/styles/theme.css +12 -0
- package/dist/utils/usePrefersReducedMotion.mjs +22 -0
- package/dist/utils/usePrefersReducedMotion.mjs.map +1 -0
- package/package.json +14 -3
- package/dist/cjs/components/CyclingText/usePrefersReducedMotion.cjs.map +0 -1
- package/dist/components/CyclingText/usePrefersReducedMotion.mjs +0 -22
- package/dist/components/CyclingText/usePrefersReducedMotion.mjs.map +0 -1
|
@@ -5,9 +5,9 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const cn = require("../../utils/cn.cjs");
|
|
7
7
|
const useCyclingCycle = require("./useCyclingCycle.cjs");
|
|
8
|
+
const useCyclingMotion = require("./useCyclingMotion.cjs");
|
|
8
9
|
const useCyclingTextTrackWidth = require("./useCyclingTextTrackWidth.cjs");
|
|
9
10
|
const usePageVisibility = require("./usePageVisibility.cjs");
|
|
10
|
-
const usePrefersReducedMotion = require("./usePrefersReducedMotion.cjs");
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
12
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
13
|
if (e) {
|
|
@@ -27,7 +27,6 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
28
28
|
const DEFAULT_INTERVAL_MS = 2100;
|
|
29
29
|
const DEFAULT_TRANSITION_MS = 200;
|
|
30
|
-
const SLIDE_OFFSET_PX = 18;
|
|
31
30
|
const CyclingText = React__namespace.forwardRef(
|
|
32
31
|
({
|
|
33
32
|
items,
|
|
@@ -43,7 +42,6 @@ const CyclingText = React__namespace.forwardRef(
|
|
|
43
42
|
...rest
|
|
44
43
|
}, ref) => {
|
|
45
44
|
const docVisible = usePageVisibility.usePageVisibility();
|
|
46
|
-
const reducedMotion = usePrefersReducedMotion.usePrefersReducedMotion();
|
|
47
45
|
const { sizingLabelRef, trackWidth } = useCyclingTextTrackWidth.useCyclingTextTrackWidth();
|
|
48
46
|
const {
|
|
49
47
|
cycle,
|
|
@@ -61,32 +59,17 @@ const CyclingText = React__namespace.forwardRef(
|
|
|
61
59
|
React__namespace.useEffect(() => {
|
|
62
60
|
onActiveIndexChangeRef.current?.(currentIndex);
|
|
63
61
|
}, [currentIndex]);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
transform: exiting ? `translate3d(0, ${yExit}px, 0)` : "translate3d(0, 0, 0)",
|
|
71
|
-
transition: exiting && durMs > 0 ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)` : "none"
|
|
72
|
-
};
|
|
73
|
-
}, [cycle.transitioning, direction, transitionMs, reducedMotion]);
|
|
74
|
-
const incomingMotionStyle = React__namespace.useMemo(() => {
|
|
75
|
-
const durMs = reducedMotion ? 0 : transitionMs;
|
|
76
|
-
const entered = cycle.incomingEntered;
|
|
77
|
-
const yEnter = direction === "up" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;
|
|
78
|
-
return {
|
|
79
|
-
opacity: entered ? 1 : 0,
|
|
80
|
-
transform: entered ? "translate3d(0, 0, 0)" : `translate3d(0, ${yEnter}px, 0)`,
|
|
81
|
-
transition: durMs > 0 ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)` : "none"
|
|
82
|
-
};
|
|
83
|
-
}, [cycle.incomingEntered, direction, transitionMs, reducedMotion]);
|
|
62
|
+
const { outgoingStyle, incomingStyle } = useCyclingMotion.useCyclingMotion({
|
|
63
|
+
transitioning: cycle.transitioning,
|
|
64
|
+
incomingEntered: cycle.incomingEntered,
|
|
65
|
+
direction,
|
|
66
|
+
transitionMs
|
|
67
|
+
});
|
|
84
68
|
if (itemCount === 0) {
|
|
85
69
|
return null;
|
|
86
70
|
}
|
|
87
71
|
const wrapperStyle = {
|
|
88
72
|
...trackWidth !== null ? { width: `${trackWidth}px` } : {}
|
|
89
|
-
// paddingTop: SLIDE_OFFSET_PX,
|
|
90
73
|
};
|
|
91
74
|
const showIncoming = incomingLabel !== null && cycle.transitioning;
|
|
92
75
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -127,7 +110,7 @@ const CyclingText = React__namespace.forwardRef(
|
|
|
127
110
|
"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]",
|
|
128
111
|
labelClassName
|
|
129
112
|
),
|
|
130
|
-
style:
|
|
113
|
+
style: outgoingStyle,
|
|
131
114
|
children: currentLabel
|
|
132
115
|
}
|
|
133
116
|
),
|
|
@@ -141,7 +124,7 @@ const CyclingText = React__namespace.forwardRef(
|
|
|
141
124
|
"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]",
|
|
142
125
|
labelClassName
|
|
143
126
|
),
|
|
144
|
-
style:
|
|
127
|
+
style: incomingStyle,
|
|
145
128
|
children: incomingLabel
|
|
146
129
|
}
|
|
147
130
|
) : null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyclingText.cjs","sources":["../../../../src/components/CyclingText/CyclingText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCyclingCycle } from \"./useCyclingCycle\";\nimport { useCyclingTextTrackWidth } from \"./useCyclingTextTrackWidth\";\nimport { usePageVisibility } from \"./usePageVisibility\";\nimport { usePrefersReducedMotion } from \"./usePrefersReducedMotion\";\n\nconst DEFAULT_INTERVAL_MS = 2100;\nconst DEFAULT_TRANSITION_MS = 200;\n\nconst SLIDE_OFFSET_PX = 18;\n\n/** How the wrapper should be sized to accommodate variable-length items. */\nexport type CyclingTextSizing = \"longest\" | \"current\";\n\nexport interface CyclingTextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** Strings to cycle through, in order. Cycles back to the first after the last. */\n items: readonly string[];\n /**\n * Milliseconds to wait after the previous transition finishes before starting the next one.\n * @default 2100\n */\n intervalMs?: number;\n /** Slide and cross-fade duration in milliseconds. @default 200 */\n transitionMs?: number;\n /** Direction the outgoing item slides. @default \"up\" */\n direction?: \"up\" | \"down\";\n /** When true, freezes on the current item — no further cycling until cleared. @default false */\n paused?: boolean;\n /**\n * How the wrapper sizes itself horizontally.\n * - `longest` reserves space for the longest item — no width jitter as items cycle.\n * - `current` shrinks/grows with each item, animating width between cycles.\n * @default \"longest\"\n */\n sizing?: CyclingTextSizing;\n /**\n * When `true`, updates are exposed to assistive technologies via `aria-live=\"polite\"`.\n * Leave `false` for decorative or frequently changing copy so screen readers are not interrupted on every cycle.\n * @default false\n */\n announceChanges?: boolean;\n /**\n * Class applied to each visible label span (current + incoming). Use this for\n * effects that have to sit on the text element itself, e.g. `background-clip: text`.\n */\n labelClassName?: string;\n /**\n * Called with the index of the settled, fully-visible item — once on mount and\n * again whenever it changes (after each transition completes). Lets a parent\n * stay in lockstep with what is on screen (e.g. to act on the item the user is\n * currently looking at) without running a second, drifting timer of its own.\n */\n onActiveIndexChange?: (index: number) => void;\n}\n\n/**\n * Cycles through a list of strings with a slide-in/slide-out animation. Lives\n * inline so it can sit inside divs, spans, buttons, or as a fake placeholder\n * overlay.\n *\n * @example\n * ```tsx\n * <CyclingText items={[\"Thinking\", \"Reading messages\", \"Drafting reply\"]} />\n * ```\n */\nexport const CyclingText = React.forwardRef<HTMLSpanElement, CyclingTextProps>(\n (\n {\n items,\n intervalMs = DEFAULT_INTERVAL_MS,\n transitionMs = DEFAULT_TRANSITION_MS,\n direction = \"up\",\n paused = false,\n sizing = \"longest\",\n className,\n labelClassName,\n announceChanges = false,\n onActiveIndexChange,\n ...rest\n },\n ref,\n ) => {\n const docVisible = usePageVisibility();\n const reducedMotion = usePrefersReducedMotion();\n const { sizingLabelRef, trackWidth } = useCyclingTextTrackWidth();\n const {\n cycle,\n currentIndex,\n currentLabel,\n incomingLabel,\n sizingLabel,\n onOutgoingTransitionEnd,\n } = useCyclingCycle(items, sizing, intervalMs, paused, docVisible, transitionMs);\n\n const itemCount = items.length;\n\n // Notify the parent of the settled active index without re-subscribing when\n // an inline callback identity changes each render — the latest is always\n // read from the ref.\n const onActiveIndexChangeRef = React.useRef(onActiveIndexChange);\n React.useEffect(() => {\n onActiveIndexChangeRef.current = onActiveIndexChange;\n }, [onActiveIndexChange]);\n React.useEffect(() => {\n onActiveIndexChangeRef.current?.(currentIndex);\n }, [currentIndex]);\n\n const outgoingMotionStyle = React.useMemo((): React.CSSProperties => {\n const durMs = reducedMotion ? 0 : transitionMs;\n const exiting = cycle.transitioning;\n const yExit = direction === \"up\" ? -SLIDE_OFFSET_PX : SLIDE_OFFSET_PX;\n return {\n opacity: exiting ? 0 : 1,\n transform: exiting ? `translate3d(0, ${yExit}px, 0)` : \"translate3d(0, 0, 0)\",\n transition:\n exiting && durMs > 0\n ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n };\n }, [cycle.transitioning, direction, transitionMs, reducedMotion]);\n\n const incomingMotionStyle = React.useMemo((): React.CSSProperties => {\n const durMs = reducedMotion ? 0 : transitionMs;\n const entered = cycle.incomingEntered;\n const yEnter = direction === \"up\" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;\n return {\n opacity: entered ? 1 : 0,\n transform: entered ? \"translate3d(0, 0, 0)\" : `translate3d(0, ${yEnter}px, 0)`,\n transition:\n durMs > 0\n ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n };\n }, [cycle.incomingEntered, direction, transitionMs, reducedMotion]);\n\n if (itemCount === 0) {\n return null;\n }\n\n const wrapperStyle = {\n ...(trackWidth !== null ? { width: `${trackWidth}px` } : {}),\n // paddingTop: SLIDE_OFFSET_PX,\n } as React.CSSProperties;\n\n const showIncoming = incomingLabel !== null && cycle.transitioning;\n\n return (\n <span\n ref={ref}\n data-testid=\"cycling-text\"\n data-paused={paused ? \"true\" : undefined}\n className={cn(\n \"relative inline-flex items-center overflow-hidden align-middle leading-[inherit]\",\n \"motion-safe:transition-[width] motion-safe:duration-300 motion-safe:ease-out\",\n className,\n )}\n style={wrapperStyle}\n {...rest}\n >\n <span\n ref={sizingLabelRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none invisible inline-block select-none whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n >\n {sizingLabel}\n </span>\n\n <span\n data-layer=\"current\"\n aria-live={announceChanges ? \"polite\" : undefined}\n aria-atomic={announceChanges ? true : undefined}\n data-state={cycle.transitioning ? \"exit\" : \"idle\"}\n onTransitionEnd={onOutgoingTransitionEnd}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={outgoingMotionStyle}\n >\n {currentLabel}\n </span>\n\n {showIncoming ? (\n <span\n aria-hidden=\"true\"\n data-layer=\"incoming\"\n data-state={cycle.incomingEntered ? \"idle\" : \"enter\"}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={incomingMotionStyle}\n >\n {incomingLabel}\n </span>\n ) : null}\n </span>\n );\n },\n);\n\nCyclingText.displayName = \"CyclingText\";\n"],"names":["React","usePageVisibility","usePrefersReducedMotion","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AA;AAAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAEF,OAAO;AAAA,cAEN,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,eACCC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,eAAY;AAAA,cACZ,cAAW;AAAA,cACX,cAAY,MAAM,kBAAkB,SAAS;AAAA,cAC7C,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAEF,OAAO;AAAA,cAEN,UAAA;AAAA,YAAA;AAAA,UAAA,IAED;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,YAAY,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"CyclingText.cjs","sources":["../../../../src/components/CyclingText/CyclingText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCyclingCycle } from \"./useCyclingCycle\";\nimport { useCyclingMotion } from \"./useCyclingMotion\";\nimport { useCyclingTextTrackWidth } from \"./useCyclingTextTrackWidth\";\nimport { usePageVisibility } from \"./usePageVisibility\";\n\nconst DEFAULT_INTERVAL_MS = 2100;\nconst DEFAULT_TRANSITION_MS = 200;\n\n/** How the wrapper should be sized to accommodate variable-length items. */\nexport type CyclingTextSizing = \"longest\" | \"current\";\n\nexport interface CyclingTextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** Strings to cycle through, in order. Cycles back to the first after the last. */\n items: readonly string[];\n /**\n * Milliseconds to wait after the previous transition finishes before starting the next one.\n * @default 2100\n */\n intervalMs?: number;\n /** Slide and cross-fade duration in milliseconds. @default 200 */\n transitionMs?: number;\n /** Direction the outgoing item slides. @default \"up\" */\n direction?: \"up\" | \"down\";\n /** When true, freezes on the current item — no further cycling until cleared. @default false */\n paused?: boolean;\n /**\n * How the wrapper sizes itself horizontally.\n * - `longest` reserves space for the longest item — no width jitter as items cycle.\n * - `current` shrinks/grows with each item, animating width between cycles.\n * @default \"longest\"\n */\n sizing?: CyclingTextSizing;\n /**\n * When `true`, updates are exposed to assistive technologies via `aria-live=\"polite\"`.\n * Leave `false` for decorative or frequently changing copy so screen readers are not interrupted on every cycle.\n * @default false\n */\n announceChanges?: boolean;\n /**\n * Class applied to each visible label span (current + incoming). Use this for\n * effects that have to sit on the text element itself, e.g. `background-clip: text`.\n */\n labelClassName?: string;\n /**\n * Called with the index of the settled, fully-visible item — once on mount and\n * again whenever it changes (after each transition completes). Lets a parent\n * stay in lockstep with what is on screen (e.g. to act on the item the user is\n * currently looking at) without running a second, drifting timer of its own.\n */\n onActiveIndexChange?: (index: number) => void;\n}\n\n/**\n * Cycles through a list of strings with a slide-in/slide-out animation. Lives\n * inline so it can sit inside divs, spans, buttons, or as a fake placeholder\n * overlay.\n *\n * @example\n * ```tsx\n * <CyclingText items={[\"Thinking\", \"Reading messages\", \"Drafting reply\"]} />\n * ```\n */\nexport const CyclingText = React.forwardRef<HTMLSpanElement, CyclingTextProps>(\n (\n {\n items,\n intervalMs = DEFAULT_INTERVAL_MS,\n transitionMs = DEFAULT_TRANSITION_MS,\n direction = \"up\",\n paused = false,\n sizing = \"longest\",\n className,\n labelClassName,\n announceChanges = false,\n onActiveIndexChange,\n ...rest\n },\n ref,\n ) => {\n const docVisible = usePageVisibility();\n const { sizingLabelRef, trackWidth } = useCyclingTextTrackWidth();\n const {\n cycle,\n currentIndex,\n currentLabel,\n incomingLabel,\n sizingLabel,\n onOutgoingTransitionEnd,\n } = useCyclingCycle(items, sizing, intervalMs, paused, docVisible, transitionMs);\n\n const itemCount = items.length;\n\n // Notify the parent of the settled active index without re-subscribing when\n // an inline callback identity changes each render — the latest is always\n // read from the ref.\n const onActiveIndexChangeRef = React.useRef(onActiveIndexChange);\n React.useEffect(() => {\n onActiveIndexChangeRef.current = onActiveIndexChange;\n }, [onActiveIndexChange]);\n React.useEffect(() => {\n onActiveIndexChangeRef.current?.(currentIndex);\n }, [currentIndex]);\n\n const { outgoingStyle, incomingStyle } = useCyclingMotion({\n transitioning: cycle.transitioning,\n incomingEntered: cycle.incomingEntered,\n direction,\n transitionMs,\n });\n\n if (itemCount === 0) {\n return null;\n }\n\n const wrapperStyle = {\n ...(trackWidth !== null ? { width: `${trackWidth}px` } : {}),\n } as React.CSSProperties;\n\n const showIncoming = incomingLabel !== null && cycle.transitioning;\n\n return (\n <span\n ref={ref}\n data-testid=\"cycling-text\"\n data-paused={paused ? \"true\" : undefined}\n className={cn(\n \"relative inline-flex items-center overflow-hidden align-middle leading-[inherit]\",\n \"motion-safe:transition-[width] motion-safe:duration-300 motion-safe:ease-out\",\n className,\n )}\n style={wrapperStyle}\n {...rest}\n >\n <span\n ref={sizingLabelRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none invisible inline-block select-none whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n >\n {sizingLabel}\n </span>\n\n <span\n data-layer=\"current\"\n aria-live={announceChanges ? \"polite\" : undefined}\n aria-atomic={announceChanges ? true : undefined}\n data-state={cycle.transitioning ? \"exit\" : \"idle\"}\n onTransitionEnd={onOutgoingTransitionEnd}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={outgoingStyle}\n >\n {currentLabel}\n </span>\n\n {showIncoming ? (\n <span\n aria-hidden=\"true\"\n data-layer=\"incoming\"\n data-state={cycle.incomingEntered ? \"idle\" : \"enter\"}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={incomingStyle}\n >\n {incomingLabel}\n </span>\n ) : null}\n </span>\n );\n },\n);\n\nCyclingText.displayName = \"CyclingText\";\n"],"names":["React","usePageVisibility","useCyclingTextTrackWidth","useCyclingCycle","useCyclingMotion","jsxs","cn","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAwDvB,MAAM,cAAcA,iBAAM;AAAA,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AAAA,UAAAC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,eAAY;AAAA,cACZ,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAGD,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGHC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,cAAW;AAAA,cACX,aAAW,kBAAkB,WAAW;AAAA,cACxC,eAAa,kBAAkB,OAAO;AAAA,cACtC,cAAY,MAAM,gBAAgB,SAAS;AAAA,cAC3C,iBAAiB;AAAA,cACjB,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAEF,OAAO;AAAA,cAEN,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGF,eACCC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,eAAY;AAAA,cACZ,cAAW;AAAA,cACX,cAAY,MAAM,kBAAkB,SAAS;AAAA,cAC7C,WAAWD,GAAAA;AAAAA,gBACT;AAAA,gBACA;AAAA,cAAA;AAAA,cAEF,OAAO;AAAA,cAEN,UAAA;AAAA,YAAA;AAAA,UAAA,IAED;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;AAEA,YAAY,cAAc;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const usePrefersReducedMotion = require("../../utils/usePrefersReducedMotion.cjs");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
|
+
const SLIDE_OFFSET_PX = 18;
|
|
24
|
+
const EASING = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
25
|
+
function useCyclingMotion({
|
|
26
|
+
transitioning,
|
|
27
|
+
incomingEntered,
|
|
28
|
+
direction,
|
|
29
|
+
transitionMs
|
|
30
|
+
}) {
|
|
31
|
+
const reducedMotion = usePrefersReducedMotion.usePrefersReducedMotion();
|
|
32
|
+
const durMs = reducedMotion ? 0 : transitionMs;
|
|
33
|
+
const outgoingStyle = React__namespace.useMemo(() => {
|
|
34
|
+
const yExit = direction === "up" ? -SLIDE_OFFSET_PX : SLIDE_OFFSET_PX;
|
|
35
|
+
return {
|
|
36
|
+
opacity: transitioning ? 0 : 1,
|
|
37
|
+
transform: transitioning ? `translate3d(0, ${yExit}px, 0)` : "translate3d(0, 0, 0)",
|
|
38
|
+
// Only while exiting: returning to idle should snap, not animate back.
|
|
39
|
+
transition: transitioning && durMs > 0 ? `opacity ${durMs}ms ${EASING}, transform ${durMs}ms ${EASING}` : "none"
|
|
40
|
+
};
|
|
41
|
+
}, [transitioning, direction, durMs]);
|
|
42
|
+
const incomingStyle = React__namespace.useMemo(() => {
|
|
43
|
+
const yEnter = direction === "up" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;
|
|
44
|
+
return {
|
|
45
|
+
opacity: incomingEntered ? 1 : 0,
|
|
46
|
+
transform: incomingEntered ? "translate3d(0, 0, 0)" : `translate3d(0, ${yEnter}px, 0)`,
|
|
47
|
+
transition: durMs > 0 ? `opacity ${durMs}ms ${EASING}, transform ${durMs}ms ${EASING}` : "none"
|
|
48
|
+
};
|
|
49
|
+
}, [incomingEntered, direction, durMs]);
|
|
50
|
+
return { outgoingStyle, incomingStyle };
|
|
51
|
+
}
|
|
52
|
+
exports.useCyclingMotion = useCyclingMotion;
|
|
53
|
+
//# sourceMappingURL=useCyclingMotion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCyclingMotion.cjs","sources":["../../../../src/components/CyclingText/useCyclingMotion.ts"],"sourcesContent":["import * as React from \"react\";\nimport { usePrefersReducedMotion } from \"../../utils/usePrefersReducedMotion\";\n\nconst SLIDE_OFFSET_PX = 18;\nconst EASING = \"cubic-bezier(0.4, 0, 0.2, 1)\";\n\nexport interface CyclingMotionOptions {\n /** True while the outgoing item is sliding out and the incoming one is sliding in. */\n transitioning: boolean;\n /** True once the incoming item has been moved to its resting position. */\n incomingEntered: boolean;\n /** Direction the outgoing item slides. */\n direction: \"up\" | \"down\";\n /** Slide and cross-fade duration in milliseconds. */\n transitionMs: number;\n}\n\nexport interface CyclingMotion {\n outgoingStyle: React.CSSProperties;\n incomingStyle: React.CSSProperties;\n}\n\n/**\n * Inline styles driving the slide and cross-fade between two cycling items.\n *\n * Inline rather than utility classes because `transitionMs` is a runtime prop.\n * Reduced motion collapses the duration to zero, leaving the end states intact;\n * the cycle is advanced by the fallback timer in `useCyclingCycle`, not by\n * `transitionend`, so it keeps running when no transition fires.\n */\nexport function useCyclingMotion({\n transitioning,\n incomingEntered,\n direction,\n transitionMs,\n}: CyclingMotionOptions): CyclingMotion {\n const reducedMotion = usePrefersReducedMotion();\n const durMs = reducedMotion ? 0 : transitionMs;\n\n const outgoingStyle = React.useMemo((): React.CSSProperties => {\n const yExit = direction === \"up\" ? -SLIDE_OFFSET_PX : SLIDE_OFFSET_PX;\n return {\n opacity: transitioning ? 0 : 1,\n transform: transitioning ? `translate3d(0, ${yExit}px, 0)` : \"translate3d(0, 0, 0)\",\n // Only while exiting: returning to idle should snap, not animate back.\n transition:\n transitioning && durMs > 0\n ? `opacity ${durMs}ms ${EASING}, transform ${durMs}ms ${EASING}`\n : \"none\",\n };\n }, [transitioning, direction, durMs]);\n\n const incomingStyle = React.useMemo((): React.CSSProperties => {\n const yEnter = direction === \"up\" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;\n return {\n opacity: incomingEntered ? 1 : 0,\n transform: incomingEntered ? \"translate3d(0, 0, 0)\" : `translate3d(0, ${yEnter}px, 0)`,\n transition:\n durMs > 0 ? `opacity ${durMs}ms ${EASING}, transform ${durMs}ms ${EASING}` : \"none\",\n };\n }, [incomingEntered, direction, durMs]);\n\n return { outgoingStyle, incomingStyle };\n}\n"],"names":["usePrefersReducedMotion","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,kBAAkB;AACxB,MAAM,SAAS;AA0BR,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwC;AACtC,QAAM,gBAAgBA,wBAAAA,wBAAA;AACtB,QAAM,QAAQ,gBAAgB,IAAI;AAElC,QAAM,gBAAgBC,iBAAM,QAAQ,MAA2B;AAC7D,UAAM,QAAQ,cAAc,OAAO,CAAC,kBAAkB;AACtD,WAAO;AAAA,MACL,SAAS,gBAAgB,IAAI;AAAA,MAC7B,WAAW,gBAAgB,kBAAkB,KAAK,WAAW;AAAA;AAAA,MAE7D,YACE,iBAAiB,QAAQ,IACrB,WAAW,KAAK,MAAM,MAAM,eAAe,KAAK,MAAM,MAAM,KAC5D;AAAA,IAAA;AAAA,EAEV,GAAG,CAAC,eAAe,WAAW,KAAK,CAAC;AAEpC,QAAM,gBAAgBA,iBAAM,QAAQ,MAA2B;AAC7D,UAAM,SAAS,cAAc,OAAO,kBAAkB,CAAC;AACvD,WAAO;AAAA,MACL,SAAS,kBAAkB,IAAI;AAAA,MAC/B,WAAW,kBAAkB,yBAAyB,kBAAkB,MAAM;AAAA,MAC9E,YACE,QAAQ,IAAI,WAAW,KAAK,MAAM,MAAM,eAAe,KAAK,MAAM,MAAM,KAAK;AAAA,IAAA;AAAA,EAEnF,GAAG,CAAC,iBAAiB,WAAW,KAAK,CAAC;AAEtC,SAAO,EAAE,eAAe,cAAA;AAC1B;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 ProgressBar = require("../ProgressBar/ProgressBar.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 Demographics = React__namespace.forwardRef(
|
|
26
|
+
({ label, value, formattedValue, icon, className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn.cn("flex w-full flex-col gap-2", className), ...props, children: [
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
29
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-5 shrink-0 items-center justify-center", children: icon }),
|
|
30
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-semibold truncate text-content-primary", children: label })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-regular shrink-0 text-content-primary", children: formattedValue })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProgressBar.ProgressBar, { variant: "sky", size: "medium", value, ariaLabel: label })
|
|
35
|
+
] })
|
|
36
|
+
);
|
|
37
|
+
Demographics.displayName = "Demographics";
|
|
38
|
+
exports.Demographics = Demographics;
|
|
39
|
+
//# sourceMappingURL=Demographics.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Demographics.cjs","sources":["../../../../src/components/Demographics/Demographics.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { ProgressBar } from \"../ProgressBar/ProgressBar\";\n\n/** Props for {@link Demographics}. */\nexport interface DemographicsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /**\n * Row label, e.g. a country name. Pass a translated string for i18n.\n *\n * A string rather than a node because it is also the bar's accessible name:\n * a node would leave the bar announcing \"Progress\" and a bare number, with\n * nothing saying which row it belongs to.\n */\n label: string;\n /** Share of the total, 0–100. Drives the bar and is announced to assistive tech. */\n value: number;\n /** Formatted share shown at the end of the row, e.g. `\"52.6%\"`. */\n formattedValue: React.ReactNode;\n /** Leading 20px glyph — a flag for a country row. */\n icon?: React.ReactNode;\n}\n\n/**\n * One row of a breakdown: a leading glyph and label, its share at the far end,\n * and a bar underneath. Stack these to show how a total splits across\n * categories — the top-countries breakdown on the insights dashboard, and the\n * same list expanded inside a dialog.\n *\n * @example\n * ```tsx\n * <Demographics\n * icon={<span aria-hidden>🇺🇸</span>}\n * label=\"United States\"\n * value={52.6}\n * formattedValue=\"52.6%\"\n * />\n * ```\n */\nexport const Demographics = React.forwardRef<HTMLDivElement, DemographicsProps>(\n ({ label, value, formattedValue, icon, className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex w-full flex-col gap-2\", className)} {...props}>\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-2\">\n {icon && <span className=\"flex size-5 shrink-0 items-center justify-center\">{icon}</span>}\n <span className=\"typography-body-small-14px-semibold truncate text-content-primary\">\n {label}\n </span>\n </span>\n <span className=\"typography-body-small-14px-regular shrink-0 text-content-primary\">\n {formattedValue}\n </span>\n </div>\n <ProgressBar variant=\"sky\" size=\"medium\" value={value} ariaLabel={label} />\n </div>\n ),\n);\n\nDemographics.displayName = \"Demographics\";\n"],"names":["React","jsxs","cn","jsx","ProgressBar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAM,eAAeA,iBAAM;AAAA,EAChC,CAAC,EAAE,OAAO,OAAO,gBAAgB,MAAM,WAAW,GAAG,MAAA,GAAS,QAC5DC,2BAAAA,KAAC,OAAA,EAAI,KAAU,WAAWC,GAAAA,GAAG,8BAA8B,SAAS,GAAI,GAAG,OACzE,UAAA;AAAA,IAAAD,2BAAAA,KAAC,OAAA,EAAI,WAAU,kDACb,UAAA;AAAA,MAAAA,2BAAAA,KAAC,QAAA,EAAK,WAAU,mCACb,UAAA;AAAA,QAAA,QAAQE,2BAAAA,IAAC,QAAA,EAAK,WAAU,oDAAoD,UAAA,MAAK;AAAA,QAClFA,2BAAAA,IAAC,QAAA,EAAK,WAAU,qEACb,UAAA,MAAA,CACH;AAAA,MAAA,GACF;AAAA,MACAA,2BAAAA,IAAC,QAAA,EAAK,WAAU,oEACb,UAAA,eAAA,CACH;AAAA,IAAA,GACF;AAAA,IACAA,+BAACC,YAAAA,eAAY,SAAQ,OAAM,MAAK,UAAS,OAAc,WAAW,MAAA,CAAO;AAAA,EAAA,EAAA,CAC3E;AAEJ;AAEA,aAAa,cAAc;;"}
|
|
@@ -27,6 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
const DialogPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(DialogPrimitive);
|
|
28
28
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
29
29
|
const SHEET_CLASSES = "rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]";
|
|
30
|
+
const MENU_CLASSES = "inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]";
|
|
30
31
|
const DrawerContext = React__namespace.createContext({
|
|
31
32
|
overlay: true
|
|
32
33
|
});
|
|
@@ -98,13 +99,20 @@ const DrawerContent = React__namespace.forwardRef(
|
|
|
98
99
|
...style
|
|
99
100
|
},
|
|
100
101
|
className: cn.cn(
|
|
101
|
-
"fixed flex flex-col bg-surface-secondary
|
|
102
|
+
"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg",
|
|
103
|
+
// `shadow-lg` is scoped to `panel` rather than sitting in the base classes.
|
|
104
|
+
// tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow
|
|
105
|
+
// utility, so it never deduped the two and `shadow-lg` won on stylesheet
|
|
106
|
+
// order — meaning the sheet and menu surfaces silently rendered `shadow-lg`
|
|
107
|
+
// instead of the menu shadow their tokens name.
|
|
108
|
+
variant === "panel" && "shadow-lg",
|
|
102
109
|
"data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
103
110
|
"data-[state=closed]:duration-150 data-[state=closed]:ease-in",
|
|
104
111
|
"data-[state=open]:duration-200 data-[state=open]:ease-out",
|
|
105
112
|
SLIDE_CLASSES[position],
|
|
106
113
|
sizeClass,
|
|
107
114
|
variant === "sheet" && SHEET_CLASSES,
|
|
115
|
+
variant === "menu" && MENU_CLASSES,
|
|
108
116
|
className
|
|
109
117
|
),
|
|
110
118
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment. @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position = \"right\",\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && <DrawerOverlay {...overlayProps} />}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary shadow-lg outline-none backdrop-blur-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n className,\n )}\n {...props}\n >\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex items-center gap-2 p-4\", className)} {...props}>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n ),\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A semantic footer area for the drawer, typically containing action buttons. */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-col gap-2 p-4\", className)} {...props} />\n ),\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,gBACJ;AA2BF,MAAM,gBAAgBA,iBAAM,cAAoC;AAAA,EAC9D,SAAS;AACX,CAAC;AAuBM,SAAS,OAAO,EAAE,UAAU,MAAM,OAAO,UAAU,GAAG,SAAsB;AACjF,QAAM,gBAAgB,UAAU,UAAU,SAAY;AACtD,wCACG,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAA,GAC/B,UAAAC,2BAAAA,IAACC,2BAAgB,MAAhB,EAAqB,OAAO,eAAgB,GAAG,OAC7C,UACH,GACF;AAEJ;AACA,OAAO,cAAc;AAYd,MAAM,gBAAgBF,iBAAM,WAGjC,CAAC,OAAO,QAAQC,2BAAAA,IAACC,2BAAgB,SAAhB,EAAwB,KAAW,GAAGC,0BAAAA,0BAA0B,KAAK,GAAG,CAAE;AAC7F,cAAc,cAAc;AAMrB,MAAM,cAAcD,2BAAgB;AAC3C,YAAY,cAAc;AAUnB,MAAM,gBAAgBF,iBAAM,WAGjC,CAAC,EAAE,WAAW,OAAO,GAAG,SAAS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AAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWE,GAAAA,GAAG,6DAA6D,SAAS;AAAA,IACnF,GAAG;AAAA,EAAA;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","sources":["../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useSuppressClickAfterDrag } from \"../../utils/useSuppressClickAfterDrag\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** The side from which the drawer slides in. */\nexport type DrawerPosition = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/** Size presets for the drawer panel. Maps to max-width (left/right) or max-height (top/bottom). */\nexport type DrawerSize = \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/**\n * Visual treatment of the drawer panel.\n *\n * - `\"panel\"` (default) — the standard edge-anchored surface.\n * - `\"sheet\"` — a bottom-sheet treatment matching the modal surface: large\n * top-only radius (32px), modal background/stroke, and menu blur+shadow.\n * Intended for `position=\"bottom\"`.\n * - `\"menu\"` — a floating menu near the bottom edge rather than a sheet fixed to\n * it: inset from all three sides and rounded on every corner. Shares the modal\n * surface with `\"sheet\"`; only the shape differs. Intended for\n * `position=\"bottom\"`.\n */\nexport type DrawerVariant = \"panel\" | \"sheet\" | \"menu\";\n\n/**\n * Shared surface classes for the `\"sheet\"` variant. Mirrors the mobile sheet\n * treatment used by {@link Dialog} so bottom sheets are visually consistent.\n */\nconst SHEET_CLASSES =\n \"rounded-t-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Surface and inset for the `\"menu\"` variant. Same modal background and stroke as\n * a sheet — the design puts this panel on `background/secondary` with\n * `border/strong`, not on the lighter surface the trigger-anchored dropdown uses.\n * The 24px radius is the design's `rounded-lg`.\n *\n * The insets restate position on purpose — they override `SLIDE_CLASSES.bottom`,\n * which pins a sheet flush to the bottom edge at full width.\n */\nconst MENU_CLASSES =\n \"inset-x-4 bottom-4 w-auto rounded-lg border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-[4px]\";\n\n/**\n * Props for the {@link Drawer} root component.\n *\n * Inherits `open`, `onOpenChange`, and `defaultOpen` from Radix Dialog.Root.\n *\n * The Radix `modal` prop (default `true`) can also be passed to create a\n * non-modal drawer — useful for persistent side navigation that does not\n * block interaction with the rest of the page.\n *\n * **`overlay` behaviour:** When `overlay` is `false`, the component\n * automatically sets `modal={false}` on the underlying Radix Dialog.Root.\n * A modal dialog without a visible overlay is confusing because focus is\n * still trapped and scroll is blocked even though the page appears\n * interactive. Passing `modal={true}` explicitly will override this.\n */\nexport interface DrawerProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root> {\n /**\n * Whether the default {@link DrawerOverlay} is rendered.\n * When `false`, `modal` is automatically set to `false` as well\n * (unless explicitly overridden) so focus-trap and scroll-lock are disabled.\n * @default true\n */\n overlay?: boolean;\n}\n\nconst DrawerContext = React.createContext<{ overlay: boolean }>({\n overlay: true,\n});\n\n/**\n * Root component that manages open/close state for a drawer.\n * Wraps Radix Dialog.Root.\n *\n * @example\n * ```tsx\n * <Drawer>\n * <DrawerTrigger>Open</DrawerTrigger>\n * <DrawerContent position=\"right\">\n * <DrawerHeader>\n * <DrawerTitle>Settings</DrawerTitle>\n * <DrawerDescription>Adjust your preferences.</DrawerDescription>\n * </DrawerHeader>\n * <p>Content goes here.</p>\n * <DrawerFooter>\n * <DrawerClose>Done</DrawerClose>\n * </DrawerFooter>\n * </DrawerContent>\n * </Drawer>\n * ```\n */\nexport function Drawer({ overlay = true, modal, children, ...props }: DrawerProps) {\n const resolvedModal = modal ?? (overlay ? undefined : false);\n return (\n <DrawerContext.Provider value={{ overlay }}>\n <DialogPrimitive.Root modal={resolvedModal} {...props}>\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}\nDrawer.displayName = \"Drawer\";\n\n/** Props for the {@link DrawerTrigger} component. */\nexport type DrawerTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\n/**\n * The element that opens the drawer when clicked.\n *\n * On touch / pen, a press-and-release that crosses a small movement threshold\n * is treated as a drag and the resulting synthetic click is suppressed —\n * defends against Android Chrome opening the drawer on a scroll-drag-end.\n */\nexport const DrawerTrigger = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Trigger>,\n DrawerTriggerProps\n>((props, ref) => <DialogPrimitive.Trigger ref={ref} {...useSuppressClickAfterDrag(props)} />);\nDrawerTrigger.displayName = \"DrawerTrigger\";\n\n/** Props for the {@link DrawerClose} component. */\nexport type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Close>;\n\n/** Closes the drawer when clicked. Can be placed anywhere inside the drawer. */\nexport const DrawerClose = DialogPrimitive.Close;\nDrawerClose.displayName = \"DrawerClose\";\n\n/** Props for the {@link DrawerOverlay} component. */\nexport interface DrawerOverlayProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> {}\n\n/**\n * A translucent backdrop rendered behind the drawer content.\n * Clicking the overlay closes the drawer by default.\n */\nexport const DrawerOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n DrawerOverlayProps\n>(({ className, style, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"fixed inset-0 bg-background-overlay-default\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:fade-in-0 data-[state=open]:duration-200 data-[state=open]:ease-out\",\n className,\n )}\n {...props}\n />\n));\nDrawerOverlay.displayName = \"DrawerOverlay\";\n\n/**\n * Slide-in animation classes keyed by position.\n * Uses Tailwind animate utilities (animate-in / animate-out).\n */\nconst SLIDE_CLASSES: Record<DrawerPosition, string> = {\n right:\n \"inset-y-0 right-0 h-full w-2/3 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right\",\n left: \"inset-y-0 left-0 h-full w-2/3 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left\",\n top: \"inset-x-0 top-0 w-full data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 w-full rounded-t-xs data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n};\n\n/** Props for the {@link DrawerContent} component. */\nexport interface DrawerContentProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {\n /**\n * The edge from which the drawer slides in.\n *\n * Named `position` (rather than `side`) to avoid confusion with the CSS\n * `side` concept used by Radix Popover/Tooltip and to better convey the\n * spatial relationship of the drawer to the viewport.\n *\n * @default \"right\"\n */\n position?: DrawerPosition;\n /**\n * Controls the maximum extent of the drawer panel.\n * For left/right drawers this sets `max-width`; for top/bottom it sets `max-height`.\n * @default \"sm\"\n */\n size?: DrawerSize;\n /**\n * Visual treatment of the panel. Use `\"sheet\"` (with `position=\"bottom\"`) for\n * a bottom sheet with the modal surface treatment, or `\"menu\"` for a floating\n * inset menu carrying the dropdown surface. @default \"panel\"\n */\n variant?: DrawerVariant;\n /**\n * Whether to render the default {@link DrawerOverlay} behind the content.\n * Set to `false` to provide your own overlay or omit it entirely.\n *\n * Prefer setting `overlay` on the {@link Drawer} root instead so that\n * `modal` is also adjusted automatically.\n *\n * @default true\n */\n overlay?: boolean;\n /** Props forwarded to the default {@link DrawerOverlay} when `overlay` is `true`. */\n overlayProps?: DrawerOverlayProps;\n}\n\n/**\n * The panel that slides in from the chosen edge. Renders inside a portal with\n * an overlay backdrop by default.\n *\n * Includes focus-trap, `aria-describedby`, and Escape-to-close from Radix Dialog.\n */\nexport const DrawerContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(\n (\n {\n className,\n position = \"right\",\n size = \"sm\",\n variant = \"panel\",\n overlay: overlayProp,\n overlayProps,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const ctx = React.useContext(DrawerContext);\n const overlay = overlayProp ?? ctx.overlay;\n const isHorizontal = position === \"left\" || position === \"right\";\n const sizeClass = isHorizontal\n ? (\n {\n sm: \"max-w-sm\",\n md: \"max-w-md\",\n lg: \"max-w-lg\",\n full: \"max-w-full\",\n } as const\n )[size]\n : (\n {\n sm: \"max-h-[24rem]\",\n md: \"max-h-[28rem]\",\n lg: \"max-h-[32rem]\",\n full: \"max-h-full\",\n } as const\n )[size];\n\n return (\n <DialogPrimitive.Portal>\n {overlay && <DrawerOverlay {...overlayProps} />}\n <DialogPrimitive.Content\n ref={ref}\n style={{\n zIndex: \"calc(var(--fanvue-ui-portal-z-index, 50) + 1)\",\n ...style,\n }}\n className={cn(\n \"fixed flex flex-col bg-surface-secondary outline-none backdrop-blur-lg\",\n // `shadow-lg` is scoped to `panel` rather than sitting in the base classes.\n // tailwind-merge does not recognise `shadow-blur-menu` as a box-shadow\n // utility, so it never deduped the two and `shadow-lg` won on stylesheet\n // order — meaning the sheet and menu surfaces silently rendered `shadow-lg`\n // instead of the menu shadow their tokens name.\n variant === \"panel\" && \"shadow-lg\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:duration-150 data-[state=closed]:ease-in\",\n \"data-[state=open]:duration-200 data-[state=open]:ease-out\",\n SLIDE_CLASSES[position],\n sizeClass,\n variant === \"sheet\" && SHEET_CLASSES,\n variant === \"menu\" && MENU_CLASSES,\n className,\n )}\n {...props}\n >\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n },\n);\nDrawerContent.displayName = \"DrawerContent\";\n\n/** Props for the {@link DrawerHeader} component. */\nexport interface DrawerHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Whether to show a built-in close (X) button. @default true */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close drawer\" */\n closeLabel?: string;\n}\n\n/**\n * A semantic header area for the drawer, typically containing a title and description.\n * Renders a built-in close button by default.\n */\nexport const DrawerHeader = React.forwardRef<HTMLDivElement, DrawerHeaderProps>(\n ({ className, showClose = true, closeLabel = \"Close drawer\", children, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex items-center gap-2 p-4\", className)} {...props}>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">{children}</div>\n {showClose && (\n <DialogPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n variant=\"secondary\"\n size=\"32\"\n className=\"shrink-0\"\n />\n </DialogPrimitive.Close>\n )}\n </div>\n ),\n);\nDrawerHeader.displayName = \"DrawerHeader\";\n\n/** Props for the {@link DrawerFooter} component. */\nexport interface DrawerFooterProps extends React.HTMLAttributes<HTMLDivElement> {}\n\n/** A semantic footer area for the drawer, typically containing action buttons. */\nexport const DrawerFooter = React.forwardRef<HTMLDivElement, DrawerFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn(\"flex flex-col gap-2 p-4\", className)} {...props} />\n ),\n);\nDrawerFooter.displayName = \"DrawerFooter\";\n\n/** Props for the {@link DrawerTitle} component. */\nexport interface DrawerTitleProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> {}\n\n/** An accessible title for the drawer. Required for screen readers. */\nexport const DrawerTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n DrawerTitleProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"typography-body-default-16px-semibold truncate text-content-primary\", className)}\n {...props}\n />\n));\nDrawerTitle.displayName = \"DrawerTitle\";\n\n/** Props for the {@link DrawerDescription} component. */\nexport interface DrawerDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> {}\n\n/** An accessible description for the drawer, providing supplementary context. */\nexport const DrawerDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n DrawerDescriptionProps\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"typography-body-small-14px-regular text-content-secondary\", className)}\n {...props}\n />\n));\nDrawerDescription.displayName = \"DrawerDescription\";\n"],"names":["React","jsx","DialogPrimitive","useSuppressClickAfterDrag","cn","jsxs","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,gBACJ;AAWF,MAAM,eACJ;AA2BF,MAAM,gBAAgBA,iBAAM,cAAoC;AAAA,EAC9D,SAAS;AACX,CAAC;AAuBM,SAAS,OAAO,EAAE,UAAU,MAAM,OAAO,UAAU,GAAG,SAAsB;AACjF,QAAM,gBAAgB,UAAU,UAAU,SAAY;AACtD,wCACG,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAA,GAC/B,UAAAC,2BAAAA,IAACC,2BAAgB,MAAhB,EAAqB,OAAO,eAAgB,GAAG,OAC7C,UACH,GACF;AAEJ;AACA,OAAO,cAAc;AAYd,MAAM,gBAAgBF,iBAAM,WAGjC,CAAC,OAAO,QAAQC,2BAAAA,IAACC,2BAAgB,SAAhB,EAAwB,KAAW,GAAGC,0BAAAA,0BAA0B,KAAK,GAAG,CAAE;AAC7F,cAAc,cAAc;AAMrB,MAAM,cAAcD,2BAAgB;AAC3C,YAAY,cAAc;AAUnB,MAAM,gBAAgBF,iBAAM,WAGjC,CAAC,EAAE,WAAW,OAAO,GAAG,SAAS,QACjCC,2BAAAA;AAAAA,EAACC,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,OAAO,EAAE,QAAQ,uCAAuC,GAAG,MAAA;AAAA,IAC3D,WAAWE,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;A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A;AACN,CACD;AACD,kBAAkB,cAAc;;;;;;;;;;"}
|
|
@@ -13,6 +13,7 @@ const IconButton = require("../IconButton/IconButton.cjs");
|
|
|
13
13
|
const CheckIcon = require("../Icons/CheckIcon.cjs");
|
|
14
14
|
const CloseIcon = require("../Icons/CloseIcon.cjs");
|
|
15
15
|
const SearchIcon = require("../Icons/SearchIcon.cjs");
|
|
16
|
+
const TickIcon = require("../Icons/TickIcon.cjs");
|
|
16
17
|
function _interopNamespaceDefault(e) {
|
|
17
18
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
18
19
|
if (e) {
|
|
@@ -130,18 +131,22 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
130
131
|
// is enough to keep the menu flipping/shifting to stay on screen — no
|
|
131
132
|
// hand-rolled reposition logic needed.
|
|
132
133
|
collisionPadding = floatingContentCollisionPadding.FLOATING_CONTENT_COLLISION_PADDING,
|
|
134
|
+
onPointerDownOutside,
|
|
135
|
+
onCloseAutoFocus,
|
|
133
136
|
children,
|
|
134
137
|
...props
|
|
135
138
|
}, ref) => {
|
|
136
139
|
const variant = React__namespace.useContext(DropdownMenuVariantContext);
|
|
140
|
+
const dismissedByPointer = React__namespace.useRef(false);
|
|
137
141
|
if (variant === "sheet") {
|
|
138
142
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
139
143
|
Drawer.DrawerContent,
|
|
140
144
|
{
|
|
141
145
|
ref,
|
|
142
146
|
position: "bottom",
|
|
143
|
-
variant: "
|
|
144
|
-
className:
|
|
147
|
+
variant: "menu",
|
|
148
|
+
overlayProps: { className: "backdrop-blur-[8px]" },
|
|
149
|
+
className: cn.cn("flex flex-col gap-1 p-1 pb-4", className),
|
|
145
150
|
style,
|
|
146
151
|
...props,
|
|
147
152
|
children
|
|
@@ -152,10 +157,27 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
152
157
|
DropdownMenuPrimitive__namespace.Content,
|
|
153
158
|
{
|
|
154
159
|
ref,
|
|
160
|
+
onPointerDownOutside: (event) => {
|
|
161
|
+
dismissedByPointer.current = true;
|
|
162
|
+
onPointerDownOutside?.(event);
|
|
163
|
+
},
|
|
164
|
+
onCloseAutoFocus: (event) => {
|
|
165
|
+
if (dismissedByPointer.current) event.preventDefault();
|
|
166
|
+
dismissedByPointer.current = false;
|
|
167
|
+
onCloseAutoFocus?.(event);
|
|
168
|
+
},
|
|
155
169
|
sideOffset,
|
|
156
170
|
collisionPadding,
|
|
157
171
|
className: cn.cn(
|
|
158
|
-
|
|
172
|
+
// `rounded-sm` (12px) is the panel radius `V2 Menu Dropdown` carries
|
|
173
|
+
// (product file node `7393:62008`). The 8px `rounded-xs` belongs to the
|
|
174
|
+
// rows inside it, not the panel.
|
|
175
|
+
//
|
|
176
|
+
// The `sheet` variant is deliberately not 12px: it renders through
|
|
177
|
+
// `DrawerContent variant="menu"`, whose `MENU_CLASSES` is `rounded-lg`
|
|
178
|
+
// (24px). A bottom sheet is a full-width surface with its own radius,
|
|
179
|
+
// not a scaled-up popper, so the two are meant to differ.
|
|
180
|
+
"w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) overflow-y-auto rounded-sm border border-border-primary bg-surface-primary p-1 text-content-primary shadow-blur-menu backdrop-blur-[4px]",
|
|
159
181
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
160
182
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
161
183
|
"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
|
|
@@ -200,14 +222,21 @@ const ITEM_SIZE_CLASSES = {
|
|
|
200
222
|
"32": "min-h-8 py-[7px] typography-body-small-14px-regular"
|
|
201
223
|
};
|
|
202
224
|
const ITEM_COUNT_TYPOGRAPHY = {
|
|
203
|
-
"40": "typography-body-
|
|
225
|
+
"40": "typography-body-small-14px-regular",
|
|
204
226
|
"32": "typography-body-small-14px-regular"
|
|
205
227
|
};
|
|
206
228
|
function SelectedCheckIndicator({ hasDescription }) {
|
|
207
229
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
208
230
|
CheckIcon.CheckIcon,
|
|
209
231
|
{
|
|
210
|
-
className: cn.cn(
|
|
232
|
+
className: cn.cn(
|
|
233
|
+
"size-4 shrink-0 text-content-primary",
|
|
234
|
+
// The two-line layout switches the row to `items-start`, which would hang
|
|
235
|
+
// the tick off the title's line. A leading icon or avatar belongs there —
|
|
236
|
+
// it labels the title — but the tick is a property of the whole row, so it
|
|
237
|
+
// centres against both lines. {@link SelectItem} already does this.
|
|
238
|
+
hasDescription && "self-center"
|
|
239
|
+
)
|
|
211
240
|
}
|
|
212
241
|
);
|
|
213
242
|
}
|
|
@@ -234,8 +263,15 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
234
263
|
const hasDescription = description != null;
|
|
235
264
|
const hasAvatar = avatar != null;
|
|
236
265
|
const itemClassName = cn.cn(
|
|
237
|
-
|
|
266
|
+
// `text-start` because the sheet variant renders the row as a <button>,
|
|
267
|
+
// whose UA-centred text misaligned it from the popper variant's rows.
|
|
268
|
+
"group flex w-full cursor-pointer gap-2 rounded-sm px-3 text-start outline-none",
|
|
238
269
|
hasDescription ? "items-start" : "items-center",
|
|
270
|
+
// The sheet's header runs the full width of the panel, so its rows have to
|
|
271
|
+
// come in off the edge themselves — 12px here on the panel's own 4px is the
|
|
272
|
+
// design's 16px. `w-auto` lets the column stretch them to the space left
|
|
273
|
+
// over; `w-full` plus a margin would overflow.
|
|
274
|
+
variant === "sheet" && "mx-3 w-auto",
|
|
239
275
|
ITEM_SIZE_CLASSES[normalizedSize],
|
|
240
276
|
// A 24px avatar would push the compact 32px row past its height with the
|
|
241
277
|
// default padding; tighten it so the avatar variant keeps the 32px contract.
|
|
@@ -255,12 +291,13 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
255
291
|
selected && ["bg-neutral-alphas-100", "data-[highlighted]:bg-neutral-alphas-200"],
|
|
256
292
|
className
|
|
257
293
|
);
|
|
258
|
-
const iconAlignClassName = hasDescription ? "flex shrink-0 items-center
|
|
294
|
+
const iconAlignClassName = hasDescription ? "flex h-[18px] shrink-0 items-center" : null;
|
|
259
295
|
const countNode = count != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
260
296
|
"span",
|
|
261
297
|
{
|
|
262
298
|
className: cn.cn(
|
|
263
299
|
"shrink-0 tabular-nums",
|
|
300
|
+
iconAlignClassName,
|
|
264
301
|
ITEM_COUNT_TYPOGRAPHY[normalizedSize],
|
|
265
302
|
destructive ? "text-error-content" : "text-content-tertiary",
|
|
266
303
|
"group-data-[disabled]:text-content-disabled"
|
|
@@ -270,9 +307,9 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
270
307
|
);
|
|
271
308
|
const trailingNode = trailingIcon != null ? hasDescription ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: iconAlignClassName, children: trailingIcon }) : trailingIcon : selected && /* @__PURE__ */ jsxRuntime.jsx(SelectedCheckIndicator, { hasDescription });
|
|
272
309
|
const itemChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
273
|
-
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: avatar }) : leadingIcon != null && (hasDescription ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: iconAlignClassName, children: leadingIcon }) : leadingIcon),
|
|
310
|
+
avatar != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("shrink-0", iconAlignClassName), children: avatar }) : leadingIcon != null && (hasDescription ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: iconAlignClassName, children: leadingIcon }) : leadingIcon),
|
|
274
311
|
hasDescription ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
275
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children }),
|
|
312
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-semibold truncate", children }),
|
|
276
313
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-small-14px-regular truncate text-content-secondary", children: description })
|
|
277
314
|
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
278
315
|
countNode,
|
|
@@ -355,8 +392,9 @@ const DropdownMenuHeader = React__namespace.forwardRef(
|
|
|
355
392
|
children,
|
|
356
393
|
...props
|
|
357
394
|
}, ref) => {
|
|
358
|
-
const titleTypography = size === "32" ? "typography-body-small-14px-
|
|
395
|
+
const titleTypography = size === "32" ? "typography-body-small-14px-regular" : "typography-body-default-16px-regular";
|
|
359
396
|
const toggleOpen = React__namespace.useContext(ToggleOpenContext);
|
|
397
|
+
const variant = React__namespace.useContext(DropdownMenuVariantContext);
|
|
360
398
|
const handleClose = () => {
|
|
361
399
|
onClose?.();
|
|
362
400
|
toggleOpen?.(() => false);
|
|
@@ -371,11 +409,15 @@ const DropdownMenuHeader = React__namespace.forwardRef(
|
|
|
371
409
|
// default (title) variant uses 4px because the title baseline sits
|
|
372
410
|
// closer to the divider naturally.
|
|
373
411
|
type === "search" ? "gap-2" : "gap-1",
|
|
412
|
+
// The sheet is a taller, roomier surface than a trigger-anchored panel:
|
|
413
|
+
// the design sets 16px between the rule and the first row, which this
|
|
414
|
+
// margin plus the panel's own 4px gap adds up to.
|
|
415
|
+
variant === "sheet" && "mb-3",
|
|
374
416
|
className
|
|
375
417
|
),
|
|
376
418
|
...props,
|
|
377
419
|
children: [
|
|
378
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 pl-2", children: [
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn.cn("flex items-center gap-4", type === "default" && "pl-2"), children: [
|
|
379
421
|
type === "default" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn.cn("min-w-0 flex-1 truncate text-content-primary", titleTypography), children: children ?? title }) : /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { ...searchProps }),
|
|
380
422
|
showClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
381
423
|
IconButton.IconButton,
|
|
@@ -388,7 +430,7 @@ const DropdownMenuHeader = React__namespace.forwardRef(
|
|
|
388
430
|
}
|
|
389
431
|
)
|
|
390
432
|
] }),
|
|
391
|
-
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, { className: "my-0" })
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, { className: "-mx-2 my-0 bg-border-strong" })
|
|
392
434
|
]
|
|
393
435
|
}
|
|
394
436
|
);
|
|
@@ -400,18 +442,23 @@ function SearchInput({
|
|
|
400
442
|
defaultValue,
|
|
401
443
|
onChange,
|
|
402
444
|
placeholder = "Search…",
|
|
403
|
-
"aria-label": ariaLabel = "Search"
|
|
445
|
+
"aria-label": ariaLabel = "Search",
|
|
446
|
+
autoFocus
|
|
404
447
|
} = {}) {
|
|
448
|
+
const inputRef = React__namespace.useRef(null);
|
|
449
|
+
React__namespace.useEffect(() => {
|
|
450
|
+
if (autoFocus) inputRef.current?.focus();
|
|
451
|
+
}, [autoFocus]);
|
|
405
452
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
406
453
|
"label",
|
|
407
454
|
{
|
|
408
455
|
className: cn.cn(
|
|
409
456
|
"flex min-w-0 flex-1 items-center gap-2 rounded-xs border border-border-primary",
|
|
410
|
-
"bg-
|
|
457
|
+
"bg-inputs-inputs-primary px-3 py-1 text-content-primary",
|
|
411
458
|
"focus-within:shadow-focus-ring focus-within:outline-none"
|
|
412
459
|
),
|
|
413
460
|
children: [
|
|
414
|
-
/* @__PURE__ */ jsxRuntime.jsx(SearchIcon.SearchIcon, { className: "size-4 shrink-0 text-content-
|
|
461
|
+
/* @__PURE__ */ jsxRuntime.jsx(SearchIcon.SearchIcon, { className: "size-4 shrink-0 text-content-primary", "aria-hidden": "true" }),
|
|
415
462
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
416
463
|
"input",
|
|
417
464
|
{
|
|
@@ -420,6 +467,7 @@ function SearchInput({
|
|
|
420
467
|
"typography-body-default-16px-regular min-w-0 flex-1 bg-transparent outline-none",
|
|
421
468
|
"placeholder:text-content-tertiary"
|
|
422
469
|
),
|
|
470
|
+
ref: inputRef,
|
|
423
471
|
value,
|
|
424
472
|
defaultValue,
|
|
425
473
|
placeholder,
|
|
@@ -443,7 +491,10 @@ const DropdownMenuRadioItem = React__namespace.forwardRef(({ className, children
|
|
|
443
491
|
{
|
|
444
492
|
ref,
|
|
445
493
|
className: cn.cn(
|
|
446
|
-
|
|
494
|
+
// `px-3` (12px), not 16px: `V2 Menu Radio Item` is `px-[12px] py-[8px]`
|
|
495
|
+
// (node `7393:62008`), and at 16px a radio row indented 4px further than a
|
|
496
|
+
// `DropdownMenuCheckboxItem` in the same menu.
|
|
497
|
+
"group flex w-full cursor-pointer items-start gap-3 rounded-xs px-3 py-2 outline-none",
|
|
447
498
|
"data-[highlighted]:bg-neutral-alphas-50",
|
|
448
499
|
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
449
500
|
// See DropdownMenuItem above: bg-interaction-hover aliases to the same
|
|
@@ -484,7 +535,55 @@ const DropdownMenuRadioItem = React__namespace.forwardRef(({ className, children
|
|
|
484
535
|
);
|
|
485
536
|
});
|
|
486
537
|
DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
|
|
538
|
+
const DropdownMenuCheckboxItem = React__namespace.forwardRef(({ className, children, helper, avatar, ...props }, ref) => {
|
|
539
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
540
|
+
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
541
|
+
{
|
|
542
|
+
ref,
|
|
543
|
+
className: cn.cn(
|
|
544
|
+
"group flex w-full cursor-pointer items-center gap-3 rounded-xs px-3 py-2 outline-none",
|
|
545
|
+
// Checked state is carried by the tick alone. A background here would
|
|
546
|
+
// leave every selected row shaded, which reads as "all highlighted" on
|
|
547
|
+
// a menu that starts fully selected.
|
|
548
|
+
"data-[highlighted]:bg-neutral-alphas-50",
|
|
549
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled",
|
|
550
|
+
className
|
|
551
|
+
),
|
|
552
|
+
...props,
|
|
553
|
+
children: [
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
555
|
+
"span",
|
|
556
|
+
{
|
|
557
|
+
className: cn.cn(
|
|
558
|
+
"flex size-4 shrink-0 items-center justify-center rounded-2xs border border-icons-primary",
|
|
559
|
+
"group-data-[state=checked]:bg-icons-primary",
|
|
560
|
+
"group-data-[disabled]:border-content-disabled"
|
|
561
|
+
),
|
|
562
|
+
"aria-hidden": "true",
|
|
563
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TickIcon.TickIcon, { className: "size-4 text-content-primary-inverted" }) })
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
avatar && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: avatar }),
|
|
567
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-body-default-16px-semibold truncate", children }),
|
|
569
|
+
helper && /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
"span",
|
|
571
|
+
{
|
|
572
|
+
className: cn.cn(
|
|
573
|
+
"typography-description-12px-regular text-content-secondary",
|
|
574
|
+
"group-data-[disabled]:text-content-disabled"
|
|
575
|
+
),
|
|
576
|
+
children: helper
|
|
577
|
+
}
|
|
578
|
+
)
|
|
579
|
+
] })
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
});
|
|
584
|
+
DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
|
|
487
585
|
exports.DropdownMenu = DropdownMenu;
|
|
586
|
+
exports.DropdownMenuCheckboxItem = DropdownMenuCheckboxItem;
|
|
488
587
|
exports.DropdownMenuContent = DropdownMenuContent;
|
|
489
588
|
exports.DropdownMenuGroup = DropdownMenuGroup;
|
|
490
589
|
exports.DropdownMenuHeader = DropdownMenuHeader;
|