@karakuri-ui/react 0.3.10 → 0.3.12
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/components/ui/accordion.d.mts +1 -1
- package/dist/components/ui/accordion.d.ts +1 -1
- package/dist/components/ui/alert.d.mts +2 -0
- package/dist/components/ui/alert.d.ts +2 -0
- package/dist/components/ui/alert.js +2 -1
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/alert.mjs +2 -1
- package/dist/components/ui/alert.mjs.map +1 -1
- package/dist/components/ui/badge.d.mts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.js +54 -43
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/badge.mjs +55 -44
- package/dist/components/ui/badge.mjs.map +1 -1
- package/dist/components/ui/button.js +31 -20
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/button.mjs +31 -20
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/chart.d.mts +1 -1
- package/dist/components/ui/chart.d.ts +1 -1
- package/dist/components/ui/drawer.d.mts +2 -0
- package/dist/components/ui/drawer.d.ts +2 -0
- package/dist/components/ui/drawer.js +2 -2
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/drawer.mjs +2 -2
- package/dist/components/ui/drawer.mjs.map +1 -1
- package/dist/components/ui/dropdown.js +35 -18
- package/dist/components/ui/dropdown.js.map +1 -1
- package/dist/components/ui/dropdown.mjs +35 -18
- package/dist/components/ui/dropdown.mjs.map +1 -1
- package/dist/components/ui/icon-button.js +24 -13
- package/dist/components/ui/icon-button.js.map +1 -1
- package/dist/components/ui/icon-button.mjs +24 -13
- package/dist/components/ui/icon-button.mjs.map +1 -1
- package/dist/components/ui/modal.d.mts +2 -0
- package/dist/components/ui/modal.d.ts +2 -0
- package/dist/components/ui/modal.js +2 -2
- package/dist/components/ui/modal.js.map +1 -1
- package/dist/components/ui/modal.mjs +2 -2
- package/dist/components/ui/modal.mjs.map +1 -1
- package/dist/components/ui/navigation-menu.js +25 -11
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/navigation-menu.mjs +25 -11
- package/dist/components/ui/navigation-menu.mjs.map +1 -1
- package/dist/components/ui/popover.d.mts +2 -0
- package/dist/components/ui/popover.d.ts +2 -0
- package/dist/components/ui/popover.js +2 -2
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/popover.mjs +2 -2
- package/dist/components/ui/popover.mjs.map +1 -1
- package/dist/components/ui/segmented.js +3 -1
- package/dist/components/ui/segmented.js.map +1 -1
- package/dist/components/ui/segmented.mjs +3 -1
- package/dist/components/ui/segmented.mjs.map +1 -1
- package/dist/components/ui/select.js +16 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/select.mjs +16 -1
- package/dist/components/ui/select.mjs.map +1 -1
- package/dist/components/ui/toast.d.mts +3 -1
- package/dist/components/ui/toast.d.ts +3 -1
- package/dist/components/ui/toast.js +4 -1
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toast.mjs +4 -1
- package/dist/components/ui/toast.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -101,6 +101,16 @@ const buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
|
+
const REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
105
|
+
function renderInsideChild(children, render) {
|
|
106
|
+
let child = children;
|
|
107
|
+
const resolve = React.use;
|
|
108
|
+
if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE && typeof resolve === "function") {
|
|
109
|
+
child = resolve(child._payload);
|
|
110
|
+
}
|
|
111
|
+
if (!React.isValidElement(child)) return render(children);
|
|
112
|
+
return React.cloneElement(child, void 0, render(child.props.children));
|
|
113
|
+
}
|
|
104
114
|
const Button = React.forwardRef(
|
|
105
115
|
({
|
|
106
116
|
className,
|
|
@@ -144,6 +154,26 @@ const Button = React.forwardRef(
|
|
|
144
154
|
// icon-only → 20px
|
|
145
155
|
}[size || "default"];
|
|
146
156
|
const selectedStyles = selected ? variant === "outline" ? "bg-background-muted" : variant === "ghost" ? "font-semibold" : "" : "";
|
|
157
|
+
const renderContent = (content) => loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
159
|
+
"svg",
|
|
160
|
+
{
|
|
161
|
+
className: (0, import_utils.cn)(iconSizeClass, "animate-spin"),
|
|
162
|
+
fill: "none",
|
|
163
|
+
viewBox: "0 0 24 24",
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: content })
|
|
172
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
173
|
+
leftIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_utils.cn)(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: leftIcon }),
|
|
174
|
+
content,
|
|
175
|
+
rightIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_utils.cn)(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: rightIcon })
|
|
176
|
+
] });
|
|
147
177
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
178
|
Comp,
|
|
149
179
|
{
|
|
@@ -153,26 +183,7 @@ const Button = React.forwardRef(
|
|
|
153
183
|
"aria-busy": loading || void 0,
|
|
154
184
|
"aria-pressed": selected || void 0,
|
|
155
185
|
...props,
|
|
156
|
-
children:
|
|
157
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
158
|
-
"svg",
|
|
159
|
-
{
|
|
160
|
-
className: (0, import_utils.cn)(iconSizeClass, "animate-spin"),
|
|
161
|
-
fill: "none",
|
|
162
|
-
viewBox: "0 0 24 24",
|
|
163
|
-
"aria-hidden": "true",
|
|
164
|
-
children: [
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
166
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children })
|
|
171
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
172
|
-
leftIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_utils.cn)(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: leftIcon }),
|
|
173
|
-
children,
|
|
174
|
-
rightIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_utils.cn)(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: rightIcon })
|
|
175
|
-
] })
|
|
186
|
+
children: asChild ? renderInsideChild(children, renderContent) : renderContent(children)
|
|
176
187
|
}
|
|
177
188
|
);
|
|
178
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/button.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useButtonGroup } from './button-group'\n\n// Solid color maps (applied when variant=\"solid\")\nconst solidColorMap = {\n default: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',\n primary: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active',\n destructive: 'bg-error text-error-foreground hover:bg-error-hover active:bg-error-active',\n} as const\n\nexport type ButtonColor = keyof typeof solidColorMap\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n solid: 'font-semibold',\n outline: 'border border-border-form bg-background text-foreground hover:bg-background-muted font-normal',\n ghost: 'text-foreground hover:bg-background-muted font-normal',\n link: 'text-text-link underline-offset-4 hover:underline font-normal',\n },\n size: {\n xs: 'h-7 px-2.5 text-xs gap-1', // 28px height, 10px paddingX, 12px font\n sm: 'h-8 px-3 text-sm gap-2', // 32px height, 12px paddingX, 13px font\n md: 'h-9 px-3.5 text-md gap-2', // 36px height, 14px paddingX, 14px font\n default: 'h-10 px-4 text-md gap-2', // 40px height, 16px paddingX, 14px font\n lg: 'h-12 px-6 text-base gap-2', // 48px height, 24px paddingX, 16px font\n icon: 'h-10 w-10',\n },\n radius: {\n none: 'rounded-none', // 0px - primitive.borderRadius.none\n sm: 'rounded-sm', // 2px - primitive.borderRadius.sm\n base: 'rounded', // 4px - primitive.borderRadius.base\n default: 'rounded-md', // 6px - primitive.borderRadius.md (Figma button default)\n lg: 'rounded-lg', // 8px - primitive.borderRadius.lg\n xl: 'rounded-xl', // 12px - primitive.borderRadius.xl\n '2xl': 'rounded-2xl', // 16px - primitive.borderRadius.2xl\n '3xl': 'rounded-3xl', // 24px - primitive.borderRadius.3xl\n full: 'rounded-full', // 9999px - primitive.borderRadius.full\n },\n fullWidth: {\n true: 'w-full',\n false: 'w-auto',\n },\n },\n defaultVariants: {\n variant: 'solid',\n size: 'default',\n radius: 'default',\n fullWidth: false,\n },\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Solid variant color */\n color?: ButtonColor\n asChild?: boolean\n loading?: boolean\n leftIcon?: React.ReactNode\n rightIcon?: React.ReactNode\n selected?: boolean\n fontWeight?: 'normal' | 'semibold'\n pressEffect?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({\n className,\n variant: variantProp,\n color: colorProp,\n size: sizeProp,\n radius: radiusProp,\n fullWidth,\n asChild = false,\n loading = false,\n disabled: disabledProp,\n leftIcon,\n rightIcon,\n selected = false,\n fontWeight: fontWeightProp,\n pressEffect,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'button'\n const groupContext = useButtonGroup()\n\n // Use context values as fallback, individual props take precedence\n const variant = variantProp ?? groupContext?.variant ?? 'solid'\n const color = colorProp ?? 'default'\n const size = sizeProp ?? groupContext?.size\n const radius = radiusProp ?? groupContext?.radius\n const disabled = disabledProp ?? groupContext?.disabled\n\n // Priority: direct prop > ButtonGroup context > variant default (no class)\n const fontWeight = fontWeightProp ?? groupContext?.fontWeight\n\n // FontWeight class (overrides variant default)\n const fontWeightClass = fontWeight === 'normal' ? 'font-normal' : fontWeight === 'semibold' ? 'font-semibold' : ''\n\n // Icon size for button with text (5-step scale)\n // xs~sm: 14px, md~default~lg: 16px\n const iconSizeClass = {\n xs: 'icon-xs', // 14px\n sm: 'icon-xs', // 14px\n md: 'icon-sm', // 16px\n default: 'icon-sm', // 16px\n lg: 'icon-sm', // 16px\n icon: 'icon-md', // icon-only → 20px\n }[size || 'default']\n\n // Selected styles by variant (used in ButtonGroup)\n const selectedStyles = selected ? (\n variant === 'outline' ? 'bg-background-muted' :\n variant === 'ghost' ? 'font-semibold' : ''\n ) : ''\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, radius, fullWidth }), variant === 'solid' && solidColorMap[color], pressEffect !== false && 'active:scale-pressed', fontWeightClass, selectedStyles, className)}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n aria-pressed={selected || undefined}\n {...props}\n >\n {loading ? (\n <>\n <svg\n className={cn(iconSizeClass, 'animate-spin')}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n <span>{children}</span>\n </>\n ) : (\n <>\n {leftIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{leftIcon}</span>}\n {children}\n {rightIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{rightIcon}</span>}\n </>\n )}\n </Comp>\n )\n }\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyIU;AAvIV,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,mBAAmB;AACnB,0BAA+B;AAG/B,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAA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Ae,+BAA+B,GAAG,eAAY,QAAQ,qBAAU;AAAA,WACnH;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/button.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useButtonGroup } from './button-group'\n\n// Solid color maps (applied when variant=\"solid\")\nconst solidColorMap = {\n default: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',\n primary: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active',\n destructive: 'bg-error text-error-foreground hover:bg-error-hover active:bg-error-active',\n} as const\n\nexport type ButtonColor = keyof typeof solidColorMap\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n solid: 'font-semibold',\n outline: 'border border-border-form bg-background text-foreground hover:bg-background-muted font-normal',\n ghost: 'text-foreground hover:bg-background-muted font-normal',\n link: 'text-text-link underline-offset-4 hover:underline font-normal',\n },\n size: {\n xs: 'h-7 px-2.5 text-xs gap-1', // 28px height, 10px paddingX, 12px font\n sm: 'h-8 px-3 text-sm gap-2', // 32px height, 12px paddingX, 13px font\n md: 'h-9 px-3.5 text-md gap-2', // 36px height, 14px paddingX, 14px font\n default: 'h-10 px-4 text-md gap-2', // 40px height, 16px paddingX, 14px font\n lg: 'h-12 px-6 text-base gap-2', // 48px height, 24px paddingX, 16px font\n icon: 'h-10 w-10',\n },\n radius: {\n none: 'rounded-none', // 0px - primitive.borderRadius.none\n sm: 'rounded-sm', // 2px - primitive.borderRadius.sm\n base: 'rounded', // 4px - primitive.borderRadius.base\n default: 'rounded-md', // 6px - primitive.borderRadius.md (Figma button default)\n lg: 'rounded-lg', // 8px - primitive.borderRadius.lg\n xl: 'rounded-xl', // 12px - primitive.borderRadius.xl\n '2xl': 'rounded-2xl', // 16px - primitive.borderRadius.2xl\n '3xl': 'rounded-3xl', // 24px - primitive.borderRadius.3xl\n full: 'rounded-full', // 9999px - primitive.borderRadius.full\n },\n fullWidth: {\n true: 'w-full',\n false: 'w-auto',\n },\n },\n defaultVariants: {\n variant: 'solid',\n size: 'default',\n radius: 'default',\n fullWidth: false,\n },\n }\n)\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\n// asChild: Slot merges props only into a single child element, so icons and\n// wrappers must go inside that child, not next to it. Lazy children (from\n// Server Components) are resolved the same way Radix Slot does.\nfunction renderInsideChild(\n children: React.ReactNode,\n render: (content: React.ReactNode) => React.ReactNode\n): React.ReactNode {\n let child: unknown = children\n const resolve = (React as { use?: (usable: unknown) => unknown }).use\n if (\n typeof child === 'object' && child !== null &&\n (child as { $$typeof?: symbol }).$$typeof === REACT_LAZY_TYPE &&\n typeof resolve === 'function'\n ) {\n child = resolve((child as { _payload: unknown })._payload)\n }\n if (!React.isValidElement<{ children?: React.ReactNode }>(child)) return render(children)\n return React.cloneElement(child, undefined, render(child.props.children))\n}\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Solid variant color */\n color?: ButtonColor\n asChild?: boolean\n loading?: boolean\n leftIcon?: React.ReactNode\n rightIcon?: React.ReactNode\n selected?: boolean\n fontWeight?: 'normal' | 'semibold'\n pressEffect?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({\n className,\n variant: variantProp,\n color: colorProp,\n size: sizeProp,\n radius: radiusProp,\n fullWidth,\n asChild = false,\n loading = false,\n disabled: disabledProp,\n leftIcon,\n rightIcon,\n selected = false,\n fontWeight: fontWeightProp,\n pressEffect,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'button'\n const groupContext = useButtonGroup()\n\n // Use context values as fallback, individual props take precedence\n const variant = variantProp ?? groupContext?.variant ?? 'solid'\n const color = colorProp ?? 'default'\n const size = sizeProp ?? groupContext?.size\n const radius = radiusProp ?? groupContext?.radius\n const disabled = disabledProp ?? groupContext?.disabled\n\n // Priority: direct prop > ButtonGroup context > variant default (no class)\n const fontWeight = fontWeightProp ?? groupContext?.fontWeight\n\n // FontWeight class (overrides variant default)\n const fontWeightClass = fontWeight === 'normal' ? 'font-normal' : fontWeight === 'semibold' ? 'font-semibold' : ''\n\n // Icon size for button with text (5-step scale)\n // xs~sm: 14px, md~default~lg: 16px\n const iconSizeClass = {\n xs: 'icon-xs', // 14px\n sm: 'icon-xs', // 14px\n md: 'icon-sm', // 16px\n default: 'icon-sm', // 16px\n lg: 'icon-sm', // 16px\n icon: 'icon-md', // icon-only → 20px\n }[size || 'default']\n\n // Selected styles by variant (used in ButtonGroup)\n const selectedStyles = selected ? (\n variant === 'outline' ? 'bg-background-muted' :\n variant === 'ghost' ? 'font-semibold' : ''\n ) : ''\n\n const renderContent = (content: React.ReactNode) => loading ? (\n <>\n <svg\n className={cn(iconSizeClass, 'animate-spin')}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n <span>{content}</span>\n </>\n ) : (\n <>\n {leftIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{leftIcon}</span>}\n {content}\n {rightIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{rightIcon}</span>}\n </>\n )\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, radius, fullWidth }), variant === 'solid' && solidColorMap[color], pressEffect !== false && 'active:scale-pressed', fontWeightClass, selectedStyles, className)}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n aria-pressed={selected || undefined}\n {...props}\n >\n {asChild ? renderInsideChild(children, renderContent) : renderContent(children)}\n </Comp>\n )\n }\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsJM;AApJN,YAAuB;AACvB,wBAAqB;AACrB,sCAAuC;AACvC,mBAAmB;AACnB,0BAA+B;AAG/B,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AACf;AAIA,MAAM,qBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,OAAO;AAAA,QACP,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA;AAAA,QACN,IAAI;AAAA;AAAA,QACJ,MAAM;AAAA;AAAA,QACN,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,OAAO;AAAA;AAAA,QACP,OAAO;AAAA;AAAA,QACP,MAAM;AAAA;AAAA,MACR;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,MACN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|
71
|
+
function renderInsideChild(children, render) {
|
|
72
|
+
let child = children;
|
|
73
|
+
const resolve = React.use;
|
|
74
|
+
if (typeof child === "object" && child !== null && child.$$typeof === REACT_LAZY_TYPE && typeof resolve === "function") {
|
|
75
|
+
child = resolve(child._payload);
|
|
76
|
+
}
|
|
77
|
+
if (!React.isValidElement(child)) return render(children);
|
|
78
|
+
return React.cloneElement(child, void 0, render(child.props.children));
|
|
79
|
+
}
|
|
70
80
|
const Button = React.forwardRef(
|
|
71
81
|
({
|
|
72
82
|
className,
|
|
@@ -110,6 +120,26 @@ const Button = React.forwardRef(
|
|
|
110
120
|
// icon-only → 20px
|
|
111
121
|
}[size || "default"];
|
|
112
122
|
const selectedStyles = selected ? variant === "outline" ? "bg-background-muted" : variant === "ghost" ? "font-semibold" : "" : "";
|
|
123
|
+
const renderContent = (content) => loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
124
|
+
/* @__PURE__ */ jsxs(
|
|
125
|
+
"svg",
|
|
126
|
+
{
|
|
127
|
+
className: cn(iconSizeClass, "animate-spin"),
|
|
128
|
+
fill: "none",
|
|
129
|
+
viewBox: "0 0 24 24",
|
|
130
|
+
"aria-hidden": "true",
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
133
|
+
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx("span", { children: content })
|
|
138
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: leftIcon }),
|
|
140
|
+
content,
|
|
141
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: rightIcon })
|
|
142
|
+
] });
|
|
113
143
|
return /* @__PURE__ */ jsx(
|
|
114
144
|
Comp,
|
|
115
145
|
{
|
|
@@ -119,26 +149,7 @@ const Button = React.forwardRef(
|
|
|
119
149
|
"aria-busy": loading || void 0,
|
|
120
150
|
"aria-pressed": selected || void 0,
|
|
121
151
|
...props,
|
|
122
|
-
children:
|
|
123
|
-
/* @__PURE__ */ jsxs(
|
|
124
|
-
"svg",
|
|
125
|
-
{
|
|
126
|
-
className: cn(iconSizeClass, "animate-spin"),
|
|
127
|
-
fill: "none",
|
|
128
|
-
viewBox: "0 0 24 24",
|
|
129
|
-
"aria-hidden": "true",
|
|
130
|
-
children: [
|
|
131
|
-
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
132
|
-
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
/* @__PURE__ */ jsx("span", { children })
|
|
137
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
138
|
-
leftIcon && /* @__PURE__ */ jsx("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: leftIcon }),
|
|
139
|
-
children,
|
|
140
|
-
rightIcon && /* @__PURE__ */ jsx("span", { className: cn(iconSizeClass, "[&>svg]:w-full [&>svg]:h-full"), "aria-hidden": "true", children: rightIcon })
|
|
141
|
-
] })
|
|
152
|
+
children: asChild ? renderInsideChild(children, renderContent) : renderContent(children)
|
|
142
153
|
}
|
|
143
154
|
);
|
|
144
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/button.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useButtonGroup } from './button-group'\n\n// Solid color maps (applied when variant=\"solid\")\nconst solidColorMap = {\n default: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',\n primary: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active',\n destructive: 'bg-error text-error-foreground hover:bg-error-hover active:bg-error-active',\n} as const\n\nexport type ButtonColor = keyof typeof solidColorMap\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n solid: 'font-semibold',\n outline: 'border border-border-form bg-background text-foreground hover:bg-background-muted font-normal',\n ghost: 'text-foreground hover:bg-background-muted font-normal',\n link: 'text-text-link underline-offset-4 hover:underline font-normal',\n },\n size: {\n xs: 'h-7 px-2.5 text-xs gap-1', // 28px height, 10px paddingX, 12px font\n sm: 'h-8 px-3 text-sm gap-2', // 32px height, 12px paddingX, 13px font\n md: 'h-9 px-3.5 text-md gap-2', // 36px height, 14px paddingX, 14px font\n default: 'h-10 px-4 text-md gap-2', // 40px height, 16px paddingX, 14px font\n lg: 'h-12 px-6 text-base gap-2', // 48px height, 24px paddingX, 16px font\n icon: 'h-10 w-10',\n },\n radius: {\n none: 'rounded-none', // 0px - primitive.borderRadius.none\n sm: 'rounded-sm', // 2px - primitive.borderRadius.sm\n base: 'rounded', // 4px - primitive.borderRadius.base\n default: 'rounded-md', // 6px - primitive.borderRadius.md (Figma button default)\n lg: 'rounded-lg', // 8px - primitive.borderRadius.lg\n xl: 'rounded-xl', // 12px - primitive.borderRadius.xl\n '2xl': 'rounded-2xl', // 16px - primitive.borderRadius.2xl\n '3xl': 'rounded-3xl', // 24px - primitive.borderRadius.3xl\n full: 'rounded-full', // 9999px - primitive.borderRadius.full\n },\n fullWidth: {\n true: 'w-full',\n false: 'w-auto',\n },\n },\n defaultVariants: {\n variant: 'solid',\n size: 'default',\n radius: 'default',\n fullWidth: false,\n },\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Solid variant color */\n color?: ButtonColor\n asChild?: boolean\n loading?: boolean\n leftIcon?: React.ReactNode\n rightIcon?: React.ReactNode\n selected?: boolean\n fontWeight?: 'normal' | 'semibold'\n pressEffect?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({\n className,\n variant: variantProp,\n color: colorProp,\n size: sizeProp,\n radius: radiusProp,\n fullWidth,\n asChild = false,\n loading = false,\n disabled: disabledProp,\n leftIcon,\n rightIcon,\n selected = false,\n fontWeight: fontWeightProp,\n pressEffect,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'button'\n const groupContext = useButtonGroup()\n\n // Use context values as fallback, individual props take precedence\n const variant = variantProp ?? groupContext?.variant ?? 'solid'\n const color = colorProp ?? 'default'\n const size = sizeProp ?? groupContext?.size\n const radius = radiusProp ?? groupContext?.radius\n const disabled = disabledProp ?? groupContext?.disabled\n\n // Priority: direct prop > ButtonGroup context > variant default (no class)\n const fontWeight = fontWeightProp ?? groupContext?.fontWeight\n\n // FontWeight class (overrides variant default)\n const fontWeightClass = fontWeight === 'normal' ? 'font-normal' : fontWeight === 'semibold' ? 'font-semibold' : ''\n\n // Icon size for button with text (5-step scale)\n // xs~sm: 14px, md~default~lg: 16px\n const iconSizeClass = {\n xs: 'icon-xs', // 14px\n sm: 'icon-xs', // 14px\n md: 'icon-sm', // 16px\n default: 'icon-sm', // 16px\n lg: 'icon-sm', // 16px\n icon: 'icon-md', // icon-only → 20px\n }[size || 'default']\n\n // Selected styles by variant (used in ButtonGroup)\n const selectedStyles = selected ? (\n variant === 'outline' ? 'bg-background-muted' :\n variant === 'ghost' ? 'font-semibold' : ''\n ) : ''\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, radius, fullWidth }), variant === 'solid' && solidColorMap[color], pressEffect !== false && 'active:scale-pressed', fontWeightClass, selectedStyles, className)}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n aria-pressed={selected || undefined}\n {...props}\n >\n {loading ? (\n <>\n <svg\n className={cn(iconSizeClass, 'animate-spin')}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n <span>{children}</span>\n </>\n ) : (\n <>\n {leftIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{leftIcon}</span>}\n {children}\n {rightIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{rightIcon}</span>}\n </>\n )}\n </Comp>\n )\n }\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":";AAyIU,mBAOI,KANF,YADF;AAvIV,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AACvC,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAG/B,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AACf;AAIA,MAAM,iBAAiB;AAAA,EACrB;AA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;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/button.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useButtonGroup } from './button-group'\n\n// Solid color maps (applied when variant=\"solid\")\nconst solidColorMap = {\n default: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',\n primary: 'bg-primary text-primary-foreground hover:bg-primary-hover active:bg-primary-active',\n secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover active:bg-secondary-active',\n destructive: 'bg-error text-error-foreground hover:bg-error-hover active:bg-error-active',\n} as const\n\nexport type ButtonColor = keyof typeof solidColorMap\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-all duration-micro focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n solid: 'font-semibold',\n outline: 'border border-border-form bg-background text-foreground hover:bg-background-muted font-normal',\n ghost: 'text-foreground hover:bg-background-muted font-normal',\n link: 'text-text-link underline-offset-4 hover:underline font-normal',\n },\n size: {\n xs: 'h-7 px-2.5 text-xs gap-1', // 28px height, 10px paddingX, 12px font\n sm: 'h-8 px-3 text-sm gap-2', // 32px height, 12px paddingX, 13px font\n md: 'h-9 px-3.5 text-md gap-2', // 36px height, 14px paddingX, 14px font\n default: 'h-10 px-4 text-md gap-2', // 40px height, 16px paddingX, 14px font\n lg: 'h-12 px-6 text-base gap-2', // 48px height, 24px paddingX, 16px font\n icon: 'h-10 w-10',\n },\n radius: {\n none: 'rounded-none', // 0px - primitive.borderRadius.none\n sm: 'rounded-sm', // 2px - primitive.borderRadius.sm\n base: 'rounded', // 4px - primitive.borderRadius.base\n default: 'rounded-md', // 6px - primitive.borderRadius.md (Figma button default)\n lg: 'rounded-lg', // 8px - primitive.borderRadius.lg\n xl: 'rounded-xl', // 12px - primitive.borderRadius.xl\n '2xl': 'rounded-2xl', // 16px - primitive.borderRadius.2xl\n '3xl': 'rounded-3xl', // 24px - primitive.borderRadius.3xl\n full: 'rounded-full', // 9999px - primitive.borderRadius.full\n },\n fullWidth: {\n true: 'w-full',\n false: 'w-auto',\n },\n },\n defaultVariants: {\n variant: 'solid',\n size: 'default',\n radius: 'default',\n fullWidth: false,\n },\n }\n)\n\nconst REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\n// asChild: Slot merges props only into a single child element, so icons and\n// wrappers must go inside that child, not next to it. Lazy children (from\n// Server Components) are resolved the same way Radix Slot does.\nfunction renderInsideChild(\n children: React.ReactNode,\n render: (content: React.ReactNode) => React.ReactNode\n): React.ReactNode {\n let child: unknown = children\n const resolve = (React as { use?: (usable: unknown) => unknown }).use\n if (\n typeof child === 'object' && child !== null &&\n (child as { $$typeof?: symbol }).$$typeof === REACT_LAZY_TYPE &&\n typeof resolve === 'function'\n ) {\n child = resolve((child as { _payload: unknown })._payload)\n }\n if (!React.isValidElement<{ children?: React.ReactNode }>(child)) return render(children)\n return React.cloneElement(child, undefined, render(child.props.children))\n}\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /** Solid variant color */\n color?: ButtonColor\n asChild?: boolean\n loading?: boolean\n leftIcon?: React.ReactNode\n rightIcon?: React.ReactNode\n selected?: boolean\n fontWeight?: 'normal' | 'semibold'\n pressEffect?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({\n className,\n variant: variantProp,\n color: colorProp,\n size: sizeProp,\n radius: radiusProp,\n fullWidth,\n asChild = false,\n loading = false,\n disabled: disabledProp,\n leftIcon,\n rightIcon,\n selected = false,\n fontWeight: fontWeightProp,\n pressEffect,\n children,\n ...props\n }, ref) => {\n const Comp = asChild ? Slot : 'button'\n const groupContext = useButtonGroup()\n\n // Use context values as fallback, individual props take precedence\n const variant = variantProp ?? groupContext?.variant ?? 'solid'\n const color = colorProp ?? 'default'\n const size = sizeProp ?? groupContext?.size\n const radius = radiusProp ?? groupContext?.radius\n const disabled = disabledProp ?? groupContext?.disabled\n\n // Priority: direct prop > ButtonGroup context > variant default (no class)\n const fontWeight = fontWeightProp ?? groupContext?.fontWeight\n\n // FontWeight class (overrides variant default)\n const fontWeightClass = fontWeight === 'normal' ? 'font-normal' : fontWeight === 'semibold' ? 'font-semibold' : ''\n\n // Icon size for button with text (5-step scale)\n // xs~sm: 14px, md~default~lg: 16px\n const iconSizeClass = {\n xs: 'icon-xs', // 14px\n sm: 'icon-xs', // 14px\n md: 'icon-sm', // 16px\n default: 'icon-sm', // 16px\n lg: 'icon-sm', // 16px\n icon: 'icon-md', // icon-only → 20px\n }[size || 'default']\n\n // Selected styles by variant (used in ButtonGroup)\n const selectedStyles = selected ? (\n variant === 'outline' ? 'bg-background-muted' :\n variant === 'ghost' ? 'font-semibold' : ''\n ) : ''\n\n const renderContent = (content: React.ReactNode) => loading ? (\n <>\n <svg\n className={cn(iconSizeClass, 'animate-spin')}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <circle className=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" strokeWidth=\"4\" />\n <path className=\"opacity-75\" fill=\"currentColor\" d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n <span>{content}</span>\n </>\n ) : (\n <>\n {leftIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{leftIcon}</span>}\n {content}\n {rightIcon && <span className={cn(iconSizeClass, '[&>svg]:w-full [&>svg]:h-full')} aria-hidden=\"true\">{rightIcon}</span>}\n </>\n )\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, radius, fullWidth }), variant === 'solid' && solidColorMap[color], pressEffect !== false && 'active:scale-pressed', fontWeightClass, selectedStyles, className)}\n ref={ref}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n aria-pressed={selected || undefined}\n {...props}\n >\n {asChild ? renderInsideChild(children, renderContent) : renderContent(children)}\n </Comp>\n )\n }\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":";AAsJM,mBAOI,KANF,YADF;AApJN,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,WAA8B;AACvC,SAAS,UAAU;AACnB,SAAS,sBAAsB;AAG/B,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AACf;AAIA,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,OAAO;AAAA,QACP,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA;AAAA,QACN,IAAI;AAAA;AAAA,QACJ,MAAM;AAAA;AAAA,QACN,SAAS;AAAA;AAAA,QACT,IAAI;AAAA;AAAA,QACJ,IAAI;AAAA;AAAA,QACJ,OAAO;AAAA;AAAA,QACP,OAAO;AAAA;AAAA,QACP,MAAM;AAAA;AAAA,MACR;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW;AAAA,IACb;AAAA,EACF;AACF;AAEA,MAAM,kBAAkB,uBAAO,IAAI,YAAY;AAK/C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CAAC,YAA6B,UAClD,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,GAAG,eAAe,cAAc;AAAA,UAC3C,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,eAAY;AAAA,UAEZ;AAAA,gCAAC,YAAO,WAAU,cAAa,IAAG,MAAK,IAAG,MAAK,GAAE,MAAK,QAAO,gBAAe,aAAY,KAAI;AAAA,YAC5F,oBAAC,UAAK,WAAU,cAAa,MAAK,gBAAe,GAAE,mHAAkH;AAAA;AAAA;AAAA,MACvK;AAAA,MACA,oBAAC,UAAM,mBAAQ;AAAA,OACjB,IAEA,iCACG;AAAA,kBAAY,oBAAC,UAAK,WAAW,GAAG,eAAe,+BAA+B,GAAG,eAAY,QAAQ,oBAAS;AAAA,MAC9G;AAAA,MACA,aAAa,oBAAC,UAAK,WAAW,GAAG,eAAe,+BAA+B,GAAG,eAAY,QAAQ,qBAAU;AAAA,OACnH;AAGF,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,GAAG,eAAe,EAAE,SAAS,MAAM,QAAQ,UAAU,CAAC,GAAG,YAAY,WAAW,cAAc,KAAK,GAAG,gBAAgB,SAAS,wBAAwB,iBAAiB,gBAAgB,SAAS;AAAA,QAC5M;AAAA,QACA,UAAU,YAAY;AAAA,QACtB,aAAW,WAAW;AAAA,QACtB,gBAAc,YAAY;AAAA,QACzB,GAAG;AAAA,QAEH,oBAAU,kBAAkB,UAAU,aAAa,IAAI,cAAc,QAAQ;AAAA;AAAA,IAChF;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;","names":[]}
|
|
@@ -74,7 +74,7 @@ type ChartTooltipContentProps = React.ComponentProps<'div'> & {
|
|
|
74
74
|
labelKey?: string;
|
|
75
75
|
};
|
|
76
76
|
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): React.JSX.Element | null;
|
|
77
|
-
declare const ChartLegend:
|
|
77
|
+
declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
78
78
|
type LegendPayloadItem = {
|
|
79
79
|
value?: string;
|
|
80
80
|
type?: string;
|
|
@@ -74,7 +74,7 @@ type ChartTooltipContentProps = React.ComponentProps<'div'> & {
|
|
|
74
74
|
labelKey?: string;
|
|
75
75
|
};
|
|
76
76
|
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): React.JSX.Element | null;
|
|
77
|
-
declare const ChartLegend:
|
|
77
|
+
declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
78
78
|
type LegendPayloadItem = {
|
|
79
79
|
value?: string;
|
|
80
80
|
type?: string;
|
|
@@ -24,6 +24,8 @@ interface DrawerContentProps extends Omit<React.ComponentPropsWithoutRef<typeof
|
|
|
24
24
|
showCloseButton?: boolean;
|
|
25
25
|
/** Custom close icon (replaces default X) */
|
|
26
26
|
closeIcon?: React.ReactNode;
|
|
27
|
+
/** Accessible label for the close button (screen readers) — localize per page */
|
|
28
|
+
closeLabel?: string;
|
|
27
29
|
children?: React.ReactNode;
|
|
28
30
|
}
|
|
29
31
|
declare const DrawerContent: React.ForwardRefExoticComponent<DrawerContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -24,6 +24,8 @@ interface DrawerContentProps extends Omit<React.ComponentPropsWithoutRef<typeof
|
|
|
24
24
|
showCloseButton?: boolean;
|
|
25
25
|
/** Custom close icon (replaces default X) */
|
|
26
26
|
closeIcon?: React.ReactNode;
|
|
27
|
+
/** Accessible label for the close button (screen readers) — localize per page */
|
|
28
|
+
closeLabel?: string;
|
|
27
29
|
children?: React.ReactNode;
|
|
28
30
|
}
|
|
29
31
|
declare const DrawerContent: React.ForwardRefExoticComponent<DrawerContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -116,7 +116,7 @@ const SIDE_POSITION = {
|
|
|
116
116
|
top: "inset-x-0 top-0",
|
|
117
117
|
bottom: "inset-x-0 bottom-0"
|
|
118
118
|
};
|
|
119
|
-
const DrawerContent = React.forwardRef(({ className, children, side = "right", size = "md", showCloseButton = true, closeIcon, ...props }, ref) => {
|
|
119
|
+
const DrawerContent = React.forwardRef(({ className, children, side = "right", size = "md", showCloseButton = true, closeIcon, closeLabel = "Close", ...props }, ref) => {
|
|
120
120
|
const isHorizontal = side === "left" || side === "right";
|
|
121
121
|
const sizeClass = isHorizontal ? drawerSizeHorizontal({ size }) : drawerSizeVertical({ size });
|
|
122
122
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerPortal, { children: [
|
|
@@ -145,7 +145,7 @@ const DrawerContent = React.forwardRef(({ className, children, side = "right", s
|
|
|
145
145
|
"disabled:pointer-events-none"
|
|
146
146
|
), children: [
|
|
147
147
|
closeIcon || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultCloseIcon, { className: "icon-sm" }),
|
|
148
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children:
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: closeLabel })
|
|
149
149
|
] })
|
|
150
150
|
]
|
|
151
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/drawer.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Default Close Icon (built-in, no external dependency) ──\nconst DefaultCloseIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\n// ─── Types ──────────────────────────────────────────────────\nexport type DrawerSide = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\n// ─── Animation class mapping (static strings for Tailwind scanner) ──\nconst ANIMATION_CLASSES: Record<DrawerSide, string> = {\n right: 'data-[state=open]:animate-drawer-right-enter data-[state=closed]:animate-drawer-right-exit',\n left: 'data-[state=open]:animate-drawer-left-enter data-[state=closed]:animate-drawer-left-exit',\n top: 'data-[state=open]:animate-drawer-top-enter data-[state=closed]:animate-drawer-top-exit',\n bottom: 'data-[state=open]:animate-drawer-bottom-enter data-[state=closed]:animate-drawer-bottom-exit',\n}\n\n// ─── Size variants ──────────────────────────────────────────\nconst drawerSizeHorizontal = cva('', {\n variants: {\n size: {\n sm: 'w-[320px]',\n md: 'w-[400px]',\n lg: 'w-[480px]',\n xl: 'w-[640px]',\n full: 'w-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nconst drawerSizeVertical = cva('', {\n variants: {\n size: {\n sm: 'h-[320px]',\n md: 'h-[400px]',\n lg: 'h-[480px]',\n xl: 'h-[640px]',\n full: 'h-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\n// ═══════════════════════════════════════════════════════════════\n// Drawer\n// ═══════════════════════════════════════════════════════════════\n\n// ─── Drawer (Root) — wrapper to keep our own component identity separate from DialogPrimitive.Root ──\nfunction Drawer(props: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root {...props} />\n}\n\n// ─── DrawerTrigger ──────────────────────────────────────────\nconst DrawerTrigger = DialogPrimitive.Trigger\n\n// ─── DrawerPortal ───────────────────────────────────────────\nconst DrawerPortal = DialogPrimitive.Portal\n\n// ─── DrawerClose ────────────────────────────────────────────\nconst DrawerClose = DialogPrimitive.Close\n\n// ─── DrawerOverlay ──────────────────────────────────────────\nconst DrawerOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-overlay bg-black/50',\n 'data-[state=open]:animate-modal-overlay-enter data-[state=closed]:animate-modal-overlay-exit',\n className\n )}\n {...props}\n />\n))\nDrawerOverlay.displayName = 'DrawerOverlay'\n\n// ─── DrawerContent ──────────────────────────────────────────\nexport interface DrawerContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'children'> {\n /** Side from which the drawer slides in */\n side?: DrawerSide\n /** Panel size (width for left/right, height for top/bottom) */\n size?: DrawerSize\n /** Show built-in close button */\n showCloseButton?: boolean\n /** Custom close icon (replaces default X) */\n closeIcon?: React.ReactNode\n children?: React.ReactNode\n}\n\nconst SIDE_POSITION: Record<DrawerSide, string> = {\n right: 'inset-y-0 right-0',\n left: 'inset-y-0 left-0',\n top: 'inset-x-0 top-0',\n bottom: 'inset-x-0 bottom-0',\n}\n\nconst DrawerContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(({ className, children, side = 'right', size = 'md', showCloseButton = true, closeIcon, ...props }, ref) => {\n const isHorizontal = side === 'left' || side === 'right'\n const sizeClass = isHorizontal\n ? drawerSizeHorizontal({ size })\n : drawerSizeVertical({ size })\n\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed z-modal flex flex-col bg-background text-foreground shadow-xl',\n 'focus:outline-none',\n SIDE_POSITION[side],\n isHorizontal ? 'max-w-full h-full' : 'max-h-full w-full',\n sizeClass,\n ANIMATION_CLASSES[side],\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close className={cn(\n 'absolute right-4 top-4 rounded-md p-1',\n 'text-text-muted hover:text-foreground',\n 'transition-colors duration-fast',\n 'focus-visible:focus-ring focus-visible:outline-none',\n 'disabled:pointer-events-none'\n )}>\n {closeIcon || <DefaultCloseIcon className=\"icon-sm\" />}\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DrawerPortal>\n )\n})\nDrawerContent.displayName = 'DrawerContent'\n\n// ─── DrawerHeader ───────────────────────────────────────────\nconst DrawerHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex flex-col gap-1.5 p-6 pb-0', className)}\n {...props}\n />\n))\nDrawerHeader.displayName = 'DrawerHeader'\n\n// ─── DrawerTitle ────────────────────────────────────────────\nconst DrawerTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold text-foreground', className)}\n {...props}\n />\n))\nDrawerTitle.displayName = 'DrawerTitle'\n\n// ─── DrawerDescription ─────────────────────────────────────\nconst DrawerDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-md text-text-muted', className)}\n {...props}\n />\n))\nDrawerDescription.displayName = 'DrawerDescription'\n\n// ─── DrawerBody ─────────────────────────────────────────────\nconst DrawerBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex-1 overflow-y-auto p-6', className)}\n {...props}\n />\n))\nDrawerBody.displayName = 'DrawerBody'\n\n// ─── DrawerFooter ───────────────────────────────────────────\nconst DrawerFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-end gap-3 p-6 pt-0',\n className\n )}\n {...props}\n />\n))\nDrawerFooter.displayName = 'DrawerFooter'\n\n// ─── Exports ────────────────────────────────────────────────\nexport {\n Drawer,\n DrawerTrigger,\n DrawerPortal,\n DrawerOverlay,\n DrawerContent,\n DrawerHeader,\n DrawerTitle,\n DrawerDescription,\n DrawerBody,\n DrawerFooter,\n DrawerClose,\n drawerSizeHorizontal,\n drawerSizeVertical,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBI;AAfJ,YAAuB;AACvB,sBAAiC;AACjC,sCAAuC;AACvC,mBAAmB;AAGnB,MAAM,mBAAmB,CAAC,EAAE,UAAU,MACpC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,aAAa;AAAA,IACb,eAAY;AAAA,IAEZ,sDAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAC9E;AAQF,MAAM,oBAAgD;AAAA,EACpD,OAAQ;AAAA,EACR,MAAQ;AAAA,EACR,KAAQ;AAAA,EACR,QAAQ;AACV;AAGA,MAAM,2BAAuB,qCAAI,IAAI;AAAA,EACnC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC;AAED,MAAM,yBAAqB,qCAAI,IAAI;AAAA,EACjC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,MAAM;AAAA,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cesContent":["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Default Close Icon (built-in, no external dependency) ──\nconst DefaultCloseIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\n// ─── Types ──────────────────────────────────────────────────\nexport type DrawerSide = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\n// ─── Animation class mapping (static strings for Tailwind scanner) ──\nconst ANIMATION_CLASSES: Record<DrawerSide, string> = {\n right: 'data-[state=open]:animate-drawer-right-enter data-[state=closed]:animate-drawer-right-exit',\n left: 'data-[state=open]:animate-drawer-left-enter data-[state=closed]:animate-drawer-left-exit',\n top: 'data-[state=open]:animate-drawer-top-enter data-[state=closed]:animate-drawer-top-exit',\n bottom: 'data-[state=open]:animate-drawer-bottom-enter data-[state=closed]:animate-drawer-bottom-exit',\n}\n\n// ─── Size variants ──────────────────────────────────────────\nconst drawerSizeHorizontal = cva('', {\n variants: {\n size: {\n sm: 'w-[320px]',\n md: 'w-[400px]',\n lg: 'w-[480px]',\n xl: 'w-[640px]',\n full: 'w-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nconst drawerSizeVertical = cva('', {\n variants: {\n size: {\n sm: 'h-[320px]',\n md: 'h-[400px]',\n lg: 'h-[480px]',\n xl: 'h-[640px]',\n full: 'h-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\n// ═══════════════════════════════════════════════════════════════\n// Drawer\n// ═══════════════════════════════════════════════════════════════\n\n// ─── Drawer (Root) — wrapper to keep our own component identity separate from DialogPrimitive.Root ──\nfunction Drawer(props: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root {...props} />\n}\n\n// ─── DrawerTrigger ──────────────────────────────────────────\nconst DrawerTrigger = DialogPrimitive.Trigger\n\n// ─── DrawerPortal ───────────────────────────────────────────\nconst DrawerPortal = DialogPrimitive.Portal\n\n// ─── DrawerClose ────────────────────────────────────────────\nconst DrawerClose = DialogPrimitive.Close\n\n// ─── DrawerOverlay ──────────────────────────────────────────\nconst DrawerOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-overlay bg-black/50',\n 'data-[state=open]:animate-modal-overlay-enter data-[state=closed]:animate-modal-overlay-exit',\n className\n )}\n {...props}\n />\n))\nDrawerOverlay.displayName = 'DrawerOverlay'\n\n// ─── DrawerContent ──────────────────────────────────────────\nexport interface DrawerContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'children'> {\n /** Side from which the drawer slides in */\n side?: DrawerSide\n /** Panel size (width for left/right, height for top/bottom) */\n size?: DrawerSize\n /** Show built-in close button */\n showCloseButton?: boolean\n /** Custom close icon (replaces default X) */\n closeIcon?: React.ReactNode\n /** Accessible label for the close button (screen readers) — localize per page */\n closeLabel?: string\n children?: React.ReactNode\n}\n\nconst SIDE_POSITION: Record<DrawerSide, string> = {\n right: 'inset-y-0 right-0',\n left: 'inset-y-0 left-0',\n top: 'inset-x-0 top-0',\n bottom: 'inset-x-0 bottom-0',\n}\n\nconst DrawerContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(({ className, children, side = 'right', size = 'md', showCloseButton = true, closeIcon, closeLabel = 'Close', ...props }, ref) => {\n const isHorizontal = side === 'left' || side === 'right'\n const sizeClass = isHorizontal\n ? drawerSizeHorizontal({ size })\n : drawerSizeVertical({ size })\n\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed z-modal flex flex-col bg-background text-foreground shadow-xl',\n 'focus:outline-none',\n SIDE_POSITION[side],\n isHorizontal ? 'max-w-full h-full' : 'max-h-full w-full',\n sizeClass,\n ANIMATION_CLASSES[side],\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close className={cn(\n 'absolute right-4 top-4 rounded-md p-1',\n 'text-text-muted hover:text-foreground',\n 'transition-colors duration-fast',\n 'focus-visible:focus-ring focus-visible:outline-none',\n 'disabled:pointer-events-none'\n )}>\n {closeIcon || <DefaultCloseIcon className=\"icon-sm\" />}\n <span className=\"sr-only\">{closeLabel}</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DrawerPortal>\n )\n})\nDrawerContent.displayName = 'DrawerContent'\n\n// ─── DrawerHeader ───────────────────────────────────────────\nconst DrawerHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex flex-col gap-1.5 p-6 pb-0', className)}\n {...props}\n />\n))\nDrawerHeader.displayName = 'DrawerHeader'\n\n// ─── DrawerTitle ────────────────────────────────────────────\nconst DrawerTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold text-foreground', className)}\n {...props}\n />\n))\nDrawerTitle.displayName = 'DrawerTitle'\n\n// ─── DrawerDescription ─────────────────────────────────────\nconst DrawerDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-md text-text-muted', className)}\n {...props}\n />\n))\nDrawerDescription.displayName = 'DrawerDescription'\n\n// ─── DrawerBody ─────────────────────────────────────────────\nconst DrawerBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex-1 overflow-y-auto p-6', className)}\n {...props}\n />\n))\nDrawerBody.displayName = 'DrawerBody'\n\n// ─── DrawerFooter ───────────────────────────────────────────\nconst DrawerFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-end gap-3 p-6 pt-0',\n className\n )}\n {...props}\n />\n))\nDrawerFooter.displayName = 'DrawerFooter'\n\n// ─── Exports ────────────────────────────────────────────────\nexport {\n Drawer,\n DrawerTrigger,\n DrawerPortal,\n DrawerOverlay,\n DrawerContent,\n DrawerHeader,\n DrawerTitle,\n DrawerDescription,\n DrawerBody,\n DrawerFooter,\n DrawerClose,\n drawerSizeHorizontal,\n drawerSizeVertical,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBI;AAfJ,YAAuB;AACvB,sBAAiC;AACjC,sCAAuC;AACvC,mBAAmB;AAGnB,MAAM,mBAAmB,CAAC,EAAE,UAAU,MACpC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,aAAa;AAAA,IACb,eAAY;AAAA,IAEZ,sDAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAC9E;AAQF,MAAM,oBAAgD;AAAA,EACpD,OAAQ;AAAA,EACR,MAAQ;AAAA,EACR,KAAQ;AAAA,EACR,QAAQ;AACV;AAGA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,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,eAAW,iBAAG,8BAA8B,SAAS;AAAA,IACpD,GAAG;AAAA;AACN,CACD;AACD,WAAW,cAAc;AAGzB,MAAM,eAAe,MAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,eAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,aAAa,cAAc;","names":[]}
|
|
@@ -71,7 +71,7 @@ const SIDE_POSITION = {
|
|
|
71
71
|
top: "inset-x-0 top-0",
|
|
72
72
|
bottom: "inset-x-0 bottom-0"
|
|
73
73
|
};
|
|
74
|
-
const DrawerContent = React.forwardRef(({ className, children, side = "right", size = "md", showCloseButton = true, closeIcon, ...props }, ref) => {
|
|
74
|
+
const DrawerContent = React.forwardRef(({ className, children, side = "right", size = "md", showCloseButton = true, closeIcon, closeLabel = "Close", ...props }, ref) => {
|
|
75
75
|
const isHorizontal = side === "left" || side === "right";
|
|
76
76
|
const sizeClass = isHorizontal ? drawerSizeHorizontal({ size }) : drawerSizeVertical({ size });
|
|
77
77
|
return /* @__PURE__ */ jsxs(DrawerPortal, { children: [
|
|
@@ -100,7 +100,7 @@ const DrawerContent = React.forwardRef(({ className, children, side = "right", s
|
|
|
100
100
|
"disabled:pointer-events-none"
|
|
101
101
|
), children: [
|
|
102
102
|
closeIcon || /* @__PURE__ */ jsx(DefaultCloseIcon, { className: "icon-sm" }),
|
|
103
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children:
|
|
103
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: closeLabel })
|
|
104
104
|
] })
|
|
105
105
|
]
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/drawer.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Default Close Icon (built-in, no external dependency) ──\nconst DefaultCloseIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\n// ─── Types ──────────────────────────────────────────────────\nexport type DrawerSide = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\n// ─── Animation class mapping (static strings for Tailwind scanner) ──\nconst ANIMATION_CLASSES: Record<DrawerSide, string> = {\n right: 'data-[state=open]:animate-drawer-right-enter data-[state=closed]:animate-drawer-right-exit',\n left: 'data-[state=open]:animate-drawer-left-enter data-[state=closed]:animate-drawer-left-exit',\n top: 'data-[state=open]:animate-drawer-top-enter data-[state=closed]:animate-drawer-top-exit',\n bottom: 'data-[state=open]:animate-drawer-bottom-enter data-[state=closed]:animate-drawer-bottom-exit',\n}\n\n// ─── Size variants ──────────────────────────────────────────\nconst drawerSizeHorizontal = cva('', {\n variants: {\n size: {\n sm: 'w-[320px]',\n md: 'w-[400px]',\n lg: 'w-[480px]',\n xl: 'w-[640px]',\n full: 'w-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nconst drawerSizeVertical = cva('', {\n variants: {\n size: {\n sm: 'h-[320px]',\n md: 'h-[400px]',\n lg: 'h-[480px]',\n xl: 'h-[640px]',\n full: 'h-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\n// ═══════════════════════════════════════════════════════════════\n// Drawer\n// ═══════════════════════════════════════════════════════════════\n\n// ─── Drawer (Root) — wrapper to keep our own component identity separate from DialogPrimitive.Root ──\nfunction Drawer(props: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root {...props} />\n}\n\n// ─── DrawerTrigger ──────────────────────────────────────────\nconst DrawerTrigger = DialogPrimitive.Trigger\n\n// ─── DrawerPortal ───────────────────────────────────────────\nconst DrawerPortal = DialogPrimitive.Portal\n\n// ─── DrawerClose ────────────────────────────────────────────\nconst DrawerClose = DialogPrimitive.Close\n\n// ─── DrawerOverlay ──────────────────────────────────────────\nconst DrawerOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-overlay bg-black/50',\n 'data-[state=open]:animate-modal-overlay-enter data-[state=closed]:animate-modal-overlay-exit',\n className\n )}\n {...props}\n />\n))\nDrawerOverlay.displayName = 'DrawerOverlay'\n\n// ─── DrawerContent ──────────────────────────────────────────\nexport interface DrawerContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'children'> {\n /** Side from which the drawer slides in */\n side?: DrawerSide\n /** Panel size (width for left/right, height for top/bottom) */\n size?: DrawerSize\n /** Show built-in close button */\n showCloseButton?: boolean\n /** Custom close icon (replaces default X) */\n closeIcon?: React.ReactNode\n children?: React.ReactNode\n}\n\nconst SIDE_POSITION: Record<DrawerSide, string> = {\n right: 'inset-y-0 right-0',\n left: 'inset-y-0 left-0',\n top: 'inset-x-0 top-0',\n bottom: 'inset-x-0 bottom-0',\n}\n\nconst DrawerContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(({ className, children, side = 'right', size = 'md', showCloseButton = true, closeIcon, ...props }, ref) => {\n const isHorizontal = side === 'left' || side === 'right'\n const sizeClass = isHorizontal\n ? drawerSizeHorizontal({ size })\n : drawerSizeVertical({ size })\n\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed z-modal flex flex-col bg-background text-foreground shadow-xl',\n 'focus:outline-none',\n SIDE_POSITION[side],\n isHorizontal ? 'max-w-full h-full' : 'max-h-full w-full',\n sizeClass,\n ANIMATION_CLASSES[side],\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close className={cn(\n 'absolute right-4 top-4 rounded-md p-1',\n 'text-text-muted hover:text-foreground',\n 'transition-colors duration-fast',\n 'focus-visible:focus-ring focus-visible:outline-none',\n 'disabled:pointer-events-none'\n )}>\n {closeIcon || <DefaultCloseIcon className=\"icon-sm\" />}\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DrawerPortal>\n )\n})\nDrawerContent.displayName = 'DrawerContent'\n\n// ─── DrawerHeader ───────────────────────────────────────────\nconst DrawerHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex flex-col gap-1.5 p-6 pb-0', className)}\n {...props}\n />\n))\nDrawerHeader.displayName = 'DrawerHeader'\n\n// ─── DrawerTitle ────────────────────────────────────────────\nconst DrawerTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold text-foreground', className)}\n {...props}\n />\n))\nDrawerTitle.displayName = 'DrawerTitle'\n\n// ─── DrawerDescription ─────────────────────────────────────\nconst DrawerDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-md text-text-muted', className)}\n {...props}\n />\n))\nDrawerDescription.displayName = 'DrawerDescription'\n\n// ─── DrawerBody ─────────────────────────────────────────────\nconst DrawerBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex-1 overflow-y-auto p-6', className)}\n {...props}\n />\n))\nDrawerBody.displayName = 'DrawerBody'\n\n// ─── DrawerFooter ───────────────────────────────────────────\nconst DrawerFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-end gap-3 p-6 pt-0',\n className\n )}\n {...props}\n />\n))\nDrawerFooter.displayName = 'DrawerFooter'\n\n// ─── Exports ────────────────────────────────────────────────\nexport {\n Drawer,\n DrawerTrigger,\n DrawerPortal,\n DrawerOverlay,\n DrawerContent,\n DrawerHeader,\n DrawerTitle,\n DrawerDescription,\n DrawerBody,\n DrawerFooter,\n DrawerClose,\n drawerSizeHorizontal,\n drawerSizeVertical,\n}\n"],"mappings":";AAiBI,cA8HM,YA9HN;AAfJ,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,WAA8B;AACvC,SAAS,UAAU;AAGnB,MAAM,mBAAmB,CAAC,EAAE,UAAU,MACpC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,aAAa;AAAA,IACb,eAAY;AAAA,IAEZ,8BAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAC9E;AAQF,MAAM,oBAAgD;AAAA,EACpD,OAAQ;AAAA,EACR,MAAQ;AAAA,EACR,KAAQ;AAAA,EACR,QAAQ;AACV;AAGA,MAAM,uBAAuB,IAAI,IAAI;AAAA,EACnC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,IAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CA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AA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,aAAa,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/drawer.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ─── Default Close Icon (built-in, no external dependency) ──\nconst DefaultCloseIcon = ({ className }: { className?: string }) => (\n <svg\n className={className}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n)\n\n// ─── Types ──────────────────────────────────────────────────\nexport type DrawerSide = 'left' | 'right' | 'top' | 'bottom'\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\n// ─── Animation class mapping (static strings for Tailwind scanner) ──\nconst ANIMATION_CLASSES: Record<DrawerSide, string> = {\n right: 'data-[state=open]:animate-drawer-right-enter data-[state=closed]:animate-drawer-right-exit',\n left: 'data-[state=open]:animate-drawer-left-enter data-[state=closed]:animate-drawer-left-exit',\n top: 'data-[state=open]:animate-drawer-top-enter data-[state=closed]:animate-drawer-top-exit',\n bottom: 'data-[state=open]:animate-drawer-bottom-enter data-[state=closed]:animate-drawer-bottom-exit',\n}\n\n// ─── Size variants ──────────────────────────────────────────\nconst drawerSizeHorizontal = cva('', {\n variants: {\n size: {\n sm: 'w-[320px]',\n md: 'w-[400px]',\n lg: 'w-[480px]',\n xl: 'w-[640px]',\n full: 'w-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nconst drawerSizeVertical = cva('', {\n variants: {\n size: {\n sm: 'h-[320px]',\n md: 'h-[400px]',\n lg: 'h-[480px]',\n xl: 'h-[640px]',\n full: 'h-full',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\n// ═══════════════════════════════════════════════════════════════\n// Drawer\n// ═══════════════════════════════════════════════════════════════\n\n// ─── Drawer (Root) — wrapper to keep our own component identity separate from DialogPrimitive.Root ──\nfunction Drawer(props: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) {\n return <DialogPrimitive.Root {...props} />\n}\n\n// ─── DrawerTrigger ──────────────────────────────────────────\nconst DrawerTrigger = DialogPrimitive.Trigger\n\n// ─── DrawerPortal ───────────────────────────────────────────\nconst DrawerPortal = DialogPrimitive.Portal\n\n// ─── DrawerClose ────────────────────────────────────────────\nconst DrawerClose = DialogPrimitive.Close\n\n// ─── DrawerOverlay ──────────────────────────────────────────\nconst DrawerOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-overlay bg-black/50',\n 'data-[state=open]:animate-modal-overlay-enter data-[state=closed]:animate-modal-overlay-exit',\n className\n )}\n {...props}\n />\n))\nDrawerOverlay.displayName = 'DrawerOverlay'\n\n// ─── DrawerContent ──────────────────────────────────────────\nexport interface DrawerContentProps\n extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'children'> {\n /** Side from which the drawer slides in */\n side?: DrawerSide\n /** Panel size (width for left/right, height for top/bottom) */\n size?: DrawerSize\n /** Show built-in close button */\n showCloseButton?: boolean\n /** Custom close icon (replaces default X) */\n closeIcon?: React.ReactNode\n /** Accessible label for the close button (screen readers) — localize per page */\n closeLabel?: string\n children?: React.ReactNode\n}\n\nconst SIDE_POSITION: Record<DrawerSide, string> = {\n right: 'inset-y-0 right-0',\n left: 'inset-y-0 left-0',\n top: 'inset-x-0 top-0',\n bottom: 'inset-x-0 bottom-0',\n}\n\nconst DrawerContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n DrawerContentProps\n>(({ className, children, side = 'right', size = 'md', showCloseButton = true, closeIcon, closeLabel = 'Close', ...props }, ref) => {\n const isHorizontal = side === 'left' || side === 'right'\n const sizeClass = isHorizontal\n ? drawerSizeHorizontal({ size })\n : drawerSizeVertical({ size })\n\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed z-modal flex flex-col bg-background text-foreground shadow-xl',\n 'focus:outline-none',\n SIDE_POSITION[side],\n isHorizontal ? 'max-w-full h-full' : 'max-h-full w-full',\n sizeClass,\n ANIMATION_CLASSES[side],\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close className={cn(\n 'absolute right-4 top-4 rounded-md p-1',\n 'text-text-muted hover:text-foreground',\n 'transition-colors duration-fast',\n 'focus-visible:focus-ring focus-visible:outline-none',\n 'disabled:pointer-events-none'\n )}>\n {closeIcon || <DefaultCloseIcon className=\"icon-sm\" />}\n <span className=\"sr-only\">{closeLabel}</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DrawerPortal>\n )\n})\nDrawerContent.displayName = 'DrawerContent'\n\n// ─── DrawerHeader ───────────────────────────────────────────\nconst DrawerHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex flex-col gap-1.5 p-6 pb-0', className)}\n {...props}\n />\n))\nDrawerHeader.displayName = 'DrawerHeader'\n\n// ─── DrawerTitle ────────────────────────────────────────────\nconst DrawerTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold text-foreground', className)}\n {...props}\n />\n))\nDrawerTitle.displayName = 'DrawerTitle'\n\n// ─── DrawerDescription ─────────────────────────────────────\nconst DrawerDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-md text-text-muted', className)}\n {...props}\n />\n))\nDrawerDescription.displayName = 'DrawerDescription'\n\n// ─── DrawerBody ─────────────────────────────────────────────\nconst DrawerBody = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn('flex-1 overflow-y-auto p-6', className)}\n {...props}\n />\n))\nDrawerBody.displayName = 'DrawerBody'\n\n// ─── DrawerFooter ───────────────────────────────────────────\nconst DrawerFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n 'flex items-center justify-end gap-3 p-6 pt-0',\n className\n )}\n {...props}\n />\n))\nDrawerFooter.displayName = 'DrawerFooter'\n\n// ─── Exports ────────────────────────────────────────────────\nexport {\n Drawer,\n DrawerTrigger,\n DrawerPortal,\n DrawerOverlay,\n DrawerContent,\n DrawerHeader,\n DrawerTitle,\n DrawerDescription,\n DrawerBody,\n DrawerFooter,\n DrawerClose,\n drawerSizeHorizontal,\n drawerSizeVertical,\n}\n"],"mappings":";AAiBI,cAgIM,YAhIN;AAfJ,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,WAA8B;AACvC,SAAS,UAAU;AAGnB,MAAM,mBAAmB,CAAC,EAAE,UAAU,MACpC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IACP,aAAa;AAAA,IACb,eAAY;AAAA,IAEZ,8BAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,GAAE,wBAAuB;AAAA;AAC9E;AAQF,MAAM,oBAAgD;AAAA,EACpD,OAAQ;AAAA,EACR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MAAM,WAGvB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,WAAW,GAAG,8BAA8B,SAAS;AAAA,IACpD,GAAG;AAAA;AACN,CACD;AACD,WAAW,cAAc;AAGzB,MAAM,eAAe,MAAM,WAGzB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,aAAa,cAAc;","names":[]}
|
|
@@ -106,24 +106,41 @@ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
|
106
106
|
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
107
107
|
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
108
108
|
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
109
|
+
let lastInputWasKeyboard = false;
|
|
110
|
+
let inputTypeTrackerInstalled = false;
|
|
111
|
+
function useLastInputTypeTracker() {
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
if (inputTypeTrackerInstalled) return;
|
|
114
|
+
inputTypeTrackerInstalled = true;
|
|
115
|
+
document.addEventListener("keydown", () => {
|
|
116
|
+
lastInputWasKeyboard = true;
|
|
117
|
+
}, true);
|
|
118
|
+
document.addEventListener("pointerdown", () => {
|
|
119
|
+
lastInputWasKeyboard = false;
|
|
120
|
+
}, true);
|
|
121
|
+
}, []);
|
|
122
|
+
}
|
|
123
|
+
const DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, radius = "md", flush = false, size = "md", onCloseAutoFocus, ...props }, ref) => {
|
|
124
|
+
useLastInputTypeTracker();
|
|
125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownMenuStyleContext.Provider, { value: { radius, flush, size }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
+
DropdownMenuPrimitive.Content,
|
|
127
|
+
{
|
|
128
|
+
ref,
|
|
129
|
+
sideOffset,
|
|
130
|
+
onCloseAutoFocus: (e) => {
|
|
131
|
+
if (!lastInputWasKeyboard) e.preventDefault();
|
|
132
|
+
onCloseAutoFocus?.(e);
|
|
133
|
+
},
|
|
134
|
+
className: (0, import_utils.cn)(
|
|
135
|
+
"z-popover min-w-[8rem] overflow-hidden border border-border bg-background text-foreground shadow-lg",
|
|
136
|
+
flush ? "py-1" : "p-1",
|
|
137
|
+
contentRadiusMap[radius],
|
|
138
|
+
className
|
|
139
|
+
),
|
|
140
|
+
...props
|
|
141
|
+
}
|
|
142
|
+
) }) });
|
|
143
|
+
});
|
|
127
144
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
128
145
|
const DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => {
|
|
129
146
|
const { radius, flush, size } = React.useContext(DropdownMenuStyleContext);
|