Skip to content

Commit

Permalink
Merge pull request #106 from dev-family/ADM-183
Browse files Browse the repository at this point in the history
ADM-183: Fix FilePictureInput disable list
  • Loading branch information
aMurashkoWebSecret authored Nov 20, 2023
2 parents fe694f9 + 7cab813 commit 51dd0c6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admiral/form/fields/FilePictureInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const FilePictureInput: InputComponentWithName<React.FC<FilePictureInputP
}) => {
const { values, errors, setValues, locale: formLocale } = useForm()
const locale = formLocale.fields.upload

let value = values[name]

const isArrayValue = Array.isArray(value)
Expand Down Expand Up @@ -55,6 +54,7 @@ export const FilePictureInput: InputComponentWithName<React.FC<FilePictureInputP
fileList={normalizedValue}
onChange={onChange}
maxCount={maxCount}
disabled={disabled}
>
<Button type="button" disabled={disabled} iconLeft={<FiUpload />}>
{children || 'Upload'}
Expand Down
4 changes: 2 additions & 2 deletions admiral/ui/Upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
value: fileList,
postState: (list) => list ?? [],
})

const upload = React.useRef<any>()

// Control mode will auto fill file uid if not provided
Expand Down Expand Up @@ -79,7 +78,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
}

const mergedBeforeUpload = async (file: RcFile, fileListArgs: RcFile[]) => {
onInternalChange(file, fileListArgs)
!disabled && onInternalChange(file, fileListArgs)
return false
}

Expand Down Expand Up @@ -191,6 +190,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
<RcUpload
{...rcUploadProps}
ref={upload}
disabled={disabled}
className={cn({
[`${prefixCls}-btn`]: buttonType === 'drag',
[styles.item]: buttonType === 'picture-card',
Expand Down
6 changes: 4 additions & 2 deletions lib/admiral.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -93945,7 +93945,7 @@ const InternalUpload = (props, ref) => {
onChange2 == null ? void 0 : onChange2(changeInfo);
};
const mergedBeforeUpload = async (file2, fileListArgs) => {
onInternalChange(file2, fileListArgs);
!disabled2 && onInternalChange(file2, fileListArgs);
return false;
};
const handleRemove = (file2) => {
Expand Down Expand Up @@ -94028,6 +94028,7 @@ const InternalUpload = (props, ref) => {
})
}, /* @__PURE__ */ React__default.createElement(Upload$2, __spreadProps(__spreadValues({}, rcUploadProps), {
ref: upload2,
disabled: disabled2,
className: cn$1({
[`${prefixCls2}-btn`]: buttonType2 === "drag",
[styles$8.item]: buttonType2 === "picture-card"
Expand Down Expand Up @@ -95001,7 +95002,8 @@ const FilePictureInput = (_S) => {
locale: locale2,
fileList: normalizedValue,
onChange: onChange2,
maxCount
maxCount,
disabled: disabled2
}), /* @__PURE__ */ React__default.createElement(Button$1, {
type: "button",
disabled: disabled2,
Expand Down
2 changes: 1 addition & 1 deletion lib/admiral.umd.js

Large diffs are not rendered by default.

0 comments on commit 51dd0c6

Please sign in to comment.