@stoa-dev/kit 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/display/BarChart/index.js +147 -31
- package/dist/display/BarChart/index.js.map +1 -1
- package/dist/i18n/locales/at.json.js +16 -14
- package/dist/i18n/locales/at.json.js.map +1 -1
- package/dist/i18n/locales/de.json.js +16 -14
- package/dist/i18n/locales/de.json.js.map +1 -1
- package/dist/i18n/locales/en.json.js +12 -10
- package/dist/i18n/locales/en.json.js.map +1 -1
- package/dist/i18n/locales/it.json.js +16 -14
- package/dist/i18n/locales/it.json.js.map +1 -1
- package/dist/kit.css +1 -1
- package/dist/shell/NativeSelect/index.js +5 -5
- package/dist/shell/NativeSelect/index.js.map +1 -1
- package/dist/types/display/BarChart/index.d.ts +26 -2
- package/dist/types/display/BarChart/index.d.ts.map +1 -1
- package/dist/types/i18n/index.d.ts +56 -0
- package/dist/types/i18n/index.d.ts.map +1 -1
- package/dist/types/ui/button/index.d.ts +1 -1
- package/dist/types/ui/card/index.d.ts +12 -4
- package/dist/types/ui/card/index.d.ts.map +1 -1
- package/dist/types/ui/color-picker/color.d.ts +13 -0
- package/dist/types/ui/color-picker/color.d.ts.map +1 -0
- package/dist/types/ui/color-picker/index.d.ts +10 -0
- package/dist/types/ui/color-picker/index.d.ts.map +1 -0
- package/dist/types/ui/color-picker-toggle/index.d.ts +8 -0
- package/dist/types/ui/color-picker-toggle/index.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +4 -0
- package/dist/types/ui/index.d.ts.map +1 -1
- package/dist/types/ui/input/index.d.ts +13 -3
- package/dist/types/ui/input/index.d.ts.map +1 -1
- package/dist/types/ui/marked-text/index.d.ts +9 -0
- package/dist/types/ui/marked-text/index.d.ts.map +1 -0
- package/dist/types/ui/pill/index.d.ts +8 -0
- package/dist/types/ui/pill/index.d.ts.map +1 -0
- package/dist/types/ui/radio-group/index.d.ts.map +1 -1
- package/dist/ui/card/index.js +109 -52
- package/dist/ui/card/index.js.map +1 -1
- package/dist/ui/color-picker/ColorPicker.module.scss.js +42 -0
- package/dist/ui/color-picker/ColorPicker.module.scss.js.map +1 -0
- package/dist/ui/color-picker/color.js +60 -0
- package/dist/ui/color-picker/color.js.map +1 -0
- package/dist/ui/color-picker/index.js +239 -0
- package/dist/ui/color-picker/index.js.map +1 -0
- package/dist/ui/color-picker-toggle/index.js +66 -0
- package/dist/ui/color-picker-toggle/index.js.map +1 -0
- package/dist/ui/index.js +113 -105
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/input/index.js +68 -10
- package/dist/ui/input/index.js.map +1 -1
- package/dist/ui/input-group/index.js +9 -9
- package/dist/ui/input-group/index.js.map +1 -1
- package/dist/ui/marked-text/index.js +28 -0
- package/dist/ui/marked-text/index.js.map +1 -0
- package/dist/ui/pill/index.js +33 -0
- package/dist/ui/pill/index.js.map +1 -0
- package/dist/ui/radio-group/index.js +17 -15
- package/dist/ui/radio-group/index.js.map +1 -1
- package/dist/ui/select/index.js +10 -10
- package/dist/ui/select/index.js.map +1 -1
- package/dist/ui/switch/index.js +10 -10
- package/dist/ui/switch/index.js.map +1 -1
- package/dist/ui/textarea/index.js +4 -4
- package/dist/ui/textarea/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/instrument.css +17 -17
- package/styles/theme.css +134 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/ui/card/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/ui/card/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn } from '../../utils/cn'\n\ntype CardProps = React.ComponentProps<'div'> & {\n\tsize?: 'default' | 'sm'\n\tclickable?: boolean\n\t/** Primary action of a clickable card. */\n\taction?: () => void\n\t/** Decorative affordance for the primary action. */\n\tactionIcon?: React.ReactNode\n\t/** On hover-capable devices, also reveal a hover-only icon during keyboard focus. */\n\tactionIconVisibility?: 'hoverOnly' | 'always'\n}\n\nconst interactiveCardContent =\n\t'a[href], button, input, select, textarea, summary, label, [contenteditable]:not([contenteditable=\"false\"]), [role=\"button\"], [role=\"link\"], [tabindex]'\n\nfunction Card({\n\tclassName,\n\tsize = 'default',\n\tclickable = false,\n\taction,\n\tactionIcon,\n\tactionIconVisibility = 'hoverOnly',\n\tchildren,\n\tid,\n\t'aria-label': ariaLabel,\n\t'aria-labelledby': ariaLabelledBy,\n\tonClick,\n\t...props\n}: CardProps) {\n\tconst generatedId = React.useId()\n\tconst hasTrigger = clickable && Boolean(action || onClick)\n\tconst cardId = id ?? (hasTrigger ? generatedId : undefined)\n\tconst hasIcon = clickable && actionIcon != null && actionIcon !== false\n\n\tfunction handleClick(event: React.MouseEvent<HTMLDivElement>) {\n\t\tconst { target, currentTarget } = event\n\t\tif (\n\t\t\t!(target instanceof Element) ||\n\t\t\ttarget.closest('[data-slot=\"card\"]') !== currentTarget\n\t\t)\n\t\t\treturn\n\n\t\tconst control = target.closest(interactiveCardContent)\n\t\tif (\n\t\t\tcontrol &&\n\t\t\tcontrol !== currentTarget &&\n\t\t\tcurrentTarget.contains(control) &&\n\t\t\tcontrol.getAttribute('data-slot') !== 'card-trigger'\n\t\t)\n\t\t\treturn\n\n\t\tonClick?.(event)\n\t\tif (!event.defaultPrevented) action?.()\n\t}\n\n\treturn (\n\t\t// biome-ignore lint/a11y/useKeyWithClickEvents lint/a11y/noStaticElementInteractions: The native card trigger handles keyboard activation. The card delegates pointer clicks on its surface.\n\t\t<div\n\t\t\tid={cardId}\n\t\t\tdata-slot='card'\n\t\t\tdata-size={size}\n\t\t\tdata-clickable={clickable ? 'true' : undefined}\n\t\t\t{...(!hasTrigger && {\n\t\t\t\t'aria-label': ariaLabel,\n\t\t\t\t'aria-labelledby': ariaLabelledBy,\n\t\t\t})}\n\t\t\tonClick={hasTrigger ? handleClick : onClick}\n\t\t\tclassName={cn(\n\t\t\t\t'group/card flex flex-col gap-4 overflow-hidden rounded-xl border-0 bg-card/95 py-5 shadow-(--surface-shadow) text-sm text-card-foreground has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl',\n\t\t\t\tclickable && 'relative',\n\t\t\t\thasIcon ? 'pe-9' : hasTrigger && 'pe-3',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{hasTrigger || hasIcon ? (\n\t\t\t\t<>\n\t\t\t\t\t{children}\n\t\t\t\t\t{hasTrigger && (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\tdata-slot='card-trigger'\n\t\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\t\taria-labelledby={\n\t\t\t\t\t\t\t\tariaLabelledBy ?? (ariaLabel ? undefined : cardId)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t'absolute inset-y-0 end-0 outline-none',\n\t\t\t\t\t\t\t\thasIcon ? 'w-9' : 'w-3',\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{hasIcon && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden='true'\n\t\t\t\t\t\t\tdata-slot='card-action-icon'\n\t\t\t\t\t\t\tdata-visibility={actionIconVisibility}\n\t\t\t\t\t\t\tclassName='pointer-events-none absolute end-4 top-1/2 grid size-4 -translate-y-1/2 place-items-center text-muted-foreground [&>svg]:size-full'\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{actionIcon}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\nfunction CardHeader({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-header'\n\t\t\tclassName={cn(\n\t\t\t\t'group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-5 sm:px-6 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-5 group-data-[size=sm]/card:[.border-b]:pb-4',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction CardTitle({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-title'\n\t\t\tclassName={cn(\n\t\t\t\t'font-heading text-lg leading-snug font-semibold tracking-tight group-data-[size=sm]/card:text-sm',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction CardDescription({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-description'\n\t\t\tclassName={cn('text-sm text-muted-foreground', className)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction CardAction({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-action'\n\t\t\tclassName={cn(\n\t\t\t\t'col-start-2 row-span-2 row-start-1 self-start justify-self-end',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction CardContent({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-content'\n\t\t\tclassName={cn('px-5 sm:px-6 group-data-[size=sm]/card:px-3', className)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction CardFooter({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot='card-footer'\n\t\t\tclassName={cn(\n\t\t\t\t'flex items-center rounded-b-xl mt-1 border-t bg-transparent p-5 pt-6 sm:px-6 group-data-[size=sm]/card:p-3 group-data-[size=sm]/card:pt-4',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nexport {\n\tCard,\n\tCardAction,\n\tCardContent,\n\tCardDescription,\n\tCardFooter,\n\tCardHeader,\n\ttype CardProps,\n\tCardTitle,\n}\n"],"names":["interactiveCardContent","Card","className","size","clickable","action","actionIcon","actionIconVisibility","children","id","ariaLabel","ariaLabelledBy","onClick","props","generatedId","React","hasTrigger","cardId","hasIcon","handleClick","event","target","currentTarget","control","jsx","cn","jsxs","Fragment","CardHeader","CardTitle","CardDescription","CardAction","CardContent","CardFooter"],"mappings":";;;AAeA,MAAMA,IACL;AAED,SAASC,EAAK;AAAA,EACb,WAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,UAAAC;AAAA,EACA,IAAAC;AAAA,EACA,cAAcC;AAAA,EACd,mBAAmBC;AAAA,EACnB,SAAAC;AAAA,EACA,GAAGC;AACJ,GAAc;AACb,QAAMC,IAAcC,EAAM,MAAA,GACpBC,IAAaZ,KAAa,GAAQC,KAAUO,IAC5CK,IAASR,MAAOO,IAAaF,IAAc,SAC3CI,IAAUd,KAAaE,KAAc,QAAQA,MAAe;AAElE,WAASa,EAAYC,GAAyC;AAC7D,UAAM,EAAE,QAAAC,GAAQ,eAAAC,EAAA,IAAkBF;AAClC,QACC,EAAEC,aAAkB,YACpBA,EAAO,QAAQ,oBAAoB,MAAMC;AAEzC;AAED,UAAMC,IAAUF,EAAO,QAAQrB,CAAsB;AACrD,IACCuB,KACAA,MAAYD,KACZA,EAAc,SAASC,CAAO,KAC9BA,EAAQ,aAAa,WAAW,MAAM,mBAIvCX,IAAUQ,CAAK,GACVA,EAAM,oBAAkBf,IAAA;AAAA,EAC9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AAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC;AAAA,QACV;AAAA,QACAvB;AAAA,MAAA;AAAA,MAEA,GAAGW;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAASiB,EAAgB,EAAE,WAAA5B,GAAW,GAAGW,KAAsC;AAC9E,SACC,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC,EAAG,iCAAiCvB,CAAS;AAAA,MACvD,GAAGW;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAASkB,EAAW,EAAE,WAAA7B,GAAW,GAAGW,KAAsC;AACzE,SACC,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC;AAAA,QACV;AAAA,QACAvB;AAAA,MAAA;AAAA,MAEA,GAAGW;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAASmB,EAAY,EAAE,WAAA9B,GAAW,GAAGW,KAAsC;AAC1E,SACC,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC,EAAG,+CAA+CvB,CAAS;AAAA,MACrE,GAAGW;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAASoB,EAAW,EAAE,WAAA/B,GAAW,GAAGW,KAAsC;AACzE,SACC,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,aAAU;AAAA,MACV,WAAWC;AAAA,QACV;AAAA,QACAvB;AAAA,MAAA;AAAA,MAEA,GAAGW;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const o = "stoa-ColorPicker-picker-m4d3", r = "stoa-ColorPicker-header-i9ri", t = "stoa-ColorPicker-wheel-nqe9", c = "stoa-ColorPicker-hue-input-50uw", e = "stoa-ColorPicker-indicator-3hrr", n = "stoa-ColorPicker-track-nox6", s = "stoa-ColorPicker-inner-track-gnno", a = "stoa-ColorPicker-tick-wuc0", i = "stoa-ColorPicker-major-tick-6mya", k = "stoa-ColorPicker-hue-ring-10ts", l = "stoa-ColorPicker-center-fws1", h = "stoa-ColorPicker-caption-1t6d", C = "stoa-ColorPicker-control-qt49", P = "stoa-ColorPicker-readout-2vje", u = "stoa-ColorPicker-hex-row-1xik", d = "stoa-ColorPicker-controls-n32o", w = "stoa-ColorPicker-footer-hhfh", p = "stoa-ColorPicker-swatches-r9ha", f = {
|
|
2
|
+
picker: o,
|
|
3
|
+
header: r,
|
|
4
|
+
wheel: t,
|
|
5
|
+
hueInput: c,
|
|
6
|
+
indicator: e,
|
|
7
|
+
track: n,
|
|
8
|
+
innerTrack: s,
|
|
9
|
+
tick: a,
|
|
10
|
+
majorTick: i,
|
|
11
|
+
hueRing: k,
|
|
12
|
+
center: l,
|
|
13
|
+
caption: h,
|
|
14
|
+
control: C,
|
|
15
|
+
readout: P,
|
|
16
|
+
hexRow: u,
|
|
17
|
+
controls: d,
|
|
18
|
+
footer: w,
|
|
19
|
+
swatches: p
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
h as caption,
|
|
23
|
+
l as center,
|
|
24
|
+
C as control,
|
|
25
|
+
d as controls,
|
|
26
|
+
f as default,
|
|
27
|
+
w as footer,
|
|
28
|
+
r as header,
|
|
29
|
+
u as hexRow,
|
|
30
|
+
c as hueInput,
|
|
31
|
+
k as hueRing,
|
|
32
|
+
e as indicator,
|
|
33
|
+
s as innerTrack,
|
|
34
|
+
i as majorTick,
|
|
35
|
+
o as picker,
|
|
36
|
+
P as readout,
|
|
37
|
+
p as swatches,
|
|
38
|
+
a as tick,
|
|
39
|
+
n as track,
|
|
40
|
+
t as wheel
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=ColorPicker.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPicker.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { parseHexColor as h } from "../../utils/colors.js";
|
|
2
|
+
const u = "#FF607F", f = [
|
|
3
|
+
u,
|
|
4
|
+
"#E23F5A",
|
|
5
|
+
"#FF9BFA",
|
|
6
|
+
"#0070FF",
|
|
7
|
+
"#0093AF",
|
|
8
|
+
"#A226AD",
|
|
9
|
+
"#262629",
|
|
10
|
+
"#F0F0ED"
|
|
11
|
+
];
|
|
12
|
+
function p(t) {
|
|
13
|
+
const n = t.trim().replace(/^#/, "");
|
|
14
|
+
if (/^[\da-f]{8}$/i.test(n)) {
|
|
15
|
+
const o = `#${n.toUpperCase()}`;
|
|
16
|
+
return o.endsWith("FF") ? o.slice(0, 7) : o;
|
|
17
|
+
}
|
|
18
|
+
return h(t);
|
|
19
|
+
}
|
|
20
|
+
function F(t, n) {
|
|
21
|
+
return Number.parseInt(t.slice(n, n + 2), 16) / 255;
|
|
22
|
+
}
|
|
23
|
+
function d(t) {
|
|
24
|
+
const n = F(t, 1), o = F(t, 3), e = F(t, 5), c = t.length === 9 ? F(t, 7) : 1, a = Math.max(n, o, e), r = Math.min(n, o, e), s = a - r, i = (a + r) / 2;
|
|
25
|
+
if (s === 0) return { h: 0, s: 0, l: i * 100, a: c };
|
|
26
|
+
let l = (n - o) / s + 4;
|
|
27
|
+
return a === n ? l = (o - e) / s : a === o && (l = (e - n) / s + 2), {
|
|
28
|
+
h: (l * 60 + 360) % 360,
|
|
29
|
+
s: s / (1 - Math.abs(2 * i - 1)) * 100,
|
|
30
|
+
l: i * 100,
|
|
31
|
+
a: c
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function C({ h: t, s: n, l: o, a: e }) {
|
|
35
|
+
const c = o / 100, a = n / 100 * Math.min(c, 1 - c);
|
|
36
|
+
function r(i) {
|
|
37
|
+
const l = (i + t / 30) % 12;
|
|
38
|
+
return c - a * Math.max(-1, Math.min(l - 3, 9 - l, 1));
|
|
39
|
+
}
|
|
40
|
+
const s = [r(0), r(8), r(4), e].map(
|
|
41
|
+
(i) => Math.round(i * 255).toString(16).padStart(2, "0")
|
|
42
|
+
).join("").toUpperCase();
|
|
43
|
+
return s.endsWith("FF") ? `#${s.slice(0, 6)}` : `#${s}`;
|
|
44
|
+
}
|
|
45
|
+
function M(t, n) {
|
|
46
|
+
const [o, e, c] = [1, 3, 5].map((a) => {
|
|
47
|
+
const r = F(t, a) * n + 1 - n;
|
|
48
|
+
return r <= 0.04045 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
49
|
+
});
|
|
50
|
+
return 0.2126 * o + 0.7152 * e + 0.0722 * c > 0.179 ? "#000" : "#fff";
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
u as DEFAULT_COLOR,
|
|
54
|
+
f as PRESETS,
|
|
55
|
+
M as discTextColor,
|
|
56
|
+
d as hexToHsla,
|
|
57
|
+
C as hslaToHex,
|
|
58
|
+
p as normalizeColor
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sources":["../../../src/ui/color-picker/color.ts"],"sourcesContent":["import { parseHexColor } from '../../utils/colors'\n\nexport const DEFAULT_COLOR = '#FF607F'\nexport const PRESETS = [\n\tDEFAULT_COLOR,\n\t'#E23F5A',\n\t'#FF9BFA',\n\t'#0070FF',\n\t'#0093AF',\n\t'#A226AD',\n\t'#262629',\n\t'#F0F0ED',\n]\n\nexport type Hsla = { h: number; s: number; l: number; a: number }\n\nexport function normalizeColor(value: string) {\n\tconst hex = value.trim().replace(/^#/, '')\n\tif (/^[\\da-f]{8}$/i.test(hex)) {\n\t\tconst canonical = `#${hex.toUpperCase()}`\n\t\treturn canonical.endsWith('FF') ? canonical.slice(0, 7) : canonical\n\t}\n\treturn parseHexColor(value)\n}\n\nfunction readChannel(hex: string, offset: number) {\n\treturn Number.parseInt(hex.slice(offset, offset + 2), 16) / 255\n}\n\nexport function hexToHsla(hex: string): Hsla {\n\tconst r = readChannel(hex, 1)\n\tconst g = readChannel(hex, 3)\n\tconst b = readChannel(hex, 5)\n\tconst a = hex.length === 9 ? readChannel(hex, 7) : 1\n\tconst max = Math.max(r, g, b)\n\tconst min = Math.min(r, g, b)\n\tconst delta = max - min\n\tconst l = (max + min) / 2\n\tif (delta === 0) return { h: 0, s: 0, l: l * 100, a }\n\n\tlet sector = (r - g) / delta + 4\n\tif (max === r) sector = (g - b) / delta\n\telse if (max === g) sector = (b - r) / delta + 2\n\n\treturn {\n\t\th: (sector * 60 + 360) % 360,\n\t\ts: (delta / (1 - Math.abs(2 * l - 1))) * 100,\n\t\tl: l * 100,\n\t\ta,\n\t}\n}\n\nexport function hslaToHex({ h, s, l, a }: Hsla) {\n\tconst lightness = l / 100\n\tconst chroma = (s / 100) * Math.min(lightness, 1 - lightness)\n\n\tfunction channel(offset: number) {\n\t\tconst position = (offset + h / 30) % 12\n\t\treturn (\n\t\t\tlightness - chroma * Math.max(-1, Math.min(position - 3, 9 - position, 1))\n\t\t)\n\t}\n\n\tconst hex = [channel(0), channel(8), channel(4), a]\n\t\t.map((value) =>\n\t\t\tMath.round(value * 255)\n\t\t\t\t.toString(16)\n\t\t\t\t.padStart(2, '0'),\n\t\t)\n\t\t.join('')\n\t\t.toUpperCase()\n\treturn hex.endsWith('FF') ? `#${hex.slice(0, 6)}` : `#${hex}`\n}\n\n// The disc composites transparent colors over white.\nexport function discTextColor(hex: string, alpha: number) {\n\tconst [r, g, b] = [1, 3, 5].map((offset) => {\n\t\tconst channel = readChannel(hex, offset) * alpha + 1 - alpha\n\t\treturn channel <= 0.04045\n\t\t\t? channel / 12.92\n\t\t\t: ((channel + 0.055) / 1.055) ** 2.4\n\t})\n\treturn 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.179 ? '#000' : '#fff'\n}\n"],"names":["DEFAULT_COLOR","PRESETS","normalizeColor","value","hex","canonical","parseHexColor","readChannel","offset","hexToHsla","r","g","b","a","max","min","delta","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
+
import { useTranslation as U } from "react-i18next";
|
|
4
|
+
import { STOA_NS as V } from "../../i18n/namespace.js";
|
|
5
|
+
import { cn as z } from "../../utils/cn.js";
|
|
6
|
+
import { normalizeColor as b, DEFAULT_COLOR as D, discTextColor as G, PRESETS as Q, hexToHsla as X, hslaToHex as Y } from "./color.js";
|
|
7
|
+
import r from "./ColorPicker.module.scss.js";
|
|
8
|
+
const n = 160, S = 139, q = ["s", "l", "a"];
|
|
9
|
+
function E(d, m) {
|
|
10
|
+
const l = (d - 90) * Math.PI / 180;
|
|
11
|
+
return {
|
|
12
|
+
x: n + Math.cos(l) * m,
|
|
13
|
+
y: n + Math.sin(l) * m
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const J = Array.from({ length: 72 }, (d, m) => {
|
|
17
|
+
const l = m * 5, x = l % 30 === 0, o = E(l, x ? 140 : 145), s = E(l, 151);
|
|
18
|
+
return { degrees: l, major: x, x1: o.x, y1: o.y, x2: s.x, y2: s.y };
|
|
19
|
+
});
|
|
20
|
+
function N(d) {
|
|
21
|
+
return { color: d, hsla: X(d) };
|
|
22
|
+
}
|
|
23
|
+
function ie({
|
|
24
|
+
value: d,
|
|
25
|
+
defaultValue: m,
|
|
26
|
+
onChange: l,
|
|
27
|
+
className: x
|
|
28
|
+
}) {
|
|
29
|
+
const { t: o } = U(V), s = K(), h = d === void 0 ? void 0 : b(d) ?? D, [w, $] = k(
|
|
30
|
+
() => N(
|
|
31
|
+
h ?? b(m ?? "") ?? D
|
|
32
|
+
)
|
|
33
|
+
), [F, L] = k(h), [M, g] = k(), [R, y] = k();
|
|
34
|
+
let C = w;
|
|
35
|
+
h !== void 0 && h !== w.color && (C = N(h)), h !== F && (L(h), $(C), g(void 0), y(void 0));
|
|
36
|
+
const { color: i, hsla: p } = C, H = M?.color === i ? M.text : i, P = Math.round(p.h) % 360, I = E(p.h, S), j = o("colorPicker.title", "Color instrument");
|
|
37
|
+
function v(e) {
|
|
38
|
+
g(void 0), y(void 0), $(e), e.color !== i && l?.(e.color);
|
|
39
|
+
}
|
|
40
|
+
function T(e, c) {
|
|
41
|
+
const u = { ...p, [e]: c };
|
|
42
|
+
v({ color: Y(u), hsla: u });
|
|
43
|
+
}
|
|
44
|
+
function A(e) {
|
|
45
|
+
const c = e.currentTarget.ownerSVGElement?.getBoundingClientRect();
|
|
46
|
+
if (!c) return;
|
|
47
|
+
const u = e.clientX - c.left - c.width / 2, f = e.clientY - c.top - c.height / 2;
|
|
48
|
+
u === 0 && f === 0 || T(
|
|
49
|
+
"h",
|
|
50
|
+
(Math.round(Math.atan2(u, -f) * 180 / Math.PI) + 360) % 360
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
function O() {
|
|
54
|
+
const e = b(H);
|
|
55
|
+
e && e !== i ? v(N(e)) : g(void 0);
|
|
56
|
+
}
|
|
57
|
+
async function B() {
|
|
58
|
+
try {
|
|
59
|
+
await navigator.clipboard.writeText(i), y({ color: i, success: !0 });
|
|
60
|
+
} catch {
|
|
61
|
+
y({ color: i, success: !1 });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const _ = {
|
|
65
|
+
s: o("colorPicker.saturation", "Saturation"),
|
|
66
|
+
l: o("colorPicker.lightness", "Lightness"),
|
|
67
|
+
a: o("colorPicker.opacity", "Opacity")
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ a(
|
|
70
|
+
"section",
|
|
71
|
+
{
|
|
72
|
+
className: z(r.picker, x),
|
|
73
|
+
"data-slot": "color-picker",
|
|
74
|
+
"aria-labelledby": `${s}-title`,
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ t("header", { className: r.header, children: /* @__PURE__ */ t(
|
|
77
|
+
"h2",
|
|
78
|
+
{
|
|
79
|
+
id: `${s}-title`,
|
|
80
|
+
className: "font-heading text-2xl leading-snug font-semibold tracking-tight",
|
|
81
|
+
children: j
|
|
82
|
+
}
|
|
83
|
+
) }),
|
|
84
|
+
/* @__PURE__ */ a("div", { className: r.wheel, children: [
|
|
85
|
+
/* @__PURE__ */ t(
|
|
86
|
+
"input",
|
|
87
|
+
{
|
|
88
|
+
className: r.hueInput,
|
|
89
|
+
type: "range",
|
|
90
|
+
min: 0,
|
|
91
|
+
max: 359,
|
|
92
|
+
value: P,
|
|
93
|
+
onChange: (e) => T("h", e.currentTarget.valueAsNumber),
|
|
94
|
+
"aria-label": o("colorPicker.hue", "Hue"),
|
|
95
|
+
"aria-valuetext": `${P}°`
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ a("svg", { viewBox: "0 0 320 320", "aria-hidden": "true", children: [
|
|
99
|
+
/* @__PURE__ */ t("circle", { cx: n, cy: n, r: S, className: r.track }),
|
|
100
|
+
J.map(({ degrees: e, major: c, ...u }) => /* @__PURE__ */ t(
|
|
101
|
+
"line",
|
|
102
|
+
{
|
|
103
|
+
...u,
|
|
104
|
+
className: c ? r.majorTick : r.tick
|
|
105
|
+
},
|
|
106
|
+
e
|
|
107
|
+
)),
|
|
108
|
+
/* @__PURE__ */ t(
|
|
109
|
+
"circle",
|
|
110
|
+
{
|
|
111
|
+
cx: n,
|
|
112
|
+
cy: n,
|
|
113
|
+
r: 126,
|
|
114
|
+
className: r.innerTrack
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ t("circle", { cx: n, cy: n, r: 117, fill: "white" }),
|
|
118
|
+
/* @__PURE__ */ t("circle", { cx: n, cy: n, r: 117, fill: i }),
|
|
119
|
+
/* @__PURE__ */ t(
|
|
120
|
+
"circle",
|
|
121
|
+
{
|
|
122
|
+
cx: I.x,
|
|
123
|
+
cy: I.y,
|
|
124
|
+
r: 8,
|
|
125
|
+
className: r.indicator
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ t(
|
|
129
|
+
"circle",
|
|
130
|
+
{
|
|
131
|
+
cx: n,
|
|
132
|
+
cy: n,
|
|
133
|
+
r: S,
|
|
134
|
+
className: r.hueRing,
|
|
135
|
+
onPointerDown: (e) => {
|
|
136
|
+
e.button !== 0 || !e.isPrimary || (e.currentTarget.setPointerCapture(e.pointerId), A(e));
|
|
137
|
+
},
|
|
138
|
+
onPointerMove: (e) => {
|
|
139
|
+
e.currentTarget.hasPointerCapture(e.pointerId) && A(e);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ a(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: r.center,
|
|
148
|
+
style: { color: G(i, p.a) },
|
|
149
|
+
"aria-hidden": "true",
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ t("strong", { children: i.slice(0, 7) }),
|
|
152
|
+
/* @__PURE__ */ a("span", { children: [
|
|
153
|
+
o("colorPicker.hue", "Hue"),
|
|
154
|
+
" ",
|
|
155
|
+
String(P).padStart(3, "0"),
|
|
156
|
+
"°"
|
|
157
|
+
] })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ a("div", { className: r.readout, children: [
|
|
163
|
+
/* @__PURE__ */ t("label", { className: r.caption, htmlFor: `${s}-hex`, children: o("colorPicker.hex", "Hex color") }),
|
|
164
|
+
/* @__PURE__ */ a("div", { className: r.hexRow, children: [
|
|
165
|
+
/* @__PURE__ */ t(
|
|
166
|
+
"input",
|
|
167
|
+
{
|
|
168
|
+
id: `${s}-hex`,
|
|
169
|
+
value: H,
|
|
170
|
+
onChange: (e) => g({ color: i, text: e.currentTarget.value }),
|
|
171
|
+
onBlur: O,
|
|
172
|
+
onKeyDown: (e) => {
|
|
173
|
+
e.key === "Enter" && !e.nativeEvent.isComposing && (e.preventDefault(), e.currentTarget.blur());
|
|
174
|
+
},
|
|
175
|
+
spellCheck: !1
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: B, children: [
|
|
179
|
+
o("colorPicker.copy", "Copy"),
|
|
180
|
+
" ",
|
|
181
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true", children: "↗" })
|
|
182
|
+
] })
|
|
183
|
+
] }),
|
|
184
|
+
/* @__PURE__ */ t("span", { className: r.caption, role: "status", children: R?.color === i && (R.success ? o("colorPicker.copied", "Color copied") : o("colorPicker.copyFailed", "Could not copy color")) })
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ t("div", { className: r.controls, children: q.map((e) => {
|
|
187
|
+
const c = Math.round(
|
|
188
|
+
e === "a" ? p.a * 100 : p[e]
|
|
189
|
+
);
|
|
190
|
+
return /* @__PURE__ */ a("div", { className: r.control, children: [
|
|
191
|
+
/* @__PURE__ */ t("label", { htmlFor: `${s}-${e}`, children: _[e] }),
|
|
192
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: [
|
|
193
|
+
String(c).padStart(2, "0"),
|
|
194
|
+
"%"
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ t(
|
|
197
|
+
"input",
|
|
198
|
+
{
|
|
199
|
+
id: `${s}-${e}`,
|
|
200
|
+
type: "range",
|
|
201
|
+
min: 0,
|
|
202
|
+
max: 100,
|
|
203
|
+
value: c,
|
|
204
|
+
"aria-valuetext": `${c}%`,
|
|
205
|
+
onChange: (u) => {
|
|
206
|
+
const f = u.currentTarget.valueAsNumber;
|
|
207
|
+
T(e, e === "a" ? f / 100 : f);
|
|
208
|
+
},
|
|
209
|
+
style: { "--progress": `${c}%` }
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] }, e);
|
|
213
|
+
}) }),
|
|
214
|
+
/* @__PURE__ */ t("footer", { className: r.footer, children: /* @__PURE__ */ a("fieldset", { children: [
|
|
215
|
+
/* @__PURE__ */ t("legend", { className: r.caption, children: o("colorPicker.presets", "Quick select") }),
|
|
216
|
+
/* @__PURE__ */ t("div", { className: r.swatches, children: Q.map((e) => /* @__PURE__ */ t(
|
|
217
|
+
"button",
|
|
218
|
+
{
|
|
219
|
+
type: "button",
|
|
220
|
+
"aria-label": o("colorPicker.select", {
|
|
221
|
+
defaultValue: "Select {{color}}",
|
|
222
|
+
color: e
|
|
223
|
+
}),
|
|
224
|
+
"aria-pressed": i === e,
|
|
225
|
+
title: e,
|
|
226
|
+
style: { backgroundColor: e },
|
|
227
|
+
onClick: () => v(N(e))
|
|
228
|
+
},
|
|
229
|
+
e
|
|
230
|
+
)) })
|
|
231
|
+
] }) })
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
export {
|
|
237
|
+
ie as ColorPicker
|
|
238
|
+
};
|
|
239
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/ui/color-picker/index.tsx"],"sourcesContent":["'use client'\n\nimport { type CSSProperties, type PointerEvent, useId, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { cn } from '../../utils/cn'\nimport {\n\tDEFAULT_COLOR,\n\tdiscTextColor,\n\ttype Hsla,\n\thexToHsla,\n\thslaToHex,\n\tnormalizeColor,\n\tPRESETS,\n} from './color'\nimport styles from './ColorPicker.module.scss'\n\nexport interface ColorPickerProps {\n\t/** Displayed hex color. Omit to let the picker own the selection. */\n\tvalue?: string\n\tdefaultValue?: string\n\t/** Emits uppercase #RRGGBB or #RRGGBBAA. */\n\tonChange?: (color: string) => void\n\tclassName?: string\n}\n\nconst CENTER = 160\nconst RADIUS = 139\nconst CHANNELS = ['s', 'l', 'a'] as const\n\nfunction ringPoint(degrees: number, radius: number) {\n\tconst radians = ((degrees - 90) * Math.PI) / 180\n\treturn {\n\t\tx: CENTER + Math.cos(radians) * radius,\n\t\ty: CENTER + Math.sin(radians) * radius,\n\t}\n}\n\nconst TICKS = Array.from({ length: 72 }, (_, index) => {\n\tconst degrees = index * 5\n\tconst major = degrees % 30 === 0\n\tconst start = ringPoint(degrees, major ? 140 : 145)\n\tconst end = ringPoint(degrees, 151)\n\treturn { degrees, major, x1: start.x, y1: start.y, x2: end.x, y2: end.y }\n})\n\nfunction selectionFromHex(color: string) {\n\treturn { color, hsla: hexToHsla(color) }\n}\n\nexport function ColorPicker({\n\tvalue,\n\tdefaultValue,\n\tonChange,\n\tclassName,\n}: ColorPickerProps) {\n\tconst { t } = useTranslation(STOA_NS)\n\tconst id = useId()\n\tconst external =\n\t\tvalue === undefined ? undefined : (normalizeColor(value) ?? DEFAULT_COLOR)\n\tconst [selection, setSelection] = useState(() =>\n\t\tselectionFromHex(\n\t\t\texternal ?? normalizeColor(defaultValue ?? '') ?? DEFAULT_COLOR,\n\t\t),\n\t)\n\tconst [previousExternal, setPreviousExternal] = useState(external)\n\tconst [draft, setDraft] = useState<{ color: string; text: string }>()\n\tconst [copyResult, setCopyResult] = useState<{\n\t\tcolor: string\n\t\tsuccess: boolean\n\t}>()\n\n\tlet current = selection\n\tif (external !== undefined && external !== selection.color) {\n\t\tcurrent = selectionFromHex(external)\n\t}\n\tif (external !== previousExternal) {\n\t\tsetPreviousExternal(external)\n\t\tsetSelection(current)\n\t\tsetDraft(undefined)\n\t\tsetCopyResult(undefined)\n\t}\n\n\tconst { color, hsla } = current\n\tconst text = draft?.color === color ? draft.text : color\n\tconst hue = Math.round(hsla.h) % 360\n\tconst indicator = ringPoint(hsla.h, RADIUS)\n\tconst title = t('colorPicker.title', 'Color instrument')\n\n\tfunction commit(next: typeof selection) {\n\t\tsetDraft(undefined)\n\t\tsetCopyResult(undefined)\n\t\tsetSelection(next)\n\t\tif (next.color !== color) onChange?.(next.color)\n\t}\n\n\tfunction changeChannel(channel: keyof Hsla, amount: number) {\n\t\tconst next = { ...hsla, [channel]: amount }\n\t\t// Preserve the dial settings when multiple HSL values map to the same hex.\n\t\tcommit({ color: hslaToHex(next), hsla: next })\n\t}\n\n\tfunction pointToHue(event: PointerEvent<SVGCircleElement>) {\n\t\tconst bounds = event.currentTarget.ownerSVGElement?.getBoundingClientRect()\n\t\tif (!bounds) return\n\t\tconst x = event.clientX - bounds.left - bounds.width / 2\n\t\tconst y = event.clientY - bounds.top - bounds.height / 2\n\t\tif (x === 0 && y === 0) return\n\t\tchangeChannel(\n\t\t\t'h',\n\t\t\t(Math.round((Math.atan2(x, -y) * 180) / Math.PI) + 360) % 360,\n\t\t)\n\t}\n\n\tfunction finishEditing() {\n\t\tconst next = normalizeColor(text)\n\t\tif (next && next !== color) commit(selectionFromHex(next))\n\t\telse setDraft(undefined)\n\t}\n\n\tasync function copyColor() {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(color)\n\t\t\tsetCopyResult({ color, success: true })\n\t\t} catch {\n\t\t\tsetCopyResult({ color, success: false })\n\t\t}\n\t}\n\n\tconst channelLabels = {\n\t\ts: t('colorPicker.saturation', 'Saturation'),\n\t\tl: t('colorPicker.lightness', 'Lightness'),\n\t\ta: t('colorPicker.opacity', 'Opacity'),\n\t}\n\n\treturn (\n\t\t<section\n\t\t\tclassName={cn(styles.picker, className)}\n\t\t\tdata-slot='color-picker'\n\t\t\taria-labelledby={`${id}-title`}\n\t\t>\n\t\t\t<header className={styles.header}>\n\t\t\t\t<h2\n\t\t\t\t\tid={`${id}-title`}\n\t\t\t\t\tclassName='font-heading text-2xl leading-snug font-semibold tracking-tight'\n\t\t\t\t>\n\t\t\t\t\t{title}\n\t\t\t\t</h2>\n\t\t\t</header>\n\t\t\t<div className={styles.wheel}>\n\t\t\t\t<input\n\t\t\t\t\tclassName={styles.hueInput}\n\t\t\t\t\ttype='range'\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={359}\n\t\t\t\t\tvalue={hue}\n\t\t\t\t\tonChange={(event) =>\n\t\t\t\t\t\tchangeChannel('h', event.currentTarget.valueAsNumber)\n\t\t\t\t\t}\n\t\t\t\t\taria-label={t('colorPicker.hue', 'Hue')}\n\t\t\t\t\taria-valuetext={`${hue}°`}\n\t\t\t\t/>\n\t\t\t\t<svg viewBox='0 0 320 320' aria-hidden='true'>\n\t\t\t\t\t<circle cx={CENTER} cy={CENTER} r={RADIUS} className={styles.track} />\n\t\t\t\t\t{TICKS.map(({ degrees, major, ...line }) => (\n\t\t\t\t\t\t<line\n\t\t\t\t\t\t\tkey={degrees}\n\t\t\t\t\t\t\t{...line}\n\t\t\t\t\t\t\tclassName={major ? styles.majorTick : styles.tick}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx={CENTER}\n\t\t\t\t\t\tcy={CENTER}\n\t\t\t\t\t\tr={126}\n\t\t\t\t\t\tclassName={styles.innerTrack}\n\t\t\t\t\t/>\n\t\t\t\t\t<circle cx={CENTER} cy={CENTER} r={117} fill='white' />\n\t\t\t\t\t<circle cx={CENTER} cy={CENTER} r={117} fill={color} />\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx={indicator.x}\n\t\t\t\t\t\tcy={indicator.y}\n\t\t\t\t\t\tr={8}\n\t\t\t\t\t\tclassName={styles.indicator}\n\t\t\t\t\t/>\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx={CENTER}\n\t\t\t\t\t\tcy={CENTER}\n\t\t\t\t\t\tr={RADIUS}\n\t\t\t\t\t\tclassName={styles.hueRing}\n\t\t\t\t\t\tonPointerDown={(event) => {\n\t\t\t\t\t\t\tif (event.button !== 0 || !event.isPrimary) return\n\t\t\t\t\t\t\tevent.currentTarget.setPointerCapture(event.pointerId)\n\t\t\t\t\t\t\tpointToHue(event)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonPointerMove={(event) => {\n\t\t\t\t\t\t\tif (event.currentTarget.hasPointerCapture(event.pointerId))\n\t\t\t\t\t\t\t\tpointToHue(event)\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</svg>\n\t\t\t\t<div\n\t\t\t\t\tclassName={styles.center}\n\t\t\t\t\tstyle={{ color: discTextColor(color, hsla.a) }}\n\t\t\t\t\taria-hidden='true'\n\t\t\t\t>\n\t\t\t\t\t<strong>{color.slice(0, 7)}</strong>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{t('colorPicker.hue', 'Hue')} {String(hue).padStart(3, '0')}°\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div className={styles.readout}>\n\t\t\t\t<label className={styles.caption} htmlFor={`${id}-hex`}>\n\t\t\t\t\t{t('colorPicker.hex', 'Hex color')}\n\t\t\t\t</label>\n\t\t\t\t<div className={styles.hexRow}>\n\t\t\t\t\t<input\n\t\t\t\t\t\tid={`${id}-hex`}\n\t\t\t\t\t\tvalue={text}\n\t\t\t\t\t\tonChange={(event) =>\n\t\t\t\t\t\t\tsetDraft({ color, text: event.currentTarget.value })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonBlur={finishEditing}\n\t\t\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\t\t\tif (event.key === 'Enter' && !event.nativeEvent.isComposing) {\n\t\t\t\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\t\t\t\tevent.currentTarget.blur()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t/>\n\t\t\t\t\t<button type='button' onClick={copyColor}>\n\t\t\t\t\t\t{t('colorPicker.copy', 'Copy')} <span aria-hidden='true'>↗</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<span className={styles.caption} role='status'>\n\t\t\t\t\t{copyResult?.color === color &&\n\t\t\t\t\t\t(copyResult.success\n\t\t\t\t\t\t\t? t('colorPicker.copied', 'Color copied')\n\t\t\t\t\t\t\t: t('colorPicker.copyFailed', 'Could not copy color'))}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t<div className={styles.controls}>\n\t\t\t\t{CHANNELS.map((channel) => {\n\t\t\t\t\tconst amount = Math.round(\n\t\t\t\t\t\tchannel === 'a' ? hsla.a * 100 : hsla[channel],\n\t\t\t\t\t)\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div key={channel} className={styles.control}>\n\t\t\t\t\t\t\t<label htmlFor={`${id}-${channel}`}>\n\t\t\t\t\t\t\t\t{channelLabels[channel]}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<span aria-hidden='true'>{String(amount).padStart(2, '0')}%</span>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid={`${id}-${channel}`}\n\t\t\t\t\t\t\t\ttype='range'\n\t\t\t\t\t\t\t\tmin={0}\n\t\t\t\t\t\t\t\tmax={100}\n\t\t\t\t\t\t\t\tvalue={amount}\n\t\t\t\t\t\t\t\taria-valuetext={`${amount}%`}\n\t\t\t\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\t\t\t\tconst next = event.currentTarget.valueAsNumber\n\t\t\t\t\t\t\t\t\tchangeChannel(channel, channel === 'a' ? next / 100 : next)\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tstyle={{ '--progress': `${amount}%` } as CSSProperties}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</div>\n\t\t\t<footer className={styles.footer}>\n\t\t\t\t<fieldset>\n\t\t\t\t\t<legend className={styles.caption}>\n\t\t\t\t\t\t{t('colorPicker.presets', 'Quick select')}\n\t\t\t\t\t</legend>\n\t\t\t\t\t<div className={styles.swatches}>\n\t\t\t\t\t\t{PRESETS.map((preset) => (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tkey={preset}\n\t\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\t\taria-label={t('colorPicker.select', {\n\t\t\t\t\t\t\t\t\tdefaultValue: 'Select {{color}}',\n\t\t\t\t\t\t\t\t\tcolor: preset,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\taria-pressed={color === preset}\n\t\t\t\t\t\t\t\ttitle={preset}\n\t\t\t\t\t\t\t\tstyle={{ backgroundColor: preset }}\n\t\t\t\t\t\t\t\tonClick={() => commit(selectionFromHex(preset))}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t</footer>\n\t\t</section>\n\t)\n}\n"],"names":["CENTER","RADIUS","CHANNELS","ringPoint","degrees","radius","radians","TICKS","_","index","major","start","end","selectionFromHex","color","hexToHsla","ColorPicker","value","defaultValue","onChange","className","t","useTranslation","STOA_NS","id","useId","external","normalizeColor","DEFAULT_COLOR","selection","setSelection","useState","previousExternal","setPreviousExternal","draft","setDraft","copyResult","setCopyResult","current","hsla","text","hue","indicator","title","commit","next","changeChannel","channel","amount","hslaToHex","pointToHue","event","bounds","x","y","finishEditing","copyColor","channelLabels","jsxs","cn","styles","jsx","line","discTextColor","PRESETS","preset"],"mappings":";;;;;;;AA0BA,MAAMA,IAAS,KACTC,IAAS,KACTC,IAAW,CAAC,KAAK,KAAK,GAAG;AAE/B,SAASC,EAAUC,GAAiBC,GAAgB;AACnD,QAAMC,KAAYF,IAAU,MAAM,KAAK,KAAM;AAC7C,SAAO;AAAA,IACN,GAAGJ,IAAS,KAAK,IAAIM,CAAO,IAAID;AAAA,IAChC,GAAGL,IAAS,KAAK,IAAIM,CAAO,IAAID;AAAA,EAAA;AAElC;AAEA,MAAME,IAAQ,MAAM,KAAK,EAAE,QAAQ,MAAM,CAACC,GAAGC,MAAU;AACtD,QAAML,IAAUK,IAAQ,GAClBC,IAAQN,IAAU,OAAO,GACzBO,IAAQR,EAAUC,GAASM,IAAQ,MAAM,GAAG,GAC5CE,IAAMT,EAAUC,GAAS,GAAG;AAClC,SAAO,EAAE,SAAAA,GAAS,OAAAM,GAAO,IAAIC,EAAM,GAAG,IAAIA,EAAM,GAAG,IAAIC,EAAI,GAAG,IAAIA,EAAI,EAAA;AACvE,CAAC;AAED,SAASC,EAAiBC,GAAe;AACxC,SAAO,EAAE,OAAAA,GAAO,MAAMC,EA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;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h } from "react";
|
|
3
|
+
import { useTranslation as v } from "react-i18next";
|
|
4
|
+
import { STOA_NS as C } from "../../i18n/namespace.js";
|
|
5
|
+
import { Button as g } from "../button/index.js";
|
|
6
|
+
import { ColorPicker as b } from "../color-picker/index.js";
|
|
7
|
+
import { DEFAULT_COLOR as a, normalizeColor as l } from "../color-picker/color.js";
|
|
8
|
+
import { Popover as P, PopoverTrigger as x, PopoverContent as k } from "../popover/index.js";
|
|
9
|
+
function A({
|
|
10
|
+
value: e,
|
|
11
|
+
defaultValue: s,
|
|
12
|
+
onChange: c,
|
|
13
|
+
className: m,
|
|
14
|
+
label: d,
|
|
15
|
+
disabled: p
|
|
16
|
+
}) {
|
|
17
|
+
const { t } = v(C), [f, u] = h(
|
|
18
|
+
() => l(s ?? "") ?? a
|
|
19
|
+
), r = e === void 0 ? f : l(e) ?? a;
|
|
20
|
+
return /* @__PURE__ */ n(P, { children: [
|
|
21
|
+
/* @__PURE__ */ o(x, { asChild: !0, children: /* @__PURE__ */ n(
|
|
22
|
+
g,
|
|
23
|
+
{
|
|
24
|
+
type: "button",
|
|
25
|
+
variant: "outline",
|
|
26
|
+
disabled: p,
|
|
27
|
+
className: m,
|
|
28
|
+
"aria-label": `${d ?? t("colorPicker.choose", "Choose color")}: ${r}`,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ o(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
"aria-hidden": "true",
|
|
34
|
+
className: "size-5 rounded-full border border-current/25",
|
|
35
|
+
style: { backgroundColor: r }
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ o("span", { className: "font-mono", children: r })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
) }),
|
|
42
|
+
/* @__PURE__ */ o(
|
|
43
|
+
k,
|
|
44
|
+
{
|
|
45
|
+
align: "start",
|
|
46
|
+
sideOffset: 8,
|
|
47
|
+
collisionPadding: 12,
|
|
48
|
+
"aria-label": t("colorPicker.title", "Color instrument"),
|
|
49
|
+
className: "max-h-(--radix-popover-content-available-height) w-[27.5rem] max-w-(--radix-popover-content-available-width) overflow-y-auto overscroll-contain rounded-[1.375rem] p-0",
|
|
50
|
+
children: /* @__PURE__ */ o(
|
|
51
|
+
b,
|
|
52
|
+
{
|
|
53
|
+
value: r,
|
|
54
|
+
onChange: (i) => {
|
|
55
|
+
e === void 0 && u(i), c?.(i);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
A as ColorPickerToggle
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/ui/color-picker-toggle/index.tsx"],"sourcesContent":["'use client'\n\nimport { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../button'\nimport { ColorPicker, type ColorPickerProps } from '../color-picker'\nimport { DEFAULT_COLOR, normalizeColor } from '../color-picker/color'\nimport { Popover, PopoverContent, PopoverTrigger } from '../popover'\n\nexport interface ColorPickerToggleProps extends ColorPickerProps {\n\t/** Accessible name for the trigger. */\n\tlabel?: string\n\tdisabled?: boolean\n}\n\nexport function ColorPickerToggle({\n\tvalue,\n\tdefaultValue,\n\tonChange,\n\tclassName,\n\tlabel,\n\tdisabled,\n}: ColorPickerToggleProps) {\n\tconst { t } = useTranslation(STOA_NS)\n\tconst [internal, setInternal] = useState(\n\t\t() => normalizeColor(defaultValue ?? '') ?? DEFAULT_COLOR,\n\t)\n\tconst color =\n\t\tvalue === undefined ? internal : (normalizeColor(value) ?? DEFAULT_COLOR)\n\n\treturn (\n\t\t<Popover>\n\t\t\t<PopoverTrigger asChild>\n\t\t\t\t<Button\n\t\t\t\t\ttype='button'\n\t\t\t\t\tvariant='outline'\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tclassName={className}\n\t\t\t\t\taria-label={`${label ?? t('colorPicker.choose', 'Choose color')}: ${color}`}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden='true'\n\t\t\t\t\t\tclassName='size-5 rounded-full border border-current/25'\n\t\t\t\t\t\tstyle={{ backgroundColor: color }}\n\t\t\t\t\t/>\n\t\t\t\t\t<span className='font-mono'>{color}</span>\n\t\t\t\t</Button>\n\t\t\t</PopoverTrigger>\n\t\t\t<PopoverContent\n\t\t\t\talign='start'\n\t\t\t\tsideOffset={8}\n\t\t\t\tcollisionPadding={12}\n\t\t\t\taria-label={t('colorPicker.title', 'Color instrument')}\n\t\t\t\tclassName='max-h-(--radix-popover-content-available-height) w-[27.5rem] max-w-(--radix-popover-content-available-width) overflow-y-auto overscroll-contain rounded-[1.375rem] p-0'\n\t\t\t>\n\t\t\t\t<ColorPicker\n\t\t\t\t\tvalue={color}\n\t\t\t\t\tonChange={(next) => {\n\t\t\t\t\t\tif (value === undefined) setInternal(next)\n\t\t\t\t\t\tonChange?.(next)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t)\n}\n"],"names":["ColorPickerToggle","value","defaultValue","onChange","className","label","disabled","useTranslation","STOA_NS","internal","setInternal","useState","normalizeColor","DEFAULT_COLOR","color","Popover","jsx","PopoverTrigger","jsxs","Button","PopoverContent","ColorPicker","next"],"mappings":";;;;;;;;AAgBO,SAASA,EAAkB;AAAA,EACjC,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AACD,GAA2B;AAC1B,QAAM,EAAE,EAAA,IAAMC,EAAeC,CAAO,GAC9B,CAACC,GAAUC,C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