x-next 1.10.0 → 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 (182) 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 +173 -46
  37. package/CHANGELOG.md +36 -1
  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/_components/select-view/select-view.d.ts +9 -0
  48. package/dist/components/alert/Alert.vue.d.ts +1 -1
  49. package/dist/components/alert/index.d.ts +3 -3
  50. package/dist/components/bar-chart/BarChart.d.ts +3 -3
  51. package/dist/components/bar-chart/index.d.ts +9 -9
  52. package/dist/components/color-picker/ColorPicker.d.ts +2 -1
  53. package/dist/components/color-picker/index.d.ts +2 -0
  54. package/dist/components/color-picker/panel.d.ts +6 -0
  55. package/dist/components/config-provider/context.d.ts +7 -1
  56. package/dist/components/date-picker/DatePicker.vue.d.ts +9 -12
  57. package/dist/components/date-picker/index.d.ts +19 -27
  58. package/dist/components/drawer/index.d.ts +51 -9
  59. package/dist/components/drawer/src/Drawer.vue.d.ts +19 -4
  60. package/dist/components/dropdown/Dropdown.vue.d.ts +6 -3
  61. package/dist/components/dropdown/DropdownButton.vue.d.ts +6 -3
  62. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +6 -3
  63. package/dist/components/dropdown/dropdown-panel.vue.d.ts +6 -3
  64. package/dist/components/dropdown/index.d.ts +36 -18
  65. package/dist/components/form-select/Select.d.ts +18 -5
  66. package/dist/components/form-select/SelectDropdown.vue.d.ts +6 -3
  67. package/dist/components/form-select/SelectOption.vue.d.ts +1 -0
  68. package/dist/components/form-select/SelectOptionGroup.vue.d.ts +1 -0
  69. package/dist/components/form-select/hooks/use-options.d.ts +1 -1
  70. package/dist/components/form-select/hooks/use-select.d.ts +1 -1
  71. package/dist/components/form-select/index.d.ts +57 -17
  72. package/dist/components/form-select/interface.d.ts +8 -0
  73. package/dist/components/form-slider/Slider.vue.d.ts +1 -1
  74. package/dist/components/form-slider/index.d.ts +3 -3
  75. package/dist/components/form-textarea/Textarea.vue.d.ts +2 -4
  76. package/dist/components/form-textarea/index.d.ts +6 -12
  77. package/dist/components/image/Image.vue.d.ts +2 -4
  78. package/dist/components/image/index.d.ts +6 -12
  79. package/dist/components/layout/LayoutSidebar.vue.d.ts +5 -5
  80. package/dist/components/layout/index.d.ts +10 -10
  81. package/dist/components/line-chart/LineChart.d.ts +3 -3
  82. package/dist/components/line-chart/index.d.ts +9 -9
  83. package/dist/components/menu/Menu.d.ts +6 -3
  84. package/dist/components/menu/base-menu.vue.d.ts +6 -3
  85. package/dist/components/menu/index.d.ts +12 -6
  86. package/dist/components/menu/sub-menu-pop.vue.d.ts +6 -3
  87. package/dist/components/network/Network.vue.d.ts +1 -1
  88. package/dist/components/network/index.d.ts +3 -3
  89. package/dist/components/pagination/page-options.vue.d.ts +60 -32
  90. package/dist/components/pie-chart/PieChart.d.ts +1 -1
  91. package/dist/components/pie-chart/index.d.ts +3 -3
  92. package/dist/components/resize-box/ResizeBox.vue.d.ts +2 -2
  93. package/dist/components/resize-box/index.d.ts +5 -5
  94. package/dist/components/scrollbar-v2/Scrollbar.vue.d.ts +2 -1
  95. package/dist/components/scrollbar-v2/index.d.ts +6 -3
  96. package/dist/components/table/Table.d.ts +1 -1
  97. package/dist/components/table/index.d.ts +3 -3
  98. package/dist/components/tabs/Tabs.d.ts +1 -1
  99. package/dist/components/tabs/index.d.ts +3 -3
  100. package/dist/components/time-picker/TimeColumn.vue.d.ts +6 -3
  101. package/dist/components/time-picker/TimePanel.vue.d.ts +6 -3
  102. package/dist/components/time-picker/TimePicker.vue.d.ts +9 -12
  103. package/dist/components/time-picker/index.d.ts +19 -27
  104. package/dist/components/trend-chart/components/TrendChart.d.ts +5 -5
  105. package/dist/components/trend-chart/components/trend-chart-curve.d.ts +1 -1
  106. package/dist/components/trend-chart/index.d.ts +14 -14
  107. package/dist/components/trigger/interface.d.ts +2 -0
  108. package/dist/components/virtual-list-v2/virtual-list.vue.d.ts +7 -4
  109. package/dist/es/_hooks/use-dialog-focus.js +69 -0
  110. package/dist/es/_hooks/use-pointer-drag.js +18 -0
  111. package/dist/es/_hooks/use-popup-close.js +27 -0
  112. package/dist/es/_hooks/use-popup-manager.js +26 -24
  113. package/dist/es/_hooks/use-popup-theme.js +18 -0
  114. package/dist/es/_hooks/use-teleport-container.js +9 -10
  115. package/dist/es/_utils/palette.js +57 -52
  116. package/dist/es/components/_components/select-view/select-view.js +89 -78
  117. package/dist/es/components/button/Button.js +1 -1
  118. package/dist/es/components/color-picker/ColorPicker.js +131 -102
  119. package/dist/es/components/color-picker/gradient-slider.js +38 -40
  120. package/dist/es/components/color-picker/panel.js +221 -192
  121. package/dist/es/components/color-picker/sv-panel.js +51 -50
  122. package/dist/es/components/config-provider/ConfigProvider.js +58 -41
  123. package/dist/es/components/dialog/Dialog.js +133 -186
  124. package/dist/es/components/drawer/src/Drawer.vue.js +59 -51
  125. package/dist/es/components/drawer/src/Drawer.vue2.js +117 -107
  126. package/dist/es/components/form/FormItem.vue.js +12 -12
  127. package/dist/es/components/form-input-tag/InputTag.js +1 -1
  128. package/dist/es/components/form-select/Select.js +348 -300
  129. package/dist/es/components/form-select/SelectDropdown.vue.js +7 -7
  130. package/dist/es/components/form-select/SelectOption.vue.js +22 -17
  131. package/dist/es/components/form-select/SelectOption.vue2.js +59 -51
  132. package/dist/es/components/form-select/SelectOptionGroup.vue.js +17 -13
  133. package/dist/es/components/form-select/SelectOptionGroup.vue2.js +8 -5
  134. package/dist/es/components/form-select/hooks/use-options.js +40 -40
  135. package/dist/es/components/form-select/hooks/use-select.js +76 -71
  136. package/dist/es/components/form-switch/Switch.vue.js +24 -24
  137. package/dist/es/components/image/Image.vue.js +12 -12
  138. package/dist/es/components/link/Link.vue.js +6 -6
  139. package/dist/es/components/menu/sub-menu-inline.vue.js +11 -11
  140. package/dist/es/components/menu/sub-menu-pop.vue.js +12 -12
  141. package/dist/es/components/notification/Notification.js +59 -59
  142. package/dist/es/components/resize-box/ResizeBox.vue.js +19 -22
  143. package/dist/es/components/skeleton/Skeleton.vue.js +9 -9
  144. package/dist/es/components/tag/Tag.vue.js +7 -7
  145. package/dist/es/components/trigger/Trigger.js +171 -163
  146. package/dist/es/style.css +1 -1
  147. package/dist/index.cjs +3 -3
  148. package/dist/index.umd.js +3 -3
  149. package/dist/style/bar-chart.js +1 -0
  150. package/dist/style/base.css +1 -1
  151. package/dist/style/button.css +1 -1
  152. package/dist/style/color-picker.css +1 -1
  153. package/dist/style/color-picker.js +4 -0
  154. package/dist/style/date-picker.js +4 -0
  155. package/dist/style/dependencies.json +296 -0
  156. package/dist/style/dialog.js +2 -0
  157. package/dist/style/drawer.js +3 -0
  158. package/dist/style/dropdown.js +5 -0
  159. package/dist/style/form-checkbox.css +1 -1
  160. package/dist/style/form-input-number.js +2 -0
  161. package/dist/style/form-input.css +1 -1
  162. package/dist/style/form-input.js +1 -0
  163. package/dist/style/form-select.js +5 -0
  164. package/dist/style/form-slider.js +5 -0
  165. package/dist/style/form.js +3 -0
  166. package/dist/style/heatmap.js +1 -0
  167. package/dist/style/image.js +2 -0
  168. package/dist/style/layout.js +1 -0
  169. package/dist/style/line-chart.js +1 -0
  170. package/dist/style/menu.js +3 -0
  171. package/dist/style/message-box.js +3 -0
  172. package/dist/style/pagination.js +9 -0
  173. package/dist/style/pie-chart.js +1 -0
  174. package/dist/style/popconfirm.js +3 -0
  175. package/dist/style/popover.js +1 -0
  176. package/dist/style/popup.js +2 -0
  177. package/dist/style/table.js +12 -0
  178. package/dist/style/time-picker.js +3 -0
  179. package/dist/style/tooltip.js +1 -0
  180. package/dist/style/upload.js +4 -0
  181. package/dist/style.css +1 -1
  182. package/package.json +17 -7
@@ -1,16 +1,20 @@
1
- import { defineComponent as K, createVNode as o, Fragment as J, ref as z, watch as j, computed as b } from "vue";
2
- import { getClassNameMixin as Q } from "../../_utils/config.js";
3
- import { rgbToHsl as W, hslToRgb as X } from "../../_utils/palette.js";
4
- import { formatColor as E, rgbToHsv as _, hsvToRgb as Y, toRgbaString as Z, toAlphaSliderColor as ee, parseColorAlpha as G, formatAlphaPercent as ae } from "../../_utils/color.js";
5
- import le from "../form-input/Input.js";
6
- import ne from "../form-input-number/InputNumber.js";
7
- import te from "../button/Button.js";
8
- import oe from "../../icons/default/check.js";
9
- import se from "./sv-panel.js";
10
- import re from "./gradient-slider.js";
11
- const he = "linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red)", Ce = /* @__PURE__ */ K({
1
+ import { defineComponent as F, createVNode as o, Fragment as X, provide as J, ref as B, onMounted as Q, watch as D, computed as f } from "vue";
2
+ import { formItemInjectionKey as W } from "../form/context.js";
3
+ import { getTabbableElements as Y } from "../../_hooks/use-dialog-focus.js";
4
+ import { getClassNameMixin as Z } from "../../_utils/config.js";
5
+ import { rgbToHsl as ee, hslToRgb as ae } from "../../_utils/palette.js";
6
+ import { formatColor as _, rgbToHsv as $, hsvToRgb as le, toRgbaString as ne, toAlphaSliderColor as te, parseColorAlpha as j, formatAlphaPercent as oe } from "../../_utils/color.js";
7
+ import se from "../form-input/Input.js";
8
+ import re from "../form-input-number/InputNumber.js";
9
+ import ie from "../button/Button.js";
10
+ import ue from "../../icons/default/check.js";
11
+ import ce from "./sv-panel.js";
12
+ import he from "./gradient-slider.js";
13
+ const de = "linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red)", xe = /* @__PURE__ */ F({
12
14
  name: "ColorPickerPanel",
13
15
  props: {
16
+ id: String,
17
+ ariaLabel: String,
14
18
  value: {
15
19
  type: Object,
16
20
  required: !0
@@ -52,256 +56,281 @@ const he = "linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, re
52
56
  }
53
57
  },
54
58
  emits: {
55
- change: (a, h) => !0,
56
- confirm: (a) => !0,
59
+ change: (l, r) => !0,
60
+ confirm: (l) => !0,
57
61
  clear: () => !0,
58
62
  close: () => !0
59
63
  },
60
- setup(a, {
61
- emit: h
64
+ setup(l, {
65
+ emit: r,
66
+ expose: k
62
67
  }) {
63
- const y = Q("color-picker"), d = z(a.modes[0] ?? "hex"), u = z(_(a.value)), c = z(a.value.a);
64
- j(() => a.value, (e) => {
65
- const l = _(e);
66
- (Math.abs(l.h - u.value.h) > 0.5 || Math.abs(l.s - u.value.s) > 0.5 || Math.abs(l.v - u.value.v) > 0.5) && (u.value = l), Math.abs(e.a - c.value) > 1e-3 && (c.value = e.a);
67
- }), j(() => a.modes, (e) => {
68
- e.length && !e.includes(d.value) && (d.value = e[0]);
68
+ const A = Z("color-picker");
69
+ J(W, {});
70
+ const M = B(), v = () => {
71
+ const e = M.value;
72
+ e && (Y(e)[0] ?? e).focus();
73
+ };
74
+ k({
75
+ focus: v
76
+ }), Q(() => {
77
+ var e, a;
78
+ ((e = document.activeElement) == null ? void 0 : e.getAttribute("aria-controls")) === ((a = M.value) == null ? void 0 : a.id) && v();
79
+ });
80
+ const g = B(l.modes[0] ?? "hex"), u = B($(l.value)), h = B(l.value.a);
81
+ D(() => l.value, (e) => {
82
+ const a = $(e);
83
+ (Math.abs(a.h - u.value.h) > 0.5 || Math.abs(a.s - u.value.s) > 0.5 || Math.abs(a.v - u.value.v) > 0.5) && (u.value = a), Math.abs(e.a - h.value) > 1e-3 && (h.value = e.a);
84
+ }), D(() => l.modes, (e) => {
85
+ e.length && !e.includes(g.value) && (g.value = e[0]);
69
86
  });
70
- const n = b(() => {
71
- const [e, l, s] = Y(u.value);
87
+ const t = f(() => {
88
+ const [e, a, s] = le(u.value);
72
89
  return {
73
90
  r: e,
74
- g: l,
91
+ g: a,
75
92
  b: s,
76
- a: a.showAlpha ? c.value : 1
93
+ a: l.showAlpha ? h.value : 1
77
94
  };
78
- }), m = (e, l) => h("change", e, l), H = (e) => {
79
- u.value = e, m(n.value);
80
- }, S = (e) => {
95
+ }), m = (e, a) => r("change", e, a), P = (e) => {
96
+ u.value = e, m(t.value);
97
+ }, w = (e) => {
81
98
  u.value = {
82
99
  ...u.value,
83
100
  h: e / 100 * 360
84
- }, m(n.value);
85
- }, B = (e) => {
86
- c.value = e / 100, m(n.value);
87
- }, I = b(() => `linear-gradient(to right, ${Z({
88
- ...n.value,
101
+ }, m(t.value);
102
+ }, R = (e) => {
103
+ h.value = e / 100, m(t.value);
104
+ }, V = f(() => `linear-gradient(to right, ${ne({
105
+ ...t.value,
89
106
  a: 0
90
- })}, ${ee(n.value)})`), k = b(() => E(n.value, "hex", a.showAlpha)), p = (e, l) => {
91
- u.value = _(e), c.value = e.a, m({
107
+ })}, ${te(t.value)})`), E = f(() => _(t.value, "hex", l.showAlpha)), p = (e, a) => {
108
+ u.value = $(e), h.value = e.a, m({
92
109
  ...e,
93
- a: a.showAlpha ? e.a : 1
94
- }, l);
95
- }, P = (e) => {
96
- const l = G(e);
97
- l && p(l);
98
- }, V = b(() => [Math.round(n.value.r), Math.round(n.value.g), Math.round(n.value.b)]), w = b(() => {
110
+ a: l.showAlpha ? e.a : 1
111
+ }, a);
112
+ }, N = (e) => {
113
+ const a = j(e);
114
+ a && p(a);
115
+ }, L = f(() => [Math.round(t.value.r), Math.round(t.value.g), Math.round(t.value.b)]), x = f(() => {
99
116
  const {
100
117
  h: e,
101
- s: l,
118
+ s: a,
102
119
  l: s
103
- } = W([Math.round(n.value.r), Math.round(n.value.g), Math.round(n.value.b)]);
104
- return [Math.round(e), Math.round(l), Math.round(s)];
105
- }), N = (e, l, s) => {
120
+ } = ee([Math.round(t.value.r), Math.round(t.value.g), Math.round(t.value.b)]);
121
+ return [Math.round(e), Math.round(a), Math.round(s)];
122
+ }), T = (e, a, s) => {
106
123
  if (s === void 0) return;
107
124
  if (e === "rgb") {
108
- const i = {
109
- ...n.value
125
+ const c = {
126
+ ...t.value
110
127
  };
111
- l === 0 ? i.r = s : l === 1 ? i.g = s : i.b = s, p(i);
128
+ a === 0 ? c.r = s : a === 1 ? c.g = s : c.b = s, p(c);
112
129
  return;
113
130
  }
114
- const [T, U, A] = w.value, v = {
115
- h: T,
116
- s: U,
117
- l: A
131
+ const [z, C, i] = x.value, d = {
132
+ h: z,
133
+ s: C,
134
+ l: i
118
135
  };
119
- l === 0 ? v.h = s : l === 1 ? v.s = s : v.l = s;
120
- const [f, r, M] = X(v);
136
+ a === 0 ? d.h = s : a === 1 ? d.s = s : d.l = s;
137
+ const [H, I, G] = ae(d);
121
138
  p({
122
- r: f,
123
- g: r,
124
- b: M,
125
- a: n.value.a
139
+ r: H,
140
+ g: I,
141
+ b: G,
142
+ a: t.value.a
126
143
  });
127
- }, R = b(() => E(n.value, "hex", a.showAlpha));
144
+ }, S = f(() => _(t.value, "hex", l.showAlpha));
128
145
  return {
129
- className: y,
130
- activeMode: d,
146
+ className: A,
147
+ panelRef: M,
148
+ focus: v,
149
+ activeMode: g,
131
150
  hsv: u,
132
- alpha: c,
133
- rgba: n,
134
- hexValue: k,
135
- rgbChannels: V,
136
- hslChannels: w,
137
- activeSwatch: R,
138
- alphaBackground: I,
139
- handleHsvChange: H,
140
- handleHueChange: S,
141
- handleAlphaChange: B,
142
- handleHexInput: P,
143
- handleChannelChange: N,
144
- handleSwatchClick: (e, l) => {
145
- const s = G(e);
146
- s && p(s, l);
151
+ alpha: h,
152
+ rgba: t,
153
+ hexValue: E,
154
+ rgbChannels: L,
155
+ hslChannels: x,
156
+ activeSwatch: S,
157
+ alphaBackground: V,
158
+ handleHsvChange: P,
159
+ handleHueChange: w,
160
+ handleAlphaChange: R,
161
+ handleHexInput: N,
162
+ handleChannelChange: T,
163
+ handleSwatchClick: (e, a) => {
164
+ const s = j(e);
165
+ s && p(s, a);
147
166
  },
148
- confirm: () => h("confirm", n.value),
149
- clear: () => h("clear"),
150
- close: () => h("close"),
151
- formatAlphaPercent: ae,
152
- HUE_GRADIENT: he,
153
- Input: le,
154
- InputNumber: ne,
155
- Button: te,
156
- IconCheck: oe,
157
- SvPanel: se,
158
- GradientSlider: re,
159
- parseColorAlpha: G
167
+ confirm: () => r("confirm", t.value),
168
+ clear: () => r("clear"),
169
+ close: () => r("close"),
170
+ formatAlphaPercent: oe,
171
+ HUE_GRADIENT: de,
172
+ Input: se,
173
+ InputNumber: re,
174
+ Button: ie,
175
+ IconCheck: ue,
176
+ SvPanel: ce,
177
+ GradientSlider: he,
178
+ parseColorAlpha: j
160
179
  };
161
180
  },
162
181
  render() {
163
182
  const {
164
- className: a,
165
- activeMode: h,
166
- hsv: y,
167
- alpha: d,
168
- rgba: u,
169
- hexValue: c,
170
- rgbChannels: n,
171
- hslChannels: m,
172
- activeSwatch: H,
173
- alphaBackground: S,
174
- handleHsvChange: B,
175
- handleHueChange: I,
176
- handleAlphaChange: k,
177
- handleHexInput: p,
178
- handleChannelChange: P,
179
- handleSwatchClick: V,
180
- confirm: w,
183
+ className: l,
184
+ activeMode: r,
185
+ hsv: k,
186
+ alpha: A,
187
+ rgba: M,
188
+ hexValue: v,
189
+ rgbChannels: g,
190
+ hslChannels: u,
191
+ activeSwatch: h,
192
+ alphaBackground: t,
193
+ handleHsvChange: m,
194
+ handleHueChange: P,
195
+ handleAlphaChange: w,
196
+ handleHexInput: R,
197
+ handleChannelChange: V,
198
+ handleSwatchClick: E,
199
+ confirm: p,
181
200
  clear: N,
182
- formatAlphaPercent: R,
183
- HUE_GRADIENT: L,
184
- Input: e,
185
- InputNumber: l,
186
- Button: s,
187
- IconCheck: T,
188
- SvPanel: U,
189
- GradientSlider: A,
190
- parseColorAlpha: v,
191
- showAlpha: f,
192
- disabled: r,
193
- swatches: M,
194
- showConfirm: i,
195
- showClear: $,
196
- modes: D,
197
- texts: g
198
- } = this, O = h === "rgb" ? n : m, q = h === "rgb" ? 255 : void 0;
201
+ formatAlphaPercent: L,
202
+ HUE_GRADIENT: x,
203
+ Input: T,
204
+ InputNumber: S,
205
+ Button: U,
206
+ IconCheck: e,
207
+ SvPanel: a,
208
+ GradientSlider: s,
209
+ parseColorAlpha: z,
210
+ showAlpha: C,
211
+ disabled: i,
212
+ swatches: d,
213
+ showConfirm: H,
214
+ showClear: I,
215
+ modes: G,
216
+ texts: c
217
+ } = this, K = r === "rgb" ? g : u, O = r === "rgb" ? 255 : void 0;
199
218
  return o("div", {
200
- class: [a.element("panel"), {
201
- [a.is("disabled")]: r
219
+ ref: "panelRef",
220
+ id: this.id,
221
+ "aria-label": this.ariaLabel,
222
+ role: "dialog",
223
+ tabindex: -1,
224
+ class: [l.element("panel"), {
225
+ [l.is("disabled")]: i
202
226
  }],
203
- onKeydown: (t) => {
204
- t.key === "Escape" && (t.stopPropagation(), this.close());
227
+ onKeydown: (n) => {
228
+ n.key === "Escape" && (n.stopPropagation(), this.close());
205
229
  }
206
230
  }, [o("div", {
207
- class: a.element("panel-body")
208
- }, [o(U, {
209
- value: y,
210
- disabled: r,
211
- onChange: B,
212
- ariaLabel: g.saturation
231
+ class: l.element("panel-body")
232
+ }, [o(a, {
233
+ value: k,
234
+ disabled: i,
235
+ onChange: m,
236
+ ariaLabel: c.saturation
213
237
  }, null), o("div", {
214
- class: a.element("sliders")
215
- }, [o(A, {
216
- value: y.h / 360 * 100,
217
- background: L,
218
- disabled: r,
219
- ariaLabel: g.hue,
220
- onChange: I
221
- }, null), f && o(A, {
222
- value: d * 100,
223
- background: S,
224
- disabled: r,
225
- ariaLabel: g.alpha,
226
- onChange: k
238
+ class: l.element("sliders")
239
+ }, [o(s, {
240
+ value: k.h / 360 * 100,
241
+ background: x,
242
+ disabled: i,
243
+ ariaLabel: c.hue,
244
+ onChange: P
245
+ }, null), C && o(s, {
246
+ value: A * 100,
247
+ background: t,
248
+ disabled: i,
249
+ ariaLabel: c.alpha,
250
+ onChange: w
227
251
  }, null)]), o("div", {
228
- class: a.element("modes")
229
- }, [D.map((t) => o("button", {
230
- key: t,
252
+ class: l.element("modes")
253
+ }, [G.map((n) => o("button", {
254
+ key: n,
231
255
  type: "button",
232
- class: [a.element("mode"), {
233
- [a.is("active")]: h === t
256
+ class: [l.element("mode"), {
257
+ [l.is("active")]: r === n
234
258
  }],
235
- disabled: r,
259
+ disabled: i,
236
260
  onClick: () => {
237
- this.activeMode = t;
261
+ this.activeMode = n;
238
262
  }
239
- }, [t.toUpperCase()]))]), o("div", {
240
- class: a.element("inputs")
241
- }, [h === "hex" ? o(e, {
263
+ }, [n.toUpperCase()]))]), o("div", {
264
+ class: l.element("inputs")
265
+ }, [r === "hex" ? o(T, {
242
266
  size: "small",
243
- disabled: r,
244
- modelValue: c,
267
+ disabled: i,
268
+ modelValue: v,
245
269
  maxLength: 9,
246
- "onUpdate:modelValue": (t) => p(t)
247
- }, null) : o(J, null, [O.map((t, C) => o(l, {
248
- key: `${h}-${C}`,
249
- class: a.element("channel"),
270
+ "aria-label": "HEX",
271
+ "onUpdate:modelValue": (n) => R(n)
272
+ }, null) : o(X, null, [K.map((n, b) => o(S, {
273
+ key: `${r}-${b}`,
274
+ class: l.element("channel"),
250
275
  size: "small",
251
276
  hideButton: !0,
252
277
  min: 0,
253
- max: q,
278
+ max: O,
254
279
  precision: 0,
255
- disabled: r,
256
- modelValue: t,
257
- "onUpdate:modelValue": (x) => P(h, C, x)
258
- }, null)), f && o(l, {
259
- class: a.element("channel"),
280
+ "aria-label": (r === "rgb" ? ["R", "G", "B"] : ["H", "S", "L"])[b],
281
+ disabled: i,
282
+ modelValue: n,
283
+ "onUpdate:modelValue": (y) => V(r, b, y)
284
+ }, null)), C && o(S, {
285
+ class: l.element("channel"),
260
286
  size: "small",
261
287
  hideButton: !0,
262
288
  min: 0,
263
289
  max: 100,
264
290
  precision: 0,
265
- disabled: r,
266
- modelValue: R(d),
267
- "onUpdate:modelValue": (t) => {
268
- t !== void 0 && k(t);
291
+ disabled: i,
292
+ "aria-label": c.alpha,
293
+ modelValue: L(A),
294
+ "onUpdate:modelValue": (n) => {
295
+ n !== void 0 && w(n);
269
296
  }
270
- }, null)])]), M.length > 0 && o("div", {
271
- class: a.element("swatches")
272
- }, [M.map((t) => {
273
- const C = v(t), x = C ? E(C, "hex", f) === H : !1;
297
+ }, null)])]), d.length > 0 && o("div", {
298
+ class: l.element("swatches")
299
+ }, [d.map((n) => {
300
+ const b = z(n), y = b ? _(b, "hex", C) === h : !1;
274
301
  return o("button", {
275
- key: t,
302
+ key: n,
276
303
  type: "button",
277
- class: [a.element("swatch"), {
278
- [a.is("active")]: x
304
+ class: [l.element("swatch"), {
305
+ [l.is("active")]: y
279
306
  }],
307
+ "aria-label": n,
308
+ "aria-pressed": y,
280
309
  style: {
281
- backgroundColor: t
310
+ backgroundColor: n
282
311
  },
283
- disabled: r,
284
- onClick: (F) => V(t, F)
285
- }, [x && o(T, null, null)]);
286
- })])]), (i || $) && o("div", {
287
- class: a.element("panel-footer")
288
- }, [$ && o(s, {
312
+ disabled: i,
313
+ onClick: (q) => E(n, q)
314
+ }, [y && o(e, null, null)]);
315
+ })])]), (H || I) && o("div", {
316
+ class: l.element("panel-footer")
317
+ }, [I && o(U, {
289
318
  size: "small",
290
319
  type: "text",
291
- disabled: r,
320
+ disabled: i,
292
321
  onClick: N
293
322
  }, {
294
- default: () => [g.clear]
295
- }), i && o(s, {
323
+ default: () => [c.clear]
324
+ }), H && o(U, {
296
325
  size: "small",
297
326
  type: "primary",
298
- disabled: r,
299
- onClick: w
327
+ disabled: i,
328
+ onClick: p
300
329
  }, {
301
- default: () => [g.confirm]
330
+ default: () => [c.confirm]
302
331
  })])]);
303
332
  }
304
333
  });
305
334
  export {
306
- Ce as default
335
+ xe as default
307
336
  };
@@ -1,7 +1,8 @@
1
- import { defineComponent as $, ref as g, computed as d, watch as L, createVNode as s } from "vue";
1
+ import { defineComponent as M, ref as y, computed as u, toRef as x, createVNode as r } from "vue";
2
+ import { usePointerDrag as $ } from "../../_hooks/use-pointer-drag.js";
2
3
  import { getClassNameMixin as k } from "../../_utils/config.js";
3
4
  import { hsvToRgb as C } from "../../_utils/color.js";
4
- const E = /* @__PURE__ */ $({
5
+ const D = /* @__PURE__ */ M({
5
6
  name: "ColorPickerSvPanel",
6
7
  props: {
7
8
  /** h 0-360,s/v 0-100 */
@@ -22,78 +23,78 @@ const E = /* @__PURE__ */ $({
22
23
  change: (e) => !0
23
24
  },
24
25
  setup(e, {
25
- emit: v
26
+ emit: d
26
27
  }) {
27
- const l = k("color-picker"), m = g(), i = g(!1), b = d(() => {
28
- const [t, a, o] = C({
28
+ const l = k("color-picker"), c = y(), v = u(() => {
29
+ const [n, t, i] = C({
29
30
  h: e.value.h,
30
31
  s: 100,
31
32
  v: 100
32
33
  });
33
- return `rgb(${t}, ${a}, ${o})`;
34
- }), w = d(() => ({
35
- backgroundColor: b.value
36
- })), M = d(() => ({
34
+ return `rgb(${n}, ${t}, ${i})`;
35
+ }), m = u(() => ({
36
+ backgroundColor: v.value
37
+ })), f = u(() => ({
37
38
  left: `${e.value.s}%`,
38
39
  top: `${100 - e.value.v}%`
39
- })), h = (t, a) => {
40
- const o = m.value;
41
- if (!o || e.disabled) return;
42
- const n = o.getBoundingClientRect();
43
- if (!n.width || !n.height) return;
44
- const u = Math.min(Math.max(t - n.left, 0), n.width), c = Math.min(Math.max(a - n.top, 0), n.height);
45
- v("change", {
40
+ })), g = (n, t) => {
41
+ const i = c.value;
42
+ if (!i || e.disabled) return;
43
+ const a = i.getBoundingClientRect();
44
+ if (!a.width || !a.height) return;
45
+ const o = Math.min(Math.max(n - a.left, 0), a.width), s = Math.min(Math.max(t - a.top, 0), a.height);
46
+ d("change", {
46
47
  h: e.value.h,
47
- s: u / n.width * 100,
48
- v: (1 - c / n.height) * 100
48
+ s: o / a.width * 100,
49
+ v: (1 - s / a.height) * 100
49
50
  });
50
- }, f = (t) => {
51
- h(t.clientX, t.clientY);
52
- }, r = () => {
53
- i.value = !1, document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", r);
54
- }, y = (t) => {
55
- e.disabled || (t.preventDefault(), i.value = !0, h(t.clientX, t.clientY), document.addEventListener("mousemove", f), document.addEventListener("mouseup", r));
56
- }, x = (t) => {
51
+ }, {
52
+ dragging: b,
53
+ start: h
54
+ } = $(x(e, "disabled"), g), w = (n) => {
57
55
  if (e.disabled) return;
58
- const a = t.shiftKey ? 10 : 1, n = {
59
- ArrowLeft: [-a, 0],
60
- ArrowRight: [a, 0],
61
- ArrowUp: [0, a],
62
- ArrowDown: [0, -a]
63
- }[t.key];
64
- if (!n) return;
65
- t.preventDefault();
66
- const u = Math.min(Math.max(e.value.s + n[0], 0), 100), c = Math.min(Math.max(e.value.v + n[1], 0), 100);
67
- v("change", {
56
+ const t = n.shiftKey ? 10 : 1, a = {
57
+ ArrowLeft: [-t, 0],
58
+ ArrowRight: [t, 0],
59
+ ArrowUp: [0, t],
60
+ ArrowDown: [0, -t]
61
+ }[n.key];
62
+ if (!a) return;
63
+ n.preventDefault();
64
+ const o = Math.min(Math.max(e.value.s + a[0], 0), 100), s = Math.min(Math.max(e.value.v + a[1], 0), 100);
65
+ d("change", {
68
66
  h: e.value.h,
69
- s: u,
70
- v: c
67
+ s: o,
68
+ v: s
71
69
  });
72
70
  };
73
- return L(() => e.disabled, (t) => {
74
- t && r();
75
- }), () => s("div", {
76
- ref: m,
71
+ return () => r("div", {
72
+ ref: c,
77
73
  class: [l.element("sv"), {
78
- [l.is("dragging")]: i.value
74
+ [l.is("dragging")]: b.value
79
75
  }],
80
- style: w.value,
76
+ style: m.value,
81
77
  role: "slider",
82
78
  "aria-label": e.ariaLabel,
79
+ "aria-valuemin": 0,
80
+ "aria-valuemax": 100,
81
+ "aria-valuenow": Math.round(e.value.s),
83
82
  "aria-valuetext": `${Math.round(e.value.s)}%, ${Math.round(e.value.v)}%`,
83
+ "aria-disabled": e.disabled || void 0,
84
84
  tabindex: e.disabled ? -1 : 0,
85
- onMousedown: y,
86
- onKeydown: x
87
- }, [s("div", {
85
+ onPointerdown: h,
86
+ onMousedown: h,
87
+ onKeydown: w
88
+ }, [r("div", {
88
89
  class: l.element("sv-white")
89
- }, null), s("div", {
90
+ }, null), r("div", {
90
91
  class: l.element("sv-black")
91
- }, null), s("div", {
92
+ }, null), r("div", {
92
93
  class: l.element("sv-handler"),
93
- style: M.value
94
+ style: f.value
94
95
  }, null)]);
95
96
  }
96
97
  });
97
98
  export {
98
- E as default
99
+ D as default
99
100
  };