@transferwise/components 0.0.0-experimental-47ae02a → 0.0.0-experimental-da6dbbf
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.
- package/build/index.js +940 -642
- package/build/index.js.map +1 -1
- package/build/index.mjs +930 -633
- package/build/index.mjs.map +1 -1
- package/build/main.css +135 -0
- package/build/styles/carousel/Carousel.css +135 -0
- package/build/styles/main.css +135 -0
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/carousel/Carousel.d.ts +26 -0
- package/build/types/carousel/Carousel.d.ts.map +1 -0
- package/build/types/carousel/index.d.ts +3 -0
- package/build/types/carousel/index.d.ts.map +1 -0
- package/build/types/common/card/Card.d.ts +2 -2
- package/build/types/common/card/Card.d.ts.map +1 -1
- package/build/types/common/hooks/useMedia.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +11 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/drawer/Drawer.d.ts +4 -4
- package/build/types/index.d.ts +4 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts +1 -2
- package/build/types/inputWithDisplayFormat/InputWithDisplayFormat.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +19 -36
- package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
- package/build/types/processIndicator/index.d.ts +2 -2
- package/build/types/processIndicator/index.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +16 -5
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts +1 -2
- package/build/types/textareaWithDisplayFormat/TextareaWithDisplayFormat.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +14 -14
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/package.json +11 -7
- package/src/accordion/AccordionItem/AccordionItem.tsx +4 -2
- package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -1
- package/src/button/Button.tsx +1 -1
- package/src/carousel/Carousel.css +135 -0
- package/src/carousel/Carousel.less +133 -0
- package/src/carousel/Carousel.spec.tsx +221 -0
- package/src/carousel/Carousel.story.tsx +63 -0
- package/src/carousel/Carousel.tsx +345 -0
- package/src/carousel/index.ts +3 -0
- package/src/common/card/Card.tsx +51 -43
- package/src/common/hooks/useConditionalListener/useConditionalListener.spec.js +1 -1
- package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +3 -3
- package/src/common/hooks/useMedia.spec.ts +1 -1
- package/src/common/hooks/useMedia.ts +2 -1
- package/src/common/panel/Panel.tsx +92 -90
- package/src/common/responsivePanel/ResponsivePanel.tsx +38 -34
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +180 -0
- package/src/dateLookup/DateLookup.rtl.spec.tsx +5 -181
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +124 -171
- package/src/drawer/Drawer.js +3 -3
- package/src/field/Field.tsx +3 -3
- package/src/index.ts +4 -3
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.tsx +1 -2
- package/src/inputs/SelectInput.story.tsx +0 -1
- package/src/inputs/SelectInput.tsx +2 -10
- package/src/main.css +135 -0
- package/src/main.less +1 -0
- package/src/modal/Modal.tsx +2 -1
- package/src/processIndicator/ProcessIndicator.js +117 -0
- package/src/processIndicator/ProcessIndicator.spec.js +101 -0
- package/src/promoCard/PromoCard.story.tsx +2 -2
- package/src/promoCard/PromoCard.tsx +31 -9
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +1 -0
- package/src/snackbar/Snackbar.spec.js +1 -4
- package/src/tabs/Tabs.spec.js +27 -46
- package/src/test-utils/index.js +7 -5
- package/src/test-utils/jest.setup.js +3 -9
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.tsx +1 -2
- package/src/tooltip/Tooltip.tsx +46 -44
- package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +2 -2
- package/src/upload/Upload.spec.js +13 -34
- package/src/uploadInput/UploadInput.spec.tsx +23 -21
- package/src/uploadInput/uploadItem/UploadItem.tsx +3 -1
- package/src/withDisplayFormat/WithDisplayFormat.spec.js +32 -63
- package/src/withDisplayFormat/WithDisplayFormat.tsx +28 -28
- package/src/processIndicator/ProcessIndicator.rtl.spec.tsx +0 -45
- package/src/processIndicator/ProcessIndicator.tsx +0 -110
- /package/src/processIndicator/{index.ts → index.js} +0 -0
package/build/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var reactId = require('@radix-ui/react-id');
|
|
4
5
|
var classNames = require('classnames');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var icons = require('@transferwise/icons');
|
|
@@ -11,6 +12,7 @@ var componentsTheming = require('@wise/components-theming');
|
|
|
11
12
|
var reactTransitionGroup = require('react-transition-group');
|
|
12
13
|
var focus = require('@react-aria/focus');
|
|
13
14
|
var reactDom = require('react-dom');
|
|
15
|
+
var index_js = require('use-sync-external-store/shim/index.js');
|
|
14
16
|
var neptuneValidation = require('@transferwise/neptune-validation');
|
|
15
17
|
var formatting = require('@transferwise/formatting');
|
|
16
18
|
var react$1 = require('@headlessui/react');
|
|
@@ -563,7 +565,7 @@ const AccordionItem = ({
|
|
|
563
565
|
const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
|
|
564
566
|
size: 24
|
|
565
567
|
}) : null;
|
|
566
|
-
const fallbackId =
|
|
568
|
+
const fallbackId = reactId.useId();
|
|
567
569
|
const accordionId = id ?? fallbackId;
|
|
568
570
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
569
571
|
id: accordionId,
|
|
@@ -1266,67 +1268,68 @@ const radius = {
|
|
|
1266
1268
|
};
|
|
1267
1269
|
const ANIMATION_DURATION_IN_MS = 1500;
|
|
1268
1270
|
class ProcessIndicator extends React.Component {
|
|
1269
|
-
static defaultProps = {
|
|
1270
|
-
status: 'processing',
|
|
1271
|
-
size: 'sm'
|
|
1272
|
-
};
|
|
1273
|
-
interval = 0;
|
|
1274
|
-
timeout = 0;
|
|
1275
1271
|
constructor(props) {
|
|
1276
1272
|
super(props);
|
|
1277
1273
|
this.state = {
|
|
1278
1274
|
status: props.status,
|
|
1279
1275
|
size: props.size
|
|
1280
1276
|
};
|
|
1277
|
+
this.interval = null;
|
|
1278
|
+
this.timeout = null;
|
|
1281
1279
|
}
|
|
1280
|
+
|
|
1282
1281
|
/**
|
|
1283
1282
|
* Create interval for animation duration (1500ms)
|
|
1284
1283
|
* Update state only at the end of every interval
|
|
1285
1284
|
* (end of animation loop) if props changed before end of animation
|
|
1286
1285
|
*/
|
|
1287
1286
|
componentDidMount() {
|
|
1288
|
-
this.interval =
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
const {
|
|
1295
|
-
status: currentStatus,
|
|
1296
|
-
size: currentSize
|
|
1297
|
-
} = this.state;
|
|
1298
|
-
if (currentStatus !== targetStatus) {
|
|
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) {
|
|
1299
1293
|
this.setState({
|
|
1300
|
-
status:
|
|
1301
|
-
}, ()
|
|
1302
|
-
if (onAnimationCompleted) {
|
|
1303
|
-
this.timeout = window.setTimeout(() => {
|
|
1304
|
-
onAnimationCompleted(targetStatus);
|
|
1305
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1294
|
+
status: statusFromProps
|
|
1295
|
+
}, this.runCallBack(statusFromProps));
|
|
1308
1296
|
}
|
|
1309
|
-
if (
|
|
1297
|
+
if (sizeFromState !== sizeFromProps) {
|
|
1310
1298
|
this.setState({
|
|
1311
|
-
size:
|
|
1299
|
+
size: sizeFromProps
|
|
1312
1300
|
});
|
|
1313
1301
|
}
|
|
1314
1302
|
}, ANIMATION_DURATION_IN_MS);
|
|
1315
1303
|
}
|
|
1304
|
+
|
|
1316
1305
|
/**
|
|
1317
1306
|
* Only trigger render if comopnent's state got
|
|
1318
1307
|
* updated from interval callback
|
|
1308
|
+
*
|
|
1309
|
+
* @param nextProps
|
|
1310
|
+
* @param nextState
|
|
1319
1311
|
*/
|
|
1320
1312
|
shouldComponentUpdate(nextProps, nextState) {
|
|
1321
1313
|
const isSameStatus = nextProps.status === nextState.status;
|
|
1322
1314
|
const isSameSize = nextProps.size === nextState.size;
|
|
1323
1315
|
return isSameStatus && isSameSize;
|
|
1324
1316
|
}
|
|
1317
|
+
|
|
1325
1318
|
// Clear interval before destroying component
|
|
1326
1319
|
componentWillUnmount() {
|
|
1327
|
-
|
|
1328
|
-
|
|
1320
|
+
clearInterval(this.interval);
|
|
1321
|
+
clearTimeout(this.timeout);
|
|
1329
1322
|
}
|
|
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
|
+
};
|
|
1330
1333
|
render() {
|
|
1331
1334
|
const {
|
|
1332
1335
|
className,
|
|
@@ -1357,13 +1360,28 @@ class ProcessIndicator extends React.Component {
|
|
|
1357
1360
|
className: "process-circle",
|
|
1358
1361
|
cx: "50%",
|
|
1359
1362
|
cy: "50%",
|
|
1360
|
-
r: radius[size],
|
|
1363
|
+
r: radius[this.state.size],
|
|
1361
1364
|
fillOpacity: "0.0"
|
|
1362
1365
|
})
|
|
1363
1366
|
})]
|
|
1364
1367
|
});
|
|
1365
1368
|
}
|
|
1366
1369
|
}
|
|
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;
|
|
1367
1385
|
|
|
1368
1386
|
var messages$b = reactIntl.defineMessages({
|
|
1369
1387
|
loadingAriaLabel: {
|
|
@@ -1485,14 +1503,724 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
1485
1503
|
...props,
|
|
1486
1504
|
"aria-live": loading ? 'polite' : 'off',
|
|
1487
1505
|
"aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
|
|
1488
|
-
children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
1506
|
+
children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
|
|
1489
1507
|
size: processIndicatorSize(),
|
|
1490
1508
|
className: "btn-loader"
|
|
1491
1509
|
})]
|
|
1492
1510
|
});
|
|
1493
1511
|
});
|
|
1494
1512
|
|
|
1495
|
-
const Card$
|
|
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'
|
|
1912
|
+
};
|
|
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,
|
|
1929
|
+
...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
|
|
1952
|
+
})]
|
|
1953
|
+
});
|
|
1954
|
+
});
|
|
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
|
+
|
|
2223
|
+
const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
|
|
1496
2224
|
const {
|
|
1497
2225
|
'aria-label': ariaLabel,
|
|
1498
2226
|
as: Element,
|
|
@@ -1543,7 +2271,7 @@ const Card$1 = /*#__PURE__*/React.forwardRef((props, reference) => {
|
|
|
1543
2271
|
const hasChildren = ({
|
|
1544
2272
|
children
|
|
1545
2273
|
}) => children;
|
|
1546
|
-
Card
|
|
2274
|
+
Card.propTypes = {
|
|
1547
2275
|
'aria-label': PropTypes__default.default.string,
|
|
1548
2276
|
as: PropTypes__default.default.string,
|
|
1549
2277
|
isExpanded: requiredIf__default.default(PropTypes__default.default.bool, hasChildren),
|
|
@@ -1556,7 +2284,7 @@ Card$1.propTypes = {
|
|
|
1556
2284
|
className: PropTypes__default.default.string,
|
|
1557
2285
|
'data-testid': PropTypes__default.default.string
|
|
1558
2286
|
};
|
|
1559
|
-
Card
|
|
2287
|
+
Card.defaultProps = {
|
|
1560
2288
|
'aria-label': undefined,
|
|
1561
2289
|
as: 'div',
|
|
1562
2290
|
children: null,
|
|
@@ -1564,7 +2292,7 @@ Card$1.defaultProps = {
|
|
|
1564
2292
|
className: null,
|
|
1565
2293
|
'data-testid': null
|
|
1566
2294
|
};
|
|
1567
|
-
var Card$
|
|
2295
|
+
var Card$1 = Card;
|
|
1568
2296
|
|
|
1569
2297
|
const CheckboxButton = /*#__PURE__*/React.forwardRef(({
|
|
1570
2298
|
checked,
|
|
@@ -2050,134 +2778,6 @@ const DimmerContentWrapper = ({
|
|
|
2050
2778
|
};
|
|
2051
2779
|
var Dimmer$1 = withNextPortalWrapper(Dimmer);
|
|
2052
2780
|
|
|
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
|
-
};
|
|
2180
|
-
|
|
2181
2781
|
const EXIT_ANIMATION = 350;
|
|
2182
2782
|
const SlidingPanel = /*#__PURE__*/React.forwardRef(({
|
|
2183
2783
|
position = 'left',
|
|
@@ -2224,7 +2824,7 @@ const Drawer = ({
|
|
|
2224
2824
|
const {
|
|
2225
2825
|
isMobile
|
|
2226
2826
|
} = useLayout();
|
|
2227
|
-
const titleId =
|
|
2827
|
+
const titleId = reactId.useId();
|
|
2228
2828
|
return /*#__PURE__*/jsxRuntime.jsx(Dimmer$1, {
|
|
2229
2829
|
open: open,
|
|
2230
2830
|
onClose: onClose,
|
|
@@ -2266,12 +2866,12 @@ Drawer.propTypes = {
|
|
|
2266
2866
|
footerContent: PropTypes__default.default.node,
|
|
2267
2867
|
/** The content to appear in the drawer header. */
|
|
2268
2868
|
headerTitle: PropTypes__default.default.node,
|
|
2869
|
+
/** The action to perform on close click. */
|
|
2870
|
+
onClose: PropTypes__default.default.func,
|
|
2269
2871
|
/** The status of Drawer either open or not. */
|
|
2270
2872
|
open: PropTypes__default.default.bool,
|
|
2271
2873
|
/** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
|
|
2272
|
-
position: PropTypes__default.default.oneOf(['left', 'right', 'bottom'])
|
|
2273
|
-
/** The action to perform on close click. */
|
|
2274
|
-
onClose: PropTypes__default.default.func
|
|
2874
|
+
position: PropTypes__default.default.oneOf(['left', 'right', 'bottom'])
|
|
2275
2875
|
};
|
|
2276
2876
|
Drawer.defaultProps = {
|
|
2277
2877
|
children: null,
|
|
@@ -2444,49 +3044,16 @@ const BottomSheet$1 = props => {
|
|
|
2444
3044
|
}), /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
2445
3045
|
size: "sm",
|
|
2446
3046
|
className: "sr-only np-bottom-sheet--close-btn",
|
|
2447
|
-
onClick: close
|
|
2448
|
-
})]
|
|
2449
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2450
|
-
ref: contentReference,
|
|
2451
|
-
style: setContentMaxHeight(),
|
|
2452
|
-
className: "np-bottom-sheet--content",
|
|
2453
|
-
children: props.children
|
|
2454
|
-
})]
|
|
2455
|
-
})
|
|
2456
|
-
})
|
|
2457
|
-
});
|
|
2458
|
-
};
|
|
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]
|
|
3047
|
+
onClick: close
|
|
3048
|
+
})]
|
|
3049
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3050
|
+
ref: contentReference,
|
|
3051
|
+
style: setContentMaxHeight(),
|
|
3052
|
+
className: "np-bottom-sheet--content",
|
|
3053
|
+
children: props.children
|
|
3054
|
+
})]
|
|
3055
|
+
})
|
|
3056
|
+
})
|
|
2490
3057
|
});
|
|
2491
3058
|
};
|
|
2492
3059
|
|
|
@@ -2979,7 +3546,7 @@ const fallbackPlacements = {
|
|
|
2979
3546
|
[exports.Position.LEFT]: [exports.Position.RIGHT, exports.Position.TOP, exports.Position.BOTTOM],
|
|
2980
3547
|
[exports.Position.RIGHT]: [exports.Position.LEFT, exports.Position.TOP, exports.Position.BOTTOM]
|
|
2981
3548
|
};
|
|
2982
|
-
const Panel = /*#__PURE__*/React.forwardRef(
|
|
3549
|
+
const Panel = /*#__PURE__*/React.forwardRef(({
|
|
2983
3550
|
arrow = false,
|
|
2984
3551
|
flip = true,
|
|
2985
3552
|
altAxis = false,
|
|
@@ -2990,7 +3557,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
2990
3557
|
anchorRef,
|
|
2991
3558
|
anchorWidth = false,
|
|
2992
3559
|
...rest
|
|
2993
|
-
}, reference) {
|
|
3560
|
+
}, reference) => {
|
|
2994
3561
|
const [arrowElement, setArrowElement] = React.useState(null);
|
|
2995
3562
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
2996
3563
|
const modifiers = [];
|
|
@@ -3068,7 +3635,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
3068
3635
|
...attributes.popper,
|
|
3069
3636
|
className: classNames__default.default('np-panel', {
|
|
3070
3637
|
'np-panel--open': open
|
|
3071
|
-
}, rest
|
|
3638
|
+
}, rest['className']),
|
|
3072
3639
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3073
3640
|
ref: reference
|
|
3074
3641
|
/* eslint-disable-next-line react/forbid-dom-props */,
|
|
@@ -3087,7 +3654,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
|
|
|
3087
3654
|
});
|
|
3088
3655
|
var Panel$1 = Panel;
|
|
3089
3656
|
|
|
3090
|
-
const ResponsivePanel = /*#__PURE__*/React.forwardRef(
|
|
3657
|
+
const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
|
|
3091
3658
|
anchorRef,
|
|
3092
3659
|
arrow = false,
|
|
3093
3660
|
flip = true,
|
|
@@ -3096,7 +3663,7 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(function ResponsivePanel({
|
|
|
3096
3663
|
onClose,
|
|
3097
3664
|
open = false,
|
|
3098
3665
|
position = exports.Position.BOTTOM
|
|
3099
|
-
}, reference) {
|
|
3666
|
+
}, reference) => {
|
|
3100
3667
|
const {
|
|
3101
3668
|
isMobile
|
|
3102
3669
|
} = useLayout();
|
|
@@ -4347,20 +4914,6 @@ DefinitionList.defaultProps = {
|
|
|
4347
4914
|
};
|
|
4348
4915
|
var DefinitionList$1 = DefinitionList;
|
|
4349
4916
|
|
|
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
|
-
|
|
4364
4917
|
const DropFade = ({
|
|
4365
4918
|
children,
|
|
4366
4919
|
show
|
|
@@ -4449,84 +5002,6 @@ const Emphasis = ({
|
|
|
4449
5002
|
}) : null;
|
|
4450
5003
|
};
|
|
4451
5004
|
|
|
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
|
-
|
|
4530
5005
|
const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
|
|
4531
5006
|
bottomContent,
|
|
4532
5007
|
className,
|
|
@@ -4733,7 +5208,7 @@ const Tooltip = ({
|
|
|
4733
5208
|
const anchorReference = React.useRef(null);
|
|
4734
5209
|
const [arrowElement, setArrowElement] = React.useState(null);
|
|
4735
5210
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
4736
|
-
const fallbackId =
|
|
5211
|
+
const fallbackId = reactId.useId();
|
|
4737
5212
|
const tooltipId = id ?? fallbackId;
|
|
4738
5213
|
const modifiers = [];
|
|
4739
5214
|
modifiers.push({
|
|
@@ -4773,40 +5248,42 @@ const Tooltip = ({
|
|
|
4773
5248
|
forceUpdate();
|
|
4774
5249
|
}
|
|
4775
5250
|
}, [open]);
|
|
4776
|
-
return /*#__PURE__*/jsxRuntime.
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
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
|
+
})
|
|
4810
5287
|
});
|
|
4811
5288
|
};
|
|
4812
5289
|
|
|
@@ -5004,6 +5481,84 @@ const FlowNavigation = ({
|
|
|
5004
5481
|
});
|
|
5005
5482
|
};
|
|
5006
5483
|
|
|
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
|
+
|
|
5007
5562
|
const HeaderAction = ({
|
|
5008
5563
|
action
|
|
5009
5564
|
}) => {
|
|
@@ -5043,70 +5598,31 @@ const HeaderAction = ({
|
|
|
5043
5598
|
const Header = ({
|
|
5044
5599
|
action,
|
|
5045
5600
|
as = 'h5',
|
|
5046
|
-
title,
|
|
5047
|
-
className
|
|
5048
|
-
}) => {
|
|
5049
|
-
if (!action) {
|
|
5050
|
-
return /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
5051
|
-
as: as,
|
|
5052
|
-
type: exports.Typography.TITLE_GROUP,
|
|
5053
|
-
className: classNames__default.default('np-header', 'np-header__title', className),
|
|
5054
|
-
children: title
|
|
5055
|
-
});
|
|
5056
|
-
}
|
|
5057
|
-
if (as === 'legend') {
|
|
5058
|
-
// eslint-disable-next-line no-console
|
|
5059
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
5060
|
-
}
|
|
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;
|
|
5601
|
+
title,
|
|
5602
|
+
className
|
|
5603
|
+
}) => {
|
|
5604
|
+
if (!action) {
|
|
5605
|
+
return /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
5606
|
+
as: as,
|
|
5607
|
+
type: exports.Typography.TITLE_GROUP,
|
|
5608
|
+
className: classNames__default.default('np-header', 'np-header__title', className),
|
|
5609
|
+
children: title
|
|
5610
|
+
});
|
|
5097
5611
|
}
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
className: classNames__default.default(
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5612
|
+
if (as === 'legend') {
|
|
5613
|
+
// eslint-disable-next-line no-console
|
|
5614
|
+
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
5615
|
+
}
|
|
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
|
+
})]
|
|
5110
5626
|
});
|
|
5111
5627
|
};
|
|
5112
5628
|
|
|
@@ -5139,7 +5655,7 @@ const Modal = ({
|
|
|
5139
5655
|
const isCompact = checkSpecialClasses('compact');
|
|
5140
5656
|
const noDivider = checkSpecialClasses('no-divider');
|
|
5141
5657
|
const contentReference = React.useRef(null);
|
|
5142
|
-
const titleId =
|
|
5658
|
+
const titleId = reactId.useId();
|
|
5143
5659
|
return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
|
|
5144
5660
|
open: open,
|
|
5145
5661
|
headerTitle: title,
|
|
@@ -5652,9 +6168,10 @@ class WithDisplayFormat extends React.Component {
|
|
|
5652
6168
|
return 'Backspace';
|
|
5653
6169
|
}
|
|
5654
6170
|
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';
|
|
5655
6174
|
}
|
|
5656
|
-
// triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
|
|
5657
|
-
return 'Paste';
|
|
5658
6175
|
};
|
|
5659
6176
|
resetEvent = () => {
|
|
5660
6177
|
this.setState({
|
|
@@ -5807,10 +6324,11 @@ class WithDisplayFormat extends React.Component {
|
|
|
5807
6324
|
selectionEnd,
|
|
5808
6325
|
pastedLength
|
|
5809
6326
|
} = this.state;
|
|
5810
|
-
const target = triggerEvent?.currentTarget;
|
|
5811
6327
|
const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
|
|
5812
6328
|
setTimeout(() => {
|
|
5813
|
-
|
|
6329
|
+
if (triggerEvent) {
|
|
6330
|
+
triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
|
|
6331
|
+
}
|
|
5814
6332
|
this.setState({
|
|
5815
6333
|
selectionStart: cursorPosition,
|
|
5816
6334
|
selectionEnd: cursorPosition
|
|
@@ -6490,8 +7008,8 @@ function SelectInputOptions({
|
|
|
6490
7008
|
}
|
|
6491
7009
|
}, []);
|
|
6492
7010
|
const showStatus = resultsEmpty;
|
|
6493
|
-
const statusId =
|
|
6494
|
-
const listboxId =
|
|
7011
|
+
const statusId = reactId.useId();
|
|
7012
|
+
const listboxId = reactId.useId();
|
|
6495
7013
|
return /*#__PURE__*/jsxRuntime.jsxs(react$1.Listbox.Options, {
|
|
6496
7014
|
as: SelectInputOptionsContainer,
|
|
6497
7015
|
static: true,
|
|
@@ -6618,7 +7136,7 @@ function SelectInputGroupItemView({
|
|
|
6618
7136
|
renderValue,
|
|
6619
7137
|
needle
|
|
6620
7138
|
}) {
|
|
6621
|
-
const headerId =
|
|
7139
|
+
const headerId = reactId.useId();
|
|
6622
7140
|
return (
|
|
6623
7141
|
/*#__PURE__*/
|
|
6624
7142
|
// An empty container may be rendered when no options match `needle`
|
|
@@ -8977,227 +9495,6 @@ const ProgressBar = ({
|
|
|
8977
9495
|
});
|
|
8978
9496
|
};
|
|
8979
9497
|
|
|
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
|
-
|
|
9201
9498
|
const PromoCardGroup = ({
|
|
9202
9499
|
children,
|
|
9203
9500
|
className,
|
|
@@ -12305,7 +12602,7 @@ const ProcessingStep = props => {
|
|
|
12305
12602
|
"aria-hidden": isComplete,
|
|
12306
12603
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12307
12604
|
className: "droppable-card-content",
|
|
12308
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
12605
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
|
|
12309
12606
|
size: exports.Size.Small,
|
|
12310
12607
|
status: processStatus,
|
|
12311
12608
|
onAnimationCompleted: status => onAnimationCompleted(status)
|
|
@@ -13128,7 +13425,7 @@ const UploadItem = ({
|
|
|
13128
13425
|
switch (status) {
|
|
13129
13426
|
case exports.Status.PROCESSING:
|
|
13130
13427
|
case exports.Status.PENDING:
|
|
13131
|
-
processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
13428
|
+
processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
|
|
13132
13429
|
size: exports.Size.EXTRA_SMALL,
|
|
13133
13430
|
status: exports.Status.PROCESSING
|
|
13134
13431
|
});
|
|
@@ -13139,7 +13436,7 @@ const UploadItem = ({
|
|
|
13139
13436
|
processIndicator = isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
13140
13437
|
size: exports.Size.SMALL,
|
|
13141
13438
|
sentiment: exports.Sentiment.POSITIVE
|
|
13142
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
13439
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
|
|
13143
13440
|
size: exports.Size.EXTRA_SMALL,
|
|
13144
13441
|
status: exports.Status.SUCCEEDED
|
|
13145
13442
|
});
|
|
@@ -13154,7 +13451,7 @@ const UploadItem = ({
|
|
|
13154
13451
|
children: processIndicator
|
|
13155
13452
|
}); // Scale down ProcessIndicator to be 20px*20px to match `icons`
|
|
13156
13453
|
};
|
|
13157
|
-
const getErrorMessage = () => typeof error === 'object'
|
|
13454
|
+
const getErrorMessage = () => typeof error === 'object' && error.message || error || formatMessage(MESSAGES.uploadingFailed);
|
|
13158
13455
|
const getDescription = () => {
|
|
13159
13456
|
if (error || status === exports.Status.FAILED) {
|
|
13160
13457
|
return /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
@@ -14498,11 +14795,12 @@ exports.Alert = Alert;
|
|
|
14498
14795
|
exports.Avatar = Avatar;
|
|
14499
14796
|
exports.AvatarWrapper = AvatarWrapper;
|
|
14500
14797
|
exports.Badge = Badge;
|
|
14501
|
-
exports.BaseCard = Card;
|
|
14798
|
+
exports.BaseCard = Card$2;
|
|
14502
14799
|
exports.Body = Body;
|
|
14503
14800
|
exports.BottomSheet = BottomSheet$1;
|
|
14504
14801
|
exports.Button = Button;
|
|
14505
|
-
exports.Card = Card$
|
|
14802
|
+
exports.Card = Card$1;
|
|
14803
|
+
exports.Carousel = Carousel;
|
|
14506
14804
|
exports.Checkbox = Checkbox;
|
|
14507
14805
|
exports.CheckboxButton = CheckboxButton$1;
|
|
14508
14806
|
exports.CheckboxOption = CheckboxOption;
|
|
@@ -14550,7 +14848,7 @@ exports.Option = Option$2;
|
|
|
14550
14848
|
exports.OverlayHeader = OverlayHeader$1;
|
|
14551
14849
|
exports.PhoneNumberInput = PhoneNumberInput;
|
|
14552
14850
|
exports.Popover = Popover$1;
|
|
14553
|
-
exports.ProcessIndicator = ProcessIndicator;
|
|
14851
|
+
exports.ProcessIndicator = ProcessIndicator$1;
|
|
14554
14852
|
exports.Progress = Progress;
|
|
14555
14853
|
exports.ProgressBar = ProgressBar;
|
|
14556
14854
|
exports.PromoCard = PromoCard$1;
|