@apipass/design-system 5.1.0 → 5.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.
Files changed (42) hide show
  1. package/dist/lib/charts.index.cjs +1 -1
  2. package/dist/lib/charts.index.js +10 -4
  3. package/dist/lib/charts.index.js.map +1 -1
  4. package/dist/lib/embedded-styles.js +2 -2
  5. package/dist/lib/style.css +1 -1
  6. package/dist/lib/ui/components/charts/BarChart/BarChart.cjs +2 -0
  7. package/dist/lib/ui/components/charts/BarChart/BarChart.cjs.map +1 -0
  8. package/dist/lib/ui/components/charts/BarChart/BarChart.js +79 -0
  9. package/dist/lib/ui/components/charts/BarChart/BarChart.js.map +1 -0
  10. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs +2 -0
  11. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs.map +1 -0
  12. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js +166 -0
  13. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js.map +1 -0
  14. package/dist/lib/ui/components/charts/ChartColorPicker/ChartColorPicker.cjs +2 -0
  15. package/dist/lib/ui/components/charts/ChartColorPicker/ChartColorPicker.cjs.map +1 -0
  16. package/dist/lib/ui/components/charts/ChartColorPicker/ChartColorPicker.js +99 -0
  17. package/dist/lib/ui/components/charts/ChartColorPicker/ChartColorPicker.js.map +1 -0
  18. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.cjs +2 -0
  19. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.cjs.map +1 -0
  20. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.js +47 -0
  21. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.js.map +1 -0
  22. package/dist/lib/ui/components/charts/ChartLegend/use-chart-legend.cjs +2 -0
  23. package/dist/lib/ui/components/charts/ChartLegend/use-chart-legend.cjs.map +1 -0
  24. package/dist/lib/ui/components/charts/ChartLegend/use-chart-legend.js +34 -0
  25. package/dist/lib/ui/components/charts/ChartLegend/use-chart-legend.js.map +1 -0
  26. package/dist/lib/ui/components/charts/TimeSeriesChart/TimeSeriesChart.cjs +1 -1
  27. package/dist/lib/ui/components/charts/TimeSeriesChart/TimeSeriesChart.cjs.map +1 -1
  28. package/dist/lib/ui/components/charts/TimeSeriesChart/TimeSeriesChart.js +63 -45
  29. package/dist/lib/ui/components/charts/TimeSeriesChart/TimeSeriesChart.js.map +1 -1
  30. package/dist/lib/ui/components/charts/TimeSeriesChart/time-series-option.cjs +1 -1
  31. package/dist/lib/ui/components/charts/TimeSeriesChart/time-series-option.cjs.map +1 -1
  32. package/dist/lib/ui/components/charts/TimeSeriesChart/time-series-option.js +31 -41
  33. package/dist/lib/ui/components/charts/TimeSeriesChart/time-series-option.js.map +1 -1
  34. package/dist/types/charts.index.d.ts +3 -0
  35. package/dist/types/ui/components/charts/BarChart/BarChart.d.ts +18 -0
  36. package/dist/types/ui/components/charts/BarChart/bar-chart-option.d.ts +34 -0
  37. package/dist/types/ui/components/charts/ChartColorPicker/ChartColorPicker.d.ts +18 -0
  38. package/dist/types/ui/components/charts/ChartLegend/ChartLegend.d.ts +21 -0
  39. package/dist/types/ui/components/charts/ChartLegend/use-chart-legend.d.ts +14 -0
  40. package/dist/types/ui/components/charts/TimeSeriesChart/TimeSeriesChart.d.ts +4 -1
  41. package/dist/types/ui/components/charts/TimeSeriesChart/time-series-option.d.ts +0 -1
  42. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),d=require("../chart-palette.cjs");function T(t,r,u){const[s,S]=c.useState(()=>new Set),l=c.useCallback(e=>{S(n=>{const o=new Set(n);return o.has(e)?o.delete(e):o.add(e),o})},[]),h=c.useMemo(()=>{const e={};return t.forEach((n,o)=>{e[n.id]=n.colorToken??d.CHART_SERIES_COLOR_TOKENS[o%d.CHART_SERIES_COLOR_TOKENS.length]}),e},[t]),i=c.useMemo(()=>{const e={};return t.forEach((n,o)=>{const m=n.colorToken?u(n.colorToken):void 0;e[n.id]=m??r[o%r.length]}),e},[t,r,u]);return{items:c.useMemo(()=>t.map(e=>({id:e.id,name:e.name,color:i[e.id],isHidden:s.has(e.id)})),[t,i,s]),colorsBySeriesId:i,colorTokensBySeriesId:h,hiddenSeriesIds:s,toggleSeries:l}}exports.useChartLegend=T;
2
+ //# sourceMappingURL=use-chart-legend.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-chart-legend.cjs","sources":["../../../../../../src/ui/components/charts/ChartLegend/use-chart-legend.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport { CHART_SERIES_COLOR_TOKENS } from \"../chart-palette\";\nimport type { ChartLegendItem } from \"./ChartLegend\";\n\nexport interface ChartLegendSeries {\n id: string;\n name: string;\n colorToken?: string;\n}\n\nexport interface ChartLegendState {\n items: ChartLegendItem[];\n // Por id, e já resolvida: é o que o canvas recebe. Fica com todas as séries, e não só com as\n // visíveis, porque a cor de quem não escolheu token sai da posição — recalculá-la sobre a lista\n // filtrada faria esconder uma série repintar todas as que vêm depois dela.\n colorsBySeriesId: Record<string, string>;\n // O token por trás da cor: a escolhida, ou a que a paleta dá àquela posição. É o que o seletor\n // de cor recebe, porque token é o que se persiste.\n colorTokensBySeriesId: Record<string, string>;\n hiddenSeriesIds: Set<string>;\n toggleSeries: (seriesId: string) => void;\n}\n\nexport function useChartLegend(\n series: ChartLegendSeries[],\n paletteColors: string[],\n resolveSeriesColor: (token: string) => string | undefined,\n): ChartLegendState {\n const [hiddenSeriesIds, setHiddenSeriesIds] = useState<Set<string>>(() => new Set<string>());\n\n const toggleSeries = useCallback((seriesId: string): void => {\n setHiddenSeriesIds((current: Set<string>) => {\n const next: Set<string> = new Set(current);\n if (next.has(seriesId)) next.delete(seriesId);\n else next.add(seriesId);\n return next;\n });\n }, []);\n\n const colorTokensBySeriesId: Record<string, string> = useMemo(() => {\n const tokens: Record<string, string> = {};\n series.forEach((data: ChartLegendSeries, index: number) => {\n tokens[data.id] =\n data.colorToken ?? CHART_SERIES_COLOR_TOKENS[index % CHART_SERIES_COLOR_TOKENS.length];\n });\n return tokens;\n }, [series]);\n\n const colorsBySeriesId: Record<string, string> = useMemo(() => {\n const colors: Record<string, string> = {};\n series.forEach((data: ChartLegendSeries, index: number) => {\n const chosen: string | undefined = data.colorToken\n ? resolveSeriesColor(data.colorToken)\n : undefined;\n colors[data.id] = chosen ?? paletteColors[index % paletteColors.length];\n });\n return colors;\n }, [series, paletteColors, resolveSeriesColor]);\n\n // A legenda mostra a mesma cor resolvida que o canvas desenha, e não o token: é o que o seletor\n // de cor compara para marcar a amostra escolhida, e o que impede as duas metades da tela de\n // discordarem sobre a cor de uma série.\n const items: ChartLegendItem[] = useMemo(\n () =>\n series.map((data: ChartLegendSeries) => ({\n id: data.id,\n name: data.name,\n color: colorsBySeriesId[data.id],\n isHidden: hiddenSeriesIds.has(data.id),\n })),\n [series, colorsBySeriesId, hiddenSeriesIds],\n );\n\n return { items, colorsBySeriesId, colorTokensBySeriesId, hiddenSeriesIds, toggleSeries };\n}\n"],"names":["useChartLegend","series","paletteColors","resolveSeriesColor","hiddenSeriesIds","setHiddenSeriesIds","useState","toggleSeries","useCallback","seriesId","current","next","colorTokensBySeriesId","useMemo","tokens","data","index","CHART_SERIES_COLOR_TOKENS","colorsBySeriesId","colors","chosen"],"mappings":"2IAuBO,SAASA,EACdC,EACAC,EACAC,EACkB,CAClB,KAAM,CAACC,EAAiBC,CAAkB,EAAIC,EAAAA,SAAsB,IAAM,IAAI,GAAa,EAErFC,EAAeC,cAAaC,GAA2B,CAC3DJ,EAAoBK,GAAyB,CAC3C,MAAMC,EAAoB,IAAI,IAAID,CAAO,EACzC,OAAIC,EAAK,IAAIF,CAAQ,EAAGE,EAAK,OAAOF,CAAQ,EACvCE,EAAK,IAAIF,CAAQ,EACfE,CACT,CAAC,CACH,EAAG,CAAA,CAAE,EAECC,EAAgDC,EAAAA,QAAQ,IAAM,CAClE,MAAMC,EAAiC,CAAA,EACvC,OAAAb,EAAO,QAAQ,CAACc,EAAyBC,IAAkB,CACzDF,EAAOC,EAAK,EAAE,EACZA,EAAK,YAAcE,4BAA0BD,EAAQC,EAAAA,0BAA0B,MAAM,CACzF,CAAC,EACMH,CACT,EAAG,CAACb,CAAM,CAAC,EAELiB,EAA2CL,EAAAA,QAAQ,IAAM,CAC7D,MAAMM,EAAiC,CAAA,EACvC,OAAAlB,EAAO,QAAQ,CAACc,EAAyBC,IAAkB,CACzD,MAAMI,EAA6BL,EAAK,WACpCZ,EAAmBY,EAAK,UAAU,EAClC,OACJI,EAAOJ,EAAK,EAAE,EAAIK,GAAUlB,EAAcc,EAAQd,EAAc,MAAM,CACxE,CAAC,EACMiB,CACT,EAAG,CAAClB,EAAQC,EAAeC,CAAkB,CAAC,EAgB9C,MAAO,CAAE,MAXwBU,EAAAA,QAC/B,IACEZ,EAAO,IAAKc,IAA6B,CACvC,GAAIA,EAAK,GACT,KAAMA,EAAK,KACX,MAAOG,EAAiBH,EAAK,EAAE,EAC/B,SAAUX,EAAgB,IAAIW,EAAK,EAAE,CAAA,EACrC,EACJ,CAACd,EAAQiB,EAAkBd,CAAe,CAAA,EAG5B,iBAAAc,EAAkB,sBAAAN,EAAuB,gBAAAR,EAAiB,aAAAG,CAAA,CAC5E"}
@@ -0,0 +1,34 @@
1
+ import { useState as f, useCallback as k, useMemo as s } from "react";
2
+ import { CHART_SERIES_COLOR_TOKENS as m } from "../chart-palette.js";
3
+ function H(c, t, d) {
4
+ const [r, S] = f(() => /* @__PURE__ */ new Set()), h = k((o) => {
5
+ S((n) => {
6
+ const e = new Set(n);
7
+ return e.has(o) ? e.delete(o) : e.add(o), e;
8
+ });
9
+ }, []), u = s(() => {
10
+ const o = {};
11
+ return c.forEach((n, e) => {
12
+ o[n.id] = n.colorToken ?? m[e % m.length];
13
+ }), o;
14
+ }, [c]), i = s(() => {
15
+ const o = {};
16
+ return c.forEach((n, e) => {
17
+ const l = n.colorToken ? d(n.colorToken) : void 0;
18
+ o[n.id] = l ?? t[e % t.length];
19
+ }), o;
20
+ }, [c, t, d]);
21
+ return { items: s(
22
+ () => c.map((o) => ({
23
+ id: o.id,
24
+ name: o.name,
25
+ color: i[o.id],
26
+ isHidden: r.has(o.id)
27
+ })),
28
+ [c, i, r]
29
+ ), colorsBySeriesId: i, colorTokensBySeriesId: u, hiddenSeriesIds: r, toggleSeries: h };
30
+ }
31
+ export {
32
+ H as useChartLegend
33
+ };
34
+ //# sourceMappingURL=use-chart-legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-chart-legend.js","sources":["../../../../../../src/ui/components/charts/ChartLegend/use-chart-legend.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport { CHART_SERIES_COLOR_TOKENS } from \"../chart-palette\";\nimport type { ChartLegendItem } from \"./ChartLegend\";\n\nexport interface ChartLegendSeries {\n id: string;\n name: string;\n colorToken?: string;\n}\n\nexport interface ChartLegendState {\n items: ChartLegendItem[];\n // Por id, e já resolvida: é o que o canvas recebe. Fica com todas as séries, e não só com as\n // visíveis, porque a cor de quem não escolheu token sai da posição — recalculá-la sobre a lista\n // filtrada faria esconder uma série repintar todas as que vêm depois dela.\n colorsBySeriesId: Record<string, string>;\n // O token por trás da cor: a escolhida, ou a que a paleta dá àquela posição. É o que o seletor\n // de cor recebe, porque token é o que se persiste.\n colorTokensBySeriesId: Record<string, string>;\n hiddenSeriesIds: Set<string>;\n toggleSeries: (seriesId: string) => void;\n}\n\nexport function useChartLegend(\n series: ChartLegendSeries[],\n paletteColors: string[],\n resolveSeriesColor: (token: string) => string | undefined,\n): ChartLegendState {\n const [hiddenSeriesIds, setHiddenSeriesIds] = useState<Set<string>>(() => new Set<string>());\n\n const toggleSeries = useCallback((seriesId: string): void => {\n setHiddenSeriesIds((current: Set<string>) => {\n const next: Set<string> = new Set(current);\n if (next.has(seriesId)) next.delete(seriesId);\n else next.add(seriesId);\n return next;\n });\n }, []);\n\n const colorTokensBySeriesId: Record<string, string> = useMemo(() => {\n const tokens: Record<string, string> = {};\n series.forEach((data: ChartLegendSeries, index: number) => {\n tokens[data.id] =\n data.colorToken ?? CHART_SERIES_COLOR_TOKENS[index % CHART_SERIES_COLOR_TOKENS.length];\n });\n return tokens;\n }, [series]);\n\n const colorsBySeriesId: Record<string, string> = useMemo(() => {\n const colors: Record<string, string> = {};\n series.forEach((data: ChartLegendSeries, index: number) => {\n const chosen: string | undefined = data.colorToken\n ? resolveSeriesColor(data.colorToken)\n : undefined;\n colors[data.id] = chosen ?? paletteColors[index % paletteColors.length];\n });\n return colors;\n }, [series, paletteColors, resolveSeriesColor]);\n\n // A legenda mostra a mesma cor resolvida que o canvas desenha, e não o token: é o que o seletor\n // de cor compara para marcar a amostra escolhida, e o que impede as duas metades da tela de\n // discordarem sobre a cor de uma série.\n const items: ChartLegendItem[] = useMemo(\n () =>\n series.map((data: ChartLegendSeries) => ({\n id: data.id,\n name: data.name,\n color: colorsBySeriesId[data.id],\n isHidden: hiddenSeriesIds.has(data.id),\n })),\n [series, colorsBySeriesId, hiddenSeriesIds],\n );\n\n return { items, colorsBySeriesId, colorTokensBySeriesId, hiddenSeriesIds, toggleSeries };\n}\n"],"names":["useChartLegend","series","paletteColors","resolveSeriesColor","hiddenSeriesIds","setHiddenSeriesIds","useState","toggleSeries","useCallback","seriesId","current","next","colorTokensBySeriesId","useMemo","tokens","data","index","CHART_SERIES_COLOR_TOKENS","colorsBySeriesId","colors","chosen"],"mappings":";;AAuBO,SAASA,EACdC,GACAC,GACAC,GACkB;AAClB,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAAsB,MAAM,oBAAI,KAAa,GAErFC,IAAeC,EAAY,CAACC,MAA2B;AAC3D,IAAAJ,EAAmB,CAACK,MAAyB;AAC3C,YAAMC,IAAoB,IAAI,IAAID,CAAO;AACzC,aAAIC,EAAK,IAAIF,CAAQ,IAAGE,EAAK,OAAOF,CAAQ,IACvCE,EAAK,IAAIF,CAAQ,GACfE;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAA,CAAE,GAECC,IAAgDC,EAAQ,MAAM;AAClE,UAAMC,IAAiC,CAAA;AACvC,WAAAb,EAAO,QAAQ,CAACc,GAAyBC,MAAkB;AACzD,MAAAF,EAAOC,EAAK,EAAE,IACZA,EAAK,cAAcE,EAA0BD,IAAQC,EAA0B,MAAM;AAAA,IACzF,CAAC,GACMH;AAAA,EACT,GAAG,CAACb,CAAM,CAAC,GAELiB,IAA2CL,EAAQ,MAAM;AAC7D,UAAMM,IAAiC,CAAA;AACvC,WAAAlB,EAAO,QAAQ,CAACc,GAAyBC,MAAkB;AACzD,YAAMI,IAA6BL,EAAK,aACpCZ,EAAmBY,EAAK,UAAU,IAClC;AACJ,MAAAI,EAAOJ,EAAK,EAAE,IAAIK,KAAUlB,EAAcc,IAAQd,EAAc,MAAM;AAAA,IACxE,CAAC,GACMiB;AAAA,EACT,GAAG,CAAClB,GAAQC,GAAeC,CAAkB,CAAC;AAgB9C,SAAO,EAAE,OAXwBU;AAAA,IAC/B,MACEZ,EAAO,IAAI,CAACc,OAA6B;AAAA,MACvC,IAAIA,EAAK;AAAA,MACT,MAAMA,EAAK;AAAA,MACX,OAAOG,EAAiBH,EAAK,EAAE;AAAA,MAC/B,UAAUX,EAAgB,IAAIW,EAAK,EAAE;AAAA,IAAA,EACrC;AAAA,IACJ,CAACd,GAAQiB,GAAkBd,CAAe;AAAA,EAAA,GAG5B,kBAAAc,GAAkB,uBAAAN,GAAuB,iBAAAR,GAAiB,cAAAG,EAAA;AAC5E;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),I=require("../../../../vendor/clsx/dist/clsx.cjs"),d=require("react"),h=require("../useChartInstance.cjs"),P=require("./time-series-option.cjs");;/* empty css */const _={},E={};function M({series:e,displayType:n="line",legend:o="inline",line:c=E,yAxis:s=_,showSymbols:u=!1,showValueLabels:a=!1,valueFormatter:f,className:T,...m}){const{containerRef:q,chart:r,theme:t,resolveSeriesColor:l}=h.useChartInstance();return d.useEffect(()=>{if(!r||!t)return;const O={};for(const i of e){if(!i.colorToken)continue;const S=l(i.colorToken);S&&(O[i.id]=S)}r.setOption(P.buildTimeSeriesOption({series:e,displayType:n,legend:o,line:c,yAxis:s,theme:t,showSymbols:u,showValueLabels:a,seriesColorOverrides:O,valueFormatter:f}),{notMerge:!0})},[r,t,l,e,n,o,c,s,u,a,f]),C.jsx("div",{ref:q,className:I.clsx("time-series-chart",T),...m})}exports.TimeSeriesChart=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),L=require("../../../../vendor/clsx/dist/clsx.cjs"),S=require("react"),M=require("../useChartInstance.cjs"),N=require("../ChartLegend/ChartLegend.cjs"),P=require("../ChartLegend/use-chart-legend.cjs"),b=require("./time-series-option.cjs");;/* empty css */const E={},R={};function Y({series:r,displayType:t="line",legend:h="inline",line:n=R,yAxis:o=E,showSymbols:c=!1,showValueLabels:a=!1,valueFormatter:l,onSeriesColorChange:C,legendLabels:f,className:m,...I}){const{containerRef:O,chart:s,theme:e,resolveSeriesColor:T}=M.useChartInstance(),{items:q,colorsBySeriesId:u,colorTokensBySeriesId:_,hiddenSeriesIds:d,toggleSeries:v}=P.useChartLegend(r,(e==null?void 0:e.seriesColors)??[],T),g=S.useMemo(()=>r.filter(x=>!d.has(x.id)),[r,d]);S.useEffect(()=>{!s||!e||s.setOption(b.buildTimeSeriesOption({series:g,displayType:t,line:n,yAxis:o,theme:e,showSymbols:c,showValueLabels:a,seriesColorOverrides:u,valueFormatter:l}),{notMerge:!0})},[s,e,g,t,n,o,c,a,u,l]);const j=h!=="none"&&r.length>0;return i.jsxs("div",{className:L.clsx("time-series-chart",m),...I,children:[j&&i.jsx(N.ChartLegend,{items:q,onToggle:v,onColorChange:C,colorTokensBySeriesId:_,labels:f}),i.jsx("div",{ref:O,className:"time-series-chart__canvas"})]})}exports.TimeSeriesChart=Y;
2
2
  //# sourceMappingURL=TimeSeriesChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSeriesChart.cjs","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/TimeSeriesChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport {\n buildTimeSeriesOption,\n type TimeSeriesData,\n type TimeSeriesDisplayType,\n type TimeSeriesLegendMode,\n type TimeSeriesLineOptions,\n type TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\nimport \"./time-series-chart.css\";\n\nexport type {\n TimeSeriesData,\n TimeSeriesDisplayType,\n TimeSeriesLegendMode,\n TimeSeriesLineOptions,\n TimeSeriesLineStyle,\n TimeSeriesLineWidth,\n TimeSeriesPoint,\n TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\n\nexport type TimeSeriesChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n series: TimeSeriesData[];\n displayType?: TimeSeriesDisplayType;\n legend?: TimeSeriesLegendMode;\n line?: TimeSeriesLineOptions;\n yAxis?: TimeSeriesYAxisOptions;\n showSymbols?: boolean;\n showValueLabels?: boolean;\n valueFormatter?: (value: number) => string;\n};\n\nconst EMPTY_Y_AXIS_OPTIONS: TimeSeriesYAxisOptions = {};\n\nconst EMPTY_LINE_OPTIONS: TimeSeriesLineOptions = {};\n\nexport function TimeSeriesChart({\n series,\n displayType = \"line\",\n legend = \"inline\",\n line = EMPTY_LINE_OPTIONS,\n yAxis = EMPTY_Y_AXIS_OPTIONS,\n showSymbols = false,\n showValueLabels = false,\n valueFormatter,\n className,\n ...props\n}: TimeSeriesChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n const seriesColorOverrides: Record<string, string> = {};\n for (const data of series) {\n if (!data.colorToken) continue;\n const color: string | undefined = resolveSeriesColor(data.colorToken);\n if (color) seriesColorOverrides[data.id] = color;\n }\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildTimeSeriesOption({\n series,\n displayType,\n legend,\n line,\n yAxis,\n theme,\n showSymbols,\n showValueLabels,\n seriesColorOverrides,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n resolveSeriesColor,\n series,\n displayType,\n legend,\n line,\n yAxis,\n showSymbols,\n showValueLabels,\n valueFormatter,\n ]);\n\n return <div ref={containerRef} className={clsx(\"time-series-chart\", className)} {...props} />;\n}\n"],"names":["EMPTY_Y_AXIS_OPTIONS","EMPTY_LINE_OPTIONS","TimeSeriesChart","series","displayType","legend","line","yAxis","showSymbols","showValueLabels","valueFormatter","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","useEffect","seriesColorOverrides","data","color","buildTimeSeriesOption","jsx","clsx"],"mappings":"6SAmCA,MAAMA,EAA+C,CAAA,EAE/CC,EAA4C,CAAA,EAE3C,SAASC,EAAgB,CAC9B,OAAAC,EACA,YAAAC,EAAc,OACd,OAAAC,EAAS,SACT,KAAAC,EAAOL,EACP,MAAAM,EAAQP,EACR,YAAAQ,EAAc,GACd,gBAAAC,EAAkB,GAClB,eAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAyB,CACvB,KAAM,CAAE,aAAAC,EAAc,MAAAC,EAAO,MAAAC,EAAO,mBAAAC,CAAA,EAAsCC,EAAAA,iBAAA,EAE1EC,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAI,CAACJ,GAAS,CAACC,EAAO,OAEtB,MAAMI,EAA+C,CAAA,EACrD,UAAWC,KAAQjB,EAAQ,CACzB,GAAI,CAACiB,EAAK,WAAY,SACtB,MAAMC,EAA4BL,EAAmBI,EAAK,UAAU,EAChEC,IAAOF,EAAqBC,EAAK,EAAE,EAAIC,EAC7C,CAIAP,EAAM,UACJQ,wBAAsB,CACpB,OAAAnB,EACA,YAAAC,EACA,OAAAC,EACA,KAAAC,EACA,MAAAC,EACA,MAAAQ,EACA,YAAAP,EACA,gBAAAC,EACA,qBAAAU,EACA,eAAAT,CAAA,CACD,EACD,CAAE,SAAU,EAAA,CAAK,CAErB,EAAG,CACDI,EACAC,EACAC,EACAb,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CAAA,CACD,EAEMa,MAAC,MAAA,CAAI,IAAKV,EAAc,UAAWW,EAAAA,KAAK,oBAAqBb,CAAS,EAAI,GAAGC,CAAA,CAAO,CAC7F"}
1
+ {"version":3,"file":"TimeSeriesChart.cjs","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/TimeSeriesChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect, useMemo } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport { ChartLegend, type ChartLegendLabels } from \"../ChartLegend/ChartLegend\";\nimport { useChartLegend, type ChartLegendState } from \"../ChartLegend/use-chart-legend\";\nimport {\n buildTimeSeriesOption,\n type TimeSeriesData,\n type TimeSeriesDisplayType,\n type TimeSeriesLegendMode,\n type TimeSeriesLineOptions,\n type TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\nimport \"./time-series-chart.css\";\n\nexport type {\n TimeSeriesData,\n TimeSeriesDisplayType,\n TimeSeriesLegendMode,\n TimeSeriesLineOptions,\n TimeSeriesLineStyle,\n TimeSeriesLineWidth,\n TimeSeriesPoint,\n TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\n\nexport type TimeSeriesChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n series: TimeSeriesData[];\n displayType?: TimeSeriesDisplayType;\n legend?: TimeSeriesLegendMode;\n line?: TimeSeriesLineOptions;\n yAxis?: TimeSeriesYAxisOptions;\n showSymbols?: boolean;\n showValueLabels?: boolean;\n valueFormatter?: (value: number) => string;\n // Habilita o seletor de cor no marcador da legenda. Sem ele o marcador é só desenho — o gráfico\n // que não tem onde guardar a escolha não pode oferecê-la.\n onSeriesColorChange?: (seriesId: string, colorToken: string | null) => void;\n legendLabels?: Partial<ChartLegendLabels>;\n};\n\nconst EMPTY_Y_AXIS_OPTIONS: TimeSeriesYAxisOptions = {};\n\nconst EMPTY_LINE_OPTIONS: TimeSeriesLineOptions = {};\n\nexport function TimeSeriesChart({\n series,\n displayType = \"line\",\n legend = \"inline\",\n line = EMPTY_LINE_OPTIONS,\n yAxis = EMPTY_Y_AXIS_OPTIONS,\n showSymbols = false,\n showValueLabels = false,\n valueFormatter,\n onSeriesColorChange,\n legendLabels,\n className,\n ...props\n}: TimeSeriesChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n const {\n items,\n colorsBySeriesId,\n colorTokensBySeriesId,\n hiddenSeriesIds,\n toggleSeries,\n }: ChartLegendState =\n useChartLegend(series, theme?.seriesColors ?? [], resolveSeriesColor);\n\n // A série escondida sai da opção inteira, em vez de ficar com a seleção desligada do ECharts: é\n // o que faz o eixo reescalar sobre o que restou.\n const visibleSeries: TimeSeriesData[] = useMemo(\n () => series.filter((data: TimeSeriesData) => !hiddenSeriesIds.has(data.id)),\n [series, hiddenSeriesIds],\n );\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildTimeSeriesOption({\n series: visibleSeries,\n displayType,\n line,\n yAxis,\n theme,\n showSymbols,\n showValueLabels,\n seriesColorOverrides: colorsBySeriesId,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n visibleSeries,\n displayType,\n line,\n yAxis,\n showSymbols,\n showValueLabels,\n colorsBySeriesId,\n valueFormatter,\n ]);\n\n const isLegendVisible: boolean = legend !== \"none\" && series.length > 0;\n\n return (\n <div className={clsx(\"time-series-chart\", className)} {...props}>\n {isLegendVisible && (\n <ChartLegend\n items={items}\n onToggle={toggleSeries}\n onColorChange={onSeriesColorChange}\n colorTokensBySeriesId={colorTokensBySeriesId}\n labels={legendLabels}\n />\n )}\n <div ref={containerRef} className=\"time-series-chart__canvas\" />\n </div>\n );\n}\n"],"names":["EMPTY_Y_AXIS_OPTIONS","EMPTY_LINE_OPTIONS","TimeSeriesChart","series","displayType","legend","line","yAxis","showSymbols","showValueLabels","valueFormatter","onSeriesColorChange","legendLabels","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","items","colorsBySeriesId","colorTokensBySeriesId","hiddenSeriesIds","toggleSeries","useChartLegend","visibleSeries","useMemo","data","useEffect","buildTimeSeriesOption","isLegendVisible","jsxs","clsx","jsx","ChartLegend"],"mappings":"0YAyCA,MAAMA,EAA+C,CAAA,EAE/CC,EAA4C,CAAA,EAE3C,SAASC,EAAgB,CAC9B,OAAAC,EACA,YAAAC,EAAc,OACd,OAAAC,EAAS,SACT,KAAAC,EAAOL,EACP,MAAAM,EAAQP,EACR,YAAAQ,EAAc,GACd,gBAAAC,EAAkB,GAClB,eAAAC,EACA,oBAAAC,EACA,aAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAyB,CACvB,KAAM,CAAE,aAAAC,EAAc,MAAAC,EAAO,MAAAC,EAAO,mBAAAC,CAAA,EAAsCC,EAAAA,iBAAA,EAEpE,CACJ,MAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,gBAAAC,EACA,aAAAC,CAAA,EAEAC,EAAAA,eAAetB,GAAQc,GAAA,YAAAA,EAAO,eAAgB,CAAA,EAAIC,CAAkB,EAIhEQ,EAAkCC,EAAAA,QACtC,IAAMxB,EAAO,OAAQyB,GAAyB,CAACL,EAAgB,IAAIK,EAAK,EAAE,CAAC,EAC3E,CAACzB,EAAQoB,CAAe,CAAA,EAG1BM,EAAAA,UAAU,IAAM,CACV,CAACb,GAAS,CAACC,GAIfD,EAAM,UACJc,wBAAsB,CACpB,OAAQJ,EACR,YAAAtB,EACA,KAAAE,EACA,MAAAC,EACA,MAAAU,EACA,YAAAT,EACA,gBAAAC,EACA,qBAAsBY,EACtB,eAAAX,CAAA,CACD,EACD,CAAE,SAAU,EAAA,CAAK,CAErB,EAAG,CACDM,EACAC,EACAS,EACAtB,EACAE,EACAC,EACAC,EACAC,EACAY,EACAX,CAAA,CACD,EAED,MAAMqB,EAA2B1B,IAAW,QAAUF,EAAO,OAAS,EAEtE,OACE6B,EAAAA,KAAC,OAAI,UAAWC,EAAAA,KAAK,oBAAqBpB,CAAS,EAAI,GAAGC,EACvD,SAAA,CAAAiB,GACCG,EAAAA,IAACC,EAAAA,YAAA,CACC,MAAAf,EACA,SAAUI,EACV,cAAeb,EACf,sBAAAW,EACA,OAAQV,CAAA,CAAA,EAGZsB,EAAAA,IAAC,MAAA,CAAI,IAAKnB,EAAc,UAAU,2BAAA,CAA4B,CAAA,EAChE,CAEJ"}
@@ -1,61 +1,79 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { clsx as _ } from "../../../../vendor/clsx/dist/clsx.js";
3
- import { useEffect as C } from "react";
4
- import { useChartInstance as E } from "../useChartInstance.js";
5
- import { buildTimeSeriesOption as N } from "./time-series-option.js";
1
+ import { jsxs as E, jsx as d } from "react/jsx-runtime";
2
+ import { clsx as M } from "../../../../vendor/clsx/dist/clsx.js";
3
+ import { useMemo as P, useEffect as x } from "react";
4
+ import { useChartInstance as L } from "../useChartInstance.js";
5
+ import { ChartLegend as Y } from "../ChartLegend/ChartLegend.js";
6
+ import { useChartLegend as b } from "../ChartLegend/use-chart-legend.js";
7
+ import { buildTimeSeriesOption as j } from "./time-series-option.js";
6
8
  /* empty css */
7
- const P = {}, d = {};
8
- function j({
9
- series: o,
9
+ const B = {}, k = {};
10
+ function J({
11
+ series: r,
10
12
  displayType: i = "line",
11
- legend: n = "inline",
12
- line: c = d,
13
- yAxis: f = P,
14
- showSymbols: s = !1,
15
- showValueLabels: m = !1,
16
- valueFormatter: a,
17
- className: l,
18
- ...u
13
+ legend: g = "inline",
14
+ line: s = k,
15
+ yAxis: t = B,
16
+ showSymbols: n = !1,
17
+ showValueLabels: c = !1,
18
+ valueFormatter: m,
19
+ onSeriesColorChange: S,
20
+ legendLabels: h,
21
+ className: p,
22
+ ...C
19
23
  }) {
20
- const { containerRef: I, chart: r, theme: t, resolveSeriesColor: p } = E();
21
- return C(() => {
22
- if (!r || !t) return;
23
- const O = {};
24
- for (const e of o) {
25
- if (!e.colorToken) continue;
26
- const T = p(e.colorToken);
27
- T && (O[e.id] = T);
28
- }
29
- r.setOption(
30
- N({
31
- series: o,
24
+ const { containerRef: I, chart: o, theme: e, resolveSeriesColor: u } = L(), {
25
+ items: O,
26
+ colorsBySeriesId: l,
27
+ colorTokensBySeriesId: T,
28
+ hiddenSeriesIds: f,
29
+ toggleSeries: _
30
+ } = b(r, (e == null ? void 0 : e.seriesColors) ?? [], u), a = P(
31
+ () => r.filter((N) => !f.has(N.id)),
32
+ [r, f]
33
+ );
34
+ x(() => {
35
+ !o || !e || o.setOption(
36
+ j({
37
+ series: a,
32
38
  displayType: i,
33
- legend: n,
34
- line: c,
35
- yAxis: f,
36
- theme: t,
37
- showSymbols: s,
38
- showValueLabels: m,
39
- seriesColorOverrides: O,
40
- valueFormatter: a
39
+ line: s,
40
+ yAxis: t,
41
+ theme: e,
42
+ showSymbols: n,
43
+ showValueLabels: c,
44
+ seriesColorOverrides: l,
45
+ valueFormatter: m
41
46
  }),
42
47
  { notMerge: !0 }
43
48
  );
44
49
  }, [
45
- r,
46
- t,
47
- p,
48
50
  o,
51
+ e,
52
+ a,
49
53
  i,
54
+ s,
55
+ t,
50
56
  n,
51
57
  c,
52
- f,
53
- s,
54
- m,
55
- a
56
- ]), /* @__PURE__ */ S("div", { ref: I, className: _("time-series-chart", l), ...u });
58
+ l,
59
+ m
60
+ ]);
61
+ const v = g !== "none" && r.length > 0;
62
+ return /* @__PURE__ */ E("div", { className: M("time-series-chart", p), ...C, children: [
63
+ v && /* @__PURE__ */ d(
64
+ Y,
65
+ {
66
+ items: O,
67
+ onToggle: _,
68
+ onColorChange: S,
69
+ colorTokensBySeriesId: T,
70
+ labels: h
71
+ }
72
+ ),
73
+ /* @__PURE__ */ d("div", { ref: I, className: "time-series-chart__canvas" })
74
+ ] });
57
75
  }
58
76
  export {
59
- j as TimeSeriesChart
77
+ J as TimeSeriesChart
60
78
  };
61
79
  //# sourceMappingURL=TimeSeriesChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSeriesChart.js","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/TimeSeriesChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport {\n buildTimeSeriesOption,\n type TimeSeriesData,\n type TimeSeriesDisplayType,\n type TimeSeriesLegendMode,\n type TimeSeriesLineOptions,\n type TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\nimport \"./time-series-chart.css\";\n\nexport type {\n TimeSeriesData,\n TimeSeriesDisplayType,\n TimeSeriesLegendMode,\n TimeSeriesLineOptions,\n TimeSeriesLineStyle,\n TimeSeriesLineWidth,\n TimeSeriesPoint,\n TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\n\nexport type TimeSeriesChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n series: TimeSeriesData[];\n displayType?: TimeSeriesDisplayType;\n legend?: TimeSeriesLegendMode;\n line?: TimeSeriesLineOptions;\n yAxis?: TimeSeriesYAxisOptions;\n showSymbols?: boolean;\n showValueLabels?: boolean;\n valueFormatter?: (value: number) => string;\n};\n\nconst EMPTY_Y_AXIS_OPTIONS: TimeSeriesYAxisOptions = {};\n\nconst EMPTY_LINE_OPTIONS: TimeSeriesLineOptions = {};\n\nexport function TimeSeriesChart({\n series,\n displayType = \"line\",\n legend = \"inline\",\n line = EMPTY_LINE_OPTIONS,\n yAxis = EMPTY_Y_AXIS_OPTIONS,\n showSymbols = false,\n showValueLabels = false,\n valueFormatter,\n className,\n ...props\n}: TimeSeriesChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n const seriesColorOverrides: Record<string, string> = {};\n for (const data of series) {\n if (!data.colorToken) continue;\n const color: string | undefined = resolveSeriesColor(data.colorToken);\n if (color) seriesColorOverrides[data.id] = color;\n }\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildTimeSeriesOption({\n series,\n displayType,\n legend,\n line,\n yAxis,\n theme,\n showSymbols,\n showValueLabels,\n seriesColorOverrides,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n resolveSeriesColor,\n series,\n displayType,\n legend,\n line,\n yAxis,\n showSymbols,\n showValueLabels,\n valueFormatter,\n ]);\n\n return <div ref={containerRef} className={clsx(\"time-series-chart\", className)} {...props} />;\n}\n"],"names":["EMPTY_Y_AXIS_OPTIONS","EMPTY_LINE_OPTIONS","TimeSeriesChart","series","displayType","legend","line","yAxis","showSymbols","showValueLabels","valueFormatter","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","useEffect","seriesColorOverrides","data","color","buildTimeSeriesOption","jsx","clsx"],"mappings":";;;;;;AAmCA,MAAMA,IAA+C,CAAA,GAE/CC,IAA4C,CAAA;AAE3C,SAASC,EAAgB;AAAA,EAC9B,QAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,MAAAC,IAAOL;AAAA,EACP,OAAAM,IAAQP;AAAA,EACR,aAAAQ,IAAc;AAAA,EACd,iBAAAC,IAAkB;AAAA,EAClB,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GAAyB;AACvB,QAAM,EAAE,cAAAC,GAAc,OAAAC,GAAO,OAAAC,GAAO,oBAAAC,EAAA,IAAsCC,EAAA;AAE1E,SAAAC,EAAU,MAAM;AACd,QAAI,CAACJ,KAAS,CAACC,EAAO;AAEtB,UAAMI,IAA+C,CAAA;AACrD,eAAWC,KAAQjB,GAAQ;AACzB,UAAI,CAACiB,EAAK,WAAY;AACtB,YAAMC,IAA4BL,EAAmBI,EAAK,UAAU;AACpE,MAAIC,MAAOF,EAAqBC,EAAK,EAAE,IAAIC;AAAA,IAC7C;AAIA,IAAAP,EAAM;AAAA,MACJQ,EAAsB;AAAA,QACpB,QAAAnB;AAAA,QACA,aAAAC;AAAA,QACA,QAAAC;AAAA,QACA,MAAAC;AAAA,QACA,OAAAC;AAAA,QACA,OAAAQ;AAAA,QACA,aAAAP;AAAA,QACA,iBAAAC;AAAA,QACA,sBAAAU;AAAA,QACA,gBAAAT;AAAA,MAAA,CACD;AAAA,MACD,EAAE,UAAU,GAAA;AAAA,IAAK;AAAA,EAErB,GAAG;AAAA,IACDI;AAAA,IACAC;AAAA,IACAC;AAAA,IACAb;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD,GAEM,gBAAAa,EAAC,OAAA,EAAI,KAAKV,GAAc,WAAWW,EAAK,qBAAqBb,CAAS,GAAI,GAAGC,EAAA,CAAO;AAC7F;"}
1
+ {"version":3,"file":"TimeSeriesChart.js","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/TimeSeriesChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect, useMemo } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport { ChartLegend, type ChartLegendLabels } from \"../ChartLegend/ChartLegend\";\nimport { useChartLegend, type ChartLegendState } from \"../ChartLegend/use-chart-legend\";\nimport {\n buildTimeSeriesOption,\n type TimeSeriesData,\n type TimeSeriesDisplayType,\n type TimeSeriesLegendMode,\n type TimeSeriesLineOptions,\n type TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\nimport \"./time-series-chart.css\";\n\nexport type {\n TimeSeriesData,\n TimeSeriesDisplayType,\n TimeSeriesLegendMode,\n TimeSeriesLineOptions,\n TimeSeriesLineStyle,\n TimeSeriesLineWidth,\n TimeSeriesPoint,\n TimeSeriesYAxisOptions,\n} from \"./time-series-option\";\n\nexport type TimeSeriesChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n series: TimeSeriesData[];\n displayType?: TimeSeriesDisplayType;\n legend?: TimeSeriesLegendMode;\n line?: TimeSeriesLineOptions;\n yAxis?: TimeSeriesYAxisOptions;\n showSymbols?: boolean;\n showValueLabels?: boolean;\n valueFormatter?: (value: number) => string;\n // Habilita o seletor de cor no marcador da legenda. Sem ele o marcador é só desenho — o gráfico\n // que não tem onde guardar a escolha não pode oferecê-la.\n onSeriesColorChange?: (seriesId: string, colorToken: string | null) => void;\n legendLabels?: Partial<ChartLegendLabels>;\n};\n\nconst EMPTY_Y_AXIS_OPTIONS: TimeSeriesYAxisOptions = {};\n\nconst EMPTY_LINE_OPTIONS: TimeSeriesLineOptions = {};\n\nexport function TimeSeriesChart({\n series,\n displayType = \"line\",\n legend = \"inline\",\n line = EMPTY_LINE_OPTIONS,\n yAxis = EMPTY_Y_AXIS_OPTIONS,\n showSymbols = false,\n showValueLabels = false,\n valueFormatter,\n onSeriesColorChange,\n legendLabels,\n className,\n ...props\n}: TimeSeriesChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n const {\n items,\n colorsBySeriesId,\n colorTokensBySeriesId,\n hiddenSeriesIds,\n toggleSeries,\n }: ChartLegendState =\n useChartLegend(series, theme?.seriesColors ?? [], resolveSeriesColor);\n\n // A série escondida sai da opção inteira, em vez de ficar com a seleção desligada do ECharts: é\n // o que faz o eixo reescalar sobre o que restou.\n const visibleSeries: TimeSeriesData[] = useMemo(\n () => series.filter((data: TimeSeriesData) => !hiddenSeriesIds.has(data.id)),\n [series, hiddenSeriesIds],\n );\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildTimeSeriesOption({\n series: visibleSeries,\n displayType,\n line,\n yAxis,\n theme,\n showSymbols,\n showValueLabels,\n seriesColorOverrides: colorsBySeriesId,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n visibleSeries,\n displayType,\n line,\n yAxis,\n showSymbols,\n showValueLabels,\n colorsBySeriesId,\n valueFormatter,\n ]);\n\n const isLegendVisible: boolean = legend !== \"none\" && series.length > 0;\n\n return (\n <div className={clsx(\"time-series-chart\", className)} {...props}>\n {isLegendVisible && (\n <ChartLegend\n items={items}\n onToggle={toggleSeries}\n onColorChange={onSeriesColorChange}\n colorTokensBySeriesId={colorTokensBySeriesId}\n labels={legendLabels}\n />\n )}\n <div ref={containerRef} className=\"time-series-chart__canvas\" />\n </div>\n );\n}\n"],"names":["EMPTY_Y_AXIS_OPTIONS","EMPTY_LINE_OPTIONS","TimeSeriesChart","series","displayType","legend","line","yAxis","showSymbols","showValueLabels","valueFormatter","onSeriesColorChange","legendLabels","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","items","colorsBySeriesId","colorTokensBySeriesId","hiddenSeriesIds","toggleSeries","useChartLegend","visibleSeries","useMemo","data","useEffect","buildTimeSeriesOption","isLegendVisible","jsxs","clsx","jsx","ChartLegend"],"mappings":";;;;;;;;AAyCA,MAAMA,IAA+C,CAAA,GAE/CC,IAA4C,CAAA;AAE3C,SAASC,EAAgB;AAAA,EAC9B,QAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,MAAAC,IAAOL;AAAA,EACP,OAAAM,IAAQP;AAAA,EACR,aAAAQ,IAAc;AAAA,EACd,iBAAAC,IAAkB;AAAA,EAClB,gBAAAC;AAAA,EACA,qB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AAA,QACA,QAAQV;AAAA,MAAA;AAAA,IAAA;AAAA,IAGZ,gBAAAsB,EAAC,OAAA,EAAI,KAAKnB,GAAc,WAAU,4BAAA,CAA4B;AAAA,EAAA,GAChE;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=32,n={top:16,right:16,bottom:24,left:56},f=6,y=.15,L={thin:1,normal:2,thick:4},g="solid",b="normal",h=new Intl.DateTimeFormat(void 0,{year:"numeric"}),p=new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit"}),S=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),E=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function T(o){const e=new Date(o);return e.getSeconds()!==0||e.getMilliseconds()!==0?E.format(e):e.getHours()!==0||e.getMinutes()!==0?S.format(e):e.getMonth()===0&&e.getDate()===1?h.format(e):p.format(e)}function c(o){const{valueFormatter:e}=o;if(e)return i=>i===null?"":e(i)}function C(o){const{showValueLabels:e,theme:i}=o,l=c(o);return{show:e,position:"top",color:i.labelColor,formatter:l?t=>l(t.value[1]):void 0}}function x(o,e,i){const l=o.points.map(r=>[r.timestamp,r.value]),t=C(e);return e.displayType==="bar"?{id:o.id,name:o.name,type:"bar",data:l,itemStyle:{color:i},label:t}:{id:o.id,name:o.name,type:"line",data:l,showSymbol:e.showSymbols,symbolSize:f,lineStyle:{color:i,type:e.line.style??g,width:L[e.line.width??b]},itemStyle:{color:i},areaStyle:e.displayType==="area"?{color:i,opacity:y}:void 0,label:t}}function _(o){const{series:e,legend:i,yAxis:l,theme:t,seriesColorOverrides:r}=o,s=i!=="none"&&e.length>0,a=c(o);return{animation:!1,color:t.seriesColors,textStyle:{fontFamily:t.fontFamily,color:t.labelColor},grid:{...n,top:s?n.top+u:n.top,containLabel:!1},legend:s?{type:"scroll",top:0,left:0,icon:"roundRect",itemHeight:8,itemWidth:12,textStyle:{color:t.labelColor}}:{show:!1},tooltip:{trigger:"axis",backgroundColor:t.tooltipBackgroundColor,borderColor:t.tooltipBorderColor,textStyle:{color:t.labelColor},valueFormatter:a},xAxis:{type:"time",axisLine:{lineStyle:{color:t.axisLineColor}},axisTick:{show:!1},axisLabel:{color:t.labelColor,hideOverlap:!0,formatter:T},splitLine:{show:!1}},yAxis:{type:l.scale==="log"?"log":"value",scale:l.includeZero!==!0,min:l.min,max:l.max,axisLine:{show:!1},axisLabel:{color:t.labelColor,formatter:a},splitLine:{lineStyle:{color:t.splitLineColor}}},series:e.map((m,d)=>x(m,o,r[m.id]??t.seriesColors[d%t.seriesColors.length]))}}exports.buildTimeSeriesOption=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m={top:16,right:16,bottom:24,left:56},c=6,d=.15,u={thin:1,normal:2,thick:4},f="solid",y="normal",L=new Intl.DateTimeFormat(void 0,{year:"numeric"}),b=new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit"}),g=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}),h=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function S(t){const e=new Date(t);return e.getSeconds()!==0||e.getMilliseconds()!==0?h.format(e):e.getHours()!==0||e.getMinutes()!==0?g.format(e):e.getMonth()===0&&e.getDate()===1?L.format(e):b.format(e)}function n(t){const{valueFormatter:e}=t;if(e)return i=>i===null?"":e(i)}function p(t){const{showValueLabels:e,theme:i}=t,o=n(t);return{show:e,position:"top",color:i.labelColor,formatter:o?l=>o(l.value[1]):void 0}}function C(t,e,i){const o=t.points.map(r=>[r.timestamp,r.value]),l=p(e);return e.displayType==="bar"?{id:t.id,name:t.name,type:"bar",data:o,itemStyle:{color:i},label:l}:{id:t.id,name:t.name,type:"line",data:o,showSymbol:e.showSymbols,symbolSize:c,lineStyle:{color:i,type:e.line.style??f,width:u[e.line.width??y]},itemStyle:{color:i},areaStyle:e.displayType==="area"?{color:i,opacity:d}:void 0,label:l}}function T(t){const{series:e,yAxis:i,theme:o,seriesColorOverrides:l}=t,r=n(t);return{animation:!1,color:o.seriesColors,textStyle:{fontFamily:o.fontFamily,color:o.labelColor},grid:{...m,containLabel:!1},tooltip:{trigger:"axis",backgroundColor:o.tooltipBackgroundColor,borderColor:o.tooltipBorderColor,textStyle:{color:o.labelColor},valueFormatter:r},xAxis:{type:"time",axisLine:{lineStyle:{color:o.axisLineColor}},axisTick:{show:!1},axisLabel:{color:o.labelColor,hideOverlap:!0,formatter:S},splitLine:{show:!1}},yAxis:{type:i.scale==="log"?"log":"value",scale:i.includeZero!==!0,min:i.min,max:i.max,axisLine:{show:!1},axisLabel:{color:o.labelColor,formatter:r},splitLine:{lineStyle:{color:o.splitLineColor}}},series:e.map((s,a)=>C(s,t,l[s.id]??o.seriesColors[a%o.seriesColors.length]))}}exports.buildTimeSeriesOption=T;
2
2
  //# sourceMappingURL=time-series-option.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-option.cjs","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/time-series-option.ts"],"sourcesContent":["import type { ChartTheme } from \"../chart-theme\";\n\nexport interface TimeSeriesPoint {\n timestamp: number;\n value: number | null;\n}\n\nexport interface TimeSeriesData {\n id: string;\n name: string;\n points: TimeSeriesPoint[];\n // Nome de token, nunca hex: é o que mantém a cor válida nos dois temas. Sem ele a série\n // recebe a próxima cor da paleta.\n colorToken?: string;\n}\n\nexport type TimeSeriesDisplayType = \"line\" | \"bar\" | \"area\";\n\nexport type TimeSeriesLineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport type TimeSeriesLineWidth = \"thin\" | \"normal\" | \"thick\";\n\nexport interface TimeSeriesLineOptions {\n style?: TimeSeriesLineStyle;\n width?: TimeSeriesLineWidth;\n}\n\nexport type TimeSeriesLegendMode = \"inline\" | \"none\";\n\nexport type TimeSeriesAxisScale = \"linear\" | \"log\";\n\nexport interface TimeSeriesYAxisOptions {\n scale?: TimeSeriesAxisScale;\n min?: number;\n max?: number;\n includeZero?: boolean;\n}\n\nexport interface TimeSeriesOptionInput {\n series: TimeSeriesData[];\n displayType: TimeSeriesDisplayType;\n legend: TimeSeriesLegendMode;\n line: TimeSeriesLineOptions;\n yAxis: TimeSeriesYAxisOptions;\n theme: ChartTheme;\n showSymbols: boolean;\n showValueLabels: boolean;\n seriesColorOverrides: Record<string, string>;\n valueFormatter?: (value: number) => string;\n}\n\nconst LEGEND_HEIGHT_PX: number = 32;\n\nconst GRID_WITHOUT_LEGEND = { top: 16, right: 16, bottom: 24, left: 56 } as const;\n\nconst SYMBOL_SIZE_PX: number = 6;\n\nconst AREA_OPACITY: number = 0.15;\n\nconst LINE_WIDTH_PX: Record<TimeSeriesLineWidth, number> = { thin: 1, normal: 2, thick: 4 };\n\nconst DEFAULT_LINE_STYLE: TimeSeriesLineStyle = \"solid\";\n\nconst DEFAULT_LINE_WIDTH: TimeSeriesLineWidth = \"normal\";\n\n// O eixo de tempo do ECharts rotula a marca de dia so com o numero do dia -- \"2\", \"3\", \"4\" --, que\n// sozinho nao diz nem o mes. Aqui a marca de dia vira data e a marca dentro do dia vira hora, que e\n// o que se espera de uma serie temporal.\n//\n// A precisao sai do proprio instante, e nao de um nivel pedido ao ECharts: ele alinha as marcas ao\n// nivel que cabe no eixo, entao meia-noite e marca de dia, minuto cheio e marca de hora, e assim por\n// diante. Ler o instante e o que permite usar `Intl` e escrever a data na convencao de quem le -- o\n// objeto de niveis do ECharts so aceita template, e um `{dd}/{MM}` fixo seria lido como mes/dia por\n// metade dos usuarios.\nconst YEAR_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, { year: \"numeric\" });\n\nconst DAY_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n day: \"2-digit\",\n month: \"2-digit\",\n});\n\nconst MINUTE_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n});\n\nconst SECOND_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: false,\n});\n\nfunction timeAxisLabel(timestamp: number): string {\n const instant: Date = new Date(timestamp);\n if (instant.getSeconds() !== 0 || instant.getMilliseconds() !== 0) return SECOND_LABEL.format(instant);\n if (instant.getHours() !== 0 || instant.getMinutes() !== 0) return MINUTE_LABEL.format(instant);\n // Primeiro de janeiro e a marca de ano do ECharts, e ali a data sem o ano nao situa ninguem.\n if (instant.getMonth() === 0 && instant.getDate() === 1) return YEAR_LABEL.format(instant);\n return DAY_LABEL.format(instant);\n}\n\n// O ponto de gap chega ao formatter como `null` — o ECharts monta o bloco do tooltip sem marcar\n// `noValue`, então formata o vazio junto com o resto. O tipo público promete `number` ao\n// consumidor, e é esta guarda que mantém a promessa em vez de transformá-la em aviso.\nfunction nullSafeValueFormatter(\n input: TimeSeriesOptionInput,\n): ((value: number | null) => string) | undefined {\n const { valueFormatter } = input;\n if (!valueFormatter) return undefined;\n return (value: number | null) => (value === null ? \"\" : valueFormatter(value));\n}\n\nfunction seriesLabel(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { showValueLabels, theme } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n show: showValueLabels,\n position: \"top\",\n color: theme.labelColor,\n formatter: formatValue\n ? (params: { value: [number, number | null] }) => formatValue(params.value[1])\n : undefined,\n };\n}\n\nfunction seriesEntry(\n data: TimeSeriesData,\n input: TimeSeriesOptionInput,\n color: string,\n): Record<string, unknown> {\n const values: Array<[number, number | null]> = data.points.map((point: TimeSeriesPoint) => [\n point.timestamp,\n point.value,\n ]);\n const label: Record<string, unknown> = seriesLabel(input);\n\n if (input.displayType === \"bar\") {\n return { id: data.id, name: data.name, type: \"bar\", data: values, itemStyle: { color }, label };\n }\n\n return {\n id: data.id,\n name: data.name,\n type: \"line\",\n data: values,\n showSymbol: input.showSymbols,\n symbolSize: SYMBOL_SIZE_PX,\n lineStyle: {\n color,\n type: input.line.style ?? DEFAULT_LINE_STYLE,\n width: LINE_WIDTH_PX[input.line.width ?? DEFAULT_LINE_WIDTH],\n },\n itemStyle: { color },\n areaStyle: input.displayType === \"area\" ? { color, opacity: AREA_OPACITY } : undefined,\n label,\n };\n}\n\n// O retorno é `Record<string, unknown>` de propósito, e não `EChartsOption`: é o que impede\n// um tipo da biblioteca de vazar para o resto do design system.\nexport function buildTimeSeriesOption(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { series, legend, yAxis, theme, seriesColorOverrides } = input;\n const isLegendVisible: boolean = legend !== \"none\" && series.length > 0;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n\n return {\n animation: false,\n color: theme.seriesColors,\n textStyle: { fontFamily: theme.fontFamily, color: theme.labelColor },\n grid: {\n ...GRID_WITHOUT_LEGEND,\n top: isLegendVisible ? GRID_WITHOUT_LEGEND.top + LEGEND_HEIGHT_PX : GRID_WITHOUT_LEGEND.top,\n containLabel: false,\n },\n legend: isLegendVisible\n ? {\n type: \"scroll\",\n top: 0,\n left: 0,\n icon: \"roundRect\",\n itemHeight: 8,\n itemWidth: 12,\n textStyle: { color: theme.labelColor },\n }\n : { show: false },\n tooltip: {\n trigger: \"axis\",\n backgroundColor: theme.tooltipBackgroundColor,\n borderColor: theme.tooltipBorderColor,\n textStyle: { color: theme.labelColor },\n valueFormatter: formatValue,\n },\n xAxis: {\n type: \"time\",\n axisLine: { lineStyle: { color: theme.axisLineColor } },\n axisTick: { show: false },\n axisLabel: { color: theme.labelColor, hideOverlap: true, formatter: timeAxisLabel },\n splitLine: { show: false },\n },\n yAxis: {\n type: yAxis.scale === \"log\" ? \"log\" : \"value\",\n scale: yAxis.includeZero !== true,\n min: yAxis.min,\n max: yAxis.max,\n axisLine: { show: false },\n axisLabel: { color: theme.labelColor, formatter: formatValue },\n splitLine: { lineStyle: { color: theme.splitLineColor } },\n },\n series: series.map((data: TimeSeriesData, index: number) =>\n seriesEntry(\n data,\n input,\n seriesColorOverrides[data.id] ?? theme.seriesColors[index % theme.seriesColors.length],\n ),\n ),\n };\n}\n"],"names":["LEGEND_HEIGHT_PX","GRID_WITHOUT_LEGEND","SYMBOL_SIZE_PX","AREA_OPACITY","LINE_WIDTH_PX","DEFAULT_LINE_STYLE","DEFAULT_LINE_WIDTH","YEAR_LABEL","DAY_LABEL","MINUTE_LABEL","SECOND_LABEL","timeAxisLabel","timestamp","instant","nullSafeValueFormatter","input","valueFormatter","value","seriesLabel","showValueLabels","theme","formatValue","params","seriesEntry","data","color","values","point","label","buildTimeSeriesOption","series","legend","yAxis","seriesColorOverrides","isLegendVisible","index"],"mappings":"gFAmDA,MAAMA,EAA2B,GAE3BC,EAAsB,CAAE,IAAK,GAAI,MAAO,GAAI,OAAQ,GAAI,KAAM,EAAA,EAE9DC,EAAyB,EAEzBC,EAAuB,IAEvBC,EAAqD,CAAE,KAAM,EAAG,OAAQ,EAAG,MAAO,CAAA,EAElFC,EAA0C,QAE1CC,EAA0C,SAW1CC,EAAkC,IAAI,KAAK,eAAe,OAAW,CAAE,KAAM,UAAW,EAExFC,EAAiC,IAAI,KAAK,eAAe,OAAW,CACxE,IAAK,UACL,MAAO,SACT,CAAC,EAEKC,EAAoC,IAAI,KAAK,eAAe,OAAW,CAC3E,KAAM,UACN,OAAQ,UACR,OAAQ,EACV,CAAC,EAEKC,EAAoC,IAAI,KAAK,eAAe,OAAW,CAC3E,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OAAQ,EACV,CAAC,EAED,SAASC,EAAcC,EAA2B,CAChD,MAAMC,EAAgB,IAAI,KAAKD,CAAS,EACxC,OAAIC,EAAQ,eAAiB,GAAKA,EAAQ,gBAAA,IAAsB,EAAUH,EAAa,OAAOG,CAAO,EACjGA,EAAQ,aAAe,GAAKA,EAAQ,WAAA,IAAiB,EAAUJ,EAAa,O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Chart/time-series-option.ts"],"sourcesContent":["import type { ChartTheme } from \"../chart-theme\";\n\nexport interface TimeSeriesPoint {\n timestamp: number;\n value: number | null;\n}\n\nexport interface TimeSeriesData {\n id: string;\n name: string;\n points: TimeSeriesPoint[];\n // Nome de token, nunca hex: é o que mantém a cor válida nos dois temas. Sem ele a série\n // recebe a próxima cor da paleta.\n colorToken?: string;\n}\n\nexport type TimeSeriesDisplayType = \"line\" | \"bar\" | \"area\";\n\nexport type TimeSeriesLineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport type TimeSeriesLineWidth = \"thin\" | \"normal\" | \"thick\";\n\nexport interface TimeSeriesLineOptions {\n style?: TimeSeriesLineStyle;\n width?: TimeSeriesLineWidth;\n}\n\nexport type TimeSeriesLegendMode = \"inline\" | \"none\";\n\nexport type TimeSeriesAxisScale = \"linear\" | \"log\";\n\nexport interface TimeSeriesYAxisOptions {\n scale?: TimeSeriesAxisScale;\n min?: number;\n max?: number;\n includeZero?: boolean;\n}\n\nexport interface TimeSeriesOptionInput {\n series: TimeSeriesData[];\n displayType: TimeSeriesDisplayType;\n line: TimeSeriesLineOptions;\n yAxis: TimeSeriesYAxisOptions;\n theme: ChartTheme;\n showSymbols: boolean;\n showValueLabels: boolean;\n seriesColorOverrides: Record<string, string>;\n valueFormatter?: (value: number) => string;\n}\n\n// A legenda saiu do canvas e virou HTML (`ChartLegend`), entao a grade nao reserva mais faixa\n// para ela: quem divide a altura agora e o flex do componente.\nconst GRID_PADDING = { top: 16, right: 16, bottom: 24, left: 56 } as const;\n\nconst SYMBOL_SIZE_PX: number = 6;\n\nconst AREA_OPACITY: number = 0.15;\n\nconst LINE_WIDTH_PX: Record<TimeSeriesLineWidth, number> = { thin: 1, normal: 2, thick: 4 };\n\nconst DEFAULT_LINE_STYLE: TimeSeriesLineStyle = \"solid\";\n\nconst DEFAULT_LINE_WIDTH: TimeSeriesLineWidth = \"normal\";\n\n// O eixo de tempo do ECharts rotula a marca de dia so com o numero do dia -- \"2\", \"3\", \"4\" --, que\n// sozinho nao diz nem o mes. Aqui a marca de dia vira data e a marca dentro do dia vira hora, que e\n// o que se espera de uma serie temporal.\n//\n// A precisao sai do proprio instante, e nao de um nivel pedido ao ECharts: ele alinha as marcas ao\n// nivel que cabe no eixo, entao meia-noite e marca de dia, minuto cheio e marca de hora, e assim por\n// diante. Ler o instante e o que permite usar `Intl` e escrever a data na convencao de quem le -- o\n// objeto de niveis do ECharts so aceita template, e um `{dd}/{MM}` fixo seria lido como mes/dia por\n// metade dos usuarios.\nconst YEAR_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, { year: \"numeric\" });\n\nconst DAY_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n day: \"2-digit\",\n month: \"2-digit\",\n});\n\nconst MINUTE_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n});\n\nconst SECOND_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: false,\n});\n\nfunction timeAxisLabel(timestamp: number): string {\n const instant: Date = new Date(timestamp);\n if (instant.getSeconds() !== 0 || instant.getMilliseconds() !== 0) return SECOND_LABEL.format(instant);\n if (instant.getHours() !== 0 || instant.getMinutes() !== 0) return MINUTE_LABEL.format(instant);\n // Primeiro de janeiro e a marca de ano do ECharts, e ali a data sem o ano nao situa ninguem.\n if (instant.getMonth() === 0 && instant.getDate() === 1) return YEAR_LABEL.format(instant);\n return DAY_LABEL.format(instant);\n}\n\n// O ponto de gap chega ao formatter como `null` — o ECharts monta o bloco do tooltip sem marcar\n// `noValue`, então formata o vazio junto com o resto. O tipo público promete `number` ao\n// consumidor, e é esta guarda que mantém a promessa em vez de transformá-la em aviso.\nfunction nullSafeValueFormatter(\n input: TimeSeriesOptionInput,\n): ((value: number | null) => string) | undefined {\n const { valueFormatter } = input;\n if (!valueFormatter) return undefined;\n return (value: number | null) => (value === null ? \"\" : valueFormatter(value));\n}\n\nfunction seriesLabel(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { showValueLabels, theme } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n show: showValueLabels,\n position: \"top\",\n color: theme.labelColor,\n formatter: formatValue\n ? (params: { value: [number, number | null] }) => formatValue(params.value[1])\n : undefined,\n };\n}\n\nfunction seriesEntry(\n data: TimeSeriesData,\n input: TimeSeriesOptionInput,\n color: string,\n): Record<string, unknown> {\n const values: Array<[number, number | null]> = data.points.map((point: TimeSeriesPoint) => [\n point.timestamp,\n point.value,\n ]);\n const label: Record<string, unknown> = seriesLabel(input);\n\n if (input.displayType === \"bar\") {\n return { id: data.id, name: data.name, type: \"bar\", data: values, itemStyle: { color }, label };\n }\n\n return {\n id: data.id,\n name: data.name,\n type: \"line\",\n data: values,\n showSymbol: input.showSymbols,\n symbolSize: SYMBOL_SIZE_PX,\n lineStyle: {\n color,\n type: input.line.style ?? DEFAULT_LINE_STYLE,\n width: LINE_WIDTH_PX[input.line.width ?? DEFAULT_LINE_WIDTH],\n },\n itemStyle: { color },\n areaStyle: input.displayType === \"area\" ? { color, opacity: AREA_OPACITY } : undefined,\n label,\n };\n}\n\n// O retorno é `Record<string, unknown>` de propósito, e não `EChartsOption`: é o que impede\n// um tipo da biblioteca de vazar para o resto do design system.\nexport function buildTimeSeriesOption(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { series, yAxis, theme, seriesColorOverrides } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n\n return {\n animation: false,\n color: theme.seriesColors,\n textStyle: { fontFamily: theme.fontFamily, color: theme.labelColor },\n grid: {\n ...GRID_PADDING,\n containLabel: false,\n },\n tooltip: {\n trigger: \"axis\",\n backgroundColor: theme.tooltipBackgroundColor,\n borderColor: theme.tooltipBorderColor,\n textStyle: { color: theme.labelColor },\n valueFormatter: formatValue,\n },\n xAxis: {\n type: \"time\",\n axisLine: { lineStyle: { color: theme.axisLineColor } },\n axisTick: { show: false },\n axisLabel: { color: theme.labelColor, hideOverlap: true, formatter: timeAxisLabel },\n splitLine: { show: false },\n },\n yAxis: {\n type: yAxis.scale === \"log\" ? \"log\" : \"value\",\n scale: yAxis.includeZero !== true,\n min: yAxis.min,\n max: yAxis.max,\n axisLine: { show: false },\n axisLabel: { color: theme.labelColor, formatter: formatValue },\n splitLine: { lineStyle: { color: theme.splitLineColor } },\n },\n series: series.map((data: TimeSeriesData, index: number) =>\n seriesEntry(\n data,\n input,\n seriesColorOverrides[data.id] ?? theme.seriesColors[index % theme.seriesColors.length],\n ),\n ),\n };\n}\n"],"names":["GRID_PADDING","SYMBOL_SIZE_PX","AREA_OPACITY","LINE_WIDTH_PX","DEFAULT_LINE_STYLE","DEFAULT_LINE_WIDTH","YEAR_LABEL","DAY_LABEL","MINUTE_LABEL","SECOND_LABEL","timeAxisLabel","timestamp","instant","nullSafeValueFormatter","input","valueFormatter","value","seriesLabel","showValueLabels","theme","formatValue","params","seriesEntry","data","color","values","point","label","buildTimeSeriesOption","series","yAxis","seriesColorOverrides","index"],"mappings":"gFAoDA,MAAMA,EAAe,CAAE,IAAK,GAAI,MAAO,GAAI,OAAQ,GAAI,KAAM,EAAA,EAEvDC,EAAyB,EAEzBC,EAAuB,IAEvBC,EAAqD,CAAE,KAAM,EAAG,OAAQ,EAAG,MAAO,CAAA,EAElFC,EAA0C,QAE1CC,EAA0C,SAW1CC,EAAkC,IAAI,KAAK,eAAe,OAAW,CAAE,KAAM,UAAW,EAExFC,EAAiC,IAAI,KAAK,eAAe,OAAW,CACxE,IAAK,UACL,MAAO,SACT,CAAC,EAEKC,EAAoC,IAAI,KAAK,eAAe,OAAW,CAC3E,KAAM,UACN,OAAQ,UACR,OAAQ,EACV,CAAC,EAEKC,EAAoC,IAAI,KAAK,eAAe,OAAW,CAC3E,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,OA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L = "solid", g = "normal", h = new Intl.DateTimeFormat(void 0, { year: "numeric" }), E = new Intl.DateTimeFormat(void 0, {
1
+ const m = { top: 16, right: 16, bottom: 24, left: 56 }, c = 6, d = 0.15, u = { thin: 1, normal: 2, thick: 4 }, f = "solid", y = "normal", L = new Intl.DateTimeFormat(void 0, { year: "numeric" }), g = new Intl.DateTimeFormat(void 0, {
2
2
  day: "2-digit",
3
3
  month: "2-digit"
4
- }), b = new Intl.DateTimeFormat(void 0, {
4
+ }), h = new Intl.DateTimeFormat(void 0, {
5
5
  hour: "2-digit",
6
6
  minute: "2-digit",
7
7
  hour12: !1
8
- }), p = new Intl.DateTimeFormat(void 0, {
8
+ }), b = new Intl.DateTimeFormat(void 0, {
9
9
  hour: "2-digit",
10
10
  minute: "2-digit",
11
11
  second: "2-digit",
@@ -13,70 +13,60 @@ const n = { top: 16, right: 16, bottom: 24, left: 56 }, u = 6, f = 0.15, y = { t
13
13
  });
14
14
  function S(t) {
15
15
  const e = new Date(t);
16
- return e.getSeconds() !== 0 || e.getMilliseconds() !== 0 ? p.format(e) : e.getHours() !== 0 || e.getMinutes() !== 0 ? b.format(e) : e.getMonth() === 0 && e.getDate() === 1 ? h.format(e) : E.format(e);
16
+ return e.getSeconds() !== 0 || e.getMilliseconds() !== 0 ? b.format(e) : e.getHours() !== 0 || e.getMinutes() !== 0 ? h.format(e) : e.getMonth() === 0 && e.getDate() === 1 ? L.format(e) : g.format(e);
17
17
  }
18
- function c(t) {
18
+ function n(t) {
19
19
  const { valueFormatter: e } = t;
20
20
  if (e)
21
21
  return (i) => i === null ? "" : e(i);
22
22
  }
23
- function T(t) {
24
- const { showValueLabels: e, theme: i } = t, l = c(t);
23
+ function p(t) {
24
+ const { showValueLabels: e, theme: i } = t, o = n(t);
25
25
  return {
26
26
  show: e,
27
27
  position: "top",
28
28
  color: i.labelColor,
29
- formatter: l ? (o) => l(o.value[1]) : void 0
29
+ formatter: o ? (l) => o(l.value[1]) : void 0
30
30
  };
31
31
  }
32
- function _(t, e, i) {
33
- const l = t.points.map((r) => [
32
+ function x(t, e, i) {
33
+ const o = t.points.map((r) => [
34
34
  r.timestamp,
35
35
  r.value
36
- ]), o = T(e);
37
- return e.displayType === "bar" ? { id: t.id, name: t.name, type: "bar", data: l, itemStyle: { color: i }, label: o } : {
36
+ ]), l = p(e);
37
+ return e.displayType === "bar" ? { id: t.id, name: t.name, type: "bar", data: o, itemStyle: { color: i }, label: l } : {
38
38
  id: t.id,
39
39
  name: t.name,
40
40
  type: "line",
41
- data: l,
41
+ data: o,
42
42
  showSymbol: e.showSymbols,
43
- symbolSize: u,
43
+ symbolSize: c,
44
44
  lineStyle: {
45
45
  color: i,
46
- type: e.line.style ?? L,
47
- width: y[e.line.width ?? g]
46
+ type: e.line.style ?? f,
47
+ width: u[e.line.width ?? y]
48
48
  },
49
49
  itemStyle: { color: i },
50
- areaStyle: e.displayType === "area" ? { color: i, opacity: f } : void 0,
51
- label: o
50
+ areaStyle: e.displayType === "area" ? { color: i, opacity: d } : void 0,
51
+ label: l
52
52
  };
53
53
  }
54
- function x(t) {
55
- const { series: e, legend: i, yAxis: l, theme: o, seriesColorOverrides: r } = t, s = i !== "none" && e.length > 0, a = c(t);
54
+ function C(t) {
55
+ const { series: e, yAxis: i, theme: o, seriesColorOverrides: l } = t, r = n(t);
56
56
  return {
57
57
  animation: !1,
58
58
  color: o.seriesColors,
59
59
  textStyle: { fontFamily: o.fontFamily, color: o.labelColor },
60
60
  grid: {
61
- ...n,
62
- top: s ? n.top + 32 : n.top,
61
+ ...m,
63
62
  containLabel: !1
64
63
  },
65
- legend: s ? {
66
- type: "scroll",
67
- top: 0,
68
- left: 0,
69
- icon: "roundRect",
70
- itemHeight: 8,
71
- itemWidth: 12,
72
- textStyle: { color: o.labelColor }
73
- } : { show: !1 },
74
64
  tooltip: {
75
65
  trigger: "axis",
76
66
  backgroundColor: o.tooltipBackgroundColor,
77
67
  borderColor: o.tooltipBorderColor,
78
68
  textStyle: { color: o.labelColor },
79
- valueFormatter: a
69
+ valueFormatter: r
80
70
  },
81
71
  xAxis: {
82
72
  type: "time",
@@ -86,24 +76,24 @@ function x(t) {
86
76
  splitLine: { show: !1 }
87
77
  },
88
78
  yAxis: {
89
- type: l.scale === "log" ? "log" : "value",
90
- scale: l.includeZero !== !0,
91
- min: l.min,
92
- max: l.max,
79
+ type: i.scale === "log" ? "log" : "value",
80
+ scale: i.includeZero !== !0,
81
+ min: i.min,
82
+ max: i.max,
93
83
  axisLine: { show: !1 },
94
- axisLabel: { color: o.labelColor, formatter: a },
84
+ axisLabel: { color: o.labelColor, formatter: r },
95
85
  splitLine: { lineStyle: { color: o.splitLineColor } }
96
86
  },
97
87
  series: e.map(
98
- (m, d) => _(
99
- m,
88
+ (s, a) => x(
89
+ s,
100
90
  t,
101
- r[m.id] ?? o.seriesColors[d % o.seriesColors.length]
91
+ l[s.id] ?? o.seriesColors[a % o.seriesColors.length]
102
92
  )
103
93
  )
104
94
  };
105
95
  }
106
96
  export {
107
- x as buildTimeSeriesOption
97
+ C as buildTimeSeriesOption
108
98
  };
109
99
  //# sourceMappingURL=time-series-option.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-option.js","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/time-series-option.ts"],"sourcesContent":["import type { ChartTheme } from \"../chart-theme\";\n\nexport interface TimeSeriesPoint {\n timestamp: number;\n value: number | null;\n}\n\nexport interface TimeSeriesData {\n id: string;\n name: string;\n points: TimeSeriesPoint[];\n // Nome de token, nunca hex: é o que mantém a cor válida nos dois temas. Sem ele a série\n // recebe a próxima cor da paleta.\n colorToken?: string;\n}\n\nexport type TimeSeriesDisplayType = \"line\" | \"bar\" | \"area\";\n\nexport type TimeSeriesLineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport type TimeSeriesLineWidth = \"thin\" | \"normal\" | \"thick\";\n\nexport interface TimeSeriesLineOptions {\n style?: TimeSeriesLineStyle;\n width?: TimeSeriesLineWidth;\n}\n\nexport type TimeSeriesLegendMode = \"inline\" | \"none\";\n\nexport type TimeSeriesAxisScale = \"linear\" | \"log\";\n\nexport interface TimeSeriesYAxisOptions {\n scale?: TimeSeriesAxisScale;\n min?: number;\n max?: number;\n includeZero?: boolean;\n}\n\nexport interface TimeSeriesOptionInput {\n series: TimeSeriesData[];\n displayType: TimeSeriesDisplayType;\n legend: TimeSeriesLegendMode;\n line: TimeSeriesLineOptions;\n yAxis: TimeSeriesYAxisOptions;\n theme: ChartTheme;\n showSymbols: boolean;\n showValueLabels: boolean;\n seriesColorOverrides: Record<string, string>;\n valueFormatter?: (value: number) => string;\n}\n\nconst LEGEND_HEIGHT_PX: number = 32;\n\nconst GRID_WITHOUT_LEGEND = { top: 16, right: 16, bottom: 24, left: 56 } as const;\n\nconst SYMBOL_SIZE_PX: number = 6;\n\nconst AREA_OPACITY: number = 0.15;\n\nconst LINE_WIDTH_PX: Record<TimeSeriesLineWidth, number> = { thin: 1, normal: 2, thick: 4 };\n\nconst DEFAULT_LINE_STYLE: TimeSeriesLineStyle = \"solid\";\n\nconst DEFAULT_LINE_WIDTH: TimeSeriesLineWidth = \"normal\";\n\n// O eixo de tempo do ECharts rotula a marca de dia so com o numero do dia -- \"2\", \"3\", \"4\" --, que\n// sozinho nao diz nem o mes. Aqui a marca de dia vira data e a marca dentro do dia vira hora, que e\n// o que se espera de uma serie temporal.\n//\n// A precisao sai do proprio instante, e nao de um nivel pedido ao ECharts: ele alinha as marcas ao\n// nivel que cabe no eixo, entao meia-noite e marca de dia, minuto cheio e marca de hora, e assim por\n// diante. Ler o instante e o que permite usar `Intl` e escrever a data na convencao de quem le -- o\n// objeto de niveis do ECharts so aceita template, e um `{dd}/{MM}` fixo seria lido como mes/dia por\n// metade dos usuarios.\nconst YEAR_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, { year: \"numeric\" });\n\nconst DAY_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n day: \"2-digit\",\n month: \"2-digit\",\n});\n\nconst MINUTE_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n});\n\nconst SECOND_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: false,\n});\n\nfunction timeAxisLabel(timestamp: number): string {\n const instant: Date = new Date(timestamp);\n if (instant.getSeconds() !== 0 || instant.getMilliseconds() !== 0) return SECOND_LABEL.format(instant);\n if (instant.getHours() !== 0 || instant.getMinutes() !== 0) return MINUTE_LABEL.format(instant);\n // Primeiro de janeiro e a marca de ano do ECharts, e ali a data sem o ano nao situa ninguem.\n if (instant.getMonth() === 0 && instant.getDate() === 1) return YEAR_LABEL.format(instant);\n return DAY_LABEL.format(instant);\n}\n\n// O ponto de gap chega ao formatter como `null` — o ECharts monta o bloco do tooltip sem marcar\n// `noValue`, então formata o vazio junto com o resto. O tipo público promete `number` ao\n// consumidor, e é esta guarda que mantém a promessa em vez de transformá-la em aviso.\nfunction nullSafeValueFormatter(\n input: TimeSeriesOptionInput,\n): ((value: number | null) => string) | undefined {\n const { valueFormatter } = input;\n if (!valueFormatter) return undefined;\n return (value: number | null) => (value === null ? \"\" : valueFormatter(value));\n}\n\nfunction seriesLabel(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { showValueLabels, theme } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n show: showValueLabels,\n position: \"top\",\n color: theme.labelColor,\n formatter: formatValue\n ? (params: { value: [number, number | null] }) => formatValue(params.value[1])\n : undefined,\n };\n}\n\nfunction seriesEntry(\n data: TimeSeriesData,\n input: TimeSeriesOptionInput,\n color: string,\n): Record<string, unknown> {\n const values: Array<[number, number | null]> = data.points.map((point: TimeSeriesPoint) => [\n point.timestamp,\n point.value,\n ]);\n const label: Record<string, unknown> = seriesLabel(input);\n\n if (input.displayType === \"bar\") {\n return { id: data.id, name: data.name, type: \"bar\", data: values, itemStyle: { color }, label };\n }\n\n return {\n id: data.id,\n name: data.name,\n type: \"line\",\n data: values,\n showSymbol: input.showSymbols,\n symbolSize: SYMBOL_SIZE_PX,\n lineStyle: {\n color,\n type: input.line.style ?? DEFAULT_LINE_STYLE,\n width: LINE_WIDTH_PX[input.line.width ?? DEFAULT_LINE_WIDTH],\n },\n itemStyle: { color },\n areaStyle: input.displayType === \"area\" ? { color, opacity: AREA_OPACITY } : undefined,\n label,\n };\n}\n\n// O retorno é `Record<string, unknown>` de propósito, e não `EChartsOption`: é o que impede\n// um tipo da biblioteca de vazar para o resto do design system.\nexport function buildTimeSeriesOption(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { series, legend, yAxis, theme, seriesColorOverrides } = input;\n const isLegendVisible: boolean = legend !== \"none\" && series.length > 0;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n\n return {\n animation: false,\n color: theme.seriesColors,\n textStyle: { fontFamily: theme.fontFamily, color: theme.labelColor },\n grid: {\n ...GRID_WITHOUT_LEGEND,\n top: isLegendVisible ? GRID_WITHOUT_LEGEND.top + LEGEND_HEIGHT_PX : GRID_WITHOUT_LEGEND.top,\n containLabel: false,\n },\n legend: isLegendVisible\n ? {\n type: \"scroll\",\n top: 0,\n left: 0,\n icon: \"roundRect\",\n itemHeight: 8,\n itemWidth: 12,\n textStyle: { color: theme.labelColor },\n }\n : { show: false },\n tooltip: {\n trigger: \"axis\",\n backgroundColor: theme.tooltipBackgroundColor,\n borderColor: theme.tooltipBorderColor,\n textStyle: { color: theme.labelColor },\n valueFormatter: formatValue,\n },\n xAxis: {\n type: \"time\",\n axisLine: { lineStyle: { color: theme.axisLineColor } },\n axisTick: { show: false },\n axisLabel: { color: theme.labelColor, hideOverlap: true, formatter: timeAxisLabel },\n splitLine: { show: false },\n },\n yAxis: {\n type: yAxis.scale === \"log\" ? \"log\" : \"value\",\n scale: yAxis.includeZero !== true,\n min: yAxis.min,\n max: yAxis.max,\n axisLine: { show: false },\n axisLabel: { color: theme.labelColor, formatter: formatValue },\n splitLine: { lineStyle: { color: theme.splitLineColor } },\n },\n series: series.map((data: TimeSeriesData, index: number) =>\n seriesEntry(\n data,\n input,\n seriesColorOverrides[data.id] ?? theme.seriesColors[index % theme.seriesColors.length],\n ),\n ),\n };\n}\n"],"names":["GRID_WITHOUT_LEGEND","SYMBOL_SIZE_PX","AREA_OPACITY","LINE_WIDTH_PX","DEFAULT_LINE_STYLE","DEFAULT_LINE_WIDTH","YEAR_LABEL","DAY_LABEL","MINUTE_LABEL","SECOND_LABEL","timeAxisLabel","timestamp","instant","nullSafeValueFormatter","input","valueFormatter","value","seriesLabel","showValueLabels","theme","formatValue","params","seriesEntry","data","color","values","point","label","buildTimeSeriesOption","series","legend","yAxis","seriesColorOverrides","isLegendVisible","index"],"mappings":"AAqDA,MAAMA,IAAsB,EAAE,KAAK,IAAI,OAAO,IAAI,QAAQ,IAAI,MAAM,GAAA,GAE9DC,IAAyB,GAEzBC,IAAuB,MAEvBC,IAAqD,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAA,GAElFC,IAA0C,SAE1CC,IAA0C,UAW1CC,IAAkC,IAAI,KAAK,eAAe,QAAW,EAAE,MAAM,WAAW,GAExFC,IAAiC,IAAI,KAAK,eAAe,QAAW;AAAA,EACxE,KAAK;AAAA,EACL,OAAO;AACT,CAAC,GAEKC,IAAoC,IAAI,KAAK,eAAe,QAAW;AAAA,EAC3E,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,CAAC,GAEKC,IAAoC,IAAI,KAAK,eAAe,QAAW;AAAA,EAC3E,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AACV,CAAC;AAED,SAASC,EAAcC,GAA2B;AAChD,QAAMC,IAAgB,IAAI,KAAKD,CAAS;AACxC,SAAIC,EAAQ,iBAAiB,KAAKA,EAAQ,gBAAA,MAAsB,IAAU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,QAAQ,QAAQ;AAAA,MACtC,OAAOA,EAAM,gBAAgB;AAAA,MAC7B,KAAKA,EAAM;AAAA,MACX,KAAKA,EAAM;AAAA,MACX,UAAU,EAAE,MAAM,GAAA;AAAA,MAClB,WAAW,EAAE,OAAOZ,EAAM,YAAY,WAAWC,EAAA;AAAA,MACjD,WAAW,EAAE,WAAW,EAAE,OAAOD,EAAM,iBAAe;AAAA,IAAE;AAAA,IAE1D,QAAQU,EAAO;AAAA,MAAI,CAACN,GAAsBW,MACxCZ;AAAA,QACEC;AAAA,QACAT;AAAA,QACAkB,EAAqBT,EAAK,EAAE,KAAKJ,EAAM,aAAae,IAAQf,EAAM,aAAa,MAAM;AAAA,MAAA;AAAA,IACvF;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"time-series-option.js","sources":["../../../../../../src/ui/components/charts/TimeSeriesChart/time-series-option.ts"],"sourcesContent":["import type { ChartTheme } from \"../chart-theme\";\n\nexport interface TimeSeriesPoint {\n timestamp: number;\n value: number | null;\n}\n\nexport interface TimeSeriesData {\n id: string;\n name: string;\n points: TimeSeriesPoint[];\n // Nome de token, nunca hex: é o que mantém a cor válida nos dois temas. Sem ele a série\n // recebe a próxima cor da paleta.\n colorToken?: string;\n}\n\nexport type TimeSeriesDisplayType = \"line\" | \"bar\" | \"area\";\n\nexport type TimeSeriesLineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport type TimeSeriesLineWidth = \"thin\" | \"normal\" | \"thick\";\n\nexport interface TimeSeriesLineOptions {\n style?: TimeSeriesLineStyle;\n width?: TimeSeriesLineWidth;\n}\n\nexport type TimeSeriesLegendMode = \"inline\" | \"none\";\n\nexport type TimeSeriesAxisScale = \"linear\" | \"log\";\n\nexport interface TimeSeriesYAxisOptions {\n scale?: TimeSeriesAxisScale;\n min?: number;\n max?: number;\n includeZero?: boolean;\n}\n\nexport interface TimeSeriesOptionInput {\n series: TimeSeriesData[];\n displayType: TimeSeriesDisplayType;\n line: TimeSeriesLineOptions;\n yAxis: TimeSeriesYAxisOptions;\n theme: ChartTheme;\n showSymbols: boolean;\n showValueLabels: boolean;\n seriesColorOverrides: Record<string, string>;\n valueFormatter?: (value: number) => string;\n}\n\n// A legenda saiu do canvas e virou HTML (`ChartLegend`), entao a grade nao reserva mais faixa\n// para ela: quem divide a altura agora e o flex do componente.\nconst GRID_PADDING = { top: 16, right: 16, bottom: 24, left: 56 } as const;\n\nconst SYMBOL_SIZE_PX: number = 6;\n\nconst AREA_OPACITY: number = 0.15;\n\nconst LINE_WIDTH_PX: Record<TimeSeriesLineWidth, number> = { thin: 1, normal: 2, thick: 4 };\n\nconst DEFAULT_LINE_STYLE: TimeSeriesLineStyle = \"solid\";\n\nconst DEFAULT_LINE_WIDTH: TimeSeriesLineWidth = \"normal\";\n\n// O eixo de tempo do ECharts rotula a marca de dia so com o numero do dia -- \"2\", \"3\", \"4\" --, que\n// sozinho nao diz nem o mes. Aqui a marca de dia vira data e a marca dentro do dia vira hora, que e\n// o que se espera de uma serie temporal.\n//\n// A precisao sai do proprio instante, e nao de um nivel pedido ao ECharts: ele alinha as marcas ao\n// nivel que cabe no eixo, entao meia-noite e marca de dia, minuto cheio e marca de hora, e assim por\n// diante. Ler o instante e o que permite usar `Intl` e escrever a data na convencao de quem le -- o\n// objeto de niveis do ECharts so aceita template, e um `{dd}/{MM}` fixo seria lido como mes/dia por\n// metade dos usuarios.\nconst YEAR_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, { year: \"numeric\" });\n\nconst DAY_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n day: \"2-digit\",\n month: \"2-digit\",\n});\n\nconst MINUTE_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: false,\n});\n\nconst SECOND_LABEL: Intl.DateTimeFormat = new Intl.DateTimeFormat(undefined, {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hour12: false,\n});\n\nfunction timeAxisLabel(timestamp: number): string {\n const instant: Date = new Date(timestamp);\n if (instant.getSeconds() !== 0 || instant.getMilliseconds() !== 0) return SECOND_LABEL.format(instant);\n if (instant.getHours() !== 0 || instant.getMinutes() !== 0) return MINUTE_LABEL.format(instant);\n // Primeiro de janeiro e a marca de ano do ECharts, e ali a data sem o ano nao situa ninguem.\n if (instant.getMonth() === 0 && instant.getDate() === 1) return YEAR_LABEL.format(instant);\n return DAY_LABEL.format(instant);\n}\n\n// O ponto de gap chega ao formatter como `null` — o ECharts monta o bloco do tooltip sem marcar\n// `noValue`, então formata o vazio junto com o resto. O tipo público promete `number` ao\n// consumidor, e é esta guarda que mantém a promessa em vez de transformá-la em aviso.\nfunction nullSafeValueFormatter(\n input: TimeSeriesOptionInput,\n): ((value: number | null) => string) | undefined {\n const { valueFormatter } = input;\n if (!valueFormatter) return undefined;\n return (value: number | null) => (value === null ? \"\" : valueFormatter(value));\n}\n\nfunction seriesLabel(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { showValueLabels, theme } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n show: showValueLabels,\n position: \"top\",\n color: theme.labelColor,\n formatter: formatValue\n ? (params: { value: [number, number | null] }) => formatValue(params.value[1])\n : undefined,\n };\n}\n\nfunction seriesEntry(\n data: TimeSeriesData,\n input: TimeSeriesOptionInput,\n color: string,\n): Record<string, unknown> {\n const values: Array<[number, number | null]> = data.points.map((point: TimeSeriesPoint) => [\n point.timestamp,\n point.value,\n ]);\n const label: Record<string, unknown> = seriesLabel(input);\n\n if (input.displayType === \"bar\") {\n return { id: data.id, name: data.name, type: \"bar\", data: values, itemStyle: { color }, label };\n }\n\n return {\n id: data.id,\n name: data.name,\n type: \"line\",\n data: values,\n showSymbol: input.showSymbols,\n symbolSize: SYMBOL_SIZE_PX,\n lineStyle: {\n color,\n type: input.line.style ?? DEFAULT_LINE_STYLE,\n width: LINE_WIDTH_PX[input.line.width ?? DEFAULT_LINE_WIDTH],\n },\n itemStyle: { color },\n areaStyle: input.displayType === \"area\" ? { color, opacity: AREA_OPACITY } : undefined,\n label,\n };\n}\n\n// O retorno é `Record<string, unknown>` de propósito, e não `EChartsOption`: é o que impede\n// um tipo da biblioteca de vazar para o resto do design system.\nexport function buildTimeSeriesOption(input: TimeSeriesOptionInput): Record<string, unknown> {\n const { series, yAxis, theme, seriesColorOverrides } = input;\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n\n return {\n animation: false,\n color: theme.seriesColors,\n textStyle: { fontFamily: theme.fontFamily, color: theme.labelColor },\n grid: {\n ...GRID_PADDING,\n containLabel: false,\n },\n tooltip: {\n trigger: \"axis\",\n backgroundColor: theme.tooltipBackgroundColor,\n borderColor: theme.tooltipBorderColor,\n textStyle: { color: theme.labelColor },\n valueFormatter: formatValue,\n },\n xAxis: {\n type: \"time\",\n axisLine: { lineStyle: { color: theme.axisLineColor } },\n axisTick: { show: false },\n axisLabel: { color: theme.labelColor, hideOverlap: true, formatter: timeAxisLabel },\n splitLine: { show: false },\n },\n yAxis: {\n type: yAxis.scale === \"log\" ? \"log\" : \"value\",\n scale: yAxis.includeZero !== true,\n min: yAxis.min,\n max: yAxis.max,\n axisLine: { show: false },\n axisLabel: { color: theme.labelColor, formatter: formatValue },\n splitLine: { lineStyle: { color: theme.splitLineColor } },\n },\n series: series.map((data: TimeSeriesData, index: number) =>\n seriesEntry(\n data,\n input,\n seriesColorOverrides[data.id] ?? theme.seriesColors[index % theme.seriesColors.length],\n ),\n ),\n };\n}\n"],"names":["GRID_PADDING","SYMBOL_SIZE_PX","AREA_OPACITY","LINE_WIDTH_PX","DEFAULT_LINE_STYLE","DEFAULT_LINE_WIDTH","YEAR_LABEL","DAY_LABEL","MINUTE_LABEL","SECOND_LABEL","timeAxisLabel","timestamp","instant","nullSafeValueFormatter","input","valueFormatter","value","seriesLabel","showValueLabels","theme","formatValue","params","seriesEntry","data","color","values","point","label","buildTimeSeriesO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B,EAAM;AAAA,MACvB,aAAaA,EAAM;AAAA,MACnB,WAAW,EAAE,OAAOA,EAAM,WAAA;AAAA,MAC1B,gBAAgBC;AAAA,IAAA;AAAA,IAElB,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU,EAAE,WAAW,EAAE,OAAOD,EAAM,gBAAc;AAAA,MACpD,UAAU,EAAE,MAAM,GAAA;AAAA,MAClB,WAAW,EAAE,OAAOA,EAAM,YAAY,aAAa,IAAM,WAAWT,EAAA;AAAA,MACpE,WAAW,EAAE,MAAM,GAAA;AAAA,IAAM;AAAA,IAE3B,OAAO;AAAA,MACL,MAAMoB,EAAM,UAAU,QAAQ,QAAQ;AAAA,MACtC,OAAOA,EAAM,gBAAgB;AAAA,MAC7B,KAAKA,EAAM;AAAA,MACX,KAAKA,EAAM;AAAA,MACX,UAAU,EAAE,MAAM,GAAA;AAAA,MAClB,WAAW,EAAE,OAAOX,EAAM,YAAY,WAAWC,EAAA;AAAA,MACjD,WAAW,EAAE,WAAW,EAAE,OAAOD,EAAM,iBAAe;AAAA,IAAE;AAAA,IAE1D,QAAQU,EAAO;AAAA,MAAI,CAACN,GAAsBS,MACxCV;AAAA,QACEC;AAAA,QACAT;AAAA,QACAiB,EAAqBR,EAAK,EAAE,KAAKJ,EAAM,aAAaa,IAAQb,EAAM,aAAa,MAAM;AAAA,MAAA;AAAA,IACvF;AAAA,EACF;AAEJ;"}
@@ -1,2 +1,5 @@
1
+ export * from "./ui/components/charts/BarChart/BarChart";
1
2
  export * from "./ui/components/charts/chart-palette";
3
+ export * from "./ui/components/charts/ChartColorPicker/ChartColorPicker";
4
+ export * from "./ui/components/charts/ChartLegend/ChartLegend";
2
5
  export * from "./ui/components/charts/TimeSeriesChart/TimeSeriesChart";
@@ -0,0 +1,18 @@
1
+ import { type ComponentPropsWithoutRef } from "react";
2
+ import { type ChartLegendLabels } from "../ChartLegend/ChartLegend";
3
+ import { type BarChartLegendMode, type BarChartOrientation, type BarChartSeriesData, type BarChartStacking, type BarChartValueAxisOptions, type BarChartValueLabel } from "./bar-chart-option";
4
+ import "./bar-chart.css";
5
+ export type { BarChartAxisScale, BarChartLegendMode, BarChartOrientation, BarChartPoint, BarChartSeriesData, BarChartStacking, BarChartValueAxisOptions, BarChartValueLabel, } from "./bar-chart-option";
6
+ export type BarChartProps = Omit<ComponentPropsWithoutRef<"div">, "children"> & {
7
+ categories: string[];
8
+ series: BarChartSeriesData[];
9
+ orientation?: BarChartOrientation;
10
+ stacking?: BarChartStacking;
11
+ valueLabel?: BarChartValueLabel;
12
+ legend?: BarChartLegendMode;
13
+ valueAxis?: BarChartValueAxisOptions;
14
+ valueFormatter?: (value: number) => string;
15
+ onSeriesColorChange?: (seriesId: string, colorToken: string | null) => void;
16
+ legendLabels?: Partial<ChartLegendLabels>;
17
+ };
18
+ export declare function BarChart({ categories, series, orientation, stacking, valueLabel, legend, valueAxis, valueFormatter, onSeriesColorChange, legendLabels, className, ...props }: BarChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import type { ChartTheme } from "../chart-theme";
2
+ export interface BarChartPoint {
3
+ category: string;
4
+ value: number | null;
5
+ }
6
+ export interface BarChartSeriesData {
7
+ id: string;
8
+ name: string;
9
+ points: BarChartPoint[];
10
+ colorToken?: string;
11
+ }
12
+ export type BarChartOrientation = "vertical" | "horizontal";
13
+ export type BarChartStacking = "off" | "stacked" | "percent";
14
+ export type BarChartValueLabel = "auto" | "always" | "never";
15
+ export type BarChartLegendMode = "inline" | "none";
16
+ export type BarChartAxisScale = "linear" | "log";
17
+ export interface BarChartValueAxisOptions {
18
+ scale?: BarChartAxisScale;
19
+ min?: number;
20
+ max?: number;
21
+ includeZero?: boolean;
22
+ }
23
+ export interface BarChartOptionInput {
24
+ categories: string[];
25
+ series: BarChartSeriesData[];
26
+ orientation: BarChartOrientation;
27
+ stacking: BarChartStacking;
28
+ valueLabel: BarChartValueLabel;
29
+ valueAxis: BarChartValueAxisOptions;
30
+ theme: ChartTheme;
31
+ seriesColorOverrides: Record<string, string>;
32
+ valueFormatter?: (value: number) => string;
33
+ }
34
+ export declare function buildBarChartOption(input: BarChartOptionInput): Record<string, unknown>;