@mcistudio/unoui-vue 1.1.1 → 1.2.0
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/index.js +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/chunks/{ImageEditor-DOGIATeD.js → ImageEditor-DRoD50TJ.js} +2 -2
- package/dist/chunks/{ImageEditor-DOGIATeD.js.map → ImageEditor-DRoD50TJ.js.map} +1 -1
- package/dist/chunks/{Table-SDKDGSur.js → Table-QvmJFoxl.js} +3 -3
- package/dist/chunks/{Table-SDKDGSur.js.map → Table-QvmJFoxl.js.map} +1 -1
- package/dist/chunks/{button-BDScl2qA.js → button-BBFPr3FH.js} +33 -32
- package/dist/chunks/button-BBFPr3FH.js.map +1 -0
- package/dist/chunks/{checkbox-9_0oR4kg.js → checkbox-wJpQHCeN.js} +2 -2
- package/dist/chunks/{checkbox-9_0oR4kg.js.map → checkbox-wJpQHCeN.js.map} +1 -1
- package/dist/chunks/{colorpicker-CcizUCQv.js → colorpicker-B-kSQ2Gh.js} +154 -158
- package/dist/chunks/colorpicker-B-kSQ2Gh.js.map +1 -0
- package/dist/chunks/control-BIl2ynWn.js +10 -0
- package/dist/chunks/control-BIl2ynWn.js.map +1 -0
- package/dist/chunks/datepicker-XNgIvgTe.js +1411 -0
- package/dist/chunks/datepicker-XNgIvgTe.js.map +1 -0
- package/dist/chunks/{dropdown-0l967g7D.js → dropdown-B4XuqfaI.js} +4 -4
- package/dist/chunks/dropdown-B4XuqfaI.js.map +1 -0
- package/dist/chunks/{form-Qeqkd-HH.js → form-CVJ4YMWA.js} +7 -7
- package/dist/chunks/{form-Qeqkd-HH.js.map → form-CVJ4YMWA.js.map} +1 -1
- package/dist/chunks/input-hIYHtcTj.js +1272 -0
- package/dist/chunks/input-hIYHtcTj.js.map +1 -0
- package/dist/chunks/{pagination-cndgtghb.js → pagination-xntyuczw.js} +38 -56
- package/dist/chunks/pagination-xntyuczw.js.map +1 -0
- package/dist/chunks/{popconfirm-Bp2mluJ5.js → popconfirm-DWmeebIf.js} +2 -2
- package/dist/chunks/{popconfirm-Bp2mluJ5.js.map → popconfirm-DWmeebIf.js.map} +1 -1
- package/dist/chunks/{radio-DnYm59xH.js → radio-DGt8o-UL.js} +12 -12
- package/dist/chunks/{radio-DnYm59xH.js.map → radio-DGt8o-UL.js.map} +1 -1
- package/dist/chunks/select-eZ9h_f58.js +462 -0
- package/dist/chunks/select-eZ9h_f58.js.map +1 -0
- package/dist/chunks/{switch-BULGbODP.js → switch-C6a6ga2G.js} +2 -2
- package/dist/chunks/{switch-BULGbODP.js.map → switch-C6a6ga2G.js.map} +1 -1
- package/dist/chunks/{timepicker-DFxwJePF.js → timepicker-BU9TRvFI.js} +326 -329
- package/dist/chunks/{timepicker-DFxwJePF.js.map → timepicker-BU9TRvFI.js.map} +1 -1
- package/dist/colorpicker/index.d.ts +4 -0
- package/dist/colorpicker/index.js +2 -2
- package/dist/control.d.ts +6 -0
- package/dist/datepicker/index.js +1 -1
- package/dist/dropdown/index.js +1 -1
- package/dist/form/index.js +1 -1
- package/dist/imageeditor/index.js +1 -1
- package/dist/index.js +31 -31
- package/dist/input/index.d.ts +4 -0
- package/dist/input/index.js +2 -2
- package/dist/modal/Modal.vue.d.ts +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/popconfirm/index.js +1 -1
- package/dist/radio/index.js +1 -1
- package/dist/select/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/table/index.js +1 -1
- package/dist/timepicker/index.js +1 -1
- package/dist/uno.js +1 -0
- package/dist/uno.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/button-BDScl2qA.js.map +0 -1
- package/dist/chunks/colorpicker-CcizUCQv.js.map +0 -1
- package/dist/chunks/datepicker-wXIjngpq.js +0 -1414
- package/dist/chunks/datepicker-wXIjngpq.js.map +0 -1
- package/dist/chunks/dropdown-0l967g7D.js.map +0 -1
- package/dist/chunks/input-DhZ8Wu1m.js +0 -1281
- package/dist/chunks/input-DhZ8Wu1m.js.map +0 -1
- package/dist/chunks/pagination-cndgtghb.js.map +0 -1
- package/dist/chunks/select-ChTfQM5u.js +0 -417
- package/dist/chunks/select-ChTfQM5u.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { t as e } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "./control-BIl2ynWn.js";
|
|
2
|
+
import { t } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
3
|
+
import { cva as n } from "class-variance-authority";
|
|
4
|
+
import { createCommentVNode as r, createElementBlock as i, defineComponent as a, normalizeClass as o, normalizeStyle as s, openBlock as c, renderSlot as l, unref as u } from "vue";
|
|
4
5
|
//#region src/button/Button.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
6
|
+
var d = [
|
|
6
7
|
"data-color",
|
|
7
8
|
"data-variant",
|
|
8
9
|
"type",
|
|
9
10
|
"disabled"
|
|
10
|
-
],
|
|
11
|
+
], f = /* @__PURE__ */ a({
|
|
11
12
|
__name: "Button",
|
|
12
13
|
props: {
|
|
13
14
|
color: { default: "brand" },
|
|
@@ -27,12 +28,12 @@ var u = [
|
|
|
27
28
|
type: { default: "button" }
|
|
28
29
|
},
|
|
29
30
|
setup(e) {
|
|
30
|
-
return (t,
|
|
31
|
+
return (t, n) => (c(), i("button", {
|
|
31
32
|
"data-ui-button": "true",
|
|
32
33
|
"data-color": e.color,
|
|
33
34
|
"data-variant": e.variant,
|
|
34
35
|
type: e.type,
|
|
35
|
-
class:
|
|
36
|
+
class: o(u(T)({
|
|
36
37
|
color: e.color,
|
|
37
38
|
variant: e.variant,
|
|
38
39
|
size: e.size,
|
|
@@ -40,41 +41,41 @@ var u = [
|
|
|
40
41
|
disabled: e.disabled
|
|
41
42
|
})),
|
|
42
43
|
disabled: e.disabled
|
|
43
|
-
}, [e.loading ? (
|
|
44
|
+
}, [e.loading ? (c(), i("span", {
|
|
44
45
|
key: 0,
|
|
45
46
|
class: "i-lucide:loader-2 animate-spin",
|
|
46
|
-
style:
|
|
47
|
-
}, null, 4)) : e.icon ? (
|
|
47
|
+
style: s(`font-size: ${e.iconSize}px`)
|
|
48
|
+
}, null, 4)) : e.icon ? (c(), i("span", {
|
|
48
49
|
key: 1,
|
|
49
|
-
class:
|
|
50
|
-
style:
|
|
51
|
-
}, null, 6)) :
|
|
50
|
+
class: o(e.icon),
|
|
51
|
+
style: s(`font-size: ${e.iconSize}px`)
|
|
52
|
+
}, null, 6)) : r("", !0), l(t.$slots, "default")], 10, d));
|
|
52
53
|
}
|
|
53
|
-
}),
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
}), p = {}, m = { class: "inline-flex items-center isolate" };
|
|
55
|
+
function h(e, t) {
|
|
56
|
+
return c(), i("div", m, [l(e.$slots, "default", {}, void 0, !0)]);
|
|
56
57
|
}
|
|
57
|
-
var
|
|
58
|
+
var g = /*#__PURE__*/ t(p, [["render", h], ["__scopeId", "data-v-d7310e6e"]]), _ = [
|
|
58
59
|
"brand",
|
|
59
60
|
"red",
|
|
60
61
|
"gray",
|
|
61
62
|
"green",
|
|
62
63
|
"yellow",
|
|
63
64
|
"orange"
|
|
64
|
-
],
|
|
65
|
+
], v = [
|
|
65
66
|
"default",
|
|
66
67
|
"outline",
|
|
67
68
|
"dashed",
|
|
68
69
|
"link",
|
|
69
70
|
"mono"
|
|
70
|
-
],
|
|
71
|
+
], y = (e) => Object.fromEntries(e.map((e) => [e, ""])), b = {
|
|
71
72
|
brand: "active:after:shadow-[0_0_0_0_brand-500]",
|
|
72
73
|
red: "active:after:shadow-[0_0_0_0_red-500]",
|
|
73
74
|
gray: "active:after:shadow-[0_0_0_0_gray-500]",
|
|
74
75
|
green: "active:after:shadow-[0_0_0_0_green-500]",
|
|
75
76
|
yellow: "active:after:shadow-[0_0_0_0_yellow-500]",
|
|
76
77
|
orange: "active:after:shadow-[0_0_0_0_orange-500]"
|
|
77
|
-
},
|
|
78
|
+
}, x = "after:content-empty after:absolute after:inset-0 after:opacity-80 after:transition-all after:duration-800 after:shadow-[0_0_0_7px_transparent] after:ease-out active:after:opacity-0 active:after:duration-0", S = {
|
|
78
79
|
brand: {
|
|
79
80
|
solid: "border-brand-500 bg-brand-500 text-brand-50 hover:border-brand-400 hover:bg-brand-400",
|
|
80
81
|
outline: "border-brand-500 text-brand-500 hover:border-brand-400 hover:bg-brand-400/15 hover:text-brand-400",
|
|
@@ -117,30 +118,30 @@ var h = /*#__PURE__*/ e(f, [["render", m], ["__scopeId", "data-v-d7310e6e"]]), g
|
|
|
117
118
|
dashed: "border-orange-500 text-orange-500 hover:border-orange-400 hover:bg-orange-400/15 hover:text-orange-400",
|
|
118
119
|
link: "text-orange-500 hover:text-orange-600"
|
|
119
120
|
}
|
|
120
|
-
},
|
|
121
|
+
}, C = {
|
|
121
122
|
default: "solid",
|
|
122
123
|
outline: "outline",
|
|
123
124
|
dashed: "dashed",
|
|
124
125
|
link: "link",
|
|
125
126
|
mono: "mono"
|
|
126
|
-
},
|
|
127
|
+
}, w = _.flatMap((e) => v.map((t) => ({
|
|
127
128
|
color: e,
|
|
128
129
|
variant: t,
|
|
129
|
-
class: `${
|
|
130
|
-
}))),
|
|
130
|
+
class: `${S[e][C[t]]} ${t === "link" ? "" : `${x} ${b[e]}`}`
|
|
131
|
+
}))), T = n("relative flex shrink-0 items-center justify-center whitespace-nowrap font-normal transition-all duration-150", {
|
|
131
132
|
variants: {
|
|
132
|
-
color:
|
|
133
|
+
color: y(_),
|
|
133
134
|
variant: {
|
|
134
135
|
default: "border",
|
|
135
136
|
outline: "border bg-transparent",
|
|
136
137
|
dashed: "border border-dashed bg-transparent",
|
|
137
138
|
link: "bg-transparent hover:bg-transparent hover:underline underline-offset-4 underline-dashed px-2!",
|
|
138
|
-
mono: "border border-
|
|
139
|
+
mono: "border border-control bg-primary text-zinc-500 dark:text-zinc-400"
|
|
139
140
|
},
|
|
140
141
|
size: {
|
|
141
|
-
sm:
|
|
142
|
-
md:
|
|
143
|
-
lg:
|
|
142
|
+
sm: `[&_svg]:size-4 px-4 gap-1 ${e.sm}`,
|
|
143
|
+
md: `[&_svg]:size-5 px-6 gap-1.5 ${e.md}`,
|
|
144
|
+
lg: `[&_svg]:size-6 px-8 gap-2 ${e.lg}`,
|
|
144
145
|
icon: "[&_svg]:size-4 px-1.5 py-1.5",
|
|
145
146
|
"icon-md": "[&_svg]:size-5 px-2 py-2",
|
|
146
147
|
"icon-lg": "[&_svg]:size-6 px-2.5 py-2.5"
|
|
@@ -154,7 +155,7 @@ var h = /*#__PURE__*/ e(f, [["render", m], ["__scopeId", "data-v-d7310e6e"]]), g
|
|
|
154
155
|
},
|
|
155
156
|
disabled: { true: "opacity-50 cursor-not-allowed pointer-events-none" }
|
|
156
157
|
},
|
|
157
|
-
compoundVariants:
|
|
158
|
+
compoundVariants: w,
|
|
158
159
|
defaultVariants: {
|
|
159
160
|
color: "brand",
|
|
160
161
|
variant: "default",
|
|
@@ -163,6 +164,6 @@ var h = /*#__PURE__*/ e(f, [["render", m], ["__scopeId", "data-v-d7310e6e"]]), g
|
|
|
163
164
|
}
|
|
164
165
|
});
|
|
165
166
|
//#endregion
|
|
166
|
-
export {
|
|
167
|
+
export { g as n, f as r, T as t };
|
|
167
168
|
|
|
168
|
-
//# sourceMappingURL=button-
|
|
169
|
+
//# sourceMappingURL=button-BBFPr3FH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-BBFPr3FH.js","names":[],"sources":["../../src/button/Button.vue","../../src/button/Button.vue","../../src/button/ButtonGroup.vue","../../src/button/index.ts"],"sourcesContent":["<template>\n <button data-ui-button=\"true\" :data-color=\"color\" :data-variant=\"variant\" :type=\"type\" :class=\"button({ color, variant, size, radius, disabled })\" :disabled=\"disabled\">\n <span v-if=\"loading\" class=\"i-lucide:loader-2 animate-spin\" :style=\"`font-size: ${iconSize}px`\"></span>\n <span v-else-if=\"icon\" :class=\"icon\" :style=\"`font-size: ${iconSize}px`\"></span>\n <slot></slot>\n </button>\n</template>\n\n<script setup lang=\"ts\">\nimport { button, type ButtonProps } from '.'\n\n/**\n * Button 是管理端轻量按钮组件,统一颜色、尺寸、圆角、图标和加载态样式。\n */\nwithDefaults(\n defineProps<{\n /** color 是按钮色彩语义,可选,默认 brand。 */\n color?: ButtonProps['color']\n /** variant 是按钮视觉变体,可选,默认 default。 */\n variant?: ButtonProps['variant']\n /** icon 是 UnoCSS/Iconify 图标类名,可选。 */\n icon?: string\n /** iconSize 是图标字号像素值字符串,可选,默认 14。 */\n iconSize?: string\n /** size 是按钮尺寸,可选,默认 md。 */\n size?: ButtonProps['size']\n /** radius 是按钮圆角尺寸,可选,默认 md。 */\n radius?: ButtonProps['radius']\n /** loading 表示是否展示加载图标,可选,默认 false。 */\n loading?: boolean\n /** disabled 表示是否禁用点击和指针事件,可选,默认 false。 */\n disabled?: boolean\n /** type 是原生 button 类型,可选,默认 button,避免表单内误触发提交。 */\n type?: 'button' | 'submit' | 'reset'\n }>(),\n {\n color: 'brand',\n variant: 'default',\n iconSize: '14',\n size: 'md',\n radius: 'md',\n loading: false,\n disabled: false,\n type: 'button'\n }\n)\n</script>\n","<template>\n <button data-ui-button=\"true\" :data-color=\"color\" :data-variant=\"variant\" :type=\"type\" :class=\"button({ color, variant, size, radius, disabled })\" :disabled=\"disabled\">\n <span v-if=\"loading\" class=\"i-lucide:loader-2 animate-spin\" :style=\"`font-size: ${iconSize}px`\"></span>\n <span v-else-if=\"icon\" :class=\"icon\" :style=\"`font-size: ${iconSize}px`\"></span>\n <slot></slot>\n </button>\n</template>\n\n<script setup lang=\"ts\">\nimport { button, type ButtonProps } from '.'\n\n/**\n * Button 是管理端轻量按钮组件,统一颜色、尺寸、圆角、图标和加载态样式。\n */\nwithDefaults(\n defineProps<{\n /** color 是按钮色彩语义,可选,默认 brand。 */\n color?: ButtonProps['color']\n /** variant 是按钮视觉变体,可选,默认 default。 */\n variant?: ButtonProps['variant']\n /** icon 是 UnoCSS/Iconify 图标类名,可选。 */\n icon?: string\n /** iconSize 是图标字号像素值字符串,可选,默认 14。 */\n iconSize?: string\n /** size 是按钮尺寸,可选,默认 md。 */\n size?: ButtonProps['size']\n /** radius 是按钮圆角尺寸,可选,默认 md。 */\n radius?: ButtonProps['radius']\n /** loading 表示是否展示加载图标,可选,默认 false。 */\n loading?: boolean\n /** disabled 表示是否禁用点击和指针事件,可选,默认 false。 */\n disabled?: boolean\n /** type 是原生 button 类型,可选,默认 button,避免表单内误触发提交。 */\n type?: 'button' | 'submit' | 'reset'\n }>(),\n {\n color: 'brand',\n variant: 'default',\n iconSize: '14',\n size: 'md',\n radius: 'md',\n loading: false,\n disabled: false,\n type: 'button'\n }\n)\n</script>\n","<template>\n <div class=\"inline-flex items-center isolate\">\n <slot />\n </div>\n</template>\n\n<style scoped>\n:deep(button),\n:deep(.button) {\n border-radius: 0 !important;\n}\n\n/* 按钮组内部取消中间圆角,仅首尾按钮保留外侧圆角。 */\n:deep(> *:first-child),\n:deep(> *:first-child button) {\n border-top-left-radius: 0.375rem !important;\n border-bottom-left-radius: 0.375rem !important;\n}\n\n:deep(> *:last-child),\n:deep(> *:last-child button) {\n border-top-right-radius: 0.375rem !important;\n border-bottom-right-radius: 0.375rem !important;\n}\n\n/* 相邻按钮边框重叠,避免按钮组中间出现双边框。 */\n:deep(> *:not(:first-child)) {\n margin-left: -1px;\n}\n\n/* 按钮组内的 default 表示已选中,hover 时保持选中态本色。 */\n:deep([data-ui-button='true'][data-variant='default'][data-color='brand']:hover) {\n --at-apply: '!border-brand-500 !bg-brand-500';\n}\n\n:deep([data-ui-button='true'][data-variant='default'][data-color='red']:hover) {\n --at-apply: '!border-red-500 !bg-red-500';\n}\n\n:deep([data-ui-button='true'][data-variant='default'][data-color='gray']:hover) {\n --at-apply: '!border-gray-500 !bg-gray-500';\n}\n\n:deep([data-ui-button='true'][data-variant='default'][data-color='green']:hover) {\n --at-apply: '!border-green-500 !bg-green-500';\n}\n\n:deep([data-ui-button='true'][data-variant='default'][data-color='yellow']:hover) {\n --at-apply: '!border-amber-500 !bg-amber-500';\n}\n\n:deep([data-ui-button='true'][data-variant='default'][data-color='orange']:hover) {\n --at-apply: '!border-orange-500 !bg-orange-500';\n}\n</style>\n","import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\n\nimport { controlSizeClasses } from '../control'\n\nexport { default as Button } from './Button.vue'\nexport { default as ButtonGroup } from './ButtonGroup.vue'\n\nconst buttonColorOptions = ['brand', 'red', 'gray', 'green', 'yellow', 'orange'] as const\nconst buttonVariantOptions = ['default', 'outline', 'dashed', 'link', 'mono'] as const\ntype ButtonColor = (typeof buttonColorOptions)[number]\ntype ButtonVariant = (typeof buttonVariantOptions)[number]\ntype ButtonColorStyleKey = 'solid' | 'outline' | 'mono' | 'dashed' | 'link'\n\nconst emptyVariantRecord = <T extends readonly string[]>(options: T) => Object.fromEntries(options.map((option) => [option, ''])) as Record<T[number], ''>\n\nconst buttonActiveClasses: Record<ButtonColor, string> = {\n brand: 'active:after:shadow-[0_0_0_0_brand-500]',\n red: 'active:after:shadow-[0_0_0_0_red-500]',\n gray: 'active:after:shadow-[0_0_0_0_gray-500]',\n green: 'active:after:shadow-[0_0_0_0_green-500]',\n yellow: 'active:after:shadow-[0_0_0_0_yellow-500]',\n orange: 'active:after:shadow-[0_0_0_0_orange-500]'\n}\nconst buttonRippleClasses = 'after:content-empty after:absolute after:inset-0 after:opacity-80 after:transition-all after:duration-800 after:shadow-[0_0_0_7px_transparent] after:ease-out active:after:opacity-0 active:after:duration-0'\n\n// 颜色态保留完整 UnoCSS 类字面量,确保构建扫描可以生成对应样式。\nconst buttonColorClasses: Record<ButtonColor, Record<ButtonColorStyleKey, string>> = {\n brand: {\n solid: 'border-brand-500 bg-brand-500 text-brand-50 hover:border-brand-400 hover:bg-brand-400',\n outline: 'border-brand-500 text-brand-500 hover:border-brand-400 hover:bg-brand-400/15 hover:text-brand-400',\n mono: 'hover:border-brand-400 hover:bg-brand-400/15 hover:text-brand-400',\n dashed: 'border-brand-500 text-brand-500 hover:border-brand-400 hover:bg-brand-400/15 hover:text-brand-400',\n link: 'text-brand-500 hover:text-brand-600'\n },\n red: {\n solid: 'border-red-500 bg-red-500 text-red-50 hover:border-red-400 hover:bg-red-400',\n outline: 'border-red-500 text-red-500 hover:border-red-400 hover:bg-red-400/15 hover:text-red-400',\n mono: 'hover:border-red-400 hover:bg-red-400/15 hover:text-red-400',\n dashed: 'border-red-500 text-red-500 hover:border-red-400 hover:bg-red-400/15 hover:text-red-400',\n link: 'text-red-500 hover:text-red-600'\n },\n gray: {\n solid: 'border-gray-500 bg-gray-500 text-gray-50 hover:border-gray-400 hover:bg-gray-400',\n outline: 'border-gray-400 text-gray-500 hover:border-gray-400 hover:bg-gray-400/15 hover:text-gray-400',\n mono: 'hover:border-gray-400 hover:bg-gray-400/15 hover:text-gray-400',\n dashed: 'border-gray-400 text-gray-500 hover:border-gray-400 hover:bg-gray-400/15 hover:text-gray-400',\n link: 'text-gray-500 hover:text-gray-600'\n },\n green: {\n solid: 'border-green-500 bg-green-500 text-green-50 hover:border-green-400 hover:bg-green-400',\n outline: 'border-green-500 text-green-500 hover:border-green-400 hover:bg-green-400/15 hover:text-green-400',\n mono: 'hover:border-green-400 hover:bg-green-400/15 hover:text-green-400',\n dashed: 'border-green-500 text-green-500 hover:border-green-400 hover:bg-green-400/15 hover:text-green-400',\n link: 'text-green-500 hover:text-green-600'\n },\n yellow: {\n solid: 'border-amber-500 bg-amber-500 text-amber-50 hover:border-amber-400 hover:bg-amber-400',\n outline: 'border-amber-500 text-amber-500 hover:border-amber-400 hover:bg-amber-400/15 hover:text-amber-400',\n mono: 'hover:border-amber-400 hover:bg-amber-400/15 hover:text-amber-400',\n dashed: 'border-amber-500 text-amber-500 hover:border-amber-400 hover:bg-amber-400/15 hover:text-amber-400',\n link: 'text-amber-500 hover:text-amber-600'\n },\n orange: {\n solid: 'border-orange-500 bg-orange-500 text-orange-50 hover:border-orange-400 hover:bg-orange-400',\n outline: 'border-orange-500 text-orange-500 hover:border-orange-400 hover:bg-orange-400/15 hover:text-orange-400',\n mono: 'hover:border-orange-400 hover:bg-orange-400/15 hover:text-orange-400',\n dashed: 'border-orange-500 text-orange-500 hover:border-orange-400 hover:bg-orange-400/15 hover:text-orange-400',\n link: 'text-orange-500 hover:text-orange-600'\n }\n} as const\n\nconst buttonVariantColorStyleKeys: Record<ButtonVariant, ButtonColorStyleKey> = {\n default: 'solid',\n outline: 'outline',\n dashed: 'dashed',\n link: 'link',\n mono: 'mono'\n}\n\nconst buttonCompoundVariants = buttonColorOptions.flatMap((color) =>\n buttonVariantOptions.map((variant) => ({\n color,\n variant,\n class: `${buttonColorClasses[color][buttonVariantColorStyleKeys[variant]]} ${variant === 'link' ? '' : `${buttonRippleClasses} ${buttonActiveClasses[color]}`}`\n }))\n)\n\n/** button 定义管理端 Button 组件的样式变体组合。 */\nexport const button = cva('relative flex shrink-0 items-center justify-center whitespace-nowrap font-normal transition-all duration-150', {\n variants: {\n color: emptyVariantRecord(buttonColorOptions),\n variant: {\n default: 'border',\n outline: 'border bg-transparent',\n dashed: 'border border-dashed bg-transparent',\n link: 'bg-transparent hover:bg-transparent hover:underline underline-offset-4 underline-dashed px-2!',\n mono: 'border border-control bg-primary text-zinc-500 dark:text-zinc-400'\n },\n size: {\n sm: `[&_svg]:size-4 px-4 gap-1 ${controlSizeClasses.sm}`,\n md: `[&_svg]:size-5 px-6 gap-1.5 ${controlSizeClasses.md}`,\n lg: `[&_svg]:size-6 px-8 gap-2 ${controlSizeClasses.lg}`,\n icon: '[&_svg]:size-4 px-1.5 py-1.5',\n 'icon-md': '[&_svg]:size-5 px-2 py-2',\n 'icon-lg': '[&_svg]:size-6 px-2.5 py-2.5'\n },\n radius: {\n none: 'rounded-none after:rounded-none',\n sm: 'rounded-sm after:rounded-sm',\n md: 'rounded-md after:rounded-md',\n lg: 'rounded-lg after:rounded-lg',\n full: 'rounded-full after:rounded-full'\n },\n disabled: {\n true: 'opacity-50 cursor-not-allowed pointer-events-none'\n }\n },\n compoundVariants: buttonCompoundVariants,\n defaultVariants: {\n color: 'brand',\n variant: 'default',\n size: 'sm',\n radius: 'md'\n }\n})\n\n/** ButtonProps 是 button 变体推导出的组件属性类型。 */\nexport type ButtonProps = VariantProps<typeof button>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBACE,EAIS,UAAA;GAJD,kBAAe;GAAQ,cAAY,EAAA;GAAQ,gBAAc,EAAA;GAAU,MAAM,EAAA;GAAO,OAAK,EAAE,EAAA,CAAA,CAAM,CAAA;IAAA,OAAG,EAAA;IAAK,SAAE,EAAA;IAAO,MAAE,EAAA;IAAI,QAAE,EAAA;IAAM,UAAE,EAAA;GAAQ,CAAA,CAAA;GAAM,UAAU,EAAA;MAChJ,EAAA,WAAA,EAAA,GAAZ,EAAuG,QAAA;;GAAlF,OAAM;GAAkC,OAAK,EAAA,cAAgB,EAAA,SAAQ,GAAA;iBACzE,EAAA,QAAA,EAAA,GAAjB,EAAgF,QAAA;;GAAxD,OAAK,EAAE,EAAA,IAAI;GAAG,OAAK,EAAA,cAAgB,EAAA,SAAQ,GAAA;4BACnE,EAAa,EAAA,QAAA,SAAA,CAAA,GAAA,IAAA,CAAA;;kBEHV,OAAM,mCAAkC;;aAA7C,EAEM,OAFN,GAEM,CADJ,EAAQ,EAAA,QAAA,WAAA,CAAA,GAAA,KAAA,GAAA,EAAA,CAAA,CAAA;;+ECMN,IAAqB;CAAC;CAAS;CAAO;CAAQ;CAAS;CAAU;AAAQ,GACzE,IAAuB;CAAC;CAAW;CAAW;CAAU;CAAQ;AAAM,GAKtE,KAAmD,MAAe,OAAO,YAAY,EAAQ,KAAK,MAAW,CAAC,GAAQ,EAAE,CAAC,CAAC,GAE1H,IAAmD;CACvD,OAAO;CACP,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,QAAQ;AACV,GACM,IA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188
188
|
checked: !1,
|
|
189
189
|
disabled: !1,
|
|
190
|
-
class: "border-
|
|
190
|
+
class: "border-control bg-primary hover:border-brand-400 dark:bg-zinc-950 dark:hover:border-brand-400"
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
checked: !1,
|
|
@@ -257,4 +257,4 @@ var w = [
|
|
|
257
257
|
//#endregion
|
|
258
258
|
export { O as a, A as i, N as n, j as r, M as t };
|
|
259
259
|
|
|
260
|
-
//# sourceMappingURL=checkbox-
|
|
260
|
+
//# sourceMappingURL=checkbox-wJpQHCeN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-9_0oR4kg.js","names":["$slots"],"sources":["../../src/checkbox/Checkbox.vue","../../src/checkbox/Checkbox.vue","../../src/checkbox/CheckboxGroup.vue","../../src/checkbox/CheckboxGroup.vue","../../src/checkbox/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, inject, nextTick, onMounted, ref, useAttrs, watch } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkbox, checkboxGroupContextKey, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\n/**\n * Checkbox 是编辑器 UI 使用的原生复选框封装。\n *\n * 组件保留 input 原生事件;组内受控值由 CheckboxGroup 统一管理。\n */\nconst props = withDefaults(\n defineProps<{\n /** checked 是非受控单个 Checkbox 的默认选中态;组内选中态由 CheckboxGroup 控制。 */\n checked?: boolean\n /** indeterminate 表示部分选中状态,只控制视觉和原生 input 中间态。 */\n indeterminate?: boolean\n /** value 是当前 Checkbox 代表的值,组内选中时会同步到 CheckboxGroup modelValue。 */\n value?: CheckboxValue\n /** disabled 表示是否禁用交互,可选,默认 false。 */\n disabled?: boolean\n /** size 表示复选框尺寸;未传时继承 CheckboxGroup,组外默认 md。 */\n size?: CheckboxSize\n /** name 是原生 checkbox name;未传时继承 CheckboxGroup。 */\n name?: string\n }>(),\n {\n checked: undefined,\n indeterminate: false,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'change', checked: boolean, event: Event): void\n (e: 'input', event: Event): void\n (e: 'focus', event: FocusEvent): void\n (e: 'blur', event: FocusEvent): void\n}>()\n\nconst attrs = useAttrs()\nconst groupContext = inject(checkboxGroupContextKey, null)\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst internalChecked = ref(!!props.checked)\nconst hasSizeClass = computed(() => /(?:^|\\s)!?(?:size|h|w)-/.test(getUiAttrClass(attrs)))\nconst resolvedDisabled = computed(() => props.disabled || !!groupContext?.disabled.value)\nconst resolvedSize = computed(() => props.size ?? groupContext?.size.value ?? 'md')\nconst resolvedName = computed(() => props.name ?? groupContext?.name.value)\nconst isChecked = computed(() => (groupContext && props.value !== undefined ? groupContext.modelValue.value.includes(props.value) : internalChecked.value))\nconst isIndeterminate = computed(() => props.indeterminate)\nconst isActive = computed(() => isChecked.value || isIndeterminate.value)\nconst ariaChecked = computed(() => (isIndeterminate.value ? 'mixed' : Boolean(isChecked.value)))\nconst checkboxClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkbox({\n size: hasSizeClass.value ? null : resolvedSize.value,\n checked: isActive.value,\n disabled: resolvedDisabled.value\n })\n )\n)\n\nwatch(\n () => props.checked,\n (checked) => {\n if (!groupContext) {\n internalChecked.value = !!checked\n }\n }\n)\n\nfunction syncNativeInputState() {\n if (!inputRef.value) return\n inputRef.value.checked = Boolean(isChecked.value)\n inputRef.value.indeterminate = isIndeterminate.value\n}\n\nonMounted(syncNativeInputState)\nwatch([isChecked, isIndeterminate], () => nextTick(syncNativeInputState))\n\nfunction syncInputChecked(event: Event) {\n const target = event.target as HTMLInputElement | null\n if (target) {\n target.checked = Boolean(isChecked.value)\n target.indeterminate = isIndeterminate.value\n }\n}\n\nfunction handleInput(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n emit('input', event)\n}\n\n/**\n * 同步原生 change 事件到 CheckboxGroup 和外部监听器。\n *\n * @param event 原生 change 事件,target 必须是复选框 input。\n * @returns 无返回值。\n */\nfunction handleChange(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n const checked = (event.target as HTMLInputElement).checked\n internalChecked.value = checked\n emit('change', checked, event)\n if (groupContext && props.value !== undefined) {\n groupContext.updateValue(props.value, checked, event)\n }\n void nextTick(syncNativeInputState)\n}\n</script>\n\n<template>\n <label :class=\"['inline-flex w-fit items-center align-middle', resolvedDisabled ? 'cursor-not-allowed text-tertiary opacity-70' : 'cursor-pointer text-secondary', $slots.default ? 'gap-2' : '']\" :style=\"getUiAttrStyle(attrs)\">\n <span :class=\"checkboxClass\">\n <input\n ref=\"inputRef\"\n v-bind=\"getUiExposeAttrs(attrs)\"\n data-map-ui-checkbox=\"true\"\n type=\"checkbox\"\n :name=\"resolvedName\"\n :value=\"value\"\n :checked=\"isChecked\"\n :aria-checked=\"ariaChecked\"\n :disabled=\"resolvedDisabled\"\n class=\"absolute inset-0 m-0 h-full w-full cursor-inherit opacity-0\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @focus=\"emit('focus', $event)\"\n @blur=\"emit('blur', $event)\"\n />\n <svg v-if=\"isIndeterminate\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M4 8H12\" stroke=\"white\" stroke-width=\"2.4\" stroke-linecap=\"round\" />\n </svg>\n <svg v-else-if=\"isChecked\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M3.5 8.25L6.5 11L12.5 5\" stroke=\"white\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span v-if=\"$slots.default\" class=\"select-none\">\n <slot></slot>\n </span>\n </label>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, inject, nextTick, onMounted, ref, useAttrs, watch } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkbox, checkboxGroupContextKey, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\n/**\n * Checkbox 是编辑器 UI 使用的原生复选框封装。\n *\n * 组件保留 input 原生事件;组内受控值由 CheckboxGroup 统一管理。\n */\nconst props = withDefaults(\n defineProps<{\n /** checked 是非受控单个 Checkbox 的默认选中态;组内选中态由 CheckboxGroup 控制。 */\n checked?: boolean\n /** indeterminate 表示部分选中状态,只控制视觉和原生 input 中间态。 */\n indeterminate?: boolean\n /** value 是当前 Checkbox 代表的值,组内选中时会同步到 CheckboxGroup modelValue。 */\n value?: CheckboxValue\n /** disabled 表示是否禁用交互,可选,默认 false。 */\n disabled?: boolean\n /** size 表示复选框尺寸;未传时继承 CheckboxGroup,组外默认 md。 */\n size?: CheckboxSize\n /** name 是原生 checkbox name;未传时继承 CheckboxGroup。 */\n name?: string\n }>(),\n {\n checked: undefined,\n indeterminate: false,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'change', checked: boolean, event: Event): void\n (e: 'input', event: Event): void\n (e: 'focus', event: FocusEvent): void\n (e: 'blur', event: FocusEvent): void\n}>()\n\nconst attrs = useAttrs()\nconst groupContext = inject(checkboxGroupContextKey, null)\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst internalChecked = ref(!!props.checked)\nconst hasSizeClass = computed(() => /(?:^|\\s)!?(?:size|h|w)-/.test(getUiAttrClass(attrs)))\nconst resolvedDisabled = computed(() => props.disabled || !!groupContext?.disabled.value)\nconst resolvedSize = computed(() => props.size ?? groupContext?.size.value ?? 'md')\nconst resolvedName = computed(() => props.name ?? groupContext?.name.value)\nconst isChecked = computed(() => (groupContext && props.value !== undefined ? groupContext.modelValue.value.includes(props.value) : internalChecked.value))\nconst isIndeterminate = computed(() => props.indeterminate)\nconst isActive = computed(() => isChecked.value || isIndeterminate.value)\nconst ariaChecked = computed(() => (isIndeterminate.value ? 'mixed' : Boolean(isChecked.value)))\nconst checkboxClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkbox({\n size: hasSizeClass.value ? null : resolvedSize.value,\n checked: isActive.value,\n disabled: resolvedDisabled.value\n })\n )\n)\n\nwatch(\n () => props.checked,\n (checked) => {\n if (!groupContext) {\n internalChecked.value = !!checked\n }\n }\n)\n\nfunction syncNativeInputState() {\n if (!inputRef.value) return\n inputRef.value.checked = Boolean(isChecked.value)\n inputRef.value.indeterminate = isIndeterminate.value\n}\n\nonMounted(syncNativeInputState)\nwatch([isChecked, isIndeterminate], () => nextTick(syncNativeInputState))\n\nfunction syncInputChecked(event: Event) {\n const target = event.target as HTMLInputElement | null\n if (target) {\n target.checked = Boolean(isChecked.value)\n target.indeterminate = isIndeterminate.value\n }\n}\n\nfunction handleInput(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n emit('input', event)\n}\n\n/**\n * 同步原生 change 事件到 CheckboxGroup 和外部监听器。\n *\n * @param event 原生 change 事件,target 必须是复选框 input。\n * @returns 无返回值。\n */\nfunction handleChange(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n const checked = (event.target as HTMLInputElement).checked\n internalChecked.value = checked\n emit('change', checked, event)\n if (groupContext && props.value !== undefined) {\n groupContext.updateValue(props.value, checked, event)\n }\n void nextTick(syncNativeInputState)\n}\n</script>\n\n<template>\n <label :class=\"['inline-flex w-fit items-center align-middle', resolvedDisabled ? 'cursor-not-allowed text-tertiary opacity-70' : 'cursor-pointer text-secondary', $slots.default ? 'gap-2' : '']\" :style=\"getUiAttrStyle(attrs)\">\n <span :class=\"checkboxClass\">\n <input\n ref=\"inputRef\"\n v-bind=\"getUiExposeAttrs(attrs)\"\n data-map-ui-checkbox=\"true\"\n type=\"checkbox\"\n :name=\"resolvedName\"\n :value=\"value\"\n :checked=\"isChecked\"\n :aria-checked=\"ariaChecked\"\n :disabled=\"resolvedDisabled\"\n class=\"absolute inset-0 m-0 h-full w-full cursor-inherit opacity-0\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @focus=\"emit('focus', $event)\"\n @blur=\"emit('blur', $event)\"\n />\n <svg v-if=\"isIndeterminate\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M4 8H12\" stroke=\"white\" stroke-width=\"2.4\" stroke-linecap=\"round\" />\n </svg>\n <svg v-else-if=\"isChecked\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M3.5 8.25L6.5 11L12.5 5\" stroke=\"white\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span v-if=\"$slots.default\" class=\"select-none\">\n <slot></slot>\n </span>\n </label>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, provide, toRef, useAttrs } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkboxGroup, checkboxGroupContextKey, type CheckboxGroupDirection, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是组内当前选中值数组。 */\n modelValue?: CheckboxValue[]\n /** disabled 会禁用组内所有 Checkbox。 */\n disabled?: boolean\n /** size 统一设置组内 Checkbox 尺寸,可被子项显式 size 覆盖。 */\n size?: CheckboxSize\n /** name 统一设置组内原生 checkbox name。 */\n name?: string\n /** direction 控制组内排列方向。 */\n direction?: CheckboxGroupDirection\n }>(),\n {\n modelValue: () => [],\n disabled: false,\n size: 'md',\n name: undefined,\n direction: 'horizontal'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: CheckboxValue[]): void\n (e: 'change', value: CheckboxValue[], event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst groupClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkboxGroup({\n direction: props.direction,\n size: props.size,\n disabled: props.disabled\n })\n )\n)\n\nfunction updateValue(value: CheckboxValue, checked: boolean, event: Event) {\n const currentValue = props.modelValue ?? []\n const nextValue = checked\n ? currentValue.includes(value)\n ? currentValue\n : [...currentValue, value]\n : currentValue.filter((item) => item !== value)\n emit('update:modelValue', nextValue)\n emit('change', nextValue, event)\n}\n\nprovide(checkboxGroupContextKey, {\n modelValue: toRef(props, 'modelValue'),\n disabled: toRef(props, 'disabled'),\n size: toRef(props, 'size'),\n name: toRef(props, 'name'),\n updateValue\n})\n</script>\n\n<template>\n <div\n v-bind=\"getUiExposeAttrs(attrs)\"\n role=\"group\"\n data-ui-checkbox-group=\"true\"\n :data-direction=\"direction\"\n :aria-disabled=\"disabled || undefined\"\n :class=\"groupClass\"\n :style=\"getUiAttrStyle(attrs)\"\n >\n <slot></slot>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, provide, toRef, useAttrs } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkboxGroup, checkboxGroupContextKey, type CheckboxGroupDirection, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是组内当前选中值数组。 */\n modelValue?: CheckboxValue[]\n /** disabled 会禁用组内所有 Checkbox。 */\n disabled?: boolean\n /** size 统一设置组内 Checkbox 尺寸,可被子项显式 size 覆盖。 */\n size?: CheckboxSize\n /** name 统一设置组内原生 checkbox name。 */\n name?: string\n /** direction 控制组内排列方向。 */\n direction?: CheckboxGroupDirection\n }>(),\n {\n modelValue: () => [],\n disabled: false,\n size: 'md',\n name: undefined,\n direction: 'horizontal'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: CheckboxValue[]): void\n (e: 'change', value: CheckboxValue[], event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst groupClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkboxGroup({\n direction: props.direction,\n size: props.size,\n disabled: props.disabled\n })\n )\n)\n\nfunction updateValue(value: CheckboxValue, checked: boolean, event: Event) {\n const currentValue = props.modelValue ?? []\n const nextValue = checked\n ? currentValue.includes(value)\n ? currentValue\n : [...currentValue, value]\n : currentValue.filter((item) => item !== value)\n emit('update:modelValue', nextValue)\n emit('change', nextValue, event)\n}\n\nprovide(checkboxGroupContextKey, {\n modelValue: toRef(props, 'modelValue'),\n disabled: toRef(props, 'disabled'),\n size: toRef(props, 'size'),\n name: toRef(props, 'name'),\n updateValue\n})\n</script>\n\n<template>\n <div\n v-bind=\"getUiExposeAttrs(attrs)\"\n role=\"group\"\n data-ui-checkbox-group=\"true\"\n :data-direction=\"direction\"\n :aria-disabled=\"disabled || undefined\"\n :class=\"groupClass\"\n :style=\"getUiAttrStyle(attrs)\"\n >\n <slot></slot>\n </div>\n</template>\n","import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\nimport type { InjectionKey, Ref } from 'vue'\n\nexport { default as Checkbox } from './Checkbox.vue'\nexport { default as CheckboxGroup } from './CheckboxGroup.vue'\n\nexport type CheckboxValue = string | number\nexport type CheckboxSize = 'sm' | 'md' | 'lg'\nexport type CheckboxGroupDirection = 'horizontal' | 'vertical'\n\nexport interface CheckboxGroupContext {\n modelValue: Readonly<Ref<CheckboxValue[]>>\n disabled: Readonly<Ref<boolean>>\n size: Readonly<Ref<CheckboxSize>>\n name: Readonly<Ref<string | undefined>>\n updateValue: (value: CheckboxValue, checked: boolean, event: Event) => void\n}\n\nexport const checkboxGroupContextKey: InjectionKey<CheckboxGroupContext> = Symbol('ui-checkbox-group-context')\n\n/** checkbox 定义管理端 Checkbox 组件的样式变体组合。 */\nexport const checkbox = cva('relative inline-flex shrink-0 items-center justify-center overflow-hidden border align-middle transition-colors duration-150', {\n variants: {\n size: {\n sm: 'size-4 rounded-sm',\n md: 'size-5 rounded',\n lg: 'size-6 rounded'\n },\n checked: {\n true: '',\n false: ''\n },\n disabled: {\n true: 'cursor-not-allowed',\n false: 'cursor-pointer'\n }\n },\n compoundVariants: [\n {\n checked: true,\n disabled: false,\n class: 'border-brand-500 bg-brand-500 dark:border-brand-400 dark:bg-brand-500'\n },\n {\n checked: true,\n disabled: true,\n class: 'border-zinc-400 bg-zinc-400 dark:border-zinc-600 dark:bg-zinc-800'\n },\n {\n checked: false,\n disabled: false,\n class: 'border-medium bg-primary hover:border-brand-400 dark:border-zinc-500 dark:bg-zinc-950 dark:hover:border-brand-400'\n },\n {\n checked: false,\n disabled: true,\n class: 'border-zinc-300 bg-zinc-100 dark:border-zinc-600 dark:bg-zinc-800'\n }\n ],\n defaultVariants: {\n size: 'md',\n checked: false,\n disabled: false\n }\n})\n\n/** checkboxGroup 定义 CheckboxGroup 根节点布局。 */\nexport const checkboxGroup = cva('ui-checkbox-group inline-flex w-fit align-middle', {\n variants: {\n direction: {\n horizontal: 'flex-row flex-wrap items-center',\n vertical: 'flex-col items-start'\n },\n size: {\n sm: '',\n md: '',\n lg: ''\n },\n disabled: {\n true: '',\n false: ''\n }\n },\n compoundVariants: [\n { direction: 'horizontal', size: 'sm', class: 'gap-x-4 gap-y-2' },\n { direction: 'horizontal', size: 'md', class: 'gap-x-5 gap-y-2' },\n { direction: 'horizontal', size: 'lg', class: 'gap-x-6 gap-y-2.5' },\n { direction: 'vertical', size: 'sm', class: 'gap-1.5' },\n { direction: 'vertical', size: 'md', class: 'gap-2' },\n { direction: 'vertical', size: 'lg', class: 'gap-2.5' }\n ],\n defaultVariants: {\n direction: 'horizontal',\n size: 'md',\n disabled: false\n }\n})\n\n/** CheckboxProps 是 checkbox 变体推导出的组件属性类型。 */\nexport type CheckboxProps = VariantProps<typeof checkbox>\nexport type CheckboxGroupProps = VariantProps<typeof checkboxGroup>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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U;GACR,MAAM;GACN,OAAO;EACT;CACF;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,UAAU;GACV,OAAO;EACT;EACA;GACE,SAAS;GACT,UAAU;GACV,OAAO;EACT;EACA;GACE,SAAS;GACT,UAAU;GACV,OAAO;EACT;EACA;GACE,SAAS;GACT,UAAU;GACV,OAAO;EACT;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;EACT,UAAU;CACZ;AACF,CAAC,GAGY,IAAgB,EAAI,oDAAoD;CACnF,UAAU;EACR,WAAW;GACT,YAAY;GACZ,UAAU;EACZ;EACA,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,UAAU;GACR,MAAM;GACN,OAAO;EACT;CACF;CACA,kBAAkB;EAChB;GAAE,WAAW;GAAc,MAAM;GAAM,OAAO;EAAkB;EAChE;GAAE,WAAW;GAAc,MAAM;GAAM,OAAO;EAAkB;EAChE;GAAE,WAAW;GAAc,MAAM;GAAM,OAAO;EAAoB;EAClE;GAAE,WAAW;GAAY,MAAM;GAAM,OAAO;EAAU;EACtD;GAAE,WAAW;GAAY,MAAM;GAAM,OAAO;EAAQ;EACpD;GAAE,WAAW;GAAY,MAAM;GAAM,OAAO;EAAU;CACxD;CACA,iBAAiB;EACf,WAAW;EACX,MAAM;EACN,UAAU;CACZ;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"checkbox-wJpQHCeN.js","names":["$slots"],"sources":["../../src/checkbox/Checkbox.vue","../../src/checkbox/Checkbox.vue","../../src/checkbox/CheckboxGroup.vue","../../src/checkbox/CheckboxGroup.vue","../../src/checkbox/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, inject, nextTick, onMounted, ref, useAttrs, watch } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkbox, checkboxGroupContextKey, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\n/**\n * Checkbox 是编辑器 UI 使用的原生复选框封装。\n *\n * 组件保留 input 原生事件;组内受控值由 CheckboxGroup 统一管理。\n */\nconst props = withDefaults(\n defineProps<{\n /** checked 是非受控单个 Checkbox 的默认选中态;组内选中态由 CheckboxGroup 控制。 */\n checked?: boolean\n /** indeterminate 表示部分选中状态,只控制视觉和原生 input 中间态。 */\n indeterminate?: boolean\n /** value 是当前 Checkbox 代表的值,组内选中时会同步到 CheckboxGroup modelValue。 */\n value?: CheckboxValue\n /** disabled 表示是否禁用交互,可选,默认 false。 */\n disabled?: boolean\n /** size 表示复选框尺寸;未传时继承 CheckboxGroup,组外默认 md。 */\n size?: CheckboxSize\n /** name 是原生 checkbox name;未传时继承 CheckboxGroup。 */\n name?: string\n }>(),\n {\n checked: undefined,\n indeterminate: false,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'change', checked: boolean, event: Event): void\n (e: 'input', event: Event): void\n (e: 'focus', event: FocusEvent): void\n (e: 'blur', event: FocusEvent): void\n}>()\n\nconst attrs = useAttrs()\nconst groupContext = inject(checkboxGroupContextKey, null)\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst internalChecked = ref(!!props.checked)\nconst hasSizeClass = computed(() => /(?:^|\\s)!?(?:size|h|w)-/.test(getUiAttrClass(attrs)))\nconst resolvedDisabled = computed(() => props.disabled || !!groupContext?.disabled.value)\nconst resolvedSize = computed(() => props.size ?? groupContext?.size.value ?? 'md')\nconst resolvedName = computed(() => props.name ?? groupContext?.name.value)\nconst isChecked = computed(() => (groupContext && props.value !== undefined ? groupContext.modelValue.value.includes(props.value) : internalChecked.value))\nconst isIndeterminate = computed(() => props.indeterminate)\nconst isActive = computed(() => isChecked.value || isIndeterminate.value)\nconst ariaChecked = computed(() => (isIndeterminate.value ? 'mixed' : Boolean(isChecked.value)))\nconst checkboxClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkbox({\n size: hasSizeClass.value ? null : resolvedSize.value,\n checked: isActive.value,\n disabled: resolvedDisabled.value\n })\n )\n)\n\nwatch(\n () => props.checked,\n (checked) => {\n if (!groupContext) {\n internalChecked.value = !!checked\n }\n }\n)\n\nfunction syncNativeInputState() {\n if (!inputRef.value) return\n inputRef.value.checked = Boolean(isChecked.value)\n inputRef.value.indeterminate = isIndeterminate.value\n}\n\nonMounted(syncNativeInputState)\nwatch([isChecked, isIndeterminate], () => nextTick(syncNativeInputState))\n\nfunction syncInputChecked(event: Event) {\n const target = event.target as HTMLInputElement | null\n if (target) {\n target.checked = Boolean(isChecked.value)\n target.indeterminate = isIndeterminate.value\n }\n}\n\nfunction handleInput(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n emit('input', event)\n}\n\n/**\n * 同步原生 change 事件到 CheckboxGroup 和外部监听器。\n *\n * @param event 原生 change 事件,target 必须是复选框 input。\n * @returns 无返回值。\n */\nfunction handleChange(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n const checked = (event.target as HTMLInputElement).checked\n internalChecked.value = checked\n emit('change', checked, event)\n if (groupContext && props.value !== undefined) {\n groupContext.updateValue(props.value, checked, event)\n }\n void nextTick(syncNativeInputState)\n}\n</script>\n\n<template>\n <label :class=\"['inline-flex w-fit items-center align-middle', resolvedDisabled ? 'cursor-not-allowed text-tertiary opacity-70' : 'cursor-pointer text-secondary', $slots.default ? 'gap-2' : '']\" :style=\"getUiAttrStyle(attrs)\">\n <span :class=\"checkboxClass\">\n <input\n ref=\"inputRef\"\n v-bind=\"getUiExposeAttrs(attrs)\"\n data-map-ui-checkbox=\"true\"\n type=\"checkbox\"\n :name=\"resolvedName\"\n :value=\"value\"\n :checked=\"isChecked\"\n :aria-checked=\"ariaChecked\"\n :disabled=\"resolvedDisabled\"\n class=\"absolute inset-0 m-0 h-full w-full cursor-inherit opacity-0\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @focus=\"emit('focus', $event)\"\n @blur=\"emit('blur', $event)\"\n />\n <svg v-if=\"isIndeterminate\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M4 8H12\" stroke=\"white\" stroke-width=\"2.4\" stroke-linecap=\"round\" />\n </svg>\n <svg v-else-if=\"isChecked\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M3.5 8.25L6.5 11L12.5 5\" stroke=\"white\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span v-if=\"$slots.default\" class=\"select-none\">\n <slot></slot>\n </span>\n </label>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, inject, nextTick, onMounted, ref, useAttrs, watch } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkbox, checkboxGroupContextKey, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\n/**\n * Checkbox 是编辑器 UI 使用的原生复选框封装。\n *\n * 组件保留 input 原生事件;组内受控值由 CheckboxGroup 统一管理。\n */\nconst props = withDefaults(\n defineProps<{\n /** checked 是非受控单个 Checkbox 的默认选中态;组内选中态由 CheckboxGroup 控制。 */\n checked?: boolean\n /** indeterminate 表示部分选中状态,只控制视觉和原生 input 中间态。 */\n indeterminate?: boolean\n /** value 是当前 Checkbox 代表的值,组内选中时会同步到 CheckboxGroup modelValue。 */\n value?: CheckboxValue\n /** disabled 表示是否禁用交互,可选,默认 false。 */\n disabled?: boolean\n /** size 表示复选框尺寸;未传时继承 CheckboxGroup,组外默认 md。 */\n size?: CheckboxSize\n /** name 是原生 checkbox name;未传时继承 CheckboxGroup。 */\n name?: string\n }>(),\n {\n checked: undefined,\n indeterminate: false,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'change', checked: boolean, event: Event): void\n (e: 'input', event: Event): void\n (e: 'focus', event: FocusEvent): void\n (e: 'blur', event: FocusEvent): void\n}>()\n\nconst attrs = useAttrs()\nconst groupContext = inject(checkboxGroupContextKey, null)\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst internalChecked = ref(!!props.checked)\nconst hasSizeClass = computed(() => /(?:^|\\s)!?(?:size|h|w)-/.test(getUiAttrClass(attrs)))\nconst resolvedDisabled = computed(() => props.disabled || !!groupContext?.disabled.value)\nconst resolvedSize = computed(() => props.size ?? groupContext?.size.value ?? 'md')\nconst resolvedName = computed(() => props.name ?? groupContext?.name.value)\nconst isChecked = computed(() => (groupContext && props.value !== undefined ? groupContext.modelValue.value.includes(props.value) : internalChecked.value))\nconst isIndeterminate = computed(() => props.indeterminate)\nconst isActive = computed(() => isChecked.value || isIndeterminate.value)\nconst ariaChecked = computed(() => (isIndeterminate.value ? 'mixed' : Boolean(isChecked.value)))\nconst checkboxClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkbox({\n size: hasSizeClass.value ? null : resolvedSize.value,\n checked: isActive.value,\n disabled: resolvedDisabled.value\n })\n )\n)\n\nwatch(\n () => props.checked,\n (checked) => {\n if (!groupContext) {\n internalChecked.value = !!checked\n }\n }\n)\n\nfunction syncNativeInputState() {\n if (!inputRef.value) return\n inputRef.value.checked = Boolean(isChecked.value)\n inputRef.value.indeterminate = isIndeterminate.value\n}\n\nonMounted(syncNativeInputState)\nwatch([isChecked, isIndeterminate], () => nextTick(syncNativeInputState))\n\nfunction syncInputChecked(event: Event) {\n const target = event.target as HTMLInputElement | null\n if (target) {\n target.checked = Boolean(isChecked.value)\n target.indeterminate = isIndeterminate.value\n }\n}\n\nfunction handleInput(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n emit('input', event)\n}\n\n/**\n * 同步原生 change 事件到 CheckboxGroup 和外部监听器。\n *\n * @param event 原生 change 事件,target 必须是复选框 input。\n * @returns 无返回值。\n */\nfunction handleChange(event: Event) {\n if (resolvedDisabled.value) {\n syncInputChecked(event)\n return\n }\n const checked = (event.target as HTMLInputElement).checked\n internalChecked.value = checked\n emit('change', checked, event)\n if (groupContext && props.value !== undefined) {\n groupContext.updateValue(props.value, checked, event)\n }\n void nextTick(syncNativeInputState)\n}\n</script>\n\n<template>\n <label :class=\"['inline-flex w-fit items-center align-middle', resolvedDisabled ? 'cursor-not-allowed text-tertiary opacity-70' : 'cursor-pointer text-secondary', $slots.default ? 'gap-2' : '']\" :style=\"getUiAttrStyle(attrs)\">\n <span :class=\"checkboxClass\">\n <input\n ref=\"inputRef\"\n v-bind=\"getUiExposeAttrs(attrs)\"\n data-map-ui-checkbox=\"true\"\n type=\"checkbox\"\n :name=\"resolvedName\"\n :value=\"value\"\n :checked=\"isChecked\"\n :aria-checked=\"ariaChecked\"\n :disabled=\"resolvedDisabled\"\n class=\"absolute inset-0 m-0 h-full w-full cursor-inherit opacity-0\"\n @change=\"handleChange\"\n @input=\"handleInput\"\n @focus=\"emit('focus', $event)\"\n @blur=\"emit('blur', $event)\"\n />\n <svg v-if=\"isIndeterminate\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M4 8H12\" stroke=\"white\" stroke-width=\"2.4\" stroke-linecap=\"round\" />\n </svg>\n <svg v-else-if=\"isChecked\" aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"h-[82%] w-[82%]\">\n <path d=\"M3.5 8.25L6.5 11L12.5 5\" stroke=\"white\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n </span>\n <span v-if=\"$slots.default\" class=\"select-none\">\n <slot></slot>\n </span>\n </label>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, provide, toRef, useAttrs } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkboxGroup, checkboxGroupContextKey, type CheckboxGroupDirection, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是组内当前选中值数组。 */\n modelValue?: CheckboxValue[]\n /** disabled 会禁用组内所有 Checkbox。 */\n disabled?: boolean\n /** size 统一设置组内 Checkbox 尺寸,可被子项显式 size 覆盖。 */\n size?: CheckboxSize\n /** name 统一设置组内原生 checkbox name。 */\n name?: string\n /** direction 控制组内排列方向。 */\n direction?: CheckboxGroupDirection\n }>(),\n {\n modelValue: () => [],\n disabled: false,\n size: 'md',\n name: undefined,\n direction: 'horizontal'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: CheckboxValue[]): void\n (e: 'change', value: CheckboxValue[], event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst groupClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkboxGroup({\n direction: props.direction,\n size: props.size,\n disabled: props.disabled\n })\n )\n)\n\nfunction updateValue(value: CheckboxValue, checked: boolean, event: Event) {\n const currentValue = props.modelValue ?? []\n const nextValue = checked\n ? currentValue.includes(value)\n ? currentValue\n : [...currentValue, value]\n : currentValue.filter((item) => item !== value)\n emit('update:modelValue', nextValue)\n emit('change', nextValue, event)\n}\n\nprovide(checkboxGroupContextKey, {\n modelValue: toRef(props, 'modelValue'),\n disabled: toRef(props, 'disabled'),\n size: toRef(props, 'size'),\n name: toRef(props, 'name'),\n updateValue\n})\n</script>\n\n<template>\n <div\n v-bind=\"getUiExposeAttrs(attrs)\"\n role=\"group\"\n data-ui-checkbox-group=\"true\"\n :data-direction=\"direction\"\n :aria-disabled=\"disabled || undefined\"\n :class=\"groupClass\"\n :style=\"getUiAttrStyle(attrs)\"\n >\n <slot></slot>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, provide, toRef, useAttrs } from 'vue'\n\nimport { getUiAttrClass, getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { checkboxGroup, checkboxGroupContextKey, type CheckboxGroupDirection, type CheckboxSize, type CheckboxValue } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是组内当前选中值数组。 */\n modelValue?: CheckboxValue[]\n /** disabled 会禁用组内所有 Checkbox。 */\n disabled?: boolean\n /** size 统一设置组内 Checkbox 尺寸,可被子项显式 size 覆盖。 */\n size?: CheckboxSize\n /** name 统一设置组内原生 checkbox name。 */\n name?: string\n /** direction 控制组内排列方向。 */\n direction?: CheckboxGroupDirection\n }>(),\n {\n modelValue: () => [],\n disabled: false,\n size: 'md',\n name: undefined,\n direction: 'horizontal'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: CheckboxValue[]): void\n (e: 'change', value: CheckboxValue[], event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst groupClass = computed(() =>\n clsx(\n getUiAttrClass(attrs),\n checkboxGroup({\n direction: props.direction,\n size: props.size,\n disabled: props.disabled\n })\n )\n)\n\nfunction updateValue(value: CheckboxValue, checked: boolean, event: Event) {\n const currentValue = props.modelValue ?? []\n const nextValue = checked\n ? currentValue.includes(value)\n ? currentValue\n : [...currentValue, value]\n : currentValue.filter((item) => item !== value)\n emit('update:modelValue', nextValue)\n emit('change', nextValue, event)\n}\n\nprovide(checkboxGroupContextKey, {\n modelValue: toRef(props, 'modelValue'),\n disabled: toRef(props, 'disabled'),\n size: toRef(props, 'size'),\n name: toRef(props, 'name'),\n updateValue\n})\n</script>\n\n<template>\n <div\n v-bind=\"getUiExposeAttrs(attrs)\"\n role=\"group\"\n data-ui-checkbox-group=\"true\"\n :data-direction=\"direction\"\n :aria-disabled=\"disabled || undefined\"\n :class=\"groupClass\"\n :style=\"getUiAttrStyle(attrs)\"\n >\n <slot></slot>\n </div>\n</template>\n","import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\nimport type { InjectionKey, Ref } from 'vue'\n\nexport { default as Checkbox } from './Checkbox.vue'\nexport { default as CheckboxGroup } from './CheckboxGroup.vue'\n\nexport type CheckboxValue = string | number\nexport type CheckboxSize = 'sm' | 'md' | 'lg'\nexport type CheckboxGroupDirection = 'horizontal' | 'vertical'\n\nexport interface CheckboxGroupContext {\n modelValue: Readonly<Ref<CheckboxValue[]>>\n disabled: Readonly<Ref<boolean>>\n size: Readonly<Ref<CheckboxSize>>\n name: Readonly<Ref<string | undefined>>\n updateValue: (value: CheckboxValue, checked: boolean, event: Event) => void\n}\n\nexport const checkboxGroupContextKey: InjectionKey<CheckboxGroupContext> = Symbol('ui-checkbox-group-context')\n\n/** checkbox 定义管理端 Checkbox 组件的样式变体组合。 */\nexport const checkbox = cva('relative inline-flex shrink-0 items-center justify-center overflow-hidden border align-middle transition-colors duration-150', {\n variants: {\n size: {\n sm: 'size-4 rounded-sm',\n md: 'size-5 rounded',\n lg: 'size-6 rounded'\n },\n checked: {\n true: '',\n false: ''\n },\n disabled: {\n true: 'cursor-not-allowed',\n false: 'cursor-pointer'\n }\n },\n compoundVariants: [\n {\n checked: true,\n disabled: false,\n class: 'border-brand-500 bg-brand-500 dark:border-brand-400 dark:bg-brand-500'\n },\n {\n checked: true,\n disabled: true,\n class: 'border-zinc-400 bg-zinc-400 dark:border-zinc-600 dark:bg-zinc-800'\n },\n {\n checked: false,\n disabled: false,\n class: 'border-control bg-primary hover:border-brand-400 dark:bg-zinc-950 dark:hover:border-brand-400'\n },\n {\n checked: false,\n disabled: true,\n class: 'border-zinc-300 bg-zinc-100 dark:border-zinc-600 dark:bg-zinc-800'\n }\n ],\n defaultVariants: {\n size: 'md',\n checked: false,\n disabled: false\n }\n})\n\n/** checkboxGroup 定义 CheckboxGroup 根节点布局。 */\nexport const checkboxGroup = cva('ui-checkbox-group inline-flex w-fit align-middle', {\n variants: {\n direction: {\n horizontal: 'flex-row flex-wrap items-center',\n vertical: 'flex-col items-start'\n },\n size: {\n sm: '',\n md: '',\n lg: ''\n },\n disabled: {\n true: '',\n false: ''\n }\n },\n compoundVariants: [\n { direction: 'horizontal', size: 'sm', class: 'gap-x-4 gap-y-2' },\n { direction: 'horizontal', size: 'md', class: 'gap-x-5 gap-y-2' },\n { direction: 'horizontal', size: 'lg', class: 'gap-x-6 gap-y-2.5' },\n { direction: 'vertical', size: 'sm', class: 'gap-1.5' },\n { direction: 'vertical', size: 'md', class: 'gap-2' },\n { direction: 'vertical', size: 'lg', class: 'gap-2.5' }\n ],\n defaultVariants: {\n direction: 'horizontal',\n size: 'md',\n disabled: false\n }\n})\n\n/** CheckboxProps 是 checkbox 变体推导出的组件属性类型。 */\nexport type CheckboxProps = VariantProps<typeof checkbox>\nexport type CheckboxGroupProps = VariantProps<typeof checkboxGroup>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA,IAAM,IAAQ,GAsBR,IAAO,GAOP,IAAQ,EAAS,GACjB,IAAe,EAAO,GAAyB,IAAI,GACnD,IAAW,EAA6B,IAAI,GAC5C,IAAkB,EAAI,CAAC,CAAC,EAAM,OAAO,GACrC,IAAe,QAAe,0BAA0B,KAAK,EAAe,CAAK,CAAC,CAAC,GACnF,IAAmB,QAAe,EAAM,YAAY,CAAC,CAAC,GAAc,SAAS,KAAK,GAClF,IAAe,QAAe,EAAM,QAAQ,GAAc,KAAK,SAAS,IAAI,GAC5E,IAAe,QAAe,EAAM,QAAQ,GAAc,KAAK,KAAK,GACpE,IAAY,QAAgB,KAAgB,EAAM,UAAU,KAAA,IAAY,EAAa,WAAW,MAAM,SAAS,EAAM,KAAK,IAAI,EAAgB,KAAM,GACpJ,IAAkB,QAAe,EAAM,aAAa,GACpD,IAAW,QAAe,EAAU,SAAS,EAAgB,KAAK,GAClE,IAAc,QAAgB,EAAgB,QAAQ,UAAU,EAAQ,EAAU,KAAO,GACzF,IAAgB,QACpB,EACE,EAAe,CAAK,GACpB,EAAS;GACP,MAAM,EAAa,QAAQ,OAAO,EAAa;GAC/C,SAAS,EAAS;GAClB,UAAU,EAAiB;EAC7B,CAAC,C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