File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
form-groups/form-input/input-image-picker
tools/gamification-admin/pages/create-badge/create-badge-form Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ import { InputValue } from '../../../form-input.model'
66import styles from './InputImagePicker.module.scss'
77
88interface InputImagePickerProps {
9- readonly accept ?: string
9+ readonly fileConfig ?: {
10+ readonly acceptFileType ?: string
11+ readonly maxFileSize ?: number
12+ }
1013 readonly name : string
1114 readonly onChange : ( event : ChangeEvent < HTMLInputElement > ) => void
12- readonly size ?: number
1315 readonly value ?: InputValue
1416}
1517
@@ -49,14 +51,14 @@ const InputImagePicker: FC<InputImagePickerProps> = (props: InputImagePickerProp
4951 < input
5052 name = { props . name }
5153 type = { 'file' }
52- accept = { props . accept || '*' }
54+ accept = { props . fileConfig ?. acceptFileType || '*' }
5355 className = { styles . filePickerInput }
5456 ref = { fileInputRef }
5557 onChange = { event => {
5658 setFiles ( event . target . files )
5759 props . onChange ( event )
5860 } }
59- size = { props . size || Infinity }
61+ size = { props . fileConfig ?. maxFileSize || Infinity }
6062 />
6163 {
6264 fileDataURL ? (
Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ export interface FormCard {
2020export type InputValue = string | boolean | FileList | undefined
2121
2222export interface FormInputModel {
23- readonly accept ?: string
2423 readonly autocomplete ?: FormInputAutocompleteOption
2524 readonly cards ?: ReadonlyArray < FormCard >
2625 checked ?: boolean
@@ -30,6 +29,10 @@ export interface FormInputModel {
3029 disabled ?: boolean
3130 error ?: string
3231 readonly events ?: ReadonlyArray < InputEvent >
32+ readonly fileConfig ?: {
33+ readonly acceptFileType ?: string
34+ readonly maxFileSize ?: number
35+ }
3336 readonly files ?: FileList
3437 readonly hideInlineErrors ?: boolean
3538 readonly hint ?: string
@@ -40,7 +43,6 @@ export interface FormInputModel {
4043 readonly notTabbable ?: boolean
4144 options ?: ReadonlyArray < FormRadioButtonOption >
4245 readonly placeholder ?: string
43- readonly size ?: number
4446 readonly spellCheck ?: boolean
4547 readonly title ?: string
4648 touched ?: boolean
Original file line number Diff line number Diff line change @@ -33,9 +33,11 @@ export const createBadgeFormDef: FormDefinition = {
3333 {
3434 inputs : [
3535 {
36- accept : GamificationConfig . ACCEPTED_BADGE_MIME_TYPES ,
36+ fileConfig : {
37+ acceptFileType : GamificationConfig . ACCEPTED_BADGE_MIME_TYPES ,
38+ maxFileSize : GamificationConfig . MAX_BADGE_IMAGE_FILE_SIZE ,
39+ } ,
3740 name : CreateBadgeFormField . file ,
38- size : GamificationConfig . MAX_BADGE_IMAGE_FILE_SIZE ,
3941 type : 'image-picker' ,
4042 validators : [
4143 {
You can’t perform that action at this time.
0 commit comments