@transferwise/components 46.33.0 → 46.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/build/index.js +195 -200
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +189 -194
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  6. package/build/types/alert/Alert.d.ts +3 -2
  7. package/build/types/alert/Alert.d.ts.map +1 -1
  8. package/build/types/common/hooks/useMedia.d.ts.map +1 -1
  9. package/build/types/common/panel/Panel.d.ts.map +1 -1
  10. package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
  11. package/build/types/dimmer/Dimmer.d.ts +1 -11
  12. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  13. package/build/types/drawer/Drawer.d.ts +4 -4
  14. package/build/types/index.d.ts +3 -2
  15. package/build/types/index.d.ts.map +1 -1
  16. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  17. package/build/types/modal/Modal.d.ts.map +1 -1
  18. package/build/types/processIndicator/ProcessIndicator.d.ts +36 -19
  19. package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
  20. package/build/types/processIndicator/index.d.ts +2 -2
  21. package/build/types/processIndicator/index.d.ts.map +1 -1
  22. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  23. package/build/types/select/searchBox/SearchBox.d.ts +1 -1
  24. package/build/types/snackbar/Snackbar.d.ts +0 -1
  25. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  26. package/build/types/test-utils/wait.d.ts +2 -0
  27. package/build/types/test-utils/wait.d.ts.map +1 -0
  28. package/build/types/tooltip/Tooltip.d.ts +1 -1
  29. package/build/types/tooltip/Tooltip.d.ts.map +1 -1
  30. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  31. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  32. package/package.json +10 -14
  33. package/src/accordion/AccordionItem/AccordionItem.tsx +2 -4
  34. package/src/alert/Alert.spec.tsx +12 -0
  35. package/src/alert/Alert.story.tsx +11 -1
  36. package/src/alert/Alert.tsx +33 -14
  37. package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -3
  38. package/src/button/Button.tsx +1 -1
  39. package/src/common/hooks/useConditionalListener/useConditionalListener.spec.js +1 -1
  40. package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +3 -3
  41. package/src/common/hooks/useMedia.spec.ts +1 -1
  42. package/src/common/hooks/useMedia.ts +1 -2
  43. package/src/common/panel/Panel.tsx +90 -92
  44. package/src/common/responsivePanel/ResponsivePanel.tsx +34 -38
  45. package/src/dateLookup/DateLookup.rtl.spec.tsx +181 -5
  46. package/src/dateLookup/DateLookup.testingLibrary.spec.js +171 -124
  47. package/src/drawer/Drawer.js +3 -3
  48. package/src/field/Field.tsx +3 -3
  49. package/src/index.ts +3 -2
  50. package/src/inputs/SelectInput.story.tsx +3 -2
  51. package/src/inputs/SelectInput.tsx +10 -2
  52. package/src/modal/Modal.tsx +1 -2
  53. package/src/processIndicator/ProcessIndicator.rtl.spec.tsx +45 -0
  54. package/src/processIndicator/ProcessIndicator.tsx +110 -0
  55. package/src/promoCard/PromoCard.tsx +1 -2
  56. package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -1
  57. package/src/snackbar/Snackbar.spec.js +8 -2
  58. package/src/snackbar/Snackbar.story.tsx +3 -1
  59. package/src/snackbar/Snackbar.tsx +1 -1
  60. package/src/tabs/Tabs.spec.js +46 -27
  61. package/src/test-utils/index.js +5 -7
  62. package/src/test-utils/jest.setup.js +9 -3
  63. package/src/test-utils/wait.ts +7 -0
  64. package/src/tooltip/Tooltip.tsx +44 -46
  65. package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +2 -2
  66. package/src/upload/Upload.spec.js +34 -13
  67. package/src/uploadInput/UploadInput.spec.tsx +21 -23
  68. package/src/uploadInput/uploadItem/UploadItem.tsx +1 -3
  69. package/src/withDisplayFormat/WithDisplayFormat.spec.js +63 -32
  70. package/src/withDisplayFormat/WithDisplayFormat.tsx +4 -6
  71. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -180
  72. package/src/processIndicator/ProcessIndicator.js +0 -117
  73. package/src/processIndicator/ProcessIndicator.spec.js +0 -101
  74. /package/src/processIndicator/{index.js → index.ts} +0 -0
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var reactId = require('@radix-ui/react-id');
5
4
  var classNames = require('classnames');
6
5
  var jsxRuntime = require('react/jsx-runtime');
7
6
  var icons = require('@transferwise/icons');
@@ -12,7 +11,6 @@ var componentsTheming = require('@wise/components-theming');
12
11
  var reactTransitionGroup = require('react-transition-group');
13
12
  var focus = require('@react-aria/focus');
14
13
  var reactDom = require('react-dom');
15
- var index_js = require('use-sync-external-store/shim/index.js');
16
14
  var neptuneValidation = require('@transferwise/neptune-validation');
17
15
  var formatting = require('@transferwise/formatting');
18
16
  var react$1 = require('@headlessui/react');
@@ -21,6 +19,7 @@ var react = require('@floating-ui/react');
21
19
  var overlays = require('@react-aria/overlays');
22
20
  var reactPopper = require('react-popper');
23
21
  var art = require('@wise/art');
22
+ var reactId = require('@radix-ui/react-id');
24
23
  var clamp$2 = require('lodash.clamp');
25
24
  var debounce = require('lodash.debounce');
26
25
  var requiredIf = require('react-required-if');
@@ -561,7 +560,7 @@ const AccordionItem = ({
561
560
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
562
561
  size: 24
563
562
  }) : null;
564
- const fallbackId = reactId.useId();
563
+ const fallbackId = React.useId();
565
564
  const accordionId = id ?? fallbackId;
566
565
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
567
566
  id: accordionId,
@@ -980,7 +979,7 @@ function Alert({
980
979
  "data-testid": "alert",
981
980
  onTouchStart: () => setShouldFire(true),
982
981
  onTouchEnd: event => {
983
- if (shouldFire && action &&
982
+ if (shouldFire && action?.href &&
984
983
  // Check if current event is triggered from closeButton
985
984
  event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
986
985
  if (action.target === '_blank') {
@@ -1017,13 +1016,8 @@ function Alert({
1017
1016
  children: message
1018
1017
  })
1019
1018
  })]
1020
- }), action && /*#__PURE__*/jsxRuntime.jsx(Link, {
1021
- href: action.href,
1022
- className: "m-t-1",
1023
- "aria-label": action['aria-label'],
1024
- target: action.target,
1025
- type: exports.Typography.LINK_LARGE,
1026
- children: action.text
1019
+ }), action && /*#__PURE__*/jsxRuntime.jsx(Action, {
1020
+ action: action
1027
1021
  })]
1028
1022
  })]
1029
1023
  }), onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
@@ -1050,6 +1044,28 @@ function alertArrowClassNames(arrow) {
1050
1044
  return 'arrow';
1051
1045
  }
1052
1046
  }
1047
+ function Action({
1048
+ action
1049
+ }) {
1050
+ if ('href' in action) {
1051
+ return /*#__PURE__*/jsxRuntime.jsx(Link, {
1052
+ href: action.href,
1053
+ className: "m-t-1",
1054
+ "aria-label": action['aria-label'],
1055
+ target: action.target,
1056
+ type: exports.Typography.LINK_LARGE,
1057
+ onClick: action.onClick,
1058
+ children: action.text
1059
+ });
1060
+ }
1061
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
1062
+ type: "button",
1063
+ "aria-label": action['aria-label'],
1064
+ className: "btn-unstyled np-text-link-large m-t-1",
1065
+ onClick: action.onClick,
1066
+ children: action.text
1067
+ });
1068
+ }
1053
1069
 
1054
1070
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
1055
1071
  exports.AvatarType = void 0;
@@ -1264,68 +1280,67 @@ const radius = {
1264
1280
  };
1265
1281
  const ANIMATION_DURATION_IN_MS = 1500;
1266
1282
  class ProcessIndicator extends React.Component {
1283
+ static defaultProps = {
1284
+ status: 'processing',
1285
+ size: 'sm'
1286
+ };
1287
+ interval = 0;
1288
+ timeout = 0;
1267
1289
  constructor(props) {
1268
1290
  super(props);
1269
1291
  this.state = {
1270
1292
  status: props.status,
1271
1293
  size: props.size
1272
1294
  };
1273
- this.interval = null;
1274
- this.timeout = null;
1275
1295
  }
1276
-
1277
1296
  /**
1278
1297
  * Create interval for animation duration (1500ms)
1279
1298
  * Update state only at the end of every interval
1280
1299
  * (end of animation loop) if props changed before end of animation
1281
1300
  */
1282
1301
  componentDidMount() {
1283
- this.interval = setInterval(() => {
1284
- const statusFromState = this.state.status;
1285
- const sizeFromState = this.state.size;
1286
- const statusFromProps = this.props.status;
1287
- const sizeFromProps = this.props.size;
1288
- if (statusFromState !== statusFromProps) {
1302
+ this.interval = window.setInterval(() => {
1303
+ const {
1304
+ status: targetStatus,
1305
+ size: targetSize,
1306
+ onAnimationCompleted
1307
+ } = this.props;
1308
+ const {
1309
+ status: currentStatus,
1310
+ size: currentSize
1311
+ } = this.state;
1312
+ if (currentStatus !== targetStatus) {
1289
1313
  this.setState({
1290
- status: statusFromProps
1291
- }, this.runCallBack(statusFromProps));
1314
+ status: targetStatus
1315
+ }, () => {
1316
+ if (onAnimationCompleted) {
1317
+ this.timeout = window.setTimeout(() => {
1318
+ onAnimationCompleted(targetStatus);
1319
+ }, ANIMATION_DURATION_IN_MS);
1320
+ }
1321
+ });
1292
1322
  }
1293
- if (sizeFromState !== sizeFromProps) {
1323
+ if (currentSize !== targetSize) {
1294
1324
  this.setState({
1295
- size: sizeFromProps
1325
+ size: targetSize
1296
1326
  });
1297
1327
  }
1298
1328
  }, ANIMATION_DURATION_IN_MS);
1299
1329
  }
1300
-
1301
1330
  /**
1302
1331
  * Only trigger render if comopnent's state got
1303
1332
  * updated from interval callback
1304
- *
1305
- * @param nextProps
1306
- * @param nextState
1307
1333
  */
1308
1334
  shouldComponentUpdate(nextProps, nextState) {
1309
1335
  const isSameStatus = nextProps.status === nextState.status;
1310
1336
  const isSameSize = nextProps.size === nextState.size;
1311
1337
  return isSameStatus && isSameSize;
1312
1338
  }
1313
-
1314
1339
  // Clear interval before destroying component
1315
1340
  componentWillUnmount() {
1316
- clearInterval(this.interval);
1317
- clearTimeout(this.timeout);
1341
+ window.clearInterval(this.interval);
1342
+ window.clearTimeout(this.timeout);
1318
1343
  }
1319
- runCallBack = statusFromProps => {
1320
- const {
1321
- onAnimationCompleted
1322
- } = this.props;
1323
- if (onAnimationCompleted) {
1324
- this.timeouts = setTimeout(() => {
1325
- onAnimationCompleted(statusFromProps);
1326
- }, ANIMATION_DURATION_IN_MS);
1327
- }
1328
- };
1329
1344
  render() {
1330
1345
  const {
1331
1346
  className,
@@ -1356,28 +1371,13 @@ class ProcessIndicator extends React.Component {
1356
1371
  className: "process-circle",
1357
1372
  cx: "50%",
1358
1373
  cy: "50%",
1359
- r: radius[this.state.size],
1374
+ r: radius[size],
1360
1375
  fillOpacity: "0.0"
1361
1376
  })
1362
1377
  })]
1363
1378
  });
1364
1379
  }
1365
1380
  }
1366
- ProcessIndicator.propTypes = {
1367
- status: PropTypes__default.default.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
1368
- size: PropTypes__default.default.oneOf(['xxs', 'xs', 'sm', 'xl']),
1369
- onAnimationCompleted: PropTypes__default.default.func,
1370
- className: PropTypes__default.default.string,
1371
- 'data-testid': PropTypes__default.default.string
1372
- };
1373
- ProcessIndicator.defaultProps = {
1374
- status: exports.Status.PROCESSING,
1375
- size: exports.Size.SMALL,
1376
- onAnimationCompleted: null,
1377
- className: undefined,
1378
- 'data-testid': null
1379
- };
1380
- var ProcessIndicator$1 = ProcessIndicator;
1381
1381
 
1382
1382
  var messages$b = reactIntl.defineMessages({
1383
1383
  loadingAriaLabel: {
@@ -1499,7 +1499,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
1499
1499
  ...props,
1500
1500
  "aria-live": loading ? 'polite' : 'off',
1501
1501
  "aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
1502
- children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
1502
+ children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
1503
1503
  size: processIndicatorSize(),
1504
1504
  className: "btn-loader"
1505
1505
  })]
@@ -1650,9 +1650,8 @@ const useHasIntersected = ({
1650
1650
  return [hasIntersected];
1651
1651
  };
1652
1652
 
1653
- // eslint-disable-next-line import/extensions
1654
1653
  function useMedia(query) {
1655
- return index_js.useSyncExternalStore(onStoreChange => {
1654
+ return React.useSyncExternalStore(onStoreChange => {
1656
1655
  const mediaQueryList = window.matchMedia(query);
1657
1656
  mediaQueryList.addEventListener('change', onStoreChange);
1658
1657
  return () => {
@@ -1830,7 +1829,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
1830
1829
  setChecked(!checked); // Update local state for checkbox
1831
1830
  }
1832
1831
  };
1833
- const fallbackId = reactId.useId();
1832
+ const fallbackId = React.useId();
1834
1833
  const componentId = id || fallbackId;
1835
1834
  // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
1836
1835
  // `'download'` if `download` is truthy. If neither condition is true, set
@@ -2820,7 +2819,7 @@ const Drawer = ({
2820
2819
  const {
2821
2820
  isMobile
2822
2821
  } = useLayout();
2823
- const titleId = reactId.useId();
2822
+ const titleId = React.useId();
2824
2823
  return /*#__PURE__*/jsxRuntime.jsx(Dimmer$1, {
2825
2824
  open: open,
2826
2825
  onClose: onClose,
@@ -2862,12 +2861,12 @@ Drawer.propTypes = {
2862
2861
  footerContent: PropTypes__default.default.node,
2863
2862
  /** The content to appear in the drawer header. */
2864
2863
  headerTitle: PropTypes__default.default.node,
2865
- /** The action to perform on close click. */
2866
- onClose: PropTypes__default.default.func,
2867
2864
  /** The status of Drawer either open or not. */
2868
2865
  open: PropTypes__default.default.bool,
2869
2866
  /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
2870
- position: PropTypes__default.default.oneOf(['left', 'right', 'bottom'])
2867
+ position: PropTypes__default.default.oneOf(['left', 'right', 'bottom']),
2868
+ /** The action to perform on close click. */
2869
+ onClose: PropTypes__default.default.func
2871
2870
  };
2872
2871
  Drawer.defaultProps = {
2873
2872
  children: null,
@@ -3542,7 +3541,7 @@ const fallbackPlacements = {
3542
3541
  [exports.Position.LEFT]: [exports.Position.RIGHT, exports.Position.TOP, exports.Position.BOTTOM],
3543
3542
  [exports.Position.RIGHT]: [exports.Position.LEFT, exports.Position.TOP, exports.Position.BOTTOM]
3544
3543
  };
3545
- const Panel = /*#__PURE__*/React.forwardRef(({
3544
+ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
3546
3545
  arrow = false,
3547
3546
  flip = true,
3548
3547
  altAxis = false,
@@ -3553,7 +3552,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3553
3552
  anchorRef,
3554
3553
  anchorWidth = false,
3555
3554
  ...rest
3556
- }, reference) => {
3555
+ }, reference) {
3557
3556
  const [arrowElement, setArrowElement] = React.useState(null);
3558
3557
  const [popperElement, setPopperElement] = React.useState(null);
3559
3558
  const modifiers = [];
@@ -3631,7 +3630,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3631
3630
  ...attributes.popper,
3632
3631
  className: classNames__default.default('np-panel', {
3633
3632
  'np-panel--open': open
3634
- }, rest['className']),
3633
+ }, rest.className),
3635
3634
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
3636
3635
  ref: reference
3637
3636
  /* eslint-disable-next-line react/forbid-dom-props */,
@@ -3650,7 +3649,7 @@ const Panel = /*#__PURE__*/React.forwardRef(({
3650
3649
  });
3651
3650
  var Panel$1 = Panel;
3652
3651
 
3653
- const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
3652
+ const ResponsivePanel = /*#__PURE__*/React.forwardRef(function ResponsivePanel({
3654
3653
  anchorRef,
3655
3654
  arrow = false,
3656
3655
  flip = true,
@@ -3659,7 +3658,7 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
3659
3658
  onClose,
3660
3659
  open = false,
3661
3660
  position = exports.Position.BOTTOM
3662
- }, reference) => {
3661
+ }, reference) {
3663
3662
  const {
3664
3663
  isMobile
3665
3664
  } = useLayout();
@@ -4998,6 +4997,84 @@ const Emphasis = ({
4998
4997
  }) : null;
4999
4998
  };
5000
4999
 
5000
+ function InlineAlert({
5001
+ id,
5002
+ type = 'neutral',
5003
+ className,
5004
+ children
5005
+ }) {
5006
+ const danger = type === 'negative' || type === 'error';
5007
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
5008
+ role: "alert",
5009
+ id: id,
5010
+ className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
5011
+ children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
5012
+ children: children
5013
+ })]
5014
+ });
5015
+ }
5016
+
5017
+ const Label = ({
5018
+ id,
5019
+ htmlFor,
5020
+ className,
5021
+ children
5022
+ }) => {
5023
+ return /*#__PURE__*/jsxRuntime.jsx("label", {
5024
+ id: id,
5025
+ htmlFor: htmlFor,
5026
+ className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
5027
+ children: children
5028
+ });
5029
+ };
5030
+
5031
+ const Field = ({
5032
+ id,
5033
+ label,
5034
+ hint,
5035
+ error,
5036
+ className,
5037
+ children
5038
+ }) => {
5039
+ const hasError = Boolean(error);
5040
+ const hasHint = Boolean(hint) && !hasError;
5041
+ const labelId = React.useId();
5042
+ const fallbackInputId = React.useId();
5043
+ const inputId = id !== null ? id ?? fallbackInputId : undefined;
5044
+ const descriptionId = React.useId();
5045
+ return /*#__PURE__*/jsxRuntime.jsx(FieldLabelIdContextProvider, {
5046
+ value: labelId,
5047
+ children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
5048
+ value: inputId,
5049
+ children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
5050
+ value: hasError || hasHint ? descriptionId : undefined,
5051
+ children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
5052
+ value: hasError,
5053
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5054
+ className: classNames__default.default('form-group d-block', {
5055
+ 'has-error': hasError,
5056
+ 'has-info': hasHint
5057
+ }, className),
5058
+ children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
5059
+ id: labelId,
5060
+ htmlFor: inputId,
5061
+ children: [label, children]
5062
+ }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5063
+ type: exports.Sentiment.NEUTRAL,
5064
+ id: descriptionId,
5065
+ children: hint
5066
+ }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5067
+ type: exports.Sentiment.NEGATIVE,
5068
+ id: descriptionId,
5069
+ children: error
5070
+ })]
5071
+ })
5072
+ })
5073
+ })
5074
+ })
5075
+ });
5076
+ };
5077
+
5001
5078
  const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
5002
5079
  bottomContent,
5003
5080
  className,
@@ -5204,7 +5281,7 @@ const Tooltip = ({
5204
5281
  const anchorReference = React.useRef(null);
5205
5282
  const [arrowElement, setArrowElement] = React.useState(null);
5206
5283
  const [popperElement, setPopperElement] = React.useState(null);
5207
- const fallbackId = reactId.useId();
5284
+ const fallbackId = React.useId();
5208
5285
  const tooltipId = id ?? fallbackId;
5209
5286
  const modifiers = [];
5210
5287
  modifiers.push({
@@ -5244,42 +5321,40 @@ const Tooltip = ({
5244
5321
  forceUpdate();
5245
5322
  }
5246
5323
  }, [open]);
5247
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5248
- children: /*#__PURE__*/jsxRuntime.jsxs("span", {
5249
- ref: anchorReference,
5250
- className: "tw-tooltip-container",
5251
- onMouseOver: () => setOpen(true),
5252
- onFocus: () => setOpen(true),
5253
- onMouseOut: () => setOpen(false),
5254
- onBlur: () => setOpen(false),
5255
- children: [children ? /*#__PURE__*/React.cloneElement(children, {
5256
- 'aria-describedby': `${tooltipId}-tooltip`
5257
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5258
- // @ts-expect-error
5259
- ref: setPopperElement,
5260
- className: classNames__default.default('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
5261
- // eslint-disable-next-line react/forbid-dom-props
5262
- ,
5263
- style: {
5264
- ...styles.popper
5265
- },
5266
- ...attributes.popper,
5267
- "aria-hidden": !open,
5268
- role: "tooltip",
5269
- id: `${tooltipId}-tooltip`,
5270
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5271
- className: "np-panel__content tooltip-inner",
5272
- children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
5273
- // @ts-expect-error
5274
- ref: setArrowElement,
5275
- className: classNames__default.default('np-panel__arrow')
5276
- // eslint-disable-next-line react/forbid-dom-props
5277
- ,
5278
- style: styles.arrow
5279
- })]
5280
- })
5281
- })]
5282
- })
5324
+ return /*#__PURE__*/jsxRuntime.jsxs("span", {
5325
+ ref: anchorReference,
5326
+ className: "tw-tooltip-container",
5327
+ onMouseOver: () => setOpen(true),
5328
+ onFocus: () => setOpen(true),
5329
+ onMouseOut: () => setOpen(false),
5330
+ onBlur: () => setOpen(false),
5331
+ children: [children ? /*#__PURE__*/React.cloneElement(children, {
5332
+ 'aria-describedby': `${tooltipId}-tooltip`
5333
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5334
+ // @ts-expect-error
5335
+ ref: setPopperElement,
5336
+ className: classNames__default.default('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
5337
+ // eslint-disable-next-line react/forbid-dom-props
5338
+ ,
5339
+ style: {
5340
+ ...styles.popper
5341
+ },
5342
+ ...attributes.popper,
5343
+ "aria-hidden": !open,
5344
+ role: "tooltip",
5345
+ id: `${tooltipId}-tooltip`,
5346
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5347
+ className: "np-panel__content tooltip-inner",
5348
+ children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
5349
+ // @ts-expect-error
5350
+ ref: setArrowElement,
5351
+ className: classNames__default.default('np-panel__arrow')
5352
+ // eslint-disable-next-line react/forbid-dom-props
5353
+ ,
5354
+ style: styles.arrow
5355
+ })]
5356
+ })
5357
+ })]
5283
5358
  });
5284
5359
  };
5285
5360
 
@@ -5477,84 +5552,6 @@ const FlowNavigation = ({
5477
5552
  });
5478
5553
  };
5479
5554
 
5480
- function InlineAlert({
5481
- id,
5482
- type = 'neutral',
5483
- className,
5484
- children
5485
- }) {
5486
- const danger = type === 'negative' || type === 'error';
5487
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
5488
- role: "alert",
5489
- id: id,
5490
- className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
5491
- children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
5492
- children: children
5493
- })]
5494
- });
5495
- }
5496
-
5497
- const Label = ({
5498
- id,
5499
- htmlFor,
5500
- className,
5501
- children
5502
- }) => {
5503
- return /*#__PURE__*/jsxRuntime.jsx("label", {
5504
- id: id,
5505
- htmlFor: htmlFor,
5506
- className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
5507
- children: children
5508
- });
5509
- };
5510
-
5511
- const Field = ({
5512
- id,
5513
- label,
5514
- hint,
5515
- error,
5516
- className,
5517
- children
5518
- }) => {
5519
- const hasError = Boolean(error);
5520
- const hasHint = Boolean(hint) && !hasError;
5521
- const labelId = reactId.useId();
5522
- const fallbackInputId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
5523
- const inputId = id !== null ? id ?? fallbackInputId : undefined;
5524
- const descriptionId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
5525
- return /*#__PURE__*/jsxRuntime.jsx(FieldLabelIdContextProvider, {
5526
- value: labelId,
5527
- children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
5528
- value: inputId,
5529
- children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
5530
- value: hasError || hasHint ? descriptionId : undefined,
5531
- children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
5532
- value: hasError,
5533
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5534
- className: classNames__default.default('form-group d-block', {
5535
- 'has-error': hasError,
5536
- 'has-info': hasHint
5537
- }, className),
5538
- children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
5539
- id: labelId,
5540
- htmlFor: inputId,
5541
- children: [label, children]
5542
- }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5543
- type: exports.Sentiment.NEUTRAL,
5544
- id: descriptionId,
5545
- children: hint
5546
- }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
5547
- type: exports.Sentiment.NEGATIVE,
5548
- id: descriptionId,
5549
- children: error
5550
- })]
5551
- })
5552
- })
5553
- })
5554
- })
5555
- });
5556
- };
5557
-
5558
5555
  const HeaderAction = ({
5559
5556
  action
5560
5557
  }) => {
@@ -5651,7 +5648,7 @@ const Modal = ({
5651
5648
  const isCompact = checkSpecialClasses('compact');
5652
5649
  const noDivider = checkSpecialClasses('no-divider');
5653
5650
  const contentReference = React.useRef(null);
5654
- const titleId = reactId.useId();
5651
+ const titleId = React.useId();
5655
5652
  return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
5656
5653
  open: open,
5657
5654
  headerTitle: title,
@@ -6164,10 +6161,9 @@ class WithDisplayFormat extends React.Component {
6164
6161
  return 'Backspace';
6165
6162
  }
6166
6163
  return triggerEvent.key;
6167
- } else {
6168
- // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
6169
- return 'Paste';
6170
6164
  }
6165
+ // triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
6166
+ return 'Paste';
6171
6167
  };
6172
6168
  resetEvent = () => {
6173
6169
  this.setState({
@@ -6320,11 +6316,10 @@ class WithDisplayFormat extends React.Component {
6320
6316
  selectionEnd,
6321
6317
  pastedLength
6322
6318
  } = this.state;
6319
+ const target = triggerEvent?.currentTarget;
6323
6320
  const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
6324
6321
  setTimeout(() => {
6325
- if (triggerEvent) {
6326
- triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
6327
- }
6322
+ target?.setSelectionRange(cursorPosition, cursorPosition);
6328
6323
  this.setState({
6329
6324
  selectionStart: cursorPosition,
6330
6325
  selectionEnd: cursorPosition
@@ -7004,8 +6999,8 @@ function SelectInputOptions({
7004
6999
  }
7005
7000
  }, []);
7006
7001
  const showStatus = resultsEmpty;
7007
- const statusId = reactId.useId();
7008
- const listboxId = reactId.useId();
7002
+ const statusId = React.useId();
7003
+ const listboxId = React.useId();
7009
7004
  return /*#__PURE__*/jsxRuntime.jsxs(react$1.Listbox.Options, {
7010
7005
  as: SelectInputOptionsContainer,
7011
7006
  static: true,
@@ -7132,7 +7127,7 @@ function SelectInputGroupItemView({
7132
7127
  renderValue,
7133
7128
  needle
7134
7129
  }) {
7135
- const headerId = reactId.useId();
7130
+ const headerId = React.useId();
7136
7131
  return (
7137
7132
  /*#__PURE__*/
7138
7133
  // An empty container may be rendered when no options match `needle`
@@ -12617,7 +12612,7 @@ const ProcessingStep = props => {
12617
12612
  "aria-hidden": isComplete,
12618
12613
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
12619
12614
  className: "droppable-card-content",
12620
- children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
12615
+ children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
12621
12616
  size: exports.Size.Small,
12622
12617
  status: processStatus,
12623
12618
  onAnimationCompleted: status => onAnimationCompleted(status)
@@ -13440,7 +13435,7 @@ const UploadItem = ({
13440
13435
  switch (status) {
13441
13436
  case exports.Status.PROCESSING:
13442
13437
  case exports.Status.PENDING:
13443
- processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
13438
+ processIndicator = /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13444
13439
  size: exports.Size.EXTRA_SMALL,
13445
13440
  status: exports.Status.PROCESSING
13446
13441
  });
@@ -13451,7 +13446,7 @@ const UploadItem = ({
13451
13446
  processIndicator = isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13452
13447
  size: exports.Size.SMALL,
13453
13448
  sentiment: exports.Sentiment.POSITIVE
13454
- }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
13449
+ }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13455
13450
  size: exports.Size.EXTRA_SMALL,
13456
13451
  status: exports.Status.SUCCEEDED
13457
13452
  });
@@ -13466,7 +13461,7 @@ const UploadItem = ({
13466
13461
  children: processIndicator
13467
13462
  }); // Scale down ProcessIndicator to be 20px*20px to match `icons`
13468
13463
  };
13469
- const getErrorMessage = () => typeof error === 'object' && error.message || error || formatMessage(MESSAGES.uploadingFailed);
13464
+ const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13470
13465
  const getDescription = () => {
13471
13466
  if (error || status === exports.Status.FAILED) {
13472
13467
  return /*#__PURE__*/jsxRuntime.jsx(Body, {
@@ -14863,7 +14858,7 @@ exports.Option = Option$2;
14863
14858
  exports.OverlayHeader = OverlayHeader$1;
14864
14859
  exports.PhoneNumberInput = PhoneNumberInput;
14865
14860
  exports.Popover = Popover$1;
14866
- exports.ProcessIndicator = ProcessIndicator$1;
14861
+ exports.ProcessIndicator = ProcessIndicator;
14867
14862
  exports.Progress = Progress;
14868
14863
  exports.ProgressBar = ProgressBar;
14869
14864
  exports.PromoCard = PromoCard$1;