@opentiny/vue-renderless 3.19.5 → 3.20.1

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 (77) hide show
  1. package/base-select/index.js +11 -74
  2. package/base-select/vue.js +10 -10
  3. package/bulletin-board/index.js +5 -1
  4. package/bulletin-board/vue.js +5 -4
  5. package/button/index.js +11 -3
  6. package/button/vue.js +6 -2
  7. package/button-group/index.js +1 -1
  8. package/color-picker/index.js +4 -4
  9. package/color-picker/utils/color.js +358 -83
  10. package/color-picker/utils/hsv-to-rgb.js +59 -0
  11. package/color-picker/vue.js +27 -8
  12. package/color-select-panel/alpha-select/index.js +65 -14
  13. package/color-select-panel/alpha-select/vue.js +29 -44
  14. package/color-select-panel/hue-select/index.js +47 -61
  15. package/color-select-panel/hue-select/vue.js +29 -47
  16. package/color-select-panel/index.js +230 -80
  17. package/color-select-panel/sv-select/index.js +68 -0
  18. package/color-select-panel/sv-select/vue.js +32 -0
  19. package/color-select-panel/utils/color.js +345 -82
  20. package/color-select-panel/utils/getClientXY.js +54 -0
  21. package/color-select-panel/vue.js +47 -72
  22. package/common/deps/popper.js +1 -1
  23. package/common/deps/useUserAgent.js +16 -0
  24. package/common/event.js +21 -0
  25. package/common/index.js +1 -1
  26. package/common/runtime.js +1 -1
  27. package/date-picker-mobile/index.js +4 -4
  28. package/dialog-box/index.js +1 -1
  29. package/dropdown/index.js +5 -1
  30. package/dropdown/vue.js +2 -2
  31. package/file-upload/vue.js +1 -0
  32. package/flowchart/index.js +3 -2
  33. package/form/index.js +2 -2
  34. package/form-item/index.js +4 -1
  35. package/grid-select/index.js +82 -0
  36. package/grid-select/vue.js +30 -0
  37. package/input/index.js +2 -2
  38. package/menu/vue.js +5 -1
  39. package/modal/index.js +2 -0
  40. package/numeric/index.js +29 -9
  41. package/option/index.js +6 -0
  42. package/option/vue.js +12 -2
  43. package/package.json +1 -1
  44. package/picker/index.js +1 -1
  45. package/recycle-scroller/index.js +43 -27
  46. package/recycle-scroller/vue.js +9 -4
  47. package/rich-text/index.js +13 -0
  48. package/rich-text/vue.js +4 -2
  49. package/select/index.js +71 -23
  50. package/select/vue.js +12 -4
  51. package/select-dropdown/vue.js +1 -1
  52. package/tabbar/index.js +4 -1
  53. package/tabbar/vue.js +1 -1
  54. package/tabs/index.js +8 -5
  55. package/tabs/vue.js +4 -1
  56. package/time-panel/vue.js +1 -1
  57. package/tooltip/vue.js +1 -0
  58. package/tree-menu/index.js +5 -1
  59. package/tree-node/index.js +5 -4
  60. package/tree-select/index.js +77 -1
  61. package/tree-select/vue.js +21 -7
  62. package/types/button.type.d.ts +7 -3
  63. package/types/color-select-panel.type.d.ts +23 -1
  64. package/types/file-upload.type.d.ts +1 -1
  65. package/types/input.type.d.ts +1 -1
  66. package/types/numeric.type.d.ts +5 -5
  67. package/types/popover.type.d.ts +1 -1
  68. package/types/transfer.type.d.ts +3 -3
  69. package/types/tree-menu.type.d.ts +1 -1
  70. package/types/upload-dragger.type.d.ts +1 -1
  71. package/types/{upload-list.type-26173587.d.ts → upload-list.type-6189e4c9.d.ts} +7 -3
  72. package/types/upload-list.type.d.ts +1 -1
  73. package/types/upload.type.d.ts +1 -1
  74. package/types/user-head.type.d.ts +4 -0
  75. package/user-head/index.js +1 -1
  76. package/year-table/index.js +14 -29
  77. package/year-table/vue.js +17 -5
@@ -0,0 +1,32 @@
1
+ import "../../chunk-G2ADBYYC.js";
2
+ import { draggable } from "../utils/use-drag";
3
+ import { initState, initWatch, useDrag, useUpdate } from "./index";
4
+ const api = ["state", "wrapper", "cursor"];
5
+ const renderless = (props, hooks, utils) => {
6
+ const state = initState(props, hooks);
7
+ const { ref, onMounted } = hooks;
8
+ const { emit } = utils;
9
+ const wrapper = ref();
10
+ const update = useUpdate(state, props, wrapper);
11
+ const onDrag = useDrag(state, wrapper, props, utils);
12
+ initWatch(state, update, hooks);
13
+ onMounted(() => {
14
+ const drag = {
15
+ drag: (event) => {
16
+ onDrag(event);
17
+ },
18
+ end: (event) => {
19
+ onDrag(event);
20
+ }
21
+ };
22
+ draggable(wrapper.value, drag);
23
+ update();
24
+ emit("ready", update);
25
+ });
26
+ const api2 = { state, wrapper };
27
+ return api2;
28
+ };
29
+ export {
30
+ api,
31
+ renderless
32
+ };
@@ -1,102 +1,365 @@
1
1
  import "../../chunk-G2ADBYYC.js";
2
- import { hsv, rgb } from "color";
3
- function hexToRgb(hex) {
4
- let r = parseInt(hex.substring(1, 3), 16);
5
- let g = parseInt(hex.substring(3, 5), 16);
6
- let b = parseInt(hex.substring(5, 7), 16);
7
- let a = parseInt(hex.slice(7), 16) / 255;
8
- return { r, g, b, a: a * 100 };
9
- }
10
- const normalizeHexColor = (color) => {
11
- let normalizedColor = color.replace("#", "");
12
- if (normalizedColor.length === 3) {
13
- normalizedColor = normalizedColor.split("").map((char) => char + char).join("");
14
- }
15
- normalizedColor = normalizedColor.padEnd(6, "0");
16
- const r = parseInt(normalizedColor.substr(0, 2), 16);
17
- const g = parseInt(normalizedColor.substr(2, 2), 16);
18
- const b = parseInt(normalizedColor.substr(4, 2), 16);
19
- let a = 255;
20
- if (normalizedColor.length === 8) {
21
- a = parseInt(normalizedColor.slice(6), 16);
22
- }
23
- const hexR = ("0" + r.toString(16)).slice(-2);
24
- const hexG = ("0" + g.toString(16)).slice(-2);
25
- const hexB = ("0" + b.toString(16)).slice(-2);
26
- const alpha = ("0" + a.toString(16)).slice(-2);
27
- return `#${hexR}${hexG}${hexB}${alpha}`;
2
+ const INT_HEX_MAP = {
3
+ 10: "A",
4
+ 11: "B",
5
+ 12: "C",
6
+ 13: "D",
7
+ 14: "E",
8
+ 15: "F"
9
+ };
10
+ const HEX_INT_MAP = {
11
+ A: 10,
12
+ B: 11,
13
+ C: 12,
14
+ D: 13,
15
+ E: 14,
16
+ F: 15
17
+ };
18
+ const parseHex = function(hex) {
19
+ if (hex.length === 2) {
20
+ return (HEX_INT_MAP[hex[0].toUpperCase()] || +hex[0]) * 16 + (HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1]);
21
+ }
22
+ return HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1];
23
+ };
24
+ const hsv2hsl = ({ hue, sat, val }) => {
25
+ const hue_ = (2 - sat) * val;
26
+ return [hue, sat * val / (hue_ < 1 ? hue_ : 2 - hue_) || 0, hue_ / 2];
27
+ };
28
+ const isString = (val) => typeof val === "string";
29
+ const isOnePointZero = (n) => {
30
+ return isString(n) && n.includes(".") && Number.parseFloat(n) === 1;
31
+ };
32
+ const isPercentage = (n) => {
33
+ return isString(n) && n.includes("%");
34
+ };
35
+ const normalized = (value, max) => {
36
+ if (isOnePointZero(value))
37
+ value = "100%";
38
+ const processPercent = isPercentage(value);
39
+ value = Math.min(max, Math.max(0, Number.parseFloat(`${value}`)));
40
+ if (processPercent) {
41
+ value = Number.parseInt(`${value * max}`, 10) / 100;
42
+ }
43
+ if (Math.abs(value - max) < 1e-6) {
44
+ return 1;
45
+ }
46
+ return value % max / Number.parseFloat(max);
47
+ };
48
+ const hexOne = (value) => {
49
+ value = Math.min(Math.round(value), 255);
50
+ const high = Math.floor(value / 16);
51
+ const low = value % 16;
52
+ return `${INT_HEX_MAP[high] || high}${INT_HEX_MAP[low] || low}`;
53
+ };
54
+ const toHex = ({ r, g, b }) => {
55
+ if (Number.isNaN(+r) || Number.isNaN(+g) || Number.isNaN(+b))
56
+ return "";
57
+ return `#${hexOne(r)}${hexOne(g)}${hexOne(b)}`;
58
+ };
59
+ const hsl2hsv = ({ hue, sat, light }) => {
60
+ sat = sat / 100;
61
+ light = light / 100;
62
+ let smin = sat;
63
+ const lmin = Math.max(light, 0.01);
64
+ light *= 2;
65
+ sat *= light <= 1 ? light : 2 - light;
66
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
67
+ const v = (light + sat) / 2;
68
+ const sv = light === 0 ? 2 * smin / (lmin + smin) : 2 * sat / (light + sat);
69
+ return {
70
+ h: hue,
71
+ s: sv * 100,
72
+ v: v * 100
73
+ };
74
+ };
75
+ const rgb2hsv = ({ r, g, b }) => {
76
+ r = normalized(r, 255);
77
+ g = normalized(g, 255);
78
+ b = normalized(b, 255);
79
+ const max = Math.max(r, g, b);
80
+ const min = Math.min(r, g, b);
81
+ let h;
82
+ const v = max;
83
+ const d = max - min;
84
+ const s = max === 0 ? 0 : d / max;
85
+ if (max === min) {
86
+ h = 0;
87
+ } else {
88
+ switch (max) {
89
+ case r: {
90
+ h = (g - b) / d + (g < b ? 6 : 0);
91
+ break;
92
+ }
93
+ case g: {
94
+ h = (b - r) / d + 2;
95
+ break;
96
+ }
97
+ case b: {
98
+ h = (r - g) / d + 4;
99
+ break;
100
+ }
101
+ }
102
+ h /= 6;
103
+ }
104
+ return { h: h * 360, s: s * 100, v: v * 100 };
105
+ };
106
+ const hsv2rgb = ({ h, s, v }) => {
107
+ h = normalized(h, 360) * 6;
108
+ s = normalized(s, 100);
109
+ v = normalized(v, 100);
110
+ const i = Math.floor(h);
111
+ const f = h - i;
112
+ const p = v * (1 - s);
113
+ const q = v * (1 - f * s);
114
+ const t = v * (1 - (1 - f) * s);
115
+ const mod = i % 6;
116
+ const r = [v, q, p, p, t, v][mod];
117
+ const g = [t, v, v, q, p, p][mod];
118
+ const b = [p, p, t, v, v, q][mod];
119
+ return {
120
+ r: Math.round(r * 255),
121
+ g: Math.round(g * 255),
122
+ b: Math.round(b * 255)
123
+ };
28
124
  };
29
125
  class Color {
30
- constructor(value, alpha = false) {
31
- this.hex = "#000";
32
- this.h = 0;
33
- this.s = 0;
34
- this.v = 0;
35
- this.a = 100;
36
- this.preH = 0;
126
+ constructor(opts) {
127
+ this._hue = 0;
128
+ this._sat = 100;
129
+ this._value = 100;
130
+ this._alpha = 100;
37
131
  this.enableAlpha = false;
38
- this.reset(value);
39
- this.enableAlpha = alpha;
40
- }
41
- reset(hex) {
42
- if (this.hex === "transparent") {
43
- this.h = 0;
44
- this.s = 0;
45
- this.v = 0;
46
- this.a = 0;
132
+ this.format = "hex";
133
+ this.value = "";
134
+ for (const opt in opts) {
135
+ if (opt in opts) {
136
+ this[opt] = opts[opt];
137
+ }
138
+ }
139
+ if (opts.value) {
140
+ this.fromString(opts.value);
141
+ } else {
142
+ this.onChange();
143
+ }
144
+ }
145
+ get(prop) {
146
+ if (prop === "alpha") {
147
+ return Math.floor(this._alpha);
148
+ }
149
+ return this[`_${prop}`];
150
+ }
151
+ set(props, value) {
152
+ if (arguments.length === 1 && typeof props === "object") {
153
+ for (const p in props) {
154
+ if (Object.hasOwn(props, p)) {
155
+ this.set(p, props[p]);
156
+ }
157
+ }
47
158
  return;
48
159
  }
49
- this.hex = normalizeHexColor(hex);
50
- const { r, g, b, a } = hexToRgb(this.hex);
51
- const { h, s, v } = rgb([r, g, b, a]).hsv().object();
52
- this.preH = h;
53
- this.h = h;
54
- this.s = s;
55
- this.v = v;
56
- this.a = a;
160
+ this[`_${props}`] = value;
161
+ this.onChange();
57
162
  }
58
- set({ h, s, v, a }) {
59
- this.h = h != null ? h : this.h;
60
- this.s = s != null ? s : this.s;
61
- this.v = v != null ? v : this.v;
62
- this.a = a != null ? a : this.a;
163
+ compare(color) {
164
+ return Math.abs(color._hue - this._hue) < 2 && Math.abs(color._sat - this._sat) < 1 && Math.abs(color._value - this._value) < 1 && Math.abs(color._alpha - this._alpha) < 1;
63
165
  }
64
- setPrevH(val) {
65
- this.preH = val;
166
+ isHSL(value) {
167
+ return value.includes("hsl");
66
168
  }
67
- /**
68
- *
69
- * @returns [R,G,B]
70
- */
71
- getRGB() {
72
- return hsv(this.h, this.s, this.v).rgb().array();
169
+ isHsv(value) {
170
+ return value.includes("hsv");
171
+ }
172
+ isRgb(value) {
173
+ return value.includes("rgb");
73
174
  }
74
- getHex() {
75
- if (!this.enableAlpha) {
76
- return hsv(this.h, this.s, this.v).hex().toString();
175
+ isHex(value) {
176
+ return value.includes("#");
177
+ }
178
+ splitPart(value, regExp) {
179
+ return value.replace(regExp, "").split(/\s|,/g).filter((v) => v).map((val, idx) => {
180
+ return idx > 2 ? Number.parseFloat(val) : Number.parseInt(val, 10);
181
+ });
182
+ }
183
+ onHsv(value) {
184
+ const parts = this.splitPart(value, /hsva|hsv|\(|\)/gm);
185
+ if (parts.length === 4) {
186
+ this._alpha = Number.parseFloat(String(parts[3])) * 100;
187
+ } else {
188
+ this._alpha = 100;
189
+ }
190
+ if (parts.length >= 3) {
191
+ this.fromHSV({
192
+ h: parts[0],
193
+ s: parts[1],
194
+ v: parts[2]
195
+ });
196
+ }
197
+ }
198
+ onRgb(value) {
199
+ const rgbRegExp = /rgba|rgb|\(|\)/gm;
200
+ const parts = this.splitPart(value, rgbRegExp);
201
+ if (parts.length === 4) {
202
+ this._alpha = Number.parseFloat(String(parts[3])) * 100;
203
+ } else {
204
+ this._alpha = 100;
205
+ }
206
+ if (parts.length >= 3) {
207
+ const { h, s, v } = rgb2hsv({ r: parts[0], g: parts[1], b: parts[2] });
208
+ this.fromHSV({ h, s, v });
209
+ }
210
+ }
211
+ onHex(value) {
212
+ const hex = value.replace("#", "").trim();
213
+ const isValidHex = (hex2) => /^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{8}$/.test(hex2);
214
+ if (!isValidHex(hex)) {
215
+ return;
216
+ }
217
+ let [r, g, b] = [0, 0, 0];
218
+ if (hex.length === 3) {
219
+ r = parseHex(hex[0] + hex[0]);
220
+ g = parseHex(hex[1] + hex[1]);
221
+ b = parseHex(hex[2] + hex[2]);
222
+ } else if (hex.length === 6 || hex.length === 8) {
223
+ r = parseHex(hex.slice(0, 2));
224
+ g = parseHex(hex.slice(2, 4));
225
+ b = parseHex(hex.slice(4, 6));
226
+ }
227
+ if (hex.length === 8) {
228
+ this._alpha = parseHex(hex.slice(6)) / 255 * 100;
229
+ } else if (hex.length === 3 || hex.length === 6) {
230
+ this._alpha = 100;
231
+ }
232
+ const { h, s, v } = rgb2hsv({ r, g, b });
233
+ this.fromHSV({ h, s, v });
234
+ }
235
+ onHsl(value) {
236
+ const parts = value.replace(/hsla|hsl\(|\)gm/, "").split(/\s|,/g).filter((val) => val).map((val, idx) => {
237
+ return idx > 2 ? Number.parseFloat(val) : Number.parseInt(val, 10);
238
+ });
239
+ if (parts.length === 4) {
240
+ this._alpha = Number.parseFloat(String(parts[3])) * 100;
241
+ } else {
242
+ this._alpha = 100;
243
+ }
244
+ if (parent.length >= 3) {
245
+ const { h, s, v } = hsl2hsv({
246
+ hue: parts[0],
247
+ sat: parts[1],
248
+ light: parts[2]
249
+ });
250
+ this.fromHSV({ h, s, v });
77
251
  }
78
- return hsv(this.h, this.s, this.v, this.a / 100).hexa().toString();
79
252
  }
80
253
  /**
81
- *
82
- * @returns [h,s,l]
254
+ * @effect 会修改 this._hue, this._sat, this._value
83
255
  */
84
- getHSL() {
85
- return hsv(this.h, this.s, this.v).hsl().unitArray();
256
+ fromHSV({ h, s, v }) {
257
+ this._hue = Math.max(0, Math.min(360, h));
258
+ this._sat = Math.max(0, Math.min(100, s));
259
+ this._value = Math.max(0, Math.min(100, v));
260
+ this.onChange();
261
+ }
262
+ fromString(value) {
263
+ if (!value) {
264
+ this._hue = 0;
265
+ this._sat = 0;
266
+ this._value = 0;
267
+ this.onChange();
268
+ return;
269
+ }
270
+ if (this.isHSL(value)) {
271
+ this.onHsl(value);
272
+ }
273
+ if (this.isHsv(value)) {
274
+ this.onHsv(value);
275
+ }
276
+ if (this.isRgb(value)) {
277
+ this.onRgb(value);
278
+ }
279
+ if (this.isHex(value)) {
280
+ this.onHex(value);
281
+ }
86
282
  }
87
- getHSV() {
88
- return {
89
- h: this.h,
90
- s: this.s,
91
- v: this.v,
92
- a: this.a
93
- };
283
+ toRgb() {
284
+ return hsv2rgb({
285
+ h: this._hue,
286
+ s: this._sat,
287
+ v: this._value
288
+ });
94
289
  }
95
- get(key) {
96
- return this[key];
290
+ onChange() {
291
+ const { _hue, _sat, _value, _alpha, format, enableAlpha } = this;
292
+ if (!enableAlpha) {
293
+ switch (format) {
294
+ case "hsl": {
295
+ let [_, sat, light] = hsv2hsl({
296
+ hue: _hue,
297
+ sat: _sat / 100,
298
+ val: _value / 100
299
+ });
300
+ sat = Math.round(sat * 100);
301
+ light = Math.round(light * 100);
302
+ this.value = `hsl(${_hue}, ${sat}%, ${light}%)`;
303
+ break;
304
+ }
305
+ case "hsv": {
306
+ this.value = `hsv(${_hue}, ${Math.round(_sat)}%, ${Math.round(_value)}%)`;
307
+ break;
308
+ }
309
+ case "rgb": {
310
+ const { r, g, b } = hsv2rgb({ h: _hue, s: _sat, v: _value });
311
+ this.value = `rgb(${r},${g},${b})`;
312
+ break;
313
+ }
314
+ default: {
315
+ this.value = toHex(
316
+ hsv2rgb({
317
+ h: _hue,
318
+ s: _sat,
319
+ v: _value
320
+ })
321
+ );
322
+ }
323
+ }
324
+ return;
325
+ }
326
+ switch (format) {
327
+ case "hsl": {
328
+ let [_, sat, light] = hsv2hsl({
329
+ hue: _hue,
330
+ sat: _sat / 100,
331
+ val: _value / 100
332
+ });
333
+ sat = Math.round(sat * 100);
334
+ light = Math.round(light * 100);
335
+ this.value = `hsla(${_hue}, ${sat}%, ${light}%, ${this.get("alpha") / 100})`;
336
+ break;
337
+ }
338
+ case "hsv": {
339
+ this.value = `hsva(${_hue}, ${Math.round(_sat)}%, ${Math.round(_value)}%, ${this.get("alpha") / 100})`;
340
+ break;
341
+ }
342
+ case "hex": {
343
+ this.value = `${toHex(
344
+ hsv2rgb({
345
+ h: _hue,
346
+ s: _sat,
347
+ v: _value
348
+ })
349
+ )}${hexOne(_alpha * 255 / 100)}`;
350
+ break;
351
+ }
352
+ default: {
353
+ const { r, g, b } = hsv2rgb({
354
+ h: _hue,
355
+ s: _sat,
356
+ v: _value
357
+ });
358
+ this.value = `rgba(${r}, ${g}, ${b}, ${this.get("alpha") / 100})`;
359
+ }
360
+ }
97
361
  }
98
362
  }
99
363
  export {
100
- Color as default,
101
- normalizeHexColor
364
+ Color
102
365
  };
@@ -0,0 +1,54 @@
1
+ import "../../chunk-G2ADBYYC.js";
2
+ const isInContainer = (el, container) => {
3
+ if (!el || !container)
4
+ return false;
5
+ const elRect = el.getBoundingClientRect();
6
+ let containerRect;
7
+ if (container instanceof Element) {
8
+ containerRect = container.getBoundingClientRect();
9
+ } else {
10
+ containerRect = {
11
+ top: 0,
12
+ right: window.innerWidth,
13
+ bottom: window.innerHeight,
14
+ left: 0
15
+ };
16
+ }
17
+ return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right;
18
+ };
19
+ const getOffsetTop = (el) => {
20
+ let offset = 0;
21
+ let parent = el;
22
+ while (parent) {
23
+ offset += parent.offsetTop;
24
+ parent = parent.offsetParent;
25
+ }
26
+ return offset;
27
+ };
28
+ const getOffsetTopDistance = (el, containerEl) => {
29
+ return Math.abs(getOffsetTop(el) - getOffsetTop(containerEl));
30
+ };
31
+ const getClientXY = (event) => {
32
+ let clientX;
33
+ let clientY;
34
+ if (event.type === "touchend") {
35
+ clientY = event.changedTouches[0].clientY;
36
+ clientX = event.changedTouches[0].clientX;
37
+ } else if (event.type.startsWith("touch")) {
38
+ clientY = event.touches[0].clientY;
39
+ clientX = event.touches[0].clientX;
40
+ } else {
41
+ clientY = event.clientY;
42
+ clientX = event.clientX;
43
+ }
44
+ return {
45
+ clientX,
46
+ clientY
47
+ };
48
+ };
49
+ export {
50
+ getClientXY,
51
+ getOffsetTop,
52
+ getOffsetTopDistance,
53
+ isInContainer
54
+ };
@@ -1,85 +1,60 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import Color from "./utils/color";
3
- import { onConfirm, onCancel, onHSVUpdate, onAlphaUpdate, handleHistoryClick, handlePredefineClick } from ".";
2
+ import { initApi, initState, initWatch } from "./index";
4
3
  const api = [
5
4
  "state",
6
- "changeVisible",
7
- "cursor",
8
- "onColorUpdate",
9
- "onHueUpdate",
10
- "onSVUpdate",
5
+ "open",
6
+ "close",
7
+ "resetColor",
11
8
  "onConfirm",
12
9
  "onCancel",
13
- "onAlphaUpdate",
10
+ "submitValue",
11
+ "clear",
12
+ "onHueReady",
13
+ "onSvReady",
14
+ "onAlphaReady",
15
+ "onPredefineColorClick",
14
16
  "onHistoryClick",
15
- "onPredefineColorClick"
17
+ "onClickOutside"
16
18
  ];
17
- const renderless = (props, context, { emit }) => {
18
- var _a, _b, _c, _d, _e, _f;
19
- const { modelValue, visible, history, predefine } = context.toRefs(props);
20
- const hex = context.ref((_a = modelValue == null ? void 0 : modelValue.value) != null ? _a : "transparent");
21
- const res = context.ref((_b = modelValue == null ? void 0 : modelValue.value) != null ? _b : "transparent");
22
- const pre = context.ref(res.value);
23
- const triggerBg = context.ref((_c = modelValue == null ? void 0 : modelValue.value) != null ? _c : "transparent");
24
- const isShow = context.ref((_d = visible == null ? void 0 : visible.value) != null ? _d : false);
25
- const cursor = context.ref();
26
- const stack = context.ref([...(_e = history == null ? void 0 : history.value) != null ? _e : []]);
27
- const predefineStack = context.ref([...(_f = predefine == null ? void 0 : predefine.value) != null ? _f : []]);
28
- const enableHistory = history == null ? void 0 : history.value;
29
- const enablePredefineColor = predefine == null ? void 0 : predefine.value;
30
- const changeVisible = (state2) => {
31
- isShow.value = state2;
32
- };
33
- const color = context.ref(new Color(hex.value, props.alpha));
34
- const state = context.reactive({
35
- isShow,
36
- hex,
37
- color,
38
- triggerBg,
39
- defaultValue: modelValue,
40
- res,
41
- stack,
42
- predefineStack,
43
- enableHistory,
44
- enablePredefineColor
45
- });
46
- context.watch(
47
- predefine,
48
- (newPredefine) => {
49
- predefineStack.value = [...newPredefine];
50
- },
51
- { deep: true }
52
- );
53
- context.watch(
54
- history,
55
- (newHistory) => {
56
- stack.value = [...newHistory];
57
- },
58
- { deep: true }
59
- );
60
- context.watch(modelValue, (newValue) => {
61
- hex.value = newValue;
62
- res.value = newValue;
63
- color.value.reset(newValue);
64
- state.color.reset(newValue);
65
- });
66
- context.watch(visible, (visible2) => {
67
- isShow.value = visible2;
68
- });
69
- const { onHueUpdate, onSVUpdate } = onHSVUpdate(color, res, hex, emit);
70
- const { update } = onAlphaUpdate(color, res, emit);
19
+ const renderless = (props, hooks, utils) => {
20
+ const state = initState(props, hooks);
21
+ const {
22
+ open,
23
+ close,
24
+ resetColor,
25
+ onConfirm,
26
+ onCancel,
27
+ submitValue,
28
+ clear,
29
+ onHueReady,
30
+ onSvReady,
31
+ onAlphaReady,
32
+ onPredefineColorClick,
33
+ onHistoryClick,
34
+ onClickOutside
35
+ } = initApi(props, state, utils);
71
36
  const api2 = {
72
37
  state,
73
- changeVisible,
74
- onHueUpdate,
75
- onSVUpdate,
76
- onConfirm: onConfirm(hex, pre, res, emit, stack, enableHistory, color),
77
- onCancel: onCancel(res, pre, emit, isShow, hex, color),
78
- onAlphaUpdate: update,
79
- onHistoryClick: handleHistoryClick(hex, res, color, emit),
80
- onPredefineColorClick: handlePredefineClick(hex, res, color, emit),
81
- cursor
38
+ open,
39
+ close,
40
+ resetColor,
41
+ onConfirm,
42
+ onCancel,
43
+ submitValue,
44
+ clear,
45
+ onHueReady,
46
+ onSvReady,
47
+ onAlphaReady,
48
+ onPredefineColorClick,
49
+ onHistoryClick,
50
+ onClickOutside
82
51
  };
52
+ initWatch(state, props, hooks, utils);
53
+ hooks.onMounted(() => {
54
+ if (props.modelValue) {
55
+ state.input = state.currentColor;
56
+ }
57
+ });
83
58
  return api2;
84
59
  };
85
60
  export {
@@ -508,7 +508,7 @@ class Popper {
508
508
  if (this._options.updateHiddenPopperOnScroll) {
509
509
  this.state.updateBoundFn();
510
510
  } else {
511
- if (isDisplayNone(this._popper))
511
+ if (isDisplayNone(this._reference))
512
512
  return;
513
513
  this.state.updateBoundFn();
514
514
  }
@@ -0,0 +1,16 @@
1
+ import "../../chunk-G2ADBYYC.js";
2
+ import { isServer } from "./dom";
3
+ function getIsIOS() {
4
+ if (isServer)
5
+ return false;
6
+ return window.navigator && window.navigator.userAgent && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || // The new iPad Pro Gen3 does not identify itself as iPad, but as Macintosh.
7
+ // https://github.com/vueuse/vueuse/issues/3577
8
+ window.navigator.maxTouchPoints > 2 && /iPad|Macintosh/.test(window.navigator.userAgent));
9
+ }
10
+ const useUserAgent = () => {
11
+ const isIOS = getIsIOS();
12
+ return { isIOS };
13
+ };
14
+ export {
15
+ useUserAgent
16
+ };