@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.
- package/base-select/index.js +11 -74
- package/base-select/vue.js +10 -10
- package/bulletin-board/index.js +5 -1
- package/bulletin-board/vue.js +5 -4
- package/button/index.js +11 -3
- package/button/vue.js +6 -2
- package/button-group/index.js +1 -1
- package/color-picker/index.js +4 -4
- package/color-picker/utils/color.js +358 -83
- package/color-picker/utils/hsv-to-rgb.js +59 -0
- package/color-picker/vue.js +27 -8
- package/color-select-panel/alpha-select/index.js +65 -14
- package/color-select-panel/alpha-select/vue.js +29 -44
- package/color-select-panel/hue-select/index.js +47 -61
- package/color-select-panel/hue-select/vue.js +29 -47
- package/color-select-panel/index.js +230 -80
- package/color-select-panel/sv-select/index.js +68 -0
- package/color-select-panel/sv-select/vue.js +32 -0
- package/color-select-panel/utils/color.js +345 -82
- package/color-select-panel/utils/getClientXY.js +54 -0
- package/color-select-panel/vue.js +47 -72
- package/common/deps/popper.js +1 -1
- package/common/deps/useUserAgent.js +16 -0
- package/common/event.js +21 -0
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- package/date-picker-mobile/index.js +4 -4
- package/dialog-box/index.js +1 -1
- package/dropdown/index.js +5 -1
- package/dropdown/vue.js +2 -2
- package/file-upload/vue.js +1 -0
- package/flowchart/index.js +3 -2
- package/form/index.js +2 -2
- package/form-item/index.js +4 -1
- package/grid-select/index.js +82 -0
- package/grid-select/vue.js +30 -0
- package/input/index.js +2 -2
- package/menu/vue.js +5 -1
- package/modal/index.js +2 -0
- package/numeric/index.js +29 -9
- package/option/index.js +6 -0
- package/option/vue.js +12 -2
- package/package.json +1 -1
- package/picker/index.js +1 -1
- package/recycle-scroller/index.js +43 -27
- package/recycle-scroller/vue.js +9 -4
- package/rich-text/index.js +13 -0
- package/rich-text/vue.js +4 -2
- package/select/index.js +71 -23
- package/select/vue.js +12 -4
- package/select-dropdown/vue.js +1 -1
- package/tabbar/index.js +4 -1
- package/tabbar/vue.js +1 -1
- package/tabs/index.js +8 -5
- package/tabs/vue.js +4 -1
- package/time-panel/vue.js +1 -1
- package/tooltip/vue.js +1 -0
- package/tree-menu/index.js +5 -1
- package/tree-node/index.js +5 -4
- package/tree-select/index.js +77 -1
- package/tree-select/vue.js +21 -7
- package/types/button.type.d.ts +7 -3
- package/types/color-select-panel.type.d.ts +23 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/input.type.d.ts +1 -1
- package/types/numeric.type.d.ts +5 -5
- package/types/popover.type.d.ts +1 -1
- package/types/transfer.type.d.ts +3 -3
- package/types/tree-menu.type.d.ts +1 -1
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-26173587.d.ts → upload-list.type-6189e4c9.d.ts} +7 -3
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-head.type.d.ts +4 -0
- package/user-head/index.js +1 -1
- package/year-table/index.js +14 -29
- 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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
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(
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
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.
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
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
|
|
50
|
-
|
|
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
|
-
|
|
59
|
-
this.
|
|
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
|
-
|
|
65
|
-
|
|
166
|
+
isHSL(value) {
|
|
167
|
+
return value.includes("hsl");
|
|
66
168
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
88
|
-
return {
|
|
89
|
-
h: this.
|
|
90
|
-
s: this.
|
|
91
|
-
v: this.
|
|
92
|
-
|
|
93
|
-
};
|
|
283
|
+
toRgb() {
|
|
284
|
+
return hsv2rgb({
|
|
285
|
+
h: this._hue,
|
|
286
|
+
s: this._sat,
|
|
287
|
+
v: this._value
|
|
288
|
+
});
|
|
94
289
|
}
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
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
|
|
3
|
-
import { onConfirm, onCancel, onHSVUpdate, onAlphaUpdate, handleHistoryClick, handlePredefineClick } from ".";
|
|
2
|
+
import { initApi, initState, initWatch } from "./index";
|
|
4
3
|
const api = [
|
|
5
4
|
"state",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"onHueUpdate",
|
|
10
|
-
"onSVUpdate",
|
|
5
|
+
"open",
|
|
6
|
+
"close",
|
|
7
|
+
"resetColor",
|
|
11
8
|
"onConfirm",
|
|
12
9
|
"onCancel",
|
|
13
|
-
"
|
|
10
|
+
"submitValue",
|
|
11
|
+
"clear",
|
|
12
|
+
"onHueReady",
|
|
13
|
+
"onSvReady",
|
|
14
|
+
"onAlphaReady",
|
|
15
|
+
"onPredefineColorClick",
|
|
14
16
|
"onHistoryClick",
|
|
15
|
-
"
|
|
17
|
+
"onClickOutside"
|
|
16
18
|
];
|
|
17
|
-
const renderless = (props,
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
onConfirm
|
|
77
|
-
onCancel
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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 {
|
package/common/deps/popper.js
CHANGED
|
@@ -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
|
+
};
|