@transferwise/components 0.0.0-experimental-1072d5f → 0.0.0-experimental-80ec562
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/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/SelectInput.js +31 -5
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.messages.js +3 -0
- package/build/inputs/SelectInput.messages.js.map +1 -1
- package/build/inputs/SelectInput.messages.mjs +3 -0
- package/build/inputs/SelectInput.messages.mjs.map +1 -1
- package/build/inputs/SelectInput.mjs +31 -5
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/main.css +20 -28
- package/build/styles/main.css +20 -28
- package/build/styles/uploadInput/uploadButton/UploadButton.css +0 -5
- package/build/styles/uploadInput/uploadItem/UploadItem.css +20 -23
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.messages.d.ts +5 -0
- package/build/types/inputs/SelectInput.messages.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/{UploadItemLink.d.ts → UploadItemBody.d.ts} +2 -2
- package/build/types/uploadInput/uploadItem/UploadItemBody.d.ts.map +1 -0
- package/build/uploadInput/uploadItem/UploadItem.js +11 -13
- package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
- package/build/uploadInput/uploadItem/UploadItem.mjs +12 -14
- package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
- package/build/uploadInput/uploadItem/UploadItemBody.js +27 -0
- package/build/uploadInput/uploadItem/UploadItemBody.js.map +1 -0
- package/build/uploadInput/uploadItem/{UploadItemLink.mjs → UploadItemBody.mjs} +4 -5
- package/build/uploadInput/uploadItem/UploadItemBody.mjs.map +1 -0
- package/package.json +3 -3
- package/src/i18n/en.json +1 -0
- package/src/inputs/SelectInput.messages.ts +6 -0
- package/src/inputs/SelectInput.story.tsx +6429 -0
- package/src/inputs/SelectInput.tsx +48 -6
- package/src/main.css +20 -28
- package/src/uploadInput/uploadButton/UploadButton.css +0 -5
- package/src/uploadInput/uploadButton/UploadButton.less +0 -6
- package/src/uploadInput/uploadItem/UploadItem.css +20 -23
- package/src/uploadInput/uploadItem/UploadItem.less +12 -16
- package/src/uploadInput/uploadItem/UploadItem.tsx +7 -11
- package/src/uploadInput/uploadItem/{UploadItemLink.tsx → UploadItemBody.tsx} +2 -6
- package/build/types/uploadInput/uploadItem/UploadItemLink.d.ts.map +0 -1
- package/build/uploadInput/uploadItem/UploadItemLink.js +0 -32
- package/build/uploadInput/uploadItem/UploadItemLink.js.map +0 -1
- package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +0 -1
|
@@ -28,6 +28,9 @@ import { useInputAttributes, WithInputAttributesProps } from './contexts';
|
|
|
28
28
|
import { InputGroup } from './InputGroup';
|
|
29
29
|
import { SearchInput } from './SearchInput';
|
|
30
30
|
import messages from './SelectInput.messages';
|
|
31
|
+
import { debounce } from 'lodash';
|
|
32
|
+
|
|
33
|
+
const DEFAULT_OPTIONS_PAGE_SIZE = 10;
|
|
31
34
|
|
|
32
35
|
function searchableString(value: string) {
|
|
33
36
|
return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
|
|
@@ -288,6 +291,11 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
288
291
|
const listboxRef = useRef<HTMLDivElement>(null);
|
|
289
292
|
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
290
293
|
|
|
294
|
+
const hasGroups = items.filter((item) => item.type === 'group').length > 0;
|
|
295
|
+
|
|
296
|
+
// TODO - Logic here up for debate
|
|
297
|
+
const enableShowMore = !!filterable && items.length > DEFAULT_OPTIONS_PAGE_SIZE && !hasGroups;
|
|
298
|
+
|
|
291
299
|
return (
|
|
292
300
|
<ListboxBase
|
|
293
301
|
name={name}
|
|
@@ -393,6 +401,7 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
393
401
|
searchInputRef={searchInputRef}
|
|
394
402
|
listboxRef={listboxRef}
|
|
395
403
|
filterQuery={filterQuery}
|
|
404
|
+
enableShowMore={enableShowMore}
|
|
396
405
|
onFilterChange={setFilterQuery}
|
|
397
406
|
/>
|
|
398
407
|
</OptionsOverlay>
|
|
@@ -483,6 +492,7 @@ interface SelectInputOptionsProps<T = string>
|
|
|
483
492
|
listboxRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
484
493
|
filterQuery: string;
|
|
485
494
|
onFilterChange: (query: string) => void;
|
|
495
|
+
enableShowMore: boolean;
|
|
486
496
|
}
|
|
487
497
|
|
|
488
498
|
function SelectInputOptions<T = string>({
|
|
@@ -494,12 +504,15 @@ function SelectInputOptions<T = string>({
|
|
|
494
504
|
searchInputRef,
|
|
495
505
|
listboxRef,
|
|
496
506
|
filterQuery,
|
|
507
|
+
enableShowMore,
|
|
497
508
|
onFilterChange,
|
|
498
509
|
}: SelectInputOptionsProps<T>) {
|
|
499
510
|
const intl = useIntl();
|
|
500
511
|
|
|
501
512
|
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
502
513
|
|
|
514
|
+
const [numberOfOptionsShown, setNumberOfOptionsShown] = useState(DEFAULT_OPTIONS_PAGE_SIZE);
|
|
515
|
+
|
|
503
516
|
const needle = useMemo(() => {
|
|
504
517
|
if (filterable) {
|
|
505
518
|
return filterQuery ? searchableString(filterQuery) : null;
|
|
@@ -522,6 +535,13 @@ function SelectInputOptions<T = string>({
|
|
|
522
535
|
const statusId = useId();
|
|
523
536
|
const listboxId = useId();
|
|
524
537
|
|
|
538
|
+
const onShowMore = () => {
|
|
539
|
+
setNumberOfOptionsShown((prev) => prev + DEFAULT_OPTIONS_PAGE_SIZE);
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
const displayShowMoreLink =
|
|
543
|
+
enableShowMore && needle === null && numberOfOptionsShown < items.length;
|
|
544
|
+
|
|
525
545
|
return (
|
|
526
546
|
<ListboxBase.Options
|
|
527
547
|
as={SelectInputOptionsContainer}
|
|
@@ -590,7 +610,10 @@ function SelectInputOptions<T = string>({
|
|
|
590
610
|
tabIndex={0}
|
|
591
611
|
className="np-select-input-listbox"
|
|
592
612
|
>
|
|
593
|
-
{(needle != null
|
|
613
|
+
{(needle != null
|
|
614
|
+
? dedupeSelectInputItems(items)
|
|
615
|
+
: items.slice(0, numberOfOptionsShown)
|
|
616
|
+
).map((item, index) => (
|
|
594
617
|
<SelectInputItemView
|
|
595
618
|
// eslint-disable-next-line react/no-array-index-key
|
|
596
619
|
key={index}
|
|
@@ -601,7 +624,7 @@ function SelectInputOptions<T = string>({
|
|
|
601
624
|
))}
|
|
602
625
|
</div>
|
|
603
626
|
|
|
604
|
-
{renderFooter != null ? (
|
|
627
|
+
{renderFooter != null || displayShowMoreLink ? (
|
|
605
628
|
<footer className="np-select-input-footer">
|
|
606
629
|
<div
|
|
607
630
|
role="none"
|
|
@@ -612,10 +635,13 @@ function SelectInputOptions<T = string>({
|
|
|
612
635
|
}
|
|
613
636
|
}}
|
|
614
637
|
>
|
|
615
|
-
{
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
638
|
+
{displayShowMoreLink ? <ShowMoreOption onClick={onShowMore} /> : null}
|
|
639
|
+
{renderFooter
|
|
640
|
+
? renderFooter({
|
|
641
|
+
resultsEmpty,
|
|
642
|
+
queryNormalized: needle,
|
|
643
|
+
})
|
|
644
|
+
: null}
|
|
619
645
|
</div>
|
|
620
646
|
</footer>
|
|
621
647
|
) : null}
|
|
@@ -624,6 +650,22 @@ function SelectInputOptions<T = string>({
|
|
|
624
650
|
);
|
|
625
651
|
}
|
|
626
652
|
|
|
653
|
+
function ShowMoreOption({ onClick }: { onClick: () => void }) {
|
|
654
|
+
const intl = useIntl();
|
|
655
|
+
|
|
656
|
+
return (
|
|
657
|
+
<a
|
|
658
|
+
href=""
|
|
659
|
+
onClick={(e) => {
|
|
660
|
+
e.preventDefault();
|
|
661
|
+
onClick();
|
|
662
|
+
}}
|
|
663
|
+
>
|
|
664
|
+
{intl.formatMessage(messages.showMore)}
|
|
665
|
+
</a>
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
627
669
|
interface SelectInputItemViewProps<
|
|
628
670
|
T = string,
|
|
629
671
|
I extends SelectInputItem<T | undefined> = SelectInputItem<T | undefined>,
|
package/src/main.css
CHANGED
|
@@ -5472,11 +5472,6 @@ label.np-upload-button:not(.disabled):active {
|
|
|
5472
5472
|
.np-upload-button .media {
|
|
5473
5473
|
align-items: flex-start;
|
|
5474
5474
|
}
|
|
5475
|
-
@media (max-width: 320px) {
|
|
5476
|
-
.np-upload-icon {
|
|
5477
|
-
padding-left: 0;
|
|
5478
|
-
}
|
|
5479
|
-
}
|
|
5480
5475
|
.np-upload-input.form-control {
|
|
5481
5476
|
height: auto;
|
|
5482
5477
|
padding: 0;
|
|
@@ -5568,9 +5563,9 @@ label.np-upload-button:not(.disabled):active {
|
|
|
5568
5563
|
border: 1px solid var(--color-interactive-secondary);
|
|
5569
5564
|
position: relative;
|
|
5570
5565
|
}
|
|
5571
|
-
.np-upload-item:first-child ~ div:not(.np-upload-
|
|
5572
|
-
.np-upload-item:not(:first-child).np-upload-
|
|
5573
|
-
.np-upload-item.np-upload-
|
|
5566
|
+
.np-upload-item:first-child ~ div:not(.np-upload-item__link):before,
|
|
5567
|
+
.np-upload-item:not(:first-child).np-upload-item__link .np-upload-item--link:before,
|
|
5568
|
+
.np-upload-item.np-upload-item__link:hover .np-upload-item--link:after {
|
|
5574
5569
|
display: block;
|
|
5575
5570
|
position: absolute;
|
|
5576
5571
|
height: 1px;
|
|
@@ -5582,27 +5577,27 @@ label.np-upload-button:not(.disabled):active {
|
|
|
5582
5577
|
width: calc(100% - 2 * 16px);
|
|
5583
5578
|
width: calc(100% - 2 * var(--size-16));
|
|
5584
5579
|
}
|
|
5585
|
-
.np-upload-item:first-child ~ div:not(.np-upload-
|
|
5586
|
-
.np-upload-item:not(:first-child).np-upload-
|
|
5580
|
+
.np-upload-item:first-child ~ div:not(.np-upload-item__link):before,
|
|
5581
|
+
.np-upload-item:not(:first-child).np-upload-item__link .np-upload-item--link:before {
|
|
5587
5582
|
top: 0;
|
|
5588
5583
|
}
|
|
5589
|
-
.np-upload-item.np-upload-
|
|
5584
|
+
.np-upload-item.np-upload-item__link:hover .np-upload-item--link:after {
|
|
5590
5585
|
bottom: -1px;
|
|
5591
5586
|
}
|
|
5592
5587
|
.np-upload-item:first-child ~ div {
|
|
5593
5588
|
border-top: 1px;
|
|
5594
5589
|
}
|
|
5595
|
-
.np-upload-item:not(:first-child) .np-upload-
|
|
5590
|
+
.np-upload-item:not(:first-child) .np-upload-item--link:hover {
|
|
5596
5591
|
border-top-color: rgba(0,0,0,0.10196);
|
|
5597
5592
|
border-top-color: var(--color-border-neutral);
|
|
5598
5593
|
}
|
|
5599
5594
|
.np-upload-item:not(:last-child) {
|
|
5600
5595
|
border-bottom: 0;
|
|
5601
5596
|
}
|
|
5602
|
-
.np-upload-item.np-upload-
|
|
5603
|
-
.np-upload-item.np-upload-
|
|
5604
|
-
.np-upload-item.np-upload-
|
|
5605
|
-
.np-upload-item.np-upload-
|
|
5597
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-item:before,
|
|
5598
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-button-container:before,
|
|
5599
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-item .np-upload-item--link:before,
|
|
5600
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-button-container .np-upload-item--link:before {
|
|
5606
5601
|
display: none;
|
|
5607
5602
|
}
|
|
5608
5603
|
.np-upload-button-container:hover:before,
|
|
@@ -5617,41 +5612,38 @@ label.np-upload-button:not(.disabled):active {
|
|
|
5617
5612
|
outline-offset: -3px;
|
|
5618
5613
|
}
|
|
5619
5614
|
.np-upload-item--single-file:focus-visible,
|
|
5620
|
-
.np-upload-
|
|
5615
|
+
.np-upload-item--link:focus-visible,
|
|
5621
5616
|
.np-upload-button-container:has(:focus-visible) {
|
|
5622
5617
|
outline-width: 3px;
|
|
5623
5618
|
}
|
|
5624
|
-
.np-upload-
|
|
5619
|
+
.np-upload-item__link a {
|
|
5625
5620
|
flex: 1;
|
|
5626
5621
|
-webkit-text-decoration: none;
|
|
5627
5622
|
text-decoration: none;
|
|
5628
5623
|
border-top: 1px solid transparent;
|
|
5629
5624
|
border-radius: inherit;
|
|
5630
5625
|
}
|
|
5631
|
-
.np-upload-
|
|
5626
|
+
.np-upload-item__link a:focus-visible {
|
|
5632
5627
|
outline-offset: -2px;
|
|
5633
5628
|
}
|
|
5634
|
-
.np-upload-
|
|
5629
|
+
.np-upload-item__link a:hover:before {
|
|
5635
5630
|
display: none !important;
|
|
5636
5631
|
}
|
|
5637
|
-
.np-upload-
|
|
5632
|
+
.np-upload-item__link a:hover:after {
|
|
5638
5633
|
left: 0 !important;
|
|
5639
5634
|
width: 100% !important;
|
|
5640
5635
|
}
|
|
5641
|
-
.np-upload-
|
|
5642
|
-
.np-upload-
|
|
5636
|
+
.np-upload-item__link a:hover,
|
|
5637
|
+
.np-upload-item__link a:active {
|
|
5643
5638
|
-webkit-text-decoration: none;
|
|
5644
5639
|
text-decoration: none;
|
|
5645
5640
|
}
|
|
5646
|
-
.np-upload-
|
|
5647
|
-
.np-upload-
|
|
5641
|
+
.np-upload-item__link a:hover .np-upload-button,
|
|
5642
|
+
.np-upload-item__link a:active .np-upload-button {
|
|
5648
5643
|
background-color: rgba(134,167,189,0.10196);
|
|
5649
5644
|
background-color: var(--color-background-neutral);
|
|
5650
5645
|
border-radius: inherit;
|
|
5651
5646
|
}
|
|
5652
|
-
.np-upload-item--link:first-of-type a {
|
|
5653
|
-
border-top: 0;
|
|
5654
|
-
}
|
|
5655
5647
|
.np-upload-item__body {
|
|
5656
5648
|
display: flex;
|
|
5657
5649
|
align-items: center;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
border: 1px solid var(--color-interactive-secondary);
|
|
4
4
|
position: relative;
|
|
5
5
|
}
|
|
6
|
-
.np-upload-item:first-child ~ div:not(.np-upload-
|
|
7
|
-
.np-upload-item:not(:first-child).np-upload-
|
|
8
|
-
.np-upload-item.np-upload-
|
|
6
|
+
.np-upload-item:first-child ~ div:not(.np-upload-item__link):before,
|
|
7
|
+
.np-upload-item:not(:first-child).np-upload-item__link .np-upload-item--link:before,
|
|
8
|
+
.np-upload-item.np-upload-item__link:hover .np-upload-item--link:after {
|
|
9
9
|
display: block;
|
|
10
10
|
position: absolute;
|
|
11
11
|
height: 1px;
|
|
@@ -17,27 +17,27 @@
|
|
|
17
17
|
width: calc(100% - 2 * 16px);
|
|
18
18
|
width: calc(100% - 2 * var(--size-16));
|
|
19
19
|
}
|
|
20
|
-
.np-upload-item:first-child ~ div:not(.np-upload-
|
|
21
|
-
.np-upload-item:not(:first-child).np-upload-
|
|
20
|
+
.np-upload-item:first-child ~ div:not(.np-upload-item__link):before,
|
|
21
|
+
.np-upload-item:not(:first-child).np-upload-item__link .np-upload-item--link:before {
|
|
22
22
|
top: 0;
|
|
23
23
|
}
|
|
24
|
-
.np-upload-item.np-upload-
|
|
24
|
+
.np-upload-item.np-upload-item__link:hover .np-upload-item--link:after {
|
|
25
25
|
bottom: -1px;
|
|
26
26
|
}
|
|
27
27
|
.np-upload-item:first-child ~ div {
|
|
28
28
|
border-top: 1px;
|
|
29
29
|
}
|
|
30
|
-
.np-upload-item:not(:first-child) .np-upload-
|
|
30
|
+
.np-upload-item:not(:first-child) .np-upload-item--link:hover {
|
|
31
31
|
border-top-color: rgba(0,0,0,0.10196);
|
|
32
32
|
border-top-color: var(--color-border-neutral);
|
|
33
33
|
}
|
|
34
34
|
.np-upload-item:not(:last-child) {
|
|
35
35
|
border-bottom: 0;
|
|
36
36
|
}
|
|
37
|
-
.np-upload-item.np-upload-
|
|
38
|
-
.np-upload-item.np-upload-
|
|
39
|
-
.np-upload-item.np-upload-
|
|
40
|
-
.np-upload-item.np-upload-
|
|
37
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-item:before,
|
|
38
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-button-container:before,
|
|
39
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-item .np-upload-item--link:before,
|
|
40
|
+
.np-upload-item.np-upload-item__link:hover + .np-upload-button-container .np-upload-item--link:before {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
43
|
.np-upload-button-container:hover:before,
|
|
@@ -52,41 +52,38 @@
|
|
|
52
52
|
outline-offset: -3px;
|
|
53
53
|
}
|
|
54
54
|
.np-upload-item--single-file:focus-visible,
|
|
55
|
-
.np-upload-
|
|
55
|
+
.np-upload-item--link:focus-visible,
|
|
56
56
|
.np-upload-button-container:has(:focus-visible) {
|
|
57
57
|
outline-width: 3px;
|
|
58
58
|
}
|
|
59
|
-
.np-upload-
|
|
59
|
+
.np-upload-item__link a {
|
|
60
60
|
flex: 1;
|
|
61
61
|
-webkit-text-decoration: none;
|
|
62
62
|
text-decoration: none;
|
|
63
63
|
border-top: 1px solid transparent;
|
|
64
64
|
border-radius: inherit;
|
|
65
65
|
}
|
|
66
|
-
.np-upload-
|
|
66
|
+
.np-upload-item__link a:focus-visible {
|
|
67
67
|
outline-offset: -2px;
|
|
68
68
|
}
|
|
69
|
-
.np-upload-
|
|
69
|
+
.np-upload-item__link a:hover:before {
|
|
70
70
|
display: none !important;
|
|
71
71
|
}
|
|
72
|
-
.np-upload-
|
|
72
|
+
.np-upload-item__link a:hover:after {
|
|
73
73
|
left: 0 !important;
|
|
74
74
|
width: 100% !important;
|
|
75
75
|
}
|
|
76
|
-
.np-upload-
|
|
77
|
-
.np-upload-
|
|
76
|
+
.np-upload-item__link a:hover,
|
|
77
|
+
.np-upload-item__link a:active {
|
|
78
78
|
-webkit-text-decoration: none;
|
|
79
79
|
text-decoration: none;
|
|
80
80
|
}
|
|
81
|
-
.np-upload-
|
|
82
|
-
.np-upload-
|
|
81
|
+
.np-upload-item__link a:hover .np-upload-button,
|
|
82
|
+
.np-upload-item__link a:active .np-upload-button {
|
|
83
83
|
background-color: rgba(134,167,189,0.10196);
|
|
84
84
|
background-color: var(--color-background-neutral);
|
|
85
85
|
border-radius: inherit;
|
|
86
86
|
}
|
|
87
|
-
.np-upload-item--link:first-of-type a {
|
|
88
|
-
border-top: 0;
|
|
89
|
-
}
|
|
90
87
|
.np-upload-item__body {
|
|
91
88
|
display: flex;
|
|
92
89
|
align-items: center;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
border: 1px solid var(--color-interactive-secondary);
|
|
6
6
|
position: relative;
|
|
7
7
|
|
|
8
|
-
&:first-child ~ div:not(.np-upload-
|
|
9
|
-
&:not(:first-child).np-upload-
|
|
10
|
-
&.np-upload-
|
|
8
|
+
&:first-child ~ div:not(.np-upload-item__link):before,
|
|
9
|
+
&:not(:first-child).np-upload-item__link .np-upload-item--link:before,
|
|
10
|
+
&.np-upload-item__link:hover .np-upload-item--link:after {
|
|
11
11
|
display: block;
|
|
12
12
|
position: absolute;
|
|
13
13
|
height: 1px;
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
width: calc(100% - 2 * var(--size-16));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
&:first-child ~ div:not(.np-upload-
|
|
21
|
-
&:not(:first-child).np-upload-
|
|
20
|
+
&:first-child ~ div:not(.np-upload-item__link):before,
|
|
21
|
+
&:not(:first-child).np-upload-item__link .np-upload-item--link:before {
|
|
22
22
|
top: 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
&.np-upload-
|
|
25
|
+
&.np-upload-item__link:hover .np-upload-item--link:after {
|
|
26
26
|
bottom: -1px;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&:not(:first-child) {
|
|
36
|
-
.np-upload-
|
|
36
|
+
.np-upload-item--link:hover {
|
|
37
37
|
border-top-color: var(--color-border-neutral);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
&.np-upload-
|
|
47
|
-
&.np-upload-
|
|
46
|
+
&.np-upload-item__link:hover + .np-upload-item,
|
|
47
|
+
&.np-upload-item__link:hover + .np-upload-button-container {
|
|
48
48
|
&:before,
|
|
49
|
-
.np-upload-
|
|
49
|
+
.np-upload-item--link:before {
|
|
50
50
|
display: none;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
.np-upload-item--single-file:focus-visible,
|
|
70
|
-
.np-upload-
|
|
70
|
+
.np-upload-item--link:focus-visible,
|
|
71
71
|
.np-upload-button-container:has(:focus-visible) {
|
|
72
72
|
outline-width: 3px;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
.np-upload-
|
|
75
|
+
.np-upload-item__link {
|
|
76
76
|
a {
|
|
77
77
|
flex: 1;
|
|
78
78
|
text-decoration: none;
|
|
@@ -103,10 +103,6 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
&:first-of-type a {
|
|
108
|
-
border-top: 0;
|
|
109
|
-
}
|
|
110
106
|
}
|
|
111
107
|
|
|
112
108
|
.np-upload-item__body {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bin
|
|
1
|
+
import { Bin } from '@transferwise/icons';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ import StatusIcon from '../../statusIcon/StatusIcon';
|
|
|
9
9
|
import { UploadedFile, UploadError } from '../types';
|
|
10
10
|
|
|
11
11
|
import MESSAGES from './UploadItem.messages';
|
|
12
|
-
import {
|
|
12
|
+
import { UploadItemBody } from './UploadItemBody';
|
|
13
13
|
|
|
14
14
|
export type UploadItemProps = JSX.IntrinsicAttributes & {
|
|
15
15
|
file: UploadedFile;
|
|
@@ -46,13 +46,9 @@ const UploadItem = ({
|
|
|
46
46
|
|
|
47
47
|
const isSucceeded = [Status.SUCCEEDED, undefined].includes(status) && !!url;
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* We're temporarily reverting to the regular icon components,
|
|
51
|
-
* until the StatusIcon receives 24px sizing.
|
|
52
|
-
*/
|
|
53
49
|
const getIcon = () => {
|
|
54
50
|
if (error || errors?.length || status === Status.FAILED) {
|
|
55
|
-
return <
|
|
51
|
+
return <StatusIcon size={Size.SMALL} sentiment={Sentiment.NEGATIVE} />;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
let processIndicator: React.ReactNode;
|
|
@@ -65,7 +61,7 @@ const UploadItem = ({
|
|
|
65
61
|
case Status.SUCCEEDED:
|
|
66
62
|
case Status.DONE:
|
|
67
63
|
default:
|
|
68
|
-
processIndicator = <
|
|
64
|
+
processIndicator = <StatusIcon size={Size.SMALL} sentiment={Sentiment.POSITIVE} />;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
return processIndicator;
|
|
@@ -131,11 +127,11 @@ const UploadItem = ({
|
|
|
131
127
|
|
|
132
128
|
return (
|
|
133
129
|
<div
|
|
134
|
-
className={classNames('np-upload-item', { 'np-upload-
|
|
130
|
+
className={classNames('np-upload-item', { 'np-upload-item__link': isSucceeded })}
|
|
135
131
|
data-testid={TEST_IDS.uploadItem}
|
|
136
132
|
>
|
|
137
133
|
<div className="np-upload-item__body">
|
|
138
|
-
<
|
|
134
|
+
<UploadItemBody
|
|
139
135
|
url={isSucceeded ? url : undefined}
|
|
140
136
|
singleFileUpload={singleFileUpload}
|
|
141
137
|
onDownload={onDownloadFile}
|
|
@@ -149,7 +145,7 @@ const UploadItem = ({
|
|
|
149
145
|
</div>
|
|
150
146
|
</div>
|
|
151
147
|
</div>
|
|
152
|
-
</
|
|
148
|
+
</UploadItemBody>
|
|
153
149
|
{canDelete && (
|
|
154
150
|
<button
|
|
155
151
|
aria-label={formatMessage(MESSAGES.removeFile, { filename })}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PropsWithChildren, MouseEvent } from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
2
|
|
|
4
3
|
type UploadItemLinkProps = PropsWithChildren<{
|
|
5
4
|
url?: string;
|
|
@@ -7,7 +6,7 @@ type UploadItemLinkProps = PropsWithChildren<{
|
|
|
7
6
|
singleFileUpload: boolean;
|
|
8
7
|
}>;
|
|
9
8
|
|
|
10
|
-
export const
|
|
9
|
+
export const UploadItemBody = ({
|
|
11
10
|
children,
|
|
12
11
|
url,
|
|
13
12
|
onDownload,
|
|
@@ -22,10 +21,7 @@ export const UploadItemLink = ({
|
|
|
22
21
|
href={url}
|
|
23
22
|
target="_blank"
|
|
24
23
|
rel="noopener noreferrer"
|
|
25
|
-
className={
|
|
26
|
-
'np-upload-item__link',
|
|
27
|
-
singleFileUpload ? 'np-upload-item--single-file' : '',
|
|
28
|
-
)}
|
|
24
|
+
className={singleFileUpload ? 'np-upload-item--single-file' : 'np-upload-item--link'}
|
|
29
25
|
onClick={onDownload}
|
|
30
26
|
>
|
|
31
27
|
{children}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UploadItemLink.d.ts","sourceRoot":"","sources":["../../../../src/uploadInput/uploadItem/UploadItemLink.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGtD,KAAK,mBAAmB,GAAG,iBAAiB,CAAC;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC,CAAC;AAEH,eAAO,MAAM,cAAc,qDAKxB,mBAAmB,gCAmBrB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var classNames = require('classnames');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
9
|
-
|
|
10
|
-
const UploadItemLink = ({
|
|
11
|
-
children,
|
|
12
|
-
url,
|
|
13
|
-
onDownload,
|
|
14
|
-
singleFileUpload
|
|
15
|
-
}) => {
|
|
16
|
-
if (!url) {
|
|
17
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
18
|
-
children: children
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return /*#__PURE__*/jsxRuntime.jsx("a", {
|
|
22
|
-
href: url,
|
|
23
|
-
target: "_blank",
|
|
24
|
-
rel: "noopener noreferrer",
|
|
25
|
-
className: classNames__default.default('np-upload-item__link', singleFileUpload ? 'np-upload-item--single-file' : ''),
|
|
26
|
-
onClick: onDownload,
|
|
27
|
-
children: children
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.UploadItemLink = UploadItemLink;
|
|
32
|
-
//# sourceMappingURL=UploadItemLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UploadItemLink.js","sources":["../../../src/uploadInput/uploadItem/UploadItemLink.tsx"],"sourcesContent":["import { PropsWithChildren, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\ntype UploadItemLinkProps = PropsWithChildren<{\n url?: string;\n onDownload?: (event: MouseEvent) => void;\n singleFileUpload: boolean;\n}>;\n\nexport const UploadItemLink = ({\n children,\n url,\n onDownload,\n singleFileUpload,\n}: UploadItemLinkProps) => {\n if (!url) {\n return <div>{children}</div>;\n }\n\n return (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={classnames(\n 'np-upload-item__link',\n singleFileUpload ? 'np-upload-item--single-file' : '',\n )}\n onClick={onDownload}\n >\n {children}\n </a>\n );\n};\n"],"names":["UploadItemLink","children","url","onDownload","singleFileUpload","_jsx","href","target","rel","className","classnames","onClick"],"mappings":";;;;;;;;;AASO,MAAMA,cAAc,GAAGA,CAAC;EAC7BC,QAAQ;EACRC,GAAG;EACHC,UAAU;AACVC,EAAAA,gBAAAA;AAAgB,CACI,KAAI;EACxB,IAAI,CAACF,GAAG,EAAE;AACR,IAAA,oBAAOG,cAAA,CAAA,KAAA,EAAA;AAAAJ,MAAAA,QAAA,EAAMA,QAAAA;AAAQ,KAAM,CAAC,CAAA;AAC9B,GAAA;AAEA,EAAA,oBACEI,cAAA,CAAA,GAAA,EAAA;AACEC,IAAAA,IAAI,EAAEJ,GAAI;AACVK,IAAAA,MAAM,EAAC,QAAQ;AACfC,IAAAA,GAAG,EAAC,qBAAqB;IACzBC,SAAS,EAAEC,2BAAU,CACnB,sBAAsB,EACtBN,gBAAgB,GAAG,6BAA6B,GAAG,EAAE,CACrD;AACFO,IAAAA,OAAO,EAAER,UAAW;AAAAF,IAAAA,QAAA,EAEnBA,QAAAA;AAAQ,GACR,CAAC,CAAA;AAER;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UploadItemLink.mjs","sources":["../../../src/uploadInput/uploadItem/UploadItemLink.tsx"],"sourcesContent":["import { PropsWithChildren, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\ntype UploadItemLinkProps = PropsWithChildren<{\n url?: string;\n onDownload?: (event: MouseEvent) => void;\n singleFileUpload: boolean;\n}>;\n\nexport const UploadItemLink = ({\n children,\n url,\n onDownload,\n singleFileUpload,\n}: UploadItemLinkProps) => {\n if (!url) {\n return <div>{children}</div>;\n }\n\n return (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={classnames(\n 'np-upload-item__link',\n singleFileUpload ? 'np-upload-item--single-file' : '',\n )}\n onClick={onDownload}\n >\n {children}\n </a>\n );\n};\n"],"names":["UploadItemLink","children","url","onDownload","singleFileUpload","_jsx","href","target","rel","className","classnames","onClick"],"mappings":";;;AASO,MAAMA,cAAc,GAAGA,CAAC;EAC7BC,QAAQ;EACRC,GAAG;EACHC,UAAU;AACVC,EAAAA,gBAAAA;AAAgB,CACI,KAAI;EACxB,IAAI,CAACF,GAAG,EAAE;AACR,IAAA,oBAAOG,GAAA,CAAA,KAAA,EAAA;AAAAJ,MAAAA,QAAA,EAAMA,QAAAA;AAAQ,KAAM,CAAC,CAAA;AAC9B,GAAA;AAEA,EAAA,oBACEI,GAAA,CAAA,GAAA,EAAA;AACEC,IAAAA,IAAI,EAAEJ,GAAI;AACVK,IAAAA,MAAM,EAAC,QAAQ;AACfC,IAAAA,GAAG,EAAC,qBAAqB;IACzBC,SAAS,EAAEC,UAAU,CACnB,sBAAsB,EACtBN,gBAAgB,GAAG,6BAA6B,GAAG,EAAE,CACrD;AACFO,IAAAA,OAAO,EAAER,UAAW;AAAAF,IAAAA,QAAA,EAEnBA,QAAAA;AAAQ,GACR,CAAC,CAAA;AAER;;;;"}
|