@transferwise/components 46.30.2 → 46.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +931 -523
- package/build/index.js.map +1 -1
- package/build/index.mjs +928 -523
- 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/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/dateInput/DateInput.d.ts +5 -4
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +11 -4
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +12 -0
- package/build/types/field/Field.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/_common.d.ts +2 -2
- package/build/types/inputs/_common.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +24 -0
- package/build/types/inputs/contexts.d.ts.map +1 -0
- package/build/types/label/Label.d.ts +9 -0
- package/build/types/label/Label.d.ts.map +1 -0
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.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/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/switch/Switch.d.ts +6 -3
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/package.json +3 -3
- 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/dateInput/DateInput.rtl.spec.tsx +17 -0
- package/src/dateInput/DateInput.tsx +28 -22
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +2 -2
- package/src/dateLookup/DateLookup.rtl.spec.tsx +21 -0
- package/src/dateLookup/DateLookup.state.spec.js +5 -5
- package/src/dateLookup/DateLookup.tests.story.tsx +4 -11
- package/src/dateLookup/DateLookup.tsx +24 -9
- package/src/dateLookup/DateLookup.view.spec.js +11 -11
- package/src/field/Field.spec.tsx +95 -0
- package/src/field/Field.story.tsx +59 -0
- package/src/field/Field.tsx +70 -0
- package/src/index.ts +6 -0
- package/src/inputs/Input.tsx +5 -3
- package/src/inputs/SelectInput.spec.tsx +10 -0
- package/src/inputs/SelectInput.tsx +9 -4
- package/src/inputs/TextArea.tsx +6 -3
- package/src/inputs/_ButtonInput.tsx +2 -2
- package/src/inputs/_common.ts +2 -2
- package/src/inputs/contexts.tsx +45 -0
- package/src/label/Label.spec.tsx +26 -0
- package/src/label/Label.story.tsx +37 -0
- package/src/label/Label.tsx +20 -0
- package/src/main.css +135 -0
- package/src/main.less +1 -0
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +16 -22
- package/src/phoneNumberInput/PhoneNumberInput.tsx +14 -2
- package/src/promoCard/PromoCard.story.tsx +2 -2
- package/src/promoCard/PromoCard.tsx +30 -9
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +14 -0
- package/src/radioGroup/RadioGroup.story.tsx +26 -0
- package/src/radioGroup/RadioGroup.tsx +4 -1
- package/src/switch/Switch.spec.tsx +10 -0
- package/src/switch/Switch.tsx +22 -13
- package/src/utilities/logActionRequired.js +1 -1
package/build/index.js
CHANGED
|
@@ -826,7 +826,7 @@ function Title({
|
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
function logActionRequired(message) {
|
|
829
|
-
if (
|
|
829
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
|
|
830
830
|
// eslint-disable-next-line no-console
|
|
831
831
|
console.warn(message);
|
|
832
832
|
}
|
|
@@ -1510,7 +1510,717 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
1510
1510
|
});
|
|
1511
1511
|
});
|
|
1512
1512
|
|
|
1513
|
-
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) => {
|
|
1514
2224
|
const {
|
|
1515
2225
|
'aria-label': ariaLabel,
|
|
1516
2226
|
as: Element,
|
|
@@ -1561,7 +2271,7 @@ const Card$1 = /*#__PURE__*/React.forwardRef((props, reference) => {
|
|
|
1561
2271
|
const hasChildren = ({
|
|
1562
2272
|
children
|
|
1563
2273
|
}) => children;
|
|
1564
|
-
Card
|
|
2274
|
+
Card.propTypes = {
|
|
1565
2275
|
'aria-label': PropTypes__default.default.string,
|
|
1566
2276
|
as: PropTypes__default.default.string,
|
|
1567
2277
|
isExpanded: requiredIf__default.default(PropTypes__default.default.bool, hasChildren),
|
|
@@ -1574,7 +2284,7 @@ Card$1.propTypes = {
|
|
|
1574
2284
|
className: PropTypes__default.default.string,
|
|
1575
2285
|
'data-testid': PropTypes__default.default.string
|
|
1576
2286
|
};
|
|
1577
|
-
Card
|
|
2287
|
+
Card.defaultProps = {
|
|
1578
2288
|
'aria-label': undefined,
|
|
1579
2289
|
as: 'div',
|
|
1580
2290
|
children: null,
|
|
@@ -1582,7 +2292,7 @@ Card$1.defaultProps = {
|
|
|
1582
2292
|
className: null,
|
|
1583
2293
|
'data-testid': null
|
|
1584
2294
|
};
|
|
1585
|
-
var Card$
|
|
2295
|
+
var Card$1 = Card;
|
|
1586
2296
|
|
|
1587
2297
|
const CheckboxButton = /*#__PURE__*/React.forwardRef(({
|
|
1588
2298
|
checked,
|
|
@@ -2035,167 +2745,38 @@ const Dimmer = ({
|
|
|
2035
2745
|
const DimmerWrapper = ({
|
|
2036
2746
|
open,
|
|
2037
2747
|
hasNotExited,
|
|
2038
|
-
children
|
|
2039
|
-
}) => {
|
|
2040
|
-
const {
|
|
2041
|
-
screenMode,
|
|
2042
|
-
theme
|
|
2043
|
-
} = componentsTheming.useTheme();
|
|
2044
|
-
return open || hasNotExited ? /*#__PURE__*/jsxRuntime.jsx(componentsTheming.ThemeProvider, {
|
|
2045
|
-
theme: "personal",
|
|
2046
|
-
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
2047
|
-
isNotRootProvider: true,
|
|
2048
|
-
children: children
|
|
2049
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2050
|
-
children: children
|
|
2051
|
-
});
|
|
2052
|
-
};
|
|
2053
|
-
const DimmerContentWrapper = ({
|
|
2054
|
-
children,
|
|
2055
|
-
scrollBody
|
|
2056
|
-
}) => {
|
|
2057
|
-
React.useEffect(() => {
|
|
2058
|
-
if (scrollBody) {
|
|
2059
|
-
addNoScrollClass();
|
|
2060
|
-
}
|
|
2061
|
-
return () => {
|
|
2062
|
-
if (scrollBody) {
|
|
2063
|
-
removeNoScrollClass();
|
|
2064
|
-
}
|
|
2065
|
-
};
|
|
2066
|
-
}, [scrollBody]);
|
|
2067
|
-
return children;
|
|
2068
|
-
};
|
|
2069
|
-
var Dimmer$1 = withNextPortalWrapper(Dimmer);
|
|
2070
|
-
|
|
2071
|
-
const useConditionalListener = ({
|
|
2072
|
-
attachListener,
|
|
2073
|
-
callback,
|
|
2074
|
-
eventType,
|
|
2075
|
-
parent
|
|
2076
|
-
}) => {
|
|
2077
|
-
React.useEffect(() => {
|
|
2078
|
-
if (attachListener && !neptuneValidation.isUndefined(parent)) {
|
|
2079
|
-
parent.addEventListener(eventType, callback, true);
|
|
2080
|
-
}
|
|
2081
|
-
return () => {
|
|
2082
|
-
if (!neptuneValidation.isUndefined(parent)) {
|
|
2083
|
-
parent.removeEventListener(eventType, callback, true);
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2086
|
-
}, [attachListener, callback, eventType, parent]);
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
const DirectionContext = /*#__PURE__*/React.createContext(exports.Direction.LTR);
|
|
2090
|
-
const DirectionProvider = ({
|
|
2091
|
-
direction,
|
|
2092
|
-
children
|
|
2093
|
-
}) => {
|
|
2094
|
-
return /*#__PURE__*/jsxRuntime.jsx(DirectionContext.Provider, {
|
|
2095
|
-
value: direction,
|
|
2096
|
-
children: children
|
|
2097
|
-
});
|
|
2098
|
-
};
|
|
2099
|
-
|
|
2100
|
-
const useDirection = () => {
|
|
2101
|
-
const direction = React.useContext(DirectionContext);
|
|
2102
|
-
return {
|
|
2103
|
-
direction,
|
|
2104
|
-
isRTL: direction === 'rtl'
|
|
2105
|
-
};
|
|
2106
|
-
};
|
|
2107
|
-
|
|
2108
|
-
const ObserverParams = {
|
|
2109
|
-
threshold: 0.1
|
|
2110
|
-
};
|
|
2111
|
-
|
|
2112
|
-
/**
|
|
2113
|
-
* useHasIntersected.
|
|
2114
|
-
* Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.
|
|
2115
|
-
* Once the intersection has happened the hook will not return false even if the element gets out of the viewport.
|
|
2116
|
-
*
|
|
2117
|
-
* @param elRef.elRef
|
|
2118
|
-
* @param {object} [elRef] - node object that contains a react reference to the element that needs to be observed.
|
|
2119
|
-
* @param {strimng} [loading = 'eager'] - string that contains the type of loading.
|
|
2120
|
-
* @param elRef.loading
|
|
2121
|
-
* @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`
|
|
2122
|
-
*/
|
|
2123
|
-
const useHasIntersected = ({
|
|
2124
|
-
elRef,
|
|
2125
|
-
loading
|
|
2748
|
+
children
|
|
2126
2749
|
}) => {
|
|
2127
|
-
const [hasIntersected, setHasIntersected] = React.useState(false);
|
|
2128
2750
|
const {
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2751
|
+
screenMode,
|
|
2752
|
+
theme
|
|
2753
|
+
} = componentsTheming.useTheme();
|
|
2754
|
+
return open || hasNotExited ? /*#__PURE__*/jsxRuntime.jsx(componentsTheming.ThemeProvider, {
|
|
2755
|
+
theme: "personal",
|
|
2756
|
+
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
2757
|
+
isNotRootProvider: true,
|
|
2758
|
+
children: children
|
|
2759
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2760
|
+
children: children
|
|
2761
|
+
});
|
|
2762
|
+
};
|
|
2763
|
+
const DimmerContentWrapper = ({
|
|
2764
|
+
children,
|
|
2765
|
+
scrollBody
|
|
2766
|
+
}) => {
|
|
2142
2767
|
React.useEffect(() => {
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
// Check if window is define for SSR and Old browsers fallback
|
|
2147
|
-
if (typeof window === 'undefined' || !window.IntersectionObserver || !isValidReference()) {
|
|
2148
|
-
setHasIntersected(true);
|
|
2149
|
-
} else if (!didCancel) {
|
|
2150
|
-
observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
|
|
2151
|
-
observer.observe(current);
|
|
2768
|
+
if (scrollBody) {
|
|
2769
|
+
addNoScrollClass();
|
|
2152
2770
|
}
|
|
2153
2771
|
return () => {
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
observer.unobserve(current);
|
|
2772
|
+
if (scrollBody) {
|
|
2773
|
+
removeNoScrollClass();
|
|
2157
2774
|
}
|
|
2158
2775
|
};
|
|
2159
|
-
}, [
|
|
2160
|
-
|
|
2161
|
-
return [false];
|
|
2162
|
-
}
|
|
2163
|
-
return [hasIntersected];
|
|
2164
|
-
};
|
|
2165
|
-
|
|
2166
|
-
// eslint-disable-next-line import/extensions
|
|
2167
|
-
function useMedia(query) {
|
|
2168
|
-
return index_js.useSyncExternalStore(onStoreChange => {
|
|
2169
|
-
const mediaQueryList = window.matchMedia(query);
|
|
2170
|
-
mediaQueryList.addEventListener('change', onStoreChange);
|
|
2171
|
-
return () => {
|
|
2172
|
-
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
2173
|
-
};
|
|
2174
|
-
}, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
function useScreenSize(size) {
|
|
2178
|
-
return useMedia(`(min-width: ${size}px)`);
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
/**
|
|
2182
|
-
* @deprecated Prefer `useScreenSize` instead.
|
|
2183
|
-
*/
|
|
2184
|
-
const useLayout = () => {
|
|
2185
|
-
const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
|
|
2186
|
-
const screenSm = useScreenSize(exports.Breakpoint.SMALL);
|
|
2187
|
-
const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
|
|
2188
|
-
const screenLg = useScreenSize(exports.Breakpoint.LARGE);
|
|
2189
|
-
const screenXl = useScreenSize(exports.Breakpoint.EXTRA_LARGE);
|
|
2190
|
-
return {
|
|
2191
|
-
isMobile: screenSm != null ? !screenSm : undefined,
|
|
2192
|
-
isExtraSmall: screenXs,
|
|
2193
|
-
isSmall: screenSm,
|
|
2194
|
-
isMedium: screenMd,
|
|
2195
|
-
isLarge: screenLg,
|
|
2196
|
-
isExtraLarge: screenXl
|
|
2197
|
-
};
|
|
2776
|
+
}, [scrollBody]);
|
|
2777
|
+
return children;
|
|
2198
2778
|
};
|
|
2779
|
+
var Dimmer$1 = withNextPortalWrapper(Dimmer);
|
|
2199
2780
|
|
|
2200
2781
|
const EXIT_ANIMATION = 350;
|
|
2201
2782
|
const SlidingPanel = /*#__PURE__*/React.forwardRef(({
|
|
@@ -2476,39 +3057,6 @@ const BottomSheet$1 = props => {
|
|
|
2476
3057
|
});
|
|
2477
3058
|
};
|
|
2478
3059
|
|
|
2479
|
-
const Card = ({
|
|
2480
|
-
className,
|
|
2481
|
-
children = null,
|
|
2482
|
-
id,
|
|
2483
|
-
isDisabled = false,
|
|
2484
|
-
isSmall = false,
|
|
2485
|
-
onDismiss,
|
|
2486
|
-
testId,
|
|
2487
|
-
...props
|
|
2488
|
-
}) => {
|
|
2489
|
-
const closeButtonReference = React.useRef(null);
|
|
2490
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2491
|
-
className: classNames__default.default('np-Card', {
|
|
2492
|
-
'np-Card--small': !!isSmall,
|
|
2493
|
-
'is-disabled': !!isDisabled
|
|
2494
|
-
}, className),
|
|
2495
|
-
id: id,
|
|
2496
|
-
"data-testid": testId,
|
|
2497
|
-
...props,
|
|
2498
|
-
children: [onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
2499
|
-
ref: closeButtonReference,
|
|
2500
|
-
className: "np-Card-closeButton",
|
|
2501
|
-
size: isSmall ? 'sm' : 'md',
|
|
2502
|
-
isDisabled: isDisabled,
|
|
2503
|
-
testId: "close-button",
|
|
2504
|
-
onClick: e => {
|
|
2505
|
-
stopPropagation$1(e);
|
|
2506
|
-
onDismiss();
|
|
2507
|
-
}
|
|
2508
|
-
}), children]
|
|
2509
|
-
});
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
3060
|
function CriticalCommsBanner({
|
|
2513
3061
|
title,
|
|
2514
3062
|
subtitle,
|
|
@@ -2622,6 +3170,36 @@ const isMonthAndYearFormat = dateString => validDateString(dateString) && dateSt
|
|
|
2622
3170
|
const MDY = new Set(['en-US']);
|
|
2623
3171
|
const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
|
|
2624
3172
|
|
|
3173
|
+
const FieldLabelIdContext = /*#__PURE__*/React.createContext(undefined);
|
|
3174
|
+
const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
|
|
3175
|
+
const InputIdContext = /*#__PURE__*/React.createContext(undefined);
|
|
3176
|
+
const InputIdContextProvider = InputIdContext.Provider;
|
|
3177
|
+
const InputDescribedByContext = /*#__PURE__*/React.createContext(undefined);
|
|
3178
|
+
const InputDescribedByProvider = InputDescribedByContext.Provider;
|
|
3179
|
+
const InputInvalidContext = /*#__PURE__*/React.createContext(undefined);
|
|
3180
|
+
const InputInvalidProvider = InputInvalidContext.Provider;
|
|
3181
|
+
function useInputAttributes({
|
|
3182
|
+
nonLabelable
|
|
3183
|
+
} = {}) {
|
|
3184
|
+
const labelId = React.useContext(FieldLabelIdContext);
|
|
3185
|
+
return {
|
|
3186
|
+
id: React.useContext(InputIdContext),
|
|
3187
|
+
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
3188
|
+
'aria-describedby': React.useContext(InputDescribedByContext),
|
|
3189
|
+
'aria-invalid': React.useContext(InputInvalidContext)
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
function withInputAttributes(Component, args) {
|
|
3193
|
+
function ComponentWithInputAttributes(props) {
|
|
3194
|
+
return /*#__PURE__*/jsxRuntime.jsx(Component, {
|
|
3195
|
+
inputAttributes: useInputAttributes(args),
|
|
3196
|
+
...props
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
|
|
3200
|
+
return ComponentWithInputAttributes;
|
|
3201
|
+
}
|
|
3202
|
+
|
|
2625
3203
|
var messages$9 = reactIntl.defineMessages({
|
|
2626
3204
|
monthLabel: {
|
|
2627
3205
|
id: "neptune.DateInput.month.label"
|
|
@@ -2646,7 +3224,7 @@ const convertToLocalMidnight = date => {
|
|
|
2646
3224
|
};
|
|
2647
3225
|
|
|
2648
3226
|
const DateInput = ({
|
|
2649
|
-
'aria-labelledby':
|
|
3227
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
2650
3228
|
'aria-label': ariaLabel,
|
|
2651
3229
|
disabled = false,
|
|
2652
3230
|
size = exports.Size.MEDIUM,
|
|
@@ -2662,9 +3240,14 @@ const DateInput = ({
|
|
|
2662
3240
|
onFocus,
|
|
2663
3241
|
onBlur,
|
|
2664
3242
|
placeholders,
|
|
2665
|
-
id,
|
|
3243
|
+
id: idProp,
|
|
2666
3244
|
selectProps = {}
|
|
2667
3245
|
}) => {
|
|
3246
|
+
const inputAttributes = useInputAttributes({
|
|
3247
|
+
nonLabelable: true
|
|
3248
|
+
});
|
|
3249
|
+
const id = idProp ?? inputAttributes.id;
|
|
3250
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
|
|
2668
3251
|
const {
|
|
2669
3252
|
locale,
|
|
2670
3253
|
formatMessage
|
|
@@ -2701,9 +3284,9 @@ const DateInput = ({
|
|
|
2701
3284
|
const [year, setYear] = React.useState(() => getInitialDate('year'));
|
|
2702
3285
|
const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
|
|
2703
3286
|
const monthNames = getMonthNames(locale, monthFormat);
|
|
2704
|
-
dayLabel
|
|
2705
|
-
monthLabel
|
|
2706
|
-
yearLabel
|
|
3287
|
+
dayLabel ||= formatMessage(messages$9.dayLabel);
|
|
3288
|
+
monthLabel ||= formatMessage(messages$9.monthLabel);
|
|
3289
|
+
yearLabel ||= formatMessage(messages$9.yearLabel);
|
|
2707
3290
|
placeholders = {
|
|
2708
3291
|
day: placeholders?.day || formatMessage(messages$9.dayPlaceholder),
|
|
2709
3292
|
month: placeholders?.month || formatMessage(messages$9.monthLabel),
|
|
@@ -2894,6 +3477,7 @@ const DateInput = ({
|
|
|
2894
3477
|
const yearFirst = YMD.has(locale);
|
|
2895
3478
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2896
3479
|
className: "tw-date",
|
|
3480
|
+
...inputAttributes,
|
|
2897
3481
|
id: id,
|
|
2898
3482
|
"aria-labelledby": ariaLabelledBy,
|
|
2899
3483
|
"aria-label": ariaLabel,
|
|
@@ -2913,15 +3497,15 @@ const DateInput = ({
|
|
|
2913
3497
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2914
3498
|
children: [getMonth(), getDay(), getYear()]
|
|
2915
3499
|
});
|
|
2916
|
-
}
|
|
3500
|
+
}
|
|
3501
|
+
if (yearFirst) {
|
|
2917
3502
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2918
3503
|
children: [getYear(), getMonth(), getDay()]
|
|
2919
3504
|
});
|
|
2920
|
-
} else {
|
|
2921
|
-
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2922
|
-
children: [getDay(), getMonth(), getYear()]
|
|
2923
|
-
});
|
|
2924
3505
|
}
|
|
3506
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3507
|
+
children: [getDay(), getMonth(), getYear()]
|
|
3508
|
+
});
|
|
2925
3509
|
})()
|
|
2926
3510
|
})
|
|
2927
3511
|
});
|
|
@@ -4022,18 +4606,23 @@ class DateLookup extends React.PureComponent {
|
|
|
4022
4606
|
open
|
|
4023
4607
|
} = this.state;
|
|
4024
4608
|
const {
|
|
4609
|
+
inputAttributes,
|
|
4610
|
+
id: idProp,
|
|
4611
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
4025
4612
|
size,
|
|
4026
4613
|
placeholder,
|
|
4027
4614
|
label,
|
|
4028
|
-
'aria-labelledby': ariaLabelledBy,
|
|
4029
4615
|
monthFormat,
|
|
4030
4616
|
disabled,
|
|
4031
4617
|
clearable,
|
|
4032
4618
|
value
|
|
4033
4619
|
} = this.props;
|
|
4620
|
+
const id = idProp ?? inputAttributes?.id;
|
|
4621
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
|
|
4034
4622
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4035
4623
|
ref: this.element,
|
|
4036
|
-
|
|
4624
|
+
...inputAttributes,
|
|
4625
|
+
id: id,
|
|
4037
4626
|
"aria-labelledby": ariaLabelledBy,
|
|
4038
4627
|
className: "input-group",
|
|
4039
4628
|
onKeyDown: this.handleKeyDown,
|
|
@@ -4057,6 +4646,9 @@ class DateLookup extends React.PureComponent {
|
|
|
4057
4646
|
});
|
|
4058
4647
|
}
|
|
4059
4648
|
}
|
|
4649
|
+
var DateLookup$1 = withInputAttributes(DateLookup, {
|
|
4650
|
+
nonLabelable: true
|
|
4651
|
+
});
|
|
4060
4652
|
|
|
4061
4653
|
const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
4062
4654
|
as: component = 'button',
|
|
@@ -4322,20 +4914,6 @@ DefinitionList.defaultProps = {
|
|
|
4322
4914
|
};
|
|
4323
4915
|
var DefinitionList$1 = DefinitionList;
|
|
4324
4916
|
|
|
4325
|
-
function Display({
|
|
4326
|
-
as: Heading = 'h1',
|
|
4327
|
-
type = exports.Typography.DISPLAY_LARGE,
|
|
4328
|
-
children,
|
|
4329
|
-
className,
|
|
4330
|
-
id
|
|
4331
|
-
}) {
|
|
4332
|
-
return /*#__PURE__*/jsxRuntime.jsx(Heading, {
|
|
4333
|
-
id: id,
|
|
4334
|
-
className: classNames__default.default(`np-text-${type}`, 'text-primary', className),
|
|
4335
|
-
children: children
|
|
4336
|
-
});
|
|
4337
|
-
}
|
|
4338
|
-
|
|
4339
4917
|
const DropFade = ({
|
|
4340
4918
|
children,
|
|
4341
4919
|
show
|
|
@@ -4903,6 +5481,84 @@ const FlowNavigation = ({
|
|
|
4903
5481
|
});
|
|
4904
5482
|
};
|
|
4905
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
|
+
|
|
4906
5562
|
const HeaderAction = ({
|
|
4907
5563
|
action
|
|
4908
5564
|
}) => {
|
|
@@ -4970,45 +5626,6 @@ const Header = ({
|
|
|
4970
5626
|
});
|
|
4971
5627
|
};
|
|
4972
5628
|
|
|
4973
|
-
const EmptyTransparentImage = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
|
4974
|
-
const Image = ({
|
|
4975
|
-
id,
|
|
4976
|
-
src,
|
|
4977
|
-
alt,
|
|
4978
|
-
onLoad,
|
|
4979
|
-
onError,
|
|
4980
|
-
className,
|
|
4981
|
-
loading,
|
|
4982
|
-
stretch = true,
|
|
4983
|
-
role,
|
|
4984
|
-
shrink = true
|
|
4985
|
-
}) => {
|
|
4986
|
-
const elementReference = React.useRef(null);
|
|
4987
|
-
const [hasIntersected] = useHasIntersected({
|
|
4988
|
-
elRef: elementReference,
|
|
4989
|
-
loading
|
|
4990
|
-
});
|
|
4991
|
-
let imageSource = src;
|
|
4992
|
-
let imageOnLoad = onLoad;
|
|
4993
|
-
if (loading === 'lazy' && !hasIntersected) {
|
|
4994
|
-
imageSource = EmptyTransparentImage;
|
|
4995
|
-
imageOnLoad = undefined;
|
|
4996
|
-
}
|
|
4997
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
4998
|
-
ref: elementReference,
|
|
4999
|
-
id: id,
|
|
5000
|
-
alt: alt,
|
|
5001
|
-
src: imageSource,
|
|
5002
|
-
className: classNames__default.default(['tw-image', {
|
|
5003
|
-
'tw-image__stretch': stretch,
|
|
5004
|
-
'tw-image__shrink': shrink
|
|
5005
|
-
}, className]),
|
|
5006
|
-
role: role,
|
|
5007
|
-
onLoad: imageOnLoad,
|
|
5008
|
-
onError: onError
|
|
5009
|
-
});
|
|
5010
|
-
};
|
|
5011
|
-
|
|
5012
5629
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
5013
5630
|
exports.InfoPresentation = void 0;
|
|
5014
5631
|
(function (InfoPresentation) {
|
|
@@ -5235,20 +5852,16 @@ const Info = ({
|
|
|
5235
5852
|
});
|
|
5236
5853
|
};
|
|
5237
5854
|
|
|
5238
|
-
function
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
5249
|
-
children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5250
|
-
children: children
|
|
5251
|
-
})]
|
|
5855
|
+
function inputClassNameBase({
|
|
5856
|
+
size = 'auto'
|
|
5857
|
+
} = {}) {
|
|
5858
|
+
return classNames__default.default('form-control',
|
|
5859
|
+
// TODO: Deprecate
|
|
5860
|
+
'np-form-control', {
|
|
5861
|
+
'np-form-control--size-auto': size === 'auto',
|
|
5862
|
+
'np-form-control--size-sm': size === 'sm',
|
|
5863
|
+
'np-form-control--size-md': size === 'md',
|
|
5864
|
+
'np-form-control--size-lg': size === 'lg'
|
|
5252
5865
|
});
|
|
5253
5866
|
}
|
|
5254
5867
|
|
|
@@ -5370,29 +5983,17 @@ function InputAddon({
|
|
|
5370
5983
|
});
|
|
5371
5984
|
}
|
|
5372
5985
|
|
|
5373
|
-
function formControlClassNameBase({
|
|
5374
|
-
size = 'auto'
|
|
5375
|
-
} = {}) {
|
|
5376
|
-
return classNames__default.default('form-control',
|
|
5377
|
-
// TODO: Deprecate
|
|
5378
|
-
'np-form-control', {
|
|
5379
|
-
'np-form-control--size-auto': size === 'auto',
|
|
5380
|
-
'np-form-control--size-sm': size === 'sm',
|
|
5381
|
-
'np-form-control--size-md': size === 'md',
|
|
5382
|
-
'np-form-control--size-lg': size === 'lg'
|
|
5383
|
-
});
|
|
5384
|
-
}
|
|
5385
|
-
|
|
5386
5986
|
const Input = /*#__PURE__*/React.forwardRef(function Input({
|
|
5387
5987
|
size = 'auto',
|
|
5388
5988
|
shape = 'rectangle',
|
|
5389
5989
|
className,
|
|
5390
5990
|
...restProps
|
|
5391
5991
|
}, reference) {
|
|
5992
|
+
const inputAttributes = useInputAttributes();
|
|
5392
5993
|
const inputPaddings = useInputPaddings();
|
|
5393
5994
|
return /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
5394
5995
|
ref: reference,
|
|
5395
|
-
className: classNames__default.default(className,
|
|
5996
|
+
className: classNames__default.default(className, inputClassNameBase({
|
|
5396
5997
|
size
|
|
5397
5998
|
}), 'np-input', {
|
|
5398
5999
|
'np-input--shape-rectangle': shape === 'rectangle',
|
|
@@ -5401,6 +6002,7 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
|
|
|
5401
6002
|
// eslint-disable-next-line react/forbid-dom-props
|
|
5402
6003
|
,
|
|
5403
6004
|
style: inputPaddings,
|
|
6005
|
+
...inputAttributes,
|
|
5404
6006
|
...restProps
|
|
5405
6007
|
});
|
|
5406
6008
|
});
|
|
@@ -5822,12 +6424,6 @@ const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function Polymorp
|
|
|
5822
6424
|
});
|
|
5823
6425
|
});
|
|
5824
6426
|
|
|
5825
|
-
var messages$5 = reactIntl.defineMessages({
|
|
5826
|
-
noResultsFound: {
|
|
5827
|
-
id: "neptune.SelectInput.noResultsFound"
|
|
5828
|
-
}
|
|
5829
|
-
});
|
|
5830
|
-
|
|
5831
6427
|
function PreventScroll() {
|
|
5832
6428
|
overlays.usePreventScroll();
|
|
5833
6429
|
return null;
|
|
@@ -5947,7 +6543,7 @@ const ButtonInput = /*#__PURE__*/React.forwardRef(function ButtonInput({
|
|
|
5947
6543
|
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
5948
6544
|
ref: ref,
|
|
5949
6545
|
type: "button",
|
|
5950
|
-
className: classNames__default.default(className,
|
|
6546
|
+
className: classNames__default.default(className, inputClassNameBase({
|
|
5951
6547
|
size
|
|
5952
6548
|
}), 'np-button-input')
|
|
5953
6549
|
// eslint-disable-next-line react/forbid-dom-props
|
|
@@ -6063,6 +6659,12 @@ function Popover({
|
|
|
6063
6659
|
});
|
|
6064
6660
|
}
|
|
6065
6661
|
|
|
6662
|
+
var messages$5 = reactIntl.defineMessages({
|
|
6663
|
+
noResultsFound: {
|
|
6664
|
+
id: "neptune.SelectInput.noResultsFound"
|
|
6665
|
+
}
|
|
6666
|
+
});
|
|
6667
|
+
|
|
6066
6668
|
function searchableString(value) {
|
|
6067
6669
|
return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
|
|
6068
6670
|
}
|
|
@@ -6182,7 +6784,7 @@ function SelectInputClearButton({
|
|
|
6182
6784
|
}
|
|
6183
6785
|
const noop = () => {};
|
|
6184
6786
|
function SelectInput({
|
|
6185
|
-
id,
|
|
6787
|
+
id: idProp,
|
|
6186
6788
|
name,
|
|
6187
6789
|
multiple,
|
|
6188
6790
|
placeholder,
|
|
@@ -6203,6 +6805,8 @@ function SelectInput({
|
|
|
6203
6805
|
onClose,
|
|
6204
6806
|
onClear
|
|
6205
6807
|
}) {
|
|
6808
|
+
const inputAttributes = useInputAttributes();
|
|
6809
|
+
const id = idProp ?? inputAttributes.id;
|
|
6206
6810
|
const [open, setOpen] = React.useState(false);
|
|
6207
6811
|
const initialized = React.useRef(false);
|
|
6208
6812
|
const handleClose = useEffectEvent(onClose ?? (() => {}));
|
|
@@ -6263,6 +6867,7 @@ function SelectInput({
|
|
|
6263
6867
|
ref(node);
|
|
6264
6868
|
triggerRef.current = node;
|
|
6265
6869
|
},
|
|
6870
|
+
...inputAttributes,
|
|
6266
6871
|
id,
|
|
6267
6872
|
...mergeProps__default.default({
|
|
6268
6873
|
onClick: () => {
|
|
@@ -6616,9 +7221,11 @@ const TextArea = /*#__PURE__*/React.forwardRef(function TextArea({
|
|
|
6616
7221
|
className,
|
|
6617
7222
|
...restProps
|
|
6618
7223
|
}, reference) {
|
|
7224
|
+
const inputAttributes = useInputAttributes();
|
|
6619
7225
|
return /*#__PURE__*/jsxRuntime.jsx("textarea", {
|
|
6620
7226
|
ref: reference,
|
|
6621
|
-
className: classNames__default.default(className,
|
|
7227
|
+
className: classNames__default.default(className, inputClassNameBase(), 'np-text-area'),
|
|
7228
|
+
...inputAttributes,
|
|
6622
7229
|
...restProps
|
|
6623
7230
|
});
|
|
6624
7231
|
});
|
|
@@ -8735,6 +9342,12 @@ const PhoneNumberInput = ({
|
|
|
8735
9342
|
return explodeNumberModel(cleanValue);
|
|
8736
9343
|
});
|
|
8737
9344
|
const [broadcastedValue, setBroadcastedValue] = React.useState(null);
|
|
9345
|
+
const [suffixDirty, setSuffixDirty] = React.useState(false);
|
|
9346
|
+
React.useEffect(() => {
|
|
9347
|
+
if (internalValue.suffix) {
|
|
9348
|
+
setSuffixDirty(true);
|
|
9349
|
+
}
|
|
9350
|
+
}, [internalValue.suffix]);
|
|
8738
9351
|
const countriesByPrefix = React.useMemo(() => groupCountriesByPrefix(sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3')), [disabledCountries]);
|
|
8739
9352
|
const onSuffixChange = event => {
|
|
8740
9353
|
const suffix = event.target.value;
|
|
@@ -8798,6 +9411,11 @@ const PhoneNumberInput = ({
|
|
|
8798
9411
|
format: country?.phoneFormat
|
|
8799
9412
|
}));
|
|
8800
9413
|
},
|
|
9414
|
+
onClose: () => {
|
|
9415
|
+
if (suffixDirty) {
|
|
9416
|
+
onBlur?.();
|
|
9417
|
+
}
|
|
9418
|
+
},
|
|
8801
9419
|
...selectProps
|
|
8802
9420
|
})
|
|
8803
9421
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -8817,7 +9435,7 @@ const PhoneNumberInput = ({
|
|
|
8817
9435
|
onChange: onSuffixChange,
|
|
8818
9436
|
onPaste: onPaste,
|
|
8819
9437
|
onFocus: onFocus,
|
|
8820
|
-
onBlur: onBlur
|
|
9438
|
+
onBlur: () => onBlur?.()
|
|
8821
9439
|
})
|
|
8822
9440
|
})
|
|
8823
9441
|
})]
|
|
@@ -8877,227 +9495,6 @@ const ProgressBar = ({
|
|
|
8877
9495
|
});
|
|
8878
9496
|
};
|
|
8879
9497
|
|
|
8880
|
-
const defaultPromoCardContext = {
|
|
8881
|
-
state: '',
|
|
8882
|
-
isDisabled: false,
|
|
8883
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
8884
|
-
onChange: () => {}
|
|
8885
|
-
};
|
|
8886
|
-
/**
|
|
8887
|
-
* The PromoCard context object.
|
|
8888
|
-
*/
|
|
8889
|
-
const PromoCardContext = /*#__PURE__*/React.createContext(defaultPromoCardContext);
|
|
8890
|
-
/**
|
|
8891
|
-
* A custom hook for accessing the PromoCard context object.
|
|
8892
|
-
*
|
|
8893
|
-
* The `usePromoCardContext` hook is used to access the PromoCard context object
|
|
8894
|
-
* from within a child PromoCard component. It throws an error if the context
|
|
8895
|
-
* object is not available, which can help with debugging and development.
|
|
8896
|
-
*
|
|
8897
|
-
* @returns {PromoCardContextType} - The PromoCard context object.
|
|
8898
|
-
*/
|
|
8899
|
-
const usePromoCardContext = () => {
|
|
8900
|
-
return React.useContext(PromoCardContext);
|
|
8901
|
-
};
|
|
8902
|
-
|
|
8903
|
-
const PromoCardIndicator = ({
|
|
8904
|
-
className,
|
|
8905
|
-
children,
|
|
8906
|
-
label,
|
|
8907
|
-
icon,
|
|
8908
|
-
isSmall = false,
|
|
8909
|
-
testid,
|
|
8910
|
-
...rest
|
|
8911
|
-
}) => {
|
|
8912
|
-
const isIconString = icon && typeof icon === 'string';
|
|
8913
|
-
const IconComponent = isIconString && {
|
|
8914
|
-
check: icons.Check,
|
|
8915
|
-
arrow: icons.ArrowRight,
|
|
8916
|
-
download: icons.Download
|
|
8917
|
-
}[icon];
|
|
8918
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
8919
|
-
className: classNames__default.default('np-Card-indicator', className),
|
|
8920
|
-
"data-testid": testid,
|
|
8921
|
-
...rest,
|
|
8922
|
-
children: [label && /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
8923
|
-
as: "span",
|
|
8924
|
-
type: exports.Typography.BODY_LARGE_BOLD,
|
|
8925
|
-
className: "np-Card-indicatorText",
|
|
8926
|
-
children: label
|
|
8927
|
-
}), icon && /*#__PURE__*/jsxRuntime.jsx(Avatar, {
|
|
8928
|
-
type: exports.AvatarType.ICON,
|
|
8929
|
-
size: isSmall ? 40 : 56,
|
|
8930
|
-
backgroundColor: "var(--Card-indicator-icon-background-color)",
|
|
8931
|
-
className: "np-Card-indicatorIcon",
|
|
8932
|
-
children: IconComponent ? /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
|
|
8933
|
-
size: 24,
|
|
8934
|
-
"aria-hidden": "true"
|
|
8935
|
-
}) : icon
|
|
8936
|
-
}), children]
|
|
8937
|
-
});
|
|
8938
|
-
};
|
|
8939
|
-
|
|
8940
|
-
const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
8941
|
-
className,
|
|
8942
|
-
description,
|
|
8943
|
-
defaultChecked,
|
|
8944
|
-
download,
|
|
8945
|
-
href,
|
|
8946
|
-
hrefLang,
|
|
8947
|
-
id,
|
|
8948
|
-
headingLevel = 'h3',
|
|
8949
|
-
imageAlt,
|
|
8950
|
-
imageClass,
|
|
8951
|
-
imageSource,
|
|
8952
|
-
indicatorLabel,
|
|
8953
|
-
indicatorIcon,
|
|
8954
|
-
isChecked,
|
|
8955
|
-
isDisabled,
|
|
8956
|
-
onClick,
|
|
8957
|
-
rel,
|
|
8958
|
-
tabIndex,
|
|
8959
|
-
target,
|
|
8960
|
-
testId,
|
|
8961
|
-
title,
|
|
8962
|
-
type,
|
|
8963
|
-
value,
|
|
8964
|
-
isSmall,
|
|
8965
|
-
useDisplayFont = true,
|
|
8966
|
-
...props
|
|
8967
|
-
}, reference) => {
|
|
8968
|
-
// Set the `checked` state to the value of `defaultChecked` if it is truthy,
|
|
8969
|
-
// or the value of `isChecked` if it is truthy, or `false` if neither
|
|
8970
|
-
// is truthy.
|
|
8971
|
-
const {
|
|
8972
|
-
state,
|
|
8973
|
-
onChange,
|
|
8974
|
-
isDisabled: contextIsDisabled
|
|
8975
|
-
} = usePromoCardContext();
|
|
8976
|
-
const [checked, setChecked] = React.useState(type === 'checkbox' ? defaultChecked ?? isChecked ?? false : false);
|
|
8977
|
-
const handleClick = () => {
|
|
8978
|
-
if (type === 'radio') {
|
|
8979
|
-
onChange(value || ''); // Update the context state for radio
|
|
8980
|
-
} else if (type === 'checkbox') {
|
|
8981
|
-
setChecked(!checked); // Update local state for checkbox
|
|
8982
|
-
}
|
|
8983
|
-
};
|
|
8984
|
-
const fallbackId = reactId.useId();
|
|
8985
|
-
const componentId = id || fallbackId;
|
|
8986
|
-
// Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
|
|
8987
|
-
// `'download'` if `download` is truthy. If neither condition is true, set
|
|
8988
|
-
// `icon` to `undefined`.
|
|
8989
|
-
// Create a function to get icon type
|
|
8990
|
-
const getIconType = () => {
|
|
8991
|
-
if (indicatorIcon) {
|
|
8992
|
-
return indicatorIcon;
|
|
8993
|
-
}
|
|
8994
|
-
if (download) {
|
|
8995
|
-
return 'download';
|
|
8996
|
-
}
|
|
8997
|
-
if (href && !type) {
|
|
8998
|
-
return 'arrow';
|
|
8999
|
-
}
|
|
9000
|
-
return undefined;
|
|
9001
|
-
};
|
|
9002
|
-
// Define all class names string based on the values of the `href`, `type`,
|
|
9003
|
-
// `checked`, and `className` props.
|
|
9004
|
-
const commonClasses = classNames__default.default({
|
|
9005
|
-
'np-Card--promoCard': true,
|
|
9006
|
-
'np-Card--checked': !href && type,
|
|
9007
|
-
'np-Card--link': href && !type,
|
|
9008
|
-
'is-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined
|
|
9009
|
-
}, className);
|
|
9010
|
-
// Object with common props that will be passed to the `Card` components
|
|
9011
|
-
const commonProps = {
|
|
9012
|
-
className: commonClasses,
|
|
9013
|
-
id: componentId,
|
|
9014
|
-
isDisabled: isDisabled || contextIsDisabled,
|
|
9015
|
-
onClick,
|
|
9016
|
-
ref: reference,
|
|
9017
|
-
'data-testid': testId,
|
|
9018
|
-
isSmall
|
|
9019
|
-
};
|
|
9020
|
-
// Object with Anchor props that will be passed to the `a` element. These
|
|
9021
|
-
// won't be refurned if set to `isDisabled`
|
|
9022
|
-
const anchorProps = href && !isDisabled ? {
|
|
9023
|
-
download,
|
|
9024
|
-
href: href || undefined,
|
|
9025
|
-
hrefLang,
|
|
9026
|
-
rel,
|
|
9027
|
-
target
|
|
9028
|
-
} : {};
|
|
9029
|
-
// Object of all Checked props that will be passed to the root `Card` component
|
|
9030
|
-
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
9031
|
-
...commonProps,
|
|
9032
|
-
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
9033
|
-
'aria-describedby': `${componentId}-title`,
|
|
9034
|
-
'aria-disabled': isDisabled,
|
|
9035
|
-
'data-value': value ?? undefined,
|
|
9036
|
-
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
9037
|
-
onClick: handleClick,
|
|
9038
|
-
onKeyDown: event => {
|
|
9039
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
9040
|
-
handleClick();
|
|
9041
|
-
}
|
|
9042
|
-
},
|
|
9043
|
-
ref: reference,
|
|
9044
|
-
tabIndex: 0
|
|
9045
|
-
} : {};
|
|
9046
|
-
const getTitle = () => {
|
|
9047
|
-
const titleContent = href && !type ? /*#__PURE__*/jsxRuntime.jsx("a", {
|
|
9048
|
-
className: "np-Card-titleLink",
|
|
9049
|
-
...anchorProps,
|
|
9050
|
-
children: title
|
|
9051
|
-
}) : title;
|
|
9052
|
-
const titleProps = {
|
|
9053
|
-
id: `${componentId}-title`,
|
|
9054
|
-
as: headingLevel,
|
|
9055
|
-
className: 'np-Card-title'
|
|
9056
|
-
};
|
|
9057
|
-
return useDisplayFont ? /*#__PURE__*/jsxRuntime.jsx(Display, {
|
|
9058
|
-
type: exports.Typography.DISPLAY_SMALL,
|
|
9059
|
-
...titleProps,
|
|
9060
|
-
children: titleContent
|
|
9061
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
9062
|
-
type: exports.Typography.TITLE_SUBSECTION,
|
|
9063
|
-
...titleProps,
|
|
9064
|
-
children: titleContent
|
|
9065
|
-
});
|
|
9066
|
-
};
|
|
9067
|
-
React.useEffect(() => {
|
|
9068
|
-
setChecked(defaultChecked ?? isChecked ?? false);
|
|
9069
|
-
}, [defaultChecked, isChecked]);
|
|
9070
|
-
return /*#__PURE__*/jsxRuntime.jsxs(Card, {
|
|
9071
|
-
...commonProps,
|
|
9072
|
-
...checkedProps,
|
|
9073
|
-
...props,
|
|
9074
|
-
children: [(value === state || checked) && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
9075
|
-
className: "np-Card-check",
|
|
9076
|
-
children: /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
|
|
9077
|
-
size: 24,
|
|
9078
|
-
"aria-hidden": "true"
|
|
9079
|
-
})
|
|
9080
|
-
}), getTitle(), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
9081
|
-
className: "np-Card-description",
|
|
9082
|
-
children: description
|
|
9083
|
-
}), imageSource && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9084
|
-
className: classNames__default.default('np-Card-image', {
|
|
9085
|
-
imageClass
|
|
9086
|
-
}),
|
|
9087
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Image, {
|
|
9088
|
-
src: imageSource,
|
|
9089
|
-
alt: imageAlt || '',
|
|
9090
|
-
loading: "lazy"
|
|
9091
|
-
})
|
|
9092
|
-
}), /*#__PURE__*/jsxRuntime.jsx(PromoCardIndicator, {
|
|
9093
|
-
label: indicatorLabel,
|
|
9094
|
-
icon: getIconType(),
|
|
9095
|
-
isSmall: isSmall
|
|
9096
|
-
})]
|
|
9097
|
-
});
|
|
9098
|
-
});
|
|
9099
|
-
var PromoCard$1 = /*#__PURE__*/React__namespace.default.memo(PromoCard);
|
|
9100
|
-
|
|
9101
9498
|
const PromoCardGroup = ({
|
|
9102
9499
|
children,
|
|
9103
9500
|
className,
|
|
@@ -9364,9 +9761,13 @@ function RadioGroup({
|
|
|
9364
9761
|
selectedValue: controlledValue,
|
|
9365
9762
|
onChange
|
|
9366
9763
|
}) {
|
|
9764
|
+
const inputAttributes = useInputAttributes({
|
|
9765
|
+
nonLabelable: true
|
|
9766
|
+
});
|
|
9367
9767
|
const [uncontrolledValue, setUncontrolledValue] = React.useState(controlledValue);
|
|
9368
9768
|
return radios.length > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9369
9769
|
role: "radiogroup",
|
|
9770
|
+
...inputAttributes,
|
|
9370
9771
|
children: radios.map(({
|
|
9371
9772
|
value = '',
|
|
9372
9773
|
...restProps
|
|
@@ -10478,13 +10879,18 @@ const Summary = ({
|
|
|
10478
10879
|
};
|
|
10479
10880
|
|
|
10480
10881
|
const Switch = props => {
|
|
10882
|
+
const inputAttributes = useInputAttributes({
|
|
10883
|
+
nonLabelable: true
|
|
10884
|
+
});
|
|
10481
10885
|
const {
|
|
10482
10886
|
isModern
|
|
10483
10887
|
} = componentsTheming.useTheme();
|
|
10484
10888
|
const {
|
|
10485
10889
|
checked,
|
|
10486
10890
|
className,
|
|
10487
|
-
id,
|
|
10891
|
+
id = inputAttributes.id,
|
|
10892
|
+
'aria-label': ariaLabel,
|
|
10893
|
+
'aria-labelledby': ariaLabelledbyProp,
|
|
10488
10894
|
onClick,
|
|
10489
10895
|
disabled
|
|
10490
10896
|
} = props;
|
|
@@ -10515,19 +10921,18 @@ const Switch = props => {
|
|
|
10515
10921
|
})
|
|
10516
10922
|
});
|
|
10517
10923
|
};
|
|
10518
|
-
const
|
|
10519
|
-
const ariaLabelledby = ariaLabel ? undefined : props['aria-labelledby'];
|
|
10520
|
-
logActionRequiredIf('Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.', !ariaLabel && !ariaLabelledby);
|
|
10924
|
+
const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
|
|
10521
10925
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
10522
10926
|
className: classNames__default.default('np-switch', {
|
|
10523
10927
|
'np-switch--unchecked': !checked,
|
|
10524
10928
|
'np-switch--checked': checked,
|
|
10525
|
-
disabled
|
|
10929
|
+
disabled
|
|
10526
10930
|
}, className),
|
|
10527
10931
|
tabIndex: 0,
|
|
10528
10932
|
role: "switch",
|
|
10529
10933
|
"aria-checked": checked,
|
|
10530
10934
|
"aria-label": ariaLabel,
|
|
10935
|
+
...inputAttributes,
|
|
10531
10936
|
"aria-labelledby": ariaLabelledby,
|
|
10532
10937
|
id: id,
|
|
10533
10938
|
"aria-disabled": disabled,
|
|
@@ -14390,11 +14795,12 @@ exports.Alert = Alert;
|
|
|
14390
14795
|
exports.Avatar = Avatar;
|
|
14391
14796
|
exports.AvatarWrapper = AvatarWrapper;
|
|
14392
14797
|
exports.Badge = Badge;
|
|
14393
|
-
exports.BaseCard = Card;
|
|
14798
|
+
exports.BaseCard = Card$2;
|
|
14394
14799
|
exports.Body = Body;
|
|
14395
14800
|
exports.BottomSheet = BottomSheet$1;
|
|
14396
14801
|
exports.Button = Button;
|
|
14397
|
-
exports.Card = Card$
|
|
14802
|
+
exports.Card = Card$1;
|
|
14803
|
+
exports.Carousel = Carousel;
|
|
14398
14804
|
exports.Checkbox = Checkbox;
|
|
14399
14805
|
exports.CheckboxButton = CheckboxButton$1;
|
|
14400
14806
|
exports.CheckboxOption = CheckboxOption;
|
|
@@ -14406,7 +14812,7 @@ exports.CriticalCommsBanner = CriticalCommsBanner;
|
|
|
14406
14812
|
exports.DEFAULT_LANG = DEFAULT_LANG;
|
|
14407
14813
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
14408
14814
|
exports.DateInput = DateInput;
|
|
14409
|
-
exports.DateLookup = DateLookup;
|
|
14815
|
+
exports.DateLookup = DateLookup$1;
|
|
14410
14816
|
exports.Decision = Decision;
|
|
14411
14817
|
exports.DefinitionList = DefinitionList$1;
|
|
14412
14818
|
exports.Dimmer = Dimmer$1;
|
|
@@ -14415,6 +14821,7 @@ exports.Display = Display;
|
|
|
14415
14821
|
exports.Drawer = Drawer$1;
|
|
14416
14822
|
exports.DropFade = DropFade;
|
|
14417
14823
|
exports.Emphasis = Emphasis;
|
|
14824
|
+
exports.Field = Field;
|
|
14418
14825
|
exports.FlowNavigation = FlowNavigation;
|
|
14419
14826
|
exports.Header = Header;
|
|
14420
14827
|
exports.Image = Image;
|
|
@@ -14424,6 +14831,7 @@ exports.Input = Input;
|
|
|
14424
14831
|
exports.InputGroup = InputGroup;
|
|
14425
14832
|
exports.InputWithDisplayFormat = InputWithDisplayFormat;
|
|
14426
14833
|
exports.InstructionsList = InstructionsList;
|
|
14834
|
+
exports.Label = Label;
|
|
14427
14835
|
exports.LanguageProvider = LanguageProvider;
|
|
14428
14836
|
exports.Link = Link;
|
|
14429
14837
|
exports.ListItem = ListItem$1;
|