Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne-components/components-core",
"version": "0.4.46",
"version": "0.4.47",
"files": [
"build"
],
Expand All @@ -22,7 +22,7 @@
"@kne/create-deferred": "^0.1.0",
"@kne/ensure-slash": "^0.1.0",
"@kne/flex-box": "^0.1.1",
"@kne/form-info": "^0.1.2",
"@kne/form-info": "^0.1.4",
"@kne/global-context": "^1.3.2",
"@kne/info-page": "^0.2.3",
"@kne/is-empty": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/Scroller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ const ScrollBar = ({onScroll, getContainer, ...scrollerProps}) => {
};
}, []);
return createPortal(scrollerProps.hasScroller ? (<div
className={style["scroller"]}
className={classnames(style["scroller"], 'scroller-bar')}
style={{
left: scrollerProps.left, width: scrollerProps.width, height: 15, //scrollerProps.height
}}
>
<div
className={classnames(style["scroller-inner"], {
className={classnames(style["scroller-inner"], 'scroller-bar-inner', {
[style["is-moving"]]: moving,
})}
style={{
Expand Down
74 changes: 33 additions & 41 deletions src/components/File/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,60 @@ import dropRight from "lodash/dropRight";
import last from "lodash/last";
import FormInfo, {Input, useFormModal} from "@components/FormInfo";
import Modal from "@components/Modal";
import importMessages from "../locale";
import {FormattedMessage, IntlProvider} from '@components/Intl';

const useEdit = ({apis}) => {
const formModal = useFormModal();
return typeof apis?.onEditModalShow === 'function' ? apis.onEditModalShow : (item, apis) => {
const modalApi = formModal({
size: "small",
title: "修改文件名称",
formProps: {
size: "small", title: <IntlProvider importMessages={importMessages} moduleName="File"><FormattedMessage
id="editDocumentName" moduleName="File"/></IntlProvider>, formProps: {
data: {
name: dropRight(item.filename.split(".")).join("."),
},
onSubmit: async (data) => {
const res =
apis?.onEdit &&
(await apis?.onEdit({
formData: Object.assign({}, data, {
name: `${data.name}.${last(item.filename.split("."))}`,
}),
item,
}));
}, onSubmit: async (data) => {
const res = apis?.onEdit && (await apis?.onEdit({
formData: Object.assign({}, data, {
name: `${data.name}.${last(item.filename.split("."))}`,
}), item,
}));
if (res !== false) {
modalApi.close();
}
},
},
children: (
<FormInfo
column={1}
list={[<Input name="name" label={"文件名称"} rule="REQ LEN-0-100"/>]}
/>
),
}, children: (<FormInfo
column={1}
list={[<Input name="name"
label={<IntlProvider importMessages={importMessages} moduleName="File"><FormattedMessage
id="documentName" moduleName="File"/></IntlProvider>} rule="REQ LEN-0-100"/>]}
/>),
});
};
};

const List = ({apis, ...p}) => {
const handlerEdit = useEdit({apis});
return (
<FileList
{...p}
apis={apis}
onEdit={(item) => handlerEdit(item, apis)}
onDelete={apis?.onDelete}
renderModal={typeof p.renderModal === 'function' ? p.renderModal : ({onCancel, ...modalProps}) => {
return <Modal {...Object.assign({}, modalProps)} onClose={onCancel}/>;
}}
/>
);
return (<FileList
{...p}
apis={apis}
onEdit={(item) => handlerEdit(item, apis)}
onDelete={apis?.onDelete}
renderModal={typeof p.renderModal === 'function' ? p.renderModal : ({onCancel, ...modalProps}) => {
return <Modal {...Object.assign({}, modalProps)} onClose={onCancel}/>;
}}
/>);
};

const OptionButtons = (props) => {
const handlerEdit = useEdit({apis: props.apis});
return (
<FileListOptionButtons
{...props}
onEdit={(item) => handlerEdit(item, props.apis)}
onDelete={props.apis?.onDelete}
renderModal={typeof props.renderModal === 'function' ? props.renderModal : ({onCancel, ...modalProps}) => {
return <Modal {...Object.assign({}, modalProps)} onClose={onCancel}/>;
}}
/>
);
return (<FileListOptionButtons
{...props}
onEdit={(item) => handlerEdit(item, props.apis)}
onDelete={props.apis?.onDelete}
renderModal={typeof props.renderModal === 'function' ? props.renderModal : ({onCancel, ...modalProps}) => {
return <Modal {...Object.assign({}, modalProps)} onClose={onCancel}/>;
}}
/>);
};

export default List;
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileList/DragArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const DragAreaOuter = ({
},
}}
>
<Space className={style["file-list-outer"]} direction="vertical">
<Space className={style["file-list-outer"]} orientation="vertical">
{title}
<div
className={classnames(style["container"], className)}
Expand Down
58 changes: 29 additions & 29 deletions src/components/FileList/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {useFileUpload} from "@kne/react-file";
import {usePreset} from "@components/Global";
import useControlValue from "@kne/use-control-value";
import get from "lodash/get";
import {FormattedMessage, IntlProvider} from "@components/Intl";
import importMessages from "./locale";

const FileUpload = ({
maxLength = Number.MAX_VALUE,
Expand All @@ -18,9 +20,7 @@ const FileUpload = ({
const {apis: baseApis} = usePreset();
const apis = Object.assign({}, baseApis, currentApis);
const [previewList, setList] = useControlValue({defaultList, ...props}, {
defaultValue: "defaultList",
value: "list",
onChange: "setList",
defaultValue: "defaultList", value: "list", onChange: "setList",
});
const {fileList: uploadingList, onFileSelected} = useFileUpload({
maxLength,
Expand All @@ -37,32 +37,32 @@ const FileUpload = ({
},
onUpload: apis.ossUpload,
});
return (
<DragAreaOuter
title={
<Row>
<Col flex={1}></Col>
<Col>
<Space split={<Divider type="vertical"/>}>
<DragButton/>
<UploadButton>上传</UploadButton>
</Space>
</Col>
</Row>
}
fileSize={fileSize}
maxLength={maxLength}
onFileSelected={onFileSelected}
accept={accept}
>
<List
dataSource={[...uploadingList, ...previewList]}
getPermission={getPermission}
apis={apis}
/>
<DragArea/>
</DragAreaOuter>
);
return (<DragAreaOuter
title={<Row>
<Col flex={1}></Col>
<Col>
<Space split={<Divider type="vertical"/>}>
<DragButton/>
<UploadButton>
<IntlProvider importMessages={importMessages} moduleName="FileList">
<FormattedMessage id="upload" moduleName="FileList"/>
</IntlProvider>
</UploadButton>
</Space>
</Col>
</Row>}
fileSize={fileSize}
maxLength={maxLength}
onFileSelected={onFileSelected}
accept={accept}
>
<List
dataSource={[...uploadingList, ...previewList]}
getPermission={getPermission}
apis={apis}
/>
<DragArea/>
</DragAreaOuter>);
};

export default FileUpload;
4 changes: 2 additions & 2 deletions src/components/FileList/Title.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const Title = ({
getPopupContainer,
}) => {
return (<div className={style["file-list-title"]}>
<Row align="middle" justify="space-between" wrap={false}>
<Row align="middle" justify="space-between" wrap>
<Col>
<Space className={classnames(style["title-group"], 'core-file-list-title-group')} size={4}>
<Space className={classnames(style["title-group"], 'core-file-list-title-group')} size={4} wrap>
<Segmented
value={currentTab}
onChange={setCurrentTab}
Expand Down
35 changes: 17 additions & 18 deletions src/components/FileList/locale/en-US.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
const message = {
loadingText: "loading",
listText: "List",
previewText: "Preview",
uploadUser: "Upload user",
uploadTime: "Upload time",
totalCount: "total:{count}",
dragText: "Drag",
uploadFile: "Upload",
dragTitle: "Drag files here to upload",
dragTips:
"Supported file formats: {accept}, single file size less than {size}M",
uploading: "Uploading",
documentName: "Document name",
editDocumentName: "Edit document name",
documentTips:
"Do not modify the file extension, which may cause the file to not preview correctly",
successDelete: "Success delete {name}",
successEditFileName: "Save Success",
upload: "Upload",
loadingText: "loading",
listText: "List",
previewText: "Preview",
uploadUser: "Upload user",
uploadTime: "Upload time",
totalCount: "total:{count}",
dragText: "Drag",
uploadFile: "Upload",
dragTitle: "Drag files here to upload",
dragTips: "Supported file formats: {accept}, single file size less than {size}M",
uploading: "Uploading",
documentName: "Document name",
editDocumentName: "Edit document name",
documentTips: "Do not modify the file extension, which may cause the file to not preview correctly",
successDelete: "Success delete {name}",
successEditFileName: "Save Success",
};

export default message;
33 changes: 17 additions & 16 deletions src/components/FileList/locale/zh-CN.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
const message = {
loadingText: "正在上传",
listText: "列表",
previewText: "预览",
uploadUser: "上传人",
uploadTime: "上传时间",
totalCount: "共{count}份",
dragText: "拖拽上传",
uploadFile: "上传文件",
dragTitle: "将文件拖拽到这里上传",
dragTips: "支持文件格式:{accept},单个文件大小{size}M以内",
uploading: "正在上传",
documentName: "文件名称",
editDocumentName: "修改文件名称",
documentTips: "请勿修改文件扩展名,这有可能导致文件不能正确预览",
successDelete: "删除{name}成功",
successEditFileName: "修改成功",
upload: "上传",
loadingText: "正在上传",
listText: "列表",
previewText: "预览",
uploadUser: "上传人",
uploadTime: "上传时间",
totalCount: "共{count}份",
dragText: "拖拽上传",
uploadFile: "上传文件",
dragTitle: "将文件拖拽到这里上传",
dragTips: "支持文件格式:{accept},单个文件大小{size}M以内",
uploading: "正在上传",
documentName: "文件名称",
editDocumentName: "修改文件名称",
documentTips: "请勿修改文件扩展名,这有可能导致文件不能正确预览",
successDelete: "删除{name}成功",
successEditFileName: "修改成功",
};

export default message;
11 changes: 8 additions & 3 deletions src/components/FileList/style.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.file-list-outer {
min-width: 600px;

}

.file-list-title {
Expand All @@ -20,11 +20,14 @@
justify-content: center;
margin: 0;
}

.file-preview-inner {
border: 10px solid #999;
background: #999;
width: 100%;
box-sizing: border-box;
min-height: var(--min-inner-height);

.file-preview {
:global {
.react-pdf__message--error {
Expand All @@ -48,13 +51,13 @@
}

.upload-drag-close {
position: absolute;
position: absolute !important;
right: 10px;
top: 10px;
}

.upload-drag-tips {
padding: 80px 0;
padding: 80px 12px;
display: flex;
flex-direction: column;
justify-content: center;
Expand Down Expand Up @@ -86,6 +89,7 @@
.split {
margin-right: 4px;
}

:global(.is-block) {
line-height: 32px;
}
Expand Down Expand Up @@ -116,6 +120,7 @@
}

.title-group {
justify-content: space-between;
> :global(.ant-space-item) {
display: flex;
align-items: center;
Expand Down
15 changes: 9 additions & 6 deletions src/components/FormInfo/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,26 @@ import withLocale from '../withLocale';
import style from "../style.module.scss";

const createWithFieldDecorator = (decoratorList) => (WrappedComponent) => {
const TargetComponent = compose(...decoratorList)(({forwardedRef, label, placeholder, ...props}) => {
const TargetComponent = compose(...decoratorList)(({forwardedRef, label, placeholder, labelRender, ...props}) => {
return (<WrappedComponent
{...props}
label={label}
placeholder={placeholder}
labelRender={() => props.tips ? (<Space>
{label}
<Tooltip content={props.tips}>
labelRender={(...args) => {
const targetLabel = typeof labelRender === 'function' ? labelRender(...args) : label;
return props.tips ? (<Space>
{targetLabel}
<Tooltip content={props.tips}>
<span
className={classnames(style["field-tips"], {
[style["label-hidden"]]: props.labelHidden,
})}
>
<Icon type="icon-xinxi-miaobian"/>
</span>
</Tooltip>
</Space>) : (label)}
</Tooltip>
</Space>) : (targetLabel);
}}
ref={forwardedRef}
/>)
});
Expand Down
Loading