@inceptionbg/iui 2.0.35 → 2.0.36
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/package.json +4 -1
- package/idea/GridTable/GridTable.tsx +0 -119
- package/idea/GridTable/gridTable.scss +0 -42
- package/idea/Menu/Menu.tsx +0 -121
- package/idea/Menu/MenuItem.tsx +0 -75
- package/idea/Menu/hooks/useMenuControl.ts +0 -13
- package/idea/Menu.tsx +0 -133
- package/idea/NoAccessInfo.tsx +0 -193
- package/idea/Table/Components/Edit/ItemActionsMenu.tsx +0 -85
- package/idea/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -31
- package/idea/Table/Components/Edit/TableEditRow.tsx +0 -57
- package/idea/Table/Components/FilterItem.tsx +0 -20
- package/idea/Table/Components/Header/TableHeader.tsx +0 -46
- package/idea/Table/Components/Header/TableHeaderRow.tsx +0 -37
- package/idea/Table/Components/Print/CustomTablePrint.tsx +0 -115
- package/idea/Table/Components/SetSortList.tsx +0 -30
- package/idea/Table/Components/SetTableFilter.tsx +0 -91
- package/idea/Table/Components/TableFooter.tsx +0 -137
- package/idea/Table/Components/TableOptions.tsx +0 -227
- package/idea/Table/Components/Templates/TemplateCreate.tsx +0 -80
- package/idea/Table/Components/Templates/TemplateCreateDefault.tsx +0 -45
- package/idea/Table/Components/Templates/TemplateList.tsx +0 -167
- package/idea/Table/Components/Templates/repo/TemplateRepo.ts +0 -53
- package/idea/Table/Table.tsx +0 -528
- package/idea/Table/hooks/useDefaultTemplate.ts +0 -20
- package/idea/Table/hooks/useTableKeyboard.ts +0 -137
- package/idea/Table/hooks/useTableSelect.ts +0 -11
- package/rollup.config.js +0 -52
- package/src/assets/icons/duotone/faBell.ts +0 -17
- package/src/assets/icons/duotone/faCircleUser.ts +0 -17
- package/src/assets/icons/regular/faArrowLeft.ts +0 -15
- package/src/assets/icons/regular/faArrowRightArrowLeft.ts +0 -15
- package/src/assets/icons/regular/faCircleCheck.ts +0 -15
- package/src/assets/icons/regular/faCircleExclamation.ts +0 -15
- package/src/assets/icons/regular/faCircleInfo.ts +0 -15
- package/src/assets/icons/regular/faFileArrowDown.ts +0 -15
- package/src/assets/icons/regular/faFilterCircleXmark.ts +0 -15
- package/src/assets/icons/regular/faTriangleExclamation.ts +0 -15
- package/src/assets/icons/solid/faAngleLeft.ts +0 -15
- package/src/assets/icons/solid/faAngleRight.ts +0 -15
- package/src/assets/icons/solid/faArrowDownWideShort.ts +0 -15
- package/src/assets/icons/solid/faCaretDown.ts +0 -15
- package/src/assets/icons/solid/faCheck.ts +0 -15
- package/src/assets/icons/solid/faEllipsisVertical.ts +0 -15
- package/src/assets/icons/solid/faEnvelopeDot.ts +0 -15
- package/src/assets/icons/solid/faFilter.ts +0 -15
- package/src/assets/icons/solid/faFloppyDisk.ts +0 -15
- package/src/assets/icons/solid/faGripDotsVertical.ts +0 -15
- package/src/assets/icons/solid/faListUl.ts +0 -15
- package/src/assets/icons/solid/faMinus.ts +0 -15
- package/src/assets/icons/solid/faPlus.ts +0 -15
- package/src/assets/icons/solid/faPrint.ts +0 -15
- package/src/assets/icons/solid/faRotateRight.ts +0 -15
- package/src/assets/icons/solid/faXmark.ts +0 -15
- package/src/assets/images/logo/inception.svg +0 -22
- package/src/assets/images/logo/mts.svg +0 -5703
- package/src/assets/images/logo/paperless.svg +0 -21
- package/src/assets/images/logo/pismonosa.png +0 -0
- package/src/assets/images/not-found.svg +0 -19
- package/src/components/Accordions/Accordions.tsx +0 -74
- package/src/components/Alert/Alert.tsx +0 -31
- package/src/components/Badge/DotBadge.tsx +0 -16
- package/src/components/Badge/NotificationBadge.tsx +0 -29
- package/src/components/Badge/PillBadge.tsx +0 -13
- package/src/components/Button/Button.tsx +0 -56
- package/src/components/Button/IconButton.tsx +0 -51
- package/src/components/Button/SplitButton.tsx +0 -91
- package/src/components/Dashboard/Dashboard.tsx +0 -9
- package/src/components/Dashboard/DashboardWidget.tsx +0 -44
- package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +0 -36
- package/src/components/Dialog/Dialog.tsx +0 -178
- package/src/components/Dialog/components/DialogFooter.tsx +0 -100
- package/src/components/Header/Components/EnvBadge.tsx +0 -17
- package/src/components/Header/Components/ModuleSelect.tsx +0 -68
- package/src/components/Header/Components/Notifications.tsx +0 -204
- package/src/components/Header/Components/UserMenu.tsx +0 -52
- package/src/components/Header/Header.tsx +0 -45
- package/src/components/Helper/Collapse.tsx +0 -53
- package/src/components/Inputs/Checkbox.tsx +0 -53
- package/src/components/Inputs/CurrencyInput.tsx +0 -124
- package/src/components/Inputs/DateInput/DateInput.tsx +0 -184
- package/src/components/Inputs/DateInput/components/DatePartInput.tsx +0 -159
- package/src/components/Inputs/InputWrapper.tsx +0 -95
- package/src/components/Inputs/NumberInput.tsx +0 -86
- package/src/components/Inputs/PasswordInput.tsx +0 -39
- package/src/components/Inputs/PhoneInput/PhoneInput.tsx +0 -108
- package/src/components/Inputs/PhoneInput/utils/countryCode.ts +0 -20
- package/src/components/Inputs/Radio.tsx +0 -59
- package/src/components/Inputs/RadioGroup.tsx +0 -48
- package/src/components/Inputs/RadioLarge.tsx +0 -39
- package/src/components/Inputs/SearchInput.tsx +0 -46
- package/src/components/Inputs/Selects/Select.tsx +0 -17
- package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +0 -19
- package/src/components/Inputs/Selects/components/SelectWrapper.tsx +0 -118
- package/src/components/Inputs/Selects/utils/selectStyles.ts +0 -101
- package/src/components/Inputs/TextAreaInput.tsx +0 -68
- package/src/components/Inputs/TextInput.tsx +0 -100
- package/src/components/Inputs/TimeInput/TimeInput.tsx +0 -81
- package/src/components/List/List.tsx +0 -21
- package/src/components/List/ListItem.tsx +0 -70
- package/src/components/Loader/Loader.tsx +0 -66
- package/src/components/Loader/ProgressBar.tsx +0 -41
- package/src/components/Menu/Menu.tsx +0 -81
- package/src/components/Menu/MenuItem.tsx +0 -46
- package/src/components/Menu/NewMenu.tsx +0 -63
- package/src/components/Menu/hooks/useMenuPosition.tsx +0 -116
- package/src/components/PageComponents/ScrollableContent.tsx +0 -11
- package/src/components/Pullover/Pullover.tsx +0 -197
- package/src/components/Router/Router.tsx +0 -52
- package/src/components/Sidebar/AddButton.tsx +0 -22
- package/src/components/Sidebar/Sidebar.tsx +0 -85
- package/src/components/Sidebar/SidebarItem.tsx +0 -84
- package/src/components/Sidebar/types/ISidebar.ts +0 -28
- package/src/components/Table/Table.tsx +0 -258
- package/src/components/Table/components/columns/ColumnsList.tsx +0 -60
- package/src/components/Table/components/columns/TableColumnsEdit.tsx +0 -114
- package/src/components/Table/components/edit/TableEditRow.tsx +0 -78
- package/src/components/Table/components/filters/FilterItem.tsx +0 -15
- package/src/components/Table/components/filters/TableFilters.tsx +0 -126
- package/src/components/Table/components/footer/TableFooter.tsx +0 -126
- package/src/components/Table/components/header/TableHeader.tsx +0 -40
- package/src/components/Table/components/header/TableHeaderRow.tsx +0 -57
- package/src/components/Table/components/items/TableItemActions.tsx +0 -78
- package/src/components/Table/components/print/TablePrint.tsx +0 -200
- package/src/components/Table/components/select/TableSelect.tsx +0 -50
- package/src/components/Table/components/sort/TableSort.tsx +0 -75
- package/src/components/Table/components/templates/CreateTemplateDialog.tsx +0 -58
- package/src/components/Table/components/templates/TableTemplates.tsx +0 -65
- package/src/components/Table/components/templates/TemplatesPullover.tsx +0 -88
- package/src/components/Table/contexts/TableContext.tsx +0 -117
- package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +0 -70
- package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +0 -82
- package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +0 -175
- package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +0 -12
- package/src/components/Table/hooks/useTableColumns.ts +0 -34
- package/src/components/Table/hooks/useTableEdit.tsx +0 -140
- package/src/components/Table/hooks/useTableFilterFields.tsx +0 -150
- package/src/components/Table/hooks/useTablePagination.ts +0 -19
- package/src/components/Table/hooks/useTablePrint.ts +0 -83
- package/src/components/Table/hooks/useTableSearch.ts +0 -31
- package/src/components/Table/hooks/useTableSelect.ts +0 -19
- package/src/components/Table/hooks/useTableSort.ts +0 -8
- package/src/components/Tabs/Tabs.tsx +0 -68
- package/src/components/Tooltip/Tooltip.tsx +0 -191
- package/src/components/Tree/Tree.tsx +0 -22
- package/src/components/Tree/TreeItem.tsx +0 -57
- package/src/components/Wrappers/AppLayout.tsx +0 -17
- package/src/components/Wrappers/ConditionalWrapper.tsx +0 -10
- package/src/components/Wrappers/FormWrapper.tsx +0 -84
- package/src/components/Wrappers/PageLayout.tsx +0 -168
- package/src/hooks/useBackgroundClose.ts +0 -19
- package/src/hooks/useGetFocusableElements.ts +0 -43
- package/src/hooks/useIsMenuOpen.ts +0 -11
- package/src/hooks/useLocalPopoverControl.ts +0 -63
- package/src/hooks/useOnEsc.ts +0 -14
- package/src/hooks/usePopupControl.ts +0 -22
- package/src/hooks/useZendesk.ts +0 -22
- package/src/index.ts +0 -387
- package/src/pages/NoAccessPage.tsx +0 -27
- package/src/pages/NotFoundPage.tsx +0 -26
- package/src/styles/App.scss +0 -47
- package/src/styles/common/_animations.scss +0 -58
- package/src/styles/common/_typography.scss +0 -91
- package/src/styles/common/helpers/_base.scss +0 -55
- package/src/styles/common/helpers/_color.scss +0 -10
- package/src/styles/common/helpers/_display.scss +0 -85
- package/src/styles/common/helpers/_size.scss +0 -25
- package/src/styles/common/maps/_align.scss +0 -21
- package/src/styles/common/maps/_buttonMaps.scss +0 -42
- package/src/styles/common/maps/_info-types.scss +0 -1
- package/src/styles/common/maps/_spacing.scss +0 -78
- package/src/styles/common/maps/_text.scss +0 -14
- package/src/styles/components/_accordions.scss +0 -51
- package/src/styles/components/_alert.scss +0 -23
- package/src/styles/components/_badge.scss +0 -84
- package/src/styles/components/_button.scss +0 -99
- package/src/styles/components/_buttonSplit.scss +0 -74
- package/src/styles/components/_card.scss +0 -24
- package/src/styles/components/_dialog.scss +0 -119
- package/src/styles/components/_form.scss +0 -8
- package/src/styles/components/_header.scss +0 -157
- package/src/styles/components/_input.scss +0 -167
- package/src/styles/components/_inputCheckbox.scss +0 -48
- package/src/styles/components/_inputDateTime.scss +0 -161
- package/src/styles/components/_inputRadio.scss +0 -83
- package/src/styles/components/_inputSelect.scss +0 -8
- package/src/styles/components/_list.scss +0 -58
- package/src/styles/components/_loader.scss +0 -55
- package/src/styles/components/_menu-v2.scss +0 -67
- package/src/styles/components/_menu.scss +0 -62
- package/src/styles/components/_notifications.scss +0 -71
- package/src/styles/components/_page.scss +0 -84
- package/src/styles/components/_portal.scss +0 -8
- package/src/styles/components/_print.scss +0 -77
- package/src/styles/components/_progressBar.scss +0 -83
- package/src/styles/components/_pullover.scss +0 -95
- package/src/styles/components/_scrollbar.scss +0 -18
- package/src/styles/components/_sidebar.scss +0 -204
- package/src/styles/components/_smallComponents.scss +0 -23
- package/src/styles/components/_table.scss +0 -340
- package/src/styles/components/_tabs.scss +0 -33
- package/src/styles/components/_tooltip.scss +0 -48
- package/src/styles/components/_tree.scss +0 -21
- package/src/styles/components/_widget.scss +0 -90
- package/src/styles/pages/_fullScreenPage.scss +0 -64
- package/src/styles/variables/_bp.scss +0 -6
- package/src/styles/variables/_variables.scss +0 -142
- package/src/types/Base/custom.d.ts +0 -9
- package/src/types/IBasic.ts +0 -32
- package/src/types/ICountryCode.ts +0 -5
- package/src/types/IError.ts +0 -5
- package/src/types/IHeader.ts +0 -40
- package/src/types/IInfo.ts +0 -1
- package/src/types/IKeyboard.ts +0 -33
- package/src/types/IMenu.ts +0 -19
- package/src/types/INotifications.ts +0 -15
- package/src/types/IPopup.ts +0 -17
- package/src/types/IRouter.ts +0 -6
- package/src/types/ISelect.ts +0 -54
- package/src/types/ITab.ts +0 -10
- package/src/types/ITable.ts +0 -291
- package/src/types/ITree.ts +0 -6
- package/src/utils/InputPatternValidation.ts +0 -12
- package/src/utils/dateUtils.ts +0 -32
- package/src/utils/fileUtils.ts +0 -177
- package/src/utils/i18n/i18nIUICyrilic.ts +0 -119
- package/src/utils/i18n/i18nIUILatin.ts +0 -120
- package/src/utils/i18n/i18nIUIMe.ts +0 -118
- package/src/utils/icons.ts +0 -13
- package/src/utils/localStorageHelper.ts +0 -24
- package/src/utils/logoUtils.ts +0 -7
- package/src/utils/numberUtils.ts +0 -21
- package/src/utils/objectUtils.ts +0 -114
- package/src/utils/popupUtils.ts +0 -82
- package/src/utils/rootDir.ts +0 -1
- package/src/utils/stringUtils.ts +0 -18
- package/src/utils/tableUtils.ts +0 -130
- package/src/utils/toasts.ts +0 -6
- package/src/utils/urlUtils.ts +0 -4
- package/tsconfig.icons.json +0 -5
- package/tsconfig.json +0 -22
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { ITableDataItem, ITableEdit } from '../../../types/ITable';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { deleteProps, hasValue } from '../../../utils/objectUtils';
|
|
4
|
-
import { DateInput } from '../../Inputs/DateInput/DateInput';
|
|
5
|
-
import { NumberInput } from '../../Inputs/NumberInput';
|
|
6
|
-
import { Select } from '../../Inputs/Selects/Select';
|
|
7
|
-
import { TextInput } from '../../Inputs/TextInput';
|
|
8
|
-
|
|
9
|
-
interface BaseItemProps<T> {
|
|
10
|
-
id: keyof T;
|
|
11
|
-
placeholder?: string;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
additionalClearIds?: (keyof T)[];
|
|
14
|
-
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
15
|
-
}
|
|
16
|
-
interface SelectProps<T> extends BaseItemProps<T> {
|
|
17
|
-
options: readonly (string | boolean)[] | (string | boolean)[];
|
|
18
|
-
minWidth?: number;
|
|
19
|
-
formatOption: (value: string | boolean) => {
|
|
20
|
-
value: string | boolean;
|
|
21
|
-
label: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const useTableEdit = <T extends Record<string, any>>() => {
|
|
26
|
-
const [selectedItem, setSelectedItem] = useState<ITableDataItem<T> | null>(null);
|
|
27
|
-
const [editData, setEditData] = useState<Partial<T>>({});
|
|
28
|
-
|
|
29
|
-
// Text
|
|
30
|
-
const textEditCell = ({
|
|
31
|
-
placeholder,
|
|
32
|
-
required,
|
|
33
|
-
id,
|
|
34
|
-
additionalClearIds = [],
|
|
35
|
-
inputProps,
|
|
36
|
-
}: BaseItemProps<T>) => ({
|
|
37
|
-
value: (
|
|
38
|
-
<TextInput
|
|
39
|
-
placeholder={placeholder}
|
|
40
|
-
required={required}
|
|
41
|
-
value={editData[id]}
|
|
42
|
-
setValue={e =>
|
|
43
|
-
setEditData(e ? { ...editData, [id]: e } : deleteProps(editData as T, [id]))
|
|
44
|
-
}
|
|
45
|
-
inputProps={inputProps}
|
|
46
|
-
onClear={() => deleteProps(editData as T, [id, ...additionalClearIds])}
|
|
47
|
-
/>
|
|
48
|
-
),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Number
|
|
52
|
-
const numberEditCell = ({
|
|
53
|
-
placeholder,
|
|
54
|
-
required,
|
|
55
|
-
id,
|
|
56
|
-
additionalClearIds = [],
|
|
57
|
-
inputProps,
|
|
58
|
-
}: BaseItemProps<T>) => ({
|
|
59
|
-
value: (
|
|
60
|
-
<NumberInput
|
|
61
|
-
placeholder={placeholder}
|
|
62
|
-
required={required}
|
|
63
|
-
value={editData[id]}
|
|
64
|
-
setValue={e =>
|
|
65
|
-
setEditData(e ? { ...editData, [id]: e } : deleteProps(editData as T, [id]))
|
|
66
|
-
}
|
|
67
|
-
inputProps={inputProps}
|
|
68
|
-
onClear={() => deleteProps(editData as T, [id, ...additionalClearIds])}
|
|
69
|
-
/>
|
|
70
|
-
),
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Date
|
|
74
|
-
const dateEditCell = ({
|
|
75
|
-
id,
|
|
76
|
-
required,
|
|
77
|
-
additionalClearIds,
|
|
78
|
-
}: Omit<BaseItemProps<T>, 'placeholder' | 'inputProps'>) => ({
|
|
79
|
-
value: (
|
|
80
|
-
<DateInput
|
|
81
|
-
required={required}
|
|
82
|
-
date={editData[id]}
|
|
83
|
-
setDate={e => setEditData({ ...editData, [id]: e })}
|
|
84
|
-
onClear={
|
|
85
|
-
additionalClearIds
|
|
86
|
-
? () => setEditData(deleteProps(editData as T, additionalClearIds))
|
|
87
|
-
: undefined
|
|
88
|
-
}
|
|
89
|
-
/>
|
|
90
|
-
),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Select
|
|
94
|
-
const selectEditCell = ({
|
|
95
|
-
id,
|
|
96
|
-
placeholder,
|
|
97
|
-
required,
|
|
98
|
-
options,
|
|
99
|
-
formatOption,
|
|
100
|
-
additionalClearIds = [],
|
|
101
|
-
minWidth = 110,
|
|
102
|
-
}: SelectProps<T>) => ({
|
|
103
|
-
value: (
|
|
104
|
-
<Select
|
|
105
|
-
required={required}
|
|
106
|
-
placeholder={placeholder}
|
|
107
|
-
value={hasValue(editData[id]) ? formatOption(editData[id]!) : null}
|
|
108
|
-
options={options.map(formatOption)}
|
|
109
|
-
minWidth={minWidth}
|
|
110
|
-
onChange={e => {
|
|
111
|
-
e
|
|
112
|
-
? setEditData({
|
|
113
|
-
...editData,
|
|
114
|
-
[id]: e.value,
|
|
115
|
-
})
|
|
116
|
-
: setEditData(deleteProps(editData as T, [id, ...additionalClearIds]));
|
|
117
|
-
}}
|
|
118
|
-
isClearable
|
|
119
|
-
/>
|
|
120
|
-
),
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const returnEditable: Pick<
|
|
124
|
-
ITableEdit<T>,
|
|
125
|
-
'selectedItem' | 'setSelectedItem' | 'editData' | 'setEditData'
|
|
126
|
-
> = {
|
|
127
|
-
selectedItem,
|
|
128
|
-
setSelectedItem,
|
|
129
|
-
editData,
|
|
130
|
-
setEditData,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
editable: returnEditable,
|
|
135
|
-
textEditCell,
|
|
136
|
-
numberEditCell,
|
|
137
|
-
dateEditCell,
|
|
138
|
-
selectEditCell,
|
|
139
|
-
};
|
|
140
|
-
};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { deleteProps } from '../../../utils/objectUtils';
|
|
4
|
-
import { DateInput } from '../../Inputs/DateInput/DateInput';
|
|
5
|
-
import { Select } from '../../Inputs/Selects/Select';
|
|
6
|
-
import { TextInput } from '../../Inputs/TextInput';
|
|
7
|
-
|
|
8
|
-
interface Props<T> {
|
|
9
|
-
searchData: T;
|
|
10
|
-
setSearchData: Dispatch<SetStateAction<Partial<T>>>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface BaseItemField<T> {
|
|
14
|
-
id: keyof T;
|
|
15
|
-
additionalClearIds?: (keyof T)[];
|
|
16
|
-
}
|
|
17
|
-
interface BaseItemProps<T> extends BaseItemField<T> {
|
|
18
|
-
label: string;
|
|
19
|
-
}
|
|
20
|
-
interface DateFilterProps<T> {
|
|
21
|
-
label: string;
|
|
22
|
-
from: BaseItemField<T>;
|
|
23
|
-
to: BaseItemField<T>;
|
|
24
|
-
}
|
|
25
|
-
interface SelectProps<T> extends BaseItemProps<T> {
|
|
26
|
-
options: readonly string[] | string[];
|
|
27
|
-
formatOption: (value: string) => {
|
|
28
|
-
value: string;
|
|
29
|
-
label: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
interface BooleanSelectProps<T> extends BaseItemProps<T> {
|
|
33
|
-
labelTrue?: string;
|
|
34
|
-
labelFalse?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const useTableFilterFields = <T extends Record<string, any>>({
|
|
38
|
-
searchData,
|
|
39
|
-
setSearchData,
|
|
40
|
-
}: Props<T>) => {
|
|
41
|
-
const { t } = useTranslation();
|
|
42
|
-
|
|
43
|
-
// Text
|
|
44
|
-
const textFilter = ({ label, id, additionalClearIds = [] }: BaseItemProps<T>) => ({
|
|
45
|
-
label,
|
|
46
|
-
field: (
|
|
47
|
-
<TextInput
|
|
48
|
-
placeholder={t('AddInput') + '...'}
|
|
49
|
-
value={searchData[id]}
|
|
50
|
-
setValue={e => setSearchData({ ...searchData, [id]: e })}
|
|
51
|
-
onClear={() =>
|
|
52
|
-
setSearchData(deleteProps(searchData, [id, ...additionalClearIds]))
|
|
53
|
-
}
|
|
54
|
-
/>
|
|
55
|
-
),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Date From - To
|
|
59
|
-
const dateFilter = ({ label, from, to }: DateFilterProps<T>) => ({
|
|
60
|
-
label,
|
|
61
|
-
field: (
|
|
62
|
-
<div className="flex center full-width gap-2">
|
|
63
|
-
<DateInput
|
|
64
|
-
date={searchData[from.id]}
|
|
65
|
-
setDate={e => setSearchData({ ...searchData, [from.id]: e })}
|
|
66
|
-
onClear={() =>
|
|
67
|
-
setSearchData(
|
|
68
|
-
deleteProps(searchData, [from.id, ...(from.additionalClearIds ?? [])])
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
/>
|
|
72
|
-
<p>{t('to')}</p>
|
|
73
|
-
<DateInput
|
|
74
|
-
date={searchData[to.id]}
|
|
75
|
-
setDate={e => setSearchData({ ...searchData, [to.id]: e })}
|
|
76
|
-
onClear={() =>
|
|
77
|
-
setSearchData(
|
|
78
|
-
deleteProps(searchData, [to.id, ...(to.additionalClearIds ?? [])])
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
calendarPlacement="bottom-right"
|
|
82
|
-
/>
|
|
83
|
-
</div>
|
|
84
|
-
),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Select
|
|
88
|
-
const selectFilter = ({ label, id, options, formatOption }: SelectProps<T>) => ({
|
|
89
|
-
label,
|
|
90
|
-
field: (
|
|
91
|
-
<Select
|
|
92
|
-
placeholder={t('Choose')}
|
|
93
|
-
isClearable
|
|
94
|
-
value={searchData[id] ? formatOption(searchData[id]) : null}
|
|
95
|
-
options={options.map(formatOption)}
|
|
96
|
-
onChange={data => {
|
|
97
|
-
data
|
|
98
|
-
? setSearchData({
|
|
99
|
-
...searchData,
|
|
100
|
-
[id]: data.value,
|
|
101
|
-
})
|
|
102
|
-
: setSearchData(deleteProps(searchData, [id]));
|
|
103
|
-
}}
|
|
104
|
-
/>
|
|
105
|
-
),
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Select Boolean
|
|
109
|
-
const booleanSelectFilter = ({
|
|
110
|
-
label,
|
|
111
|
-
id,
|
|
112
|
-
labelFalse,
|
|
113
|
-
labelTrue,
|
|
114
|
-
}: BooleanSelectProps<T>) => ({
|
|
115
|
-
label,
|
|
116
|
-
field: (
|
|
117
|
-
<Select
|
|
118
|
-
placeholder={t('Choose')}
|
|
119
|
-
isClearable
|
|
120
|
-
value={
|
|
121
|
-
searchData[id] !== undefined
|
|
122
|
-
? {
|
|
123
|
-
value: searchData[id],
|
|
124
|
-
label: searchData[id] ? (labelTrue ?? t('Yes')) : (labelFalse ?? t('No')),
|
|
125
|
-
}
|
|
126
|
-
: null
|
|
127
|
-
}
|
|
128
|
-
options={[true, false].map(e => ({
|
|
129
|
-
value: e,
|
|
130
|
-
label: e ? (labelTrue ?? t('Yes')) : (labelFalse ?? t('No')),
|
|
131
|
-
}))}
|
|
132
|
-
onChange={data => {
|
|
133
|
-
data
|
|
134
|
-
? setSearchData({
|
|
135
|
-
...searchData,
|
|
136
|
-
[id]: data.value,
|
|
137
|
-
})
|
|
138
|
-
: setSearchData(deleteProps(searchData, [id]));
|
|
139
|
-
}}
|
|
140
|
-
/>
|
|
141
|
-
),
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
textFilter,
|
|
146
|
-
dateFilter,
|
|
147
|
-
selectFilter,
|
|
148
|
-
booleanSelectFilter,
|
|
149
|
-
};
|
|
150
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IPagination, IPaginationControl } from '../../../types/ITable';
|
|
2
|
-
import { useMemo, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
export const useTablePagination = (defaultLimit: number = 5) => {
|
|
5
|
-
const [limit, setLimit] = useState(defaultLimit);
|
|
6
|
-
const [offset, setOffset] = useState(0);
|
|
7
|
-
|
|
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
|
-
);
|
|
17
|
-
|
|
18
|
-
return { pagination, paginationControl };
|
|
19
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { IGetPrintData, IPrintData, ITableDataItem } from '../../../types/ITable';
|
|
2
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import { usePopupControl } from '../../../hooks/usePopupControl';
|
|
4
|
-
|
|
5
|
-
type Props<T> = {
|
|
6
|
-
getPrintData: IGetPrintData<T>;
|
|
7
|
-
createTableData?: (data: T[]) => ITableDataItem<T>[];
|
|
8
|
-
totalRows?: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const limit = 1000;
|
|
12
|
-
const defaultData = { items: [], totalRows: 0 };
|
|
13
|
-
|
|
14
|
-
export const useTablePrint = <T>({
|
|
15
|
-
getPrintData,
|
|
16
|
-
createTableData,
|
|
17
|
-
totalRows: initialTotalRows = 0,
|
|
18
|
-
}: Props<T>) => {
|
|
19
|
-
const printPopupControl = usePopupControl();
|
|
20
|
-
|
|
21
|
-
const [data, setData] = useState<{ items: T[]; totalRows: number }>(defaultData);
|
|
22
|
-
const [offset, setOffset] = useState(0);
|
|
23
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (printPopupControl.control.isOpen) {
|
|
27
|
-
setIsLoading(true);
|
|
28
|
-
setOffset(0);
|
|
29
|
-
}
|
|
30
|
-
return () => {
|
|
31
|
-
setIsLoading(false);
|
|
32
|
-
setData(defaultData);
|
|
33
|
-
setOffset(0);
|
|
34
|
-
};
|
|
35
|
-
}, [printPopupControl.control.isOpen]);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (printPopupControl.control.isOpen) {
|
|
39
|
-
getPrintData({
|
|
40
|
-
pagination: { limit, offset },
|
|
41
|
-
noTotalRows: !!initialTotalRows || offset > 0,
|
|
42
|
-
})
|
|
43
|
-
.then(({ items, totalRows: newTotalRows }) => {
|
|
44
|
-
setData(prevState => {
|
|
45
|
-
const newData = offset === 0 ? items : prevState.items.concat(items);
|
|
46
|
-
const totalRows =
|
|
47
|
-
newTotalRows || initialTotalRows || prevState.totalRows || 0;
|
|
48
|
-
|
|
49
|
-
if (items?.length === limit) {
|
|
50
|
-
setOffset(offset => offset + 1);
|
|
51
|
-
} else {
|
|
52
|
-
setIsLoading(false);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return { items: newData, totalRows };
|
|
56
|
-
});
|
|
57
|
-
})
|
|
58
|
-
.catch(() => setIsLoading(false));
|
|
59
|
-
}
|
|
60
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
}, [printPopupControl.control.isOpen, initialTotalRows, offset]);
|
|
62
|
-
|
|
63
|
-
const loaded = data.items?.length;
|
|
64
|
-
const progress = data.totalRows ? (loaded / data.totalRows) * 100 : 0;
|
|
65
|
-
|
|
66
|
-
const tableData = useMemo(
|
|
67
|
-
() => (!isLoading ? (createTableData?.(data.items) ?? []) : []),
|
|
68
|
-
[isLoading, data.items, createTableData]
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const printData: Pick<
|
|
72
|
-
IPrintData<T>,
|
|
73
|
-
'tableData' | 'printPopupControl' | 'isLoading' | 'progress' | 'items'
|
|
74
|
-
> = {
|
|
75
|
-
tableData,
|
|
76
|
-
printPopupControl,
|
|
77
|
-
isLoading,
|
|
78
|
-
progress,
|
|
79
|
-
items: data.items ?? [],
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return printData;
|
|
83
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { deletePropsThatEndsWith } from '../../../utils/objectUtils';
|
|
4
|
-
|
|
5
|
-
export interface ITableSearchProps<T> {
|
|
6
|
-
setOffset: Dispatch<SetStateAction<number>>;
|
|
7
|
-
resetSelectedRows?: () => void;
|
|
8
|
-
defaultSearch?: T;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const useTableSearch = <T>({
|
|
12
|
-
setOffset,
|
|
13
|
-
resetSelectedRows,
|
|
14
|
-
defaultSearch = {} as T,
|
|
15
|
-
}: ITableSearchProps<T>) => {
|
|
16
|
-
const [search, setSearch] = useState<T>(defaultSearch);
|
|
17
|
-
const [searchData, setSearchData] = useState<T>(defaultSearch);
|
|
18
|
-
|
|
19
|
-
const onSearch = (filters: T) => {
|
|
20
|
-
setOffset(0);
|
|
21
|
-
resetSelectedRows?.();
|
|
22
|
-
setSearch(<T>deletePropsThatEndsWith(filters, 'Obj'));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
search,
|
|
27
|
-
searchData,
|
|
28
|
-
setSearchData,
|
|
29
|
-
onSearch,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ITableSelectedAction } from '../../../types/ITable';
|
|
2
|
-
import { useMemo, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
export const useTableSelect = (actions: ITableSelectedAction[] = []) => {
|
|
5
|
-
const [selectedRows, setSelectedRows] = useState(new Set<string>());
|
|
6
|
-
|
|
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;
|
|
19
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import type { ITab } from '../../types/ITab';
|
|
3
|
-
import { useMemo, useState } from 'react';
|
|
4
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
tabs: ITab[];
|
|
9
|
-
initialValue?: string;
|
|
10
|
-
control?: {
|
|
11
|
-
value: string;
|
|
12
|
-
setValue: (value: string) => void;
|
|
13
|
-
};
|
|
14
|
-
onChange?: (value: string) => void;
|
|
15
|
-
noWrap?: boolean;
|
|
16
|
-
className?: string;
|
|
17
|
-
classNameContent?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Tabs: FC<Props> = ({
|
|
21
|
-
tabs,
|
|
22
|
-
initialValue,
|
|
23
|
-
control,
|
|
24
|
-
onChange,
|
|
25
|
-
noWrap,
|
|
26
|
-
className,
|
|
27
|
-
classNameContent,
|
|
28
|
-
}) => {
|
|
29
|
-
const filteredTabs = useMemo(() => tabs.filter(e => !e.hidden), [tabs]);
|
|
30
|
-
|
|
31
|
-
const [selected, setSelected] = useState(initialValue || filteredTabs[0]?.value || '');
|
|
32
|
-
|
|
33
|
-
const activeTab = filteredTabs.find(tab => (control?.value ?? selected) === tab.value);
|
|
34
|
-
|
|
35
|
-
return filteredTabs.length > 0 ? (
|
|
36
|
-
<div className={className}>
|
|
37
|
-
<div className="iui-tabs">
|
|
38
|
-
{filteredTabs.map(tab => (
|
|
39
|
-
<div
|
|
40
|
-
id={tab.value}
|
|
41
|
-
key={tab.value}
|
|
42
|
-
className={clsx('iui-tab clickable', {
|
|
43
|
-
selected: (control?.value ?? selected) === tab.value,
|
|
44
|
-
disabled: tab.disabled,
|
|
45
|
-
'no-wrap': noWrap,
|
|
46
|
-
})}
|
|
47
|
-
onClick={
|
|
48
|
-
tab.disabled
|
|
49
|
-
? undefined
|
|
50
|
-
: () => {
|
|
51
|
-
!!control ? control.setValue(tab.value) : setSelected(tab.value);
|
|
52
|
-
onChange?.(tab.value);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
>
|
|
56
|
-
{tab.icon && <FontAwesomeIcon icon={tab.icon} />}
|
|
57
|
-
{tab.label}
|
|
58
|
-
</div>
|
|
59
|
-
))}
|
|
60
|
-
</div>
|
|
61
|
-
{activeTab && (
|
|
62
|
-
<div key={activeTab.value} className={clsx('iui-tab-content', classNameContent)}>
|
|
63
|
-
{activeTab.component}
|
|
64
|
-
</div>
|
|
65
|
-
)}
|
|
66
|
-
</div>
|
|
67
|
-
) : null;
|
|
68
|
-
};
|