@transferwise/components 0.0.0-experimental-6f38fd8 → 0.0.0-experimental-37df6fe

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 (110) hide show
  1. package/build/flowNavigation/animatedLabel/AnimatedLabel.js +1 -1
  2. package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
  3. package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +1 -1
  4. package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
  5. package/build/index.js +4 -3
  6. package/build/index.js.map +1 -1
  7. package/build/index.mjs +3 -3
  8. package/build/listItem/List.js.map +1 -0
  9. package/build/listItem/List.mjs.map +1 -0
  10. package/build/{legacylistItem/LegacyListItem.js → listItem/ListItem.js} +3 -3
  11. package/build/listItem/ListItem.js.map +1 -0
  12. package/build/{legacylistItem/LegacyListItem.mjs → listItem/ListItem.mjs} +3 -3
  13. package/build/listItem/ListItem.mjs.map +1 -0
  14. package/build/main.css +185 -3
  15. package/build/phoneNumberInput/PhoneNumberInput.js +1 -1
  16. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  17. package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -1
  18. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  19. package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js +2 -2
  20. package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js.map +1 -1
  21. package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs +2 -2
  22. package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs.map +1 -1
  23. package/build/styles/item/Item.css +185 -0
  24. package/build/styles/main.css +185 -3
  25. package/build/styles/switch/Switch.css +0 -3
  26. package/build/test-utils/assets/apple-pay-logo.svg +84 -0
  27. package/build/types/index.d.ts +4 -2
  28. package/build/types/index.d.ts.map +1 -1
  29. package/build/types/item/Item.d.ts +43 -0
  30. package/build/types/item/Item.d.ts.map +1 -0
  31. package/build/types/item/ItemAdditionalInfo.d.ts +9 -0
  32. package/build/types/item/ItemAdditionalInfo.d.ts.map +1 -0
  33. package/build/types/item/ItemButton.d.ts +4 -0
  34. package/build/types/item/ItemButton.d.ts.map +1 -0
  35. package/build/types/item/ItemCheckbox.d.ts +4 -0
  36. package/build/types/item/ItemCheckbox.d.ts.map +1 -0
  37. package/build/types/item/ItemIconButton.d.ts +7 -0
  38. package/build/types/item/ItemIconButton.d.ts.map +1 -0
  39. package/build/types/item/ItemMedia.d.ts +19 -0
  40. package/build/types/item/ItemMedia.d.ts.map +1 -0
  41. package/build/types/item/ItemNavigation.d.ts +4 -0
  42. package/build/types/item/ItemNavigation.d.ts.map +1 -0
  43. package/build/types/item/ItemSwitch.d.ts +3 -0
  44. package/build/types/item/ItemSwitch.d.ts.map +1 -0
  45. package/build/types/item/index.d.ts +6 -0
  46. package/build/types/item/index.d.ts.map +1 -0
  47. package/build/types/item/prompt/Prompt.d.ts +12 -0
  48. package/build/types/item/prompt/Prompt.d.ts.map +1 -0
  49. package/build/types/item/useItemControl.d.ts +5 -0
  50. package/build/types/item/useItemControl.d.ts.map +1 -0
  51. package/build/types/listItem/List.d.ts.map +1 -0
  52. package/build/types/{legacylistItem/LegacyListItem.d.ts → listItem/ListItem.d.ts} +4 -4
  53. package/build/types/listItem/ListItem.d.ts.map +1 -0
  54. package/build/types/listItem/index.d.ts +5 -0
  55. package/build/types/listItem/index.d.ts.map +1 -0
  56. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts +2 -2
  57. package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts.map +1 -1
  58. package/build/types/test-utils/fake-data.d.ts +2 -0
  59. package/build/types/test-utils/fake-data.d.ts.map +1 -1
  60. package/package.json +3 -3
  61. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
  62. package/src/index.ts +4 -2
  63. package/src/item/Item.css +185 -0
  64. package/src/item/Item.less +178 -0
  65. package/src/item/Item.story.tsx +188 -0
  66. package/src/item/Item.tsx +174 -0
  67. package/src/item/ItemAdditionalInfo.tsx +31 -0
  68. package/src/item/ItemButton.spec.tsx +90 -0
  69. package/src/item/ItemButton.tsx +18 -0
  70. package/src/item/ItemCheckbox.tsx +11 -0
  71. package/src/item/ItemIconButton.tsx +13 -0
  72. package/src/item/ItemMedia.tsx +52 -0
  73. package/src/item/ItemNavigation.tsx +11 -0
  74. package/src/item/ItemSwitch.tsx +8 -0
  75. package/src/item/index.ts +6 -0
  76. package/src/item/prompt/Prompt.spec.tsx +77 -0
  77. package/src/item/prompt/Prompt.story.tsx +170 -0
  78. package/src/item/prompt/Prompt.tsx +44 -0
  79. package/src/item/useItemControl.tsx +12 -0
  80. package/src/{legacylistItem/LegacyListItem.tests.story.tsx → listItem/ListItem.tests.story.tsx} +2 -2
  81. package/src/{legacylistItem/LegacyListItem.tsx → listItem/ListItem.tsx} +3 -3
  82. package/src/listItem/index.ts +4 -0
  83. package/src/main.css +185 -3
  84. package/src/main.less +2 -1
  85. package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +4 -4
  86. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +0 -22
  87. package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
  88. package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts +3 -4
  89. package/src/switch/Switch.css +0 -3
  90. package/src/switch/Switch.less +0 -1
  91. package/src/test-utils/assets/apple-pay-logo.svg +84 -0
  92. package/src/test-utils/fake-data.ts +5 -0
  93. package/build/legacylistItem/LegacyListItem.js.map +0 -1
  94. package/build/legacylistItem/LegacyListItem.mjs.map +0 -1
  95. package/build/legacylistItem/List.js.map +0 -1
  96. package/build/legacylistItem/List.mjs.map +0 -1
  97. package/build/types/legacylistItem/LegacyListItem.d.ts.map +0 -1
  98. package/build/types/legacylistItem/List.d.ts.map +0 -1
  99. package/build/types/legacylistItem/index.d.ts +0 -5
  100. package/build/types/legacylistItem/index.d.ts.map +0 -1
  101. package/src/legacylistItem/index.ts +0 -4
  102. /package/build/{legacylistItem → listItem}/List.js +0 -0
  103. /package/build/{legacylistItem → listItem}/List.mjs +0 -0
  104. /package/build/styles/{legacylistItem/LegacyListItem.css → listItem/ListItem.css} +0 -0
  105. /package/build/types/{legacylistItem → listItem}/List.d.ts +0 -0
  106. /package/src/{legacylistItem → listItem}/List.tsx +0 -0
  107. /package/src/{legacylistItem/LegacyListItem.css → listItem/ListItem.css} +0 -0
  108. /package/src/{legacylistItem/LegacyListItem.less → listItem/ListItem.less} +0 -0
  109. /package/src/{legacylistItem/LegacyListItem.spec.tsx → listItem/ListItem.spec.tsx} +0 -0
  110. /package/src/{legacylistItem/LegacyListItem.story.tsx → listItem/ListItem.story.tsx} +0 -0
@@ -0,0 +1,170 @@
1
+ import Link from '../../link';
2
+ import { Sentiment } from '../../common';
3
+ import { ItemPrompt, ItemPromptProps } from './Prompt';
4
+ import { lorem40 } from '../../test-utils';
5
+ import { StoryObj } from '@storybook/react';
6
+
7
+ export default {
8
+ component: ItemPrompt,
9
+ title: 'Content/Item/Prompt',
10
+ args: {
11
+ type: Sentiment.NEGATIVE,
12
+ children: 'You have done a terrible thing',
13
+ },
14
+ argTypes: {
15
+ type: {
16
+ options: [
17
+ Sentiment.POSITIVE,
18
+ Sentiment.NEGATIVE,
19
+ Sentiment.NEUTRAL,
20
+ Sentiment.WARNING,
21
+ 'discount',
22
+ 'savings',
23
+ ],
24
+ control: { type: 'radio' },
25
+ description: 'The type of prompt to display',
26
+ },
27
+ action: {
28
+ table: {
29
+ disable: true,
30
+ },
31
+ },
32
+ children: {
33
+ type: {
34
+ name: 'string',
35
+ required: true,
36
+ description: 'The content of the prompt',
37
+ },
38
+ },
39
+ },
40
+ };
41
+
42
+ type CustomStory = StoryObj<
43
+ ItemPromptProps & {
44
+ interactivity?: 'none' | 'full-anchor' | 'full-button' | 'link';
45
+ }
46
+ >;
47
+
48
+ export const Basic: CustomStory = {
49
+ args: {
50
+ interactivity: 'none',
51
+ },
52
+ argTypes: {
53
+ interactivity: {
54
+ options: ['none', 'full-button', 'full-anchor', 'link'],
55
+ control: { type: 'radio' },
56
+ description: 'The type of interactivity to display',
57
+ },
58
+ },
59
+ render: ({ interactivity, ...args }) => {
60
+ return (
61
+ <div>
62
+ <ItemPrompt
63
+ type={args.type}
64
+ action={
65
+ interactivity === 'full-anchor'
66
+ ? { href: 'wise.com' }
67
+ : interactivity === 'full-button'
68
+ ? {
69
+ onClick: () => {
70
+ console.log('clicked');
71
+ },
72
+ }
73
+ : undefined
74
+ }
75
+ >
76
+ {args.children} {interactivity === 'link' && <Link href="www.wise.com">with a link</Link>}
77
+ </ItemPrompt>
78
+ </div>
79
+ );
80
+ },
81
+ };
82
+
83
+ export const Variants = () => {
84
+ return (
85
+ <>
86
+ <div className="m-b-2">
87
+ <ItemPrompt type={Sentiment.POSITIVE}>
88
+ Positive prompt <Link href="www.wise.com">with a link to amazing content</Link>
89
+ </ItemPrompt>
90
+ </div>
91
+ <div className="m-b-2">
92
+ <ItemPrompt type={Sentiment.NEGATIVE}>
93
+ Negative prompt <Link href="www.wise.com">with a link to amazing content</Link>
94
+ </ItemPrompt>
95
+ </div>
96
+ <div className="m-b-2">
97
+ <ItemPrompt type={Sentiment.NEUTRAL}>
98
+ Neutral prompt <Link href="www.wise.com">with a link to amazing content</Link>
99
+ </ItemPrompt>
100
+ </div>
101
+ <div className="m-b-2">
102
+ <ItemPrompt type={Sentiment.WARNING}>
103
+ Warning prompt <Link href="www.wise.com">with a link to amazing content</Link>
104
+ </ItemPrompt>
105
+ </div>
106
+ <div className="m-b-2">
107
+ <ItemPrompt type="discount">
108
+ Discount prompt <Link href="www.wise.com">with a link to amazing content</Link>
109
+ </ItemPrompt>
110
+ </div>
111
+ <div className="m-b-2">
112
+ <ItemPrompt type="savings">
113
+ Savings prompt <Link href="www.wise.com">with a link to amazing content</Link>
114
+ </ItemPrompt>
115
+ </div>
116
+ <div className="m-b-2">
117
+ <ItemPrompt
118
+ type="discount"
119
+ action={{
120
+ href: 'www.wise.com',
121
+ target: '_self',
122
+ 'aria-label': 'hidden anchor tags are accessible, right?',
123
+ }}
124
+ >
125
+ The whole prompt is secretly clickable
126
+ </ItemPrompt>
127
+ </div>
128
+ <div className="m-b-2">
129
+ <ItemPrompt
130
+ type="negative"
131
+ action={{
132
+ href: 'www.wise.com',
133
+ target: '_self',
134
+ 'aria-label': 'clickable <a>',
135
+ }}
136
+ >
137
+ The whole prompt is secretly clickable as an anchor tag
138
+ </ItemPrompt>
139
+ </div>
140
+ <div className="m-b-2">
141
+ <ItemPrompt
142
+ type="warning"
143
+ action={{
144
+ onClick: () => {
145
+ console.log('clicked');
146
+ },
147
+ 'aria-label': 'clickable button',
148
+ }}
149
+ >
150
+ The whole prompt is secretly clickable as a button
151
+ </ItemPrompt>
152
+ </div>
153
+ <div className="m-b-2">
154
+ <ItemPrompt
155
+ type="neutral"
156
+ action={{
157
+ href: 'www.wise.com',
158
+ target: '_self',
159
+ 'aria-label': 'clickable prompt',
160
+ }}
161
+ >
162
+ The whole prompt is secretly clickable
163
+ </ItemPrompt>
164
+ </div>
165
+ <div className="m-b-2" style={{ maxWidth: '300px' }}>
166
+ <ItemPrompt type="warning">The prompt has very long text that wraps {lorem40}</ItemPrompt>
167
+ </div>
168
+ </>
169
+ );
170
+ };
@@ -0,0 +1,44 @@
1
+ import { Confetti, Tags } from '@transferwise/icons';
2
+ import { Sentiment } from '../../common';
3
+ import StatusIcon from '../../statusIcon';
4
+ import { clsx } from 'clsx';
5
+ import { LinkProps } from '../../link';
6
+ import Body from '../../body';
7
+
8
+ export type ItemPromptProps = {
9
+ type:
10
+ | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`
11
+ | 'discount'
12
+ | 'savings';
13
+ children: React.ReactNode;
14
+ action?: Pick<LinkProps, 'href' | 'target' | 'onClick'> & { 'aria-label'?: string };
15
+ };
16
+
17
+ export const ItemPrompt = ({ type, children, action }: ItemPromptProps) => {
18
+ const Wrapper = action?.href ? 'a' : action?.onClick ? 'button' : 'span';
19
+
20
+ const icon =
21
+ type === 'discount' ? (
22
+ <Tags size={16} />
23
+ ) : type === 'savings' ? (
24
+ <Confetti size={16} />
25
+ ) : (
26
+ <StatusIcon size={16} sentiment={type} />
27
+ );
28
+
29
+ return (
30
+ <Wrapper
31
+ className={clsx(
32
+ 'np-item-prompt',
33
+ type,
34
+ (action?.href || action?.onClick) && 'np-prompt-interactive',
35
+ )}
36
+ {...(action ?? {})}
37
+ >
38
+ <div className="np-prompt-icon">{icon}</div>
39
+ <Body>{children}</Body>
40
+ </Wrapper>
41
+ );
42
+ };
43
+
44
+ export default ItemPrompt;
@@ -0,0 +1,12 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import { ItemContext, ItemContextData, ItemTypes } from './Item';
3
+
4
+ export function useItemControl(controlType: ItemTypes) {
5
+ const { setControlType, props: baseItemProps } = useContext<ItemContextData>(ItemContext);
6
+
7
+ useEffect(() => {
8
+ setControlType(controlType);
9
+ }, [controlType, setControlType]);
10
+
11
+ return { baseItemProps };
12
+ }
@@ -1,7 +1,7 @@
1
1
  import { FastFlag } from '@transferwise/icons';
2
2
  import Button from '../button';
3
3
  import AvatarView from '../avatarView';
4
- import ListItem, { List, type LegacyListItemProps } from '.';
4
+ import ListItem, { List, type ListItemProps } from '.';
5
5
 
6
6
  export default {
7
7
  component: ListItem,
@@ -9,7 +9,7 @@ export default {
9
9
  };
10
10
 
11
11
  export const LongText = () => {
12
- const sharedProps: Partial<LegacyListItemProps> = {
12
+ const sharedProps: Partial<ListItemProps> = {
13
13
  media: <AvatarView profileName="Super Pepa" badge={{ icon: <FastFlag /> }} />,
14
14
  action: (
15
15
  <Button v2 size="sm" onClick={() => {}}>
@@ -3,7 +3,7 @@ import { ElementType, FC, ReactNode } from 'react';
3
3
 
4
4
  import Body from '../body/Body';
5
5
 
6
- export type LegacyListItemProps = {
6
+ export type ListItemProps = {
7
7
  title: ReactNode;
8
8
  value: ReactNode;
9
9
  media?: ReactNode;
@@ -13,7 +13,7 @@ export type LegacyListItemProps = {
13
13
  as?: ElementType;
14
14
  };
15
15
 
16
- const LegacyListItem: FC<LegacyListItemProps> = ({
16
+ const ListItem: FC<ListItemProps> = ({
17
17
  media,
18
18
  action,
19
19
  className,
@@ -50,4 +50,4 @@ const LegacyListItem: FC<LegacyListItemProps> = ({
50
50
  );
51
51
  };
52
52
 
53
- export default LegacyListItem;
53
+ export default ListItem;
@@ -0,0 +1,4 @@
1
+ export { List } from './List';
2
+ export type { ListProps } from './List';
3
+ export { default } from './ListItem';
4
+ export type { ListItemProps } from './ListItem';
package/src/main.css CHANGED
@@ -2648,6 +2648,191 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2648
2648
  border-radius: 9999px !important;
2649
2649
  border-radius: var(--radius-full) !important;
2650
2650
  }
2651
+ .np-item {
2652
+ padding: 16px;
2653
+ padding: var(--size-16);
2654
+ border-radius: 24px;
2655
+ border-radius: var(--radius-large);
2656
+ background-color: #ffffff;
2657
+ background-color: var(--color-background-screen);
2658
+ gap: 16px;
2659
+ gap: var(--size-16);
2660
+ }
2661
+ .np-item-interactive {
2662
+ cursor: pointer;
2663
+ }
2664
+ .np-item-interactive:hover {
2665
+ background-color: var(--color-background-screen-hover);
2666
+ }
2667
+ .np-item-interactive:active {
2668
+ background-color: var(--color-background-screen-active);
2669
+ }
2670
+ .np-item-media-image {
2671
+ width: var(--item-media-image-size);
2672
+ height: var(--item-media-image-size);
2673
+ }
2674
+ .np-item-title {
2675
+ color: #37517e;
2676
+ color: var(--color-content-primary);
2677
+ }
2678
+ .np-item-additional-info {
2679
+ color: #768e9c;
2680
+ color: var(--color-content-tertiary);
2681
+ }
2682
+ .np-item-value {
2683
+ flex: 0 0 auto;
2684
+ }
2685
+ .np-item-control {
2686
+ flex: 0 0 auto;
2687
+ }
2688
+ .np-item-spotlight-active {
2689
+ background-color: rgba(134,167,189,0.10196);
2690
+ background-color: var(--color-background-neutral);
2691
+ }
2692
+ .np-item-spotlight-active:hover {
2693
+ background-color: var(--color-background-neutral-hover);
2694
+ }
2695
+ .np-item-spotlight-active:active {
2696
+ background-color: var(--color-background-neutral-active);
2697
+ }
2698
+ .np-item-spotlight-inactive {
2699
+ background-color: rgba(134, 167, 189, 0.025);
2700
+ border: 1px dashed rgba(0,0,0,0.10196);
2701
+ border: 1px dashed var(--color-border-neutral);
2702
+ }
2703
+ @supports (color: color-mix(in lch, red, blue)) {
2704
+ .np-item-spotlight-inactive {
2705
+ background-color: color-mix(in srgb, var(--color-background-neutral) 25%, transparent);
2706
+ }
2707
+ }
2708
+ .np-item-spotlight-inactive:hover {
2709
+ background-color: color-mix(in srgb, var(--color-background-neutral-hover) 25%, transparent);
2710
+ }
2711
+ .np-item-spotlight-inactive:active {
2712
+ background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
2713
+ }
2714
+ .np-item-prompt {
2715
+ display: inline-flex;
2716
+ padding-top: calc(8px / 2);
2717
+ padding-top: calc(var(--padding-x-small) / 2);
2718
+ padding-bottom: calc(8px / 2);
2719
+ padding-bottom: calc(var(--padding-x-small) / 2);
2720
+ padding-left: calc(8px - 1px);
2721
+ padding-left: calc(var(--padding-x-small) - 1px);
2722
+ padding-right: 8px;
2723
+ padding-right: var(--padding-x-small);
2724
+ border-radius: 10px;
2725
+ border-radius: var(--radius-small);
2726
+ word-break: break-word;
2727
+ word-wrap: break-word;
2728
+ }
2729
+ .np-item-prompt .np-prompt-icon {
2730
+ padding-right: calc(12px / 2);
2731
+ padding-right: calc(var(--size-12) / 2);
2732
+ padding-top: calc(4px - 1px);
2733
+ padding-top: calc(var(--size-4) - 1px);
2734
+ padding-bottom: calc(4px - 1px);
2735
+ padding-bottom: calc(var(--size-4) - 1px);
2736
+ }
2737
+ .np-item-prompt .np-prompt-icon .tw-icon-tags,
2738
+ .np-item-prompt .np-prompt-icon .tw-icon-confetti {
2739
+ color: var(--color-sentiment-positive-primary);
2740
+ }
2741
+ .np-item-prompt a {
2742
+ text-underline-offset: calc(4px / 2);
2743
+ text-underline-offset: calc(var(--size-4) / 2);
2744
+ }
2745
+ .np-item-prompt.np-prompt-interactive {
2746
+ -webkit-text-decoration: none;
2747
+ text-decoration: none;
2748
+ cursor: pointer;
2749
+ border: none;
2750
+ }
2751
+ .np-item-prompt.negative {
2752
+ background-color: var(--color-sentiment-negative-secondary);
2753
+ color: var(--color-sentiment-negative-primary);
2754
+ }
2755
+ .np-item-prompt.negative a {
2756
+ color: var(--color-sentiment-negative-primary);
2757
+ }
2758
+ .np-item-prompt.negative a:hover {
2759
+ color: var(--color-sentiment-negative-primary-hover);
2760
+ }
2761
+ .np-item-prompt.negative a:active {
2762
+ color: var(--color-sentiment-negative-primary-active);
2763
+ }
2764
+ .np-prompt-interactive.np-item-prompt.negative:hover {
2765
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 95%, var(--color-sentiment-negative-primary));
2766
+ }
2767
+ .np-prompt-interactive.np-item-prompt.negative:active {
2768
+ background-color: color-mix(in srgb, var(--color-sentiment-negative-secondary) 90%, var(--color-sentiment-negative-primary));
2769
+ }
2770
+ .np-item-prompt.positive,
2771
+ .np-item-prompt.discount,
2772
+ .np-item-prompt.savings {
2773
+ background-color: var(--color-sentiment-positive-secondary);
2774
+ color: var(--color-sentiment-positive-primary);
2775
+ }
2776
+ .np-item-prompt.positive a,
2777
+ .np-item-prompt.discount a,
2778
+ .np-item-prompt.savings a {
2779
+ color: var(--color-sentiment-positive-primary);
2780
+ }
2781
+ .np-item-prompt.positive a:hover,
2782
+ .np-item-prompt.discount a:hover,
2783
+ .np-item-prompt.savings a:hover {
2784
+ color: var(--color-sentiment-positive-primary-hover);
2785
+ }
2786
+ .np-item-prompt.positive a:active,
2787
+ .np-item-prompt.discount a:active,
2788
+ .np-item-prompt.savings a:active {
2789
+ color: var(--color-sentiment-positive-primary-active);
2790
+ }
2791
+ .np-prompt-interactive.np-item-prompt.positive:hover,
2792
+ .np-prompt-interactive.np-item-prompt.discount:hover,
2793
+ .np-prompt-interactive.np-item-prompt.savings:hover {
2794
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 95%, var(--color-sentiment-positive-primary));
2795
+ }
2796
+ .np-prompt-interactive.np-item-prompt.positive:active,
2797
+ .np-prompt-interactive.np-item-prompt.discount:active,
2798
+ .np-prompt-interactive.np-item-prompt.savings:active {
2799
+ background-color: color-mix(in srgb, var(--color-sentiment-positive-secondary) 90%, var(--color-sentiment-positive-primary));
2800
+ }
2801
+ .np-item-prompt.neutral {
2802
+ background-color: rgba(134,167,189,0.10196);
2803
+ background-color: var(--color-background-neutral);
2804
+ color: #37517e;
2805
+ color: var(--color-content-primary);
2806
+ }
2807
+ .np-item-prompt.neutral a {
2808
+ color: #37517e;
2809
+ color: var(--color-content-primary);
2810
+ }
2811
+ .np-prompt-interactive.np-item-prompt.neutral:hover {
2812
+ background-color: var(--color-background-neutral-hover);
2813
+ }
2814
+ .np-prompt-interactive.np-item-prompt.neutral:active {
2815
+ background-color: var(--color-background-neutral-active);
2816
+ }
2817
+ .np-item-prompt.warning {
2818
+ background-color: var(--color-sentiment-warning-secondary);
2819
+ color: var(--color-sentiment-warning-content);
2820
+ }
2821
+ .np-item-prompt.warning a {
2822
+ color: var(--color-sentiment-warning-content);
2823
+ }
2824
+ .np-item-prompt.warning a:hover {
2825
+ color: var(--color-sentiment-warning-content-hover);
2826
+ }
2827
+ .np-item-prompt.warning a:active {
2828
+ color: var(--color-sentiment-warning-content-active);
2829
+ }
2830
+ .np-prompt-interactive.np-item-prompt.warning:hover {
2831
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 90%, var(--color-sentiment-warning-primary));
2832
+ }
2833
+ .np-prompt-interactive.np-item-prompt.warning:active {
2834
+ background-color: color-mix(in srgb, var(--color-sentiment-warning-secondary) 80%, var(--color-sentiment-warning-primary));
2835
+ }
2651
2836
  .np-field-control {
2652
2837
  margin-top: 4px;
2653
2838
  margin-top: var(--size-4);
@@ -5165,9 +5350,6 @@ html:not([dir="rtl"]) .np-navigation-option {
5165
5350
  width: 50px;
5166
5351
  padding: 2px;
5167
5352
  border-radius: 16px;
5168
- -webkit-user-select: none;
5169
- -moz-user-select: none;
5170
- user-select: none;
5171
5353
  }
5172
5354
  .np-switch:focus {
5173
5355
  outline: none;
package/src/main.less CHANGED
@@ -39,6 +39,7 @@
39
39
  @import "./image/Image.less";
40
40
  @import "./info/Info.less";
41
41
  @import "./inputs/Input.less";
42
+ @import "./item/Item.less";
42
43
  @import "./field/Field.less";
43
44
  @import "./inputs/InputGroup.less";
44
45
  @import "./inputs/SelectInput.less";
@@ -77,7 +78,7 @@
77
78
  @import "./uploadInput/uploadItem/UploadItem.less";
78
79
  @import "./progress/Progress.less";
79
80
  @import "./progressBar/ProgressBar.less";
80
- @import "./legacylistItem/LegacyListItem.less";
81
+ @import "./listItem/ListItem.less";
81
82
 
82
83
  // List all less files in src in alphabetical order: find -s src -type f -name '*.less' ! -name 'main.less'
83
84
  // Make sure you are not referencing main.less itself in this file!
@@ -159,11 +159,11 @@ describe('PhoneNumberInput', () => {
159
159
  });
160
160
  });
161
161
 
162
- describe('when an partial model is supplied (with a matching prefix)', () => {
163
- it('should set the select to the matching prefix and put the rest of the number in the suffix', () => {
162
+ describe('when an invalid model is supplied', () => {
163
+ it('should not re-explode model', () => {
164
164
  customRender({ initialValue: '+123' });
165
- expect(getPrefixEl()).toHaveTextContent('+1');
166
- expect(getInputEl()).toHaveValue('23');
165
+ expect(getPrefixEl()).toHaveTextContent('+44');
166
+ expect(getInputEl()).toHaveValue('');
167
167
  });
168
168
  });
169
169
  });
@@ -1,6 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
- import { Field } from '../field/Field';
4
3
  import PhoneNumberInput from './PhoneNumberInput';
5
4
 
6
5
  const meta = {
@@ -23,24 +22,3 @@ export const Basic = {
23
22
  onChange: () => {},
24
23
  },
25
24
  } satisfies Story;
26
-
27
- export const InitialValue = () => {
28
- const initialValues = [
29
- undefined,
30
- '+44',
31
- '+441',
32
- '+1',
33
- '+12',
34
- '+1234',
35
- '+1264',
36
- '+992',
37
- '+9999',
38
- '+99992',
39
- ];
40
-
41
- return initialValues.map((initialValue) => (
42
- <Field key={initialValue} label={`With initialValue: ${JSON.stringify(initialValue ?? null)}`}>
43
- <PhoneNumberInput initialValue={initialValue} placeholder="placeholder" onChange={() => {}} />
44
- </Field>
45
- ));
46
- };
@@ -66,7 +66,7 @@ const PhoneNumberInput = ({
66
66
  const [internalValue, setInternalValue] = useState<PhoneNumber>(() => {
67
67
  const cleanValue = initialValue ? cleanNumber(initialValue) : null;
68
68
 
69
- if (!cleanValue || !isValidPhoneNumber(cleanValue, 1)) {
69
+ if (!cleanValue || !isValidPhoneNumber(cleanValue)) {
70
70
  return {
71
71
  prefix: setDefaultPrefix(locale, countryCode),
72
72
  suffix: '',
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  *
3
3
  * @param phoneNumber
4
- * @returns True if number that starts with "+" and contains a mix of digits and spaces with a configurable min length that defaults to 4.
4
+ * @returns True if number that starts with "+" and contains a mix of digits and spaces with at least 4 digits.
5
5
  */
6
- export const isValidPhoneNumber = (phoneNumber: string, minLength = 4) =>
7
- /^\+[\d-\s]+$/.test(phoneNumber) &&
8
- (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= minLength;
6
+ export const isValidPhoneNumber = (phoneNumber: string) =>
7
+ /^\+[\d-\s]+$/.test(phoneNumber) && (phoneNumber.match(/\d+/g)?.join('').length ?? 0) >= 4;
@@ -4,9 +4,6 @@
4
4
  width: 50px;
5
5
  padding: 2px;
6
6
  border-radius: 16px;
7
- -webkit-user-select: none;
8
- -moz-user-select: none;
9
- user-select: none;
10
7
  }
11
8
  .np-switch:focus {
12
9
  outline: none;
@@ -8,7 +8,6 @@
8
8
  width: 50px;
9
9
  padding: 2px;
10
10
  border-radius: 16px;
11
- user-select: none;
12
11
 
13
12
  .focus-ring();
14
13
 
@@ -0,0 +1,84 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Artwork" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ width="165.52107px" height="105.9651px" viewBox="0 0 165.52107 105.9651" enable-background="new 0 0 165.52107 105.9651"
5
+ xml:space="preserve">
6
+ <g>
7
+ <path id="XMLID_4_" d="M150.69807,0H14.82318c-0.5659,0-1.1328,0-1.69769,0.0033c-0.47751,0.0034-0.95391,0.0087-1.43031,0.0217
8
+ c-1.039,0.0281-2.0869,0.0894-3.1129,0.2738c-1.0424,0.1876-2.0124,0.4936-2.9587,0.9754
9
+ c-0.9303,0.4731-1.782,1.0919-2.52009,1.8303c-0.73841,0.7384-1.35721,1.5887-1.83021,2.52
10
+ c-0.4819,0.9463-0.7881,1.9166-0.9744,2.9598c-0.18539,1.0263-0.2471,2.074-0.2751,3.1119
11
+ c-0.0128,0.4764-0.01829,0.9528-0.0214,1.4291c-0.0033,0.5661-0.0022,1.1318-0.0022,1.6989V91.142
12
+ c0,0.5671-0.0011,1.13181,0.0022,1.69901c0.00311,0.4763,0.0086,0.9527,0.0214,1.4291
13
+ c0.028,1.03699,0.08971,2.08469,0.2751,3.11069c0.1863,1.0436,0.4925,2.0135,0.9744,2.9599
14
+ c0.473,0.9313,1.0918,1.7827,1.83021,2.52c0.73809,0.7396,1.58979,1.3583,2.52009,1.8302
15
+ c0.9463,0.4831,1.9163,0.7892,2.9587,0.9767c1.026,0.1832,2.0739,0.2456,3.1129,0.2737c0.4764,0.0108,0.9528,0.0172,1.43031,0.0194
16
+ c0.56489,0.0044,1.13179,0.0044,1.69769,0.0044h135.87489c0.5649,0,1.13181,0,1.69659-0.0044
17
+ c0.47641-0.0022,0.95282-0.0086,1.4314-0.0194c1.0368-0.0281,2.0845-0.0905,3.11301-0.2737
18
+ c1.041-0.1875,2.0112-0.4936,2.9576-0.9767c0.9313-0.4719,1.7805-1.0906,2.52011-1.8302c0.7372-0.7373,1.35599-1.5887,1.8302-2.52
19
+ c0.48299-0.9464,0.78889-1.9163,0.97429-2.9599c0.1855-1.026,0.2457-2.0737,0.2738-3.11069
20
+ c0.013-0.4764,0.01941-0.9528,0.02161-1.4291c0.00439-0.5672,0.00439-1.1319,0.00439-1.69901V14.8242
21
+ c0-0.5671,0-1.1328-0.00439-1.6989c-0.0022-0.4763-0.00861-0.9527-0.02161-1.4291c-0.02811-1.0379-0.0883-2.0856-0.2738-3.1119
22
+ c-0.18539-1.0432-0.4913-2.0135-0.97429-2.9598c-0.47421-0.9313-1.093-1.7816-1.8302-2.52
23
+ c-0.73961-0.7384-1.58881-1.3572-2.52011-1.8303c-0.9464-0.4818-1.9166-0.7878-2.9576-0.9754
24
+ c-1.0285-0.1844-2.0762-0.2457-3.11301-0.2738c-0.47858-0.013-0.95499-0.0183-1.4314-0.0217C151.82988,0,151.26297,0,150.69807,0
25
+ L150.69807,0z"/>
26
+ <path id="XMLID_3_" fill="#FFFFFF" d="M150.69807,3.532l1.67149,0.0032c0.4528,0.0032,0.90561,0.0081,1.36092,0.0205
27
+ c0.79201,0.0214,1.71849,0.0643,2.58209,0.2191c0.7507,0.1352,1.38029,0.3408,1.9845,0.6484
28
+ c0.5965,0.3031,1.14301,0.7003,1.62019,1.1768c0.479,0.4797,0.87671,1.0271,1.18381,1.6302
29
+ c0.30589,0.5995,0.51019,1.2261,0.64459,1.9823c0.1544,0.8542,0.1971,1.7832,0.21881,2.5801
30
+ c0.01219,0.4498,0.01819,0.8996,0.0204,1.3601c0.00429,0.5569,0.0042,1.1135,0.0042,1.6715V91.142
31
+ c0,0.558,0.00009,1.1136-0.0043,1.6824c-0.00211,0.4497-0.0081,0.8995-0.0204,1.3501c-0.02161,0.7957-0.0643,1.7242-0.2206,2.5885
32
+ c-0.13251,0.7458-0.3367,1.3725-0.64429,1.975c-0.30621,0.6016-0.70331,1.1484-1.18022,1.6251
33
+ c-0.47989,0.48-1.0246,0.876-1.62819,1.1819c-0.5997,0.3061-1.22821,0.51151-1.97151,0.6453
34
+ c-0.88109,0.157-1.84639,0.2002-2.57339,0.2199c-0.4574,0.0103-0.9126,0.01649-1.37889,0.0187
35
+ c-0.55571,0.0043-1.1134,0.0042-1.6692,0.0042H14.82318c-0.0074,0-0.0146,0-0.0221,0c-0.5494,0-1.0999,0-1.6593-0.0043
36
+ c-0.4561-0.00211-0.9112-0.0082-1.3512-0.0182c-0.7436-0.0201-1.7095-0.0632-2.5834-0.2193
37
+ c-0.74969-0.1348-1.3782-0.3402-1.9858-0.6503c-0.59789-0.3032-1.1422-0.6988-1.6223-1.1797
38
+ c-0.4764-0.4756-0.8723-1.0207-1.1784-1.6232c-0.3064-0.6019-0.5114-1.2305-0.64619-1.9852
39
+ c-0.15581-0.8626-0.19861-1.7874-0.22-2.5777c-0.01221-0.4525-0.01731-0.9049-0.02021-1.3547l-0.0022-1.3279l0.0001-0.3506V14.8242
40
+ l-0.0001-0.3506l0.0021-1.3251c0.003-0.4525,0.0081-0.9049,0.02031-1.357c0.02139-0.7911,0.06419-1.7163,0.22129-2.5861
41
+ c0.1336-0.7479,0.3385-1.3765,0.6465-1.9814c0.3037-0.5979,0.7003-1.1437,1.17921-1.6225
42
+ c0.477-0.4772,1.02309-0.8739,1.62479-1.1799c0.6011-0.3061,1.2308-0.5116,1.9805-0.6465c0.8638-0.1552,1.7909-0.198,2.5849-0.2195
43
+ c0.4526-0.0123,0.9052-0.0172,1.3544-0.0203l1.6771-0.0033H150.69807"/>
44
+ <g>
45
+ <g>
46
+ <path d="M45.1862,35.64053c1.41724-1.77266,2.37897-4.15282,2.12532-6.58506c-2.07464,0.10316-4.60634,1.36871-6.07207,3.14276
47
+ c-1.31607,1.5192-2.4809,3.99902-2.17723,6.3293C41.39111,38.72954,43.71785,37.36345,45.1862,35.64053"/>
48
+ <path d="M47.28506,38.98252c-3.38211-0.20146-6.25773,1.91951-7.87286,1.91951c-1.61602,0-4.08931-1.81799-6.76438-1.76899
49
+ c-3.48177,0.05114-6.71245,2.01976-8.4793,5.15079c-3.63411,6.2636-0.95904,15.55471,2.57494,20.65606
50
+ c1.71618,2.5238,3.78447,5.30269,6.50976,5.20287c2.57494-0.10104,3.58421-1.66732,6.71416-1.66732
51
+ c3.12765,0,4.03679,1.66732,6.76252,1.61681c2.82665-0.05054,4.59381-2.52506,6.30997-5.05132
52
+ c1.96878-2.877,2.77473-5.65498,2.82542-5.80748c-0.0507-0.05051-5.45058-2.12204-5.50065-8.33358
53
+ c-0.05098-5.20101,4.23951-7.6749,4.44144-7.82832C52.3832,39.4881,48.5975,39.08404,47.28506,38.98252"/>
54
+ </g>
55
+ <g>
56
+ <path d="M76.73385,31.94381c7.35096,0,12.4697,5.06708,12.4697,12.44437c0,7.40363-5.22407,12.49704-12.65403,12.49704h-8.13892
57
+ v12.94318h-5.88037v-37.8846H76.73385z M68.41059,51.9493h6.74732c5.11975,0,8.0336-2.75636,8.0336-7.53479
58
+ c0-4.77792-2.91385-7.50845-8.00727-7.50845h-6.77365V51.9493z"/>
59
+ <path d="M90.73997,61.97864c0-4.8311,3.70182-7.79761,10.26583-8.16526l7.56061-0.44614v-2.12639
60
+ c0-3.07185-2.07423-4.90959-5.53905-4.90959c-3.28251,0-5.33041,1.57492-5.82871,4.04313h-5.35574
61
+ c0.31499-4.98859,4.56777-8.66407,11.3941-8.66407c6.69466,0,10.97377,3.54432,10.97377,9.08388v19.03421h-5.43472v-4.54194
62
+ h-0.13065c-1.60125,3.07185-5.09341,5.01441-8.71623,5.01441C94.52078,70.30088,90.73997,66.94038,90.73997,61.97864z
63
+ M108.56641,59.4846v-2.17905l-6.8,0.41981c-3.38683,0.23649-5.30306,1.73291-5.30306,4.09579
64
+ c0,2.41504,1.99523,3.99046,5.04075,3.99046C105.46823,65.81161,108.56641,63.08108,108.56641,59.4846z"/>
65
+ <path d="M119.34167,79.9889v-4.5946c0.4193,0.10483,1.36425,0.10483,1.83723,0.10483c2.6252,0,4.04313-1.10245,4.90908-3.9378
66
+ c0-0.05267,0.49931-1.68025,0.49931-1.70658l-9.97616-27.64562h6.14268l6.98432,22.47371h0.10432l6.98433-22.47371h5.9857
67
+ l-10.34483,29.06304c-2.36186,6.69517-5.0924,8.84789-10.81577,8.84789C121.17891,80.12006,119.76098,80.06739,119.34167,79.9889
68
+ z"/>
69
+ </g>
70
+ </g>
71
+ </g>
72
+ <g>
73
+ </g>
74
+ <g>
75
+ </g>
76
+ <g>
77
+ </g>
78
+ <g>
79
+ </g>
80
+ <g>
81
+ </g>
82
+ <g>
83
+ </g>
84
+ </svg>