@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,7 +1,8 @@
|
|
|
1
|
+
import { CheckIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { Text } from "../Text/Text.js";
|
|
2
|
-
import { Button } from "../Button/Button.js";
|
|
3
3
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Button } from "../Button/Button.js";
|
|
5
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
5
6
|
import { useCopy } from "./useCopy.js";
|
|
6
7
|
import { useState } from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -9,7 +10,9 @@ import { CopySimpleIcon } from "@phosphor-icons/react/dist/ssr/CopySimple";
|
|
|
9
10
|
//#region packages/components/src/components/CopyButton/CopyButton.tsx
|
|
10
11
|
function CopyButton(props) {
|
|
11
12
|
const { copied, onCopy } = useCopy({ copy: props.copy });
|
|
13
|
+
const dataAttributes = pickDataAttributes(props);
|
|
12
14
|
if (props.variant === "icon") return /* @__PURE__ */ jsx(CopyIconButton, {
|
|
15
|
+
...dataAttributes,
|
|
13
16
|
copy: props.copy,
|
|
14
17
|
copyText: props.copyText,
|
|
15
18
|
className: props.className,
|
|
@@ -18,6 +21,7 @@ function CopyButton(props) {
|
|
|
18
21
|
});
|
|
19
22
|
const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;
|
|
20
23
|
return /* @__PURE__ */ jsx(Button, {
|
|
24
|
+
...dataAttributes,
|
|
21
25
|
size: "sm",
|
|
22
26
|
color: "secondary",
|
|
23
27
|
variant: "outlined",
|
|
@@ -90,6 +94,7 @@ function CopyIconButton(props) {
|
|
|
90
94
|
const copyLabel = getCopyLabel(props.copyText, props.label);
|
|
91
95
|
const tooltipTitle = props.copyText ?? copyLabel;
|
|
92
96
|
return /* @__PURE__ */ jsx(IconButton, {
|
|
97
|
+
...pickDataAttributes(props),
|
|
93
98
|
onClick: (e) => {
|
|
94
99
|
e.stopPropagation();
|
|
95
100
|
onCopy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","names":[],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { CopySimpleIcon } from '@phosphor-icons/react/dist/ssr/CopySimple';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport { Button } from '../Button';\nimport { IconButton, type IconButtonProps } from '../IconButton';\nimport { Text } from '../Text';\nimport { useCopy } from './useCopy';\n\nexport interface CopyButtonProps {\n copy: string;\n variant?: 'full' | 'icon';\n className?: string;\n copyText?: string;\n disabled?: boolean;\n onCopy?: () => void;\n}\n\nexport function CopyButton(props: CopyButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n\n if (props.variant === 'icon') {\n return (\n <CopyIconButton\n copy={props.copy}\n copyText={props.copyText}\n className={props.className}\n disabled={props.disabled}\n onCopy={props.onCopy}\n />\n );\n }\n\n const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;\n\n return (\n <Button\n size=\"sm\"\n color=\"secondary\"\n variant=\"outlined\"\n aria-label={copied ? 'Copied' : (props.copyText ?? 'Copy')}\n onClick={(event) => {\n event.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n className={props.className}\n disabled={props.disabled}\n >\n <span className=\"grid\">\n {/* Both states rendered invisibly so the grid cell is always wide enough for either */}\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopySimpleIcon size=\"100%\" weight=\"regular\" />\n </span>\n {props.copyText ?? 'Copy'}\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CheckIcon size=\"100%\" weight=\"regular\" />\n </span>\n Copied\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"col-start-1 row-start-1 flex items-center justify-center gap-1 whitespace-nowrap\"\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopyStatusIcon size=\"100%\" weight=\"regular\" />\n </span>\n {copied ? 'Copied' : (props.copyText ?? 'Copy')}\n </Text>\n </span>\n </Button>\n );\n}\n\nexport interface CopyIconButtonProps {\n copy: string;\n className?: string;\n iconClassName?: string;\n copyText?: ReactNode;\n label?: string;\n disabled?: boolean;\n color?: IconButtonProps['color'];\n size?: IconButtonProps['size'];\n variant?: IconButtonProps['variant'];\n onCopy?: () => void;\n}\n\nfunction getCopyLabel(copyText: ReactNode, label?: string) {\n if (label) return label;\n return typeof copyText === 'string' ? copyText : 'Copy';\n}\n\nexport function CopyIconButton(props: CopyIconButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const [tooltipOpen, setTooltipOpen] = useState(false);\n const copyLabel = getCopyLabel(props.copyText, props.label);\n const tooltipTitle = props.copyText ?? copyLabel;\n\n return (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n disabled={props.disabled}\n icon={copied ? CheckIcon : CopySimpleIcon}\n label={copied ? 'Copied' : copyLabel}\n tooltipProps={{\n title: copied ? 'Copied' : tooltipTitle,\n side: 'top',\n open: tooltipOpen,\n onOpenChange: (open) => {\n if (open) setTooltipOpen(true);\n },\n }}\n variant={props.variant ?? 'plain'}\n color={props.color ?? 'secondary'}\n size={props.size ?? 'sm'}\n className={props.className}\n iconClassName={props.iconClassName}\n onMouseLeave={() => setTooltipOpen(false)}\n onBlur={() => setTooltipOpen(false)}\n />\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CopyButton.js","names":[],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { CopySimpleIcon } from '@phosphor-icons/react/dist/ssr/CopySimple';\n\nimport { CheckIcon } from '../../icons/PaddedPhosphorIcons';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { Button } from '../Button';\nimport { IconButton, type IconButtonProps } from '../IconButton';\nimport { Text } from '../Text';\nimport { useCopy } from './useCopy';\n\nexport interface CopyButtonProps extends DataAttributes {\n copy: string;\n variant?: 'full' | 'icon';\n className?: string;\n copyText?: string;\n disabled?: boolean;\n onCopy?: () => void;\n}\n\nexport function CopyButton(props: CopyButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const dataAttributes = pickDataAttributes(props);\n\n if (props.variant === 'icon') {\n return (\n <CopyIconButton\n {...dataAttributes}\n copy={props.copy}\n copyText={props.copyText}\n className={props.className}\n disabled={props.disabled}\n onCopy={props.onCopy}\n />\n );\n }\n\n const CopyStatusIcon = copied ? CheckIcon : CopySimpleIcon;\n\n return (\n <Button\n {...dataAttributes}\n size=\"sm\"\n color=\"secondary\"\n variant=\"outlined\"\n aria-label={copied ? 'Copied' : (props.copyText ?? 'Copy')}\n onClick={(event) => {\n event.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n className={props.className}\n disabled={props.disabled}\n >\n <span className=\"grid\">\n {/* Both states rendered invisibly so the grid cell is always wide enough for either */}\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopySimpleIcon size=\"100%\" weight=\"regular\" />\n </span>\n {props.copyText ?? 'Copy'}\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"invisible col-start-1 row-start-1 flex items-center gap-1 whitespace-nowrap\"\n aria-hidden\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CheckIcon size=\"100%\" weight=\"regular\" />\n </span>\n Copied\n </Text>\n <Text\n as=\"span\"\n variant=\"sm\"\n weight=\"normal\"\n className=\"col-start-1 row-start-1 flex items-center justify-center gap-1 whitespace-nowrap\"\n >\n <span aria-hidden className=\"inline-flex size-4 shrink-0\">\n <CopyStatusIcon size=\"100%\" weight=\"regular\" />\n </span>\n {copied ? 'Copied' : (props.copyText ?? 'Copy')}\n </Text>\n </span>\n </Button>\n );\n}\n\nexport interface CopyIconButtonProps extends DataAttributes {\n copy: string;\n className?: string;\n iconClassName?: string;\n copyText?: ReactNode;\n label?: string;\n disabled?: boolean;\n color?: IconButtonProps['color'];\n size?: IconButtonProps['size'];\n variant?: IconButtonProps['variant'];\n onCopy?: () => void;\n}\n\nfunction getCopyLabel(copyText: ReactNode, label?: string) {\n if (label) return label;\n return typeof copyText === 'string' ? copyText : 'Copy';\n}\n\nexport function CopyIconButton(props: CopyIconButtonProps) {\n const { copied, onCopy } = useCopy({ copy: props.copy });\n const [tooltipOpen, setTooltipOpen] = useState(false);\n const copyLabel = getCopyLabel(props.copyText, props.label);\n const tooltipTitle = props.copyText ?? copyLabel;\n\n return (\n <IconButton\n {...pickDataAttributes(props)}\n onClick={(e) => {\n e.stopPropagation();\n onCopy();\n props.onCopy?.();\n }}\n disabled={props.disabled}\n icon={copied ? CheckIcon : CopySimpleIcon}\n label={copied ? 'Copied' : copyLabel}\n tooltipProps={{\n title: copied ? 'Copied' : tooltipTitle,\n side: 'top',\n open: tooltipOpen,\n onOpenChange: (open) => {\n if (open) setTooltipOpen(true);\n },\n }}\n variant={props.variant ?? 'plain'}\n color={props.color ?? 'secondary'}\n size={props.size ?? 'sm'}\n className={props.className}\n iconClassName={props.iconClassName}\n onMouseLeave={() => setTooltipOpen(false)}\n onBlur={() => setTooltipOpen(false)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,QAAQ,WAAW,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC;CACvD,MAAM,iBAAiB,mBAAmB,KAAK;CAE/C,IAAI,MAAM,YAAY,QACpB,OACE,oBAAC,gBAAD;EACE,GAAI;EACJ,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,UAAU,MAAM;EAChB,QAAQ,MAAM;CACf,CAAA;CAIL,MAAM,iBAAiB,SAAS,YAAY;CAE5C,OACE,oBAAC,QAAD;EACE,GAAI;EACJ,MAAK;EACL,OAAM;EACN,SAAQ;EACR,cAAY,SAAS,WAAY,MAAM,YAAY;EACnD,UAAU,UAAU;GAClB,MAAM,gBAAgB;GACtB,OAAO;GACP,MAAM,SAAS;EACjB;EACA,WAAW,MAAM;EACjB,UAAU,MAAM;EAEhB,UAAA,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA;IAEE,qBAAC,MAAD;KACE,IAAG;KACH,SAAQ;KACR,QAAO;KACP,WAAU;KACV,eAAA;KALF,UAAA,CAOE,oBAAC,QAAD;MAAM,eAAA;MAAY,WAAU;MAC1B,UAAA,oBAAC,gBAAD;OAAgB,MAAK;OAAO,QAAO;MAAW,CAAA;KAC1C,CAAA,GACL,MAAM,YAAY,MACf;;IACN,qBAAC,MAAD;KACE,IAAG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CACnC,CAAA;AAEL"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react';
|
|
2
2
|
import { DialogClose as RadixDialogClose, DialogDescription as RadixDialogDescription, DialogTitle as RadixDialogTitle, type DialogContentProps as RadixDialogContentProps } from '@radix-ui/react-dialog';
|
|
3
|
+
import { type DataAttributes } from '../../utils/dataAttributes.js';
|
|
4
|
+
export { ModalProvider } from '../../utils/ModalLayerContext.js';
|
|
3
5
|
import type { IconComponent } from '../Icon/index.js';
|
|
4
6
|
/**
|
|
5
7
|
* Exposes the modal DialogContent DOM node to descendants so portaled overlays
|
|
@@ -20,7 +22,7 @@ export type DialogCloseProps = ComponentPropsWithoutRef<typeof RadixDialogClose>
|
|
|
20
22
|
/** Closes the nearest dialog and supports custom controls through `asChild`. */
|
|
21
23
|
export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("@radix-ui/react-dialog").DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
22
24
|
type TitleIconIntent = 'error' | 'warning' | 'info';
|
|
23
|
-
interface DialogContentProps {
|
|
25
|
+
interface DialogContentProps extends DataAttributes {
|
|
24
26
|
title?: ReactNode;
|
|
25
27
|
description?: ReactNode;
|
|
26
28
|
/** Icon component to display in the title area, inside a colored circular container */
|
|
@@ -46,4 +48,3 @@ export declare function Dialog({ open, onOpenChange, children, className, onEsca
|
|
|
46
48
|
onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;
|
|
47
49
|
}): import("react").JSX.Element;
|
|
48
50
|
export declare const DialogContent: import("react").ForwardRefExoticComponent<DialogContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
49
|
-
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { XIcon } 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
4
|
import { useZIndex } from "../../utils/useZIndex.js";
|
|
5
5
|
import { ZIndexProvider } from "../../utils/ZIndexContext.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Text } from "../Text/Text.js";
|
|
7
7
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
8
|
-
import {
|
|
8
|
+
import { Icon } from "../Icon/Icon.js";
|
|
9
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
9
10
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
11
|
+
import { ModalLayerProvider, ModalProvider, useCurrentModalLayer, useModalLayer } from "../../utils/ModalLayerContext.js";
|
|
10
12
|
import { createContext, forwardRef, useContext, useState } from "react";
|
|
11
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
14
|
import { Dialog as Dialog$1, DialogClose as DialogClose$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogOverlay, DialogPortal, DialogTitle as DialogTitle$1 } from "@radix-ui/react-dialog";
|
|
@@ -40,36 +42,61 @@ var DialogClose = forwardRef((props, ref) => /* @__PURE__ */ jsx(DialogClose$1,
|
|
|
40
42
|
...props
|
|
41
43
|
}));
|
|
42
44
|
DialogClose.displayName = "DialogClose";
|
|
45
|
+
var DialogEscapeContext = createContext(void 0);
|
|
43
46
|
function Dialog({ open, onOpenChange, children, className, onEscapeKeyDown }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const layer = useModalLayer(open);
|
|
48
|
+
const zIndex = useZIndex(layer.zIndex ?? zIndices.dialogOverlay);
|
|
49
|
+
return /* @__PURE__ */ jsx(ModalLayerProvider, {
|
|
50
|
+
layer,
|
|
51
|
+
children: /* @__PURE__ */ jsx(DialogEscapeContext.Provider, {
|
|
52
|
+
value: onEscapeKeyDown,
|
|
53
|
+
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
54
|
+
value: zIndex,
|
|
55
|
+
children: /* @__PURE__ */ jsx(Dialog$1, {
|
|
56
|
+
modal: true,
|
|
57
|
+
open: open && !layer.suspended,
|
|
58
|
+
onOpenChange,
|
|
59
|
+
children: /* @__PURE__ */ jsxs(DialogPortal, {
|
|
60
|
+
forceMount: open || void 0,
|
|
61
|
+
children: [/* @__PURE__ */ jsx(DialogOverlay, {
|
|
62
|
+
forceMount: open || void 0,
|
|
63
|
+
className: cn("fixed inset-0 bg-overlay", "data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none", className),
|
|
64
|
+
style: {
|
|
65
|
+
zIndex,
|
|
66
|
+
...layer.backdropStyle,
|
|
67
|
+
display: layer.suspended ? "none" : void 0
|
|
68
|
+
}
|
|
69
|
+
}), children]
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
57
74
|
});
|
|
58
75
|
}
|
|
59
|
-
var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titleIconIntent = "info", showClose = true, children, className, childrenClassName, onPointerDownOutside, onInteractOutside, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onKeyDown }, ref) => {
|
|
76
|
+
var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titleIconIntent = "info", showClose = true, children, className, childrenClassName, onPointerDownOutside, onInteractOutside, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onKeyDown, ...rest }, ref) => {
|
|
60
77
|
const dialogZIndex = useZIndex(zIndices.dialogContent);
|
|
78
|
+
const layer = useCurrentModalLayer();
|
|
79
|
+
const onDialogEscape = useContext(DialogEscapeContext);
|
|
61
80
|
const hasHeader = Boolean(title || description || showClose);
|
|
62
81
|
const [contentNode, setContentNode] = useState(null);
|
|
63
82
|
return /* @__PURE__ */ jsx(DialogContent$1, {
|
|
83
|
+
forceMount: layer?.open || void 0,
|
|
84
|
+
...pickDataAttributes(rest),
|
|
64
85
|
ref: mergeRefs([ref, setContentNode]),
|
|
65
86
|
className: cn("fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background", "fade-in", "data-[state=closed]:fade-out", className),
|
|
66
|
-
style: {
|
|
87
|
+
style: {
|
|
88
|
+
zIndex: dialogZIndex,
|
|
89
|
+
display: layer?.suspended ? "none" : void 0
|
|
90
|
+
},
|
|
67
91
|
onPointerDownOutside,
|
|
68
92
|
onInteractOutside,
|
|
69
93
|
onOpenAutoFocus,
|
|
70
94
|
onCloseAutoFocus,
|
|
71
95
|
onEscapeKeyDown,
|
|
72
|
-
onKeyDown
|
|
96
|
+
onKeyDown: (event) => {
|
|
97
|
+
onKeyDown?.(event);
|
|
98
|
+
if (event.key === "Escape") onDialogEscape?.(event);
|
|
99
|
+
},
|
|
73
100
|
children: /* @__PURE__ */ jsx(ZIndexProvider, {
|
|
74
101
|
value: dialogZIndex,
|
|
75
102
|
children: /* @__PURE__ */ jsxs(DialogContainerContext.Provider, {
|
|
@@ -125,6 +152,6 @@ var DialogContent = forwardRef(({ title, description, titleIcon: TitleIcon, titl
|
|
|
125
152
|
});
|
|
126
153
|
DialogContent.displayName = "DialogContent";
|
|
127
154
|
//#endregion
|
|
128
|
-
export { Dialog, DialogClose, DialogContainerContext, DialogContent, DialogDescription, DialogTitle, useDialogContainer };
|
|
155
|
+
export { Dialog, DialogClose, DialogContainerContext, DialogContent, DialogDescription, DialogTitle, ModalProvider, useDialogContainer };
|
|
129
156
|
|
|
130
157
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dialog/index.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n createContext,\n forwardRef,\n useContext,\n useState,\n} from 'react';\n\nimport {\n DialogClose as RadixDialogClose,\n DialogDescription as RadixDialogDescription,\n DialogOverlay,\n DialogPortal,\n DialogTitle as RadixDialogTitle,\n Dialog as RadixDialog,\n DialogContent as RadixDialogContent,\n type DialogContentProps as RadixDialogContentProps,\n} from '@radix-ui/react-dialog';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Icon } from '../Icon';\nimport type { IconComponent } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\n/**\n * Exposes the modal DialogContent DOM node to descendants so portaled overlays\n * (e.g. Typeahead's Popover) can render inside the dialog. A modal Dialog sets\n * `pointer-events: none` outside DialogContent, so overlays portaled to\n * `document.body` become mouse-inert; portaling into this node keeps them\n * interactive. Null when not inside a Dialog.\n */\n// eslint-disable-next-line react-refresh/only-export-components\nexport const DialogContainerContext = createContext<HTMLElement | null>(null);\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useDialogContainer(): HTMLElement | null {\n return useContext(DialogContainerContext);\n}\n\nexport type DialogTitleProps = ComponentPropsWithoutRef<\n typeof RadixDialogTitle\n>;\n\n/** Associates a custom-composed heading with the dialog content. */\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof RadixDialogTitle>,\n DialogTitleProps\n>((props, ref) => <RadixDialogTitle ref={ref} {...props} />);\nDialogTitle.displayName = 'DialogTitle';\n\nexport type DialogDescriptionProps = ComponentPropsWithoutRef<\n typeof RadixDialogDescription\n>;\n\n/** Associates supporting copy with the dialog content. */\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof RadixDialogDescription>,\n DialogDescriptionProps\n>((props, ref) => <RadixDialogDescription ref={ref} {...props} />);\nDialogDescription.displayName = 'DialogDescription';\n\nexport type DialogCloseProps = ComponentPropsWithoutRef<\n typeof RadixDialogClose\n>;\n\n/** Closes the nearest dialog and supports custom controls through `asChild`. */\nexport const DialogClose = forwardRef<\n ComponentRef<typeof RadixDialogClose>,\n DialogCloseProps\n>((props, ref) => <RadixDialogClose ref={ref} {...props} />);\nDialogClose.displayName = 'DialogClose';\n\ntype TitleIconIntent = 'error' | 'warning' | 'info';\n\ninterface DialogContentProps {\n title?: ReactNode;\n description?: ReactNode;\n /** Icon component to display in the title area, inside a colored circular container */\n titleIcon?: IconComponent;\n /** Controls the background and color of the title icon container */\n titleIconIntent?: TitleIconIntent;\n showClose?: boolean;\n children: ReactNode;\n className?: string;\n childrenClassName?: string;\n onPointerDownOutside?: RadixDialogContentProps['onPointerDownOutside'];\n onInteractOutside?: RadixDialogContentProps['onInteractOutside'];\n onOpenAutoFocus?: RadixDialogContentProps['onOpenAutoFocus'];\n onCloseAutoFocus?: RadixDialogContentProps['onCloseAutoFocus'];\n onEscapeKeyDown?: RadixDialogContentProps['onEscapeKeyDown'];\n onKeyDown?: RadixDialogContentProps['onKeyDown'];\n}\n\nexport function Dialog({\n open,\n onOpenChange,\n children,\n className,\n onEscapeKeyDown,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n className?: string;\n onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;\n}) {\n const zIndex = useZIndex(zIndices.dialogOverlay);\n return (\n <RadixDialog modal={true} open={open} onOpenChange={onOpenChange}>\n <DialogPortal>\n <DialogOverlay\n className={cn(\n 'fixed inset-0 bg-overlay',\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n className\n )}\n style={{ zIndex }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onEscapeKeyDown) {\n onEscapeKeyDown(e);\n }\n }}\n >\n {children}\n </DialogOverlay>\n </DialogPortal>\n </RadixDialog>\n );\n}\n\nexport const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n (\n {\n title,\n description,\n titleIcon: TitleIcon,\n titleIconIntent = 'info',\n showClose = true,\n children,\n className,\n childrenClassName,\n onPointerDownOutside,\n onInteractOutside,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onKeyDown,\n },\n ref\n ) => {\n const dialogZIndex = useZIndex(zIndices.dialogContent);\n const hasHeader = Boolean(title || description || showClose);\n // A modal Dialog sets `pointer-events: none` outside this node, so overlays\n // portaled to `document.body` (e.g. Typeahead's Popover) become mouse-inert.\n // Expose the content node so descendants can portal into it and stay live.\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <RadixDialogContent\n ref={mergeRefs([ref, setContentNode])}\n className={cn(\n 'fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background',\n 'fade-in',\n 'data-[state=closed]:fade-out',\n className\n )}\n style={{ zIndex: dialogZIndex }}\n onPointerDownOutside={onPointerDownOutside}\n onInteractOutside={onInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={onCloseAutoFocus}\n onEscapeKeyDown={onEscapeKeyDown}\n onKeyDown={onKeyDown}\n >\n <ZIndexProvider value={dialogZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n {hasHeader && (\n <div className=\"m-0 min-h-14 shrink-0 p-space-4\">\n <div className=\"flex items-center justify-between gap-space-4\">\n <div className=\"flex min-w-0 items-center gap-space-2\">\n {TitleIcon && (\n <Icon\n icon={TitleIcon}\n color={titleIconIntent}\n size=\"md\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n {title && (\n <DialogTitle asChild>\n <Text variant=\"h3\" weight=\"semibold\">\n {title}\n </Text>\n </DialogTitle>\n )}\n {description && (\n <DialogDescription asChild>\n <Text variant=\"sm\" className=\"text-quaternary\">\n {description}\n </Text>\n </DialogDescription>\n )}\n </div>\n </div>\n {showClose && (\n <DialogClose asChild>\n <IconButton\n icon={XIcon}\n label=\"Close\"\n color=\"secondary\"\n variant=\"plain\"\n className=\"shrink-0 self-start\"\n data-testid=\"dialog-close-button\"\n tooltipProps={{ disabled: true }}\n />\n </DialogClose>\n )}\n </div>\n </div>\n )}\n <div\n className={cn(\n 'flex min-h-0 flex-col gap-space-4 overflow-y-auto p-space-4',\n hasHeader && 'pt-0',\n childrenClassName\n )}\n >\n {children}\n </div>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialogContent>\n );\n }\n);\n\nDialogContent.displayName = 'DialogContent';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,yBAAyB,cAAkC,IAAI;AAG5E,SAAgB,qBAAyC;CACvD,OAAO,WAAW,sBAAsB;AAC1C;;AAOA,IAAa,cAAc,YAGxB,OAAO,QAAQ,oBAAC,eAAD;CAAuB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC3D,YAAY,cAAc;;AAO1B,IAAa,oBAAoB,YAG9B,OAAO,QAAQ,oBAAC,qBAAD;CAA6B;CAAK,GAAI;AAAQ,CAAA,CAAC;AACjE,kBAAkB,cAAc;;AAOhC,IAAa,cAAc,YAGxB,OAAO,QAAQ,oBAAC,eAAD;CAAuB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC3D,YAAY,cAAc;AAuB1B,SAAgB,OAAO,EACrB,MACA,cACA,UACA,WACA,mBAOC;CACD,MAAM,SAAS,UAAU,SAAS,aAAa;CAC/C,OACE,oBAAC,UAAD;EAAa,OAAO;EAAY;EAAoB;EAClD,UAAA,oBAAC,cAAD,EAAA,UACE,oBAAC,eAAD;GACE,WAAW,GACT,4BACA,2GACA,SACF;GACA,OAAO,EAAE,OAAO;GAChB,YAAY,MAAM;IAChB,IAAI,EAAE,QAAQ,YAAY,iBACxB,gBAAgB,CAAC;GAErB;GAEC;EACY,CAAA,EACH,CAAA;CACH,CAAA;AAEjB;AAEA,IAA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,oBAAC,OAAD;KACE,WAAW,GACT,+DACA,aAAa,QACb,iBACF;KAEC;IACE,CAAA,CAC0B;;EACnB,CAAA;CACE,CAAA;AAExB,CACF;AAEA,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Dialog/index.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n createContext,\n forwardRef,\n useContext,\n useState,\n} from 'react';\n\nimport {\n DialogClose as RadixDialogClose,\n DialogDescription as RadixDialogDescription,\n DialogOverlay,\n DialogPortal,\n DialogTitle as RadixDialogTitle,\n Dialog as RadixDialog,\n DialogContent as RadixDialogContent,\n type DialogContentProps as RadixDialogContentProps,\n} from '@radix-ui/react-dialog';\n\nimport { XIcon } from '../../icons/PaddedPhosphorIcons';\nimport { cn } from '../../utils/cn';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport { mergeRefs } from '../../utils/merge-refs';\nimport {\n ModalLayerProvider,\n useCurrentModalLayer,\n useModalLayer,\n} from '../../utils/ModalLayerContext';\nexport { ModalProvider } from '../../utils/ModalLayerContext';\nimport { useZIndex } from '../../utils/useZIndex';\nimport { ZIndexProvider } from '../../utils/ZIndexContext';\nimport zIndices from '../../utils/zIndices';\nimport { Icon } from '../Icon';\nimport type { IconComponent } from '../Icon';\nimport { IconButton } from '../IconButton';\nimport { Text } from '../Text';\n\n/**\n * Exposes the modal DialogContent DOM node to descendants so portaled overlays\n * (e.g. Typeahead's Popover) can render inside the dialog. A modal Dialog sets\n * `pointer-events: none` outside DialogContent, so overlays portaled to\n * `document.body` become mouse-inert; portaling into this node keeps them\n * interactive. Null when not inside a Dialog.\n */\n// eslint-disable-next-line react-refresh/only-export-components\nexport const DialogContainerContext = createContext<HTMLElement | null>(null);\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport function useDialogContainer(): HTMLElement | null {\n return useContext(DialogContainerContext);\n}\n\nexport type DialogTitleProps = ComponentPropsWithoutRef<\n typeof RadixDialogTitle\n>;\n\n/** Associates a custom-composed heading with the dialog content. */\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof RadixDialogTitle>,\n DialogTitleProps\n>((props, ref) => <RadixDialogTitle ref={ref} {...props} />);\nDialogTitle.displayName = 'DialogTitle';\n\nexport type DialogDescriptionProps = ComponentPropsWithoutRef<\n typeof RadixDialogDescription\n>;\n\n/** Associates supporting copy with the dialog content. */\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof RadixDialogDescription>,\n DialogDescriptionProps\n>((props, ref) => <RadixDialogDescription ref={ref} {...props} />);\nDialogDescription.displayName = 'DialogDescription';\n\nexport type DialogCloseProps = ComponentPropsWithoutRef<\n typeof RadixDialogClose\n>;\n\n/** Closes the nearest dialog and supports custom controls through `asChild`. */\nexport const DialogClose = forwardRef<\n ComponentRef<typeof RadixDialogClose>,\n DialogCloseProps\n>((props, ref) => <RadixDialogClose ref={ref} {...props} />);\nDialogClose.displayName = 'DialogClose';\n\nconst DialogEscapeContext = createContext<\n ((event: ReactKeyboardEvent) => void) | undefined\n>(undefined);\n\ntype TitleIconIntent = 'error' | 'warning' | 'info';\n\ninterface DialogContentProps extends DataAttributes {\n title?: ReactNode;\n description?: ReactNode;\n /** Icon component to display in the title area, inside a colored circular container */\n titleIcon?: IconComponent;\n /** Controls the background and color of the title icon container */\n titleIconIntent?: TitleIconIntent;\n showClose?: boolean;\n children: ReactNode;\n className?: string;\n childrenClassName?: string;\n onPointerDownOutside?: RadixDialogContentProps['onPointerDownOutside'];\n onInteractOutside?: RadixDialogContentProps['onInteractOutside'];\n onOpenAutoFocus?: RadixDialogContentProps['onOpenAutoFocus'];\n onCloseAutoFocus?: RadixDialogContentProps['onCloseAutoFocus'];\n onEscapeKeyDown?: RadixDialogContentProps['onEscapeKeyDown'];\n onKeyDown?: RadixDialogContentProps['onKeyDown'];\n}\n\nexport function Dialog({\n open,\n onOpenChange,\n children,\n className,\n onEscapeKeyDown,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n className?: string;\n onEscapeKeyDown?: (e: ReactKeyboardEvent) => void;\n}) {\n const layer = useModalLayer(open);\n const zIndex = useZIndex(layer.zIndex ?? zIndices.dialogOverlay);\n return (\n <ModalLayerProvider layer={layer}>\n <DialogEscapeContext.Provider value={onEscapeKeyDown}>\n <ZIndexProvider value={zIndex}>\n <RadixDialog\n modal={true}\n open={open && !layer.suspended}\n onOpenChange={onOpenChange}\n >\n <DialogPortal forceMount={open || undefined}>\n <DialogOverlay\n forceMount={open || undefined}\n className={cn(\n 'fixed inset-0 bg-overlay',\n 'data-[state=open]:animate-overlay-in data-[state=closed]:animate-overlay-out motion-reduce:animate-none',\n className\n )}\n style={{\n zIndex,\n ...layer.backdropStyle,\n display: layer.suspended ? 'none' : undefined,\n }}\n />\n {children}\n </DialogPortal>\n </RadixDialog>\n </ZIndexProvider>\n </DialogEscapeContext.Provider>\n </ModalLayerProvider>\n );\n}\n\nexport const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(\n (\n {\n title,\n description,\n titleIcon: TitleIcon,\n titleIconIntent = 'info',\n showClose = true,\n children,\n className,\n childrenClassName,\n onPointerDownOutside,\n onInteractOutside,\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onKeyDown,\n ...rest\n },\n ref\n ) => {\n const dialogZIndex = useZIndex(zIndices.dialogContent);\n const layer = useCurrentModalLayer();\n const onDialogEscape = useContext(DialogEscapeContext);\n const hasHeader = Boolean(title || description || showClose);\n // A modal Dialog sets `pointer-events: none` outside this node, so overlays\n // portaled to `document.body` (e.g. Typeahead's Popover) become mouse-inert.\n // Expose the content node so descendants can portal into it and stay live.\n const [contentNode, setContentNode] = useState<HTMLDivElement | null>(null);\n\n return (\n <RadixDialogContent\n forceMount={layer?.open || undefined}\n {...pickDataAttributes(rest)}\n ref={mergeRefs([ref, setContentNode])}\n className={cn(\n 'fixed left-[50%] top-[50%] flex max-h-[calc(100vh-2rem)] w-[37.5rem] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg bg-background',\n 'fade-in',\n 'data-[state=closed]:fade-out',\n className\n )}\n style={{\n zIndex: dialogZIndex,\n display: layer?.suspended ? 'none' : undefined,\n }}\n onPointerDownOutside={onPointerDownOutside}\n onInteractOutside={onInteractOutside}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={onCloseAutoFocus}\n onEscapeKeyDown={onEscapeKeyDown}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') onDialogEscape?.(event);\n }}\n >\n <ZIndexProvider value={dialogZIndex}>\n <DialogContainerContext.Provider value={contentNode}>\n {hasHeader && (\n <div className=\"m-0 min-h-14 shrink-0 p-space-4\">\n <div className=\"flex items-center justify-between gap-space-4\">\n <div className=\"flex min-w-0 items-center gap-space-2\">\n {TitleIcon && (\n <Icon\n icon={TitleIcon}\n color={titleIconIntent}\n size=\"md\"\n />\n )}\n <div className=\"flex min-w-0 flex-col gap-space-1\">\n {title && (\n <DialogTitle asChild>\n <Text variant=\"h3\" weight=\"semibold\">\n {title}\n </Text>\n </DialogTitle>\n )}\n {description && (\n <DialogDescription asChild>\n <Text variant=\"sm\" className=\"text-quaternary\">\n {description}\n </Text>\n </DialogDescription>\n )}\n </div>\n </div>\n {showClose && (\n <DialogClose asChild>\n <IconButton\n icon={XIcon}\n label=\"Close\"\n color=\"secondary\"\n variant=\"plain\"\n className=\"shrink-0 self-start\"\n data-testid=\"dialog-close-button\"\n tooltipProps={{ disabled: true }}\n />\n </DialogClose>\n )}\n </div>\n </div>\n )}\n <div\n className={cn(\n 'flex min-h-0 flex-col gap-space-4 overflow-y-auto p-space-4',\n hasHeader && 'pt-0',\n childrenClassName\n )}\n >\n {children}\n </div>\n </DialogContainerContext.Provider>\n </ZIndexProvider>\n </RadixDialogContent>\n );\n }\n);\n\nDialogContent.displayName = 'DialogContent';\n"],"mappings":";;;;;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,OAAM;QACN,OAAM;QACN,SAAQ;QACR,WAAU;QACV,eAAY;QACZ,cAAc,EAAE,UAAU,KAAK;OAChC,CAAA;MACU,CAAA,CAEZ;;IACF,CAAA,GAEP,oBAAC,OAAD;KACE,WAAW,GACT,+DACA,aAAa,QACb,iBACF;KAEC;IACE,CAAA,CAC0B;;EACnB,CAAA;CACE,CAAA;AAExB,CACF;AAEA,cAAc,cAAc"}
|
|
@@ -112,20 +112,20 @@ 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-hidden transition-colors focus:bg-
|
|
115
|
+
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-elevated-hover 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;
|
|
119
119
|
var DropdownMenuSeparator = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Separator, {
|
|
120
120
|
ref,
|
|
121
|
-
className: cn("my-space-1 h-px
|
|
121
|
+
className: cn("my-space-1 h-px border-b border-subtle", className),
|
|
122
122
|
...props
|
|
123
123
|
}));
|
|
124
124
|
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-hidden transition-colors focus:bg-
|
|
128
|
+
className: cn("flex cursor-pointer select-none items-center rounded-sm px-space-2 py-space-1 outline-hidden transition-colors focus:bg-elevated-hover data-[state=open]:bg-elevated-hover", 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-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,gBAAgB,qBAAqB;EACxD,MAAM,MAAM;EACZ,aAAa,MAAM,eAAe;EAClC,UAAU,MAAM;CAClB,CAAC;CAED,OACE,oBAAC,sBAAsB,MAAvB;EACE,GAAI;EACE;EACQ;EACd,aAAa,KAAA;CACd,CAAA;AAEL;AAEA,IAAa,sBAAsB,sBAAsB;AAEzD,IAAa,qBAAqB,sBAAsB;AAExD,IAAa,oBAAoB,sBAAsB;AAEvD,IAAa,oBAAoB,sBAAsB;;;;;;;;;;;;;;;;;AAkBvD,IAAM,0BAA0B;CAC9B,MAAM,kBACJ,QAAM,OAAsC,KAAA,CAAS;CACvD,MAAM,wBAAwB,QAAM,OAAO,KAAK;CAEhD,QAAM,sBAAsB;EAC1B,aAAa,gBAAgB,OAAO;EACpC,sBAAsB,UAAU;EAEhC,MAAM,aAAa,WACjB,EAAE,kBAAkB,YAAY,CAAC,OAAO,QAAQ,iBAAe;EAIjE,MAAM,iBAAiB,UAAwB;GAC7C,IAAI,UAAU,M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BAAC,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-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 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 border-b border-subtle', 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-elevated-hover data-[state=open]:bg-elevated-hover',\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,gBAAgB,qBAAqB;EACxD,MAAM,MAAM;EACZ,aAAa,MAAM,eAAe;EAClC,UAAU,MAAM;CAClB,CAAC;CAED,OACE,oBAAC,sBAAsB,MAAvB;EACE,GAAI;EACE;EACQ;EACd,aAAa,KAAA;CACd,CAAA;AAEL;AAEA,IAAa,sBAAsB,sBAAsB;AAEzD,IAAa,qBAAqB,sBAAsB;AAExD,IAAa,oBAAoB,sBAAsB;AAEvD,IAAa,oBAAoB,sBAAsB;;;;;;;;;;;;;;;;;AAkBvD,IAAM,0BAA0B;CAC9B,MAAM,kBACJ,QAAM,OAAsC,KAAA,CAAS;CACvD,MAAM,wBAAwB,QAAM,OAAO,KAAK;CAEhD,QAAM,sBAAsB;EAC1B,aAAa,gBAAgB,OAAO;EACpC,sBAAsB,UAAU;EAEhC,MAAM,aAAa,WACjB,EAAE,kBAAkB,YAAY,CAAC,OAAO,QAAQ,iBAAe;EAIjE,MAAM,iBAAiB,UAAwB;GAC7C,IAAI,UAAU,MAAM,MAAM,GAAG,sBAAsB,UAAU;EAC/D;EACA,SAAS,iBAAiB,eAAe,eAAe,IAAI;EAG5D,MAAM,WAAW,UAAsB;GACrC,IAAI,UAAU,MAAM,MAAM,GAAG;IAC3B,MAAM,eAAe;IACrB,MAAM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AAyB,CAAA;CACzB,CAAA,EACN,CAAA;AAElC,CAAC;AACD,uBAAuB,cACrB,sBAAsB,WAAW"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { CaretRightIcon, XCloseIcon } from "../../icons/PaddedPhosphorIcons.js";
|
|
1
2
|
import { cn } from "../../utils/cn.js";
|
|
2
3
|
import { Text } from "../Text/Text.js";
|
|
3
|
-
import { Icon } from "../Icon/Icon.js";
|
|
4
4
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Icon } from "../Icon/Icon.js";
|
|
6
6
|
import { CopyIconButton } from "../CopyButton/CopyButton.js";
|
|
7
7
|
import { prettifyErrorPayload } from "../../utils/prettify-error-payload.js";
|
|
8
8
|
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { ExclamationMarkIcon } from "@phosphor-icons/react/dist/ssr/ExclamationMark";
|
|
11
10
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
11
|
+
import { ExclamationMarkIcon } from "@phosphor-icons/react/dist/ssr/ExclamationMark";
|
|
12
12
|
//#region packages/components/src/components/ErrorMessage/ErrorMessage.tsx
|
|
13
13
|
var sizeStyles = {
|
|
14
14
|
sm: {
|
|
@@ -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
|
import type { IconComponent, IconWeight } from '../../utils/icon-types.js';
|
|
4
5
|
import type { TooltipProps } from '../Tooltip/index.js';
|
|
5
6
|
type GroupedTabsSize = Exclude<ControlSize, 'lg'>;
|
|
@@ -29,6 +30,6 @@ export type GroupedTabsProps<T extends string | number> = {
|
|
|
29
30
|
selectionClassName?: string;
|
|
30
31
|
/** Optional class for the indicator (e.g. to override top/height for custom margins) */
|
|
31
32
|
indicatorClassName?: string;
|
|
32
|
-
};
|
|
33
|
-
export declare const GroupedTabs: <T extends string | number>({ value, onChange, options, className, size, disabled, tooltip, selectionClassName, indicatorClassName, }: GroupedTabsProps<T>) => import("react").JSX.Element;
|
|
33
|
+
} & DataAttributes;
|
|
34
|
+
export declare const GroupedTabs: <T extends string | number>({ value, onChange, options, className, size, disabled, tooltip, selectionClassName, indicatorClassName, ...rest }: GroupedTabsProps<T>) => import("react").JSX.Element;
|
|
34
35
|
export {};
|
|
@@ -2,10 +2,11 @@ import { cn } from "../../utils/cn.js";
|
|
|
2
2
|
import { CONTROL_SIZES } from "../../utils/componentSizes.js";
|
|
3
3
|
import { Text } from "../Text/Text.js";
|
|
4
4
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
5
|
+
import { pickDataAttributes } from "../../utils/dataAttributes.js";
|
|
5
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region packages/components/src/components/GroupedTabs/GroupedTabs.tsx
|
|
8
|
-
var GroupedTabs = ({ value, onChange, options, className, size = "sm", disabled, tooltip, selectionClassName, indicatorClassName }) => {
|
|
9
|
+
var GroupedTabs = ({ value, onChange, options, className, size = "sm", disabled, tooltip, selectionClassName, indicatorClassName, ...rest }) => {
|
|
9
10
|
const containerRef = useRef(null);
|
|
10
11
|
const buttonRefs = useRef([]);
|
|
11
12
|
const [clipState, setClipState] = useState({
|
|
@@ -46,6 +47,7 @@ var GroupedTabs = ({ value, onChange, options, className, size = "sm", disabled,
|
|
|
46
47
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
47
48
|
title: tooltip,
|
|
48
49
|
children: /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
...pickDataAttributes(rest),
|
|
49
51
|
ref: containerRef,
|
|
50
52
|
className: cn("relative box-border flex w-fit border border-subtle bg-surface-level-1 dark:border-muted", CONTROL_SIZES[size].heightClassName, size === "md" ? "p-0.5" : "p-px", size === "xs" ? "gap-px" : "gap-0.5", size === "xs" ? "rounded-[2px]" : size === "sm" ? "rounded-[3px]" : "rounded-sm", className),
|
|
51
53
|
children: [clipState.path && /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupedTabs.js","names":[],"sources":["../../../src/components/GroupedTabs/GroupedTabs.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\nimport type { IconComponent, IconWeight } from '../../utils/icon-types';\nimport { Text } from '../Text';\nimport type { TooltipProps } from '../Tooltip';\nimport { Tooltip } from '../Tooltip';\n\ntype GroupedTabsSize = Exclude<ControlSize, 'lg'>;\n\nexport interface GroupedTabOption<T> {\n display?: ReactNode | ((isActive: boolean) => ReactNode);\n value: T;\n disabled?: boolean;\n tooltip?: string | ReactNode;\n tooltipProps?: Omit<TooltipProps, 'children' | 'title'>;\n icon?: IconComponent;\n iconWeight?: IconWeight;\n leftDecorator?: ReactNode;\n rightDecorator?: ReactNode;\n className?: string;\n textClassName?: string;\n 'aria-label'?: string;\n}\n\nexport type GroupedTabsProps<T extends string | number> = {\n value: T;\n onChange: (value: T) => void;\n options: readonly GroupedTabOption<T>[];\n className?: string;\n /** Exact outer group height: xs=20px, sm=24px, md=32px. */\n size?: GroupedTabsSize;\n disabled?: boolean;\n tooltip?: string | ReactNode;\n selectionClassName?: string;\n /** Optional class for the indicator (e.g. to override top/height for custom margins) */\n indicatorClassName?: string;\n};\n\nexport const GroupedTabs = <T extends string | number>({\n value,\n onChange,\n options,\n className,\n size = 'sm',\n disabled,\n tooltip,\n selectionClassName,\n indicatorClassName,\n}: GroupedTabsProps<T>) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const [clipState, setClipState] = useState<{\n path: string;\n isFirst: boolean;\n shouldAnimate: boolean;\n }>({ path: '', isFirst: true, shouldAnimate: false });\n const activeIndex = useMemo(\n () => options.findIndex((option) => option.value === value),\n [options, value]\n );\n\n const updateClipState = useCallback(\n (\n container: HTMLDivElement,\n activeButton: HTMLButtonElement,\n shouldAnimate: boolean\n ) => {\n const containerRect = container.getBoundingClientRect();\n const buttonRect = activeButton.getBoundingClientRect();\n const roundValue = size === 'xs' ? '1px' : size === 'sm' ? '2px' : '4px';\n\n const top = buttonRect.top - containerRect.top - container.clientTop;\n const bottom =\n containerRect.bottom - buttonRect.bottom - container.clientTop;\n const left = buttonRect.left - containerRect.left - container.clientLeft;\n const right =\n containerRect.right - buttonRect.right - container.clientLeft;\n\n const path = `inset(${top}px ${right}px ${bottom}px ${left}px round ${roundValue})`;\n setClipState((prev) =>\n prev.path === path\n ? prev\n : {\n path,\n isFirst: false,\n shouldAnimate: shouldAnimate && !prev.isFirst,\n }\n );\n },\n [size]\n );\n\n useEffect(() => {\n const container = containerRef.current;\n const activeButton = buttonRefs.current[activeIndex];\n if (!activeButton || !container) return;\n\n updateClipState(container, activeButton, true);\n\n const observer = new ResizeObserver(() =>\n updateClipState(container, activeButton, false)\n );\n observer.observe(container);\n observer.observe(activeButton);\n\n return () => observer.disconnect();\n }, [activeIndex, updateClipState, value]);\n\n const isActive = (option: GroupedTabOption<T>) => option.value === value;\n return (\n <Tooltip title={tooltip}>\n <div\n ref={containerRef}\n className={cn(\n 'relative box-border flex w-fit border border-subtle bg-surface-level-1 dark:border-muted',\n CONTROL_SIZES[size].heightClassName,\n size === 'md' ? 'p-0.5' : 'p-px',\n size === 'xs' ? 'gap-px' : 'gap-0.5',\n size === 'xs'\n ? 'rounded-[2px]'\n : size === 'sm'\n ? 'rounded-[3px]'\n : 'rounded-sm',\n className\n )}\n >\n {/* Clip-path animated background indicator */}\n {clipState.path && (\n <div\n aria-hidden\n className={cn(\n 'pointer-events-none absolute inset-0 bg-surface-level-4',\n selectionClassName,\n indicatorClassName\n )}\n style={{\n clipPath: clipState.path,\n transition: clipState.shouldAnimate\n ? 'clip-path 0.25s ease-out, background-color 0.25s ease-out'\n : 'none',\n }}\n />\n )}\n\n {options.map((option, idx) => (\n <Tooltip\n key={option.value}\n title={option.tooltip}\n {...option.tooltipProps}\n >\n {/* eslint-disable-next-line react/forbid-elements */}\n <button\n ref={(el) => {\n buttonRefs.current[idx] = el;\n }}\n type=\"button\"\n aria-label={option['aria-label']}\n onClick={() => onChange(option.value)}\n disabled={option.disabled || disabled}\n className={cn(\n 'relative flex h-full items-center gap-space-1',\n 'transition-colors duration-fast',\n {\n 'rounded-xs px-space-1': size === 'xs',\n 'rounded-xs px-space-2': size === 'sm',\n 'rounded-sm px-space-2': size === 'md',\n },\n {\n 'text-primary': isActive(option),\n 'text-secondary hover:bg-surface-level-1-hover':\n !isActive(option),\n },\n (option.disabled || disabled) &&\n 'text-disabled hover:bg-transparent',\n option.className\n )}\n >\n {option.icon && (\n <option.icon\n aria-hidden\n className={size === 'xs' ? 'size-3' : 'size-4'}\n weight={option.iconWeight}\n />\n )}\n {option.leftDecorator}\n {option.display &&\n (typeof option.display === 'function' ? (\n option.display(isActive(option))\n ) : (\n <Text\n variant={size === 'xs' ? 'xs' : 'sm'}\n className={cn('font-medium', option.textClassName)}\n >\n {option.display}\n </Text>\n ))}\n {option.rightDecorator}\n </button>\n </Tooltip>\n ))}\n </div>\n </Tooltip>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupedTabs.js","names":[],"sources":["../../../src/components/GroupedTabs/GroupedTabs.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { CONTROL_SIZES, type ControlSize } from '../../utils/componentSizes';\nimport {\n type DataAttributes,\n pickDataAttributes,\n} from '../../utils/dataAttributes';\nimport type { IconComponent, IconWeight } from '../../utils/icon-types';\nimport { Text } from '../Text';\nimport type { TooltipProps } from '../Tooltip';\nimport { Tooltip } from '../Tooltip';\n\ntype GroupedTabsSize = Exclude<ControlSize, 'lg'>;\n\nexport interface GroupedTabOption<T> {\n display?: ReactNode | ((isActive: boolean) => ReactNode);\n value: T;\n disabled?: boolean;\n tooltip?: string | ReactNode;\n tooltipProps?: Omit<TooltipProps, 'children' | 'title'>;\n icon?: IconComponent;\n iconWeight?: IconWeight;\n leftDecorator?: ReactNode;\n rightDecorator?: ReactNode;\n className?: string;\n textClassName?: string;\n 'aria-label'?: string;\n}\n\nexport type GroupedTabsProps<T extends string | number> = {\n value: T;\n onChange: (value: T) => void;\n options: readonly GroupedTabOption<T>[];\n className?: string;\n /** Exact outer group height: xs=20px, sm=24px, md=32px. */\n size?: GroupedTabsSize;\n disabled?: boolean;\n tooltip?: string | ReactNode;\n selectionClassName?: string;\n /** Optional class for the indicator (e.g. to override top/height for custom margins) */\n indicatorClassName?: string;\n} & DataAttributes;\n\nexport const GroupedTabs = <T extends string | number>({\n value,\n onChange,\n options,\n className,\n size = 'sm',\n disabled,\n tooltip,\n selectionClassName,\n indicatorClassName,\n ...rest\n}: GroupedTabsProps<T>) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const [clipState, setClipState] = useState<{\n path: string;\n isFirst: boolean;\n shouldAnimate: boolean;\n }>({ path: '', isFirst: true, shouldAnimate: false });\n const activeIndex = useMemo(\n () => options.findIndex((option) => option.value === value),\n [options, value]\n );\n\n const updateClipState = useCallback(\n (\n container: HTMLDivElement,\n activeButton: HTMLButtonElement,\n shouldAnimate: boolean\n ) => {\n const containerRect = container.getBoundingClientRect();\n const buttonRect = activeButton.getBoundingClientRect();\n const roundValue = size === 'xs' ? '1px' : size === 'sm' ? '2px' : '4px';\n\n const top = buttonRect.top - containerRect.top - container.clientTop;\n const bottom =\n containerRect.bottom - buttonRect.bottom - container.clientTop;\n const left = buttonRect.left - containerRect.left - container.clientLeft;\n const right =\n containerRect.right - buttonRect.right - container.clientLeft;\n\n const path = `inset(${top}px ${right}px ${bottom}px ${left}px round ${roundValue})`;\n setClipState((prev) =>\n prev.path === path\n ? prev\n : {\n path,\n isFirst: false,\n shouldAnimate: shouldAnimate && !prev.isFirst,\n }\n );\n },\n [size]\n );\n\n useEffect(() => {\n const container = containerRef.current;\n const activeButton = buttonRefs.current[activeIndex];\n if (!activeButton || !container) return;\n\n updateClipState(container, activeButton, true);\n\n const observer = new ResizeObserver(() =>\n updateClipState(container, activeButton, false)\n );\n observer.observe(container);\n observer.observe(activeButton);\n\n return () => observer.disconnect();\n }, [activeIndex, updateClipState, value]);\n\n const isActive = (option: GroupedTabOption<T>) => option.value === value;\n return (\n <Tooltip title={tooltip}>\n <div\n {...pickDataAttributes(rest)}\n ref={containerRef}\n className={cn(\n 'relative box-border flex w-fit border border-subtle bg-surface-level-1 dark:border-muted',\n CONTROL_SIZES[size].heightClassName,\n size === 'md' ? 'p-0.5' : 'p-px',\n size === 'xs' ? 'gap-px' : 'gap-0.5',\n size === 'xs'\n ? 'rounded-[2px]'\n : size === 'sm'\n ? 'rounded-[3px]'\n : 'rounded-sm',\n className\n )}\n >\n {/* Clip-path animated background indicator */}\n {clipState.path && (\n <div\n aria-hidden\n className={cn(\n 'pointer-events-none absolute inset-0 bg-surface-level-4',\n selectionClassName,\n indicatorClassName\n )}\n style={{\n clipPath: clipState.path,\n transition: clipState.shouldAnimate\n ? 'clip-path 0.25s ease-out, background-color 0.25s ease-out'\n : 'none',\n }}\n />\n )}\n\n {options.map((option, idx) => (\n <Tooltip\n key={option.value}\n title={option.tooltip}\n {...option.tooltipProps}\n >\n {/* eslint-disable-next-line react/forbid-elements */}\n <button\n ref={(el) => {\n buttonRefs.current[idx] = el;\n }}\n type=\"button\"\n aria-label={option['aria-label']}\n onClick={() => onChange(option.value)}\n disabled={option.disabled || disabled}\n className={cn(\n 'relative flex h-full items-center gap-space-1',\n 'transition-colors duration-fast',\n {\n 'rounded-xs px-space-1': size === 'xs',\n 'rounded-xs px-space-2': size === 'sm',\n 'rounded-sm px-space-2': size === 'md',\n },\n {\n 'text-primary': isActive(option),\n 'text-secondary hover:bg-surface-level-1-hover':\n !isActive(option),\n },\n (option.disabled || disabled) &&\n 'text-disabled hover:bg-transparent',\n option.className\n )}\n >\n {option.icon && (\n <option.icon\n aria-hidden\n className={size === 'xs' ? 'size-3' : 'size-4'}\n weight={option.iconWeight}\n />\n )}\n {option.leftDecorator}\n {option.display &&\n (typeof option.display === 'function' ? (\n option.display(isActive(option))\n ) : (\n <Text\n variant={size === 'xs' ? 'xs' : 'sm'}\n className={cn('font-medium', option.textClassName)}\n >\n {option.display}\n </Text>\n ))}\n {option.rightDecorator}\n </button>\n </Tooltip>\n ))}\n </div>\n </Tooltip>\n );\n};\n"],"mappings":";;;;;;;;AA6CA,IAAa,eAA0C,EACrD,OACA,UACA,SACA,WACA,OAAO,MACP,UACA,SACA,oBACA,oBACA,GAAG,WACsB;CACzB,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,aAAa,OAAqC,CAAC,CAAC;CAC1D,MAAM,CAAC,WAAW,gBAAgB,SAI/B;EAAE,MAAM;EAAI,SAAS;EAAM,eAAe;CAAM,CAAC;CACpD,MAAM,cAAc,cACZ,QAAQ,WAAW,WAAW,OAAO,UAAU,KAAK,GAC1D,CAAC,SAAS,KAAK,CACjB;CAEA,MAAM,kBAAkB,aAEpB,WACA,cACA,kBACG;EACH,MAAM,gBAAgB,UAAU,sBAAsB;EACtD,MAAM,aAAa,aAAa,sBAAsB;EACtD,MAAM,aAAa,SAAS,OAAO,QAAQ,SAAS,OAAO,QAAQ;EAEnE,MAAM,MAAM,WAAW,MAAM,cAAc,MAAM,UAAU;EAC3D,MAAM,SACJ,cAAc,SAAS,WAAW,SAAS,UAAU;EACvD,MAAM,OAAO,WAAW,OAAO,cAAc,OAAO,UAAU;EAI9D,MAAM,OAAO,SAAS,IAAI,KAFxB,cAAc,QAAQ,WAAW,QAAQ,UAAU,WAEhB,KAA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,yBAAyB,SAAS;KACpC,GACA;MACE,gBAAgB,SAAS,MAAM;MAC/B,iDACE,CAAC,SAAS,MAAM;KACpB,IACC,OAAO,YAAY,aAClB,sCACF,OAAO,SACT;KAxBF,UAAA;MA0BG,OAAO,QACN,oBAAC,OAAO,MAAR;OACE,eAAA;OACA,WAAW,SAAS,OAAO,WAAW;OACtC,QAAQ,OAAO;MAChB,CAAA;MAEF,OAAO;MACP,OAAO,YACL,OAAO,OAAO,YAAY,aACzB,OAAO,QAAQ,SAAS,MAAM,CAAC,IAE/B,oBAAC,MAAD;OACE,SAAS,SAAS,OAAO,OAAO;OAChC,WAAW,GAAG,eAAe,OAAO,aAAa;OAEhD,UAAA,OAAO;MACJ,CAAA;MAET,OAAO;KACF;;GACD,GApDF,OAAO,KAoDL,CACV,CACE;;CACE,CAAA;AAEb"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { CONTROL_SIZES } from "../../utils/componentSizes.js";
|
|
3
|
-
import { Spinner } from "../Spinner/Spinner.js";
|
|
4
|
-
import { buttonStyleMap } from "../Button/constants.js";
|
|
5
3
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
4
|
+
import { buttonStyleMap } from "../Button/constants.js";
|
|
5
|
+
import { Spinner } from "../Spinner/Spinner.js";
|
|
6
6
|
import { cloneElement, forwardRef, isValidElement } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region packages/components/src/components/IconButton/IconButton.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { Text } from "../Text/Text.js";
|
|
3
|
-
import { Icon } from "../Icon/Icon.js";
|
|
4
3
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
4
|
+
import { Icon } from "../Icon/Icon.js";
|
|
5
5
|
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
6
6
|
import { CONTROL_ICON_SIZES } from "../../utils/controlIconSizes.js";
|
|
7
7
|
import { INPUT_TEXT_CLASSES, getInputContainerClasses, getInputElementClasses } from "./inputStyles.js";
|
|
@@ -33,19 +33,19 @@ function InputIconSlot({ icon, action, size, disabled }) {
|
|
|
33
33
|
weight: "regular"
|
|
34
34
|
}) : null;
|
|
35
35
|
}
|
|
36
|
-
function FileSelection({ size, fileNames, placeholder }) {
|
|
36
|
+
function FileSelection({ size, fileNames, placeholder, disabled }) {
|
|
37
37
|
const summary = fileNames.length > 1 ? `${fileNames.length} files selected` : fileNames[0];
|
|
38
38
|
const textClasses = INPUT_TEXT_CLASSES[size];
|
|
39
39
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {
|
|
40
40
|
"aria-hidden": true,
|
|
41
41
|
as: "span",
|
|
42
|
-
className: cn(textClasses, "min-w-0 flex-1 truncate", summary ? "text-primary" : "text-placeholder"),
|
|
42
|
+
className: cn(textClasses, "min-w-0 flex-1 truncate", summary ? "text-primary" : "text-placeholder", disabled && "text-disabled"),
|
|
43
43
|
children: summary ?? placeholder ?? "No file selected"
|
|
44
44
|
}), /* @__PURE__ */ jsx(Text, {
|
|
45
45
|
"aria-hidden": true,
|
|
46
46
|
as: "span",
|
|
47
47
|
weight: "medium",
|
|
48
|
-
className: cn(textClasses, "shrink-0 text-secondary"),
|
|
48
|
+
className: cn(textClasses, "shrink-0 text-secondary", disabled && "text-disabled"),
|
|
49
49
|
children: "Browse"
|
|
50
50
|
})] });
|
|
51
51
|
}
|
|
@@ -177,14 +177,15 @@ var Input = forwardRef(({ size = "lg", variant = "outlined", leftIcon, rightIcon
|
|
|
177
177
|
onClick: isFileInput ? openFilePicker : void 0,
|
|
178
178
|
children: [
|
|
179
179
|
effectiveLeftDecorator && /* @__PURE__ */ jsx("div", {
|
|
180
|
-
className: "flex items-center text-tertiary",
|
|
180
|
+
className: cn("flex items-center text-tertiary", disabled && "text-disabled"),
|
|
181
181
|
style: { marginInlineStart: leftActionOffset },
|
|
182
182
|
children: effectiveLeftDecorator
|
|
183
183
|
}),
|
|
184
184
|
isFileInput && /* @__PURE__ */ jsx(FileSelection, {
|
|
185
185
|
size,
|
|
186
186
|
fileNames: selectedFileNames,
|
|
187
|
-
placeholder
|
|
187
|
+
placeholder,
|
|
188
|
+
disabled
|
|
188
189
|
}),
|
|
189
190
|
isDateInput ? /* @__PURE__ */ jsxs("div", {
|
|
190
191
|
className: cn("relative flex min-w-0 flex-1 items-center", CONTROL_ICON_SIZES[size].sizeVariableClassName),
|
|
@@ -198,7 +199,7 @@ var Input = forwardRef(({ size = "lg", variant = "outlined", leftIcon, rightIcon
|
|
|
198
199
|
})]
|
|
199
200
|
}) : nativeInput,
|
|
200
201
|
effectiveRightDecorator && /* @__PURE__ */ jsx("div", {
|
|
201
|
-
className: cn("flex items-center text-tertiary", "gap-space-1"),
|
|
202
|
+
className: cn("flex items-center text-tertiary", "gap-space-1", disabled && "text-disabled"),
|
|
202
203
|
style: { marginInlineEnd: rightActionOffset },
|
|
203
204
|
children: effectiveRightDecorator
|
|
204
205
|
})
|