@m4l/components 9.2.28 → 9.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/types.d.ts +8 -0
- package/components/MFIsolationApp/MFIsolationApp.js +4 -4
- package/components/hook-form/RHFTimePicker/slots/RHFTimePickerEnum.d.ts +4 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.d.ts +7 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +74 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.styles.d.ts +2 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.styles.js +147 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.d.ts +23 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/constants.js +34 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/dictionary.d.ts +15 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/dictionary.js +15 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/formatFileSize.d.ts +6 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/formatFileSize.js +16 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/getReadableFileType.d.ts +6 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/getReadableFileType.js +55 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/uploadReducer.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/helpers/uploadReducer.js +17 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/index.d.ts +1 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileEnum.d.ts +22 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileEnum.js +26 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts +60 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.js +110 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/BlockContent.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/BlockContent.js +77 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/BlockContent/types.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/Preview.js +36 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/Preview/types.d.ts +6 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.d.ts +5 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js +89 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/types.d.ts +38 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/test/RHFUploadsinglefile.test.d.ts +1 -0
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/types.d.ts +42 -0
- package/components/hook-form/index.d.ts +1 -1
- package/components/mui_extended/Button/ButtonStyles.js +88 -59
- package/components/mui_extended/LinearProgress/index.js +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/storybook/hook-form/RHFUploadSingleFile/RHFUploadSingleFile.stories.d.ts +11 -0
- package/components/MFIsolationApp/constants.js +0 -4
- package/components/hook-form/RHFUpload/RHFUploadFile/components/UploadSingleFile/index.d.ts +0 -13
- package/components/hook-form/RHFUpload/RHFUploadFile/components/UploadSingleFile/index.js +0 -84
- package/components/hook-form/RHFUpload/RHFUploadFile/index.d.ts +0 -9
- package/components/hook-form/RHFUpload/RHFUploadFile/index.js +0 -31
- package/components/hook-form/RHFUpload/components/UploadComponents/BlockContent.js +0 -36
- package/components/hook-form/RHFUpload/components/UploadComponents/RejectionFiles.js +0 -31
- package/storybook/hook-form/RHFUploadImage/RHFUploadFile.stories.d.ts +0 -6
package/components/hook-form/RHFUpload/RHFUploadSingleFile/slots/RHFUploadSingleFileSlots.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const RHFUploadSingleFileRootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
2
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
3
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
4
|
+
export declare const LabelStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../..').LabelProps, keyof import('../../../..').LabelProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
5
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
6
|
+
}, {}, {}>;
|
|
7
|
+
export declare const HelperErrorStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../HelperError').HelperErrorProps & import('react').RefAttributes<HTMLLabelElement>, keyof import('../../../../HelperError').HelperErrorProps | keyof import('react').RefAttributes<HTMLLabelElement>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
8
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
9
|
+
}, {}, {}>;
|
|
10
|
+
export declare const ContainerDropZoneStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
11
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
12
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
13
|
+
export declare const DropZoneStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
14
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
15
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
16
|
+
export declare const ImageStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../Image').ImageProps, keyof import('../../../../Image').ImageProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
17
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
18
|
+
}, {}, {}>;
|
|
19
|
+
export declare const BlockContentGroupStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
20
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
21
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
22
|
+
export declare const ContainerBlockContentStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
23
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
24
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
25
|
+
export declare const IllustrationUploadStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../Image').ImageProps, keyof import('../../../../Image').ImageProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
26
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
27
|
+
}, {}, {}>;
|
|
28
|
+
export declare const TitleStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
29
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
30
|
+
}, {}, {}>;
|
|
31
|
+
export declare const DescriptionStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
32
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
33
|
+
}, {}, {}>;
|
|
34
|
+
export declare const DividerStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
35
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
36
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
37
|
+
export declare const DividerTextStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
38
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
export declare const ButtonStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('../../../../mui_extended/Button').ButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>, "value" | "size" | "children" | "title" | "component" | "name" | "id" | "type" | "disabled" | "action" | "hidden" | "color" | "content" | "style" | "variant" | "translate" | "className" | "classes" | "sx" | "form" | "label" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "href" | "skeletonWidth" | "startIcon" | "endIcon" | keyof import('react').RefAttributes<HTMLButtonElement> | "disableElevation" | "fullWidth"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
41
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
42
|
+
}, {}, {}>;
|
|
43
|
+
export declare const ContainerPreviewStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
44
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
45
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
46
|
+
export declare const ContainerNameSizeStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
47
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
48
|
+
}, Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('react').ClassAttributes<HTMLDivElement> | keyof import('react').HTMLAttributes<HTMLDivElement>>, {}>;
|
|
49
|
+
export declare const ImagePreviewStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../Image').ImageProps, keyof import('../../../../Image').ImageProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
50
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
51
|
+
}, {}, {}>;
|
|
52
|
+
export declare const NamePreviewStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
53
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
54
|
+
}, {}, {}>;
|
|
55
|
+
export declare const SizePreviewStyled: import('@emotion/styled').StyledComponent<Pick<import('../../../../mui_extended/Typography/types').TypographyProps, keyof import('../../../../mui_extended/Typography/types').TypographyProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
56
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
57
|
+
}, {}, {}>;
|
|
58
|
+
export declare const ClosePreviewStyled: import('@emotion/styled').StyledComponent<Pick<Omit<import('../../../../mui_extended/IconButton/types').IconButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>, "value" | "size" | "children" | "title" | "component" | "name" | "id" | "type" | "selected" | "disabled" | "action" | "hidden" | "color" | "content" | "style" | "icon" | "tooltip" | "variant" | "translate" | "className" | "classes" | "src" | "sx" | "form" | "slot" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "instaceDataTestId" | "rotationAngle" | "placement" | "tooltipContent" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "badgeContent" | "dictionaryTooltipId" | keyof import('react').RefAttributes<HTMLButtonElement>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & Record<string, unknown> & {
|
|
59
|
+
ownerState: Partial<import('../types').RHFUploadSingleFileOwnerState> & Record<string, unknown>;
|
|
60
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { styled } from "@mui/material";
|
|
2
|
+
import { R as RHFUploadSingleFileSlots } from "./RHFUploadSingleFileEnum.js";
|
|
3
|
+
import { r as rhfUploadSingleFileStyles } from "../RHFUploadSingleFile.styles.js";
|
|
4
|
+
import { T as Typography } from "../../../../mui_extended/Typography/Typography.js";
|
|
5
|
+
import { B as Button } from "../../../../mui_extended/Button/Button.js";
|
|
6
|
+
import { I as IconButton } from "../../../../mui_extended/IconButton/IconButton.js";
|
|
7
|
+
import { I as Image } from "../../../../Image/Image.js";
|
|
8
|
+
import { L as Label } from "../../../../Label/Label.js";
|
|
9
|
+
import { H as HelperError } from "../../../../HelperError/HelperError.js";
|
|
10
|
+
const RHFUploadSingleFileRootStyled = styled("div", {
|
|
11
|
+
name: RHFUploadSingleFileSlots.root,
|
|
12
|
+
slot: RHFUploadSingleFileSlots.root
|
|
13
|
+
})(rhfUploadSingleFileStyles.root);
|
|
14
|
+
const LabelStyled = styled(Label, {
|
|
15
|
+
name: RHFUploadSingleFileSlots.label,
|
|
16
|
+
slot: RHFUploadSingleFileSlots.label
|
|
17
|
+
})(rhfUploadSingleFileStyles.label);
|
|
18
|
+
const HelperErrorStyled = styled(HelperError, {
|
|
19
|
+
name: RHFUploadSingleFileSlots.helperError,
|
|
20
|
+
slot: RHFUploadSingleFileSlots.helperError
|
|
21
|
+
})(rhfUploadSingleFileStyles.helperError);
|
|
22
|
+
const ContainerDropZoneStyled = styled("div", {
|
|
23
|
+
name: RHFUploadSingleFileSlots.containerDropZone,
|
|
24
|
+
slot: RHFUploadSingleFileSlots.containerDropZone
|
|
25
|
+
})(rhfUploadSingleFileStyles.containerDropZone);
|
|
26
|
+
const DropZoneStyled = styled("div", {
|
|
27
|
+
name: RHFUploadSingleFileSlots.dropZone,
|
|
28
|
+
slot: RHFUploadSingleFileSlots.dropZone
|
|
29
|
+
})(rhfUploadSingleFileStyles.dropZone);
|
|
30
|
+
styled(Image, {
|
|
31
|
+
name: RHFUploadSingleFileSlots.image,
|
|
32
|
+
slot: RHFUploadSingleFileSlots.image
|
|
33
|
+
})(rhfUploadSingleFileStyles.image);
|
|
34
|
+
const BlockContentGroupStyled = styled("div", {
|
|
35
|
+
name: RHFUploadSingleFileSlots.blockContentGroup,
|
|
36
|
+
slot: RHFUploadSingleFileSlots.blockContentGroup
|
|
37
|
+
})(rhfUploadSingleFileStyles.blockContentGroup);
|
|
38
|
+
const ContainerBlockContentStyled = styled("div", {
|
|
39
|
+
name: RHFUploadSingleFileSlots.containerBlockContent,
|
|
40
|
+
slot: RHFUploadSingleFileSlots.containerBlockContent
|
|
41
|
+
})(rhfUploadSingleFileStyles.containerBlockContent);
|
|
42
|
+
const IllustrationUploadStyled = styled(Image, {
|
|
43
|
+
name: RHFUploadSingleFileSlots.illustrationUpload,
|
|
44
|
+
slot: RHFUploadSingleFileSlots.illustrationUpload
|
|
45
|
+
})(rhfUploadSingleFileStyles.illustrationUpload);
|
|
46
|
+
const TitleStyled = styled(Typography, {
|
|
47
|
+
name: RHFUploadSingleFileSlots.title,
|
|
48
|
+
slot: RHFUploadSingleFileSlots.title
|
|
49
|
+
})(rhfUploadSingleFileStyles.title);
|
|
50
|
+
const DescriptionStyled = styled(Typography, {
|
|
51
|
+
name: RHFUploadSingleFileSlots.description,
|
|
52
|
+
slot: RHFUploadSingleFileSlots.description
|
|
53
|
+
})(rhfUploadSingleFileStyles.description);
|
|
54
|
+
const DividerStyled = styled("div", {
|
|
55
|
+
name: RHFUploadSingleFileSlots.divider,
|
|
56
|
+
slot: RHFUploadSingleFileSlots.divider
|
|
57
|
+
})(rhfUploadSingleFileStyles.divider);
|
|
58
|
+
const DividerTextStyled = styled(Typography, {
|
|
59
|
+
name: RHFUploadSingleFileSlots.dividerText,
|
|
60
|
+
slot: RHFUploadSingleFileSlots.dividerText
|
|
61
|
+
})(rhfUploadSingleFileStyles.dividerText);
|
|
62
|
+
const ButtonStyled = styled(Button, {
|
|
63
|
+
name: RHFUploadSingleFileSlots.button,
|
|
64
|
+
slot: RHFUploadSingleFileSlots.button
|
|
65
|
+
})(rhfUploadSingleFileStyles.button);
|
|
66
|
+
const ContainerPreviewStyled = styled("div", {
|
|
67
|
+
name: RHFUploadSingleFileSlots.containerPreview,
|
|
68
|
+
slot: RHFUploadSingleFileSlots.containerPreview
|
|
69
|
+
})(rhfUploadSingleFileStyles.containerPreview);
|
|
70
|
+
const ContainerNameSizeStyled = styled("div", {
|
|
71
|
+
name: RHFUploadSingleFileSlots.containerNameSize,
|
|
72
|
+
slot: RHFUploadSingleFileSlots.containerNameSize
|
|
73
|
+
})(rhfUploadSingleFileStyles.containerNameSize);
|
|
74
|
+
const ImagePreviewStyled = styled(Image, {
|
|
75
|
+
name: RHFUploadSingleFileSlots.imagePreview,
|
|
76
|
+
slot: RHFUploadSingleFileSlots.imagePreview
|
|
77
|
+
})(rhfUploadSingleFileStyles.imagePreview);
|
|
78
|
+
const NamePreviewStyled = styled(Typography, {
|
|
79
|
+
name: RHFUploadSingleFileSlots.namePreview,
|
|
80
|
+
slot: RHFUploadSingleFileSlots.namePreview
|
|
81
|
+
})(rhfUploadSingleFileStyles.namePreview);
|
|
82
|
+
const SizePreviewStyled = styled(Typography, {
|
|
83
|
+
name: RHFUploadSingleFileSlots.sizePreview,
|
|
84
|
+
slot: RHFUploadSingleFileSlots.sizePreview
|
|
85
|
+
})(rhfUploadSingleFileStyles.sizePreview);
|
|
86
|
+
const ClosePreviewStyled = styled(IconButton, {
|
|
87
|
+
name: RHFUploadSingleFileSlots.closePreview,
|
|
88
|
+
slot: RHFUploadSingleFileSlots.closePreview
|
|
89
|
+
})(rhfUploadSingleFileStyles.closePreview);
|
|
90
|
+
export {
|
|
91
|
+
BlockContentGroupStyled as B,
|
|
92
|
+
ContainerBlockContentStyled as C,
|
|
93
|
+
DescriptionStyled as D,
|
|
94
|
+
HelperErrorStyled as H,
|
|
95
|
+
IllustrationUploadStyled as I,
|
|
96
|
+
LabelStyled as L,
|
|
97
|
+
NamePreviewStyled as N,
|
|
98
|
+
RHFUploadSingleFileRootStyled as R,
|
|
99
|
+
SizePreviewStyled as S,
|
|
100
|
+
TitleStyled as T,
|
|
101
|
+
DividerStyled as a,
|
|
102
|
+
DividerTextStyled as b,
|
|
103
|
+
ButtonStyled as c,
|
|
104
|
+
ContainerPreviewStyled as d,
|
|
105
|
+
ImagePreviewStyled as e,
|
|
106
|
+
ContainerNameSizeStyled as f,
|
|
107
|
+
ClosePreviewStyled as g,
|
|
108
|
+
ContainerDropZoneStyled as h,
|
|
109
|
+
DropZoneStyled as i
|
|
110
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModuleDictionary, useEnvironment } from "@m4l/core";
|
|
3
|
+
import { C as ContainerBlockContentStyled, B as BlockContentGroupStyled, I as IllustrationUploadStyled, T as TitleStyled, D as DescriptionStyled, a as DividerStyled, b as DividerTextStyled, c as ButtonStyled } from "../../slots/RHFUploadSingleFileSlots.js";
|
|
4
|
+
import { C as COMPONENTS_DICTIONARY_KEYS } from "../../dictionary.js";
|
|
5
|
+
import { a as RHF_UPLOAD_SINGLE_FILE_CLASSES, I as ILLUSTRATION_UPLOAD } from "../../constants.js";
|
|
6
|
+
import { L as LinearProgress } from "../../../../../mui_extended/LinearProgress/index.js";
|
|
7
|
+
const BlockContent = (props) => {
|
|
8
|
+
const { value, hidden, size } = props;
|
|
9
|
+
const { getLabel } = useModuleDictionary();
|
|
10
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
11
|
+
return /* @__PURE__ */ jsxs(ContainerBlockContentStyled, { ownerState: { hidden }, children: [
|
|
12
|
+
/* @__PURE__ */ jsxs(BlockContentGroupStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.blockContentGroup, children: [
|
|
13
|
+
/* @__PURE__ */ jsx(
|
|
14
|
+
IllustrationUploadStyled,
|
|
15
|
+
{
|
|
16
|
+
ownerState: {},
|
|
17
|
+
src: `${host_static_assets}/${environment_assets}/${ILLUSTRATION_UPLOAD}`,
|
|
18
|
+
width: 100,
|
|
19
|
+
height: 100,
|
|
20
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.illustrationUpload,
|
|
21
|
+
size
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
TitleStyled,
|
|
26
|
+
{
|
|
27
|
+
ownerState: {},
|
|
28
|
+
skeletonWidth: 100,
|
|
29
|
+
variant: "bodyDens",
|
|
30
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.title,
|
|
31
|
+
size,
|
|
32
|
+
children: getLabel(COMPONENTS_DICTIONARY_KEYS.title)
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
DescriptionStyled,
|
|
37
|
+
{
|
|
38
|
+
ownerState: {},
|
|
39
|
+
skeletonWidth: 200,
|
|
40
|
+
skeletonRows: 2,
|
|
41
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.description,
|
|
42
|
+
variant: "body",
|
|
43
|
+
color: "text.secondary",
|
|
44
|
+
size,
|
|
45
|
+
children: getLabel(COMPONENTS_DICTIONARY_KEYS.description)
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx(DividerStyled, { ownerState: {}, children: /* @__PURE__ */ jsx(
|
|
49
|
+
DividerTextStyled,
|
|
50
|
+
{
|
|
51
|
+
ownerState: {},
|
|
52
|
+
skeletonWidth: 10,
|
|
53
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.dividerText,
|
|
54
|
+
variant: "bodyDens",
|
|
55
|
+
color: "text.secondary",
|
|
56
|
+
size,
|
|
57
|
+
children: getLabel(COMPONENTS_DICTIONARY_KEYS.dividerText)
|
|
58
|
+
}
|
|
59
|
+
) })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
ButtonStyled,
|
|
63
|
+
{
|
|
64
|
+
ownerState: {},
|
|
65
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.button,
|
|
66
|
+
variant: "contained",
|
|
67
|
+
color: "primary",
|
|
68
|
+
label: getLabel(COMPONENTS_DICTIONARY_KEYS.buttonText),
|
|
69
|
+
size
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
value && /* @__PURE__ */ jsx(LinearProgress, { className: RHF_UPLOAD_SINGLE_FILE_CLASSES.linearProgress, variant: "determinate", value })
|
|
73
|
+
] });
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
BlockContent as B
|
|
77
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { F as FILES_ICONS, a as RHF_UPLOAD_SINGLE_FILE_CLASSES, C as CLOSE_PREVIEW_ICON } from "../../constants.js";
|
|
3
|
+
import { d as ContainerPreviewStyled, e as ImagePreviewStyled, f as ContainerNameSizeStyled, N as NamePreviewStyled, S as SizePreviewStyled, g as ClosePreviewStyled } from "../../slots/RHFUploadSingleFileSlots.js";
|
|
4
|
+
import { useEnvironment } from "@m4l/core";
|
|
5
|
+
import { f as formatFileSize } from "../../helpers/formatFileSize.js";
|
|
6
|
+
const Preview = (props) => {
|
|
7
|
+
const { file, onChange, onClose } = props;
|
|
8
|
+
const { host_static_assets, environment_assets } = useEnvironment();
|
|
9
|
+
const icon = `${host_static_assets}/${environment_assets}/${FILES_ICONS[file.type] || FILES_ICONS["application/octet-stream"]}`;
|
|
10
|
+
const closePreviewIcon = `${host_static_assets}/${environment_assets}/${CLOSE_PREVIEW_ICON}`;
|
|
11
|
+
return /* @__PURE__ */ jsxs(ContainerPreviewStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.containerPreview, children: [
|
|
12
|
+
/* @__PURE__ */ jsx(ImagePreviewStyled, { enableIntersectionObserver: false, role: "img", "aria-label": "image-preview", ownerState: {}, src: icon, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.imagePreview }),
|
|
13
|
+
/* @__PURE__ */ jsxs(ContainerNameSizeStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.containerNameSize, children: [
|
|
14
|
+
/* @__PURE__ */ jsx(NamePreviewStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.namePreview, children: file.name }),
|
|
15
|
+
/* @__PURE__ */ jsx(SizePreviewStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.sizePreview, color: "text.secondary", children: formatFileSize(file.size) })
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ jsx(
|
|
18
|
+
ClosePreviewStyled,
|
|
19
|
+
{
|
|
20
|
+
role: "button",
|
|
21
|
+
"aria-label": "button-close-preview",
|
|
22
|
+
ownerState: {},
|
|
23
|
+
icon: closePreviewIcon,
|
|
24
|
+
className: RHF_UPLOAD_SINGLE_FILE_CLASSES.closePreview,
|
|
25
|
+
onClick: (e) => {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
onChange && onChange(null);
|
|
28
|
+
onClose();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
] });
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
Preview as P
|
|
36
|
+
};
|
package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDropzone } from "react-dropzone";
|
|
3
|
+
import { useReducer, useEffect } from "react";
|
|
4
|
+
import { h as ContainerDropZoneStyled, i as DropZoneStyled } from "../../slots/RHFUploadSingleFileSlots.js";
|
|
5
|
+
import { useHostTools, useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
6
|
+
import { C as COMPONENTS_DICTIONARY_KEYS } from "../../dictionary.js";
|
|
7
|
+
import { B as BlockContent } from "../BlockContent/BlockContent.js";
|
|
8
|
+
import { P as Preview } from "../Preview/Preview.js";
|
|
9
|
+
import { a as RHF_UPLOAD_SINGLE_FILE_CLASSES } from "../../constants.js";
|
|
10
|
+
import { u as uploadReducer } from "../../helpers/uploadReducer.js";
|
|
11
|
+
import { f as formatFileSize } from "../../helpers/formatFileSize.js";
|
|
12
|
+
import { g as getReadableFileType } from "../../helpers/getReadableFileType.js";
|
|
13
|
+
function UploadSingleFile(props) {
|
|
14
|
+
const { file, accept, onChange, maxFileSize, size } = props;
|
|
15
|
+
const { toast } = useHostTools();
|
|
16
|
+
const { getLabel } = useModuleDictionary();
|
|
17
|
+
const isSkeleton = useModuleSkeleton();
|
|
18
|
+
const [uploadState, dispatch] = useReducer(uploadReducer, {
|
|
19
|
+
progress: null,
|
|
20
|
+
preview: false,
|
|
21
|
+
validFile: false
|
|
22
|
+
});
|
|
23
|
+
const { getRootProps, getInputProps } = useDropzone({
|
|
24
|
+
multiple: false,
|
|
25
|
+
/**
|
|
26
|
+
* Maneja el evento de drop del archivo
|
|
27
|
+
*/
|
|
28
|
+
onDrop: (acceptedFiles) => {
|
|
29
|
+
try {
|
|
30
|
+
dispatch({ type: "RESET" });
|
|
31
|
+
if (acceptedFiles.length > 0) {
|
|
32
|
+
const fileAccepted = acceptedFiles[0];
|
|
33
|
+
const isValid = Object.entries(accept).some(([mimeType]) => {
|
|
34
|
+
if (mimeType === "*/*") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (fileAccepted.type === mimeType) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (mimeType.endsWith("/*") && fileAccepted.type.startsWith(mimeType.slice(0, -2))) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
const sizeAccepted = fileAccepted.size <= maxFileSize;
|
|
46
|
+
if (!isValid || !sizeAccepted) {
|
|
47
|
+
if (!isValid) {
|
|
48
|
+
toast({ title: `${getLabel(COMPONENTS_DICTIONARY_KEYS.errorFileRejected)} ${getLabel(COMPONENTS_DICTIONARY_KEYS.acceptFile)} ${getReadableFileType(Object.keys(accept)[0])}.` }, { type: "error" });
|
|
49
|
+
}
|
|
50
|
+
if (!sizeAccepted) {
|
|
51
|
+
toast({ title: `${getLabel(COMPONENTS_DICTIONARY_KEYS.errorMaxSize)} ${getLabel(COMPONENTS_DICTIONARY_KEYS.acceptSize)} ${formatFileSize(maxFileSize)}.` }, { type: "error" });
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
onChange?.(fileAccepted);
|
|
55
|
+
dispatch({ type: "SET_VALID_FILE", payload: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("Error in file drop:", error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
let interval;
|
|
65
|
+
if (uploadState.validFile && !!file) {
|
|
66
|
+
interval = setInterval(() => {
|
|
67
|
+
dispatch({ type: "SET_PROGRESS", payload: (uploadState.progress ?? 0) + 10 });
|
|
68
|
+
if (uploadState.progress !== null && uploadState.progress >= 100) {
|
|
69
|
+
clearInterval(interval);
|
|
70
|
+
dispatch({ type: "SET_PROGRESS", payload: null });
|
|
71
|
+
dispatch({ type: "SET_PREVIEW", payload: true });
|
|
72
|
+
}
|
|
73
|
+
}, 100);
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
if (interval) {
|
|
77
|
+
clearInterval(interval);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [file, uploadState.progress, uploadState.validFile]);
|
|
81
|
+
return /* @__PURE__ */ jsx(ContainerDropZoneStyled, { ownerState: {}, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.containerDropZone, children: /* @__PURE__ */ jsxs(DropZoneStyled, { ...getRootProps(), ownerState: { isSkeleton }, className: RHF_UPLOAD_SINGLE_FILE_CLASSES.dropZone, children: [
|
|
82
|
+
/* @__PURE__ */ jsx(BlockContent, { value: uploadState.progress, hidden: uploadState.preview, size }),
|
|
83
|
+
uploadState.preview && !!file && /* @__PURE__ */ jsx(Preview, { uploadProgress: uploadState.progress, file, onChange, onClose: () => dispatch({ type: "RESET" }), size }),
|
|
84
|
+
!isSkeleton && /* @__PURE__ */ jsx("input", { role: "button", "aria-label": "button-upload-single-file", ...getInputProps() })
|
|
85
|
+
] }) });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
UploadSingleFile as U
|
|
89
|
+
};
|
package/components/hook-form/RHFUpload/RHFUploadSingleFile/subcomponents/UploadSingleFile/types.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DropzoneProps } from 'react-dropzone/.';
|
|
2
|
+
import { Accept } from 'react-dropzone';
|
|
3
|
+
import { RHFUploadSingleFileProps } from '../../types';
|
|
4
|
+
export interface UploadSingleFileProps extends Omit<DropzoneProps, 'accept'>, Pick<RHFUploadSingleFileProps, 'size'> {
|
|
5
|
+
/**
|
|
6
|
+
* Archivo seleccionado
|
|
7
|
+
*/
|
|
8
|
+
file: File | null;
|
|
9
|
+
/**
|
|
10
|
+
* Función para cambiar el archivo seleccionado
|
|
11
|
+
*/
|
|
12
|
+
onChange?: (file: File | null) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Tamaño máximo del archivo
|
|
15
|
+
*/
|
|
16
|
+
maxFileSize: number;
|
|
17
|
+
/**
|
|
18
|
+
* Tipos de archivos aceptados
|
|
19
|
+
*/
|
|
20
|
+
accept: Accept;
|
|
21
|
+
}
|
|
22
|
+
export interface UploadState {
|
|
23
|
+
progress: number | null;
|
|
24
|
+
preview: boolean;
|
|
25
|
+
validFile: boolean;
|
|
26
|
+
}
|
|
27
|
+
export type UploadAction = {
|
|
28
|
+
type: 'SET_PROGRESS';
|
|
29
|
+
payload: number | null;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'SET_PREVIEW';
|
|
32
|
+
payload: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'SET_VALID_FILE';
|
|
35
|
+
payload: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'RESET';
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
2
|
+
import { M4LOverridesStyleRules } from '../../../../@types/augmentations';
|
|
3
|
+
import { RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT } from './constants';
|
|
4
|
+
import { RHFUploadSingleFileSlots } from './slots/RHFUploadSingleFileEnum';
|
|
5
|
+
import { LabelProps } from '../../../Label/types';
|
|
6
|
+
import { Sizes } from '@m4l/styles';
|
|
7
|
+
export interface RHFUploadSingleFileProps extends Omit<LabelProps, 'size' | 'error' | 'disabled' | 'children'> {
|
|
8
|
+
/**
|
|
9
|
+
* Nombre del campo del formulario usado en react-hook-form.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Identificador único para el componente.
|
|
14
|
+
*/
|
|
15
|
+
dataTestId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Tamaño del componente.
|
|
18
|
+
*/
|
|
19
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
20
|
+
/**
|
|
21
|
+
* Clase CSS personalizada.
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Variante del componente.
|
|
26
|
+
*/
|
|
27
|
+
variant?: 'standard';
|
|
28
|
+
/**
|
|
29
|
+
* Tamaño máximo del archivo en bytes.
|
|
30
|
+
*/
|
|
31
|
+
maxFileSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Tipos de archivos aceptados.
|
|
34
|
+
*/
|
|
35
|
+
accept?: string;
|
|
36
|
+
}
|
|
37
|
+
export type RHFUploadSingleFileSlotsType = keyof typeof RHFUploadSingleFileSlots;
|
|
38
|
+
export type RHFUploadSingleFileOwnerState = Pick<RHFUploadSingleFileProps, 'size' | 'variant'> & {
|
|
39
|
+
hidden: boolean;
|
|
40
|
+
isSkeleton: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type RHFUploadSingleFileStyles = M4LOverridesStyleRules<keyof typeof RHFUploadSingleFileSlots, typeof RHF_UPLOAD_SINGLE_FILE_KEY_COMPONENT, Theme>;
|
|
@@ -13,5 +13,5 @@ export * from './RHFTextFieldPassword';
|
|
|
13
13
|
export * from './RHFPeriod';
|
|
14
14
|
export { RHFRadioGroup } from './RHFRadioGroup';
|
|
15
15
|
export { RHFNumberInput } from './RHFNumberInput/RHFNumberInput';
|
|
16
|
-
export {
|
|
16
|
+
export { RHFUploadSingleFile } from './RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile';
|
|
17
17
|
export * from './RHFUpload';
|