Skip to content

Commit

Permalink
* file-selector: set maxFileSize default value as totalFileSize.
Browse files Browse the repository at this point in the history
  • Loading branch information
YonLJ committed Nov 12, 2024
1 parent fe4b618 commit d114bdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions lib/file-selector/src/components/file-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ export class FileSelector<P extends FileSelectorProps = FileSelectorProps, S ext

constructor(props: P) {
if (props.totalFileSize) {
const {maxFileSize = '100MB', totalFileSize} = props;
const maxSize = typeof maxFileSize === 'number' ? maxFileSize : convertBytes(maxFileSize);
const totalSize = typeof totalFileSize === 'number' ? totalFileSize : convertBytes(totalFileSize);
props.maxFileSize = maxSize > totalSize
? totalFileSize
: maxFileSize;
if (props.maxFileSize) {
const {maxFileSize, totalFileSize} = props;
const maxSize = typeof maxFileSize === 'number' ? maxFileSize : convertBytes(maxFileSize);
const totalSize = typeof totalFileSize === 'number' ? totalFileSize : convertBytes(totalFileSize);
props.maxFileSize = maxSize > totalSize
? totalFileSize
: maxFileSize;
} else {
props.maxFileSize = props.totalFileSize;
}
}

if (!props.maxFileSize) {
Expand Down
2 changes: 1 addition & 1 deletion lib/file-selector/src/vanilla/file-selector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ComponentFromReact} from '@zui/core';
import {FileSelector as FileSelectorReact} from '../components';
import {FileSelectorProps} from '../types';
import type {FileSelectorProps} from '../types';

export class FileSelector extends ComponentFromReact<FileSelectorProps, FileSelectorReact> {
static NAME = 'FileSelector';
Expand Down

0 comments on commit d114bdd

Please sign in to comment.