@razorpay/blade 11.6.0 → 11.6.2

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 (52) hide show
  1. package/build/lib/native/components/FileUpload/FileUpload.native.js +7 -0
  2. package/build/lib/native/components/FileUpload/FileUpload.native.js.map +1 -0
  3. package/build/lib/native/components/index.js +1 -0
  4. package/build/lib/native/components/index.js.map +1 -1
  5. package/build/lib/web/development/components/FileUpload/FileUpload.web.js +434 -0
  6. package/build/lib/web/development/components/FileUpload/FileUpload.web.js.map +1 -0
  7. package/build/lib/web/development/components/FileUpload/FileUploadItem.js +149 -0
  8. package/build/lib/web/development/components/FileUpload/FileUploadItem.js.map +1 -0
  9. package/build/lib/web/development/components/FileUpload/FileUploadItemIcon.js +122 -0
  10. package/build/lib/web/development/components/FileUpload/FileUploadItemIcon.js.map +1 -0
  11. package/build/lib/web/development/components/FileUpload/StyledFileUploadItemWrapper.js +47 -0
  12. package/build/lib/web/development/components/FileUpload/StyledFileUploadItemWrapper.js.map +1 -0
  13. package/build/lib/web/development/components/FileUpload/StyledFileUploadWrapper.js +45 -0
  14. package/build/lib/web/development/components/FileUpload/StyledFileUploadWrapper.js.map +1 -0
  15. package/build/lib/web/development/components/FileUpload/fileUploadTokens.js +66 -0
  16. package/build/lib/web/development/components/FileUpload/fileUploadTokens.js.map +1 -0
  17. package/build/lib/web/development/components/FileUpload/index.js +2 -0
  18. package/build/lib/web/development/components/FileUpload/index.js.map +1 -0
  19. package/build/lib/web/development/components/FileUpload/isFileAccepted.js +28 -0
  20. package/build/lib/web/development/components/FileUpload/isFileAccepted.js.map +1 -0
  21. package/build/lib/web/development/components/index.js +2 -0
  22. package/build/lib/web/development/components/index.js.map +1 -1
  23. package/build/lib/web/development/tokens/global/fontFamily/fontFamily.web.js +3 -2
  24. package/build/lib/web/development/tokens/global/fontFamily/fontFamily.web.js.map +1 -1
  25. package/build/lib/web/production/components/FileUpload/FileUpload.web.js +434 -0
  26. package/build/lib/web/production/components/FileUpload/FileUpload.web.js.map +1 -0
  27. package/build/lib/web/production/components/FileUpload/FileUploadItem.js +149 -0
  28. package/build/lib/web/production/components/FileUpload/FileUploadItem.js.map +1 -0
  29. package/build/lib/web/production/components/FileUpload/FileUploadItemIcon.js +122 -0
  30. package/build/lib/web/production/components/FileUpload/FileUploadItemIcon.js.map +1 -0
  31. package/build/lib/web/production/components/FileUpload/StyledFileUploadItemWrapper.js +47 -0
  32. package/build/lib/web/production/components/FileUpload/StyledFileUploadItemWrapper.js.map +1 -0
  33. package/build/lib/web/production/components/FileUpload/StyledFileUploadWrapper.js +45 -0
  34. package/build/lib/web/production/components/FileUpload/StyledFileUploadWrapper.js.map +1 -0
  35. package/build/lib/web/production/components/FileUpload/fileUploadTokens.js +66 -0
  36. package/build/lib/web/production/components/FileUpload/fileUploadTokens.js.map +1 -0
  37. package/build/lib/web/production/components/FileUpload/index.js +2 -0
  38. package/build/lib/web/production/components/FileUpload/index.js.map +1 -0
  39. package/build/lib/web/production/components/FileUpload/isFileAccepted.js +28 -0
  40. package/build/lib/web/production/components/FileUpload/isFileAccepted.js.map +1 -0
  41. package/build/lib/web/production/components/index.js +2 -0
  42. package/build/lib/web/production/components/index.js.map +1 -1
  43. package/build/lib/web/production/tokens/global/fontFamily/fontFamily.web.js +3 -2
  44. package/build/lib/web/production/tokens/global/fontFamily/fontFamily.web.js.map +1 -1
  45. package/build/types/components/index.d.ts +190 -1
  46. package/build/types/components/index.native.d.ts +140 -1
  47. package/codemods/brand-refresh/transformers/__tests__/migrate-colors.test.ts +11 -1
  48. package/codemods/brand-refresh/transformers/__tests__/migrate-typography.test.ts +5 -1
  49. package/codemods/brand-refresh/transformers/index.ts +3 -1
  50. package/codemods/brand-refresh/transformers/migrate-typography.ts +22 -0
  51. package/fonts.css +19 -0
  52. package/package.json +3 -3
@@ -0,0 +1,434 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import { useState, useMemo, useCallback, forwardRef } from 'react';
6
+ import { StyledFileUploadWrapper } from './StyledFileUploadWrapper.js';
7
+ import { fileUploadColorTokens, getFileUploadInputHoverTokens, fileUploadLinkBorderTokens } from './fileUploadTokens.js';
8
+ import { FileUploadItem } from './FileUploadItem.js';
9
+ import { isFileAccepted } from './isFileAccepted.js';
10
+ import '../Box/BaseBox/index.js';
11
+ import '../Box/index.js';
12
+ import { SelectorLabel } from '../Form/Selector/SelectorLabel.web.js';
13
+ import { SelectorInput } from '../Form/Selector/SelectorInput.web.js';
14
+ import '../VisuallyHidden/index.web.js';
15
+ import '../Form/index.js';
16
+ import { useFormId } from '../Form/useFormId.js';
17
+ import '../../utils/assignWithoutSideEffects/index.js';
18
+ import '../../utils/metaAttribute/index.js';
19
+ import '../Box/styledProps/index.js';
20
+ import '../../utils/index.js';
21
+ import '../Typography/index.js';
22
+ import { getHintType } from '../Input/BaseInput/BaseInput.js';
23
+ import '../../utils/makeAccessible/index.js';
24
+ import { jsxs, jsx } from 'react/jsx-runtime';
25
+ import useTheme from '../BladeProvider/useTheme.js';
26
+ import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.web.js';
27
+ import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
28
+ import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
29
+ import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
30
+ import { getStyledProps } from '../Box/styledProps/getStyledProps.js';
31
+ import { FormLabel } from '../Form/FormLabel.js';
32
+ import { screenReaderStyles } from '../VisuallyHidden/ScreenReaderStyles.js';
33
+ import { Box } from '../Box/Box.js';
34
+ import { makeSize } from '../../utils/makeSize/makeSize.js';
35
+ import { Text } from '../Typography/Text/Text.js';
36
+ import { FormHint } from '../Form/FormHint.js';
37
+ import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
38
+
39
+ var _excluded = ["name", "accept", "uploadType", "onChange", "onPreview", "onRemove", "onDismiss", "onDrop", "isDisabled", "isRequired", "necessityIndicator", "fileList", "testID", "label", "labelPosition", "accessibilityLabel", "validationState", "helpText", "errorText", "maxCount", "maxSize"];
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
42
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
43
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
44
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
45
+ var _FileUpload = function _FileUpload(_ref, ref) {
46
+ var name = _ref.name,
47
+ accept = _ref.accept,
48
+ _ref$uploadType = _ref.uploadType,
49
+ uploadType = _ref$uploadType === void 0 ? 'single' : _ref$uploadType,
50
+ onChange = _ref.onChange,
51
+ onPreview = _ref.onPreview,
52
+ _onRemove = _ref.onRemove,
53
+ _onDismiss = _ref.onDismiss,
54
+ onDrop = _ref.onDrop,
55
+ isDisabled = _ref.isDisabled,
56
+ isRequired = _ref.isRequired,
57
+ necessityIndicator = _ref.necessityIndicator,
58
+ fileList = _ref.fileList,
59
+ testID = _ref.testID,
60
+ label = _ref.label,
61
+ _ref$labelPosition = _ref.labelPosition,
62
+ labelPosition = _ref$labelPosition === void 0 ? 'top' : _ref$labelPosition,
63
+ accessibilityLabel = _ref.accessibilityLabel,
64
+ validationState = _ref.validationState,
65
+ helpText = _ref.helpText,
66
+ errorText = _ref.errorText,
67
+ maxCount = _ref.maxCount,
68
+ maxSize = _ref.maxSize,
69
+ styledProps = _objectWithoutProperties(_ref, _excluded);
70
+ var _useTheme = useTheme(),
71
+ platform = _useTheme.platform;
72
+ var _useState = useState(fileList !== null && fileList !== void 0 ? fileList : []),
73
+ _useState2 = _slicedToArray(_useState, 2),
74
+ selectedFiles = _useState2[0],
75
+ setSelectedFiles = _useState2[1];
76
+ var _useState3 = useState(errorText),
77
+ _useState4 = _slicedToArray(_useState3, 2),
78
+ errorMessage = _useState4[0],
79
+ setErrorMessage = _useState4[1];
80
+ console.log('🚀 ~ errorMessage:', errorMessage);
81
+ var _useState5 = useState('none'),
82
+ _useState6 = _slicedToArray(_useState5, 2),
83
+ internalValidationState = _useState6[0],
84
+ setInternalValidationState = _useState6[1];
85
+ var _useState7 = useState(false),
86
+ _useState8 = _slicedToArray(_useState7, 2),
87
+ isActive = _useState8[0],
88
+ setIsActive = _useState8[1];
89
+ var isMultiple = uploadType === 'multiple';
90
+ var isOneFileSelectedWithSingleUpload = !isMultiple && selectedFiles.length === 1;
91
+ var inputLabelPosition = platform === 'onMobile' ? 'top' : labelPosition;
92
+ var isLabelLeftPositioned = inputLabelPosition === 'left';
93
+ var willRenderHintText = Boolean(helpText) || Boolean(errorMessage);
94
+ var showError = validationState === 'error' || internalValidationState === 'error';
95
+ var showHelpText = !showError && helpText;
96
+ var accessibilityText = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : ",".concat(showError ? errorText : '', " ").concat(showHelpText ? helpText : '');
97
+ var _useFormId = useFormId('fileuploadinput'),
98
+ inputId = _useFormId.inputId,
99
+ labelId = _useFormId.labelId,
100
+ helpTextId = _useFormId.helpTextId,
101
+ errorTextId = _useFormId.errorTextId;
102
+ var accessibilityProps = makeAccessible({
103
+ required: Boolean(isRequired),
104
+ invalid: Boolean(showError),
105
+ disabled: Boolean(isDisabled),
106
+ describedBy: labelId
107
+ });
108
+
109
+ // In control mode attach a unique id to each file if not provided
110
+ useMemo(function () {
111
+ var _iterator = _createForOfIteratorHelper(selectedFiles),
112
+ _step;
113
+ try {
114
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
115
+ var file = _step.value;
116
+ if (!file.id) {
117
+ file.id = "".concat(new Date().getTime().toString()).concat(Math.floor(Math.random() * 1000000));
118
+ }
119
+ }
120
+ } catch (err) {
121
+ _iterator.e(err);
122
+ } finally {
123
+ _iterator.f();
124
+ }
125
+ }, [selectedFiles]);
126
+ var handleFilesChange = useCallback(function (inputFiles) {
127
+ setSelectedFiles(function (prevFiles) {
128
+ if (prevFiles.length > 0) {
129
+ var allFiles = [].concat(_toConsumableArray(prevFiles), _toConsumableArray(inputFiles));
130
+ return allFiles;
131
+ }
132
+ return inputFiles;
133
+ });
134
+ }, []);
135
+ var validateFiles = function validateFiles(inputFiles, allFiles) {
136
+ if (accept && inputFiles.some(function (file) {
137
+ return !isFileAccepted(file, accept);
138
+ })) {
139
+ setErrorMessage("You provided an unsupported file type. Supported file types are: ".concat(accept));
140
+ setInternalValidationState('error');
141
+ return true;
142
+ }
143
+ if (uploadType === 'single' && inputFiles.length > 1) {
144
+ setErrorMessage('You can upload only one file.');
145
+ setInternalValidationState('error');
146
+ return true;
147
+ }
148
+ if (maxCount && allFiles.length > maxCount) {
149
+ setErrorMessage("You can't upload more than ".concat(maxCount, " files."));
150
+ setInternalValidationState('error');
151
+ return true;
152
+ }
153
+ if (maxSize && inputFiles.some(function (file) {
154
+ return file.size > maxSize;
155
+ })) {
156
+ setErrorMessage('File size exceeded.');
157
+ setInternalValidationState('error');
158
+ return true;
159
+ }
160
+ setInternalValidationState('none');
161
+ setErrorMessage('');
162
+ return false;
163
+ };
164
+ var handleDragOver = function handleDragOver(event) {
165
+ event.preventDefault();
166
+ setIsActive(true);
167
+ };
168
+ var handleDragLeave = function handleDragLeave(event) {
169
+ event.preventDefault();
170
+ setIsActive(false);
171
+ };
172
+ var handleDrop = function handleDrop(event) {
173
+ event.preventDefault();
174
+ setIsActive(false);
175
+ var droppedFiles = Array.from(event.dataTransfer.files);
176
+ var allFiles = selectedFiles.length > 0 ? [].concat(_toConsumableArray(selectedFiles), droppedFiles) : droppedFiles;
177
+ var hasValidationErrors = validateFiles(droppedFiles, allFiles);
178
+ if (!hasValidationErrors) {
179
+ handleFilesChange(droppedFiles);
180
+ onDrop === null || onDrop === void 0 ? void 0 : onDrop({
181
+ name: name,
182
+ fileList: allFiles
183
+ });
184
+ }
185
+ };
186
+ var handleInputChange = function handleInputChange(event) {
187
+ var _event$target$files;
188
+ var inputFiles = Array.from((_event$target$files = event.target.files) !== null && _event$target$files !== void 0 ? _event$target$files : []);
189
+ var allFiles = selectedFiles.length > 0 ? [].concat(_toConsumableArray(selectedFiles), inputFiles) : inputFiles;
190
+ var hasValidationErrors = validateFiles(inputFiles, allFiles);
191
+ if (!hasValidationErrors) {
192
+ handleFilesChange(inputFiles);
193
+ onChange === null || onChange === void 0 ? void 0 : onChange({
194
+ name: name,
195
+ fileList: allFiles
196
+ });
197
+ }
198
+ };
199
+ return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
200
+ display: "flex",
201
+ flexDirection: "column",
202
+ width: "100%"
203
+ }, metaAttribute({
204
+ name: MetaConstants.FileUpload,
205
+ testID: testID
206
+ })), getStyledProps(styledProps)), {}, {
207
+ children: [/*#__PURE__*/jsxs(BaseBox, {
208
+ display: "flex",
209
+ flexDirection: isLabelLeftPositioned ? 'row' : 'column',
210
+ alignItems: isLabelLeftPositioned ? 'center' : undefined,
211
+ position: "relative",
212
+ width: "100%",
213
+ children: [label ? /*#__PURE__*/jsx(FormLabel, {
214
+ as: "span",
215
+ necessityIndicator: necessityIndicator,
216
+ position: labelPosition,
217
+ id: labelId,
218
+ accessibilityText: accessibilityText,
219
+ children: label
220
+ }) : null, /*#__PURE__*/jsx(SelectorLabel, {
221
+ componentName: MetaConstants.FileUploadLabel,
222
+ inputProps: {},
223
+ style: {
224
+ cursor: isDisabled ? 'not-allowed' : 'pointer'
225
+ },
226
+ children: /*#__PURE__*/jsx(BaseBox, {
227
+ display: "flex",
228
+ flexDirection: "column",
229
+ width: "100%",
230
+ marginBottom: willRenderHintText ? 'spacing.0' : 'spacing.5',
231
+ children: /*#__PURE__*/jsx(StyledFileUploadWrapper, {
232
+ isDisabled: isDisabled,
233
+ isActive: isActive,
234
+ display: "flex",
235
+ flexDirection: "row",
236
+ justifyContent: "center",
237
+ alignItems: "center",
238
+ borderRadius: "medium",
239
+ borderWidth: "thin",
240
+ onDragOver: handleDragOver,
241
+ onDragLeave: handleDragLeave,
242
+ onDrop: handleDrop,
243
+ onClick: function onClick() {
244
+ return setIsActive(true);
245
+ },
246
+ "data-comp": "f",
247
+ style: _objectSpread({}, isOneFileSelectedWithSingleUpload ? screenReaderStyles : {}),
248
+ children: /*#__PURE__*/jsxs(Box, {
249
+ display: "flex",
250
+ justifyContent: "center",
251
+ alignItems: "center",
252
+ flexDirection: {
253
+ base: 'column',
254
+ s: 'row'
255
+ },
256
+ gap: makeSize(6),
257
+ padding: "spacing.3",
258
+ children: [/*#__PURE__*/jsxs(Text, {
259
+ color: isDisabled ? fileUploadColorTokens.text.disabled : fileUploadColorTokens.text["default"],
260
+ children: ["Drag files here or", ' ']
261
+ }), /*#__PURE__*/jsx(SelectorInput, {
262
+ id: inputId,
263
+ hoverTokens: getFileUploadInputHoverTokens(),
264
+ isChecked: false,
265
+ isDisabled: isDisabled,
266
+ inputProps: _objectSpread({
267
+ name: name,
268
+ type: 'file',
269
+ onChange: handleInputChange,
270
+ multiple: isMultiple,
271
+ required: isRequired,
272
+ disabled: isDisabled,
273
+ accept: accept,
274
+ onBlur: function onBlur() {
275
+ return setIsActive(false);
276
+ }
277
+ }, accessibilityProps),
278
+ ref: ref
279
+ }), /*#__PURE__*/jsx(Box, {
280
+ display: "flex",
281
+ justifyContent: "center",
282
+ alignItems: "center",
283
+ flexDirection: {
284
+ base: 'column',
285
+ s: 'row'
286
+ },
287
+ borderRadius: "small",
288
+ children: /*#__PURE__*/jsx(Box, {
289
+ display: "flex",
290
+ flexDirection: "row",
291
+ alignItems: "center",
292
+ borderBottomColor: fileUploadLinkBorderTokens.color[isDisabled ? 'disabled' : 'default'],
293
+ borderBottomWidth: fileUploadLinkBorderTokens.width["default"],
294
+ children: /*#__PURE__*/jsx(Text, {
295
+ color: isDisabled ? fileUploadColorTokens.link.disabled : fileUploadColorTokens.link["default"],
296
+ children: "Upload"
297
+ })
298
+ })
299
+ })]
300
+ })
301
+ })
302
+ })
303
+ }), isOneFileSelectedWithSingleUpload && /*#__PURE__*/jsx(FileUploadItem, {
304
+ file: selectedFiles[0],
305
+ onRemove: function onRemove() {
306
+ var newFiles = selectedFiles.filter(function (_ref2) {
307
+ var id = _ref2.id;
308
+ return id !== selectedFiles[0].id;
309
+ });
310
+ setSelectedFiles(newFiles);
311
+ _onRemove === null || _onRemove === void 0 ? void 0 : _onRemove({
312
+ file: selectedFiles[0]
313
+ });
314
+ },
315
+ onDismiss: function onDismiss() {
316
+ var newFiles = selectedFiles.filter(function (_ref3) {
317
+ var id = _ref3.id;
318
+ return id !== selectedFiles[0].id;
319
+ });
320
+ setSelectedFiles(newFiles);
321
+ _onDismiss === null || _onDismiss === void 0 ? void 0 : _onDismiss({
322
+ file: selectedFiles[0]
323
+ });
324
+ },
325
+ onPreview: onPreview
326
+ })]
327
+ }), willRenderHintText && /*#__PURE__*/jsx(BaseBox, {
328
+ marginLeft: makeSize(label && isLabelLeftPositioned ? 136 : 0),
329
+ marginBottom: "spacing.5",
330
+ children: /*#__PURE__*/jsx(BaseBox, {
331
+ display: "flex",
332
+ flexDirection: "row",
333
+ justifyContent: "'space-between",
334
+ children: /*#__PURE__*/jsx(FormHint, {
335
+ type: getHintType({
336
+ validationState: showError ? 'error' : validationState,
337
+ hasHelpText: Boolean(helpText)
338
+ }),
339
+ helpText: helpText,
340
+ errorText: errorMessage,
341
+ helpTextId: helpTextId,
342
+ errorTextId: errorTextId
343
+ })
344
+ })
345
+ }), !isOneFileSelectedWithSingleUpload && selectedFiles.map(function (file) {
346
+ return /*#__PURE__*/jsx(BaseBox, {
347
+ marginLeft: makeSize(label && isLabelLeftPositioned ? 136 : 0),
348
+ marginBottom: "spacing.3",
349
+ children: /*#__PURE__*/jsx(FileUploadItem, {
350
+ file: file,
351
+ onRemove: function onRemove() {
352
+ var newFiles = selectedFiles.filter(function (_ref4) {
353
+ var id = _ref4.id;
354
+ return id !== file.id;
355
+ });
356
+ setSelectedFiles(newFiles);
357
+ _onRemove === null || _onRemove === void 0 ? void 0 : _onRemove({
358
+ file: file
359
+ });
360
+ },
361
+ onDismiss: function onDismiss() {
362
+ var newFiles = selectedFiles.filter(function (_ref5) {
363
+ var id = _ref5.id;
364
+ return id !== file.id;
365
+ });
366
+ setSelectedFiles(newFiles);
367
+ _onDismiss === null || _onDismiss === void 0 ? void 0 : _onDismiss({
368
+ file: file
369
+ });
370
+ },
371
+ onPreview: onPreview
372
+ })
373
+ }, file.id);
374
+ })]
375
+ }));
376
+ };
377
+
378
+ /**
379
+ * ### FileUpload Component
380
+ *
381
+ * The FileUpload component is used to handle file attachments, including the drag-and-drop interaction.
382
+ * Primarily, it is used to upload files to a server or to display a list of uploaded files.
383
+ *
384
+ * ---
385
+ *
386
+ * #### Usage
387
+ *
388
+ * ```jsx
389
+ const GSTForm = () => {
390
+ const [selectedFile, setSelectedFile] = useState<BladeFile>();
391
+ const [isLoading, setIsLoading] = useState(false);
392
+
393
+ return (
394
+ <Box>
395
+ <Heading marginBottom="spacing.4">Add GST Details</Heading>
396
+ <form encType="multipart/form-data" onSubmit={handleSubmit}>
397
+ <FileUpload
398
+ uploadType="single"
399
+ label="Upload GST"
400
+ helpText="Upload .jpg, .jpeg, or .png file only"
401
+ accept=".jpg, .jpeg, .png"
402
+ onChange={({ fileList }) => {
403
+ setSelectedFile(fileList[0]);
404
+ }}
405
+ onDrop={({ fileList }) => {
406
+ setSelectedFile(fileList[0]);
407
+ }}
408
+ isRequired
409
+ necessityIndicator="required"
410
+ />
411
+ <Button type="submit" variant="primary">
412
+ Submit
413
+ </Button>
414
+ {isLoading && (
415
+ <ProgressBar isIndeterminate label="Uploading your GST Certificate..." />
416
+ )}
417
+ </form>
418
+ </Box>
419
+ );
420
+ }
421
+ * ```
422
+ *
423
+ * ---
424
+ *
425
+ * Checkout {@link https://blade.razorpay.com/?path=/docs/components-fileupload FileUpload Documentation}
426
+ *
427
+ */
428
+ var FileUpload = /*#__PURE__*/assignWithoutSideEffects( /*#__PURE__*/forwardRef(_FileUpload), {
429
+ displayName: 'FileUpload',
430
+ componentId: 'FileUpload'
431
+ });
432
+
433
+ export { FileUpload };
434
+ //# sourceMappingURL=FileUpload.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUpload.web.js","sources":["../../../../../../src/components/FileUpload/FileUpload.web.tsx"],"sourcesContent":["import { useState, useCallback, useMemo, forwardRef } from 'react';\nimport type { FileUploadProps, BladeFile, BladeFileList } from './types';\nimport { StyledFileUploadWrapper } from './StyledFileUploadWrapper';\nimport {\n fileUploadColorTokens,\n fileUploadLinkBorderTokens,\n getFileUploadInputHoverTokens,\n} from './fileUploadTokens';\nimport { FileUploadItem } from './FileUploadItem';\nimport { isFileAccepted } from './isFileAccepted';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Box } from '~components/Box';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { screenReaderStyles } from '~components/VisuallyHidden';\nimport { FormHint, FormLabel } from '~components/Form';\nimport { useFormId } from '~components/Form/useFormId';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport { makeSize, useTheme } from '~utils';\nimport { Text } from '~components/Typography';\nimport type { BladeElementRef } from '~utils/types';\nimport { getHintType } from '~components/Input/BaseInput/BaseInput';\nimport { makeAccessible } from '~utils/makeAccessible';\n\nconst _FileUpload: React.ForwardRefRenderFunction<BladeElementRef, FileUploadProps> = (\n {\n name,\n accept,\n uploadType = 'single',\n onChange,\n onPreview,\n onRemove,\n onDismiss,\n onDrop,\n isDisabled,\n isRequired,\n necessityIndicator,\n fileList,\n testID,\n label,\n labelPosition = 'top',\n accessibilityLabel,\n validationState,\n helpText,\n errorText,\n maxCount,\n maxSize,\n ...styledProps\n },\n ref,\n): React.ReactElement => {\n const { platform } = useTheme();\n const [selectedFiles, setSelectedFiles] = useState<BladeFileList>(fileList ?? []);\n const [errorMessage, setErrorMessage] = useState(errorText);\n console.log('🚀 ~ errorMessage:', errorMessage);\n const [internalValidationState, setInternalValidationState] = useState('none');\n const [isActive, setIsActive] = useState(false);\n\n const isMultiple = uploadType === 'multiple';\n const isOneFileSelectedWithSingleUpload = !isMultiple && selectedFiles.length === 1;\n const inputLabelPosition = platform === 'onMobile' ? 'top' : labelPosition;\n const isLabelLeftPositioned = inputLabelPosition === 'left';\n const willRenderHintText = Boolean(helpText) || Boolean(errorMessage);\n\n const showError = validationState === 'error' || internalValidationState === 'error';\n const showHelpText = !showError && helpText;\n const accessibilityText =\n accessibilityLabel ?? `,${showError ? errorText : ''} ${showHelpText ? helpText : ''}`;\n const { inputId, labelId, helpTextId, errorTextId } = useFormId('fileuploadinput');\n\n const accessibilityProps = makeAccessible({\n required: Boolean(isRequired),\n invalid: Boolean(showError),\n disabled: Boolean(isDisabled),\n describedBy: labelId,\n });\n\n // In control mode attach a unique id to each file if not provided\n useMemo(() => {\n for (const file of selectedFiles) {\n if (!file.id) {\n file.id = `${new Date().getTime().toString()}${Math.floor(Math.random() * 1000000)}`;\n }\n }\n }, [selectedFiles]);\n\n const handleFilesChange = useCallback((inputFiles: BladeFileList) => {\n setSelectedFiles((prevFiles) => {\n if (prevFiles.length > 0) {\n const allFiles = [...prevFiles, ...inputFiles];\n return allFiles;\n }\n\n return inputFiles;\n });\n }, []);\n\n const validateFiles = (inputFiles: BladeFileList, allFiles: BladeFileList): boolean => {\n if (accept && inputFiles.some((file) => !isFileAccepted(file, accept))) {\n setErrorMessage(`You provided an unsupported file type. Supported file types are: ${accept}`);\n setInternalValidationState('error');\n return true;\n }\n\n if (uploadType === 'single' && inputFiles.length > 1) {\n setErrorMessage('You can upload only one file.');\n setInternalValidationState('error');\n return true;\n }\n\n if (maxCount && allFiles.length > maxCount) {\n setErrorMessage(`You can't upload more than ${maxCount} files.`);\n setInternalValidationState('error');\n return true;\n }\n\n if (maxSize && inputFiles.some((file) => file.size > maxSize)) {\n setErrorMessage('File size exceeded.');\n setInternalValidationState('error');\n return true;\n }\n\n setInternalValidationState('none');\n setErrorMessage('');\n return false;\n };\n\n const handleDragOver = (event: React.DragEvent): void => {\n event.preventDefault();\n setIsActive(true);\n };\n\n const handleDragLeave = (event: React.DragEvent): void => {\n event.preventDefault();\n setIsActive(false);\n };\n\n const handleDrop = (event: React.DragEvent): void => {\n event.preventDefault();\n setIsActive(false);\n\n const droppedFiles = Array.from(event.dataTransfer.files);\n const allFiles = selectedFiles.length > 0 ? [...selectedFiles, ...droppedFiles] : droppedFiles;\n\n const hasValidationErrors = validateFiles(droppedFiles, allFiles);\n\n if (!hasValidationErrors) {\n handleFilesChange(droppedFiles);\n onDrop?.({ name, fileList: allFiles });\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n const inputFiles = Array.from(event.target.files ?? []);\n const allFiles = selectedFiles.length > 0 ? [...selectedFiles, ...inputFiles] : inputFiles;\n\n const hasValidationErrors = validateFiles(inputFiles, allFiles);\n\n if (!hasValidationErrors) {\n handleFilesChange(inputFiles);\n onChange?.({ name, fileList: allFiles });\n }\n };\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection=\"column\"\n width=\"100%\"\n {...metaAttribute({ name: MetaConstants.FileUpload, testID })}\n {...getStyledProps(styledProps)}\n >\n <BaseBox\n display=\"flex\"\n flexDirection={isLabelLeftPositioned ? 'row' : 'column'}\n alignItems={isLabelLeftPositioned ? 'center' : undefined}\n position=\"relative\"\n width=\"100%\"\n >\n {label ? (\n <FormLabel\n as=\"span\"\n necessityIndicator={necessityIndicator}\n position={labelPosition}\n id={labelId}\n accessibilityText={accessibilityText}\n >\n {label}\n </FormLabel>\n ) : null}\n\n <SelectorLabel\n componentName={MetaConstants.FileUploadLabel}\n inputProps={{}}\n style={{\n cursor: isDisabled ? 'not-allowed' : 'pointer',\n }}\n >\n <BaseBox\n display=\"flex\"\n flexDirection=\"column\"\n width=\"100%\"\n marginBottom={willRenderHintText ? 'spacing.0' : 'spacing.5'}\n >\n <StyledFileUploadWrapper\n isDisabled={isDisabled}\n isActive={isActive}\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent=\"center\"\n alignItems=\"center\"\n borderRadius=\"medium\"\n borderWidth=\"thin\"\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}\n onClick={() => setIsActive(true)}\n data-comp=\"f\"\n style={{\n ...(isOneFileSelectedWithSingleUpload ? screenReaderStyles : {}),\n }}\n >\n <Box\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n flexDirection={{ base: 'column', s: 'row' }}\n gap={makeSize(6)}\n padding=\"spacing.3\"\n >\n <Text\n color={\n isDisabled\n ? fileUploadColorTokens.text.disabled\n : fileUploadColorTokens.text.default\n }\n >\n Drag files here or{' '}\n </Text>\n <SelectorInput\n id={inputId}\n hoverTokens={getFileUploadInputHoverTokens()}\n isChecked={false}\n isDisabled={isDisabled}\n inputProps={{\n name,\n type: 'file',\n onChange: handleInputChange,\n multiple: isMultiple,\n required: isRequired,\n disabled: isDisabled,\n accept,\n onBlur: () => setIsActive(false),\n ...accessibilityProps,\n }}\n ref={ref}\n />\n\n <Box\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n flexDirection={{ base: 'column', s: 'row' }}\n borderRadius=\"small\"\n >\n <Box\n display=\"flex\"\n flexDirection=\"row\"\n alignItems=\"center\"\n borderBottomColor={\n fileUploadLinkBorderTokens.color[isDisabled ? 'disabled' : 'default']\n }\n borderBottomWidth={fileUploadLinkBorderTokens.width.default}\n >\n <Text\n color={\n isDisabled\n ? fileUploadColorTokens.link.disabled\n : fileUploadColorTokens.link.default\n }\n >\n Upload\n </Text>\n </Box>\n </Box>\n </Box>\n </StyledFileUploadWrapper>\n </BaseBox>\n </SelectorLabel>\n {isOneFileSelectedWithSingleUpload && (\n <FileUploadItem\n file={selectedFiles[0]}\n onRemove={() => {\n const newFiles = selectedFiles.filter(({ id }) => id !== selectedFiles[0].id);\n setSelectedFiles(newFiles);\n onRemove?.({ file: selectedFiles[0] });\n }}\n onDismiss={() => {\n const newFiles = selectedFiles.filter(({ id }) => id !== selectedFiles[0].id);\n setSelectedFiles(newFiles);\n onDismiss?.({ file: selectedFiles[0] });\n }}\n onPreview={onPreview}\n />\n )}\n </BaseBox>\n {/* the magic number 136 is basically max-width of label i.e 120 and then right margin i.e 16 which is the spacing between label and input field */}\n {willRenderHintText && (\n <BaseBox\n marginLeft={makeSize(label && isLabelLeftPositioned ? 136 : 0)}\n marginBottom=\"spacing.5\"\n >\n <BaseBox display=\"flex\" flexDirection=\"row\" justifyContent=\"'space-between\">\n <FormHint\n type={getHintType({\n validationState: showError ? 'error' : validationState,\n hasHelpText: Boolean(helpText),\n })}\n helpText={helpText}\n errorText={errorMessage}\n helpTextId={helpTextId}\n errorTextId={errorTextId}\n />\n </BaseBox>\n </BaseBox>\n )}\n {!isOneFileSelectedWithSingleUpload &&\n selectedFiles.map((file) => (\n <BaseBox\n key={file.id}\n marginLeft={makeSize(label && isLabelLeftPositioned ? 136 : 0)}\n marginBottom=\"spacing.3\"\n >\n <FileUploadItem\n file={file}\n onRemove={() => {\n const newFiles = selectedFiles.filter(({ id }) => id !== file.id);\n setSelectedFiles(newFiles);\n onRemove?.({ file });\n }}\n onDismiss={() => {\n const newFiles = selectedFiles.filter(({ id }) => id !== file.id);\n setSelectedFiles(newFiles);\n onDismiss?.({ file });\n }}\n onPreview={onPreview}\n />\n </BaseBox>\n ))}\n </BaseBox>\n );\n};\n\n/**\n * ### FileUpload Component\n * \n * The FileUpload component is used to handle file attachments, including the drag-and-drop interaction.\n * Primarily, it is used to upload files to a server or to display a list of uploaded files.\n * \n * ---\n * \n * #### Usage\n * \n * ```jsx\n const GSTForm = () => {\n const [selectedFile, setSelectedFile] = useState<BladeFile>();\n const [isLoading, setIsLoading] = useState(false);\n \n return (\n <Box>\n <Heading marginBottom=\"spacing.4\">Add GST Details</Heading>\n <form encType=\"multipart/form-data\" onSubmit={handleSubmit}>\n <FileUpload\n uploadType=\"single\"\n label=\"Upload GST\"\n helpText=\"Upload .jpg, .jpeg, or .png file only\"\n accept=\".jpg, .jpeg, .png\"\n onChange={({ fileList }) => {\n setSelectedFile(fileList[0]);\n }}\n onDrop={({ fileList }) => {\n setSelectedFile(fileList[0]);\n }}\n isRequired\n necessityIndicator=\"required\"\n />\n <Button type=\"submit\" variant=\"primary\">\n Submit\n </Button>\n {isLoading && (\n <ProgressBar isIndeterminate label=\"Uploading your GST Certificate...\" />\n )}\n </form>\n </Box>\n );\n }\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-fileupload FileUpload Documentation}\n * \n */\nconst FileUpload = assignWithoutSideEffects(forwardRef(_FileUpload), {\n displayName: 'FileUpload',\n componentId: 'FileUpload',\n});\n\nexport { FileUpload };\nexport type { BladeFile, BladeFileList, FileUploadProps };\n"],"names":["_FileUpload","_ref","ref","name","accept","_ref$uploadType","uploadType","onChange","onPreview","onRemove","onDismiss","onDrop","isDisabled","isRequired","necessityIndicator","fileList","testID","label","_ref$labelPosition","labelPosition","accessibilityLabel","validationState","helpText","errorText","maxCount","maxSize","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","platform","_useState","useState","_useState2","_slicedToArray","selectedFiles","setSelectedFiles","_useState3","_useState4","errorMessage","setErrorMessage","console","log","_useState5","_useState6","internalValidationState","setInternalValidationState","_useState7","_useState8","isActive","setIsActive","isMultiple","isOneFileSelectedWithSingleUpload","length","inputLabelPosition","isLabelLeftPositioned","willRenderHintText","Boolean","showError","showHelpText","accessibilityText","concat","_useFormId","useFormId","inputId","labelId","helpTextId","errorTextId","accessibilityProps","makeAccessible","required","invalid","disabled","describedBy","useMemo","_iterator","_createForOfIteratorHelper","_step","s","n","done","file","value","id","Date","getTime","toString","Math","floor","random","err","e","f","handleFilesChange","useCallback","inputFiles","prevFiles","allFiles","_toConsumableArray","validateFiles","some","isFileAccepted","size","handleDragOver","event","preventDefault","handleDragLeave","handleDrop","droppedFiles","Array","from","dataTransfer","files","hasValidationErrors","handleInputChange","_event$target$files","target","_jsxs","BaseBox","_objectSpread","display","flexDirection","width","metaAttribute","MetaConstants","FileUpload","getStyledProps","children","alignItems","undefined","position","_jsx","FormLabel","as","SelectorLabel","componentName","FileUploadLabel","inputProps","style","cursor","marginBottom","StyledFileUploadWrapper","justifyContent","borderRadius","borderWidth","onDragOver","onDragLeave","onClick","screenReaderStyles","Box","base","gap","makeSize","padding","Text","color","fileUploadColorTokens","text","SelectorInput","hoverTokens","getFileUploadInputHoverTokens","isChecked","type","multiple","onBlur","borderBottomColor","fileUploadLinkBorderTokens","borderBottomWidth","link","FileUploadItem","newFiles","filter","_ref2","_ref3","marginLeft","FormHint","getHintType","hasHelpText","map","_ref4","_ref5","assignWithoutSideEffects","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAMA,WAA6E,GAAG,SAAhFA,WAA6EA,CAAAC,IAAA,EAyBjFC,GAAG,EACoB;AAAA,EAAA,IAxBrBC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,MAAM,GAAAH,IAAA,CAANG,MAAM;IAAAC,eAAA,GAAAJ,IAAA,CACNK,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,eAAA;IACrBE,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IACRC,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,SAAQ,GAAAR,IAAA,CAARQ,QAAQ;IACRC,UAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,MAAM,GAAAV,IAAA,CAANU,MAAM;IACNC,UAAU,GAAAX,IAAA,CAAVW,UAAU;IACVC,UAAU,GAAAZ,IAAA,CAAVY,UAAU;IACVC,kBAAkB,GAAAb,IAAA,CAAlBa,kBAAkB;IAClBC,QAAQ,GAAAd,IAAA,CAARc,QAAQ;IACRC,MAAM,GAAAf,IAAA,CAANe,MAAM;IAC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,EAAAA,IAAI,CAACE,EAkBH,CAAC,CAAA;AAAA,KACX,CAAC,CAAA;AAAA,GAAA,CACG,CAAC,CAAA;AAEd,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACM0C,IAAAA,UAAU,gBAAGwD,wBAAwB,eAACC,UAAU,CAACvL,WAAW,CAAC,EAAE;AACnEwL,EAAAA,WAAW,EAAE,YAAY;AACzBC,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC;;;;"}
@@ -0,0 +1,149 @@
1
+ import { memo } from 'react';
2
+ import { StyledFileUploadItemWrapper } from './StyledFileUploadItemWrapper.js';
3
+ import { FileUploadItemIcon } from './FileUploadItemIcon.js';
4
+ import '../Icons/index.js';
5
+ import '../Box/BaseBox/index.js';
6
+ import '../Typography/index.js';
7
+ import '../Divider/index.js';
8
+ import '../Button/IconButton/index.js';
9
+ import '../ProgressBar/index.js';
10
+ import isUndefined from '../../utils/lodashButBetter/isUndefined.js';
11
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
+ import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
13
+ import { Text } from '../Typography/Text/Text.js';
14
+ import CheckCircleIcon from '../Icons/CheckCircleIcon/CheckCircleIcon.js';
15
+ import { IconButton } from '../Button/IconButton/IconButton.js';
16
+ import CloseIcon from '../Icons/CloseIcon/CloseIcon.js';
17
+ import EyeIcon from '../Icons/EyeIcon/EyeIcon.js';
18
+ import { Divider } from '../Divider/Divider.js';
19
+ import TrashIcon from '../Icons/TrashIcon/TrashIcon.js';
20
+ import { ProgressBar } from '../ProgressBar/ProgressBar.js';
21
+
22
+ var FileUploadItem = /*#__PURE__*/memo(function (_ref) {
23
+ var file = _ref.file,
24
+ onPreview = _ref.onPreview,
25
+ onRemove = _ref.onRemove,
26
+ onDismiss = _ref.onDismiss;
27
+ var name = file.name,
28
+ size = file.size,
29
+ uploadPercent = file.uploadPercent,
30
+ errorText = file.errorText,
31
+ status = file.status;
32
+ var isUploading = status === 'uploading';
33
+ var sizeInKB = size / 1024;
34
+ var sizeInMB = sizeInKB / 1024;
35
+ var showSizeInKB = sizeInKB < 1024;
36
+ return /*#__PURE__*/jsx(StyledFileUploadItemWrapper, {
37
+ status: status !== null && status !== void 0 ? status : 'success',
38
+ borderRadius: "medium",
39
+ borderWidth: "thin",
40
+ children: /*#__PURE__*/jsxs(BaseBox, {
41
+ width: "100%",
42
+ display: "flex",
43
+ flexDirection: "column",
44
+ children: [/*#__PURE__*/jsxs(BaseBox, {
45
+ display: "flex",
46
+ flexDirection: "row",
47
+ margin: "spacing.3",
48
+ children: [/*#__PURE__*/jsx(BaseBox, {
49
+ marginRight: "spacing.3",
50
+ children: /*#__PURE__*/jsx(FileUploadItemIcon, {
51
+ fileName: name,
52
+ uploadStatus: status
53
+ })
54
+ }), /*#__PURE__*/jsxs(BaseBox, {
55
+ flexGrow: 1,
56
+ children: [/*#__PURE__*/jsxs(BaseBox, {
57
+ alignItems: "center",
58
+ display: "flex",
59
+ children: [/*#__PURE__*/jsx(BaseBox, {
60
+ alignItems: "center",
61
+ maxWidth: "70%",
62
+ display: "flex",
63
+ marginRight: "spacing.3",
64
+ children: /*#__PURE__*/jsx(Text, {
65
+ size: "medium",
66
+ weight: "medium",
67
+ color: "surface.text.gray.subtle",
68
+ truncateAfterLines: 1,
69
+ children: name
70
+ })
71
+ }), status === 'success' && /*#__PURE__*/jsx(CheckCircleIcon, {
72
+ size: "medium",
73
+ marginRight: "spacing.2",
74
+ color: "interactive.icon.positive.normal"
75
+ })]
76
+ }), /*#__PURE__*/jsx(Text, {
77
+ size: "small",
78
+ weight: "regular",
79
+ color: status === 'error' ? 'feedback.text.negative.intense' : 'surface.text.gray.muted',
80
+ children: errorText !== null && errorText !== void 0 ? errorText : "".concat((showSizeInKB ? sizeInKB : sizeInMB).toFixed(2), " ").concat(showSizeInKB ? 'KB' : 'MB', " ").concat(isUploading && uploadPercent ? "(".concat(uploadPercent, "%)") : '')
81
+ })]
82
+ }), status === 'error' || status === 'uploading' ? /*#__PURE__*/jsx(BaseBox, {
83
+ children: /*#__PURE__*/jsx(IconButton, {
84
+ accessibilityLabel: "Remove File",
85
+ icon: CloseIcon,
86
+ onClick: function onClick() {
87
+ return onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss({
88
+ file: file
89
+ });
90
+ }
91
+ })
92
+ }) : /*#__PURE__*/jsx(BaseBox, {
93
+ display: "flex",
94
+ flexDirection: "row",
95
+ alignItems: "center",
96
+ children: onPreview ? /*#__PURE__*/jsxs(BaseBox, {
97
+ display: "flex",
98
+ flexDirection: "row",
99
+ alignItems: "center",
100
+ padding: "spacing.0",
101
+ gap: "spacing.3",
102
+ children: [/*#__PURE__*/jsx(IconButton, {
103
+ accessibilityLabel: "Preview File",
104
+ icon: EyeIcon,
105
+ onClick: function onClick() {
106
+ return onPreview === null || onPreview === void 0 ? void 0 : onPreview({
107
+ file: file
108
+ });
109
+ }
110
+ }), /*#__PURE__*/jsx(Divider, {
111
+ orientation: "vertical",
112
+ thickness: "thinner",
113
+ variant: "normal"
114
+ }), /*#__PURE__*/jsx(IconButton, {
115
+ accessibilityLabel: "Remove File",
116
+ icon: TrashIcon,
117
+ onClick: function onClick() {
118
+ return onRemove === null || onRemove === void 0 ? void 0 : onRemove({
119
+ file: file
120
+ });
121
+ }
122
+ })]
123
+ }) : /*#__PURE__*/jsx(IconButton, {
124
+ accessibilityLabel: "Remove File",
125
+ icon: TrashIcon,
126
+ onClick: function onClick() {
127
+ return onRemove === null || onRemove === void 0 ? void 0 : onRemove({
128
+ file: file
129
+ });
130
+ }
131
+ })
132
+ })]
133
+ }), isUploading && /*#__PURE__*/jsx(BaseBox, {
134
+ width: "100%",
135
+ position: "absolute",
136
+ bottom: "spacing.0",
137
+ children: /*#__PURE__*/jsx(ProgressBar, {
138
+ left: "spacing.0",
139
+ showPercentage: false,
140
+ value: uploadPercent !== null && uploadPercent !== void 0 ? uploadPercent : 0,
141
+ isIndeterminate: isUndefined(uploadPercent)
142
+ })
143
+ })]
144
+ })
145
+ });
146
+ });
147
+
148
+ export { FileUploadItem };
149
+ //# sourceMappingURL=FileUploadItem.js.map