blockforce-design-system 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +8 -1
- package/lib/ai/components.json +7 -7
- package/lib/ai/tokens.md +1 -1
- package/lib/commonjs/components/charts/bar-chart/bar-chart.comp.js +1 -1
- package/lib/commonjs/components/charts/bar-chart/bar-chart.comp.js.map +1 -1
- package/lib/commonjs/components/charts/chart-legend/chart-legend.comp.js.map +1 -1
- package/lib/commonjs/components/charts/doughnut-chart/doughnut-chart.comp.js +1 -1
- package/lib/commonjs/components/charts/doughnut-chart/doughnut-chart.comp.js.map +1 -1
- package/lib/commonjs/components/charts/line-chart/line-chart.comp.js +1 -1
- package/lib/commonjs/components/charts/line-chart/line-chart.comp.js.map +1 -1
- package/lib/commonjs/components/charts/treemap-chart/treemap-chart.comp.js +1 -1
- package/lib/commonjs/components/charts/treemap-chart/treemap-chart.comp.js.map +1 -1
- package/lib/index.d.ts +31 -11
- package/lib/module/components/charts/bar-chart/bar-chart.comp.js +1 -1
- package/lib/module/components/charts/bar-chart/bar-chart.comp.js.map +1 -1
- package/lib/module/components/charts/chart-legend/chart-legend.comp.js.map +1 -1
- package/lib/module/components/charts/doughnut-chart/doughnut-chart.comp.js +1 -1
- package/lib/module/components/charts/doughnut-chart/doughnut-chart.comp.js.map +1 -1
- package/lib/module/components/charts/line-chart/line-chart.comp.js +1 -1
- package/lib/module/components/charts/line-chart/line-chart.comp.js.map +1 -1
- package/lib/module/components/charts/treemap-chart/treemap-chart.comp.js +1 -1
- package/lib/module/components/charts/treemap-chart/treemap-chart.comp.js.map +1 -1
- package/llms-full.txt +18 -5
- package/llms.txt +10 -2
- package/package.json +1 -1
package/MIGRATION.md
CHANGED
|
@@ -248,7 +248,13 @@ Nenhuma prop foi removida.
|
|
|
248
248
|
- **+ `legend`:** `side` ou `bottom`.
|
|
249
249
|
- **`customContent`:** não tem mais o tamanho e a cor do texto sobrescritos pelo DS.
|
|
250
250
|
|
|
251
|
-
**BarChart, LineChart e TreemapChart:** usam a sombra e as cores de texto do tema.
|
|
251
|
+
**BarChart, LineChart e TreemapChart:** usam a sombra e as cores de texto do tema.
|
|
252
|
+
|
|
253
|
+
**Cores dos gráficos (DoughnutChart, BarChart, LineChart, TreemapChart):**
|
|
254
|
+
|
|
255
|
+
- **`color` aceita o nome do token:** `'chart.blue'`, além do valor (`theme.colors.chart.blue` ou hex). A `ChartLegend` já aceitava.
|
|
256
|
+
- **`color` ficou opcional** na rosca, na linha e no treemap: sem cor, a peça segue a ordem de `getChartColors`. A barra continua em `secondary` sem cor.
|
|
257
|
+
- **Gráfico usa só `chart.*`,** mesmo quando a fatia é um status. Os exemplos e as stories em hex e `success` foram trocados.
|
|
252
258
|
|
|
253
259
|
**Sem mudança de API:** `Image` e `TextLink`.
|
|
254
260
|
|
|
@@ -377,6 +383,7 @@ Use para landing, slides, vídeos e HTML sem React.
|
|
|
377
383
|
| `grey_6` e sombras | Novos valores (4.3). | Nada. |
|
|
378
384
|
| Modal (z-index 1200) | Listas próprias com z-index 1000 ficam atrás dele. | Suba essas listas para `theme.zIndex.dropdown` (1300). |
|
|
379
385
|
| Estilos do projeto que sobrescrevem estilos internos do DS | Podem ganhar ou perder pela ordem de carregamento dos estilos. | Revise as telas. O DoughnutChart foi um caso real, já corrigido. |
|
|
386
|
+
| TreemapChart com item sem `color` | O bloco sai na paleta de gráfico, na ordem de `getChartColors`, em vez de cinza (`#cccccc`). | Passe `color` no item para escolher. |
|
|
380
387
|
| Barra de rolagem de Modal, Autocomplete, Carousel, Drawer, Popover, Table, Calendar, SidePanel e Matrix | Fica fina (4px), com polegar `grey_4` e trilho transparente. No Carousel continua aparecendo só no hover. | Nada. Para a mesma barra nas telas do projeto, use `thinScrollbar`. |
|
|
381
388
|
|
|
382
389
|
### 6.2 Compatibilidades adicionadas
|
package/lib/ai/components.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blockforce-design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"storybook": "https://designsystem.blockforce.ai",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
@@ -4200,7 +4200,7 @@
|
|
|
4200
4200
|
{
|
|
4201
4201
|
"name": "BarChart",
|
|
4202
4202
|
"group": "Gráficos",
|
|
4203
|
-
"description": "Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\nCada item de `data` é uma barra, com `name` e `value`.\nPara evolução no tempo use LineChart; para partes de um total use DoughnutChart.",
|
|
4203
|
+
"description": "Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\nCada item de `data` é uma barra, com `name` e `value`.\nPara evolução no tempo use LineChart; para partes de um total use DoughnutChart.\nCor da barra pela paleta de gráfico (`color: 'chart.purple'`), mesmo quando a barra é um status.",
|
|
4204
4204
|
"examples": [
|
|
4205
4205
|
"<BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />"
|
|
4206
4206
|
],
|
|
@@ -4310,7 +4310,7 @@
|
|
|
4310
4310
|
"group": "Gráficos",
|
|
4311
4311
|
"description": "Legenda de gráfico: bolinha na cor da série, nome e valor opcional.\nUse ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.\n`variant=\"square\"` é a legenda das roscas das dashboards: quadradinho e \"Nome: valor\".",
|
|
4312
4312
|
"examples": [
|
|
4313
|
-
"<ChartLegend items={[{ label: 'Aprovados', color: '
|
|
4313
|
+
"<ChartLegend items={[{ label: 'Aprovados', color: 'chart.blue', value: '60%' }]} />",
|
|
4314
4314
|
"<ChartLegend variant=\"square\" direction=\"column\" items={[{ label: 'Pendentes', color: 'chart.purple', value: 850 }]} />"
|
|
4315
4315
|
],
|
|
4316
4316
|
"aliases": [],
|
|
@@ -4353,9 +4353,9 @@
|
|
|
4353
4353
|
{
|
|
4354
4354
|
"name": "DoughnutChart",
|
|
4355
4355
|
"group": "Gráficos",
|
|
4356
|
-
"description": "Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n`parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n`legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\nUse com até 5 fatias. Com mais categorias use BarChart.",
|
|
4356
|
+
"description": "Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n`parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n`legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\nUse com até 5 fatias. Com mais categorias use BarChart.\nAs fatias usam a paleta de gráfico (`chart.*`), mesmo quando cada uma é um status: passe o nome\n(`color: 'chart.blue'`) ou deixe sem cor, que a rosca segue a ordem de `getChartColors`.",
|
|
4357
4357
|
"examples": [
|
|
4358
|
-
"<DoughnutChart totalValue={100} parts={[{ value: 60, color: '
|
|
4358
|
+
"<DoughnutChart totalValue={100} parts={[{ value: 60, color: 'chart.blue', name: 'Aprovados' }]} />"
|
|
4359
4359
|
],
|
|
4360
4360
|
"aliases": [],
|
|
4361
4361
|
"docs": "https://designsystem.blockforce.ai/?path=/docs/gráficos-doughnutchart--docs",
|
|
@@ -4460,7 +4460,7 @@
|
|
|
4460
4460
|
"group": "Gráficos",
|
|
4461
4461
|
"description": "Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).\n`showArea` preenche a área abaixo da linha.\nPara comparar categorias sem ordem de tempo use BarChart.",
|
|
4462
4462
|
"examples": [
|
|
4463
|
-
"<LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: '
|
|
4463
|
+
"<LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: 'chart.purple' }]} />"
|
|
4464
4464
|
],
|
|
4465
4465
|
"aliases": [],
|
|
4466
4466
|
"docs": "https://designsystem.blockforce.ai/?path=/docs/gráficos-linechart--docs",
|
|
@@ -4542,7 +4542,7 @@
|
|
|
4542
4542
|
{
|
|
4543
4543
|
"name": "TreemapChart",
|
|
4544
4544
|
"group": "Gráficos",
|
|
4545
|
-
"description": "Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).\nPara poucas categorias use BarChart ou DoughnutChart.",
|
|
4545
|
+
"description": "Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).\nPara poucas categorias use BarChart ou DoughnutChart.\nCor de cada bloco pela paleta de gráfico (`color: 'chart.lilac'`); sem cor, segue a ordem de\n`getChartColors`.",
|
|
4546
4546
|
"examples": [
|
|
4547
4547
|
"<TreemapChart data={[{ name: 'Algodão', value: 120 }, { name: 'Poliéster', value: 40 }]} />"
|
|
4548
4548
|
],
|
package/lib/ai/tokens.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("styled-components"),t=require("./bar-chart.styles.js"),o=require("../../../node_modules/recharts/es6/component/ResponsiveContainer.js"),s=require("../../../node_modules/recharts/es6/chart/BarChart.js"),i=require("../../../node_modules/recharts/es6/cartesian/CartesianGrid.js"),a=require("../../../node_modules/recharts/es6/cartesian/XAxis.js"),l=require("../../../node_modules/recharts/es6/cartesian/YAxis.js"),n=require("../../../node_modules/recharts/es6/component/Tooltip.js"),h=require("../../../node_modules/recharts/es6/cartesian/Bar.js"),d=require("../../../node_modules/recharts/es6/component/Cell.js"),c=require("../../../node_modules/recharts/es6/component/LabelList.js"),m=require("../../../theme/theme.util.js"),u=require("../../typography/text/text.comp.js");const g=({active:r,payload:o,label:s})=>r&&o&&o.length?e.jsxs(t.CustomTooltip,{direction:"column",gap:1,children:[e.jsx(u.Text,{size:"small",fontWeight:500,children:s}),o.map(((r,t)=>e.jsx(u.Text,{size:"small",color:r.color||r.payload?.color,children:r.value},t)))]}):null;exports.BarChart=({width:u="100%",height:p=300,data:x,showGrid:j=!0,xAxisLabel:y,yAxisLabel:C,yAxisFormatter:f,barSize:b,radius:_,showLabels:T=!1,labelFormatter:q,barCategoryGap:v})=>{const z=r.useTheme();return e.jsx(t.ChartContainer,{"data-testid":"bar-chart",width:u,height:p,children:e.jsx(o.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(s.BarChart,{width:"number"==typeof u?u:500,height:p,data:x,margin:{top:T?20:5,right:30,left:20,bottom:5},barCategoryGap:v,children:[j&&e.jsx(i.CartesianGrid,{strokeDasharray:"3 3",stroke:m.getThemeColor("grey_4",z),horizontal:!0,vertical:!1}),e.jsx(a.XAxis,{dataKey:"name",stroke:m.getThemeColor("grey_3",z),tick:{fill:m.getThemeColor("grey_2",z),fontSize:12},label:y?{value:y,position:"insideBottom",offset:-5,style:{fill:m.getThemeColor("grey_2",z),fontSize:12}}:void 0}),e.jsx(l.YAxis,{stroke:m.getThemeColor("grey_3",z),tick:{fill:m.getThemeColor("grey_2",z),fontSize:12},tickFormatter:f,label:C?{value:C,angle:-90,position:"insideLeft",style:{fill:m.getThemeColor("grey_2",z),fontSize:12}}:void 0}),e.jsx(n.Tooltip,{content:e.jsx(g,{})}),e.jsxs(h.Bar,{dataKey:"value",barSize:b,radius:(e=>{if(e)return"number"==typeof e?[e,e,0,0]:e})(_),children:[x.map(((r,t)=>e.jsx(d.Cell,{fill:r.color||
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("styled-components"),t=require("./bar-chart.styles.js"),o=require("../../../node_modules/recharts/es6/component/ResponsiveContainer.js"),s=require("../../../node_modules/recharts/es6/chart/BarChart.js"),i=require("../../../node_modules/recharts/es6/cartesian/CartesianGrid.js"),a=require("../../../node_modules/recharts/es6/cartesian/XAxis.js"),l=require("../../../node_modules/recharts/es6/cartesian/YAxis.js"),n=require("../../../node_modules/recharts/es6/component/Tooltip.js"),h=require("../../../node_modules/recharts/es6/cartesian/Bar.js"),d=require("../../../node_modules/recharts/es6/component/Cell.js"),c=require("../../../node_modules/recharts/es6/component/LabelList.js"),m=require("../../../theme/theme.util.js"),u=require("../../typography/text/text.comp.js");const g=({active:r,payload:o,label:s})=>r&&o&&o.length?e.jsxs(t.CustomTooltip,{direction:"column",gap:1,children:[e.jsx(u.Text,{size:"small",fontWeight:500,children:s}),o.map(((r,t)=>e.jsx(u.Text,{size:"small",color:r.color||r.payload?.color,children:r.value},t)))]}):null;exports.BarChart=({width:u="100%",height:p=300,data:x,showGrid:j=!0,xAxisLabel:y,yAxisLabel:C,yAxisFormatter:f,barSize:b,radius:_,showLabels:T=!1,labelFormatter:q,barCategoryGap:v})=>{const z=r.useTheme();return e.jsx(t.ChartContainer,{"data-testid":"bar-chart",width:u,height:p,children:e.jsx(o.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(s.BarChart,{width:"number"==typeof u?u:500,height:p,data:x,margin:{top:T?20:5,right:30,left:20,bottom:5},barCategoryGap:v,children:[j&&e.jsx(i.CartesianGrid,{strokeDasharray:"3 3",stroke:m.getThemeColor("grey_4",z),horizontal:!0,vertical:!1}),e.jsx(a.XAxis,{dataKey:"name",stroke:m.getThemeColor("grey_3",z),tick:{fill:m.getThemeColor("grey_2",z),fontSize:12},label:y?{value:y,position:"insideBottom",offset:-5,style:{fill:m.getThemeColor("grey_2",z),fontSize:12}}:void 0}),e.jsx(l.YAxis,{stroke:m.getThemeColor("grey_3",z),tick:{fill:m.getThemeColor("grey_2",z),fontSize:12},tickFormatter:f,label:C?{value:C,angle:-90,position:"insideLeft",style:{fill:m.getThemeColor("grey_2",z),fontSize:12}}:void 0}),e.jsx(n.Tooltip,{content:e.jsx(g,{})}),e.jsxs(h.Bar,{dataKey:"value",barSize:b,radius:(e=>{if(e)return"number"==typeof e?[e,e,0,0]:e})(_),children:[x.map(((r,t)=>e.jsx(d.Cell,{fill:m.getThemeColor(r.color||"secondary",z)},`cell-${t}`))),T&&e.jsx(c.LabelList,{position:"top",formatter:e=>q?q(e):e,style:{fill:m.getThemeColor("grey_1",z),fontSize:12}})]})]})})})};
|
|
2
2
|
//# sourceMappingURL=bar-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-chart.comp.js","sources":["../../../../../src/components/charts/bar-chart/bar-chart.comp.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as BarChartRecharts,\n CartesianGrid,\n Cell,\n LabelList,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { BarChartProps } from './bar-chart.types'\n\nimport * as Styles from './bar-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text\n key={index}\n size=\"small\"\n color={entry.color || entry.payload?.color}\n >\n {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\n * Cada item de `data` é uma barra, com `name` e `value`.\n * Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.\n * @example <BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />\n */\nexport const BarChart = ({\n width = '100%',\n height = 300,\n data,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n barSize,\n radius,\n showLabels = false,\n labelFormatter,\n barCategoryGap,\n}: BarChartProps) => {\n const theme = useTheme()\n\n // Converte radius numérico para array [topLeft, topRight, 0, 0] (apenas cantos superiores)\n const getRadiusValue = (\n radiusValue?: number | [number, number, number, number],\n ) => {\n if (!radiusValue) return undefined\n if (typeof radiusValue === 'number') {\n return [radiusValue, radiusValue, 0, 0] as [\n number,\n number,\n number,\n number,\n ]\n }\n return radiusValue\n }\n\n return (\n <Styles.ChartContainer\n data-testid=\"bar-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChartRecharts\n width={typeof width === 'number' ? width : 500}\n height={height}\n data={data}\n margin={{ top: showLabels ? 20 : 5, right: 30, left: 20, bottom: 5 }}\n barCategoryGap={barCategoryGap}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n <Bar\n dataKey=\"value\"\n barSize={barSize}\n radius={getRadiusValue(radius)}\n >\n {data.map((entry, index) => (\n <Cell\n key={`cell-${index}`}\n fill={entry.color ||
|
|
1
|
+
{"version":3,"file":"bar-chart.comp.js","sources":["../../../../../src/components/charts/bar-chart/bar-chart.comp.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as BarChartRecharts,\n CartesianGrid,\n Cell,\n LabelList,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { BarChartProps } from './bar-chart.types'\n\nimport * as Styles from './bar-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text\n key={index}\n size=\"small\"\n color={entry.color || entry.payload?.color}\n >\n {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\n * Cada item de `data` é uma barra, com `name` e `value`.\n * Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.\n * Cor da barra pela paleta de gráfico (`color: 'chart.purple'`), mesmo quando a barra é um status.\n * @example <BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />\n */\nexport const BarChart = ({\n width = '100%',\n height = 300,\n data,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n barSize,\n radius,\n showLabels = false,\n labelFormatter,\n barCategoryGap,\n}: BarChartProps) => {\n const theme = useTheme()\n\n // Converte radius numérico para array [topLeft, topRight, 0, 0] (apenas cantos superiores)\n const getRadiusValue = (\n radiusValue?: number | [number, number, number, number],\n ) => {\n if (!radiusValue) return undefined\n if (typeof radiusValue === 'number') {\n return [radiusValue, radiusValue, 0, 0] as [\n number,\n number,\n number,\n number,\n ]\n }\n return radiusValue\n }\n\n return (\n <Styles.ChartContainer\n data-testid=\"bar-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChartRecharts\n width={typeof width === 'number' ? width : 500}\n height={height}\n data={data}\n margin={{ top: showLabels ? 20 : 5, right: 30, left: 20, bottom: 5 }}\n barCategoryGap={barCategoryGap}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n <Bar\n dataKey=\"value\"\n barSize={barSize}\n radius={getRadiusValue(radius)}\n >\n {data.map((entry, index) => (\n <Cell\n key={`cell-${index}`}\n fill={getThemeColor(entry.color || 'secondary', theme)}\n />\n ))}\n {showLabels && (\n <LabelList\n position=\"top\"\n formatter={(value: number) =>\n labelFormatter ? labelFormatter(value) : value\n }\n // style aqui é a API do recharts para o texto do rótulo, não CSS inline em elemento HTML\n // eslint-disable-next-line no-restricted-syntax\n style={{\n fill: getThemeColor('grey_1', theme),\n fontSize: 12,\n }}\n />\n )}\n </Bar>\n </BarChartRecharts>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomTooltip","active","payload","label","length","_jsxs","Styles","direction","gap","_jsx","jsx","Text","size","fontWeight","children","map","entry","index","color","value","BarChart","width","height","data","showGrid","xAxisLabel","yAxisLabel","yAxisFormatter","barSize","radius","showLabels","labelFormatter","barCategoryGap","theme","useTheme","ResponsiveContainer","BarChartRecharts","margin","top","right","left","bottom","CartesianGrid","strokeDasharray","stroke","getThemeColor","horizontal","vertical","XAxis","dataKey","tick","fill","fontSize","position","offset","style","undefined","YAxis","tickFormatter","angle","Tooltip","content","jsxs","Bar","radiusValue","getRadiusValue","Cell","LabelList","formatter"],"mappings":"+zBAoBA,MAAMA,EAAgBA,EAAGC,SAAQC,UAASC,WACnCF,GAAWC,GAAYA,EAAQE,OAGlCC,EAAAA,KAACC,EAAAA,cAAqB,CAAAC,UAAU,SAASC,IAAK,YAC5CC,EAACC,I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AAQ,GACRN,SAAU,aACVE,MAAO,CACLJ,KAAMN,EAAAA,cAAc,SAAUZ,GAC9BmB,SAAU,UAGdI,IAGR/C,MAACmD,UAAO,CAACC,QAASpD,EAAAA,IAACT,EAAgB,MACnCK,EAACyD,KAAAC,OACCd,QAAQ,QACRrB,QAASA,EACTC,OA5ERmC,KAEA,GAAKA,EACL,MAA2B,iBAAhBA,EACF,CAACA,EAAaA,EAAa,EAAG,GAOhCA,CAAW,EAiEFC,CAAepC,aAEtBN,EAAKR,KAAI,CAACC,EAAOC,IAChBR,EAAAC,IAACwD,OAAI,CAEHf,KAAMN,EAAAA,cAAc7B,EAAME,OAAS,YAAae,IADnC,QAAAhB,OAIhBa,GACCrB,EAACC,IAAAyD,aACCd,SAAS,MACTe,UAAYjD,GACVY,EAAiBA,EAAeZ,GAASA,EAI3CoC,MAAO,CACLJ,KAAMN,EAAAA,cAAc,SAAUZ,GAC9BmB,SAAU,eAOA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-legend.comp.js","sources":["../../../../../src/components/charts/chart-legend/chart-legend.comp.tsx"],"sourcesContent":["import { ChartLegendProps } from './chart-legend.types'\n\nimport * as Styles from './chart-legend.styles'\n\n/**\n * Legenda de gráfico: bolinha na cor da série, nome e valor opcional.\n * Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.\n * `variant=\"square\"` é a legenda das roscas das dashboards: quadradinho e \"Nome: valor\".\n * @example <ChartLegend items={[{ label: 'Aprovados', color: '
|
|
1
|
+
{"version":3,"file":"chart-legend.comp.js","sources":["../../../../../src/components/charts/chart-legend/chart-legend.comp.tsx"],"sourcesContent":["import { ChartLegendProps } from './chart-legend.types'\n\nimport * as Styles from './chart-legend.styles'\n\n/**\n * Legenda de gráfico: bolinha na cor da série, nome e valor opcional.\n * Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.\n * `variant=\"square\"` é a legenda das roscas das dashboards: quadradinho e \"Nome: valor\".\n * @example <ChartLegend items={[{ label: 'Aprovados', color: 'chart.blue', value: '60%' }]} />\n * @example <ChartLegend variant=\"square\" direction=\"column\" items={[{ label: 'Pendentes', color: 'chart.purple', value: 850 }]} />\n */\nexport const ChartLegend = ({\n items,\n direction = 'row',\n variant = 'dot',\n}: ChartLegendProps) => (\n <Styles.List\n $direction={direction}\n $variant={variant}\n data-testid=\"chart-legend\"\n >\n {items.map((item) => (\n <Styles.Item key={item.label} $variant={variant}>\n <Styles.Marker\n $color={item.color}\n $variant={variant}\n aria-hidden=\"true\"\n />\n {variant === 'square' ? (\n <Styles.Label title={item.label}>\n {item.label}\n {item.value !== undefined && <>: {item.value}</>}\n </Styles.Label>\n ) : (\n <>\n <Styles.Label title={item.label}>{item.label}</Styles.Label>\n {item.value !== undefined && (\n <Styles.Value $direction={direction}>{item.value}</Styles.Value>\n )}\n </>\n )}\n </Styles.Item>\n ))}\n </Styles.List>\n)\n"],"names":["ChartLegend","items","direction","variant","_jsx","Styles","$direction","$variant","children","map","item","_jsxs","jsx","color","title","label","undefined","value","jsxs","_Fragment"],"mappings":"0GAW2BA,EACzBC,QACAC,YAAY,MACZC,UAAU,SAEVC,EAAAA,IAACC,EAAAA,KACa,CAAAC,WAAAJ,EACFK,SAAAJ,gBACE,eAAcK,SAEzBP,EAAMQ,KAAKC,GACVC,EAAAA,KAACN,EAAAA,KAAuC,CAAAE,SAAAJ,YACtCC,EAACQ,IAAAP,iBACSK,EAAKG,MAAKN,SACRJ,EAAO,cACL,SAED,WAAZA,EACCQ,EAAAA,KAACN,EAAAA,MAAY,CAACS,MAAOJ,EAAKK,MAAKP,SAAA,CAC5BE,EAAKK,WACUC,IAAfN,EAAKO,OAAuBN,kCAAKD,EAAKO,YAGzCN,EAAAO,KAAAC,WAAA,CAAAX,SAAA,CACEJ,EAACQ,IAAAP,QAAY,CAACS,MAAOJ,EAAKK,MAAQP,SAAAE,EAAKK,aACvBC,IAAfN,EAAKO,OACJb,EAAAA,IAACC,EAAAA,MAAyB,CAAAC,WAAAJ,EAAYM,SAAAE,EAAKO,aAfjCP,EAAKK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("styled-components"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("styled-components"),a=require("./doughnut-chart.styles.js"),l=require("../../../theme/chart-colors.js"),s=require("../../../node_modules/recharts/es6/chart/PieChart.js"),i=require("../../../node_modules/recharts/es6/polar/Pie.js"),n=require("../../../node_modules/recharts/es6/component/Cell.js"),o=require("../../../node_modules/recharts/es6/component/Tooltip.js"),u=require("../chart-legend/chart-legend.comp.js"),c=require("../../../theme/theme.util.js"),d=require("../../typography/text/text.comp.js");const h=e=>e.name?{"aria-label":`${e.name}: ${e.display??e.value}`}:{"aria-hidden":"true"};exports.DoughnutChart=({size:m=200,totalValue:p,parts:j,fontSize:x,showTotalValue:g=!0,showTooltip:C=!1,tooltipValueFormatter:T,disableAnimation:v=!1,customContent:q,legend:y})=>{const f=r.useTheme(),A=l.CHART_COLOR_ORDER.map((e=>c.getThemeColor(`chart.${e}`,f))),$=(e,t)=>c.getThemeColor(e.color??A[t%A.length],f),[_,z]=t.useState([]),[R,P]=t.useState(!1),w=t.useId();t.useEffect((()=>{const e=j.reduce(((e,t)=>e+t.value),0),t=[...j];e!==p&&(1===j.length?(P(!0),t.push({value:p-e,color:"transparent",display:"none"})):t.push({value:p-e,color:c.getThemeColor("grey_5",f)})),z([...t])}),[j]);const S={dataKey:"value",innerRadius:m/2*.75,outerRadius:m/2,startAngle:90,endAngle:-270},b=e.jsxs(a.ChartContainer,{"data-testid":"doughnut-chart",size:m,children:[q?e.jsx(a.CenterText,{children:q}):g&&e.jsxs(a.TotalText,{fontSize:x,children:[e.jsx("small",{children:"Total"}),e.jsx("p",{children:p})]}),e.jsxs(s.PieChart,{width:m,height:m,id:w,children:[(R||!p)&&e.jsx(i.Pie,{data:[{value:1}],fill:c.getThemeColor("grey_5",f),animationDuration:0,isAnimationActive:!v,...S,children:e.jsx(n.Cell,{"aria-hidden":"true"})}),p&&e.jsx(i.Pie,{data:_,paddingAngle:1===_.length?0:3,cornerRadius:10,isAnimationActive:!v,...S,children:_.map(((t,r)=>e.jsx(n.Cell,{fill:$(t,r),...h(t)},`cell-${r}`)))}),C&&e.jsx(o.Tooltip,{content:({active:t,payload:r})=>{const l=r?.[0]?.name&&"string"==typeof r[0].name;return t?e.jsx(a.CustomTooltip,{direction:"column",children:l?e.jsxs(e.Fragment,{children:[e.jsx(d.Text,{size:"small",fontWeight:500,children:`${r[0].name}`}),e.jsx(d.Text,{size:"small",children:`${T?T(r[0].value):r[0].value}`})]}):e.jsx(d.Text,{size:"small",children:`${T?T(r[0].value):r[0].value}`})}):null}})]})]});return y?e.jsxs(a.WithLegend,{$position:y,children:[b,e.jsx(u.ChartLegend,{direction:"side"===y?"column":"row",items:j.map(((e,t)=>({part:e,color:$(e,t)}))).filter((({part:e})=>e.name)).map((({part:e,color:t})=>({label:e.name,color:t,value:e.display??e.value})))})]}):b};
|
|
2
2
|
//# sourceMappingURL=doughnut-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doughnut-chart.comp.js","sources":["../../../../../src/components/charts/doughnut-chart/doughnut-chart.comp.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react'\n\nimport { Cell, Pie, PieChart, Tooltip } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\nimport { ChartLegend } from '../chart-legend'\n\nimport { DoughnutChartProps, PartsProps } from './doughnut-chart.types'\n\nimport * as Styles from './doughnut-chart.styles'\n\n/** Fatia com nome vira imagem com texto alternativo; fatia sem nome (restante) fica fora do leitor de tela. */\nconst getCellA11yProps = (part: PartsProps) =>\n part.name\n ? { 'aria-label': `${part.name}: ${part.display ?? part.value}` }\n : { 'aria-hidden': 'true' as const }\n\n/**\n * Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n * `parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n * `legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\n * Use com até 5 fatias. Com mais categorias use BarChart.\n * @example <DoughnutChart totalValue={100} parts={[{ value: 60, color: '
|
|
1
|
+
{"version":3,"file":"doughnut-chart.comp.js","sources":["../../../../../src/components/charts/doughnut-chart/doughnut-chart.comp.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react'\n\nimport { Cell, Pie, PieChart, Tooltip } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\nimport { ChartLegend } from '../chart-legend'\n\nimport { DoughnutChartProps, PartsProps } from './doughnut-chart.types'\n\nimport * as Styles from './doughnut-chart.styles'\n\n/** Fatia com nome vira imagem com texto alternativo; fatia sem nome (restante) fica fora do leitor de tela. */\nconst getCellA11yProps = (part: PartsProps) =>\n part.name\n ? { 'aria-label': `${part.name}: ${part.display ?? part.value}` }\n : { 'aria-hidden': 'true' as const }\n\n/**\n * Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n * `parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n * `legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\n * Use com até 5 fatias. Com mais categorias use BarChart.\n * As fatias usam a paleta de gráfico (`chart.*`), mesmo quando cada uma é um status: passe o nome\n * (`color: 'chart.blue'`) ou deixe sem cor, que a rosca segue a ordem de `getChartColors`.\n * @example <DoughnutChart totalValue={100} parts={[{ value: 60, color: 'chart.blue', name: 'Aprovados' }]} />\n */\nexport const DoughnutChart = ({\n size = 200,\n totalValue,\n parts,\n fontSize,\n showTotalValue = true,\n showTooltip = false,\n tooltipValueFormatter,\n disableAnimation = false,\n customContent,\n legend,\n}: DoughnutChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const colorOf = (part: PartsProps, index: number) =>\n getThemeColor(part.color ?? chartColors[index % chartColors.length], theme)\n\n const [adjustedParts, setAdjustedParts] = useState<PartsProps[]>([])\n const [showBackground, setShowBackground] = useState(false)\n\n const chartId = useId()\n\n useEffect(() => {\n const totalSum = parts.reduce((sum, part) => sum + part.value, 0)\n const auxParts = [...parts]\n\n if (totalSum !== totalValue) {\n if (parts.length === 1) {\n setShowBackground(true)\n auxParts.push({\n value: totalValue - totalSum,\n color: 'transparent',\n display: 'none',\n })\n } else {\n auxParts.push({\n value: totalValue - totalSum,\n color: getThemeColor('grey_5', theme),\n })\n }\n }\n setAdjustedParts([...auxParts])\n }, [parts])\n\n const defaultPieChartProps = {\n dataKey: 'value',\n innerRadius: (size / 2) * 0.75,\n outerRadius: size / 2,\n startAngle: 90,\n endAngle: -270,\n }\n\n const CustomTooltip = ({ active, payload }: any) => {\n const hasName = payload?.[0]?.name && typeof payload[0].name === 'string'\n\n if (!active) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\">\n {hasName ? (\n <>\n <Text size=\"small\" fontWeight={500}>{`${payload[0].name}`}</Text>\n <Text size=\"small\">{`${tooltipValueFormatter ? tooltipValueFormatter(payload[0].value) : payload[0].value}`}</Text>\n </>\n ) : (\n <Text size=\"small\">{`${tooltipValueFormatter ? tooltipValueFormatter(payload[0].value) : payload[0].value}`}</Text>\n )}\n </Styles.CustomTooltip>\n )\n }\n\n const chart = (\n <Styles.ChartContainer data-testid=\"doughnut-chart\" size={size}>\n {customContent ? (\n <Styles.CenterText>{customContent}</Styles.CenterText>\n ) : (\n showTotalValue && (\n <Styles.TotalText fontSize={fontSize}>\n <small>Total</small>\n <p>{totalValue}</p>\n </Styles.TotalText>\n )\n )}\n <PieChart width={size} height={size} id={chartId}>\n {(showBackground || !totalValue) && (\n <Pie\n data={[{ value: 1 }]}\n fill={getThemeColor('grey_5', theme)}\n animationDuration={0}\n isAnimationActive={!disableAnimation}\n {...defaultPieChartProps}\n >\n <Cell aria-hidden=\"true\" />\n </Pie>\n )}\n\n {totalValue && (\n <Pie\n data={adjustedParts}\n paddingAngle={adjustedParts.length === 1 ? 0 : 3}\n cornerRadius={10}\n isAnimationActive={!disableAnimation}\n {...defaultPieChartProps}\n >\n {adjustedParts.map((part, index) => (\n <Cell\n key={`cell-${index}`}\n fill={colorOf(part, index)}\n {...getCellA11yProps(part)}\n />\n ))}\n </Pie>\n )}\n\n {showTooltip && <Tooltip content={CustomTooltip} />}\n </PieChart>\n </Styles.ChartContainer>\n )\n\n if (!legend) return chart\n\n return (\n <Styles.WithLegend $position={legend}>\n {chart}\n <ChartLegend\n direction={legend === 'side' ? 'column' : 'row'}\n items={parts\n .map((part, index) => ({ part, color: colorOf(part, index) }))\n .filter(({ part }) => part.name)\n .map(({ part, color }) => ({\n label: part.name as string,\n color,\n value: part.display ?? part.value,\n }))}\n />\n </Styles.WithLegend>\n )\n}\n"],"names":["getCellA11yProps","part","name","display","value","DoughnutChart","size","totalValue","parts","fontSize","showTotalValue","showTooltip","tooltipValueFormatter","disableAnimation","customContent","legend","theme","useTheme","chartColors","CHART_COLOR_ORDER","map","getThemeColor","colorOf","index","color","length","adjustedParts","setAdjustedParts","useState","showBackground","setShowBackground","chartId","useId","useEffect","totalSum","reduce","sum","auxParts","push","defaultPieChartProps","dataKey","innerRadius","outerRadius","startAngle","endAngle","chart","_jsxs","jsxs","Styles","_jsx","jsx","children","PieChart","width","height","id","Pie","data","fill","animationDuration","isAnimationActive","Cell","paddingAngle","cornerRadius","Tooltip","content","CustomTooltip","active","payload","hasName","direction","_Fragment","Text","fontWeight","$position","ChartLegend","items","filter","label"],"mappings":"wkBAcA,MAAMA,EAAoBC,GACxBA,EAAKC,KACD,CAAE,aAAc,GAAGD,EAAKC,SAASD,EAAKE,SAAWF,EAAKG,SACtD,CAAE,cAAe,8BAWMC,EAC3BC,OAAO,IACPC,aACAC,QACAC,WACAC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AO,EAAG5E,UAAWA,EAAKC,OAC1BkB,KAAI,EAAGnB,OAAMuB,YAAa,CACzBsD,MAAO7E,EAAKC,KACZsB,QACApB,MAAOH,EAAKE,SAAWF,EAAKG,eAblByC,CAgBE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("styled-components"),r=require("./line-chart.styles.js"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("styled-components"),r=require("./line-chart.styles.js"),o=require("../../../node_modules/recharts/es6/component/ResponsiveContainer.js"),s=require("../../../node_modules/recharts/es6/cartesian/CartesianGrid.js"),i=require("../../../node_modules/recharts/es6/cartesian/XAxis.js"),a=require("../../../node_modules/recharts/es6/cartesian/YAxis.js"),l=require("../../../node_modules/recharts/es6/component/Tooltip.js"),n=require("../../../node_modules/recharts/es6/cartesian/Area.js"),h=require("../../../node_modules/recharts/es6/cartesian/Line.js"),d=require("../../../node_modules/recharts/es6/chart/AreaChart.js"),c=require("../../../node_modules/recharts/es6/chart/LineChart.js"),m=require("../../../theme/chart-colors.js"),u=require("../../../theme/theme.util.js"),g=require("../../typography/text/text.comp.js");const j=({active:t,payload:o,label:s})=>t&&o&&o.length?e.jsxs(r.CustomTooltip,{direction:"column",gap:1,children:[e.jsx(g.Text,{size:"small",fontWeight:500,children:s}),o.map(((t,r)=>e.jsxs(g.Text,{size:"small",color:t.color,children:[t.name,": ",t.value]},r)))]}):null;exports.LineChart=({width:g=500,height:x=300,data:y,series:p,showArea:C=!1,showGrid:_=!0,xAxisLabel:T,yAxisLabel:f,yAxisFormatter:q})=>{const k=t.useTheme(),A=m.CHART_COLOR_ORDER.map((e=>u.getThemeColor(`chart.${e}`,k))),v=(e,t)=>u.getThemeColor(e??A[t%A.length],k),L=C?d.AreaChart:c.LineChart;return e.jsx(r.ChartContainer,{"data-testid":"line-chart",width:g,height:x,children:e.jsx(o.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(L,{width:g,height:x,data:y,margin:{top:5,right:30,left:20,bottom:5},children:[_&&e.jsx(s.CartesianGrid,{strokeDasharray:"3 3",stroke:u.getThemeColor("grey_4",k),horizontal:!0,vertical:!1}),e.jsx(i.XAxis,{dataKey:"name",stroke:u.getThemeColor("grey_3",k),tick:{fill:u.getThemeColor("grey_2",k),fontSize:12},label:T?{value:T,position:"insideBottom",offset:-5,style:{fill:u.getThemeColor("grey_2",k),fontSize:12}}:void 0}),e.jsx(a.YAxis,{stroke:u.getThemeColor("grey_3",k),tick:{fill:u.getThemeColor("grey_2",k),fontSize:12},tickFormatter:q,label:f?{value:f,angle:-90,position:"insideLeft",style:{fill:u.getThemeColor("grey_2",k),fontSize:12}}:void 0}),e.jsx(l.Tooltip,{content:e.jsx(j,{})}),C?p.map(((t,r)=>e.jsx(n.Area,{type:"monotone",dataKey:t.dataKey,name:t.name,stroke:v(t.color,r),fill:v(t.color,r),fillOpacity:.2,strokeWidth:t.strokeWidth||2},t.dataKey))):p.map(((t,r)=>e.jsx(h.Line,{type:"monotone",dataKey:t.dataKey,name:t.name,stroke:v(t.color,r),strokeWidth:t.strokeWidth||2,dot:{r:4},activeDot:{r:6}},t.dataKey)))]})})})};
|
|
2
2
|
//# sourceMappingURL=line-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.comp.js","sources":["../../../../../src/components/charts/line-chart/line-chart.comp.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as AreaChartRecharts,\n CartesianGrid,\n Line,\n LineChart as LineChartRecharts,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { LineChartProps } from './line-chart.types'\n\nimport * as Styles from './line-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text key={index} size=\"small\" color={entry.color}>\n {entry.name}: {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).\n * `showArea` preenche a área abaixo da linha.\n * Para comparar categorias sem ordem de tempo use BarChart.\n * @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: '
|
|
1
|
+
{"version":3,"file":"line-chart.comp.js","sources":["../../../../../src/components/charts/line-chart/line-chart.comp.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as AreaChartRecharts,\n CartesianGrid,\n Line,\n LineChart as LineChartRecharts,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { LineChartProps } from './line-chart.types'\n\nimport * as Styles from './line-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text key={index} size=\"small\" color={entry.color}>\n {entry.name}: {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).\n * `showArea` preenche a área abaixo da linha.\n * Para comparar categorias sem ordem de tempo use BarChart.\n * @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: 'chart.purple' }]} />\n */\nexport const LineChart = ({\n width = 500,\n height = 300,\n data,\n series,\n showArea = false,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n}: LineChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const colorOf = (color: string | undefined, index: number) =>\n getThemeColor(color ?? chartColors[index % chartColors.length], theme)\n\n const ChartComponent = showArea ? AreaChartRecharts : LineChartRecharts\n\n return (\n <Styles.ChartContainer\n data-testid=\"line-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <ChartComponent\n width={width}\n height={height}\n data={data}\n margin={{ top: 5, right: 30, left: 20, bottom: 5 }}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n {showArea\n ? series.map((serie, index) => (\n <Area\n key={serie.dataKey}\n type=\"monotone\"\n dataKey={serie.dataKey}\n name={serie.name}\n stroke={colorOf(serie.color, index)}\n fill={colorOf(serie.color, index)}\n fillOpacity={0.2}\n strokeWidth={serie.strokeWidth || 2}\n />\n ))\n : series.map((serie, index) => (\n <Line\n key={serie.dataKey}\n type=\"monotone\"\n dataKey={serie.dataKey}\n name={serie.name}\n stroke={colorOf(serie.color, index)}\n strokeWidth={serie.strokeWidth || 2}\n dot={{ r: 4 }}\n activeDot={{ r: 6 }}\n />\n ))}\n </ChartComponent>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomTooltip","active","payload","label","length","_jsxs","Styles","direction","gap","children","_jsx","jsx","Text","size","fontWeight","map","entry","index","jsxs","color","name","value","LineChart","width","height","data","series","showArea","showGrid","xAxisLabel","yAxisLabel","yAxisFormatter","theme","useTheme","chartColors","CHART_COLOR_ORDER","getThemeColor","colorOf","ChartComponent","AreaChartRecharts","AreaChart","LineChartRecharts","ResponsiveContainer","margin","top","right","left","bottom","CartesianGrid","strokeDasharray","stroke","horizontal","vertical","XAxis","dataKey","tick","fill","fontSize","position","offset","style","undefined","YAxis","tickFormatter","angle","Tooltip","content","serie","Area","type","fillOpacity","strokeWidth","Line","dot","r","activeDot"],"mappings":"02BAoBA,MAAMA,EAAgBA,EAAGC,SAAQC,UAASC,WACnCF,GAAWC,GAAYA,EAAQE,OAGlCC,EAAAA,KAACC,EAAAA,cAAoB,CAACC,UAAU,SAASC,IAAK,EAC5CC,SAAA,CAAAC,EAAAC,IAACC,OAAI,CAACC,KAAK,QAAQC,WAAY,IAC5BL,SAAAN,IAEFD,EAAQa,KAAI,CAACC,EAAYC,IACxBZ,EAACa,KAAAN,OAAiB,CAAAC,KAAK,QAAQM,MAAOH,EAAMG,MAAKV,SAAA,CAC9CO,EAAMI,KAAI,KAAIJ,EAAMK,QADZJ,QARkC,uBAsB5BK,EACvBC,QAAQ,IACRC,SAAS,IACTC,OACAC,SACAC,YAAW,EACXC,YAAW,EACXC,aACAC,aACAC,qBAEA,MAAMC,EAAQC,EAAAA,WACRC,EAAcC,EAAAA,kBAAkBpB,KAAKK,GACzCgB,EAAAA,uBAAuBhB,IAAQY,KAE3BK,EAAUA,CAAClB,EAA2BF,IAC1CmB,EAAAA,cAAcjB,GAASe,EAAYjB,EAAQiB,EAAY9B,QAAS4B,GAE5DM,EAAiBX,EAAWY,EAAiBC,UAAGC,YAEtD,OACE/B,EAAAA,IAACJ,EAAAA,eAAqB,CAAA,cACR,aACZiB,MAAOA,EACPC,OAAQA,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CAACoD,EAAOlD,IACjBP,EAACC,IAAA6D,QAECH,KAAK,WACLf,QAASa,EAAMb,QACflC,KAAM+C,EAAM/C,KACZ8B,OAAQb,EAAQ8B,EAAMhD,MAAOF,GAC7BsD,YAAaJ,EAAMI,aAAe,EAClCE,IAAK,CAAEC,EAAG,GACVC,UAAW,CAAED,EAAG,IAPXP,EAAMb,iBAYD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("styled-components"),r=require("./treemap-chart.styles.js"),n=require("../../../node_modules/recharts/es6/component/ResponsiveContainer.js"),a=require("../../../node_modules/recharts/es6/chart/Treemap.js"),o=require("../../../node_modules/recharts/es6/component/Tooltip.js"),i=require("../../typography/text/text.comp.js");
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("styled-components"),r=require("./treemap-chart.styles.js"),n=require("../../../node_modules/recharts/es6/component/ResponsiveContainer.js"),a=require("../../../node_modules/recharts/es6/chart/Treemap.js"),o=require("../../../node_modules/recharts/es6/component/Tooltip.js"),l=require("../../../theme/chart-colors.js"),i=require("../../../theme/theme.util.js"),s=require("../../typography/text/text.comp.js");function h({x:r=0,y:n=0,width:a=0,height:o=0,name:l,value:s,fill:h,valueFormatter:c}){const m=a>=60&&o>=40,u=a>=60&&o>=60,d=t.useTheme(),x=function(e){const t=e.replace("#","");if(6!==t.length)return!1;const r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return(.299*r+.587*n+.114*a)/255<.5}(h??i.getThemeColor("chart.grey",d)),p=x?d.colors.white:d.colors.grey_1,g=x?"rgba(255,255,255,0.75)":d.colors.grey_2;return e.jsxs("g",{children:[e.jsx("rect",{x:r+1,y:n+1,width:Math.max(0,a-2),height:Math.max(0,o-2),fill:h??i.getThemeColor("chart.grey",d),rx:3,ry:3}),m&&l&&e.jsx("text",{x:r+a/2,y:n+o/2-(u?10:0),textAnchor:"middle",dominantBaseline:"middle",fill:p,fontSize:Math.min(13,Math.max(9,a/10)),fontWeight:600,pointerEvents:"none",children:l.length>Math.floor(a/7)?`${l.slice(0,Math.floor(a/7)-1)}…`:l}),u&&null!=s&&e.jsx("text",{x:r+a/2,y:n+o/2+12,textAnchor:"middle",dominantBaseline:"middle",fill:g,fontSize:Math.min(11,Math.max(9,a/12)),pointerEvents:"none",children:c?c(s):s})]})}const c=({active:t,payload:n,valueFormatter:a})=>{if(!t||!n?.length)return null;const o=n[0].payload;return e.jsxs(r.CustomTooltip,{direction:"column",gap:1,children:[e.jsx(s.Text,{size:"small",fontWeight:500,children:o.name}),e.jsx(s.Text,{size:"small",color:"grey_2",children:a?a(o.value):o.value})]})};exports.TreemapChart=({width:s="100%",height:m=300,data:u,valueFormatter:d})=>{const x=t.useTheme(),p=l.CHART_COLOR_ORDER.map((e=>i.getThemeColor(`chart.${e}`,x))),g=u.map(((e,t)=>({name:e.name,value:e.value>0?e.value:.01,fill:i.getThemeColor(e.color??p[t%p.length],x)})));return e.jsx(r.ChartContainer,{"data-testid":"treemap-chart",width:s,height:m,children:e.jsx(n.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsx(a.Treemap,{data:g,dataKey:"value",content:t=>e.jsx(h,{...t,valueFormatter:d}),children:e.jsx(o.Tooltip,{content:t=>e.jsx(c,{...t,valueFormatter:d})})})})})};
|
|
2
2
|
//# sourceMappingURL=treemap-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treemap-chart.comp.js","sources":["../../../../../src/components/charts/treemap-chart/treemap-chart.comp.tsx"],"sourcesContent":["import { ResponsiveContainer, Tooltip, Treemap } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { Text } from '../../typography'\n\nimport { TreemapChartProps } from './treemap-chart.types'\n\nimport * as Styles from './treemap-chart.styles'\n\ninterface ContentProps {\n x?: number\n y?: number\n width?: number\n height?: number\n name?: string\n value?: number\n fill?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"treemap-chart.comp.js","sources":["../../../../../src/components/charts/treemap-chart/treemap-chart.comp.tsx"],"sourcesContent":["import { ResponsiveContainer, Tooltip, Treemap } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { TreemapChartProps } from './treemap-chart.types'\n\nimport * as Styles from './treemap-chart.styles'\n\ninterface ContentProps {\n x?: number\n y?: number\n width?: number\n height?: number\n name?: string\n value?: number\n fill?: string\n}\n\nconst MIN_WIDTH_FOR_TEXT = 60\nconst MIN_HEIGHT_FOR_TEXT = 40\nconst MIN_HEIGHT_FOR_VALUE = 60\n\nfunction CustomContent({\n x = 0,\n y = 0,\n width = 0,\n height = 0,\n name,\n value,\n fill,\n valueFormatter,\n}: ContentProps & { valueFormatter?: (v: number) => string }) {\n const showText = width >= MIN_WIDTH_FOR_TEXT && height >= MIN_HEIGHT_FOR_TEXT\n const showValue =\n width >= MIN_WIDTH_FOR_TEXT && height >= MIN_HEIGHT_FOR_VALUE\n\n const theme = useTheme()\n const isDark = isDarkColor(fill ?? getThemeColor('chart.grey', theme))\n const textColor = isDark ? theme.colors.white : theme.colors.grey_1\n const subTextColor = isDark ? 'rgba(255,255,255,0.75)' : theme.colors.grey_2\n\n return (\n <g>\n <rect\n x={x + 1}\n y={y + 1}\n width={Math.max(0, width - 2)}\n height={Math.max(0, height - 2)}\n fill={fill ?? getThemeColor('chart.grey', theme)}\n rx={3}\n ry={3}\n />\n {showText && name && (\n <text\n x={x + width / 2}\n y={y + height / 2 - (showValue ? 10 : 0)}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n fill={textColor}\n fontSize={Math.min(13, Math.max(9, width / 10))}\n fontWeight={600}\n pointerEvents=\"none\"\n >\n {name.length > Math.floor(width / 7)\n ? `${name.slice(0, Math.floor(width / 7) - 1)}…`\n : name}\n </text>\n )}\n {showValue && value != null && (\n <text\n x={x + width / 2}\n y={y + height / 2 + 12}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n fill={subTextColor}\n fontSize={Math.min(11, Math.max(9, width / 12))}\n pointerEvents=\"none\"\n >\n {valueFormatter ? valueFormatter(value) : value}\n </text>\n )}\n </g>\n )\n}\n\nfunction isDarkColor(hex: string): boolean {\n const clean = hex.replace('#', '')\n if (clean.length !== 6) return false\n const r = parseInt(clean.slice(0, 2), 16)\n const g = parseInt(clean.slice(2, 4), 16)\n const b = parseInt(clean.slice(4, 6), 16)\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255\n return luminance < 0.5\n}\n\nconst CustomTooltip = ({\n active,\n payload,\n valueFormatter,\n}: {\n active?: boolean\n payload?: Array<{ payload: { name: string; value: number; fill: string } }>\n valueFormatter?: (v: number) => string\n}) => {\n if (!active || !payload?.length) return null\n const item = payload[0].payload\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {item.name}\n </Text>\n <Text size=\"small\" color=\"grey_2\">\n {valueFormatter ? valueFormatter(item.value) : item.value}\n </Text>\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).\n * Para poucas categorias use BarChart ou DoughnutChart.\n * Cor de cada bloco pela paleta de gráfico (`color: 'chart.lilac'`); sem cor, segue a ordem de\n * `getChartColors`.\n * @example <TreemapChart data={[{ name: 'Algodão', value: 120 }, { name: 'Poliéster', value: 40 }]} />\n */\nexport const TreemapChart = ({\n width = '100%',\n height = 300,\n data,\n valueFormatter,\n}: TreemapChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const rechartsData = data.map((item, index) => ({\n name: item.name,\n value: item.value > 0 ? item.value : 0.01,\n fill: getThemeColor(\n item.color ?? chartColors[index % chartColors.length],\n theme,\n ),\n }))\n\n return (\n <Styles.ChartContainer\n data-testid=\"treemap-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n <Treemap\n data={rechartsData}\n dataKey=\"value\"\n content={\n ((props: ContentProps) => (\n <CustomContent {...props} valueFormatter={valueFormatter} />\n )) as any\n }\n >\n <Tooltip\n content={\n ((props: any) => (\n <CustomTooltip {...props} valueFormatter={valueFormatter} />\n )) as any\n }\n />\n </Treemap>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomContent","x","y","width","height","name","value","fill","valueFormatter","showText","showValue","theme","useTheme","isDark","hex","clean","replace","length","r","parseInt","slice","g","b","isDarkColor","getThemeColor","textColor","colors","white","grey_1","subTextColor","grey_2","_jsxs","children","_jsx","jsx","Math","max","rx","ry","textAnchor","dominantBaseline","fontSize","min","fontWeight","pointerEvents","floor","CustomTooltip","active","payload","item","Styles","direction","gap","Text","size","color","TreemapChart","data","chartColors","CHART_COLOR_ORDER","map","rechartsData","index","ResponsiveContainer","Treemap","dataKey","content","props","Tooltip"],"mappings":"mdAwBA,SAASA,GAAcC,EACrBA,EAAI,EAACC,EACLA,EAAI,EAACC,MACLA,EAAQ,EAACC,OACTA,EAAS,EAACC,KACVA,EAAIC,MACJA,EAAKC,KACLA,EAAIC,eACJA,IAEA,MAAMC,EAAWN,GAdQ,IAcuBC,GAbtB,GAcpBM,EACJP,GAhBuB,IAgBQC,GAdN,GAgBrBO,EAAQC,EAAAA,WACRC,EAgDR,SAAqBC,GACnB,MAAMC,EAAQD,EAAIE,QAAQ,IAAK,IAC/B,GAAqB,IAAjBD,EAAME,OAAc,OAAO,EAC/B,MAAMC,EAAIC,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAChCC,EAAIF,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAChCE,EAAIH,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAEtC,OADmB,KAAQF,EAAI,KAAQG,EAAI,KAAQC,GAAK,IACrC,EACrB,CAxD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cAAoB,CAACC,UAAU,SAASC,IAAK,EAACpB,SAAA,CAC7CC,EAACC,IAAAmB,OAAK,CAAAC,KAAK,QAAQX,WAAY,IAC5BX,SAAAiB,EAAK5C,OAER4B,EAACC,IAAAmB,OAAK,CAAAC,KAAK,QAAQC,MAAM,SACtBvB,SAAAxB,EAAiBA,EAAeyC,EAAK3C,OAAS2C,EAAK3C,UAEjC,uBAWCkD,EAC1BrD,QAAQ,OACRC,SAAS,IACTqD,OACAjD,qBAEA,MAAMG,EAAQC,EAAAA,WACR8C,EAAcC,EAAAA,kBAAkBC,KAAKvD,GACzCmB,EAAAA,uBAAuBnB,IAAQM,KAE3BkD,EAAeJ,EAAKG,KAAI,CAACX,EAAMa,KAAW,CAC9CzD,KAAM4C,EAAK5C,KACXC,MAAO2C,EAAK3C,MAAQ,EAAI2C,EAAK3C,MAAQ,IACrCC,KAAMiB,EAAAA,cACJyB,EAAKM,OAASG,EAAYI,EAAQJ,EAAYzC,QAC9CN,OAIJ,OACEsB,EAAAA,IAACiB,EAAAA,eAAqB,CAAA,cACR,gBACZ/C,MAAOA,EACPC,OAAQA,EAER4B,SAAAC,EAAAC,IAAC6B,sBAAoB,CAAA5D,MAAM,OAAOC,OAAO,OAEvC4B,SAAAC,EAAAC,IAAC8B,UACC,CAAAP,KAAMI,EACNI,QAAQ,QACRC,QACIC,GACAlC,EAAAC,IAAClC,EAAkB,IAAAmE,EAAO3D,eAAgBA,IAI9CwB,SAAAC,EAAAC,IAACkC,UACC,CAAAF,QACIC,GACAlC,MAACa,EAAa,IAAKqB,EAAO3D,eAAgBA,WAM9B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -904,8 +904,12 @@ interface DoughnutChartProps {
|
|
|
904
904
|
interface PartsProps {
|
|
905
905
|
/** Numeric value of this segment */
|
|
906
906
|
value: number;
|
|
907
|
-
/**
|
|
908
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Cor da fatia, da paleta de gráfico: `'chart.blue'` ou `theme.colors.chart.blue`. Vale também
|
|
909
|
+
* quando a fatia é um status (aprovado, pendente): gráfico não usa `state.*`.
|
|
910
|
+
* Sem cor, segue a ordem de `getChartColors`.
|
|
911
|
+
*/
|
|
912
|
+
color?: ThemeColors | string;
|
|
909
913
|
/** Formatted display string shown in tooltip (e.g. '45%') */
|
|
910
914
|
display?: string;
|
|
911
915
|
/** Name/label of this segment shown in tooltip */
|
|
@@ -917,7 +921,9 @@ interface PartsProps {
|
|
|
917
921
|
* `parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.
|
|
918
922
|
* `legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).
|
|
919
923
|
* Use com até 5 fatias. Com mais categorias use BarChart.
|
|
920
|
-
*
|
|
924
|
+
* As fatias usam a paleta de gráfico (`chart.*`), mesmo quando cada uma é um status: passe o nome
|
|
925
|
+
* (`color: 'chart.blue'`) ou deixe sem cor, que a rosca segue a ordem de `getChartColors`.
|
|
926
|
+
* @example <DoughnutChart totalValue={100} parts={[{ value: 60, color: 'chart.blue', name: 'Aprovados' }]} />
|
|
921
927
|
*/
|
|
922
928
|
declare const DoughnutChart: ({ size, totalValue, parts, fontSize, showTotalValue, showTooltip, tooltipValueFormatter, disableAnimation, customContent, legend, }: DoughnutChartProps) => react_jsx_runtime.JSX.Element;
|
|
923
929
|
|
|
@@ -927,8 +933,12 @@ interface BarChartData {
|
|
|
927
933
|
name: string;
|
|
928
934
|
/** Numeric value of the bar */
|
|
929
935
|
value: number;
|
|
930
|
-
/**
|
|
931
|
-
|
|
936
|
+
/**
|
|
937
|
+
* Cor da barra, da paleta de gráfico: `'chart.purple'` ou `theme.colors.chart.purple`. Vale
|
|
938
|
+
* também quando a barra é um status: gráfico não usa `state.*`.
|
|
939
|
+
* @default 'secondary'
|
|
940
|
+
*/
|
|
941
|
+
color?: ThemeColors | string;
|
|
932
942
|
}
|
|
933
943
|
/** Props for the BarChart component */
|
|
934
944
|
interface BarChartProps {
|
|
@@ -962,6 +972,7 @@ interface BarChartProps {
|
|
|
962
972
|
* Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).
|
|
963
973
|
* Cada item de `data` é uma barra, com `name` e `value`.
|
|
964
974
|
* Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.
|
|
975
|
+
* Cor da barra pela paleta de gráfico (`color: 'chart.purple'`), mesmo quando a barra é um status.
|
|
965
976
|
* @example <BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />
|
|
966
977
|
*/
|
|
967
978
|
declare const BarChart: ({ width, height, data, showGrid, xAxisLabel, yAxisLabel, yAxisFormatter, barSize, radius, showLabels, labelFormatter, barCategoryGap, }: BarChartProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -979,8 +990,12 @@ interface LineChartSeries {
|
|
|
979
990
|
dataKey: string;
|
|
980
991
|
/** Display name for the legend */
|
|
981
992
|
name: string;
|
|
982
|
-
/**
|
|
983
|
-
|
|
993
|
+
/**
|
|
994
|
+
* Cor da linha, da paleta de gráfico: `'chart.purple'` ou `theme.colors.chart.purple`. Vale
|
|
995
|
+
* também quando a série é um status (pendente, concluído): gráfico não usa `state.*`.
|
|
996
|
+
* Sem cor, segue a ordem de `getChartColors`.
|
|
997
|
+
*/
|
|
998
|
+
color?: ThemeColors | string;
|
|
984
999
|
/** Stroke width in pixels
|
|
985
1000
|
* @default 2
|
|
986
1001
|
*/
|
|
@@ -1012,7 +1027,7 @@ interface LineChartProps {
|
|
|
1012
1027
|
* Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).
|
|
1013
1028
|
* `showArea` preenche a área abaixo da linha.
|
|
1014
1029
|
* Para comparar categorias sem ordem de tempo use BarChart.
|
|
1015
|
-
* @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: '
|
|
1030
|
+
* @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: 'chart.purple' }]} />
|
|
1016
1031
|
*/
|
|
1017
1032
|
declare const LineChart: ({ width, height, data, series, showArea, showGrid, xAxisLabel, yAxisLabel, yAxisFormatter, }: LineChartProps) => react_jsx_runtime.JSX.Element;
|
|
1018
1033
|
|
|
@@ -1022,8 +1037,11 @@ interface TreemapChartData {
|
|
|
1022
1037
|
name: string;
|
|
1023
1038
|
/** Numeric value that determines block size */
|
|
1024
1039
|
value: number;
|
|
1025
|
-
/**
|
|
1026
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* Cor do bloco, da paleta de gráfico: `'chart.lilac'` ou `theme.colors.chart.lilac`. Sem cor,
|
|
1042
|
+
* segue a ordem de `getChartColors`.
|
|
1043
|
+
*/
|
|
1044
|
+
color?: ThemeColors | string;
|
|
1027
1045
|
}
|
|
1028
1046
|
/** Props for the TreemapChart component */
|
|
1029
1047
|
interface TreemapChartProps {
|
|
@@ -1040,6 +1058,8 @@ interface TreemapChartProps {
|
|
|
1040
1058
|
/**
|
|
1041
1059
|
* Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).
|
|
1042
1060
|
* Para poucas categorias use BarChart ou DoughnutChart.
|
|
1061
|
+
* Cor de cada bloco pela paleta de gráfico (`color: 'chart.lilac'`); sem cor, segue a ordem de
|
|
1062
|
+
* `getChartColors`.
|
|
1043
1063
|
* @example <TreemapChart data={[{ name: 'Algodão', value: 120 }, { name: 'Poliéster', value: 40 }]} />
|
|
1044
1064
|
*/
|
|
1045
1065
|
declare const TreemapChart: ({ width, height, data, valueFormatter, }: TreemapChartProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -1075,7 +1095,7 @@ interface ChartLegendProps {
|
|
|
1075
1095
|
* Legenda de gráfico: bolinha na cor da série, nome e valor opcional.
|
|
1076
1096
|
* Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.
|
|
1077
1097
|
* `variant="square"` é a legenda das roscas das dashboards: quadradinho e "Nome: valor".
|
|
1078
|
-
* @example <ChartLegend items={[{ label: 'Aprovados', color: '
|
|
1098
|
+
* @example <ChartLegend items={[{ label: 'Aprovados', color: 'chart.blue', value: '60%' }]} />
|
|
1079
1099
|
* @example <ChartLegend variant="square" direction="column" items={[{ label: 'Pendentes', color: 'chart.purple', value: 850 }]} />
|
|
1080
1100
|
*/
|
|
1081
1101
|
declare const ChartLegend: ({ items, direction, variant, }: ChartLegendProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as r}from"styled-components";import{ChartContainer as o,CustomTooltip as i}from"./bar-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{BarChart as s}from"../../../node_modules/recharts/es6/chart/BarChart.js";import{CartesianGrid as l}from"../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";import{XAxis as n}from"../../../node_modules/recharts/es6/cartesian/XAxis.js";import{YAxis as m}from"../../../node_modules/recharts/es6/cartesian/YAxis.js";import{Tooltip as d}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{Bar as c}from"../../../node_modules/recharts/es6/cartesian/Bar.js";import{Cell as h}from"../../../node_modules/recharts/es6/component/Cell.js";import{LabelList as p}from"../../../node_modules/recharts/es6/component/LabelList.js";import{getThemeColor as f}from"../../../theme/theme.util.js";import{Text as y}from"../../typography/text/text.comp.js";const u=({active:r,payload:o,label:a})=>r&&o&&o.length?t(i,{direction:"column",gap:1,children:[e(y,{size:"small",fontWeight:500,children:a}),o.map(((t,r)=>e(y,{size:"small",color:t.color||t.payload?.color,children:t.value},r)))]}):null,g=({width:i="100%",height:y=300,data:g,showGrid:b=!0,xAxisLabel:_,yAxisLabel:j,yAxisFormatter:x,barSize:z,radius:v,showLabels:C=!1,labelFormatter:k,barCategoryGap:S})=>{const w=r();return e(o,{"data-testid":"bar-chart",width:i,height:y,children:e(a,{width:"100%",height:"100%",children:t(s,{width:"number"==typeof i?i:500,height:y,data:g,margin:{top:C?20:5,right:30,left:20,bottom:5},barCategoryGap:S,children:[b&&e(l,{strokeDasharray:"3 3",stroke:f("grey_4",w),horizontal:!0,vertical:!1}),e(n,{dataKey:"name",stroke:f("grey_3",w),tick:{fill:f("grey_2",w),fontSize:12},label:_?{value:_,position:"insideBottom",offset:-5,style:{fill:f("grey_2",w),fontSize:12}}:void 0}),e(m,{stroke:f("grey_3",w),tick:{fill:f("grey_2",w),fontSize:12},tickFormatter:x,label:j?{value:j,angle:-90,position:"insideLeft",style:{fill:f("grey_2",w),fontSize:12}}:void 0}),e(d,{content:e(u,{})}),t(c,{dataKey:"value",barSize:z,radius:(e=>{if(e)return"number"==typeof e?[e,e,0,0]:e})(v),children:[g.map(((t,r)=>e(h,{fill:t.color||
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as r}from"styled-components";import{ChartContainer as o,CustomTooltip as i}from"./bar-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{BarChart as s}from"../../../node_modules/recharts/es6/chart/BarChart.js";import{CartesianGrid as l}from"../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";import{XAxis as n}from"../../../node_modules/recharts/es6/cartesian/XAxis.js";import{YAxis as m}from"../../../node_modules/recharts/es6/cartesian/YAxis.js";import{Tooltip as d}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{Bar as c}from"../../../node_modules/recharts/es6/cartesian/Bar.js";import{Cell as h}from"../../../node_modules/recharts/es6/component/Cell.js";import{LabelList as p}from"../../../node_modules/recharts/es6/component/LabelList.js";import{getThemeColor as f}from"../../../theme/theme.util.js";import{Text as y}from"../../typography/text/text.comp.js";const u=({active:r,payload:o,label:a})=>r&&o&&o.length?t(i,{direction:"column",gap:1,children:[e(y,{size:"small",fontWeight:500,children:a}),o.map(((t,r)=>e(y,{size:"small",color:t.color||t.payload?.color,children:t.value},r)))]}):null,g=({width:i="100%",height:y=300,data:g,showGrid:b=!0,xAxisLabel:_,yAxisLabel:j,yAxisFormatter:x,barSize:z,radius:v,showLabels:C=!1,labelFormatter:k,barCategoryGap:S})=>{const w=r();return e(o,{"data-testid":"bar-chart",width:i,height:y,children:e(a,{width:"100%",height:"100%",children:t(s,{width:"number"==typeof i?i:500,height:y,data:g,margin:{top:C?20:5,right:30,left:20,bottom:5},barCategoryGap:S,children:[b&&e(l,{strokeDasharray:"3 3",stroke:f("grey_4",w),horizontal:!0,vertical:!1}),e(n,{dataKey:"name",stroke:f("grey_3",w),tick:{fill:f("grey_2",w),fontSize:12},label:_?{value:_,position:"insideBottom",offset:-5,style:{fill:f("grey_2",w),fontSize:12}}:void 0}),e(m,{stroke:f("grey_3",w),tick:{fill:f("grey_2",w),fontSize:12},tickFormatter:x,label:j?{value:j,angle:-90,position:"insideLeft",style:{fill:f("grey_2",w),fontSize:12}}:void 0}),e(d,{content:e(u,{})}),t(c,{dataKey:"value",barSize:z,radius:(e=>{if(e)return"number"==typeof e?[e,e,0,0]:e})(v),children:[g.map(((t,r)=>e(h,{fill:f(t.color||"secondary",w)},`cell-${r}`))),C&&e(p,{position:"top",formatter:e=>k?k(e):e,style:{fill:f("grey_1",w),fontSize:12}})]})]})})})};export{g as BarChart};
|
|
2
2
|
//# sourceMappingURL=bar-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-chart.comp.js","sources":["../../../../../src/components/charts/bar-chart/bar-chart.comp.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as BarChartRecharts,\n CartesianGrid,\n Cell,\n LabelList,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { BarChartProps } from './bar-chart.types'\n\nimport * as Styles from './bar-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text\n key={index}\n size=\"small\"\n color={entry.color || entry.payload?.color}\n >\n {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\n * Cada item de `data` é uma barra, com `name` e `value`.\n * Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.\n * @example <BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />\n */\nexport const BarChart = ({\n width = '100%',\n height = 300,\n data,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n barSize,\n radius,\n showLabels = false,\n labelFormatter,\n barCategoryGap,\n}: BarChartProps) => {\n const theme = useTheme()\n\n // Converte radius numérico para array [topLeft, topRight, 0, 0] (apenas cantos superiores)\n const getRadiusValue = (\n radiusValue?: number | [number, number, number, number],\n ) => {\n if (!radiusValue) return undefined\n if (typeof radiusValue === 'number') {\n return [radiusValue, radiusValue, 0, 0] as [\n number,\n number,\n number,\n number,\n ]\n }\n return radiusValue\n }\n\n return (\n <Styles.ChartContainer\n data-testid=\"bar-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChartRecharts\n width={typeof width === 'number' ? width : 500}\n height={height}\n data={data}\n margin={{ top: showLabels ? 20 : 5, right: 30, left: 20, bottom: 5 }}\n barCategoryGap={barCategoryGap}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n <Bar\n dataKey=\"value\"\n barSize={barSize}\n radius={getRadiusValue(radius)}\n >\n {data.map((entry, index) => (\n <Cell\n key={`cell-${index}`}\n fill={entry.color ||
|
|
1
|
+
{"version":3,"file":"bar-chart.comp.js","sources":["../../../../../src/components/charts/bar-chart/bar-chart.comp.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as BarChartRecharts,\n CartesianGrid,\n Cell,\n LabelList,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { BarChartProps } from './bar-chart.types'\n\nimport * as Styles from './bar-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text\n key={index}\n size=\"small\"\n color={entry.color || entry.payload?.color}\n >\n {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).\n * Cada item de `data` é uma barra, com `name` e `value`.\n * Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.\n * Cor da barra pela paleta de gráfico (`color: 'chart.purple'`), mesmo quando a barra é um status.\n * @example <BarChart data={[{ name: 'Jan', value: 10 }, { name: 'Fev', value: 14 }]} />\n */\nexport const BarChart = ({\n width = '100%',\n height = 300,\n data,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n barSize,\n radius,\n showLabels = false,\n labelFormatter,\n barCategoryGap,\n}: BarChartProps) => {\n const theme = useTheme()\n\n // Converte radius numérico para array [topLeft, topRight, 0, 0] (apenas cantos superiores)\n const getRadiusValue = (\n radiusValue?: number | [number, number, number, number],\n ) => {\n if (!radiusValue) return undefined\n if (typeof radiusValue === 'number') {\n return [radiusValue, radiusValue, 0, 0] as [\n number,\n number,\n number,\n number,\n ]\n }\n return radiusValue\n }\n\n return (\n <Styles.ChartContainer\n data-testid=\"bar-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChartRecharts\n width={typeof width === 'number' ? width : 500}\n height={height}\n data={data}\n margin={{ top: showLabels ? 20 : 5, right: 30, left: 20, bottom: 5 }}\n barCategoryGap={barCategoryGap}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n <Bar\n dataKey=\"value\"\n barSize={barSize}\n radius={getRadiusValue(radius)}\n >\n {data.map((entry, index) => (\n <Cell\n key={`cell-${index}`}\n fill={getThemeColor(entry.color || 'secondary', theme)}\n />\n ))}\n {showLabels && (\n <LabelList\n position=\"top\"\n formatter={(value: number) =>\n labelFormatter ? labelFormatter(value) : value\n }\n // style aqui é a API do recharts para o texto do rótulo, não CSS inline em elemento HTML\n // eslint-disable-next-line no-restricted-syntax\n style={{\n fill: getThemeColor('grey_1', theme),\n fontSize: 12,\n }}\n />\n )}\n </Bar>\n </BarChartRecharts>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomTooltip","active","payload","label","length","_jsxs","Styles","direction","gap","_jsx","Text","size","fontWeight","children","map","entry","index","color","value","BarChart","width","height","data","showGrid","xAxisLabel","yAxisLabel","yAxisFormatter","barSize","radius","showLabels","labelFormatter","barCategoryGap","theme","useTheme","ResponsiveContainer","BarChartRecharts","margin","top","right","left","bottom","CartesianGrid","strokeDasharray","stroke","getThemeColor","horizontal","vertical","XAxis","dataKey","tick","fill","fontSize","position","offset","style","undefined","YAxis","tickFormatter","angle","Tooltip","content","Bar","radiusValue","getRadiusValue","Cell","LabelList","formatter"],"mappings":"khCAoBA,MAAMA,EAAgBA,EAAGC,SAAQC,UAASC,WACnCF,GAAWC,GAAYA,EAAQE,OAGlCC,EAACC,EAAqB,CAAAC,UAAU,SAASC,IAAK,YAC5CC,EAACC,EAAK,CAAAC,KAAK,QAAQC,WAAY,IAAGC,SAC/BV,IAEFD,EAAQY,KAAI,CAACC,EAAYC,IACxBP,EAACC,EAAI,CAEHC,KAAK,QACLM,MAAOF,EAAME,OAASF,EAAMb,SAASe,eAEpCF,EAAMG,OAJFF,QATsC,KA2BxCG,EAAWA,EACtBC,QAAQ,OACRC,SAAS,IACTC,OACAC,YAAW,EACXC,aACAC,aACAC,iBACAC,UACAC,SACAC,cAAa,EACbC,iBACAC,qBAEA,MAAMC,EAAQC,IAkBd,OACExB,EAACH,EACa,CAAA,cAAA,YACZc,MAAOA,EACPC,OAAQA,EAAMR,SAEdJ,EAACyB,EAAoB,CAAAd,MAAM,OAAOC,OAAO,OAAMR,SAC7CR,EAAC8B,EAAgB,CACff,MAAwB,i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":"chart-legend.comp.js","sources":["../../../../../src/components/charts/chart-legend/chart-legend.comp.tsx"],"sourcesContent":["import { ChartLegendProps } from './chart-legend.types'\n\nimport * as Styles from './chart-legend.styles'\n\n/**\n * Legenda de gráfico: bolinha na cor da série, nome e valor opcional.\n * Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.\n * `variant=\"square\"` é a legenda das roscas das dashboards: quadradinho e \"Nome: valor\".\n * @example <ChartLegend items={[{ label: 'Aprovados', color: '
|
|
1
|
+
{"version":3,"file":"chart-legend.comp.js","sources":["../../../../../src/components/charts/chart-legend/chart-legend.comp.tsx"],"sourcesContent":["import { ChartLegendProps } from './chart-legend.types'\n\nimport * as Styles from './chart-legend.styles'\n\n/**\n * Legenda de gráfico: bolinha na cor da série, nome e valor opcional.\n * Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com a prop `legend`.\n * `variant=\"square\"` é a legenda das roscas das dashboards: quadradinho e \"Nome: valor\".\n * @example <ChartLegend items={[{ label: 'Aprovados', color: 'chart.blue', value: '60%' }]} />\n * @example <ChartLegend variant=\"square\" direction=\"column\" items={[{ label: 'Pendentes', color: 'chart.purple', value: 850 }]} />\n */\nexport const ChartLegend = ({\n items,\n direction = 'row',\n variant = 'dot',\n}: ChartLegendProps) => (\n <Styles.List\n $direction={direction}\n $variant={variant}\n data-testid=\"chart-legend\"\n >\n {items.map((item) => (\n <Styles.Item key={item.label} $variant={variant}>\n <Styles.Marker\n $color={item.color}\n $variant={variant}\n aria-hidden=\"true\"\n />\n {variant === 'square' ? (\n <Styles.Label title={item.label}>\n {item.label}\n {item.value !== undefined && <>: {item.value}</>}\n </Styles.Label>\n ) : (\n <>\n <Styles.Label title={item.label}>{item.label}</Styles.Label>\n {item.value !== undefined && (\n <Styles.Value $direction={direction}>{item.value}</Styles.Value>\n )}\n </>\n )}\n </Styles.Item>\n ))}\n </Styles.List>\n)\n"],"names":["ChartLegend","items","direction","variant","_jsx","Styles","$direction","$variant","children","map","item","_jsxs","color","title","label","undefined","value","_Fragment"],"mappings":"4JAWO,MAAMA,EAAcA,EACzBC,QACAC,YAAY,MACZC,UAAU,SAEVC,EAACC,EACa,CAAAC,WAAAJ,EACFK,SAAAJ,gBACE,eAAcK,SAEzBP,EAAMQ,KAAKC,GACVC,EAACN,EAAuC,CAAAE,SAAAJ,YACtCC,EAACC,UACSK,EAAKE,MAAKL,SACRJ,EAAO,cACL,SAED,WAAZA,EACCQ,EAACN,EAAY,CAACQ,MAAOH,EAAKI,MAAKN,SAAA,CAC5BE,EAAKI,WACUC,IAAfL,EAAKM,OAAuBL,oBAAKD,EAAKM,YAGzCL,EAAAM,EAAA,CAAAT,SAAA,CACEJ,EAACC,EAAY,CAACQ,MAAOH,EAAKI,MAAQN,SAAAE,EAAKI,aACvBC,IAAfL,EAAKM,OACJZ,EAACC,EAAyB,CAAAC,WAAAJ,EAAYM,SAAAE,EAAKM,aAfjCN,EAAKI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as r,useId as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as r,useId as a,useEffect as l}from"react";import{useTheme as i}from"styled-components";import{ChartContainer as n,CenterText as s,TotalText as m,WithLegend as c,CustomTooltip as d}from"./doughnut-chart.styles.js";import{CHART_COLOR_ORDER as h}from"../../../theme/chart-colors.js";import{PieChart as p}from"../../../node_modules/recharts/es6/chart/PieChart.js";import{Pie as u}from"../../../node_modules/recharts/es6/polar/Pie.js";import{Cell as f}from"../../../node_modules/recharts/es6/component/Cell.js";import{Tooltip as g}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{ChartLegend as v}from"../chart-legend/chart-legend.comp.js";import{getThemeColor as y}from"../../../theme/theme.util.js";import{Text as j}from"../../typography/text/text.comp.js";const A=e=>e.name?{"aria-label":`${e.name}: ${e.display??e.value}`}:{"aria-hidden":"true"},$=({size:$=200,totalValue:z,parts:_,fontSize:w,showTotalValue:x=!0,showTooltip:T=!1,tooltipValueFormatter:b,disableAnimation:C=!1,customContent:R,legend:V})=>{const P=i(),S=h.map((e=>y(`chart.${e}`,P))),D=(e,t)=>y(e.color??S[t%S.length],P),[F,K]=r([]),[W,k]=r(!1),q=a();l((()=>{const e=_.reduce(((e,t)=>e+t.value),0),t=[..._];e!==z&&(1===_.length?(k(!0),t.push({value:z-e,color:"transparent",display:"none"})):t.push({value:z-e,color:y("grey_5",P)})),K([...t])}),[_]);const B={dataKey:"value",innerRadius:$/2*.75,outerRadius:$/2,startAngle:90,endAngle:-270},E=e(n,{"data-testid":"doughnut-chart",size:$,children:[R?t(s,{children:R}):x&&e(m,{fontSize:w,children:[t("small",{children:"Total"}),t("p",{children:z})]}),e(p,{width:$,height:$,id:q,children:[(W||!z)&&t(u,{data:[{value:1}],fill:y("grey_5",P),animationDuration:0,isAnimationActive:!C,...B,children:t(f,{"aria-hidden":"true"})}),z&&t(u,{data:F,paddingAngle:1===F.length?0:3,cornerRadius:10,isAnimationActive:!C,...B,children:F.map(((e,o)=>t(f,{fill:D(e,o),...A(e)},`cell-${o}`)))}),T&&t(g,{content:({active:r,payload:a})=>{const l=a?.[0]?.name&&"string"==typeof a[0].name;return r?t(d,{direction:"column",children:l?e(o,{children:[t(j,{size:"small",fontWeight:500,children:`${a[0].name}`}),t(j,{size:"small",children:`${b?b(a[0].value):a[0].value}`})]}):t(j,{size:"small",children:`${b?b(a[0].value):a[0].value}`})}):null}})]})]});return V?e(c,{$position:V,children:[E,t(v,{direction:"side"===V?"column":"row",items:_.map(((e,t)=>({part:e,color:D(e,t)}))).filter((({part:e})=>e.name)).map((({part:e,color:t})=>({label:e.name,color:t,value:e.display??e.value})))})]}):E};export{$ as DoughnutChart};
|
|
2
2
|
//# sourceMappingURL=doughnut-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doughnut-chart.comp.js","sources":["../../../../../src/components/charts/doughnut-chart/doughnut-chart.comp.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react'\n\nimport { Cell, Pie, PieChart, Tooltip } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\nimport { ChartLegend } from '../chart-legend'\n\nimport { DoughnutChartProps, PartsProps } from './doughnut-chart.types'\n\nimport * as Styles from './doughnut-chart.styles'\n\n/** Fatia com nome vira imagem com texto alternativo; fatia sem nome (restante) fica fora do leitor de tela. */\nconst getCellA11yProps = (part: PartsProps) =>\n part.name\n ? { 'aria-label': `${part.name}: ${part.display ?? part.value}` }\n : { 'aria-hidden': 'true' as const }\n\n/**\n * Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n * `parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n * `legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\n * Use com até 5 fatias. Com mais categorias use BarChart.\n * @example <DoughnutChart totalValue={100} parts={[{ value: 60, color: '
|
|
1
|
+
{"version":3,"file":"doughnut-chart.comp.js","sources":["../../../../../src/components/charts/doughnut-chart/doughnut-chart.comp.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react'\n\nimport { Cell, Pie, PieChart, Tooltip } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\nimport { ChartLegend } from '../chart-legend'\n\nimport { DoughnutChartProps, PartsProps } from './doughnut-chart.types'\n\nimport * as Styles from './doughnut-chart.styles'\n\n/** Fatia com nome vira imagem com texto alternativo; fatia sem nome (restante) fica fora do leitor de tela. */\nconst getCellA11yProps = (part: PartsProps) =>\n part.name\n ? { 'aria-label': `${part.name}: ${part.display ?? part.value}` }\n : { 'aria-hidden': 'true' as const }\n\n/**\n * Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).\n * `parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.\n * `legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).\n * Use com até 5 fatias. Com mais categorias use BarChart.\n * As fatias usam a paleta de gráfico (`chart.*`), mesmo quando cada uma é um status: passe o nome\n * (`color: 'chart.blue'`) ou deixe sem cor, que a rosca segue a ordem de `getChartColors`.\n * @example <DoughnutChart totalValue={100} parts={[{ value: 60, color: 'chart.blue', name: 'Aprovados' }]} />\n */\nexport const DoughnutChart = ({\n size = 200,\n totalValue,\n parts,\n fontSize,\n showTotalValue = true,\n showTooltip = false,\n tooltipValueFormatter,\n disableAnimation = false,\n customContent,\n legend,\n}: DoughnutChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const colorOf = (part: PartsProps, index: number) =>\n getThemeColor(part.color ?? chartColors[index % chartColors.length], theme)\n\n const [adjustedParts, setAdjustedParts] = useState<PartsProps[]>([])\n const [showBackground, setShowBackground] = useState(false)\n\n const chartId = useId()\n\n useEffect(() => {\n const totalSum = parts.reduce((sum, part) => sum + part.value, 0)\n const auxParts = [...parts]\n\n if (totalSum !== totalValue) {\n if (parts.length === 1) {\n setShowBackground(true)\n auxParts.push({\n value: totalValue - totalSum,\n color: 'transparent',\n display: 'none',\n })\n } else {\n auxParts.push({\n value: totalValue - totalSum,\n color: getThemeColor('grey_5', theme),\n })\n }\n }\n setAdjustedParts([...auxParts])\n }, [parts])\n\n const defaultPieChartProps = {\n dataKey: 'value',\n innerRadius: (size / 2) * 0.75,\n outerRadius: size / 2,\n startAngle: 90,\n endAngle: -270,\n }\n\n const CustomTooltip = ({ active, payload }: any) => {\n const hasName = payload?.[0]?.name && typeof payload[0].name === 'string'\n\n if (!active) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\">\n {hasName ? (\n <>\n <Text size=\"small\" fontWeight={500}>{`${payload[0].name}`}</Text>\n <Text size=\"small\">{`${tooltipValueFormatter ? tooltipValueFormatter(payload[0].value) : payload[0].value}`}</Text>\n </>\n ) : (\n <Text size=\"small\">{`${tooltipValueFormatter ? tooltipValueFormatter(payload[0].value) : payload[0].value}`}</Text>\n )}\n </Styles.CustomTooltip>\n )\n }\n\n const chart = (\n <Styles.ChartContainer data-testid=\"doughnut-chart\" size={size}>\n {customContent ? (\n <Styles.CenterText>{customContent}</Styles.CenterText>\n ) : (\n showTotalValue && (\n <Styles.TotalText fontSize={fontSize}>\n <small>Total</small>\n <p>{totalValue}</p>\n </Styles.TotalText>\n )\n )}\n <PieChart width={size} height={size} id={chartId}>\n {(showBackground || !totalValue) && (\n <Pie\n data={[{ value: 1 }]}\n fill={getThemeColor('grey_5', theme)}\n animationDuration={0}\n isAnimationActive={!disableAnimation}\n {...defaultPieChartProps}\n >\n <Cell aria-hidden=\"true\" />\n </Pie>\n )}\n\n {totalValue && (\n <Pie\n data={adjustedParts}\n paddingAngle={adjustedParts.length === 1 ? 0 : 3}\n cornerRadius={10}\n isAnimationActive={!disableAnimation}\n {...defaultPieChartProps}\n >\n {adjustedParts.map((part, index) => (\n <Cell\n key={`cell-${index}`}\n fill={colorOf(part, index)}\n {...getCellA11yProps(part)}\n />\n ))}\n </Pie>\n )}\n\n {showTooltip && <Tooltip content={CustomTooltip} />}\n </PieChart>\n </Styles.ChartContainer>\n )\n\n if (!legend) return chart\n\n return (\n <Styles.WithLegend $position={legend}>\n {chart}\n <ChartLegend\n direction={legend === 'side' ? 'column' : 'row'}\n items={parts\n .map((part, index) => ({ part, color: colorOf(part, index) }))\n .filter(({ part }) => part.name)\n .map(({ part, color }) => ({\n label: part.name as string,\n color,\n value: part.display ?? part.value,\n }))}\n />\n </Styles.WithLegend>\n )\n}\n"],"names":["getCellA11yProps","part","name","display","value","DoughnutChart","size","totalValue","parts","fontSize","showTotalValue","showTooltip","tooltipValueFormatter","disableAnimation","customContent","legend","theme","useTheme","chartColors","CHART_COLOR_ORDER","map","getThemeColor","colorOf","index","color","length","adjustedParts","setAdjustedParts","useState","showBackground","setShowBackground","chartId","useId","useEffect","totalSum","reduce","sum","auxParts","push","defaultPieChartProps","dataKey","innerRadius","outerRadius","startAngle","endAngle","chart","_jsxs","Styles","_jsx","children","PieChart","width","height","id","Pie","data","fill","animationDuration","isAnimationActive","Cell","paddingAngle","cornerRadius","Tooltip","content","CustomTooltip","active","payload","hasName","direction","_Fragment","Text","fontWeight","$position","ChartLegend","items","filter","label"],"mappings":"u1BAcA,MAAMA,EAAoBC,GACxBA,EAAKC,KACD,CAAE,aAAc,GAAGD,EAAKC,SAASD,EAAKE,SAAWF,EAAKG,SACtD,CAAE,cAAe,QAWVC,EAAgBA,EAC3BC,OAAO,IACPC,aACAC,QACAC,WACAC,kBAAiB,EACjBC,eAAc,EACdC,wBACAC,oBAAmB,EACnBC,gBACAC,aAEA,MAAMC,EAAQC,IACRC,EAAcC,EAAkBC,KAAKlB,GACzCmB,WAAuBnB,IAAQc,KAE3BM,EAAUA,CAACrB,EAAkBsB,IACjCF,EAAcpB,EAAKuB,OAASN,EAAYK,EAAQL,EAAYO,QAAST,IAEhEU,EAAeC,GAAoBC,EAAuB,KAC1DC,EAAgBC,GAAqBF,GAAS,GAE/CG,EAAUC,IAEhBC,GAAU,KACR,MAAMC,EAAW1B,EAAM2B,QAAO,CAACC,EAAKnC,IAASmC,EAAMnC,EAAKG,OAAO,GACzDiC,EAAW,IAAI7B,GAEjB0B,IAAa3B,IACM,IAAjBC,EAAMiB,QACRK,GAAkB,GAClBO,EAASC,KAAK,CACZlC,MAAOG,EAAa2B,EACpBV,MAAO,cACPrB,QAAS,UAGXkC,EAASC,KAAK,CACZlC,MAAOG,EAAa2B,EACpBV,MAAOH,EAAc,SAAUL,MAIrCW,EAAiB,IAAIU,GAAU,GAC9B,CAAC7B,IAEJ,MAAM+B,EAAuB,CAC3BC,QAAS,QACTC,YAAcnC,EAAO,EAAK,IAC1BoC,YAAapC,EAAO,EACpBqC,WAAY,GACZC,UAAW,KAsBPC,EACJC,EAACC,iBAAkC,iBAAiB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B,EAACC,EAAiB,CAAAyB,UAAYzD,EAAMkC,SAAA,CACjCJ,EACDG,EAACyB,EACC,CAAAL,UAAsB,SAAXrD,EAAoB,SAAW,MAC1C2D,MAAOlE,EACJY,KAAI,CAACnB,EAAMsB,KAAW,CAAEtB,OAAMuB,MAAOF,EAAQrB,EAAMsB,OACnDoD,QAAO,EAAG1E,UAAWA,EAAKC,OAC1BkB,KAAI,EAAGnB,OAAMuB,YAAa,CACzBoD,MAAO3E,EAAKC,KACZsB,QACApB,MAAOH,EAAKE,SAAWF,EAAKG,eAblByC,CAgBE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as o}from"styled-components";import{ChartContainer as r,CustomTooltip as i}from"./line-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{CartesianGrid as s}from"../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";import{XAxis as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as o}from"styled-components";import{ChartContainer as r,CustomTooltip as i}from"./line-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{CartesianGrid as s}from"../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";import{XAxis as m}from"../../../node_modules/recharts/es6/cartesian/XAxis.js";import{YAxis as n}from"../../../node_modules/recharts/es6/cartesian/YAxis.js";import{Tooltip as l}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{Area as d}from"../../../node_modules/recharts/es6/cartesian/Area.js";import{Line as h}from"../../../node_modules/recharts/es6/cartesian/Line.js";import{AreaChart as c}from"../../../node_modules/recharts/es6/chart/AreaChart.js";import{LineChart as p}from"../../../node_modules/recharts/es6/chart/LineChart.js";import{CHART_COLOR_ORDER as f}from"../../../theme/chart-colors.js";import{getThemeColor as y}from"../../../theme/theme.util.js";import{Text as g}from"../../typography/text/text.comp.js";const u=({active:o,payload:r,label:a})=>o&&r&&r.length?t(i,{direction:"column",gap:1,children:[e(g,{size:"small",fontWeight:500,children:a}),r.map(((e,o)=>t(g,{size:"small",color:e.color,children:[e.name,": ",e.value]},o)))]}):null,_=({width:i=500,height:g=300,data:_,series:j,showArea:k=!1,showGrid:x=!0,xAxisLabel:v,yAxisLabel:A,yAxisFormatter:z})=>{const K=o(),b=f.map((e=>y(`chart.${e}`,K))),w=(e,t)=>y(e??b[t%b.length],K);return e(r,{"data-testid":"line-chart",width:i,height:g,children:e(a,{width:"100%",height:"100%",children:t(k?c:p,{width:i,height:g,data:_,margin:{top:5,right:30,left:20,bottom:5},children:[x&&e(s,{strokeDasharray:"3 3",stroke:y("grey_4",K),horizontal:!0,vertical:!1}),e(m,{dataKey:"name",stroke:y("grey_3",K),tick:{fill:y("grey_2",K),fontSize:12},label:v?{value:v,position:"insideBottom",offset:-5,style:{fill:y("grey_2",K),fontSize:12}}:void 0}),e(n,{stroke:y("grey_3",K),tick:{fill:y("grey_2",K),fontSize:12},tickFormatter:z,label:A?{value:A,angle:-90,position:"insideLeft",style:{fill:y("grey_2",K),fontSize:12}}:void 0}),e(l,{content:e(u,{})}),k?j.map(((t,o)=>e(d,{type:"monotone",dataKey:t.dataKey,name:t.name,stroke:w(t.color,o),fill:w(t.color,o),fillOpacity:.2,strokeWidth:t.strokeWidth||2},t.dataKey))):j.map(((t,o)=>e(h,{type:"monotone",dataKey:t.dataKey,name:t.name,stroke:w(t.color,o),strokeWidth:t.strokeWidth||2,dot:{r:4},activeDot:{r:6}},t.dataKey)))]})})})};export{_ as LineChart};
|
|
2
2
|
//# sourceMappingURL=line-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.comp.js","sources":["../../../../../src/components/charts/line-chart/line-chart.comp.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as AreaChartRecharts,\n CartesianGrid,\n Line,\n LineChart as LineChartRecharts,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { LineChartProps } from './line-chart.types'\n\nimport * as Styles from './line-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text key={index} size=\"small\" color={entry.color}>\n {entry.name}: {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).\n * `showArea` preenche a área abaixo da linha.\n * Para comparar categorias sem ordem de tempo use BarChart.\n * @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: '
|
|
1
|
+
{"version":3,"file":"line-chart.comp.js","sources":["../../../../../src/components/charts/line-chart/line-chart.comp.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as AreaChartRecharts,\n CartesianGrid,\n Line,\n LineChart as LineChartRecharts,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { LineChartProps } from './line-chart.types'\n\nimport * as Styles from './line-chart.styles'\n\nconst CustomTooltip = ({ active, payload, label }: any) => {\n if (!active || !payload || !payload.length) return null\n\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {label}\n </Text>\n {payload.map((entry: any, index: number) => (\n <Text key={index} size=\"small\" color={entry.color}>\n {entry.name}: {entry.value}\n </Text>\n ))}\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Gráfico de linhas para mostrar evolução no tempo, com uma ou mais séries (`series`).\n * `showArea` preenche a área abaixo da linha.\n * Para comparar categorias sem ordem de tempo use BarChart.\n * @example <LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: 'chart.purple' }]} />\n */\nexport const LineChart = ({\n width = 500,\n height = 300,\n data,\n series,\n showArea = false,\n showGrid = true,\n xAxisLabel,\n yAxisLabel,\n yAxisFormatter,\n}: LineChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const colorOf = (color: string | undefined, index: number) =>\n getThemeColor(color ?? chartColors[index % chartColors.length], theme)\n\n const ChartComponent = showArea ? AreaChartRecharts : LineChartRecharts\n\n return (\n <Styles.ChartContainer\n data-testid=\"line-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <ChartComponent\n width={width}\n height={height}\n data={data}\n margin={{ top: 5, right: 30, left: 20, bottom: 5 }}\n >\n {showGrid && (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n stroke={getThemeColor('grey_4', theme)}\n horizontal\n vertical={false}\n />\n )}\n <XAxis\n dataKey=\"name\"\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n label={\n xAxisLabel\n ? {\n value: xAxisLabel,\n position: 'insideBottom',\n offset: -5,\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <YAxis\n stroke={getThemeColor('grey_3', theme)}\n tick={{ fill: getThemeColor('grey_2', theme), fontSize: 12 }}\n tickFormatter={yAxisFormatter}\n label={\n yAxisLabel\n ? {\n value: yAxisLabel,\n angle: -90,\n position: 'insideLeft',\n style: {\n fill: getThemeColor('grey_2', theme),\n fontSize: 12,\n },\n }\n : undefined\n }\n />\n <Tooltip content={<CustomTooltip />} />\n {showArea\n ? series.map((serie, index) => (\n <Area\n key={serie.dataKey}\n type=\"monotone\"\n dataKey={serie.dataKey}\n name={serie.name}\n stroke={colorOf(serie.color, index)}\n fill={colorOf(serie.color, index)}\n fillOpacity={0.2}\n strokeWidth={serie.strokeWidth || 2}\n />\n ))\n : series.map((serie, index) => (\n <Line\n key={serie.dataKey}\n type=\"monotone\"\n dataKey={serie.dataKey}\n name={serie.name}\n stroke={colorOf(serie.color, index)}\n strokeWidth={serie.strokeWidth || 2}\n dot={{ r: 4 }}\n activeDot={{ r: 6 }}\n />\n ))}\n </ChartComponent>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomTooltip","active","payload","label","length","_jsxs","Styles","direction","gap","children","_jsx","Text","size","fontWeight","map","entry","index","color","name","value","LineChart","width","height","data","series","showArea","showGrid","xAxisLabel","yAxisLabel","yAxisFormatter","theme","useTheme","chartColors","CHART_COLOR_ORDER","getThemeColor","colorOf","ResponsiveContainer","AreaChartRecharts","LineChartRecharts","margin","top","right","left","bottom","CartesianGrid","strokeDasharray","stroke","horizontal","vertical","XAxis","dataKey","tick","fill","fontSize","position","offset","style","undefined","YAxis","tickFormatter","angle","Tooltip","content","serie","Area","type","fillOpacity","strokeWidth","Line","dot","r","activeDot"],"mappings":"slCAoBA,MAAMA,EAAgBA,EAAGC,SAAQC,UAASC,WACnCF,GAAWC,GAAYA,EAAQE,OAGlCC,EAACC,EAAoB,CAACC,UAAU,SAASC,IAAK,EAC5CC,SAAA,CAAAC,EAACC,EAAI,CAACC,KAAK,QAAQC,WAAY,IAC5BJ,SAAAN,IAEFD,EAAQY,KAAI,CAACC,EAAYC,IACxBX,EAACM,EAAiB,CAAAC,KAAK,QAAQK,MAAOF,EAAME,MAAKR,SAAA,CAC9CM,EAAMG,KAAI,KAAIH,EAAMI,QADZH,QARkC,KAsBxCI,EAAYA,EACvBC,QAAQ,IACRC,SAAS,IACTC,OACAC,SACAC,YAAW,EACXC,YAAW,EACXC,aACAC,aACAC,qBAEA,MAAMC,EAAQC,IACRC,EAAcC,EAAkBnB,KAAKI,GACzCgB,WAAuBhB,IAAQY,KAE3BK,EAAUA,CAAClB,EAA2BD,IAC1CkB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e,GAP7BJ,EAAMb,WAUf1B,EAAOV,KAAI,CAACiD,EAAO/C,IACjBN,EAAC0D,GAECH,KAAK,WACLf,QAASa,EAAMb,QACfhC,KAAM6C,EAAM7C,KACZ4B,OAAQX,EAAQ4B,EAAM9C,MAAOD,GAC7BmD,YAAaJ,EAAMI,aAAe,EAClCE,IAAK,CAAEC,EAAG,GACVC,UAAW,CAAED,EAAG,IAPXP,EAAMb,iBAYD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as r}from"styled-components";import{ChartContainer as o,CustomTooltip as n}from"./treemap-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{Treemap as l}from"../../../node_modules/recharts/es6/chart/Treemap.js";import{Tooltip as i}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{Text as c}from"../../typography/text/text.comp.js";
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useTheme as r}from"styled-components";import{ChartContainer as o,CustomTooltip as n}from"./treemap-chart.styles.js";import{ResponsiveContainer as a}from"../../../node_modules/recharts/es6/component/ResponsiveContainer.js";import{Treemap as l}from"../../../node_modules/recharts/es6/chart/Treemap.js";import{Tooltip as i}from"../../../node_modules/recharts/es6/component/Tooltip.js";import{CHART_COLOR_ORDER as m}from"../../../theme/chart-colors.js";import{getThemeColor as h}from"../../../theme/theme.util.js";import{Text as c}from"../../typography/text/text.comp.js";function s({x:o=0,y:n=0,width:a=0,height:l=0,name:i,value:m,fill:c,valueFormatter:s}){const d=a>=60&&l>=40,p=a>=60&&l>=60,u=r(),f=function(e){const t=e.replace("#","");if(6!==t.length)return!1;const r=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return(.299*r+.587*o+.114*n)/255<.5}(c??h("chart.grey",u)),g=f?u.colors.white:u.colors.grey_1,x=f?"rgba(255,255,255,0.75)":u.colors.grey_2;return t("g",{children:[e("rect",{x:o+1,y:n+1,width:Math.max(0,a-2),height:Math.max(0,l-2),fill:c??h("chart.grey",u),rx:3,ry:3}),d&&i&&e("text",{x:o+a/2,y:n+l/2-(p?10:0),textAnchor:"middle",dominantBaseline:"middle",fill:g,fontSize:Math.min(13,Math.max(9,a/10)),fontWeight:600,pointerEvents:"none",children:i.length>Math.floor(a/7)?`${i.slice(0,Math.floor(a/7)-1)}…`:i}),p&&null!=m&&e("text",{x:o+a/2,y:n+l/2+12,textAnchor:"middle",dominantBaseline:"middle",fill:x,fontSize:Math.min(11,Math.max(9,a/12)),pointerEvents:"none",children:s?s(m):m})]})}const d=({active:r,payload:o,valueFormatter:a})=>{if(!r||!o?.length)return null;const l=o[0].payload;return t(n,{direction:"column",gap:1,children:[e(c,{size:"small",fontWeight:500,children:l.name}),e(c,{size:"small",color:"grey_2",children:a?a(l.value):l.value})]})},p=({width:t="100%",height:n=300,data:c,valueFormatter:p})=>{const u=r(),f=m.map((e=>h(`chart.${e}`,u))),g=c.map(((e,t)=>({name:e.name,value:e.value>0?e.value:.01,fill:h(e.color??f[t%f.length],u)})));return e(o,{"data-testid":"treemap-chart",width:t,height:n,children:e(a,{width:"100%",height:"100%",children:e(l,{data:g,dataKey:"value",content:t=>e(s,{...t,valueFormatter:p}),children:e(i,{content:t=>e(d,{...t,valueFormatter:p})})})})})};export{p as TreemapChart};
|
|
2
2
|
//# sourceMappingURL=treemap-chart.comp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treemap-chart.comp.js","sources":["../../../../../src/components/charts/treemap-chart/treemap-chart.comp.tsx"],"sourcesContent":["import { ResponsiveContainer, Tooltip, Treemap } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { Text } from '../../typography'\n\nimport { TreemapChartProps } from './treemap-chart.types'\n\nimport * as Styles from './treemap-chart.styles'\n\ninterface ContentProps {\n x?: number\n y?: number\n width?: number\n height?: number\n name?: string\n value?: number\n fill?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"treemap-chart.comp.js","sources":["../../../../../src/components/charts/treemap-chart/treemap-chart.comp.tsx"],"sourcesContent":["import { ResponsiveContainer, Tooltip, Treemap } from 'recharts'\nimport { useTheme } from 'styled-components'\n\nimport { CHART_COLOR_ORDER, getThemeColor } from '../../../theme'\nimport { Text } from '../../typography'\n\nimport { TreemapChartProps } from './treemap-chart.types'\n\nimport * as Styles from './treemap-chart.styles'\n\ninterface ContentProps {\n x?: number\n y?: number\n width?: number\n height?: number\n name?: string\n value?: number\n fill?: string\n}\n\nconst MIN_WIDTH_FOR_TEXT = 60\nconst MIN_HEIGHT_FOR_TEXT = 40\nconst MIN_HEIGHT_FOR_VALUE = 60\n\nfunction CustomContent({\n x = 0,\n y = 0,\n width = 0,\n height = 0,\n name,\n value,\n fill,\n valueFormatter,\n}: ContentProps & { valueFormatter?: (v: number) => string }) {\n const showText = width >= MIN_WIDTH_FOR_TEXT && height >= MIN_HEIGHT_FOR_TEXT\n const showValue =\n width >= MIN_WIDTH_FOR_TEXT && height >= MIN_HEIGHT_FOR_VALUE\n\n const theme = useTheme()\n const isDark = isDarkColor(fill ?? getThemeColor('chart.grey', theme))\n const textColor = isDark ? theme.colors.white : theme.colors.grey_1\n const subTextColor = isDark ? 'rgba(255,255,255,0.75)' : theme.colors.grey_2\n\n return (\n <g>\n <rect\n x={x + 1}\n y={y + 1}\n width={Math.max(0, width - 2)}\n height={Math.max(0, height - 2)}\n fill={fill ?? getThemeColor('chart.grey', theme)}\n rx={3}\n ry={3}\n />\n {showText && name && (\n <text\n x={x + width / 2}\n y={y + height / 2 - (showValue ? 10 : 0)}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n fill={textColor}\n fontSize={Math.min(13, Math.max(9, width / 10))}\n fontWeight={600}\n pointerEvents=\"none\"\n >\n {name.length > Math.floor(width / 7)\n ? `${name.slice(0, Math.floor(width / 7) - 1)}…`\n : name}\n </text>\n )}\n {showValue && value != null && (\n <text\n x={x + width / 2}\n y={y + height / 2 + 12}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n fill={subTextColor}\n fontSize={Math.min(11, Math.max(9, width / 12))}\n pointerEvents=\"none\"\n >\n {valueFormatter ? valueFormatter(value) : value}\n </text>\n )}\n </g>\n )\n}\n\nfunction isDarkColor(hex: string): boolean {\n const clean = hex.replace('#', '')\n if (clean.length !== 6) return false\n const r = parseInt(clean.slice(0, 2), 16)\n const g = parseInt(clean.slice(2, 4), 16)\n const b = parseInt(clean.slice(4, 6), 16)\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255\n return luminance < 0.5\n}\n\nconst CustomTooltip = ({\n active,\n payload,\n valueFormatter,\n}: {\n active?: boolean\n payload?: Array<{ payload: { name: string; value: number; fill: string } }>\n valueFormatter?: (v: number) => string\n}) => {\n if (!active || !payload?.length) return null\n const item = payload[0].payload\n return (\n <Styles.CustomTooltip direction=\"column\" gap={1}>\n <Text size=\"small\" fontWeight={500}>\n {item.name}\n </Text>\n <Text size=\"small\" color=\"grey_2\">\n {valueFormatter ? valueFormatter(item.value) : item.value}\n </Text>\n </Styles.CustomTooltip>\n )\n}\n\n/**\n * Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).\n * Para poucas categorias use BarChart ou DoughnutChart.\n * Cor de cada bloco pela paleta de gráfico (`color: 'chart.lilac'`); sem cor, segue a ordem de\n * `getChartColors`.\n * @example <TreemapChart data={[{ name: 'Algodão', value: 120 }, { name: 'Poliéster', value: 40 }]} />\n */\nexport const TreemapChart = ({\n width = '100%',\n height = 300,\n data,\n valueFormatter,\n}: TreemapChartProps) => {\n const theme = useTheme()\n const chartColors = CHART_COLOR_ORDER.map((name) =>\n getThemeColor(`chart.${name}`, theme),\n )\n const rechartsData = data.map((item, index) => ({\n name: item.name,\n value: item.value > 0 ? item.value : 0.01,\n fill: getThemeColor(\n item.color ?? chartColors[index % chartColors.length],\n theme,\n ),\n }))\n\n return (\n <Styles.ChartContainer\n data-testid=\"treemap-chart\"\n width={width}\n height={height}\n >\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n <Treemap\n data={rechartsData}\n dataKey=\"value\"\n content={\n ((props: ContentProps) => (\n <CustomContent {...props} valueFormatter={valueFormatter} />\n )) as any\n }\n >\n <Tooltip\n content={\n ((props: any) => (\n <CustomTooltip {...props} valueFormatter={valueFormatter} />\n )) as any\n }\n />\n </Treemap>\n </ResponsiveContainer>\n </Styles.ChartContainer>\n )\n}\n"],"names":["CustomContent","x","y","width","height","name","value","fill","valueFormatter","showText","showValue","theme","useTheme","isDark","hex","clean","replace","length","r","parseInt","slice","g","b","isDarkColor","getThemeColor","textColor","colors","white","grey_1","subTextColor","grey_2","_jsxs","children","_jsx","Math","max","rx","ry","textAnchor","dominantBaseline","fontSize","min","fontWeight","pointerEvents","floor","CustomTooltip","active","payload","item","Styles","direction","gap","Text","size","color","TreemapChart","data","chartColors","CHART_COLOR_ORDER","map","rechartsData","index","ResponsiveContainer","Treemap","dataKey","content","props","Tooltip"],"mappings":"inBAwBA,SAASA,GAAcC,EACrBA,EAAI,EAACC,EACLA,EAAI,EAACC,MACLA,EAAQ,EAACC,OACTA,EAAS,EAACC,KACVA,EAAIC,MACJA,EAAKC,KACLA,EAAIC,eACJA,IAEA,MAAMC,EAAWN,GAdQ,IAcuBC,GAbtB,GAcpBM,EACJP,GAhBuB,IAgBQC,GAdN,GAgBrBO,EAAQC,IACRC,EAgDR,SAAqBC,GACnB,MAAMC,EAAQD,EAAIE,QAAQ,IAAK,IAC/B,GAAqB,IAAjBD,EAAME,OAAc,OAAO,EAC/B,MAAMC,EAAIC,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAChCC,EAAIF,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAChCE,EAAIH,SAASJ,EAAMK,MAAM,EAAG,GAAI,IAEtC,OADmB,KAAQF,EAAI,KAAQG,EAAI,KAAQC,GAA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B,SAAA,CAC7CC,EAACmB,EAAK,CAAAC,KAAK,QAAQX,WAAY,IAC5BV,SAAAgB,EAAK3C,OAER4B,EAACmB,EAAK,CAAAC,KAAK,QAAQC,MAAM,SACtBtB,SAAAxB,EAAiBA,EAAewC,EAAK1C,OAAS0C,EAAK1C,UAEjC,EAWdiD,EAAeA,EAC1BpD,QAAQ,OACRC,SAAS,IACToD,OACAhD,qBAEA,MAAMG,EAAQC,IACR6C,EAAcC,EAAkBC,KAAKtD,GACzCmB,WAAuBnB,IAAQM,KAE3BiD,EAAeJ,EAAKG,KAAI,CAACX,EAAMa,KAAW,CAC9CxD,KAAM2C,EAAK3C,KACXC,MAAO0C,EAAK1C,MAAQ,EAAI0C,EAAK1C,MAAQ,IACrCC,KAAMiB,EACJwB,EAAKM,OAASG,EAAYI,EAAQJ,EAAYxC,QAC9CN,OAIJ,OACEsB,EAACgB,EAAqB,CAAA,cACR,gBACZ9C,MAAOA,EACPC,OAAQA,EAER4B,SAAAC,EAAC6B,EAAoB,CAAA3D,MAAM,OAAOC,OAAO,OAEvC4B,SAAAC,EAAC8B,EACC,CAAAP,KAAMI,EACNI,QAAQ,QACRC,QACIC,GACAjC,EAACjC,EAAkB,IAAAkE,EAAO1D,eAAgBA,IAI9CwB,SAAAC,EAACkC,EACC,CAAAF,QACIC,GACAjC,EAACY,EAAa,IAAKqB,EAAO1D,eAAgBA,WAM9B"}
|
package/llms-full.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Blockforce Design System 2.0.
|
|
1
|
+
# Blockforce Design System 2.0.5 (completo)
|
|
2
2
|
|
|
3
3
|
> Pacote `blockforce-design-system`. Storybook: https://designsystem.blockforce.ai
|
|
4
4
|
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
1. **Procure a peça antes de criar uma nova.** Card, Tag, Toast, EmptyState, IconButton, Skeleton, Pagination, DatePicker, Matrix e as peças da árvore já existem. A lista completa está em `lib/ai/components.json`.
|
|
8
8
|
2. **Nunca escreva cor, tamanho, raio ou sombra à mão.** Use o token do tema: `theme.colors.grey_2`, `theme.spacing.md`, `theme.radius.lg`, `theme.shadow.sm`. Em props de componente, use o nome (`color="primary"`, `padding="md"`).
|
|
9
9
|
3. **Cores com os nomes de sempre:** `primary` (roxo), `secondary` (teal), `grey_1`…`grey_6`, `white`. Estados em `state.*`, fundos claros de estado em `stateSubtle.*`, texto de estado em `stateText.*`, gráficos em `chart.*`.
|
|
10
|
+
- **Gráfico usa só `chart.*`, mesmo quando cada fatia é um status** (aprovado, pendente, reprovado). `DoughnutChart`, `BarChart`, `LineChart`, `TreemapChart` e `ChartLegend` nunca levam verde, laranja e vermelho de `state.*` nem hex. Bom, parcial e ruim: `chart.blue`, `chart.lightBlue` e `chart.purple`.
|
|
11
|
+
- **Como passar:** o nome (`color: 'chart.blue'`) ou nenhuma cor, que o gráfico segue a ordem de `getChartColors`.
|
|
10
12
|
4. **O gradiente é a marca e existe um só:** `theme.colors.brand.gradient`, a 45°, roxo → teal. Nunca outro ângulo nem outras cores.
|
|
11
13
|
5. **Cor de estado é só para estado.** Verde é sucesso, laranja é alerta, vermelho é erro. O teal da marca não é cor de sucesso.
|
|
12
14
|
6. **A fonte é Inter** (`theme.typography.fontFamily`). O projeto carrega a Inter de 300 a 700; o DS não carrega fonte.
|
|
@@ -29,7 +31,13 @@
|
|
|
29
31
|
## Como usar
|
|
30
32
|
|
|
31
33
|
```tsx
|
|
32
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
ThemeProvider,
|
|
36
|
+
defaultTheme,
|
|
37
|
+
Card,
|
|
38
|
+
Tag,
|
|
39
|
+
Button,
|
|
40
|
+
} from 'blockforce-design-system'
|
|
33
41
|
|
|
34
42
|
export const App = () => (
|
|
35
43
|
<ThemeProvider theme={defaultTheme}>
|
|
@@ -1302,6 +1310,7 @@ Props:
|
|
|
1302
1310
|
Gráfico de barras para comparar valores entre categorias (ex.: emissões por fornecedor).
|
|
1303
1311
|
Cada item de `data` é uma barra, com `name` e `value`.
|
|
1304
1312
|
Para evolução no tempo use LineChart; para partes de um total use DoughnutChart.
|
|
1313
|
+
Cor da barra pela paleta de gráfico (`color: 'chart.purple'`), mesmo quando a barra é um status.
|
|
1305
1314
|
|
|
1306
1315
|
|
|
1307
1316
|
Exemplo:
|
|
@@ -1337,7 +1346,7 @@ Use ao lado ou abaixo de qualquer gráfico; o DoughnutChart já monta a dele com
|
|
|
1337
1346
|
Exemplo:
|
|
1338
1347
|
|
|
1339
1348
|
```tsx
|
|
1340
|
-
<ChartLegend items={[{ label: 'Aprovados', color: '
|
|
1349
|
+
<ChartLegend items={[{ label: 'Aprovados', color: 'chart.blue', value: '60%' }]} />
|
|
1341
1350
|
```
|
|
1342
1351
|
|
|
1343
1352
|
Exemplo:
|
|
@@ -1360,12 +1369,14 @@ Rosca que mostra partes de um total (ex.: 60% dos fornecedores aprovados).
|
|
|
1360
1369
|
`parts` são as fatias; o que faltar para chegar em `totalValue` aparece em cinza.
|
|
1361
1370
|
`legend` mostra a legenda das fatias com nome ao lado (`side`) ou abaixo (`bottom`).
|
|
1362
1371
|
Use com até 5 fatias. Com mais categorias use BarChart.
|
|
1372
|
+
As fatias usam a paleta de gráfico (`chart.*`), mesmo quando cada uma é um status: passe o nome
|
|
1373
|
+
(`color: 'chart.blue'`) ou deixe sem cor, que a rosca segue a ordem de `getChartColors`.
|
|
1363
1374
|
|
|
1364
1375
|
|
|
1365
1376
|
Exemplo:
|
|
1366
1377
|
|
|
1367
1378
|
```tsx
|
|
1368
|
-
<DoughnutChart totalValue={100} parts={[{ value: 60, color: '
|
|
1379
|
+
<DoughnutChart totalValue={100} parts={[{ value: 60, color: 'chart.blue', name: 'Aprovados' }]} />
|
|
1369
1380
|
```
|
|
1370
1381
|
|
|
1371
1382
|
Documentação: https://designsystem.blockforce.ai/?path=/docs/gráficos-doughnutchart--docs
|
|
@@ -1394,7 +1405,7 @@ Para comparar categorias sem ordem de tempo use BarChart.
|
|
|
1394
1405
|
Exemplo:
|
|
1395
1406
|
|
|
1396
1407
|
```tsx
|
|
1397
|
-
<LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: '
|
|
1408
|
+
<LineChart data={dados} series={[{ dataKey: 'total', name: 'Total', color: 'chart.purple' }]} />
|
|
1398
1409
|
```
|
|
1399
1410
|
|
|
1400
1411
|
Documentação: https://designsystem.blockforce.ai/?path=/docs/gráficos-linechart--docs
|
|
@@ -1415,6 +1426,8 @@ Props:
|
|
|
1415
1426
|
|
|
1416
1427
|
Retângulos com área proporcional ao valor, para mostrar o peso de muitas categorias de uma vez (ex.: volume por material).
|
|
1417
1428
|
Para poucas categorias use BarChart ou DoughnutChart.
|
|
1429
|
+
Cor de cada bloco pela paleta de gráfico (`color: 'chart.lilac'`); sem cor, segue a ordem de
|
|
1430
|
+
`getChartColors`.
|
|
1418
1431
|
|
|
1419
1432
|
|
|
1420
1433
|
Exemplo:
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Blockforce Design System 2.0.
|
|
1
|
+
# Blockforce Design System 2.0.5
|
|
2
2
|
|
|
3
3
|
> Componentes React (styled-components) e tokens visuais da Blockforce. Pacote `blockforce-design-system`. Storybook com exemplos e props: https://designsystem.blockforce.ai
|
|
4
4
|
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
1. **Procure a peça antes de criar uma nova.** Card, Tag, Toast, EmptyState, IconButton, Skeleton, Pagination, DatePicker, Matrix e as peças da árvore já existem. A lista completa está em `lib/ai/components.json`.
|
|
8
8
|
2. **Nunca escreva cor, tamanho, raio ou sombra à mão.** Use o token do tema: `theme.colors.grey_2`, `theme.spacing.md`, `theme.radius.lg`, `theme.shadow.sm`. Em props de componente, use o nome (`color="primary"`, `padding="md"`).
|
|
9
9
|
3. **Cores com os nomes de sempre:** `primary` (roxo), `secondary` (teal), `grey_1`…`grey_6`, `white`. Estados em `state.*`, fundos claros de estado em `stateSubtle.*`, texto de estado em `stateText.*`, gráficos em `chart.*`.
|
|
10
|
+
- **Gráfico usa só `chart.*`, mesmo quando cada fatia é um status** (aprovado, pendente, reprovado). `DoughnutChart`, `BarChart`, `LineChart`, `TreemapChart` e `ChartLegend` nunca levam verde, laranja e vermelho de `state.*` nem hex. Bom, parcial e ruim: `chart.blue`, `chart.lightBlue` e `chart.purple`.
|
|
11
|
+
- **Como passar:** o nome (`color: 'chart.blue'`) ou nenhuma cor, que o gráfico segue a ordem de `getChartColors`.
|
|
10
12
|
4. **O gradiente é a marca e existe um só:** `theme.colors.brand.gradient`, a 45°, roxo → teal. Nunca outro ângulo nem outras cores.
|
|
11
13
|
5. **Cor de estado é só para estado.** Verde é sucesso, laranja é alerta, vermelho é erro. O teal da marca não é cor de sucesso.
|
|
12
14
|
6. **A fonte é Inter** (`theme.typography.fontFamily`). O projeto carrega a Inter de 300 a 700; o DS não carrega fonte.
|
|
@@ -29,7 +31,13 @@
|
|
|
29
31
|
## Como usar
|
|
30
32
|
|
|
31
33
|
```tsx
|
|
32
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
ThemeProvider,
|
|
36
|
+
defaultTheme,
|
|
37
|
+
Card,
|
|
38
|
+
Tag,
|
|
39
|
+
Button,
|
|
40
|
+
} from 'blockforce-design-system'
|
|
33
41
|
|
|
34
42
|
export const App = () => (
|
|
35
43
|
<ThemeProvider theme={defaultTheme}>
|