@veeqo/ui 14.3.0 → 14.4.0
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/dist/components/UploadFile/UploadFile.cjs +10 -9
- package/dist/components/UploadFile/UploadFile.cjs.map +1 -1
- package/dist/components/UploadFile/UploadFile.js +8 -7
- package/dist/components/UploadFile/UploadFile.js.map +1 -1
- package/dist/components/UploadedFile/UploadedFile.cjs +2 -2
- package/dist/components/UploadedFile/UploadedFile.cjs.map +1 -1
- package/dist/components/UploadedFile/UploadedFile.js +2 -2
- package/dist/components/UploadedFile/UploadedFile.js.map +1 -1
- package/dist/hoc/withClassNames/withClassNames.cjs.map +1 -1
- package/dist/hoc/withClassNames/withClassNames.d.ts +1 -2
- package/dist/hoc/withClassNames/withClassNames.js.map +1 -1
- package/dist/hoc/withLabels/styled.cjs +5 -14
- package/dist/hoc/withLabels/styled.cjs.map +1 -1
- package/dist/hoc/withLabels/styled.d.ts +0 -13
- package/dist/hoc/withLabels/styled.js +6 -10
- package/dist/hoc/withLabels/styled.js.map +1 -1
- package/dist/hoc/withLabels/withLabels.cjs +8 -5
- package/dist/hoc/withLabels/withLabels.cjs.map +1 -1
- package/dist/hoc/withLabels/withLabels.js +9 -6
- package/dist/hoc/withLabels/withLabels.js.map +1 -1
- package/dist/hoc/withLabels/withLabels.module.scss.cjs +9 -0
- package/dist/hoc/withLabels/withLabels.module.scss.cjs.map +1 -0
- package/dist/hoc/withLabels/withLabels.module.scss.js +7 -0
- package/dist/hoc/withLabels/withLabels.module.scss.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,16 +4,17 @@ var React = require('react');
|
|
|
4
4
|
var index = require('../../theme/index.cjs');
|
|
5
5
|
var CriticalIcon = require('../../icons/design-system/components/CriticalIcon.cjs');
|
|
6
6
|
var LockIcon = require('../../icons/design-system/components/LockIcon.cjs');
|
|
7
|
-
var styled
|
|
7
|
+
var styled = require('./styled.cjs');
|
|
8
8
|
var constants = require('./constants.cjs');
|
|
9
9
|
var UploadCopy = require('./components/UploadCopy/UploadCopy.cjs');
|
|
10
10
|
var DropCopy = require('./components/DropCopy/DropCopy.cjs');
|
|
11
11
|
var getValidTypesString = require('./utils/getValidTypesString/getValidTypesString.cjs');
|
|
12
12
|
var getFileSizeString = require('./utils/getFileSizeString/getFileSizeString.cjs');
|
|
13
13
|
var getTypePropForInputEl = require('./utils/getTypePropForInputEl/getTypePropForInputEl.cjs');
|
|
14
|
-
var
|
|
15
|
-
var UploadedFile = require('../UploadedFile/UploadedFile.cjs');
|
|
14
|
+
var Text = require('../Text/Text.cjs');
|
|
16
15
|
var FlexCol = require('../Flex/FlexCol/FlexCol.cjs');
|
|
16
|
+
var withLabels_module = require('../../hoc/withLabels/withLabels.module.scss.cjs');
|
|
17
|
+
var UploadedFile = require('../UploadedFile/UploadedFile.cjs');
|
|
17
18
|
var FlexRow = require('../Flex/FlexRow/FlexRow.cjs');
|
|
18
19
|
var useUploadFile = require('./hooks/useUploadFile/useUploadFile.cjs');
|
|
19
20
|
var useValidateInput = require('./hooks/useValidateInput/useValidateInput.cjs');
|
|
@@ -95,24 +96,24 @@ const UploadFile = React.forwardRef(({ id, name, maxBytes = constants.DEFAULT_MA
|
|
|
95
96
|
};
|
|
96
97
|
}, [onChange, onCancel, inputRef]);
|
|
97
98
|
const hasError = !!((errorMessage || ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.validationMessage)) && !(fileList === null || fileList === void 0 ? void 0 : fileList.length));
|
|
98
|
-
return (React__default.default.createElement(
|
|
99
|
-
React__default.default.createElement(
|
|
99
|
+
return (React__default.default.createElement(FlexCol.FlexCol, { gap: "xs", className: withLabels_module.rootStack },
|
|
100
|
+
React__default.default.createElement(Text.Text, { variant: "inputLabel", as: "label", htmlFor: id },
|
|
100
101
|
label,
|
|
101
102
|
React__default.default.createElement(FlexCol.FlexCol, null,
|
|
102
|
-
React__default.default.createElement(
|
|
103
|
+
React__default.default.createElement(Text.Text, { variant: "hintText", as: "span", className: withLabels_module.hint },
|
|
103
104
|
maxSizeCopy,
|
|
104
105
|
React__default.default.createElement("br", null),
|
|
105
106
|
acceptedTypesCopy),
|
|
106
|
-
React__default.default.createElement(styled
|
|
107
|
+
React__default.default.createElement(styled.DropZoneContainer, { hasError: hasError, isDragOver: isDragOver, "data-testid": "drop-zone-container", onDrop: onDrop, onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave },
|
|
107
108
|
isDragOver ? React__default.default.createElement(DropCopy.DropCopy, null) : React__default.default.createElement(UploadCopy.UploadCopy, null),
|
|
108
109
|
React__default.default.createElement("input", { ref: inputRef, id: id, type: "file", accept: acceptedTypesForInputEl, name: name, disabled: disabled, multiple: multiple, ...otherProps })))),
|
|
109
110
|
React__default.default.createElement(FlexCol.FlexCol, null,
|
|
110
111
|
hasError && (React__default.default.createElement(FlexRow.FlexRow, null,
|
|
111
112
|
React__default.default.createElement(CriticalIcon.ReactComponent, { width: index.theme.sizes.base, height: index.theme.sizes.base, color: index.theme.colors.secondary.red.base }),
|
|
112
|
-
React__default.default.createElement(
|
|
113
|
+
React__default.default.createElement(Text.Text, { variant: "error", as: "span", className: withLabels_module.error }, errorMessage || ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.validationMessage)))),
|
|
113
114
|
disabledMessage && (React__default.default.createElement(FlexRow.FlexRow, { id: `${id}-disabled` },
|
|
114
115
|
React__default.default.createElement(LockIcon.ReactComponent, { width: index.theme.sizes.base, height: index.theme.sizes.base, color: index.theme.colors.neutral.ink.light }),
|
|
115
|
-
React__default.default.createElement(
|
|
116
|
+
React__default.default.createElement(Text.Text, { variant: "bodyBold", as: "span" }, disabledMessage))),
|
|
116
117
|
!hideUploadedFiles &&
|
|
117
118
|
fileList && [
|
|
118
119
|
Array.from(fileList).map((file) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadFile.cjs","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport {\n FileSizeUnit,\n DEFAULT_MAXIMUM_MULTIPLE_FILES,\n DEFAULT_MAXIMUM_FILE_BYTES,\n} from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from '../UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = DEFAULT_MAXIMUM_FILE_BYTES,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n onFileRemoved,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage = '',\n onFileInputCancelled,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile({ onFileInputCancelled });\n\n useValidateInput({ inputRef, fileList, fileTypes, maxBytes, errorMessage });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasError = !!((errorMessage || inputRef.current?.validationMessage) && !fileList?.length);\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n hasError={hasError}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {hasError && (\n <FlexRow>\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <Error>{errorMessage || inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n onRemoveFile={(fileToRemove) => {\n removeFileFromList(fileToRemove);\n onFileRemoved?.(fileToRemove);\n }}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["forwardRef","DEFAULT_MAXIMUM_FILE_BYTES","FileSizeUnit","DEFAULT_MAXIMUM_MULTIPLE_FILES","useUploadFile","useValidateInput","useImperativeHandle","useState","getFileSizeString","getValidTypesString","getTypePropForInputEl","useCallback","useEffect","React","RootStack","Label","FlexCol","Hint","DropZoneContainer","DropCopy","UploadCopy","FlexRow","CriticalIcon","theme","Error","LockIcon","Disabled","UploadedFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,UAAU,GAAGA,gBAAU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C,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAA,CACrC;AACF,gBAAAV,sBAAA,CAAA,aAAA,CAACa,eAAQ,EAAA,IAAA,EAAE,eAAe,CAAY,CAC9B,CACX;AACA,YAAA,CAAC,iBAAiB;AACjB,gBAAA,QAAQ,IAAI;gBACV,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;oBAChC,QACEb,qCAACc,yBAAY,EAAA,EACX,GAAG,EAAE,CAAA,EAAG,IAAI,CAAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,YAAY,KAAI;4BAC7B,kBAAkB,CAAC,YAAY,CAAC;AAChC,4BAAA,aAAa,aAAb,aAAa,KAAA,MAAA,GAAA,MAAA,GAAb,aAAa,CAAG,YAAY,CAAC;AAC/B,wBAAA,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,gBAAA,CAAC,CAAC;aACH,CACK,CACA;AAEhB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"UploadFile.cjs","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport {\n FileSizeUnit,\n DEFAULT_MAXIMUM_MULTIPLE_FILES,\n DEFAULT_MAXIMUM_FILE_BYTES,\n} from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Text } from '../Text';\nimport { FlexCol } from '../Flex/FlexCol';\nimport labelStyles from '../../hoc/withLabels/withLabels.module.scss';\nimport { UploadedFile } from '../UploadedFile';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = DEFAULT_MAXIMUM_FILE_BYTES,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n onFileRemoved,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage = '',\n onFileInputCancelled,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile({ onFileInputCancelled });\n\n useValidateInput({ inputRef, fileList, fileTypes, maxBytes, errorMessage });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasError = !!((errorMessage || inputRef.current?.validationMessage) && !fileList?.length);\n\n return (\n <FlexCol gap=\"xs\" className={labelStyles.rootStack}>\n <Text variant=\"inputLabel\" as=\"label\" htmlFor={id}>\n {label}\n <FlexCol>\n <Text variant=\"hintText\" as=\"span\" className={labelStyles.hint}>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Text>\n <DropZoneContainer\n hasError={hasError}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Text>\n <FlexCol>\n {hasError && (\n <FlexRow>\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <Text variant=\"error\" as=\"span\" className={labelStyles.error}>{errorMessage || inputRef.current?.validationMessage}</Text>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n <Text variant=\"bodyBold\" as=\"span\">{disabledMessage}</Text>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n onRemoveFile={(fileToRemove) => {\n removeFileFromList(fileToRemove);\n onFileRemoved?.(fileToRemove);\n }}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </FlexCol>\n );\n },\n);\n"],"names":["forwardRef","DEFAULT_MAXIMUM_FILE_BYTES","FileSizeUnit","DEFAULT_MAXIMUM_MULTIPLE_FILES","useUploadFile","useValidateInput","useImperativeHandle","useState","getFileSizeString","getValidTypesString","getTypePropForInputEl","useCallback","useEffect","React","FlexCol","labelStyles","Text","DropZoneContainer","DropCopy","UploadCopy","FlexRow","CriticalIcon","theme","LockIcon","UploadedFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,UAAU,GAAGA,gBAAU,CAClC,CACE,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAAGC,oCAA0B,EACrC,MAAM,GAAGC,sBAAY,CAAC,EAAE,EACxB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,EACjD,iBAAiB,GAAG,KAAK,EACzB,kBAAkB,EAClB,aAAa,EACb,QAAQ,GAAGC,wCAA8B,EACzC,eAAe,EACf,YAAY,GAAG,EAAE,EACjB,oBAA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AAA,aAAA,CAACG,SAAI,EAAA,EAAC,OAAO,EAAC,UAAU,EAAC,EAAE,EAAC,MAAM,EAAA,EAAE,eAAe,CAAQ,CACnD,CACX;AACA,YAAA,CAAC,iBAAiB;AACjB,gBAAA,QAAQ,IAAI;gBACV,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;oBAChC,QACEH,qCAACW,yBAAY,EAAA,EACX,GAAG,EAAE,CAAA,EAAG,IAAI,CAAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,YAAY,KAAI;4BAC7B,kBAAkB,CAAC,YAAY,CAAC;AAChC,4BAAA,aAAa,aAAb,aAAa,KAAA,MAAA,GAAA,MAAA,GAAb,aAAa,CAAG,YAAY,CAAC;AAC/B,wBAAA,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,gBAAA,CAAC,CAAC;aACH,CACK,CACF;AAEd,CAAC;;;;"}
|
|
@@ -9,9 +9,10 @@ import { DropCopy } from './components/DropCopy/DropCopy.js';
|
|
|
9
9
|
import { getValidTypesString } from './utils/getValidTypesString/getValidTypesString.js';
|
|
10
10
|
import { getFileSizeString } from './utils/getFileSizeString/getFileSizeString.js';
|
|
11
11
|
import { getTypePropForInputEl } from './utils/getTypePropForInputEl/getTypePropForInputEl.js';
|
|
12
|
-
import {
|
|
13
|
-
import { UploadedFile } from '../UploadedFile/UploadedFile.js';
|
|
12
|
+
import { Text } from '../Text/Text.js';
|
|
14
13
|
import { FlexCol } from '../Flex/FlexCol/FlexCol.js';
|
|
14
|
+
import labelStyles from '../../hoc/withLabels/withLabels.module.scss.js';
|
|
15
|
+
import { UploadedFile } from '../UploadedFile/UploadedFile.js';
|
|
15
16
|
import { FlexRow } from '../Flex/FlexRow/FlexRow.js';
|
|
16
17
|
import { useUploadFile } from './hooks/useUploadFile/useUploadFile.js';
|
|
17
18
|
import { useValidateInput } from './hooks/useValidateInput/useValidateInput.js';
|
|
@@ -89,11 +90,11 @@ const UploadFile = forwardRef(({ id, name, maxBytes = DEFAULT_MAXIMUM_FILE_BYTES
|
|
|
89
90
|
};
|
|
90
91
|
}, [onChange, onCancel, inputRef]);
|
|
91
92
|
const hasError = !!((errorMessage || ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.validationMessage)) && !(fileList === null || fileList === void 0 ? void 0 : fileList.length));
|
|
92
|
-
return (React__default.createElement(
|
|
93
|
-
React__default.createElement(
|
|
93
|
+
return (React__default.createElement(FlexCol, { gap: "xs", className: labelStyles.rootStack },
|
|
94
|
+
React__default.createElement(Text, { variant: "inputLabel", as: "label", htmlFor: id },
|
|
94
95
|
label,
|
|
95
96
|
React__default.createElement(FlexCol, null,
|
|
96
|
-
React__default.createElement(
|
|
97
|
+
React__default.createElement(Text, { variant: "hintText", as: "span", className: labelStyles.hint },
|
|
97
98
|
maxSizeCopy,
|
|
98
99
|
React__default.createElement("br", null),
|
|
99
100
|
acceptedTypesCopy),
|
|
@@ -103,10 +104,10 @@ const UploadFile = forwardRef(({ id, name, maxBytes = DEFAULT_MAXIMUM_FILE_BYTES
|
|
|
103
104
|
React__default.createElement(FlexCol, null,
|
|
104
105
|
hasError && (React__default.createElement(FlexRow, null,
|
|
105
106
|
React__default.createElement(CriticalIcon, { width: theme.sizes.base, height: theme.sizes.base, color: theme.colors.secondary.red.base }),
|
|
106
|
-
React__default.createElement(
|
|
107
|
+
React__default.createElement(Text, { variant: "error", as: "span", className: labelStyles.error }, errorMessage || ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.validationMessage)))),
|
|
107
108
|
disabledMessage && (React__default.createElement(FlexRow, { id: `${id}-disabled` },
|
|
108
109
|
React__default.createElement(LockIcon, { width: theme.sizes.base, height: theme.sizes.base, color: theme.colors.neutral.ink.light }),
|
|
109
|
-
React__default.createElement(
|
|
110
|
+
React__default.createElement(Text, { variant: "bodyBold", as: "span" }, disabledMessage))),
|
|
110
111
|
!hideUploadedFiles &&
|
|
111
112
|
fileList && [
|
|
112
113
|
Array.from(fileList).map((file) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadFile.js","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport {\n FileSizeUnit,\n DEFAULT_MAXIMUM_MULTIPLE_FILES,\n DEFAULT_MAXIMUM_FILE_BYTES,\n} from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Disabled, Error, Hint, Label, RootStack } from '../../hoc/withLabels/styled';\nimport { UploadedFile } from '../UploadedFile';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = DEFAULT_MAXIMUM_FILE_BYTES,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n onFileRemoved,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage = '',\n onFileInputCancelled,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile({ onFileInputCancelled });\n\n useValidateInput({ inputRef, fileList, fileTypes, maxBytes, errorMessage });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasError = !!((errorMessage || inputRef.current?.validationMessage) && !fileList?.length);\n\n return (\n <RootStack spacing=\"xs\" alignX=\"stretch\">\n <Label htmlFor={id}>\n {label}\n <FlexCol>\n <Hint>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Hint>\n <DropZoneContainer\n hasError={hasError}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Label>\n <FlexCol>\n {hasError && (\n <FlexRow>\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <Error>{errorMessage || inputRef.current?.validationMessage}</Error>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n <Disabled>{disabledMessage}</Disabled>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n onRemoveFile={(fileToRemove) => {\n removeFileFromList(fileToRemove);\n onFileRemoved?.(fileToRemove);\n }}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </RootStack>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;AA2BO,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,EA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AAA,aAAA,CAAC,QAAQ,EAAA,IAAA,EAAE,eAAe,CAAY,CAC9B,CACX;AACA,YAAA,CAAC,iBAAiB;AACjB,gBAAA,QAAQ,IAAI;gBACV,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;oBAChC,QACEA,6BAAC,YAAY,EAAA,EACX,GAAG,EAAE,CAAA,EAAG,IAAI,CAAC,IAAI,EAAE,EACnB,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,YAAY,KAAI;4BAC7B,kBAAkB,CAAC,YAAY,CAAC;AAChC,4BAAA,aAAa,aAAb,aAAa,KAAA,MAAA,GAAA,MAAA,GAAb,aAAa,CAAG,YAAY,CAAC;AAC/B,wBAAA,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,gBAAA,CAAC,CAAC;aACH,CACK,CACA;AAEhB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"UploadFile.js","sources":["../../../src/components/UploadFile/UploadFile.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useState,\n DragEvent,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { theme } from 'Theme';\nimport { CriticalIcon, LockIcon } from '../../icons';\nimport { DropZoneContainer } from './styled';\nimport {\n FileSizeUnit,\n DEFAULT_MAXIMUM_MULTIPLE_FILES,\n DEFAULT_MAXIMUM_FILE_BYTES,\n} from './constants';\nimport { UploadCopy } from './components/UploadCopy/UploadCopy';\nimport { DropCopy } from './components/DropCopy/DropCopy';\nimport { getFileSizeString, getTypePropForInputEl, getValidTypesString } from './utils';\nimport { UploadFileProps } from './types';\nimport { Text } from '../Text';\nimport { FlexCol } from '../Flex/FlexCol';\nimport labelStyles from '../../hoc/withLabels/withLabels.module.scss';\nimport { UploadedFile } from '../UploadedFile';\nimport { FlexRow } from '../Flex/FlexRow';\nimport { useUploadFile } from './hooks/useUploadFile';\nimport { useValidateInput } from './hooks/useValidateInput';\n\nexport const UploadFile = forwardRef<HTMLInputElement, UploadFileProps>(\n (\n {\n id,\n name,\n maxBytes = DEFAULT_MAXIMUM_FILE_BYTES,\n format = FileSizeUnit.MB,\n fileTypes,\n disabled,\n multiple,\n label = multiple ? 'Upload files' : 'Upload file',\n hideUploadedFiles = false,\n onMaxFilesExceeded,\n onFileRemoved,\n maxFiles = DEFAULT_MAXIMUM_MULTIPLE_FILES,\n disabledMessage,\n errorMessage = '',\n onFileInputCancelled,\n ...otherProps\n }: UploadFileProps,\n outerRef,\n ) => {\n const { inputRef, fileList, setFileList, onCancel, removeFileFromList, clearFileSelection } =\n useUploadFile({ onFileInputCancelled });\n\n useValidateInput({ inputRef, fileList, fileTypes, maxBytes, errorMessage });\n\n useImperativeHandle(outerRef, () => inputRef.current!, [inputRef]);\n\n const [isDragOver, setIsDragOver] = useState(false);\n\n // Computed properties based on params\n const maxSizeCopy = getFileSizeString({ maxBytes, format });\n const acceptedTypesCopy = getValidTypesString({ fileTypes });\n const acceptedTypesForInputEl = getTypePropForInputEl({ fileTypes });\n\n const validateMaximumFiles = useCallback(\n (files: FileList | null | undefined) => {\n if (files?.length && files?.length > maxFiles) {\n clearFileSelection();\n onMaxFilesExceeded?.();\n return false;\n }\n return true;\n },\n [clearFileSelection, maxFiles, onMaxFilesExceeded],\n );\n\n // Processes file and updates the UI appropriately:\n const updateFiles = useCallback(\n (files: FileList) => {\n if (!files.length) {\n return;\n }\n\n setFileList(files);\n },\n [setFileList],\n );\n\n // For focussing of input el and updating drop UI\n const onDragEnter = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(true);\n inputRef.current?.focus();\n };\n\n // For unfocussing of input el and updating drop UI\n const onDragLeave = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n };\n\n // Prevents default browser behaviour\n const onDragOver = (event: DragEvent<HTMLElement>) => event.preventDefault();\n\n // Process file when dropped into eligible area\n const onDrop = (event: DragEvent<HTMLElement>) => {\n event.preventDefault();\n setIsDragOver(false);\n // Prevent reactions on dragging events that do not contain files\n if (!event.dataTransfer.files.length) return;\n\n const canUpdateFiles = validateMaximumFiles(event.dataTransfer.files);\n if (canUpdateFiles) {\n updateFiles(event.dataTransfer.files);\n }\n };\n\n // Updates UI based on a native file input change. Attached via useEffect below\n const onChange = useCallback(() => {\n const canUpdateFiles = validateMaximumFiles(inputRef?.current?.files);\n const files = inputRef?.current?.files;\n if (canUpdateFiles && files) {\n updateFiles(files);\n } else if (fileList) {\n updateFiles(fileList);\n }\n }, [validateMaximumFiles, inputRef, fileList, updateFiles]);\n\n useEffect(() => {\n const ref = inputRef?.current;\n ref?.addEventListener('change', onChange);\n ref?.addEventListener('cancel', onCancel);\n\n return () => {\n ref?.removeEventListener('change', onChange);\n ref?.removeEventListener('cancel', onCancel);\n };\n }, [onChange, onCancel, inputRef]);\n\n const hasError = !!((errorMessage || inputRef.current?.validationMessage) && !fileList?.length);\n\n return (\n <FlexCol gap=\"xs\" className={labelStyles.rootStack}>\n <Text variant=\"inputLabel\" as=\"label\" htmlFor={id}>\n {label}\n <FlexCol>\n <Text variant=\"hintText\" as=\"span\" className={labelStyles.hint}>\n {maxSizeCopy}\n <br />\n {acceptedTypesCopy}\n </Text>\n <DropZoneContainer\n hasError={hasError}\n isDragOver={isDragOver}\n data-testid=\"drop-zone-container\"\n onDrop={onDrop}\n onDragEnter={onDragEnter}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n >\n {isDragOver ? <DropCopy /> : <UploadCopy />}\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={acceptedTypesForInputEl}\n name={name}\n disabled={disabled}\n multiple={multiple}\n {...otherProps}\n />\n </DropZoneContainer>\n </FlexCol>\n </Text>\n <FlexCol>\n {hasError && (\n <FlexRow>\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <Text variant=\"error\" as=\"span\" className={labelStyles.error}>{errorMessage || inputRef.current?.validationMessage}</Text>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${id}-disabled`}>\n <LockIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n <Text variant=\"bodyBold\" as=\"span\">{disabledMessage}</Text>\n </FlexRow>\n )}\n {!hideUploadedFiles &&\n fileList && [\n Array.from(fileList).map((file) => {\n return (\n <UploadedFile\n key={`${file.name}`}\n file={file}\n onRemoveFile={(fileToRemove) => {\n removeFileFromList(fileToRemove);\n onFileRemoved?.(fileToRemove);\n }}\n disabled={disabled}\n format={format}\n maxBytes={maxBytes}\n fileTypes={fileTypes}\n />\n );\n }),\n ]}\n </FlexCol>\n </FlexCol>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BO,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAAG,0BAA0B,EACrC,MAAM,GAAG,YAAY,CAAC,EAAE,EACxB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,GAAG,QAAQ,GAAG,cAAc,GAAG,aAAa,EACjD,iBAAiB,GAAG,KAAK,EACzB,kBAAkB,EAClB,aAAa,EACb,QAAQ,GAAG,8BAA8B,EACzC,eAAe,EACf,YAAY,GAAG,EAAE,EACjB,oBAAoB,EACpB,GAAG,UAAU,EACG,EAClB,QAAQ,KACN;;IACF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GACzF,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;AAEzC,IAAA,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AAE3E,IAAA,mBAAmB,CAAC,QAAQ,EAAE,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;4BAC7B,kBAAkB,CAAC,YAAY,CAAC;AAChC,4BAAA,aAAa,aAAb,aAAa,KAAA,MAAA,GAAA,MAAA,GAAb,aAAa,CAAG,YAAY,CAAC;AAC/B,wBAAA,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EAAA,CACpB;AAEN,gBAAA,CAAC,CAAC;aACH,CACK,CACF;AAEd,CAAC;;;;"}
|
|
@@ -9,7 +9,7 @@ var Text = require('../Text/Text.cjs');
|
|
|
9
9
|
var Image = require('../Image/Image.cjs');
|
|
10
10
|
var FlexCol = require('../Flex/FlexCol/FlexCol.cjs');
|
|
11
11
|
var FlexRow = require('../Flex/FlexRow/FlexRow.cjs');
|
|
12
|
-
var
|
|
12
|
+
var withLabels_module = require('../../hoc/withLabels/withLabels.module.scss.cjs');
|
|
13
13
|
var usePreviewImage = require('./hooks/usePreviewImage/usePreviewImage.cjs');
|
|
14
14
|
var UploadedFile_module = require('./UploadedFile.module.scss.cjs');
|
|
15
15
|
var useFileErrorMessages = require('./hooks/useFileErrorMessages/useFileErrorMessages.cjs');
|
|
@@ -37,7 +37,7 @@ const UploadedFile = ({ file, onRemoveFile, disabled, format, maxBytes, fileType
|
|
|
37
37
|
const ErrorMessages = hasCriticalErrors && (React__default.default.createElement(FlexRow.FlexRow, { alignItems: "flex-start" },
|
|
38
38
|
React__default.default.createElement(CriticalIcon.ReactComponent, { width: index.theme.sizes.base, height: index.theme.sizes.base, color: index.theme.colors.secondary.red.base }),
|
|
39
39
|
React__default.default.createElement("div", { className: UploadedFile_module.singleLineWrapper },
|
|
40
|
-
React__default.default.createElement(
|
|
40
|
+
React__default.default.createElement(Text.Text, { variant: "error", as: "span", className: `${withLabels_module.error} ${UploadedFile_module.singleLineTextWithoutFlex}` }, errorMessages.criticalErrors.map((error, index, array) => {
|
|
41
41
|
const isNotLast = !!(array.length > index + 1);
|
|
42
42
|
return `${error.errorMessage}${isNotLast ? ', ' : ''}`;
|
|
43
43
|
})))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadedFile.cjs","sources":["../../../src/components/UploadedFile/UploadedFile.tsx"],"sourcesContent":["import React from 'react';\nimport { theme } from 'Theme';\nimport { Button } from '../Button';\nimport { CriticalIcon, CrossIcon } from '../../icons';\nimport { Text } from '../Text';\nimport { Image } from '../Image';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport
|
|
1
|
+
{"version":3,"file":"UploadedFile.cjs","sources":["../../../src/components/UploadedFile/UploadedFile.tsx"],"sourcesContent":["import React from 'react';\nimport { theme } from 'Theme';\nimport { Button } from '../Button';\nimport { CriticalIcon, CrossIcon } from '../../icons';\nimport { Text } from '../Text';\nimport { Image } from '../Image';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport labelStyles from '../../hoc/withLabels/withLabels.module.scss';\nimport { usePreviewImage } from './hooks/usePreviewImage';\nimport uploadedFileStyles from './UploadedFile.module.scss';\nimport { useFileErrorMessages } from './hooks/useFileErrorMessages';\nimport { AcceptedFileTypes, FileSizeUnit } from '../UploadFile/constants';\nimport { getFileSizeString } from '../UploadFile/utils';\nimport { Skeleton } from '../Skeleton';\n\nexport type UploadedFileProps = {\n file?: File | null;\n onRemoveFile?: (file: File) => void;\n disabled?: boolean;\n format: FileSizeUnit;\n maxBytes: number;\n fileTypes: Array<AcceptedFileTypes>;\n isLoading?: boolean;\n};\n\nexport const UploadedFile = ({\n file,\n onRemoveFile,\n disabled,\n format,\n maxBytes,\n fileTypes,\n isLoading,\n}: UploadedFileProps) => {\n const { previewSrc, shouldShowPreview } = usePreviewImage({ file });\n\n const { errorMessages, hasCriticalErrors } = useFileErrorMessages({\n file,\n maxBytes,\n fileTypes,\n });\n\n const fileSizeCopy = getFileSizeString({ maxBytes: file?.size || 0, format, baseString: '' });\n\n if (isLoading) {\n return <Skeleton height=\"40px\" aria-label=\"Loading file\" />;\n }\n\n if (!file) return null;\n\n const RemoveButton = (\n <Button\n size=\"sm\"\n variant=\"flat\"\n onClick={() => onRemoveFile && onRemoveFile(file)}\n iconSlot={<CrossIcon />}\n aria-label={`Remove file ${file.name}`}\n disabled={disabled}\n type=\"button\"\n />\n );\n\n const ErrorMessages = hasCriticalErrors && (\n <FlexRow alignItems=\"flex-start\">\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <div className={uploadedFileStyles.singleLineWrapper}>\n <Text variant=\"error\" as=\"span\" className={`${labelStyles.error} ${uploadedFileStyles.singleLineTextWithoutFlex}`}>\n {errorMessages.criticalErrors.map((error, index, array) => {\n const isNotLast = !!(array.length > index + 1);\n return `${error.errorMessage}${isNotLast ? ', ' : ''}`;\n })}\n </Text>\n </div>\n </FlexRow>\n );\n\n if (!shouldShowPreview) {\n return (\n <div\n className={\n hasCriticalErrors\n ? uploadedFileStyles.uploadedFileContainerCriticalError\n : uploadedFileStyles.uploadedFileContainer\n }\n >\n <FlexRow justifyContent=\"space-between\" alignItems=\"center\">\n <FlexCol style={{ flex: 1, minWidth: 0 }}>\n <div className={uploadedFileStyles.standardFileTextWrapper}>\n <Text\n className={uploadedFileStyles.singleLineText}\n variant=\"body\"\n style={{\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {file.name}\n </Text>\n <Text\n variant=\"body\"\n className={uploadedFileStyles.fileSizeText}\n style={{ color: theme.colors.neutral.ink.light }}\n >\n {fileSizeCopy}\n </Text>\n </div>\n {ErrorMessages}\n </FlexCol>\n {onRemoveFile && (\n <div style={{ display: 'flex', alignItems: 'center', marginLeft: 12 }}>\n {RemoveButton}\n </div>\n )}\n </FlexRow>\n </div>\n );\n }\n\n return (\n <div\n className={\n hasCriticalErrors\n ? uploadedFileStyles.uploadedFileContainerCriticalError\n : uploadedFileStyles.uploadedFileContainer\n }\n >\n <FlexRow style={{ flexWrap: 'nowrap' }} justifyContent=\"space-between\">\n <FlexCol>\n <FlexRow\n alignItems=\"center\"\n style={{ flex: 1, minWidth: 0, gap: theme.sizes.base }}\n flexWrap=\"nowrap\"\n >\n <Image\n className={uploadedFileStyles.previewImage}\n height=\"44\"\n width=\"44\"\n src={previewSrc}\n />\n <div className={uploadedFileStyles.singleLineWrapper}>\n <Text className={uploadedFileStyles.singleLineTextWithoutFlex} variant=\"body\">\n {file?.name}\n </Text>\n <Text\n variant=\"body\"\n className={uploadedFileStyles.singleLineTextWithoutFlex}\n style={{\n color: theme.colors.neutral.ink.light,\n }}\n >\n {fileSizeCopy}\n </Text>\n </div>\n </FlexRow>\n {ErrorMessages}\n </FlexCol>\n {onRemoveFile && RemoveButton}\n </FlexRow>\n </div>\n );\n};\n"],"names":["usePreviewImage","useFileErrorMessages","getFileSizeString","React","Skeleton","Button","CrossIcon","FlexRow","CriticalIcon","theme","uploadedFileStyles","Text","labelStyles","FlexCol","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;MA0Ba,YAAY,GAAG,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,GACS,KAAI;AACtB,IAAA,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAGA,+BAAe,CAAC,EAAE,IAAI,EAAE,CAAC;AAEnE,IAAA,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAGC,yCAAoB,CAAC;QAChE,IAAI;QACJ,QAAQ;QACR,SAAS;AACV,KAAA,CAAC;IAEF,MAAM,YAAY,GAAGC,mCAAiB,CAAC,EAAE,QAAQ,EAAE,CAAA,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,IAAI,KAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AAE7F,IAAA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AM,EAAA,EAC1E,IAAI,KAAA,IAAA,IAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CACN;AACP,wBAAAP,sBAAA,CAAA,aAAA,CAACQ,SAAI,EAAA,EACH,OAAO,EAAC,MAAM,EACd,SAAS,EAAED,mBAAkB,CAAC,yBAAyB,EACvD,KAAK,EAAE;gCACL,KAAK,EAAED,WAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK;6BACtC,EAAA,EAEA,YAAY,CACR,CACH,CACE;AACT,gBAAA,aAAa,CACN;AACT,YAAA,YAAY,IAAI,YAAY,CACrB,CACN;AAEV;;;;"}
|
|
@@ -7,7 +7,7 @@ import { Text } from '../Text/Text.js';
|
|
|
7
7
|
import { Image } from '../Image/Image.js';
|
|
8
8
|
import { FlexCol } from '../Flex/FlexCol/FlexCol.js';
|
|
9
9
|
import { FlexRow } from '../Flex/FlexRow/FlexRow.js';
|
|
10
|
-
import
|
|
10
|
+
import labelStyles from '../../hoc/withLabels/withLabels.module.scss.js';
|
|
11
11
|
import { usePreviewImage } from './hooks/usePreviewImage/usePreviewImage.js';
|
|
12
12
|
import uploadedFileStyles from './UploadedFile.module.scss.js';
|
|
13
13
|
import { useFileErrorMessages } from './hooks/useFileErrorMessages/useFileErrorMessages.js';
|
|
@@ -31,7 +31,7 @@ const UploadedFile = ({ file, onRemoveFile, disabled, format, maxBytes, fileType
|
|
|
31
31
|
const ErrorMessages = hasCriticalErrors && (React__default.createElement(FlexRow, { alignItems: "flex-start" },
|
|
32
32
|
React__default.createElement(CriticalIcon, { width: theme.sizes.base, height: theme.sizes.base, color: theme.colors.secondary.red.base }),
|
|
33
33
|
React__default.createElement("div", { className: uploadedFileStyles.singleLineWrapper },
|
|
34
|
-
React__default.createElement(
|
|
34
|
+
React__default.createElement(Text, { variant: "error", as: "span", className: `${labelStyles.error} ${uploadedFileStyles.singleLineTextWithoutFlex}` }, errorMessages.criticalErrors.map((error, index, array) => {
|
|
35
35
|
const isNotLast = !!(array.length > index + 1);
|
|
36
36
|
return `${error.errorMessage}${isNotLast ? ', ' : ''}`;
|
|
37
37
|
})))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadedFile.js","sources":["../../../src/components/UploadedFile/UploadedFile.tsx"],"sourcesContent":["import React from 'react';\nimport { theme } from 'Theme';\nimport { Button } from '../Button';\nimport { CriticalIcon, CrossIcon } from '../../icons';\nimport { Text } from '../Text';\nimport { Image } from '../Image';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport
|
|
1
|
+
{"version":3,"file":"UploadedFile.js","sources":["../../../src/components/UploadedFile/UploadedFile.tsx"],"sourcesContent":["import React from 'react';\nimport { theme } from 'Theme';\nimport { Button } from '../Button';\nimport { CriticalIcon, CrossIcon } from '../../icons';\nimport { Text } from '../Text';\nimport { Image } from '../Image';\nimport { FlexCol } from '../Flex/FlexCol';\nimport { FlexRow } from '../Flex/FlexRow';\nimport labelStyles from '../../hoc/withLabels/withLabels.module.scss';\nimport { usePreviewImage } from './hooks/usePreviewImage';\nimport uploadedFileStyles from './UploadedFile.module.scss';\nimport { useFileErrorMessages } from './hooks/useFileErrorMessages';\nimport { AcceptedFileTypes, FileSizeUnit } from '../UploadFile/constants';\nimport { getFileSizeString } from '../UploadFile/utils';\nimport { Skeleton } from '../Skeleton';\n\nexport type UploadedFileProps = {\n file?: File | null;\n onRemoveFile?: (file: File) => void;\n disabled?: boolean;\n format: FileSizeUnit;\n maxBytes: number;\n fileTypes: Array<AcceptedFileTypes>;\n isLoading?: boolean;\n};\n\nexport const UploadedFile = ({\n file,\n onRemoveFile,\n disabled,\n format,\n maxBytes,\n fileTypes,\n isLoading,\n}: UploadedFileProps) => {\n const { previewSrc, shouldShowPreview } = usePreviewImage({ file });\n\n const { errorMessages, hasCriticalErrors } = useFileErrorMessages({\n file,\n maxBytes,\n fileTypes,\n });\n\n const fileSizeCopy = getFileSizeString({ maxBytes: file?.size || 0, format, baseString: '' });\n\n if (isLoading) {\n return <Skeleton height=\"40px\" aria-label=\"Loading file\" />;\n }\n\n if (!file) return null;\n\n const RemoveButton = (\n <Button\n size=\"sm\"\n variant=\"flat\"\n onClick={() => onRemoveFile && onRemoveFile(file)}\n iconSlot={<CrossIcon />}\n aria-label={`Remove file ${file.name}`}\n disabled={disabled}\n type=\"button\"\n />\n );\n\n const ErrorMessages = hasCriticalErrors && (\n <FlexRow alignItems=\"flex-start\">\n <CriticalIcon\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.secondary.red.base}\n />\n <div className={uploadedFileStyles.singleLineWrapper}>\n <Text variant=\"error\" as=\"span\" className={`${labelStyles.error} ${uploadedFileStyles.singleLineTextWithoutFlex}`}>\n {errorMessages.criticalErrors.map((error, index, array) => {\n const isNotLast = !!(array.length > index + 1);\n return `${error.errorMessage}${isNotLast ? ', ' : ''}`;\n })}\n </Text>\n </div>\n </FlexRow>\n );\n\n if (!shouldShowPreview) {\n return (\n <div\n className={\n hasCriticalErrors\n ? uploadedFileStyles.uploadedFileContainerCriticalError\n : uploadedFileStyles.uploadedFileContainer\n }\n >\n <FlexRow justifyContent=\"space-between\" alignItems=\"center\">\n <FlexCol style={{ flex: 1, minWidth: 0 }}>\n <div className={uploadedFileStyles.standardFileTextWrapper}>\n <Text\n className={uploadedFileStyles.singleLineText}\n variant=\"body\"\n style={{\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {file.name}\n </Text>\n <Text\n variant=\"body\"\n className={uploadedFileStyles.fileSizeText}\n style={{ color: theme.colors.neutral.ink.light }}\n >\n {fileSizeCopy}\n </Text>\n </div>\n {ErrorMessages}\n </FlexCol>\n {onRemoveFile && (\n <div style={{ display: 'flex', alignItems: 'center', marginLeft: 12 }}>\n {RemoveButton}\n </div>\n )}\n </FlexRow>\n </div>\n );\n }\n\n return (\n <div\n className={\n hasCriticalErrors\n ? uploadedFileStyles.uploadedFileContainerCriticalError\n : uploadedFileStyles.uploadedFileContainer\n }\n >\n <FlexRow style={{ flexWrap: 'nowrap' }} justifyContent=\"space-between\">\n <FlexCol>\n <FlexRow\n alignItems=\"center\"\n style={{ flex: 1, minWidth: 0, gap: theme.sizes.base }}\n flexWrap=\"nowrap\"\n >\n <Image\n className={uploadedFileStyles.previewImage}\n height=\"44\"\n width=\"44\"\n src={previewSrc}\n />\n <div className={uploadedFileStyles.singleLineWrapper}>\n <Text className={uploadedFileStyles.singleLineTextWithoutFlex} variant=\"body\">\n {file?.name}\n </Text>\n <Text\n variant=\"body\"\n className={uploadedFileStyles.singleLineTextWithoutFlex}\n style={{\n color: theme.colors.neutral.ink.light,\n }}\n >\n {fileSizeCopy}\n </Text>\n </div>\n </FlexRow>\n {ErrorMessages}\n </FlexCol>\n {onRemoveFile && RemoveButton}\n </FlexRow>\n </div>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;MA0Ba,YAAY,GAAG,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,GACS,KAAI;AACtB,IAAA,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;AAEnE,IAAA,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,CAAC;QAChE,IAAI;QACJ,QAAQ;QACR,SAAS;AACV,KAAA,CAAC;IAEF,MAAM,YAAY,GAAG,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAA,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,IAAI,KAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AAE7F,IAAA,IAAI,SAAS,EAAE;QACb,OAAOA,cAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EAAC,MAAM,EAAC,MA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,MAAM,EACd,SAAS,EAAE,kBAAkB,CAAC,yBAAyB,EACvD,KAAK,EAAE;gCACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK;6BACtC,EAAA,EAEA,YAAY,CACR,CACH,CACE;AACT,gBAAA,aAAa,CACN;AACT,YAAA,YAAY,IAAI,YAAY,CACrB,CACN;AAEV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withClassNames.cjs","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"withClassNames.cjs","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../utils/buildClassnames';\n\ntype PropsOf<C> = C extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[C]\n : C extends React.ComponentType<infer P>\n ? P\n : never;\n\ntype WithClassName = { className?: string };\n\n/**\n * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when\n * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use\n * a similar approach to styled-components.\n *\n * Example usage:\n *\n * `styled.ts`:\n * ```\n * const StyledButton = withClassNames(Button, ['button', 'button--primary']);\n * ```\n *\n * `component.tsx`:\n * ```\n * <StyledButton className=\"other-class\">Click me</StyledButton>\n * ```\n *\n * @param Component Component to render with styles applied.\n * @param classNames An array of class names to apply to instances of the component.\n */\nexport const withClassNames = <\n C extends React.ComponentType<any> | keyof JSX.IntrinsicElements,\n>(\n Component: PropsOf<C> extends WithClassName ? C : never,\n classNames: string[],\n) => {\n const ComponentWithClassNames = React.forwardRef<unknown, PropsOf<C>>(\n ({ className, ...props }: any, ref) =>\n React.createElement(Component as any, {\n ...props,\n ref,\n className: buildClassnames([...classNames, className]),\n }),\n );\n\n const componentName =\n typeof Component === 'string'\n ? Component\n : (Component as React.ComponentType<any>).displayName ||\n (Component as React.ComponentType<any>).name ||\n 'Component';\n\n ComponentWithClassNames.displayName = `withClassNames(${componentName})`;\n\n return ComponentWithClassNames;\n};\n"],"names":["React","buildClassnames"],"mappings":";;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;AAmBG;MACU,cAAc,GAAG,CAG5B,SAAuD,EACvD,UAAoB,KAClB;IACF,MAAM,uBAAuB,GAAGA,sBAAK,CAAC,UAAU,CAC9C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAO,EAAE,GAAG,KAChCA,sBAAK,CAAC,aAAa,CAAC,SAAgB,EAAE;AACpC,QAAA,GAAG,KAAK;QACR,GAAG;QACH,SAAS,EAAEC,+BAAe,CAAC,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC;AACvD,KAAA,CAAC,CACL;AAED,IAAA,MAAM,aAAa,GACjB,OAAO,SAAS,KAAK;AACnB,UAAE;UACC,SAAsC,CAAC,WAAW;AAClD,YAAA,SAAsC,CAAC,IAAI;AAC5C,YAAA,WAAW;AAEjB,IAAA,uBAAuB,CAAC,WAAW,GAAG,CAAA,eAAA,EAAkB,aAAa,GAAG;AAExE,IAAA,OAAO,uBAAuB;AAChC;;;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AnyStyledComponent } from 'styled-components';
|
|
3
2
|
type PropsOf<C> = C extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[C] : C extends React.ComponentType<infer P> ? P : never;
|
|
4
3
|
type WithClassName = {
|
|
5
4
|
className?: string;
|
|
@@ -24,5 +23,5 @@ type WithClassName = {
|
|
|
24
23
|
* @param Component Component to render with styles applied.
|
|
25
24
|
* @param classNames An array of class names to apply to instances of the component.
|
|
26
25
|
*/
|
|
27
|
-
export declare const withClassNames: <C extends React.ComponentType<any> | keyof JSX.IntrinsicElements
|
|
26
|
+
export declare const withClassNames: <C extends React.ComponentType<any> | keyof JSX.IntrinsicElements>(Component: PropsOf<C> extends WithClassName ? C : never, classNames: string[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropsOf<C>> & React.RefAttributes<unknown>>;
|
|
28
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withClassNames.js","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"withClassNames.js","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport { buildClassnames } from '../../utils/buildClassnames';\n\ntype PropsOf<C> = C extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[C]\n : C extends React.ComponentType<infer P>\n ? P\n : never;\n\ntype WithClassName = { className?: string };\n\n/**\n * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when\n * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use\n * a similar approach to styled-components.\n *\n * Example usage:\n *\n * `styled.ts`:\n * ```\n * const StyledButton = withClassNames(Button, ['button', 'button--primary']);\n * ```\n *\n * `component.tsx`:\n * ```\n * <StyledButton className=\"other-class\">Click me</StyledButton>\n * ```\n *\n * @param Component Component to render with styles applied.\n * @param classNames An array of class names to apply to instances of the component.\n */\nexport const withClassNames = <\n C extends React.ComponentType<any> | keyof JSX.IntrinsicElements,\n>(\n Component: PropsOf<C> extends WithClassName ? C : never,\n classNames: string[],\n) => {\n const ComponentWithClassNames = React.forwardRef<unknown, PropsOf<C>>(\n ({ className, ...props }: any, ref) =>\n React.createElement(Component as any, {\n ...props,\n ref,\n className: buildClassnames([...classNames, className]),\n }),\n );\n\n const componentName =\n typeof Component === 'string'\n ? Component\n : (Component as React.ComponentType<any>).displayName ||\n (Component as React.ComponentType<any>).name ||\n 'Component';\n\n ComponentWithClassNames.displayName = `withClassNames(${componentName})`;\n\n return ComponentWithClassNames;\n};\n"],"names":["React"],"mappings":";;;AAWA;;;;;;;;;;;;;;;;;;;AAmBG;MACU,cAAc,GAAG,CAG5B,SAAuD,EACvD,UAAoB,KAClB;IACF,MAAM,uBAAuB,GAAGA,cAAK,CAAC,UAAU,CAC9C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAO,EAAE,GAAG,KAChCA,cAAK,CAAC,aAAa,CAAC,SAAgB,EAAE;AACpC,QAAA,GAAG,KAAK;QACR,GAAG;QACH,SAAS,EAAE,eAAe,CAAC,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC;AACvD,KAAA,CAAC,CACL;AAED,IAAA,MAAM,aAAa,GACjB,OAAO,SAAS,KAAK;AACnB,UAAE;UACC,SAAsC,CAAC,WAAW;AAClD,YAAA,SAAsC,CAAC,IAAI;AAC5C,YAAA,WAAW;AAEjB,IAAA,uBAAuB,CAAC,WAAW,GAAG,CAAA,eAAA,EAAkB,aAAa,GAAG;AAExE,IAAA,OAAO,uBAAuB;AAChC;;;;"}
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var styled = require('styled-components');
|
|
4
|
-
var Stack = require('../../components/Stack/Stack.cjs');
|
|
5
4
|
var Tooltip = require('../../components/Tooltip/Tooltip.cjs');
|
|
6
|
-
var index = require('../../theme/index.cjs');
|
|
7
|
-
var utils = require('../../theme/utils.cjs');
|
|
8
5
|
|
|
9
6
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
7
|
|
|
11
8
|
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const BlockTooltip = styled__default.default(Tooltip.Tooltip).withConfig({ displayName: "vui--BlockTooltip", componentId: "vui--3phidg" }) `display:block;&-hoverable{display:flex;}`;
|
|
10
|
+
// TODO(VQCL-7563): BlockTooltip remains as a styled-component because Tooltip
|
|
11
|
+
// uses a className-suffix convention (`${className}-hoverable`) that is
|
|
12
|
+
// incompatible with CSS Module class name hashing. Remove this SC wrapper
|
|
13
|
+
// when Tooltip is migrated to CSS Modules in a later wave.
|
|
14
|
+
const BlockTooltip = styled__default.default(Tooltip.Tooltip).withConfig({ displayName: "vui--BlockTooltip", componentId: "vui--1rp8rx" }) `display:block;&-hoverable{display:flex;}`;
|
|
19
15
|
|
|
20
16
|
exports.BlockTooltip = BlockTooltip;
|
|
21
|
-
exports.Disabled = Disabled;
|
|
22
|
-
exports.Error = Error;
|
|
23
|
-
exports.Hint = Hint;
|
|
24
|
-
exports.Label = Label;
|
|
25
|
-
exports.RootStack = RootStack;
|
|
26
17
|
//# sourceMappingURL=styled.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.cjs","sources":["../../../src/hoc/withLabels/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport {
|
|
1
|
+
{"version":3,"file":"styled.cjs","sources":["../../../src/hoc/withLabels/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Tooltip } from '../../components/Tooltip';\n\n// TODO(VQCL-7563): BlockTooltip remains as a styled-component because Tooltip\n// uses a className-suffix convention (`${className}-hoverable`) that is\n// incompatible with CSS Module class name hashing. Remove this SC wrapper\n// when Tooltip is migrated to CSS Modules in a later wave.\nexport const BlockTooltip = styled(Tooltip)`\n /* Tooltip uses inline-block containers which add more height when\n the child component is an inline element (e.g. Glyph or an SVG),\n so we need to set to block to preserve the height and fix alignment. */\n display: block;\n &-hoverable {\n display: flex;\n }\n`;\n"],"names":["styled","Tooltip"],"mappings":";;;;;;;;;AAGA;AACA;AACA;AACA;MACa,YAAY,GAAGA,uBAAM,CAACC,eAAO,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,mBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,wCAAA;;;;"}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const RootStack: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
|
|
3
|
-
direction?: "horizontal" | "vertical" | undefined;
|
|
4
|
-
alignX?: "start" | "end" | "center" | "stretch" | "between" | "around" | undefined;
|
|
5
|
-
alignY?: "start" | "end" | "center" | "stretch" | "between" | "around" | undefined;
|
|
6
|
-
spacing?: keyof import("../../components/Stack").SizeScale | undefined;
|
|
7
|
-
as?: import("react").ElementType<any> | undefined;
|
|
8
|
-
forwardedAs?: import("react").ElementType<any> | undefined;
|
|
9
|
-
} & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
|
|
10
|
-
export declare const Label: import("styled-components").StyledComponent<"label", any, {}, never>;
|
|
11
|
-
export declare const Hint: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
12
|
-
export declare const Error: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
13
|
-
export declare const Disabled: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
14
1
|
export declare const BlockTooltip: import("styled-components").StyledComponent<({ children, text, content, config, reversed, className, withTriangle, initialShouldShow, useReactPortal, }: import("../../components/Tooltip/types").TooltipProps) => JSX.Element | null, any, {}, never>;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { Stack } from '../../components/Stack/Stack.js';
|
|
3
2
|
import { Tooltip } from '../../components/Tooltip/Tooltip.js';
|
|
4
|
-
import { theme } from '../../theme/index.js';
|
|
5
|
-
import { getTextStyles } from '../../theme/utils.js';
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const BlockTooltip = styled(Tooltip).withConfig({ displayName: "vui--BlockTooltip", componentId: "vui--3phidg" }) `display:block;&-hoverable{display:flex;}`;
|
|
4
|
+
// TODO(VQCL-7563): BlockTooltip remains as a styled-component because Tooltip
|
|
5
|
+
// uses a className-suffix convention (`${className}-hoverable`) that is
|
|
6
|
+
// incompatible with CSS Module class name hashing. Remove this SC wrapper
|
|
7
|
+
// when Tooltip is migrated to CSS Modules in a later wave.
|
|
8
|
+
const BlockTooltip = styled(Tooltip).withConfig({ displayName: "vui--BlockTooltip", componentId: "vui--1rp8rx" }) `display:block;&-hoverable{display:flex;}`;
|
|
13
9
|
|
|
14
|
-
export { BlockTooltip
|
|
10
|
+
export { BlockTooltip };
|
|
15
11
|
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sources":["../../../src/hoc/withLabels/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport {
|
|
1
|
+
{"version":3,"file":"styled.js","sources":["../../../src/hoc/withLabels/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Tooltip } from '../../components/Tooltip';\n\n// TODO(VQCL-7563): BlockTooltip remains as a styled-component because Tooltip\n// uses a className-suffix convention (`${className}-hoverable`) that is\n// incompatible with CSS Module class name hashing. Remove this SC wrapper\n// when Tooltip is migrated to CSS Modules in a later wave.\nexport const BlockTooltip = styled(Tooltip)`\n /* Tooltip uses inline-block containers which add more height when\n the child component is an inline element (e.g. Glyph or an SVG),\n so we need to set to block to preserve the height and fix alignment. */\n display: block;\n &-hoverable {\n display: flex;\n }\n`;\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;MACa,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,mBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,wCAAA;;;;"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var FlexCol = require('../../components/Flex/FlexCol/FlexCol.cjs');
|
|
4
5
|
var FlexRow = require('../../components/Flex/FlexRow/FlexRow.cjs');
|
|
6
|
+
var Text = require('../../components/Text/Text.cjs');
|
|
5
7
|
var useId = require('../../hooks/useId.cjs');
|
|
6
8
|
var CriticalIcon = require('../../icons/design-system/components/CriticalIcon.cjs');
|
|
7
9
|
var HelpIcon = require('../../icons/design-system/components/HelpIcon.cjs');
|
|
8
10
|
var LockIcon = require('../../icons/design-system/components/LockIcon.cjs');
|
|
9
11
|
var index = require('../../theme/index.cjs');
|
|
10
12
|
var styled = require('./styled.cjs');
|
|
13
|
+
var withLabels_module = require('./withLabels.module.scss.cjs');
|
|
11
14
|
|
|
12
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
16
|
|
|
@@ -19,19 +22,19 @@ const withLabels = (Component) => {
|
|
|
19
22
|
const componentId = useId.useId({ id, prefix: Component.name });
|
|
20
23
|
if (!label)
|
|
21
24
|
return (React__default.default.createElement(Component, { ref: ref, id: componentId, hasError: !!error, disabled: !!disabledMessage, ...otherProps }));
|
|
22
|
-
return (React__default.default.createElement(
|
|
25
|
+
return (React__default.default.createElement(FlexCol.FlexCol, { className: withLabels_module.rootStack },
|
|
23
26
|
React__default.default.createElement(FlexRow.FlexRow, null,
|
|
24
|
-
React__default.default.createElement(
|
|
27
|
+
React__default.default.createElement(Text.Text, { variant: "inputLabel", id: `${componentId}-label`, htmlFor: componentId }, label),
|
|
25
28
|
(tooltip || tooltipContent) && (React__default.default.createElement(styled.BlockTooltip, { text: tooltip, content: tooltipContent },
|
|
26
29
|
React__default.default.createElement(HelpIcon.ReactComponent, { "data-testid": "tooltip-help", width: index.theme.sizes.base, height: index.theme.sizes.base, color: index.theme.colors.neutral.ink.light })))),
|
|
27
|
-
hint && React__default.default.createElement(
|
|
30
|
+
hint && React__default.default.createElement(Text.Text, { variant: "hintText", as: "span", className: withLabels_module.hint, id: `${componentId}-hint` }, hint),
|
|
28
31
|
React__default.default.createElement(Component, { ref: ref, id: componentId, hasError: !!error, disabled: !!disabledMessage, ...otherProps }),
|
|
29
32
|
error && (React__default.default.createElement(FlexRow.FlexRow, { id: `${componentId}-error`, gap: "xs" },
|
|
30
33
|
React__default.default.createElement(CriticalIcon.ReactComponent, { width: 16, height: 16, color: index.theme.colors.secondary.red.base }),
|
|
31
|
-
React__default.default.createElement(
|
|
34
|
+
React__default.default.createElement(Text.Text, { variant: "error", as: "span", className: withLabels_module.error }, error))),
|
|
32
35
|
disabledMessage && (React__default.default.createElement(FlexRow.FlexRow, { id: `${componentId}-disabled`, gap: "xs" },
|
|
33
36
|
React__default.default.createElement(LockIcon.ReactComponent, { width: 16, height: 16, color: index.theme.colors.neutral.ink.light }),
|
|
34
|
-
React__default.default.createElement(
|
|
37
|
+
React__default.default.createElement(Text.Text, { variant: "bodyBold", as: "span" }, disabledMessage)))));
|
|
35
38
|
});
|
|
36
39
|
ComponentWithLabels.displayName = `withLabels(${Component.displayName || Component.name || 'Component'})`;
|
|
37
40
|
return ComponentWithLabels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLabels.cjs","sources":["../../../src/hoc/withLabels/withLabels.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, ReactNode } from 'react';\n\nimport { FlexRow } from '../../components/Flex/FlexRow';\nimport { useId } from '../../hooks/useId';\nimport { CriticalIcon, HelpIcon, LockIcon } from '../../icons';\nimport { theme } from '../../theme';\n\nimport {
|
|
1
|
+
{"version":3,"file":"withLabels.cjs","sources":["../../../src/hoc/withLabels/withLabels.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, ReactNode } from 'react';\n\nimport { FlexCol } from '../../components/Flex/FlexCol';\nimport { FlexRow } from '../../components/Flex/FlexRow';\nimport { Text } from '../../components/Text';\nimport { useId } from '../../hooks/useId';\nimport { CriticalIcon, HelpIcon, LockIcon } from '../../icons';\nimport { theme } from '../../theme';\n\nimport { BlockTooltip } from './styled';\nimport styles from './withLabels.module.scss';\n\nexport interface WithLabelsProps {\n id?: string;\n label?: ReactNode;\n hint?: ReactNode;\n error?: ReactNode;\n disabledMessage?: ReactNode;\n tooltip?: string;\n tooltipContent?: ReactNode;\n}\n\n// eslint-disable-next-line @typescript-eslint/comma-dangle -- comma is required so TS knows this is a generic, not JSX\nexport const withLabels = <P, R = unknown>(Component: ComponentType<P>) => {\n const ComponentWithLabels = forwardRef<R, P & WithLabelsProps>(\n ({ label, hint, error, disabledMessage, tooltip, tooltipContent, id, ...otherProps }, ref) => {\n const componentId = useId({ id, prefix: Component.name });\n\n if (!label)\n return (\n <Component\n ref={ref}\n id={componentId}\n hasError={!!error}\n disabled={!!disabledMessage}\n {...(otherProps as P)}\n />\n );\n\n return (\n <FlexCol className={styles.rootStack}>\n <FlexRow>\n <Text variant=\"inputLabel\" id={`${componentId}-label`} htmlFor={componentId}>\n {label}\n </Text>\n {(tooltip || tooltipContent) && (\n <BlockTooltip text={tooltip} content={tooltipContent}>\n <HelpIcon\n data-testid=\"tooltip-help\"\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n </BlockTooltip>\n )}\n </FlexRow>\n {hint && <Text variant=\"hintText\" as=\"span\" className={styles.hint} id={`${componentId}-hint`}>{hint}</Text>}\n <Component\n ref={ref}\n id={componentId}\n hasError={!!error}\n disabled={!!disabledMessage}\n {...(otherProps as P)}\n />\n {error && (\n <FlexRow id={`${componentId}-error`} gap=\"xs\">\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Text variant=\"error\" as=\"span\" className={styles.error}>{error}</Text>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${componentId}-disabled`} gap=\"xs\">\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Text variant=\"bodyBold\" as=\"span\">{disabledMessage}</Text>\n </FlexRow>\n )}\n </FlexCol>\n );\n },\n );\n\n ComponentWithLabels.displayName = `withLabels(${Component.displayName || Component.name || 'Component'})`;\n\n return ComponentWithLabels;\n};\n"],"names":["forwardRef","useId","React","FlexCol","styles","FlexRow","Text","BlockTooltip","HelpIcon","theme","CriticalIcon","LockIcon"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA;AACO,MAAM,UAAU,GAAG,CAAiB,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,gBAAAP,sBAAA,CAAA,aAAA,CAACI,SAAI,EAAA,EAAC,OAAO,EAAC,UAAU,EAAC,EAAE,EAAC,MAAM,EAAA,EAAE,eAAe,CAAQ,CACnD,CACX,CACO;AAEd,IAAA,CAAC,CACF;AAED,IAAA,mBAAmB,CAAC,WAAW,GAAG,CAAA,WAAA,EAAc,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAAW,GAAG;AAEzG,IAAA,OAAO,mBAAmB;AAC5B;;;;"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React__default, { forwardRef } from 'react';
|
|
2
|
+
import { FlexCol } from '../../components/Flex/FlexCol/FlexCol.js';
|
|
2
3
|
import { FlexRow } from '../../components/Flex/FlexRow/FlexRow.js';
|
|
4
|
+
import { Text } from '../../components/Text/Text.js';
|
|
3
5
|
import { useId } from '../../hooks/useId.js';
|
|
4
6
|
import { ReactComponent as CriticalIcon } from '../../icons/design-system/components/CriticalIcon.js';
|
|
5
7
|
import { ReactComponent as HelpIcon } from '../../icons/design-system/components/HelpIcon.js';
|
|
6
8
|
import { ReactComponent as LockIcon } from '../../icons/design-system/components/LockIcon.js';
|
|
7
9
|
import { theme } from '../../theme/index.js';
|
|
8
|
-
import {
|
|
10
|
+
import { BlockTooltip } from './styled.js';
|
|
11
|
+
import labelStyles from './withLabels.module.scss.js';
|
|
9
12
|
|
|
10
13
|
// eslint-disable-next-line @typescript-eslint/comma-dangle -- comma is required so TS knows this is a generic, not JSX
|
|
11
14
|
const withLabels = (Component) => {
|
|
@@ -13,19 +16,19 @@ const withLabels = (Component) => {
|
|
|
13
16
|
const componentId = useId({ id, prefix: Component.name });
|
|
14
17
|
if (!label)
|
|
15
18
|
return (React__default.createElement(Component, { ref: ref, id: componentId, hasError: !!error, disabled: !!disabledMessage, ...otherProps }));
|
|
16
|
-
return (React__default.createElement(
|
|
19
|
+
return (React__default.createElement(FlexCol, { className: labelStyles.rootStack },
|
|
17
20
|
React__default.createElement(FlexRow, null,
|
|
18
|
-
React__default.createElement(
|
|
21
|
+
React__default.createElement(Text, { variant: "inputLabel", id: `${componentId}-label`, htmlFor: componentId }, label),
|
|
19
22
|
(tooltip || tooltipContent) && (React__default.createElement(BlockTooltip, { text: tooltip, content: tooltipContent },
|
|
20
23
|
React__default.createElement(HelpIcon, { "data-testid": "tooltip-help", width: theme.sizes.base, height: theme.sizes.base, color: theme.colors.neutral.ink.light })))),
|
|
21
|
-
hint && React__default.createElement(
|
|
24
|
+
hint && React__default.createElement(Text, { variant: "hintText", as: "span", className: labelStyles.hint, id: `${componentId}-hint` }, hint),
|
|
22
25
|
React__default.createElement(Component, { ref: ref, id: componentId, hasError: !!error, disabled: !!disabledMessage, ...otherProps }),
|
|
23
26
|
error && (React__default.createElement(FlexRow, { id: `${componentId}-error`, gap: "xs" },
|
|
24
27
|
React__default.createElement(CriticalIcon, { width: 16, height: 16, color: theme.colors.secondary.red.base }),
|
|
25
|
-
React__default.createElement(
|
|
28
|
+
React__default.createElement(Text, { variant: "error", as: "span", className: labelStyles.error }, error))),
|
|
26
29
|
disabledMessage && (React__default.createElement(FlexRow, { id: `${componentId}-disabled`, gap: "xs" },
|
|
27
30
|
React__default.createElement(LockIcon, { width: 16, height: 16, color: theme.colors.neutral.ink.light }),
|
|
28
|
-
React__default.createElement(
|
|
31
|
+
React__default.createElement(Text, { variant: "bodyBold", as: "span" }, disabledMessage)))));
|
|
29
32
|
});
|
|
30
33
|
ComponentWithLabels.displayName = `withLabels(${Component.displayName || Component.name || 'Component'})`;
|
|
31
34
|
return ComponentWithLabels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLabels.js","sources":["../../../src/hoc/withLabels/withLabels.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, ReactNode } from 'react';\n\nimport { FlexRow } from '../../components/Flex/FlexRow';\nimport { useId } from '../../hooks/useId';\nimport { CriticalIcon, HelpIcon, LockIcon } from '../../icons';\nimport { theme } from '../../theme';\n\nimport {
|
|
1
|
+
{"version":3,"file":"withLabels.js","sources":["../../../src/hoc/withLabels/withLabels.tsx"],"sourcesContent":["import React, { ComponentType, forwardRef, ReactNode } from 'react';\n\nimport { FlexCol } from '../../components/Flex/FlexCol';\nimport { FlexRow } from '../../components/Flex/FlexRow';\nimport { Text } from '../../components/Text';\nimport { useId } from '../../hooks/useId';\nimport { CriticalIcon, HelpIcon, LockIcon } from '../../icons';\nimport { theme } from '../../theme';\n\nimport { BlockTooltip } from './styled';\nimport styles from './withLabels.module.scss';\n\nexport interface WithLabelsProps {\n id?: string;\n label?: ReactNode;\n hint?: ReactNode;\n error?: ReactNode;\n disabledMessage?: ReactNode;\n tooltip?: string;\n tooltipContent?: ReactNode;\n}\n\n// eslint-disable-next-line @typescript-eslint/comma-dangle -- comma is required so TS knows this is a generic, not JSX\nexport const withLabels = <P, R = unknown>(Component: ComponentType<P>) => {\n const ComponentWithLabels = forwardRef<R, P & WithLabelsProps>(\n ({ label, hint, error, disabledMessage, tooltip, tooltipContent, id, ...otherProps }, ref) => {\n const componentId = useId({ id, prefix: Component.name });\n\n if (!label)\n return (\n <Component\n ref={ref}\n id={componentId}\n hasError={!!error}\n disabled={!!disabledMessage}\n {...(otherProps as P)}\n />\n );\n\n return (\n <FlexCol className={styles.rootStack}>\n <FlexRow>\n <Text variant=\"inputLabel\" id={`${componentId}-label`} htmlFor={componentId}>\n {label}\n </Text>\n {(tooltip || tooltipContent) && (\n <BlockTooltip text={tooltip} content={tooltipContent}>\n <HelpIcon\n data-testid=\"tooltip-help\"\n width={theme.sizes.base}\n height={theme.sizes.base}\n color={theme.colors.neutral.ink.light}\n />\n </BlockTooltip>\n )}\n </FlexRow>\n {hint && <Text variant=\"hintText\" as=\"span\" className={styles.hint} id={`${componentId}-hint`}>{hint}</Text>}\n <Component\n ref={ref}\n id={componentId}\n hasError={!!error}\n disabled={!!disabledMessage}\n {...(otherProps as P)}\n />\n {error && (\n <FlexRow id={`${componentId}-error`} gap=\"xs\">\n <CriticalIcon width={16} height={16} color={theme.colors.secondary.red.base} />\n <Text variant=\"error\" as=\"span\" className={styles.error}>{error}</Text>\n </FlexRow>\n )}\n {disabledMessage && (\n <FlexRow id={`${componentId}-disabled`} gap=\"xs\">\n <LockIcon width={16} height={16} color={theme.colors.neutral.ink.light} />\n <Text variant=\"bodyBold\" as=\"span\">{disabledMessage}</Text>\n </FlexRow>\n )}\n </FlexCol>\n );\n },\n );\n\n ComponentWithLabels.displayName = `withLabels(${Component.displayName || Component.name || 'Component'})`;\n\n return ComponentWithLabels;\n};\n"],"names":["React","styles"],"mappings":";;;;;;;;;;;;AAsBA;AACO,MAAM,UAAU,GAAG,CAAiB,SAA2B,KAAI;IACxE,MAAM,mBAAmB,GAAG,UAAU,CACpC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,UAAU,EAAE,EAAE,GAAG,KAAI;AAC3F,QAAA,MAAM,WAAW,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;AAEzD,QAAA,IAAI,CAAC,KAAK;YACR,QACEA,cAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EACR,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,CAAC,CAAC,KAAK,EACjB,QAAQ,EAAE,CAAC,CAAC,eAAe,EAAA,GACtB,UAAgB,EAAA,CACrB;QAGN,QACEA,6BAAC,OAAO,EAAA,EAAC,SAAS,EAAEC,WAAM,CAAC,SAAS,EAAA;AAClC,YAAAD,cAAA,CAAA,aAAA,CAAC,OAAO,EAAA,IAAA;AACN,gBAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,OAAO,EAAC,YAAY,EAAC,EAAE,EAAE,CAAA,EAAG,WAAW,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAA,EACxE,KAAK,CACD;AACN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SAAS,EAAEC,WAAM,CAAC,KAAK,IAAG,KAAK,CAAQ,CAC/D,CACX;AACA,YAAA,eAAe,KACdD,cAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,EAAE,EAAE,CAAA,EAAG,WAAW,CAAA,SAAA,CAAW,EAAE,GAAG,EAAC,IAAI,EAAA;gBAC9CA,cAAA,CAAA,aAAA,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAA,CAAI;AAC1E,gBAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,OAAO,EAAC,UAAU,EAAC,EAAE,EAAC,MAAM,EAAA,EAAE,eAAe,CAAQ,CACnD,CACX,CACO;AAEd,IAAA,CAAC,CACF;AAED,IAAA,mBAAmB,CAAC,WAAW,GAAG,CAAA,WAAA,EAAc,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAAW,GAAG;AAEzG,IAAA,OAAO,mBAAmB;AAC5B;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ___$insertStyle = require('../../_virtual/____insertStyle.cjs');
|
|
4
|
+
|
|
5
|
+
___$insertStyle("._rootStack_1rs8c_1 {\n position: relative;\n}\n\n/* Overrides hintText token's 12px/16px to use body font-size/line-height */\n._hint_1rs8c_6 {\n margin-top: var(--sizes-xs);\n font-size: var(--text-body-font-size);\n line-height: var(--text-body-line-height);\n}\n\n/* Error token uses font-weight: 600, but form errors render at normal weight */\n._error_1rs8c_13 {\n font-weight: normal;\n}");
|
|
6
|
+
var labelStyles = {"rootStack":"_rootStack_1rs8c_1","hint":"_hint_1rs8c_6","error":"_error_1rs8c_13"};
|
|
7
|
+
|
|
8
|
+
module.exports = labelStyles;
|
|
9
|
+
//# sourceMappingURL=withLabels.module.scss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withLabels.module.scss.cjs","sources":["../../../src/hoc/withLabels/withLabels.module.scss"],"sourcesContent":[".rootStack {\n position: relative;\n}\n\n/* Overrides hintText token's 12px/16px to use body font-size/line-height */\n.hint {\n margin-top: var(--sizes-xs);\n font-size: var(--text-body-font-size);\n line-height: var(--text-body-line-height);\n}\n\n/* Error token uses font-weight: 600, but form errors render at normal weight */\n.error {\n font-weight: normal;\n}\n"],"names":[],"mappings":";;;;AACE,eAAA,CAAA,iZAAA;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import insertStyle from '../../_virtual/____insertStyle.js';
|
|
2
|
+
|
|
3
|
+
insertStyle("._rootStack_1rs8c_1 {\n position: relative;\n}\n\n/* Overrides hintText token's 12px/16px to use body font-size/line-height */\n._hint_1rs8c_6 {\n margin-top: var(--sizes-xs);\n font-size: var(--text-body-font-size);\n line-height: var(--text-body-line-height);\n}\n\n/* Error token uses font-weight: 600, but form errors render at normal weight */\n._error_1rs8c_13 {\n font-weight: normal;\n}");
|
|
4
|
+
var labelStyles = {"rootStack":"_rootStack_1rs8c_1","hint":"_hint_1rs8c_6","error":"_error_1rs8c_13"};
|
|
5
|
+
|
|
6
|
+
export { labelStyles as default };
|
|
7
|
+
//# sourceMappingURL=withLabels.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withLabels.module.scss.js","sources":["../../../src/hoc/withLabels/withLabels.module.scss"],"sourcesContent":[".rootStack {\n position: relative;\n}\n\n/* Overrides hintText token's 12px/16px to use body font-size/line-height */\n.hint {\n margin-top: var(--sizes-xs);\n font-size: var(--text-body-font-size);\n line-height: var(--text-body-line-height);\n}\n\n/* Error token uses font-weight: 600, but form errors render at normal weight */\n.error {\n font-weight: normal;\n}\n"],"names":["___$insertStyle"],"mappings":";;AACEA,WAAA,CAAA,iZAAA;;;;;"}
|