@transferwise/components 46.29.1 → 46.30.0

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 (102) hide show
  1. package/build/index.js +4737 -4678
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +3504 -3445
  4. package/build/index.mjs.map +1 -1
  5. package/build/mocks.js.map +1 -1
  6. package/build/mocks.mjs.map +1 -1
  7. package/build/types/common/DOMOperations/DOMOperations.d.ts +10 -2
  8. package/build/types/common/DOMOperations/DOMOperations.d.ts.map +1 -1
  9. package/build/types/common/DOMOperations/index.d.ts +1 -3
  10. package/build/types/common/DOMOperations/index.d.ts.map +1 -1
  11. package/build/types/common/bottomSheet/BottomSheet.d.ts +2 -2
  12. package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
  13. package/build/types/common/bottomSheet/index.d.ts +2 -1
  14. package/build/types/common/bottomSheet/index.d.ts.map +1 -1
  15. package/build/types/common/closeButton/CloseButton.messages.d.ts +7 -7
  16. package/build/types/common/closeButton/CloseButton.messages.d.ts.map +1 -1
  17. package/build/types/common/closeButton/index.d.ts +0 -1
  18. package/build/types/common/closeButton/index.d.ts.map +1 -1
  19. package/build/types/common/deviceDetection/deviceDetection.d.ts +1 -1
  20. package/build/types/common/deviceDetection/deviceDetection.d.ts.map +1 -1
  21. package/build/types/common/deviceDetection/index.d.ts +1 -1
  22. package/build/types/common/deviceDetection/index.d.ts.map +1 -1
  23. package/build/types/common/domHelpers/documentIosClick.d.ts +7 -2
  24. package/build/types/common/domHelpers/documentIosClick.d.ts.map +1 -1
  25. package/build/types/common/domHelpers/index.d.ts +1 -6
  26. package/build/types/common/domHelpers/index.d.ts.map +1 -1
  27. package/build/types/common/flowHeader/index.d.ts +2 -0
  28. package/build/types/common/flowHeader/index.d.ts.map +1 -0
  29. package/build/types/common/focusBoundary/index.d.ts +1 -1
  30. package/build/types/common/focusBoundary/index.d.ts.map +1 -1
  31. package/build/types/common/historyNavigator/historyNavigator.d.ts +8 -8
  32. package/build/types/common/historyNavigator/historyNavigator.d.ts.map +1 -1
  33. package/build/types/common/historyNavigator/index.d.ts +1 -1
  34. package/build/types/common/historyNavigator/index.d.ts.map +1 -1
  35. package/build/types/common/panel/Panel.d.ts +1 -1
  36. package/build/types/common/panel/Panel.d.ts.map +1 -1
  37. package/build/types/common/panel/index.d.ts +1 -1
  38. package/build/types/common/panel/index.d.ts.map +1 -1
  39. package/build/types/dimmer/Dimmer.d.ts +1 -1
  40. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  41. package/build/types/dimmer/index.d.ts +2 -1
  42. package/build/types/dimmer/index.d.ts.map +1 -1
  43. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  44. package/build/types/index.d.ts +42 -41
  45. package/build/types/index.d.ts.map +1 -1
  46. package/build/types/inputs/SelectInput.d.ts +2 -1
  47. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  48. package/build/types/nudge/Nudge.d.ts.map +1 -1
  49. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  50. package/build/types/promoCard/PromoCardGroup.d.ts.map +1 -1
  51. package/build/types/title/Title.d.ts.map +1 -1
  52. package/package.json +58 -59
  53. package/src/chevron/Chevron.tsx +1 -1
  54. package/src/common/DOMOperations/index.ts +1 -0
  55. package/src/common/bottomSheet/BottomSheet.tsx +6 -3
  56. package/src/common/bottomSheet/index.ts +2 -0
  57. package/src/common/closeButton/{CloseButton.spec.js → CloseButton.spec.tsx} +1 -0
  58. package/src/common/closeButton/index.ts +0 -1
  59. package/src/common/deviceDetection/{deviceDetection.spec.js → deviceDetection.spec.ts} +1 -1
  60. package/src/common/deviceDetection/deviceDetection.ts +7 -0
  61. package/src/common/domHelpers/{documentIosClick.spec.js → documentIosClick.spec.ts} +7 -13
  62. package/src/common/domHelpers/{documentIosClick.js → documentIosClick.ts} +23 -0
  63. package/src/common/domHelpers/index.ts +4 -23
  64. package/src/common/flowHeader/{FlowHeader.spec.js → FlowHeader.spec.tsx} +2 -1
  65. package/src/common/flowHeader/index.ts +1 -0
  66. package/src/common/historyNavigator/{historyNavigator.js → historyNavigator.ts} +9 -5
  67. package/src/common/panel/{Panel.spec.js → Panel.spec.tsx} +14 -9
  68. package/src/common/panel/Panel.tsx +3 -3
  69. package/src/common/responsivePanel/ResponsivePanel.tsx +1 -1
  70. package/src/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.spec.ts +1 -1
  71. package/src/dateLookup/DateLookup.testingLibrary.spec.js +2 -2
  72. package/src/dimmer/Dimmer.tsx +1 -1
  73. package/src/dimmer/index.ts +2 -0
  74. package/src/flowNavigation/FlowNavigation.tsx +1 -2
  75. package/src/index.ts +68 -66
  76. package/src/inputs/SelectInput.spec.tsx +12 -0
  77. package/src/inputs/SelectInput.story.tsx +2 -0
  78. package/src/inputs/SelectInput.tsx +14 -0
  79. package/src/listItem/ListItem.tsx +1 -1
  80. package/src/nudge/Nudge.tsx +5 -8
  81. package/src/overlayHeader/OverlayHeader.js +1 -1
  82. package/src/promoCard/PromoCard.tsx +10 -7
  83. package/src/promoCard/PromoCardGroup.tsx +9 -7
  84. package/src/select/Select.story.js +1 -1
  85. package/src/stepper/Stepper.spec.js +13 -13
  86. package/src/title/Title.tsx +4 -5
  87. package/src/withDisplayFormat/WithDisplayFormat.tsx +2 -2
  88. package/src/common/DOMOperations/index.js +0 -3
  89. package/src/common/bottomSheet/index.js +0 -1
  90. package/src/common/deviceDetection/deviceDetection.js +0 -7
  91. package/src/dimmer/index.js +0 -1
  92. /package/src/common/DOMOperations/{DOMOperations.spec.js → DOMOperations.spec.tsx} +0 -0
  93. /package/src/common/DOMOperations/{DOMOperations.js → DOMOperations.ts} +0 -0
  94. /package/src/common/closeButton/{CloseButton.messages.js → CloseButton.messages.ts} +0 -0
  95. /package/src/common/closeButton/__snapshots__/{CloseButton.spec.js.snap → CloseButton.spec.tsx.snap} +0 -0
  96. /package/src/common/deviceDetection/{index.js → index.ts} +0 -0
  97. /package/src/common/flowHeader/__snapshots__/{FlowHeader.spec.js.snap → FlowHeader.spec.tsx.snap} +0 -0
  98. /package/src/common/focusBoundary/{index.js → index.ts} +0 -0
  99. /package/src/common/historyNavigator/{historyNavigator.spec.js → historyNavigator.spec.ts} +0 -0
  100. /package/src/common/historyNavigator/{index.js → index.ts} +0 -0
  101. /package/src/common/panel/__snapshots__/{Panel.spec.js.snap → Panel.spec.tsx.snap} +0 -0
  102. /package/src/common/panel/{index.js → index.ts} +0 -0
package/src/index.ts CHANGED
@@ -1,23 +1,30 @@
1
1
  /**
2
2
  * Types
3
3
  */
4
- export type { AccordionProps, AccordionItem } from './accordion';
5
- export type { AvatarProps } from './avatar';
4
+ export type { AccordionItem, AccordionProps } from './accordion';
6
5
  export type { ActionOptionProps } from './actionOption';
7
- export type { AlertProps, AlertAction, AlertArrowPosition, AlertType } from './alert';
6
+ export type { AlertAction, AlertProps, AlertType } from './alert';
7
+ export type { AvatarProps } from './avatar';
8
8
  export type { BadgeProps } from './badge';
9
9
  export type { CircularButtonProps } from './circularButton';
10
+ export type {
11
+ BodyTypes,
12
+ DisplayTypes,
13
+ LayoutDirection,
14
+ LinkTypes,
15
+ TitleTypes,
16
+ TypographyTypes,
17
+ } from './common';
18
+ export type { BottomSheetProps } from './common/bottomSheet';
19
+ export type { DateInputProps } from './dateInput';
20
+ export type { DateLookupProps } from './dateLookup';
10
21
  export type { DecisionProps } from './decision/Decision';
22
+ export type { DimmerProps } from './dimmer';
11
23
  export type { EmphasisProps } from './emphasis';
12
24
  export type { InfoProps } from './info';
13
- export type { SummaryProps } from './summary';
14
- export type { InputProps } from './inputs/Input';
15
- export type { DateInputProps } from './dateInput';
16
- export type { DateLookupProps } from './dateLookup';
17
25
  export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
26
+ export type { InputProps } from './inputs/Input';
18
27
  export type { InputGroupProps } from './inputs/InputGroup';
19
- export type { LoaderProps } from './loader';
20
- export type { NavigationOptionListProps } from './navigationOptionsList';
21
28
  export type { SearchInputProps } from './inputs/SearchInput';
22
29
  export type {
23
30
  SelectInputGroupItem,
@@ -29,50 +36,43 @@ export type {
29
36
  SelectInputTriggerButtonProps,
30
37
  } from './inputs/SelectInput';
31
38
  export type { TextAreaProps } from './inputs/TextArea';
39
+ export type { InstructionsListProps } from './instructionsList';
40
+ export type { LoaderProps } from './loader';
41
+ export type { MarkdownProps } from './markdown';
42
+ export type { ModalProps } from './modal';
43
+ export type { MoneyProps } from './money';
44
+ export type {
45
+ CurrencyHeaderItem,
46
+ CurrencyItem,
47
+ CurrencyOptionItem,
48
+ MoneyInputProps,
49
+ } from './moneyInput';
50
+ export type { NavigationOptionListProps } from './navigationOptionsList';
32
51
  export type { PhoneNumberInputProps } from './phoneNumberInput/PhoneNumberInput';
33
52
  export type { PopoverProps } from './popover';
34
53
  export type { ProgressProps } from './progress';
35
54
  export type { ProgressBarProps } from './progressBar';
36
- export type { ProviderProps, DirectionProviderProps, LanguageProviderProps } from './provider';
55
+ export type { DirectionProviderProps, LanguageProviderProps, ProviderProps } from './provider';
37
56
  export type { RadioProps } from './radio';
38
57
  export type { RadioGroupProps, RadioGroupRadio } from './radioGroup';
39
58
  export type { RadioOptionProps } from './radioOption';
59
+ export type { SegmentedControlProps } from './segmentedControl';
60
+ export type { SlidingPanelProps } from './slidingPanel';
40
61
  export type { SnackbarProps } from './snackbar/Snackbar';
41
62
  export type { SnackbarContextType } from './snackbar/SnackbarContext';
42
63
  export type { StatusIconProps } from './statusIcon';
43
64
  export type { StickyProps } from './sticky';
65
+ export type { SummaryProps } from './summary';
44
66
  export type { SwitchProps } from './switch';
45
67
  export type { SwitchOptionProps } from './switchOption';
46
68
  export type { TextareaWithDisplayFormatProps } from './textareaWithDisplayFormat';
47
69
  export type { TooltipProps } from './tooltip';
48
- export type { UploadedFile, UploadError, UploadResponse } from './uploadInput/types';
49
- export type { MarkdownProps } from './markdown';
50
- export type { ModalProps } from './modal';
51
- export type { MoneyProps } from './money';
52
- export type {
53
- CurrencyHeaderItem,
54
- CurrencyItem,
55
- CurrencyOptionItem,
56
- MoneyInputProps,
57
- } from './moneyInput';
58
- export type { SlidingPanelProps } from './slidingPanel';
59
- export type {
60
- LayoutDirection,
61
- TypographyTypes,
62
- TitleTypes,
63
- BodyTypes,
64
- LinkTypes,
65
- DisplayTypes,
66
- } from './common';
67
- export type { SegmentedControlProps } from './segmentedControl';
68
- export type { TypeaheadProps, TypeaheadOption } from './typeahead';
69
- export type { InstructionsListProps } from './instructionsList';
70
+ export type { TypeaheadOption, TypeaheadProps } from './typeahead';
71
+ export type { UploadError, UploadResponse, UploadedFile } from './uploadInput/types';
70
72
 
71
73
  /**
72
74
  * Components
73
75
  */
74
- export { default as Title } from './title';
75
- export { default as Body } from './body';
76
76
  export { default as Accordion } from './accordion';
77
77
  export { default as ActionButton } from './actionButton';
78
78
  export { default as ActionOption } from './actionOption';
@@ -80,16 +80,19 @@ export { default as Alert } from './alert';
80
80
  export { default as Avatar } from './avatar';
81
81
  export { default as AvatarWrapper } from './avatarWrapper';
82
82
  export { default as Badge } from './badge';
83
- export { default as BottomSheet } from './common/bottomSheet';
83
+ export { default as Body } from './body';
84
84
  export { default as Button } from './button';
85
85
  export { default as Card } from './card';
86
- export { default as BaseCard } from './common/card';
87
86
  export { default as Checkbox } from './checkbox';
88
87
  export { default as CheckboxButton } from './checkboxButton';
89
88
  export { default as CheckboxOption } from './checkboxOption';
90
89
  export { default as Chevron } from './chevron';
91
- export { default as Chips, Chip } from './chips';
90
+ export { Chip, default as Chips } from './chips';
92
91
  export { default as CircularButton } from './circularButton';
92
+ export { default as Option } from './common/Option';
93
+ export { default as BottomSheet } from './common/bottomSheet';
94
+ export { default as BaseCard } from './common/card';
95
+ export { default as CriticalCommsBanner } from './criticalBanner';
93
96
  export { default as DateInput } from './dateInput';
94
97
  export { default as DateLookup } from './dateLookup';
95
98
  export { default as Decision } from './decision';
@@ -104,6 +107,7 @@ export { default as Header } from './header';
104
107
  export { default as Image } from './image';
105
108
  export { default as Info } from './info';
106
109
  export { default as InlineAlert } from './inlineAlert';
110
+ export { default as InputWithDisplayFormat } from './inputWithDisplayFormat';
107
111
  export { Input } from './inputs/Input';
108
112
  export { InputGroup } from './inputs/InputGroup';
109
113
  export { SearchInput } from './inputs/SearchInput';
@@ -113,9 +117,9 @@ export {
113
117
  SelectInputTriggerButton,
114
118
  } from './inputs/SelectInput';
115
119
  export { TextArea } from './inputs/TextArea';
116
- export { default as InputWithDisplayFormat } from './inputWithDisplayFormat';
117
120
  export { default as InstructionsList } from './instructionsList';
118
121
  export { default as Link } from './link';
122
+ export { default as ListItem } from './listItem';
119
123
  export { default as Loader } from './loader';
120
124
  export { default as Logo } from './logo';
121
125
  export { default as Markdown } from './markdown';
@@ -125,24 +129,23 @@ export { default as MoneyInput } from './moneyInput';
125
129
  export { default as NavigationOption } from './navigationOption';
126
130
  export { default as NavigationOptionsList } from './navigationOptionsList';
127
131
  export { default as Nudge } from './nudge';
128
- export { default as Option } from './common/Option';
129
132
  export { default as OverlayHeader } from './overlayHeader';
130
133
  export { default as PhoneNumberInput } from './phoneNumberInput';
131
134
  export { default as Popover } from './popover';
132
135
  export { default as ProcessIndicator } from './processIndicator';
133
- export { default as ProgressBar } from './progressBar';
134
136
  export { default as Progress } from './progress';
135
- export { default as PromoCard } from './promoCard';
136
- export { default as PromoCardGroup } from './promoCard';
137
- export { default as Provider, DirectionProvider, LanguageProvider } from './provider';
137
+ export { default as ProgressBar } from './progressBar';
138
+ export { PromoCardGroup, default as PromoCard } from './promoCard';
139
+ export { DirectionProvider, LanguageProvider, default as Provider } from './provider';
138
140
  export { default as Radio } from './radio';
139
141
  export { default as RadioGroup } from './radioGroup';
140
142
  export { default as RadioOption } from './radioOption';
141
143
  export { default as Section } from './section';
142
- export { default as Select } from './select';
143
144
  export { default as SegmentedControl } from './segmentedControl';
145
+ export { default as Select } from './select';
144
146
  export { default as SlidingPanel } from './slidingPanel';
145
147
  export { default as SnackbarPortal } from './snackbar/Snackbar';
148
+ export { SnackbarConsumer, SnackbarContext } from './snackbar/SnackbarContext';
146
149
  export { default as SnackbarProvider } from './snackbar/SnackbarProvider';
147
150
  export { default as StatusIcon } from './statusIcon/StatusIcon';
148
151
  export { default as Stepper } from './stepper/Stepper';
@@ -152,66 +155,65 @@ export { default as Switch } from './switch';
152
155
  export { default as SwitchOption } from './switchOption';
153
156
  export { default as Tabs } from './tabs';
154
157
  export { default as TextareaWithDisplayFormat } from './textareaWithDisplayFormat';
158
+ export { default as Title } from './title';
155
159
  export { default as Tooltip } from './tooltip';
156
160
  export { default as Typeahead } from './typeahead';
157
161
  export { default as Upload } from './upload';
158
162
  export { default as UploadInput } from './uploadInput';
159
- export { SnackbarConsumer, SnackbarContext } from './snackbar/SnackbarContext';
160
- export { default as CriticalCommsBanner } from './criticalBanner';
161
- export { default as ListItem } from './listItem';
162
163
 
163
164
  /**
164
165
  * Hooks
165
166
  */
166
- export { default as useSnackbar } from './snackbar/useSnackbar';
167
167
  export { useDirection, useLayout } from './common/hooks';
168
168
  export { useScreenSize } from './common/hooks/useScreenSize';
169
+ export { default as useSnackbar } from './snackbar/useSnackbar';
169
170
 
170
171
  /**
171
172
  * Enums
172
173
  */
174
+ export { AlertArrowPosition } from './alert/Alert';
175
+ export { AvatarType } from './avatar';
173
176
  export {
174
- Direction,
175
- Size,
176
- Width,
177
- Sentiment,
178
- Priority,
177
+ Breakpoint,
179
178
  ControlType,
180
- Type,
181
- Theme,
182
179
  DateMode,
180
+ Direction,
181
+ FileType,
182
+ Layout,
183
+ MarkdownNodeType,
183
184
  MonthFormat,
184
185
  Position,
185
- Scroll,
186
+ Priority,
186
187
  ProfileType,
187
- Breakpoint,
188
- Layout,
188
+ Scroll,
189
+ Sentiment,
190
+ Size,
189
191
  Status,
190
- MarkdownNodeType,
192
+ Theme,
193
+ Type,
191
194
  Typography,
192
195
  Variant,
196
+ Width,
193
197
  } from './common';
194
- export { AvatarType } from './avatar';
195
- export { InfoPresentation } from './info';
196
- export { UploadStep } from './upload';
197
198
  export { DecisionPresentation, DecisionType } from './decision';
199
+ export { InfoPresentation } from './info';
198
200
  export { LogoType } from './logo';
199
- export { FileType } from './common';
201
+ export { UploadStep } from './upload';
200
202
 
201
203
  /**
202
204
  * Utils
203
205
  */
204
206
  export {
205
- adjustLocale,
206
207
  DEFAULT_LANG,
207
208
  DEFAULT_LOCALE,
209
+ RTL_LANGUAGES,
210
+ SUPPORTED_LANGUAGES,
211
+ adjustLocale,
208
212
  getCountryFromLocale,
209
213
  getDirectionFromLocale,
210
214
  getLangFromLocale,
211
215
  isBrowser,
212
216
  isServerSide,
213
- RTL_LANGUAGES,
214
- SUPPORTED_LANGUAGES,
215
217
  } from './common';
216
218
 
217
219
  /**
@@ -64,12 +64,15 @@ describe('SelectInput', () => {
64
64
  });
65
65
 
66
66
  it('shows item selected via mouse', async () => {
67
+ const handleClose = jest.fn();
68
+
67
69
  render(
68
70
  <SelectInput
69
71
  items={[
70
72
  { type: 'option', value: 'USD' },
71
73
  { type: 'option', value: 'EUR' },
72
74
  ]}
75
+ onClose={handleClose}
73
76
  />,
74
77
  );
75
78
 
@@ -81,14 +84,19 @@ describe('SelectInput', () => {
81
84
  userEvent.click(trigger);
82
85
  });
83
86
 
87
+ expect(handleClose).not.toHaveBeenCalled();
88
+
84
89
  const listbox = screen.getByRole('listbox');
85
90
  const option = within(listbox).getByRole('option', { name: 'EUR' });
86
91
  userEvent.click(option);
87
92
 
93
+ expect(handleClose).toHaveBeenCalledTimes(1);
88
94
  expect(trigger).toHaveTextContent('EUR');
89
95
  });
90
96
 
91
97
  it('filters items via keyboard', async () => {
98
+ const handleClose = jest.fn();
99
+
92
100
  render(
93
101
  <SelectInput
94
102
  items={[
@@ -103,6 +111,7 @@ describe('SelectInput', () => {
103
111
  },
104
112
  ]}
105
113
  filterable
114
+ onClose={handleClose}
106
115
  />,
107
116
  );
108
117
 
@@ -113,6 +122,8 @@ describe('SelectInput', () => {
113
122
  userEvent.keyboard(' ');
114
123
  });
115
124
 
125
+ expect(handleClose).not.toHaveBeenCalled();
126
+
116
127
  const listbox = screen.getByRole('listbox');
117
128
  expect(within(listbox).getAllByRole('option')).toHaveLength(3);
118
129
 
@@ -134,6 +145,7 @@ describe('SelectInput', () => {
134
145
  userEvent.click(option);
135
146
  });
136
147
 
148
+ expect(handleClose).toHaveBeenCalledTimes(1);
137
149
  expect(trigger).toHaveTextContent('EUR');
138
150
  });
139
151
 
@@ -46,7 +46,9 @@ export const Months: Story<Month | null> = {
46
46
  value: month,
47
47
  })),
48
48
  renderValue: (month) => <SelectInputOptionContent title={month.name} />,
49
+ onFilterChange: fn() satisfies Mock,
49
50
  onChange: fn() satisfies Mock,
51
+ onClose: fn() satisfies Mock,
50
52
  onClear: fn() satisfies Mock,
51
53
  },
52
54
  render: function Render({ onChange, onClear, ...args }) {
@@ -155,6 +155,7 @@ export interface SelectInputProps<T = string, M extends boolean = false> {
155
155
  className?: string;
156
156
  onFilterChange?: (args: { query: string; queryNormalized: string | null }) => void;
157
157
  onChange?: (value: M extends true ? T[] : T) => void;
158
+ onClose?: () => void;
158
159
  onClear?: () => void;
159
160
  }
160
161
 
@@ -238,10 +239,23 @@ export function SelectInput<T = string, M extends boolean = false>({
238
239
  className,
239
240
  onFilterChange = noop,
240
241
  onChange,
242
+ onClose,
241
243
  onClear,
242
244
  }: SelectInputProps<T, M>) {
243
245
  const [open, setOpen] = useState(false);
244
246
 
247
+ const initialized = useRef(false);
248
+ const handleClose = useEffectEvent(onClose ?? (() => {}));
249
+ useEffect(() => {
250
+ if (initialized.current) {
251
+ if (!open) {
252
+ handleClose?.();
253
+ }
254
+ } else {
255
+ initialized.current = true;
256
+ }
257
+ }, [handleClose, open]);
258
+
245
259
  const [filterQuery, _setFilterQuery] = useState('');
246
260
  const setFilterQuery = useEffectEvent((query: string) => {
247
261
  _setFilterQuery(query);
@@ -32,7 +32,7 @@ const ListItem: FC<ListItemProps> = ({
32
32
  })}
33
33
  {...rest}
34
34
  >
35
- {media ? media : null}
35
+ {media}
36
36
 
37
37
  <div className={classNames('d-flex flex-column', { 'p-l-2': !!media, 'p-r-2': !!action })}>
38
38
  <Body type="body-default" className="text-secondary m-b-0">
@@ -10,15 +10,15 @@ import Link from '../link';
10
10
  // WARNING: Changing this will cause nudges to reappear wherever persist nudge is used and privacy team will need to be updated too
11
11
  export const STORAGE_NAME = 'dismissedNudges';
12
12
 
13
- const getLocalStorage = (): Array<string> => {
13
+ const getLocalStorage = (): string[] => {
14
14
  try {
15
15
  const storageItem = localStorage.getItem(STORAGE_NAME);
16
16
 
17
17
  if (storageItem) {
18
- const storage = JSON.parse(storageItem) as string[];
18
+ const storage: unknown = JSON.parse(storageItem);
19
19
 
20
20
  if (Array.isArray(storage)) {
21
- return storage;
21
+ return storage.map((item) => String(item));
22
22
  }
23
23
  }
24
24
  // eslint-disable-next-line unicorn/prefer-optional-catch-binding, no-empty
@@ -98,10 +98,7 @@ const Nudge = ({
98
98
 
99
99
  if (persistDismissal && id) {
100
100
  try {
101
- localStorage.setItem(
102
- STORAGE_NAME,
103
- JSON.stringify([...(dismissedNudgesStorage ? dismissedNudgesStorage : []), id]),
104
- );
101
+ localStorage.setItem(STORAGE_NAME, JSON.stringify([...dismissedNudgesStorage, id]));
105
102
  // eslint-disable-next-line unicorn/prefer-optional-catch-binding, no-empty
106
103
  } catch (error) {}
107
104
 
@@ -118,7 +115,7 @@ const Nudge = ({
118
115
  const dismissedNudgesStorage = getLocalStorage();
119
116
  let isDismissed = false;
120
117
 
121
- if (dismissedNudgesStorage && dismissedNudgesStorage.find((item) => item === id)) {
118
+ if (dismissedNudgesStorage?.find((item) => item === id)) {
122
119
  setIsDismissed(true);
123
120
  isDismissed = true;
124
121
  }
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import { Size } from '../common';
5
5
  import { CloseButton } from '../common/closeButton';
6
- import FlowHeader from '../common/flowHeader/FlowHeader';
6
+ import FlowHeader from '../common/flowHeader';
7
7
  import Logo from '../logo';
8
8
 
9
9
  const OverlayHeader = ({ avatar, onClose, logo }) => {
@@ -259,13 +259,16 @@ const PromoCard: FunctionComponent<PromoCardProps> = forwardRef(
259
259
 
260
260
  // Define all class names string based on the values of the `href`, `type`,
261
261
  // `checked`, and `className` props.
262
- const commonClasses = classNames({
263
- 'np-Card--promoCard': true,
264
- 'np-Card--checked': !href && type,
265
- 'np-Card--link': href && !type,
266
- 'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
267
- [`${className || ''}`]: className,
268
- });
262
+ const commonClasses = classNames(
263
+ {
264
+ 'np-Card--promoCard': true,
265
+ 'np-Card--checked': !href && type,
266
+ 'np-Card--link': href && !type,
267
+ 'is-checked':
268
+ type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
269
+ },
270
+ className,
271
+ );
269
272
 
270
273
  // Object with common props that will be passed to the `Card` components
271
274
  const commonProps = {
@@ -86,18 +86,20 @@ const PromoCardGroup: FunctionComponent<PromoCardGroupProps> = ({
86
86
  onChange(value);
87
87
  };
88
88
 
89
- return { state, isDisabled: isDisabled, onChange: handleOnChange };
89
+ return { state, isDisabled, onChange: handleOnChange };
90
90
  }, [state, isDisabled, onChange]);
91
91
 
92
- const commonClasses = classNames({
93
- 'np-CardGroup': true,
94
- 'is-disabled': isDisabled,
95
- [`${className || ''}`]: className,
96
- });
92
+ const commonClasses = classNames(
93
+ {
94
+ 'np-CardGroup': true,
95
+ 'is-disabled': isDisabled,
96
+ },
97
+ className,
98
+ );
97
99
 
98
100
  const commonProps = {
99
101
  className: commonClasses,
100
- id: id,
102
+ id,
101
103
  'data-testid': testId,
102
104
  role: containerRole as AriaRoleRadioGroup | undefined, // Add the role attribute here
103
105
  };
@@ -42,7 +42,7 @@ export const Basic = () => {
42
42
  <Select
43
43
  id={id}
44
44
  size={size}
45
- classNames={`${hasError ? 'has-error' : ''}`}
45
+ classNames={hasError ? 'has-error' : ''}
46
46
  placeholder={placeholder}
47
47
  dropdownRight={dropdownRight}
48
48
  dropdownWidth={dropdownWidth}
@@ -40,25 +40,25 @@ describe('Stepper', () => {
40
40
  });
41
41
 
42
42
  it('sets the widths of the progress bar to match where you are in the flow', () => {
43
- expect(totalWidth()).toStrictEqual('0%');
43
+ expect(totalWidth()).toBe('0%');
44
44
  activeStep(2);
45
- expect(totalWidth()).toStrictEqual('100%');
45
+ expect(totalWidth()).toBe('100%');
46
46
  steps(5);
47
- expect(totalWidth()).toStrictEqual('50%');
47
+ expect(totalWidth()).toBe('50%');
48
48
  activeStep(10000);
49
- expect(totalWidth()).toStrictEqual('100%');
49
+ expect(totalWidth()).toBe('100%');
50
50
  activeStep(-10);
51
- expect(totalWidth()).toStrictEqual('0%');
51
+ expect(totalWidth()).toBe('0%');
52
52
  });
53
53
  });
54
54
 
55
55
  describe('steps', () => {
56
56
  it('have rendered labels', () => {
57
57
  steps(5);
58
- [0, 1, 2, 3, 4].forEach((label, index) => {
59
- expect(
60
- component.find('.tw-stepper__step').at(index).find('span').props().children,
61
- ).toStrictEqual(`${label}`);
58
+ [0, 1, 2, 3, 4].forEach((step) => {
59
+ expect(component.find('.tw-stepper__step').at(step).find('span').props().children).toBe(
60
+ step.toString(),
61
+ );
62
62
  });
63
63
  });
64
64
 
@@ -188,8 +188,8 @@ describe('Stepper', () => {
188
188
  });
189
189
  const firstStepHoverLabel = step(0).children();
190
190
  expect(firstStepHoverLabel.type()).toBe(Tooltip);
191
- expect(firstStepHoverLabel.children().render().text()).toStrictEqual('label');
192
- expect(step(1).find('span').props().children).toStrictEqual('label 2');
191
+ expect(firstStepHoverLabel.children().render().text()).toBe('label');
192
+ expect(step(1).find('span').props().children).toBe('label 2');
193
193
  });
194
194
 
195
195
  it('renders jsx', () => {
@@ -220,8 +220,8 @@ describe('Stepper', () => {
220
220
  });
221
221
  const firstStepHoverLabel = step(0).children();
222
222
  expect(firstStepHoverLabel.type()).toBe('span');
223
- expect(firstStepHoverLabel.props().children).toStrictEqual('label');
224
- expect(step(1).children().props().children).toStrictEqual('label 2');
223
+ expect(firstStepHoverLabel.props().children).toBe('label');
224
+ expect(step(1).children().props().children).toBe('label 2');
225
225
  });
226
226
  });
227
227
  });
@@ -11,7 +11,7 @@ const titleTypeMapping = {
11
11
  [Typography.TITLE_SUBSECTION]: 'h3',
12
12
  [Typography.TITLE_BODY]: 'h4',
13
13
  [Typography.TITLE_GROUP]: 'h5',
14
- };
14
+ } as const;
15
15
 
16
16
  type Props = LabelHTMLAttributes<HTMLHeadingElement | HTMLSpanElement | HTMLLabelElement> &
17
17
  LiHTMLAttributes<HTMLLIElement> & {
@@ -29,12 +29,11 @@ function Title({ as, type = DEFAULT_TYPE, className, ...props }: Props) {
29
29
  const mapping = titleTypeMapping[type];
30
30
  const isTypeSupported = mapping !== undefined;
31
31
  if (isTypeSupported) {
32
- const HeaderTag = (as ?? `${mapping}`) as keyof ReactHTML;
32
+ const HeaderTag = as ?? mapping;
33
33
  return <HeaderTag {...props} className={classNames(`np-text-${type}`, className)} />;
34
- } else {
35
- const HeaderTag = (as ?? `${titleTypeMapping[DEFAULT_TYPE]}`) as keyof ReactHTML;
36
- return <HeaderTag {...props} className={classNames(`np-text-${DEFAULT_TYPE}`, className)} />;
37
34
  }
35
+ const HeaderTag = as ?? titleTypeMapping[DEFAULT_TYPE];
36
+ return <HeaderTag {...props} className={classNames(`np-text-${DEFAULT_TYPE}`, className)} />;
38
37
  }
39
38
 
40
39
  export default Title;
@@ -169,10 +169,10 @@ class WithDisplayFormat<T extends TextElementProps> extends Component<
169
169
  let newFormattedValue = '';
170
170
 
171
171
  if (this.detectUndoRedo(event) === 'Undo') {
172
- newFormattedValue = formatWithPattern(historyNavigator.undo(), displayPattern);
172
+ newFormattedValue = formatWithPattern(historyNavigator.undo().toString(), displayPattern);
173
173
  this.setState({ value: newFormattedValue, triggerType: 'Undo' });
174
174
  } else if (this.detectUndoRedo(event) === 'Redo') {
175
- newFormattedValue = formatWithPattern(historyNavigator.redo(), displayPattern);
175
+ newFormattedValue = formatWithPattern(historyNavigator.redo().toString(), displayPattern);
176
176
  this.setState({ value: newFormattedValue, triggerType: 'Redo' });
177
177
  } else {
178
178
  this.setState({
@@ -1,3 +0,0 @@
1
- import { addNoScrollClass, removeNoScrollClass } from './DOMOperations';
2
-
3
- export { addNoScrollClass, removeNoScrollClass };
@@ -1 +0,0 @@
1
- export { default } from './BottomSheet';
@@ -1,7 +0,0 @@
1
- export function isIosDevice() {
2
- const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
3
- const matchString = sampleTouchDevices.map((device) => `(${device})`).join('|');
4
- const regex = new RegExp(matchString, 'gi');
5
-
6
- return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
7
- }
@@ -1 +0,0 @@
1
- export { default } from './Dimmer';
File without changes
File without changes