@hh.ru/magritte-ui-upload 4.2.5 → 4.2.7
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/FileName.js +1 -1
- package/FileName.js.map +1 -1
- package/FileView.js +1 -1
- package/FileView.js.map +1 -1
- package/FileViewWithPreview.js.map +1 -1
- package/MultiUpload.js +1 -1
- package/MultiUpload.js.map +1 -1
- package/Placeholder.js.map +1 -1
- package/SingleUpload.js +1 -1
- package/SingleUpload.js.map +1 -1
- package/Upload.js +1 -1
- package/Upload.js.map +1 -1
- package/index.css +61 -61
- package/index.js +1 -1
- package/index.mock.js.map +1 -1
- package/package.json +13 -13
- package/upload-Dpstho06.js +10 -0
- package/upload-Dpstho06.js.map +1 -0
- package/useDropActions.js.map +1 -1
- package/useDropButtons.js.map +1 -1
- package/useFilePreview.js.map +1 -1
- package/utils.js.map +1 -1
- package/upload-uOm1es2U.js +0 -10
- package/upload-uOm1es2U.js.map +0 -1
package/FileName.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
5
5
|
|
|
6
|
-
var styles = {"file-name-body":"magritte-file-name-body___PTTMc_4-2-
|
|
6
|
+
var styles = {"file-name-body":"magritte-file-name-body___PTTMc_4-2-7","fileNameBody":"magritte-file-name-body___PTTMc_4-2-7","file-name-body_medium":"magritte-file-name-body_medium___sfmmq_4-2-7","fileNameBodyMedium":"magritte-file-name-body_medium___sfmmq_4-2-7"};
|
|
7
7
|
|
|
8
8
|
const parse = (file) => {
|
|
9
9
|
const name = file.name;
|
package/FileName.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileName.js","sources":["
|
|
1
|
+
{"version":3,"file":"FileName.js","sources":["src/FileName.tsx"],"sourcesContent":["import { ReactElement } from 'react';\nimport classnames from 'classnames';\n\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './file-name.less';\n\nconst parse = (file: File): { name: string; extension: string } => {\n const name = file.name;\n const parts = name.split('.');\n if (parts.length === 1) {\n return {\n name: parts[0],\n extension: '',\n };\n }\n const extension = parts.pop();\n return {\n // -1 из-за точки\n name: name.substring(0, name.length - (extension?.length || 0) - 1),\n extension: extension || '',\n };\n};\n\ninterface FileNameProps {\n file: File;\n isSizeMedium?: boolean;\n}\n\nconst FileName = ({ file, isSizeMedium = false }: FileNameProps): ReactElement => {\n const { name, extension } = parse(file);\n return (\n <div className={classnames(styles.fileNameBody, { [styles.fileNameBodyMedium]: isSizeMedium })}>\n <Text typography=\"label-2-regular\" ellipsis Element=\"span\">\n {name}\n </Text>\n {extension && (\n <Text typography=\"label-2-regular\" Element=\"span\">\n .{extension}\n </Text>\n )}\n </div>\n );\n};\n\nexport { FileName };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAOA,MAAM,KAAK,GAAG,CAAC,IAAU,KAAyC;AAC9D,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9B,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;AACH,YAAA,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACd,YAAA,SAAS,EAAE,EAAE;SAChB,CAAC;KACL;AACD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO;;QAEH,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnE,SAAS,EAAE,SAAS,IAAI,EAAE;KAC7B,CAAC;AACN,CAAC,CAAC;AAOI,MAAA,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,KAAK,EAAiB,KAAkB;IAC7E,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,QACIA,IAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,kBAAkB,GAAG,YAAY,EAAE,CAAC,EAC1F,QAAA,EAAA,CAAAC,GAAA,CAAC,IAAI,EAAA,EAAC,UAAU,EAAC,iBAAiB,EAAC,QAAQ,EAAC,IAAA,EAAA,OAAO,EAAC,MAAM,EACrD,QAAA,EAAA,IAAI,EACF,CAAA,EACN,SAAS,KACND,IAAA,CAAC,IAAI,EAAA,EAAC,UAAU,EAAC,iBAAiB,EAAC,OAAO,EAAC,MAAM,EAC3C,QAAA,EAAA,CAAA,GAAA,EAAA,SAAS,CACR,EAAA,CAAA,CACV,CACC,EAAA,CAAA,EACR;AACN;;;;"}
|
package/FileView.js
CHANGED
|
@@ -10,7 +10,7 @@ import { FileName } from './FileName.js';
|
|
|
10
10
|
import { getUploadIcon, bytes2mb } from './utils.js';
|
|
11
11
|
import 'classnames';
|
|
12
12
|
|
|
13
|
-
var styles = {"avatar-and-info":"magritte-avatar-and-info___vt6aT_4-2-
|
|
13
|
+
var styles = {"avatar-and-info":"magritte-avatar-and-info___vt6aT_4-2-7","avatarAndInfo":"magritte-avatar-and-info___vt6aT_4-2-7","file-info-body":"magritte-file-info-body___HmfXd_4-2-7","fileInfoBody":"magritte-file-info-body___HmfXd_4-2-7","file-info-and-controls":"magritte-file-info-and-controls___61iyY_4-2-7","fileInfoAndControls":"magritte-file-info-and-controls___61iyY_4-2-7","file-info-container":"magritte-file-info-container___WFab8_4-2-7","fileInfoContainer":"magritte-file-info-container___WFab8_4-2-7","file-info":"magritte-file-info___HrqiB_4-2-7","fileInfo":"magritte-file-info___HrqiB_4-2-7","controls":"magritte-controls___WdH7A_4-2-7","divider":"magritte-divider___3-bj9_4-2-7"};
|
|
14
14
|
|
|
15
15
|
const FileView = ({ uploadType, loadedFile, preview, renderFileInfo, onFileDelete, disableCancel, 'aria-label': ariaLabel, isLast = false, }) => {
|
|
16
16
|
const isLoading = Boolean(loadedFile?.loading);
|
package/FileView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileView.js","sources":["
|
|
1
|
+
{"version":3,"file":"FileView.js","sources":["src/FileView.tsx"],"sourcesContent":["import { ReactElement, MouseEvent } from 'react';\n\nimport { Avatar } from '@hh.ru/magritte-ui-avatar';\nimport { Divider } from '@hh.ru/magritte-ui-divider';\nimport {\n CrossOutlinedSize24,\n CheckCircleOutlinedSize16,\n ExclamationTriangleOutlinedSize16,\n TrashOutlinedSize24,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\nimport { Text } from '@hh.ru/magritte-ui-typography';\nimport { FileName } from '@hh.ru/magritte-ui-upload/FileName';\nimport { UploadType, LoadedFile, RenderFileInfo } from '@hh.ru/magritte-ui-upload/types';\nimport { getUploadIcon, bytes2mb } from '@hh.ru/magritte-ui-upload/utils';\n\nimport styles from './file-view.less';\n\nexport interface FileViewProps {\n uploadType: UploadType;\n loadedFile: LoadedFile;\n renderFileInfo: RenderFileInfo;\n onFileDelete: (event: MouseEvent) => void;\n preview: string;\n 'aria-label': string;\n isLast?: boolean;\n disableCancel?: boolean;\n}\n\nconst FileView = ({\n uploadType,\n loadedFile,\n preview,\n renderFileInfo,\n onFileDelete,\n disableCancel,\n 'aria-label': ariaLabel,\n isLast = false,\n}: FileViewProps): ReactElement => {\n const isLoading = Boolean(loadedFile?.loading);\n const isInvalid = Boolean(loadedFile?.error);\n const isImageType = uploadType === 'image';\n return (\n <>\n <div className={styles.avatarAndInfo}>\n <Avatar\n mode={isImageType && !isLoading && !isInvalid ? 'image' : 'icon'}\n style=\"secondary\"\n image={preview}\n size={48}\n icon={getUploadIcon(uploadType, loadedFile, true)}\n aria-label={ariaLabel}\n />\n <div className={styles.fileInfoBody}>\n <div className={styles.fileInfoAndControls}>\n <div className={styles.fileInfoContainer}>\n <FileName file={loadedFile.data} />\n <VSpacing default={4} />\n <div className={styles.fileInfo}>\n {isInvalid && <ExclamationTriangleOutlinedSize16 initialColor=\"negative\" />}\n {isLoading && <Loader size={16} />}\n {!isInvalid && !isLoading && <CheckCircleOutlinedSize16 initialColor=\"positive\" />}\n <Text typography=\"label-4-regular\">\n {renderFileInfo({\n ...loadedFile,\n fileSizeMB: bytes2mb(loadedFile.data.size),\n })}\n </Text>\n </div>\n </div>\n <div className={styles.controls}>\n {isLoading && !disableCancel && (\n <CrossOutlinedSize24\n padding={8}\n borderRadius=\"halfHeight\"\n initialColor=\"secondary\"\n onClick={onFileDelete}\n />\n )}\n {!isLoading && (\n <TrashOutlinedSize24\n padding={8}\n borderRadius=\"halfHeight\"\n onClick={onFileDelete}\n data-qa=\"magritte-upload-delete-file-action\"\n initialColor=\"secondary\"\n />\n )}\n </div>\n </div>\n </div>\n </div>\n {!isLast && (\n <div className={styles.divider}>\n <VSpacing default={16} />\n <Divider />\n <VSpacing default={16} />\n </div>\n )}\n </>\n );\n};\n\nexport { FileView };\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AA8BM,MAAA,QAAQ,GAAG,CAAC,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EAAE,SAAS,EACvB,MAAM,GAAG,KAAK,GACF,KAAkB;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC7C,IAAA,MAAM,WAAW,GAAG,UAAU,KAAK,OAAO,CAAC;AAC3C,IAAA,QACIA,IAAA,CAAAC,QAAA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,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;qDAC7C,CAAC,EAAA,CACC,IACL,CACJ,EAAA,CAAA,EACNF,cAAK,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAA,QAAA,EAAA,CAC1B,SAAS,IAAI,CAAC,aAAa,KACxBE,IAAC,mBAAmB,EAAA,EAChB,OAAO,EAAE,CAAC,EACV,YAAY,EAAC,YAAY,EACzB,YAAY,EAAC,WAAW,EACxB,OAAO,EAAE,YAAY,EACvB,CAAA,CACL,EACA,CAAC,SAAS,KACPA,GAAC,CAAA,mBAAmB,IAChB,OAAO,EAAE,CAAC,EACV,YAAY,EAAC,YAAY,EACzB,OAAO,EAAE,YAAY,EAAA,SAAA,EACb,oCAAoC,EAC5C,YAAY,EAAC,WAAW,EAC1B,CAAA,CACL,IACC,CACJ,EAAA,CAAA,EAAA,CACJ,CACJ,EAAA,CAAA,EACL,CAAC,MAAM,KACJF,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,OAAO,EAC1B,QAAA,EAAA,CAAAE,GAAA,CAAC,QAAQ,EAAC,EAAA,OAAO,EAAE,EAAE,EAAA,CAAI,EACzBA,GAAA,CAAC,OAAO,EAAA,EAAA,CAAG,EACXA,GAAC,CAAA,QAAQ,EAAC,EAAA,OAAO,EAAE,EAAE,GAAI,CACvB,EAAA,CAAA,CACT,CACF,EAAA,CAAA,EACL;AACN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileViewWithPreview.js","sources":["
|
|
1
|
+
{"version":3,"file":"FileViewWithPreview.js","sources":["src/FileViewWithPreview.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { FileView, FileViewProps } from '@hh.ru/magritte-ui-upload/FileView';\nimport { useFilePreview } from '@hh.ru/magritte-ui-upload/useFilePreview';\nimport { getFileType } from '@hh.ru/magritte-ui-upload/utils';\n\ntype FileViewWithPreviewProps = Omit<FileViewProps, 'preview' | 'uploadType'>;\n\nconst FileViewWithPreview = ({ loadedFile, ...otherProps }: FileViewWithPreviewProps): ReactElement => {\n const uploadType = getFileType(loadedFile.data.type);\n const preview = useFilePreview({ loadedFile, isImageType: uploadType === 'image' });\n return <FileView uploadType={uploadType} loadedFile={loadedFile} preview={preview} {...otherProps} />;\n};\n\nexport { FileViewWithPreview };\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;AAQM,MAAA,mBAAmB,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,UAAU,EAA4B,KAAkB;IAClG,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,IAAA,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,KAAK,OAAO,EAAE,CAAC,CAAC;AACpF,IAAA,OAAOA,IAAC,QAAQ,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAM,GAAA,UAAU,GAAI,CAAC;AAC1G;;;;"}
|
package/MultiUpload.js
CHANGED
|
@@ -2,7 +2,7 @@ import './index.css';
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useDropzone } from 'react-dropzone';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { u as useDisabled, D as DisabledContext, s as styles } from './upload-
|
|
5
|
+
import { u as useDisabled, D as DisabledContext, s as styles } from './upload-Dpstho06.js';
|
|
6
6
|
import { VSpacing } from '@hh.ru/magritte-ui-spacing';
|
|
7
7
|
import { TextDynamic } from '@hh.ru/magritte-ui-typography';
|
|
8
8
|
import { FileViewWithPreview } from './FileViewWithPreview.js';
|
package/MultiUpload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiUpload.js","sources":["
|
|
1
|
+
{"version":3,"file":"MultiUpload.js","sources":["src/MultiUpload.tsx"],"sourcesContent":["import { ReactElement } from 'react';\nimport { useDropzone } from 'react-dropzone';\nimport classnames from 'classnames';\n\nimport { DisabledContext, useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\nimport { TextDynamic } from '@hh.ru/magritte-ui-typography';\nimport { FileViewWithPreview } from '@hh.ru/magritte-ui-upload/FileViewWithPreview';\nimport { Placeholder } from '@hh.ru/magritte-ui-upload/Placeholder';\nimport { UploadProps } from '@hh.ru/magritte-ui-upload/types';\nimport { useDropActions } from '@hh.ru/magritte-ui-upload/useDropActions';\nimport { useDropButtons } from '@hh.ru/magritte-ui-upload/useDropButtons';\nimport {\n getUploadIcon,\n getAvaliableFileTypes,\n RenderFileInfoDefault,\n DEFAULT_ACCEPT,\n} from '@hh.ru/magritte-ui-upload/utils';\n\nimport styles from './upload.less';\n\nconst MultiUpload = ({\n files,\n trls,\n size,\n disableCancel,\n accept = DEFAULT_ACCEPT,\n selectFileButton: _selectFileButton,\n renderFileInfo = RenderFileInfoDefault,\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n disabled,\n 'aria-label': ariaLabel,\n ...dropzoneProps\n}: Omit<UploadProps, 'multiple'>): ReactElement => {\n const uploadType = getAvaliableFileTypes(accept);\n const contextDisabled = useDisabled();\n const isDisabled = disabled || contextDisabled;\n const { onDropAccepted, onDropRejected, onFileDelete } = useDropActions({\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n });\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n ...dropzoneProps,\n disabled: isDisabled,\n accept,\n onDropAccepted,\n onDropRejected,\n multiple: true,\n });\n const { selectFileButton } = useDropButtons({ selectFileButton: _selectFileButton });\n\n return (\n <>\n <DisabledContext.Provider value={isDisabled}>\n <div\n className={classnames(styles.root, styles[`root_${size}`], {\n [styles.dragActive]: isDragActive && !isDisabled,\n [styles.disabled]: isDisabled,\n })}\n {...getRootProps()}\n data-qa=\"magritte-multiple-upload\"\n >\n <input {...getInputProps()} data-qa=\"magritte-multiple-upload-input\" disabled={isDisabled} />\n <div className={styles.background} />\n <TextDynamic className={styles.body}>\n {getUploadIcon(uploadType, undefined, false)}\n <VSpacing default={16} />\n <Placeholder trls={trls} selectFileButton={selectFileButton} />\n </TextDynamic>\n </div>\n </DisabledContext.Provider>\n {files.length > 0 && (\n <div className={styles.fileList}>\n {files.map((loadedFile, indexFile) => {\n return (\n <FileViewWithPreview\n key={`${loadedFile.data.name}${loadedFile.data.size}${loadedFile.data.lastModified}`}\n loadedFile={loadedFile}\n renderFileInfo={renderFileInfo}\n onFileDelete={(event) => {\n onFileDelete(event, loadedFile, indexFile);\n }}\n aria-label={ariaLabel || ''}\n disableCancel={disableCancel}\n isLast={files.length - 1 === indexFile}\n />\n );\n })}\n </div>\n )}\n </>\n );\n};\n\nexport { MultiUpload };\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBM,MAAA,WAAW,GAAG,CAAC,EACjB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,MAAM,GAAG,cAAc,EACvB,gBAAgB,EAAE,iBAAiB,EACnC,cAAc,GAAG,qBAAqB,EACtC,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,oBAAoB,EAClC,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,GAAG,aAAa,EACY,KAAkB;AAC9C,IAAA,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACjD,IAAA,MAAM,eAAe,GAAG,WAAW,EAAE,CAAC;AACtC,IAAA,MAAM,UAAU,GAAG,QAAQ,IAAI,eAAe,CAAC;IAC/C,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;AACpE,QAAA,cAAc,EAAE,sB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AAA,CAAC,WAAW,EAAC,EAAA,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CACrD,EAAA,CAAA,CAAA,EAAA,CACZ,GACiB,EAC1B,KAAK,CAAC,MAAM,GAAG,CAAC,KACbA,aAAK,SAAS,EAAE,MAAM,CAAC,QAAQ,YAC1B,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,SAAS,KAAI;AACjC,oBAAA,QACIA,GAAC,CAAA,mBAAmB,EAEhB,EAAA,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,CAAC,KAAK,KAAI;AACpB,4BAAA,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAC/C,yBAAC,gBACW,SAAS,IAAI,EAAE,EAC3B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,SAAS,EARjC,EAAA,CAAA,EAAG,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAG,EAAA,UAAU,CAAC,IAAI,CAAC,YAAY,CAAE,CAAA,CAStF,EACJ;AACN,iBAAC,CAAC,EAAA,CACA,CACT,CAAA,EAAA,CACF,EACL;AACN;;;;"}
|
package/Placeholder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Placeholder.js","sources":["
|
|
1
|
+
{"version":3,"file":"Placeholder.js","sources":["src/Placeholder.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { ButtonElement } from '@hh.ru/magritte-ui-button-stack';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\nimport { Text } from '@hh.ru/magritte-ui-typography';\nimport { UploadTrls } from '@hh.ru/magritte-ui-upload/types';\n\ninterface PlaceholderProps {\n trls: UploadTrls;\n selectFileButton?: ButtonElement;\n}\n\nconst Placeholder = ({ trls, selectFileButton }: PlaceholderProps): ReactElement => {\n const { isMobile } = useBreakpoint();\n const { title, titleMobile, subTitle } = trls;\n return (\n <>\n <Text typography=\"label-2-regular\">{isMobile ? titleMobile || title : title}</Text>\n <VSpacing default={6} />\n <Text typography=\"label-4-regular\" style=\"secondary\">\n {subTitle}\n </Text>\n {selectFileButton && (\n <>\n <VSpacing default={16} />\n {selectFileButton}\n </>\n )}\n </>\n );\n};\n\nexport { Placeholder };\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;AAaM,MAAA,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAoB,KAAkB;AAC/E,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;AAC9C,IAAA,QACIA,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACIC,GAAC,CAAA,IAAI,EAAC,EAAA,UAAU,EAAC,iBAAiB,EAAE,QAAA,EAAA,QAAQ,GAAG,WAAW,IAAI,KAAK,GAAG,KAAK,EAAQ,CAAA,EACnFA,GAAC,CAAA,QAAQ,EAAC,EAAA,OAAO,EAAE,CAAC,EAAI,CAAA,EACxBA,GAAC,CAAA,IAAI,EAAC,EAAA,UAAU,EAAC,iBAAiB,EAAC,KAAK,EAAC,WAAW,EAC/C,QAAA,EAAA,QAAQ,EACN,CAAA,EACN,gBAAgB,KACbF,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACIC,GAAC,CAAA,QAAQ,EAAC,EAAA,OAAO,EAAE,EAAE,EAAI,CAAA,EACxB,gBAAgB,CAAA,EAAA,CAClB,CACN,CAAA,EAAA,CACF,EACL;AACN;;;;"}
|
package/SingleUpload.js
CHANGED
|
@@ -2,7 +2,7 @@ import './index.css';
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useDropzone } from 'react-dropzone';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { u as useDisabled, D as DisabledContext, s as styles } from './upload-
|
|
5
|
+
import { u as useDisabled, D as DisabledContext, s as styles } from './upload-Dpstho06.js';
|
|
6
6
|
import { Avatar } from '@hh.ru/magritte-ui-avatar';
|
|
7
7
|
import { CrossOutlinedSize24, ExclamationTriangleOutlinedSize32 } from '@hh.ru/magritte-ui-icon/icon';
|
|
8
8
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
package/SingleUpload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleUpload.js","sources":["../src/SingleUpload.tsx"],"sourcesContent":["import { ReactElement, MouseEvent } from 'react';\nimport { useDropzone } from 'react-dropzone';\nimport classnames from 'classnames';\n\nimport { DisabledContext, useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { Avatar } from '@hh.ru/magritte-ui-avatar';\nimport { CrossOutlinedSize24, ExclamationTriangleOutlinedSize32 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\nimport { Text, TextDynamic } from '@hh.ru/magritte-ui-typography';\nimport { FileName } from '@hh.ru/magritte-ui-upload/FileName';\nimport { FileView } from '@hh.ru/magritte-ui-upload/FileView';\nimport { Placeholder } from '@hh.ru/magritte-ui-upload/Placeholder';\nimport { UploadProps } from '@hh.ru/magritte-ui-upload/types';\nimport { useDropActions } from '@hh.ru/magritte-ui-upload/useDropActions';\nimport { useDropButtons } from '@hh.ru/magritte-ui-upload/useDropButtons';\nimport { useFilePreview } from '@hh.ru/magritte-ui-upload/useFilePreview';\nimport {\n getUploadIcon,\n bytes2mb,\n getAvaliableFileTypes,\n RenderFileInfoDefault,\n DEFAULT_ACCEPT,\n} from '@hh.ru/magritte-ui-upload/utils';\n\nimport styles from './upload.less';\n\nconst SingleUpload = ({\n files,\n trls,\n size = 'medium',\n accept = DEFAULT_ACCEPT,\n disableCancel,\n selectFileButton: _selectFileButton,\n deleteFileButton: _deleteFileButton,\n replaceImageButton: _replaceImageButton,\n renderFileInfo = RenderFileInfoDefault,\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n 'aria-label': ariaLabel,\n disabled,\n ...dropzoneProps\n}: UploadProps): ReactElement => {\n const uploadType = getAvaliableFileTypes(accept);\n const loadedFile = files.length > 0 ? files[0] : undefined;\n const isLoad = Boolean(loadedFile);\n const isLoading = Boolean(loadedFile?.loading);\n const isInvalid = Boolean(loadedFile?.error);\n const isSizeSmall = size === 'small';\n const isImageType = uploadType === 'image';\n const preview = useFilePreview({ loadedFile, isImageType });\n const usePreview = preview !== 'none';\n const contextDisabled = useDisabled();\n const isDisabled = disabled || contextDisabled;\n\n const { onDropAccepted, onDropRejected, onFileDelete } = useDropActions({\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n });\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n ...dropzoneProps,\n disabled: isDisabled,\n accept,\n onDropAccepted,\n onDropRejected,\n multiple: false,\n });\n\n const { selectFileButton, deleteFileButton, replaceImageButton } = useDropButtons({\n selectFileButton: _selectFileButton,\n deleteFileButton: _deleteFileButton,\n replaceImageButton: _replaceImageButton,\n onFileDelete: (event: MouseEvent) => {\n onFileDelete(event, loadedFile, 0);\n },\n });\n\n const backgroundStyles = !isSizeSmall\n ? { backgroundImage: preview !== 'none' ? `url('${preview}')` : preview }\n : {};\n return (\n <DisabledContext.Provider value={isDisabled}>\n <div\n className={classnames(styles.root, styles[`root_${size}`], {\n [styles.dragActive]: isDragActive && isDisabled,\n [styles.loading]: isLoading,\n [styles.load]: isLoad,\n [styles.invalid]: isInvalid,\n [styles.disabled]: isDisabled,\n })}\n {...getRootProps()}\n data-qa=\"magritte-single-upload\"\n >\n <input {...getInputProps()} data-qa=\"magritte-single-upload-input\" disabled={isDisabled} />\n <div\n className={styles.background}\n style={backgroundStyles}\n data-qa=\"magritte-single-upload-background\"\n />\n <TextDynamic className={classnames(styles.body, { [styles.disabled]: isDisabled })}>\n {isSizeSmall && (\n <>\n {loadedFile && (\n <FileView\n uploadType={uploadType}\n loadedFile={loadedFile}\n renderFileInfo={renderFileInfo}\n onFileDelete={(event) => {\n onFileDelete(event, loadedFile, 0);\n }}\n preview={preview}\n disableCancel={disableCancel}\n aria-label={ariaLabel || ''}\n isLast\n />\n )}\n {!loadedFile && (\n <>\n <Avatar\n mode=\"icon\"\n style=\"secondary\"\n size={48}\n icon={getUploadIcon(uploadType, loadedFile, true)}\n aria-label={ariaLabel || ''}\n />\n <div className={styles.singleSmallPlaceholer}>\n <Text typography=\"label-2-regular\">{trls.title}</Text>\n <VSpacing default={4} />\n <Text typography=\"label-4-regular\" style=\"secondary\">\n {trls.subTitle}\n </Text>\n </div>\n {selectFileButton && <div className={styles.smallControls}>{selectFileButton}</div>}\n </>\n )}\n </>\n )}\n {!isSizeSmall && (\n <>\n {isLoading && (\n <>\n <VSpacing default={12} />\n <div className={styles.loader}>\n <Loader size={64} />\n {!disableCancel && (\n <div className={styles.cancel}>\n <CrossOutlinedSize24\n initialColor=\"accent\"\n onClick={(event) => {\n onFileDelete(event, loadedFile, 0);\n }}\n />\n </div>\n )}\n </div>\n </>\n )}\n {isInvalid ? (\n <ExclamationTriangleOutlinedSize32 initialColor=\"negative\" />\n ) : (\n <span className={classnames(styles.fileIcon, { [styles.hiddenFileInfo]: usePreview })}>\n {getUploadIcon(uploadType, loadedFile, false)}\n </span>\n )}\n <VSpacing default={16} />\n {loadedFile && (\n <>\n <div\n className={classnames(styles.fileInfo, { [styles.hiddenFileInfo]: usePreview })}\n >\n <FileName file={loadedFile.data} isSizeMedium />\n <VSpacing default={6} />\n <Text typography=\"label-4-regular\" style=\"secondary\">\n {renderFileInfo({\n ...loadedFile,\n fileSizeMB: bytes2mb(loadedFile.data.size),\n })}\n </Text>\n </div>\n {!isLoading && (!isImageType || isInvalid) && deleteFileButton && (\n <>\n <VSpacing default={16} />\n {deleteFileButton}\n </>\n )}\n {!isLoading &&\n isImageType &&\n !isInvalid &&\n (replaceImageButton || deleteFileButton) && (\n <>\n <VSpacing default={16} />\n <div className={styles.imageControls}>\n {replaceImageButton}\n {deleteFileButton}\n </div>\n </>\n )}\n {isLoading && <VSpacing default={12} />}\n </>\n )}\n {!loadedFile && <Placeholder trls={trls} selectFileButton={selectFileButton} />}\n </>\n )}\n </TextDynamic>\n </div>\n </DisabledContext.Provider>\n );\n};\n\nexport { SingleUpload };\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BM,MAAA,YAAY,GAAG,CAAC,EAClB,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,QAAQ,EACf,MAAM,GAAG,cAAc,EACvB,aAAa,EACb,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,EAAE,iBAAiB,EACnC,kBAAkB,EAAE,mBAAmB,EACvC,cAAc,GAAG,qBAAqB,EACtC,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,oBAAoB,EAClC,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,GAAG,aAAa,EACN,KAAkB;AAC5B,IAAA,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACjD,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAC3D,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC7C,IAAA,MAAM,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SAAS,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,gBAAgB,KAC1DC,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACIF,GAAC,CAAA,QAAQ,EAAC,EAAA,OAAO,EAAE,EAAE,EAAI,CAAA,EACxB,gBAAgB,CAAA,EAAA,CAClB,CACN,EACA,CAAC,SAAS;4CACP,WAAW;AACX,4CAAA,CAAC,SAAS;AACV,6CAAC,kBAAkB,IAAI,gBAAgB,CAAC,KACpCC,IACI,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAF,GAAA,CAAC,QAAQ,EAAA,EAAC,OAAO,EAAE,EAAE,EAAA,CAAI,EACzBC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,aAAa,EAAA,QAAA,EAAA,CAC/B,kBAAkB,EAClB,gBAAgB,CAAA,EAAA,CACf,CACP,EAAA,CAAA,CACN,EACJ,SAAS,IAAID,GAAA,CAAC,QAAQ,EAAA,EAAC,OAAO,EAAE,EAAE,EAAA,CAAI,CACxC,EAAA,CAAA,CACN,EACA,CAAC,UAAU,IAAIA,GAAC,CAAA,WAAW,EAAC,EAAA,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,EAAI,CAAA,CAAA,EAAA,CAChF,CACN,CAAA,EAAA,CACS,CACZ,EAAA,CAAA,EAAA,CACiB,EAC7B;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"SingleUpload.js","sources":["src/SingleUpload.tsx"],"sourcesContent":["import { ReactElement, MouseEvent } from 'react';\nimport { useDropzone } from 'react-dropzone';\nimport classnames from 'classnames';\n\nimport { DisabledContext, useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { Avatar } from '@hh.ru/magritte-ui-avatar';\nimport { CrossOutlinedSize24, ExclamationTriangleOutlinedSize32 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\nimport { Text, TextDynamic } from '@hh.ru/magritte-ui-typography';\nimport { FileName } from '@hh.ru/magritte-ui-upload/FileName';\nimport { FileView } from '@hh.ru/magritte-ui-upload/FileView';\nimport { Placeholder } from '@hh.ru/magritte-ui-upload/Placeholder';\nimport { UploadProps } from '@hh.ru/magritte-ui-upload/types';\nimport { useDropActions } from '@hh.ru/magritte-ui-upload/useDropActions';\nimport { useDropButtons } from '@hh.ru/magritte-ui-upload/useDropButtons';\nimport { useFilePreview } from '@hh.ru/magritte-ui-upload/useFilePreview';\nimport {\n getUploadIcon,\n bytes2mb,\n getAvaliableFileTypes,\n RenderFileInfoDefault,\n DEFAULT_ACCEPT,\n} from '@hh.ru/magritte-ui-upload/utils';\n\nimport styles from './upload.less';\n\nconst SingleUpload = ({\n files,\n trls,\n size = 'medium',\n accept = DEFAULT_ACCEPT,\n disableCancel,\n selectFileButton: _selectFileButton,\n deleteFileButton: _deleteFileButton,\n replaceImageButton: _replaceImageButton,\n renderFileInfo = RenderFileInfoDefault,\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n 'aria-label': ariaLabel,\n disabled,\n ...dropzoneProps\n}: UploadProps): ReactElement => {\n const uploadType = getAvaliableFileTypes(accept);\n const loadedFile = files.length > 0 ? files[0] : undefined;\n const isLoad = Boolean(loadedFile);\n const isLoading = Boolean(loadedFile?.loading);\n const isInvalid = Boolean(loadedFile?.error);\n const isSizeSmall = size === 'small';\n const isImageType = uploadType === 'image';\n const preview = useFilePreview({ loadedFile, isImageType });\n const usePreview = preview !== 'none';\n const contextDisabled = useDisabled();\n const isDisabled = disabled || contextDisabled;\n\n const { onDropAccepted, onDropRejected, onFileDelete } = useDropActions({\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n });\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n ...dropzoneProps,\n disabled: isDisabled,\n accept,\n onDropAccepted,\n onDropRejected,\n multiple: false,\n });\n\n const { selectFileButton, deleteFileButton, replaceImageButton } = useDropButtons({\n selectFileButton: _selectFileButton,\n deleteFileButton: _deleteFileButton,\n replaceImageButton: _replaceImageButton,\n onFileDelete: (event: MouseEvent) => {\n onFileDelete(event, loadedFile, 0);\n },\n });\n\n const backgroundStyles = !isSizeSmall\n ? { backgroundImage: preview !== 'none' ? `url('${preview}')` : preview }\n : {};\n return (\n <DisabledContext.Provider value={isDisabled}>\n <div\n className={classnames(styles.root, styles[`root_${size}`], {\n [styles.dragActive]: isDragActive && isDisabled,\n [styles.loading]: isLoading,\n [styles.load]: isLoad,\n [styles.invalid]: isInvalid,\n [styles.disabled]: isDisabled,\n })}\n {...getRootProps()}\n data-qa=\"magritte-single-upload\"\n >\n <input {...getInputProps()} data-qa=\"magritte-single-upload-input\" disabled={isDisabled} />\n <div\n className={styles.background}\n style={backgroundStyles}\n data-qa=\"magritte-single-upload-background\"\n />\n <TextDynamic className={classnames(styles.body, { [styles.disabled]: isDisabled })}>\n {isSizeSmall && (\n <>\n {loadedFile && (\n <FileView\n uploadType={uploadType}\n loadedFile={loadedFile}\n renderFileInfo={renderFileInfo}\n onFileDelete={(event) => {\n onFileDelete(event, loadedFile, 0);\n }}\n preview={preview}\n disableCancel={disableCancel}\n aria-label={ariaLabel || ''}\n isLast\n />\n )}\n {!loadedFile && (\n <>\n <Avatar\n mode=\"icon\"\n style=\"secondary\"\n size={48}\n icon={getUploadIcon(uploadType, loadedFile, true)}\n aria-label={ariaLabel || ''}\n />\n <div className={styles.singleSmallPlaceholer}>\n <Text typography=\"label-2-regular\">{trls.title}</Text>\n <VSpacing default={4} />\n <Text typography=\"label-4-regular\" style=\"secondary\">\n {trls.subTitle}\n </Text>\n </div>\n {selectFileButton && <div className={styles.smallControls}>{selectFileButton}</div>}\n </>\n )}\n </>\n )}\n {!isSizeSmall && (\n <>\n {isLoading && (\n <>\n <VSpacing default={12} />\n <div className={styles.loader}>\n <Loader size={64} />\n {!disableCancel && (\n <div className={styles.cancel}>\n <CrossOutlinedSize24\n initialColor=\"accent\"\n onClick={(event) => {\n onFileDelete(event, loadedFile, 0);\n }}\n />\n </div>\n )}\n </div>\n </>\n )}\n {isInvalid ? (\n <ExclamationTriangleOutlinedSize32 initialColor=\"negative\" />\n ) : (\n <span className={classnames(styles.fileIcon, { [styles.hiddenFileInfo]: usePreview })}>\n {getUploadIcon(uploadType, loadedFile, false)}\n </span>\n )}\n <VSpacing default={16} />\n {loadedFile && (\n <>\n <div\n className={classnames(styles.fileInfo, { [styles.hiddenFileInfo]: usePreview })}\n >\n <FileName file={loadedFile.data} isSizeMedium />\n <VSpacing default={6} />\n <Text typography=\"label-4-regular\" style=\"secondary\">\n {renderFileInfo({\n ...loadedFile,\n fileSizeMB: bytes2mb(loadedFile.data.size),\n })}\n </Text>\n </div>\n {!isLoading && (!isImageType || isInvalid) && deleteFileButton && (\n <>\n <VSpacing default={16} />\n {deleteFileButton}\n </>\n )}\n {!isLoading &&\n isImageType &&\n !isInvalid &&\n (replaceImageButton || deleteFileButton) && (\n <>\n <VSpacing default={16} />\n <div className={styles.imageControls}>\n {replaceImageButton}\n {deleteFileButton}\n </div>\n </>\n )}\n {isLoading && <VSpacing default={12} />}\n </>\n )}\n {!loadedFile && <Placeholder trls={trls} selectFileButton={selectFileButton} />}\n </>\n )}\n </TextDynamic>\n </div>\n </DisabledContext.Provider>\n );\n};\n\nexport { SingleUpload };\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BM,MAAA,YAAY,GAAG,CAAC,EAClB,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,QAAQ,EACf,MAAM,GAAG,cAAc,EACvB,aAAa,EACb,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,EAAE,iBAAiB,EACnC,kBAAkB,EAAE,mBAAmB,EACvC,cAAc,GAAG,qBAAqB,EACtC,cAAc,EAAE,sBAAsB,EACtC,cA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IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,EAAI,CAAA,CAAA,EAAA,CAChF,CACN,CAAA,EAAA,CACS,CACZ,EAAA,CAAA,EAAA,CACiB,EAC7B;AACN;;;;"}
|
package/Upload.js
CHANGED
|
@@ -4,7 +4,7 @@ import { MultiUpload } from './MultiUpload.js';
|
|
|
4
4
|
import { SingleUpload } from './SingleUpload.js';
|
|
5
5
|
import 'react-dropzone';
|
|
6
6
|
import 'classnames';
|
|
7
|
-
import './upload-
|
|
7
|
+
import './upload-Dpstho06.js';
|
|
8
8
|
import 'react';
|
|
9
9
|
import '@hh.ru/magritte-ui-spacing';
|
|
10
10
|
import '@hh.ru/magritte-ui-typography';
|
package/Upload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Upload.js","sources":["
|
|
1
|
+
{"version":3,"file":"Upload.js","sources":["src/Upload.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { MultiUpload } from '@hh.ru/magritte-ui-upload/MultiUpload';\nimport { SingleUpload } from '@hh.ru/magritte-ui-upload/SingleUpload';\nimport { UploadProps } from '@hh.ru/magritte-ui-upload/types';\n\nexport const Upload = ({\n multiple,\n noDragEventsBubbling = true,\n disableCancel = false,\n size,\n ...uploadProps\n}: UploadProps): ReactElement => {\n const Component = multiple && size === 'medium' ? MultiUpload : SingleUpload;\n\n return (\n <Component\n noDragEventsBubbling={noDragEventsBubbling}\n {...uploadProps}\n size={size}\n disableCancel={disableCancel}\n />\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAMa,MAAM,GAAG,CAAC,EACnB,QAAQ,EACR,oBAAoB,GAAG,IAAI,EAC3B,aAAa,GAAG,KAAK,EACrB,IAAI,EACJ,GAAG,WAAW,EACJ,KAAkB;AAC5B,IAAA,MAAM,SAAS,GAAG,QAAQ,IAAI,IAAI,KAAK,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AAE7E,IAAA,QACIA,GAAC,CAAA,SAAS,IACN,oBAAoB,EAAE,oBAAoB,EACtC,GAAA,WAAW,EACf,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,aAAa,EAAA,CAC9B,EACJ;AACN;;;;"}
|
package/index.css
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
.magritte-file-name-body___PTTMc_4-2-
|
|
1
|
+
.magritte-file-name-body___PTTMc_4-2-7{
|
|
2
2
|
display:flex;
|
|
3
3
|
width:100%;
|
|
4
4
|
overflow:hidden;
|
|
5
5
|
}
|
|
6
|
-
.magritte-file-name-body_medium___sfmmq_4-2-
|
|
6
|
+
.magritte-file-name-body_medium___sfmmq_4-2-7{
|
|
7
7
|
justify-content:center;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.magritte-avatar-and-info___vt6aT_4-2-
|
|
10
|
+
.magritte-avatar-and-info___vt6aT_4-2-7{
|
|
11
11
|
display:flex;
|
|
12
12
|
gap:16px;
|
|
13
13
|
width:100%;
|
|
14
14
|
}
|
|
15
|
-
.magritte-file-info-body___HmfXd_4-2-
|
|
15
|
+
.magritte-file-info-body___HmfXd_4-2-7{
|
|
16
16
|
display:flex;
|
|
17
17
|
flex-grow:1;
|
|
18
18
|
flex-direction:column;
|
|
19
19
|
}
|
|
20
|
-
.magritte-file-info-and-controls___61iyY_4-2-
|
|
20
|
+
.magritte-file-info-and-controls___61iyY_4-2-7{
|
|
21
21
|
display:flex;
|
|
22
22
|
gap:16px;
|
|
23
23
|
flex-grow:1;
|
|
24
24
|
}
|
|
25
|
-
.magritte-file-info-container___WFab8_4-2-
|
|
25
|
+
.magritte-file-info-container___WFab8_4-2-7{
|
|
26
26
|
flex-grow:1;
|
|
27
27
|
display:flex;
|
|
28
28
|
flex-direction:column;
|
|
29
29
|
justify-content:center;
|
|
30
30
|
width:50px;
|
|
31
31
|
}
|
|
32
|
-
.magritte-file-info___HrqiB_4-2-
|
|
32
|
+
.magritte-file-info___HrqiB_4-2-7{
|
|
33
33
|
display:flex;
|
|
34
34
|
gap:4px;
|
|
35
35
|
align-items:center;
|
|
36
36
|
}
|
|
37
|
-
.magritte-controls___WdH7A_4-2-
|
|
37
|
+
.magritte-controls___WdH7A_4-2-7{
|
|
38
38
|
display:flex;
|
|
39
39
|
align-items:center;
|
|
40
40
|
margin-left:auto;
|
|
41
41
|
margin-right:16px;
|
|
42
42
|
}
|
|
43
|
-
.magritte-divider___3-bj9_4-2-
|
|
43
|
+
.magritte-divider___3-bj9_4-2-7{
|
|
44
44
|
margin-left:64px;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
:root{
|
|
48
|
-
--magritte-color-background-primary-v24-4-
|
|
49
|
-
--magritte-color-background-state-primary-disabled-v24-4-
|
|
50
|
-
--magritte-color-stroke-neutral-v24-4-
|
|
51
|
-
--magritte-color-stroke-accent-v24-4-
|
|
52
|
-
--magritte-color-stroke-state-focused-accessible-v24-4-
|
|
53
|
-
--magritte-color-stroke-state-neutral-disabled-v24-4-
|
|
54
|
-
--magritte-color-component-input-stroke-state-negative-focused-accessible-v24-4-
|
|
48
|
+
--magritte-color-background-primary-v24-4-1:#ffffff;
|
|
49
|
+
--magritte-color-background-state-primary-disabled-v24-4-1:#ffffff7a;
|
|
50
|
+
--magritte-color-stroke-neutral-v24-4-1:#DCE3EB;
|
|
51
|
+
--magritte-color-stroke-accent-v24-4-1:#0070ff;
|
|
52
|
+
--magritte-color-stroke-state-focused-accessible-v24-4-1:#0070ff7a;
|
|
53
|
+
--magritte-color-stroke-state-neutral-disabled-v24-4-1:#dce3eb7a;
|
|
54
|
+
--magritte-color-component-input-stroke-state-negative-focused-accessible-v24-4-1:#ff4d3a7a;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.magritte-night-theme{
|
|
58
|
-
--magritte-color-background-primary-v24-4-
|
|
59
|
-
--magritte-color-background-state-primary-disabled-v24-4-
|
|
60
|
-
--magritte-color-stroke-neutral-v24-4-
|
|
61
|
-
--magritte-color-stroke-accent-v24-4-
|
|
62
|
-
--magritte-color-stroke-state-neutral-disabled-v24-4-
|
|
58
|
+
--magritte-color-background-primary-v24-4-1:#1B1B1B;
|
|
59
|
+
--magritte-color-background-state-primary-disabled-v24-4-1:#1b1b1b7a;
|
|
60
|
+
--magritte-color-stroke-neutral-v24-4-1:#303030;
|
|
61
|
+
--magritte-color-stroke-accent-v24-4-1:#2b7fff;
|
|
62
|
+
--magritte-color-stroke-state-neutral-disabled-v24-4-1:#3030307a;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.magritte-zp-day-theme{
|
|
66
|
-
--magritte-color-stroke-accent-v24-4-
|
|
66
|
+
--magritte-color-stroke-accent-v24-4-1:#7195AF;
|
|
67
67
|
}
|
|
68
|
-
.magritte-root___FV1tC_4-2-
|
|
68
|
+
.magritte-root___FV1tC_4-2-7{
|
|
69
69
|
position:relative;
|
|
70
70
|
display:flex;
|
|
71
71
|
overflow:hidden;
|
|
72
72
|
border-radius:24px;
|
|
73
|
-
background-color:var(--magritte-color-background-primary-v24-4-
|
|
73
|
+
background-color:var(--magritte-color-background-primary-v24-4-1);
|
|
74
74
|
cursor:pointer;
|
|
75
75
|
--border-background-dimension:5px;
|
|
76
76
|
}
|
|
77
|
-
.magritte-root___FV1tC_4-2-
|
|
78
|
-
border-color:var(--magritte-color-stroke-accent-v24-4-
|
|
77
|
+
.magritte-root___FV1tC_4-2-7:hover .magritte-background___RfZ0U_4-2-7{
|
|
78
|
+
border-color:var(--magritte-color-stroke-accent-v24-4-1);
|
|
79
79
|
}
|
|
80
|
-
.magritte-root___FV1tC_4-2-
|
|
81
|
-
border-color:var(--magritte-color-stroke-accent-v24-4-
|
|
80
|
+
.magritte-root___FV1tC_4-2-7.magritte-drag-active___dihBL_4-2-7 .magritte-background___RfZ0U_4-2-7{
|
|
81
|
+
border-color:var(--magritte-color-stroke-accent-v24-4-1);
|
|
82
82
|
}
|
|
83
|
-
.magritte-root___FV1tC_4-2-
|
|
84
|
-
outline:var(--magritte-color-stroke-state-focused-accessible-v24-4-
|
|
83
|
+
.magritte-root___FV1tC_4-2-7.focus-visible{
|
|
84
|
+
outline:var(--magritte-color-stroke-state-focused-accessible-v24-4-1) solid 4px;
|
|
85
85
|
}
|
|
86
|
-
.magritte-root___FV1tC_4-2-
|
|
87
|
-
border-color:var(--magritte-color-stroke-accent-v24-4-
|
|
86
|
+
.magritte-root___FV1tC_4-2-7.focus-visible .magritte-background___RfZ0U_4-2-7{
|
|
87
|
+
border-color:var(--magritte-color-stroke-accent-v24-4-1);
|
|
88
88
|
}
|
|
89
|
-
.magritte-root___FV1tC_4-2-
|
|
90
|
-
.magritte-root___FV1tC_4-2-
|
|
89
|
+
.magritte-root___FV1tC_4-2-7.magritte-load___MghDA_4-2-7 .magritte-background___RfZ0U_4-2-7,
|
|
90
|
+
.magritte-root___FV1tC_4-2-7.magritte-loading___9E3p-_4-2-7 .magritte-background___RfZ0U_4-2-7{
|
|
91
91
|
border-style:solid;
|
|
92
92
|
border-width:calc(1px + var(--border-background-dimension));
|
|
93
93
|
}
|
|
94
|
-
.magritte-root___FV1tC_4-2-
|
|
95
|
-
outline:var(--magritte-color-component-input-stroke-state-negative-focused-accessible-v24-4-
|
|
94
|
+
.magritte-root___FV1tC_4-2-7.magritte-invalid___Rt10-_4-2-7.focus-visible{
|
|
95
|
+
outline:var(--magritte-color-component-input-stroke-state-negative-focused-accessible-v24-4-1) solid 4px;
|
|
96
96
|
}
|
|
97
|
-
.magritte-root___FV1tC_4-2-
|
|
98
|
-
border-color:var(--magritte-color-stroke-neutral-v24-4-
|
|
97
|
+
.magritte-root___FV1tC_4-2-7.magritte-invalid___Rt10-_4-2-7 .magritte-background___RfZ0U_4-2-7{
|
|
98
|
+
border-color:var(--magritte-color-stroke-neutral-v24-4-1);
|
|
99
99
|
}
|
|
100
|
-
.magritte-root___FV1tC_4-2-
|
|
100
|
+
.magritte-root___FV1tC_4-2-7.magritte-disabled___bhw2K_4-2-7{
|
|
101
101
|
cursor:default;
|
|
102
|
-
background-color:var(--magritte-color-background-state-primary-disabled-v24-4-
|
|
102
|
+
background-color:var(--magritte-color-background-state-primary-disabled-v24-4-1);
|
|
103
103
|
}
|
|
104
|
-
.magritte-root___FV1tC_4-2-
|
|
105
|
-
border-color:var(--magritte-color-stroke-state-neutral-disabled-v24-4-
|
|
104
|
+
.magritte-root___FV1tC_4-2-7.magritte-disabled___bhw2K_4-2-7 .magritte-background___RfZ0U_4-2-7{
|
|
105
|
+
border-color:var(--magritte-color-stroke-state-neutral-disabled-v24-4-1);
|
|
106
106
|
border-width:calc(2px + var(--border-background-dimension));
|
|
107
107
|
}
|
|
108
108
|
@supports (-moz-appearance: none){
|
|
109
|
-
.magritte-root___FV1tC_4-2-
|
|
109
|
+
.magritte-root___FV1tC_4-2-7{
|
|
110
110
|
--border-background-dimension:2px;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
@supports (background: -webkit-named-image(i)) and (-webkit-appearance: none){
|
|
114
|
-
.magritte-root___FV1tC_4-2-
|
|
114
|
+
.magritte-root___FV1tC_4-2-7{
|
|
115
115
|
--border-background-dimension:2px;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
.magritte-root_medium___67WJa_4-2-
|
|
118
|
+
.magritte-root_medium___67WJa_4-2-7{
|
|
119
119
|
justify-content:center;
|
|
120
120
|
padding:24px;
|
|
121
121
|
}
|
|
122
|
-
.magritte-root_medium___67WJa_4-2-
|
|
122
|
+
.magritte-root_medium___67WJa_4-2-7 .magritte-body___O7ROl_4-2-7{
|
|
123
123
|
flex-direction:column;
|
|
124
124
|
align-items:center;
|
|
125
125
|
justify-content:center;
|
|
126
126
|
}
|
|
127
|
-
.magritte-root_small___dkUYq_4-2-
|
|
127
|
+
.magritte-root_small___dkUYq_4-2-7{
|
|
128
128
|
padding-top:16px;
|
|
129
129
|
padding-bottom:16px;
|
|
130
130
|
padding-left:16px;
|
|
131
131
|
}
|
|
132
|
-
.magritte-root_small___dkUYq_4-2-
|
|
132
|
+
.magritte-root_small___dkUYq_4-2-7 .magritte-body___O7ROl_4-2-7{
|
|
133
133
|
gap:16px;
|
|
134
134
|
}
|
|
135
|
-
.magritte-background___RfZ0U_4-2-
|
|
135
|
+
.magritte-background___RfZ0U_4-2-7{
|
|
136
136
|
position:absolute;
|
|
137
137
|
border-width:calc(2px + var(--border-background-dimension));
|
|
138
138
|
border-style:dashed;
|
|
139
|
-
border-color:var(--magritte-color-stroke-neutral-v24-4-
|
|
139
|
+
border-color:var(--magritte-color-stroke-neutral-v24-4-1);
|
|
140
140
|
top:calc(-1 * var(--border-background-dimension));
|
|
141
141
|
bottom:calc(-1 * var(--border-background-dimension));
|
|
142
142
|
left:calc(-1 * var(--border-background-dimension));
|
|
@@ -145,15 +145,15 @@
|
|
|
145
145
|
background-position:center;
|
|
146
146
|
background-size:100%;
|
|
147
147
|
}
|
|
148
|
-
.magritte-body___O7ROl_4-2-
|
|
148
|
+
.magritte-body___O7ROl_4-2-7{
|
|
149
149
|
display:flex;
|
|
150
150
|
width:100%;
|
|
151
151
|
}
|
|
152
|
-
.magritte-loader___XYpWg_4-2-
|
|
152
|
+
.magritte-loader___XYpWg_4-2-7{
|
|
153
153
|
position:relative;
|
|
154
154
|
display:flex;
|
|
155
155
|
}
|
|
156
|
-
.magritte-cancel___tQ-yX_4-2-
|
|
156
|
+
.magritte-cancel___tQ-yX_4-2-7{
|
|
157
157
|
position:absolute;
|
|
158
158
|
top:0;
|
|
159
159
|
left:0;
|
|
@@ -163,41 +163,41 @@
|
|
|
163
163
|
align-items:center;
|
|
164
164
|
justify-content:center;
|
|
165
165
|
}
|
|
166
|
-
.magritte-image-controls___vLf94_4-2-
|
|
166
|
+
.magritte-image-controls___vLf94_4-2-7{
|
|
167
167
|
display:flex;
|
|
168
168
|
gap:12px;
|
|
169
169
|
align-items:flex-end;
|
|
170
170
|
justify-content:flex-end;
|
|
171
171
|
width:100%;
|
|
172
172
|
}
|
|
173
|
-
.magritte-small-controls___Qn9TP_4-2-
|
|
173
|
+
.magritte-small-controls___Qn9TP_4-2-7{
|
|
174
174
|
display:flex;
|
|
175
175
|
align-items:center;
|
|
176
176
|
margin-left:auto;
|
|
177
177
|
margin-right:20px;
|
|
178
178
|
}
|
|
179
|
-
.magritte-file-list___L9uHt_4-2-
|
|
179
|
+
.magritte-file-list___L9uHt_4-2-7{
|
|
180
180
|
margin-top:12px;
|
|
181
|
-
box-shadow:inset 0 0 0 1px var(--magritte-color-stroke-neutral-v24-4-
|
|
181
|
+
box-shadow:inset 0 0 0 1px var(--magritte-color-stroke-neutral-v24-4-1);
|
|
182
182
|
border-radius:24px;
|
|
183
183
|
padding-top:16px;
|
|
184
184
|
padding-right:0;
|
|
185
185
|
padding-bottom:16px;
|
|
186
186
|
padding-left:16px;
|
|
187
187
|
}
|
|
188
|
-
.magritte-file-icon___oetLK_4-2-
|
|
188
|
+
.magritte-file-icon___oetLK_4-2-7{
|
|
189
189
|
display:inline-flex;
|
|
190
190
|
}
|
|
191
|
-
.magritte-file-info___Y3vyi_4-2-
|
|
191
|
+
.magritte-file-info___Y3vyi_4-2-7{
|
|
192
192
|
display:inline-flex;
|
|
193
193
|
width:100%;
|
|
194
194
|
flex-direction:column;
|
|
195
195
|
align-items:center;
|
|
196
196
|
}
|
|
197
|
-
.magritte-hidden-file-info___92c69_4-2-
|
|
197
|
+
.magritte-hidden-file-info___92c69_4-2-7{
|
|
198
198
|
visibility:hidden;
|
|
199
199
|
}
|
|
200
|
-
.magritte-single-small-placeholer___m8Vnt_4-2-
|
|
200
|
+
.magritte-single-small-placeholer___m8Vnt_4-2-7{
|
|
201
201
|
display:flex;
|
|
202
202
|
flex-direction:column;
|
|
203
203
|
justify-content:center;
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import 'react/jsx-runtime';
|
|
|
4
4
|
import './MultiUpload.js';
|
|
5
5
|
import 'react-dropzone';
|
|
6
6
|
import 'classnames';
|
|
7
|
-
import './upload-
|
|
7
|
+
import './upload-Dpstho06.js';
|
|
8
8
|
import 'react';
|
|
9
9
|
import '@hh.ru/magritte-ui-spacing';
|
|
10
10
|
import '@hh.ru/magritte-ui-typography';
|
package/index.mock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mock.js","sources":["
|
|
1
|
+
{"version":3,"file":"index.mock.js","sources":["src/index.mock.ts"],"sourcesContent":["import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport type * from '@hh.ru/magritte-ui-upload/types';\n\nexport const Upload: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent('Upload', undefined, {\n withChildren: false,\n});\n"],"names":[],"mappings":";;MAMa,MAAM,GAAuD,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE;AACzG,IAAA,YAAY,EAAE,KAAK;AACtB,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-upload",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"react": ">=18.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@hh.ru/magritte-design-tokens": "24.4.
|
|
30
|
-
"@hh.ru/magritte-ui-avatar": "8.0.
|
|
31
|
-
"@hh.ru/magritte-ui-breakpoint": "6.0.
|
|
32
|
-
"@hh.ru/magritte-ui-button": "7.1.
|
|
33
|
-
"@hh.ru/magritte-ui-button-stack": "3.0.
|
|
34
|
-
"@hh.ru/magritte-ui-divider": "3.0.
|
|
35
|
-
"@hh.ru/magritte-ui-icon": "13.
|
|
36
|
-
"@hh.ru/magritte-ui-loader": "2.1.
|
|
37
|
-
"@hh.ru/magritte-ui-mock-component": "1.1.
|
|
38
|
-
"@hh.ru/magritte-ui-spacing": "2.1.
|
|
39
|
-
"@hh.ru/magritte-ui-typography": "4.5.
|
|
29
|
+
"@hh.ru/magritte-design-tokens": "24.4.1",
|
|
30
|
+
"@hh.ru/magritte-ui-avatar": "8.0.16",
|
|
31
|
+
"@hh.ru/magritte-ui-breakpoint": "6.0.7",
|
|
32
|
+
"@hh.ru/magritte-ui-button": "7.1.5",
|
|
33
|
+
"@hh.ru/magritte-ui-button-stack": "3.0.2",
|
|
34
|
+
"@hh.ru/magritte-ui-divider": "3.0.17",
|
|
35
|
+
"@hh.ru/magritte-ui-icon": "13.11.1",
|
|
36
|
+
"@hh.ru/magritte-ui-loader": "2.1.5",
|
|
37
|
+
"@hh.ru/magritte-ui-mock-component": "1.1.7",
|
|
38
|
+
"@hh.ru/magritte-ui-spacing": "2.1.11",
|
|
39
|
+
"@hh.ru/magritte-ui-typography": "4.5.2",
|
|
40
40
|
"react-dropzone": "14.3.5"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ec7d56f576ca5581c2acb5010b53bbfb8da52962"
|
|
43
43
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const DisabledContext = createContext(false);
|
|
5
|
+
const useDisabled = () => useContext(DisabledContext);
|
|
6
|
+
|
|
7
|
+
var styles = {"root":"magritte-root___FV1tC_4-2-7","background":"magritte-background___RfZ0U_4-2-7","drag-active":"magritte-drag-active___dihBL_4-2-7","dragActive":"magritte-drag-active___dihBL_4-2-7","load":"magritte-load___MghDA_4-2-7","loading":"magritte-loading___9E3p-_4-2-7","invalid":"magritte-invalid___Rt10-_4-2-7","disabled":"magritte-disabled___bhw2K_4-2-7","root_medium":"magritte-root_medium___67WJa_4-2-7","rootMedium":"magritte-root_medium___67WJa_4-2-7","body":"magritte-body___O7ROl_4-2-7","root_small":"magritte-root_small___dkUYq_4-2-7","rootSmall":"magritte-root_small___dkUYq_4-2-7","loader":"magritte-loader___XYpWg_4-2-7","cancel":"magritte-cancel___tQ-yX_4-2-7","image-controls":"magritte-image-controls___vLf94_4-2-7","imageControls":"magritte-image-controls___vLf94_4-2-7","small-controls":"magritte-small-controls___Qn9TP_4-2-7","smallControls":"magritte-small-controls___Qn9TP_4-2-7","file-list":"magritte-file-list___L9uHt_4-2-7","fileList":"magritte-file-list___L9uHt_4-2-7","file-icon":"magritte-file-icon___oetLK_4-2-7","fileIcon":"magritte-file-icon___oetLK_4-2-7","file-info":"magritte-file-info___Y3vyi_4-2-7","fileInfo":"magritte-file-info___Y3vyi_4-2-7","hidden-file-info":"magritte-hidden-file-info___92c69_4-2-7","hiddenFileInfo":"magritte-hidden-file-info___92c69_4-2-7","single-small-placeholer":"magritte-single-small-placeholer___m8Vnt_4-2-7","singleSmallPlaceholer":"magritte-single-small-placeholer___m8Vnt_4-2-7"};
|
|
8
|
+
|
|
9
|
+
export { DisabledContext as D, styles as s, useDisabled as u };
|
|
10
|
+
//# sourceMappingURL=upload-Dpstho06.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-Dpstho06.js","sources":["../../common/use-disabled/lib/index.js"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst DisabledContext = createContext(false);\nconst useDisabled = () => useContext(DisabledContext);\n\nexport { DisabledContext, useDisabled };\n//# sourceMappingURL=index.js.map\n"],"names":[],"mappings":";;AAEK,MAAC,eAAe,GAAG,aAAa,CAAC,KAAK,EAAE;AACxC,MAAC,WAAW,GAAG,MAAM,UAAU,CAAC,eAAe;;;;;;"}
|
package/useDropActions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropActions.js","sources":["
|
|
1
|
+
{"version":3,"file":"useDropActions.js","sources":["src/useDropActions.tsx"],"sourcesContent":["import { useCallback, MouseEvent } from 'react';\nimport { DropEvent, FileRejection, DropzoneOptions } from 'react-dropzone';\n\nimport { UploadProps, LoadedFile, OnFileDelete } from '@hh.ru/magritte-ui-upload/types';\n\ninterface UseDropActionsProps {\n onDropAccepted: UploadProps['onDropAccepted'];\n onDropRejected: UploadProps['onDropRejected'];\n onFileDelete: UploadProps['onFileDelete'];\n}\n\ninterface UseDropActionsResult {\n onDropAccepted: DropzoneOptions['onDropAccepted'];\n onDropRejected: DropzoneOptions['onDropRejected'];\n onFileDelete: OnFileDelete;\n}\n\nconst useDropActions = ({\n onDropAccepted: onDropAcceptedExternal,\n onDropRejected: onDropRejectedExternal,\n onFileDelete: onFileDeleteExternal,\n}: UseDropActionsProps): UseDropActionsResult => {\n const onDropAccepted = useCallback(\n (acceptedFiles: File[], event: DropEvent) => {\n const acceptedLoadFiles = acceptedFiles.map((file) => ({ data: file, loading: true, loadPercentage: 0 }));\n onDropAcceptedExternal(acceptedLoadFiles, event);\n },\n [onDropAcceptedExternal]\n );\n const onDropRejected = useCallback(\n (fileRejections: FileRejection[], event: DropEvent) => {\n const rejectionLoadFiles = fileRejections.map((fileRejection) => ({\n data: fileRejection.file,\n loading: false,\n error: fileRejection.errors?.[0].code || '',\n }));\n onDropRejectedExternal?.(rejectionLoadFiles, event);\n },\n [onDropRejectedExternal]\n );\n const onFileDelete = useCallback(\n (event: MouseEvent, loadedFile: LoadedFile | undefined, indexFile: number) => {\n loadedFile && onFileDeleteExternal(loadedFile, indexFile);\n event.stopPropagation();\n },\n [onFileDeleteExternal]\n );\n return { onDropAccepted, onDropRejected, onFileDelete };\n};\n\nexport { useDropActions };\n"],"names":[],"mappings":";;AAiBA,MAAM,cAAc,GAAG,CAAC,EACpB,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,oBAAoB,GAChB,KAA0B;IAC5C,MAAM,cAAc,GAAG,WAAW,CAC9B,CAAC,aAAqB,EAAE,KAAgB,KAAI;QACxC,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1G,QAAA,sBAAsB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACrD,KAAC,EACD,CAAC,sBAAsB,CAAC,CAC3B,CAAC;IACF,MAAM,cAAc,GAAG,WAAW,CAC9B,CAAC,cAA+B,EAAE,KAAgB,KAAI;QAClD,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,MAAM;YAC9D,IAAI,EAAE,aAAa,CAAC,IAAI;AACxB,YAAA,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;AAC9C,SAAA,CAAC,CAAC,CAAC;AACJ,QAAA,sBAAsB,GAAG,kBAAkB,EAAE,KAAK,CAAC,CAAC;AACxD,KAAC,EACD,CAAC,sBAAsB,CAAC,CAC3B,CAAC;IACF,MAAM,YAAY,GAAG,WAAW,CAC5B,CAAC,KAAiB,EAAE,UAAkC,EAAE,SAAiB,KAAI;AACzE,QAAA,UAAU,IAAI,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC1D,KAAK,CAAC,eAAe,EAAE,CAAC;AAC5B,KAAC,EACD,CAAC,oBAAoB,CAAC,CACzB,CAAC;AACF,IAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAC5D;;;;"}
|
package/useDropButtons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropButtons.js","sources":["
|
|
1
|
+
{"version":3,"file":"useDropButtons.js","sources":["src/useDropButtons.tsx"],"sourcesContent":["import { MouseEvent, cloneElement, ComponentProps } from 'react';\n\nimport { Button } from '@hh.ru/magritte-ui-button';\nimport { ButtonElement } from '@hh.ru/magritte-ui-button-stack';\n\ninterface DropButtons {\n selectFileButton?: ButtonElement;\n deleteFileButton?: ButtonElement;\n replaceImageButton?: ButtonElement;\n}\n\ninterface UseDropButtonsProps extends DropButtons {\n onFileDelete?: (event: MouseEvent) => void;\n}\n\nconst useDropButtons = ({\n selectFileButton: _selectFileButton,\n deleteFileButton: _deleteFileButton,\n replaceImageButton: _replaceImageButton,\n onFileDelete,\n}: UseDropButtonsProps): DropButtons => {\n const selectFileButton =\n _selectFileButton &&\n cloneElement(_selectFileButton, {\n key: 'selectFileButton',\n 'data-qa': 'magritte-select-file-button',\n } as Partial<ComponentProps<typeof Button>>);\n\n const deleteFileButton =\n _deleteFileButton &&\n cloneElement(_deleteFileButton, {\n key: 'deleteFileButton',\n 'data-qa': 'magritte-delete-file-button',\n onClick: onFileDelete,\n } as Partial<ComponentProps<typeof Button>>);\n\n const replaceImageButton =\n _replaceImageButton &&\n cloneElement(_replaceImageButton, {\n key: 'replaceImageButton',\n 'data-qa': 'magritte-select-replace-image-button',\n } as Partial<ComponentProps<typeof Button>>);\n\n return { selectFileButton, deleteFileButton, replaceImageButton };\n};\n\nexport { useDropButtons };\n"],"names":[],"mappings":";;AAeA,MAAM,cAAc,GAAG,CAAC,EACpB,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,EAAE,iBAAiB,EACnC,kBAAkB,EAAE,mBAAmB,EACvC,YAAY,GACM,KAAiB;IACnC,MAAM,gBAAgB,GAClB,iBAAiB;QACjB,YAAY,CAAC,iBAAiB,EAAE;AAC5B,YAAA,GAAG,EAAE,kBAAkB;AACvB,YAAA,SAAS,EAAE,6BAA6B;AACD,SAAA,CAAC,CAAC;IAEjD,MAAM,gBAAgB,GAClB,iBAAiB;QACjB,YAAY,CAAC,iBAAiB,EAAE;AAC5B,YAAA,GAAG,EAAE,kBAAkB;AACvB,YAAA,SAAS,EAAE,6BAA6B;AACxC,YAAA,OAAO,EAAE,YAAY;AACkB,SAAA,CAAC,CAAC;IAEjD,MAAM,kBAAkB,GACpB,mBAAmB;QACnB,YAAY,CAAC,mBAAmB,EAAE;AAC9B,YAAA,GAAG,EAAE,oBAAoB;AACzB,YAAA,SAAS,EAAE,sCAAsC;AACV,SAAA,CAAC,CAAC;AAEjD,IAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC;AACtE;;;;"}
|
package/useFilePreview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilePreview.js","sources":["
|
|
1
|
+
{"version":3,"file":"useFilePreview.js","sources":["src/useFilePreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { LoadedFile } from '@hh.ru/magritte-ui-upload/types';\n\ninterface UseFilePreviewProps {\n loadedFile: LoadedFile | undefined;\n isImageType: boolean;\n}\n\nconst useFilePreview = ({ loadedFile, isImageType }: UseFilePreviewProps): string => {\n return useMemo(() => {\n if (!loadedFile || !isImageType) {\n return 'none';\n }\n if (loadedFile.loading || loadedFile.error) {\n return 'none';\n }\n return URL.createObjectURL(loadedFile.data);\n }, [loadedFile, isImageType]);\n};\n\nexport { useFilePreview };\n"],"names":[],"mappings":";;AASM,MAAA,cAAc,GAAG,CAAC,EAAE,UAAU,EAAE,WAAW,EAAuB,KAAY;IAChF,OAAO,OAAO,CAAC,MAAK;AAChB,QAAA,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE;AAC7B,YAAA,OAAO,MAAM,CAAC;SACjB;QACD,IAAI,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE;AACxC,YAAA,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAChD,KAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAClC;;;;"}
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["src/utils.tsx"],"sourcesContent":["import { ReactElement, ReactNode } from 'react';\nimport { Accept } from 'react-dropzone';\n\nimport {\n DocumentArrowUpOutlinedSize32,\n DocumentOutlinedSize32,\n VideocameraOutlinedSize32,\n ImageOutlinedSize32,\n DocumentArrowUpOutlinedSize24,\n DocumentOutlinedSize24,\n VideocameraOutlinedSize24,\n ImageOutlinedSize24,\n IconDynamic,\n} from '@hh.ru/magritte-ui-icon/icon';\nimport { LoadedFile, UploadType, LoadedFileWithFileSize } from '@hh.ru/magritte-ui-upload/types';\n\nexport const RenderFileInfoDefault = (loadedFile: LoadedFileWithFileSize): ReactNode => {\n return loadedFile.fileSizeMB;\n};\n\nexport const DEFAULT_ACCEPT: Accept = {\n 'image/*': ['.png', '.jpeg', '.jpg'],\n};\n\nconst order = 1024 * 1024;\nexport const bytes2mb = (value: number): string => {\n return (value / order).toFixed(2);\n};\n\nexport const getFileType = (avaliableType: string): UploadType => {\n return avaliableType.split('/')[0] as UploadType;\n};\n\n// парсим accept в нормальный формат\nexport const getAvaliableFileTypes = (accept: Accept): UploadType => {\n const avaliableTypes = Object.keys(accept);\n if (avaliableTypes.length === 0) {\n throw new Error(`Magritte component Upload: accept can't be empty`);\n }\n if (avaliableTypes.length > 1) {\n return 'mixed';\n }\n return getFileType(avaliableTypes[0]);\n};\n\nconst ICONS_LOADED = {\n default: {\n small: DocumentOutlinedSize24,\n large: DocumentOutlinedSize32,\n },\n image: {\n small: ImageOutlinedSize24,\n large: ImageOutlinedSize32,\n },\n video: {\n small: VideocameraOutlinedSize24,\n large: VideocameraOutlinedSize32,\n },\n} as const;\n\nconst ICONS_NOT_LOADED = {\n default: {\n small: DocumentArrowUpOutlinedSize24,\n large: DocumentArrowUpOutlinedSize32,\n },\n image: {\n small: ImageOutlinedSize24,\n large: ImageOutlinedSize32,\n },\n video: {\n small: ImageOutlinedSize24,\n large: ImageOutlinedSize32,\n },\n} as const;\n\n// иконка (тип и цвет) может меняться в зависимости от типа, размера и состояния загрузки\nexport const getUploadIcon = (\n uploadType: UploadType,\n loadedFile: LoadedFile | undefined,\n isSmall: boolean\n): ReactElement | undefined => {\n const MAP = loadedFile ? ICONS_LOADED : ICONS_NOT_LOADED;\n\n if (loadedFile) {\n const { error, loading } = loadedFile;\n if ((loading || error) && !isSmall) {\n return undefined;\n }\n }\n\n const component = MAP[uploadType as keyof typeof MAP] ?? MAP.default;\n const IconJSX = component[isSmall ? 'small' : 'large'];\n const color = isSmall && loadedFile ? 'accent' : 'secondary';\n\n return (\n <IconDynamic>\n <IconJSX initialColor={color} disabledColor={color} />\n </IconDynamic>\n );\n};\n"],"names":["_jsx"],"mappings":";;;AAgBa,MAAA,qBAAqB,GAAG,CAAC,UAAkC,KAAe;IACnF,OAAO,UAAU,CAAC,UAAU,CAAC;AACjC,EAAE;AAEW,MAAA,cAAc,GAAW;AAClC,IAAA,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;EACtC;AAEF,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;AACb,MAAA,QAAQ,GAAG,CAAC,KAAa,KAAY;IAC9C,OAAO,CAAC,KAAK,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACtC,EAAE;AAEW,MAAA,WAAW,GAAG,CAAC,aAAqB,KAAgB;IAC7D,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAe,CAAC;AACrD,EAAE;AAEF;AACa,MAAA,qBAAqB,GAAG,CAAC,MAAc,KAAgB;IAChE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3C,IAAA,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7B,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,gDAAA,CAAkD,CAAC,CAAC;KACvE;AACD,IAAA,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,QAAA,OAAO,OAAO,CAAC;KAClB;AACD,IAAA,OAAO,WAAW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AAA,MAAM,KAAK,GAAG,OAAO,IAAI,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE7D,IAAA,QACIA,GAAC,CAAA,WAAW,EACR,EAAA,QAAA,EAAAA,GAAA,CAAC,OAAO,EAAC,EAAA,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAI,CAAA,EAAA,CAC5C,EAChB;AACN;;;;"}
|
package/upload-uOm1es2U.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
3
|
-
|
|
4
|
-
const DisabledContext = createContext(false);
|
|
5
|
-
const useDisabled = () => useContext(DisabledContext);
|
|
6
|
-
|
|
7
|
-
var styles = {"root":"magritte-root___FV1tC_4-2-5","background":"magritte-background___RfZ0U_4-2-5","drag-active":"magritte-drag-active___dihBL_4-2-5","dragActive":"magritte-drag-active___dihBL_4-2-5","load":"magritte-load___MghDA_4-2-5","loading":"magritte-loading___9E3p-_4-2-5","invalid":"magritte-invalid___Rt10-_4-2-5","disabled":"magritte-disabled___bhw2K_4-2-5","root_medium":"magritte-root_medium___67WJa_4-2-5","rootMedium":"magritte-root_medium___67WJa_4-2-5","body":"magritte-body___O7ROl_4-2-5","root_small":"magritte-root_small___dkUYq_4-2-5","rootSmall":"magritte-root_small___dkUYq_4-2-5","loader":"magritte-loader___XYpWg_4-2-5","cancel":"magritte-cancel___tQ-yX_4-2-5","image-controls":"magritte-image-controls___vLf94_4-2-5","imageControls":"magritte-image-controls___vLf94_4-2-5","small-controls":"magritte-small-controls___Qn9TP_4-2-5","smallControls":"magritte-small-controls___Qn9TP_4-2-5","file-list":"magritte-file-list___L9uHt_4-2-5","fileList":"magritte-file-list___L9uHt_4-2-5","file-icon":"magritte-file-icon___oetLK_4-2-5","fileIcon":"magritte-file-icon___oetLK_4-2-5","file-info":"magritte-file-info___Y3vyi_4-2-5","fileInfo":"magritte-file-info___Y3vyi_4-2-5","hidden-file-info":"magritte-hidden-file-info___92c69_4-2-5","hiddenFileInfo":"magritte-hidden-file-info___92c69_4-2-5","single-small-placeholer":"magritte-single-small-placeholer___m8Vnt_4-2-5","singleSmallPlaceholer":"magritte-single-small-placeholer___m8Vnt_4-2-5"};
|
|
8
|
-
|
|
9
|
-
export { DisabledContext as D, styles as s, useDisabled as u };
|
|
10
|
-
//# sourceMappingURL=upload-uOm1es2U.js.map
|
package/upload-uOm1es2U.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-uOm1es2U.js","sources":["../../../common/use-disabled/lib/index.js"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst DisabledContext = createContext(false);\nconst useDisabled = () => useContext(DisabledContext);\n\nexport { DisabledContext, useDisabled };\n//# sourceMappingURL=index.js.map\n"],"names":[],"mappings":";;AAEK,MAAC,eAAe,GAAG,aAAa,CAAC,KAAK,EAAE;AACxC,MAAC,WAAW,GAAG,MAAM,UAAU,CAAC,eAAe;;;;;;"}
|