@kayord/ui 4.0.0 → 4.0.1
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.
|
@@ -5,7 +5,7 @@ export type ControlledState = Partial<TableState<DataTableFeatures>>;
|
|
|
5
5
|
export type ShadTableOptions<TData extends RowData> = BaseOptions<TData> & {
|
|
6
6
|
enableRowSelectionUI?: boolean;
|
|
7
7
|
controlledState?: ControlledState;
|
|
8
|
-
resetPageIndexOn?: Array<keyof ControlledState
|
|
8
|
+
resetPageIndexOn?: Array<keyof ControlledState> | undefined;
|
|
9
9
|
};
|
|
10
10
|
export declare function createShadTable<TData extends RowData>(shadOptions: ShadTableOptions<TData>): Table<DataTableFeatures, TData>;
|
|
11
11
|
export { features };
|
|
@@ -3,15 +3,18 @@ import DataTableCheckbox from "./DataTableCheckbox.svelte";
|
|
|
3
3
|
import { renderComponent } from "../../ui/data-table";
|
|
4
4
|
import { features } from "./features";
|
|
5
5
|
export function createShadTable(shadOptions) {
|
|
6
|
-
const { enableRowSelectionUI = true, controlledState, resetPageIndexOn
|
|
6
|
+
const { enableRowSelectionUI = true, controlledState, resetPageIndexOn, ...rest } = shadOptions;
|
|
7
7
|
const externalHandlers = {};
|
|
8
8
|
if (controlledState) {
|
|
9
|
+
// Default: reset the page index on any controlled state change.
|
|
10
|
+
const resetKeys = resetPageIndexOn ?? Object.keys(controlledState);
|
|
9
11
|
for (const key of Object.keys(controlledState)) {
|
|
10
|
-
const resetPage =
|
|
12
|
+
const resetPage = resetKeys.includes(key);
|
|
11
13
|
externalHandlers[`on${key.charAt(0).toUpperCase()}${key.slice(1)}Change`] = (updater) => {
|
|
12
14
|
const record = controlledState;
|
|
13
15
|
record[key] = functionalUpdate(updater, record[key]);
|
|
14
|
-
|
|
16
|
+
// Never reset the page because the page itself changed.
|
|
17
|
+
if (resetPage && key !== "pagination" && controlledState.pagination) {
|
|
15
18
|
controlledState.pagination = { ...controlledState.pagination, pageIndex: 0 };
|
|
16
19
|
}
|
|
17
20
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kayord/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/kayordDX/ui.git"
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"layerchart": "^2.2.0",
|
|
141
141
|
"mode-watcher": "^1.1.0",
|
|
142
142
|
"paneforge": "^1.0.2",
|
|
143
|
-
"playwright": "^1.
|
|
143
|
+
"playwright": "^1.62.1",
|
|
144
144
|
"prettier": "^3.9.6",
|
|
145
145
|
"prettier-plugin-svelte": "4.1.1",
|
|
146
146
|
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"shadcn-svelte": "^1.5.0",
|
|
149
149
|
"svelte": "^5.56.9",
|
|
150
150
|
"svelte-check": "^4.7.6",
|
|
151
|
-
"svelte-sonner": "^1.
|
|
151
|
+
"svelte-sonner": "^1.2.1",
|
|
152
152
|
"sveltekit-superforms": "^2.30.2",
|
|
153
153
|
"tailwindcss": "^4.3.3",
|
|
154
154
|
"tslib": "^2.8.1",
|