@majoo-ui/react 2.0.1 → 2.1.0-rc.1

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 (202) hide show
  1. package/charts.esm.js +3 -1453
  2. package/colors/Colors.esm.js +93 -0
  3. package/components/accordion/Accordion.esm.js +109 -0
  4. package/components/alertDialog/AlertDialog.esm.js +440 -0
  5. package/components/avatar/Avatar.esm.js +83 -0
  6. package/components/badge/Badge.esm.js +255 -0
  7. package/components/banner/Banner.esm.js +341 -0
  8. package/components/barChart/BarChart.esm.js +212 -0
  9. package/components/breadcrumb/Breadcrumb.esm.js +65 -0
  10. package/components/breadcrumb/index.esm.js +19 -0
  11. package/components/button/Button.esm.js +331 -0
  12. package/components/buttonGroup/ButtonGroup.esm.js +350 -0
  13. package/components/card/Card.esm.js +236 -0
  14. package/components/chart/assets/data_kosong.png.esm.js +3 -0
  15. package/components/chart/lineChart/LineChart.esm.js +358 -0
  16. package/components/chart/lineChart/components/Comparator.esm.js +82 -0
  17. package/components/chart/lineChart/components/ComparatorController.esm.js +112 -0
  18. package/components/chart/lineChart/components/ComparatorItem.esm.js +104 -0
  19. package/components/chart/lineChart/components/ProductList.esm.js +78 -0
  20. package/components/chart/lineChart/components/TitleLegend.esm.js +107 -0
  21. package/components/chart/lineChart/components/Tooltip.esm.js +90 -0
  22. package/components/chart/utils/index.esm.js +109 -0
  23. package/components/checkboxTable/CheckboxTable.esm.js +287 -0
  24. package/components/colorPicker/ColorPicker.esm.js +342 -0
  25. package/components/colorPicker/InputColorPicker.esm.js +120 -0
  26. package/components/colorPicker/assets/img_colormap.gif.esm.js +3 -0
  27. package/components/colorPicker/components/ColorFields.esm.js +144 -0
  28. package/components/colorPicker/components/ColorMap.esm.js +1188 -0
  29. package/components/contentEditor/ContentEditor.esm.js +251 -0
  30. package/components/contentEditor/assets/Inline-code-outline.svg.esm.js +3 -0
  31. package/components/contentEditor/assets/Link-outline.svg.esm.js +3 -0
  32. package/components/contentEditor/assets/List-bulleted-outline.svg.esm.js +3 -0
  33. package/components/contentEditor/assets/List-numbered-outline.svg.esm.js +3 -0
  34. package/components/contentEditor/assets/Redo-outline.svg.esm.js +3 -0
  35. package/components/contentEditor/assets/Text-bold-filled.svg.esm.js +3 -0
  36. package/components/contentEditor/assets/Text-clear-format-outline.svg.esm.js +3 -0
  37. package/components/contentEditor/assets/Text-italic-outline.svg.esm.js +3 -0
  38. package/components/contentEditor/assets/Text-strikethrough-outline.svg.esm.js +3 -0
  39. package/components/contentEditor/assets/Text-underline-outline.svg.esm.js +3 -0
  40. package/components/contentEditor/assets/Undo-outline.svg.esm.js +3 -0
  41. package/components/contextMenu/ContextMenu.esm.js +298 -0
  42. package/components/datePicker/AdvancedOption.esm.js +37 -0
  43. package/components/datePicker/CustomDatePicker.esm.js +121 -0
  44. package/components/datePicker/DatePicker.esm.js +244 -0
  45. package/components/datePicker/DatePickerMulti.esm.js +70 -0
  46. package/components/datePicker/InputDatePicker.esm.js +290 -0
  47. package/components/datePicker/InputDateRangePicker.esm.js +174 -0
  48. package/components/datePicker/components/Calendar.esm.js +654 -0
  49. package/components/datePicker/components/CalendarMulti.esm.js +407 -0
  50. package/components/datePicker/components/CalendarTimePicker.esm.js +104 -0
  51. package/components/datePicker/components/DateNumber.esm.js +89 -0
  52. package/components/datePicker/components/MobileCalendar.esm.js +522 -0
  53. package/components/datePicker/state/reducer.esm.js +286 -0
  54. package/components/datePicker/timePicker/InputTimePicker.esm.js +205 -0
  55. package/components/datePicker/timePicker/TimePicker.esm.js +481 -0
  56. package/components/devicePreview/DevicePreview.esm.js +631 -0
  57. package/components/devicePreview/deviceFrame/android-transparant.png.esm.js +3 -0
  58. package/components/devicePreview/deviceFrame/android-wide-transparant.png.esm.js +3 -0
  59. package/components/devicePreview/deviceFrame/bg-email.png.esm.js +3 -0
  60. package/components/devicePreview/deviceFrame/bg-notification.png.esm.js +3 -0
  61. package/components/devicePreview/deviceFrame/bg-sms.png.esm.js +3 -0
  62. package/components/devicePreview/deviceFrame/bg-whatsapp.png.esm.js +3 -0
  63. package/components/devicePreview/deviceFrame/desktop-transparant.png.esm.js +3 -0
  64. package/components/devicePreview/deviceFrame/ic-majoo-profpic.png.esm.js +3 -0
  65. package/components/devicePreview/deviceFrame/iphone-transparant.png.esm.js +3 -0
  66. package/components/dialog/Dialog.esm.js +106 -0
  67. package/components/drawer/Drawer.esm.js +294 -0
  68. package/components/dropdownMenu/DropdownMenu.esm.js +281 -0
  69. package/components/editableTable/EditableMobile.esm.js +361 -0
  70. package/components/editableTable/EditableTable.esm.js +618 -0
  71. package/components/editableTable/transition.esm.js +37 -0
  72. package/components/form/components/FormGroup/FormGroup.esm.js +142 -0
  73. package/components/form/components/FormHelper/Helper.esm.js +50 -0
  74. package/components/form/components/FormLabel/Label.esm.js +90 -0
  75. package/components/form/components/InputAddon/InputAddon.esm.js +105 -0
  76. package/components/form/components/InputCheckbox/CheckboxGroup.esm.js +60 -0
  77. package/components/form/components/InputCheckbox/InputCheckbox.esm.js +129 -0
  78. package/components/form/components/InputCheckbox/icon/CheckOutline.esm.js +33 -0
  79. package/components/form/components/InputCheckbox/icon/MinusOutline.esm.js +33 -0
  80. package/components/form/components/InputCombobox/InputCombobox.esm.js +169 -0
  81. package/components/form/components/InputCounter/InputCounter.esm.js +226 -0
  82. package/components/form/components/InputCreatable/InputCreatable.esm.js +229 -0
  83. package/components/form/components/InputDateRange/InputDateRange.esm.js +46 -0
  84. package/components/form/components/InputElement/InputElement.esm.js +35 -0
  85. package/components/form/components/InputGroup/InputGroup.esm.js +188 -0
  86. package/components/form/components/InputLetter/InputLetter.esm.js +68 -0
  87. package/components/form/components/InputNumber/InputNumber.esm.js +248 -0
  88. package/components/form/components/InputNumber/NumberFormat.esm.js +1263 -0
  89. package/components/form/components/InputOTP/InputOTP.esm.js +70 -0
  90. package/components/form/components/InputRadio/InputRadio.esm.js +273 -0
  91. package/components/form/components/InputRadio/InputRadioGroup.esm.js +35 -0
  92. package/components/form/components/InputRadio/context.esm.js +5 -0
  93. package/components/form/components/InputResourceList/InputResourceList.esm.js +429 -0
  94. package/components/form/components/InputSearchbox/CloseFilled.esm.js +34 -0
  95. package/components/form/components/InputSearchbox/InputSearchbox.esm.js +90 -0
  96. package/components/form/components/InputSearchbox/SearchOutline.esm.js +26 -0
  97. package/components/form/components/InputSelect/InputSelect.esm.js +964 -0
  98. package/components/form/components/InputSelectCheck/InputSelectCheck.esm.js +1388 -0
  99. package/components/form/components/InputSelectCheck/OptionGroupItem.esm.js +39 -0
  100. package/components/form/components/InputSelectCheck/icon/CheckOutline.esm.js +33 -0
  101. package/components/form/components/InputSelectTag/InputSelectTag.esm.js +62 -0
  102. package/components/form/components/InputSignature/InputSignature.esm.js +122 -0
  103. package/components/form/components/InputSignature/SignatureModal.esm.js +67 -0
  104. package/components/form/components/InputSwitch/InputSwitch.esm.js +96 -0
  105. package/components/form/components/InputSwitch/InputSwitchWithImage.esm.js +136 -0
  106. package/components/form/components/InputTags/InputTags.esm.js +268 -0
  107. package/components/form/components/InputText/InputText.esm.js +197 -0
  108. package/components/form/components/InputTextArea/InputTextArea.esm.js +77 -0
  109. package/components/heading/Heading.esm.js +64 -0
  110. package/components/iconButton/IconButton.esm.js +71 -0
  111. package/components/image/Image.esm.js +141 -0
  112. package/components/link/Link.esm.js +59 -0
  113. package/components/loadingBar/LoadingBar.esm.js +113 -0
  114. package/components/mapPicker/InputMapPicker.esm.js +160 -0
  115. package/components/mapPicker/MapPicker.esm.js +122 -0
  116. package/components/mapPicker/MapPicker.styles.esm.js +70 -0
  117. package/components/mapPicker/assets/images/Mapsicle.png.esm.js +3 -0
  118. package/components/mapPicker/components/AddressCard.esm.js +25 -0
  119. package/components/mapPicker/components/ButtonSelect.esm.js +46 -0
  120. package/components/mapPicker/components/ChangeView.esm.js +20 -0
  121. package/components/mapPicker/components/InputSearch.esm.js +74 -0
  122. package/components/mapPicker/components/MarkerIcon.esm.js +22 -0
  123. package/components/mapPicker/components/MarkerSvg.esm.js +62 -0
  124. package/components/mapPicker/components/ZoomControls.esm.js +36 -0
  125. package/components/mapPicker/hooks/useMapSearch.esm.js +161 -0
  126. package/components/modalDialog/ModalDialog.esm.js +247 -0
  127. package/components/notificationBadge/NotificationBadge.esm.js +149 -0
  128. package/components/pageDialog/PageDialog.esm.js +291 -0
  129. package/components/pageDialog/logo.svg.esm.js +3 -0
  130. package/components/pagination/Pagination.esm.js +94 -0
  131. package/components/pagination/PaginationButton.esm.js +346 -0
  132. package/components/pagination/PaginationInfo.esm.js +146 -0
  133. package/components/paper/Paper.esm.js +76 -0
  134. package/components/paragraph/Paragraph.esm.js +52 -0
  135. package/components/pieChart/PieChart.esm.js +287 -0
  136. package/components/popover/Popover.esm.js +142 -0
  137. package/components/progress/Progress.esm.js +170 -0
  138. package/components/progressIndicator/ProgressIndicator.esm.js +287 -0
  139. package/components/scrollSync/ScrollSync.esm.js +172 -0
  140. package/components/scrollSync/ScrollSyncNode.esm.js +87 -0
  141. package/components/scrollSync/utils.esm.js +9 -0
  142. package/components/separator/Separator.esm.js +43 -0
  143. package/components/skeleton/Skeleton.esm.js +131 -0
  144. package/components/slider/Slider.esm.js +345 -0
  145. package/components/stepWizard/StepWizard.esm.js +451 -0
  146. package/components/stepWizard/index.esm.js +14 -0
  147. package/components/table/MobileTable.esm.js +415 -0
  148. package/components/table/Table.esm.js +1472 -0
  149. package/components/table/components/columns/DateColumn.esm.js +26 -0
  150. package/components/table/components/columns/DecimalColumn.esm.js +36 -0
  151. package/components/table/components/columns/PriceColumn.esm.js +57 -0
  152. package/components/table/components/columns/RowDraggableColumn.esm.js +24 -0
  153. package/components/table/components/columns/RowExpanderColumn.esm.js +32 -0
  154. package/components/table/components/columns/RowExpanderMultipleColumn.esm.js +24 -0
  155. package/components/table/components/columns/RowMenuColumn.esm.js +101 -0
  156. package/components/table/components/columns/RowSelectionCallbackColumn.esm.js +38 -0
  157. package/components/table/components/columns/RowSelectionColumn.esm.js +34 -0
  158. package/components/table/images/img-emptydata.webp.esm.js +3 -0
  159. package/components/table/images/img-emptysearchdata.webp.esm.js +3 -0
  160. package/components/tableOfContent/TableOfContent.esm.js +267 -0
  161. package/components/tableOfContent/index.esm.js +18 -0
  162. package/components/tableOfContent/transition.esm.js +38 -0
  163. package/components/tabs/Tabs.esm.js +282 -0
  164. package/components/tag/Tag.esm.js +161 -0
  165. package/components/tagList/TagList.esm.js +90 -0
  166. package/components/tagStatus/TagStatus.esm.js +134 -0
  167. package/components/text/Text.esm.js +140 -0
  168. package/components/toast/Toast.esm.js +297 -0
  169. package/components/toast/ToastContainer.esm.js +73 -0
  170. package/components/toast/context/ToastContext.esm.js +5 -0
  171. package/components/toast/context/ToastProvider.esm.js +96 -0
  172. package/components/tooltip/Tooltip.esm.js +175 -0
  173. package/components/upload/Upload.esm.js +1103 -0
  174. package/components/upload/utils/canvasPreview.esm.js +39 -0
  175. package/components/upload/utils/imgPreview.esm.js +21 -0
  176. package/config/stitches.config.esm.js +216 -0
  177. package/editor.esm.js +1 -264
  178. package/hooks/useListOption/useListOption.esm.js +56 -0
  179. package/hooks/useToggle/useToggle.esm.js +8 -0
  180. package/index.esm.js +106 -42293
  181. package/layout/box/Box.esm.js +24 -0
  182. package/layout/flex/Flex.esm.js +135 -0
  183. package/layout/grid/Grid.esm.js +270 -0
  184. package/layout/pageContainer/PageContainer.esm.js +60 -0
  185. package/majoo-provider/MajooProvider.esm.js +42 -0
  186. package/majoo-provider/ThemeProvider.esm.js +41 -0
  187. package/majoo-provider/globalStyles.esm.js +242 -0
  188. package/majoo-provider/styles/modern-normalize.esm.js +95 -0
  189. package/map.esm.js +2 -734
  190. package/package.json +8 -4
  191. package/utils/calendar.esm.js +26 -0
  192. package/utils/element.esm.js +21 -0
  193. package/utils/object.esm.js +12 -0
  194. package/utils/request.esm.js +74 -0
  195. package/utils/strings.esm.js +6 -0
  196. package/{useMediaQuery.esm.js → utils/useMediaQuery.esm.js} +1 -1
  197. package/utils/useNavigatorOnline.esm.js +19 -0
  198. package/utils/variant.esm.js +12 -0
  199. package/wrapper/ConditionalWrapper.esm.js +9 -0
  200. package/ModalDialog.esm.js +0 -2669
  201. package/Separator.esm.js +0 -3002
  202. package/stitches.config.esm.js +0 -2284
@@ -0,0 +1,78 @@
1
+ import 'core-js/modules/es.iterator.constructor.js';
2
+ import 'core-js/modules/es.iterator.map.js';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import React__default from 'react';
5
+ import Box from '../../../../layout/box/Box.esm.js';
6
+ import Flex from '../../../../layout/flex/Flex.esm.js';
7
+ import Tooltip from '../../../tooltip/Tooltip.esm.js';
8
+ import { Tag } from '../../../tag/Tag.esm.js';
9
+
10
+ const tooltipLabel = (name, variants) => {
11
+ if (variants && variants.length > 0) {
12
+ return `${name} - ${variants && variants.join(', ')}`;
13
+ }
14
+ return name;
15
+ };
16
+ const ProductList = props => {
17
+ const {
18
+ variants = [],
19
+ name,
20
+ direction,
21
+ css
22
+ } = props;
23
+ return jsx(Tooltip, {
24
+ label: tooltipLabel(name, variants),
25
+ children: jsxs(Box, {
26
+ gap: 2,
27
+ css: Object.assign({
28
+ display: 'flex',
29
+ alignItems: 'center',
30
+ flexDirection: direction === 'column' ? 'column' : 'row',
31
+ gap: '4px',
32
+ maxWidth: '250px',
33
+ '@md': {
34
+ maxWidth: '124px',
35
+ flexDirection: direction === 'row' ? 'row' : 'column',
36
+ alignItems: 'flex-start'
37
+ }
38
+ }, css),
39
+ children: [jsx(Box, {
40
+ title: name && name,
41
+ css: {
42
+ maxWidth: '124px',
43
+ overflow: 'hidden',
44
+ whiteSpace: 'nowrap',
45
+ textOverflow: 'ellipsis',
46
+ fontSize: 14,
47
+ fontWeight: 600,
48
+ color: '$textSecondary'
49
+ },
50
+ children: name
51
+ }), variants && variants.length > 0 && jsxs(React__default.Fragment, {
52
+ children: [jsx(Flex, {
53
+ gap: 2,
54
+ children: variants.slice(0, 2).map(variant => jsx(Tag, {
55
+ css: {
56
+ height: 'auto',
57
+ padding: '4px 8px'
58
+ },
59
+ type: "varian",
60
+ children: variant
61
+ }, variant))
62
+ }), variants.length > 2 && jsx(Tag, {
63
+ css: {
64
+ height: 'auto',
65
+ padding: '4px 8px',
66
+ minWidth: 'unset',
67
+ justifyContent: 'flex-start',
68
+ mr: 'auto'
69
+ },
70
+ type: "varian",
71
+ children: `+${variants.length - 2}`
72
+ }, "index")]
73
+ })]
74
+ })
75
+ });
76
+ };
77
+
78
+ export { ProductList as default };
@@ -0,0 +1,107 @@
1
+ import 'core-js/modules/es.iterator.constructor.js';
2
+ import 'core-js/modules/es.iterator.find.js';
3
+ import 'core-js/modules/es.iterator.map.js';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+ import Heading from '../../../heading/Heading.esm.js';
6
+ import Text from '../../../text/Text.esm.js';
7
+ import Box from '../../../../layout/box/Box.esm.js';
8
+ import { styled } from '../../../../config/stitches.config.esm.js';
9
+ import InputCheckbox from '../../../form/components/InputCheckbox/InputCheckbox.esm.js';
10
+
11
+ const StyledDescription = styled('p', {
12
+ marginTop: '$spacing-03',
13
+ fontWeight: 400,
14
+ fontSize: 12,
15
+ color: '$textSecondary'
16
+ });
17
+ const TitleLegend = props => {
18
+ const {
19
+ title,
20
+ description,
21
+ legendData,
22
+ filteredData,
23
+ setFilteredData,
24
+ isComparator,
25
+ titleOnly
26
+ } = props;
27
+ return filteredData.length > 0 ? jsxs(Box, {
28
+ css: {
29
+ display: 'flex',
30
+ marginBottom: '$spacing-06',
31
+ '@sm': {
32
+ flexDirection: 'column',
33
+ gap: '$compact',
34
+ alignItems: 'start'
35
+ },
36
+ '@md': {
37
+ flexDirection: 'row',
38
+ justifyContent: 'space-between'
39
+ }
40
+ },
41
+ children: [jsxs(Box, {
42
+ css: {
43
+ marginBottom: '$spacing-03'
44
+ },
45
+ children: [jsx(Heading, {
46
+ heading: "sectionTitle",
47
+ css: {
48
+ lineHeight: '24px'
49
+ },
50
+ children: title
51
+ }), description && jsx(StyledDescription, {
52
+ children: description
53
+ })]
54
+ }), !titleOnly && !isComparator && jsx(Box, {
55
+ css: {
56
+ '@sm': {
57
+ display: 'grid',
58
+ gridTemplateColumns: legendData.length > 2 ? '1fr 1fr' : '1fr',
59
+ gap: legendData.length > 2 ? '$compact' : '4px'
60
+ },
61
+ '@md': {
62
+ display: 'flex',
63
+ flexWrap: 'nowrap',
64
+ gap: '$compact'
65
+ }
66
+ },
67
+ children: legendData.map(legend => jsxs(Box, {
68
+ css: {
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ justifyContent: 'start'
72
+ },
73
+ children: [legend.isHideable && jsx(InputCheckbox, {
74
+ id: legend.name,
75
+ checked: !filteredData.find(data => data.name === legend.name).hide,
76
+ onCheckedChange: status => setFilteredData(filteredData.map(data => data.name === legend.name ? Object.assign(Object.assign({}, data), {
77
+ hide: !status
78
+ }) : Object.assign({}, data)))
79
+ }), jsx(Box, {
80
+ css: {
81
+ backgroundColor: legend.color,
82
+ borderRadius: '50%',
83
+ display: 'inline-block',
84
+ margin: '0px 6px 0px 10px',
85
+ '@sm': {
86
+ height: legend.isHideable ? 4 : 10,
87
+ width: legend.isHideable ? 4 : 10
88
+ },
89
+ '@md': {
90
+ height: 6,
91
+ width: 6
92
+ }
93
+ }
94
+ }), jsx(Text, {
95
+ variant: "label",
96
+ children: legend.name
97
+ })]
98
+ }, legend.name))
99
+ })]
100
+ }) : jsx(Box, {});
101
+ };
102
+ TitleLegend.defaultProps = {
103
+ isComparator: undefined,
104
+ titleOnly: false
105
+ };
106
+
107
+ export { TitleLegend as default };
@@ -0,0 +1,90 @@
1
+ import 'core-js/modules/es.iterator.constructor.js';
2
+ import 'core-js/modules/es.iterator.filter.js';
3
+ import 'core-js/modules/es.iterator.find.js';
4
+ import 'core-js/modules/es.iterator.map.js';
5
+ import 'core-js/modules/es.iterator.some.js';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+ import Paragraph from '../../../paragraph/Paragraph.esm.js';
8
+ import Box from '../../../../layout/box/Box.esm.js';
9
+ import Flex from '../../../../layout/flex/Flex.esm.js';
10
+ import moment from 'moment';
11
+ import { styled } from '../../../../config/stitches.config.esm.js';
12
+ import { isValidDate, currency, numSeparator } from '../../utils/index.esm.js';
13
+
14
+ const StyledIconLeft = styled('div', {
15
+ margin: '5px 3px 5px 0px',
16
+ display: 'inline-flex',
17
+ verticalAlign: 'middle',
18
+ width: '8px',
19
+ height: '8px',
20
+ borderRadius: '50%'
21
+ });
22
+ const Tooltip = props => {
23
+ const {
24
+ hover,
25
+ payload,
26
+ active,
27
+ legendData,
28
+ xAxisKey,
29
+ chartTypeLabel,
30
+ customTooltipDate
31
+ } = props;
32
+ if (legendData.some(l => l.dataKey === 'novalue')) {
33
+ return jsx("div", {});
34
+ }
35
+ const formatValue = (legendDataKey, hoverKey, hoverValue) => {
36
+ let finalValue = '';
37
+ const selectedKey = legendDataKey.find(l => l.dataKey === hoverKey);
38
+ if (selectedKey === undefined) return finalValue;
39
+ const formattedValue = Number.isNaN(Number(hoverValue)) ? '0' : `${selectedKey.isCurrency ? currency({
40
+ value: hoverValue,
41
+ convertMinus: hoverValue < 0,
42
+ decimal: true
43
+ }) : numSeparator(hoverValue)}`;
44
+ finalValue = `${formattedValue} ${chartTypeLabel !== null && chartTypeLabel !== void 0 ? chartTypeLabel : selectedKey.name}`;
45
+ return finalValue;
46
+ };
47
+ if (active && hover) {
48
+ const visibleValue = legendData.filter(v => v.hide === false);
49
+ const mapValue = visibleValue.map(val => Object.assign(Object.assign({}, val), {
50
+ name: val.dataKey,
51
+ hoverValue: payload[0].payload[val.dataKey]
52
+ }));
53
+ const hoverDate = payload[0].payload[xAxisKey];
54
+ return jsxs(Box, {
55
+ css: {
56
+ backgroundColor: '$textContent',
57
+ color: '$white',
58
+ borderRadius: '$sm',
59
+ padding: '$spacing-03'
60
+ },
61
+ children: [payload && (customTooltipDate ? jsx(Paragraph, {
62
+ paragraph: "shortContentRegular",
63
+ children: isValidDate(hoverDate) ? customTooltipDate(hoverDate) : hoverDate
64
+ }) : jsx(Paragraph, {
65
+ paragraph: "shortContentRegular",
66
+ children: isValidDate(hoverDate) ? moment(hoverDate).locale('id-ID').format('DD MMMM YYYY') : hoverDate
67
+ })), mapValue.map((s, index) => jsxs(Flex, {
68
+ align: "center",
69
+ gap: 2,
70
+ children: [jsx(StyledIconLeft, {
71
+ css: {
72
+ backgroundColor: s.color
73
+ }
74
+ }), jsx(Paragraph, {
75
+ paragraph: "shortContentRegular",
76
+ children: formatValue(legendData, s.name, s.hoverValue)
77
+ }, s.name)]
78
+ }, `${s.name}_${index}`))]
79
+ });
80
+ }
81
+ return null;
82
+ };
83
+ Tooltip.defaultProps = {
84
+ hover: null,
85
+ payload: undefined,
86
+ active: undefined,
87
+ legendData: []
88
+ };
89
+
90
+ export { Tooltip as default };
@@ -0,0 +1,109 @@
1
+ import moment from 'moment';
2
+
3
+ //@ts-nocheck
4
+ const formatHour = date => moment(date, 'YYYY-MM-DD HH:mm:ss').format('HH:mm');
5
+ const formatDay = date => moment(date).locale('id-ID').format('DD MMM');
6
+ const formatMonth = date => moment(date).locale('id-ID').format('MMM');
7
+ const formatYear = date => new Date(Date.parse(date)).toLocaleDateString('id-ID', {
8
+ year: 'numeric'
9
+ });
10
+ const handleXaxis = (date, period) => {
11
+ switch (period) {
12
+ case 'jam':
13
+ return formatHour(date);
14
+ case 'hari':
15
+ return formatDay(date);
16
+ case 'minggu':
17
+ return formatDay(date);
18
+ case 'bulan':
19
+ return formatMonth(date);
20
+ case 'tahun':
21
+ return formatYear(date);
22
+ default:
23
+ return formatDay(date);
24
+ }
25
+ };
26
+ const currency = ({
27
+ value,
28
+ type = 'Rp',
29
+ thousandSeparator = '.',
30
+ decimal = false,
31
+ convertMinus = false
32
+ }) => {
33
+ let formattedNumber;
34
+ if (decimal) {
35
+ const toFixedNum = parseFloat(value).toFixed(2);
36
+ const decimalSplit = toFixedNum ? toFixedNum.split('.') : ['0', '00'];
37
+ decimalSplit[0] = decimalSplit[0].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${thousandSeparator}`);
38
+ formattedNumber = decimalSplit.join(thousandSeparator === ',' ? '.' : ',');
39
+ } else {
40
+ formattedNumber = Math.round(value).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${thousandSeparator}`);
41
+ }
42
+ if (convertMinus && parseFloat(value) < 0) {
43
+ const numberWithoutMinus = formattedNumber.toString().replace('-', '');
44
+ return type.length > 0 ? `( ${type} ${numberWithoutMinus} )` : `( ${numberWithoutMinus} )`;
45
+ }
46
+ return type.length > 0 ? `${type} ${formattedNumber}` : formattedNumber;
47
+ };
48
+ const numSeparator = num => {
49
+ const toFixedNum = parseFloat(num).toFixed(2); // set two decimal places
50
+ const decimalSplit = toFixedNum.split('.');
51
+ let formatedNumber = decimalSplit[0].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.');
52
+ if (decimalSplit.length <= 2) {
53
+ const decimalNumber = decimalSplit[1];
54
+ if (decimalNumber) {
55
+ formatedNumber += `,${decimalNumber}`;
56
+ }
57
+ }
58
+ return formatedNumber;
59
+ };
60
+ const formatCurrency = (number, options) => new Intl.NumberFormat('id-Id', Object.assign({
61
+ style: 'currency',
62
+ currency: 'IDR'
63
+ }, options)).format(number);
64
+ const compactCurrency = number => formatCurrency(number, {
65
+ notation: 'compact',
66
+ compactDisplay: 'short'
67
+ }).replace('Rp', '').trim();
68
+ const roundUp = highestVal => {
69
+ let upper = 1;
70
+ for (let j = 0; j < Number.parseInt(highestVal, 10).toString().length; j += 1) {
71
+ upper += String(0);
72
+ }
73
+ if (highestVal === 0 || highestVal === Number.NEGATIVE_INFINITY) {
74
+ return 1;
75
+ }
76
+ if (highestVal <= 5) {
77
+ return 5;
78
+ }
79
+ if (Math.ceil(highestVal) % (upper / 10) !== 0) {
80
+ const newHighest = Math.ceil(highestVal / (upper * 0.2)) * (upper * 0.2);
81
+ return newHighest;
82
+ }
83
+ return highestVal;
84
+ };
85
+ const roundDown = lowestVal => {
86
+ let upper,
87
+ _lowestVal = 0;
88
+ if (lowestVal) {
89
+ if (parseFloat(lowestVal) < 0) {
90
+ upper = -1;
91
+ for (let z = 0; z < Math.abs(parseInt(lowestVal, 10)).toString().length; z += 1) {
92
+ upper += String(0);
93
+ }
94
+ if (Math.ceil(lowestVal) % (upper / 10) !== 0) {
95
+ const newLowest = Math.ceil(lowestVal / (upper * 0.2)) * (upper * 0.2);
96
+ _lowestVal = Math.ceil(newLowest);
97
+ } else {
98
+ _lowestVal = lowestVal;
99
+ }
100
+ }
101
+ return _lowestVal;
102
+ }
103
+ return _lowestVal;
104
+ };
105
+ function isValidDate(date) {
106
+ return date instanceof Date && !isNaN(date);
107
+ }
108
+
109
+ export { compactCurrency, currency, formatCurrency, formatDay, formatHour, formatMonth, formatYear, handleXaxis, isValidDate, numSeparator, roundDown, roundUp };
@@ -0,0 +1,287 @@
1
+ import 'core-js/modules/es.array.includes.js';
2
+ import 'core-js/modules/es.iterator.constructor.js';
3
+ import 'core-js/modules/es.iterator.filter.js';
4
+ import 'core-js/modules/es.iterator.map.js';
5
+ import React__default, { useState, createElement } from 'react';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+ import { ChevronUpOutline, ChevronDownOutline, MinusOutline } from '@majoo-ui/icons';
8
+ import { useTable, useExpanded } from 'react-table';
9
+ import Paragraph from '../paragraph/Paragraph.esm.js';
10
+ import { styled, colors } from '../../config/stitches.config.esm.js';
11
+ import Box from '../../layout/box/Box.esm.js';
12
+ import Flex from '../../layout/flex/Flex.esm.js';
13
+ import InputCheckbox from '../form/components/InputCheckbox/InputCheckbox.esm.js';
14
+
15
+ const TableContainer = styled('div', {
16
+ display: 'block',
17
+ flexDirection: 'column',
18
+ maxWidth: '100%',
19
+ position: 'relative',
20
+ height: '100%',
21
+ overflow: 'auto'
22
+ });
23
+ const TableContent = styled('table', {
24
+ width: '100%',
25
+ borderSpacing: 0,
26
+ borderCollapse: 'collapse'
27
+ });
28
+ const TableHead = styled('thead', {
29
+ position: 'sticky',
30
+ top: 0,
31
+ backgroundColor: '$white',
32
+ zIndex: 10
33
+ });
34
+ const TableHeadRow = styled('tr', {
35
+ borderBottom: '1px solid $bgBorder'
36
+ });
37
+ const TableHeadCell = styled('th', {
38
+ height: 44,
39
+ fontSize: '$header-table',
40
+ fontWeight: 600,
41
+ color: '$textPrimary',
42
+ textAlign: 'left',
43
+ paddingLeft: 8
44
+ });
45
+ const TableBody = styled('tbody', {});
46
+ const TableRow = styled('tr', {
47
+ borderTop: '1pt solid $bgBorder',
48
+ '&:last-child': {
49
+ borderBottom: '1pt solid $bgBorder'
50
+ },
51
+ '&:hover': {
52
+ backgroundColor: '$bgGray'
53
+ },
54
+ variants: {
55
+ subRow: {
56
+ true: {
57
+ borderTop: 'none',
58
+ borderBottom: '1pt solid $bgBorder'
59
+ }
60
+ }
61
+ }
62
+ });
63
+ const TableCell = styled('td', {
64
+ fontSize: '$short-content-regular',
65
+ lineHeight: '$short-content-regular',
66
+ letterSpacing: '$short-content-regular',
67
+ fontWeight: 400,
68
+ color: '$textPrimary',
69
+ position: 'relative',
70
+ paddingLeft: 8,
71
+ height: 44,
72
+ '&:last-child': {
73
+ paddingRight: 8
74
+ },
75
+ variants: {
76
+ verticalAlign: {
77
+ top: {
78
+ verticalAlign: 'top'
79
+ },
80
+ middle: {
81
+ verticalAlign: 'middle'
82
+ },
83
+ bottom: {
84
+ verticalAlign: 'bottom'
85
+ }
86
+ }
87
+ }
88
+ });
89
+ const TableCellContent = styled('div', {
90
+ height: '100%',
91
+ paddingTop: 10,
92
+ paddingBottom: 10,
93
+ display: 'flex',
94
+ userSelect: 'none',
95
+ variants: {
96
+ align: {
97
+ top: {
98
+ alignItems: 'start'
99
+ },
100
+ center: {
101
+ alignItems: 'center'
102
+ },
103
+ bottom: {
104
+ alignItems: 'end'
105
+ }
106
+ }
107
+ }
108
+ });
109
+ const Required = styled('span', {
110
+ marginLeft: 4,
111
+ color: '$textRed !important'
112
+ });
113
+ function CheckboxTable(props) {
114
+ const {
115
+ columns,
116
+ data,
117
+ emptyDataMessage,
118
+ rowHeight,
119
+ align,
120
+ onChange
121
+ } = props;
122
+ const [datasets, setDatasets] = useState([...data]);
123
+ const instance = useTable({
124
+ columns,
125
+ data: datasets,
126
+ autoResetExpanded: false
127
+ }, useExpanded);
128
+ const {
129
+ getTableProps,
130
+ getTableBodyProps,
131
+ rows,
132
+ headerGroups,
133
+ prepareRow,
134
+ toggleAllRowsExpanded,
135
+ state
136
+ } = instance;
137
+ return jsxs(TableContainer, {
138
+ css: props === null || props === void 0 ? void 0 : props.css,
139
+ children: [jsxs(TableContent, Object.assign({}, getTableProps(), {
140
+ children: [jsx(TableHead, {
141
+ children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map(headerGroup => {
142
+ const visibleHeaders = headerGroup.headers.filter(column => !column.isSubRow);
143
+ return jsx(TableHeadRow, Object.assign({}, headerGroup.getHeaderGroupProps(), {
144
+ children: visibleHeaders === null || visibleHeaders === void 0 ? void 0 : visibleHeaders.map(column => jsxs(TableHeadCell, Object.assign({}, column.getHeaderProps({
145
+ style: {
146
+ minWidth: column.minWidth,
147
+ width: column.width,
148
+ maxWidth: column.maxWidth
149
+ }
150
+ }), {
151
+ children: [column.render('Header'), (column === null || column === void 0 ? void 0 : column.isRequired) ? jsx(Required, {
152
+ children: "*"
153
+ }) : '']
154
+ })))
155
+ }));
156
+ })
157
+ }), jsx(TableBody, Object.assign({}, getTableBodyProps(), {
158
+ children: rows === null || rows === void 0 ? void 0 : rows.map((row, index) => {
159
+ var _a, _b, _c;
160
+ prepareRow(row);
161
+ const originalRow = row.original;
162
+ return jsxs(React__default.Fragment, {
163
+ children: [/*#__PURE__*/createElement(TableRow, Object.assign({}, row.getRowProps(), {
164
+ key: index
165
+ }), (_b = (_a = row === null || row === void 0 ? void 0 : row.cells) === null || _a === void 0 ? void 0 : _a.filter(cell => !cell.column.isSubRow)) === null || _b === void 0 ? void 0 : _b.map((cell, indexCell) => {
166
+ var _a;
167
+ const column = cell.column;
168
+ const originalCell = cell.row.original;
169
+ return /*#__PURE__*/createElement(TableCell, Object.assign({}, cell.getCellProps({
170
+ style: {
171
+ minWidth: column.minWidth,
172
+ width: column.width,
173
+ maxWidth: column.maxWidth
174
+ }
175
+ }), {
176
+ key: index + indexCell + 'tb-cell',
177
+ css: {
178
+ '@md': {
179
+ height: rowHeight
180
+ }
181
+ }
182
+ }), jsxs(TableCellContent, {
183
+ align: align,
184
+ children: [indexCell === 0 && jsx(Flex, {
185
+ justify: "center",
186
+ align: "center",
187
+ css: {
188
+ marginRight: 12,
189
+ cursor: 'pointer',
190
+ display: ((_a = originalCell === null || originalCell === void 0 ? void 0 : originalCell.detail) === null || _a === void 0 ? void 0 : _a.length) ? 'flex' : 'none !important'
191
+ },
192
+ onClick: () => {
193
+ if (!Object.keys(state.expanded).includes(row.id)) {
194
+ toggleAllRowsExpanded(false);
195
+ }
196
+ row.toggleRowExpanded(!row.isExpanded);
197
+ },
198
+ children: row.isExpanded ? jsx(ChevronUpOutline, {}) : jsx(ChevronDownOutline, {})
199
+ }), cell.render('Cell')]
200
+ }));
201
+ })), (_c = originalRow === null || originalRow === void 0 ? void 0 : originalRow.detail) === null || _c === void 0 ? void 0 : _c.map((cell, index) => {
202
+ const id_row = originalRow === null || originalRow === void 0 ? void 0 : originalRow.id;
203
+ const {
204
+ id: id_subrow,
205
+ name,
206
+ detail_method
207
+ } = cell;
208
+ const headerRender = name;
209
+ return /*#__PURE__*/createElement(TableRow, Object.assign({}, row.getRowProps(), {
210
+ key: `row_collapse_${index}`,
211
+ css: {
212
+ display: row.isExpanded ? 'table-row' : 'none'
213
+ }
214
+ }), jsx(TableCell, {
215
+ css: {
216
+ '@md': {
217
+ height: rowHeight
218
+ }
219
+ },
220
+ children: jsx(Box, {
221
+ css: {
222
+ paddingLeft: 36
223
+ },
224
+ children: headerRender
225
+ })
226
+ }, index + 'tb-cell-collapse'), detail_method === null || detail_method === void 0 ? void 0 : detail_method.map((subRow, indexSubRow) => {
227
+ const {
228
+ id: id_col,
229
+ is_grant,
230
+ is_show
231
+ } = subRow;
232
+ return jsx(TableCell, {
233
+ css: {
234
+ '@md': {
235
+ height: rowHeight
236
+ }
237
+ },
238
+ children: jsx(Box, {
239
+ children: Number(is_show) === 1 ? jsx(InputCheckbox, {
240
+ checked: Number(is_grant) === 1,
241
+ indeterminate: false,
242
+ onCheckedChange: e => {
243
+ const newDatasets = [...datasets];
244
+ for (const [indexDataRow, dataRow] of newDatasets.entries()) {
245
+ const rowData = dataRow;
246
+ if ((rowData === null || rowData === void 0 ? void 0 : rowData.id) === id_row) {
247
+ for (const [indexDataSubRow, dataSubRow] of rowData.detail.entries()) {
248
+ if ((dataSubRow === null || dataSubRow === void 0 ? void 0 : dataSubRow.id) === id_subrow) {
249
+ for (const [indexDataCol, dataCol] of dataSubRow.detail_method.entries()) {
250
+ if ((dataCol === null || dataCol === void 0 ? void 0 : dataCol.id) === id_col) {
251
+ newDatasets[indexDataRow].detail[indexDataSubRow].detail_method[indexDataCol].is_grant = e ? 1 : 0;
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
257
+ }
258
+ setDatasets(newDatasets);
259
+ onChange === null || onChange === void 0 ? void 0 : onChange(newDatasets);
260
+ }
261
+ }) : jsx(MinusOutline, {
262
+ size: 16,
263
+ color: colors.iconDisable
264
+ })
265
+ })
266
+ }, index + indexSubRow + 'tb-cell-collapse');
267
+ }));
268
+ })]
269
+ });
270
+ })
271
+ }))]
272
+ })), rows.length < 1 && jsx(Flex, {
273
+ css: {
274
+ padding: '$spacing-07'
275
+ },
276
+ align: "center",
277
+ justify: "center",
278
+ children: jsx(Paragraph, {
279
+ paragraph: "shortContentRegular",
280
+ color: "secondary",
281
+ children: emptyDataMessage || 'Tidak ada data'
282
+ })
283
+ })]
284
+ });
285
+ }
286
+
287
+ export { CheckboxTable as default };