Skip to content

Commit

Permalink
fixup! feat: add FileField definition
Browse files Browse the repository at this point in the history
  • Loading branch information
moonRider committed Aug 30, 2024
1 parent 0bb486c commit 9918639
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
14 changes: 10 additions & 4 deletions types/ui_schema/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ interface AssocitaionSettings {
}

interface FileSettings {
/** Size limit of single file with Byte unit, default Infinity */
maxFileItemSize?: number
/** Count limit, default 1 */
/**
* Defines the max size of a file upload in megabytes (MB) (inclusive)
* that can be selected for uploading, default Infinity
*/
maxFileItemSizeLimitInMB?: number
/** Count limit, undefined means unlimited */
maxCount?: number
/** Allowed mimetype pattern, default '*' */
/**
* Allowed mimetype pattern, default '*'
* See more at: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept
*/
accept?: string
}

Expand Down
2 changes: 1 addition & 1 deletion types/ui_schema/form/example/association.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const MovieFormUISchema: FormUISchema<
},
poster: {
'ui:widget': 'FileWidget',
'ui:x-max-file-item-size': 20 * 1024 * 1024,
'ui:x-max-file-item-size-limit-in-mb': 20,
'ui:x-capture': 'user',
'ui:x-accept': 'image/*',
'ui:x-max-count': 1,
Expand Down
3 changes: 2 additions & 1 deletion types/ui_schema/form/ui_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ type BooleanFieldUIOptions = {
} & CommonCustomFieldUIOptions

type FileFieldUIOptions = {
'ui:x-max-file-item-size'?: number
'ui:x-max-file-item-size-limit-in-mb'?: number
'ui:x-accept'?: string
/** @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture */
'ui:x-capture'?: 'user' | 'environment'
'ui:x-max-count'?: number
} & CommonCustomFieldUIOptions
Expand Down
2 changes: 1 addition & 1 deletion types/ui_schema/table/example/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const moviesTableSchema: TableSchema<
settings: {
accept: 'image/*',
maxCount: 1,
maxFileItemSize: 20 * 1024 * 1024,
maxFileItemSizeLimitInMB: 20,
},
},
actors: {
Expand Down

0 comments on commit 9918639

Please sign in to comment.