@transferwise/components 45.15.1 → 45.16.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 (40) 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/main.css +1 -1
  7. package/build/styles/popover/Popover.css +1 -1
  8. package/build/styles/promoCard/PromoCard.css +1 -1
  9. package/build/types/alert/Alert.d.ts.map +1 -1
  10. package/build/types/common/card/Card.d.ts.map +1 -1
  11. package/build/types/common/card/index.d.ts +1 -0
  12. package/build/types/common/card/index.d.ts.map +1 -1
  13. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  14. package/build/types/inputs/_Popover.d.ts.map +1 -1
  15. package/build/types/promoCard/PromoCard.d.ts +9 -3
  16. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  17. package/build/types/promoCard/PromoCardIndicator.d.ts +5 -3
  18. package/build/types/promoCard/PromoCardIndicator.d.ts.map +1 -1
  19. package/package.json +3 -3
  20. package/src/alert/Alert.js +11 -9
  21. package/src/alert/Alert.spec.js +22 -13
  22. package/src/alert/withArrow/withArrow.spec.js +4 -4
  23. package/src/common/card/Card.tsx +6 -2
  24. package/src/common/card/index.ts +1 -0
  25. package/src/dateLookup/tableLink/TableLink.js +1 -0
  26. package/src/dateLookup/tableLink/TableLink.spec.js +6 -0
  27. package/src/inputs/SelectInput.story.tsx +22 -0
  28. package/src/inputs/_BottomSheet.less +1 -1
  29. package/src/inputs/_BottomSheet.tsx +57 -52
  30. package/src/inputs/_Popover.less +1 -1
  31. package/src/inputs/_Popover.tsx +31 -24
  32. package/src/listItem/ListItem.story.tsx +1 -1
  33. package/src/main.css +1 -1
  34. package/src/popover/Popover.css +1 -1
  35. package/src/promoCard/PromoCard.css +1 -1
  36. package/src/promoCard/PromoCard.less +9 -9
  37. package/src/promoCard/PromoCard.spec.tsx +1 -0
  38. package/src/promoCard/PromoCard.story.tsx +90 -30
  39. package/src/promoCard/PromoCard.tsx +69 -22
  40. package/src/promoCard/PromoCardIndicator.tsx +20 -8
@@ -1150,8 +1150,8 @@ const Alert = props => {
1150
1150
  setShouldFire(false);
1151
1151
  };
1152
1152
  return /*#__PURE__*/jsxs("div", {
1153
- role: "alert",
1154
1153
  className: classNames('alert d-flex', `alert-${mappedType}`, className),
1154
+ "data-testid": "alert",
1155
1155
  onTouchStart: handleTouchStart,
1156
1156
  onTouchEnd: handleTouchEnd,
1157
1157
  onTouchMove: handleTouchMove,
@@ -1160,17 +1160,20 @@ const Alert = props => {
1160
1160
  "data-testid": variant,
1161
1161
  children: [generateIcon(), /*#__PURE__*/jsxs("div", {
1162
1162
  className: "alert__message",
1163
- children: [title && /*#__PURE__*/jsx(Title, {
1164
- className: "m-b-1",
1165
- type: Typography.TITLE_BODY,
1166
- children: title
1167
- }), /*#__PURE__*/jsx(Body, {
1168
- as: "span",
1169
- className: "d-block",
1170
- type: Typography.BODY_LARGE,
1171
- children: children || /*#__PURE__*/jsx(InlineMarkdown$1, {
1172
- children: message
1173
- })
1163
+ children: [/*#__PURE__*/jsxs("div", {
1164
+ role: Sentiment.NEGATIVE === mappedType ? 'alert' : 'status',
1165
+ children: [title && /*#__PURE__*/jsx(Title, {
1166
+ className: "m-b-1",
1167
+ type: Typography.TITLE_BODY,
1168
+ children: title
1169
+ }), /*#__PURE__*/jsx(Body, {
1170
+ as: "span",
1171
+ className: "d-block",
1172
+ type: Typography.BODY_LARGE,
1173
+ children: children || /*#__PURE__*/jsx(InlineMarkdown$1, {
1174
+ children: message
1175
+ })
1176
+ })]
1174
1177
  }), action && /*#__PURE__*/jsx(Link, {
1175
1178
  href: action.href,
1176
1179
  className: "m-t-1",
@@ -2257,7 +2260,7 @@ var Card$2 = Card$1;
2257
2260
 
2258
2261
  const Card = ({
2259
2262
  className,
2260
- children,
2263
+ children = null,
2261
2264
  id,
2262
2265
  isDisabled = false,
2263
2266
  isSmall = false,
@@ -2280,7 +2283,10 @@ const Card = ({
2280
2283
  size: isSmall ? 'sm' : 'md',
2281
2284
  isDisabled: isDisabled,
2282
2285
  testId: "close-button",
2283
- onClick: onDismiss
2286
+ onClick: e => {
2287
+ stopPropagation$1(e);
2288
+ onDismiss();
2289
+ }
2284
2290
  }), children]
2285
2291
  });
2286
2292
  };
@@ -3339,6 +3345,7 @@ class TableLink extends PureComponent {
3339
3345
  className: `tw-date-lookup-${type}-option ${active ? 'active' : ''} ${today ? 'today' : ''} np-text-body-default-bold`,
3340
3346
  disabled: disabled,
3341
3347
  "aria-label": this.calculateAriaLabel(longTitle, title, active, type, formatMessage),
3348
+ "aria-pressed": active,
3342
3349
  onClick: this.onClick,
3343
3350
  children: title || item
3344
3351
  })
@@ -6218,65 +6225,74 @@ function BottomSheet({
6218
6225
  getFloatingProps
6219
6226
  } = useInteractions([dismiss, role]);
6220
6227
  const [floatingKey, setFloatingKey] = useState(0);
6228
+ const {
6229
+ theme,
6230
+ screenMode
6231
+ } = useTheme();
6221
6232
  return /*#__PURE__*/jsxs(Fragment, {
6222
6233
  children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger?.({
6223
6234
  ref: refs.setReference,
6224
6235
  getInteractionProps: getReferenceProps
6225
6236
  }), /*#__PURE__*/jsx(FloatingPortal, {
6226
- children: /*#__PURE__*/jsxs(Transition, {
6227
- show: open,
6228
- className: "np-bottom-sheet-v2-container",
6229
- beforeEnter: () => {
6230
- setFloatingKey(prev => prev + 1);
6231
- },
6232
- children: [/*#__PURE__*/jsx(Transition.Child, {
6233
- enter: "np-bottom-sheet-v2-backdrop-container--enter",
6234
- enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6235
- leave: "np-bottom-sheet-v2-backdrop-container--leave",
6236
- leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6237
- children: /*#__PURE__*/jsx("div", {
6238
- className: "np-bottom-sheet-v2-backdrop"
6239
- })
6240
- }), /*#__PURE__*/jsx(FloatingFocusManager, {
6241
- context: context,
6242
- initialFocus: initialFocusRef,
6243
- children: /*#__PURE__*/jsx("div", {
6244
- className: "np-bottom-sheet-v2",
6245
- children: /*#__PURE__*/jsx(Transition.Child, {
6246
- className: "np-bottom-sheet-v2-content",
6247
- enter: "np-bottom-sheet-v2-content--enter",
6248
- enterFrom: "np-bottom-sheet-v2-content--enter-from",
6249
- leave: "np-bottom-sheet-v2-content--leave",
6250
- leaveTo: "np-bottom-sheet-v2-content--leave-to",
6251
- children: /*#__PURE__*/jsxs("div", {
6252
- // Force inner state invalidation on open
6253
- ref: refs.setFloating,
6254
- className: "np-bottom-sheet-v2-content-inner-container",
6255
- ...getFloatingProps(),
6256
- children: [/*#__PURE__*/jsx("div", {
6257
- className: "np-bottom-sheet-v2-header",
6258
- children: /*#__PURE__*/jsx(CloseButton, {
6259
- size: Size.SMALL,
6260
- onClick: () => {
6261
- onClose?.();
6262
- }
6263
- })
6264
- }), /*#__PURE__*/jsxs("div", {
6265
- className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6266
- 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6267
- }),
6268
- children: [title ? /*#__PURE__*/jsx("h2", {
6269
- className: "np-bottom-sheet-v2-title np-text-title-body",
6270
- children: title
6271
- }) : null, /*#__PURE__*/jsx("div", {
6272
- className: "np-bottom-sheet-v2-body np-text-body-default",
6273
- children: children
6237
+ children: /*#__PURE__*/jsx(ThemeProvider, {
6238
+ theme: theme,
6239
+ screenMode: screenMode,
6240
+ isNotRootProvider: true,
6241
+ children: /*#__PURE__*/jsxs(Transition, {
6242
+ show: open,
6243
+ className: "np-bottom-sheet-v2-container",
6244
+ beforeEnter: () => {
6245
+ setFloatingKey(prev => prev + 1);
6246
+ },
6247
+ children: [/*#__PURE__*/jsx(Transition.Child, {
6248
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6249
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6250
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6251
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6252
+ children: /*#__PURE__*/jsx("div", {
6253
+ className: "np-bottom-sheet-v2-backdrop"
6254
+ })
6255
+ }), /*#__PURE__*/jsx(FloatingFocusManager, {
6256
+ context: context,
6257
+ initialFocus: initialFocusRef,
6258
+ children: /*#__PURE__*/jsx("div", {
6259
+ className: "np-bottom-sheet-v2",
6260
+ children: /*#__PURE__*/jsx(Transition.Child, {
6261
+ className: "np-bottom-sheet-v2-content",
6262
+ enter: "np-bottom-sheet-v2-content--enter",
6263
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6264
+ leave: "np-bottom-sheet-v2-content--leave",
6265
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6266
+ children: /*#__PURE__*/jsxs("div", {
6267
+ // Force inner state invalidation on open
6268
+ ref: refs.setFloating,
6269
+ className: "np-bottom-sheet-v2-content-inner-container",
6270
+ ...getFloatingProps(),
6271
+ children: [/*#__PURE__*/jsx("div", {
6272
+ className: "np-bottom-sheet-v2-header",
6273
+ children: /*#__PURE__*/jsx(CloseButton, {
6274
+ size: Size.SMALL,
6275
+ onClick: () => {
6276
+ onClose?.();
6277
+ }
6278
+ })
6279
+ }), /*#__PURE__*/jsxs("div", {
6280
+ className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6281
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6282
+ }),
6283
+ children: [title ? /*#__PURE__*/jsx("h2", {
6284
+ className: "np-bottom-sheet-v2-title np-text-title-body",
6285
+ children: title
6286
+ }) : null, /*#__PURE__*/jsx("div", {
6287
+ className: "np-bottom-sheet-v2-body np-text-body-default",
6288
+ children: children
6289
+ })]
6274
6290
  })]
6275
- })]
6276
- }, floatingKey)
6291
+ }, floatingKey)
6292
+ })
6277
6293
  })
6278
- })
6279
- })]
6294
+ })]
6295
+ })
6280
6296
  })
6281
6297
  })]
6282
6298
  });
@@ -6352,41 +6368,50 @@ function Popover({
6352
6368
  getFloatingProps
6353
6369
  } = useInteractions([role, dismiss]);
6354
6370
  const [floatingKey, setFloatingKey] = useState(0);
6371
+ const {
6372
+ theme,
6373
+ screenMode
6374
+ } = useTheme();
6355
6375
  return /*#__PURE__*/jsxs(Fragment, {
6356
6376
  children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger({
6357
6377
  ref: refs.setReference,
6358
6378
  getInteractionProps: getReferenceProps
6359
6379
  }), /*#__PURE__*/jsx(FloatingPortal, {
6360
- children: /*#__PURE__*/jsx(FloatingFocusManager, {
6361
- context: context,
6362
- children: /*#__PURE__*/jsx(Transition, {
6363
- show: open,
6364
- leave: "transition-opacity",
6365
- leaveTo: "opacity-0",
6366
- beforeEnter: () => {
6367
- setFloatingKey(prev => prev + 1);
6368
- },
6369
- children: /*#__PURE__*/jsx("div", {
6370
- // Force inner state invalidation on open
6371
- ref: refs.setFloating,
6372
- className: "np-popover-v2-container"
6373
- // eslint-disable-next-line react/forbid-dom-props
6374
- ,
6375
- style: floatingStyles,
6376
- ...getFloatingProps(),
6377
- children: /*#__PURE__*/jsxs("div", {
6378
- className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
6379
- 'np-popover-v2--padding-md': padding === 'md'
6380
- }),
6381
- children: [title ? /*#__PURE__*/jsx("h2", {
6382
- className: "np-popover-v2-title np-text-title-body",
6383
- children: title
6384
- }) : null, /*#__PURE__*/jsx("div", {
6385
- className: "np-popover-v2-content np-text-body-default",
6386
- children: children
6387
- })]
6388
- })
6389
- }, floatingKey)
6380
+ children: /*#__PURE__*/jsx(ThemeProvider, {
6381
+ theme: theme,
6382
+ screenMode: screenMode,
6383
+ isNotRootProvider: true,
6384
+ children: /*#__PURE__*/jsx(FloatingFocusManager, {
6385
+ context: context,
6386
+ children: /*#__PURE__*/jsx(Transition, {
6387
+ show: open,
6388
+ leave: "transition-opacity",
6389
+ leaveTo: "opacity-0",
6390
+ beforeEnter: () => {
6391
+ setFloatingKey(prev => prev + 1);
6392
+ },
6393
+ children: /*#__PURE__*/jsx("div", {
6394
+ // Force inner state invalidation on open
6395
+ ref: refs.setFloating,
6396
+ className: "np-popover-v2-container"
6397
+ // eslint-disable-next-line react/forbid-dom-props
6398
+ ,
6399
+ style: floatingStyles,
6400
+ ...getFloatingProps(),
6401
+ children: /*#__PURE__*/jsxs("div", {
6402
+ className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
6403
+ 'np-popover-v2--padding-md': padding === 'md'
6404
+ }),
6405
+ children: [title ? /*#__PURE__*/jsx("h2", {
6406
+ className: "np-popover-v2-title np-text-title-body",
6407
+ children: title
6408
+ }) : null, /*#__PURE__*/jsx("div", {
6409
+ className: "np-popover-v2-content np-text-body-default",
6410
+ children: children
6411
+ })]
6412
+ })
6413
+ }, floatingKey)
6414
+ })
6390
6415
  })
6391
6416
  })
6392
6417
  })]
@@ -10335,10 +10360,12 @@ const PromoCardIndicator = ({
10335
10360
  children,
10336
10361
  label,
10337
10362
  icon,
10363
+ isSmall = false,
10338
10364
  testid,
10339
10365
  ...rest
10340
10366
  }) => {
10341
- const IconComponent = icon && {
10367
+ const isIconString = icon && typeof icon === 'string';
10368
+ const IconComponent = isIconString && {
10342
10369
  check: Check,
10343
10370
  arrow: ArrowRight,
10344
10371
  download: Download
@@ -10352,12 +10379,15 @@ const PromoCardIndicator = ({
10352
10379
  type: Typography.BODY_LARGE_BOLD,
10353
10380
  className: "np-Card-indicatorText",
10354
10381
  children: label
10355
- }), IconComponent && /*#__PURE__*/jsx("span", {
10382
+ }), icon && /*#__PURE__*/jsx(Avatar, {
10383
+ type: AvatarType.ICON,
10384
+ size: isSmall ? 40 : 56,
10385
+ backgroundColor: "var(--Card-indicator-icon-background-color)",
10356
10386
  className: "np-Card-indicatorIcon",
10357
- children: /*#__PURE__*/jsx(IconComponent, {
10387
+ children: IconComponent ? /*#__PURE__*/jsx(IconComponent, {
10358
10388
  size: 24,
10359
10389
  "aria-hidden": "true"
10360
- })
10390
+ }) : icon
10361
10391
  }), children]
10362
10392
  });
10363
10393
  };
@@ -10419,6 +10449,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10419
10449
  imageClass,
10420
10450
  imageSource,
10421
10451
  indicatorLabel,
10452
+ indicatorIcon,
10422
10453
  isChecked,
10423
10454
  isDisabled,
10424
10455
  onClick,
@@ -10429,6 +10460,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10429
10460
  title,
10430
10461
  type,
10431
10462
  value,
10463
+ isSmall,
10464
+ useDisplayFont = true,
10432
10465
  ...props
10433
10466
  }, reference) => {
10434
10467
  // Set the `checked` state to the value of `defaultChecked` if it is truthy,
@@ -10452,7 +10485,19 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10452
10485
  // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
10453
10486
  // `'download'` if `download` is truthy. If neither condition is true, set
10454
10487
  // `icon` to `undefined`.
10455
- const icon = href && download ? 'download' : href ? 'arrow' : undefined;
10488
+ // Create a function to get icon type
10489
+ const getIconType = () => {
10490
+ if (indicatorIcon) {
10491
+ return indicatorIcon;
10492
+ }
10493
+ if (download) {
10494
+ return 'download';
10495
+ }
10496
+ if (href && !type) {
10497
+ return 'arrow';
10498
+ }
10499
+ return undefined;
10500
+ };
10456
10501
  // Define all class names string based on the values of the `href`, `type`,
10457
10502
  // `checked`, and `className` props.
10458
10503
  const commonClasses = classNames({
@@ -10469,7 +10514,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10469
10514
  isDisabled: isDisabled || contextIsDisabled,
10470
10515
  onClick,
10471
10516
  ref: reference,
10472
- 'data-testid': testId
10517
+ 'data-testid': testId,
10518
+ isSmall
10473
10519
  };
10474
10520
  // Object with Anchor props that will be passed to the `a` element. These
10475
10521
  // won't be refurned if set to `isDisabled`
@@ -10497,6 +10543,27 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10497
10543
  ref: reference,
10498
10544
  tabIndex: 0
10499
10545
  } : {};
10546
+ const getTitle = () => {
10547
+ const titleContent = href && !type ? /*#__PURE__*/jsx("a", {
10548
+ className: "np-Card-titleLink",
10549
+ ...anchorProps,
10550
+ children: title
10551
+ }) : title;
10552
+ const titleProps = {
10553
+ id: `${componentId}-title`,
10554
+ as: headingLevel,
10555
+ className: 'np-Card-title'
10556
+ };
10557
+ return useDisplayFont ? /*#__PURE__*/jsx(Display, {
10558
+ type: Typography.DISPLAY_SMALL,
10559
+ ...titleProps,
10560
+ children: titleContent
10561
+ }) : /*#__PURE__*/jsx(Title, {
10562
+ type: Typography.TITLE_SUBSECTION,
10563
+ ...titleProps,
10564
+ children: titleContent
10565
+ });
10566
+ };
10500
10567
  useEffect(() => {
10501
10568
  setChecked(defaultChecked ?? isChecked ?? false);
10502
10569
  }, [defaultChecked, isChecked]);
@@ -10510,17 +10577,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10510
10577
  size: 24,
10511
10578
  "aria-hidden": "true"
10512
10579
  })
10513
- }), /*#__PURE__*/jsx(Display, {
10514
- id: `${componentId}-title`,
10515
- as: headingLevel,
10516
- className: "np-Card-title",
10517
- type: Typography.DISPLAY_SMALL,
10518
- children: href && !type ? /*#__PURE__*/jsx("a", {
10519
- className: "np-Card-titleLink",
10520
- ...anchorProps,
10521
- children: title
10522
- }) : title
10523
- }), /*#__PURE__*/jsx(Body, {
10580
+ }), getTitle(), /*#__PURE__*/jsx(Body, {
10524
10581
  className: "np-Card-description",
10525
10582
  children: description
10526
10583
  }), imageSource && /*#__PURE__*/jsx("div", {
@@ -10534,7 +10591,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
10534
10591
  })
10535
10592
  }), /*#__PURE__*/jsx(PromoCardIndicator, {
10536
10593
  label: indicatorLabel,
10537
- icon: icon
10594
+ icon: getIconType(),
10595
+ isSmall: isSmall
10538
10596
  })]
10539
10597
  });
10540
10598
  });