@inceptionbg/iui 2.0.13 → 2.0.15
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/index.d.ts +85 -50
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/iui.css +1 -1
- package/package.json +1 -1
- package/src/assets/icons/light/faBookmark.ts +15 -15
- package/src/assets/icons/light/faBookmarkSlash.ts +15 -15
- package/src/assets/images/logo/inception.svg +22 -0
- package/src/components/Dialog/components/DialogFooter.tsx +18 -16
- package/src/components/Header/Components/ModuleSelect.tsx +15 -10
- package/src/components/Header/Components/UserMenu.tsx +1 -0
- package/src/components/List/List.tsx +4 -2
- package/src/components/List/ListItem.tsx +58 -13
- package/src/components/Menu/Menu.tsx +5 -1
- package/src/components/Pullover/Pullover.tsx +36 -22
- package/src/components/Sidebar/Sidebar.tsx +6 -4
- package/src/components/Table/Table.tsx +1 -4
- package/src/components/Table/components/edit/TableEditRow.tsx +4 -1
- package/src/components/Table/components/filters/TableFilters.tsx +4 -1
- package/src/components/Table/components/items/TableItemActions.tsx +12 -3
- package/src/components/Table/components/print/TablePrint.tsx +4 -1
- package/src/components/Table/components/templates/TableTemplates.tsx +49 -55
- package/src/components/Table/contexts/TableContext.tsx +13 -17
- package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +8 -10
- package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +1 -1
- package/src/components/Table/hooks/useTableColumns.ts +28 -0
- package/src/components/Table/hooks/useTablePagination.ts +10 -7
- package/src/components/Table/hooks/useTableSelect.ts +15 -7
- package/src/index.ts +12 -2
- package/src/styles/components/_header.scss +26 -5
- package/src/styles/components/_list.scss +18 -1
- package/src/styles/components/_page.scss +2 -1
- package/src/styles/components/_sidebar.scss +2 -2
- package/src/types/ITable.ts +40 -31
- package/src/utils/i18n/i18nIUICyrilic.ts +21 -12
- package/src/utils/i18n/i18nIUILatin.ts +8 -2
- package/src/utils/i18n/i18nIUIMe.ts +20 -10
- package/src/utils/logoUtils.ts +7 -0
- package/src/utils/tableUtils.ts +5 -5
- package/src/components/Table/components/templates/components/CreateTemplateDialog.tsx +0 -41
- package/src/components/Table/hooks/useDefaultTemplate.ts +0 -20
|
@@ -21,6 +21,7 @@ interface Props {
|
|
|
21
21
|
title: string;
|
|
22
22
|
onSearch?: (search: string) => void;
|
|
23
23
|
};
|
|
24
|
+
isFetching?: boolean;
|
|
24
25
|
isLoading?: boolean;
|
|
25
26
|
onFormSubmit?: () => void;
|
|
26
27
|
onContentClick?: () => void;
|
|
@@ -36,6 +37,7 @@ export const Pullover: FC<Props> = ({
|
|
|
36
37
|
id,
|
|
37
38
|
control,
|
|
38
39
|
header,
|
|
40
|
+
isFetching = false,
|
|
39
41
|
isLoading = false,
|
|
40
42
|
onFormSubmit,
|
|
41
43
|
onContentClick,
|
|
@@ -50,7 +52,7 @@ export const Pullover: FC<Props> = ({
|
|
|
50
52
|
const { t } = useTranslation();
|
|
51
53
|
const searchRef = useRef<HTMLInputElement>(null);
|
|
52
54
|
|
|
53
|
-
const ConfirmButton = footer?.confirmButton
|
|
55
|
+
const ConfirmButton = footer?.confirmButton?.splitActions ? SplitButton : Button;
|
|
54
56
|
|
|
55
57
|
const { elementRef, isOpen, onClose } = useLocalPopoverControl({
|
|
56
58
|
control,
|
|
@@ -77,10 +79,10 @@ export const Pullover: FC<Props> = ({
|
|
|
77
79
|
onClose,
|
|
78
80
|
enter: {
|
|
79
81
|
onAction: () => {
|
|
80
|
-
footer?.confirmButton
|
|
81
|
-
!footer?.confirmButton
|
|
82
|
+
footer?.confirmButton?.onClick?.();
|
|
83
|
+
!footer?.confirmButton?.keepOpen && onClose();
|
|
82
84
|
},
|
|
83
|
-
disabled: !footer?.confirmButton
|
|
85
|
+
disabled: !footer?.confirmButton?.onClick,
|
|
84
86
|
},
|
|
85
87
|
search: {
|
|
86
88
|
onAction: () => searchRef.current?.focus(),
|
|
@@ -131,14 +133,18 @@ export const Pullover: FC<Props> = ({
|
|
|
131
133
|
)}
|
|
132
134
|
>
|
|
133
135
|
{/* CONTENT */}
|
|
134
|
-
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
{isLoading ? (
|
|
137
|
+
<Loader isLoading isFullPage />
|
|
138
|
+
) : (
|
|
139
|
+
<Loader isLoading={isFetching}>
|
|
140
|
+
<div
|
|
141
|
+
onClick={onContentClick}
|
|
142
|
+
className={clsx('pullover-content', contentClassName)}
|
|
143
|
+
>
|
|
144
|
+
{children}
|
|
145
|
+
</div>
|
|
146
|
+
</Loader>
|
|
147
|
+
)}
|
|
142
148
|
|
|
143
149
|
{/* FOOTER */}
|
|
144
150
|
{footer && (
|
|
@@ -146,7 +152,9 @@ export const Pullover: FC<Props> = ({
|
|
|
146
152
|
{footer.additionalButton && (
|
|
147
153
|
<Button
|
|
148
154
|
{...footer.additionalButton}
|
|
149
|
-
disabled={
|
|
155
|
+
disabled={
|
|
156
|
+
footer.additionalButton.disabled || isFetching || isLoading
|
|
157
|
+
}
|
|
150
158
|
variant="simple"
|
|
151
159
|
className="mr-auto"
|
|
152
160
|
/>
|
|
@@ -155,16 +163,22 @@ export const Pullover: FC<Props> = ({
|
|
|
155
163
|
label={t('Cancel')}
|
|
156
164
|
variant="outlined"
|
|
157
165
|
onClick={onClose}
|
|
158
|
-
disabled={isLoading}
|
|
159
|
-
/>
|
|
160
|
-
<ConfirmButton
|
|
161
|
-
{...footer.confirmButton}
|
|
162
|
-
label={footer.confirmButton.label ?? t('Confirm')}
|
|
163
|
-
disabled={footer.confirmButton.disabled || isLoading}
|
|
164
|
-
type={
|
|
165
|
-
(footer.confirmButton.type ?? onFormSubmit) ? 'submit' : 'button'
|
|
166
|
-
}
|
|
166
|
+
disabled={isFetching || isLoading}
|
|
167
167
|
/>
|
|
168
|
+
{footer.confirmButton && (
|
|
169
|
+
<ConfirmButton
|
|
170
|
+
{...footer.confirmButton}
|
|
171
|
+
label={footer.confirmButton.label ?? t('Confirm')}
|
|
172
|
+
disabled={
|
|
173
|
+
footer.confirmButton.disabled || isFetching || isLoading
|
|
174
|
+
}
|
|
175
|
+
type={
|
|
176
|
+
(footer.confirmButton.type ?? onFormSubmit)
|
|
177
|
+
? 'submit'
|
|
178
|
+
: 'button'
|
|
179
|
+
}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
168
182
|
</div>
|
|
169
183
|
)}
|
|
170
184
|
</ConditionalWrapper>
|
|
@@ -4,13 +4,15 @@ import { SidebarItem } from './SidebarItem';
|
|
|
4
4
|
import { ISidebarItem } from './types/ISidebar';
|
|
5
5
|
import { faAngleLeft } from '../../assets/icons/solid/faAngleLeft';
|
|
6
6
|
import { IconButton } from '../Button/IconButton';
|
|
7
|
+
import { IOrgLogo, orgLogo } from '../../utils/logoUtils';
|
|
7
8
|
|
|
8
9
|
export interface ISidebarProps {
|
|
9
10
|
items: ISidebarItem[][];
|
|
10
|
-
logo?:
|
|
11
|
+
logo?: IOrgLogo;
|
|
12
|
+
customLogo?: string;
|
|
11
13
|
appVersion?: string;
|
|
12
14
|
}
|
|
13
|
-
export const Sidebar: FC<ISidebarProps> = ({ items, logo, appVersion }) => {
|
|
15
|
+
export const Sidebar: FC<ISidebarProps> = ({ items, logo, customLogo, appVersion }) => {
|
|
14
16
|
const [itemsList, setItemsList] = useState<ISidebarItem[][]>([]);
|
|
15
17
|
const [collapsed, setCollapsed] = useState(false);
|
|
16
18
|
const [openedMenu, setOpenedMenu] = useState('');
|
|
@@ -66,11 +68,11 @@ export const Sidebar: FC<ISidebarProps> = ({ items, logo, appVersion }) => {
|
|
|
66
68
|
</div>
|
|
67
69
|
{/* ////// FOOTER ////// */}
|
|
68
70
|
<div className={clsx('sidebar-footer', { collapsed })}>
|
|
69
|
-
{logo && (
|
|
71
|
+
{(logo ?? customLogo) && (
|
|
70
72
|
<img
|
|
71
73
|
className="sidebar-logo"
|
|
72
74
|
// src={!!organization?.reseller ? orgLogo[organization?.reseller] : logo}
|
|
73
|
-
src={logo}
|
|
75
|
+
src={customLogo || orgLogo[logo || 'INC']}
|
|
74
76
|
alt="logo"
|
|
75
77
|
/>
|
|
76
78
|
)}
|
|
@@ -20,17 +20,14 @@ import { TableTemplates } from './components/templates/TableTemplates';
|
|
|
20
20
|
|
|
21
21
|
export const TableContent: FC = () => {
|
|
22
22
|
const {
|
|
23
|
-
columns,
|
|
23
|
+
columnData: { columns },
|
|
24
24
|
customHeader,
|
|
25
25
|
headerWrap,
|
|
26
|
-
// setColumns,
|
|
27
|
-
// withColumnsSearch,
|
|
28
26
|
data,
|
|
29
27
|
sumRows,
|
|
30
28
|
isLoading,
|
|
31
29
|
selectedRowUuid,
|
|
32
30
|
// customPrintData,
|
|
33
|
-
// templates,
|
|
34
31
|
// additionsalOptions,
|
|
35
32
|
footer,
|
|
36
33
|
rowHeight = 'm',
|
|
@@ -6,7 +6,10 @@ import { useTableContext } from '../../contexts/TableContext';
|
|
|
6
6
|
import { useGetFocusableElements } from '../../../../hooks/useGetFocusableElements';
|
|
7
7
|
|
|
8
8
|
export const TableEditRow: FC = () => {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
columnData: { columns },
|
|
11
|
+
editable,
|
|
12
|
+
} = useTableContext();
|
|
10
13
|
|
|
11
14
|
const elementRef = useRef(null);
|
|
12
15
|
|
|
@@ -20,7 +20,10 @@ import { usePopupControl } from '../../../../hooks/usePopupControl';
|
|
|
20
20
|
|
|
21
21
|
export const TableFilters: FC = () => {
|
|
22
22
|
const { t } = useTranslation();
|
|
23
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
columnData: { columns },
|
|
25
|
+
filterData,
|
|
26
|
+
} = useTableContext();
|
|
24
27
|
const { control, onClose, onOpen } = usePopupControl();
|
|
25
28
|
const columnIds = getVisibleColumnsIds(columns);
|
|
26
29
|
|
|
@@ -22,14 +22,20 @@ export const TableItemActions: FC<{ tableDataItem: ITableDataItem }> = ({
|
|
|
22
22
|
{dataActions.isEditable && (
|
|
23
23
|
<IconButton
|
|
24
24
|
icon={faPen}
|
|
25
|
-
onClick={
|
|
25
|
+
onClick={e => {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
editable?.setSelectedItem(tableDataItem.item ?? null);
|
|
28
|
+
}}
|
|
26
29
|
size="s"
|
|
27
30
|
/>
|
|
28
31
|
)}
|
|
29
32
|
{dataActions.isDeletable && (
|
|
30
33
|
<IconButton
|
|
31
34
|
icon={faTrashCan}
|
|
32
|
-
onClick={
|
|
35
|
+
onClick={e => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
dataActions.delete?.onClick?.(tableDataItem.uuid);
|
|
38
|
+
}}
|
|
33
39
|
size="s"
|
|
34
40
|
color="danger"
|
|
35
41
|
/>
|
|
@@ -45,7 +51,10 @@ export const TableItemActions: FC<{ tableDataItem: ITableDataItem }> = ({
|
|
|
45
51
|
ref={ref}
|
|
46
52
|
icon={faEllipsisVertical}
|
|
47
53
|
active={isMenuOpen}
|
|
48
|
-
onClick={
|
|
54
|
+
onClick={e => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
onMenuOpen();
|
|
57
|
+
}}
|
|
49
58
|
size="s"
|
|
50
59
|
/>
|
|
51
60
|
)}
|
|
@@ -15,7 +15,10 @@ import { ProgressBar } from '../../../Loader/ProgressBar';
|
|
|
15
15
|
export const TablePrint: FC = () => {
|
|
16
16
|
const { t } = useTranslation();
|
|
17
17
|
useHideZendesk();
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
columnData: { columns },
|
|
20
|
+
printData,
|
|
21
|
+
} = useTableContext();
|
|
19
22
|
|
|
20
23
|
const {
|
|
21
24
|
label,
|
|
@@ -1,98 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type FC } from 'react';
|
|
2
2
|
import { IconButton } from '../../../Button/IconButton';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { useTableContext } from '../../contexts/TableContext';
|
|
5
|
-
import { faBookmark, faBookmarkSlash,
|
|
6
|
-
import { usePopupControl } from '../../../../hooks/usePopupControl';
|
|
5
|
+
import { faBookmark, faBookmarkSlash, faTrashCan } from '../../../../assets/icons';
|
|
7
6
|
import { Pullover } from '../../../Pullover/Pullover';
|
|
8
7
|
import { List } from '../../../List/List';
|
|
9
|
-
import {
|
|
10
|
-
import { TextInput } from '../../../Inputs/TextInput';
|
|
11
|
-
import { CreateTemplateDialog } from './components/CreateTemplateDialog';
|
|
8
|
+
import { setTemplateData } from '../../../../utils/tableUtils';
|
|
12
9
|
|
|
13
10
|
export const TableTemplates: FC = () => {
|
|
14
11
|
const { t } = useTranslation();
|
|
15
|
-
const { templateData
|
|
16
|
-
const { control, onOpen } = usePopupControl();
|
|
17
|
-
// const { control: dialogControl, onOpen: onDialogOpen } = usePopupControl();
|
|
12
|
+
const { templateData, columnData, filterData, sortData } = useTableContext();
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
if (!templateData) return null;
|
|
20
15
|
|
|
21
16
|
return (
|
|
22
17
|
<>
|
|
23
18
|
<IconButton
|
|
24
19
|
tooltip={t('Templates')}
|
|
25
20
|
icon={faBookmark}
|
|
26
|
-
active={control.isOpen}
|
|
27
|
-
onClick={onOpen}
|
|
21
|
+
active={templateData.popupController.control.isOpen}
|
|
22
|
+
onClick={templateData.popupController.onOpen}
|
|
28
23
|
size="s"
|
|
29
24
|
variant="outlined"
|
|
30
25
|
/>
|
|
31
26
|
<Pullover
|
|
32
|
-
|
|
27
|
+
isLoading={templateData.isLoading}
|
|
28
|
+
isFetching={templateData.isFetching}
|
|
29
|
+
control={templateData.popupController.control}
|
|
33
30
|
header={{
|
|
34
31
|
title: t('Templates'),
|
|
35
|
-
onSearch:
|
|
32
|
+
onSearch: templateData.setSearch,
|
|
36
33
|
}}
|
|
37
|
-
onContentClick={() => setSelectedItemId(null)}
|
|
38
34
|
footer={{
|
|
39
35
|
confirmButton: {
|
|
40
|
-
label: t('
|
|
41
|
-
|
|
36
|
+
label: t('CreateTemplate'),
|
|
37
|
+
onClick: templateData.initiateCreate,
|
|
42
38
|
splitActions: [
|
|
43
|
-
{
|
|
44
|
-
label: t('CreateTemplateLong'),
|
|
45
|
-
icon: faBookmark,
|
|
46
|
-
// onClick: onDialogOpen,
|
|
47
|
-
},
|
|
48
39
|
{
|
|
49
40
|
label: t('CreateDefaultTemplate'),
|
|
50
41
|
icon: faBookmark,
|
|
51
|
-
onClick:
|
|
52
|
-
// Handle use template action
|
|
53
|
-
},
|
|
42
|
+
onClick: templateData.initiateCreateDefault,
|
|
54
43
|
},
|
|
55
44
|
],
|
|
56
45
|
},
|
|
57
|
-
additionalButton:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
icon: faBookmarkSlash,
|
|
69
|
-
onClick: () => {
|
|
70
|
-
// setSearchData?.(defaultSearch);
|
|
71
|
-
// onSearch?.(defaultSearch);
|
|
72
|
-
// onClose();
|
|
73
|
-
},
|
|
74
|
-
// disabled: defaultSearch
|
|
75
|
-
// ? JSON.stringify(searchData) === JSON.stringify(defaultSearch)
|
|
76
|
-
// : Object.keys(searchData).length === 0,
|
|
77
|
-
},
|
|
78
|
-
}}
|
|
79
|
-
onCloseCallback={() => {
|
|
80
|
-
templates?.setSearch?.('');
|
|
81
|
-
setSelectedItemId(null);
|
|
46
|
+
additionalButton: {
|
|
47
|
+
label: t('ResetTemplate'),
|
|
48
|
+
icon: faBookmarkSlash,
|
|
49
|
+
onClick: () => {
|
|
50
|
+
columnData?.setColumns?.(columnData.defaultColumns);
|
|
51
|
+
filterData?.setSearchData(filterData.defaultSearch ?? {});
|
|
52
|
+
filterData?.onSearch(filterData.defaultSearch ?? {});
|
|
53
|
+
sortData?.setSort('');
|
|
54
|
+
templateData.popupController.onClose();
|
|
55
|
+
},
|
|
56
|
+
},
|
|
82
57
|
}}
|
|
58
|
+
onCloseCallback={() => templateData.setSearch?.('')}
|
|
83
59
|
size="w600"
|
|
84
60
|
>
|
|
85
61
|
<List
|
|
86
|
-
items={
|
|
62
|
+
items={templateData.items.map(item => ({
|
|
87
63
|
id: item.uuid,
|
|
88
64
|
label: item.name,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
65
|
+
desc: item.isPublic ? t('PublicTemplate') : t('PrivateTemplate'),
|
|
66
|
+
onClick: () => {
|
|
67
|
+
setTemplateData({
|
|
68
|
+
template: item,
|
|
69
|
+
columnData,
|
|
70
|
+
setFilters: e => {
|
|
71
|
+
filterData?.setSearchData(e);
|
|
72
|
+
filterData?.onSearch(e);
|
|
73
|
+
},
|
|
74
|
+
setSort: sortData?.setSort,
|
|
75
|
+
});
|
|
76
|
+
templateData.popupController.onClose();
|
|
77
|
+
},
|
|
78
|
+
actions: [
|
|
79
|
+
{
|
|
80
|
+
icon: faTrashCan,
|
|
81
|
+
onClick: () => templateData.setItemToDeleteUuids([item.uuid]),
|
|
82
|
+
color: 'danger',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
92
85
|
}))}
|
|
86
|
+
noItemsMessage={t('NoTemplatesAvailable')}
|
|
93
87
|
/>
|
|
94
|
-
{/* <CreateTemplateDialog control={dialogControl} /> */}
|
|
95
88
|
</Pullover>
|
|
89
|
+
{templateData.TemplateNode}
|
|
96
90
|
</>
|
|
97
91
|
);
|
|
98
92
|
};
|
|
@@ -10,17 +10,17 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
IPaginationControl,
|
|
12
12
|
ITable,
|
|
13
|
-
|
|
13
|
+
ITableColumnsData,
|
|
14
14
|
ITableEdit,
|
|
15
|
-
|
|
15
|
+
ITableSelectedAction,
|
|
16
16
|
} from '../../../types/ITable';
|
|
17
17
|
import { useLocalTablePagination } from '../hooks/localHooks/useLocalTablePagination';
|
|
18
18
|
import { useLocalTableColumns } from '../hooks/localHooks/useLocalTableColumns';
|
|
19
19
|
import { useLocalTableData } from '../hooks/localHooks/useLocalTableData';
|
|
20
20
|
|
|
21
21
|
interface ITableContext extends ITable {
|
|
22
|
-
|
|
23
|
-
selectActions:
|
|
22
|
+
columnData: ITableColumnsData;
|
|
23
|
+
selectActions: ITableSelectedAction[];
|
|
24
24
|
dataActions?: ITable['dataActions'] & {
|
|
25
25
|
hasItemActions: boolean;
|
|
26
26
|
isEditable: boolean;
|
|
@@ -37,10 +37,9 @@ interface ITableContext extends ITable {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const TableContext = createContext<ITableContext>({
|
|
40
|
-
|
|
41
|
-
selectActions: [],
|
|
40
|
+
columnData: { columns: [], defaultColumns: [] },
|
|
42
41
|
data: [],
|
|
43
|
-
|
|
42
|
+
selectActions: [],
|
|
44
43
|
});
|
|
45
44
|
|
|
46
45
|
interface Props extends ITable {
|
|
@@ -48,18 +47,17 @@ interface Props extends ITable {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
export const TableProvider = ({
|
|
51
|
-
|
|
50
|
+
columnData,
|
|
52
51
|
data: initialData,
|
|
53
52
|
dataActions,
|
|
54
53
|
editable,
|
|
55
54
|
footer,
|
|
56
55
|
children,
|
|
56
|
+
rowSelect,
|
|
57
57
|
...rest
|
|
58
58
|
}: Props) => {
|
|
59
59
|
const [isAdding, setIsAdding] = useState(false);
|
|
60
60
|
|
|
61
|
-
const { rowSelect } = rest;
|
|
62
|
-
|
|
63
61
|
const selectActions = useMemo(
|
|
64
62
|
() => rowSelect?.actions.filter(e => !e.hidden) || [],
|
|
65
63
|
[rowSelect?.actions]
|
|
@@ -80,17 +78,16 @@ export const TableProvider = ({
|
|
|
80
78
|
const localPagination = useLocalTablePagination({
|
|
81
79
|
defaultLimit: footer?.customPagination?.defaultLimit,
|
|
82
80
|
});
|
|
83
|
-
|
|
84
|
-
const { data } = useLocalTableData({
|
|
81
|
+
const data = useLocalTableData({
|
|
85
82
|
initialData,
|
|
86
83
|
localPagination,
|
|
87
84
|
controledPagination: !!footer?.paginationControl,
|
|
88
|
-
dataActions,
|
|
85
|
+
dataActions: updatedDataActions,
|
|
89
86
|
rowSelect,
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
useLocalTableColumns({
|
|
90
|
+
columnData,
|
|
94
91
|
hasSelect: selectActions.length > 0,
|
|
95
92
|
data,
|
|
96
93
|
rowSelect,
|
|
@@ -101,8 +98,7 @@ export const TableProvider = ({
|
|
|
101
98
|
...rest,
|
|
102
99
|
data,
|
|
103
100
|
dataActions: updatedDataActions,
|
|
104
|
-
|
|
105
|
-
setColumns,
|
|
101
|
+
columnData,
|
|
106
102
|
selectActions,
|
|
107
103
|
};
|
|
108
104
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useEffect
|
|
2
|
-
import { ITable, ITableColumn } from '../../../../types/ITable';
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { ITable, ITableColumn, ITableColumnsData } from '../../../../types/ITable';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Checkbox } from '../../../Inputs/Checkbox';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
|
|
7
|
+
columnData: ITableColumnsData;
|
|
8
8
|
hasSelect: boolean;
|
|
9
9
|
data: ITable['data'];
|
|
10
10
|
rowSelect: ITable['rowSelect'];
|
|
@@ -12,17 +12,17 @@ interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const useLocalTableColumns = ({
|
|
15
|
-
|
|
15
|
+
columnData: { defaultColumns, setColumns },
|
|
16
16
|
hasSelect,
|
|
17
17
|
data,
|
|
18
18
|
rowSelect,
|
|
19
19
|
hasItemActions,
|
|
20
20
|
}: Props) => {
|
|
21
|
-
const [columns, setColumns] = useState<ITableColumn[]>([]);
|
|
22
21
|
const { t } = useTranslation();
|
|
23
22
|
|
|
24
23
|
useEffect(() => {
|
|
25
|
-
const activeColumns =
|
|
24
|
+
const activeColumns = defaultColumns.filter(e => !e.hidden && !e.unavailable);
|
|
25
|
+
// const activeColumns = defaultColumns.filter(e => !e.unavailable);
|
|
26
26
|
|
|
27
27
|
let newCols: ITableColumn[] = [];
|
|
28
28
|
|
|
@@ -66,8 +66,6 @@ export const useLocalTableColumns = ({
|
|
|
66
66
|
className: 'actions-col',
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
setColumns(newCols);
|
|
70
|
-
}, [
|
|
71
|
-
|
|
72
|
-
return { columns, setColumns };
|
|
69
|
+
setColumns?.(newCols);
|
|
70
|
+
}, [defaultColumns, setColumns, hasSelect, data, rowSelect, hasItemActions, t]);
|
|
73
71
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { ITableColumn, ITableColumnsData } from '../../../types/ITable';
|
|
3
|
+
|
|
4
|
+
export interface ITableColumnsProps {
|
|
5
|
+
defaultColumns: ITableColumn[];
|
|
6
|
+
templateColumns?: ITableColumn[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useTableColumns = ({
|
|
10
|
+
defaultColumns,
|
|
11
|
+
templateColumns,
|
|
12
|
+
}: ITableColumnsProps): ITableColumnsData => {
|
|
13
|
+
const [columns, setColumns] = useState<ITableColumn[]>(defaultColumns);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setColumns(defaultColumns);
|
|
17
|
+
}, [defaultColumns, templateColumns]);
|
|
18
|
+
|
|
19
|
+
const columnData = useMemo(
|
|
20
|
+
() => ({
|
|
21
|
+
defaultColumns,
|
|
22
|
+
columns,
|
|
23
|
+
setColumns,
|
|
24
|
+
}),
|
|
25
|
+
[defaultColumns, columns]
|
|
26
|
+
);
|
|
27
|
+
return columnData;
|
|
28
|
+
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
2
|
import { IPagination, IPaginationControl } from '../../../types/ITable';
|
|
3
3
|
|
|
4
4
|
export const useTablePagination = (defaultLimit: number = 5) => {
|
|
5
5
|
const [limit, setLimit] = useState(defaultLimit);
|
|
6
6
|
const [offset, setOffset] = useState(0);
|
|
7
7
|
|
|
8
|
-
const pagination: IPagination = { limit, offset };
|
|
9
|
-
const paginationControl: IPaginationControl =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const pagination: IPagination = useMemo(() => ({ limit, offset }), [limit, offset]);
|
|
9
|
+
const paginationControl: IPaginationControl = useMemo(
|
|
10
|
+
() => ({
|
|
11
|
+
...pagination,
|
|
12
|
+
setLimit,
|
|
13
|
+
setOffset,
|
|
14
|
+
}),
|
|
15
|
+
[pagination]
|
|
16
|
+
);
|
|
14
17
|
|
|
15
18
|
return { pagination, paginationControl };
|
|
16
19
|
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { ITableSelectedAction } from '../../../types/ITable';
|
|
2
3
|
|
|
3
|
-
export const useTableSelect = () => {
|
|
4
|
+
export const useTableSelect = ({ actions }: { actions: ITableSelectedAction[] }) => {
|
|
4
5
|
const [selectedRows, setSelectedRows] = useState(new Set<string>());
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const rowSelect = useMemo(
|
|
8
|
+
() => ({
|
|
9
|
+
selectedRows,
|
|
10
|
+
setSelectedRows,
|
|
11
|
+
resetSelectedRows: () => setSelectedRows(new Set<string>()),
|
|
12
|
+
actions,
|
|
13
|
+
}),
|
|
14
|
+
// eslint-disable-next-line
|
|
15
|
+
[selectedRows]
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
return rowSelect;
|
|
11
19
|
};
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
IPaginationControl,
|
|
28
28
|
ITable,
|
|
29
29
|
ITableColumn,
|
|
30
|
+
ITableDataActions,
|
|
30
31
|
ITableDataItem,
|
|
31
32
|
ITableDataItemCells,
|
|
32
33
|
ITableEdit,
|
|
@@ -34,6 +35,10 @@ import type {
|
|
|
34
35
|
ITableFilterData,
|
|
35
36
|
ITableFilterItem,
|
|
36
37
|
ITableSort,
|
|
38
|
+
ITableTemplateData,
|
|
39
|
+
IReportTemplate,
|
|
40
|
+
IReportTemplateData,
|
|
41
|
+
IReportTemplateFilterValue,
|
|
37
42
|
} from './types/ITable';
|
|
38
43
|
import type { ITreeItem } from './types/ITree';
|
|
39
44
|
import type { IHeaderAction, IHeaderUserMenuProps } from './types/IHeader';
|
|
@@ -97,7 +102,7 @@ import { Table } from './components/Table/Table';
|
|
|
97
102
|
// import { TableFooter } from './components/Table/Components/TableFooter';
|
|
98
103
|
// import { GridTable } from '../idea/GridTable/GridTable';
|
|
99
104
|
// import { TablePrint } from './components/Table/Components/Print/TablePrint';
|
|
100
|
-
import {
|
|
105
|
+
import { useTableColumns } from './components/Table/hooks/useTableColumns';
|
|
101
106
|
import { useTableEdit } from './components/Table/hooks/useTableEdit';
|
|
102
107
|
import { useTableFilterFields } from './components/Table/hooks/useTableFilterFields';
|
|
103
108
|
import { useTablePagination } from './components/Table/hooks/useTablePagination';
|
|
@@ -234,7 +239,7 @@ export {
|
|
|
234
239
|
// TablePrint,
|
|
235
240
|
// TableEditRow,
|
|
236
241
|
// TableFooter,
|
|
237
|
-
|
|
242
|
+
useTableColumns,
|
|
238
243
|
useTableEdit,
|
|
239
244
|
useTableFilterFields,
|
|
240
245
|
useTablePagination,
|
|
@@ -269,6 +274,7 @@ export type {
|
|
|
269
274
|
ITab,
|
|
270
275
|
ITable,
|
|
271
276
|
ITableColumn,
|
|
277
|
+
ITableDataActions,
|
|
272
278
|
ITableDataItem,
|
|
273
279
|
ITableDataItemCells,
|
|
274
280
|
ITableEdit,
|
|
@@ -276,6 +282,10 @@ export type {
|
|
|
276
282
|
ITableFilterData,
|
|
277
283
|
ITableFilterItem,
|
|
278
284
|
ITableSort,
|
|
285
|
+
ITableTemplateData,
|
|
286
|
+
IReportTemplate,
|
|
287
|
+
IReportTemplateData,
|
|
288
|
+
IReportTemplateFilterValue,
|
|
279
289
|
IGetPrintData,
|
|
280
290
|
ITreeItem,
|
|
281
291
|
IValueLabel,
|