@langchain/macaw-components 1.7.13 → 1.7.15

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.
@@ -57,13 +57,13 @@ function ChatToolCall({ toolCall, variant = "default", onInspect, inspectLabel,
57
57
  weight: "regular"
58
58
  }) : icon;
59
59
  const heading = /* @__PURE__ */ jsxs("span", {
60
- className: "inline-flex min-w-0 items-center gap-space-2",
60
+ className: "inline-flex min-w-0 max-w-full shrink-0 items-center gap-space-2",
61
61
  children: [resolvedIcon != null && /* @__PURE__ */ jsx(ChatToolCallIcon, { children: resolvedIcon }), /* @__PURE__ */ jsx(Text, {
62
62
  as: "span",
63
63
  variant: "xs",
64
64
  weight: "medium",
65
65
  color: "secondary",
66
- className: "min-w-0 truncate",
66
+ className: "min-w-0 whitespace-normal [overflow-wrap:anywhere]",
67
67
  children: name
68
68
  })]
69
69
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ChatToolCall.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCall.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { WrenchIcon } from '@phosphor-icons/react/dist/ssr/Wrench';\n\nimport type { ChatStateStatus } from '../ChatState';\nimport { Text } from '../Text';\nimport type {\n ChatToolCallModel,\n ChatToolCallStatus,\n} from './ChatToolCall.types';\nimport { formatChatToolCallValue } from './ChatToolCall.value';\nimport { ChatToolCallAccordion } from './ChatToolCallAccordion';\nimport { ChatToolCallDetails } from './ChatToolCallDetails';\nimport { useReportToGroup } from './ChatToolCallGroupContext';\nimport { ChatToolCallIcon } from './ChatToolCallIcon';\nimport { ChatToolCallRowStatus } from './ChatToolCallRowStatus';\nimport { ChatToolCallStatusRow } from './ChatToolCallStatusRow';\n\nconst STATUS_PRESENTATIONS = {\n pending: { label: 'Pending', status: 'pending' },\n running: { label: 'Running', status: 'streaming' },\n succeeded: { label: 'Succeeded', status: 'completed' },\n failed: { label: 'Failed', status: 'failed' },\n canceled: { label: 'Canceled', status: 'canceled' },\n 'input-required': { label: 'Needs input', status: 'input-required' },\n} as const satisfies Record<\n ChatToolCallStatus,\n { label: string; status: ChatStateStatus }\n>;\n\nexport interface ChatToolCallProps {\n /** Render at the call's position in the host's ordered content stream. Use its stable ID as the React key. */\n toolCall: ChatToolCallModel;\n variant?: 'default' | 'simple';\n /** Simple row inspection; the host owns navigation, panes, and permissions. */\n onInspect?: () => void;\n /** Tooltip and accessible action label for Simple row inspection. */\n inspectLabel?: string;\n label?: string;\n /**\n * Leading 12px single-color icon, e.g. a product or provider mark. Undefined\n * uses a generic wrench; null omits the icon. Noninteractive presentation\n * slots; response controls belong in a separate content block.\n */\n icon?: ReactNode;\n /** Undefined previews args; null omits the summary. */\n summary?: ReactNode;\n /**\n * Trailing metadata before the status, such as a duration, an edit count,\n * or a link to related work. It sits outside the toggle, so it may hold\n * its own link or button; keep it short.\n */\n meta?: ReactNode;\n /** Undefined uses generic details; null omits the detail region. */\n children?: ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n}\n\nfunction ToolCallStatus({\n toolCall,\n inGroup,\n}: Pick<ChatToolCallProps, 'toolCall'> & { inGroup: boolean }) {\n const presentation = STATUS_PRESENTATIONS[toolCall.status];\n\n return (\n <ChatToolCallRowStatus\n label={presentation.label}\n status={presentation.status}\n elapsedMs={toolCall.elapsedMs}\n inGroup={inGroup}\n />\n );\n}\n\nexport function ChatToolCall({\n toolCall,\n variant = 'default',\n onInspect,\n inspectLabel,\n label,\n icon,\n summary,\n meta,\n children,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n}: ChatToolCallProps) {\n const inGroup = useReportToGroup({\n status: STATUS_PRESENTATIONS[toolCall.status].status,\n icon,\n });\n const summaryId = useId();\n const name = label ?? (toolCall.name || 'Tool');\n const resolvedIcon =\n icon === undefined ? <WrenchIcon size={12} weight=\"regular\" /> : icon;\n const heading = (\n <span className=\"inline-flex min-w-0 items-center gap-space-2\">\n {resolvedIcon != null && (\n <ChatToolCallIcon>{resolvedIcon}</ChatToolCallIcon>\n )}\n <Text\n as=\"span\"\n variant=\"xs\"\n weight=\"medium\"\n color=\"secondary\"\n className=\"min-w-0 truncate\"\n >\n {name}\n </Text>\n </span>\n );\n\n if (variant === 'simple') {\n return (\n <ChatToolCallStatusRow\n groupLabel={`${name} tool call`}\n heading={heading}\n status={<ToolCallStatus toolCall={toolCall} inGroup={inGroup} />}\n meta={meta}\n onInspect={onInspect}\n inspectLabel={inspectLabel}\n className={className}\n />\n );\n }\n\n const detailContent =\n children === undefined ? (\n <ChatToolCallDetails toolCall={toolCall} />\n ) : (\n children\n );\n const summaryContent =\n summary === undefined && toolCall.args !== undefined\n ? formatChatToolCallValue(toolCall.args, 120)\n : summary;\n\n return (\n <ChatToolCallAccordion\n groupLabel={`${name} tool call`}\n triggerLabel={`Details for ${name}`}\n triggerDescriptionId={summaryContent != null ? summaryId : undefined}\n detailsLabel={`${name} details`}\n heading={\n <>\n {heading}\n {summaryContent != null && (\n <Text\n id={summaryId}\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 truncate rounded-md bg-surface-level-2 px-space-1 py-0\"\n >\n {summaryContent}\n </Text>\n )}\n </>\n }\n status={<ToolCallStatus toolCall={toolCall} inGroup={inGroup} />}\n meta={meta}\n expanded={expanded}\n defaultExpanded={defaultExpanded}\n onExpandedChange={onExpandedChange}\n className={className}\n >\n {detailContent}\n </ChatToolCallAccordion>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,uBAAuB;CAC3B,SAAS;EAAE,OAAO;EAAW,QAAQ;CAAU;CAC/C,SAAS;EAAE,OAAO;EAAW,QAAQ;CAAY;CACjD,WAAW;EAAE,OAAO;EAAa,QAAQ;CAAY;CACrD,QAAQ;EAAE,OAAO;EAAU,QAAQ;CAAS;CAC5C,UAAU;EAAE,OAAO;EAAY,QAAQ;CAAW;CAClD,kBAAkB;EAAE,O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tB,SACE,qBAAA,YAAA,EAAA,UAAA,CACG,SACA,kBAAkB,QACjB,oBAAC,MAAD;GACE,IAAI;GACJ,IAAG;GACH,SAAQ;GACR,OAAM;GACN,WAAU;GAET,UAAA;EACG,CAAA,CAER,EAAA,CAAA;EAEJ,QAAQ,oBAAC,gBAAD;GAA0B;GAAmB;EAAU,CAAA;EACzD;EACI;EACO;EACC;EACP;EAEV,UAAA;CACoB,CAAA;AAE3B"}
1
+ {"version":3,"file":"ChatToolCall.js","names":[],"sources":["../../../src/components/ChatToolCall/ChatToolCall.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { WrenchIcon } from '@phosphor-icons/react/dist/ssr/Wrench';\n\nimport type { ChatStateStatus } from '../ChatState';\nimport { Text } from '../Text';\nimport type {\n ChatToolCallModel,\n ChatToolCallStatus,\n} from './ChatToolCall.types';\nimport { formatChatToolCallValue } from './ChatToolCall.value';\nimport { ChatToolCallAccordion } from './ChatToolCallAccordion';\nimport { ChatToolCallDetails } from './ChatToolCallDetails';\nimport { useReportToGroup } from './ChatToolCallGroupContext';\nimport { ChatToolCallIcon } from './ChatToolCallIcon';\nimport { ChatToolCallRowStatus } from './ChatToolCallRowStatus';\nimport { ChatToolCallStatusRow } from './ChatToolCallStatusRow';\n\nconst STATUS_PRESENTATIONS = {\n pending: { label: 'Pending', status: 'pending' },\n running: { label: 'Running', status: 'streaming' },\n succeeded: { label: 'Succeeded', status: 'completed' },\n failed: { label: 'Failed', status: 'failed' },\n canceled: { label: 'Canceled', status: 'canceled' },\n 'input-required': { label: 'Needs input', status: 'input-required' },\n} as const satisfies Record<\n ChatToolCallStatus,\n { label: string; status: ChatStateStatus }\n>;\n\nexport interface ChatToolCallProps {\n /** Render at the call's position in the host's ordered content stream. Use its stable ID as the React key. */\n toolCall: ChatToolCallModel;\n variant?: 'default' | 'simple';\n /** Simple row inspection; the host owns navigation, panes, and permissions. */\n onInspect?: () => void;\n /** Tooltip and accessible action label for Simple row inspection. */\n inspectLabel?: string;\n label?: string;\n /**\n * Leading 12px single-color icon, e.g. a product or provider mark. Undefined\n * uses a generic wrench; null omits the icon. Noninteractive presentation\n * slots; response controls belong in a separate content block.\n */\n icon?: ReactNode;\n /** Undefined previews args; null omits the summary. */\n summary?: ReactNode;\n /**\n * Trailing metadata before the status, such as a duration, an edit count,\n * or a link to related work. It sits outside the toggle, so it may hold\n * its own link or button; keep it short.\n */\n meta?: ReactNode;\n /** Undefined uses generic details; null omits the detail region. */\n children?: ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n className?: string;\n}\n\nfunction ToolCallStatus({\n toolCall,\n inGroup,\n}: Pick<ChatToolCallProps, 'toolCall'> & { inGroup: boolean }) {\n const presentation = STATUS_PRESENTATIONS[toolCall.status];\n\n return (\n <ChatToolCallRowStatus\n label={presentation.label}\n status={presentation.status}\n elapsedMs={toolCall.elapsedMs}\n inGroup={inGroup}\n />\n );\n}\n\nexport function ChatToolCall({\n toolCall,\n variant = 'default',\n onInspect,\n inspectLabel,\n label,\n icon,\n summary,\n meta,\n children,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n className,\n}: ChatToolCallProps) {\n const inGroup = useReportToGroup({\n status: STATUS_PRESENTATIONS[toolCall.status].status,\n icon,\n });\n const summaryId = useId();\n const name = label ?? (toolCall.name || 'Tool');\n const resolvedIcon =\n icon === undefined ? <WrenchIcon size={12} weight=\"regular\" /> : icon;\n const heading = (\n <span className=\"inline-flex min-w-0 max-w-full shrink-0 items-center gap-space-2\">\n {resolvedIcon != null && (\n <ChatToolCallIcon>{resolvedIcon}</ChatToolCallIcon>\n )}\n <Text\n as=\"span\"\n variant=\"xs\"\n weight=\"medium\"\n color=\"secondary\"\n className=\"min-w-0 whitespace-normal [overflow-wrap:anywhere]\"\n >\n {name}\n </Text>\n </span>\n );\n\n if (variant === 'simple') {\n return (\n <ChatToolCallStatusRow\n groupLabel={`${name} tool call`}\n heading={heading}\n status={<ToolCallStatus toolCall={toolCall} inGroup={inGroup} />}\n meta={meta}\n onInspect={onInspect}\n inspectLabel={inspectLabel}\n className={className}\n />\n );\n }\n\n const detailContent =\n children === undefined ? (\n <ChatToolCallDetails toolCall={toolCall} />\n ) : (\n children\n );\n const summaryContent =\n summary === undefined && toolCall.args !== undefined\n ? formatChatToolCallValue(toolCall.args, 120)\n : summary;\n\n return (\n <ChatToolCallAccordion\n groupLabel={`${name} tool call`}\n triggerLabel={`Details for ${name}`}\n triggerDescriptionId={summaryContent != null ? summaryId : undefined}\n detailsLabel={`${name} details`}\n heading={\n <>\n {heading}\n {summaryContent != null && (\n <Text\n id={summaryId}\n as=\"span\"\n variant=\"xs\"\n color=\"tertiary\"\n className=\"min-w-0 truncate rounded-md bg-surface-level-2 px-space-1 py-0\"\n >\n {summaryContent}\n </Text>\n )}\n </>\n }\n status={<ToolCallStatus toolCall={toolCall} inGroup={inGroup} />}\n meta={meta}\n expanded={expanded}\n defaultExpanded={defaultExpanded}\n onExpandedChange={onExpandedChange}\n className={className}\n >\n {detailContent}\n </ChatToolCallAccordion>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAM,uBAAuB;CAC3B,SAAS;EAAE,OAAO;EAAW,QAAQ;CAAU;CAC/C,SAAS;EAAE,OAAO;EAAW,QAAQ;CAAY;CACjD,WAAW;EAAE,OAAO;EAAa,QAAQ;CAAY;CACrD,QAAQ;EAAE,OAAO;EAAU,QAAQ;CAAS;CAC5C,UAAU;EAAE,OAAO;EAAY,QAAQ;CAAW;CAClD,kBAAkB;EAAE,OAAO;EAAe,QAAQ;CAAiB;AACrE;AAoCA,SAAS,eAAe,EACtB,UACA,WAC6D;CAC7D,MAAM,eAAe,qBAAqB,SAAS;CAEnD,OACE,oBAAC,uBAAD;EACE,OAAO,aAAa;EACpB,QAAQ,aAAa;EACrB,WAAW,SAAS;EACX;CACV,CAAA;AAEL;AAEA,SAAgB,aAAa,EAC3B,UACA,UAAU,WACV,WACA,cACA,OACA,M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B,CAAA;AAE3B"}
@@ -1,4 +1,5 @@
1
1
  import * as PopoverPrimitive from '@radix-ui/react-popover';
2
+ export type PopoverVariant = 'neutral' | 'info';
2
3
  export declare const Popover: import("react").FC<PopoverPrimitive.PopoverProps>;
3
4
  export declare const PopoverTrigger: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
4
5
  export declare const PopoverAnchor: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -10,4 +11,5 @@ export declare const PopoverContent: import("react").ForwardRefExoticComponent<O
10
11
  * mouse-interactive, and falls back to `document.body` otherwise.
11
12
  */
12
13
  container?: HTMLElement | null;
14
+ variant?: PopoverVariant;
13
15
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -4,30 +4,42 @@ import { useZIndex } from "../../utils/useZIndex.js";
4
4
  import { ZIndexProvider } from "../../utils/ZIndexContext.js";
5
5
  import { useDialogContainer } from "../Dialog/index.js";
6
6
  import { popoverSurfaceClassName } from "./constants.js";
7
- import { forwardRef } from "react";
7
+ import { createContext, forwardRef, useContext } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import * as PopoverPrimitive from "@radix-ui/react-popover";
10
10
  //#region packages/components/src/components/Popover/Popover.tsx
11
+ var PopoverVariantContext = createContext("neutral");
12
+ var surfaceByVariant = {
13
+ neutral: "bg-popover border-subtle",
14
+ info: "bg-brand-subtle border-brand-subtle"
15
+ };
16
+ var arrowByVariant = {
17
+ neutral: "fill-popover stroke-subtle",
18
+ info: "fill-[var(--bg-brand-subtle)] stroke-[var(--border-brand-subtle)]"
19
+ };
11
20
  var Popover = PopoverPrimitive.Root;
12
21
  var PopoverTrigger = PopoverPrimitive.Trigger;
13
22
  var PopoverAnchor = PopoverPrimitive.Anchor;
14
- var PopoverArrow = forwardRef(({ className, asChild, children, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Arrow, {
15
- ref,
16
- className: cn("overflow-visible fill-popover stroke-subtle", !asChild && "-translate-y-px", className),
17
- ...props,
18
- asChild: true,
19
- children: asChild ? children : /* @__PURE__ */ jsxs("svg", { children: [/* @__PURE__ */ jsx("polygon", {
20
- points: "0,0 30,0 15,10",
21
- stroke: "none"
22
- }), /* @__PURE__ */ jsx("polyline", {
23
- points: "0,0 15,10 30,0",
24
- fill: "none",
25
- strokeWidth: 1,
26
- vectorEffect: "non-scaling-stroke"
27
- })] })
28
- }));
23
+ var PopoverArrow = forwardRef(({ className, asChild, children, ...props }, ref) => {
24
+ const variant = useContext(PopoverVariantContext);
25
+ return /* @__PURE__ */ jsx(PopoverPrimitive.Arrow, {
26
+ ref,
27
+ className: cn("overflow-visible", arrowByVariant[variant], !asChild && "-translate-y-px", className),
28
+ ...props,
29
+ asChild: true,
30
+ children: asChild ? children : /* @__PURE__ */ jsxs("svg", { children: [/* @__PURE__ */ jsx("polygon", {
31
+ points: "0,0 30,0 15,10",
32
+ stroke: "none"
33
+ }), /* @__PURE__ */ jsx("polyline", {
34
+ points: "0,0 15,10 30,0",
35
+ fill: "none",
36
+ strokeWidth: 1,
37
+ vectorEffect: "non-scaling-stroke"
38
+ })] })
39
+ });
40
+ });
29
41
  PopoverArrow.displayName = "PopoverArrow";
30
- var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4, forceMount, container, children, ...props }, ref) => {
42
+ var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4, variant = "neutral", forceMount, container, children, ...props }, ref) => {
31
43
  const zIndex = useZIndex(zIndices.popover);
32
44
  const dialogContainer = useDialogContainer();
33
45
  return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, {
@@ -38,16 +50,19 @@ var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4,
38
50
  align,
39
51
  sideOffset,
40
52
  forceMount,
41
- className: cn(popoverSurfaceClassName, className),
53
+ className: cn(popoverSurfaceClassName, surfaceByVariant[variant], className),
42
54
  collisionBoundary: dialogContainer ?? void 0,
43
55
  ...props,
44
56
  style: {
45
57
  zIndex,
46
58
  ...props.style
47
59
  },
48
- children: /* @__PURE__ */ jsx(ZIndexProvider, {
49
- value: zIndex,
50
- children
60
+ children: /* @__PURE__ */ jsx(PopoverVariantContext.Provider, {
61
+ value: variant,
62
+ children: /* @__PURE__ */ jsx(ZIndexProvider, {
63
+ value: zIndex,
64
+ children
65
+ })
51
66
  })
52
67
  })
53
68
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef } from 'react';\nimport { forwardRef } from 'react';\n\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { useDialogContainer } from '../Dialog';\nimport { popoverSurfaceClassName } from './constants';\n\nexport const Popover = PopoverPrimitive.Root;\n\nexport const PopoverTrigger = PopoverPrimitive.Trigger;\nexport const PopoverAnchor = PopoverPrimitive.Anchor;\n\nexport const PopoverArrow = forwardRef<\n ElementRef<typeof PopoverPrimitive.Arrow>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>\n>(({ className, asChild, children, ...props }, ref) => (\n <PopoverPrimitive.Arrow\n ref={ref}\n className={cn(\n 'overflow-visible fill-popover stroke-subtle',\n !asChild && '-translate-y-px',\n className\n )}\n {...props}\n asChild\n >\n {asChild ? (\n children\n ) : (\n <svg>\n <polygon points=\"0,0 30,0 15,10\" stroke=\"none\" />\n <polyline\n points=\"0,0 15,10 30,0\"\n fill=\"none\"\n strokeWidth={1}\n vectorEffect=\"non-scaling-stroke\"\n />\n </svg>\n )}\n </PopoverPrimitive.Arrow>\n));\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport const PopoverContent = forwardRef<\n ElementRef<typeof PopoverPrimitive.Content>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {\n /**\n * Portal target for the popover. When omitted, the popover automatically\n * portals into the enclosing modal `Dialog` (if any) so it stays\n * mouse-interactive, and falls back to `document.body` otherwise.\n */\n container?: HTMLElement | null;\n }\n>(\n (\n {\n className,\n align = 'center',\n sideOffset = 4,\n forceMount,\n container,\n children,\n ...props\n },\n ref\n ) => {\n const zIndex = useZIndex(zIndices.popover);\n // Portal into the enclosing modal Dialog (null when not inside one) so the\n // popover stays inside the dialog's pointer-events-interactive region.\n const dialogContainer = useDialogContainer();\n\n return (\n <PopoverPrimitive.Portal\n forceMount={forceMount}\n // Fall back to `undefined` (not `null`) when there is no dialog: Radix's\n // Portal only defaults to `document.body` when `container` is absent, so\n // an explicit `null` leaves non-forceMount popovers unrendered.\n container={container ?? dialogContainer ?? undefined}\n >\n <PopoverPrimitive.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n forceMount={forceMount}\n className={cn(popoverSurfaceClassName, className)}\n collisionBoundary={dialogContainer ?? undefined}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n );\n }\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n"],"mappings":";;;;;;;;;;AAYA,IAAa,UAAU,iBAAiB;AAExC,IAAa,iBAAiB,iBAAiB;AAC/C,IAAa,gBAAgB,iBAAiB;AAE9C,IAAa,eAAe,YAGzB,EAAE,WAAW,SAAS,UAAU,GAAG,SAAS,QAC7C,oBAAC,iBAAiB,OAAlB;CACO;CACL,WAAW,GACT,+CACA,CAAC,WAAW,mBACZ,SACF;CACA,GAAI;CACJ,SAAA;CAEC,UAAA,UACC,WAEA,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,WAAD;EAAS,QAAO;EAAiB,QAAO;CAAQ,CAAA,GAChD,oBAAC,YAAD;EACE,QAAO;EACP,MAAK;EACL,aAAa;EACb,cAAa;CACd,CAAA,CACE,EAAA,CAAA;AAEe,CAAA,CACzB;AACD,aAAa,cAAc;AAE3B,IAAa,iBAAiB,YAY1B,EACE,WACA,QAAQ,UACR,aAAa,GACb,YACA,WACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,SAAS,UAAU,SAAS,OAAO;CAGzC,MAAM,kBAAkB,mBAAmB;CAE3C,OACE,oBAAC,iBAAiB,QAAlB;EACc;EAIZ,WAAW,aAAa,mBAAmB,KAAA;EAE3C,UAAA,oBAAC,iBAAiB,SAAlB;GACO;GACE;GACK;GACA;GACZ,WAAW,GAAG,yBAAyB,SAAS;GAChD,mBAAmB,mBAAmB,KAAA;GACtC,GAAI;GACJ,OAAO;IAAE;IAAQ,GAAG,MAAM;GAAM;GAEhC,UAAA,oBAAC,gBAAD;IAAgB,OAAO;IAAS;GAAyB,CAAA;EACjC,CAAA;CACH,CAAA;AAE7B,CACF;AACA,eAAe,cAAc,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"Popover.js","names":[],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef } from 'react';\nimport { createContext, forwardRef, useContext } from 'react';\n\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { useDialogContainer } from '../Dialog';\nimport { popoverSurfaceClassName } from './constants';\n\nexport type PopoverVariant = 'neutral' | 'info';\n\nconst PopoverVariantContext = createContext<PopoverVariant>('neutral');\n\nconst surfaceByVariant = {\n neutral: 'bg-popover border-subtle',\n info: 'bg-brand-subtle border-brand-subtle',\n};\n\nconst arrowByVariant = {\n neutral: 'fill-popover stroke-subtle',\n info: 'fill-[var(--bg-brand-subtle)] stroke-[var(--border-brand-subtle)]',\n};\n\nexport const Popover = PopoverPrimitive.Root;\n\nexport const PopoverTrigger = PopoverPrimitive.Trigger;\nexport const PopoverAnchor = PopoverPrimitive.Anchor;\n\nexport const PopoverArrow = forwardRef<\n ElementRef<typeof PopoverPrimitive.Arrow>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>\n>(({ className, asChild, children, ...props }, ref) => {\n const variant = useContext(PopoverVariantContext);\n return (\n <PopoverPrimitive.Arrow\n ref={ref}\n className={cn(\n 'overflow-visible',\n arrowByVariant[variant],\n !asChild && '-translate-y-px',\n className\n )}\n {...props}\n asChild\n >\n {asChild ? (\n children\n ) : (\n <svg>\n <polygon points=\"0,0 30,0 15,10\" stroke=\"none\" />\n <polyline\n points=\"0,0 15,10 30,0\"\n fill=\"none\"\n strokeWidth={1}\n vectorEffect=\"non-scaling-stroke\"\n />\n </svg>\n )}\n </PopoverPrimitive.Arrow>\n );\n});\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport const PopoverContent = forwardRef<\n ElementRef<typeof PopoverPrimitive.Content>,\n ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {\n /**\n * Portal target for the popover. When omitted, the popover automatically\n * portals into the enclosing modal `Dialog` (if any) so it stays\n * mouse-interactive, and falls back to `document.body` otherwise.\n */\n container?: HTMLElement | null;\n variant?: PopoverVariant;\n }\n>(\n (\n {\n className,\n align = 'center',\n sideOffset = 4,\n variant = 'neutral',\n forceMount,\n container,\n children,\n ...props\n },\n ref\n ) => {\n const zIndex = useZIndex(zIndices.popover);\n // Portal into the enclosing modal Dialog (null when not inside one) so the\n // popover stays inside the dialog's pointer-events-interactive region.\n const dialogContainer = useDialogContainer();\n\n return (\n <PopoverPrimitive.Portal\n forceMount={forceMount}\n // Fall back to `undefined` (not `null`) when there is no dialog: Radix's\n // Portal only defaults to `document.body` when `container` is absent, so\n // an explicit `null` leaves non-forceMount popovers unrendered.\n container={container ?? dialogContainer ?? undefined}\n >\n <PopoverPrimitive.Content\n ref={ref}\n align={align}\n sideOffset={sideOffset}\n forceMount={forceMount}\n className={cn(\n popoverSurfaceClassName,\n surfaceByVariant[variant],\n className\n )}\n collisionBoundary={dialogContainer ?? undefined}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <PopoverVariantContext.Provider value={variant}>\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </PopoverVariantContext.Provider>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n );\n }\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n"],"mappings":";;;;;;;;;;AAcA,IAAM,wBAAwB,cAA8B,SAAS;AAErE,IAAM,mBAAmB;CACvB,SAAS;CACT,MAAM;AACR;AAEA,IAAM,iBAAiB;CACrB,SAAS;CACT,MAAM;AACR;AAEA,IAAa,UAAU,iBAAiB;AAExC,IAAa,iBAAiB,iBAAiB;AAC/C,IAAa,gBAAgB,iBAAiB;AAE9C,IAAa,eAAe,YAGzB,EAAE,WAAW,SAAS,UAAU,GAAG,SAAS,QAAQ;CACrD,MAAM,UAAU,WAAW,qBAAqB;CAChD,OACE,oBAAC,iBAAiB,OAAlB;EACO;EACL,WAAW,GACT,oBACA,eAAe,UACf,CAAC,WAAW,mBACZ,SACF;EACA,GAAI;EACJ,SAAA;EAEC,UAAA,UACC,WAEA,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,WAAD;GAAS,QAAO;GAAiB,QAAO;EAAQ,CAAA,GAChD,oBAAC,YAAD;GACE,QAAO;GACP,MAAK;GACL,aAAa;GACb,cAAa;EACd,CAAA,CACE,EAAA,CAAA;CAEe,CAAA;AAE5B,CAAC;AACD,aAAa,cAAc;AAE3B,IAAa,iBAAiB,YAa1B,EACE,WACA,QAAQ,UACR,aAAa,GACb,UAAU,WACV,YACA,WACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,SAAS,UAAU,SAAS,OAAO;CAGzC,MAAM,kBAAkB,mBAAmB;CAE3C,OACE,oBAAC,iBAAiB,QAAlB;EACc;EAIZ,WAAW,aAAa,mBAAmB,KAAA;EAE3C,UAAA,oBAAC,iBAAiB,SAAlB;GACO;GACE;GACK;GACA;GACZ,WAAW,GACT,yBACA,iBAAiB,UACjB,SACF;GACA,mBAAmB,mBAAmB,KAAA;GACtC,GAAI;GACJ,OAAO;IAAE;IAAQ,GAAG,MAAM;GAAM;GAEhC,UAAA,oBAAC,sBAAsB,UAAvB;IAAgC,OAAO;IACrC,UAAA,oBAAC,gBAAD;KAAgB,OAAO;KAAS;IAAyB,CAAA;GAC3B,CAAA;EACR,CAAA;CACH,CAAA;AAE7B,CACF;AACA,eAAe,cAAc,iBAAiB,QAAQ"}
@@ -1 +1,2 @@
1
+ export type { PopoverVariant } from './Popover.js';
1
2
  export { Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, } from './Popover.js';
@@ -17,7 +17,7 @@ var VIEWBOX_WIDTH = 440;
17
17
  var VIEWBOX_HEIGHT = 340;
18
18
  var CENTER_X = VIEWBOX_WIDTH / 2;
19
19
  var CENTER_Y = VIEWBOX_HEIGHT / 2;
20
- var RADIUS = 96;
20
+ var RADIUS = 106;
21
21
  var LABEL_RADIUS = 116;
22
22
  var LABEL_WIDTH = 100;
23
23
  var LABEL_LINE_HEIGHT = 20;
@@ -60,6 +60,7 @@ var getAxisLayouts = (axes, labelHeight) => axes.map(({ id }, index) => {
60
60
  labelX: CENTER_X + unitX * LABEL_RADIUS - side.offset,
61
61
  labelY: CENTER_Y + unitY * LABEL_RADIUS - (isAbove ? labelHeight : isBelow ? 0 : labelHeight / 2),
62
62
  align: side.align,
63
+ justify: isAbove ? "justify-end" : isBelow ? "justify-start" : "justify-center",
63
64
  tooltipSide: isAbove ? "top" : isBelow ? "bottom" : unitX < 0 ? "left" : "right",
64
65
  tooltipAlign: isAbove || isBelow ? side.tooltipAlign : "center"
65
66
  };
@@ -120,7 +121,7 @@ var RadarChart = (props) => {
120
121
  width: LABEL_WIDTH,
121
122
  height,
122
123
  children: /* @__PURE__ */ jsx("div", {
123
- className: cn("flex h-full flex-col justify-center", layout.align),
124
+ className: cn("flex h-full flex-col", layout.justify, layout.align),
124
125
  title: isInteractive ? void 0 : summary,
125
126
  children: lines
126
127
  })
@@ -176,7 +177,7 @@ var RadarChart = (props) => {
176
177
  /* @__PURE__ */ jsx("circle", {
177
178
  cx: pointX,
178
179
  cy: pointY,
179
- r: 8,
180
+ r: 6,
180
181
  fill: "none",
181
182
  stroke: datum.color,
182
183
  strokeWidth: 1.5,
@@ -192,12 +193,12 @@ var RadarChart = (props) => {
192
193
  }),
193
194
  renderLabel(layout, labelHeight, summary, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {
194
195
  variant: "xs",
195
- className: "truncate",
196
+ className: "truncate leading-tight",
196
197
  children: datum.label
197
198
  }), /* @__PURE__ */ jsx(Text, {
198
199
  variant: "xs",
199
200
  color: "secondary",
200
- className: "truncate tabular-nums",
201
+ className: "truncate leading-tight tabular-nums",
201
202
  children: formattedValue
202
203
  })] }))
203
204
  ]
@@ -290,7 +291,7 @@ var RadarChart = (props) => {
290
291
  }),
291
292
  renderLabel(layout, LABEL_LINE_HEIGHT, summary, /* @__PURE__ */ jsx(Text, {
292
293
  variant: "xs",
293
- className: "truncate",
294
+ className: "truncate leading-tight",
294
295
  children: axis.label
295
296
  }))
296
297
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"RadarChart.js","names":[],"sources":["../../../src/components/RadarChart/RadarChart.tsx"],"sourcesContent":["import {\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport {\n CHART_SINGLE_FILL_COLOR,\n getCategoricalFillChartColor,\n getCategoricalFillColor,\n getCategoricalLineChartColor,\n} from '../../utils/chartColors';\nimport { CHART_DIMMED_OPACITY } from '../../utils/chartConstants';\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { ChartTooltip } from '../ChartTooltip';\nimport { Text } from '../Text';\n\nexport type RadarChartDatum = {\n /** Unique, stable identifier for this axis. */\n id: string;\n label: string;\n value: number;\n /** Semantic chart color; defaults to the categorical fill palette in axis order. */\n color?: string;\n};\n\nexport type RadarChartAxis = {\n /** Unique, stable identifier; keys each series' `values`. */\n id: string;\n label: string;\n};\n\nexport type RadarChartSeries = {\n /** Unique, stable identifier; use it as the matching legend item's id. */\n id: string;\n label: string;\n /** Values keyed by axis id. Missing, negative, and non-finite values plot at zero. */\n values: Readonly<Record<string, number | undefined>>;\n /**\n * Outline color; defaults to the categorical line palette in series order.\n * The area uses the hue-matched fill color.\n */\n color?: string;\n};\n\n/** One axis and every visible series' value on it, for multi-series tooltips. */\nexport type RadarChartAxisValues = RadarChartAxis & {\n /** Visible series in input order, with sanitized values and outline colors. */\n values: readonly {\n id: string;\n label: string;\n value: number;\n color: string;\n }[];\n};\n\ntype RadarChartBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** Shared axis maximum; defaults to the largest finite positive value. */\n maxValue?: number;\n /** Formats labels and the accessible data summary. */\n formatValue?: (value: number) => string;\n};\n\nexport type RadarChartSingleSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n data: readonly RadarChartDatum[];\n /**\n * Content inside ChartTooltip on point or label hover and keyboard focus.\n * Receives the sanitized value and resolved color. Compose ChartTooltipHeader,\n * ChartTooltipBody, and ChartTooltipRow here; omit for a static chart.\n */\n renderTooltip?: (datum: RadarChartDatum) => ReactNode;\n axes?: never;\n series?: never;\n renderAxisTooltip?: never;\n selectedIds?: never;\n excludedIds?: never;\n activeLegendItemId?: never;\n};\n\nexport type RadarChartMultiSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n axes: readonly RadarChartAxis[];\n /**\n * Overlapping areas on the shared axes, drawn in input order. Keep to about\n * four; beyond that, filter series or use small multiples.\n */\n series: readonly RadarChartSeries[];\n /**\n * Content inside ChartTooltip when an axis is hovered anywhere in its sector\n * or focused. Compose one ChartTooltipRow per series; omit for a static chart.\n */\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode;\n /** When non-empty, only these series are drawn. Colors keep their series order. */\n selectedIds?: ReadonlySet<string>;\n /** Series left out, whatever `selectedIds` holds. */\n excludedIds?: ReadonlySet<string>;\n /** Emphasizes one series from an external legend and dims the rest. */\n activeLegendItemId?: string | null;\n data?: never;\n renderTooltip?: never;\n};\n\nexport type RadarChartProps =\n | RadarChartSingleSeriesProps\n | RadarChartMultiSeriesProps;\n\ntype AxisLayout = {\n id: string;\n unitX: number;\n unitY: number;\n labelX: number;\n labelY: number;\n align: 'text-left' | 'text-center' | 'text-right';\n tooltipSide: 'top' | 'right' | 'bottom' | 'left';\n tooltipAlign: 'start' | 'center' | 'end';\n};\n\nconst numberFormatter = new Intl.NumberFormat('en-US');\nconst formatNumber = (value: number) => numberFormatter.format(value);\nconst sanitize = (value: number | undefined) =>\n value !== undefined && Number.isFinite(value) ? Math.max(0, value) : 0;\n// Layout uses SVG units, which scale together with the viewBox. This canvas\n// fits the plot plus outside labels, with extra width for horizontal text.\nconst VIEWBOX_WIDTH = 440;\nconst VIEWBOX_HEIGHT = 340;\nconst CENTER_X = VIEWBOX_WIDTH / 2;\nconst CENTER_Y = VIEWBOX_HEIGHT / 2;\n// A 96-unit plot leaves room for a 20-unit gap and the two-line label boxes.\nconst RADIUS = 96;\nconst LABEL_RADIUS = RADIUS + 20;\n// Reserve 100 units for truncated names and 20 per text line: single-series\n// labels pair the name with its value; multi-series labels show the name.\nconst LABEL_WIDTH = 100;\nconst LABEL_LINE_HEIGHT = 20;\n// Labels left of center end at their axis; labels right of it start there.\nconst LABEL_SIDES = {\n left: { offset: LABEL_WIDTH, align: 'text-right', tooltipAlign: 'start' },\n center: {\n offset: LABEL_WIDTH / 2,\n align: 'text-center',\n tooltipAlign: 'center',\n },\n right: { offset: 0, align: 'text-left', tooltipAlign: 'end' },\n} as const;\n// Absorb trig rounding at alignment boundaries so mirrored labels line up.\nconst ALIGNMENT_EPSILON = 1e-6;\n// Four equally spaced rings represent fractions of the shared axis maximum.\nconst GRID_LEVELS = [0.25, 0.5, 0.75, 1];\n// Overlapping areas lead with their outlines: a faint wash keeps stacked\n// areas from mixing into a muddy tint. While one series is emphasized, it\n// alone keeps a fill, and the other series recede to dimmed outlines.\nconst SERIES_FILL_OPACITY = 0.08;\nconst EMPHASIZED_SERIES_FILL_OPACITY = 0.2;\n\nconst getAxisLayouts = (\n axes: readonly { id: string }[],\n labelHeight: number\n): AxisLayout[] =>\n axes.map(({ id }, index) => {\n const angle = (index * Math.PI * 2) / axes.length - Math.PI / 2;\n const unitX = Math.cos(angle);\n const unitY = Math.sin(angle);\n // Center labels within ~6 degrees of vertical (|cos| <= 0.1).\n const side =\n LABEL_SIDES[unitX < -0.1 ? 'left' : unitX > 0.1 ? 'right' : 'center'];\n // At 30 degrees or more above/below horizontal (|sin| >= 0.5), place the\n // whole label box outside the axis instead of straddling it.\n const isAbove = unitY <= -0.5 + ALIGNMENT_EPSILON;\n const isBelow = unitY >= 0.5 - ALIGNMENT_EPSILON;\n return {\n id,\n unitX,\n unitY,\n labelX: CENTER_X + unitX * LABEL_RADIUS - side.offset,\n labelY:\n CENTER_Y +\n unitY * LABEL_RADIUS -\n (isAbove ? labelHeight : isBelow ? 0 : labelHeight / 2),\n align: side.align,\n // Open outward, past the label and away from the plot.\n tooltipSide: isAbove\n ? 'top'\n : isBelow\n ? 'bottom'\n : unitX < 0\n ? 'left'\n : 'right',\n tooltipAlign: isAbove || isBelow ? side.tooltipAlign : 'center',\n };\n });\n\nconst getPoint = (axis: AxisLayout, ratio: number): [number, number] => [\n CENTER_X + axis.unitX * RADIUS * ratio,\n CENTER_Y + axis.unitY * RADIUS * ratio,\n];\n\nconst toPoints = (points: readonly (readonly [number, number])[]) =>\n points.map(([x, y]) => `${x},${y}`).join(' ');\n\nconst getMaximum = (values: readonly number[], maxValue?: number) =>\n maxValue !== undefined && Number.isFinite(maxValue) && maxValue > 0\n ? maxValue\n : values.reduce((largest, value) => Math.max(largest, value), 0) || 1;\n\n/**\n * A radar with a shared scale and clockwise, outside axis labels. Pass `data`\n * for one series with categorical points, or `axes` and `series` for\n * overlapping areas identified by an external legend.\n */\nexport const RadarChart = (props: RadarChartProps) => {\n // Mode-specific props are read from `props` so TypeScript narrows them by\n // mode; they are destructured here only to keep them off the wrapper div.\n const {\n data: _data,\n axes: _axes,\n series: _series,\n renderTooltip: _renderTooltip,\n renderAxisTooltip: _renderAxisTooltip,\n selectedIds,\n excludedIds,\n activeLegendItemId,\n maxValue,\n formatValue = formatNumber,\n className,\n 'aria-label': ariaLabel = 'Radar chart',\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...divProps\n } = props;\n const summaryId = useId();\n const [activeTooltip, setActiveTooltip] = useState<string | null>(null);\n const isPointerDownRef = useRef(false);\n const tooltipZIndex = useZIndex(zIndices.tooltip);\n const isInteractive =\n (props.series !== undefined\n ? props.renderAxisTooltip\n : props.renderTooltip) !== undefined;\n\n const withTooltip = (\n id: string,\n mark: ReactElement,\n content: ReactNode,\n layout?: AxisLayout\n ) => (\n <TooltipPrimitive.Root\n key={id}\n open={activeTooltip === id}\n onOpenChange={(open) =>\n setActiveTooltip((active) =>\n open ? id : active === id ? null : active\n )\n }\n >\n <TooltipPrimitive.Trigger\n asChild\n onPointerDown={(event) => {\n isPointerDownRef.current = true;\n event.currentTarget.ownerDocument.addEventListener(\n 'pointerup',\n () => {\n isPointerDownRef.current = false;\n },\n { once: true }\n );\n }}\n onFocus={(event) => {\n // Wait for keyboard focus to scroll an offscreen axis into\n // view; otherwise Radix closes the tooltip on that scroll.\n // Like Radix, focus from a pointer press stays closed.\n event.preventDefault();\n if (isPointerDownRef.current) return;\n const target = event.currentTarget;\n requestAnimationFrame(() => {\n if (target === target.ownerDocument.activeElement) {\n setActiveTooltip(id);\n }\n });\n }}\n >\n {mark}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n asChild\n side={layout?.tooltipSide}\n align={layout?.tooltipAlign}\n // Leave an 8px gap from the trigger and viewport edges.\n sideOffset={8}\n collisionPadding={8}\n >\n <ChartTooltip style={{ zIndex: tooltipZIndex }}>\n <ZIndexProvider value={tooltipZIndex}>{content}</ZIndexProvider>\n </ChartTooltip>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n\n const renderLabel = (\n layout: AxisLayout,\n height: number,\n summary: string,\n lines: ReactNode\n ) => (\n <foreignObject\n x={layout.labelX}\n y={layout.labelY}\n width={LABEL_WIDTH}\n height={height}\n >\n <div\n className={cn('flex h-full flex-col justify-center', layout.align)}\n title={isInteractive ? undefined : summary}\n >\n {lines}\n </div>\n </foreignObject>\n );\n\n const renderSingleSeries = (\n data: readonly RadarChartDatum[],\n renderDatumTooltip?: (datum: RadarChartDatum) => ReactNode\n ) => {\n const labelHeight = LABEL_LINE_HEIGHT * 2;\n const layouts = getAxisLayouts(data, labelHeight);\n const values = data.map(({ value }) => sanitize(value));\n const maximum = getMaximum(values, maxValue);\n const axes = data.map((datum, index) => {\n const value = values[index];\n const formattedValue = formatValue(value);\n return {\n layout: layouts[index],\n datum: {\n ...datum,\n value,\n color: datum.color ?? getCategoricalFillChartColor(index),\n },\n formattedValue,\n summary: `${datum.label}: ${formattedValue}`,\n point: getPoint(layouts[index], Math.min(1, value / maximum)),\n };\n });\n\n return {\n layouts,\n summary: axes.map(({ summary }) => summary).join('; '),\n marks: (\n <>\n <polygon\n aria-hidden=\"true\"\n points={toPoints(axes.map(({ point }) => point))}\n fill={CHART_SINGLE_FILL_COLOR}\n // A light wash and subdued outline keep the category points prominent.\n // Dark surfaces need slightly more opacity to preserve the shape.\n className=\"dark:[fill-opacity:0.24] dark:[stroke-opacity:0.8]\"\n fillOpacity={0.16}\n stroke={getCategoricalLineChartColor(0)}\n strokeOpacity={0.55}\n strokeWidth={1.25}\n strokeLinejoin=\"round\"\n />\n {axes.map(({ layout, datum, formattedValue, summary, point }) => {\n const [pointX, pointY] = point;\n const mark = (\n <g\n key={datum.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* A 24-unit hit target surrounds the 8-unit point; the\n 16-unit ring shows hover in the axis color and keyboard\n focus in the shared focus color without changing layout. */}\n <circle cx={pointX} cy={pointY} r={12} fill=\"transparent\" />\n <circle\n cx={pointX}\n cy={pointY}\n r={8}\n fill=\"none\"\n stroke={datum.color}\n strokeWidth={1.5}\n className=\"opacity-0 group-hover:opacity-100 group-focus-visible:stroke-focus group-focus-visible:opacity-100\"\n />\n <circle\n cx={pointX}\n cy={pointY}\n r={4}\n fill={datum.color}\n // A thin surface-colored separator avoids heavy dark borders.\n className=\"stroke-surface-level-1\"\n strokeWidth={1}\n />\n {renderLabel(\n layout,\n labelHeight,\n summary,\n <>\n <Text variant=\"xs\" className=\"truncate\">\n {datum.label}\n </Text>\n <Text\n variant=\"xs\"\n color=\"secondary\"\n className=\"truncate tabular-nums\"\n >\n {formattedValue}\n </Text>\n </>\n )}\n </g>\n );\n return renderDatumTooltip\n ? withTooltip(datum.id, mark, renderDatumTooltip(datum))\n : mark;\n })}\n </>\n ),\n };\n };\n\n const renderMultiSeries = (\n axes: readonly RadarChartAxis[],\n series: readonly RadarChartSeries[],\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode\n ) => {\n const layouts = getAxisLayouts(axes, LABEL_LINE_HEIGHT);\n // Resolve colors before filtering so each series keeps its hue.\n const resolvedSeries = series.map((item, index) => {\n const color = item.color ?? getCategoricalLineChartColor(index);\n return {\n id: item.id,\n label: item.label,\n color,\n fill: getCategoricalFillColor(color),\n values: axes.map(({ id }) => sanitize(item.values[id])),\n };\n });\n const visibleSeries = resolvedSeries.filter(\n ({ id }) =>\n (selectedIds === undefined ||\n selectedIds.size === 0 ||\n selectedIds.has(id)) &&\n !excludedIds?.has(id)\n );\n const maximum = getMaximum(\n visibleSeries.flatMap(({ values }) => values),\n maxValue\n );\n const plottedSeries = visibleSeries.map((item) => ({\n ...item,\n points: item.values.map((value, index) =>\n getPoint(layouts[index], Math.min(1, value / maximum))\n ),\n }));\n const emphasizedId = plottedSeries.some(\n ({ id }) => id === activeLegendItemId\n )\n ? activeLegendItemId\n : null;\n const getSeriesOpacity = (id: string) =>\n emphasizedId != null && id !== emphasizedId ? CHART_DIMMED_OPACITY : 1;\n\n return {\n layouts,\n summary: plottedSeries\n .map(\n (item) =>\n `${item.label}: ${axes\n .map(\n (axis, index) =>\n `${axis.label} ${formatValue(item.values[index])}`\n )\n .join(', ')}`\n )\n .join('; '),\n marks: (\n <>\n {/* Draw the emphasized series last so its outline sits on top. */}\n {[\n ...plottedSeries.filter(({ id }) => id !== emphasizedId),\n ...plottedSeries.filter(({ id }) => id === emphasizedId),\n ].map((item) => {\n const isEmphasized = item.id === emphasizedId;\n return (\n <polygon\n key={item.id}\n aria-hidden=\"true\"\n points={toPoints(item.points)}\n fill={item.fill}\n fillOpacity={\n isEmphasized\n ? EMPHASIZED_SERIES_FILL_OPACITY\n : emphasizedId == null\n ? SERIES_FILL_OPACITY\n : 0\n }\n className=\"transition-[opacity,fill-opacity] duration-fast motion-reduce:transition-none\"\n opacity={getSeriesOpacity(item.id)}\n stroke={item.color}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n />\n );\n })}\n {axes.map((axis, index) => {\n const layout = layouts[index];\n const values = plottedSeries.map((item) => ({\n id: item.id,\n label: item.label,\n value: item.values[index],\n color: item.color,\n }));\n const summary = values.length\n ? `${axis.label}: ${values\n .map(({ label, value }) => `${label} ${formatValue(value)}`)\n .join(', ')}`\n : axis.label;\n const [outerX, outerY] = getPoint(layout, 1);\n const [previousX, previousY] = getPoint(\n layouts[(index - 1 + layouts.length) % layouts.length],\n 1\n );\n const [nextX, nextY] = getPoint(\n layouts[(index + 1) % layouts.length],\n 1\n );\n const mark = (\n <g\n key={axis.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* Each axis owns the sector between its neighbors' edge\n midpoints, so hovering anywhere in the plot inspects the\n nearest axis. */}\n <polygon\n points={toPoints([\n [CENTER_X, CENTER_Y],\n [(previousX + outerX) / 2, (previousY + outerY) / 2],\n [outerX, outerY],\n [(outerX + nextX) / 2, (outerY + nextY) / 2],\n ])}\n fill=\"transparent\"\n />\n {/* Hover strengthens the spoke and reveals each series'\n vertex; keyboard focus uses the shared focus color. */}\n <g className=\"opacity-0 transition-opacity duration-fast group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none\">\n <line\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={outerX}\n y2={outerY}\n stroke=\"var(--border-default)\"\n className=\"group-focus-visible:stroke-focus\"\n />\n {plottedSeries.map((item) => (\n <circle\n key={item.id}\n cx={item.points[index][0]}\n cy={item.points[index][1]}\n r={3.5}\n fill={item.color}\n opacity={getSeriesOpacity(item.id)}\n // A surface-colored separator keeps coincident vertices distinct.\n className=\"stroke-surface-level-1\"\n strokeWidth={1.5}\n />\n ))}\n </g>\n {renderLabel(\n layout,\n LABEL_LINE_HEIGHT,\n summary,\n <Text variant=\"xs\" className=\"truncate\">\n {axis.label}\n </Text>\n )}\n </g>\n );\n return renderAxisTooltip\n ? withTooltip(\n axis.id,\n mark,\n renderAxisTooltip({ id: axis.id, label: axis.label, values }),\n layout\n )\n : mark;\n })}\n </>\n ),\n };\n };\n\n const axisCount = (props.series !== undefined ? props.axes : props.data)\n .length;\n const chart =\n axisCount < 3\n ? null\n : props.series !== undefined\n ? renderMultiSeries(props.axes, props.series, props.renderAxisTooltip)\n : renderSingleSeries(props.data, props.renderTooltip);\n\n return (\n <div className={cn('w-full overflow-x-auto', className)} {...divProps}>\n {chart === null ? (\n <div className=\"flex h-80 items-center justify-center\" role=\"status\">\n <Text variant=\"sm\" color=\"secondary\">\n At least three axes are needed to display a radar chart.\n </Text>\n </div>\n ) : (\n <TooltipPrimitive.Provider\n // Brief hover delay avoids flashes when crossing between axes.\n delayDuration={150}\n >\n <svg\n viewBox={`0 0 ${VIEWBOX_WIDTH} ${VIEWBOX_HEIGHT}`}\n className=\"block w-full\"\n // Preserve the labels' base font size; narrow containers scroll.\n style={{ minWidth: VIEWBOX_WIDTH }}\n role={isInteractive ? 'group' : 'img'}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[summaryId, ariaDescribedBy]\n .filter(Boolean)\n .join(' ')}\n >\n <desc id={summaryId}>{chart.summary}</desc>\n <g aria-hidden=\"true\" fill=\"none\" stroke=\"var(--border-subtle)\">\n {GRID_LEVELS.map((level) => (\n <polygon\n key={level}\n points={toPoints(\n chart.layouts.map((layout) => getPoint(layout, level))\n )}\n />\n ))}\n {chart.layouts.map((layout) => {\n const [x, y] = getPoint(layout, 1);\n return (\n <line\n key={layout.id}\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={x}\n y2={y}\n />\n );\n })}\n </g>\n {chart.marks}\n </svg>\n </TooltipPrimitive.Provider>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA8HA,IAAM,kBAAkB,IAAI,KAAK,aAAa,OAAO;AACrD,IAAM,gBAAgB,UAAkB,gBAAgB,OAAO,KAAK;AACpE,IAAM,YAAY,UAChB,UAAU,KAAA,KAAa,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAGvE,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,WAAW,gBAAgB;AACjC,IAAM,WAAW,iBAAiB;AAElC,IAAM,SAAS;AACf,IAAM,eAAe;AAGrB,IAAM,cAAc;AACpB,IA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QAEE,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,IAAI;OACL,GALM,OAAO,EAKb;MAEL,CAAC,CACA;;KACF,MAAM;IACJ;;EACoB,CAAA;CAE1B,CAAA;AAET"}
1
+ {"version":3,"file":"RadarChart.js","names":[],"sources":["../../../src/components/RadarChart/RadarChart.tsx"],"sourcesContent":["import {\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport {\n CHART_SINGLE_FILL_COLOR,\n getCategoricalFillChartColor,\n getCategoricalFillColor,\n getCategoricalLineChartColor,\n} from '../../utils/chartColors';\nimport { CHART_DIMMED_OPACITY } from '../../utils/chartConstants';\nimport { cn } from '../../utils/cn';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { ChartTooltip } from '../ChartTooltip';\nimport { Text } from '../Text';\n\nexport type RadarChartDatum = {\n /** Unique, stable identifier for this axis. */\n id: string;\n label: string;\n value: number;\n /** Semantic chart color; defaults to the categorical fill palette in axis order. */\n color?: string;\n};\n\nexport type RadarChartAxis = {\n /** Unique, stable identifier; keys each series' `values`. */\n id: string;\n label: string;\n};\n\nexport type RadarChartSeries = {\n /** Unique, stable identifier; use it as the matching legend item's id. */\n id: string;\n label: string;\n /** Values keyed by axis id. Missing, negative, and non-finite values plot at zero. */\n values: Readonly<Record<string, number | undefined>>;\n /**\n * Outline color; defaults to the categorical line palette in series order.\n * The area uses the hue-matched fill color.\n */\n color?: string;\n};\n\n/** One axis and every visible series' value on it, for multi-series tooltips. */\nexport type RadarChartAxisValues = RadarChartAxis & {\n /** Visible series in input order, with sanitized values and outline colors. */\n values: readonly {\n id: string;\n label: string;\n value: number;\n color: string;\n }[];\n};\n\ntype RadarChartBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** Shared axis maximum; defaults to the largest finite positive value. */\n maxValue?: number;\n /** Formats labels and the accessible data summary. */\n formatValue?: (value: number) => string;\n};\n\nexport type RadarChartSingleSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n data: readonly RadarChartDatum[];\n /**\n * Content inside ChartTooltip on point or label hover and keyboard focus.\n * Receives the sanitized value and resolved color. Compose ChartTooltipHeader,\n * ChartTooltipBody, and ChartTooltipRow here; omit for a static chart.\n */\n renderTooltip?: (datum: RadarChartDatum) => ReactNode;\n axes?: never;\n series?: never;\n renderAxisTooltip?: never;\n selectedIds?: never;\n excludedIds?: never;\n activeLegendItemId?: never;\n};\n\nexport type RadarChartMultiSeriesProps = RadarChartBaseProps & {\n /** Axes in clockwise order, beginning at the top. Supply at least three. */\n axes: readonly RadarChartAxis[];\n /**\n * Overlapping areas on the shared axes, drawn in input order. Keep to about\n * four; beyond that, filter series or use small multiples.\n */\n series: readonly RadarChartSeries[];\n /**\n * Content inside ChartTooltip when an axis is hovered anywhere in its sector\n * or focused. Compose one ChartTooltipRow per series; omit for a static chart.\n */\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode;\n /** When non-empty, only these series are drawn. Colors keep their series order. */\n selectedIds?: ReadonlySet<string>;\n /** Series left out, whatever `selectedIds` holds. */\n excludedIds?: ReadonlySet<string>;\n /** Emphasizes one series from an external legend and dims the rest. */\n activeLegendItemId?: string | null;\n data?: never;\n renderTooltip?: never;\n};\n\nexport type RadarChartProps =\n | RadarChartSingleSeriesProps\n | RadarChartMultiSeriesProps;\n\ntype AxisLayout = {\n id: string;\n unitX: number;\n unitY: number;\n labelX: number;\n labelY: number;\n align: 'text-left' | 'text-center' | 'text-right';\n /** Labels above or below the plot sit against the box edge facing it. */\n justify: 'justify-start' | 'justify-center' | 'justify-end';\n tooltipSide: 'top' | 'right' | 'bottom' | 'left';\n tooltipAlign: 'start' | 'center' | 'end';\n};\n\nconst numberFormatter = new Intl.NumberFormat('en-US');\nconst formatNumber = (value: number) => numberFormatter.format(value);\nconst sanitize = (value: number | undefined) =>\n value !== undefined && Number.isFinite(value) ? Math.max(0, value) : 0;\n// Layout uses SVG units, which scale together with the viewBox. This canvas\n// fits the plot plus outside labels, with extra width for horizontal text.\nconst VIEWBOX_WIDTH = 440;\nconst VIEWBOX_HEIGHT = 340;\nconst CENTER_X = VIEWBOX_WIDTH / 2;\nconst CENTER_Y = VIEWBOX_HEIGHT / 2;\n// A 106-unit plot leaves room for a 10-unit gap and the two-line label boxes;\n// the narrow gap keeps each label visibly tied to its spoke.\nconst RADIUS = 106;\nconst LABEL_RADIUS = RADIUS + 10;\n// Reserve 100 units for truncated names and 20 per text line: single-series\n// labels pair the name with its value; multi-series labels show the name.\nconst LABEL_WIDTH = 100;\nconst LABEL_LINE_HEIGHT = 20;\n// Labels left of center end at their axis; labels right of it start there.\nconst LABEL_SIDES = {\n left: { offset: LABEL_WIDTH, align: 'text-right', tooltipAlign: 'start' },\n center: {\n offset: LABEL_WIDTH / 2,\n align: 'text-center',\n tooltipAlign: 'center',\n },\n right: { offset: 0, align: 'text-left', tooltipAlign: 'end' },\n} as const;\n// Absorb trig rounding at alignment boundaries so mirrored labels line up.\nconst ALIGNMENT_EPSILON = 1e-6;\n// Four equally spaced rings represent fractions of the shared axis maximum.\nconst GRID_LEVELS = [0.25, 0.5, 0.75, 1];\n// Overlapping areas lead with their outlines: a faint wash keeps stacked\n// areas from mixing into a muddy tint. While one series is emphasized, it\n// alone keeps a fill, and the other series recede to dimmed outlines.\nconst SERIES_FILL_OPACITY = 0.08;\nconst EMPHASIZED_SERIES_FILL_OPACITY = 0.2;\n\nconst getAxisLayouts = (\n axes: readonly { id: string }[],\n labelHeight: number\n): AxisLayout[] =>\n axes.map(({ id }, index) => {\n const angle = (index * Math.PI * 2) / axes.length - Math.PI / 2;\n const unitX = Math.cos(angle);\n const unitY = Math.sin(angle);\n // Center labels within ~6 degrees of vertical (|cos| <= 0.1).\n const side =\n LABEL_SIDES[unitX < -0.1 ? 'left' : unitX > 0.1 ? 'right' : 'center'];\n // At 30 degrees or more above/below horizontal (|sin| >= 0.5), place the\n // whole label box outside the axis instead of straddling it.\n const isAbove = unitY <= -0.5 + ALIGNMENT_EPSILON;\n const isBelow = unitY >= 0.5 - ALIGNMENT_EPSILON;\n return {\n id,\n unitX,\n unitY,\n labelX: CENTER_X + unitX * LABEL_RADIUS - side.offset,\n labelY:\n CENTER_Y +\n unitY * LABEL_RADIUS -\n (isAbove ? labelHeight : isBelow ? 0 : labelHeight / 2),\n align: side.align,\n justify: isAbove\n ? 'justify-end'\n : isBelow\n ? 'justify-start'\n : 'justify-center',\n // Open outward, past the label and away from the plot.\n tooltipSide: isAbove\n ? 'top'\n : isBelow\n ? 'bottom'\n : unitX < 0\n ? 'left'\n : 'right',\n tooltipAlign: isAbove || isBelow ? side.tooltipAlign : 'center',\n };\n });\n\nconst getPoint = (axis: AxisLayout, ratio: number): [number, number] => [\n CENTER_X + axis.unitX * RADIUS * ratio,\n CENTER_Y + axis.unitY * RADIUS * ratio,\n];\n\nconst toPoints = (points: readonly (readonly [number, number])[]) =>\n points.map(([x, y]) => `${x},${y}`).join(' ');\n\nconst getMaximum = (values: readonly number[], maxValue?: number) =>\n maxValue !== undefined && Number.isFinite(maxValue) && maxValue > 0\n ? maxValue\n : values.reduce((largest, value) => Math.max(largest, value), 0) || 1;\n\n/**\n * A radar with a shared scale and clockwise, outside axis labels. Pass `data`\n * for one series with categorical points, or `axes` and `series` for\n * overlapping areas identified by an external legend.\n */\nexport const RadarChart = (props: RadarChartProps) => {\n // Mode-specific props are read from `props` so TypeScript narrows them by\n // mode; they are destructured here only to keep them off the wrapper div.\n const {\n data: _data,\n axes: _axes,\n series: _series,\n renderTooltip: _renderTooltip,\n renderAxisTooltip: _renderAxisTooltip,\n selectedIds,\n excludedIds,\n activeLegendItemId,\n maxValue,\n formatValue = formatNumber,\n className,\n 'aria-label': ariaLabel = 'Radar chart',\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...divProps\n } = props;\n const summaryId = useId();\n const [activeTooltip, setActiveTooltip] = useState<string | null>(null);\n const isPointerDownRef = useRef(false);\n const tooltipZIndex = useZIndex(zIndices.tooltip);\n const isInteractive =\n (props.series !== undefined\n ? props.renderAxisTooltip\n : props.renderTooltip) !== undefined;\n\n const withTooltip = (\n id: string,\n mark: ReactElement,\n content: ReactNode,\n layout?: AxisLayout\n ) => (\n <TooltipPrimitive.Root\n key={id}\n open={activeTooltip === id}\n onOpenChange={(open) =>\n setActiveTooltip((active) =>\n open ? id : active === id ? null : active\n )\n }\n >\n <TooltipPrimitive.Trigger\n asChild\n onPointerDown={(event) => {\n isPointerDownRef.current = true;\n event.currentTarget.ownerDocument.addEventListener(\n 'pointerup',\n () => {\n isPointerDownRef.current = false;\n },\n { once: true }\n );\n }}\n onFocus={(event) => {\n // Wait for keyboard focus to scroll an offscreen axis into\n // view; otherwise Radix closes the tooltip on that scroll.\n // Like Radix, focus from a pointer press stays closed.\n event.preventDefault();\n if (isPointerDownRef.current) return;\n const target = event.currentTarget;\n requestAnimationFrame(() => {\n if (target === target.ownerDocument.activeElement) {\n setActiveTooltip(id);\n }\n });\n }}\n >\n {mark}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n asChild\n side={layout?.tooltipSide}\n align={layout?.tooltipAlign}\n // Leave an 8px gap from the trigger and viewport edges.\n sideOffset={8}\n collisionPadding={8}\n >\n <ChartTooltip style={{ zIndex: tooltipZIndex }}>\n <ZIndexProvider value={tooltipZIndex}>{content}</ZIndexProvider>\n </ChartTooltip>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n\n const renderLabel = (\n layout: AxisLayout,\n height: number,\n summary: string,\n lines: ReactNode\n ) => (\n <foreignObject\n x={layout.labelX}\n y={layout.labelY}\n width={LABEL_WIDTH}\n height={height}\n >\n <div\n className={cn('flex h-full flex-col', layout.justify, layout.align)}\n title={isInteractive ? undefined : summary}\n >\n {lines}\n </div>\n </foreignObject>\n );\n\n const renderSingleSeries = (\n data: readonly RadarChartDatum[],\n renderDatumTooltip?: (datum: RadarChartDatum) => ReactNode\n ) => {\n const labelHeight = LABEL_LINE_HEIGHT * 2;\n const layouts = getAxisLayouts(data, labelHeight);\n const values = data.map(({ value }) => sanitize(value));\n const maximum = getMaximum(values, maxValue);\n const axes = data.map((datum, index) => {\n const value = values[index];\n const formattedValue = formatValue(value);\n return {\n layout: layouts[index],\n datum: {\n ...datum,\n value,\n color: datum.color ?? getCategoricalFillChartColor(index),\n },\n formattedValue,\n summary: `${datum.label}: ${formattedValue}`,\n point: getPoint(layouts[index], Math.min(1, value / maximum)),\n };\n });\n\n return {\n layouts,\n summary: axes.map(({ summary }) => summary).join('; '),\n marks: (\n <>\n <polygon\n aria-hidden=\"true\"\n points={toPoints(axes.map(({ point }) => point))}\n fill={CHART_SINGLE_FILL_COLOR}\n // A light wash and subdued outline keep the category points prominent.\n // Dark surfaces need slightly more opacity to preserve the shape.\n className=\"dark:[fill-opacity:0.24] dark:[stroke-opacity:0.8]\"\n fillOpacity={0.16}\n stroke={getCategoricalLineChartColor(0)}\n strokeOpacity={0.55}\n strokeWidth={1.25}\n strokeLinejoin=\"round\"\n />\n {axes.map(({ layout, datum, formattedValue, summary, point }) => {\n const [pointX, pointY] = point;\n const mark = (\n <g\n key={datum.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* A 24-unit hit target surrounds the 8-unit point; the\n 12-unit ring shows hover in the axis color and keyboard\n focus in the shared focus color without changing layout.\n The ring stays inside the label gap, so a point at the\n maximum doesn't draw it over its label. */}\n <circle cx={pointX} cy={pointY} r={12} fill=\"transparent\" />\n <circle\n cx={pointX}\n cy={pointY}\n r={6}\n fill=\"none\"\n stroke={datum.color}\n strokeWidth={1.5}\n className=\"opacity-0 group-hover:opacity-100 group-focus-visible:stroke-focus group-focus-visible:opacity-100\"\n />\n <circle\n cx={pointX}\n cy={pointY}\n r={4}\n fill={datum.color}\n // A thin surface-colored separator avoids heavy dark borders.\n className=\"stroke-surface-level-1\"\n strokeWidth={1}\n />\n {renderLabel(\n layout,\n labelHeight,\n summary,\n <>\n <Text variant=\"xs\" className=\"truncate leading-tight\">\n {datum.label}\n </Text>\n <Text\n variant=\"xs\"\n color=\"secondary\"\n className=\"truncate leading-tight tabular-nums\"\n >\n {formattedValue}\n </Text>\n </>\n )}\n </g>\n );\n return renderDatumTooltip\n ? withTooltip(datum.id, mark, renderDatumTooltip(datum))\n : mark;\n })}\n </>\n ),\n };\n };\n\n const renderMultiSeries = (\n axes: readonly RadarChartAxis[],\n series: readonly RadarChartSeries[],\n renderAxisTooltip?: (axis: RadarChartAxisValues) => ReactNode\n ) => {\n const layouts = getAxisLayouts(axes, LABEL_LINE_HEIGHT);\n // Resolve colors before filtering so each series keeps its hue.\n const resolvedSeries = series.map((item, index) => {\n const color = item.color ?? getCategoricalLineChartColor(index);\n return {\n id: item.id,\n label: item.label,\n color,\n fill: getCategoricalFillColor(color),\n values: axes.map(({ id }) => sanitize(item.values[id])),\n };\n });\n const visibleSeries = resolvedSeries.filter(\n ({ id }) =>\n (selectedIds === undefined ||\n selectedIds.size === 0 ||\n selectedIds.has(id)) &&\n !excludedIds?.has(id)\n );\n const maximum = getMaximum(\n visibleSeries.flatMap(({ values }) => values),\n maxValue\n );\n const plottedSeries = visibleSeries.map((item) => ({\n ...item,\n points: item.values.map((value, index) =>\n getPoint(layouts[index], Math.min(1, value / maximum))\n ),\n }));\n const emphasizedId = plottedSeries.some(\n ({ id }) => id === activeLegendItemId\n )\n ? activeLegendItemId\n : null;\n const getSeriesOpacity = (id: string) =>\n emphasizedId != null && id !== emphasizedId ? CHART_DIMMED_OPACITY : 1;\n\n return {\n layouts,\n summary: plottedSeries\n .map(\n (item) =>\n `${item.label}: ${axes\n .map(\n (axis, index) =>\n `${axis.label} ${formatValue(item.values[index])}`\n )\n .join(', ')}`\n )\n .join('; '),\n marks: (\n <>\n {/* Draw the emphasized series last so its outline sits on top. */}\n {[\n ...plottedSeries.filter(({ id }) => id !== emphasizedId),\n ...plottedSeries.filter(({ id }) => id === emphasizedId),\n ].map((item) => {\n const isEmphasized = item.id === emphasizedId;\n return (\n <polygon\n key={item.id}\n aria-hidden=\"true\"\n points={toPoints(item.points)}\n fill={item.fill}\n fillOpacity={\n isEmphasized\n ? EMPHASIZED_SERIES_FILL_OPACITY\n : emphasizedId == null\n ? SERIES_FILL_OPACITY\n : 0\n }\n className=\"transition-[opacity,fill-opacity] duration-fast motion-reduce:transition-none\"\n opacity={getSeriesOpacity(item.id)}\n stroke={item.color}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n />\n );\n })}\n {axes.map((axis, index) => {\n const layout = layouts[index];\n const values = plottedSeries.map((item) => ({\n id: item.id,\n label: item.label,\n value: item.values[index],\n color: item.color,\n }));\n const summary = values.length\n ? `${axis.label}: ${values\n .map(({ label, value }) => `${label} ${formatValue(value)}`)\n .join(', ')}`\n : axis.label;\n const [outerX, outerY] = getPoint(layout, 1);\n const [previousX, previousY] = getPoint(\n layouts[(index - 1 + layouts.length) % layouts.length],\n 1\n );\n const [nextX, nextY] = getPoint(\n layouts[(index + 1) % layouts.length],\n 1\n );\n const mark = (\n <g\n key={axis.id}\n className=\"group outline-hidden\"\n role={isInteractive ? 'img' : undefined}\n aria-label={isInteractive ? summary : undefined}\n aria-hidden={isInteractive ? undefined : true}\n tabIndex={isInteractive ? 0 : undefined}\n >\n {/* Each axis owns the sector between its neighbors' edge\n midpoints, so hovering anywhere in the plot inspects the\n nearest axis. */}\n <polygon\n points={toPoints([\n [CENTER_X, CENTER_Y],\n [(previousX + outerX) / 2, (previousY + outerY) / 2],\n [outerX, outerY],\n [(outerX + nextX) / 2, (outerY + nextY) / 2],\n ])}\n fill=\"transparent\"\n />\n {/* Hover strengthens the spoke and reveals each series'\n vertex; keyboard focus uses the shared focus color. */}\n <g className=\"opacity-0 transition-opacity duration-fast group-hover:opacity-100 group-focus-visible:opacity-100 motion-reduce:transition-none\">\n <line\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={outerX}\n y2={outerY}\n stroke=\"var(--border-default)\"\n className=\"group-focus-visible:stroke-focus\"\n />\n {plottedSeries.map((item) => (\n <circle\n key={item.id}\n cx={item.points[index][0]}\n cy={item.points[index][1]}\n r={3.5}\n fill={item.color}\n opacity={getSeriesOpacity(item.id)}\n // A surface-colored separator keeps coincident vertices distinct.\n className=\"stroke-surface-level-1\"\n strokeWidth={1.5}\n />\n ))}\n </g>\n {renderLabel(\n layout,\n LABEL_LINE_HEIGHT,\n summary,\n <Text variant=\"xs\" className=\"truncate leading-tight\">\n {axis.label}\n </Text>\n )}\n </g>\n );\n return renderAxisTooltip\n ? withTooltip(\n axis.id,\n mark,\n renderAxisTooltip({ id: axis.id, label: axis.label, values }),\n layout\n )\n : mark;\n })}\n </>\n ),\n };\n };\n\n const axisCount = (props.series !== undefined ? props.axes : props.data)\n .length;\n const chart =\n axisCount < 3\n ? null\n : props.series !== undefined\n ? renderMultiSeries(props.axes, props.series, props.renderAxisTooltip)\n : renderSingleSeries(props.data, props.renderTooltip);\n\n return (\n <div className={cn('w-full overflow-x-auto', className)} {...divProps}>\n {chart === null ? (\n <div className=\"flex h-80 items-center justify-center\" role=\"status\">\n <Text variant=\"sm\" color=\"secondary\">\n At least three axes are needed to display a radar chart.\n </Text>\n </div>\n ) : (\n <TooltipPrimitive.Provider\n // Brief hover delay avoids flashes when crossing between axes.\n delayDuration={150}\n >\n <svg\n viewBox={`0 0 ${VIEWBOX_WIDTH} ${VIEWBOX_HEIGHT}`}\n className=\"block w-full\"\n // Preserve the labels' base font size; narrow containers scroll.\n style={{ minWidth: VIEWBOX_WIDTH }}\n role={isInteractive ? 'group' : 'img'}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={[summaryId, ariaDescribedBy]\n .filter(Boolean)\n .join(' ')}\n >\n <desc id={summaryId}>{chart.summary}</desc>\n <g aria-hidden=\"true\" fill=\"none\" stroke=\"var(--border-subtle)\">\n {GRID_LEVELS.map((level) => (\n <polygon\n key={level}\n points={toPoints(\n chart.layouts.map((layout) => getPoint(layout, level))\n )}\n />\n ))}\n {chart.layouts.map((layout) => {\n const [x, y] = getPoint(layout, 1);\n return (\n <line\n key={layout.id}\n x1={CENTER_X}\n y1={CENTER_Y}\n x2={x}\n y2={y}\n />\n );\n })}\n </g>\n {chart.marks}\n </svg>\n </TooltipPrimitive.Provider>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAgIA,IAAM,kBAAkB,IAAI,KAAK,aAAa,OAAO;AACrD,IAAM,gBAAgB,UAAkB,gBAAgB,OAAO,KAAK;AACpE,IAAM,YAAY,UAChB,UAAU,KAAA,KAAa,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAGvE,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,WAAW,gBAAgB;AACjC,IAAM,WAAW,iBAAiB;AAGlC,IAAM,SAAS;AACf,IAAM,eAAe;AAGrB,IAAM,cAAc;AACpB,IAAM,oBAAoB;AAE1B,IAAM,cAAc;CAClB,MAAM;EAAE,QAAQ;EAAa,OAAO;EAAc,cAAc;CAAQ;CACxE,QAAQ;EACN,QAAQ,cAAc;EACtB,OAAO;EACP,cAAc;CAChB;CACA,OAAO;EAAE,QAAQ;EAAG,OAAO;EAAa,cAAc;CAAM;AAC9D;AAIA,IAAM,cAAc;CAAC;CAAM;CAAK;CAAM;AAAC;AAIvC,IAAM,sBAAsB;AAC5B,IAAM,iCAAiC;AAEvC,IAAM,kBACJ,MACA,gBAEA,KAAK,KAAK,EAAE,MAAM,UAAU;CAC1B,MAAM,QAAS,QAAQ,KAAK,KAAK,IAAK,KAAK,SAAS,KAAK,KAAK;CAC9D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