kelt-ui-kit-react 2.0.1 → 2.0.3
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/_core/type/generiqueType.d.ts +4 -0
- package/dist/badge/Badge.d.ts +3 -1
- package/dist/button/Button.d.ts +1 -1
- package/dist/button/button.interface.d.ts +1 -2
- package/dist/dataTable/DataTable.d.ts +17 -14
- package/dist/dataTable/dataTable.interface.d.ts +24 -19
- package/dist/dataTable/dataTableActions/DataTableAction.d.ts +3 -5
- package/dist/dataTable/dataTableColumn/DataTableColumn.d.ts +13 -7
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.d.ts +10 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.d.ts +13 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.d.ts +9 -0
- package/dist/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.d.ts +11 -0
- package/dist/dataTable/dataTableFilters/DataTableFilters.d.ts +7 -0
- package/dist/dataTable/dataTableLoading/DataTableLoading.d.ts +1 -3
- package/dist/dataTable/dataTableRow/DataTableRow.d.ts +5 -6
- package/dist/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.d.ts +12 -0
- package/dist/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.d.ts +11 -0
- package/dist/expands/expand/expand.d.ts +1 -1
- package/dist/form/Form.d.ts +1 -2
- package/dist/form/form.enum.d.ts +2 -2
- package/dist/form/form.interface.d.ts +2 -4
- package/dist/form/input/Input.d.ts +3 -0
- package/dist/form/inputNumber/InputNumber.d.ts +0 -2
- package/dist/grid/col/Col.d.ts +6 -3
- package/dist/grid/col/colStyled/ColStyled.d.ts +5 -7
- package/dist/grid/grid.interface.d.ts +5 -9
- package/dist/header/Header.d.ts +1 -1
- package/dist/header/header.interface.d.ts +1 -2
- package/dist/icon/Icon.d.ts +1 -1
- package/dist/icon/icon.interface.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3740 -3443
- package/dist/menus/menu/Menu.d.ts +0 -1
- package/dist/overlayPanel/OverlayPanel.d.ts +4 -2
- package/dist/overlayPanel/overlayPanelStyled/OverlayPanelStyled.d.ts +2 -0
- package/dist/select/Select.d.ts +6 -2
- package/dist/select/selectOption.interface.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/tabs/Tabs.d.ts +2 -1
- package/dist/toaster/store/useToasterStore.d.ts +0 -1
- package/index.html +2 -1
- package/package/package.json +56 -0
- package/package/src/sidebar/Sidebar.tsx +208 -0
- package/package/src/sidebar/sidebar.css +104 -0
- package/package.json +1 -1
- package/src/_core/type/generiqueType.tsx +4 -0
- package/src/badge/Badge.tsx +9 -1
- package/src/badge/badge.css +4 -0
- package/src/button/Button.tsx +1 -3
- package/src/button/button.css +2 -2
- package/src/button/button.interface.tsx +1 -2
- package/src/card/card.css +25 -5
- package/src/card/cardAction/CardAction.tsx +4 -4
- package/src/damier/Damier.tsx +7 -16
- package/src/damier/damier.css +4 -11
- package/src/dataTable/DataTable.tsx +685 -542
- package/src/dataTable/DataTable.view.tsx +48 -24
- package/src/dataTable/dataTable.css +134 -159
- package/src/dataTable/dataTable.interface.ts +25 -19
- package/src/dataTable/dataTableActions/DataTableAction.tsx +14 -25
- package/src/dataTable/dataTableColumn/DataTableColumn.tsx +64 -14
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/DataTableColumnFilter.tsx +36 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilter.css +0 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDate/DataTableColumnFilterDate.tsx +39 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterDateRange/dataTableColumnFilterDateRange.tsx +80 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterEnum/DataTableColumnFilterEnum.tsx +89 -0
- package/src/dataTable/dataTableColumn/dataTableColumnFilter/dataTableColumnFilterString/DataTableColumnFilterString.tsx +37 -0
- package/src/dataTable/dataTableColumn/dataTableColumnSort/DataTableColumnSort.tsx +42 -0
- package/src/dataTable/dataTableFilters/DataTableFilters.tsx +91 -0
- package/src/dataTable/dataTableFilters/dataTableFilters.css +16 -0
- package/src/dataTable/dataTableLoading/DataTableLoading.tsx +4 -15
- package/src/dataTable/dataTableRow/DataTableRow.tsx +64 -180
- package/src/dataTable/dataTableRow/dataTableRowOverlay/DataTableRowOverlay.tsx +80 -0
- package/src/dataTable/dataTableRow/dataTableRowValue/DataTableRowValue.tsx +123 -0
- package/src/expands/Expands.tsx +2 -16
- package/src/expands/expand/expand.tsx +5 -122
- package/src/expands/expands.css +3 -8
- package/src/form/Form.tsx +25 -125
- package/src/form/Form.view.tsx +1 -9
- package/src/form/form.css +1 -38
- package/src/form/form.enum.ts +1 -1
- package/src/form/form.interface.tsx +2 -7
- package/src/form/input/Input.tsx +61 -7
- package/src/form/input/input.css +23 -1
- package/src/form/inputNumber/InputNumber.tsx +6 -11
- package/src/form/inputPrice/InputPrice.tsx +2 -4
- package/src/grid/col/Col.tsx +7 -5
- package/src/grid/col/colStyled/ColStyled.tsx +7 -21
- package/src/grid/grid.interface.tsx +5 -11
- package/src/header/Header.tsx +2 -4
- package/src/header/header.css +0 -17
- package/src/header/header.interface.tsx +1 -2
- package/src/icon/Icon.tsx +6 -2
- package/src/icon/icon.interface.tsx +1 -0
- package/src/index.css +12 -58
- package/src/index.ts +2 -1
- package/src/menus/Menus.tsx +0 -1
- package/src/menus/menu/Menu.tsx +1 -2
- package/src/overlayPanel/OverlayPanel.tsx +71 -18
- package/src/overlayPanel/overlay.context.tsx +6 -4
- package/src/overlayPanel/overlayPanel.css +10 -1
- package/src/overlayPanel/overlayPanelStyled/OverlayPanelStyled.tsx +7 -2
- package/src/select/Select.tsx +178 -41
- package/src/select/select.css +94 -13
- package/src/select/selectOption.interface.ts +1 -0
- package/src/sidebar/Sidebar.tsx +5 -107
- package/src/sidebar/sidebar.css +1 -18
- package/src/tabs/Tabs.tsx +20 -1
- package/src/tabs/tabs.css +3 -9
- package/src/toaster/Toaster.tsx +2 -7
- package/src/toaster/Toaster.view.tsx +0 -1
- package/src/toaster/store/useToasterStore.tsx +0 -2
- package/src/toaster/toaster.css +2 -7
|
@@ -1,37 +1,53 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import { TypeInputEnum } from "../form/form.enum";
|
|
3
|
+
import { DataTable, DataTableFilterState } from "./DataTable";
|
|
4
|
+
import {
|
|
5
|
+
DataTableActionsInterface,
|
|
6
|
+
DataTableColumnsInterface,
|
|
7
|
+
} from "./dataTable.interface";
|
|
4
8
|
|
|
5
9
|
export const DataTableView = () => {
|
|
6
|
-
const dataTableColumns = useMemo(() => {
|
|
10
|
+
const dataTableColumns: DataTableColumnsInterface<{}>[] = useMemo(() => {
|
|
7
11
|
return [
|
|
8
|
-
{
|
|
12
|
+
{
|
|
13
|
+
id: "id",
|
|
14
|
+
label: "ID",
|
|
15
|
+
minWidth: 50,
|
|
16
|
+
type: "number",
|
|
17
|
+
filterable: true,
|
|
18
|
+
filterType: TypeInputEnum.CHECKBOX,
|
|
19
|
+
filterDataEnum: [
|
|
20
|
+
{ label: "1", value: "1" },
|
|
21
|
+
{ label: "2", value: "2" },
|
|
22
|
+
{ label: "3", value: "3" },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
9
25
|
{
|
|
10
26
|
id: "name",
|
|
11
27
|
label: "Name",
|
|
28
|
+
field: "name",
|
|
12
29
|
minWidth: 100,
|
|
13
|
-
|
|
14
|
-
enterToNextColumn: true,
|
|
30
|
+
filterable: true,
|
|
15
31
|
type: "text",
|
|
32
|
+
displayOverlay: true,
|
|
33
|
+
openClickCell: true,
|
|
34
|
+
filterType: TypeInputEnum.TEXT,
|
|
35
|
+
filterDataEnum: [
|
|
36
|
+
{ label: "John Doe", value: "John Doe" },
|
|
37
|
+
{ label: "Jane Smith", value: "Jane Smith" },
|
|
38
|
+
{ label: "Alice Johnson", value: "Alice Johnson" },
|
|
39
|
+
],
|
|
16
40
|
},
|
|
17
|
-
{
|
|
18
|
-
id: "age",
|
|
19
|
-
label: "Age",
|
|
20
|
-
minWidth: 50,
|
|
21
|
-
editable: true,
|
|
22
|
-
enterToNextColumn: true,
|
|
23
|
-
type: "number",
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
}, []);
|
|
27
|
-
const data = useMemo(() => {
|
|
28
|
-
return [
|
|
29
|
-
{ id: 1, name: "John Doe", age: 28 },
|
|
30
|
-
{ id: 2, name: "Jane Smith", age: 34 },
|
|
31
|
-
{ id: 3, name: "Alice Johnson", age: 45 },
|
|
41
|
+
{ id: "age", label: "Age", minWidth: 50, type: "number" },
|
|
32
42
|
];
|
|
33
43
|
}, []);
|
|
34
|
-
const
|
|
44
|
+
const [data, setData] = useState([
|
|
45
|
+
{ id: 1, name: "John Doe", age: 28 },
|
|
46
|
+
{ id: 2, name: "Jane Smith", age: 34 },
|
|
47
|
+
{ id: 3, name: "Alice Johnson", age: 45 },
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
const actions: DataTableActionsInterface<{
|
|
35
51
|
id: number;
|
|
36
52
|
name: string;
|
|
37
53
|
age: number;
|
|
@@ -55,14 +71,22 @@ export const DataTableView = () => {
|
|
|
55
71
|
},
|
|
56
72
|
];
|
|
57
73
|
}, []);
|
|
74
|
+
const onFiltersChange = (filters: DataTableFilterState) => {
|
|
75
|
+
console.log("Filters changed: ", filters);
|
|
76
|
+
};
|
|
58
77
|
return (
|
|
59
78
|
<DataTable
|
|
60
79
|
data={data}
|
|
61
80
|
actions={actions}
|
|
62
81
|
columns={dataTableColumns}
|
|
82
|
+
onFiltersChange={onFiltersChange}
|
|
83
|
+
onEditColumnByOverlay={(newRow) => {
|
|
84
|
+
setData((prevData) =>
|
|
85
|
+
prevData.map((row) => (row.id === newRow.id ? newRow : row)),
|
|
86
|
+
);
|
|
87
|
+
}}
|
|
63
88
|
id="datatable-example"
|
|
64
89
|
name={"DataTable"}
|
|
65
|
-
mobileCardView
|
|
66
90
|
onSelectionChange={(selectedRows) => {
|
|
67
91
|
console.log("Selected Rows: ", selectedRows);
|
|
68
92
|
}}
|
|
@@ -1,110 +1,25 @@
|
|
|
1
|
-
.data-table-footer-action {
|
|
2
|
-
position: fixed;
|
|
3
|
-
left: 5px;
|
|
4
|
-
right: 5px;
|
|
5
|
-
bottom: 5px;
|
|
6
|
-
border-radius: 4px;
|
|
7
|
-
z-index: 1000;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
background: #fff;
|
|
10
|
-
border-top: 1px solid #e5e5e5;
|
|
11
|
-
box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
|
|
12
|
-
animation: data-table-footer-action-enter 180ms ease-out;
|
|
13
|
-
|
|
14
|
-
& .data-table-footer-action__content {
|
|
15
|
-
position: relative;
|
|
16
|
-
padding: 0.75rem 1rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
& .data-table-footer-action__close {
|
|
20
|
-
position: absolute;
|
|
21
|
-
top: 5px;
|
|
22
|
-
right: 5px;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
|
|
25
|
-
.bi {
|
|
26
|
-
color: #333;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@keyframes data-table-footer-action-enter {
|
|
35
|
-
from {
|
|
36
|
-
opacity: 0;
|
|
37
|
-
transform: translateY(100%);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
to {
|
|
41
|
-
opacity: 1;
|
|
42
|
-
transform: translateY(0);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
1
|
.data-table-container {
|
|
47
2
|
overflow: auto;
|
|
48
|
-
position: relative;
|
|
49
|
-
|
|
50
|
-
.data-table-mobile-cards {
|
|
51
|
-
display: grid;
|
|
52
|
-
gap: 0.75rem;
|
|
53
|
-
|
|
54
|
-
.data-table-mobile-card {
|
|
55
|
-
width: 100%;
|
|
56
|
-
max-width: none;
|
|
57
|
-
height: auto;
|
|
58
|
-
padding: 0;
|
|
59
|
-
border-radius: 8px;
|
|
60
|
-
}
|
|
61
3
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
grid-template-columns: minmax(90px, 35%) minmax(0, 1fr);
|
|
70
|
-
gap: 0.75rem;
|
|
71
|
-
align-items: center;
|
|
72
|
-
padding: 0.625rem 0.75rem;
|
|
73
|
-
border-bottom: 1px solid #e5e5e5;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.data-table-mobile-card__label {
|
|
77
|
-
color: var(--tertiary-color);
|
|
78
|
-
font-size: 0.875rem;
|
|
79
|
-
font-weight: 600;
|
|
80
|
-
overflow-wrap: anywhere;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.data-table-mobile-card__actions {
|
|
84
|
-
display: flex;
|
|
85
|
-
gap: 0.5rem;
|
|
86
|
-
align-items: center;
|
|
87
|
-
justify-content: flex-end;
|
|
88
|
-
padding: 0.75rem;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.data-table-mobile-cards__empty {
|
|
92
|
-
padding: 1rem;
|
|
93
|
-
text-align: center;
|
|
94
|
-
color: #666;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&.data-table-container--with-footer-action {
|
|
99
|
-
scroll-padding-bottom: 80px;
|
|
4
|
+
.data-table-empty-state-content {
|
|
5
|
+
width: 100%;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
padding: 1rem;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
100
11
|
}
|
|
101
12
|
|
|
102
13
|
.data-table {
|
|
103
14
|
width: 100%;
|
|
104
|
-
border-spacing: 0;
|
|
105
|
-
font-size:
|
|
15
|
+
border-spacing: 5px 0;
|
|
16
|
+
font-size: 14px;
|
|
106
17
|
color: #333;
|
|
107
18
|
|
|
19
|
+
/* .data-table-sticky-cell {
|
|
20
|
+
box-shadow: 2px 0 0 #f1f3f8;
|
|
21
|
+
} */
|
|
22
|
+
|
|
108
23
|
.select-cell {
|
|
109
24
|
min-width: 40px !important;
|
|
110
25
|
|
|
@@ -119,90 +34,150 @@
|
|
|
119
34
|
}
|
|
120
35
|
}
|
|
121
36
|
|
|
122
|
-
|
|
123
37
|
thead {
|
|
124
38
|
margin-bottom: 1rem;
|
|
125
|
-
|
|
126
|
-
top: 0;
|
|
127
|
-
z-index: 1;
|
|
128
|
-
background-color: #fff;
|
|
39
|
+
background-color: inherit;
|
|
129
40
|
|
|
130
41
|
th {
|
|
131
|
-
|
|
132
|
-
top: 0;
|
|
133
|
-
z-index: 2;
|
|
134
|
-
background-color: #fff;
|
|
135
|
-
color: var(--tertiary-color);
|
|
42
|
+
color: #bdbaba;
|
|
136
43
|
min-width: 100px;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
44
|
+
position: relative;
|
|
45
|
+
z-index: 11;
|
|
46
|
+
background-color: inherit;
|
|
47
|
+
background-clip: padding-box;
|
|
48
|
+
|
|
49
|
+
.data-table-column-sort {
|
|
50
|
+
.bi-arrow-down-up {
|
|
51
|
+
font-size: 1rem;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.data-table-column-filter {
|
|
56
|
+
visibility: hidden;
|
|
57
|
+
margin-left: 4px;
|
|
140
58
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
59
|
+
&.active {
|
|
60
|
+
visibility: visible;
|
|
61
|
+
}
|
|
144
62
|
|
|
145
|
-
|
|
146
|
-
|
|
63
|
+
.data-table-column-filter-active {
|
|
64
|
+
color: var(--tertiary-color);
|
|
65
|
+
}
|
|
147
66
|
}
|
|
148
|
-
}
|
|
149
67
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
68
|
+
.data-table-column-sort {
|
|
69
|
+
visibility: hidden;
|
|
70
|
+
margin-left: 4px;
|
|
71
|
+
|
|
72
|
+
&.active {
|
|
73
|
+
visibility: visible;
|
|
74
|
+
}
|
|
153
75
|
|
|
154
|
-
|
|
155
|
-
|
|
76
|
+
.data-table-column-sort-active {
|
|
77
|
+
color: var(--tertiary-color);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:hover,
|
|
82
|
+
&:focus {
|
|
83
|
+
|
|
84
|
+
.data-table-column-filter,
|
|
85
|
+
.data-table-column-sort {
|
|
86
|
+
visibility: visible;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
156
89
|
}
|
|
157
90
|
|
|
158
|
-
.data-table-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
max-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
91
|
+
.data-table-filter-row {
|
|
92
|
+
th {
|
|
93
|
+
padding-top: 6px;
|
|
94
|
+
padding-bottom: 6px;
|
|
95
|
+
overflow: visible;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.data-table-filter-select {
|
|
99
|
+
width: 100%;
|
|
100
|
+
max-width: 100%;
|
|
101
|
+
|
|
102
|
+
button {
|
|
103
|
+
width: 100%;
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
padding: 4px 6px;
|
|
107
|
+
border: 1px solid #dedede;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.select-container-value {
|
|
111
|
+
display: block;
|
|
112
|
+
min-width: 0;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
text-overflow: ellipsis;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
font-size: 0.7rem;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.data-table-filter-input-wrapper {
|
|
121
|
+
width: 100%;
|
|
122
|
+
max-width: 100%;
|
|
123
|
+
overflow: visible;
|
|
124
|
+
box-sizing: border-box;
|
|
180
125
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
126
|
+
.input-clear-icon,
|
|
127
|
+
.clear-btn {
|
|
128
|
+
right: 5px;
|
|
129
|
+
|
|
130
|
+
.bi {
|
|
131
|
+
font-size: 0.8rem;
|
|
132
|
+
}
|
|
184
133
|
}
|
|
185
134
|
|
|
186
|
-
|
|
187
|
-
|
|
135
|
+
.input-container {
|
|
136
|
+
min-width: 0;
|
|
137
|
+
width: 100%;
|
|
188
138
|
}
|
|
189
139
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
background-color: #f8f9fa;
|
|
140
|
+
.select-container {
|
|
141
|
+
max-width: 100%;
|
|
142
|
+
min-width: 0;
|
|
194
143
|
}
|
|
195
144
|
|
|
196
|
-
.
|
|
197
|
-
|
|
198
|
-
|
|
145
|
+
.select-container-button {
|
|
146
|
+
max-width: 100%;
|
|
147
|
+
min-width: 0;
|
|
199
148
|
}
|
|
200
149
|
}
|
|
201
150
|
|
|
202
|
-
input {
|
|
203
|
-
|
|
151
|
+
.data-table-filter-input {
|
|
152
|
+
width: 100%;
|
|
153
|
+
max-width: 100%;
|
|
154
|
+
min-width: 0;
|
|
155
|
+
box-sizing: border-box;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
text-overflow: ellipsis;
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
border: 1px solid #c9cfdb;
|
|
160
|
+
border-radius: 6px;
|
|
161
|
+
padding: 4px 6px;
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
background-color: #fff;
|
|
164
|
+
color: #333;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.data-table-header-row {
|
|
169
|
+
th {
|
|
170
|
+
position: sticky;
|
|
171
|
+
top: 0;
|
|
172
|
+
z-index: 12;
|
|
173
|
+
background-color: #f9fbfc;
|
|
204
174
|
}
|
|
205
175
|
}
|
|
206
176
|
}
|
|
207
177
|
}
|
|
208
|
-
}
|
|
178
|
+
}
|
|
179
|
+
.data-table-action-icon {
|
|
180
|
+
cursor: pointer;
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
}
|
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { HTMLInputTypeAttribute } from "react";
|
|
2
|
+
import { EnumerableType } from "../_core/type/generiqueType";
|
|
3
|
+
import { TypeInputEnum } from "../form/form.enum";
|
|
2
4
|
|
|
3
|
-
export interface
|
|
5
|
+
export interface DataTableColumnsInterface<T> {
|
|
4
6
|
id: string;
|
|
5
7
|
label: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
sticky?: boolean;
|
|
6
11
|
minWidth?: number;
|
|
7
12
|
maxWidth?: number;
|
|
8
13
|
width?: number;
|
|
9
14
|
align?: "right" | "left" | "center";
|
|
15
|
+
alignText?: "right" | "left" | "center";
|
|
10
16
|
format?: (value: any) => string;
|
|
11
17
|
sortable?: boolean;
|
|
12
18
|
filterable?: boolean;
|
|
13
|
-
|
|
19
|
+
filterDataEnum?: EnumerableType[];
|
|
20
|
+
filterType?: TypeInputEnum;
|
|
14
21
|
editable?: boolean;
|
|
15
|
-
|
|
22
|
+
isUpdatable?: boolean;
|
|
16
23
|
options?: { label: string; value: string }[];
|
|
24
|
+
displayOverlay?: boolean;
|
|
25
|
+
onEditable?: (value: any, row: T) => boolean;
|
|
26
|
+
onChange?: (value: any, row: T) => void;
|
|
27
|
+
onEditByOverlay?: (value: any, row: T) => void;
|
|
17
28
|
onEdit?: (value: any, row: T) => void;
|
|
18
|
-
onEnter?: (value: any, row: T) => void;
|
|
19
29
|
onDisable?: (row: T) => boolean;
|
|
30
|
+
onEditTrigger?: "change" | "enter";
|
|
20
31
|
onRowStyle?: (row: T) => React.CSSProperties;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
withStepControls?: boolean | ((row: T) => boolean);
|
|
28
|
-
step?: number;
|
|
29
|
-
min?: number;
|
|
30
|
-
max?: number;
|
|
32
|
+
renderComponent?: (value: any, row: T) => JSX.Element;
|
|
33
|
+
openClickCell?: boolean;
|
|
34
|
+
handleClickCell?: (e: React.MouseEvent<HTMLTableCellElement>, row: T) => void;
|
|
35
|
+
renderClickCellComponent?: (value: any, row: T) => JSX.Element;
|
|
36
|
+
type: HTMLInputTypeAttribute | "select";
|
|
37
|
+
children?: DataTableColumnsInterface<T>[];
|
|
31
38
|
}
|
|
32
|
-
export interface
|
|
39
|
+
export interface DataTableActionsInterface<T> {
|
|
33
40
|
id: string;
|
|
34
41
|
label: string;
|
|
35
42
|
type: "button" | "link" | "icon";
|
|
36
43
|
classIcon?: string;
|
|
37
|
-
onClick: (row: T
|
|
44
|
+
onClick: (row: T) => void;
|
|
38
45
|
shouldDisplay?: (row: T) => boolean;
|
|
39
46
|
disabled?: boolean;
|
|
40
47
|
labelButton?: (row: T) => string;
|
|
41
48
|
visible?: boolean;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
focusNextRow?: boolean;
|
|
49
|
+
// Largeur (px) réservée à l'action ; la colonne des actions fait la somme des largeurs
|
|
50
|
+
width?: number;
|
|
45
51
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Button } from "../../button/Button";
|
|
2
2
|
import { Icon } from "../../icon/Icon";
|
|
3
|
-
import {
|
|
3
|
+
import { DataTableActionsInterface } from "../dataTable.interface";
|
|
4
4
|
type DataTableActionProps = {
|
|
5
|
-
action:
|
|
5
|
+
action: DataTableActionsInterface<any>;
|
|
6
6
|
row: any;
|
|
7
|
-
rowIndex?: number;
|
|
8
7
|
index?: number;
|
|
9
|
-
onFocusNextRow?: (rowIndex: number) => void;
|
|
10
8
|
};
|
|
11
9
|
export const DataTableAction = ({
|
|
12
10
|
action,
|
|
13
11
|
row,
|
|
14
|
-
rowIndex,
|
|
15
12
|
index,
|
|
16
|
-
onFocusNextRow,
|
|
17
13
|
}: DataTableActionProps) => {
|
|
18
14
|
let title = action.label;
|
|
19
15
|
const display = action.shouldDisplay ? action.shouldDisplay(row) : true;
|
|
@@ -21,27 +17,18 @@ export const DataTableAction = ({
|
|
|
21
17
|
if (action.labelButton) {
|
|
22
18
|
title = action.labelButton ? action.labelButton(row) : action.label;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
const handleClick = (e?: React.MouseEvent) => {
|
|
26
|
-
e?.stopPropagation();
|
|
27
|
-
action.onClick(row, rowIndex);
|
|
28
|
-
if (action.focusNextRow && rowIndex !== undefined) {
|
|
29
|
-
onFocusNextRow?.(rowIndex);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
20
|
return (
|
|
34
21
|
<>
|
|
35
22
|
{action.type === "button" && (
|
|
36
23
|
<Button
|
|
37
24
|
title={title}
|
|
38
25
|
key={`button-action-${action.id}-${index}`}
|
|
39
|
-
onClick={
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
width: action.width,
|
|
26
|
+
onClick={(e) => {
|
|
27
|
+
// évite de déclencher le onRowClick de la ligne
|
|
28
|
+
e?.stopPropagation?.();
|
|
29
|
+
action.onClick(row);
|
|
44
30
|
}}
|
|
31
|
+
disabled={action.disabled}
|
|
45
32
|
className={`data-table-action button--tertiary mr-2 w-100 ${
|
|
46
33
|
action.classIcon ? action.classIcon : ""
|
|
47
34
|
}`}
|
|
@@ -50,11 +37,13 @@ export const DataTableAction = ({
|
|
|
50
37
|
{action.type === "icon" && (
|
|
51
38
|
<div
|
|
52
39
|
key={`icon-action-${action.id}-${index}`}
|
|
53
|
-
className={`mr-2 `}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
className={`mr-2 data-table-action-icon`}
|
|
41
|
+
title={title}
|
|
42
|
+
role="button"
|
|
43
|
+
onClick={(e) => {
|
|
44
|
+
// évite de déclencher le onRowClick de la ligne
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
action.onClick(row);
|
|
58
47
|
}}
|
|
59
48
|
>
|
|
60
49
|
<Icon classIcon={action.classIcon ?? ""} key={action.id} />
|
|
@@ -1,27 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataTableSortDirection } from "../DataTable";
|
|
2
|
+
import { DataTableColumnsInterface } from "../dataTable.interface";
|
|
3
|
+
import { DataTableColumnFilter } from "./dataTableColumnFilter/DataTableColumnFilter";
|
|
4
|
+
import { DataTableColumnSort } from "./dataTableColumnSort/DataTableColumnSort";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
column: dataTableColumnsInterface<any>;
|
|
5
|
-
idx: number;
|
|
6
|
-
onColumnClick?: (column: dataTableColumnsInterface<any>) => void;
|
|
7
|
-
};
|
|
8
|
-
export const DataTableColumn = ({
|
|
6
|
+
export function DataTableColumn<T>({
|
|
9
7
|
column,
|
|
10
8
|
idx,
|
|
11
9
|
onColumnClick,
|
|
12
|
-
|
|
10
|
+
hasNestedColumns,
|
|
11
|
+
isFilterVisible,
|
|
12
|
+
onToggleFilterVisibility,
|
|
13
|
+
currentSortDirection,
|
|
14
|
+
onToggleSort,
|
|
15
|
+
stickyLeft,
|
|
16
|
+
stickyTop,
|
|
17
|
+
}: {
|
|
18
|
+
hasNestedColumns: boolean;
|
|
19
|
+
column: DataTableColumnsInterface<T>;
|
|
20
|
+
idx: number;
|
|
21
|
+
onColumnClick?: (column: DataTableColumnsInterface<T>) => void;
|
|
22
|
+
isFilterVisible?: boolean;
|
|
23
|
+
onToggleFilterVisibility?: (column: DataTableColumnsInterface<T>) => void;
|
|
24
|
+
currentSortDirection?: DataTableSortDirection | null;
|
|
25
|
+
onToggleSort?: (column: DataTableColumnsInterface<T>) => void;
|
|
26
|
+
stickyLeft?: number;
|
|
27
|
+
stickyTop?: number;
|
|
28
|
+
}) {
|
|
29
|
+
const hasChildren = !!column.children?.length;
|
|
30
|
+
const isSticky = stickyLeft !== undefined;
|
|
31
|
+
|
|
13
32
|
return (
|
|
14
33
|
<th
|
|
15
34
|
key={`colonne-${column.id}-${idx}`}
|
|
16
35
|
style={{
|
|
17
|
-
minWidth: column.minWidth,
|
|
18
|
-
maxWidth: column.maxWidth,
|
|
19
|
-
width: column.width,
|
|
20
|
-
textAlign: column.align
|
|
36
|
+
minWidth: hasChildren ? undefined : column.minWidth,
|
|
37
|
+
maxWidth: hasChildren ? undefined : column.maxWidth,
|
|
38
|
+
width: hasChildren ? undefined : column.width,
|
|
39
|
+
textAlign: column.align ?? "left",
|
|
40
|
+
alignContent: column.children ? "center" : "flex-end",
|
|
41
|
+
top: stickyTop,
|
|
42
|
+
...(isSticky
|
|
43
|
+
? {
|
|
44
|
+
position: "sticky",
|
|
45
|
+
left: stickyLeft,
|
|
46
|
+
zIndex: 13,
|
|
47
|
+
backgroundColor: "#f9fbfc",
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
21
50
|
}}
|
|
51
|
+
className={`${column.children ? "has-children" : ""} ${
|
|
52
|
+
isSticky ? "data-table-sticky-cell" : ""
|
|
53
|
+
}`.trim()}
|
|
54
|
+
colSpan={column.children?.length ?? 1}
|
|
55
|
+
rowSpan={!column.children?.length && hasNestedColumns ? 2 : 1}
|
|
22
56
|
onClick={() => onColumnClick?.(column)}
|
|
23
57
|
>
|
|
24
|
-
|
|
58
|
+
<div className="d-flex align-items-center">
|
|
59
|
+
<div className="flex-1">{column.label}</div>
|
|
60
|
+
{column.filterable && (
|
|
61
|
+
<DataTableColumnFilter
|
|
62
|
+
column={column}
|
|
63
|
+
isFilterVisible={isFilterVisible}
|
|
64
|
+
onToggleVisibility={onToggleFilterVisibility}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
{column.sortable && (
|
|
68
|
+
<DataTableColumnSort
|
|
69
|
+
column={column}
|
|
70
|
+
sortDirection={currentSortDirection}
|
|
71
|
+
onToggleSort={onToggleSort}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
25
75
|
</th>
|
|
26
76
|
);
|
|
27
|
-
}
|
|
77
|
+
}
|