@apipass/design-system 5.7.0 → 5.9.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 (46) hide show
  1. package/dist/lib/embedded-styles.js +2 -2
  2. package/dist/lib/lib.index.cjs +1 -1
  3. package/dist/lib/lib.index.js +670 -669
  4. package/dist/lib/lib.index.js.map +1 -1
  5. package/dist/lib/style.css +1 -1
  6. package/dist/lib/ui/components/DataTable/DataTable.cjs +1 -1
  7. package/dist/lib/ui/components/DataTable/DataTable.cjs.map +1 -1
  8. package/dist/lib/ui/components/DataTable/DataTable.js +3 -184
  9. package/dist/lib/ui/components/DataTable/DataTable.js.map +1 -1
  10. package/dist/lib/ui/primitives/Accordion/Accordion.cjs +1 -1
  11. package/dist/lib/ui/primitives/Accordion/Accordion.cjs.map +1 -1
  12. package/dist/lib/ui/primitives/Accordion/Accordion.js +26 -20
  13. package/dist/lib/ui/primitives/Accordion/Accordion.js.map +1 -1
  14. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs +1 -1
  15. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs.map +1 -1
  16. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js +43 -42
  17. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js.map +1 -1
  18. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs +1 -1
  19. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs.map +1 -1
  20. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js +33 -26
  21. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js.map +1 -1
  22. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs +1 -1
  23. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs.map +1 -1
  24. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js +36 -31
  25. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js.map +1 -1
  26. package/dist/lib/ui/primitives/Table/DataDrivenTable.cjs +2 -0
  27. package/dist/lib/ui/primitives/Table/DataDrivenTable.cjs.map +1 -0
  28. package/dist/lib/ui/primitives/Table/DataDrivenTable.js +196 -0
  29. package/dist/lib/ui/primitives/Table/DataDrivenTable.js.map +1 -0
  30. package/dist/lib/ui/primitives/Table/Table.cjs +1 -1
  31. package/dist/lib/ui/primitives/Table/Table.cjs.map +1 -1
  32. package/dist/lib/ui/primitives/Table/Table.js +12 -123
  33. package/dist/lib/ui/primitives/Table/Table.js.map +1 -1
  34. package/dist/lib/ui/primitives/Table/TableBase.cjs +2 -0
  35. package/dist/lib/ui/primitives/Table/TableBase.cjs.map +1 -0
  36. package/dist/lib/ui/primitives/Table/TableBase.js +127 -0
  37. package/dist/lib/ui/primitives/Table/TableBase.js.map +1 -0
  38. package/dist/types/ui/components/DataTable/DataTable.d.ts +11 -66
  39. package/dist/types/ui/primitives/Accordion/Accordion.d.ts +4 -1
  40. package/dist/types/ui/primitives/JsonViewer/JsonEditor.d.ts +3 -3
  41. package/dist/types/ui/primitives/JsonViewer/JsonViewer.d.ts +3 -3
  42. package/dist/types/ui/primitives/JsonViewer/json-code-mirror.d.ts +7 -0
  43. package/dist/types/ui/primitives/Table/DataDrivenTable.d.ts +68 -0
  44. package/dist/types/ui/primitives/Table/Table.d.ts +22 -32
  45. package/dist/types/ui/primitives/Table/TableBase.d.ts +35 -0
  46. package/package.json +1 -1
@@ -0,0 +1,127 @@
1
+ import { jsx as e, jsxs as b, Fragment as v } from "react/jsx-runtime";
2
+ import { clsx as o } from "../../../vendor/clsx/dist/clsx.js";
3
+ import { useContext as N, createContext as k } from "react";
4
+ import { TableBody as B, Cell as $, Column as w, useTableOptions as f, TableHeader as R, Checkbox as g, Collection as p, Row as U, Button as j, Table 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 = k("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: a = !1,
20
+ selectionType: c = "checkbox",
21
+ maxHeight: n,
22
+ className: m,
23
+ ...i
24
+ }) {
25
+ const r = n !== void 0, x = o(
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 = o(
31
+ "sds-table",
32
+ l && "table-bleed",
33
+ t && "table-dense",
34
+ s && "table-grid",
35
+ a && "sds-table-striped"
36
+ );
37
+ return /* @__PURE__ */ e("div", { className: x, style: T, children: /* @__PURE__ */ e(d.Provider, { value: c, children: /* @__PURE__ */ e(D, { className: y, ...i }) }) });
38
+ }
39
+ function h({
40
+ align: l = "start",
41
+ className: t,
42
+ ...s
43
+ }) {
44
+ const a = o(t, "table-column", `table-align-${l}`);
45
+ return /* @__PURE__ */ e(w, { className: a, ...s, children: ({ allowsSorting: c, sortDirection: n }) => /* @__PURE__ */ e("div", { className: o("table-column-inner"), children: /* @__PURE__ */ b(v, { children: [
46
+ s.children,
47
+ c && /* @__PURE__ */ e(
48
+ "span",
49
+ {
50
+ "aria-hidden": "true",
51
+ className: o(
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
+ ...a
71
+ }) {
72
+ const { selectionBehavior: c, selectionMode: n, allowsDragging: m } = f(), i = N(d), r = o(l, "table-head");
73
+ return /* @__PURE__ */ b(R, { className: r, ...a, children: [
74
+ m && /* @__PURE__ */ e(h, {}),
75
+ c === "toggle" && /* @__PURE__ */ e(
76
+ h,
77
+ {
78
+ className: o(
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: a,
93
+ ...c
94
+ }) {
95
+ const { selectionBehavior: n, allowsDragging: m } = f(), i = N(d), r = o(a, "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: o(
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 a = o(t, "table-cell", `table-align-${l}`);
117
+ return /* @__PURE__ */ e($, { className: a, ...s });
118
+ }
119
+ export {
120
+ G as TableBase,
121
+ J as TableBody,
122
+ u as TableCell,
123
+ h as TableColumn,
124
+ K as TableHead,
125
+ Q as TableRow
126
+ };
127
+ //# sourceMappingURL=TableBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableBase.js","sources":["../../../../../src/ui/primitives/Table/TableBase.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 TableBaseProps = RACTableProps & {\n bleed?: boolean;\n dense?: boolean;\n grid?: boolean;\n striped?: boolean;\n selectionType?: SelectionType;\n maxHeight?: number | string;\n};\nexport function TableBase({\n bleed = false,\n dense = false,\n grid = false,\n striped = false,\n selectionType = \"checkbox\",\n maxHeight,\n className,\n ...props\n}: TableBaseProps) {\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","TableBase","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,CAA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,gBAAAE,EAAA,IAAmBC,EAAA,GACxC7B,IAAgB8B,EAAWxC,CAAoB,GAC/CsB,IAAaN,EAAKJ,GAAW,WAAW;AAC9C,2BACGoC,GAAA,EAAO,IAAAF,GAAS,GAAGC,GAAY,WAAWzB,GACxC,UAAA;AAAA,IAAAgB,uBACEW,GAAA,EACC,UAAA,gBAAAvB,EAACwB,KAAU,MAAK,QAAO,eAAC,EAAA,CAC1B;AAAA,IAEDd,MAAsB,YACrB,gBAAAV;AAAA,MAACuB;AAAA,MAAA;AAAA,QACC,WAAWjC;AAAA,UACT;AAAA,UACAN,MAAkB,WAAW;AAAA,QAAA;AAAA,QAG/B,UAAA,gBAAAgB,EAACgB,GAAA,EAAqB,MAAK,aAAY,WAAU,4BAC9C,UAAAhC,MAAkB,UAAU,gBAAAgB,EAACyB,GAAA,CAAA,CAAM,IAAK,gBAAAzB,EAACiB,KAAS,EAAA,CACrD;AAAA,MAAA;AAAA,IAAA;AAAA,IAGJ,gBAAAjB,EAACkB,GAAA,EAAc,OAAOV,GAAU,UAAAC,EAAA,CAAS;AAAA,EAAA,GAC3C;AAEJ;AAGO,SAASc,EAAU;AAAA,EACxB,OAAA5B,IAAQ;AAAA,EACR,WAAAT;AAAA,EACA,GAAGC;AACL,GAAmB;AACjB,QAAMS,IAAaN,EAAKJ,GAAW,cAAc,eAAeS,CAAK,EAAE;AACvE,SAAO,gBAAAK,EAAC0B,GAAA,EAAQ,WAAW9B,GAAa,GAAGT,GAAO;AACpD;"}
@@ -1,69 +1,14 @@
1
- import type { ReactNode } from "react";
2
- import type { Selection } from "react-aria-components";
1
+ import { Table, type DataDrivenTableProps } from "primitives";
3
2
  import "./datatable.css";
4
- export interface Column<T> {
5
- key: keyof T | string;
6
- label: string;
7
- align?: "start" | "center" | "right";
8
- render?: (item: T) => ReactNode;
9
- }
10
- export interface RowActionDef<T> {
11
- /** Unique key for this action. */
12
- key: string;
13
- /** aria-label for the button. */
14
- label: string;
15
- /** Icon element rendered inside the button. */
16
- icon: ReactNode;
17
- /** When false, button is disabled and a tooltip with `noAccessLabel` is shown. Default: true. */
18
- isAllowed?: boolean;
19
- /** Tooltip text shown when `isAllowed` is false. */
20
- noAccessLabel?: string;
21
- /** Called with the row item when the button is pressed. */
22
- onPress: (item: T) => void;
23
- }
24
- export interface DataTableProps<T extends {
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 {
25
9
  id: string;
26
- }> {
27
- columns: Column<T>[];
28
- data: T[];
29
- actions?: ReactNode;
30
- /** Per-row action buttons rendered in a dedicated last column. */
31
- rowActions?: RowActionDef<T>[] | ((item: T) => RowActionDef<T>[]);
32
- /** Label for the row actions column header. Defaults to empty string. */
33
- rowActionsLabel?: string;
34
- /**
35
- * When true, renders a selection column before the first data column — a per-row control on
36
- * every row (see `selectionType`), plus a "select all" checkbox in the header when
37
- * `selectionType` is "checkbox". Off by default.
38
- */
39
- selectable?: boolean;
40
- /**
41
- * Visual style of the built-in selection control. "checkbox" (default) allows selecting
42
- * multiple rows and shows a "select all" in the header. "radio" restricts selection to a
43
- * single row (no "select all" — there is nothing to select all *to* with one choice) and
44
- * renders a round control instead of a checkbox.
45
- */
46
- selectionType?: "checkbox" | "radio";
47
- /** Controlled selection state. Omit to let the table manage its own selection internally. */
48
- selectedKeys?: Selection;
49
- onSelectionChange?: (keys: Selection) => void;
50
- searchPlaceholder?: string;
51
- searchKeys?: (keyof T)[];
52
- isLoading?: boolean;
53
- loadingMessage?: string;
54
- emptyMessage?: string;
55
- previousLabel?: string;
56
- nextLabel?: string;
57
- pageSize?: number;
58
- nestedColumns?: Column<any>[];
59
- getNestedData?: (item: T) => any[] | Promise<any[]>;
60
- nestedLoadingMessage?: string;
61
- nestedEmptyMessage?: string;
62
- nestedSearchKeys?: (keyof any)[];
63
- nestedSearchPlaceholder?: string;
64
- nestedActions?: (item: T) => ReactNode;
65
- nestedPageSize?: number;
66
- }
67
- export declare function DataTable<T extends {
10
+ }>(props: DataDrivenTableProps<T>) => ReturnType<typeof Table>;
11
+ /** @deprecated Use `DataDrivenTableProps`. */
12
+ export type DataTableProps<T extends {
68
13
  id: string;
69
- }>({ 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, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
14
+ }> = DataDrivenTableProps<T>;
@@ -1,8 +1,11 @@
1
+ import type { ReactNode } from "react";
1
2
  import { type DisclosureGroupProps, type DisclosureProps } from "react-aria-components";
2
3
  import "./accordion.css";
3
4
  export type AccordionProps = DisclosureGroupProps;
4
5
  export declare function Accordion({ className, ...props }: AccordionProps): import("react/jsx-runtime").JSX.Element;
5
6
  export type AccordionItemProps = DisclosureProps & {
6
7
  title: string;
8
+ subtitle?: ReactNode;
9
+ badge?: ReactNode;
7
10
  };
8
- export declare function AccordionItem({ className, title, isExpanded, isDisabled, children, ...props }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function AccordionItem({ className, title, subtitle, badge, isExpanded, isDisabled, children, ...props }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
+ import type { JsonEditorSize } from "./json-code-mirror";
1
2
  import "./jsonviewer.css";
2
- export interface JsonEditorProps {
3
+ export interface JsonEditorProps extends JsonEditorSize {
3
4
  value: string;
4
5
  onChange?: (value: string) => void;
5
6
  expandAllLabel: string;
6
7
  className?: string;
7
- height?: string | number;
8
8
  isDisabled?: boolean;
9
9
  isReadOnly?: boolean;
10
10
  "aria-label"?: string;
@@ -15,4 +15,4 @@ export interface JsonEditorProps {
15
15
  * `JsonViewer` stays read-only-only on purpose so its bundle keeps assuming
16
16
  * a static document; this component owns the editable/controlled behavior.
17
17
  */
18
- export declare function JsonEditor({ value, onChange, expandAllLabel, className, height, isDisabled, isReadOnly, "aria-label": ariaLabel, }: JsonEditorProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function JsonEditor({ value, onChange, expandAllLabel, className, height, minHeight, maxHeight, isDisabled, isReadOnly, "aria-label": ariaLabel, }: JsonEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { JsonEditorSize } from "./json-code-mirror";
2
3
  import "./jsonviewer.css";
3
4
  export interface JsonViewerAction {
4
5
  key: string;
@@ -6,11 +7,10 @@ export interface JsonViewerAction {
6
7
  icon: ReactNode;
7
8
  onPress: () => void;
8
9
  }
9
- export interface JsonViewerProps {
10
+ export interface JsonViewerProps extends JsonEditorSize {
10
11
  value: unknown;
11
12
  expandAllLabel: string;
12
13
  actions?: JsonViewerAction[];
13
14
  className?: string;
14
- height?: string | number;
15
15
  }
16
- export declare function JsonViewer({ value, expandAllLabel, actions, className, height }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function JsonViewer({ value, expandAllLabel, actions, className, height, minHeight, maxHeight, }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,16 @@
1
+ import type { CSSProperties } from "react";
1
2
  import { HighlightStyle } from "@codemirror/language";
2
3
  export declare const jsonHighlightStyle: HighlightStyle;
3
4
  export declare const jsonEditorTheme: import("@codemirror/state").Extension;
4
5
  export declare const jsonEditorExtensions: import("@codemirror/state").Extension[];
5
6
  export declare function serializeJson(value: unknown): string;
6
7
  export declare function toCssSize(size: string | number): string;
8
+ export interface JsonEditorSize {
9
+ height?: string | number;
10
+ minHeight?: string | number;
11
+ maxHeight?: string | number;
12
+ }
13
+ export declare function toEditorSizeStyle({ height, minHeight, maxHeight }: JsonEditorSize): CSSProperties;
7
14
  /**
8
15
  * Finds the fold range of every direct child (depth 1) of the root object/array
9
16
  * by scanning the text itself for matching brackets. This mirrors what
@@ -0,0 +1,68 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Selection } from "react-aria-components";
3
+ export interface Column<T> {
4
+ key: keyof T | string;
5
+ label: string;
6
+ align?: "start" | "center" | "right";
7
+ render?: (item: T) => ReactNode;
8
+ }
9
+ export interface RowActionDef<T> {
10
+ /** Unique key for this action. */
11
+ key: string;
12
+ /** aria-label for the button. */
13
+ label: string;
14
+ /** Icon element rendered inside the button. */
15
+ icon: ReactNode;
16
+ /** When false, button is disabled and a tooltip with `noAccessLabel` is shown. Default: true. */
17
+ isAllowed?: boolean;
18
+ /** Tooltip text shown when `isAllowed` is false. */
19
+ noAccessLabel?: string;
20
+ /** Called with the row item when the button is pressed. */
21
+ onPress: (item: T) => void;
22
+ }
23
+ export interface DataDrivenTableProps<T extends {
24
+ id: string;
25
+ }> {
26
+ columns: Column<T>[];
27
+ data: T[];
28
+ actions?: ReactNode;
29
+ /** Per-row action buttons rendered in a dedicated last column. */
30
+ rowActions?: RowActionDef<T>[] | ((item: T) => RowActionDef<T>[]);
31
+ /** Label for the row actions column header. Defaults to empty string. */
32
+ rowActionsLabel?: string;
33
+ /**
34
+ * When true, renders a selection column before the first data column — a per-row control on
35
+ * every row (see `selectionType`), plus a "select all" checkbox in the header when
36
+ * `selectionType` is "checkbox". Off by default.
37
+ */
38
+ selectable?: boolean;
39
+ /**
40
+ * Visual style of the built-in selection control. "checkbox" (default) allows selecting
41
+ * multiple rows and shows a "select all" in the header. "radio" restricts selection to a
42
+ * single row (no "select all" — there is nothing to select all *to* with one choice) and
43
+ * renders a round control instead of a checkbox.
44
+ */
45
+ selectionType?: "checkbox" | "radio";
46
+ /** Controlled selection state. Omit to let the table manage its own selection internally. */
47
+ selectedKeys?: Selection;
48
+ onSelectionChange?: (keys: Selection) => void;
49
+ searchPlaceholder?: string;
50
+ searchKeys?: (keyof T)[];
51
+ isLoading?: boolean;
52
+ loadingMessage?: string;
53
+ emptyMessage?: string;
54
+ previousLabel?: string;
55
+ nextLabel?: string;
56
+ pageSize?: number;
57
+ nestedColumns?: Column<any>[];
58
+ getNestedData?: (item: T) => any[] | Promise<any[]>;
59
+ nestedLoadingMessage?: string;
60
+ nestedEmptyMessage?: string;
61
+ nestedSearchKeys?: (keyof any)[];
62
+ nestedSearchPlaceholder?: string;
63
+ nestedActions?: (item: T) => ReactNode;
64
+ nestedPageSize?: number;
65
+ }
66
+ export declare function DataDrivenTable<T extends {
67
+ id: string;
68
+ }>({ 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, }: DataDrivenTableProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +1,25 @@
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";
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";
4
5
  /**
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).
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.
10
9
  */
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;
10
+ export type TableProps = TableBaseProps & {
11
+ columns?: never;
19
12
  };
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 {};
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>;
@@ -0,0 +1,35 @@
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";
4
+ /**
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).
10
+ */
11
+ type SelectionType = "checkbox" | "radio";
12
+ export type TableBaseProps = RACTableProps & {
13
+ bleed?: boolean;
14
+ dense?: boolean;
15
+ grid?: boolean;
16
+ striped?: boolean;
17
+ selectionType?: SelectionType;
18
+ maxHeight?: number | string;
19
+ };
20
+ export declare function TableBase({ bleed, dense, grid, striped, selectionType, maxHeight, className, ...props }: TableBaseProps): 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.7.0",
3
+ "version": "5.9.0",
4
4
  "type": "module",
5
5
  "description": "APIPass React Design System",
6
6
  "sideEffects": [