@jbpark/ui-kit 5.4.5 → 5.4.7
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/Button.d.mts +8 -7
- package/dist/Button.d.mts.map +1 -1
- package/dist/Button.mjs +17 -11
- package/dist/Button.mjs.map +1 -1
- package/dist/Tag.d.mts +6 -5
- package/dist/Tag.d.mts.map +1 -1
- package/dist/Tag.mjs +8 -6
- package/dist/Tag.mjs.map +1 -1
- package/dist/components/atoms/checkbox/checkbox.mjs +1 -1
- package/dist/components/atoms/date-picker.mjs +2 -2
- package/dist/components/atoms/float-button/back-top.mjs +1 -1
- package/dist/components/atoms/input/search.mjs +2 -2
- package/dist/components/atoms/radio/group.mjs +1 -1
- package/dist/components/atoms/radio/radio.mjs +1 -1
- package/dist/components/molecules/menu/item/item.mjs +1 -1
- package/dist/components/molecules/upload.d.mts.map +1 -1
- package/dist/components/molecules/upload.mjs +4 -3
- package/dist/components/molecules/upload.mjs.map +1 -1
- package/dist/components/organisms/drawer.mjs +2 -2
- package/dist/components/organisms/imperative-stack.mjs +3 -2
- package/dist/components/organisms/imperative-stack.mjs.map +1 -1
- package/dist/components/organisms/modal.mjs +2 -2
- package/dist/components/organisms/toast.mjs +1 -1
- package/dist/components/templates/container.mjs +1 -1
- package/dist/components/templates/layout/content.mjs +1 -1
- package/dist/components/templates/layout/sider.mjs +1 -1
- package/dist/core/accordion.mjs +2 -2
- package/dist/core/badge.d.mts +1 -1
- package/dist/core/badge.mjs +1 -1
- package/dist/core/button.d.mts +2 -2
- package/dist/core/button.mjs +1 -1
- package/dist/core/calendar.mjs +1 -1
- package/dist/core/checkbox.mjs +1 -1
- package/dist/core/dialog.mjs +1 -1
- package/dist/core/label.d.mts +4 -4
- package/dist/core/label.d.mts.map +1 -1
- package/dist/core/label.mjs +5 -5
- package/dist/core/label.mjs.map +1 -1
- package/dist/core/radio-group.d.mts +5 -5
- package/dist/core/radio-group.d.mts.map +1 -1
- package/dist/core/radio-group.mjs +9 -9
- package/dist/core/radio-group.mjs.map +1 -1
- package/dist/core/select.d.mts +13 -13
- package/dist/core/select.d.mts.map +1 -1
- package/dist/core/select.mjs +20 -20
- package/dist/core/select.mjs.map +1 -1
- package/dist/core/separator.d.mts +4 -4
- package/dist/core/separator.d.mts.map +1 -1
- package/dist/core/separator.mjs +5 -5
- package/dist/core/separator.mjs.map +1 -1
- package/dist/lib/chassis.mjs +23 -0
- package/dist/lib/chassis.mjs.map +1 -0
- package/dist/providers/config/config.mjs +1 -1
- package/package.json +10 -5
package/dist/Button.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./core.mjs";
|
|
1
|
+
import * as React$1 from "react";
|
|
3
2
|
//#region src/components/atoms/button.d.ts
|
|
4
|
-
type
|
|
3
|
+
type NativeButtonProps = React$1.ComponentProps<'button'> & {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
};
|
|
5
6
|
type PresetColors = 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
|
|
6
|
-
interface Props extends Omit<
|
|
7
|
-
icon?: React.ReactNode;
|
|
7
|
+
interface Props extends Omit<NativeButtonProps, 'size' | 'variant' | 'type'> {
|
|
8
|
+
icon?: React$1.ReactNode;
|
|
8
9
|
block?: boolean;
|
|
9
10
|
danger?: boolean;
|
|
10
11
|
disabled?: boolean;
|
|
@@ -25,10 +26,10 @@ interface Props extends Omit<ButtonProps, 'size' | 'variant' | 'type'> {
|
|
|
25
26
|
shape?: 'default' | 'circle' | 'round';
|
|
26
27
|
color?: PresetColors | 'default' | 'primary' | 'danger';
|
|
27
28
|
loading?: boolean | {
|
|
28
|
-
icon: React.ReactNode;
|
|
29
|
+
icon: React$1.ReactNode;
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
declare const Button: ({ icon, className, type, variant, htmlType, size, color, shape, block, disabled, loading, danger, children, onMouseDown, ...props }: Props) =>
|
|
32
|
+
declare const Button: ({ icon, className, type, variant, htmlType, size, color, shape, block, disabled, loading, danger, asChild, children, onMouseDown, ...props }: Props) => React$1.JSX.Element;
|
|
32
33
|
//#endregion
|
|
33
34
|
export { Props, Button as default };
|
|
34
35
|
//# sourceMappingURL=Button.d.mts.map
|
package/dist/Button.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.mts","names":[],"sources":["../src/components/atoms/button.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.mts","names":[],"sources":["../src/components/atoms/button.tsx"],"mappings":";;KAYK,oBAAoB,QAAM;EAC7B;;KAGG;UAeY,cAAc,KAC7B;EAGA,OAAO,QAAM;EACb;EACA;EACA;EACA;;;;;;EAMA;EACA;;;;;;EAMA;EACA;EACA,QAAQ;EACR;IAAsB,MAAM,QAAM;;;cA2E9B,WAAU,MAAA,WAAA,MAAA,SAAA,UAAA,MAAA,OAAA,OAAA,OAAA,UAAA,SAAA,QAAA,SAAA,UAAA,gBAAA,SAiBb,UAAK,QAAA,IAAA"}
|
package/dist/Button.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "./utils.mjs";
|
|
3
|
-
import { Button as Button$1 } from "./core/button.mjs";
|
|
4
3
|
import { useConfig } from "./providers/config/context.mjs";
|
|
4
|
+
import { INTERACTIVE_CHASSIS } from "./lib/chassis.mjs";
|
|
5
|
+
import "react";
|
|
6
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
7
|
import { LoaderCircle } from "lucide-react";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
//#region src/components/atoms/button.tsx
|
|
8
|
-
const
|
|
10
|
+
const BUTTON_CHASSIS = cn(INTERACTIVE_CHASSIS, "outline-none", "disabled:pointer-events-none disabled:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4");
|
|
11
|
+
const BUTTON_BASE = cn(BUTTON_CHASSIS, "gap-2 whitespace-nowrap font-medium transition-all", "has-[>svg]:px-3");
|
|
9
12
|
const variantClasses = {
|
|
10
|
-
solid: "",
|
|
13
|
+
solid: cn("bg-primary text-primary-foreground", "hover:bg-primary/90"),
|
|
11
14
|
outlined: cn("border border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]", "bg-background text-foreground", "hover:bg-accent"),
|
|
12
15
|
dashed: cn("border border-dashed border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]", "bg-background text-foreground", "hover:bg-accent"),
|
|
13
16
|
filled: cn("bg-muted text-foreground", "hover:bg-muted/80"),
|
|
@@ -36,7 +39,7 @@ const shapesClasses = {
|
|
|
36
39
|
circle: "rounded-full",
|
|
37
40
|
round: "rounded-2xl"
|
|
38
41
|
};
|
|
39
|
-
const Button = ({ icon, className, type = "default", variant, htmlType = "button", size, color = "default", shape, block = false, disabled, loading, danger, children, onMouseDown, ...props }) => {
|
|
42
|
+
const Button = ({ icon, className, type = "default", variant, htmlType = "button", size, color = "default", shape, block = false, disabled, loading, danger, asChild = false, children, onMouseDown, ...props }) => {
|
|
40
43
|
const { componentSize, defaultProps } = useConfig();
|
|
41
44
|
const buttonDefaults = defaultProps?.button;
|
|
42
45
|
const resolvedSize = size ?? componentSize ?? "middle";
|
|
@@ -46,20 +49,23 @@ const Button = ({ icon, className, type = "default", variant, htmlType = "button
|
|
|
46
49
|
const colored = computedColor && computedColor !== "default";
|
|
47
50
|
const resolvedVariant = variant ?? typeToVariant[type] ?? "solid";
|
|
48
51
|
const isLoading = !!loading;
|
|
52
|
+
const Comp = asChild ? Slot : "button";
|
|
49
53
|
const displayIcon = loading ? typeof loading === "object" ? loading.icon : /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : icon;
|
|
50
|
-
return /* @__PURE__ */ jsxs(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
"data-color": computedColor,
|
|
56
|
-
className: cn("inline-flex items-center justify-center gap-x-2", "rounded-lg", "cursor-pointer", "h-auto py-0", "transition-all", variantClasses[resolvedVariant], sizesClasses[resolvedSize], iconOnly && ["p-0", iconClasses[resolvedSize]], shapesClasses[resolvedShape], block && "w-full", colored && (resolvedVariant === "solid" ? [
|
|
54
|
+
return /* @__PURE__ */ jsxs(Comp, {
|
|
55
|
+
"data-slot": "button",
|
|
56
|
+
"data-variant": "default",
|
|
57
|
+
"data-size": "default",
|
|
58
|
+
className: cn(BUTTON_BASE, "inline-flex items-center justify-center gap-x-2", "rounded-lg", "cursor-pointer", "h-auto py-0", "transition-all", variantClasses[resolvedVariant], sizesClasses[resolvedSize], iconOnly && ["p-0", iconClasses[resolvedSize]], shapesClasses[resolvedShape], block && "w-full", colored && (resolvedVariant === "solid" ? [
|
|
57
59
|
"bg-(--btn-bg)",
|
|
58
60
|
"hover:bg-(--btn-bg-hover)",
|
|
59
61
|
"active:bg-(--btn-bg-active)",
|
|
60
62
|
"text-(--btn-fg)",
|
|
61
63
|
"border-(--btn-border)"
|
|
62
64
|
] : ["text-(--btn-bg)", "border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]"]), className),
|
|
65
|
+
type: htmlType,
|
|
66
|
+
disabled: disabled || isLoading,
|
|
67
|
+
"aria-busy": isLoading,
|
|
68
|
+
"data-color": computedColor,
|
|
63
69
|
onMouseDown: (e) => {
|
|
64
70
|
onMouseDown?.(e);
|
|
65
71
|
},
|
package/dist/Button.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","names":[
|
|
1
|
+
{"version":3,"file":"Button.mjs","names":[],"sources":["../src/components/atoms/button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\nimport { LoaderCircle } from 'lucide-react';\n\nimport { useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport { INTERACTIVE_CHASSIS } from '../../lib/chassis';\n\ntype NativeButtonProps = React.ComponentProps<'button'> & {\n asChild?: boolean;\n};\n\ntype PresetColors =\n | 'blue'\n | 'purple'\n | 'cyan'\n | 'green'\n | 'magenta'\n | 'pink'\n | 'red'\n | 'orange'\n | 'yellow'\n | 'volcano'\n | 'geekblue'\n | 'lime'\n | 'gold';\n\nexport interface Props extends Omit<\n NativeButtonProps,\n 'size' | 'variant' | 'type'\n> {\n icon?: React.ReactNode;\n block?: boolean;\n danger?: boolean;\n disabled?: boolean;\n size?: 'small' | 'middle' | 'large';\n /**\n * antd-style visual preset. Maps to a `variant` internally — passing\n * both `type` and `variant` lets `variant` win, so it can override the\n * preset for one-off cases without needing every value duplicated here.\n */\n type?: 'primary' | 'default' | 'dashed' | 'text' | 'link';\n variant?: 'solid' | 'outlined' | 'dashed' | 'filled' | 'text' | 'link';\n /**\n * Native `<button>` `type` (`button`/`submit`/`reset`), kept separate\n * from the antd-style `type` above. Defaults to `'button'` so a Button\n * placed inside a `<form>` doesn't submit it unless explicitly opted in.\n */\n htmlType?: 'button' | 'submit' | 'reset';\n shape?: 'default' | 'circle' | 'round';\n color?: PresetColors | 'default' | 'primary' | 'danger';\n loading?: boolean | { icon: React.ReactNode };\n}\n\n// Chassis absorbed from core/button's cva base (#278 ③ / #294 Phase 4). The\n// shared focus/aria set lives in INTERACTIVE_CHASSIS; a Button additionally\n// disables and sizes its icons. Kept as constants so the absorb relocates this\n// treatment rather than dropping it (the #177 class of silent regression the\n// #300/#301 net guards).\nconst BUTTON_CHASSIS = cn(\n INTERACTIVE_CHASSIS,\n 'outline-none',\n 'disabled:pointer-events-none disabled:opacity-50',\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n);\n\n// Presentation the atom builds on. The size/variant/shape classes below still\n// override the incidental leftovers exactly as they did when this wrapped\n// core/button, so the rendered output is unchanged (verified against a\n// pre-refactor render matrix).\nconst BUTTON_BASE = cn(\n BUTTON_CHASSIS,\n 'gap-2 whitespace-nowrap font-medium transition-all',\n 'has-[>svg]:px-3',\n);\n\nconst variantClasses: Record<string, string> = {\n // solid used to inherit its fill from core/button's default variant; carry it\n // explicitly now that the primitive is absorbed. A colored solid overrides\n // this with the --btn-* custom properties further down.\n solid: cn('bg-primary text-primary-foreground', 'hover:bg-primary/90'),\n outlined: cn(\n 'border border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]',\n 'bg-background text-foreground',\n 'hover:bg-accent',\n ),\n dashed: cn(\n 'border border-dashed border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]',\n 'bg-background text-foreground',\n 'hover:bg-accent',\n ),\n filled: cn('bg-muted text-foreground', 'hover:bg-muted/80'),\n text: cn('bg-transparent text-foreground', 'hover:bg-accent'),\n link: cn(\n 'bg-transparent text-primary',\n 'underline-offset-4 hover:underline',\n 'hover:bg-primary/10',\n ),\n};\n\nconst typeToVariant: Record<string, string> = {\n primary: 'solid',\n default: 'outlined',\n dashed: 'dashed',\n text: 'text',\n link: 'link',\n};\n\nconst sizesClasses: Record<string, string> = {\n small: 'h-6 px-3 text-sm',\n middle: 'h-8 px-4 text-base',\n large: 'h-10 px-5 text-lg',\n};\n\nconst iconClasses: Record<string, string> = {\n small: `size-6 [&_svg:not([class*='size-'])]:size-3`,\n middle: `size-8 [&_svg:not([class*='size-'])]:size-4`,\n large: `size-10 [&_svg:not([class*='size-'])]:size-5`,\n};\n\nconst shapesClasses = {\n default: 'rounded-sm',\n circle: 'rounded-full',\n round: 'rounded-2xl',\n};\n\nconst Button = ({\n icon,\n className,\n type = 'default',\n variant,\n htmlType = 'button',\n size,\n color = 'default',\n shape,\n block = false,\n disabled,\n loading,\n danger,\n asChild = false,\n children,\n onMouseDown,\n ...props\n}: Props) => {\n const { componentSize, defaultProps } = useConfig();\n const buttonDefaults = defaultProps?.button as\n Partial<Pick<Props, 'shape'>> | undefined;\n const resolvedSize = size ?? componentSize ?? 'middle';\n const resolvedShape = shape ?? buttonDefaults?.shape ?? 'default';\n const iconOnly = icon && !children;\n const computedColor = danger ? 'danger' : color;\n const colored = computedColor && computedColor !== 'default';\n const resolvedVariant = variant ?? typeToVariant[type] ?? 'solid';\n const isLoading = !!loading;\n\n const Comp = asChild ? Slot : 'button';\n\n const displayIcon = loading ? (\n typeof loading === 'object' ? (\n loading.icon\n ) : (\n <LoaderCircle className=\"animate-spin\" />\n )\n ) : (\n icon\n );\n\n return (\n <Comp\n data-slot=\"button\"\n data-variant=\"default\"\n data-size=\"default\"\n className={cn(\n BUTTON_BASE,\n 'inline-flex items-center justify-center gap-x-2',\n 'rounded-lg',\n 'cursor-pointer',\n 'h-auto py-0',\n 'transition-all',\n variantClasses[resolvedVariant],\n sizesClasses[resolvedSize],\n iconOnly && ['p-0', iconClasses[resolvedSize]],\n shapesClasses[resolvedShape],\n block && 'w-full',\n colored &&\n (resolvedVariant === 'solid'\n ? [\n 'bg-(--btn-bg)',\n 'hover:bg-(--btn-bg-hover)',\n 'active:bg-(--btn-bg-active)',\n 'text-(--btn-fg)',\n 'border-(--btn-border)',\n ]\n : [\n 'text-(--btn-bg)',\n 'border-[color-mix(in_oklch,var(--btn-border),transparent_50%)]',\n //\n ]),\n className,\n //\n )}\n type={htmlType}\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n data-color={computedColor}\n onMouseDown={e => {\n onMouseDown?.(e);\n }}\n {...props}\n >\n {displayIcon}\n {children}\n </Comp>\n );\n};\n\nexport default Button;\n"],"mappings":";;;;;;;;;AA+DA,MAAM,iBAAiB,GACrB,qBACA,gBACA,oDACA,mFACF;AAMA,MAAM,cAAc,GAClB,gBACA,sDACA,iBACF;AAEA,MAAM,iBAAyC;CAI7C,OAAO,GAAG,sCAAsC,qBAAqB;CACrE,UAAU,GACR,yEACA,iCACA,iBACF;CACA,QAAQ,GACN,uFACA,iCACA,iBACF;CACA,QAAQ,GAAG,4BAA4B,mBAAmB;CAC1D,MAAM,GAAG,kCAAkC,iBAA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AChB,cAAc,CAAC;EACjB;EACA,GAAI;EAxCN,UAAA,CA0CG,aACA,QACG;;AAEV"}
|
package/dist/Tag.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./core.mjs";
|
|
1
|
+
import * as React$1 from "react";
|
|
3
2
|
//#region src/components/atoms/tag.d.ts
|
|
4
|
-
type
|
|
5
|
-
|
|
3
|
+
type NativeSpanProps = React$1.ComponentProps<'span'> & {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
};
|
|
6
|
+
interface Props extends Omit<NativeSpanProps, 'variant'> {
|
|
6
7
|
variant?: 'default' | 'outlined';
|
|
7
8
|
color?: 'default' | 'primary' | 'success' | 'warning' | 'danger';
|
|
8
9
|
}
|
|
9
|
-
declare const Tag: ({ className, variant, color, children, ...props }: Props) =>
|
|
10
|
+
declare const Tag: ({ className, variant, color, asChild, children, ...props }: Props) => React$1.JSX.Element;
|
|
10
11
|
//#endregion
|
|
11
12
|
export { Props, Tag as default };
|
|
12
13
|
//# sourceMappingURL=Tag.d.mts.map
|
package/dist/Tag.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.d.mts","names":[],"sources":["../src/components/atoms/tag.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tag.d.mts","names":[],"sources":["../src/components/atoms/tag.tsx"],"mappings":";;KAQK,kBAAkB,QAAM;EAC3B;;UAGe,cAAc,KAAK;EAClC;EACA;;cAoCI,QAAO,WAAA,SAAA,OAAA,SAAA,aAAA,SAOV,UAAK,QAAA,IAAA"}
|
package/dist/Tag.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { cn } from "./utils.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { INTERACTIVE_CHASSIS } from "./lib/chassis.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
5
|
import { jsx } from "react/jsx-runtime";
|
|
4
6
|
//#region src/components/atoms/tag.tsx
|
|
5
|
-
const
|
|
7
|
+
const TAG_BASE = cn(INTERACTIVE_CHASSIS, "border w-fit whitespace-nowrap overflow-hidden", "text-xs font-medium gap-1 transition-[color,box-shadow]", "[&>svg]:size-3 [&>svg]:pointer-events-none", "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground");
|
|
6
8
|
const fillColorClasses = {
|
|
7
9
|
default: "border-transparent bg-muted text-muted-foreground",
|
|
8
10
|
primary: "border-transparent bg-primary/10 text-primary",
|
|
@@ -17,10 +19,10 @@ const outlinedColorClasses = {
|
|
|
17
19
|
warning: "border-yellow-500 text-yellow-600 dark:text-yellow-400",
|
|
18
20
|
danger: "border-destructive text-destructive"
|
|
19
21
|
};
|
|
20
|
-
const Tag = ({ className, variant = "default", color = "default", children, ...props }) => {
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
|
|
23
|
-
className: cn("rounded-full px-2.5 py-1", "text-xs font-medium", variant === "default" && fillColorClasses[color], variant === "outlined" && outlinedColorClasses[color], className),
|
|
22
|
+
const Tag = ({ className, variant = "default", color = "default", asChild = false, children, ...props }) => {
|
|
23
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "span", {
|
|
24
|
+
"data-slot": "badge",
|
|
25
|
+
className: cn(TAG_BASE, "rounded-full px-2.5 py-1", "text-xs font-medium", variant === "default" && fillColorClasses[color], variant === "outlined" && outlinedColorClasses[color], className),
|
|
24
26
|
...props,
|
|
25
27
|
children
|
|
26
28
|
});
|
package/dist/Tag.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.mjs","names":[
|
|
1
|
+
{"version":3,"file":"Tag.mjs","names":[],"sources":["../src/components/atoms/tag.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nimport { cn } from '@repo/ui/utils';\n\nimport { INTERACTIVE_CHASSIS } from '../../lib/chassis';\n\ntype NativeSpanProps = React.ComponentProps<'span'> & {\n asChild?: boolean;\n};\n\nexport interface Props extends Omit<NativeSpanProps, 'variant'> {\n variant?: 'default' | 'outlined';\n color?: 'default' | 'primary' | 'success' | 'warning' | 'danger';\n}\n\n// Base absorbed from core/badge's cva base + its `outline` variant, which Tag\n// always rendered as (#278 ③ / #294 Phase 4). The shared focus/aria/centering\n// set lives in INTERACTIVE_CHASSIS; a Tag adds badge geometry and its svg\n// sizing but — unlike Button — no `disabled:*` (a Tag is not disableable). The\n// rounded/padding leftovers are overridden by the atom classes below exactly as\n// before, so the rendered output is unchanged (verified against a pre-refactor\n// render matrix).\nconst TAG_BASE = cn(\n INTERACTIVE_CHASSIS,\n 'border w-fit whitespace-nowrap overflow-hidden',\n 'text-xs font-medium gap-1 transition-[color,box-shadow]',\n '[&>svg]:size-3 [&>svg]:pointer-events-none',\n 'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',\n);\n\nconst fillColorClasses: Record<string, string> = {\n default: 'border-transparent bg-muted text-muted-foreground',\n primary: 'border-transparent bg-primary/10 text-primary',\n success:\n 'border-transparent bg-green-500/10 text-green-600 dark:text-green-400',\n warning:\n 'border-transparent bg-yellow-500/10 text-yellow-600 dark:text-yellow-400',\n danger: 'border-transparent bg-destructive/10 text-destructive',\n};\n\nconst outlinedColorClasses: Record<string, string> = {\n default: 'border-border text-foreground',\n primary: 'border-primary text-primary',\n success: 'border-green-500 text-green-600 dark:text-green-400',\n warning: 'border-yellow-500 text-yellow-600 dark:text-yellow-400',\n danger: 'border-destructive text-destructive',\n};\n\nconst Tag = ({\n className,\n variant = 'default',\n color = 'default',\n asChild = false,\n children,\n ...props\n}: Props) => {\n const Comp = asChild ? Slot : 'span';\n\n return (\n <Comp\n data-slot=\"badge\"\n className={cn(\n TAG_BASE,\n 'rounded-full px-2.5 py-1',\n 'text-xs font-medium',\n variant === 'default' && fillColorClasses[color],\n variant === 'outlined' && outlinedColorClasses[color],\n className,\n //\n )}\n {...props}\n >\n {children}\n </Comp>\n );\n};\n\nexport default Tag;\n"],"mappings":";;;;;;AAwBA,MAAM,WAAW,GACf,qBACA,kDACA,2DACA,8CACA,wEACF;AAEA,MAAM,mBAA2C;CAC/C,SAAS;CACT,SAAS;CACT,SACE;CACF,SACE;CACF,QAAQ;AACV;AAEA,MAAM,uBAA+C;CACnD,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAM,OAAO,EACX,WACA,UAAU,WACV,QAAQ,WACR,UAAU,OACV,UACA,GAAG,YACQ;CAGX,OACE,oBAHW,UAAU,OAAO,QAG5B;EACE,aAAU;EACV,WAAW,GACT,UACA,4BACA,uBACA,YAAY,aAAa,iBAAiB,QAC1C,YAAY,cAAc,qBAAqB,QAC/C,SAEF;EACA,GAAI;EAEH;CACG,CAAA;AAEV"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import { checkbox_exports } from "../../../core/checkbox.mjs";
|
|
4
4
|
import { label_exports } from "../../../core/label.mjs";
|
|
5
|
-
import { Square, SquareCheck } from "lucide-react";
|
|
6
5
|
import { useId, useRef } from "react";
|
|
6
|
+
import { Square, SquareCheck } from "lucide-react";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useControllableState, useKeyPress } from "@jbpark/use-hooks";
|
|
9
9
|
//#region src/components/atoms/checkbox/checkbox.tsx
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../utils.mjs";
|
|
3
|
-
import { calendar_exports } from "../../core/calendar.mjs";
|
|
4
3
|
import Button from "../../Button.mjs";
|
|
4
|
+
import { calendar_exports } from "../../core/calendar.mjs";
|
|
5
5
|
import Popover from "./popover.mjs";
|
|
6
|
-
import { CalendarIcon } from "lucide-react";
|
|
7
6
|
import { useState } from "react";
|
|
7
|
+
import { CalendarIcon } from "lucide-react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
10
10
|
import { format } from "date-fns";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../../providers/config/context.mjs";
|
|
4
4
|
import FloatButton from "./float-button.mjs";
|
|
5
|
-
import { ArrowUp } from "lucide-react";
|
|
6
5
|
import { useRef } from "react";
|
|
6
|
+
import { ArrowUp } from "lucide-react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { useMergedRef, useWindowScroll } from "@jbpark/use-hooks";
|
|
9
9
|
//#region src/components/atoms/float-button/back-top.tsx
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../../providers/config/context.mjs";
|
|
4
|
-
import { input_exports } from "../../../core/input.mjs";
|
|
5
4
|
import Button from "../../../Button.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { input_exports } from "../../../core/input.mjs";
|
|
7
6
|
import { useRef, useState } from "react";
|
|
7
|
+
import { CircleX, Search } from "lucide-react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useMergedRef } from "@jbpark/use-hooks";
|
|
10
10
|
//#region src/components/atoms/input/search.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
|
-
import { radio_group_exports } from "../../../core/radio-group.mjs";
|
|
4
3
|
import Button from "../../../Button.mjs";
|
|
4
|
+
import { radio_group_exports } from "../../../core/radio-group.mjs";
|
|
5
5
|
import { normalizeOptions, warnOnDuplicateOptionValues } from "../option-group.mjs";
|
|
6
6
|
import { RadioGroupContext } from "./context.mjs";
|
|
7
7
|
import Radio from "./radio.mjs";
|
|
@@ -3,8 +3,8 @@ import { cn } from "../../../utils.mjs";
|
|
|
3
3
|
import { field_exports } from "../../../core/field.mjs";
|
|
4
4
|
import { radio_group_exports } from "../../../core/radio-group.mjs";
|
|
5
5
|
import { RadioGroupContext } from "./context.mjs";
|
|
6
|
-
import { Circle, CircleCheck } from "lucide-react";
|
|
7
6
|
import { useContext, useId, useRef } from "react";
|
|
7
|
+
import { Circle, CircleCheck } from "lucide-react";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useControllableState, useKeyPress } from "@jbpark/use-hooks";
|
|
10
10
|
//#region src/components/atoms/radio/radio.tsx
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../../../utils.mjs";
|
|
3
3
|
import Label from "./label.mjs";
|
|
4
4
|
import { MENU_CLASSNAMES } from "../menu.mjs";
|
|
5
|
-
import { ChevronDown } from "lucide-react";
|
|
6
5
|
import { createElement, useRef, useState } from "react";
|
|
6
|
+
import { ChevronDown } from "lucide-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion } from "motion/react";
|
|
9
9
|
//#region src/components/molecules/menu/item/item.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.mts","names":[],"sources":["../../../src/components/molecules/upload.tsx"],"mappings":";
|
|
1
|
+
{"version":3,"file":"upload.d.mts","names":[],"sources":["../../../src/components/molecules/upload.tsx"],"mappings":";UAuBiB;EACf;EACA;EACA;;UAGe;EACf,eAAe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;;EAEF,YAAY,OAAO;;;;;EAKnB,YAAY;IAAQ,MAAM;IAAM;;;cAO5B,WAAU,cAAA,OAAA,QAAA,UAAA,QAAA,UAAA,UAAA,WAAA,YAAA,UAAA,WAAA,YAWb,0BAAK,IAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../utils.mjs";
|
|
3
3
|
import Button from "../../Button.mjs";
|
|
4
|
-
import { Upload, X } from "lucide-react";
|
|
5
4
|
import { useId } from "react";
|
|
5
|
+
import { Upload, X } from "lucide-react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useControllableState, useFileDrop, useFileToDataUrl } from "@jbpark/use-hooks";
|
|
8
|
-
import { v4 } from "uuid";
|
|
9
8
|
//#region src/components/molecules/upload.tsx
|
|
9
|
+
let uidCounter = 0;
|
|
10
|
+
const nextUid = () => uidCounter += 1;
|
|
10
11
|
const isImage = (file) => /^data:image\//.test(file.url) || /\.(png|jpe?g|gif|webp|svg)$/i.test(file.name);
|
|
11
12
|
const Upload$1 = ({ defaultValue = [], value: _value, multiple = true, accept = "image/*", maxCount, disabled, className, classNames, onChange: _onChange = () => {}, onReject }) => {
|
|
12
13
|
const inputId = useId();
|
|
@@ -27,7 +28,7 @@ const Upload$1 = ({ defaultValue = [], value: _value, multiple = true, accept =
|
|
|
27
28
|
const uploaded = (await Promise.all(accepted.map(async (file) => {
|
|
28
29
|
try {
|
|
29
30
|
return {
|
|
30
|
-
uid: `${file.name}-${file.lastModified}-${file.size}-${
|
|
31
|
+
uid: `${file.name}-${file.lastModified}-${file.size}-${nextUid()}`,
|
|
31
32
|
name: file.name,
|
|
32
33
|
url: await readAsDataUrl(file)
|
|
33
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.mjs","names":["Upload","
|
|
1
|
+
{"version":3,"file":"upload.mjs","names":["Upload","UploadIcon"],"sources":["../../../src/components/molecules/upload.tsx"],"sourcesContent":["'use client';\n\nimport { useId } from 'react';\n\nimport {\n useControllableState,\n useFileDrop,\n useFileToDataUrl,\n} from '@jbpark/use-hooks';\nimport { Upload as UploadIcon, X } from 'lucide-react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Button from '../atoms/button';\n\n// Monotonic per-session counter used as a uniqueness tiebreaker for file\n// uids. Guarantees a unique suffix even for the same file (identical\n// name/lastModified/size) added twice, which name+lastModified+size alone\n// can't. These uids are internal React keys, not cryptographic, so a plain\n// counter is enough — and it avoids a runtime `uuid` dependency.\nlet uidCounter = 0;\nconst nextUid = () => (uidCounter += 1);\n\nexport interface UploadFile {\n uid: string;\n name: string;\n url: string;\n}\n\nexport interface Props {\n defaultValue?: UploadFile[];\n value?: UploadFile[];\n multiple?: boolean;\n accept?: string;\n maxCount?: number;\n disabled?: boolean;\n className?: string;\n classNames?: {\n dropzone?: string;\n list?: string;\n item?: string;\n };\n onChange?: (files: UploadFile[]) => void;\n /**\n * Called once per file that didn't make it in — either bumped by\n * `maxCount` or failed to read.\n */\n onReject?: (info: { file: File; reason: 'max-count' | 'read-error' }) => void;\n}\n\nconst isImage = (file: UploadFile) =>\n /^data:image\\//.test(file.url) ||\n /\\.(png|jpe?g|gif|webp|svg)$/i.test(file.name);\n\nconst Upload = ({\n defaultValue = [],\n value: _value,\n multiple = true,\n accept = 'image/*',\n maxCount,\n disabled,\n className,\n classNames,\n onChange: _onChange = () => {},\n onReject,\n}: Props) => {\n const inputId = useId();\n const readAsDataUrl = useFileToDataUrl();\n const [files, setFiles] = useControllableState<UploadFile[]>({\n value: _value,\n defaultValue,\n onChange: _onChange,\n });\n\n const addFiles = async (incoming: File[]) => {\n const remaining =\n typeof maxCount === 'number'\n ? Math.max(0, maxCount - files.length)\n : incoming.length;\n\n const accepted = incoming.slice(0, remaining);\n const rejected = incoming.slice(remaining);\n\n rejected.forEach(file => onReject?.({ file, reason: 'max-count' }));\n\n if (accepted.length === 0) {\n return;\n }\n\n const uploaded = (\n await Promise.all(\n accepted.map(async file => {\n try {\n return {\n // `nextUid()` guarantees uniqueness even for the same file\n // added twice (identical name/lastModified/size), which\n // name+lastModified+size alone can't — a collision there\n // corrupted React's item keys and made removeFile's\n // uid-based filter delete both copies at once.\n uid: `${file.name}-${file.lastModified}-${file.size}-${nextUid()}`,\n name: file.name,\n url: await readAsDataUrl(file),\n };\n } catch {\n onReject?.({ file, reason: 'read-error' });\n return null;\n }\n }),\n )\n ).filter((file): file is UploadFile => file !== null);\n\n if (uploaded.length === 0) {\n return;\n }\n\n setFiles([...files, ...uploaded]);\n };\n\n const removeFile = (uid: string) => {\n setFiles(files.filter(file => file.uid !== uid));\n };\n\n const { dropRef, isDragging } = useFileDrop<HTMLLabelElement>({\n accept,\n multiple,\n disabled,\n onDrop: addFiles,\n });\n\n return (\n <div\n className={cn(\n 'flex flex-col gap-3',\n className,\n //\n )}\n >\n <label\n ref={dropRef}\n htmlFor={inputId}\n className={cn(\n 'flex cursor-pointer flex-col items-center justify-center gap-2',\n 'rounded-md border border-dashed p-6 text-center',\n 'text-muted-foreground text-sm',\n 'transition-colors',\n isDragging && 'border-primary bg-accent',\n disabled && 'pointer-events-none cursor-not-allowed opacity-50',\n classNames?.dropzone,\n //\n )}\n >\n <UploadIcon className=\"size-6\" />\n <span>Click or drag file{multiple ? 's' : ''} to upload</span>\n <input\n id={inputId}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n className=\"hidden\"\n onChange={e => {\n if (e.target.files?.length) {\n addFiles(Array.from(e.target.files));\n }\n e.target.value = '';\n }}\n />\n </label>\n\n {files.length > 0 && (\n <ul\n className={cn(\n 'm-0 flex list-none flex-col gap-2 p-0',\n classNames?.list,\n //\n )}\n >\n {files.map(file => (\n <li\n key={file.uid}\n className={cn(\n 'flex items-center gap-2 rounded-md border p-2',\n classNames?.item,\n //\n )}\n >\n {isImage(file) && (\n <img\n src={file.url}\n alt=\"\"\n className=\"size-10 shrink-0 rounded object-cover\"\n />\n )}\n <span className=\"flex-1 truncate text-sm\">{file.name}</span>\n <Button\n type=\"text\"\n shape=\"circle\"\n size=\"small\"\n icon={<X className=\"size-4\" />}\n onClick={() => removeFile(file.uid)}\n className=\"text-muted-foreground hover:text-foreground shrink-0\"\n aria-label={`Remove ${file.name}`}\n />\n </li>\n ))}\n </ul>\n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{ cn, renderConditional } from "../../utils.mjs";
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../providers/config/context.mjs";
|
|
4
|
-
import { drawer_exports } from "../../core/drawer.mjs";
|
|
5
4
|
import Button from "../../Button.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { drawer_exports } from "../../core/drawer.mjs";
|
|
7
6
|
import { useEffect } from "react";
|
|
7
|
+
import { X } from "lucide-react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/organisms/drawer.tsx
|
|
10
10
|
const { DrawerContent, Drawer: DrawerCore, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle } = drawer_exports;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { ConfigSnapshotProvider, getRootConfigValue } from "../../providers/config/registry.mjs";
|
|
3
3
|
import { useCallback, useSyncExternalStore } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { v4 } from "uuid";
|
|
6
5
|
import { createRoot } from "react-dom/client";
|
|
7
6
|
//#region src/components/organisms/imperative-stack.tsx
|
|
7
|
+
let idCounter = 0;
|
|
8
|
+
const nextId = () => `stack-${idCounter += 1}`;
|
|
8
9
|
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
9
10
|
function createImperativeStack({ createRootElement, StackItem }) {
|
|
10
11
|
const containerStates = /* @__PURE__ */ new Map();
|
|
@@ -58,7 +59,7 @@ function createImperativeStack({ createRootElement, StackItem }) {
|
|
|
58
59
|
root.render(/* @__PURE__ */ jsx(StackRenderer, { container: targetContainer }));
|
|
59
60
|
}
|
|
60
61
|
const state = getContainerState(targetContainer);
|
|
61
|
-
const id = props.id ||
|
|
62
|
+
const id = props.id || nextId();
|
|
62
63
|
state.stack = [...state.stack, {
|
|
63
64
|
...props,
|
|
64
65
|
id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imperative-stack.mjs","names":[
|
|
1
|
+
{"version":3,"file":"imperative-stack.mjs","names":[],"sources":["../../../src/components/organisms/imperative-stack.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { Root, createRoot } from 'react-dom/client';\n\nimport { ConfigSnapshotProvider, getRootConfigValue } from '@repo/ui/providers';\n\n// Monotonic per-session counter for stack item ids. These ids are internal\n// handles (React keys + destroy(id) lookups), not cryptographic, so a plain\n// counter is enough and avoids a runtime `uuid` dependency.\nlet idCounter = 0;\nconst nextId = () => `stack-${(idCounter += 1)}`;\n\n// Shared machinery behind Modal.info/success/error/warning/confirm and\n// Toast.info/success/error/warning — both used to independently\n// reimplement ~120 near-identical lines of this (container-scoped stack,\n// a React root per container, imperative render/destroy). The only parts\n// that actually differ between the two are the DOM node their stack\n// mounts into (position/ARIA) and which component renders each stack\n// entry — everything else here is generic over that.\n\nexport const isBrowser =\n typeof window !== 'undefined' && typeof document !== 'undefined';\n\ntype ContainerState<TProps> = {\n stack: (TProps & { id: string })[];\n update: (() => void) | null;\n};\n\nexport interface ImperativeStack<\n TProps extends { id?: string; container?: HTMLElement },\n> {\n render: (props: TProps) => string | undefined;\n destroy: (id?: string) => void;\n getRootElement: (container?: HTMLElement) => HTMLElement | null;\n}\n\nexport interface ImperativeStackOptions<\n TProps extends { id?: string; container?: HTMLElement },\n> {\n /** Creates the DOM node this stack's React root mounts into — not yet\n * attached to the document; the factory appends it to the target\n * container itself. Called once per distinct container. */\n createRootElement: () => HTMLElement;\n /** Renders one stack entry — typically each caller's \"Static<Thing>\"\n * component, which owns its own createPortal(..., getRootElement()). */\n StackItem: React.ComponentType<TProps & { id: string }>;\n}\n\nexport function createImperativeStack<\n TProps extends { id?: string; container?: HTMLElement },\n>({\n createRootElement,\n StackItem,\n}: ImperativeStackOptions<TProps>): ImperativeStack<TProps> {\n const containerStates = new Map<HTMLElement, ContainerState<TProps>>();\n const rootElements = new WeakMap<HTMLElement, HTMLElement>();\n const reactRoots = new Map<HTMLElement, Root>();\n\n const getContainerState = (\n container: HTMLElement,\n ): ContainerState<TProps> => {\n let state = containerStates.get(container);\n\n if (!state) {\n state = { stack: [], update: null };\n containerStates.set(container, state);\n }\n\n return state;\n };\n\n // Shared by `render` and `getRootElement` so both agree on the same\n // target container whenever the caller doesn't pass one explicitly — the\n // stack's React root (created once, in `render`) and the DOM node a\n // `StackItem` (e.g. StaticToast) later portals into (calling\n // `getRootElement` again with the same, possibly-undefined `container`)\n // would otherwise resolve two different containers here, splitting the\n // React tree (correctly under the root Config, via ConfigSnapshotProvider\n // above) from the actual visible DOM (silently back under `document.body`,\n // outside the Config's themed wrapper — undoing this fix's whole point).\n const resolveContainer = (container?: HTMLElement): HTMLElement =>\n container || getRootConfigValue()?.getContainer() || document.body;\n\n const getRootElement = (container?: HTMLElement): HTMLElement | null => {\n if (!isBrowser) {\n return null;\n }\n\n const targetContainer = resolveContainer(container);\n let rootEl = rootElements.get(targetContainer);\n\n if (!rootEl) {\n rootEl = createRootElement();\n targetContainer.appendChild(rootEl);\n rootElements.set(targetContainer, rootEl);\n }\n\n return rootEl;\n };\n\n const StackRenderer = ({ container }: { container: HTMLElement }) => {\n const subscribe = useCallback(\n (onStoreChange: () => void) => {\n const state = getContainerState(container);\n state.update = onStoreChange;\n return () => {\n state.update = null;\n };\n },\n [container],\n );\n\n const getSnapshot = useCallback(\n () => getContainerState(container).stack,\n [container],\n );\n\n const stack = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n return (\n <ConfigSnapshotProvider>\n {stack.map(({ id, ...props }) => (\n <StackItem key={id} id={id} {...(props as TProps)} />\n ))}\n </ConfigSnapshotProvider>\n );\n };\n\n const render = (props: TProps): string | undefined => {\n if (!isBrowser) {\n return;\n }\n\n // An explicit `container` prop always wins (it may be chosen for\n // layout reasons unrelated to theming); otherwise mount into the root\n // Config's own themed wrapper element (if one renders — see\n // `needsWrapper` in config.tsx) so CSS custom properties and the\n // `.dark` class cascade to this stack via normal DOM inheritance, not\n // just `document.body` sitting as an unthemed sibling of it.\n const targetContainer = resolveContainer(props.container);\n const rootElement = getRootElement(targetContainer)!;\n\n if (!reactRoots.has(targetContainer)) {\n const root = createRoot(rootElement);\n reactRoots.set(targetContainer, root);\n root.render(<StackRenderer container={targetContainer} />);\n }\n\n const state = getContainerState(targetContainer);\n const id = props.id || nextId();\n state.stack = [...state.stack, { ...props, id }];\n state.update?.();\n\n return id;\n };\n\n const destroy = (id?: string) => {\n if (!id) {\n containerStates.forEach(state => {\n state.stack = [];\n state.update?.();\n });\n reactRoots.forEach((root, container) => {\n root.unmount();\n rootElements.get(container)?.remove();\n rootElements.delete(container);\n });\n reactRoots.clear();\n containerStates.clear();\n return;\n }\n\n containerStates.forEach((state, container) => {\n if (!state.stack.some(item => item.id === id)) {\n return;\n }\n\n state.stack = state.stack.filter(item => item.id !== id);\n state.update?.();\n\n if (!state.stack.length) {\n reactRoots.get(container)?.unmount();\n reactRoots.delete(container);\n containerStates.delete(container);\n rootElements.get(container)?.remove();\n rootElements.delete(container);\n }\n });\n };\n\n return { render, destroy, getRootElement };\n}\n"],"mappings":";;;;;;AAUA,IAAI,YAAY;AAChB,MAAM,eAAe,SAAU,aAAa;AAU5C,MAAa,YACX,OAAO,WAAW,eAAe,OAAO,aAAa;AA2BvD,SAAgB,sBAEd,EACA,mBACA,aAC0D;CAC1D,MAAM,kCAAkB,IAAI,IAAyC;CACrE,MAAM,+BAAe,IAAI,QAAkC;CAC3D,MAAM,6BAAa,IAAI,IAAuB;CAE9C,MAAM,qBACJ,cAC2B;EAC3B,IAAI,QAAQ,gBAAgB,IAAI,SAAS;EAEzC,IAAI,CAAC,OAAO;GACV,QAAQ;IAAE,OAAO,CAAC;IAAG,QAAQ;GAAK;GAClC,gBAAgB,IAAI,WAAW,KAAK;EACtC;EAEA,OAAO;CACT;CAWA,MAAM,oBAAoB,cACxB,aAAa,mBAAmB,CAAC,EAAE,aAAa,KAAK,SAAS;CAEhE,MAAM,kBAAkB,cAAgD;EACtE,IAAI,CAAC,WACH,OAAO;E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IACf,MAAM,SAAS;GACjB,CAAC;GACD,WAAW,SAAS,MAAM,cAAc;IACtC,KAAK,QAAQ;IACb,aAAa,IAAI,SAAS,CAAC,EAAE,OAAO;IACpC,aAAa,OAAO,SAAS;GAC/B,CAAC;GACD,WAAW,MAAM;GACjB,gBAAgB,MAAM;GACtB;EACF;EAEA,gBAAgB,SAAS,OAAO,cAAc;GAC5C,IAAI,CAAC,MAAM,MAAM,MAAK,SAAQ,KAAK,OAAO,EAAE,GAC1C;GAGF,MAAM,QAAQ,MAAM,MAAM,QAAO,SAAQ,KAAK,OAAO,EAAE;GACvD,MAAM,SAAS;GAEf,IAAI,CAAC,MAAM,MAAM,QAAQ;IACvB,WAAW,IAAI,SAAS,CAAC,EAAE,QAAQ;IACnC,WAAW,OAAO,SAAS;IAC3B,gBAAgB,OAAO,SAAS;IAChC,aAAa,IAAI,SAAS,CAAC,EAAE,OAAO;IACpC,aAAa,OAAO,SAAS;GAC/B;EACF,CAAC;CACH;CAEA,OAAO;EAAE;EAAQ;EAAS;CAAe;AAC3C"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../utils.mjs";
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../providers/config/context.mjs";
|
|
4
|
-
import { dialog_exports } from "../../core/dialog.mjs";
|
|
5
4
|
import Button from "../../Button.mjs";
|
|
5
|
+
import { dialog_exports } from "../../core/dialog.mjs";
|
|
6
6
|
import { createImperativeStack, isBrowser } from "./imperative-stack.mjs";
|
|
7
|
-
import { Check, CircleQuestionMark, Info, OctagonAlert, OctagonX } from "lucide-react";
|
|
8
7
|
import { useState } from "react";
|
|
8
|
+
import { Check, CircleQuestionMark, Info, OctagonAlert, OctagonX } from "lucide-react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
//#region src/components/organisms/modal.tsx
|
|
@@ -3,8 +3,8 @@ import { cn } from "../../utils.mjs";
|
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../providers/config/context.mjs";
|
|
4
4
|
import Button from "../../Button.mjs";
|
|
5
5
|
import { createImperativeStack, isBrowser } from "./imperative-stack.mjs";
|
|
6
|
-
import { Check, Info, OctagonAlert, OctagonX, X } from "lucide-react";
|
|
7
6
|
import { useState } from "react";
|
|
7
|
+
import { Check, Info, OctagonAlert, OctagonX, X } from "lucide-react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { useTimeout } from "@jbpark/use-hooks";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../utils.mjs";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/templates/container.tsx
|
|
5
5
|
const MAX_WIDTH_CLASSES = {
|
|
6
6
|
"3xs": "max-w-3xs",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../../utils.mjs";
|
|
2
2
|
import { SiderRegistryContext } from "./sider-context.mjs";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/templates/layout/content.tsx
|
|
6
6
|
const Content = ({ children, className, asChild = false, ...props }) => {
|
|
7
7
|
return /* @__PURE__ */ jsx(asChild ? Slot : "main", {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import { DEFAULT_LOCALE, useConfig } from "../../../providers/config/context.mjs";
|
|
4
4
|
import { useRegisterSider } from "./sider-context.mjs";
|
|
5
|
-
import { PanelLeftClose, PanelLeftOpen } from "lucide-react";
|
|
6
5
|
import { useEffect, useId, useRef } from "react";
|
|
6
|
+
import { PanelLeftClose, PanelLeftOpen } from "lucide-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useControllableState, useResponsiveSize } from "@jbpark/use-hooks";
|
|
9
9
|
//#region src/components/templates/layout/sider.tsx
|
package/dist/core/accordion.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
3
3
|
import { cn } from "../utils.mjs";
|
|
4
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
5
4
|
import "react";
|
|
6
|
-
import
|
|
5
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
8
8
|
//#region src/core/accordion.tsx
|
|
9
9
|
var accordion_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
Accordion: () => Accordion,
|
package/dist/core/badge.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ declare namespace badge_d_exports {
|
|
|
4
4
|
export { Badge, Props, badgeVariants };
|
|
5
5
|
}
|
|
6
6
|
declare const badgeVariants: (props?: ({
|
|
7
|
-
variant?: "default" | "
|
|
7
|
+
variant?: "default" | "outline" | "secondary" | "destructive" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
type Props = React$1.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
10
10
|
asChild?: boolean;
|
package/dist/core/badge.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { cn } from "../utils.mjs";
|
|
3
3
|
import "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
//#region src/core/badge.tsx
|
|
8
8
|
var badge_exports = /* @__PURE__ */ __exportAll({
|
package/dist/core/button.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ declare namespace button_d_exports {
|
|
|
4
4
|
export { Button, Props, buttonVariants };
|
|
5
5
|
}
|
|
6
6
|
declare const buttonVariants: (props?: ({
|
|
7
|
-
variant?: "link" | "default" | "
|
|
8
|
-
size?: "
|
|
7
|
+
variant?: "link" | "default" | "outline" | "secondary" | "destructive" | "ghost" | null | undefined;
|
|
8
|
+
size?: "icon" | "default" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
10
|
type Props = React$1.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
11
11
|
asChild?: boolean;
|
package/dist/core/button.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { cn } from "../utils.mjs";
|
|
3
3
|
import "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
//#region src/core/button.tsx
|
|
8
8
|
var button_exports = /* @__PURE__ */ __exportAll({
|
package/dist/core/calendar.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
3
3
|
import { cn } from "../utils.mjs";
|
|
4
4
|
import { Button, buttonVariants } from "./button.mjs";
|
|
5
|
-
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
6
5
|
import * as React$1 from "react";
|
|
6
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
9
9
|
//#region src/core/calendar.tsx
|
package/dist/core/checkbox.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
3
3
|
import { cn } from "../utils.mjs";
|
|
4
|
-
import { CheckIcon } from "lucide-react";
|
|
5
4
|
import "react";
|
|
5
|
+
import { CheckIcon } from "lucide-react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
8
8
|
//#region src/core/checkbox.tsx
|