@w-run/wdesign-ui 1.0.0 → 1.1.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 (213) hide show
  1. package/README.md +208 -127
  2. package/dist/index.d.ts +1010 -80
  3. package/dist/parts/WdAffix.js +159 -0
  4. package/dist/parts/WdAiMessage.js +277 -0
  5. package/dist/parts/WdAlert.js +92 -0
  6. package/dist/parts/WdAnchor.js +159 -0
  7. package/dist/parts/WdAudioPlayer.js +1024 -0
  8. package/dist/parts/WdAvatar.js +6 -0
  9. package/dist/parts/WdAvatarGroup.js +46 -0
  10. package/dist/parts/WdBacktop.js +120 -0
  11. package/dist/parts/WdBadge.js +61 -0
  12. package/dist/parts/WdBento.js +40 -0
  13. package/dist/parts/WdBentoItem.js +43 -0
  14. package/dist/parts/WdBottomSheet.js +263 -0
  15. package/dist/parts/WdBreadcrumb.js +64 -0
  16. package/dist/parts/WdButton.js +94 -0
  17. package/dist/parts/WdCalendar.js +11 -0
  18. package/dist/parts/WdCard.js +113 -0
  19. package/dist/parts/WdCarousel.js +365 -0
  20. package/dist/parts/WdCascader.js +386 -0
  21. package/dist/parts/WdCheckbox.js +81 -0
  22. package/dist/parts/WdCollapse.js +135 -0
  23. package/dist/parts/WdColorPicker.js +592 -0
  24. package/dist/parts/WdCommand.js +357 -0
  25. package/dist/parts/WdContainer.js +37 -0
  26. package/dist/parts/WdCountdown.js +163 -0
  27. package/dist/parts/WdDanmaku.js +6 -0
  28. package/dist/parts/WdDatePicker.js +169 -0
  29. package/dist/parts/WdDateTimePicker.js +162 -0
  30. package/dist/parts/WdDescriptions.js +146 -0
  31. package/dist/parts/WdDivider.js +64 -0
  32. package/dist/parts/WdDrawer.js +176 -0
  33. package/dist/parts/WdDropdown.js +140 -0
  34. package/dist/parts/WdEmpty.js +79 -0
  35. package/dist/parts/WdExplorer.js +336 -0
  36. package/dist/parts/WdFileList.js +177 -0
  37. package/dist/parts/WdForm.js +111 -0
  38. package/dist/parts/WdFormItem.js +156 -0
  39. package/dist/parts/WdGrid.js +40 -0
  40. package/dist/parts/WdGroup.js +68 -0
  41. package/dist/parts/WdImagePreview.js +274 -0
  42. package/dist/parts/WdInput.js +10 -0
  43. package/dist/parts/WdInputNumber.js +253 -0
  44. package/dist/parts/WdListItem.js +60 -0
  45. package/dist/parts/WdLoading.js +128 -0
  46. package/dist/parts/WdMarkdown.js +172 -0
  47. package/dist/parts/WdMarquee.js +80 -0
  48. package/dist/parts/WdMasonry.js +40 -0
  49. package/dist/parts/WdMediaCard.js +302 -0
  50. package/dist/parts/WdMentions.js +277 -0
  51. package/dist/parts/WdModal.js +149 -0
  52. package/dist/parts/WdNav.js +311 -0
  53. package/dist/parts/WdNotification.js +112 -0
  54. package/dist/parts/WdOtp.js +107 -0
  55. package/dist/parts/WdPagination.js +252 -0
  56. package/dist/parts/WdPopconfirm.js +214 -0
  57. package/dist/parts/WdPopover.js +203 -0
  58. package/dist/parts/WdPostItem.js +84 -0
  59. package/dist/parts/WdProgress.js +48 -0
  60. package/dist/parts/WdProgressRing.js +101 -0
  61. package/dist/parts/WdPullRefresh.js +167 -0
  62. package/dist/parts/WdQRCode.js +1909 -0
  63. package/dist/parts/WdRadioGroup.js +95 -0
  64. package/dist/parts/WdRate.js +128 -0
  65. package/dist/parts/WdResult.js +86 -0
  66. package/dist/parts/WdScrollbar.js +186 -0
  67. package/dist/parts/WdSegmented.js +11 -0
  68. package/dist/parts/WdSelect.js +465 -0
  69. package/dist/parts/WdSkeleton.js +69 -0
  70. package/dist/parts/WdSlider.js +100 -0
  71. package/dist/parts/WdSortableList.js +291 -0
  72. package/dist/parts/WdSpace.js +46 -0
  73. package/dist/parts/WdSparkline.js +148 -0
  74. package/dist/parts/WdSpinner.js +6 -0
  75. package/dist/parts/WdSplitter.js +183 -0
  76. package/dist/parts/WdStatBar.js +202 -0
  77. package/dist/parts/WdStatistic.js +131 -0
  78. package/dist/parts/WdSteps.js +110 -0
  79. package/dist/parts/WdSwitch.js +63 -0
  80. package/dist/parts/WdTabBar.js +84 -0
  81. package/dist/parts/WdTable.js +589 -0
  82. package/dist/parts/WdTabs.js +219 -0
  83. package/dist/parts/WdTag.js +6 -0
  84. package/dist/parts/WdTagInput.js +181 -0
  85. package/dist/parts/WdTimePicker.js +12 -0
  86. package/dist/parts/WdTimeline.js +145 -0
  87. package/dist/parts/WdTooltip.js +108 -0
  88. package/dist/parts/WdTour.js +264 -0
  89. package/dist/parts/WdTransfer.js +446 -0
  90. package/dist/parts/WdTree.js +322 -0
  91. package/dist/parts/WdUpload.js +309 -0
  92. package/dist/parts/WdVideoPlayer.js +1006 -0
  93. package/dist/parts/WdVirtualList.js +169 -0
  94. package/dist/parts/WdWatermark.js +150 -0
  95. package/dist/parts/chunk-3LVE72ZK.js +361 -0
  96. package/dist/parts/chunk-5HYOQ52I.js +101 -0
  97. package/dist/parts/chunk-7M3MUL3B.js +275 -0
  98. package/dist/parts/chunk-AOTJ63HN.js +15 -0
  99. package/dist/parts/chunk-AXEF2U2A.js +41 -0
  100. package/dist/parts/chunk-CY3QOSFP.js +645 -0
  101. package/dist/parts/chunk-G7NN4A6J.js +40 -0
  102. package/dist/parts/chunk-HAKYCUAR.js +9 -0
  103. package/dist/parts/chunk-JDE4AHBR.js +160 -0
  104. package/dist/parts/chunk-LT3NTWIT.js +117 -0
  105. package/dist/parts/chunk-OGHYFT7B.js +387 -0
  106. package/dist/parts/chunk-Q34U2HES.js +261 -0
  107. package/dist/parts/chunk-RLSVPJHM.js +10 -0
  108. package/dist/parts/chunk-U2CDKD2T.js +30 -0
  109. package/dist/parts/chunk-UYUNYHZD.js +40 -0
  110. package/dist/parts/chunk-VUJL2HGD.js +23 -0
  111. package/dist/parts/chunk-WCFG5KNT.js +51 -0
  112. package/dist/parts/chunk-WDDAALPI.js +42 -0
  113. package/dist/parts/chunk-WFXLDBP2.js +149 -0
  114. package/dist/style/affix.css +566 -0
  115. package/dist/style/ai-msg.css +572 -13
  116. package/dist/style/alert.css +577 -5
  117. package/dist/style/anchor.css +630 -0
  118. package/dist/style/audio.css +658 -67
  119. package/dist/style/avatar.css +575 -12
  120. package/dist/style/backtop.css +625 -0
  121. package/dist/style/badge.css +595 -11
  122. package/dist/style/bento.css +763 -0
  123. package/dist/style/bottom-sheet.css +776 -0
  124. package/dist/style/breadcrumb.css +579 -4
  125. package/dist/style/button.css +631 -36
  126. package/dist/style/calendar.css +1512 -0
  127. package/dist/style/card.css +683 -6
  128. package/dist/style/carousel.css +573 -4
  129. package/dist/style/cascader.css +862 -0
  130. package/dist/style/checkbox.css +584 -7
  131. package/dist/style/chevron.css +543 -1
  132. package/dist/style/collapse.css +586 -7
  133. package/dist/style/colorpicker.css +876 -0
  134. package/dist/style/command.css +572 -13
  135. package/dist/style/container.css +543 -0
  136. package/dist/style/countdown.css +722 -0
  137. package/dist/style/danmaku.css +644 -0
  138. package/dist/style/datepicker.css +606 -128
  139. package/dist/style/datetime-picker.css +714 -0
  140. package/dist/style/descriptions.css +604 -11
  141. package/dist/style/divider.css +544 -2
  142. package/dist/style/dot.css +556 -1
  143. package/dist/style/drawer.css +609 -11
  144. package/dist/style/dropdown.css +565 -3
  145. package/dist/style/empty.css +624 -3
  146. package/dist/style/explorer.css +632 -24
  147. package/dist/style/file-list.css +577 -5
  148. package/dist/style/flip.css +600 -0
  149. package/dist/style/form.css +550 -8
  150. package/dist/style/grid.css +614 -0
  151. package/dist/style/group.css +560 -16
  152. package/dist/style/icon-btn.css +570 -4
  153. package/dist/style/image-preview.css +652 -8
  154. package/dist/style/input-number.css +680 -0
  155. package/dist/style/input.css +571 -8
  156. package/dist/style/list.css +553 -4
  157. package/dist/style/loading.css +667 -0
  158. package/dist/style/markdown.css +592 -20
  159. package/dist/style/marquee.css +678 -0
  160. package/dist/style/masonry.css +614 -0
  161. package/dist/style/media-card.css +1229 -0
  162. package/dist/style/mentions.css +690 -0
  163. package/dist/style/modal.css +626 -15
  164. package/dist/style/nav.css +1046 -0
  165. package/dist/style/notification.css +556 -7
  166. package/dist/style/otp.css +567 -7
  167. package/dist/style/pagination.css +571 -11
  168. package/dist/style/popconfirm.css +568 -10
  169. package/dist/style/popover.css +645 -15
  170. package/dist/style/post-item.css +548 -6
  171. package/dist/style/progress-ring.css +640 -0
  172. package/dist/style/progress.css +543 -1
  173. package/dist/style/pull-refresh.css +637 -0
  174. package/dist/style/qrcode.css +613 -0
  175. package/dist/style/radio.css +584 -5
  176. package/dist/style/rate.css +594 -1
  177. package/dist/style/result.css +546 -3
  178. package/dist/style/scroll-reveal.css +613 -0
  179. package/dist/style/scrollbar.css +644 -0
  180. package/dist/style/segmented-picker.css +573 -14
  181. package/dist/style/segmented.css +711 -7
  182. package/dist/style/select.css +682 -26
  183. package/dist/style/skeleton.css +559 -0
  184. package/dist/style/slider.css +565 -4
  185. package/dist/style/sortable.css +593 -7
  186. package/dist/style/space.css +543 -0
  187. package/dist/style/sparkline.css +606 -0
  188. package/dist/style/spinner.css +559 -0
  189. package/dist/style/splitter.css +711 -0
  190. package/dist/style/stat-bar.css +767 -0
  191. package/dist/style/statistic.css +552 -7
  192. package/dist/style/steps.css +633 -9
  193. package/dist/style/switch.css +585 -4
  194. package/dist/style/tab-bar.css +647 -0
  195. package/dist/style/table.css +886 -36
  196. package/dist/style/tabs.css +599 -10
  197. package/dist/style/tag-input.css +710 -0
  198. package/dist/style/tag.css +603 -18
  199. package/dist/style/time-picker.css +749 -0
  200. package/dist/style/timeline.css +575 -14
  201. package/dist/style/toast.css +567 -6
  202. package/dist/style/tooltip.css +564 -5
  203. package/dist/style/tour.css +683 -0
  204. package/dist/style/transfer.css +858 -0
  205. package/dist/style/tree.css +613 -16
  206. package/dist/style/typography.css +884 -3
  207. package/dist/style/upload.css +602 -13
  208. package/dist/style/vlist.css +543 -1
  209. package/dist/style/vplayer.css +799 -57
  210. package/dist/style/watermark.css +570 -0
  211. package/dist/wdesign-ui.css +18055 -7262
  212. package/dist/wdesign-ui.esm.js +8976 -5044
  213. package/package.json +99 -13
@@ -0,0 +1,592 @@
1
+ import {
2
+ useOverlayLayer
3
+ } from "./chunk-5HYOQ52I.js";
4
+ import {
5
+ useAnchoredPosition,
6
+ useDismiss
7
+ } from "./chunk-WFXLDBP2.js";
8
+ import {
9
+ useFormItemA11y
10
+ } from "./chunk-VUJL2HGD.js";
11
+ import "./chunk-UYUNYHZD.js";
12
+ import {
13
+ WdIcon_default
14
+ } from "./chunk-Q34U2HES.js";
15
+
16
+ // .lib-build/WdColorPicker.ts
17
+ import { defineComponent as _defineComponent } from "vue";
18
+ import { unref as _unref, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createVNode as _createVNode, mergeProps as _mergeProps, renderList as _renderList, Fragment as _Fragment, Teleport as _Teleport, createBlock as _createBlock } from "vue";
19
+ import { computed, ref, watch } from "vue";
20
+ var _hoisted_1 = ["tabindex", "aria-label", "aria-expanded"];
21
+ var _hoisted_2 = {
22
+ key: 0,
23
+ class: "wd-colorpicker__value"
24
+ };
25
+ var _hoisted_3 = { class: "wd-colorpicker__inputs" };
26
+ var _hoisted_4 = ["value", "maxlength"];
27
+ var _hoisted_5 = { class: "wd-colorpicker__field" };
28
+ var _hoisted_6 = ["value"];
29
+ var _hoisted_7 = {
30
+ key: 0,
31
+ class: "wd-colorpicker__field wd-colorpicker__field--alpha"
32
+ };
33
+ var _hoisted_8 = ["value"];
34
+ var _hoisted_9 = { class: "wd-colorpicker__presets" };
35
+ var _hoisted_10 = ["aria-label", "onClick"];
36
+ var WdColorPicker_default = /* @__PURE__ */ _defineComponent({
37
+ ...{ name: "WdColorPicker" },
38
+ __name: "WdColorPicker",
39
+ props: {
40
+ modelValue: { type: String, required: false, default: void 0 },
41
+ defaultValue: { type: String, required: false, default: "#D62839" },
42
+ presets: { type: Array, required: false, default: () => [
43
+ "#D62839",
44
+ "#E8590C",
45
+ "#F2A93B",
46
+ "#4CAF50",
47
+ "#2E9E8F",
48
+ "#3B82F6",
49
+ "#6366F1",
50
+ "#8B5CF6",
51
+ "#D946A0",
52
+ "#191B1F",
53
+ "#6B7280",
54
+ "#FFFFFF"
55
+ ] },
56
+ editable: { type: Boolean, required: false, default: true },
57
+ showAlpha: { type: Boolean, required: false, default: false },
58
+ size: { type: String, required: false, default: "md" },
59
+ disabled: { type: Boolean, required: false, default: false }
60
+ },
61
+ emits: ["update:modelValue", "change"],
62
+ setup(__props, { emit: __emit }) {
63
+ const formA11y = useFormItemA11y();
64
+ const props = __props;
65
+ const emit = __emit;
66
+ const inner = ref(props.defaultValue);
67
+ const isControlled = computed(() => props.modelValue !== void 0);
68
+ function parseColor(input) {
69
+ if (!input) return null;
70
+ let v = input.trim().replace(/^#/, "");
71
+ if (/^[0-9a-f]{3,4}$/i.test(v)) v = v.split("").map((c) => c + c).join("");
72
+ if (!/^([0-9a-f]{6})([0-9a-f]{2})?$/i.test(v)) return null;
73
+ return {
74
+ rgb: "#" + v.slice(0, 6).toUpperCase(),
75
+ alpha: v.length === 8 ? parseInt(v.slice(6, 8), 16) : 255
76
+ };
77
+ }
78
+ function formatColor(rgb, alpha2) {
79
+ if (!props.showAlpha) return rgb;
80
+ const a = Math.round(Math.min(255, Math.max(0, alpha2))).toString(16).padStart(2, "0");
81
+ return rgb + a.toUpperCase();
82
+ }
83
+ const parsed = computed(() => parseColor(isControlled.value ? props.modelValue : inner.value) || { rgb: "#000000", alpha: 255 });
84
+ const color = computed(() => parsed.value.rgb);
85
+ const alpha = computed(() => parsed.value.alpha);
86
+ const alphaText = computed(() => Math.round(alpha.value / 255 * 100));
87
+ function commit(v, nextAlpha) {
88
+ const p = parseColor(v);
89
+ if (!p) return;
90
+ const out = formatColor(p.rgb, nextAlpha ?? p.alpha);
91
+ if (!isControlled.value) inner.value = out;
92
+ emit("update:modelValue", out);
93
+ emit("change", out);
94
+ }
95
+ function normalizeHex(input) {
96
+ if (!input) return null;
97
+ let s = input.trim().replace(/^#/, "");
98
+ if (/^[0-9a-f]{3}$/i.test(s)) {
99
+ s = s.split("").map((c) => c + c).join("");
100
+ }
101
+ if (!/^[0-9a-f]{6}$/i.test(s)) return null;
102
+ return "#" + s.toUpperCase();
103
+ }
104
+ function hexToRgb(hex) {
105
+ const s = hex.replace("#", "");
106
+ return {
107
+ r: parseInt(s.slice(0, 2), 16),
108
+ g: parseInt(s.slice(2, 4), 16),
109
+ b: parseInt(s.slice(4, 6), 16)
110
+ };
111
+ }
112
+ function rgbToHex(r, g, b) {
113
+ const h = (n) => Math.round(Math.max(0, Math.min(255, n))).toString(16).padStart(2, "0");
114
+ return ("#" + h(r) + h(g) + h(b)).toUpperCase();
115
+ }
116
+ function rgbToHsv(r, g, b) {
117
+ const rn = r / 255, gn = g / 255, bn = b / 255;
118
+ const max = Math.max(rn, gn, bn);
119
+ const min = Math.min(rn, gn, bn);
120
+ const d = max - min;
121
+ let h = 0;
122
+ if (d !== 0) {
123
+ if (max === rn) h = (gn - bn) / d % 6;
124
+ else if (max === gn) h = (bn - rn) / d + 2;
125
+ else h = (rn - gn) / d + 4;
126
+ h *= 60;
127
+ if (h < 0) h += 360;
128
+ }
129
+ return { h, s: max === 0 ? 0 : d / max, v: max };
130
+ }
131
+ function hsvToRgb(h, s, v) {
132
+ const c = v * s;
133
+ const hp = h % 360 / 60;
134
+ const x = c * (1 - Math.abs(hp % 2 - 1));
135
+ let r = 0, g = 0, b = 0;
136
+ if (hp < 1) {
137
+ r = c;
138
+ g = x;
139
+ } else if (hp < 2) {
140
+ r = x;
141
+ g = c;
142
+ } else if (hp < 3) {
143
+ g = c;
144
+ b = x;
145
+ } else if (hp < 4) {
146
+ g = x;
147
+ b = c;
148
+ } else if (hp < 5) {
149
+ r = x;
150
+ b = c;
151
+ } else {
152
+ r = c;
153
+ b = x;
154
+ }
155
+ const m = v - c;
156
+ return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 };
157
+ }
158
+ const localHsv = ref(null);
159
+ watch(
160
+ () => color.value,
161
+ (v) => {
162
+ const { r, g, b } = hexToRgb(v);
163
+ const next = rgbToHsv(r, g, b);
164
+ const cur = localHsv.value;
165
+ if (!cur || Math.abs(cur.h - next.h) > 0.5 || Math.abs(cur.s - next.s) > 0.01 || Math.abs(cur.v - next.v) > 0.01) {
166
+ localHsv.value = next;
167
+ }
168
+ },
169
+ { immediate: true }
170
+ );
171
+ const hsv = computed(() => localHsv.value ?? { h: 0, s: 0, v: 1 });
172
+ const hexText = ref("");
173
+ watch(
174
+ () => [color.value, alpha.value],
175
+ ([c, a]) => {
176
+ hexText.value = formatColor(c, a);
177
+ },
178
+ { immediate: true }
179
+ );
180
+ const open = ref(false);
181
+ const mounted = ref(false);
182
+ const rootEl = ref(null);
183
+ const panelEl = ref(null);
184
+ const { pos } = useAnchoredPosition(open, rootEl, panelEl, {
185
+ placement: "bottom-start",
186
+ gap: 8
187
+ });
188
+ const panelStyle = computed(() => ({
189
+ top: pos.value.top + "px",
190
+ left: pos.value.left + "px"
191
+ }));
192
+ function toggle() {
193
+ if (props.disabled) return;
194
+ if (open.value) close();
195
+ else {
196
+ mounted.value = true;
197
+ open.value = true;
198
+ }
199
+ }
200
+ function close() {
201
+ open.value = false;
202
+ window.setTimeout(() => {
203
+ if (!open.value) mounted.value = false;
204
+ }, 200);
205
+ }
206
+ useDismiss([rootEl, panelEl], close, open);
207
+ useOverlayLayer(open, panelEl, () => {
208
+ close();
209
+ return true;
210
+ });
211
+ const svEl = ref(null);
212
+ let svDragging = false;
213
+ function updateSv(e) {
214
+ const el = svEl.value;
215
+ if (!el) return;
216
+ const r = el.getBoundingClientRect();
217
+ const s = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
218
+ const v = 1 - Math.min(1, Math.max(0, (e.clientY - r.top) / r.height));
219
+ localHsv.value = { ...hsv.value, s, v };
220
+ const { r: rr, g, b } = hsvToRgb(hsv.value.h, s, v);
221
+ commit(rgbToHex(rr, g, b));
222
+ }
223
+ function onSvDown(e) {
224
+ svDragging = true;
225
+ e.target.setPointerCapture?.(e.pointerId);
226
+ updateSv(e);
227
+ }
228
+ function onSvMove(e) {
229
+ if (svDragging) updateSv(e);
230
+ }
231
+ function onSvUp(e) {
232
+ svDragging = false;
233
+ e.target.releasePointerCapture?.(e.pointerId);
234
+ }
235
+ const hueEl = ref(null);
236
+ let hueDragging = false;
237
+ function updateHue(e) {
238
+ const el = hueEl.value;
239
+ if (!el) return;
240
+ const r = el.getBoundingClientRect();
241
+ const h = Math.min(359.999, Math.max(0, (e.clientX - r.left) / r.width * 360));
242
+ localHsv.value = { ...hsv.value, h };
243
+ const { r: rr, g, b } = hsvToRgb(h, hsv.value.s, hsv.value.v);
244
+ commit(rgbToHex(rr, g, b));
245
+ }
246
+ function onHueDown(e) {
247
+ hueDragging = true;
248
+ e.target.setPointerCapture?.(e.pointerId);
249
+ updateHue(e);
250
+ }
251
+ function onHueMove(e) {
252
+ if (hueDragging) updateHue(e);
253
+ }
254
+ function onHueUp(e) {
255
+ hueDragging = false;
256
+ e.target.releasePointerCapture?.(e.pointerId);
257
+ }
258
+ const alphaEl = ref(null);
259
+ let alphaDragging = false;
260
+ function updateAlpha(e) {
261
+ const el = alphaEl.value;
262
+ if (!el) return;
263
+ const r = el.getBoundingClientRect();
264
+ const ratio = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));
265
+ commit(color.value, Math.round(ratio * 255));
266
+ }
267
+ function onAlphaDown(e) {
268
+ alphaDragging = true;
269
+ e.target.setPointerCapture?.(e.pointerId);
270
+ updateAlpha(e);
271
+ }
272
+ function onAlphaMove(e) {
273
+ if (alphaDragging) updateAlpha(e);
274
+ }
275
+ function onAlphaUp(e) {
276
+ alphaDragging = false;
277
+ e.target.releasePointerCapture?.(e.pointerId);
278
+ }
279
+ function onAlphaInput(e) {
280
+ const v = Number(e.target.value);
281
+ if (Number.isNaN(v)) return;
282
+ commit(color.value, Math.round(Math.min(100, Math.max(0, v)) / 100 * 255));
283
+ }
284
+ function onHexInput(e) {
285
+ const raw = e.target.value;
286
+ hexText.value = raw;
287
+ const p = parseColor(raw);
288
+ if (p) {
289
+ const { r, g, b } = hexToRgb(p.rgb);
290
+ localHsv.value = rgbToHsv(r, g, b);
291
+ commit(p.rgb, p.alpha);
292
+ }
293
+ }
294
+ function onHexBlur() {
295
+ hexText.value = formatColor(color.value, alpha.value);
296
+ }
297
+ const rgbText = computed(() => {
298
+ const { r, g, b } = hexToRgb(color.value);
299
+ return `${r}, ${g}, ${b}`;
300
+ });
301
+ function pickPreset(c) {
302
+ const n = normalizeHex(c);
303
+ if (!n) return;
304
+ const { r, g, b } = hexToRgb(n);
305
+ localHsv.value = rgbToHsv(r, g, b);
306
+ commit(n);
307
+ }
308
+ const pureHue = computed(() => {
309
+ const { r, g, b } = hsvToRgb(hsv.value.h, 1, 1);
310
+ return rgbToHex(r, g, b);
311
+ });
312
+ const alphaLeft = computed(() => alpha.value / 255 * 100 + "%");
313
+ const knobs = computed(() => ({
314
+ svLeft: `${hsv.value.s * 100}%`,
315
+ svTop: `${(1 - hsv.value.v) * 100}%`,
316
+ hueLeft: `${hsv.value.h / 360 * 100}%`
317
+ }));
318
+ const sizePx = computed(() => ({ sm: 28, md: 34, lg: 42 })[props.size]);
319
+ const swatchColor = computed(() => {
320
+ const { r, g, b } = hexToRgb(color.value);
321
+ return "rgba(" + r + ", " + g + ", " + b + ", " + (alpha.value / 255).toFixed(3) + ")";
322
+ });
323
+ const alphaGradient = computed(() => {
324
+ const { r, g, b } = hexToRgb(color.value);
325
+ return "linear-gradient(to right, rgba(" + r + ", " + g + ", " + b + ", 0), rgb(" + r + ", " + g + ", " + b + "))";
326
+ });
327
+ function onKeydown(e) {
328
+ if (e.key === "Escape") close();
329
+ else if (e.key === "Enter" || e.key === " ") {
330
+ e.preventDefault();
331
+ toggle();
332
+ }
333
+ }
334
+ return (_ctx, _cache) => {
335
+ return _openBlock(), _createElementBlock(
336
+ _Fragment,
337
+ null,
338
+ [
339
+ _createElementVNode("div", _mergeProps({
340
+ ref_key: "rootEl",
341
+ ref: rootEl,
342
+ class: ["wd-colorpicker", [`wd-colorpicker--${__props.size}`, { "is-open": open.value, "is-disabled": __props.disabled }]],
343
+ tabindex: __props.disabled ? -1 : 0,
344
+ role: "button",
345
+ "aria-label": `\u989C\u8272 ${color.value}`,
346
+ "aria-expanded": open.value,
347
+ onClick: toggle,
348
+ onKeydown
349
+ }, { ..._ctx.$attrs, ..._unref(formA11y).attrs.value }), [
350
+ _createElementVNode(
351
+ "span",
352
+ {
353
+ class: _normalizeClass(["wd-colorpicker__swatch", { "wd-colorpicker__swatch--alpha": __props.showAlpha }]),
354
+ style: _normalizeStyle({ backgroundColor: swatchColor.value, width: sizePx.value + "px", height: sizePx.value + "px" })
355
+ },
356
+ [
357
+ _createCommentVNode(" \u6D45\u8272\u7CFB\u7684\u8272\u5757\u5728\u767D\u5E95\u4E0A\u770B\u4E0D\u6E05\u8FB9\u754C\uFF0C\u52A0\u4E00\u5708\u5185\u63CF\u8FB9\u538B\u4F4F "),
358
+ _cache[0] || (_cache[0] = _createElementVNode(
359
+ "span",
360
+ { class: "wd-colorpicker__swatch-inner" },
361
+ null,
362
+ -1
363
+ /* CACHED */
364
+ ))
365
+ ],
366
+ 6
367
+ /* CLASS, STYLE */
368
+ ),
369
+ __props.editable ? (_openBlock(), _createElementBlock(
370
+ "span",
371
+ _hoisted_2,
372
+ _toDisplayString(color.value),
373
+ 1
374
+ /* TEXT */
375
+ )) : _createCommentVNode("v-if", true),
376
+ _createVNode(_unref(WdIcon_default), {
377
+ class: "wd-colorpicker__caret",
378
+ name: "chevron-down",
379
+ size: 14
380
+ })
381
+ ], 16, _hoisted_1),
382
+ (_openBlock(), _createBlock(_Teleport, { to: "body" }, [
383
+ mounted.value ? (_openBlock(), _createElementBlock(
384
+ "div",
385
+ {
386
+ key: 0,
387
+ ref_key: "panelEl",
388
+ ref: panelEl,
389
+ class: _normalizeClass(["wd-colorpicker__panel", { "is-open": open.value }]),
390
+ style: _normalizeStyle(panelStyle.value),
391
+ role: "group",
392
+ "aria-label": "\u9009\u62E9\u989C\u8272"
393
+ },
394
+ [
395
+ _createCommentVNode(" \u9971\u548C\u5EA6/\u660E\u5EA6\u9762\u677F\uFF1A\u767D\u2192\u8272\u76F8\u3001\u900F\u660E\u2192\u9ED1 \u4E24\u5C42\u6E10\u53D8\u53E0\u52A0 "),
396
+ _createElementVNode(
397
+ "div",
398
+ {
399
+ ref_key: "svEl",
400
+ ref: svEl,
401
+ class: "wd-colorpicker__sv",
402
+ style: _normalizeStyle({ background: pureHue.value }),
403
+ onPointerdown: onSvDown,
404
+ onPointermove: onSvMove,
405
+ onPointerup: onSvUp,
406
+ onPointercancel: onSvUp
407
+ },
408
+ [
409
+ _cache[1] || (_cache[1] = _createElementVNode(
410
+ "span",
411
+ { class: "wd-colorpicker__sv-white" },
412
+ null,
413
+ -1
414
+ /* CACHED */
415
+ )),
416
+ _cache[2] || (_cache[2] = _createElementVNode(
417
+ "span",
418
+ { class: "wd-colorpicker__sv-black" },
419
+ null,
420
+ -1
421
+ /* CACHED */
422
+ )),
423
+ _createElementVNode(
424
+ "span",
425
+ {
426
+ class: "wd-colorpicker__knob",
427
+ style: _normalizeStyle({ left: knobs.value.svLeft, top: knobs.value.svTop })
428
+ },
429
+ null,
430
+ 4
431
+ /* STYLE */
432
+ )
433
+ ],
434
+ 36
435
+ /* STYLE, NEED_HYDRATION */
436
+ ),
437
+ _createCommentVNode(" \u8272\u76F8\u6761 "),
438
+ _createElementVNode(
439
+ "div",
440
+ {
441
+ ref_key: "hueEl",
442
+ ref: hueEl,
443
+ class: "wd-colorpicker__hue",
444
+ onPointerdown: onHueDown,
445
+ onPointermove: onHueMove,
446
+ onPointerup: onHueUp,
447
+ onPointercancel: onHueUp
448
+ },
449
+ [
450
+ _createElementVNode(
451
+ "span",
452
+ {
453
+ class: "wd-colorpicker__knob wd-colorpicker__knob--hue",
454
+ style: _normalizeStyle({ left: knobs.value.hueLeft })
455
+ },
456
+ null,
457
+ 4
458
+ /* STYLE */
459
+ )
460
+ ],
461
+ 544
462
+ /* NEED_HYDRATION, NEED_PATCH */
463
+ ),
464
+ _createCommentVNode(" \u900F\u660E\u5EA6\u6761\uFF08showAlpha \u65F6\u624D\u51FA\u73B0\uFF09\uFF1A\u68CB\u76D8\u683C\u886C\u5E95 + \u5F53\u524D\u8272\u4ECE\u900F\u660E\u5230\u5B9E\u8272 "),
465
+ __props.showAlpha ? (_openBlock(), _createElementBlock(
466
+ "div",
467
+ {
468
+ key: 0,
469
+ ref_key: "alphaEl",
470
+ ref: alphaEl,
471
+ class: "wd-colorpicker__alpha",
472
+ onPointerdown: onAlphaDown,
473
+ onPointermove: onAlphaMove,
474
+ onPointerup: onAlphaUp,
475
+ onPointercancel: onAlphaUp
476
+ },
477
+ [
478
+ _createElementVNode(
479
+ "span",
480
+ {
481
+ class: "wd-colorpicker__alpha-fill",
482
+ style: _normalizeStyle({ backgroundImage: alphaGradient.value })
483
+ },
484
+ null,
485
+ 4
486
+ /* STYLE */
487
+ ),
488
+ _createElementVNode(
489
+ "span",
490
+ {
491
+ class: "wd-colorpicker__knob wd-colorpicker__knob--hue",
492
+ style: _normalizeStyle({ left: alphaLeft.value, background: color.value })
493
+ },
494
+ null,
495
+ 4
496
+ /* STYLE */
497
+ )
498
+ ],
499
+ 544
500
+ /* NEED_HYDRATION, NEED_PATCH */
501
+ )) : _createCommentVNode("v-if", true),
502
+ _createCommentVNode(" \u8272\u503C\u8F93\u5165 "),
503
+ _createElementVNode("div", _hoisted_3, [
504
+ _createElementVNode(
505
+ "label",
506
+ {
507
+ class: _normalizeClass(["wd-colorpicker__field", { "wd-colorpicker__field--hex": __props.showAlpha }])
508
+ },
509
+ [
510
+ _cache[3] || (_cache[3] = _createElementVNode(
511
+ "span",
512
+ null,
513
+ "HEX",
514
+ -1
515
+ /* CACHED */
516
+ )),
517
+ _createElementVNode("input", {
518
+ value: hexText.value,
519
+ maxlength: __props.showAlpha ? 9 : 7,
520
+ spellcheck: "false",
521
+ onInput: onHexInput,
522
+ onBlur: onHexBlur
523
+ }, null, 40, _hoisted_4)
524
+ ],
525
+ 2
526
+ /* CLASS */
527
+ ),
528
+ _createElementVNode("label", _hoisted_5, [
529
+ _cache[4] || (_cache[4] = _createElementVNode(
530
+ "span",
531
+ null,
532
+ "RGB",
533
+ -1
534
+ /* CACHED */
535
+ )),
536
+ _createElementVNode("input", {
537
+ value: rgbText.value,
538
+ readonly: ""
539
+ }, null, 8, _hoisted_6)
540
+ ]),
541
+ __props.showAlpha ? (_openBlock(), _createElementBlock("label", _hoisted_7, [
542
+ _cache[5] || (_cache[5] = _createElementVNode(
543
+ "span",
544
+ null,
545
+ "A",
546
+ -1
547
+ /* CACHED */
548
+ )),
549
+ _createElementVNode("input", {
550
+ value: alphaText.value,
551
+ type: "number",
552
+ min: "0",
553
+ max: "100",
554
+ "aria-label": "\u900F\u660E\u5EA6\u767E\u5206\u6BD4",
555
+ onChange: onAlphaInput
556
+ }, null, 40, _hoisted_8)
557
+ ])) : _createCommentVNode("v-if", true)
558
+ ]),
559
+ _createCommentVNode(" \u9884\u8BBE "),
560
+ _createElementVNode("div", _hoisted_9, [
561
+ (_openBlock(true), _createElementBlock(
562
+ _Fragment,
563
+ null,
564
+ _renderList(__props.presets, (c) => {
565
+ return _openBlock(), _createElementBlock("button", {
566
+ key: c,
567
+ type: "button",
568
+ class: _normalizeClass(["wd-colorpicker__preset", { "is-active": normalizeHex(c) === color.value }]),
569
+ style: _normalizeStyle({ background: c }),
570
+ "aria-label": c,
571
+ onClick: ($event) => pickPreset(c)
572
+ }, null, 14, _hoisted_10);
573
+ }),
574
+ 128
575
+ /* KEYED_FRAGMENT */
576
+ ))
577
+ ])
578
+ ],
579
+ 6
580
+ /* CLASS, STYLE */
581
+ )) : _createCommentVNode("v-if", true)
582
+ ]))
583
+ ],
584
+ 64
585
+ /* STABLE_FRAGMENT */
586
+ );
587
+ };
588
+ }
589
+ });
590
+ export {
591
+ WdColorPicker_default as WdColorPicker
592
+ };