@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
|
@@ -1,261 +1,60 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { FC, Fragment,
|
|
3
|
-
import {
|
|
4
|
-
ITable,
|
|
5
|
-
ITableColumn,
|
|
6
|
-
ITableDataItem,
|
|
7
|
-
ITableSelectedActions,
|
|
8
|
-
} from '../../types/ITable';
|
|
2
|
+
import { type FC, Fragment, useState } from 'react';
|
|
3
|
+
import { ITable } from '../../types/ITable';
|
|
9
4
|
import { Loader } from '../Loader/Loader';
|
|
10
5
|
import { Tooltip } from '../Tooltip/Tooltip';
|
|
11
6
|
import { ConditionalWrapper } from '../Wrappers/ConditionalWrapper';
|
|
12
|
-
import { TableFooter } from './Components/TableFooter';
|
|
13
|
-
import { HeaderTable } from './Components/Header/TableHeader';
|
|
14
|
-
import { TableOptions } from './Components/TableOptions';
|
|
15
7
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import {
|
|
17
|
-
import { Menu } from '../Menu/Menu';
|
|
18
|
-
import { faEllipsisVertical } from '../../assets/icons/solid/faEllipsisVertical';
|
|
19
|
-
import { MenuItem } from '../Menu/MenuItem';
|
|
20
|
-
import { Button } from '../Button/Button';
|
|
21
|
-
import { useTableKeyboard } from './hooks/useTableKeyboard';
|
|
8
|
+
import { useLocalTableKeyboard } from './hooks/localHooks/useLocalTableKeyboard';
|
|
22
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
23
10
|
import { faPlus } from '../../assets/icons/solid/faPlus';
|
|
11
|
+
import { HeaderTable } from './components/header/TableHeader';
|
|
12
|
+
import { TableFooter } from './components/footer/TableFooter';
|
|
13
|
+
import { TableProvider, useTableContext } from './contexts/TableContext';
|
|
14
|
+
import { TableSelect } from './components/select/TableSelect';
|
|
15
|
+
import { TableSort } from './components/sort/TableSort';
|
|
16
|
+
import { TableFilters } from './components/filters/TableFilters';
|
|
17
|
+
import { TableEditRow } from './components/edit/TableEditRow';
|
|
24
18
|
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
headerWrap,
|
|
34
|
-
serverSidePagination,
|
|
35
|
-
customPagination,
|
|
36
|
-
selectedRowUuid,
|
|
37
|
-
footerAction,
|
|
38
|
-
hideFooter,
|
|
39
|
-
noTotalRows,
|
|
40
|
-
showLastBorder,
|
|
41
|
-
className,
|
|
42
|
-
filterData,
|
|
43
|
-
sortData,
|
|
44
|
-
printData,
|
|
45
|
-
customPrintData,
|
|
46
|
-
templates,
|
|
47
|
-
additionsalOptions,
|
|
48
|
-
rowSelect,
|
|
49
|
-
rowHeight = 'm',
|
|
50
|
-
maxHeight,
|
|
51
|
-
editable,
|
|
52
|
-
keyboard,
|
|
53
|
-
}) => {
|
|
54
|
-
const [limit, setLimit] = useState(customPagination?.defaultLimit ?? 5);
|
|
55
|
-
const [offset, setOffset] = useState(0);
|
|
56
|
-
const [cols, setCols] = useState<ITableColumn[]>([]);
|
|
57
|
-
const [data, setData] = useState<ITableDataItem[]>([]);
|
|
58
|
-
const [extendedRow, setExtendedRow] = useState('');
|
|
59
|
-
const [editableData, setEditableData] = useState<object>({});
|
|
60
|
-
const [isAdding, setIsAdding] = useState(false);
|
|
61
|
-
const [selectedActionOpen, setSelectedActionOpen] = useState(false);
|
|
62
|
-
const [activeSelectOptions, setActiveSelectOptions] = useState<ITableSelectedActions[]>(
|
|
63
|
-
[]
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const { t } = useTranslation();
|
|
67
|
-
|
|
68
|
-
const pagination = {
|
|
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,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const focusedRow = useTableKeyboard({
|
|
77
|
-
enabled: !!keyboard?.enabled,
|
|
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
|
-
},
|
|
84
|
-
actions: {
|
|
85
|
-
moveDisabled: !!keyboard?.actions?.moveDisabled || isAdding,
|
|
86
|
-
...keyboard?.actions,
|
|
87
|
-
add: {
|
|
88
|
-
isAdding,
|
|
89
|
-
setIsAdding,
|
|
90
|
-
enabled: !!editable?.EditableRow && !editable.addDisabled,
|
|
91
|
-
},
|
|
92
|
-
edit: {
|
|
93
|
-
item: editable?.selectedItem,
|
|
94
|
-
setItem: editable?.setSelectedItem!,
|
|
95
|
-
enabled:
|
|
96
|
-
!!editable && !!editable!.setSelectedItem && !keyboard?.actions.editDisabled,
|
|
97
|
-
},
|
|
98
|
-
additional: additionalProps => [
|
|
99
|
-
...(keyboard?.actions?.additional?.(additionalProps) || []),
|
|
100
|
-
{
|
|
101
|
-
key: 'PageUp',
|
|
102
|
-
isActive: !additionalProps.isEditing,
|
|
103
|
-
onAction: () =>
|
|
104
|
-
pagination.offset > 0 && pagination.setOffset(pagination.offset - 1),
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
key: 'PageDown',
|
|
108
|
-
isActive: !additionalProps.isEditing,
|
|
109
|
-
onAction: () => {
|
|
110
|
-
if (
|
|
111
|
-
noTotalRows
|
|
112
|
-
? pagination.limit <= pagination.totalRows
|
|
113
|
-
: pagination.offset + 1 <
|
|
114
|
-
Math.ceil(pagination.totalRows / pagination.limit)
|
|
115
|
-
) {
|
|
116
|
-
pagination.setOffset(pagination.offset + 1);
|
|
117
|
-
}
|
|
118
|
-
},
|
|
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
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Set Active Select Options
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
rowSelect?.actions.length &&
|
|
140
|
-
setActiveSelectOptions(rowSelect.actions.filter(e => !e.hidden) || []);
|
|
141
|
-
}, [rowSelect?.actions]);
|
|
19
|
+
export const TableContent: FC = () => {
|
|
20
|
+
const {
|
|
21
|
+
columns,
|
|
22
|
+
// setColumns,
|
|
23
|
+
// withColumnsSearch,
|
|
24
|
+
data,
|
|
25
|
+
sumRows,
|
|
26
|
+
isLoading,
|
|
142
27
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
}
|
|
176
|
-
|
|
177
|
-
let newCols: ITableColumn[] = [];
|
|
178
|
-
|
|
179
|
-
selectCol && newCols.push(selectCol);
|
|
180
|
-
newCols = newCols.concat(activeColumns);
|
|
181
|
-
|
|
182
|
-
setCols(newCols);
|
|
183
|
-
},
|
|
184
|
-
// eslint-disable-next-line
|
|
185
|
-
[
|
|
186
|
-
columns,
|
|
187
|
-
editable,
|
|
188
|
-
rowSelect?.selectedRows,
|
|
189
|
-
activeSelectOptions,
|
|
190
|
-
serverSidePagination,
|
|
191
|
-
]
|
|
192
|
-
);
|
|
28
|
+
// filterData,
|
|
29
|
+
selectedRowUuid,
|
|
30
|
+
// printData,
|
|
31
|
+
// customPrintData,
|
|
32
|
+
// templates,
|
|
33
|
+
// additionsalOptions,
|
|
34
|
+
footer,
|
|
35
|
+
className,
|
|
36
|
+
rowHeight = 'm',
|
|
37
|
+
maxHeight,
|
|
38
|
+
editable,
|
|
39
|
+
} = useTableContext();
|
|
193
40
|
|
|
194
|
-
|
|
195
|
-
// const data = editable
|
|
196
|
-
// ? tableData.map((e) => ({
|
|
197
|
-
// ...e,
|
|
198
|
-
// cells: {
|
|
199
|
-
// ...e.cells,
|
|
200
|
-
// actions: {
|
|
201
|
-
// value: (
|
|
202
|
-
// <ItemActionsMenu
|
|
203
|
-
// item={e}
|
|
204
|
-
// setSelectedItem={editable!.setSelectedItem}
|
|
205
|
-
// />
|
|
206
|
-
// ),
|
|
207
|
-
// },
|
|
208
|
-
// },
|
|
209
|
-
// }))
|
|
210
|
-
// : tableData;
|
|
211
|
-
const data =
|
|
212
|
-
serverSidePagination || limit <= 0
|
|
213
|
-
? tableData
|
|
214
|
-
: tableData.slice(offset * limit, offset * limit + limit);
|
|
215
|
-
|
|
216
|
-
rowSelect &&
|
|
217
|
-
activeSelectOptions.length > 0 &&
|
|
218
|
-
data.map(
|
|
219
|
-
e =>
|
|
220
|
-
(e.cells.select = {
|
|
221
|
-
value: (
|
|
222
|
-
<Checkbox
|
|
223
|
-
value={rowSelect.selectedRows.has(e.uuid!)}
|
|
224
|
-
setValue={checked => {
|
|
225
|
-
rowSelect.setSelectedRows(oldSet => {
|
|
226
|
-
const newSet = new Set(oldSet);
|
|
227
|
-
checked ? newSet.add(e.uuid!) : newSet.delete(e.uuid!);
|
|
228
|
-
return newSet;
|
|
229
|
-
});
|
|
230
|
-
}}
|
|
231
|
-
disabled={e.disableSelect}
|
|
232
|
-
/>
|
|
233
|
-
),
|
|
234
|
-
unclickable: true,
|
|
235
|
-
})
|
|
236
|
-
);
|
|
237
|
-
setData(data);
|
|
238
|
-
}, [
|
|
239
|
-
tableData,
|
|
240
|
-
limit,
|
|
241
|
-
offset,
|
|
242
|
-
rowSelect?.selectedRows,
|
|
243
|
-
activeSelectOptions,
|
|
244
|
-
serverSidePagination,
|
|
245
|
-
rowSelect,
|
|
246
|
-
]);
|
|
41
|
+
const [extendedRow, setExtendedRow] = useState('');
|
|
247
42
|
|
|
248
|
-
const
|
|
43
|
+
const { t } = useTranslation();
|
|
44
|
+
const { focusedRow } = useLocalTableKeyboard();
|
|
45
|
+
const noTotalRows = footer?.totalRows === undefined;
|
|
249
46
|
|
|
250
47
|
return (
|
|
251
48
|
<Loader isLoading={!!isLoading}>
|
|
252
49
|
<div
|
|
50
|
+
// onKeyDown={handleKeyDown}
|
|
253
51
|
className={clsx('iui-table', className, {
|
|
254
52
|
'pb-3': data.length === 0,
|
|
255
53
|
})}
|
|
54
|
+
// tabIndex={-1}
|
|
256
55
|
>
|
|
257
|
-
<div className="
|
|
258
|
-
{(!!filterData ||
|
|
56
|
+
<div className="iui-table-header-actions">
|
|
57
|
+
{/* {(!!filterData ||
|
|
259
58
|
!!sortData ||
|
|
260
59
|
!!setColumns ||
|
|
261
60
|
!!printData ||
|
|
@@ -274,45 +73,10 @@ export const Table: FC<ITable> = ({
|
|
|
274
73
|
templates={templates}
|
|
275
74
|
additionsalOptions={additionsalOptions}
|
|
276
75
|
/>
|
|
277
|
-
)}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
<p className="fs-12">{`${t('Selected')}: ${
|
|
282
|
-
rowSelect.selectedRows.size
|
|
283
|
-
}`}</p>
|
|
284
|
-
<Menu
|
|
285
|
-
isOpen={selectedActionOpen}
|
|
286
|
-
onClose={() => setSelectedActionOpen(false)}
|
|
287
|
-
placement="bottom-left"
|
|
288
|
-
renderButton={ref => (
|
|
289
|
-
<Button
|
|
290
|
-
ref={ref}
|
|
291
|
-
label={t('Actions')}
|
|
292
|
-
icon={faEllipsisVertical}
|
|
293
|
-
active={selectedActionOpen}
|
|
294
|
-
disabled={!rowSelect.selectedRows.size}
|
|
295
|
-
onClick={() => setSelectedActionOpen(!selectedActionOpen)}
|
|
296
|
-
size="s"
|
|
297
|
-
/>
|
|
298
|
-
)}
|
|
299
|
-
>
|
|
300
|
-
{activeSelectOptions.map(action => (
|
|
301
|
-
<MenuItem
|
|
302
|
-
key={action.label}
|
|
303
|
-
label={action.label}
|
|
304
|
-
disabled={action.disabled}
|
|
305
|
-
onClick={() => {
|
|
306
|
-
action.onClick!(rowSelect.selectedRows);
|
|
307
|
-
setSelectedActionOpen(false);
|
|
308
|
-
action.clearSelected &&
|
|
309
|
-
rowSelect.setSelectedRows(new Set<string>());
|
|
310
|
-
}}
|
|
311
|
-
/>
|
|
312
|
-
))}
|
|
313
|
-
</Menu>
|
|
314
|
-
</div>
|
|
315
|
-
)}
|
|
76
|
+
)} */}
|
|
77
|
+
<TableSelect />
|
|
78
|
+
<TableFilters />
|
|
79
|
+
<TableSort />
|
|
316
80
|
</div>
|
|
317
81
|
<div className="table-container" style={{ maxHeight }}>
|
|
318
82
|
<ConditionalWrapper
|
|
@@ -322,12 +86,10 @@ export const Table: FC<ITable> = ({
|
|
|
322
86
|
onSubmit={e => {
|
|
323
87
|
e.preventDefault();
|
|
324
88
|
e.stopPropagation();
|
|
325
|
-
editable
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
setEditableData(editable!.defaultDataValue ?? {});
|
|
330
|
-
editable?.setSelectedItem && editable.setSelectedItem(null);
|
|
89
|
+
editable?.onSubmit(editable.editData, () => {
|
|
90
|
+
editable.setEditData(editable.defaultDataValue ?? {});
|
|
91
|
+
if (!editable.keepEditOnSubmit && editable.selectedItem) {
|
|
92
|
+
editable.setSelectedItem(null);
|
|
331
93
|
}
|
|
332
94
|
});
|
|
333
95
|
}}
|
|
@@ -337,15 +99,8 @@ export const Table: FC<ITable> = ({
|
|
|
337
99
|
)}
|
|
338
100
|
>
|
|
339
101
|
<table className="full-width">
|
|
340
|
-
<HeaderTable
|
|
341
|
-
|
|
342
|
-
headerWrap={headerWrap}
|
|
343
|
-
customHeader={customHeader}
|
|
344
|
-
sticky={!!maxHeight}
|
|
345
|
-
/>
|
|
346
|
-
<tbody
|
|
347
|
-
className={clsx({ 'no-last-border': hideFooter && !showLastBorder })}
|
|
348
|
-
>
|
|
102
|
+
<HeaderTable />
|
|
103
|
+
<tbody>
|
|
349
104
|
{data.length ? (
|
|
350
105
|
<>
|
|
351
106
|
{data.map(row => {
|
|
@@ -356,18 +111,8 @@ export const Table: FC<ITable> = ({
|
|
|
356
111
|
return (
|
|
357
112
|
<Fragment key={row.uuid}>
|
|
358
113
|
{/* ////// EDITABLE ROW ////// */}
|
|
359
|
-
{!!
|
|
360
|
-
|
|
361
|
-
editable.setSelectedItem ? (
|
|
362
|
-
<EditableRow
|
|
363
|
-
columns={cols}
|
|
364
|
-
data={editableData}
|
|
365
|
-
setData={setEditableData}
|
|
366
|
-
item={editable.selectedItem}
|
|
367
|
-
clearItem={() => editable.setSelectedItem!(null)}
|
|
368
|
-
defaultDataValue={editable.defaultDataValue}
|
|
369
|
-
inputFocusRef={editable.inputFocusRef}
|
|
370
|
-
/>
|
|
114
|
+
{!!editable && row.uuid === editable.selectedItem?.uuid ? (
|
|
115
|
+
<TableEditRow />
|
|
371
116
|
) : (
|
|
372
117
|
////// REGULAR ROW //////
|
|
373
118
|
<tr
|
|
@@ -380,14 +125,14 @@ export const Table: FC<ITable> = ({
|
|
|
380
125
|
loading: row.extendable?.isLoading,
|
|
381
126
|
})}
|
|
382
127
|
onClick={e => {
|
|
383
|
-
row.onRowClick
|
|
128
|
+
row.onRowClick?.(e);
|
|
384
129
|
row.extendable &&
|
|
385
130
|
setExtendedRow(
|
|
386
131
|
extendedRow === row.uuid ? '' : row.uuid
|
|
387
132
|
);
|
|
388
133
|
}}
|
|
389
134
|
>
|
|
390
|
-
{
|
|
135
|
+
{columns.map(column => {
|
|
391
136
|
const cell = row.cells[column.id];
|
|
392
137
|
return (
|
|
393
138
|
<Tooltip
|
|
@@ -401,8 +146,8 @@ export const Table: FC<ITable> = ({
|
|
|
401
146
|
column.id === 'select'
|
|
402
147
|
? t('Selected') + ':'
|
|
403
148
|
: column.label
|
|
404
|
-
|
|
405
|
-
|
|
149
|
+
? column.label + ': '
|
|
150
|
+
: '/'
|
|
406
151
|
}
|
|
407
152
|
align={cell?.align || column.align}
|
|
408
153
|
onClick={
|
|
@@ -414,12 +159,12 @@ export const Table: FC<ITable> = ({
|
|
|
414
159
|
: undefined
|
|
415
160
|
}
|
|
416
161
|
className={clsx(
|
|
162
|
+
column.className,
|
|
417
163
|
column.color,
|
|
418
164
|
cell?.className,
|
|
419
165
|
rowHeight,
|
|
420
166
|
{
|
|
421
167
|
link: cell?.link,
|
|
422
|
-
'p-0': !cell?.value && cell?.value !== 0,
|
|
423
168
|
'clickable-column': cell?.onClick,
|
|
424
169
|
'word-break': column.break,
|
|
425
170
|
'no-border': isExtended,
|
|
@@ -437,7 +182,7 @@ export const Table: FC<ITable> = ({
|
|
|
437
182
|
{/* ////// EXTENDABLE ROW ////// */}
|
|
438
183
|
{isExtended && (
|
|
439
184
|
<tr>
|
|
440
|
-
<td colSpan={
|
|
185
|
+
<td colSpan={columns.length} className={rowHeight}>
|
|
441
186
|
{row.extendable!.element}
|
|
442
187
|
</td>
|
|
443
188
|
</tr>
|
|
@@ -448,27 +193,22 @@ export const Table: FC<ITable> = ({
|
|
|
448
193
|
</>
|
|
449
194
|
) : (
|
|
450
195
|
<tr>
|
|
451
|
-
<td
|
|
452
|
-
{t('NoResults')}
|
|
453
|
-
</td>
|
|
196
|
+
<td colSpan={columns.length}>{t('NoResults')}</td>
|
|
454
197
|
</tr>
|
|
455
198
|
)}
|
|
456
199
|
</tbody>
|
|
457
|
-
<tfoot
|
|
458
|
-
|
|
459
|
-
>
|
|
460
|
-
{!!EditableRow &&
|
|
200
|
+
<tfoot>
|
|
201
|
+
{!!editable &&
|
|
461
202
|
!editable.selectedItem &&
|
|
462
203
|
!editable.addDisabled &&
|
|
463
|
-
|
|
464
|
-
(keyboard?.enabled && !isAdding ? (
|
|
204
|
+
(!editable.isAdding ? (
|
|
465
205
|
////// NEW ITEM ROW //////
|
|
466
206
|
<tr
|
|
467
207
|
data-id="add"
|
|
468
|
-
className={
|
|
469
|
-
focusedRow?.uuid === 'add'
|
|
470
|
-
}
|
|
471
|
-
onClick={() => setIsAdding(true)}
|
|
208
|
+
className={clsx('clickable', {
|
|
209
|
+
focused: focusedRow?.uuid === 'add',
|
|
210
|
+
})}
|
|
211
|
+
onClick={() => editable.setIsAdding(true)}
|
|
472
212
|
>
|
|
473
213
|
<td className={`text-center ${rowHeight}`} colSpan={columns.length}>
|
|
474
214
|
<div className="flex center gap-2">
|
|
@@ -478,23 +218,13 @@ export const Table: FC<ITable> = ({
|
|
|
478
218
|
</td>
|
|
479
219
|
</tr>
|
|
480
220
|
) : (
|
|
481
|
-
<
|
|
482
|
-
columns={cols}
|
|
483
|
-
data={editableData}
|
|
484
|
-
setData={setEditableData}
|
|
485
|
-
defaultDataValue={editable.defaultDataValue}
|
|
486
|
-
clearItem={() => {
|
|
487
|
-
editable.setSelectedItem?.(null);
|
|
488
|
-
isAdding && setIsAdding(false);
|
|
489
|
-
}}
|
|
490
|
-
inputFocusRef={editable.inputFocusRef}
|
|
491
|
-
/>
|
|
221
|
+
<TableEditRow />
|
|
492
222
|
))}
|
|
493
223
|
{!!sumRows &&
|
|
494
224
|
!!data.length &&
|
|
495
225
|
sumRows.map(row => (
|
|
496
226
|
<tr key={row.uuid}>
|
|
497
|
-
{
|
|
227
|
+
{columns.map(({ id: columnId }) => (
|
|
498
228
|
<td
|
|
499
229
|
key={columnId}
|
|
500
230
|
align={row.cells[columnId]?.align || 'right'}
|
|
@@ -510,14 +240,14 @@ export const Table: FC<ITable> = ({
|
|
|
510
240
|
</table>
|
|
511
241
|
</ConditionalWrapper>
|
|
512
242
|
</div>
|
|
513
|
-
{
|
|
514
|
-
(!!data.length ||
|
|
515
|
-
(noTotalRows && (serverSidePagination?.offset || offset) > 0)) && (
|
|
243
|
+
{footer &&
|
|
244
|
+
(!!data.length || (noTotalRows && footer!.paginationControl!.offset > 0)) && (
|
|
516
245
|
<TableFooter
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
footerAction={footerAction}
|
|
246
|
+
pagination={footer.paginationControl}
|
|
247
|
+
totalRows={footer.totalRows}
|
|
520
248
|
noTotalRows={noTotalRows}
|
|
249
|
+
customLimit={footer.customPagination?.customLimit}
|
|
250
|
+
footerAction={footer.footerAction}
|
|
521
251
|
dataLength={data.length}
|
|
522
252
|
/>
|
|
523
253
|
)}
|
|
@@ -525,3 +255,9 @@ export const Table: FC<ITable> = ({
|
|
|
525
255
|
</Loader>
|
|
526
256
|
);
|
|
527
257
|
};
|
|
258
|
+
|
|
259
|
+
export const Table: FC<ITable> = props => (
|
|
260
|
+
<TableProvider {...props}>
|
|
261
|
+
<TableContent />
|
|
262
|
+
</TableProvider>
|
|
263
|
+
);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { FC, useEffect, useRef } from 'react';
|
|
2
|
+
import { ITableDataItem } from '../../../../types/ITable';
|
|
3
|
+
import { IconButton } from '../../../Button/IconButton';
|
|
4
|
+
import { faCheck, faXmark } from '../../../../assets/icons';
|
|
5
|
+
import { useTableContext } from '../../contexts/TableContext';
|
|
6
|
+
import { useGetFocusableElements } from '../../../../hooks/useGetFocusableElements';
|
|
7
|
+
|
|
8
|
+
export const TableEditRow: FC = () => {
|
|
9
|
+
const { columns, editable } = useTableContext();
|
|
10
|
+
|
|
11
|
+
const elementRef = useRef(null);
|
|
12
|
+
|
|
13
|
+
const focusableElements = useGetFocusableElements({
|
|
14
|
+
elementRef,
|
|
15
|
+
isOpen: true,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
focusableElements[0]?.focus();
|
|
20
|
+
}, [focusableElements]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
editable!.setEditData(editable!.selectedItem ?? editable!.defaultDataValue ?? {});
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
}, [editable?.setEditData, editable?.selectedItem, editable?.defaultDataValue]);
|
|
26
|
+
|
|
27
|
+
let rowCells = {
|
|
28
|
+
...editable?.cells,
|
|
29
|
+
actions: {
|
|
30
|
+
value: (
|
|
31
|
+
<div className="flex center gap-1">
|
|
32
|
+
<IconButton icon={faCheck} size="s" type="submit" />
|
|
33
|
+
<IconButton
|
|
34
|
+
icon={faXmark}
|
|
35
|
+
size="s"
|
|
36
|
+
onClick={() => {
|
|
37
|
+
editable?.setEditData(editable?.defaultDataValue || {});
|
|
38
|
+
if (editable?.isAdding) {
|
|
39
|
+
editable.setIsAdding(false);
|
|
40
|
+
} else {
|
|
41
|
+
editable?.setSelectedItem(null);
|
|
42
|
+
}
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const rowData: ITableDataItem = { uuid: editable?.selectedItem?.uuid, cells: rowCells };
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<tr ref={elementRef} data-id={rowData.uuid} className="edit-row">
|
|
54
|
+
{columns.map(
|
|
55
|
+
column =>
|
|
56
|
+
!column.hidden && (
|
|
57
|
+
<td
|
|
58
|
+
key={column.id}
|
|
59
|
+
align={column.align}
|
|
60
|
+
colSpan={rowData.cells[column.id]?.span}
|
|
61
|
+
className={rowData.cells[column.id]?.className}
|
|
62
|
+
>
|
|
63
|
+
{rowData.cells[column.id]?.value ?? ''}
|
|
64
|
+
</td>
|
|
65
|
+
)
|
|
66
|
+
)}
|
|
67
|
+
</tr>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ITableFilterItem } from '../../../../types/ITable';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
item: ITableFilterItem;
|
|
6
|
+
}
|
|
7
|
+
export const FilterItem: FC<Props> = ({ item }) => (
|
|
8
|
+
<div className="table-filter-item">
|
|
9
|
+
{/* Added zero-width non-breaking space symbol (⁠)
|
|
10
|
+
because of losing focus from input field when first letter of the label is pressed. */}
|
|
11
|
+
{/* <p className="filter-item-label">⁠{item.label}</p> */}
|
|
12
|
+
<p className="filter-item-label">{item.label}</p>
|
|
13
|
+
{item.field}
|
|
14
|
+
</div>
|
|
15
|
+
);
|