@terraware/web-components 5.2.6-rc.1 → 5.2.6-rc.2
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/components/EditableTableV2/ColumnDragging.d.ts +19 -0
- package/components/EditableTableV2/ColumnDragging.d.ts.map +1 -0
- package/components/EditableTableV2/ColumnDragging.js +191 -0
- package/components/EditableTableV2/index.d.ts +2 -1
- package/components/EditableTableV2/index.d.ts.map +1 -1
- package/components/EditableTableV2/index.js +36 -6
- package/package.json +1 -1
- package/strings/csv/en.csv +2 -0
- package/strings/csv/es.csv +2 -0
- package/strings/csv/fr.csv +2 -0
- package/strings/strings-en.d.ts +2 -0
- package/strings/strings-en.d.ts.map +1 -1
- package/strings/strings-en.js +2 -0
- package/strings/strings-es.d.ts +2 -0
- package/strings/strings-es.d.ts.map +1 -1
- package/strings/strings-es.js +2 -0
- package/strings/strings-fr.d.ts +2 -0
- package/strings/strings-fr.d.ts.map +1 -1
- package/strings/strings-fr.js +2 -0
- package/strings/strings-gx.d.ts +2 -0
- package/strings/strings-gx.d.ts.map +1 -1
- package/strings/strings-gx.js +2 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DragEndEvent } from '@dnd-kit/core';
|
|
3
|
+
import { MenuItemProps, MenuProps, TableCellProps, TableContainerProps } from '@mui/material';
|
|
4
|
+
type DragContextProps = {
|
|
5
|
+
ids: string[];
|
|
6
|
+
onDragEnd: (event: DragEndEvent) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ColumnDragMenu: ({ ids, onDragEnd, ...props }: DragContextProps & Omit<MenuProps, "onDragEnd">) => React.JSX.Element;
|
|
9
|
+
export declare const ColumnDragTableContainer: ({ ids, onDragEnd, ...props }: DragContextProps & Omit<TableContainerProps, "onDragEnd">) => React.JSX.Element;
|
|
10
|
+
export declare const ColumnDragHandle: () => React.ReactNode;
|
|
11
|
+
type ColumnDragProps = {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const DraggableColumnHeader: ({ id, label, enabled, ...props }: ColumnDragProps & TableCellProps) => React.JSX.Element;
|
|
17
|
+
export declare const DraggableColumnItem: ({ id, label, enabled, ...props }: ColumnDragProps & MenuItemProps) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=ColumnDragging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnDragging.d.ts","sourceRoot":"","sources":["../../../src/components/EditableTableV2/ColumnDragging.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAEnG,OAAO,EAGL,YAAY,EAOb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAKL,aAAa,EACb,SAAS,EAET,cAAc,EAEd,mBAAmB,EAGpB,MAAM,eAAe,CAAC;AAIvB,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAA;CAAE,CAAC;AAoDpF,eAAO,MAAM,cAAc,GAAI,8BAA8B,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,sBAI3G,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,8BAItC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,sBAI3D,CAAC;AAGF,eAAO,MAAM,gBAAgB,uBAAsC,CAAC;AAEpE,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAsDF,eAAO,MAAM,qBAAqB,GAAI,kCAAkC,eAAe,GAAG,cAAc,sBAOvG,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,kCAAkC,eAAe,GAAG,aAAa,sBAWpG,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
3
|
+
import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
4
|
+
import { SortableContext, sortableKeyboardCoordinates, useSortable } from "@dnd-kit/sortable";
|
|
5
|
+
import { DragHandle } from "@mui/icons-material";
|
|
6
|
+
import { Box, IconButton, Menu, MenuItem, TableCell, TableContainer, Tooltip, useTheme } from "@mui/material";
|
|
7
|
+
import { useStrings } from "../../strings/index.js";
|
|
8
|
+
const ColumnDragContext = ({ ids, onDragEnd, children })=>{
|
|
9
|
+
const [overlay, setOverlay] = useState(null);
|
|
10
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
|
11
|
+
activationConstraint: {
|
|
12
|
+
distance: 5
|
|
13
|
+
}
|
|
14
|
+
}), useSensor(KeyboardSensor, {
|
|
15
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
16
|
+
}));
|
|
17
|
+
return /*#__PURE__*/ jsxs(DndContext, {
|
|
18
|
+
sensors: sensors,
|
|
19
|
+
collisionDetection: closestCenter,
|
|
20
|
+
measuring: {
|
|
21
|
+
dragOverlay: {
|
|
22
|
+
measure: (node)=>overlay?.rect ?? node.getBoundingClientRect()
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
onDragStart: ({ active })=>{
|
|
26
|
+
const element = active.data.current?.getDragElement();
|
|
27
|
+
if (element) {
|
|
28
|
+
const { width, height, top, left, right, bottom } = element.getBoundingClientRect();
|
|
29
|
+
const rect = {
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
top,
|
|
33
|
+
left,
|
|
34
|
+
right,
|
|
35
|
+
bottom
|
|
36
|
+
};
|
|
37
|
+
const html = 'TH' === element.tagName ? `<table style="border-collapse:collapse;width:${rect.width}px"><thead><tr>${element.outerHTML}</tr></thead></table>` : `<ul style="margin:0;padding:0;list-style:none">${element.outerHTML}</ul>`;
|
|
38
|
+
setOverlay({
|
|
39
|
+
html,
|
|
40
|
+
rect
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onDragCancel: ()=>setOverlay(null),
|
|
45
|
+
onDragEnd: (event)=>{
|
|
46
|
+
setOverlay(null);
|
|
47
|
+
onDragEnd(event);
|
|
48
|
+
},
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ jsx(SortableContext, {
|
|
51
|
+
items: ids,
|
|
52
|
+
children: children
|
|
53
|
+
}),
|
|
54
|
+
/*#__PURE__*/ jsx(DragOverlay, {
|
|
55
|
+
dropAnimation: null,
|
|
56
|
+
zIndex: 1500,
|
|
57
|
+
children: overlay && /*#__PURE__*/ jsx(Box, {
|
|
58
|
+
"aria-hidden": true,
|
|
59
|
+
"data-testid": "column-drag-overlay",
|
|
60
|
+
sx: {
|
|
61
|
+
width: overlay.rect.width,
|
|
62
|
+
height: overlay.rect.height,
|
|
63
|
+
opacity: 0.65,
|
|
64
|
+
bgcolor: 'background.paper',
|
|
65
|
+
pointerEvents: 'none'
|
|
66
|
+
},
|
|
67
|
+
dangerouslySetInnerHTML: {
|
|
68
|
+
__html: overlay.html
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const ColumnDragMenu = ({ ids, onDragEnd, ...props })=>/*#__PURE__*/ jsx(ColumnDragContext, {
|
|
76
|
+
ids: ids,
|
|
77
|
+
onDragEnd: onDragEnd,
|
|
78
|
+
children: /*#__PURE__*/ jsx(Menu, {
|
|
79
|
+
...props
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
const ColumnDragTableContainer = ({ ids, onDragEnd, ...props })=>/*#__PURE__*/ jsx(ColumnDragContext, {
|
|
83
|
+
ids: ids,
|
|
84
|
+
onDragEnd: onDragEnd,
|
|
85
|
+
children: /*#__PURE__*/ jsx(TableContainer, {
|
|
86
|
+
...props
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
const DragHandleContext = /*#__PURE__*/ createContext(null);
|
|
90
|
+
const ColumnDragHandle = ()=>useContext(DragHandleContext);
|
|
91
|
+
const useColumnDrag = ({ id, label, enabled }, activeOutlineWidth = 1)=>{
|
|
92
|
+
const strings = useStrings();
|
|
93
|
+
const theme = useTheme();
|
|
94
|
+
const element = useRef(null);
|
|
95
|
+
const { setNodeRef, setActivatorNodeRef, attributes, listeners, isDragging, isOver } = useSortable({
|
|
96
|
+
id,
|
|
97
|
+
disabled: !enabled,
|
|
98
|
+
data: {
|
|
99
|
+
getDragElement: ()=>element.current
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const ref = useCallback((node)=>{
|
|
103
|
+
element.current = node;
|
|
104
|
+
setNodeRef(node);
|
|
105
|
+
}, [
|
|
106
|
+
setNodeRef
|
|
107
|
+
]);
|
|
108
|
+
const dragStyles = {
|
|
109
|
+
outline: isDragging ? `${activeOutlineWidth}px dashed ${theme.palette.grey[500]}` : isOver ? `2px dashed ${theme.palette.primary.main}` : void 0,
|
|
110
|
+
outlineOffset: '-2px'
|
|
111
|
+
};
|
|
112
|
+
const handle = enabled && /*#__PURE__*/ jsx(Tooltip, {
|
|
113
|
+
title: strings.TABLE_MOVE,
|
|
114
|
+
placement: "top",
|
|
115
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
116
|
+
size: "small",
|
|
117
|
+
disableRipple: true,
|
|
118
|
+
ref: setActivatorNodeRef,
|
|
119
|
+
...attributes,
|
|
120
|
+
...listeners,
|
|
121
|
+
"aria-label": `${strings.TABLE_DRAG_COLUMN}: ${label}`,
|
|
122
|
+
sx: {
|
|
123
|
+
touchAction: 'none',
|
|
124
|
+
cursor: 'grab',
|
|
125
|
+
'&:active': {
|
|
126
|
+
cursor: 'grabbing'
|
|
127
|
+
},
|
|
128
|
+
'&:hover': {
|
|
129
|
+
backgroundColor: 'transparent',
|
|
130
|
+
opacity: 1
|
|
131
|
+
},
|
|
132
|
+
m: '0 -0.1rem',
|
|
133
|
+
opacity: 0.5,
|
|
134
|
+
p: '2px',
|
|
135
|
+
transition: 'all 150ms ease-in-out'
|
|
136
|
+
},
|
|
137
|
+
onClick: (event)=>event.stopPropagation(),
|
|
138
|
+
children: /*#__PURE__*/ jsx(DragHandle, {})
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
ref,
|
|
143
|
+
handle,
|
|
144
|
+
dragStyles,
|
|
145
|
+
isDragging
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const DraggableColumnHeader = ({ id, label, enabled, ...props })=>{
|
|
149
|
+
const { ref, handle, dragStyles } = useColumnDrag({
|
|
150
|
+
id,
|
|
151
|
+
label,
|
|
152
|
+
enabled
|
|
153
|
+
});
|
|
154
|
+
return /*#__PURE__*/ jsx(DragHandleContext.Provider, {
|
|
155
|
+
value: handle,
|
|
156
|
+
children: /*#__PURE__*/ jsx(TableCell, {
|
|
157
|
+
...props,
|
|
158
|
+
ref: ref,
|
|
159
|
+
sx: [
|
|
160
|
+
...Array.isArray(props.sx) ? props.sx : [
|
|
161
|
+
props.sx
|
|
162
|
+
],
|
|
163
|
+
dragStyles
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const DraggableColumnItem = ({ id, label, enabled, ...props })=>{
|
|
169
|
+
const { ref, handle, dragStyles, isDragging } = useColumnDrag({
|
|
170
|
+
id,
|
|
171
|
+
label,
|
|
172
|
+
enabled
|
|
173
|
+
}, 2);
|
|
174
|
+
return /*#__PURE__*/ jsx(DragHandleContext.Provider, {
|
|
175
|
+
value: handle,
|
|
176
|
+
children: /*#__PURE__*/ jsx(MenuItem, {
|
|
177
|
+
...props,
|
|
178
|
+
ref: ref,
|
|
179
|
+
sx: [
|
|
180
|
+
...Array.isArray(props.sx) ? props.sx : [
|
|
181
|
+
props.sx
|
|
182
|
+
],
|
|
183
|
+
dragStyles,
|
|
184
|
+
{
|
|
185
|
+
opacity: isDragging ? 0.5 : 1
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
export { ColumnDragHandle, ColumnDragMenu, ColumnDragTableContainer, DraggableColumnHeader, DraggableColumnItem };
|
|
@@ -9,6 +9,7 @@ export type EditableTablePropsV2<TData extends object> = {
|
|
|
9
9
|
enableClearAllFilters?: boolean;
|
|
10
10
|
enableEditing?: boolean;
|
|
11
11
|
enableColumnOrdering?: boolean;
|
|
12
|
+
enableColumnDragging?: boolean;
|
|
12
13
|
enableColumnActions?: boolean;
|
|
13
14
|
showColumnsButton?: boolean;
|
|
14
15
|
showGlobalFilterButton?: boolean;
|
|
@@ -38,6 +39,6 @@ export type EditableTablePropsV2<TData extends object> = {
|
|
|
38
39
|
containerProps?: TableContainerProps;
|
|
39
40
|
sx?: SxProps<Theme>;
|
|
40
41
|
};
|
|
41
|
-
declare const EditableTableV2: <TData extends object>({ clearAllFiltersLabel, columns, data, enableClearAllFilters, enableEditing, enableColumnOrdering, enableColumnActions, showColumnsButton, showGlobalFilterButton, showColumnFiltersButton, showDensityButton, showFullScreenButton, enableColumnPinning, enableHiding, enableSorting, enableGlobalFilter, enableColumnFilters, stickyFilters, storageKey, enablePagination, enableBottomToolbar, enableTopToolbar, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, tableOptions, containerProps, sx, }: EditableTablePropsV2<TData>) => React.JSX.Element;
|
|
42
|
+
declare const EditableTableV2: <TData extends object>({ clearAllFiltersLabel, columns, data, enableClearAllFilters, enableEditing, enableColumnOrdering, enableColumnDragging, enableColumnActions, showColumnsButton, showGlobalFilterButton, showColumnFiltersButton, showDensityButton, showFullScreenButton, enableColumnPinning, enableHiding, enableSorting, enableGlobalFilter, enableColumnFilters, stickyFilters, storageKey, enablePagination, enableBottomToolbar, enableTopToolbar, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, tableOptions, containerProps, sx, }: EditableTablePropsV2<TData>) => React.JSX.Element;
|
|
42
43
|
export default EditableTableV2;
|
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EditableTableV2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EditableTableV2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAC;AA0BvE,OAAO,EAYL,OAAO,EAIP,mBAAmB,EAMnB,KAAK,EAGN,MAAM,eAAe,CAAC;AAcvB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,sBAAsB,EAAyB,MAAM,SAAS,CAAC;AAExH,YAAY,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,MAAM,IAAI;IACvD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;IACxC,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACjD,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,4BAA4B,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAA;KAAE,KAAK,SAAS,CAAC;IAC/F,YAAY,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC;AA2JF,QAAA,MAAM,eAAe,GAAI,KAAK,SAAS,MAAM,EAAE,4hBA+B5C,oBAAoB,CAAC,KAAK,CAAC,sBAyqB7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
3
4
|
import { ArrowDownward, ArrowUpward, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, FilterAlt, FilterList, FilterListOff, Fullscreen, FullscreenExit, MoreVert, PushPin, Search, SearchOff, Sort, SyncAlt, ViewColumn, VisibilityOff } from "@mui/icons-material";
|
|
4
|
-
import { Box, Button, Divider, FormControlLabel, IconButton, InputAdornment, ListItemIcon,
|
|
5
|
+
import { Box, Button, Divider, FormControlLabel, IconButton, InputAdornment, ListItemIcon, MenuItem, Paper, Switch, Table, TableBody, TableCell, TableHead, TablePagination, TableRow, TableSortLabel, TextField, Toolbar, Tooltip } from "@mui/material";
|
|
5
6
|
import { alpha, darken, lighten } from "@mui/material/styles";
|
|
6
7
|
import { useTable } from "@tanstack/react-table";
|
|
7
8
|
import { useStrings } from "../../strings/index.js";
|
|
8
9
|
import Button_Button from "../Button/Button.js";
|
|
10
|
+
import { ColumnDragHandle, ColumnDragMenu, ColumnDragTableContainer, DraggableColumnHeader, DraggableColumnItem } from "./ColumnDragging.js";
|
|
9
11
|
import EditableCellV2 from "./EditableCellV2.js";
|
|
10
12
|
import { editableTableFeatures } from "./types.js";
|
|
11
13
|
const isActiveFilter = (filter)=>{
|
|
@@ -179,7 +181,7 @@ const ColumnFilter = ({ column, definition })=>{
|
|
|
179
181
|
]
|
|
180
182
|
});
|
|
181
183
|
};
|
|
182
|
-
const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFilters = true, enableEditing = false, enableColumnOrdering = false, enableColumnActions = true, showColumnsButton = false, showGlobalFilterButton = false, showColumnFiltersButton = false, showDensityButton = false, showFullScreenButton = false, enableColumnPinning = false, enableHiding = true, enableSorting = true, enableGlobalFilter = false, enableColumnFilters = false, stickyFilters = false, storageKey, enablePagination = true, enableBottomToolbar = true, enableTopToolbar = true, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, tableOptions, containerProps, sx })=>{
|
|
184
|
+
const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFilters = true, enableEditing = false, enableColumnOrdering = false, enableColumnDragging = false, enableColumnActions = true, showColumnsButton = false, showGlobalFilterButton = false, showColumnFiltersButton = false, showDensityButton = false, showFullScreenButton = false, enableColumnPinning = false, enableHiding = true, enableSorting = true, enableGlobalFilter = false, enableColumnFilters = false, stickyFilters = false, storageKey, enablePagination = true, enableBottomToolbar = true, enableTopToolbar = true, initialSorting, onClearAllFilters, onRowClick, renderToolbarInternalActions, tableOptions, containerProps, sx })=>{
|
|
183
185
|
const strings = useStrings();
|
|
184
186
|
const [editingCell, setEditingCell] = useState(null);
|
|
185
187
|
const [globalFilterVisible, setGlobalFilterVisible] = useState(true);
|
|
@@ -302,6 +304,22 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
302
304
|
table.setColumnOrder(order);
|
|
303
305
|
}
|
|
304
306
|
};
|
|
307
|
+
const reorderColumns = ({ active, over })=>{
|
|
308
|
+
if (!over || active.id === over.id) return;
|
|
309
|
+
const source = table.getAllLeafColumns().find((column)=>column.id === active.id);
|
|
310
|
+
const target = table.getAllLeafColumns().find((column)=>column.id === over.id);
|
|
311
|
+
if (!source || !target || source.getIsPinned() !== target.getIsPinned()) return;
|
|
312
|
+
const pin = source.getIsPinned();
|
|
313
|
+
const order = table.getAllLeafColumns().map((column)=>column.id);
|
|
314
|
+
table.setColumnOrder(arrayMove(order, order.indexOf(source.id), order.indexOf(target.id)));
|
|
315
|
+
if (pin) table.setColumnPinning((previous)=>{
|
|
316
|
+
const group = previous[pin] ?? [];
|
|
317
|
+
return {
|
|
318
|
+
...previous,
|
|
319
|
+
[pin]: arrayMove(group, group.indexOf(source.id), group.indexOf(target.id))
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
};
|
|
305
323
|
return /*#__PURE__*/ jsx(Box, {
|
|
306
324
|
minHeight: "160px",
|
|
307
325
|
padding: 2,
|
|
@@ -433,7 +451,9 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
433
451
|
})
|
|
434
452
|
]
|
|
435
453
|
}),
|
|
436
|
-
/*#__PURE__*/ jsxs(
|
|
454
|
+
/*#__PURE__*/ jsxs(ColumnDragMenu, {
|
|
455
|
+
ids: table.getAllLeafColumns().map((column)=>column.id),
|
|
456
|
+
onDragEnd: reorderColumns,
|
|
437
457
|
anchorEl: menuAnchor,
|
|
438
458
|
open: !!menuAnchor,
|
|
439
459
|
onClose: ()=>setMenuAnchor(null),
|
|
@@ -554,7 +574,10 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
554
574
|
]
|
|
555
575
|
}),
|
|
556
576
|
!menuColumnId && controlsEnabled && /*#__PURE__*/ jsx(Divider, {}),
|
|
557
|
-
table.getAllLeafColumns().map((column, index, allColumns)=>!menuColumnId && controlsEnabled && /*#__PURE__*/ jsxs(
|
|
577
|
+
table.getAllLeafColumns().map((column, index, allColumns)=>!menuColumnId && controlsEnabled && /*#__PURE__*/ jsxs(DraggableColumnItem, {
|
|
578
|
+
id: column.id,
|
|
579
|
+
label: definitions.get(column.id).header,
|
|
580
|
+
enabled: enableColumnOrdering,
|
|
558
581
|
disableRipple: true,
|
|
559
582
|
sx: {
|
|
560
583
|
my: 0,
|
|
@@ -562,6 +585,7 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
562
585
|
pl: '16px'
|
|
563
586
|
},
|
|
564
587
|
children: [
|
|
588
|
+
/*#__PURE__*/ jsx(ColumnDragHandle, {}),
|
|
565
589
|
/*#__PURE__*/ jsx(FormControlLabel, {
|
|
566
590
|
label: definitions.get(column.id)?.header,
|
|
567
591
|
slotProps: {
|
|
@@ -618,8 +642,10 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
618
642
|
}, column.id))
|
|
619
643
|
]
|
|
620
644
|
}),
|
|
621
|
-
/*#__PURE__*/ jsx(
|
|
645
|
+
/*#__PURE__*/ jsx(ColumnDragTableContainer, {
|
|
622
646
|
...containerProps,
|
|
647
|
+
ids: orderedColumns.map((column)=>column.id),
|
|
648
|
+
onDragEnd: reorderColumns,
|
|
623
649
|
children: /*#__PURE__*/ jsxs(Table, {
|
|
624
650
|
sx: {
|
|
625
651
|
minWidth: table.getTotalSize()
|
|
@@ -647,7 +673,10 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
647
673
|
})
|
|
648
674
|
]
|
|
649
675
|
});
|
|
650
|
-
return /*#__PURE__*/ jsxs(
|
|
676
|
+
return /*#__PURE__*/ jsxs(DraggableColumnHeader, {
|
|
677
|
+
id: column.id,
|
|
678
|
+
label: definitions.get(column.id).header,
|
|
679
|
+
enabled: enableColumnDragging || enableColumnOrdering,
|
|
651
680
|
sortDirection: column.getIsSorted() || false,
|
|
652
681
|
sx: (theme)=>({
|
|
653
682
|
...pinnedStyles(column, theme),
|
|
@@ -686,6 +715,7 @@ const EditableTableV2 = ({ clearAllFiltersLabel, columns, data, enableClearAllFi
|
|
|
686
715
|
onClick: column.getToggleSortingHandler(),
|
|
687
716
|
children: header
|
|
688
717
|
}) : header,
|
|
718
|
+
/*#__PURE__*/ jsx(ColumnDragHandle, {}),
|
|
689
719
|
enableColumnActions && (column.getCanSort() || column.getCanFilter() || controlsEnabled) && /*#__PURE__*/ jsx(IconButton, {
|
|
690
720
|
size: "small",
|
|
691
721
|
sx: {
|
package/package.json
CHANGED
package/strings/csv/en.csv
CHANGED
package/strings/csv/es.csv
CHANGED
|
@@ -58,6 +58,8 @@ TABLE_HIDE_COLUMN,Ocultar columna {column},b4a87c14
|
|
|
58
58
|
TABLE_LAST_PAGE,Última página,6eafe34a
|
|
59
59
|
TABLE_MAX,Máximo,96f88e1f
|
|
60
60
|
TABLE_MIN,Mínimo,f2a882fd
|
|
61
|
+
TABLE_DRAG_COLUMN,Arrastrar columna,
|
|
62
|
+
TABLE_MOVE,Mover,
|
|
61
63
|
TABLE_MOVE_BACK,Mover columna hacia atrás,ccaba4fb
|
|
62
64
|
TABLE_MOVE_FORWARD,Mover columna hacia adelante,a7cfa4d3
|
|
63
65
|
TABLE_NEXT_PAGE,Página siguiente,be0bb188
|
package/strings/csv/fr.csv
CHANGED
|
@@ -58,6 +58,8 @@ TABLE_HIDE_COLUMN,Masquer la colonne {column},b4a87c14
|
|
|
58
58
|
TABLE_LAST_PAGE,Dernière page,6eafe34a
|
|
59
59
|
TABLE_MAX,Maximum,96f88e1f
|
|
60
60
|
TABLE_MIN,Minimum,f2a882fd
|
|
61
|
+
TABLE_DRAG_COLUMN,Déplacer la colonne,
|
|
62
|
+
TABLE_MOVE,Déplacer,
|
|
61
63
|
TABLE_MOVE_BACK,Déplacer la colonne vers l’arrière,ccaba4fb
|
|
62
64
|
TABLE_MOVE_FORWARD,Déplacer la colonne vers l’avant,a7cfa4d3
|
|
63
65
|
TABLE_NEXT_PAGE,Page suivante,be0bb188
|
package/strings/strings-en.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings-en.d.ts","sourceRoot":"","sources":["../../src/strings/strings-en.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"strings-en.d.ts","sourceRoot":"","sources":["../../src/strings/strings-en.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFnB,CAAC"}
|
package/strings/strings-en.js
CHANGED
|
@@ -57,6 +57,8 @@ const strings = {
|
|
|
57
57
|
TABLE_ALL: 'All',
|
|
58
58
|
TABLE_SEARCH: 'Search',
|
|
59
59
|
TABLE_COLUMNS: 'Columns',
|
|
60
|
+
TABLE_DRAG_COLUMN: 'Drag column',
|
|
61
|
+
TABLE_MOVE: 'Move',
|
|
60
62
|
TABLE_MOVE_BACK: 'Move column backward',
|
|
61
63
|
TABLE_MOVE_FORWARD: 'Move column forward',
|
|
62
64
|
TABLE_PIN: 'Pin column',
|
package/strings/strings-es.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings-es.d.ts","sourceRoot":"","sources":["../../src/strings/strings-es.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"strings-es.d.ts","sourceRoot":"","sources":["../../src/strings/strings-es.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFnB,CAAC"}
|
package/strings/strings-es.js
CHANGED
|
@@ -57,6 +57,8 @@ const strings = {
|
|
|
57
57
|
TABLE_ALL: 'Todos',
|
|
58
58
|
TABLE_SEARCH: 'Buscar',
|
|
59
59
|
TABLE_COLUMNS: 'Columnas',
|
|
60
|
+
TABLE_DRAG_COLUMN: 'Arrastrar columna',
|
|
61
|
+
TABLE_MOVE: 'Mover',
|
|
60
62
|
TABLE_MOVE_BACK: 'Mover columna hacia atrás',
|
|
61
63
|
TABLE_MOVE_FORWARD: 'Mover columna hacia adelante',
|
|
62
64
|
TABLE_PIN: 'Fijar columna',
|
package/strings/strings-fr.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings-fr.d.ts","sourceRoot":"","sources":["../../src/strings/strings-fr.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"strings-fr.d.ts","sourceRoot":"","sources":["../../src/strings/strings-fr.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFnB,CAAC"}
|
package/strings/strings-fr.js
CHANGED
|
@@ -57,6 +57,8 @@ const strings = {
|
|
|
57
57
|
TABLE_ALL: 'Tout',
|
|
58
58
|
TABLE_SEARCH: 'Rechercher',
|
|
59
59
|
TABLE_COLUMNS: 'Colonnes',
|
|
60
|
+
TABLE_DRAG_COLUMN: 'Déplacer la colonne',
|
|
61
|
+
TABLE_MOVE: 'Déplacer',
|
|
60
62
|
TABLE_MOVE_BACK: 'Déplacer la colonne vers l’arrière',
|
|
61
63
|
TABLE_MOVE_FORWARD: 'Déplacer la colonne vers l’avant',
|
|
62
64
|
TABLE_PIN: 'Épingler la colonne',
|
package/strings/strings-gx.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings-gx.d.ts","sourceRoot":"","sources":["../../src/strings/strings-gx.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"strings-gx.d.ts","sourceRoot":"","sources":["../../src/strings/strings-gx.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwFnB,CAAC"}
|
package/strings/strings-gx.js
CHANGED
|
@@ -57,6 +57,8 @@ const strings = {
|
|
|
57
57
|
TABLE_ALL: 'QWxs',
|
|
58
58
|
TABLE_SEARCH: 'U2VhcmNo',
|
|
59
59
|
TABLE_COLUMNS: 'Q29sdW1ucw',
|
|
60
|
+
TABLE_DRAG_COLUMN: 'Y29sdW1u RHJhZw',
|
|
61
|
+
TABLE_MOVE: 'TW92ZQ',
|
|
60
62
|
TABLE_MOVE_BACK: 'YmFja3dhcmQ Y29sdW1u TW92ZQ',
|
|
61
63
|
TABLE_MOVE_FORWARD: 'Zm9yd2FyZA Y29sdW1u TW92ZQ',
|
|
62
64
|
TABLE_PIN: 'Y29sdW1u UGlu',
|