x-next 1.5.0 → 1.7.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/AI_USAGE.md +57 -4
- package/CHANGELOG.md +72 -0
- package/dist/_utils/color.d.ts +53 -0
- package/dist/components/color-picker/ColorPicker.d.ts +239 -0
- package/dist/components/color-picker/gradient-slider.d.ts +52 -0
- package/dist/components/color-picker/index.d.ts +238 -0
- package/dist/components/color-picker/panel.d.ts +721 -0
- package/dist/components/color-picker/sv-panel.d.ts +48 -0
- package/dist/components/date-picker/DatePicker.vue.d.ts +3 -3
- package/dist/components/date-picker/index.d.ts +6 -6
- package/dist/components/draggable/Draggable.d.ts +1 -1
- package/dist/components/draggable/index.d.ts +2 -2
- package/dist/components/drawer/index.d.ts +6 -6
- package/dist/components/drawer/src/Drawer.vue.d.ts +3 -3
- package/dist/components/dropdown/Dropdown.vue.d.ts +34 -4
- package/dist/components/dropdown/DropdownButton.vue.d.ts +35 -5
- package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +34 -4
- package/dist/components/dropdown/dropdown-panel.vue.d.ts +30 -0
- package/dist/components/dropdown/index.d.ts +209 -29
- package/dist/components/form/FormItem.vue.d.ts +12 -12
- package/dist/components/form/form-item-label.vue.d.ts +3 -3
- package/dist/components/form/index.d.ts +24 -24
- package/dist/components/form-select/Select.d.ts +3 -3
- package/dist/components/form-select/SelectDropdown.vue.d.ts +30 -0
- package/dist/components/form-select/index.d.ts +66 -6
- package/dist/components/form-slider/Slider.vue.d.ts +3 -3
- package/dist/components/form-slider/index.d.ts +6 -6
- package/dist/components/form-slider/slider-button.vue.d.ts +3 -3
- package/dist/components/grid/Row.vue.d.ts +3 -3
- package/dist/components/grid/index.d.ts +9 -9
- package/dist/components/heatmap/Heatmap.d.ts +311 -0
- package/dist/components/heatmap/helpers/matrix.d.ts +58 -0
- package/dist/components/heatmap/index.d.ts +372 -0
- package/dist/components/heatmap/interface.d.ts +57 -0
- package/dist/components/image/Image.vue.d.ts +125 -17
- package/dist/components/image/ImagePreview.vue.d.ts +97 -7
- package/dist/components/image/ImagePreviewAction.d.ts +3 -3
- package/dist/components/image/ImagePreviewGroup.vue.d.ts +100 -7
- package/dist/components/image/hooks/use-image-drag.d.ts +2 -2
- package/dist/components/image/index.d.ts +712 -124
- package/dist/components/image/interface.d.ts +9 -1
- package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
- package/dist/components/index.d.ts +3 -0
- package/dist/components/menu/sub-menu-pop.vue.d.ts +3 -3
- package/dist/components/network/Network.vue.d.ts +1 -1
- package/dist/components/network/index.d.ts +3 -3
- package/dist/components/network/utils.d.ts +2 -0
- package/dist/components/pagination/page-item-ellipsis.vue.d.ts +9 -0
- package/dist/components/pagination/page-jumper.vue.d.ts +6 -0
- package/dist/components/pagination/page-options.vue.d.ts +6 -6
- package/dist/components/popconfirm/src/popup.vue.d.ts +3 -3
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -3
- package/dist/components/popup/Popup.d.ts +1 -1
- package/dist/components/popup/index.d.ts +3 -3
- package/dist/components/skeleton/SkeletonShape.vue.d.ts +3 -3
- package/dist/components/skeleton/index.d.ts +6 -6
- package/dist/components/space/Space.d.ts +1 -1
- package/dist/components/space/index.d.ts +3 -3
- package/dist/components/spin/Spin.d.ts +38 -0
- package/dist/components/spin/index.d.ts +30 -0
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/tabs/Tabs.d.ts +1 -1
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/time-picker/TimePicker.vue.d.ts +3 -3
- package/dist/components/time-picker/index.d.ts +6 -6
- package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/components/trigger/Trigger.d.ts +1 -1
- package/dist/components/trigger/index.d.ts +3 -3
- package/dist/components/upload/Upload.d.ts +372 -0
- package/dist/components/upload/context.d.ts +28 -0
- package/dist/components/upload/index.d.ts +656 -0
- package/dist/components/upload/interface.d.ts +110 -0
- package/dist/components/upload/props.d.ts +321 -0
- package/dist/components/upload/upload-list-item.d.ts +15 -0
- package/dist/components/upload/upload-list.d.ts +11 -0
- package/dist/components/upload/upload-picture-item.d.ts +20 -0
- package/dist/components/upload/upload-trigger.d.ts +8 -0
- package/dist/components/upload/utils.d.ts +48 -0
- package/dist/components/watermark/Watermark.d.ts +1 -1
- package/dist/components/watermark/index.d.ts +3 -3
- package/dist/es/_styles/palette-aliases.js +10 -4
- package/dist/es/_utils/color.js +73 -0
- package/dist/es/components/button/Button.js +2 -2
- package/dist/es/components/color-picker/ColorPicker.js +239 -0
- package/dist/es/components/color-picker/gradient-slider.js +79 -0
- package/dist/es/components/color-picker/index.js +8 -0
- package/dist/es/components/color-picker/panel.js +307 -0
- package/dist/es/components/color-picker/sv-panel.js +99 -0
- package/dist/es/components/dropdown/dropdown-panel.vue.js +17 -17
- package/dist/es/components/form-input/Input.js +7 -7
- package/dist/es/components/form-input/InputPassword.vue2.js +2 -2
- package/dist/es/components/form-input/InputSearch.js +2 -2
- package/dist/es/components/form-input-number/InputNumber.js +12 -12
- package/dist/es/components/heatmap/Heatmap.js +334 -0
- package/dist/es/components/heatmap/helpers/matrix.js +106 -0
- package/dist/es/components/heatmap/index.js +8 -0
- package/dist/es/components/image/Image.vue.js +55 -45
- package/dist/es/components/image/Image.vue2.js +113 -92
- package/dist/es/components/image/ImagePreview.vue.js +66 -53
- package/dist/es/components/image/ImagePreview.vue2.js +219 -171
- package/dist/es/components/image/ImagePreviewAction.js +12 -15
- package/dist/es/components/image/ImagePreviewGroup.vue.js +21 -20
- package/dist/es/components/image/ImagePreviewGroup.vue2.js +45 -39
- package/dist/es/components/image/hooks/use-image-drag.js +16 -14
- package/dist/es/components/index.js +123 -117
- package/dist/es/components/menu/sub-menu-pop.vue2.js +12 -12
- package/dist/es/components/network/Network.vue2.js +72 -72
- package/dist/es/components/network/utils.js +44 -35
- package/dist/es/components/pagination/Pagination.js +113 -104
- package/dist/es/components/pagination/page-item-ellipsis.vue.js +13 -12
- package/dist/es/components/pagination/page-item-ellipsis.vue2.js +19 -15
- package/dist/es/components/pagination/page-jumper.vue.js +13 -12
- package/dist/es/components/pagination/page-jumper.vue2.js +7 -4
- package/dist/es/components/pagination/page-options.vue.js +4 -3
- package/dist/es/components/pagination/page-options.vue2.js +17 -15
- package/dist/es/components/skeleton/Skeleton.vue.js +11 -9
- package/dist/es/components/skeleton/SkeletonLine.vue.js +9 -8
- package/dist/es/components/skeleton/SkeletonShape.vue.js +8 -7
- package/dist/es/components/spin/Spin.js +124 -60
- package/dist/es/components/table/Table.js +3 -1
- package/dist/es/components/trigger/Trigger.js +19 -19
- package/dist/es/components/upload/Upload.js +420 -0
- package/dist/es/components/upload/context.js +4 -0
- package/dist/es/components/upload/index.js +8 -0
- package/dist/es/components/upload/props.js +321 -0
- package/dist/es/components/upload/upload-list-item.js +138 -0
- package/dist/es/components/upload/upload-list.js +48 -0
- package/dist/es/components/upload/upload-picture-item.js +109 -0
- package/dist/es/components/upload/upload-trigger.js +89 -0
- package/dist/es/components/upload/utils.js +195 -0
- package/dist/es/icons/_self/empty-better.js +25 -8
- package/dist/es/icons/_self/upload-icons.js +103 -0
- package/dist/es/index.js +168 -162
- package/dist/es/locale/en-US.js +39 -1
- package/dist/es/locale/zh-CN.js +39 -1
- package/dist/es/style.css +1 -1
- package/dist/icons/_self/upload-icons.d.ts +523 -0
- package/dist/index.cjs +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/locale/interface.d.ts +60 -0
- package/dist/style/base.css +1 -1
- package/dist/style/button.css +1 -1
- package/dist/style/color-picker.css +1 -0
- package/dist/style/color-picker.js +2 -0
- package/dist/style/date-picker.css +1 -1
- package/dist/style/empty.css +1 -1
- package/dist/style/form-checkbox.css +1 -1
- package/dist/style/form-input-tag.css +1 -1
- package/dist/style/form-input.css +1 -1
- package/dist/style/form-radio.css +1 -1
- package/dist/style/form-textarea.css +1 -1
- package/dist/style/form.css +1 -1
- package/dist/style/heatmap.css +1 -0
- package/dist/style/heatmap.js +2 -0
- package/dist/style/image.css +1 -1
- package/dist/style/menu.css +1 -1
- package/dist/style/pagination.css +1 -1
- package/dist/style/skeleton.css +1 -1
- package/dist/style/spin.css +1 -1
- package/dist/style/steps.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style/upload.css +1 -0
- package/dist/style/upload.js +2 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
- package/volar.d.ts +3 -0
- package/dist/es/_hooks/use-popup-overflow-hidden.js +0 -29
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { hslToRgb as N } from "./palette.js";
|
|
2
|
+
import { rgbToHsl as w } from "./palette.js";
|
|
3
|
+
const c = (n, t, r) => Math.min(r, Math.max(t, n)), T = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, F = /^(rgba?|hsla?)\(([^)]+)\)$/i, b = /^[+-]?(?:\d+\.?\d*|\.\d+)%?$/, u = (n) => c(Math.round(n), 0, 255), v = (n) => {
|
|
4
|
+
if (n === void 0) return 1;
|
|
5
|
+
const t = n.trim();
|
|
6
|
+
if (!t) return 1;
|
|
7
|
+
if (t.endsWith("%")) return c(parseFloat(t) / 100, 0, 1);
|
|
8
|
+
const r = Number(t);
|
|
9
|
+
return Number.isFinite(r) ? c(r, 0, 1) : 1;
|
|
10
|
+
}, A = (n) => {
|
|
11
|
+
const t = n.trim();
|
|
12
|
+
return t.endsWith("%") ? u(parseFloat(t) / 100 * 255) : u(Number(t));
|
|
13
|
+
}, C = (n) => {
|
|
14
|
+
if (!T.test(n)) return null;
|
|
15
|
+
const t = n.slice(1), r = t.length <= 4 ? [...t].map((i) => i + i).join("") : t, a = parseInt(r.slice(0, 2), 16), s = parseInt(r.slice(2, 4), 16), e = parseInt(r.slice(4, 6), 16), o = r.length === 8 ? parseInt(r.slice(6, 8), 16) / 255 : 1;
|
|
16
|
+
return [a, s, e, o].some((i) => !Number.isFinite(i)) ? null : { r: a, g: s, b: e, a: c(o, 0, 1) };
|
|
17
|
+
}, M = (n) => {
|
|
18
|
+
const t = n.trim();
|
|
19
|
+
if (!t) return null;
|
|
20
|
+
if (t.includes(",")) {
|
|
21
|
+
const e = t.split(",").map((o) => o.trim());
|
|
22
|
+
return e.length !== 3 && e.length !== 4 ? null : { channels: e.slice(0, 3), alpha: e[3] };
|
|
23
|
+
}
|
|
24
|
+
if (t.split("/").length > 2) return null;
|
|
25
|
+
const [r, a] = t.split("/"), s = r.trim().split(/\s+/);
|
|
26
|
+
return s.length !== 3 ? null : { channels: s, alpha: a };
|
|
27
|
+
}, H = (n) => {
|
|
28
|
+
if (typeof n != "string") return null;
|
|
29
|
+
const t = n.trim();
|
|
30
|
+
if (!t) return null;
|
|
31
|
+
if (t.startsWith("#")) return C(t);
|
|
32
|
+
const r = t.match(F);
|
|
33
|
+
if (!r) return null;
|
|
34
|
+
const a = r[1].toLowerCase(), s = M(r[2]);
|
|
35
|
+
if (!s || s.channels.some((f) => !b.test(f)) || s.alpha !== void 0 && s.alpha !== "" && !b.test(s.alpha.trim()))
|
|
36
|
+
return null;
|
|
37
|
+
const e = v(s.alpha), o = s.channels.map((f) => parseFloat(f));
|
|
38
|
+
if (o.some((f) => !Number.isFinite(f))) return null;
|
|
39
|
+
if (a.startsWith("rgb")) {
|
|
40
|
+
const [f, $, x] = s.channels.map(A);
|
|
41
|
+
return { r: f, g: $, b: x, a: e };
|
|
42
|
+
}
|
|
43
|
+
const [i, h, l] = o, [m, g, d] = N({ h: i, s: c(h, 0, 100), l: c(l, 0, 100) });
|
|
44
|
+
return { r: u(m), g: u(g), b: u(d), a: e };
|
|
45
|
+
}, I = ({ r: n, g: t, b: r }) => {
|
|
46
|
+
const a = c(n, 0, 255) / 255, s = c(t, 0, 255) / 255, e = c(r, 0, 255) / 255, o = Math.max(a, s, e), i = Math.min(a, s, e), h = o - i;
|
|
47
|
+
let l = 0;
|
|
48
|
+
h !== 0 && (o === a ? l = (s - e) / h % 6 : o === s ? l = (e - a) / h + 2 : l = (a - s) / h + 4, l *= 60, l < 0 && (l += 360));
|
|
49
|
+
const m = o === 0 ? 0 : h / o * 100;
|
|
50
|
+
return { h: l, s: m, v: o * 100 };
|
|
51
|
+
}, E = ({ h: n, s: t, v: r }) => {
|
|
52
|
+
const a = c(t, 0, 100) / 100, s = c(r, 0, 100) / 100, e = (n % 360 + 360) % 360, o = s * a, i = o * (1 - Math.abs(e / 60 % 2 - 1)), h = s - o;
|
|
53
|
+
let l;
|
|
54
|
+
return e < 60 ? l = [o, i, 0] : e < 120 ? l = [i, o, 0] : e < 180 ? l = [0, o, i] : e < 240 ? l = [0, i, o] : e < 300 ? l = [i, 0, o] : l = [o, 0, i], l.map((m) => u((m + h) * 255));
|
|
55
|
+
}, p = (n) => u(n).toString(16).padStart(2, "0"), P = ({ r: n, g: t, b: r, a }, s = !1) => {
|
|
56
|
+
const e = `#${p(n)}${p(t)}${p(r)}`;
|
|
57
|
+
return s && a < 1 ? `${e}${p(a * 255)}` : e;
|
|
58
|
+
}, S = (n) => Math.round(c(n, 0, 1) * 100), W = (n, t, r = !1) => {
|
|
59
|
+
const { r: a, g: s, b: e, a: o } = n;
|
|
60
|
+
return P(n, r);
|
|
61
|
+
}, _ = ({ r: n, g: t, b: r, a }) => `rgba(${u(n)}, ${u(t)}, ${u(r)}, ${Number(c(a, 0, 1).toFixed(3))})`, L = ({ r: n, g: t, b: r }) => `rgba(${u(n)}, ${u(t)}, ${u(r)}, 1)`;
|
|
62
|
+
export {
|
|
63
|
+
S as formatAlphaPercent,
|
|
64
|
+
W as formatColor,
|
|
65
|
+
N as hslToRgb,
|
|
66
|
+
E as hsvToRgb,
|
|
67
|
+
H as parseColorAlpha,
|
|
68
|
+
w as rgbToHsl,
|
|
69
|
+
I as rgbToHsv,
|
|
70
|
+
P as rgbaToHex,
|
|
71
|
+
L as toAlphaSliderColor,
|
|
72
|
+
_ as toRgbaString
|
|
73
|
+
};
|
|
@@ -5,7 +5,7 @@ import B from "../../icons/animation/animation-loading.js";
|
|
|
5
5
|
import I from "../../directives/wave.js";
|
|
6
6
|
import { buttonGroupInjectionKey as K } from "./context.js";
|
|
7
7
|
import { useSize as N } from "../../_hooks/use-size.js";
|
|
8
|
-
const
|
|
8
|
+
const H = /* @__PURE__ */ O({
|
|
9
9
|
name: "Button",
|
|
10
10
|
props: A,
|
|
11
11
|
// 显式导入插槽
|
|
@@ -69,5 +69,5 @@ const q = /* @__PURE__ */ O({
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
H as default
|
|
73
73
|
};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { defineComponent as L, toRefs as k, ref as C, computed as c, watch as A, createVNode as n } from "vue";
|
|
2
|
+
import { getClassNameMixin as R } from "../../_utils/config.js";
|
|
3
|
+
import { useFormItem as j } from "../../_hooks/use-form-item.js";
|
|
4
|
+
import { useSize as D } from "../../_hooks/use-size.js";
|
|
5
|
+
import { useLocale as G } from "../../locale/index.js";
|
|
6
|
+
import { parseColorAlpha as H, formatColor as v } from "../../_utils/color.js";
|
|
7
|
+
import I from "../trigger/Trigger.js";
|
|
8
|
+
import K from "./panel.js";
|
|
9
|
+
const Y = /* @__PURE__ */ L({
|
|
10
|
+
name: "ColorPicker",
|
|
11
|
+
props: {
|
|
12
|
+
/**
|
|
13
|
+
* @zh 颜色值,支持 hex / rgb / hsl(含 alpha)
|
|
14
|
+
* @en Color value, supports hex / rgb / hsl with alpha
|
|
15
|
+
* @vModel
|
|
16
|
+
*/
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: void 0
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* @zh 非受控初值
|
|
23
|
+
* @en Default value for uncontrolled mode
|
|
24
|
+
*/
|
|
25
|
+
defaultValue: {
|
|
26
|
+
type: String,
|
|
27
|
+
/*
|
|
28
|
+
* 不设字符串默认值:未传值时由下方 rgba 的数值兜底给出品牌蓝,
|
|
29
|
+
* 避免在组件里硬编码色值(硬编码色门禁不允许,且换主色时会失配)。
|
|
30
|
+
*/
|
|
31
|
+
default: void 0
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* @zh 面板是否可见
|
|
35
|
+
* @en Whether the panel is visible
|
|
36
|
+
* @vModel
|
|
37
|
+
*/
|
|
38
|
+
show: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* @zh 面板默认是否可见
|
|
44
|
+
* @en Whether the panel is visible by default
|
|
45
|
+
*/
|
|
46
|
+
defaultShow: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: !1
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* @zh 可选的颜色格式
|
|
52
|
+
* @en Available color formats
|
|
53
|
+
* @defaultValue ['hex', 'rgb', 'hsl']
|
|
54
|
+
*/
|
|
55
|
+
modes: {
|
|
56
|
+
type: Array,
|
|
57
|
+
default: () => ["hex", "rgb", "hsl"]
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* @zh 是否启用透明度
|
|
61
|
+
* @en Whether alpha is enabled
|
|
62
|
+
* @defaultValue true
|
|
63
|
+
*/
|
|
64
|
+
showAlpha: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: !0
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* @zh 预设色块
|
|
70
|
+
* @en Preset swatches
|
|
71
|
+
*/
|
|
72
|
+
swatches: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: () => []
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* @zh 是否展示确认按钮
|
|
78
|
+
* @en Whether to show the confirm button
|
|
79
|
+
* @defaultValue true
|
|
80
|
+
*/
|
|
81
|
+
showConfirm: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: !0
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* @zh 是否展示清除按钮
|
|
87
|
+
* @en Whether to show the clear button
|
|
88
|
+
* @defaultValue true
|
|
89
|
+
*/
|
|
90
|
+
showClear: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: !0
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* @zh 是否禁用
|
|
96
|
+
* @en Whether the picker is disabled
|
|
97
|
+
*/
|
|
98
|
+
disabled: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: !1
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* @zh 尺寸
|
|
104
|
+
* @en Size
|
|
105
|
+
* @values 'mini', 'small', 'medium', 'large'
|
|
106
|
+
*/
|
|
107
|
+
size: {
|
|
108
|
+
type: String
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* @zh 面板挂载容器
|
|
112
|
+
* @en Mount container for the panel
|
|
113
|
+
*/
|
|
114
|
+
popupContainer: {
|
|
115
|
+
type: [String, Object]
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
emits: {
|
|
119
|
+
"update:modelValue": (a, d) => !0,
|
|
120
|
+
change: (a, d) => !0,
|
|
121
|
+
"update:show": (a) => !0,
|
|
122
|
+
showChange: (a) => !0,
|
|
123
|
+
confirm: (a) => !0,
|
|
124
|
+
clear: () => !0
|
|
125
|
+
},
|
|
126
|
+
slots: Object,
|
|
127
|
+
setup(a, {
|
|
128
|
+
attrs: d,
|
|
129
|
+
emit: t,
|
|
130
|
+
slots: s
|
|
131
|
+
}) {
|
|
132
|
+
const f = R("color-picker"), {
|
|
133
|
+
t: u
|
|
134
|
+
} = G(), {
|
|
135
|
+
mergedDisabled: g,
|
|
136
|
+
mergedSize: x,
|
|
137
|
+
eventHandlers: B
|
|
138
|
+
} = j({
|
|
139
|
+
disabled: k(a).disabled,
|
|
140
|
+
size: k(a).size
|
|
141
|
+
});
|
|
142
|
+
D(x);
|
|
143
|
+
const h = C(a.defaultShow), i = c(() => a.show ?? h.value), m = (e) => {
|
|
144
|
+
e !== i.value && (h.value = e, t("update:show", e), t("showChange", e));
|
|
145
|
+
};
|
|
146
|
+
A(() => a.show, (e) => {
|
|
147
|
+
e !== void 0 && e !== h.value && (h.value = e);
|
|
148
|
+
});
|
|
149
|
+
const p = C(a.defaultValue), w = c(() => a.modelValue ?? p.value ?? ""), S = {
|
|
150
|
+
r: 28,
|
|
151
|
+
g: 97,
|
|
152
|
+
b: 255,
|
|
153
|
+
a: 1
|
|
154
|
+
}, b = c(() => H(w.value ?? "") ?? S), y = c(() => v(b.value, "hex", a.showAlpha)), _ = (e, l) => {
|
|
155
|
+
var r, P;
|
|
156
|
+
const o = v(e, "hex", a.showAlpha);
|
|
157
|
+
o !== w.value && (p.value = o, t("update:modelValue", o, l), t("change", o, l), (P = (r = B.value) == null ? void 0 : r.onChange) == null || P.call(r, l));
|
|
158
|
+
}, z = c(() => ({
|
|
159
|
+
clear: u("colorPicker.clear"),
|
|
160
|
+
confirm: u("colorPicker.confirm"),
|
|
161
|
+
hue: u("colorPicker.hue"),
|
|
162
|
+
alpha: u("colorPicker.alpha"),
|
|
163
|
+
saturation: u("colorPicker.saturation")
|
|
164
|
+
})), T = (e, l) => {
|
|
165
|
+
_(e, l);
|
|
166
|
+
}, F = (e) => {
|
|
167
|
+
const l = v(e, "hex", a.showAlpha);
|
|
168
|
+
p.value = l, t("update:modelValue", l), t("change", l), t("confirm", l), m(!1);
|
|
169
|
+
}, N = () => {
|
|
170
|
+
const e = a.defaultValue;
|
|
171
|
+
p.value = e, t("update:modelValue", e ?? ""), t("change", e ?? ""), t("clear");
|
|
172
|
+
}, V = C();
|
|
173
|
+
A(i, (e, l) => {
|
|
174
|
+
var o, r;
|
|
175
|
+
l && !e && ((r = (o = V.value) == null ? void 0 : o.focus) == null || r.call(o));
|
|
176
|
+
});
|
|
177
|
+
const O = () => {
|
|
178
|
+
var o;
|
|
179
|
+
if (s.trigger)
|
|
180
|
+
return s.trigger({
|
|
181
|
+
value: y.value,
|
|
182
|
+
visible: i.value
|
|
183
|
+
});
|
|
184
|
+
const e = (o = s.default) == null ? void 0 : o.call(s), l = n("button", {
|
|
185
|
+
ref: V,
|
|
186
|
+
type: "button",
|
|
187
|
+
class: f.element("trigger"),
|
|
188
|
+
disabled: g.value,
|
|
189
|
+
"aria-haspopup": "dialog",
|
|
190
|
+
"aria-expanded": i.value ? "true" : "false",
|
|
191
|
+
"aria-label": u("colorPicker.trigger")
|
|
192
|
+
}, [n("span", {
|
|
193
|
+
class: f.element("trigger-color"),
|
|
194
|
+
style: {
|
|
195
|
+
backgroundColor: y.value
|
|
196
|
+
}
|
|
197
|
+
}, null)]);
|
|
198
|
+
return e ? n("span", {
|
|
199
|
+
class: [f.element("trigger-wrapper"), d.class]
|
|
200
|
+
}, [l, n("span", {
|
|
201
|
+
class: f.element("trigger-label")
|
|
202
|
+
}, [e])]) : n("span", {
|
|
203
|
+
class: d.class
|
|
204
|
+
}, [l]);
|
|
205
|
+
};
|
|
206
|
+
return () => n(I, {
|
|
207
|
+
trigger: "click",
|
|
208
|
+
position: "bl",
|
|
209
|
+
popupOffset: 4,
|
|
210
|
+
clickToClose: !1,
|
|
211
|
+
preventFocus: !0,
|
|
212
|
+
autoFitTransformOrigin: !0,
|
|
213
|
+
animationName: "x-zoom-in-fade-out",
|
|
214
|
+
disabled: g.value,
|
|
215
|
+
popupVisible: i.value,
|
|
216
|
+
popupContainer: a.popupContainer,
|
|
217
|
+
onPopupVisibleChange: m
|
|
218
|
+
}, {
|
|
219
|
+
default: O,
|
|
220
|
+
content: () => n(K, {
|
|
221
|
+
value: b.value,
|
|
222
|
+
modes: a.modes,
|
|
223
|
+
showAlpha: a.showAlpha,
|
|
224
|
+
swatches: a.swatches,
|
|
225
|
+
disabled: g.value,
|
|
226
|
+
showConfirm: a.showConfirm,
|
|
227
|
+
showClear: a.showClear,
|
|
228
|
+
texts: z.value,
|
|
229
|
+
onChange: T,
|
|
230
|
+
onConfirm: F,
|
|
231
|
+
onClear: N,
|
|
232
|
+
onClose: () => m(!1)
|
|
233
|
+
}, null)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
export {
|
|
238
|
+
Y as default
|
|
239
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { defineComponent as b, ref as m, computed as y, watch as w, createVNode as o } from "vue";
|
|
2
|
+
import { getClassNameMixin as k } from "../../_utils/config.js";
|
|
3
|
+
const D = /* @__PURE__ */ b({
|
|
4
|
+
name: "ColorPickerSlider",
|
|
5
|
+
props: {
|
|
6
|
+
/** 0-100 的位置百分比 */
|
|
7
|
+
value: {
|
|
8
|
+
type: Number,
|
|
9
|
+
required: !0
|
|
10
|
+
},
|
|
11
|
+
/** 滑轨背景(CSS background 值) */
|
|
12
|
+
background: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: !0
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !1
|
|
19
|
+
},
|
|
20
|
+
/** 无障碍名称,由父组件传入已本地化的文案 */
|
|
21
|
+
ariaLabel: {
|
|
22
|
+
type: String
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: {
|
|
26
|
+
change: (t) => !0
|
|
27
|
+
},
|
|
28
|
+
setup(t, {
|
|
29
|
+
emit: l
|
|
30
|
+
}) {
|
|
31
|
+
const n = k("color-picker"), u = m(), i = m(!1), f = y(() => ({
|
|
32
|
+
left: `${t.value}%`
|
|
33
|
+
})), s = (e) => {
|
|
34
|
+
const a = u.value;
|
|
35
|
+
if (!a || t.disabled) return;
|
|
36
|
+
const r = a.getBoundingClientRect();
|
|
37
|
+
if (!r.width) return;
|
|
38
|
+
const h = Math.min(Math.max(e - r.left, 0), r.width);
|
|
39
|
+
l("change", h / r.width * 100);
|
|
40
|
+
}, c = (e) => {
|
|
41
|
+
s(e.clientX);
|
|
42
|
+
}, d = () => {
|
|
43
|
+
i.value = !1, document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", d);
|
|
44
|
+
}, v = (e) => {
|
|
45
|
+
t.disabled || (e.preventDefault(), i.value = !0, s(e.clientX), document.addEventListener("mousemove", c), document.addEventListener("mouseup", d));
|
|
46
|
+
}, g = (e) => {
|
|
47
|
+
if (t.disabled) return;
|
|
48
|
+
const a = e.shiftKey ? 10 : 1;
|
|
49
|
+
e.key === "ArrowLeft" || e.key === "ArrowDown" ? (e.preventDefault(), l("change", Math.max(t.value - a, 0))) : (e.key === "ArrowRight" || e.key === "ArrowUp") && (e.preventDefault(), l("change", Math.min(t.value + a, 100)));
|
|
50
|
+
};
|
|
51
|
+
return w(() => t.disabled, (e) => {
|
|
52
|
+
e && d();
|
|
53
|
+
}), () => o("div", {
|
|
54
|
+
class: [n.element("slider"), {
|
|
55
|
+
[n.is("dragging")]: i.value
|
|
56
|
+
}],
|
|
57
|
+
role: "slider",
|
|
58
|
+
"aria-label": t.ariaLabel,
|
|
59
|
+
"aria-valuemin": 0,
|
|
60
|
+
"aria-valuemax": 100,
|
|
61
|
+
"aria-valuenow": Math.round(t.value),
|
|
62
|
+
tabindex: t.disabled ? -1 : 0,
|
|
63
|
+
onMousedown: v,
|
|
64
|
+
onKeydown: g
|
|
65
|
+
}, [o("div", {
|
|
66
|
+
ref: u,
|
|
67
|
+
class: n.element("slider-track"),
|
|
68
|
+
style: {
|
|
69
|
+
background: t.background
|
|
70
|
+
}
|
|
71
|
+
}, [o("div", {
|
|
72
|
+
class: n.element("slider-handler"),
|
|
73
|
+
style: f.value
|
|
74
|
+
}, null)])]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
export {
|
|
78
|
+
D as default
|
|
79
|
+
};
|