@kjun-ui/react 0.19.0 → 0.20.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.
@@ -4,8 +4,17 @@ export interface TableRowGroup<Row extends object> {
4
4
  value: unknown;
5
5
  rows: Row[];
6
6
  }
7
+ export declare const tableGroupKey: (value: unknown) => string;
7
8
  /** Groups keep the order their first row appears in, so a sorted table sorts inside each group. */
8
9
  export declare function groupTableRows<Row extends object>(rows: readonly Row[], groupBy?: string | null): TableRowGroup<Row>[] | null;
10
+ /** undefined uses internal collapsed keys; a supplied array contains the original groupBy values. */
11
+ export declare function tableGroupExpansion<Row extends object>(groups: TableRowGroup<Row>[] | null, expanded: unknown[] | undefined, internalCollapsed: string[]): {
12
+ collapsed: string[];
13
+ toggle(key: string): {
14
+ expanded: unknown[];
15
+ collapsed: string[];
16
+ } | null;
17
+ };
9
18
  /** count counts rows; the other kinds read finite numbers only and give null when a column has none. */
10
19
  export declare function summarizeColumn<Row extends object>(rows: readonly Row[], key: string, kind: TableSummaryKind): number | null;
11
20
  export declare function formatSummary(value: number | null, kind: TableSummaryKind, locale?: string): string;
@@ -85,6 +85,8 @@ export interface TableCardsProps<Row extends object> extends TableRowsProps<Row>
85
85
  totals?: TableTotal[];
86
86
  /** groupBy groups: each one opens with a header line (label, count and, with two or more rows, its subtotals) above its cards. */
87
87
  groups?: TableRowGroup<Row>[] | null;
88
+ collapsed?: string[];
89
+ toggleGroup?: (key: string) => void;
88
90
  groupLabel?: (group: TableRowGroup<Row>) => ReactNode;
89
91
  groupTotals?: (rows: Row[]) => TableTotal[];
90
92
  /** The cell's plain text, for a value read out with its label where the label is not drawn (tile highlight on Native). */
@@ -85,6 +85,8 @@ export interface TableCardsProps<Row extends object> extends TableRowsProps<Row>
85
85
  totals?: TableTotal[];
86
86
  /** groupBy groups: each one opens with a header line (label, count and, with two or more rows, its subtotals) above its cards. */
87
87
  groups?: TableRowGroup<Row>[] | null;
88
+ collapsed?: string[];
89
+ toggleGroup?: (key: string) => void;
88
90
  groupLabel?: (group: TableRowGroup<Row>) => ReactNode;
89
91
  groupTotals?: (rows: Row[]) => TableTotal[];
90
92
  /** The cell's plain text, for a value read out with its label where the label is not drawn (tile highlight on Native). */
@@ -80,6 +80,8 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
80
80
  selected?: Row[];
81
81
  /** Row field (dot path) whose values split the rows into collapsible groups. */
82
82
  groupBy?: string;
83
+ /** Original groupBy values of open groups. undefined: internal state, initially all open; []: all closed. */
84
+ expandedGroups?: unknown[];
83
85
  renderGroupLabel?: (value: unknown, rows: Row[]) => ReactNode;
84
86
  /** Per column key: a subtotal under each group and a total row at the end. */
85
87
  summary?: Partial<Record<string, TableSummaryKind | ((rows: Row[], column: TableColumn<Row>) => ReactNode)>>;
@@ -97,6 +99,7 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
97
99
  }) => void;
98
100
  onSelectionChange?: (selected: Row[]) => void;
99
101
  onExpandedRowsChange?: (keys: (string | number)[]) => void;
102
+ onExpandedGroupsChange?: (values: unknown[]) => void;
100
103
  onPageChange?: (page: number) => void;
101
104
  onRowClick?: (row: Row, index: number) => void;
102
105
  onSearch?: (query: string) => void;
@@ -80,6 +80,8 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
80
80
  selected?: Row[];
81
81
  /** Row field (dot path) whose values split the rows into collapsible groups. */
82
82
  groupBy?: string;
83
+ /** Original groupBy values of open groups. undefined: internal state, initially all open; []: all closed. */
84
+ expandedGroups?: unknown[];
83
85
  renderGroupLabel?: (value: unknown, rows: Row[]) => ReactNode;
84
86
  /** Per column key: a subtotal under each group and a total row at the end. */
85
87
  summary?: Partial<Record<string, TableSummaryKind | ((rows: Row[], column: TableColumn<Row>) => ReactNode)>>;
@@ -97,6 +99,7 @@ export interface TableProps<Row extends object = Record<string, unknown>, MaxHei
97
99
  }) => void;
98
100
  onSelectionChange?: (selected: Row[]) => void;
99
101
  onExpandedRowsChange?: (keys: (string | number)[]) => void;
102
+ onExpandedGroupsChange?: (values: unknown[]) => void;
100
103
  onPageChange?: (page: number) => void;
101
104
  onRowClick?: (row: Row, index: number) => void;
102
105
  onSearch?: (query: string) => void;
@@ -0,0 +1,6 @@
1
+ import { type TableRowGroup } from "./table-groups.cjs";
2
+ /** Shared React/Native state; Vue uses the same framework-free transition rules. */
3
+ export declare function useTableGroupExpansion<Row extends object>(groups: TableRowGroup<Row>[] | null, groupBy: string | undefined, expanded: unknown[] | undefined, onChange: ((values: unknown[]) => void) | undefined): {
4
+ collapsed: string[];
5
+ toggleGroup(key: string): void;
6
+ };
@@ -0,0 +1,6 @@
1
+ import { type TableRowGroup } from "./table-groups.js";
2
+ /** Shared React/Native state; Vue uses the same framework-free transition rules. */
3
+ export declare function useTableGroupExpansion<Row extends object>(groups: TableRowGroup<Row>[] | null, groupBy: string | undefined, expanded: unknown[] | undefined, onChange: ((values: unknown[]) => void) | undefined): {
4
+ collapsed: string[];
5
+ toggleGroup(key: string): void;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kjun-ui/react",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://ui.kjun.dev",
6
6
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@kjun-ui/tokens": "0.19.0",
44
+ "@kjun-ui/tokens": "0.20.0",
45
45
  "react-aria-components": "1.21.1",
46
- "@kjun-ui/icons": "0.19.0"
46
+ "@kjun-ui/icons": "0.20.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": "^19.2.3",