@cloudscape-design/components-themeable 3.0.836 → 3.0.838
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/components/file-token-group/constants.scss +14 -0
- package/lib/internal/scss/internal/components/file-token-group/styles.scss +143 -0
- package/lib/internal/scss/internal/components/file-token-group/test-classes/styles.scss +12 -0
- package/lib/internal/scss/internal/components/token-list/styles.scss +13 -1
- package/lib/internal/scss/token-group/constants.scss +0 -1
- package/lib/internal/scss/token-group/mixins.scss +27 -0
- package/lib/internal/scss/token-group/styles.scss +2 -33
- package/lib/internal/template/file-upload/interfaces.d.ts +5 -0
- package/lib/internal/template/file-upload/interfaces.d.ts.map +1 -1
- package/lib/internal/template/file-upload/interfaces.js.map +1 -1
- package/lib/internal/template/file-upload/internal.d.ts.map +1 -1
- package/lib/internal/template/file-upload/internal.js +7 -13
- package/lib/internal/template/file-upload/internal.js.map +1 -1
- package/lib/internal/template/internal/components/file-token-group/default-formatters.d.ts.map +1 -0
- package/lib/internal/template/{file-upload → internal/components/file-token-group}/default-formatters.js +1 -1
- package/lib/internal/template/internal/components/file-token-group/default-formatters.js.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/file-token.d.ts +32 -0
- package/lib/internal/template/internal/components/file-token-group/file-token.d.ts.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/file-token.js +71 -0
- package/lib/internal/template/internal/components/file-token-group/file-token.js.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/index.d.ts +8 -0
- package/lib/internal/template/internal/components/file-token-group/index.d.ts.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/index.js +41 -0
- package/lib/internal/template/internal/components/file-token-group/index.js.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/interfaces.d.ts +85 -0
- package/lib/internal/template/internal/components/file-token-group/interfaces.d.ts.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/interfaces.js +2 -0
- package/lib/internal/template/internal/components/file-token-group/interfaces.js.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/styles.css.js +27 -0
- package/lib/internal/template/internal/components/file-token-group/styles.scoped.css +375 -0
- package/lib/internal/template/internal/components/file-token-group/styles.selectors.js +28 -0
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.css.js +11 -0
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.scoped.css +12 -0
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.selectors.js +12 -0
- package/lib/internal/template/internal/components/file-token-group/thumbnail.d.ts.map +1 -0
- package/lib/internal/template/internal/components/file-token-group/thumbnail.js.map +1 -0
- package/lib/internal/template/internal/components/token-list/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/token-list/index.js +5 -1
- package/lib/internal/template/internal/components/token-list/index.js.map +1 -1
- package/lib/internal/template/internal/components/token-list/interfaces.d.ts +1 -1
- package/lib/internal/template/internal/components/token-list/interfaces.d.ts.map +1 -1
- package/lib/internal/template/internal/components/token-list/interfaces.js.map +1 -1
- package/lib/internal/template/internal/components/token-list/styles.css.js +10 -9
- package/lib/internal/template/internal/components/token-list/styles.scoped.css +41 -21
- package/lib/internal/template/internal/components/token-list/styles.selectors.js +10 -9
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/property-filter/token-editor-inputs.js +5 -5
- package/lib/internal/template/property-filter/token-editor-inputs.js.map +1 -1
- package/lib/internal/template/test-utils/dom/file-upload/index.d.ts +1 -10
- package/lib/internal/template/test-utils/dom/file-upload/index.js +13 -36
- package/lib/internal/template/test-utils/dom/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/dom/internal/file-token-group.d.ts +21 -0
- package/lib/internal/template/test-utils/dom/internal/file-token-group.js +51 -0
- package/lib/internal/template/test-utils/dom/internal/file-token-group.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/file-upload/index.d.ts +1 -10
- package/lib/internal/template/test-utils/selectors/file-upload/index.js +13 -36
- package/lib/internal/template/test-utils/selectors/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/internal/file-token-group.d.ts +21 -0
- package/lib/internal/template/test-utils/selectors/internal/file-token-group.js +51 -0
- package/lib/internal/template/test-utils/selectors/internal/file-token-group.js.map +1 -0
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/lib/internal/template/token-group/styles.css.js +8 -10
- package/lib/internal/template/token-group/styles.scoped.css +25 -38
- package/lib/internal/template/token-group/styles.selectors.js +8 -10
- package/lib/internal/template/token-group/token.d.ts +1 -5
- package/lib/internal/template/token-group/token.d.ts.map +1 -1
- package/lib/internal/template/token-group/token.js +4 -11
- package/lib/internal/template/token-group/token.js.map +1 -1
- package/package.json +1 -1
- package/lib/internal/scss/file-upload/file-option/styles.scss +0 -34
- package/lib/internal/template/file-upload/default-formatters.d.ts.map +0 -1
- package/lib/internal/template/file-upload/default-formatters.js.map +0 -1
- package/lib/internal/template/file-upload/file-option/index.d.ts +0 -10
- package/lib/internal/template/file-upload/file-option/index.d.ts.map +0 -1
- package/lib/internal/template/file-upload/file-option/index.js +0 -22
- package/lib/internal/template/file-upload/file-option/index.js.map +0 -1
- package/lib/internal/template/file-upload/file-option/styles.css.js +0 -12
- package/lib/internal/template/file-upload/file-option/styles.scoped.css +0 -35
- package/lib/internal/template/file-upload/file-option/styles.selectors.js +0 -13
- package/lib/internal/template/file-upload/file-option/thumbnail.d.ts.map +0 -1
- package/lib/internal/template/file-upload/file-option/thumbnail.js.map +0 -1
- /package/lib/internal/template/{file-upload → internal/components/file-token-group}/default-formatters.d.ts +0 -0
- /package/lib/internal/template/{file-upload/file-option → internal/components/file-token-group}/thumbnail.d.ts +0 -0
- /package/lib/internal/template/{file-upload/file-option → internal/components/file-token-group}/thumbnail.js +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../../styles/tokens' as awsui;
|
|
7
|
+
|
|
8
|
+
$image-size: 48px;
|
|
9
|
+
$file-token-height: 68px;
|
|
10
|
+
$compact-token-width: 230px;
|
|
11
|
+
$spinner-size: awsui.$size-icon-normal;
|
|
12
|
+
|
|
13
|
+
$token-background: awsui.$color-background-item-selected;
|
|
14
|
+
$token-border-color: awsui.$color-border-item-selected;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../../styles/tokens' as awsui;
|
|
7
|
+
@use '../../styles' as styles;
|
|
8
|
+
@use './constants' as constants;
|
|
9
|
+
@use '../../../token-group/mixins.scss' as mixins;
|
|
10
|
+
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
11
|
+
|
|
12
|
+
@mixin token-box-validation {
|
|
13
|
+
border-inline-start-width: awsui.$border-invalid-width;
|
|
14
|
+
|
|
15
|
+
> .dismiss-button {
|
|
16
|
+
color: awsui.$color-text-interactive-default;
|
|
17
|
+
&:hover {
|
|
18
|
+
color: awsui.$color-text-interactive-hover;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.root {
|
|
24
|
+
@include styles.styles-reset();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.file-loading-overlay {
|
|
28
|
+
position: absolute;
|
|
29
|
+
inset-inline-end: awsui.$space-static-xs;
|
|
30
|
+
inset-block-end: awsui.$space-static-xxs;
|
|
31
|
+
|
|
32
|
+
&-single-row {
|
|
33
|
+
inset-inline-end: awsui.$space-static-xxl;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.file-option-name,
|
|
38
|
+
.file-option-size,
|
|
39
|
+
.file-option-last-modified {
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.file-option {
|
|
46
|
+
inline-size: 100%;
|
|
47
|
+
min-inline-size: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: awsui.$space-scaled-xs;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.file-option-thumbnail {
|
|
53
|
+
margin-block-start: awsui.$space-static-xxs;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.file-option-thumbnail-image {
|
|
57
|
+
@include styles.font-body-s;
|
|
58
|
+
|
|
59
|
+
inline-size: constants.$image-size;
|
|
60
|
+
block-size: constants.$image-size;
|
|
61
|
+
object-fit: cover;
|
|
62
|
+
|
|
63
|
+
display: -webkit-box;
|
|
64
|
+
-webkit-line-clamp: 3;
|
|
65
|
+
-webkit-box-orient: vertical;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.file-option-metadata {
|
|
70
|
+
inline-size: 100%;
|
|
71
|
+
|
|
72
|
+
&.with-image {
|
|
73
|
+
inline-size: calc(100% - constants.$image-size);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&.single-row-loading {
|
|
77
|
+
inline-size: calc(100% - constants.$spinner-size);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.token {
|
|
82
|
+
position: relative;
|
|
83
|
+
block-size: 100%;
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
gap: awsui.$space-xxs;
|
|
87
|
+
|
|
88
|
+
&-grid {
|
|
89
|
+
display: grid;
|
|
90
|
+
grid-template-rows: max-content auto;
|
|
91
|
+
|
|
92
|
+
@include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
|
|
93
|
+
display: flex;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&-contains-image {
|
|
98
|
+
grid-template-rows: constants.$file-token-height auto;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.token-box {
|
|
103
|
+
@include mixins.token-box-styles();
|
|
104
|
+
|
|
105
|
+
&.horizontal {
|
|
106
|
+
max-inline-size: constants.$compact-token-width;
|
|
107
|
+
|
|
108
|
+
@include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
|
|
109
|
+
max-inline-size: 100%;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&.error {
|
|
114
|
+
border-color: awsui.$color-border-status-error;
|
|
115
|
+
@include token-box-validation;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&.warning {
|
|
119
|
+
border-color: awsui.$color-border-status-warning;
|
|
120
|
+
@include token-box-validation;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&.read-only {
|
|
124
|
+
border-color: awsui.$color-border-input-disabled;
|
|
125
|
+
background-color: awsui.$color-background-container-content;
|
|
126
|
+
pointer-events: none;
|
|
127
|
+
|
|
128
|
+
> .dismiss-button {
|
|
129
|
+
color: awsui.$color-text-button-inline-icon-disabled;
|
|
130
|
+
|
|
131
|
+
&:hover {
|
|
132
|
+
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
|
|
133
|
+
cursor: initial;
|
|
134
|
+
color: awsui.$color-text-button-inline-icon-disabled;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.loading {
|
|
140
|
+
border-color: awsui.$color-border-control-disabled;
|
|
141
|
+
background-color: awsui.$color-background-container-content;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
.root,
|
|
6
|
+
.file-option-thumbnail,
|
|
7
|
+
.file-option-name,
|
|
8
|
+
.file-option-size,
|
|
9
|
+
.file-option-last-modified,
|
|
10
|
+
.ellipsis-active {
|
|
11
|
+
/* used in test-utils */
|
|
12
|
+
}
|
|
@@ -5,18 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
@use '../../styles/tokens' as awsui;
|
|
7
7
|
@use '../../styles' as styles;
|
|
8
|
+
@use '../../../internal/components/file-token-group/constants' as constants;
|
|
8
9
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
9
10
|
|
|
10
11
|
.root {
|
|
11
|
-
display: flex;
|
|
12
12
|
gap: awsui.$space-scaled-xs;
|
|
13
13
|
|
|
14
14
|
&.horizontal {
|
|
15
|
+
display: flex;
|
|
15
16
|
gap: awsui.$space-xs;
|
|
16
17
|
flex-direction: row;
|
|
17
18
|
flex-wrap: wrap;
|
|
18
19
|
}
|
|
19
20
|
&.vertical {
|
|
21
|
+
display: flex;
|
|
20
22
|
flex-direction: column;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -41,6 +43,16 @@
|
|
|
41
43
|
&.vertical {
|
|
42
44
|
flex-direction: column;
|
|
43
45
|
}
|
|
46
|
+
&.grid {
|
|
47
|
+
display: grid;
|
|
48
|
+
gap: awsui.$space-xs;
|
|
49
|
+
grid-template-columns: repeat(auto-fill, constants.$compact-token-width);
|
|
50
|
+
|
|
51
|
+
@include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
.list-item {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
@use '../internal/styles' as styles;
|
|
6
|
+
@use '../internal/styles/tokens' as awsui;
|
|
7
|
+
@use './constants' as constants;
|
|
8
|
+
|
|
9
|
+
@mixin token-box-styles {
|
|
10
|
+
position: relative;
|
|
11
|
+
block-size: 100%;
|
|
12
|
+
border-block: awsui.$border-field-width solid constants.$token-border-color;
|
|
13
|
+
border-inline: awsui.$border-field-width solid constants.$token-border-color;
|
|
14
|
+
padding-block-start: styles.$control-padding-vertical;
|
|
15
|
+
padding-block-end: styles.$control-padding-vertical;
|
|
16
|
+
padding-inline-start: styles.$control-padding-horizontal;
|
|
17
|
+
padding-inline-end: awsui.$space-xxs;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: flex-start;
|
|
20
|
+
background: constants.$token-background;
|
|
21
|
+
border-start-start-radius: awsui.$border-radius-token;
|
|
22
|
+
border-start-end-radius: awsui.$border-radius-token;
|
|
23
|
+
border-end-start-radius: awsui.$border-radius-token;
|
|
24
|
+
border-end-end-radius: awsui.$border-radius-token;
|
|
25
|
+
color: awsui.$color-text-body-default;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@use '../internal/styles/tokens' as awsui;
|
|
8
8
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
9
9
|
@use './constants' as constants;
|
|
10
|
+
@use './mixins.scss' as mixins;
|
|
10
11
|
|
|
11
12
|
.root {
|
|
12
13
|
@include styles.styles-reset;
|
|
@@ -51,41 +52,9 @@
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
.token-box {
|
|
54
|
-
|
|
55
|
-
border-block: awsui.$border-field-width solid constants.$token-border-color;
|
|
56
|
-
border-inline: awsui.$border-field-width solid constants.$token-border-color;
|
|
57
|
-
padding-block-start: styles.$control-padding-vertical;
|
|
58
|
-
padding-block-end: styles.$control-padding-vertical;
|
|
59
|
-
padding-inline-start: styles.$control-padding-horizontal;
|
|
60
|
-
padding-inline-end: awsui.$space-xxs;
|
|
61
|
-
display: flex;
|
|
62
|
-
align-items: flex-start;
|
|
63
|
-
background: constants.$token-background;
|
|
64
|
-
border-start-start-radius: awsui.$border-radius-token;
|
|
65
|
-
border-start-end-radius: awsui.$border-radius-token;
|
|
66
|
-
border-end-start-radius: awsui.$border-radius-token;
|
|
67
|
-
border-end-end-radius: awsui.$border-radius-token;
|
|
68
|
-
color: awsui.$color-text-body-default;
|
|
69
|
-
box-sizing: border-box;
|
|
55
|
+
@include mixins.token-box-styles();
|
|
70
56
|
}
|
|
71
|
-
@mixin token-box-validation {
|
|
72
|
-
border-inline-start-width: awsui.$border-invalid-width;
|
|
73
57
|
|
|
74
|
-
> .dismiss-button {
|
|
75
|
-
color: awsui.$color-text-interactive-default;
|
|
76
|
-
&:hover {
|
|
77
|
-
color: awsui.$color-text-interactive-hover;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
.token-box-error {
|
|
82
|
-
border-color: awsui.$color-border-status-error;
|
|
83
|
-
@include token-box-validation;
|
|
84
|
-
}
|
|
85
|
-
.token-box-warning {
|
|
86
|
-
border-color: awsui.$color-border-status-warning;
|
|
87
|
-
@include token-box-validation;
|
|
88
|
-
}
|
|
89
58
|
.token-box-readonly {
|
|
90
59
|
border-color: awsui.$color-border-input-disabled;
|
|
91
60
|
background-color: awsui.$color-background-container-content;
|
|
@@ -61,6 +61,10 @@ export interface FileUploadProps extends BaseComponentProps, FormFieldCommonVali
|
|
|
61
61
|
* An array of file warnings corresponding to the files in the `value`.
|
|
62
62
|
*/
|
|
63
63
|
fileWarnings?: ReadonlyArray<null | string>;
|
|
64
|
+
/**
|
|
65
|
+
* Alignment of the file tokens. Defaults to "vertical".
|
|
66
|
+
*/
|
|
67
|
+
fileTokenAlignment?: FileUploadProps.FileTokenAlignment;
|
|
64
68
|
/**
|
|
65
69
|
* An object containing all the localized strings required by the component:
|
|
66
70
|
* * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.
|
|
@@ -83,6 +87,7 @@ export declare namespace FileUploadProps {
|
|
|
83
87
|
index: number;
|
|
84
88
|
file: File;
|
|
85
89
|
}
|
|
90
|
+
type FileTokenAlignment = 'vertical' | 'horizontal';
|
|
86
91
|
interface I18nStrings {
|
|
87
92
|
uploadButtonText: (multiple: boolean) => string;
|
|
88
93
|
dropzoneText: (multiple: boolean) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/file-upload/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qCAAqC,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,qCAAqC;IAChG;;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,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IA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;KACf;IAED,UAAiB,aAAa;QAC5B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,IAAI,CAAC;KACZ;IAED,KAAY,kBAAkB,GAAG,UAAU,GAAG,YAAY,CAAC;IAE3D,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,CAAC,EAAE,MAAM,CAAC;QAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/file-upload/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldCommonValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileUploadProps extends BaseComponentProps, FormFieldCommonValidationControlProps {\n /**\n * Specifies the native file input `accept` attribute to describe the allow-list of file types.\n */\n accept?: string;\n /**\n * Specifies whether to add aria-required to the file upload control.\n */\n ariaRequired?: boolean;\n /**\n * Show file size in the token. Use `i18nStrings.formatFileSize` to customize it.\n */\n showFileSize?: boolean;\n /**\n * Show file last modified timestamp in the token. Use `i18nStrings.formatFileLastModified` to customize it.\n */\n showFileLastModified?: boolean;\n /**\n * Show file thumbnail in the token. Only supported for images.\n */\n showFileThumbnail?: boolean;\n /**\n * Specifies the native file input `multiple` attribute to allow users entering more than one file.\n */\n multiple?: boolean;\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange?: NonCancelableEventHandler<FileUploadProps.ChangeDetail>;\n /**\n * Specifies the currently selected file(s).\n * If you want to clear the selection, use empty array.\n */\n value: ReadonlyArray<File>;\n /**\n * Specifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Constraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.\n */\n constraintText?: React.ReactNode;\n /**\n * Text that displays as a validation error message.\n */\n errorText?: React.ReactNode;\n /**\n * Text that displays as a validation warning message.\n */\n warningText?: React.ReactNode;\n /**\n * An array of file errors corresponding to the files in the `value`.\n */\n fileErrors?: ReadonlyArray<null | string>;\n /**\n * An array of file warnings corresponding to the files in the `value`.\n */\n fileWarnings?: ReadonlyArray<null | string>;\n /**\n * An object containing all the localized strings required by the component:\n * * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.\n * * `dropzoneText` (function): A function to render the text shown in the dropzone. It takes `multiple` attribute to define plurality.\n * * `removeFileAriaLabel` (function): A function to render the ARIA label for file token remove button.\n * * `limitShowFewer` (string): The text of the show more tokens button.\n * * `limitShowMore` (string): The text of the show fewer tokens button.\n * * `errorIconAriaLabel` (string): The ARIA label to be shown on the error file icon.\n * * `warningIconAriaLabel` (string): The ARIA label to be shown on the warning file icon.\n * * `formatFileSize` (function): (Optional) A function that takes file size in bytes, and produces a formatted string.\n * * `formatFileLastModified` (function): (Optional) A function that takes the files last modified date, and produces a formatted string.\n */\n i18nStrings: FileUploadProps.I18nStrings;\n}\n\nexport namespace FileUploadProps {\n export interface ChangeDetail {\n value: File[];\n }\n\n export interface DismissDetail {\n index: number;\n file: File;\n }\n\n export interface I18nStrings {\n uploadButtonText: (multiple: boolean) => string;\n dropzoneText: (multiple: boolean) => string;\n removeFileAriaLabel: (fileIndex: number) => string;\n limitShowFewer: string;\n limitShowMore: string;\n errorIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n formatFileSize?: (sizeInBytes: number) => string;\n formatFileLastModified?: (date: Date) => string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the file upload button.\n */\n focus(): void;\n }\n}\n\nexport interface FileMetadata {\n showFileSize?: boolean;\n showFileLastModified?: boolean;\n showFileThumbnail?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/file-upload/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldCommonValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileUploadProps extends BaseComponentProps, FormFieldCommonValidationControlProps {\n /**\n * Specifies the native file input `accept` attribute to describe the allow-list of file types.\n */\n accept?: string;\n /**\n * Specifies whether to add aria-required to the file upload control.\n */\n ariaRequired?: boolean;\n /**\n * Show file size in the token. Use `i18nStrings.formatFileSize` to customize it.\n */\n showFileSize?: boolean;\n /**\n * Show file last modified timestamp in the token. Use `i18nStrings.formatFileLastModified` to customize it.\n */\n showFileLastModified?: boolean;\n /**\n * Show file thumbnail in the token. Only supported for images.\n */\n showFileThumbnail?: boolean;\n /**\n * Specifies the native file input `multiple` attribute to allow users entering more than one file.\n */\n multiple?: boolean;\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange?: NonCancelableEventHandler<FileUploadProps.ChangeDetail>;\n /**\n * Specifies the currently selected file(s).\n * If you want to clear the selection, use empty array.\n */\n value: ReadonlyArray<File>;\n /**\n * Specifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.\n */\n tokenLimit?: number;\n /**\n * Constraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.\n */\n constraintText?: React.ReactNode;\n /**\n * Text that displays as a validation error message.\n */\n errorText?: React.ReactNode;\n /**\n * Text that displays as a validation warning message.\n */\n warningText?: React.ReactNode;\n /**\n * An array of file errors corresponding to the files in the `value`.\n */\n fileErrors?: ReadonlyArray<null | string>;\n /**\n * An array of file warnings corresponding to the files in the `value`.\n */\n fileWarnings?: ReadonlyArray<null | string>;\n /**\n * Alignment of the file tokens. Defaults to \"vertical\".\n */\n fileTokenAlignment?: FileUploadProps.FileTokenAlignment;\n /**\n * An object containing all the localized strings required by the component:\n * * `uploadButtonText` (function): A function to render the text of the file upload button. It takes `multiple` attribute to define plurality.\n * * `dropzoneText` (function): A function to render the text shown in the dropzone. It takes `multiple` attribute to define plurality.\n * * `removeFileAriaLabel` (function): A function to render the ARIA label for file token remove button.\n * * `limitShowFewer` (string): The text of the show more tokens button.\n * * `limitShowMore` (string): The text of the show fewer tokens button.\n * * `errorIconAriaLabel` (string): The ARIA label to be shown on the error file icon.\n * * `warningIconAriaLabel` (string): The ARIA label to be shown on the warning file icon.\n * * `formatFileSize` (function): (Optional) A function that takes file size in bytes, and produces a formatted string.\n * * `formatFileLastModified` (function): (Optional) A function that takes the files last modified date, and produces a formatted string.\n */\n i18nStrings: FileUploadProps.I18nStrings;\n}\n\nexport namespace FileUploadProps {\n export interface ChangeDetail {\n value: File[];\n }\n\n export interface DismissDetail {\n index: number;\n file: File;\n }\n\n export type FileTokenAlignment = 'vertical' | 'horizontal';\n\n export interface I18nStrings {\n uploadButtonText: (multiple: boolean) => string;\n dropzoneText: (multiple: boolean) => string;\n removeFileAriaLabel: (fileIndex: number) => string;\n limitShowFewer: string;\n limitShowMore: string;\n errorIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n formatFileSize?: (sizeInBytes: number) => string;\n formatFileLastModified?: (date: Date) => string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the file upload button.\n */\n focus(): void;\n }\n}\n\nexport interface FileMetadata {\n showFileSize?: boolean;\n showFileLastModified?: boolean;\n showFileThumbnail?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;;AAQ/C,wBAAoD"}
|
|
@@ -10,7 +10,7 @@ import { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/
|
|
|
10
10
|
import { getBaseProps } from '../internal/base-component';
|
|
11
11
|
import InternalFileDropzone, { useFilesDragging } from '../internal/components/file-dropzone';
|
|
12
12
|
import InternalFileInput from '../internal/components/file-input';
|
|
13
|
-
import
|
|
13
|
+
import InternalFileTokenGroup from '../internal/components/file-token-group';
|
|
14
14
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
15
15
|
import checkControlled from '../internal/hooks/check-controlled';
|
|
16
16
|
import { useListFocusController } from '../internal/hooks/use-list-focus-controller';
|
|
@@ -18,15 +18,13 @@ import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
|
18
18
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
19
19
|
import { joinStrings } from '../internal/utils/strings';
|
|
20
20
|
import InternalSpaceBetween from '../space-between/internal';
|
|
21
|
-
import { Token } from '../token-group/token';
|
|
22
|
-
import { FileOption } from './file-option';
|
|
23
21
|
import fileInputStyles from '../internal/components/file-input/styles.css.js';
|
|
24
22
|
import tokenListStyles from '../internal/components/token-list/styles.css.js';
|
|
25
23
|
import styles from './styles.css.js';
|
|
26
24
|
export default React.forwardRef(InternalFileUpload);
|
|
27
25
|
function InternalFileUpload(_a, externalRef) {
|
|
28
26
|
var _b;
|
|
29
|
-
var { accept, ariaRequired, multiple = false, onChange, value, tokenLimit, showFileSize, showFileLastModified, showFileThumbnail, i18nStrings, __internalRootRef = null, constraintText, errorText, warningText, fileErrors, fileWarnings } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "multiple", "onChange", "value", "tokenLimit", "showFileSize", "showFileLastModified", "showFileThumbnail", "i18nStrings", "__internalRootRef", "constraintText", "errorText", "warningText", "fileErrors", "fileWarnings"]);
|
|
27
|
+
var { accept, ariaRequired, multiple = false, onChange, value, tokenLimit, showFileSize, showFileLastModified, showFileThumbnail, i18nStrings, __internalRootRef = null, constraintText, errorText, warningText, fileErrors, fileWarnings, fileTokenAlignment = 'vertical' } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "multiple", "onChange", "value", "tokenLimit", "showFileSize", "showFileLastModified", "showFileThumbnail", "i18nStrings", "__internalRootRef", "constraintText", "errorText", "warningText", "fileErrors", "fileWarnings", "fileTokenAlignment"]);
|
|
30
28
|
const [nextFocusIndex, setNextFocusIndex] = useState(null);
|
|
31
29
|
const tokenListRef = useListFocusController({
|
|
32
30
|
nextFocusIndex,
|
|
@@ -74,14 +72,10 @@ function InternalFileUpload(_a, externalRef) {
|
|
|
74
72
|
errorText && (React.createElement(FormFieldError, { id: errorId, errorIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel }, errorText)),
|
|
75
73
|
showWarning && (React.createElement(FormFieldWarning, { id: warningId, warningIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.warningIconAriaLabel }, warningText)),
|
|
76
74
|
constraintText && (React.createElement(ConstraintText, { id: constraintTextId, hasValidationText: !!errorText || !!warningText }, constraintText))))),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
React.createElement(FileOption, { file: file, metadata: metadata, i18nStrings: i18nStrings }))), limit: tokenLimit, i18nStrings: {
|
|
83
|
-
limitShowFewer: i18nStrings.limitShowFewer,
|
|
84
|
-
limitShowMore: i18nStrings.limitShowMore,
|
|
85
|
-
} }))) : null));
|
|
75
|
+
value.length > 0 ? (React.createElement(InternalFileTokenGroup, { limit: tokenLimit, alignment: fileTokenAlignment, items: value.map((file, fileIndex) => ({
|
|
76
|
+
file,
|
|
77
|
+
errorText: fileErrors === null || fileErrors === void 0 ? void 0 : fileErrors[fileIndex],
|
|
78
|
+
warningText: fileWarnings === null || fileWarnings === void 0 ? void 0 : fileWarnings[fileIndex],
|
|
79
|
+
})), showFileLastModified: metadata.showFileLastModified, showFileSize: metadata.showFileSize, showFileThumbnail: metadata.showFileThumbnail, i18nStrings: i18nStrings, onDismiss: event => onFileRemove(event.detail.fileIndex) })) : null));
|
|
86
80
|
}
|
|
87
81
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CA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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,WAAW,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,SAAS,CAAC,EACtC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,EAClD,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,gBAC1C,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,GACD,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 clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalFileDropzone, { useFilesDragging } from '../internal/components/file-dropzone';\nimport InternalFileInput from '../internal/components/file-input';\nimport TokenList from '../internal/components/token-list';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { Token } from '../token-group/token';\nimport { FileOption } from './file-option';\nimport { FileUploadProps } from './interfaces';\n\nimport fileInputStyles from '../internal/components/file-input/styles.css.js';\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['file-input']}`,\n });\n\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const { areFilesDragging } = useFilesDragging();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {areFilesDragging ? (\n <InternalFileDropzone onChange={event => handleFilesChange(event.detail.value)}>\n {i18nStrings.dropzoneText(multiple)}\n </InternalFileDropzone>\n ) : (\n <InternalFileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={event => handleFilesChange(event.detail.value)}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </InternalFileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={warningId} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!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 warningText={fileWarnings?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\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 warningText={fileWarnings?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\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 />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,WAAW,MAAM,iBAAiB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AAoB,IACrF,WAAW,CACK,CACpB;gBACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,IAClF,cAAc,CACA,CAClB,CACG,CACP,CACW;QAEb,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAClB,oBAAC,sBAAsB,IACrB,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,kBAAkB,EAC7B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;gBACrC,IAAI;gBACJ,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC;gBAClC,WAAW,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,SAAS,CAAC;aACvC,CAAC,CAAC,EACH,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,EACnD,YAAY,EAAE,QAAQ,CAAC,YAAY,EACnC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,EAC7C,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GACxD,CACH,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalFileDropzone, { useFilesDragging } from '../internal/components/file-dropzone';\nimport InternalFileInput from '../internal/components/file-input';\nimport InternalFileTokenGroup from '../internal/components/file-token-group';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { FileUploadProps } from './interfaces';\n\nimport fileInputStyles from '../internal/components/file-input/styles.css.js';\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n fileTokenAlignment = 'vertical',\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['file-input']}`,\n });\n\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const { areFilesDragging } = useFilesDragging();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {areFilesDragging ? (\n <InternalFileDropzone onChange={event => handleFilesChange(event.detail.value)}>\n {i18nStrings.dropzoneText(multiple)}\n </InternalFileDropzone>\n ) : (\n <InternalFileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={event => handleFilesChange(event.detail.value)}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </InternalFileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={warningId} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {value.length > 0 ? (\n <InternalFileTokenGroup\n limit={tokenLimit}\n alignment={fileTokenAlignment}\n items={value.map((file, fileIndex) => ({\n file,\n errorText: fileErrors?.[fileIndex],\n warningText: fileWarnings?.[fileIndex],\n }))}\n showFileLastModified={metadata.showFileLastModified}\n showFileSize={metadata.showFileSize}\n showFileThumbnail={metadata.showFileThumbnail}\n i18nStrings={i18nStrings}\n onDismiss={event => onFileRemove(event.detail.fileIndex)}\n />\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
|
package/lib/internal/template/internal/components/file-token-group/default-formatters.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-formatters.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-token-group/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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { formatDateTime } from '
|
|
3
|
+
import { formatDateTime } from '../../utils/date-time';
|
|
4
4
|
const KB = 1000;
|
|
5
5
|
const MB = Math.pow(1000, 2);
|
|
6
6
|
const GB = Math.pow(1000, 3);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-formatters.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-token-group/default-formatters.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,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 '../../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,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TokenGroupProps } from '../../../token-group/interfaces.js';
|
|
3
|
+
import { BaseComponentProps } from '../../base-component/index.js';
|
|
4
|
+
export declare namespace FileTokenProps {
|
|
5
|
+
interface I18nStrings {
|
|
6
|
+
removeFileAriaLabel: (fileIndex: number) => string;
|
|
7
|
+
errorIconAriaLabel?: string;
|
|
8
|
+
warningIconAriaLabel?: string;
|
|
9
|
+
formatFileSize?: (sizeInBytes: number) => string;
|
|
10
|
+
formatFileLastModified?: (date: Date) => string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface FileTokenProps extends BaseComponentProps {
|
|
14
|
+
file: File;
|
|
15
|
+
onDismiss: () => void;
|
|
16
|
+
showFileSize?: boolean;
|
|
17
|
+
showFileLastModified?: boolean;
|
|
18
|
+
showFileThumbnail?: boolean;
|
|
19
|
+
errorText?: React.ReactNode;
|
|
20
|
+
warningText?: React.ReactNode;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
i18nStrings: FileTokenProps.I18nStrings;
|
|
24
|
+
dismissLabel?: string;
|
|
25
|
+
alignment?: TokenGroupProps.Alignment;
|
|
26
|
+
groupContainsImage?: boolean;
|
|
27
|
+
isImage: boolean;
|
|
28
|
+
index: number;
|
|
29
|
+
}
|
|
30
|
+
declare function InternalFileToken({ file, showFileLastModified, showFileSize, showFileThumbnail, i18nStrings, onDismiss, errorText, warningText, readOnly, loading, alignment, groupContainsImage, isImage, index, }: FileTokenProps): JSX.Element;
|
|
31
|
+
export default InternalFileToken;
|
|
32
|
+
//# sourceMappingURL=file-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-token.d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ACZ,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,OAAO,EACP,KAAK,GACN,EAAE,cAAc,eA+HhB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import InternalBox from '../../../box/internal.js';
|
|
6
|
+
import { FormFieldError, FormFieldWarning } from '../../../form-field/internal';
|
|
7
|
+
import InternalSpaceBetween from '../../../space-between/internal.js';
|
|
8
|
+
import InternalSpinner from '../../../spinner/internal.js';
|
|
9
|
+
import DismissButton from '../../../token-group/dismiss-button';
|
|
10
|
+
import { useUniqueId } from '../../hooks/use-unique-id';
|
|
11
|
+
import Tooltip from '../tooltip/index';
|
|
12
|
+
import * as defaultFormatters from './default-formatters.js';
|
|
13
|
+
import { FileOptionThumbnail } from './thumbnail.js';
|
|
14
|
+
import styles from './styles.css.js';
|
|
15
|
+
import testUtilStyles from './test-classes/styles.css.js';
|
|
16
|
+
function InternalFileToken({ file, showFileLastModified, showFileSize, showFileThumbnail, i18nStrings, onDismiss, errorText, warningText, readOnly, loading, alignment, groupContainsImage, isImage, index, }) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const formatFileSize = (_a = i18nStrings.formatFileSize) !== null && _a !== void 0 ? _a : defaultFormatters.formatFileSize;
|
|
19
|
+
const formatFileLastModified = (_b = i18nStrings.formatFileLastModified) !== null && _b !== void 0 ? _b : defaultFormatters.formatFileLastModified;
|
|
20
|
+
const errorId = useUniqueId('error');
|
|
21
|
+
const warningId = useUniqueId('warning');
|
|
22
|
+
const showWarning = warningText && !errorText;
|
|
23
|
+
const containerRef = useRef(null);
|
|
24
|
+
const fileNameRef = useRef(null);
|
|
25
|
+
const fileNameContainerRef = useRef(null);
|
|
26
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
27
|
+
function isEllipsisActive() {
|
|
28
|
+
const span = fileNameRef.current;
|
|
29
|
+
const container = fileNameContainerRef.current;
|
|
30
|
+
if (span && container) {
|
|
31
|
+
return span.offsetWidth >= container.offsetWidth;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const fileIsSingleRow = !showFileLastModified && !showFileSize && (!groupContainsImage || (groupContainsImage && !showFileThumbnail));
|
|
36
|
+
return (React.createElement("div", { ref: containerRef, className: clsx(styles.token, {
|
|
37
|
+
[styles['token-grid']]: alignment === 'horizontal',
|
|
38
|
+
[styles['token-contains-image']]: groupContainsImage,
|
|
39
|
+
}), role: "group", "aria-label": file.name, "aria-describedby": errorText ? errorId : warningText ? warningId : undefined, "aria-disabled": loading, "data-index": index },
|
|
40
|
+
React.createElement("div", { className: clsx(styles['token-box'], {
|
|
41
|
+
[styles.loading]: loading,
|
|
42
|
+
[styles.error]: errorText,
|
|
43
|
+
[styles.warning]: showWarning,
|
|
44
|
+
[styles.horizontal]: alignment === 'horizontal',
|
|
45
|
+
[styles['read-only']]: readOnly,
|
|
46
|
+
}) },
|
|
47
|
+
loading && (React.createElement("div", { className: clsx(styles['file-loading-overlay'], {
|
|
48
|
+
[styles['file-loading-overlay-single-row']]: loading && fileIsSingleRow,
|
|
49
|
+
}) },
|
|
50
|
+
React.createElement(InternalSpinner, { variant: "disabled", size: "normal" }))),
|
|
51
|
+
React.createElement(InternalBox, { className: styles['file-option'] },
|
|
52
|
+
showFileThumbnail && isImage && React.createElement(FileOptionThumbnail, { file: file }),
|
|
53
|
+
React.createElement("div", { className: clsx(styles['file-option-metadata'], {
|
|
54
|
+
[styles['with-image']]: showFileThumbnail && isImage,
|
|
55
|
+
[styles['single-row-loading']]: loading && fileIsSingleRow,
|
|
56
|
+
}) },
|
|
57
|
+
React.createElement(InternalSpaceBetween, { direction: "vertical", size: "xxxs" },
|
|
58
|
+
React.createElement("div", { onMouseOver: () => setShowTooltip(true), onMouseOut: () => setShowTooltip(false), ref: fileNameContainerRef },
|
|
59
|
+
React.createElement(InternalBox, { fontWeight: "normal", className: clsx(styles['file-option-name'], testUtilStyles['file-option-name'], {
|
|
60
|
+
[testUtilStyles['ellipsis-active']]: isEllipsisActive(),
|
|
61
|
+
}) },
|
|
62
|
+
React.createElement("span", { ref: fileNameRef }, file.name))),
|
|
63
|
+
showFileSize && file.size ? (React.createElement(InternalBox, { fontSize: "body-s", color: 'text-body-secondary', className: clsx(styles['file-option-size'], testUtilStyles['file-option-size']) }, formatFileSize(file.size))) : null,
|
|
64
|
+
showFileLastModified && file.lastModified ? (React.createElement(InternalBox, { fontSize: "body-s", color: 'text-body-secondary', className: clsx(styles['file-option-last-modified'], testUtilStyles['file-option-last-modified']) }, formatFileLastModified(new Date(file.lastModified)))) : null))),
|
|
65
|
+
onDismiss && !readOnly && (React.createElement(DismissButton, { dismissLabel: i18nStrings.removeFileAriaLabel(index), onDismiss: onDismiss }))),
|
|
66
|
+
errorText && (React.createElement(FormFieldError, { id: errorId, errorIconAriaLabel: i18nStrings.errorIconAriaLabel }, errorText)),
|
|
67
|
+
showWarning && (React.createElement(FormFieldWarning, { id: warningId, warningIconAriaLabel: i18nStrings.warningIconAriaLabel }, warningText)),
|
|
68
|
+
showTooltip && isEllipsisActive() && (React.createElement(Tooltip, { trackRef: containerRef, trackKey: file.name, value: React.createElement(InternalBox, { fontWeight: "normal" }, file.name) }))));
|
|
69
|
+
}
|
|
70
|
+
export default InternalFileToken;
|
|
71
|
+
//# sourceMappingURL=file-token.js.map
|