@pallasoft/ps-table-components 1.20.0 → 1.22.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.
- package/dist/components/ps-data-table.d.ts +5 -1
- package/dist/components/ps-data-table.js +80 -12
- package/dist/components/ps-table-pagination.d.ts +2 -1
- package/dist/components/ps-table-pagination.js +4 -2
- package/dist/components/ps-table-reorder-frame.d.ts +8 -0
- package/dist/components/ps-table-reorder-frame.js +30 -0
- package/dist/components/ps-table-reorder-handle.d.ts +6 -0
- package/dist/components/ps-table-reorder-handle.js +8 -0
- package/dist/components/ps-table-searching-state.d.ts +6 -0
- package/dist/components/ps-table-searching-state.js +7 -0
- package/dist/components/ps-table-sortable-row.d.ts +9 -0
- package/dist/components/ps-table-sortable-row.js +22 -0
- package/dist/constants/table-config.d.ts +2 -0
- package/dist/constants/table-config.js +2 -0
- package/dist/esm/components/ps-data-table.js +49 -14
- package/dist/esm/components/ps-table-pagination.js +4 -2
- package/dist/esm/components/ps-table-reorder-frame.js +26 -0
- package/dist/esm/components/ps-table-reorder-handle.js +4 -0
- package/dist/esm/components/ps-table-searching-state.js +3 -0
- package/dist/esm/components/ps-table-sortable-row.js +18 -0
- package/dist/esm/constants/table-config.js +2 -0
- package/dist/esm/hooks/use-ps-table-page.js +5 -0
- package/dist/esm/hooks/use-ps-table-reorder.js +63 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/interfaces/ps-table-page-state.js +1 -0
- package/dist/esm/interfaces/table-reorder-announcements.js +1 -0
- package/dist/esm/interfaces/table-reorder-api.js +1 -0
- package/dist/esm/interfaces/table-reorder-item.js +1 -0
- package/dist/esm/interfaces/table-reorder-placement.js +1 -0
- package/dist/esm/interfaces/table-reorder-row-props.js +1 -0
- package/dist/esm/interfaces/table-reorder-run.js +1 -0
- package/dist/esm/interfaces/table-reorder.js +1 -0
- package/dist/esm/interfaces/table-row-entry.js +1 -0
- package/dist/esm/services/ps-table-reorder-service.js +42 -0
- package/dist/hooks/use-ps-table-page.d.ts +2 -0
- package/dist/hooks/use-ps-table-page.js +9 -0
- package/dist/hooks/use-ps-table-reorder.d.ts +18 -0
- package/dist/hooks/use-ps-table-reorder.js +67 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/interfaces/ps-table-page-state.d.ts +4 -0
- package/dist/interfaces/ps-table-page-state.js +2 -0
- package/dist/interfaces/table-reorder-announcements.d.ts +6 -0
- package/dist/interfaces/table-reorder-announcements.js +2 -0
- package/dist/interfaces/table-reorder-api.d.ts +8 -0
- package/dist/interfaces/table-reorder-api.js +2 -0
- package/dist/interfaces/table-reorder-item.d.ts +6 -0
- package/dist/interfaces/table-reorder-item.js +2 -0
- package/dist/interfaces/table-reorder-placement.d.ts +6 -0
- package/dist/interfaces/table-reorder-placement.js +2 -0
- package/dist/interfaces/table-reorder-row-props.d.ts +6 -0
- package/dist/interfaces/table-reorder-row-props.js +2 -0
- package/dist/interfaces/table-reorder-run.d.ts +5 -0
- package/dist/interfaces/table-reorder-run.js +2 -0
- package/dist/interfaces/table-reorder.d.ts +12 -0
- package/dist/interfaces/table-reorder.js +2 -0
- package/dist/interfaces/table-row-entry.d.ts +7 -0
- package/dist/interfaces/table-row-entry.js +2 -0
- package/dist/services/ps-table-reorder-service.d.ts +11 -0
- package/dist/services/ps-table-reorder-service.js +46 -0
- package/package.json +6 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PsTableReorderAnnouncements } from './table-reorder-announcements';
|
|
2
|
+
export interface PsTableReorder<RowData> {
|
|
3
|
+
announcements: PsTableReorderAnnouncements;
|
|
4
|
+
cardsReason?: string;
|
|
5
|
+
columnLabel: string;
|
|
6
|
+
disabledReason?: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
getHandleLabel: (rowLabel: string) => string;
|
|
9
|
+
groupKey: (row: RowData) => string;
|
|
10
|
+
instructions: string;
|
|
11
|
+
onReorder: (groupKey: string, orderedIds: string[]) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Modifier } from '@dnd-kit/core';
|
|
2
|
+
import type { PsTableReorderApi } from '../interfaces/table-reorder-api';
|
|
3
|
+
import type { PsTableReorderPlacement } from '../interfaces/table-reorder-placement';
|
|
4
|
+
import type { PsTableReorderRun } from '../interfaces/table-reorder-run';
|
|
5
|
+
export declare class PsTableReorderService {
|
|
6
|
+
static readonly plain: PsTableReorderApi;
|
|
7
|
+
static runs<Item>(items: Item[], getKey: (item: Item) => string, getId: (item: Item) => string): PsTableReorderRun<Item>[];
|
|
8
|
+
static placements<Item>(runs: PsTableReorderRun<Item>[], getId: (item: Item) => string): Map<string, PsTableReorderPlacement>;
|
|
9
|
+
static move(ids: string[], activeId: string, overId: string): string[];
|
|
10
|
+
static readonly lockToVerticalAxis: Modifier;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsTableReorderService = void 0;
|
|
4
|
+
class PsTableReorderService {
|
|
5
|
+
static runs(items, getKey, getId) {
|
|
6
|
+
const runs = [];
|
|
7
|
+
for (const item of items) {
|
|
8
|
+
const groupKey = getKey(item);
|
|
9
|
+
const last = runs[runs.length - 1];
|
|
10
|
+
if (last !== undefined && last.groupKey === groupKey)
|
|
11
|
+
last.items.push(item);
|
|
12
|
+
else
|
|
13
|
+
runs.push({ groupKey, id: `${groupKey}:${getId(item)}`, items: [item] });
|
|
14
|
+
}
|
|
15
|
+
return runs;
|
|
16
|
+
}
|
|
17
|
+
static placements(runs, getId) {
|
|
18
|
+
const placements = new Map();
|
|
19
|
+
for (const run of runs)
|
|
20
|
+
run.items.forEach((item, index) => placements.set(getId(item), {
|
|
21
|
+
groupKey: run.groupKey,
|
|
22
|
+
index,
|
|
23
|
+
runId: run.id,
|
|
24
|
+
size: run.items.length,
|
|
25
|
+
}));
|
|
26
|
+
return placements;
|
|
27
|
+
}
|
|
28
|
+
static move(ids, activeId, overId) {
|
|
29
|
+
const from = ids.indexOf(activeId);
|
|
30
|
+
const to = ids.indexOf(overId);
|
|
31
|
+
if (from < 0 || to < 0 || from === to)
|
|
32
|
+
return ids;
|
|
33
|
+
const next = [...ids];
|
|
34
|
+
const [moved] = next.splice(from, 1);
|
|
35
|
+
next.splice(to, 0, moved);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.PsTableReorderService = PsTableReorderService;
|
|
40
|
+
PsTableReorderService.plain = {
|
|
41
|
+
Row: 'tr',
|
|
42
|
+
isActive: false,
|
|
43
|
+
rowProps: (rowId) => ({ handleLabel: '', hasHandle: false, isDisabled: true, rowId }),
|
|
44
|
+
run: (_runId, _ids, children) => children,
|
|
45
|
+
};
|
|
46
|
+
PsTableReorderService.lockToVerticalAxis = ({ transform }) => ({ ...transform, x: 0 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pallasoft/ps-table-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"eslint-plugin-import": "^2.32.0",
|
|
56
56
|
"eslint-plugin-prettier": "^5.5.4",
|
|
57
57
|
"husky": "^9.1.7",
|
|
58
|
+
"jsdom": "^30.1.1",
|
|
58
59
|
"lint-staged": "^16.2.7",
|
|
59
60
|
"prettier": "^3.6.2",
|
|
60
61
|
"react": "^19.3.0",
|
|
@@ -73,7 +74,10 @@
|
|
|
73
74
|
"url": "git+https://github.com/pallasoft/ps-table-components.git"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
|
-
"@
|
|
77
|
+
"@dnd-kit/core": "^6.3.1",
|
|
78
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
79
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
80
|
+
"@pallasoft/ps-core-components": "^2.23.0",
|
|
77
81
|
"@pallasoft/ps-design-system": "^1.5.0",
|
|
78
82
|
"@pallasoft/ps-icons": "^1.5.4",
|
|
79
83
|
"@pallasoft/ps-input-components": "^1.14.0",
|