@cashub/ui-elv 1.0.0
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/Tab/Tab.js +28 -0
- package/Tab/TabList.js +167 -0
- package/Tab/TabPanel.js +49 -0
- package/Tab/TabTab.js +105 -0
- package/Tab/index.js +30 -0
- package/Tab/subComponent/TabContext.js +9 -0
- package/Tab/subComponent/TabListV2.js +25 -0
- package/Tab/subComponent/TabPanelV2.js +52 -0
- package/Tab/subComponent/TabTabV2.js +63 -0
- package/VerticalTab/TabList.js +27 -0
- package/VerticalTab/TabPanel.js +52 -0
- package/VerticalTab/TabTab.js +70 -0
- package/VerticalTab/VerticalTab.js +41 -0
- package/VerticalTab/index.js +16 -0
- package/VerticalTab/subComponent/TabContext.js +9 -0
- package/alert/Alert.js +29 -0
- package/alert/index.js +13 -0
- package/animate/Collapse.js +71 -0
- package/animate/Loader.js +58 -0
- package/animate/NumberCounter.js +51 -0
- package/animate/PulseRing.js +35 -0
- package/animate/Spinner.js +18 -0
- package/animate/index.js +41 -0
- package/assets/css/autocomplete.css +16 -0
- package/assets/css/font.css +4 -0
- package/assets/css/global.css +2 -0
- package/assets/font/helvetica/Helvetica.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/assets/icons/app-management.png +0 -0
- package/assets/icons/burger-black.png +0 -0
- package/assets/icons/burger-white.png +0 -0
- package/assets/icons/burger.png +0 -0
- package/assets/icons/file.svg +1 -0
- package/assets/icons/map_icon1.png +0 -0
- package/assets/icons/map_icon4.png +0 -0
- package/assets/images/bg-aside.png +0 -0
- package/assets/images/bg-chart-circle.png +0 -0
- package/assets/images/bg-chart-triangle.png +0 -0
- package/assets/images/cashub-logo-only.png +0 -0
- package/assets/images/default-user.jpg +0 -0
- package/assets/images/logo-cashub.png +0 -0
- package/assets/images/map.png +0 -0
- package/assets/images/qrcode.png +0 -0
- package/backdrop/BaseBackdrop.js +18 -0
- package/backdrop/LoadingBackdrop.js +17 -0
- package/backdrop/ModalBackdrop.js +15 -0
- package/backdrop/index.js +27 -0
- package/badge/Badge.js +26 -0
- package/badge/BadgeDot.js +18 -0
- package/badge/BadgeFill.js +49 -0
- package/badge/BadgeFillTriangle.js +147 -0
- package/badge/BadgeWithText.js +31 -0
- package/badge/index.js +41 -0
- package/billing/BarChart.js +51 -0
- package/billing/Grid.js +45 -0
- package/billing/Header2.js +25 -0
- package/billing/Header3.js +37 -0
- package/billing/Paragraph.js +33 -0
- package/billing/ParagraphGroup.js +22 -0
- package/billing/ParagraphText.js +26 -0
- package/billing/Section.js +50 -0
- package/billing/SectionBody.js +17 -0
- package/billing/SectionHeader.js +26 -0
- package/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/billing/__stories__/Grid.stories.js_bak +57 -0
- package/billing/__stories__/Header2.stories.js_bak +62 -0
- package/billing/__stories__/Header3.stories.js_bak +69 -0
- package/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/billing/__stories__/Section.stories.js_bak +115 -0
- package/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/breadcrumb/Breadcrumb.js +78 -0
- package/breadcrumb/index.js +13 -0
- package/button/Button.js +154 -0
- package/button/ButtonGroup.js +61 -0
- package/button/IconButton.js +72 -0
- package/button/ScrollToTopButton.js +54 -0
- package/button/index.js +34 -0
- package/callout/Callout.js +52 -0
- package/callout/index.js +13 -0
- package/chart/BarChart.js +148 -0
- package/chart/DoughnutChart.js +118 -0
- package/chart/LineChart.js +146 -0
- package/chart/SingleBarChart.js +42 -0
- package/chart/index.js +52 -0
- package/chart/utils/centerTextPlugin.js +62 -0
- package/chart/utils/customTooltip.js +94 -0
- package/chart/utils/htmlLegendPlugin.js +89 -0
- package/chart/utils/index.js +27 -0
- package/chart/utils/padEmptyChartBar.js +53 -0
- package/chart/utils/yAxisTopTitlePlugin.js +49 -0
- package/container/FlexContainer.js +40 -0
- package/container/index.js +13 -0
- package/cropper/Cropper.js +54 -0
- package/cropper/CropperModalHandler.js +41 -0
- package/cropper/index.js +20 -0
- package/cropper/subComponent/CropImageModal.js +79 -0
- package/datetimePicker/DatePicker.js +363 -0
- package/datetimePicker/DatePickerV2.js +407 -0
- package/datetimePicker/DatetimePicker.js +240 -0
- package/datetimePicker/DatetimePickerV2.js +395 -0
- package/datetimePicker/DatetimePickerV3.js +279 -0
- package/datetimePicker/TimeInput.js +56 -0
- package/datetimePicker/TimePicker.js +317 -0
- package/datetimePicker/TimePickerStyle.js +64 -0
- package/datetimePicker/TimePickerV2.js +208 -0
- package/datetimePicker/accordion/Month.js +254 -0
- package/datetimePicker/accordion/Year.js +284 -0
- package/datetimePicker/hooks/index.js +27 -0
- package/datetimePicker/hooks/useChangeNumber.js +42 -0
- package/datetimePicker/hooks/useDecrease.js +38 -0
- package/datetimePicker/hooks/useIncrease.js +38 -0
- package/datetimePicker/index.js +69 -0
- package/datetimePicker/provider/constant.js +43 -0
- package/datetimePicker/subComponent/Accordion.js +373 -0
- package/datetimePicker/subComponent/CustomTimeInput.js +47 -0
- package/datetimePicker/subComponent/DateTimePickerContext.js +9 -0
- package/datetimePicker/utils/GMTDate.js +15 -0
- package/datetimePicker/utils/pad.js +13 -0
- package/datetimePicker/utils/toUTC0.js +13 -0
- package/descriptionList/DescriptionDetail.js +28 -0
- package/descriptionList/DescriptionList.js +25 -0
- package/descriptionList/DescriptionTerm.js +14 -0
- package/descriptionList/index.js +27 -0
- package/divider/Divider.js +31 -0
- package/divider/index.js +13 -0
- package/dropdown/Dropdown.js +55 -0
- package/dropdown/DropdownButtonOption.js +43 -0
- package/dropdown/DropdownContent.js +90 -0
- package/dropdown/DropdownDivOption.js +26 -0
- package/dropdown/DropdownItem.js +26 -0
- package/dropdown/DropdownLinkOption.js +24 -0
- package/dropdown/DropdownToggle.js +38 -0
- package/dropdown/index.js +42 -0
- package/dropdown/subComponent/DropdownContext.js +9 -0
- package/dropzone/FileDropzone.js +479 -0
- package/dropzone/ImageDropzone.js +334 -0
- package/dropzone/index.js +20 -0
- package/dropzone/subComponent/Message.js +26 -0
- package/figure/IconFigure.js +42 -0
- package/figure/ImageFigure.js +38 -0
- package/figure/index.js +20 -0
- package/file/HiddenFileInput.js +15 -0
- package/file/index.js +13 -0
- package/form/Checkbox.js +166 -0
- package/form/Fieldset.js +18 -0
- package/form/FormItem.js +22 -0
- package/form/Input.js +66 -0
- package/form/Label.js +61 -0
- package/form/MutedText.js +21 -0
- package/form/PasswordInput.js +47 -0
- package/form/RadioButton.js +103 -0
- package/form/SearchSelect.js +181 -0
- package/form/Searchbox.js +98 -0
- package/form/Slider.js +46 -0
- package/form/SwitchButton.js +105 -0
- package/form/Textarea.js +41 -0
- package/form/TreeView.js +73 -0
- package/form/index.js +104 -0
- package/grid/Column.js +46 -0
- package/grid/Grid.js +35 -0
- package/grid/index.js +20 -0
- package/heading/Heading1.js +21 -0
- package/heading/Heading2.js +28 -0
- package/heading/Heading3.js +49 -0
- package/heading/index.js +27 -0
- package/helmet/Helmet.js +23 -0
- package/helmet/index.js +20 -0
- package/iconbox/ApplicationIconBox.js +81 -0
- package/iconbox/IconBox.js +67 -0
- package/iconbox/IconBoxV2.js +72 -0
- package/iconbox/index.js +27 -0
- package/iconbox/subComponent/IconBoxFigure.js +50 -0
- package/iconbox/subComponent/IconBoxImage.js +42 -0
- package/image/ImageFluid.js +17 -0
- package/image/UploadImage.js +250 -0
- package/image/index.js +20 -0
- package/index.js +568 -0
- package/jsoneditor/JsonEditor.js +142 -0
- package/jsoneditor/index.js +13 -0
- package/keyframe/Pulse.js +21 -0
- package/keyframe/Spin.js +13 -0
- package/layout/Aside.js +48 -0
- package/layout/AsideHeader.jsx +27 -0
- package/layout/Backdrop.js +23 -0
- package/layout/Container.js +39 -0
- package/layout/Footer.js +45 -0
- package/layout/Header.jsx +55 -0
- package/layout/Layout.jsx +84 -0
- package/layout/Logo.jsx +17 -0
- package/layout/MenuIcon.jsx +27 -0
- package/layout/Sidebar.jsx +271 -0
- package/layout/index.js +13 -0
- package/link/LinkSpan.js +69 -0
- package/link/index.js +13 -0
- package/map/GoogleMap.js +448 -0
- package/map/GoogleReverseGeolocation.js +200 -0
- package/map/LeafletMap.js +231 -0
- package/map/LeafletReverseGeolocation.js +101 -0
- package/map/index.js +34 -0
- package/map/subComponent/BasicLeafletMap.js +34 -0
- package/map/subComponent/GoogleMapContainer.js +29 -0
- package/map/subComponent/GoogleMapPopup.js +109 -0
- package/map/subComponent/GoogleMapWrapper.js +40 -0
- package/map/subComponent/LeafletDrawControl.js +127 -0
- package/map/subComponent/LeafletMapContainer.js +173 -0
- package/map/subComponent/MapSearchBoxControl.js +54 -0
- package/modal/StateModal.js +178 -0
- package/modal/TitleModal.js +250 -0
- package/modal/index.js +20 -0
- package/package.json +54 -0
- package/page/Disclaimer.js +128 -0
- package/page/index.js +13 -0
- package/paginate/Paginate.js +137 -0
- package/paginate/index.js +13 -0
- package/popover/Popover.js +91 -0
- package/popover/index.js +13 -0
- package/qrcode/QRCode.js +58 -0
- package/qrcode/QRCodeContainter.js +34 -0
- package/qrcode/index.js +20 -0
- package/ribbon/Ribbon.js +42 -0
- package/ribbon/index.js +13 -0
- package/section/Section.js +133 -0
- package/section/SectionBody.js +52 -0
- package/section/SectionHeader.js +70 -0
- package/section/SectionToolbar.js +18 -0
- package/section/SectionToolbarItem.js +17 -0
- package/section/index.js +41 -0
- package/select/InputSelect.js +270 -0
- package/select/Select.js +818 -0
- package/select/index.js +20 -0
- package/select/subComponent/Checkbox.js +48 -0
- package/select/subComponent/Footer.js +13 -0
- package/select/subComponent/ListBox.js +30 -0
- package/select/subComponent/Option.js +45 -0
- package/select/subComponent/OptionGroup.js +23 -0
- package/select/subComponent/Options.js +32 -0
- package/select/subComponent/SearchBox.js +58 -0
- package/select/subComponent/SelectedMultipleCount.js +39 -0
- package/select/subComponent/SelectedMultipleTags.js +54 -0
- package/select/subComponent/SelectedMultipleText.js +70 -0
- package/select/subComponent/SelectedSingle.js +17 -0
- package/styles/GlobalStyle.js +334 -0
- package/styles/config/breakpoint.style.js +13 -0
- package/styles/config/header.style.js +10 -0
- package/styles/config/sidebar.style.js +17 -0
- package/styles/index.js +20 -0
- package/styles/mixin/backgroundColor.js +44 -0
- package/styles/mixin/borderColor.js +37 -0
- package/styles/mixin/color.js +37 -0
- package/styles/mixin/colorOnBackground.js +37 -0
- package/styles/mixin/inputPlaceholder.js +30 -0
- package/styles/mixin/media.js +21 -0
- package/styles/mixin/rounded.js +30 -0
- package/styles/mixin/scrollbar.js +32 -0
- package/styles/theme/dark.theme.js +97 -0
- package/styles/theme/light.theme.js +97 -0
- package/styles/theme/white.theme.js +97 -0
- package/styles/themes.js +16 -0
- package/table/GridTable.js +336 -0
- package/table/ImageBox.js +45 -0
- package/table/InfiniteGridTable.js +403 -0
- package/table/PermissionTable.js +64 -0
- package/table/SimpleGridTable.js +143 -0
- package/table/Table.js +568 -0
- package/table/__mock__/columns.js +70 -0
- package/table/__mock__/data.js +536 -0
- package/table/hooks/index.js +20 -0
- package/table/hooks/useCalculateDataRange.js +28 -0
- package/table/hooks/useGenerateSort.js +39 -0
- package/table/index.js +48 -0
- package/table/subComponent/BaseTableHeadCell.js +62 -0
- package/table/subComponent/GridTableFooter.js +24 -0
- package/table/subComponent/GridTableHeadCell.js +20 -0
- package/table/subComponent/Resizer.js +77 -0
- package/table/subComponent/TableFooter.js +31 -0
- package/table/subComponent/TableFooterInfo.js +13 -0
- package/table/subComponent/TableFooterPager.js +33 -0
- package/table/subComponent/TableHeadCell.js +19 -0
- package/table/subComponent/TableSort.js +38 -0
- package/tagify/TagifyStyle.js +60 -0
- package/tagify/Tags.js +56 -0
- package/tagify/index.js +27 -0
- package/tagify/templates/getCreateButtonTemplate.js +18 -0
- package/text/Paragraph.js +86 -0
- package/text/index.js +13 -0
- package/timeline/Timeline.js +139 -0
- package/timeline/index.js +13 -0
- package/toast/CustomToastContainer.js +45 -0
- package/toast/MessageContainer.js +51 -0
- package/toast/index.js +36 -0
- package/toast/show.js +39 -0
- package/toast/style.css +1 -0
- package/tooltip/Tooltip.js +140 -0
- package/tooltip/index.js +13 -0
- package/treeView/TreeViewV2.js +38 -0
- package/treeView/TreeflexStyle.js +49 -0
- package/treeView/index.js +20 -0
- package/wizard/Wizard.js +251 -0
- package/wizard/index.js +13 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
var _hooks = require("./hooks");
|
|
10
|
+
var _scrollbar = _interopRequireDefault(require("../styles/mixin/scrollbar"));
|
|
11
|
+
var _GridTableHeadCell = _interopRequireDefault(require("./subComponent/GridTableHeadCell"));
|
|
12
|
+
var _Resizer = _interopRequireDefault(require("./subComponent/Resizer"));
|
|
13
|
+
var _Popover = _interopRequireDefault(require("../popover/Popover"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const ROW_HEIGHT = 48;
|
|
17
|
+
const OVER_SCAN_COUNT = 5;
|
|
18
|
+
const InfiniteGridTable = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
containerHeight,
|
|
21
|
+
scrollTop,
|
|
22
|
+
columns,
|
|
23
|
+
data,
|
|
24
|
+
sortColumn,
|
|
25
|
+
sortType,
|
|
26
|
+
onSortChange,
|
|
27
|
+
backgroundReverse,
|
|
28
|
+
translation
|
|
29
|
+
} = _ref;
|
|
30
|
+
const wrapperRef = (0, _react.useRef)(null);
|
|
31
|
+
const tableRef = (0, _react.useRef)(null);
|
|
32
|
+
const tableHeadRef = (0, _react.useRef)(null);
|
|
33
|
+
const [wrapperTop, setWrapperTop] = (0, _react.useState)(0);
|
|
34
|
+
const [tableColumns, setTableColumns] = (0, _react.useState)(columns);
|
|
35
|
+
const [tableWidth, setTableWidth] = (0, _react.useState)(0);
|
|
36
|
+
const [restWidth, setRestWidth] = (0, _react.useState)(0);
|
|
37
|
+
const [theadHeight, setTheadHeight] = (0, _react.useState)(0);
|
|
38
|
+
const texts = (0, _react.useMemo)(() => {
|
|
39
|
+
const defaultTexts = {
|
|
40
|
+
info: 'Showing _START_ to _END_ of _TOTAL_ entries',
|
|
41
|
+
empty: 'No data available in table'
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
...defaultTexts,
|
|
45
|
+
...translation
|
|
46
|
+
};
|
|
47
|
+
}, [translation]);
|
|
48
|
+
const tableHeight = (0, _react.useMemo)(() => {
|
|
49
|
+
// when data is empty, table will generate a row to show a message
|
|
50
|
+
const rowCounts = data.length || 1;
|
|
51
|
+
return theadHeight + rowCounts * ROW_HEIGHT;
|
|
52
|
+
}, [theadHeight, data.length]);
|
|
53
|
+
const visibleRowCounts = (0, _react.useMemo)(() => {
|
|
54
|
+
return Math.ceil(containerHeight / ROW_HEIGHT);
|
|
55
|
+
}, [containerHeight]);
|
|
56
|
+
const startIndex = (0, _react.useMemo)(() => {
|
|
57
|
+
const top = Math.max(0, scrollTop - wrapperTop);
|
|
58
|
+
return Math.max(0, Math.floor(top / ROW_HEIGHT) - OVER_SCAN_COUNT);
|
|
59
|
+
}, [wrapperTop, scrollTop]);
|
|
60
|
+
const endIndex = (0, _react.useMemo)(() => {
|
|
61
|
+
return Math.min(data.length, startIndex + visibleRowCounts + OVER_SCAN_COUNT * 2);
|
|
62
|
+
}, [data.length, startIndex, visibleRowCounts]);
|
|
63
|
+
const visibleData = (0, _react.useMemo)(() => {
|
|
64
|
+
return data.slice(startIndex, endIndex);
|
|
65
|
+
}, [data, startIndex, endIndex]);
|
|
66
|
+
const handleSortChange = (0, _react.useCallback)(columnName => {
|
|
67
|
+
if (onSortChange) {
|
|
68
|
+
onSortChange(columnName);
|
|
69
|
+
}
|
|
70
|
+
}, [onSortChange]);
|
|
71
|
+
const calculateWrapperTop = (0, _react.useCallback)(() => {
|
|
72
|
+
const {
|
|
73
|
+
top
|
|
74
|
+
} = wrapperRef.current.getBoundingClientRect();
|
|
75
|
+
setWrapperTop(top + window.scrollY);
|
|
76
|
+
}, []);
|
|
77
|
+
const calculateTableWidth = (0, _react.useCallback)(() => {
|
|
78
|
+
setTableWidth(tableRef.current.offsetWidth);
|
|
79
|
+
setRestWidth(previousWidth => {
|
|
80
|
+
const containerWidth = wrapperRef.current.offsetWidth;
|
|
81
|
+
const tableWidth = tableRef.current.offsetWidth - previousWidth;
|
|
82
|
+
if (containerWidth > tableWidth) {
|
|
83
|
+
return containerWidth - tableWidth;
|
|
84
|
+
}
|
|
85
|
+
return 0;
|
|
86
|
+
});
|
|
87
|
+
}, []);
|
|
88
|
+
const handleResize = (0, _react.useCallback)(() => {
|
|
89
|
+
calculateWrapperTop();
|
|
90
|
+
calculateTableWidth();
|
|
91
|
+
}, [calculateWrapperTop, calculateTableWidth]);
|
|
92
|
+
const handleResizeColumn = (0, _react.useCallback)((targetIndex, width) => {
|
|
93
|
+
setTableColumns(previous => {
|
|
94
|
+
return previous.map((column, index) => {
|
|
95
|
+
if (index === targetIndex) {
|
|
96
|
+
return {
|
|
97
|
+
...column,
|
|
98
|
+
width: `${width}px`
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
...column
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}, []);
|
|
107
|
+
const handleScroll = (0, _react.useCallback)(event => {
|
|
108
|
+
const {
|
|
109
|
+
target
|
|
110
|
+
} = event;
|
|
111
|
+
wrapperRef.current.scrollLeft = target.scrollLeft;
|
|
112
|
+
}, []);
|
|
113
|
+
const showFullValue = (0, _react.useCallback)(event => {
|
|
114
|
+
let {
|
|
115
|
+
id
|
|
116
|
+
} = event.target;
|
|
117
|
+
if (!id) {
|
|
118
|
+
({
|
|
119
|
+
id
|
|
120
|
+
} = event.currentTarget);
|
|
121
|
+
event.target.id = id;
|
|
122
|
+
}
|
|
123
|
+
const {
|
|
124
|
+
offsetWidth,
|
|
125
|
+
scrollWidth,
|
|
126
|
+
innerText
|
|
127
|
+
} = event.target;
|
|
128
|
+
if (scrollWidth >= offsetWidth && innerText) {
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
(0, _Popover.default)({
|
|
131
|
+
id,
|
|
132
|
+
target: event.target,
|
|
133
|
+
content: innerText,
|
|
134
|
+
boundary: tableRef.current
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
|
|
139
|
+
// generate sort icon area
|
|
140
|
+
const generateSort = (0, _hooks.useGenerateSort)(sortColumn, sortType);
|
|
141
|
+
const tableHeads = (0, _react.useMemo)(() => {
|
|
142
|
+
const tableHeads = tableColumns.map((column, index) => {
|
|
143
|
+
const {
|
|
144
|
+
title,
|
|
145
|
+
fieldName,
|
|
146
|
+
width,
|
|
147
|
+
sortable,
|
|
148
|
+
align
|
|
149
|
+
} = column;
|
|
150
|
+
let key = 'TH';
|
|
151
|
+
if (title) {
|
|
152
|
+
key += `${key}${title}`;
|
|
153
|
+
} else if (fieldName) {
|
|
154
|
+
key += `${key}${fieldName}`;
|
|
155
|
+
} else {
|
|
156
|
+
key += `${key}${index}`;
|
|
157
|
+
}
|
|
158
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridTableHeadCell.default, {
|
|
159
|
+
width: width,
|
|
160
|
+
align: align,
|
|
161
|
+
backgroundReverse: backgroundReverse,
|
|
162
|
+
sortable: sortable,
|
|
163
|
+
onClick: () => {
|
|
164
|
+
sortable && handleSortChange(fieldName);
|
|
165
|
+
},
|
|
166
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
167
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
168
|
+
id: fieldName,
|
|
169
|
+
onClick: showFullValue,
|
|
170
|
+
children: title
|
|
171
|
+
}), sortable && generateSort(fieldName)]
|
|
172
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Resizer.default, {
|
|
173
|
+
index: index,
|
|
174
|
+
onResize: handleResizeColumn
|
|
175
|
+
})]
|
|
176
|
+
}, key);
|
|
177
|
+
});
|
|
178
|
+
tableHeads.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridTableHeadCell.default, {
|
|
179
|
+
role: "presentation",
|
|
180
|
+
width: restWidth,
|
|
181
|
+
backgroundReverse: backgroundReverse
|
|
182
|
+
}, 'rest'));
|
|
183
|
+
return tableHeads;
|
|
184
|
+
}, [backgroundReverse, tableColumns, handleSortChange, generateSort, showFullValue, handleResizeColumn, restWidth]);
|
|
185
|
+
const tableRows = (0, _react.useMemo)(() => {
|
|
186
|
+
if (visibleData.length === 0) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
return visibleData.map((row, rowIndex) => {
|
|
190
|
+
const tds = tableColumns.map((column, columnIndex) => {
|
|
191
|
+
const {
|
|
192
|
+
title,
|
|
193
|
+
fieldName,
|
|
194
|
+
render,
|
|
195
|
+
custom,
|
|
196
|
+
width,
|
|
197
|
+
...props
|
|
198
|
+
} = column;
|
|
199
|
+
const key = rowIndex + columnIndex.toString();
|
|
200
|
+
let renderedData = null;
|
|
201
|
+
if (custom && render) {
|
|
202
|
+
// call render function to get custom data(fully)
|
|
203
|
+
renderedData = render(row);
|
|
204
|
+
} else {
|
|
205
|
+
// call render function to get custom data(part)
|
|
206
|
+
renderedData = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
207
|
+
id: key,
|
|
208
|
+
onClick: showFullValue,
|
|
209
|
+
children: render ? render(row[fieldName], row) : String(row[fieldName])
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TD, {
|
|
213
|
+
"data-label": title,
|
|
214
|
+
backgroundReverse: backgroundReverse,
|
|
215
|
+
$width: width,
|
|
216
|
+
...props,
|
|
217
|
+
children: renderedData
|
|
218
|
+
}, columnIndex);
|
|
219
|
+
});
|
|
220
|
+
tds.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(TD, {
|
|
221
|
+
role: "presentation",
|
|
222
|
+
width: restWidth,
|
|
223
|
+
backgroundReverse: backgroundReverse
|
|
224
|
+
}, 'rest'));
|
|
225
|
+
const index = rowIndex + startIndex;
|
|
226
|
+
const top = index * ROW_HEIGHT + theadHeight;
|
|
227
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
228
|
+
"data-index": index,
|
|
229
|
+
style: {
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
display: 'flex',
|
|
232
|
+
left: 0,
|
|
233
|
+
top: `${top}px`
|
|
234
|
+
},
|
|
235
|
+
children: tds
|
|
236
|
+
}, index);
|
|
237
|
+
});
|
|
238
|
+
}, [backgroundReverse, tableColumns, visibleData, showFullValue, restWidth, startIndex, theadHeight]);
|
|
239
|
+
const generateEmptyMessage = (0, _react.useCallback)(() => {
|
|
240
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
241
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TD, {
|
|
242
|
+
center: true,
|
|
243
|
+
colSpan: tableColumns.length,
|
|
244
|
+
backgroundReverse: backgroundReverse,
|
|
245
|
+
children: texts.empty
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
}, [backgroundReverse, tableColumns, texts]);
|
|
249
|
+
|
|
250
|
+
// merge previous column width to columns array
|
|
251
|
+
(0, _react.useEffect)(() => {
|
|
252
|
+
setTableColumns(previousColumns => {
|
|
253
|
+
return columns.map(column => {
|
|
254
|
+
const previousColumn = previousColumns.find(previousColumn => {
|
|
255
|
+
const {
|
|
256
|
+
title: previousTitle,
|
|
257
|
+
fieldName: previousFieldName
|
|
258
|
+
} = previousColumn;
|
|
259
|
+
const {
|
|
260
|
+
title,
|
|
261
|
+
fieldName
|
|
262
|
+
} = column;
|
|
263
|
+
return title === previousTitle && fieldName === previousFieldName;
|
|
264
|
+
});
|
|
265
|
+
const width = previousColumn?.width || column.width;
|
|
266
|
+
return {
|
|
267
|
+
...column,
|
|
268
|
+
width
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}, [columns]);
|
|
273
|
+
(0, _react.useEffect)(() => {
|
|
274
|
+
handleResize();
|
|
275
|
+
}, [tableColumns, handleResize]);
|
|
276
|
+
(0, _react.useEffect)(() => {
|
|
277
|
+
window.addEventListener('resize', handleResize);
|
|
278
|
+
return () => {
|
|
279
|
+
window.removeEventListener('resize', handleResize);
|
|
280
|
+
};
|
|
281
|
+
}, [handleResize]);
|
|
282
|
+
(0, _react.useEffect)(() => {
|
|
283
|
+
if (tableRef.current) {
|
|
284
|
+
setTableWidth(tableRef.current.offsetWidth);
|
|
285
|
+
}
|
|
286
|
+
}, [columns]);
|
|
287
|
+
(0, _react.useLayoutEffect)(() => {
|
|
288
|
+
if (tableHeadRef.current) {
|
|
289
|
+
const theadHeight = tableHeadRef.current.offsetHeight;
|
|
290
|
+
setTheadHeight(theadHeight);
|
|
291
|
+
}
|
|
292
|
+
}, []);
|
|
293
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
294
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(TableWrapper, {
|
|
295
|
+
style: {
|
|
296
|
+
height: `${tableHeight}px`
|
|
297
|
+
},
|
|
298
|
+
ref: wrapperRef,
|
|
299
|
+
backgroundReverse: backgroundReverse,
|
|
300
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ResponsiveTable, {
|
|
301
|
+
ref: tableRef,
|
|
302
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
|
|
303
|
+
ref: tableHeadRef,
|
|
304
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
305
|
+
children: tableHeads
|
|
306
|
+
})
|
|
307
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
|
|
308
|
+
children: data.length === 0 ? generateEmptyMessage() : tableRows
|
|
309
|
+
})]
|
|
310
|
+
})
|
|
311
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Scrollbar, {
|
|
312
|
+
backgroundReverse: backgroundReverse,
|
|
313
|
+
width: tableWidth,
|
|
314
|
+
onScroll: handleScroll
|
|
315
|
+
})]
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
const TableWrapper = _styledComponents.default.div`
|
|
319
|
+
overflow: hidden;
|
|
320
|
+
background: ${_ref2 => {
|
|
321
|
+
let {
|
|
322
|
+
backgroundReverse
|
|
323
|
+
} = _ref2;
|
|
324
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
325
|
+
}};
|
|
326
|
+
`;
|
|
327
|
+
const ResponsiveTable = _styledComponents.default.table`
|
|
328
|
+
/* make fixed width work */
|
|
329
|
+
position: relative;
|
|
330
|
+
width: 0px;
|
|
331
|
+
color: var(--font-on-background);
|
|
332
|
+
table-layout: fixed;
|
|
333
|
+
border-collapse: collapse;
|
|
334
|
+
`;
|
|
335
|
+
const TD = _styledComponents.default.td`
|
|
336
|
+
align-content: center;
|
|
337
|
+
width: ${_ref3 => {
|
|
338
|
+
let {
|
|
339
|
+
$width
|
|
340
|
+
} = _ref3;
|
|
341
|
+
return $width;
|
|
342
|
+
}};
|
|
343
|
+
height: 48px;
|
|
344
|
+
padding: 0 var(--spacing-xs);
|
|
345
|
+
border-top: 1px solid var(--border-color);
|
|
346
|
+
border-right: 1px solid var(--border-color);
|
|
347
|
+
border-bottom: 1px solid var(--border-color);
|
|
348
|
+
text-align: ${_ref4 => {
|
|
349
|
+
let {
|
|
350
|
+
center
|
|
351
|
+
} = _ref4;
|
|
352
|
+
return center ? 'center' : 'left';
|
|
353
|
+
}};
|
|
354
|
+
background: ${_ref5 => {
|
|
355
|
+
let {
|
|
356
|
+
backgroundReverse
|
|
357
|
+
} = _ref5;
|
|
358
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
359
|
+
}};
|
|
360
|
+
|
|
361
|
+
&:last-child {
|
|
362
|
+
border-right: none;
|
|
363
|
+
padding: 0;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
> span {
|
|
367
|
+
display: inline-block;
|
|
368
|
+
width: 100%;
|
|
369
|
+
padding: 0 2px;
|
|
370
|
+
overflow: hidden;
|
|
371
|
+
white-space: pre;
|
|
372
|
+
text-overflow: ellipsis;
|
|
373
|
+
}
|
|
374
|
+
`;
|
|
375
|
+
const Scrollbar = _styledComponents.default.div`
|
|
376
|
+
position: sticky;
|
|
377
|
+
bottom: 0;
|
|
378
|
+
width: 100%;
|
|
379
|
+
overflow: auto;
|
|
380
|
+
background: ${_ref6 => {
|
|
381
|
+
let {
|
|
382
|
+
backgroundReverse
|
|
383
|
+
} = _ref6;
|
|
384
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
385
|
+
}};
|
|
386
|
+
|
|
387
|
+
::before {
|
|
388
|
+
display: block;
|
|
389
|
+
content: '';
|
|
390
|
+
width: ${_ref7 => {
|
|
391
|
+
let {
|
|
392
|
+
width
|
|
393
|
+
} = _ref7;
|
|
394
|
+
return `${width}px`;
|
|
395
|
+
}};
|
|
396
|
+
height: 1px;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
${(0, _scrollbar.default)({
|
|
400
|
+
size: 'large'
|
|
401
|
+
})}
|
|
402
|
+
`;
|
|
403
|
+
var _default = exports.default = InfiniteGridTable;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const PermissionTable = _styledComponents.default.table`
|
|
10
|
+
width: 100%;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
table-layout: fixed;
|
|
13
|
+
border: 0;
|
|
14
|
+
color: var(--font-on-background);
|
|
15
|
+
`;
|
|
16
|
+
const TH = _styledComponents.default.th`
|
|
17
|
+
padding: var(--spacing) 0;
|
|
18
|
+
border-bottom: 1px solid var(--border-color);
|
|
19
|
+
font-weight: var(--font-bold);
|
|
20
|
+
|
|
21
|
+
${_ref => {
|
|
22
|
+
let {
|
|
23
|
+
clickable
|
|
24
|
+
} = _ref;
|
|
25
|
+
return clickable && 'cursor: pointer;';
|
|
26
|
+
}}
|
|
27
|
+
${_ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
alignCenter
|
|
30
|
+
} = _ref2;
|
|
31
|
+
return alignCenter && 'text-align: center;';
|
|
32
|
+
}}
|
|
33
|
+
`;
|
|
34
|
+
const TD = _styledComponents.default.td`
|
|
35
|
+
padding: var(--spacing) 0;
|
|
36
|
+
border-bottom: 1px solid var(--border-color);
|
|
37
|
+
|
|
38
|
+
&:nth-child(even) {
|
|
39
|
+
background: var(--color-background1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
${_ref3 => {
|
|
43
|
+
let {
|
|
44
|
+
clickable
|
|
45
|
+
} = _ref3;
|
|
46
|
+
return clickable && 'cursor: pointer;';
|
|
47
|
+
}}
|
|
48
|
+
${_ref4 => {
|
|
49
|
+
let {
|
|
50
|
+
alignCenter
|
|
51
|
+
} = _ref4;
|
|
52
|
+
return alignCenter && 'text-align: center;';
|
|
53
|
+
}}
|
|
54
|
+
${_ref5 => {
|
|
55
|
+
let {
|
|
56
|
+
bold
|
|
57
|
+
} = _ref5;
|
|
58
|
+
return bold && 'font-weight: var(--font-bold);';
|
|
59
|
+
}}
|
|
60
|
+
`;
|
|
61
|
+
var _default = exports.default = Object.assign(PermissionTable, {
|
|
62
|
+
TH,
|
|
63
|
+
TD
|
|
64
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
var _GridTableHeadCell = _interopRequireDefault(require("./subComponent/GridTableHeadCell"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const SimpleGridTable = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
columns,
|
|
15
|
+
data,
|
|
16
|
+
backgroundReverse,
|
|
17
|
+
translation
|
|
18
|
+
} = _ref;
|
|
19
|
+
const texts = (0, _react.useMemo)(() => {
|
|
20
|
+
const defaultTexts = {
|
|
21
|
+
empty: 'No data available in table'
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
...defaultTexts,
|
|
25
|
+
...translation
|
|
26
|
+
};
|
|
27
|
+
}, [translation]);
|
|
28
|
+
const tableHeads = (0, _react.useMemo)(() => {
|
|
29
|
+
const tableHeads = columns.map((column, index) => {
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TH, {
|
|
31
|
+
backgroundReverse: !backgroundReverse,
|
|
32
|
+
children: column.title
|
|
33
|
+
}, `TH${index}`);
|
|
34
|
+
});
|
|
35
|
+
return tableHeads;
|
|
36
|
+
}, [backgroundReverse, columns]);
|
|
37
|
+
const tableRows = (0, _react.useMemo)(() => {
|
|
38
|
+
if (data.length === 0) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return data.map((row, rowIndex) => {
|
|
42
|
+
const tds = columns.map((column, columnIndex) => {
|
|
43
|
+
const {
|
|
44
|
+
title,
|
|
45
|
+
fieldName,
|
|
46
|
+
render
|
|
47
|
+
} = column;
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TD, {
|
|
49
|
+
"data-label": title,
|
|
50
|
+
backgroundReverse: backgroundReverse,
|
|
51
|
+
children: render ? render(row[fieldName], row) : String(row[fieldName])
|
|
52
|
+
}, columnIndex);
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TR, {
|
|
55
|
+
children: tds
|
|
56
|
+
}, rowIndex);
|
|
57
|
+
});
|
|
58
|
+
}, [backgroundReverse, columns, data]);
|
|
59
|
+
const generateEmptyMessage = (0, _react.useCallback)(() => {
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TR, {
|
|
61
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TD, {
|
|
62
|
+
center: true,
|
|
63
|
+
colSpan: columns.length,
|
|
64
|
+
backgroundReverse: backgroundReverse,
|
|
65
|
+
children: texts.empty
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}, [backgroundReverse, columns, texts]);
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(TableWrapper, {
|
|
71
|
+
backgroundReverse: backgroundReverse,
|
|
72
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(ResponsiveTable, {
|
|
73
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
|
|
75
|
+
children: tableHeads
|
|
76
|
+
})
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
|
|
78
|
+
children: tableRows || generateEmptyMessage()
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const TableWrapper = _styledComponents.default.div`
|
|
85
|
+
background: ${_ref2 => {
|
|
86
|
+
let {
|
|
87
|
+
backgroundReverse
|
|
88
|
+
} = _ref2;
|
|
89
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
90
|
+
}};
|
|
91
|
+
`;
|
|
92
|
+
const ResponsiveTable = _styledComponents.default.table`
|
|
93
|
+
width: 100%;
|
|
94
|
+
color: var(--font-on-background);
|
|
95
|
+
table-layout: fixed;
|
|
96
|
+
border-collapse: separate;
|
|
97
|
+
border-spacing: 0;
|
|
98
|
+
border: 1px solid var(--border-color);
|
|
99
|
+
border-radius: 8px;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
`;
|
|
102
|
+
const TH = (0, _styledComponents.default)(_GridTableHeadCell.default)`
|
|
103
|
+
text-align: left;
|
|
104
|
+
border-top: none;
|
|
105
|
+
border-right: 1px solid var(--border-color);
|
|
106
|
+
|
|
107
|
+
&:last-child {
|
|
108
|
+
border-right: none;
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
const TD = _styledComponents.default.td`
|
|
112
|
+
height: 48px;
|
|
113
|
+
padding: 0 var(--spacing-xs);
|
|
114
|
+
border-bottom: 1px solid var(--border-color);
|
|
115
|
+
border-right: 1px solid var(--border-color);
|
|
116
|
+
text-align: ${_ref3 => {
|
|
117
|
+
let {
|
|
118
|
+
center
|
|
119
|
+
} = _ref3;
|
|
120
|
+
return center ? 'center' : 'left';
|
|
121
|
+
}};
|
|
122
|
+
background: ${_ref4 => {
|
|
123
|
+
let {
|
|
124
|
+
backgroundReverse
|
|
125
|
+
} = _ref4;
|
|
126
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
127
|
+
}};
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
text-overflow: ellipsis;
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
|
|
132
|
+
&:last-child {
|
|
133
|
+
border-right: none;
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
const TR = _styledComponents.default.tr`
|
|
137
|
+
&:last-child {
|
|
138
|
+
${TD} {
|
|
139
|
+
border-bottom: none;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
var _default = exports.default = SimpleGridTable;
|