@frontify/fondue-components 3.2.1 → 3.3.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/dist/fondue-components.js +18 -16
- package/dist/fondue-components.js.map +1 -1
- package/dist/fondue-components10.js +2 -2
- package/dist/fondue-components11.js +42 -30
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +2 -2
- package/dist/fondue-components13.js +1 -1
- package/dist/fondue-components14.js +1 -1
- package/dist/fondue-components15.js +64 -6
- package/dist/fondue-components15.js.map +1 -1
- package/dist/fondue-components16.js +6 -47
- package/dist/fondue-components16.js.map +1 -1
- package/dist/fondue-components17.js +42 -50
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js +112 -29
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js +53 -110
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js +27 -64
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +64 -41
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +43 -32
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +32 -5
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +5 -12
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +10 -153
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +59 -22
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +17 -17
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +112 -15
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +19 -30
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components3.js +2 -2
- package/dist/fondue-components30.js +32 -28
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +23 -125
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +129 -20
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +21 -45
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +45 -15
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +28 -60
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +15 -15
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +60 -19
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +15 -17
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +16 -4
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js +4 -4
- package/dist/fondue-components40.js +3 -11
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +11 -3
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +5 -35
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +35 -5
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +12 -24
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +4 -16
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +24 -10
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +14 -10
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components5.js +2 -2
- package/dist/fondue-components50.js +2 -2
- package/dist/fondue-components53.js +1 -1
- package/dist/fondue-components54.js +9 -16
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +12 -6
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +18 -2
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +4 -8
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +2 -39
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +14 -0
- package/dist/fondue-components59.js.map +1 -0
- package/dist/fondue-components6.js +5 -5
- package/dist/fondue-components60.js +42 -0
- package/dist/fondue-components60.js.map +1 -0
- package/dist/fondue-components7.js +78 -68
- package/dist/fondue-components7.js.map +1 -1
- package/dist/fondue-components8.js +2 -2
- package/dist/fondue-components9.js +3 -3
- package/dist/index.d.ts +27 -3
- package/dist/style.css +1 -1
- package/package.json +16 -15
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
"data-test-id": o = "color-picker-input"
|
|
11
|
-
}, p) => /* @__PURE__ */ r("div", { className: t.gradientInput, "data-test-id": o, ref: p, children: /* @__PURE__ */ r(
|
|
12
|
-
n,
|
|
13
|
-
{
|
|
14
|
-
className: t.reactColorful,
|
|
15
|
-
color: {
|
|
16
|
-
r: a.red,
|
|
17
|
-
g: a.green,
|
|
18
|
-
b: a.blue,
|
|
19
|
-
a: a.alpha === void 0 ? 1 : a.alpha
|
|
1
|
+
import { FOCUS_OUTLINE as t } from "./fondue-components58.js";
|
|
2
|
+
import { sv as e } from "./fondue-components25.js";
|
|
3
|
+
const s = e({
|
|
4
|
+
base: `tw-peer tw-relative tw-inline-flex tw-bg-base tw-text-white tw-shrink-0 tw-rounded tw-border tw-border-line-x-strong group-hover:tw-border-line-xx-strong hover:tw-border-line-xx-strong tw-transition-colors data-[state="checked"]:tw-border-transparent data-[state="indeterminate"]:tw-border-transparent disabled:tw-border-line-strong disabled:tw-bg-base disabled:tw-cursor-not-allowed data-[state="checked"]:disabled:tw-bg-box-disabled-strong ${t}`,
|
|
5
|
+
variants: {
|
|
6
|
+
size: {
|
|
7
|
+
default: "tw-size-4",
|
|
8
|
+
large: "tw-size-5"
|
|
20
9
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
emphasis: {
|
|
11
|
+
default: 'data-[state="checked"]:tw-bg-box-selected-strong data-[state="checked"]:hover:tw-bg-box-selected-strong-hover data-[state="checked"]:active:tw-bg-box-selected-strong-pressed data-[state="indeterminate"]:tw-bg-box-selected-strong data-[state="indeterminate"]:hover:tw-bg-box-selected-strong-hover data-[state="indeterminate"]:active:tw-bg-box-selected-strong-pressed ',
|
|
12
|
+
weak: 'data-[state="checked"]:tw-bg-box-neutral-strong data-[state="checked"]:hover:tw-bg-box-neutral-strong-hover data-[state="checked"]:active:tw-bg-box-neutral-strong-pressed data-[state="indeterminate"]:tw-bg-box-neutral-strong data-[state="indeterminate"]:hover:tw-bg-box-neutral-strong-hover data-[state="indeterminate"]:active:tw-bg-box-neutral-strong-pressed '
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
size: "default",
|
|
17
|
+
emphasis: "default"
|
|
27
18
|
}
|
|
28
|
-
)
|
|
29
|
-
i.displayName = "ColorPicker.Gradient";
|
|
30
|
-
const c = m(i);
|
|
19
|
+
}), o = 'tw-group tw-absolute tw-inset-0 tw-inline-flex tw-items-center tw-justify-center tw-text-current tw-opacity-0 data-[state="checked"]:tw-opacity-100 data-[state="indeterminate"]:tw-opacity-100 tw-transition-opacity ';
|
|
31
20
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
o as checkboxIndicatorStyles,
|
|
22
|
+
s as checkboxStyles
|
|
34
23
|
};
|
|
35
24
|
//# sourceMappingURL=fondue-components29.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components29.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components29.js","sources":["../src/components/Checkbox/styles/checkboxStyles.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { FOCUS_OUTLINE } from '#/utilities/focusStyle';\nimport { sv } from '#/utilities/styleUtilities';\n\nexport const checkboxStyles = sv({\n base:\n 'tw-peer tw-relative tw-inline-flex tw-bg-base tw-text-white tw-shrink-0 tw-rounded tw-border tw-border-line-x-strong group-hover:tw-border-line-xx-strong hover:tw-border-line-xx-strong tw-transition-colors ' +\n 'data-[state=\"checked\"]:tw-border-transparent data-[state=\"indeterminate\"]:tw-border-transparent ' +\n 'disabled:tw-border-line-strong disabled:tw-bg-base disabled:tw-cursor-not-allowed data-[state=\"checked\"]:disabled:tw-bg-box-disabled-strong ' +\n `${FOCUS_OUTLINE}`,\n variants: {\n size: {\n default: 'tw-size-4',\n large: 'tw-size-5',\n },\n emphasis: {\n default:\n 'data-[state=\"checked\"]:tw-bg-box-selected-strong data-[state=\"checked\"]:hover:tw-bg-box-selected-strong-hover data-[state=\"checked\"]:active:tw-bg-box-selected-strong-pressed ' +\n 'data-[state=\"indeterminate\"]:tw-bg-box-selected-strong data-[state=\"indeterminate\"]:hover:tw-bg-box-selected-strong-hover data-[state=\"indeterminate\"]:active:tw-bg-box-selected-strong-pressed ',\n weak:\n 'data-[state=\"checked\"]:tw-bg-box-neutral-strong data-[state=\"checked\"]:hover:tw-bg-box-neutral-strong-hover data-[state=\"checked\"]:active:tw-bg-box-neutral-strong-pressed ' +\n 'data-[state=\"indeterminate\"]:tw-bg-box-neutral-strong data-[state=\"indeterminate\"]:hover:tw-bg-box-neutral-strong-hover data-[state=\"indeterminate\"]:active:tw-bg-box-neutral-strong-pressed ',\n },\n },\n defaultVariants: {\n size: 'default',\n emphasis: 'default',\n },\n});\n\nexport const checkboxIndicatorStyles =\n 'tw-group tw-absolute tw-inset-0 tw-inline-flex tw-items-center tw-justify-center tw-text-current ' +\n 'tw-opacity-0 data-[state=\"checked\"]:tw-opacity-100 data-[state=\"indeterminate\"]:tw-opacity-100 tw-transition-opacity ';\n"],"names":["checkboxStyles","sv","FOCUS_OUTLINE","checkboxIndicatorStyles"],"mappings":";;AAKO,MAAMA,IAAiBC,EAAG;AAAA,EAC7B,MACI,6bAGGC,CAAa;AAAA,EACpB,UAAU;AAAA,IACN,MAAM;AAAA,MACF,SAAS;AAAA,MACT,OAAO;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACN,SACI;AAAA,MAEJ,MACI;AAAA,IAER;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,EACd;AACJ,CAAC,GAEYC,IACT;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { propsToCssVariables as e } from "./fondue-
|
|
3
|
-
import i from "./fondue-
|
|
2
|
+
import { propsToCssVariables as e } from "./fondue-components23.js";
|
|
3
|
+
import i from "./fondue-components24.js";
|
|
4
4
|
const m = ({
|
|
5
5
|
as: t = "div",
|
|
6
6
|
"data-test-id": s = "fondue-box",
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m } from "react";
|
|
3
|
+
import { RgbaColorPicker as n } from "react-colorful";
|
|
4
|
+
import t from "./fondue-components33.js";
|
|
5
|
+
import { DEFAULT_COLOR as s } from "./fondue-components34.js";
|
|
6
|
+
const i = ({
|
|
7
|
+
currentColor: a = s,
|
|
8
|
+
onColorChange: d = () => {
|
|
9
|
+
},
|
|
10
|
+
"data-test-id": o = "color-picker-input"
|
|
11
|
+
}, p) => /* @__PURE__ */ r("div", { className: t.gradientInput, "data-test-id": o, ref: p, children: /* @__PURE__ */ r(
|
|
12
|
+
n,
|
|
13
|
+
{
|
|
14
|
+
className: t.reactColorful,
|
|
15
|
+
color: {
|
|
16
|
+
r: a.red,
|
|
17
|
+
g: a.green,
|
|
18
|
+
b: a.blue,
|
|
19
|
+
a: a.alpha === void 0 ? 1 : a.alpha
|
|
20
|
+
},
|
|
21
|
+
onChange: (e) => d({
|
|
22
|
+
red: e.r,
|
|
23
|
+
green: e.g,
|
|
24
|
+
blue: e.b,
|
|
25
|
+
alpha: e.a
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
) });
|
|
29
|
+
i.displayName = "ColorPicker.Gradient";
|
|
30
|
+
const c = m(i);
|
|
27
31
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
i as ColorGradientInput,
|
|
33
|
+
c as ForwardedRefColorGradientInput
|
|
30
34
|
};
|
|
31
35
|
//# sourceMappingURL=fondue-components30.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components30.js","sources":["../src/components/ColorPicker/
|
|
1
|
+
{"version":3,"file":"fondue-components30.js","sources":["../src/components/ColorPicker/ColorGradientInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ForwardedRef, forwardRef } from 'react';\nimport { RgbaColorPicker } from 'react-colorful';\n\nimport styles from './styles/customColorPicker.module.scss';\nimport { type RgbaColor } from './types';\nimport { DEFAULT_COLOR } from './utils';\n\ntype ColorGradientInputProps = {\n /**\n * @ignore\n * The active color in the color picker, passed down from the root component\n */\n currentColor?: RgbaColor;\n /**\n * @ignore\n * Event handler called when the color changes, passed down from the root component\n */\n onColorChange?: (color: RgbaColor) => void;\n /**\n * The test id of the color picker gradient input\n */\n 'data-test-id'?: string;\n};\n\nexport const ColorGradientInput = (\n {\n currentColor = DEFAULT_COLOR,\n onColorChange = () => {},\n 'data-test-id': dataTestId = 'color-picker-input',\n }: ColorGradientInputProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div className={styles.gradientInput} data-test-id={dataTestId} ref={forwardedRef}>\n <RgbaColorPicker\n className={styles.reactColorful}\n color={{\n r: currentColor.red,\n g: currentColor.green,\n b: currentColor.blue,\n a: currentColor.alpha === undefined ? 1 : currentColor.alpha,\n }}\n onChange={(color) =>\n onColorChange({\n red: color.r,\n green: color.g,\n blue: color.b,\n alpha: color.a,\n })\n }\n />\n </div>\n );\n};\nColorGradientInput.displayName = 'ColorPicker.Gradient';\n\nexport const ForwardedRefColorGradientInput = forwardRef<HTMLDivElement, ColorGradientInputProps>(ColorGradientInput);\n"],"names":["ColorGradientInput","currentColor","DEFAULT_COLOR","onColorChange","dataTestId","forwardedRef","jsx","styles","RgbaColorPicker","color","ForwardedRefColorGradientInput","forwardRef"],"mappings":";;;;;AA0BO,MAAMA,IAAqB,CAC9B;AAAA,EACI,cAAAC,IAAeC;AAAA,EACf,eAAAC,IAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,gBAAgBC,IAAa;AACjC,GACAC,MAGI,gBAAAC,EAAC,SAAI,WAAWC,EAAO,eAAe,gBAAcH,GAAY,KAAKC,GACjE,UAAA,gBAAAC;AAAA,EAACE;AAAA,EAAA;AAAA,IACG,WAAWD,EAAO;AAAA,IAClB,OAAO;AAAA,MACH,GAAGN,EAAa;AAAA,MAChB,GAAGA,EAAa;AAAA,MAChB,GAAGA,EAAa;AAAA,MAChB,GAAGA,EAAa,UAAU,SAAY,IAAIA,EAAa;AAAA,IAC3D;AAAA,IACA,UAAU,CAACQ,MACPN,EAAc;AAAA,MACV,KAAKM,EAAM;AAAA,MACX,OAAOA,EAAM;AAAA,MACb,MAAMA,EAAM;AAAA,MACZ,OAAOA,EAAM;AAAA,IAAA,CAChB;AAAA,EAAA;AAGb,EAAA,CAAA;AAGRT,EAAmB,cAAc;AAEpB,MAAAU,IAAiCC,EAAoDX,CAAkB;"}
|
|
@@ -1,133 +1,31 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
currentFormat: s = S,
|
|
12
|
-
setCurrentFormat: v = () => {
|
|
13
|
-
},
|
|
14
|
-
"data-test-id": f = "color-picker-value-input"
|
|
15
|
-
}, N) => {
|
|
16
|
-
const [u, p] = g(d(t));
|
|
17
|
-
return R(() => {
|
|
18
|
-
p(d(t));
|
|
19
|
-
}, [t]), /* @__PURE__ */ o("div", { className: a.inputs, "data-test-id": f, ref: N, children: [
|
|
20
|
-
/* @__PURE__ */ e("div", { className: a.colorFormatInput, children: /* @__PURE__ */ o(
|
|
21
|
-
c,
|
|
1
|
+
import { jsxs as d, jsx as a, Fragment as m } from "react/jsx-runtime";
|
|
2
|
+
import { IconDroplet as n, IconTrashBin as p, IconCaretDown as f } from "@frontify/fondue-icons";
|
|
3
|
+
import { forwardRef as I, useId as N } from "react";
|
|
4
|
+
import i from "./fondue-components59.js";
|
|
5
|
+
import { colorToCss as h } from "./fondue-components34.js";
|
|
6
|
+
const c = ({ currentColor: e, onClear: s, "data-test-id": t = "color-picker-input", ...r }, l) => {
|
|
7
|
+
const o = N();
|
|
8
|
+
return /* @__PURE__ */ d("div", { className: i.root, ...r, ref: l, "data-test-id": t, children: [
|
|
9
|
+
(e == null ? void 0 : e.red) !== void 0 ? /* @__PURE__ */ a(
|
|
10
|
+
"div",
|
|
22
11
|
{
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
v(l);
|
|
27
|
-
},
|
|
28
|
-
value: s,
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ e(c.Item, { value: "HEX", children: "HEX" }),
|
|
31
|
-
/* @__PURE__ */ e(c.Item, { value: "RGBA", children: "RGBA" })
|
|
32
|
-
]
|
|
12
|
+
"aria-describedby": o,
|
|
13
|
+
className: i.colorIndicator,
|
|
14
|
+
style: { backgroundColor: h(e) }
|
|
33
15
|
}
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
"data-test-id": "color-picker-value-input-hex",
|
|
39
|
-
className: a.valueInput,
|
|
40
|
-
type: "text",
|
|
41
|
-
value: u,
|
|
42
|
-
status: m(u) ? "neutral" : "error",
|
|
43
|
-
onBlur: (l) => {
|
|
44
|
-
m(l.target.value) && i(I(l.target.value));
|
|
45
|
-
},
|
|
46
|
-
onChange: (l) => {
|
|
47
|
-
p(l.target.value);
|
|
48
|
-
},
|
|
49
|
-
"aria-label": "Hex color value",
|
|
50
|
-
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "#" }) })
|
|
51
|
-
}
|
|
52
|
-
) : /* @__PURE__ */ o("div", { className: a.colorChannelInputGroup, children: [
|
|
53
|
-
/* @__PURE__ */ e(
|
|
54
|
-
r.Root,
|
|
55
|
-
{
|
|
56
|
-
"data-test-id": "color-picker-value-input-red",
|
|
57
|
-
className: a.valueInput,
|
|
58
|
-
value: t.red,
|
|
59
|
-
type: "number",
|
|
60
|
-
onChange: (l) => {
|
|
61
|
-
i({
|
|
62
|
-
...t,
|
|
63
|
-
red: n(l.target.value)
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
"aria-label": "Red Color Channel",
|
|
67
|
-
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "R" }) })
|
|
68
|
-
}
|
|
69
|
-
),
|
|
70
|
-
/* @__PURE__ */ e(
|
|
71
|
-
r.Root,
|
|
72
|
-
{
|
|
73
|
-
"data-test-id": "color-picker-value-input-green",
|
|
74
|
-
className: a.valueInput,
|
|
75
|
-
value: t.green,
|
|
76
|
-
type: "number",
|
|
77
|
-
onChange: (l) => {
|
|
78
|
-
i({
|
|
79
|
-
...t,
|
|
80
|
-
green: n(l.target.value)
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
"aria-label": "Green Color Channel",
|
|
84
|
-
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "G" }) })
|
|
85
|
-
}
|
|
86
|
-
),
|
|
87
|
-
/* @__PURE__ */ e(
|
|
88
|
-
r.Root,
|
|
89
|
-
{
|
|
90
|
-
"data-test-id": "color-picker-value-input-blue",
|
|
91
|
-
className: a.valueInput,
|
|
92
|
-
value: t.blue,
|
|
93
|
-
type: "number",
|
|
94
|
-
onChange: (l) => {
|
|
95
|
-
i({
|
|
96
|
-
...t,
|
|
97
|
-
blue: n(l.target.value)
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
"aria-label": "Blue Color Channel",
|
|
101
|
-
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "B" }) })
|
|
102
|
-
}
|
|
103
|
-
)
|
|
16
|
+
) : /* @__PURE__ */ d(m, { children: [
|
|
17
|
+
/* @__PURE__ */ a(n, { size: 16 }),
|
|
18
|
+
/* @__PURE__ */ a("span", { children: "Select Color" })
|
|
104
19
|
] }),
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"data-test-id": "color-picker-value-input-alpha",
|
|
109
|
-
className: a.valueInput,
|
|
110
|
-
value: t.alpha === void 0 ? 100 : Math.trunc(t.alpha * 100),
|
|
111
|
-
type: "number",
|
|
112
|
-
onChange: (l) => {
|
|
113
|
-
i({
|
|
114
|
-
...t,
|
|
115
|
-
alpha: n(l.target.value, 0, 100) / 100
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
"aria-label": "Color Opacity",
|
|
119
|
-
children: [
|
|
120
|
-
/* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "A" }) }),
|
|
121
|
-
/* @__PURE__ */ e(r.Slot, { name: "right", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "%" }) })
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
) })
|
|
20
|
+
/* @__PURE__ */ a("span", { id: o, className: i.colorName, children: e == null ? void 0 : e.name }),
|
|
21
|
+
s && /* @__PURE__ */ a("button", { type: "button", "aria-label": "Clear color", onClick: s, className: i.clear, children: /* @__PURE__ */ a(p, { size: 16 }) }),
|
|
22
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(f, { size: 16, className: i.caret }) })
|
|
125
23
|
] });
|
|
126
24
|
};
|
|
127
|
-
|
|
128
|
-
const
|
|
25
|
+
c.displayName = "ColorPicker.Input";
|
|
26
|
+
const x = I(c);
|
|
129
27
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
28
|
+
c as ColorPickerInput,
|
|
29
|
+
x as ForwardedRefColorPickerInput
|
|
132
30
|
};
|
|
133
31
|
//# sourceMappingURL=fondue-components31.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components31.js","sources":["../src/components/ColorPicker/ColorValueInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ForwardedRef, forwardRef, useEffect, useState } from 'react';\n\nimport { Select } from '../Select/Select';\nimport { TextInput } from '../TextInput/TextInput';\n\nimport styles from './styles/customColorPicker.module.scss';\nimport { type RgbaColor } from './types';\nimport {\n DEFAULT_COLOR,\n DEFAULT_FORMAT,\n getLimitedColorChannelValue,\n hexColorToRgba,\n isValidHexColor,\n rgbColorToHex,\n} from './utils';\n\ntype ColorFormat = 'HEX' | 'RGBA';\n\ntype ColorValueInputProps = {\n /**\n * @ignore\n * The active color in the color picker, passed down from the root component\n */\n currentColor?: RgbaColor;\n /**\n * @ignore\n * Event handler called when the color changes, passed down from the root component\n */\n onColorChange?: (color: RgbaColor) => void;\n /**\n * @ignore\n * The format to use for the color input, passed down from the root component\n */\n currentFormat?: ColorFormat;\n /**\n * @ignore\n * The format to use for the color input, passed down from the root component\n */\n setCurrentFormat?: (format: ColorFormat) => void;\n /**\n * The test id of the color picker value input\n */\n 'data-test-id'?: string;\n};\n\nexport const ColorValueInput = (\n {\n currentColor = DEFAULT_COLOR,\n onColorChange = () => {},\n currentFormat = DEFAULT_FORMAT,\n setCurrentFormat = () => {},\n 'data-test-id': dataTestId = 'color-picker-value-input',\n }: ColorValueInputProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const [hexColorValue, setHexColorValue] = useState<string>(rgbColorToHex(currentColor));\n\n useEffect(() => {\n setHexColorValue(rgbColorToHex(currentColor));\n }, [currentColor]);\n\n return (\n <div className={styles.inputs} data-test-id={dataTestId} ref={forwardedRef}>\n <div className={styles.colorFormatInput}>\n <Select\n data-test-id=\"color-picker-select-format\"\n aria-label=\"Select a color format\"\n onSelect={(selectedValue) => {\n setCurrentFormat(selectedValue as ColorFormat);\n }}\n value={currentFormat}\n >\n <Select.Item value=\"HEX\">HEX</Select.Item>\n <Select.Item value=\"RGBA\">RGBA</Select.Item>\n </Select>\n </div>\n {currentFormat === 'HEX' ? (\n <TextInput.Root\n data-test-id=\"color-picker-value-input-hex\"\n className={styles.valueInput}\n type=\"text\"\n value={hexColorValue}\n status={isValidHexColor(hexColorValue) ? 'neutral' : 'error'}\n onBlur={(event) => {\n if (isValidHexColor(event.target.value)) {\n onColorChange(hexColorToRgba(event.target.value));\n }\n }}\n onChange={(event) => {\n setHexColorValue(event.target.value);\n }}\n aria-label=\"Hex color value\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>#</span>\n </TextInput.Slot>\n </TextInput.Root>\n ) : (\n <div className={styles.colorChannelInputGroup}>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-red\"\n className={styles.valueInput}\n value={currentColor.red}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n red: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Red Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>R</span>\n </TextInput.Slot>\n </TextInput.Root>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-green\"\n className={styles.valueInput}\n value={currentColor.green}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n green: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Green Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>G</span>\n </TextInput.Slot>\n </TextInput.Root>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-blue\"\n className={styles.valueInput}\n value={currentColor.blue}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n blue: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Blue Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>B</span>\n </TextInput.Slot>\n </TextInput.Root>\n </div>\n )}\n <div className={styles.colorAlphaInput}>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-alpha\"\n className={styles.valueInput}\n value={currentColor.alpha === undefined ? 100 : Math.trunc(currentColor.alpha * 100)}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n alpha: getLimitedColorChannelValue(event.target.value, 0, 100) / 100,\n });\n }}\n aria-label=\"Color Opacity\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>A</span>\n </TextInput.Slot>\n <TextInput.Slot name=\"right\">\n <span className={styles.inputDecorator}>%</span>\n </TextInput.Slot>\n </TextInput.Root>\n </div>\n </div>\n );\n};\nColorValueInput.displayName = 'ColorPicker.Values';\n\nexport const ForwardedRefColorValueInput = forwardRef<HTMLDivElement, ColorValueInputProps>(ColorValueInput);\n"],"names":["ColorValueInput","currentColor","DEFAULT_COLOR","onColorChange","currentFormat","DEFAULT_FORMAT","setCurrentFormat","dataTestId","forwardedRef","hexColorValue","setHexColorValue","useState","rgbColorToHex","useEffect","jsxs","styles","jsx","Select","selectedValue","TextInput","isValidHexColor","event","hexColorToRgba","getLimitedColorChannelValue","ForwardedRefColorValueInput","forwardRef"],"mappings":";;;;;;AA+CO,MAAMA,IAAkB,CAC3B;A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AAwB,IAA8BC,EAAiDzB,CAAe;"}
|
|
1
|
+
{"version":3,"file":"fondue-components31.js","sources":["../src/components/ColorPicker/ColorPickerInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconDroplet, IconTrashBin } from '@frontify/fondue-icons';\nimport { type ForwardedRef, forwardRef, useId } from 'react';\n\nimport { type CommonAriaAttrs } from '#/utilities/types';\n\nimport styles from './styles/colorInput.module.scss';\nimport { type RgbaColor } from './types';\nimport { colorToCss } from './utils';\n\ntype ColorPickerInputProps = {\n /**\n * The active color in the color picker\n */\n currentColor?: RgbaColor;\n /**\n * The open state of the color picker used to dermine arrow state\n */\n isOpen?: boolean;\n /**\n * callback for clearing the color\n */\n onClear?: () => void;\n /**\n * The test id of the color picker input\n */\n 'data-test-id'?: string;\n} & CommonAriaAttrs;\n\nexport const ColorPickerInput = (\n { currentColor, onClear, 'data-test-id': dataTestId = 'color-picker-input', ...props }: ColorPickerInputProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const colorNameId = useId();\n\n return (\n <div className={styles.root} {...props} ref={forwardedRef} data-test-id={dataTestId}>\n {currentColor?.red !== undefined ? (\n <div\n aria-describedby={colorNameId}\n className={styles.colorIndicator}\n style={{ backgroundColor: colorToCss(currentColor) }}\n />\n ) : (\n <>\n <IconDroplet size={16} />\n <span>Select Color</span>\n </>\n )}\n\n <span id={colorNameId} className={styles.colorName}>\n {currentColor?.name}\n </span>\n {onClear && (\n <button type=\"button\" aria-label=\"Clear color\" onClick={onClear} className={styles.clear}>\n <IconTrashBin size={16} />\n </button>\n )}\n <div>\n <IconCaretDown size={16} className={styles.caret} />\n </div>\n </div>\n );\n};\nColorPickerInput.displayName = 'ColorPicker.Input';\n\nexport const ForwardedRefColorPickerInput = forwardRef<HTMLDivElement, ColorPickerInputProps>(ColorPickerInput);\n"],"names":["ColorPickerInput","currentColor","onClear","dataTestId","props","forwardedRef","colorNameId","useId","jsxs","styles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|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as b, useState as g, useEffect as R } from "react";
|
|
3
|
+
import { Select as c } from "./fondue-components18.js";
|
|
4
|
+
import { TextInput as r } from "./fondue-components21.js";
|
|
5
|
+
import a from "./fondue-components33.js";
|
|
6
|
+
import { rgbColorToHex as d, isValidHexColor as m, hexColorToRgba as I, getLimitedColorChannelValue as n, DEFAULT_COLOR as x, DEFAULT_FORMAT as S } from "./fondue-components34.js";
|
|
7
|
+
const h = ({
|
|
8
|
+
currentColor: t = x,
|
|
9
|
+
onColorChange: i = () => {
|
|
10
|
+
},
|
|
11
|
+
currentFormat: s = S,
|
|
12
|
+
setCurrentFormat: v = () => {
|
|
13
|
+
},
|
|
14
|
+
"data-test-id": f = "color-picker-value-input"
|
|
15
|
+
}, N) => {
|
|
16
|
+
const [u, p] = g(d(t));
|
|
17
|
+
return R(() => {
|
|
18
|
+
p(d(t));
|
|
19
|
+
}, [t]), /* @__PURE__ */ o("div", { className: a.inputs, "data-test-id": f, ref: N, children: [
|
|
20
|
+
/* @__PURE__ */ e("div", { className: a.colorFormatInput, children: /* @__PURE__ */ o(
|
|
21
|
+
c,
|
|
22
|
+
{
|
|
23
|
+
"data-test-id": "color-picker-select-format",
|
|
24
|
+
"aria-label": "Select a color format",
|
|
25
|
+
onSelect: (l) => {
|
|
26
|
+
v(l);
|
|
27
|
+
},
|
|
28
|
+
value: s,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ e(c.Item, { value: "HEX", children: "HEX" }),
|
|
31
|
+
/* @__PURE__ */ e(c.Item, { value: "RGBA", children: "RGBA" })
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
) }),
|
|
35
|
+
s === "HEX" ? /* @__PURE__ */ e(
|
|
36
|
+
r.Root,
|
|
37
|
+
{
|
|
38
|
+
"data-test-id": "color-picker-value-input-hex",
|
|
39
|
+
className: a.valueInput,
|
|
40
|
+
type: "text",
|
|
41
|
+
value: u,
|
|
42
|
+
status: m(u) ? "neutral" : "error",
|
|
43
|
+
onBlur: (l) => {
|
|
44
|
+
m(l.target.value) && i(I(l.target.value));
|
|
45
|
+
},
|
|
46
|
+
onChange: (l) => {
|
|
47
|
+
p(l.target.value);
|
|
48
|
+
},
|
|
49
|
+
"aria-label": "Hex color value",
|
|
50
|
+
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "#" }) })
|
|
51
|
+
}
|
|
52
|
+
) : /* @__PURE__ */ o("div", { className: a.colorChannelInputGroup, children: [
|
|
53
|
+
/* @__PURE__ */ e(
|
|
54
|
+
r.Root,
|
|
55
|
+
{
|
|
56
|
+
"data-test-id": "color-picker-value-input-red",
|
|
57
|
+
className: a.valueInput,
|
|
58
|
+
value: t.red,
|
|
59
|
+
type: "number",
|
|
60
|
+
onChange: (l) => {
|
|
61
|
+
i({
|
|
62
|
+
...t,
|
|
63
|
+
red: n(l.target.value)
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
"aria-label": "Red Color Channel",
|
|
67
|
+
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "R" }) })
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ e(
|
|
71
|
+
r.Root,
|
|
72
|
+
{
|
|
73
|
+
"data-test-id": "color-picker-value-input-green",
|
|
74
|
+
className: a.valueInput,
|
|
75
|
+
value: t.green,
|
|
76
|
+
type: "number",
|
|
77
|
+
onChange: (l) => {
|
|
78
|
+
i({
|
|
79
|
+
...t,
|
|
80
|
+
green: n(l.target.value)
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
"aria-label": "Green Color Channel",
|
|
84
|
+
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "G" }) })
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ e(
|
|
88
|
+
r.Root,
|
|
89
|
+
{
|
|
90
|
+
"data-test-id": "color-picker-value-input-blue",
|
|
91
|
+
className: a.valueInput,
|
|
92
|
+
value: t.blue,
|
|
93
|
+
type: "number",
|
|
94
|
+
onChange: (l) => {
|
|
95
|
+
i({
|
|
96
|
+
...t,
|
|
97
|
+
blue: n(l.target.value)
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
"aria-label": "Blue Color Channel",
|
|
101
|
+
children: /* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "B" }) })
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ e("div", { className: a.colorAlphaInput, children: /* @__PURE__ */ o(
|
|
106
|
+
r.Root,
|
|
107
|
+
{
|
|
108
|
+
"data-test-id": "color-picker-value-input-alpha",
|
|
109
|
+
className: a.valueInput,
|
|
110
|
+
value: t.alpha === void 0 ? 100 : Math.trunc(t.alpha * 100),
|
|
111
|
+
type: "number",
|
|
112
|
+
onChange: (l) => {
|
|
113
|
+
i({
|
|
114
|
+
...t,
|
|
115
|
+
alpha: n(l.target.value, 0, 100) / 100
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
"aria-label": "Color Opacity",
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ e(r.Slot, { name: "left", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "A" }) }),
|
|
121
|
+
/* @__PURE__ */ e(r.Slot, { name: "right", children: /* @__PURE__ */ e("span", { className: a.inputDecorator, children: "%" }) })
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
) })
|
|
125
|
+
] });
|
|
11
126
|
};
|
|
127
|
+
h.displayName = "ColorPicker.Values";
|
|
128
|
+
const E = b(h);
|
|
12
129
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
n as colorFormatInput,
|
|
16
|
-
a as default,
|
|
17
|
-
_ as gradientInput,
|
|
18
|
-
p as inputDecorator,
|
|
19
|
-
t as inputs,
|
|
20
|
-
l as reactColorful,
|
|
21
|
-
o as root,
|
|
22
|
-
c as valueInput
|
|
130
|
+
h as ColorValueInput,
|
|
131
|
+
E as ForwardedRefColorValueInput
|
|
23
132
|
};
|
|
24
133
|
//# sourceMappingURL=fondue-components32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components32.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"fondue-components32.js","sources":["../src/components/ColorPicker/ColorValueInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ForwardedRef, forwardRef, useEffect, useState } from 'react';\n\nimport { Select } from '../Select/Select';\nimport { TextInput } from '../TextInput/TextInput';\n\nimport styles from './styles/customColorPicker.module.scss';\nimport { type RgbaColor } from './types';\nimport {\n DEFAULT_COLOR,\n DEFAULT_FORMAT,\n getLimitedColorChannelValue,\n hexColorToRgba,\n isValidHexColor,\n rgbColorToHex,\n} from './utils';\n\ntype ColorFormat = 'HEX' | 'RGBA';\n\ntype ColorValueInputProps = {\n /**\n * @ignore\n * The active color in the color picker, passed down from the root component\n */\n currentColor?: RgbaColor;\n /**\n * @ignore\n * Event handler called when the color changes, passed down from the root component\n */\n onColorChange?: (color: RgbaColor) => void;\n /**\n * @ignore\n * The format to use for the color input, passed down from the root component\n */\n currentFormat?: ColorFormat;\n /**\n * @ignore\n * The format to use for the color input, passed down from the root component\n */\n setCurrentFormat?: (format: ColorFormat) => void;\n /**\n * The test id of the color picker value input\n */\n 'data-test-id'?: string;\n};\n\nexport const ColorValueInput = (\n {\n currentColor = DEFAULT_COLOR,\n onColorChange = () => {},\n currentFormat = DEFAULT_FORMAT,\n setCurrentFormat = () => {},\n 'data-test-id': dataTestId = 'color-picker-value-input',\n }: ColorValueInputProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const [hexColorValue, setHexColorValue] = useState<string>(rgbColorToHex(currentColor));\n\n useEffect(() => {\n setHexColorValue(rgbColorToHex(currentColor));\n }, [currentColor]);\n\n return (\n <div className={styles.inputs} data-test-id={dataTestId} ref={forwardedRef}>\n <div className={styles.colorFormatInput}>\n <Select\n data-test-id=\"color-picker-select-format\"\n aria-label=\"Select a color format\"\n onSelect={(selectedValue) => {\n setCurrentFormat(selectedValue as ColorFormat);\n }}\n value={currentFormat}\n >\n <Select.Item value=\"HEX\">HEX</Select.Item>\n <Select.Item value=\"RGBA\">RGBA</Select.Item>\n </Select>\n </div>\n {currentFormat === 'HEX' ? (\n <TextInput.Root\n data-test-id=\"color-picker-value-input-hex\"\n className={styles.valueInput}\n type=\"text\"\n value={hexColorValue}\n status={isValidHexColor(hexColorValue) ? 'neutral' : 'error'}\n onBlur={(event) => {\n if (isValidHexColor(event.target.value)) {\n onColorChange(hexColorToRgba(event.target.value));\n }\n }}\n onChange={(event) => {\n setHexColorValue(event.target.value);\n }}\n aria-label=\"Hex color value\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>#</span>\n </TextInput.Slot>\n </TextInput.Root>\n ) : (\n <div className={styles.colorChannelInputGroup}>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-red\"\n className={styles.valueInput}\n value={currentColor.red}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n red: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Red Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>R</span>\n </TextInput.Slot>\n </TextInput.Root>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-green\"\n className={styles.valueInput}\n value={currentColor.green}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n green: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Green Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>G</span>\n </TextInput.Slot>\n </TextInput.Root>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-blue\"\n className={styles.valueInput}\n value={currentColor.blue}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n blue: getLimitedColorChannelValue(event.target.value),\n });\n }}\n aria-label=\"Blue Color Channel\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>B</span>\n </TextInput.Slot>\n </TextInput.Root>\n </div>\n )}\n <div className={styles.colorAlphaInput}>\n <TextInput.Root\n data-test-id=\"color-picker-value-input-alpha\"\n className={styles.valueInput}\n value={currentColor.alpha === undefined ? 100 : Math.trunc(currentColor.alpha * 100)}\n type=\"number\"\n onChange={(event) => {\n onColorChange({\n ...currentColor,\n alpha: getLimitedColorChannelValue(event.target.value, 0, 100) / 100,\n });\n }}\n aria-label=\"Color Opacity\"\n >\n <TextInput.Slot name=\"left\">\n <span className={styles.inputDecorator}>A</span>\n </TextInput.Slot>\n <TextInput.Slot name=\"right\">\n <span className={styles.inputDecorator}>%</span>\n </TextInput.Slot>\n </TextInput.Root>\n </div>\n </div>\n );\n};\nColorValueInput.displayName = 'ColorPicker.Values';\n\nexport const ForwardedRefColorValueInput = forwardRef<HTMLDivElement, ColorValueInputProps>(ColorValueInput);\n"],"names":["ColorValueInput","currentColor","DEFAULT_COLOR","onColorChange","currentFormat","DEFAULT_FORMAT","setCurrentFormat","dataTestId","forwardedRef","hexColorValue","setHexColorValue","useState","rgbColorToHex","useEffect","jsxs","styles","jsx","Select","selectedValue","TextInput","isValidHexColor","event","hexColorToRgba","getLimitedColorChannelValue","ForwardedRefColorValueInput","forwardRef"],"mappings":";;;;;;AA+CO,MAAMA,IAAkB,CAC3B;AAAA,EACI,cAAAC,IAAeC;AAAA,EACf,eAAAC,IAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,eAAAC,IAAgBC;AAAA,E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
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
green: 0,
|
|
13
|
-
blue: 0,
|
|
14
|
-
alpha: 0
|
|
15
|
-
};
|
|
16
|
-
const t = n[0];
|
|
17
|
-
return t.length === 3 ? {
|
|
18
|
-
red: parseInt(`${t[0]}${t[0]}`, 16),
|
|
19
|
-
green: parseInt(`${t[1]}${t[1]}`, 16),
|
|
20
|
-
blue: parseInt(`${t[2]}${t[2]}`, 16),
|
|
21
|
-
alpha: 1
|
|
22
|
-
} : {
|
|
23
|
-
red: parseInt(t.slice(0, 2), 16),
|
|
24
|
-
green: parseInt(t.slice(2, 4), 16),
|
|
25
|
-
blue: parseInt(t.slice(4, 6), 16),
|
|
26
|
-
alpha: 1
|
|
27
|
-
};
|
|
28
|
-
}, a = (e) => {
|
|
29
|
-
const { red: r, green: n, blue: t } = e;
|
|
30
|
-
return `${r.toString(16).padStart(2, "0")}${n.toString(16).padStart(2, "0")}${t.toString(16).padStart(2, "0")}`;
|
|
31
|
-
}, i = (e, r) => r === "HEX" ? {
|
|
32
|
-
...e,
|
|
33
|
-
name: `#${a(e)}`
|
|
34
|
-
} : {
|
|
35
|
-
...e,
|
|
36
|
-
name: `rgba(${e.red}, ${e.green}, ${e.blue}, ${e.alpha || 1})`
|
|
37
|
-
}, u = (e, r = 0, n = 255) => e.length === 0 || parseInt(e) < r ? r : parseInt(e) > n ? n : parseInt(e);
|
|
1
|
+
const o = "_root_v784d_5", t = "_inputs_v784d_12", n = "_colorFormatInput_v784d_23", r = "_colorAlphaInput_v784d_24", u = "_colorChannelInputGroup_v784d_28", p = "_inputDecorator_v784d_39", _ = "_gradientInput_v784d_43", l = "_reactColorful_v784d_46", c = "_valueInput_v784d_50", a = {
|
|
2
|
+
root: o,
|
|
3
|
+
inputs: t,
|
|
4
|
+
colorFormatInput: n,
|
|
5
|
+
colorAlphaInput: r,
|
|
6
|
+
colorChannelInputGroup: u,
|
|
7
|
+
inputDecorator: p,
|
|
8
|
+
gradientInput: _,
|
|
9
|
+
reactColorful: l,
|
|
10
|
+
valueInput: c
|
|
11
|
+
};
|
|
38
12
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
13
|
+
r as colorAlphaInput,
|
|
14
|
+
u as colorChannelInputGroup,
|
|
15
|
+
n as colorFormatInput,
|
|
16
|
+
a as default,
|
|
17
|
+
_ as gradientInput,
|
|
18
|
+
p as inputDecorator,
|
|
19
|
+
t as inputs,
|
|
20
|
+
l as reactColorful,
|
|
21
|
+
o as root,
|
|
22
|
+
c as valueInput
|
|
47
23
|
};
|
|
48
24
|
//# sourceMappingURL=fondue-components33.js.map
|