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