@cloudscape-design/components 3.0.357 → 3.0.358
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button-dropdown/item-element/styles.css.js +15 -14
- package/button-dropdown/item-element/styles.scoped.css +18 -18
- package/button-dropdown/item-element/styles.selectors.js +15 -14
- package/file-upload/dropzone/index.d.ts +1 -1
- package/file-upload/dropzone/index.d.ts.map +1 -1
- package/file-upload/dropzone/index.js +10 -4
- package/file-upload/dropzone/index.js.map +1 -1
- package/file-upload/internal.js +1 -1
- package/file-upload/internal.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"item-element": "awsui_item-
|
|
5
|
-
"disabled": "
|
|
6
|
-
"last": "
|
|
7
|
-
"highlighted": "
|
|
8
|
-
"variant-icon": "awsui_variant-
|
|
9
|
-
"variant-
|
|
10
|
-
"variant-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
4
|
+
"item-element": "awsui_item-element_93a1u_153ch_93",
|
|
5
|
+
"disabled": "awsui_disabled_93a1u_153ch_103",
|
|
6
|
+
"last": "awsui_last_93a1u_153ch_110",
|
|
7
|
+
"highlighted": "awsui_highlighted_93a1u_153ch_113",
|
|
8
|
+
"variant-icon": "awsui_variant-icon_93a1u_153ch_117",
|
|
9
|
+
"variant-inline-icon": "awsui_variant-inline-icon_93a1u_153ch_117",
|
|
10
|
+
"variant-normal": "awsui_variant-normal_93a1u_153ch_117",
|
|
11
|
+
"variant-primary": "awsui_variant-primary_93a1u_153ch_117",
|
|
12
|
+
"is-focused": "awsui_is-focused_93a1u_153ch_127",
|
|
13
|
+
"variant-navigation": "awsui_variant-navigation_93a1u_153ch_131",
|
|
14
|
+
"first": "awsui_first_93a1u_153ch_134",
|
|
15
|
+
"has-category-header": "awsui_has-category-header_93a1u_153ch_134",
|
|
16
|
+
"menu-item": "awsui_menu-item_93a1u_153ch_148",
|
|
17
|
+
"icon": "awsui_icon_93a1u_153ch_166",
|
|
18
|
+
"external-icon": "awsui_external-icon_93a1u_153ch_171"
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -90,7 +90,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.awsui_item-
|
|
93
|
+
.awsui_item-element_93a1u_153ch_93:not(#\9) {
|
|
94
94
|
position: relative;
|
|
95
95
|
z-index: 1;
|
|
96
96
|
border: var(--border-item-width-yel47s, 2px) solid transparent;
|
|
@@ -100,52 +100,52 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
100
100
|
margin-top: calc(-1 * var(--border-field-width-09w7vk, 2px));
|
|
101
101
|
cursor: pointer;
|
|
102
102
|
}
|
|
103
|
-
.awsui_item-
|
|
103
|
+
.awsui_item-element_93a1u_153ch_93.awsui_disabled_93a1u_153ch_103:not(#\9) {
|
|
104
104
|
cursor: default;
|
|
105
105
|
color: var(--color-text-dropdown-item-disabled-6oq3n6, #9ba7b6);
|
|
106
106
|
}
|
|
107
|
-
.awsui_item-
|
|
107
|
+
.awsui_item-element_93a1u_153ch_93:not(#\9):first-child {
|
|
108
108
|
margin-top: 0;
|
|
109
109
|
}
|
|
110
|
-
.awsui_item-
|
|
110
|
+
.awsui_item-element_93a1u_153ch_93.awsui_last_93a1u_153ch_110:not(#\9) {
|
|
111
111
|
border-bottom: var(--border-item-width-yel47s, 2px) solid var(--color-border-dropdown-group-c2r4dp, #e9ebed);
|
|
112
112
|
}
|
|
113
|
-
.awsui_item-
|
|
113
|
+
.awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113:not(#\9) {
|
|
114
114
|
color: var(--color-text-dropdown-item-highlighted-a51hdb, #000716);
|
|
115
115
|
z-index: 2;
|
|
116
116
|
}
|
|
117
|
-
.awsui_item-
|
|
117
|
+
.awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-icon_93a1u_153ch_117:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-inline-icon_93a1u_153ch_117:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-normal_93a1u_153ch_117:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-primary_93a1u_153ch_117:not(#\9) {
|
|
118
118
|
background-color: var(--color-background-dropdown-item-hover-md83i5, #f4f4f4);
|
|
119
119
|
border-color: var(--color-border-dropdown-item-hover-461g78, #7d8998);
|
|
120
120
|
border-radius: var(--border-radius-item-05df9h, 8px);
|
|
121
121
|
}
|
|
122
|
-
.awsui_item-
|
|
122
|
+
.awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-icon_93a1u_153ch_117.awsui_disabled_93a1u_153ch_103:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-inline-icon_93a1u_153ch_117.awsui_disabled_93a1u_153ch_103:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-normal_93a1u_153ch_117.awsui_disabled_93a1u_153ch_103:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-primary_93a1u_153ch_117.awsui_disabled_93a1u_153ch_103:not(#\9) {
|
|
123
123
|
color: var(--color-text-dropdown-item-dimmed-f2joj8, #9ba7b6);
|
|
124
124
|
border-color: var(--color-border-dropdown-item-dimmed-hover-xdu0hf, #7d8998);
|
|
125
125
|
background-color: var(--color-background-dropdown-item-dimmed-dlm6wk, transparent);
|
|
126
126
|
}
|
|
127
|
-
.awsui_item-
|
|
127
|
+
.awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-icon_93a1u_153ch_117.awsui_is-focused_93a1u_153ch_127:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-inline-icon_93a1u_153ch_117.awsui_is-focused_93a1u_153ch_127:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-normal_93a1u_153ch_117.awsui_is-focused_93a1u_153ch_127:not(#\9), .awsui_item-element_93a1u_153ch_93.awsui_highlighted_93a1u_153ch_113.awsui_variant-primary_93a1u_153ch_117.awsui_is-focused_93a1u_153ch_127:not(#\9) {
|
|
128
128
|
border-color: var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
129
129
|
box-shadow: inset 0 0 0 var(--border-control-focus-ring-shadow-spread-0ctpjf, 0px) var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
130
130
|
}
|
|
131
|
-
.awsui_item-
|
|
131
|
+
.awsui_item-element_93a1u_153ch_93.awsui_variant-navigation_93a1u_153ch_131.awsui_highlighted_93a1u_153ch_113:not(#\9) {
|
|
132
132
|
color: var(--color-text-accent-n2acxv, #0972d3);
|
|
133
133
|
}
|
|
134
|
-
.awsui_item-
|
|
134
|
+
.awsui_item-element_93a1u_153ch_93.awsui_variant-navigation_93a1u_153ch_131.awsui_first_93a1u_153ch_134:not(#\9):not(.awsui_has-category-header_93a1u_153ch_134) {
|
|
135
135
|
padding-top: var(--space-xxs-p8yyaw, 4px);
|
|
136
136
|
}
|
|
137
|
-
.awsui_item-
|
|
137
|
+
.awsui_item-element_93a1u_153ch_93.awsui_variant-navigation_93a1u_153ch_131.awsui_last_93a1u_153ch_110:not(#\9) {
|
|
138
138
|
padding-bottom: var(--space-xxs-p8yyaw, 4px);
|
|
139
139
|
}
|
|
140
|
-
.awsui_item-
|
|
140
|
+
.awsui_item-element_93a1u_153ch_93.awsui_variant-navigation_93a1u_153ch_131.awsui_first_93a1u_153ch_134.awsui_last_93a1u_153ch_110:not(#\9) {
|
|
141
141
|
padding-bottom: var(--space-xxs-p8yyaw, 4px);
|
|
142
142
|
padding-top: var(--space-xxs-p8yyaw, 4px);
|
|
143
143
|
}
|
|
144
|
-
.awsui_item-
|
|
144
|
+
.awsui_item-element_93a1u_153ch_93.awsui_variant-navigation_93a1u_153ch_131.awsui_last_93a1u_153ch_110:not(#\9):last-child {
|
|
145
145
|
padding-bottom: var(--space-xxs-p8yyaw, 4px);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
.awsui_menu-
|
|
148
|
+
.awsui_menu-item_93a1u_153ch_148:not(#\9) {
|
|
149
149
|
min-width: 0;
|
|
150
150
|
-ms-word-break: break-all;
|
|
151
151
|
word-break: break-word;
|
|
@@ -156,18 +156,18 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
156
156
|
text-decoration: none;
|
|
157
157
|
/* stylelint-disable-next-line selector-max-type */
|
|
158
158
|
}
|
|
159
|
-
.awsui_menu-
|
|
159
|
+
.awsui_menu-item_93a1u_153ch_148:not(#\9):focus {
|
|
160
160
|
outline: none;
|
|
161
161
|
}
|
|
162
|
-
.awsui_has-category-
|
|
162
|
+
.awsui_has-category-header_93a1u_153ch_134 > .awsui_menu-item_93a1u_153ch_148:not(#\9), .awsui_has-category-header_93a1u_153ch_134 > span > .awsui_menu-item_93a1u_153ch_148:not(#\9) {
|
|
163
163
|
padding-left: calc(var(--space-s-34lx8l, 12px) + var(--space-button-horizontal-8jxzea, 20px));
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
.
|
|
166
|
+
.awsui_icon_93a1u_153ch_166:not(#\9) {
|
|
167
167
|
padding-right: var(--space-xs-zb16t3, 8px);
|
|
168
168
|
flex-shrink: 0;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
.awsui_external-
|
|
171
|
+
.awsui_external-icon_93a1u_153ch_171:not(#\9) {
|
|
172
172
|
margin-left: var(--space-xxs-p8yyaw, 4px);
|
|
173
173
|
}
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"item-element": "awsui_item-
|
|
6
|
-
"disabled": "
|
|
7
|
-
"last": "
|
|
8
|
-
"highlighted": "
|
|
9
|
-
"variant-icon": "awsui_variant-
|
|
10
|
-
"variant-
|
|
11
|
-
"variant-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
5
|
+
"item-element": "awsui_item-element_93a1u_153ch_93",
|
|
6
|
+
"disabled": "awsui_disabled_93a1u_153ch_103",
|
|
7
|
+
"last": "awsui_last_93a1u_153ch_110",
|
|
8
|
+
"highlighted": "awsui_highlighted_93a1u_153ch_113",
|
|
9
|
+
"variant-icon": "awsui_variant-icon_93a1u_153ch_117",
|
|
10
|
+
"variant-inline-icon": "awsui_variant-inline-icon_93a1u_153ch_117",
|
|
11
|
+
"variant-normal": "awsui_variant-normal_93a1u_153ch_117",
|
|
12
|
+
"variant-primary": "awsui_variant-primary_93a1u_153ch_117",
|
|
13
|
+
"is-focused": "awsui_is-focused_93a1u_153ch_127",
|
|
14
|
+
"variant-navigation": "awsui_variant-navigation_93a1u_153ch_131",
|
|
15
|
+
"first": "awsui_first_93a1u_153ch_134",
|
|
16
|
+
"has-category-header": "awsui_has-category-header_93a1u_153ch_134",
|
|
17
|
+
"menu-item": "awsui_menu-item_93a1u_153ch_148",
|
|
18
|
+
"icon": "awsui_icon_93a1u_153ch_166",
|
|
19
|
+
"external-icon": "awsui_external-icon_93a1u_153ch_171"
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -3,7 +3,7 @@ interface DropzoneProps {
|
|
|
3
3
|
onChange: (files: File[]) => void;
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
}
|
|
6
|
-
export declare function useDropzoneVisible(): boolean;
|
|
6
|
+
export declare function useDropzoneVisible(multiple: boolean): boolean;
|
|
7
7
|
export declare function Dropzone({ onChange, children }: DropzoneProps): JSX.Element;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,CAAC,QAAQ,EAAE,OAAO,WAmDnD;AAED,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,aAAa,eAuC7D"}
|
|
@@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
4
4
|
import styles from './styles.css.js';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import InternalIcon from '../../icon/internal';
|
|
7
|
-
export function useDropzoneVisible() {
|
|
7
|
+
export function useDropzoneVisible(multiple) {
|
|
8
8
|
const [isDropzoneVisible, setDropzoneVisible] = useState(false);
|
|
9
9
|
// Registering global drag events listeners.
|
|
10
10
|
useEffect(() => {
|
|
@@ -14,7 +14,13 @@ export function useDropzoneVisible() {
|
|
|
14
14
|
const onDocumentDragOver = (event) => {
|
|
15
15
|
var _a, _b;
|
|
16
16
|
event.preventDefault();
|
|
17
|
-
|
|
17
|
+
let files = 0;
|
|
18
|
+
for (let item = 0; item < (((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.items.length) || 0); item++) {
|
|
19
|
+
if (((_b = event.dataTransfer) === null || _b === void 0 ? void 0 : _b.items[item].kind) === 'file') {
|
|
20
|
+
files++;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (files > 0 && (multiple || files === 1)) {
|
|
18
24
|
setDropzoneVisible(true);
|
|
19
25
|
dragTimer && clearTimeout(dragTimer);
|
|
20
26
|
}
|
|
@@ -38,15 +44,15 @@ export function useDropzoneVisible() {
|
|
|
38
44
|
document.removeEventListener('dragleave', onDocumentDragLeave);
|
|
39
45
|
document.removeEventListener('drop', onDocumentDrop);
|
|
40
46
|
};
|
|
41
|
-
}, []);
|
|
47
|
+
}, [multiple]);
|
|
42
48
|
return isDropzoneVisible;
|
|
43
49
|
}
|
|
44
50
|
export function Dropzone({ onChange, children }) {
|
|
45
51
|
const [isDropzoneHovered, setDropzoneHovered] = useState(false);
|
|
46
52
|
const onDragOver = (event) => {
|
|
47
53
|
event.preventDefault();
|
|
48
|
-
setDropzoneHovered(true);
|
|
49
54
|
if (event.dataTransfer) {
|
|
55
|
+
setDropzoneHovered(true);
|
|
50
56
|
event.dataTransfer.dropEffect = 'copy';
|
|
51
57
|
}
|
|
52
58
|
};
|
|
@@ -1 +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,E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AC5D,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACzB,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(multiple: boolean) {\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 let files = 0;\n for (let item = 0; item < (event.dataTransfer?.items.length || 0); item++) {\n if (event.dataTransfer?.items[item].kind === 'file') {\n files++;\n }\n }\n if (files > 0 && (multiple || 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 }, [multiple]);\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\n if (event.dataTransfer) {\n setDropzoneHovered(true);\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"]}
|
package/file-upload/internal.js
CHANGED
|
@@ -48,7 +48,7 @@ function InternalFileUpload(_a, externalRef) {
|
|
|
48
48
|
(_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const isDropzoneVisible = useDropzoneVisible();
|
|
51
|
+
const isDropzoneVisible = useDropzoneVisible(multiple);
|
|
52
52
|
const formFieldContext = useFormFieldContext(restProps);
|
|
53
53
|
const ariaDescribedBy = joinStrings((_b = restProps.ariaDescribedby) !== null && _b !== void 0 ? _b : formFieldContext.ariaDescribedby, errorText ? errorId : undefined, constraintText ? constraintTextId : undefined);
|
|
54
54
|
const hasError = Boolean(errorText || (fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors.filter(Boolean).length));
|
|
@@ -1 +1 @@
|
|
|
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,OAA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ACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,gBACtC,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;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 '@cloudscape-design/component-toolkit/internal';\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
|
+
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["file-upload/internal.tsx"],"names":[],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AAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC9B,oBAAC,WAAW;YACV,oBAAC,SAAS,IACR,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC/B,oBAAC,KAAK,IACJ,SAAS,EAAE,IAAI,CAAC,IAAI,EACpB,YAAY,EAAE,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACxD,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,gBACtC,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;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 '@cloudscape-design/component-toolkit/internal';\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(multiple);\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"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED