@sito/dashboard 0.0.63 → 0.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -120
- package/dist/components/Button/Button.d.ts +7 -0
- package/dist/components/Button/Button.stories.d.ts +28 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/types.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.stories.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.test.d.ts +1 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/components/Dropdown/types.d.ts +6 -0
- package/dist/components/Form/AutocompleteInput/AutocompleteInput.d.ts +3 -3
- package/dist/components/IconButton/IconButton.d.ts +7 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +29 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/IconButton/types.d.ts +6 -0
- package/dist/components/Table/components/Rows.d.ts +0 -1
- package/dist/components/Table/components/TableSelectionBar.d.ts +18 -0
- package/dist/components/Table/components/TableSelectionBar.test.d.ts +1 -0
- package/dist/components/Table/components/Widgets/types.d.ts +3 -6
- package/dist/components/Table/components/index.d.ts +1 -0
- package/dist/components/Table/hooks/index.d.ts +3 -0
- package/dist/components/Table/hooks/useExpandedRows.d.ts +28 -0
- package/dist/components/Table/hooks/useTableMultiActions.d.ts +20 -0
- package/dist/components/Table/hooks/useTableRowSelection.d.ts +26 -0
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/components/Table/utils.d.ts +8 -0
- package/dist/components/Table/utils.test.d.ts +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/dashboard.cjs +1 -1
- package/dist/dashboard.js +1064 -1857
- package/dist/main.css +1 -1
- package/package.json +26 -19
package/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# @sito/dashboard
|
|
2
2
|
|
|
3
|
-
`@sito/dashboard` is a React + TypeScript UI library
|
|
3
|
+
`@sito/dashboard` is a React + TypeScript UI library for dashboard and admin interfaces.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Highlights
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- Built-in providers for translations and table state management.
|
|
7
|
+
- `Table` component with sorting, filtering, pagination, row selection, bulk actions, and expandable rows.
|
|
8
|
+
- Reusable UI pieces: `Badge`, `Button`, `Chip`, `Dropdown`, `IconButton`, `Loading`, `Tooltip`, and `SvgIcons`.
|
|
9
|
+
- Form controls: `TextInput`, `SelectInput`, `AutocompleteInput`, `CheckInput`, and `FileInput`.
|
|
10
|
+
- Built-in providers for translations and table state (`TranslationProvider`, `TableOptionsProvider`).
|
|
12
11
|
|
|
13
12
|
## Installation
|
|
14
13
|
|
|
@@ -18,22 +17,18 @@ npm install @sito/dashboard
|
|
|
18
17
|
|
|
19
18
|
# yarn
|
|
20
19
|
yarn add @sito/dashboard
|
|
21
|
-
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm add @sito/dashboard
|
|
23
|
+
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### Peer dependency
|
|
26
26
|
|
|
27
27
|
- `react` (`>=18.2 <20`)
|
|
28
|
-
- `@emotion/css` (`11.13.5`)
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
## Quick Usage
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
- `Table` should be wrapped by `TranslationProvider` and `TableOptionsProvider`.
|
|
36
|
-
- `actions` is a callback per row: `(row) => ActionType[]`.
|
|
31
|
+
Import directly from `@sito/dashboard` (do not import from internal paths).
|
|
37
32
|
|
|
38
33
|
```tsx
|
|
39
34
|
import {
|
|
@@ -54,48 +49,7 @@ const rows: UserRow[] = [
|
|
|
54
49
|
{ id: 2, deletedAt: null, name: "Jane Smith", age: 25 },
|
|
55
50
|
];
|
|
56
51
|
|
|
57
|
-
const
|
|
58
|
-
{
|
|
59
|
-
id: "view",
|
|
60
|
-
tooltip: `View ${row.name}`,
|
|
61
|
-
icon: <span>View</span>,
|
|
62
|
-
onClick: () => console.log("View", row),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: "delete",
|
|
66
|
-
tooltip: "Delete selected",
|
|
67
|
-
icon: <span>Delete</span>,
|
|
68
|
-
multiple: true,
|
|
69
|
-
onClick: () => console.log("Delete", row),
|
|
70
|
-
onMultipleClick: (selectedRows: UserRow[]) =>
|
|
71
|
-
console.log("Bulk delete", selectedRows.map(({ name }) => name)),
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
const translations: Record<string, string> = {
|
|
76
|
-
"_accessibility:components.table.selectedCount": "Selected {{count}} items",
|
|
77
|
-
"_accessibility:labels.actions": "Actions",
|
|
78
|
-
"_accessibility:buttons.filters": "Filters",
|
|
79
|
-
"_accessibility:buttons.previous": "Previous page",
|
|
80
|
-
"_accessibility:buttons.next": "Next page",
|
|
81
|
-
"_accessibility:buttons.clear": "Clear",
|
|
82
|
-
"_accessibility:buttons.applyFilters": "Apply filters",
|
|
83
|
-
"_accessibility:components.table.pageSizes": "Rows per page",
|
|
84
|
-
"_accessibility:components.table.jumpToPage": "Jump to page",
|
|
85
|
-
"_accessibility:components.table.of": "of",
|
|
86
|
-
"_accessibility:components.table.empty": "No data available",
|
|
87
|
-
"_accessibility:components.table.selectRow": "Select row",
|
|
88
|
-
"_accessibility:components.table.selectAllRows": "Select all visible rows",
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const t = (key: string, options?: Record<string, unknown>) => {
|
|
92
|
-
if (key === "_accessibility:components.table.selectedCount") {
|
|
93
|
-
const count = typeof options?.count === "number" ? options.count : 0;
|
|
94
|
-
return translations[key].replace("{{count}}", String(count));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return translations[key] ?? key;
|
|
98
|
-
};
|
|
52
|
+
const t = (key: string) => key;
|
|
99
53
|
|
|
100
54
|
export function UsersTable() {
|
|
101
55
|
return (
|
|
@@ -117,11 +71,14 @@ export function UsersTable() {
|
|
|
117
71
|
},
|
|
118
72
|
{ key: "age", label: "Age", sortable: true },
|
|
119
73
|
]}
|
|
120
|
-
actions={
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
74
|
+
actions={(row) => [
|
|
75
|
+
{
|
|
76
|
+
id: "view",
|
|
77
|
+
tooltip: `View ${row.name}`,
|
|
78
|
+
icon: <span>View</span>,
|
|
79
|
+
onClick: () => console.log("View", row),
|
|
80
|
+
},
|
|
81
|
+
]}
|
|
125
82
|
/>
|
|
126
83
|
</TableOptionsProvider>
|
|
127
84
|
</TranslationProvider>
|
|
@@ -129,24 +86,38 @@ export function UsersTable() {
|
|
|
129
86
|
}
|
|
130
87
|
```
|
|
131
88
|
|
|
132
|
-
## Core Table Props
|
|
133
|
-
|
|
134
|
-
| Prop
|
|
135
|
-
|
|
136
|
-
| `entity`
|
|
137
|
-
| `data`
|
|
138
|
-
| `columns`
|
|
139
|
-
| `actions`
|
|
140
|
-
| `title`
|
|
141
|
-
| `toolbar`
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
|
|
149
|
-
|
|
89
|
+
## Core `Table` Props
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Required | Description |
|
|
92
|
+
| --------------------------- | ----------------------------------------------------------------- | -------- | --------------------------------------------------------------------------- |
|
|
93
|
+
| `entity` | `string` | Yes | Entity name used by internal table state. |
|
|
94
|
+
| `data` | `TRow[]` | Yes | Rows to render. `TRow` must extend `BaseDto` and include `id`. |
|
|
95
|
+
| `columns` | `ColumnType<TRow>[]` | No | Column definitions. |
|
|
96
|
+
| `actions` | `(row: TRow) => ActionType<TRow>[]` | No | Per-row action factory. |
|
|
97
|
+
| `title` | `string` | No | Header title. |
|
|
98
|
+
| `toolbar` | `ReactNode` | No | Extra content rendered in the table header. |
|
|
99
|
+
| `isLoading` | `boolean` | No | Loading state for table UI. |
|
|
100
|
+
| `filterOptions` | `FilterOptions` | No | Extra options passed to filter behavior/components. |
|
|
101
|
+
| `onSort` | `(prop: string, sortOrder: SortOrder) => void` | No | Sort callback when a sortable column is toggled. |
|
|
102
|
+
| `onRowSelect` | `(row: TRow, selected: boolean) => void` | No | Row selection callback. |
|
|
103
|
+
| `onSelectedRowsChange` | `(rows: TRow[]) => void` | No | Callback with selected rows. |
|
|
104
|
+
| `softDeleteProperty` | `keyof TRow` | No | Property name used to determine soft-deleted rows. Defaults to `deletedAt`. |
|
|
105
|
+
| `allowMultipleExpandedRows` | `boolean` | No | Enables multiple expanded rows (uncontrolled mode). |
|
|
106
|
+
| `expandedRowId` | `TRow["id"] \| null` | No | Controlled expanded row id. |
|
|
107
|
+
| `onExpandedRowChange` | `(expandedRow: TRow \| null, collapsedRow: TRow \| null) => void` | No | Called when expanded row changes. |
|
|
108
|
+
| `onRowExpand` | `(expandedRow: TRow, collapsedRow: TRow \| null) => ReactNode` | No | Returns content rendered inside expanded row area. |
|
|
109
|
+
| `className` | `string` | No | Wrapper class name. |
|
|
110
|
+
| `contentClassName` | `string` | No | Content container class name. |
|
|
111
|
+
|
|
112
|
+
## Exported API
|
|
113
|
+
|
|
114
|
+
Main package exports include:
|
|
115
|
+
|
|
116
|
+
- Components: `Badge`, `Button`, `Chip`, `Dropdown`, `Form`, `IconButton`, `Loading`, `SvgIcons`, `Table`, `Tooltip`.
|
|
117
|
+
- Providers: `FiltersProvider`, `TableOptionsProvider`, `TranslationProvider` and related hooks/types.
|
|
118
|
+
- Utilities and models: `FilterTypes`, `SortOrder`, `BaseDto`, and query/filter helpers from `lib`.
|
|
119
|
+
|
|
120
|
+
## Development Setup
|
|
150
121
|
|
|
151
122
|
1. Clone the repository.
|
|
152
123
|
|
|
@@ -158,67 +129,45 @@ cd -- -sito-dashboard
|
|
|
158
129
|
2. Use the expected Node version.
|
|
159
130
|
|
|
160
131
|
```bash
|
|
161
|
-
nvm install
|
|
162
|
-
nvm use
|
|
132
|
+
nvm install
|
|
133
|
+
nvm use
|
|
163
134
|
```
|
|
164
135
|
|
|
136
|
+
Current `.nvmrc`: `20.19.0`
|
|
137
|
+
|
|
165
138
|
3. Install dependencies.
|
|
166
139
|
|
|
167
140
|
```bash
|
|
168
141
|
npm install
|
|
169
142
|
```
|
|
170
143
|
|
|
171
|
-
4. Start
|
|
144
|
+
4. Start development.
|
|
172
145
|
|
|
173
146
|
```bash
|
|
174
147
|
# Vite dev server
|
|
175
148
|
npm run dev
|
|
176
149
|
|
|
177
|
-
#
|
|
150
|
+
# Storybook (recommended for component work)
|
|
178
151
|
npm run storybook
|
|
179
152
|
```
|
|
180
153
|
|
|
181
|
-
|
|
154
|
+
## Scripts
|
|
182
155
|
|
|
183
156
|
```bash
|
|
184
|
-
npm run build
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
npm run test
|
|
192
|
-
|
|
193
|
-
# run a specific test file
|
|
194
|
-
npm run test -- src/components/Table/Table.expandable.test.tsx
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## How To Run Linters
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
# runs ESLint with auto-fix enabled in this project
|
|
201
|
-
npm run lint
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Additional Useful Scripts
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
# format source files
|
|
208
|
-
npm run format
|
|
209
|
-
|
|
210
|
-
# build static Storybook
|
|
211
|
-
npm run build-storybook
|
|
212
|
-
|
|
213
|
-
# preview production build
|
|
214
|
-
npm run preview
|
|
157
|
+
npm run build # Build library (types + bundles)
|
|
158
|
+
npm run test # Run tests once with Vitest
|
|
159
|
+
npm run lint # ESLint + Prettier + depcheck
|
|
160
|
+
npm run format # Prettier on src files
|
|
161
|
+
npm run build-storybook # Build static Storybook
|
|
162
|
+
npm run preview # Preview Vite build
|
|
163
|
+
npm run full # lint + build + test
|
|
215
164
|
```
|
|
216
165
|
|
|
217
166
|
## Contributing
|
|
218
167
|
|
|
219
168
|
1. Create a branch from `main`.
|
|
220
|
-
2. Add
|
|
221
|
-
3. Run
|
|
169
|
+
2. Add or update tests for your changes.
|
|
170
|
+
3. Run `npm run full`.
|
|
222
171
|
4. Open a pull request with a clear summary.
|
|
223
172
|
|
|
224
173
|
## License
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: (props: import('..').ButtonPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
args: {
|
|
7
|
+
children: string;
|
|
8
|
+
};
|
|
9
|
+
argTypes: {
|
|
10
|
+
variant: {
|
|
11
|
+
control: {
|
|
12
|
+
type: "select";
|
|
13
|
+
};
|
|
14
|
+
options: string[];
|
|
15
|
+
};
|
|
16
|
+
color: {
|
|
17
|
+
control: {
|
|
18
|
+
type: "select";
|
|
19
|
+
};
|
|
20
|
+
options: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
26
|
+
export declare const Text: Story;
|
|
27
|
+
export declare const Outlined: Story;
|
|
28
|
+
export declare const Submit: Story;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export type ButtonBaseProps = {
|
|
3
|
+
variant?: "text" | "submit" | "outlined";
|
|
4
|
+
color?: "default" | "primary" | "secondary" | "error" | "warning" | "success" | "info";
|
|
5
|
+
};
|
|
6
|
+
export interface ButtonPropsType extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "color">, ButtonBaseProps {
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Dropdown } from '..';
|
|
3
|
+
declare const meta: Meta<typeof Dropdown>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Dropdown>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const ActionDropdown: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutocompleteInputPropsType } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param props
|
|
5
|
-
* @
|
|
3
|
+
* Text input with autocomplete suggestions, supporting single and multiple selection.
|
|
4
|
+
* @param props - Component props
|
|
5
|
+
* @param ref - Forwarded ref to the underlying input element
|
|
6
6
|
*/
|
|
7
7
|
export declare const AutocompleteInput: import('react').ForwardRefExoticComponent<Omit<AutocompleteInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IconButtonPropsType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders the IconButton component.
|
|
4
|
+
* @param props - props parameter.
|
|
5
|
+
* @returns Function result.
|
|
6
|
+
*/
|
|
7
|
+
export declare const IconButton: (props: IconButtonPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: (props: import('..').IconButtonPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
args: {
|
|
7
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
argTypes: {
|
|
10
|
+
variant: {
|
|
11
|
+
control: {
|
|
12
|
+
type: "select";
|
|
13
|
+
};
|
|
14
|
+
options: string[];
|
|
15
|
+
};
|
|
16
|
+
color: {
|
|
17
|
+
control: {
|
|
18
|
+
type: "select";
|
|
19
|
+
};
|
|
20
|
+
options: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
26
|
+
export declare const Default: Story;
|
|
27
|
+
export declare const WithFilters: Story;
|
|
28
|
+
export declare const WithChevron: Story;
|
|
29
|
+
export declare const ErrorOnHover: Story;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ButtonBaseProps } from '../Button/types';
|
|
3
|
+
export interface IconButtonPropsType extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "color">, ButtonBaseProps {
|
|
4
|
+
icon: ReactNode;
|
|
5
|
+
iconClassName?: string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseDto } from '../../../lib';
|
|
2
|
+
import { ActionType } from '../types';
|
|
3
|
+
type TableSelectionBarProps<TRow extends BaseDto> = {
|
|
4
|
+
count: number;
|
|
5
|
+
multiActions: ActionType<TRow>[];
|
|
6
|
+
onActionClick: (action: ActionType<TRow>) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Renders the selection bar shown when one or more table rows are selected.
|
|
10
|
+
* Displays the count of selected rows and optional bulk action buttons.
|
|
11
|
+
* @param root0 - Component props.
|
|
12
|
+
* @param root0.count - Number of currently selected rows.
|
|
13
|
+
* @param root0.multiActions - List of actions available for the selected rows.
|
|
14
|
+
* @param root0.onActionClick - Callback invoked when a bulk action button is clicked.
|
|
15
|
+
* @returns Selection bar element.
|
|
16
|
+
*/
|
|
17
|
+
export declare function TableSelectionBar<TRow extends BaseDto>({ count, multiActions, onActionClick, }: TableSelectionBarProps<TRow>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { AutocompleteFilterType, CheckFilterType, RangeFilterType, SelectFilterType, TextFilterType } from '../../../../lib';
|
|
2
2
|
import { HTMLInputTypeAttribute } from 'react';
|
|
3
|
-
export
|
|
4
|
-
}
|
|
3
|
+
export type SelectWidgetPropsType = SelectFilterType;
|
|
5
4
|
export interface RangeWidgetPropsType<T> extends RangeFilterType<T> {
|
|
6
5
|
inputType: HTMLInputTypeAttribute;
|
|
7
6
|
}
|
|
8
7
|
export interface AutocompleteWidgetPropsType extends AutocompleteFilterType {
|
|
9
8
|
multiple?: boolean;
|
|
10
9
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
export interface TextWidgetPropsType extends TextFilterType {
|
|
14
|
-
}
|
|
10
|
+
export type CheckWidgetPropsType = CheckFilterType;
|
|
11
|
+
export type TextWidgetPropsType = TextFilterType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseDto } from '../../../lib';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ExpandedRowStateType } from '../components/types';
|
|
4
|
+
interface UseExpandedRowsParams<TRow extends BaseDto> {
|
|
5
|
+
data: TRow[];
|
|
6
|
+
allowMultipleExpandedRows: boolean;
|
|
7
|
+
controlledExpandedRowId: TRow["id"] | null | undefined;
|
|
8
|
+
onExpandedRowChange?: (expandedRow: TRow | null, collapsedRow: TRow | null) => void;
|
|
9
|
+
onRowExpand?: (expandedRow: TRow, collapsedRow: TRow | null) => ReactNode;
|
|
10
|
+
findRowById: (rowId: TRow["id"] | null) => TRow | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Manages expand/collapse state and CSS transition animations for table rows.
|
|
14
|
+
* Supports both single and multiple expanded rows, as well as controlled mode via `controlledExpandedRowId`.
|
|
15
|
+
* @param root0 - Hook parameters.
|
|
16
|
+
* @param root0.data - Array of row data; used to clean up expanded state when rows are removed.
|
|
17
|
+
* @param root0.allowMultipleExpandedRows - When true, multiple rows can be expanded simultaneously.
|
|
18
|
+
* @param root0.controlledExpandedRowId - When provided, the expanded row is controlled externally.
|
|
19
|
+
* @param root0.onExpandedRowChange - Optional callback fired when a row is expanded or collapsed.
|
|
20
|
+
* @param root0.onRowExpand - Callback that returns the content to render inside an expanded row.
|
|
21
|
+
* @param root0.findRowById - Helper to look up a row by its id.
|
|
22
|
+
* @returns expandedRowsToRender — list of rows currently rendered with animation state, and onRowExpandChange — click handler for row expansion.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useExpandedRows<TRow extends BaseDto>({ data, allowMultipleExpandedRows, controlledExpandedRowId, onExpandedRowChange, onRowExpand, findRowById, }: UseExpandedRowsParams<TRow>): {
|
|
25
|
+
expandedRowsToRender: ExpandedRowStateType<TRow>[];
|
|
26
|
+
onRowExpandChange: (row: TRow) => void;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseDto } from '../../../lib';
|
|
2
|
+
import { ActionType } from '../types';
|
|
3
|
+
interface UseTableMultiActionsParams<TRow extends BaseDto> {
|
|
4
|
+
actions?: (row: TRow) => ActionType<TRow>[];
|
|
5
|
+
selectedRowsData: TRow[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Computes the set of bulk actions shared across all selected rows and provides a click handler.
|
|
9
|
+
* An action is included only if it is present (and not hidden) on every selected row; the `disabled`
|
|
10
|
+
* flag is set if any row marks the action as disabled.
|
|
11
|
+
* @param root0 - Hook parameters.
|
|
12
|
+
* @param root0.actions - Function that returns the action list for a given row.
|
|
13
|
+
* @param root0.selectedRowsData - Array of currently selected row objects.
|
|
14
|
+
* @returns multiActions — filtered shared actions, and handleMultipleActionClick — handler that calls `onMultipleClick` or iterates over selected rows.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTableMultiActions<TRow extends BaseDto>({ actions, selectedRowsData, }: UseTableMultiActionsParams<TRow>): {
|
|
17
|
+
multiActions: ActionType<TRow>[];
|
|
18
|
+
handleMultipleActionClick: (action: ActionType<TRow>) => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseDto } from '../../../lib';
|
|
2
|
+
interface UseTableRowSelectionParams<TRow extends BaseDto> {
|
|
3
|
+
data: TRow[];
|
|
4
|
+
onRowSelect?: (row: TRow, selected: boolean) => void;
|
|
5
|
+
onSelectedRowsChange?: (rows: TRow[]) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages row selection state for the Table component.
|
|
9
|
+
* Handles individual row toggling, select-all, and keeps selection in sync when data changes.
|
|
10
|
+
* @param root0 - Hook parameters.
|
|
11
|
+
* @param root0.data - Array of row data; used to sync selection when rows are added or removed.
|
|
12
|
+
* @param root0.onRowSelect - Optional callback fired when a single row is selected or deselected.
|
|
13
|
+
* @param root0.onSelectedRowsChange - Optional callback fired with the full array of selected rows whenever selection changes.
|
|
14
|
+
* @returns Selection state and handlers: selectedRows, selectedRowsData, selectionState, onRowSelectionChange, onToggleAllRows.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTableRowSelection<TRow extends BaseDto>({ data, onRowSelect, onSelectedRowsChange, }: UseTableRowSelectionParams<TRow>): {
|
|
17
|
+
selectedRows: Set<TRow["id"]>;
|
|
18
|
+
selectedRowsData: TRow[];
|
|
19
|
+
selectionState: {
|
|
20
|
+
allSelected: boolean;
|
|
21
|
+
hasSomeSelected: boolean;
|
|
22
|
+
};
|
|
23
|
+
onRowSelectionChange: (row: TRow) => void;
|
|
24
|
+
onToggleAllRows: () => void;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseDto } from '../../lib';
|
|
2
|
+
import { ColumnType } from './components/types';
|
|
3
|
+
/**
|
|
4
|
+
* Returns columns sorted by position (descending) with hidden columns filtered out.
|
|
5
|
+
* @param columns - Array of column definitions to sort and filter.
|
|
6
|
+
* @returns Sorted and filtered array of visible columns.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSortedVisibleColumns<TRow extends BaseDto>(columns: ColumnType<TRow>[]): ColumnType<TRow>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|