@pega/cosmos-react-core 8.20.0 → 8.21.1
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/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.js +6 -6
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts +1 -0
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.js +30 -1
- package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +1 -1
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/Duration/DurationInput.js +1 -1
- package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +1 -1
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.js +1 -1
- package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +1 -1
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.js +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +1 -1
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +10 -19
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileInput.styles.d.ts +3 -1
- package/lib/components/File/FileInput.styles.d.ts.map +1 -1
- package/lib/components/File/FileInput.styles.js +16 -18
- package/lib/components/File/FileInput.styles.js.map +1 -1
- package/lib/components/FormField/FormField.d.ts +1 -1
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +34 -32
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Number/NumberRangeInput.d.ts.map +1 -1
- package/lib/components/Number/NumberRangeInput.js +1 -1
- package/lib/components/Number/NumberRangeInput.js.map +1 -1
- package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.js +1 -1
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.js +3 -2
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts +3 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +30 -15
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +2 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +2 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +3 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +2 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUtF,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,KAAK,EAAE,EAAsC,MAAM,UAAU,CAAC;AACrE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,EACV,eAAe,EAC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":["import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Ref, ChangeEvent, PropsWithoutRef, DragEvent } from 'react';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport {\n useConsolidatedRef,\n useI18n,\n useUID,\n useTestIds,\n usePrevious,\n useElement,\n useModalManager,\n useModalContext,\n useLiveLog\n} from '../../hooks';\nimport type { FormControlProps } from '../FormControl';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport { getActiveElement, getFocusables, withTestIds, createClassName } from '../../utils';\nimport Tooltip from '../Tooltip';\nimport Button from '../Button';\nimport Modal, { type ModalMethods, type ModalProps } from '../Modal';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport MetaList from '../MetaList';\n\nimport type { FileItemProps } from './FileItem';\nimport { getFileInputTestIds } from './File.test-ids';\nimport FileList from './FileList';\nimport type { FileListProps } from './FileList';\nimport FileItem from './FileItem';\nimport {\n StyledBareButton,\n StyledDropZone,\n StyledFileInput,\n StyledIconWrapper,\n StyledAttachedFileCount,\n StyledSingleFileWrapper,\n StyledUploadStatus,\n StyledFlex,\n StyledFormField,\n StyledFileInputControl,\n StyledDownloadAllButton\n} from './FileInput.styles';\n\nregisterIcon(paperClipIcon);\n\n/** Props to be used when rendering compact variant for multiple FileInput. */\ninterface MultiAttachCompactProps {\n /** Modal props */\n modal?: Pick<ModalProps, 'onBeforeOpen'> & {\n /** Callback for cancel button */\n onCancel: ({ close }: { close: () => void }) => void;\n /** Callback for submit button */\n onSubmit: ({ close }: { close: () => void }) => void;\n /** If true renders loading indicator inside Modal. */\n loading?: boolean;\n };\n /** Conveys the number of files attached */\n count?: number;\n}\n\ninterface ComponentProps\n extends Pick<BaseFileInputProps, 'compact' | 'multiple' | 'status' | 'readOnly'>,\n Pick<MultiAttachCompactProps, 'count'> {\n dragOver?: boolean;\n}\n\ninterface BaseFileInputProps\n extends BaseProps,\n NoChildrenProp,\n TestIdProp,\n Pick<FileItemProps, 'previewFromActions'>,\n Pick<FileListProps, 'onDownloadAll'> {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /**\n * Renders compact variant.\n * @default false\n */\n compact?: boolean;\n /** An array of files that have been uploaded. */\n files?: OmitStrict<FileItemProps, 'previewFromActions'>[];\n /**\n * Specify allowed file types.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept}\n */\n accept?: string | string[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport interface FileInputProps extends BaseFileInputProps, MultiAttachCompactProps {}\n\nconst Component = ({\n compact,\n multiple,\n status,\n count,\n dragOver = false,\n readOnly\n}: ComponentProps) => {\n const t = useI18n();\n\n const attachedFileCount =\n multiple && count ? (\n <StyledAttachedFileCount>{t('number_of_items', [count], { count })}</StyledAttachedFileCount>\n ) : undefined;\n\n return (\n <>\n <StyledUploadStatus\n item={{ grow: 1 }}\n container={{ justify: compact && multiple ? 'start' : 'center', alignItems: 'center' }}\n status={status}\n dragOver={dragOver}\n readOnly={readOnly}\n >\n <Text variant='secondary'>\n {compact\n ? attachedFileCount\n : t('file_upload_text_main', [\n t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')\n ])}\n </Text>\n </StyledUploadStatus>\n\n <StyledIconWrapper container={{ justify: 'center', alignItems: 'center' }}>\n <Icon name='paper-clip' />\n </StyledIconWrapper>\n </>\n );\n};\n\nconst BaseFileInput: ForwardRefForwardPropsComponent<BaseFileInputProps> = forwardRef(\n function FileInput(props: PropsWithoutRef<BaseFileInputProps>, ref: BaseFileInputProps['ref']) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n readOnly = false,\n files,\n onDownloadAll,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n accept,\n compact = false,\n previewFromActions = false,\n className,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n const [target, setTarget] = useElement<HTMLElement>();\n\n const inputRef = useConsolidatedRef(ref);\n const fileItemListRef = useRef<HTMLDivElement>();\n const activeElement = getActiveElement();\n const activeElementInList = fileItemListRef.current?.contains(activeElement);\n const isInputActiveElement = activeElement === inputRef.current;\n const compactWithSingleAttach = compact && !multiple;\n\n const filesAnnounced = useRef(false);\n const announcedFilesSet = useRef<Set<string>>(new Set());\n const { announcePolite } = useLiveLog();\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const hideFileInput = !multiple && files && files.length > 0;\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n id={id}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n className={createClassName('file-input', className, {\n compact\n })}\n onChange={onChange}\n onFocus={() => {\n if (target) {\n target.dispatchEvent(new Event('focusin'));\n }\n }}\n onBlur={() => {\n if (target) {\n target.dispatchEvent(new Event('focusout'));\n }\n }}\n multiple={multiple}\n accept={Array.isArray(accept) ? accept.join(',') : accept}\n aria-describedby={`${id}-info`}\n onClick={\n readOnly\n ? e => {\n e.preventDefault();\n }\n : undefined\n }\n />\n <Flex\n container\n as={StyledDropZone}\n disabled={disabled}\n readOnly={readOnly}\n onClick={() => {\n inputRef.current?.focus();\n if (!readOnly) {\n inputRef.current?.click();\n }\n }}\n {...(!disabled && !readOnly\n ? {\n onDragOver: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n },\n onDragEnter: () => setDragOver(true),\n onDragLeave: () => setDragOver(false),\n onDrop: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n\n const fileList = Array.from(e.dataTransfer.files);\n onFilesAdded?.(multiple ? fileList : fileList.slice(0, 1));\n }\n }\n : undefined)}\n compactMode={compact}\n ref={setTarget}\n >\n <Component\n compact={compact}\n multiple={multiple}\n status={status}\n dragOver={dragOver}\n readOnly={readOnly}\n />\n </Flex>\n {compactWithSingleAttach && target && (\n <Tooltip target={target} describeTarget>\n {t('file_upload_text_main', [t('file_upload_text_one')])}\n </Tooltip>\n )}\n </StyledFileInput>\n );\n\n const getReadOnlyFile = (file: FileItemProps) => {\n const readOnlyFile = { ...file };\n delete readOnlyFile.onCancel;\n delete readOnlyFile.onEdit;\n delete readOnlyFile.onDelete;\n delete readOnlyFile.progress;\n return readOnlyFile;\n };\n\n const fileItemList = hideFileInput ? (\n <StyledSingleFileWrapper\n data-testid={testIds.files}\n compact={compact}\n ref={element => {\n if (element) fileItemListRef.current = element;\n }}\n >\n <FileItem\n {...(readOnly ? getReadOnlyFile(files[0]) : files[0])}\n compact={compact}\n previewFromActions={compactWithSingleAttach && previewFromActions}\n disabled={disabled}\n />\n </StyledSingleFileWrapper>\n ) : (\n <FileList\n type='item'\n items={\n readOnly\n ? files?.map(file => {\n return getReadOnlyFile(file);\n }) ?? []\n : files ?? []\n }\n data-testid={testIds.files}\n disabled={disabled}\n ref={element => {\n if (element) fileItemListRef.current = element;\n }}\n />\n );\n\n const prevFiles = usePrevious(files);\n\n useEffect(() => {\n if (\n !multiple &&\n prevFiles?.length === 0 &&\n files?.length === 1 &&\n fileItemListRef.current &&\n isInputActiveElement\n ) {\n getFocusables(fileItemListRef.current)[0]?.focus();\n }\n\n if (prevFiles?.length === 1 && files?.length === 0 && activeElementInList) {\n inputRef.current?.focus();\n }\n\n if (!files) return;\n\n if (announcedFilesSet.current.size !== files.length) {\n filesAnnounced.current = false;\n }\n if ((prevFiles?.length ?? 0) > files.length) {\n announcedFilesSet.current = new Set(\n Array.from(announcedFilesSet.current).filter(item => files.some(file => file.id === item))\n );\n }\n\n const errorFiles = files.filter(\n item => !announcedFilesSet.current.has(item.id) && item.error\n );\n const progressFiles = files.filter(\n item =>\n !announcedFilesSet.current.has(item.id) &&\n ('progress' in item ? typeof item.progress === 'number' && item.progress > 99 : true)\n );\n const totalAttachedFilesLength = progressFiles.length + errorFiles.length;\n\n if (\n totalAttachedFilesLength > 0 &&\n files.length - announcedFilesSet.current.size === totalAttachedFilesLength &&\n !filesAnnounced.current\n ) {\n if (progressFiles.length > 0) {\n announcePolite({\n message: t('files_uploaded', [progressFiles.length], { count: progressFiles.length })\n });\n progressFiles.forEach(file => {\n if (file.id && !announcedFilesSet.current.has(file.id)) {\n announcedFilesSet.current.add(file.id);\n }\n });\n }\n if (errorFiles.length > 0) {\n announcePolite({\n message: t('files_upload_failed', [errorFiles.length], { count: errorFiles.length })\n });\n errorFiles.forEach(file => {\n if (file.id && !announcedFilesSet.current.has(file.id)) {\n announcedFilesSet.current.add(file.id);\n }\n });\n }\n filesAnnounced.current = true;\n }\n }, [files]);\n\n const renderElement = hideFileInput ? fileItemList : fileInput;\n\n const fileInputInfoActions = useMemo(() => {\n if (info && !onDownloadAll) {\n return info;\n }\n\n const downloadAllButton = (\n <Button onClick={onDownloadAll} variant='link'>\n {t('download_all')}\n </Button>\n );\n\n if (onDownloadAll && !info && files && files.length > 1 && multiple) {\n return downloadAllButton;\n }\n\n if (info && onDownloadAll) {\n if (files && files.length > 1 && multiple) {\n return <MetaList items={[info, downloadAllButton]} />;\n }\n return info;\n }\n }, [info, onDownloadAll]);\n\n return (\n <Flex\n container={{ rowGap: hideFileInput ? undefined : 1, direction: 'column' }}\n as={StyledFileInputControl}\n status={status}\n >\n {label ? (\n <StyledFormField\n testId={testIds}\n label={\n <>\n {label}\n {readOnly && <VisuallyHiddenText>{t('read_only')}</VisuallyHiddenText>}\n </>\n }\n labelHidden={labelHidden}\n id={id}\n info={fileInputInfoActions}\n required={required}\n disabled={!hideFileInput && disabled}\n readOnly={readOnly}\n status={status}\n additionalInfo={additionalInfo}\n compactMode={compactWithSingleAttach}\n >\n <>\n {renderElement}\n {readOnly && files && files.length > 1 && multiple && (\n <StyledDownloadAllButton variant='link' onClick={onDownloadAll}>\n {t('download_all')}\n </StyledDownloadAllButton>\n )}\n </>\n </StyledFormField>\n ) : (\n renderElement\n )}\n {multiple && !compact && files && files.length > 0 && fileItemList}\n </Flex>\n );\n }\n);\n\nconst AttachFilesModal = ({\n modalContent,\n modal,\n readOnly\n}: {\n modalContent?: JSX.Element;\n readOnly: FileInputProps['readOnly'];\n} & Pick<MultiAttachCompactProps, 'modal'>) => {\n const t = useI18n();\n const { dismiss } = useModalContext();\n\n const formActions = (\n <>\n <Button\n disabled={modal?.loading}\n onClick={() => {\n if (modal?.onCancel) modal.onCancel({ close: dismiss });\n }}\n >\n {t('cancel')}\n </Button>\n\n <Button\n disabled={modal?.loading}\n type='submit'\n variant='primary'\n onClick={() => {\n if (modal?.onSubmit) modal.onSubmit({ close: dismiss });\n }}\n >\n {t('submit')}\n </Button>\n </>\n );\n\n return (\n <Modal\n progress={modal?.loading}\n heading={t('attach_files')}\n actions={!readOnly ? formActions : undefined}\n onBeforeOpen={modal?.onBeforeOpen}\n >\n {modalContent}\n </Modal>\n );\n};\n\nconst FileInput: ForwardRefForwardPropsComponent<FileInputProps> = forwardRef(function FileInput(\n props: PropsWithoutRef<FileInputProps>,\n ref: FileInputProps['ref']\n) {\n const uid = useUID();\n const { modal, count, ...baseFileInputProps } = props;\n\n const {\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n readOnly = false,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n compact = false\n } = baseFileInputProps;\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const [buttonEl, setButtonEl] = useElement<HTMLButtonElement>();\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods>();\n\n let modalContent: JSX.Element | undefined;\n\n if (compact && multiple) {\n modalContent = (\n <BaseFileInput\n {...baseFileInputProps}\n multiple\n compact={false}\n labelHidden={false}\n ref={ref}\n />\n );\n }\n\n const modalProps = {\n modal,\n modalContent\n };\n\n useEffect(() => {\n if (compact && multiple && modal) {\n modalMethods.current?.update({\n modal,\n modalContent,\n readOnly\n });\n }\n }, [compact, multiple, modal, readOnly, modalProps]);\n\n useEffect(() => {\n return () => {\n if (modalMethods.current) {\n modalMethods.current?.dismiss();\n modalMethods.current?.unmount();\n }\n };\n }, []);\n\n if (compact && multiple) {\n const render = (\n <Flex container>\n <StyledBareButton\n id={id}\n onClick={() => {\n modalMethods.current = create(\n AttachFilesModal,\n { ...modalProps, readOnly },\n { dismissible: readOnly }\n );\n }}\n aria-label={\n count && count > 0\n ? `${t('attach_review')} ${t('number_of_items', [count], { count })}`\n : undefined\n }\n aria-describedby={`${id}-info`}\n disabled={disabled}\n {...(!disabled && !readOnly\n ? {\n onDragOver: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n },\n onDragEnter: () => setDragOver(true),\n onDragLeave: () => setDragOver(false),\n onDrop: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n if (buttonEl) buttonEl.click();\n }\n }\n : undefined)}\n ref={setButtonEl}\n >\n <StyledFlex container>\n <Component\n compact={compact}\n multiple={multiple}\n status={status}\n count={count}\n dragOver={dragOver}\n readOnly={readOnly}\n />\n </StyledFlex>\n </StyledBareButton>\n {buttonEl && (\n <Tooltip target={buttonEl} describeTarget={count === 0}>\n {count && count > 0\n ? t('attach_review')\n : t('file_upload_text_main', [t('file_upload_text_multiple')])}\n </Tooltip>\n )}\n </Flex>\n );\n\n return label ? (\n <StyledFormField\n label={label}\n labelHidden={labelHidden}\n id={id}\n info={info}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n additionalInfo={additionalInfo}\n compactMode\n >\n {render}\n </StyledFormField>\n ) : (\n render\n );\n }\n\n return <BaseFileInput {...baseFileInputProps} ref={ref} />;\n});\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUtF,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AAEr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AAK,KAAK,CAAC,YACnD,KAAK,IAAI,KAAK,GAAG,CAAC;wBACjB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC;wBACpB,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,GACxD,CACX,IACI,CACR,CAAC;QAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,eAAe,IACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,WAAW,kBAEV,MAAM,GACS,CACnB,CAAC,CAAC,CAAC,CACF,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,KAAC,aAAa,OAAK,kBAAkB,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Ref, ChangeEvent, PropsWithoutRef, DragEvent } from 'react';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport {\n useConsolidatedRef,\n useI18n,\n useUID,\n useTestIds,\n usePrevious,\n useElement,\n useModalManager,\n useModalContext,\n useLiveLog\n} from '../../hooks';\nimport type { FormControlProps } from '../FormControl';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport { getActiveElement, getFocusables, withTestIds, createClassName } from '../../utils';\nimport Tooltip from '../Tooltip';\nimport Button from '../Button';\nimport Modal, { type ModalMethods, type ModalProps } from '../Modal';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport MetaList from '../MetaList';\n\nimport type { FileItemProps } from './FileItem';\nimport { getFileInputTestIds } from './File.test-ids';\nimport FileList from './FileList';\nimport type { FileListProps } from './FileList';\nimport FileItem from './FileItem';\nimport {\n StyledBareButton,\n StyledDropZone,\n StyledFileInput,\n StyledIconWrapper,\n StyledAttachedFileCount,\n StyledSingleFileWrapper,\n StyledUploadStatus,\n StyledFlex,\n StyledFormField,\n StyledFileInputControl,\n StyledDownloadAllButton\n} from './FileInput.styles';\n\nregisterIcon(paperClipIcon);\n\n/** Props to be used when rendering compact variant for multiple FileInput. */\ninterface MultiAttachCompactProps {\n /** Modal props */\n modal?: Pick<ModalProps, 'onBeforeOpen'> & {\n /** Callback for cancel button */\n onCancel: ({ close }: { close: () => void }) => void;\n /** Callback for submit button */\n onSubmit: ({ close }: { close: () => void }) => void;\n /** If true renders loading indicator inside Modal. */\n loading?: boolean;\n };\n /** Conveys the number of files attached */\n count?: number;\n}\n\ninterface ComponentProps\n extends Pick<BaseFileInputProps, 'compact' | 'multiple' | 'status' | 'readOnly'>,\n Pick<MultiAttachCompactProps, 'count'> {\n dragOver?: boolean;\n}\n\ninterface BaseFileInputProps\n extends BaseProps,\n NoChildrenProp,\n TestIdProp,\n Pick<FileItemProps, 'previewFromActions'>,\n Pick<FileListProps, 'onDownloadAll'> {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /**\n * Renders compact variant.\n * @default false\n */\n compact?: boolean;\n /** An array of files that have been uploaded. */\n files?: OmitStrict<FileItemProps, 'previewFromActions'>[];\n /**\n * Specify allowed file types.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept}\n */\n accept?: string | string[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport interface FileInputProps extends BaseFileInputProps, MultiAttachCompactProps {}\n\nconst Component = ({\n compact,\n multiple,\n status,\n count,\n dragOver = false,\n readOnly\n}: ComponentProps) => {\n const t = useI18n();\n\n const attachedFileCount =\n multiple && count ? (\n <StyledAttachedFileCount>{t('number_of_items', [count], { count })}</StyledAttachedFileCount>\n ) : undefined;\n\n return (\n <>\n <StyledUploadStatus\n item={{ grow: 1 }}\n container={{ justify: compact && multiple ? 'start' : 'center', alignItems: 'center' }}\n status={status}\n dragOver={dragOver}\n readOnly={readOnly}\n >\n <Text variant='secondary'>\n {compact\n ? attachedFileCount\n : t('file_upload_text_main', [\n t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')\n ])}\n </Text>\n </StyledUploadStatus>\n\n <StyledIconWrapper container={{ justify: 'center', alignItems: 'center' }}>\n <Icon name='paper-clip' />\n </StyledIconWrapper>\n </>\n );\n};\n\nconst BaseFileInput: ForwardRefForwardPropsComponent<BaseFileInputProps> = forwardRef(\n function FileInput(props: PropsWithoutRef<BaseFileInputProps>, ref: BaseFileInputProps['ref']) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n readOnly = false,\n files,\n onDownloadAll,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n accept,\n compact = false,\n previewFromActions = false,\n className,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n const [target, setTarget] = useElement<HTMLElement>();\n\n const inputRef = useConsolidatedRef(ref);\n const fileItemListRef = useRef<HTMLDivElement>();\n const dropZoneRef = useConsolidatedRef(setTarget);\n const activeElement = getActiveElement();\n const activeElementInList = fileItemListRef.current?.contains(activeElement);\n const isDropZoneActiveElement = activeElement === dropZoneRef.current;\n const compactWithSingleAttach = compact && !multiple;\n\n const filesAnnounced = useRef(false);\n const announcedFilesSet = useRef<Set<string>>(new Set());\n const { announcePolite } = useLiveLog();\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const hideFileInput = !multiple && files && files.length > 0;\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n disabled={disabled}\n readOnly={readOnly}\n className={createClassName('file-input', className, {\n compact\n })}\n onChange={onChange}\n multiple={multiple}\n accept={Array.isArray(accept) ? accept.join(',') : accept}\n />\n <Flex\n container\n as={StyledDropZone}\n forwardedAs='button'\n type='button'\n id={id}\n required={required}\n aria-describedby={`${id}-file-status${info ? ` ${id}-info` : ''}`}\n disabled={disabled}\n readOnly={readOnly}\n onClick={() => {\n dropZoneRef.current?.focus();\n if (!readOnly) {\n inputRef.current?.click();\n }\n }}\n {...(!disabled && !readOnly\n ? {\n onDragOver: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n },\n onDragEnter: () => setDragOver(true),\n onDragLeave: () => setDragOver(false),\n onDrop: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n\n const fileList = Array.from(e.dataTransfer.files);\n onFilesAdded?.(multiple ? fileList : fileList.slice(0, 1));\n }\n }\n : undefined)}\n compactMode={compact}\n ref={dropZoneRef}\n >\n <Component\n compact={compact}\n multiple={multiple}\n status={status}\n dragOver={dragOver}\n readOnly={readOnly}\n />\n </Flex>\n <VisuallyHiddenText id={`${id}-file-status`}>\n {files && files.length > 0\n ? t('number_of_items', [files.length], { count: files.length })\n : t('no_file_chosen')}\n </VisuallyHiddenText>\n {compactWithSingleAttach && target && (\n <Tooltip target={target} describeTarget>\n {t('file_upload_text_main', [t('file_upload_text_one')])}\n </Tooltip>\n )}\n </StyledFileInput>\n );\n\n const getReadOnlyFile = (file: FileItemProps) => {\n const readOnlyFile = { ...file };\n delete readOnlyFile.onCancel;\n delete readOnlyFile.onEdit;\n delete readOnlyFile.onDelete;\n delete readOnlyFile.progress;\n return readOnlyFile;\n };\n\n const fileItemList = hideFileInput ? (\n <StyledSingleFileWrapper\n data-testid={testIds.files}\n compact={compact}\n ref={element => {\n if (element) fileItemListRef.current = element;\n }}\n >\n <FileItem\n {...(readOnly ? getReadOnlyFile(files[0]) : files[0])}\n compact={compact}\n previewFromActions={compactWithSingleAttach && previewFromActions}\n disabled={disabled}\n />\n </StyledSingleFileWrapper>\n ) : (\n <FileList\n type='item'\n items={\n readOnly\n ? files?.map(file => {\n return getReadOnlyFile(file);\n }) ?? []\n : files ?? []\n }\n data-testid={testIds.files}\n disabled={disabled}\n ref={element => {\n if (element) fileItemListRef.current = element;\n }}\n />\n );\n\n const prevFiles = usePrevious(files);\n\n useEffect(() => {\n if (\n !multiple &&\n prevFiles?.length === 0 &&\n files?.length === 1 &&\n fileItemListRef.current &&\n isDropZoneActiveElement\n ) {\n getFocusables(fileItemListRef.current)[0]?.focus();\n }\n\n if (prevFiles?.length === 1 && files?.length === 0 && activeElementInList) {\n dropZoneRef.current?.focus();\n }\n\n if (!files) return;\n\n if (announcedFilesSet.current.size !== files.length) {\n filesAnnounced.current = false;\n }\n if ((prevFiles?.length ?? 0) > files.length) {\n announcedFilesSet.current = new Set(\n Array.from(announcedFilesSet.current).filter(item => files.some(file => file.id === item))\n );\n }\n\n const errorFiles = files.filter(\n item => !announcedFilesSet.current.has(item.id) && item.error\n );\n const progressFiles = files.filter(\n item =>\n !announcedFilesSet.current.has(item.id) &&\n ('progress' in item ? typeof item.progress === 'number' && item.progress > 99 : true)\n );\n const totalAttachedFilesLength = progressFiles.length + errorFiles.length;\n\n if (\n totalAttachedFilesLength > 0 &&\n files.length - announcedFilesSet.current.size === totalAttachedFilesLength &&\n !filesAnnounced.current\n ) {\n if (progressFiles.length > 0) {\n announcePolite({\n message: t('files_uploaded', [progressFiles.length], { count: progressFiles.length })\n });\n progressFiles.forEach(file => {\n if (file.id && !announcedFilesSet.current.has(file.id)) {\n announcedFilesSet.current.add(file.id);\n }\n });\n }\n if (errorFiles.length > 0) {\n announcePolite({\n message: t('files_upload_failed', [errorFiles.length], { count: errorFiles.length })\n });\n errorFiles.forEach(file => {\n if (file.id && !announcedFilesSet.current.has(file.id)) {\n announcedFilesSet.current.add(file.id);\n }\n });\n }\n filesAnnounced.current = true;\n }\n }, [files]);\n\n const renderElement = hideFileInput ? fileItemList : fileInput;\n\n const fileInputInfoActions = useMemo(() => {\n if (info && !onDownloadAll) {\n return info;\n }\n\n const downloadAllButton = (\n <Button onClick={onDownloadAll} variant='link'>\n {t('download_all')}\n </Button>\n );\n\n if (onDownloadAll && !info && files && files.length > 1 && multiple) {\n return downloadAllButton;\n }\n\n if (info && onDownloadAll) {\n if (files && files.length > 1 && multiple) {\n return <MetaList items={[info, downloadAllButton]} />;\n }\n return info;\n }\n }, [info, onDownloadAll]);\n\n return (\n <Flex\n container={{ rowGap: hideFileInput ? undefined : 1, direction: 'column' }}\n as={StyledFileInputControl}\n status={status}\n >\n {label ? (\n <StyledFormField\n testId={testIds}\n label={\n <>\n {label}\n {readOnly && <VisuallyHiddenText>{t('read_only')}</VisuallyHiddenText>}\n </>\n }\n labelHidden={labelHidden}\n id={id}\n info={fileInputInfoActions}\n required={required}\n disabled={!hideFileInput && disabled}\n readOnly={readOnly}\n status={status}\n additionalInfo={additionalInfo}\n compactMode={compactWithSingleAttach}\n >\n <>\n {renderElement}\n {readOnly && files && files.length > 1 && multiple && (\n <StyledDownloadAllButton variant='link' onClick={onDownloadAll}>\n {t('download_all')}\n </StyledDownloadAllButton>\n )}\n </>\n </StyledFormField>\n ) : (\n renderElement\n )}\n {multiple && !compact && files && files.length > 0 && fileItemList}\n </Flex>\n );\n }\n);\n\nconst AttachFilesModal = ({\n modalContent,\n modal,\n readOnly\n}: {\n modalContent?: JSX.Element;\n readOnly: FileInputProps['readOnly'];\n} & Pick<MultiAttachCompactProps, 'modal'>) => {\n const t = useI18n();\n const { dismiss } = useModalContext();\n\n const formActions = (\n <>\n <Button\n disabled={modal?.loading}\n onClick={() => {\n if (modal?.onCancel) modal.onCancel({ close: dismiss });\n }}\n >\n {t('cancel')}\n </Button>\n\n <Button\n disabled={modal?.loading}\n type='submit'\n variant='primary'\n onClick={() => {\n if (modal?.onSubmit) modal.onSubmit({ close: dismiss });\n }}\n >\n {t('submit')}\n </Button>\n </>\n );\n\n return (\n <Modal\n progress={modal?.loading}\n heading={t('attach_files')}\n actions={!readOnly ? formActions : undefined}\n onBeforeOpen={modal?.onBeforeOpen}\n >\n {modalContent}\n </Modal>\n );\n};\n\nconst FileInput: ForwardRefForwardPropsComponent<FileInputProps> = forwardRef(function FileInput(\n props: PropsWithoutRef<FileInputProps>,\n ref: FileInputProps['ref']\n) {\n const uid = useUID();\n const { modal, count, ...baseFileInputProps } = props;\n\n const {\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n readOnly = false,\n onFilesAdded,\n multiple = false,\n status,\n additionalInfo,\n compact = false\n } = baseFileInputProps;\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const [buttonEl, setButtonEl] = useElement<HTMLButtonElement>();\n const { create } = useModalManager();\n const modalMethods = useRef<ModalMethods>();\n\n let modalContent: JSX.Element | undefined;\n\n if (compact && multiple) {\n modalContent = (\n <BaseFileInput\n {...baseFileInputProps}\n multiple\n compact={false}\n labelHidden={false}\n ref={ref}\n />\n );\n }\n\n const modalProps = {\n modal,\n modalContent\n };\n\n useEffect(() => {\n if (compact && multiple && modal) {\n modalMethods.current?.update({\n modal,\n modalContent,\n readOnly\n });\n }\n }, [compact, multiple, modal, readOnly, modalProps]);\n\n useEffect(() => {\n return () => {\n if (modalMethods.current) {\n modalMethods.current?.dismiss();\n modalMethods.current?.unmount();\n }\n };\n }, []);\n\n if (compact && multiple) {\n const render = (\n <Flex container>\n <StyledBareButton\n id={id}\n onClick={() => {\n modalMethods.current = create(\n AttachFilesModal,\n { ...modalProps, readOnly },\n { dismissible: readOnly }\n );\n }}\n aria-label={\n count && count > 0\n ? `${t('attach_review')} ${t('number_of_items', [count], { count })}`\n : undefined\n }\n aria-describedby={`${id}-info`}\n disabled={disabled}\n {...(!disabled && !readOnly\n ? {\n onDragOver: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n },\n onDragEnter: () => setDragOver(true),\n onDragLeave: () => setDragOver(false),\n onDrop: (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n if (buttonEl) buttonEl.click();\n }\n }\n : undefined)}\n ref={setButtonEl}\n >\n <StyledFlex container>\n <Component\n compact={compact}\n multiple={multiple}\n status={status}\n count={count}\n dragOver={dragOver}\n readOnly={readOnly}\n />\n </StyledFlex>\n </StyledBareButton>\n {buttonEl && (\n <Tooltip target={buttonEl} describeTarget={count === 0}>\n {count && count > 0\n ? t('attach_review')\n : t('file_upload_text_main', [t('file_upload_text_multiple')])}\n </Tooltip>\n )}\n </Flex>\n );\n\n return label ? (\n <StyledFormField\n label={label}\n labelHidden={labelHidden}\n id={id}\n info={info}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n additionalInfo={additionalInfo}\n compactMode\n >\n {render}\n </StyledFormField>\n ) : (\n render\n );\n }\n\n return <BaseFileInput {...baseFileInputProps} ref={ref} />;\n});\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type FormControlProps } from '../FormControl';
|
|
2
2
|
import type { FileInputProps } from './FileInput';
|
|
3
|
-
export declare const StyledDropZone: import("styled-components").StyledComponent<
|
|
3
|
+
export declare const StyledDropZone: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<FormControlProps, keyof FormControlProps> & Required<Pick<FormControlProps, never>> & {
|
|
4
|
+
hasSuggestion?: boolean;
|
|
5
|
+
} & {
|
|
4
6
|
compactMode: FileInputProps["compact"];
|
|
5
7
|
}, never>;
|
|
6
8
|
export declare const StyledUploadStatus: import("styled-components").StyledComponent<import("../..").ForwardRefForwardPropsComponent<import("../Flex").FlexProps>, import("styled-components").DefaultTheme, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAS1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,cAAc;;;iBAA4C,cAAc,CAAC,SAAS,CAAC;SA0B/F,CAAC;AAIF,eAAO,MAAM,kBAAkB;YACrB,gBAAgB,CAAC,QAAQ,CAAC;cACxB,gBAAgB,CAAC,UAAU,CAAC;cAC5B,OAAO;SAyCjB,CAAC;AAIH,eAAO,MAAM,iBAAiB,gLAe5B,CAAC;AAIH,eAAO,MAAM,eAAe,yGA2B3B,CAAC;AAIF,eAAO,MAAM,uBAAuB;aAAyB,cAAc,CAAC,SAAS,CAAC;SAarF,CAAC;AAEF,eAAO,MAAM,uBAAuB,0GAWnC,CAAC;AAIF,eAAO,MAAM,UAAU,gLAEtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,mMAwC3B,CAAC;AAIH,eAAO,MAAM,eAAe;;;iBAAoC,cAAc,CAAC,SAAS,CAAC;SASvF,CAAC;AAEH,eAAO,MAAM,sBAAsB,8MAejC,CAAC;AAIH,eAAO,MAAM,uBAAuB,oLAWlC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import {
|
|
3
|
-
import FormControl, {} from '../FormControl';
|
|
2
|
+
import { StyledFormControl } from '../FormControl';
|
|
4
3
|
import { defaultThemeProp } from '../../theme';
|
|
5
4
|
import Flex from '../Flex';
|
|
6
5
|
import BareButton from '../Button/BareButton';
|
|
@@ -9,21 +8,22 @@ import { StyledMetaListItem } from '../MetaList/MetaList';
|
|
|
9
8
|
import Button from '../Button';
|
|
10
9
|
import { calculateFontSize } from '../../styles';
|
|
11
10
|
import { StyledFileItem } from './FileItem';
|
|
12
|
-
export const StyledDropZone = styled(
|
|
11
|
+
export const StyledDropZone = styled(StyledFormControl)(({ compactMode, theme: { base: { 'hit-area': { 'finger-min': fingerMin, compact } }, components } }) => {
|
|
13
12
|
return css `
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: ${components.input.height};
|
|
15
|
+
border: none;
|
|
16
|
+
cursor: pointer;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
${compactMode &&
|
|
19
19
|
css `
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
height: ${compact};
|
|
21
|
+
`}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
@media (pointer: coarse) {
|
|
24
|
+
height: ${fingerMin};
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
27
|
});
|
|
28
28
|
StyledDropZone.defaultProps = defaultThemeProp;
|
|
29
29
|
export const StyledUploadStatus = styled(Flex)(({ dragOver, status, readOnly, theme: { base: { 'border-radius': borderRadius }, components: { 'form-field': formField, 'form-control': { 'border-color': borderColor, ':hover': { 'border-color': hoverBorderColor }, 'border-radius': formBorderRadius } } } }) => {
|
|
@@ -63,17 +63,15 @@ export const StyledIconWrapper = styled(Flex)(({ theme: { base: { 'border-radius
|
|
|
63
63
|
`;
|
|
64
64
|
});
|
|
65
65
|
StyledIconWrapper.defaultProps = defaultThemeProp;
|
|
66
|
-
export const StyledFileInput = styled.div(({ theme: { components: { 'form-control': { 'border-color': borderColor
|
|
66
|
+
export const StyledFileInput = styled.div(({ theme: { components: { 'form-control': { 'border-color': borderColor } } } }) => {
|
|
67
67
|
return css `
|
|
68
68
|
position: relative;
|
|
69
69
|
|
|
70
70
|
input {
|
|
71
|
-
|
|
71
|
+
display: none;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
box-shadow: ${boxShadow};
|
|
76
|
-
|
|
74
|
+
${StyledDropZone}:focus:not([disabled]) {
|
|
77
75
|
> ${StyledIconWrapper} {
|
|
78
76
|
border: none;
|
|
79
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.styles.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE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AGoB,WAAW;;;GAGtD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAA6C,CAAC,EAC5F,WAAW,EACZ,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,WAAW;QACb,GAAG,CAAA;;KAEF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAmC,CAAC,EACpF,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EACjB,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EACxC,EACD,MAAM,EACP,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,mBAAmB;uCACc,OAAO;QACtC,kBAAkB;iBACT,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;;;GAGzD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EACrD,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EAClE,EACF,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrE,OAAO,GAAG,CAAA;iBACK,YAAY;qCACQ,OAAO;;GAEzC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport FormControl, { type FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport BareButton from '../Button/BareButton';\nimport FormField, { StyledFormFieldInfo } from '../FormField';\nimport { StyledMetaListItem } from '../MetaList/MetaList';\nimport Button from '../Button';\nimport { calculateFontSize } from '../../styles';\n\nimport type { FileInputProps } from './FileInput';\nimport { StyledFileItem } from './FileItem';\n\nexport const StyledDropZone = styled(FormControl)<{ compactMode: FileInputProps['compact'] }>(({\n compactMode,\n theme: {\n base: {\n 'hit-area': { 'finger-min': fingerMin, compact }\n },\n components\n }\n}) => {\n return css`\n height: ${components.input.height};\n border: none;\n cursor: pointer;\n\n ${compactMode &&\n css`\n height: ${compact};\n `}\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n `;\n});\n\nStyledDropZone.defaultProps = defaultThemeProp;\n\nexport const StyledUploadStatus = styled(Flex)<{\n status: FormControlProps['status'];\n readOnly: FormControlProps['readOnly'];\n dragOver: boolean;\n}>(({\n dragOver,\n status,\n readOnly,\n theme: {\n base: { 'border-radius': borderRadius },\n components: {\n 'form-field': formField,\n 'form-control': {\n 'border-color': borderColor,\n ':hover': { 'border-color': hoverBorderColor },\n 'border-radius': formBorderRadius\n }\n }\n }\n}) => {\n return css`\n border: 0.0625rem dashed ${borderColor};\n border-start-start-radius: calc(${borderRadius} * ${formBorderRadius});\n border-end-start-radius: calc(${borderRadius} * ${formBorderRadius});\n ${!readOnly &&\n css`\n ${status &&\n css`\n border-color: ${formField[status]['status-color']};\n `};\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n\n &:hover:not([disabled]):not(:focus, :focus-within) {\n ${!status &&\n css`\n border-color: ${hoverBorderColor};\n `}\n }\n `}\n `;\n});\n\nStyledUploadStatus.defaultProps = defaultThemeProp;\n\nexport const StyledIconWrapper = styled(Flex)(({\n theme: {\n base: { 'border-radius': borderRadius },\n components: {\n 'form-control': { 'border-color': borderColor, 'border-radius': formBorderRadius }\n }\n }\n}) => {\n return css`\n border: 0.0625rem solid ${borderColor};\n border-start-end-radius: calc(${borderRadius} * ${formBorderRadius});\n border-end-end-radius: calc(${borderRadius} * ${formBorderRadius});\n border-inline-start: none;\n aspect-ratio: 1 / 1;\n `;\n});\n\nStyledIconWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledFileInput = styled.div(\n ({\n theme: {\n components: {\n 'form-control': {\n 'border-color': borderColor,\n ':focus': { 'box-shadow': boxShadow }\n }\n }\n }\n }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${boxShadow};\n\n > ${StyledIconWrapper} {\n border: none;\n }\n > ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nexport const StyledSingleFileWrapper = styled.div<{ compact: FileInputProps['compact'] }>(\n ({ compact }) => {\n return css`\n display: contents;\n\n ${compact &&\n css`\n > ${StyledFileItem} {\n width: 25ch;\n }\n `};\n `;\n }\n);\n\nexport const StyledAttachedFileCount = styled.span(\n ({\n theme: {\n base: { palette, spacing }\n }\n }) => {\n return css`\n padding-inline-start: ${spacing};\n color: ${palette.interactive};\n `;\n }\n);\n\nStyledAttachedFileCount.defaultProps = defaultThemeProp;\n\nexport const StyledFlex = styled(Flex)`\n height: inherit;\n`;\n\nexport const StyledBareButton = styled(BareButton)(({\n theme: {\n base: {\n palette,\n 'hit-area': { 'finger-min': fingerMin, compact },\n 'border-radius': baseRadius\n },\n components: {\n 'form-control': {\n 'border-color': borderColor,\n 'border-radius': radius,\n ':focus': { 'box-shadow': boxShadow }\n }\n }\n }\n}) => {\n return css`\n height: ${compact};\n width: 25ch;\n cursor: pointer;\n border-radius: calc(${baseRadius} * ${radius});\n background-color: ${palette['primary-background']};\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n\n &:focus {\n box-shadow: ${boxShadow};\n\n ${StyledIconWrapper} {\n border: none;\n }\n ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n});\n\nStyledBareButton.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled(FormField)<{ compactMode: FileInputProps['compact'] }>(({\n compactMode\n}) => {\n return css`\n ${compactMode &&\n css`\n width: 25ch;\n `};\n `;\n});\n\nexport const StyledFileInputControl = styled(Flex)<Pick<FormControlProps, 'status'>>(({\n theme: {\n base: { spacing },\n components: { 'form-field': formField }\n },\n status\n}) => {\n return css`\n ${StyledFormFieldInfo} {\n margin-block-start: calc(0.5 * ${spacing});\n ${StyledMetaListItem}:first-child {\n color: ${status && formField[status]['status-color']};\n }\n }\n `;\n});\n\nStyledFileInputControl.defaultProps = defaultThemeProp;\n\nexport const StyledDownloadAllButton = styled(Button)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n}) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n return css`\n font-size: ${infoFontSize};\n margin-block-start: calc(0.5 * ${spacing});\n align-self: flex-start;\n `;\n});\n\nStyledDownloadAllButton.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"FileInput.styles.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,SAAS,EAAE,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B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,EACP,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,mBAAmB;uCACc,OAAO;QACtC,kBAAkB;iBACT,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;;;GAGzD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EACrD,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EAClE,EACF,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrE,OAAO,GAAG,CAAA;iBACK,YAAY;qCACQ,OAAO;;GAEzC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { StyledFormControl, type FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport BareButton from '../Button/BareButton';\nimport FormField, { StyledFormFieldInfo } from '../FormField';\nimport { StyledMetaListItem } from '../MetaList/MetaList';\nimport Button from '../Button';\nimport { calculateFontSize } from '../../styles';\n\nimport type { FileInputProps } from './FileInput';\nimport { StyledFileItem } from './FileItem';\n\nexport const StyledDropZone = styled(StyledFormControl)<{ compactMode: FileInputProps['compact'] }>(\n ({\n compactMode,\n theme: {\n base: {\n 'hit-area': { 'finger-min': fingerMin, compact }\n },\n components\n }\n }) => {\n return css`\n width: 100%;\n height: ${components.input.height};\n border: none;\n cursor: pointer;\n\n ${compactMode &&\n css`\n height: ${compact};\n `}\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n `;\n }\n);\n\nStyledDropZone.defaultProps = defaultThemeProp;\n\nexport const StyledUploadStatus = styled(Flex)<{\n status: FormControlProps['status'];\n readOnly: FormControlProps['readOnly'];\n dragOver: boolean;\n}>(({\n dragOver,\n status,\n readOnly,\n theme: {\n base: { 'border-radius': borderRadius },\n components: {\n 'form-field': formField,\n 'form-control': {\n 'border-color': borderColor,\n ':hover': { 'border-color': hoverBorderColor },\n 'border-radius': formBorderRadius\n }\n }\n }\n}) => {\n return css`\n border: 0.0625rem dashed ${borderColor};\n border-start-start-radius: calc(${borderRadius} * ${formBorderRadius});\n border-end-start-radius: calc(${borderRadius} * ${formBorderRadius});\n ${!readOnly &&\n css`\n ${status &&\n css`\n border-color: ${formField[status]['status-color']};\n `};\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n\n &:hover:not([disabled]):not(:focus, :focus-within) {\n ${!status &&\n css`\n border-color: ${hoverBorderColor};\n `}\n }\n `}\n `;\n});\n\nStyledUploadStatus.defaultProps = defaultThemeProp;\n\nexport const StyledIconWrapper = styled(Flex)(({\n theme: {\n base: { 'border-radius': borderRadius },\n components: {\n 'form-control': { 'border-color': borderColor, 'border-radius': formBorderRadius }\n }\n }\n}) => {\n return css`\n border: 0.0625rem solid ${borderColor};\n border-start-end-radius: calc(${borderRadius} * ${formBorderRadius});\n border-end-end-radius: calc(${borderRadius} * ${formBorderRadius});\n border-inline-start: none;\n aspect-ratio: 1 / 1;\n `;\n});\n\nStyledIconWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledFileInput = styled.div(\n ({\n theme: {\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n }\n }) => {\n return css`\n position: relative;\n\n input {\n display: none;\n }\n\n ${StyledDropZone}:focus:not([disabled]) {\n > ${StyledIconWrapper} {\n border: none;\n }\n > ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nexport const StyledSingleFileWrapper = styled.div<{ compact: FileInputProps['compact'] }>(\n ({ compact }) => {\n return css`\n display: contents;\n\n ${compact &&\n css`\n > ${StyledFileItem} {\n width: 25ch;\n }\n `};\n `;\n }\n);\n\nexport const StyledAttachedFileCount = styled.span(\n ({\n theme: {\n base: { palette, spacing }\n }\n }) => {\n return css`\n padding-inline-start: ${spacing};\n color: ${palette.interactive};\n `;\n }\n);\n\nStyledAttachedFileCount.defaultProps = defaultThemeProp;\n\nexport const StyledFlex = styled(Flex)`\n height: inherit;\n`;\n\nexport const StyledBareButton = styled(BareButton)(({\n theme: {\n base: {\n palette,\n 'hit-area': { 'finger-min': fingerMin, compact },\n 'border-radius': baseRadius\n },\n components: {\n 'form-control': {\n 'border-color': borderColor,\n 'border-radius': radius,\n ':focus': { 'box-shadow': boxShadow }\n }\n }\n }\n}) => {\n return css`\n height: ${compact};\n width: 25ch;\n cursor: pointer;\n border-radius: calc(${baseRadius} * ${radius});\n background-color: ${palette['primary-background']};\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n\n &:focus {\n box-shadow: ${boxShadow};\n\n ${StyledIconWrapper} {\n border: none;\n }\n ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n});\n\nStyledBareButton.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled(FormField)<{ compactMode: FileInputProps['compact'] }>(({\n compactMode\n}) => {\n return css`\n ${compactMode &&\n css`\n width: 25ch;\n `};\n `;\n});\n\nexport const StyledFileInputControl = styled(Flex)<Pick<FormControlProps, 'status'>>(({\n theme: {\n base: { spacing },\n components: { 'form-field': formField }\n },\n status\n}) => {\n return css`\n ${StyledFormFieldInfo} {\n margin-block-start: calc(0.5 * ${spacing});\n ${StyledMetaListItem}:first-child {\n color: ${status && formField[status]['status-color']};\n }\n }\n `;\n});\n\nStyledFileInputControl.defaultProps = defaultThemeProp;\n\nexport const StyledDownloadAllButton = styled(Button)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n}) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n return css`\n font-size: ${infoFontSize};\n margin-block-start: calc(0.5 * ${spacing});\n align-self: flex-start;\n `;\n});\n\nStyledDownloadAllButton.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -73,7 +73,7 @@ export interface FormFieldProps extends OmitStrict<FormControlProps, 'placeholde
|
|
|
73
73
|
export declare const StyledFormFieldInfo: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<FormControlProps, "status">, never>;
|
|
74
74
|
export declare const StyledLabelRow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
75
75
|
export declare const StyledFormField: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, FormFieldProps & {
|
|
76
|
-
|
|
76
|
+
asFieldset: boolean;
|
|
77
77
|
showAdditionalInfo: boolean;
|
|
78
78
|
}, never>;
|
|
79
79
|
declare const _default: FC<FormFieldProps & ForwardProps> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAK9F,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAa3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,WAAW,cACf,SAAQ,UAAU,CAAC,gBAAgB,EAAE,aAAa,GAA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AAE,MAAM,EAAE,CAAC;IACnB,gDAAgD;IAChD,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;IACxD,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAgCD,eAAO,MAAM,mBAAmB,uIA6B/B,CAAC;AAIF,eAAO,MAAM,cAAc,yGAAe,CAAC;AAE3C,eAAO,MAAM,eAAe;gBACK,OAAO;wBAAsB,OAAO;SAuEnE,CAAC;;;;AA6UH,wBAA2D"}
|
|
@@ -3,7 +3,7 @@ import { cloneElement, useEffect, forwardRef, useState, useRef, Children } from
|
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { rgba } from 'polished';
|
|
5
5
|
import { defaultThemeProp } from '../../theme';
|
|
6
|
-
import Flex from '../Flex';
|
|
6
|
+
import Flex, { StyledFlex } from '../Flex';
|
|
7
7
|
import Actions from '../Actions';
|
|
8
8
|
import { useConsolidatedRef, useI18n, useLiveLog, useTestIds, useUID } from '../../hooks';
|
|
9
9
|
import Label, { StyledLabel } from '../Label';
|
|
@@ -16,7 +16,7 @@ import * as warnSolidIcon from '../Icon/icons/warn-solid.icon';
|
|
|
16
16
|
import * as diamondMinusIcon from '../Icon/icons/diamond-minus.icon';
|
|
17
17
|
import * as checkIcon from '../Icon/icons/check.icon';
|
|
18
18
|
import AdditionalInfo, { StyledAdditionalInfo } from '../AdditionalInfo';
|
|
19
|
-
import { StyledRadioCheckInput } from '../RadioCheck/RadioCheck';
|
|
19
|
+
import { StyledRadioCheck, StyledRadioCheckInput } from '../RadioCheck/RadioCheck';
|
|
20
20
|
import { getFormFieldTestIds } from './FormField.test-ids';
|
|
21
21
|
registerIcon(warnSolidIcon, diamondMinusIcon, checkIcon);
|
|
22
22
|
const StyledStatusIcon = styled(Icon)(({ theme, status }) => {
|
|
@@ -56,7 +56,7 @@ export const StyledFormFieldInfo = styled.div(({ status, theme: { base: { 'font-
|
|
|
56
56
|
StyledFormFieldInfo.defaultProps = defaultThemeProp;
|
|
57
57
|
export const StyledLabelRow = styled.div ``;
|
|
58
58
|
export const StyledFormField = styled.div(props => {
|
|
59
|
-
const {
|
|
59
|
+
const { asFieldset, showAdditionalInfo, disabled, required, theme: { base: { palette: { urgent }, 'disabled-opacity': disabledOpacity, spacing, 'hit-area': { 'compact-min': hitAreaCompact } } } } = props;
|
|
60
60
|
return css `
|
|
61
61
|
${disabled &&
|
|
62
62
|
css `
|
|
@@ -73,14 +73,18 @@ export const StyledFormField = styled.div(props => {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
${StyledFlex}:has(${StyledRadioCheck}) {
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
> ${StyledLabel}, > ${StyledLabelRow}, > ${StyledFlex}:has(> ${StyledLabel}) {
|
|
77
81
|
&:not(:empty) {
|
|
78
82
|
margin-bottom: calc(0.25 * ${spacing});
|
|
79
83
|
min-height: ${hitAreaCompact};
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
> ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel} {
|
|
87
|
+
> ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel}, > ${StyledFlex} > ${StyledLabel} {
|
|
84
88
|
${required &&
|
|
85
89
|
css `
|
|
86
90
|
&::after {
|
|
@@ -95,31 +99,15 @@ export const StyledFormField = styled.div(props => {
|
|
|
95
99
|
`}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
${
|
|
99
|
-
css `
|
|
100
|
-
> legend {
|
|
101
|
-
display: inline-flex;
|
|
102
|
-
align-items: flex-end;
|
|
103
|
-
}
|
|
104
|
-
`}
|
|
105
|
-
|
|
106
|
-
${labelAsLegend &&
|
|
102
|
+
${asFieldset &&
|
|
107
103
|
showAdditionalInfo &&
|
|
108
104
|
css `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
> legend {
|
|
112
|
-
float: inline-start;
|
|
105
|
+
> ${StyledFlex} > ${StyledLabel} {
|
|
106
|
+
display: block;
|
|
113
107
|
}
|
|
114
108
|
|
|
115
|
-
> ${StyledAdditionalInfo} {
|
|
116
|
-
|
|
117
|
-
css `
|
|
118
|
-
float: inline-end;
|
|
119
|
-
`}
|
|
120
|
-
+ * {
|
|
121
|
-
clear: both;
|
|
122
|
-
}
|
|
109
|
+
> ${StyledFlex}:has(> ${StyledLabel}) > ${StyledAdditionalInfo} {
|
|
110
|
+
align-self: flex-start;
|
|
123
111
|
}
|
|
124
112
|
`}
|
|
125
113
|
`;
|
|
@@ -166,21 +154,35 @@ StyledSuggestionButton.defaultProps = defaultThemeProp;
|
|
|
166
154
|
const statusIconMap = { error: 'warn-solid', warning: 'diamond-minus', success: 'check' };
|
|
167
155
|
const FormField = forwardRef(function FormField(props, ref) {
|
|
168
156
|
const uid = useUID();
|
|
169
|
-
const { testId, children: controlElement, id = uid, as = 'div', label, labelAs = 'label', labelFor = id, labelId, labelHidden = false, labelAfter = false, info, status, suppressAnnouncements, isRadioCheck, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = false, onClear, actions, container, additionalInfo, onResolveSuggestion, 'aria-describedby': ariaDescribedBy, className, ...restProps } = props;
|
|
157
|
+
const { testId, children: controlElement, id = uid, as = 'div', label, labelAs: labelAsProp = 'label', labelFor = id, labelId: labelIdProp, labelHidden = false, labelAfter = false, info, status, suppressAnnouncements, isRadioCheck, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = false, onClear, actions, container, additionalInfo, onResolveSuggestion, 'aria-describedby': ariaDescribedBy, className, ...restProps } = props;
|
|
170
158
|
const testIds = useTestIds(testId, getFormFieldTestIds);
|
|
159
|
+
const asFieldset = as === 'fieldset' || (typeof as !== 'string' && 'target' in as && as.target === 'fieldset');
|
|
171
160
|
const t = useI18n();
|
|
172
161
|
const { announceAssertive } = useLiveLog();
|
|
173
|
-
const
|
|
162
|
+
const labelAs = asFieldset || labelAsProp === 'legend' ? 'span' : labelAsProp;
|
|
174
163
|
const hasSuggestion = status === 'pending' && !!onResolveSuggestion;
|
|
175
164
|
const consolidatedRef = useConsolidatedRef(ref);
|
|
176
165
|
const labelRef = useRef(null);
|
|
177
166
|
const [labelText, setLabelText] = useState(null);
|
|
178
167
|
const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;
|
|
168
|
+
const labelId = asFieldset && !labelIdProp ? `${id}-label` : labelIdProp;
|
|
179
169
|
const labelContent = (_jsxs(_Fragment, { children: [_jsx(Label, { "data-testid": testIds.label, id: labelId, as: labelAs, htmlFor: labelAs === 'label' ? labelFor : undefined, labelHidden: labelHidden, onClick: (e) => {
|
|
180
170
|
if (readOnly)
|
|
181
171
|
e.preventDefault();
|
|
182
172
|
}, inline: inline, ref: labelRef, children: label }), showAdditionalInfo && labelText && (_jsx(AdditionalInfo, { "data-testid": testIds.additionalInfo, heading: additionalInfo.heading, contextualLabel: labelText, children: additionalInfo.content }))] }));
|
|
183
|
-
|
|
173
|
+
let labelRow;
|
|
174
|
+
if (!isRadioCheck && !asFieldset && !labelHidden) {
|
|
175
|
+
labelRow = (_jsx(Flex, { as: StyledLabelRow, container: { justify: 'between', alignItems: 'end' }, item: { alignSelf: 'stretch' }, children: labelContent }));
|
|
176
|
+
}
|
|
177
|
+
else if (asFieldset && !labelHidden) {
|
|
178
|
+
labelRow = (_jsx(Flex, { container: {
|
|
179
|
+
alignItems: 'end',
|
|
180
|
+
justify: showAdditionalInfo && !isRadioCheck ? 'between' : undefined
|
|
181
|
+
}, children: labelContent }));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
labelRow = labelContent;
|
|
185
|
+
}
|
|
184
186
|
useEffect(() => {
|
|
185
187
|
setLabelText(labelRef.current?.textContent ?? null);
|
|
186
188
|
}, [label]);
|
|
@@ -196,7 +198,7 @@ const FormField = forwardRef(function FormField(props, ref) {
|
|
|
196
198
|
}, [status, info]);
|
|
197
199
|
// fieldset or single form control element
|
|
198
200
|
let content;
|
|
199
|
-
if (
|
|
201
|
+
if (asFieldset || Children.count(controlElement) > 1) {
|
|
200
202
|
content = controlElement;
|
|
201
203
|
}
|
|
202
204
|
else {
|
|
@@ -236,14 +238,14 @@ const FormField = forwardRef(function FormField(props, ref) {
|
|
|
236
238
|
const descriptionIds = [];
|
|
237
239
|
if (ariaDescribedBy)
|
|
238
240
|
descriptionIds.push(ariaDescribedBy);
|
|
239
|
-
if (
|
|
241
|
+
if (asFieldset && info)
|
|
240
242
|
descriptionIds.push(`${id}-info`);
|
|
241
243
|
return (_jsxs(Flex, { "data-testid": testIds.root, ...restProps, container: {
|
|
242
244
|
direction: inline ? 'row' : 'column',
|
|
243
245
|
alignItems: inline ? 'center' : undefined,
|
|
244
246
|
wrap: isRadioCheck ? 'wrap' : undefined,
|
|
245
247
|
...container
|
|
246
|
-
}, as: StyledFormField,
|
|
248
|
+
}, as: StyledFormField, asFieldset: asFieldset, isRadioCheck: isRadioCheck, showAdditionalInfo: showAdditionalInfo, id: `${id}-field`, forwardedAs: as, required: required, disabled: disabled, readOnly: readOnly, onKeyDown: hasSuggestion ? onKeyDown : undefined, "aria-describedby": descriptionIds.length ? descriptionIds.join(' ') : undefined, "aria-labelledby": asFieldset ? labelId : undefined, ref: consolidatedRef, className: createClassName('form-field', className, { status }), children: [(asFieldset || !labelAfter) && labelRow, content, !asFieldset && labelAfter && labelRow, !readOnly && infoContent, isRadioCheck && onClear && (_jsx(StyledClearButton, { variant: 'link', onClick: () => {
|
|
247
249
|
onClear();
|
|
248
250
|
}, children: t('clear_selection') }))] }));
|
|
249
251
|
});
|