xtreme-ui 0.0.110 → 0.0.111
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPopper.d.ts","sourceRoot":"","sources":["../../../../src/components/base/ColorPopper/ColorPopper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoD,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorPopper.d.ts","sourceRoot":"","sources":["../../../../src/components/base/ColorPopper/ColorPopper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoD,GAAG,EAAE,MAAM,OAAO,CAAC;AAyB9E,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,cAAc,CAAC;AAE/D,iBAAS,gBAAgB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAG,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,2CAwP9G;kBAxPQ,gBAAgB;;;AA0PzB,eAAO,MAAM,WAAW,EAAmC,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EACxF,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CAAE,KACvD,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as i, Fragment as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useFloating as
|
|
2
|
+
import { jsxs as i, Fragment as le, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as ne, useMemo as T, useState as C, useRef as ie, useEffect as L } from "react";
|
|
4
|
+
import { useFloating as ae, autoUpdate as ce, shift as he, flip as de, offset as me, useTransitionStyles as pe, useInteractions as ue, useClick as fe, useDismiss as Ce } from "@floating-ui/react";
|
|
5
5
|
import g from "clsx";
|
|
6
|
-
import { colord as s, getFormat as
|
|
7
|
-
import { ColorPicker as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import { Textfield as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
6
|
+
import { colord as s, getFormat as ge } from "colord";
|
|
7
|
+
import { ColorPicker as xe } from "../ColorPicker/ColorPicker.js";
|
|
8
|
+
import { Icon as ve } from "../Icon/Icon.js";
|
|
9
|
+
import { Textfield as ye } from "../Textfield/Textfield.js";
|
|
10
|
+
import { useScreenType as He } from "../../hooks/useScreen.js";
|
|
11
|
+
import { getColorLabel as Ne } from "../../../utils/helper/colorHelper.js";
|
|
12
|
+
import { THEME_SCHEME as $e } from "../../../utils/constants/theme.js";
|
|
13
|
+
import { mergeRefs as Pe } from "../../../utils/function/mergeRefs.js";
|
|
14
|
+
import { Button as b } from "../Button/Button.js";
|
|
14
15
|
/* empty css */
|
|
15
16
|
function O(j, z) {
|
|
16
17
|
const {
|
|
17
|
-
className:
|
|
18
|
+
className: R,
|
|
18
19
|
popperClassName: A,
|
|
19
20
|
input: x = "textfield",
|
|
20
|
-
size:
|
|
21
|
-
placeholder:
|
|
21
|
+
size: D = "default",
|
|
22
|
+
placeholder: q = "Color Picker",
|
|
22
23
|
colorHeading: m = "Pick color",
|
|
23
|
-
schemeHeading:
|
|
24
|
+
schemeHeading: S,
|
|
24
25
|
themeScheme: v,
|
|
25
|
-
setThemeScheme:
|
|
26
|
+
setThemeScheme: y,
|
|
26
27
|
showReset: U = !0,
|
|
27
28
|
alpha: W,
|
|
28
29
|
shade: _,
|
|
29
|
-
swatch:
|
|
30
|
-
hideWheel:
|
|
30
|
+
swatch: H,
|
|
31
|
+
hideWheel: I = !1,
|
|
31
32
|
color: a,
|
|
32
33
|
setColor: p
|
|
33
|
-
} = j, r =
|
|
34
|
+
} = j, { isDesktop: G } = He(), r = T(() => s(a), []), u = T(() => ge(a), [a]), [N, c] = C(r.toHsv()), [h, d] = C(r.toHex()), [J, K] = C(m), $ = ie(!1), [E, P] = C(!1), { refs: k, floatingStyles: Q, context: w } = ae({
|
|
34
35
|
open: E,
|
|
35
36
|
onOpenChange: P,
|
|
36
37
|
middleware: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
he({ crossAxis: !0, padding: 18 }),
|
|
39
|
+
de(),
|
|
40
|
+
me(({ placement: e }) => e === "bottom" ? 10 : 16)
|
|
40
41
|
],
|
|
41
|
-
whileElementsMounted:
|
|
42
|
-
}), { isMounted:
|
|
42
|
+
whileElementsMounted: ce
|
|
43
|
+
}), { isMounted: X, styles: Y } = pe(w, {
|
|
43
44
|
duration: 200,
|
|
44
45
|
initial: ({ side: e }) => ({
|
|
45
46
|
opacity: 0,
|
|
46
47
|
translate: e === "bottom" ? "0px 8px" : "0px -8px"
|
|
47
48
|
})
|
|
48
|
-
}), { getReferenceProps: F, getFloatingProps:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
]), [M,
|
|
49
|
+
}), { getReferenceProps: F, getFloatingProps: Z } = ue([
|
|
50
|
+
fe(w),
|
|
51
|
+
Ce(w)
|
|
52
|
+
]), [M, ee, B] = T(() => {
|
|
52
53
|
const e = s(N), o = e.toHsl(), l = r.toHsl();
|
|
53
54
|
return [
|
|
54
55
|
`${Math.round(o.h)} ${Math.round(o.s)}% ${Math.round(o.l)}%`,
|
|
@@ -61,13 +62,13 @@ function O(j, z) {
|
|
|
61
62
|
d(e);
|
|
62
63
|
const o = s(e);
|
|
63
64
|
o.isValid() && (c(o.toHsv()), f(o));
|
|
64
|
-
},
|
|
65
|
+
}, oe = (e) => {
|
|
65
66
|
const o = s(e);
|
|
66
67
|
c(e), d(o.toHex()), f(o);
|
|
67
|
-
},
|
|
68
|
+
}, te = (e) => {
|
|
68
69
|
const o = s(e);
|
|
69
70
|
c(o.toHsv()), d(o.toHex()), f(o);
|
|
70
|
-
},
|
|
71
|
+
}, se = () => {
|
|
71
72
|
c(r.toHsv()), d(r.toHex()), f(r);
|
|
72
73
|
};
|
|
73
74
|
return L(() => {
|
|
@@ -77,14 +78,14 @@ function O(j, z) {
|
|
|
77
78
|
}
|
|
78
79
|
$.current = !1;
|
|
79
80
|
}, [a]), L(() => {
|
|
80
|
-
|
|
81
|
-
}, [m, h]), /* @__PURE__ */ i(
|
|
81
|
+
K(Ne(s(h).toHsl()) ?? m);
|
|
82
|
+
}, [m, h]), /* @__PURE__ */ i(le, { children: [
|
|
82
83
|
x === "button" ? /* @__PURE__ */ t(
|
|
83
|
-
|
|
84
|
+
b,
|
|
84
85
|
{
|
|
85
86
|
className: "xtrColorButton",
|
|
86
87
|
ref: k.setReference,
|
|
87
|
-
size:
|
|
88
|
+
size: D,
|
|
88
89
|
icon: "f53f",
|
|
89
90
|
iconType: "solid",
|
|
90
91
|
style: {
|
|
@@ -95,11 +96,11 @@ function O(j, z) {
|
|
|
95
96
|
...F()
|
|
96
97
|
}
|
|
97
98
|
) : /* @__PURE__ */ t(
|
|
98
|
-
|
|
99
|
+
ye,
|
|
99
100
|
{
|
|
100
|
-
className: g("xtrColorInput",
|
|
101
|
+
className: g("xtrColorInput", R),
|
|
101
102
|
ref: k.setReference,
|
|
102
|
-
placeholder:
|
|
103
|
+
placeholder: q,
|
|
103
104
|
icon: "f53f",
|
|
104
105
|
iconType: "solid",
|
|
105
106
|
active: E,
|
|
@@ -113,25 +114,25 @@ function O(j, z) {
|
|
|
113
114
|
...F()
|
|
114
115
|
}
|
|
115
116
|
),
|
|
116
|
-
|
|
117
|
+
X && /* @__PURE__ */ i(
|
|
117
118
|
"div",
|
|
118
119
|
{
|
|
119
|
-
ref:
|
|
120
|
+
ref: Pe([z, k.setFloating]),
|
|
120
121
|
className: g("xtrColorPopper", A),
|
|
121
|
-
style: { ...
|
|
122
|
-
...
|
|
122
|
+
style: { ...Q, ...Y, "--colorBrandPrimary": M },
|
|
123
|
+
...Z(),
|
|
123
124
|
children: [
|
|
124
|
-
(
|
|
125
|
+
(H || !I) && /* @__PURE__ */ i("div", { className: g("header", x === "button" && "withInput"), children: [
|
|
125
126
|
/* @__PURE__ */ i("div", { className: "heading", children: [
|
|
126
127
|
/* @__PURE__ */ i("div", { children: [
|
|
127
|
-
/* @__PURE__ */ t("h1", { children:
|
|
128
|
+
/* @__PURE__ */ t("h1", { children: J }),
|
|
128
129
|
x === "button" && /* @__PURE__ */ t(
|
|
129
130
|
"input",
|
|
130
131
|
{
|
|
131
132
|
placeholder: "#Hex",
|
|
132
|
-
className: g("popperInput",
|
|
133
|
-
autoFocus: !0,
|
|
133
|
+
className: g("popperInput", R),
|
|
134
134
|
value: h,
|
|
135
|
+
autoFocus: G,
|
|
135
136
|
onChange: (e) => V(e.target.value)
|
|
136
137
|
}
|
|
137
138
|
)
|
|
@@ -139,56 +140,56 @@ function O(j, z) {
|
|
|
139
140
|
/* @__PURE__ */ t("h1", { children: m })
|
|
140
141
|
] }),
|
|
141
142
|
U && /* @__PURE__ */ t(
|
|
142
|
-
|
|
143
|
+
ve,
|
|
143
144
|
{
|
|
144
145
|
code: "f1da",
|
|
145
146
|
type: "solid",
|
|
146
|
-
style: { "--colorBrandPrimary":
|
|
147
|
-
onClick:
|
|
147
|
+
style: { "--colorBrandPrimary": ee },
|
|
148
|
+
onClick: se
|
|
148
149
|
}
|
|
149
150
|
)
|
|
150
151
|
] }),
|
|
151
|
-
|
|
152
|
-
const l = s(h).isEqual(e), n = s(e).toHsl(),
|
|
152
|
+
H && /* @__PURE__ */ t("div", { className: "swatch", children: H.map((e, o) => {
|
|
153
|
+
const l = s(h).isEqual(e), n = s(e).toHsl(), re = `${n.h} ${n.s}% ${n.l}%`;
|
|
153
154
|
return /* @__PURE__ */ t(
|
|
154
|
-
|
|
155
|
+
b,
|
|
155
156
|
{
|
|
156
157
|
className: "swatchItem",
|
|
157
158
|
icon: "f00c",
|
|
158
159
|
iconType: "solid",
|
|
159
160
|
size: "mini",
|
|
160
161
|
style: {
|
|
161
|
-
"--themeColor":
|
|
162
|
+
"--themeColor": re,
|
|
162
163
|
color: l ? "white" : "transparent"
|
|
163
164
|
},
|
|
164
|
-
onClick: () =>
|
|
165
|
+
onClick: () => te(n)
|
|
165
166
|
},
|
|
166
167
|
`ThemeColor-${n.h}${n.s}${n.l}-${o}`
|
|
167
168
|
);
|
|
168
169
|
}) }),
|
|
169
|
-
!
|
|
170
|
-
|
|
170
|
+
!I && /* @__PURE__ */ t(
|
|
171
|
+
xe,
|
|
171
172
|
{
|
|
172
173
|
className: "colorPicker",
|
|
173
174
|
alpha: W,
|
|
174
175
|
shade: _,
|
|
175
176
|
color: N,
|
|
176
|
-
setColor:
|
|
177
|
+
setColor: oe
|
|
177
178
|
}
|
|
178
179
|
),
|
|
179
|
-
|
|
180
|
+
S && /* @__PURE__ */ i("div", { className: "themeScheme", children: [
|
|
180
181
|
/* @__PURE__ */ t("div", { className: "header", children: /* @__PURE__ */ i("div", { className: "heading", children: [
|
|
181
182
|
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t("h1", { children: v }) }),
|
|
182
|
-
/* @__PURE__ */ t("h1", { children:
|
|
183
|
+
/* @__PURE__ */ t("h1", { children: S })
|
|
183
184
|
] }) }),
|
|
184
|
-
/* @__PURE__ */ t("div", { className: "schemeSelector", children:
|
|
185
|
-
|
|
185
|
+
/* @__PURE__ */ t("div", { className: "schemeSelector", children: $e.map(({ name: e, icon: o }, l) => /* @__PURE__ */ t(
|
|
186
|
+
b,
|
|
186
187
|
{
|
|
187
188
|
icon: o,
|
|
188
189
|
iconType: "solid",
|
|
189
190
|
disabled: v === e,
|
|
190
191
|
type: v === e ? "primary" : "secondary",
|
|
191
|
-
onClick: () =>
|
|
192
|
+
onClick: () => y == null ? void 0 : y(e)
|
|
192
193
|
},
|
|
193
194
|
`ThemeScheme-${e}-${l}`
|
|
194
195
|
)) })
|
|
@@ -198,8 +199,8 @@ function O(j, z) {
|
|
|
198
199
|
)
|
|
199
200
|
] });
|
|
200
201
|
}
|
|
201
|
-
const
|
|
202
|
+
const je = ne(O);
|
|
202
203
|
O.displayName = "ColorPopper";
|
|
203
204
|
export {
|
|
204
|
-
|
|
205
|
+
je as ColorPopper
|
|
205
206
|
};
|