@cloudscape-design/components-themeable 3.0.1202 → 3.0.1203

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.
Files changed (57) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/file-token-group/styles.scss +15 -0
  3. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  4. package/lib/internal/template/file-token-group/file-token.d.ts +1 -1
  5. package/lib/internal/template/file-token-group/file-token.d.ts.map +1 -1
  6. package/lib/internal/template/file-token-group/file-token.js +7 -5
  7. package/lib/internal/template/file-token-group/file-token.js.map +1 -1
  8. package/lib/internal/template/file-token-group/interfaces.d.ts +2 -2
  9. package/lib/internal/template/file-token-group/interfaces.d.ts.map +1 -1
  10. package/lib/internal/template/file-token-group/interfaces.js.map +1 -1
  11. package/lib/internal/template/file-token-group/internal.js +1 -1
  12. package/lib/internal/template/file-token-group/internal.js.map +1 -1
  13. package/lib/internal/template/file-token-group/styles.css.js +23 -22
  14. package/lib/internal/template/file-token-group/styles.scoped.css +59 -29
  15. package/lib/internal/template/file-token-group/styles.selectors.js +23 -22
  16. package/lib/internal/template/file-upload/interfaces.d.ts +1 -1
  17. package/lib/internal/template/file-upload/interfaces.d.ts.map +1 -1
  18. package/lib/internal/template/file-upload/interfaces.js.map +1 -1
  19. package/lib/internal/template/file-upload/internal.js +1 -1
  20. package/lib/internal/template/file-upload/internal.js.map +1 -1
  21. package/lib/internal/template/i18n/messages/all.all.js +1 -1
  22. package/lib/internal/template/i18n/messages/all.all.json +1 -1
  23. package/lib/internal/template/i18n/messages/all.ar.js +1 -1
  24. package/lib/internal/template/i18n/messages/all.ar.json +1 -1
  25. package/lib/internal/template/i18n/messages/all.de.js +1 -1
  26. package/lib/internal/template/i18n/messages/all.de.json +1 -1
  27. package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
  28. package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
  29. package/lib/internal/template/i18n/messages/all.en.js +1 -1
  30. package/lib/internal/template/i18n/messages/all.en.json +1 -1
  31. package/lib/internal/template/i18n/messages/all.es.js +1 -1
  32. package/lib/internal/template/i18n/messages/all.es.json +1 -1
  33. package/lib/internal/template/i18n/messages/all.fr.js +1 -1
  34. package/lib/internal/template/i18n/messages/all.fr.json +1 -1
  35. package/lib/internal/template/i18n/messages/all.id.js +1 -1
  36. package/lib/internal/template/i18n/messages/all.id.json +1 -1
  37. package/lib/internal/template/i18n/messages/all.it.js +1 -1
  38. package/lib/internal/template/i18n/messages/all.it.json +1 -1
  39. package/lib/internal/template/i18n/messages/all.ja.js +1 -1
  40. package/lib/internal/template/i18n/messages/all.ja.json +1 -1
  41. package/lib/internal/template/i18n/messages/all.ko.js +1 -1
  42. package/lib/internal/template/i18n/messages/all.ko.json +1 -1
  43. package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
  44. package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
  45. package/lib/internal/template/i18n/messages/all.tr.js +1 -1
  46. package/lib/internal/template/i18n/messages/all.tr.json +1 -1
  47. package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
  48. package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
  49. package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
  50. package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
  51. package/lib/internal/template/i18n/messages-types.d.ts +2 -0
  52. package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
  53. package/lib/internal/template/i18n/messages-types.js.map +1 -1
  54. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  55. package/lib/internal/template/internal/environment.js +2 -2
  56. package/lib/internal/template/internal/environment.json +2 -2
  57. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/file-upload/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldCommonValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileUploadProps extends BaseComponentProps, FormFieldCommonValidationControlProps {\n /**\n * Specifies the native file input `accept` attribute to describe the allow-list of file types.\n */\n accept?: string;\n /**\n * Specifies whether to add aria-required to the file upload control.\n */\n ariaRequired?: boolean;\n /**\n * Show file size in the token. Use `i18nStrings.formatFileSize` to customize it.\n */\n showFileSize?: boolean;\n /**\n * Show file last modified timestamp in the token. Use `i18nStrings.formatFileLastModified` to customize it.\n */\n showFileLastModified?: boolean;\n /**\n * Show file thumbnail in the token. Only supported for images.\n */\n showFileThumbnail?: boolean;\n /**\n * Specifies the native file input `multiple` attribute to allow users entering more than one file.\n */\n multiple?: boolean;\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange?: NonCancelableEventHandler<FileUploadProps.ChangeDetail>;\n /**\n * Specifies the currently selected file(s).\n * If you want to clear the selection, use empty array.\n */\n value: ReadonlyArray<File>;\n /**\n * Specifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Constraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.\n */\n constraintText?: React.ReactNode;\n /**\n * Text that displays as a validation error message.\n */\n errorText?: React.ReactNode;\n /**\n * Text that displays as a validation warning message.\n */\n warningText?: React.ReactNode;\n /**\n * An array of file errors corresponding to the files in the `value`.\n */\n fileErrors?: ReadonlyArray<null | string>;\n /**\n * An array of file warnings corresponding to the files in the `value`.\n */\n fileWarnings?: ReadonlyArray<null | string>;\n /**\n * Alignment of the file tokens. Defaults to \"vertical\".\n */\n fileTokenAlignment?: FileUploadProps.FileTokenAlignment;\n /**\n * An object containing all the localized strings required by the component:\n * * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.\n * * `dropzoneText` (function): A function to render the text shown in the dropzone. It takes `multiple` attribute to define plurality.\n * * `removeFileAriaLabel` (function): A function to render the ARIA label for file token remove button.\n * * `limitShowFewer` (string): The text of the show more tokens button.\n * * `limitShowMore` (string): The text of the show fewer tokens button.\n * * `errorIconAriaLabel` (string): The ARIA label to be shown on the error file icon.\n * * `warningIconAriaLabel` (string): The ARIA label to be shown on the warning file icon.\n * * `formatFileSize` (function): (Optional) A function that takes file size in bytes, and produces a formatted string.\n * * `formatFileLastModified` (function): (Optional) A function that takes the files last modified date, and produces a formatted string.\n */\n i18nStrings?: FileUploadProps.I18nStrings;\n}\n\nexport namespace FileUploadProps {\n export interface ChangeDetail {\n value: File[];\n }\n\n export interface DismissDetail {\n index: number;\n file: File;\n }\n\n export type FileTokenAlignment = 'vertical' | 'horizontal';\n\n export interface I18nStrings {\n uploadButtonText?: (multiple: boolean) => string;\n dropzoneText?: (multiple: boolean) => string;\n removeFileAriaLabel?: (fileIndex: number) => string;\n limitShowFewer?: string;\n limitShowMore?: string;\n errorIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n formatFileSize?: (sizeInBytes: number) => string;\n formatFileLastModified?: (date: Date) => string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the file upload button.\n */\n focus(): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/file-upload/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldCommonValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileUploadProps extends BaseComponentProps, FormFieldCommonValidationControlProps {\n /**\n * Specifies the native file input `accept` attribute to describe the allow-list of file types.\n */\n accept?: string;\n /**\n * Specifies whether to add aria-required to the file upload control.\n */\n ariaRequired?: boolean;\n /**\n * Show file size in the token. Use `i18nStrings.formatFileSize` to customize it.\n */\n showFileSize?: boolean;\n /**\n * Show file last modified timestamp in the token. Use `i18nStrings.formatFileLastModified` to customize it.\n */\n showFileLastModified?: boolean;\n /**\n * Show file thumbnail in the token. Only supported for images.\n */\n showFileThumbnail?: boolean;\n /**\n * Specifies the native file input `multiple` attribute to allow users entering more than one file.\n */\n multiple?: boolean;\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange?: NonCancelableEventHandler<FileUploadProps.ChangeDetail>;\n /**\n * Specifies the currently selected file(s).\n * If you want to clear the selection, use empty array.\n */\n value: ReadonlyArray<File>;\n /**\n * Specifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Constraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.\n */\n constraintText?: React.ReactNode;\n /**\n * Text that displays as a validation error message.\n */\n errorText?: React.ReactNode;\n /**\n * Text that displays as a validation warning message.\n */\n warningText?: React.ReactNode;\n /**\n * An array of file errors corresponding to the files in the `value`.\n */\n fileErrors?: ReadonlyArray<null | string>;\n /**\n * An array of file warnings corresponding to the files in the `value`.\n */\n fileWarnings?: ReadonlyArray<null | string>;\n /**\n * Alignment of the file tokens. Defaults to \"vertical\".\n */\n fileTokenAlignment?: FileUploadProps.FileTokenAlignment;\n /**\n * An object containing all the localized strings required by the component:\n * * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.\n * * `dropzoneText` (function): A function to render the text shown in the dropzone. It takes `multiple` attribute to define plurality.\n * * `removeFileAriaLabel` (function): A function to render the ARIA label for file token remove button.\n * * `limitShowFewer` (string): The text of the show more tokens button.\n * * `limitShowMore` (string): The text of the show fewer tokens button.\n * * `errorIconAriaLabel` (string): The ARIA label to be shown on the error file icon.\n * * `warningIconAriaLabel` (string): The ARIA label to be shown on the warning file icon.\n * * `formatFileSize` (function): (Optional) A function that takes file size in bytes, and produces a formatted string.\n * * `formatFileLastModified` (function): (Optional) A function that takes the files last modified date, and produces a formatted string.\n */\n i18nStrings?: FileUploadProps.I18nStrings;\n}\n\nexport namespace FileUploadProps {\n export interface ChangeDetail {\n value: File[];\n }\n\n export interface DismissDetail {\n index: number;\n file: File;\n }\n\n export type FileTokenAlignment = 'vertical' | 'horizontal';\n\n export interface I18nStrings {\n uploadButtonText?: (multiple: boolean) => string;\n dropzoneText?: (multiple: boolean) => string;\n removeFileAriaLabel?: (fileIndex: number, fileName: string) => string;\n limitShowFewer?: string;\n limitShowMore?: string;\n errorIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n formatFileSize?: (sizeInBytes: number) => string;\n formatFileLastModified?: (date: Date) => string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the file upload button.\n */\n focus(): void;\n }\n}\n"]}
@@ -76,7 +76,7 @@ function InternalFileUpload({ accept, ariaRequired, multiple = false, onChange,
76
76
  errorText: fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors[fileIndex],
77
77
  warningText: fileWarnings === null || fileWarnings === void 0 ? void 0 : fileWarnings[fileIndex],
78
78
  })), showFileLastModified: metadata.showFileLastModified, showFileSize: metadata.showFileSize, showFileThumbnail: metadata.showFileThumbnail, i18nStrings: {
79
- removeFileAriaLabel: i18n('i18nStrings.removeFileAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.removeFileAriaLabel, format => fileIndex => format({ fileIndex: fileIndex + 1 })),
79
+ removeFileAriaLabel: i18n('i18nStrings.removeFileAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.removeFileAriaLabel, format => (fileIndex, fileName) => format({ fileIndex: fileIndex + 1, fileName })),
80
80
  limitShowFewer: i18n('i18nStrings.limitShowFewer', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.limitShowFewer),
81
81
  limitShowMore: i18n('i18nStrings.limitShowMore', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.limitShowMore),
82
82
  formatFileSize: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.formatFileSize,
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEpG,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,sBAAsB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAG7D,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,eAAe,MAAM,iDAAiD,CAAC;AAC9E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,eAAe,KAAK,CAAC,UAAU,CAAC,kBA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B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport InternalFileDropzone from '../file-dropzone/internal';\nimport { useFilesDragging } from '../file-dropzone/use-files-dragging';\nimport InternalFileInput from '../file-input/internal';\nimport InternalFileTokenGroup from '../file-token-group/internal';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { FileUploadProps } from './interfaces';\n\nimport fileInputStyles from '../file-input/styles.css.js';\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n fileTokenAlignment = 'vertical',\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['file-input']}`,\n });\n\n const i18n = useInternalI18n('file-upload');\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const { areFilesDragging } = useFilesDragging();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {areFilesDragging ? (\n <InternalFileDropzone onChange={event => handleFilesChange(event.detail.value)}>\n {i18n('i18nStrings.dropzoneText', i18nStrings?.dropzoneText?.(multiple), format =>\n format({ multiple: `${multiple}` })\n )}\n </InternalFileDropzone>\n ) : (\n <InternalFileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={event => handleFilesChange(event.detail.value)}\n value={value}\n ariaLabelledby={restProps.ariaLabelledby}\n controlId={restProps.controlId}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18n('i18nStrings.uploadButtonText', i18nStrings?.uploadButtonText?.(multiple), format =>\n format({ multiple: `${multiple}` })\n )}\n </InternalFileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError\n id={errorId}\n errorIconAriaLabel={i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel)}\n >\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning\n id={warningId}\n warningIconAriaLabel={i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel)}\n >\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {value.length > 0 ? (\n <InternalFileTokenGroup\n limit={tokenLimit}\n alignment={fileTokenAlignment}\n items={value.map((file, fileIndex) => ({\n file,\n errorText: fileErrors?.[fileIndex],\n warningText: fileWarnings?.[fileIndex],\n }))}\n showFileLastModified={metadata.showFileLastModified}\n showFileSize={metadata.showFileSize}\n showFileThumbnail={metadata.showFileThumbnail}\n i18nStrings={{\n removeFileAriaLabel: i18n(\n 'i18nStrings.removeFileAriaLabel',\n i18nStrings?.removeFileAriaLabel,\n format => fileIndex => format({ fileIndex: fileIndex + 1 })\n ),\n limitShowFewer: i18n('i18nStrings.limitShowFewer', i18nStrings?.limitShowFewer),\n limitShowMore: i18n('i18nStrings.limitShowMore', i18nStrings?.limitShowMore),\n formatFileSize: i18nStrings?.formatFileSize,\n formatFileLastModified: i18nStrings?.formatFileLastModified,\n errorIconAriaLabel: i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel),\n warningIconAriaLabel: i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel),\n }}\n onDismiss={event => onFileRemove(event.detail.fileIndex)}\n />\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEpG,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,sBAAsB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,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BAAX,WAAW,CAAE,kBAAkB,CAAC;gBAC3F,oBAAoB,EAAE,IAAI,CAAC,kCAAkC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,CAAC;aAClG,EACD,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GACxD,CACH,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport InternalFileDropzone from '../file-dropzone/internal';\nimport { useFilesDragging } from '../file-dropzone/use-files-dragging';\nimport InternalFileInput from '../file-input/internal';\nimport InternalFileTokenGroup from '../file-token-group/internal';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { FileUploadProps } from './interfaces';\n\nimport fileInputStyles from '../file-input/styles.css.js';\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n fileTokenAlignment = 'vertical',\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['file-input']}`,\n });\n\n const i18n = useInternalI18n('file-upload');\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const { areFilesDragging } = useFilesDragging();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {areFilesDragging ? (\n <InternalFileDropzone onChange={event => handleFilesChange(event.detail.value)}>\n {i18n('i18nStrings.dropzoneText', i18nStrings?.dropzoneText?.(multiple), format =>\n format({ multiple: `${multiple}` })\n )}\n </InternalFileDropzone>\n ) : (\n <InternalFileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={event => handleFilesChange(event.detail.value)}\n value={value}\n ariaLabelledby={restProps.ariaLabelledby}\n controlId={restProps.controlId}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18n('i18nStrings.uploadButtonText', i18nStrings?.uploadButtonText?.(multiple), format =>\n format({ multiple: `${multiple}` })\n )}\n </InternalFileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError\n id={errorId}\n errorIconAriaLabel={i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel)}\n >\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning\n id={warningId}\n warningIconAriaLabel={i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel)}\n >\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {value.length > 0 ? (\n <InternalFileTokenGroup\n limit={tokenLimit}\n alignment={fileTokenAlignment}\n items={value.map((file, fileIndex) => ({\n file,\n errorText: fileErrors?.[fileIndex],\n warningText: fileWarnings?.[fileIndex],\n }))}\n showFileLastModified={metadata.showFileLastModified}\n showFileSize={metadata.showFileSize}\n showFileThumbnail={metadata.showFileThumbnail}\n i18nStrings={{\n removeFileAriaLabel: i18n(\n 'i18nStrings.removeFileAriaLabel',\n i18nStrings?.removeFileAriaLabel,\n format => (fileIndex: number, fileName: string) => format({ fileIndex: fileIndex + 1, fileName })\n ),\n limitShowFewer: i18n('i18nStrings.limitShowFewer', i18nStrings?.limitShowFewer),\n limitShowMore: i18n('i18nStrings.limitShowMore', i18nStrings?.limitShowMore),\n formatFileSize: i18nStrings?.formatFileSize,\n formatFileLastModified: i18nStrings?.formatFileLastModified,\n errorIconAriaLabel: i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel),\n warningIconAriaLabel: i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel),\n }}\n onDismiss={event => onFileRemove(event.detail.fileIndex)}\n />\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}