@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
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inceptionbg/iui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.36",
|
|
4
4
|
"description": "UI components, elements & utils for Inception ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"types": "dist/index.d.ts",
|
|
8
11
|
"scripts": {
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import './gridTable.scss';
|
|
2
|
-
|
|
3
|
-
import type { FC } from 'react';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
6
|
-
TableProvider,
|
|
7
|
-
useTableContext,
|
|
8
|
-
} from '../../src/components/Table/contexts/TableContext';
|
|
9
|
-
import { useLocalTableSelect } from '../../src/components/Table/hooks/localHooks/useLocalTableSelect';
|
|
10
|
-
import { useLocalTableColumns } from '../../src/components/Table/hooks/localHooks/useLocalTableColumns';
|
|
11
|
-
import type { ITable } from '../../src/types/ITable';
|
|
12
|
-
import { TableFooter } from '../../src/components/Table/components/footer/TableFooter';
|
|
13
|
-
import { useLocalTablePagination } from '../../src/components/Table/hooks/localHooks/useLocalTablePagination';
|
|
14
|
-
|
|
15
|
-
export const Table: FC = () => {
|
|
16
|
-
const { columns, data, footer, maxHeight } = useTableContext();
|
|
17
|
-
|
|
18
|
-
const colCount = columns?.length;
|
|
19
|
-
|
|
20
|
-
const localPagination = useLocalTablePagination({
|
|
21
|
-
defaultLimit: footer?.customPagination?.defaultLimit,
|
|
22
|
-
});
|
|
23
|
-
const pagination = footer?.pagination ?? localPagination;
|
|
24
|
-
const totalRows = footer?.totalRows ?? data.length;
|
|
25
|
-
const noTotalRows = footer?.totalRows === undefined;
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
!!colCount && (
|
|
29
|
-
<div className="iui-table">
|
|
30
|
-
<div className="table-wrapper" style={{ maxHeight }}>
|
|
31
|
-
<div
|
|
32
|
-
className="table-grid"
|
|
33
|
-
style={{
|
|
34
|
-
gridTemplateColumns: `repeat(${colCount}, auto)`,
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
37
|
-
<div className="header-row">
|
|
38
|
-
{columns?.map((col, colIndex) => (
|
|
39
|
-
<div
|
|
40
|
-
key={col.id}
|
|
41
|
-
className={clsx(
|
|
42
|
-
`header cell justify-${col.align || 'left'}`,
|
|
43
|
-
col.color,
|
|
44
|
-
{
|
|
45
|
-
'last-col': colCount === colIndex + 1,
|
|
46
|
-
}
|
|
47
|
-
)}
|
|
48
|
-
>
|
|
49
|
-
{col.label}
|
|
50
|
-
</div>
|
|
51
|
-
))}
|
|
52
|
-
</div>
|
|
53
|
-
<div className="body">
|
|
54
|
-
{data?.map((row, rowIndex) =>
|
|
55
|
-
columns?.map((col, colIndex) => (
|
|
56
|
-
<div
|
|
57
|
-
key={row.uuid + col.id}
|
|
58
|
-
className={clsx(`cell justify-${col.align || 'left'}`, col.color, {
|
|
59
|
-
'last-row': data.length === rowIndex + 1,
|
|
60
|
-
'last-col': colCount === colIndex + 1,
|
|
61
|
-
})}
|
|
62
|
-
>
|
|
63
|
-
{row.cells[col.id as keyof typeof row.cells]?.value}
|
|
64
|
-
</div>
|
|
65
|
-
))
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
{footer && (!!data.length || (noTotalRows && pagination.offset > 0)) && (
|
|
71
|
-
<TableFooter
|
|
72
|
-
pagination={pagination}
|
|
73
|
-
totalRows={totalRows}
|
|
74
|
-
noTotalRows={noTotalRows}
|
|
75
|
-
customLimit={footer.customPagination?.customLimit}
|
|
76
|
-
footerAction={footer.footerAction}
|
|
77
|
-
dataLength={data.length}
|
|
78
|
-
/>
|
|
79
|
-
)}
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const GridTable: FC<ITable> = ({
|
|
86
|
-
columns: initialColumns,
|
|
87
|
-
// setColumns,
|
|
88
|
-
// withColumnsSearch,
|
|
89
|
-
// customHeader,
|
|
90
|
-
data,
|
|
91
|
-
// sumRows,
|
|
92
|
-
// isLoading,
|
|
93
|
-
|
|
94
|
-
// headerWrap,
|
|
95
|
-
// selectedRowUuid,
|
|
96
|
-
rowSelect,
|
|
97
|
-
// filterData,
|
|
98
|
-
// sortData,
|
|
99
|
-
// printData,
|
|
100
|
-
// customPrintData,
|
|
101
|
-
// templates,
|
|
102
|
-
// additionsalOptions,
|
|
103
|
-
// footer,
|
|
104
|
-
// className,
|
|
105
|
-
// rowHeight = 'm',
|
|
106
|
-
// maxHeight,
|
|
107
|
-
// editable,
|
|
108
|
-
// keyboard,
|
|
109
|
-
...props
|
|
110
|
-
}) => {
|
|
111
|
-
const { selectColumn } = useLocalTableSelect({ data, rowSelect });
|
|
112
|
-
const { columns, setColumns } = useLocalTableColumns({ initialColumns, selectColumn });
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<TableProvider columns={columns} setColumns={setColumns} data={data} {...props}>
|
|
116
|
-
<Table />
|
|
117
|
-
</TableProvider>
|
|
118
|
-
);
|
|
119
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
.table-wrapper {
|
|
2
|
-
width: 100%;
|
|
3
|
-
overflow: auto;
|
|
4
|
-
border: 1px solid #ccc;
|
|
5
|
-
border-radius: 8px;
|
|
6
|
-
position: relative;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.table-grid {
|
|
10
|
-
display: grid;
|
|
11
|
-
grid-template-rows: auto 1fr;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.header-row,
|
|
15
|
-
.body {
|
|
16
|
-
display: contents;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.cell {
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: center;
|
|
22
|
-
padding: 10px;
|
|
23
|
-
white-space: nowrap;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
text-overflow: ellipsis;
|
|
26
|
-
min-width: 100px;
|
|
27
|
-
&.secondary {
|
|
28
|
-
background-color: var(--neutral-100);
|
|
29
|
-
}
|
|
30
|
-
&.header {
|
|
31
|
-
background-color: var(--primary-100);
|
|
32
|
-
border-bottom: var(--border);
|
|
33
|
-
position: sticky;
|
|
34
|
-
top: 0;
|
|
35
|
-
}
|
|
36
|
-
&:not(.last-col) {
|
|
37
|
-
border-right: var(--border);
|
|
38
|
-
}
|
|
39
|
-
&:not(.last-row) {
|
|
40
|
-
border-bottom: var(--border);
|
|
41
|
-
}
|
|
42
|
-
}
|
package/idea/Menu/Menu.tsx
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import '@oddbird/popover-polyfill';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import type {
|
|
4
|
-
ReactNode,
|
|
5
|
-
RefObject} from 'react';
|
|
6
|
-
import {
|
|
7
|
-
forwardRef,
|
|
8
|
-
useEffect,
|
|
9
|
-
useImperativeHandle,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from 'react';
|
|
13
|
-
import type { IMenuItem} from './MenuItem';
|
|
14
|
-
import { MenuItem } from './MenuItem';
|
|
15
|
-
|
|
16
|
-
export type MenuPlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
17
|
-
|
|
18
|
-
interface Props {
|
|
19
|
-
id: string;
|
|
20
|
-
renderButton: (ref: RefObject<any>) => ReactNode;
|
|
21
|
-
items?: IMenuItem[];
|
|
22
|
-
placement?: MenuPlacement;
|
|
23
|
-
size?: 's' | 'm' | 'l';
|
|
24
|
-
className?: string;
|
|
25
|
-
classNameItem?: string;
|
|
26
|
-
children?: ReactNode;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface MenuHandle {
|
|
30
|
-
isOpen: boolean;
|
|
31
|
-
handleOpen: () => void;
|
|
32
|
-
handleClose: () => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const Menu = forwardRef<MenuHandle, Props>(
|
|
36
|
-
(
|
|
37
|
-
{
|
|
38
|
-
id,
|
|
39
|
-
renderButton,
|
|
40
|
-
items,
|
|
41
|
-
placement = 'bottom-left',
|
|
42
|
-
size,
|
|
43
|
-
className,
|
|
44
|
-
classNameItem,
|
|
45
|
-
children,
|
|
46
|
-
},
|
|
47
|
-
ref
|
|
48
|
-
) => {
|
|
49
|
-
const buttonRef = useRef<Element>(null);
|
|
50
|
-
const popoverRef = useRef<HTMLDivElement>(null);
|
|
51
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
-
|
|
53
|
-
// Anchor button setup
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (buttonRef.current) {
|
|
56
|
-
buttonRef.current.setAttribute('popovertarget', id);
|
|
57
|
-
buttonRef.current.setAttribute('anchor-name', `--${id}`);
|
|
58
|
-
}
|
|
59
|
-
}, [id]);
|
|
60
|
-
|
|
61
|
-
// Sync open/close state based on native popover behavior
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
const popover = popoverRef.current;
|
|
64
|
-
if (!popover) return;
|
|
65
|
-
|
|
66
|
-
const handleToggle = () => {
|
|
67
|
-
setIsOpen(popover.matches(':open'));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
popover.addEventListener('toggle', handleToggle);
|
|
71
|
-
return () => {
|
|
72
|
-
popover.removeEventListener('toggle', handleToggle);
|
|
73
|
-
};
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
// Expose public API via ref
|
|
77
|
-
useImperativeHandle(
|
|
78
|
-
ref,
|
|
79
|
-
() => ({
|
|
80
|
-
isOpen,
|
|
81
|
-
handleOpen: () => popoverRef.current?.showPopover?.(),
|
|
82
|
-
handleClose: () => popoverRef.current?.hidePopover?.(),
|
|
83
|
-
}),
|
|
84
|
-
[isOpen]
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<>
|
|
89
|
-
{renderButton(buttonRef)}
|
|
90
|
-
<div
|
|
91
|
-
ref={popoverRef}
|
|
92
|
-
role="menu"
|
|
93
|
-
popover="auto"
|
|
94
|
-
className={clsx('iui-menu', size, placement, className)}
|
|
95
|
-
id={id}
|
|
96
|
-
>
|
|
97
|
-
{!!items?.length && (
|
|
98
|
-
<div>
|
|
99
|
-
{items.map(item => (
|
|
100
|
-
<MenuItem
|
|
101
|
-
key={item.label}
|
|
102
|
-
{...item}
|
|
103
|
-
className={classNameItem}
|
|
104
|
-
onClick={e => {
|
|
105
|
-
item.onClick?.(e);
|
|
106
|
-
if (!item.keepOpen) {
|
|
107
|
-
popoverRef.current?.hidePopover?.();
|
|
108
|
-
}
|
|
109
|
-
}}
|
|
110
|
-
/>
|
|
111
|
-
))}
|
|
112
|
-
</div>
|
|
113
|
-
)}
|
|
114
|
-
{children}
|
|
115
|
-
</div>
|
|
116
|
-
</>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
Menu.displayName = 'Menu';
|
package/idea/Menu/MenuItem.tsx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { IconDefinition, RotateProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import type { MouseEventHandler, ReactNode} from 'react';
|
|
5
|
-
import { forwardRef } from 'react';
|
|
6
|
-
import { ConditionalWrapper } from '../Wrappers/ConditionalWrapper';
|
|
7
|
-
import { Link } from 'react-router';
|
|
8
|
-
import { NotificationBadge } from '../Badge/NotificationBadge';
|
|
9
|
-
|
|
10
|
-
export interface IMenuItem {
|
|
11
|
-
label: string;
|
|
12
|
-
icon?: IconDefinition;
|
|
13
|
-
iconRotation?: RotateProp;
|
|
14
|
-
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
15
|
-
to?: string;
|
|
16
|
-
badge?: number;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
hidden?: boolean;
|
|
19
|
-
withDevider?: boolean;
|
|
20
|
-
keepOpen?: boolean;
|
|
21
|
-
className?: string;
|
|
22
|
-
children?: ReactNode;
|
|
23
|
-
}
|
|
24
|
-
export const MenuItem = forwardRef<HTMLDivElement, IMenuItem>(
|
|
25
|
-
(
|
|
26
|
-
{
|
|
27
|
-
label,
|
|
28
|
-
icon,
|
|
29
|
-
iconRotation,
|
|
30
|
-
onClick,
|
|
31
|
-
to,
|
|
32
|
-
badge,
|
|
33
|
-
disabled,
|
|
34
|
-
hidden,
|
|
35
|
-
withDevider,
|
|
36
|
-
className,
|
|
37
|
-
children,
|
|
38
|
-
},
|
|
39
|
-
ref
|
|
40
|
-
) =>
|
|
41
|
-
hidden ? null : (
|
|
42
|
-
<div ref={ref}>
|
|
43
|
-
<ConditionalWrapper
|
|
44
|
-
key={label}
|
|
45
|
-
condition={!disabled && !!to}
|
|
46
|
-
wrapper={children => <Link to={to!}>{children}</Link>}
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
// className="flex align-center gap-1"
|
|
50
|
-
className={clsx(className, {
|
|
51
|
-
'iui-menu-item': !className,
|
|
52
|
-
clickable: !!onClick || !!to,
|
|
53
|
-
disabled,
|
|
54
|
-
'with-devider': withDevider,
|
|
55
|
-
})}
|
|
56
|
-
onClick={disabled ? undefined : onClick}
|
|
57
|
-
>
|
|
58
|
-
{icon && (
|
|
59
|
-
<div className="menu-item-icon">
|
|
60
|
-
<FontAwesomeIcon icon={icon} rotation={iconRotation} />
|
|
61
|
-
</div>
|
|
62
|
-
)}
|
|
63
|
-
{!!badge ? (
|
|
64
|
-
<NotificationBadge number={badge} small className="menu-item-badge">
|
|
65
|
-
<p>{label}</p>
|
|
66
|
-
</NotificationBadge>
|
|
67
|
-
) : (
|
|
68
|
-
<p className="menu-item-label">{label}</p>
|
|
69
|
-
)}
|
|
70
|
-
{children}
|
|
71
|
-
</div>
|
|
72
|
-
</ConditionalWrapper>
|
|
73
|
-
</div>
|
|
74
|
-
)
|
|
75
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import type { MenuHandle } from '../Menu';
|
|
3
|
-
|
|
4
|
-
export const useMenuControl = () => {
|
|
5
|
-
const menuRef = useRef<MenuHandle>(null);
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
menuRef,
|
|
9
|
-
isOpen: menuRef.current?.isOpen,
|
|
10
|
-
onOpen: () => menuRef.current?.handleOpen?.(),
|
|
11
|
-
onClose: () => menuRef.current?.handleClose?.(),
|
|
12
|
-
};
|
|
13
|
-
};
|
package/idea/Menu.tsx
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import type {
|
|
3
|
-
FC,
|
|
4
|
-
ReactNode,
|
|
5
|
-
RefObject} from 'react';
|
|
6
|
-
import {
|
|
7
|
-
useCallback,
|
|
8
|
-
useEffect,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
} from 'react';
|
|
12
|
-
import { createPortal } from 'react-dom';
|
|
13
|
-
import { rootDir } from '../src/utils/RootDir';
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
isOpen: boolean;
|
|
17
|
-
onClose: () => void;
|
|
18
|
-
renderButton: (ref: RefObject<any>) => ReactNode;
|
|
19
|
-
placementX?: 'left' | 'right';
|
|
20
|
-
placementY?: 'bottom' | 'top' | 'auto';
|
|
21
|
-
size?: 's' | 'm' | 'l';
|
|
22
|
-
className?: string;
|
|
23
|
-
children?: ReactNode;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface Offsets {
|
|
27
|
-
offsetTop: number;
|
|
28
|
-
offsetLeft: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const Menu: FC<Props> = ({
|
|
32
|
-
isOpen,
|
|
33
|
-
onClose,
|
|
34
|
-
renderButton,
|
|
35
|
-
placementX,
|
|
36
|
-
placementY = 'auto',
|
|
37
|
-
size,
|
|
38
|
-
className,
|
|
39
|
-
children,
|
|
40
|
-
}) => {
|
|
41
|
-
const menuRef = useRef<HTMLDivElement>(null);
|
|
42
|
-
const portalRef = useRef<HTMLDivElement>(null);
|
|
43
|
-
const containerRef = useRef<Element>(null);
|
|
44
|
-
const [offsets, setOffsets] = useState<Offsets>({
|
|
45
|
-
offsetLeft: 0,
|
|
46
|
-
offsetTop: 0,
|
|
47
|
-
});
|
|
48
|
-
const [maxHeight, setMaxHeight] = useState<number>();
|
|
49
|
-
|
|
50
|
-
const recalculatePosition = useCallback(() => {
|
|
51
|
-
if (containerRef.current && menuRef.current) {
|
|
52
|
-
const containerRect = containerRef.current.getBoundingClientRect();
|
|
53
|
-
const menuRect = menuRef.current.getBoundingClientRect();
|
|
54
|
-
|
|
55
|
-
let offsetTop = containerRect.bottom + 5;
|
|
56
|
-
// let offsetTop = containerRect.bottom + document.documentElement.scrollTop + 5;
|
|
57
|
-
|
|
58
|
-
const offsetLeft =
|
|
59
|
-
containerRect.left +
|
|
60
|
-
(placementX === 'right' ? containerRect.width - menuRect.width : 0);
|
|
61
|
-
// + document.documentElement.scrollLeft;
|
|
62
|
-
|
|
63
|
-
if (placementY === 'bottom') {
|
|
64
|
-
setMaxHeight(window.innerHeight - containerRect.bottom - 20);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (placementY === 'top') {
|
|
68
|
-
setMaxHeight(
|
|
69
|
-
window.innerHeight - containerRect.top + 40
|
|
70
|
-
// - 2 * document.documentElement.scrollTop
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// check for space on the bottom
|
|
75
|
-
if (
|
|
76
|
-
(placementY === 'auto' && offsetTop + menuRect.height > window.innerHeight) ||
|
|
77
|
-
placementY === 'top'
|
|
78
|
-
) {
|
|
79
|
-
offsetTop = containerRect.top - menuRect.height - 5; //+ document.documentElement.scrollTop
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
setOffsets({ offsetTop, offsetLeft });
|
|
83
|
-
}
|
|
84
|
-
}, [menuRef, containerRef, placementX, placementY]);
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
isOpen
|
|
88
|
-
? window.addEventListener('resize', recalculatePosition)
|
|
89
|
-
: window.removeEventListener('resize', recalculatePosition);
|
|
90
|
-
// Disable scroll & fix page resize on menu open
|
|
91
|
-
document.body.style.marginRight =
|
|
92
|
-
isOpen && window.innerWidth > document.body.clientWidth ? '19px' : '';
|
|
93
|
-
// document.body.style.overflow = isOpen ? 'hidden' : '';
|
|
94
|
-
|
|
95
|
-
recalculatePosition();
|
|
96
|
-
return () => {
|
|
97
|
-
window.removeEventListener('resize', recalculatePosition);
|
|
98
|
-
};
|
|
99
|
-
}, [isOpen, recalculatePosition]);
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
const portal = portalRef.current;
|
|
103
|
-
const handleClick = (ev: MouseEvent) => ev.target === portal && onClose();
|
|
104
|
-
isOpen
|
|
105
|
-
? portal?.addEventListener('click', handleClick)
|
|
106
|
-
: portal?.removeEventListener('click', handleClick);
|
|
107
|
-
return () => portal?.removeEventListener('click', handleClick);
|
|
108
|
-
}, [isOpen, onClose]);
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<>
|
|
112
|
-
{renderButton(containerRef)}
|
|
113
|
-
{isOpen
|
|
114
|
-
? createPortal(
|
|
115
|
-
<div ref={portalRef} className="portal-background">
|
|
116
|
-
<div
|
|
117
|
-
ref={menuRef}
|
|
118
|
-
className={clsx('iui-menu', className, size)}
|
|
119
|
-
style={{
|
|
120
|
-
top: offsets.offsetTop + 'px',
|
|
121
|
-
left: offsets.offsetLeft + 'px',
|
|
122
|
-
maxHeight: maxHeight || undefined,
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{children}
|
|
126
|
-
</div>
|
|
127
|
-
</div>,
|
|
128
|
-
rootDir
|
|
129
|
-
)
|
|
130
|
-
: null}
|
|
131
|
-
</>
|
|
132
|
-
);
|
|
133
|
-
};
|