@inceptionbg/iui 2.0.7 → 2.0.10
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/NoAccessPage-DBq5IzIf.js +2 -0
- package/dist/{NoAccessPage-BozT_Suz.js.map → NoAccessPage-DBq5IzIf.js.map} +1 -1
- package/dist/NotFoundPage-DM-I96ar.js +2 -0
- package/dist/{NotFoundPage-WWiekDef.js.map → NotFoundPage-DM-I96ar.js.map} +1 -1
- package/dist/icons/index.d.ts +2 -2
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +286 -259
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/iui.css +1 -1
- package/idea/GridTable/GridTable.tsx +119 -0
- package/idea/GridTable/gridTable.scss +42 -0
- package/{src/components → idea}/Table/Components/Print/CustomTablePrint.tsx +2 -2
- package/{src/components → idea}/Table/Components/Print/TablePrint.tsx +2 -2
- package/{src/components → idea}/Table/Components/SetTableFilter.tsx +1 -1
- package/{src/components → idea}/Table/Components/TableOptions.tsx +4 -4
- package/idea/{Table2 → Table}/Table.tsx +151 -281
- package/idea/Table/hooks/useDefaultTemplate.ts +20 -0
- package/{src/components → idea}/Table/hooks/useTableKeyboard.ts +1 -2
- package/idea/Table/hooks/useTableSelect.ts +11 -0
- package/package.json +3 -2
- package/src/assets/icons/index.ts +1 -1
- package/src/assets/icons/light/faClipboardCheck.ts +15 -0
- package/src/assets/icons/light/faHouse.ts +15 -15
- package/src/assets/icons/light/faIdBadge.ts +15 -15
- package/src/assets/icons/light/faPen.ts +15 -0
- package/src/components/Button/IconButton.tsx +3 -1
- package/src/components/Dialog/Dialog.tsx +60 -124
- package/src/components/Dialog/components/DialogFooter.tsx +92 -0
- package/src/components/Dialog/hooks/useDialogKeyboard.ts +6 -5
- package/src/components/Header/Components/ModuleSelect.tsx +1 -1
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/Inputs/DateInput/DateInput.tsx +108 -101
- package/src/components/Inputs/DateInput/components/DatePartInput.tsx +7 -3
- package/src/components/Inputs/InputWrapper.tsx +6 -1
- package/src/components/Inputs/SearchInput.tsx +9 -4
- package/src/components/Inputs/Select2/Select.tsx +65 -30
- package/src/components/Inputs/Select2/select.scss +13 -14
- package/src/components/Inputs/Selects/components/SelectWrapper.tsx +4 -2
- package/src/components/Inputs/Selects/utils/selectStyles.ts +9 -12
- package/src/components/Menu/Menu.tsx +10 -2
- package/src/components/Menu/MenuItem.tsx +11 -10
- package/src/components/Menu/hooks/useMenuPosition.tsx +23 -6
- package/src/components/Pullover/Pullover.tsx +122 -59
- package/src/components/Table/Table.tsx +78 -342
- package/src/components/Table/components/edit/TableEditRow.tsx +69 -0
- package/src/components/Table/components/filters/FilterItem.tsx +15 -0
- package/src/components/Table/components/filters/TableFilters.tsx +125 -0
- package/src/components/Table/components/footer/TableFooter.tsx +128 -0
- package/src/components/Table/components/header/TableHeader.tsx +42 -0
- package/src/components/Table/components/header/TableHeaderRow.tsx +47 -0
- package/src/components/Table/components/items/TableItemActions.tsx +66 -0
- package/src/components/Table/components/select/TableSelect.tsx +49 -0
- package/src/components/Table/components/sort/TableSort.tsx +52 -0
- package/src/components/Table/contexts/TableContext.tsx +123 -0
- package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +73 -0
- package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +78 -0
- package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +173 -0
- package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +12 -0
- package/src/components/Table/hooks/useTableEdit.tsx +111 -0
- package/src/components/Table/hooks/useTableFilterFields.tsx +150 -0
- package/src/components/Table/hooks/useTablePagination.ts +16 -0
- package/src/components/Table/hooks/useTableSearch.ts +29 -0
- package/src/components/Table/hooks/useTableSort.ts +8 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/Wrappers/PageLayout.tsx +13 -18
- package/src/hooks/useGetFocusableElements.ts +42 -0
- package/src/hooks/useLocalPopoverControl.ts +38 -0
- package/src/hooks/usePopupControl.ts +13 -0
- package/src/index.ts +53 -39
- package/src/styles/common/_typography.scss +3 -0
- package/src/styles/common/helpers/_size.scss +1 -1
- package/src/styles/components/_accordions.scss +1 -1
- package/src/styles/components/_badge.scss +4 -3
- package/src/styles/components/_card.scss +1 -1
- package/src/styles/components/_dialog.scss +15 -13
- package/src/styles/components/_input.scss +1 -1
- package/src/styles/components/_inputCheckbox.scss +1 -1
- package/src/styles/components/_inputDateTime.scss +2 -2
- package/src/styles/components/_inputRadio.scss +1 -1
- package/src/styles/components/_inputSelect.scss +6 -4
- package/src/styles/components/_menu-v2.scss +1 -1
- package/src/styles/components/_menu.scss +23 -15
- package/src/styles/components/_page.scss +3 -2
- package/src/styles/components/_pullover.scss +74 -18
- package/src/styles/components/_table.scss +151 -142
- package/src/styles/components/_widget.scss +1 -1
- package/src/styles/variables/_bp.scss +1 -0
- package/src/styles/variables/_variables.scss +4 -2
- package/src/types/IKeyboard.ts +2 -1
- package/src/types/IMenu.ts +1 -0
- package/src/types/ISelect.ts +1 -0
- package/src/types/ITable.ts +87 -80
- package/src/utils/fileUtils.ts +7 -6
- package/src/utils/i18n/i18nIUICyrilic.ts +4 -0
- package/src/utils/i18n/i18nIUILatin.ts +3 -1
- package/src/utils/i18n/i18nIUIMe.ts +4 -0
- package/src/utils/{ObjectUtils.ts → objectUtils.ts} +8 -8
- package/src/utils/popupUtils.ts +82 -0
- package/src/utils/{TableUtils.ts → tableUtils.ts} +5 -5
- package/src/utils/{Toasts.ts → toasts.ts} +6 -6
- package/src/utils/{UrlUtils.ts → urlUtils.ts} +4 -4
- package/dist/NoAccessPage-BozT_Suz.js +0 -2
- package/dist/NotFoundPage-WWiekDef.js +0 -2
- package/idea/Table2/Components/Columns/ColumnsList.tsx +0 -56
- package/idea/Table2/Components/Columns/SetColumnsList.tsx +0 -107
- package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +0 -87
- package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +0 -32
- package/idea/Table2/Components/Edit/TableEditRow.tsx +0 -56
- package/idea/Table2/Components/FilterItem.tsx +0 -20
- package/idea/Table2/Components/Header/TableHeader.tsx +0 -35
- package/idea/Table2/Components/Header/TableHeaderRow.tsx +0 -37
- package/idea/Table2/Components/Print/CustomTablePrint.tsx +0 -119
- package/idea/Table2/Components/Print/TablePrint.tsx +0 -208
- package/idea/Table2/Components/SetSortList.tsx +0 -33
- package/idea/Table2/Components/SetTableFilter.tsx +0 -90
- package/idea/Table2/Components/TableFooter.tsx +0 -107
- package/idea/Table2/Components/TableOptions.tsx +0 -211
- package/idea/Table2/Components/Templates/TemplateCreate.tsx +0 -75
- package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +0 -45
- package/idea/Table2/Components/Templates/TemplateList.tsx +0 -167
- package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +0 -51
- package/idea/Table2/_table.scss +0 -300
- package/idea/Table2/hooks/useDefaultTemplate.ts +0 -22
- package/idea/Table2/hooks/useTableKeyboard.ts +0 -115
- package/src/assets/icons/light/faPenField.ts +0 -15
- package/src/assets/icons/solid/faMagnifyingGlass.ts +0 -15
- package/src/components/Dialog/DeleteItemDialog.tsx +0 -52
- package/src/components/Dialog/hooks/useDialogObserver.ts +0 -21
- /package/{src/components → idea}/Table/Components/Columns/ColumnsList.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Columns/SetColumnsList.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Edit/ItemActionsMenu.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Edit/TableEditRow.tsx +0 -0
- /package/{src/components → idea}/Table/Components/FilterItem.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Header/TableHeader.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Header/TableHeaderRow.tsx +0 -0
- /package/{src/components → idea}/Table/Components/SetSortList.tsx +0 -0
- /package/{src/components → idea}/Table/Components/TableFooter.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Templates/TemplateCreate.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Templates/TemplateCreateDefault.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Templates/TemplateList.tsx +0 -0
- /package/{src/components → idea}/Table/Components/Templates/repo/TemplateRepo.ts +0 -0
- /package/src/utils/{DateUtils.ts → dateUtils.ts} +0 -0
- /package/src/utils/{LocalStorageHelper.ts → localStorageHelper.ts} +0 -0
- /package/src/utils/{NumberUtils.ts → numberUtils.ts} +0 -0
- /package/src/utils/{RootDir.ts → rootDir.ts} +0 -0
- /package/src/utils/{StringUtils.ts → stringUtils.ts} +0 -0
|
@@ -15,14 +15,12 @@ import { TableOptions } from './Components/TableOptions';
|
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { Checkbox } from '../Inputs/Checkbox';
|
|
17
17
|
import { Menu } from '../Menu/Menu';
|
|
18
|
-
import { faEllipsisVertical } from '../../icons/solid/faEllipsisVertical';
|
|
18
|
+
import { faEllipsisVertical } from '../../assets/icons/solid/faEllipsisVertical';
|
|
19
19
|
import { MenuItem } from '../Menu/MenuItem';
|
|
20
20
|
import { Button } from '../Button/Button';
|
|
21
21
|
import { useTableKeyboard } from './hooks/useTableKeyboard';
|
|
22
22
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
23
|
-
import { faPlus } from '../../icons/solid/faPlus';
|
|
24
|
-
|
|
25
|
-
import './table.scss';
|
|
23
|
+
import { faPlus } from '../../assets/icons/solid/faPlus';
|
|
26
24
|
|
|
27
25
|
export const Table: FC<ITable> = ({
|
|
28
26
|
columns,
|
|
@@ -30,7 +28,7 @@ export const Table: FC<ITable> = ({
|
|
|
30
28
|
withColumnsSearch,
|
|
31
29
|
customHeader,
|
|
32
30
|
data: tableData,
|
|
33
|
-
|
|
31
|
+
sumRows,
|
|
34
32
|
isLoading,
|
|
35
33
|
headerWrap,
|
|
36
34
|
serverSidePagination,
|
|
@@ -47,7 +45,8 @@ export const Table: FC<ITable> = ({
|
|
|
47
45
|
customPrintData,
|
|
48
46
|
templates,
|
|
49
47
|
additionsalOptions,
|
|
50
|
-
|
|
48
|
+
rowSelect,
|
|
49
|
+
rowHeight = 'm',
|
|
51
50
|
maxHeight,
|
|
52
51
|
editable,
|
|
53
52
|
keyboard,
|
|
@@ -59,7 +58,6 @@ export const Table: FC<ITable> = ({
|
|
|
59
58
|
const [extendedRow, setExtendedRow] = useState('');
|
|
60
59
|
const [editableData, setEditableData] = useState<object>({});
|
|
61
60
|
const [isAdding, setIsAdding] = useState(false);
|
|
62
|
-
const [selected, setSelected] = useState(new Set<string>());
|
|
63
61
|
const [selectedActionOpen, setSelectedActionOpen] = useState(false);
|
|
64
62
|
const [activeSelectOptions, setActiveSelectOptions] = useState<ITableSelectedActions[]>(
|
|
65
63
|
[]
|
|
@@ -68,16 +66,21 @@ export const Table: FC<ITable> = ({
|
|
|
68
66
|
const { t } = useTranslation();
|
|
69
67
|
|
|
70
68
|
const pagination = {
|
|
71
|
-
limit: serverSidePagination?.limit
|
|
72
|
-
offset: serverSidePagination?.offset
|
|
73
|
-
setLimit: serverSidePagination?.setLimit
|
|
74
|
-
setOffset: serverSidePagination?.setOffset
|
|
75
|
-
totalRows: serverSidePagination?.totalRows
|
|
69
|
+
limit: serverSidePagination?.limit ?? limit,
|
|
70
|
+
offset: serverSidePagination?.offset ?? offset,
|
|
71
|
+
setLimit: serverSidePagination?.setLimit ?? setLimit,
|
|
72
|
+
setOffset: serverSidePagination?.setOffset ?? setOffset,
|
|
73
|
+
totalRows: serverSidePagination?.totalRows ?? tableData.length,
|
|
76
74
|
};
|
|
77
75
|
|
|
78
76
|
const focusedRow = useTableKeyboard({
|
|
79
77
|
enabled: !!keyboard?.enabled,
|
|
80
78
|
rows: data,
|
|
79
|
+
selected: {
|
|
80
|
+
enabled: !!rowSelect && activeSelectOptions.length > 0,
|
|
81
|
+
rows: rowSelect?.selectedRows ?? new Set<string>(),
|
|
82
|
+
resetSelected: () => rowSelect?.setSelectedRows(new Set<string>()),
|
|
83
|
+
},
|
|
81
84
|
actions: {
|
|
82
85
|
moveDisabled: !!keyboard?.actions?.moveDisabled || isAdding,
|
|
83
86
|
...keyboard?.actions,
|
|
@@ -114,62 +117,79 @@ export const Table: FC<ITable> = ({
|
|
|
114
117
|
}
|
|
115
118
|
},
|
|
116
119
|
},
|
|
120
|
+
{
|
|
121
|
+
key: ' ',
|
|
122
|
+
isActive: activeSelectOptions.length > 0 && !!focusedRow?.uuid,
|
|
123
|
+
onAction: () => {
|
|
124
|
+
const rowUuid = focusedRow?.uuid!;
|
|
125
|
+
const isRowSelected = rowSelect?.selectedRows.has(rowUuid);
|
|
126
|
+
rowSelect?.setSelectedRows(oldSet => {
|
|
127
|
+
const newSet = new Set(oldSet);
|
|
128
|
+
newSet[isRowSelected ? 'delete' : 'add'](rowUuid);
|
|
129
|
+
return newSet;
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
},
|
|
117
133
|
],
|
|
118
134
|
},
|
|
119
135
|
});
|
|
120
136
|
|
|
121
137
|
// Set Active Select Options
|
|
122
138
|
useEffect(() => {
|
|
123
|
-
|
|
124
|
-
setActiveSelectOptions(
|
|
125
|
-
}, [
|
|
139
|
+
rowSelect?.actions.length &&
|
|
140
|
+
setActiveSelectOptions(rowSelect.actions.filter(e => !e.hidden) || []);
|
|
141
|
+
}, [rowSelect?.actions]);
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}, [selectedOptions?.resetSelect]);
|
|
143
|
+
useEffect(
|
|
144
|
+
() => {
|
|
145
|
+
// Active Column
|
|
146
|
+
const activeColumns = columns.filter(e => !e.hidden && !e.unavailable);
|
|
133
147
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
width: '50px',
|
|
163
|
-
};
|
|
164
|
-
}
|
|
148
|
+
// Select Column
|
|
149
|
+
let selectCol;
|
|
150
|
+
if (rowSelect && activeSelectOptions.length > 0) {
|
|
151
|
+
const selectableData = data.filter(e => !e.disableSelect);
|
|
152
|
+
const selectedSome =
|
|
153
|
+
!!rowSelect.selectedRows.size &&
|
|
154
|
+
selectableData.some(e => !rowSelect.selectedRows.has(e.uuid));
|
|
155
|
+
const selectedAll = !!rowSelect.selectedRows.size && !selectedSome;
|
|
156
|
+
selectCol = {
|
|
157
|
+
id: 'select',
|
|
158
|
+
label: (
|
|
159
|
+
<Checkbox
|
|
160
|
+
value={selectedSome ? 'middle' : selectedAll}
|
|
161
|
+
// label={`${selected.size}`}
|
|
162
|
+
setValue={() => {
|
|
163
|
+
selectedAll
|
|
164
|
+
? rowSelect.setSelectedRows(new Set<string>())
|
|
165
|
+
: rowSelect.setSelectedRows(oldValue => {
|
|
166
|
+
let newSet = new Set(oldValue);
|
|
167
|
+
selectableData.forEach(e => newSet.add(e.uuid!));
|
|
168
|
+
return newSet;
|
|
169
|
+
});
|
|
170
|
+
}}
|
|
171
|
+
/>
|
|
172
|
+
),
|
|
173
|
+
width: '50px',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
165
176
|
|
|
166
|
-
|
|
177
|
+
let newCols: ITableColumn[] = [];
|
|
167
178
|
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
selectCol && newCols.push(selectCol);
|
|
180
|
+
newCols = newCols.concat(activeColumns);
|
|
170
181
|
|
|
171
|
-
|
|
172
|
-
|
|
182
|
+
setCols(newCols);
|
|
183
|
+
},
|
|
184
|
+
// eslint-disable-next-line
|
|
185
|
+
[
|
|
186
|
+
columns,
|
|
187
|
+
editable,
|
|
188
|
+
rowSelect?.selectedRows,
|
|
189
|
+
activeSelectOptions,
|
|
190
|
+
serverSidePagination,
|
|
191
|
+
]
|
|
192
|
+
);
|
|
173
193
|
|
|
174
194
|
useEffect(() => {
|
|
175
195
|
// const data = editable
|
|
@@ -193,15 +213,16 @@ export const Table: FC<ITable> = ({
|
|
|
193
213
|
? tableData
|
|
194
214
|
: tableData.slice(offset * limit, offset * limit + limit);
|
|
195
215
|
|
|
196
|
-
|
|
216
|
+
rowSelect &&
|
|
217
|
+
activeSelectOptions.length > 0 &&
|
|
197
218
|
data.map(
|
|
198
219
|
e =>
|
|
199
220
|
(e.cells.select = {
|
|
200
221
|
value: (
|
|
201
222
|
<Checkbox
|
|
202
|
-
value={
|
|
223
|
+
value={rowSelect.selectedRows.has(e.uuid!)}
|
|
203
224
|
setValue={checked => {
|
|
204
|
-
|
|
225
|
+
rowSelect.setSelectedRows(oldSet => {
|
|
205
226
|
const newSet = new Set(oldSet);
|
|
206
227
|
checked ? newSet.add(e.uuid!) : newSet.delete(e.uuid!);
|
|
207
228
|
return newSet;
|
|
@@ -214,13 +235,25 @@ export const Table: FC<ITable> = ({
|
|
|
214
235
|
})
|
|
215
236
|
);
|
|
216
237
|
setData(data);
|
|
217
|
-
}, [
|
|
238
|
+
}, [
|
|
239
|
+
tableData,
|
|
240
|
+
limit,
|
|
241
|
+
offset,
|
|
242
|
+
rowSelect?.selectedRows,
|
|
243
|
+
activeSelectOptions,
|
|
244
|
+
serverSidePagination,
|
|
245
|
+
rowSelect,
|
|
246
|
+
]);
|
|
218
247
|
|
|
219
248
|
const EditableRow = editable?.EditableRow;
|
|
220
249
|
|
|
221
250
|
return (
|
|
222
251
|
<Loader isLoading={!!isLoading}>
|
|
223
|
-
<div
|
|
252
|
+
<div
|
|
253
|
+
className={clsx('iui-table', className, {
|
|
254
|
+
'pb-3': data.length === 0,
|
|
255
|
+
})}
|
|
256
|
+
>
|
|
224
257
|
<div className="flex column gap-2">
|
|
225
258
|
{(!!filterData ||
|
|
226
259
|
!!sortData ||
|
|
@@ -243,34 +276,37 @@ export const Table: FC<ITable> = ({
|
|
|
243
276
|
/>
|
|
244
277
|
)}
|
|
245
278
|
{/* ////// SELECT ////// */}
|
|
246
|
-
{!!activeSelectOptions
|
|
279
|
+
{!!rowSelect && activeSelectOptions.length > 0 && (
|
|
247
280
|
<div className="flex gap-2 align-center pl-3">
|
|
248
|
-
<p className="fs-12">{`${t('Selected')}: ${
|
|
281
|
+
<p className="fs-12">{`${t('Selected')}: ${
|
|
282
|
+
rowSelect.selectedRows.size
|
|
283
|
+
}`}</p>
|
|
249
284
|
<Menu
|
|
250
285
|
isOpen={selectedActionOpen}
|
|
251
286
|
onClose={() => setSelectedActionOpen(false)}
|
|
252
|
-
|
|
287
|
+
placement="bottom-left"
|
|
253
288
|
renderButton={ref => (
|
|
254
289
|
<Button
|
|
255
290
|
ref={ref}
|
|
256
291
|
label={t('Actions')}
|
|
257
292
|
icon={faEllipsisVertical}
|
|
258
293
|
active={selectedActionOpen}
|
|
259
|
-
disabled={!
|
|
294
|
+
disabled={!rowSelect.selectedRows.size}
|
|
260
295
|
onClick={() => setSelectedActionOpen(!selectedActionOpen)}
|
|
261
296
|
size="s"
|
|
262
297
|
/>
|
|
263
298
|
)}
|
|
264
299
|
>
|
|
265
|
-
{activeSelectOptions
|
|
300
|
+
{activeSelectOptions.map(action => (
|
|
266
301
|
<MenuItem
|
|
267
302
|
key={action.label}
|
|
268
303
|
label={action.label}
|
|
269
304
|
disabled={action.disabled}
|
|
270
305
|
onClick={() => {
|
|
271
|
-
action.onClick!(
|
|
306
|
+
action.onClick!(rowSelect.selectedRows);
|
|
272
307
|
setSelectedActionOpen(false);
|
|
273
|
-
action.clearSelected &&
|
|
308
|
+
action.clearSelected &&
|
|
309
|
+
rowSelect.setSelectedRows(new Set<string>());
|
|
274
310
|
}}
|
|
275
311
|
/>
|
|
276
312
|
))}
|
|
@@ -278,10 +314,7 @@ export const Table: FC<ITable> = ({
|
|
|
278
314
|
</div>
|
|
279
315
|
)}
|
|
280
316
|
</div>
|
|
281
|
-
<div
|
|
282
|
-
className="table-container"
|
|
283
|
-
// style={{ maxHeight }}
|
|
284
|
-
>
|
|
317
|
+
<div className="table-container" style={{ maxHeight }}>
|
|
285
318
|
<ConditionalWrapper
|
|
286
319
|
condition={!!editable}
|
|
287
320
|
wrapper={children => (
|
|
@@ -303,7 +336,7 @@ export const Table: FC<ITable> = ({
|
|
|
303
336
|
</form>
|
|
304
337
|
)}
|
|
305
338
|
>
|
|
306
|
-
|
|
339
|
+
<table className="full-width">
|
|
307
340
|
<HeaderTable
|
|
308
341
|
columns={cols}
|
|
309
342
|
headerWrap={headerWrap}
|
|
@@ -311,7 +344,7 @@ export const Table: FC<ITable> = ({
|
|
|
311
344
|
sticky={!!maxHeight}
|
|
312
345
|
/>
|
|
313
346
|
<tbody
|
|
314
|
-
className={
|
|
347
|
+
className={clsx({ 'no-last-border': hideFooter && !showLastBorder })}
|
|
315
348
|
>
|
|
316
349
|
{data.length ? (
|
|
317
350
|
<>
|
|
@@ -321,9 +354,9 @@ export const Table: FC<ITable> = ({
|
|
|
321
354
|
!row.extendable.isLoading &&
|
|
322
355
|
extendedRow === row.uuid;
|
|
323
356
|
return (
|
|
324
|
-
<Fragment key={row.uuid}>
|
|
325
|
-
|
|
326
|
-
|
|
357
|
+
<Fragment key={row.uuid}>
|
|
358
|
+
{/* ////// EDITABLE ROW ////// */}
|
|
359
|
+
{!!EditableRow &&
|
|
327
360
|
row.uuid === editable?.selectedItem?.uuid &&
|
|
328
361
|
editable.setSelectedItem ? (
|
|
329
362
|
<EditableRow
|
|
@@ -380,13 +413,18 @@ export const Table: FC<ITable> = ({
|
|
|
380
413
|
}
|
|
381
414
|
: undefined
|
|
382
415
|
}
|
|
383
|
-
className={clsx(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
416
|
+
className={clsx(
|
|
417
|
+
column.color,
|
|
418
|
+
cell?.className,
|
|
419
|
+
rowHeight,
|
|
420
|
+
{
|
|
421
|
+
link: cell?.link,
|
|
422
|
+
'p-0': !cell?.value && cell?.value !== 0,
|
|
423
|
+
'clickable-column': cell?.onClick,
|
|
424
|
+
'word-break': column.break,
|
|
425
|
+
'no-border': isExtended,
|
|
426
|
+
}
|
|
427
|
+
)}
|
|
390
428
|
colSpan={cell?.span}
|
|
391
429
|
>
|
|
392
430
|
{cell?.value}
|
|
@@ -395,11 +433,13 @@ export const Table: FC<ITable> = ({
|
|
|
395
433
|
);
|
|
396
434
|
})}
|
|
397
435
|
</tr>
|
|
398
|
-
)}
|
|
399
|
-
|
|
400
|
-
|
|
436
|
+
)}
|
|
437
|
+
{/* ////// EXTENDABLE ROW ////// */}
|
|
438
|
+
{isExtended && (
|
|
401
439
|
<tr>
|
|
402
|
-
<td colSpan={cols.length}
|
|
440
|
+
<td colSpan={cols.length} className={rowHeight}>
|
|
441
|
+
{row.extendable!.element}
|
|
442
|
+
</td>
|
|
403
443
|
</tr>
|
|
404
444
|
)}
|
|
405
445
|
</Fragment>
|
|
@@ -413,6 +453,10 @@ export const Table: FC<ITable> = ({
|
|
|
413
453
|
</td>
|
|
414
454
|
</tr>
|
|
415
455
|
)}
|
|
456
|
+
</tbody>
|
|
457
|
+
<tfoot
|
|
458
|
+
// className="sticky-footer"
|
|
459
|
+
>
|
|
416
460
|
{!!EditableRow &&
|
|
417
461
|
!editable.selectedItem &&
|
|
418
462
|
!editable.addDisabled &&
|
|
@@ -426,8 +470,11 @@ export const Table: FC<ITable> = ({
|
|
|
426
470
|
}`}
|
|
427
471
|
onClick={() => setIsAdding(true)}
|
|
428
472
|
>
|
|
429
|
-
<td className=
|
|
430
|
-
<
|
|
473
|
+
<td className={`text-center ${rowHeight}`} colSpan={columns.length}>
|
|
474
|
+
<div className="flex center gap-2">
|
|
475
|
+
<FontAwesomeIcon icon={faPlus} className="c-primary icon24" />
|
|
476
|
+
<p>{editable.addLabel || t('AddItem')}</p>
|
|
477
|
+
</div>
|
|
431
478
|
</td>
|
|
432
479
|
</tr>
|
|
433
480
|
) : (
|
|
@@ -443,202 +490,24 @@ export const Table: FC<ITable> = ({
|
|
|
443
490
|
inputFocusRef={editable.inputFocusRef}
|
|
444
491
|
/>
|
|
445
492
|
))}
|
|
446
|
-
{!!
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
align={totals.cells[columnId]?.align || 'right'}
|
|
452
|
-
colSpan={totals.cells[columnId]?.span}
|
|
453
|
-
>
|
|
454
|
-
<strong>{totals.cells[columnId]?.value}</strong>
|
|
455
|
-
</td>
|
|
456
|
-
))}
|
|
457
|
-
</tr>
|
|
458
|
-
)}
|
|
459
|
-
</tbody>
|
|
460
|
-
</table> */}
|
|
461
|
-
|
|
462
|
-
<div className="grid-table">
|
|
463
|
-
<HeaderTable
|
|
464
|
-
columns={cols}
|
|
465
|
-
headerWrap={headerWrap}
|
|
466
|
-
customHeader={customHeader}
|
|
467
|
-
// sticky={!!maxHeight}
|
|
468
|
-
/>
|
|
469
|
-
<div>
|
|
470
|
-
<tbody
|
|
471
|
-
className={clsx({
|
|
472
|
-
'no-last-border': hideFooter && !showLastBorder,
|
|
473
|
-
})}
|
|
474
|
-
style={{ maxHeight }}
|
|
475
|
-
>
|
|
476
|
-
{data.length ? (
|
|
477
|
-
<>
|
|
478
|
-
{data.map(row => {
|
|
479
|
-
const isExtended =
|
|
480
|
-
row.extendable &&
|
|
481
|
-
!row.extendable.isLoading &&
|
|
482
|
-
extendedRow === row.uuid;
|
|
483
|
-
return (
|
|
484
|
-
<Fragment key={row.uuid}>
|
|
485
|
-
{/* ////// EDITABLE ROW ////// */}
|
|
486
|
-
{!!EditableRow &&
|
|
487
|
-
row.uuid === editable?.selectedItem?.uuid &&
|
|
488
|
-
editable.setSelectedItem ? (
|
|
489
|
-
<EditableRow
|
|
490
|
-
columns={cols}
|
|
491
|
-
data={editableData}
|
|
492
|
-
setData={setEditableData}
|
|
493
|
-
item={editable.selectedItem}
|
|
494
|
-
clearItem={() => editable.setSelectedItem!(null)}
|
|
495
|
-
defaultDataValue={editable.defaultDataValue}
|
|
496
|
-
inputFocusRef={editable.inputFocusRef}
|
|
497
|
-
/>
|
|
498
|
-
) : (
|
|
499
|
-
////// REGULAR ROW //////
|
|
500
|
-
<tr
|
|
501
|
-
data-id={row.uuid}
|
|
502
|
-
className={clsx('row', row.className, {
|
|
503
|
-
selected:
|
|
504
|
-
!!selectedRowUuid && selectedRowUuid === row.uuid,
|
|
505
|
-
clickable: !!row.onRowClick || !!row.extendable,
|
|
506
|
-
focused: !!focusedRow && focusedRow.uuid === row.uuid,
|
|
507
|
-
loading: row.extendable?.isLoading,
|
|
508
|
-
})}
|
|
509
|
-
onClick={e => {
|
|
510
|
-
row.onRowClick && row.onRowClick(e);
|
|
511
|
-
row.extendable &&
|
|
512
|
-
setExtendedRow(
|
|
513
|
-
extendedRow === row.uuid ? '' : row.uuid
|
|
514
|
-
);
|
|
515
|
-
}}
|
|
516
|
-
>
|
|
517
|
-
{cols.map(column => {
|
|
518
|
-
const cell = row.cells[column.id];
|
|
519
|
-
return (
|
|
520
|
-
<Tooltip
|
|
521
|
-
key={column.id}
|
|
522
|
-
label={cell?.tooltip!}
|
|
523
|
-
position="top"
|
|
524
|
-
disabled={!cell?.tooltip}
|
|
525
|
-
>
|
|
526
|
-
<td
|
|
527
|
-
data-th={
|
|
528
|
-
column.id === 'select'
|
|
529
|
-
? t('Selected') + ':'
|
|
530
|
-
: column.label
|
|
531
|
-
? column.label + ': '
|
|
532
|
-
: '/'
|
|
533
|
-
}
|
|
534
|
-
style={
|
|
535
|
-
column.minWidth
|
|
536
|
-
? { minWidth: column.minWidth }
|
|
537
|
-
: column.width
|
|
538
|
-
? { width: column.width }
|
|
539
|
-
: undefined
|
|
540
|
-
}
|
|
541
|
-
align={cell?.align || column.align}
|
|
542
|
-
onClick={
|
|
543
|
-
cell?.onClick || cell?.unclickable
|
|
544
|
-
? e => {
|
|
545
|
-
e.stopPropagation();
|
|
546
|
-
cell?.onClick && cell?.onClick!(e);
|
|
547
|
-
}
|
|
548
|
-
: undefined
|
|
549
|
-
}
|
|
550
|
-
className={clsx(column.color, cell?.className, {
|
|
551
|
-
link: cell?.link,
|
|
552
|
-
'p-0': !cell?.value && cell?.value !== 0,
|
|
553
|
-
'clickable-column': cell?.onClick,
|
|
554
|
-
'word-break': column.break,
|
|
555
|
-
'no-border': isExtended,
|
|
556
|
-
})}
|
|
557
|
-
colSpan={cell?.span}
|
|
558
|
-
>
|
|
559
|
-
{cell?.value}
|
|
560
|
-
</td>
|
|
561
|
-
</Tooltip>
|
|
562
|
-
);
|
|
563
|
-
})}
|
|
564
|
-
</tr>
|
|
565
|
-
)}
|
|
566
|
-
{/* ////// EXTENDABLE ROW ////// */}
|
|
567
|
-
{isExtended && (
|
|
568
|
-
<tr>
|
|
569
|
-
<td colSpan={cols.length}>{row.extendable!.element}</td>
|
|
570
|
-
</tr>
|
|
571
|
-
)}
|
|
572
|
-
</Fragment>
|
|
573
|
-
);
|
|
574
|
-
})}
|
|
575
|
-
</>
|
|
576
|
-
) : (
|
|
577
|
-
<tr>
|
|
578
|
-
<td className="no-border" colSpan={cols.length}>
|
|
579
|
-
{t('NoResults')}
|
|
580
|
-
</td>
|
|
581
|
-
</tr>
|
|
582
|
-
)}
|
|
583
|
-
{!!EditableRow &&
|
|
584
|
-
!editable.selectedItem &&
|
|
585
|
-
!editable.addDisabled &&
|
|
586
|
-
// TO DO -> Remove keyboard condition to enable this for every table
|
|
587
|
-
(keyboard?.enabled && !isAdding ? (
|
|
588
|
-
////// NEW ITEM ROW //////
|
|
589
|
-
<tr
|
|
590
|
-
data-id="add"
|
|
591
|
-
className={`clickable${
|
|
592
|
-
focusedRow?.uuid === 'add' ? ' focused' : ''
|
|
593
|
-
}`}
|
|
594
|
-
onClick={() => setIsAdding(true)}
|
|
595
|
-
>
|
|
596
|
-
{/* <td
|
|
597
|
-
className="justify-center"
|
|
598
|
-
// colSpan={cols.length}
|
|
599
|
-
style={{
|
|
600
|
-
gridColumn: `span ${cols.length}`,
|
|
601
|
-
}}
|
|
602
|
-
>
|
|
603
|
-
<FontAwesomeIcon icon={faPlus} className="c-primary icon24" />
|
|
604
|
-
</td> */}
|
|
605
|
-
</tr>
|
|
606
|
-
) : (
|
|
607
|
-
<EditableRow
|
|
608
|
-
columns={cols}
|
|
609
|
-
data={editableData}
|
|
610
|
-
setData={setEditableData}
|
|
611
|
-
defaultDataValue={editable.defaultDataValue}
|
|
612
|
-
clearItem={() => {
|
|
613
|
-
editable.setSelectedItem?.(null);
|
|
614
|
-
isAdding && setIsAdding(false);
|
|
615
|
-
}}
|
|
616
|
-
inputFocusRef={editable.inputFocusRef}
|
|
617
|
-
/>
|
|
618
|
-
))}
|
|
619
|
-
{!!totals && !!data.length && (
|
|
620
|
-
<tr>
|
|
621
|
-
{cols.map(({ id: columnId, ...column }) => (
|
|
493
|
+
{!!sumRows &&
|
|
494
|
+
!!data.length &&
|
|
495
|
+
sumRows.map(row => (
|
|
496
|
+
<tr key={row.uuid}>
|
|
497
|
+
{cols.map(({ id: columnId }) => (
|
|
622
498
|
<td
|
|
623
499
|
key={columnId}
|
|
624
|
-
align={
|
|
625
|
-
colSpan={
|
|
626
|
-
|
|
627
|
-
minWidth: column.minWidth,
|
|
628
|
-
width: column.width,
|
|
629
|
-
gridColumn: totals.cells[columnId]?.span
|
|
630
|
-
? `span ${totals.cells[columnId].span}`
|
|
631
|
-
: undefined,
|
|
632
|
-
}}
|
|
500
|
+
align={row.cells[columnId]?.align || 'right'}
|
|
501
|
+
colSpan={row.cells[columnId]?.span}
|
|
502
|
+
className={rowHeight}
|
|
633
503
|
>
|
|
634
|
-
<strong>{
|
|
504
|
+
<strong>{row.cells[columnId]?.value}</strong>
|
|
635
505
|
</td>
|
|
636
506
|
))}
|
|
637
507
|
</tr>
|
|
638
|
-
)}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
</div>
|
|
508
|
+
))}
|
|
509
|
+
</tfoot>
|
|
510
|
+
</table>
|
|
642
511
|
</ConditionalWrapper>
|
|
643
512
|
</div>
|
|
644
513
|
{!hideFooter &&
|
|
@@ -649,6 +518,7 @@ export const Table: FC<ITable> = ({
|
|
|
649
518
|
pagination={pagination}
|
|
650
519
|
footerAction={footerAction}
|
|
651
520
|
noTotalRows={noTotalRows}
|
|
521
|
+
dataLength={data.length}
|
|
652
522
|
/>
|
|
653
523
|
)}
|
|
654
524
|
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// import { useEffect, useState } from 'react';
|
|
2
|
+
// import { getDefaultReportTemplate } from '../Components/Templates/repo/TemplateRepo';
|
|
3
|
+
// import { IReportTemplate } from '../../../types/ITable';
|
|
4
|
+
|
|
5
|
+
export const useDefaultTemplate = (identifier?: string) => {
|
|
6
|
+
// const [template, setTemplate] = useState<IReportTemplate | null>(null);
|
|
7
|
+
// const [isLoading, setIsLoading] = useState(true);
|
|
8
|
+
// useEffect(() => {
|
|
9
|
+
// if (identifier) {
|
|
10
|
+
// getDefaultReportTemplate(identifier)
|
|
11
|
+
// .then(setTemplate)
|
|
12
|
+
// .catch(() => {})
|
|
13
|
+
// .finally(() => setIsLoading(false));
|
|
14
|
+
// }
|
|
15
|
+
// }, [identifier]);
|
|
16
|
+
// return {
|
|
17
|
+
// defaultTemplate: template,
|
|
18
|
+
// isLoadingDefaultTemplate: !!identifier && isLoading,
|
|
19
|
+
// };
|
|
20
|
+
};
|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import { ITableDataItem } from '../../../types/ITable';
|
|
3
3
|
import { IKeyboardAction, ITableKeyboardActionsProp } from '../../../types/IKeyboard';
|
|
4
4
|
import { useDialogObserver } from '../../Dialog/hooks/useDialogObserver';
|
|
5
|
-
import { scrollToRow } from '../../../utils/
|
|
5
|
+
import { scrollToRow } from '../../../utils/tableUtils';
|
|
6
6
|
|
|
7
7
|
export const useTableKeyboard = ({
|
|
8
8
|
enabled,
|
|
@@ -73,7 +73,6 @@ export const useTableKeyboard = ({
|
|
|
73
73
|
{
|
|
74
74
|
key: 'Escape',
|
|
75
75
|
disabled: !focusedRow && !isAdding,
|
|
76
|
-
// isActive: !!focusedRow || !!isAdding,
|
|
77
76
|
onAction: () =>
|
|
78
77
|
isAdding
|
|
79
78
|
? actions.add?.setIsAdding(false)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useTableSelect = () => {
|
|
4
|
+
const [selectedRows, setSelectedRows] = useState(new Set<string>());
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
selectedRows,
|
|
8
|
+
setSelectedRows,
|
|
9
|
+
resetSelectedRows: () => setSelectedRows(new Set<string>()),
|
|
10
|
+
};
|
|
11
|
+
};
|