@transferwise/components 0.0.0-experimental-6fa7ff3 → 0.0.0-experimental-1775875
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/avatarLayout/AvatarLayout.js +2 -9
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +2 -9
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +79 -78
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +80 -79
- package/build/button/Button.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +3 -8
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +3 -8
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +0 -258
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +3 -5
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +2 -4
- package/build/select/Select.mjs.map +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +0 -11
- package/build/styles/button/Button.css +16 -240
- package/build/styles/main.css +0 -258
- package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +0 -1
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +23 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -5
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +4 -4
- package/src/avatarLayout/AvatarLayout.css +0 -11
- package/src/avatarLayout/AvatarLayout.less +1 -18
- package/src/avatarLayout/AvatarLayout.tsx +3 -11
- package/src/avatarLayout/index.ts +0 -1
- package/src/button/Button.css +16 -240
- package/src/button/Button.less +14 -208
- package/src/button/Button.spec.tsx +231 -54
- package/src/button/Button.story.tsx +137 -612
- package/src/button/Button.tsx +132 -88
- package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
- package/src/button/index.ts +3 -2
- package/src/drawer/Drawer.spec.tsx +93 -0
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/link/Link.tsx +6 -15
- package/src/main.css +0 -258
- package/src/main.less +0 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -6
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
- package/src/select/Select.tsx +0 -1
- package/build/button/Button.resolver.js +0 -78
- package/build/button/Button.resolver.js.map +0 -1
- package/build/button/Button.resolver.mjs +0 -76
- package/build/button/Button.resolver.mjs.map +0 -1
- package/build/button/LegacyButton.js +0 -114
- package/build/button/LegacyButton.js.map +0 -1
- package/build/button/LegacyButton.mjs +0 -112
- package/build/button/LegacyButton.mjs.map +0 -1
- package/build/styles/button/Button.vars.css +0 -55
- package/build/styles/button/LegacyButton.css +0 -23
- package/build/types/button/Button.resolver.d.ts +0 -31
- package/build/types/button/Button.resolver.d.ts.map +0 -1
- package/build/types/button/Button.types.d.ts +0 -65
- package/build/types/button/Button.types.d.ts.map +0 -1
- package/build/types/button/LegacyButton.d.ts +0 -30
- package/build/types/button/LegacyButton.d.ts.map +0 -1
- package/src/button/Button.resolver.tsx +0 -120
- package/src/button/Button.types.ts +0 -86
- package/src/button/Button.vars.css +0 -55
- package/src/button/Button.vars.less +0 -69
- package/src/button/LegacyButton.css +0 -23
- package/src/button/LegacyButton.less +0 -24
- package/src/button/LegacyButton.spec.tsx +0 -146
- package/src/button/LegacyButton.story.tsx +0 -224
- package/src/button/LegacyButton.tsx +0 -161
- package/src/drawer/Drawer.rtl.spec.tsx +0 -59
- package/src/drawer/Drawer.spec.js +0 -101
- package/src/drawer/__snapshots__/Drawer.rtl.spec.tsx.snap +0 -55
package/src/link/Link.tsx
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
+
import { AnchorHTMLAttributes } from 'react';
|
|
3
4
|
import { useIntl } from 'react-intl';
|
|
4
|
-
import { PrimitiveAnchor } from '../primitives';
|
|
5
|
-
import type { PrimitiveAnchorProps } from '../primitives';
|
|
6
5
|
|
|
7
6
|
import { LinkLarge, LinkDefault } from '../common';
|
|
8
7
|
|
|
9
8
|
import messages from './Link.messages';
|
|
10
9
|
|
|
11
|
-
export type Props =
|
|
10
|
+
export type Props = AnchorHTMLAttributes<HTMLAnchorElement> & { type?: LinkLarge | LinkDefault };
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Standard Link component with navigate away icon
|
|
@@ -25,30 +24,22 @@ const Link = ({
|
|
|
25
24
|
onClick,
|
|
26
25
|
...props
|
|
27
26
|
}: Props) => {
|
|
28
|
-
const { formatMessage } = useIntl();
|
|
29
27
|
const isBlank = target === '_blank';
|
|
30
28
|
|
|
31
|
-
const
|
|
32
|
-
'np-link',
|
|
33
|
-
'd-inline-flex',
|
|
34
|
-
{
|
|
35
|
-
[`np-text-${type}`]: type,
|
|
36
|
-
},
|
|
37
|
-
className,
|
|
38
|
-
);
|
|
29
|
+
const { formatMessage } = useIntl();
|
|
39
30
|
|
|
40
31
|
return (
|
|
41
|
-
<
|
|
32
|
+
<a
|
|
42
33
|
href={href}
|
|
43
34
|
target={target}
|
|
44
|
-
className={
|
|
35
|
+
className={clsx('np-link', type ? `np-text-${type}` : undefined, 'd-inline-flex', className)}
|
|
45
36
|
aria-label={ariaLabel}
|
|
46
37
|
rel={isBlank ? 'noreferrer' : undefined}
|
|
47
38
|
onClick={onClick}
|
|
48
39
|
{...props}
|
|
49
40
|
>
|
|
50
41
|
{children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}
|
|
51
|
-
</
|
|
42
|
+
</a>
|
|
52
43
|
);
|
|
53
44
|
};
|
|
54
45
|
|
package/src/main.css
CHANGED
|
@@ -518,18 +518,10 @@ div.critical-comms .critical-comms-body {
|
|
|
518
518
|
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
519
519
|
mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
520
520
|
}
|
|
521
|
-
[dir="rtl"] .np-avatar-layout-diagonal-mask {
|
|
522
|
-
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
523
|
-
mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
524
|
-
}
|
|
525
521
|
.np-avatar-layout-diagonal-child {
|
|
526
522
|
margin-left: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
527
523
|
margin-top: calc(var(--np-avatar-layout-size) - var(--np-avatar-size));
|
|
528
524
|
}
|
|
529
|
-
[dir="rtl"] .np-avatar-layout-diagonal-child {
|
|
530
|
-
margin-left: 0;
|
|
531
|
-
margin-right: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
532
|
-
}
|
|
533
525
|
.np-avatar-layout-horizontal {
|
|
534
526
|
width: calc(var(--np-avatar-size) * 2 - var(--np-avatar-offset) - 2px);
|
|
535
527
|
height: var(--np-avatar-layout-size);
|
|
@@ -543,9 +535,6 @@ div.critical-comms .critical-comms-body {
|
|
|
543
535
|
.np-avatar-layout-horizontal-child {
|
|
544
536
|
margin-left: calc(var(--np-avatar-offset) * -1);
|
|
545
537
|
}
|
|
546
|
-
[dir="rtl"] .np-avatar-layout-horizontal-child {
|
|
547
|
-
margin-right: calc(var(--np-avatar-offset) * -1);
|
|
548
|
-
}
|
|
549
538
|
.np-icon-button {
|
|
550
539
|
border: none;
|
|
551
540
|
}
|
|
@@ -716,253 +705,6 @@ div.critical-comms .critical-comms-body {
|
|
|
716
705
|
.np-btn.disabled[class] {
|
|
717
706
|
pointer-events: auto;
|
|
718
707
|
}
|
|
719
|
-
:root {
|
|
720
|
-
--Button-background: var(--color-interactive-accent);
|
|
721
|
-
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
722
|
-
--Button-background-active: var(--color-interactive-accent-active);
|
|
723
|
-
--Button-color: var(--color-interactive-control);
|
|
724
|
-
--Button-padding: var(--size-8) var(--size-12);
|
|
725
|
-
--Button-border-radius: var(--radius-full);
|
|
726
|
-
--Button-size-small-padding: 5px var(--size-12);
|
|
727
|
-
--Button-size-medium-padding: var(--size-8) var(--size-12);
|
|
728
|
-
--Button-size-large-padding: var(--size-12) var(--size-16);
|
|
729
|
-
--Button-avatar-border-color: var(--color-border-neutral);
|
|
730
|
-
--Button-transition-duration: 150ms;
|
|
731
|
-
--Button-transition-easing: ease-in-out;
|
|
732
|
-
--Button-secondary-background: var(--color-interactive-neutral);
|
|
733
|
-
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
734
|
-
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
735
|
-
--Button-secondary-color: var(--color-interactive-primary);
|
|
736
|
-
--Button-tertiary-background: var(--color-background-neutral);
|
|
737
|
-
--Button-tertiary-background-hover: var(--color-background-neutral-hover);
|
|
738
|
-
--Button-tertiary-background-active: var(--color-background-neutral-active);
|
|
739
|
-
--Button-tertiary-color: var(--color-content-primary);
|
|
740
|
-
--Button-minimal-background: transparent;
|
|
741
|
-
--Button-minimal-background-hover: var(--color-background-screen-hover);
|
|
742
|
-
--Button-minimal-background-active: var(--color-background-screen-active);
|
|
743
|
-
--Button-minimal-color: var(--color-interactive-primary);
|
|
744
|
-
--Button-primary-negative-background: var(--color-sentiment-negative-primary);
|
|
745
|
-
--Button-primary-negative-background-hover: var(--color-sentiment-negative-primary-hover);
|
|
746
|
-
--Button-primary-negative-background-active: var(--color-sentiment-negative-primary-active);
|
|
747
|
-
--Button-primary-negative-color: var(--color-contrast);
|
|
748
|
-
--Button-primary-netative-avatar-border-color: rgba(255,255,255,0.2);
|
|
749
|
-
--Button-secondary-negative-background: var(--color-sentiment-negative-secondary);
|
|
750
|
-
--Button-secondary-negative-background-hover: var(--color-sentiment-negative-secondary-hover);
|
|
751
|
-
--Button-secondary-negative-background-active: var(--color-sentiment-negative-secondary-active);
|
|
752
|
-
--Button-secondary-negative-color: var(--color-sentiment-negative-primary);
|
|
753
|
-
--Button-secondary-netative-avatar-border-color: rgba(168,32,13,0.12157);
|
|
754
|
-
}
|
|
755
|
-
.np-theme-personal--dark .wds-Button {
|
|
756
|
-
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
757
|
-
}
|
|
758
|
-
.np-theme-personal--forest-green .wds-Button {
|
|
759
|
-
--color-interactive-neutral: rgba(159,232,112,0.2);
|
|
760
|
-
--color-interactive-neutral-hover: rgba(205,255,173,0.2);
|
|
761
|
-
--color-interactive-neutral-active: rgba(236,255,224,0.2);
|
|
762
|
-
--color-sentiment-negative-secondary: rgba(255,196,194,0.2);
|
|
763
|
-
--color-sentiment-negative-secondary-hover: rgba(255,220,219,0.2);
|
|
764
|
-
--color-sentiment-negative-secondary-active: rgba(255,235,235,0.2);
|
|
765
|
-
--Button-primary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
766
|
-
--Button-secondary-netative-avatar-border-color: rgba(14,15,12,0.12157);
|
|
767
|
-
}
|
|
768
|
-
.np-theme-personal--bright-green .wds-Button {
|
|
769
|
-
--color-contrast: #FFFFFF;
|
|
770
|
-
--Button-secondary-color: var(--color-interactive-control);
|
|
771
|
-
--Button-secondary-negative-color: var(--color-contrast);
|
|
772
|
-
--Button-secondary-netative-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
|
|
773
|
-
}
|
|
774
|
-
/* Button Styles */
|
|
775
|
-
.wds-Button {
|
|
776
|
-
display: inline-flex;
|
|
777
|
-
flex: none;
|
|
778
|
-
width: auto;
|
|
779
|
-
align-items: center;
|
|
780
|
-
justify-content: center;
|
|
781
|
-
vertical-align: middle;
|
|
782
|
-
text-align: center;
|
|
783
|
-
-webkit-text-decoration: none;
|
|
784
|
-
text-decoration: none;
|
|
785
|
-
white-space: nowrap;
|
|
786
|
-
word-wrap: break-word;
|
|
787
|
-
-webkit-appearance: none;
|
|
788
|
-
-moz-appearance: none;
|
|
789
|
-
appearance: none;
|
|
790
|
-
background-color: #00a2dd;
|
|
791
|
-
background-color: var(--Button-background);
|
|
792
|
-
border: none;
|
|
793
|
-
border-radius: 9999px;
|
|
794
|
-
border-radius: var(--Button-border-radius);
|
|
795
|
-
color: var(--Button-color);
|
|
796
|
-
cursor: pointer;
|
|
797
|
-
padding: 8px 12px;
|
|
798
|
-
padding: var(--Button-padding);
|
|
799
|
-
transition: color, background-color 150ms ease-in-out;
|
|
800
|
-
transition: color, background-color var(--Button-transition-duration) var(--Button-transition-easing);
|
|
801
|
-
}
|
|
802
|
-
.wds-Button:focus {
|
|
803
|
-
-webkit-text-decoration: none;
|
|
804
|
-
text-decoration: none;
|
|
805
|
-
}
|
|
806
|
-
.wds-Button:hover {
|
|
807
|
-
background-color: #008fc9;
|
|
808
|
-
background-color: var(--Button-background-hover);
|
|
809
|
-
-webkit-text-decoration: none;
|
|
810
|
-
text-decoration: none;
|
|
811
|
-
}
|
|
812
|
-
.wds-Button:active {
|
|
813
|
-
background-color: #0081ba;
|
|
814
|
-
background-color: var(--Button-background-active);
|
|
815
|
-
-webkit-text-decoration: none;
|
|
816
|
-
text-decoration: none;
|
|
817
|
-
}
|
|
818
|
-
.wds-Button.wds-Button--disabled,
|
|
819
|
-
.wds-Button:disabled {
|
|
820
|
-
mix-blend-mode: luminosity;
|
|
821
|
-
opacity: 0.45;
|
|
822
|
-
cursor: not-allowed;
|
|
823
|
-
}
|
|
824
|
-
.wds-Button.wds-Button--disabled:hover,
|
|
825
|
-
.wds-Button:disabled:hover,
|
|
826
|
-
.wds-Button.wds-Button--disabled:active,
|
|
827
|
-
.wds-Button:disabled:active {
|
|
828
|
-
background-color: #00a2dd;
|
|
829
|
-
background-color: var(--Button-background);
|
|
830
|
-
}
|
|
831
|
-
.wds-Button--secondary {
|
|
832
|
-
--Button-background: var(--Button-secondary-background);
|
|
833
|
-
--Button-background-hover: var(--Button-secondary-background-hover);
|
|
834
|
-
--Button-background-active: var(--Button-secondary-background-active);
|
|
835
|
-
--Button-color: var(--Button-secondary-color);
|
|
836
|
-
}
|
|
837
|
-
.wds-Button--tertiary {
|
|
838
|
-
--Button-background: var(--Button-tertiary-background);
|
|
839
|
-
--Button-background-hover: var(--Button-tertiary-background-hover);
|
|
840
|
-
--Button-background-active: var(--Button-tertiary-background-active);
|
|
841
|
-
--Button-color: var(--Button-tertiary-color);
|
|
842
|
-
}
|
|
843
|
-
.wds-Button--tertiary .wds-Button-icon--end {
|
|
844
|
-
color: var(--color-interactive-primary);
|
|
845
|
-
}
|
|
846
|
-
.wds-Button--minimal {
|
|
847
|
-
--Button-background: var(--Button-minimal-background);
|
|
848
|
-
--Button-background-hover: var(--Button-minimal-background-hover);
|
|
849
|
-
--Button-background-active: var(--Button-minimal-background-active);
|
|
850
|
-
--Button-color: var(--Button-minimal-color);
|
|
851
|
-
-webkit-text-decoration: underline;
|
|
852
|
-
text-decoration: underline;
|
|
853
|
-
text-underline-offset: 3px;
|
|
854
|
-
text-decoration-thickness: 1px;
|
|
855
|
-
}
|
|
856
|
-
.wds-Button--minimal:hover,
|
|
857
|
-
.wds-Button--minimal:hover:active {
|
|
858
|
-
-webkit-text-decoration: underline;
|
|
859
|
-
text-decoration: underline;
|
|
860
|
-
}
|
|
861
|
-
.wds-Button--negative.wds-Button--primary {
|
|
862
|
-
--Button-background: var(--Button-primary-negative-background);
|
|
863
|
-
--Button-background-hover: var(--Button-primary-negative-background-hover);
|
|
864
|
-
--Button-background-active: var(--Button-primary-negative-background-active);
|
|
865
|
-
--Button-color: var(--Button-primary-negative-color);
|
|
866
|
-
--Button-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
|
|
867
|
-
}
|
|
868
|
-
.wds-Button--negative.wds-Button--secondary {
|
|
869
|
-
--Button-background: var(--Button-secondary-negative-background);
|
|
870
|
-
--Button-background-hover: var(--Button-secondary-negative-background-hover);
|
|
871
|
-
--Button-background-active: var(--Button-secondary-negative-background-active);
|
|
872
|
-
--Button-color: var(--Button-secondary-negative-color);
|
|
873
|
-
--Button-avatar-border-color: var(--Button-secondary-netative-avatar-border-color);
|
|
874
|
-
}
|
|
875
|
-
.wds-Button--small {
|
|
876
|
-
--Button-padding: var(--Button-size-small-padding);
|
|
877
|
-
}
|
|
878
|
-
.wds-Button--small .wds-Button-icon--start {
|
|
879
|
-
margin-right: 4px;
|
|
880
|
-
margin-right: var(--size-4);
|
|
881
|
-
}
|
|
882
|
-
[dir="rtl"] .wds-Button--small .wds-Button-icon--start {
|
|
883
|
-
margin-right: 0;
|
|
884
|
-
margin-left: 4px;
|
|
885
|
-
margin-left: var(--size-4);
|
|
886
|
-
}
|
|
887
|
-
.wds-Button--medium {
|
|
888
|
-
--Button-padding: var(--Button-size-medium-padding);
|
|
889
|
-
}
|
|
890
|
-
.wds-Button--large {
|
|
891
|
-
--Button-padding: var(--Button-size-large-padding);
|
|
892
|
-
}
|
|
893
|
-
.wds-Button--block {
|
|
894
|
-
width: 100%;
|
|
895
|
-
}
|
|
896
|
-
.wds-Button-avatars {
|
|
897
|
-
display: inline-flex;
|
|
898
|
-
margin-right: 5px;
|
|
899
|
-
margin-left: calc(4px * -1);
|
|
900
|
-
margin-left: calc(var(--size-4) * -1);
|
|
901
|
-
}
|
|
902
|
-
[dir="rtl"] .wds-Button-avatars {
|
|
903
|
-
margin-right: 0;
|
|
904
|
-
margin-left: 5px;
|
|
905
|
-
}
|
|
906
|
-
.wds-Button-avatars .np-circle {
|
|
907
|
-
--circle-border-color: var(--Button-avatar-border-color);
|
|
908
|
-
}
|
|
909
|
-
.wds-Button-avatars .np-avatar-view .np-avatar-view-content {
|
|
910
|
-
color: var(--Button-color);
|
|
911
|
-
}
|
|
912
|
-
.wds-Button-icon {
|
|
913
|
-
display: inline-block;
|
|
914
|
-
}
|
|
915
|
-
.wds-Button-icon--start {
|
|
916
|
-
margin-right: 8px;
|
|
917
|
-
margin-right: var(--size-8);
|
|
918
|
-
}
|
|
919
|
-
[dir="rtl"] .wds-Button-icon--start {
|
|
920
|
-
margin-right: 0;
|
|
921
|
-
margin-left: 8px;
|
|
922
|
-
margin-left: var(--size-8);
|
|
923
|
-
}
|
|
924
|
-
.wds-Button-icon--end {
|
|
925
|
-
margin-left: 4px;
|
|
926
|
-
margin-left: var(--size-4);
|
|
927
|
-
}
|
|
928
|
-
[dir="rtl"] .wds-Button-icon--end {
|
|
929
|
-
margin-left: 0;
|
|
930
|
-
margin-right: 4px;
|
|
931
|
-
margin-right: var(--size-4);
|
|
932
|
-
}
|
|
933
|
-
.wds-Button-content {
|
|
934
|
-
position: relative;
|
|
935
|
-
}
|
|
936
|
-
.wds-Button-content--loading .wds-Button-label,
|
|
937
|
-
.wds-Button-content--loading .wds-Button-media,
|
|
938
|
-
.wds-Button-content--loading .wds-Button-icon {
|
|
939
|
-
visibility: hidden;
|
|
940
|
-
opacity: 0;
|
|
941
|
-
}
|
|
942
|
-
.wds-Button-label {
|
|
943
|
-
display: flex;
|
|
944
|
-
justify-content: center;
|
|
945
|
-
align-items: center;
|
|
946
|
-
position: relative;
|
|
947
|
-
}
|
|
948
|
-
.wds-Button-loader {
|
|
949
|
-
position: absolute;
|
|
950
|
-
display: flex;
|
|
951
|
-
justify-content: center;
|
|
952
|
-
align-items: center;
|
|
953
|
-
width: 100%;
|
|
954
|
-
height: 100%;
|
|
955
|
-
}
|
|
956
|
-
.wds-Button-loader .process-circle {
|
|
957
|
-
stroke: var(--Button-color);
|
|
958
|
-
}
|
|
959
|
-
/* RTL Styles */
|
|
960
|
-
[dir="rtl"] .wds-Button .tw-icon-chevron-right,[dir="rtl"] .wds-Button .tw-icon-arrow-right {
|
|
961
|
-
transform: rotate(180deg);
|
|
962
|
-
}
|
|
963
|
-
[dir="rtl"] .wds-Button .tw-icon-chevron-left,[dir="rtl"] .wds-Button .tw-icon-arrow-left {
|
|
964
|
-
transform: rotate(180deg);
|
|
965
|
-
}
|
|
966
708
|
.np-card {
|
|
967
709
|
overflow: hidden;
|
|
968
710
|
transition-property: transform, box-shadow;
|
package/src/main.less
CHANGED
|
@@ -30,7 +30,13 @@ const PrimitiveAnchor = forwardRef<HTMLAnchorElement, PrimitiveAnchorProps>(
|
|
|
30
30
|
},
|
|
31
31
|
ref,
|
|
32
32
|
) => {
|
|
33
|
-
const anchorClasses = clsx(
|
|
33
|
+
const anchorClasses = clsx(
|
|
34
|
+
'wds-Anchor',
|
|
35
|
+
{
|
|
36
|
+
'wds-Anchor--disabled': disabled,
|
|
37
|
+
},
|
|
38
|
+
className,
|
|
39
|
+
);
|
|
34
40
|
|
|
35
41
|
const handleClick = useCallback(
|
|
36
42
|
(event: React.MouseEvent<HTMLAnchorElement>) => {
|
|
@@ -18,16 +18,11 @@ export interface PrimitiveAnchorProps
|
|
|
18
18
|
children?: ReactNode;
|
|
19
19
|
|
|
20
20
|
/** The URL to navigate to when the anchor is clicked */
|
|
21
|
-
href
|
|
21
|
+
href: string;
|
|
22
22
|
|
|
23
23
|
/** Disable the anchor */
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
|
|
26
26
|
/** Reference to the anchor element */
|
|
27
27
|
ref?: PrimitiveAnchorElementRef;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* HTML anchor `target` attribute. If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
|
|
31
|
-
*/
|
|
32
|
-
target?: HTMLAnchorElement['target'];
|
|
33
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import PrimitiveAnchor from '
|
|
2
|
+
import PrimitiveAnchor from '..';
|
|
3
3
|
|
|
4
4
|
describe('PrimitiveAnchor', () => {
|
|
5
5
|
const defaultProps = {
|
|
@@ -27,6 +27,7 @@ describe('PrimitiveAnchor', () => {
|
|
|
27
27
|
renderAnchor(props);
|
|
28
28
|
|
|
29
29
|
const link = screen.getByRole('link');
|
|
30
|
+
expect(link).toHaveClass('wds-Anchor');
|
|
30
31
|
expect(link).toHaveClass('custom-class');
|
|
31
32
|
});
|
|
32
33
|
|
|
@@ -40,6 +41,7 @@ describe('PrimitiveAnchor', () => {
|
|
|
40
41
|
|
|
41
42
|
const link = screen.getByRole('link');
|
|
42
43
|
expect(link).toHaveAttribute('aria-disabled', 'true');
|
|
44
|
+
expect(link).toHaveClass('wds-Anchor--disabled');
|
|
43
45
|
expect(link).not.toHaveAttribute('href', 'https://example.com');
|
|
44
46
|
});
|
|
45
47
|
|
|
@@ -35,7 +35,14 @@ const PrimitiveButton = forwardRef<HTMLButtonElement, PrimitiveButtonProps>(
|
|
|
35
35
|
ref,
|
|
36
36
|
) => {
|
|
37
37
|
const intl = useIntl();
|
|
38
|
-
const classNames = clsx(
|
|
38
|
+
const classNames = clsx(
|
|
39
|
+
'wds-Button',
|
|
40
|
+
{
|
|
41
|
+
'wds-Button--disabled': disabled,
|
|
42
|
+
'wds-Button--loading': loading,
|
|
43
|
+
},
|
|
44
|
+
className,
|
|
45
|
+
);
|
|
39
46
|
|
|
40
47
|
const handleClick = useCallback(
|
|
41
48
|
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { screen } from '@testing-library/react';
|
|
2
|
-
import
|
|
1
|
+
import { fireEvent, screen } from '@testing-library/react';
|
|
2
|
+
import { userEvent } from '@testing-library/user-event';
|
|
3
|
+
import PrimitiveButton from '..';
|
|
3
4
|
import messages from '../../../i18n/commonMessages/Button.messages';
|
|
4
5
|
import { render } from '../../../test-utils';
|
|
5
6
|
|
|
@@ -35,6 +36,7 @@ describe('Button', () => {
|
|
|
35
36
|
renderButton(props);
|
|
36
37
|
|
|
37
38
|
const button = screen.getByRole('button');
|
|
39
|
+
expect(button).toHaveClass('wds-Button');
|
|
38
40
|
expect(button).toHaveClass('custom-class');
|
|
39
41
|
});
|
|
40
42
|
|
|
@@ -47,6 +49,7 @@ describe('Button', () => {
|
|
|
47
49
|
renderButton(props);
|
|
48
50
|
|
|
49
51
|
const button = screen.getByRole('button');
|
|
52
|
+
expect(button).toHaveClass('wds-Button--disabled');
|
|
50
53
|
expect(button).toBeDisabled();
|
|
51
54
|
});
|
|
52
55
|
|
package/src/select/Select.tsx
CHANGED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var LegacyButton = require('./LegacyButton.js');
|
|
5
|
-
var Button$1 = require('./Button.js');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
|
|
8
|
-
const mapProps = props => {
|
|
9
|
-
const {
|
|
10
|
-
priority,
|
|
11
|
-
size,
|
|
12
|
-
type,
|
|
13
|
-
as,
|
|
14
|
-
...newProps
|
|
15
|
-
} = props;
|
|
16
|
-
const priorityMapping = {
|
|
17
|
-
accent: {
|
|
18
|
-
primary: 'primary',
|
|
19
|
-
secondary: 'tertiary',
|
|
20
|
-
tertiary: 'minimal'
|
|
21
|
-
},
|
|
22
|
-
positive: {
|
|
23
|
-
primary: 'primary',
|
|
24
|
-
secondary: 'tertiary',
|
|
25
|
-
tertiary: 'tertiary'
|
|
26
|
-
},
|
|
27
|
-
negative: {
|
|
28
|
-
primary: 'primary',
|
|
29
|
-
secondary: 'secondary',
|
|
30
|
-
tertiary: 'secondary'
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
34
|
-
const mappedSentiment = type === 'negative' ? 'negative' : undefined;
|
|
35
|
-
const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
|
|
36
|
-
const resolveSize = () => {
|
|
37
|
-
if (size) {
|
|
38
|
-
return {
|
|
39
|
-
xs: 'sm',
|
|
40
|
-
sm: 'sm',
|
|
41
|
-
md: 'md',
|
|
42
|
-
lg: 'lg'
|
|
43
|
-
}[size] || size;
|
|
44
|
-
}
|
|
45
|
-
return size;
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
...newProps,
|
|
49
|
-
size: resolveSize(),
|
|
50
|
-
priority: mappedPriority,
|
|
51
|
-
sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
|
|
52
|
-
type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
|
|
53
|
-
href: as === 'a' ? props.href || '' : null
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
57
|
-
const {
|
|
58
|
-
v2 = false,
|
|
59
|
-
as,
|
|
60
|
-
...rest
|
|
61
|
-
} = props;
|
|
62
|
-
if (v2) {
|
|
63
|
-
const mappedProps = mapProps(props);
|
|
64
|
-
return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
65
|
-
...mappedProps,
|
|
66
|
-
ref: ref,
|
|
67
|
-
as: as
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return /*#__PURE__*/jsxRuntime.jsx(LegacyButton, {
|
|
71
|
-
...rest,
|
|
72
|
-
ref: ref
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
Button.displayName = 'Button';
|
|
76
|
-
|
|
77
|
-
module.exports = Button;
|
|
78
|
-
//# sourceMappingURL=Button.resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.resolver.js","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { LegacyButtonProps } from './LegacyButton';\nimport { ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\ntype LegacyButtonType =\n | 'accent'\n | 'negative'\n | 'positive'\n | 'primary'\n | 'pay'\n | 'secondary'\n | 'danger'\n | 'link'\n | null\n | undefined;\n\ntype NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;\n\ntype CommonButtonProps = {\n href?: string;\n target?: string;\n ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n};\n\nexport type ButtonProps =\n | (Omit<LegacyButtonProps, 'ref'> &\n CommonButtonProps & {\n priority?: LegacyButtonProps['priority'];\n type?: LegacyButtonType;\n htmlType?: string;\n v2?: false;\n })\n | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &\n CommonButtonProps & {\n priority?: NewButtonProps['priority'];\n type?: NewButtonType;\n v2: true;\n });\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonType[] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type:\n type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,\n href: as === 'a' ? props.href || '' : null,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {\n const { v2 = false, as, ...rest } = props;\n\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return (\n <NewButton\n {...mappedProps}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n as={as}\n />\n );\n }\n\n return (\n <LegacyButton\n {...(rest as LegacyButtonProps)}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n />\n );\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","href","Button","forwardRef","ref","v2","rest","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;;;AAwCA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGC,QAAAA;AAAU,GAAA,GAAGL,KAAK,CAAA;AAEvD,EAAA,MAAMM,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAA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C,IAAI,EAAErB,EAAE,KAAK,GAAG,GAAGJ,KAAK,CAACyB,IAAI,IAAI,EAAE,GAAG,IAAA;GACrB,CAAA;AACrB,CAAC,CAAA;AAEKC,MAAAA,MAAM,gBAAGC,gBAAU,CAAqD,CAAC3B,KAAK,EAAE4B,GAAG,KAAI;EAC3F,MAAM;AAAEC,IAAAA,EAAE,GAAG,KAAK;IAAEzB,EAAE;IAAE,GAAG0B,IAAAA;AAAI,GAAE,GAAG9B,KAAK,CAAA;AAEzC,EAAA,IAAI6B,EAAE,EAAE;AACN,IAAA,MAAME,WAAW,GAAGhC,QAAQ,CAACC,KAA0B,CAAC,CAAA;IACxD,oBACEgC,cAAA,CAACC,QAAS,EAAA;AAAA,MAAA,GACJF,WAAW;AACfH,MAAAA,GAAG,EAAEA,GAAwD;AAC7DxB,MAAAA,EAAE,EAAEA,EAAAA;AAAG,KACP,CAAA,CAAA;AAEN,GAAA;EAEA,oBACE4B,cAAA,CAACE,YAAY,EAAA;AAAA,IAAA,GACNJ,IAA0B;AAC/BF,IAAAA,GAAG,EAAEA,GAAAA;AAAwD,GAAA,CAC7D,CAAA;AAEN,CAAC,EAAC;AAEFF,MAAM,CAACS,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import LegacyButton from './LegacyButton.mjs';
|
|
3
|
-
import Button$1 from './Button.mjs';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
const mapProps = props => {
|
|
7
|
-
const {
|
|
8
|
-
priority,
|
|
9
|
-
size,
|
|
10
|
-
type,
|
|
11
|
-
as,
|
|
12
|
-
...newProps
|
|
13
|
-
} = props;
|
|
14
|
-
const priorityMapping = {
|
|
15
|
-
accent: {
|
|
16
|
-
primary: 'primary',
|
|
17
|
-
secondary: 'tertiary',
|
|
18
|
-
tertiary: 'minimal'
|
|
19
|
-
},
|
|
20
|
-
positive: {
|
|
21
|
-
primary: 'primary',
|
|
22
|
-
secondary: 'tertiary',
|
|
23
|
-
tertiary: 'tertiary'
|
|
24
|
-
},
|
|
25
|
-
negative: {
|
|
26
|
-
primary: 'primary',
|
|
27
|
-
secondary: 'secondary',
|
|
28
|
-
tertiary: 'secondary'
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
|
|
32
|
-
const mappedSentiment = type === 'negative' ? 'negative' : undefined;
|
|
33
|
-
const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
|
|
34
|
-
const resolveSize = () => {
|
|
35
|
-
if (size) {
|
|
36
|
-
return {
|
|
37
|
-
xs: 'sm',
|
|
38
|
-
sm: 'sm',
|
|
39
|
-
md: 'md',
|
|
40
|
-
lg: 'lg'
|
|
41
|
-
}[size] || size;
|
|
42
|
-
}
|
|
43
|
-
return size;
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
...newProps,
|
|
47
|
-
size: resolveSize(),
|
|
48
|
-
priority: mappedPriority,
|
|
49
|
-
sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
|
|
50
|
-
type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
|
|
51
|
-
href: as === 'a' ? props.href || '' : null
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
const Button = /*#__PURE__*/forwardRef((props, ref) => {
|
|
55
|
-
const {
|
|
56
|
-
v2 = false,
|
|
57
|
-
as,
|
|
58
|
-
...rest
|
|
59
|
-
} = props;
|
|
60
|
-
if (v2) {
|
|
61
|
-
const mappedProps = mapProps(props);
|
|
62
|
-
return /*#__PURE__*/jsx(Button$1, {
|
|
63
|
-
...mappedProps,
|
|
64
|
-
ref: ref,
|
|
65
|
-
as: as
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return /*#__PURE__*/jsx(LegacyButton, {
|
|
69
|
-
...rest,
|
|
70
|
-
ref: ref
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
Button.displayName = 'Button';
|
|
74
|
-
|
|
75
|
-
export { Button as default };
|
|
76
|
-
//# sourceMappingURL=Button.resolver.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.resolver.mjs","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { LegacyButtonProps } from './LegacyButton';\nimport { ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\ntype LegacyButtonType =\n | 'accent'\n | 'negative'\n | 'positive'\n | 'primary'\n | 'pay'\n | 'secondary'\n | 'danger'\n | 'link'\n | null\n | undefined;\n\ntype NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;\n\ntype CommonButtonProps = {\n href?: string;\n target?: string;\n ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;\n};\n\nexport type ButtonProps =\n | (Omit<LegacyButtonProps, 'ref'> &\n CommonButtonProps & {\n priority?: LegacyButtonProps['priority'];\n type?: LegacyButtonType;\n htmlType?: string;\n v2?: false;\n })\n | (Omit<Omit<NewButtonProps, 'type'>, 'ref'> &\n CommonButtonProps & {\n priority?: NewButtonProps['priority'];\n type?: NewButtonType;\n v2: true;\n });\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, as, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonType[] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type:\n type && !legacyButtonTypes.includes(type as LegacyButtonType) ? type : props.htmlType || null,\n href: as === 'a' ? props.href || '' : null,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>((props, ref) => {\n const { v2 = false, as, ...rest } = props;\n\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return (\n <NewButton\n {...mappedProps}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n as={as}\n />\n );\n }\n\n return (\n <LegacyButton\n {...(rest as LegacyButtonProps)}\n ref={ref as React.Ref<HTMLButtonElement | HTMLAnchorElement>}\n />\n );\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","as","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","href","Button","forwardRef","ref","v2","rest","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;AAwCA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGC,QAAAA;AAAU,GAAA,GAAGL,KAAK,CAAA;AAEvD,EAAA,MAAMM,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,E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