Update from Vibe Studio

This commit is contained in:
Vibe Studio
2026-01-16 01:51:36 +00:00
parent a4605e311a
commit 58905d02c2
28599 changed files with 2179074 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import type { DraggerProps, UploadProps } from 'antd/lib/upload';
import React from 'react';
import type { ProFormFieldItemProps } from '../../typing';
export type ProFormUploadDraggerProps = ProFormFieldItemProps<DraggerProps> & {
/**
* @name 上传文件块的图标
* @default UploadOutlined
*
* @example 改成笑脸图标 icon={<SmileOutlined/>}
*/
icon?: React.ReactNode;
/**
* @name 上传文件块的标题
* @default 单击或拖动文件到此区域进行上传
*
* @example title="上传"
* @example title={<div>上传</div>}
*/
title?: React.ReactNode;
/**
* @name 上传文件块的说明,比标题小一点,但是字数可以更多
* @default 支持单次或批量上传
*
* @example description="支持xxx文件"
* @example description={<div>支持xxx文件</div>}
*/
description?: React.ReactNode;
/**
* @name 最大的文件数量,到达数量之后上传按钮会失效
*
* @example max=2
*/
max?: number;
/**
* @name 上传组件的 fileList为了配合form改成了这个名字
* @default []
*
* example:value={ [{uid: '-1', name: 'xxx.png', status: 'done', url: 'http://www.baidu.com/xxx.png'}] }
*/
value?: UploadProps['fileList'];
onChange?: UploadProps['onChange'];
action?: UploadProps['action'];
accept?: UploadProps['accept'];
};
declare const ProFormUploadDragger: React.FC<ProFormUploadDraggerProps>;
export default ProFormUploadDragger;

View File

@@ -0,0 +1,79 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { InboxOutlined } from '@ant-design/icons';
import { ConfigProvider, Upload } from 'antd';
import React, { useContext } from 'react';
import { EditOrReadOnlyContext } from "../../BaseForm/EditOrReadOnlyContext";
import { createField } from "../../BaseForm/createField";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
/**
* 拖动上传组件
*
* @param
*/
var BaseProFormUploadDragger = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var _fieldProps$style;
var fieldProps = _ref.fieldProps,
_ref$title = _ref.title,
title = _ref$title === void 0 ? '单击或拖动文件到此区域进行上传' : _ref$title,
_ref$icon = _ref.icon,
icon = _ref$icon === void 0 ? /*#__PURE__*/_jsx(InboxOutlined, {}) : _ref$icon,
_ref$description = _ref.description,
description = _ref$description === void 0 ? '支持单次或批量上传' : _ref$description,
action = _ref.action,
accept = _ref.accept,
_onChange = _ref.onChange,
value = _ref.value,
children = _ref.children,
max = _ref.max,
proFieldProps = _ref.proFieldProps;
var context = useContext(ConfigProvider.ConfigContext);
var modeContext = useContext(EditOrReadOnlyContext);
var mode = (proFieldProps === null || proFieldProps === void 0 ? void 0 : proFieldProps.mode) || modeContext.mode || 'edit';
var baseClassName = context.getPrefixCls('upload');
// 如果配置了 max ,并且 超过了文件列表的大小,就不展示按钮
var showUploadButton = (max === undefined || !value || (value === null || value === void 0 ? void 0 : value.length) < max) && mode !== 'read' && (proFieldProps === null || proFieldProps === void 0 ? void 0 : proFieldProps.readonly) !== true;
return /*#__PURE__*/_jsxs(Upload.Dragger, _objectSpread(_objectSpread({
// @ts-ignore
ref: ref,
name: "files",
action: action,
accept: accept,
fileList: value
}, fieldProps), {}, {
onChange: function onChange(info) {
_onChange === null || _onChange === void 0 || _onChange(info);
if (fieldProps !== null && fieldProps !== void 0 && fieldProps.onChange) {
fieldProps === null || fieldProps === void 0 || fieldProps.onChange(info);
}
},
style: _objectSpread(_objectSpread({
flexDirection: 'column',
alignItems: 'center'
}, fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style), {}, {
display: !showUploadButton ? 'none' : (fieldProps === null || fieldProps === void 0 || (_fieldProps$style = fieldProps.style) === null || _fieldProps$style === void 0 ? void 0 : _fieldProps$style.display) || 'flex'
}),
children: [/*#__PURE__*/_jsx("p", {
className: "".concat(baseClassName, "-drag-icon"),
children: icon
}), /*#__PURE__*/_jsx("p", {
className: "".concat(baseClassName, "-text"),
children: title
}), /*#__PURE__*/_jsx("p", {
className: "".concat(baseClassName, "-hint"),
children: description
}), children ? /*#__PURE__*/_jsx("div", {
className: "".concat(baseClassName, "-extra"),
style: {
padding: 16
},
children: children
}) : null]
}));
});
var ProFormUploadDragger = createField(BaseProFormUploadDragger, {
getValueFromEvent: function getValueFromEvent(value) {
return value.fileList;
}
});
export default ProFormUploadDragger;