x-next 1.10.1 → 1.11.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_CODING.md +97 -0
- package/AI_USAGE/catalog.md +111 -0
- package/AI_USAGE/components/alert.md +33 -0
- package/AI_USAGE/components/bar-chart.md +46 -0
- package/AI_USAGE/components/button.md +35 -0
- package/AI_USAGE/components/checkbox.md +34 -0
- package/AI_USAGE/components/color-picker.md +36 -0
- package/AI_USAGE/components/config-provider.md +58 -0
- package/AI_USAGE/components/date-picker.md +34 -0
- package/AI_USAGE/components/dialog.md +37 -0
- package/AI_USAGE/components/dropdown.md +38 -0
- package/AI_USAGE/components/empty.md +30 -0
- package/AI_USAGE/components/input.md +32 -0
- package/AI_USAGE/components/line-chart.md +45 -0
- package/AI_USAGE/components/message-box.md +39 -0
- package/AI_USAGE/components/message.md +36 -0
- package/AI_USAGE/components/notification.md +37 -0
- package/AI_USAGE/components/pagination.md +32 -0
- package/AI_USAGE/components/pie-chart.md +55 -0
- package/AI_USAGE/components/popconfirm.md +33 -0
- package/AI_USAGE/components/popover.md +35 -0
- package/AI_USAGE/components/progress.md +32 -0
- package/AI_USAGE/components/radio.md +35 -0
- package/AI_USAGE/components/rate.md +30 -0
- package/AI_USAGE/components/select.md +38 -0
- package/AI_USAGE/components/slider.md +34 -0
- package/AI_USAGE/components/steps.md +33 -0
- package/AI_USAGE/components/switch.md +32 -0
- package/AI_USAGE/components/tabs.md +33 -0
- package/AI_USAGE/components/textarea.md +31 -0
- package/AI_USAGE/components/time-picker.md +34 -0
- package/AI_USAGE/components/upload.md +60 -0
- package/AI_USAGE/core.md +37 -0
- package/AI_USAGE/index.md +52 -0
- package/AI_USAGE/recipes/form-on-demand.md +42 -0
- package/AI_USAGE.md +171 -46
- package/CHANGELOG.md +23 -0
- package/README.md +15 -2
- package/dist/_container/resize-trigger.vue.d.ts +1 -1
- package/dist/_hooks/use-dialog-focus.d.ts +7 -0
- package/dist/_hooks/use-pointer-drag.d.ts +6 -0
- package/dist/_hooks/use-popup-close.d.ts +11 -0
- package/dist/_hooks/use-popup-theme.d.ts +5 -0
- package/dist/_utils/palette.d.ts +2 -0
- package/dist/components/_components/picker/input-range.vue.d.ts +1 -3
- package/dist/components/_components/picker/input.vue.d.ts +1 -3
- package/dist/components/alert/Alert.vue.d.ts +1 -1
- package/dist/components/alert/index.d.ts +3 -3
- package/dist/components/bar-chart/BarChart.d.ts +3 -3
- package/dist/components/bar-chart/index.d.ts +9 -9
- package/dist/components/color-picker/ColorPicker.d.ts +2 -1
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/panel.d.ts +6 -0
- package/dist/components/config-provider/context.d.ts +7 -1
- package/dist/components/date-picker/DatePicker.vue.d.ts +9 -12
- package/dist/components/date-picker/index.d.ts +19 -27
- package/dist/components/drawer/index.d.ts +51 -9
- package/dist/components/drawer/src/Drawer.vue.d.ts +19 -4
- package/dist/components/dropdown/Dropdown.vue.d.ts +6 -3
- package/dist/components/dropdown/DropdownButton.vue.d.ts +6 -3
- package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +6 -3
- package/dist/components/dropdown/dropdown-panel.vue.d.ts +6 -3
- package/dist/components/dropdown/index.d.ts +36 -18
- package/dist/components/form-select/SelectDropdown.vue.d.ts +6 -3
- package/dist/components/form-select/SelectOption.vue.d.ts +1 -0
- package/dist/components/form-select/index.d.ts +15 -6
- package/dist/components/form-slider/Slider.vue.d.ts +1 -1
- package/dist/components/form-slider/index.d.ts +3 -3
- package/dist/components/form-textarea/Textarea.vue.d.ts +2 -4
- package/dist/components/form-textarea/index.d.ts +6 -12
- package/dist/components/image/Image.vue.d.ts +2 -4
- package/dist/components/image/index.d.ts +6 -12
- package/dist/components/layout/LayoutSidebar.vue.d.ts +5 -5
- package/dist/components/layout/index.d.ts +10 -10
- package/dist/components/line-chart/LineChart.d.ts +3 -3
- package/dist/components/line-chart/index.d.ts +9 -9
- package/dist/components/menu/Menu.d.ts +6 -3
- package/dist/components/menu/base-menu.vue.d.ts +6 -3
- package/dist/components/menu/index.d.ts +12 -6
- package/dist/components/menu/sub-menu-pop.vue.d.ts +6 -3
- package/dist/components/network/Network.vue.d.ts +1 -1
- package/dist/components/network/index.d.ts +3 -3
- package/dist/components/pie-chart/PieChart.d.ts +1 -1
- package/dist/components/pie-chart/index.d.ts +3 -3
- package/dist/components/resize-box/ResizeBox.vue.d.ts +2 -2
- package/dist/components/resize-box/index.d.ts +5 -5
- package/dist/components/scrollbar-v2/Scrollbar.vue.d.ts +2 -1
- package/dist/components/scrollbar-v2/index.d.ts +6 -3
- 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/TimeColumn.vue.d.ts +6 -3
- package/dist/components/time-picker/TimePanel.vue.d.ts +6 -3
- package/dist/components/time-picker/TimePicker.vue.d.ts +9 -12
- package/dist/components/time-picker/index.d.ts +19 -27
- package/dist/components/trend-chart/components/TrendChart.d.ts +5 -5
- package/dist/components/trend-chart/components/trend-chart-curve.d.ts +1 -1
- package/dist/components/trend-chart/index.d.ts +14 -14
- package/dist/components/virtual-list-v2/virtual-list.vue.d.ts +7 -4
- package/dist/es/_hooks/use-dialog-focus.js +69 -0
- package/dist/es/_hooks/use-pointer-drag.js +18 -0
- package/dist/es/_hooks/use-popup-close.js +27 -0
- package/dist/es/_hooks/use-popup-manager.js +26 -24
- package/dist/es/_hooks/use-popup-theme.js +18 -0
- package/dist/es/_hooks/use-teleport-container.js +9 -10
- package/dist/es/_utils/palette.js +57 -52
- package/dist/es/components/color-picker/ColorPicker.js +131 -102
- package/dist/es/components/color-picker/gradient-slider.js +38 -40
- package/dist/es/components/color-picker/panel.js +221 -192
- package/dist/es/components/color-picker/sv-panel.js +51 -50
- package/dist/es/components/config-provider/ConfigProvider.js +58 -41
- package/dist/es/components/dialog/Dialog.js +133 -186
- package/dist/es/components/drawer/src/Drawer.vue.js +59 -51
- package/dist/es/components/drawer/src/Drawer.vue2.js +117 -107
- package/dist/es/components/form/FormItem.vue.js +12 -12
- package/dist/es/components/form-select/SelectDropdown.vue.js +7 -7
- package/dist/es/components/form-select/SelectOption.vue.js +20 -17
- package/dist/es/components/form-select/SelectOption.vue2.js +39 -36
- package/dist/es/components/form-switch/Switch.vue.js +24 -24
- package/dist/es/components/image/Image.vue.js +12 -12
- package/dist/es/components/link/Link.vue.js +6 -6
- package/dist/es/components/menu/sub-menu-inline.vue.js +11 -11
- package/dist/es/components/menu/sub-menu-pop.vue.js +12 -12
- package/dist/es/components/notification/Notification.js +59 -59
- package/dist/es/components/resize-box/ResizeBox.vue.js +19 -22
- package/dist/es/components/skeleton/Skeleton.vue.js +9 -9
- package/dist/es/components/tag/Tag.vue.js +7 -7
- package/dist/es/components/trigger/Trigger.js +171 -163
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/style/bar-chart.js +1 -0
- package/dist/style/base.css +1 -1
- package/dist/style/color-picker.css +1 -1
- package/dist/style/color-picker.js +4 -0
- package/dist/style/date-picker.js +4 -0
- package/dist/style/dependencies.json +296 -0
- package/dist/style/dialog.js +2 -0
- package/dist/style/drawer.js +3 -0
- package/dist/style/dropdown.js +5 -0
- package/dist/style/form-checkbox.css +1 -1
- package/dist/style/form-input-number.js +2 -0
- package/dist/style/form-input.css +1 -1
- package/dist/style/form-input.js +1 -0
- package/dist/style/form-select.css +1 -1
- package/dist/style/form-select.js +5 -0
- package/dist/style/form-slider.js +5 -0
- package/dist/style/form.js +3 -0
- package/dist/style/heatmap.js +1 -0
- package/dist/style/image.js +2 -0
- package/dist/style/layout.js +1 -0
- package/dist/style/line-chart.js +1 -0
- package/dist/style/menu.js +3 -0
- package/dist/style/message-box.js +3 -0
- package/dist/style/pagination.js +9 -0
- package/dist/style/pie-chart.js +1 -0
- package/dist/style/popconfirm.js +3 -0
- package/dist/style/popover.js +1 -0
- package/dist/style/popup.js +2 -0
- package/dist/style/table.js +12 -0
- package/dist/style/time-picker.js +3 -0
- package/dist/style/tooltip.js +1 -0
- package/dist/style/upload.js +4 -0
- package/dist/style.css +1 -1
- package/package.json +17 -7
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { reactive as h, watch as m, onBeforeUnmount as d } from "vue";
|
|
2
|
+
const y = (n, f, u) => {
|
|
3
|
+
const e = h({ ok: !1, cancel: !1 });
|
|
4
|
+
let r = 0, l = !1;
|
|
5
|
+
const c = () => {
|
|
6
|
+
r++, e.ok = e.cancel = !1;
|
|
7
|
+
};
|
|
8
|
+
return m(n, c, { flush: "sync" }), d(() => {
|
|
9
|
+
l = !0, c();
|
|
10
|
+
}), { loading: e, requestClose: (s, a) => {
|
|
11
|
+
if (l || !n.value || e.ok || e.cancel) return;
|
|
12
|
+
const i = ++r;
|
|
13
|
+
e[s] = !0;
|
|
14
|
+
const p = () => !l && n.value && i === r, o = (t) => {
|
|
15
|
+
p() && (e[s] = !1, t && u(s, a));
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
const t = f(s, a);
|
|
19
|
+
t && typeof t == "object" && "then" in t ? Promise.resolve(t).then(o, () => o(!1)) : o(t);
|
|
20
|
+
} catch {
|
|
21
|
+
o(!1);
|
|
22
|
+
}
|
|
23
|
+
} };
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
y as usePopupClose
|
|
27
|
+
};
|
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
var c = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { ref as
|
|
5
|
-
const
|
|
6
|
-
class
|
|
2
|
+
var l = (o, e, t) => e in o ? c(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => l(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ref as f, watch as g, onMounted as S, onBeforeUnmount as m, readonly as h } from "vue";
|
|
5
|
+
const k = 1e3, E = 3e3, _ = 1;
|
|
6
|
+
class x {
|
|
7
7
|
constructor() {
|
|
8
|
-
|
|
8
|
+
a(this, "popupStack", {
|
|
9
9
|
popup: /* @__PURE__ */ new Set(),
|
|
10
10
|
dialog: /* @__PURE__ */ new Set(),
|
|
11
11
|
message: /* @__PURE__ */ new Set()
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
a(this, "getNextZIndex", (e) => (e === "message" ? Array.from(this.popupStack.message).pop() || E : Array.from(this.popupStack.popup).pop() || k) + _);
|
|
14
|
+
a(this, "add", (e) => {
|
|
15
15
|
const t = this.getNextZIndex(e);
|
|
16
16
|
return this.popupStack[e].add(t), e === "dialog" && this.popupStack.popup.add(t), t;
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
a(this, "delete", (e, t) => {
|
|
19
19
|
this.popupStack[t].delete(e), t === "dialog" && this.popupStack.popup.delete(e);
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
a(this, "isLastDialog", (e) => this.popupStack.dialog.size > 1 ? e === Array.from(this.popupStack.dialog).pop() : !0);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
24
|
+
const s = new x();
|
|
25
|
+
function D(o, {
|
|
26
26
|
visible: e,
|
|
27
27
|
runOnMounted: t
|
|
28
28
|
} = {}) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
29
|
+
const p = f(0);
|
|
30
|
+
let r = !1;
|
|
31
|
+
const n = () => {
|
|
32
|
+
r || (p.value = s.add(o), r = !0);
|
|
33
|
+
}, u = () => {
|
|
34
|
+
r && (s.delete(p.value, o), r = !1);
|
|
35
|
+
}, d = () => o === "dialog" ? s.isLastDialog(p.value) : !1;
|
|
34
36
|
return g(
|
|
35
37
|
() => e == null ? void 0 : e.value,
|
|
36
|
-
(
|
|
37
|
-
|
|
38
|
+
(i) => {
|
|
39
|
+
i ? n() : u();
|
|
38
40
|
},
|
|
39
41
|
{
|
|
40
42
|
immediate: !0
|
|
41
43
|
}
|
|
42
|
-
), t &&
|
|
43
|
-
zIndex:
|
|
44
|
+
), t && S(n), m(u), {
|
|
45
|
+
zIndex: h(p),
|
|
44
46
|
open: n,
|
|
45
|
-
close:
|
|
46
|
-
isLastDialog:
|
|
47
|
+
close: u,
|
|
48
|
+
isLastDialog: d
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
export {
|
|
50
|
-
|
|
52
|
+
D as default
|
|
51
53
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject as m, computed as o } from "vue";
|
|
2
|
+
import { configProviderInjectionKey as r } from "../components/config-provider/context.js";
|
|
3
|
+
const d = () => {
|
|
4
|
+
const e = m(r, void 0);
|
|
5
|
+
return {
|
|
6
|
+
popupThemeStyle: o(() => {
|
|
7
|
+
var p;
|
|
8
|
+
return (p = e == null ? void 0 : e.popupTheme) == null ? void 0 : p.value.style;
|
|
9
|
+
}),
|
|
10
|
+
popupThemeName: o(() => {
|
|
11
|
+
var p;
|
|
12
|
+
return (p = e == null ? void 0 : e.popupTheme) != null && p.value.dark ? "dark" : void 0;
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
d as usePopupTheme
|
|
18
|
+
};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as u, onMounted as f, watch as i } from "vue";
|
|
2
2
|
import { getElement as s } from "../_utils/dom.js";
|
|
3
3
|
const g = ({
|
|
4
4
|
popupContainer: e,
|
|
5
|
-
visible:
|
|
5
|
+
visible: a,
|
|
6
6
|
defaultContainer: m = "body",
|
|
7
|
-
documentContainer:
|
|
7
|
+
documentContainer: d
|
|
8
8
|
}) => {
|
|
9
|
-
const t =
|
|
10
|
-
|
|
11
|
-
r
|
|
9
|
+
const t = u(e.value), n = u(), o = () => {
|
|
10
|
+
if (typeof document > "u") return;
|
|
11
|
+
const r = s(e.value), l = r ? e.value : m, c = r ?? document.documentElement;
|
|
12
|
+
l !== t.value && (t.value = l), c !== n.value && (n.value = c);
|
|
12
13
|
};
|
|
13
|
-
return
|
|
14
|
-
t.value !== e.value && n && l();
|
|
15
|
-
}), {
|
|
14
|
+
return f(() => o()), i([e, a], o, { flush: "post" }), {
|
|
16
15
|
teleportContainer: t,
|
|
17
|
-
containerRef:
|
|
16
|
+
containerRef: n
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
19
|
export {
|
|
@@ -1,65 +1,70 @@
|
|
|
1
|
-
import { PALETTE_ALIASES as
|
|
2
|
-
const
|
|
3
|
-
if (typeof
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
const t =
|
|
1
|
+
import { PALETTE_ALIASES as x, PALETTE_ALIASES_DARK as b } from "../_styles/palette-aliases.js";
|
|
2
|
+
const y = 2.05, p = 95.5, d = 22, A = [1, 0.8, 0.6, 0.4, 0.2], _ = [1 / 3, 2 / 3, 1], S = 90, H = 300, u = (r, c, i) => Math.min(i, Math.max(c, r)), P = (r) => {
|
|
3
|
+
if (typeof r != "string") return null;
|
|
4
|
+
const c = r.trim();
|
|
5
|
+
if (c.startsWith("#")) {
|
|
6
|
+
const t = c.slice(1);
|
|
7
7
|
if (!/^(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)) return null;
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
const m = t.length === 3 ? [...t].map((a) => a + a).join("") : t.length === 6 || t.length === 8 ? t.slice(0, 6) : null;
|
|
9
|
+
return m ? [0, 2, 4].map((a) => parseInt(m.slice(a, a + 2), 16)) : null;
|
|
10
10
|
}
|
|
11
|
-
const i =
|
|
11
|
+
const i = c.match(/^rgba?\(([^)]+)\)$/i);
|
|
12
12
|
if (!i) return null;
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
const l =
|
|
18
|
-
return l.some((t) => !Number.isFinite(t)) ? null : l.map((t) =>
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
return t !== 0 && (
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
return e < 60 ?
|
|
27
|
-
},
|
|
28
|
-
const i =
|
|
13
|
+
const n = i[1].trim(), s = n.includes(",") ? n.split(",").map((t) => t.trim()) : n.split(/\s*\/\s*/)[0].split(/\s+/), e = n.includes(",") ? s[3] : n.includes("/") ? n.split("/")[1].trim() : void 0;
|
|
14
|
+
if (n.split("/").length > 2 || s.length < 3 || s.length > (n.includes(",") ? 4 : 3)) return null;
|
|
15
|
+
const o = /^[+-]?(?:\d+\.?\d*|\.\d+)%?$/;
|
|
16
|
+
if (s.slice(0, 3).some((t) => !o.test(t)) || e !== void 0 && !o.test(e)) return null;
|
|
17
|
+
const l = s.slice(0, 3).map((t) => t.endsWith("%") ? Math.round(parseFloat(t) / 100 * 255) : Number(t));
|
|
18
|
+
return l.some((t) => !Number.isFinite(t)) ? null : l.map((t) => u(Math.round(t), 0, 255));
|
|
19
|
+
}, $ = ([r, c, i]) => {
|
|
20
|
+
const n = r / 255, s = c / 255, e = i / 255, o = Math.max(n, s, e), l = Math.min(n, s, e), t = o - l, m = (o + l) / 2;
|
|
21
|
+
let a = 0, h = 0;
|
|
22
|
+
return t !== 0 && (h = m > 0.5 ? t / (2 - o - l) : t / (o + l), o === n ? a = (s - e) / t + (s < e ? 6 : 0) : o === s ? a = (e - n) / t + 2 : a = (n - s) / t + 4, a *= 60), { h: a, s: h * 100, l: m * 100 };
|
|
23
|
+
}, I = ({ h: r, s: c, l: i }) => {
|
|
24
|
+
const n = u(c, 0, 100) / 100, s = u(i, 0, 100) / 100, e = (r % 360 + 360) % 360, o = (1 - Math.abs(2 * s - 1)) * n, l = o * (1 - Math.abs(e / 60 % 2 - 1)), t = s - o / 2;
|
|
25
|
+
let m;
|
|
26
|
+
return e < 60 ? m = [o, l, 0] : e < 120 ? m = [l, o, 0] : e < 180 ? m = [0, o, l] : e < 240 ? m = [0, l, o] : e < 300 ? m = [l, 0, o] : m = [o, 0, l], m.map((a) => u(Math.round((a + t) * 255), 0, 255));
|
|
27
|
+
}, L = (r) => `#${r.map((c) => u(Math.round(c), 0, 255).toString(16).padStart(2, "0")).join("")}`, R = (r) => r <= S || r >= H ? 1 : -1, g = (r, c = {}) => {
|
|
28
|
+
const i = P(r);
|
|
29
29
|
if (!i)
|
|
30
|
-
throw new Error(`[x-next] generatePalette: 无法解析种子色 "${
|
|
31
|
-
const { h:
|
|
32
|
-
for (let
|
|
30
|
+
throw new Error(`[x-next] generatePalette: 无法解析种子色 "${r}"`);
|
|
31
|
+
const { h: n, s, l: e } = $(i), o = R(n), { dark: l = !1 } = c, t = l ? Math.min(d, e) : Math.max(p, e), m = l ? Math.max(p, e) : Math.min(d, e), a = [];
|
|
32
|
+
for (let h = 0; h < 9; h += 1) {
|
|
33
33
|
let f;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
h < 5 ? f = e + (t - e) * A[h] : h === 5 ? f = e : f = e + (m - e) * _[h - 6];
|
|
35
|
+
const E = 5 - h, M = o * y * E * (l ? -1 : 1);
|
|
36
|
+
a.push(L(I({ h: n + M, s, l: u(f, 0, 100) })));
|
|
37
37
|
}
|
|
38
|
-
return
|
|
39
|
-
}, G = (
|
|
40
|
-
const { name: i = "primary", target:
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
return a;
|
|
39
|
+
}, G = (r, c = {}) => {
|
|
40
|
+
const { name: i = "primary", target: n, dark: s } = c, e = g(r, { dark: s }), o = n ?? (typeof document < "u" ? document.documentElement : null);
|
|
41
|
+
if (o) {
|
|
42
|
+
o.style.setProperty(`--x-color-${i}`, e[5]), e.forEach((l, t) => {
|
|
43
|
+
o.style.setProperty(`--x-color-${i}-${t + 1}`, l);
|
|
44
44
|
});
|
|
45
|
-
const l
|
|
46
|
-
|
|
47
|
-
const t = r ? E[i] : void 0;
|
|
48
|
-
for (const [c, h] of Object.entries(l))
|
|
49
|
-
n.style.setProperty(c, (t == null ? void 0 : t[c]) ?? h);
|
|
50
|
-
}
|
|
45
|
+
for (const [l, t] of Object.entries(T(i, s)))
|
|
46
|
+
o.style.setProperty(l, t);
|
|
51
47
|
}
|
|
52
48
|
return e;
|
|
53
|
-
},
|
|
54
|
-
const
|
|
55
|
-
return
|
|
49
|
+
}, T = (r, c) => {
|
|
50
|
+
const i = x[r] ?? {}, n = c ? b[r] : void 0;
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(i).map(([s, e]) => [s, (n == null ? void 0 : n[s]) ?? e])
|
|
53
|
+
);
|
|
54
|
+
}, W = (r, c = !1) => {
|
|
55
|
+
const i = g(r, { dark: c });
|
|
56
|
+
return {
|
|
57
|
+
"--x-color-primary": i[5],
|
|
58
|
+
...Object.fromEntries(i.map((n, s) => [`--x-color-primary-${s + 1}`, n])),
|
|
59
|
+
...T("primary", c)
|
|
60
|
+
};
|
|
56
61
|
};
|
|
57
62
|
export {
|
|
58
63
|
G as applyThemeColor,
|
|
59
|
-
|
|
60
|
-
W as
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
g as generatePalette,
|
|
65
|
+
W as getThemeColorStyles,
|
|
66
|
+
I as hslToRgb,
|
|
67
|
+
P as parseColor,
|
|
68
|
+
$ as rgbToHsl,
|
|
69
|
+
L as toHex
|
|
65
70
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { getClassNameMixin as
|
|
3
|
-
import { useFormItem as
|
|
4
|
-
import { useSize as
|
|
5
|
-
import { useLocale as
|
|
6
|
-
import { parseColorAlpha as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
const
|
|
1
|
+
import { defineComponent as G, toRefs as E, useId as q, ref as w, computed as m, watch as O, createVNode as h, nextTick as J, mergeProps as T } from "vue";
|
|
2
|
+
import { getClassNameMixin as Q } from "../../_utils/config.js";
|
|
3
|
+
import { useFormItem as U, useFormItemControl as X } from "../../_hooks/use-form-item.js";
|
|
4
|
+
import { useSize as Y } from "../../_hooks/use-size.js";
|
|
5
|
+
import { useLocale as Z } from "../../locale/index.js";
|
|
6
|
+
import { parseColorAlpha as ee, formatColor as A } from "../../_utils/color.js";
|
|
7
|
+
import ae from "../trigger/Trigger.js";
|
|
8
|
+
import oe from "./panel.js";
|
|
9
|
+
const de = /* @__PURE__ */ G({
|
|
10
10
|
name: "ColorPicker",
|
|
11
|
+
inheritAttrs: !1,
|
|
11
12
|
props: {
|
|
12
13
|
/**
|
|
13
14
|
* @zh 颜色值,支持 hex / rgb / hsl(含 alpha)
|
|
@@ -116,124 +117,152 @@ const Y = /* @__PURE__ */ L({
|
|
|
116
117
|
}
|
|
117
118
|
},
|
|
118
119
|
emits: {
|
|
119
|
-
"update:modelValue": (
|
|
120
|
-
change: (
|
|
121
|
-
"update:show": (
|
|
122
|
-
showChange: (
|
|
123
|
-
confirm: (
|
|
120
|
+
"update:modelValue": (o, n) => !0,
|
|
121
|
+
change: (o, n) => !0,
|
|
122
|
+
"update:show": (o) => !0,
|
|
123
|
+
showChange: (o) => !0,
|
|
124
|
+
confirm: (o) => !0,
|
|
124
125
|
clear: () => !0
|
|
125
126
|
},
|
|
126
127
|
slots: Object,
|
|
127
|
-
setup(
|
|
128
|
-
attrs:
|
|
129
|
-
emit:
|
|
130
|
-
slots:
|
|
128
|
+
setup(o, {
|
|
129
|
+
attrs: n,
|
|
130
|
+
emit: d,
|
|
131
|
+
slots: f
|
|
131
132
|
}) {
|
|
132
|
-
const
|
|
133
|
-
t:
|
|
134
|
-
} =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
const u = Q("color-picker"), {
|
|
134
|
+
t: i
|
|
135
|
+
} = Z(), {
|
|
136
|
+
formItemCtx: P,
|
|
137
|
+
mergedDisabled: s,
|
|
138
|
+
mergedSize: j,
|
|
139
|
+
mergedError: F,
|
|
140
|
+
eventHandlers: b
|
|
141
|
+
} = U({
|
|
142
|
+
disabled: E(o).disabled,
|
|
143
|
+
size: E(o).size
|
|
144
|
+
}), {
|
|
145
|
+
mergedSize: I
|
|
146
|
+
} = Y(j), k = `x-color-picker-panel-${q()}`, L = X(P, () => ({
|
|
147
|
+
...Object.fromEntries(Object.entries(n).filter(([e]) => e === "id" || e.startsWith("aria-"))),
|
|
148
|
+
"aria-label": n["aria-label"] ?? (P.labelId ? void 0 : i("colorPicker.trigger"))
|
|
149
|
+
})), D = () => Object.fromEntries(Object.entries(n).filter(([e]) => e !== "id" && !e.startsWith("aria-") && e !== "class" && e !== "style")), p = w(o.defaultShow), c = m(() => o.show ?? p.value), g = (e) => {
|
|
150
|
+
e !== c.value && (p.value = e, d("update:show", e), d("showChange", e));
|
|
145
151
|
};
|
|
146
|
-
|
|
147
|
-
e !== void 0 && e !==
|
|
152
|
+
O(() => o.show, (e) => {
|
|
153
|
+
e !== void 0 && e !== p.value && (p.value = e);
|
|
148
154
|
});
|
|
149
|
-
const
|
|
155
|
+
const x = w(o.defaultValue), V = m(() => o.modelValue ?? x.value ?? ""), N = {
|
|
150
156
|
r: 28,
|
|
151
157
|
g: 97,
|
|
152
158
|
b: 255,
|
|
153
159
|
a: 1
|
|
154
|
-
},
|
|
155
|
-
var r,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
}, B = m(() => ee(V.value ?? "") ?? N), S = m(() => A(B.value, "hex", o.showAlpha)), y = (e, a, t = !1) => {
|
|
161
|
+
var r, l;
|
|
162
|
+
s.value || !t && e === V.value || (x.value = e, d("update:modelValue", e, a), d("change", e, a), (l = (r = b.value) == null ? void 0 : r.onChange) == null || l.call(r, a));
|
|
163
|
+
}, R = m(() => ({
|
|
164
|
+
clear: i("colorPicker.clear"),
|
|
165
|
+
confirm: i("colorPicker.confirm"),
|
|
166
|
+
hue: i("colorPicker.hue"),
|
|
167
|
+
alpha: i("colorPicker.alpha"),
|
|
168
|
+
saturation: i("colorPicker.saturation")
|
|
169
|
+
})), K = (e, a) => {
|
|
170
|
+
y(A(e, "hex", o.showAlpha), a);
|
|
171
|
+
}, $ = (e) => {
|
|
172
|
+
const a = A(e, "hex", o.showAlpha);
|
|
173
|
+
s.value || (y(a, void 0, !0), d("confirm", a), g(!1));
|
|
174
|
+
}, H = () => {
|
|
175
|
+
const e = o.defaultValue;
|
|
176
|
+
s.value || (y(e ?? "", void 0, !0), d("clear"));
|
|
177
|
+
}, v = w(), C = w(), M = (e) => {
|
|
178
|
+
s.value || (["Enter", " ", "ArrowDown"].includes(e.key) ? (e.preventDefault(), g(!0), J(() => {
|
|
179
|
+
var a;
|
|
180
|
+
return (a = C.value) == null ? void 0 : a.focus();
|
|
181
|
+
})) : e.key === "Escape" && c.value && (e.preventDefault(), g(!1)));
|
|
182
|
+
};
|
|
183
|
+
O(c, (e, a) => {
|
|
184
|
+
var r, l, _;
|
|
185
|
+
if (!a || e || typeof document > "u") return;
|
|
186
|
+
const t = document.activeElement;
|
|
187
|
+
(t === document.body || t === v.value || (l = (r = C.value) == null ? void 0 : r.$el) != null && l.contains(t)) && ((_ = v.value) == null || _.focus());
|
|
176
188
|
});
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
const z = m(() => ({
|
|
190
|
+
...L.value,
|
|
191
|
+
ref: (e) => {
|
|
192
|
+
v.value = e instanceof HTMLElement ? e : void 0;
|
|
193
|
+
},
|
|
194
|
+
type: "button",
|
|
195
|
+
disabled: s.value,
|
|
196
|
+
"aria-haspopup": "dialog",
|
|
197
|
+
"aria-expanded": c.value,
|
|
198
|
+
"aria-controls": c.value ? k : void 0,
|
|
199
|
+
onKeydown: M,
|
|
200
|
+
onFocus: (e) => {
|
|
201
|
+
var a, t;
|
|
202
|
+
return (t = (a = b.value) == null ? void 0 : a.onFocus) == null ? void 0 : t.call(a, e);
|
|
203
|
+
},
|
|
204
|
+
onBlur: (e) => {
|
|
205
|
+
var a, t;
|
|
206
|
+
return (t = (a = b.value) == null ? void 0 : a.onBlur) == null ? void 0 : t.call(a, e);
|
|
207
|
+
}
|
|
208
|
+
})), W = () => {
|
|
209
|
+
var r, l;
|
|
210
|
+
const e = (r = f.default) == null ? void 0 : r.call(f), a = (l = f.trigger) == null ? void 0 : l.call(f, {
|
|
211
|
+
value: S.value,
|
|
212
|
+
visible: c.value,
|
|
213
|
+
triggerAttrs: z.value
|
|
214
|
+
}), t = h("button", T(z.value, {
|
|
215
|
+
class: u.element("trigger")
|
|
216
|
+
}), [h("span", {
|
|
217
|
+
class: u.element("trigger-color"),
|
|
194
218
|
style: {
|
|
195
|
-
backgroundColor:
|
|
219
|
+
backgroundColor: S.value
|
|
196
220
|
}
|
|
197
221
|
}, null)]);
|
|
198
|
-
return
|
|
199
|
-
class: [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}, [l]);
|
|
222
|
+
return h("span", T(D(), {
|
|
223
|
+
class: [u.block, u.modifier(`size-${I.value}`), e && u.element("trigger-wrapper"), F.value && u.modifier("error"), n.class],
|
|
224
|
+
style: n.style
|
|
225
|
+
}), [a ?? t, e && h("span", {
|
|
226
|
+
class: u.element("trigger-label")
|
|
227
|
+
}, [e])]);
|
|
205
228
|
};
|
|
206
|
-
return () =>
|
|
229
|
+
return () => h(ae, {
|
|
207
230
|
trigger: "click",
|
|
208
231
|
position: "bl",
|
|
209
232
|
popupOffset: 4,
|
|
210
233
|
clickToClose: !1,
|
|
211
|
-
preventFocus: !0,
|
|
212
234
|
autoFitTransformOrigin: !0,
|
|
213
235
|
animationName: "x-zoom-in-fade-out",
|
|
214
|
-
disabled:
|
|
215
|
-
popupVisible:
|
|
216
|
-
popupContainer:
|
|
217
|
-
onPopupVisibleChange:
|
|
236
|
+
disabled: s.value,
|
|
237
|
+
popupVisible: c.value,
|
|
238
|
+
popupContainer: o.popupContainer,
|
|
239
|
+
onPopupVisibleChange: g,
|
|
240
|
+
onShow: () => {
|
|
241
|
+
var e;
|
|
242
|
+
document.activeElement === v.value && ((e = C.value) == null || e.focus());
|
|
243
|
+
}
|
|
218
244
|
}, {
|
|
219
|
-
default:
|
|
220
|
-
content: () =>
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
245
|
+
default: W,
|
|
246
|
+
content: () => h(oe, {
|
|
247
|
+
ref: C,
|
|
248
|
+
id: k,
|
|
249
|
+
ariaLabel: i("colorPicker.trigger"),
|
|
250
|
+
value: B.value,
|
|
251
|
+
modes: o.modes,
|
|
252
|
+
showAlpha: o.showAlpha,
|
|
253
|
+
swatches: o.swatches,
|
|
254
|
+
disabled: s.value,
|
|
255
|
+
showConfirm: o.showConfirm,
|
|
256
|
+
showClear: o.showClear,
|
|
257
|
+
texts: R.value,
|
|
258
|
+
onChange: K,
|
|
259
|
+
onConfirm: $,
|
|
260
|
+
onClear: H,
|
|
261
|
+
onClose: () => g(!1)
|
|
233
262
|
}, null)
|
|
234
263
|
});
|
|
235
264
|
}
|
|
236
265
|
});
|
|
237
266
|
export {
|
|
238
|
-
|
|
267
|
+
de as default
|
|
239
268
|
};
|