@cashub/ui-elv 1.0.2 → 1.0.4
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/datetimePicker/index.js +2 -37
- package/esm/Tab/Tab.js +21 -0
- package/esm/Tab/TabList.js +160 -0
- package/esm/Tab/TabPanel.js +42 -0
- package/esm/Tab/TabTab.js +98 -0
- package/esm/Tab/index.js +23 -0
- package/esm/Tab/subComponent/TabContext.js +3 -0
- package/esm/Tab/subComponent/TabListV2.js +18 -0
- package/esm/Tab/subComponent/TabPanelV2.js +45 -0
- package/esm/Tab/subComponent/TabTabV2.js +56 -0
- package/esm/VerticalTab/TabList.js +20 -0
- package/esm/VerticalTab/TabPanel.js +45 -0
- package/esm/VerticalTab/TabTab.js +63 -0
- package/esm/VerticalTab/VerticalTab.js +34 -0
- package/esm/VerticalTab/index.js +9 -0
- package/esm/VerticalTab/subComponent/TabContext.js +3 -0
- package/esm/alert/Alert.js +22 -0
- package/esm/alert/index.js +1 -0
- package/esm/animate/Collapse.js +65 -0
- package/esm/animate/Loader.js +51 -0
- package/esm/animate/NumberCounter.js +45 -0
- package/esm/animate/PulseRing.js +26 -0
- package/esm/animate/Spinner.js +11 -0
- package/esm/animate/index.js +5 -0
- package/esm/assets/css/autocomplete.css +16 -0
- package/esm/assets/css/font.css +4 -0
- package/esm/assets/css/global.css +2 -0
- package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/esm/assets/icons/app-management.png +0 -0
- package/esm/assets/icons/burger-black.png +0 -0
- package/esm/assets/icons/burger-white.png +0 -0
- package/esm/assets/icons/burger.png +0 -0
- package/esm/assets/icons/file.svg +1 -0
- package/esm/assets/icons/map_icon1.png +0 -0
- package/esm/assets/icons/map_icon4.png +0 -0
- package/esm/assets/images/bg-aside.png +0 -0
- package/esm/assets/images/bg-chart-circle.png +0 -0
- package/esm/assets/images/bg-chart-triangle.png +0 -0
- package/esm/assets/images/cashub-logo-only.png +0 -0
- package/esm/assets/images/default-user.jpg +0 -0
- package/esm/assets/images/logo-cashub.png +0 -0
- package/esm/assets/images/map.png +0 -0
- package/esm/assets/images/qrcode.png +0 -0
- package/esm/backdrop/BaseBackdrop.js +11 -0
- package/esm/backdrop/LoadingBackdrop.js +10 -0
- package/esm/backdrop/ModalBackdrop.js +8 -0
- package/esm/backdrop/index.js +3 -0
- package/esm/badge/Badge.js +19 -0
- package/esm/badge/BadgeDot.js +11 -0
- package/esm/badge/BadgeFill.js +42 -0
- package/esm/badge/BadgeFillTriangle.js +138 -0
- package/esm/badge/BadgeWithText.js +24 -0
- package/esm/badge/index.js +5 -0
- package/esm/billing/BarChart.js +45 -0
- package/esm/billing/Grid.js +38 -0
- package/esm/billing/Header2.js +19 -0
- package/esm/billing/Header3.js +31 -0
- package/esm/billing/Paragraph.js +27 -0
- package/esm/billing/ParagraphGroup.js +16 -0
- package/esm/billing/ParagraphText.js +20 -0
- package/esm/billing/Section.js +44 -0
- package/esm/billing/SectionBody.js +11 -0
- package/esm/billing/SectionHeader.js +20 -0
- package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
- package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
- package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
- package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/esm/billing/__stories__/Section.stories.js_bak +115 -0
- package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/esm/breadcrumb/Breadcrumb.js +71 -0
- package/esm/breadcrumb/index.js +1 -0
- package/esm/button/Button.js +145 -0
- package/esm/button/ButtonGroup.js +54 -0
- package/esm/button/IconButton.js +64 -0
- package/esm/button/ScrollToTopButton.js +47 -0
- package/esm/button/index.js +4 -0
- package/esm/callout/Callout.js +45 -0
- package/esm/callout/index.js +1 -0
- package/esm/chart/BarChart.js +147 -0
- package/esm/chart/DoughnutChart.js +110 -0
- package/esm/chart/LineChart.js +140 -0
- package/esm/chart/SingleBarChart.js +35 -0
- package/esm/chart/index.js +5 -0
- package/esm/chart/utils/centerTextPlugin.js +56 -0
- package/esm/chart/utils/customTooltip.js +84 -0
- package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
- package/esm/chart/utils/htmlLegendPlugin.js +83 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/padEmptyChartBar.js +47 -0
- package/esm/chart/utils/tooltipElement.js +17 -0
- package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
- package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
- package/esm/container/FlexContainer.js +33 -0
- package/esm/container/index.js +1 -0
- package/esm/cropper/Cropper.js +47 -0
- package/esm/cropper/CropperModalHandler.js +34 -0
- package/esm/cropper/index.js +2 -0
- package/esm/cropper/subComponent/CropImageModal.js +72 -0
- package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
- package/esm/datetimePicker/TimeInput.js +49 -0
- package/esm/datetimePicker/TimePickerStyle.js +58 -0
- package/esm/datetimePicker/TimePickerV2.js +199 -0
- package/esm/datetimePicker/accordion/Month.js +245 -0
- package/esm/datetimePicker/accordion/Year.js +275 -0
- package/esm/datetimePicker/index.js +4 -0
- package/esm/datetimePicker/provider/constant.js +38 -0
- package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
- package/esm/datetimePicker/utils/GMTDate.js +9 -0
- package/esm/datetimePicker/utils/pad.js +7 -0
- package/esm/datetimePicker/utils/toUTC0.js +7 -0
- package/esm/descriptionList/DescriptionDetail.js +21 -0
- package/esm/descriptionList/DescriptionList.js +18 -0
- package/esm/descriptionList/DescriptionTerm.js +7 -0
- package/esm/descriptionList/index.js +3 -0
- package/esm/divider/Divider.js +24 -0
- package/esm/divider/index.js +1 -0
- package/esm/dropdown/Dropdown.js +48 -0
- package/esm/dropdown/DropdownButtonOption.js +36 -0
- package/esm/dropdown/DropdownContent.js +83 -0
- package/esm/dropdown/DropdownDivOption.js +19 -0
- package/esm/dropdown/DropdownItem.js +19 -0
- package/esm/dropdown/DropdownLinkOption.js +17 -0
- package/esm/dropdown/DropdownToggle.js +31 -0
- package/esm/dropdown/index.js +11 -0
- package/esm/dropdown/subComponent/DropdownContext.js +3 -0
- package/esm/dropzone/FileDropzone.js +472 -0
- package/esm/dropzone/ImageDropzone.js +327 -0
- package/esm/dropzone/index.js +2 -0
- package/esm/dropzone/subComponent/Message.js +19 -0
- package/esm/figure/IconFigure.js +35 -0
- package/esm/figure/ImageFigure.js +31 -0
- package/esm/figure/index.js +2 -0
- package/esm/file/HiddenFileInput.js +8 -0
- package/esm/file/index.js +1 -0
- package/esm/form/Checkbox.js +157 -0
- package/esm/form/Fieldset.js +11 -0
- package/esm/form/FormItem.js +15 -0
- package/esm/form/Input.js +59 -0
- package/esm/form/Label.js +54 -0
- package/esm/form/MutedText.js +14 -0
- package/esm/form/PasswordInput.js +40 -0
- package/esm/form/RadioButton.js +94 -0
- package/esm/form/SearchSelect.js +174 -0
- package/esm/form/Searchbox.js +91 -0
- package/esm/form/Slider.js +39 -0
- package/esm/form/SwitchButton.js +97 -0
- package/esm/form/Textarea.js +34 -0
- package/esm/form/TreeView.js +66 -0
- package/esm/form/index.js +14 -0
- package/esm/grid/Column.js +39 -0
- package/esm/grid/Grid.js +28 -0
- package/esm/grid/index.js +2 -0
- package/esm/heading/Heading1.js +14 -0
- package/esm/heading/Heading2.js +21 -0
- package/esm/heading/Heading3.js +42 -0
- package/esm/heading/index.js +3 -0
- package/esm/helmet/Helmet.js +17 -0
- package/esm/helmet/index.js +3 -0
- package/esm/iconbox/ApplicationIconBox.js +74 -0
- package/esm/iconbox/IconBox.js +60 -0
- package/esm/iconbox/IconBoxV2.js +63 -0
- package/esm/iconbox/index.js +3 -0
- package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
- package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
- package/esm/image/ImageFluid.js +10 -0
- package/esm/image/UploadImage.js +243 -0
- package/esm/image/index.js +2 -0
- package/esm/index.js +47 -0
- package/esm/keyframe/Pulse.js +15 -0
- package/esm/keyframe/Spin.js +7 -0
- package/esm/layout/Aside.js +39 -0
- package/esm/layout/AsideHeader.jsx +27 -0
- package/esm/layout/Backdrop.js +16 -0
- package/esm/layout/Container.js +30 -0
- package/esm/layout/Footer.js +36 -0
- package/esm/layout/Header.jsx +55 -0
- package/esm/layout/Layout.jsx +84 -0
- package/esm/layout/Logo.jsx +17 -0
- package/esm/layout/MenuIcon.jsx +27 -0
- package/esm/layout/Sidebar.jsx +271 -0
- package/esm/layout/index.js +1 -0
- package/esm/link/LinkSpan.js +62 -0
- package/esm/link/index.js +1 -0
- package/esm/map/GoogleMap.js +439 -0
- package/esm/map/GoogleReverseGeolocation.js +193 -0
- package/esm/map/LeafletMap.js +224 -0
- package/esm/map/LeafletReverseGeolocation.js +94 -0
- package/esm/map/index.js +4 -0
- package/esm/map/subComponent/BasicLeafletMap.js +27 -0
- package/esm/map/subComponent/GoogleMapContainer.js +22 -0
- package/esm/map/subComponent/GoogleMapPopup.js +103 -0
- package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
- package/esm/map/subComponent/LeafletDrawControl.js +116 -0
- package/esm/map/subComponent/LeafletMapContainer.js +166 -0
- package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
- package/esm/modal/StateModal.js +169 -0
- package/esm/modal/TitleModal.js +241 -0
- package/esm/modal/index.js +2 -0
- package/esm/page/Disclaimer.js +121 -0
- package/esm/page/index.js +1 -0
- package/esm/paginate/Paginate.js +129 -0
- package/esm/paginate/index.js +1 -0
- package/esm/popover/Popover.js +82 -0
- package/esm/popover/index.js +1 -0
- package/esm/qrcode/QRCode.js +51 -0
- package/esm/qrcode/QRCodeContainter.js +27 -0
- package/esm/qrcode/index.js +2 -0
- package/esm/ribbon/Ribbon.js +35 -0
- package/esm/ribbon/index.js +1 -0
- package/esm/section/Section.js +126 -0
- package/esm/section/SectionBody.js +43 -0
- package/esm/section/SectionHeader.js +61 -0
- package/esm/section/SectionToolbar.js +11 -0
- package/esm/section/SectionToolbarItem.js +10 -0
- package/esm/section/index.js +5 -0
- package/esm/select/InputSelect.js +263 -0
- package/esm/select/Select.js +811 -0
- package/esm/select/index.js +2 -0
- package/esm/select/subComponent/Checkbox.js +40 -0
- package/esm/select/subComponent/Footer.js +6 -0
- package/esm/select/subComponent/ListBox.js +23 -0
- package/esm/select/subComponent/Option.js +37 -0
- package/esm/select/subComponent/OptionGroup.js +16 -0
- package/esm/select/subComponent/Options.js +25 -0
- package/esm/select/subComponent/SearchBox.js +51 -0
- package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
- package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
- package/esm/select/subComponent/SelectedMultipleText.js +63 -0
- package/esm/select/subComponent/SelectedSingle.js +10 -0
- package/esm/styles/GlobalStyle.js +328 -0
- package/esm/styles/config/breakpoint.style.js +7 -0
- package/esm/styles/config/header.style.js +4 -0
- package/esm/styles/config/sidebar.style.js +11 -0
- package/esm/styles/index.js +2 -0
- package/esm/styles/mixin/backgroundColor.js +38 -0
- package/esm/styles/mixin/borderColor.js +31 -0
- package/esm/styles/mixin/color.js +31 -0
- package/esm/styles/mixin/colorOnBackground.js +31 -0
- package/esm/styles/mixin/inputPlaceholder.js +24 -0
- package/esm/styles/mixin/media.js +15 -0
- package/esm/styles/mixin/rounded.js +24 -0
- package/esm/styles/mixin/scrollbar.js +26 -0
- package/esm/styles/theme/dark.theme.js +91 -0
- package/esm/styles/theme/light.theme.js +91 -0
- package/esm/styles/theme/white.theme.js +91 -0
- package/esm/styles/themes.js +9 -0
- package/esm/table/GridTable.js +329 -0
- package/esm/table/ImageBox.js +38 -0
- package/esm/table/InfiniteGridTable.js +396 -0
- package/esm/table/PermissionTable.js +57 -0
- package/esm/table/SimpleGridTable.js +136 -0
- package/esm/table/Table.js +559 -0
- package/esm/table/__mock__/columns.js +64 -0
- package/esm/table/__mock__/data.js +530 -0
- package/esm/table/hooks/index.js +2 -0
- package/esm/table/hooks/useCalculateDataRange.js +22 -0
- package/esm/table/hooks/useGenerateSort.js +32 -0
- package/esm/table/index.js +6 -0
- package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
- package/esm/table/subComponent/GridTableFooter.js +17 -0
- package/esm/table/subComponent/GridTableHeadCell.js +13 -0
- package/esm/table/subComponent/Resizer.js +70 -0
- package/esm/table/subComponent/TableFooter.js +24 -0
- package/esm/table/subComponent/TableFooterInfo.js +6 -0
- package/esm/table/subComponent/TableFooterPager.js +26 -0
- package/esm/table/subComponent/TableHeadCell.js +12 -0
- package/esm/table/subComponent/TableSort.js +31 -0
- package/esm/tagify/TagifyStyle.js +54 -0
- package/esm/tagify/Tags.js +49 -0
- package/esm/tagify/index.js +3 -0
- package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
- package/esm/text/Paragraph.js +79 -0
- package/esm/text/index.js +1 -0
- package/esm/timeline/Timeline.js +132 -0
- package/esm/timeline/index.js +1 -0
- package/esm/toast/CustomToastContainer.js +38 -0
- package/esm/toast/MessageContainer.js +44 -0
- package/esm/toast/index.js +3 -0
- package/esm/toast/show.js +29 -0
- package/esm/toast/style.css +1 -0
- package/esm/tooltip/Tooltip.js +133 -0
- package/esm/tooltip/index.js +1 -0
- package/esm/treeView/TreeViewV2.js +32 -0
- package/esm/treeView/TreeflexStyle.js +43 -0
- package/esm/treeView/index.js +2 -0
- package/esm/wizard/Wizard.js +244 -0
- package/esm/wizard/index.js +1 -0
- package/helmet/index.js +3 -7
- package/index.js +0 -12
- package/layout/Sidebar.jsx +1 -1
- package/package.json +5 -4
- package/datetimePicker/DatePicker.js +0 -363
- package/datetimePicker/DatePickerV2.js +0 -407
- package/datetimePicker/DatetimePickerV2.js +0 -395
- package/datetimePicker/TimePicker.js +0 -317
- package/datetimePicker/hooks/index.js +0 -27
- package/datetimePicker/hooks/useChangeNumber.js +0 -42
- package/datetimePicker/hooks/useDecrease.js +0 -38
- package/datetimePicker/hooks/useIncrease.js +0 -38
- package/datetimePicker/subComponent/Accordion.js +0 -373
- package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
- package/jsoneditor/JsonEditor.js +0 -142
- package/jsoneditor/index.js +0 -13
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import media from '../styles/mixin/media';
|
|
4
|
+
import { useCalculateDataRange, useGenerateSort } from './hooks';
|
|
5
|
+
import TH from './subComponent/TableHeadCell';
|
|
6
|
+
import TableFooter from './subComponent/TableFooter';
|
|
7
|
+
import TableFooterInfo from './subComponent/TableFooterInfo';
|
|
8
|
+
import TableFooterPager from './subComponent/TableFooterPager';
|
|
9
|
+
import Paginate from '../paginate/Paginate';
|
|
10
|
+
import Select from '../select/Select';
|
|
11
|
+
import Popover from '../popover/Popover';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
const Table = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
columns,
|
|
16
|
+
data,
|
|
17
|
+
currentPage,
|
|
18
|
+
limit,
|
|
19
|
+
total,
|
|
20
|
+
onPageChange,
|
|
21
|
+
onLimitChange,
|
|
22
|
+
sortColumn,
|
|
23
|
+
sortType,
|
|
24
|
+
onSortChange,
|
|
25
|
+
select,
|
|
26
|
+
selected,
|
|
27
|
+
onRowClick,
|
|
28
|
+
enableRowDrag,
|
|
29
|
+
onRowDragEnter,
|
|
30
|
+
onRowDragLeave,
|
|
31
|
+
onRowDragOver,
|
|
32
|
+
onRowDrop,
|
|
33
|
+
backgroundReverse,
|
|
34
|
+
translation,
|
|
35
|
+
beforeCreateRow,
|
|
36
|
+
popoverContainer,
|
|
37
|
+
centerFooter = false,
|
|
38
|
+
showPager = true
|
|
39
|
+
} = _ref;
|
|
40
|
+
const tableRef = useRef(null);
|
|
41
|
+
const {
|
|
42
|
+
start,
|
|
43
|
+
end
|
|
44
|
+
} = useCalculateDataRange(currentPage, limit, total);
|
|
45
|
+
const texts = useMemo(() => {
|
|
46
|
+
const defaultTexts = {
|
|
47
|
+
info: 'Showing _START_ to _END_ of _TOTAL_ entries',
|
|
48
|
+
empty: 'No data available in table'
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
...defaultTexts,
|
|
52
|
+
...translation
|
|
53
|
+
};
|
|
54
|
+
}, [translation]);
|
|
55
|
+
const handleSortChange = useCallback(columnName => {
|
|
56
|
+
if (onSortChange) {
|
|
57
|
+
onSortChange(columnName);
|
|
58
|
+
}
|
|
59
|
+
}, [onSortChange]);
|
|
60
|
+
const handleRowClick = useCallback((event, rowData) => {
|
|
61
|
+
if (onRowClick) {
|
|
62
|
+
onRowClick(event, rowData);
|
|
63
|
+
}
|
|
64
|
+
}, [onRowClick]);
|
|
65
|
+
const handleRowDragEnter = useCallback((event, rowData) => {
|
|
66
|
+
if (onRowDragEnter) {
|
|
67
|
+
onRowDragEnter(event, rowData);
|
|
68
|
+
}
|
|
69
|
+
}, [onRowDragEnter]);
|
|
70
|
+
const handleRowDragLeave = useCallback((event, rowData) => {
|
|
71
|
+
if (onRowDragLeave) {
|
|
72
|
+
onRowDragLeave(event, rowData);
|
|
73
|
+
}
|
|
74
|
+
}, [onRowDragLeave]);
|
|
75
|
+
const handleRowDragOver = useCallback((event, rowData) => {
|
|
76
|
+
if (onRowDragOver) {
|
|
77
|
+
onRowDragOver(event, rowData);
|
|
78
|
+
}
|
|
79
|
+
}, [onRowDragOver]);
|
|
80
|
+
const handleRowDrop = useCallback((event, rowData) => {
|
|
81
|
+
if (onRowDrop) {
|
|
82
|
+
onRowDrop(event, rowData);
|
|
83
|
+
}
|
|
84
|
+
}, [onRowDrop]);
|
|
85
|
+
const showFullValue = useCallback((event, customContent) => {
|
|
86
|
+
let {
|
|
87
|
+
id
|
|
88
|
+
} = event.target;
|
|
89
|
+
if (!id) {
|
|
90
|
+
({
|
|
91
|
+
id
|
|
92
|
+
} = event.currentTarget);
|
|
93
|
+
event.target.id = id;
|
|
94
|
+
}
|
|
95
|
+
const {
|
|
96
|
+
offsetWidth,
|
|
97
|
+
scrollWidth,
|
|
98
|
+
innerText
|
|
99
|
+
} = event.target;
|
|
100
|
+
if ((scrollWidth >= offsetWidth || customContent) && innerText) {
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
Popover({
|
|
103
|
+
id,
|
|
104
|
+
container: popoverContainer,
|
|
105
|
+
target: event.target,
|
|
106
|
+
content: customContent ? customContent : innerText,
|
|
107
|
+
boundary: tableRef.current
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, [popoverContainer]);
|
|
111
|
+
|
|
112
|
+
// generate sort icon area
|
|
113
|
+
const generateSort = useGenerateSort(sortColumn, sortType);
|
|
114
|
+
const tableHeads = useMemo(() => {
|
|
115
|
+
return columns.map((column, index) => {
|
|
116
|
+
const {
|
|
117
|
+
title,
|
|
118
|
+
fieldName,
|
|
119
|
+
width,
|
|
120
|
+
sortable,
|
|
121
|
+
align
|
|
122
|
+
} = column;
|
|
123
|
+
return /*#__PURE__*/_jsx(TH, {
|
|
124
|
+
width: width,
|
|
125
|
+
sortable: sortable,
|
|
126
|
+
onClick: () => {
|
|
127
|
+
sortable && handleSortChange(fieldName);
|
|
128
|
+
},
|
|
129
|
+
align: align,
|
|
130
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
131
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
132
|
+
id: fieldName,
|
|
133
|
+
onClick: showFullValue,
|
|
134
|
+
children: title
|
|
135
|
+
}), sortable && generateSort(fieldName)]
|
|
136
|
+
})
|
|
137
|
+
}, `TH${index}`);
|
|
138
|
+
});
|
|
139
|
+
}, [columns, handleSortChange, generateSort, showFullValue]);
|
|
140
|
+
const tableRows = useMemo(() => {
|
|
141
|
+
if (data.length === 0) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const {
|
|
145
|
+
matcher,
|
|
146
|
+
type
|
|
147
|
+
} = select || {};
|
|
148
|
+
return data.map((row, rowIndex) => {
|
|
149
|
+
let active = false;
|
|
150
|
+
let rowConfig = {};
|
|
151
|
+
if (beforeCreateRow) {
|
|
152
|
+
rowConfig = beforeCreateRow(row) || {};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// row data cell
|
|
156
|
+
const tds = columns.map((column, columnIndex) => {
|
|
157
|
+
const {
|
|
158
|
+
title,
|
|
159
|
+
fieldName,
|
|
160
|
+
render,
|
|
161
|
+
custom,
|
|
162
|
+
customPop,
|
|
163
|
+
...props
|
|
164
|
+
} = column;
|
|
165
|
+
const key = rowIndex + columnIndex.toString();
|
|
166
|
+
let value = row[fieldName];
|
|
167
|
+
|
|
168
|
+
// 如果有matcher,比對當前 column 的 fieldName 是不是等於 matcher
|
|
169
|
+
if (matcher && fieldName === matcher) {
|
|
170
|
+
if (type === 'single' && selected === value) {
|
|
171
|
+
active = true;
|
|
172
|
+
}
|
|
173
|
+
if (type === 'multiple' && selected.includes(value)) {
|
|
174
|
+
active = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// convert to an empty string
|
|
179
|
+
if (value === null || value === undefined) {
|
|
180
|
+
value = '';
|
|
181
|
+
}
|
|
182
|
+
let isCustom = false;
|
|
183
|
+
let renderedData = null;
|
|
184
|
+
const customContent = customPop ? customPop(row) : null;
|
|
185
|
+
if (custom && render) {
|
|
186
|
+
// call render function to get custom data(fully)
|
|
187
|
+
isCustom = true;
|
|
188
|
+
renderedData = render(row);
|
|
189
|
+
} else {
|
|
190
|
+
// call render function to get custom data(part)
|
|
191
|
+
renderedData = /*#__PURE__*/_jsx("span", {
|
|
192
|
+
id: key,
|
|
193
|
+
onClick: event => showFullValue(event, customContent),
|
|
194
|
+
children: render ? render(value, row) : String(value)
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return /*#__PURE__*/_jsxs(TableDataCell, {
|
|
198
|
+
"data-label": title,
|
|
199
|
+
enableRowDrag: columnIndex === columns.length - 1 && enableRowDrag,
|
|
200
|
+
backgroundReverse: backgroundReverse,
|
|
201
|
+
border: rowConfig.border,
|
|
202
|
+
custom: isCustom,
|
|
203
|
+
...props,
|
|
204
|
+
children: [renderedData, enableRowDrag && columnIndex === columns.length - 1 && /*#__PURE__*/_jsx(DragHandle, {
|
|
205
|
+
draggable: true,
|
|
206
|
+
onDragStart: event => {
|
|
207
|
+
event.dataTransfer.setData('fromRow', JSON.stringify(row));
|
|
208
|
+
},
|
|
209
|
+
children: /*#__PURE__*/_jsxs("svg", {
|
|
210
|
+
stroke: "currentColor",
|
|
211
|
+
fill: "currentColor",
|
|
212
|
+
"stroke-width": "0",
|
|
213
|
+
viewBox: "0 0 24 24",
|
|
214
|
+
height: "1em",
|
|
215
|
+
width: "1em",
|
|
216
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
217
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
218
|
+
fill: "none",
|
|
219
|
+
d: "M0 0h24v24H0V0z"
|
|
220
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
221
|
+
d: "M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
|
|
222
|
+
})]
|
|
223
|
+
})
|
|
224
|
+
})]
|
|
225
|
+
}, columnIndex);
|
|
226
|
+
});
|
|
227
|
+
return /*#__PURE__*/_jsx(BodyTR, {
|
|
228
|
+
clickable: onRowClick,
|
|
229
|
+
active: active,
|
|
230
|
+
primary: rowConfig.primary,
|
|
231
|
+
border: rowConfig.border,
|
|
232
|
+
backgroundReverse: backgroundReverse,
|
|
233
|
+
onClick: event => {
|
|
234
|
+
handleRowClick(event, row);
|
|
235
|
+
},
|
|
236
|
+
onDragEnter: event => {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
event.stopPropagation();
|
|
239
|
+
handleRowDragEnter(event, row);
|
|
240
|
+
},
|
|
241
|
+
onDragLeave: event => {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
event.stopPropagation();
|
|
244
|
+
handleRowDragLeave(event, row);
|
|
245
|
+
},
|
|
246
|
+
onDragOver: event => {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
event.stopPropagation();
|
|
249
|
+
handleRowDragOver(event, row);
|
|
250
|
+
},
|
|
251
|
+
onDrop: event => {
|
|
252
|
+
handleRowDrop(event, row);
|
|
253
|
+
},
|
|
254
|
+
children: tds
|
|
255
|
+
}, rowIndex);
|
|
256
|
+
});
|
|
257
|
+
}, [backgroundReverse, beforeCreateRow, columns, data, handleRowClick, handleRowDragEnter, handleRowDragLeave, handleRowDragOver, handleRowDrop, onRowClick, enableRowDrag, select, selected, showFullValue]);
|
|
258
|
+
const generateEmptyMessage = useCallback(() => {
|
|
259
|
+
return /*#__PURE__*/_jsx(BodyTR, {
|
|
260
|
+
noData: true,
|
|
261
|
+
backgroundReverse: backgroundReverse,
|
|
262
|
+
children: /*#__PURE__*/_jsx(TableDataCell, {
|
|
263
|
+
noData: true,
|
|
264
|
+
center: true,
|
|
265
|
+
colSpan: columns.length,
|
|
266
|
+
backgroundReverse: backgroundReverse,
|
|
267
|
+
children: texts.empty
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
}, [backgroundReverse, columns, texts]);
|
|
271
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
272
|
+
children: [/*#__PURE__*/_jsxs(ResponsiveTable, {
|
|
273
|
+
ref: tableRef,
|
|
274
|
+
enableRowDrag: enableRowDrag,
|
|
275
|
+
children: [/*#__PURE__*/_jsx(TableHead, {
|
|
276
|
+
children: /*#__PURE__*/_jsx("tr", {
|
|
277
|
+
children: tableHeads
|
|
278
|
+
})
|
|
279
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
280
|
+
children: tableRows || generateEmptyMessage()
|
|
281
|
+
})]
|
|
282
|
+
}), /*#__PURE__*/_jsxs(TableFooter, {
|
|
283
|
+
center: centerFooter,
|
|
284
|
+
enableRowDrag: enableRowDrag,
|
|
285
|
+
children: [/*#__PURE__*/_jsx(TableFooterInfo, {
|
|
286
|
+
children: texts.info.replace('_START_', start).replace('_END_', end).replace('_TOTAL_', total)
|
|
287
|
+
}), showPager && /*#__PURE__*/_jsxs(TableFooterPager, {
|
|
288
|
+
center: centerFooter,
|
|
289
|
+
children: [/*#__PURE__*/_jsx(Paginate, {
|
|
290
|
+
currentPage: currentPage,
|
|
291
|
+
totalCount: total,
|
|
292
|
+
pageSize: limit,
|
|
293
|
+
onPageChange: onPageChange
|
|
294
|
+
}), /*#__PURE__*/_jsx(Select, {
|
|
295
|
+
fill: true,
|
|
296
|
+
fillReverse: backgroundReverse,
|
|
297
|
+
allowSearch: false,
|
|
298
|
+
options: [{
|
|
299
|
+
id: 10,
|
|
300
|
+
text: '10'
|
|
301
|
+
}, {
|
|
302
|
+
id: 20,
|
|
303
|
+
text: '20'
|
|
304
|
+
}, {
|
|
305
|
+
id: 30,
|
|
306
|
+
text: '30'
|
|
307
|
+
}, {
|
|
308
|
+
id: 40,
|
|
309
|
+
text: '40'
|
|
310
|
+
}, {
|
|
311
|
+
id: 50,
|
|
312
|
+
text: '50'
|
|
313
|
+
}],
|
|
314
|
+
selected: limit,
|
|
315
|
+
onSelect: onLimitChange
|
|
316
|
+
})]
|
|
317
|
+
})]
|
|
318
|
+
})]
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
const ResponsiveTable = styled.table`
|
|
322
|
+
width: 100%;
|
|
323
|
+
border-collapse: separate;
|
|
324
|
+
margin-top: calc(var(--spacing-s) * -1);
|
|
325
|
+
border-spacing: 0 var(--spacing-s);
|
|
326
|
+
color: var(--font-on-background);
|
|
327
|
+
table-layout: fixed;
|
|
328
|
+
|
|
329
|
+
${_ref2 => {
|
|
330
|
+
let {
|
|
331
|
+
enableRowDrag
|
|
332
|
+
} = _ref2;
|
|
333
|
+
return enableRowDrag && 'padding-right: calc(1.5rem + 0.5rem);';
|
|
334
|
+
}}
|
|
335
|
+
`;
|
|
336
|
+
const TableHead = styled.thead`
|
|
337
|
+
${media.mobile`
|
|
338
|
+
display: none;
|
|
339
|
+
`}
|
|
340
|
+
`;
|
|
341
|
+
const BodyTR = styled.tr`
|
|
342
|
+
&:hover {
|
|
343
|
+
> td {
|
|
344
|
+
border-color: var(--color-primary);
|
|
345
|
+
border-width: var(--border-width);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
${_ref3 => {
|
|
350
|
+
let {
|
|
351
|
+
active,
|
|
352
|
+
primary
|
|
353
|
+
} = _ref3;
|
|
354
|
+
return (active || primary) && css`
|
|
355
|
+
> td {
|
|
356
|
+
background: var(--color-background3);
|
|
357
|
+
}
|
|
358
|
+
`;
|
|
359
|
+
}}
|
|
360
|
+
|
|
361
|
+
${_ref4 => {
|
|
362
|
+
let {
|
|
363
|
+
clickable
|
|
364
|
+
} = _ref4;
|
|
365
|
+
return clickable && 'pointer: cursor;';
|
|
366
|
+
}}
|
|
367
|
+
|
|
368
|
+
${media.mobile`
|
|
369
|
+
overflow: hidden;
|
|
370
|
+
position: relative;
|
|
371
|
+
transition: .3s;
|
|
372
|
+
display: block;
|
|
373
|
+
margin-bottom: 0.75rem;
|
|
374
|
+
padding: var(--spacing-xs) var(--spacing-s);
|
|
375
|
+
background: var(
|
|
376
|
+
--color-background${_ref5 => {
|
|
377
|
+
let {
|
|
378
|
+
backgroundReverse
|
|
379
|
+
} = _ref5;
|
|
380
|
+
return backgroundReverse ? 1 : 2;
|
|
381
|
+
}}
|
|
382
|
+
);
|
|
383
|
+
border-radius: var(--border-radius);
|
|
384
|
+
transition: .3s;
|
|
385
|
+
border: 1px solid transparent;
|
|
386
|
+
|
|
387
|
+
&:hover {
|
|
388
|
+
border: var(--border-width) solid var(--color-primary);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
${_ref6 => {
|
|
392
|
+
let {
|
|
393
|
+
active,
|
|
394
|
+
primary
|
|
395
|
+
} = _ref6;
|
|
396
|
+
return (active || primary) && css`
|
|
397
|
+
background: var(--color-background3);
|
|
398
|
+
`;
|
|
399
|
+
}}
|
|
400
|
+
|
|
401
|
+
${_ref7 => {
|
|
402
|
+
let {
|
|
403
|
+
border
|
|
404
|
+
} = _ref7;
|
|
405
|
+
return border && css`
|
|
406
|
+
border-color: var(--font-on-background);
|
|
407
|
+
border-width: 3px;
|
|
408
|
+
`;
|
|
409
|
+
}}
|
|
410
|
+
|
|
411
|
+
${_ref8 => {
|
|
412
|
+
let {
|
|
413
|
+
noData
|
|
414
|
+
} = _ref8;
|
|
415
|
+
return noData && css`
|
|
416
|
+
height: 168px;
|
|
417
|
+
|
|
418
|
+
> td {
|
|
419
|
+
&:first-child:before {
|
|
420
|
+
display: none;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
`;
|
|
424
|
+
}}
|
|
425
|
+
`}
|
|
426
|
+
`;
|
|
427
|
+
const TableDataCell = styled.td.attrs(_ref9 => {
|
|
428
|
+
let {
|
|
429
|
+
border
|
|
430
|
+
} = _ref9;
|
|
431
|
+
return {
|
|
432
|
+
borderWidth: border ? '3px' : 'var(--border-width)',
|
|
433
|
+
borderColor: border ? 'var(--font-on-background)' : 'transparent'
|
|
434
|
+
};
|
|
435
|
+
})`
|
|
436
|
+
height: 48px;
|
|
437
|
+
background: ${_ref10 => {
|
|
438
|
+
let {
|
|
439
|
+
backgroundReverse
|
|
440
|
+
} = _ref10;
|
|
441
|
+
return backgroundReverse ? 'var(--color-background1)' : 'var(--color-background2)';
|
|
442
|
+
}};
|
|
443
|
+
padding: 0 var(--spacing-xs);
|
|
444
|
+
max-width: 0px;
|
|
445
|
+
text-align: ${_ref11 => {
|
|
446
|
+
let {
|
|
447
|
+
center
|
|
448
|
+
} = _ref11;
|
|
449
|
+
return center ? 'center' : 'left';
|
|
450
|
+
}};
|
|
451
|
+
vertical-align: middle;
|
|
452
|
+
transition: border-color 0.3s;
|
|
453
|
+
|
|
454
|
+
${_ref12 => {
|
|
455
|
+
let {
|
|
456
|
+
borderWidth,
|
|
457
|
+
borderColor
|
|
458
|
+
} = _ref12;
|
|
459
|
+
return css`
|
|
460
|
+
border-top: ${borderWidth} solid ${borderColor};
|
|
461
|
+
border-bottom: ${borderWidth} solid ${borderColor};
|
|
462
|
+
&:first-child {
|
|
463
|
+
border-left: ${borderWidth} solid ${borderColor};
|
|
464
|
+
border-top-left-radius: var(--border-radius-l);
|
|
465
|
+
border-bottom-left-radius: var(--border-radius-l);
|
|
466
|
+
padding-left: var(--spacing);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
&:last-child {
|
|
470
|
+
border-right: ${borderWidth} solid ${borderColor};
|
|
471
|
+
border-top-right-radius: var(--border-radius-l);
|
|
472
|
+
border-bottom-right-radius: var(--border-radius-l);
|
|
473
|
+
padding-right: var(--spacing);
|
|
474
|
+
}
|
|
475
|
+
`;
|
|
476
|
+
}}
|
|
477
|
+
> span {
|
|
478
|
+
display: inline-block;
|
|
479
|
+
width: 100%;
|
|
480
|
+
overflow: hidden;
|
|
481
|
+
white-space: pre;
|
|
482
|
+
text-overflow: ellipsis;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
${_ref13 => {
|
|
486
|
+
let {
|
|
487
|
+
noData
|
|
488
|
+
} = _ref13;
|
|
489
|
+
return noData && css`
|
|
490
|
+
padding: 20px 0;
|
|
491
|
+
`;
|
|
492
|
+
}}
|
|
493
|
+
|
|
494
|
+
${_ref14 => {
|
|
495
|
+
let {
|
|
496
|
+
enableRowDrag
|
|
497
|
+
} = _ref14;
|
|
498
|
+
return enableRowDrag && 'position: relative;';
|
|
499
|
+
}}
|
|
500
|
+
|
|
501
|
+
${media.mobile`
|
|
502
|
+
display: flex;
|
|
503
|
+
height: auto;
|
|
504
|
+
margin-bottom: var(--spacing-xs);
|
|
505
|
+
background: transparent !important;
|
|
506
|
+
border: none !important;
|
|
507
|
+
min-width: 100%;
|
|
508
|
+
|
|
509
|
+
&:first-child {
|
|
510
|
+
padding: var(--spacing-xs) 0 0 var(--spacing-xs);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
&:last-child {
|
|
514
|
+
padding-right: var(--spacing-xs);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
&:before {
|
|
518
|
+
content: attr(data-label) ": ";
|
|
519
|
+
font-weight: bold;
|
|
520
|
+
padding-right: var(--spacing-xs);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
> span {
|
|
524
|
+
flex: 1;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
${_ref15 => {
|
|
528
|
+
let {
|
|
529
|
+
custom
|
|
530
|
+
} = _ref15;
|
|
531
|
+
return custom && css`
|
|
532
|
+
&:last-child:before {
|
|
533
|
+
display: none;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
&:last-child {
|
|
537
|
+
padding: 0;
|
|
538
|
+
position: absolute;
|
|
539
|
+
right: 0.75rem;
|
|
540
|
+
top: var(--spacing-xs);
|
|
541
|
+
justify-content: flex-end;
|
|
542
|
+
}
|
|
543
|
+
`;
|
|
544
|
+
}}
|
|
545
|
+
`}
|
|
546
|
+
`;
|
|
547
|
+
const DragHandle = styled.div`
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
justify-content: center;
|
|
551
|
+
width: var(--spacing);
|
|
552
|
+
height: var(--spacing);
|
|
553
|
+
position: absolute;
|
|
554
|
+
left: calc(100% + var(--spacing-xs));
|
|
555
|
+
cursor: grab;
|
|
556
|
+
top: 50%;
|
|
557
|
+
transform: translateY(-50%);
|
|
558
|
+
`;
|
|
559
|
+
export default Table;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Badge } from '../../badge';
|
|
2
|
+
import { BsFillTagFill } from 'react-icons/bs/index.esm';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
const columns = [{
|
|
5
|
+
title: 'Name',
|
|
6
|
+
fieldName: 'name',
|
|
7
|
+
sortable: true,
|
|
8
|
+
width: '400px'
|
|
9
|
+
}, {
|
|
10
|
+
title: 'Tag',
|
|
11
|
+
fieldName: 'tag',
|
|
12
|
+
sortable: false,
|
|
13
|
+
width: '150px',
|
|
14
|
+
render(data) {
|
|
15
|
+
return data.length > 0 && /*#__PURE__*/_jsx(Badge, {
|
|
16
|
+
style: {
|
|
17
|
+
margin: '0'
|
|
18
|
+
},
|
|
19
|
+
success: true,
|
|
20
|
+
children: `${data.length} ${data.length > 1 ? 'Tags' : 'Tag'}`
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
customPop(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
tag
|
|
26
|
+
} = _ref;
|
|
27
|
+
return /*#__PURE__*/_jsx("div", {
|
|
28
|
+
style: {
|
|
29
|
+
display: 'grid',
|
|
30
|
+
gap: 'var(--spacing-xs)'
|
|
31
|
+
},
|
|
32
|
+
children: tag.map(_ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
name,
|
|
35
|
+
tag_id: id
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
38
|
+
style: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
gap: 'var(--spacing-xs)'
|
|
42
|
+
},
|
|
43
|
+
children: [/*#__PURE__*/_jsx(BsFillTagFill, {}), "\xA0", name]
|
|
44
|
+
}, id);
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
title: 'Contact Name',
|
|
50
|
+
fieldName: 'contact',
|
|
51
|
+
sortable: true,
|
|
52
|
+
width: '400px'
|
|
53
|
+
}, {
|
|
54
|
+
title: 'Contact Email',
|
|
55
|
+
fieldName: 'contactEmail',
|
|
56
|
+
sortable: false,
|
|
57
|
+
width: '500px'
|
|
58
|
+
}, {
|
|
59
|
+
title: 'telephone',
|
|
60
|
+
fieldName: 'telephone',
|
|
61
|
+
sortable: false,
|
|
62
|
+
width: '400px'
|
|
63
|
+
}];
|
|
64
|
+
export default columns;
|