@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.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
- import React__default, { forwardRef, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
3
- import { useId } from '@radix-ui/react-id';
2
+ import React__default, { forwardRef, useId, cloneElement, useState, useEffect, useRef, useMemo, Component, useCallback, createContext, useContext, useSyncExternalStore, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
4
3
  import classNames from 'classnames';
5
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, ArrowLeft, AlertCircle, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
5
+ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, AlertCircleFill, AlertCircle, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
7
6
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
8
7
  import PropTypes from 'prop-types';
9
8
  import commonmark from 'commonmark';
@@ -11,7 +10,6 @@ import { useTheme, ThemeProvider } from '@wise/components-theming';
11
10
  import { CSSTransition } from 'react-transition-group';
12
11
  import { FocusScope } from '@react-aria/focus';
13
12
  import { createPortal } from 'react-dom';
14
- import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
15
13
  import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
16
14
  import { formatDate, formatMoney, formatAmount } from '@transferwise/formatting';
17
15
  import { Transition, Listbox } from '@headlessui/react';
@@ -1238,68 +1236,67 @@ const radius = {
1238
1236
  };
1239
1237
  const ANIMATION_DURATION_IN_MS = 1500;
1240
1238
  class ProcessIndicator extends Component {
1239
+ static defaultProps = {
1240
+ status: 'processing',
1241
+ size: 'sm'
1242
+ };
1243
+ interval = 0;
1244
+ timeout = 0;
1241
1245
  constructor(props) {
1242
1246
  super(props);
1243
1247
  this.state = {
1244
1248
  status: props.status,
1245
1249
  size: props.size
1246
1250
  };
1247
- this.interval = null;
1248
- this.timeout = null;
1249
1251
  }
1250
-
1251
1252
  /**
1252
1253
  * Create interval for animation duration (1500ms)
1253
1254
  * Update state only at the end of every interval
1254
1255
  * (end of animation loop) if props changed before end of animation
1255
1256
  */
1256
1257
  componentDidMount() {
1257
- this.interval = setInterval(() => {
1258
- const statusFromState = this.state.status;
1259
- const sizeFromState = this.state.size;
1260
- const statusFromProps = this.props.status;
1261
- const sizeFromProps = this.props.size;
1262
- if (statusFromState !== statusFromProps) {
1258
+ this.interval = window.setInterval(() => {
1259
+ const {
1260
+ status: targetStatus,
1261
+ size: targetSize,
1262
+ onAnimationCompleted
1263
+ } = this.props;
1264
+ const {
1265
+ status: currentStatus,
1266
+ size: currentSize
1267
+ } = this.state;
1268
+ if (currentStatus !== targetStatus) {
1263
1269
  this.setState({
1264
- status: statusFromProps
1265
- }, this.runCallBack(statusFromProps));
1270
+ status: targetStatus
1271
+ }, () => {
1272
+ if (onAnimationCompleted) {
1273
+ this.timeout = window.setTimeout(() => {
1274
+ onAnimationCompleted(targetStatus);
1275
+ }, ANIMATION_DURATION_IN_MS);
1276
+ }
1277
+ });
1266
1278
  }
1267
- if (sizeFromState !== sizeFromProps) {
1279
+ if (currentSize !== targetSize) {
1268
1280
  this.setState({
1269
- size: sizeFromProps
1281
+ size: targetSize
1270
1282
  });
1271
1283
  }
1272
1284
  }, ANIMATION_DURATION_IN_MS);
1273
1285
  }
1274
-
1275
1286
  /**
1276
1287
  * Only trigger render if comopnent's state got
1277
1288
  * updated from interval callback
1278
- *
1279
- * @param nextProps
1280
- * @param nextState
1281
1289
  */
1282
1290
  shouldComponentUpdate(nextProps, nextState) {
1283
1291
  const isSameStatus = nextProps.status === nextState.status;
1284
1292
  const isSameSize = nextProps.size === nextState.size;
1285
1293
  return isSameStatus && isSameSize;
1286
1294
  }
1287
-
1288
1295
  // Clear interval before destroying component
1289
1296
  componentWillUnmount() {
1290
- clearInterval(this.interval);
1291
- clearTimeout(this.timeout);
1297
+ window.clearInterval(this.interval);
1298
+ window.clearTimeout(this.timeout);
1292
1299
  }
1293
- runCallBack = statusFromProps => {
1294
- const {
1295
- onAnimationCompleted
1296
- } = this.props;
1297
- if (onAnimationCompleted) {
1298
- this.timeouts = setTimeout(() => {
1299
- onAnimationCompleted(statusFromProps);
1300
- }, ANIMATION_DURATION_IN_MS);
1301
- }
1302
- };
1303
1300
  render() {
1304
1301
  const {
1305
1302
  className,
@@ -1330,28 +1327,13 @@ class ProcessIndicator extends Component {
1330
1327
  className: "process-circle",
1331
1328
  cx: "50%",
1332
1329
  cy: "50%",
1333
- r: radius[this.state.size],
1330
+ r: radius[size],
1334
1331
  fillOpacity: "0.0"
1335
1332
  })
1336
1333
  })]
1337
1334
  });
1338
1335
  }
1339
1336
  }
1340
- ProcessIndicator.propTypes = {
1341
- status: PropTypes.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
1342
- size: PropTypes.oneOf(['xxs', 'xs', 'sm', 'xl']),
1343
- onAnimationCompleted: PropTypes.func,
1344
- className: PropTypes.string,
1345
- 'data-testid': PropTypes.string
1346
- };
1347
- ProcessIndicator.defaultProps = {
1348
- status: Status.PROCESSING,
1349
- size: Size.SMALL,
1350
- onAnimationCompleted: null,
1351
- className: undefined,
1352
- 'data-testid': null
1353
- };
1354
- var ProcessIndicator$1 = ProcessIndicator;
1355
1337
 
1356
1338
  var messages$b = defineMessages({
1357
1339
  loadingAriaLabel: {
@@ -1459,738 +1441,28 @@ const Button = /*#__PURE__*/forwardRef(({
1459
1441
  } = rest;
1460
1442
  props = {
1461
1443
  ...restProps,
1462
- disabled: disabled || loading,
1463
- type: htmlType
1464
- };
1465
- } else {
1466
- props = {
1467
- ...rest
1468
- };
1469
- }
1470
- return /*#__PURE__*/jsxs(Element, {
1471
- ref: reference,
1472
- className: classes,
1473
- ...props,
1474
- "aria-live": loading ? 'polite' : 'off',
1475
- "aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
1476
- children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator$1, {
1477
- size: processIndicatorSize(),
1478
- className: "btn-loader"
1479
- })]
1480
- });
1481
- });
1482
-
1483
- const Card$2 = /*#__PURE__*/forwardRef(({
1484
- className,
1485
- children = null,
1486
- id,
1487
- isDisabled = false,
1488
- isSmall = false,
1489
- onDismiss,
1490
- testId,
1491
- ...props
1492
- }, ref) => {
1493
- const closeButtonReference = useRef(null);
1494
- return /*#__PURE__*/jsxs("div", {
1495
- ref: ref,
1496
- className: classNames('np-Card', {
1497
- 'np-Card--small': !!isSmall,
1498
- 'is-disabled': !!isDisabled
1499
- }, className),
1500
- id: id,
1501
- "data-testid": testId,
1502
- ...props,
1503
- children: [onDismiss && /*#__PURE__*/jsx(CloseButton, {
1504
- ref: closeButtonReference,
1505
- className: "np-Card-closeButton",
1506
- size: isSmall ? 'sm' : 'md',
1507
- isDisabled: isDisabled,
1508
- testId: "close-button",
1509
- onClick: e => {
1510
- stopPropagation$1(e);
1511
- onDismiss();
1512
- }
1513
- }), children]
1514
- });
1515
- });
1516
- Card$2.displayName = 'Card';
1517
-
1518
- function Display({
1519
- as: Heading = 'h1',
1520
- type = Typography.DISPLAY_LARGE,
1521
- children,
1522
- className,
1523
- id
1524
- }) {
1525
- return /*#__PURE__*/jsx(Heading, {
1526
- id: id,
1527
- className: classNames(`np-text-${type}`, 'text-primary', className),
1528
- children: children
1529
- });
1530
- }
1531
-
1532
- const useConditionalListener = ({
1533
- attachListener,
1534
- callback,
1535
- eventType,
1536
- parent
1537
- }) => {
1538
- useEffect(() => {
1539
- if (attachListener && !isUndefined(parent)) {
1540
- parent.addEventListener(eventType, callback, true);
1541
- }
1542
- return () => {
1543
- if (!isUndefined(parent)) {
1544
- parent.removeEventListener(eventType, callback, true);
1545
- }
1546
- };
1547
- }, [attachListener, callback, eventType, parent]);
1548
- };
1549
-
1550
- const DirectionContext = /*#__PURE__*/createContext(Direction.LTR);
1551
- const DirectionProvider = ({
1552
- direction,
1553
- children
1554
- }) => {
1555
- return /*#__PURE__*/jsx(DirectionContext.Provider, {
1556
- value: direction,
1557
- children: children
1558
- });
1559
- };
1560
-
1561
- const useDirection = () => {
1562
- const direction = useContext(DirectionContext);
1563
- return {
1564
- direction,
1565
- isRTL: direction === 'rtl'
1566
- };
1567
- };
1568
-
1569
- const ObserverParams = {
1570
- threshold: 0.1
1571
- };
1572
-
1573
- /**
1574
- * useHasIntersected.
1575
- * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
1576
- * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
1577
- *
1578
- * @param elRef.elRef
1579
- * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
1580
- * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
1581
- * @param elRef.loading
1582
- * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
1583
- */
1584
- const useHasIntersected = ({
1585
- elRef,
1586
- loading
1587
- }) => {
1588
- const [hasIntersected, setHasIntersected] = useState(false);
1589
- const {
1590
- current
1591
- } = elRef || {};
1592
- const isValidReference = () => {
1593
- return elRef && current;
1594
- };
1595
- const handleOnIntersect = (entries, observer) => {
1596
- entries.forEach(entry => {
1597
- if (entry.isIntersecting) {
1598
- setHasIntersected(true);
1599
- observer.unobserve(current);
1600
- }
1601
- });
1602
- };
1603
- useEffect(() => {
1604
- let observer;
1605
- let didCancel = false;
1606
-
1607
- // Check if window is define for SSR and Old browsers fallback
1608
- if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
1609
- setHasIntersected(true);
1610
- } else if (!didCancel) {
1611
- observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
1612
- observer.observe(current);
1613
- }
1614
- return () => {
1615
- didCancel = true;
1616
- if (observer) {
1617
- observer.unobserve(current);
1618
- }
1619
- };
1620
- }, [elRef]);
1621
- if (loading === 'eager') {
1622
- return [false];
1623
- }
1624
- return [hasIntersected];
1625
- };
1626
-
1627
- // eslint-disable-next-line import/extensions
1628
- function useMedia(query) {
1629
- return useSyncExternalStore(onStoreChange => {
1630
- const mediaQueryList = window.matchMedia(query);
1631
- mediaQueryList.addEventListener('change', onStoreChange);
1632
- return () => {
1633
- mediaQueryList.removeEventListener('change', onStoreChange);
1634
- };
1635
- }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
1636
- }
1637
-
1638
- function useScreenSize(size) {
1639
- return useMedia(`(min-width: ${size}px)`);
1640
- }
1641
-
1642
- /**
1643
- * @deprecated Prefer `useScreenSize` instead.
1644
- */
1645
- const useLayout = () => {
1646
- const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
1647
- const screenSm = useScreenSize(Breakpoint.SMALL);
1648
- const screenMd = useScreenSize(Breakpoint.MEDIUM);
1649
- const screenLg = useScreenSize(Breakpoint.LARGE);
1650
- const screenXl = useScreenSize(Breakpoint.EXTRA_LARGE);
1651
- return {
1652
- isMobile: screenSm != null ? !screenSm : undefined,
1653
- isExtraSmall: screenXs,
1654
- isSmall: screenSm,
1655
- isMedium: screenMd,
1656
- isLarge: screenLg,
1657
- isExtraLarge: screenXl
1658
- };
1659
- };
1660
-
1661
- const EmptyTransparentImage = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
1662
- const Image = ({
1663
- id,
1664
- src,
1665
- alt,
1666
- onLoad,
1667
- onError,
1668
- className,
1669
- loading,
1670
- stretch = true,
1671
- role,
1672
- shrink = true
1673
- }) => {
1674
- const elementReference = useRef(null);
1675
- const [hasIntersected] = useHasIntersected({
1676
- elRef: elementReference,
1677
- loading
1678
- });
1679
- let imageSource = src;
1680
- let imageOnLoad = onLoad;
1681
- if (loading === 'lazy' && !hasIntersected) {
1682
- imageSource = EmptyTransparentImage;
1683
- imageOnLoad = undefined;
1684
- }
1685
- return /*#__PURE__*/jsx("img", {
1686
- ref: elementReference,
1687
- id: id,
1688
- alt: alt,
1689
- src: imageSource,
1690
- className: classNames(['tw-image', {
1691
- 'tw-image__stretch': stretch,
1692
- 'tw-image__shrink': shrink
1693
- }, className]),
1694
- role: role,
1695
- onLoad: imageOnLoad,
1696
- onError: onError
1697
- });
1698
- };
1699
-
1700
- const defaultPromoCardContext = {
1701
- state: '',
1702
- isDisabled: false,
1703
- // eslint-disable-next-line @typescript-eslint/no-empty-function
1704
- onChange: () => {}
1705
- };
1706
- /**
1707
- * The PromoCard context object.
1708
- */
1709
- const PromoCardContext = /*#__PURE__*/createContext(defaultPromoCardContext);
1710
- /**
1711
- * A custom hook for accessing the PromoCard context object.
1712
- *
1713
- * The `usePromoCardContext` hook is used to access the PromoCard context object
1714
- * from within a child PromoCard component. It throws an error if the context
1715
- * object is not available, which can help with debugging and development.
1716
- *
1717
- * @returns {PromoCardContextType} - The PromoCard context object.
1718
- */
1719
- const usePromoCardContext = () => {
1720
- return useContext(PromoCardContext);
1721
- };
1722
-
1723
- const PromoCardIndicator = ({
1724
- className,
1725
- children,
1726
- label,
1727
- icon,
1728
- isSmall = false,
1729
- testid,
1730
- ...rest
1731
- }) => {
1732
- const isIconString = icon && typeof icon === 'string';
1733
- const IconComponent = isIconString && {
1734
- check: Check,
1735
- arrow: ArrowRight,
1736
- download: Download
1737
- }[icon];
1738
- return /*#__PURE__*/jsxs("div", {
1739
- className: classNames('np-Card-indicator', className),
1740
- "data-testid": testid,
1741
- ...rest,
1742
- children: [label && /*#__PURE__*/jsx(Body, {
1743
- as: "span",
1744
- type: Typography.BODY_LARGE_BOLD,
1745
- className: "np-Card-indicatorText",
1746
- children: label
1747
- }), icon && /*#__PURE__*/jsx(Avatar, {
1748
- type: AvatarType.ICON,
1749
- size: isSmall ? 40 : 56,
1750
- backgroundColor: "var(--Card-indicator-icon-background-color)",
1751
- className: "np-Card-indicatorIcon",
1752
- children: IconComponent ? /*#__PURE__*/jsx(IconComponent, {
1753
- size: 24,
1754
- "aria-hidden": "true"
1755
- }) : icon
1756
- }), children]
1757
- });
1758
- };
1759
-
1760
- const PromoCard = /*#__PURE__*/forwardRef(({
1761
- className,
1762
- description,
1763
- defaultChecked,
1764
- download,
1765
- href,
1766
- hrefLang,
1767
- id,
1768
- headingLevel = 'h3',
1769
- imageAlt,
1770
- imageClass,
1771
- imageSource,
1772
- indicatorLabel,
1773
- indicatorIcon,
1774
- isChecked,
1775
- isDisabled,
1776
- onClick,
1777
- onKeyDown,
1778
- rel,
1779
- tabIndex,
1780
- target,
1781
- testId,
1782
- title,
1783
- type,
1784
- value,
1785
- isSmall,
1786
- useDisplayFont = true,
1787
- anchorRef,
1788
- anchorId,
1789
- ...props
1790
- }, ref) => {
1791
- // Set the `checked` state to the value of `defaultChecked` if it is truthy,
1792
- // or the value of `isChecked` if it is truthy, or `false` if neither
1793
- // is truthy.
1794
- const {
1795
- state,
1796
- onChange,
1797
- isDisabled: contextIsDisabled
1798
- } = usePromoCardContext();
1799
- const [checked, setChecked] = useState(type === 'checkbox' ? defaultChecked ?? isChecked ?? false : false);
1800
- const handleClick = () => {
1801
- if (type === 'radio') {
1802
- onChange(value || ''); // Update the context state for radio
1803
- } else if (type === 'checkbox') {
1804
- setChecked(!checked); // Update local state for checkbox
1805
- }
1806
- };
1807
- const fallbackId = useId();
1808
- const componentId = id || fallbackId;
1809
- // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
1810
- // `'download'` if `download` is truthy. If neither condition is true, set
1811
- // `icon` to `undefined`.
1812
- // Create a function to get icon type
1813
- const getIconType = () => {
1814
- if (indicatorIcon) {
1815
- return indicatorIcon;
1816
- }
1817
- if (download) {
1818
- return 'download';
1819
- }
1820
- if (href && !type) {
1821
- return 'arrow';
1822
- }
1823
- return undefined;
1824
- };
1825
- // Define all class names string based on the values of the `href`, `type`,
1826
- // `checked`, and `className` props.
1827
- const commonClasses = classNames({
1828
- 'np-Card--promoCard': true,
1829
- 'np-Card--checked': !href && type,
1830
- 'np-Card--link': href && !type,
1831
- 'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined
1832
- }, className);
1833
- // Object with common props that will be passed to the `Card` components
1834
- const commonProps = {
1835
- className: commonClasses,
1836
- id: componentId,
1837
- isDisabled: isDisabled || contextIsDisabled,
1838
- onClick,
1839
- onKeyDown,
1840
- ref,
1841
- 'data-testid': testId,
1842
- isSmall
1843
- };
1844
- // Object with Anchor props that will be passed to the `a` element. These
1845
- // won't be refurned if set to `isDisabled`
1846
- const anchorProps = href && !isDisabled ? {
1847
- download,
1848
- href: href || undefined,
1849
- hrefLang,
1850
- rel,
1851
- target,
1852
- ref: anchorRef,
1853
- id: anchorId
1854
- } : {};
1855
- // Object of all Checked props that will be passed to the root `Card` component
1856
- const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
1857
- ...commonProps,
1858
- 'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
1859
- 'aria-describedby': `${componentId}-title`,
1860
- 'aria-disabled': isDisabled,
1861
- 'data-value': value ?? undefined,
1862
- role: type === 'checkbox' || type === 'radio' ? type : undefined,
1863
- onClick: handleClick,
1864
- onKeyDown: event => {
1865
- if (event.key === 'Enter' || event.key === ' ') {
1866
- handleClick();
1867
- }
1868
- },
1869
- ref,
1870
- tabIndex: 0
1871
- } : {};
1872
- const getTitle = () => {
1873
- const titleContent = href && !type ? /*#__PURE__*/jsx("a", {
1874
- className: "np-Card-titleLink",
1875
- ...anchorProps,
1876
- children: title
1877
- }) : title;
1878
- const titleProps = {
1879
- id: `${componentId}-title`,
1880
- as: headingLevel,
1881
- className: 'np-Card-title'
1444
+ disabled: disabled || loading,
1445
+ type: htmlType
1882
1446
  };
1883
- return useDisplayFont ? /*#__PURE__*/jsx(Display, {
1884
- type: Typography.DISPLAY_SMALL,
1885
- ...titleProps,
1886
- children: titleContent
1887
- }) : /*#__PURE__*/jsx(Title, {
1888
- type: Typography.TITLE_SUBSECTION,
1889
- ...titleProps,
1890
- children: titleContent
1891
- });
1892
- };
1893
- useEffect(() => {
1894
- setChecked(defaultChecked ?? isChecked ?? false);
1895
- }, [defaultChecked, isChecked]);
1896
- return /*#__PURE__*/jsxs(Card$2, {
1897
- ...commonProps,
1898
- ...checkedProps,
1447
+ } else {
1448
+ props = {
1449
+ ...rest
1450
+ };
1451
+ }
1452
+ return /*#__PURE__*/jsxs(Element, {
1453
+ ref: reference,
1454
+ className: classes,
1899
1455
  ...props,
1900
- children: [(value === state || checked) && /*#__PURE__*/jsx("span", {
1901
- className: "np-Card-check",
1902
- children: /*#__PURE__*/jsx(Check, {
1903
- size: 24,
1904
- "aria-hidden": "true"
1905
- })
1906
- }), getTitle(), /*#__PURE__*/jsx(Body, {
1907
- className: "np-Card-description",
1908
- children: description
1909
- }), imageSource && /*#__PURE__*/jsx("div", {
1910
- className: classNames('np-Card-image', {
1911
- imageClass
1912
- }),
1913
- children: /*#__PURE__*/jsx(Image, {
1914
- src: imageSource,
1915
- alt: imageAlt || '',
1916
- loading: "lazy"
1917
- })
1918
- }), /*#__PURE__*/jsx(PromoCardIndicator, {
1919
- label: indicatorLabel,
1920
- icon: getIconType(),
1921
- isSmall: isSmall
1456
+ "aria-live": loading ? 'polite' : 'off',
1457
+ "aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
1458
+ children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator, {
1459
+ size: processIndicatorSize(),
1460
+ className: "btn-loader"
1922
1461
  })]
1923
1462
  });
1924
1463
  });
1925
- var PromoCard$1 = /*#__PURE__*/React__default.memo(PromoCard);
1926
-
1927
- const LEFT_SCROLL_OFFSET = 8;
1928
- const Carousel = ({
1929
- header,
1930
- className,
1931
- cards,
1932
- onClick
1933
- }) => {
1934
- const [scrollPosition, setScrollPosition] = useState(0);
1935
- const [previousScrollPosition, setPreviousScrollPosition] = useState(0);
1936
- const [scrollIsAtEnd, setScrollIsAtEnd] = useState(false);
1937
- const [visibleCardOnMobileView, setVisibleCardOnMobileView] = useState('');
1938
- const carouselElementRef = useRef(null);
1939
- const carouselCardsRef = useRef([]);
1940
- const isLeftActionButtonEnabled = scrollPosition > LEFT_SCROLL_OFFSET;
1941
- const areActionButtonsEnabled = isLeftActionButtonEnabled || !scrollIsAtEnd;
1942
- const [focusedCard, setFocusedCard] = useState(cards?.[0]?.id);
1943
- const updateScrollButtonsState = () => {
1944
- if (carouselElementRef.current) {
1945
- const {
1946
- scrollWidth,
1947
- offsetWidth
1948
- } = carouselElementRef.current;
1949
- const scrollAtEnd = scrollWidth - offsetWidth <= scrollPosition + LEFT_SCROLL_OFFSET;
1950
- setScrollIsAtEnd(scrollAtEnd);
1951
- }
1952
- const scrollDirecton = scrollPosition > previousScrollPosition ? 'right' : 'left';
1953
- const cardsInFullViewIds = [];
1954
- carouselCardsRef.current.forEach(card => {
1955
- if (isVisible(carouselElementRef.current, card.cardElement)) {
1956
- // eslint-disable-next-line functional/immutable-data
1957
- cardsInFullViewIds.push(card.cardElement.getAttribute('id') ?? '');
1958
- }
1959
- });
1960
- if (cardsInFullViewIds.length >= 1) {
1961
- const visibleCardIndex = scrollDirecton === 'right' ? cardsInFullViewIds.length - 1 : 0;
1962
- const visibleCardId = cardsInFullViewIds[visibleCardIndex];
1963
- setVisibleCardOnMobileView(visibleCardId);
1964
- setFocusedCard(visibleCardId);
1965
- }
1966
- setPreviousScrollPosition(scrollPosition);
1967
- };
1968
- const scrollCarousel = (direction = 'right') => {
1969
- if (carouselElementRef.current) {
1970
- const {
1971
- scrollWidth
1972
- } = carouselElementRef.current;
1973
- const cardWidth = scrollWidth / carouselCardsRef.current.length;
1974
- const res = Math.floor(cardWidth - cardWidth * 0.05);
1975
- carouselElementRef.current.scrollBy({
1976
- left: direction === 'right' ? res : -res,
1977
- behavior: 'smooth'
1978
- });
1979
- }
1980
- };
1981
- const handleOnKeyDown = (event, index) => {
1982
- if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
1983
- const nextIndex = event.key === 'ArrowRight' ? index + 1 : index - 1;
1984
- const nextCard = cards[nextIndex];
1985
- if (nextCard) {
1986
- const ref = carouselCardsRef.current[nextIndex];
1987
- if (ref.type === 'promo') {
1988
- ref.anchorElement?.focus();
1989
- } else {
1990
- ref.cardElement?.focus();
1991
- }
1992
- scrollCardIntoView(carouselCardsRef.current[nextIndex].cardElement, nextCard);
1993
- event.preventDefault();
1994
- }
1995
- }
1996
- if (event.key === 'Enter' || event.key === ' ') {
1997
- event.currentTarget.click();
1998
- }
1999
- };
2000
- const scrollCardIntoView = (element, card) => {
2001
- element.scrollIntoView({
2002
- behavior: 'smooth',
2003
- block: 'nearest',
2004
- inline: 'center'
2005
- });
2006
- setFocusedCard(card.id);
2007
- };
2008
- useEffect(() => {
2009
- updateScrollButtonsState();
2010
- // eslint-disable-next-line react-hooks/exhaustive-deps
2011
- }, [scrollPosition]);
2012
- useEffect(() => {
2013
- window.addEventListener('resize', updateScrollButtonsState);
2014
- return () => {
2015
- window.removeEventListener('resize', updateScrollButtonsState);
2016
- };
2017
- // eslint-disable-next-line react-hooks/exhaustive-deps
2018
- }, []);
2019
- const addElementToCardsRefArray = (index, ref) => {
2020
- if (ref) {
2021
- // eslint-disable-next-line functional/immutable-data
2022
- carouselCardsRef.current[index] = {
2023
- type: ref.type ?? carouselCardsRef.current?.[index]?.type,
2024
- cardElement: ref.cardElement ?? carouselCardsRef.current?.[index]?.cardElement,
2025
- anchorElement: ref.anchorElement ?? carouselCardsRef.current?.[index]?.anchorElement
2026
- };
2027
- }
2028
- };
2029
- return /*#__PURE__*/jsxs("div", {
2030
- className: classNames('carousel-wrapper', className),
2031
- children: [/*#__PURE__*/jsxs("div", {
2032
- className: "d-flex justify-content-between carousel__header",
2033
- children: [typeof header === 'string' ? /*#__PURE__*/jsx(Title, {
2034
- as: "span",
2035
- type: "title-body",
2036
- children: header
2037
- }) : header, areActionButtonsEnabled ? /*#__PURE__*/jsxs("div", {
2038
- className: "hidden-xs",
2039
- children: [/*#__PURE__*/jsx(ActionButton, {
2040
- className: "carousel__scroll-button",
2041
- tabIndex: -1,
2042
- priority: "secondary",
2043
- disabled: !isLeftActionButtonEnabled,
2044
- "aria-hidden": "true",
2045
- "data-testid": "scroll-carousel-left",
2046
- onClick: () => scrollCarousel('left'),
2047
- children: /*#__PURE__*/jsx(ChevronLeft, {})
2048
- }), /*#__PURE__*/jsx(ActionButton, {
2049
- tabIndex: -1,
2050
- className: "carousel__scroll-button m-l-1",
2051
- priority: "secondary",
2052
- "aria-hidden": "true",
2053
- "data-testid": "scroll-carousel-right",
2054
- disabled: scrollIsAtEnd,
2055
- onClick: () => scrollCarousel(),
2056
- children: /*#__PURE__*/jsx(ChevronRight, {})
2057
- })]
2058
- }) : null]
2059
- }), /*#__PURE__*/jsx("div", {
2060
- ref: carouselElementRef,
2061
- tabIndex: -1,
2062
- role: "list",
2063
- className: "carousel",
2064
- onScroll: event => {
2065
- const target = event.target;
2066
- setScrollPosition(target.scrollLeft);
2067
- },
2068
- children: cards?.map((card, index) => {
2069
- const sharedProps = {
2070
- id: card.id,
2071
- className: classNames('carousel__card', {
2072
- 'carousel__card--focused': card.id === focusedCard
2073
- }),
2074
- onClick: () => {
2075
- card.onClick?.();
2076
- onClick?.(card.id);
2077
- },
2078
- onFocus: event => {
2079
- scrollCardIntoView(event.currentTarget, card);
2080
- }
2081
- };
2082
- const cardContent = card.type !== 'promo' ? /*#__PURE__*/jsx("div", {
2083
- id: `${card.id}-content`,
2084
- className: classNames('carousel__card-content', {
2085
- [card.className ?? '']: !!card.className
2086
- })
2087
- // eslint-disable-next-line react/forbid-dom-props
2088
- ,
2089
- style: card.styles,
2090
- children: card.content
2091
- }) : null;
2092
- if (card.type === 'button') {
2093
- return /*#__PURE__*/jsx("div", {
2094
- "aria-labelledby": `${card.id}-content`,
2095
- role: "listitem",
2096
- children: /*#__PURE__*/jsx("div", {
2097
- ...sharedProps,
2098
- ref: el => {
2099
- if (el) {
2100
- // eslint-disable-next-line functional/immutable-data
2101
- carouselCardsRef.current[index] = {
2102
- type: 'default',
2103
- cardElement: el
2104
- };
2105
- }
2106
- },
2107
- role: "button",
2108
- tabIndex: 0,
2109
- onKeyDown: event => handleOnKeyDown(event, index),
2110
- children: cardContent
2111
- })
2112
- }, card.id);
2113
- }
2114
- if (card.type === 'promo') {
2115
- return /*#__PURE__*/jsx("div", {
2116
- id: card.id,
2117
- role: "listitem",
2118
- "aria-labelledby": `${card.id}-anchor`,
2119
- children: /*#__PURE__*/jsx(PromoCard$1, {
2120
- ...card,
2121
- type: undefined,
2122
- ...sharedProps,
2123
- ref: el => {
2124
- if (el) {
2125
- addElementToCardsRefArray(index, {
2126
- type: 'promo',
2127
- cardElement: el
2128
- });
2129
- }
2130
- },
2131
- anchorRef: el => {
2132
- if (el) {
2133
- addElementToCardsRefArray(index, {
2134
- type: 'promo',
2135
- anchorElement: el
2136
- });
2137
- }
2138
- },
2139
- anchorId: `${card.id}-anchor`,
2140
- onKeyDown: event => handleOnKeyDown(event, index)
2141
- })
2142
- }, card.id);
2143
- }
2144
- return /*#__PURE__*/jsx("div", {
2145
- "aria-labelledby": `${card.id}-content`,
2146
- role: "listitem",
2147
- children: /*#__PURE__*/jsx("a", {
2148
- ...sharedProps,
2149
- ref: el => {
2150
- if (el) {
2151
- // eslint-disable-next-line functional/immutable-data
2152
- carouselCardsRef.current[index] = {
2153
- type: 'default',
2154
- cardElement: el
2155
- };
2156
- }
2157
- },
2158
- href: card.href,
2159
- rel: "noreferrer",
2160
- onKeyDown: event => handleOnKeyDown(event, index),
2161
- children: cardContent
2162
- })
2163
- }, card.id);
2164
- })
2165
- }), /*#__PURE__*/jsx("div", {
2166
- className: "visible-xs",
2167
- children: /*#__PURE__*/jsx("div", {
2168
- className: "carousel__indicators",
2169
- children: cards?.map((card, index) => /*#__PURE__*/jsx("button", {
2170
- "data-testid": `${card.id}-indicator`,
2171
- tabIndex: -1,
2172
- "aria-hidden": true,
2173
- type: "button",
2174
- className: classNames('carousel__indicator', {
2175
- 'carousel__indicator--selected': card.id === visibleCardOnMobileView
2176
- }),
2177
- onClick: () => {
2178
- scrollCardIntoView(carouselCardsRef.current[index].cardElement, card);
2179
- }
2180
- }, `${card.id}-indicator`))
2181
- })
2182
- })]
2183
- });
2184
- };
2185
- const isVisible = (container, el) => {
2186
- const cWidth = container.offsetWidth;
2187
- const cScrollOffset = container.scrollLeft;
2188
- const elemLeft = el.offsetLeft - container.offsetLeft;
2189
- const elemRight = elemLeft + el.offsetWidth;
2190
- return elemLeft >= cScrollOffset && elemRight <= cScrollOffset + cWidth;
2191
- };
2192
1464
 
2193
- const Card = /*#__PURE__*/forwardRef((props, reference) => {
1465
+ const Card$1 = /*#__PURE__*/forwardRef((props, reference) => {
2194
1466
  const {
2195
1467
  'aria-label': ariaLabel,
2196
1468
  as: Element,
@@ -2241,7 +1513,7 @@ const Card = /*#__PURE__*/forwardRef((props, reference) => {
2241
1513
  const hasChildren = ({
2242
1514
  children
2243
1515
  }) => children;
2244
- Card.propTypes = {
1516
+ Card$1.propTypes = {
2245
1517
  'aria-label': PropTypes.string,
2246
1518
  as: PropTypes.string,
2247
1519
  isExpanded: requiredIf(PropTypes.bool, hasChildren),
@@ -2254,7 +1526,7 @@ Card.propTypes = {
2254
1526
  className: PropTypes.string,
2255
1527
  'data-testid': PropTypes.string
2256
1528
  };
2257
- Card.defaultProps = {
1529
+ Card$1.defaultProps = {
2258
1530
  'aria-label': undefined,
2259
1531
  as: 'div',
2260
1532
  children: null,
@@ -2262,7 +1534,7 @@ Card.defaultProps = {
2262
1534
  className: null,
2263
1535
  'data-testid': null
2264
1536
  };
2265
- var Card$1 = Card;
1537
+ var Card$2 = Card$1;
2266
1538
 
2267
1539
  const CheckboxButton = /*#__PURE__*/forwardRef(({
2268
1540
  checked,
@@ -2748,6 +2020,134 @@ const DimmerContentWrapper = ({
2748
2020
  };
2749
2021
  var Dimmer$1 = withNextPortalWrapper(Dimmer);
2750
2022
 
2023
+ const useConditionalListener = ({
2024
+ attachListener,
2025
+ callback,
2026
+ eventType,
2027
+ parent
2028
+ }) => {
2029
+ useEffect(() => {
2030
+ if (attachListener && !isUndefined(parent)) {
2031
+ parent.addEventListener(eventType, callback, true);
2032
+ }
2033
+ return () => {
2034
+ if (!isUndefined(parent)) {
2035
+ parent.removeEventListener(eventType, callback, true);
2036
+ }
2037
+ };
2038
+ }, [attachListener, callback, eventType, parent]);
2039
+ };
2040
+
2041
+ const DirectionContext = /*#__PURE__*/createContext(Direction.LTR);
2042
+ const DirectionProvider = ({
2043
+ direction,
2044
+ children
2045
+ }) => {
2046
+ return /*#__PURE__*/jsx(DirectionContext.Provider, {
2047
+ value: direction,
2048
+ children: children
2049
+ });
2050
+ };
2051
+
2052
+ const useDirection = () => {
2053
+ const direction = useContext(DirectionContext);
2054
+ return {
2055
+ direction,
2056
+ isRTL: direction === 'rtl'
2057
+ };
2058
+ };
2059
+
2060
+ const ObserverParams = {
2061
+ threshold: 0.1
2062
+ };
2063
+
2064
+ /**
2065
+ * useHasIntersected.
2066
+ * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
2067
+ * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
2068
+ *
2069
+ * @param elRef.elRef
2070
+ * @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
2071
+ * @param {strimng} [loading = 'eager'] - string that contains the type of loading.
2072
+ * @param elRef.loading
2073
+ * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
2074
+ */
2075
+ const useHasIntersected = ({
2076
+ elRef,
2077
+ loading
2078
+ }) => {
2079
+ const [hasIntersected, setHasIntersected] = useState(false);
2080
+ const {
2081
+ current
2082
+ } = elRef || {};
2083
+ const isValidReference = () => {
2084
+ return elRef && current;
2085
+ };
2086
+ const handleOnIntersect = (entries, observer) => {
2087
+ entries.forEach(entry => {
2088
+ if (entry.isIntersecting) {
2089
+ setHasIntersected(true);
2090
+ observer.unobserve(current);
2091
+ }
2092
+ });
2093
+ };
2094
+ useEffect(() => {
2095
+ let observer;
2096
+ let didCancel = false;
2097
+
2098
+ // Check if window is define for SSR and Old browsers fallback
2099
+ if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
2100
+ setHasIntersected(true);
2101
+ } else if (!didCancel) {
2102
+ observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
2103
+ observer.observe(current);
2104
+ }
2105
+ return () => {
2106
+ didCancel = true;
2107
+ if (observer) {
2108
+ observer.unobserve(current);
2109
+ }
2110
+ };
2111
+ }, [elRef]);
2112
+ if (loading === 'eager') {
2113
+ return [false];
2114
+ }
2115
+ return [hasIntersected];
2116
+ };
2117
+
2118
+ function useMedia(query) {
2119
+ return useSyncExternalStore(onStoreChange => {
2120
+ const mediaQueryList = window.matchMedia(query);
2121
+ mediaQueryList.addEventListener('change', onStoreChange);
2122
+ return () => {
2123
+ mediaQueryList.removeEventListener('change', onStoreChange);
2124
+ };
2125
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
2126
+ }
2127
+
2128
+ function useScreenSize(size) {
2129
+ return useMedia(`(min-width: ${size}px)`);
2130
+ }
2131
+
2132
+ /**
2133
+ * @deprecated Prefer `useScreenSize` instead.
2134
+ */
2135
+ const useLayout = () => {
2136
+ const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
2137
+ const screenSm = useScreenSize(Breakpoint.SMALL);
2138
+ const screenMd = useScreenSize(Breakpoint.MEDIUM);
2139
+ const screenLg = useScreenSize(Breakpoint.LARGE);
2140
+ const screenXl = useScreenSize(Breakpoint.EXTRA_LARGE);
2141
+ return {
2142
+ isMobile: screenSm != null ? !screenSm : undefined,
2143
+ isExtraSmall: screenXs,
2144
+ isSmall: screenSm,
2145
+ isMedium: screenMd,
2146
+ isLarge: screenLg,
2147
+ isExtraLarge: screenXl
2148
+ };
2149
+ };
2150
+
2751
2151
  const EXIT_ANIMATION = 350;
2752
2152
  const SlidingPanel = /*#__PURE__*/forwardRef(({
2753
2153
  position = 'left',
@@ -2836,12 +2236,12 @@ Drawer.propTypes = {
2836
2236
  footerContent: PropTypes.node,
2837
2237
  /** The content to appear in the drawer header. */
2838
2238
  headerTitle: PropTypes.node,
2839
- /** The action to perform on close click. */
2840
- onClose: PropTypes.func,
2841
2239
  /** The status of Drawer either open or not. */
2842
2240
  open: PropTypes.bool,
2843
2241
  /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
2844
- position: PropTypes.oneOf(['left', 'right', 'bottom'])
2242
+ position: PropTypes.oneOf(['left', 'right', 'bottom']),
2243
+ /** The action to perform on close click. */
2244
+ onClose: PropTypes.func
2845
2245
  };
2846
2246
  Drawer.defaultProps = {
2847
2247
  children: null,
@@ -3027,6 +2427,39 @@ const BottomSheet$1 = props => {
3027
2427
  });
3028
2428
  };
3029
2429
 
2430
+ const Card = ({
2431
+ className,
2432
+ children = null,
2433
+ id,
2434
+ isDisabled = false,
2435
+ isSmall = false,
2436
+ onDismiss,
2437
+ testId,
2438
+ ...props
2439
+ }) => {
2440
+ const closeButtonReference = useRef(null);
2441
+ return /*#__PURE__*/jsxs("div", {
2442
+ className: classNames('np-Card', {
2443
+ 'np-Card--small': !!isSmall,
2444
+ 'is-disabled': !!isDisabled
2445
+ }, className),
2446
+ id: id,
2447
+ "data-testid": testId,
2448
+ ...props,
2449
+ children: [onDismiss && /*#__PURE__*/jsx(CloseButton, {
2450
+ ref: closeButtonReference,
2451
+ className: "np-Card-closeButton",
2452
+ size: isSmall ? 'sm' : 'md',
2453
+ isDisabled: isDisabled,
2454
+ testId: "close-button",
2455
+ onClick: e => {
2456
+ stopPropagation$1(e);
2457
+ onDismiss();
2458
+ }
2459
+ }), children]
2460
+ });
2461
+ };
2462
+
3030
2463
  function CriticalCommsBanner({
3031
2464
  title,
3032
2465
  subtitle,
@@ -3516,7 +2949,7 @@ const fallbackPlacements = {
3516
2949
  [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],
3517
2950
  [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM]
3518
2951
  };
3519
- const Panel = /*#__PURE__*/forwardRef(({
2952
+ const Panel = /*#__PURE__*/forwardRef(function Panel({
3520
2953
  arrow = false,
3521
2954
  flip = true,
3522
2955
  altAxis = false,
@@ -3527,7 +2960,7 @@ const Panel = /*#__PURE__*/forwardRef(({
3527
2960
  anchorRef,
3528
2961
  anchorWidth = false,
3529
2962
  ...rest
3530
- }, reference) => {
2963
+ }, reference) {
3531
2964
  const [arrowElement, setArrowElement] = useState(null);
3532
2965
  const [popperElement, setPopperElement] = useState(null);
3533
2966
  const modifiers = [];
@@ -3605,7 +3038,7 @@ const Panel = /*#__PURE__*/forwardRef(({
3605
3038
  ...attributes.popper,
3606
3039
  className: classNames('np-panel', {
3607
3040
  'np-panel--open': open
3608
- }, rest['className']),
3041
+ }, rest.className),
3609
3042
  children: /*#__PURE__*/jsxs("div", {
3610
3043
  ref: reference
3611
3044
  /* eslint-disable-next-line react/forbid-dom-props */,
@@ -3624,7 +3057,7 @@ const Panel = /*#__PURE__*/forwardRef(({
3624
3057
  });
3625
3058
  var Panel$1 = Panel;
3626
3059
 
3627
- const ResponsivePanel = /*#__PURE__*/forwardRef(({
3060
+ const ResponsivePanel = /*#__PURE__*/forwardRef(function ResponsivePanel({
3628
3061
  anchorRef,
3629
3062
  arrow = false,
3630
3063
  flip = true,
@@ -3633,7 +3066,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
3633
3066
  onClose,
3634
3067
  open = false,
3635
3068
  position = Position.BOTTOM
3636
- }, reference) => {
3069
+ }, reference) {
3637
3070
  const {
3638
3071
  isMobile
3639
3072
  } = useLayout();
@@ -4884,6 +4317,20 @@ DefinitionList.defaultProps = {
4884
4317
  };
4885
4318
  var DefinitionList$1 = DefinitionList;
4886
4319
 
4320
+ function Display({
4321
+ as: Heading = 'h1',
4322
+ type = Typography.DISPLAY_LARGE,
4323
+ children,
4324
+ className,
4325
+ id
4326
+ }) {
4327
+ return /*#__PURE__*/jsx(Heading, {
4328
+ id: id,
4329
+ className: classNames(`np-text-${type}`, 'text-primary', className),
4330
+ children: children
4331
+ });
4332
+ }
4333
+
4887
4334
  const DropFade = ({
4888
4335
  children,
4889
4336
  show
@@ -4972,6 +4419,84 @@ const Emphasis = ({
4972
4419
  }) : null;
4973
4420
  };
4974
4421
 
4422
+ function InlineAlert({
4423
+ id,
4424
+ type = 'neutral',
4425
+ className,
4426
+ children
4427
+ }) {
4428
+ const danger = type === 'negative' || type === 'error';
4429
+ return /*#__PURE__*/jsxs("div", {
4430
+ role: "alert",
4431
+ id: id,
4432
+ className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4433
+ children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
4434
+ children: children
4435
+ })]
4436
+ });
4437
+ }
4438
+
4439
+ const Label = ({
4440
+ id,
4441
+ htmlFor,
4442
+ className,
4443
+ children
4444
+ }) => {
4445
+ return /*#__PURE__*/jsx("label", {
4446
+ id: id,
4447
+ htmlFor: htmlFor,
4448
+ className: classNames('control-label d-flex flex-column gap-y-1 m-b-0', className),
4449
+ children: children
4450
+ });
4451
+ };
4452
+
4453
+ const Field = ({
4454
+ id,
4455
+ label,
4456
+ hint,
4457
+ error,
4458
+ className,
4459
+ children
4460
+ }) => {
4461
+ const hasError = Boolean(error);
4462
+ const hasHint = Boolean(hint) && !hasError;
4463
+ const labelId = useId();
4464
+ const fallbackInputId = useId();
4465
+ const inputId = id !== null ? id ?? fallbackInputId : undefined;
4466
+ const descriptionId = useId();
4467
+ return /*#__PURE__*/jsx(FieldLabelIdContextProvider, {
4468
+ value: labelId,
4469
+ children: /*#__PURE__*/jsx(InputIdContextProvider, {
4470
+ value: inputId,
4471
+ children: /*#__PURE__*/jsx(InputDescribedByProvider, {
4472
+ value: hasError || hasHint ? descriptionId : undefined,
4473
+ children: /*#__PURE__*/jsx(InputInvalidProvider, {
4474
+ value: hasError,
4475
+ children: /*#__PURE__*/jsxs("div", {
4476
+ className: classNames('form-group d-block', {
4477
+ 'has-error': hasError,
4478
+ 'has-info': hasHint
4479
+ }, className),
4480
+ children: [/*#__PURE__*/jsxs(Label, {
4481
+ id: labelId,
4482
+ htmlFor: inputId,
4483
+ children: [label, children]
4484
+ }), hasHint && /*#__PURE__*/jsx(InlineAlert, {
4485
+ type: Sentiment.NEUTRAL,
4486
+ id: descriptionId,
4487
+ children: hint
4488
+ }), hasError && /*#__PURE__*/jsx(InlineAlert, {
4489
+ type: Sentiment.NEGATIVE,
4490
+ id: descriptionId,
4491
+ children: error
4492
+ })]
4493
+ })
4494
+ })
4495
+ })
4496
+ })
4497
+ });
4498
+ };
4499
+
4975
4500
  const FlowHeader = /*#__PURE__*/React.forwardRef(({
4976
4501
  bottomContent,
4977
4502
  className,
@@ -5218,42 +4743,40 @@ const Tooltip = ({
5218
4743
  forceUpdate();
5219
4744
  }
5220
4745
  }, [open]);
5221
- return /*#__PURE__*/jsx(Fragment, {
5222
- children: /*#__PURE__*/jsxs("span", {
5223
- ref: anchorReference,
5224
- className: "tw-tooltip-container",
5225
- onMouseOver: () => setOpen(true),
5226
- onFocus: () => setOpen(true),
5227
- onMouseOut: () => setOpen(false),
5228
- onBlur: () => setOpen(false),
5229
- children: [children ? /*#__PURE__*/cloneElement(children, {
5230
- 'aria-describedby': `${tooltipId}-tooltip`
5231
- }) : null, /*#__PURE__*/jsx("div", {
5232
- // @ts-expect-error
5233
- ref: setPopperElement,
5234
- className: classNames('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
5235
- // eslint-disable-next-line react/forbid-dom-props
5236
- ,
5237
- style: {
5238
- ...styles.popper
5239
- },
5240
- ...attributes.popper,
5241
- "aria-hidden": !open,
5242
- role: "tooltip",
5243
- id: `${tooltipId}-tooltip`,
5244
- children: /*#__PURE__*/jsxs("div", {
5245
- className: "np-panel__content tooltip-inner",
5246
- children: [label, /*#__PURE__*/jsx("div", {
5247
- // @ts-expect-error
5248
- ref: setArrowElement,
5249
- className: classNames('np-panel__arrow')
5250
- // eslint-disable-next-line react/forbid-dom-props
5251
- ,
5252
- style: styles.arrow
5253
- })]
5254
- })
5255
- })]
5256
- })
4746
+ return /*#__PURE__*/jsxs("span", {
4747
+ ref: anchorReference,
4748
+ className: "tw-tooltip-container",
4749
+ onMouseOver: () => setOpen(true),
4750
+ onFocus: () => setOpen(true),
4751
+ onMouseOut: () => setOpen(false),
4752
+ onBlur: () => setOpen(false),
4753
+ children: [children ? /*#__PURE__*/cloneElement(children, {
4754
+ 'aria-describedby': `${tooltipId}-tooltip`
4755
+ }) : null, /*#__PURE__*/jsx("div", {
4756
+ // @ts-expect-error
4757
+ ref: setPopperElement,
4758
+ className: classNames('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
4759
+ // eslint-disable-next-line react/forbid-dom-props
4760
+ ,
4761
+ style: {
4762
+ ...styles.popper
4763
+ },
4764
+ ...attributes.popper,
4765
+ "aria-hidden": !open,
4766
+ role: "tooltip",
4767
+ id: `${tooltipId}-tooltip`,
4768
+ children: /*#__PURE__*/jsxs("div", {
4769
+ className: "np-panel__content tooltip-inner",
4770
+ children: [label, /*#__PURE__*/jsx("div", {
4771
+ // @ts-expect-error
4772
+ ref: setArrowElement,
4773
+ className: classNames('np-panel__arrow')
4774
+ // eslint-disable-next-line react/forbid-dom-props
4775
+ ,
4776
+ style: styles.arrow
4777
+ })]
4778
+ })
4779
+ })]
5257
4780
  });
5258
4781
  };
5259
4782
 
@@ -5451,84 +4974,6 @@ const FlowNavigation = ({
5451
4974
  });
5452
4975
  };
5453
4976
 
5454
- function InlineAlert({
5455
- id,
5456
- type = 'neutral',
5457
- className,
5458
- children
5459
- }) {
5460
- const danger = type === 'negative' || type === 'error';
5461
- return /*#__PURE__*/jsxs("div", {
5462
- role: "alert",
5463
- id: id,
5464
- className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
5465
- children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
5466
- children: children
5467
- })]
5468
- });
5469
- }
5470
-
5471
- const Label = ({
5472
- id,
5473
- htmlFor,
5474
- className,
5475
- children
5476
- }) => {
5477
- return /*#__PURE__*/jsx("label", {
5478
- id: id,
5479
- htmlFor: htmlFor,
5480
- className: classNames('control-label d-flex flex-column gap-y-1 m-b-0', className),
5481
- children: children
5482
- });
5483
- };
5484
-
5485
- const Field = ({
5486
- id,
5487
- label,
5488
- hint,
5489
- error,
5490
- className,
5491
- children
5492
- }) => {
5493
- const hasError = Boolean(error);
5494
- const hasHint = Boolean(hint) && !hasError;
5495
- const labelId = useId();
5496
- const fallbackInputId = useId(); // TODO: Use `React.useId()` when react>=18
5497
- const inputId = id !== null ? id ?? fallbackInputId : undefined;
5498
- const descriptionId = useId(); // TODO: Use `React.useId()` when react>=18
5499
- return /*#__PURE__*/jsx(FieldLabelIdContextProvider, {
5500
- value: labelId,
5501
- children: /*#__PURE__*/jsx(InputIdContextProvider, {
5502
- value: inputId,
5503
- children: /*#__PURE__*/jsx(InputDescribedByProvider, {
5504
- value: hasError || hasHint ? descriptionId : undefined,
5505
- children: /*#__PURE__*/jsx(InputInvalidProvider, {
5506
- value: hasError,
5507
- children: /*#__PURE__*/jsxs("div", {
5508
- className: classNames('form-group d-block', {
5509
- 'has-error': hasError,
5510
- 'has-info': hasHint
5511
- }, className),
5512
- children: [/*#__PURE__*/jsxs(Label, {
5513
- id: labelId,
5514
- htmlFor: inputId,
5515
- children: [label, children]
5516
- }), hasHint && /*#__PURE__*/jsx(InlineAlert, {
5517
- type: Sentiment.NEUTRAL,
5518
- id: descriptionId,
5519
- children: hint
5520
- }), hasError && /*#__PURE__*/jsx(InlineAlert, {
5521
- type: Sentiment.NEGATIVE,
5522
- id: descriptionId,
5523
- children: error
5524
- })]
5525
- })
5526
- })
5527
- })
5528
- })
5529
- });
5530
- };
5531
-
5532
4977
  const HeaderAction = ({
5533
4978
  action
5534
4979
  }) => {
@@ -5583,16 +5028,55 @@ const Header = ({
5583
5028
  // eslint-disable-next-line no-console
5584
5029
  console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
5585
5030
  }
5586
- return /*#__PURE__*/jsxs("div", {
5587
- className: classNames('np-header', className),
5588
- children: [/*#__PURE__*/jsx(Title, {
5589
- as: as,
5590
- type: Typography.TITLE_GROUP,
5591
- className: "np-header__title",
5592
- children: title
5593
- }), /*#__PURE__*/jsx(HeaderAction, {
5594
- action: action
5595
- })]
5031
+ return /*#__PURE__*/jsxs("div", {
5032
+ className: classNames('np-header', className),
5033
+ children: [/*#__PURE__*/jsx(Title, {
5034
+ as: as,
5035
+ type: Typography.TITLE_GROUP,
5036
+ className: "np-header__title",
5037
+ children: title
5038
+ }), /*#__PURE__*/jsx(HeaderAction, {
5039
+ action: action
5040
+ })]
5041
+ });
5042
+ };
5043
+
5044
+ const EmptyTransparentImage = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
5045
+ const Image = ({
5046
+ id,
5047
+ src,
5048
+ alt,
5049
+ onLoad,
5050
+ onError,
5051
+ className,
5052
+ loading,
5053
+ stretch = true,
5054
+ role,
5055
+ shrink = true
5056
+ }) => {
5057
+ const elementReference = useRef(null);
5058
+ const [hasIntersected] = useHasIntersected({
5059
+ elRef: elementReference,
5060
+ loading
5061
+ });
5062
+ let imageSource = src;
5063
+ let imageOnLoad = onLoad;
5064
+ if (loading === 'lazy' && !hasIntersected) {
5065
+ imageSource = EmptyTransparentImage;
5066
+ imageOnLoad = undefined;
5067
+ }
5068
+ return /*#__PURE__*/jsx("img", {
5069
+ ref: elementReference,
5070
+ id: id,
5071
+ alt: alt,
5072
+ src: imageSource,
5073
+ className: classNames(['tw-image', {
5074
+ 'tw-image__stretch': stretch,
5075
+ 'tw-image__shrink': shrink
5076
+ }, className]),
5077
+ role: role,
5078
+ onLoad: imageOnLoad,
5079
+ onError: onError
5596
5080
  });
5597
5081
  };
5598
5082
 
@@ -6138,10 +5622,9 @@ class WithDisplayFormat extends Component {
6138
5622
  return 'Backspace';
6139
5623
  }
6140
5624
  return triggerEvent.key;
6141
- } else {
6142
- // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
6143
- return 'Paste';
6144
5625
  }
5626
+ // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
5627
+ return 'Paste';
6145
5628
  };
6146
5629
  resetEvent = () => {
6147
5630
  this.setState({
@@ -6294,11 +5777,10 @@ class WithDisplayFormat extends Component {
6294
5777
  selectionEnd,
6295
5778
  pastedLength
6296
5779
  } = this.state;
5780
+ const target = triggerEvent?.currentTarget;
6297
5781
  const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
6298
5782
  setTimeout(() => {
6299
- if (triggerEvent) {
6300
- triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
6301
- }
5783
+ target?.setSelectionRange(cursorPosition, cursorPosition);
6302
5784
  this.setState({
6303
5785
  selectionStart: cursorPosition,
6304
5786
  selectionEnd: cursorPosition
@@ -9465,6 +8947,227 @@ const ProgressBar = ({
9465
8947
  });
9466
8948
  };
9467
8949
 
8950
+ const defaultPromoCardContext = {
8951
+ state: '',
8952
+ isDisabled: false,
8953
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
8954
+ onChange: () => {}
8955
+ };
8956
+ /**
8957
+ * The PromoCard context object.
8958
+ */
8959
+ const PromoCardContext = /*#__PURE__*/createContext(defaultPromoCardContext);
8960
+ /**
8961
+ * A custom hook for accessing the PromoCard context object.
8962
+ *
8963
+ * The `usePromoCardContext` hook is used to access the PromoCard context object
8964
+ * from within a child PromoCard component. It throws an error if the context
8965
+ * object is not available, which can help with debugging and development.
8966
+ *
8967
+ * @returns {PromoCardContextType} - The PromoCard context object.
8968
+ */
8969
+ const usePromoCardContext = () => {
8970
+ return useContext(PromoCardContext);
8971
+ };
8972
+
8973
+ const PromoCardIndicator = ({
8974
+ className,
8975
+ children,
8976
+ label,
8977
+ icon,
8978
+ isSmall = false,
8979
+ testid,
8980
+ ...rest
8981
+ }) => {
8982
+ const isIconString = icon && typeof icon === 'string';
8983
+ const IconComponent = isIconString && {
8984
+ check: Check,
8985
+ arrow: ArrowRight,
8986
+ download: Download
8987
+ }[icon];
8988
+ return /*#__PURE__*/jsxs("div", {
8989
+ className: classNames('np-Card-indicator', className),
8990
+ "data-testid": testid,
8991
+ ...rest,
8992
+ children: [label && /*#__PURE__*/jsx(Body, {
8993
+ as: "span",
8994
+ type: Typography.BODY_LARGE_BOLD,
8995
+ className: "np-Card-indicatorText",
8996
+ children: label
8997
+ }), icon && /*#__PURE__*/jsx(Avatar, {
8998
+ type: AvatarType.ICON,
8999
+ size: isSmall ? 40 : 56,
9000
+ backgroundColor: "var(--Card-indicator-icon-background-color)",
9001
+ className: "np-Card-indicatorIcon",
9002
+ children: IconComponent ? /*#__PURE__*/jsx(IconComponent, {
9003
+ size: 24,
9004
+ "aria-hidden": "true"
9005
+ }) : icon
9006
+ }), children]
9007
+ });
9008
+ };
9009
+
9010
+ const PromoCard = /*#__PURE__*/forwardRef(({
9011
+ className,
9012
+ description,
9013
+ defaultChecked,
9014
+ download,
9015
+ href,
9016
+ hrefLang,
9017
+ id,
9018
+ headingLevel = 'h3',
9019
+ imageAlt,
9020
+ imageClass,
9021
+ imageSource,
9022
+ indicatorLabel,
9023
+ indicatorIcon,
9024
+ isChecked,
9025
+ isDisabled,
9026
+ onClick,
9027
+ rel,
9028
+ tabIndex,
9029
+ target,
9030
+ testId,
9031
+ title,
9032
+ type,
9033
+ value,
9034
+ isSmall,
9035
+ useDisplayFont = true,
9036
+ ...props
9037
+ }, reference) => {
9038
+ // Set the `checked` state to the value of `defaultChecked` if it is truthy,
9039
+ // or the value of `isChecked` if it is truthy, or `false` if neither
9040
+ // is truthy.
9041
+ const {
9042
+ state,
9043
+ onChange,
9044
+ isDisabled: contextIsDisabled
9045
+ } = usePromoCardContext();
9046
+ const [checked, setChecked] = useState(type === 'checkbox' ? defaultChecked ?? isChecked ?? false : false);
9047
+ const handleClick = () => {
9048
+ if (type === 'radio') {
9049
+ onChange(value || ''); // Update the context state for radio
9050
+ } else if (type === 'checkbox') {
9051
+ setChecked(!checked); // Update local state for checkbox
9052
+ }
9053
+ };
9054
+ const fallbackId = useId();
9055
+ const componentId = id || fallbackId;
9056
+ // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
9057
+ // `'download'` if `download` is truthy. If neither condition is true, set
9058
+ // `icon` to `undefined`.
9059
+ // Create a function to get icon type
9060
+ const getIconType = () => {
9061
+ if (indicatorIcon) {
9062
+ return indicatorIcon;
9063
+ }
9064
+ if (download) {
9065
+ return 'download';
9066
+ }
9067
+ if (href && !type) {
9068
+ return 'arrow';
9069
+ }
9070
+ return undefined;
9071
+ };
9072
+ // Define all class names string based on the values of the `href`, `type`,
9073
+ // `checked`, and `className` props.
9074
+ const commonClasses = classNames({
9075
+ 'np-Card--promoCard': true,
9076
+ 'np-Card--checked': !href && type,
9077
+ 'np-Card--link': href && !type,
9078
+ 'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined
9079
+ }, className);
9080
+ // Object with common props that will be passed to the `Card` components
9081
+ const commonProps = {
9082
+ className: commonClasses,
9083
+ id: componentId,
9084
+ isDisabled: isDisabled || contextIsDisabled,
9085
+ onClick,
9086
+ ref: reference,
9087
+ 'data-testid': testId,
9088
+ isSmall
9089
+ };
9090
+ // Object with Anchor props that will be passed to the `a` element. These
9091
+ // won't be refurned if set to `isDisabled`
9092
+ const anchorProps = href && !isDisabled ? {
9093
+ download,
9094
+ href: href || undefined,
9095
+ hrefLang,
9096
+ rel,
9097
+ target
9098
+ } : {};
9099
+ // Object of all Checked props that will be passed to the root `Card` component
9100
+ const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
9101
+ ...commonProps,
9102
+ 'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
9103
+ 'aria-describedby': `${componentId}-title`,
9104
+ 'aria-disabled': isDisabled,
9105
+ 'data-value': value ?? undefined,
9106
+ role: type === 'checkbox' || type === 'radio' ? type : undefined,
9107
+ onClick: handleClick,
9108
+ onKeyDown: event => {
9109
+ if (event.key === 'Enter' || event.key === ' ') {
9110
+ handleClick();
9111
+ }
9112
+ },
9113
+ ref: reference,
9114
+ tabIndex: 0
9115
+ } : {};
9116
+ const getTitle = () => {
9117
+ const titleContent = href && !type ? /*#__PURE__*/jsx("a", {
9118
+ className: "np-Card-titleLink",
9119
+ ...anchorProps,
9120
+ children: title
9121
+ }) : title;
9122
+ const titleProps = {
9123
+ id: `${componentId}-title`,
9124
+ as: headingLevel,
9125
+ className: 'np-Card-title'
9126
+ };
9127
+ return useDisplayFont ? /*#__PURE__*/jsx(Display, {
9128
+ type: Typography.DISPLAY_SMALL,
9129
+ ...titleProps,
9130
+ children: titleContent
9131
+ }) : /*#__PURE__*/jsx(Title, {
9132
+ type: Typography.TITLE_SUBSECTION,
9133
+ ...titleProps,
9134
+ children: titleContent
9135
+ });
9136
+ };
9137
+ useEffect(() => {
9138
+ setChecked(defaultChecked ?? isChecked ?? false);
9139
+ }, [defaultChecked, isChecked]);
9140
+ return /*#__PURE__*/jsxs(Card, {
9141
+ ...commonProps,
9142
+ ...checkedProps,
9143
+ ...props,
9144
+ children: [(value === state || checked) && /*#__PURE__*/jsx("span", {
9145
+ className: "np-Card-check",
9146
+ children: /*#__PURE__*/jsx(Check, {
9147
+ size: 24,
9148
+ "aria-hidden": "true"
9149
+ })
9150
+ }), getTitle(), /*#__PURE__*/jsx(Body, {
9151
+ className: "np-Card-description",
9152
+ children: description
9153
+ }), imageSource && /*#__PURE__*/jsx("div", {
9154
+ className: classNames('np-Card-image', {
9155
+ imageClass
9156
+ }),
9157
+ children: /*#__PURE__*/jsx(Image, {
9158
+ src: imageSource,
9159
+ alt: imageAlt || '',
9160
+ loading: "lazy"
9161
+ })
9162
+ }), /*#__PURE__*/jsx(PromoCardIndicator, {
9163
+ label: indicatorLabel,
9164
+ icon: getIconType(),
9165
+ isSmall: isSmall
9166
+ })]
9167
+ });
9168
+ });
9169
+ var PromoCard$1 = /*#__PURE__*/React__default.memo(PromoCard);
9170
+
9468
9171
  const PromoCardGroup = ({
9469
9172
  children,
9470
9173
  className,
@@ -12572,7 +12275,7 @@ const ProcessingStep = props => {
12572
12275
  "aria-hidden": isComplete,
12573
12276
  children: /*#__PURE__*/jsxs("div", {
12574
12277
  className: "droppable-card-content",
12575
- children: [/*#__PURE__*/jsx(ProcessIndicator$1, {
12278
+ children: [/*#__PURE__*/jsx(ProcessIndicator, {
12576
12279
  size: Size.Small,
12577
12280
  status: processStatus,
12578
12281
  onAnimationCompleted: status => onAnimationCompleted(status)
@@ -13395,7 +13098,7 @@ const UploadItem = ({
13395
13098
  switch (status) {
13396
13099
  case Status.PROCESSING:
13397
13100
  case Status.PENDING:
13398
- processIndicator = /*#__PURE__*/jsx(ProcessIndicator$1, {
13101
+ processIndicator = /*#__PURE__*/jsx(ProcessIndicator, {
13399
13102
  size: Size.EXTRA_SMALL,
13400
13103
  status: Status.PROCESSING
13401
13104
  });
@@ -13406,7 +13109,7 @@ const UploadItem = ({
13406
13109
  processIndicator = isModern ? /*#__PURE__*/jsx(StatusIcon, {
13407
13110
  size: Size.SMALL,
13408
13111
  sentiment: Sentiment.POSITIVE
13409
- }) : /*#__PURE__*/jsx(ProcessIndicator$1, {
13112
+ }) : /*#__PURE__*/jsx(ProcessIndicator, {
13410
13113
  size: Size.EXTRA_SMALL,
13411
13114
  status: Status.SUCCEEDED
13412
13115
  });
@@ -13421,7 +13124,7 @@ const UploadItem = ({
13421
13124
  children: processIndicator
13422
13125
  }); // Scale down ProcessIndicator to be 20px*20px to match `icons`
13423
13126
  };
13424
- const getErrorMessage = () => typeof error === 'object' && error.message || error || formatMessage(MESSAGES.uploadingFailed);
13127
+ const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13425
13128
  const getDescription = () => {
13426
13129
  if (error || status === Status.FAILED) {
13427
13130
  return /*#__PURE__*/jsx(Body, {
@@ -14758,5 +14461,5 @@ const translations = {
14758
14461
  'zh-HK': zhHK
14759
14462
  };
14760
14463
 
14761
- export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card$2 as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$1 as Card, Carousel, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, Field, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, Label, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCardGroup$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
14464
+ export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, Field, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, Label, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCardGroup$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
14762
14465
  //# sourceMappingURL=index.mjs.map