@addsign/moje-agenda-shared-lib 1.0.61 → 2.0.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/assets/style.css +4369 -0
- package/dist/assets/tailwind.css +1249 -1231
- package/dist/components/Button.js +1 -1
- package/dist/components/datatable/DataTable.js +1 -1
- package/dist/components/datatable/DataTableServer.js +1 -1
- package/dist/components/form/AutocompleteSearchBar.js +1 -1
- package/dist/components/form/AutocompleteSearchBarServer.js +1 -1
- package/dist/components/form/FileInput.js +1 -1
- package/dist/components/form/FileInputMultiple.js +1 -1
- package/dist/components/form/FormField.js +1 -1
- package/dist/components/form/PositionsSelectorSingle.js +1 -1
- package/dist/components/form/SelectField.js +1 -1
- package/dist/components/profiles/ProfileOverview.js +1 -1
- package/dist/main.js +1 -1
- package/dist/tailwind-l0sNRNKZ.js +2 -0
- package/dist/tailwind-l0sNRNKZ.js.map +1 -0
- package/lib/components/Button.tsx +57 -0
- package/lib/components/Calendar.tsx +242 -0
- package/lib/components/ConfirmationModalDialog.tsx +115 -0
- package/lib/components/Modal.tsx +73 -0
- package/lib/components/ModalDialog.tsx +63 -0
- package/lib/components/Spinner.tsx +25 -0
- package/lib/components/SpinnerIcon.tsx +12 -0
- package/lib/components/datatable/DataTable.tsx +442 -0
- package/lib/components/datatable/DataTableServer.tsx +939 -0
- package/lib/components/datatable/DatatableSettings.tsx +48 -0
- package/lib/components/datatable/Resizable.tsx +99 -0
- package/lib/components/datatable/types.ts +33 -0
- package/lib/components/form/AutocompleteSearchBar.tsx +424 -0
- package/lib/components/form/AutocompleteSearchBarServer.tsx +257 -0
- package/lib/components/form/DateField.tsx +124 -0
- package/lib/components/form/DateRangeField.tsx +116 -0
- package/lib/components/form/FileInput.tsx +188 -0
- package/lib/components/form/FileInputMultiple.tsx +186 -0
- package/lib/components/form/FormField.tsx +371 -0
- package/lib/components/form/InputField.tsx +230 -0
- package/lib/components/form/PositionsSelectorSingle.tsx +266 -0
- package/lib/components/form/RadioGroup.tsx +64 -0
- package/lib/components/form/SelectField.tsx +267 -0
- package/lib/components/layout/IconInCircle.tsx +29 -0
- package/lib/components/layout/PageTitle.tsx +19 -0
- package/lib/components/layout/SectionTitle.tsx +22 -0
- package/lib/components/profiles/ProfileOverview.tsx +212 -0
- package/lib/components/ui/Calendar.tsx +68 -0
- package/lib/components/ui/Combobox.tsx +122 -0
- package/lib/components/ui/DatePicker.tsx +124 -0
- package/lib/components/ui/DateTimePicker.tsx +187 -0
- package/lib/components/ui/Dialog.tsx +118 -0
- package/lib/components/ui/ScrollArea.tsx +45 -0
- package/lib/components/ui/button.tsx +56 -0
- package/lib/components/ui/command.tsx +153 -0
- package/lib/components/ui/form.tsx +177 -0
- package/lib/components/ui/input.tsx +22 -0
- package/lib/components/ui/label.tsx +24 -0
- package/lib/components/ui/popover.tsx +31 -0
- package/lib/components/ui/radioGroup.tsx +44 -0
- package/lib/components/ui/select.tsx +158 -0
- package/lib/contexts/FederationContext.tsx +28 -0
- package/lib/contexts/useFederationContext.ts +4 -0
- package/lib/css/tailwind.css +10 -0
- package/lib/fonts/arial.ts +3 -0
- package/lib/fonts/arialBold.ts +4 -0
- package/lib/main.ts +64 -0
- package/lib/types.ts +492 -0
- package/lib/utils/PdfManager.ts +224 -0
- package/lib/utils/getFullName.tsx +83 -0
- package/lib/utils/getIntersectingDays.ts +28 -0
- package/lib/utils/handleErrors.ts +28 -0
- package/lib/utils/hasRightInModule.ts +17 -0
- package/lib/utils/hasRole.ts +12 -0
- package/lib/utils/utils.ts +6 -0
- package/lib/vite-env.d.ts +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default function Spinner() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="flex flex-col items-center justify-center align-middle h-full ">
|
|
4
|
+
<div role="status">
|
|
5
|
+
<svg
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
className="inline w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
|
8
|
+
viewBox="0 0 100 101"
|
|
9
|
+
fill="none"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
<path
|
|
17
|
+
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
18
|
+
fill="currentFill"
|
|
19
|
+
/>
|
|
20
|
+
</svg>
|
|
21
|
+
<span className="sr-only">Loading...</span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FaSpinner } from "react-icons/fa";
|
|
3
|
+
|
|
4
|
+
type SpinnerIconProps = {
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const SpinnerIcon: React.FC<SpinnerIconProps> = ({ icon = <FaSpinner /> }) => {
|
|
9
|
+
return <div className="animate-spin">{icon}</div>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default SpinnerIcon;
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { Button, FormField, Spinner } from "../../main";
|
|
4
|
+
import {
|
|
5
|
+
MdArrowBack,
|
|
6
|
+
MdArrowDownward,
|
|
7
|
+
MdArrowForward,
|
|
8
|
+
MdArrowUpward,
|
|
9
|
+
MdClose,
|
|
10
|
+
MdOutlineFilterAlt,
|
|
11
|
+
MdOutlineFilterAltOff,
|
|
12
|
+
MdSearch,
|
|
13
|
+
} from "react-icons/md";
|
|
14
|
+
|
|
15
|
+
export interface DataTableColumn<T> {
|
|
16
|
+
key: keyof T | "actions";
|
|
17
|
+
header: string;
|
|
18
|
+
render?: (item: T) => React.ReactNode;
|
|
19
|
+
actions?: DataTableAction<T>[];
|
|
20
|
+
filterType?: string;
|
|
21
|
+
classes?: string;
|
|
22
|
+
type?: "string" | "number" | "date";
|
|
23
|
+
filterOperator?: ">=" | "<=" | "==";
|
|
24
|
+
}
|
|
25
|
+
export interface DataTableAction<T> {
|
|
26
|
+
label: string;
|
|
27
|
+
onClick: (item: T) => void;
|
|
28
|
+
visible?: (item: T) => boolean;
|
|
29
|
+
icon?: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
interface DataTableProps<T> {
|
|
32
|
+
items: T[];
|
|
33
|
+
columns: DataTableColumn<T | "actions">[];
|
|
34
|
+
itemsPerPage?: number;
|
|
35
|
+
title?: string;
|
|
36
|
+
subtitle?: string;
|
|
37
|
+
allowSearch?: boolean;
|
|
38
|
+
isLoading?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type DataTableInternalItems = {
|
|
42
|
+
_isHighlighted?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function DataTable<T extends DataTableInternalItems>({
|
|
46
|
+
items,
|
|
47
|
+
columns,
|
|
48
|
+
itemsPerPage = 10,
|
|
49
|
+
title,
|
|
50
|
+
subtitle,
|
|
51
|
+
allowSearch = true,
|
|
52
|
+
isLoading,
|
|
53
|
+
}: DataTableProps<T>) {
|
|
54
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
55
|
+
const [fulltextSearch, setFulltextSearch] = useState("");
|
|
56
|
+
const [filterOptions, setFilterOptions] = useState<Record<string, any[]>>({});
|
|
57
|
+
const [columnFilters, setColumnFilters] = useState<Record<string, string>>(
|
|
58
|
+
{}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const [showColFilters, setShowColFilters] = useState(false);
|
|
62
|
+
|
|
63
|
+
const [sortConfig, setSortConfig] = useState<{
|
|
64
|
+
key: keyof T | "actions";
|
|
65
|
+
direction: "ascending" | "descending" | null;
|
|
66
|
+
} | null>(null);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const newFilterOptions: Record<string, any[]> = {};
|
|
70
|
+
|
|
71
|
+
columns.forEach((column) => {
|
|
72
|
+
if (column.filterType && items.length > 0) {
|
|
73
|
+
const uniqueOptions = new Set(
|
|
74
|
+
items.map((item) => item[column.key as keyof T])
|
|
75
|
+
);
|
|
76
|
+
// Convert Set to an array of { value, label } objects
|
|
77
|
+
let sortedOptions = Array.from(uniqueOptions).map((option) => ({
|
|
78
|
+
value: option,
|
|
79
|
+
label:
|
|
80
|
+
column.type === "date"
|
|
81
|
+
? new Date(option as string)?.toLocaleDateString()
|
|
82
|
+
: option,
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
// Sort the options array by label in ascending alphabetical order
|
|
86
|
+
if (column.type === "date") {
|
|
87
|
+
// Convert labels to timestamps and sort accordingly
|
|
88
|
+
sortedOptions = sortedOptions.sort((a, b) => {
|
|
89
|
+
const timestampA = new Date(a.value as string).getTime();
|
|
90
|
+
const timestampB = new Date(b.value as string).getTime();
|
|
91
|
+
return timestampA - timestampB;
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
// Sort alphabetically by label for non-date columns
|
|
95
|
+
sortedOptions = sortedOptions.sort((a, b) =>
|
|
96
|
+
(a.label as string)?.localeCompare(b.label as string)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Add a default option if needed
|
|
101
|
+
newFilterOptions[column.key as string] = [
|
|
102
|
+
{ value: "", label: "" },
|
|
103
|
+
...sortedOptions,
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
setFilterOptions(newFilterOptions);
|
|
109
|
+
}, [items, columns]);
|
|
110
|
+
|
|
111
|
+
const requestSort = (key: keyof T | "actions") => {
|
|
112
|
+
if (sortConfig?.key === key && sortConfig.direction !== null) {
|
|
113
|
+
setSortConfig({
|
|
114
|
+
key,
|
|
115
|
+
direction: sortConfig.direction === "ascending" ? "descending" : null,
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
setSortConfig({ key, direction: "ascending" });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const getSortIcon = (key: keyof T | "actions") => {
|
|
123
|
+
if (sortConfig?.key === key) {
|
|
124
|
+
return sortConfig.direction === "ascending" ? (
|
|
125
|
+
<MdArrowUpward fontSize="small" />
|
|
126
|
+
) : sortConfig.direction === "descending" ? (
|
|
127
|
+
<MdArrowDownward fontSize="small" />
|
|
128
|
+
) : (
|
|
129
|
+
<MdArrowUpward
|
|
130
|
+
fontSize="small"
|
|
131
|
+
className="text-gray-300 invisible group-hover:visible "
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return (
|
|
136
|
+
<MdArrowUpward
|
|
137
|
+
fontSize="small"
|
|
138
|
+
className="text-gray-300 invisible group-hover:visible "
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const sortedItems = sortConfig?.direction
|
|
144
|
+
? [...items].sort((a, b) => {
|
|
145
|
+
const aValue = a[sortConfig.key as keyof T];
|
|
146
|
+
const bValue = b[sortConfig.key as keyof T];
|
|
147
|
+
|
|
148
|
+
// Check if values are Date objects
|
|
149
|
+
if (aValue instanceof Date && bValue instanceof Date) {
|
|
150
|
+
return sortConfig.direction === "ascending"
|
|
151
|
+
? aValue.getTime() - bValue.getTime()
|
|
152
|
+
: bValue.getTime() - aValue.getTime();
|
|
153
|
+
}
|
|
154
|
+
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
155
|
+
return sortConfig.direction === "ascending"
|
|
156
|
+
? aValue - bValue
|
|
157
|
+
: bValue - aValue;
|
|
158
|
+
}
|
|
159
|
+
return sortConfig.direction === "ascending"
|
|
160
|
+
? String(aValue).localeCompare(String(bValue))
|
|
161
|
+
: String(bValue).localeCompare(String(aValue));
|
|
162
|
+
})
|
|
163
|
+
: items;
|
|
164
|
+
|
|
165
|
+
// const searchableKeys = new Set(
|
|
166
|
+
// columns.filter((col) => !col.actions).map((col) => col.key)
|
|
167
|
+
// );
|
|
168
|
+
|
|
169
|
+
const filteredItems = sortedItems.filter((item: any) => {
|
|
170
|
+
const textSearchMatch = fulltextSearch
|
|
171
|
+
? columns.some((column) => {
|
|
172
|
+
const value = item[column.key];
|
|
173
|
+
return (
|
|
174
|
+
(typeof value === "string" || typeof value === "number") &&
|
|
175
|
+
value
|
|
176
|
+
.toString()
|
|
177
|
+
.toLowerCase()
|
|
178
|
+
.includes(fulltextSearch.toLowerCase())
|
|
179
|
+
);
|
|
180
|
+
})
|
|
181
|
+
: true;
|
|
182
|
+
|
|
183
|
+
const columnFiltersMatch = columns.every((column) => {
|
|
184
|
+
// debugger;
|
|
185
|
+
const filterValue = columnFilters[column.key as string];
|
|
186
|
+
if (!filterValue) return true; // Ignore filter if 'None' is selected
|
|
187
|
+
|
|
188
|
+
const itemValue = item[column.key];
|
|
189
|
+
if ((column.type || typeof itemValue) === "string") {
|
|
190
|
+
if (column.filterOperator == ">=") {
|
|
191
|
+
return itemValue.toLowerCase() >= filterValue.toLowerCase();
|
|
192
|
+
} else if (column.filterOperator == "<=") {
|
|
193
|
+
return itemValue.toLowerCase() <= filterValue.toLowerCase();
|
|
194
|
+
}
|
|
195
|
+
if (column.filterType == "text") {
|
|
196
|
+
return itemValue.toLowerCase().includes(filterValue.toLowerCase());
|
|
197
|
+
} else {
|
|
198
|
+
return itemValue.toLowerCase() == filterValue.toLowerCase();
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
if (column.filterOperator == ">=") {
|
|
202
|
+
return itemValue >= filterValue;
|
|
203
|
+
} else if (column.filterOperator == "<=") {
|
|
204
|
+
return itemValue <= filterValue;
|
|
205
|
+
} else {
|
|
206
|
+
return itemValue == filterValue;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return textSearchMatch && columnFiltersMatch;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Pagination logic
|
|
215
|
+
const indexOfLastItem = (currentPage + 1) * itemsPerPage;
|
|
216
|
+
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
|
|
217
|
+
const currentItems = filteredItems.slice(indexOfFirstItem, indexOfLastItem);
|
|
218
|
+
|
|
219
|
+
const nextPage = () => {
|
|
220
|
+
setCurrentPage(currentPage + 1);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const prevPage = () => {
|
|
224
|
+
setCurrentPage(currentPage - 1);
|
|
225
|
+
};
|
|
226
|
+
const handleSearchChanged = (
|
|
227
|
+
e: React.ChangeEvent<
|
|
228
|
+
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
|
|
229
|
+
>
|
|
230
|
+
) => {
|
|
231
|
+
setFulltextSearch(e.target?.value);
|
|
232
|
+
setCurrentPage(0);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const totalPages = Math.max(
|
|
236
|
+
1,
|
|
237
|
+
Math.ceil(filteredItems.length / itemsPerPage)
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// Pagination display logic
|
|
241
|
+
const paginationDisplay = `Strana ${currentPage + 1} z ${totalPages}`;
|
|
242
|
+
|
|
243
|
+
const filterHandler = (key: keyof T, value: string) => {
|
|
244
|
+
setColumnFilters((prev) => ({ ...prev, [key]: value }));
|
|
245
|
+
setCurrentPage(0);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
if (isLoading) return <Spinner />;
|
|
249
|
+
return (
|
|
250
|
+
<>
|
|
251
|
+
<div className="container shadow-lg border border-gray-200 rounded-xl overflow-hidden ">
|
|
252
|
+
{(title || subtitle || allowSearch) && (
|
|
253
|
+
<div className="p-5 leading-9 flex ">
|
|
254
|
+
<div className="flex-grow">
|
|
255
|
+
{title && (
|
|
256
|
+
<h1 className="font-semibold text-xl leading-[42px] ">
|
|
257
|
+
{title}
|
|
258
|
+
</h1>
|
|
259
|
+
)}
|
|
260
|
+
{subtitle && (
|
|
261
|
+
<p className="font-normal text-gray-600">{subtitle}</p>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
<div
|
|
265
|
+
className="flex items-center text-xl h-full p-3 mr-5 cursor-pointer text-gray-500 "
|
|
266
|
+
onClick={() => setShowColFilters(!showColFilters)}
|
|
267
|
+
>
|
|
268
|
+
{!showColFilters && <MdOutlineFilterAlt />}
|
|
269
|
+
{showColFilters && <MdOutlineFilterAltOff />}
|
|
270
|
+
</div>
|
|
271
|
+
{allowSearch && (
|
|
272
|
+
<div className="">
|
|
273
|
+
<FormField
|
|
274
|
+
placeholder="Vyhledávání"
|
|
275
|
+
name="search"
|
|
276
|
+
onInputChange={handleSearchChanged}
|
|
277
|
+
type="text"
|
|
278
|
+
value={fulltextSearch}
|
|
279
|
+
>
|
|
280
|
+
{" "}
|
|
281
|
+
<div className=" text-gray-500 leading-5 flex items-center h-full">
|
|
282
|
+
{!fulltextSearch && <MdSearch></MdSearch>}
|
|
283
|
+
{fulltextSearch && (
|
|
284
|
+
<MdClose onClick={() => setFulltextSearch("")}></MdClose>
|
|
285
|
+
)}
|
|
286
|
+
</div>
|
|
287
|
+
</FormField>
|
|
288
|
+
</div>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
)}
|
|
292
|
+
<div className="overflow-x-auto">
|
|
293
|
+
<table className="w-full leading-normal">
|
|
294
|
+
<thead>
|
|
295
|
+
{showColFilters &&
|
|
296
|
+
columns.findIndex((it) => it.filterType) > -1 && (
|
|
297
|
+
<tr>
|
|
298
|
+
{columns.map(({ key, header, filterType }) => (
|
|
299
|
+
<th
|
|
300
|
+
key={String(key) + "_filter"}
|
|
301
|
+
// className="cursor-pointer px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-sm font-medium text-gray-600 uppercase tracking-wider"
|
|
302
|
+
className={` font-medium cursor-pointer !leading-9 text-xs text-left pl-5 pb-5 text-gray-600 ${
|
|
303
|
+
!title && !subtitle ? "border-t-0" : ""
|
|
304
|
+
}`}
|
|
305
|
+
>
|
|
306
|
+
{filterType && (
|
|
307
|
+
<FormField
|
|
308
|
+
label={header}
|
|
309
|
+
name={String(key) + "_filter"}
|
|
310
|
+
onInputChange={(e) =>
|
|
311
|
+
filterHandler(key as keyof T, e.target.value)
|
|
312
|
+
}
|
|
313
|
+
type={filterType}
|
|
314
|
+
options={filterOptions[String(key)] || []}
|
|
315
|
+
value={columnFilters[String(key)]}
|
|
316
|
+
clearable
|
|
317
|
+
></FormField>
|
|
318
|
+
)}
|
|
319
|
+
</th>
|
|
320
|
+
))}
|
|
321
|
+
</tr>
|
|
322
|
+
)}
|
|
323
|
+
<tr>
|
|
324
|
+
{columns.map(({ key, header, actions }) => (
|
|
325
|
+
<th
|
|
326
|
+
key={String(key)}
|
|
327
|
+
// className="cursor-pointer px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-sm font-medium text-gray-600 uppercase tracking-wider"
|
|
328
|
+
className={`group font-medium cursor-pointer !leading-9 text-xs text-left px-5 text-gray-600 bg bg-gray-50 border-t border-b border-gray-200 ${
|
|
329
|
+
!title && !subtitle ? "border-t-0" : ""
|
|
330
|
+
}`}
|
|
331
|
+
onClick={() => requestSort(key)}
|
|
332
|
+
>
|
|
333
|
+
<span className="inline-flex items-center gap-2">
|
|
334
|
+
{header} {!actions ? getSortIcon(key) : ""}
|
|
335
|
+
</span>
|
|
336
|
+
</th>
|
|
337
|
+
))}
|
|
338
|
+
</tr>
|
|
339
|
+
</thead>
|
|
340
|
+
|
|
341
|
+
<tbody>
|
|
342
|
+
{currentItems.map((item, rowIndex) => (
|
|
343
|
+
<tr
|
|
344
|
+
key={rowIndex}
|
|
345
|
+
className={`${
|
|
346
|
+
item._isHighlighted ? " bg-gray-200 " : " "
|
|
347
|
+
} hover:bg-gray-50 border-gray-200 border-b text-sm `}
|
|
348
|
+
>
|
|
349
|
+
{columns.map(({ render, actions, classes }, colIndex) => (
|
|
350
|
+
<td
|
|
351
|
+
key={`${rowIndex}-${colIndex}`}
|
|
352
|
+
className={`px-5 py-2
|
|
353
|
+
${
|
|
354
|
+
colIndex == 0
|
|
355
|
+
? " font-medium text-gray-900"
|
|
356
|
+
: " text-gray-700"
|
|
357
|
+
} ${classes}`}
|
|
358
|
+
>
|
|
359
|
+
{render ? render(item) : ""}
|
|
360
|
+
{actions &&
|
|
361
|
+
actions
|
|
362
|
+
.filter((it) => {
|
|
363
|
+
if (it.visible) {
|
|
364
|
+
return it.visible(item);
|
|
365
|
+
} else true;
|
|
366
|
+
})
|
|
367
|
+
.map((action, actionIndex) => (
|
|
368
|
+
<div
|
|
369
|
+
key={`${rowIndex}-${colIndex}-${actionIndex}`}
|
|
370
|
+
className="inline-flex align-middle"
|
|
371
|
+
>
|
|
372
|
+
{action.icon && (
|
|
373
|
+
<Button
|
|
374
|
+
variant="icon"
|
|
375
|
+
onClick={() => action.onClick(item)}
|
|
376
|
+
>
|
|
377
|
+
{" "}
|
|
378
|
+
{action.icon}
|
|
379
|
+
</Button>
|
|
380
|
+
)}
|
|
381
|
+
{!action.icon && (
|
|
382
|
+
<Button
|
|
383
|
+
variant="transparent"
|
|
384
|
+
onClick={() => action.onClick(item)}
|
|
385
|
+
>
|
|
386
|
+
{" "}
|
|
387
|
+
{action.label}
|
|
388
|
+
</Button>
|
|
389
|
+
)}
|
|
390
|
+
</div>
|
|
391
|
+
))}
|
|
392
|
+
</td>
|
|
393
|
+
))}
|
|
394
|
+
</tr>
|
|
395
|
+
))}
|
|
396
|
+
{currentItems.length == 0 && (
|
|
397
|
+
<tr key="tr-nodata ">
|
|
398
|
+
<td
|
|
399
|
+
key="td-nodata"
|
|
400
|
+
className="px-5 py-3 border-b border-gray-200 bg-white text-sm items-center justify-center align-middle"
|
|
401
|
+
colSpan={columns.length}
|
|
402
|
+
>
|
|
403
|
+
Žádná data
|
|
404
|
+
</td>
|
|
405
|
+
</tr>
|
|
406
|
+
)}
|
|
407
|
+
</tbody>
|
|
408
|
+
</table>
|
|
409
|
+
</div>
|
|
410
|
+
<div className="w-full p-5 grid grid-cols-3">
|
|
411
|
+
<div className="text-left items-start justify-start">
|
|
412
|
+
{currentPage !== 0 && (
|
|
413
|
+
<Button
|
|
414
|
+
variant="secondary"
|
|
415
|
+
onClick={prevPage}
|
|
416
|
+
className="flex items-center float-left"
|
|
417
|
+
>
|
|
418
|
+
<MdArrowBack className="mr-1.5" /> Předchozí
|
|
419
|
+
</Button>
|
|
420
|
+
)}
|
|
421
|
+
</div>
|
|
422
|
+
<div className=" text-center text-xs text-gray-800">
|
|
423
|
+
{paginationDisplay} {/* Updated to use dynamic page numbers */}
|
|
424
|
+
</div>
|
|
425
|
+
<div className="text-right items-end justify-end">
|
|
426
|
+
{indexOfLastItem < filteredItems.length && (
|
|
427
|
+
<Button
|
|
428
|
+
variant="secondary"
|
|
429
|
+
onClick={nextPage}
|
|
430
|
+
className="flex items-center float-right"
|
|
431
|
+
>
|
|
432
|
+
Následující <MdArrowForward className="ml-2" size={20} />
|
|
433
|
+
</Button>
|
|
434
|
+
)}
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
</>
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export default DataTable;
|