@transferwise/components 45.15.1 → 45.17.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 (44) hide show
  1. package/build/index.esm.js +172 -114
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +172 -114
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/inputs/SelectInput.css +1 -1
  7. package/build/styles/main.css +1 -1
  8. package/build/styles/popover/Popover.css +1 -1
  9. package/build/styles/promoCard/PromoCard.css +1 -1
  10. package/build/types/alert/Alert.d.ts.map +1 -1
  11. package/build/types/common/card/Card.d.ts.map +1 -1
  12. package/build/types/common/card/index.d.ts +1 -0
  13. package/build/types/common/card/index.d.ts.map +1 -1
  14. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  15. package/build/types/inputs/_Popover.d.ts.map +1 -1
  16. package/build/types/promoCard/PromoCard.d.ts +9 -3
  17. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  18. package/build/types/promoCard/PromoCardIndicator.d.ts +5 -3
  19. package/build/types/promoCard/PromoCardIndicator.d.ts.map +1 -1
  20. package/package.json +3 -3
  21. package/src/alert/Alert.js +11 -9
  22. package/src/alert/Alert.spec.js +22 -13
  23. package/src/alert/withArrow/withArrow.spec.js +4 -4
  24. package/src/common/card/Card.tsx +6 -2
  25. package/src/common/card/index.ts +1 -0
  26. package/src/dateLookup/tableLink/TableLink.js +1 -0
  27. package/src/dateLookup/tableLink/TableLink.spec.js +6 -0
  28. package/src/inputs/SelectInput.css +1 -1
  29. package/src/inputs/SelectInput.less +3 -0
  30. package/src/inputs/SelectInput.story.tsx +22 -0
  31. package/src/inputs/_BottomSheet.less +1 -1
  32. package/src/inputs/_BottomSheet.tsx +57 -52
  33. package/src/inputs/_Popover.less +1 -1
  34. package/src/inputs/_Popover.tsx +31 -24
  35. package/src/listItem/ListItem.story.tsx +1 -1
  36. package/src/main.css +1 -1
  37. package/src/main.less +0 -3
  38. package/src/popover/Popover.css +1 -1
  39. package/src/promoCard/PromoCard.css +1 -1
  40. package/src/promoCard/PromoCard.less +9 -9
  41. package/src/promoCard/PromoCard.spec.tsx +1 -0
  42. package/src/promoCard/PromoCard.story.tsx +90 -30
  43. package/src/promoCard/PromoCard.tsx +69 -22
  44. package/src/promoCard/PromoCardIndicator.tsx +20 -8
package/build/index.js CHANGED
@@ -1183,8 +1183,8 @@ const Alert = props => {
1183
1183
  setShouldFire(false);
1184
1184
  };
1185
1185
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1186
- role: "alert",
1187
1186
  className: classNames__default.default('alert d-flex', `alert-${mappedType}`, className),
1187
+ "data-testid": "alert",
1188
1188
  onTouchStart: handleTouchStart,
1189
1189
  onTouchEnd: handleTouchEnd,
1190
1190
  onTouchMove: handleTouchMove,
@@ -1193,17 +1193,20 @@ const Alert = props => {
1193
1193
  "data-testid": variant,
1194
1194
  children: [generateIcon(), /*#__PURE__*/jsxRuntime.jsxs("div", {
1195
1195
  className: "alert__message",
1196
- children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
1197
- className: "m-b-1",
1198
- type: exports.Typography.TITLE_BODY,
1199
- children: title
1200
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
1201
- as: "span",
1202
- className: "d-block",
1203
- type: exports.Typography.BODY_LARGE,
1204
- children: children || /*#__PURE__*/jsxRuntime.jsx(InlineMarkdown$1, {
1205
- children: message
1206
- })
1196
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1197
+ role: exports.Sentiment.NEGATIVE === mappedType ? 'alert' : 'status',
1198
+ children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
1199
+ className: "m-b-1",
1200
+ type: exports.Typography.TITLE_BODY,
1201
+ children: title
1202
+ }), /*#__PURE__*/jsxRuntime.jsx(Body, {
1203
+ as: "span",
1204
+ className: "d-block",
1205
+ type: exports.Typography.BODY_LARGE,
1206
+ children: children || /*#__PURE__*/jsxRuntime.jsx(InlineMarkdown$1, {
1207
+ children: message
1208
+ })
1209
+ })]
1207
1210
  }), action && /*#__PURE__*/jsxRuntime.jsx(Link, {
1208
1211
  href: action.href,
1209
1212
  className: "m-t-1",
@@ -2290,7 +2293,7 @@ var Card$2 = Card$1;
2290
2293
 
2291
2294
  const Card = ({
2292
2295
  className,
2293
- children,
2296
+ children = null,
2294
2297
  id,
2295
2298
  isDisabled = false,
2296
2299
  isSmall = false,
@@ -2313,7 +2316,10 @@ const Card = ({
2313
2316
  size: isSmall ? 'sm' : 'md',
2314
2317
  isDisabled: isDisabled,
2315
2318
  testId: "close-button",
2316
- onClick: onDismiss
2319
+ onClick: e => {
2320
+ stopPropagation$1(e);
2321
+ onDismiss();
2322
+ }
2317
2323
  }), children]
2318
2324
  });
2319
2325
  };
@@ -3372,6 +3378,7 @@ class TableLink extends React.PureComponent {
3372
3378
  className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
3373
3379
  disabled: disabled,
3374
3380
  "aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
3381
+ "aria-pressed": active,
3375
3382
  onClick: this.onClick,
3376
3383
  children: title || item
3377
3384
  })
@@ -6251,65 +6258,74 @@ function BottomSheet({
6251
6258
  getFloatingProps
6252
6259
  } = react.useInteractions([dismiss, role]);
6253
6260
  const [floatingKey, setFloatingKey] = React.useState(0);
6261
+ const {
6262
+ theme,
6263
+ screenMode
6264
+ } = componentsTheming.useTheme();
6254
6265
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6255
6266
  children: [open ? /*#__PURE__*/jsxRuntime.jsx(PreventScroll, {}) : null, renderTrigger?.({
6256
6267
  ref: refs.setReference,
6257
6268
  getInteractionProps: getReferenceProps
6258
6269
  }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingPortal, {
6259
- children: /*#__PURE__*/jsxRuntime.jsxs(react$1.Transition, {
6260
- show: open,
6261
- className: "np-bottom-sheet-v2-container",
6262
- beforeEnter: () => {
6263
- setFloatingKey(prev => prev + 1);
6264
- },
6265
- children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6266
- enter: "np-bottom-sheet-v2-backdrop-container--enter",
6267
- enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6268
- leave: "np-bottom-sheet-v2-backdrop-container--leave",
6269
- leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6270
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
6271
- className: "np-bottom-sheet-v2-backdrop"
6272
- })
6273
- }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6274
- context: context,
6275
- initialFocus: initialFocusRef,
6276
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
6277
- className: "np-bottom-sheet-v2",
6278
- children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6279
- className: "np-bottom-sheet-v2-content",
6280
- enter: "np-bottom-sheet-v2-content--enter",
6281
- enterFrom: "np-bottom-sheet-v2-content--enter-from",
6282
- leave: "np-bottom-sheet-v2-content--leave",
6283
- leaveTo: "np-bottom-sheet-v2-content--leave-to",
6284
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6285
- // Force inner state invalidation on open
6286
- ref: refs.setFloating,
6287
- className: "np-bottom-sheet-v2-content-inner-container",
6288
- ...getFloatingProps(),
6289
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6290
- className: "np-bottom-sheet-v2-header",
6291
- children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
6292
- size: exports.Size.SMALL,
6293
- onClick: () => {
6294
- onClose?.();
6295
- }
6296
- })
6297
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
6298
- className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6299
- 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6300
- }),
6301
- children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6302
- className: "np-bottom-sheet-v2-title np-text-title-body",
6303
- children: title
6304
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6305
- className: "np-bottom-sheet-v2-body np-text-body-default",
6306
- children: children
6270
+ children: /*#__PURE__*/jsxRuntime.jsx(componentsTheming.ThemeProvider, {
6271
+ theme: theme,
6272
+ screenMode: screenMode,
6273
+ isNotRootProvider: true,
6274
+ children: /*#__PURE__*/jsxRuntime.jsxs(react$1.Transition, {
6275
+ show: open,
6276
+ className: "np-bottom-sheet-v2-container",
6277
+ beforeEnter: () => {
6278
+ setFloatingKey(prev => prev + 1);
6279
+ },
6280
+ children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6281
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6282
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6283
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6284
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6285
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6286
+ className: "np-bottom-sheet-v2-backdrop"
6287
+ })
6288
+ }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6289
+ context: context,
6290
+ initialFocus: initialFocusRef,
6291
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6292
+ className: "np-bottom-sheet-v2",
6293
+ children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6294
+ className: "np-bottom-sheet-v2-content",
6295
+ enter: "np-bottom-sheet-v2-content--enter",
6296
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6297
+ leave: "np-bottom-sheet-v2-content--leave",
6298
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6299
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6300
+ // Force inner state invalidation on open
6301
+ ref: refs.setFloating,
6302
+ className: "np-bottom-sheet-v2-content-inner-container",
6303
+ ...getFloatingProps(),
6304
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6305
+ className: "np-bottom-sheet-v2-header",
6306
+ children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
6307
+ size: exports.Size.SMALL,
6308
+ onClick: () => {
6309
+ onClose?.();
6310
+ }
6311
+ })
6312
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
6313
+ className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6314
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6315
+ }),
6316
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6317
+ className: "np-bottom-sheet-v2-title np-text-title-body",
6318
+ children: title
6319
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6320
+ className: "np-bottom-sheet-v2-body np-text-body-default",
6321
+ children: children
6322
+ })]
6307
6323
  })]
6308
- })]
6309
- }, floatingKey)
6324
+ }, floatingKey)
6325
+ })
6310
6326
  })
6311
- })
6312
- })]
6327
+ })]
6328
+ })
6313
6329
  })
6314
6330
  })]
6315
6331
  });
@@ -6385,41 +6401,50 @@ function Popover({
6385
6401
  getFloatingProps
6386
6402
  } = react.useInteractions([role, dismiss]);
6387
6403
  const [floatingKey, setFloatingKey] = React.useState(0);
6404
+ const {
6405
+ theme,
6406
+ screenMode
6407
+ } = componentsTheming.useTheme();
6388
6408
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6389
6409
  children: [open ? /*#__PURE__*/jsxRuntime.jsx(PreventScroll, {}) : null, renderTrigger({
6390
6410
  ref: refs.setReference,
6391
6411
  getInteractionProps: getReferenceProps
6392
6412
  }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingPortal, {
6393
- children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6394
- context: context,
6395
- children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition, {
6396
- show: open,
6397
- leave: "transition-opacity",
6398
- leaveTo: "opacity-0",
6399
- beforeEnter: () => {
6400
- setFloatingKey(prev => prev + 1);
6401
- },
6402
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
6403
- // Force inner state invalidation on open
6404
- ref: refs.setFloating,
6405
- className: "np-popover-v2-container"
6406
- // eslint-disable-next-line react/forbid-dom-props
6407
- ,
6408
- style: floatingStyles,
6409
- ...getFloatingProps(),
6410
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6411
- className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
6412
- 'np-popover-v2--padding-md': padding === 'md'
6413
- }),
6414
- children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6415
- className: "np-popover-v2-title np-text-title-body",
6416
- children: title
6417
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6418
- className: "np-popover-v2-content np-text-body-default",
6419
- children: children
6420
- })]
6421
- })
6422
- }, floatingKey)
6413
+ children: /*#__PURE__*/jsxRuntime.jsx(componentsTheming.ThemeProvider, {
6414
+ theme: theme,
6415
+ screenMode: screenMode,
6416
+ isNotRootProvider: true,
6417
+ children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6418
+ context: context,
6419
+ children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition, {
6420
+ show: open,
6421
+ leave: "transition-opacity",
6422
+ leaveTo: "opacity-0",
6423
+ beforeEnter: () => {
6424
+ setFloatingKey(prev => prev + 1);
6425
+ },
6426
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6427
+ // Force inner state invalidation on open
6428
+ ref: refs.setFloating,
6429
+ className: "np-popover-v2-container"
6430
+ // eslint-disable-next-line react/forbid-dom-props
6431
+ ,
6432
+ style: floatingStyles,
6433
+ ...getFloatingProps(),
6434
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6435
+ className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
6436
+ 'np-popover-v2--padding-md': padding === 'md'
6437
+ }),
6438
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6439
+ className: "np-popover-v2-title np-text-title-body",
6440
+ children: title
6441
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6442
+ className: "np-popover-v2-content np-text-body-default",
6443
+ children: children
6444
+ })]
6445
+ })
6446
+ }, floatingKey)
6447
+ })
6423
6448
  })
6424
6449
  })
6425
6450
  })]
@@ -10368,10 +10393,12 @@ const PromoCardIndicator = ({
10368
10393
  children,
10369
10394
  label,
10370
10395
  icon,
10396
+ isSmall = false,
10371
10397
  testid,
10372
10398
  ...rest
10373
10399
  }) => {
10374
- const IconComponent = icon && {
10400
+ const isIconString = icon && typeof icon === 'string';
10401
+ const IconComponent = isIconString && {
10375
10402
  check: icons.Check,
10376
10403
  arrow: icons.ArrowRight,
10377
10404
  download: icons.Download
@@ -10385,12 +10412,15 @@ const PromoCardIndicator = ({
10385
10412
  type: exports.Typography.BODY_LARGE_BOLD,
10386
10413
  className: "np-Card-indicatorText",
10387
10414
  children: label
10388
- }), IconComponent && /*#__PURE__*/jsxRuntime.jsx("span", {
10415
+ }), icon && /*#__PURE__*/jsxRuntime.jsx(Avatar, {
10416
+ type: exports.AvatarType.ICON,
10417
+ size: isSmall ? 40 : 56,
10418
+ backgroundColor: "var(--Card-indicator-icon-background-color)",
10389
10419
  className: "np-Card-indicatorIcon",
10390
- children: /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
10420
+ children: IconComponent ? /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
10391
10421
  size: 24,
10392
10422
  "aria-hidden": "true"
10393
- })
10423
+ }) : icon
10394
10424
  }), children]
10395
10425
  });
10396
10426
  };
@@ -10452,6 +10482,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10452
10482
  imageClass,
10453
10483
  imageSource,
10454
10484
  indicatorLabel,
10485
+ indicatorIcon,
10455
10486
  isChecked,
10456
10487
  isDisabled,
10457
10488
  onClick,
@@ -10462,6 +10493,8 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10462
10493
  title,
10463
10494
  type,
10464
10495
  value,
10496
+ isSmall,
10497
+ useDisplayFont = true,
10465
10498
  ...props
10466
10499
  }, reference) => {
10467
10500
  // Set the `checked` state to the value of `defaultChecked` if it is truthy,
@@ -10485,7 +10518,19 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10485
10518
  // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
10486
10519
  // `'download'` if `download` is truthy. If neither condition is true, set
10487
10520
  // `icon` to `undefined`.
10488
- const icon = href && download ? 'download' : href ? 'arrow' : undefined;
10521
+ // Create a function to get icon type
10522
+ const getIconType = () => {
10523
+ if (indicatorIcon) {
10524
+ return indicatorIcon;
10525
+ }
10526
+ if (download) {
10527
+ return 'download';
10528
+ }
10529
+ if (href && !type) {
10530
+ return 'arrow';
10531
+ }
10532
+ return undefined;
10533
+ };
10489
10534
  // Define all class names string based on the values of the `href`, `type`,
10490
10535
  // `checked`, and `className` props.
10491
10536
  const commonClasses = classNames__default.default({
@@ -10502,7 +10547,8 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10502
10547
  isDisabled: isDisabled || contextIsDisabled,
10503
10548
  onClick,
10504
10549
  ref: reference,
10505
- 'data-testid': testId
10550
+ 'data-testid': testId,
10551
+ isSmall
10506
10552
  };
10507
10553
  // Object with Anchor props that will be passed to the `a` element. These
10508
10554
  // won't be refurned if set to `isDisabled`
@@ -10530,6 +10576,27 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10530
10576
  ref: reference,
10531
10577
  tabIndex: 0
10532
10578
  } : {};
10579
+ const getTitle = () => {
10580
+ const titleContent = href && !type ? /*#__PURE__*/jsxRuntime.jsx("a", {
10581
+ className: "np-Card-titleLink",
10582
+ ...anchorProps,
10583
+ children: title
10584
+ }) : title;
10585
+ const titleProps = {
10586
+ id: `${componentId}-title`,
10587
+ as: headingLevel,
10588
+ className: 'np-Card-title'
10589
+ };
10590
+ return useDisplayFont ? /*#__PURE__*/jsxRuntime.jsx(Display, {
10591
+ type: exports.Typography.DISPLAY_SMALL,
10592
+ ...titleProps,
10593
+ children: titleContent
10594
+ }) : /*#__PURE__*/jsxRuntime.jsx(Title, {
10595
+ type: exports.Typography.TITLE_SUBSECTION,
10596
+ ...titleProps,
10597
+ children: titleContent
10598
+ });
10599
+ };
10533
10600
  React.useEffect(() => {
10534
10601
  setChecked(defaultChecked ?? isChecked ?? false);
10535
10602
  }, [defaultChecked, isChecked]);
@@ -10543,17 +10610,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10543
10610
  size: 24,
10544
10611
  "aria-hidden": "true"
10545
10612
  })
10546
- }), /*#__PURE__*/jsxRuntime.jsx(Display, {
10547
- id: `${componentId}-title`,
10548
- as: headingLevel,
10549
- className: "np-Card-title",
10550
- type: exports.Typography.DISPLAY_SMALL,
10551
- children: href && !type ? /*#__PURE__*/jsxRuntime.jsx("a", {
10552
- className: "np-Card-titleLink",
10553
- ...anchorProps,
10554
- children: title
10555
- }) : title
10556
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
10613
+ }), getTitle(), /*#__PURE__*/jsxRuntime.jsx(Body, {
10557
10614
  className: "np-Card-description",
10558
10615
  children: description
10559
10616
  }), imageSource && /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -10567,7 +10624,8 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
10567
10624
  })
10568
10625
  }), /*#__PURE__*/jsxRuntime.jsx(PromoCardIndicator, {
10569
10626
  label: indicatorLabel,
10570
- icon: icon
10627
+ icon: getIconType(),
10628
+ isSmall: isSmall
10571
10629
  })]
10572
10630
  });
10573
10631
  });