@stoa-dev/kit 1.0.2 → 1.1.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/display/BarChart/index.js +147 -31
  3. package/dist/display/BarChart/index.js.map +1 -1
  4. package/dist/i18n/locales/at.json.js +16 -14
  5. package/dist/i18n/locales/at.json.js.map +1 -1
  6. package/dist/i18n/locales/de.json.js +16 -14
  7. package/dist/i18n/locales/de.json.js.map +1 -1
  8. package/dist/i18n/locales/en.json.js +12 -10
  9. package/dist/i18n/locales/en.json.js.map +1 -1
  10. package/dist/i18n/locales/it.json.js +16 -14
  11. package/dist/i18n/locales/it.json.js.map +1 -1
  12. package/dist/kit.css +1 -1
  13. package/dist/shell/BackButton/index.js +1 -1
  14. package/dist/shell/BackButton/index.js.map +1 -1
  15. package/dist/types/display/BarChart/index.d.ts +26 -2
  16. package/dist/types/display/BarChart/index.d.ts.map +1 -1
  17. package/dist/types/i18n/index.d.ts +56 -0
  18. package/dist/types/i18n/index.d.ts.map +1 -1
  19. package/dist/types/ui/color-picker/color.d.ts +13 -0
  20. package/dist/types/ui/color-picker/color.d.ts.map +1 -0
  21. package/dist/types/ui/color-picker/index.d.ts +10 -0
  22. package/dist/types/ui/color-picker/index.d.ts.map +1 -0
  23. package/dist/types/ui/color-picker-toggle/index.d.ts +8 -0
  24. package/dist/types/ui/color-picker-toggle/index.d.ts.map +1 -0
  25. package/dist/types/ui/index.d.ts +2 -0
  26. package/dist/types/ui/index.d.ts.map +1 -1
  27. package/dist/ui/color-picker/ColorPicker.module.scss.js +42 -0
  28. package/dist/ui/color-picker/ColorPicker.module.scss.js.map +1 -0
  29. package/dist/ui/color-picker/color.js +60 -0
  30. package/dist/ui/color-picker/color.js.map +1 -0
  31. package/dist/ui/color-picker/index.js +239 -0
  32. package/dist/ui/color-picker/index.js.map +1 -0
  33. package/dist/ui/color-picker-toggle/index.js +66 -0
  34. package/dist/ui/color-picker-toggle/index.js.map +1 -0
  35. package/dist/ui/index.js +105 -101
  36. package/dist/ui/index.js.map +1 -1
  37. package/package.json +1 -1
package/dist/kit.css CHANGED
@@ -1 +1 @@
1
- .stoa-ThemeSwitch-track-1bx4{--thumb-size: 2.125rem;--track-inset: .25rem;position:relative;display:inline-grid;flex-shrink:0;grid-template-rows:var(--thumb-size);grid-template-columns:repeat(2,var(--thumb-size));gap:var(--track-inset);place-items:center;padding:var(--track-inset);border:1px solid var(--input);border-radius:999px;background:color-mix(in srgb,var(--muted) 65%,var(--card));color:var(--muted-foreground);cursor:pointer;transition:border-color .18s ease}.stoa-ThemeSwitch-track-1bx4:hover:not(:disabled){border-color:var(--muted-foreground)}.stoa-ThemeSwitch-track-1bx4:focus-visible{outline:2px solid var(--foreground);outline-offset:3px}.stoa-ThemeSwitch-track-1bx4:disabled{cursor:not-allowed;opacity:.5}.stoa-ThemeSwitch-thumb-1bwy{position:absolute;inset-block-start:var(--track-inset);inset-inline-start:var(--track-inset);inline-size:var(--thumb-size);block-size:var(--thumb-size);border:1px solid color-mix(in srgb,var(--accent) 45%,var(--input));border-radius:50%;background:var(--card) linear-gradient(145deg,color-mix(in srgb,var(--accent) 16%,var(--card)),var(--card));box-shadow:0 1px 3px #00000029;transition:inset-inline-start .24s cubic-bezier(.2,.75,.25,1)}.stoa-ThemeSwitch-track-1bx4[data-state=checked] .stoa-ThemeSwitch-thumb-1bwy{inset-inline-start:calc(var(--thumb-size) + 2 * var(--track-inset))}.stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-moon-czyl{position:relative;inline-size:1rem;block-size:1rem;pointer-events:none;transition:color .18s ease,scale .24s ease}.stoa-ThemeSwitch-track-1bx4[data-state=unchecked] .stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-track-1bx4[data-state=checked] .stoa-ThemeSwitch-moon-czyl{color:var(--foreground);scale:1.125}@media(forced-colors:active){.stoa-ThemeSwitch-thumb-1bwy{border:2px solid Highlight}}@media(prefers-reduced-motion:reduce){.stoa-ThemeSwitch-track-1bx4,.stoa-ThemeSwitch-thumb-1bwy,.stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-moon-czyl{transition:none}}.stoa-AppNavigation-root-12db{position:fixed;inset-block:.75rem;inset-inline-start:.75rem;z-index:40;display:flex;flex-direction:column;align-items:center;gap:.75rem;width:4rem;padding-block:1.25rem;border-radius:1rem;background:color-mix(in srgb,var(--card) 95%,transparent);box-shadow:var(--surface-shadow)}.stoa-AppNavigation-logo-12d7{width:2.25rem;height:2.25rem;margin-bottom:.75rem;border-radius:.5rem}.stoa-AppNavigation-divider-1ctl{width:1.5rem;margin-block:.5rem;border-top:1px solid var(--border)}.stoa-AppNavigation-spacer-8ruf{flex:1}.stoa-AppNavigation-menuButton-1gqk{position:relative}.stoa-AppNavigation-menuButton-1gqk[aria-current=page]{background:var(--accent-wash);color:var(--foreground)}.stoa-AppNavigation-menuButton-1gqk[aria-current=page]:before{content:"";position:absolute;left:-9px;width:3px;height:16px;border-radius:2px;background:var(--accent)}.stoa-AppNavigation-menuButton-1gqk svg{stroke:currentColor}@media(prefers-reduced-motion:reduce){.stoa-AppNavigation-menuButton-1gqk{transition:none}}.stoa-BrandLines-brand-lines-dcsr{display:inline-flex;flex:none;flex-direction:column;align-items:flex-start;gap:4px;width:20px;color:var(--accent)}.stoa-BrandLines-brand-lines-dcsr>i{display:block;width:100%;height:2px;border-radius:2px;background:currentColor}.stoa-BrandLines-brand-lines-dcsr>i:nth-child(2){width:75%}.stoa-BrandLines-brand-lines-dcsr>i:nth-child(3){width:50%}.stoa-BrandLines-brand-lines-loading-1z0s>i{transform-origin:left;animation:stoa-BrandLines-brand-line-pulse-7z2o 1.1s ease-in-out infinite alternate}.stoa-BrandLines-brand-lines-loading-1z0s>i:nth-child(2){animation-delay:.15s}.stoa-BrandLines-brand-lines-loading-1z0s>i:nth-child(3){animation-delay:.3s}@keyframes stoa-BrandLines-brand-line-pulse-7z2o{0%{opacity:.35;transform:scaleX(.55)}to{opacity:1;transform:scaleX(1)}}@media(prefers-reduced-motion:reduce){.stoa-BrandLines-brand-lines-loading-1z0s>i{animation:none}}.stoa-PageHeading-page-heading-lq8m{display:flex;align-items:center;gap:.875rem;min-width:0;margin-block:.25rem .5rem;font-size:clamp(1.75rem,2.4vw,2.5rem);line-height:1.15;letter-spacing:-.045em;font-weight:650;overflow-wrap:anywhere}
1
+ .stoa-ColorPicker-picker-m4d3{--picker-surface: color-mix(in srgb, var(--card) 68%, var(--muted));--picker-line: color-mix(in srgb, currentColor 25%, transparent);--picker-padding: clamp(1rem, 5vw, 1.8125rem);width:min(100%,27.5rem);box-sizing:border-box;padding:var(--picker-padding);border-radius:1.375rem;background:var(--picker-surface);color:var(--card-foreground);font-family:var(--font-mono, "Mona Sans Mono", ui-monospace, monospace);box-shadow:var(--surface-shadow)}.stoa-ColorPicker-picker-m4d3 button:focus-visible,.stoa-ColorPicker-picker-m4d3 input:focus-visible{outline:2px solid currentColor;outline-offset:3px}.stoa-ColorPicker-header-i9ri{padding-bottom:1.25rem;border-bottom:1px solid var(--picker-line)}.stoa-ColorPicker-wheel-nqe9{position:relative;width:min(100%,21.25rem);margin:.875rem auto .375rem}.stoa-ColorPicker-wheel-nqe9 svg{display:block;width:100%;aspect-ratio:1}.stoa-ColorPicker-wheel-nqe9:has(.stoa-ColorPicker-hue-input-50uw:focus-visible) .stoa-ColorPicker-indicator-3hrr{stroke-width:3}.stoa-ColorPicker-track-nox6,.stoa-ColorPicker-inner-track-gnno{fill:none;stroke:var(--picker-line);stroke-width:.7}.stoa-ColorPicker-tick-wuc0{stroke:currentColor;stroke-opacity:.4;stroke-width:.8}.stoa-ColorPicker-major-tick-6mya{stroke:currentColor;stroke-opacity:.75;stroke-width:1.5}.stoa-ColorPicker-indicator-3hrr{fill:var(--picker-surface);stroke:currentColor;stroke-width:1.5}.stoa-ColorPicker-hue-ring-10ts{fill:none;stroke:transparent;stroke-width:32;pointer-events:stroke;touch-action:none;cursor:grab}.stoa-ColorPicker-hue-ring-10ts:active{cursor:grabbing}.stoa-ColorPicker-hue-input-50uw{position:absolute;top:0;left:50%;width:1px;height:1px;clip-path:inset(50%);pointer-events:none}.stoa-ColorPicker-center-fws1{position:absolute;inset:0;display:grid;align-content:center;justify-items:center;gap:.375rem;line-height:1.2;pointer-events:none}.stoa-ColorPicker-center-fws1 strong{font-size:clamp(1.125rem,6vw,2.25rem);font-weight:400;letter-spacing:-.06em}.stoa-ColorPicker-caption-1t6d,.stoa-ColorPicker-center-fws1 span,.stoa-ColorPicker-control-qt49 label{font-size:.6875rem;letter-spacing:.09em;text-transform:uppercase}.stoa-ColorPicker-caption-1t6d{color:var(--muted-foreground)}.stoa-ColorPicker-readout-2vje{margin-bottom:1.25rem}.stoa-ColorPicker-readout-2vje [role=status]{display:block;min-height:1rem;line-height:1rem}.stoa-ColorPicker-hex-row-1xik{display:flex;align-items:center;gap:.625rem;margin-block:.375rem}.stoa-ColorPicker-hex-row-1xik input{width:100%;min-width:0;padding-block:.375rem;border-bottom:1px solid var(--picker-line);background:transparent;font-size:1.375rem;letter-spacing:-.04em}.stoa-ColorPicker-hex-row-1xik button{flex-shrink:0;padding:.375rem .625rem;border:1px solid var(--picker-line);border-radius:999px;font-size:.6875rem;text-transform:uppercase;white-space:nowrap;cursor:pointer}.stoa-ColorPicker-hex-row-1xik button:hover{border-color:currentColor}.stoa-ColorPicker-controls-n32o{display:grid;gap:.875rem;padding-top:1rem;border-top:1px solid var(--picker-line)}.stoa-ColorPicker-control-qt49{display:grid;grid-template-columns:1fr auto;align-items:center;gap:.125rem .5rem}.stoa-ColorPicker-control-qt49 span{font-size:.875rem}.stoa-ColorPicker-control-qt49 input{grid-column:1/-1;appearance:none;width:100%;height:1.5rem;margin:0;background:linear-gradient(to right,currentColor var(--progress),var(--picker-line) var(--progress)) center/100% 2px no-repeat;cursor:pointer}.stoa-ColorPicker-control-qt49 input::-webkit-slider-thumb{appearance:none;box-sizing:border-box;width:.9375rem;height:.9375rem;border:3px solid var(--picker-surface);border-radius:50%;background:currentColor;box-shadow:0 0 0 1px currentColor}.stoa-ColorPicker-control-qt49 input::-moz-range-thumb{box-sizing:border-box;width:.9375rem;height:.9375rem;border:3px solid var(--picker-surface);border-radius:50%;background:currentColor;box-shadow:0 0 0 1px currentColor}.stoa-ColorPicker-footer-hhfh{margin-top:1.25rem;padding-top:1rem;border-top:1px solid var(--picker-line)}.stoa-ColorPicker-swatches-r9ha{display:flex;flex-wrap:wrap;gap:.6875rem;margin-top:.625rem}.stoa-ColorPicker-swatches-r9ha button{width:1.6875rem;height:1.6875rem;border:2px solid var(--picker-surface);border-radius:50%;box-shadow:0 0 0 1px var(--picker-line);cursor:pointer}.stoa-ColorPicker-swatches-r9ha button[aria-pressed=true],.stoa-ColorPicker-swatches-r9ha button:hover{box-shadow:0 0 0 2px currentColor}.stoa-ThemeSwitch-track-1bx4{--thumb-size: 2.125rem;--track-inset: .25rem;position:relative;display:inline-grid;flex-shrink:0;grid-template-rows:var(--thumb-size);grid-template-columns:repeat(2,var(--thumb-size));gap:var(--track-inset);place-items:center;padding:var(--track-inset);border:1px solid var(--input);border-radius:999px;background:color-mix(in srgb,var(--muted) 65%,var(--card));color:var(--muted-foreground);cursor:pointer;transition:border-color .18s ease}.stoa-ThemeSwitch-track-1bx4:hover:not(:disabled){border-color:var(--muted-foreground)}.stoa-ThemeSwitch-track-1bx4:focus-visible{outline:2px solid var(--foreground);outline-offset:3px}.stoa-ThemeSwitch-track-1bx4:disabled{cursor:not-allowed;opacity:.5}.stoa-ThemeSwitch-thumb-1bwy{position:absolute;inset-block-start:var(--track-inset);inset-inline-start:var(--track-inset);inline-size:var(--thumb-size);block-size:var(--thumb-size);border:1px solid color-mix(in srgb,var(--accent) 45%,var(--input));border-radius:50%;background:var(--card) linear-gradient(145deg,color-mix(in srgb,var(--accent) 16%,var(--card)),var(--card));box-shadow:0 1px 3px #00000029;transition:inset-inline-start .24s cubic-bezier(.2,.75,.25,1)}.stoa-ThemeSwitch-track-1bx4[data-state=checked] .stoa-ThemeSwitch-thumb-1bwy{inset-inline-start:calc(var(--thumb-size) + 2 * var(--track-inset))}.stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-moon-czyl{position:relative;inline-size:1rem;block-size:1rem;pointer-events:none;transition:color .18s ease,scale .24s ease}.stoa-ThemeSwitch-track-1bx4[data-state=unchecked] .stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-track-1bx4[data-state=checked] .stoa-ThemeSwitch-moon-czyl{color:var(--foreground);scale:1.125}@media(forced-colors:active){.stoa-ThemeSwitch-thumb-1bwy{border:2px solid Highlight}}@media(prefers-reduced-motion:reduce){.stoa-ThemeSwitch-track-1bx4,.stoa-ThemeSwitch-thumb-1bwy,.stoa-ThemeSwitch-sun-1skq,.stoa-ThemeSwitch-moon-czyl{transition:none}}.stoa-AppNavigation-root-12db{position:fixed;inset-block:.75rem;inset-inline-start:.75rem;z-index:40;display:flex;flex-direction:column;align-items:center;gap:.75rem;width:4rem;padding-block:1.25rem;border-radius:1rem;background:color-mix(in srgb,var(--card) 95%,transparent);box-shadow:var(--surface-shadow)}.stoa-AppNavigation-logo-12d7{width:2.25rem;height:2.25rem;margin-bottom:.75rem;border-radius:.5rem}.stoa-AppNavigation-divider-1ctl{width:1.5rem;margin-block:.5rem;border-top:1px solid var(--border)}.stoa-AppNavigation-spacer-8ruf{flex:1}.stoa-AppNavigation-menuButton-1gqk{position:relative}.stoa-AppNavigation-menuButton-1gqk[aria-current=page]{background:var(--accent-wash);color:var(--foreground)}.stoa-AppNavigation-menuButton-1gqk[aria-current=page]:before{content:"";position:absolute;left:-9px;width:3px;height:16px;border-radius:2px;background:var(--accent)}.stoa-AppNavigation-menuButton-1gqk svg{stroke:currentColor}@media(prefers-reduced-motion:reduce){.stoa-AppNavigation-menuButton-1gqk{transition:none}}.stoa-BrandLines-brand-lines-dcsr{display:inline-flex;flex:none;flex-direction:column;align-items:flex-start;gap:4px;width:20px;color:var(--accent)}.stoa-BrandLines-brand-lines-dcsr>i{display:block;width:100%;height:2px;border-radius:2px;background:currentColor}.stoa-BrandLines-brand-lines-dcsr>i:nth-child(2){width:75%}.stoa-BrandLines-brand-lines-dcsr>i:nth-child(3){width:50%}.stoa-BrandLines-brand-lines-loading-1z0s>i{transform-origin:left;animation:stoa-BrandLines-brand-line-pulse-7z2o 1.1s ease-in-out infinite alternate}.stoa-BrandLines-brand-lines-loading-1z0s>i:nth-child(2){animation-delay:.15s}.stoa-BrandLines-brand-lines-loading-1z0s>i:nth-child(3){animation-delay:.3s}@keyframes stoa-BrandLines-brand-line-pulse-7z2o{0%{opacity:.35;transform:scaleX(.55)}to{opacity:1;transform:scaleX(1)}}@media(prefers-reduced-motion:reduce){.stoa-BrandLines-brand-lines-loading-1z0s>i{animation:none}}.stoa-PageHeading-page-heading-lq8m{display:flex;align-items:center;gap:.875rem;min-width:0;margin-block:.25rem .5rem;font-size:clamp(1.75rem,2.4vw,2.5rem);line-height:1.15;letter-spacing:-.045em;font-weight:650;overflow-wrap:anywhere}
@@ -13,7 +13,7 @@ function h({ strict: t = !1, to: r = "/", label: i }) {
13
13
  variant: "ghost",
14
14
  size: "icon",
15
15
  "aria-label": i ?? e("app.back"),
16
- onClick: () => t ? a(-1) : n,
16
+ onClick: () => t ? a(-1) : n(),
17
17
  children: /* @__PURE__ */ o(m, {})
18
18
  }
19
19
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/shell/BackButton/index.tsx"],"sourcesContent":["import { ArrowLeft } from 'lucide-react'\nimport { useTranslation } from 'react-i18next'\nimport { useNavigate } from 'react-router'\nimport { useRouting } from '../../hooks/useRouting'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\n\nexport interface BackButtonProps {\n\t/** Route to return to. Defaults to `/`. */\n\tstrict?: boolean\n\tto?: string\n\tlabel?: string\n}\n\nexport function BackButton({ strict = false, to = '/', label }: BackButtonProps) {\n\tconst navigate = useNavigate()\n\tconst { routeToDefault } = useRouting(to)\n\tconst { t } = useTranslation(STOA_NS)\n\n\treturn (\n\t\t<Button\n\t\t\tvariant='ghost'\n\t\t\tsize='icon'\n\t\t\taria-label={label ?? t('app.back')}\n\t\t\tonClick={() => strict ? navigate(-1) : routeToDefault}\n\t\t>\n\t\t\t<ArrowLeft />\n\t\t</Button>\n\t)\n}\n"],"names":["BackButton","strict","to","label","navigate","useNavigate","routeToDefault","useRouting","t","useTranslation","STOA_NS","jsx","Button","ArrowLeft"],"mappings":";;;;;;;AAcO,SAASA,EAAW,EAAE,QAAAC,IAAS,IAAO,IAAAC,IAAK,KAAK,OAAAC,KAA0B;AAChF,QAAMC,IAAWC,EAAA,GACX,EAAE,gBAAAC,EAAA,IAAmBC,EAAWL,CAAE,GAClC,EAAE,GAAAM,EAAA,IAAMC,EAAeC,CAAO;AAEpC,SACC,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,cAAYT,KAASK,EAAE,UAAU;AAAA,MACjC,SAAS,MAAMP,IAASG,EAAS,EAAE,IAAIE;AAAA,MAEvC,4BAACO,GAAA,CAAA,CAAU;AAAA,IAAA;AAAA,EAAA;AAGd;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/shell/BackButton/index.tsx"],"sourcesContent":["import { ArrowLeft } from 'lucide-react'\nimport { useTranslation } from 'react-i18next'\nimport { useNavigate } from 'react-router'\nimport { useRouting } from '../../hooks/useRouting'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\n\nexport interface BackButtonProps {\n\t/** Route to return to. Defaults to `/`. */\n\tstrict?: boolean\n\tto?: string\n\tlabel?: string\n}\n\nexport function BackButton({ strict = false, to = '/', label }: BackButtonProps) {\n\tconst navigate = useNavigate()\n\tconst { routeToDefault } = useRouting(to)\n\tconst { t } = useTranslation(STOA_NS)\n\n\treturn (\n\t\t<Button\n\t\t\tvariant='ghost'\n\t\t\tsize='icon'\n\t\t\taria-label={label ?? t('app.back')}\n\t\t\tonClick={() => strict ? navigate(-1) : routeToDefault()}\n\t\t>\n\t\t\t<ArrowLeft />\n\t\t</Button>\n\t)\n}\n"],"names":["BackButton","strict","to","label","navigate","useNavigate","routeToDefault","useRouting","t","useTranslation","STOA_NS","jsx","Button","ArrowLeft"],"mappings":";;;;;;;AAcO,SAASA,EAAW,EAAE,QAAAC,IAAS,IAAO,IAAAC,IAAK,KAAK,OAAAC,KAA0B;AAChF,QAAMC,IAAWC,EAAA,GACX,EAAE,gBAAAC,EAAA,IAAmBC,EAAWL,CAAE,GAClC,EAAE,GAAAM,EAAA,IAAMC,EAAeC,CAAO;AAEpC,SACC,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,cAAYT,KAASK,EAAE,UAAU;AAAA,MACjC,SAAS,MAAMP,IAASG,EAAS,EAAE,IAAIE,EAAA;AAAA,MAEvC,4BAACO,GAAA,CAAA,CAAU;AAAA,IAAA;AAAA,EAAA;AAGd;"}
@@ -6,6 +6,28 @@ export interface BarChartItemProps {
6
6
  /** Text for the figure; defaults to the value. */
7
7
  display?: ReactNode;
8
8
  }
9
+ export interface BarChartSegment {
10
+ /** Unique within the item. */
11
+ id: string;
12
+ label: string;
13
+ value: number;
14
+ /** Theme classes that color the segment. */
15
+ className?: string;
16
+ }
17
+ export interface BarChartStackedItemProps {
18
+ /** Presentational content for the visible category label. */
19
+ label: ReactNode;
20
+ /** Presentational override for the visible total. */
21
+ display?: ReactNode;
22
+ segments: readonly BarChartSegment[];
23
+ value?: never;
24
+ totalLabel: string;
25
+ /** Full category name for the trigger and details, e.g. November 2026. */
26
+ detailLabel?: string;
27
+ }
28
+ type ItemProps = (BarChartItemProps & {
29
+ segments?: never;
30
+ }) | BarChartStackedItemProps;
9
31
  export interface BarChartProps {
10
32
  children: ReactNode;
11
33
  variant?: Variant;
@@ -14,12 +36,14 @@ export interface BarChartProps {
14
36
  /** Accessible name of the chart. */
15
37
  label?: string;
16
38
  className?: string;
39
+ /** Formats visible figures, accessible totals and segment details. */
40
+ formatValue?: (value: number) => string;
17
41
  }
18
42
  /**
19
43
  * Bars as firm rounded strokes. `vertical`: columns with figure and label
20
44
  * below; `horizontal`: rows with label, bar and figure.
21
45
  */
22
- export declare function BarChart({ children, variant, max, label, className, }: BarChartProps): import("react").JSX.Element;
23
- export declare function BarChartItem({ label, value, display }: BarChartItemProps): import("react").JSX.Element;
46
+ export declare function BarChart({ children, variant, max, label, className, formatValue, }: BarChartProps): import("react").JSX.Element;
47
+ export declare function BarChartItem(props: ItemProps): import("react").JSX.Element;
24
48
  export {};
25
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/display/BarChart/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,SAAS,EAEd,MAAM,OAAO,CAAA;AAGd,KAAK,OAAO,GAAG,UAAU,GAAG,YAAY,CAAA;AAOxC,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAQD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACxB,QAAQ,EACR,OAAoB,EACpB,GAAG,EACH,KAAK,EACL,SAAS,GACT,EAAE,aAAa,+BAoBf;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,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CAAA;CACvC;AAqBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACxB,QAAQ,EACR,OAAoB,EACpB,GAAG,EACH,KAAK,EACL,SAAS,EACT,WAAW,GACX,EAAE,aAAa,+BAuBf;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,+BAG5C"}
@@ -19,6 +19,20 @@ export declare const stoaResources: {
19
19
  switchTheme: string;
20
20
  loadingSettings: string;
21
21
  };
22
+ colorPicker: {
23
+ title: string;
24
+ choose: string;
25
+ hue: string;
26
+ saturation: string;
27
+ lightness: string;
28
+ opacity: string;
29
+ hex: string;
30
+ copy: string;
31
+ copied: string;
32
+ copyFailed: string;
33
+ presets: string;
34
+ select: string;
35
+ };
22
36
  datePicker: {
23
37
  selectDate: string;
24
38
  today: string;
@@ -180,6 +194,20 @@ export declare const stoaResources: {
180
194
  switchTheme: string;
181
195
  loadingSettings: string;
182
196
  };
197
+ colorPicker: {
198
+ title: string;
199
+ choose: string;
200
+ hue: string;
201
+ saturation: string;
202
+ lightness: string;
203
+ opacity: string;
204
+ hex: string;
205
+ copy: string;
206
+ copied: string;
207
+ copyFailed: string;
208
+ presets: string;
209
+ select: string;
210
+ };
183
211
  datePicker: {
184
212
  selectDate: string;
185
213
  today: string;
@@ -341,6 +369,20 @@ export declare const stoaResources: {
341
369
  switchTheme: string;
342
370
  loadingSettings: string;
343
371
  };
372
+ colorPicker: {
373
+ title: string;
374
+ choose: string;
375
+ hue: string;
376
+ saturation: string;
377
+ lightness: string;
378
+ opacity: string;
379
+ hex: string;
380
+ copy: string;
381
+ copied: string;
382
+ copyFailed: string;
383
+ presets: string;
384
+ select: string;
385
+ };
344
386
  datePicker: {
345
387
  selectDate: string;
346
388
  today: string;
@@ -502,6 +544,20 @@ export declare const stoaResources: {
502
544
  switchTheme: string;
503
545
  loadingSettings: string;
504
546
  };
547
+ colorPicker: {
548
+ title: string;
549
+ choose: string;
550
+ hue: string;
551
+ saturation: string;
552
+ lightness: string;
553
+ opacity: string;
554
+ hex: string;
555
+ copy: string;
556
+ copied: string;
557
+ copyFailed: string;
558
+ presets: string;
559
+ select: string;
560
+ };
505
561
  datePicker: {
506
562
  selectDate: string;
507
563
  today: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,SAAS,CAAA;AAK3C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKhB,CAAA;AAEV,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAKrB,CAAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKhB,CAAA;AAEV,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAKrB,CAAA;AAEV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAE5E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,EACV,SAAS,GAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAM,QAQ3E"}
@@ -0,0 +1,13 @@
1
+ export declare const DEFAULT_COLOR = "#FF607F";
2
+ export declare const PRESETS: string[];
3
+ export type Hsla = {
4
+ h: number;
5
+ s: number;
6
+ l: number;
7
+ a: number;
8
+ };
9
+ export declare function normalizeColor(value: string): string | null;
10
+ export declare function hexToHsla(hex: string): Hsla;
11
+ export declare function hslaToHex({ h, s, l, a }: Hsla): string;
12
+ export declare function discTextColor(hex: string, alpha: number): "#000" | "#fff";
13
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../src/ui/color-picker/color.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,YAAY,CAAA;AACtC,eAAO,MAAM,OAAO,UASnB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,iBAO3C;AAMD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAqB3C;AAED,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,UAoB7C;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,mBAQvD"}
@@ -0,0 +1,10 @@
1
+ export interface ColorPickerProps {
2
+ /** Displayed hex color. Omit to let the picker own the selection. */
3
+ value?: string;
4
+ defaultValue?: string;
5
+ /** Emits uppercase #RRGGBB or #RRGGBBAA. */
6
+ onChange?: (color: string) => void;
7
+ className?: string;
8
+ }
9
+ export declare function ColorPicker({ value, defaultValue, onChange, className, }: ColorPickerProps): import("react").JSX.Element;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/color-picker/index.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,gBAAgB;IAChC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AA0BD,wBAAgB,WAAW,CAAC,EAC3B,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,GACT,EAAE,gBAAgB,+BAiPlB"}
@@ -0,0 +1,8 @@
1
+ import { type ColorPickerProps } from '../color-picker';
2
+ export interface ColorPickerToggleProps extends ColorPickerProps {
3
+ /** Accessible name for the trigger. */
4
+ label?: string;
5
+ disabled?: boolean;
6
+ }
7
+ export declare function ColorPickerToggle({ value, defaultValue, onChange, className, label, disabled, }: ColorPickerToggleProps): import("react").JSX.Element;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/color-picker-toggle/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIpE,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC/D,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,EACjC,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,GACR,EAAE,sBAAsB,+BA2CxB"}
@@ -2,6 +2,8 @@ export * from './accordion';
2
2
  export * from './button';
3
3
  export * from './calendar';
4
4
  export * from './card';
5
+ export * from './color-picker';
6
+ export * from './color-picker-toggle';
5
7
  export * from './dialog';
6
8
  export * from './dropdown-menu';
7
9
  export * from './field';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}
@@ -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","l","sector","hslaToHex","h","s","lightness","chroma","channel","position","discTextColor","alpha"],"mappings":";AAEO,MAAMA,IAAgB,WAChBC,IAAU;AAAA,EACtBD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAIO,SAASE,EAAeC,GAAe;AAC7C,QAAMC,IAAMD,EAAM,KAAA,EAAO,QAAQ,MAAM,EAAE;AACzC,MAAI,gBAAgB,KAAKC,CAAG,GAAG;AAC9B,UAAMC,IAAY,IAAID,EAAI,YAAA,CAAa;AACvC,WAAOC,EAAU,SAAS,IAAI,IAAIA,EAAU,MAAM,GAAG,CAAC,IAAIA;AAAA,EAC3D;AACA,SAAOC,EAAcH,CAAK;AAC3B;AAEA,SAASI,EAAYH,GAAaI,GAAgB;AACjD,SAAO,OAAO,SAASJ,EAAI,MAAMI,GAAQA,IAAS,CAAC,GAAG,EAAE,IAAI;AAC7D;AAEO,SAASC,EAAUL,GAAmB;AAC5C,QAAMM,IAAIH,EAAYH,GAAK,CAAC,GACtBO,IAAIJ,EAAYH,GAAK,CAAC,GACtBQ,IAAIL,EAAYH,GAAK,CAAC,GACtBS,IAAIT,EAAI,WAAW,IAAIG,EAAYH,GAAK,CAAC,IAAI,GAC7CU,IAAM,KAAK,IAAIJ,GAAGC,GAAGC,CAAC,GACtBG,IAAM,KAAK,IAAIL,GAAGC,GAAGC,CAAC,GACtBI,IAAQF,IAAMC,GACdE,KAAKH,IAAMC,KAAO;AACxB,MAAIC,MAAU,EAAG,QAAO,EAAE,GAAG,GAAG,GAAG,GAAG,GAAGC,IAAI,KAAK,GAAAJ,EAAA;AAElD,MAAIK,KAAUR,IAAIC,KAAKK,IAAQ;AAC/B,SAAIF,MAAQJ,IAAGQ,KAAUP,IAAIC,KAAKI,IACzBF,MAAQH,MAAGO,KAAUN,IAAIF,KAAKM,IAAQ,IAExC;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runtime";
2
+ import { useId as K, useState as k } from "react";
3
+ 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