@shtabapp/ui-kit 1.32.0 → 1.34.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.
- package/CHANGELOG.md +12 -0
- package/dist/SAvatar-C2gekygl.cjs +1 -0
- package/dist/SAvatar-DAfDAqrP.js +265 -0
- package/dist/{SAvatarGroup-CMa9KhUZ.cjs → SAvatarGroup-76j-sHCe.cjs} +1 -1
- package/dist/{SAvatarGroup-wkXHy_tK.js → SAvatarGroup-HvIlI5y0.js} +1 -1
- package/dist/SColorPalette-B9WrqgRz.js +146 -0
- package/dist/SColorPalette-CYGnmIWP.cjs +1 -0
- package/dist/SColorPicker-Cs0QmYWm.js +635 -0
- package/dist/SColorPicker-D7QwVS2t.cjs +1 -0
- package/dist/{SDropdown-Cv729__Y.js → SDropdown-CTQ5Qlez.js} +50 -49
- package/dist/SDropdown-_QUOP-rw.cjs +1 -0
- package/dist/{SSelect-iBb45tet.js → SSelect-AcH04gtk.js} +23 -18
- package/dist/{SSelect-CgL7ECfS.cjs → SSelect-CT3AMH-u.cjs} +1 -1
- package/dist/STag-COwzellL.js +123 -0
- package/dist/STag-HgFvU1Iy.cjs +1 -0
- package/dist/{STagGroup-BMyuxfVX.cjs → STagGroup-CKxDA9Y0.cjs} +1 -1
- package/dist/{STagGroup-B2-_OG3R.js → STagGroup-Cbe0AENj.js} +1 -1
- package/dist/colorValue-DClAEDHr.cjs +1 -0
- package/dist/colorValue-DXJiNKGE.js +5 -0
- package/dist/components/SAvatar/SAvatar.vue.d.ts.map +1 -1
- package/dist/components/SAvatar/utils/getAvatarInitialsTextColor.d.ts +4 -0
- package/dist/components/SAvatar/utils/getAvatarInitialsTextColor.d.ts.map +1 -0
- package/dist/components/SAvatar/utils/resolveAvatarColor.d.ts +1 -3
- package/dist/components/SAvatar/utils/resolveAvatarColor.d.ts.map +1 -1
- package/dist/components/SColorPalette/SColorPalette.types.d.ts +19 -0
- package/dist/components/SColorPalette/SColorPalette.types.d.ts.map +1 -0
- package/dist/components/SColorPalette/SColorPalette.vue.d.ts +26 -0
- package/dist/components/SColorPalette/SColorPalette.vue.d.ts.map +1 -0
- package/dist/components/SColorPalette/index.d.ts +4 -0
- package/dist/components/SColorPalette/index.d.ts.map +1 -0
- package/dist/components/SColorPicker/SColorPicker.types.d.ts +12 -0
- package/dist/components/SColorPicker/SColorPicker.types.d.ts.map +1 -0
- package/dist/components/SColorPicker/SColorPicker.vue.d.ts +25 -0
- package/dist/components/SColorPicker/SColorPicker.vue.d.ts.map +1 -0
- package/dist/components/SColorPicker/constants/SColorPicker.constants.d.ts +2 -0
- package/dist/components/SColorPicker/constants/SColorPicker.constants.d.ts.map +1 -0
- package/dist/components/SColorPicker/index.d.ts +8 -0
- package/dist/components/SColorPicker/index.d.ts.map +1 -0
- package/dist/components/SColorPicker/parts/SColorArea.types.d.ts +9 -0
- package/dist/components/SColorPicker/parts/SColorArea.types.d.ts.map +1 -0
- package/dist/components/SColorPicker/parts/SColorArea.vue.d.ts +15 -0
- package/dist/components/SColorPicker/parts/SColorArea.vue.d.ts.map +1 -0
- package/dist/components/SColorPicker/parts/SColorValues.types.d.ts +12 -0
- package/dist/components/SColorPicker/parts/SColorValues.types.d.ts.map +1 -0
- package/dist/components/SColorPicker/parts/SColorValues.vue.d.ts +22 -0
- package/dist/components/SColorPicker/parts/SColorValues.vue.d.ts.map +1 -0
- package/dist/components/SColorPicker/utils/resolveColorSwatchFillElement.d.ts +3 -0
- package/dist/components/SColorPicker/utils/resolveColorSwatchFillElement.d.ts.map +1 -0
- package/dist/components/SColorPicker/utils/useColorArea.d.ts +29 -0
- package/dist/components/SColorPicker/utils/useColorArea.d.ts.map +1 -0
- package/dist/components/SDropdown/SDropdown.vue.d.ts.map +1 -1
- package/dist/components/SSelect/SSelect.types.d.ts +5 -0
- package/dist/components/SSelect/SSelect.types.d.ts.map +1 -1
- package/dist/components/SSelect/SSelect.vue.d.ts.map +1 -1
- package/dist/components/STag/utils/resolveTagColor.d.ts +1 -3
- package/dist/components/STag/utils/resolveTagColor.d.ts.map +1 -1
- package/dist/composables/connectedPosition/parseAnchor.d.ts.map +1 -1
- package/dist/composables/connectedPosition/types.d.ts +5 -1
- package/dist/composables/connectedPosition/types.d.ts.map +1 -1
- package/dist/contrastSurfaceTextColor-Dl641cZ_.js +33 -0
- package/dist/contrastSurfaceTextColor-Ybh-FZof.cjs +1 -0
- package/dist/entries/avatar-group.cjs +1 -1
- package/dist/entries/avatar-group.js +1 -1
- package/dist/entries/avatar.cjs +1 -1
- package/dist/entries/avatar.js +1 -1
- package/dist/entries/color-palette.cjs +1 -0
- package/dist/entries/color-palette.d.ts +5 -0
- package/dist/entries/color-palette.d.ts.map +1 -0
- package/dist/entries/color-palette.js +3 -0
- package/dist/entries/color-picker.cjs +1 -0
- package/dist/entries/color-picker.d.ts +5 -0
- package/dist/entries/color-picker.d.ts.map +1 -0
- package/dist/entries/color-picker.js +4 -0
- package/dist/entries/composables.cjs +1 -1
- package/dist/entries/composables.js +1 -1
- package/dist/entries/dropdown.cjs +1 -1
- package/dist/entries/dropdown.js +2 -2
- package/dist/entries/select.cjs +1 -1
- package/dist/entries/select.js +1 -1
- package/dist/entries/tag-group.cjs +1 -1
- package/dist/entries/tag-group.js +2 -2
- package/dist/entries/tag.cjs +1 -1
- package/dist/entries/tag.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -34
- package/dist/uikit-components.css +1 -1
- package/dist/useFloatingOverlay-B1UCUYQQ.cjs +1 -0
- package/dist/{useFloatingOverlay-D-GlpoPP.js → useFloatingOverlay-QcumEYEq.js} +23 -3
- package/dist/utils/color/colorFormatChannels.d.ts +11 -0
- package/dist/utils/color/colorFormatChannels.d.ts.map +1 -0
- package/dist/utils/color/colorValue.d.ts +9 -0
- package/dist/utils/color/colorValue.d.ts.map +1 -0
- package/dist/utils/color/contrastSurfaceTextColor.d.ts +4 -0
- package/dist/utils/color/contrastSurfaceTextColor.d.ts.map +1 -0
- package/dist/utils/color/defaultPaletteColors.d.ts +3 -0
- package/dist/utils/color/defaultPaletteColors.d.ts.map +1 -0
- package/dist/utils/color/formatColorForDisplay.d.ts +9 -0
- package/dist/utils/color/formatColorForDisplay.d.ts.map +1 -0
- package/dist/utils/color/index.d.ts +10 -0
- package/dist/utils/color/index.d.ts.map +1 -0
- package/dist/utils/color/parseColorFromInput.d.ts +4 -0
- package/dist/utils/color/parseColorFromInput.d.ts.map +1 -0
- package/dist/utils/color/recommendedColorPalette.d.ts +3 -0
- package/dist/utils/color/recommendedColorPalette.d.ts.map +1 -0
- package/dist/utils/color/types.d.ts +35 -0
- package/dist/utils/color/types.d.ts.map +1 -0
- package/package.json +12 -2
- package/dist/SAvatar-BS9Lu2eL.js +0 -249
- package/dist/SAvatar-BXABKIV0.cjs +0 -1
- package/dist/SDropdown-B6b7IDjp.cjs +0 -1
- package/dist/STag-CYoj7L-p.js +0 -118
- package/dist/STag-DVrSWByQ.cjs +0 -1
- package/dist/useFloatingOverlay-Cwg2MWyD.cjs +0 -1
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import { n as e } from "./contrastSurfaceTextColor-Dl641cZ_.js";
|
|
2
|
+
import { n as t, o as n, r, t as i } from "./SColorPalette-B9WrqgRz.js";
|
|
3
|
+
import { a, n as o } from "./colorValue-DXJiNKGE.js";
|
|
4
|
+
import { n as s, r as c, t as l } from "./SButton.types-CpdHQtyx.js";
|
|
5
|
+
import { t as u } from "./SButton-DnU_XZ1C.js";
|
|
6
|
+
import { i as d } from "./useFloatingOverlay-QcumEYEq.js";
|
|
7
|
+
import { t as f } from "./SDropdown-CTQ5Qlez.js";
|
|
8
|
+
import { r as p, t as m } from "./SSelect-AcH04gtk.js";
|
|
9
|
+
import { Fragment as h, computed as g, createBlock as _, createElementBlock as v, createElementVNode as y, createTextVNode as b, createVNode as x, defineComponent as S, mergeModels as C, mergeProps as w, nextTick as T, normalizeClass as E, normalizeStyle as D, onMounted as O, openBlock as k, ref as A, shallowRef as j, toRef as M, unref as N, useModel as P, useTemplateRef as F, vModelText as I, watch as L, withCtx as R, withDirectives as z } from "vue";
|
|
10
|
+
import { ESColorSwatchSize as B, SColorSwatch as V } from "@shtabapp/ui-kit-primitives";
|
|
11
|
+
import { useEventListener as H } from "@vueuse/core";
|
|
12
|
+
//#region src/utils/color/colorFormatChannels.ts
|
|
13
|
+
var U = (e) => Math.max(0, Math.min(255, Math.round(e))), ee = (e) => {
|
|
14
|
+
let t = e % 360;
|
|
15
|
+
return t < 0 ? t + 360 : t;
|
|
16
|
+
}, W = (e) => Math.max(0, Math.min(100, Math.round(e))), te = (e) => {
|
|
17
|
+
let t = e.slice(1);
|
|
18
|
+
if (t.length === 3) {
|
|
19
|
+
let e = t[0], n = t[1], r = t[2];
|
|
20
|
+
return !e || !n || !r ? void 0 : `${e}${e}${n}${n}${r}${r}`;
|
|
21
|
+
}
|
|
22
|
+
if (t.length === 6 || t.length === 8) return t.slice(0, 6);
|
|
23
|
+
}, G = (e) => {
|
|
24
|
+
let t = te(e);
|
|
25
|
+
if (!t) return;
|
|
26
|
+
let n = Number.parseInt(t.slice(0, 2), 16), r = Number.parseInt(t.slice(2, 4), 16), i = Number.parseInt(t.slice(4, 6), 16);
|
|
27
|
+
if (!(Number.isNaN(n) || Number.isNaN(r) || Number.isNaN(i))) return {
|
|
28
|
+
first: n,
|
|
29
|
+
second: r,
|
|
30
|
+
third: i
|
|
31
|
+
};
|
|
32
|
+
}, K = (e) => {
|
|
33
|
+
let t = U(e.first), n = U(e.second), r = U(e.third);
|
|
34
|
+
return `#${t.toString(16).padStart(2, "0").toUpperCase()}${n.toString(16).padStart(2, "0").toUpperCase()}${r.toString(16).padStart(2, "0").toUpperCase()}`;
|
|
35
|
+
}, q = (e) => {
|
|
36
|
+
let t = G(e);
|
|
37
|
+
if (!t) return;
|
|
38
|
+
let n = t.first / 255, r = t.second / 255, i = t.third / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = a - o, c = 0, l = (a + o) / 2;
|
|
39
|
+
s !== 0 && (c = a === n ? ((r - i) / s + (r < i ? 6 : 0)) * 60 : a === r ? ((i - n) / s + 2) * 60 : ((n - r) / s + 4) * 60);
|
|
40
|
+
let u = 0;
|
|
41
|
+
return s !== 0 && (u = l > .5 ? s / (2 - a - o) : s / (a + o)), {
|
|
42
|
+
first: Math.round(c),
|
|
43
|
+
second: Math.round(u * 100),
|
|
44
|
+
third: Math.round(l * 100)
|
|
45
|
+
};
|
|
46
|
+
}, ne = (e) => {
|
|
47
|
+
let t = ee(e.first), n = W(e.second) / 100, r = W(e.third) / 100, i = (e) => {
|
|
48
|
+
let i = (t + e) / 30;
|
|
49
|
+
return U((r - n * Math.min(r, 1 - r) * Math.max(-1, Math.min(i % 2 - 1, 1))) * 255);
|
|
50
|
+
};
|
|
51
|
+
return K({
|
|
52
|
+
first: i(0),
|
|
53
|
+
second: i(8),
|
|
54
|
+
third: i(4)
|
|
55
|
+
});
|
|
56
|
+
}, re = (t) => {
|
|
57
|
+
let n = t.toUpperCase(), r = n.startsWith("#") ? n.slice(1) : n;
|
|
58
|
+
if (!/^[0-9A-F]{3}$/.test(r) && !/^[0-9A-F]{6}$/.test(r)) return;
|
|
59
|
+
let i = `#${r}`;
|
|
60
|
+
if (e(i)) return K(G(i) ?? {
|
|
61
|
+
first: 0,
|
|
62
|
+
second: 0,
|
|
63
|
+
third: 0
|
|
64
|
+
});
|
|
65
|
+
}, ie = (e) => e.slice(1).toUpperCase(), ae = (e) => {
|
|
66
|
+
let t = e.first / 255, n = e.second / 255, r = e.third / 255, i = Math.max(t, n, r), a = i - Math.min(t, n, r), o = 0;
|
|
67
|
+
a !== 0 && (o = i === t ? (n - r) / a % 6 : i === n ? (r - t) / a + 2 : (t - n) / a + 4, o = Math.round(o * 60), o < 0 && (o += 360));
|
|
68
|
+
let s = i === 0 ? 0 : a / i;
|
|
69
|
+
return {
|
|
70
|
+
hue: o,
|
|
71
|
+
saturation: s,
|
|
72
|
+
value: i
|
|
73
|
+
};
|
|
74
|
+
}, oe = (e) => {
|
|
75
|
+
let t = e.value * e.saturation, n = e.hue / 60, r = t * (1 - Math.abs(n % 2 - 1)), i = e.value - t, a = 0, o = 0, s = 0;
|
|
76
|
+
return n >= 0 && n < 1 ? (a = t, o = r) : n >= 1 && n < 2 ? (a = r, o = t) : n >= 2 && n < 3 ? (o = t, s = r) : n >= 3 && n < 4 ? (o = r, s = t) : n >= 4 && n < 5 ? (a = r, s = t) : (a = t, s = r), {
|
|
77
|
+
first: U((a + i) * 255),
|
|
78
|
+
second: U((o + i) * 255),
|
|
79
|
+
third: U((s + i) * 255)
|
|
80
|
+
};
|
|
81
|
+
}, J = (e) => {
|
|
82
|
+
let t = G(e);
|
|
83
|
+
if (t) return ae(t);
|
|
84
|
+
}, Y = (e) => K(oe(e)), X = [
|
|
85
|
+
n.HEX,
|
|
86
|
+
n.RGB,
|
|
87
|
+
n.HSL
|
|
88
|
+
], se = {
|
|
89
|
+
[n.HEX]: "Hex",
|
|
90
|
+
[n.RGB]: "RGB",
|
|
91
|
+
[n.HSL]: "HSL"
|
|
92
|
+
}, ce = (e) => {
|
|
93
|
+
let t = getComputedStyle(e).backgroundColor.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
94
|
+
if (!t) return;
|
|
95
|
+
let n = Number.parseInt(t[1] ?? "0", 10), r = Number.parseInt(t[2] ?? "0", 10), i = Number.parseInt(t[3] ?? "0", 10);
|
|
96
|
+
return `#${n.toString(16).padStart(2, "0").toUpperCase()}${r.toString(16).padStart(2, "0").toUpperCase()}${i.toString(16).padStart(2, "0").toUpperCase()}`;
|
|
97
|
+
}, Z = (t, n) => {
|
|
98
|
+
if (o(t) && e(t)) return t;
|
|
99
|
+
if (n) return ce(n);
|
|
100
|
+
}, le = (e, t) => t === n.HEX ? ie(e) : t === n.RGB ? G(e) ?? {
|
|
101
|
+
first: 0,
|
|
102
|
+
second: 0,
|
|
103
|
+
third: 0
|
|
104
|
+
} : q(e) ?? {
|
|
105
|
+
first: 0,
|
|
106
|
+
second: 0,
|
|
107
|
+
third: 0
|
|
108
|
+
}, Q = (e) => {
|
|
109
|
+
let t = Number.parseInt(e, 10);
|
|
110
|
+
if (!Number.isNaN(t)) return t;
|
|
111
|
+
}, $ = (e, t) => {
|
|
112
|
+
if (e === n.HEX) return typeof t == "string" ? re(t) : void 0;
|
|
113
|
+
if (typeof t == "string") return;
|
|
114
|
+
if (e === n.RGB) {
|
|
115
|
+
let e = K({
|
|
116
|
+
first: Q(String(t.first)) ?? 0,
|
|
117
|
+
second: Q(String(t.second)) ?? 0,
|
|
118
|
+
third: Q(String(t.third)) ?? 0
|
|
119
|
+
});
|
|
120
|
+
return G(e) ? e : void 0;
|
|
121
|
+
}
|
|
122
|
+
let r = ne({
|
|
123
|
+
first: Q(String(t.first)) ?? 0,
|
|
124
|
+
second: Q(String(t.second)) ?? 0,
|
|
125
|
+
third: Q(String(t.third)) ?? 0
|
|
126
|
+
});
|
|
127
|
+
if (r && q(r)) return r;
|
|
128
|
+
}, ue = 17, de = "#000000", fe = (e) => e ?? de, pe = ({ modelValue: e, getEditableHex: t, saturationAreaRef: n, hueSliderRef: r, disabled: i, readonly: a }) => {
|
|
129
|
+
let o = J(fe(t())) ?? {
|
|
130
|
+
hue: 0,
|
|
131
|
+
saturation: 0,
|
|
132
|
+
value: 0
|
|
133
|
+
}, s = A(o.hue), c = A(o.saturation), l = A(o.value), u = A(!1), d = A(!1), f = A(!1), p = j(null), m = j(null), h = g(() => Y({
|
|
134
|
+
hue: s.value,
|
|
135
|
+
saturation: c.value,
|
|
136
|
+
value: l.value
|
|
137
|
+
})), _ = g(() => Y({
|
|
138
|
+
hue: s.value,
|
|
139
|
+
saturation: 1,
|
|
140
|
+
value: 1
|
|
141
|
+
})), v = (e) => {
|
|
142
|
+
s.value = Math.max(0, Math.min(360, e));
|
|
143
|
+
}, y = (e, t) => {
|
|
144
|
+
c.value = Math.max(0, Math.min(1, e)), l.value = Math.max(0, Math.min(1, t));
|
|
145
|
+
}, b = (e) => {
|
|
146
|
+
let t = J(fe(e));
|
|
147
|
+
t && (u.value = !0, t.saturation > 0 && (s.value = t.hue), c.value = t.saturation, l.value = t.value, u.value = !1);
|
|
148
|
+
}, x = () => {
|
|
149
|
+
let e = t();
|
|
150
|
+
e && e.toUpperCase() !== h.value.toUpperCase() && b(e);
|
|
151
|
+
}, S = () => {
|
|
152
|
+
let n = h.value;
|
|
153
|
+
t()?.toUpperCase() !== n.toUpperCase() && (u.value = !0, e.value = n, u.value = !1);
|
|
154
|
+
};
|
|
155
|
+
L([
|
|
156
|
+
s,
|
|
157
|
+
c,
|
|
158
|
+
l
|
|
159
|
+
], () => {
|
|
160
|
+
u.value || S();
|
|
161
|
+
}), L(e, () => {
|
|
162
|
+
u.value || x();
|
|
163
|
+
}), O(() => {
|
|
164
|
+
T(() => {
|
|
165
|
+
C(), w(), x();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
let C = () => {
|
|
169
|
+
p.value = n.value?.getBoundingClientRect() ?? null;
|
|
170
|
+
}, w = () => {
|
|
171
|
+
m.value = r.value?.getBoundingClientRect() ?? null;
|
|
172
|
+
}, E = g(() => {
|
|
173
|
+
let e = p.value;
|
|
174
|
+
return e ? { transform: `translate3d(calc(${c.value * e.width}px - 50%), calc(${(1 - l.value) * e.height}px - 50%), 0)` } : {};
|
|
175
|
+
}), D = g(() => {
|
|
176
|
+
let e = m.value;
|
|
177
|
+
return e ? { transform: `translate3d(-50%, calc(${s.value / 360 * e.height}px - 50%), 0)` } : {};
|
|
178
|
+
}), k = () => !i.value && !a.value, M = (e) => {
|
|
179
|
+
let t = p.value;
|
|
180
|
+
if (!t) return;
|
|
181
|
+
let n = Math.max(0, Math.min(e.clientX - t.left, t.width)), r = Math.max(0, Math.min(e.clientY - t.top, t.height));
|
|
182
|
+
y(n / t.width, 1 - r / t.height);
|
|
183
|
+
}, N = (e) => {
|
|
184
|
+
let t = m.value;
|
|
185
|
+
t && v(Math.max(0, Math.min(e.clientY - t.top, t.height)) / t.height * 360);
|
|
186
|
+
}, P = (e) => {
|
|
187
|
+
k() && (C(), d.value = !0, M(e), e.currentTarget instanceof HTMLElement && e.currentTarget.setPointerCapture(e.pointerId));
|
|
188
|
+
}, F = (e) => {
|
|
189
|
+
k() && (w(), f.value = !0, N(e), e.currentTarget instanceof HTMLElement && e.currentTarget.setPointerCapture(e.pointerId));
|
|
190
|
+
}, I = () => {
|
|
191
|
+
d.value = !1;
|
|
192
|
+
}, R = () => {
|
|
193
|
+
f.value = !1;
|
|
194
|
+
};
|
|
195
|
+
return H(n, "pointermove", (e) => {
|
|
196
|
+
d.value && M(e);
|
|
197
|
+
}), H(n, "pointerup", I), H(n, "pointercancel", I), H(n, "lostpointercapture", I), H(r, "pointermove", (e) => {
|
|
198
|
+
f.value && N(e);
|
|
199
|
+
}), H(r, "pointerup", R), H(r, "pointercancel", R), H(r, "lostpointercapture", R), {
|
|
200
|
+
hexColor: h,
|
|
201
|
+
hueBackground: _,
|
|
202
|
+
saturationPointerStyle: E,
|
|
203
|
+
huePointerStyle: D,
|
|
204
|
+
handleSaturationPointerDown: P,
|
|
205
|
+
handleHuePointerDown: F,
|
|
206
|
+
syncFromModelValue: x
|
|
207
|
+
};
|
|
208
|
+
}, me = (e) => {
|
|
209
|
+
if (!e) return null;
|
|
210
|
+
let t = e.$el;
|
|
211
|
+
if (!(t instanceof HTMLElement)) return null;
|
|
212
|
+
let n = t.querySelector(".s-ui-color-swatch__fill");
|
|
213
|
+
return n instanceof HTMLElement ? n : null;
|
|
214
|
+
}, he = { class: "s-ui-color-area__canvas-row" }, ge = ["aria-disabled"], _e = /* @__PURE__ */ S({
|
|
215
|
+
__name: "SColorArea",
|
|
216
|
+
props: /*@__PURE__*/ C({
|
|
217
|
+
disabled: {
|
|
218
|
+
type: Boolean,
|
|
219
|
+
default: !1
|
|
220
|
+
},
|
|
221
|
+
readonly: {
|
|
222
|
+
type: Boolean,
|
|
223
|
+
default: !1
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
modelValue: { required: !0 },
|
|
227
|
+
modelModifiers: {}
|
|
228
|
+
}),
|
|
229
|
+
emits: ["update:modelValue"],
|
|
230
|
+
setup(e) {
|
|
231
|
+
let t = P(e, "modelValue"), n = F("colorResolutionSwatchRef"), r = F("saturationAreaRef"), i = F("hueSliderRef"), o = () => Z(t.value, me(n.value)), s = g(() => a(t.value)), { hexColor: c, hueBackground: l, saturationPointerStyle: u, huePointerStyle: d, handleSaturationPointerDown: f, handleHuePointerDown: p } = pe({
|
|
232
|
+
modelValue: t,
|
|
233
|
+
getEditableHex: o,
|
|
234
|
+
saturationAreaRef: r,
|
|
235
|
+
hueSliderRef: i,
|
|
236
|
+
disabled: M(() => e.disabled),
|
|
237
|
+
readonly: M(() => e.readonly)
|
|
238
|
+
});
|
|
239
|
+
return (t, a) => (k(), v("div", w({ class: ["s-ui-color-area", {
|
|
240
|
+
"s-ui-color-area--disabled": e.disabled,
|
|
241
|
+
"s-ui-color-area--readonly": e.readonly
|
|
242
|
+
}] }, t.$attrs), [x(N(V), {
|
|
243
|
+
ref_key: "colorResolutionSwatchRef",
|
|
244
|
+
ref: n,
|
|
245
|
+
class: "s-ui-color-area__color-resolution",
|
|
246
|
+
color: s.value,
|
|
247
|
+
size: N(B).SIZE_24,
|
|
248
|
+
tabindex: "-1",
|
|
249
|
+
"aria-hidden": "true"
|
|
250
|
+
}, null, 8, ["color", "size"]), y("div", he, [y("div", {
|
|
251
|
+
ref_key: "saturationAreaRef",
|
|
252
|
+
ref: r,
|
|
253
|
+
class: "s-ui-color-area__canvas",
|
|
254
|
+
role: "img",
|
|
255
|
+
"aria-label": "Color saturation and brightness",
|
|
256
|
+
style: D({ "--s-ui-color-area-hue": N(l) }),
|
|
257
|
+
onPointerdown: a[0] ||= (...e) => N(f) && N(f)(...e)
|
|
258
|
+
}, [y("div", {
|
|
259
|
+
class: "s-ui-color-area__canvas-pointer",
|
|
260
|
+
style: D({
|
|
261
|
+
...N(u),
|
|
262
|
+
backgroundColor: N(c)
|
|
263
|
+
})
|
|
264
|
+
}, null, 4)], 36), y("div", {
|
|
265
|
+
ref_key: "hueSliderRef",
|
|
266
|
+
ref: i,
|
|
267
|
+
class: "s-ui-color-area__hue",
|
|
268
|
+
role: "slider",
|
|
269
|
+
"aria-label": "Hue",
|
|
270
|
+
"aria-valuemin": "0",
|
|
271
|
+
"aria-valuemax": "360",
|
|
272
|
+
"aria-disabled": e.disabled || e.readonly,
|
|
273
|
+
onPointerdown: a[1] ||= (...e) => N(p) && N(p)(...e)
|
|
274
|
+
}, [y("div", {
|
|
275
|
+
class: "s-ui-color-area__hue-pointer",
|
|
276
|
+
style: D({
|
|
277
|
+
...N(d),
|
|
278
|
+
backgroundColor: N(l)
|
|
279
|
+
})
|
|
280
|
+
}, null, 4)], 40, ge)])], 16));
|
|
281
|
+
}
|
|
282
|
+
}), ve = { class: "s-ui-color-values__left" }, ye = { class: "s-ui-color-values__format" }, be = { class: "s-ui-color-values__value-group" }, xe = { class: "s-ui-color-values__inputs" }, Se = {
|
|
283
|
+
key: 0,
|
|
284
|
+
class: "s-ui-color-values__input-wrap"
|
|
285
|
+
}, Ce = ["disabled", "readonly"], we = { class: "s-ui-color-values__input-wrap" }, Te = [
|
|
286
|
+
"disabled",
|
|
287
|
+
"readonly",
|
|
288
|
+
"aria-label"
|
|
289
|
+
], Ee = { class: "s-ui-color-values__input-wrap" }, De = [
|
|
290
|
+
"disabled",
|
|
291
|
+
"readonly",
|
|
292
|
+
"aria-label"
|
|
293
|
+
], Oe = { class: "s-ui-color-values__input-wrap" }, ke = [
|
|
294
|
+
"disabled",
|
|
295
|
+
"readonly",
|
|
296
|
+
"aria-label"
|
|
297
|
+
], Ae = /* @__PURE__ */ S({
|
|
298
|
+
__name: "SColorValues",
|
|
299
|
+
props: /*@__PURE__*/ C({
|
|
300
|
+
disabled: {
|
|
301
|
+
type: Boolean,
|
|
302
|
+
default: !1
|
|
303
|
+
},
|
|
304
|
+
readonly: {
|
|
305
|
+
type: Boolean,
|
|
306
|
+
default: !1
|
|
307
|
+
},
|
|
308
|
+
formats: { default: () => X }
|
|
309
|
+
}, {
|
|
310
|
+
modelValue: { required: !0 },
|
|
311
|
+
modelModifiers: {},
|
|
312
|
+
format: { default: n.HEX },
|
|
313
|
+
formatModifiers: {}
|
|
314
|
+
}),
|
|
315
|
+
emits: /*@__PURE__*/ C(["formatDropdownOpen", "formatDropdownClose"], ["update:modelValue", "update:format"]),
|
|
316
|
+
setup(e, { emit: t }) {
|
|
317
|
+
let r = P(e, "modelValue"), i = P(e, "format"), o = t, d = F("previewSwatchRef"), f = A(""), p = A("0"), _ = A("0"), b = A("0"), S = g(() => (e.formats.length > 0 ? e.formats : X).map((e) => ({
|
|
318
|
+
value: e,
|
|
319
|
+
label: se[e]
|
|
320
|
+
}))), C = g(() => a(r.value)), E = g(() => Z(r.value, me(d.value))), D = g(() => i.value === n.RGB ? "Red channel" : "Hue"), j = g(() => i.value === n.RGB ? "Green channel" : "Saturation"), M = g(() => i.value === n.RGB ? "Blue channel" : "Lightness"), R = () => {
|
|
321
|
+
let e = E.value;
|
|
322
|
+
if (!e) return;
|
|
323
|
+
let t = le(e, i.value);
|
|
324
|
+
if (i.value === n.HEX && typeof t == "string") {
|
|
325
|
+
f.value = t;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
typeof t == "object" && (p.value = String(t.first), _.value = String(t.second), b.value = String(t.third));
|
|
329
|
+
};
|
|
330
|
+
L([
|
|
331
|
+
r,
|
|
332
|
+
i,
|
|
333
|
+
E
|
|
334
|
+
], () => {
|
|
335
|
+
R();
|
|
336
|
+
}), O(() => {
|
|
337
|
+
T(() => {
|
|
338
|
+
R();
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
let H = () => {
|
|
342
|
+
if (e.disabled || e.readonly) return;
|
|
343
|
+
if (i.value === n.HEX) {
|
|
344
|
+
let e = $(n.HEX, f.value);
|
|
345
|
+
e && (r.value = e), R();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let t = $(i.value, {
|
|
349
|
+
first: Number.parseInt(p.value, 10),
|
|
350
|
+
second: Number.parseInt(_.value, 10),
|
|
351
|
+
third: Number.parseInt(b.value, 10)
|
|
352
|
+
});
|
|
353
|
+
t && (r.value = t), R();
|
|
354
|
+
}, U = (e) => {
|
|
355
|
+
e.key === "Enter" && (e.preventDefault(), H());
|
|
356
|
+
};
|
|
357
|
+
return (t, r) => (k(), v("div", w({ class: ["s-ui-color-values", {
|
|
358
|
+
"s-ui-color-values--disabled": e.disabled,
|
|
359
|
+
"s-ui-color-values--readonly": e.readonly
|
|
360
|
+
}] }, t.$attrs), [y("div", ve, [x(N(V), {
|
|
361
|
+
ref_key: "previewSwatchRef",
|
|
362
|
+
ref: d,
|
|
363
|
+
class: "s-ui-color-values__preview",
|
|
364
|
+
color: C.value,
|
|
365
|
+
size: N(B).SIZE_32,
|
|
366
|
+
disabled: e.disabled,
|
|
367
|
+
tabindex: "-1",
|
|
368
|
+
"aria-hidden": "true"
|
|
369
|
+
}, null, 8, [
|
|
370
|
+
"color",
|
|
371
|
+
"size",
|
|
372
|
+
"disabled"
|
|
373
|
+
]), y("div", ye, [x(N(m), {
|
|
374
|
+
modelValue: i.value,
|
|
375
|
+
"onUpdate:modelValue": r[0] ||= (e) => i.value = e,
|
|
376
|
+
class: "s-ui-color-values__format-select",
|
|
377
|
+
options: S.value,
|
|
378
|
+
disabled: e.disabled,
|
|
379
|
+
readonly: e.readonly,
|
|
380
|
+
bordered: !0,
|
|
381
|
+
clearable: !1,
|
|
382
|
+
"close-on-select": !0,
|
|
383
|
+
"fit-viewport": !1,
|
|
384
|
+
"aria-label": "Color format",
|
|
385
|
+
onOpen: r[1] ||= (e) => o("formatDropdownOpen"),
|
|
386
|
+
onClose: r[2] ||= (e) => o("formatDropdownClose")
|
|
387
|
+
}, null, 8, [
|
|
388
|
+
"modelValue",
|
|
389
|
+
"options",
|
|
390
|
+
"disabled",
|
|
391
|
+
"readonly"
|
|
392
|
+
])])]), y("div", be, [
|
|
393
|
+
x(N(u), {
|
|
394
|
+
class: "s-ui-color-values__pipette",
|
|
395
|
+
appearance: N(l).BARE,
|
|
396
|
+
variant: N(c).NEUTRAL,
|
|
397
|
+
size: N(s).SMALL,
|
|
398
|
+
icon: "pipette",
|
|
399
|
+
"aria-label": "Pick color",
|
|
400
|
+
"aria-disabled": "true",
|
|
401
|
+
disabled: e.disabled,
|
|
402
|
+
tabindex: "-1"
|
|
403
|
+
}, null, 8, [
|
|
404
|
+
"appearance",
|
|
405
|
+
"variant",
|
|
406
|
+
"size",
|
|
407
|
+
"disabled"
|
|
408
|
+
]),
|
|
409
|
+
r[9] ||= y("span", {
|
|
410
|
+
class: "s-ui-color-values__separator",
|
|
411
|
+
"aria-hidden": "true"
|
|
412
|
+
}, null, -1),
|
|
413
|
+
y("div", xe, [i.value === N(n).HEX ? (k(), v("div", Se, [z(y("input", {
|
|
414
|
+
"onUpdate:modelValue": r[3] ||= (e) => f.value = e,
|
|
415
|
+
class: "s-ui-color-values__input s-ui-typography-body-14-regular",
|
|
416
|
+
type: "text",
|
|
417
|
+
inputmode: "text",
|
|
418
|
+
spellcheck: "false",
|
|
419
|
+
disabled: e.disabled,
|
|
420
|
+
readonly: e.readonly,
|
|
421
|
+
"aria-label": "Hex color value",
|
|
422
|
+
onBlur: H,
|
|
423
|
+
onKeydown: U
|
|
424
|
+
}, null, 40, Ce), [[I, f.value]])])) : (k(), v(h, { key: 1 }, [
|
|
425
|
+
y("div", we, [z(y("input", {
|
|
426
|
+
"onUpdate:modelValue": r[4] ||= (e) => p.value = e,
|
|
427
|
+
class: "s-ui-color-values__input s-ui-typography-body-14-regular",
|
|
428
|
+
type: "text",
|
|
429
|
+
inputmode: "numeric",
|
|
430
|
+
spellcheck: "false",
|
|
431
|
+
disabled: e.disabled,
|
|
432
|
+
readonly: e.readonly,
|
|
433
|
+
"aria-label": D.value,
|
|
434
|
+
onBlur: H,
|
|
435
|
+
onKeydown: U
|
|
436
|
+
}, null, 40, Te), [[I, p.value]])]),
|
|
437
|
+
r[7] ||= y("span", {
|
|
438
|
+
class: "s-ui-color-values__separator",
|
|
439
|
+
"aria-hidden": "true"
|
|
440
|
+
}, null, -1),
|
|
441
|
+
y("div", Ee, [z(y("input", {
|
|
442
|
+
"onUpdate:modelValue": r[5] ||= (e) => _.value = e,
|
|
443
|
+
class: "s-ui-color-values__input s-ui-typography-body-14-regular",
|
|
444
|
+
type: "text",
|
|
445
|
+
inputmode: "numeric",
|
|
446
|
+
spellcheck: "false",
|
|
447
|
+
disabled: e.disabled,
|
|
448
|
+
readonly: e.readonly,
|
|
449
|
+
"aria-label": j.value,
|
|
450
|
+
onBlur: H,
|
|
451
|
+
onKeydown: U
|
|
452
|
+
}, null, 40, De), [[I, _.value]])]),
|
|
453
|
+
r[8] ||= y("span", {
|
|
454
|
+
class: "s-ui-color-values__separator",
|
|
455
|
+
"aria-hidden": "true"
|
|
456
|
+
}, null, -1),
|
|
457
|
+
y("div", Oe, [z(y("input", {
|
|
458
|
+
"onUpdate:modelValue": r[6] ||= (e) => b.value = e,
|
|
459
|
+
class: "s-ui-color-values__input s-ui-typography-body-14-regular",
|
|
460
|
+
type: "text",
|
|
461
|
+
inputmode: "numeric",
|
|
462
|
+
spellcheck: "false",
|
|
463
|
+
disabled: e.disabled,
|
|
464
|
+
readonly: e.readonly,
|
|
465
|
+
"aria-label": M.value,
|
|
466
|
+
onBlur: H,
|
|
467
|
+
onKeydown: U
|
|
468
|
+
}, null, 40, ke), [[I, b.value]])])
|
|
469
|
+
], 64))])
|
|
470
|
+
])], 16));
|
|
471
|
+
}
|
|
472
|
+
}), je = { class: "s-ui-color-picker__section" }, Me = { class: "s-ui-color-picker__section" }, Ne = { class: "s-ui-color-picker__custom-editor" }, Pe = { class: "s-ui-color-picker__custom-actions" }, Fe = /* @__PURE__ */ S({
|
|
473
|
+
__name: "SColorPicker",
|
|
474
|
+
props: /*@__PURE__*/ C({
|
|
475
|
+
disabled: {
|
|
476
|
+
type: Boolean,
|
|
477
|
+
default: !1
|
|
478
|
+
},
|
|
479
|
+
recommendedColors: {},
|
|
480
|
+
recentColors: { default: () => [] }
|
|
481
|
+
}, {
|
|
482
|
+
modelValue: {},
|
|
483
|
+
modelModifiers: {}
|
|
484
|
+
}),
|
|
485
|
+
emits: /*@__PURE__*/ C([
|
|
486
|
+
"select",
|
|
487
|
+
"customEditorOpen",
|
|
488
|
+
"customEditorClose",
|
|
489
|
+
"formatDropdownOpen",
|
|
490
|
+
"formatDropdownClose"
|
|
491
|
+
], ["update:modelValue"]),
|
|
492
|
+
setup(e, { emit: a }) {
|
|
493
|
+
let o = P(e, "modelValue"), m = a, h = A(!1), v = A("#526DE3"), S = A(n.HEX), C = g(() => e.recommendedColors && e.recommendedColors.length > 0 ? e.recommendedColors : r), T = g(() => e.recentColors.length <= 17 ? e.recentColors : e.recentColors.slice(0, 17)), D = () => {
|
|
494
|
+
if (o.value) {
|
|
495
|
+
v.value = o.value;
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
v.value = "#526DE3";
|
|
499
|
+
}, O = (e) => {
|
|
500
|
+
m("select", e);
|
|
501
|
+
}, j = () => {
|
|
502
|
+
o.value = v.value, m("select", v.value), h.value = !1;
|
|
503
|
+
}, M = () => {
|
|
504
|
+
h.value = !1;
|
|
505
|
+
};
|
|
506
|
+
return L(h, (e, t) => {
|
|
507
|
+
if (e && !t) {
|
|
508
|
+
D(), m("customEditorOpen");
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
!e && t && m("customEditorClose");
|
|
512
|
+
}), (n, r) => (k(), _(N(p), w({ width: 336 }, n.$attrs), {
|
|
513
|
+
default: R(() => [y("div", { class: E(["s-ui-color-picker", { "s-ui-color-picker--disabled": e.disabled }]) }, [y("section", je, [r[8] ||= y("span", { class: "s-ui-color-picker__label" }, "Рекомендованные цвета", -1), x(N(i), {
|
|
514
|
+
modelValue: o.value,
|
|
515
|
+
"onUpdate:modelValue": r[0] ||= (e) => o.value = e,
|
|
516
|
+
class: "s-ui-color-picker__palette",
|
|
517
|
+
layout: N(t).GRID,
|
|
518
|
+
colors: C.value,
|
|
519
|
+
size: N(B).SIZE_32,
|
|
520
|
+
disabled: e.disabled,
|
|
521
|
+
onSelect: O
|
|
522
|
+
}, null, 8, [
|
|
523
|
+
"modelValue",
|
|
524
|
+
"layout",
|
|
525
|
+
"colors",
|
|
526
|
+
"size",
|
|
527
|
+
"disabled"
|
|
528
|
+
])]), y("section", Me, [r[11] ||= y("span", { class: "s-ui-color-picker__label" }, "Последние использованные", -1), x(N(i), {
|
|
529
|
+
modelValue: o.value,
|
|
530
|
+
"onUpdate:modelValue": r[7] ||= (e) => o.value = e,
|
|
531
|
+
class: "s-ui-color-picker__palette",
|
|
532
|
+
layout: N(t).ROW,
|
|
533
|
+
colors: T.value,
|
|
534
|
+
size: N(B).SIZE_32,
|
|
535
|
+
disabled: e.disabled,
|
|
536
|
+
onSelect: O
|
|
537
|
+
}, {
|
|
538
|
+
append: R(() => [x(N(f), {
|
|
539
|
+
modelValue: h.value,
|
|
540
|
+
"onUpdate:modelValue": r[6] ||= (e) => h.value = e,
|
|
541
|
+
placement: N(d).RIGHT_START,
|
|
542
|
+
offset: 8,
|
|
543
|
+
shift: !0,
|
|
544
|
+
flip: !0,
|
|
545
|
+
disabled: e.disabled,
|
|
546
|
+
"dismiss-on-click-outside": !0,
|
|
547
|
+
"dismiss-on-escape": !0
|
|
548
|
+
}, {
|
|
549
|
+
trigger: R(({ toggle: t, triggerProps: n }) => [x(N(u), w(n, {
|
|
550
|
+
class: "s-ui-color-picker__add-button",
|
|
551
|
+
appearance: N(l).OUTLINED,
|
|
552
|
+
variant: N(c).NEUTRAL,
|
|
553
|
+
size: N(s).SMALL,
|
|
554
|
+
icon: "plus",
|
|
555
|
+
"aria-label": "Add custom color",
|
|
556
|
+
disabled: e.disabled,
|
|
557
|
+
onClick: t
|
|
558
|
+
}), null, 16, [
|
|
559
|
+
"appearance",
|
|
560
|
+
"variant",
|
|
561
|
+
"size",
|
|
562
|
+
"disabled",
|
|
563
|
+
"onClick"
|
|
564
|
+
])]),
|
|
565
|
+
content: R(() => [x(N(p), { width: 320 }, {
|
|
566
|
+
footer: R(() => [y("div", Pe, [x(N(u), {
|
|
567
|
+
class: "s-ui-color-picker__save-button",
|
|
568
|
+
appearance: N(l).MAJOR,
|
|
569
|
+
variant: N(c).MAIN,
|
|
570
|
+
size: N(s).SMALL,
|
|
571
|
+
disabled: e.disabled,
|
|
572
|
+
onClick: j
|
|
573
|
+
}, {
|
|
574
|
+
default: R(() => [...r[9] ||= [b(" Сохранить ", -1)]]),
|
|
575
|
+
_: 1
|
|
576
|
+
}, 8, [
|
|
577
|
+
"appearance",
|
|
578
|
+
"variant",
|
|
579
|
+
"size",
|
|
580
|
+
"disabled"
|
|
581
|
+
]), x(N(u), {
|
|
582
|
+
class: "s-ui-color-picker__cancel-button",
|
|
583
|
+
appearance: N(l).MINOR,
|
|
584
|
+
variant: N(c).NEUTRAL,
|
|
585
|
+
size: N(s).SMALL,
|
|
586
|
+
disabled: e.disabled,
|
|
587
|
+
onClick: M
|
|
588
|
+
}, {
|
|
589
|
+
default: R(() => [...r[10] ||= [b(" Отменить ", -1)]]),
|
|
590
|
+
_: 1
|
|
591
|
+
}, 8, [
|
|
592
|
+
"appearance",
|
|
593
|
+
"variant",
|
|
594
|
+
"size",
|
|
595
|
+
"disabled"
|
|
596
|
+
])])]),
|
|
597
|
+
default: R(() => [y("div", Ne, [x(_e, {
|
|
598
|
+
modelValue: v.value,
|
|
599
|
+
"onUpdate:modelValue": r[1] ||= (e) => v.value = e,
|
|
600
|
+
disabled: e.disabled
|
|
601
|
+
}, null, 8, ["modelValue", "disabled"]), x(Ae, {
|
|
602
|
+
modelValue: v.value,
|
|
603
|
+
"onUpdate:modelValue": r[2] ||= (e) => v.value = e,
|
|
604
|
+
format: S.value,
|
|
605
|
+
"onUpdate:format": r[3] ||= (e) => S.value = e,
|
|
606
|
+
disabled: e.disabled,
|
|
607
|
+
onFormatDropdownOpen: r[4] ||= (e) => m("formatDropdownOpen"),
|
|
608
|
+
onFormatDropdownClose: r[5] ||= (e) => m("formatDropdownClose")
|
|
609
|
+
}, null, 8, [
|
|
610
|
+
"modelValue",
|
|
611
|
+
"format",
|
|
612
|
+
"disabled"
|
|
613
|
+
])])]),
|
|
614
|
+
_: 1
|
|
615
|
+
})]),
|
|
616
|
+
_: 1
|
|
617
|
+
}, 8, [
|
|
618
|
+
"modelValue",
|
|
619
|
+
"placement",
|
|
620
|
+
"disabled"
|
|
621
|
+
])]),
|
|
622
|
+
_: 1
|
|
623
|
+
}, 8, [
|
|
624
|
+
"modelValue",
|
|
625
|
+
"layout",
|
|
626
|
+
"colors",
|
|
627
|
+
"size",
|
|
628
|
+
"disabled"
|
|
629
|
+
])])], 2)]),
|
|
630
|
+
_: 1
|
|
631
|
+
}, 16));
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
//#endregion
|
|
635
|
+
export { ue as i, Ae as n, _e as r, Fe as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./contrastSurfaceTextColor-Ybh-FZof.cjs"),t=require("./SColorPalette-CYGnmIWP.cjs"),n=require("./colorValue-DClAEDHr.cjs"),r=require("./SButton.types-UKroD-ev.cjs"),i=require("./SButton-C-z_q5CG.cjs"),a=require("./useFloatingOverlay-B1UCUYQQ.cjs"),o=require("./SDropdown-_QUOP-rw.cjs"),s=require("./SSelect-CT3AMH-u.cjs");let c=require("vue"),l=require("@shtabapp/ui-kit-primitives"),u=require("@vueuse/core");var d=e=>Math.max(0,Math.min(255,Math.round(e))),f=e=>{let t=e%360;return t<0?t+360:t},p=e=>Math.max(0,Math.min(100,Math.round(e))),m=e=>{let t=e.slice(1);if(t.length===3){let e=t[0],n=t[1],r=t[2];return!e||!n||!r?void 0:`${e}${e}${n}${n}${r}${r}`}if(t.length===6||t.length===8)return t.slice(0,6)},h=e=>{let t=m(e);if(!t)return;let n=Number.parseInt(t.slice(0,2),16),r=Number.parseInt(t.slice(2,4),16),i=Number.parseInt(t.slice(4,6),16);if(!(Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(i)))return{first:n,second:r,third:i}},g=e=>{let t=d(e.first),n=d(e.second),r=d(e.third);return`#${t.toString(16).padStart(2,`0`).toUpperCase()}${n.toString(16).padStart(2,`0`).toUpperCase()}${r.toString(16).padStart(2,`0`).toUpperCase()}`},_=e=>{let t=h(e);if(!t)return;let n=t.first/255,r=t.second/255,i=t.third/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=a-o,c=0,l=(a+o)/2;s!==0&&(c=a===n?((r-i)/s+(r<i?6:0))*60:a===r?((i-n)/s+2)*60:((n-r)/s+4)*60);let u=0;return s!==0&&(u=l>.5?s/(2-a-o):s/(a+o)),{first:Math.round(c),second:Math.round(u*100),third:Math.round(l*100)}},v=e=>{let t=f(e.first),n=p(e.second)/100,r=p(e.third)/100,i=e=>{let i=(t+e)/30;return d((r-n*Math.min(r,1-r)*Math.max(-1,Math.min(i%2-1,1)))*255)};return g({first:i(0),second:i(8),third:i(4)})},y=t=>{let n=t.toUpperCase(),r=n.startsWith(`#`)?n.slice(1):n;if(!/^[0-9A-F]{3}$/.test(r)&&!/^[0-9A-F]{6}$/.test(r))return;let i=`#${r}`;if(e.n(i))return g(h(i)??{first:0,second:0,third:0})},b=e=>e.slice(1).toUpperCase(),x=e=>{let t=e.first/255,n=e.second/255,r=e.third/255,i=Math.max(t,n,r),a=i-Math.min(t,n,r),o=0;a!==0&&(o=i===t?(n-r)/a%6:i===n?(r-t)/a+2:(t-n)/a+4,o=Math.round(o*60),o<0&&(o+=360));let s=i===0?0:a/i;return{hue:o,saturation:s,value:i}},S=e=>{let t=e.value*e.saturation,n=e.hue/60,r=t*(1-Math.abs(n%2-1)),i=e.value-t,a=0,o=0,s=0;return n>=0&&n<1?(a=t,o=r):n>=1&&n<2?(a=r,o=t):n>=2&&n<3?(o=t,s=r):n>=3&&n<4?(o=r,s=t):n>=4&&n<5?(a=r,s=t):(a=t,s=r),{first:d((a+i)*255),second:d((o+i)*255),third:d((s+i)*255)}},C=e=>{let t=h(e);if(t)return x(t)},w=e=>g(S(e)),T=[t.o.HEX,t.o.RGB,t.o.HSL],E={[t.o.HEX]:`Hex`,[t.o.RGB]:`RGB`,[t.o.HSL]:`HSL`},D=e=>{let t=getComputedStyle(e).backgroundColor.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(!t)return;let n=Number.parseInt(t[1]??`0`,10),r=Number.parseInt(t[2]??`0`,10),i=Number.parseInt(t[3]??`0`,10);return`#${n.toString(16).padStart(2,`0`).toUpperCase()}${r.toString(16).padStart(2,`0`).toUpperCase()}${i.toString(16).padStart(2,`0`).toUpperCase()}`},O=(t,r)=>{if(n.n(t)&&e.n(t))return t;if(r)return D(r)},k=(e,n)=>n===t.o.HEX?b(e):n===t.o.RGB?h(e)??{first:0,second:0,third:0}:_(e)??{first:0,second:0,third:0},A=e=>{let t=Number.parseInt(e,10);if(!Number.isNaN(t))return t},j=(e,n)=>{if(e===t.o.HEX)return typeof n==`string`?y(n):void 0;if(typeof n==`string`)return;if(e===t.o.RGB){let e=g({first:A(String(n.first))??0,second:A(String(n.second))??0,third:A(String(n.third))??0});return h(e)?e:void 0}let r=v({first:A(String(n.first))??0,second:A(String(n.second))??0,third:A(String(n.third))??0});if(r&&_(r))return r},M=17,N=`#000000`,P=e=>e??N,F=({modelValue:e,getEditableHex:t,saturationAreaRef:n,hueSliderRef:r,disabled:i,readonly:a})=>{let o=C(P(t()))??{hue:0,saturation:0,value:0},s=(0,c.ref)(o.hue),l=(0,c.ref)(o.saturation),d=(0,c.ref)(o.value),f=(0,c.ref)(!1),p=(0,c.ref)(!1),m=(0,c.ref)(!1),h=(0,c.shallowRef)(null),g=(0,c.shallowRef)(null),_=(0,c.computed)(()=>w({hue:s.value,saturation:l.value,value:d.value})),v=(0,c.computed)(()=>w({hue:s.value,saturation:1,value:1})),y=e=>{s.value=Math.max(0,Math.min(360,e))},b=(e,t)=>{l.value=Math.max(0,Math.min(1,e)),d.value=Math.max(0,Math.min(1,t))},x=e=>{let t=C(P(e));t&&(f.value=!0,t.saturation>0&&(s.value=t.hue),l.value=t.saturation,d.value=t.value,f.value=!1)},S=()=>{let e=t();e&&e.toUpperCase()!==_.value.toUpperCase()&&x(e)},T=()=>{let n=_.value;t()?.toUpperCase()!==n.toUpperCase()&&(f.value=!0,e.value=n,f.value=!1)};(0,c.watch)([s,l,d],()=>{f.value||T()}),(0,c.watch)(e,()=>{f.value||S()}),(0,c.onMounted)(()=>{(0,c.nextTick)(()=>{E(),D(),S()})});let E=()=>{h.value=n.value?.getBoundingClientRect()??null},D=()=>{g.value=r.value?.getBoundingClientRect()??null},O=(0,c.computed)(()=>{let e=h.value;return e?{transform:`translate3d(calc(${l.value*e.width}px - 50%), calc(${(1-d.value)*e.height}px - 50%), 0)`}:{}}),k=(0,c.computed)(()=>{let e=g.value;return e?{transform:`translate3d(-50%, calc(${s.value/360*e.height}px - 50%), 0)`}:{}}),A=()=>!i.value&&!a.value,j=e=>{let t=h.value;if(!t)return;let n=Math.max(0,Math.min(e.clientX-t.left,t.width)),r=Math.max(0,Math.min(e.clientY-t.top,t.height));b(n/t.width,1-r/t.height)},M=e=>{let t=g.value;t&&y(Math.max(0,Math.min(e.clientY-t.top,t.height))/t.height*360)},N=e=>{A()&&(E(),p.value=!0,j(e),e.currentTarget instanceof HTMLElement&&e.currentTarget.setPointerCapture(e.pointerId))},F=e=>{A()&&(D(),m.value=!0,M(e),e.currentTarget instanceof HTMLElement&&e.currentTarget.setPointerCapture(e.pointerId))},I=()=>{p.value=!1},L=()=>{m.value=!1};return(0,u.useEventListener)(n,`pointermove`,e=>{p.value&&j(e)}),(0,u.useEventListener)(n,`pointerup`,I),(0,u.useEventListener)(n,`pointercancel`,I),(0,u.useEventListener)(n,`lostpointercapture`,I),(0,u.useEventListener)(r,`pointermove`,e=>{m.value&&M(e)}),(0,u.useEventListener)(r,`pointerup`,L),(0,u.useEventListener)(r,`pointercancel`,L),(0,u.useEventListener)(r,`lostpointercapture`,L),{hexColor:_,hueBackground:v,saturationPointerStyle:O,huePointerStyle:k,handleSaturationPointerDown:N,handleHuePointerDown:F,syncFromModelValue:S}},I=e=>{if(!e)return null;let t=e.$el;if(!(t instanceof HTMLElement))return null;let n=t.querySelector(`.s-ui-color-swatch__fill`);return n instanceof HTMLElement?n:null},L={class:`s-ui-color-area__canvas-row`},R=[`aria-disabled`],z=(0,c.defineComponent)({__name:`SColorArea`,props:(0,c.mergeModels)({disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=(0,c.useModel)(e,`modelValue`),r=(0,c.useTemplateRef)(`colorResolutionSwatchRef`),i=(0,c.useTemplateRef)(`saturationAreaRef`),a=(0,c.useTemplateRef)(`hueSliderRef`),o=()=>O(t.value,I(r.value)),s=(0,c.computed)(()=>n.a(t.value)),{hexColor:u,hueBackground:d,saturationPointerStyle:f,huePointerStyle:p,handleSaturationPointerDown:m,handleHuePointerDown:h}=F({modelValue:t,getEditableHex:o,saturationAreaRef:i,hueSliderRef:a,disabled:(0,c.toRef)(()=>e.disabled),readonly:(0,c.toRef)(()=>e.readonly)});return(t,n)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,(0,c.mergeProps)({class:[`s-ui-color-area`,{"s-ui-color-area--disabled":e.disabled,"s-ui-color-area--readonly":e.readonly}]},t.$attrs),[(0,c.createVNode)((0,c.unref)(l.SColorSwatch),{ref_key:`colorResolutionSwatchRef`,ref:r,class:`s-ui-color-area__color-resolution`,color:s.value,size:(0,c.unref)(l.ESColorSwatchSize).SIZE_24,tabindex:`-1`,"aria-hidden":`true`},null,8,[`color`,`size`]),(0,c.createElementVNode)(`div`,L,[(0,c.createElementVNode)(`div`,{ref_key:`saturationAreaRef`,ref:i,class:`s-ui-color-area__canvas`,role:`img`,"aria-label":`Color saturation and brightness`,style:(0,c.normalizeStyle)({"--s-ui-color-area-hue":(0,c.unref)(d)}),onPointerdown:n[0]||=(...e)=>(0,c.unref)(m)&&(0,c.unref)(m)(...e)},[(0,c.createElementVNode)(`div`,{class:`s-ui-color-area__canvas-pointer`,style:(0,c.normalizeStyle)({...(0,c.unref)(f),backgroundColor:(0,c.unref)(u)})},null,4)],36),(0,c.createElementVNode)(`div`,{ref_key:`hueSliderRef`,ref:a,class:`s-ui-color-area__hue`,role:`slider`,"aria-label":`Hue`,"aria-valuemin":`0`,"aria-valuemax":`360`,"aria-disabled":e.disabled||e.readonly,onPointerdown:n[1]||=(...e)=>(0,c.unref)(h)&&(0,c.unref)(h)(...e)},[(0,c.createElementVNode)(`div`,{class:`s-ui-color-area__hue-pointer`,style:(0,c.normalizeStyle)({...(0,c.unref)(p),backgroundColor:(0,c.unref)(d)})},null,4)],40,R)])],16))}}),B={class:`s-ui-color-values__left`},V={class:`s-ui-color-values__format`},H={class:`s-ui-color-values__value-group`},U={class:`s-ui-color-values__inputs`},W={key:0,class:`s-ui-color-values__input-wrap`},G=[`disabled`,`readonly`],K={class:`s-ui-color-values__input-wrap`},q=[`disabled`,`readonly`,`aria-label`],J={class:`s-ui-color-values__input-wrap`},Y=[`disabled`,`readonly`,`aria-label`],X={class:`s-ui-color-values__input-wrap`},Z=[`disabled`,`readonly`,`aria-label`],Q=(0,c.defineComponent)({__name:`SColorValues`,props:(0,c.mergeModels)({disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},formats:{default:()=>T}},{modelValue:{required:!0},modelModifiers:{},format:{default:t.o.HEX},formatModifiers:{}}),emits:(0,c.mergeModels)([`formatDropdownOpen`,`formatDropdownClose`],[`update:modelValue`,`update:format`]),setup(e,{emit:a}){let o=(0,c.useModel)(e,`modelValue`),u=(0,c.useModel)(e,`format`),d=a,f=(0,c.useTemplateRef)(`previewSwatchRef`),p=(0,c.ref)(``),m=(0,c.ref)(`0`),h=(0,c.ref)(`0`),g=(0,c.ref)(`0`),_=(0,c.computed)(()=>(e.formats.length>0?e.formats:T).map(e=>({value:e,label:E[e]}))),v=(0,c.computed)(()=>n.a(o.value)),y=(0,c.computed)(()=>O(o.value,I(f.value))),b=(0,c.computed)(()=>u.value===t.o.RGB?`Red channel`:`Hue`),x=(0,c.computed)(()=>u.value===t.o.RGB?`Green channel`:`Saturation`),S=(0,c.computed)(()=>u.value===t.o.RGB?`Blue channel`:`Lightness`),C=()=>{let e=y.value;if(!e)return;let n=k(e,u.value);if(u.value===t.o.HEX&&typeof n==`string`){p.value=n;return}typeof n==`object`&&(m.value=String(n.first),h.value=String(n.second),g.value=String(n.third))};(0,c.watch)([o,u,y],()=>{C()}),(0,c.onMounted)(()=>{(0,c.nextTick)(()=>{C()})});let w=()=>{if(e.disabled||e.readonly)return;if(u.value===t.o.HEX){let e=j(t.o.HEX,p.value);e&&(o.value=e),C();return}let n=j(u.value,{first:Number.parseInt(m.value,10),second:Number.parseInt(h.value,10),third:Number.parseInt(g.value,10)});n&&(o.value=n),C()},D=e=>{e.key===`Enter`&&(e.preventDefault(),w())};return(n,a)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,(0,c.mergeProps)({class:[`s-ui-color-values`,{"s-ui-color-values--disabled":e.disabled,"s-ui-color-values--readonly":e.readonly}]},n.$attrs),[(0,c.createElementVNode)(`div`,B,[(0,c.createVNode)((0,c.unref)(l.SColorSwatch),{ref_key:`previewSwatchRef`,ref:f,class:`s-ui-color-values__preview`,color:v.value,size:(0,c.unref)(l.ESColorSwatchSize).SIZE_32,disabled:e.disabled,tabindex:`-1`,"aria-hidden":`true`},null,8,[`color`,`size`,`disabled`]),(0,c.createElementVNode)(`div`,V,[(0,c.createVNode)((0,c.unref)(s.t),{modelValue:u.value,"onUpdate:modelValue":a[0]||=e=>u.value=e,class:`s-ui-color-values__format-select`,options:_.value,disabled:e.disabled,readonly:e.readonly,bordered:!0,clearable:!1,"close-on-select":!0,"fit-viewport":!1,"aria-label":`Color format`,onOpen:a[1]||=e=>d(`formatDropdownOpen`),onClose:a[2]||=e=>d(`formatDropdownClose`)},null,8,[`modelValue`,`options`,`disabled`,`readonly`])])]),(0,c.createElementVNode)(`div`,H,[(0,c.createVNode)((0,c.unref)(i.t),{class:`s-ui-color-values__pipette`,appearance:(0,c.unref)(r.t).BARE,variant:(0,c.unref)(r.r).NEUTRAL,size:(0,c.unref)(r.n).SMALL,icon:`pipette`,"aria-label":`Pick color`,"aria-disabled":`true`,disabled:e.disabled,tabindex:`-1`},null,8,[`appearance`,`variant`,`size`,`disabled`]),a[9]||=(0,c.createElementVNode)(`span`,{class:`s-ui-color-values__separator`,"aria-hidden":`true`},null,-1),(0,c.createElementVNode)(`div`,U,[u.value===(0,c.unref)(t.o).HEX?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,W,[(0,c.withDirectives)((0,c.createElementVNode)(`input`,{"onUpdate:modelValue":a[3]||=e=>p.value=e,class:`s-ui-color-values__input s-ui-typography-body-14-regular`,type:`text`,inputmode:`text`,spellcheck:`false`,disabled:e.disabled,readonly:e.readonly,"aria-label":`Hex color value`,onBlur:w,onKeydown:D},null,40,G),[[c.vModelText,p.value]])])):((0,c.openBlock)(),(0,c.createElementBlock)(c.Fragment,{key:1},[(0,c.createElementVNode)(`div`,K,[(0,c.withDirectives)((0,c.createElementVNode)(`input`,{"onUpdate:modelValue":a[4]||=e=>m.value=e,class:`s-ui-color-values__input s-ui-typography-body-14-regular`,type:`text`,inputmode:`numeric`,spellcheck:`false`,disabled:e.disabled,readonly:e.readonly,"aria-label":b.value,onBlur:w,onKeydown:D},null,40,q),[[c.vModelText,m.value]])]),a[7]||=(0,c.createElementVNode)(`span`,{class:`s-ui-color-values__separator`,"aria-hidden":`true`},null,-1),(0,c.createElementVNode)(`div`,J,[(0,c.withDirectives)((0,c.createElementVNode)(`input`,{"onUpdate:modelValue":a[5]||=e=>h.value=e,class:`s-ui-color-values__input s-ui-typography-body-14-regular`,type:`text`,inputmode:`numeric`,spellcheck:`false`,disabled:e.disabled,readonly:e.readonly,"aria-label":x.value,onBlur:w,onKeydown:D},null,40,Y),[[c.vModelText,h.value]])]),a[8]||=(0,c.createElementVNode)(`span`,{class:`s-ui-color-values__separator`,"aria-hidden":`true`},null,-1),(0,c.createElementVNode)(`div`,X,[(0,c.withDirectives)((0,c.createElementVNode)(`input`,{"onUpdate:modelValue":a[6]||=e=>g.value=e,class:`s-ui-color-values__input s-ui-typography-body-14-regular`,type:`text`,inputmode:`numeric`,spellcheck:`false`,disabled:e.disabled,readonly:e.readonly,"aria-label":S.value,onBlur:w,onKeydown:D},null,40,Z),[[c.vModelText,g.value]])])],64))])])],16))}}),$={class:`s-ui-color-picker__section`},ee={class:`s-ui-color-picker__section`},te={class:`s-ui-color-picker__custom-editor`},ne={class:`s-ui-color-picker__custom-actions`},re=(0,c.defineComponent)({__name:`SColorPicker`,props:(0,c.mergeModels)({disabled:{type:Boolean,default:!1},recommendedColors:{},recentColors:{default:()=>[]}},{modelValue:{},modelModifiers:{}}),emits:(0,c.mergeModels)([`select`,`customEditorOpen`,`customEditorClose`,`formatDropdownOpen`,`formatDropdownClose`],[`update:modelValue`]),setup(e,{emit:n}){let u=(0,c.useModel)(e,`modelValue`),d=n,f=(0,c.ref)(!1),p=(0,c.ref)(`#526DE3`),m=(0,c.ref)(t.o.HEX),h=(0,c.computed)(()=>e.recommendedColors&&e.recommendedColors.length>0?e.recommendedColors:t.r),g=(0,c.computed)(()=>e.recentColors.length<=17?e.recentColors:e.recentColors.slice(0,17)),_=()=>{if(u.value){p.value=u.value;return}p.value=`#526DE3`},v=e=>{d(`select`,e)},y=()=>{u.value=p.value,d(`select`,p.value),f.value=!1},b=()=>{f.value=!1};return(0,c.watch)(f,(e,t)=>{if(e&&!t){_(),d(`customEditorOpen`);return}!e&&t&&d(`customEditorClose`)}),(n,_)=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(s.r),(0,c.mergeProps)({width:336},n.$attrs),{default:(0,c.withCtx)(()=>[(0,c.createElementVNode)(`div`,{class:(0,c.normalizeClass)([`s-ui-color-picker`,{"s-ui-color-picker--disabled":e.disabled}])},[(0,c.createElementVNode)(`section`,$,[_[8]||=(0,c.createElementVNode)(`span`,{class:`s-ui-color-picker__label`},`Рекомендованные цвета`,-1),(0,c.createVNode)((0,c.unref)(t.t),{modelValue:u.value,"onUpdate:modelValue":_[0]||=e=>u.value=e,class:`s-ui-color-picker__palette`,layout:(0,c.unref)(t.n).GRID,colors:h.value,size:(0,c.unref)(l.ESColorSwatchSize).SIZE_32,disabled:e.disabled,onSelect:v},null,8,[`modelValue`,`layout`,`colors`,`size`,`disabled`])]),(0,c.createElementVNode)(`section`,ee,[_[11]||=(0,c.createElementVNode)(`span`,{class:`s-ui-color-picker__label`},`Последние использованные`,-1),(0,c.createVNode)((0,c.unref)(t.t),{modelValue:u.value,"onUpdate:modelValue":_[7]||=e=>u.value=e,class:`s-ui-color-picker__palette`,layout:(0,c.unref)(t.n).ROW,colors:g.value,size:(0,c.unref)(l.ESColorSwatchSize).SIZE_32,disabled:e.disabled,onSelect:v},{append:(0,c.withCtx)(()=>[(0,c.createVNode)((0,c.unref)(o.t),{modelValue:f.value,"onUpdate:modelValue":_[6]||=e=>f.value=e,placement:(0,c.unref)(a.i).RIGHT_START,offset:8,shift:!0,flip:!0,disabled:e.disabled,"dismiss-on-click-outside":!0,"dismiss-on-escape":!0},{trigger:(0,c.withCtx)(({toggle:t,triggerProps:n})=>[(0,c.createVNode)((0,c.unref)(i.t),(0,c.mergeProps)(n,{class:`s-ui-color-picker__add-button`,appearance:(0,c.unref)(r.t).OUTLINED,variant:(0,c.unref)(r.r).NEUTRAL,size:(0,c.unref)(r.n).SMALL,icon:`plus`,"aria-label":`Add custom color`,disabled:e.disabled,onClick:t}),null,16,[`appearance`,`variant`,`size`,`disabled`,`onClick`])]),content:(0,c.withCtx)(()=>[(0,c.createVNode)((0,c.unref)(s.r),{width:320},{footer:(0,c.withCtx)(()=>[(0,c.createElementVNode)(`div`,ne,[(0,c.createVNode)((0,c.unref)(i.t),{class:`s-ui-color-picker__save-button`,appearance:(0,c.unref)(r.t).MAJOR,variant:(0,c.unref)(r.r).MAIN,size:(0,c.unref)(r.n).SMALL,disabled:e.disabled,onClick:y},{default:(0,c.withCtx)(()=>[..._[9]||=[(0,c.createTextVNode)(` Сохранить `,-1)]]),_:1},8,[`appearance`,`variant`,`size`,`disabled`]),(0,c.createVNode)((0,c.unref)(i.t),{class:`s-ui-color-picker__cancel-button`,appearance:(0,c.unref)(r.t).MINOR,variant:(0,c.unref)(r.r).NEUTRAL,size:(0,c.unref)(r.n).SMALL,disabled:e.disabled,onClick:b},{default:(0,c.withCtx)(()=>[..._[10]||=[(0,c.createTextVNode)(` Отменить `,-1)]]),_:1},8,[`appearance`,`variant`,`size`,`disabled`])])]),default:(0,c.withCtx)(()=>[(0,c.createElementVNode)(`div`,te,[(0,c.createVNode)(z,{modelValue:p.value,"onUpdate:modelValue":_[1]||=e=>p.value=e,disabled:e.disabled},null,8,[`modelValue`,`disabled`]),(0,c.createVNode)(Q,{modelValue:p.value,"onUpdate:modelValue":_[2]||=e=>p.value=e,format:m.value,"onUpdate:format":_[3]||=e=>m.value=e,disabled:e.disabled,onFormatDropdownOpen:_[4]||=e=>d(`formatDropdownOpen`),onFormatDropdownClose:_[5]||=e=>d(`formatDropdownClose`)},null,8,[`modelValue`,`format`,`disabled`])])]),_:1})]),_:1},8,[`modelValue`,`placement`,`disabled`])]),_:1},8,[`modelValue`,`layout`,`colors`,`size`,`disabled`])])],2)]),_:1},16))}});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return re}});
|