@majoo-ui/react 2.0.0 → 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 +16 -5
  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,618 @@
1
+ import 'core-js/modules/es.array.push.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 'core-js/modules/es.json.stringify.js';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import { RemoveOutline } from '@majoo-ui/icons';
8
+ import React__default, { useState, useRef, useCallback, useEffect, memo } from 'react';
9
+ import { useTable, useSortBy, useExpanded, useRowSelect, useMountedLayoutEffect } from 'react-table';
10
+ import { styled, colors } from '../../config/stitches.config.esm.js';
11
+ import InputSwitch from '../form/components/InputSwitch/InputSwitch.esm.js';
12
+ import { InputText } from '../form/components/InputText/InputText.esm.js';
13
+ import Paragraph from '../paragraph/Paragraph.esm.js';
14
+ import InputCheckbox from '../form/components/InputCheckbox/InputCheckbox.esm.js';
15
+ import Flex from '../../layout/flex/Flex.esm.js';
16
+ import useMediaQuery from '../../utils/useMediaQuery.esm.js';
17
+ import EditableTableMobile from './EditableMobile.esm.js';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { pick, isEqual } from 'lodash';
20
+ import { defaultEmptyDataProps, TableHeaderCellContainer, TableHeadCellContent } from '../table/Table.esm.js';
21
+ import { useVirtual } from 'react-virtual';
22
+ import Tooltip from '../tooltip/Tooltip.esm.js';
23
+
24
+ const TableContainer = styled('div', {
25
+ display: 'block',
26
+ flexDirection: 'column',
27
+ maxWidth: '100%',
28
+ position: 'relative',
29
+ height: '100%',
30
+ overflow: 'auto'
31
+ });
32
+ const TableContent = styled('table', {
33
+ width: '100%',
34
+ borderSpacing: 0,
35
+ borderCollapse: 'collapse'
36
+ });
37
+ const TableHead = styled('thead', {
38
+ position: 'sticky',
39
+ top: 0,
40
+ backgroundColor: '$gray50',
41
+ boxShadow: '0 4px 4px rgba(0, 0, 0, 0.025)',
42
+ zIndex: 10
43
+ });
44
+ const TableHeadRow = styled('tr', {
45
+ borderBottom: '1pt solid $bgBorder'
46
+ });
47
+ const TableHeadCell = styled('th', {
48
+ height: '48px',
49
+ fontSize: '$header-table',
50
+ fontWeight: 600,
51
+ color: '$textSecondary',
52
+ textAlign: 'left',
53
+ paddingLeft: 8
54
+ });
55
+ const TableBody = styled('tbody', {});
56
+ const TableRow = styled('tr', {
57
+ borderTop: '1pt solid $bgBorder',
58
+ '&:last-child': {
59
+ borderBottom: '1pt solid $bgBorder'
60
+ },
61
+ '&:hover': {
62
+ backgroundColor: '$bgGray'
63
+ },
64
+ variants: {
65
+ subRow: {
66
+ true: {
67
+ borderTop: 'none',
68
+ borderBottom: '1pt solid $bgBorder'
69
+ }
70
+ }
71
+ }
72
+ });
73
+ const TableCell = styled('td', {
74
+ fontSize: '$short-content-regular',
75
+ lineHeight: '$short-content-regular',
76
+ letterSpacing: '$short-content-regular',
77
+ fontWeight: 400,
78
+ color: '$textPrimary',
79
+ position: 'relative',
80
+ paddingLeft: 8,
81
+ height: 'auto',
82
+ '&:last-child': {
83
+ paddingRight: 8
84
+ },
85
+ '@md': {
86
+ height: '80px'
87
+ },
88
+ variants: {
89
+ verticalAlign: {
90
+ top: {
91
+ verticalAlign: 'top'
92
+ },
93
+ middle: {
94
+ verticalAlign: 'middle'
95
+ },
96
+ bottom: {
97
+ verticalAlign: 'bottom'
98
+ }
99
+ }
100
+ }
101
+ });
102
+ const TableCellContent = styled('div', {
103
+ height: '100%',
104
+ paddingTop: 10,
105
+ paddingBottom: 10,
106
+ display: 'flex',
107
+ variants: {
108
+ align: {
109
+ top: {
110
+ alignItems: 'start'
111
+ },
112
+ center: {
113
+ alignItems: 'center'
114
+ },
115
+ bottom: {
116
+ alignItems: 'end'
117
+ }
118
+ }
119
+ }
120
+ });
121
+ const TableFoot = styled('tfoot', {
122
+ position: 'sticky',
123
+ bottom: 0,
124
+ backgroundColor: '$bgWhite'
125
+ });
126
+ const TableFootRow = styled('tr');
127
+ const TableFootCell = styled('td', {});
128
+ const StyledText = styled('p', {
129
+ fontSize: '$short-content-regular',
130
+ color: '$textPrimary',
131
+ fontWeight: 400,
132
+ margin: 0
133
+ });
134
+ const Variant = styled(Flex, {
135
+ gap: 2,
136
+ marginLeft: 8,
137
+ '@md': {
138
+ marginTop: 4,
139
+ marginBottom: 12,
140
+ marginLeft: 0
141
+ }
142
+ });
143
+ const VariantItem = styled('p', {
144
+ padding: '2px 4px',
145
+ backgroundColor: '$white',
146
+ border: '1px solid $gray150',
147
+ borderRadius: 4,
148
+ fontWeight: 500,
149
+ fontSize: '$label',
150
+ color: '$textBrand',
151
+ whiteSpace: 'nowrap',
152
+ overflow: 'hidden',
153
+ textOverflow: 'ellipsis',
154
+ textAlign: 'center',
155
+ margin: 0,
156
+ '@md': {
157
+ padding: '4px 8px'
158
+ }
159
+ });
160
+ const RemoveIcon = styled(RemoveOutline, {
161
+ cursor: 'pointer',
162
+ userSelect: 'none',
163
+ transitionDuration: '0.2s',
164
+ variants: {
165
+ position: {
166
+ leftBottom: {
167
+ position: 'absolute',
168
+ left: 0,
169
+ bottom: 10
170
+ },
171
+ rightBottom: {
172
+ position: 'absolute',
173
+ right: 0,
174
+ bottom: 10
175
+ },
176
+ leftTop: {
177
+ position: 'absolute',
178
+ left: 0,
179
+ top: 10
180
+ },
181
+ rightTop: {
182
+ position: 'absolute',
183
+ right: 0,
184
+ top: 10
185
+ }
186
+ }
187
+ }
188
+ });
189
+ const Input = styled(InputText, {
190
+ height: '32px !important'
191
+ });
192
+ const Required = styled('span', {
193
+ marginLeft: 4,
194
+ color: '$textRed !important'
195
+ });
196
+ const ContainerSwitch = styled('div', {
197
+ variants: {
198
+ position: {
199
+ leftBottom: {
200
+ position: 'absolute',
201
+ left: 0,
202
+ bottom: 10
203
+ },
204
+ rightBottom: {
205
+ position: 'absolute',
206
+ right: 0,
207
+ bottom: 10
208
+ },
209
+ leftTop: {
210
+ position: 'absolute',
211
+ left: 0,
212
+ top: 10
213
+ },
214
+ rightTop: {
215
+ position: 'absolute',
216
+ right: 0,
217
+ top: 10
218
+ }
219
+ }
220
+ }
221
+ });
222
+ function Product({
223
+ name,
224
+ label,
225
+ variants
226
+ }) {
227
+ function tooltipLabel(name, variants) {
228
+ if (variants && variants.length > 0) {
229
+ return `${name} - ${variants === null || variants === void 0 ? void 0 : variants.join(', ')}`;
230
+ }
231
+ return name;
232
+ }
233
+ return jsx(Tooltip, {
234
+ label: tooltipLabel(name, variants),
235
+ children: jsxs(Flex, {
236
+ css: {
237
+ flexDirection: 'row',
238
+ alignItems: 'center',
239
+ '@md': {
240
+ flexDirection: 'column',
241
+ alignItems: 'start'
242
+ }
243
+ },
244
+ children: [jsx(StyledText, {
245
+ children: name
246
+ }), jsx(Variant, {
247
+ wrap: "wrap",
248
+ children: variants === null || variants === void 0 ? void 0 : variants.map((item, index) => {
249
+ return jsx(VariantItem, {
250
+ children: item
251
+ }, index);
252
+ })
253
+ }), jsx(StyledText, {
254
+ css: {
255
+ fontWeight: 500,
256
+ display: 'none',
257
+ '@md': {
258
+ display: 'unset',
259
+ marginBottom: 10
260
+ }
261
+ },
262
+ children: label !== null && label !== void 0 ? label : 'Terima Stok'
263
+ })]
264
+ })
265
+ });
266
+ }
267
+ function Switch(props) {
268
+ return jsx(ContainerSwitch, {
269
+ position: props === null || props === void 0 ? void 0 : props.position,
270
+ css: props === null || props === void 0 ? void 0 : props.css,
271
+ children: jsx(InputSwitch, Object.assign({
272
+ dataOnLabel: "ON",
273
+ dataOffLabel: "OFF"
274
+ }, props))
275
+ });
276
+ }
277
+ function Remove(props) {
278
+ const [isHover, setIsHover] = useState(false);
279
+ function onEnter() {
280
+ setIsHover(true);
281
+ }
282
+ function onLeave() {
283
+ setIsHover(false);
284
+ }
285
+ return jsx(RemoveIcon, {
286
+ css: props === null || props === void 0 ? void 0 : props.css,
287
+ position: props === null || props === void 0 ? void 0 : props.position,
288
+ onClick: props === null || props === void 0 ? void 0 : props.onRemove,
289
+ color: isHover ? colors.red400 : colors.gray400,
290
+ onMouseEnter: onEnter,
291
+ onMouseLeave: onLeave
292
+ });
293
+ }
294
+ function EditableTable(props) {
295
+ var _a, _b;
296
+ const {
297
+ columns,
298
+ data,
299
+ rowHeight,
300
+ align,
301
+ customRows,
302
+ showCheckbox,
303
+ onSelectedChange,
304
+ getCheckboxProps,
305
+ keyId = 'id',
306
+ selectedIds,
307
+ onExpand,
308
+ isMobileLayout,
309
+ hiddenColumns,
310
+ customEmptyDataProps: emptyDataProps,
311
+ virtualized = false,
312
+ onSortByChange
313
+ } = props;
314
+ const {
315
+ t
316
+ } = useTranslation('MajooUI/table');
317
+ const [selectedIndex, setSelectedIndex] = useState(null);
318
+ const isMobile = useMediaQuery(isMobileLayout === undefined ? '(max-width: 767px)' : isMobileLayout ? '(max-width: 8000px)' : '(max-width: 0px)');
319
+ const IndeterminateCheckbox = props => {
320
+ function handleCheckedChange(checked) {
321
+ props === null || props === void 0 ? void 0 : props.onChange({
322
+ target: {
323
+ checked
324
+ }
325
+ });
326
+ setSelectedIndex(Object.assign({}, props));
327
+ }
328
+ return jsx(InputCheckbox, Object.assign({}, props, getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(props === null || props === void 0 ? void 0 : props.row), {
329
+ onCheckedChange: handleCheckedChange
330
+ }));
331
+ };
332
+ const getInitialState = () => {
333
+ const initialState = {};
334
+ if (selectedIds) {
335
+ Object.assign(initialState, {
336
+ selectedRowIds: selectedIds
337
+ });
338
+ }
339
+ return Object.keys(initialState).length > 0 ? initialState : undefined;
340
+ };
341
+ const instance = useTable({
342
+ columns,
343
+ data,
344
+ initialState: getInitialState(),
345
+ autoResetExpanded: false,
346
+ getRowId: row => row[keyId] || JSON.stringify(row),
347
+ defaultCanSort: false,
348
+ autoResetSortBy: false
349
+ }, useSortBy, useExpanded, useRowSelect, hooks => {
350
+ showCheckbox && hooks.visibleColumns.push(columns => {
351
+ return [{
352
+ id: 'selection',
353
+ Header: ({
354
+ getToggleAllRowsSelectedProps
355
+ }) => jsx(IndeterminateCheckbox, Object.assign({
356
+ row: "header"
357
+ }, getToggleAllRowsSelectedProps())),
358
+ Cell: ({
359
+ row
360
+ }) => jsx(IndeterminateCheckbox, Object.assign({
361
+ row: row
362
+ }, row.getToggleRowSelectedProps())),
363
+ width: 30
364
+ }, ...columns];
365
+ });
366
+ });
367
+ const {
368
+ getTableProps,
369
+ getTableBodyProps,
370
+ headerGroups,
371
+ rows,
372
+ prepareRow,
373
+ visibleColumns,
374
+ setHiddenColumns,
375
+ state: {
376
+ selectedRowIds,
377
+ sortBy
378
+ }
379
+ } = instance;
380
+ const tableContainerRef = useRef(null);
381
+ const rowVirtualizer = useVirtual({
382
+ parentRef: tableContainerRef,
383
+ size: data === null || data === void 0 ? void 0 : data.length,
384
+ overscan: isMobile ? 20 : 10,
385
+ estimateSize: useCallback(() => isMobile ? 40 : rowHeight || 80, [isMobile, rowHeight])
386
+ });
387
+ const {
388
+ virtualItems: virtualRows,
389
+ totalSize
390
+ } = rowVirtualizer;
391
+ const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _a === void 0 ? void 0 : _a.start) || 0 : 0;
392
+ const paddingBottom = virtualRows.length > 0 ? totalSize - (((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0) : 0;
393
+ useEffect(() => {
394
+ if (hiddenColumns) setHiddenColumns(hiddenColumns);
395
+ }, [hiddenColumns, setHiddenColumns]);
396
+ useEffect(() => {
397
+ if (data && data.length > 0 && selectedRowIds && onSelectedChange) {
398
+ const selected = selectedRowIds ? Object.keys(selectedRowIds) : [];
399
+ onSelectedChange({
400
+ selected,
401
+ row: (selectedIndex === null || selectedIndex === void 0 ? void 0 : selectedIndex.row) || {},
402
+ state: !(selectedIndex === null || selectedIndex === void 0 ? void 0 : selectedIndex.checked)
403
+ });
404
+ }
405
+ }, [selectedRowIds, data, onSelectedChange, selectedIndex]);
406
+ const customEmptyDataProps = emptyDataProps || defaultEmptyDataProps(t, isMobile);
407
+ const getCustomRows = (row, renderRow) => {
408
+ var _a;
409
+ let customStyle = {};
410
+ let CustomRow;
411
+ if (customRows && customRows(row).length) {
412
+ for (let i = 0; i < customRows(row).length; i++) {
413
+ if (customRows(row)[i].predicate) {
414
+ customStyle = (_a = customRows(row)[i]) === null || _a === void 0 ? void 0 : _a.css;
415
+ CustomRow = () => {
416
+ var _a;
417
+ return (_a = customRows(row)[i]) === null || _a === void 0 ? void 0 : _a.Row(row.values, renderRow);
418
+ };
419
+ }
420
+ }
421
+ }
422
+ return {
423
+ CustomRow,
424
+ customStyle
425
+ };
426
+ };
427
+ const renderTableRow = (row, customStyle) => {
428
+ return jsx(TableRow, Object.assign({
429
+ css: customStyle
430
+ }, row.getRowProps(), {
431
+ children: row.cells.filter(cell => {
432
+ var _a, _b, _c, _d, _e;
433
+ return !((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.isSubRow) && (typeof ((_b = cell === null || cell === void 0 ? void 0 : cell.column) === null || _b === void 0 ? void 0 : _b.hidden) === 'boolean' ? !((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.hidden) : !((_e = (_d = cell === null || cell === void 0 ? void 0 : cell.column) === null || _d === void 0 ? void 0 : _d.hidden) === null || _e === void 0 ? void 0 : _e.call(_d, cell)));
434
+ }).map(cell => {
435
+ var _a;
436
+ return !((_a = cell.column) === null || _a === void 0 ? void 0 : _a.isMobileOnly) && jsx(TableCell, Object.assign({}, cell.getCellProps({
437
+ style: {
438
+ minWidth: cell.column.minWidth,
439
+ width: cell.column.width,
440
+ maxWidth: cell.column.maxWidth
441
+ }
442
+ }), {
443
+ css: {
444
+ '@md': {
445
+ height: rowHeight
446
+ }
447
+ },
448
+ children: jsx(TableCellContent, {
449
+ align: align,
450
+ children: cell.render('Cell')
451
+ })
452
+ }));
453
+ })
454
+ }));
455
+ };
456
+ const tableRowData = virtualized ? virtualRows : rows;
457
+ useMountedLayoutEffect(() => {
458
+ if (onSortByChange) {
459
+ onSortByChange(sortBy);
460
+ }
461
+ }, [sortBy]);
462
+ return !isMobile ? jsx(TableContainer, {
463
+ ref: tableContainerRef,
464
+ css: props === null || props === void 0 ? void 0 : props.css,
465
+ children: jsxs(TableContent, Object.assign({}, getTableProps(), {
466
+ children: [jsx(TableHead, {
467
+ children: headerGroups.map(headerGroup => {
468
+ const visibleHeaders = headerGroup.headers.filter(column => {
469
+ var _a;
470
+ return !(column === null || column === void 0 ? void 0 : column.isSubRow) && (typeof (column === null || column === void 0 ? void 0 : column.hidden) === 'boolean' ? !(column === null || column === void 0 ? void 0 : column.hidden) : !((_a = column === null || column === void 0 ? void 0 : column.hidden) === null || _a === void 0 ? void 0 : _a.call(column, column)));
471
+ });
472
+ return jsx(TableHeadRow, Object.assign({}, headerGroup.getHeaderGroupProps(), {
473
+ children: visibleHeaders.map(column => {
474
+ const headerRender = column.render('Header');
475
+ return !(column === null || column === void 0 ? void 0 : column.isMobileOnly) && jsx(TableHeadCell, Object.assign({}, column.getHeaderProps(props => [props, column.sortable ? column.getSortByToggleProps({
476
+ title: t('sortColumnTitle', 'Urutkan') || 'Urutkan'
477
+ }) : {
478
+ onClick: column.onToggle
479
+ }, {
480
+ style: {
481
+ minWidth: column.minWidth,
482
+ width: column.width,
483
+ maxWidth: column.maxWidth
484
+ }
485
+ }]), {
486
+ children: typeof headerRender === 'string' ? jsx(TableHeaderCellContainer, {
487
+ isSortedDesc: column.isSortedDesc,
488
+ unsortable: !column.sortable,
489
+ isToggleable: !!column.onToggle,
490
+ isToggled: column.isToggled,
491
+ css: {
492
+ padding: 0
493
+ },
494
+ children: jsxs(TableHeadCellContent, {
495
+ heading: "headerTable",
496
+ children: [headerRender.toUpperCase(), (column === null || column === void 0 ? void 0 : column.isRequired) ? jsx(Required, {
497
+ children: "*"
498
+ }) : '']
499
+ })
500
+ }) : jsxs(Fragment, {
501
+ children: [headerRender, (column === null || column === void 0 ? void 0 : column.isRequired) ? jsx(Required, {
502
+ children: "*"
503
+ }) : '']
504
+ })
505
+ }));
506
+ })
507
+ }));
508
+ })
509
+ }), jsxs(TableBody, Object.assign({}, getTableBodyProps(), {
510
+ children: [virtualized && paddingTop > 0 && jsx("tr", {
511
+ children: jsx("td", {
512
+ style: {
513
+ height: `${paddingTop}px`
514
+ }
515
+ })
516
+ }), tableRowData.map((dataRow, index) => {
517
+ const row = virtualized ? rows === null || rows === void 0 ? void 0 : rows[dataRow === null || dataRow === void 0 ? void 0 : dataRow.index] : dataRow;
518
+ prepareRow(row);
519
+ const subRowCells = row.cells.filter(cell => cell.column.isSubRow);
520
+ const notNullHeaderColumns = visibleColumns.filter(column => typeof column.Header !== 'function' && column.Header !== null && !column.isSubRow);
521
+ const {
522
+ customStyle
523
+ } = getCustomRows(row);
524
+ const {
525
+ CustomRow
526
+ } = getCustomRows(row, () => renderTableRow(row, customStyle));
527
+ return jsxs(React__default.Fragment, {
528
+ children: [CustomRow ? jsx(CustomRow, {
529
+ style: customStyle
530
+ }) : renderTableRow(row, customStyle), subRowCells.map(cell => {
531
+ var _a;
532
+ return jsx(TableRow, {
533
+ subRow: true,
534
+ children: jsxs(React__default.Fragment, {
535
+ children: [jsx(TableCell, {
536
+ subCell: true,
537
+ colSpan: notNullHeaderColumns.length > 5 ? 2 : 1,
538
+ headerSubCell: true,
539
+ verticalAlign: (_a = cell.column) === null || _a === void 0 ? void 0 : _a.verticalAlign,
540
+ css: {
541
+ paddingTop: '$spacing-03 !important',
542
+ paddingBottom: '$spacing-03 !important',
543
+ '@md': {
544
+ height: rowHeight
545
+ }
546
+ },
547
+ children: jsx(Paragraph, {
548
+ paragraph: "shortContentBold",
549
+ children: cell.column.Header
550
+ })
551
+ }), jsx(TableCell, {
552
+ subCell: true,
553
+ colSpan: visibleColumns.length - subRowCells.length,
554
+ css: {
555
+ paddingTop: '$spacing-03 !important',
556
+ paddingBottom: '$spacing-03 !important'
557
+ },
558
+ children: jsx(Paragraph, {
559
+ paragraph: "shortContentRegular",
560
+ children: cell.render('Cell')
561
+ })
562
+ })]
563
+ }, cell.column.id)
564
+ }, cell.column.id);
565
+ })]
566
+ }, index);
567
+ }), virtualized && paddingBottom > 0 && jsx("tr", {
568
+ children: jsx("td", {
569
+ style: {
570
+ height: `${paddingBottom}px`
571
+ }
572
+ })
573
+ })]
574
+ })), rows.length < 1 && jsx(TableFoot, {
575
+ children: jsx(TableFootRow, {
576
+ children: jsx(TableFootCell, {
577
+ colSpan: "100%",
578
+ children: jsxs(Flex, {
579
+ align: "center",
580
+ justify: "center",
581
+ direction: "column",
582
+ gap: 3,
583
+ css: {
584
+ margin: '56px auto 100px'
585
+ },
586
+ children: [customEmptyDataProps.doodleImage, customEmptyDataProps.title, customEmptyDataProps.description]
587
+ })
588
+ })
589
+ })
590
+ })]
591
+ }))
592
+ }) : jsx(EditableTableMobile, {
593
+ css: props === null || props === void 0 ? void 0 : props.css,
594
+ instance: instance,
595
+ showCheckbox: showCheckbox,
596
+ customRows: customRows,
597
+ onExpand: onExpand,
598
+ hiddenColumns: hiddenColumns,
599
+ customEmptyDataProps: customEmptyDataProps,
600
+ virtualized: virtualized,
601
+ rowVirtualizer: rowVirtualizer,
602
+ tableContainerRef: tableContainerRef
603
+ });
604
+ }
605
+ EditableTable.Product = Product;
606
+ EditableTable.Input = Input;
607
+ EditableTable.Switch = Switch;
608
+ EditableTable.Remove = Remove;
609
+ EditableTable.TableRow = TableRow;
610
+ EditableTable.TableCell = TableCell;
611
+ const MemoizedEditableTable = /*#__PURE__*/memo(EditableTable, (prev, next) => {
612
+ const prevProps = pick(prev, ['data', 'additional']);
613
+ const nextProps = pick(next, ['data', 'additional']);
614
+ const eq = isEqual(prevProps, nextProps);
615
+ return eq;
616
+ });
617
+
618
+ export { MemoizedEditableTable, EditableTable as default };
@@ -0,0 +1,37 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+ import Box from '../../layout/box/Box.esm.js';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ function Collapalse({
6
+ children,
7
+ isOpen
8
+ }) {
9
+ const [height, setHeight] = useState(0);
10
+ const contentRef = useRef(null);
11
+ useEffect(() => {
12
+ const resizeObserver = new ResizeObserver(el => {
13
+ setHeight(el[0].contentRect.height);
14
+ });
15
+ resizeObserver.observe(contentRef.current);
16
+ return () => {
17
+ resizeObserver.disconnect();
18
+ };
19
+ }, [height, isOpen]);
20
+ return /*#__PURE__*/jsx(Box, {
21
+ css: {
22
+ maxHeight: isOpen ? height : 0,
23
+ overflow: 'hidden',
24
+ transition: '0.4s max-height',
25
+ width: '100%'
26
+ },
27
+ children: /*#__PURE__*/jsx(Box, {
28
+ ref: contentRef,
29
+ children: children
30
+ })
31
+ });
32
+ }
33
+ Collapalse.defaultProps = {
34
+ isOpen: false
35
+ };
36
+
37
+ export { Collapalse as default };