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.
Files changed (166) hide show
  1. package/AI_CODING.md +97 -0
  2. package/AI_USAGE/catalog.md +111 -0
  3. package/AI_USAGE/components/alert.md +33 -0
  4. package/AI_USAGE/components/bar-chart.md +46 -0
  5. package/AI_USAGE/components/button.md +35 -0
  6. package/AI_USAGE/components/checkbox.md +34 -0
  7. package/AI_USAGE/components/color-picker.md +36 -0
  8. package/AI_USAGE/components/config-provider.md +58 -0
  9. package/AI_USAGE/components/date-picker.md +34 -0
  10. package/AI_USAGE/components/dialog.md +37 -0
  11. package/AI_USAGE/components/dropdown.md +38 -0
  12. package/AI_USAGE/components/empty.md +30 -0
  13. package/AI_USAGE/components/input.md +32 -0
  14. package/AI_USAGE/components/line-chart.md +45 -0
  15. package/AI_USAGE/components/message-box.md +39 -0
  16. package/AI_USAGE/components/message.md +36 -0
  17. package/AI_USAGE/components/notification.md +37 -0
  18. package/AI_USAGE/components/pagination.md +32 -0
  19. package/AI_USAGE/components/pie-chart.md +55 -0
  20. package/AI_USAGE/components/popconfirm.md +33 -0
  21. package/AI_USAGE/components/popover.md +35 -0
  22. package/AI_USAGE/components/progress.md +32 -0
  23. package/AI_USAGE/components/radio.md +35 -0
  24. package/AI_USAGE/components/rate.md +30 -0
  25. package/AI_USAGE/components/select.md +38 -0
  26. package/AI_USAGE/components/slider.md +34 -0
  27. package/AI_USAGE/components/steps.md +33 -0
  28. package/AI_USAGE/components/switch.md +32 -0
  29. package/AI_USAGE/components/tabs.md +33 -0
  30. package/AI_USAGE/components/textarea.md +31 -0
  31. package/AI_USAGE/components/time-picker.md +34 -0
  32. package/AI_USAGE/components/upload.md +60 -0
  33. package/AI_USAGE/core.md +37 -0
  34. package/AI_USAGE/index.md +52 -0
  35. package/AI_USAGE/recipes/form-on-demand.md +42 -0
  36. package/AI_USAGE.md +171 -46
  37. package/CHANGELOG.md +23 -0
  38. package/README.md +15 -2
  39. package/dist/_container/resize-trigger.vue.d.ts +1 -1
  40. package/dist/_hooks/use-dialog-focus.d.ts +7 -0
  41. package/dist/_hooks/use-pointer-drag.d.ts +6 -0
  42. package/dist/_hooks/use-popup-close.d.ts +11 -0
  43. package/dist/_hooks/use-popup-theme.d.ts +5 -0
  44. package/dist/_utils/palette.d.ts +2 -0
  45. package/dist/components/_components/picker/input-range.vue.d.ts +1 -3
  46. package/dist/components/_components/picker/input.vue.d.ts +1 -3
  47. package/dist/components/alert/Alert.vue.d.ts +1 -1
  48. package/dist/components/alert/index.d.ts +3 -3
  49. package/dist/components/bar-chart/BarChart.d.ts +3 -3
  50. package/dist/components/bar-chart/index.d.ts +9 -9
  51. package/dist/components/color-picker/ColorPicker.d.ts +2 -1
  52. package/dist/components/color-picker/index.d.ts +2 -0
  53. package/dist/components/color-picker/panel.d.ts +6 -0
  54. package/dist/components/config-provider/context.d.ts +7 -1
  55. package/dist/components/date-picker/DatePicker.vue.d.ts +9 -12
  56. package/dist/components/date-picker/index.d.ts +19 -27
  57. package/dist/components/drawer/index.d.ts +51 -9
  58. package/dist/components/drawer/src/Drawer.vue.d.ts +19 -4
  59. package/dist/components/dropdown/Dropdown.vue.d.ts +6 -3
  60. package/dist/components/dropdown/DropdownButton.vue.d.ts +6 -3
  61. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +6 -3
  62. package/dist/components/dropdown/dropdown-panel.vue.d.ts +6 -3
  63. package/dist/components/dropdown/index.d.ts +36 -18
  64. package/dist/components/form-select/SelectDropdown.vue.d.ts +6 -3
  65. package/dist/components/form-select/SelectOption.vue.d.ts +1 -0
  66. package/dist/components/form-select/index.d.ts +15 -6
  67. package/dist/components/form-slider/Slider.vue.d.ts +1 -1
  68. package/dist/components/form-slider/index.d.ts +3 -3
  69. package/dist/components/form-textarea/Textarea.vue.d.ts +2 -4
  70. package/dist/components/form-textarea/index.d.ts +6 -12
  71. package/dist/components/image/Image.vue.d.ts +2 -4
  72. package/dist/components/image/index.d.ts +6 -12
  73. package/dist/components/layout/LayoutSidebar.vue.d.ts +5 -5
  74. package/dist/components/layout/index.d.ts +10 -10
  75. package/dist/components/line-chart/LineChart.d.ts +3 -3
  76. package/dist/components/line-chart/index.d.ts +9 -9
  77. package/dist/components/menu/Menu.d.ts +6 -3
  78. package/dist/components/menu/base-menu.vue.d.ts +6 -3
  79. package/dist/components/menu/index.d.ts +12 -6
  80. package/dist/components/menu/sub-menu-pop.vue.d.ts +6 -3
  81. package/dist/components/network/Network.vue.d.ts +1 -1
  82. package/dist/components/network/index.d.ts +3 -3
  83. package/dist/components/pie-chart/PieChart.d.ts +1 -1
  84. package/dist/components/pie-chart/index.d.ts +3 -3
  85. package/dist/components/resize-box/ResizeBox.vue.d.ts +2 -2
  86. package/dist/components/resize-box/index.d.ts +5 -5
  87. package/dist/components/scrollbar-v2/Scrollbar.vue.d.ts +2 -1
  88. package/dist/components/scrollbar-v2/index.d.ts +6 -3
  89. package/dist/components/table/Table.d.ts +1 -1
  90. package/dist/components/table/index.d.ts +3 -3
  91. package/dist/components/tabs/Tabs.d.ts +1 -1
  92. package/dist/components/tabs/index.d.ts +3 -3
  93. package/dist/components/time-picker/TimeColumn.vue.d.ts +6 -3
  94. package/dist/components/time-picker/TimePanel.vue.d.ts +6 -3
  95. package/dist/components/time-picker/TimePicker.vue.d.ts +9 -12
  96. package/dist/components/time-picker/index.d.ts +19 -27
  97. package/dist/components/trend-chart/components/TrendChart.d.ts +5 -5
  98. package/dist/components/trend-chart/components/trend-chart-curve.d.ts +1 -1
  99. package/dist/components/trend-chart/index.d.ts +14 -14
  100. package/dist/components/virtual-list-v2/virtual-list.vue.d.ts +7 -4
  101. package/dist/es/_hooks/use-dialog-focus.js +69 -0
  102. package/dist/es/_hooks/use-pointer-drag.js +18 -0
  103. package/dist/es/_hooks/use-popup-close.js +27 -0
  104. package/dist/es/_hooks/use-popup-manager.js +26 -24
  105. package/dist/es/_hooks/use-popup-theme.js +18 -0
  106. package/dist/es/_hooks/use-teleport-container.js +9 -10
  107. package/dist/es/_utils/palette.js +57 -52
  108. package/dist/es/components/color-picker/ColorPicker.js +131 -102
  109. package/dist/es/components/color-picker/gradient-slider.js +38 -40
  110. package/dist/es/components/color-picker/panel.js +221 -192
  111. package/dist/es/components/color-picker/sv-panel.js +51 -50
  112. package/dist/es/components/config-provider/ConfigProvider.js +58 -41
  113. package/dist/es/components/dialog/Dialog.js +133 -186
  114. package/dist/es/components/drawer/src/Drawer.vue.js +59 -51
  115. package/dist/es/components/drawer/src/Drawer.vue2.js +117 -107
  116. package/dist/es/components/form/FormItem.vue.js +12 -12
  117. package/dist/es/components/form-select/SelectDropdown.vue.js +7 -7
  118. package/dist/es/components/form-select/SelectOption.vue.js +20 -17
  119. package/dist/es/components/form-select/SelectOption.vue2.js +39 -36
  120. package/dist/es/components/form-switch/Switch.vue.js +24 -24
  121. package/dist/es/components/image/Image.vue.js +12 -12
  122. package/dist/es/components/link/Link.vue.js +6 -6
  123. package/dist/es/components/menu/sub-menu-inline.vue.js +11 -11
  124. package/dist/es/components/menu/sub-menu-pop.vue.js +12 -12
  125. package/dist/es/components/notification/Notification.js +59 -59
  126. package/dist/es/components/resize-box/ResizeBox.vue.js +19 -22
  127. package/dist/es/components/skeleton/Skeleton.vue.js +9 -9
  128. package/dist/es/components/tag/Tag.vue.js +7 -7
  129. package/dist/es/components/trigger/Trigger.js +171 -163
  130. package/dist/es/style.css +1 -1
  131. package/dist/index.cjs +3 -3
  132. package/dist/index.umd.js +3 -3
  133. package/dist/style/bar-chart.js +1 -0
  134. package/dist/style/base.css +1 -1
  135. package/dist/style/color-picker.css +1 -1
  136. package/dist/style/color-picker.js +4 -0
  137. package/dist/style/date-picker.js +4 -0
  138. package/dist/style/dependencies.json +296 -0
  139. package/dist/style/dialog.js +2 -0
  140. package/dist/style/drawer.js +3 -0
  141. package/dist/style/dropdown.js +5 -0
  142. package/dist/style/form-checkbox.css +1 -1
  143. package/dist/style/form-input-number.js +2 -0
  144. package/dist/style/form-input.css +1 -1
  145. package/dist/style/form-input.js +1 -0
  146. package/dist/style/form-select.css +1 -1
  147. package/dist/style/form-select.js +5 -0
  148. package/dist/style/form-slider.js +5 -0
  149. package/dist/style/form.js +3 -0
  150. package/dist/style/heatmap.js +1 -0
  151. package/dist/style/image.js +2 -0
  152. package/dist/style/layout.js +1 -0
  153. package/dist/style/line-chart.js +1 -0
  154. package/dist/style/menu.js +3 -0
  155. package/dist/style/message-box.js +3 -0
  156. package/dist/style/pagination.js +9 -0
  157. package/dist/style/pie-chart.js +1 -0
  158. package/dist/style/popconfirm.js +3 -0
  159. package/dist/style/popover.js +1 -0
  160. package/dist/style/popup.js +2 -0
  161. package/dist/style/table.js +12 -0
  162. package/dist/style/time-picker.js +3 -0
  163. package/dist/style/tooltip.js +1 -0
  164. package/dist/style/upload.js +4 -0
  165. package/dist/style.css +1 -1
  166. 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 i = (o, e, t) => e in o ? c(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var p = (o, e, t) => i(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { ref as l, watch as g, onMounted as S, onBeforeUnmount as f, readonly as m } from "vue";
5
- const h = 1e3, k = 3e3, E = 1;
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
- p(this, "popupStack", {
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
- p(this, "getNextZIndex", (e) => (e === "message" ? Array.from(this.popupStack.message).pop() || k : Array.from(this.popupStack.popup).pop() || h) + E);
14
- p(this, "add", (e) => {
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
- p(this, "delete", (e, t) => {
18
+ a(this, "delete", (e, t) => {
19
19
  this.popupStack[t].delete(e), t === "dialog" && this.popupStack.popup.delete(e);
20
20
  });
21
- p(this, "isLastDialog", (e) => this.popupStack.dialog.size > 1 ? e === Array.from(this.popupStack.dialog).pop() : !0);
21
+ a(this, "isLastDialog", (e) => this.popupStack.dialog.size > 1 ? e === Array.from(this.popupStack.dialog).pop() : !0);
22
22
  }
23
23
  }
24
- const u = new _();
25
- function A(o, {
24
+ const s = new x();
25
+ function D(o, {
26
26
  visible: e,
27
27
  runOnMounted: t
28
28
  } = {}) {
29
- const a = l(0), n = () => {
30
- a.value = u.add(o);
31
- }, r = () => {
32
- u.delete(a.value, o);
33
- }, s = () => o === "dialog" ? u.isLastDialog(a.value) : !1;
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
- (d) => {
37
- d ? n() : r();
38
+ (i) => {
39
+ i ? n() : u();
38
40
  },
39
41
  {
40
42
  immediate: !0
41
43
  }
42
- ), t && (S(n), f(r)), {
43
- zIndex: m(a),
44
+ ), t && S(n), m(u), {
45
+ zIndex: h(p),
44
46
  open: n,
45
- close: r,
46
- isLastDialog: s
47
+ close: u,
48
+ isLastDialog: d
47
49
  };
48
50
  }
49
51
  export {
50
- A as default
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 c, onMounted as i, watch as v } from "vue";
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: u,
5
+ visible: a,
6
6
  defaultContainer: m = "body",
7
- documentContainer: f
7
+ documentContainer: d
8
8
  }) => {
9
- const t = c(e.value), o = c(), l = () => {
10
- const n = s(e.value), r = n ? e.value : m, a = n ?? document.documentElement;
11
- r !== t.value && (t.value = r), a !== o.value && (o.value = a);
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 i(() => l()), v(u, (n) => {
14
- t.value !== e.value && n && l();
15
- }), {
14
+ return f(() => o()), i([e, a], o, { flush: "post" }), {
16
15
  teleportContainer: t,
17
- containerRef: o
16
+ containerRef: n
18
17
  };
19
18
  };
20
19
  export {
@@ -1,65 +1,70 @@
1
- import { PALETTE_ALIASES as g, PALETTE_ALIASES_DARK as E } from "../_styles/palette-aliases.js";
2
- const x = 2.05, d = 95.5, p = 22, A = [1, 0.8, 0.6, 0.4, 0.2], _ = [1 / 3, 2 / 3, 1], b = 90, y = 300, m = (s, a, i) => Math.min(i, Math.max(a, s)), $ = (s) => {
3
- if (typeof s != "string") return null;
4
- const a = s.trim();
5
- if (a.startsWith("#")) {
6
- const t = a.slice(1);
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 c = t.length === 3 ? [...t].map((h) => h + h).join("") : t.length === 6 || t.length === 8 ? t.slice(0, 6) : null;
9
- return c ? [0, 2, 4].map((h) => parseInt(c.slice(h, h + 2), 16)) : null;
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 = a.match(/^rgba?\(([^)]+)\)$/i);
11
+ const i = c.match(/^rgba?\(([^)]+)\)$/i);
12
12
  if (!i) return null;
13
- const o = i[1].trim(), r = o.includes(",") ? o.split(",").map((t) => t.trim()) : o.split(/\s*\/\s*/)[0].split(/\s+/), e = o.includes(",") ? r[3] : o.includes("/") ? o.split("/")[1].trim() : void 0;
14
- if (o.split("/").length > 2 || r.length < 3 || r.length > (o.includes(",") ? 4 : 3)) return null;
15
- const n = /^[+-]?(?:\d+\.?\d*|\.\d+)%?$/;
16
- if (r.slice(0, 3).some((t) => !n.test(t)) || e !== void 0 && !n.test(e)) return null;
17
- const l = r.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) => m(Math.round(t), 0, 255));
19
- }, H = ([s, a, i]) => {
20
- const o = s / 255, r = a / 255, e = i / 255, n = Math.max(o, r, e), l = Math.min(o, r, e), t = n - l, c = (n + l) / 2;
21
- let h = 0, u = 0;
22
- return t !== 0 && (u = c > 0.5 ? t / (2 - n - l) : t / (n + l), n === o ? h = (r - e) / t + (r < e ? 6 : 0) : n === r ? h = (e - o) / t + 2 : h = (o - r) / t + 4, h *= 60), { h, s: u * 100, l: c * 100 };
23
- }, S = ({ h: s, s: a, l: i }) => {
24
- const o = m(a, 0, 100) / 100, r = m(i, 0, 100) / 100, e = (s % 360 + 360) % 360, n = (1 - Math.abs(2 * r - 1)) * o, l = n * (1 - Math.abs(e / 60 % 2 - 1)), t = r - n / 2;
25
- let c;
26
- return e < 60 ? c = [n, l, 0] : e < 120 ? c = [l, n, 0] : e < 180 ? c = [0, n, l] : e < 240 ? c = [0, l, n] : e < 300 ? c = [l, 0, n] : c = [n, 0, l], c.map((h) => m(Math.round((h + t) * 255), 0, 255));
27
- }, P = (s) => `#${s.map((a) => m(Math.round(a), 0, 255).toString(16).padStart(2, "0")).join("")}`, I = (s) => s <= b || s >= y ? 1 : -1, L = (s, a = {}) => {
28
- const i = $(s);
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: 无法解析种子色 "${s}"`);
31
- const { h: o, s: r, l: e } = H(i), n = I(o), { dark: l = !1 } = a, t = l ? Math.min(p, e) : Math.max(d, e), c = l ? Math.max(d, e) : Math.min(p, e), h = [];
32
- for (let u = 0; u < 9; u += 1) {
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
- u < 5 ? f = e + (t - e) * A[u] : u === 5 ? f = e : f = e + (c - e) * _[u - 6];
35
- const T = 5 - u, M = n * x * T * (l ? -1 : 1);
36
- h.push(P(S({ h: o + M, s: r, l: m(f, 0, 100) })));
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 h;
39
- }, G = (s, a = {}) => {
40
- const { name: i = "primary", target: o, dark: r } = a, e = L(s, { dark: r }), n = o ?? (typeof document < "u" ? document.documentElement : null);
41
- if (n) {
42
- n.style.setProperty(`--x-color-${i}`, e[5]), e.forEach((t, c) => {
43
- n.style.setProperty(`--x-color-${i}-${c + 1}`, t);
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 = g[i];
46
- if (l) {
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
- }, W = (s = "primary") => {
54
- const a = [`--x-color-${s}`, ...Array.from({ length: 9 }, (o, r) => `--x-color-${s}-${r + 1}`)], i = g[s];
55
- return i ? [...a, ...Object.keys(i)] : a;
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
- L as generatePalette,
60
- W as getThemeColorProperties,
61
- S as hslToRgb,
62
- $ as parseColor,
63
- H as rgbToHsl,
64
- P as toHex
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 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({
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": (a, d) => !0,
120
- change: (a, d) => !0,
121
- "update:show": (a) => !0,
122
- showChange: (a) => !0,
123
- confirm: (a) => !0,
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(a, {
128
- attrs: d,
129
- emit: t,
130
- slots: s
128
+ setup(o, {
129
+ attrs: n,
130
+ emit: d,
131
+ slots: f
131
132
  }) {
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));
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
- A(() => a.show, (e) => {
147
- e !== void 0 && e !== h.value && (h.value = e);
152
+ O(() => o.show, (e) => {
153
+ e !== void 0 && e !== p.value && (p.value = e);
148
154
  });
149
- const p = C(a.defaultValue), w = c(() => a.modelValue ?? p.value ?? ""), S = {
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
- }, 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));
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 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"),
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: y.value
219
+ backgroundColor: S.value
196
220
  }
197
221
  }, 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]);
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 () => n(I, {
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: g.value,
215
- popupVisible: i.value,
216
- popupContainer: a.popupContainer,
217
- onPopupVisibleChange: m
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: 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)
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
- Y as default
267
+ de as default
239
268
  };