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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) 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
  203. package/{index.esm.css → charts.esm.css} +4 -4
@@ -0,0 +1,358 @@
1
+ import 'core-js/modules/es.iterator.constructor.js';
2
+ import 'core-js/modules/es.iterator.map.js';
3
+ import 'core-js/modules/es.iterator.some.js';
4
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
+ import { foundations } from '@majoo-ui/core';
6
+ import { useState, useEffect } from 'react';
7
+ import { ResponsiveContainer, LineChart as LineChart$1, XAxis, YAxis, CartesianGrid, Tooltip, Line } from 'recharts';
8
+ import { Image } from '../../image/Image.esm.js';
9
+ import Text from '../../text/Text.esm.js';
10
+ import { styled } from '../../../config/stitches.config.esm.js';
11
+ import img from '../assets/data_kosong.png.esm.js';
12
+ import { isValidDate, handleXaxis, roundDown, roundUp, compactCurrency } from '../utils/index.esm.js';
13
+ import Comparator from './components/Comparator.esm.js';
14
+ import TitleLegend from './components/TitleLegend.esm.js';
15
+ import Tooltip$1 from './components/Tooltip.esm.js';
16
+
17
+ const {
18
+ colors
19
+ } = foundations;
20
+ const Container = styled('div', {
21
+ '@sm': {
22
+ overflowY: 'hidden',
23
+ whiteSpace: 'nowrap',
24
+ overflowX: 'scroll',
25
+ scrollbarWidth: 0,
26
+ '&::-webkit-scrollbar': {
27
+ width: 0,
28
+ height: 0
29
+ }
30
+ },
31
+ '@md': {
32
+ overflowX: 'auto',
33
+ overflowY: 'auto',
34
+ whiteSpace: 'wrap'
35
+ }
36
+ });
37
+ const ErrorWrapper = styled('div', {
38
+ display: 'flex',
39
+ justifyContent: 'center',
40
+ alignItems: 'center',
41
+ height: '100%',
42
+ flexDirection: 'column',
43
+ variants: {
44
+ hidden: {
45
+ true: {
46
+ display: 'none'
47
+ }
48
+ }
49
+ }
50
+ });
51
+ const StyledContainer = styled('div', {
52
+ position: 'relative',
53
+ '@md': {
54
+ width: '100%',
55
+ height: 300
56
+ },
57
+ '& circle': {
58
+ r: 4
59
+ },
60
+ 'g.yAxis text': {
61
+ fontSize: '$label',
62
+ lineHeight: '$label',
63
+ fontWeight: '500',
64
+ fill: '$textSecondary'
65
+ },
66
+ 'g.xAxis text': {
67
+ fontSize: '$label',
68
+ lineHeight: '$label',
69
+ fontWeight: '500',
70
+ fill: '$textPrimary'
71
+ },
72
+ variants: {
73
+ hidden: {
74
+ true: {
75
+ '& > #responsive-container': {
76
+ display: 'none'
77
+ }
78
+ }
79
+ },
80
+ isEmpty: {
81
+ true: {
82
+ '@sm': {
83
+ width: 'auto',
84
+ height: 254,
85
+ display: 'flex',
86
+ justifyContent: 'center'
87
+ }
88
+ },
89
+ false: {
90
+ '@sm': {
91
+ width: 900,
92
+ height: 254,
93
+ display: 'inline-block',
94
+ justifyContent: 'unset'
95
+ }
96
+ }
97
+ }
98
+ }
99
+ });
100
+ const ContainerLoading = styled('div', {
101
+ display: 'flex',
102
+ justifyContent: 'center',
103
+ alignItems: 'center',
104
+ zIndex: '$docked',
105
+ position: 'absolute',
106
+ inset: 0,
107
+ top: 0,
108
+ bottom: 0,
109
+ left: 0,
110
+ right: 0,
111
+ backgroundColor: '$bgWhite',
112
+ opacity: 0.8,
113
+ userSelect: 'none',
114
+ variants: {
115
+ loading: {
116
+ false: {
117
+ display: 'none'
118
+ }
119
+ }
120
+ }
121
+ });
122
+ const COMPARISON_LIMIT = 5;
123
+ function LineChart(props) {
124
+ const {
125
+ title,
126
+ description,
127
+ data,
128
+ legendData,
129
+ xAxisKey,
130
+ isLoading,
131
+ period,
132
+ customXAxisFormat,
133
+ customYAxisFormat,
134
+ roundUpYAxis,
135
+ placeholder,
136
+ comparatorList,
137
+ chartTypeLabel,
138
+ onComparatorChange,
139
+ customTooltipDate
140
+ } = props;
141
+ const [isDividedByThousand, setIsDividedByThousand] = useState(false);
142
+ const [isComparator, setIsComparator] = useState(false);
143
+ const [hover, setHover] = useState(null);
144
+ const [filteredData, setFilteredData] = useState([]);
145
+ const [maxData, setMaxData] = useState(0);
146
+ useEffect(() => {
147
+ if (maxData > 0) {
148
+ setIsDividedByThousand(String(Math.round(maxData)).length > 10);
149
+ }
150
+ }, [maxData]);
151
+ useEffect(() => {
152
+ setFilteredData(legendData.map(value => Object.assign(Object.assign({}, value), {
153
+ hide: false,
154
+ isCurrency: !!value.isCurrency
155
+ })));
156
+ if (legendData.length === 0) {
157
+ setFilteredData([{
158
+ dataKey: 'novalue',
159
+ name: 'novalue',
160
+ color: colors.chartYellow,
161
+ hide: true
162
+ }]);
163
+ setIsComparator(false);
164
+ }
165
+ if (legendData.some(l => l.isComparator === true)) {
166
+ setIsComparator(true);
167
+ setFilteredData(legendData.map(value => Object.assign(Object.assign({}, value), {
168
+ hide: false
169
+ })).slice(0, COMPARISON_LIMIT));
170
+ }
171
+ }, [legendData]);
172
+ const handleActiveDot = e => {
173
+ const {
174
+ cx,
175
+ cy,
176
+ fill
177
+ } = e;
178
+ if (e.dataKey === hover) {
179
+ return jsx("circle", {
180
+ cx: cx,
181
+ cy: cy,
182
+ r: 10,
183
+ fill: colors.white,
184
+ stroke: fill,
185
+ strokeWidth: 3
186
+ });
187
+ }
188
+ return jsx("circle", {
189
+ cx: cx,
190
+ cy: cy,
191
+ r: 10,
192
+ fill: "#00000000",
193
+ stroke: "#00000000",
194
+ strokeWidth: 3
195
+ });
196
+ };
197
+ return jsxs(Fragment, {
198
+ children: [jsx(TitleLegend, {
199
+ title: title,
200
+ description: description,
201
+ legendData: legendData,
202
+ filteredData: filteredData,
203
+ setFilteredData: setFilteredData,
204
+ isComparator: isComparator,
205
+ isDividedByThousand: isDividedByThousand,
206
+ titleOnly: data.length === 0
207
+ }), jsx(Container, {
208
+ children: jsxs(StyledContainer, {
209
+ hidden: data.length < 1,
210
+ isEmpty: data.length < 1,
211
+ children: [jsx(ResponsiveContainer, {
212
+ id: "responsive-container",
213
+ children: jsxs(LineChart$1, {
214
+ data: legendData.length === 0 ? data.map(d => Object.assign(Object.assign({}, d), {
215
+ novalue: 0
216
+ })) : data,
217
+ margin: {
218
+ top: 20,
219
+ bottom: 5,
220
+ right: 20
221
+ },
222
+ children: [jsx(XAxis, {
223
+ dataKey: xAxisKey,
224
+ padding: {
225
+ left: 20
226
+ },
227
+ interval: "preserveEnd",
228
+ tickLine: false,
229
+ axisLine: false,
230
+ hide: data.length === 0,
231
+ dy: 10,
232
+ tickFormatter: dateValue => {
233
+ if (!isValidDate(dateValue)) return dateValue;
234
+ if (customXAxisFormat) {
235
+ return customXAxisFormat(dateValue);
236
+ }
237
+ if (period) {
238
+ return handleXaxis(dateValue, period);
239
+ }
240
+ return dateValue;
241
+ }
242
+ }), jsx(YAxis, {
243
+ textAnchor: "start",
244
+ tickLine: false,
245
+ axisLine: false,
246
+ dy: -10,
247
+ dx: -50,
248
+ type: "number",
249
+ tickCount: maxData === 0 ? 3 : 5,
250
+ allowDecimals: roundUpYAxis,
251
+ tickFormatter: val => {
252
+ if (customYAxisFormat) {
253
+ return customYAxisFormat(val);
254
+ }
255
+ return compactCurrency(val);
256
+ },
257
+ domain: [dataMin => dataMin < 0 ? roundDown(dataMin) : 0, dataMax => {
258
+ setMaxData(dataMax);
259
+ return roundUpYAxis ? roundUp(dataMax) : dataMax;
260
+ }]
261
+ }), jsx(CartesianGrid, {
262
+ vertical: false,
263
+ x: 0,
264
+ width: 9999
265
+ }), jsx(Tooltip, {
266
+ cursor: false,
267
+ content: jsx(Tooltip$1, {
268
+ hover: hover,
269
+ xAxisKey: xAxisKey,
270
+ chartTypeLabel: chartTypeLabel,
271
+ legendData: filteredData,
272
+ maxValue: maxData,
273
+ customTooltipDate: customTooltipDate
274
+ })
275
+ }), !isLoading && filteredData.map(legend => data.length === 1 ? jsx(Line, {
276
+ type: "monotone",
277
+ dot: false,
278
+ dataKey: legend.dataKey,
279
+ stroke: legend.color,
280
+ hide: legend.hide,
281
+ strokeWidth: 4,
282
+ onMouseOver: () => setHover(legend.dataKey),
283
+ activeDot: {
284
+ onMouseOver: (_, b) => {
285
+ const {
286
+ cx,
287
+ cy,
288
+ fill
289
+ } = b;
290
+ setHover(legend.dataKey);
291
+ return jsx("circle", {
292
+ cx: cx,
293
+ cy: cy,
294
+ r: 10,
295
+ fill: colors.white,
296
+ stroke: fill,
297
+ strokeWidth: 3
298
+ });
299
+ },
300
+ onMouseLeave: () => setHover(null)
301
+ }
302
+ }, legend.name) : jsx(Line, {
303
+ type: "monotone",
304
+ dot: false,
305
+ dataKey: legend.dataKey,
306
+ stroke: legend.color,
307
+ hide: legend.hide,
308
+ strokeWidth: 4,
309
+ onMouseOver: () => setHover(legend.dataKey),
310
+ activeDot: handleActiveDot
311
+ }, legend.name))]
312
+ })
313
+ }), jsxs(ErrorWrapper, {
314
+ hidden: data.length > 0,
315
+ children: [jsx(Image, {
316
+ src: img,
317
+ alt: "no-data-content"
318
+ }), jsx(Text, {
319
+ variant: "status",
320
+ children: "Tidak ada data yang dapat ditampilkan"
321
+ })]
322
+ }), jsx(ContainerLoading, {
323
+ loading: isLoading,
324
+ children: jsx(Text, {
325
+ variant: "caption",
326
+ children: "Loading .... "
327
+ })
328
+ })]
329
+ })
330
+ }), isComparator && comparatorList && jsx(Comparator, {
331
+ legendData: comparatorList,
332
+ placeholder: placeholder,
333
+ option: filteredData,
334
+ onCloseClick: x => onComparatorChange === null || onComparatorChange === void 0 ? void 0 : onComparatorChange({
335
+ type: 'DELETE',
336
+ payload: x
337
+ }),
338
+ onComparatorAdd: x => onComparatorChange === null || onComparatorChange === void 0 ? void 0 : onComparatorChange({
339
+ type: 'ADD',
340
+ payload: x
341
+ }),
342
+ onComparatorSearch: x => onComparatorChange === null || onComparatorChange === void 0 ? void 0 : onComparatorChange({
343
+ type: 'SEARCH',
344
+ payload: x
345
+ })
346
+ })]
347
+ });
348
+ }
349
+ LineChart.defaultProps = {
350
+ customXAxisFormat: undefined,
351
+ onComparatorChange: undefined,
352
+ comparatorList: [],
353
+ placeholder: 'Cari ...',
354
+ roundUpYAxis: true,
355
+ period: undefined
356
+ };
357
+
358
+ export { COMPARISON_LIMIT, LineChart as default };
@@ -0,0 +1,82 @@
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.map.js';
4
+ import 'core-js/modules/es.iterator.some.js';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { useState, useEffect } from 'react';
7
+ import Flex from '../../../../layout/flex/Flex.esm.js';
8
+ import { styled } from '../../../../config/stitches.config.esm.js';
9
+ import { COMPARISON_LIMIT } from '../LineChart.esm.js';
10
+ import ComparatorItem from './ComparatorItem.esm.js';
11
+ import ComparatorController from './ComparatorController.esm.js';
12
+
13
+ const Comparator = props => {
14
+ const {
15
+ option,
16
+ onCloseClick,
17
+ onComparatorAdd,
18
+ legendData,
19
+ placeholder,
20
+ onComparatorSearch
21
+ } = props;
22
+ const [filteredOption, setFilteredOption] = useState(option);
23
+ const [isDisableClose, setIsDisableClose] = useState(false);
24
+ const visibleOptions = option.filter(opt => !opt.hide);
25
+ useEffect(() => {
26
+ setFilteredOption(legendData.filter(f => !option.some(l => {
27
+ if (typeof l.value === 'number') {
28
+ return +l.value === +f.value;
29
+ }
30
+ if (typeof l.value === 'string') {
31
+ return String(l.value) === String(f.value);
32
+ }
33
+ return false;
34
+ })));
35
+ if (option.length === 1) {
36
+ setIsDisableClose(true);
37
+ } else {
38
+ setIsDisableClose(false);
39
+ }
40
+ }, [option, legendData]);
41
+ const Container = styled(Flex, {
42
+ borderRadius: 8,
43
+ marginTop: '$spacing-02',
44
+ '@sm': {
45
+ display: 'grid',
46
+ gap: 8,
47
+ gridTemplateColumns: 'repeat(2,1fr)',
48
+ boxShadow: 'none',
49
+ backgroundColor: 'transparent'
50
+ },
51
+ '@md': {
52
+ display: 'flex',
53
+ flexWrap: 'wrap',
54
+ width: 'fit-content',
55
+ rowGap: '$compact',
56
+ boxShadow: '$small',
57
+ backgroundColor: '$white'
58
+ },
59
+ '& > #comparator-item:last-child > #separator-item': {
60
+ display: 'none'
61
+ }
62
+ });
63
+ return jsxs(Container, {
64
+ children: [visibleOptions.map(opt => jsx(ComparatorItem, {
65
+ dataKey: opt.dataKey,
66
+ color: opt.color,
67
+ onCloseClick: () => onCloseClick(opt),
68
+ variants: opt.variants,
69
+ disableClose: isDisableClose
70
+ }, opt.value)), option.length < COMPARISON_LIMIT && filteredOption.length > 0 && jsx(ComparatorController, {
71
+ option: filteredOption,
72
+ onComparatorAdd: d => onComparatorAdd(d),
73
+ onComparatorSearch: keyword => onComparatorSearch(keyword),
74
+ placeholder: placeholder
75
+ })]
76
+ });
77
+ };
78
+ Comparator.defaultProps = {
79
+ option: [{}]
80
+ };
81
+
82
+ export { Comparator as default };
@@ -0,0 +1,112 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import React__default, { useState, useRef, useEffect } from 'react';
3
+ import { Button } from '../../../button/Button.esm.js';
4
+ import { InputSelect } from '../../../form/components/InputSelect/InputSelect.esm.js';
5
+ import Box from '../../../../layout/box/Box.esm.js';
6
+ import { PlusOutline } from '@majoo-ui/icons';
7
+ import { foundations } from '@majoo-ui/core';
8
+
9
+ const {
10
+ colors
11
+ } = foundations;
12
+ const ComparatorController = ({
13
+ option,
14
+ onComparatorAdd,
15
+ onComparatorSearch,
16
+ placeholder
17
+ }) => {
18
+ const [toggle, setToggle] = useState(true);
19
+ const [selectedValue, setSelectedValue] = useState();
20
+ const ref = useRef(null);
21
+ const handleToggle = () => {
22
+ setToggle(!toggle);
23
+ };
24
+ const handleSelected = selected => {
25
+ onComparatorAdd(selected);
26
+ setSelectedValue(undefined);
27
+ setToggle(true);
28
+ };
29
+ const handleSearch = keyword => {
30
+ onComparatorSearch(keyword);
31
+ return keyword;
32
+ };
33
+ useEffect(() => {
34
+ function handleClickOutside(event) {
35
+ if (ref.current && !ref.current.contains(event.target) && !toggle) {
36
+ setToggle(!toggle);
37
+ }
38
+ }
39
+ document.addEventListener('mousedown', handleClickOutside);
40
+ return () => {
41
+ document.removeEventListener('mousedown', handleClickOutside);
42
+ };
43
+ }, [ref, toggle, selectedValue]);
44
+ return jsxs(React__default.Fragment, {
45
+ children: [jsx(Box, {
46
+ css: {
47
+ display: toggle ? 'flex' : 'none',
48
+ justifyContent: 'center',
49
+ alignItems: 'center',
50
+ '@sm': {
51
+ padding: 0
52
+ }
53
+ },
54
+ children: jsx(Button, {
55
+ buttonType: "ghost",
56
+ css: {
57
+ fontWeight: 600,
58
+ fontSize: 14,
59
+ '@sm': {
60
+ height: 60,
61
+ width: '100%',
62
+ backgroundColor: '$white',
63
+ boxShadow: '$small',
64
+ borderRadius: '$md'
65
+ },
66
+ '@md': {
67
+ height: 'auto',
68
+ width: 'auto',
69
+ backgroundColor: 'none',
70
+ boxShadow: 'none',
71
+ borderRadius: 'none'
72
+ }
73
+ },
74
+ leftIcon: jsx(PlusOutline, {
75
+ size: 24,
76
+ color: colors.primary500
77
+ }),
78
+ onClick: () => handleToggle(),
79
+ children: "Perbandingan"
80
+ })
81
+ }), jsx(Box, {
82
+ css: {
83
+ display: toggle ? 'none' : 'flex',
84
+ justifyContent: 'center',
85
+ alignItems: 'center',
86
+ padding: '$spacing-03 $spacing-04'
87
+ },
88
+ children: jsx("div", {
89
+ ref: ref,
90
+ children: jsx(InputSelect, {
91
+ showLeadingIcon: true,
92
+ search: true,
93
+ size: "sm",
94
+ placeholder: placeholder,
95
+ option: option,
96
+ onChange: x => handleSelected(x),
97
+ onSearch: y => handleSearch(y),
98
+ css: {
99
+ '& > div > div': {
100
+ maxHeight: '250px',
101
+ '&::-webkit-scrollbar': {
102
+ display: 'none'
103
+ }
104
+ }
105
+ }
106
+ }, String(toggle))
107
+ })
108
+ })]
109
+ });
110
+ };
111
+
112
+ export { ComparatorController as default };
@@ -0,0 +1,104 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { foundations } from '@majoo-ui/core';
3
+ import { CloseOutline } from '@majoo-ui/icons';
4
+ import Box from '../../../../layout/box/Box.esm.js';
5
+ import Flex from '../../../../layout/flex/Flex.esm.js';
6
+ import ProductList from './ProductList.esm.js';
7
+
8
+ const {
9
+ colors
10
+ } = foundations;
11
+ const ComparatorItem = props => {
12
+ const {
13
+ dataKey,
14
+ color,
15
+ onCloseClick,
16
+ disableClose,
17
+ variants
18
+ } = props;
19
+ return jsxs(Flex, {
20
+ id: "comparator-item",
21
+ children: [jsxs(Box, {
22
+ css: {
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ '@sm': {
26
+ padding: '$spacing-02',
27
+ gap: 8,
28
+ backgroundColor: '$white',
29
+ boxShadow: '$small',
30
+ borderRadius: '$md'
31
+ },
32
+ '@md': {
33
+ padding: '$spacing-03 $spacing-04',
34
+ gap: '$compact',
35
+ backgroundColor: 'none',
36
+ boxShadow: 'none',
37
+ borderRadius: 'none'
38
+ }
39
+ },
40
+ children: [jsxs(Box, {
41
+ css: {
42
+ display: 'flex',
43
+ alignItems: 'center',
44
+ position: 'relative',
45
+ gap: '$spacing-08',
46
+ '@md': {
47
+ gap: '$spacing-10'
48
+ }
49
+ },
50
+ children: [jsxs(Box, {
51
+ css: {
52
+ display: 'flex',
53
+ alignItems: 'center',
54
+ height: 24
55
+ },
56
+ children: [jsx(Box, {
57
+ css: {
58
+ position: 'absolute',
59
+ left: 4,
60
+ backgroundColor: color,
61
+ width: 12,
62
+ height: 12,
63
+ borderRadius: '50%'
64
+ }
65
+ }), jsx(Box, {
66
+ css: {
67
+ width: 80,
68
+ height: 4,
69
+ backgroundColor: color
70
+ }
71
+ })]
72
+ }), jsx(Box, {
73
+ onClick: () => onCloseClick(),
74
+ css: {
75
+ cursor: 'pointer',
76
+ display: disableClose ? 'none' : 'block'
77
+ },
78
+ children: jsx(CloseOutline, {
79
+ color: colors.textSecondary,
80
+ size: 24
81
+ })
82
+ })]
83
+ }), jsx(ProductList, {
84
+ name: dataKey,
85
+ variants: variants,
86
+ direction: "column",
87
+ css: {
88
+ '& > div': {
89
+ fontWeight: 600
90
+ }
91
+ }
92
+ })]
93
+ }), jsx(Box, {
94
+ id: "separator-item",
95
+ css: {
96
+ height: '100%',
97
+ width: 1,
98
+ backgroundColor: '$bgBorder'
99
+ }
100
+ })]
101
+ });
102
+ };
103
+
104
+ export { ComparatorItem as default };