@apipass/design-system 5.0.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/lib/charts.index.cjs +1 -1
  2. package/dist/lib/charts.index.js +6 -4
  3. package/dist/lib/charts.index.js.map +1 -1
  4. package/dist/lib/embedded-styles.js +2 -2
  5. package/dist/lib/style.css +1 -1
  6. package/dist/lib/ui/components/PageHeader/PageHeader.cjs +1 -1
  7. package/dist/lib/ui/components/PageHeader/PageHeader.cjs.map +1 -1
  8. package/dist/lib/ui/components/PageHeader/PageHeader.js +32 -31
  9. package/dist/lib/ui/components/PageHeader/PageHeader.js.map +1 -1
  10. package/dist/lib/ui/components/WidgetGrid/WidgetGrid.cjs +1 -1
  11. package/dist/lib/ui/components/WidgetGrid/WidgetGrid.cjs.map +1 -1
  12. package/dist/lib/ui/components/WidgetGrid/WidgetGrid.js +25 -25
  13. package/dist/lib/ui/components/WidgetGrid/WidgetGrid.js.map +1 -1
  14. package/dist/lib/ui/components/charts/BarChart/BarChart.cjs +2 -0
  15. package/dist/lib/ui/components/charts/BarChart/BarChart.cjs.map +1 -0
  16. package/dist/lib/ui/components/charts/BarChart/BarChart.js +61 -0
  17. package/dist/lib/ui/components/charts/BarChart/BarChart.js.map +1 -0
  18. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs +2 -0
  19. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs.map +1 -0
  20. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js +176 -0
  21. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js.map +1 -0
  22. package/dist/types/charts.index.d.ts +1 -0
  23. package/dist/types/ui/components/charts/BarChart/BarChart.d.ts +15 -0
  24. package/dist/types/ui/components/charts/BarChart/bar-chart-option.d.ts +35 -0
  25. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");;/* empty css */const l=require("../../icons/IconArrowLeft.cjs"),n=require("../../layout/Flex/Flex.cjs"),o=require("../../primitives/IconButton/IconButton.cjs"),s=require("../../primitives/Text/Text.cjs");function d({title:i,subtitle:r,onBack:t,backLabel:c}){const a=e.jsx(s.Text,{elementType:"h1",className:"page-header-title",children:i});return e.jsxs(n.Flex,{direction:"column",gap:"200",className:"page-header",children:[t?e.jsxs(n.Flex,{direction:"row",gap:"200",alignSecondary:"center",className:"page-header-title-row",children:[e.jsx(o.IconButton,{"aria-label":c??"Back",variant:"subtle",size:"small",onPress:t,children:e.jsx(l.IconArrowLeft,{size:"20"})}),a]}):a,r&&e.jsx(s.Text,{className:"page-header-subtitle",children:r})]})}exports.PageHeader=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");;/* empty css */const l=require("../../icons/IconArrowLeft.cjs"),s=require("../../layout/Flex/Flex.cjs"),o=require("../../primitives/IconButton/IconButton.cjs"),n=require("../../primitives/Text/Text.cjs");function d({title:c,subtitle:r,onBack:a,backLabel:i}){const t=e.jsxs(s.Flex,{direction:"column",gap:"200",className:"page-header-text",children:[e.jsx(n.Text,{elementType:"h1",className:"page-header-title",children:c}),r&&e.jsx(n.Text,{className:"page-header-subtitle",children:r})]});return a?e.jsxs(s.Flex,{direction:"row",gap:"200",alignSecondary:"start",className:"page-header page-header-title-row",children:[e.jsx(o.IconButton,{"aria-label":i??"Back",variant:"subtle",size:"small",className:"page-header-back",onPress:a,children:e.jsx(l.IconArrowLeft,{size:"20"})}),t]}):e.jsx("div",{className:"page-header",children:t})}exports.PageHeader=d;
2
2
  //# sourceMappingURL=PageHeader.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageHeader.cjs","sources":["../../../../../src/ui/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { IconArrowLeft } from \"icons\";\nimport { Flex } from \"layout\";\nimport { IconButton, Text } from \"primitives\";\nimport \"./pageheader.css\";\n\nexport interface PageHeaderProps {\n title: string;\n subtitle?: string;\n onBack?: () => void;\n backLabel?: string;\n}\n\nexport function PageHeader({ title, subtitle, onBack, backLabel }: PageHeaderProps) {\n const heading = (\n <Text elementType=\"h1\" className=\"page-header-title\">\n {title}\n </Text>\n );\n\n return (\n <Flex direction=\"column\" gap=\"200\" className=\"page-header\">\n {onBack ? (\n <Flex\n direction=\"row\"\n gap=\"200\"\n alignSecondary=\"center\"\n className=\"page-header-title-row\"\n >\n <IconButton\n aria-label={backLabel ?? \"Back\"}\n variant=\"subtle\"\n size=\"small\"\n onPress={onBack}\n >\n <IconArrowLeft size=\"20\" />\n </IconButton>\n {heading}\n </Flex>\n ) : (\n heading\n )}\n {subtitle && <Text className=\"page-header-subtitle\">{subtitle}</Text>}\n </Flex>\n );\n}\n"],"names":["PageHeader","title","subtitle","onBack","backLabel","heading","jsx","Text","Flex","jsxs","IconButton","IconArrowLeft"],"mappings":"kVAYO,SAASA,EAAW,CAAE,MAAAC,EAAO,SAAAC,EAAU,OAAAC,EAAQ,UAAAC,GAA8B,CAClF,MAAMC,EACJC,EAAAA,IAACC,EAAAA,KAAA,CAAK,YAAY,KAAK,UAAU,oBAC9B,SAAAN,EACH,EAGF,cACGO,OAAA,CAAK,UAAU,SAAS,IAAI,MAAM,UAAU,cAC1C,SAAA,CAAAL,EACCM,EAAAA,KAACD,EAAAA,KAAA,CACC,UAAU,MACV,IAAI,MACJ,eAAe,SACf,UAAU,wBAEV,SAAA,CAAAF,EAAAA,IAACI,EAAAA,WAAA,CACC,aAAYN,GAAa,OACzB,QAAQ,SACR,KAAK,QACL,QAASD,EAET,SAAAG,EAAAA,IAACK,EAAAA,cAAA,CAAc,KAAK,IAAA,CAAK,CAAA,CAAA,EAE1BN,CAAA,CAAA,CAAA,EAGHA,EAEDH,GAAYI,EAAAA,IAACC,OAAA,CAAK,UAAU,uBAAwB,SAAAL,CAAA,CAAS,CAAA,EAChE,CAEJ"}
1
+ {"version":3,"file":"PageHeader.cjs","sources":["../../../../../src/ui/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { IconArrowLeft } from \"icons\";\nimport { Flex } from \"layout\";\nimport { IconButton, Text } from \"primitives\";\nimport \"./pageheader.css\";\n\nexport interface PageHeaderProps {\n title: string;\n subtitle?: string;\n onBack?: () => void;\n backLabel?: string;\n}\n\nexport function PageHeader({ title, subtitle, onBack, backLabel }: PageHeaderProps) {\n // Título e descrição formam um bloco só, e é esse bloco que o voltar empurra para a direita.\n // Soltos, os dois começavam em pontos diferentes: o título depois do botão e a descrição na\n // margem da página, alinhada com a seta em vez de com o próprio título.\n const titleBlock = (\n <Flex direction=\"column\" gap=\"200\" className=\"page-header-text\">\n <Text elementType=\"h1\" className=\"page-header-title\">\n {title}\n </Text>\n {subtitle && <Text className=\"page-header-subtitle\">{subtitle}</Text>}\n </Flex>\n );\n\n if (!onBack) {\n return <div className=\"page-header\">{titleBlock}</div>;\n }\n\n return (\n <Flex\n direction=\"row\"\n gap=\"200\"\n alignSecondary=\"start\"\n className=\"page-header page-header-title-row\"\n >\n <IconButton\n aria-label={backLabel ?? \"Back\"}\n variant=\"subtle\"\n size=\"small\"\n className=\"page-header-back\"\n onPress={onBack}\n >\n <IconArrowLeft size=\"20\" />\n </IconButton>\n {titleBlock}\n </Flex>\n );\n}\n"],"names":["PageHeader","title","subtitle","onBack","backLabel","titleBlock","Flex","jsx","Text","jsxs","IconButton","IconArrowLeft"],"mappings":"kVAYO,SAASA,EAAW,CAAE,MAAAC,EAAO,SAAAC,EAAU,OAAAC,EAAQ,UAAAC,GAA8B,CAIlF,MAAMC,SACHC,EAAAA,KAAA,CAAK,UAAU,SAAS,IAAI,MAAM,UAAU,mBAC3C,SAAA,CAAAC,MAACC,EAAAA,KAAA,CAAK,YAAY,KAAK,UAAU,oBAC9B,SAAAP,EACH,EACCC,GAAYK,EAAAA,IAACC,OAAA,CAAK,UAAU,uBAAwB,SAAAN,CAAA,CAAS,CAAA,EAChE,EAGF,OAAKC,EAKHM,EAAAA,KAACH,EAAAA,KAAA,CACC,UAAU,MACV,IAAI,MACJ,eAAe,QACf,UAAU,oCAEV,SAAA,CAAAC,EAAAA,IAACG,EAAAA,WAAA,CACC,aAAYN,GAAa,OACzB,QAAQ,SACR,KAAK,QACL,UAAU,mBACV,QAASD,EAET,SAAAI,EAAAA,IAACI,EAAAA,cAAA,CAAc,KAAK,IAAA,CAAK,CAAA,CAAA,EAE1BN,CAAA,CAAA,CAAA,EAnBIE,EAAAA,IAAC,MAAA,CAAI,UAAU,cAAe,SAAAF,EAAW,CAsBpD"}
@@ -1,36 +1,37 @@
1
- import { jsxs as o, jsx as e } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  /* empty css */
3
- import { IconArrowLeft as m } from "../../icons/IconArrowLeft.js";
4
- import { Flex as t } from "../../layout/Flex/Flex.js";
5
- import { IconButton as s } from "../../primitives/IconButton/IconButton.js";
6
- import { Text as n } from "../../primitives/Text/Text.js";
7
- function x({ title: l, subtitle: r, onBack: a, backLabel: c }) {
8
- const i = /* @__PURE__ */ e(n, { elementType: "h1", className: "page-header-title", children: l });
9
- return /* @__PURE__ */ o(t, { direction: "column", gap: "200", className: "page-header", children: [
10
- a ? /* @__PURE__ */ o(
11
- t,
12
- {
13
- direction: "row",
14
- gap: "200",
15
- alignSecondary: "center",
16
- className: "page-header-title-row",
17
- children: [
18
- /* @__PURE__ */ e(
19
- s,
20
- {
21
- "aria-label": c ?? "Back",
22
- variant: "subtle",
23
- size: "small",
24
- onPress: a,
25
- children: /* @__PURE__ */ e(m, { size: "20" })
26
- }
27
- ),
28
- i
29
- ]
30
- }
31
- ) : i,
32
- r && /* @__PURE__ */ e(n, { className: "page-header-subtitle", children: r })
3
+ import { IconArrowLeft as n } from "../../icons/IconArrowLeft.js";
4
+ import { Flex as l } from "../../layout/Flex/Flex.js";
5
+ import { IconButton as m } from "../../primitives/IconButton/IconButton.js";
6
+ import { Text as o } from "../../primitives/Text/Text.js";
7
+ function x({ title: s, subtitle: r, onBack: a, backLabel: c }) {
8
+ const t = /* @__PURE__ */ i(l, { direction: "column", gap: "200", className: "page-header-text", children: [
9
+ /* @__PURE__ */ e(o, { elementType: "h1", className: "page-header-title", children: s }),
10
+ r && /* @__PURE__ */ e(o, { className: "page-header-subtitle", children: r })
33
11
  ] });
12
+ return a ? /* @__PURE__ */ i(
13
+ l,
14
+ {
15
+ direction: "row",
16
+ gap: "200",
17
+ alignSecondary: "start",
18
+ className: "page-header page-header-title-row",
19
+ children: [
20
+ /* @__PURE__ */ e(
21
+ m,
22
+ {
23
+ "aria-label": c ?? "Back",
24
+ variant: "subtle",
25
+ size: "small",
26
+ className: "page-header-back",
27
+ onPress: a,
28
+ children: /* @__PURE__ */ e(n, { size: "20" })
29
+ }
30
+ ),
31
+ t
32
+ ]
33
+ }
34
+ ) : /* @__PURE__ */ e("div", { className: "page-header", children: t });
34
35
  }
35
36
  export {
36
37
  x as PageHeader
@@ -1 +1 @@
1
- {"version":3,"file":"PageHeader.js","sources":["../../../../../src/ui/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { IconArrowLeft } from \"icons\";\nimport { Flex } from \"layout\";\nimport { IconButton, Text } from \"primitives\";\nimport \"./pageheader.css\";\n\nexport interface PageHeaderProps {\n title: string;\n subtitle?: string;\n onBack?: () => void;\n backLabel?: string;\n}\n\nexport function PageHeader({ title, subtitle, onBack, backLabel }: PageHeaderProps) {\n const heading = (\n <Text elementType=\"h1\" className=\"page-header-title\">\n {title}\n </Text>\n );\n\n return (\n <Flex direction=\"column\" gap=\"200\" className=\"page-header\">\n {onBack ? (\n <Flex\n direction=\"row\"\n gap=\"200\"\n alignSecondary=\"center\"\n className=\"page-header-title-row\"\n >\n <IconButton\n aria-label={backLabel ?? \"Back\"}\n variant=\"subtle\"\n size=\"small\"\n onPress={onBack}\n >\n <IconArrowLeft size=\"20\" />\n </IconButton>\n {heading}\n </Flex>\n ) : (\n heading\n )}\n {subtitle && <Text className=\"page-header-subtitle\">{subtitle}</Text>}\n </Flex>\n );\n}\n"],"names":["PageHeader","title","subtitle","onBack","backLabel","heading","jsx","Text","Flex","jsxs","IconButton","IconArrowLeft"],"mappings":";;;;;;AAYO,SAASA,EAAW,EAAE,OAAAC,GAAO,UAAAC,GAAU,QAAAC,GAAQ,WAAAC,KAA8B;AAClF,QAAMC,IACJ,gBAAAC,EAACC,GAAA,EAAK,aAAY,MAAK,WAAU,qBAC9B,UAAAN,GACH;AAGF,2BACGO,GAAA,EAAK,WAAU,UAAS,KAAI,OAAM,WAAU,eAC1C,UAAA;AAAA,IAAAL,IACC,gBAAAM;AAAA,MAACD;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,KAAI;AAAA,QACJ,gBAAe;AAAA,QACf,WAAU;AAAA,QAEV,UAAA;AAAA,UAAA,gBAAAF;AAAA,YAACI;AAAA,YAAA;AAAA,cACC,cAAYN,KAAa;AAAA,cACzB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,SAASD;AAAA,cAET,UAAA,gBAAAG,EAACK,GAAA,EAAc,MAAK,KAAA,CAAK;AAAA,YAAA;AAAA,UAAA;AAAA,UAE1BN;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,IAGHA;AAAA,IAEDH,KAAY,gBAAAI,EAACC,GAAA,EAAK,WAAU,wBAAwB,UAAAL,EAAA,CAAS;AAAA,EAAA,GAChE;AAEJ;"}
1
+ {"version":3,"file":"PageHeader.js","sources":["../../../../../src/ui/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { IconArrowLeft } from \"icons\";\nimport { Flex } from \"layout\";\nimport { IconButton, Text } from \"primitives\";\nimport \"./pageheader.css\";\n\nexport interface PageHeaderProps {\n title: string;\n subtitle?: string;\n onBack?: () => void;\n backLabel?: string;\n}\n\nexport function PageHeader({ title, subtitle, onBack, backLabel }: PageHeaderProps) {\n // Título e descrição formam um bloco só, e é esse bloco que o voltar empurra para a direita.\n // Soltos, os dois começavam em pontos diferentes: o título depois do botão e a descrição na\n // margem da página, alinhada com a seta em vez de com o próprio título.\n const titleBlock = (\n <Flex direction=\"column\" gap=\"200\" className=\"page-header-text\">\n <Text elementType=\"h1\" className=\"page-header-title\">\n {title}\n </Text>\n {subtitle && <Text className=\"page-header-subtitle\">{subtitle}</Text>}\n </Flex>\n );\n\n if (!onBack) {\n return <div className=\"page-header\">{titleBlock}</div>;\n }\n\n return (\n <Flex\n direction=\"row\"\n gap=\"200\"\n alignSecondary=\"start\"\n className=\"page-header page-header-title-row\"\n >\n <IconButton\n aria-label={backLabel ?? \"Back\"}\n variant=\"subtle\"\n size=\"small\"\n className=\"page-header-back\"\n onPress={onBack}\n >\n <IconArrowLeft size=\"20\" />\n </IconButton>\n {titleBlock}\n </Flex>\n );\n}\n"],"names":["PageHeader","title","subtitle","onBack","backLabel","titleBlock","Flex","jsx","Text","jsxs","IconButton","IconArrowLeft"],"mappings":";;;;;;AAYO,SAASA,EAAW,EAAE,OAAAC,GAAO,UAAAC,GAAU,QAAAC,GAAQ,WAAAC,KAA8B;AAIlF,QAAMC,sBACHC,GAAA,EAAK,WAAU,UAAS,KAAI,OAAM,WAAU,oBAC3C,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAA,EAAK,aAAY,MAAK,WAAU,qBAC9B,UAAAP,GACH;AAAA,IACCC,KAAY,gBAAAK,EAACC,GAAA,EAAK,WAAU,wBAAwB,UAAAN,EAAA,CAAS;AAAA,EAAA,GAChE;AAGF,SAAKC,IAKH,gBAAAM;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,gBAAe;AAAA,MACf,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,gBAAAC;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,cAAYN,KAAa;AAAA,YACzB,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,WAAU;AAAA,YACV,SAASD;AAAA,YAET,UAAA,gBAAAI,EAACI,GAAA,EAAc,MAAK,KAAA,CAAK;AAAA,UAAA;AAAA,QAAA;AAAA,QAE1BN;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAnBI,gBAAAE,EAAC,OAAA,EAAI,WAAU,eAAe,UAAAF,GAAW;AAsBpD;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("../../../vendor/clsx/dist/clsx.cjs"),D=require("react"),c=require("../../../_virtual/index.cjs");;/* empty css */;/* empty css */;/* empty css */const G=c.WidthProvider(c),T=".widget-drag-handle",_=".widget-header-actions";function S({layout:g,onLayoutChange:r,cols:u=12,rowHeight:o=80,isEditable:n=!1,isDraggable:m,isResizable:E,className:R,style:q,children:i}){const b=g.map(({id:e,x:t,y:a,w:s,h:d})=>({i:e,x:t,y:a,w:s,h:d}));function x(e){r==null||r(e.map(({i:t,x:a,y:s,w:d,h:y})=>({id:t,x:a,y:s,w:d,h:y})))}return l.jsx(G,{className:A.clsx("widget-grid",R),style:q,layout:b,cols:u,rowHeight:o,isDraggable:m??n,isResizable:E??n,draggableHandle:T,draggableCancel:_,onLayoutChange:x,children:(Array.isArray(i)?i:[i]).map(e=>D.isValidElement(e)?l.jsx("div",{className:"widget-grid-item",children:e},e.key):e)})}exports.WidgetGrid=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("../../../vendor/clsx/dist/clsx.cjs"),G=require("react"),c=require("../../../_virtual/index.cjs");;/* empty css */;/* empty css */;/* empty css */const T=c.WidthProvider(c),_=".widget-drag-handle",w=".widget-header-actions";function S({layout:o,onLayoutChange:r,cols:u=12,rowHeight:E=80,isEditable:g=!1,isDraggable:m,isResizable:b,className:R,style:q,children:i}){const D=o.map(({id:e,x:a,y:t,w:s,h:d})=>({i:e,x:a,y:t,w:s,h:d})),n=m??g;function x(e){r==null||r(e.map(({i:a,x:t,y:s,w:d,h:y})=>({id:a,x:t,y:s,w:d,h:y})))}return l.jsx(T,{className:A.clsx("widget-grid",n&&"widget-grid-draggable",R),style:q,layout:D,cols:u,rowHeight:E,isDraggable:n,isResizable:b??g,draggableHandle:_,draggableCancel:w,onLayoutChange:x,children:(Array.isArray(i)?i:[i]).map(e=>G.isValidElement(e)?l.jsx("div",{className:"widget-grid-item",children:e},e.key):e)})}exports.WidgetGrid=S;
2
2
  //# sourceMappingURL=WidgetGrid.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetGrid.cjs","sources":["../../../../../src/ui/components/WidgetGrid/WidgetGrid.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { isValidElement, type CSSProperties, type ReactNode } from \"react\";\nimport GridLayout, { type Layout } from \"react-grid-layout\";\nimport \"react-grid-layout/css/styles.css\";\nimport \"react-resizable/css/styles.css\";\nimport \"./widgetgrid.css\";\n\nconst ResizableGridLayout = /* @__PURE__ */ GridLayout.WidthProvider(GridLayout);\n\nconst WIDGET_DRAG_HANDLE_SELECTOR = \".widget-drag-handle\";\nconst WIDGET_HEADER_ACTIONS_SELECTOR = \".widget-header-actions\";\n\nexport interface WidgetLayoutItem {\n id: string;\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\nexport interface WidgetGridProps {\n layout: WidgetLayoutItem[];\n onLayoutChange?: (layout: WidgetLayoutItem[]) => void;\n cols?: number;\n rowHeight?: number;\n isEditable?: boolean;\n isDraggable?: boolean;\n isResizable?: boolean;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\nexport function WidgetGrid({\n layout,\n onLayoutChange,\n cols = 12,\n rowHeight = 80,\n isEditable = false,\n isDraggable,\n isResizable,\n className,\n style,\n children,\n}: WidgetGridProps) {\n const rglLayout: Layout[] = layout.map(({ id, x, y, w, h }) => ({ i: id, x, y, w, h }));\n\n function handleLayoutChange(nextLayout: Layout[]): void {\n onLayoutChange?.(nextLayout.map(({ i, x, y, w, h }) => ({ id: i, x, y, w, h })));\n }\n\n return (\n <ResizableGridLayout\n className={clsx(\"widget-grid\", className)}\n style={style}\n layout={rglLayout}\n cols={cols}\n rowHeight={rowHeight}\n isDraggable={isDraggable ?? isEditable}\n isResizable={isResizable ?? isEditable}\n draggableHandle={WIDGET_DRAG_HANDLE_SELECTOR}\n draggableCancel={WIDGET_HEADER_ACTIONS_SELECTOR}\n onLayoutChange={handleLayoutChange}\n >\n {(Array.isArray(children) ? children : [children]).map((child) =>\n isValidElement(child) ? (\n // react-grid-layout clones this direct child to attach position styles and,\n // when resizable, appends the resize handle as one of its children. Widget\n // renders its own children inside .widget-body, so cloning Widget directly\n // would bury the handle there instead of at the item's edge. This wrapper\n // keeps Widget's markup untouched and gives react-grid-layout a plain node\n // to clone onto.\n //\n // A plain array .map() is used here (not Children.map/Children.forEach/\n // Children.toArray): those APIs re-escape each child's key on every call,\n // prefixing it with React's internal `.$` marker regardless of the key set\n // on the returned element. react-grid-layout derives each item's id from\n // this wrapper's resolved key, and that id round-trips back into `layout` on\n // the next render, so the escaped key compounded every render (id -> `.$id`\n // -> `.$.$id` -> ...) and never converged, causing an infinite update loop\n // as soon as a consumer re-rendered with the reported layout. Plain .map()\n // leaves the explicit key untouched.\n <div key={child.key} className=\"widget-grid-item\">\n {child}\n </div>\n ) : (\n child\n ),\n )}\n </ResizableGridLayout>\n );\n}\n"],"names":["ResizableGridLayout","GridLayout","WIDGET_DRAG_HANDLE_SELECTOR","WIDGET_HEADER_ACTIONS_SELECTOR","WidgetGrid","layout","onLayoutChange","cols","rowHeight","isEditable","isDraggable","isResizable","className","style","children","rglLayout","id","x","y","w","h","handleLayoutChange","nextLayout","i","jsx","clsx","child","isValidElement"],"mappings":"+XAOA,MAAMA,EAAsCC,EAAW,cAAcA,CAAU,EAEzEC,EAA8B,sBAC9BC,EAAiC,yBAuBhC,SAASC,EAAW,CACzB,OAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,GACP,UAAAC,EAAY,GACZ,WAAAC,EAAa,GACb,YAAAC,EACA,YAAAC,EACA,UAAAC,EACA,MAAAC,EACA,SAAAC,CACF,EAAoB,CAClB,MAAMC,EAAsBV,EAAO,IAAI,CAAC,CAAE,GAAAW,EAAI,EAAAC,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,KAAS,CAAE,EAAGJ,EAAI,EAAAC,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,GAAI,EAEtF,SAASC,EAAmBC,EAA4B,CACtDhB,GAAA,MAAAA,EAAiBgB,EAAW,IAAI,CAAC,CAAE,EAAAC,EAAG,EAAAN,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,KAAS,CAAE,GAAIG,EAAG,EAAAN,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,EAAI,EAChF,CAEA,OACEI,EAAAA,IAACxB,EAAA,CACC,UAAWyB,EAAAA,KAAK,cAAeb,CAAS,EACxC,MAAAC,EACA,OAAQE,EACR,KAAAR,EACA,UAAAC,EACA,YAAaE,GAAeD,EAC5B,YAAaE,GAAeF,EAC5B,gBAAiBP,EACjB,gBAAiBC,EACjB,eAAgBkB,EAEd,gBAAM,QAAQP,CAAQ,EAAIA,EAAW,CAACA,CAAQ,GAAG,IAAKY,GACtDC,EAAAA,eAAeD,CAAK,QAiBjB,MAAA,CAAoB,UAAU,mBAC5B,SAAAA,CAAA,EADOA,EAAM,GAEhB,EAEAA,CAAA,CAEJ,CAAA,CAGN"}
1
+ {"version":3,"file":"WidgetGrid.cjs","sources":["../../../../../src/ui/components/WidgetGrid/WidgetGrid.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { isValidElement, type CSSProperties, type ReactNode } from \"react\";\nimport GridLayout, { type Layout } from \"react-grid-layout\";\nimport \"react-grid-layout/css/styles.css\";\nimport \"react-resizable/css/styles.css\";\nimport \"./widgetgrid.css\";\n\nconst ResizableGridLayout = /* @__PURE__ */ GridLayout.WidthProvider(GridLayout);\n\nconst WIDGET_DRAG_HANDLE_SELECTOR = \".widget-drag-handle\";\nconst WIDGET_HEADER_ACTIONS_SELECTOR = \".widget-header-actions\";\n\nexport interface WidgetLayoutItem {\n id: string;\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\nexport interface WidgetGridProps {\n layout: WidgetLayoutItem[];\n onLayoutChange?: (layout: WidgetLayoutItem[]) => void;\n cols?: number;\n rowHeight?: number;\n isEditable?: boolean;\n isDraggable?: boolean;\n isResizable?: boolean;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\nexport function WidgetGrid({\n layout,\n onLayoutChange,\n cols = 12,\n rowHeight = 80,\n isEditable = false,\n isDraggable,\n isResizable,\n className,\n style,\n children,\n}: WidgetGridProps) {\n const rglLayout: Layout[] = layout.map(({ id, x, y, w, h }) => ({ i: id, x, y, w, h }));\n const isDragEnabled: boolean = isDraggable ?? isEditable;\n\n function handleLayoutChange(nextLayout: Layout[]): void {\n onLayoutChange?.(nextLayout.map(({ i, x, y, w, h }) => ({ id: i, x, y, w, h })));\n }\n\n return (\n <ResizableGridLayout\n className={clsx(\"widget-grid\", isDragEnabled && \"widget-grid-draggable\", className)}\n style={style}\n layout={rglLayout}\n cols={cols}\n rowHeight={rowHeight}\n isDraggable={isDragEnabled}\n isResizable={isResizable ?? isEditable}\n draggableHandle={WIDGET_DRAG_HANDLE_SELECTOR}\n draggableCancel={WIDGET_HEADER_ACTIONS_SELECTOR}\n onLayoutChange={handleLayoutChange}\n >\n {(Array.isArray(children) ? children : [children]).map((child) =>\n isValidElement(child) ? (\n // react-grid-layout clones this direct child to attach position styles and,\n // when resizable, appends the resize handle as one of its children. Widget\n // renders its own children inside .widget-body, so cloning Widget directly\n // would bury the handle there instead of at the item's edge. This wrapper\n // keeps Widget's markup untouched and gives react-grid-layout a plain node\n // to clone onto.\n //\n // A plain array .map() is used here (not Children.map/Children.forEach/\n // Children.toArray): those APIs re-escape each child's key on every call,\n // prefixing it with React's internal `.$` marker regardless of the key set\n // on the returned element. react-grid-layout derives each item's id from\n // this wrapper's resolved key, and that id round-trips back into `layout` on\n // the next render, so the escaped key compounded every render (id -> `.$id`\n // -> `.$.$id` -> ...) and never converged, causing an infinite update loop\n // as soon as a consumer re-rendered with the reported layout. Plain .map()\n // leaves the explicit key untouched.\n <div key={child.key} className=\"widget-grid-item\">\n {child}\n </div>\n ) : (\n child\n ),\n )}\n </ResizableGridLayout>\n );\n}\n"],"names":["ResizableGridLayout","GridLayout","WIDGET_DRAG_HANDLE_SELECTOR","WIDGET_HEADER_ACTIONS_SELECTOR","WidgetGrid","layout","onLayoutChange","cols","rowHeight","isEditable","isDraggable","isResizable","className","style","children","rglLayout","id","x","y","w","h","isDragEnabled","handleLayoutChange","nextLayout","i","jsx","clsx","child","isValidElement"],"mappings":"+XAOA,MAAMA,EAAsCC,EAAW,cAAcA,CAAU,EAEzEC,EAA8B,sBAC9BC,EAAiC,yBAuBhC,SAASC,EAAW,CACzB,OAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,GACP,UAAAC,EAAY,GACZ,WAAAC,EAAa,GACb,YAAAC,EACA,YAAAC,EACA,UAAAC,EACA,MAAAC,EACA,SAAAC,CACF,EAAoB,CAClB,MAAMC,EAAsBV,EAAO,IAAI,CAAC,CAAE,GAAAW,EAAI,EAAAC,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,KAAS,CAAE,EAAGJ,EAAI,EAAAC,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,GAAI,EAChFC,EAAyBX,GAAeD,EAE9C,SAASa,EAAmBC,EAA4B,CACtDjB,GAAA,MAAAA,EAAiBiB,EAAW,IAAI,CAAC,CAAE,EAAAC,EAAG,EAAAP,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,KAAS,CAAE,GAAII,EAAG,EAAAP,EAAG,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAA,EAAI,EAChF,CAEA,OACEK,EAAAA,IAACzB,EAAA,CACC,UAAW0B,EAAAA,KAAK,cAAeL,GAAiB,wBAAyBT,CAAS,EAClF,MAAAC,EACA,OAAQE,EACR,KAAAR,EACA,UAAAC,EACA,YAAaa,EACb,YAAaV,GAAeF,EAC5B,gBAAiBP,EACjB,gBAAiBC,EACjB,eAAgBmB,EAEd,gBAAM,QAAQR,CAAQ,EAAIA,EAAW,CAACA,CAAQ,GAAG,IAAKa,GACtDC,EAAAA,eAAeD,CAAK,QAiBjB,MAAA,CAAoB,UAAU,mBAC5B,SAAAA,CAAA,EADOA,EAAM,GAEhB,EAEAA,CAAA,CAEJ,CAAA,CAGN"}
@@ -1,39 +1,39 @@
1
- import { jsx as s } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
2
  import { clsx as _ } from "../../../vendor/clsx/dist/clsx.js";
3
3
  import { isValidElement as u } from "react";
4
- import g from "../../../_virtual/index.js";
4
+ import l from "../../../_virtual/index.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
7
  /* empty css */
8
- const y = /* @__PURE__ */ g.WidthProvider(g), T = ".widget-drag-handle", b = ".widget-header-actions";
9
- function O({
10
- layout: l,
8
+ const w = /* @__PURE__ */ l.WidthProvider(l), y = ".widget-drag-handle", T = ".widget-header-actions";
9
+ function S({
10
+ layout: n,
11
11
  onLayoutChange: i,
12
12
  cols: p = 12,
13
- rowHeight: n = 80,
14
- isEditable: m = !1,
15
- isDraggable: E,
16
- isResizable: c,
17
- className: f,
18
- style: A,
13
+ rowHeight: E = 80,
14
+ isEditable: s = !1,
15
+ isDraggable: c,
16
+ isResizable: f,
17
+ className: D,
18
+ style: b,
19
19
  children: a
20
20
  }) {
21
- const D = l.map(({ id: r, x: e, y: t, w: o, h: d }) => ({ i: r, x: e, y: t, w: o, h: d }));
21
+ const A = n.map(({ id: r, x: e, y: t, w: d, h: o }) => ({ i: r, x: e, y: t, w: d, h: o })), g = c ?? s;
22
22
  function G(r) {
23
- i == null || i(r.map(({ i: e, x: t, y: o, w: d, h: R }) => ({ id: e, x: t, y: o, w: d, h: R })));
23
+ i == null || i(r.map(({ i: e, x: t, y: d, w: o, h: R }) => ({ id: e, x: t, y: d, w: o, h: R })));
24
24
  }
25
- return /* @__PURE__ */ s(
26
- y,
25
+ return /* @__PURE__ */ m(
26
+ w,
27
27
  {
28
- className: _("widget-grid", f),
29
- style: A,
30
- layout: D,
28
+ className: _("widget-grid", g && "widget-grid-draggable", D),
29
+ style: b,
30
+ layout: A,
31
31
  cols: p,
32
- rowHeight: n,
33
- isDraggable: E ?? m,
34
- isResizable: c ?? m,
35
- draggableHandle: T,
36
- draggableCancel: b,
32
+ rowHeight: E,
33
+ isDraggable: g,
34
+ isResizable: f ?? s,
35
+ draggableHandle: y,
36
+ draggableCancel: T,
37
37
  onLayoutChange: G,
38
38
  children: (Array.isArray(a) ? a : [a]).map(
39
39
  (r) => u(r) ? (
@@ -53,13 +53,13 @@ function O({
53
53
  // -> `.$.$id` -> ...) and never converged, causing an infinite update loop
54
54
  // as soon as a consumer re-rendered with the reported layout. Plain .map()
55
55
  // leaves the explicit key untouched.
56
- /* @__PURE__ */ s("div", { className: "widget-grid-item", children: r }, r.key)
56
+ /* @__PURE__ */ m("div", { className: "widget-grid-item", children: r }, r.key)
57
57
  ) : r
58
58
  )
59
59
  }
60
60
  );
61
61
  }
62
62
  export {
63
- O as WidgetGrid
63
+ S as WidgetGrid
64
64
  };
65
65
  //# sourceMappingURL=WidgetGrid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetGrid.js","sources":["../../../../../src/ui/components/WidgetGrid/WidgetGrid.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { isValidElement, type CSSProperties, type ReactNode } from \"react\";\nimport GridLayout, { type Layout } from \"react-grid-layout\";\nimport \"react-grid-layout/css/styles.css\";\nimport \"react-resizable/css/styles.css\";\nimport \"./widgetgrid.css\";\n\nconst ResizableGridLayout = /* @__PURE__ */ GridLayout.WidthProvider(GridLayout);\n\nconst WIDGET_DRAG_HANDLE_SELECTOR = \".widget-drag-handle\";\nconst WIDGET_HEADER_ACTIONS_SELECTOR = \".widget-header-actions\";\n\nexport interface WidgetLayoutItem {\n id: string;\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\nexport interface WidgetGridProps {\n layout: WidgetLayoutItem[];\n onLayoutChange?: (layout: WidgetLayoutItem[]) => void;\n cols?: number;\n rowHeight?: number;\n isEditable?: boolean;\n isDraggable?: boolean;\n isResizable?: boolean;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\nexport function WidgetGrid({\n layout,\n onLayoutChange,\n cols = 12,\n rowHeight = 80,\n isEditable = false,\n isDraggable,\n isResizable,\n className,\n style,\n children,\n}: WidgetGridProps) {\n const rglLayout: Layout[] = layout.map(({ id, x, y, w, h }) => ({ i: id, x, y, w, h }));\n\n function handleLayoutChange(nextLayout: Layout[]): void {\n onLayoutChange?.(nextLayout.map(({ i, x, y, w, h }) => ({ id: i, x, y, w, h })));\n }\n\n return (\n <ResizableGridLayout\n className={clsx(\"widget-grid\", className)}\n style={style}\n layout={rglLayout}\n cols={cols}\n rowHeight={rowHeight}\n isDraggable={isDraggable ?? isEditable}\n isResizable={isResizable ?? isEditable}\n draggableHandle={WIDGET_DRAG_HANDLE_SELECTOR}\n draggableCancel={WIDGET_HEADER_ACTIONS_SELECTOR}\n onLayoutChange={handleLayoutChange}\n >\n {(Array.isArray(children) ? children : [children]).map((child) =>\n isValidElement(child) ? (\n // react-grid-layout clones this direct child to attach position styles and,\n // when resizable, appends the resize handle as one of its children. Widget\n // renders its own children inside .widget-body, so cloning Widget directly\n // would bury the handle there instead of at the item's edge. This wrapper\n // keeps Widget's markup untouched and gives react-grid-layout a plain node\n // to clone onto.\n //\n // A plain array .map() is used here (not Children.map/Children.forEach/\n // Children.toArray): those APIs re-escape each child's key on every call,\n // prefixing it with React's internal `.$` marker regardless of the key set\n // on the returned element. react-grid-layout derives each item's id from\n // this wrapper's resolved key, and that id round-trips back into `layout` on\n // the next render, so the escaped key compounded every render (id -> `.$id`\n // -> `.$.$id` -> ...) and never converged, causing an infinite update loop\n // as soon as a consumer re-rendered with the reported layout. Plain .map()\n // leaves the explicit key untouched.\n <div key={child.key} className=\"widget-grid-item\">\n {child}\n </div>\n ) : (\n child\n ),\n )}\n </ResizableGridLayout>\n );\n}\n"],"names":["ResizableGridLayout","GridLayout","WIDGET_DRAG_HANDLE_SELECTOR","WIDGET_HEADER_ACTIONS_SELECTOR","WidgetGrid","layout","onLayoutChange","cols","rowHeight","isEditable","isDraggable","isResizable","className","style","children","rglLayout","id","x","y","w","h","handleLayoutChange","nextLayout","i","jsx","clsx","child","isValidElement"],"mappings":";;;;;;;AAOA,MAAMA,IAAsC,gBAAAC,EAAW,cAAcA,CAAU,GAEzEC,IAA8B,uBAC9BC,IAAiC;AAuBhC,SAASC,EAAW;AAAA,EACzB,QAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,WAAAC,IAAY;AAAA,EACZ,YAAAC,IAAa;AAAA,EACb,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AACF,GAAoB;AAClB,QAAMC,IAAsBV,EAAO,IAAI,CAAC,EAAE,IAAAW,GAAI,GAAAC,GAAG,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,OAAS,EAAE,GAAGJ,GAAI,GAAAC,GAAG,GAAAC,GAAG,GAAAC,GAAG,GAAAC,IAAI;AAEtF,WAASC,EAAmBC,GAA4B;AACtD,IAAAhB,KAAA,QAAAA,EAAiBgB,EAAW,IAAI,CAAC,EAAE,GAAAC,GAAG,GAAAN,GAAG,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,OAAS,EAAE,IAAIG,GAAG,GAAAN,GAAG,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,EAAI;AAAA,EAChF;AAEA,SACE,gBAAAI;AAAA,IAACxB;AAAA,IAAA;AAAA,MACC,WAAWyB,EAAK,eAAeb,CAAS;AAAA,MACxC,OAAAC;AAAA,MACA,QAAQE;AAAA,MACR,MAAAR;AAAA,MACA,WAAAC;AAAA,MACA,aAAaE,KAAeD;AAAA,MAC5B,aAAaE,KAAeF;AAAA,MAC5B,iBAAiBP;AAAA,MACjB,iBAAiBC;AAAA,MACjB,gBAAgBkB;AAAA,MAEd,iBAAM,QAAQP,CAAQ,IAAIA,IAAW,CAACA,CAAQ,GAAG;AAAA,QAAI,CAACY,MACtDC,EAAeD,CAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAiBjB,OAAA,EAAoB,WAAU,oBAC5B,UAAAA,EAAA,GADOA,EAAM,GAEhB;AAAA,YAEAA;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"WidgetGrid.js","sources":["../../../../../src/ui/components/WidgetGrid/WidgetGrid.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { isValidElement, type CSSProperties, type ReactNode } from \"react\";\nimport GridLayout, { type Layout } from \"react-grid-layout\";\nimport \"react-grid-layout/css/styles.css\";\nimport \"react-resizable/css/styles.css\";\nimport \"./widgetgrid.css\";\n\nconst ResizableGridLayout = /* @__PURE__ */ GridLayout.WidthProvider(GridLayout);\n\nconst WIDGET_DRAG_HANDLE_SELECTOR = \".widget-drag-handle\";\nconst WIDGET_HEADER_ACTIONS_SELECTOR = \".widget-header-actions\";\n\nexport interface WidgetLayoutItem {\n id: string;\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\nexport interface WidgetGridProps {\n layout: WidgetLayoutItem[];\n onLayoutChange?: (layout: WidgetLayoutItem[]) => void;\n cols?: number;\n rowHeight?: number;\n isEditable?: boolean;\n isDraggable?: boolean;\n isResizable?: boolean;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}\n\nexport function WidgetGrid({\n layout,\n onLayoutChange,\n cols = 12,\n rowHeight = 80,\n isEditable = false,\n isDraggable,\n isResizable,\n className,\n style,\n children,\n}: WidgetGridProps) {\n const rglLayout: Layout[] = layout.map(({ id, x, y, w, h }) => ({ i: id, x, y, w, h }));\n const isDragEnabled: boolean = isDraggable ?? isEditable;\n\n function handleLayoutChange(nextLayout: Layout[]): void {\n onLayoutChange?.(nextLayout.map(({ i, x, y, w, h }) => ({ id: i, x, y, w, h })));\n }\n\n return (\n <ResizableGridLayout\n className={clsx(\"widget-grid\", isDragEnabled && \"widget-grid-draggable\", className)}\n style={style}\n layout={rglLayout}\n cols={cols}\n rowHeight={rowHeight}\n isDraggable={isDragEnabled}\n isResizable={isResizable ?? isEditable}\n draggableHandle={WIDGET_DRAG_HANDLE_SELECTOR}\n draggableCancel={WIDGET_HEADER_ACTIONS_SELECTOR}\n onLayoutChange={handleLayoutChange}\n >\n {(Array.isArray(children) ? children : [children]).map((child) =>\n isValidElement(child) ? (\n // react-grid-layout clones this direct child to attach position styles and,\n // when resizable, appends the resize handle as one of its children. Widget\n // renders its own children inside .widget-body, so cloning Widget directly\n // would bury the handle there instead of at the item's edge. This wrapper\n // keeps Widget's markup untouched and gives react-grid-layout a plain node\n // to clone onto.\n //\n // A plain array .map() is used here (not Children.map/Children.forEach/\n // Children.toArray): those APIs re-escape each child's key on every call,\n // prefixing it with React's internal `.$` marker regardless of the key set\n // on the returned element. react-grid-layout derives each item's id from\n // this wrapper's resolved key, and that id round-trips back into `layout` on\n // the next render, so the escaped key compounded every render (id -> `.$id`\n // -> `.$.$id` -> ...) and never converged, causing an infinite update loop\n // as soon as a consumer re-rendered with the reported layout. Plain .map()\n // leaves the explicit key untouched.\n <div key={child.key} className=\"widget-grid-item\">\n {child}\n </div>\n ) : (\n child\n ),\n )}\n </ResizableGridLayout>\n );\n}\n"],"names":["ResizableGridLayout","GridLayout","WIDGET_DRAG_HANDLE_SELECTOR","WIDGET_HEADER_ACTIONS_SELECTOR","WidgetGrid","layout","onLayoutChange","cols","rowHeight","isEditable","isDraggable","isResizable","className","style","children","rglLayout","id","x","y","w","h","isDragEnabled","handleLay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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAiBjB,OAAA,EAAoB,WAAU,oBAC5B,UAAAA,EAAA,GADOA,EAAM,GAEhB;AAAA,YAEAA;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),T=require("../../../../vendor/clsx/dist/clsx.cjs"),b=require("react"),p=require("../useChartInstance.cjs"),I=require("./bar-chart-option.cjs");;/* empty css */const j={};function m({categories:n,series:r,orientation:c="vertical",stacking:s="off",valueLabel:i="auto",legend:a="inline",valueAxis:u=j,valueFormatter:f,className:O,...d}){const{containerRef:q,chart:e,theme:t,resolveSeriesColor:l}=p.useChartInstance();return b.useEffect(()=>{if(!e||!t)return;const h={};for(const o of r){if(!o.colorToken)continue;const C=l(o.colorToken);C&&(h[o.id]=C)}e.setOption(I.buildBarChartOption({categories:n,series:r,orientation:c,stacking:s,valueLabel:i,legend:a,valueAxis:u,theme:t,seriesColorOverrides:h,valueFormatter:f}),{notMerge:!0})},[e,t,l,n,r,c,s,i,a,u,f]),S.jsx("div",{ref:q,className:T.clsx("bar-chart",O),...d})}exports.BarChart=m;
2
+ //# sourceMappingURL=BarChart.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BarChart.cjs","sources":["../../../../../../src/ui/components/charts/BarChart/BarChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport {\n buildBarChartOption,\n type BarChartLegendMode,\n type BarChartOrientation,\n type BarChartSeriesData,\n type BarChartStacking,\n type BarChartValueAxisOptions,\n type BarChartValueLabel,\n} from \"./bar-chart-option\";\nimport \"./bar-chart.css\";\n\nexport type {\n BarChartAxisScale,\n BarChartLegendMode,\n BarChartOrientation,\n BarChartPoint,\n BarChartSeriesData,\n BarChartStacking,\n BarChartValueAxisOptions,\n BarChartValueLabel,\n} from \"./bar-chart-option\";\n\nexport type BarChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n categories: string[];\n series: BarChartSeriesData[];\n orientation?: BarChartOrientation;\n stacking?: BarChartStacking;\n valueLabel?: BarChartValueLabel;\n legend?: BarChartLegendMode;\n valueAxis?: BarChartValueAxisOptions;\n valueFormatter?: (value: number) => string;\n};\n\nconst EMPTY_VALUE_AXIS_OPTIONS: BarChartValueAxisOptions = {};\n\nexport function BarChart({\n categories,\n series,\n orientation = \"vertical\",\n stacking = \"off\",\n valueLabel = \"auto\",\n legend = \"inline\",\n valueAxis = EMPTY_VALUE_AXIS_OPTIONS,\n valueFormatter,\n className,\n ...props\n}: BarChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n const seriesColorOverrides: Record<string, string> = {};\n for (const data of series) {\n if (!data.colorToken) continue;\n const color: string | undefined = resolveSeriesColor(data.colorToken);\n if (color) seriesColorOverrides[data.id] = color;\n }\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildBarChartOption({\n categories,\n series,\n orientation,\n stacking,\n valueLabel,\n legend,\n valueAxis,\n theme,\n seriesColorOverrides,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n resolveSeriesColor,\n categories,\n series,\n orientation,\n stacking,\n valueLabel,\n legend,\n valueAxis,\n valueFormatter,\n ]);\n\n return <div ref={containerRef} className={clsx(\"bar-chart\", className)} {...props} />;\n}\n"],"names":["EMPTY_VALUE_AXIS_OPTIONS","BarChart","categories","series","orientation","stacking","valueLabel","legend","valueAxis","valueFormatter","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","useEffect","seriesColorOverrides","data","color","buildBarChartOption","jsx","clsx"],"mappings":"mSAoCA,MAAMA,EAAqD,CAAA,EAEpD,SAASC,EAAS,CACvB,WAAAC,EACA,OAAAC,EACA,YAAAC,EAAc,WACd,SAAAC,EAAW,MACX,WAAAC,EAAa,OACb,OAAAC,EAAS,SACT,UAAAC,EAAYR,EACZ,eAAAS,EACA,UAAAC,EACA,GAAGC,CACL,EAAkB,CAChB,KAAM,CAAE,aAAAC,EAAc,MAAAC,EAAO,MAAAC,EAAO,mBAAAC,CAAA,EAAsCC,EAAAA,iBAAA,EAE1EC,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAI,CAACJ,GAAS,CAACC,EAAO,OAEtB,MAAMI,EAA+C,CAAA,EACrD,UAAWC,KAAQhB,EAAQ,CACzB,GAAI,CAACgB,EAAK,WAAY,SACtB,MAAMC,EAA4BL,EAAmBI,EAAK,UAAU,EAChEC,IAAOF,EAAqBC,EAAK,EAAE,EAAIC,EAC7C,CAIAP,EAAM,UACJQ,sBAAoB,CAClB,WAAAnB,EACA,OAAAC,EACA,YAAAC,EACA,SAAAC,EACA,WAAAC,EACA,OAAAC,EACA,UAAAC,EACA,MAAAM,EACA,qBAAAI,EACA,eAAAT,CAAA,CACD,EACD,CAAE,SAAU,EAAA,CAAK,CAErB,EAAG,CACDI,EACAC,EACAC,EACAb,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CAAA,CACD,EAEMa,MAAC,MAAA,CAAI,IAAKV,EAAc,UAAWW,EAAAA,KAAK,YAAab,CAAS,EAAI,GAAGC,CAAA,CAAO,CACrF"}
@@ -0,0 +1,61 @@
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { clsx as T } from "../../../../vendor/clsx/dist/clsx.js";
3
+ import { useEffect as E } from "react";
4
+ import { useChartInstance as I } from "../useChartInstance.js";
5
+ import { buildBarChartOption as S } from "./bar-chart-option.js";
6
+ /* empty css */
7
+ const _ = {};
8
+ function j({
9
+ categories: f,
10
+ series: o,
11
+ orientation: c = "vertical",
12
+ stacking: e = "off",
13
+ valueLabel: i = "auto",
14
+ legend: m = "inline",
15
+ valueAxis: s = _,
16
+ valueFormatter: p,
17
+ className: u,
18
+ ...C
19
+ }) {
20
+ const { containerRef: O, chart: r, theme: t, resolveSeriesColor: a } = I();
21
+ return E(() => {
22
+ if (!r || !t) return;
23
+ const h = {};
24
+ for (const n of o) {
25
+ if (!n.colorToken) continue;
26
+ const l = a(n.colorToken);
27
+ l && (h[n.id] = l);
28
+ }
29
+ r.setOption(
30
+ S({
31
+ categories: f,
32
+ series: o,
33
+ orientation: c,
34
+ stacking: e,
35
+ valueLabel: i,
36
+ legend: m,
37
+ valueAxis: s,
38
+ theme: t,
39
+ seriesColorOverrides: h,
40
+ valueFormatter: p
41
+ }),
42
+ { notMerge: !0 }
43
+ );
44
+ }, [
45
+ r,
46
+ t,
47
+ a,
48
+ f,
49
+ o,
50
+ c,
51
+ e,
52
+ i,
53
+ m,
54
+ s,
55
+ p
56
+ ]), /* @__PURE__ */ d("div", { ref: O, className: T("bar-chart", u), ...C });
57
+ }
58
+ export {
59
+ j as BarChart
60
+ };
61
+ //# sourceMappingURL=BarChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BarChart.js","sources":["../../../../../../src/ui/components/charts/BarChart/BarChart.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type ComponentPropsWithoutRef, useEffect } from \"react\";\nimport { useChartInstance, type ChartInstance } from \"../useChartInstance\";\nimport {\n buildBarChartOption,\n type BarChartLegendMode,\n type BarChartOrientation,\n type BarChartSeriesData,\n type BarChartStacking,\n type BarChartValueAxisOptions,\n type BarChartValueLabel,\n} from \"./bar-chart-option\";\nimport \"./bar-chart.css\";\n\nexport type {\n BarChartAxisScale,\n BarChartLegendMode,\n BarChartOrientation,\n BarChartPoint,\n BarChartSeriesData,\n BarChartStacking,\n BarChartValueAxisOptions,\n BarChartValueLabel,\n} from \"./bar-chart-option\";\n\nexport type BarChartProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n categories: string[];\n series: BarChartSeriesData[];\n orientation?: BarChartOrientation;\n stacking?: BarChartStacking;\n valueLabel?: BarChartValueLabel;\n legend?: BarChartLegendMode;\n valueAxis?: BarChartValueAxisOptions;\n valueFormatter?: (value: number) => string;\n};\n\nconst EMPTY_VALUE_AXIS_OPTIONS: BarChartValueAxisOptions = {};\n\nexport function BarChart({\n categories,\n series,\n orientation = \"vertical\",\n stacking = \"off\",\n valueLabel = \"auto\",\n legend = \"inline\",\n valueAxis = EMPTY_VALUE_AXIS_OPTIONS,\n valueFormatter,\n className,\n ...props\n}: BarChartProps) {\n const { containerRef, chart, theme, resolveSeriesColor }: ChartInstance = useChartInstance();\n\n useEffect(() => {\n if (!chart || !theme) return;\n\n const seriesColorOverrides: Record<string, string> = {};\n for (const data of series) {\n if (!data.colorToken) continue;\n const color: string | undefined = resolveSeriesColor(data.colorToken);\n if (color) seriesColorOverrides[data.id] = color;\n }\n\n // `notMerge` evita que uma série removida da configuração continue desenhada: o ECharts\n // casa séries por id e mantém as que não aparecem na opção nova.\n chart.setOption(\n buildBarChartOption({\n categories,\n series,\n orientation,\n stacking,\n valueLabel,\n legend,\n valueAxis,\n theme,\n seriesColorOverrides,\n valueFormatter,\n }),\n { notMerge: true },\n );\n }, [\n chart,\n theme,\n resolveSeriesColor,\n categories,\n series,\n orientation,\n stacking,\n valueLabel,\n legend,\n valueAxis,\n valueFormatter,\n ]);\n\n return <div ref={containerRef} className={clsx(\"bar-chart\", className)} {...props} />;\n}\n"],"names":["EMPTY_VALUE_AXIS_OPTIONS","BarChart","categories","series","orientation","stacking","valueLabel","legend","valueAxis","valueFormatter","className","props","containerRef","chart","theme","resolveSeriesColor","useChartInstance","useEffect","seriesColorOverrides","data","color","buildBarChartOption","jsx","clsx"],"mappings":";;;;;;AAoCA,MAAMA,IAAqD,CAAA;AAEpD,SAASC,EAAS;AAAA,EACvB,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AAAA,EACX,YAAAC,IAAa;AAAA,EACb,QAAAC,IAAS;AAAA,EACT,WAAAC,IAAYR;AAAA,EACZ,gBAAAS;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GAAkB;AAChB,QAAM,EAAE,cAAAC,GAAc,OAAAC,GAAO,OAAAC,GAAO,oBAAAC,EAAA,IAAsCC,EAAA;AAE1E,SAAAC,EAAU,MAAM;AACd,QAAI,CAACJ,KAAS,CAACC,EAAO;AAEtB,UAAMI,IAA+C,CAAA;AACrD,eAAWC,KAAQhB,GAAQ;AACzB,UAAI,CAACgB,EAAK,WAAY;AACtB,YAAMC,IAA4BL,EAAmBI,EAAK,UAAU;AACpE,MAAIC,MAAOF,EAAqBC,EAAK,EAAE,IAAIC;AAAA,IAC7C;AAIA,IAAAP,EAAM;AAAA,MACJQ,EAAoB;AAAA,QAClB,YAAAnB;AAAA,QACA,QAAAC;AAAA,QACA,aAAAC;AAAA,QACA,UAAAC;AAAA,QACA,YAAAC;AAAA,QACA,QAAAC;AAAA,QACA,WAAAC;AAAA,QACA,OAAAM;AAAA,QACA,sBAAAI;AAAA,QACA,gBAAAT;AAAA,MAAA,CACD;AAAA,MACD,EAAE,UAAU,GAAA;AAAA,IAAK;AAAA,EAErB,GAAG;AAAA,IACDI;AAAA,IACAC;AAAA,IACAC;AAAA,IACAb;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD,GAEM,gBAAAa,EAAC,OAAA,EAAI,KAAKV,GAAc,WAAWW,EAAK,aAAab,CAAS,GAAI,GAAGC,EAAA,CAAO;AACrF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=32,s={top:16,right:16,bottom:16,left:16},T={vertical:140,horizontal:200},E=48,I="total",c=100,C="#ffffff",N="#1e1e1e",O=.0144,w=1;function F(e){const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}function S(e){const t=e.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(t){const n=t[1],r=n.length===3?n.split("").map(a=>a+a).join(""):n;return[0,2,4].map(a=>parseInt(r.slice(a,a+2),16))}const o=e.trim().match(/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i);if(o)return[Number(o[1]),Number(o[2]),Number(o[3])]}function B(e){const t=S(e);if(!t)return;const[o,n,r]=t.map(F);return .2126*o+.7152*n+.0722*r}function p(e,t){return(e+.05)/(t+.05)}function k(e){const t=B(e);if(t===void 0)return C;const o=p(w,t);return p(t,O)>=o?N:C}const D=new Intl.NumberFormat(void 0,{style:"percent",maximumFractionDigits:1});function H(e){return D.format(e/c)}function M(e){return e.stacking==="percent"?H:e.valueFormatter}function u(e){const t=M(e);if(t)return o=>o===null?"":t(o)}function P(e,t){const o=new Map(e.points.map(n=>[n.category,n.value]));return t.map(n=>o.get(n)??null)}function R(e,t){const o=Array.from({length:t},(n,r)=>e.reduce((a,l)=>a+(l[r]??0),0));return e.map(n=>n.map((r,a)=>{const l=o[a];return r===null||l===0?null:r/l*c}))}function y(e){return e.stacking!=="off"?"inside":e.orientation==="horizontal"?"right":"top"}function V(e){return e.labelRect.width<=e.rect.width&&e.labelRect.height<=e.rect.height}function z(e){const t=e.valueLabel==="auto";return!t||y(e)!=="inside"?{hideOverlap:t}:o=>({hideOverlap:t,fontSize:V(o)?void 0:0})}function G(e,t){const o=y(e),n=u(e);return{show:e.valueLabel!=="never",position:o,color:o==="inside"?k(t):e.theme.labelColor,formatter:n?r=>n(r.value):void 0}}function W(e){const{categories:t,theme:o,orientation:n}=e;return{type:"category",data:t,inverse:n==="horizontal",axisLine:{lineStyle:{color:o.axisLineColor}},axisTick:{show:!1},axisLabel:{color:o.labelColor,hideOverlap:!0,width:T[n],overflow:"truncate"},splitLine:{show:!1}}}function X(e){const{valueAxis:t,stacking:o,theme:n}=e,r=o==="percent",a=u(e);return{type:t.scale==="log"?"log":"value",scale:!r&&t.includeZero===!1,min:r?0:t.min,max:r?c:t.max,axisLine:{show:!1},axisLabel:{color:n.labelColor,formatter:a},splitLine:{lineStyle:{color:n.splitLineColor}}}}function U(e){const{categories:t,series:o,orientation:n,stacking:r,legend:a,theme:l}=e,f=a!=="none"&&o.length>0,m=n==="horizontal",x=u(e),d=o.map(i=>P(i,t)),v=r==="percent"?R(d,t.length):d,_=z(e),g=W(e),h=X(e);return{animation:!1,color:l.seriesColors,textStyle:{fontFamily:l.fontFamily,color:l.labelColor},grid:{...s,top:f?s.top+A:s.top,containLabel:!0},legend:f?{type:"scroll",top:0,left:0,icon:"roundRect",itemHeight:8,itemWidth:12,textStyle:{color:l.labelColor}}:{show:!1},tooltip:{trigger:"axis",axisPointer:{type:"shadow"},backgroundColor:l.tooltipBackgroundColor,borderColor:l.tooltipBorderColor,textStyle:{color:l.labelColor},valueFormatter:x},xAxis:m?h:g,yAxis:m?g:h,series:o.map((i,L)=>{const b=e.seriesColorOverrides[i.id]??l.seriesColors[L%l.seriesColors.length];return{id:i.id,name:i.name,type:"bar",stack:r==="off"?void 0:I,barMaxWidth:E,data:v[L],itemStyle:{color:b},label:G(e,b),labelLayout:_}})}}exports.buildBarChartOption=U;
2
+ //# sourceMappingURL=bar-chart-option.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bar-chart-option.cjs","sources":["../../../../../../src/ui/components/charts/BarChart/bar-chart-option.ts"],"sourcesContent":["import type { ChartTheme } from \"../chart-theme\";\n\nexport interface BarChartPoint {\n category: string;\n value: number | null;\n}\n\nexport interface BarChartSeriesData {\n id: string;\n name: string;\n points: BarChartPoint[];\n // Nome de token, nunca hex: é o que mantém a cor válida nos dois temas. Sem ele a série\n // recebe a próxima cor da paleta.\n colorToken?: string;\n}\n\nexport type BarChartOrientation = \"vertical\" | \"horizontal\";\n\nexport type BarChartStacking = \"off\" | \"stacked\" | \"percent\";\n\nexport type BarChartValueLabel = \"auto\" | \"always\" | \"never\";\n\nexport type BarChartLegendMode = \"inline\" | \"none\";\n\nexport type BarChartAxisScale = \"linear\" | \"log\";\n\nexport interface BarChartValueAxisOptions {\n scale?: BarChartAxisScale;\n min?: number;\n max?: number;\n includeZero?: boolean;\n}\n\nexport interface BarChartOptionInput {\n categories: string[];\n series: BarChartSeriesData[];\n orientation: BarChartOrientation;\n stacking: BarChartStacking;\n valueLabel: BarChartValueLabel;\n legend: BarChartLegendMode;\n valueAxis: BarChartValueAxisOptions;\n theme: ChartTheme;\n seriesColorOverrides: Record<string, string>;\n valueFormatter?: (value: number) => string;\n}\n\nconst LEGEND_HEIGHT_PX: number = 32;\n\nconst GRID_WITHOUT_LEGEND = { top: 16, right: 16, bottom: 16, left: 16 } as const;\n\n// Na horizontal o rótulo da categoria disputa largura com a própria barra; na vertical ele fica\n// sob a barra e uma faixa mais estreita já dá conta.\nconst CATEGORY_LABEL_MAX_WIDTH_PX: Record<BarChartOrientation, number> = {\n vertical: 140,\n horizontal: 200,\n};\n\nconst BAR_MAX_WIDTH_PX: number = 48;\n\nconst STACK_ID: string = \"total\";\n\nconst PERCENT_SCALE: number = 100;\n\n// O rótulo dentro da barra é lido contra a cor da série, não contra o fundo da página: a paleta\n// de séries é a mesma nos dois temas, então quem decide entre texto claro e escuro é o\n// preenchimento. O branco que o ECharts usa por padrão reprova no contraste em toda a paleta —\n// 2,24:1 sobre a `yellow-500`.\nconst LABEL_ON_DARK_FILL: string = \"#ffffff\";\n\nconst LABEL_ON_LIGHT_FILL: string = \"#1e1e1e\";\n\nconst LABEL_ON_LIGHT_FILL_LUMINANCE: number = 0.0144;\n\nconst WHITE_LUMINANCE: number = 1;\n\nfunction channelLuminance(channel: number): number {\n const normalized: number = channel / 255;\n return normalized <= 0.03928\n ? normalized / 12.92\n : Math.pow((normalized + 0.055) / 1.055, 2.4);\n}\n\nfunction parseColorChannels(color: string): [number, number, number] | undefined {\n const hexMatch: RegExpMatchArray | null = color\n .trim()\n .match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);\n if (hexMatch) {\n const digits: string = hexMatch[1];\n const expanded: string =\n digits.length === 3\n ? digits\n .split(\"\")\n .map((digit: string) => digit + digit)\n .join(\"\")\n : digits;\n return [0, 2, 4].map((start: number) => parseInt(expanded.slice(start, start + 2), 16)) as [\n number,\n number,\n number,\n ];\n }\n\n const rgbMatch: RegExpMatchArray | null = color\n .trim()\n .match(/^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i);\n if (rgbMatch) {\n return [Number(rgbMatch[1]), Number(rgbMatch[2]), Number(rgbMatch[3])];\n }\n\n return undefined;\n}\n\nfunction relativeLuminance(color: string): number | undefined {\n const channels: [number, number, number] | undefined = parseColorChannels(color);\n if (!channels) return undefined;\n const [red, green, blue] = channels.map(channelLuminance);\n return 0.2126 * red + 0.7152 * green + 0.0722 * blue;\n}\n\nfunction contrastRatio(lighter: number, darker: number): number {\n return (lighter + 0.05) / (darker + 0.05);\n}\n\nfunction labelColorOnFill(fillColor: string): string {\n const luminance: number | undefined = relativeLuminance(fillColor);\n if (luminance === undefined) return LABEL_ON_DARK_FILL;\n const againstLightText: number = contrastRatio(WHITE_LUMINANCE, luminance);\n const againstDarkText: number = contrastRatio(luminance, LABEL_ON_LIGHT_FILL_LUMINANCE);\n return againstDarkText >= againstLightText ? LABEL_ON_LIGHT_FILL : LABEL_ON_DARK_FILL;\n}\n\nconst PERCENT_LABEL: Intl.NumberFormat = new Intl.NumberFormat(undefined, {\n style: \"percent\",\n maximumFractionDigits: 1,\n});\n\nfunction formatPercent(value: number): string {\n return PERCENT_LABEL.format(value / PERCENT_SCALE);\n}\n\n// Em `percent` o valor desenhado é a participação na categoria, e não mais o dado do consumidor:\n// aplicar ali o formatador dele escreveria \"31 ms\" numa barra que vale 31%.\nfunction resolveValueFormatter(input: BarChartOptionInput): ((value: number) => string) | undefined {\n return input.stacking === \"percent\" ? formatPercent : input.valueFormatter;\n}\n\n// Categoria sem valor chega ao formatter como `null` — o ECharts formata o vazio junto com o\n// resto. O tipo público promete `number` ao consumidor, e é esta guarda que mantém a promessa.\nfunction nullSafeValueFormatter(\n input: BarChartOptionInput,\n): ((value: number | null) => string) | undefined {\n const formatValue: ((value: number) => string) | undefined = resolveValueFormatter(input);\n if (!formatValue) return undefined;\n return (value: number | null) => (value === null ? \"\" : formatValue(value));\n}\n\nfunction alignValuesToCategories(\n data: BarChartSeriesData,\n categories: string[],\n): Array<number | null> {\n const valueByCategory: Map<string, number | null> = new Map(\n data.points.map((point: BarChartPoint) => [point.category, point.value]),\n );\n return categories.map((category: string) => valueByCategory.get(category) ?? null);\n}\n\nfunction toShareOfCategoryTotal(\n valuesBySeries: Array<Array<number | null>>,\n categoryCount: number,\n): Array<Array<number | null>> {\n const categoryTotals: number[] = Array.from(\n { length: categoryCount },\n (_unused, categoryIndex: number) =>\n valuesBySeries.reduce(\n (total: number, values: Array<number | null>) => total + (values[categoryIndex] ?? 0),\n 0,\n ),\n );\n return valuesBySeries.map((values: Array<number | null>) =>\n values.map((value: number | null, categoryIndex: number) => {\n const categoryTotal: number = categoryTotals[categoryIndex];\n if (value === null || categoryTotal === 0) return null;\n return (value / categoryTotal) * PERCENT_SCALE;\n }),\n );\n}\n\nfunction labelPosition(input: BarChartOptionInput): string {\n if (input.stacking !== \"off\") return \"inside\";\n return input.orientation === \"horizontal\" ? \"right\" : \"top\";\n}\n\ninterface LabelLayoutParams {\n rect: { width: number; height: number };\n labelRect: { width: number; height: number };\n}\n\ninterface LabelLayout {\n hideOverlap: boolean;\n fontSize?: number;\n}\n\ntype SeriesLabelLayout = LabelLayout | ((params: LabelLayoutParams) => LabelLayout);\n\nfunction fitsInsideBar(params: LabelLayoutParams): boolean {\n return (\n params.labelRect.width <= params.rect.width && params.labelRect.height <= params.rect.height\n );\n}\n\n// `hideOverlap` resolve rótulo que encosta em rótulo, mas não rótulo maior que a própria fatia:\n// numa barra empilhada o ECharts desenha o número por cima das fatias vizinhas. `fontSize: 0` é\n// o que o `labelLayout` oferece para sumir com um rótulo caso a caso.\nfunction seriesLabelLayout(input: BarChartOptionInput): SeriesLabelLayout {\n const hideOverlap: boolean = input.valueLabel === \"auto\";\n if (!hideOverlap || labelPosition(input) !== \"inside\") return { hideOverlap };\n return (params: LabelLayoutParams) => ({\n hideOverlap,\n fontSize: fitsInsideBar(params) ? undefined : 0,\n });\n}\n\nfunction seriesLabel(input: BarChartOptionInput, fillColor: string): Record<string, unknown> {\n const position: string = labelPosition(input);\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n show: input.valueLabel !== \"never\",\n position,\n color: position === \"inside\" ? labelColorOnFill(fillColor) : input.theme.labelColor,\n formatter: formatValue\n ? (params: { value: number | null }) => formatValue(params.value)\n : undefined,\n };\n}\n\nfunction categoryAxis(input: BarChartOptionInput): Record<string, unknown> {\n const { categories, theme, orientation } = input;\n return {\n type: \"category\",\n data: categories,\n // Na horizontal o ECharts empilha a categoria de baixo para cima, invertendo a ordem que o\n // app escolheu ao ordenar as barras.\n inverse: orientation === \"horizontal\",\n axisLine: { lineStyle: { color: theme.axisLineColor } },\n axisTick: { show: false },\n axisLabel: {\n color: theme.labelColor,\n hideOverlap: true,\n width: CATEGORY_LABEL_MAX_WIDTH_PX[orientation],\n overflow: \"truncate\",\n },\n splitLine: { show: false },\n };\n}\n\nfunction valueAxis(input: BarChartOptionInput): Record<string, unknown> {\n const { valueAxis: options, stacking, theme } = input;\n const isPercent: boolean = stacking === \"percent\";\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n return {\n type: options.scale === \"log\" ? \"log\" : \"value\",\n // Barra mede por comprimento: eixo cortado mente sobre a proporção entre as barras, então\n // aqui o zero entra por padrão — ao contrário da série temporal, que só mostra variação.\n scale: !isPercent && options.includeZero === false,\n min: isPercent ? 0 : options.min,\n max: isPercent ? PERCENT_SCALE : options.max,\n axisLine: { show: false },\n axisLabel: { color: theme.labelColor, formatter: formatValue },\n splitLine: { lineStyle: { color: theme.splitLineColor } },\n };\n}\n\n// O retorno é `Record<string, unknown>` de propósito, e não `EChartsOption`: é o que impede\n// um tipo da biblioteca de vazar para o resto do design system.\nexport function buildBarChartOption(input: BarChartOptionInput): Record<string, unknown> {\n const { categories, series, orientation, stacking, legend, theme } = input;\n const isLegendVisible: boolean = legend !== \"none\" && series.length > 0;\n const isHorizontal: boolean = orientation === \"horizontal\";\n const formatValue: ((value: number | null) => string) | undefined = nullSafeValueFormatter(input);\n\n const alignedValues: Array<Array<number | null>> = series.map((data: BarChartSeriesData) =>\n alignValuesToCategories(data, categories),\n );\n // O ECharts não tem empilhamento 100%: a participação precisa chegar calculada no dado.\n const plottedValues: Array<Array<number | null>> =\n stacking === \"percent\"\n ? toShareOfCategoryTotal(alignedValues, categories.length)\n : alignedValues;\n\n const labelLayout: SeriesLabelLayout = seriesLabelLayout(input);\n const categoryAxisOption: Record<string, unknown> = categoryAxis(input);\n const valueAxisOption: Record<string, unknown> = valueAxis(input);\n\n return {\n animation: false,\n color: theme.seriesColors,\n textStyle: { fontFamily: theme.fontFamily, color: theme.labelColor },\n grid: {\n ...GRID_WITHOUT_LEGEND,\n top: isLegendVisible ? GRID_WITHOUT_LEGEND.top + LEGEND_HEIGHT_PX : GRID_WITHOUT_LEGEND.top,\n containLabel: true,\n },\n legend: isLegendVisible\n ? {\n type: \"scroll\",\n top: 0,\n left: 0,\n icon: \"roundRect\",\n itemHeight: 8,\n itemWidth: 12,\n textStyle: { color: theme.labelColor },\n }\n : { show: false },\n tooltip: {\n trigger: \"axis\",\n axisPointer: { type: \"shadow\" },\n backgroundColor: theme.tooltipBackgroundColor,\n borderColor: theme.tooltipBorderColor,\n textStyle: { color: theme.labelColor },\n valueFormatter: formatValue,\n },\n xAxis: isHorizontal ? valueAxisOption : categoryAxisOption,\n yAxis: isHorizontal ? categoryAxisOption : valueAxisOption,\n series: series.map((data: BarChartSeriesData, index: number) => {\n const fillColor: string =\n input.seriesColorOverrides[data.id] ??\n theme.seriesColors[index % theme.seriesColors.length];\n return {\n id: data.id,\n name: data.name,\n type: \"bar\",\n stack: stacking === \"off\" ? undefined : STACK_ID,\n barMaxWidth: BAR_MAX_WIDTH_PX,\n data: plottedValues[index],\n itemStyle: { color: fillColor },\n label: seriesLabel(input, fillColor),\n labelLayout,\n };\n }),\n };\n}\n"],"names":["LEGEND_HEIGHT_PX","GRID_WITHOUT_LEGEND","CATEGORY_LABEL_MAX_WIDTH_PX","BAR_MAX_WIDTH_PX","STACK_ID","PERCENT_SCALE","LABEL_ON_DARK_FILL","LABEL_ON_LIGHT_FILL","LABEL_ON_LIGHT_FILL_LUMINANCE","WHITE_LUMINANCE","channelLuminance","channel","normalized","parseColorChannels","color","hexMatch","digits","expanded","digit","start","rgbMatch","relativeLuminance","channels","red","green","blue","contrastRatio","lighter","darker","labelColorOnFill","fillColor","luminance","againstLightText","PERCENT_LABEL","formatPercent","value","resolveValueFormatter","input","nullSafeValueFormatter","formatValue","alignValuesToCategories","data","categories","valueByCategory","point","category","toShareOfCategoryTotal","valuesBySeries","categoryCount","categoryTotals","_unused","categoryIndex","total","values","categoryTotal","labelPosition","fitsInsideBar","params","seriesLabelLayout","hideOverlap","seriesLabel","position","categoryAxis","theme","orientation","valueAxis","options","stacking","isPercent","buildBarChartOption","series","legend","isLegendVisible","isHorizontal","alignedValues","plottedValues","labelLayout","categoryAxisOption","valueAxisOption","index"],"mappings":"gFA8CA,MAAMA,EAA2B,GAE3BC,EAAsB,CAAE,IAAK,GAAI,MAAO,GAAI,OAAQ,GAAI,KAAM,EAAA,EAI9DC,EAAmE,CACvE,SAAU,IACV,WAAY,GACd,EAEMC,EAA2B,GAE3BC,EAAmB,QAEnBC,EAAwB,IAMxBC,EAA6B,UAE7BC,EAA8B,UAE9BC,EAAwC,MAExCC,EAA0B,EAEhC,SAASC,EAAiBC,EAAyB,CACjD,MAAMC,EAAqBD,EAAU,IACrC,OAAOC,GAAc,OACjBA,EAAa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MAAOjD,CAAA,EACpB,MAAO8B,EAAYvB,EAAOP,CAAS,EACnC,YAAA8C,CAAA,CAEJ,CAAC,CAAA,CAEL"}
@@ -0,0 +1,176 @@
1
+ const s = { top: 16, right: 16, bottom: 16, left: 16 }, A = {
2
+ vertical: 140,
3
+ horizontal: 200
4
+ }, E = 48, T = "total", c = 100, C = "#ffffff", I = "#1e1e1e", N = 0.0144, w = 1;
5
+ function O(e) {
6
+ const t = e / 255;
7
+ return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
8
+ }
9
+ function F(e) {
10
+ const t = e.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
11
+ if (t) {
12
+ const n = t[1], r = n.length === 3 ? n.split("").map((a) => a + a).join("") : n;
13
+ return [0, 2, 4].map((a) => parseInt(r.slice(a, a + 2), 16));
14
+ }
15
+ const o = e.trim().match(/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i);
16
+ if (o)
17
+ return [Number(o[1]), Number(o[2]), Number(o[3])];
18
+ }
19
+ function H(e) {
20
+ const t = F(e);
21
+ if (!t) return;
22
+ const [o, n, r] = t.map(O);
23
+ return 0.2126 * o + 0.7152 * n + 0.0722 * r;
24
+ }
25
+ function p(e, t) {
26
+ return (e + 0.05) / (t + 0.05);
27
+ }
28
+ function D(e) {
29
+ const t = H(e);
30
+ if (t === void 0) return C;
31
+ const o = p(w, t);
32
+ return p(t, N) >= o ? I : C;
33
+ }
34
+ const k = new Intl.NumberFormat(void 0, {
35
+ style: "percent",
36
+ maximumFractionDigits: 1
37
+ });
38
+ function B(e) {
39
+ return k.format(e / c);
40
+ }
41
+ function P(e) {
42
+ return e.stacking === "percent" ? B : e.valueFormatter;
43
+ }
44
+ function u(e) {
45
+ const t = P(e);
46
+ if (t)
47
+ return (o) => o === null ? "" : t(o);
48
+ }
49
+ function R(e, t) {
50
+ const o = new Map(
51
+ e.points.map((n) => [n.category, n.value])
52
+ );
53
+ return t.map((n) => o.get(n) ?? null);
54
+ }
55
+ function S(e, t) {
56
+ const o = Array.from(
57
+ { length: t },
58
+ (n, r) => e.reduce(
59
+ (a, l) => a + (l[r] ?? 0),
60
+ 0
61
+ )
62
+ );
63
+ return e.map(
64
+ (n) => n.map((r, a) => {
65
+ const l = o[a];
66
+ return r === null || l === 0 ? null : r / l * c;
67
+ })
68
+ );
69
+ }
70
+ function x(e) {
71
+ return e.stacking !== "off" ? "inside" : e.orientation === "horizontal" ? "right" : "top";
72
+ }
73
+ function V(e) {
74
+ return e.labelRect.width <= e.rect.width && e.labelRect.height <= e.rect.height;
75
+ }
76
+ function G(e) {
77
+ const t = e.valueLabel === "auto";
78
+ return !t || x(e) !== "inside" ? { hideOverlap: t } : (o) => ({
79
+ hideOverlap: t,
80
+ fontSize: V(o) ? void 0 : 0
81
+ });
82
+ }
83
+ function M(e, t) {
84
+ const o = x(e), n = u(e);
85
+ return {
86
+ show: e.valueLabel !== "never",
87
+ position: o,
88
+ color: o === "inside" ? D(t) : e.theme.labelColor,
89
+ formatter: n ? (r) => n(r.value) : void 0
90
+ };
91
+ }
92
+ function z(e) {
93
+ const { categories: t, theme: o, orientation: n } = e;
94
+ return {
95
+ type: "category",
96
+ data: t,
97
+ // Na horizontal o ECharts empilha a categoria de baixo para cima, invertendo a ordem que o
98
+ // app escolheu ao ordenar as barras.
99
+ inverse: n === "horizontal",
100
+ axisLine: { lineStyle: { color: o.axisLineColor } },
101
+ axisTick: { show: !1 },
102
+ axisLabel: {
103
+ color: o.labelColor,
104
+ hideOverlap: !0,
105
+ width: A[n],
106
+ overflow: "truncate"
107
+ },
108
+ splitLine: { show: !1 }
109
+ };
110
+ }
111
+ function W(e) {
112
+ const { valueAxis: t, stacking: o, theme: n } = e, r = o === "percent", a = u(e);
113
+ return {
114
+ type: t.scale === "log" ? "log" : "value",
115
+ // Barra mede por comprimento: eixo cortado mente sobre a proporção entre as barras, então
116
+ // aqui o zero entra por padrão — ao contrário da série temporal, que só mostra variação.
117
+ scale: !r && t.includeZero === !1,
118
+ min: r ? 0 : t.min,
119
+ max: r ? c : t.max,
120
+ axisLine: { show: !1 },
121
+ axisLabel: { color: n.labelColor, formatter: a },
122
+ splitLine: { lineStyle: { color: n.splitLineColor } }
123
+ };
124
+ }
125
+ function X(e) {
126
+ const { categories: t, series: o, orientation: n, stacking: r, legend: a, theme: l } = e, f = a !== "none" && o.length > 0, m = n === "horizontal", _ = u(e), g = o.map(
127
+ (i) => R(i, t)
128
+ ), y = r === "percent" ? S(g, t.length) : g, v = G(e), d = z(e), h = W(e);
129
+ return {
130
+ animation: !1,
131
+ color: l.seriesColors,
132
+ textStyle: { fontFamily: l.fontFamily, color: l.labelColor },
133
+ grid: {
134
+ ...s,
135
+ top: f ? s.top + 32 : s.top,
136
+ containLabel: !0
137
+ },
138
+ legend: f ? {
139
+ type: "scroll",
140
+ top: 0,
141
+ left: 0,
142
+ icon: "roundRect",
143
+ itemHeight: 8,
144
+ itemWidth: 12,
145
+ textStyle: { color: l.labelColor }
146
+ } : { show: !1 },
147
+ tooltip: {
148
+ trigger: "axis",
149
+ axisPointer: { type: "shadow" },
150
+ backgroundColor: l.tooltipBackgroundColor,
151
+ borderColor: l.tooltipBorderColor,
152
+ textStyle: { color: l.labelColor },
153
+ valueFormatter: _
154
+ },
155
+ xAxis: m ? h : d,
156
+ yAxis: m ? d : h,
157
+ series: o.map((i, L) => {
158
+ const b = e.seriesColorOverrides[i.id] ?? l.seriesColors[L % l.seriesColors.length];
159
+ return {
160
+ id: i.id,
161
+ name: i.name,
162
+ type: "bar",
163
+ stack: r === "off" ? void 0 : T,
164
+ barMaxWidth: E,
165
+ data: y[L],
166
+ itemStyle: { color: b },
167
+ label: M(e, b),
168
+ labelLayout: v
169
+ };
170
+ })
171
+ };
172
+ }
173
+ export {
174
+ X as buildBarChartOption
175
+ };
176
+ //# sourceMappingURL=bar-chart-option.js.map