@transferwise/components 0.0.0-experimental-7f34f59 → 0.0.0-experimental-d1c5355

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 (39) hide show
  1. package/build/i18n/tr.json +1 -1
  2. package/build/i18n/tr.json.js +1 -1
  3. package/build/i18n/tr.json.mjs +1 -1
  4. package/build/main.css +162 -215
  5. package/build/styles/main.css +162 -215
  6. package/build/styles/uploadInput/UploadInput.css +33 -84
  7. package/build/styles/uploadInput/uploadButton/UploadButton.css +62 -31
  8. package/build/styles/uploadInput/uploadItem/UploadItem.css +76 -109
  9. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  10. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  11. package/build/uploadInput/UploadInput.js +24 -16
  12. package/build/uploadInput/UploadInput.js.map +1 -1
  13. package/build/uploadInput/UploadInput.mjs +24 -16
  14. package/build/uploadInput/UploadInput.mjs.map +1 -1
  15. package/build/uploadInput/uploadButton/UploadButton.js +23 -31
  16. package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
  17. package/build/uploadInput/uploadButton/UploadButton.mjs +23 -31
  18. package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
  19. package/build/uploadInput/uploadItem/UploadItem.js +31 -38
  20. package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
  21. package/build/uploadInput/uploadItem/UploadItem.mjs +32 -39
  22. package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
  23. package/build/uploadInput/uploadItem/UploadItemLink.js +2 -1
  24. package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -1
  25. package/build/uploadInput/uploadItem/UploadItemLink.mjs +2 -1
  26. package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -1
  27. package/package.json +3 -3
  28. package/src/i18n/tr.json +1 -1
  29. package/src/main.css +162 -215
  30. package/src/uploadInput/UploadInput.css +33 -84
  31. package/src/uploadInput/UploadInput.less +25 -75
  32. package/src/uploadInput/UploadInput.tsx +32 -28
  33. package/src/uploadInput/uploadButton/UploadButton.css +62 -31
  34. package/src/uploadInput/uploadButton/UploadButton.less +61 -38
  35. package/src/uploadInput/uploadButton/UploadButton.tsx +22 -25
  36. package/src/uploadInput/uploadItem/UploadItem.css +76 -109
  37. package/src/uploadInput/uploadItem/UploadItem.less +77 -127
  38. package/src/uploadInput/uploadItem/UploadItem.tsx +28 -28
  39. package/src/uploadInput/uploadItem/UploadItemLink.tsx +3 -3
@@ -1,86 +1,35 @@
1
- .np-upload-input.form-control {
2
- height: auto;
3
- padding: 0;
4
- padding: initial;
5
- }
6
- .np-upload-input > div:first-child,
7
- .np-upload-input > div:first-child .np-upload-item--single-file,
8
- .np-upload-input > div:first-child .np-upload-item--link {
9
- border-top-left-radius: 10px;
10
- border-top-left-radius: var(--radius-small);
11
- border-top-right-radius: 10px;
12
- border-top-right-radius: var(--radius-small);
13
- }
14
- .np-upload-input > div:last-child {
15
- border-bottom-left-radius: 10px;
16
- border-bottom-left-radius: var(--radius-small);
17
- border-bottom-right-radius: 10px;
18
- border-bottom-right-radius: var(--radius-small);
19
- }
20
- .np-theme-personal .np-upload-input.disabled .btn {
21
- cursor: inherit;
22
- }
23
- .np-theme-personal .np-upload-input .np-upload-icon {
24
- color: var(--color-interactive-primary);
25
- }
26
- .np-theme-personal .np-upload-input .media-body {
27
- padding-right: 32px;
28
- padding-right: var(--size-32);
29
- color: var(--color-content-link);
30
- white-space: break-spaces;
31
- }
32
- @media (max-width: 320px) {
33
- .np-theme-personal .np-upload-input .media-body {
34
- padding-right: 64px;
35
- padding-right: var(--size-64);
36
- }
37
- }
38
- .np-theme-personal .np-upload-input .media-body .np-text-body-large-bold {
39
- -webkit-text-decoration: underline;
40
- text-decoration: underline;
41
- text-underline-offset: 0.3em;
42
- }
43
- .np-theme-personal .np-upload-input .media-body .np-text-body-default,
44
- .np-theme-personal .np-upload-input .media-body .np-upload-description,
45
- .np-theme-personal .np-upload-input .media-body .text-positive {
46
- color: #5d7079 !important;
47
- color: var(--color-content-secondary) !important;
48
- }
49
- .np-theme-personal .np-upload-input .media-body .text-negative {
50
- color: var(--color-sentiment-negative) !important;
51
- }
52
- .np-theme-personal .np-upload-input-errors {
53
- list-style: none;
54
- padding-left: 0;
55
- }
56
- .np-theme-personal .np-upload-input-errors li {
57
- position: relative;
58
- padding-left: 16px;
59
- padding-left: var(--size-16);
60
- }
61
- @media (max-width: 320px) {
62
- .np-theme-personal .np-upload-input-errors li {
63
- padding-left: 32px;
64
- padding-left: var(--size-32);
65
- }
66
- }
67
- .np-theme-personal .np-upload-input-errors li:before {
68
- content: '•';
69
- position: absolute;
70
- display: block;
1
+ .np-upload-input {
2
+ box-shadow: inset 0px 0px 1px 1px #c9cbce;
3
+ box-shadow: inset 0px 0px 1px 1px var(--color-interactive-secondary);
4
+ border-radius: 10px;
5
+ border-radius: var(--radius-small);
6
+ }
7
+ .np-upload-input .np-upload-input__items {
8
+ overflow: hidden;
9
+ border-radius: 10px;
10
+ border-radius: var(--radius-small);
11
+ }
12
+ .np-upload-input .np-upload-input__items:first-child:not(:empty),
13
+ .np-upload-input .np-upload-input__items:first-child:not(:empty) .np-upload-input__item:first-child {
14
+ border-radius: 10px 10px 0 0;
15
+ border-radius: var(--radius-small) var(--radius-small) 0 0;
16
+ }
17
+ .np-upload-input .np-upload-input__items:first-child:not(:empty) + .np-upload-input__items:last-child,
18
+ .np-upload-input .np-upload-input__items:first-child:not(:empty) .np-upload-input__item:first-child + .np-upload-input__items:last-child,
19
+ .np-upload-input .np-upload-input__items:first-child:not(:empty) + .np-upload-input__items:last-child .np-upload-input__upload-button,
20
+ .np-upload-input .np-upload-input__items:first-child:not(:empty) .np-upload-input__item:first-child + .np-upload-input__items:last-child .np-upload-input__upload-button {
21
+ border-radius: 0 0 10px 10px;
22
+ border-radius: 0 0 var(--radius-small) var(--radius-small);
23
+ }
24
+ .np-upload-input .np-upload-input__items,
25
+ .np-upload-input .np-upload-input__file-upload {
26
+ margin: 0;
27
+ }
28
+ .np-upload-input .np-upload-input__items:empty ~ .np-upload-input__items .np-upload-input__upload-button::before {
29
+ display: none;
30
+ }
31
+ .np-upload-input .np-upload-input__items:has(.np-upload-input__item:last-child.is-interactive:hover) ~ .np-upload-input__items .np-upload-input__upload-button::before {
71
32
  left: 0;
72
- }
73
- .np-theme-personal .np-upload-input .status-circle {
74
- width: 24px;
75
- width: var(--size-x-small);
76
- height: 24px;
77
- height: var(--size-x-small);
78
- }
79
- @media (max-width: 320px) {
80
- .np-theme-personal .np-upload-input .status-circle {
81
- width: 48px;
82
- width: var(--size-large);
83
- height: 48px;
84
- height: var(--size-large);
85
- }
33
+ width: 100%;
34
+ top: 0px;
86
35
  }
@@ -3,90 +3,40 @@
3
3
  @import (reference) './uploadItem/UploadItem.less';
4
4
 
5
5
  .np-upload-input {
6
- &.form-control {
7
- height: auto;
8
- padding: initial;
9
- }
10
-
11
- & > div {
12
- &:first-child,
13
- &:first-child .np-upload-item--single-file,
14
- &:first-child .np-upload-item--link {
15
- border-top-left-radius: var(--radius-small);
16
- border-top-right-radius: var(--radius-small);
17
- }
18
-
19
- &:last-child {
20
- border-bottom-left-radius: var(--radius-small);
21
- border-bottom-right-radius: var(--radius-small);
22
- }
23
- }
24
- }
25
-
26
- .np-theme-personal {
27
- .np-upload-input {
28
- &.disabled .btn {
29
- cursor: inherit;
30
- }
6
+ box-shadow: inset 0px 0px 1px 1px var(--color-interactive-secondary);
7
+ border-radius: var(--radius-small);
31
8
 
32
- .np-upload-icon {
33
- color: var(--color-interactive-primary);
34
- }
35
-
36
- .media-body {
37
- padding-right: var(--size-32);
38
- color: var(--color-content-link);
39
- white-space: break-spaces;
9
+ .np-upload-input__items {
10
+ overflow: hidden;
11
+ border-radius: var(--radius-small);
40
12
 
41
- @media (--screen-400-zoom) {
42
- padding-right: var(--size-64);
43
- }
13
+ &:first-child:not(:empty),
14
+ &:first-child:not(:empty) .np-upload-input__item:first-child {
15
+ border-radius: var(--radius-small) var(--radius-small) 0 0;
44
16
 
45
- .np-text-body-large-bold {
46
- text-decoration: underline;
47
- .link-underline();
48
- }
49
-
50
- .np-text-body-default,
51
- .np-upload-description,
52
- .text-positive {
53
- color: var(--color-content-secondary) !important;
54
- }
55
-
56
- .text-negative {
57
- color: var(--color-sentiment-negative) !important;
17
+ & + .np-upload-input__items:last-child,
18
+ & + .np-upload-input__items:last-child .np-upload-input__upload-button {
19
+ border-radius: 0 0 var(--radius-small) var(--radius-small);
58
20
  }
59
21
  }
22
+ }
60
23
 
61
- &-errors {
62
- list-style: none;
63
- padding-left: 0;
64
-
65
- li {
66
- position: relative;
67
- padding-left: var(--size-16);
68
-
69
- @media (--screen-400-zoom) {
70
- padding-left: var(--size-32);
71
- }
24
+ .np-upload-input__items,
25
+ .np-upload-input__file-upload {
26
+ margin: 0;
27
+ }
72
28
 
73
- &:before {
74
- content: '•';
75
- position: absolute;
76
- display: block;
77
- left: 0;
78
- }
79
- }
29
+ .np-upload-input__items {
30
+ &:empty ~ .np-upload-input__items .np-upload-input__upload-button::before {
31
+ display: none;
80
32
  }
81
33
 
82
- .status-circle {
83
- width: var(--size-x-small);
84
- height: var(--size-x-small);
85
-
86
- @media (--screen-400-zoom) {
87
- width: var(--size-large);
88
- height: var(--size-large);
89
- }
34
+ &:has(.np-upload-input__item:last-child.is-interactive:hover)
35
+ ~ .np-upload-input__items
36
+ .np-upload-input__upload-button::before {
37
+ left: 0;
38
+ width: 100%;
39
+ top: 0px;
90
40
  }
91
41
  }
92
42
  }
@@ -307,35 +307,39 @@ const UploadInput = ({
307
307
  className={clsx('np-upload-input', className, { disabled })}
308
308
  {...inputAttributes}
309
309
  >
310
- {uploadedFiles.map((file) => (
311
- <UploadItem
312
- key={file.id}
313
- file={file}
314
- singleFileUpload={!multiple}
315
- canDelete={
316
- (!!onDeleteFile || file.status === Status.FAILED) &&
317
- (!file.status || !PROGRESS_STATUSES.has(file.status))
318
- }
319
- onDelete={
320
- file.status === Status.FAILED
321
- ? () => removeFile(file)
322
- : () => setMarkedFileForDelete(file)
323
- }
324
- onDownload={onDownload}
325
- />
326
- ))}
310
+ <div className={clsx('np-upload-input__items')} aria-live="polite" role="region">
311
+ {uploadedFiles.map((file) => (
312
+ <UploadItem
313
+ key={file.id}
314
+ file={file}
315
+ singleFileUpload={!multiple}
316
+ canDelete={
317
+ (!!onDeleteFile || file.status === Status.FAILED) &&
318
+ (!file.status || !PROGRESS_STATUSES.has(file.status))
319
+ }
320
+ onDelete={
321
+ file.status === Status.FAILED
322
+ ? () => removeFile(file)
323
+ : () => setMarkedFileForDelete(file)
324
+ }
325
+ onDownload={onDownload}
326
+ />
327
+ ))}
328
+ </div>
327
329
  {(multiple || (!multiple && !uploadedFiles.length)) && (
328
- <UploadButton
329
- id={id}
330
- uploadButtonTitle={uploadButtonTitle}
331
- disabled={areMaximumFilesUploadedAlready() || disabled}
332
- multiple={multiple}
333
- fileTypes={fileTypes}
334
- sizeLimit={sizeLimit}
335
- description={description}
336
- maxFiles={maxFiles}
337
- onChange={addFiles}
338
- />
330
+ <div className="np-upload-input__items">
331
+ <UploadButton
332
+ id={id}
333
+ uploadButtonTitle={uploadButtonTitle}
334
+ disabled={areMaximumFilesUploadedAlready() || disabled}
335
+ multiple={multiple}
336
+ fileTypes={fileTypes}
337
+ sizeLimit={sizeLimit}
338
+ description={description}
339
+ maxFiles={maxFiles}
340
+ onChange={addFiles}
341
+ />
342
+ </div>
339
343
  )}
340
344
  </div>
341
345
  <Modal
@@ -1,44 +1,75 @@
1
- .np-upload-button-container {
2
- border-style: solid;
3
- }
4
- .np-upload-button-container .droppable-card-content {
1
+ .np-upload-input__upload-button {
2
+ position: relative;
3
+ padding: 16px;
4
+ padding: var(--size-16);
5
5
  display: flex;
6
+ align-items: center;
7
+ margin: 0;
8
+ border-radius: inherit;
6
9
  }
7
- .np-upload-button-container.droppable-dropping {
8
- border-color: #c9cbce !important;
9
- border-color: var(--color-interactive-secondary) !important;
10
+ .np-upload-input__upload-button .np-upload-input__title {
11
+ color: var(--color-content-link);
12
+ -webkit-text-decoration: underline;
13
+ text-decoration: underline;
14
+ text-underline-offset: 0.3em;
10
15
  }
11
- .np-upload-button-container.droppable-dropping:before {
12
- z-index: 2;
16
+ .np-upload-input__upload-button .np-upload-input__title + .np-upload-input__text {
17
+ margin-top: 4px;
18
+ margin-top: var(--size-4);
19
+ line-height: 22px;
13
20
  }
14
- .np-upload-button-container input[type="file"] {
15
- opacity: 0;
16
- z-index: -1;
21
+ .np-upload-input__upload-button .np-upload-input__icon {
22
+ padding-right: 16px;
23
+ padding-right: var(--size-16);
24
+ color: var(--color-interactive-primary);
25
+ }
26
+ .np-upload-input__upload-button::before {
27
+ display: block;
17
28
  position: absolute;
29
+ height: 1px;
30
+ background-color: rgba(0,0,0,0.10196);
31
+ background-color: var(--color-border-neutral);
32
+ content: " ";
33
+ left: 16px;
34
+ left: var(--size-16);
35
+ width: calc(100% - 2 * 16px);
36
+ width: calc(100% - 2 * var(--size-16));
37
+ top: 0;
38
+ }
39
+ .np-upload-input__upload-button.is-dropping .np-upload-input__icon,
40
+ .np-upload-input__upload-button.is-dropping .np-upload-input__item-content {
41
+ display: none;
18
42
  }
19
- .np-upload-button-container .np-upload-button {
20
- border: none;
43
+ .np-upload-input__upload-button.is-dropping,
44
+ .np-upload-input__upload-button:hover,
45
+ .np-upload-input__upload-button:active {
46
+ background: rgba(134,167,189,0.10196);
47
+ background: var(--color-background-neutral);
21
48
  }
22
- .np-upload-button {
49
+ .np-upload-input__upload-button.is-dropping::before,
50
+ .np-upload-input__upload-button:hover::before,
51
+ .np-upload-input__upload-button:active::before {
23
52
  width: 100%;
24
- border-top: 1px solid transparent;
25
- padding: 16px;
26
- padding: var(--padding-small);
27
- border-radius: 0;
53
+ left: 0;
28
54
  }
29
- label.np-upload-button:not(.disabled):hover,
30
- label.np-upload-button:not(.disabled):active {
31
- background-color: var(--color-background-screen-hover);
55
+ .np-upload-input__upload-button:focus-within,
56
+ .np-upload-input__upload-button:focus-visible {
57
+ outline: var(--ring-outline-color) solid 3px;
58
+ outline-offset: -3px;
32
59
  }
33
- .disabled label.np-upload-button:not(.disabled):hover,
34
- .disabled label.np-upload-button:not(.disabled):active {
35
- background-color: transparent;
60
+ .np-upload-input__upload-button-input {
61
+ position: absolute;
62
+ opacity: 0;
63
+ z-index: -1;
36
64
  }
37
- .np-upload-button .media {
38
- align-items: flex-start;
65
+ .np-upload-input__upload-button-input:focus {
66
+ outline: none;
39
67
  }
40
- @media (max-width: 320px) {
41
- .np-upload-icon {
42
- padding-left: 0;
43
- }
68
+ .np-upload-input__upload-button .np-upload-input__drop-file-overlay {
69
+ display: flex;
70
+ flex: 1;
71
+ padding: 13px 0 !important;
72
+ background-color: transparent;
73
+ transition: transform 0.3s ease;
74
+ position: relative;
44
75
  }
@@ -1,55 +1,78 @@
1
- .np-upload-button-container {
2
- border-style: solid;
1
+ .np-upload-input__upload-button {
2
+ position: relative;
3
+ padding: var(--size-16);
4
+ display: flex;
5
+ align-items: center;
6
+ margin: 0;
7
+ border-radius: inherit;
3
8
 
4
- .droppable-card-content {
5
- display: flex;
6
- }
7
-
8
- &.droppable-dropping {
9
- border-color: var(--color-interactive-secondary) !important;
9
+ .np-upload-input__title {
10
+ color: var(--color-content-link);
11
+ text-decoration: underline;
12
+ text-underline-offset: 0.3em;
10
13
 
11
- &:before {
12
- z-index: 2;
14
+ & + .np-upload-input__text {
15
+ margin-top: var(--size-4);
16
+ line-height: 22px;
13
17
  }
14
18
  }
15
19
 
16
- input[type="file"] {
17
- opacity: 0;
18
- z-index: -1;
19
- position: absolute;
20
+ .np-upload-input__icon {
21
+ padding-right: var(--size-16);
22
+ color: var(--color-interactive-primary);
20
23
  }
21
24
 
22
- .np-upload-button {
23
- border: none;
25
+ &::before {
26
+ display: block;
27
+ position: absolute;
28
+ height: 1px;
29
+ background-color: var(--color-border-neutral);
30
+ content: " ";
31
+ left: var(--size-16);
32
+ width: calc(100% - 2 * var(--size-16));
33
+ top: 0;
24
34
  }
25
- }
26
35
 
27
- .np-upload-button {
28
- width: 100%;
29
- border-top: 1px solid transparent;
30
- padding: var(--padding-small);
31
- border-radius: 0;
36
+ &.is-dropping {
37
+ .np-upload-input__icon,
38
+ .np-upload-input__item-content {
39
+ display: none;
40
+ }
41
+ }
32
42
 
33
- label& {
34
- &:not(.disabled) {
35
- &:hover,
36
- &:active {
37
- background-color: var(--color-background-screen-hover);
43
+ &.is-dropping,
44
+ &:hover,
45
+ &:active {
46
+ background: var(--color-background-neutral);
38
47
 
39
- .disabled & {
40
- background-color: transparent;
41
- }
42
- }
48
+ &::before {
49
+ width: 100%;
50
+ left: 0;
43
51
  }
44
52
  }
45
53
 
46
- .media {
47
- align-items: flex-start;
54
+ &:focus-within,
55
+ &:focus-visible {
56
+ outline: var(--ring-outline-color) solid 3px;
57
+ outline-offset: -3px;
48
58
  }
49
- }
50
59
 
51
- .np-upload-icon{
52
- @media (max-width: 320px) {
53
- padding-left: 0;
60
+ &-input {
61
+ position: absolute;
62
+ opacity: 0;
63
+ z-index: -1;
64
+
65
+ &:focus {
66
+ outline: none;
67
+ }
68
+ }
69
+
70
+ .np-upload-input__drop-file-overlay {
71
+ display: flex;
72
+ flex: 1;
73
+ padding: 13px 0 !important;
74
+ background-color: transparent;
75
+ transition: transform 0.3s ease;
76
+ position: relative;
54
77
  }
55
- }
78
+ }
@@ -169,7 +169,7 @@ const UploadButton = ({
169
169
 
170
170
  function renderDescription() {
171
171
  return (
172
- <Body className={clsx({ 'text-primary': !disabled })}>
172
+ <Body className="np-upload-input__text">
173
173
  {getDescription()}
174
174
  {maxFiles && (
175
175
  <>
@@ -189,49 +189,46 @@ const UploadButton = ({
189
189
  }
190
190
 
191
191
  return (
192
- <div
193
- className={clsx('np-upload-button-container', 'droppable', {
194
- 'droppable-dropping': isDropping,
195
- })}
192
+ <label
193
+ className={clsx('np-upload-input__upload-button', { 'is-dropping': isDropping })}
194
+ htmlFor={id}
196
195
  {...(!disabled && { onDragEnter, onDragLeave, onDrop, onDragOver })}
197
196
  >
197
+ <span className="np-upload-input__icon">
198
+ <UploadIcon size={24} className="text-link" />
199
+ </span>
200
+ <div className="np-upload-input__item-content" data-testid={TEST_IDS.mediaBody}>
201
+ <Body type={Typography.BODY_LARGE_BOLD} className="np-upload-input__title">
202
+ {renderButtonTitle()}
203
+ </Body>
204
+ {renderDescription()}
205
+ </div>
198
206
  <input
199
207
  ref={inputReference}
200
- id={id}
208
+ className="np-upload-input__upload-button-input sr-only"
201
209
  type="file"
210
+ id={id}
202
211
  {...getAcceptedTypes()}
203
212
  {...(multiple && { multiple: true })}
204
- className="tw-droppable-input"
205
213
  disabled={disabled}
206
214
  name="file-upload"
207
215
  data-testid={TEST_IDS.uploadInput}
208
216
  onChange={filesSelected}
209
217
  />
210
- {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
211
- <label htmlFor={id} className={clsx('btn', 'np-upload-button')}>
212
- <div className="media">
213
- <div className="np-upload-icon media-middle media-left">
214
- <UploadIcon size={24} className="text-link" />
215
- </div>
216
- <div className="media-body text-xs-left" data-testid={TEST_IDS.mediaBody}>
217
- <Body type={Typography.BODY_LARGE_BOLD} className="d-block">
218
- {renderButtonTitle()}
219
- </Body>
220
- {renderDescription()}
221
- </div>
222
- </div>
223
- </label>
224
-
225
- {/* Drop area overlay */}
226
218
  {isDropping && (
227
219
  <div
228
- className={clsx('droppable-card', 'droppable-dropping-card', 'droppable-card-content')}
220
+ className={clsx(
221
+ 'np-upload-input__drop-file-overlay',
222
+ 'droppable-card',
223
+ 'droppable-dropping-card',
224
+ 'droppable-card-content',
225
+ )}
229
226
  >
230
227
  <PlusIcon className="m-x-1" size={24} />
231
228
  <div>{formatMessage(MESSAGES.dropFile)}</div>
232
229
  </div>
233
230
  )}
234
- </div>
231
+ </label>
235
232
  );
236
233
  };
237
234