@cloudscape-design/components-themeable 3.0.255 → 3.0.256

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 (138) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/button/styles.scss +0 -4
  3. package/lib/internal/scss/token-group/styles.scss +14 -30
  4. package/lib/internal/template/app-layout/visual-refresh/app-bar.js +1 -1
  5. package/lib/internal/template/app-layout/visual-refresh/app-bar.js.map +1 -1
  6. package/lib/internal/template/autosuggest/internal.d.ts.map +1 -1
  7. package/lib/internal/template/autosuggest/internal.js +1 -2
  8. package/lib/internal/template/autosuggest/internal.js.map +1 -1
  9. package/lib/internal/template/autosuggest/options-list.d.ts +1 -2
  10. package/lib/internal/template/autosuggest/options-list.d.ts.map +1 -1
  11. package/lib/internal/template/autosuggest/options-list.js +2 -8
  12. package/lib/internal/template/autosuggest/options-list.js.map +1 -1
  13. package/lib/internal/template/button/internal.d.ts +1 -1
  14. package/lib/internal/template/button/internal.d.ts.map +1 -1
  15. package/lib/internal/template/button/internal.js +2 -3
  16. package/lib/internal/template/button/internal.js.map +1 -1
  17. package/lib/internal/template/button/styles.css.js +19 -20
  18. package/lib/internal/template/button/styles.scoped.css +136 -298
  19. package/lib/internal/template/button/styles.selectors.js +19 -20
  20. package/lib/internal/template/form-field/internal.d.ts +1 -6
  21. package/lib/internal/template/form-field/internal.d.ts.map +1 -1
  22. package/lib/internal/template/form-field/internal.js +3 -6
  23. package/lib/internal/template/form-field/internal.js.map +1 -1
  24. package/lib/internal/template/index.d.ts +0 -1
  25. package/lib/internal/template/index.d.ts.map +1 -1
  26. package/lib/internal/template/index.js +0 -1
  27. package/lib/internal/template/index.js.map +1 -1
  28. package/lib/internal/template/internal/base-component/styles.scoped.css +0 -37
  29. package/lib/internal/template/internal/components/dropdown-footer/index.d.ts +0 -1
  30. package/lib/internal/template/internal/components/dropdown-footer/index.d.ts.map +1 -1
  31. package/lib/internal/template/internal/components/dropdown-footer/index.js +2 -2
  32. package/lib/internal/template/internal/components/dropdown-footer/index.js.map +1 -1
  33. package/lib/internal/template/internal/components/live-region/index.d.ts +1 -2
  34. package/lib/internal/template/internal/components/live-region/index.d.ts.map +1 -1
  35. package/lib/internal/template/internal/components/live-region/index.js +2 -2
  36. package/lib/internal/template/internal/components/live-region/index.js.map +1 -1
  37. package/lib/internal/template/internal/components/options-list/index.d.ts +0 -1
  38. package/lib/internal/template/internal/components/options-list/index.d.ts.map +1 -1
  39. package/lib/internal/template/internal/components/options-list/index.js +2 -2
  40. package/lib/internal/template/internal/components/options-list/index.js.map +1 -1
  41. package/lib/internal/template/internal/environment.js +1 -1
  42. package/lib/internal/template/internal/generated/theming/index.cjs +0 -95
  43. package/lib/internal/template/internal/generated/theming/index.js +0 -95
  44. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  45. package/lib/internal/template/multiselect/internal.js +3 -4
  46. package/lib/internal/template/multiselect/internal.js.map +1 -1
  47. package/lib/internal/template/package.json +0 -1
  48. package/lib/internal/template/property-filter/index.d.ts.map +1 -1
  49. package/lib/internal/template/property-filter/index.js +1 -1
  50. package/lib/internal/template/property-filter/index.js.map +1 -1
  51. package/lib/internal/template/property-filter/interfaces.d.ts +1 -2
  52. package/lib/internal/template/property-filter/interfaces.d.ts.map +1 -1
  53. package/lib/internal/template/property-filter/interfaces.js.map +1 -1
  54. package/lib/internal/template/property-filter/property-filter-autosuggest.d.ts.map +1 -1
  55. package/lib/internal/template/property-filter/property-filter-autosuggest.js +2 -4
  56. package/lib/internal/template/property-filter/property-filter-autosuggest.js.map +1 -1
  57. package/lib/internal/template/select/internal.d.ts.map +1 -1
  58. package/lib/internal/template/select/internal.js +3 -4
  59. package/lib/internal/template/select/internal.js.map +1 -1
  60. package/lib/internal/template/split-panel/interfaces.d.ts +8 -8
  61. package/lib/internal/template/split-panel/interfaces.d.ts.map +1 -1
  62. package/lib/internal/template/split-panel/interfaces.js.map +1 -1
  63. package/lib/internal/template/split-panel/preferences-modal.d.ts +7 -7
  64. package/lib/internal/template/split-panel/preferences-modal.d.ts.map +1 -1
  65. package/lib/internal/template/split-panel/preferences-modal.js.map +1 -1
  66. package/lib/internal/template/table/body-cell/index.js +1 -1
  67. package/lib/internal/template/table/body-cell/index.js.map +1 -1
  68. package/lib/internal/template/test-utils/dom/index.d.ts +0 -3
  69. package/lib/internal/template/test-utils/dom/index.js +2 -10
  70. package/lib/internal/template/test-utils/dom/index.js.map +1 -1
  71. package/lib/internal/template/test-utils/selectors/index.d.ts +0 -3
  72. package/lib/internal/template/test-utils/selectors/index.js +2 -10
  73. package/lib/internal/template/test-utils/selectors/index.js.map +1 -1
  74. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  75. package/lib/internal/template/token-group/styles.css.js +5 -7
  76. package/lib/internal/template/token-group/styles.scoped.css +23 -41
  77. package/lib/internal/template/token-group/styles.selectors.js +5 -7
  78. package/lib/internal/template/token-group/token.d.ts +1 -4
  79. package/lib/internal/template/token-group/token.d.ts.map +1 -1
  80. package/lib/internal/template/token-group/token.js +4 -13
  81. package/lib/internal/template/token-group/token.js.map +1 -1
  82. package/lib/theming/index.d.ts +1 -2
  83. package/lib/theming/index.js +1 -2
  84. package/package.json +1 -1
  85. package/lib/internal/scss/file-upload/dropzone/styles.scss +0 -24
  86. package/lib/internal/scss/file-upload/file-input/styles.scss +0 -20
  87. package/lib/internal/scss/file-upload/file-option/styles.scss +0 -34
  88. package/lib/internal/scss/file-upload/styles.scss +0 -15
  89. package/lib/internal/template/file-upload/default-formatters.d.ts +0 -3
  90. package/lib/internal/template/file-upload/default-formatters.d.ts.map +0 -1
  91. package/lib/internal/template/file-upload/default-formatters.js +0 -23
  92. package/lib/internal/template/file-upload/default-formatters.js.map +0 -1
  93. package/lib/internal/template/file-upload/dropzone/index.d.ts +0 -9
  94. package/lib/internal/template/file-upload/dropzone/index.d.ts.map +0 -1
  95. package/lib/internal/template/file-upload/dropzone/index.js +0 -69
  96. package/lib/internal/template/file-upload/dropzone/index.js.map +0 -1
  97. package/lib/internal/template/file-upload/dropzone/styles.css.js +0 -7
  98. package/lib/internal/template/file-upload/dropzone/styles.scoped.css +0 -108
  99. package/lib/internal/template/file-upload/dropzone/styles.selectors.js +0 -8
  100. package/lib/internal/template/file-upload/file-input/index.d.ts +0 -14
  101. package/lib/internal/template/file-upload/file-input/index.d.ts.map +0 -1
  102. package/lib/internal/template/file-upload/file-input/index.js +0 -55
  103. package/lib/internal/template/file-upload/file-input/index.js.map +0 -1
  104. package/lib/internal/template/file-upload/file-input/styles.css.js +0 -8
  105. package/lib/internal/template/file-upload/file-input/styles.scoped.css +0 -21
  106. package/lib/internal/template/file-upload/file-input/styles.selectors.js +0 -9
  107. package/lib/internal/template/file-upload/file-option/index.d.ts +0 -10
  108. package/lib/internal/template/file-upload/file-option/index.d.ts.map +0 -1
  109. package/lib/internal/template/file-upload/file-option/index.js +0 -22
  110. package/lib/internal/template/file-upload/file-option/index.js.map +0 -1
  111. package/lib/internal/template/file-upload/file-option/styles.css.js +0 -12
  112. package/lib/internal/template/file-upload/file-option/styles.scoped.css +0 -35
  113. package/lib/internal/template/file-upload/file-option/styles.selectors.js +0 -13
  114. package/lib/internal/template/file-upload/file-option/thumbnail.d.ts +0 -7
  115. package/lib/internal/template/file-upload/file-option/thumbnail.d.ts.map +0 -1
  116. package/lib/internal/template/file-upload/file-option/thumbnail.js +0 -20
  117. package/lib/internal/template/file-upload/file-option/thumbnail.js.map +0 -1
  118. package/lib/internal/template/file-upload/index.d.ts +0 -6
  119. package/lib/internal/template/file-upload/index.d.ts.map +0 -1
  120. package/lib/internal/template/file-upload/index.js +0 -17
  121. package/lib/internal/template/file-upload/index.js.map +0 -1
  122. package/lib/internal/template/file-upload/interfaces.d.ts +0 -99
  123. package/lib/internal/template/file-upload/interfaces.d.ts.map +0 -1
  124. package/lib/internal/template/file-upload/interfaces.js +0 -4
  125. package/lib/internal/template/file-upload/interfaces.js.map +0 -1
  126. package/lib/internal/template/file-upload/internal.d.ts +0 -7
  127. package/lib/internal/template/file-upload/internal.d.ts.map +0 -1
  128. package/lib/internal/template/file-upload/internal.js +0 -72
  129. package/lib/internal/template/file-upload/internal.js.map +0 -1
  130. package/lib/internal/template/file-upload/styles.css.js +0 -7
  131. package/lib/internal/template/file-upload/styles.scoped.css +0 -16
  132. package/lib/internal/template/file-upload/styles.selectors.js +0 -8
  133. package/lib/internal/template/test-utils/dom/file-upload/index.d.ts +0 -29
  134. package/lib/internal/template/test-utils/dom/file-upload/index.js +0 -66
  135. package/lib/internal/template/test-utils/dom/file-upload/index.js.map +0 -1
  136. package/lib/internal/template/test-utils/selectors/file-upload/index.d.ts +0 -29
  137. package/lib/internal/template/test-utils/selectors/file-upload/index.js +0 -66
  138. package/lib/internal/template/test-utils/selectors/file-upload/index.js.map +0 -1
@@ -1,55 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __rest } from "tslib";
4
- import React, { useEffect, useRef, useState } from 'react';
5
- import InternalButton from '../../button/internal';
6
- import styles from './styles.css.js';
7
- import { useFormFieldContext } from '../../contexts/form-field';
8
- import { useUniqueId } from '../../internal/hooks/use-unique-id';
9
- import { joinStrings } from '../../internal/utils/strings';
10
- import ScreenreaderOnly from '../../internal/components/screenreader-only';
11
- import useForwardFocus from '../../internal/hooks/forward-focus';
12
- export default React.forwardRef(FileInput);
13
- function FileInput(_a, ref) {
14
- var _b;
15
- var { accept, ariaRequired, multiple, value, onChange, children } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "multiple", "value", "onChange", "children"]);
16
- const uploadInputRef = useRef(null);
17
- const uploadButtonLabelId = useUniqueId('upload-button-label');
18
- const formFieldContext = useFormFieldContext(restProps);
19
- const selfControlId = useUniqueId('upload-input');
20
- const controlId = (_b = formFieldContext.controlId) !== null && _b !== void 0 ? _b : selfControlId;
21
- useForwardFocus(ref, uploadInputRef);
22
- const [isFocused, setIsFocused] = useState(false);
23
- const onUploadButtonClick = () => { var _a; return (_a = uploadInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); };
24
- const onUploadInputFocus = () => setIsFocused(true);
25
- const onUploadInputBlur = () => setIsFocused(false);
26
- const onUploadInputChange = ({ target }) => {
27
- onChange(target.files ? Array.from(target.files) : []);
28
- };
29
- const nativeAttributes = {
30
- 'aria-labelledby': joinStrings(formFieldContext.ariaLabelledby, uploadButtonLabelId),
31
- 'aria-describedby': formFieldContext.ariaDescribedby,
32
- };
33
- if (formFieldContext.invalid) {
34
- nativeAttributes['aria-invalid'] = true;
35
- }
36
- if (ariaRequired) {
37
- nativeAttributes['aria-required'] = true;
38
- }
39
- // Synchronizing component's value with the native file input state.
40
- useEffect(() => {
41
- // The DataTransfer is not available in jsdom.
42
- if (window.DataTransfer) {
43
- const dataTransfer = new DataTransfer();
44
- for (const file of value) {
45
- dataTransfer.items.add(file);
46
- }
47
- uploadInputRef.current.files = dataTransfer.files;
48
- }
49
- }, [value]);
50
- return (React.createElement("div", { className: styles['file-input-container'] },
51
- React.createElement("input", Object.assign({ id: controlId, ref: uploadInputRef, type: "file", hidden: false, multiple: multiple, accept: accept, onChange: onUploadInputChange, onFocus: onUploadInputFocus, onBlur: onUploadInputBlur, className: styles['upload-input'] }, nativeAttributes)),
52
- React.createElement(InternalButton, { iconName: "upload", formAction: "none", onClick: onUploadButtonClick, className: styles['upload-button'], __nativeAttributes: { tabIndex: -1, 'aria-hidden': true }, __forcedFocusState: isFocused ? 'focused' : undefined }, children),
53
- React.createElement(ScreenreaderOnly, { id: uploadButtonLabelId }, children)));
54
- }
55
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["file-upload/file-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAA6B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO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zB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAC7B,gBAAgB,EACpB;QAIF,oBAAC,cAAc,IACb,QAAQ,EAAC,QAAQ,EACjB,UAAU,EAAC,MAAM,EACjB,OAAO,EAAE,mBAAmB,EAC5B,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAClC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,EACzD,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAEpD,QAAQ,CACM;QAGjB,oBAAC,gBAAgB,IAAC,EAAE,EAAE,mBAAmB,IAAG,QAAQ,CAAoB,CACpE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ChangeEvent, ForwardedRef, useEffect, useRef, useState } from 'react';\n\nimport InternalButton from '../../button/internal';\nimport styles from './styles.css.js';\nimport { useFormFieldContext } from '../../contexts/form-field';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { FormFieldValidationControlProps } from '../../internal/context/form-field-context';\nimport { joinStrings } from '../../internal/utils/strings';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only';\nimport { FileUploadProps } from '../interfaces';\nimport useForwardFocus from '../../internal/hooks/forward-focus';\n\ninterface FileInputProps extends FormFieldValidationControlProps {\n accept?: string;\n ariaRequired?: boolean;\n multiple: boolean;\n value: readonly File[];\n onChange: (files: File[]) => void;\n children: React.ReactNode;\n}\n\nexport default React.forwardRef(FileInput);\n\nfunction FileInput(\n { accept, ariaRequired, multiple, value, onChange, children, ...restProps }: FileInputProps,\n ref: ForwardedRef<FileUploadProps.Ref>\n) {\n const uploadInputRef = useRef<HTMLInputElement>(null);\n const uploadButtonLabelId = useUniqueId('upload-button-label');\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('upload-input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n\n useForwardFocus(ref, uploadInputRef);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const onUploadButtonClick = () => uploadInputRef.current?.click();\n\n const onUploadInputFocus = () => setIsFocused(true);\n\n const onUploadInputBlur = () => setIsFocused(false);\n\n const onUploadInputChange = ({ target }: ChangeEvent<HTMLInputElement>) => {\n onChange(target.files ? Array.from(target.files) : []);\n };\n\n const nativeAttributes: Record<string, any> = {\n 'aria-labelledby': joinStrings(formFieldContext.ariaLabelledby, uploadButtonLabelId),\n 'aria-describedby': formFieldContext.ariaDescribedby,\n };\n if (formFieldContext.invalid) {\n nativeAttributes['aria-invalid'] = true;\n }\n if (ariaRequired) {\n nativeAttributes['aria-required'] = true;\n }\n\n // Synchronizing component's value with the native file input state.\n useEffect(() => {\n // The DataTransfer is not available in jsdom.\n if (window.DataTransfer) {\n const dataTransfer = new DataTransfer();\n for (const file of value) {\n dataTransfer.items.add(file);\n }\n uploadInputRef.current!.files = dataTransfer.files;\n }\n }, [value]);\n\n return (\n <div className={styles['file-input-container']}>\n {/* This is the actual interactive and accessible file-upload element. */}\n {/* It is visually hidden to achieve the desired UX design. */}\n <input\n id={controlId}\n ref={uploadInputRef}\n type=\"file\"\n hidden={false}\n multiple={multiple}\n accept={accept}\n onChange={onUploadInputChange}\n onFocus={onUploadInputFocus}\n onBlur={onUploadInputBlur}\n className={styles['upload-input']}\n {...nativeAttributes}\n />\n\n {/* The button is decorative. It dispatches clicks to the file input and is ARIA-hidden. */}\n {/* When the input is focused the focus outline is forced on the button. */}\n <InternalButton\n iconName=\"upload\"\n formAction=\"none\"\n onClick={onUploadButtonClick}\n className={styles['upload-button']}\n __nativeAttributes={{ tabIndex: -1, 'aria-hidden': true }}\n __forcedFocusState={isFocused ? 'focused' : undefined}\n >\n {children}\n </InternalButton>\n\n {/* The file input needs to be labelled with provided content. Can't use the button because it is ARIA-hidden. */}\n <ScreenreaderOnly id={uploadButtonLabelId}>{children}</ScreenreaderOnly>\n </div>\n );\n}\n"]}
@@ -1,8 +0,0 @@
1
-
2
- import './styles.scoped.css';
3
- export default {
4
- "upload-button": "awsui_upload-button_4xu1k_1753t_9",
5
- "upload-input": "awsui_upload-input_4xu1k_1753t_10",
6
- "file-input-container": "awsui_file-input-container_4xu1k_1753t_14"
7
- };
8
-
@@ -1,21 +0,0 @@
1
- /*
2
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- SPDX-License-Identifier: Apache-2.0
4
- */
5
- /*
6
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
- SPDX-License-Identifier: Apache-2.0
8
- */
9
- .awsui_upload-button_4xu1k_1753t_9:not(#\9),
10
- .awsui_upload-input_4xu1k_1753t_10:not(#\9) {
11
- /* used in test-utils */
12
- }
13
-
14
- .awsui_file-input-container_4xu1k_1753t_14:not(#\9) {
15
- position: relative;
16
- }
17
-
18
- .awsui_upload-input_4xu1k_1753t_10:not(#\9) {
19
- position: absolute;
20
- clip: rect(0, 0, 0, 0);
21
- }
@@ -1,9 +0,0 @@
1
-
2
- // es-module interop with Babel and Typescript
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- module.exports.default = {
5
- "upload-button": "awsui_upload-button_4xu1k_1753t_9",
6
- "upload-input": "awsui_upload-input_4xu1k_1753t_10",
7
- "file-input-container": "awsui_file-input-container_4xu1k_1753t_14"
8
- };
9
-
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { FileMetadata, FileUploadProps } from '../interfaces';
3
- interface FileOptionProps {
4
- file: File;
5
- metadata: FileMetadata;
6
- i18nStrings: FileUploadProps.I18nStrings;
7
- }
8
- export declare function FileOption({ file, metadata, i18nStrings }: FileOptionProps): JSX.Element;
9
- export {};
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["file-upload/file-option/index.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO9D,UAAU,eAAe;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC;CAC1C;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,eAAe,eA2B1E"}
@@ -1,22 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import React from 'react';
4
- import InternalBox from '../../box/internal';
5
- import InternalSpaceBetween from '../../space-between/internal';
6
- import styles from './styles.css.js';
7
- import * as defaultFormatters from '../default-formatters';
8
- import { FileOptionThumbnail } from './thumbnail';
9
- export function FileOption({ file, metadata, i18nStrings }) {
10
- var _a, _b;
11
- const isImage = file.type.startsWith('image/');
12
- const formatFileSize = (_a = i18nStrings.formatFileSize) !== null && _a !== void 0 ? _a : defaultFormatters.formatFileSize;
13
- const formatFileLastModified = (_b = i18nStrings.formatFileLastModified) !== null && _b !== void 0 ? _b : defaultFormatters.formatFileLastModified;
14
- return (React.createElement(InternalBox, { className: styles['file-option'] },
15
- metadata.showFileThumbnail && isImage && React.createElement(FileOptionThumbnail, { file: file }),
16
- React.createElement("div", { className: styles['file-option-metadata'] },
17
- React.createElement(InternalSpaceBetween, { direction: "vertical", size: "xxxs" },
18
- React.createElement(InternalBox, { className: styles['file-option-name'] }, file.name),
19
- metadata.showFileSize && file.size ? (React.createElement(InternalBox, { fontSize: "body-s", color: "text-body-secondary", className: styles['file-option-size'] }, formatFileSize(file.size))) : null,
20
- metadata.showFileLastModified && file.lastModified ? (React.createElement(InternalBox, { fontSize: "body-s", color: "text-body-secondary", className: styles['file-option-last-modified'] }, formatFileLastModified(new Date(file.lastModified)))) : null))));
21
- }
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/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,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CACd,CACf,CAAC,CAAC,CAAC,IAAI;gBAEP,QAAQ,CAAC,oBAAoB,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CACpD,oBAAC,WAAW,IAAC,QAAQ,EAAC,QAAQ,EAAC,KAAK,EAAC,qBAAqB,EAAC,SAAS,EAAE,MAAM,CAAC,2BAA2B,CAAC,IACtG,sBAAsB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CACxC,CACf,CAAC,CAAC,CAAC,IAAI,CACa,CACnB,CACM,CACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport { FileMetadata, FileUploadProps } from '../interfaces';\nimport InternalBox from '../../box/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport styles from './styles.css.js';\nimport * as defaultFormatters from '../default-formatters';\nimport { FileOptionThumbnail } from './thumbnail';\n\ninterface FileOptionProps {\n file: File;\n metadata: FileMetadata;\n i18nStrings: FileUploadProps.I18nStrings;\n}\n\nexport function FileOption({ file, metadata, i18nStrings }: FileOptionProps) {\n const isImage = file.type.startsWith('image/');\n const formatFileSize = i18nStrings.formatFileSize ?? defaultFormatters.formatFileSize;\n const formatFileLastModified = i18nStrings.formatFileLastModified ?? defaultFormatters.formatFileLastModified;\n return (\n <InternalBox className={styles['file-option']}>\n {metadata.showFileThumbnail && isImage && <FileOptionThumbnail file={file} />}\n\n <div className={styles['file-option-metadata']}>\n <InternalSpaceBetween direction=\"vertical\" size=\"xxxs\">\n <InternalBox className={styles['file-option-name']}>{file.name}</InternalBox>\n\n {metadata.showFileSize && file.size ? (\n <InternalBox fontSize=\"body-s\" color=\"text-body-secondary\" className={styles['file-option-size']}>\n {formatFileSize(file.size)}\n </InternalBox>\n ) : null}\n\n {metadata.showFileLastModified && file.lastModified ? (\n <InternalBox fontSize=\"body-s\" color=\"text-body-secondary\" className={styles['file-option-last-modified']}>\n {formatFileLastModified(new Date(file.lastModified))}\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n </div>\n </InternalBox>\n );\n}\n"]}
@@ -1,12 +0,0 @@
1
-
2
- import './styles.scoped.css';
3
- export default {
4
- "file-option-name": "awsui_file-option-name_ezgb4_q9xmi_9",
5
- "file-option-size": "awsui_file-option-size_ezgb4_q9xmi_10",
6
- "file-option-last-modified": "awsui_file-option-last-modified_ezgb4_q9xmi_11",
7
- "file-option-thumbnail": "awsui_file-option-thumbnail_ezgb4_q9xmi_12",
8
- "file-option": "awsui_file-option_ezgb4_q9xmi_9",
9
- "file-option-thumbnail-image": "awsui_file-option-thumbnail-image_ezgb4_q9xmi_28",
10
- "file-option-metadata": "awsui_file-option-metadata_ezgb4_q9xmi_33"
11
- };
12
-
@@ -1,35 +0,0 @@
1
- /*
2
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- SPDX-License-Identifier: Apache-2.0
4
- */
5
- /*
6
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
- SPDX-License-Identifier: Apache-2.0
8
- */
9
- .awsui_file-option-name_ezgb4_q9xmi_9:not(#\9),
10
- .awsui_file-option-size_ezgb4_q9xmi_10:not(#\9),
11
- .awsui_file-option-last-modified_ezgb4_q9xmi_11:not(#\9),
12
- .awsui_file-option-thumbnail_ezgb4_q9xmi_12:not(#\9) {
13
- /* used in test-utils */
14
- }
15
-
16
- .awsui_file-option_ezgb4_q9xmi_9:not(#\9) {
17
- width: 100%;
18
- min-width: 0;
19
- display: flex;
20
- gap: var(--space-scaled-xs-6859qs, 8px);
21
- }
22
-
23
- .awsui_file-option-thumbnail_ezgb4_q9xmi_12:not(#\9) {
24
- margin-top: var(--space-static-xxs-jy4jgd, 4px);
25
- max-width: 60px;
26
- }
27
-
28
- .awsui_file-option-thumbnail-image_ezgb4_q9xmi_28:not(#\9) {
29
- width: 100%;
30
- height: auto;
31
- }
32
-
33
- .awsui_file-option-metadata_ezgb4_q9xmi_33:not(#\9) {
34
- width: 100%;
35
- }
@@ -1,13 +0,0 @@
1
-
2
- // es-module interop with Babel and Typescript
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- module.exports.default = {
5
- "file-option-name": "awsui_file-option-name_ezgb4_q9xmi_9",
6
- "file-option-size": "awsui_file-option-size_ezgb4_q9xmi_10",
7
- "file-option-last-modified": "awsui_file-option-last-modified_ezgb4_q9xmi_11",
8
- "file-option-thumbnail": "awsui_file-option-thumbnail_ezgb4_q9xmi_12",
9
- "file-option": "awsui_file-option_ezgb4_q9xmi_9",
10
- "file-option-thumbnail-image": "awsui_file-option-thumbnail-image_ezgb4_q9xmi_28",
11
- "file-option-metadata": "awsui_file-option-metadata_ezgb4_q9xmi_33"
12
- };
13
-
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- interface FileOptionThumbnailProps {
3
- file: File;
4
- }
5
- export declare function FileOptionThumbnail({ file }: FileOptionThumbnailProps): JSX.Element;
6
- export {};
7
- //# sourceMappingURL=thumbnail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thumbnail.d.ts","sourceRoot":"lib/default/","sources":["file-upload/file-option/thumbnail.tsx"],"names":[],"mappings":";AAMA,UAAU,wBAAwB;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,EAAE,wBAAwB,eAoBrE"}
@@ -1,20 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import React, { useEffect, useState } from 'react';
4
- import styles from './styles.css.js';
5
- export function FileOptionThumbnail({ file }) {
6
- const [imageSrc, setImageSrc] = useState('');
7
- useEffect(() => {
8
- // The URL.createObjectURL is not available in jsdom.
9
- if (URL.createObjectURL) {
10
- const src = URL.createObjectURL(file);
11
- setImageSrc(src);
12
- return () => {
13
- URL.revokeObjectURL(src);
14
- };
15
- }
16
- }, [file]);
17
- return (React.createElement("div", { className: styles['file-option-thumbnail'], "aria-hidden": true },
18
- React.createElement("img", { className: styles['file-option-thumbnail-image'], alt: file.name, src: imageSrc })));
19
- }
20
- //# sourceMappingURL=thumbnail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thumbnail.js","sourceRoot":"lib/default/","sources":["file-upload/file-option/thumbnail.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,MAAM,UAAU,mBAAmB,CAAC,EAAE,IAAI,EAA4B;IACpE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,qDAAqD;QACrD,IAAI,GAAG,CAAC,eAAe,EAAE;YACvB,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACtC,WAAW,CAAC,GAAG,CAAC,CAAC;YAEjB,OAAO,GAAG,EAAE;gBACV,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,iBAAe,IAAI;QAChE,6BAAK,SAAS,EAAE,MAAM,CAAC,6BAA6B,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAI,CACpF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useState } from 'react';\nimport styles from './styles.css.js';\n\ninterface FileOptionThumbnailProps {\n file: File;\n}\n\nexport function FileOptionThumbnail({ file }: FileOptionThumbnailProps) {\n const [imageSrc, setImageSrc] = useState('');\n\n useEffect(() => {\n // The URL.createObjectURL is not available in jsdom.\n if (URL.createObjectURL) {\n const src = URL.createObjectURL(file);\n setImageSrc(src);\n\n return () => {\n URL.revokeObjectURL(src);\n };\n }\n }, [file]);\n\n return (\n <div className={styles['file-option-thumbnail']} aria-hidden={true}>\n <img className={styles['file-option-thumbnail-image']} alt={file.name} src={imageSrc} />\n </div>\n );\n}\n"]}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { FileUploadProps } from './interfaces';
3
- export { FileUploadProps };
4
- declare const FileUpload: React.ForwardRefExoticComponent<FileUploadProps & React.RefAttributes<FileUploadProps.Ref>>;
5
- export default FileUpload;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["file-upload/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FAmBf,CAAC;AAGF,eAAe,UAAU,CAAC"}
@@ -1,17 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __rest } from "tslib";
4
- import React from 'react';
5
- import { applyDisplayName } from '../internal/utils/apply-display-name';
6
- import InternalFileUpload from './internal';
7
- import useBaseComponent from '../internal/hooks/use-base-component';
8
- import { getExternalProps } from '../internal/utils/external-props';
9
- const FileUpload = React.forwardRef((_a, ref) => {
10
- var { multiple, showFileSize, showFileLastModified, showFileThumbnail } = _a, restProps = __rest(_a, ["multiple", "showFileSize", "showFileLastModified", "showFileThumbnail"]);
11
- const baseComponentProps = useBaseComponent('FileUpload');
12
- const externalProps = getExternalProps(restProps);
13
- return (React.createElement(InternalFileUpload, Object.assign({ ref: ref, multiple: multiple, showFileSize: showFileSize, showFileLastModified: showFileLastModified, showFileThumbnail: showFileThumbnail }, externalProps, baseComponentProps)));
14
- });
15
- applyDisplayName(FileUpload, 'FileUpload');
16
- export default FileUpload;
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["file-upload/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,kBAAkB,MAAM,YAAY,CAAC;AAC5C,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIpE,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACjC,CACE,EAAkG,EAClG,GAAmC,EACnC,EAAE;QAFF,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,OAAiC,EAA5B,SAAS,cAA/E,yEAAiF,CAAF;IAG/E,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,CACL,oBAAC,kBAAkB,kBACjB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,iBAAiB,IAChC,aAAa,EACb,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FileUploadProps } from './interfaces';\nimport InternalFileUpload from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { getExternalProps } from '../internal/utils/external-props';\n\nexport { FileUploadProps };\n\nconst FileUpload = React.forwardRef(\n (\n { multiple, showFileSize, showFileLastModified, showFileThumbnail, ...restProps }: FileUploadProps,\n ref: React.Ref<FileUploadProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('FileUpload');\n const externalProps = getExternalProps(restProps);\n return (\n <InternalFileUpload\n ref={ref}\n multiple={multiple}\n showFileSize={showFileSize}\n showFileLastModified={showFileLastModified}\n showFileThumbnail={showFileThumbnail}\n {...externalProps}\n {...baseComponentProps}\n />\n );\n }\n);\n\napplyDisplayName(FileUpload, 'FileUpload');\nexport default FileUpload;\n"]}
@@ -1,99 +0,0 @@
1
- /// <reference types="react" />
2
- import { BaseComponentProps } from '../internal/base-component';
3
- import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
4
- import { NonCancelableEventHandler } from '../internal/events';
5
- export interface FileUploadProps extends BaseComponentProps, FormFieldValidationControlProps {
6
- /**
7
- * Specifies the native file input `accept` attribute to describe the allow-list of file types.
8
- */
9
- accept?: string;
10
- /**
11
- * Specifies whether to add aria-required to the file upload control.
12
- */
13
- ariaRequired?: boolean;
14
- /**
15
- * Show file size in the token. Use `i18nStrings.formatFileSize` to customize it.
16
- */
17
- showFileSize?: boolean;
18
- /**
19
- * Show file last modified timestamp in the token. Use `i18nStrings.formatFileLastModified` to customize it.
20
- */
21
- showFileLastModified?: boolean;
22
- /**
23
- * Show file thumbnail in the token. Only supported for images.
24
- */
25
- showFileThumbnail?: boolean;
26
- /**
27
- * Specifies the native file input `multiple` attribute to allow users entering more than one file.
28
- */
29
- multiple?: boolean;
30
- /**
31
- * Called when the user selects new file(s), or removes a file.
32
- * The event `detail` contains the current value of the component.
33
- */
34
- onChange?: NonCancelableEventHandler<FileUploadProps.ChangeDetail>;
35
- /**
36
- * Specifies the currently selected file(s).
37
- * If you want to clear the selection, use empty array.
38
- */
39
- value: ReadonlyArray<File>;
40
- /**
41
- * Specifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.
42
- */
43
- tokenLimit?: number;
44
- /**
45
- * Constraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.
46
- */
47
- constraintText?: React.ReactNode;
48
- /**
49
- * Text that displays as a validation message.
50
- */
51
- errorText?: React.ReactNode;
52
- /**
53
- * An array of file errors corresponding to the files in the `value`.
54
- */
55
- fileErrors?: ReadonlyArray<null | string>;
56
- /**
57
- * An object containing all the localized strings required by the component:
58
- * * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.
59
- * * `dropzoneText` (function): A function to render the text shown in the dropzone. It takes `multiple` attribute to define plurality.
60
- * * `removeFileAriaLabel` (function): A function to render the ARIA label for file token remove button.
61
- * * `limitShowFewer` (string): The text of the show more tokens button.
62
- * * `limitShowMore` (string): The text of the show fewer tokens button.
63
- * * `errorIconAriaLabel` (string): The ARIA label to be shown on the error file icon.
64
- * * `formatFileSize` (function): (Optional) A function that takes file size in bytes, and produces a formatted string.
65
- * * `formatFileLastModified` (function): (Optional) A function that takes the files last modified date, and produces a formatted string.
66
- */
67
- i18nStrings: FileUploadProps.I18nStrings;
68
- }
69
- export declare namespace FileUploadProps {
70
- interface ChangeDetail {
71
- value: File[];
72
- }
73
- interface DismissDetail {
74
- index: number;
75
- file: File;
76
- }
77
- interface I18nStrings {
78
- uploadButtonText: (multiple: boolean) => string;
79
- dropzoneText: (multiple: boolean) => string;
80
- removeFileAriaLabel: (fileIndex: number) => string;
81
- limitShowFewer: string;
82
- limitShowMore: string;
83
- errorIconAriaLabel: string;
84
- formatFileSize?: (sizeInBytes: number) => string;
85
- formatFileLastModified?: (date: Date) => string;
86
- }
87
- interface Ref {
88
- /**
89
- * Sets focus on the file upload button.
90
- */
91
- focus(): void;
92
- }
93
- }
94
- export interface FileMetadata {
95
- showFileSize?: boolean;
96
- showFileLastModified?: boolean;
97
- showFileThumbnail?: boolean;
98
- }
99
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["file-upload/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,+BAA+B;IAC1F;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACnE;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IAC1C;;;;;;;;;;OAUG;IACH,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC;CAC1C;AAED,yBAAiB,eAAe,CAAC;IAC/B,UAAiB,YAAY;QAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;KACf;IAED,UAAiB,aAAa;QAC5B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,IAAI,CAAC;KACZ;IAED,UAAiB,WAAW;QAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;QAChD,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;QAC5C,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;QACnD,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;QACjD,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;KACjD;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
@@ -1,4 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- export {};
4
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["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 { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileUploadProps extends BaseComponentProps, FormFieldValidationControlProps {\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 message.\n */\n errorText?: 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 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 * * `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 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 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\nexport interface FileMetadata {\n showFileSize?: boolean;\n showFileLastModified?: boolean;\n showFileThumbnail?: boolean;\n}\n"]}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { FileUploadProps } from './interfaces';
3
- import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
4
- import { ButtonProps } from '../button/interfaces';
5
- declare const _default: React.ForwardRefExoticComponent<FileUploadProps & InternalBaseComponentProps & React.RefAttributes<ButtonProps.Ref>>;
6
- export default _default;
7
- //# sourceMappingURL=internal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["file-upload/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;;AAqBnD,wBAAoD"}
@@ -1,72 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __rest } from "tslib";
4
- import React, { useRef, useState } from 'react';
5
- import { FileOption } from './file-option';
6
- import InternalSpaceBetween from '../space-between/internal';
7
- import styles from './styles.css.js';
8
- import { fireNonCancelableEvent } from '../internal/events';
9
- import { getBaseProps } from '../internal/base-component';
10
- import checkControlled from '../internal/hooks/check-controlled';
11
- import clsx from 'clsx';
12
- import { warnOnce } from '../internal/logging';
13
- import { Dropzone, useDropzoneVisible } from './dropzone';
14
- import FileInput from './file-input';
15
- import TokenList from '../internal/components/token-list';
16
- import { Token } from '../token-group/token';
17
- import { ConstraintText, FormFieldError } from '../form-field/internal';
18
- import { useUniqueId } from '../internal/hooks/use-unique-id';
19
- import { useMergeRefs } from '../internal/hooks/use-merge-refs';
20
- import { joinStrings } from '../internal/utils/strings';
21
- import { useFormFieldContext } from '../contexts/form-field';
22
- import InternalBox from '../box/internal';
23
- export default React.forwardRef(InternalFileUpload);
24
- function InternalFileUpload(_a, externalRef) {
25
- var _b;
26
- var { accept, ariaRequired, multiple = false, onChange, value, tokenLimit, showFileSize, showFileLastModified, showFileThumbnail, i18nStrings, __internalRootRef = null, constraintText, errorText, fileErrors } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "multiple", "onChange", "value", "tokenLimit", "showFileSize", "showFileLastModified", "showFileThumbnail", "i18nStrings", "__internalRootRef", "constraintText", "errorText", "fileErrors"]);
27
- const baseProps = getBaseProps(restProps);
28
- const metadata = { showFileSize, showFileLastModified, showFileThumbnail };
29
- const errorId = useUniqueId('error-');
30
- const constraintTextId = useUniqueId('constraint-text-');
31
- const fileInputRef = useRef(null);
32
- const ref = useMergeRefs(fileInputRef, externalRef);
33
- const [removedFileIndex, setRemovedFileIndex] = useState(null);
34
- checkControlled('FileUpload', 'value', value, 'onChange', onChange);
35
- if (!multiple && value.length > 1) {
36
- warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');
37
- }
38
- const handleFilesChange = (newFiles) => {
39
- const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles : [...value];
40
- fireNonCancelableEvent(onChange, { value: newValue });
41
- };
42
- const onFileRemove = (removeFileIndex) => {
43
- var _a;
44
- const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);
45
- fireNonCancelableEvent(onChange, { value: newValue });
46
- setRemovedFileIndex(removeFileIndex);
47
- if (value.length === 1) {
48
- (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
49
- }
50
- };
51
- const isDropzoneVisible = useDropzoneVisible();
52
- const formFieldContext = useFormFieldContext(restProps);
53
- const ariaDescribedBy = joinStrings((_b = restProps.ariaDescribedby) !== null && _b !== void 0 ? _b : formFieldContext.ariaDescribedby, errorText ? errorId : undefined, constraintText ? constraintTextId : undefined);
54
- const hasError = Boolean(errorText || (fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors.filter(Boolean).length));
55
- const invalid = restProps.invalid || formFieldContext.invalid || hasError;
56
- return (React.createElement(InternalSpaceBetween, Object.assign({}, baseProps, { size: "xs", className: clsx(baseProps.className, styles.root), __internalRootRef: __internalRootRef }),
57
- React.createElement(InternalBox, null,
58
- isDropzoneVisible ? (React.createElement(Dropzone, { onChange: handleFilesChange }, i18nStrings.dropzoneText(multiple))) : (React.createElement(FileInput, Object.assign({ ref: ref, accept: accept, ariaRequired: ariaRequired, multiple: multiple, onChange: handleFilesChange, value: value }, restProps, { ariaDescribedby: ariaDescribedBy, invalid: invalid }), i18nStrings.uploadButtonText(multiple))),
59
- (constraintText || errorText) && (React.createElement("div", { className: styles.hints },
60
- errorText && (React.createElement(FormFieldError, { id: errorId, errorIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel }, errorText)),
61
- constraintText && (React.createElement(ConstraintText, { id: constraintTextId, hasError: !!errorText }, constraintText))))),
62
- !multiple && value.length > 0 ? (React.createElement(InternalBox, null,
63
- React.createElement(Token, { ariaLabel: value[0].name, dismissLabel: i18nStrings.removeFileAriaLabel(0), onDismiss: () => onFileRemove(0), errorText: fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors[0], errorIconAriaLabel: i18nStrings.errorIconAriaLabel, "data-index": 0 },
64
- React.createElement(FileOption, { file: value[0], metadata: metadata, i18nStrings: i18nStrings })))) : null,
65
- multiple && value.length > 0 ? (React.createElement(InternalBox, null,
66
- React.createElement(TokenList, { alignment: "vertical", items: value, renderItem: (file, fileIndex) => (React.createElement(Token, { ariaLabel: file.name, dismissLabel: i18nStrings.removeFileAriaLabel(fileIndex), onDismiss: () => onFileRemove(fileIndex), errorText: fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors[fileIndex], errorIconAriaLabel: i18nStrings.errorIconAriaLabel, "data-index": fileIndex },
67
- React.createElement(FileOption, { file: file, metadata: metadata, i18nStrings: i18nStrings }))), limit: tokenLimit, i18nStrings: {
68
- limitShowFewer: i18nStrings.limitShowFewer,
69
- limitShowMore: i18nStrings.limitShowMore,
70
- }, removedItemIndex: removedFileIndex }))) : null));
71
- }
72
- //# sourceMappingURL=internal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAA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Ac;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa;iBACzC,EACD,gBAAgB,EAAE,gBAAgB,GAClC,CACU,CACf,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 { FileUploadProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nimport { FileOption } from './file-option';\nimport { ButtonProps } from '../button/interfaces';\nimport InternalSpaceBetween from '../space-between/internal';\nimport styles from './styles.css.js';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport clsx from 'clsx';\nimport { warnOnce } from '../internal/logging';\nimport { Dropzone, useDropzoneVisible } from './dropzone';\nimport FileInput from './file-input';\nimport TokenList from '../internal/components/token-list';\nimport { Token } from '../token-group/token';\nimport { ConstraintText, FormFieldError } from '../form-field/internal';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport InternalBox from '../box/internal';\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 = null,\n constraintText,\n errorText,\n fileErrors,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n const [removedFileIndex, setRemovedFileIndex] = useState<null | number>(null);\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 : [...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 setRemovedFileIndex(removeFileIndex);\n if (value.length === 1) {\n fileInputRef.current?.focus();\n }\n };\n\n const isDropzoneVisible = useDropzoneVisible();\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : 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 >\n <InternalBox>\n {isDropzoneVisible ? (\n <Dropzone onChange={handleFilesChange}>{i18nStrings.dropzoneText(multiple)}</Dropzone>\n ) : (\n <FileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={handleFilesChange}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </FileInput>\n )}\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!multiple && value.length > 0 ? (\n <InternalBox>\n <Token\n ariaLabel={value[0].name}\n dismissLabel={i18nStrings.removeFileAriaLabel(0)}\n onDismiss={() => onFileRemove(0)}\n errorText={fileErrors?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n data-index={0}\n >\n <FileOption file={value[0]} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n </InternalBox>\n ) : null}\n\n {multiple && value.length > 0 ? (\n <InternalBox>\n <TokenList\n alignment=\"vertical\"\n items={value}\n renderItem={(file, fileIndex) => (\n <Token\n ariaLabel={file.name}\n dismissLabel={i18nStrings.removeFileAriaLabel(fileIndex)}\n onDismiss={() => onFileRemove(fileIndex)}\n errorText={fileErrors?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n data-index={fileIndex}\n >\n <FileOption file={file} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n )}\n limit={tokenLimit}\n i18nStrings={{\n limitShowFewer: i18nStrings.limitShowFewer,\n limitShowMore: i18nStrings.limitShowMore,\n }}\n removedItemIndex={removedFileIndex}\n />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
@@ -1,7 +0,0 @@
1
-
2
- import './styles.scoped.css';
3
- export default {
4
- "root": "awsui_root_1ubbm_utofa_9",
5
- "hints": "awsui_hints_1ubbm_utofa_10"
6
- };
7
-
@@ -1,16 +0,0 @@
1
- /*
2
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- SPDX-License-Identifier: Apache-2.0
4
- */
5
- /*
6
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
- SPDX-License-Identifier: Apache-2.0
8
- */
9
- .awsui_root_1ubbm_utofa_9:not(#\9),
10
- .awsui_hints_1ubbm_utofa_10:not(#\9) {
11
- /* used in test-utils */
12
- }
13
-
14
- .awsui_hints_1ubbm_utofa_10:not(#\9) {
15
- margin-top: var(--space-static-xxs-jy4jgd, 4px);
16
- }
@@ -1,8 +0,0 @@
1
-
2
- // es-module interop with Babel and Typescript
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- module.exports.default = {
5
- "root": "awsui_root_1ubbm_utofa_9",
6
- "hints": "awsui_hints_1ubbm_utofa_10"
7
- };
8
-
@@ -1,29 +0,0 @@
1
- import { ComponentWrapper, ElementWrapper } from '@cloudscape-design/test-utils-core/dom';
2
- import ButtonWrapper from '../button';
3
- export default class FileUploadWrapper extends ComponentWrapper<HTMLElement> {
4
- static rootSelector: string;
5
- findUploadButton(): ButtonWrapper;
6
- findNativeInput(): ElementWrapper<HTMLInputElement>;
7
- findFileTokens(): Array<FileTokenWrapper>;
8
- /**
9
- * Returns a file token from for a given index.
10
- *
11
- * @param tokenIndex 1-based index of the file token to return.
12
- */
13
- findFileToken(fileTokenIndex: number): null | FileTokenWrapper;
14
- /**
15
- * Returns the token toggle button.
16
- */
17
- findTokenToggle(): null | ElementWrapper;
18
- findConstraint(): null | ElementWrapper;
19
- findError(): null | ElementWrapper;
20
- }
21
- declare class FileTokenWrapper extends ComponentWrapper {
22
- findFileName(): ElementWrapper;
23
- findFileSize(): null | ElementWrapper;
24
- findFileLastModified(): null | ElementWrapper;
25
- findFileThumbnail(): null | ElementWrapper;
26
- findFileError(): null | ElementWrapper;
27
- findRemoveButton(): ElementWrapper;
28
- }
29
- export {};