@cloudscape-design/components 3.0.250 → 3.0.251

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 (129) hide show
  1. package/app-layout/visual-refresh/app-bar.js +1 -1
  2. package/app-layout/visual-refresh/app-bar.js.map +1 -1
  3. package/autosuggest/internal.d.ts.map +1 -1
  4. package/autosuggest/internal.js +2 -1
  5. package/autosuggest/internal.js.map +1 -1
  6. package/autosuggest/options-list.d.ts +2 -1
  7. package/autosuggest/options-list.d.ts.map +1 -1
  8. package/autosuggest/options-list.js +8 -2
  9. package/autosuggest/options-list.js.map +1 -1
  10. package/button/internal.d.ts +1 -1
  11. package/button/internal.d.ts.map +1 -1
  12. package/button/internal.js +3 -2
  13. package/button/internal.js.map +1 -1
  14. package/button/styles.css.js +20 -19
  15. package/button/styles.scoped.css +298 -136
  16. package/button/styles.selectors.js +20 -19
  17. package/file-upload/default-formatters.d.ts +3 -0
  18. package/file-upload/default-formatters.d.ts.map +1 -0
  19. package/file-upload/default-formatters.js +23 -0
  20. package/file-upload/default-formatters.js.map +1 -0
  21. package/file-upload/dropzone/index.d.ts +9 -0
  22. package/file-upload/dropzone/index.d.ts.map +1 -0
  23. package/file-upload/dropzone/index.js +69 -0
  24. package/file-upload/dropzone/index.js.map +1 -0
  25. package/file-upload/dropzone/styles.css.js +7 -0
  26. package/file-upload/dropzone/styles.scoped.css +108 -0
  27. package/file-upload/dropzone/styles.selectors.js +8 -0
  28. package/file-upload/file-input/index.d.ts +14 -0
  29. package/file-upload/file-input/index.d.ts.map +1 -0
  30. package/file-upload/file-input/index.js +55 -0
  31. package/file-upload/file-input/index.js.map +1 -0
  32. package/file-upload/file-input/styles.css.js +8 -0
  33. package/file-upload/file-input/styles.scoped.css +21 -0
  34. package/file-upload/file-input/styles.selectors.js +9 -0
  35. package/file-upload/file-option/index.d.ts +10 -0
  36. package/file-upload/file-option/index.d.ts.map +1 -0
  37. package/file-upload/file-option/index.js +22 -0
  38. package/file-upload/file-option/index.js.map +1 -0
  39. package/file-upload/file-option/styles.css.js +12 -0
  40. package/file-upload/file-option/styles.scoped.css +35 -0
  41. package/file-upload/file-option/styles.selectors.js +13 -0
  42. package/file-upload/file-option/thumbnail.d.ts +7 -0
  43. package/file-upload/file-option/thumbnail.d.ts.map +1 -0
  44. package/file-upload/file-option/thumbnail.js +20 -0
  45. package/file-upload/file-option/thumbnail.js.map +1 -0
  46. package/file-upload/index.d.ts +6 -0
  47. package/file-upload/index.d.ts.map +1 -0
  48. package/file-upload/index.js +17 -0
  49. package/file-upload/index.js.map +1 -0
  50. package/file-upload/interfaces.d.ts +99 -0
  51. package/file-upload/interfaces.d.ts.map +1 -0
  52. package/file-upload/interfaces.js +4 -0
  53. package/file-upload/interfaces.js.map +1 -0
  54. package/file-upload/internal.d.ts +7 -0
  55. package/file-upload/internal.d.ts.map +1 -0
  56. package/file-upload/internal.js +72 -0
  57. package/file-upload/internal.js.map +1 -0
  58. package/file-upload/styles.css.js +7 -0
  59. package/file-upload/styles.scoped.css +16 -0
  60. package/file-upload/styles.selectors.js +8 -0
  61. package/form-field/internal.d.ts +6 -1
  62. package/form-field/internal.d.ts.map +1 -1
  63. package/form-field/internal.js +6 -3
  64. package/form-field/internal.js.map +1 -1
  65. package/index.d.ts +1 -0
  66. package/index.d.ts.map +1 -1
  67. package/index.js +1 -0
  68. package/index.js.map +1 -1
  69. package/internal/base-component/styles.scoped.css +17 -0
  70. package/internal/components/dropdown-footer/index.d.ts +1 -0
  71. package/internal/components/dropdown-footer/index.d.ts.map +1 -1
  72. package/internal/components/dropdown-footer/index.js +2 -2
  73. package/internal/components/dropdown-footer/index.js.map +1 -1
  74. package/internal/components/live-region/index.d.ts +2 -1
  75. package/internal/components/live-region/index.d.ts.map +1 -1
  76. package/internal/components/live-region/index.js +2 -2
  77. package/internal/components/live-region/index.js.map +1 -1
  78. package/internal/components/options-list/index.d.ts +1 -0
  79. package/internal/components/options-list/index.d.ts.map +1 -1
  80. package/internal/components/options-list/index.js +2 -2
  81. package/internal/components/options-list/index.js.map +1 -1
  82. package/internal/environment.js +1 -1
  83. package/internal/generated/theming/index.cjs +95 -0
  84. package/internal/generated/theming/index.js +95 -0
  85. package/internal/manifest.json +1 -1
  86. package/multiselect/internal.d.ts.map +1 -1
  87. package/multiselect/internal.js +4 -3
  88. package/multiselect/internal.js.map +1 -1
  89. package/package.json +2 -1
  90. package/property-filter/index.d.ts.map +1 -1
  91. package/property-filter/index.js +1 -1
  92. package/property-filter/index.js.map +1 -1
  93. package/property-filter/interfaces.d.ts +2 -1
  94. package/property-filter/interfaces.d.ts.map +1 -1
  95. package/property-filter/interfaces.js.map +1 -1
  96. package/property-filter/property-filter-autosuggest.d.ts.map +1 -1
  97. package/property-filter/property-filter-autosuggest.js +4 -2
  98. package/property-filter/property-filter-autosuggest.js.map +1 -1
  99. package/select/internal.d.ts.map +1 -1
  100. package/select/internal.js +4 -3
  101. package/select/internal.js.map +1 -1
  102. package/split-panel/interfaces.d.ts +8 -8
  103. package/split-panel/interfaces.d.ts.map +1 -1
  104. package/split-panel/interfaces.js.map +1 -1
  105. package/split-panel/preferences-modal.d.ts +7 -7
  106. package/split-panel/preferences-modal.d.ts.map +1 -1
  107. package/split-panel/preferences-modal.js.map +1 -1
  108. package/table/body-cell/index.js +1 -1
  109. package/table/body-cell/index.js.map +1 -1
  110. package/test-utils/dom/file-upload/index.d.ts +29 -0
  111. package/test-utils/dom/file-upload/index.js +66 -0
  112. package/test-utils/dom/file-upload/index.js.map +1 -0
  113. package/test-utils/dom/index.d.ts +3 -0
  114. package/test-utils/dom/index.js +10 -2
  115. package/test-utils/dom/index.js.map +1 -1
  116. package/test-utils/selectors/file-upload/index.d.ts +29 -0
  117. package/test-utils/selectors/file-upload/index.js +66 -0
  118. package/test-utils/selectors/file-upload/index.js.map +1 -0
  119. package/test-utils/selectors/index.d.ts +3 -0
  120. package/test-utils/selectors/index.js +10 -2
  121. package/test-utils/selectors/index.js.map +1 -1
  122. package/test-utils/tsconfig.tsbuildinfo +1 -1
  123. package/token-group/styles.css.js +7 -5
  124. package/token-group/styles.scoped.css +41 -23
  125. package/token-group/styles.selectors.js +7 -5
  126. package/token-group/token.d.ts +4 -1
  127. package/token-group/token.d.ts.map +1 -1
  128. package/token-group/token.js +13 -4
  129. package/token-group/token.js.map +1 -1
@@ -2,24 +2,25 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "content": "awsui_content_vjswe_1himx_97",
6
- "button": "awsui_button_vjswe_1himx_101",
7
- "variant-normal": "awsui_variant-normal_vjswe_1himx_126",
8
- "is-activated": "awsui_is-activated_vjswe_1himx_139",
9
- "hide-focus-outline": "awsui_hide-focus-outline_vjswe_1himx_148",
10
- "variant-icon": "awsui_variant-icon_vjswe_1himx_166",
11
- "variant-modal-dismiss": "awsui_variant-modal-dismiss_vjswe_1himx_166",
12
- "variant-flashbar-icon": "awsui_variant-flashbar-icon_vjswe_1himx_166",
13
- "variant-inline-icon": "awsui_variant-inline-icon_vjswe_1himx_184",
14
- "disabled": "awsui_disabled_vjswe_1himx_202",
15
- "variant-primary": "awsui_variant-primary_vjswe_1himx_210",
16
- "variant-link": "awsui_variant-link_vjswe_1himx_294",
17
- "variant-breadcrumb-group": "awsui_variant-breadcrumb-group_vjswe_1himx_714",
18
- "variant-menu-trigger": "awsui_variant-menu-trigger_vjswe_1himx_801",
19
- "button-no-text": "awsui_button-no-text_vjswe_1himx_885",
20
- "button-no-wrap": "awsui_button-no-wrap_vjswe_1himx_889",
21
- "icon-left": "awsui_icon-left_vjswe_1himx_905",
22
- "icon-right": "awsui_icon-right_vjswe_1himx_910",
23
- "icon": "awsui_icon_vjswe_1himx_905"
5
+ "content": "awsui_content_vjswe_uh9zb_97",
6
+ "button": "awsui_button_vjswe_uh9zb_101",
7
+ "variant-normal": "awsui_variant-normal_vjswe_uh9zb_126",
8
+ "is-activated": "awsui_is-activated_vjswe_uh9zb_139",
9
+ "hide-focus-outline": "awsui_hide-focus-outline_vjswe_uh9zb_148",
10
+ "force-focus-outline": "awsui_force-focus-outline_vjswe_uh9zb_166",
11
+ "variant-icon": "awsui_variant-icon_vjswe_uh9zb_184",
12
+ "variant-modal-dismiss": "awsui_variant-modal-dismiss_vjswe_uh9zb_184",
13
+ "variant-flashbar-icon": "awsui_variant-flashbar-icon_vjswe_uh9zb_184",
14
+ "variant-inline-icon": "awsui_variant-inline-icon_vjswe_uh9zb_202",
15
+ "disabled": "awsui_disabled_vjswe_uh9zb_220",
16
+ "variant-primary": "awsui_variant-primary_vjswe_uh9zb_228",
17
+ "variant-link": "awsui_variant-link_vjswe_uh9zb_330",
18
+ "variant-breadcrumb-group": "awsui_variant-breadcrumb-group_vjswe_uh9zb_840",
19
+ "variant-menu-trigger": "awsui_variant-menu-trigger_vjswe_uh9zb_945",
20
+ "button-no-text": "awsui_button-no-text_vjswe_uh9zb_1047",
21
+ "button-no-wrap": "awsui_button-no-wrap_vjswe_uh9zb_1051",
22
+ "icon-left": "awsui_icon-left_vjswe_uh9zb_1067",
23
+ "icon-right": "awsui_icon-right_vjswe_uh9zb_1072",
24
+ "icon": "awsui_icon_vjswe_uh9zb_1067"
24
25
  };
25
26
 
@@ -0,0 +1,3 @@
1
+ export declare function formatFileSize(size: number): string;
2
+ export declare function formatFileLastModified(date: Date): string;
3
+ //# sourceMappingURL=default-formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-formatters.d.ts","sourceRoot":"lib/default/","sources":["file-upload/default-formatters.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWnD;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,23 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { formatDateTime } from '../internal/utils/date-time';
4
+ const KB = 1000;
5
+ const MB = Math.pow(1000, 2);
6
+ const GB = Math.pow(1000, 3);
7
+ const TB = Math.pow(1000, 4);
8
+ export function formatFileSize(size) {
9
+ if (size < MB) {
10
+ return `${(size / KB).toFixed(2)} KB`;
11
+ }
12
+ if (size < GB) {
13
+ return `${(size / MB).toFixed(2)} MB`;
14
+ }
15
+ if (size < TB) {
16
+ return `${(size / GB).toFixed(2)} GB`;
17
+ }
18
+ return `${(size / TB).toFixed(2)} TB`;
19
+ }
20
+ export function formatFileLastModified(date) {
21
+ return formatDateTime(date);
22
+ }
23
+ //# sourceMappingURL=default-formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-formatters.js","sourceRoot":"lib/default/","sources":["file-upload/default-formatters.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,EAAE,GAAG,IAAI,CAAC;AAChB,MAAM,EAAE,GAAG,SAAA,IAAI,EAAI,CAAC,CAAA,CAAC;AACrB,MAAM,EAAE,GAAG,SAAA,IAAI,EAAI,CAAC,CAAA,CAAC;AACrB,MAAM,EAAE,GAAG,SAAA,IAAI,EAAI,CAAC,CAAA,CAAC;AAErB,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;KACvC;IACD,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;KACvC;IACD,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;KACvC;IACD,OAAO,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAU;IAC/C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { formatDateTime } from '../internal/utils/date-time';\n\nconst KB = 1000;\nconst MB = 1000 ** 2;\nconst GB = 1000 ** 3;\nconst TB = 1000 ** 4;\n\nexport function formatFileSize(size: number): string {\n if (size < MB) {\n return `${(size / KB).toFixed(2)} KB`;\n }\n if (size < GB) {\n return `${(size / MB).toFixed(2)} MB`;\n }\n if (size < TB) {\n return `${(size / GB).toFixed(2)} GB`;\n }\n return `${(size / TB).toFixed(2)} TB`;\n}\n\nexport function formatFileLastModified(date: Date): string {\n return formatDateTime(date);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface DropzoneProps {
3
+ onChange: (files: File[]) => void;
4
+ children: React.ReactNode;
5
+ }
6
+ export declare function useDropzoneVisible(): boolean;
7
+ export declare function Dropzone({ onChange, children }: DropzoneProps): JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["file-upload/dropzone/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,UAAU,aAAa;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,kBAAkB,YA6CjC;AAED,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,aAAa,eAuC7D"}
@@ -0,0 +1,69 @@
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
+ import clsx from 'clsx';
6
+ import InternalIcon from '../../icon/internal';
7
+ export function useDropzoneVisible() {
8
+ const [isDropzoneVisible, setDropzoneVisible] = useState(false);
9
+ // Registering global drag events listeners.
10
+ useEffect(() => {
11
+ // The timer helps avoiding dropzone blinking.
12
+ let dragTimer = null;
13
+ // The file-upload dropzone is shown when the user drags files over to the browser.
14
+ const onDocumentDragOver = (event) => {
15
+ var _a, _b;
16
+ event.preventDefault();
17
+ if (((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) === null || _b === void 0 ? void 0 : _b.indexOf('Files')) !== -1) {
18
+ setDropzoneVisible(true);
19
+ dragTimer && clearTimeout(dragTimer);
20
+ }
21
+ };
22
+ // When the files are no longer dragged over the browser the state must be reset.
23
+ const onDocumentDragLeave = (event) => {
24
+ event.preventDefault();
25
+ dragTimer = setTimeout(() => setDropzoneVisible(false), 25);
26
+ };
27
+ // If the files were dropped the state must be reset.
28
+ const onDocumentDrop = (event) => {
29
+ event.preventDefault();
30
+ dragTimer = setTimeout(() => setDropzoneVisible(false), 25);
31
+ };
32
+ document.addEventListener('dragover', onDocumentDragOver, false);
33
+ document.addEventListener('dragleave', onDocumentDragLeave, false);
34
+ document.addEventListener('drop', onDocumentDrop, false);
35
+ return () => {
36
+ dragTimer && clearTimeout(dragTimer);
37
+ document.removeEventListener('dragover', onDocumentDragOver);
38
+ document.removeEventListener('dragleave', onDocumentDragLeave);
39
+ document.removeEventListener('drop', onDocumentDrop);
40
+ };
41
+ }, []);
42
+ return isDropzoneVisible;
43
+ }
44
+ export function Dropzone({ onChange, children }) {
45
+ const [isDropzoneHovered, setDropzoneHovered] = useState(false);
46
+ const onDragOver = (event) => {
47
+ event.preventDefault();
48
+ setDropzoneHovered(true);
49
+ if (event.dataTransfer) {
50
+ event.dataTransfer.dropEffect = 'copy';
51
+ }
52
+ };
53
+ const onDragLeave = (event) => {
54
+ event.preventDefault();
55
+ setDropzoneHovered(false);
56
+ if (event.dataTransfer) {
57
+ event.dataTransfer.dropEffect = 'none';
58
+ }
59
+ };
60
+ const onDrop = (event) => {
61
+ event.preventDefault();
62
+ setDropzoneHovered(false);
63
+ onChange(Array.from(event.dataTransfer.files));
64
+ };
65
+ return (React.createElement("div", { className: clsx(styles.dropzone, isDropzoneHovered && styles['dropzone-hovered']), onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop },
66
+ React.createElement(InternalIcon, { name: "upload" }),
67
+ React.createElement("span", null, children)));
68
+ }
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["file-upload/dropzone/index.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;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAO/C,MAAM,UAAU,kBAAkB;IAChC,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,4CAA4C;IAC5C,SAAS,CAAC,GAAG,EAAE;QACb,8CAA8C;QAC9C,IAAI,SAAS,GAAyC,IAAI,CAAC;QAE3D,mFAAmF;QACnF,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAE,EAAE;;YAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,IAAI,CAAA,MAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,KAAK,0CAAE,OAAO,CAAC,OAAO,CAAC,MAAK,CAAC,CAAC,EAAE;gBACtD,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBACz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CAAC,KAAK,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAEzB,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,KAAsB,EAAE,EAAE;QACxC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,IAAI,MAAM,CAAC,kBAAkB,CAAC,CAAC,EACjF,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM;QAEd,oBAAC,YAAY,IAAC,IAAI,EAAC,QAAQ,GAAG;QAC9B,kCAAO,QAAQ,CAAQ,CACnB,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';\nimport clsx from 'clsx';\nimport InternalIcon from '../../icon/internal';\n\ninterface DropzoneProps {\n onChange: (files: File[]) => void;\n children: React.ReactNode;\n}\n\nexport function useDropzoneVisible() {\n const [isDropzoneVisible, setDropzoneVisible] = useState(false);\n\n // Registering global drag events listeners.\n useEffect(() => {\n // The timer helps avoiding dropzone blinking.\n let dragTimer: null | ReturnType<typeof setTimeout> = null;\n\n // The file-upload dropzone is shown when the user drags files over to the browser.\n const onDocumentDragOver = (event: DragEvent) => {\n event.preventDefault();\n\n if (event.dataTransfer?.types?.indexOf('Files') !== -1) {\n setDropzoneVisible(true);\n dragTimer && clearTimeout(dragTimer);\n }\n };\n\n // When the files are no longer dragged over the browser the state must be reset.\n const onDocumentDragLeave = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setDropzoneVisible(false), 25);\n };\n\n // If the files were dropped the state must be reset.\n const onDocumentDrop = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setDropzoneVisible(false), 25);\n };\n\n document.addEventListener('dragover', onDocumentDragOver, false);\n document.addEventListener('dragleave', onDocumentDragLeave, false);\n document.addEventListener('drop', onDocumentDrop, false);\n\n return () => {\n dragTimer && clearTimeout(dragTimer);\n document.removeEventListener('dragover', onDocumentDragOver);\n document.removeEventListener('dragleave', onDocumentDragLeave);\n document.removeEventListener('drop', onDocumentDrop);\n };\n }, []);\n\n return isDropzoneVisible;\n}\n\nexport function Dropzone({ onChange, children }: DropzoneProps) {\n const [isDropzoneHovered, setDropzoneHovered] = useState(false);\n\n const onDragOver = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(true);\n\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = 'copy';\n }\n };\n\n const onDragLeave = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = 'none';\n }\n };\n\n const onDrop = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n\n onChange(Array.from(event.dataTransfer.files));\n };\n\n return (\n <div\n className={clsx(styles.dropzone, isDropzoneHovered && styles['dropzone-hovered'])}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n onDrop={onDrop}\n >\n <InternalIcon name=\"upload\" />\n <span>{children}</span>\n </div>\n );\n}\n"]}
@@ -0,0 +1,7 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "dropzone": "awsui_dropzone_1fham_1blgf_93",
5
+ "dropzone-hovered": "awsui_dropzone-hovered_1fham_1blgf_105"
6
+ };
7
+
@@ -0,0 +1,108 @@
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
+ /*
10
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
11
+ SPDX-License-Identifier: Apache-2.0
12
+ */
13
+ /*
14
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
15
+ SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ /*
18
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
19
+ SPDX-License-Identifier: Apache-2.0
20
+ */
21
+ /*
22
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
23
+ SPDX-License-Identifier: Apache-2.0
24
+ */
25
+ /*
26
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
+ SPDX-License-Identifier: Apache-2.0
28
+ */
29
+ /*
30
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
31
+ SPDX-License-Identifier: Apache-2.0
32
+ */
33
+ /*
34
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
35
+ SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ /*
38
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
39
+ SPDX-License-Identifier: Apache-2.0
40
+ */
41
+ /*
42
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
43
+ SPDX-License-Identifier: Apache-2.0
44
+ */
45
+ /*
46
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
47
+ SPDX-License-Identifier: Apache-2.0
48
+ */
49
+ /*
50
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
51
+ SPDX-License-Identifier: Apache-2.0
52
+ */
53
+ /*
54
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55
+ SPDX-License-Identifier: Apache-2.0
56
+ */
57
+ /*
58
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
59
+ SPDX-License-Identifier: Apache-2.0
60
+ */
61
+ /*
62
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
63
+ SPDX-License-Identifier: Apache-2.0
64
+ */
65
+ /* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
66
+ /* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
67
+ /*
68
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
69
+ SPDX-License-Identifier: Apache-2.0
70
+ */
71
+ /*
72
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
73
+ SPDX-License-Identifier: Apache-2.0
74
+ */
75
+ /*
76
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
77
+ SPDX-License-Identifier: Apache-2.0
78
+ */
79
+ /*
80
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
81
+ SPDX-License-Identifier: Apache-2.0
82
+ */
83
+ /* Style used for links in slots/components that are text heavy, to help links stand out among
84
+ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
85
+ /*
86
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
87
+ SPDX-License-Identifier: Apache-2.0
88
+ */
89
+ /*
90
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
+ SPDX-License-Identifier: Apache-2.0
92
+ */
93
+ .awsui_dropzone_1fham_1blgf_93:not(#\9) {
94
+ display: flex;
95
+ flex-direction: column;
96
+ align-items: center;
97
+ justify-content: center;
98
+ gap: var(--space-static-xxs-jy4jgd, 4px);
99
+ padding: var(--space-static-l-t7yjdj, 20px);
100
+ border-radius: var(--border-radius-dropzone-poqo08, 12px);
101
+ color: var(--color-dropzone-text-active-aobpir, #5f6b7a);
102
+ background-color: var(--color-dropzone-background-active-g4zi07, #e9ebed);
103
+ font-weight: 700;
104
+ }
105
+ .awsui_dropzone-hovered_1fham_1blgf_105:not(#\9) {
106
+ color: var(--color-dropzone-text-hover-ud2lnq, #033160);
107
+ background-color: var(--color-dropzone-background-hover-j98f7z, #d3e7f9);
108
+ }
@@ -0,0 +1,8 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "dropzone": "awsui_dropzone_1fham_1blgf_93",
6
+ "dropzone-hovered": "awsui_dropzone-hovered_1fham_1blgf_105"
7
+ };
8
+
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { FormFieldValidationControlProps } from '../../internal/context/form-field-context';
3
+ import { FileUploadProps } from '../interfaces';
4
+ interface FileInputProps extends FormFieldValidationControlProps {
5
+ accept?: string;
6
+ ariaRequired?: boolean;
7
+ multiple: boolean;
8
+ value: readonly File[];
9
+ onChange: (files: File[]) => void;
10
+ children: React.ReactNode;
11
+ }
12
+ declare const _default: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<FileUploadProps.Ref>>;
13
+ export default _default;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["file-upload/file-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAMtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAG5F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,UAAU,cAAe,SAAQ,+BAA+B;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;;AAED,wBAA2C"}
@@ -0,0 +1,55 @@
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
@@ -0,0 +1 @@
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,CAAC;AAEtF,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,MAAM,MAAM,iBAAi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Ac,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"]}
@@ -0,0 +1,8 @@
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
+
@@ -0,0 +1,21 @@
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
+ }
@@ -0,0 +1,9 @@
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
+
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"l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7F,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"]}
@@ -0,0 +1,12 @@
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
+
@@ -0,0 +1,35 @@
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
+ }
@@ -0,0 +1,13 @@
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
+
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
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"}