@fanvue/ui 3.53.0 → 3.54.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/cjs/components/AudioPlayer/AudioPlayer.cjs +4 -2
- package/dist/cjs/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
- package/dist/cjs/components/Badge/Badge.cjs +7 -6
- package/dist/cjs/components/Badge/Badge.cjs.map +1 -1
- package/dist/cjs/components/Button/Button.cjs +2 -1
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +1 -1
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs +3 -1
- package/dist/cjs/components/ChatMessage/ChatMessage.cjs.map +1 -1
- package/dist/cjs/components/Chip/Chip.cjs +10 -9
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DateRangePanel.cjs +143 -0
- package/dist/cjs/components/DatePicker/DateRangePanel.cjs.map +1 -0
- package/dist/cjs/components/DatePicker/DateRangePicker.cjs +33 -0
- package/dist/cjs/components/DatePicker/DateRangePicker.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +3 -3
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -1
- package/dist/cjs/components/FilterMenu/FilterMenu.cjs +45 -0
- package/dist/cjs/components/FilterMenu/FilterMenu.cjs.map +1 -0
- package/dist/cjs/components/IconButton/IconButton.cjs +2 -1
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/ReorganiseIcon.cjs +65 -0
- package/dist/cjs/components/Icons/ReorganiseIcon.cjs.map +1 -0
- package/dist/cjs/components/Pagination/Pagination.cjs +3 -2
- package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/components/Select/Select.cjs +20 -11
- package/dist/cjs/components/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/Table/Table.cjs +59 -34
- package/dist/cjs/components/Table/Table.cjs.map +1 -1
- package/dist/cjs/components/Table/TableToolbarSearchFilters.cjs +152 -0
- package/dist/cjs/components/Table/TableToolbarSearchFilters.cjs.map +1 -0
- package/dist/cjs/components/Table/useFittingCount.cjs +51 -0
- package/dist/cjs/components/Table/useFittingCount.cjs.map +1 -0
- package/dist/cjs/date-picker.cjs +4 -0
- package/dist/cjs/date-picker.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.mjs +4 -2
- package/dist/components/AudioPlayer/AudioPlayer.mjs.map +1 -1
- package/dist/components/Badge/Badge.mjs +7 -6
- package/dist/components/Badge/Badge.mjs.map +1 -1
- package/dist/components/Button/Button.mjs +2 -1
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Card/Card.mjs +1 -1
- package/dist/components/Card/Card.mjs.map +1 -1
- package/dist/components/ChatMessage/ChatMessage.mjs +3 -1
- package/dist/components/ChatMessage/ChatMessage.mjs.map +1 -1
- package/dist/components/Chip/Chip.mjs +10 -9
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.mjs +1 -1
- package/dist/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/components/DatePicker/DateRangePanel.mjs +126 -0
- package/dist/components/DatePicker/DateRangePanel.mjs.map +1 -0
- package/dist/components/DatePicker/DateRangePicker.mjs +33 -0
- package/dist/components/DatePicker/DateRangePicker.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +1 -1
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +3 -3
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +1 -1
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -1
- package/dist/components/FilterMenu/FilterMenu.mjs +28 -0
- package/dist/components/FilterMenu/FilterMenu.mjs.map +1 -0
- package/dist/components/IconButton/IconButton.mjs +2 -1
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/ReorganiseIcon.mjs +48 -0
- package/dist/components/Icons/ReorganiseIcon.mjs.map +1 -0
- package/dist/components/Pagination/Pagination.mjs +3 -2
- package/dist/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/components/Select/Select.mjs +20 -11
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/Table/Table.mjs +59 -34
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Table/TableToolbarSearchFilters.mjs +135 -0
- package/dist/components/Table/TableToolbarSearchFilters.mjs.map +1 -0
- package/dist/components/Table/useFittingCount.mjs +34 -0
- package/dist/components/Table/useFittingCount.mjs.map +1 -0
- package/dist/date-picker.d.ts +100 -0
- package/dist/date-picker.mjs +5 -1
- package/dist/date-picker.mjs.map +1 -1
- package/dist/index.d.ts +104 -9
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/base.css +43 -0
- package/dist/styles/theme.css +25 -25
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.cjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountVariant } from \"../Count/Count\";\n\n/** Visual variant of the chip. */\nexport type ChipVariant = \"rounded\" | \"square\" | \"dark\";\n/** Height of the chip in pixels. */\nexport type ChipSize = \"32\" | \"36\" | \"40\";\n/** Height of the notification badge in pixels. */\nexport type ChipNotificationSize = \"16\" | \"20\";\n\nexport interface ChipProps extends React.HTMLAttributes<HTMLElement> {\n /** Visual variant of the chip. @default \"rounded\" */\n variant?: ChipVariant;\n /** Height of the chip in pixels. @default \"32\" */\n size?: ChipSize;\n /** Whether the chip is in a selected (pressed) state. @default false */\n selected?: boolean;\n /** Whether the chip is disabled. @default false */\n disabled?: boolean;\n /** Whether to show a coloured status dot at the leading edge. @default false */\n leftDot?: boolean;\n /**\n * Whether the chip uses a dashed border for add/create affordances.\n * When `selected`, it becomes a subtle filled state with a solid border.\n * Has no effect when `variant=\"dark\"`.\n * @default false\n */\n dotted?: boolean;\n /**\n * Draws the unselected state as a 1px `buttons-chip-default` outline over a\n * transparent background instead of filling with that same token. This is the\n * Figma `V2 Insights Chips` treatment, used where chips sit over a chart and a\n * row of solid fills would compete with the plotted series. The selected state\n * is unaffected — it stays filled — as are the `dark` and `dotted` variants.\n * @default false\n */\n outlined?: boolean;\n /** Icon element displayed before the label. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed after the label. */\n rightIcon?: React.ReactNode;\n /** Notification badge content (e.g. `\"99+\"`). Passed as a string for i18n support. */\n notificationLabel?: string;\n /** Numeric value for the notification badge. Uses the `Count` component for overflow formatting. Takes precedence over `notificationLabel` when both are provided. */\n notificationCount?: number;\n /** Maximum value before the badge shows overflow (e.g. `\"9+\"`). Only applies when `notificationCount` is set. @default 99 */\n notificationMax?: number;\n /** Colour variant of the notification badge. @default \"brand\" */\n notificationVariant?: CountVariant;\n /**\n * Height of the notification badge. `\"20\"` is the V2 Notification Count, a\n * rounded square; `\"16\"` is a circle for dense rows such as page tab chips.\n * @default \"20\"\n */\n notificationSize?: ChipNotificationSize;\n /** Click handler — when provided, the chip renders as a `<button>` for accessibility. */\n onClick?: React.MouseEventHandler<HTMLElement>;\n /** Merge props onto a child element instead of rendering a wrapper. @default false */\n asChild?: boolean;\n}\n\n/**\n * A compact element for filters, tags, or toggleable actions. When an `onClick`\n * handler is provided, the chip renders as an interactive `<button>` with\n * `aria-pressed` support.\n *\n * @example\n * ```tsx\n * <Chip selected onClick={toggle}>Music</Chip>\n * ```\n */\nexport const Chip = React.forwardRef<HTMLButtonElement, ChipProps>(\n (\n {\n className,\n variant = \"rounded\",\n size = \"32\",\n selected = false,\n disabled = false,\n leftDot = false,\n dotted = false,\n outlined = false,\n leftIcon,\n rightIcon,\n notificationLabel,\n notificationCount,\n notificationMax,\n notificationVariant = \"brand\",\n notificationSize = \"20\",\n onClick,\n asChild = false,\n children,\n ...props\n },\n ref,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Variant-heavy UI component\n ) => {\n const isInteractive = !!onClick && !asChild;\n const Comp = asChild ? Slot : isInteractive ? \"button\" : \"span\";\n const isDark = variant === \"dark\";\n // Precedence between the three treatments, named once rather than re-derived per\n // rule: `dark` owns its own palette, `dotted` wins over `outlined`, and what is\n // left is the normal chip, either filled or outlined.\n const isDotted = !isDark && dotted;\n const isSolid = !isDark && !dotted && !outlined;\n const isOutlined = !isDark && !dotted && outlined;\n\n // The dashed border is drawn as an SVG so the dash length matches the design\n // spec (8/8 for the 40px square, 6/6 otherwise). CSS `border-dashed` only\n // renders browser-default dash lengths, which are too short. The stroke colour\n // is driven by `currentColor`, and `group-hover`/`group-active` react to the\n // chip's interactive states. Rendered only in the default (non-`asChild`) path.\n const showDottedBorder = isDotted && !selected && !asChild;\n const dottedBorder = showDottedBorder ? (\n <svg\n aria-hidden=\"true\"\n className={cn(\n // `-1px` spans the reserved transparent border rather than the padding box\n // inside it, so the dash lands on the same ring as the solid border it\n // becomes when selected.\n \"pointer-events-none absolute -top-px -left-px h-[calc(100%+2px)] w-[calc(100%+2px)] overflow-visible\",\n disabled ? \"text-buttons-chip-disabled\" : \"text-buttons-chip-dotted-default\",\n isInteractive &&\n !disabled &&\n \"group-hover:text-buttons-chip-dotted-hover-stroke group-active:text-buttons-chip-dotted-hover-stroke\",\n )}\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n rx={variant === \"square\" ? 7.5 : size === \"40\" ? 19.5 : size === \"36\" ? 17.5 : 15.5}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1\"\n strokeDasharray={variant === \"square\" && size === \"40\" ? \"8 8\" : \"6 6\"}\n style={{ width: \"calc(100% - 1px)\", height: \"calc(100% - 1px)\" }}\n />\n </svg>\n ) : null;\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chip\"\n className={cn(\n \"relative inline-flex min-w-0 items-center justify-center whitespace-nowrap motion-safe:transition-colors motion-safe:duration-150\",\n // Shape\n variant === \"square\" ? \"rounded-xs\" : \"rounded-full\",\n // Size (32px uses 12px text, 40px uses 14px text per the design spec)\n size === \"32\" && \"typography-description-12px-semibold h-8 min-w-12 py-1\",\n size === \"36\" && \"typography-body-small-14px-semibold h-9 min-w-14 py-2\",\n size === \"40\" && \"typography-body-small-14px-semibold h-10 min-w-14 py-2.5\",\n // Variant colors\n isDark && \"bg-neutral-alphas-600 text-content-always-white\",\n (isSolid || isOutlined) &&\n selected &&\n \"bg-buttons-chip-active text-content-primary-inverted\",\n // Active + dotted is a subtle filled state with a solid (non-dashed) border.\n isDotted &&\n selected &&\n \"border border-border-primary border-solid bg-inputs-inputs-primary text-content-primary\",\n isSolid && !selected && \"bg-buttons-chip-default text-content-primary\",\n // Outlined: the same token as a 1px stroke rather than a fill. The border\n // is declared in BOTH states and only changes colour, going transparent\n // once selected. It cannot be dropped on selection: `border-box` constrains\n // only explicitly sized axes, and a chip's width is intrinsic, so losing the\n // border would narrow the chip by 2px and reflow the whole row on every\n // click. Height is safe either way because `h-8` is explicit.\n isOutlined && \"border border-solid\",\n isOutlined &&\n !selected &&\n \"border-buttons-chip-default bg-transparent text-content-primary\",\n isOutlined && selected && \"border-transparent\",\n // Dotted (non-selected): the dashed border is drawn via SVG (`dottedBorder`).\n // `group` lets that SVG react to hover/active. `asChild` keeps a CSS dashed\n // border fallback since the SVG is only rendered in the default path.\n isDotted && !selected && \"bg-transparent text-content-primary\",\n isDotted && !selected && !asChild && \"group\",\n // The SVG path draws no CSS border, so selecting one used to add 1px and\n // widen the chip by 2px, shifting the row on every toggle. Reserving a\n // transparent border also puts the dash on the same ring as the solid\n // border it becomes. The `asChild` path already has a real border below.\n isDotted && !selected && !asChild && \"border border-transparent border-solid\",\n isDotted &&\n !selected &&\n asChild &&\n (disabled\n ? \"border border-buttons-chip-disabled border-dashed\"\n : \"border border-buttons-chip-dotted-default border-dashed\"),\n // Interactive\n isInteractive && !disabled && \"cursor-pointer\",\n isInteractive && !disabled && isSolid && !selected && \"hover:bg-buttons-chip-hover\",\n // Outlined darkens its stroke rather than filling. `buttons-chip-hover` is\n // the one-step darkening for chips, but as a fill it is 20% over a 10%\n // stroke, so it swallows the outline the variant exists to show. Moved onto\n // the border, over `interaction-hover`, the atomic hover surface.\n isInteractive &&\n !disabled &&\n isOutlined &&\n !selected &&\n \"hover:border-buttons-chip-hover hover:bg-interaction-hover\",\n isInteractive &&\n !disabled &&\n isDotted &&\n !selected &&\n \"hover:bg-neutral-alphas-50 active:bg-neutral-alphas-50\",\n // Focus\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled\n disabled && isDark && \"pointer-events-none opacity-50\",\n disabled && !isDark && \"pointer-events-none text-content-disabled\",\n // Solid (non-dotted) disabled chips get a muted fill; dotted ones stay\n // transparent with their dashed border (drawn via SVG).\n disabled && (isSolid || (isOutlined && selected)) && \"bg-buttons-chip-disabled\",\n // Unselected outlined greys only its stroke. Selected is already filled, so\n // it takes the muted fill above and keeps `border-transparent` for its width.\n disabled && isOutlined && !selected && \"border-buttons-chip-disabled\",\n className,\n )}\n {...(isInteractive && {\n type: \"button\" as const,\n disabled,\n \"aria-pressed\": selected,\n onClick,\n })}\n {...(!isInteractive && disabled && { \"aria-disabled\": true })}\n {...(selected && { \"data-selected\": \"\" })}\n {...props}\n >\n {asChild ? (\n <Slottable>{children}</Slottable>\n ) : (\n <>\n {dottedBorder}\n <span className=\"flex min-w-0 items-center gap-0.5 overflow-hidden px-3\">\n {leftDot && (\n <span className=\"size-2 shrink-0 rounded-full bg-current\" aria-hidden=\"true\" />\n )}\n {leftIcon && (\n <span className=\"flex shrink-0 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{children}</span>\n {rightIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center\"\n aria-hidden=\"true\"\n >\n {rightIcon}\n </span>\n )}\n </span>\n {(notificationCount != null || notificationLabel) && (\n <Count\n variant={notificationVariant}\n size={notificationSize === \"16\" ? \"24\" : \"32\"}\n className={cn(\n // V2 Notification Count: 20px high/min-width, caption 12,\n // 4px horizontal and 2px vertical padding, rounded-md.\n notificationSize === \"20\" && \"absolute top-[-4px] rounded-md px-1 py-0.5\",\n notificationSize === \"16\" && \"absolute top-[-6px] rounded-full\",\n // Anchor the leading edge so wider values grow away from the label.\n size === \"40\" && \"left-[calc(100%_-_16px)]\",\n size === \"36\" && \"left-[calc(100%_-_14px)]\",\n size === \"32\" && \"left-[calc(100%_-_11px)]\",\n )}\n value={notificationCount ?? 0}\n max={notificationMax}\n >\n {notificationCount == null ? notificationLabel : undefined}\n </Count>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\n\nChip.displayName = \"Chip\";\n"],"names":["React","Slot","jsx","cn","Slottable","jsxs","Fragment","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEO,MAAM,OAAOA,iBAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA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AA;AAAA,YAAA,WACCH,2BAAAA,IAAC,QAAA,EAAK,WAAU,2CAA0C,eAAY,QAAO;AAAA,YAE9E,YACCA,2BAAAA,IAAC,QAAA,EAAK,WAAU,6CAA4C,eAAY,QACrE,UAAA,UACH;AAAA,YAEFA,2BAAAA,IAAC,QAAA,EAAK,WAAU,oBAAoB,SAAA,CAAS;AAAA,YAC5C,aACCA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEX,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,WACE,qBAAqB,QAAQ,sBAC7BA,2BAAAA;AAAAA,YAACK,MAAAA;AAAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,MAAM,qBAAqB,OAAO,OAAO;AAAA,cACzC,WAAWJ,GAAAA;AAAAA;AAAAA;AAAAA,gBAGT,qBAAqB,QAAQ;AAAA,gBAC7B,qBAAqB,QAAQ;AAAA;AAAA,gBAE7B,SAAS,QAAQ;AAAA,gBACjB,SAAS,QAAQ;AAAA,gBACjB,SAAS,QAAQ;AAAA,cAAA;AAAA,cAEnB,OAAO,qBAAqB;AAAA,cAC5B,KAAK;AAAA,cAEJ,UAAA,qBAAqB,OAAO,oBAAoB;AAAA,YAAA;AAAA,UAAA;AAAA,QACnD,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,KAAK,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Chip.cjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Count, type CountVariant } from \"../Count/Count\";\n\n/** Visual variant of the chip. */\nexport type ChipVariant = \"rounded\" | \"square\" | \"dark\";\n/** Height of the chip in pixels. */\nexport type ChipSize = \"32\" | \"36\" | \"40\";\n/** Height of the notification badge in pixels. */\nexport type ChipNotificationSize = \"16\" | \"20\";\n\nexport interface ChipProps extends React.HTMLAttributes<HTMLElement> {\n /** Visual variant of the chip. @default \"rounded\" */\n variant?: ChipVariant;\n /** Height of the chip in pixels. @default \"32\" */\n size?: ChipSize;\n /** Whether the chip is in a selected (pressed) state. @default false */\n selected?: boolean;\n /** Whether the chip is disabled. @default false */\n disabled?: boolean;\n /** Whether to show a coloured status dot at the leading edge. @default false */\n leftDot?: boolean;\n /**\n * Whether the chip uses a dashed border for add/create affordances.\n * When `selected`, it becomes a subtle filled state with a solid border.\n * Has no effect when `variant=\"dark\"`.\n * @default false\n */\n dotted?: boolean;\n /**\n * Draws the unselected state as a 1px `neutral-alphas-100` outline over a\n * transparent background instead of the solid chip fill. This is the\n * Figma `V2 Insights Chips` treatment, used where chips sit over a chart and a\n * row of solid fills would compete with the plotted series. The selected state\n * is unaffected — it stays filled — as are the `dark` and `dotted` variants.\n * @default false\n */\n outlined?: boolean;\n /** Icon element displayed before the label. */\n leftIcon?: React.ReactNode;\n /** Icon element displayed after the label. */\n rightIcon?: React.ReactNode;\n /** Notification badge content (e.g. `\"99+\"`). Passed as a string for i18n support. */\n notificationLabel?: string;\n /** Numeric value for the notification badge. Uses the `Count` component for overflow formatting. Takes precedence over `notificationLabel` when both are provided. */\n notificationCount?: number;\n /** Maximum value before the badge shows overflow (e.g. `\"9+\"`). Only applies when `notificationCount` is set. @default 99 */\n notificationMax?: number;\n /** Colour variant of the notification badge. @default \"brand\" */\n notificationVariant?: CountVariant;\n /**\n * Height of the notification badge. `\"20\"` is the V2 Notification Count, a\n * rounded square; `\"16\"` is a circle for dense rows such as page tab chips.\n * @default \"20\"\n */\n notificationSize?: ChipNotificationSize;\n /** Click handler — when provided, the chip renders as a `<button>` for accessibility. */\n onClick?: React.MouseEventHandler<HTMLElement>;\n /** Merge props onto a child element instead of rendering a wrapper. @default false */\n asChild?: boolean;\n}\n\n/**\n * A compact element for filters, tags, or toggleable actions. When an `onClick`\n * handler is provided, the chip renders as an interactive `<button>` with\n * `aria-pressed` support.\n *\n * @example\n * ```tsx\n * <Chip selected onClick={toggle}>Music</Chip>\n * ```\n */\nexport const Chip = React.forwardRef<HTMLButtonElement, ChipProps>(\n (\n {\n className,\n variant = \"rounded\",\n size = \"32\",\n selected = false,\n disabled = false,\n leftDot = false,\n dotted = false,\n outlined = false,\n leftIcon,\n rightIcon,\n notificationLabel,\n notificationCount,\n notificationMax,\n notificationVariant = \"brand\",\n notificationSize = \"20\",\n onClick,\n asChild = false,\n children,\n ...props\n },\n ref,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Variant-heavy UI component\n ) => {\n const isInteractive = !!onClick && !asChild;\n const Comp = asChild ? Slot : isInteractive ? \"button\" : \"span\";\n const isDark = variant === \"dark\";\n // Precedence between the three treatments, named once rather than re-derived per\n // rule: `dark` owns its own palette, `dotted` wins over `outlined`, and what is\n // left is the normal chip, either filled or outlined.\n const isDotted = !isDark && dotted;\n const isSolid = !isDark && !dotted && !outlined;\n const isOutlined = !isDark && !dotted && outlined;\n\n // The dashed border is drawn as an SVG so the dash length matches the design\n // spec (8/8 for the 40px square, 6/6 otherwise). CSS `border-dashed` only\n // renders browser-default dash lengths, which are too short. The stroke colour\n // is driven by `currentColor`, and `group-hover`/`group-active` react to the\n // chip's interactive states. Rendered only in the default (non-`asChild`) path.\n const showDottedBorder = isDotted && !selected && !asChild;\n const dottedBorder = showDottedBorder ? (\n <svg\n aria-hidden=\"true\"\n className={cn(\n // `-1px` spans the reserved transparent border rather than the padding box\n // inside it, so the dash lands on the same ring as the solid border it\n // becomes when selected.\n \"pointer-events-none absolute -top-px -left-px h-[calc(100%+2px)] w-[calc(100%+2px)] overflow-visible\",\n disabled ? \"text-buttons-chip-disabled\" : \"text-buttons-chip-dotted-default\",\n isInteractive &&\n !disabled &&\n \"group-hover:text-buttons-chip-dotted-hover-stroke group-active:text-buttons-chip-dotted-hover-stroke\",\n )}\n >\n <rect\n x=\"0.5\"\n y=\"0.5\"\n rx={variant === \"square\" ? 7.5 : size === \"40\" ? 19.5 : size === \"36\" ? 17.5 : 15.5}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1\"\n strokeDasharray={variant === \"square\" && size === \"40\" ? \"8 8\" : \"6 6\"}\n style={{ width: \"calc(100% - 1px)\", height: \"calc(100% - 1px)\" }}\n />\n </svg>\n ) : null;\n\n return (\n <Comp\n ref={ref}\n data-testid=\"chip\"\n className={cn(\n \"relative inline-flex min-w-0 items-center justify-center whitespace-nowrap motion-safe:transition-colors motion-safe:duration-150\",\n // Shape\n variant === \"square\" ? \"rounded-xs\" : \"rounded-full\",\n // Size (32px uses 12px text, 40px uses 14px text per the design spec)\n size === \"32\" && \"typography-description-12px-semibold h-8 min-w-12 py-1\",\n size === \"36\" && \"typography-body-small-14px-semibold h-9 min-w-14 py-2\",\n size === \"40\" && \"typography-body-small-14px-semibold h-10 min-w-14 py-2.5\",\n // Variant colors\n isDark && \"bg-neutral-alphas-600 text-content-always-white\",\n (isSolid || isOutlined) &&\n selected &&\n \"bg-buttons-chip-active text-content-primary-inverted\",\n // Active + dotted is a subtle filled state with a solid (non-dashed) border.\n isDotted &&\n selected &&\n \"border border-border-primary border-solid bg-inputs-inputs-primary text-content-primary\",\n isSolid && !selected && \"bg-buttons-chip-default text-content-primary\",\n // Outlined: a 1px stroke rather than a fill. Strokes stay at 10%, a step above\n // the chip fill, because a thin line at the 5% fill weight disappears. The border\n // is declared in BOTH states and only changes colour, going transparent\n // once selected. It cannot be dropped on selection: `border-box` constrains\n // only explicitly sized axes, and a chip's width is intrinsic, so losing the\n // border would narrow the chip by 2px and reflow the whole row on every\n // click. Height is safe either way because `h-8` is explicit.\n isOutlined && \"border border-solid\",\n isOutlined &&\n !selected &&\n \"border-neutral-alphas-100 bg-transparent text-content-primary\",\n isOutlined && selected && \"border-transparent\",\n // Dotted (non-selected): the dashed border is drawn via SVG (`dottedBorder`).\n // `group` lets that SVG react to hover/active. `asChild` keeps a CSS dashed\n // border fallback since the SVG is only rendered in the default path.\n isDotted && !selected && \"bg-transparent text-content-primary\",\n isDotted && !selected && !asChild && \"group\",\n // The SVG path draws no CSS border, so selecting one used to add 1px and\n // widen the chip by 2px, shifting the row on every toggle. Reserving a\n // transparent border also puts the dash on the same ring as the solid\n // border it becomes. The `asChild` path already has a real border below.\n isDotted && !selected && !asChild && \"border border-transparent border-solid\",\n isDotted &&\n !selected &&\n asChild &&\n (disabled\n ? \"border border-buttons-chip-disabled border-dashed\"\n : \"border border-buttons-chip-dotted-default border-dashed\"),\n // Interactive\n isInteractive && !disabled && \"cursor-pointer\",\n isInteractive && !disabled && isSolid && !selected && \"hover:bg-buttons-chip-hover\",\n // Outlined darkens its stroke (10% to 20%) rather than filling, so the\n // outline the variant exists to show stays visible, over\n // `interaction-hover`, the atomic hover surface.\n isInteractive &&\n !disabled &&\n isOutlined &&\n !selected &&\n \"hover:border-neutral-alphas-200 hover:bg-interaction-hover\",\n isInteractive &&\n !disabled &&\n isDotted &&\n !selected &&\n \"hover:bg-neutral-alphas-50 active:bg-neutral-alphas-50\",\n // Focus\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n // Disabled\n disabled && isDark && \"pointer-events-none opacity-50\",\n disabled && !isDark && \"pointer-events-none text-content-disabled\",\n // Solid (non-dotted) disabled chips get a muted fill; dotted ones stay\n // transparent with their dashed border (drawn via SVG). Under the v2 palette the\n // fill matches the 5% resting chip, so a disabled chip never reads heavier.\n disabled &&\n (isSolid || (isOutlined && selected)) &&\n \"bg-buttons-chip-disabled theme-v2:bg-buttons-chip-default\",\n // Unselected outlined greys only its stroke. Selected is already filled, so\n // it takes the muted fill above and keeps `border-transparent` for its width.\n disabled && isOutlined && !selected && \"border-buttons-chip-disabled\",\n className,\n )}\n {...(isInteractive && {\n type: \"button\" as const,\n disabled,\n \"aria-pressed\": selected,\n onClick,\n })}\n {...(!isInteractive && disabled && { \"aria-disabled\": true })}\n {...(selected && { \"data-selected\": \"\" })}\n {...props}\n >\n {asChild ? (\n <Slottable>{children}</Slottable>\n ) : (\n <>\n {dottedBorder}\n <span className=\"flex min-w-0 items-center gap-0.5 overflow-hidden px-3\">\n {leftDot && (\n <span className=\"size-2 shrink-0 rounded-full bg-current\" aria-hidden=\"true\" />\n )}\n {leftIcon && (\n <span className=\"flex shrink-0 items-center justify-center\" aria-hidden=\"true\">\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{children}</span>\n {rightIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center\"\n aria-hidden=\"true\"\n >\n {rightIcon}\n </span>\n )}\n </span>\n {(notificationCount != null || notificationLabel) && (\n <Count\n variant={notificationVariant}\n size={notificationSize === \"16\" ? \"24\" : \"32\"}\n className={cn(\n // V2 Notification Count: 20px high/min-width, caption 12,\n // 4px horizontal and 2px vertical padding, rounded-md.\n notificationSize === \"20\" && \"absolute top-[-4px] rounded-md px-1 py-0.5\",\n notificationSize === \"16\" && \"absolute top-[-6px] rounded-full\",\n // Anchor the leading edge so wider values grow away from the label.\n size === \"40\" && \"left-[calc(100%_-_16px)]\",\n size === \"36\" && \"left-[calc(100%_-_14px)]\",\n size === \"32\" && \"left-[calc(100%_-_11px)]\",\n )}\n value={notificationCount ?? 0}\n max={notificationMax}\n >\n {notificationCount == null ? notificationLabel : undefined}\n </Count>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\n\nChip.displayName = \"Chip\";\n"],"names":["React","Slot","jsx","cn","Slottable","jsxs","Fragment","Count"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEO,MAAM,OAAOA,iBAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAsB;AAAA,IACtB,mBAAmB;AAAA,IACnB;AA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ACCA,2BAAAA,IAAC,QAAA,EAAK,WAAU,6CAA4C,eAAY,QACrE,UAAA,UACH;AAAA,YAEFA,2BAAAA,IAAC,QAAA,EAAK,WAAU,oBAAoB,SAAA,CAAS;AAAA,YAC5C,aACCA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,eAAY;AAAA,gBAEX,UAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,GAEJ;AAAA,WACE,qBAAqB,QAAQ,sBAC7BA,2BAAAA;AAAAA,YAACK,MAAAA;AAAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,MAAM,qBAAqB,OAAO,OAAO;AAAA,cACzC,WAAWJ,GAAAA;AAAAA;AAAAA;AAAAA,gBAGT,qBAAqB,QAAQ;AAAA,gBAC7B,qBAAqB,QAAQ;AAAA;AAAA,gBAE7B,SAAS,QAAQ;AAAA,gBACjB,SAAS,QAAQ;AAAA,gBACjB,SAAS,QAAQ;AAAA,cAAA;AAAA,cAEnB,OAAO,qBAAqB;AAAA,cAC5B,KAAK;AAAA,cAEJ,UAAA,qBAAqB,OAAO,oBAAoB;AAAA,YAAA;AAAA,UAAA;AAAA,QACnD,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,KAAK,cAAc;;"}
|
|
@@ -74,7 +74,7 @@ const DatePicker = React.forwardRef(
|
|
|
74
74
|
const isMulti = numberOfMonths > 1;
|
|
75
75
|
const isCompact = size === "32";
|
|
76
76
|
const navButtonClassName = cn.cn(
|
|
77
|
-
"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4",
|
|
77
|
+
"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default theme-v2:disabled:bg-buttons-secondary-default disabled:text-content-disabled [&>svg]:size-4",
|
|
78
78
|
isCompact ? "size-6" : "size-8"
|
|
79
79
|
);
|
|
80
80
|
const resolvedDayPickerProps = (() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.cjs","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useEffect, useRef } from \"react\";\nimport {\n type ChevronProps,\n type DateRange,\n type DayButtonProps,\n DayPicker,\n type DayPickerProps,\n type DayProps,\n type Modifiers,\n type MonthGridProps,\n type WeekdayProps,\n type WeekdaysProps,\n type WeekProps,\n type WeeksProps,\n} from \"react-day-picker\";\nimport { cn } from \"../../utils/cn\";\nimport type { OmitDistributed } from \"../../utils/types\";\nimport { Button } from \"../Button/Button\";\nimport { ChevronLeftIcon } from \"../Icons/ChevronLeftIcon\";\nimport { ChevronRightIcon } from \"../Icons/ChevronRightIcon\";\n\nexport type { DateRange }; // Needed by consumers when passing props\n\n/** Layout variant — single or side-by-side month display. */\nexport type DatePickerVariant = \"single\" | \"double\";\n\n/** Day button size in pixels. It also scales the navigation, caption, padding and footer buttons. */\nexport type DatePickerSize = \"40\" | \"32\";\n\n/** Props specific to the DatePicker wrapper (not inherited from react-day-picker). */\nexport interface DatePickerOwnProps {\n /** Display one month or two side-by-side. @default \"single\" */\n variant?: DatePickerVariant;\n /**\n * Day button size in pixels. It also scales the navigation, caption, padding and footer buttons.\n * Use `\"32\"` for compact surfaces such as toolbar popovers.\n * @default \"40\"\n */\n size?: DatePickerSize;\n /** Callback fired when the Apply button is clicked. */\n onApply?: () => void;\n /** Callback fired when the Cancel button is clicked. */\n onCancel?: () => void;\n /** Label for the cancel button. @default \"Cancel\" */\n cancelLabel?: string;\n /** Label for the apply button. @default \"Apply\" */\n applyLabel?: string;\n /** Whether to render the cancel / apply footer buttons. @default true */\n showFooter?: boolean;\n /** Additional CSS class name for the outer container. */\n className?: string;\n}\n\nconst DatePickerSizeContext = createContext<DatePickerSize>(\"40\");\n\nfunction Day({ day, modifiers, className, ...divProps }: DayProps) {\n const { range_start, range_end, range_middle } = modifiers;\n const isSingleDayRange = range_start && range_end;\n const inRange = (range_start || range_end || range_middle) && !isSingleDayRange;\n\n return (\n <div\n className={cn(\n className,\n inRange &&\n \"before:absolute before:inset-x-0 before:inset-y-0.5 before:bg-inputs-calendar-range first:before:left-0.5 first:before:rounded-l-sm last:before:right-0.5 last:before:rounded-r-sm\",\n inRange && range_start && \"before:left-0.5 before:rounded-l-sm\",\n inRange && range_end && \"before:right-0.5 before:rounded-r-sm\",\n )}\n {...divProps}\n />\n );\n}\n\nfunction DayButton({ day, modifiers, className, ...buttonProps }: DayButtonProps) {\n const ref = useRef<HTMLButtonElement>(null);\n const size = useContext(DatePickerSizeContext);\n\n useEffect(() => {\n if (modifiers.focused) ref.current?.focus();\n }, [modifiers.focused]);\n\n const isSelected = modifiers.selected && !modifiers.range_middle;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"relative z-10 inline-flex cursor-pointer items-center justify-center rounded-sm text-content-primary\",\n \"transition-colors hover:bg-inputs-calendar-range not-disabled:active:bg-inputs-calendar-range\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed\",\n size === \"40\" && \"size-10\",\n size === \"32\" && \"size-8\",\n size === \"40\" &&\n (isSelected\n ? \"typography-body-small-14px-semibold\"\n : \"typography-body-small-14px-regular\"),\n size === \"32\" &&\n (isSelected\n ? \"typography-description-12px-semibold\"\n : \"typography-description-12px-regular\"),\n modifiers.today &&\n !isSelected &&\n \"bg-inputs-calendar-today ring-1 ring-inputs-calendar-today-stroke hover:bg-inputs-calendar-today\",\n isSelected &&\n \"bg-inputs-calendar-selected text-content-primary-inverted hover:bg-inputs-calendar-selected\",\n modifiers.range_middle && \"bg-transparent hover:bg-transparent\",\n modifiers.disabled &&\n \"bg-inputs-calendar-disabled text-content-disabled hover:bg-inputs-calendar-disabled\",\n modifiers.outside && \"pointer-events-none text-content-disabled\",\n )}\n {...buttonProps}\n />\n );\n}\n\n/** Combined props — own DatePicker options plus all react-day-picker props (except `numberOfMonths`). */\nexport type DatePickerProps = DatePickerOwnProps &\n OmitDistributed<DayPickerProps, \"numberOfMonths\">;\n\n/**\n * A calendar date picker supporting single-date and date-range selection with\n * optional side-by-side month display and footer action buttons.\n *\n * Built on top of [react-day-picker](https://react-day-picker.js.org/) — all\n * `DayPickerProps` (except `numberOfMonths`) are forwarded.\n *\n * @example\n * ```tsx\n * <DatePicker\n * mode=\"range\"\n * variant=\"double\"\n * selected={range}\n * onSelect={setRange}\n * onApply={save}\n * onCancel={close}\n * />\n * ```\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n (\n {\n variant = \"single\",\n size = \"40\",\n onApply,\n onCancel,\n cancelLabel = \"Cancel\",\n applyLabel = \"Apply\",\n showFooter = true,\n className,\n formatters,\n ...dayPickerProps\n },\n ref,\n ) => {\n const numberOfMonths = variant === \"double\" ? 2 : 1;\n const isMulti = numberOfMonths > 1;\n const isCompact = size === \"32\";\n const navButtonClassName = cn(\n \"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default disabled:text-content-disabled [&>svg]:size-4\",\n isCompact ? \"size-6\" : \"size-8\",\n );\n\n // Wrap onSelect for range mode: when clicking inside a complete range,\n // move the nearest boundary instead of always resetting the end date.\n const resolvedDayPickerProps = (() => {\n if (dayPickerProps.mode !== \"range\") return dayPickerProps;\n\n const { selected, onSelect } = dayPickerProps as {\n selected?: DateRange;\n onSelect?: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n };\n\n if (!onSelect || !selected?.from || !selected?.to) return dayPickerProps;\n\n const { from, to } = selected;\n\n return {\n ...dayPickerProps,\n onSelect: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => {\n const clickedTime = triggerDate.getTime();\n const fromTime = from.getTime();\n const toTime = to.getTime();\n\n if (clickedTime > fromTime && clickedTime < toTime) {\n if (clickedTime - fromTime <= toTime - clickedTime) {\n onSelect({ from: triggerDate, to }, triggerDate, modifiers, e);\n } else {\n onSelect({ from, to: triggerDate }, triggerDate, modifiers, e);\n }\n return;\n }\n\n onSelect(range, triggerDate, modifiers, e);\n },\n } as typeof dayPickerProps;\n })();\n\n return (\n <DatePickerSizeContext.Provider value={size}>\n <div\n ref={ref}\n className={cn(\n \"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-sm\",\n isCompact ? \"p-4\" : \"p-6\",\n className,\n )}\n >\n <DayPicker\n showOutsideDays\n numberOfMonths={numberOfMonths}\n formatters={{\n formatCaption: (date: Date) =>\n date.toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" }),\n ...formatters,\n }}\n classNames={{\n root: \"w-full\",\n months: cn(\"relative flex\", isMulti && \"gap-6\"),\n month: \"flex flex-1 flex-col\",\n month_caption: cn(\n \"flex items-center justify-center\",\n isCompact ? \"mb-2 h-6\" : \"mb-4 h-8\",\n ),\n caption_label: cn(\n \"text-content-primary\",\n isCompact\n ? \"typography-body-small-14px-regular\"\n : \"typography-body-default-16px-regular\",\n ),\n nav: \"absolute inset-x-0 top-0 z-20 flex justify-between\",\n button_previous: navButtonClassName,\n button_next: navButtonClassName,\n month_grid: \"w-full\",\n weekdays: \"flex\",\n weekday: cn(\n \"flex flex-1 items-center justify-center text-content-secondary\",\n isCompact\n ? \"typography-description-12px-regular h-6 w-8\"\n : \"typography-body-small-14px-regular h-7.5 w-10\",\n ),\n week: \"flex\",\n day: \"relative flex flex-1 items-center justify-center p-0.5\",\n hidden: \"hidden\",\n }}\n components={{\n /**\n * !NOTE: We're unable to use semantic elements for the grid due to rdp, as such we've disabled the a11y lint rules for these elements in biome.json.\n */\n Chevron: ({ orientation }: ChevronProps) =>\n orientation === \"left\" ? <ChevronLeftIcon /> : <ChevronRightIcon />,\n MonthGrid: (props: MonthGridProps) => <div role=\"grid\" {...props} />,\n Weekdays: (props: WeekdaysProps) => <div role=\"row\" {...props} />,\n Weekday: (props: WeekdayProps) => <div role=\"columnheader\" {...props} />,\n Weeks: (props: WeeksProps) => <div role=\"rowgroup\" {...props} />,\n Week: ({ week, ...props }: WeekProps) => <div role=\"row\" {...props} />,\n Day,\n DayButton,\n }}\n {...resolvedDayPickerProps}\n />\n\n {showFooter && (\n <div className={cn(\"flex gap-2\", isCompact ? \"pt-4\" : \"pt-6\")}>\n <Button variant=\"outline\" size={size} className=\"flex-1\" onClick={onCancel}>\n {cancelLabel}\n </Button>\n <Button variant=\"primary\" size={size} className=\"flex-1\" onClick={onApply}>\n {applyLabel}\n </Button>\n </div>\n )}\n </div>\n </DatePickerSizeContext.Provider>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["createContext","jsx","cn","useRef","useContext","useEffect","forwardRef","jsxs","DayPicker","ChevronLeftIcon","ChevronRightIcon","Button"],"mappings":";;;;;;;;;;AAqDA,MAAM,wBAAwBA,MAAAA,cAA8B,IAAI;AAEhE,SAAS,IAAI,EAAE,KAAK,WAAW,WAAW,GAAG,YAAsB;AACjE,QAAM,EAAE,aAAa,WAAW,aAAA,IAAiB;AACjD,QAAM,mBAAmB,eAAe;AACxC,QAAM,WAAW,eAAe,aAAa,iBAAiB,CAAC;AAE/D,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,GAAAA;AAAAA,QACT;AAAA,QACA,WACE;AAAA,QACF,WAAW,eAAe;AAAA,QAC1B,WAAW,aA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AU,MAAY,WAAU,UAAS,SAAS,SAC/D,UAAA,WAAA,CACH;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAGN;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.cjs","sources":["../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useEffect, useRef } from \"react\";\nimport {\n type ChevronProps,\n type DateRange,\n type DayButtonProps,\n DayPicker,\n type DayPickerProps,\n type DayProps,\n type Modifiers,\n type MonthGridProps,\n type WeekdayProps,\n type WeekdaysProps,\n type WeekProps,\n type WeeksProps,\n} from \"react-day-picker\";\nimport { cn } from \"../../utils/cn\";\nimport type { OmitDistributed } from \"../../utils/types\";\nimport { Button } from \"../Button/Button\";\nimport { ChevronLeftIcon } from \"../Icons/ChevronLeftIcon\";\nimport { ChevronRightIcon } from \"../Icons/ChevronRightIcon\";\n\nexport type { DateRange }; // Needed by consumers when passing props\n\n/** Layout variant — single or side-by-side month display. */\nexport type DatePickerVariant = \"single\" | \"double\";\n\n/** Day button size in pixels. It also scales the navigation, caption, padding and footer buttons. */\nexport type DatePickerSize = \"40\" | \"32\";\n\n/** Props specific to the DatePicker wrapper (not inherited from react-day-picker). */\nexport interface DatePickerOwnProps {\n /** Display one month or two side-by-side. @default \"single\" */\n variant?: DatePickerVariant;\n /**\n * Day button size in pixels. It also scales the navigation, caption, padding and footer buttons.\n * Use `\"32\"` for compact surfaces such as toolbar popovers.\n * @default \"40\"\n */\n size?: DatePickerSize;\n /** Callback fired when the Apply button is clicked. */\n onApply?: () => void;\n /** Callback fired when the Cancel button is clicked. */\n onCancel?: () => void;\n /** Label for the cancel button. @default \"Cancel\" */\n cancelLabel?: string;\n /** Label for the apply button. @default \"Apply\" */\n applyLabel?: string;\n /** Whether to render the cancel / apply footer buttons. @default true */\n showFooter?: boolean;\n /** Additional CSS class name for the outer container. */\n className?: string;\n}\n\nconst DatePickerSizeContext = createContext<DatePickerSize>(\"40\");\n\nfunction Day({ day, modifiers, className, ...divProps }: DayProps) {\n const { range_start, range_end, range_middle } = modifiers;\n const isSingleDayRange = range_start && range_end;\n const inRange = (range_start || range_end || range_middle) && !isSingleDayRange;\n\n return (\n <div\n className={cn(\n className,\n inRange &&\n \"before:absolute before:inset-x-0 before:inset-y-0.5 before:bg-inputs-calendar-range first:before:left-0.5 first:before:rounded-l-sm last:before:right-0.5 last:before:rounded-r-sm\",\n inRange && range_start && \"before:left-0.5 before:rounded-l-sm\",\n inRange && range_end && \"before:right-0.5 before:rounded-r-sm\",\n )}\n {...divProps}\n />\n );\n}\n\nfunction DayButton({ day, modifiers, className, ...buttonProps }: DayButtonProps) {\n const ref = useRef<HTMLButtonElement>(null);\n const size = useContext(DatePickerSizeContext);\n\n useEffect(() => {\n if (modifiers.focused) ref.current?.focus();\n }, [modifiers.focused]);\n\n const isSelected = modifiers.selected && !modifiers.range_middle;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={cn(\n \"relative z-10 inline-flex cursor-pointer items-center justify-center rounded-sm text-content-primary\",\n \"transition-colors hover:bg-inputs-calendar-range not-disabled:active:bg-inputs-calendar-range\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed\",\n size === \"40\" && \"size-10\",\n size === \"32\" && \"size-8\",\n size === \"40\" &&\n (isSelected\n ? \"typography-body-small-14px-semibold\"\n : \"typography-body-small-14px-regular\"),\n size === \"32\" &&\n (isSelected\n ? \"typography-description-12px-semibold\"\n : \"typography-description-12px-regular\"),\n modifiers.today &&\n !isSelected &&\n \"bg-inputs-calendar-today ring-1 ring-inputs-calendar-today-stroke hover:bg-inputs-calendar-today\",\n isSelected &&\n \"bg-inputs-calendar-selected text-content-primary-inverted hover:bg-inputs-calendar-selected\",\n modifiers.range_middle && \"bg-transparent hover:bg-transparent\",\n modifiers.disabled &&\n \"bg-inputs-calendar-disabled text-content-disabled hover:bg-inputs-calendar-disabled\",\n modifiers.outside && \"pointer-events-none text-content-disabled\",\n )}\n {...buttonProps}\n />\n );\n}\n\n/** Combined props — own DatePicker options plus all react-day-picker props (except `numberOfMonths`). */\nexport type DatePickerProps = DatePickerOwnProps &\n OmitDistributed<DayPickerProps, \"numberOfMonths\">;\n\n/**\n * A calendar date picker supporting single-date and date-range selection with\n * optional side-by-side month display and footer action buttons.\n *\n * Built on top of [react-day-picker](https://react-day-picker.js.org/) — all\n * `DayPickerProps` (except `numberOfMonths`) are forwarded.\n *\n * @example\n * ```tsx\n * <DatePicker\n * mode=\"range\"\n * variant=\"double\"\n * selected={range}\n * onSelect={setRange}\n * onApply={save}\n * onCancel={close}\n * />\n * ```\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(\n (\n {\n variant = \"single\",\n size = \"40\",\n onApply,\n onCancel,\n cancelLabel = \"Cancel\",\n applyLabel = \"Apply\",\n showFooter = true,\n className,\n formatters,\n ...dayPickerProps\n },\n ref,\n ) => {\n const numberOfMonths = variant === \"double\" ? 2 : 1;\n const isMulti = numberOfMonths > 1;\n const isCompact = size === \"32\";\n const navButtonClassName = cn(\n \"pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full bg-buttons-secondary-default text-content-primary transition-colors hover:bg-buttons-secondary-hover focus-visible:shadow-focus-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:bg-buttons-disabled-default theme-v2:disabled:bg-buttons-secondary-default disabled:text-content-disabled [&>svg]:size-4\",\n isCompact ? \"size-6\" : \"size-8\",\n );\n\n // Wrap onSelect for range mode: when clicking inside a complete range,\n // move the nearest boundary instead of always resetting the end date.\n const resolvedDayPickerProps = (() => {\n if (dayPickerProps.mode !== \"range\") return dayPickerProps;\n\n const { selected, onSelect } = dayPickerProps as {\n selected?: DateRange;\n onSelect?: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n };\n\n if (!onSelect || !selected?.from || !selected?.to) return dayPickerProps;\n\n const { from, to } = selected;\n\n return {\n ...dayPickerProps,\n onSelect: (\n range: DateRange | undefined,\n triggerDate: Date,\n modifiers: Modifiers,\n e: React.MouseEvent | React.KeyboardEvent,\n ) => {\n const clickedTime = triggerDate.getTime();\n const fromTime = from.getTime();\n const toTime = to.getTime();\n\n if (clickedTime > fromTime && clickedTime < toTime) {\n if (clickedTime - fromTime <= toTime - clickedTime) {\n onSelect({ from: triggerDate, to }, triggerDate, modifiers, e);\n } else {\n onSelect({ from, to: triggerDate }, triggerDate, modifiers, e);\n }\n return;\n }\n\n onSelect(range, triggerDate, modifiers, e);\n },\n } as typeof dayPickerProps;\n })();\n\n return (\n <DatePickerSizeContext.Provider value={size}>\n <div\n ref={ref}\n className={cn(\n \"inline-flex flex-col rounded-xl border border-modal-stroke bg-modal-background shadow-blur-menu backdrop-blur-sm\",\n isCompact ? \"p-4\" : \"p-6\",\n className,\n )}\n >\n <DayPicker\n showOutsideDays\n numberOfMonths={numberOfMonths}\n formatters={{\n formatCaption: (date: Date) =>\n date.toLocaleDateString(\"en-US\", { month: \"long\", year: \"numeric\" }),\n ...formatters,\n }}\n classNames={{\n root: \"w-full\",\n months: cn(\"relative flex\", isMulti && \"gap-6\"),\n month: \"flex flex-1 flex-col\",\n month_caption: cn(\n \"flex items-center justify-center\",\n isCompact ? \"mb-2 h-6\" : \"mb-4 h-8\",\n ),\n caption_label: cn(\n \"text-content-primary\",\n isCompact\n ? \"typography-body-small-14px-regular\"\n : \"typography-body-default-16px-regular\",\n ),\n nav: \"absolute inset-x-0 top-0 z-20 flex justify-between\",\n button_previous: navButtonClassName,\n button_next: navButtonClassName,\n month_grid: \"w-full\",\n weekdays: \"flex\",\n weekday: cn(\n \"flex flex-1 items-center justify-center text-content-secondary\",\n isCompact\n ? \"typography-description-12px-regular h-6 w-8\"\n : \"typography-body-small-14px-regular h-7.5 w-10\",\n ),\n week: \"flex\",\n day: \"relative flex flex-1 items-center justify-center p-0.5\",\n hidden: \"hidden\",\n }}\n components={{\n /**\n * !NOTE: We're unable to use semantic elements for the grid due to rdp, as such we've disabled the a11y lint rules for these elements in biome.json.\n */\n Chevron: ({ orientation }: ChevronProps) =>\n orientation === \"left\" ? <ChevronLeftIcon /> : <ChevronRightIcon />,\n MonthGrid: (props: MonthGridProps) => <div role=\"grid\" {...props} />,\n Weekdays: (props: WeekdaysProps) => <div role=\"row\" {...props} />,\n Weekday: (props: WeekdayProps) => <div role=\"columnheader\" {...props} />,\n Weeks: (props: WeeksProps) => <div role=\"rowgroup\" {...props} />,\n Week: ({ week, ...props }: WeekProps) => <div role=\"row\" {...props} />,\n Day,\n DayButton,\n }}\n {...resolvedDayPickerProps}\n />\n\n {showFooter && (\n <div className={cn(\"flex gap-2\", isCompact ? \"pt-4\" : \"pt-6\")}>\n <Button variant=\"outline\" size={size} className=\"flex-1\" onClick={onCancel}>\n {cancelLabel}\n </Button>\n <Button variant=\"primary\" size={size} className=\"flex-1\" onClick={onApply}>\n {applyLabel}\n </Button>\n </div>\n )}\n </div>\n </DatePickerSizeContext.Provider>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["createContext","jsx","cn","useRef","useContext","useEffect","forwardRef","jsxs","DayPicker","ChevronLeftIcon","ChevronRightIcon","Button"],"mappings":";;;;;;;;;;AAqDA,MAAM,wBAAwBA,MAAAA,cAA8B,IAAI;AAEhE,SAAS,IAAI,EAAE,KAAK,WAAW,WAAW,GAAG,YAAsB;AACjE,QAAM,EAAE,aAAa,WAAW,aAAA,IAAiB;AACjD,QAAM,mBAAmB,eAAe;AACxC,QAAM,WAAW,eAAe,aAAa,iBAAiB,CAAC;AAE/D,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,GAAAA;AAAAA,QACT;AAAA,QACA,WACE;AAAA,QACF,WAAW,eAAe;AAAA,QAC1B,WAAW,aAAa;AAAA,MAAA;AAAA,MAEzB,GAAG;AAAA,IAAA;AAAA,E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AA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAGN;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const RadioGroupPrimitive = require("@radix-ui/react-radio-group");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const Button = require("../Button/Button.cjs");
|
|
9
|
+
const CheckIcon = require("../Icons/CheckIcon.cjs");
|
|
10
|
+
const RadioGroup = require("../RadioGroup/RadioGroup.cjs");
|
|
11
|
+
const DatePicker = require("./DatePicker.cjs");
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
14
|
+
if (e) {
|
|
15
|
+
for (const k in e) {
|
|
16
|
+
if (k !== "default") {
|
|
17
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: () => e[k]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
const RadioGroupPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadioGroupPrimitive);
|
|
29
|
+
const CUSTOM_ROW_VALUE = "__custom-range__";
|
|
30
|
+
const ROW_CLASS_NAME = [
|
|
31
|
+
"typography-body-small-14px-regular flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-3 py-1.5 text-start text-content-primary outline-none",
|
|
32
|
+
"hover:bg-interaction-hover focus-visible:bg-interaction-hover",
|
|
33
|
+
"data-[state=checked]:bg-menu-item-selected data-[state=checked]:font-semibold data-[state=checked]:hover:bg-interaction-hover data-[state=checked]:focus-visible:bg-interaction-hover",
|
|
34
|
+
"theme-v2:data-[state=checked]:text-content-primary-inverted theme-v2:data-[state=checked]:hover:bg-menu-item-selected-hover theme-v2:data-[state=checked]:focus-visible:bg-menu-item-selected-hover"
|
|
35
|
+
].join(" ");
|
|
36
|
+
const ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
37
|
+
function DateRangeRow({ value, onClick, children }) {
|
|
38
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RadioGroupPrimitive__namespace.Item, { value, onClick, className: ROW_CLASS_NAME, children: [
|
|
39
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon.CheckIcon, { className: "size-4 shrink-0" }) })
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
const DateRangePanel = React.forwardRef(
|
|
44
|
+
({
|
|
45
|
+
presets,
|
|
46
|
+
customRangeLabel,
|
|
47
|
+
value,
|
|
48
|
+
onValueChange,
|
|
49
|
+
applyLabel = "Apply",
|
|
50
|
+
cancelLabel = "Cancel",
|
|
51
|
+
onCancel,
|
|
52
|
+
calendarProps,
|
|
53
|
+
"aria-label": ariaLabel,
|
|
54
|
+
className
|
|
55
|
+
}, ref) => {
|
|
56
|
+
const appliedRange = value.type === "custom" ? value.range : void 0;
|
|
57
|
+
const [showCalendar, setShowCalendar] = React.useState(false);
|
|
58
|
+
const [draft, setDraft] = React.useState(appliedRange);
|
|
59
|
+
const arrowKeyDown = React.useRef(false);
|
|
60
|
+
const openCalendar = () => {
|
|
61
|
+
setDraft(appliedRange);
|
|
62
|
+
setShowCalendar(true);
|
|
63
|
+
};
|
|
64
|
+
const pickRow = (rowValue) => {
|
|
65
|
+
if (rowValue === CUSTOM_ROW_VALUE) openCalendar();
|
|
66
|
+
else onValueChange({ type: "preset", presetId: rowValue });
|
|
67
|
+
};
|
|
68
|
+
const apply = () => {
|
|
69
|
+
if (draft?.from && draft.to) {
|
|
70
|
+
onValueChange({ type: "custom", range: { from: draft.from, to: draft.to } });
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const cancel = () => {
|
|
74
|
+
setDraft(void 0);
|
|
75
|
+
setShowCalendar(false);
|
|
76
|
+
onCancel?.();
|
|
77
|
+
};
|
|
78
|
+
if (showCalendar) {
|
|
79
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn.cn("flex flex-col", className), children: [
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
DatePicker.DatePicker,
|
|
82
|
+
{
|
|
83
|
+
mode: "range",
|
|
84
|
+
variant: "single",
|
|
85
|
+
size: "32",
|
|
86
|
+
showFooter: false,
|
|
87
|
+
defaultMonth: appliedRange?.from,
|
|
88
|
+
selected: draft,
|
|
89
|
+
onSelect: setDraft,
|
|
90
|
+
className: "rounded-none border-0 bg-transparent p-0 shadow-none backdrop-blur-none",
|
|
91
|
+
...calendarProps
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 pt-4", children: [
|
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button.Button, { variant: "outline", size: "32", onClick: cancel, children: cancelLabel }),
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
Button.Button,
|
|
98
|
+
{
|
|
99
|
+
variant: "primary",
|
|
100
|
+
size: "32",
|
|
101
|
+
disabled: !draft?.from || !draft.to,
|
|
102
|
+
onClick: apply,
|
|
103
|
+
children: applyLabel
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
const rowClick = (rowValue) => () => {
|
|
110
|
+
if (!arrowKeyDown.current) pickRow(rowValue);
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
113
|
+
RadioGroup.RadioGroup,
|
|
114
|
+
{
|
|
115
|
+
ref,
|
|
116
|
+
"aria-label": ariaLabel,
|
|
117
|
+
value: value.type === "preset" ? value.presetId : customRangeLabel === void 0 ? "" : CUSTOM_ROW_VALUE,
|
|
118
|
+
className: cn.cn("flex min-w-48 flex-col gap-0.5", className),
|
|
119
|
+
onKeyDown: (event) => {
|
|
120
|
+
if (ARROW_KEYS.has(event.key)) arrowKeyDown.current = true;
|
|
121
|
+
const row = event.target instanceof HTMLElement ? event.target.closest("[role=radio]") : null;
|
|
122
|
+
if (event.key === "Enter" && row instanceof HTMLButtonElement) pickRow(row.value);
|
|
123
|
+
},
|
|
124
|
+
onKeyUp: () => {
|
|
125
|
+
arrowKeyDown.current = false;
|
|
126
|
+
},
|
|
127
|
+
onBlur: (event) => {
|
|
128
|
+
if (!event.currentTarget.contains(event.relatedTarget)) arrowKeyDown.current = false;
|
|
129
|
+
},
|
|
130
|
+
children: [
|
|
131
|
+
presets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(DateRangeRow, { value: preset.id, onClick: rowClick(preset.id), children: preset.label }, preset.id)),
|
|
132
|
+
customRangeLabel !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, className: "my-1 h-px bg-neutral-alphas-200" }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(DateRangeRow, { value: CUSTOM_ROW_VALUE, onClick: rowClick(CUSTOM_ROW_VALUE), children: customRangeLabel })
|
|
135
|
+
] })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
DateRangePanel.displayName = "DateRangePanel";
|
|
142
|
+
exports.DateRangePanel = DateRangePanel;
|
|
143
|
+
//# sourceMappingURL=DateRangePanel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateRangePanel.cjs","sources":["../../../../src/components/DatePicker/DateRangePanel.tsx"],"sourcesContent":["import * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\nimport { forwardRef, useRef, useState } from \"react\";\nimport type { DateRange, DayPickerProps } from \"react-day-picker\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { RadioGroup } from \"../RadioGroup/RadioGroup\";\nimport { DatePicker } from \"./DatePicker\";\n\n/** A named preset the caller maps to a date range. The kit does no date maths. */\nexport interface DateRangePreset {\n /** Stable identifier emitted in `{ type: \"preset\", presetId }`. */\n id: string;\n /** Visible, already translated label. */\n label: string;\n}\n\n/** The applied selection: one of the caller's presets, or an explicit custom range. */\nexport type DateRangeValue =\n | { type: \"preset\"; presetId: string }\n | { type: \"custom\"; range: { from: Date; to: Date } };\n\n/** Calendar options forwarded to the custom range calendar. */\nexport type DateRangeCalendarProps = Pick<\n DayPickerProps,\n \"disabled\" | \"startMonth\" | \"endMonth\" | \"weekStartsOn\" | \"locale\"\n>;\n\n/** Props for {@link DateRangePanel}. */\nexport interface DateRangePanelProps {\n /** Preset rows, in display order. */\n presets: readonly DateRangePreset[];\n /** Label of the last row, which opens the calendar. Omit to offer presets only. Translated by the caller. */\n customRangeLabel?: string;\n /** The applied selection. A custom value checks the Custom range row. Picking that row opens the calendar on the applied range. */\n value: DateRangeValue;\n /**\n * Called with `{ type: \"preset\", presetId }` as soon as a preset row is picked by click, Space or\n * Enter, including the current one, and with `{ type: \"custom\", range }` when Apply is clicked.\n * Arrow keys move focus without calling it.\n */\n onValueChange: (value: DateRangeValue) => void;\n /** Label of the Apply button. @default \"Apply\" */\n applyLabel?: string;\n /** Label of the Cancel button. @default \"Cancel\" */\n cancelLabel?: string;\n /** Called after Cancel drops the draft range and the panel returns to the preset list. */\n onCancel?: () => void;\n /** Bounds, locale and first weekday for the calendar. */\n calendarProps?: DateRangeCalendarProps;\n /** Accessible name of the preset list. Translated by the caller. */\n \"aria-label\": string;\n /** Additional CSS class name for the root element. */\n className?: string;\n}\n\nconst CUSTOM_ROW_VALUE = \"__custom-range__\";\nconst ROW_CLASS_NAME = [\n \"typography-body-small-14px-regular flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-sm border-0 bg-transparent px-3 py-1.5 text-start text-content-primary outline-none\",\n \"hover:bg-interaction-hover focus-visible:bg-interaction-hover\",\n \"data-[state=checked]:bg-menu-item-selected data-[state=checked]:font-semibold data-[state=checked]:hover:bg-interaction-hover data-[state=checked]:focus-visible:bg-interaction-hover\",\n \"theme-v2:data-[state=checked]:text-content-primary-inverted theme-v2:data-[state=checked]:hover:bg-menu-item-selected-hover theme-v2:data-[state=checked]:focus-visible:bg-menu-item-selected-hover\",\n].join(\" \");\n\nconst ARROW_KEYS = new Set([\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"]);\n\ninterface DateRangeRowProps {\n value: string;\n onClick: () => void;\n children: string;\n}\n\nfunction DateRangeRow({ value, onClick, children }: DateRangeRowProps) {\n return (\n <RadioGroupPrimitive.Item value={value} onClick={onClick} className={ROW_CLASS_NAME}>\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n <RadioGroupPrimitive.Indicator>\n <CheckIcon className=\"size-4 shrink-0\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n );\n}\n\n/**\n * A list of date range presets, with a \"Custom range\" row that swaps to a one-month calendar when\n * `customRangeLabel` is given. A pointer click, Space or Enter on a row picks it. A preset applies\n * at once, and a custom range applies on Apply, with Cancel returning to the list. It always opens\n * on the list, even when a custom range is applied, so a preset stays reachable. The arrow keys\n * only move focus between rows and never pick one, so a keyboard user can reach a row without\n * applying it. It renders no popover, so it can sit inside a popover or a phone sheet. The caller\n * maps preset ids to dates.\n *\n * @example\n * ```tsx\n * <DateRangePanel\n * aria-label=\"Date range\"\n * presets={[{ id: \"7d\", label: \"Last 7 days\" }]}\n * customRangeLabel=\"Custom range\"\n * value={value}\n * onValueChange={setValue}\n * />\n * ```\n */\nexport const DateRangePanel = forwardRef<HTMLDivElement, DateRangePanelProps>(\n (\n {\n presets,\n customRangeLabel,\n value,\n onValueChange,\n applyLabel = \"Apply\",\n cancelLabel = \"Cancel\",\n onCancel,\n calendarProps,\n \"aria-label\": ariaLabel,\n className,\n },\n ref,\n ) => {\n const appliedRange = value.type === \"custom\" ? value.range : undefined;\n const [showCalendar, setShowCalendar] = useState(false);\n const [draft, setDraft] = useState<DateRange | undefined>(appliedRange);\n const arrowKeyDown = useRef(false);\n\n const openCalendar = () => {\n setDraft(appliedRange);\n setShowCalendar(true);\n };\n\n const pickRow = (rowValue: string) => {\n if (rowValue === CUSTOM_ROW_VALUE) openCalendar();\n else onValueChange({ type: \"preset\", presetId: rowValue });\n };\n\n const apply = () => {\n if (draft?.from && draft.to) {\n onValueChange({ type: \"custom\", range: { from: draft.from, to: draft.to } });\n }\n };\n\n const cancel = () => {\n setDraft(undefined);\n setShowCalendar(false);\n onCancel?.();\n };\n\n if (showCalendar) {\n return (\n <div ref={ref} className={cn(\"flex flex-col\", className)}>\n <DatePicker\n mode=\"range\"\n variant=\"single\"\n size=\"32\"\n showFooter={false}\n defaultMonth={appliedRange?.from}\n selected={draft}\n onSelect={setDraft}\n className=\"rounded-none border-0 bg-transparent p-0 shadow-none backdrop-blur-none\"\n {...calendarProps}\n />\n <div className=\"grid grid-cols-2 gap-2 pt-4\">\n <Button variant=\"outline\" size=\"32\" onClick={cancel}>\n {cancelLabel}\n </Button>\n <Button\n variant=\"primary\"\n size=\"32\"\n disabled={!draft?.from || !draft.to}\n onClick={apply}\n >\n {applyLabel}\n </Button>\n </div>\n </div>\n );\n }\n\n const rowClick = (rowValue: string) => () => {\n if (!arrowKeyDown.current) pickRow(rowValue);\n };\n\n return (\n <RadioGroup\n ref={ref}\n aria-label={ariaLabel}\n value={\n value.type === \"preset\"\n ? value.presetId\n : customRangeLabel === undefined\n ? \"\"\n : CUSTOM_ROW_VALUE\n }\n className={cn(\"flex min-w-48 flex-col gap-0.5\", className)}\n onKeyDown={(event) => {\n if (ARROW_KEYS.has(event.key)) arrowKeyDown.current = true;\n const row =\n event.target instanceof HTMLElement ? event.target.closest(\"[role=radio]\") : null;\n if (event.key === \"Enter\" && row instanceof HTMLButtonElement) pickRow(row.value);\n }}\n onKeyUp={() => {\n arrowKeyDown.current = false;\n }}\n onBlur={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget)) arrowKeyDown.current = false;\n }}\n >\n {presets.map((preset) => (\n <DateRangeRow key={preset.id} value={preset.id} onClick={rowClick(preset.id)}>\n {preset.label}\n </DateRangeRow>\n ))}\n {customRangeLabel !== undefined && (\n <>\n <div aria-hidden className=\"my-1 h-px bg-neutral-alphas-200\" />\n <DateRangeRow value={CUSTOM_ROW_VALUE} onClick={rowClick(CUSTOM_ROW_VALUE)}>\n {customRangeLabel}\n </DateRangeRow>\n </>\n )}\n </RadioGroup>\n );\n },\n);\n\nDateRangePanel.displayName = \"DateRangePanel\";\n"],"names":["RadioGroupPrimitive","jsx","CheckIcon","forwardRef","useState","useRef","cn","DatePicker","jsxs","Button","RadioGroup","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAEV,MAAM,iCAAiB,IAAI,CAAC,WAAW,aAAa,aAAa,YAAY,CAAC;AAQ9E,SAAS,aAAa,EAAE,OAAO,SAAS,YAA+B;AACrE,yCACGA,+BAAoB,MAApB,EAAyB,OAAc,SAAkB,WAAW,gBACnE,UAAA;AAAA,IAA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UAAA;AAAA,UAAA,QAAQ,IAAI,CAAC,WACZL,2BAAAA,IAAC,cAAA,EAA6B,OAAO,OAAO,IAAI,SAAS,SAAS,OAAO,EAAE,GACxE,iBAAO,MAAA,GADS,OAAO,EAE1B,CACD;AAAA,UACA,qBAAqB,UACpBO,2BAAAA,KAAAG,WAAAA,UAAA,EACE,UAAA;AAAA,YAAAV,2BAAAA,IAAC,OAAA,EAAI,eAAW,MAAC,WAAU,mCAAkC;AAAA,YAC7DA,+BAAC,gBAAa,OAAO,kBAAkB,SAAS,SAAS,gBAAgB,GACtE,UAAA,iBAAA,CACH;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,eAAe,cAAc;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 Popover = require("../Popover/Popover.cjs");
|
|
7
|
+
const DateRangePanel = require("./DateRangePanel.cjs");
|
|
8
|
+
const DateRangePicker = React.forwardRef(
|
|
9
|
+
({ children, onValueChange, onCancel, "aria-label": ariaLabel, ...panelProps }, ref) => {
|
|
10
|
+
const [open, setOpen] = React.useState(false);
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover.Popover, { open, onOpenChange: setOpen, children: [
|
|
12
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover.PopoverTrigger, { asChild: true, children }),
|
|
13
|
+
/* @__PURE__ */ jsxRuntime.jsx(Popover.PopoverContent, { ref, "aria-label": ariaLabel, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
14
|
+
DateRangePanel.DateRangePanel,
|
|
15
|
+
{
|
|
16
|
+
...panelProps,
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
onValueChange: (next) => {
|
|
19
|
+
onValueChange(next);
|
|
20
|
+
setOpen(false);
|
|
21
|
+
},
|
|
22
|
+
onCancel: () => {
|
|
23
|
+
onCancel?.();
|
|
24
|
+
setOpen(false);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
) })
|
|
28
|
+
] });
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
DateRangePicker.displayName = "DateRangePicker";
|
|
32
|
+
exports.DateRangePicker = DateRangePicker;
|
|
33
|
+
//# sourceMappingURL=DateRangePicker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateRangePicker.cjs","sources":["../../../../src/components/DatePicker/DateRangePicker.tsx"],"sourcesContent":["import { forwardRef, useState } from \"react\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../Popover/Popover\";\nimport { DateRangePanel, type DateRangePanelProps } from \"./DateRangePanel\";\n\n/** Props for {@link DateRangePicker}. */\nexport interface DateRangePickerProps extends Omit<DateRangePanelProps, \"className\"> {\n /** The trigger element, rendered as the popover trigger. It shows no value, so the caller owns its label. */\n children: React.ReactElement;\n /** Accessible name of the popover dialog and of the preset list inside it. Translated by the caller. */\n \"aria-label\": string;\n}\n\n/**\n * A {@link DateRangePanel} in a popover under a caller-supplied trigger. The popover closes after\n * a preset pick, Apply and Cancel. Closing it any other way drops an unapplied range.\n *\n * @example\n * ```tsx\n * <DateRangePicker\n * aria-label=\"Date range\"\n * presets={presets}\n * customRangeLabel=\"Custom range\"\n * value={value}\n * onValueChange={setValue}\n * >\n * <TableToolbarAction icon={<ChevronDownIcon />}>Date</TableToolbarAction>\n * </DateRangePicker>\n * ```\n */\nexport const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(\n ({ children, onValueChange, onCancel, \"aria-label\": ariaLabel, ...panelProps }, ref) => {\n const [open, setOpen] = useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{children}</PopoverTrigger>\n <PopoverContent ref={ref} aria-label={ariaLabel}>\n <DateRangePanel\n {...panelProps}\n aria-label={ariaLabel}\n onValueChange={(next) => {\n onValueChange(next);\n setOpen(false);\n }}\n onCancel={() => {\n onCancel?.();\n setOpen(false);\n }}\n />\n </PopoverContent>\n </Popover>\n );\n },\n);\n\nDateRangePicker.displayName = \"DateRangePicker\";\n"],"names":["forwardRef","useState","jsxs","Popover","jsx","PopoverTrigger","PopoverContent","DateRangePanel"],"mappings":";;;;;;;AA6BO,MAAM,kBAAkBA,MAAAA;AAAAA,EAC7B,CAAC,EAAE,UAAU,eAAe,UAAU,cAAc,WAAW,GAAG,WAAA,GAAc,QAAQ;AACtF,UAAM,CAAC,MAAM,OAAO,IAAIC,MAAAA,SAAS,KAAK;AAEtC,WACEC,2BAAAA,KAACC,QAAAA,SAAA,EAAQ,MAAY,cAAc,SACjC,UAAA;AAAA,MAAAC,2BAAAA,IAACC,QAAAA,gBAAA,EAAe,SAAO,MAAE,SAAA,CAAS;AAAA,MAClCD,2BAAAA,IAACE,QAAAA,gBAAA,EAAe,KAAU,cAAY,WACpC,UAAAF,2BAAAA;AAAAA,QAACG,eAAAA;AAAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ,cAAY;AAAA,UACZ,eAAe,CAAC,SAAS;AACvB,0BAAc,IAAI;AAClB,oBAAQ,KAAK;AAAA,UACf;AAAA,UACA,UAAU,MAAM;AACd,uBAAA;AACA,oBAAQ,KAAK;AAAA,UACf;AAAA,QAAA;AAAA,MAAA,EACF,CACF;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AAEA,gBAAgB,cAAc;;"}
|
|
@@ -238,7 +238,7 @@ const DropdownMenuItem = React__namespace.forwardRef(
|
|
|
238
238
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
239
239
|
const DropdownMenuSeparator = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
240
240
|
const variant = React__namespace.useContext(context.DropdownMenuVariantContext);
|
|
241
|
-
const separatorClassName = cn.cn("my-
|
|
241
|
+
const separatorClassName = cn.cn("my-1.5 h-px border-0 bg-neutral-alphas-200", className);
|
|
242
242
|
if (variant === "sheet") {
|
|
243
243
|
return /* @__PURE__ */ jsxRuntime.jsx("hr", { ref, className: separatorClassName, ...props });
|
|
244
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuItem.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n/** Vertical placement of a {@link DropdownMenuLabel} within its group. */\nexport type DropdownMenuLabelPosition = \"default\" | \"top\";\n\n/** Props for the {@link DropdownMenuLabel} component. */\nexport interface DropdownMenuLabelProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> {\n /**\n * Vertical placement within the surrounding group. `\"top\"` is used for the\n * first label directly under a header; `\"default\"` adds extra top padding to\n * separate it from preceding items. @default \"default\"\n */\n position?: DropdownMenuLabelPosition;\n}\n\n/** A non-interactive label that groups related items within a menu. */\nexport const DropdownMenuLabel = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Label>,\n DropdownMenuLabelProps\n>(({ className, position = \"default\", ...props }, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const labelClassName = cn(\n \"typography-description-12px-regular flex items-center px-3 text-content-secondary\",\n position === \"top\" ? \"py-2\" : \"pt-4 pb-2\",\n className,\n );\n\n // DropdownMenuPrimitive.Label requires Radix menu context, unavailable when\n // the sheet variant renders inside a Drawer (Dialog) instead.\n if (variant === \"sheet\") {\n return <div ref={ref} className={labelClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Label ref={ref} className={labelClassName} {...props} />;\n});\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\";\n\n/**\n * Height preset for a dropdown menu item.\n *\n * `\"40\"` (default) and `\"32\"` are the v2 numeric tokens that mirror the Figma\n * design system. `\"sm\"` and `\"md\"` are deprecated aliases retained for\n * backwards compatibility — `\"sm\"` maps to `\"32\"`, `\"md\"` maps to `\"40\"`.\n */\nexport type DropdownMenuItemSize =\n | \"40\"\n | \"32\"\n /** @deprecated Use `\"32\"` instead. */\n | \"sm\"\n /** @deprecated Use `\"40\"` instead. */\n | \"md\";\n\nconst SIZE_NORMALIZED: Record<DropdownMenuItemSize, \"40\" | \"32\"> = {\n \"40\": \"40\",\n md: \"40\",\n \"32\": \"32\",\n sm: \"32\",\n};\n\nconst ITEM_SIZE_CLASSES: Record<\"40\" | \"32\", string> = {\n \"40\": \"min-h-10 py-2 typography-body-small-14px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\n/*\n * 14px at both heights. `V2 Menu Item` draws the count as `Body Small 14px/Regular`\n * in `content-tertiary` (node `21542:8629`), and the 40 row previously stepped up to\n * 16px — which also put the count's line box at 24px against the two-line layout's\n * 18px title leading.\n *\n * Only the 40 row is drawn in Figma: the component set's variants are Type and State\n * with no size axis. The 32 row is ours, and 14px matches the body type it already\n * uses, so both entries agree by construction rather than by design reference.\n */\nconst ITEM_COUNT_TYPOGRAPHY: Record<\"40\" | \"32\", string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface DropdownMenuItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {\n /** Height of the menu item row. @default \"40\" */\n size?: DropdownMenuItemSize;\n /** Applies the destructive (error) treatment. Use for irreversible actions. @default false */\n destructive?: boolean;\n /**\n * Icon (or other node) rendered before the label. Ignored when {@link DropdownMenuItemProps.avatar} is set.\n * Icons sit in a 16px box in `Icons/Secondary`, and prop-based icons draw filled at 16px unless they set\n * `filled` or `size` themselves (`filled={false}` opts out). Legacy icons such as `TrashBinIcon` stay outlined.\n */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link DropdownMenuItemProps.leadingIcon},\n * for rows that represent a person or account. Pass an `Avatar` sized to `24`.\n * Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /**\n * Icon (or other node) rendered after the label. Treated like {@link DropdownMenuItemProps.leadingIcon}.\n */\n trailingIcon?: React.ReactNode;\n /** Trailing count or number (e.g. an unread total) rendered before {@link DropdownMenuItemProps.trailingIcon}. */\n count?: React.ReactNode;\n /**\n * A small action drawn at the row's end, after everything else — typically a 24px\n * `Button` rendered `asChild` as a span. The whole row performs the action through\n * `onSelect`, so pass a visual, never a second interactive control. Its text joins the\n * row's accessible name, so the label people see is also the one they can speak.\n * The row does not restyle it: when the row is `disabled`, disable the visual too\n * (or show its `loading` state) so it does not look live.\n */\n trailingAction?: React.ReactNode;\n /**\n * Optional secondary text rendered on a second line below the label. When\n * provided, the row switches to a two-line layout and the leading/trailing\n * icons align to the title line (top) rather than the row's vertical centre.\n */\n description?: React.ReactNode;\n /**\n * Marks the item as the current selection in a single-select menu. The row\n * rests on `Buttons/Navigation/Hover` with a semibold label; hover still shows\n * `Interaction/Hover`, because `data-[highlighted]` outranks the selected class.\n * Under the v2 palette that fill is inverted, with inverted content, and a\n * highlighted row moves to `Menu Item Selected Hover` so keyboard focus stays visible.\n * The row also gets `data-selected`, and `aria-current` unless the consumer\n * already sets `aria-checked`.\n * @default false\n */\n selected?: boolean;\n}\n\n/**\n * Under the v2 palette a selected row's `Menu Item Selected` fill is inverted, so its\n * content inverts too, and a highlighted row moves to `Menu Item Selected Hover`.\n */\nconst SELECTED_V2_CLASSES =\n \"theme-v2:text-content-primary-inverted theme-v2:data-[highlighted]:bg-menu-item-selected-hover\";\n\n/**\n * Secondary lines (description, count) on a selected row under the v2 palette: inverted,\n * and `Menu Item Selected Hover Secondary` while the row is highlighted, so they keep\n * contrast on the hover fill.\n */\nconst SELECTED_SECONDARY_V2_CLASSES =\n \"theme-v2:group-data-[selected]:text-content-secondary-inverted theme-v2:group-data-[selected]:group-data-[highlighted]:text-menu-item-selected-hover-secondary\";\n\n/** A disabled selected row takes the library's Disabled state under the v2 palette, which has no fill. */\nconst SELECTED_DISABLED_V2_CLASSES = \"theme-v2:bg-transparent\";\n\n/**\n * An individual item within a {@link DropdownMenuContent}.\n *\n * Rows do not shrink (`shrink-0`): the panel is a scrolling flex column capped at the\n * space available, and a row allowed to shrink would drop to its minimum height and\n * spill a second line.\n *\n * @example\n * ```tsx\n * <DropdownMenuItem>Edit profile</DropdownMenuItem>\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * <DropdownMenuItem leadingIcon={<EditIcon />}>Edit</DropdownMenuItem>\n *\n * // Feature-rich row with an avatar and a trailing count\n * <DropdownMenuItem avatar={<Avatar size={24} src={src} />} count=\"12\">\n * Jane Doe\n * </DropdownMenuItem>\n *\n * // As a link\n * <DropdownMenuItem asChild>\n * <a href=\"/settings\">Settings</a>\n * </DropdownMenuItem>\n * ```\n */\nexport const DropdownMenuItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(\n (\n {\n size = \"40\",\n destructive,\n leadingIcon,\n avatar,\n trailingIcon,\n count,\n trailingAction,\n description,\n selected,\n className,\n children,\n asChild,\n onSelect,\n disabled,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const normalizedSize = SIZE_NORMALIZED[size];\n const hasDescription = description != null;\n const hasAvatar = avatar != null;\n const itemClassName = cn(\n // `text-start` because the sheet variant renders the row as a <button>,\n // whose UA-centred text misaligned it from the popper variant's rows.\n \"group flex w-full shrink-0 cursor-pointer gap-2 rounded-sm px-3 text-start outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n // The sheet's header runs the full width of the panel, so its rows have to\n // come in off the edge themselves — 4px here on the panel's own 4px gives the\n // same 8px inset as the popper panel. `w-auto` lets the column stretch them\n // to the space left over; `w-full` plus a margin would overflow.\n variant === \"sheet\" && \"mx-1 w-auto\",\n ITEM_SIZE_CLASSES[normalizedSize],\n // A 24px avatar or trailing action would push the compact 32px row past its\n // height with the default padding; tighten it so the row keeps the 32px contract.\n (hasAvatar || trailingAction != null) && !hasDescription && normalizedSize === \"32\" && \"py-1\",\n \"data-[highlighted]:bg-interaction-hover\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n \"disabled:cursor-not-allowed disabled:text-content-disabled\",\n // Sheet-variant asChild items are marked disabled via aria-disabled\n // (see below), not the native disabled attribute or Radix's\n // data-disabled — neither selector above matches them.\n \"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled\",\n destructive && \"text-error-content\",\n selected && [\n \"bg-menu-item-selected\",\n disabled ? SELECTED_DISABLED_V2_CLASSES : SELECTED_V2_CLASSES,\n ],\n className,\n );\n const selectedProps = selected\n ? {\n ...(props[\"aria-checked\"] === undefined && { \"aria-current\": \"true\" as const }),\n \"data-selected\": \"\",\n }\n : undefined;\n\n // In the two-line (description) layout everything beside the title sits on\n // the title's line, not the centre of the two-line block. A box the height of\n // that line centres each sibling on it whatever its own size — a 16px icon, a\n // 24px avatar, or the count's larger text box. The height is the title's, from\n // `typography-body-small-14px-semibold`; a `pt-*` nudge cannot do this because\n // the correct offset differs per sibling, and the previous `pt-1` was computed\n // against the single-line title's 24px leading, leaving all four 3px low.\n const iconAlignClassName = hasDescription ? \"flex h-4.5 shrink-0 items-center\" : null;\n\n const countNode = count != null && (\n <span\n className={cn(\n \"shrink-0 tabular-nums\",\n iconAlignClassName,\n ITEM_COUNT_TYPOGRAPHY[normalizedSize],\n destructive ? \"text-error-content\" : \"text-content-tertiary\",\n \"group-data-[disabled]:text-content-disabled\",\n !disabled && SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {count}\n </span>\n );\n\n // Destructive rows keep the row's error colour on their icons.\n const renderIcon = (icon: React.ReactNode, className?: string) => (\n <MenuRowIcon\n inheritColor={destructive}\n alignToTitle={hasDescription}\n invertWhenSelected={!disabled}\n className={className}\n >\n {icon}\n </MenuRowIcon>\n );\n const leadingNode = leadingIcon != null && renderIcon(leadingIcon);\n\n // In an asChild row the consumer's children have no flex-1 wrapper, so `ms-auto`\n // pushes the trailing icon to the row's end.\n const trailingNode =\n trailingIcon != null && renderIcon(trailingIcon, asChild ? \"ms-auto\" : undefined);\n const trailingActionNode = trailingAction != null && (\n <span\n className={cn(\n \"flex shrink-0 items-center\",\n iconAlignClassName,\n asChild && trailingIcon == null && \"ms-auto\",\n )}\n >\n {trailingAction}\n </span>\n );\n\n const itemChildren = (\n <>\n {avatar != null ? (\n <span className={cn(\"shrink-0\", iconAlignClassName, disabled && \"theme-v2:opacity-60\")}>\n {avatar}\n </span>\n ) : (\n leadingNode\n )}\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n {/*\n * The two-line row sets its own title type rather than inheriting the\n * row's: `V2 Menu Item` pairs a 14px semibold title with the 14px\n * regular description below it, where a single-line row's title is the\n * size's own 14px regular. It also settles the row's height — 18 + 2 +\n * 18 of text inside `py-2` is the design's 54px.\n */}\n <span className=\"typography-body-small-14px-semibold truncate\">{children}</span>\n <span\n className={cn(\n \"typography-body-small-14px-regular truncate text-content-secondary\",\n disabled ? \"theme-v2:text-content-disabled\" : SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className={cn(\"min-w-0 flex-1 truncate\", selected && \"font-semibold\")}>\n {children}\n </span>\n )}\n {countNode}\n {trailingNode}\n {trailingActionNode}\n </>\n );\n\n // The sheet variant renders inside a Drawer (Dialog), not a Radix menu, so\n // DropdownMenuPrimitive.Item (which requires menu context) can't be used —\n // render a plain option element with equivalent selection semantics instead.\n // asChild goes through the same Slot primitive Radix's own Item uses\n // internally, so a custom element (e.g. a link) gets the option\n // role/handlers merged onto it without needing menu context.\n if (variant === \"sheet\") {\n const Comp = asChild ? Slot : \"button\";\n // Pull the consumer's onClick out of the passthrough spread so the\n // handler below can compose with it instead of the spread order\n // silently overwriting it (an explicit onClick after {...props} always\n // wins over the spread's).\n const { onClick: consumerOnClick, ...restProps } =\n props as React.ComponentPropsWithoutRef<\"button\">;\n const sheetSpecificProps = !asChild\n ? { type: \"button\" as const, disabled }\n : disabled\n ? { \"aria-disabled\": true }\n : {};\n return (\n <Comp\n ref={ref as React.Ref<HTMLButtonElement>}\n {...restProps}\n {...sheetSpecificProps}\n role=\"option\"\n aria-selected={selected}\n data-selected={selected ? \"\" : undefined}\n className={itemClassName}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n // A native <button disabled> already blocks its click event, but\n // asChild's element (e.g. a link) has no such enforcement — guard\n // explicitly, and prevent the click's default action (e.g. anchor\n // navigation) since aria-disabled alone doesn't stop it.\n if (disabled) {\n event.preventDefault();\n return;\n }\n consumerOnClick?.(event);\n if (event.defaultPrevented) return;\n // Pass the real native event through, not a fake partial shape —\n // handlers that call any Event API beyond preventDefault (e.g.\n // stopPropagation, composedPath) need it to actually exist. It's\n // still live (currentTarget/target are valid) since we're inside\n // the same synchronous click handler that produced it.\n onSelect?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) toggleOpen?.(() => false);\n }}\n >\n {asChild\n ? [\n leadingNode,\n <Slottable key=\"children\">{children}</Slottable>,\n trailingNode,\n trailingActionNode,\n ]\n : itemChildren}\n </Comp>\n );\n }\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n asChild\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {/* The icons slot into the consumer's element (e.g. a link) around its own children. */}\n <Slot>\n {leadingNode}\n <Slottable>{children}</Slottable>\n {trailingNode}\n {trailingActionNode}\n </Slot>\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {itemChildren}\n </DropdownMenuPrimitive.Item>\n );\n },\n);\nDropdownMenuItem.displayName = \"DropdownMenuItem\";\n\n/** Props for the {@link DropdownMenuSeparator} component. */\nexport interface DropdownMenuSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> {}\n\n/** Visual separator between groups of items. */\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n DropdownMenuSeparatorProps\n>(({ className, ...props }, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // border-0 resets the currentColor border-top that preflight gives <hr>,\n // which would otherwise draw a second line on the sheet variant.\n const separatorClassName = cn(\"my-[5px] h-px border-0 bg-neutral-alphas-200\", className);\n\n // DropdownMenuPrimitive.Separator requires Radix menu context, unavailable\n // when the sheet variant renders inside a Drawer (Dialog) instead. <hr> is a\n // native separator, so it needs no ARIA role.\n if (variant === \"sheet\") {\n return <hr ref={ref as React.Ref<HTMLHRElement>} className={separatorClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Separator ref={ref} className={separatorClassName} {...props} />;\n});\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n"],"names":["React","DropdownMenuVariantContext","cn","jsx","DropdownMenuPrimitive","ToggleOpenContext","className","MenuRowIcon","jsxs","Fragment","Slot","Slottable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,oBAAoBA,iBAAM,WAGrC,CAAC,EAAE,WAAW,WAAW,WAAW,GAAG,MAAA,GAAS,QAAQ;AACxD,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAC3D,QAAM,iBAAiBC,GAAAA;AAAAA,IACrB;AAAA,IACA,aAAa,QAAQ,SAAS;AAAA,IAC9B;AAAA,EAAA;AAKF,MAAI,YAAY,SAAS;AACvB,0CAAQ,OAAA,EAAI,KAAU,WAAW,gB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A,SAAO;AAAA,UACP,WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UACH,GAAG;AAAA,UAGJ,0CAACM,gBAAA,EACE,UAAA;AAAA,YAAA;AAAA,YACDP,+BAACQ,UAAAA,aAAW,UAAS;AAAA,YACpB;AAAA,YACA;AAAA,UAAA,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAGN;AAEA,WACER,2BAAAA;AAAAA,MAACC,iCAAsB;AAAA,MAAtB;AAAA,QACC;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACH,GAAG;AAAA,QAEH,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AACA,iBAAiB,cAAc;AAOxB,MAAM,wBAAwBJ,iBAAM,WAGzC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAAQ;AAClC,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAG3D,QAAM,qBAAqBC,GAAAA,GAAG,gDAAgD,SAAS;AAKvF,MAAI,YAAY,SAAS;AACvB,0CAAQ,MAAA,EAAG,KAAsC,WAAW,oBAAqB,GAAG,OAAO;AAAA,EAC7F;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,WAAtB,EAAgC,KAAU,WAAW,oBAAqB,GAAG,OAAO;AAC9F,CAAC;AACD,sBAAsB,cAAc;;;;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenuItem.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenuItem.tsx"],"sourcesContent":["import * as DropdownMenuPrimitive from \"@radix-ui/react-dropdown-menu\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { MenuRowIcon } from \"../Icons/MenuRowIcon\";\nimport { DropdownMenuVariantContext, ToggleOpenContext } from \"./context\";\n\n/** Vertical placement of a {@link DropdownMenuLabel} within its group. */\nexport type DropdownMenuLabelPosition = \"default\" | \"top\";\n\n/** Props for the {@link DropdownMenuLabel} component. */\nexport interface DropdownMenuLabelProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> {\n /**\n * Vertical placement within the surrounding group. `\"top\"` is used for the\n * first label directly under a header; `\"default\"` adds extra top padding to\n * separate it from preceding items. @default \"default\"\n */\n position?: DropdownMenuLabelPosition;\n}\n\n/** A non-interactive label that groups related items within a menu. */\nexport const DropdownMenuLabel = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Label>,\n DropdownMenuLabelProps\n>(({ className, position = \"default\", ...props }, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const labelClassName = cn(\n \"typography-description-12px-regular flex items-center px-3 text-content-secondary\",\n position === \"top\" ? \"py-2\" : \"pt-4 pb-2\",\n className,\n );\n\n // DropdownMenuPrimitive.Label requires Radix menu context, unavailable when\n // the sheet variant renders inside a Drawer (Dialog) instead.\n if (variant === \"sheet\") {\n return <div ref={ref} className={labelClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Label ref={ref} className={labelClassName} {...props} />;\n});\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\";\n\n/**\n * Height preset for a dropdown menu item.\n *\n * `\"40\"` (default) and `\"32\"` are the v2 numeric tokens that mirror the Figma\n * design system. `\"sm\"` and `\"md\"` are deprecated aliases retained for\n * backwards compatibility — `\"sm\"` maps to `\"32\"`, `\"md\"` maps to `\"40\"`.\n */\nexport type DropdownMenuItemSize =\n | \"40\"\n | \"32\"\n /** @deprecated Use `\"32\"` instead. */\n | \"sm\"\n /** @deprecated Use `\"40\"` instead. */\n | \"md\";\n\nconst SIZE_NORMALIZED: Record<DropdownMenuItemSize, \"40\" | \"32\"> = {\n \"40\": \"40\",\n md: \"40\",\n \"32\": \"32\",\n sm: \"32\",\n};\n\nconst ITEM_SIZE_CLASSES: Record<\"40\" | \"32\", string> = {\n \"40\": \"min-h-10 py-2 typography-body-small-14px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\n/*\n * 14px at both heights. `V2 Menu Item` draws the count as `Body Small 14px/Regular`\n * in `content-tertiary` (node `21542:8629`), and the 40 row previously stepped up to\n * 16px — which also put the count's line box at 24px against the two-line layout's\n * 18px title leading.\n *\n * Only the 40 row is drawn in Figma: the component set's variants are Type and State\n * with no size axis. The 32 row is ours, and 14px matches the body type it already\n * uses, so both entries agree by construction rather than by design reference.\n */\nconst ITEM_COUNT_TYPOGRAPHY: Record<\"40\" | \"32\", string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface DropdownMenuItemProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {\n /** Height of the menu item row. @default \"40\" */\n size?: DropdownMenuItemSize;\n /** Applies the destructive (error) treatment. Use for irreversible actions. @default false */\n destructive?: boolean;\n /**\n * Icon (or other node) rendered before the label. Ignored when {@link DropdownMenuItemProps.avatar} is set.\n * Icons sit in a 16px box in `Icons/Secondary`, and prop-based icons draw filled at 16px unless they set\n * `filled` or `size` themselves (`filled={false}` opts out). Legacy icons such as `TrashBinIcon` stay outlined.\n */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link DropdownMenuItemProps.leadingIcon},\n * for rows that represent a person or account. Pass an `Avatar` sized to `24`.\n * Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /**\n * Icon (or other node) rendered after the label. Treated like {@link DropdownMenuItemProps.leadingIcon}.\n */\n trailingIcon?: React.ReactNode;\n /** Trailing count or number (e.g. an unread total) rendered before {@link DropdownMenuItemProps.trailingIcon}. */\n count?: React.ReactNode;\n /**\n * A small action drawn at the row's end, after everything else — typically a 24px\n * `Button` rendered `asChild` as a span. The whole row performs the action through\n * `onSelect`, so pass a visual, never a second interactive control. Its text joins the\n * row's accessible name, so the label people see is also the one they can speak.\n * The row does not restyle it: when the row is `disabled`, disable the visual too\n * (or show its `loading` state) so it does not look live.\n */\n trailingAction?: React.ReactNode;\n /**\n * Optional secondary text rendered on a second line below the label. When\n * provided, the row switches to a two-line layout and the leading/trailing\n * icons align to the title line (top) rather than the row's vertical centre.\n */\n description?: React.ReactNode;\n /**\n * Marks the item as the current selection in a single-select menu. The row\n * rests on `Buttons/Navigation/Hover` with a semibold label; hover still shows\n * `Interaction/Hover`, because `data-[highlighted]` outranks the selected class.\n * Under the v2 palette that fill is inverted, with inverted content, and a\n * highlighted row moves to `Menu Item Selected Hover` so keyboard focus stays visible.\n * The row also gets `data-selected`, and `aria-current` unless the consumer\n * already sets `aria-checked`.\n * @default false\n */\n selected?: boolean;\n}\n\n/**\n * Under the v2 palette a selected row's `Menu Item Selected` fill is inverted, so its\n * content inverts too, and a highlighted row moves to `Menu Item Selected Hover`.\n */\nconst SELECTED_V2_CLASSES =\n \"theme-v2:text-content-primary-inverted theme-v2:data-[highlighted]:bg-menu-item-selected-hover\";\n\n/**\n * Secondary lines (description, count) on a selected row under the v2 palette: inverted,\n * and `Menu Item Selected Hover Secondary` while the row is highlighted, so they keep\n * contrast on the hover fill.\n */\nconst SELECTED_SECONDARY_V2_CLASSES =\n \"theme-v2:group-data-[selected]:text-content-secondary-inverted theme-v2:group-data-[selected]:group-data-[highlighted]:text-menu-item-selected-hover-secondary\";\n\n/** A disabled selected row takes the library's Disabled state under the v2 palette, which has no fill. */\nconst SELECTED_DISABLED_V2_CLASSES = \"theme-v2:bg-transparent\";\n\n/**\n * An individual item within a {@link DropdownMenuContent}.\n *\n * Rows do not shrink (`shrink-0`): the panel is a scrolling flex column capped at the\n * space available, and a row allowed to shrink would drop to its minimum height and\n * spill a second line.\n *\n * @example\n * ```tsx\n * <DropdownMenuItem>Edit profile</DropdownMenuItem>\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * <DropdownMenuItem leadingIcon={<EditIcon />}>Edit</DropdownMenuItem>\n *\n * // Feature-rich row with an avatar and a trailing count\n * <DropdownMenuItem avatar={<Avatar size={24} src={src} />} count=\"12\">\n * Jane Doe\n * </DropdownMenuItem>\n *\n * // As a link\n * <DropdownMenuItem asChild>\n * <a href=\"/settings\">Settings</a>\n * </DropdownMenuItem>\n * ```\n */\nexport const DropdownMenuItem = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Item>,\n DropdownMenuItemProps\n>(\n (\n {\n size = \"40\",\n destructive,\n leadingIcon,\n avatar,\n trailingIcon,\n count,\n trailingAction,\n description,\n selected,\n className,\n children,\n asChild,\n onSelect,\n disabled,\n ...props\n },\n ref,\n ) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n const toggleOpen = React.useContext(ToggleOpenContext);\n const normalizedSize = SIZE_NORMALIZED[size];\n const hasDescription = description != null;\n const hasAvatar = avatar != null;\n const itemClassName = cn(\n // `text-start` because the sheet variant renders the row as a <button>,\n // whose UA-centred text misaligned it from the popper variant's rows.\n \"group flex w-full shrink-0 cursor-pointer gap-2 rounded-sm px-3 text-start outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n // The sheet's header runs the full width of the panel, so its rows have to\n // come in off the edge themselves — 4px here on the panel's own 4px gives the\n // same 8px inset as the popper panel. `w-auto` lets the column stretch them\n // to the space left over; `w-full` plus a margin would overflow.\n variant === \"sheet\" && \"mx-1 w-auto\",\n ITEM_SIZE_CLASSES[normalizedSize],\n // A 24px avatar or trailing action would push the compact 32px row past its\n // height with the default padding; tighten it so the row keeps the 32px contract.\n (hasAvatar || trailingAction != null) && !hasDescription && normalizedSize === \"32\" && \"py-1\",\n \"data-[highlighted]:bg-interaction-hover\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-content-disabled\",\n \"disabled:cursor-not-allowed disabled:text-content-disabled\",\n // Sheet-variant asChild items are marked disabled via aria-disabled\n // (see below), not the native disabled attribute or Radix's\n // data-disabled — neither selector above matches them.\n \"aria-disabled:cursor-not-allowed aria-disabled:text-content-disabled\",\n destructive && \"text-error-content\",\n selected && [\n \"bg-menu-item-selected\",\n disabled ? SELECTED_DISABLED_V2_CLASSES : SELECTED_V2_CLASSES,\n ],\n className,\n );\n const selectedProps = selected\n ? {\n ...(props[\"aria-checked\"] === undefined && { \"aria-current\": \"true\" as const }),\n \"data-selected\": \"\",\n }\n : undefined;\n\n // In the two-line (description) layout everything beside the title sits on\n // the title's line, not the centre of the two-line block. A box the height of\n // that line centres each sibling on it whatever its own size — a 16px icon, a\n // 24px avatar, or the count's larger text box. The height is the title's, from\n // `typography-body-small-14px-semibold`; a `pt-*` nudge cannot do this because\n // the correct offset differs per sibling, and the previous `pt-1` was computed\n // against the single-line title's 24px leading, leaving all four 3px low.\n const iconAlignClassName = hasDescription ? \"flex h-4.5 shrink-0 items-center\" : null;\n\n const countNode = count != null && (\n <span\n className={cn(\n \"shrink-0 tabular-nums\",\n iconAlignClassName,\n ITEM_COUNT_TYPOGRAPHY[normalizedSize],\n destructive ? \"text-error-content\" : \"text-content-tertiary\",\n \"group-data-[disabled]:text-content-disabled\",\n !disabled && SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {count}\n </span>\n );\n\n // Destructive rows keep the row's error colour on their icons.\n const renderIcon = (icon: React.ReactNode, className?: string) => (\n <MenuRowIcon\n inheritColor={destructive}\n alignToTitle={hasDescription}\n invertWhenSelected={!disabled}\n className={className}\n >\n {icon}\n </MenuRowIcon>\n );\n const leadingNode = leadingIcon != null && renderIcon(leadingIcon);\n\n // In an asChild row the consumer's children have no flex-1 wrapper, so `ms-auto`\n // pushes the trailing icon to the row's end.\n const trailingNode =\n trailingIcon != null && renderIcon(trailingIcon, asChild ? \"ms-auto\" : undefined);\n const trailingActionNode = trailingAction != null && (\n <span\n className={cn(\n \"flex shrink-0 items-center\",\n iconAlignClassName,\n asChild && trailingIcon == null && \"ms-auto\",\n )}\n >\n {trailingAction}\n </span>\n );\n\n const itemChildren = (\n <>\n {avatar != null ? (\n <span className={cn(\"shrink-0\", iconAlignClassName, disabled && \"theme-v2:opacity-60\")}>\n {avatar}\n </span>\n ) : (\n leadingNode\n )}\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n {/*\n * The two-line row sets its own title type rather than inheriting the\n * row's: `V2 Menu Item` pairs a 14px semibold title with the 14px\n * regular description below it, where a single-line row's title is the\n * size's own 14px regular. It also settles the row's height — 18 + 2 +\n * 18 of text inside `py-2` is the design's 54px.\n */}\n <span className=\"typography-body-small-14px-semibold truncate\">{children}</span>\n <span\n className={cn(\n \"typography-body-small-14px-regular truncate text-content-secondary\",\n disabled ? \"theme-v2:text-content-disabled\" : SELECTED_SECONDARY_V2_CLASSES,\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className={cn(\"min-w-0 flex-1 truncate\", selected && \"font-semibold\")}>\n {children}\n </span>\n )}\n {countNode}\n {trailingNode}\n {trailingActionNode}\n </>\n );\n\n // The sheet variant renders inside a Drawer (Dialog), not a Radix menu, so\n // DropdownMenuPrimitive.Item (which requires menu context) can't be used —\n // render a plain option element with equivalent selection semantics instead.\n // asChild goes through the same Slot primitive Radix's own Item uses\n // internally, so a custom element (e.g. a link) gets the option\n // role/handlers merged onto it without needing menu context.\n if (variant === \"sheet\") {\n const Comp = asChild ? Slot : \"button\";\n // Pull the consumer's onClick out of the passthrough spread so the\n // handler below can compose with it instead of the spread order\n // silently overwriting it (an explicit onClick after {...props} always\n // wins over the spread's).\n const { onClick: consumerOnClick, ...restProps } =\n props as React.ComponentPropsWithoutRef<\"button\">;\n const sheetSpecificProps = !asChild\n ? { type: \"button\" as const, disabled }\n : disabled\n ? { \"aria-disabled\": true }\n : {};\n return (\n <Comp\n ref={ref as React.Ref<HTMLButtonElement>}\n {...restProps}\n {...sheetSpecificProps}\n role=\"option\"\n aria-selected={selected}\n data-selected={selected ? \"\" : undefined}\n className={itemClassName}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n // A native <button disabled> already blocks its click event, but\n // asChild's element (e.g. a link) has no such enforcement — guard\n // explicitly, and prevent the click's default action (e.g. anchor\n // navigation) since aria-disabled alone doesn't stop it.\n if (disabled) {\n event.preventDefault();\n return;\n }\n consumerOnClick?.(event);\n if (event.defaultPrevented) return;\n // Pass the real native event through, not a fake partial shape —\n // handlers that call any Event API beyond preventDefault (e.g.\n // stopPropagation, composedPath) need it to actually exist. It's\n // still live (currentTarget/target are valid) since we're inside\n // the same synchronous click handler that produced it.\n onSelect?.(event.nativeEvent);\n if (!event.nativeEvent.defaultPrevented) toggleOpen?.(() => false);\n }}\n >\n {asChild\n ? [\n leadingNode,\n <Slottable key=\"children\">{children}</Slottable>,\n trailingNode,\n trailingActionNode,\n ]\n : itemChildren}\n </Comp>\n );\n }\n\n if (asChild) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n asChild\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {/* The icons slot into the consumer's element (e.g. a link) around its own children. */}\n <Slot>\n {leadingNode}\n <Slottable>{children}</Slottable>\n {trailingNode}\n {trailingActionNode}\n </Slot>\n </DropdownMenuPrimitive.Item>\n );\n }\n\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={itemClassName}\n disabled={disabled}\n onSelect={onSelect}\n {...selectedProps}\n {...props}\n >\n {itemChildren}\n </DropdownMenuPrimitive.Item>\n );\n },\n);\nDropdownMenuItem.displayName = \"DropdownMenuItem\";\n\n/** Props for the {@link DropdownMenuSeparator} component. */\nexport interface DropdownMenuSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> {}\n\n/** Visual separator between groups of items. */\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n DropdownMenuSeparatorProps\n>(({ className, ...props }, ref) => {\n const variant = React.useContext(DropdownMenuVariantContext);\n // border-0 resets the currentColor border-top that preflight gives <hr>,\n // which would otherwise draw a second line on the sheet variant.\n const separatorClassName = cn(\"my-1.5 h-px border-0 bg-neutral-alphas-200\", className);\n\n // DropdownMenuPrimitive.Separator requires Radix menu context, unavailable\n // when the sheet variant renders inside a Drawer (Dialog) instead. <hr> is a\n // native separator, so it needs no ARIA role.\n if (variant === \"sheet\") {\n return <hr ref={ref as React.Ref<HTMLHRElement>} className={separatorClassName} {...props} />;\n }\n\n return <DropdownMenuPrimitive.Separator ref={ref} className={separatorClassName} {...props} />;\n});\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\";\n"],"names":["React","DropdownMenuVariantContext","cn","jsx","DropdownMenuPrimitive","ToggleOpenContext","className","MenuRowIcon","jsxs","Fragment","Slot","Slottable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,oBAAoBA,iBAAM,WAGrC,CAAC,EAAE,WAAW,WAAW,WAAW,GAAG,MAAA,GAAS,QAAQ;AACxD,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAC3D,QAAM,iBAAiBC,GAAAA;AAAAA,IACrB;AAAA,IACA,aAAa,QAAQ,SAAS;AAAA,IAC9B;AAAA,EAAA;AAKF,MAAI,YAAY,SAAS;AACvB,0CAAQ,OAAA,EAAI,KAAU,WAAW,gBAAiB,GAAG,OAAO;AAAA,EAC9D;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,OAAtB,EAA4B,KAAU,WAAW,gBAAiB,GAAG,OAAO;AACtF,CAAC;AACD,kBAAkB,cAAc;AAiBhC,MAAM,kBAA6D;AAAA,EACjE,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,IAAI;AACN;AAEA,MAAM,oBAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AACR;AAYA,MAAM,wBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AACR;AA0DA,MAAM,sBACJ;AAOF,MAAM,gCACJ;AAGF,MAAM,+BAA+B;AA0B9B,MAAM,mBAAmBJ,iBAAM;AAAA,EAIpC,CACE;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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AClC,QAAM,UAAUA,iBAAM,WAAWC,kCAA0B;AAG3D,QAAM,qBAAqBC,GAAAA,GAAG,8CAA8C,SAAS;AAKrF,MAAI,YAAY,SAAS;AACvB,0CAAQ,MAAA,EAAG,KAAsC,WAAW,oBAAqB,GAAG,OAAO;AAAA,EAC7F;AAEA,SAAOC,2BAAAA,IAACC,iCAAsB,WAAtB,EAAgC,KAAU,WAAW,oBAAqB,GAAG,OAAO;AAC9F,CAAC;AACD,sBAAsB,cAAc;;;;"}
|
|
@@ -158,7 +158,7 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
158
158
|
position: "bottom",
|
|
159
159
|
variant: "menu",
|
|
160
160
|
overlayProps: { className: "backdrop-blur-[8px]" },
|
|
161
|
-
className: cn.cn("flex flex-col gap-
|
|
161
|
+
className: cn.cn("flex flex-col gap-0.5 p-1 pb-2", className),
|
|
162
162
|
style,
|
|
163
163
|
onPointerDownOutside,
|
|
164
164
|
onCloseAutoFocus,
|
|
@@ -192,7 +192,7 @@ const DropdownMenuContent = React__namespace.forwardRef(
|
|
|
192
192
|
// (library node `17245:2317`) adds 8px of padding here. Rows inside it
|
|
193
193
|
// are 12px `rounded-sm`, the library's `V2 Menu Item` radius.
|
|
194
194
|
floatingContentSurface.FLOATING_CONTENT_SURFACE_CLASS,
|
|
195
|
-
"flex w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) flex-col gap-
|
|
195
|
+
"flex w-max min-w-(--radix-dropdown-menu-trigger-width) max-w-(--radix-dropdown-menu-content-available-width) flex-col gap-0.5 overflow-y-auto p-2",
|
|
196
196
|
"data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in",
|
|
197
197
|
"data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out",
|
|
198
198
|
"data-[side=top]:slide-in-from-bottom-2 data-[side=bottom]:slide-in-from-top-2",
|
|
@@ -215,7 +215,7 @@ const DropdownMenuGroup = React__namespace.forwardRef(({ className, ...props },
|
|
|
215
215
|
DropdownMenuPrimitive__namespace.Group,
|
|
216
216
|
{
|
|
217
217
|
ref,
|
|
218
|
-
className: cn.cn("flex flex-col gap-
|
|
218
|
+
className: cn.cn("flex flex-col gap-0.5", className),
|
|
219
219
|
...props
|
|
220
220
|
}
|
|
221
221
|
));
|