@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,1103 @@
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.map.js';
4
+ import 'core-js/modules/web.url-search-params.delete.js';
5
+ import 'core-js/modules/web.url-search-params.has.js';
6
+ import 'core-js/modules/web.url-search-params.size.js';
7
+ import { UploadOutline, ImageOutline, CloseFilled, EyeOutline } from '@majoo-ui/icons';
8
+ import React__default, { useRef, useState, useEffect } from 'react';
9
+ import { styled, colors } from '../../config/stitches.config.esm.js';
10
+ import PropTypes from 'prop-types';
11
+ import Box from '../../layout/box/Box.esm.js';
12
+ import Flex from '../../layout/flex/Flex.esm.js';
13
+ import { Button } from '../button/Button.esm.js';
14
+ import LoadingBar from '../loadingBar/LoadingBar.esm.js';
15
+ import ModalDialog, { ModalDialogTrigger, ModalDialogTitle, ModalDialogContent, ModalDialogFooter } from '../modalDialog/ModalDialog.esm.js';
16
+ import ReactCrop, { centerCrop, makeAspectCrop } from 'react-image-crop';
17
+ import { imgPreview } from './utils/imgPreview.esm.js';
18
+ import { upload } from '../../utils/request.esm.js';
19
+ import imageCompressionComponent from 'browser-image-compression';
20
+ import useMediaQuery from '../../utils/useMediaQuery.esm.js';
21
+ import { jsxs, jsx } from 'react/jsx-runtime';
22
+ import Tooltip from '../tooltip/Tooltip.esm.js';
23
+
24
+ const Input = styled('input', {
25
+ display: 'none !important'
26
+ });
27
+ const Children = styled('div', {
28
+ display: 'flex',
29
+ justifyContent: 'center',
30
+ alignItems: 'center',
31
+ flexDirection: 'column'
32
+ });
33
+ const Text = styled('p', {
34
+ color: '$textDisable',
35
+ fontSize: 12,
36
+ fontWeight: 400,
37
+ fontStyle: 'normal',
38
+ textAlign: 'center',
39
+ variants: {
40
+ hidden: {
41
+ true: {
42
+ display: 'none'
43
+ }
44
+ }
45
+ }
46
+ });
47
+ const FileExtension = styled('p', {
48
+ color: '#C1C1C1',
49
+ fontSize: 40,
50
+ fontWeight: 700,
51
+ fontStyle: 'normal'
52
+ });
53
+ const ErrorMessage = styled('p', {
54
+ color: '$red400',
55
+ fontSize: 12,
56
+ fontWeight: 400,
57
+ fontStyle: 'normal',
58
+ textAlign: 'center',
59
+ marginTop: '$spacing-02'
60
+ });
61
+ const IconCard = styled(Flex, {
62
+ borderRadius: 50,
63
+ background: '$bgWhite',
64
+ textAlign: 'center',
65
+ width: 32,
66
+ height: 32
67
+ });
68
+ const ButtonText = styled('button', {
69
+ outline: 'none',
70
+ border: 'none',
71
+ background: 'transparent',
72
+ fontStyle: 'normal',
73
+ fontWeight: 600,
74
+ fontSize: 14,
75
+ color: '$primary500',
76
+ cursor: 'pointer',
77
+ padding: '$spacing-02 $spacing-04 $spacing-02 $spacing-04',
78
+ borderRadius: 4,
79
+ '&:hover': {
80
+ background: '$bgSelectedLight'
81
+ }
82
+ });
83
+ const CloseIcon = styled(CloseFilled, {
84
+ cursor: 'pointer',
85
+ position: 'absolute',
86
+ top: 5,
87
+ right: 5
88
+ });
89
+ const EyeIcon = styled(EyeOutline, {
90
+ cursor: 'pointer',
91
+ background: 'rgba(39, 42, 42, 0.6)',
92
+ borderRadius: 50,
93
+ width: 32,
94
+ height: 32,
95
+ padding: '$spacing-02'
96
+ });
97
+ const IconStateFull = ({
98
+ customPreviewIcon,
99
+ ...props
100
+ }) => {
101
+ const [isHover, setIsHover] = useState(false);
102
+ function handleEnter() {
103
+ setIsHover(true);
104
+ }
105
+ function handleLeave() {
106
+ setIsHover(false);
107
+ }
108
+ return props.type === 'close' ? /*#__PURE__*/jsx(CloseIcon, {
109
+ ...props,
110
+ color: isHover ? colors.red400 : colors.red500,
111
+ onMouseEnter: handleEnter,
112
+ onMouseLeave: handleLeave
113
+ }) : /*#__PURE__*/jsx(React__default.Fragment, {
114
+ children: customPreviewIcon ? (/*#__PURE__*/React__default.cloneElement(customPreviewIcon, {
115
+ ...customPreviewIcon.props,
116
+ ...props,
117
+ color: isHover ? colors.iconBrand : customPreviewIcon.props.color,
118
+ onMouseEnter: handleEnter,
119
+ onMouseLeave: handleLeave,
120
+ style: {
121
+ cursor: 'pointer',
122
+ background: 'rgba(39, 42, 42, 0.6)',
123
+ borderRadius: 50,
124
+ padding: '4px',
125
+ width: 32,
126
+ height: 32,
127
+ ...customPreviewIcon.props.style
128
+ }
129
+ })) : /*#__PURE__*/jsx(EyeIcon, {
130
+ ...props,
131
+ color: isHover ? colors.iconBrand : colors.gray400,
132
+ onMouseEnter: handleEnter,
133
+ onMouseLeave: handleLeave
134
+ })
135
+ });
136
+ };
137
+ const Upload = ({
138
+ listType,
139
+ multiple,
140
+ fileList,
141
+ onChange,
142
+ onBeforeCrop,
143
+ onError,
144
+ onSuccess,
145
+ onProgress,
146
+ onPreview,
147
+ onRemove,
148
+ children,
149
+ max,
150
+ replaceLabel,
151
+ width,
152
+ height,
153
+ css,
154
+ cropperTitle,
155
+ showCropper,
156
+ accept,
157
+ progress,
158
+ loading,
159
+ action,
160
+ customBodyRequest,
161
+ token,
162
+ tokenKey,
163
+ reqKey,
164
+ resKey,
165
+ ratio,
166
+ disabled,
167
+ errorMessage,
168
+ maxSizeMB,
169
+ imageCompression,
170
+ hiddenToggleAspect,
171
+ hiddenPreview,
172
+ fullAspectCrop,
173
+ isDefaultCustomRatio,
174
+ customPreviewIcon,
175
+ onPreviewIconClick,
176
+ maxWidthOrHeight,
177
+ theme,
178
+ uploadingLabel,
179
+ placeholder,
180
+ cancelLabel,
181
+ saveLabel
182
+ }) => {
183
+ const isFile = listType === 'file';
184
+ const imgRef = useRef(null);
185
+ const indexReplace = useRef(null);
186
+ const modalTrigger = useRef(null);
187
+ const hiddenFileInput = useRef(null);
188
+ const [dragActive, setDragActive] = useState(false);
189
+ const [previewImage, setPreviewImage] = useState('');
190
+ const [fileState, setFileState] = useState({});
191
+ const [error, setError] = useState(null);
192
+ const [crop, setCrop] = useState(null);
193
+ const [completedCrop, setCompletedCrop] = useState(null);
194
+ const [aspect, setAspect] = useState(isDefaultCustomRatio ? 0 : 1);
195
+ const [isLoading, setIsLoading] = useState(false);
196
+ const [cropperImgRatio, setCropperImgRatio] = useState(null);
197
+ const isMobile = useMediaQuery('(max-width: 767px)');
198
+ useEffect(() => {
199
+ if (loading) {
200
+ setIsLoading(true);
201
+ }
202
+ if (progress && progress < 1 && progress > 100) {
203
+ setIsLoading(false);
204
+ }
205
+ }, [loading, progress]);
206
+ useEffect(() => {
207
+ if (errorMessage && typeof errorMessage === 'string') {
208
+ setError(errorMessage);
209
+ }
210
+ return () => {
211
+ setError(null);
212
+ };
213
+ }, [errorMessage]);
214
+ const ContainerUpload = styled('div', {
215
+ border: '2px dashed $gray300',
216
+ borderRadius: 8,
217
+ height: height,
218
+ width: width,
219
+ cursor: 'pointer',
220
+ transition: '0.2s',
221
+ transitionDuration: '0.5s',
222
+ display: 'flex',
223
+ justifyContent: 'center',
224
+ alignItems: 'center',
225
+ '&:hover': {
226
+ border: '2px dashed $primary400',
227
+ background: '$bgSelectedLight'
228
+ },
229
+ variants: {
230
+ showError: {
231
+ true: {
232
+ border: '2px dashed $red400',
233
+ '&:hover': {
234
+ border: '2px dashed $red300',
235
+ background: '$bgFailed'
236
+ }
237
+ }
238
+ },
239
+ hidden: {
240
+ true: {
241
+ display: 'none !important'
242
+ }
243
+ },
244
+ focus: {
245
+ true: {
246
+ height: height + 16,
247
+ width: width + 16
248
+ }
249
+ },
250
+ disabled: {
251
+ true: {
252
+ border: 'none',
253
+ background: '$formDisable',
254
+ cursor: 'not-allowed',
255
+ '&:hover': {
256
+ border: 'none',
257
+ background: '$formDisable'
258
+ }
259
+ }
260
+ }
261
+ }
262
+ });
263
+ const FocusArea = styled('div', {
264
+ transition: '0.2s',
265
+ transitionDuration: '0.5s',
266
+ variants: {
267
+ focus: {
268
+ true: {
269
+ border: '2px solid $borderFocus',
270
+ padding: '$spacing-03',
271
+ borderRadius: 8
272
+ }
273
+ }
274
+ }
275
+ });
276
+ const Container = styled('div', {
277
+ height: height,
278
+ width: width,
279
+ background: '$white',
280
+ borderRadius: 8,
281
+ variants: {
282
+ error: {
283
+ true: {
284
+ border: '2px solid $red400',
285
+ '&:hover': {
286
+ border: '2px solid $red300',
287
+ background: '$bgFailed'
288
+ }
289
+ }
290
+ }
291
+ }
292
+ });
293
+ const Image = styled('img', {
294
+ borderRadius: 8,
295
+ width: width,
296
+ height: height - 36,
297
+ objectFit: 'cover',
298
+ variants: {
299
+ disabled: {
300
+ true: {
301
+ height
302
+ }
303
+ }
304
+ }
305
+ });
306
+ const Blank = styled('div', {
307
+ borderRadius: 8,
308
+ width: width,
309
+ height: height - 36,
310
+ background: '$gray50',
311
+ variants: {
312
+ disabled: {
313
+ true: {
314
+ height
315
+ }
316
+ }
317
+ }
318
+ });
319
+ function handleClick() {
320
+ if (!disabled) {
321
+ hiddenFileInput.current.click();
322
+ }
323
+ }
324
+ function toggleModal() {
325
+ modalTrigger.current.click();
326
+ }
327
+ function handleUpload(files) {
328
+ const arrFile = [...fileList];
329
+ for (let i = 0; i < files.length; i++) {
330
+ if (max && arrFile.length >= max && indexReplace.current === null) {
331
+ break;
332
+ }
333
+ let newFile = files[i];
334
+ newFile.uid = new Date().getTime();
335
+ newFile.url = URL.createObjectURL(newFile);
336
+ if (action && (newFile.size / 1024 / 1024).toFixed(1) <= maxSizeMB) {
337
+ upload({
338
+ url: action,
339
+ file: newFile,
340
+ customBody: customBodyRequest?.(newFile),
341
+ token,
342
+ tokenKey,
343
+ reqKey,
344
+ resKey,
345
+ onError,
346
+ onSuccess,
347
+ onProgress,
348
+ progress: percent => {
349
+ let fileProgress = {
350
+ ...newFile
351
+ };
352
+ let uid = fileProgress.uid;
353
+ fileProgress.status = 'uploading';
354
+ fileProgress.percent = percent;
355
+ fileProgress.name = newFile.name;
356
+ fileProgress.type = newFile.type;
357
+ fileProgress.size = newFile.size;
358
+ let arrProgress = [...arrFile];
359
+ for (let i = 0; i < arrProgress.length; i++) {
360
+ if (arrProgress[i].uid === uid) {
361
+ arrProgress[i] = fileProgress;
362
+ arrProgress[i].name = newFile.name;
363
+ arrProgress[i].type = newFile.type;
364
+ arrProgress[i].size = newFile.size;
365
+ }
366
+ }
367
+ onChange?.({
368
+ fileList: arrProgress,
369
+ file: fileProgress,
370
+ indexReplace: indexReplace.current,
371
+ isReplace: indexReplace.current !== null
372
+ })?.then(() => setError(null))?.catch(error => setError(error.message));
373
+ }
374
+ }).then(result => {
375
+ let fileSuccess = {
376
+ ...newFile
377
+ };
378
+ let uid = fileSuccess.uid;
379
+ fileSuccess.url = result;
380
+ fileSuccess.status = 'done';
381
+ fileSuccess.name = newFile.name;
382
+ fileSuccess.type = newFile.type;
383
+ fileSuccess.size = newFile.size;
384
+ for (let j = 0; j < arrFile.length; j++) {
385
+ if (arrFile[j].uid === uid) {
386
+ arrFile[j] = fileSuccess;
387
+ arrFile[j].name = newFile.name;
388
+ arrFile[j].type = newFile.type;
389
+ arrFile[j].size = newFile.size;
390
+ }
391
+ }
392
+ onChange?.({
393
+ fileList: arrFile,
394
+ file: fileSuccess,
395
+ indexReplace: indexReplace.current,
396
+ isReplace: indexReplace.current !== null
397
+ })?.then(() => setError(null))?.catch(error => setError(error.message));
398
+ }).catch(error => {
399
+ let fileError = {
400
+ ...newFile
401
+ };
402
+ let uid = fileError.uid;
403
+ fileError.status = 'error';
404
+ fileError.error = error;
405
+ fileError.name = newFile.name;
406
+ fileError.type = newFile.type;
407
+ fileError.size = newFile.size;
408
+ for (let i = 0; i < arrFile.length; i++) {
409
+ if (arrFile[i].uid === uid) {
410
+ arrFile[i] = fileError;
411
+ arrFile[i].name = newFile.name;
412
+ arrFile[i].type = newFile.type;
413
+ arrFile[i].size = newFile.size;
414
+ }
415
+ }
416
+ onChange?.({
417
+ fileList: arrFile,
418
+ file: fileError,
419
+ indexReplace: indexReplace.current,
420
+ isReplace: indexReplace.current !== null
421
+ })?.then(() => setError(null))?.catch(error => setError(error.message));
422
+ });
423
+ } else {
424
+ onChange?.({
425
+ fileList: arrFile,
426
+ file: newFile,
427
+ indexReplace: indexReplace.current,
428
+ isReplace: indexReplace.current !== null
429
+ })?.then(() => setError(null))?.catch(error => setError(error.message));
430
+ }
431
+ if (indexReplace.current !== null) {
432
+ arrFile[indexReplace.current] = newFile;
433
+ indexReplace.current = null;
434
+ } else {
435
+ arrFile.push(newFile);
436
+ }
437
+ }
438
+ }
439
+ function handleChange(e) {
440
+ if (e.target.files && e.target.files[0]) {
441
+ const files = e.target.files;
442
+ if (isFile || !showCropper) {
443
+ handleUpload(files);
444
+ } else {
445
+ // program to get the dimensions of an image
446
+ const img = document.createElement('img');
447
+ img.src = URL.createObjectURL(files[0]);
448
+ img.size = files?.[0]?.size;
449
+ img.type = files?.[0]?.type;
450
+ img.onload = () => {
451
+ const imgRatio = img.width / img.height;
452
+ // setAspect(imgRatio);
453
+ setCropperImgRatio(imgRatio);
454
+ if (onBeforeCrop) {
455
+ onBeforeCrop?.(img)?.then(() => {
456
+ setError(null);
457
+ toggleModal();
458
+ setTimeout(() => {
459
+ if (imgRef.current) {
460
+ const {
461
+ width,
462
+ height
463
+ } = imgRef.current;
464
+ setCrop(centerAspectCrop(width, height, ratio || imgRatio));
465
+ }
466
+ }, 300);
467
+ setFileState(files[0]);
468
+ setPreviewImage(URL.createObjectURL(files[0]));
469
+ })?.catch(error => setError(error?.message));
470
+ } else {
471
+ toggleModal();
472
+ setTimeout(() => {
473
+ if (imgRef.current) {
474
+ const {
475
+ width,
476
+ height
477
+ } = imgRef.current;
478
+ setCrop(centerAspectCrop(width, height, ratio || imgRatio));
479
+ }
480
+ }, 300);
481
+ setFileState(files[0]);
482
+ setPreviewImage(URL.createObjectURL(files[0]));
483
+ }
484
+ };
485
+ img.onerror = error => {
486
+ onBeforeCrop?.(img, error)?.then(() => setError(null))?.catch(error => setError(error?.message));
487
+ };
488
+ }
489
+ }
490
+ }
491
+ function handleCrop() {
492
+ if (completedCrop?.width && completedCrop?.height && imgRef.current) {
493
+ imgPreview(imgRef.current, completedCrop, 1, 0, ratio, fileState?.type).then(blob => {
494
+ const sizeMB = blob?.size / 1024 / 1024;
495
+ if (sizeMB < maxSizeMB || sizeMB < 1 || !imageCompression) {
496
+ const file = new File([blob], fileState?.name, {
497
+ type: blob?.type
498
+ });
499
+ handleUpload([file]);
500
+ setCrop(null);
501
+ setCompletedCrop(null);
502
+ } else {
503
+ imageCompressionComponent(blob, {
504
+ maxSizeMB,
505
+ maxWidthOrHeight,
506
+ maxIteration: 10,
507
+ useWebWorker: true,
508
+ alwaysKeepResolution: true
509
+ }).then(compressedFile => {
510
+ const file = new File([compressedFile], fileState?.name?.replace(/\.[^/.]+$/, '') + '.png', {
511
+ type: compressedFile?.type
512
+ });
513
+ handleUpload([file]);
514
+ setCrop(null);
515
+ setCompletedCrop(null);
516
+ }).catch(error => console.error(error?.message));
517
+ }
518
+ toggleModal();
519
+ }).catch(error => console.error(error?.message));
520
+ } else {
521
+ handleUpload([fileState]);
522
+ toggleModal();
523
+ }
524
+ }
525
+ function centerAspectCrop(mediaWidth, mediaHeight, aspect) {
526
+ return centerCrop(makeAspectCrop({
527
+ unit: '%',
528
+ width: fullAspectCrop ? 100 : 90,
529
+ height: fullAspectCrop ? 100 : 90
530
+ }, aspect, mediaWidth, mediaHeight), mediaWidth, mediaHeight);
531
+ }
532
+ function toggleAspect() {
533
+ if (aspect) {
534
+ setAspect(undefined);
535
+ } else if (imgRef.current) {
536
+ const {
537
+ width,
538
+ height
539
+ } = imgRef.current;
540
+ setAspect(ratio || cropperImgRatio);
541
+ setCrop(centerAspectCrop(width, height, ratio || cropperImgRatio));
542
+ }
543
+ }
544
+ function handleClose(file) {
545
+ const index = fileList.indexOf(file);
546
+ const newFileList = fileList.slice();
547
+ newFileList.splice(index, 1);
548
+ onChange?.({
549
+ fileList: newFileList,
550
+ file
551
+ });
552
+ }
553
+ function handleRemove(file) {
554
+ if (onRemove) {
555
+ onRemove(file);
556
+ } else {
557
+ handleClose(file);
558
+ }
559
+ if (hiddenFileInput) hiddenFileInput.current.value = null;
560
+ }
561
+ function handleReplace(index) {
562
+ indexReplace.current = index;
563
+ handleClick();
564
+ }
565
+ function handlePreview(file) {
566
+ if (onPreview) {
567
+ onPreview(file);
568
+ }
569
+ }
570
+ function handleOpenFile(file) {
571
+ let extension = String(file?.name?.split('.').pop())?.toLowerCase();
572
+ if (extension === 'pdf') {
573
+ window.open(file?.url);
574
+ } else {
575
+ if (file?.url) {
576
+ const link = document.createElement('a');
577
+ link.href = file.url;
578
+ link.setAttribute('download', file?.name);
579
+ document.body.appendChild(link);
580
+ link.click();
581
+ document.body.removeChild(link);
582
+ }
583
+ }
584
+ }
585
+ function handleDragEnter(e) {
586
+ e.preventDefault();
587
+ e.stopPropagation();
588
+ setDragActive(true);
589
+ }
590
+ function handleDragLeave(e) {
591
+ e.preventDefault();
592
+ e.stopPropagation();
593
+ setDragActive(false);
594
+ }
595
+ function handleDragOver(e) {
596
+ e.preventDefault();
597
+ e.stopPropagation();
598
+ }
599
+ function handleDrop(e) {
600
+ e.preventDefault();
601
+ e.stopPropagation();
602
+ setDragActive(false);
603
+ const {
604
+ files
605
+ } = e.dataTransfer;
606
+ if (files && files.length) {
607
+ handleChange({
608
+ target: {
609
+ files
610
+ }
611
+ });
612
+ }
613
+ }
614
+ function renderButtonReplace(index) {
615
+ return /*#__PURE__*/jsx(Flex, {
616
+ justify: "center",
617
+ align: "center",
618
+ css: {
619
+ marginTop: '$spacing-03'
620
+ },
621
+ children: /*#__PURE__*/jsx(ButtonText, {
622
+ type: "button",
623
+ onClick: () => handleReplace(index),
624
+ buttonType: "ghost",
625
+ children: replaceLabel || 'Ubah Berkas'
626
+ })
627
+ });
628
+ }
629
+ const renderPicture = () => {
630
+ return fileList?.map((item, index) => {
631
+ if (item?.status === 'uploading') {
632
+ return /*#__PURE__*/jsx(UploadProgress, {
633
+ progress: item?.percent,
634
+ loading: item?.loading
635
+ }, index);
636
+ }
637
+ return /*#__PURE__*/jsxs(Container, {
638
+ error: item.status === 'error',
639
+ children: [/*#__PURE__*/jsxs(Box, {
640
+ css: {
641
+ position: 'relative'
642
+ },
643
+ children: [!disabled && /*#__PURE__*/jsx(IconStateFull, {
644
+ type: "close",
645
+ onClick: () => handleRemove(item)
646
+ }), !hiddenPreview && /*#__PURE__*/jsx(Box, {
647
+ css: {
648
+ position: 'absolute',
649
+ top: '50%',
650
+ left: '50%',
651
+ transform: 'translate(-50%, -50%)'
652
+ },
653
+ children: /*#__PURE__*/jsx(IconStateFull, {
654
+ type: "eye",
655
+ onClick: () => {
656
+ if (onPreviewIconClick) {
657
+ onPreviewIconClick(item);
658
+ } else {
659
+ handlePreview(item);
660
+ }
661
+ },
662
+ customPreviewIcon: customPreviewIcon
663
+ })
664
+ }), /*#__PURE__*/jsx(Image, {
665
+ src: item.url,
666
+ alt: "upload-content",
667
+ disabled: disabled
668
+ })]
669
+ }), !disabled && renderButtonReplace(index)]
670
+ }, index);
671
+ });
672
+ };
673
+ const renderFile = () => {
674
+ return fileList?.map((item, index) => {
675
+ if (item?.status === 'uploading') {
676
+ return /*#__PURE__*/jsx(UploadProgress, {
677
+ progress: item?.percent,
678
+ loading: item?.loading
679
+ }, index);
680
+ }
681
+ return /*#__PURE__*/jsxs(Container, {
682
+ children: [/*#__PURE__*/jsxs(Box, {
683
+ css: {
684
+ position: 'relative'
685
+ },
686
+ children: [!disabled && /*#__PURE__*/jsx(IconStateFull, {
687
+ type: "close",
688
+ onClick: () => handleRemove(item)
689
+ }), /*#__PURE__*/jsx(Box, {
690
+ css: {
691
+ position: 'absolute',
692
+ top: '50%',
693
+ left: '50%',
694
+ transform: 'translate(-50%, -50%)'
695
+ },
696
+ children: /*#__PURE__*/jsxs(Flex, {
697
+ justify: "center",
698
+ align: "center",
699
+ direction: "column",
700
+ children: [/*#__PURE__*/jsxs(FileExtension, {
701
+ children: [".", item?.name?.split('.').pop()]
702
+ }), /*#__PURE__*/jsx(Tooltip, {
703
+ label: item.name,
704
+ children: /*#__PURE__*/jsx(Text, {
705
+ css: {
706
+ color: '$textPrimary',
707
+ textOverflow: 'ellipsis',
708
+ overflow: 'hidden',
709
+ width: 120,
710
+ whiteSpace: 'nowrap',
711
+ margin: '0 $spacing-07 0 $spacing-07'
712
+ },
713
+ children: item.name
714
+ })
715
+ })]
716
+ })
717
+ }), !hiddenPreview && /*#__PURE__*/jsx(Box, {
718
+ css: {
719
+ position: 'absolute',
720
+ top: '45%',
721
+ left: '50%',
722
+ transform: 'translate(-50%, -50%)'
723
+ },
724
+ children: /*#__PURE__*/jsx(IconStateFull, {
725
+ type: "eye",
726
+ onClick: () => {
727
+ if (onPreviewIconClick) {
728
+ onPreviewIconClick(item);
729
+ } else {
730
+ handleOpenFile(item);
731
+ }
732
+ },
733
+ customPreviewIcon: customPreviewIcon
734
+ })
735
+ }), /*#__PURE__*/jsx(Blank, {
736
+ disabled: disabled
737
+ })]
738
+ }), !disabled && renderButtonReplace(index)]
739
+ }, index);
740
+ });
741
+ };
742
+ function UploadProgress(props) {
743
+ const {
744
+ progress,
745
+ loading
746
+ } = props;
747
+ return /*#__PURE__*/jsx(ContainerUpload, {
748
+ children: /*#__PURE__*/jsxs(Flex, {
749
+ css: {
750
+ flex: 1,
751
+ padding: '$spacing-05',
752
+ marginTop: '$spacing-05'
753
+ },
754
+ gap: 2,
755
+ direction: "column",
756
+ children: [/*#__PURE__*/jsx(LoadingBar, {
757
+ css: {
758
+ '& > div': {
759
+ backgroundColor: '$chartLightYellow !important'
760
+ },
761
+ '& > div > div': {
762
+ background: '$chartYellow !important'
763
+ },
764
+ '& > p': {
765
+ color: '$textDisable',
766
+ fontSize: 12,
767
+ fontWeight: 400
768
+ }
769
+ },
770
+ description: "",
771
+ showProgressOnly: progress,
772
+ progress: progress,
773
+ isAuto: !progress,
774
+ show: loading,
775
+ onCompleted: () => setTimeout(() => setIsLoading(false), 1000)
776
+ }), /*#__PURE__*/jsx(Text, {
777
+ hidden: !progress,
778
+ children: `${progress <= 100 ? progress : 100}%`
779
+ }), /*#__PURE__*/jsx(Text, {
780
+ children: uploadingLabel || 'Berkas sedang diunggah'
781
+ })]
782
+ })
783
+ });
784
+ }
785
+ function renderUpload() {
786
+ return /*#__PURE__*/jsxs(FocusArea, {
787
+ focus: dragActive,
788
+ css: css,
789
+ children: [/*#__PURE__*/jsx(ContainerUpload, {
790
+ hidden: max ? fileList.length >= max ? true : false : false,
791
+ disabled: disabled,
792
+ showError: error !== null,
793
+ onClick: handleClick,
794
+ onDragEnter: handleDragEnter,
795
+ onDragLeave: handleDragLeave,
796
+ onDragOver: handleDragOver,
797
+ onDrop: handleDrop,
798
+ focus: dragActive,
799
+ children: /*#__PURE__*/jsx(Children, {
800
+ children: children ?? /*#__PURE__*/jsxs(React__default.Fragment, {
801
+ children: [/*#__PURE__*/jsx(IconCard, {
802
+ justify: "center",
803
+ align: "center",
804
+ children: /*#__PURE__*/jsx(UploadOutline, {
805
+ color: disabled ? colors.gray300 : colors.gray800
806
+ })
807
+ }), /*#__PURE__*/jsx(Text, {
808
+ css: {
809
+ margin: '$spacing-04 $spacing-05 0 $spacing-05'
810
+ },
811
+ children: placeholder || 'Pilih atau letakkan berkas di sini'
812
+ })]
813
+ })
814
+ })
815
+ }), error && /*#__PURE__*/jsx(ErrorMessage, {
816
+ css: {
817
+ width: width - 5
818
+ },
819
+ children: error
820
+ })]
821
+ });
822
+ }
823
+ function renderCropper() {
824
+ return /*#__PURE__*/jsxs(ModalDialog, {
825
+ onOpenChange: open => {
826
+ if (!open) {
827
+ setCrop(null);
828
+ if (hiddenFileInput) hiddenFileInput.current.value = null;
829
+ }
830
+ },
831
+ isMobile: isMobile,
832
+ theme: theme,
833
+ children: [/*#__PURE__*/jsx(ModalDialogTrigger, {
834
+ asChild: true,
835
+ children: /*#__PURE__*/jsx("div", {
836
+ ref: modalTrigger
837
+ })
838
+ }), /*#__PURE__*/jsx(ModalDialogTitle, {
839
+ css: {
840
+ textOverflow: 'ellipsis',
841
+ overflow: 'hidden',
842
+ width: 300,
843
+ whiteSpace: 'nowrap'
844
+ },
845
+ children: cropperTitle || 'Potong Gambar'
846
+ }), /*#__PURE__*/jsx(ModalDialogContent, {
847
+ css: {
848
+ padding: '$spacing-03 $spacing-07',
849
+ overflowY: 'auto',
850
+ textAlign: 'center',
851
+ maxHeight: 'calc(100vh - 200px)'
852
+ },
853
+ children: /*#__PURE__*/jsx(ReactCrop, {
854
+ crop: crop,
855
+ aspect: aspect,
856
+ onChange: c => setCrop(c),
857
+ onComplete: c => setCompletedCrop(c),
858
+ children: /*#__PURE__*/jsx(Image, {
859
+ ref: imgRef,
860
+ css: {
861
+ width: '100%',
862
+ height: '100%'
863
+ },
864
+ src: previewImage,
865
+ alt: "cropper-content"
866
+ })
867
+ })
868
+ }), /*#__PURE__*/jsx(ModalDialogFooter, {
869
+ children: /*#__PURE__*/jsxs(Flex, {
870
+ justify: "between",
871
+ align: "center",
872
+ css: {
873
+ flex: 1
874
+ },
875
+ children: [hiddenToggleAspect ? /*#__PURE__*/jsx(Box, {}) : /*#__PURE__*/jsx(Tooltip, {
876
+ label: "Default Crop Ratio",
877
+ children: /*#__PURE__*/jsx(ImageOutline, {
878
+ style: {
879
+ cursor: 'pointer'
880
+ },
881
+ color: aspect ? colors.iconBrand : colors.iconPrimary,
882
+ onClick: toggleAspect
883
+ })
884
+ }), /*#__PURE__*/jsxs(Flex, {
885
+ gap: 4,
886
+ children: [/*#__PURE__*/jsx(Button, {
887
+ buttonType: "secondary",
888
+ onClick: toggleModal,
889
+ children: cancelLabel || 'Batal'
890
+ }), /*#__PURE__*/jsx(Button, {
891
+ onClick: handleCrop,
892
+ children: saveLabel || 'Simpan'
893
+ })]
894
+ })]
895
+ })
896
+ })]
897
+ });
898
+ }
899
+ return /*#__PURE__*/jsxs(Flex, {
900
+ direction: "row",
901
+ gap: fileList?.length <= 1 && max === 1 ? 0 : 3,
902
+ wrap: "wrap",
903
+ css: {
904
+ userSelect: 'none'
905
+ },
906
+ children: [!isFile && renderPicture(), isFile && renderFile(), progress || isLoading ? /*#__PURE__*/jsx(UploadProgress, {
907
+ progress: progress,
908
+ loading: loading
909
+ }) : renderUpload(), showCropper && renderCropper(), /*#__PURE__*/jsx(Input, {
910
+ type: "file",
911
+ accept: accept,
912
+ ref: hiddenFileInput,
913
+ onChange: handleChange,
914
+ multiple: multiple
915
+ })]
916
+ });
917
+ };
918
+ Upload.defaultProps = {
919
+ listType: 'file',
920
+ fileList: [],
921
+ height: 140,
922
+ width: 140,
923
+ showCropper: true,
924
+ tokenKey: 'Token',
925
+ reqKey: 'file',
926
+ resKey: 'url',
927
+ disabled: false,
928
+ maxSizeMB: 1,
929
+ imageCompression: true,
930
+ maxWidthOrHeight: 1024
931
+ };
932
+ Upload.propTypes = {
933
+ /**
934
+ Disabled state of upload.
935
+ */
936
+ disabled: PropTypes.bool,
937
+ /**
938
+ Built-in stylesheets, support for two types.
939
+ */
940
+ listType: PropTypes.oneOf(['file', 'picture']),
941
+ /**
942
+ Whether to support selected multiple file.
943
+ */
944
+ multiple: PropTypes.bool,
945
+ /**
946
+ List of files to be uploaded.
947
+ */
948
+ fileList: PropTypes.array,
949
+ /**
950
+ A callback function, can be executed when uploading state is changing.
951
+ */
952
+ onChange: PropTypes.func,
953
+ /**
954
+ A callback function, can be executed when uploading in progress.
955
+ `(progress) => void`
956
+ */
957
+ onProgress: PropTypes.func,
958
+ /**
959
+ A callback function, can be executed when uploading is success.
960
+ `(response) => void`
961
+ */
962
+ onSuccess: PropTypes.func,
963
+ /**
964
+ A callback function, can be executed when uploading is error.
965
+ `(error, response) => void`
966
+ */
967
+ onError: PropTypes.func,
968
+ /**
969
+ A callback function, can be executed when preview icon in picture type is clicked.
970
+ */
971
+ onPreview: PropTypes.func,
972
+ /**
973
+ A callback function, can be executed when remove icon is clicked.
974
+ */
975
+ onRemove: PropTypes.func,
976
+ /**
977
+ A custom element inside upload container.
978
+ */
979
+ children: PropTypes.element,
980
+ /**
981
+ Limit the number of uploaded files.
982
+ */
983
+ max: PropTypes.number,
984
+ /**
985
+ Limit the maximum image size in MB.
986
+ */
987
+ maxSizeMB: PropTypes.number,
988
+ /**
989
+ Limit file type of upload.
990
+ */
991
+ accept: PropTypes.string,
992
+ /**
993
+ Custom label for replace button.
994
+ */
995
+ replaceLabel: PropTypes.string,
996
+ /**
997
+ Custom width of upload container.
998
+ */
999
+ width: PropTypes.number,
1000
+ /**
1001
+ Custom height of upload container.
1002
+ */
1003
+ height: PropTypes.number,
1004
+ /**
1005
+ Additional css.
1006
+ */
1007
+ css: PropTypes.object,
1008
+ /**
1009
+ Custom title header of cropper modal.
1010
+ */
1011
+ cropperTitle: PropTypes.string,
1012
+ /**
1013
+ Add image cropper on upload.
1014
+ */
1015
+ showCropper: PropTypes.bool,
1016
+ /**
1017
+ Hidden toggle aspect ratio image cropper.
1018
+ */
1019
+ hiddenToggleAspect: PropTypes.bool,
1020
+ /**
1021
+ The aspect ratio of the crop, e.g. `1` for a square or `16 / 9` for landscape. Omit/pass undefined for a free-form crop.
1022
+ */
1023
+ ratio: PropTypes.number,
1024
+ /**
1025
+ Can set error message to the upload.
1026
+ */
1027
+ errorMessage: PropTypes.string,
1028
+ /**
1029
+ Progress of upload process.
1030
+ */
1031
+ progress: PropTypes.number,
1032
+ /**
1033
+ Auto increment progress of upload process.
1034
+ */
1035
+ loading: PropTypes.bool,
1036
+ /**
1037
+ API upload url, allows components to automatically upload directly to API service.
1038
+ */
1039
+ action: PropTypes.string,
1040
+ /**
1041
+ Custom body request to upload action.
1042
+ */
1043
+ customBodyRequest: PropTypes.func,
1044
+ /**
1045
+ Contains an authentication token for upload API.
1046
+ */
1047
+ token: PropTypes.string,
1048
+ /**
1049
+ Referencing the headers key to attach the token.
1050
+ */
1051
+ tokenKey: PropTypes.string,
1052
+ /**
1053
+ Referencing the key to attach the file to be sent.
1054
+ */
1055
+ reqKey: PropTypes.string,
1056
+ /**
1057
+ Referencing the key to get the file from the API response.
1058
+ */
1059
+ resKey: PropTypes.string,
1060
+ /**
1061
+ To compression image if file size > 1MB.
1062
+ */
1063
+ imageCompression: PropTypes.bool,
1064
+ /**
1065
+ Callback to handle before crop image.
1066
+ */
1067
+ onBeforeCrop: PropTypes.func,
1068
+ /**
1069
+ Hidden preview icon in upload.
1070
+ */
1071
+ hiddenPreview: PropTypes.bool,
1072
+ /**
1073
+ Auto full aspect ratio cropper.
1074
+ */
1075
+ fullAspectCrop: PropTypes.bool,
1076
+ /**
1077
+ Set custom ratio as Default view
1078
+ */
1079
+ isDefaultCustomRatio: PropTypes.bool,
1080
+ /**
1081
+ Set max width or height of image
1082
+ */
1083
+ maxWidthOrHeight: PropTypes.number,
1084
+ /**
1085
+ Label for the uploading state text.
1086
+ */
1087
+ uploadingLabel: PropTypes.string,
1088
+ /**
1089
+ Label for the upload area placeholder.
1090
+ */
1091
+ placeholder: PropTypes.string,
1092
+ /**
1093
+ Label for the cancel button in the cropper dialog.
1094
+ */
1095
+ cancelLabel: PropTypes.string,
1096
+ /**
1097
+ Label for the save button in the cropper dialog.
1098
+ */
1099
+ saveLabel: PropTypes.string
1100
+ };
1101
+ Upload.displayName = 'Upload';
1102
+
1103
+ export { Upload as default };