@langchain/macaw-components 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/_chunks/{ErrorState-CmPX01HV.js → ErrorState-BY6VBCRB.js} +2 -2
- package/dist/_chunks/{ErrorState-CmPX01HV.js.map → ErrorState-BY6VBCRB.js.map} +1 -1
- package/dist/_chunks/{LoadingIndicator-DujSAzqj.js → LoadingIndicator-Itl4c0WV.js} +10 -10
- package/dist/_chunks/LoadingIndicator-Itl4c0WV.js.map +1 -0
- package/dist/base.css +14 -1
- package/dist/catalog.json +481 -478
- package/dist/components/Banner/Banner.js +3 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/BarChart/AnimatedBar.js +1 -1
- package/dist/components/BarChart/AnimatedBar.js.map +1 -1
- package/dist/components/BarChart/BarChartPlot.js +1 -1
- package/dist/components/BarChart/BarChartPlot.js.map +1 -1
- package/dist/components/Button/constants.js +2 -2
- package/dist/components/Button/constants.js.map +1 -1
- package/dist/components/ChartLegend/ChartLegend.js +1 -1
- package/dist/components/ChartLegend/ChartLegend.js.map +1 -1
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js +2 -2
- package/dist/components/ChartLegend/ChartLegendItemRenderer.js.map +1 -1
- package/dist/components/Checkbox/constants.d.ts +1 -1
- package/dist/components/Checkbox/constants.js +1 -1
- package/dist/components/Checkbox/constants.js.map +1 -1
- package/dist/components/Code/CodeLite.d.ts +16 -2
- package/dist/components/Code/CodeLite.js +79 -33
- package/dist/components/Code/CodeLite.js.map +1 -1
- package/dist/components/Code/CodeLite.utils.d.ts +1 -1
- package/dist/components/Code/CodeLite.utils.js +2 -2
- package/dist/components/Code/CodeLite.utils.js.map +1 -1
- package/dist/components/Code/CodeLiteDiff.d.ts +2 -0
- package/dist/components/Code/CodeLiteDiff.js +102 -0
- package/dist/components/Code/CodeLiteDiff.js.map +1 -0
- package/dist/components/Code/CodeToolbar.js +7 -3
- package/dist/components/Code/CodeToolbar.js.map +1 -1
- package/dist/components/Code/JsonHighlighterExtension.js +1 -1
- package/dist/components/Code/JsonHighlighterExtension.js.map +1 -1
- package/dist/components/Code/index.js +1 -1
- package/dist/components/Command/Command.js +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/Command/CommandMenu.js +2 -2
- package/dist/components/Command/CommandMenu.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/DonutChart/DonutChart.js +1 -1
- package/dist/components/DonutChart/DonutChart.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.js +1 -1
- package/dist/components/ErrorState/index.js +1 -1
- package/dist/components/Input/inputStyles.js +2 -2
- package/dist/components/Input/inputStyles.js.map +1 -1
- package/dist/components/Pane/Pane.js +1 -1
- package/dist/components/Pane/Pane.js.map +1 -1
- package/dist/components/Popover/constants.d.ts +1 -1
- package/dist/components/Popover/constants.js +1 -1
- package/dist/components/Popover/constants.js.map +1 -1
- package/dist/components/RadioButton/constants.d.ts +1 -1
- package/dist/components/RadioButton/constants.js +1 -1
- package/dist/components/RadioButton/constants.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/components/RadioGroup/RadioGroupItem.js.map +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyLink.js +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyLink.js.map +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyNode.js +1 -1
- package/dist/components/SankeyChart/AnimatedSankeyNode.js.map +1 -1
- package/dist/components/Select/SelectPrimitive.js +3 -3
- package/dist/components/Select/SelectPrimitive.js.map +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SplitViewPane/SplitViewPane.js +1 -1
- package/dist/components/SplitViewPane/SplitViewPane.js.map +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Tabs/index.js +2 -2
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/Textarea.js +2 -2
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/ThinkingState/LoadingIndicator.js +1 -1
- package/dist/components/ThinkingState/ThinkingState.js +1 -1
- package/dist/components/ThinkingState/index.js +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadView.js +1 -1
- package/dist/components/Typeahead/TypeaheadView.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components.css +2 -105
- package/dist/icons/WeightedPhosphorIcons.js +1 -1
- package/dist/index.js +1 -1
- package/dist/utilities.css +2 -2
- package/dist/utils/cn.js +17 -11
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/useCodeMirror.d.ts +2 -2
- package/dist/utils/useCodeMirror.js +4 -4
- package/dist/utils/useCodeMirror.js.map +1 -1
- package/docs/DESIGN.md +20 -2
- package/docs/STYLES.md +12 -2
- package/package.json +11 -9
- package/tailwind.preset.cjs +285 -331
- package/dist/_chunks/LoadingIndicator-DujSAzqj.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","names":[],"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n} from '../Input/inputStyles';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\n\nexport const Command = forwardRef<\n ElementRef<typeof CommandPrimitive>,\n ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover',\n className\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport interface CommandInputProps extends Omit<\n ComponentPropsWithoutRef<typeof CommandPrimitive.Input>,\n 'size'\n> {\n /** Left side decorator (icon or element) */\n leftDecorator?: ReactNode;\n /** Right side decorator (icon or element) */\n rightDecorator?: ReactNode;\n /** Size variant — uses shared Input styling */\n size?: InputSize;\n /** Visual variant — uses shared Input styling */\n variant?: InputVariant;\n}\n\nexport const CommandInput = forwardRef<\n ElementRef<typeof CommandPrimitive.Input>,\n CommandInputProps\n>(\n (\n {\n className,\n leftDecorator,\n rightDecorator,\n size = 'lg',\n variant = 'outlined',\n ...props\n },\n ref\n ) => {\n const containerClasses = getInputContainerClasses({\n size,\n variant,\n disabled: props.disabled,\n className,\n });\n\n const inputClasses = getInputElementClasses({\n size,\n disabled: props.disabled,\n });\n\n return (\n <div className={containerClasses} {...{ 'cmdk-input-wrapper': '' }}>\n {leftDecorator && (\n <div className={DECORATOR_CLASSES}>{leftDecorator}</div>\n )}\n <CommandPrimitive.Input ref={ref} className={inputClasses} {...props} />\n {rightDecorator && (\n <div className={DECORATOR_CLASSES}>{rightDecorator}</div>\n )}\n </div>\n );\n }\n);\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nexport const CommandList = forwardRef<\n ElementRef<typeof CommandPrimitive.List>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nexport const CommandEmpty = forwardRef<\n ElementRef<typeof CommandPrimitive.Empty>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty\n ref={ref}\n className=\"py-space-5 text-center\"\n {...props}\n />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nexport const CommandGroup = forwardRef<\n ElementRef<typeof CommandPrimitive.Group>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n 'overflow-hidden',\n '[&_[cmdk-group-heading]]:px-space-2 [&_[cmdk-group-heading]]:py-space-2 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:text-tertiary',\n className\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nexport const CommandSeparator = forwardRef<\n ElementRef<typeof CommandPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-space-1 h-px', className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\ninterface CommandItemProps extends ComponentPropsWithoutRef<\n typeof CommandPrimitive.Item\n> {\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n}\n\nconst COMMAND_ITEM_SIZE_CLASSES = {\n sm: 'py-space-1 text-xs leading-4',\n md: 'py-space-1 text-sm',\n} satisfies Record<OptionRowSize, string>;\n\nexport const CommandItem = forwardRef<\n ElementRef<typeof CommandPrimitive.Item>,\n CommandItemProps\n>(({ className, size = 'md', ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-
|
|
1
|
+
{"version":3,"file":"Command.js","names":[],"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ElementRef, ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport {\n DECORATOR_CLASSES,\n getInputContainerClasses,\n getInputElementClasses,\n} from '../Input/inputStyles';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\n\nexport const Command = forwardRef<\n ElementRef<typeof CommandPrimitive>,\n ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover',\n className\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport interface CommandInputProps extends Omit<\n ComponentPropsWithoutRef<typeof CommandPrimitive.Input>,\n 'size'\n> {\n /** Left side decorator (icon or element) */\n leftDecorator?: ReactNode;\n /** Right side decorator (icon or element) */\n rightDecorator?: ReactNode;\n /** Size variant — uses shared Input styling */\n size?: InputSize;\n /** Visual variant — uses shared Input styling */\n variant?: InputVariant;\n}\n\nexport const CommandInput = forwardRef<\n ElementRef<typeof CommandPrimitive.Input>,\n CommandInputProps\n>(\n (\n {\n className,\n leftDecorator,\n rightDecorator,\n size = 'lg',\n variant = 'outlined',\n ...props\n },\n ref\n ) => {\n const containerClasses = getInputContainerClasses({\n size,\n variant,\n disabled: props.disabled,\n className,\n });\n\n const inputClasses = getInputElementClasses({\n size,\n disabled: props.disabled,\n });\n\n return (\n <div className={containerClasses} {...{ 'cmdk-input-wrapper': '' }}>\n {leftDecorator && (\n <div className={DECORATOR_CLASSES}>{leftDecorator}</div>\n )}\n <CommandPrimitive.Input ref={ref} className={inputClasses} {...props} />\n {rightDecorator && (\n <div className={DECORATOR_CLASSES}>{rightDecorator}</div>\n )}\n </div>\n );\n }\n);\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nexport const CommandList = forwardRef<\n ElementRef<typeof CommandPrimitive.List>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nexport const CommandEmpty = forwardRef<\n ElementRef<typeof CommandPrimitive.Empty>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty\n ref={ref}\n className=\"py-space-5 text-center\"\n {...props}\n />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nexport const CommandGroup = forwardRef<\n ElementRef<typeof CommandPrimitive.Group>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n 'overflow-hidden',\n '[&_[cmdk-group-heading]]:px-space-2 [&_[cmdk-group-heading]]:py-space-2 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:text-tertiary',\n className\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nexport const CommandSeparator = forwardRef<\n ElementRef<typeof CommandPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-space-1 h-px', className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\ninterface CommandItemProps extends ComponentPropsWithoutRef<\n typeof CommandPrimitive.Item\n> {\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n}\n\nconst COMMAND_ITEM_SIZE_CLASSES = {\n sm: 'py-space-1 text-xs leading-4',\n md: 'py-space-1 text-sm',\n} satisfies Record<OptionRowSize, string>;\n\nexport const CommandItem = forwardRef<\n ElementRef<typeof CommandPrimitive.Item>,\n CommandItemProps\n>(({ className, size = 'md', ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex cursor-pointer select-none items-center rounded-sm px-space-2 outline-hidden hover:bg-secondary aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-selected:bg-secondary',\n OPTION_ROW_SIZES[size].minHeightClassName,\n COMMAND_ITEM_SIZE_CLASSES[size],\n className\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n"],"mappings":";;;;;;;AAiBA,IAAa,UAAU,YAGpB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,WAAD;CACO;CACL,WAAW,GACT,qEACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,QAAQ,cAAc,UAAiB;AAgBvC,IAAa,eAAe,YAKxB,EACE,WACA,eACA,gBACA,OAAO,MACP,UAAU,YACV,GAAG,SAEL,QACG;CACH,MAAM,mBAAmB,yBAAyB;EAChD;EACA;EACA,UAAU,MAAM;EAChB;CACF,CAAC;CAED,MAAM,eAAe,uBAAuB;EAC1C;EACA,UAAU,MAAM;CAClB,CAAC;CAED,OACE,qBAAC,OAAD;EAAK,WAAW;EAAwB,sBAAsB;EAA9D,UAAA;GACG,iBACC,oBAAC,OAAD;IAAK,WAAA;IAA+B,UAAA;GAAmB,CAAA;GAEzD,oBAAC,UAAiB,OAAlB;IAA6B;IAAK,WAAW;IAAc,GAAI;GAAQ,CAAA;GACtE,kBACC,oBAAC,OAAD;IAAK,WAAA;IAA+B,UAAA;GAAoB,CAAA;EAEvD;;AAET,CACF;AAEA,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,cAAc,YAGxB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,MAAlB;CACO;CACL,WAAW,GAAG,mDAAmD,SAAS;CAC1E,GAAI;AACL,CAAA,CACF;AAED,YAAY,cAAc,UAAiB,KAAK;AAEhD,IAAa,eAAe,YAGzB,OAAO,QACR,oBAAC,UAAiB,OAAlB;CACO;CACL,WAAU;CACV,GAAI;AACL,CAAA,CACF;AAED,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,eAAe,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,OAAlB;CACO;CACL,WAAW,GACT,mBACA,6NACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,aAAa,cAAc,UAAiB,MAAM;AAElD,IAAa,mBAAmB,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,UAAiB,WAAlB;CACO;CACL,WAAW,GAAG,8BAA8B,SAAS;CACrD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc,UAAiB,UAAU;AAY1D,IAAM,4BAA4B;CAChC,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,cAAc,YAGxB,EAAE,WAAW,OAAO,MAAM,GAAG,SAAS,QACvC,oBAAC,UAAiB,MAAlB;CACO;CACL,WAAW,GACT,uMACA,iBAAiB,KAAK,CAAC,oBACvB,0BAA0B,OAC1B,SACF;CACA,GAAI;AACL,CAAA,CACF;AAED,YAAY,cAAc,UAAiB,KAAK"}
|
|
@@ -69,7 +69,7 @@ function CommandMenu({ items, groups, onSelect, value, placeholder = "Search..."
|
|
|
69
69
|
}, item.value);
|
|
70
70
|
});
|
|
71
71
|
return /* @__PURE__ */ jsxs(Command, {
|
|
72
|
-
className: cn("flex flex-col gap-1.5 p-space-1 outline-
|
|
72
|
+
className: cn("flex flex-col gap-1.5 p-space-1 outline-hidden", className),
|
|
73
73
|
shouldFilter: disableFilter ? false : void 0,
|
|
74
74
|
tabIndex: hideSearch ? 0 : -1,
|
|
75
75
|
children: [!hideSearch && /* @__PURE__ */ jsx(CommandInput, {
|
|
@@ -83,7 +83,7 @@ function CommandMenu({ items, groups, onSelect, value, placeholder = "Search..."
|
|
|
83
83
|
}),
|
|
84
84
|
onValueChange: onSearchChange
|
|
85
85
|
}), /* @__PURE__ */ jsxs(CommandList, {
|
|
86
|
-
className: "outline-
|
|
86
|
+
className: "outline-hidden",
|
|
87
87
|
onScroll: handleScroll,
|
|
88
88
|
children: [
|
|
89
89
|
!loading && /* @__PURE__ */ jsx(CommandEmpty, { children: /* @__PURE__ */ jsx(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandMenu.js","names":[],"sources":["../../../src/components/Command/CommandMenu.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { Icon } from '../Icon';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\nimport { Text } from '../Text';\nimport { Tooltip } from '../Tooltip';\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from './Command';\n\nexport interface CommandMenuItem {\n /** Unique value used for selection and filtering */\n value: string;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Extra search terms for filtering */\n keywords?: string[];\n}\n\nexport interface CommandMenuGroup {\n /** Optional heading displayed above the group */\n heading?: string;\n /** Items in this group */\n items: CommandMenuItem[];\n}\n\ninterface CommandMenuBaseProps {\n /** Callback when an item is selected */\n onSelect: (value: string) => void;\n /** The currently selected value. When set, a check icon is shown next to the selected item. */\n value?: string;\n /** Placeholder text for the search input */\n placeholder?: string;\n /** Text shown when no items match the search */\n emptyText?: string;\n /** Hide the search input (default: false, search is visible) */\n hideSearch?: boolean;\n /** Show the leading selected-indicator slot in the default item layout (default: true). Set false for action menus that track no selection so labels sit flush-left. */\n showSelectedIndicator?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Custom render function for each item */\n renderItem?: (item: CommandMenuItem, isSelected: boolean) => ReactNode;\n /** Size variant for the search input */\n inputSize?: InputSize;\n /**\n * Controls minimum row height and default label typography.\n * Descriptions and custom content may grow beyond the minimum height.\n */\n itemRowSize?: OptionRowSize;\n /** Visual variant for the search input */\n inputVariant?: InputVariant;\n /** Additional class name for the Command root */\n className?: string;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n}\n\nexport type CommandMenuProps = CommandMenuBaseProps &\n (\n | { /** Flat list of items */ items: CommandMenuItem[]; groups?: never }\n | {\n /** Grouped items with optional headings */ groups: CommandMenuGroup[];\n items?: never;\n }\n );\n\nfunction TruncatedLabel({ text, size }: { text: string; size: OptionRowSize }) {\n const textRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const el = textRef.current;\n if (el) {\n setIsTruncated(el.scrollWidth > el.clientWidth);\n }\n }, [text, size]);\n\n return (\n <Tooltip title={isTruncated ? text : undefined}>\n <Text\n ref={textRef}\n as=\"span\"\n variant={size}\n className={cn(\n 'truncate tracking-normal',\n size === 'sm' ? 'leading-4' : 'leading-5'\n )}\n >\n {text}\n </Text>\n </Tooltip>\n );\n}\n\nexport function CommandMenu({\n items,\n groups,\n onSelect,\n value,\n placeholder = 'Search...',\n emptyText = 'No results found.',\n hideSearch,\n showSelectedIndicator = true,\n disableFilter,\n onSearchChange,\n renderItem,\n inputSize = 'sm',\n itemRowSize = 'md',\n inputVariant = 'plain',\n className,\n loading = false,\n loadingRows = 5,\n onEndReached,\n endReachedThresholdPx = 50,\n}: CommandMenuProps) {\n const handleScroll = useCallback(\n (e: React.UIEvent<HTMLDivElement>) => {\n if (!onEndReached) return;\n const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;\n if (scrollHeight - scrollTop - clientHeight <= endReachedThresholdPx) {\n onEndReached();\n }\n },\n [onEndReached, endReachedThresholdPx]\n );\n\n const renderItems = (menuItems: CommandMenuItem[]) =>\n menuItems.map((item) => {\n const isSelected = item.value === value;\n const label = item.label ?? item.value;\n return (\n <CommandItem\n key={item.value}\n value={item.value}\n keywords={\n item.label ? [item.label, ...(item.keywords ?? [])] : item.keywords\n }\n disabled={item.disabled}\n onSelect={() => onSelect(item.value)}\n size={itemRowSize}\n className={cn(\n 'gap-space-2',\n hideSearch &&\n 'after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] aria-selected:after:border-2 aria-selected:after:border-focus'\n )}\n >\n {renderItem ? (\n renderItem(item, isSelected)\n ) : (\n <>\n {showSelectedIndicator && (\n <Icon\n icon={CheckIcon}\n size=\"md\"\n className={cn(\n 'shrink-0',\n isSelected ? 'opacity-100' : 'opacity-0'\n )}\n />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <TruncatedLabel text={label} size={itemRowSize} />\n {item.description && (\n <Text\n as=\"span\"\n variant=\"xs\"\n className=\"truncate text-tertiary\"\n >\n {item.description}\n </Text>\n )}\n </div>\n {item.rightDecorator && (\n <div className=\"ml-auto shrink-0\">{item.rightDecorator}</div>\n )}\n </>\n )}\n </CommandItem>\n );\n });\n\n return (\n <Command\n className={cn('flex flex-col gap-1.5 p-space-1 outline-none', className)}\n shouldFilter={disableFilter ? false : undefined}\n tabIndex={hideSearch ? 0 : -1}\n >\n {!hideSearch && (\n <CommandInput\n placeholder={placeholder}\n size={inputSize}\n variant={inputVariant}\n leftDecorator={\n <MagnifyingGlassIcon aria-hidden size={16} weight=\"regular\" />\n }\n onValueChange={onSearchChange}\n />\n )}\n <CommandList className=\"outline-none\" onScroll={handleScroll}>\n {!loading && (\n <CommandEmpty>\n <Text variant=\"sm\">{emptyText}</Text>\n </CommandEmpty>\n )}\n {items && renderItems(items)}\n {groups?.map((group, i) => (\n <Fragment key={group.heading ?? i}>\n {i > 0 && <CommandSeparator />}\n <CommandGroup heading={group.heading}>\n {renderItems(group.items)}\n </CommandGroup>\n </Fragment>\n ))}\n {loading && (\n <div className=\"flex flex-col gap-space-1 px-space-2 py-space-1\">\n {Array.from({ length: loadingRows }, (_, i) => (\n <div\n key={i}\n className={cn(\n 'animate-pulse rounded-md bg-tertiary',\n OPTION_ROW_SIZES[itemRowSize].minHeightClassName\n )}\n />\n ))}\n </div>\n )}\n </CommandList>\n </Command>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgGA,SAAS,eAAe,EAAE,MAAM,QAA+C;CAC7E,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,gBAAgB;EACd,MAAM,KAAK,QAAQ;EACnB,IAAI,IACF,eAAe,GAAG,cAAc,GAAG,WAAW;CAElD,GAAG,CAAC,MAAM,IAAI,CAAC;CAEf,OACE,oBAAC,SAAD;EAAS,OAAO,cAAc,OAAO,KAAA;EACnC,UAAA,oBAAC,MAAD;GACE,KAAK;GACL,IAAG;GACH,SAAS;GACT,WAAW,GACT,4BACA,SAAS,OAAO,cAAc,WAChC;GAEC,UAAA;EACG,CAAA;CACC,CAAA;AAEb;AAEA,SAAgB,YAAY,EAC1B,OACA,QACA,UACA,OACA,cAAc,aACd,YAAY,qBACZ,YACA,wBAAwB,MACxB,eACA,gBACA,YACA,YAAY,MACZ,cAAc,MACd,eAAe,SACf,WACA,UAA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AAS;GACT,eACE,oBAAC,qBAAD;IAAqB,eAAA;IAAY,MAAM;IAAI,QAAO;GAAW,CAAA;GAE/D,eAAe;EAChB,CAAA,GAEH,qBAAC,aAAD;GAAa,WAAU;GAAe,UAAU;GAAhD,UAAA;IACG,CAAC,WACA,oBAAC,cAAD,EAAA,UACE,oBAAC,MAAD;KAAM,SAAQ;KAAM,UAAA;IAAgB,CAAA,EACxB,CAAA;IAEf,SAAS,YAAY,KAAK;IAC1B,QAAQ,KAAK,OAAO,MACnB,qBAAC,UAAD,EAAA,UAAA,CACG,IAAI,KAAK,oBAAC,kBAAD,CAAmB,CAAA,GAC7B,oBAAC,cAAD;KAAc,SAAS,MAAM;KAC1B,UAAA,YAAY,MAAM,KAAK;IACZ,CAAA,CACN,EAAA,GALK,MAAM,WAAW,CAKtB,CACX;IACA,WACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,MACvC,oBAAC,OAAD,EAEE,WAAW,GACT,wCACA,iBAAiB,YAAY,CAAC,kBAChC,EACD,GALM,CAKN,CACF;IACE,CAAA;GAEI;EACN,CAAA,CAAA;;AAEb"}
|
|
1
|
+
{"version":3,"file":"CommandMenu.js","names":[],"sources":["../../../src/components/Command/CommandMenu.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Fragment, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { Icon } from '../Icon';\nimport type { InputSize, InputVariant } from '../Input/inputStyles';\nimport { Text } from '../Text';\nimport { Tooltip } from '../Tooltip';\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n} from './Command';\n\nexport interface CommandMenuItem {\n /** Unique value used for selection and filtering */\n value: string;\n /** Display label (defaults to value if not provided) */\n label?: string;\n /** Secondary description text displayed below the label */\n description?: string;\n /** Element displayed on the right side of the item (e.g. badge, shortcut) */\n rightDecorator?: ReactNode;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Extra search terms for filtering */\n keywords?: string[];\n}\n\nexport interface CommandMenuGroup {\n /** Optional heading displayed above the group */\n heading?: string;\n /** Items in this group */\n items: CommandMenuItem[];\n}\n\ninterface CommandMenuBaseProps {\n /** Callback when an item is selected */\n onSelect: (value: string) => void;\n /** The currently selected value. When set, a check icon is shown next to the selected item. */\n value?: string;\n /** Placeholder text for the search input */\n placeholder?: string;\n /** Text shown when no items match the search */\n emptyText?: string;\n /** Hide the search input (default: false, search is visible) */\n hideSearch?: boolean;\n /** Show the leading selected-indicator slot in the default item layout (default: true). Set false for action menus that track no selection so labels sit flush-left. */\n showSelectedIndicator?: boolean;\n /** Disable client-side filtering by cmdk (default: false). Set true for server-side filtering. */\n disableFilter?: boolean;\n /** Callback when the search input value changes. Useful for server-side filtering. */\n onSearchChange?: (query: string) => void;\n /** Custom render function for each item */\n renderItem?: (item: CommandMenuItem, isSelected: boolean) => ReactNode;\n /** Size variant for the search input */\n inputSize?: InputSize;\n /**\n * Controls minimum row height and default label typography.\n * Descriptions and custom content may grow beyond the minimum height.\n */\n itemRowSize?: OptionRowSize;\n /** Visual variant for the search input */\n inputVariant?: InputVariant;\n /** Additional class name for the Command root */\n className?: string;\n /** Whether more items are currently being loaded */\n loading?: boolean;\n /** Number of skeleton rows to show while loading (default: 5) */\n loadingRows?: number;\n /** Callback when the user scrolls near the end of the list. Use for infinite loading. */\n onEndReached?: () => void;\n /** Distance in pixels from the bottom to trigger onEndReached (default: 50) */\n endReachedThresholdPx?: number;\n}\n\nexport type CommandMenuProps = CommandMenuBaseProps &\n (\n | { /** Flat list of items */ items: CommandMenuItem[]; groups?: never }\n | {\n /** Grouped items with optional headings */ groups: CommandMenuGroup[];\n items?: never;\n }\n );\n\nfunction TruncatedLabel({ text, size }: { text: string; size: OptionRowSize }) {\n const textRef = useRef<HTMLElement>(null);\n const [isTruncated, setIsTruncated] = useState(false);\n\n useEffect(() => {\n const el = textRef.current;\n if (el) {\n setIsTruncated(el.scrollWidth > el.clientWidth);\n }\n }, [text, size]);\n\n return (\n <Tooltip title={isTruncated ? text : undefined}>\n <Text\n ref={textRef}\n as=\"span\"\n variant={size}\n className={cn(\n 'truncate tracking-normal',\n size === 'sm' ? 'leading-4' : 'leading-5'\n )}\n >\n {text}\n </Text>\n </Tooltip>\n );\n}\n\nexport function CommandMenu({\n items,\n groups,\n onSelect,\n value,\n placeholder = 'Search...',\n emptyText = 'No results found.',\n hideSearch,\n showSelectedIndicator = true,\n disableFilter,\n onSearchChange,\n renderItem,\n inputSize = 'sm',\n itemRowSize = 'md',\n inputVariant = 'plain',\n className,\n loading = false,\n loadingRows = 5,\n onEndReached,\n endReachedThresholdPx = 50,\n}: CommandMenuProps) {\n const handleScroll = useCallback(\n (e: React.UIEvent<HTMLDivElement>) => {\n if (!onEndReached) return;\n const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;\n if (scrollHeight - scrollTop - clientHeight <= endReachedThresholdPx) {\n onEndReached();\n }\n },\n [onEndReached, endReachedThresholdPx]\n );\n\n const renderItems = (menuItems: CommandMenuItem[]) =>\n menuItems.map((item) => {\n const isSelected = item.value === value;\n const label = item.label ?? item.value;\n return (\n <CommandItem\n key={item.value}\n value={item.value}\n keywords={\n item.label ? [item.label, ...(item.keywords ?? [])] : item.keywords\n }\n disabled={item.disabled}\n onSelect={() => onSelect(item.value)}\n size={itemRowSize}\n className={cn(\n 'gap-space-2',\n hideSearch &&\n 'after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] aria-selected:after:border-2 aria-selected:after:border-focus'\n )}\n >\n {renderItem ? (\n renderItem(item, isSelected)\n ) : (\n <>\n {showSelectedIndicator && (\n <Icon\n icon={CheckIcon}\n size=\"md\"\n className={cn(\n 'shrink-0',\n isSelected ? 'opacity-100' : 'opacity-0'\n )}\n />\n )}\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <TruncatedLabel text={label} size={itemRowSize} />\n {item.description && (\n <Text\n as=\"span\"\n variant=\"xs\"\n className=\"truncate text-tertiary\"\n >\n {item.description}\n </Text>\n )}\n </div>\n {item.rightDecorator && (\n <div className=\"ml-auto shrink-0\">{item.rightDecorator}</div>\n )}\n </>\n )}\n </CommandItem>\n );\n });\n\n return (\n <Command\n className={cn(\n 'flex flex-col gap-1.5 p-space-1 outline-hidden',\n className\n )}\n shouldFilter={disableFilter ? false : undefined}\n tabIndex={hideSearch ? 0 : -1}\n >\n {!hideSearch && (\n <CommandInput\n placeholder={placeholder}\n size={inputSize}\n variant={inputVariant}\n leftDecorator={\n <MagnifyingGlassIcon aria-hidden size={16} weight=\"regular\" />\n }\n onValueChange={onSearchChange}\n />\n )}\n <CommandList className=\"outline-hidden\" onScroll={handleScroll}>\n {!loading && (\n <CommandEmpty>\n <Text variant=\"sm\">{emptyText}</Text>\n </CommandEmpty>\n )}\n {items && renderItems(items)}\n {groups?.map((group, i) => (\n <Fragment key={group.heading ?? i}>\n {i > 0 && <CommandSeparator />}\n <CommandGroup heading={group.heading}>\n {renderItems(group.items)}\n </CommandGroup>\n </Fragment>\n ))}\n {loading && (\n <div className=\"flex flex-col gap-space-1 px-space-2 py-space-1\">\n {Array.from({ length: loadingRows }, (_, i) => (\n <div\n key={i}\n className={cn(\n 'animate-pulse rounded-md bg-tertiary',\n OPTION_ROW_SIZES[itemRowSize].minHeightClassName\n )}\n />\n ))}\n </div>\n )}\n </CommandList>\n </Command>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgGA,SAAS,eAAe,EAAE,MAAM,QAA+C;CAC7E,MAAM,UAAU,OAAoB,IAAI;CACxC,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,gBAAgB;EACd,MAAM,KAAK,QAAQ;EACnB,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enuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
29
29
|
var ContextMenuItem = React$1.forwardRef(({ className, inset, size = "md", ...props }, ref) => /* @__PURE__ */ jsx(ContextMenuPrimitive.Item, {
|
|
30
30
|
ref,
|
|
31
|
-
className: cn("flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-
|
|
31
|
+
className: cn("flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-hidden transition-colors focus:bg-elevated-hover data-[disabled]:pointer-events-none data-[highlighted]:bg-elevated-hover data-[disabled]:opacity-50", OPTION_ROW_SIZES[size].minHeightClassName, size === "sm" ? "text-xs leading-4" : "text-sm", inset ? "pl-space-8" : void 0, className),
|
|
32
32
|
...props
|
|
33
33
|
}));
|
|
34
34
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const ContextMenu = ContextMenuPrimitive.Root;\n\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nexport const ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <ContextMenuPrimitive.Portal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-default bg-elevated p-space-1 text-primary shadow-md',\n className\n )}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </ContextMenuPrimitive.Content>\n </ContextMenuPrimitive.Portal>\n );\n});\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;\n\nexport const ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, size = 'md', ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":[],"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const ContextMenu = ContextMenuPrimitive.Root;\n\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\n\nexport const ContextMenuContent = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <ContextMenuPrimitive.Portal>\n <ContextMenuPrimitive.Content\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-default bg-elevated p-space-1 text-primary shadow-md',\n className\n )}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </ContextMenuPrimitive.Content>\n </ContextMenuPrimitive.Portal>\n );\n});\nContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;\n\nexport const ContextMenuItem = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, size = 'md', ...props }, ref) => (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'flex w-full cursor-default select-none items-center rounded-sm px-space-2 py-space-1 text-primary outline-hidden transition-colors focus:bg-elevated-hover data-[disabled]:pointer-events-none data-[highlighted]:bg-elevated-hover data-[disabled]:opacity-50',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset ? 'pl-space-8' : undefined,\n className\n )}\n {...props}\n />\n));\nContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;\n\nexport const ContextMenuSeparator = React.forwardRef<\n React.ElementRef<typeof ContextMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('-mx-space-1 my-space-1 border-b border-subtle', className)}\n {...props}\n />\n));\nContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;\n"],"mappings":";;;;;;;;;AAaA,IAAa,cAAc,qBAAqB;AAEhD,IAAa,qBAAqB,qBAAqB;AAEvD,IAAa,qBAAqB,QAAM,YAGrC,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5C,MAAM,SAAS,UAAU,SAAS,OAAO;CAEzC,OACE,oBAAC,qBAAqB,QAAtB,EAAA,UACE,oBAAC,qBAAqB,SAAtB;EACO;EACL,WAAW,GACT,8GACA,SACF;EACA,GAAI;EACJ,OAAO;GAAE;GAAQ,GAAG,MAAM;EAAM;EAEhC,UAAA,oBAAC,gBAAD;GAAgB,OAAO;GAAS;EAAyB,CAAA;CAC7B,CAAA,EACH,CAAA;AAEjC,CAAC;AACD,mBAAmB,cAAc,qBAAqB,QAAQ;AAE9D,IAAa,kBAAkB,QAAM,YAUlC,EAAE,WAAW,OAAO,OAAO,MAAM,GAAG,SAAS,QAC9C,oBAAC,qBAAqB,MAAtB;CACO;CACL,WAAW,GACT,kQACA,iBAAiB,KAAK,CAAC,oBACvB,SAAS,OAAO,sBAAsB,WACtC,QAAQ,eAAe,KAAA,GACvB,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,qBAAqB,KAAK;AAExD,IAAa,uBAAuB,QAAM,YAGvC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,qBAAqB,WAAtB;CACO;CACL,WAAW,GAAG,iDAAiD,SAAS;CACxE,GAAI;AACL,CAAA,CACF;AACD,qBAAqB,cAAc,qBAAqB,UAAU"}
|
|
@@ -29,7 +29,7 @@ var AnimatedDonutArc = ({ arc, path, animationProgress, animationStartAngle, ani
|
|
|
29
29
|
return /* @__PURE__ */ jsx(animated.path, {
|
|
30
30
|
fill: arc.data.color,
|
|
31
31
|
opacity: isDimmed ? CHART_DIMMED_OPACITY : 1,
|
|
32
|
-
className: cn("transition-opacity duration-fast focus:outline-
|
|
32
|
+
className: cn("transition-opacity duration-fast focus:outline-hidden focus-visible:stroke-focus focus-visible:stroke-2 motion-reduce:transition-none", isInteractive && "cursor-pointer"),
|
|
33
33
|
d: animationProgress.to((progress) => {
|
|
34
34
|
const revealAngle = animationStartAngle + (animationEndAngle - animationStartAngle) * progress;
|
|
35
35
|
const endAngle = Math.min(arc.endAngle, Math.max(arc.startAngle, revealAngle));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.js","names":[],"sources":["../../../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["import {\n useState,\n type AriaAttributes,\n type FocusEvent,\n type FocusEventHandler,\n type HTMLAttributes,\n type PointerEvent,\n type PointerEventHandler,\n type ReactNode,\n} from 'react';\n\nimport {\n animated,\n type SpringValue,\n useReducedMotion,\n useSpring,\n} from '@react-spring/web';\nimport { Group } from '@visx/group';\nimport { Pie as Donut } from '@visx/shape';\n\nimport { CHART_DIMMED_OPACITY } from '../../utils/chartConstants';\nimport { cn } from '../../utils/cn';\nimport { ChartLegend, type ChartLegendProps } from '../ChartLegend';\nimport { Text } from '../Text';\nimport {\n collateDonutSegments,\n getDonutLegendItems,\n getDrawnSegments,\n sumSegmentValues,\n} from './DonutChart.utils';\n\n// Viewport-invariant units. The donut renders into a fixed-size viewBox and\n// scales via `preserveAspectRatio=\"xMidYMid meet\"`.\nconst DONUT_VIEWBOX = 200;\nconst DONUT_CENTER = DONUT_VIEWBOX / 2;\nconst DONUT_OUTER_RADIUS = DONUT_CENTER - 8;\nconst DONUT_INNER_RADIUS = DONUT_OUTER_RADIUS * 0.64;\n\nconst numberFormatter = new Intl.NumberFormat('en-US');\n\nconst formatSegmentValue = (value: number) => numberFormatter.format(value);\n\n/**\n * Sizes the center number against the donut hole: `1cqi` is 1% of the hole's\n * width, so a longer value resolves to a smaller size, capped at the heading\n * size so short values do not balloon.\n */\nconst getFittedCenterFontSize = (value: string) =>\n `min(1.75rem, ${100 / (value.length * 0.7)}cqi)`;\n\nexport type DonutChartSegment = {\n id: string;\n label: ReactNode;\n value: number;\n /** Use DS CSS color token; typically a `var(--chart-...)` reference. */\n color: string;\n /**\n * Marks a segment that already stands for a group of others — a remainder the\n * data source rolled up, say. `otherCollationThreshold` merges it with the\n * tail it collates instead of drawing a second \"Other\" beside it.\n */\n isOther?: boolean;\n};\n\ntype DonutArcDatumLike<Datum> = {\n data: Datum;\n value: number;\n index: number;\n startAngle: number;\n endAngle: number;\n padAngle: number;\n};\n\n/**\n * Everything `ChartLegend` accepts except `items`, which the donut derives from\n * `segments`. Namespacing these under `legendProps` keeps `className` and the\n * other DOM attributes on the chart root unambiguous.\n */\ntype DonutChartLegendProps = Omit<ChartLegendProps, 'items'>;\n\n/**\n * `legendProps` only exists while there is a legend to configure: with\n * `showLegend={false}` it narrows to `never`, so autocomplete stops offering it\n * and passing it is a type error rather than a silently ignored prop.\n */\ntype DonutChartLegendConfig =\n | {\n /** Defaults to true. */\n showLegend?: true;\n /** Forwarded to the rendered `ChartLegend`. */\n legendProps?: DonutChartLegendProps;\n }\n | {\n showLegend: false;\n legendProps?: never;\n };\n\nexport type DonutChartProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children' | 'onPointerOut'\n> &\n DonutChartLegendConfig & {\n segments: readonly DonutChartSegment[];\n /**\n * When provided and non-empty, only segments whose IDs are in the set are\n * rendered in the donut. Unselected segments stay in the legend with a 0%\n * share. IDs address the collated list, so the segments behind an \"Other\"\n * slice are selected as `DONUT_OTHER_SEGMENT_ID` rather than individually. A\n * set naming none of those IDs draws everything, so a selection outliving\n * the data it was made against cannot empty the chart.\n */\n selectedIds?: ReadonlySet<string>;\n /**\n * Number to render in the donut hole.\n */\n centerNumber?: string;\n /**\n * Descriptor for the number in the donut hole.\n */\n centerDescriptor?: string;\n /**\n * Scales `centerNumber` to the width of the donut hole.\n */\n scaleCenterNumberSize?: boolean;\n /** Emphasizes one segment and dims the rest. */\n activeSegmentId?: string | null;\n /** Emphasizes the segment represented by one external legend item. Built-in legends set this automatically. */\n activeLegendItemId?: string | null;\n /** Animates segments when they are drawn. Defaults to true. */\n shouldAnimate?: boolean;\n /** Names segments and makes them focusable. */\n getSegmentAriaLabel?: (\n segment: DonutChartSegment\n ) => AriaAttributes['aria-label'];\n /**\n * Set to false to skip drawing the donut. Use it to avoid the work while a\n * parent container is actively resizing. Defaults to true.\n */\n isRendering?: boolean;\n /**\n * Collates segments less than this set number to an \"Other\" slice, automatically merging any segment flagged `isOther`. Do not pass a value to render all segments, even if they are tiny.\n */\n otherCollationThreshold?: number;\n /**\n * Formats each segment's value for the legend. Defaults to a plain\n * `en-US` number; pass a unit-aware formatter for durations, bytes, cost.\n */\n formatValue?: (value: number) => ReactNode;\n onSegmentPointerMove?: (\n segment: DonutChartSegment,\n event: PointerEvent<SVGPathElement>\n ) => void;\n onSegmentPointerOut?: () => void;\n onSegmentPointerUp?: (\n segment: DonutChartSegment,\n event: PointerEvent<SVGPathElement>\n ) => void;\n onSegmentFocus?: (\n segment: DonutChartSegment,\n event: FocusEvent<SVGPathElement>\n ) => void;\n onSegmentBlur?: (\n segment: DonutChartSegment,\n event: FocusEvent<SVGPathElement>\n ) => void;\n };\n\ntype AnimatedDonutArcProps = {\n arc: DonutArcDatumLike<DonutChartSegment>;\n path: (arc: DonutArcDatumLike<DonutChartSegment>) => string | null;\n animationProgress: SpringValue<number>;\n animationStartAngle: number;\n animationEndAngle: number;\n 'aria-label'?: AriaAttributes['aria-label'];\n isDimmed: boolean;\n onPointerMove?: PointerEventHandler<SVGPathElement>;\n onPointerOut?: () => void;\n onPointerUp?: PointerEventHandler<SVGPathElement>;\n onFocus?: FocusEventHandler<SVGPathElement>;\n onBlur?: FocusEventHandler<SVGPathElement>;\n};\n\nconst AnimatedDonutArc = ({\n arc,\n path,\n animationProgress,\n animationStartAngle,\n animationEndAngle,\n isDimmed,\n onPointerMove,\n onPointerOut,\n onPointerUp,\n onFocus,\n onBlur,\n ...ariaProps\n}: AnimatedDonutArcProps) => {\n const isInteractive =\n onPointerMove != null || onPointerOut != null || onPointerUp != null;\n const handlePointerDown = (event: PointerEvent<SVGPathElement>) => {\n // Chromium can match :focus-visible when a focusable SVG path is clicked.\n // Keep the focus indicator for keyboard navigation without showing it for\n // pointer interaction.\n if (\n (event.pointerType === 'mouse' || event.pointerType === 'pen') &&\n event.currentTarget.hasAttribute('tabindex')\n ) {\n event.preventDefault();\n }\n };\n\n return (\n <animated.path\n fill={arc.data.color}\n opacity={isDimmed ? CHART_DIMMED_OPACITY : 1}\n className={cn(\n 'transition-opacity duration-fast focus:outline-none focus-visible:stroke-focus focus-visible:stroke-2 motion-reduce:transition-none',\n isInteractive && 'cursor-pointer'\n )}\n d={animationProgress.to((progress) => {\n const revealAngle =\n animationStartAngle +\n (animationEndAngle - animationStartAngle) * progress;\n const endAngle = Math.min(\n arc.endAngle,\n Math.max(arc.startAngle, revealAngle)\n );\n return path({ ...arc, endAngle }) ?? '';\n })}\n role={ariaProps['aria-label'] == null ? undefined : 'graphics-symbol img'}\n tabIndex={ariaProps['aria-label'] == null ? undefined : 0}\n {...ariaProps}\n onPointerMove={onPointerMove}\n onPointerDown={handlePointerDown}\n onPointerOut={onPointerOut}\n onPointerUp={onPointerUp}\n onFocus={onFocus}\n onBlur={onBlur}\n />\n );\n};\n\n/**\n * DonutChart renders a donut and its `ChartLegend` from a flat list of\n * segments. Consumers own the segment palette and pair the chart\n * with `ChartCard` and their own tooltip.\n *\n * The legend sits below the donut in narrow containers and beside it once the\n * container passes 496px. Pass `showLegend={false}` for the donut alone,\n * `legendProps` to configure the legend, and `legendProps.onItemClick` with\n * `selectedIds` to make legend entries filter the donut. A long tail of tiny\n * slices collapses into one \"Other\" slice via `otherCollationThreshold`, which\n * absorbs any segment flagged `isOther`.\n\n */\nexport const DonutChart = ({\n segments,\n selectedIds,\n centerNumber,\n centerDescriptor,\n scaleCenterNumberSize = false,\n activeSegmentId,\n activeLegendItemId,\n shouldAnimate = true,\n getSegmentAriaLabel,\n isRendering = true,\n otherCollationThreshold,\n showLegend = true,\n legendProps,\n formatValue = formatSegmentValue,\n onSegmentPointerMove,\n onSegmentPointerOut,\n onSegmentPointerUp,\n onSegmentFocus,\n onSegmentBlur,\n className,\n ...rest\n}: DonutChartProps) => {\n const [activeBuiltInLegendItemId, setActiveBuiltInLegendItemId] = useState<\n string | null\n >(null);\n const isReducedMotion = (useReducedMotion() ?? false) || !shouldAnimate;\n const ariaProps = { 'aria-label': rest['aria-label'] };\n const rootProps: HTMLAttributes<HTMLDivElement> = { ...rest };\n delete rootProps['aria-label'];\n\n // Collation happens before the selection, so the legend lists the same rows\n // the donut draws arcs for and neither reflows while filtering.\n const collatedSegments = collateDonutSegments(\n segments,\n otherCollationThreshold\n );\n const drawnSegments = getDrawnSegments(collatedSegments, selectedIds);\n const renderedSegments = drawnSegments.filter((segment) => segment.value > 0);\n const drawnTotal = sumSegmentValues(drawnSegments);\n const drawnIds = new Set(drawnSegments.map((segment) => segment.id));\n const drawnArcIds = new Set(renderedSegments.map((segment) => segment.id));\n const hasDrawnSegments = isRendering && drawnTotal > 0;\n const segmentAnimationKey = JSON.stringify(\n renderedSegments.map((segment) => [segment.id, segment.value])\n );\n // A single sweep angle reveals the arcs in sequence, leaving only one moving\n // boundary regardless of how many colored segments the donut contains.\n const [animation] = useSpring(\n () => ({\n from: { progress: 0 },\n to: { progress: hasDrawnSegments ? 1 : 0 },\n reset: true,\n immediate: isReducedMotion,\n }),\n [segmentAnimationKey, hasDrawnSegments, isReducedMotion]\n );\n\n const legendItems = getDonutLegendItems({\n segments: collatedSegments,\n selectedIds,\n drawnIds,\n drawnTotal,\n formatValue,\n });\n const hasLegend = showLegend && collatedSegments.length > 0;\n const legendLayout = legendProps?.layout ?? 'list';\n const requestedActiveLegendItemId =\n (hasLegend ? activeBuiltInLegendItemId : null) ?? activeLegendItemId;\n const renderedActiveLegendItemId =\n requestedActiveLegendItemId != null &&\n drawnArcIds.has(requestedActiveLegendItemId)\n ? requestedActiveLegendItemId\n : null;\n const renderedActiveSegmentId =\n activeSegmentId != null && drawnArcIds.has(activeSegmentId)\n ? activeSegmentId\n : null;\n const activeId = renderedActiveLegendItemId ?? renderedActiveSegmentId;\n\n const donut = (\n <div className=\"relative flex size-full min-h-0 min-w-0 items-center justify-center [&>svg]:max-h-[22.5rem] [&>svg]:max-w-[22.5rem]\">\n <svg\n viewBox={`0 0 ${DONUT_VIEWBOX} ${DONUT_VIEWBOX}`}\n preserveAspectRatio=\"xMidYMid meet\"\n className=\"size-full\"\n role={getSegmentAriaLabel == null ? 'img' : 'graphics-document group'}\n {...ariaProps}\n >\n {isRendering && (\n <>\n {drawnTotal > 0 && (\n <Group\n top={DONUT_CENTER}\n left={DONUT_CENTER}\n className={cn(\n activeId == null &&\n '[&:focus-within>path:not(:focus)]:opacity-[0.45] [&>path:focus]:opacity-100'\n )}\n >\n <Donut\n data={renderedSegments}\n pieValue={(segment) => segment.value}\n pieSort={null}\n pieSortValues={null}\n outerRadius={DONUT_OUTER_RADIUS}\n innerRadius={DONUT_INNER_RADIUS}\n >\n {(donut) => {\n const animationStartAngle = donut.arcs[0]?.startAngle ?? 0;\n const animationEndAngle =\n donut.arcs.at(-1)?.endAngle ?? animationStartAngle;\n return donut.arcs.map((arc) => (\n <AnimatedDonutArc\n key={arc.data.id}\n arc={arc}\n path={donut.path}\n animationProgress={animation.progress}\n animationStartAngle={animationStartAngle}\n animationEndAngle={animationEndAngle}\n aria-label={getSegmentAriaLabel?.(arc.data)}\n isDimmed={activeId != null && activeId !== arc.data.id}\n onPointerMove={\n onSegmentPointerMove == null\n ? undefined\n : (event) => onSegmentPointerMove(arc.data, event)\n }\n onPointerOut={onSegmentPointerOut}\n onPointerUp={\n onSegmentPointerUp == null\n ? undefined\n : (event) => onSegmentPointerUp(arc.data, event)\n }\n onFocus={\n onSegmentFocus == null\n ? undefined\n : (event) => onSegmentFocus(arc.data, event)\n }\n onBlur={\n onSegmentBlur == null\n ? undefined\n : (event) => onSegmentBlur(arc.data, event)\n }\n />\n ));\n }}\n </Donut>\n </Group>\n )}\n {(centerNumber || centerDescriptor) != null && (\n <foreignObject\n x={DONUT_CENTER - DONUT_INNER_RADIUS}\n y={DONUT_CENTER - DONUT_INNER_RADIUS}\n width={DONUT_INNER_RADIUS * 2}\n height={DONUT_INNER_RADIUS * 2}\n className=\"pointer-events-none\"\n >\n <div\n className=\"flex size-full min-w-0 flex-col items-center justify-center\"\n style={{ containerType: 'inline-size' }}\n >\n <Text\n as=\"span\"\n variant=\"h2\"\n weight=\"semibold\"\n className={cn(\n scaleCenterNumberSize && 'block w-full text-center'\n )}\n style={\n scaleCenterNumberSize && centerNumber != null\n ? { fontSize: getFittedCenterFontSize(centerNumber) }\n : undefined\n }\n >\n {centerNumber}\n </Text>\n <Text as=\"span\" variant=\"xs\" color=\"tertiary\">\n {centerDescriptor}\n </Text>\n </div>\n </foreignObject>\n )}\n </>\n )}\n </svg>\n </div>\n );\n\n const legend = (\n <ChartLegend\n aria-label={\n ariaProps['aria-label'] == null\n ? undefined\n : `${ariaProps['aria-label']} legend`\n }\n {...legendProps}\n layout={legendLayout}\n items={legendItems}\n onItemActiveChange={(item) => {\n setActiveBuiltInLegendItemId(item?.id ?? null);\n legendProps?.onItemActiveChange?.(item);\n }}\n />\n );\n\n return (\n <div\n className={cn('size-full min-h-0 min-w-0 @container', className)}\n {...rootProps}\n >\n {hasLegend ? (\n <div\n className={cn(\n 'grid size-full min-h-0 min-w-0 grid-cols-1 items-center justify-stretch',\n legendLayout === 'list'\n ? 'grid-rows-[minmax(0,1fr)_minmax(0,45%)] gap-space-3 @[496px]:grid-cols-2 @[496px]:grid-rows-[minmax(0,1fr)] @[496px]:justify-center @[496px]:gap-space-5'\n : 'grid-rows-[minmax(0,1fr)_auto] gap-space-2'\n )}\n >\n {donut}\n {legendLayout === 'list' ? (\n <div className=\"scroll-mask-t scroll-mask-b h-full min-h-0 min-w-0 overflow-y-auto overflow-x-hidden\">\n <div className=\"flex min-h-full flex-col\">\n <div className=\"my-auto\">{legend}</div>\n </div>\n </div>\n ) : (\n legend\n )}\n </div>\n ) : (\n donut\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAiCA,IAAM,gBAAgB;AACtB,IAAM,eAAe,gBAAgB;AACrC,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB,qBAAqB;AAEhD,IAAM,kBAAkB,IAAI,KAAK,aAAa,OAAO;AAErD,IAAM,sBAAsB,UAAkB,gBAAgB,OAAO,KAAK;;;;;;AAO1E,IAAM,2BAA2B,UAC/B,gBAAgB,OAAO,MAAM,SAAS,IAAK;AAsI7C,IAAM,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oBAAC,aAAD;EACE,cACE,UAAU,iBAAiB,OACvB,KAAA,IACA,GAAG,UAAU,cAAc;EAEjC,GAAI;EACJ,QAAQ;EACR,OAAO;EACP,qBAAqB,SAAS;GAC5B,6BAA6B,MAAM,MAAM,IAAI;GAC7C,aAAa,qBAAqB,IAAI;EACxC;CACD,CAAA;CAGH,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,wCAAwC,SAAS;EAC/D,GAAI;EAEH,UAAA,YACC,qBAAC,OAAD;GACE,WAAW,GACT,2EACA,iBAAiB,SACb,6JACA,4CACN;GANF,UAAA,CAQG,OACA,iBAAiB,SAChB,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,OAAD;KAAK,WAAU;KACb,UAAA,oBAAC,OAAD;MAAK,WAAU;MAAW,UAAA;KAAY,CAAA;IACnC,CAAA;GACF,CAAA,IAEL,MAEC;EAEL,CAAA,IAAA;CAEC,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"DonutChart.js","names":[],"sources":["../../../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["import {\n useState,\n type AriaAttributes,\n type FocusEvent,\n type FocusEventHandler,\n type HTMLAttributes,\n type PointerEvent,\n type PointerEventHandler,\n type ReactNode,\n} from 'react';\n\nimport {\n animated,\n type SpringValue,\n useReducedMotion,\n useSpring,\n} from '@react-spring/web';\nimport { Group } from '@visx/group';\nimport { Pie as Donut } from '@visx/shape';\n\nimport { CHART_DIMMED_OPACITY } from '../../utils/chartConstants';\nimport { cn } from '../../utils/cn';\nimport { ChartLegend, type ChartLegendProps } from '../ChartLegend';\nimport { Text } from '../Text';\nimport {\n collateDonutSegments,\n getDonutLegendItems,\n getDrawnSegments,\n sumSegmentValues,\n} from './DonutChart.utils';\n\n// Viewport-invariant units. The donut renders into a fixed-size viewBox and\n// scales via `preserveAspectRatio=\"xMidYMid meet\"`.\nconst DONUT_VIEWBOX = 200;\nconst DONUT_CENTER = DONUT_VIEWBOX / 2;\nconst DONUT_OUTER_RADIUS = DONUT_CENTER - 8;\nconst DONUT_INNER_RADIUS = DONUT_OUTER_RADIUS * 0.64;\n\nconst numberFormatter = new Intl.NumberFormat('en-US');\n\nconst formatSegmentValue = (value: number) => numberFormatter.format(value);\n\n/**\n * Sizes the center number against the donut hole: `1cqi` is 1% of the hole's\n * width, so a longer value resolves to a smaller size, capped at the heading\n * size so short values do not balloon.\n */\nconst getFittedCenterFontSize = (value: string) =>\n `min(1.75rem, ${100 / (value.length * 0.7)}cqi)`;\n\nexport type DonutChartSegment = {\n id: string;\n label: ReactNode;\n value: number;\n /** Use DS CSS color token; typically a `var(--chart-...)` reference. */\n color: string;\n /**\n * Marks a segment that already stands for a group of others — a remainder the\n * data source rolled up, say. `otherCollationThreshold` merges it with the\n * tail it collates instead of drawing a second \"Other\" beside it.\n */\n isOther?: boolean;\n};\n\ntype DonutArcDatumLike<Datum> = {\n data: Datum;\n value: number;\n index: number;\n startAngle: number;\n endAngle: number;\n padAngle: number;\n};\n\n/**\n * Everything `ChartLegend` accepts except `items`, which the donut derives from\n * `segments`. Namespacing these under `legendProps` keeps `className` and the\n * other DOM attributes on the chart root unambiguous.\n */\ntype DonutChartLegendProps = Omit<ChartLegendProps, 'items'>;\n\n/**\n * `legendProps` only exists while there is a legend to configure: with\n * `showLegend={false}` it narrows to `never`, so autocomplete stops offering it\n * and passing it is a type error rather than a silently ignored prop.\n */\ntype DonutChartLegendConfig =\n | {\n /** Defaults to true. */\n showLegend?: true;\n /** Forwarded to the rendered `ChartLegend`. */\n legendProps?: DonutChartLegendProps;\n }\n | {\n showLegend: false;\n legendProps?: never;\n };\n\nexport type DonutChartProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children' | 'onPointerOut'\n> &\n DonutChartLegendConfig & {\n segments: readonly DonutChartSegment[];\n /**\n * When provided and non-empty, only segments whose IDs are in the set are\n * rendered in the donut. Unselected segments stay in the legend with a 0%\n * share. IDs address the collated list, so the segments behind an \"Other\"\n * slice are selected as `DONUT_OTHER_SEGMENT_ID` rather than individually. A\n * set naming none of those IDs draws everything, so a selection outliving\n * the data it was made against cannot empty the chart.\n */\n selectedIds?: ReadonlySet<string>;\n /**\n * Number to render in the donut hole.\n */\n centerNumber?: string;\n /**\n * Descriptor for the number in the donut hole.\n */\n centerDescriptor?: string;\n /**\n * Scales `centerNumber` to the width of the donut hole.\n */\n scaleCenterNumberSize?: boolean;\n /** Emphasizes one segment and dims the rest. */\n activeSegmentId?: string | null;\n /** Emphasizes the segment represented by one external legend item. Built-in legends set this automatically. */\n activeLegendItemId?: string | null;\n /** Animates segments when they are drawn. Defaults to true. */\n shouldAnimate?: boolean;\n /** Names segments and makes them focusable. */\n getSegmentAriaLabel?: (\n segment: DonutChartSegment\n ) => AriaAttributes['aria-label'];\n /**\n * Set to false to skip drawing the donut. Use it to avoid the work while a\n * parent container is actively resizing. Defaults to true.\n */\n isRendering?: boolean;\n /**\n * Collates segments less than this set number to an \"Other\" slice, automatically merging any segment flagged `isOther`. Do not pass a value to render all segments, even if they are tiny.\n */\n otherCollationThreshold?: number;\n /**\n * Formats each segment's value for the legend. Defaults to a plain\n * `en-US` number; pass a unit-aware formatter for durations, bytes, cost.\n */\n formatValue?: (value: number) => ReactNode;\n onSegmentPointerMove?: (\n segment: DonutChartSegment,\n event: PointerEvent<SVGPathElement>\n ) => void;\n onSegmentPointerOut?: () => void;\n onSegmentPointerUp?: (\n segment: DonutChartSegment,\n event: PointerEvent<SVGPathElement>\n ) => void;\n onSegmentFocus?: (\n segment: DonutChartSegment,\n event: FocusEvent<SVGPathElement>\n ) => void;\n onSegmentBlur?: (\n segment: DonutChartSegment,\n event: FocusEvent<SVGPathElement>\n ) => void;\n };\n\ntype AnimatedDonutArcProps = {\n arc: DonutArcDatumLike<DonutChartSegment>;\n path: (arc: DonutArcDatumLike<DonutChartSegment>) => string | null;\n animationProgress: SpringValue<number>;\n animationStartAngle: number;\n animationEndAngle: number;\n 'aria-label'?: AriaAttributes['aria-label'];\n isDimmed: boolean;\n onPointerMove?: PointerEventHandler<SVGPathElement>;\n onPointerOut?: () => void;\n onPointerUp?: PointerEventHandler<SVGPathElement>;\n onFocus?: FocusEventHandler<SVGPathElement>;\n onBlur?: FocusEventHandler<SVGPathElement>;\n};\n\nconst AnimatedDonutArc = ({\n arc,\n path,\n animationProgress,\n animationStartAngle,\n animationEndAngle,\n isDimmed,\n onPointerMove,\n onPointerOut,\n onPointerUp,\n onFocus,\n onBlur,\n ...ariaProps\n}: AnimatedDonutArcProps) => {\n const isInteractive =\n onPointerMove != null || onPointerOut != null || onPointerUp != null;\n const handlePointerDown = (event: PointerEvent<SVGPathElement>) => {\n // Chromium can match :focus-visible when a focusable SVG path is clicked.\n // Keep the focus indicator for keyboard navigation without showing it for\n // pointer interaction.\n if (\n (event.pointerType === 'mouse' || event.pointerType === 'pen') &&\n event.currentTarget.hasAttribute('tabindex')\n ) {\n event.preventDefault();\n }\n };\n\n return (\n <animated.path\n fill={arc.data.color}\n opacity={isDimmed ? CHART_DIMMED_OPACITY : 1}\n className={cn(\n 'transition-opacity duration-fast focus:outline-hidden focus-visible:stroke-focus focus-visible:stroke-2 motion-reduce:transition-none',\n isInteractive && 'cursor-pointer'\n )}\n d={animationProgress.to((progress) => {\n const revealAngle =\n animationStartAngle +\n (animationEndAngle - animationStartAngle) * progress;\n const endAngle = Math.min(\n arc.endAngle,\n Math.max(arc.startAngle, revealAngle)\n );\n return path({ ...arc, endAngle }) ?? '';\n })}\n role={ariaProps['aria-label'] == null ? undefined : 'graphics-symbol img'}\n tabIndex={ariaProps['aria-label'] == null ? undefined : 0}\n {...ariaProps}\n onPointerMove={onPointerMove}\n onPointerDown={handlePointerDown}\n onPointerOut={onPointerOut}\n onPointerUp={onPointerUp}\n onFocus={onFocus}\n onBlur={onBlur}\n />\n );\n};\n\n/**\n * DonutChart renders a donut and its `ChartLegend` from a flat list of\n * segments. Consumers own the segment palette and pair the chart\n * with `ChartCard` and their own tooltip.\n *\n * The legend sits below the donut in narrow containers and beside it once the\n * container passes 496px. Pass `showLegend={false}` for the donut alone,\n * `legendProps` to configure the legend, and `legendProps.onItemClick` with\n * `selectedIds` to make legend entries filter the donut. A long tail of tiny\n * slices collapses into one \"Other\" slice via `otherCollationThreshold`, which\n * absorbs any segment flagged `isOther`.\n\n */\nexport const DonutChart = ({\n segments,\n selectedIds,\n centerNumber,\n centerDescriptor,\n scaleCenterNumberSize = false,\n activeSegmentId,\n activeLegendItemId,\n shouldAnimate = true,\n getSegmentAriaLabel,\n isRendering = true,\n otherCollationThreshold,\n showLegend = true,\n legendProps,\n formatValue = formatSegmentValue,\n onSegmentPointerMove,\n onSegmentPointerOut,\n onSegmentPointerUp,\n onSegmentFocus,\n onSegmentBlur,\n className,\n ...rest\n}: DonutChartProps) => {\n const [activeBuiltInLegendItemId, setActiveBuiltInLegendItemId] = useState<\n string | null\n >(null);\n const isReducedMotion = (useReducedMotion() ?? false) || !shouldAnimate;\n const ariaProps = { 'aria-label': rest['aria-label'] };\n const rootProps: HTMLAttributes<HTMLDivElement> = { ...rest };\n delete rootProps['aria-label'];\n\n // Collation happens before the selection, so the legend lists the same rows\n // the donut draws arcs for and neither reflows while filtering.\n const collatedSegments = collateDonutSegments(\n segments,\n otherCollationThreshold\n );\n const drawnSegments = getDrawnSegments(collatedSegments, selectedIds);\n const renderedSegments = drawnSegments.filter((segment) => segment.value > 0);\n const drawnTotal = sumSegmentValues(drawnSegments);\n const drawnIds = new Set(drawnSegments.map((segment) => segment.id));\n const drawnArcIds = new Set(renderedSegments.map((segment) => segment.id));\n const hasDrawnSegments = isRendering && drawnTotal > 0;\n const segmentAnimationKey = JSON.stringify(\n renderedSegments.map((segment) => [segment.id, segment.value])\n );\n // A single sweep angle reveals the arcs in sequence, leaving only one moving\n // boundary regardless of how many colored segments the donut contains.\n const [animation] = useSpring(\n () => ({\n from: { progress: 0 },\n to: { progress: hasDrawnSegments ? 1 : 0 },\n reset: true,\n immediate: isReducedMotion,\n }),\n [segmentAnimationKey, hasDrawnSegments, isReducedMotion]\n );\n\n const legendItems = getDonutLegendItems({\n segments: collatedSegments,\n selectedIds,\n drawnIds,\n drawnTotal,\n formatValue,\n });\n const hasLegend = showLegend && collatedSegments.length > 0;\n const legendLayout = legendProps?.layout ?? 'list';\n const requestedActiveLegendItemId =\n (hasLegend ? activeBuiltInLegendItemId : null) ?? activeLegendItemId;\n const renderedActiveLegendItemId =\n requestedActiveLegendItemId != null &&\n drawnArcIds.has(requestedActiveLegendItemId)\n ? requestedActiveLegendItemId\n : null;\n const renderedActiveSegmentId =\n activeSegmentId != null && drawnArcIds.has(activeSegmentId)\n ? activeSegmentId\n : null;\n const activeId = renderedActiveLegendItemId ?? renderedActiveSegmentId;\n\n const donut = (\n <div className=\"relative flex size-full min-h-0 min-w-0 items-center justify-center [&>svg]:max-h-[22.5rem] [&>svg]:max-w-[22.5rem]\">\n <svg\n viewBox={`0 0 ${DONUT_VIEWBOX} ${DONUT_VIEWBOX}`}\n preserveAspectRatio=\"xMidYMid meet\"\n className=\"size-full\"\n role={getSegmentAriaLabel == null ? 'img' : 'graphics-document group'}\n {...ariaProps}\n >\n {isRendering && (\n <>\n {drawnTotal > 0 && (\n <Group\n top={DONUT_CENTER}\n left={DONUT_CENTER}\n className={cn(\n activeId == null &&\n '[&:focus-within>path:not(:focus)]:opacity-[0.45] [&>path:focus]:opacity-100'\n )}\n >\n <Donut\n data={renderedSegments}\n pieValue={(segment) => segment.value}\n pieSort={null}\n pieSortValues={null}\n outerRadius={DONUT_OUTER_RADIUS}\n innerRadius={DONUT_INNER_RADIUS}\n >\n {(donut) => {\n const animationStartAngle = donut.arcs[0]?.startAngle ?? 0;\n const animationEndAngle =\n donut.arcs.at(-1)?.endAngle ?? animationStartAngle;\n return donut.arcs.map((arc) => (\n <AnimatedDonutArc\n key={arc.data.id}\n arc={arc}\n path={donut.path}\n animationProgress={animation.progress}\n animationStartAngle={animationStartAngle}\n animationEndAngle={animationEndAngle}\n aria-label={getSegmentAriaLabel?.(arc.data)}\n isDimmed={activeId != null && activeId !== arc.data.id}\n onPointerMove={\n onSegmentPointerMove == null\n ? undefined\n : (event) => onSegmentPointerMove(arc.data, event)\n }\n onPointerOut={onSegmentPointerOut}\n onPointerUp={\n onSegmentPointerUp == null\n ? undefined\n : (event) => onSegmentPointerUp(arc.data, event)\n }\n onFocus={\n onSegmentFocus == null\n ? undefined\n : (event) => onSegmentFocus(arc.data, event)\n }\n onBlur={\n onSegmentBlur == null\n ? undefined\n : (event) => onSegmentBlur(arc.data, event)\n }\n />\n ));\n }}\n </Donut>\n </Group>\n )}\n {(centerNumber || centerDescriptor) != null && (\n <foreignObject\n x={DONUT_CENTER - DONUT_INNER_RADIUS}\n y={DONUT_CENTER - DONUT_INNER_RADIUS}\n width={DONUT_INNER_RADIUS * 2}\n height={DONUT_INNER_RADIUS * 2}\n className=\"pointer-events-none\"\n >\n <div\n className=\"flex size-full min-w-0 flex-col items-center justify-center\"\n style={{ containerType: 'inline-size' }}\n >\n <Text\n as=\"span\"\n variant=\"h2\"\n weight=\"semibold\"\n className={cn(\n scaleCenterNumberSize && 'block w-full text-center'\n )}\n style={\n scaleCenterNumberSize && centerNumber != null\n ? { fontSize: getFittedCenterFontSize(centerNumber) }\n : undefined\n }\n >\n {centerNumber}\n </Text>\n <Text as=\"span\" variant=\"xs\" color=\"tertiary\">\n {centerDescriptor}\n </Text>\n </div>\n </foreignObject>\n )}\n </>\n )}\n </svg>\n </div>\n );\n\n const legend = (\n <ChartLegend\n aria-label={\n ariaProps['aria-label'] == null\n ? undefined\n : `${ariaProps['aria-label']} legend`\n }\n {...legendProps}\n layout={legendLayout}\n items={legendItems}\n onItemActiveChange={(item) => {\n setActiveBuiltInLegendItemId(item?.id ?? null);\n legendProps?.onItemActiveChange?.(item);\n }}\n />\n );\n\n return (\n <div\n className={cn('size-full min-h-0 min-w-0 @container', className)}\n {...rootProps}\n >\n {hasLegend ? (\n <div\n className={cn(\n 'grid size-full min-h-0 min-w-0 grid-cols-1 items-center justify-stretch',\n legendLayout === 'list'\n ? 'grid-rows-[minmax(0,1fr)_minmax(0,45%)] gap-space-3 @[496px]:grid-cols-2 @[496px]:grid-rows-[minmax(0,1fr)] @[496px]:justify-center @[496px]:gap-space-5'\n : 'grid-rows-[minmax(0,1fr)_auto] gap-space-2'\n )}\n >\n {donut}\n {legendLayout === 'list' ? (\n <div className=\"scroll-mask-t scroll-mask-b h-full min-h-0 min-w-0 overflow-y-auto overflow-x-hidden\">\n <div className=\"flex min-h-full flex-col\">\n <div className=\"my-auto\">{legend}</div>\n </div>\n </div>\n ) : (\n legend\n )}\n </div>\n ) : (\n donut\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;AAiCA,IAAM,gBAAgB;AACtB,IAAM,eAAe,gBAAgB;AACrC,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB,qBAAqB;AAEhD,IAAM,kBAAkB,IAAI,KAAK,aAAa,OAAO;AAErD,IAAM,sBAAsB,UAAkB,gBAAgB,OAAO,KAAK;;;;;;AAO1E,IAAM,2BAA2B,UAC/B,gBAAgB,OAAO,MAAM,SAAS,IAAK;AAsI7C,IAAM,oBAAoB,EACxB,KACA,MACA,mBACA,qBACA,mBACA,UACA,eACA,cACA,aACA,SACA,QACA,GAAG,gBACwB;CAC3B,MAAM,gBACJ,iBAAiB,QAAQ,gBAAgB,QAAQ,eAAe;CAClE,MAAM,qBAAqB,UAAwC;EAIjE,KACG,MAAM,gBAAgB,WAAW,MAAM,gBAAgB,UACxD,MAAM,cAAc,aAAa,UAAU,GAE3C,MAAM,eAAe;CAEzB;CAEA,OACE,oBAAC,SAAS,MAAV;EACE,MAAM,IAAI,KAAK;EACf,SAAS,WAAW,uBAAuB;EAC3C,WAAW,GACT,yIACA,iBAAiB,gBACnB;EACA,GAAG,kBAAkB,IAAI,aAAa;GACpC,MAAM,cACJ,uBACC,oBAAoB,uBAAuB;GAC9C,MAAM,WAAW,KAAK,IACpB,IAAI,UACJ,KAAK,IAAI,IAAI,YAAY,WAAW,CAC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MAEC;EAEL,CAAA,IAAA;CAEC,CAAA;AAET"}
|
|
@@ -112,7 +112,7 @@ var DropdownMenuContent = React$1.forwardRef(({ className, sideOffset = 4, child
|
|
|
112
112
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
113
113
|
var DropdownMenuItem = React$1.forwardRef(({ className, inset, size = "md", ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Item, {
|
|
114
114
|
ref,
|
|
115
|
-
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-
|
|
115
|
+
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-surface-level-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50", OPTION_ROW_SIZES[size].minHeightClassName, size === "sm" ? "text-xs leading-4" : "text-sm", inset && "pl-space-6", className),
|
|
116
116
|
...props
|
|
117
117
|
}));
|
|
118
118
|
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
@@ -125,7 +125,7 @@ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
|
125
125
|
var DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
126
126
|
var DropdownMenuSubTrigger = React$1.forwardRef(({ className, inset, children, size = "md", ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.SubTrigger, {
|
|
127
127
|
ref,
|
|
128
|
-
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-
|
|
128
|
+
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-surface-level-2 data-[state=open]:bg-surface-level-2", OPTION_ROW_SIZES[size].minHeightClassName, size === "sm" ? "text-xs leading-4" : "text-sm", inset && "pl-space-6", className),
|
|
129
129
|
...props,
|
|
130
130
|
children
|
|
131
131
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const DropdownMenu: typeof DropdownMenuPrimitive.Root = (props) => {\n const [open = false, onOpenChange] = useControllableState({\n prop: props.open,\n defaultProp: props.defaultOpen ?? false,\n onChange: props.onOpenChange,\n });\n\n return (\n <DropdownMenuPrimitive.Root\n {...props}\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={undefined}\n />\n );\n};\n\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\n\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\n\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\n\nexport const DropdownMenuLabel = DropdownMenuPrimitive.Label;\n\n/**\n * Stops clicks outside an open dropdown from reaching elements underneath it\n * (e.g. a table row's `onClick`) without covering the viewport, so scrolling\n * the content behind the menu keeps working natively.\n *\n * React delegates `onClick` at the root in the bubble phase, so a capture-phase\n * `click` listener on `document` runs first and can stop the event before it\n * gets there. pointerdown is left alone so Radix's outside-dismiss keeps\n * working; the wheel listener is passive so native scroll is never interrupted,\n * it just also dismisses the menu (an open menu jitters as Radix repositions it\n * to follow its trigger while scrolling).\n *\n * \"Inside\" is any element with `role=\"menu\"` in its ancestry — Radix gives that\n * role to both the content and its submenus (which portal out separately), so\n * clicks and scrolls inside a submenu are correctly treated as inside.\n */\nconst OutsideClickGuard = () => {\n const cleanupTimerRef =\n React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const pointerDownOutsideRef = React.useRef(false);\n\n React.useLayoutEffect(() => {\n clearTimeout(cleanupTimerRef.current);\n pointerDownOutsideRef.current = false;\n\n const isOutside = (target: EventTarget | null) =>\n !(target instanceof Element) || !target.closest('[role=\"menu\"]');\n\n // Observe (don't block) outside pointerdowns: Radix dismisses on them, so\n // this tells us the trailing click needs absorbing on cleanup.\n const onPointerDown = (event: PointerEvent) => {\n if (isOutside(event.target)) pointerDownOutsideRef.current = true;\n };\n document.addEventListener('pointerdown', onPointerDown, true);\n\n // Block clicks that land outside the menu from reaching the content beneath.\n const onClick = (event: MouseEvent) => {\n if (isOutside(event.target)) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n document.addEventListener('click', onClick, true);\n\n // Dismiss on scroll of the content behind the menu: an anchored menu that\n // stays open jitters as Radix repositions it to chase its trigger. Passive,\n // so the wheel still scrolls the content natively on the same gesture.\n // Scrolling inside the menu (e.g. a details panel) leaves it open.\n const onWheel = (event: WheelEvent) => {\n if (isOutside(event.target)) {\n document.dispatchEvent(\n new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })\n );\n }\n };\n document.addEventListener('wheel', onWheel, { passive: true });\n\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true);\n document.removeEventListener('click', onClick, true);\n document.removeEventListener('wheel', onWheel);\n\n // Radix dismisses on the outside pointerdown and unmounts this guard\n // before the trailing click fires, so absorb that one click here. Only\n // for pointer dismissals — Escape / item selection have no trailing\n // outside click, and absorbing an unrelated later click would be wrong.\n if (!pointerDownOutsideRef.current) return;\n\n const absorb = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n };\n const opts = { capture: true, once: true } as const;\n document.addEventListener('pointerup', absorb, opts);\n document.addEventListener('mouseup', absorb, opts);\n document.addEventListener('click', absorb, opts);\n\n cleanupTimerRef.current = setTimeout(() => {\n if (typeof document === 'undefined') return;\n document.removeEventListener('pointerup', absorb, { capture: true });\n document.removeEventListener('mouseup', absorb, { capture: true });\n document.removeEventListener('click', absorb, { capture: true });\n }, 300);\n };\n }, []);\n\n return null;\n};\n\nexport const DropdownMenuContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {\n /**\n * When true, stops clicks outside the open menu from reaching elements\n * underneath (e.g. table rows), while leaving scrolling of that content\n * intact. Radix's outside-click dismiss still works normally.\n */\n preventClickThrough?: boolean;\n }\n>(\n (\n { className, sideOffset = 4, children, preventClickThrough, ...props },\n ref\n ) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-subtle bg-popover p-space-1 shadow-lg',\n className\n )}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n {preventClickThrough && <OutsideClickGuard />}\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n }\n);\nDropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;\n\nexport const DropdownMenuItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, size = 'md', ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-none transition-colors focus:bg-surface-level-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset && 'pl-space-6',\n className\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;\n\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('my-space-1 h-px bg-surface-level-2', className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;\n\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\n\nexport const DropdownMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, children, size = 'md', ...props }, ref) => (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n 'flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-none transition-colors focus:bg-surface-level-2 data-[state=open]:bg-surface-level-2',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset && 'pl-space-6',\n className\n )}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.SubTrigger>\n));\nDropdownMenuSubTrigger.displayName =\n DropdownMenuPrimitive.SubTrigger.displayName;\n\nexport const DropdownMenuSubContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-subtle bg-popover p-space-1 shadow-lg',\n className\n )}\n style={{ zIndex }}\n {...props}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </DropdownMenuPrimitive.SubContent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;CACO;CACL,WAAW,GACT,wMACA,iBAAiB,KAAK,CAAC,oBACvB,SAAS,OAAO,sBAAsB,WACtC,SAAS,cACT,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc,sBAAsB,KAAK;AAE1D,IAAa,wBAAwB,QAAM,YAGxC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,sBAAsB,WAAvB;CACO;CACL,WAAW,GAAG,sCAAsC,SAAS;CAC7D,GAAI;AACL,CAAA,CACF;AACD,sBAAsB,cAAc,sBAAsB,UAAU;AAEpE,IAAa,kBAAkB,sBAAsB;AAErD,IAAa,yBAAyB,QAAM,YAUzC,EAAE,WAAW,OAAO,UAAU,OAAO,MAAM,GAAG,SAAS,QACxD,oBAAC,sBAAsB,YAAvB;CACO;CACL,WAAW,GACT,8KACA,iBAAiB,KAAK,CAAC,oBACvB,SAAS,OAAO,sBAAsB,WACtC,SAAS,cACT,SACF;CACA,GAAI;CAEH;AAC+B,CAAA,CACnC;AACD,uBAAuB,cACrB,sBAAsB,WAAW;AAEnC,IAAa,yBAAyB,QAAM,YAGzC,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5C,MAAM,SAAS,UAAU,SAAS,OAAO;CAEzC,OACE,oBAAC,sBAAsB,QAAvB,EAAA,UACE,oBAAC,sBAAsB,YAAvB;EACO;EACL,WAAW,GACT,+FACA,SACF;EACA,OAAO,EAAE,OAAO;EAChB,GAAI;EAEJ,UAAA,oBAAC,gBAAD;GAAgB,OAAO;GAAS;EAAyB,CAAA;CACzB,CAAA,EACN,CAAA;AAElC,CAAC;AACD,uBAAuB,cACrB,sBAAsB,WAAW"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport { cn } from '../../utils/cn';\nimport {\n OPTION_ROW_SIZES,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\n\nexport const DropdownMenu: typeof DropdownMenuPrimitive.Root = (props) => {\n const [open = false, onOpenChange] = useControllableState({\n prop: props.open,\n defaultProp: props.defaultOpen ?? false,\n onChange: props.onOpenChange,\n });\n\n return (\n <DropdownMenuPrimitive.Root\n {...props}\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={undefined}\n />\n );\n};\n\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\n\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\n\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\n\nexport const DropdownMenuLabel = DropdownMenuPrimitive.Label;\n\n/**\n * Stops clicks outside an open dropdown from reaching elements underneath it\n * (e.g. a table row's `onClick`) without covering the viewport, so scrolling\n * the content behind the menu keeps working natively.\n *\n * React delegates `onClick` at the root in the bubble phase, so a capture-phase\n * `click` listener on `document` runs first and can stop the event before it\n * gets there. pointerdown is left alone so Radix's outside-dismiss keeps\n * working; the wheel listener is passive so native scroll is never interrupted,\n * it just also dismisses the menu (an open menu jitters as Radix repositions it\n * to follow its trigger while scrolling).\n *\n * \"Inside\" is any element with `role=\"menu\"` in its ancestry — Radix gives that\n * role to both the content and its submenus (which portal out separately), so\n * clicks and scrolls inside a submenu are correctly treated as inside.\n */\nconst OutsideClickGuard = () => {\n const cleanupTimerRef =\n React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const pointerDownOutsideRef = React.useRef(false);\n\n React.useLayoutEffect(() => {\n clearTimeout(cleanupTimerRef.current);\n pointerDownOutsideRef.current = false;\n\n const isOutside = (target: EventTarget | null) =>\n !(target instanceof Element) || !target.closest('[role=\"menu\"]');\n\n // Observe (don't block) outside pointerdowns: Radix dismisses on them, so\n // this tells us the trailing click needs absorbing on cleanup.\n const onPointerDown = (event: PointerEvent) => {\n if (isOutside(event.target)) pointerDownOutsideRef.current = true;\n };\n document.addEventListener('pointerdown', onPointerDown, true);\n\n // Block clicks that land outside the menu from reaching the content beneath.\n const onClick = (event: MouseEvent) => {\n if (isOutside(event.target)) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n document.addEventListener('click', onClick, true);\n\n // Dismiss on scroll of the content behind the menu: an anchored menu that\n // stays open jitters as Radix repositions it to chase its trigger. Passive,\n // so the wheel still scrolls the content natively on the same gesture.\n // Scrolling inside the menu (e.g. a details panel) leaves it open.\n const onWheel = (event: WheelEvent) => {\n if (isOutside(event.target)) {\n document.dispatchEvent(\n new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })\n );\n }\n };\n document.addEventListener('wheel', onWheel, { passive: true });\n\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true);\n document.removeEventListener('click', onClick, true);\n document.removeEventListener('wheel', onWheel);\n\n // Radix dismisses on the outside pointerdown and unmounts this guard\n // before the trailing click fires, so absorb that one click here. Only\n // for pointer dismissals — Escape / item selection have no trailing\n // outside click, and absorbing an unrelated later click would be wrong.\n if (!pointerDownOutsideRef.current) return;\n\n const absorb = (event: Event) => {\n event.preventDefault();\n event.stopPropagation();\n };\n const opts = { capture: true, once: true } as const;\n document.addEventListener('pointerup', absorb, opts);\n document.addEventListener('mouseup', absorb, opts);\n document.addEventListener('click', absorb, opts);\n\n cleanupTimerRef.current = setTimeout(() => {\n if (typeof document === 'undefined') return;\n document.removeEventListener('pointerup', absorb, { capture: true });\n document.removeEventListener('mouseup', absorb, { capture: true });\n document.removeEventListener('click', absorb, { capture: true });\n }, 300);\n };\n }, []);\n\n return null;\n};\n\nexport const DropdownMenuContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {\n /**\n * When true, stops clicks outside the open menu from reaching elements\n * underneath (e.g. table rows), while leaving scrolling of that content\n * intact. Radix's outside-click dismiss still works normally.\n */\n preventClickThrough?: boolean;\n }\n>(\n (\n { className, sideOffset = 4, children, preventClickThrough, ...props },\n ref\n ) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-subtle bg-popover p-space-1 shadow-lg',\n className\n )}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n {preventClickThrough && <OutsideClickGuard />}\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n }\n);\nDropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;\n\nexport const DropdownMenuItem = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, size = 'md', ...props }, ref) => (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n 'flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-surface-level-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset && 'pl-space-6',\n className\n )}\n {...props}\n />\n));\nDropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;\n\nexport const DropdownMenuSeparator = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('my-space-1 h-px bg-surface-level-2', className)}\n {...props}\n />\n));\nDropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;\n\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\n\nexport const DropdownMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(({ className, inset, children, size = 'md', ...props }, ref) => (\n <DropdownMenuPrimitive.SubTrigger\n ref={ref}\n className={cn(\n 'flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-surface-level-2 data-[state=open]:bg-surface-level-2',\n OPTION_ROW_SIZES[size].minHeightClassName,\n size === 'sm' ? 'text-xs leading-4' : 'text-sm',\n inset && 'pl-space-6',\n className\n )}\n {...props}\n >\n {children}\n </DropdownMenuPrimitive.SubTrigger>\n));\nDropdownMenuSubTrigger.displayName =\n DropdownMenuPrimitive.SubTrigger.displayName;\n\nexport const DropdownMenuSubContent = React.forwardRef<\n React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,\n React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(({ className, children, ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'min-w-[8rem] overflow-hidden rounded-md border border-subtle bg-popover p-space-1 shadow-lg',\n className\n )}\n style={{ zIndex }}\n {...props}\n >\n <ZIndexProvider value={zIndex}>{children}</ZIndexProvider>\n </DropdownMenuPrimitive.SubContent>\n </DropdownMenuPrimitive.Portal>\n );\n});\nDropdownMenuSubContent.displayName =\n DropdownMenuPrimitive.SubContent.displayName;\n"],"mappings":";;;;;;;;;;AAcA,IAAa,gBAAmD,UAAU;CACxE,MAAM,CAAC,OAAO,OAAO,gB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IAAa,wBAAwB,QAAM,YAGxC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,sBAAsB,WAAvB;CACO;CACL,WAAW,GAAG,sCAAsC,SAAS;CAC7D,GAAI;AACL,CAAA,CACF;AACD,sBAAsB,cAAc,sBAAsB,UAAU;AAEpE,IAAa,kBAAkB,sBAAsB;AAErD,IAAa,yBAAyB,QAAM,YAUzC,EAAE,WAAW,OAAO,UAAU,OAAO,MAAM,GAAG,SAAS,QACxD,oBAAC,sBAAsB,YAAvB;CACO;CACL,WAAW,GACT,gLACA,iBAAiB,KAAK,CAAC,oBACvB,SAAS,OAAO,sBAAsB,WACtC,SAAS,cACT,SACF;CACA,GAAI;CAEH;AAC+B,CAAA,CACnC;AACD,uBAAuB,cACrB,sBAAsB,WAAW;AAEnC,IAAa,yBAAyB,QAAM,YAGzC,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5C,MAAM,SAAS,UAAU,SAAS,OAAO;CAEzC,OACE,oBAAC,sBAAsB,QAAvB,EAAA,UACE,oBAAC,sBAAsB,YAAvB;EACO;EACL,WAAW,GACT,+FACA,SACF;EACA,OAAO,EAAE,OAAO;EAChB,GAAI;EAEJ,UAAA,oBAAC,gBAAD;GAAgB,OAAO;GAAS;EAAyB,CAAA;CACzB,CAAA,EACN,CAAA;AAElC,CAAC;AACD,uBAAuB,cACrB,sBAAsB,WAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ErrorState } from "../../_chunks/ErrorState-
|
|
1
|
+
import { t as ErrorState } from "../../_chunks/ErrorState-BY6VBCRB.js";
|
|
2
2
|
export { ErrorState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as ErrorState } from "../../_chunks/ErrorState-
|
|
1
|
+
import { t as ErrorState } from "../../_chunks/ErrorState-BY6VBCRB.js";
|
|
2
2
|
export { ErrorState };
|
|
@@ -25,7 +25,7 @@ var INPUT_TEXT_CLASSES = {
|
|
|
25
25
|
*/
|
|
26
26
|
function getInputContainerClasses({ size, variant, isError = false, disabled = false, className }) {
|
|
27
27
|
const outlined = variant === "outlined";
|
|
28
|
-
return cn("box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]", CONTROL_SIZES[size].heightClassName, INPUT_HORIZONTAL_PADDING_CLASSES[size], INPUT_RADIUS_CLASSES[size], "focus-within:outline-
|
|
28
|
+
return cn("box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]", CONTROL_SIZES[size].heightClassName, INPUT_HORIZONTAL_PADDING_CLASSES[size], INPUT_RADIUS_CLASSES[size], "focus-within:outline-hidden", {
|
|
29
29
|
"border border-subtle bg-transparent": variant === "outlined",
|
|
30
30
|
"border border-transparent bg-surface-level-3": variant === "plain"
|
|
31
31
|
}, outlined && !disabled && !isError && "[&:hover:not(:focus-within)]:border-default", !isError && (outlined ? "focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]" : "focus-within:border-focus"), isError && (outlined ? "border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]" : "border-error-strong focus-within:border-error-strong"), disabled && "cursor-not-allowed bg-disabled opacity-50", className);
|
|
@@ -35,7 +35,7 @@ function getInputContainerClasses({ size, variant, isError = false, disabled = f
|
|
|
35
35
|
* Used by both the design system Input and CommandInput.
|
|
36
36
|
*/
|
|
37
37
|
function getInputElementClasses({ size, disabled = false, className }) {
|
|
38
|
-
return cn("min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-
|
|
38
|
+
return cn("min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-hidden", INPUT_TEXT_CLASSES[size], "placeholder:text-placeholder", disabled && "cursor-not-allowed", className);
|
|
39
39
|
}
|
|
40
40
|
/** Shared styling for decorator wrappers. */
|
|
41
41
|
var DECORATOR_CLASSES = "flex items-center text-tertiary";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputStyles.js","names":[],"sources":["../../../src/components/Input/inputStyles.ts"],"sourcesContent":["import { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\n\nexport type InputSize = ControlSize;\nexport type InputVariant = 'outlined' | 'plain';\n\nexport const INPUT_HORIZONTAL_PADDING_CLASSES: Record<InputSize, string> = {\n xs: 'px-space-1',\n sm: 'px-space-2',\n md: 'px-space-3',\n lg: 'px-space-3',\n};\n\nexport const INPUT_RADIUS_CLASSES: Record<InputSize, string> = {\n xs: 'rounded-xs',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-md',\n};\n\nexport const INPUT_TEXT_CLASSES: Record<InputSize, string> = {\n xs: 'text-xxs leading-[1.15]',\n sm: 'text-xs',\n md: 'text-sm leading-normal',\n lg: 'text-sm leading-normal',\n};\n\n/**\n * Shared styling for input containers (border, padding, rounding, variant).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputContainerClasses({\n size,\n variant,\n isError = false,\n disabled = false,\n className,\n}: {\n size: InputSize;\n variant: InputVariant;\n isError?: boolean;\n disabled?: boolean;\n className?: string;\n}) {\n const outlined = variant === 'outlined';\n return cn(\n 'box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].heightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n 'focus-within:outline-
|
|
1
|
+
{"version":3,"file":"inputStyles.js","names":[],"sources":["../../../src/components/Input/inputStyles.ts"],"sourcesContent":["import { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\n\nexport type InputSize = ControlSize;\nexport type InputVariant = 'outlined' | 'plain';\n\nexport const INPUT_HORIZONTAL_PADDING_CLASSES: Record<InputSize, string> = {\n xs: 'px-space-1',\n sm: 'px-space-2',\n md: 'px-space-3',\n lg: 'px-space-3',\n};\n\nexport const INPUT_RADIUS_CLASSES: Record<InputSize, string> = {\n xs: 'rounded-xs',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-md',\n};\n\nexport const INPUT_TEXT_CLASSES: Record<InputSize, string> = {\n xs: 'text-xxs leading-[1.15]',\n sm: 'text-xs',\n md: 'text-sm leading-normal',\n lg: 'text-sm leading-normal',\n};\n\n/**\n * Shared styling for input containers (border, padding, rounding, variant).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputContainerClasses({\n size,\n variant,\n isError = false,\n disabled = false,\n className,\n}: {\n size: InputSize;\n variant: InputVariant;\n isError?: boolean;\n disabled?: boolean;\n className?: string;\n}) {\n const outlined = variant === 'outlined';\n return cn(\n 'box-border flex w-full items-center gap-space-2 transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].heightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n 'focus-within:outline-hidden',\n {\n 'border border-subtle bg-transparent': variant === 'outlined',\n 'border border-transparent bg-surface-level-3': variant === 'plain',\n },\n outlined &&\n !disabled &&\n !isError &&\n '[&:hover:not(:focus-within)]:border-default',\n !isError &&\n (outlined\n ? 'focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]'\n : 'focus-within:border-focus'),\n isError &&\n (outlined\n ? 'border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]'\n : 'border-error-strong focus-within:border-error-strong'),\n disabled && 'cursor-not-allowed bg-disabled opacity-50',\n className\n );\n}\n\n/**\n * Shared styling for the inner input element (unstyled, fills container).\n * Used by both the design system Input and CommandInput.\n */\nexport function getInputElementClasses({\n size,\n disabled = false,\n className,\n}: {\n size: InputSize;\n disabled?: boolean;\n className?: string;\n}) {\n return cn(\n 'min-w-0 max-w-full flex-1 border-none bg-transparent p-0 outline-hidden',\n INPUT_TEXT_CLASSES[size],\n 'placeholder:text-placeholder',\n disabled && 'cursor-not-allowed',\n className\n );\n}\n\n/** Shared styling for decorator wrappers. */\nexport const DECORATOR_CLASSES = 'flex items-center text-tertiary';\n"],"mappings":";;;AAMA,IAAa,mCAA8D;CACzE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,uBAAkD;CAC7D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,qBAAgD;CAC3D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;;;;;AAMA,SAAgB,yBAAyB,EACvC,MACA,SACA,UAAU,OACV,WAAW,OACX,aAOC;CACD,MAAM,WAAW,YAAY;CAC7B,OAAO,GACL,yGACA,cAAc,KAAK,CAAC,iBACpB,iCAAiC,OACjC,qBAAqB,OACrB,+BACA;EACE,uCAAuC,YAAY;EACnD,gDAAgD,YAAY;CAC9D,GACA,YACE,CAAC,YACD,CAAC,WACD,+CACF,CAAC,YACE,WACG,kFACA,8BACN,YACG,WACG,oHACA,yDACN,YAAY,6CACZ,SACF;AACF;;;;;AAMA,SAAgB,uBAAuB,EACrC,MACA,WAAW,OACX,aAKC;CACD,OAAO,GACL,2EACA,mBAAmB,OACnB,gCACA,YAAY,sBACZ,SACF;AACF;;AAGA,IAAa,oBAAoB"}
|
|
@@ -37,7 +37,7 @@ function PlainPane({ open, animation, onClose, children, dialogStyle, transparen
|
|
|
37
37
|
style: { zIndex: paneZIndex },
|
|
38
38
|
children: /* @__PURE__ */ jsx(RadixDialog.Content, {
|
|
39
39
|
ref: mergeRefs([scrollParentRef, setContentNode]),
|
|
40
|
-
className: cn("relative flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg", "focus:outline-
|
|
40
|
+
className: cn("relative flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg", "focus:outline-hidden focus-visible:outline-hidden", animation && "data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none"),
|
|
41
41
|
style: {
|
|
42
42
|
marginLeft: `${depth * 5}rem`,
|
|
43
43
|
marginRight: `var(--polly-chat-width, 0px)`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pane.js","names":[],"sources":["../../../src/components/Pane/Pane.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport { createContext, useContext, useState } from 'react';\n\nimport * as RadixDialog from '@radix-ui/react-dialog';\n\nimport { CaretDoubleRightIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ScrollParentProvider } from '../../utils/VirtuosoCustomScrollParentContext';\nimport {\n ScrollParentContext,\n useScrollParent,\n} from '../../utils/VirtuosoCustomScrollParentContext/useScrollParent';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { DialogContainerContext } from '../Dialog';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport UnsavedChangesDialog from '../UnsavedChangesDialog';\nimport { TopBarPaneSlot } from './Pane.utils';\n\nconst PaneDepth = createContext<number>(1);\n\ninterface CorePaneProps {\n open: boolean;\n animation?: boolean;\n onClose: () => void;\n children: ReactNode;\n dialogStyle?: CSSProperties;\n transparentBackdrop?: boolean;\n handleScroll?: (e: Event) => void;\n preventInteractOutside?: boolean;\n /** Escape pressed while the pane is open. preventDefault() keeps it open. */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n requireConfirmationOnClose?: boolean;\n zIndex?: number;\n}\n\nexport interface PaneProps extends CorePaneProps {\n title: string;\n description?: ReactNode;\n noBackArrow?: boolean;\n className?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n topBarRightElement?: ReactNode;\n onBack?: () => void;\n scrollRef?: React.RefObject<HTMLDivElement | null>;\n}\n\nfunction PlainPane({\n open,\n animation,\n onClose,\n children,\n dialogStyle,\n transparentBackdrop,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: CorePaneProps) {\n const depth = useContext(PaneDepth);\n const scrollParentRef = useScrollParent();\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n const paneZIndex = useZIndex(zIndex ?? zIndices.pane);\n\n const handleRequestClose = () => {\n if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n return (\n <>\n <RadixDialog.Root\n open={open}\n onOpenChange={(o) => {\n if (!o) handleRequestClose();\n }}\n >\n <RadixDialog.Portal>\n <RadixDialog.Overlay\n data-pane-interaction-boundary\n className={cn(\n 'fixed inset-0 bg-overlay',\n animation &&\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n transparentBackdrop ? 'bg-transparent' : ''\n )}\n style={{\n zIndex: paneZIndex,\n }}\n >\n <RadixDialog.Content\n ref={mergeRefs([scrollParentRef, setContentNode])}\n className={cn(\n 'relative flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg',\n 'focus:outline-none focus-visible:outline-none',\n animation &&\n 'data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none'\n )}\n style={{\n marginLeft: `${depth * 5.0}rem`,\n marginRight: `var(--polly-chat-width, 0px)`,\n ...dialogStyle,\n }}\n onScroll={(e) => handleScroll?.(e.nativeEvent)}\n onOpenAutoFocus={(e) => {\n e.preventDefault();\n const target = e.currentTarget as HTMLDivElement;\n if (target) {\n target.focus();\n }\n }}\n onEscapeKeyDown={(e) => {\n onEscapeKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (requireConfirmationOnClose) {\n e.preventDefault();\n setShowConfirmModal(true);\n }\n }}\n onPointerDownOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n onInteractOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n >\n <ZIndexProvider value={paneZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n <TopBarPaneSlot.Context>\n <PaneDepth.Provider value={depth + 1}>\n {children}\n </PaneDepth.Provider>\n </TopBarPaneSlot.Context>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialog.Content>\n </RadixDialog.Overlay>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n </>\n );\n}\n\nexport function Pane({\n open,\n animation = true,\n onClose,\n onBack,\n title,\n description,\n children,\n className,\n noBackArrow,\n headerClassName,\n titleClassName,\n descriptionClassName,\n topBarRightElement,\n dialogStyle,\n transparentBackdrop,\n scrollRef,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: PaneProps) {\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n\n const handleCloseClick = () => {\n if (onBack) {\n onBack();\n } else if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n const paneComponent = (\n <>\n <PlainPane\n open={open}\n animation={animation}\n onClose={onClose}\n dialogStyle={dialogStyle}\n transparentBackdrop={transparentBackdrop}\n handleScroll={handleScroll}\n preventInteractOutside={preventInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n requireConfirmationOnClose={requireConfirmationOnClose}\n zIndex={zIndex}\n >\n <header\n className={cn(\n 'sticky top-0 flex items-center gap-space-1 border-b border-b-subtle bg-elevated py-1.5 pl-[10px] pr-space-4',\n headerClassName\n )}\n data-testid={`pane-header-${title}`}\n style={{ zIndex: zIndices.paneHeader }}\n >\n {!noBackArrow && (\n <IconButton\n label=\"Close\"\n icon={CaretDoubleRightIcon}\n onClick={handleCloseClick}\n variant=\"plain\"\n size=\"sm\"\n iconClassName=\"size-5 text-quaternary\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n <RadixDialog.Title asChild>\n <Text\n as=\"h2\"\n variant=\"h3\"\n color=\"secondary\"\n className={cn('min-w-0', titleClassName)}\n >\n {title}\n </Text>\n </RadixDialog.Title>\n {description && (\n <RadixDialog.Description asChild>\n <Text\n as=\"p\"\n variant=\"sm\"\n color=\"tertiary\"\n className={descriptionClassName}\n >\n {description}\n </Text>\n </RadixDialog.Description>\n )}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end gap-space-2\">\n {topBarRightElement}\n <TopBarPaneSlot.Slot className=\"flex items-center gap-space-2 empty:hidden\" />\n </div>\n </header>\n <div\n className={cn(\n 'flex-1 pb-space-8 pl-space-7 pr-space-4 pt-space-4',\n className\n )}\n >\n {children}\n </div>\n </PlainPane>\n {!onBack && (\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n )}\n </>\n );\n return scrollRef ? (\n <ScrollParentContext.Provider value={scrollRef}>\n {paneComponent}\n </ScrollParentContext.Provider>\n ) : (\n <ScrollParentProvider>{paneComponent}</ScrollParentProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,YAAY,cAAsB,CAAC;AA8BzC,SAAS,UAAU,EACjB,MACA,WACA,SACA,UACA,aACA,qBACA,cACA,wBACA,iBACA,4BACA,UACgB;CAChB,MAAM,QAAQ,WAAW,SAAS;CAClC,MAAM,kBAAkB,gBAAgB;CACxC,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAC9D,MAAM,CAAC,aAAa,kBAAkB,SAAgC,IAAI;CAC1E,MAAM,aAAa,UAAU,UAAU,SAAS,IAAI;CAEpD,MAAM,2BAA2B;EAC/B,IAAI,4BACF,oBAAoB,IAAI;OAExB,QAAQ;CAEZ;CAEA,O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CAAA,CACI;CACV,CAAA,GAAA,CAAC,UACA,oBAAC,sBAAD;EACE,QAAQ;EACR,eAAe,oBAAoB,KAAK;EACxC,iBAAiB;GACf,oBAAoB,KAAK;GACzB,QAAQ;EACV;EACA,OAAM;EACN,aAAY;EACZ,aAAY;CACb,CAAA,CAEH,EAAA,CAAA;CAEJ,OAAO,YACL,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAClC,UAAA;CAC2B,CAAA,IAE9B,oBAAC,sBAAD,EAAA,UAAuB,cAAoC,CAAA;AAE/D"}
|
|
1
|
+
{"version":3,"file":"Pane.js","names":[],"sources":["../../../src/components/Pane/Pane.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\nimport { createContext, useContext, useState } from 'react';\n\nimport * as RadixDialog from '@radix-ui/react-dialog';\n\nimport { CaretDoubleRightIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ScrollParentProvider } from '../../utils/VirtuosoCustomScrollParentContext';\nimport {\n ScrollParentContext,\n useScrollParent,\n} from '../../utils/VirtuosoCustomScrollParentContext/useScrollParent';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { DialogContainerContext } from '../Dialog';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\nimport UnsavedChangesDialog from '../UnsavedChangesDialog';\nimport { TopBarPaneSlot } from './Pane.utils';\n\nconst PaneDepth = createContext<number>(1);\n\ninterface CorePaneProps {\n open: boolean;\n animation?: boolean;\n onClose: () => void;\n children: ReactNode;\n dialogStyle?: CSSProperties;\n transparentBackdrop?: boolean;\n handleScroll?: (e: Event) => void;\n preventInteractOutside?: boolean;\n /** Escape pressed while the pane is open. preventDefault() keeps it open. */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n requireConfirmationOnClose?: boolean;\n zIndex?: number;\n}\n\nexport interface PaneProps extends CorePaneProps {\n title: string;\n description?: ReactNode;\n noBackArrow?: boolean;\n className?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n topBarRightElement?: ReactNode;\n onBack?: () => void;\n scrollRef?: React.RefObject<HTMLDivElement | null>;\n}\n\nfunction PlainPane({\n open,\n animation,\n onClose,\n children,\n dialogStyle,\n transparentBackdrop,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: CorePaneProps) {\n const depth = useContext(PaneDepth);\n const scrollParentRef = useScrollParent();\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n const paneZIndex = useZIndex(zIndex ?? zIndices.pane);\n\n const handleRequestClose = () => {\n if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n return (\n <>\n <RadixDialog.Root\n open={open}\n onOpenChange={(o) => {\n if (!o) handleRequestClose();\n }}\n >\n <RadixDialog.Portal>\n <RadixDialog.Overlay\n data-pane-interaction-boundary\n className={cn(\n 'fixed inset-0 bg-overlay',\n animation &&\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n transparentBackdrop ? 'bg-transparent' : ''\n )}\n style={{\n zIndex: paneZIndex,\n }}\n >\n <RadixDialog.Content\n ref={mergeRefs([scrollParentRef, setContentNode])}\n className={cn(\n 'relative flex h-[100vh] flex-col items-stretch overflow-y-auto bg-elevated shadow-lg',\n 'focus:outline-hidden focus-visible:outline-hidden',\n animation &&\n 'data-[state=open]:animate-slide-left data-[state=closed]:animate-slide-right motion-reduce:animate-none'\n )}\n style={{\n marginLeft: `${depth * 5.0}rem`,\n marginRight: `var(--polly-chat-width, 0px)`,\n ...dialogStyle,\n }}\n onScroll={(e) => handleScroll?.(e.nativeEvent)}\n onOpenAutoFocus={(e) => {\n e.preventDefault();\n const target = e.currentTarget as HTMLDivElement;\n if (target) {\n target.focus();\n }\n }}\n onEscapeKeyDown={(e) => {\n onEscapeKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (requireConfirmationOnClose) {\n e.preventDefault();\n setShowConfirmModal(true);\n }\n }}\n onPointerDownOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n onInteractOutside={\n preventInteractOutside\n ? (e) => {\n e.preventDefault();\n }\n : undefined\n }\n >\n <ZIndexProvider value={paneZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n <TopBarPaneSlot.Context>\n <PaneDepth.Provider value={depth + 1}>\n {children}\n </PaneDepth.Provider>\n </TopBarPaneSlot.Context>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialog.Content>\n </RadixDialog.Overlay>\n </RadixDialog.Portal>\n </RadixDialog.Root>\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n </>\n );\n}\n\nexport function Pane({\n open,\n animation = true,\n onClose,\n onBack,\n title,\n description,\n children,\n className,\n noBackArrow,\n headerClassName,\n titleClassName,\n descriptionClassName,\n topBarRightElement,\n dialogStyle,\n transparentBackdrop,\n scrollRef,\n handleScroll,\n preventInteractOutside,\n onEscapeKeyDown,\n requireConfirmationOnClose,\n zIndex,\n}: PaneProps) {\n const [showConfirmModal, setShowConfirmModal] = useState(false);\n\n const handleCloseClick = () => {\n if (onBack) {\n onBack();\n } else if (requireConfirmationOnClose) {\n setShowConfirmModal(true);\n } else {\n onClose();\n }\n };\n\n const paneComponent = (\n <>\n <PlainPane\n open={open}\n animation={animation}\n onClose={onClose}\n dialogStyle={dialogStyle}\n transparentBackdrop={transparentBackdrop}\n handleScroll={handleScroll}\n preventInteractOutside={preventInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n requireConfirmationOnClose={requireConfirmationOnClose}\n zIndex={zIndex}\n >\n <header\n className={cn(\n 'sticky top-0 flex items-center gap-space-1 border-b border-b-subtle bg-elevated py-1.5 pl-[10px] pr-space-4',\n headerClassName\n )}\n data-testid={`pane-header-${title}`}\n style={{ zIndex: zIndices.paneHeader }}\n >\n {!noBackArrow && (\n <IconButton\n label=\"Close\"\n icon={CaretDoubleRightIcon}\n onClick={handleCloseClick}\n variant=\"plain\"\n size=\"sm\"\n iconClassName=\"size-5 text-quaternary\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n <RadixDialog.Title asChild>\n <Text\n as=\"h2\"\n variant=\"h3\"\n color=\"secondary\"\n className={cn('min-w-0', titleClassName)}\n >\n {title}\n </Text>\n </RadixDialog.Title>\n {description && (\n <RadixDialog.Description asChild>\n <Text\n as=\"p\"\n variant=\"sm\"\n color=\"tertiary\"\n className={descriptionClassName}\n >\n {description}\n </Text>\n </RadixDialog.Description>\n )}\n </div>\n <div className=\"flex min-w-0 flex-1 items-center justify-end gap-space-2\">\n {topBarRightElement}\n <TopBarPaneSlot.Slot className=\"flex items-center gap-space-2 empty:hidden\" />\n </div>\n </header>\n <div\n className={cn(\n 'flex-1 pb-space-8 pl-space-7 pr-space-4 pt-space-4',\n className\n )}\n >\n {children}\n </div>\n </PlainPane>\n {!onBack && (\n <UnsavedChangesDialog\n isOpen={showConfirmModal}\n onClose={() => setShowConfirmModal(false)}\n onDiscard={() => {\n setShowConfirmModal(false);\n onClose();\n }}\n title=\"Unsaved Changes\"\n description=\"You may have unsaved changes. Are you sure you want to exit?\"\n discardCopy=\"Exit\"\n />\n )}\n </>\n );\n return scrollRef ? (\n <ScrollParentContext.Provider value={scrollRef}>\n {paneComponent}\n </ScrollParentContext.Provider>\n ) : (\n <ScrollParentProvider>{paneComponent}</ScrollParentProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,YAAY,cAAsB,CAAC;AA8BzC,SAAS,UAAU,EACj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AAA,GAClB,eACC,oBAAC,YAAY,aAAb;MAAyB,SAAA;MACvB,UAAA,oBAAC,MAAD;OACE,IAAG;OACH,SAAQ;OACR,OAAM;OACN,WAAW;OAEV,UAAA;MACG,CAAA;KACiB,CAAA,CAExB;;IACL,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,oBACD,oBAAC,eAAe,MAAhB,EAAqB,WAAU,6CAA8C,CAAA,CAC1E;;GACC;EACR,CAAA,GAAA,oBAAC,OAAD;GACE,WAAW,GACT,sDACA,SACF;GAEC;EACE,CAAA,CACI;CACV,CAAA,GAAA,CAAC,UACA,oBAAC,sBAAD;EACE,QAAQ;EACR,eAAe,oBAAoB,KAAK;EACxC,iBAAiB;GACf,oBAAoB,KAAK;GACzB,QAAQ;EACV;EACA,OAAM;EACN,aAAY;EACZ,aAAY;CACb,CAAA,CAEH,EAAA,CAAA;CAEJ,OAAO,YACL,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAClC,UAAA;CAC2B,CAAA,IAE9B,oBAAC,sBAAD,EAAA,UAAuB,cAAoC,CAAA;AAE/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const popoverSurfaceClassName = "w-72 rounded-md bg-popover p-space-4 outline-
|
|
1
|
+
export declare const popoverSurfaceClassName = "w-72 rounded-md bg-popover p-space-4 outline-hidden [filter:drop-shadow(0_1px_0_var(--border-secondary))_drop-shadow(0_-1px_0_var(--border-secondary))_drop-shadow(1px_0_0_var(--border-secondary))_drop-shadow(-1px_0_0_var(--border-secondary))_drop-shadow(0_2px_3px_var(--shadow-color-subtle))_drop-shadow(0_6px_12px_var(--shadow-color-subtle))]";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region packages/components/src/components/Popover/constants.ts
|
|
2
|
-
var popoverSurfaceClassName = "w-72 rounded-md bg-popover p-space-4 outline-
|
|
2
|
+
var popoverSurfaceClassName = "w-72 rounded-md bg-popover p-space-4 outline-hidden [filter:drop-shadow(0_1px_0_var(--border-secondary))_drop-shadow(0_-1px_0_var(--border-secondary))_drop-shadow(1px_0_0_var(--border-secondary))_drop-shadow(-1px_0_0_var(--border-secondary))_drop-shadow(0_2px_3px_var(--shadow-color-subtle))_drop-shadow(0_6px_12px_var(--shadow-color-subtle))]";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { popoverSurfaceClassName };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/Popover/constants.ts"],"sourcesContent":["export const popoverSurfaceClassName =\n 'w-72 rounded-md bg-popover p-space-4 outline-
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/Popover/constants.ts"],"sourcesContent":["export const popoverSurfaceClassName =\n 'w-72 rounded-md bg-popover p-space-4 outline-hidden [filter:drop-shadow(0_1px_0_var(--border-secondary))_drop-shadow(0_-1px_0_var(--border-secondary))_drop-shadow(1px_0_0_var(--border-secondary))_drop-shadow(-1px_0_0_var(--border-secondary))_drop-shadow(0_2px_3px_var(--shadow-color-subtle))_drop-shadow(0_6px_12px_var(--shadow-color-subtle))]';\n"],"mappings":";AAAA,IAAa,0BACX"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** Base styles applied to all radio buttons */
|
|
6
6
|
export declare const radioButtonBaseStyles = "flex shrink-0 items-center justify-center rounded-full border bg-elevated transition-colors";
|
|
7
7
|
/** Focus ring styles: brand border + shadow haze */
|
|
8
|
-
export declare const radioButtonFocusStyles = "focus-visible:border-brand focus-visible:outline-
|
|
8
|
+
export declare const radioButtonFocusStyles = "focus-visible:border-brand focus-visible:outline-hidden focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)]";
|
|
9
9
|
/** Size variant styles for the radio button */
|
|
10
10
|
export declare const radioButtonSizeStyles: {
|
|
11
11
|
readonly sm: "size-4";
|
|
@@ -7,7 +7,7 @@ import { SELECTION_CONTROL_SIZES } from "../../utils/componentSizes.js";
|
|
|
7
7
|
/** Base styles applied to all radio buttons */
|
|
8
8
|
var radioButtonBaseStyles = "flex shrink-0 items-center justify-center rounded-full border bg-elevated transition-colors";
|
|
9
9
|
/** Focus ring styles: brand border + shadow haze */
|
|
10
|
-
var radioButtonFocusStyles = "focus-visible:border-brand focus-visible:outline-
|
|
10
|
+
var radioButtonFocusStyles = "focus-visible:border-brand focus-visible:outline-hidden focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)]";
|
|
11
11
|
/** Size variant styles for the radio button */
|
|
12
12
|
var radioButtonSizeStyles = {
|
|
13
13
|
sm: SELECTION_CONTROL_SIZES.sm.className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/RadioButton/constants.ts"],"sourcesContent":["import {\n SELECTION_CONTROL_SIZES,\n type SelectionControlSize,\n} from '../../utils/componentSizes';\n\n/**\n * RadioButton style constants following the Button pattern.\n * Styles are organized by category for maintainability.\n */\n\n/** Base styles applied to all radio buttons */\nexport const radioButtonBaseStyles =\n 'flex shrink-0 items-center justify-center rounded-full border bg-elevated transition-colors';\n\n/** Focus ring styles: brand border + shadow haze */\nexport const radioButtonFocusStyles =\n 'focus-visible:border-brand focus-visible:outline-
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/RadioButton/constants.ts"],"sourcesContent":["import {\n SELECTION_CONTROL_SIZES,\n type SelectionControlSize,\n} from '../../utils/componentSizes';\n\n/**\n * RadioButton style constants following the Button pattern.\n * Styles are organized by category for maintainability.\n */\n\n/** Base styles applied to all radio buttons */\nexport const radioButtonBaseStyles =\n 'flex shrink-0 items-center justify-center rounded-full border bg-elevated transition-colors';\n\n/** Focus ring styles: brand border + shadow haze */\nexport const radioButtonFocusStyles =\n 'focus-visible:border-brand focus-visible:outline-hidden focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)]';\n\n/** Size variant styles for the radio button */\nexport const radioButtonSizeStyles = {\n sm: SELECTION_CONTROL_SIZES.sm.className,\n md: SELECTION_CONTROL_SIZES.md.className,\n} as const satisfies Record<SelectionControlSize, string>;\n\n/** Size variant styles for the indicator dot */\nexport const radioButtonDotSizeStyles = {\n sm: 'size-1.5',\n md: 'size-2',\n} as const satisfies Record<SelectionControlSize, string>;\n\n/**\n * State styles using Radix data attributes.\n * These are combined and applied via cn() in the component.\n */\nconst radioButtonStateStyles = {\n // Default border (unchecked state)\n default: 'border-default',\n\n // Unchecked hover - slight background change\n uncheckedHover: 'data-[state=unchecked]:hover:bg-elevated-hover',\n\n // Checked state - filled with brand color\n checked:\n 'data-[state=checked]:border-transparent data-[state=checked]:bg-control-active hover:data-[state=checked]:bg-control-active-hover',\n\n // Disabled base - applies to all states when disabled\n disabledBase:\n 'data-[disabled]:cursor-not-allowed data-[disabled]:border-disabled data-[disabled]:bg-disabled',\n\n // Disabled unchecked - override hover effects\n disabledUnchecked:\n 'data-[disabled]:data-[state=unchecked]:hover:border-disabled data-[disabled]:data-[state=unchecked]:hover:shadow-none data-[disabled]:hover:bg-disabled data-[state=unchecked]:hover:bg-disabled',\n\n // Disabled checked - override hover effects\n disabledChecked:\n 'data-[disabled]:data-[state=checked]:border-disabled data-[disabled]:data-[state=checked]:bg-disabled data-[disabled]:data-[state=checked]:hover:bg-disabled',\n} as const;\n\n/**\n * Indicator dot styles. The disabled fill is applied via Radix's `data-disabled`\n * attribute, which is set on the Indicator whenever the radio button or its\n * enclosing group is disabled — so it covers both item-level and group-level\n * disabled states, not just the local `disabled` prop.\n */\nexport const radioButtonIndicatorStyles =\n 'bg-control-thumb data-[disabled]:bg-control-disabled';\n\n/**\n * Combined radio button root styles - convenience export for component use.\n * All state styles combined as an array to be spread in cn().\n */\nexport const radioButtonRootStateStyles = [\n radioButtonStateStyles.default,\n radioButtonStateStyles.uncheckedHover,\n radioButtonStateStyles.checked,\n radioButtonStateStyles.disabledBase,\n radioButtonStateStyles.disabledUnchecked,\n radioButtonStateStyles.disabledChecked,\n] as const;\n"],"mappings":";;;;;;;AAWA,IAAa,wBACX;;AAGF,IAAa,yBACX;;AAGF,IAAa,wBAAwB;CACnC,IAAI,wBAAwB,GAAG;CAC/B,IAAI,wBAAwB,GAAG;AACjC;;AAGA,IAAa,2BAA2B;CACtC,IAAI;CACJ,IAAI;AACN;;;;;AAMA,IAAM,yBAAyB;CAE7B,SAAS;CAGT,gBAAgB;CAGhB,SACE;CAGF,cACE;CAGF,mBACE;CAGF,iBACE;AACJ;;;;;;;AAQA,IAAa,6BACX;;;;;AAMF,IAAa,6BAA6B;CACxC,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;AACzB"}
|
|
@@ -7,7 +7,7 @@ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
|
7
7
|
var RadioGroupItem = React$1.forwardRef(({ className, ...props }, ref) => {
|
|
8
8
|
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Item, {
|
|
9
9
|
ref,
|
|
10
|
-
className: cn("flex items-start justify-end gap-space-3 self-stretch rounded-full border border-subtle bg-surface-level-1 p-space-3 transition-colors data-[disabled]:cursor-not-allowed data-[disabled]:border-disabled data-[disabled]:bg-disabled data-[disabled]:data-[state=checked]:bg-disabled data-[state=checked]:bg-brand data-[state=checked]:p-space-2", "focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)] focus-visible:outline-
|
|
10
|
+
className: cn("flex items-start justify-end gap-space-3 self-stretch rounded-full border border-subtle bg-surface-level-1 p-space-3 transition-colors data-[disabled]:cursor-not-allowed data-[disabled]:border-disabled data-[disabled]:bg-disabled data-[disabled]:data-[state=checked]:bg-disabled data-[state=checked]:bg-brand data-[state=checked]:p-space-2", "focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)] focus-visible:outline-hidden", SELECTION_CONTROL_HIT_AREA_STYLES, className),
|
|
11
11
|
...props,
|
|
12
12
|
children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, {
|
|
13
13
|
className: "group flex items-center justify-center",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroupItem.js","names":[],"sources":["../../../src/components/RadioGroup/RadioGroupItem.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\n\nimport { cn } from '../../utils/cn';\nimport { SELECTION_CONTROL_HIT_AREA_STYLES } from '../../utils/componentSizes';\n\nexport type RadioGroupItemProps = React.ComponentPropsWithoutRef<\n typeof RadioGroupPrimitive.Item\n>;\n\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n RadioGroupItemProps\n>(({ className, ...props }, ref) => {\n return (\n <RadioGroupPrimitive.Item\n ref={ref}\n className={cn(\n 'flex items-start justify-end gap-space-3 self-stretch rounded-full border border-subtle bg-surface-level-1 p-space-3 transition-colors data-[disabled]:cursor-not-allowed data-[disabled]:border-disabled data-[disabled]:bg-disabled data-[disabled]:data-[state=checked]:bg-disabled data-[state=checked]:bg-brand data-[state=checked]:p-space-2',\n 'focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)] focus-visible:outline-
|
|
1
|
+
{"version":3,"file":"RadioGroupItem.js","names":[],"sources":["../../../src/components/RadioGroup/RadioGroupItem.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\n\nimport { cn } from '../../utils/cn';\nimport { SELECTION_CONTROL_HIT_AREA_STYLES } from '../../utils/componentSizes';\n\nexport type RadioGroupItemProps = React.ComponentPropsWithoutRef<\n typeof RadioGroupPrimitive.Item\n>;\n\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n RadioGroupItemProps\n>(({ className, ...props }, ref) => {\n return (\n <RadioGroupPrimitive.Item\n ref={ref}\n className={cn(\n 'flex items-start justify-end gap-space-3 self-stretch rounded-full border border-subtle bg-surface-level-1 p-space-3 transition-colors data-[disabled]:cursor-not-allowed data-[disabled]:border-disabled data-[disabled]:bg-disabled data-[disabled]:data-[state=checked]:bg-disabled data-[state=checked]:bg-brand data-[state=checked]:p-space-2',\n 'focus-visible:shadow-[0_0_0_4px_var(--bg-brand-subtle)] focus-visible:outline-hidden',\n SELECTION_CONTROL_HIT_AREA_STYLES,\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator className=\"group flex items-center justify-center\">\n <div className=\"size-2 rounded-full bg-control-thumb group-data-[disabled]:bg-control-disabled\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n );\n});\nRadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;\n\nexport { RadioGroupItem };\n"],"mappings":";;;;;;AAWA,IAAM,iBAAiB,QAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,oBAAC,oBAAoB,MAArB;EACO;EACL,WAAW,GACT,uVACA,wFACA,mCACA,SACF;EACA,GAAI;EAEJ,UAAA,oBAAC,oBAAoB,WAArB;GAA+B,WAAU;GACvC,UAAA,oBAAC,OAAD,EAAK,WAAU,iFAAkF,CAAA;EACpE,CAAA;CACP,CAAA;AAE9B,CAAC;AACD,eAAe,cAAc,oBAAoB,KAAK"}
|