@langchain/macaw-components 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.css +5 -5
- package/dist/catalog.json +535 -480
- package/dist/components/Accordion/Accordion.d.ts +63 -0
- package/dist/components/Accordion/Accordion.js +170 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Attachment/Attachment.js +3 -3
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Banner/Banner.js +2 -2
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/constants.js +2 -2
- package/dist/components/Button/constants.js.map +1 -1
- package/dist/components/ChartCard/ChartCard.js +2 -2
- package/dist/components/ChartLegend/ChartLegend.js +1 -1
- package/dist/components/ChartTooltip/ChartTooltip.js +2 -2
- package/dist/components/ChartTooltip/ChartTooltip.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Code/CodeLite.js +2 -2
- 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 +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +3 -2
- package/dist/components/CopyButton/CopyButton.js +7 -2
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/Dialog/index.d.ts +3 -2
- package/dist/components/Dialog/index.js +47 -20
- package/dist/components/Dialog/index.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/ErrorMessage/ErrorMessage.js +3 -3
- package/dist/components/GroupedTabs/GroupedTabs.d.ts +3 -2
- package/dist/components/GroupedTabs/GroupedTabs.js +3 -1
- package/dist/components/GroupedTabs/GroupedTabs.js.map +1 -1
- package/dist/components/IconButton/IconButton.js +2 -2
- package/dist/components/Input/Input.js +8 -7
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/inputStyles.js +4 -4
- package/dist/components/Input/inputStyles.js.map +1 -1
- package/dist/components/Link/Link.js +3 -3
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/Pane/Pane.d.ts +3 -2
- package/dist/components/Pane/Pane.js +109 -103
- package/dist/components/Pane/Pane.js.map +1 -1
- package/dist/components/Popover/Popover.js +15 -4
- package/dist/components/Popover/Popover.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/Select/Select.d.ts +10 -1
- package/dist/components/Select/Select.js +7 -5
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectPrimitive.js +6 -4
- package/dist/components/Select/SelectPrimitive.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/SplitViewPane/SplitViewPaneHeader.js +2 -2
- package/dist/components/StatusBadge/StatusBadge.d.ts +27 -0
- package/dist/components/StatusBadge/StatusBadge.js +42 -0
- package/dist/components/StatusBadge/StatusBadge.js.map +1 -0
- package/dist/components/StatusBadge/index.d.ts +2 -0
- package/dist/components/StatusBadge/index.js +2 -0
- package/dist/components/Tabs/index.d.ts +3 -2
- package/dist/components/Tabs/index.js +3 -1
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/Textarea.js +8 -8
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Toast/index.js +3 -3
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Typeahead/TypeaheadParts.js +2 -2
- package/dist/components/Typeahead/TypeaheadView.js +10 -10
- package/dist/components/Typeahead/TypeaheadView.js.map +1 -1
- package/dist/components/UnsavedChangesDialog.js +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +7 -6
- package/dist/icons/LongTailPhosphorIcons.js +1 -1
- package/dist/icons/PaddedPhosphorIcons.js +2 -2
- package/dist/index.js +7 -6
- package/dist/utilities.css +1 -1
- package/dist/utils/ModalLayerContext.d.ts +23 -0
- package/dist/utils/ModalLayerContext.js +92 -0
- package/dist/utils/ModalLayerContext.js.map +1 -0
- package/dist/utils/cn.js +4 -0
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/dataAttributes.d.ts +9 -0
- package/dist/utils/dataAttributes.js +13 -0
- package/dist/utils/dataAttributes.js.map +1 -0
- package/docs/DESIGN.md +21 -1
- package/docs/STYLES.md +84 -44
- package/package.json +20 -3
- package/tailwind.preset.cjs +11 -5
|
@@ -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-hidden
|
|
2
|
+
var popoverSurfaceClassName = "w-72 rounded-md border border-subtle bg-popover p-space-4 shadow-md outline-hidden dark:shadow-none";
|
|
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-hidden
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../src/components/Popover/constants.ts"],"sourcesContent":["export const popoverSurfaceClassName =\n 'w-72 rounded-md border border-subtle bg-popover p-space-4 shadow-md outline-hidden dark:shadow-none';\n"],"mappings":";AAAA,IAAa,0BACX"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { type ControlSize } from '../../utils/componentSizes.js';
|
|
3
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
3
4
|
export interface SelectOption<T extends string = string> {
|
|
4
5
|
/** The value used for selection and filtering */
|
|
5
6
|
value: T;
|
|
@@ -17,7 +18,8 @@ export interface SelectGroup<T extends string = string> {
|
|
|
17
18
|
options: SelectOption<T>[];
|
|
18
19
|
}
|
|
19
20
|
export type SelectSize = ControlSize;
|
|
20
|
-
|
|
21
|
+
export type SelectVariant = 'outlined' | 'plain';
|
|
22
|
+
interface SelectBaseProps<T extends string = string> extends DataAttributes {
|
|
21
23
|
/** The currently selected value */
|
|
22
24
|
value?: T;
|
|
23
25
|
/** Callback when selection changes. Receives undefined when deselected. */
|
|
@@ -50,6 +52,13 @@ interface SelectBaseProps<T extends string = string> {
|
|
|
50
52
|
endReachedThresholdPx?: number;
|
|
51
53
|
/** Additional class name for the trigger button */
|
|
52
54
|
triggerClassName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Trigger appearance. `outlined` (default) is a full-width form field.
|
|
57
|
+
* `plain` drops the field fill and border and sizes the trigger to its
|
|
58
|
+
* value, so it reads as text until hovered — for an inline setting in a row,
|
|
59
|
+
* such as a member's role, where a field box would crowd it.
|
|
60
|
+
*/
|
|
61
|
+
variant?: SelectVariant;
|
|
53
62
|
/** Additional class name for the popover content */
|
|
54
63
|
contentClassName?: string;
|
|
55
64
|
/** Custom render function for the selected value in the trigger */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CaretDownIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
3
|
import { CONTROL_SIZES } from "../../utils/componentSizes.js";
|
|
3
4
|
import { Text } from "../Text/Text.js";
|
|
4
5
|
import { Button } from "../Button/Button.js";
|
|
5
6
|
import { Icon } from "../Icon/Icon.js";
|
|
6
|
-
import {
|
|
7
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
7
8
|
import { Popover, PopoverContent, PopoverTrigger } from "../Popover/Popover.js";
|
|
8
9
|
import { CONTROL_ICON_SIZES } from "../../utils/controlIconSizes.js";
|
|
9
10
|
import { CommandMenu } from "../Command/CommandMenu.js";
|
|
@@ -20,7 +21,7 @@ function optionToItem(opt) {
|
|
|
20
21
|
keywords: opt.label ? [opt.label] : void 0
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
function OptionSelect({ value, onChange, options, groups, placeholder = "Select...", searchPlaceholder = "Search...", disabled = false, size = "sm", emptyText = "No results found.", open: controlledOpen, onOpenChange: controlledOnOpenChange, allowDeselect, hideSearch = true, disableFilter, onSearchChange, loading, loadingRows, onEndReached, endReachedThresholdPx, triggerClassName, contentClassName, renderValue, renderOption, side, align = "start", "aria-label": ariaLabel, "data-testid": dataTestId }) {
|
|
24
|
+
function OptionSelect({ value, onChange, options, groups, placeholder = "Select...", searchPlaceholder = "Search...", disabled = false, size = "sm", emptyText = "No results found.", open: controlledOpen, onOpenChange: controlledOnOpenChange, allowDeselect, hideSearch = true, disableFilter, onSearchChange, loading, loadingRows, onEndReached, endReachedThresholdPx, triggerClassName, variant = "outlined", contentClassName, renderValue, renderOption, side, align = "start", "aria-label": ariaLabel, "data-testid": dataTestId, ...rest }) {
|
|
24
25
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
25
26
|
const isControlled = controlledOpen !== void 0;
|
|
26
27
|
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
@@ -80,20 +81,21 @@ function OptionSelect({ value, onChange, options, groups, placeholder = "Select.
|
|
|
80
81
|
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
81
82
|
asChild: true,
|
|
82
83
|
children: /* @__PURE__ */ jsxs(Button, {
|
|
84
|
+
...pickDataAttributes(rest),
|
|
83
85
|
role: "combobox",
|
|
84
86
|
"aria-expanded": open,
|
|
85
87
|
"aria-label": ariaLabel ?? placeholder,
|
|
86
|
-
variant
|
|
88
|
+
variant,
|
|
87
89
|
color: "secondary",
|
|
88
90
|
size: triggerButtonSize,
|
|
89
|
-
className: cn("box-border
|
|
91
|
+
className: cn("box-border justify-between py-0", CONTROL_SIZES[size].heightClassName, variant === "plain" ? cn("w-auto max-w-full gap-space-1 px-space-1", disabled && "bg-disabled text-disabled dark:bg-disabled") : cn("w-full", disabled ? "border-muted bg-input-disabled text-disabled dark:bg-input-disabled" : "bg-input border-muted hover:border-subtle focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none"), triggerClassName),
|
|
90
92
|
disabled,
|
|
91
93
|
"data-testid": dataTestId,
|
|
92
94
|
children: [triggerContent, /* @__PURE__ */ jsx(Icon, {
|
|
93
95
|
"aria-hidden": true,
|
|
94
96
|
icon: CaretDownIcon,
|
|
95
97
|
iconClassName: CONTROL_ICON_SIZES[size].iconClassName,
|
|
96
|
-
className: "text-inherit",
|
|
98
|
+
className: disabled ? "text-icon-disabled" : "text-inherit",
|
|
97
99
|
weight: "regular"
|
|
98
100
|
})]
|
|
99
101
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\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 option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\ninterface SelectBaseProps<T extends string = string> {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: 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 /** 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 /** Additional class name for the trigger button */\n triggerClassName?: string;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant=\"outlined\"\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border w-full justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className=\"text-inherit\"\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;AA+GA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EACX,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,UAAU,IAAI;EACd,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAA;CACtC;AACF;AAEA,SAAS,aAAwC,EAC/C,OACA,UACA,SACA,QACA,cAAc,aACd,oBAAoB,aACpB,WAAW,OACX,OAAO,MACP,YAAY,qBACZ,MAAM,gBACN,cAAc,wBACd,eACA,aAAa,MACb,eACA,gBACA,SACA,aACA,cACA,uBACA,kBACA,kBACA,aACA,cACA,MACA,QAAQ,SACR,cAAc,WACd,eAAe,cACE;CACjB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAC9D,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,eAAe,iBAAiB;CAC7C,MAAM,UAAU,eAAe,yBAAyB;CAExD,MAAM,aAAa,cACV,SAAS,OAAO,SAAS,MAAM,EAAE,OAAO,IAAK,WAAW,CAAC,GAChE,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,iBAAiB,cACf,WAAW,MAAM,QAAQ,IAAI,UAAU,KAAK,GAClD,CAAC,YAAY,KAAK,CACpB;CAEA,MAAM,eAAe,aAClB,gBAAwB;EACvB,MAAM,QAAQ,WAAW,MAAM,MAAM,EAAE,UAAU,WAAW;EAC5D,IAAI,CAAC,OAAO;EACZ,IAAI,iBAAiB,MAAM,UAAU,OACnC,SAAS,KAAA,CAAS;OAElB,SAAS,MAAM,KAAK;EAEtB,QAAQ,KAAK;CACf,GACA;EAAC;EAAe;EAAO;EAAU;EAAS;CAAU,CACtD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gBACF;GACM;GACC;GAEN,UAAA,gBACC,oBAAC,aAAD;IAAa,QAAQ;IAAe,GAAI;GAAyB,CAAA,IAEjE,oBAAC,aAAD;IAAoB;IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { CaretDownIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n CONTROL_SIZES,\n type ControlSize,\n type OptionRowSize,\n} from '../../utils/componentSizes';\nimport { CONTROL_ICON_SIZES } from '../../utils/controlIconSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { CommandMenu } from '../Command/CommandMenu';\nimport type { CommandMenuGroup, CommandMenuItem } from '../Command/CommandMenu';\nimport { Icon } from '../Icon';\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover';\nimport { Text } from '../Text';\n\nexport interface SelectOption<T extends string = string> {\n /** The value used for selection and filtering */\n value: T;\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 option is disabled */\n disabled?: boolean;\n}\n\nexport interface SelectGroup<T extends string = string> {\n heading?: string;\n options: SelectOption<T>[];\n}\n\nexport type SelectSize = ControlSize;\n\nexport type SelectVariant = 'outlined' | 'plain';\n\ninterface SelectBaseProps<T extends string = string> extends DataAttributes {\n /** The currently selected value */\n value?: T;\n /** Callback when selection changes. Receives undefined when deselected. */\n onChange: (value: T | undefined) => void;\n /** Placeholder text when no value is selected */\n placeholder?: string;\n /** Placeholder text for the search input */\n searchPlaceholder?: string;\n /** Whether the select is disabled */\n disabled?: boolean;\n /** Exact trigger height: xs=20px, sm=24px, md=32px, lg=40px. */\n size?: SelectSize;\n /** Text to show when no options match the search */\n emptyText?: string;\n /** Allow deselecting the current value by clicking it again (default: false) */\n allowDeselect?: boolean;\n /** Hide the search input (default: true, search is hidden) */\n hideSearch?: 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 /** 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 /** Additional class name for the trigger button */\n triggerClassName?: string;\n /**\n * Trigger appearance. `outlined` (default) is a full-width form field.\n * `plain` drops the field fill and border and sizes the trigger to its\n * value, so it reads as text until hovered — for an inline setting in a row,\n * such as a member's role, where a field box would crowd it.\n */\n variant?: SelectVariant;\n /** Additional class name for the popover content */\n contentClassName?: string;\n /** Custom render function for the selected value in the trigger */\n renderValue?: (option: SelectOption<T>) => ReactNode;\n /** Custom render function for each option in the list */\n renderOption?: (option: SelectOption<T>, isSelected: boolean) => ReactNode;\n /** Side of the trigger to align the popover */\n side?: 'top' | 'bottom' | 'left' | 'right';\n /** Alignment of the popover relative to the trigger */\n align?: 'start' | 'center' | 'end';\n /** aria-label for the trigger button */\n 'aria-label'?: string;\n /** Test id for the trigger button */\n 'data-testid'?: string;\n}\n\nexport type SelectProps<T extends string = string> = SelectBaseProps<T> &\n (\n | {\n options: SelectOption<T>[];\n groups?: never;\n }\n | {\n groups: SelectGroup<T>[];\n options?: never;\n }\n ) &\n (\n | {\n /** Controlled open state */\n open: boolean;\n /** Callback when open state changes (required when `open` is provided) */\n onOpenChange: (open: boolean) => void;\n }\n | {\n open?: never;\n onOpenChange?: never;\n }\n );\n\nfunction optionToItem(opt: SelectOption): CommandMenuItem {\n return {\n value: opt.value,\n label: opt.label,\n description: opt.description,\n rightDecorator: opt.rightDecorator,\n disabled: opt.disabled,\n keywords: opt.label ? [opt.label] : undefined,\n };\n}\n\nfunction OptionSelect<T extends string = string>({\n value,\n onChange,\n options,\n groups,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n disabled = false,\n size = 'sm',\n emptyText = 'No results found.',\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n allowDeselect,\n hideSearch = true,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n triggerClassName,\n variant = 'outlined',\n contentClassName,\n renderValue,\n renderOption,\n side,\n align = 'start',\n 'aria-label': ariaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: SelectProps<T>) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const open = isControlled ? controlledOpen : uncontrolledOpen;\n const setOpen = isControlled ? controlledOnOpenChange : setUncontrolledOpen;\n\n const allOptions = useMemo<SelectOption<T>[]>(\n () => (groups ? groups.flatMap((g) => g.options) : (options ?? [])),\n [groups, options]\n );\n\n const selectedOption = useMemo(\n () => allOptions.find((opt) => opt.value === value),\n [allOptions, value]\n );\n\n const handleSelect = useCallback(\n (optionValue: string) => {\n const match = allOptions.find((o) => o.value === optionValue);\n if (!match) return;\n if (allowDeselect && match.value === value) {\n onChange(undefined);\n } else {\n onChange(match.value);\n }\n setOpen(false);\n },\n [allowDeselect, value, onChange, setOpen, allOptions]\n );\n\n const items: CommandMenuItem[] = useMemo(\n () => (options ?? []).map(optionToItem),\n [options]\n );\n\n const commandGroups: CommandMenuGroup[] | undefined = useMemo(\n () =>\n groups?.map((g) => ({\n heading: g.heading,\n items: g.options.map(optionToItem),\n })),\n [groups]\n );\n\n const renderItem = renderOption\n ? (item: CommandMenuItem, isSelected: boolean) => {\n const option = allOptions.find((o) => o.value === item.value);\n return option ? renderOption(option, isSelected) : null;\n }\n : undefined;\n const searchInputSize = size === 'xs' ? 'sm' : size === 'lg' ? 'md' : size;\n const triggerButtonSize = size === 'lg' ? 'md' : size;\n const itemRowSize: OptionRowSize =\n size === 'xs' || size === 'sm' ? 'sm' : 'md';\n\n const commandMenuSharedProps = {\n value,\n onSelect: handleSelect,\n placeholder: searchPlaceholder,\n emptyText,\n hideSearch,\n disableFilter,\n onSearchChange,\n loading,\n loadingRows,\n onEndReached,\n endReachedThresholdPx,\n renderItem,\n inputSize: searchInputSize,\n itemRowSize,\n };\n\n const triggerContent =\n selectedOption && renderValue ? (\n renderValue(selectedOption)\n ) : (\n <Text\n as=\"span\"\n variant={triggerButtonSize}\n weight=\"normal\"\n className=\"min-w-0 truncate text-left\"\n >\n {selectedOption\n ? (selectedOption.label ?? selectedOption.value)\n : placeholder}\n </Text>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n {...pickDataAttributes(rest)}\n role=\"combobox\"\n aria-expanded={open}\n aria-label={ariaLabel ?? placeholder}\n variant={variant}\n color=\"secondary\"\n size={triggerButtonSize}\n className={cn(\n 'box-border justify-between py-0',\n CONTROL_SIZES[size].heightClassName,\n variant === 'plain'\n ? cn(\n 'w-auto max-w-full gap-space-1 px-space-1',\n // The shared disabled fill, in both themes.\n disabled && 'bg-disabled text-disabled dark:bg-disabled'\n )\n : cn(\n 'w-full',\n disabled\n ? 'border-muted bg-input-disabled text-disabled dark:bg-input-disabled'\n : 'bg-input border-muted hover:border-subtle focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none'\n ),\n triggerClassName\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {triggerContent}\n <Icon\n aria-hidden\n icon={CaretDownIcon}\n iconClassName={CONTROL_ICON_SIZES[size].iconClassName}\n className={disabled ? 'text-icon-disabled' : 'text-inherit'}\n weight=\"regular\"\n />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn(\n 'w-max min-w-[var(--radix-popover-trigger-width)] max-w-[min(24rem,calc(100vw-1rem))] p-0 text-primary',\n contentClassName\n )}\n side={side}\n align={align}\n >\n {commandGroups ? (\n <CommandMenu groups={commandGroups} {...commandMenuSharedProps} />\n ) : (\n <CommandMenu items={items} {...commandMenuSharedProps} />\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function Select<T extends string = string>(\n props: SelectProps<T>\n): React.ReactElement<unknown> {\n return <OptionSelect {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;AA4HA,SAAS,aAAa,KAAoC;CACxD,OAAO;EACL,OAAO,IAAI;EACX,OAAO,IAAI;EACX,aAAa,IAAI;EACjB,gBAAgB,IAAI;EACpB,UAAU,IAAI;EACd,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,KAAA;CACtC;AACF;AAEA,SAAS,aAAwC,EAC/C,OACA,UACA,SACA,QACA,cAAc,aACd,oBAAoB,aACpB,WAAW,OACX,OAAO,MACP,YAAY,qBACZ,MAAM,gBACN,cAAc,wBACd,eACA,aAAa,MACb,eACA,gBACA,SACA,aACA,cACA,uBACA,kBACA,UAAU,YACV,kBACA,aACA,cACA,MACA,QAAQ,SACR,cAAc,WACd,eAAe,YACf,GAAG,QACc;CACjB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAC9D,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,eAAe,iBAAiB;CAC7C,MAAM,UAAU,eAAe,yBAAyB;CAExD,MAAM,aAAa,cACV,SAAS,OAAO,SAAS,MAAM,EAAE,OAAO,IAAK,WAAW,CAAC,GAChE,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,iBAAiB,cACf,WAAW,MAAM,QAAQ,IAAI,UAAU,KAAK,GAClD,CAAC,YAAY,KAAK,CACpB;CAEA,MAAM,eAAe,aAClB,gBAAwB;EACvB,MAAM,QAAQ,WAAW,MAA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KAAK,CAAC,iBACpB,YAAY,UACR,GACE,4CAEA,YAAY,4CACd,IACA,GACE,UACA,WACI,wEACA,sJACN,GACJ,gBACF;IACU;IACV,eAAa;IA1Bf,UAAA,CA4BG,gBACD,oBAAC,MAAD;KACE,eAAA;KACA,MAAM;KACN,eAAe,mBAAmB,KAAK,CAAC;KACxC,WAAW,WAAW,uBAAuB;KAC7C,QAAO;IACR,CAAA,CACK;;EACM,CAAA,GAChB,oBAAC,gBAAD;GACE,WAAW,GACT,yGACA,gBACF;GACM;GACC;GAEN,UAAA,gBACC,oBAAC,aAAD;IAAa,QAAQ;IAAe,GAAI;GAAyB,CAAA,IAEjE,oBAAC,aAAD;IAAoB;IAAO,GAAI;GAAyB,CAAA;EAE5C,CAAA,CACT;;AAEb;AAEA,SAAgB,OACd,OAC6B;CAC7B,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { CaretDownIcon, CaretUpIcon, CheckIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
3
|
import { OPTION_ROW_SIZES } from "../../utils/componentSizes.js";
|
|
3
4
|
import zIndices from "../../utils/zIndices.js";
|
|
4
5
|
import { useZIndex } from "../../utils/useZIndex.js";
|
|
5
6
|
import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
6
|
-
import { CaretDownIcon, CaretUpIcon, CheckIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
7
7
|
import * as React$1 from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
@@ -23,15 +23,17 @@ var SelectRoot = (props) => {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
var SelectTrigger = React$1.forwardRef(({ className, children, iconClassName, ...props }, ref) => {
|
|
26
|
+
const isError = props["aria-invalid"] === true || props["aria-invalid"] === "true";
|
|
27
|
+
const triggerStateStyles = !props.disabled && (isError ? "border-error-strong focus-visible:border-error-strong focus-visible:shadow-[0_0_0_1px_var(--border-error-strong)] focus-visible:outline-none" : "[&:enabled:hover:not(:focus-visible)]:border-subtle focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none");
|
|
26
28
|
if (props.asChild) return /* @__PURE__ */ jsx(RadixSelect.Trigger, {
|
|
27
29
|
ref,
|
|
28
|
-
className: cn("flex items-center justify-between gap-space-2 rounded-md border border-
|
|
30
|
+
className: cn("flex items-center justify-between gap-space-2 rounded-md border border-muted bg-input p-1.5 px-2.5 text-sm disabled:cursor-not-allowed disabled:border-muted disabled:bg-input-disabled disabled:text-disabled enabled:data-[placeholder]:text-secondary disabled:[&_svg]:text-icon-disabled [&>span]:line-clamp-1", triggerStateStyles, className),
|
|
29
31
|
...props,
|
|
30
32
|
children: props.asChild ? children : /* @__PURE__ */ jsx("span", { children })
|
|
31
33
|
});
|
|
32
34
|
return /* @__PURE__ */ jsxs(RadixSelect.Trigger, {
|
|
33
35
|
ref,
|
|
34
|
-
className: cn("flex items-center justify-between gap-space-2 rounded-md border border-
|
|
36
|
+
className: cn("flex items-center justify-between gap-space-2 rounded-md border border-muted bg-input p-1.5 px-2.5 text-sm disabled:cursor-not-allowed disabled:border-muted disabled:bg-input-disabled disabled:text-disabled enabled:data-[placeholder]:text-secondary disabled:[&_svg]:text-icon-disabled [&>span]:line-clamp-1", triggerStateStyles, className),
|
|
35
37
|
...props,
|
|
36
38
|
children: [children, /* @__PURE__ */ jsx(RadixSelect.Icon, {
|
|
37
39
|
asChild: true,
|
|
@@ -73,7 +75,7 @@ var SelectContent = React$1.forwardRef(({ className, children, position = "poppe
|
|
|
73
75
|
const zIndex = useZIndex(zIndices.popover);
|
|
74
76
|
return /* @__PURE__ */ jsx(RadixSelect.Portal, { children: /* @__PURE__ */ jsx(RadixSelect.Content, {
|
|
75
77
|
ref,
|
|
76
|
-
className: cn("relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-default bg-
|
|
78
|
+
className: cn("relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-default bg-popover shadow-md", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
|
|
77
79
|
position,
|
|
78
80
|
...props,
|
|
79
81
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPrimitive.js","names":[],"sources":["../../../src/components/Select/SelectPrimitive.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as RadixSelect from '@radix-ui/react-select';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport {\n CaretDownIcon,\n CaretUpIcon,\n CheckIcon,\n} from '../../icons/PaddedPhosphorIcons';\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 SelectRoot: typeof RadixSelect.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 <RadixSelect.Root\n {...props}\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={undefined}\n />\n );\n};\n\nexport type SelectTriggerProps = React.ComponentPropsWithoutRef<\n typeof RadixSelect.Trigger\n> & {\n iconClassName?: string;\n};\n\nexport const SelectTrigger = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Trigger>,\n SelectTriggerProps\n>(({ className, children, iconClassName, ...props }, ref) => {\n if (props.asChild) {\n return (\n <RadixSelect.Trigger\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-space-2 rounded-md border border-default bg-transparent p-1.5 px-2.5 text-sm focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-secondary [&>span]:line-clamp-1',\n className\n )}\n {...props}\n >\n {props.asChild ? children : <span>{children}</span>}\n </RadixSelect.Trigger>\n );\n }\n\n return (\n <RadixSelect.Trigger\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-space-2 rounded-md border border-default bg-transparent p-1.5 px-2.5 text-sm focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-secondary [&>span]:line-clamp-1',\n className\n )}\n {...props}\n >\n {children}\n <RadixSelect.Icon asChild>\n <span\n aria-hidden\n className={cn('inline-flex h-4 w-4 text-icon-primary', iconClassName)}\n >\n <CaretDownIcon size=\"100%\" weight=\"regular\" />\n </span>\n </RadixSelect.Icon>\n </RadixSelect.Trigger>\n );\n});\nSelectTrigger.displayName = RadixSelect.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof RadixSelect.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <RadixSelect.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-space-1',\n className\n )}\n {...props}\n >\n <CaretUpIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = RadixSelect.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof RadixSelect.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <RadixSelect.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-space-1',\n className\n )}\n {...props}\n >\n <CaretDownIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = RadixSelect.ScrollDownButton.displayName;\n\nexport const SelectContent = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Content>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Content>\n>(({ className, children, position = 'popper', ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <RadixSelect.Portal>\n <RadixSelect.Content\n ref={ref}\n className={cn(\n 'relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-default bg-elevated shadow-md',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className\n )}\n position={position}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>\n <SelectScrollUpButton />\n <RadixSelect.Viewport\n className={cn(\n 'p-space-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'\n )}\n >\n {children}\n </RadixSelect.Viewport>\n <SelectScrollDownButton />\n </ZIndexProvider>\n </RadixSelect.Content>\n </RadixSelect.Portal>\n );\n});\nSelectContent.displayName = RadixSelect.Content.displayName;\n\nexport const SelectLabel = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Label>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Label>\n>(({ className, ...props }, ref) => (\n <RadixSelect.Label\n ref={ref}\n className={cn(\n 'py-1.5 pl-space-6 pr-space-2 text-sm font-semibold',\n className\n )}\n {...props}\n />\n));\nSelectLabel.displayName = RadixSelect.Label.displayName;\n\nexport const SelectItem = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Item>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Item> & {\n checkmarkPosition?: 'left' | 'right';\n selectedIndicator?: 'checkmark' | 'background';\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(\n (\n {\n className,\n children,\n checkmarkPosition = 'left',\n selectedIndicator = 'checkmark',\n size = 'md',\n ...props\n },\n ref\n ) => (\n <RadixSelect.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default select-none items-center rounded-sm py-space-1 pr-space-2 outline-hidden focus:bg-elevated-hover 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 selectedIndicator === 'background'\n ? 'pl-space-2 data-[state=checked]:bg-selected data-[state=checked]:focus:bg-selected-hover'\n : checkmarkPosition === 'left'\n ? 'pl-space-6'\n : 'pl-space-2',\n className\n )}\n {...props}\n >\n {selectedIndicator === 'checkmark' && (\n <span\n className={cn(\n 'absolute flex h-3.5 w-3.5 items-center justify-center',\n checkmarkPosition === 'left' ? 'left-2' : 'right-2'\n )}\n >\n <RadixSelect.ItemIndicator>\n <CheckIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ItemIndicator>\n </span>\n )}\n\n <RadixSelect.ItemText>{children}</RadixSelect.ItemText>\n </RadixSelect.Item>\n )\n);\nSelectItem.displayName = RadixSelect.Item.displayName;\n\nexport const SelectSeparator = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Separator>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Separator>\n>(({ className, ...props }, ref) => (\n <RadixSelect.Separator\n ref={ref}\n className={cn(\n '-mx-space-1 my-space-1 h-px border-b border-subtle',\n className\n )}\n {...props}\n />\n));\nSelectSeparator.displayName = RadixSelect.Separator.displayName;\n\nexport const SelectValue = RadixSelect.Value;\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,cAAuC,UAAU;CAC5D,MAAM,CAAC,OAAO,OAAO,gBAAgB,qBAAqB;EACxD,MAAM,MAAM;EACZ,aAAa,MAAM,eAAe;EAClC,UAAU,MAAM;CAClB,CAAC;CAED,OACE,oBAAC,YAAY,MAAb;EACE,GAAI;EACE;EACQ;EACd,aAAa,KAAA;CACd,CAAA;AAEL;AAQA,IAAa,gBAAgB,QAAM,YAGhC,EAAE,WAAW,UAAU,eAAe,GAAG,SAAS,QAAQ;CAC3D,IAAI,MAAM,SACR,OACE,oBAAC,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AEpD,IAAa,cAAc,YAAY"}
|
|
1
|
+
{"version":3,"file":"SelectPrimitive.js","names":[],"sources":["../../../src/components/Select/SelectPrimitive.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as RadixSelect from '@radix-ui/react-select';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\n\nimport {\n CaretDownIcon,\n CaretUpIcon,\n CheckIcon,\n} from '../../icons/PaddedPhosphorIcons';\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 SelectRoot: typeof RadixSelect.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 <RadixSelect.Root\n {...props}\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={undefined}\n />\n );\n};\n\nexport type SelectTriggerProps = React.ComponentPropsWithoutRef<\n typeof RadixSelect.Trigger\n> & {\n iconClassName?: string;\n};\n\nexport const SelectTrigger = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Trigger>,\n SelectTriggerProps\n>(({ className, children, iconClassName, ...props }, ref) => {\n const isError =\n props['aria-invalid'] === true || props['aria-invalid'] === 'true';\n const triggerStateStyles =\n !props.disabled &&\n (isError\n ? 'border-error-strong focus-visible:border-error-strong focus-visible:shadow-[0_0_0_1px_var(--border-error-strong)] focus-visible:outline-none'\n : '[&:enabled:hover:not(:focus-visible)]:border-subtle focus-visible:border-focus focus-visible:shadow-[0_0_0_1px_var(--border-focus)] focus-visible:outline-none');\n\n if (props.asChild) {\n return (\n <RadixSelect.Trigger\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-space-2 rounded-md border border-muted bg-input p-1.5 px-2.5 text-sm disabled:cursor-not-allowed disabled:border-muted disabled:bg-input-disabled disabled:text-disabled enabled:data-[placeholder]:text-secondary disabled:[&_svg]:text-icon-disabled [&>span]:line-clamp-1',\n triggerStateStyles,\n className\n )}\n {...props}\n >\n {props.asChild ? children : <span>{children}</span>}\n </RadixSelect.Trigger>\n );\n }\n\n return (\n <RadixSelect.Trigger\n ref={ref}\n className={cn(\n 'flex items-center justify-between gap-space-2 rounded-md border border-muted bg-input p-1.5 px-2.5 text-sm disabled:cursor-not-allowed disabled:border-muted disabled:bg-input-disabled disabled:text-disabled enabled:data-[placeholder]:text-secondary disabled:[&_svg]:text-icon-disabled [&>span]:line-clamp-1',\n triggerStateStyles,\n className\n )}\n {...props}\n >\n {children}\n <RadixSelect.Icon asChild>\n <span\n aria-hidden\n className={cn('inline-flex h-4 w-4 text-icon-primary', iconClassName)}\n >\n <CaretDownIcon size=\"100%\" weight=\"regular\" />\n </span>\n </RadixSelect.Icon>\n </RadixSelect.Trigger>\n );\n});\nSelectTrigger.displayName = RadixSelect.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof RadixSelect.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <RadixSelect.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-space-1',\n className\n )}\n {...props}\n >\n <CaretUpIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = RadixSelect.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof RadixSelect.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <RadixSelect.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-space-1',\n className\n )}\n {...props}\n >\n <CaretDownIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = RadixSelect.ScrollDownButton.displayName;\n\nexport const SelectContent = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Content>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Content>\n>(({ className, children, position = 'popper', ...props }, ref) => {\n const zIndex = useZIndex(zIndices.popover);\n\n return (\n <RadixSelect.Portal>\n <RadixSelect.Content\n ref={ref}\n className={cn(\n 'relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-default bg-popover shadow-md',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className\n )}\n position={position}\n {...props}\n style={{ zIndex, ...props.style }}\n >\n <ZIndexProvider value={zIndex}>\n <SelectScrollUpButton />\n <RadixSelect.Viewport\n className={cn(\n 'p-space-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'\n )}\n >\n {children}\n </RadixSelect.Viewport>\n <SelectScrollDownButton />\n </ZIndexProvider>\n </RadixSelect.Content>\n </RadixSelect.Portal>\n );\n});\nSelectContent.displayName = RadixSelect.Content.displayName;\n\nexport const SelectLabel = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Label>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Label>\n>(({ className, ...props }, ref) => (\n <RadixSelect.Label\n ref={ref}\n className={cn(\n 'py-1.5 pl-space-6 pr-space-2 text-sm font-semibold',\n className\n )}\n {...props}\n />\n));\nSelectLabel.displayName = RadixSelect.Label.displayName;\n\nexport const SelectItem = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Item>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Item> & {\n checkmarkPosition?: 'left' | 'right';\n selectedIndicator?: 'checkmark' | 'background';\n /**\n * Controls minimum row height and default label typography.\n * Rich or multiline content grows intrinsically.\n */\n size?: OptionRowSize;\n }\n>(\n (\n {\n className,\n children,\n checkmarkPosition = 'left',\n selectedIndicator = 'checkmark',\n size = 'md',\n ...props\n },\n ref\n ) => (\n <RadixSelect.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default select-none items-center rounded-sm py-space-1 pr-space-2 outline-hidden focus:bg-elevated-hover 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 selectedIndicator === 'background'\n ? 'pl-space-2 data-[state=checked]:bg-selected data-[state=checked]:focus:bg-selected-hover'\n : checkmarkPosition === 'left'\n ? 'pl-space-6'\n : 'pl-space-2',\n className\n )}\n {...props}\n >\n {selectedIndicator === 'checkmark' && (\n <span\n className={cn(\n 'absolute flex h-3.5 w-3.5 items-center justify-center',\n checkmarkPosition === 'left' ? 'left-2' : 'right-2'\n )}\n >\n <RadixSelect.ItemIndicator>\n <CheckIcon aria-hidden size={16} weight=\"regular\" />\n </RadixSelect.ItemIndicator>\n </span>\n )}\n\n <RadixSelect.ItemText>{children}</RadixSelect.ItemText>\n </RadixSelect.Item>\n )\n);\nSelectItem.displayName = RadixSelect.Item.displayName;\n\nexport const SelectSeparator = React.forwardRef<\n React.ElementRef<typeof RadixSelect.Separator>,\n React.ComponentPropsWithoutRef<typeof RadixSelect.Separator>\n>(({ className, ...props }, ref) => (\n <RadixSelect.Separator\n ref={ref}\n className={cn(\n '-mx-space-1 my-space-1 h-px border-b border-subtle',\n className\n )}\n {...props}\n />\n));\nSelectSeparator.displayName = RadixSelect.Separator.displayName;\n\nexport const SelectValue = RadixSelect.Value;\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,cAAuC,UAAU;CAC5D,MAAM,CAAC,OAAO,OAAO,gBAAgB,qBAAqB;EACxD,MAAM,MAAM;EACZ,aAAa,MAAM,eAAe;EAClC,UAAU,MAAM;CAClB,CAAC;CAED,OACE,oBAAC,YAAY,MAAb;EACE,GAAI;EACE;EACQ;EACd,aAAa,KAAA;CACd,CAAA;AAEL;AAQA,IAAa,gBA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,CAAA;AACA,WAAW,cAAc,YAAY,KAAK;AAE1C,IAAa,kBAAkB,QAAM,YAGlC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,YAAY,WAAb;CACO;CACL,WAAW,GACT,sDACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,YAAY,UAAU;AAEpD,IAAa,cAAc,YAAY"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Select } from './Select.js';
|
|
2
|
-
export type { SelectGroup, SelectOption, SelectProps, SelectSize, } from './Select.js';
|
|
2
|
+
export type { SelectGroup, SelectOption, SelectProps, SelectSize, SelectVariant, } from './Select.js';
|
|
3
3
|
export { SelectContent, SelectItem, SelectLabel, SelectRoot, SelectSeparator, SelectTrigger, SelectValue, } from './SelectPrimitive.js';
|
|
4
4
|
export type { SelectTriggerProps } from './SelectPrimitive.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CaretDoubleRightIcon, CaretDownIcon, CaretUpIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
|
-
import { Text } from "../Text/Text.js";
|
|
3
3
|
import zIndices from "../../utils/zIndices.js";
|
|
4
|
+
import { Text } from "../Text/Text.js";
|
|
4
5
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
|
-
import { CaretDoubleRightIcon, CaretDownIcon, CaretUpIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
6
6
|
import { Kbd } from "../Kbd/Kbd.js";
|
|
7
7
|
import { createPortalSlot } from "../PortalSlot.js";
|
|
8
8
|
import { useLayoutEffect, useState } from "react";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IconComponent } from '../../utils/icon-types.js';
|
|
2
|
+
import { type BadgeProps } from '../Badge/index.js';
|
|
3
|
+
/** How a state reads: fine, needs attention, broken, or neither. */
|
|
4
|
+
export type StatusBadgeVariant = 'neutral' | 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
/** Badge's text-label heights: xxs/xs=16px, sm=20px, md=24px. */
|
|
6
|
+
export type StatusBadgeSize = NonNullable<BadgeProps['size']>;
|
|
7
|
+
export interface StatusBadgeProps {
|
|
8
|
+
/** How the state reads. Defaults to `neutral`. */
|
|
9
|
+
variant?: StatusBadgeVariant;
|
|
10
|
+
/**
|
|
11
|
+
* Replaces the variant's icon; `null` drops it. Success, warning, and error
|
|
12
|
+
* carry one by default.
|
|
13
|
+
*/
|
|
14
|
+
icon?: IconComponent | null;
|
|
15
|
+
/**
|
|
16
|
+
* Badge height; the icon and text scale with it. Defaults to `xs` (16px),
|
|
17
|
+
* which sits beside a title or in a row.
|
|
18
|
+
*/
|
|
19
|
+
size?: StatusBadgeSize;
|
|
20
|
+
children: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A short state beside a title, such as Active, Expires in 3 days, or
|
|
25
|
+
* Failed, colored and marked by how it reads.
|
|
26
|
+
*/
|
|
27
|
+
export declare function StatusBadge({ variant, icon, size, children, className, }: StatusBadgeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Badge } from "../Badge/Badge.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { WarningCircleIcon } from "@phosphor-icons/react/dist/ssr/WarningCircle";
|
|
4
|
+
import { CheckCircleIcon } from "@phosphor-icons/react/dist/ssr/CheckCircle";
|
|
5
|
+
import { WarningIcon } from "@phosphor-icons/react/dist/ssr/Warning";
|
|
6
|
+
//#region packages/components/src/components/StatusBadge/StatusBadge.tsx
|
|
7
|
+
var VARIANTS = {
|
|
8
|
+
neutral: { color: "secondary" },
|
|
9
|
+
info: { color: "primary" },
|
|
10
|
+
success: {
|
|
11
|
+
color: "success",
|
|
12
|
+
icon: CheckCircleIcon
|
|
13
|
+
},
|
|
14
|
+
warning: {
|
|
15
|
+
color: "warning",
|
|
16
|
+
icon: WarningIcon
|
|
17
|
+
},
|
|
18
|
+
error: {
|
|
19
|
+
color: "error",
|
|
20
|
+
icon: WarningCircleIcon
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A short state beside a title, such as Active, Expires in 3 days, or
|
|
25
|
+
* Failed, colored and marked by how it reads.
|
|
26
|
+
*/
|
|
27
|
+
function StatusBadge({ variant = "neutral", icon, size = "xs", children, className }) {
|
|
28
|
+
const { color, icon: variantIcon } = VARIANTS[variant];
|
|
29
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
30
|
+
color,
|
|
31
|
+
size,
|
|
32
|
+
rounded: "xs",
|
|
33
|
+
leftDecorator: icon === null ? void 0 : icon ?? variantIcon,
|
|
34
|
+
iconWeight: "regular",
|
|
35
|
+
className,
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { StatusBadge };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=StatusBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/components/StatusBadge/StatusBadge.tsx"],"sourcesContent":["import { CheckCircleIcon } from '@phosphor-icons/react/dist/ssr/CheckCircle';\nimport { WarningIcon } from '@phosphor-icons/react/dist/ssr/Warning';\nimport { WarningCircleIcon } from '@phosphor-icons/react/dist/ssr/WarningCircle';\n\nimport type { IconComponent } from '../../utils/icon-types';\nimport { Badge, type BadgeProps } from '../Badge';\n\n/** How a state reads: fine, needs attention, broken, or neither. */\nexport type StatusBadgeVariant =\n | 'neutral'\n | 'info'\n | 'success'\n | 'warning'\n | 'error';\n\nconst VARIANTS: Record<\n StatusBadgeVariant,\n { color: NonNullable<BadgeProps['color']>; icon?: IconComponent }\n> = {\n neutral: { color: 'secondary' },\n info: { color: 'primary' },\n success: { color: 'success', icon: CheckCircleIcon },\n warning: { color: 'warning', icon: WarningIcon },\n error: { color: 'error', icon: WarningCircleIcon },\n};\n\n/** Badge's text-label heights: xxs/xs=16px, sm=20px, md=24px. */\nexport type StatusBadgeSize = NonNullable<BadgeProps['size']>;\n\nexport interface StatusBadgeProps {\n /** How the state reads. Defaults to `neutral`. */\n variant?: StatusBadgeVariant;\n /**\n * Replaces the variant's icon; `null` drops it. Success, warning, and error\n * carry one by default.\n */\n icon?: IconComponent | null;\n /**\n * Badge height; the icon and text scale with it. Defaults to `xs` (16px),\n * which sits beside a title or in a row.\n */\n size?: StatusBadgeSize;\n children: string;\n className?: string;\n}\n\n/**\n * A short state beside a title, such as Active, Expires in 3 days, or\n * Failed, colored and marked by how it reads.\n */\nexport function StatusBadge({\n variant = 'neutral',\n icon,\n size = 'xs',\n children,\n className,\n}: StatusBadgeProps) {\n const { color, icon: variantIcon } = VARIANTS[variant];\n return (\n <Badge\n color={color}\n size={size}\n rounded=\"xs\"\n leftDecorator={icon === null ? undefined : (icon ?? variantIcon)}\n iconWeight=\"regular\"\n className={className}\n >\n {children}\n </Badge>\n );\n}\n"],"mappings":";;;;;;AAeA,IAAM,WAGF;CACF,SAAS,EAAE,OAAO,YAAY;CAC9B,MAAM,EAAE,OAAO,UAAU;CACzB,SAAS;EAAE,OAAO;EAAW,MAAM;CAAgB;CACnD,SAAS;EAAE,OAAO;EAAW,MAAM;CAAY;CAC/C,OAAO;EAAE,OAAO;EAAS,MAAM;CAAkB;AACnD;;;;;AA0BA,SAAgB,YAAY,EAC1B,UAAU,WACV,MACA,OAAO,MACP,UACA,aACmB;CACnB,MAAM,EAAE,OAAO,MAAM,gBAAgB,SAAS;CAC9C,OACE,oBAAC,OAAD;EACS;EACD;EACN,SAAQ;EACR,eAAe,SAAS,OAAO,KAAA,IAAa,QAAQ;EACpD,YAAW;EACA;EAEV;CACI,CAAA;AAEX"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
2
3
|
import type { BadgeProps } from '../Badge/index.js';
|
|
3
4
|
export declare function TabList({ children, className, }: {
|
|
4
5
|
children: React.ReactNode;
|
|
5
6
|
className?: string;
|
|
6
7
|
}): import("react").JSX.Element;
|
|
7
|
-
export declare function TabLabel({ label, icon: Icon, badgeProps, className, disabled, dataTestId, onClick, onBlur, }: {
|
|
8
|
+
export declare function TabLabel({ label, icon: Icon, badgeProps, className, disabled, dataTestId, onClick, onBlur, ...rest }: {
|
|
8
9
|
label: React.ReactNode;
|
|
9
10
|
icon?: ComponentType<{
|
|
10
11
|
className?: string;
|
|
@@ -15,7 +16,7 @@ export declare function TabLabel({ label, icon: Icon, badgeProps, className, dis
|
|
|
15
16
|
dataTestId?: string;
|
|
16
17
|
onClick?: () => void;
|
|
17
18
|
onBlur?: () => void;
|
|
18
|
-
}): import("react").JSX.Element;
|
|
19
|
+
} & DataAttributes): import("react").JSX.Element;
|
|
19
20
|
export declare const TabPanels: import("@headlessui/react")._internal_ComponentTabPanels;
|
|
20
21
|
export declare const TabGroup: import("@headlessui/react")._internal_ComponentTabGroup;
|
|
21
22
|
export declare function TabPanel({ children, className, panelRef, onScroll, unmount, }: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { Text } from "../Text/Text.js";
|
|
3
3
|
import { Badge } from "../Badge/Badge.js";
|
|
4
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Tab, TabGroup as TabGroup$1, TabList as TabList$1, TabPanel as TabPanel$1, TabPanels as TabPanels$1 } from "@headlessui/react";
|
|
6
7
|
//#region packages/components/src/components/Tabs/index.tsx
|
|
@@ -10,8 +11,9 @@ function TabList({ children, className }) {
|
|
|
10
11
|
children
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
|
-
function TabLabel({ label, icon: Icon, badgeProps, className, disabled, dataTestId, onClick, onBlur }) {
|
|
14
|
+
function TabLabel({ label, icon: Icon, badgeProps, className, disabled, dataTestId, onClick, onBlur, ...rest }) {
|
|
14
15
|
return /* @__PURE__ */ jsxs(Tab, {
|
|
16
|
+
...pickDataAttributes(rest),
|
|
15
17
|
onClick,
|
|
16
18
|
onBlur,
|
|
17
19
|
className: cn("group relative flex items-center gap-space-2 border-b-2 border-b-transparent pb-5 text-primary outline-hidden transition-[color] duration-normal", "after:pointer-events-none after:invisible after:absolute after:inset-x-0 after:-bottom-0.5 after:mx-auto after:h-0.5 after:w-full after:rounded-full after:border-b-2 after:border-current", "data-[selected]:after:visible data-[selected]:after:animate-tab-indicator-expand motion-reduce:after:animate-none", "hover:text-brand-secondary data-[selected]:hover:after:border-b-brand-strong", "disabled:cursor-default disabled:text-disabled", className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Tabs/index.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\n// NOTE: Tabs are intentionally NOT re-exported from the design-system barrel\n// (components/index.ts). Importing @headlessui/react through the barrel pulls\n// ~297KB into every chunk that touches the barrel, bloating the initial load.\n// Import directly from '.' instead.\nimport {\n TabGroup as HeadlessTabGroup,\n TabList as HeadlessTabList,\n TabPanel as HeadlessTabPanel,\n TabPanels as HeadlessTabPanels,\n Tab,\n} from '@headlessui/react';\n\nimport { cn } from '../../utils/cn';\nimport type { BadgeProps } from '../Badge';\nimport { Badge } from '../Badge';\nimport { Text } from '../Text';\n\nexport function TabList({\n children,\n className,\n}: {\n children: React.ReactNode;\n className?: string;\n}) {\n return (\n <HeadlessTabList\n className={cn(\n 'flex gap-space-5 border-b border-secondary text-ls-black',\n className\n )}\n >\n {children}\n </HeadlessTabList>\n );\n}\n\nexport function TabLabel({\n label,\n icon: Icon,\n badgeProps,\n className,\n disabled,\n dataTestId,\n onClick,\n onBlur,\n}: {\n label: React.ReactNode;\n icon?: ComponentType<{ className?: string }>;\n badgeProps?: BadgeProps;\n className?: string;\n disabled?: boolean;\n dataTestId?: string;\n onClick?: () => void;\n onBlur?: () => void;\n}) {\n // Absolute positioning uses the padding box; -2px places the indicator inside\n // the reserved bottom border, keeping it visible in scrollable tab lists.\n return (\n <Tab\n onClick={onClick}\n onBlur={onBlur}\n className={cn(\n 'group relative flex items-center gap-space-2 border-b-2 border-b-transparent pb-5 text-primary outline-hidden transition-[color] duration-normal',\n 'after:pointer-events-none after:invisible after:absolute after:inset-x-0 after:-bottom-0.5 after:mx-auto after:h-0.5 after:w-full after:rounded-full after:border-b-2 after:border-current',\n 'data-[selected]:after:visible data-[selected]:after:animate-tab-indicator-expand motion-reduce:after:animate-none',\n 'hover:text-brand-secondary data-[selected]:hover:after:border-b-brand-strong',\n 'disabled:cursor-default disabled:text-disabled',\n className\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {Icon && <Icon className=\"size-3.5\" />}\n {typeof label === 'string' ? (\n <Text\n variant=\"md\"\n className=\"font-normal group-data-[selected]:font-medium\"\n >\n {label}\n </Text>\n ) : label != null ? (\n label\n ) : null}\n {badgeProps && <Badge {...badgeProps} />}\n </Tab>\n );\n}\n\nexport const TabPanels = HeadlessTabPanels;\n\nexport const TabGroup = HeadlessTabGroup;\n\nexport function TabPanel({\n children,\n className,\n panelRef,\n onScroll,\n unmount,\n}: {\n children: React.ReactNode;\n className?: string;\n panelRef?: React.RefObject<HTMLDivElement | null>;\n onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;\n unmount?: boolean;\n}) {\n return (\n <HeadlessTabPanel\n className={cn('outline-hidden', className)}\n onScroll={onScroll}\n ref={panelRef}\n unmount={unmount}\n >\n {children}\n </HeadlessTabPanel>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Tabs/index.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\n// NOTE: Tabs are intentionally NOT re-exported from the design-system barrel\n// (components/index.ts). Importing @headlessui/react through the barrel pulls\n// ~297KB into every chunk that touches the barrel, bloating the initial load.\n// Import directly from '.' instead.\nimport {\n TabGroup as HeadlessTabGroup,\n TabList as HeadlessTabList,\n TabPanel as HeadlessTabPanel,\n TabPanels as HeadlessTabPanels,\n Tab,\n} from '@headlessui/react';\n\nimport { cn } from '../../utils/cn';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport type { BadgeProps } from '../Badge';\nimport { Badge } from '../Badge';\nimport { Text } from '../Text';\n\nexport function TabList({\n children,\n className,\n}: {\n children: React.ReactNode;\n className?: string;\n}) {\n return (\n <HeadlessTabList\n className={cn(\n 'flex gap-space-5 border-b border-secondary text-ls-black',\n className\n )}\n >\n {children}\n </HeadlessTabList>\n );\n}\n\nexport function TabLabel({\n label,\n icon: Icon,\n badgeProps,\n className,\n disabled,\n dataTestId,\n onClick,\n onBlur,\n ...rest\n}: {\n label: React.ReactNode;\n icon?: ComponentType<{ className?: string }>;\n badgeProps?: BadgeProps;\n className?: string;\n disabled?: boolean;\n dataTestId?: string;\n onClick?: () => void;\n onBlur?: () => void;\n} & DataAttributes) {\n // Absolute positioning uses the padding box; -2px places the indicator inside\n // the reserved bottom border, keeping it visible in scrollable tab lists.\n return (\n <Tab\n {...pickDataAttributes(rest)}\n onClick={onClick}\n onBlur={onBlur}\n className={cn(\n 'group relative flex items-center gap-space-2 border-b-2 border-b-transparent pb-5 text-primary outline-hidden transition-[color] duration-normal',\n 'after:pointer-events-none after:invisible after:absolute after:inset-x-0 after:-bottom-0.5 after:mx-auto after:h-0.5 after:w-full after:rounded-full after:border-b-2 after:border-current',\n 'data-[selected]:after:visible data-[selected]:after:animate-tab-indicator-expand motion-reduce:after:animate-none',\n 'hover:text-brand-secondary data-[selected]:hover:after:border-b-brand-strong',\n 'disabled:cursor-default disabled:text-disabled',\n className\n )}\n disabled={disabled}\n data-testid={dataTestId}\n >\n {Icon && <Icon className=\"size-3.5\" />}\n {typeof label === 'string' ? (\n <Text\n variant=\"md\"\n className=\"font-normal group-data-[selected]:font-medium\"\n >\n {label}\n </Text>\n ) : label != null ? (\n label\n ) : null}\n {badgeProps && <Badge {...badgeProps} />}\n </Tab>\n );\n}\n\nexport const TabPanels = HeadlessTabPanels;\n\nexport const TabGroup = HeadlessTabGroup;\n\nexport function TabPanel({\n children,\n className,\n panelRef,\n onScroll,\n unmount,\n}: {\n children: React.ReactNode;\n className?: string;\n panelRef?: React.RefObject<HTMLDivElement | null>;\n onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;\n unmount?: boolean;\n}) {\n return (\n <HeadlessTabPanel\n className={cn('outline-hidden', className)}\n onScroll={onScroll}\n ref={panelRef}\n unmount={unmount}\n >\n {children}\n </HeadlessTabPanel>\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,QAAQ,EACtB,UACA,aAIC;CACD,OACE,oBAAC,WAAD;EACE,WAAW,GACT,4DACA,SACF;EAEC;CACc,CAAA;AAErB;AAEA,SAAgB,SAAS,EACvB,OACA,MAAM,MACN,YACA,WACA,UACA,YACA,SACA,QACA,GAAG,QAUe;CAGlB,OACE,qBAAC,KAAD;EACE,GAAI,mBAAmB,IAAI;EAClB;EACD;EACR,WAAW,GACT,oJACA,8LACA,qHACA,gFACA,kDACA,SACF;EACU;EACV,eAAa;EAbf,UAAA;GAeG,QAAQ,oBAAC,MAAD,EAAM,WAAU,WAAY,CAAA;GACpC,OAAO,UAAU,WAChB,oBAAC,MAAD;IACE,SAAQ;IACR,WAAU;IAET,UAAA;GACG,CAAA,IACJ,SAAS,OACX,QACE;GACH,cAAc,oBAAC,OAAD,EAAO,GAAI,WAAa,CAAA;EACpC;;AAET;AAEA,IAAa,YAAY;AAEzB,IAAa,WAAW;AAExB,SAAgB,SAAS,EACvB,UACA,WACA,UACA,UACA,WAOC;CACD,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,kBAAkB,SAAS;EAC/B;EACV,KAAK;EACI;EAER;CACe,CAAA;AAEtB"}
|
|
@@ -46,7 +46,7 @@ var Textarea = forwardRef(({ size = "lg", leftDecorator, rightDecorator, disable
|
|
|
46
46
|
onChange(newValue);
|
|
47
47
|
};
|
|
48
48
|
const textareaContainerClasses = cn("flex w-full gap-space-2", variant === "default" && [
|
|
49
|
-
"border bg-
|
|
49
|
+
"border bg-input transition-[border-color,box-shadow,background-color]",
|
|
50
50
|
CONTROL_SIZES[size].minHeightClassName,
|
|
51
51
|
INPUT_HORIZONTAL_PADDING_CLASSES[size],
|
|
52
52
|
INPUT_RADIUS_CLASSES[size],
|
|
@@ -57,20 +57,20 @@ var Textarea = forwardRef(({ size = "lg", leftDecorator, rightDecorator, disable
|
|
|
57
57
|
"py-space-2": size === "lg"
|
|
58
58
|
},
|
|
59
59
|
"focus-within:outline-hidden",
|
|
60
|
-
"border-
|
|
61
|
-
!disabled && !isError && "[&:hover:not(:focus-within)]:border-
|
|
62
|
-
!isError && "focus-within:border-focus focus-within:shadow-[
|
|
63
|
-
isError && "border-error-strong focus-within:border-error-strong focus-within:shadow-[
|
|
64
|
-
disabled && "cursor-not-allowed bg-disabled
|
|
60
|
+
"border-muted",
|
|
61
|
+
!disabled && !isError && "[&:hover:not(:focus-within)]:border-subtle",
|
|
62
|
+
!disabled && !isError && "focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]",
|
|
63
|
+
!disabled && isError && "border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]",
|
|
64
|
+
disabled && "cursor-not-allowed border-muted bg-input-disabled text-disabled"
|
|
65
65
|
], leftDecorator || rightDecorator ? "items-start" : "items-center");
|
|
66
66
|
const effectiveResize = autoResize ? "none" : resize;
|
|
67
|
-
const textareaClasses = cn("max-w-full flex-1 border-none bg-transparent p-0 outline-hidden", INPUT_TEXT_CLASSES[size], "placeholder:text-placeholder", disabled && "cursor-not-allowed", {
|
|
67
|
+
const textareaClasses = cn("max-w-full flex-1 border-none bg-transparent p-0 outline-hidden", INPUT_TEXT_CLASSES[size], "placeholder:text-placeholder", disabled && "cursor-not-allowed text-disabled placeholder:text-disabled", {
|
|
68
68
|
"resize-none": effectiveResize === "none",
|
|
69
69
|
"resize-y": effectiveResize === "vertical",
|
|
70
70
|
"resize-x": effectiveResize === "horizontal",
|
|
71
71
|
resize: effectiveResize === "both"
|
|
72
72
|
}, inputClassName);
|
|
73
|
-
const decoratorClasses = cn("flex items-center text-tertiary", {
|
|
73
|
+
const decoratorClasses = cn("flex items-center text-tertiary", disabled && "text-disabled", {
|
|
74
74
|
"mt-0": size === "xs" || size === "sm",
|
|
75
75
|
"mt-0.5": size === "md",
|
|
76
76
|
"mt-space-1": size === "lg"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","names":[],"sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n forwardRef,\n useCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_SIZES } from '../../utils/componentSizes';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport {\n INPUT_HORIZONTAL_PADDING_CLASSES,\n INPUT_RADIUS_CLASSES,\n INPUT_TEXT_CLASSES,\n} from '../Input/inputStyles';\nimport type { InputSize } from '../Input/inputStyles';\nimport { Text } from '../Text';\n\nconst DEFAULT_AUTO_RESIZE_MAX_HEIGHT_PX = 200;\n\nexport interface TextareaProps {\n /** First-row metrics. Total height remains intrinsic to rows and content. */\n size?: InputSize;\n /** Left side decorator/icon */\n leftDecorator?: ReactNode;\n /** Right side decorator/icon */\n rightDecorator?: ReactNode;\n /** Whether the textarea is disabled */\n disabled?: boolean;\n /** Whether the textarea has an error state */\n isError?: boolean;\n /** Label text displayed above the textarea */\n label?: string | ReactNode;\n /** Hint text displayed below the textarea */\n hintText?: string;\n /** Current textarea value */\n value?: string;\n /**\n * Update controlled value synchronously. Keep asynchronous persistence in\n * the owner, using useDebouncedCommit when writes must be debounced and ordered.\n */\n onChange: (value: string) => void;\n /** Placeholder text */\n placeholder?: string;\n /** Additional CSS classes */\n className?: string;\n /** Additional CSS classes applied to the inner <textarea> element */\n inputClassName?: string;\n /** Textarea ID for accessibility */\n id?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Auto focus on mount */\n autoFocus?: boolean;\n /** Number of visible rows */\n rows?: number;\n /** Whether the textarea can be resized */\n resize?: 'none' | 'vertical' | 'horizontal' | 'both';\n /** When true, textarea height grows with content up to maxHeight (resize is forced to none) */\n autoResize?: boolean;\n /** Max height in px when autoResize is true (default: 200) */\n maxHeight?: number;\n /** Visual variant: default (bordered container) or plain (borderless, for embedding) */\n variant?: 'default' | 'plain';\n}\n\nexport const Textarea = forwardRef<\n HTMLTextAreaElement,\n TextareaProps &\n Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof TextareaProps>\n>(\n (\n {\n size = 'lg',\n leftDecorator,\n rightDecorator,\n disabled = false,\n isError = false,\n label,\n hintText,\n value,\n onChange,\n placeholder,\n className,\n inputClassName,\n id,\n required = false,\n autoFocus = false,\n rows = 3,\n resize = 'vertical',\n autoResize = false,\n maxHeight = DEFAULT_AUTO_RESIZE_MAX_HEIGHT_PX,\n variant = 'default',\n 'aria-describedby': ariaDescribedBy,\n ...rest\n },\n ref\n ) => {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const hintTextId = `${textareaId}-hint`;\n const describedBy =\n [hintText ? hintTextId : undefined, ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined;\n const [internalValue, setInternalValue] = useState(value);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n // Auto-resize: grow with content up to maxHeight.\n // Run on value change and on element resize (e.g. container width change so text wraps).\n const runAutoResize = useCallback(() => {\n const el = textareaRef.current;\n if (!el || !autoResize) return;\n el.style.height = 'auto';\n const contentHeight = Math.min(el.scrollHeight, maxHeight);\n el.style.height = `${contentHeight}px`;\n el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';\n }, [autoResize, maxHeight]);\n\n useLayoutEffect(() => {\n const el = textareaRef.current;\n if (!el) return;\n if (!autoResize) {\n el.style.height = '';\n el.style.overflowY = '';\n return;\n }\n\n runAutoResize();\n\n const ro = new ResizeObserver(runAutoResize);\n ro.observe(el);\n return () => ro.disconnect();\n }, [autoResize, value, internalValue, runAutoResize]);\n\n const handleTextareaChange = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n const newValue = e.target.value;\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const textareaContainerClasses = cn(\n 'flex w-full gap-space-2',\n variant === 'default' && [\n 'border bg-transparent transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].minHeightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n {\n 'py-px': size === 'xs',\n 'py-0.5': size === 'sm',\n 'py-space-1': size === 'md',\n 'py-space-2': size === 'lg',\n },\n 'focus-within:outline-hidden',\n 'border-subtle',\n !disabled && !isError && '[&:hover:not(:focus-within)]:border-default',\n !isError &&\n 'focus-within:border-focus focus-within:shadow-[0_0_0_2px_var(--border-focus)]',\n isError &&\n 'border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_2px_var(--border-error-strong)]',\n disabled && 'cursor-not-allowed bg-disabled opacity-50',\n ],\n leftDecorator || rightDecorator ? 'items-start' : 'items-center'\n );\n\n const effectiveResize = autoResize ? 'none' : resize;\n const textareaClasses = cn(\n '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 // Resize handling (autoResize forces none)\n {\n 'resize-none': effectiveResize === 'none',\n 'resize-y': effectiveResize === 'vertical',\n 'resize-x': effectiveResize === 'horizontal',\n resize: effectiveResize === 'both',\n },\n inputClassName\n );\n\n const decoratorClasses = cn('flex items-center text-tertiary', {\n 'mt-0': size === 'xs' || size === 'sm',\n 'mt-0.5': size === 'md',\n 'mt-space-1': size === 'lg',\n });\n\n const labelClasses = cn(\n 'mb-space-1 block font-medium text-primary',\n disabled && 'text-disabled'\n );\n\n const hintTextClasses = cn(\n 'mt-space-1 text-xs',\n isError ? 'text-error-secondary' : 'text-tertiary'\n );\n\n const containerClasses = cn('w-full', className);\n\n return (\n <div className={containerClasses}>\n {label && (\n <Text\n as=\"label\"\n htmlFor={textareaId}\n className={labelClasses}\n variant=\"sm\"\n >\n {label}\n {required && (\n <span className=\"ml-space-1 text-error-secondary\">*</span>\n )}\n </Text>\n )}\n\n <div className={textareaContainerClasses}>\n {leftDecorator && (\n <div className={decoratorClasses}>{leftDecorator}</div>\n )}\n\n {/* eslint-disable-next-line react/forbid-elements */}\n <textarea\n ref={mergeRefs([textareaRef, ref])}\n id={textareaId}\n value={value}\n onChange={handleTextareaChange}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoFocus={autoFocus}\n rows={rows}\n aria-describedby={describedBy}\n aria-invalid={isError || undefined}\n className={textareaClasses}\n {...rest}\n />\n\n {rightDecorator && (\n <div className={decoratorClasses}>{rightDecorator}</div>\n )}\n </div>\n\n {hintText && (\n <Text\n id={hintTextId}\n className={hintTextClasses}\n variant=\"xs\"\n weight=\"normal\"\n >\n {hintText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';\n"],"mappings":";;;;;;;;AAqBA,IAAM,oCAAoC;AAgD1C,IAAa,WAAW,YAMpB,EACE,OAAO,MACP,eACA,gBACA,WAAW,OACX,UAAU,OACV,OACA,UACA,OACA,UACA,aACA,WACA,gBACA,IACA,WAAW,OACX,YAAY,OACZ,OAAO,GACP,SAAS,YACT,aAAa,OACb,YAAY,mCACZ,UAAU,WACV,oBAAoB,iBACpB,GAAG,QAEL,QACG;CACH,MAAM,cAAc,MAAM;CAC1B,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,GAAG,WAAW;CACjC,MAAM,cACJ,CAAC,WAAW,aAAa,KAAA,GAAW,eAAe,CAAC,CACjD,OAAO,OAAO,CAAC,CACf,KAA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oBAAoB;EAChC,QAAQ,oBAAoB;CAC9B,GACA,cACF;CAEA,MAAM,mBAAmB,GAAG,mCAAmC;EAC7D,QAAQ,SAAS,QAAQ,SAAS;EAClC,UAAU,SAAS;EACnB,cAAc,SAAS;CACzB,CAAC;CAED,MAAM,eAAe,GACnB,6CACA,YAAY,eACd;CAEA,MAAM,kBAAkB,GACtB,sBACA,UAAU,yBAAyB,eACrC;CAEA,MAAM,mBAAmB,GAAG,UAAU,SAAS;CAE/C,OACE,qBAAC,OAAD;EAAK,WAAW;EAAhB,UAAA;GACG,SACC,qBAAC,MAAD;IACE,IAAG;IACH,SAAS;IACT,WAAW;IACX,SAAQ;IAJV,UAAA,CAMG,OACA,YACC,oBAAC,QAAD;KAAM,WAAU;KAAkC,UAAA;IAAO,CAAA,CAEvD;;GAGR,qBAAC,OAAD;IAAK,WAAW;IAAhB,UAAA;KACG,iBACC,oBAAC,OAAD;MAAK,WAAW;MAAmB,UAAA;KAAmB,CAAA;KAIxD,oBAAC,YAAD;MACE,KAAK,UAAU,CAAC,aAAa,GAAG,CAAC;MACjC,IAAI;MACG;MACP,UAAU;MACG;MACH;MACA;MACC;MACL;MACN,oBAAkB;MAClB,gBAAc,WAAW,KAAA;MACzB,WAAW;MACX,GAAI;KACL,CAAA;KAEA,kBACC,oBAAC,OAAD;MAAK,WAAW;MAAmB,UAAA;KAAoB,CAAA;IAEtD;;GAEJ,YACC,oBAAC,MAAD;IACE,IAAI;IACJ,WAAW;IACX,SAAQ;IACR,QAAO;IAEN,UAAA;GACG,CAAA;EAEL;;AAET,CACF;AAEA,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","names":[],"sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n forwardRef,\n useCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_SIZES } from '../../utils/componentSizes';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport {\n INPUT_HORIZONTAL_PADDING_CLASSES,\n INPUT_RADIUS_CLASSES,\n INPUT_TEXT_CLASSES,\n} from '../Input/inputStyles';\nimport type { InputSize } from '../Input/inputStyles';\nimport { Text } from '../Text';\n\nconst DEFAULT_AUTO_RESIZE_MAX_HEIGHT_PX = 200;\n\nexport interface TextareaProps {\n /** First-row metrics. Total height remains intrinsic to rows and content. */\n size?: InputSize;\n /** Left side decorator/icon */\n leftDecorator?: ReactNode;\n /** Right side decorator/icon */\n rightDecorator?: ReactNode;\n /** Whether the textarea is disabled */\n disabled?: boolean;\n /** Whether the textarea has an error state */\n isError?: boolean;\n /** Label text displayed above the textarea */\n label?: string | ReactNode;\n /** Hint text displayed below the textarea */\n hintText?: string;\n /** Current textarea value */\n value?: string;\n /**\n * Update controlled value synchronously. Keep asynchronous persistence in\n * the owner, using useDebouncedCommit when writes must be debounced and ordered.\n */\n onChange: (value: string) => void;\n /** Placeholder text */\n placeholder?: string;\n /** Additional CSS classes */\n className?: string;\n /** Additional CSS classes applied to the inner <textarea> element */\n inputClassName?: string;\n /** Textarea ID for accessibility */\n id?: string;\n /** Whether the field is required */\n required?: boolean;\n /** Auto focus on mount */\n autoFocus?: boolean;\n /** Number of visible rows */\n rows?: number;\n /** Whether the textarea can be resized */\n resize?: 'none' | 'vertical' | 'horizontal' | 'both';\n /** When true, textarea height grows with content up to maxHeight (resize is forced to none) */\n autoResize?: boolean;\n /** Max height in px when autoResize is true (default: 200) */\n maxHeight?: number;\n /** Visual variant: default (bordered container) or plain (borderless, for embedding) */\n variant?: 'default' | 'plain';\n}\n\nexport const Textarea = forwardRef<\n HTMLTextAreaElement,\n TextareaProps &\n Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof TextareaProps>\n>(\n (\n {\n size = 'lg',\n leftDecorator,\n rightDecorator,\n disabled = false,\n isError = false,\n label,\n hintText,\n value,\n onChange,\n placeholder,\n className,\n inputClassName,\n id,\n required = false,\n autoFocus = false,\n rows = 3,\n resize = 'vertical',\n autoResize = false,\n maxHeight = DEFAULT_AUTO_RESIZE_MAX_HEIGHT_PX,\n variant = 'default',\n 'aria-describedby': ariaDescribedBy,\n ...rest\n },\n ref\n ) => {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const hintTextId = `${textareaId}-hint`;\n const describedBy =\n [hintText ? hintTextId : undefined, ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined;\n const [internalValue, setInternalValue] = useState(value);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n // Auto-resize: grow with content up to maxHeight.\n // Run on value change and on element resize (e.g. container width change so text wraps).\n const runAutoResize = useCallback(() => {\n const el = textareaRef.current;\n if (!el || !autoResize) return;\n el.style.height = 'auto';\n const contentHeight = Math.min(el.scrollHeight, maxHeight);\n el.style.height = `${contentHeight}px`;\n el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';\n }, [autoResize, maxHeight]);\n\n useLayoutEffect(() => {\n const el = textareaRef.current;\n if (!el) return;\n if (!autoResize) {\n el.style.height = '';\n el.style.overflowY = '';\n return;\n }\n\n runAutoResize();\n\n const ro = new ResizeObserver(runAutoResize);\n ro.observe(el);\n return () => ro.disconnect();\n }, [autoResize, value, internalValue, runAutoResize]);\n\n const handleTextareaChange = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n const newValue = e.target.value;\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const textareaContainerClasses = cn(\n 'flex w-full gap-space-2',\n variant === 'default' && [\n 'border bg-input transition-[border-color,box-shadow,background-color]',\n CONTROL_SIZES[size].minHeightClassName,\n INPUT_HORIZONTAL_PADDING_CLASSES[size],\n INPUT_RADIUS_CLASSES[size],\n {\n 'py-px': size === 'xs',\n 'py-0.5': size === 'sm',\n 'py-space-1': size === 'md',\n 'py-space-2': size === 'lg',\n },\n 'focus-within:outline-hidden',\n 'border-muted',\n !disabled &&\n !isError &&\n '[&:hover:not(:focus-within)]:border-subtle',\n !disabled &&\n !isError &&\n 'focus-within:border-focus focus-within:shadow-[0_0_0_1px_var(--border-focus)]',\n !disabled &&\n isError &&\n 'border-error-strong focus-within:border-error-strong focus-within:shadow-[0_0_0_1px_var(--border-error-strong)]',\n disabled &&\n 'cursor-not-allowed border-muted bg-input-disabled text-disabled',\n ],\n leftDecorator || rightDecorator ? 'items-start' : 'items-center'\n );\n\n const effectiveResize = autoResize ? 'none' : resize;\n const textareaClasses = cn(\n '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 text-disabled placeholder:text-disabled',\n // Resize handling (autoResize forces none)\n {\n 'resize-none': effectiveResize === 'none',\n 'resize-y': effectiveResize === 'vertical',\n 'resize-x': effectiveResize === 'horizontal',\n resize: effectiveResize === 'both',\n },\n inputClassName\n );\n\n const decoratorClasses = cn(\n 'flex items-center text-tertiary',\n disabled && 'text-disabled',\n {\n 'mt-0': size === 'xs' || size === 'sm',\n 'mt-0.5': size === 'md',\n 'mt-space-1': size === 'lg',\n }\n );\n\n const labelClasses = cn(\n 'mb-space-1 block font-medium text-primary',\n disabled && 'text-disabled'\n );\n\n const hintTextClasses = cn(\n 'mt-space-1 text-xs',\n isError ? 'text-error-secondary' : 'text-tertiary'\n );\n\n const containerClasses = cn('w-full', className);\n\n return (\n <div className={containerClasses}>\n {label && (\n <Text\n as=\"label\"\n htmlFor={textareaId}\n className={labelClasses}\n variant=\"sm\"\n >\n {label}\n {required && (\n <span className=\"ml-space-1 text-error-secondary\">*</span>\n )}\n </Text>\n )}\n\n <div className={textareaContainerClasses}>\n {leftDecorator && (\n <div className={decoratorClasses}>{leftDecorator}</div>\n )}\n\n {/* eslint-disable-next-line react/forbid-elements */}\n <textarea\n ref={mergeRefs([textareaRef, ref])}\n id={textareaId}\n value={value}\n onChange={handleTextareaChange}\n placeholder={placeholder}\n disabled={disabled}\n required={required}\n autoFocus={autoFocus}\n rows={rows}\n aria-describedby={describedBy}\n aria-invalid={isError || undefined}\n className={textareaClasses}\n {...rest}\n />\n\n {rightDecorator && (\n <div className={decoratorClasses}>{rightDecorator}</div>\n )}\n </div>\n\n {hintText && (\n <Text\n id={hintTextId}\n className={hintTextClasses}\n variant=\"xs\"\n weight=\"normal\"\n >\n {hintText}\n </Text>\n )}\n </div>\n );\n }\n);\n\nTextarea.displayName = 'Textarea';\n"],"mappings":";;;;;;;;AAqBA,IAAM,oCAAoC;AAgD1C,IAAa,WAAW,YAMpB,EACE,OAAO,MACP,eACA,gBACA,WAAW,OACX,UAAU,OACV,OACA,UACA,OACA,UACA,aACA,WACA,gBACA,IACA,WAAW,OACX,YAAY,OACZ,OAAO,GACP,SAAS,YACT,aAAa,OACb,YAAY,mCACZ,UAAU,WACV,oBAAoB,iBACpB,GAAG,QAEL,QACG;CACH,MAAM,cAAc,MAAM;CAC1B,MAAM,aAAa,MAAM;CACzB,MAAM,aAAa,GAAG,WAAW;CACjC,MAAM,cACJ,CAAC,WAAW,aAAa,KAAA,GAAW,eAAe,CAAC,CACjD,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,KAAK,KAAA;CAClB,MAAM,CAAC,eAAe,oBAAoB,SAAS,KAAK;CACxD,MAAM,cAAc,OAA4B,IAAI;CAIpD,MAAM,gBAAgB,kBAAkB;EACtC,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,MAAM,CAAC,YAAY;EACxB,GAAG,MAAM,SAAS;EAClB,MAAM,gBAAgB,KAAK,IAAI,GAAG,cAAc,SAAS;EACzD,GAAG,MAAM,SAAS,GAAG,cAAc;EACnC,GAAG,MAAM,YAAY,GAAG,eAAe,YAAY,SAAS;CAC9D,GAAG,CAAC,YAAY,SAAS,CAAC;CAE1B,sBAAsB;EACpB,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,IAAI;EACT,IAAI,CAAC,YAAY;GACf,GAAG,MAAM,SAAS;GAClB,GAAG,MAAM,YAAY;GACrB;EACF;EAEA,cA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AC,OAAD;IAAK,WAAW;IAAhB,UAAA;KACG,iBACC,oBAAC,OAAD;MAAK,WAAW;MAAmB,UAAA;KAAmB,CAAA;KAIxD,oBAAC,YAAD;MACE,KAAK,UAAU,CAAC,aAAa,GAAG,CAAC;MACjC,IAAI;MACG;MACP,UAAU;MACG;MACH;MACA;MACC;MACL;MACN,oBAAkB;MAClB,gBAAc,WAAW,KAAA;MACzB,WAAW;MACX,GAAI;KACL,CAAA;KAEA,kBACC,oBAAC,OAAD;MAAK,WAAW;MAAmB,UAAA;KAAoB,CAAA;IAEtD;;GAEJ,YACC,oBAAC,MAAD;IACE,IAAI;IACJ,WAAW;IACX,SAAQ;IACR,QAAO;IAEN,UAAA;GACG,CAAA;EAEL;;AAET,CACF;AAEA,SAAS,cAAc"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { CheckIcon, XCloseIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
3
|
import zIndices from "../../utils/zIndices.js";
|
|
3
4
|
import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
4
|
-
import { Icon } from "../Icon/Icon.js";
|
|
5
5
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Icon } from "../Icon/Icon.js";
|
|
7
7
|
import { CopyIconButton } from "../CopyButton/CopyButton.js";
|
|
8
8
|
import { ToastContext } from "./ToastContext.js";
|
|
9
9
|
import React, { useCallback } from "react";
|
|
@@ -128,7 +128,7 @@ function Toast({ title, open, setOpen, description, action, error, duration, typ
|
|
|
128
128
|
})]
|
|
129
129
|
});
|
|
130
130
|
return /* @__PURE__ */ jsx(ToastLib.Root, {
|
|
131
|
-
className: cn("flex items-start gap-space-2 rounded-md border p-space-3", surface, "shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px]", "data-[swipe=cancel]:translate-x-0 data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[state=closed]:animate-hide data-[state=open]:animate-slideIn data-[swipe=end]:animate-swipeOut data-[swipe=cancel]:transition-[transform_200ms_ease-out]"),
|
|
131
|
+
className: cn("flex items-start gap-space-2 rounded-md border p-space-3", surface, "shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] dark:shadow-none", "data-[swipe=cancel]:translate-x-0 data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[state=closed]:animate-hide data-[state=open]:animate-slideIn data-[swipe=end]:animate-swipeOut data-[swipe=cancel]:transition-[transform_200ms_ease-out]"),
|
|
132
132
|
open,
|
|
133
133
|
onOpenChange: setOpen,
|
|
134
134
|
duration,
|