UNPKG

@braineet/ui

Version:

Braineet design system

60 lines 2.78 kB
var _excluded = ["item", "animationStatus", "style", "disabled", "listType", "readonly", "uploadItemStatus", "onPreview", "uploadItems", "cancelUpload", "removeItem", "updateItem", "addItems"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } /* eslint-disable react/no-array-index-key */ import React from 'react'; import { animated } from 'react-spring'; import Field from '../../field'; import { UPLOAD_ITEM_STATUS } from '../useUploadState'; import { DefaultUploadItem } from './DefaultUploadItem'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; var defaultUploadItemStatus = { default: DefaultUploadItem, uploading: DefaultUploadItem, error: DefaultUploadItem }; export var UploadItem = function UploadItem(_ref) { var item = _ref.item, animationStatus = _ref.animationStatus, style = _ref.style, disabled = _ref.disabled, listType = _ref.listType, readonly = _ref.readonly, _ref$uploadItemStatus = _ref.uploadItemStatus, uploadItemStatus = _ref$uploadItemStatus === void 0 ? defaultUploadItemStatus : _ref$uploadItemStatus, onPreview = _ref.onPreview, uploadItems = _ref.uploadItems, cancelUpload = _ref.cancelUpload, removeItem = _ref.removeItem, updateItem = _ref.updateItem, addItems = _ref.addItems, restProps = _objectWithoutPropertiesLoose(_ref, _excluded); var UploadItemComponent = uploadItemStatus[item == null ? void 0 : item.status] || uploadItemStatus.default || defaultUploadItemStatus.default; return /*#__PURE__*/_jsxs(animated.li, { style: style, children: [/*#__PURE__*/_jsx(UploadItemComponent, _extends({ item: item, animationStatus: animationStatus, disabled: disabled, listType: listType, readonly: readonly, onPreview: onPreview, uploadItems: uploadItems, cancelUpload: cancelUpload, removeItem: removeItem, updateItem: updateItem, addItems: addItems }, restProps)), item != null && item.errorText && (item == null ? void 0 : item.status) === UPLOAD_ITEM_STATUS.ERROR ? /*#__PURE__*/_jsx(Field.Helper, { marginLeft: "0", marginTop: "2px", isInvalid: true, fieldStyle: { marginTop: 2 }, children: item == null ? void 0 : item.errorText }) : null] }); }; UploadItem.defaultProps = { animationStatus: null };