@xingxingmofashu/ui 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -14
- package/dist/components/accordion.d.ts +14 -10
- package/dist/components/accordion.mjs +78 -25
- package/dist/components/alert-dialog.d.ts +7 -2
- package/dist/components/alert-dialog.mjs +74 -33
- package/dist/components/button.d.ts +6 -2
- package/dist/components/button.mjs +20 -11
- package/dist/components/card.d.ts +6 -1
- package/dist/components/card.mjs +27 -4
- package/dist/components/checkbox.d.ts +5 -1
- package/dist/components/checkbox.mjs +73 -26
- package/dist/components/dialog.d.ts +7 -2
- package/dist/components/dialog.mjs +66 -20
- package/dist/components/drawer.d.ts +7 -2
- package/dist/components/drawer.mjs +66 -20
- package/dist/components/icons/check.d.ts +3 -0
- package/dist/components/icons/check.mjs +24 -0
- package/dist/components/icons/close.d.ts +3 -0
- package/dist/components/icons/close.mjs +21 -0
- package/dist/components/icons/dash.d.ts +3 -0
- package/dist/components/icons/dash.mjs +24 -0
- package/dist/components/icons/error.d.ts +3 -0
- package/dist/components/icons/error.mjs +23 -0
- package/dist/components/icons/info.d.ts +3 -0
- package/dist/components/icons/info.mjs +23 -0
- package/dist/components/icons/loading.d.ts +3 -0
- package/dist/components/icons/loading.mjs +22 -0
- package/dist/components/icons/plus.d.ts +3 -0
- package/dist/components/icons/plus.mjs +22 -0
- package/dist/components/icons/success.d.ts +3 -0
- package/dist/components/icons/success.mjs +22 -0
- package/dist/components/icons/warning.d.ts +3 -0
- package/dist/components/icons/warning.mjs +23 -0
- package/dist/components/input.d.ts +5 -1
- package/dist/components/input.mjs +73 -30
- package/dist/components/popover.d.ts +7 -2
- package/dist/components/popover.mjs +53 -14
- package/dist/components/progress.d.ts +21 -0
- package/dist/components/progress.mjs +71 -0
- package/dist/components/scroll-area.d.ts +7 -2
- package/dist/components/scroll-area.mjs +48 -14
- package/dist/components/slider.d.ts +15 -4
- package/dist/components/slider.mjs +65 -16
- package/dist/components/switch.d.ts +5 -1
- package/dist/components/switch.mjs +65 -18
- package/dist/components/toast.d.ts +17 -11
- package/dist/components/toast.mjs +111 -87
- package/dist/components/toggle-group.d.ts +11 -5
- package/dist/components/toggle-group.mjs +54 -6
- package/dist/components/toggle.d.ts +5 -1
- package/dist/components/toggle.mjs +36 -5
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +2 -0
- package/dist/internal/aria.d.ts +3 -0
- package/dist/internal/aria.mjs +5 -0
- package/dist/internal/tv.d.ts +17 -0
- package/dist/internal/tv.mjs +0 -0
- package/dist/keyframes.css +1 -1
- package/dist/theme/alert-dialog.mjs +1 -1
- package/dist/theme/checkbox.mjs +4 -4
- package/dist/theme/dialog.mjs +1 -1
- package/dist/theme/drawer.mjs +1 -1
- package/dist/theme/popover.mjs +2 -2
- package/dist/theme/progress.d.ts +80 -0
- package/dist/theme/progress.mjs +64 -0
- package/dist/theme/slider.mjs +8 -0
- package/dist/theme/switch.mjs +2 -0
- package/dist/theme/toast.d.ts +15 -36
- package/dist/theme/toast.mjs +29 -21
- package/package.json +8 -3
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Switch as UISwitch } from "@base-ui/react/switch";
|
|
3
3
|
import { cn } from "cn";
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { mergeIds } from "../internal/aria.mjs";
|
|
5
6
|
import theme from "../theme/switch.mjs";
|
|
6
7
|
function LiquidGlassFilter({ id }) {
|
|
7
8
|
return /* @__PURE__ */ React.createElement("svg", { "aria-hidden": "true", focusable: "false", "data-layer": "filter" }, /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("filter", { id: `${id}-goo` }, /* @__PURE__ */ React.createElement(
|
|
@@ -47,16 +48,28 @@ function LiquidGlassFilter({ id }) {
|
|
|
47
48
|
}
|
|
48
49
|
function Switch({
|
|
49
50
|
className,
|
|
51
|
+
ui,
|
|
50
52
|
label,
|
|
51
53
|
description,
|
|
52
54
|
size,
|
|
53
55
|
disabled,
|
|
54
56
|
readOnly,
|
|
55
57
|
onCheckedChange,
|
|
58
|
+
"aria-describedby": ariaDescribedBy,
|
|
59
|
+
"aria-label": ariaLabel,
|
|
60
|
+
"aria-labelledby": ariaLabelledBy,
|
|
56
61
|
...props
|
|
57
62
|
}) {
|
|
58
|
-
const
|
|
63
|
+
const styles = theme({ size });
|
|
59
64
|
const filterId = React.useId();
|
|
65
|
+
const labelId = React.useId();
|
|
66
|
+
const descriptionId = React.useId();
|
|
67
|
+
const hasName = Boolean(label || ariaLabel || ariaLabelledBy);
|
|
68
|
+
const labelledBy = ariaLabelledBy || (label && !ariaLabel ? labelId : void 0);
|
|
69
|
+
const describedBy = mergeIds(
|
|
70
|
+
ariaDescribedBy,
|
|
71
|
+
description && hasName ? descriptionId : void 0
|
|
72
|
+
);
|
|
60
73
|
const filterStyles = {
|
|
61
74
|
"--ui-switch-goo-filter": `url("#${filterId}-goo")`,
|
|
62
75
|
"--ui-switch-remove-black-filter": `url("#${filterId}-remove-black")`
|
|
@@ -80,36 +93,70 @@ function Switch({
|
|
|
80
93
|
UISwitch.Root,
|
|
81
94
|
{
|
|
82
95
|
...props,
|
|
96
|
+
"aria-describedby": describedBy,
|
|
97
|
+
"aria-label": ariaLabel,
|
|
98
|
+
"aria-labelledby": labelledBy,
|
|
83
99
|
disabled,
|
|
84
100
|
readOnly,
|
|
85
101
|
"data-slot": "root",
|
|
86
102
|
"data-animating": animating || void 0,
|
|
87
103
|
onCheckedChange: handleCheckedChange,
|
|
88
|
-
className: cn(
|
|
104
|
+
className: cn(styles.root(), ui?.root, className)
|
|
89
105
|
},
|
|
90
|
-
/* @__PURE__ */ React.createElement(
|
|
106
|
+
/* @__PURE__ */ React.createElement(
|
|
91
107
|
"span",
|
|
92
108
|
{
|
|
93
|
-
"data-slot": "
|
|
94
|
-
className:
|
|
95
|
-
style: filterStyles
|
|
109
|
+
"data-slot": "container",
|
|
110
|
+
className: cn(styles.container(), ui?.container)
|
|
96
111
|
},
|
|
97
|
-
/* @__PURE__ */ React.createElement(LiquidGlassFilter, { id: filterId }),
|
|
98
|
-
/* @__PURE__ */ React.createElement("span", { "aria-hidden": "true", "data-layer": "mask" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "track" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "track-mask" }))),
|
|
99
112
|
/* @__PURE__ */ React.createElement(
|
|
100
|
-
|
|
113
|
+
"span",
|
|
101
114
|
{
|
|
102
|
-
"data-slot": "
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
className: ui.thumb()
|
|
115
|
+
"data-slot": "base",
|
|
116
|
+
className: cn(styles.base(), ui?.base),
|
|
117
|
+
style: filterStyles
|
|
106
118
|
},
|
|
107
|
-
/* @__PURE__ */ React.createElement(
|
|
108
|
-
/* @__PURE__ */ React.createElement("span", { "
|
|
109
|
-
/* @__PURE__ */ React.createElement(
|
|
119
|
+
/* @__PURE__ */ React.createElement(LiquidGlassFilter, { id: filterId }),
|
|
120
|
+
/* @__PURE__ */ React.createElement("span", { "aria-hidden": "true", "data-layer": "mask" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "track" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "track-mask" }))),
|
|
121
|
+
/* @__PURE__ */ React.createElement(
|
|
122
|
+
UISwitch.Thumb,
|
|
123
|
+
{
|
|
124
|
+
"data-slot": "thumb",
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
onTransitionEnd: handleThumbTransitionEnd,
|
|
127
|
+
className: cn(styles.thumb(), ui?.thumb)
|
|
128
|
+
},
|
|
129
|
+
/* @__PURE__ */ React.createElement("span", { "aria-hidden": "true", "data-layer": "glass-rim" }),
|
|
130
|
+
/* @__PURE__ */ React.createElement("span", { "data-layer": "glass-lens" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "goo" }, /* @__PURE__ */ React.createElement("span", { "data-layer": "inner-glow" }), /* @__PURE__ */ React.createElement("span", { "data-layer": "fill" }))),
|
|
131
|
+
/* @__PURE__ */ React.createElement("span", { "data-layer": "cover" })
|
|
132
|
+
)
|
|
110
133
|
)
|
|
111
|
-
)
|
|
112
|
-
label || description ? /* @__PURE__ */ React.createElement(
|
|
134
|
+
),
|
|
135
|
+
label || description ? /* @__PURE__ */ React.createElement(
|
|
136
|
+
"span",
|
|
137
|
+
{
|
|
138
|
+
"data-slot": "wrapper",
|
|
139
|
+
className: cn(styles.wrapper(), ui?.wrapper)
|
|
140
|
+
},
|
|
141
|
+
label ? /* @__PURE__ */ React.createElement(
|
|
142
|
+
"span",
|
|
143
|
+
{
|
|
144
|
+
id: labelId,
|
|
145
|
+
"data-slot": "label",
|
|
146
|
+
className: cn(styles.label(), ui?.label)
|
|
147
|
+
},
|
|
148
|
+
label
|
|
149
|
+
) : null,
|
|
150
|
+
description ? /* @__PURE__ */ React.createElement(
|
|
151
|
+
"span",
|
|
152
|
+
{
|
|
153
|
+
id: descriptionId,
|
|
154
|
+
"data-slot": "description",
|
|
155
|
+
className: cn(styles.description(), ui?.description)
|
|
156
|
+
},
|
|
157
|
+
description
|
|
158
|
+
) : null
|
|
159
|
+
) : null
|
|
113
160
|
);
|
|
114
161
|
}
|
|
115
162
|
export { Switch };
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { Toast as UIToast } from "@base-ui/react/toast";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { type ComponentConfig } from "../internal/tv";
|
|
4
|
+
import theme from "../theme/toast";
|
|
5
|
+
/** Corner where the toast stack is anchored. */
|
|
6
|
+
type ToastPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
5
7
|
interface ToastProviderProps extends Omit<UIToast.Provider.Props, "children"> {
|
|
6
8
|
/** App content that can call `useToast`. */
|
|
7
9
|
children?: React.ReactNode;
|
|
8
|
-
|
|
10
|
+
}
|
|
11
|
+
type Toast = ComponentConfig<typeof theme>;
|
|
12
|
+
interface ToastProps extends Omit<UIToast.Root.Props, "children" | "className" | "swipeDirection" | "toast"> {
|
|
13
|
+
/** Corner where the toast stack is anchored. */
|
|
9
14
|
position?: ToastPosition;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
viewportLabel?: string;
|
|
14
|
-
/** Tailwind classes merged into the viewport. */
|
|
15
|
+
/** Content rendered in place of the default close button. */
|
|
16
|
+
close?: React.ReactNode;
|
|
17
|
+
/** Tailwind classes merged into each toast. */
|
|
15
18
|
className?: string;
|
|
19
|
+
/** Tailwind classes for internal slots, keyed by `data-slot`. */
|
|
20
|
+
ui?: Toast["slots"];
|
|
16
21
|
}
|
|
17
|
-
declare function ToastProvider({ children,
|
|
18
|
-
|
|
19
|
-
export
|
|
22
|
+
declare function ToastProvider({ children, ...props }: ToastProviderProps): React.JSX.Element;
|
|
23
|
+
declare function Toast({ position, close, className, ui, ...props }: ToastProps): React.JSX.Element;
|
|
24
|
+
export { Toast, ToastProvider };
|
|
25
|
+
export type { ToastPosition, ToastProps, ToastProviderProps };
|
|
@@ -4,52 +4,31 @@ import { cn } from "cn";
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { useToast } from "../composables/use-toast.mjs";
|
|
6
6
|
import theme from "../theme/toast.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
stroke: "currentColor",
|
|
27
|
-
strokeWidth: 1.5,
|
|
28
|
-
strokeLinecap: "round",
|
|
29
|
-
strokeLinejoin: "round",
|
|
30
|
-
className: "size-full"
|
|
31
|
-
};
|
|
32
|
-
switch (type) {
|
|
33
|
-
case "info":
|
|
34
|
-
return /* @__PURE__ */ React.createElement("svg", { ...svgProps }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "10", r: "7.25" }), /* @__PURE__ */ React.createElement("path", { d: "M10 9.25v4" }), /* @__PURE__ */ React.createElement("path", { d: "M10 6.75h.01" }));
|
|
35
|
-
case "success":
|
|
36
|
-
return /* @__PURE__ */ React.createElement("svg", { ...svgProps }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "10", r: "7.25" }), /* @__PURE__ */ React.createElement("path", { d: "m6.75 10.25 2.1 2.1 4.4-4.7" }));
|
|
37
|
-
case "warning":
|
|
38
|
-
return /* @__PURE__ */ React.createElement("svg", { ...svgProps }, /* @__PURE__ */ React.createElement("path", { d: "M10 3.25 17 16.5H3L10 3.25Z" }), /* @__PURE__ */ React.createElement("path", { d: "M10 8v3.5" }), /* @__PURE__ */ React.createElement("path", { d: "M10 14.25h.01" }));
|
|
39
|
-
case "error":
|
|
40
|
-
return /* @__PURE__ */ React.createElement("svg", { ...svgProps }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "10", r: "7.25" }), /* @__PURE__ */ React.createElement("path", { d: "M10 6.5v4.25" }), /* @__PURE__ */ React.createElement("path", { d: "M10 13.75h.01" }));
|
|
41
|
-
case "loading":
|
|
42
|
-
return /* @__PURE__ */ React.createElement("svg", { ...svgProps }, /* @__PURE__ */ React.createElement("circle", { cx: "10", cy: "10", r: "6.75", opacity: "0.25" }), /* @__PURE__ */ React.createElement("path", { d: "M10 3.25a6.75 6.75 0 0 1 6.75 6.75" }));
|
|
43
|
-
default:
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
7
|
+
import { CloseIcon } from "./icons/close.mjs";
|
|
8
|
+
import { ErrorIcon } from "./icons/error.mjs";
|
|
9
|
+
import { InfoIcon } from "./icons/info.mjs";
|
|
10
|
+
import { LoadingIcon } from "./icons/loading.mjs";
|
|
11
|
+
import { SuccessIcon } from "./icons/success.mjs";
|
|
12
|
+
import { WarningIcon } from "./icons/warning.mjs";
|
|
13
|
+
const SWIPE_DIRECTIONS = {
|
|
14
|
+
"top-left": ["up", "left"],
|
|
15
|
+
"top-right": ["up", "right"],
|
|
16
|
+
"bottom-left": ["down", "left"],
|
|
17
|
+
"bottom-right": ["down", "right"]
|
|
18
|
+
};
|
|
19
|
+
const STATUS_ICONS = {
|
|
20
|
+
info: InfoIcon,
|
|
21
|
+
success: SuccessIcon,
|
|
22
|
+
warning: WarningIcon,
|
|
23
|
+
error: ErrorIcon,
|
|
24
|
+
loading: LoadingIcon
|
|
25
|
+
};
|
|
47
26
|
function ToastStatusIcon({
|
|
48
27
|
type,
|
|
49
28
|
className
|
|
50
29
|
}) {
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
30
|
+
const Icon = type ? STATUS_ICONS[type] : void 0;
|
|
31
|
+
if (!Icon) {
|
|
53
32
|
return null;
|
|
54
33
|
}
|
|
55
34
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -60,61 +39,106 @@ function ToastStatusIcon({
|
|
|
60
39
|
"data-icon": type,
|
|
61
40
|
className
|
|
62
41
|
},
|
|
63
|
-
|
|
42
|
+
/* @__PURE__ */ React.createElement(Icon, { className: "size-full" })
|
|
64
43
|
);
|
|
65
44
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
closeLabel
|
|
69
|
-
}) {
|
|
70
|
-
const { toasts } = useToast();
|
|
71
|
-
const ui = theme({ placement });
|
|
72
|
-
return toasts.map((toast) => /* @__PURE__ */ React.createElement(
|
|
73
|
-
UIToast.Root,
|
|
74
|
-
{
|
|
75
|
-
key: toast.id,
|
|
76
|
-
toast,
|
|
77
|
-
"data-slot": "toast",
|
|
78
|
-
className: ui.root(),
|
|
79
|
-
swipeDirection: placement === "top" ? "up" : "down"
|
|
80
|
-
},
|
|
81
|
-
/* @__PURE__ */ React.createElement("span", { "aria-hidden": "true", "data-slot": "glass", className: ui.glass() }, /* @__PURE__ */ React.createElement("span", { "aria-hidden": "true", "data-slot": "overlay", className: ui.overlay() })),
|
|
82
|
-
/* @__PURE__ */ React.createElement(UIToast.Content, { "data-slot": "content", className: ui.content() }, /* @__PURE__ */ React.createElement(ToastStatusIcon, { type: toast.type, className: ui.icon() }), /* @__PURE__ */ React.createElement("div", { "data-slot": "text", className: ui.text() }, /* @__PURE__ */ React.createElement(UIToast.Title, { "data-slot": "title", className: ui.title() }), /* @__PURE__ */ React.createElement(
|
|
83
|
-
UIToast.Description,
|
|
84
|
-
{
|
|
85
|
-
"data-slot": "description",
|
|
86
|
-
className: ui.description()
|
|
87
|
-
}
|
|
88
|
-
)), /* @__PURE__ */ React.createElement("div", { "data-slot": "actions", className: ui.actions() }, /* @__PURE__ */ React.createElement(UIToast.Action, { "data-slot": "action", className: ui.action() }), /* @__PURE__ */ React.createElement(
|
|
89
|
-
UIToast.Close,
|
|
90
|
-
{
|
|
91
|
-
"data-slot": "close",
|
|
92
|
-
className: ui.close(),
|
|
93
|
-
"aria-label": closeLabel
|
|
94
|
-
},
|
|
95
|
-
/* @__PURE__ */ React.createElement(CloseIcon, null)
|
|
96
|
-
)))
|
|
97
|
-
));
|
|
45
|
+
function ToastProvider({ children, ...props }) {
|
|
46
|
+
return /* @__PURE__ */ React.createElement(UIToast.Provider, { ...props }, children);
|
|
98
47
|
}
|
|
99
|
-
function
|
|
100
|
-
children,
|
|
48
|
+
function Toast({
|
|
101
49
|
position = "bottom-right",
|
|
102
|
-
|
|
103
|
-
viewportLabel = "Notifications",
|
|
50
|
+
close,
|
|
104
51
|
className,
|
|
52
|
+
ui,
|
|
105
53
|
...props
|
|
106
54
|
}) {
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
return /* @__PURE__ */ React.createElement(UIToast.
|
|
55
|
+
const { toasts } = useToast();
|
|
56
|
+
const styles = theme({ position });
|
|
57
|
+
return /* @__PURE__ */ React.createElement(UIToast.Portal, null, /* @__PURE__ */ React.createElement(
|
|
110
58
|
UIToast.Viewport,
|
|
111
59
|
{
|
|
112
60
|
"data-slot": "viewport",
|
|
113
61
|
"data-position": position,
|
|
114
|
-
|
|
115
|
-
className: cn(ui.viewport(), className)
|
|
62
|
+
className: cn(styles.viewport(), ui?.viewport)
|
|
116
63
|
},
|
|
117
|
-
/* @__PURE__ */ React.createElement(
|
|
118
|
-
|
|
64
|
+
toasts.map((toast) => /* @__PURE__ */ React.createElement(
|
|
65
|
+
UIToast.Root,
|
|
66
|
+
{
|
|
67
|
+
...props,
|
|
68
|
+
key: toast.id,
|
|
69
|
+
toast,
|
|
70
|
+
"data-slot": "root",
|
|
71
|
+
className: cn(styles.root(), ui?.root, className),
|
|
72
|
+
swipeDirection: SWIPE_DIRECTIONS[position]
|
|
73
|
+
},
|
|
74
|
+
/* @__PURE__ */ React.createElement(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
key: "glass",
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
"data-slot": "glass",
|
|
80
|
+
className: cn(styles.glass(), ui?.glass)
|
|
81
|
+
},
|
|
82
|
+
/* @__PURE__ */ React.createElement(
|
|
83
|
+
"span",
|
|
84
|
+
{
|
|
85
|
+
"aria-hidden": "true",
|
|
86
|
+
"data-slot": "overlay",
|
|
87
|
+
className: cn(styles.overlay(), ui?.overlay)
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ React.createElement(
|
|
92
|
+
UIToast.Content,
|
|
93
|
+
{
|
|
94
|
+
key: "content",
|
|
95
|
+
"data-slot": "content",
|
|
96
|
+
className: cn(styles.content(), ui?.content)
|
|
97
|
+
},
|
|
98
|
+
/* @__PURE__ */ React.createElement(
|
|
99
|
+
ToastStatusIcon,
|
|
100
|
+
{
|
|
101
|
+
type: toast.type,
|
|
102
|
+
className: cn(styles.icon(), ui?.icon)
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ React.createElement("div", { "data-slot": "text", className: cn(styles.text(), ui?.text) }, /* @__PURE__ */ React.createElement(
|
|
106
|
+
UIToast.Title,
|
|
107
|
+
{
|
|
108
|
+
"data-slot": "title",
|
|
109
|
+
className: cn(styles.title(), ui?.title)
|
|
110
|
+
}
|
|
111
|
+
), /* @__PURE__ */ React.createElement(
|
|
112
|
+
UIToast.Description,
|
|
113
|
+
{
|
|
114
|
+
"data-slot": "description",
|
|
115
|
+
className: cn(styles.description(), ui?.description)
|
|
116
|
+
}
|
|
117
|
+
)),
|
|
118
|
+
/* @__PURE__ */ React.createElement(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
"data-slot": "actions",
|
|
122
|
+
className: cn(styles.actions(), ui?.actions)
|
|
123
|
+
},
|
|
124
|
+
/* @__PURE__ */ React.createElement(
|
|
125
|
+
UIToast.Action,
|
|
126
|
+
{
|
|
127
|
+
"data-slot": "action",
|
|
128
|
+
className: cn(styles.action(), ui?.action)
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
close ? close : /* @__PURE__ */ React.createElement(
|
|
132
|
+
UIToast.Close,
|
|
133
|
+
{
|
|
134
|
+
"data-slot": "close",
|
|
135
|
+
className: cn(styles.close(), ui?.close)
|
|
136
|
+
},
|
|
137
|
+
/* @__PURE__ */ React.createElement(CloseIcon, { className: "size-4" })
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
))
|
|
142
|
+
));
|
|
119
143
|
}
|
|
120
|
-
export { ToastProvider };
|
|
144
|
+
export { Toast, ToastProvider };
|
|
@@ -2,24 +2,30 @@ import { Toggle as UIToggle } from "@base-ui/react/toggle";
|
|
|
2
2
|
import { ToggleGroup as UIToggleGroup } from "@base-ui/react/toggle-group";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { type VariantProps } from "tailwind-variants";
|
|
5
|
+
import { type ComponentConfig } from "../internal/tv";
|
|
5
6
|
import theme from "../theme/toggle-group";
|
|
7
|
+
type ToggleGroup = ComponentConfig<typeof theme>;
|
|
6
8
|
/** One option managed by the toggle group. */
|
|
7
|
-
type ToggleGroupItemProps = Omit<UIToggle.Props
|
|
9
|
+
type ToggleGroupItemProps<Value extends string = string> = Omit<UIToggle.Props<Value>, "className" | "children" | "style" | "value" | "pressed" | "defaultPressed"> & {
|
|
8
10
|
/** Value that identifies the option in the group value. */
|
|
9
|
-
value:
|
|
11
|
+
value: Value;
|
|
10
12
|
/** Visible content inside the item. */
|
|
11
13
|
label?: React.ReactNode;
|
|
12
14
|
/** Icon rendered before the label. */
|
|
13
15
|
icon?: React.ReactNode;
|
|
14
16
|
/** Tailwind classes merged into the item root. */
|
|
15
17
|
className?: string;
|
|
18
|
+
/** Tailwind classes for this item's internal slots, keyed by `data-slot`. */
|
|
19
|
+
ui?: Partial<Pick<ToggleGroup["slots"], "item" | "content" | "icon" | "label">>;
|
|
16
20
|
};
|
|
17
21
|
type ToggleGroupProps<Value extends string = string> = Omit<UIToggleGroup.Props<Value>, "className" | "style" | "children"> & VariantProps<typeof theme> & {
|
|
18
22
|
/** Options rendered by the toggle group. */
|
|
19
|
-
items: readonly ToggleGroupItemProps[];
|
|
23
|
+
items: readonly ToggleGroupItemProps<Value>[];
|
|
20
24
|
/** Tailwind classes merged into the group root. */
|
|
21
|
-
className?:
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Tailwind classes for internal slots, keyed by `data-slot`. */
|
|
27
|
+
ui?: ToggleGroup["slots"];
|
|
22
28
|
};
|
|
23
|
-
declare function ToggleGroup<Value extends string = string>({ className, size, items, ...props }: ToggleGroupProps<Value>): React.JSX.Element;
|
|
29
|
+
declare function ToggleGroup<Value extends string = string>({ className, ui, size, items, ...props }: ToggleGroupProps<Value>): React.JSX.Element;
|
|
24
30
|
export { ToggleGroup };
|
|
25
31
|
export type { ToggleGroupItemProps, ToggleGroupProps };
|
|
@@ -6,29 +6,77 @@ import * as React from "react";
|
|
|
6
6
|
import theme from "../theme/toggle-group.mjs";
|
|
7
7
|
function ToggleGroup({
|
|
8
8
|
className,
|
|
9
|
+
ui,
|
|
9
10
|
size,
|
|
10
11
|
items,
|
|
11
12
|
...props
|
|
12
13
|
}) {
|
|
13
|
-
const
|
|
14
|
+
const styles = theme({ size });
|
|
14
15
|
return /* @__PURE__ */ React.createElement(
|
|
15
16
|
UIToggleGroup,
|
|
16
17
|
{
|
|
17
18
|
...props,
|
|
18
19
|
"data-slot": "root",
|
|
19
|
-
className: cn(
|
|
20
|
+
className: cn(styles.root(), ui?.root, className)
|
|
20
21
|
},
|
|
21
|
-
/* @__PURE__ */ React.createElement(
|
|
22
|
-
|
|
22
|
+
/* @__PURE__ */ React.createElement(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
"data-slot": "glass",
|
|
27
|
+
className: cn(styles.glass(), ui?.glass)
|
|
28
|
+
},
|
|
29
|
+
/* @__PURE__ */ React.createElement(
|
|
30
|
+
"span",
|
|
31
|
+
{
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
"data-slot": "rim",
|
|
34
|
+
"data-layer": "rim",
|
|
35
|
+
className: cn(styles.rim(), ui?.rim)
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
),
|
|
39
|
+
items.map((item) => /* @__PURE__ */ React.createElement(
|
|
40
|
+
ToggleGroupItem,
|
|
41
|
+
{
|
|
42
|
+
key: item.value,
|
|
43
|
+
...item,
|
|
44
|
+
ui: {
|
|
45
|
+
item: cn(ui?.item, item.ui?.item),
|
|
46
|
+
content: cn(ui?.content, item.ui?.content),
|
|
47
|
+
icon: cn(ui?.icon, item.ui?.icon),
|
|
48
|
+
label: cn(ui?.label, item.ui?.label)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
))
|
|
23
52
|
);
|
|
24
53
|
}
|
|
25
54
|
function ToggleGroupItem({
|
|
26
55
|
className,
|
|
56
|
+
ui,
|
|
27
57
|
icon,
|
|
28
58
|
label,
|
|
59
|
+
ref,
|
|
29
60
|
...props
|
|
30
61
|
}) {
|
|
31
|
-
const
|
|
32
|
-
return /* @__PURE__ */ React.createElement(
|
|
62
|
+
const styles = theme();
|
|
63
|
+
return /* @__PURE__ */ React.createElement(
|
|
64
|
+
UIToggle,
|
|
65
|
+
{
|
|
66
|
+
...props,
|
|
67
|
+
ref,
|
|
68
|
+
"data-slot": "item",
|
|
69
|
+
className: cn(styles.item(), ui?.item, className)
|
|
70
|
+
},
|
|
71
|
+
/* @__PURE__ */ React.createElement("span", { "data-slot": "content", className: cn(styles.content(), ui?.content) }, icon ? /* @__PURE__ */ React.createElement(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
"aria-hidden": "true",
|
|
75
|
+
"data-slot": "icon",
|
|
76
|
+
className: cn(styles.icon(), ui?.icon)
|
|
77
|
+
},
|
|
78
|
+
icon
|
|
79
|
+
) : null, label ? /* @__PURE__ */ React.createElement("span", { "data-slot": "label", className: cn(styles.label(), ui?.label) }, label) : null)
|
|
80
|
+
);
|
|
33
81
|
}
|
|
34
82
|
export { ToggleGroup };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Toggle as UIToggle } from "@base-ui/react/toggle";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { type VariantProps } from "tailwind-variants";
|
|
4
|
+
import { type ComponentConfig } from "../internal/tv";
|
|
4
5
|
import theme from "../theme/toggle";
|
|
6
|
+
type Toggle = ComponentConfig<typeof theme>;
|
|
5
7
|
type ToggleProps<Value extends string = string> = Omit<UIToggle.Props<Value>, "className" | "children" | "style" | "ref"> & Omit<VariantProps<typeof theme>, "iconOnly"> & {
|
|
6
8
|
/** Ref to the rendered root element. */
|
|
7
9
|
ref?: React.Ref<HTMLButtonElement>;
|
|
8
10
|
/** Tailwind classes merged into the toggle root. */
|
|
9
11
|
className?: string;
|
|
12
|
+
/** Tailwind classes for internal slots, keyed by `data-slot`. */
|
|
13
|
+
ui?: Toggle["slots"];
|
|
10
14
|
/** Visible label rendered inside the toggle. */
|
|
11
15
|
label?: React.ReactNode;
|
|
12
16
|
/** Icon rendered before the label. */
|
|
13
17
|
icon?: React.ReactNode;
|
|
14
18
|
};
|
|
15
|
-
declare function Toggle<Value extends string = string>({ className, icon, label, size, ...props }: ToggleProps<Value>): React.JSX.Element;
|
|
19
|
+
declare function Toggle<Value extends string = string>({ className, ui, icon, label, size, ...props }: ToggleProps<Value>): React.JSX.Element;
|
|
16
20
|
export { Toggle };
|
|
17
21
|
export type { ToggleProps };
|
|
@@ -5,22 +5,53 @@ import * as React from "react";
|
|
|
5
5
|
import theme from "../theme/toggle.mjs";
|
|
6
6
|
function Toggle({
|
|
7
7
|
className,
|
|
8
|
+
ui,
|
|
8
9
|
icon,
|
|
9
10
|
label,
|
|
10
11
|
size,
|
|
11
12
|
...props
|
|
12
13
|
}) {
|
|
13
|
-
const
|
|
14
|
+
const styles = theme({ size, iconOnly: !label });
|
|
14
15
|
return /* @__PURE__ */ React.createElement(
|
|
15
16
|
UIToggle,
|
|
16
17
|
{
|
|
17
18
|
...props,
|
|
18
19
|
"data-slot": "root",
|
|
19
|
-
className: cn(
|
|
20
|
+
className: cn(styles.root(), ui?.root, className)
|
|
20
21
|
},
|
|
21
|
-
/* @__PURE__ */ React.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/* @__PURE__ */ React.createElement(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
"data-slot": "glass",
|
|
27
|
+
className: cn(styles.glass(), ui?.glass)
|
|
28
|
+
},
|
|
29
|
+
/* @__PURE__ */ React.createElement(
|
|
30
|
+
"span",
|
|
31
|
+
{
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
"data-slot": "rim",
|
|
34
|
+
className: cn(styles.rim(), ui?.rim)
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ React.createElement(
|
|
39
|
+
"span",
|
|
40
|
+
{
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
"data-slot": "thumb",
|
|
43
|
+
className: cn(styles.thumb(), ui?.thumb)
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ React.createElement("span", { "data-slot": "content", className: cn(styles.content(), ui?.content) }, icon ? /* @__PURE__ */ React.createElement(
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
"data-slot": "icon",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
className: cn(styles.icon(), ui?.icon)
|
|
52
|
+
},
|
|
53
|
+
icon
|
|
54
|
+
) : null, label ? /* @__PURE__ */ React.createElement("span", { "data-slot": "label", className: cn(styles.label(), ui?.label) }, label) : null)
|
|
24
55
|
);
|
|
25
56
|
}
|
|
26
57
|
export { Toggle };
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "./keyframes.css";@source "./**/*.mjs";@source "./**/*.{ts,tsx}";@custom-variant ui-light (&:where(.light, .light *, [data-theme="light"], [data-theme="light"] *));@custom-variant ui-dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));@layer theme{:host,:root{--ui-ink:#1f1f1f;--ui-ink-active:#000;--ui-
|
|
1
|
+
@import "./keyframes.css";@source "./**/*.mjs";@source "./**/*.{ts,tsx}";@custom-variant ui-light (&:where(.light, .light *, [data-theme="light"], [data-theme="light"] *));@custom-variant ui-dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));@layer theme{:host,:root{--ui-ink:#1f1f1f;--ui-ink-active:#000;--ui-surface:#fff;--ui-glass-surface:rgba(0,0,0,.02);--ui-glass-border:rgba(51,51,51,.08);--ui-glass-focus:rgba(0,0,0,.6);--ui-glass-inner-border:rgba(0,0,0,.9);--ui-glass-rim:hsla(0,0%,100%,.2);--ui-glass-highlight:hsla(0,0%,100%,.8);--ui-glass-glare-stop:15%;--ui-glass-tone:brightness(0.9);--ui-glass-contrast:3;--ui-drop-shadow-label:drop-shadow(0 25px 3px hsla(0,0%,40%,.15));--ui-shadow-glass:inset 2px -2px 1px -1px hsla(0,0%,100%,.9),inset -2px 2px 1px -1px hsla(0,0%,100%,.9),inset 6px -6px 1px -6px hsla(0,0%,100%,.55),inset -6px 6px 1px -6px hsla(0,0%,100%,.55),inset 0 0 2px rgba(0,0,0,.8),0 4px 8px rgba(0,0,0,.2)}.dark,[data-theme=dark]{--ui-ink:#f5f5f5;--ui-ink-active:#fff;--ui-surface:#141414;--ui-glass-surface:hsla(0,0%,100%,.06);--ui-glass-border:hsla(0,0%,100%,.14);--ui-glass-focus:hsla(0,0%,100%,.7);--ui-glass-inner-border:hsla(0,0%,100%,.4);--ui-glass-rim:hsla(0,0%,100%,.25);--ui-glass-highlight:hsla(0,0%,100%,.45);--ui-glass-tone:brightness(0.9);--ui-glass-contrast:1;--ui-drop-shadow-label:drop-shadow(0 25px 3px rgba(0,0,0,.45));--ui-shadow-glass:inset 2px -2px 1px -1px hsla(0,0%,100%,.35),inset -2px 2px 1px -1px hsla(0,0%,100%,.35),inset 6px -6px 1px -6px hsla(0,0%,100%,.2),inset -6px 6px 1px -6px hsla(0,0%,100%,.2),inset 0 0 2px rgba(0,0,0,.9),0 4px 8px rgba(0,0,0,.35)}.light,[data-theme=light]{--ui-ink:#1f1f1f;--ui-ink-active:#000;--ui-surface:#fff;--ui-glass-surface:rgba(0,0,0,.02);--ui-glass-border:rgba(51,51,51,.08);--ui-glass-focus:rgba(0,0,0,.6);--ui-glass-inner-border:rgba(0,0,0,.9);--ui-glass-rim:hsla(0,0%,100%,.2);--ui-glass-highlight:hsla(0,0%,100%,.8);--ui-glass-glare-stop:15%;--ui-glass-tone:brightness(0.9);--ui-glass-contrast:3;--ui-drop-shadow-label:drop-shadow(0 25px 3px hsla(0,0%,40%,.15));--ui-shadow-glass:inset 2px -2px 1px -1px hsla(0,0%,100%,.9),inset -2px 2px 1px -1px hsla(0,0%,100%,.9),inset 6px -6px 1px -6px hsla(0,0%,100%,.55),inset -6px 6px 1px -6px hsla(0,0%,100%,.55),inset 0 0 2px rgba(0,0,0,.8),0 4px 8px rgba(0,0,0,.2)}:host,:root{--ui-glass-blur:2px;--ui-glass-saturate:150%;--ui-glass-chip-blur:8px;--ui-glass-inner-inset:8px;--ui-glass-inner-offset:1px;--ui-glass-inner-blur:8px;--ui-glass-highlight-blur:7px;--ui-glass-rim-inset:9px;--ui-glass-rim-blur:1px}}@theme inline{--color-ui-ink:var(--ui-ink);--color-ui-ink-active:var(--ui-ink-active);--color-ui-surface:var(--ui-surface);--color-ui-glass-surface:var(--ui-glass-surface);--color-ui-glass-border:var(--ui-glass-border);--color-ui-glass-focus:var(--ui-glass-focus);--color-ui-glass-inner-border:var(--ui-glass-inner-border);--color-ui-glass-rim:var(--ui-glass-rim);--color-ui-glass-highlight:var(--ui-glass-highlight)}@layer components{.ui-glass{backdrop-filter:blur(var(--ui-glass-blur,2px)) saturate(var(--ui-glass-saturate,150%));background-color:var(--ui-glass-surface);border:1px double var(--ui-glass-border);box-shadow:var(--ui-shadow-glass);filter:var(--ui-glass-tone,brightness(.9)) contrast(var(--ui-glass-contrast,3));position:relative}.ui-glass-inner:before{border:1px solid var(--ui-glass-inner-border);bottom:calc(var(--ui-glass-inner-inset, 8px) - var(--ui-glass-inner-offset, 1px));filter:blur(var(--ui-glass-inner-blur,8px));left:var(--ui-glass-inner-inset,8px);right:var(--ui-glass-inner-inset,8px);top:calc(var(--ui-glass-inner-inset, 8px) + var(--ui-glass-inner-offset, 1px));z-index:1}.ui-glass-highlight:after,.ui-glass-inner:before{border-radius:inherit;content:"";pointer-events:none;position:absolute}.ui-glass-highlight:after{background:linear-gradient(45deg,var(--ui-glass-highlight) 0,transparent var(--ui-glass-glare-stop),transparent calc(100% - var(--ui-glass-glare-stop)),var(--ui-glass-highlight) 100%);filter:blur(var(--ui-glass-highlight-blur,7px));inset:0;z-index:3}.ui-glass-rim{border:1px solid var(--ui-glass-rim);border-radius:inherit;filter:blur(var(--ui-glass-rim-blur,1px));height:calc(100% - var(--ui-glass-rim-inset, 9px));left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);width:calc(100% - var(--ui-glass-rim-inset, 9px));z-index:2}.ui-glass-chip{backdrop-filter:blur(var(--ui-glass-chip-blur,8px)) saturate(var(--ui-glass-saturate,150%));background-color:var(--ui-glass-surface);border:1px solid var(--ui-glass-border);box-shadow:inset 0 1px 0 var(--ui-glass-highlight)}}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,11 @@ export { Dialog, type DialogProps } from "./components/dialog";
|
|
|
7
7
|
export { Drawer, type DrawerProps } from "./components/drawer";
|
|
8
8
|
export { Input, type InputProps } from "./components/input";
|
|
9
9
|
export { Popover, type PopoverProps } from "./components/popover";
|
|
10
|
+
export { Progress, type ProgressProps } from "./components/progress";
|
|
10
11
|
export { ScrollArea, type ScrollAreaOrientation, type ScrollAreaProps, } from "./components/scroll-area";
|
|
11
12
|
export { Slider, type SliderProps } from "./components/slider";
|
|
12
13
|
export { Switch, type SwitchProps } from "./components/switch";
|
|
13
|
-
export { ToastProvider, type ToastPosition, type ToastProviderProps, } from "./components/toast";
|
|
14
|
+
export { Toast, ToastProvider, type ToastPosition, type ToastProps, type ToastProviderProps, } from "./components/toast";
|
|
14
15
|
export { createToastManager } from "./composables/create-toast-manager";
|
|
15
16
|
export { useToast, type ToastManager, type ToastManagerAddOptions, type ToastManagerPromiseOptions, type ToastManagerUpdateOptions, type ToastObject, } from "./composables/use-toast";
|
|
16
17
|
export { Toggle, type ToggleProps } from "./components/toggle";
|