@apipass/design-system 5.9.0 → 6.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 (93) hide show
  1. package/dist/lib/charts.index.cjs +1 -1
  2. package/dist/lib/charts.index.js +13 -8
  3. package/dist/lib/charts.index.js.map +1 -1
  4. package/dist/lib/embedded-styles.js +2 -2
  5. package/dist/lib/lib.index.cjs +1 -1
  6. package/dist/lib/lib.index.js +657 -657
  7. package/dist/lib/lib.index.js.map +1 -1
  8. package/dist/lib/style.css +1 -1
  9. package/dist/lib/ui/components/DataTable/DataTable.cjs +1 -1
  10. package/dist/lib/ui/components/DataTable/DataTable.cjs.map +1 -1
  11. package/dist/lib/ui/components/DataTable/DataTable.js +217 -3
  12. package/dist/lib/ui/components/DataTable/DataTable.js.map +1 -1
  13. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs +1 -1
  14. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.cjs.map +1 -1
  15. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js +75 -104
  16. package/dist/lib/ui/components/charts/BarChart/bar-chart-option.js.map +1 -1
  17. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.cjs +1 -1
  18. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.cjs.map +1 -1
  19. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.js +27 -26
  20. package/dist/lib/ui/components/charts/ChartLegend/ChartLegend.js.map +1 -1
  21. package/dist/lib/ui/components/charts/PieChart/PieChart.cjs +2 -0
  22. package/dist/lib/ui/components/charts/PieChart/PieChart.cjs.map +1 -0
  23. package/dist/lib/ui/components/charts/PieChart/PieChart.js +178 -0
  24. package/dist/lib/ui/components/charts/PieChart/PieChart.js.map +1 -0
  25. package/dist/lib/ui/components/charts/PieChart/pie-chart-option.cjs +2 -0
  26. package/dist/lib/ui/components/charts/PieChart/pie-chart-option.cjs.map +1 -0
  27. package/dist/lib/ui/components/charts/PieChart/pie-chart-option.js +118 -0
  28. package/dist/lib/ui/components/charts/PieChart/pie-chart-option.js.map +1 -0
  29. package/dist/lib/ui/components/charts/PieChart/pie-chart-slices.cjs +2 -0
  30. package/dist/lib/ui/components/charts/PieChart/pie-chart-slices.cjs.map +1 -0
  31. package/dist/lib/ui/components/charts/PieChart/pie-chart-slices.js +65 -0
  32. package/dist/lib/ui/components/charts/PieChart/pie-chart-slices.js.map +1 -0
  33. package/dist/lib/ui/components/charts/TopList/TopList.cjs +2 -0
  34. package/dist/lib/ui/components/charts/TopList/TopList.cjs.map +1 -0
  35. package/dist/lib/ui/components/charts/TopList/TopList.js +79 -0
  36. package/dist/lib/ui/components/charts/TopList/TopList.js.map +1 -0
  37. package/dist/lib/ui/components/charts/TopList/top-list-option.cjs +2 -0
  38. package/dist/lib/ui/components/charts/TopList/top-list-option.cjs.map +1 -0
  39. package/dist/lib/ui/components/charts/TopList/top-list-option.js +178 -0
  40. package/dist/lib/ui/components/charts/TopList/top-list-option.js.map +1 -0
  41. package/dist/lib/ui/components/charts/chart-color-tone.cjs +2 -0
  42. package/dist/lib/ui/components/charts/chart-color-tone.cjs.map +1 -0
  43. package/dist/lib/ui/components/charts/chart-color-tone.js +14 -0
  44. package/dist/lib/ui/components/charts/chart-color-tone.js.map +1 -0
  45. package/dist/lib/ui/components/charts/chart-label-color.cjs +2 -0
  46. package/dist/lib/ui/components/charts/chart-label-color.cjs.map +1 -0
  47. package/dist/lib/ui/components/charts/chart-label-color.js +35 -0
  48. package/dist/lib/ui/components/charts/chart-label-color.js.map +1 -0
  49. package/dist/lib/ui/components/charts/chart-palette.cjs +1 -1
  50. package/dist/lib/ui/components/charts/chart-palette.cjs.map +1 -1
  51. package/dist/lib/ui/components/charts/chart-palette.js +2 -1
  52. package/dist/lib/ui/components/charts/chart-palette.js.map +1 -1
  53. package/dist/lib/ui/components/charts/chart-share.cjs +2 -0
  54. package/dist/lib/ui/components/charts/chart-share.cjs.map +1 -0
  55. package/dist/lib/ui/components/charts/chart-share.js +11 -0
  56. package/dist/lib/ui/components/charts/chart-share.js.map +1 -0
  57. package/dist/lib/ui/components/charts/chart-theme.cjs +1 -1
  58. package/dist/lib/ui/components/charts/chart-theme.cjs.map +1 -1
  59. package/dist/lib/ui/components/charts/chart-theme.js +4 -3
  60. package/dist/lib/ui/components/charts/chart-theme.js.map +1 -1
  61. package/dist/lib/ui/components/charts/echarts-modules.cjs +1 -1
  62. package/dist/lib/ui/components/charts/echarts-modules.cjs.map +1 -1
  63. package/dist/lib/ui/components/charts/echarts-modules.js +11 -9
  64. package/dist/lib/ui/components/charts/echarts-modules.js.map +1 -1
  65. package/dist/lib/ui/primitives/Table/Table.cjs +1 -1
  66. package/dist/lib/ui/primitives/Table/Table.cjs.map +1 -1
  67. package/dist/lib/ui/primitives/Table/Table.js +123 -12
  68. package/dist/lib/ui/primitives/Table/Table.js.map +1 -1
  69. package/dist/types/charts.index.d.ts +2 -0
  70. package/dist/types/ui/components/DataTable/DataTable.d.ts +79 -11
  71. package/dist/types/ui/components/charts/ChartLegend/ChartLegend.d.ts +1 -0
  72. package/dist/types/ui/components/charts/PieChart/PieChart.d.ts +32 -0
  73. package/dist/types/ui/components/charts/PieChart/pie-chart-option.d.ts +12 -0
  74. package/dist/types/ui/components/charts/PieChart/pie-chart-slices.d.ts +30 -0
  75. package/dist/types/ui/components/charts/TopList/TopList.d.ts +13 -0
  76. package/dist/types/ui/components/charts/TopList/top-list-option.d.ts +24 -0
  77. package/dist/types/ui/components/charts/chart-color-tone.d.ts +1 -0
  78. package/dist/types/ui/components/charts/chart-label-color.d.ts +2 -0
  79. package/dist/types/ui/components/charts/chart-palette.d.ts +1 -0
  80. package/dist/types/ui/components/charts/chart-share.d.ts +1 -0
  81. package/dist/types/ui/components/charts/chart-theme.d.ts +1 -0
  82. package/dist/types/ui/primitives/Table/Table.d.ts +32 -22
  83. package/package.json +1 -1
  84. package/dist/lib/ui/primitives/Table/DataDrivenTable.cjs +0 -2
  85. package/dist/lib/ui/primitives/Table/DataDrivenTable.cjs.map +0 -1
  86. package/dist/lib/ui/primitives/Table/DataDrivenTable.js +0 -196
  87. package/dist/lib/ui/primitives/Table/DataDrivenTable.js.map +0 -1
  88. package/dist/lib/ui/primitives/Table/TableBase.cjs +0 -2
  89. package/dist/lib/ui/primitives/Table/TableBase.cjs.map +0 -1
  90. package/dist/lib/ui/primitives/Table/TableBase.js +0 -127
  91. package/dist/lib/ui/primitives/Table/TableBase.js.map +0 -1
  92. package/dist/types/ui/primitives/Table/DataDrivenTable.d.ts +0 -68
  93. package/dist/types/ui/primitives/Table/TableBase.d.ts +0 -35
@@ -1 +1 @@
1
- {"version":3,"file":"Table.cjs","sources":["../../../../../src/ui/primitives/Table/Table.tsx"],"sourcesContent":["import { DataDrivenTable, type DataDrivenTableProps } from \"./DataDrivenTable\";\nimport { TableBase, type TableBaseProps } from \"./TableBase\";\n\nexport {\n TableBody,\n TableCell,\n TableColumn,\n TableHead,\n TableRow,\n type TableBodyProps,\n type TableCellProps,\n type TableColumnProps,\n type TableHeadProps,\n type TableRowProps,\n} from \"./TableBase\";\nexport type { Column, DataDrivenTableProps, RowActionDef } from \"./DataDrivenTable\";\n\n/**\n * Props do modo composição: o consumidor monta cabeçalho e linhas com `TableHead`,\n * `TableColumn`, `TableBody`, `TableRow` e `TableCell`. `columns` fica proibido aqui\n * porque é ele que ativa o modo data-driven.\n */\nexport type TableProps = TableBaseProps & { columns?: never };\n\n/**\n * Tabela em dois modos, decididos pela presença de `columns`:\n *\n * - **Data-driven** (`columns` + `data`): toolbar com busca, paginação, seleção,\n * ações por linha, estados de loading/vazio e linhas aninhadas. Substitui o antigo\n * `DataTable`.\n * - **Composição** (sem `columns`): primitivo sobre o `Table` do react-aria, com os\n * filhos montados pelo consumidor.\n */\nexport function Table<T extends { id: string }>(\n props: DataDrivenTableProps<T>,\n): ReturnType<typeof DataDrivenTable>;\nexport function Table(props: TableProps): ReturnType<typeof TableBase>;\nexport function Table<T extends { id: string }>(\n props: DataDrivenTableProps<T> | TableProps,\n) {\n if (\"columns\" in props && props.columns) {\n return <DataDrivenTable {...(props as DataDrivenTableProps<T>)} />;\n }\n return <TableBase {...(props as TableProps)} />;\n}\n"],"names":["Table","props","jsx","DataDrivenTable","TableBase"],"mappings":"qLAqCO,SAASA,EACdC,EACA,CACA,MAAI,YAAaA,GAASA,EAAM,QACvBC,MAACC,EAAAA,gBAAA,CAAiB,GAAIF,CAAA,CAAmC,EAE3DC,MAACE,EAAAA,UAAA,CAAW,GAAIH,CAAA,CAAsB,CAC/C"}
1
+ {"version":3,"file":"Table.cjs","sources":["../../../../../src/ui/primitives/Table/Table.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { IconChevronDown, IconChevronUp } from \"icons\";\nimport { Checkbox, Radio } from \"primitives\";\nimport { createContext, useContext, type CSSProperties } from \"react\";\nimport {\n Button as RACButton,\n Cell as RACCell,\n Checkbox as RACSelectionCheckbox,\n Collection as RACCollection,\n Column as RACColumn,\n Row as RACRow,\n Table as RACTable,\n TableBody as RACTableBody,\n TableHeader as RACTableHeader,\n useTableOptions,\n type CellProps as RACCellProps,\n type ColumnProps as RACColumnProps,\n type RowProps as RACRowProps,\n type TableBodyProps as RACTableBodyProps,\n type TableHeaderProps as RACTableHeaderProps,\n type TableProps as RACTableProps,\n} from \"react-aria-components\";\nimport \"./table.css\";\n\ntype TableAlign = \"start\" | \"center\" | \"right\";\n\n/**\n * Visual style of the built-in selection control rendered in the selection\n * column (header \"select all\" + per-row toggle). \"radio\" is for\n * `selectionMode=\"single\"` tables where a round, single-choice control reads\n * better than a checkbox — the header never renders a control either way\n * (there is no \"select all\" for a single choice).\n */\ntype SelectionType = \"checkbox\" | \"radio\";\nconst SelectionTypeContext = createContext<SelectionType>(\"checkbox\");\n\nfunction toCssLength(value: number | string): string {\n const numericValue = Number(value);\n const isUnitlessNumber =\n `${value}`.trim() !== \"\" && Number.isFinite(numericValue);\n return isUnitlessNumber ? `${numericValue}px` : `${value}`;\n}\n\nexport type TableProps = RACTableProps & {\n bleed?: boolean;\n dense?: boolean;\n grid?: boolean;\n striped?: boolean;\n selectionType?: SelectionType;\n maxHeight?: number | string;\n};\nexport function Table({\n bleed = false,\n dense = false,\n grid = false,\n striped = false,\n selectionType = \"checkbox\",\n maxHeight,\n className,\n ...props\n}: TableProps) {\n const scrollsVertically = maxHeight !== undefined;\n const containerClassNames = clsx(\n className,\n \"table-container\",\n bleed && \"table-container-bleed\",\n scrollsVertically && \"table-container-scrollable\",\n );\n const containerStyle = scrollsVertically\n ? ({ \"--table-max-height\": toCssLength(maxHeight) } as CSSProperties)\n : undefined;\n const tableClassNames = clsx(\n \"sds-table\",\n bleed && \"table-bleed\",\n dense && \"table-dense\",\n grid && \"table-grid\",\n striped && \"sds-table-striped\",\n );\n return (\n <div className={containerClassNames} style={containerStyle}>\n <SelectionTypeContext.Provider value={selectionType}>\n <RACTable className={tableClassNames} {...props} />\n </SelectionTypeContext.Provider>\n </div>\n );\n}\n\nexport type TableColumnProps = RACColumnProps & {\n align?: TableAlign;\n};\nexport function TableColumn({\n align = \"start\",\n className,\n ...props\n}: TableColumnProps) {\n const classNames = clsx(className, \"table-column\", `table-align-${align}`);\n return (\n <RACColumn className={classNames} {...props}>\n {({ allowsSorting, sortDirection }) => (\n <div className={clsx(\"table-column-inner\")}>\n <>\n {props.children}\n {allowsSorting && (\n <span\n aria-hidden=\"true\"\n className={clsx(\n \"sort-indicator\",\n !sortDirection && \"sort-indicator-unsorted\",\n )}\n >\n {sortDirection === \"descending\" ? (\n <IconChevronDown />\n ) : (\n <IconChevronUp />\n )}\n </span>\n )}\n </>\n </div>\n )}\n </RACColumn>\n );\n}\n\nexport type TableBodyProps<T> = RACTableBodyProps<T>;\nexport function TableBody<T extends object>({\n className,\n ...props\n}: TableBodyProps<T>) {\n return <RACTableBody {...props} />;\n}\n\nexport type TableHeadProps<T> = RACTableHeaderProps<T>;\nexport function TableHead<T extends object>({\n className,\n columns,\n children,\n ...props\n}: TableHeadProps<T>) {\n const { selectionBehavior, selectionMode, allowsDragging } =\n useTableOptions();\n const selectionType = useContext(SelectionTypeContext);\n const classNames = clsx(className, \"table-head\");\n return (\n <RACTableHeader className={classNames} {...props}>\n {/* Add extra columns for drag and drop and selection. */}\n {allowsDragging && <TableColumn />}\n {selectionBehavior === \"toggle\" && (\n <TableColumn\n className={clsx(\n \"table-selection-col\",\n selectionType === \"radio\" && \"table-selection-col--radio\",\n )}\n >\n {selectionMode === \"multiple\" && (\n <RACSelectionCheckbox slot=\"selection\" className=\"table-selection-checkbox\">\n <Checkbox />\n </RACSelectionCheckbox>\n )}\n </TableColumn>\n )}\n <RACCollection items={columns}>{children}</RACCollection>\n </RACTableHeader>\n );\n}\n\nexport type TableRowProps<T> = RACRowProps<T>;\nexport function TableRow<T extends object>({\n id,\n columns,\n children,\n className,\n ...otherProps\n}: TableRowProps<T>) {\n const { selectionBehavior, allowsDragging } = useTableOptions();\n const selectionType = useContext(SelectionTypeContext);\n const classNames = clsx(className, \"table-row\");\n return (\n <RACRow id={id} {...otherProps} className={classNames}>\n {allowsDragging && (\n <TableCell>\n <RACButton slot=\"drag\">≡</RACButton>\n </TableCell>\n )}\n {selectionBehavior === \"toggle\" && (\n <TableCell\n className={clsx(\n \"table-selection-cell\",\n selectionType === \"radio\" && \"table-selection-cell--radio\",\n )}\n >\n <RACSelectionCheckbox slot=\"selection\" className=\"table-selection-checkbox\">\n {selectionType === \"radio\" ? <Radio /> : <Checkbox />}\n </RACSelectionCheckbox>\n </TableCell>\n )}\n <RACCollection items={columns}>{children}</RACCollection>\n </RACRow>\n );\n}\n\nexport type TableCellProps = RACCellProps & { align?: TableAlign };\nexport function TableCell({\n align = \"start\",\n className,\n ...props\n}: TableCellProps) {\n const classNames = clsx(className, \"table-cell\", `table-align-${align}`);\n return <RACCell className={classNames} {...props} />;\n}\n"],"names":["SelectionTypeContext","createContext","toCssLength","value","numericValue","Table","bleed","dense","grid","striped","selectionType","maxHeight","className","props","scrollsVertically","containerClassNames","clsx","containerStyle","tableClassNames","RACTable","TableColumn","align","classNames","RACColumn","allowsSorting","sortDirection","jsx","jsxs","Fragment","IconChevronDown","IconChevronUp","TableBody","RACTableBody","TableHead","columns","children","selectionBehavior","selectionMode","allowsDragging","useTableOptions","useContext","RACTableHeader","RACSelectionCheckbox","Checkbox","RACCollection","TableRow","id","otherProps","RACRow","TableCell","RACButton","Radio","RACCell"],"mappings":"0ZAkCMA,EAAuBC,EAAAA,cAA6B,UAAU,EAEpE,SAASC,EAAYC,EAAgC,CACnD,MAAMC,EAAe,OAAOD,CAAK,EAGjC,MADE,GAAGA,CAAK,GAAG,SAAW,IAAM,OAAO,SAASC,CAAY,EAChC,GAAGA,CAAY,KAAO,GAAGD,CAAK,EAC1D,CAUO,SAASE,EAAM,CACpB,MAAAC,EAAQ,GACR,MAAAC,EAAQ,GACR,KAAAC,EAAO,GACP,QAAAC,EAAU,GACV,cAAAC,EAAgB,WAChB,UAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAe,CACb,MAAMC,EAAoBH,IAAc,OAClCI,EAAsBC,EAAAA,KAC1BJ,EACA,kBACAN,GAAS,wBACTQ,GAAqB,4BAAA,EAEjBG,EAAiBH,EAClB,CAAE,qBAAsBZ,EAAYS,CAAS,GAC9C,OACEO,EAAkBF,EAAAA,KACtB,YACAV,GAAS,cACTC,GAAS,cACTC,GAAQ,aACRC,GAAW,mBAAA,EAEb,aACG,MAAA,CAAI,UAAWM,EAAqB,MAAOE,EAC1C,eAACjB,EAAqB,SAArB,CAA8B,MAAOU,EACpC,eAACS,QAAA,CAAS,UAAWD,EAAkB,GAAGL,EAAO,EACnD,CAAA,CACF,CAEJ,CAKO,SAASO,EAAY,CAC1B,MAAAC,EAAQ,QACR,UAAAT,EACA,GAAGC,CACL,EAAqB,CACnB,MAAMS,EAAaN,EAAAA,KAAKJ,EAAW,eAAgB,eAAeS,CAAK,EAAE,EACzE,aACGE,SAAA,CAAU,UAAWD,EAAa,GAAGT,EACnC,S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AGO,SAASU,EAA2B,CACzC,GAAAC,EACA,QAAAZ,EACA,SAAAC,EACA,UAAAvB,EACA,GAAGmC,CACL,EAAqB,CACnB,KAAM,CAAE,kBAAAX,EAAmB,eAAAE,CAAA,EAAmBC,kBAAA,EACxC7B,EAAgB8B,EAAAA,WAAWxC,CAAoB,EAC/CsB,EAAaN,EAAAA,KAAKJ,EAAW,WAAW,EAC9C,cACGoC,EAAAA,IAAA,CAAO,GAAAF,EAAS,GAAGC,EAAY,UAAWzB,EACxC,SAAA,CAAAgB,SACEW,EAAA,CACC,SAAAvB,EAAAA,IAACwB,EAAAA,QAAU,KAAK,OAAO,aAAC,CAAA,CAC1B,EAEDd,IAAsB,UACrBV,EAAAA,IAACuB,EAAA,CACC,UAAWjC,EAAAA,KACT,uBACAN,IAAkB,SAAW,6BAAA,EAG/B,SAAAgB,EAAAA,IAACgB,WAAA,CAAqB,KAAK,YAAY,UAAU,2BAC9C,SAAAhC,IAAkB,QAAUgB,EAAAA,IAACyB,QAAA,CAAA,CAAM,EAAKzB,MAACiB,EAAAA,WAAS,CAAA,CACrD,CAAA,CAAA,EAGJjB,EAAAA,IAACkB,EAAAA,WAAA,CAAc,MAAOV,EAAU,SAAAC,CAAA,CAAS,CAAA,EAC3C,CAEJ,CAGO,SAASc,EAAU,CACxB,MAAA5B,EAAQ,QACR,UAAAT,EACA,GAAGC,CACL,EAAmB,CACjB,MAAMS,EAAaN,EAAAA,KAAKJ,EAAW,aAAc,eAAeS,CAAK,EAAE,EACvE,OAAOK,EAAAA,IAAC0B,EAAAA,KAAA,CAAQ,UAAW9B,EAAa,GAAGT,EAAO,CACpD"}
@@ -1,16 +1,127 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { DataDrivenTable as a } from "./DataDrivenTable.js";
3
- import { TableBase as o } from "./TableBase.js";
4
- import { TableBody as i, TableCell as f, TableColumn as u, TableHead as c, TableRow as x } from "./TableBase.js";
5
- function t(e) {
6
- return "columns" in e && e.columns ? /* @__PURE__ */ l(a, { ...e }) : /* @__PURE__ */ l(o, { ...e });
1
+ import { jsx as e, jsxs as b, Fragment as v } from "react/jsx-runtime";
2
+ import { clsx as a } from "../../../vendor/clsx/dist/clsx.js";
3
+ import { createContext as $, useContext as N } from "react";
4
+ import { Table as k, Column as w, TableBody as B, useTableOptions as f, TableHeader as R, Checkbox as g, Collection as p, Row as U, Button as j, Cell as D } from "react-aria-components";
5
+ /* empty css */
6
+ import { IconChevronDown as F } from "../../icons/IconChevronDown.js";
7
+ import { IconChevronUp as I } from "../../icons/IconChevronUp.js";
8
+ import { Checkbox as C } from "../Checkbox/Checkbox.js";
9
+ import { Radio as S } from "../Radio/Radio.js";
10
+ const d = $("checkbox");
11
+ function V(l) {
12
+ const t = Number(l);
13
+ return `${l}`.trim() !== "" && Number.isFinite(t) ? `${t}px` : `${l}`;
14
+ }
15
+ function G({
16
+ bleed: l = !1,
17
+ dense: t = !1,
18
+ grid: s = !1,
19
+ striped: o = !1,
20
+ selectionType: c = "checkbox",
21
+ maxHeight: n,
22
+ className: m,
23
+ ...i
24
+ }) {
25
+ const r = n !== void 0, x = a(
26
+ m,
27
+ "table-container",
28
+ l && "table-container-bleed",
29
+ r && "table-container-scrollable"
30
+ ), T = r ? { "--table-max-height": V(n) } : void 0, y = a(
31
+ "sds-table",
32
+ l && "table-bleed",
33
+ t && "table-dense",
34
+ s && "table-grid",
35
+ o && "sds-table-striped"
36
+ );
37
+ return /* @__PURE__ */ e("div", { className: x, style: T, children: /* @__PURE__ */ e(d.Provider, { value: c, children: /* @__PURE__ */ e(k, { className: y, ...i }) }) });
38
+ }
39
+ function h({
40
+ align: l = "start",
41
+ className: t,
42
+ ...s
43
+ }) {
44
+ const o = a(t, "table-column", `table-align-${l}`);
45
+ return /* @__PURE__ */ e(w, { className: o, ...s, children: ({ allowsSorting: c, sortDirection: n }) => /* @__PURE__ */ e("div", { className: a("table-column-inner"), children: /* @__PURE__ */ b(v, { children: [
46
+ s.children,
47
+ c && /* @__PURE__ */ e(
48
+ "span",
49
+ {
50
+ "aria-hidden": "true",
51
+ className: a(
52
+ "sort-indicator",
53
+ !n && "sort-indicator-unsorted"
54
+ ),
55
+ children: n === "descending" ? /* @__PURE__ */ e(F, {}) : /* @__PURE__ */ e(I, {})
56
+ }
57
+ )
58
+ ] }) }) });
59
+ }
60
+ function J({
61
+ className: l,
62
+ ...t
63
+ }) {
64
+ return /* @__PURE__ */ e(B, { ...t });
65
+ }
66
+ function K({
67
+ className: l,
68
+ columns: t,
69
+ children: s,
70
+ ...o
71
+ }) {
72
+ const { selectionBehavior: c, selectionMode: n, allowsDragging: m } = f(), i = N(d), r = a(l, "table-head");
73
+ return /* @__PURE__ */ b(R, { className: r, ...o, children: [
74
+ m && /* @__PURE__ */ e(h, {}),
75
+ c === "toggle" && /* @__PURE__ */ e(
76
+ h,
77
+ {
78
+ className: a(
79
+ "table-selection-col",
80
+ i === "radio" && "table-selection-col--radio"
81
+ ),
82
+ children: n === "multiple" && /* @__PURE__ */ e(g, { slot: "selection", className: "table-selection-checkbox", children: /* @__PURE__ */ e(C, {}) })
83
+ }
84
+ ),
85
+ /* @__PURE__ */ e(p, { items: t, children: s })
86
+ ] });
87
+ }
88
+ function Q({
89
+ id: l,
90
+ columns: t,
91
+ children: s,
92
+ className: o,
93
+ ...c
94
+ }) {
95
+ const { selectionBehavior: n, allowsDragging: m } = f(), i = N(d), r = a(o, "table-row");
96
+ return /* @__PURE__ */ b(U, { id: l, ...c, className: r, children: [
97
+ m && /* @__PURE__ */ e(u, { children: /* @__PURE__ */ e(j, { slot: "drag", children: "≡" }) }),
98
+ n === "toggle" && /* @__PURE__ */ e(
99
+ u,
100
+ {
101
+ className: a(
102
+ "table-selection-cell",
103
+ i === "radio" && "table-selection-cell--radio"
104
+ ),
105
+ children: /* @__PURE__ */ e(g, { slot: "selection", className: "table-selection-checkbox", children: i === "radio" ? /* @__PURE__ */ e(S, {}) : /* @__PURE__ */ e(C, {}) })
106
+ }
107
+ ),
108
+ /* @__PURE__ */ e(p, { items: t, children: s })
109
+ ] });
110
+ }
111
+ function u({
112
+ align: l = "start",
113
+ className: t,
114
+ ...s
115
+ }) {
116
+ const o = a(t, "table-cell", `table-align-${l}`);
117
+ return /* @__PURE__ */ e(D, { className: o, ...s });
7
118
  }
8
119
  export {
9
- t as Table,
10
- i as TableBody,
11
- f as TableCell,
12
- u as TableColumn,
13
- c as TableHead,
14
- x as TableRow
120
+ G as Table,
121
+ J as TableBody,
122
+ u as TableCell,
123
+ h as TableColumn,
124
+ K as TableHead,
125
+ Q as TableRow
15
126
  };
16
127
  //# sourceMappingURL=Table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../../../src/ui/primitives/Table/Table.tsx"],"sourcesContent":["import { DataDrivenTable, type DataDrivenTableProps } from \"./DataDrivenTable\";\nimport { TableBase, type TableBaseProps } from \"./TableBase\";\n\nexport {\n TableBody,\n TableCell,\n TableColumn,\n TableHead,\n TableRow,\n type TableBodyProps,\n type TableCellProps,\n type TableColumnProps,\n type TableHeadProps,\n type TableRowProps,\n} from \"./TableBase\";\nexport type { Column, DataDrivenTableProps, RowActionDef } from \"./DataDrivenTable\";\n\n/**\n * Props do modo composição: o consumidor monta cabeçalho e linhas com `TableHead`,\n * `TableColumn`, `TableBody`, `TableRow` e `TableCell`. `columns` fica proibido aqui\n * porque é ele que ativa o modo data-driven.\n */\nexport type TableProps = TableBaseProps & { columns?: never };\n\n/**\n * Tabela em dois modos, decididos pela presença de `columns`:\n *\n * - **Data-driven** (`columns` + `data`): toolbar com busca, paginação, seleção,\n * ações por linha, estados de loading/vazio e linhas aninhadas. Substitui o antigo\n * `DataTable`.\n * - **Composição** (sem `columns`): primitivo sobre o `Table` do react-aria, com os\n * filhos montados pelo consumidor.\n */\nexport function Table<T extends { id: string }>(\n props: DataDrivenTableProps<T>,\n): ReturnType<typeof DataDrivenTable>;\nexport function Table(props: TableProps): ReturnType<typeof TableBase>;\nexport function Table<T extends { id: string }>(\n props: DataDrivenTableProps<T> | TableProps,\n) {\n if (\"columns\" in props && props.columns) {\n return <DataDrivenTable {...(props as DataDrivenTableProps<T>)} />;\n }\n return <TableBase {...(props as TableProps)} />;\n}\n"],"names":["Table","props","jsx","DataDrivenTable","TableBase"],"mappings":";;;;AAqCO,SAASA,EACdC,GACA;AACA,SAAI,aAAaA,KAASA,EAAM,UACvB,gBAAAC,EAACC,GAAA,EAAiB,GAAIF,EAAA,CAAmC,IAE3D,gBAAAC,EAACE,GAAA,EAAW,GAAIH,EAAA,CAAsB;AAC/C;"}
1
+ {"version":3,"file":"Table.js","sources":["../../../../../src/ui/primitives/Table/Table.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { IconChevronDown, IconChevronUp } from \"icons\";\nimport { Checkbox, Radio } from \"primitives\";\nimport { createContext, useContext, type CSSProperties } from \"react\";\nimport {\n Button as RACButton,\n Cell as RACCell,\n Checkbox as RACSelectionCheckbox,\n Collection as RACCollection,\n Column as RACColumn,\n Row as RACRow,\n Table as RACTable,\n TableBody as RACTableBody,\n TableHeader as RACTableHeader,\n useTableOptions,\n type CellProps as RACCellProps,\n type ColumnProps as RACColumnProps,\n type RowProps as RACRowProps,\n type TableBodyProps as RACTableBodyProps,\n type TableHeaderProps as RACTableHeaderProps,\n type TableProps as RACTableProps,\n} from \"react-aria-components\";\nimport \"./table.css\";\n\ntype TableAlign = \"start\" | \"center\" | \"right\";\n\n/**\n * Visual style of the built-in selection control rendered in the selection\n * column (header \"select all\" + per-row toggle). \"radio\" is for\n * `selectionMode=\"single\"` tables where a round, single-choice control reads\n * better than a checkbox — the header never renders a control either way\n * (there is no \"select all\" for a single choice).\n */\ntype SelectionType = \"checkbox\" | \"radio\";\nconst SelectionTypeContext = createContext<SelectionType>(\"checkbox\");\n\nfunction toCssLength(value: number | string): string {\n const numericValue = Number(value);\n const isUnitlessNumber =\n `${value}`.trim() !== \"\" && Number.isFinite(numericValue);\n return isUnitlessNumber ? `${numericValue}px` : `${value}`;\n}\n\nexport type TableProps = RACTableProps & {\n bleed?: boolean;\n dense?: boolean;\n grid?: boolean;\n striped?: boolean;\n selectionType?: SelectionType;\n maxHeight?: number | string;\n};\nexport function Table({\n bleed = false,\n dense = false,\n grid = false,\n striped = false,\n selectionType = \"checkbox\",\n maxHeight,\n className,\n ...props\n}: TableProps) {\n const scrollsVertically = maxHeight !== undefined;\n const containerClassNames = clsx(\n className,\n \"table-container\",\n bleed && \"table-container-bleed\",\n scrollsVertically && \"table-container-scrollable\",\n );\n const containerStyle = scrollsVertically\n ? ({ \"--table-max-height\": toCssLength(maxHeight) } as CSSProperties)\n : undefined;\n const tableClassNames = clsx(\n \"sds-table\",\n bleed && \"table-bleed\",\n dense && \"table-dense\",\n grid && \"table-grid\",\n striped && \"sds-table-striped\",\n );\n return (\n <div className={containerClassNames} style={containerStyle}>\n <SelectionTypeContext.Provider value={selectionType}>\n <RACTable className={tableClassNames} {...props} />\n </SelectionTypeContext.Provider>\n </div>\n );\n}\n\nexport type TableColumnProps = RACColumnProps & {\n align?: TableAlign;\n};\nexport function TableColumn({\n align = \"start\",\n className,\n ...props\n}: TableColumnProps) {\n const classNames = clsx(className, \"table-column\", `table-align-${align}`);\n return (\n <RACColumn className={classNames} {...props}>\n {({ allowsSorting, sortDirection }) => (\n <div className={clsx(\"table-column-inner\")}>\n <>\n {props.children}\n {allowsSorting && (\n <span\n aria-hidden=\"true\"\n className={clsx(\n \"sort-indicator\",\n !sortDirection && \"sort-indicator-unsorted\",\n )}\n >\n {sortDirection === \"descending\" ? (\n <IconChevronDown />\n ) : (\n <IconChevronUp />\n )}\n </span>\n )}\n </>\n </div>\n )}\n </RACColumn>\n );\n}\n\nexport type TableBodyProps<T> = RACTableBodyProps<T>;\nexport function TableBody<T extends object>({\n className,\n ...props\n}: TableBodyProps<T>) {\n return <RACTableBody {...props} />;\n}\n\nexport type TableHeadProps<T> = RACTableHeaderProps<T>;\nexport function TableHead<T extends object>({\n className,\n columns,\n children,\n ...props\n}: TableHeadProps<T>) {\n const { selectionBehavior, selectionMode, allowsDragging } =\n useTableOptions();\n const selectionType = useContext(SelectionTypeContext);\n const classNames = clsx(className, \"table-head\");\n return (\n <RACTableHeader className={classNames} {...props}>\n {/* Add extra columns for drag and drop and selection. */}\n {allowsDragging && <TableColumn />}\n {selectionBehavior === \"toggle\" && (\n <TableColumn\n className={clsx(\n \"table-selection-col\",\n selectionType === \"radio\" && \"table-selection-col--radio\",\n )}\n >\n {selectionMode === \"multiple\" && (\n <RACSelectionCheckbox slot=\"selection\" className=\"table-selection-checkbox\">\n <Checkbox />\n </RACSelectionCheckbox>\n )}\n </TableColumn>\n )}\n <RACCollection items={columns}>{children}</RACCollection>\n </RACTableHeader>\n );\n}\n\nexport type TableRowProps<T> = RACRowProps<T>;\nexport function TableRow<T extends object>({\n id,\n columns,\n children,\n className,\n ...otherProps\n}: TableRowProps<T>) {\n const { selectionBehavior, allowsDragging } = useTableOptions();\n const selectionType = useContext(SelectionTypeContext);\n const classNames = clsx(className, \"table-row\");\n return (\n <RACRow id={id} {...otherProps} className={classNames}>\n {allowsDragging && (\n <TableCell>\n <RACButton slot=\"drag\">≡</RACButton>\n </TableCell>\n )}\n {selectionBehavior === \"toggle\" && (\n <TableCell\n className={clsx(\n \"table-selection-cell\",\n selectionType === \"radio\" && \"table-selection-cell--radio\",\n )}\n >\n <RACSelectionCheckbox slot=\"selection\" className=\"table-selection-checkbox\">\n {selectionType === \"radio\" ? <Radio /> : <Checkbox />}\n </RACSelectionCheckbox>\n </TableCell>\n )}\n <RACCollection items={columns}>{children}</RACCollection>\n </RACRow>\n );\n}\n\nexport type TableCellProps = RACCellProps & { align?: TableAlign };\nexport function TableCell({\n align = \"start\",\n className,\n ...props\n}: TableCellProps) {\n const classNames = clsx(className, \"table-cell\", `table-align-${align}`);\n return <RACCell className={classNames} {...props} />;\n}\n"],"names":["SelectionTypeContext","createContext","toCssLength","value","numericValue","Table","bleed","dense","grid","striped","selectionType","maxHeight","className","props","scrollsVertically","containerClassNames","clsx","containerStyle","tableClassNames","RACTable","TableColumn","align","classNames","RACColumn","allowsSorting","sortDirection","jsx","jsxs","Fragment","IconChevronDown","IconChevronUp","TableBody","RACTableBody","TableHead","columns","children","selectionBehavior","selectionMode","allowsDragging","useTableOptions","useContext","RACTableHeader","RACSelectionCheckbox","Checkbox","RACCollection","TableRow","id","otherProps","RACRow","TableCell","RACButton","Radio","RACCell"],"mappings":";;;;;;;;;AAkCA,MAAMA,IAAuBC,EAA6B,UAAU;AAEpE,SAASC,EAAYC,GAAgC;AACnD,QAAMC,IAAe,OAAOD,CAAK;AAGjC,SADE,GAAGA,CAAK,GAAG,WAAW,MAAM,OAAO,SAASC,CAAY,IAChC,GAAGA,CAAY,OAAO,GAAGD,CAAK;AAC1D;AAUO,SAASE,EAAM;AAAA,EACpB,OAAAC,IAAQ;AAAA,EACR,OAAAC,IAAQ;AAAA,EACR,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,eAAAC,IAAgB;AAAA,EAChB,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GAAe;AACb,QAAMC,IAAoBH,MAAc,QAClCI,IAAsBC;AAAA,IAC1BJ;AAAA,IACA;AAAA,IACAN,KAAS;AAAA,IACTQ,KAAqB;AAAA,EAAA,GAEjBG,IAAiBH,IAClB,EAAE,sBAAsBZ,EAAYS,CAAS,MAC9C,QACEO,IAAkBF;AAAA,IACtB;AAAA,IACAV,KAAS;AAAA,IACTC,KAAS;AAAA,IACTC,KAAQ;AAAA,IACRC,KAAW;AAAA,EAAA;AAEb,2BACG,OAAA,EAAI,WAAWM,GAAqB,OAAOE,GAC1C,4BAACjB,EAAqB,UAArB,EAA8B,OAAOU,GACpC,4BAACS,GAAA,EAAS,WAAWD,GAAkB,GAAGL,GAAO,GACnD,EAAA,CACF;AAEJ;AAKO,SAASO,EAAY;AAAA,EAC1B,OAAAC,IAAQ;AAAA,EACR,WAAAT;AAAA,EACA,GAAGC;AACL,GAAqB;AAC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ACvE,SAAO,gBAAAK,EAAC0B,GAAA,EAAQ,WAAW9B,GAAa,GAAGT,GAAO;AACpD;"}
@@ -2,4 +2,6 @@ export * from "./ui/components/charts/BarChart/BarChart";
2
2
  export * from "./ui/components/charts/chart-palette";
3
3
  export * from "./ui/components/charts/ChartColorPicker/ChartColorPicker";
4
4
  export * from "./ui/components/charts/ChartLegend/ChartLegend";
5
+ export * from "./ui/components/charts/PieChart/PieChart";
5
6
  export * from "./ui/components/charts/TimeSeriesChart/TimeSeriesChart";
7
+ export * from "./ui/components/charts/TopList/TopList";
@@ -1,14 +1,82 @@
1
- import { Table, type DataDrivenTableProps } from "primitives";
1
+ import type { ReactNode } from "react";
2
+ import type { Selection, SortDescriptor } from "react-aria-components";
2
3
  import "./datatable.css";
3
- /**
4
- * @deprecated Use `Table` com `columns` e `data` — as props são idênticas. Mantido só
5
- * para a migração gradual dos consumidores; será removido quando nenhum repositório
6
- * importar mais o `DataTable`.
7
- */
8
- export declare const DataTable: <T extends {
4
+ export interface Column<T> {
5
+ key: keyof T | string;
6
+ label: string;
7
+ align?: "start" | "center" | "right";
8
+ render?: (item: T) => ReactNode;
9
+ /** When true, the header becomes clickable and the rows can be sorted by this column. */
10
+ sortable?: boolean;
11
+ /** Value used to sort this column. Defaults to `item[key]`. */
12
+ sortValue?: (item: T) => SortableValue;
13
+ }
14
+ type SortableValue = string | number | Date | null | undefined;
15
+ export interface RowActionDef<T> {
16
+ /** Unique key for this action. */
17
+ key: string;
18
+ /** aria-label for the button. */
19
+ label: string;
20
+ /** Icon element rendered inside the button. */
21
+ icon: ReactNode;
22
+ /** When false, button is disabled and a tooltip with `noAccessLabel` is shown. Default: true. */
23
+ isAllowed?: boolean;
24
+ /** Tooltip text shown when `isAllowed` is false. */
25
+ noAccessLabel?: string;
26
+ /** Called with the row item when the button is pressed. */
27
+ onPress: (item: T) => void;
28
+ }
29
+ export interface DataTableProps<T extends {
9
30
  id: string;
10
- }>(props: DataDrivenTableProps<T>) => ReturnType<typeof Table>;
11
- /** @deprecated Use `DataDrivenTableProps`. */
12
- export type DataTableProps<T extends {
31
+ }> {
32
+ columns: Column<T>[];
33
+ data: T[];
34
+ actions?: ReactNode;
35
+ /** Per-row action buttons rendered in a dedicated last column. */
36
+ rowActions?: RowActionDef<T>[] | ((item: T) => RowActionDef<T>[]);
37
+ /** Label for the row actions column header. Defaults to empty string. */
38
+ rowActionsLabel?: string;
39
+ /**
40
+ * When true, renders a selection column before the first data column — a per-row control on
41
+ * every row (see `selectionType`), plus a "select all" checkbox in the header when
42
+ * `selectionType` is "checkbox". Off by default.
43
+ */
44
+ selectable?: boolean;
45
+ /**
46
+ * Visual style of the built-in selection control. "checkbox" (default) allows selecting
47
+ * multiple rows and shows a "select all" in the header. "radio" restricts selection to a
48
+ * single row (no "select all" — there is nothing to select all *to* with one choice) and
49
+ * renders a round control instead of a checkbox.
50
+ */
51
+ selectionType?: "checkbox" | "radio";
52
+ /** When true, draws vertical lines between columns. Off by default. */
53
+ grid?: boolean;
54
+ /** Controlled selection state. Omit to let the table manage its own selection internally. */
55
+ selectedKeys?: Selection;
56
+ onSelectionChange?: (keys: Selection) => void;
57
+ /** Initial sort when the table manages its own sorting. Only columns with `sortable` can be sorted. */
58
+ defaultSortDescriptor?: SortDescriptor;
59
+ /** Controlled sort state. Omit to let the table manage its own sorting internally. */
60
+ sortDescriptor?: SortDescriptor;
61
+ onSortChange?: (descriptor: SortDescriptor) => void;
62
+ searchPlaceholder?: string;
63
+ searchKeys?: (keyof T)[];
64
+ isLoading?: boolean;
65
+ loadingMessage?: string;
66
+ emptyMessage?: string;
67
+ previousLabel?: string;
68
+ nextLabel?: string;
69
+ pageSize?: number;
70
+ nestedColumns?: Column<any>[];
71
+ getNestedData?: (item: T) => any[] | Promise<any[]>;
72
+ nestedLoadingMessage?: string;
73
+ nestedEmptyMessage?: string;
74
+ nestedSearchKeys?: (keyof any)[];
75
+ nestedSearchPlaceholder?: string;
76
+ nestedActions?: (item: T) => ReactNode;
77
+ nestedPageSize?: number;
78
+ }
79
+ export declare function DataTable<T extends {
13
80
  id: string;
14
- }> = DataDrivenTableProps<T>;
81
+ }>({ columns, data, actions, rowActions, rowActionsLabel, selectable, selectionType, grid, selectedKeys, onSelectionChange, defaultSortDescriptor, sortDescriptor: controlledSortDescriptor, onSortChange, searchPlaceholder, searchKeys, isLoading, loadingMessage, emptyMessage, previousLabel, nextLabel, pageSize, nestedColumns, getNestedData, nestedLoadingMessage, nestedEmptyMessage, nestedSearchKeys, nestedSearchPlaceholder, nestedActions, nestedPageSize, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
82
+ export {};
@@ -6,6 +6,7 @@ export interface ChartLegendItem {
6
6
  name: string;
7
7
  color: string;
8
8
  isHidden: boolean;
9
+ detail?: string;
9
10
  }
10
11
  export interface ChartLegendLabels extends ChartColorPickerLabels {
11
12
  toggleSeries: (seriesName: string) => string;
@@ -0,0 +1,32 @@
1
+ import { type ComponentPropsWithoutRef } from "react";
2
+ import { type ChartLegendLabels } from "../ChartLegend/ChartLegend";
3
+ import { type PieChartLabelContent, type PieChartShape } from "./pie-chart-option";
4
+ import { type PieChartNode } from "./pie-chart-slices";
5
+ import "./pie-chart.css";
6
+ export type { PieChartNode } from "./pie-chart-slices";
7
+ export type { PieChartLabelContent, PieChartShape } from "./pie-chart-option";
8
+ export type PieChartLegendMode = "inline" | "none";
9
+ export type PieChartLegendPosition = "bottom" | "right" | "top" | "left";
10
+ export type PieChartLegendValue = "percent" | "value";
11
+ export type PieChartShowTotal = "auto" | "on" | "off";
12
+ export interface PieChartLabels {
13
+ others: string;
14
+ total: string;
15
+ backToPrevious: (categoryName: string) => string;
16
+ }
17
+ export type PieChartProps = Omit<ComponentPropsWithoutRef<"div">, "children"> & {
18
+ data: PieChartNode[];
19
+ shape?: PieChartShape;
20
+ labelContent?: PieChartLabelContent[];
21
+ showTotal?: PieChartShowTotal;
22
+ total?: number;
23
+ valueFormatter?: (value: number) => string;
24
+ legend?: PieChartLegendMode;
25
+ legendPosition?: PieChartLegendPosition;
26
+ legendValues?: PieChartLegendValue[];
27
+ onSeriesColorChange?: (seriesId: string, colorToken: string | null) => void;
28
+ onFocusChange?: (focusedNodeId: string | null) => void;
29
+ legendLabels?: Partial<ChartLegendLabels>;
30
+ labels?: Partial<PieChartLabels>;
31
+ };
32
+ export declare function PieChart({ data, shape, labelContent, showTotal, total, valueFormatter, legend, legendPosition, legendValues, onSeriesColorChange, onFocusChange, legendLabels, labels, className, ...props }: PieChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { ChartTheme } from "../chart-theme";
2
+ import type { PieSlice } from "./pie-chart-slices";
3
+ export type PieChartLabelContent = "name" | "percent" | "value";
4
+ export type PieChartShape = "donut" | "pie";
5
+ export interface PieChartOptionInput {
6
+ slices: PieSlice[];
7
+ shape: PieChartShape;
8
+ labelContent: PieChartLabelContent[];
9
+ theme: ChartTheme;
10
+ valueFormatter?: (value: number) => string;
11
+ }
12
+ export declare function buildPieChartOption(input: PieChartOptionInput): Record<string, unknown>;
@@ -0,0 +1,30 @@
1
+ export interface PieChartNode {
2
+ id: string;
3
+ name: string;
4
+ value: number | null;
5
+ colorToken?: string;
6
+ isOthers?: boolean;
7
+ children?: PieChartNode[];
8
+ }
9
+ export interface PieSlice {
10
+ id: string;
11
+ name: string;
12
+ value: number;
13
+ share: number;
14
+ path: string[];
15
+ color: string;
16
+ isOthers: boolean;
17
+ children: PieSlice[];
18
+ }
19
+ export interface BuildPieSlicesInput {
20
+ nodes: PieChartNode[];
21
+ colorsByRootId: Record<string, string>;
22
+ fallbackColor: string;
23
+ othersName: string;
24
+ }
25
+ export declare function displayNameOf(node: PieChartNode, othersName: string): string;
26
+ export declare function buildPieSlices(input: BuildPieSlicesInput): PieSlice[];
27
+ export declare function findSlice(slices: PieSlice[], id: string): PieSlice | undefined;
28
+ export declare function findParentSlice(slices: PieSlice[], id: string): PieSlice | undefined;
29
+ export declare function sliceDepth(slices: PieSlice[]): number;
30
+ export declare function totalOf(slices: PieSlice[]): number;
@@ -0,0 +1,13 @@
1
+ import { type ComponentPropsWithoutRef } from "react";
2
+ import { type TopListItem, type TopListSort, type TopListValueDisplay } from "./top-list-option";
3
+ import "./top-list.css";
4
+ export type { TopListItem, TopListSort, TopListValueDisplay } from "./top-list-option";
5
+ export type TopListProps = Omit<ComponentPropsWithoutRef<"div">, "children"> & {
6
+ items: TopListItem[];
7
+ sort?: TopListSort;
8
+ total?: number;
9
+ valueDisplay?: TopListValueDisplay[];
10
+ valueFormatter?: (value: number) => string;
11
+ colorToken?: string;
12
+ };
13
+ export declare function TopList({ items, sort, total, valueDisplay, valueFormatter, colorToken, className, ...props }: TopListProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import type { ChartTheme } from "../chart-theme";
2
+ export interface TopListItem {
3
+ id: string;
4
+ name: string;
5
+ value: number | null;
6
+ colorToken?: string;
7
+ }
8
+ export type TopListSort = "desc" | "asc";
9
+ export type TopListValueDisplay = "value" | "percent";
10
+ export interface TopListOptionInput {
11
+ items: TopListItem[];
12
+ sort: TopListSort;
13
+ total?: number;
14
+ valueDisplay: TopListValueDisplay[];
15
+ theme: ChartTheme;
16
+ colorsByItemId: Record<string, string>;
17
+ animate: boolean;
18
+ labeledRowStep: number;
19
+ valueFormatter?: (value: number) => string;
20
+ }
21
+ export declare function rankById(items: TopListItem[], sort: TopListSort): Map<string, number>;
22
+ export declare function resolveTotal(items: TopListItem[], total?: number): number;
23
+ export declare function labeledRowStepFor(canvasHeightPx: number, itemCount: number): number;
24
+ export declare function buildTopListOption(input: TopListOptionInput): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export declare function lightenColor(color: string, amount: number): string;
@@ -0,0 +1,2 @@
1
+ export declare function parseColorChannels(color: string): [number, number, number] | undefined;
2
+ export declare function labelColorOnFill(fillColor: string): string;
@@ -1 +1,2 @@
1
1
  export declare const CHART_SERIES_COLOR_TOKENS: string[];
2
+ export declare const CHART_NEUTRAL_COLOR_TOKEN: string;
@@ -0,0 +1 @@
1
+ export declare function formatShare(share: number): string;
@@ -1,5 +1,6 @@
1
1
  export interface ChartTheme {
2
2
  seriesColors: string[];
3
+ neutralColor: string;
3
4
  axisLineColor: string;
4
5
  splitLineColor: string;
5
6
  labelColor: string;
@@ -1,25 +1,35 @@
1
- import { DataDrivenTable, type DataDrivenTableProps } from "./DataDrivenTable";
2
- import { TableBase, type TableBaseProps } from "./TableBase";
3
- export { TableBody, TableCell, TableColumn, TableHead, TableRow, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TableRowProps, } from "./TableBase";
4
- export type { Column, DataDrivenTableProps, RowActionDef } from "./DataDrivenTable";
1
+ import { type CellProps as RACCellProps, type ColumnProps as RACColumnProps, type RowProps as RACRowProps, type TableBodyProps as RACTableBodyProps, type TableHeaderProps as RACTableHeaderProps, type TableProps as RACTableProps } from "react-aria-components";
2
+ import "./table.css";
3
+ type TableAlign = "start" | "center" | "right";
5
4
  /**
6
- * Props do modo composição: o consumidor monta cabeçalho e linhas com `TableHead`,
7
- * `TableColumn`, `TableBody`, `TableRow` e `TableCell`. `columns` fica proibido aqui
8
- * porque é ele que ativa o modo data-driven.
5
+ * Visual style of the built-in selection control rendered in the selection
6
+ * column (header "select all" + per-row toggle). "radio" is for
7
+ * `selectionMode="single"` tables where a round, single-choice control reads
8
+ * better than a checkbox — the header never renders a control either way
9
+ * (there is no "select all" for a single choice).
9
10
  */
10
- export type TableProps = TableBaseProps & {
11
- columns?: never;
11
+ type SelectionType = "checkbox" | "radio";
12
+ export type TableProps = RACTableProps & {
13
+ bleed?: boolean;
14
+ dense?: boolean;
15
+ grid?: boolean;
16
+ striped?: boolean;
17
+ selectionType?: SelectionType;
18
+ maxHeight?: number | string;
12
19
  };
13
- /**
14
- * Tabela em dois modos, decididos pela presença de `columns`:
15
- *
16
- * - **Data-driven** (`columns` + `data`): toolbar com busca, paginação, seleção,
17
- * ações por linha, estados de loading/vazio e linhas aninhadas. Substitui o antigo
18
- * `DataTable`.
19
- * - **Composição** (sem `columns`): primitivo sobre o `Table` do react-aria, com os
20
- * filhos montados pelo consumidor.
21
- */
22
- export declare function Table<T extends {
23
- id: string;
24
- }>(props: DataDrivenTableProps<T>): ReturnType<typeof DataDrivenTable>;
25
- export declare function Table(props: TableProps): ReturnType<typeof TableBase>;
20
+ export declare function Table({ bleed, dense, grid, striped, selectionType, maxHeight, className, ...props }: TableProps): import("react/jsx-runtime").JSX.Element;
21
+ export type TableColumnProps = RACColumnProps & {
22
+ align?: TableAlign;
23
+ };
24
+ export declare function TableColumn({ align, className, ...props }: TableColumnProps): import("react/jsx-runtime").JSX.Element;
25
+ export type TableBodyProps<T> = RACTableBodyProps<T>;
26
+ export declare function TableBody<T extends object>({ className, ...props }: TableBodyProps<T>): import("react/jsx-runtime").JSX.Element;
27
+ export type TableHeadProps<T> = RACTableHeaderProps<T>;
28
+ export declare function TableHead<T extends object>({ className, columns, children, ...props }: TableHeadProps<T>): import("react/jsx-runtime").JSX.Element;
29
+ export type TableRowProps<T> = RACRowProps<T>;
30
+ export declare function TableRow<T extends object>({ id, columns, children, className, ...otherProps }: TableRowProps<T>): import("react/jsx-runtime").JSX.Element;
31
+ export type TableCellProps = RACCellProps & {
32
+ align?: TableAlign;
33
+ };
34
+ export declare function TableCell({ align, className, ...props }: TableCellProps): import("react/jsx-runtime").JSX.Element;
35
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apipass/design-system",
3
- "version": "5.9.0",
3
+ "version": "6.2.0",
4
4
  "type": "module",
5
5
  "description": "APIPass React Design System",
6
6
  "sideEffects": [
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),u=require("react"),l=require("./TableBase.cjs"),ee=require("../../layout/Flex/Flex.cjs"),ae=require("../Search/Search.cjs"),se=require("../../icons/IconChevronDown.cjs"),te=require("../../icons/IconChevronRight.cjs"),ne=require("../Pagination/Pagination.cjs"),le=require("../PermissionGate/PermissionGate.cjs");function re({action:o,item:c}){const d=o.isAllowed!==!1,i=a.jsx("button",{type:"button",className:"data-table-row-action-btn","aria-label":o.label,disabled:!d,onClick:d?()=>o.onPress(c):void 0,children:o.icon});return d?i:a.jsx(le.PermissionGate,{isAllowed:!1,noAccessLabel:o.noAccessLabel??"",children:i})}function D({columns:o,data:c,actions:d,rowActions:i,rowActionsLabel:E="",selectable:S=!1,selectionType:T="checkbox",selectedKeys:B,onSelectionChange:I,searchPlaceholder:F="Search...",searchKeys:p=[],isLoading:G=!1,loadingMessage:v="Loading...",emptyMessage:H="No records found",previousLabel:$="Previous",nextLabel:O="Next",pageSize:h=10,nestedColumns:M,getNestedData:P,nestedLoadingMessage:Q="Loading...",nestedEmptyMessage:z="No records found",nestedSearchKeys:J,nestedSearchPlaceholder:U,nestedActions:j,nestedPageSize:V}){const[w,W]=u.useState(""),[X,y]=u.useState(1),[R,Y]=u.useState(new Set),[q,b]=u.useState(new Map),f=!!P&&!!M,m=!!i;function k(e,s){Y(n=>{const r=new Set(n);return s?r.add(e):r.delete(e),r})}function Z(e){const s=e.id,n=!R.has(s);if(k(s,n),!n||q.has(s))return;const r=P(e);r instanceof Promise?(b(t=>new Map(t).set(s,{status:"loading",data:[]})),r.then(t=>{b(g=>new Map(g).set(s,{status:"loaded",data:t}))},()=>{b(t=>{const g=new Map(t);return g.delete(s),g}),k(s,!1)})):b(t=>new Map(t).set(s,{status:"loaded",data:r}))}const x=p.length>0,_=x||!!d,C=u.useMemo(()=>{if(!w.trim()||!x)return c;const e=w.toLowerCase();return c.filter(s=>p.some(n=>String(s[n]??"").toLowerCase().includes(e)))},[c,w,p,x]),L=Math.max(1,Math.ceil(C.length/h)),N=Math.min(X,L),A=C.slice((N-1)*h,N*h);function K(e,s){return s.render?s.render(e):String(e[s.key]??"")}return a.jsxs(ee.Flex,{direction:"column",gap:"300",className:"data-table",children:[_&&a.jsxs("div",{className:"data-table-toolbar",children:[x&&a.jsx(ae.Search,{placeholder:F,onSearch:e=>{W(e),y(1)},className:"data-table-search"}),d&&a.jsx("div",{className:"data-table-actions",children:d})]}),G?a.jsx("div",{role:"status","aria-live":"polite","aria-label":v,className:"data-table-status",children:v}):C.length===0?a.jsx("div",{role:"status",className:"data-table-status data-table-empty",children:H}):a.jsxs(l.TableBase,{selectionMode:S?T==="radio"?"single":"multiple":"none",selectionType:T,selectedKeys:B,onSelectionChange:I,children:[a.jsxs(l.TableHead,{children:[f&&a.jsx(l.TableColumn,{className:"data-table-expand-col"}),o.map((e,s)=>a.jsx(l.TableColumn,{align:e.align,isRowHeader:s===0,children:e.label},String(e.key))),m&&a.jsx(l.TableColumn,{align:"right",className:"data-table-row-actions-col",children:E})]}),a.jsx(l.TableBody,{children:A.flatMap(e=>{const s=R.has(e.id),n=q.get(e.id),r=[a.jsxs(l.TableRow,{id:e.id,children:[f&&a.jsx(l.TableCell,{className:"data-table-expand-cell",children:a.jsx("button",{type:"button",className:"data-table-expand-btn","aria-label":s?"Collapse row":"Expand row","aria-expanded":s,onClick:()=>Z(e),children:s?a.jsx(se.IconChevronDown,{size:"16"}):a.jsx(te.IconChevronRight,{size:"16"})})}),o.map(t=>a.jsx(l.TableCell,{align:t.align,children:K(e,t)},String(t.key))),m&&a.jsx(l.TableCell,{align:"right",className:"data-table-row-actions-cell",children:a.jsx("div",{className:"data-table-row-actions",children:(typeof i=="function"?i(e):i).map(t=>a.jsx(re,{action:t,item:e},t.key))})})]},e.id)];return s&&r.push(a.jsx(l.TableRow,{id:`${e.id}-nested`,className:"data-table-nested-row",children:a.jsx(l.TableCell,{colSpan:o.length+(f?1:0)+(S?1:0)+(m?1:0),className:"data-table-nested-cell",children:a.jsx(D,{columns:M,data:(n==null?void 0:n.data)??[],isLoading:!n||n.status==="loading",loadingMessage:Q,emptyMessage:z,searchKeys:J,searchPlaceholder:U,actions:j==null?void 0:j(e),pageSize:V??h})})},`${e.id}-nested`)),r})})]}),a.jsx(ne.Pagination,{page:N,totalPages:L,onPageChange:y,previousLabel:$,nextLabel:O})]})}exports.DataDrivenTable=D;
2
- //# sourceMappingURL=DataDrivenTable.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataDrivenTable.cjs","sources":["../../../../../src/ui/primitives/Table/DataDrivenTable.tsx"],"sourcesContent":["import { Pagination, PermissionGate, Search } from \"primitives\";\nimport { Flex } from \"layout\";\nimport { IconChevronDown, IconChevronRight } from \"icons\";\nimport type { ReactNode } from \"react\";\nimport { useMemo, useState } from \"react\";\nimport type { Selection } from \"react-aria-components\";\nimport {\n TableBase,\n TableBody,\n TableCell,\n TableColumn,\n TableHead,\n TableRow,\n} from \"./TableBase\";\n\nexport interface Column<T> {\n key: keyof T | string;\n label: string;\n align?: \"start\" | \"center\" | \"right\";\n render?: (item: T) => ReactNode;\n}\n\nexport interface RowActionDef<T> {\n /** Unique key for this action. */\n key: string;\n /** aria-label for the button. */\n label: string;\n /** Icon element rendered inside the button. */\n icon: ReactNode;\n /** When false, button is disabled and a tooltip with `noAccessLabel` is shown. Default: true. */\n isAllowed?: boolean;\n /** Tooltip text shown when `isAllowed` is false. */\n noAccessLabel?: string;\n /** Called with the row item when the button is pressed. */\n onPress: (item: T) => void;\n}\n\nfunction RowActionButton<T>({\n action,\n item,\n}: {\n action: RowActionDef<T>;\n item: T;\n}) {\n const allowed = action.isAllowed !== false;\n const btn = (\n <button\n type=\"button\"\n className=\"data-table-row-action-btn\"\n aria-label={action.label}\n disabled={!allowed}\n onClick={allowed ? () => action.onPress(item) : undefined}\n >\n {action.icon}\n </button>\n );\n if (allowed) return btn;\n return (\n <PermissionGate isAllowed={false} noAccessLabel={action.noAccessLabel ?? \"\"}>\n {btn}\n </PermissionGate>\n );\n}\n\n// O tipo da linha aninhada é independente de T (não há relação genérica entre linha pai e linhas\n// filhas), então \"any\" é usado deliberadamente como fronteira de erasure de tipo.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype NestedStatus = { status: \"loading\"; data: never[] } | { status: \"loaded\"; data: any[] };\n\nexport interface DataDrivenTableProps<T extends { id: string }> {\n columns: Column<T>[];\n data: T[];\n actions?: ReactNode;\n /** Per-row action buttons rendered in a dedicated last column. */\n rowActions?: RowActionDef<T>[] | ((item: T) => RowActionDef<T>[]);\n /** Label for the row actions column header. Defaults to empty string. */\n rowActionsLabel?: string;\n /**\n * When true, renders a selection column before the first data column — a per-row control on\n * every row (see `selectionType`), plus a \"select all\" checkbox in the header when\n * `selectionType` is \"checkbox\". Off by default.\n */\n selectable?: boolean;\n /**\n * Visual style of the built-in selection control. \"checkbox\" (default) allows selecting\n * multiple rows and shows a \"select all\" in the header. \"radio\" restricts selection to a\n * single row (no \"select all\" — there is nothing to select all *to* with one choice) and\n * renders a round control instead of a checkbox.\n */\n selectionType?: \"checkbox\" | \"radio\";\n /** Controlled selection state. Omit to let the table manage its own selection internally. */\n selectedKeys?: Selection;\n onSelectionChange?: (keys: Selection) => void;\n searchPlaceholder?: string;\n searchKeys?: (keyof T)[];\n isLoading?: boolean;\n loadingMessage?: string;\n emptyMessage?: string;\n previousLabel?: string;\n nextLabel?: string;\n pageSize?: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- linha aninhada é de tipo independente de T\n nestedColumns?: Column<any>[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- linha aninhada é de tipo independente de T\n getNestedData?: (item: T) => any[] | Promise<any[]>;\n nestedLoadingMessage?: string;\n nestedEmptyMessage?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- linha aninhada é de tipo independente de T\n nestedSearchKeys?: (keyof any)[];\n nestedSearchPlaceholder?: string;\n nestedActions?: (item: T) => ReactNode;\n nestedPageSize?: number;\n}\n\nexport function DataDrivenTable<T extends { id: string }>({\n columns,\n data,\n actions,\n rowActions,\n rowActionsLabel = \"\",\n selectable = false,\n selectionType = \"checkbox\",\n selectedKeys,\n onSelectionChange,\n searchPlaceholder = \"Search...\",\n searchKeys = [],\n isLoading = false,\n loadingMessage = \"Loading...\",\n emptyMessage = \"No records found\",\n previousLabel = \"Previous\",\n nextLabel = \"Next\",\n pageSize = 10,\n nestedColumns,\n getNestedData,\n nestedLoadingMessage = \"Loading...\",\n nestedEmptyMessage = \"No records found\",\n nestedSearchKeys,\n nestedSearchPlaceholder,\n nestedActions,\n nestedPageSize,\n}: DataDrivenTableProps<T>) {\n const [query, setQuery] = useState(\"\");\n const [page, setPage] = useState(1);\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n const [nestedCache, setNestedCache] = useState<Map<string, NestedStatus>>(new Map());\n\n const hasNested = !!getNestedData && !!nestedColumns;\n const hasRowActions = !!rowActions;\n\n function setRowExpanded(id: string, isExpanded: boolean) {\n setExpanded((prev) => {\n const next = new Set(prev);\n if (isExpanded) next.add(id);\n else next.delete(id);\n return next;\n });\n }\n\n // A carga fica fora do updater do setExpanded: o React pode chamar updaters mais de uma\n // vez (StrictMode), o que dispararia getNestedData em dobro.\n function toggleRow(item: T) {\n const id = item.id;\n const willExpand = !expanded.has(id);\n setRowExpanded(id, willExpand);\n if (!willExpand || nestedCache.has(id)) return;\n\n const result = getNestedData!(item);\n if (result instanceof Promise) {\n setNestedCache((c) => new Map(c).set(id, { status: \"loading\", data: [] }));\n result.then(\n (rows) => {\n setNestedCache((c) => new Map(c).set(id, { status: \"loaded\", data: rows }));\n },\n () => {\n // Na falha, descarta a entrada e recolhe a linha: expandir de novo refaz a carga,\n // em vez de a linha ficar presa em \"loading\".\n setNestedCache((c) => {\n const next = new Map(c);\n next.delete(id);\n return next;\n });\n setRowExpanded(id, false);\n },\n );\n } else {\n setNestedCache((c) => new Map(c).set(id, { status: \"loaded\", data: result }));\n }\n }\n\n const hasSearch = searchKeys.length > 0;\n const hasToolbar = hasSearch || !!actions;\n\n const filtered = useMemo(() => {\n if (!query.trim() || !hasSearch) return data;\n const lower = query.toLowerCase();\n return data.filter((item) =>\n searchKeys.some((k) =>\n String(item[k] ?? \"\")\n .toLowerCase()\n .includes(lower),\n ),\n );\n }, [data, query, searchKeys, hasSearch]);\n\n const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));\n const currentPage = Math.min(page, totalPages);\n const pageData = filtered.slice(\n (currentPage - 1) * pageSize,\n currentPage * pageSize,\n );\n\n function getCell(item: T, col: Column<T>): ReactNode {\n if (col.render) return col.render(item);\n return String((item as Record<string, unknown>)[col.key as string] ?? \"\");\n }\n\n return (\n <Flex direction=\"column\" gap=\"300\" className=\"data-table\">\n {hasToolbar && (\n <div className=\"data-table-toolbar\">\n {hasSearch && (\n <Search\n placeholder={searchPlaceholder}\n onSearch={(v) => {\n setQuery(v);\n setPage(1);\n }}\n className=\"data-table-search\"\n />\n )}\n {actions && <div className=\"data-table-actions\">{actions}</div>}\n </div>\n )}\n\n {isLoading ? (\n <div\n role=\"status\"\n aria-live=\"polite\"\n aria-label={loadingMessage}\n className=\"data-table-status\"\n >\n {loadingMessage}\n </div>\n ) : filtered.length === 0 ? (\n <div role=\"status\" className=\"data-table-status data-table-empty\">\n {emptyMessage}\n </div>\n ) : (\n <TableBase\n selectionMode={selectable ? (selectionType === \"radio\" ? \"single\" : \"multiple\") : \"none\"}\n selectionType={selectionType}\n selectedKeys={selectedKeys}\n onSelectionChange={onSelectionChange}\n >\n <TableHead>\n {hasNested && <TableColumn className=\"data-table-expand-col\" />}\n {columns.map((col, idx) => (\n <TableColumn\n key={String(col.key)}\n align={col.align}\n isRowHeader={idx === 0}\n >\n {col.label}\n </TableColumn>\n ))}\n {hasRowActions && (\n <TableColumn align=\"right\" className=\"data-table-row-actions-col\">\n {rowActionsLabel}\n </TableColumn>\n )}\n </TableHead>\n <TableBody>\n {pageData.flatMap((item) => {\n const isExpanded = expanded.has(item.id);\n const cached = nestedCache.get(item.id);\n const rows: ReactNode[] = [\n <TableRow key={item.id} id={item.id}>\n {hasNested && (\n <TableCell className=\"data-table-expand-cell\">\n <button\n type=\"button\"\n className=\"data-table-expand-btn\"\n aria-label={isExpanded ? \"Collapse row\" : \"Expand row\"}\n aria-expanded={isExpanded}\n onClick={() => toggleRow(item)}\n >\n {isExpanded ? (\n <IconChevronDown size=\"16\" />\n ) : (\n <IconChevronRight size=\"16\" />\n )}\n </button>\n </TableCell>\n )}\n {columns.map((col) => (\n <TableCell key={String(col.key)} align={col.align}>\n {getCell(item, col)}\n </TableCell>\n ))}\n {hasRowActions && (\n <TableCell align=\"right\" className=\"data-table-row-actions-cell\">\n <div className=\"data-table-row-actions\">\n {(typeof rowActions === \"function\"\n ? rowActions(item)\n : rowActions!\n ).map((action) => (\n <RowActionButton key={action.key} action={action} item={item} />\n ))}\n </div>\n </TableCell>\n )}\n </TableRow>,\n ];\n if (isExpanded) {\n rows.push(\n <TableRow key={`${item.id}-nested`} id={`${item.id}-nested`} className=\"data-table-nested-row\">\n <TableCell\n colSpan={\n columns.length +\n (hasNested ? 1 : 0) +\n (selectable ? 1 : 0) +\n (hasRowActions ? 1 : 0)\n }\n className=\"data-table-nested-cell\"\n >\n <DataDrivenTable\n columns={nestedColumns!}\n data={cached?.data ?? []}\n isLoading={!cached || cached.status === \"loading\"}\n loadingMessage={nestedLoadingMessage}\n emptyMessage={nestedEmptyMessage}\n searchKeys={nestedSearchKeys}\n searchPlaceholder={nestedSearchPlaceholder}\n actions={nestedActions?.(item)}\n pageSize={nestedPageSize ?? pageSize}\n />\n </TableCell>\n </TableRow>,\n );\n }\n return rows;\n })}\n </TableBody>\n </TableBase>\n )}\n\n <Pagination\n page={currentPage}\n totalPages={totalPages}\n onPageChange={setPage}\n previousLabel={previousLabel}\n nextLabel={nextLabel}\n />\n </Flex>\n );\n}\n"],"names":["RowActionButton","action","item","allowed","btn","jsx","PermissionGate","DataDrivenTable","columns","data","actions","rowActions","rowActionsLabel","selectable","selectionType","selectedKeys","onSelectionChange","searchPlaceholder","searchKeys","isLoading","loadingMessage","emptyMessage","previousLabel","nextLabel","pageSize","nestedColumns","getNestedData","nestedLoadingMessage","nestedEmptyMessage","nestedSearchKeys","nestedSearchPlaceholder","nestedActions","nestedPageSize","query","setQuery","useState","page","setPage","expanded","setExpanded","nestedCache","setNestedCache","hasNested","hasRowActions","setRowExpanded","id","isExpanded","prev","next","toggleRow","willExpand","result","c","rows","hasSearch","hasToolbar","filtered","useMemo","lower","k","totalPages","currentPage","pageData","getCell","col","Flex","jsxs","Search","v","TableBase","TableHead","TableColumn","idx","TableBody","cached","TableRow","TableCell","IconChevronDown","IconChevronRight","Pagination"],"mappings":"4aAqCA,SAASA,GAAmB,CAC1B,OAAAC,EACA,KAAAC,CACF,EAGG,CACD,MAAMC,EAAUF,EAAO,YAAc,GAC/BG,EACJC,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAU,4BACV,aAAYJ,EAAO,MACnB,SAAU,CAACE,EACX,QAASA,EAAU,IAAMF,EAAO,QAAQC,CAAI,EAAI,OAE/C,SAAAD,EAAO,IAAA,CAAA,EAGZ,OAAIE,EAAgBC,EAElBC,MAACC,GAAAA,gBAAe,UAAW,GAAO,cAAeL,EAAO,eAAiB,GACtE,SAAAG,CAAA,CACH,CAEJ,CAoDO,SAASG,EAA0C,CACxD,QAAAC,EACA,KAAAC,EACA,QAAAC,EACA,WAAAC,EACA,gBAAAC,EAAkB,GAClB,WAAAC,EAAa,GACb,cAAAC,EAAgB,WAChB,aAAAC,EACA,kBAAAC,EACA,kBAAAC,EAAoB,YACpB,WAAAC,EAAa,CAAA,EACb,UAAAC,EAAY,GACZ,eAAAC,EAAiB,aACjB,aAAAC,EAAe,mBACf,cAAAC,EAAgB,WAChB,UAAAC,EAAY,OACZ,SAAAC,EAAW,GACX,cAAAC,EACA,cAAAC,EACA,qBAAAC,EAAuB,aACvB,mBAAAC,EAAqB,mBACrB,iBAAAC,EACA,wBAAAC,EACA,cAAAC,EACA,eAAAC,CACF,EAA4B,CAC1B,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAAS,EAAE,EAC/B,CAACC,EAAMC,CAAO,EAAIF,EAAAA,SAAS,CAA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