UNPKG

@braineet/ui

Version:

Braineet design system

61 lines 2.98 kB
var _excluded = ["item", "animationStatus", "style", "disabled", "listType", "readonly", "uploadItemStatus", "onPreview", "uploadItems", "cancelUpload", "removeItem", "updateItem", "addItems"]; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } /* 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 } from "react/jsx-runtime"; import { 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 };