@transferwise/components 0.0.0-experimental-da6dbbf → 0.0.0-experimental-3118bd2

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 (96) hide show
  1. package/build/index.js +635 -933
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +625 -922
  4. package/build/index.mjs.map +1 -1
  5. package/build/main.css +0 -135
  6. package/build/styles/main.css +0 -135
  7. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  8. package/build/types/common/card/Card.d.ts +2 -2
  9. package/build/types/common/card/Card.d.ts.map +1 -1
  10. package/build/types/common/hooks/useMedia.d.ts.map +1 -1
  11. package/build/types/common/panel/Panel.d.ts.map +1 -1
  12. package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
  13. package/build/types/dateLookup/DateLookup.d.ts +6 -5
  14. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  15. package/build/types/dimmer/Dimmer.d.ts +1 -11
  16. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  17. package/build/types/drawer/Drawer.d.ts +4 -4
  18. package/build/types/index.d.ts +3 -4
  19. package/build/types/index.d.ts.map +1 -1
  20. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +2 -1
  21. package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
  22. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  23. package/build/types/inputs/contexts.d.ts +2 -2
  24. package/build/types/inputs/contexts.d.ts.map +1 -1
  25. package/build/types/modal/Modal.d.ts.map +1 -1
  26. package/build/types/processIndicator/ProcessIndicator.d.ts +36 -19
  27. package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
  28. package/build/types/processIndicator/index.d.ts +2 -2
  29. package/build/types/processIndicator/index.d.ts.map +1 -1
  30. package/build/types/promoCard/PromoCard.d.ts +5 -16
  31. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  32. package/build/types/select/searchBox/SearchBox.d.ts +1 -1
  33. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +2 -1
  34. package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
  35. package/build/types/tooltip/Tooltip.d.ts +1 -1
  36. package/build/types/tooltip/Tooltip.d.ts.map +1 -1
  37. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  38. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +14 -14
  39. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  40. package/package.json +7 -11
  41. package/src/accordion/AccordionItem/AccordionItem.tsx +2 -4
  42. package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -3
  43. package/src/button/Button.tsx +1 -1
  44. package/src/common/card/Card.tsx +43 -51
  45. package/src/common/hooks/useConditionalListener/useConditionalListener.spec.js +1 -1
  46. package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +3 -3
  47. package/src/common/hooks/useMedia.spec.ts +1 -1
  48. package/src/common/hooks/useMedia.ts +1 -2
  49. package/src/common/panel/Panel.tsx +90 -92
  50. package/src/common/responsivePanel/ResponsivePanel.tsx +34 -38
  51. package/src/dateLookup/DateLookup.rtl.spec.tsx +181 -5
  52. package/src/dateLookup/DateLookup.testingLibrary.spec.js +171 -124
  53. package/src/dateLookup/DateLookup.tsx +14 -9
  54. package/src/drawer/Drawer.js +3 -3
  55. package/src/field/Field.tsx +3 -3
  56. package/src/index.ts +3 -4
  57. package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +2 -1
  58. package/src/inputs/SelectInput.story.tsx +2 -1
  59. package/src/inputs/SelectInput.tsx +10 -2
  60. package/src/inputs/contexts.tsx +4 -4
  61. package/src/main.css +0 -135
  62. package/src/main.less +0 -1
  63. package/src/modal/Modal.tsx +1 -2
  64. package/src/processIndicator/ProcessIndicator.rtl.spec.tsx +45 -0
  65. package/src/processIndicator/ProcessIndicator.tsx +110 -0
  66. package/src/promoCard/PromoCard.story.tsx +2 -2
  67. package/src/promoCard/PromoCard.tsx +9 -31
  68. package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -1
  69. package/src/snackbar/Snackbar.spec.js +4 -1
  70. package/src/snackbar/Snackbar.story.tsx +4 -2
  71. package/src/tabs/Tabs.spec.js +46 -27
  72. package/src/test-utils/index.js +5 -7
  73. package/src/test-utils/jest.setup.js +9 -3
  74. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +2 -1
  75. package/src/tooltip/Tooltip.tsx +44 -46
  76. package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +2 -2
  77. package/src/upload/Upload.spec.js +34 -13
  78. package/src/uploadInput/UploadInput.spec.tsx +21 -23
  79. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -3
  80. package/src/withDisplayFormat/WithDisplayFormat.spec.js +63 -32
  81. package/src/withDisplayFormat/WithDisplayFormat.tsx +28 -28
  82. package/build/styles/carousel/Carousel.css +0 -135
  83. package/build/types/carousel/Carousel.d.ts +0 -26
  84. package/build/types/carousel/Carousel.d.ts.map +0 -1
  85. package/build/types/carousel/index.d.ts +0 -3
  86. package/build/types/carousel/index.d.ts.map +0 -1
  87. package/src/carousel/Carousel.css +0 -135
  88. package/src/carousel/Carousel.less +0 -133
  89. package/src/carousel/Carousel.spec.tsx +0 -221
  90. package/src/carousel/Carousel.story.tsx +0 -63
  91. package/src/carousel/Carousel.tsx +0 -345
  92. package/src/carousel/index.ts +0 -3
  93. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -180
  94. package/src/processIndicator/ProcessIndicator.js +0 -117
  95. package/src/processIndicator/ProcessIndicator.spec.js +0 -101
  96. /package/src/processIndicator/{index.js → index.ts} +0 -0
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var reactId = require('@radix-ui/react-id');
5
4
  var classNames = require('classnames');
6
5
  var jsxRuntime = require('react/jsx-runtime');
7
6
  var icons = require('@transferwise/icons');
@@ -12,7 +11,6 @@ var componentsTheming = require('@wise/components-theming');
12
11
  var reactTransitionGroup = require('react-transition-group');
13
12
  var focus = require('@react-aria/focus');
14
13
  var reactDom = require('react-dom');
15
- var index_js = require('use-sync-external-store/shim/index.js');
16
14
  var neptuneValidation = require('@transferwise/neptune-validation');
17
15
  var formatting = require('@transferwise/formatting');
18
16
  var react$1 = require('@headlessui/react');
@@ -565,7 +563,7 @@ const AccordionItem = ({
565
563
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
566
564
  size: 24
567
565
  }) : null;
568
- const fallbackId = reactId.useId();
566
+ const fallbackId = React.useId();
569
567
  const accordionId = id ?? fallbackId;
570
568
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
571
569
  id: accordionId,
@@ -1268,68 +1266,67 @@ const radius = {
1268
1266
  };
1269
1267
  const ANIMATION_DURATION_IN_MS = 1500;
1270
1268
  class ProcessIndicator extends React.Component {
1269
+ static defaultProps = {
1270
+ status: 'processing',
1271
+ size: 'sm'
1272
+ };
1273
+ interval = 0;
1274
+ timeout = 0;
1271
1275
  constructor(props) {
1272
1276
  super(props);
1273
1277
  this.state = {
1274
1278
  status: props.status,
1275
1279
  size: props.size
1276
1280
  };
1277
- this.interval = null;
1278
- this.timeout = null;
1279
1281
  }
1280
-
1281
1282
  /**
1282
1283
  * Create interval for animation duration (1500ms)
1283
1284
  * Update state only at the end of every interval
1284
1285
  * (end of animation loop) if props changed before end of animation
1285
1286
  */
1286
1287
  componentDidMount() {
1287
- this.interval = setInterval(() => {
1288
- const statusFromState = this.state.status;
1289
- const sizeFromState = this.state.size;
1290
- const statusFromProps = this.props.status;
1291
- const sizeFromProps = this.props.size;
1292
- if (statusFromState !== statusFromProps) {
1288
+ this.interval = window.setInterval(() => {
1289
+ const {
1290
+ status: targetStatus,
1291
+ size: targetSize,
1292
+ onAnimationCompleted
1293
+ } = this.props;
1294
+ const {
1295
+ status: currentStatus,
1296
+ size: currentSize
1297
+ } = this.state;
1298
+ if (currentStatus !== targetStatus) {
1293
1299
  this.setState({
1294
- status: statusFromProps
1295
- }, this.runCallBack(statusFromProps));
1300
+ status: targetStatus
1301
+ }, () => {
1302
+ if (onAnimationCompleted) {
1303
+ this.timeout = window.setTimeout(() => {
1304
+ onAnimationCompleted(targetStatus);
1305
+ }, ANIMATION_DURATION_IN_MS);
1306
+ }
1307
+ });
1296
1308
  }
1297
- if (sizeFromState !== sizeFromProps) {
1309
+ if (currentSize !== targetSize) {
1298
1310
  this.setState({
1299
- size: sizeFromProps
1311
+ size: targetSize
1300
1312
  });
1301
1313
  }
1302
1314
  }, ANIMATION_DURATION_IN_MS);
1303
1315
  }
1304
-
1305
1316
  /**
1306
1317
  * Only trigger render if comopnent's state got
1307
1318
  * updated from interval callback
1308
- *
1309
- * @param nextProps
1310
- * @param nextState
1311
1319
  */
1312
1320
  shouldComponentUpdate(nextProps, nextState) {
1313
1321
  const isSameStatus = nextProps.status === nextState.status;
1314
1322
  const isSameSize = nextProps.size === nextState.size;
1315
1323
  return isSameStatus && isSameSize;
1316
1324
  }
1317
-
1318
1325
  // Clear interval before destroying component
1319
1326
  componentWillUnmount() {
1320
- clearInterval(this.interval);
1321
- clearTimeout(this.timeout);
1327
+ window.clearInterval(this.interval);
1328
+ window.clearTimeout(this.timeout);
1322
1329
  }
1323
- runCallBack = statusFromProps => {
1324
- const {
1325
- onAnimationCompleted
1326
- } = this.props;
1327
- if (onAnimationCompleted) {
1328
- this.timeouts = setTimeout(() => {
1329
- onAnimationCompleted(statusFromProps);
1330
- }, ANIMATION_DURATION_IN_MS);
1331
- }
1332
- };
1333
1330
  render() {
1334
1331
  const {
1335
1332
  className,
@@ -1360,28 +1357,13 @@ class ProcessIndicator extends React.Component {
1360
1357
  className: "process-circle",
1361
1358
  cx: "50%",
1362
1359
  cy: "50%",
1363
- r: radius[this.state.size],
1360
+ r: radius[size],
1364
1361
  fillOpacity: "0.0"
1365
1362
  })
1366
1363
  })]
1367
1364
  });
1368
1365
  }
1369
1366
  }
1370
- ProcessIndicator.propTypes = {
1371
- status: PropTypes__default.default.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
1372
- size: PropTypes__default.default.oneOf(['xxs', 'xs', 'sm', 'xl']),
1373
- onAnimationCompleted: PropTypes__default.default.func,
1374
- className: PropTypes__default.default.string,
1375
- 'data-testid': PropTypes__default.default.string
1376
- };
1377
- ProcessIndicator.defaultProps = {
1378
- status: exports.Status.PROCESSING,
1379
- size: exports.Size.SMALL,
1380
- onAnimationCompleted: null,
1381
- className: undefined,
1382
- 'data-testid': null
1383
- };
1384
- var ProcessIndicator$1 = ProcessIndicator;
1385
1367
 
1386
1368
  var messages$b = reactIntl.defineMessages({
1387
1369
  loadingAriaLabel: {
@@ -1487,740 +1469,30 @@ const Button = /*#__PURE__*/React.forwardRef(({
1487
1469
  htmlType = 'button',
1488
1470
  ...restProps
1489
1471
  } = rest;
1490
- props = {
1491
- ...restProps,
1492
- disabled: disabled || loading,
1493
- type: htmlType
1494
- };
1495
- } else {
1496
- props = {
1497
- ...rest
1498
- };
1499
- }
1500
- return /*#__PURE__*/jsxRuntime.jsxs(Element, {
1501
- ref: reference,
1502
- className: classes,
1503
- ...props,
1504
- "aria-live": loading ? 'polite' : 'off',
1505
- "aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
1506
- children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
1507
- size: processIndicatorSize(),
1508
- className: "btn-loader"
1509
- })]
1510
- });
1511
- });
1512
-
1513
- const Card$2 = /*#__PURE__*/React.forwardRef(({
1514
- className,
1515
- children = null,
1516
- id,
1517
- isDisabled = false,
1518
- isSmall = false,
1519
- onDismiss,
1520
- testId,
1521
- ...props
1522
- }, ref) => {
1523
- const closeButtonReference = React.useRef(null);
1524
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1525
- ref: ref,
1526
- className: classNames__default.default('np-Card', {
1527
- 'np-Card--small': !!isSmall,
1528
- 'is-disabled': !!isDisabled
1529
- }, className),
1530
- id: id,
1531
- "data-testid": testId,
1532
- ...props,
1533
- children: [onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
1534
- ref: closeButtonReference,
1535
- className: "np-Card-closeButton",
1536
- size: isSmall ? 'sm' : 'md',
1537
- isDisabled: isDisabled,
1538
- testId: "close-button",
1539
- onClick: e => {
1540
- stopPropagation$1(e);
1541
- onDismiss();
1542
- }
1543
- }), children]
1544
- });
1545
- });
1546
- Card$2.displayName = 'Card';
1547
-
1548
- function Display({
1549
- as: Heading = 'h1',
1550
- type = exports.Typography.DISPLAY_LARGE,
1551
- children,
1552
- className,
1553
- id
1554
- }) {
1555
- return /*#__PURE__*/jsxRuntime.jsx(Heading, {
1556
- id: id,
1557
- className: classNames__default.default(`np-text-${type}`, 'text-primary', className),
1558
- children: children
1559
- });
1560
- }
1561
-
1562
- const useConditionalListener = ({
1563
- attachListener,
1564
- callback,
1565
- eventType,
1566
- parent
1567
- }) => {
1568
- React.useEffect(() => {
1569
- if (attachListener && !neptuneValidation.isUndefined(parent)) {
1570
- parent.addEventListener(eventType, callback, true);
1571
- }
1572
- return () => {
1573
- if (!neptuneValidation.isUndefined(parent)) {
1574
- parent.removeEventListener(eventType, callback, true);
1575
- }
1576
- };
1577
- }, [attachListener, callback, eventType, parent]);
1578
- };
1579
-
1580
- const DirectionContext = /*#__PURE__*/React.createContext(exports.Direction.LTR);
1581
- const DirectionProvider = ({
1582
- direction,
1583
- children
1584
- }) => {
1585
- return /*#__PURE__*/jsxRuntime.jsx(DirectionContext.Provider, {
1586
- value: direction,
1587
- children: children
1588
- });
1589
- };
1590
-
1591
- const useDirection = () => {
1592
- const direction = React.useContext(DirectionContext);
1593
- return {
1594
- direction,
1595
- isRTL: direction === 'rtl'
1596
- };
1597
- };
1598
-
1599
- const ObserverParams = {
1600
- threshold: 0.1
1601
- };
1602
-
1603
- /**
1604
- * useHasIntersected.
1605
- * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
1606
- * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
1607
- *
1608
- * @param elRef.elRef
1609
- * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
1610
- * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
1611
- * @param elRef.loading
1612
- * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
1613
- */
1614
- const useHasIntersected = ({
1615
- elRef,
1616
- loading
1617
- }) => {
1618
- const [hasIntersected, setHasIntersected] = React.useState(false);
1619
- const {
1620
- current
1621
- } = elRef || {};
1622
- const isValidReference = () => {
1623
- return elRef && current;
1624
- };
1625
- const handleOnIntersect = (entries, observer) => {
1626
- entries.forEach(entry => {
1627
- if (entry.isIntersecting) {
1628
- setHasIntersected(true);
1629
- observer.unobserve(current);
1630
- }
1631
- });
1632
- };
1633
- React.useEffect(() => {
1634
- let observer;
1635
- let didCancel = false;
1636
-
1637
- // Check if window is define for SSR and Old browsers fallback
1638
- if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
1639
- setHasIntersected(true);
1640
- } else if (!didCancel) {
1641
- observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
1642
- observer.observe(current);
1643
- }
1644
- return () => {
1645
- didCancel = true;
1646
- if (observer) {
1647
- observer.unobserve(current);
1648
- }
1649
- };
1650
- }, [elRef]);
1651
- if (loading === 'eager') {
1652
- return [false];
1653
- }
1654
- return [hasIntersected];
1655
- };
1656
-
1657
- // eslint-disable-next-line import/extensions
1658
- function useMedia(query) {
1659
- return index_js.useSyncExternalStore(onStoreChange => {
1660
- const mediaQueryList = window.matchMedia(query);
1661
- mediaQueryList.addEventListener('change', onStoreChange);
1662
- return () => {
1663
- mediaQueryList.removeEventListener('change', onStoreChange);
1664
- };
1665
- }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
1666
- }
1667
-
1668
- function useScreenSize(size) {
1669
- return useMedia(`(min-width: ${size}px)`);
1670
- }
1671
-
1672
- /**
1673
- * @deprecated Prefer `useScreenSize` instead.
1674
- */
1675
- const useLayout = () => {
1676
- const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
1677
- const screenSm = useScreenSize(exports.Breakpoint.SMALL);
1678
- const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
1679
- const screenLg = useScreenSize(exports.Breakpoint.LARGE);
1680
- const screenXl = useScreenSize(exports.Breakpoint.EXTRA_LARGE);
1681
- return {
1682
- isMobile: screenSm != null ? !screenSm : undefined,
1683
- isExtraSmall: screenXs,
1684
- isSmall: screenSm,
1685
- isMedium: screenMd,
1686
- isLarge: screenLg,
1687
- isExtraLarge: screenXl
1688
- };
1689
- };
1690
-
1691
- const EmptyTransparentImage = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
1692
- const Image = ({
1693
- id,
1694
- src,
1695
- alt,
1696
- onLoad,
1697
- onError,
1698
- className,
1699
- loading,
1700
- stretch = true,
1701
- role,
1702
- shrink = true
1703
- }) => {
1704
- const elementReference = React.useRef(null);
1705
- const [hasIntersected] = useHasIntersected({
1706
- elRef: elementReference,
1707
- loading
1708
- });
1709
- let imageSource = src;
1710
- let imageOnLoad = onLoad;
1711
- if (loading === 'lazy' && !hasIntersected) {
1712
- imageSource = EmptyTransparentImage;
1713
- imageOnLoad = undefined;
1714
- }
1715
- return /*#__PURE__*/jsxRuntime.jsx("img", {
1716
- ref: elementReference,
1717
- id: id,
1718
- alt: alt,
1719
- src: imageSource,
1720
- className: classNames__default.default(['tw-image', {
1721
- 'tw-image__stretch': stretch,
1722
- 'tw-image__shrink': shrink
1723
- }, className]),
1724
- role: role,
1725
- onLoad: imageOnLoad,
1726
- onError: onError
1727
- });
1728
- };
1729
-
1730
- const defaultPromoCardContext = {
1731
- state: '',
1732
- isDisabled: false,
1733
- // eslint-disable-next-line @typescript-eslint/no-empty-function
1734
- onChange: () => {}
1735
- };
1736
- /**
1737
- * The PromoCard context object.
1738
- */
1739
- const PromoCardContext = /*#__PURE__*/React.createContext(defaultPromoCardContext);
1740
- /**
1741
- * A custom hook for accessing the PromoCard context object.
1742
- *
1743
- * The `usePromoCardContext` hook is used to access the PromoCard context object
1744
- * from within a child PromoCard component. It throws an error if the context
1745
- * object is not available, which can help with debugging and development.
1746
- *
1747
- * @returns {PromoCardContextType} - The PromoCard context object.
1748
- */
1749
- const usePromoCardContext = () => {
1750
- return React.useContext(PromoCardContext);
1751
- };
1752
-
1753
- const PromoCardIndicator = ({
1754
- className,
1755
- children,
1756
- label,
1757
- icon,
1758
- isSmall = false,
1759
- testid,
1760
- ...rest
1761
- }) => {
1762
- const isIconString = icon && typeof icon === 'string';
1763
- const IconComponent = isIconString && {
1764
- check: icons.Check,
1765
- arrow: icons.ArrowRight,
1766
- download: icons.Download
1767
- }[icon];
1768
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1769
- className: classNames__default.default('np-Card-indicator', className),
1770
- "data-testid": testid,
1771
- ...rest,
1772
- children: [label && /*#__PURE__*/jsxRuntime.jsx(Body, {
1773
- as: "span",
1774
- type: exports.Typography.BODY_LARGE_BOLD,
1775
- className: "np-Card-indicatorText",
1776
- children: label
1777
- }), icon && /*#__PURE__*/jsxRuntime.jsx(Avatar, {
1778
- type: exports.AvatarType.ICON,
1779
- size: isSmall ? 40 : 56,
1780
- backgroundColor: "var(--Card-indicator-icon-background-color)",
1781
- className: "np-Card-indicatorIcon",
1782
- children: IconComponent ? /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
1783
- size: 24,
1784
- "aria-hidden": "true"
1785
- }) : icon
1786
- }), children]
1787
- });
1788
- };
1789
-
1790
- const PromoCard = /*#__PURE__*/React.forwardRef(({
1791
- className,
1792
- description,
1793
- defaultChecked,
1794
- download,
1795
- href,
1796
- hrefLang,
1797
- id,
1798
- headingLevel = 'h3',
1799
- imageAlt,
1800
- imageClass,
1801
- imageSource,
1802
- indicatorLabel,
1803
- indicatorIcon,
1804
- isChecked,
1805
- isDisabled,
1806
- onClick,
1807
- onKeyDown,
1808
- rel,
1809
- tabIndex,
1810
- target,
1811
- testId,
1812
- title,
1813
- type,
1814
- value,
1815
- isSmall,
1816
- useDisplayFont = true,
1817
- anchorRef,
1818
- anchorId,
1819
- ...props
1820
- }, ref) => {
1821
- // Set the `checked` state to the value of `defaultChecked` if it is truthy,
1822
- // or the value of `isChecked` if it is truthy, or `false` if neither
1823
- // is truthy.
1824
- const {
1825
- state,
1826
- onChange,
1827
- isDisabled: contextIsDisabled
1828
- } = usePromoCardContext();
1829
- const [checked, setChecked] = React.useState(type === 'checkbox' ? defaultChecked ?? isChecked ?? false : false);
1830
- const handleClick = () => {
1831
- if (type === 'radio') {
1832
- onChange(value || ''); // Update the context state for radio
1833
- } else if (type === 'checkbox') {
1834
- setChecked(!checked); // Update local state for checkbox
1835
- }
1836
- };
1837
- const fallbackId = reactId.useId();
1838
- const componentId = id || fallbackId;
1839
- // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
1840
- // `'download'` if `download` is truthy. If neither condition is true, set
1841
- // `icon` to `undefined`.
1842
- // Create a function to get icon type
1843
- const getIconType = () => {
1844
- if (indicatorIcon) {
1845
- return indicatorIcon;
1846
- }
1847
- if (download) {
1848
- return 'download';
1849
- }
1850
- if (href && !type) {
1851
- return 'arrow';
1852
- }
1853
- return undefined;
1854
- };
1855
- // Define all class names string based on the values of the `href`, `type`,
1856
- // `checked`, and `className` props.
1857
- const commonClasses = classNames__default.default({
1858
- 'np-Card--promoCard': true,
1859
- 'np-Card--checked': !href && type,
1860
- 'np-Card--link': href && !type,
1861
- 'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined
1862
- }, className);
1863
- // Object with common props that will be passed to the `Card` components
1864
- const commonProps = {
1865
- className: commonClasses,
1866
- id: componentId,
1867
- isDisabled: isDisabled || contextIsDisabled,
1868
- onClick,
1869
- onKeyDown,
1870
- ref,
1871
- 'data-testid': testId,
1872
- isSmall
1873
- };
1874
- // Object with Anchor props that will be passed to the `a` element. These
1875
- // won't be refurned if set to `isDisabled`
1876
- const anchorProps = href && !isDisabled ? {
1877
- download,
1878
- href: href || undefined,
1879
- hrefLang,
1880
- rel,
1881
- target,
1882
- ref: anchorRef,
1883
- id: anchorId
1884
- } : {};
1885
- // Object of all Checked props that will be passed to the root `Card` component
1886
- const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
1887
- ...commonProps,
1888
- 'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
1889
- 'aria-describedby': `${componentId}-title`,
1890
- 'aria-disabled': isDisabled,
1891
- 'data-value': value ?? undefined,
1892
- role: type === 'checkbox' || type === 'radio' ? type : undefined,
1893
- onClick: handleClick,
1894
- onKeyDown: event => {
1895
- if (event.key === 'Enter' || event.key === ' ') {
1896
- handleClick();
1897
- }
1898
- },
1899
- ref,
1900
- tabIndex: 0
1901
- } : {};
1902
- const getTitle = () => {
1903
- const titleContent = href && !type ? /*#__PURE__*/jsxRuntime.jsx("a", {
1904
- className: "np-Card-titleLink",
1905
- ...anchorProps,
1906
- children: title
1907
- }) : title;
1908
- const titleProps = {
1909
- id: `${componentId}-title`,
1910
- as: headingLevel,
1911
- className: 'np-Card-title'
1472
+ props = {
1473
+ ...restProps,
1474
+ disabled: disabled || loading,
1475
+ type: htmlType
1912
1476
  };
1913
- return useDisplayFont ? /*#__PURE__*/jsxRuntime.jsx(Display, {
1914
- type: exports.Typography.DISPLAY_SMALL,
1915
- ...titleProps,
1916
- children: titleContent
1917
- }) : /*#__PURE__*/jsxRuntime.jsx(Title, {
1918
- type: exports.Typography.TITLE_SUBSECTION,
1919
- ...titleProps,
1920
- children: titleContent
1921
- });
1922
- };
1923
- React.useEffect(() => {
1924
- setChecked(defaultChecked ?? isChecked ?? false);
1925
- }, [defaultChecked, isChecked]);
1926
- return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
1927
- ...commonProps,
1928
- ...checkedProps,
1477
+ } else {
1478
+ props = {
1479
+ ...rest
1480
+ };
1481
+ }
1482
+ return /*#__PURE__*/jsxRuntime.jsxs(Element, {
1483
+ ref: reference,
1484
+ className: classes,
1929
1485
  ...props,
1930
- children: [(value === state || checked) && /*#__PURE__*/jsxRuntime.jsx("span", {
1931
- className: "np-Card-check",
1932
- children: /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
1933
- size: 24,
1934
- "aria-hidden": "true"
1935
- })
1936
- }), getTitle(), /*#__PURE__*/jsxRuntime.jsx(Body, {
1937
- className: "np-Card-description",
1938
- children: description
1939
- }), imageSource && /*#__PURE__*/jsxRuntime.jsx("div", {
1940
- className: classNames__default.default('np-Card-image', {
1941
- imageClass
1942
- }),
1943
- children: /*#__PURE__*/jsxRuntime.jsx(Image, {
1944
- src: imageSource,
1945
- alt: imageAlt || '',
1946
- loading: "lazy"
1947
- })
1948
- }), /*#__PURE__*/jsxRuntime.jsx(PromoCardIndicator, {
1949
- label: indicatorLabel,
1950
- icon: getIconType(),
1951
- isSmall: isSmall
1486
+ "aria-live": loading ? 'polite' : 'off',
1487
+ "aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
1488
+ children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
1489
+ size: processIndicatorSize(),
1490
+ className: "btn-loader"
1952
1491
  })]
1953
1492
  });
1954
1493
  });
1955
- var PromoCard$1 = /*#__PURE__*/React__namespace.default.memo(PromoCard);
1956
-
1957
- const LEFT_SCROLL_OFFSET = 8;
1958
- const Carousel = ({
1959
- header,
1960
- className,
1961
- cards,
1962
- onClick
1963
- }) => {
1964
- const [scrollPosition, setScrollPosition] = React.useState(0);
1965
- const [previousScrollPosition, setPreviousScrollPosition] = React.useState(0);
1966
- const [scrollIsAtEnd, setScrollIsAtEnd] = React.useState(false);
1967
- const [visibleCardOnMobileView, setVisibleCardOnMobileView] = React.useState('');
1968
- const carouselElementRef = React.useRef(null);
1969
- const carouselCardsRef = React.useRef([]);
1970
- const isLeftActionButtonEnabled = scrollPosition > LEFT_SCROLL_OFFSET;
1971
- const areActionButtonsEnabled = isLeftActionButtonEnabled || !scrollIsAtEnd;
1972
- const [focusedCard, setFocusedCard] = React.useState(cards?.[0]?.id);
1973
- const updateScrollButtonsState = () => {
1974
- if (carouselElementRef.current) {
1975
- const {
1976
- scrollWidth,
1977
- offsetWidth
1978
- } = carouselElementRef.current;
1979
- const scrollAtEnd = scrollWidth - offsetWidth <= scrollPosition + LEFT_SCROLL_OFFSET;
1980
- setScrollIsAtEnd(scrollAtEnd);
1981
- }
1982
- const scrollDirecton = scrollPosition > previousScrollPosition ? 'right' : 'left';
1983
- const cardsInFullViewIds = [];
1984
- carouselCardsRef.current.forEach(card => {
1985
- if (isVisible(carouselElementRef.current, card.cardElement)) {
1986
- // eslint-disable-next-line functional/immutable-data
1987
- cardsInFullViewIds.push(card.cardElement.getAttribute('id') ?? '');
1988
- }
1989
- });
1990
- if (cardsInFullViewIds.length >= 1) {
1991
- const visibleCardIndex = scrollDirecton === 'right' ? cardsInFullViewIds.length - 1 : 0;
1992
- const visibleCardId = cardsInFullViewIds[visibleCardIndex];
1993
- setVisibleCardOnMobileView(visibleCardId);
1994
- setFocusedCard(visibleCardId);
1995
- }
1996
- setPreviousScrollPosition(scrollPosition);
1997
- };
1998
- const scrollCarousel = (direction = 'right') => {
1999
- if (carouselElementRef.current) {
2000
- const {
2001
- scrollWidth
2002
- } = carouselElementRef.current;
2003
- const cardWidth = scrollWidth / carouselCardsRef.current.length;
2004
- const res = Math.floor(cardWidth - cardWidth * 0.05);
2005
- carouselElementRef.current.scrollBy({
2006
- left: direction === 'right' ? res : -res,
2007
- behavior: 'smooth'
2008
- });
2009
- }
2010
- };
2011
- const handleOnKeyDown = (event, index) => {
2012
- if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
2013
- const nextIndex = event.key === 'ArrowRight' ? index + 1 : index - 1;
2014
- const nextCard = cards[nextIndex];
2015
- if (nextCard) {
2016
- const ref = carouselCardsRef.current[nextIndex];
2017
- if (ref.type === 'promo') {
2018
- ref.anchorElement?.focus();
2019
- } else {
2020
- ref.cardElement?.focus();
2021
- }
2022
- scrollCardIntoView(carouselCardsRef.current[nextIndex].cardElement, nextCard);
2023
- event.preventDefault();
2024
- }
2025
- }
2026
- if (event.key === 'Enter' || event.key === ' ') {
2027
- event.currentTarget.click();
2028
- }
2029
- };
2030
- const scrollCardIntoView = (element, card) => {
2031
- element.scrollIntoView({
2032
- behavior: 'smooth',
2033
- block: 'nearest',
2034
- inline: 'center'
2035
- });
2036
- setFocusedCard(card.id);
2037
- };
2038
- React.useEffect(() => {
2039
- updateScrollButtonsState();
2040
- // eslint-disable-next-line react-hooks/exhaustive-deps
2041
- }, [scrollPosition]);
2042
- React.useEffect(() => {
2043
- window.addEventListener('resize', updateScrollButtonsState);
2044
- return () => {
2045
- window.removeEventListener('resize', updateScrollButtonsState);
2046
- };
2047
- // eslint-disable-next-line react-hooks/exhaustive-deps
2048
- }, []);
2049
- const addElementToCardsRefArray = (index, ref) => {
2050
- if (ref) {
2051
- // eslint-disable-next-line functional/immutable-data
2052
- carouselCardsRef.current[index] = {
2053
- type: ref.type ?? carouselCardsRef.current?.[index]?.type,
2054
- cardElement: ref.cardElement ?? carouselCardsRef.current?.[index]?.cardElement,
2055
- anchorElement: ref.anchorElement ?? carouselCardsRef.current?.[index]?.anchorElement
2056
- };
2057
- }
2058
- };
2059
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2060
- className: classNames__default.default('carousel-wrapper', className),
2061
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2062
- className: "d-flex justify-content-between carousel__header",
2063
- children: [typeof header === 'string' ? /*#__PURE__*/jsxRuntime.jsx(Title, {
2064
- as: "span",
2065
- type: "title-body",
2066
- children: header
2067
- }) : header, areActionButtonsEnabled ? /*#__PURE__*/jsxRuntime.jsxs("div", {
2068
- className: "hidden-xs",
2069
- children: [/*#__PURE__*/jsxRuntime.jsx(ActionButton, {
2070
- className: "carousel__scroll-button",
2071
- tabIndex: -1,
2072
- priority: "secondary",
2073
- disabled: !isLeftActionButtonEnabled,
2074
- "aria-hidden": "true",
2075
- "data-testid": "scroll-carousel-left",
2076
- onClick: () => scrollCarousel('left'),
2077
- children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronLeft, {})
2078
- }), /*#__PURE__*/jsxRuntime.jsx(ActionButton, {
2079
- tabIndex: -1,
2080
- className: "carousel__scroll-button m-l-1",
2081
- priority: "secondary",
2082
- "aria-hidden": "true",
2083
- "data-testid": "scroll-carousel-right",
2084
- disabled: scrollIsAtEnd,
2085
- onClick: () => scrollCarousel(),
2086
- children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronRight, {})
2087
- })]
2088
- }) : null]
2089
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2090
- ref: carouselElementRef,
2091
- tabIndex: -1,
2092
- role: "list",
2093
- className: "carousel",
2094
- onScroll: event => {
2095
- const target = event.target;
2096
- setScrollPosition(target.scrollLeft);
2097
- },
2098
- children: cards?.map((card, index) => {
2099
- const sharedProps = {
2100
- id: card.id,
2101
- className: classNames__default.default('carousel__card', {
2102
- 'carousel__card--focused': card.id === focusedCard
2103
- }),
2104
- onClick: () => {
2105
- card.onClick?.();
2106
- onClick?.(card.id);
2107
- },
2108
- onFocus: event => {
2109
- scrollCardIntoView(event.currentTarget, card);
2110
- }
2111
- };
2112
- const cardContent = card.type !== 'promo' ? /*#__PURE__*/jsxRuntime.jsx("div", {
2113
- id: `${card.id}-content`,
2114
- className: classNames__default.default('carousel__card-content', {
2115
- [card.className ?? '']: !!card.className
2116
- })
2117
- // eslint-disable-next-line react/forbid-dom-props
2118
- ,
2119
- style: card.styles,
2120
- children: card.content
2121
- }) : null;
2122
- if (card.type === 'button') {
2123
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2124
- "aria-labelledby": `${card.id}-content`,
2125
- role: "listitem",
2126
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
2127
- ...sharedProps,
2128
- ref: el => {
2129
- if (el) {
2130
- // eslint-disable-next-line functional/immutable-data
2131
- carouselCardsRef.current[index] = {
2132
- type: 'default',
2133
- cardElement: el
2134
- };
2135
- }
2136
- },
2137
- role: "button",
2138
- tabIndex: 0,
2139
- onKeyDown: event => handleOnKeyDown(event, index),
2140
- children: cardContent
2141
- })
2142
- }, card.id);
2143
- }
2144
- if (card.type === 'promo') {
2145
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2146
- id: card.id,
2147
- role: "listitem",
2148
- "aria-labelledby": `${card.id}-anchor`,
2149
- children: /*#__PURE__*/jsxRuntime.jsx(PromoCard$1, {
2150
- ...card,
2151
- type: undefined,
2152
- ...sharedProps,
2153
- ref: el => {
2154
- if (el) {
2155
- addElementToCardsRefArray(index, {
2156
- type: 'promo',
2157
- cardElement: el
2158
- });
2159
- }
2160
- },
2161
- anchorRef: el => {
2162
- if (el) {
2163
- addElementToCardsRefArray(index, {
2164
- type: 'promo',
2165
- anchorElement: el
2166
- });
2167
- }
2168
- },
2169
- anchorId: `${card.id}-anchor`,
2170
- onKeyDown: event => handleOnKeyDown(event, index)
2171
- })
2172
- }, card.id);
2173
- }
2174
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2175
- "aria-labelledby": `${card.id}-content`,
2176
- role: "listitem",
2177
- children: /*#__PURE__*/jsxRuntime.jsx("a", {
2178
- ...sharedProps,
2179
- ref: el => {
2180
- if (el) {
2181
- // eslint-disable-next-line functional/immutable-data
2182
- carouselCardsRef.current[index] = {
2183
- type: 'default',
2184
- cardElement: el
2185
- };
2186
- }
2187
- },
2188
- href: card.href,
2189
- rel: "noreferrer",
2190
- onKeyDown: event => handleOnKeyDown(event, index),
2191
- children: cardContent
2192
- })
2193
- }, card.id);
2194
- })
2195
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2196
- className: "visible-xs",
2197
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
2198
- className: "carousel__indicators",
2199
- children: cards?.map((card, index) => /*#__PURE__*/jsxRuntime.jsx("button", {
2200
- "data-testid": `${card.id}-indicator`,
2201
- tabIndex: -1,
2202
- "aria-hidden": true,
2203
- type: "button",
2204
- className: classNames__default.default('carousel__indicator', {
2205
- 'carousel__indicator--selected': card.id === visibleCardOnMobileView
2206
- }),
2207
- onClick: () => {
2208
- scrollCardIntoView(carouselCardsRef.current[index].cardElement, card);
2209
- }
2210
- }, `${card.id}-indicator`))
2211
- })
2212
- })]
2213
- });
2214
- };
2215
- const isVisible = (container, el) => {
2216
- const cWidth = container.offsetWidth;
2217
- const cScrollOffset = container.scrollLeft;
2218
- const elemLeft = el.offsetLeft - container.offsetLeft;
2219
- const elemRight = elemLeft + el.offsetWidth;
2220
- return elemLeft >= cScrollOffset && elemRight <= cScrollOffset + cWidth;
2221
- };
2222
1494
 
2223
- const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
1495
+ const Card$1 = /*#__PURE__*/React.forwardRef((props, reference) => {
2224
1496
  const {
2225
1497
  'aria-label': ariaLabel,
2226
1498
  as: Element,
@@ -2271,7 +1543,7 @@ const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
2271
1543
  const hasChildren = ({
2272
1544
  children
2273
1545
  }) => children;
2274
- Card.propTypes = {
1546
+ Card$1.propTypes = {
2275
1547
  'aria-label': PropTypes__default.default.string,
2276
1548
  as: PropTypes__default.default.string,
2277
1549
  isExpanded: requiredIf__default.default(PropTypes__default.default.bool, hasChildren),
@@ -2284,7 +1556,7 @@ Card.propTypes = {
2284
1556
  className: PropTypes__default.default.string,
2285
1557
  'data-testid': PropTypes__default.default.string
2286
1558
  };
2287
- Card.defaultProps = {
1559
+ Card$1.defaultProps = {
2288
1560
  'aria-label': undefined,
2289
1561
  as: 'div',
2290
1562
  children: null,
@@ -2292,7 +1564,7 @@ Card.defaultProps = {
2292
1564
  className: null,
2293
1565
  'data-testid': null
2294
1566
  };
2295
- var Card$1 = Card;
1567
+ var Card$2 = Card$1;
2296
1568
 
2297
1569
  const CheckboxButton = /*#__PURE__*/React.forwardRef(({
2298
1570
  checked,
@@ -2776,7 +2048,135 @@ const DimmerContentWrapper = ({
2776
2048
  }, [scrollBody]);
2777
2049
  return children;
2778
2050
  };
2779
- var Dimmer$1 = withNextPortalWrapper(Dimmer);
2051
+ var Dimmer$1 = withNextPortalWrapper(Dimmer);
2052
+
2053
+ const useConditionalListener = ({
2054
+ attachListener,
2055
+ callback,
2056
+ eventType,
2057
+ parent
2058
+ }) => {
2059
+ React.useEffect(() => {
2060
+ if (attachListener && !neptuneValidation.isUndefined(parent)) {
2061
+ parent.addEventListener(eventType, callback, true);
2062
+ }
2063
+ return () => {
2064
+ if (!neptuneValidation.isUndefined(parent)) {
2065
+ parent.removeEventListener(eventType, callback, true);
2066
+ }
2067
+ };
2068
+ }, [attachListener, callback, eventType, parent]);
2069
+ };
2070
+
2071
+ const DirectionContext = /*#__PURE__*/React.createContext(exports.Direction.LTR);
2072
+ const DirectionProvider = ({
2073
+ direction,
2074
+ children
2075
+ }) => {
2076
+ return /*#__PURE__*/jsxRuntime.jsx(DirectionContext.Provider, {
2077
+ value: direction,
2078
+ children: children
2079
+ });
2080
+ };
2081
+
2082
+ const useDirection = () => {
2083
+ const direction = React.useContext(DirectionContext);
2084
+ return {
2085
+ direction,
2086
+ isRTL: direction === 'rtl'
2087
+ };
2088
+ };
2089
+
2090
+ const ObserverParams = {
2091
+ threshold: 0.1
2092
+ };
2093
+
2094
+ /**
2095
+ * useHasIntersected.
2096
+ * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
2097
+ * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
2098
+ *
2099
+ * @param elRef.elRef
2100
+ * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
2101
+ * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
2102
+ * @param elRef.loading
2103
+ * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
2104
+ */
2105
+ const useHasIntersected = ({
2106
+ elRef,
2107
+ loading
2108
+ }) => {
2109
+ const [hasIntersected, setHasIntersected] = React.useState(false);
2110
+ const {
2111
+ current
2112
+ } = elRef || {};
2113
+ const isValidReference = () => {
2114
+ return elRef && current;
2115
+ };
2116
+ const handleOnIntersect = (entries, observer) => {
2117
+ entries.forEach(entry => {
2118
+ if (entry.isIntersecting) {
2119
+ setHasIntersected(true);
2120
+ observer.unobserve(current);
2121
+ }
2122
+ });
2123
+ };
2124
+ React.useEffect(() => {
2125
+ let observer;
2126
+ let didCancel = false;
2127
+
2128
+ // Check if window is define for SSR and Old browsers fallback
2129
+ if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
2130
+ setHasIntersected(true);
2131
+ } else if (!didCancel) {
2132
+ observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
2133
+ observer.observe(current);
2134
+ }
2135
+ return () => {
2136
+ didCancel = true;
2137
+ if (observer) {
2138
+ observer.unobserve(current);
2139
+ }
2140
+ };
2141
+ }, [elRef]);
2142
+ if (loading === 'eager') {
2143
+ return [false];
2144
+ }
2145
+ return [hasIntersected];
2146
+ };
2147
+
2148
+ function useMedia(query) {
2149
+ return React.useSyncExternalStore(onStoreChange => {
2150
+ const mediaQueryList = window.matchMedia(query);
2151
+ mediaQueryList.addEventListener('change', onStoreChange);
2152
+ return () => {
2153
+ mediaQueryList.removeEventListener('change', onStoreChange);
2154
+ };
2155
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
2156
+ }
2157
+
2158
+ function useScreenSize(size) {
2159
+ return useMedia(`(min-width: ${size}px)`);
2160
+ }
2161
+
2162
+ /**
2163
+ * @deprecated Prefer `useScreenSize` instead.
2164
+ */
2165
+ const useLayout = () => {
2166
+ const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
2167
+ const screenSm = useScreenSize(exports.Breakpoint.SMALL);
2168
+ const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
2169
+ const screenLg = useScreenSize(exports.Breakpoint.LARGE);
2170
+ const screenXl = useScreenSize(exports.Breakpoint.EXTRA_LARGE);
2171
+ return {
2172
+ isMobile: screenSm != null ? !screenSm : undefined,
2173
+ isExtraSmall: screenXs,
2174
+ isSmall: screenSm,
2175
+ isMedium: screenMd,
2176
+ isLarge: screenLg,
2177
+ isExtraLarge: screenXl
2178
+ };
2179
+ };
2780
2180
 
2781
2181
  const EXIT_ANIMATION = 350;
2782
2182
  const SlidingPanel = /*#__PURE__*/React.forwardRef(({
@@ -2824,7 +2224,7 @@ const Drawer = ({
2824
2224
  const {
2825
2225
  isMobile
2826
2226
  } = useLayout();
2827
- const titleId = reactId.useId();
2227
+ const titleId = React.useId();
2828
2228
  return /*#__PURE__*/jsxRuntime.jsx(Dimmer$1, {
2829
2229
  open: open,
2830
2230
  onClose: onClose,
@@ -2866,12 +2266,12 @@ Drawer.propTypes = {
2866
2266
  footerContent: PropTypes__default.default.node,
2867
2267
  /** The content to appear in the drawer header. */
2868
2268
  headerTitle: PropTypes__default.default.node,
2869
- /** The action to perform on close click. */
2870
- onClose: PropTypes__default.default.func,
2871
2269
  /** The status of Drawer either open or not. */
2872
2270
  open: PropTypes__default.default.bool,
2873
2271
  /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
2874
- position: PropTypes__default.default.oneOf(['left', 'right', 'bottom'])
2272
+ position: PropTypes__default.default.oneOf(['left', 'right', 'bottom']),
2273
+ /** The action to perform on close click. */
2274
+ onClose: PropTypes__default.default.func
2875
2275
  };
2876
2276
  Drawer.defaultProps = {
2877
2277
  children: null,
@@ -3057,6 +2457,39 @@ const BottomSheet$1 = props => {
3057
2457
  });
3058
2458
  };
3059
2459
 
2460
+ const Card = ({
2461
+ className,
2462
+ children = null,
2463
+ id,
2464
+ isDisabled = false,
2465
+ isSmall = false,
2466
+ onDismiss,
2467
+ testId,
2468
+ ...props
2469
+ }) => {
2470
+ const closeButtonReference = React.useRef(null);
2471
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
2472
+ className: classNames__default.default('np-Card', {
2473
+ 'np-Card--small': !!isSmall,
2474
+ 'is-disabled': !!isDisabled
2475
+ }, className),
2476
+ id: id,
2477
+ "data-testid": testId,
2478
+ ...props,
2479
+ children: [onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
2480
+ ref: closeButtonReference,
2481
+ className: "np-Card-closeButton",
2482
+ size: isSmall ? 'sm' : 'md',
2483
+ isDisabled: isDisabled,
2484
+ testId: "close-button",
2485
+ onClick: e => {
2486
+ stopPropagation$1(e);
2487
+ onDismiss();
2488
+ }
2489
+ }), children]
2490
+ });
2491
+ };
2492
+
3060
2493
  function CriticalCommsBanner({
3061
2494
  title,
3062
2495
  subtitle,
@@ -3546,7 +2979,7 @@ const fallbackPlacements = {
3546
2979
  [exports.Position.LEFT]: [exports.Position.RIGHT, exports.Position.TOP, exports.Position.BOTTOM],
3547
2980
  [exports.Position.RIGHT]: [exports.Position.LEFT, exports.Position.TOP, exports.Position.BOTTOM]
3548
2981
  };
3549
- const Panel = /*#__PURE__*/React.forwardRef(({
2982
+ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
3550
2983
  arrow = false,
3551
2984
  flip = true,
3552
2985
  altAxis = false,
@@ -3557,7 +2990,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3557
2990
  anchorRef,
3558
2991
  anchorWidth = false,
3559
2992
  ...rest
3560
- }, reference) => {
2993
+ }, reference) {
3561
2994
  const [arrowElement, setArrowElement] = React.useState(null);
3562
2995
  const [popperElement, setPopperElement] = React.useState(null);
3563
2996
  const modifiers = [];
@@ -3635,7 +3068,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3635
3068
  ...attributes.popper,
3636
3069
  className: classNames__default.default('np-panel', {
3637
3070
  'np-panel--open': open
3638
- }, rest['className']),
3071
+ }, rest.className),
3639
3072
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
3640
3073
  ref: reference
3641
3074
  /* eslint-disable-next-line react/forbid-dom-props */,
@@ -3654,7 +3087,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3654
3087
  });
3655
3088
  var Panel$1 = Panel;
3656
3089
 
3657
- const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
3090
+ const ResponsivePanel = /*#__PURE__*/React.forwardRef(function ResponsivePanel({
3658
3091
  anchorRef,
3659
3092
  arrow = false,
3660
3093
  flip = true,
@@ -3663,7 +3096,7 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
3663
3096
  onClose,
3664
3097
  open = false,
3665
3098
  position = exports.Position.BOTTOM
3666
- }, reference) => {
3099
+ }, reference) {
3667
3100
  const {
3668
3101
  isMobile
3669
3102
  } = useLayout();
@@ -4914,6 +4347,20 @@ DefinitionList.defaultProps = {
4914
4347
  };
4915
4348
  var DefinitionList$1 = DefinitionList;
4916
4349
 
4350
+ function Display({
4351
+ as: Heading = 'h1',
4352
+ type = exports.Typography.DISPLAY_LARGE,
4353
+ children,
4354
+ className,
4355
+ id
4356
+ }) {
4357
+ return /*#__PURE__*/jsxRuntime.jsx(Heading, {
4358
+ id: id,
4359
+ className: classNames__default.default(`np-text-${type}`, 'text-primary', className),
4360
+ children: children
4361
+ });
4362
+ }
4363
+
4917
4364
  const DropFade = ({
4918
4365
  children,
4919
4366
  show
@@ -5002,6 +4449,84 @@ const Emphasis = ({
5002
4449
  }) : null;
5003
4450
  };
5004
4451
 
4452
+ function InlineAlert({
4453
+ id,
4454
+ type = 'neutral',
4455
+ className,
4456
+ children
4457
+ }) {
4458
+ const danger = type === 'negative' || type === 'error';
4459
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
4460
+ role: "alert",
4461
+ id: id,
4462
+ className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4463
+ children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
4464
+ children: children
4465
+ })]
4466
+ });
4467
+ }
4468
+
4469
+ const Label = ({
4470
+ id,
4471
+ htmlFor,
4472
+ className,
4473
+ children
4474
+ }) => {
4475
+ return /*#__PURE__*/jsxRuntime.jsx("label", {
4476
+ id: id,
4477
+ htmlFor: htmlFor,
4478
+ className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
4479
+ children: children
4480
+ });
4481
+ };
4482
+
4483
+ const Field = ({
4484
+ id,
4485
+ label,
4486
+ hint,
4487
+ error,
4488
+ className,
4489
+ children
4490
+ }) => {
4491
+ const hasError = Boolean(error);
4492
+ const hasHint = Boolean(hint) && !hasError;
4493
+ const labelId = React.useId();
4494
+ const fallbackInputId = React.useId();
4495
+ const inputId = id !== null ? id ?? fallbackInputId : undefined;
4496
+ const descriptionId = React.useId();
4497
+ return /*#__PURE__*/jsxRuntime.jsx(FieldLabelIdContextProvider, {
4498
+ value: labelId,
4499
+ children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
4500
+ value: inputId,
4501
+ children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
4502
+ value: hasError || hasHint ? descriptionId : undefined,
4503
+ children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
4504
+ value: hasError,
4505
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4506
+ className: classNames__default.default('form-group d-block', {
4507
+ 'has-error': hasError,
4508
+ 'has-info': hasHint
4509
+ }, className),
4510
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
4511
+ id: labelId,
4512
+ htmlFor: inputId,
4513
+ children: [label, children]
4514
+ }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4515
+ type: exports.Sentiment.NEUTRAL,
4516
+ id: descriptionId,
4517
+ children: hint
4518
+ }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4519
+ type: exports.Sentiment.NEGATIVE,
4520
+ id: descriptionId,
4521
+ children: error
4522
+ })]
4523
+ })
4524
+ })
4525
+ })
4526
+ })
4527
+ });
4528
+ };
4529
+
5005
4530
  const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
5006
4531
  bottomContent,
5007
4532
  className,
@@ -5208,7 +4733,7 @@ const Tooltip = ({
5208
4733
  const anchorReference = React.useRef(null);
5209
4734
  const [arrowElement, setArrowElement] = React.useState(null);
5210
4735
  const [popperElement, setPopperElement] = React.useState(null);
5211
- const fallbackId = reactId.useId();
4736
+ const fallbackId = React.useId();
5212
4737
  const tooltipId = id ?? fallbackId;
5213
4738
  const modifiers = [];
5214
4739
  modifiers.push({
@@ -5248,42 +4773,40 @@ const Tooltip = ({
5248
4773
  forceUpdate();
5249
4774
  }
5250
4775
  }, [open]);
5251
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5252
- children: /*#__PURE__*/jsxRuntime.jsxs("span", {
5253
- ref: anchorReference,
5254
- className: "tw-tooltip-container",
5255
- onMouseOver: () => setOpen(true),
5256
- onFocus: () => setOpen(true),
5257
- onMouseOut: () => setOpen(false),
5258
- onBlur: () => setOpen(false),
5259
- children: [children ? /*#__PURE__*/React.cloneElement(children, {
5260
- 'aria-describedby': `${tooltipId}-tooltip`
5261
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5262
- // @ts-expect-error
5263
- ref: setPopperElement,
5264
- className: classNames__default.default('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
5265
- // eslint-disable-next-line react/forbid-dom-props
5266
- ,
5267
- style: {
5268
- ...styles.popper
5269
- },
5270
- ...attributes.popper,
5271
- "aria-hidden": !open,
5272
- role: "tooltip",
5273
- id: `${tooltipId}-tooltip`,
5274
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5275
- className: "np-panel__content tooltip-inner",
5276
- children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
5277
- // @ts-expect-error
5278
- ref: setArrowElement,
5279
- className: classNames__default.default('np-panel__arrow')
5280
- // eslint-disable-next-line react/forbid-dom-props
5281
- ,
5282
- style: styles.arrow
5283
- })]
5284
- })
5285
- })]
5286
- })
4776
+ return /*#__PURE__*/jsxRuntime.jsxs("span", {
4777
+ ref: anchorReference,
4778
+ className: "tw-tooltip-container",
4779
+ onMouseOver: () => setOpen(true),
4780
+ onFocus: () => setOpen(true),
4781
+ onMouseOut: () => setOpen(false),
4782
+ onBlur: () => setOpen(false),
4783
+ children: [children ? /*#__PURE__*/React.cloneElement(children, {
4784
+ 'aria-describedby': `${tooltipId}-tooltip`
4785
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
4786
+ // @ts-expect-error
4787
+ ref: setPopperElement,
4788
+ className: classNames__default.default('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
4789
+ // eslint-disable-next-line react/forbid-dom-props
4790
+ ,
4791
+ style: {
4792
+ ...styles.popper
4793
+ },
4794
+ ...attributes.popper,
4795
+ "aria-hidden": !open,
4796
+ role: "tooltip",
4797
+ id: `${tooltipId}-tooltip`,
4798
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4799
+ className: "np-panel__content tooltip-inner",
4800
+ children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
4801
+ // @ts-expect-error
4802
+ ref: setArrowElement,
4803
+ className: classNames__default.default('np-panel__arrow')
4804
+ // eslint-disable-next-line react/forbid-dom-props
4805
+ ,
4806
+ style: styles.arrow
4807
+ })]
4808
+ })
4809
+ })]
5287
4810
  });
5288
4811
  };
5289
4812
 
@@ -5481,84 +5004,6 @@ const FlowNavigation = ({
5481
5004
  });
5482
5005
  };
5483
5006
 
5484
- function InlineAlert({
5485
- id,
5486
- type = 'neutral',
5487
- className,
5488
- children
5489
- }) {
5490
- const danger = type === 'negative' || type === 'error';
5491
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
5492
- role: "alert",
5493
- id: id,
5494
- className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
5495
- children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
5496
- children: children
5497
- })]
5498
- });
5499
- }
5500
-
5501
- const Label = ({
5502
- id,
5503
- htmlFor,
5504
- className,
5505
- children
5506
- }) => {
5507
- return /*#__PURE__*/jsxRuntime.jsx("label", {
5508
- id: id,
5509
- htmlFor: htmlFor,
5510
- className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
5511
- children: children
5512
- });
5513
- };
5514
-
5515
- const Field = ({
5516
- id,
5517
- label,
5518
- hint,
5519
- error,
5520
- className,
5521
- children
5522
- }) => {
5523
- const hasError = Boolean(error);
5524
- const hasHint = Boolean(hint) && !hasError;
5525
- const labelId = reactId.useId();
5526
- const fallbackInputId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
5527
- const inputId = id !== null ? id ?? fallbackInputId : undefined;
5528
- const descriptionId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
5529
- return /*#__PURE__*/jsxRuntime.jsx(FieldLabelIdContextProvider, {
5530
- value: labelId,
5531
- children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
5532
- value: inputId,
5533
- children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
5534
- value: hasError || hasHint ? descriptionId : undefined,
5535
- children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
5536
- value: hasError,
5537
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5538
- className: classNames__default.default('form-group d-block', {
5539
- 'has-error': hasError,
5540
- 'has-info': hasHint
5541
- }, className),
5542
- children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
5543
- id: labelId,
5544
- htmlFor: inputId,
5545
- children: [label, children]
5546
- }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5547
- type: exports.Sentiment.NEUTRAL,
5548
- id: descriptionId,
5549
- children: hint
5550
- }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5551
- type: exports.Sentiment.NEGATIVE,
5552
- id: descriptionId,
5553
- children: error
5554
- })]
5555
- })
5556
- })
5557
- })
5558
- })
5559
- });
5560
- };
5561
-
5562
5007
  const HeaderAction = ({
5563
5008
  action
5564
5009
  }) => {
@@ -5613,16 +5058,55 @@ const Header = ({
5613
5058
  // eslint-disable-next-line no-console
5614
5059
  console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
5615
5060
  }
5616
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
5617
- className: classNames__default.default('np-header', className),
5618
- children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
5619
- as: as,
5620
- type: exports.Typography.TITLE_GROUP,
5621
- className: "np-header__title",
5622
- children: title
5623
- }), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
5624
- action: action
5625
- })]
5061
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
5062
+ className: classNames__default.default('np-header', className),
5063
+ children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
5064
+ as: as,
5065
+ type: exports.Typography.TITLE_GROUP,
5066
+ className: "np-header__title",
5067
+ children: title
5068
+ }), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
5069
+ action: action
5070
+ })]
5071
+ });
5072
+ };
5073
+
5074
+ const EmptyTransparentImage = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
5075
+ const Image = ({
5076
+ id,
5077
+ src,
5078
+ alt,
5079
+ onLoad,
5080
+ onError,
5081
+ className,
5082
+ loading,
5083
+ stretch = true,
5084
+ role,
5085
+ shrink = true
5086
+ }) => {
5087
+ const elementReference = React.useRef(null);
5088
+ const [hasIntersected] = useHasIntersected({
5089
+ elRef: elementReference,
5090
+ loading
5091
+ });
5092
+ let imageSource = src;
5093
+ let imageOnLoad = onLoad;
5094
+ if (loading === 'lazy' && !hasIntersected) {
5095
+ imageSource = EmptyTransparentImage;
5096
+ imageOnLoad = undefined;
5097
+ }
5098
+ return /*#__PURE__*/jsxRuntime.jsx("img", {
5099
+ ref: elementReference,
5100
+ id: id,
5101
+ alt: alt,
5102
+ src: imageSource,
5103
+ className: classNames__default.default(['tw-image', {
5104
+ 'tw-image__stretch': stretch,
5105
+ 'tw-image__shrink': shrink
5106
+ }, className]),
5107
+ role: role,
5108
+ onLoad: imageOnLoad,
5109
+ onError: onError
5626
5110
  });
5627
5111
  };
5628
5112
 
@@ -5655,7 +5139,7 @@ const Modal = ({
5655
5139
  const isCompact = checkSpecialClasses('compact');
5656
5140
  const noDivider = checkSpecialClasses('no-divider');
5657
5141
  const contentReference = React.useRef(null);
5658
- const titleId = reactId.useId();
5142
+ const titleId = React.useId();
5659
5143
  return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
5660
5144
  open: open,
5661
5145
  headerTitle: title,
@@ -6168,10 +5652,9 @@ class WithDisplayFormat extends React.Component {
6168
5652
  return 'Backspace';
6169
5653
  }
6170
5654
  return triggerEvent.key;
6171
- } else {
6172
- // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
6173
- return 'Paste';
6174
5655
  }
5656
+ // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
5657
+ return 'Paste';
6175
5658
  };
6176
5659
  resetEvent = () => {
6177
5660
  this.setState({
@@ -6324,11 +5807,10 @@ class WithDisplayFormat extends React.Component {
6324
5807
  selectionEnd,
6325
5808
  pastedLength
6326
5809
  } = this.state;
5810
+ const target = triggerEvent?.currentTarget;
6327
5811
  const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
6328
5812
  setTimeout(() => {
6329
- if (triggerEvent) {
6330
- triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
6331
- }
5813
+ target?.setSelectionRange(cursorPosition, cursorPosition);
6332
5814
  this.setState({
6333
5815
  selectionStart: cursorPosition,
6334
5816
  selectionEnd: cursorPosition
@@ -7008,8 +6490,8 @@ function SelectInputOptions({
7008
6490
  }
7009
6491
  }, []);
7010
6492
  const showStatus = resultsEmpty;
7011
- const statusId = reactId.useId();
7012
- const listboxId = reactId.useId();
6493
+ const statusId = React.useId();
6494
+ const listboxId = React.useId();
7013
6495
  return /*#__PURE__*/jsxRuntime.jsxs(react$1.Listbox.Options, {
7014
6496
  as: SelectInputOptionsContainer,
7015
6497
  static: true,
@@ -7136,7 +6618,7 @@ function SelectInputGroupItemView({
7136
6618
  renderValue,
7137
6619
  needle
7138
6620
  }) {
7139
- const headerId = reactId.useId();
6621
+ const headerId = React.useId();
7140
6622
  return (
7141
6623
  /*#__PURE__*/
7142
6624
  // An empty container may be rendered when no options match `needle`
@@ -9495,6 +8977,227 @@ const ProgressBar = ({
9495
8977
  });
9496
8978
  };
9497
8979
 
8980
+ const defaultPromoCardContext = {
8981
+ state: '',
8982
+ isDisabled: false,
8983
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
8984
+ onChange: () => {}
8985
+ };
8986
+ /**
8987
+ * The PromoCard context object.
8988
+ */
8989
+ const PromoCardContext = /*#__PURE__*/React.createContext(defaultPromoCardContext);
8990
+ /**
8991
+ * A custom hook for accessing the PromoCard context object.
8992
+ *
8993
+ * The `usePromoCardContext` hook is used to access the PromoCard context object
8994
+ * from within a child PromoCard component. It throws an error if the context
8995
+ * object is not available, which can help with debugging and development.
8996
+ *
8997
+ * @returns {PromoCardContextType} - The PromoCard context object.
8998
+ */
8999
+ const usePromoCardContext = () => {
9000
+ return React.useContext(PromoCardContext);
9001
+ };
9002
+
9003
+ const PromoCardIndicator = ({
9004
+ className,
9005
+ children,
9006
+ label,
9007
+ icon,
9008
+ isSmall = false,
9009
+ testid,
9010
+ ...rest
9011
+ }) => {
9012
+ const isIconString = icon && typeof icon === 'string';
9013
+ const IconComponent = isIconString && {
9014
+ check: icons.Check,
9015
+ arrow: icons.ArrowRight,
9016
+ download: icons.Download
9017
+ }[icon];
9018
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
9019
+ className: classNames__default.default('np-Card-indicator', className),
9020
+ "data-testid": testid,
9021
+ ...rest,
9022
+ children: [label && /*#__PURE__*/jsxRuntime.jsx(Body, {
9023
+ as: "span",
9024
+ type: exports.Typography.BODY_LARGE_BOLD,
9025
+ className: "np-Card-indicatorText",
9026
+ children: label
9027
+ }), icon && /*#__PURE__*/jsxRuntime.jsx(Avatar, {
9028
+ type: exports.AvatarType.ICON,
9029
+ size: isSmall ? 40 : 56,
9030
+ backgroundColor: "var(--Card-indicator-icon-background-color)",
9031
+ className: "np-Card-indicatorIcon",
9032
+ children: IconComponent ? /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
9033
+ size: 24,
9034
+ "aria-hidden": "true"
9035
+ }) : icon
9036
+ }), children]
9037
+ });
9038
+ };
9039
+
9040
+ const PromoCard = /*#__PURE__*/React.forwardRef(({
9041
+ className,
9042
+ description,
9043
+ defaultChecked,
9044
+ download,
9045
+ href,
9046
+ hrefLang,
9047
+ id,
9048
+ headingLevel = 'h3',
9049
+ imageAlt,
9050
+ imageClass,
9051
+ imageSource,
9052
+ indicatorLabel,
9053
+ indicatorIcon,
9054
+ isChecked,
9055
+ isDisabled,
9056
+ onClick,
9057
+ rel,
9058
+ tabIndex,
9059
+ target,
9060
+ testId,
9061
+ title,
9062
+ type,
9063
+ value,
9064
+ isSmall,
9065
+ useDisplayFont = true,
9066
+ ...props
9067
+ }, reference) => {
9068
+ // Set the `checked` state to the value of `defaultChecked` if it is truthy,
9069
+ // or the value of `isChecked` if it is truthy, or `false` if neither
9070
+ // is truthy.
9071
+ const {
9072
+ state,
9073
+ onChange,
9074
+ isDisabled: contextIsDisabled
9075
+ } = usePromoCardContext();
9076
+ const [checked, setChecked] = React.useState(type === 'checkbox' ? defaultChecked ?? isChecked ?? false : false);
9077
+ const handleClick = () => {
9078
+ if (type === 'radio') {
9079
+ onChange(value || ''); // Update the context state for radio
9080
+ } else if (type === 'checkbox') {
9081
+ setChecked(!checked); // Update local state for checkbox
9082
+ }
9083
+ };
9084
+ const fallbackId = React.useId();
9085
+ const componentId = id || fallbackId;
9086
+ // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
9087
+ // `'download'` if `download` is truthy. If neither condition is true, set
9088
+ // `icon` to `undefined`.
9089
+ // Create a function to get icon type
9090
+ const getIconType = () => {
9091
+ if (indicatorIcon) {
9092
+ return indicatorIcon;
9093
+ }
9094
+ if (download) {
9095
+ return 'download';
9096
+ }
9097
+ if (href && !type) {
9098
+ return 'arrow';
9099
+ }
9100
+ return undefined;
9101
+ };
9102
+ // Define all class names string based on the values of the `href`, `type`,
9103
+ // `checked`, and `className` props.
9104
+ const commonClasses = classNames__default.default({
9105
+ 'np-Card--promoCard': true,
9106
+ 'np-Card--checked': !href && type,
9107
+ 'np-Card--link': href && !type,
9108
+ 'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined
9109
+ }, className);
9110
+ // Object with common props that will be passed to the `Card` components
9111
+ const commonProps = {
9112
+ className: commonClasses,
9113
+ id: componentId,
9114
+ isDisabled: isDisabled || contextIsDisabled,
9115
+ onClick,
9116
+ ref: reference,
9117
+ 'data-testid': testId,
9118
+ isSmall
9119
+ };
9120
+ // Object with Anchor props that will be passed to the `a` element. These
9121
+ // won't be refurned if set to `isDisabled`
9122
+ const anchorProps = href && !isDisabled ? {
9123
+ download,
9124
+ href: href || undefined,
9125
+ hrefLang,
9126
+ rel,
9127
+ target
9128
+ } : {};
9129
+ // Object of all Checked props that will be passed to the root `Card` component
9130
+ const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
9131
+ ...commonProps,
9132
+ 'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
9133
+ 'aria-describedby': `${componentId}-title`,
9134
+ 'aria-disabled': isDisabled,
9135
+ 'data-value': value ?? undefined,
9136
+ role: type === 'checkbox' || type === 'radio' ? type : undefined,
9137
+ onClick: handleClick,
9138
+ onKeyDown: event => {
9139
+ if (event.key === 'Enter' || event.key === ' ') {
9140
+ handleClick();
9141
+ }
9142
+ },
9143
+ ref: reference,
9144
+ tabIndex: 0
9145
+ } : {};
9146
+ const getTitle = () => {
9147
+ const titleContent = href && !type ? /*#__PURE__*/jsxRuntime.jsx("a", {
9148
+ className: "np-Card-titleLink",
9149
+ ...anchorProps,
9150
+ children: title
9151
+ }) : title;
9152
+ const titleProps = {
9153
+ id: `${componentId}-title`,
9154
+ as: headingLevel,
9155
+ className: 'np-Card-title'
9156
+ };
9157
+ return useDisplayFont ? /*#__PURE__*/jsxRuntime.jsx(Display, {
9158
+ type: exports.Typography.DISPLAY_SMALL,
9159
+ ...titleProps,
9160
+ children: titleContent
9161
+ }) : /*#__PURE__*/jsxRuntime.jsx(Title, {
9162
+ type: exports.Typography.TITLE_SUBSECTION,
9163
+ ...titleProps,
9164
+ children: titleContent
9165
+ });
9166
+ };
9167
+ React.useEffect(() => {
9168
+ setChecked(defaultChecked ?? isChecked ?? false);
9169
+ }, [defaultChecked, isChecked]);
9170
+ return /*#__PURE__*/jsxRuntime.jsxs(Card, {
9171
+ ...commonProps,
9172
+ ...checkedProps,
9173
+ ...props,
9174
+ children: [(value === state || checked) && /*#__PURE__*/jsxRuntime.jsx("span", {
9175
+ className: "np-Card-check",
9176
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
9177
+ size: 24,
9178
+ "aria-hidden": "true"
9179
+ })
9180
+ }), getTitle(), /*#__PURE__*/jsxRuntime.jsx(Body, {
9181
+ className: "np-Card-description",
9182
+ children: description
9183
+ }), imageSource && /*#__PURE__*/jsxRuntime.jsx("div", {
9184
+ className: classNames__default.default('np-Card-image', {
9185
+ imageClass
9186
+ }),
9187
+ children: /*#__PURE__*/jsxRuntime.jsx(Image, {
9188
+ src: imageSource,
9189
+ alt: imageAlt || '',
9190
+ loading: "lazy"
9191
+ })
9192
+ }), /*#__PURE__*/jsxRuntime.jsx(PromoCardIndicator, {
9193
+ label: indicatorLabel,
9194
+ icon: getIconType(),
9195
+ isSmall: isSmall
9196
+ })]
9197
+ });
9198
+ });
9199
+ var PromoCard$1 = /*#__PURE__*/React__namespace.default.memo(PromoCard);
9200
+
9498
9201
  const PromoCardGroup = ({
9499
9202
  children,
9500
9203
  className,
@@ -12602,7 +12305,7 @@ const ProcessingStep = props => {
12602
12305
  "aria-hidden": isComplete,
12603
12306
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
12604
12307
  className: "droppable-card-content",
12605
- children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
12308
+ children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
12606
12309
  size: exports.Size.Small,
12607
12310
  status: processStatus,
12608
12311
  onAnimationCompleted: status => onAnimationCompleted(status)
@@ -13425,7 +13128,7 @@ const UploadItem = ({
13425
13128
  switch (status) {
13426
13129
  case exports.Status.PROCESSING:
13427
13130
  case exports.Status.PENDING:
13428
- processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
13131
+ processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13429
13132
  size: exports.Size.EXTRA_SMALL,
13430
13133
  status: exports.Status.PROCESSING
13431
13134
  });
@@ -13436,7 +13139,7 @@ const UploadItem = ({
13436
13139
  processIndicator = isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13437
13140
  size: exports.Size.SMALL,
13438
13141
  sentiment: exports.Sentiment.POSITIVE
13439
- }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
13142
+ }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13440
13143
  size: exports.Size.EXTRA_SMALL,
13441
13144
  status: exports.Status.SUCCEEDED
13442
13145
  });
@@ -13451,7 +13154,7 @@ const UploadItem = ({
13451
13154
  children: processIndicator
13452
13155
  }); // Scale down ProcessIndicator to be 20px*20px to match `icons`
13453
13156
  };
13454
- const getErrorMessage = () => typeof error === 'object' && error.message || error || formatMessage(MESSAGES.uploadingFailed);
13157
+ const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13455
13158
  const getDescription = () => {
13456
13159
  if (error || status === exports.Status.FAILED) {
13457
13160
  return /*#__PURE__*/jsxRuntime.jsx(Body, {
@@ -14795,12 +14498,11 @@ exports.Alert = Alert;
14795
14498
  exports.Avatar = Avatar;
14796
14499
  exports.AvatarWrapper = AvatarWrapper;
14797
14500
  exports.Badge = Badge;
14798
- exports.BaseCard = Card$2;
14501
+ exports.BaseCard = Card;
14799
14502
  exports.Body = Body;
14800
14503
  exports.BottomSheet = BottomSheet$1;
14801
14504
  exports.Button = Button;
14802
- exports.Card = Card$1;
14803
- exports.Carousel = Carousel;
14505
+ exports.Card = Card$2;
14804
14506
  exports.Checkbox = Checkbox;
14805
14507
  exports.CheckboxButton = CheckboxButton$1;
14806
14508
  exports.CheckboxOption = CheckboxOption;
@@ -14848,7 +14550,7 @@ exports.Option = Option$2;
14848
14550
  exports.OverlayHeader = OverlayHeader$1;
14849
14551
  exports.PhoneNumberInput = PhoneNumberInput;
14850
14552
  exports.Popover = Popover$1;
14851
- exports.ProcessIndicator = ProcessIndicator$1;
14553
+ exports.ProcessIndicator = ProcessIndicator;
14852
14554
  exports.Progress = Progress;
14853
14555
  exports.ProgressBar = ProgressBar;
14854
14556
  exports.PromoCard = PromoCard$1;