ranui 0.1.9 → 0.1.10-alpha.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/dist/_commonjs-dynamic-modules-DLbDWi6a.js +12 -0
- package/dist/arrow-down-C9jBUUt3.js +30 -0
- package/dist/assets/image/failImage.d.ts +2 -0
- package/dist/button.js +7 -0
- package/dist/checkbox.js +7 -0
- package/dist/colorpicker.js +13 -0
- package/dist/{colz-746223ab.js → colz-CRDozfZA.js} +1 -5
- package/dist/components/button/index.d.ts +7 -3
- package/dist/components/checkbox/index.d.ts +27 -0
- package/dist/components/colorpicker/index.d.ts +122 -0
- package/dist/components/content/index.d.ts +15 -0
- package/dist/components/input/index.d.ts +65 -41
- package/dist/components/message/index.d.ts +2 -0
- package/dist/components/option/index.d.ts +2 -1
- package/dist/components/player/index.d.ts +31 -6
- package/dist/components/popover/index.d.ts +39 -0
- package/dist/components/preview/docx.d.ts +1 -1
- package/dist/components/preview/index.d.ts +2 -0
- package/dist/components/preview/pptx/process_pptx.d.ts +1 -1
- package/dist/components/progress/index.d.ts +11 -5
- package/dist/components/radar/index.d.ts +1 -1
- package/dist/components/scratch/index.d.ts +5 -1
- package/dist/components/select/index.d.ts +15 -7
- package/dist/content.js +6 -0
- package/dist/docx-ajDUtnbM.js +3665 -0
- package/dist/global-DOfcrQ2N.js +4 -0
- package/dist/icon.js +6 -0
- package/dist/iconShadowless.js +6 -0
- package/dist/image.js +4 -0
- package/dist/index-0fvHQjmN.js +298 -0
- package/dist/{index-1b73beee.js → index-BLepXisd.js} +55 -90
- package/dist/{index-e2e5d725.js → index-BOoNI-Al.js} +113 -305
- package/dist/{index-2d16a084.js → index-BPBRPxND.js} +8 -10
- package/dist/{index-e03d23e7.js → index-BpOERe9M.js} +1 -1
- package/dist/index-Bv6Z6rIe.js +498 -0
- package/dist/index-ByJ7zZdQ.js +65641 -0
- package/dist/{index-b7790662.js → index-C1x9Popy.js} +1 -1
- package/dist/index-CCNK5H8T.js +103 -0
- package/dist/{index-458debf7.js → index-CD09p_mF.js} +7 -31
- package/dist/{index-1048a998.js → index-CFnsLnrb.js} +68 -19
- package/dist/{index-4443363f.js → index-CJZp9lE4.js} +29 -50
- package/dist/{index-57492b9b.js → index-CSnBqUsQ.js} +48 -1
- package/dist/index-CWWI8SHO.js +206 -0
- package/dist/{index-7b8840f9.js → index-CZlEoE62.js} +220 -1010
- package/dist/index-CbyMC6Yz.js +59 -0
- package/dist/index-CiBVH-oH.js +258 -0
- package/dist/{index-3cf72afd.js → index-DUMmFdJ7.js} +9 -23
- package/dist/{index-01b17e26.js → index-Du-Biu-I.js} +1 -1
- package/dist/index-EnzWG8R0.js +521 -0
- package/dist/index-F2RO3OU4.js +501 -0
- package/dist/{index-7216d6b0.js → index-GavQwMDL.js} +11 -29
- package/dist/{index-0d5b9435.js → index-suip9eAw.js} +2 -2
- package/dist/index.d.ts +18 -14
- package/dist/index.js +23 -19
- package/dist/info-circle-fill-CFeVMdci.js +4 -0
- package/dist/input.js +6 -0
- package/dist/inputShadowless.js +6 -0
- package/dist/jszip.min-Ca6PjkYs.js +2674 -0
- package/dist/message.js +5 -0
- package/dist/modal.js +4 -0
- package/dist/{components/option/index.js → option.js} +3 -6
- package/dist/{pdf-bdb7818a.js → pdf-B2a6ll8f.js} +1 -1
- package/dist/player.js +8 -0
- package/dist/popover.js +6 -0
- package/dist/preview.js +7 -0
- package/dist/progress.js +7 -0
- package/dist/radar.js +6 -0
- package/dist/select.js +10 -0
- package/dist/selectShadowless.js +10 -0
- package/dist/{umd/components/image → shadowless/icon}/index.d.ts +1 -0
- package/dist/{umd/components → shadowless}/input/index.d.ts +33 -8
- package/dist/{umd/components → shadowless}/select/index.d.ts +16 -12
- package/dist/shadowless/shadowless/index.js +14 -0
- package/dist/shadowless.d.ts +3 -0
- package/dist/skeleton.js +4 -0
- package/dist/sprite-CH2zLtZy.js +141 -0
- package/dist/style.css +1 -1
- package/dist/tab.js +6 -0
- package/dist/tabpane.js +4 -0
- package/dist/tsconfig.json +29 -0
- package/dist/umd/index.umd.cjs +21 -32
- package/dist/umd/shadowless/shadowless.umd.cjs +1 -0
- package/dist/umd/shadowless/style.css +1 -0
- package/dist/umd/style.css +1 -1
- package/dist/utils/color.d.ts +52 -0
- package/dist/utils/index.d.ts +9 -1
- package/dist/{index-7913ec46.js → utils-BMBEcoPj.js} +279 -162
- package/dist/vite.config.d.ts +1 -0
- package/package.json +61 -36
- package/readme.md +14 -14
- package/typings.d.ts +101 -0
- package/dist/components/button/index.js +0 -8
- package/dist/components/icon/index.js +0 -6
- package/dist/components/image/index.js +0 -4
- package/dist/components/input/index.js +0 -6
- package/dist/components/message/index.js +0 -4
- package/dist/components/modal/index.js +0 -4
- package/dist/components/player/index.js +0 -12
- package/dist/components/preview/index.js +0 -8
- package/dist/components/progress/index.js +0 -8
- package/dist/components/radar/index.js +0 -7
- package/dist/components/select/index.js +0 -11
- package/dist/components/skeleton/index.js +0 -4
- package/dist/components/tab/index.js +0 -7
- package/dist/components/tabpane/index.js +0 -4
- package/dist/docx-c5d02d8c.js +0 -21
- package/dist/index-73ce455b.js +0 -264
- package/dist/index-c14450a9.js +0 -662
- package/dist/info-circle-fill-90ec9aa9.js +0 -14
- package/dist/umd/build/config.d.ts +0 -3
- package/dist/umd/build/config.umd.d.ts +0 -2
- package/dist/umd/components/button/index.d.ts +0 -35
- package/dist/umd/components/form/index.d.ts +0 -2
- package/dist/umd/components/icon/index.d.ts +0 -2
- package/dist/umd/components/message/index.d.ts +0 -14
- package/dist/umd/components/modal/index.d.ts +0 -2
- package/dist/umd/components/option/index.d.ts +0 -2
- package/dist/umd/components/player/index.d.ts +0 -213
- package/dist/umd/components/preview/colz.d.ts +0 -72
- package/dist/umd/components/preview/docx.d.ts +0 -8
- package/dist/umd/components/preview/excel/excel.d.ts +0 -2
- package/dist/umd/components/preview/excel/index.d.ts +0 -1
- package/dist/umd/components/preview/excel/media.d.ts +0 -37
- package/dist/umd/components/preview/index.d.ts +0 -6
- package/dist/umd/components/preview/pdf.d.ts +0 -1
- package/dist/umd/components/preview/pptx/index.d.ts +0 -16
- package/dist/umd/components/preview/pptx/process_pptx.d.ts +0 -23
- package/dist/umd/components/preview/pptx/t_xml.d.ts +0 -1
- package/dist/umd/components/preview/pptx/worker.d.ts +0 -1
- package/dist/umd/components/progress/index.d.ts +0 -36
- package/dist/umd/components/radar/index.d.ts +0 -2
- package/dist/umd/components/scratch/index.d.ts +0 -19
- package/dist/umd/components/skeleton/index.d.ts +0 -2
- package/dist/umd/components/tab/index.d.ts +0 -408
- package/dist/umd/components/tabpane/index.d.ts +0 -352
- package/dist/umd/index.d.ts +0 -14
- package/dist/umd/playwright.config.d.ts +0 -9
- package/dist/umd/plugins/auto-import-file.d.ts +0 -0
- package/dist/umd/plugins/load-style.d.ts +0 -6
- package/dist/umd/plugins/load-svg.d.ts +0 -9
- package/dist/umd/tests/button.spec.d.ts +0 -1
- package/dist/umd/utils/image.d.ts +0 -32
- package/dist/umd/utils/index.d.ts +0 -64
- package/dist/umd/utils/math.d.ts +0 -26
- package/dist/umd/utils/tween.d.ts +0 -21
- package/dist/umd/vite.config.d.ts +0 -6
- package/dist/vendor-f71e6f68.js +0 -92126
- /package/dist/{add-user-b2bed3e7.js → add-user-BN1JlY7e.js} +0 -0
- /package/dist/{book-b11a68eb.js → book-nTEFXU2x.js} +0 -0
- /package/dist/{umd/build/config.es.d.ts → build/config.sha.d.ts} +0 -0
- /package/dist/{check-circle-fill-dc284144.js → check-circle-fill-B_pd8ZSs.js} +0 -0
- /package/dist/{check-circle-74bd09c3.js → check-circle-szyAJiap.js} +0 -0
- /package/dist/{close-20925345.js → close-CFnkhudp.js} +0 -0
- /package/dist/{close-circle-720c18be.js → close-circle-CwmuN2C6.js} +0 -0
- /package/dist/{close-circle-fill-238a66b1.js → close-circle-fill-jSqPPw9i.js} +0 -0
- /package/dist/{eye-5e742329.js → eye-D_mEt17f.js} +0 -0
- /package/dist/{eye-close-3874f1ae.js → eye-close-BVr3NJtg.js} +0 -0
- /package/dist/{home-c4a05e8b.js → home-BUQ4USMk.js} +0 -0
- /package/dist/{index-8e1e2573.js → index-CQTJoWhb.js} +0 -0
- /package/dist/{info-circle-5826decc.js → info-circle-COnL5bTJ.js} +0 -0
- /package/dist/{loading-09ca52df.js → loading-Dcc5RApI.js} +0 -0
- /package/dist/{lock-1d2487c9.js → lock-Cr7BnmWN.js} +0 -0
- /package/dist/{message-b2bfdea7.js → message-D36_Zo2l.js} +0 -0
- /package/dist/{power-off-6ade5a91.js → power-off-lQRbiBak.js} +0 -0
- /package/dist/{preview-b291aea8.js → preview-CJbz9GjO.js} +0 -0
- /package/dist/{setting-1e5ccb6d.js → setting-DemlgzVC.js} +0 -0
- /package/dist/{team-ca6a12e1.js → team-tl4NJXPC.js} +0 -0
- /package/dist/{unlock-f56086fd.js → unlock-CeU74z9n.js} +0 -0
- /package/dist/{user-5c01e665.js → user-B-eVXwuk.js} +0 -0
- /package/dist/{warning-circle-035e025c.js → warning-circle-DDUgEDIv.js} +0 -0
- /package/dist/{warning-circle-fill-d17c37c9.js → warning-circle-fill-lODUKz0i.js} +0 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { e as range } from "./utils-BMBEcoPj.js";
|
|
8
|
+
import { H as HTMLElementSSR, a as createSignal, c as createCustomError } from "./index-CSnBqUsQ.js";
|
|
9
|
+
import "./index-CWWI8SHO.js";
|
|
10
|
+
import "./index-CbyMC6Yz.js";
|
|
11
|
+
import "./index-CFnsLnrb.js";
|
|
12
|
+
import "./index-Bv6Z6rIe.js";
|
|
13
|
+
import "./option.js";
|
|
14
|
+
import "./index-CJZp9lE4.js";
|
|
15
|
+
const hex2hsv = (hex) => {
|
|
16
|
+
const { r, g, b } = hex2rgb(hex);
|
|
17
|
+
return rgb2hsv(r, g, b);
|
|
18
|
+
};
|
|
19
|
+
const hex2rgb = (hex) => {
|
|
20
|
+
if (hex[0] === "#")
|
|
21
|
+
hex = hex.substr(1);
|
|
22
|
+
if (hex.length === 3) {
|
|
23
|
+
return {
|
|
24
|
+
r: parseInt(hex[0] + hex[0], 16),
|
|
25
|
+
g: parseInt(hex[1] + hex[1], 16),
|
|
26
|
+
b: parseInt(hex[2] + hex[2], 16)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
r: parseInt(hex.substr(0, 2), 16),
|
|
31
|
+
g: parseInt(hex.substr(2, 2), 16),
|
|
32
|
+
b: parseInt(hex.substr(4, 2), 16)
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const rgb2hsv = (r, g, b) => {
|
|
36
|
+
let h;
|
|
37
|
+
const max = Math.max(r, g, b);
|
|
38
|
+
const min = Math.min(r, g, b);
|
|
39
|
+
const delta = max - min;
|
|
40
|
+
if (delta === 0) {
|
|
41
|
+
h = 0;
|
|
42
|
+
} else if (r === max) {
|
|
43
|
+
h = (g - b) / delta % 6;
|
|
44
|
+
} else if (g === max) {
|
|
45
|
+
h = (b - r) / delta + 2;
|
|
46
|
+
} else {
|
|
47
|
+
h = (r - g) / delta + 4;
|
|
48
|
+
}
|
|
49
|
+
h = Math.round(h * 60);
|
|
50
|
+
if (h < 0)
|
|
51
|
+
h += 360;
|
|
52
|
+
const s = Math.round((max === 0 ? 0 : delta / max) * 100);
|
|
53
|
+
const v = Math.round(max / 255 * 100);
|
|
54
|
+
return { h, s, v };
|
|
55
|
+
};
|
|
56
|
+
const hsv2rgb = (h, s, v) => {
|
|
57
|
+
s = s / 100;
|
|
58
|
+
v = v / 100;
|
|
59
|
+
let rgb = [];
|
|
60
|
+
const c = v * s;
|
|
61
|
+
const hh = h / 60;
|
|
62
|
+
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
63
|
+
const m = v - c;
|
|
64
|
+
if (hh >= 0 && hh < 1) {
|
|
65
|
+
rgb = [c, x, 0];
|
|
66
|
+
} else if (hh >= 1 && hh < 2) {
|
|
67
|
+
rgb = [x, c, 0];
|
|
68
|
+
} else if (hh >= 2 && hh < 3) {
|
|
69
|
+
rgb = [0, c, x];
|
|
70
|
+
} else if (h >= 3 && hh < 4) {
|
|
71
|
+
rgb = [0, x, c];
|
|
72
|
+
} else if (h >= 4 && hh < 5) {
|
|
73
|
+
rgb = [x, 0, c];
|
|
74
|
+
} else if (h >= 5 && hh <= 6) {
|
|
75
|
+
rgb = [c, 0, x];
|
|
76
|
+
} else {
|
|
77
|
+
rgb = [0, 0, 0];
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
r: Math.round(255 * (rgb[0] + m)),
|
|
81
|
+
g: Math.round(255 * (rgb[1] + m)),
|
|
82
|
+
b: Math.round(255 * (rgb[2] + m))
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const HEX_COLOR_REGEX = /^#([\da-fA-F]{6}|[\da-fA-F]{3})$/;
|
|
86
|
+
const RGB_REGEX = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/;
|
|
87
|
+
const RGBA_REGEX = /^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/;
|
|
88
|
+
const BOT_WIDTH = 8;
|
|
89
|
+
const HUE = 360;
|
|
90
|
+
class ColorPicker extends HTMLElementSSR() {
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
__publicField(this, "colorpicker");
|
|
94
|
+
__publicField(this, "colorpickerInner");
|
|
95
|
+
__publicField(this, "context");
|
|
96
|
+
__publicField(this, "popoverBlock");
|
|
97
|
+
__publicField(this, "popoverContent");
|
|
98
|
+
__publicField(this, "colorPickerInner");
|
|
99
|
+
__publicField(this, "colorPickerInnerContent");
|
|
100
|
+
__publicField(this, "colorPickerPanel");
|
|
101
|
+
__publicField(this, "colorPickerInputContainer");
|
|
102
|
+
__publicField(this, "colorPickerPanelDot");
|
|
103
|
+
__publicField(this, "colorPickerPanelSliderContainer");
|
|
104
|
+
__publicField(this, "colorPickerPanelSliderGroup");
|
|
105
|
+
__publicField(this, "colorPickerPanelSliderHue");
|
|
106
|
+
__publicField(this, "colorPickerPanelSliderAlpha");
|
|
107
|
+
__publicField(this, "colorPickerColorBlockInner");
|
|
108
|
+
__publicField(this, "colorPickerColorBlock");
|
|
109
|
+
__publicField(this, "colorPickerInnerContentSelect");
|
|
110
|
+
__publicField(this, "colorPickerPanelPalette");
|
|
111
|
+
__publicField(this, "colorPickerPanelSaturation");
|
|
112
|
+
__publicField(this, "colorPickerInputContainerSelect");
|
|
113
|
+
__publicField(this, "colorPickerInputContainerInputColor");
|
|
114
|
+
__publicField(this, "colorPickerInputContainerInputNumber");
|
|
115
|
+
__publicField(this, "colorPickerInputContainerSelectItem");
|
|
116
|
+
__publicField(this, "colorPickerPaletteSelect");
|
|
117
|
+
__publicField(this, "colorPickerPanelDotInner");
|
|
118
|
+
__publicField(this, "createContext", () => {
|
|
119
|
+
this.context = {
|
|
120
|
+
value: this.createColorValueSignal(),
|
|
121
|
+
disabled: this.createColorDisabled(),
|
|
122
|
+
hue: this.createColorHue(),
|
|
123
|
+
saturation: this.createColorSaturation(),
|
|
124
|
+
lightness: this.createColorLightness(),
|
|
125
|
+
transparency: this.createColorTransparency()
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* @description: 0 - 360 色相 hue
|
|
130
|
+
* @param {*} Signal
|
|
131
|
+
* @return {*}
|
|
132
|
+
*/
|
|
133
|
+
__publicField(this, "createColorHue", () => {
|
|
134
|
+
const [getter, setter] = createSignal(0, {
|
|
135
|
+
subscriber: [
|
|
136
|
+
this.updateColorPickerPanelSaturationBackground,
|
|
137
|
+
this.updateColorPickerPanelSliderHueProgressPercent,
|
|
138
|
+
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
139
|
+
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
140
|
+
this.updateColorPickerColorBlockInnerBackground,
|
|
141
|
+
this.updateColorPickerPanelSliderHueProgressDot
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
return { getter, setter };
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* @description: 0 - 100 饱和度 x
|
|
148
|
+
* @param {*} Signal
|
|
149
|
+
* @return {*}
|
|
150
|
+
*/
|
|
151
|
+
__publicField(this, "createColorSaturation", () => {
|
|
152
|
+
const [getter, setter] = createSignal(100, {
|
|
153
|
+
subscriber: [
|
|
154
|
+
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
155
|
+
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
156
|
+
this.updateColorPickerColorBlockInnerBackground
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
return { getter, setter };
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* @description: 0 - 100 亮度 y
|
|
163
|
+
* @param {*} Signal
|
|
164
|
+
* @return {*}
|
|
165
|
+
*/
|
|
166
|
+
__publicField(this, "createColorLightness", () => {
|
|
167
|
+
const [getter, setter] = createSignal(100, {
|
|
168
|
+
subscriber: [
|
|
169
|
+
this.updateColorPickerPanelSliderAlphaProgressWrap,
|
|
170
|
+
this.updateColorPickerPanelSliderAlphaProgressDot,
|
|
171
|
+
this.updateColorPickerColorBlockInnerBackground
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
return { getter, setter };
|
|
175
|
+
});
|
|
176
|
+
/**
|
|
177
|
+
* @description: 0 - 100 透明度
|
|
178
|
+
* @param {*} Signal
|
|
179
|
+
* @return {*}
|
|
180
|
+
*/
|
|
181
|
+
__publicField(this, "createColorTransparency", () => {
|
|
182
|
+
const [getter, setter] = createSignal(80, {
|
|
183
|
+
subscriber: [
|
|
184
|
+
this.updateColorPickerPanelSliderAlphaProgressPercent,
|
|
185
|
+
this.updateColorPickerColorBlockInnerBackground,
|
|
186
|
+
this.updateColorPickerPanelSliderAlphaProgressDot
|
|
187
|
+
]
|
|
188
|
+
});
|
|
189
|
+
return { getter, setter };
|
|
190
|
+
});
|
|
191
|
+
__publicField(this, "createColorDisabled", () => {
|
|
192
|
+
const [getter, setter] = createSignal(true, { subscriber: [] });
|
|
193
|
+
return { getter, setter };
|
|
194
|
+
});
|
|
195
|
+
__publicField(this, "createColorValueSignal", () => {
|
|
196
|
+
const [getter, setter] = createSignal("", {
|
|
197
|
+
subscriber: [this.updateColorValue]
|
|
198
|
+
});
|
|
199
|
+
return { getter, setter };
|
|
200
|
+
});
|
|
201
|
+
__publicField(this, "generateHue2rgb", () => {
|
|
202
|
+
const { hue } = this.context;
|
|
203
|
+
const { r, g, b } = hsv2rgb(hue.getter(), 100, 100);
|
|
204
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
205
|
+
});
|
|
206
|
+
__publicField(this, "generateHsv2Rgb", () => {
|
|
207
|
+
const { r, g, b } = this.generateHsv2Rgba();
|
|
208
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
209
|
+
});
|
|
210
|
+
__publicField(this, "generateHsv2Rgba", () => {
|
|
211
|
+
const { hue, saturation, lightness, transparency } = this.context;
|
|
212
|
+
const { r, g, b } = hsv2rgb(hue.getter(), saturation.getter(), lightness.getter());
|
|
213
|
+
return { r, g, b, a: transparency.getter() / 100 };
|
|
214
|
+
});
|
|
215
|
+
__publicField(this, "generateHsv2RgbaValue", () => {
|
|
216
|
+
const { r, g, b, a } = this.generateHsv2Rgba();
|
|
217
|
+
return `rgb(${r}, ${g}, ${b}, ${a})`;
|
|
218
|
+
});
|
|
219
|
+
__publicField(this, "generateColorPickerProgress", () => {
|
|
220
|
+
const { r, g, b } = this.generateHsv2Rgba();
|
|
221
|
+
return `linear-gradient(to right, rgba(255, 0, 4, 0), rgba(${r}, ${g}, ${b}, 1))`;
|
|
222
|
+
});
|
|
223
|
+
__publicField(this, "updateColorValue", (value) => {
|
|
224
|
+
var _a, _b;
|
|
225
|
+
if (value !== ((_a = this.context) == null ? void 0 : _a.value.getter())) {
|
|
226
|
+
const hex = HEX_COLOR_REGEX.exec(value);
|
|
227
|
+
const rga = RGB_REGEX.exec(value.replace(/\s+/g, ""));
|
|
228
|
+
const rgba = RGBA_REGEX.exec(value.replace(/\s+/g, ""));
|
|
229
|
+
if (hex) {
|
|
230
|
+
const { h, s, v } = hex2hsv(hex[0]);
|
|
231
|
+
this.context.hue.setter(h);
|
|
232
|
+
this.context.saturation.setter(s);
|
|
233
|
+
this.context.lightness.setter(v);
|
|
234
|
+
this.context.transparency.setter(100);
|
|
235
|
+
} else if (rgba) {
|
|
236
|
+
const { h, s, v } = rgb2hsv(Number(rgba[1]), Number(rgba[2]), Number(rgba[3]));
|
|
237
|
+
this.context.hue.setter(h);
|
|
238
|
+
this.context.saturation.setter(s);
|
|
239
|
+
this.context.lightness.setter(v);
|
|
240
|
+
this.context.transparency.setter(Number(rgba[4]));
|
|
241
|
+
} else if (rga) {
|
|
242
|
+
const { h, s, v } = rgb2hsv(Number(rga[1]), Number(rga[2]), Number(rga[3]));
|
|
243
|
+
this.context.hue.setter(h);
|
|
244
|
+
this.context.saturation.setter(s);
|
|
245
|
+
this.context.lightness.setter(v);
|
|
246
|
+
this.context.transparency.setter(100);
|
|
247
|
+
} else {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.setAttribute("value", value);
|
|
251
|
+
this.colorpickerInner.style.setProperty("background", value);
|
|
252
|
+
(_b = this.context) == null ? void 0 : _b.value.setter(value);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
__publicField(this, "updateColorPickerPanelSliderHueProgressPercent", (hue) => {
|
|
256
|
+
var _a;
|
|
257
|
+
(_a = this.colorPickerPanelSliderHue) == null ? void 0 : _a.setAttribute("percent", `${hue / 360}`);
|
|
258
|
+
});
|
|
259
|
+
__publicField(this, "updateColorPickerPanelSliderAlphaProgressPercent", (alpha) => {
|
|
260
|
+
var _a;
|
|
261
|
+
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.setAttribute("percent", `${alpha / 100}`);
|
|
262
|
+
});
|
|
263
|
+
__publicField(this, "updateColorPickerPanelSliderAlphaProgressWrap", () => {
|
|
264
|
+
var _a;
|
|
265
|
+
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.style.setProperty("--ran-progress-wrap", this.generateColorPickerProgress());
|
|
266
|
+
});
|
|
267
|
+
__publicField(this, "updateColorPickerPanelSliderAlphaProgressDot", () => {
|
|
268
|
+
var _a;
|
|
269
|
+
(_a = this.colorPickerPanelSliderAlpha) == null ? void 0 : _a.style.setProperty("--ran-progress-dot", this.generateHsv2RgbaValue());
|
|
270
|
+
});
|
|
271
|
+
__publicField(this, "updateColorPickerPanelSliderHueProgressDot", () => {
|
|
272
|
+
var _a;
|
|
273
|
+
(_a = this.colorPickerPanelSliderHue) == null ? void 0 : _a.style.setProperty("--ran-progress-dot", this.generateHue2rgb());
|
|
274
|
+
});
|
|
275
|
+
__publicField(this, "updateColorPickerColorBlockInnerBackground", () => {
|
|
276
|
+
var _a;
|
|
277
|
+
(_a = this.colorPickerColorBlockInner) == null ? void 0 : _a.style.setProperty("background", this.generateHsv2RgbaValue());
|
|
278
|
+
});
|
|
279
|
+
__publicField(this, "updateColorPickerPanelSaturationBackground", () => {
|
|
280
|
+
var _a;
|
|
281
|
+
(_a = this.colorPickerPanelSaturation) == null ? void 0 : _a.style.setProperty("background-color", this.generateHue2rgb());
|
|
282
|
+
});
|
|
283
|
+
__publicField(this, "clickStop", (e) => {
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
e.preventDefault();
|
|
286
|
+
});
|
|
287
|
+
__publicField(this, "changeColorPalettePositionByContext", () => {
|
|
288
|
+
window.requestAnimationFrame(() => {
|
|
289
|
+
var _a, _b, _c, _d, _e;
|
|
290
|
+
this.updateColorValue(this.value);
|
|
291
|
+
if (!this.colorPickerPanelPalette)
|
|
292
|
+
return;
|
|
293
|
+
if (!((_a = this.context) == null ? void 0 : _a.lightness.getter) || !((_b = this.context) == null ? void 0 : _b.saturation.getter))
|
|
294
|
+
return;
|
|
295
|
+
const { width, height } = ((_c = this.colorPickerPanelPalette) == null ? void 0 : _c.getBoundingClientRect()) || {};
|
|
296
|
+
const limitY = height - this.context.lightness.getter() / 100 * height;
|
|
297
|
+
const limitX = this.context.saturation.getter() / 100 * width;
|
|
298
|
+
(_d = this.colorPickerPanelDot) == null ? void 0 : _d.style.setProperty("top", `${limitY - BOT_WIDTH}px`);
|
|
299
|
+
(_e = this.colorPickerPanelDot) == null ? void 0 : _e.style.setProperty("left", `${limitX - BOT_WIDTH}px`);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
__publicField(this, "changeColorPalettePosition", (offsetX, offsetY) => {
|
|
303
|
+
var _a, _b, _c;
|
|
304
|
+
if (!this.colorPickerPanelPalette)
|
|
305
|
+
return;
|
|
306
|
+
if (!((_a = this.context) == null ? void 0 : _a.lightness.getter) || !((_b = this.context) == null ? void 0 : _b.saturation.getter))
|
|
307
|
+
return;
|
|
308
|
+
const { width, height } = ((_c = this.colorPickerPanelPalette) == null ? void 0 : _c.getBoundingClientRect()) || {};
|
|
309
|
+
const limitY = height - range(offsetY, 0, height);
|
|
310
|
+
const limitX = range(offsetX, 0, width);
|
|
311
|
+
this.context.saturation.setter(limitX / width * 100);
|
|
312
|
+
this.context.lightness.setter(limitY / height * 100);
|
|
313
|
+
window.requestAnimationFrame(() => {
|
|
314
|
+
var _a2, _b2;
|
|
315
|
+
(_a2 = this.colorPickerPanelDot) == null ? void 0 : _a2.style.setProperty("top", `${offsetY - BOT_WIDTH}px`);
|
|
316
|
+
(_b2 = this.colorPickerPanelDot) == null ? void 0 : _b2.style.setProperty("left", `${offsetX - BOT_WIDTH}px`);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
__publicField(this, "clickColorPalette", (e) => {
|
|
320
|
+
const { offsetX, offsetY } = e;
|
|
321
|
+
this.changeColorPalettePosition(offsetX, offsetY);
|
|
322
|
+
});
|
|
323
|
+
__publicField(this, "createColorPickerProgress", () => {
|
|
324
|
+
this.colorPickerPanelSliderContainer = document.createElement("div");
|
|
325
|
+
this.colorPickerPanelSliderContainer.setAttribute("class", "ran-color-picker-slider-container");
|
|
326
|
+
this.colorPickerPanelSliderGroup = document.createElement("div");
|
|
327
|
+
this.colorPickerPanelSliderGroup.setAttribute("class", "ran-color-picker-slider-container-group");
|
|
328
|
+
this.colorPickerPanelSliderHue = document.createElement("r-progress");
|
|
329
|
+
this.updateColorPickerPanelSliderHueProgressDot();
|
|
330
|
+
this.colorPickerPanelSliderHue.style.setProperty(
|
|
331
|
+
"--ran-progress-wrap",
|
|
332
|
+
"linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"
|
|
333
|
+
);
|
|
334
|
+
this.colorPickerPanelSliderHue.setAttribute("percent", `${this.context.hue.getter() / 360}`);
|
|
335
|
+
this.colorPickerPanelSliderHue.addEventListener("change", this.changeColorPickerHue);
|
|
336
|
+
this.colorPickerPanelSliderHue.setAttribute("type", "drag");
|
|
337
|
+
this.colorPickerPanelSliderHue.setAttribute("class", "ran-color-picker-slider-container-group-hue");
|
|
338
|
+
this.colorPickerPanelSliderAlpha = document.createElement("r-progress");
|
|
339
|
+
this.updateColorPickerPanelSliderAlphaProgressDot();
|
|
340
|
+
this.colorPickerPanelSliderAlpha.setAttribute("percent", `${this.context.transparency.getter() / 100}`);
|
|
341
|
+
this.updateColorPickerPanelSliderAlphaProgressWrap();
|
|
342
|
+
this.colorPickerPanelSliderAlpha.addEventListener("change", this.changeColorPickerAlpha);
|
|
343
|
+
this.colorPickerPanelSliderAlpha.setAttribute("type", "drag");
|
|
344
|
+
this.colorPickerPanelSliderAlpha.setAttribute("class", "ran-color-picker-slider-container-group-alpha");
|
|
345
|
+
this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderHue);
|
|
346
|
+
this.colorPickerPanelSliderGroup.appendChild(this.colorPickerPanelSliderAlpha);
|
|
347
|
+
this.colorPickerPanelSliderContainer.appendChild(this.colorPickerPanelSliderGroup);
|
|
348
|
+
this.colorPickerColorBlock = document.createElement("div");
|
|
349
|
+
this.colorPickerColorBlock.setAttribute("class", "ran-color-picker-slider-container-color-block");
|
|
350
|
+
this.colorPickerColorBlockInner = document.createElement("div");
|
|
351
|
+
this.colorPickerColorBlockInner.setAttribute("class", "ran-color-picker-slider-container-color-block-inner");
|
|
352
|
+
this.updateColorPickerColorBlockInnerBackground();
|
|
353
|
+
this.colorPickerColorBlock.appendChild(this.colorPickerColorBlockInner);
|
|
354
|
+
this.colorPickerPanelSliderContainer.appendChild(this.colorPickerColorBlock);
|
|
355
|
+
});
|
|
356
|
+
__publicField(this, "changeColorPickerHue", (e) => {
|
|
357
|
+
this.context.hue.setter(e.detail.value * HUE);
|
|
358
|
+
});
|
|
359
|
+
__publicField(this, "changeColorPickerAlpha", (e) => {
|
|
360
|
+
this.context.transparency.setter(e.detail.value * 100);
|
|
361
|
+
});
|
|
362
|
+
__publicField(this, "createColorPickerSelect", () => {
|
|
363
|
+
this.colorPickerPanel = document.createElement("div");
|
|
364
|
+
this.colorPickerPanel.setAttribute("class", "ran-color-picker-panel");
|
|
365
|
+
this.colorPickerInnerContentSelect = document.createElement("div");
|
|
366
|
+
this.colorPickerInnerContentSelect.setAttribute("class", "ran-color-picker-select");
|
|
367
|
+
this.colorPickerPanel.appendChild(this.colorPickerInnerContentSelect);
|
|
368
|
+
this.colorPickerPanelPalette = document.createElement("div");
|
|
369
|
+
this.colorPickerPanelPalette.setAttribute("class", "ran-color-picker-palette");
|
|
370
|
+
this.colorPickerInnerContentSelect.appendChild(this.colorPickerPanelPalette);
|
|
371
|
+
this.colorPickerPanelSaturation = document.createElement("div");
|
|
372
|
+
this.colorPickerPanelSaturation.setAttribute("class", "ran-color-picker-saturation");
|
|
373
|
+
this.updateColorPickerPanelSaturationBackground();
|
|
374
|
+
this.colorPickerPanelDot = document.createElement("div");
|
|
375
|
+
this.colorPickerPanelDotInner = document.createElement("div");
|
|
376
|
+
this.colorPickerPanelDotInner.setAttribute("class", "ran-color-picker-palette-dot-inner");
|
|
377
|
+
this.colorPickerPanelDot.setAttribute("class", "ran-color-picker-palette-dot");
|
|
378
|
+
this.colorPickerPanelDot.addEventListener("mousedown", this.mouseDownColorPickerPalette);
|
|
379
|
+
document.body.addEventListener("mousemove", this.mouseMoveColorPickerPalette);
|
|
380
|
+
this.colorPickerPanelDot.addEventListener("mouseup", this.mouseUpColorPickerPalette);
|
|
381
|
+
this.colorPickerPanelDot.appendChild(this.colorPickerPanelDotInner);
|
|
382
|
+
this.colorPickerPanelPalette.appendChild(this.colorPickerPanelDot);
|
|
383
|
+
this.colorPickerPanelPalette.appendChild(this.colorPickerPanelSaturation);
|
|
384
|
+
this.colorPickerPanelPalette.addEventListener("mousedown", this.clickColorPalette);
|
|
385
|
+
});
|
|
386
|
+
__publicField(this, "createColorPickerInput", () => {
|
|
387
|
+
this.colorPickerInputContainer = document.createElement("div");
|
|
388
|
+
this.colorPickerInputContainer.setAttribute("class", "ran-color-picker-input-container");
|
|
389
|
+
const colorPickerInputContainerId = `${performance.now()}`.replace(".", "");
|
|
390
|
+
this.colorPickerInputContainerSelect = document.createElement("div");
|
|
391
|
+
this.colorPickerInputContainerSelect.setAttribute("class", "ran-color-picker-input-container-select");
|
|
392
|
+
this.colorPickerInputContainerSelect.setAttribute("id", colorPickerInputContainerId);
|
|
393
|
+
this.colorPickerInputContainerSelectItem = document.createElement("ra-select");
|
|
394
|
+
this.colorPickerInputContainerSelectItem.setAttribute("value", "HEX");
|
|
395
|
+
this.colorPickerInputContainerSelectItem.setAttribute("class", "ran-color-picker-input-container-select-item");
|
|
396
|
+
this.colorPickerInputContainerSelectItem.setAttribute("type", "text");
|
|
397
|
+
this.colorPickerInputContainerSelectItem.setAttribute("getPopupContainerId", colorPickerInputContainerId);
|
|
398
|
+
const colorSelectOption = ["HEX", "HSB", "RGB"];
|
|
399
|
+
const Fragment = document.createDocumentFragment();
|
|
400
|
+
colorSelectOption.forEach((item) => {
|
|
401
|
+
const Option = document.createElement("r-option");
|
|
402
|
+
Option.setAttribute("value", item);
|
|
403
|
+
Option.innerText = item;
|
|
404
|
+
Fragment.appendChild(Option);
|
|
405
|
+
});
|
|
406
|
+
this.colorPickerInputContainerSelectItem.appendChild(Fragment);
|
|
407
|
+
this.colorPickerInputContainerSelect.appendChild(this.colorPickerInputContainerSelectItem);
|
|
408
|
+
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerSelect);
|
|
409
|
+
this.colorPickerInputContainerInputColor = document.createElement("ra-input");
|
|
410
|
+
this.colorPickerInputContainerInputColor.setAttribute("class", "ran-color-picker-input-container-input-color");
|
|
411
|
+
this.colorPickerInputContainerInputNumber = document.createElement("ra-input");
|
|
412
|
+
this.colorPickerInputContainerInputNumber.setAttribute("class", "ran-color-picker-input-container-input-number");
|
|
413
|
+
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputColor);
|
|
414
|
+
this.colorPickerInputContainer.appendChild(this.colorPickerInputContainerInputNumber);
|
|
415
|
+
});
|
|
416
|
+
__publicField(this, "openColorPicker", () => {
|
|
417
|
+
if (this.colorPickerInner)
|
|
418
|
+
return;
|
|
419
|
+
this.colorPickerInner = document.createElement("div");
|
|
420
|
+
this.colorPickerInner.setAttribute("class", "ran-color-picker-inner");
|
|
421
|
+
this.colorPickerInnerContent = document.createElement("div");
|
|
422
|
+
this.colorPickerInnerContent.setAttribute("class", "ran-color-picker-inner-content");
|
|
423
|
+
this.createColorPickerProgress();
|
|
424
|
+
this.createColorPickerSelect();
|
|
425
|
+
this.createColorPickerInput();
|
|
426
|
+
this.colorPickerPanel && this.colorPickerInnerContent.appendChild(this.colorPickerPanel);
|
|
427
|
+
this.colorPickerPanelSliderContainer && this.colorPickerInnerContent.appendChild(this.colorPickerPanelSliderContainer);
|
|
428
|
+
this.colorPickerInputContainer && this.colorPickerInnerContent.appendChild(this.colorPickerInputContainer);
|
|
429
|
+
this.colorPickerInner.appendChild(this.colorPickerInnerContent);
|
|
430
|
+
this.popoverContent.appendChild(this.colorPickerInner);
|
|
431
|
+
this.changeColorPalettePositionByContext();
|
|
432
|
+
});
|
|
433
|
+
__publicField(this, "mouseMoveColorPickerPalette", (e) => {
|
|
434
|
+
var _a;
|
|
435
|
+
if (!this.colorPickerPanelPalette || !this.colorPickerPaletteSelect)
|
|
436
|
+
return;
|
|
437
|
+
const { pageX, pageY } = e;
|
|
438
|
+
const { top = 0, left = 0, width, height } = ((_a = this.colorPickerPanelPalette) == null ? void 0 : _a.getBoundingClientRect()) || {};
|
|
439
|
+
const limitY = range(pageY - top - BOT_WIDTH, -BOT_WIDTH, height - BOT_WIDTH);
|
|
440
|
+
const limitX = range(pageX - left - BOT_WIDTH, -BOT_WIDTH, width - BOT_WIDTH);
|
|
441
|
+
this.context.saturation.setter(limitX / width * 100);
|
|
442
|
+
this.context.lightness.setter(limitY / height * 100);
|
|
443
|
+
window.requestAnimationFrame(() => {
|
|
444
|
+
var _a2, _b;
|
|
445
|
+
(_a2 = this.colorPickerPanelDot) == null ? void 0 : _a2.style.setProperty("top", `${limitY}px`);
|
|
446
|
+
(_b = this.colorPickerPanelDot) == null ? void 0 : _b.style.setProperty("left", `${limitX}px`);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
__publicField(this, "mouseDownColorPickerPalette", (e) => {
|
|
450
|
+
e.stopPropagation();
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
this.colorPickerPaletteSelect = true;
|
|
453
|
+
});
|
|
454
|
+
__publicField(this, "mouseUpColorPickerPalette", (e) => {
|
|
455
|
+
this.colorPickerPaletteSelect = false;
|
|
456
|
+
});
|
|
457
|
+
this.setAttribute("class", "ran-colorpicker");
|
|
458
|
+
this.popoverBlock = document.createElement("r-popover");
|
|
459
|
+
this.popoverBlock.setAttribute("class", "ran-popover");
|
|
460
|
+
this.popoverContent = document.createElement("r-content");
|
|
461
|
+
this.popoverContent.setAttribute("class", "ran-content");
|
|
462
|
+
this.colorpicker = document.createElement("div");
|
|
463
|
+
this.colorpicker.setAttribute("class", "ran-colorpicker-block");
|
|
464
|
+
this.colorpickerInner = document.createElement("div");
|
|
465
|
+
this.colorpickerInner.setAttribute("class", "ran-colorpicker-inner");
|
|
466
|
+
this.popoverBlock.appendChild(this.colorpicker);
|
|
467
|
+
this.popoverBlock.appendChild(this.popoverContent);
|
|
468
|
+
this.colorpicker.appendChild(this.colorpickerInner);
|
|
469
|
+
this.appendChild(this.popoverBlock);
|
|
470
|
+
this.colorPickerPaletteSelect = false;
|
|
471
|
+
this.createContext();
|
|
472
|
+
}
|
|
473
|
+
static get observedAttributes() {
|
|
474
|
+
return ["disabled", "value"];
|
|
475
|
+
}
|
|
476
|
+
get value() {
|
|
477
|
+
var _a;
|
|
478
|
+
return ((_a = this.context) == null ? void 0 : _a.value.getter()) || "";
|
|
479
|
+
}
|
|
480
|
+
set value(value) {
|
|
481
|
+
this.setAttribute("value", value);
|
|
482
|
+
this.updateColorValue(value);
|
|
483
|
+
}
|
|
484
|
+
connectedCallback() {
|
|
485
|
+
this.popoverBlock.addEventListener("click", this.openColorPicker);
|
|
486
|
+
}
|
|
487
|
+
disconnectCallback() {
|
|
488
|
+
var _a, _b, _c;
|
|
489
|
+
this.popoverBlock.removeEventListener("click", this.openColorPicker);
|
|
490
|
+
(_a = this.colorPickerPanelDot) == null ? void 0 : _a.removeEventListener("mousedown", this.mouseDownColorPickerPalette);
|
|
491
|
+
document.body.removeEventListener("mousemove", this.mouseMoveColorPickerPalette);
|
|
492
|
+
(_b = this.colorPickerPanelDot) == null ? void 0 : _b.removeEventListener("mouseup", this.mouseUpColorPickerPalette);
|
|
493
|
+
(_c = this.colorPickerPanelPalette) == null ? void 0 : _c.removeEventListener("mousedown", this.clickColorPalette);
|
|
494
|
+
}
|
|
495
|
+
attributeChangedCallback(n, o, v) {
|
|
496
|
+
if (o !== v) {
|
|
497
|
+
if (n === "value") {
|
|
498
|
+
this.updateColorValue(v);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function Custom() {
|
|
504
|
+
if (typeof document !== "undefined" && !customElements.get("r-colorpicker")) {
|
|
505
|
+
customElements.define("r-colorpicker", ColorPicker);
|
|
506
|
+
return ColorPicker;
|
|
507
|
+
} else {
|
|
508
|
+
return createCustomError("document is undefined or r-colorpicker is exist");
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const index = Custom();
|
|
512
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
513
|
+
__proto__: null,
|
|
514
|
+
ColorPicker,
|
|
515
|
+
default: index
|
|
516
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
517
|
+
export {
|
|
518
|
+
ColorPicker as C,
|
|
519
|
+
index as a,
|
|
520
|
+
index$1 as i
|
|
521
|
+
};
|