@transferwise/components 45.17.1 → 45.18.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 (48) hide show
  1. package/build/index.esm.js +339 -293
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +339 -292
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/inputs/SelectInput.css +1 -1
  7. package/build/styles/instructionsList/InstructionsList.css +1 -1
  8. package/build/styles/main.css +1 -1
  9. package/build/styles/stepper/Stepper.css +1 -1
  10. package/build/styles/tooltip/Tooltip.css +1 -1
  11. package/build/types/button/Button.d.ts.map +1 -1
  12. package/build/types/common/polymorphicWithOverrides/PolymorphicWithOverrides.d.ts +13 -0
  13. package/build/types/common/polymorphicWithOverrides/PolymorphicWithOverrides.d.ts.map +1 -0
  14. package/build/types/index.d.ts +1 -1
  15. package/build/types/index.d.ts.map +1 -1
  16. package/build/types/inputs/SelectInput.d.ts +16 -6
  17. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  18. package/build/types/instructionsList/InstructionsList.d.ts +10 -3
  19. package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
  20. package/build/types/processIndicator/ProcessIndicator.d.ts +1 -1
  21. package/build/types/tooltip/Tooltip.d.ts +2 -1
  22. package/build/types/tooltip/Tooltip.d.ts.map +1 -1
  23. package/package.json +4 -3
  24. package/src/button/Button.story.tsx +6 -0
  25. package/src/button/Button.tsx +6 -1
  26. package/src/common/polymorphicWithOverrides/PolymorphicWithOverrides.tsx +19 -0
  27. package/src/index.ts +3 -0
  28. package/src/inputs/SelectInput.css +1 -1
  29. package/src/inputs/SelectInput.less +8 -2
  30. package/src/inputs/SelectInput.story.tsx +52 -5
  31. package/src/inputs/SelectInput.tsx +165 -104
  32. package/src/inputs/_Popover.less +1 -1
  33. package/src/instructionsList/InstructionList.story.tsx +39 -0
  34. package/src/instructionsList/InstructionsList.css +1 -1
  35. package/src/instructionsList/InstructionsList.less +3 -15
  36. package/src/instructionsList/InstructionsList.spec.tsx +35 -0
  37. package/src/instructionsList/InstructionsList.tsx +40 -25
  38. package/src/main.css +1 -1
  39. package/src/processIndicator/ProcessIndicator.js +2 -2
  40. package/src/stepper/Stepper.css +1 -1
  41. package/src/stepper/Stepper.less +1 -1
  42. package/src/tooltip/Tooltip.css +1 -1
  43. package/src/tooltip/Tooltip.less +13 -0
  44. package/src/tooltip/Tooltip.spec.tsx +97 -29
  45. package/src/tooltip/Tooltip.tsx +24 -31
  46. package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +31 -0
  47. package/src/instructionsList/InstructionList.story.js +0 -27
  48. package/src/instructionsList/InstructionsList.spec.js +0 -29
package/build/index.js CHANGED
@@ -17,6 +17,7 @@ var mergeRefs = require('react-merge-refs');
17
17
  var neptuneValidation = require('@transferwise/neptune-validation');
18
18
  var reactPopper = require('react-popper');
19
19
  var react$1 = require('@headlessui/react');
20
+ var mergeProps = require('merge-props');
20
21
  var shim = require('use-sync-external-store/shim');
21
22
  var react = require('@floating-ui/react');
22
23
  var overlays = require('@react-aria/overlays');
@@ -54,6 +55,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
54
55
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
55
56
  var throttle__default = /*#__PURE__*/_interopDefault(throttle);
56
57
  var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
58
+ var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
57
59
  var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
58
60
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
59
61
  var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
@@ -2126,6 +2128,129 @@ const BottomSheet$1 = props => {
2126
2128
  };
2127
2129
  var BottomSheet$2 = BottomSheet$1;
2128
2130
 
2131
+ const radius = {
2132
+ xxs: 6,
2133
+ xs: 11,
2134
+ sm: 22,
2135
+ xl: 61
2136
+ };
2137
+ const ANIMATION_DURATION_IN_MS = 1500;
2138
+ class ProcessIndicator extends React.Component {
2139
+ constructor(props) {
2140
+ super(props);
2141
+ this.state = {
2142
+ status: props.status,
2143
+ size: props.size
2144
+ };
2145
+ this.interval = null;
2146
+ this.timeout = null;
2147
+ }
2148
+
2149
+ /**
2150
+ * Create interval for animation duration (1500ms)
2151
+ * Update state only at the end of every interval
2152
+ * (end of animation loop) if props changed before end of animation
2153
+ */
2154
+ componentDidMount() {
2155
+ this.interval = setInterval(() => {
2156
+ const statusFromState = this.state.status;
2157
+ const sizeFromState = this.state.size;
2158
+ const statusFromProps = this.props.status;
2159
+ const sizeFromProps = this.props.size;
2160
+ if (statusFromState !== statusFromProps) {
2161
+ this.setState({
2162
+ status: statusFromProps
2163
+ }, this.runCallBack(statusFromProps));
2164
+ }
2165
+ if (sizeFromState !== sizeFromProps) {
2166
+ this.setState({
2167
+ size: sizeFromProps
2168
+ });
2169
+ }
2170
+ }, ANIMATION_DURATION_IN_MS);
2171
+ }
2172
+
2173
+ /**
2174
+ * Only trigger render if comopnent's state got
2175
+ * updated from interval callback
2176
+ *
2177
+ * @param nextProps
2178
+ * @param nextState
2179
+ */
2180
+ shouldComponentUpdate(nextProps, nextState) {
2181
+ const isSameStatus = nextProps.status === nextState.status;
2182
+ const isSameSize = nextProps.size === nextState.size;
2183
+ return isSameStatus && isSameSize;
2184
+ }
2185
+
2186
+ // Clear interval before destroying component
2187
+ componentWillUnmount() {
2188
+ clearInterval(this.interval);
2189
+ clearTimeout(this.timeout);
2190
+ }
2191
+ runCallBack = statusFromProps => {
2192
+ const {
2193
+ onAnimationCompleted
2194
+ } = this.props;
2195
+ if (onAnimationCompleted) {
2196
+ this.timeouts = setTimeout(() => {
2197
+ onAnimationCompleted(statusFromProps);
2198
+ }, ANIMATION_DURATION_IN_MS);
2199
+ }
2200
+ };
2201
+ render() {
2202
+ const {
2203
+ className,
2204
+ 'data-testid': dataTestId
2205
+ } = this.props;
2206
+ const {
2207
+ size,
2208
+ status
2209
+ } = this.state;
2210
+ const classes = classNames__default.default(`process process-${size}`, className, {
2211
+ [`process-danger`]: status === exports.Status.FAILED,
2212
+ [`process-stopped`]: status === exports.Status.HIDDEN,
2213
+ [`process-success`]: status === exports.Status.SUCCEEDED
2214
+ });
2215
+ return /*#__PURE__*/jsxRuntime.jsxs("span", {
2216
+ className: classes,
2217
+ "data-testid": dataTestId,
2218
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
2219
+ className: "process-icon-container",
2220
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2221
+ className: "process-icon-horizontal"
2222
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
2223
+ className: "process-icon-vertical"
2224
+ })]
2225
+ }), /*#__PURE__*/jsxRuntime.jsx("svg", {
2226
+ xmlns: "http://www.w3.org/2000/svg",
2227
+ children: /*#__PURE__*/jsxRuntime.jsx("circle", {
2228
+ className: "process-circle",
2229
+ cx: "50%",
2230
+ cy: "50%",
2231
+ r: radius[this.state.size],
2232
+ fillOpacity: "0.0"
2233
+ })
2234
+ })]
2235
+ });
2236
+ }
2237
+ }
2238
+ ProcessIndicator.propTypes = {
2239
+ status: PropTypes__default.default.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
2240
+ size: PropTypes__default.default.oneOf(['xxs', 'xs', 'sm', 'xl']),
2241
+ onAnimationCompleted: PropTypes__default.default.func,
2242
+ className: PropTypes__default.default.string,
2243
+ 'data-testid': PropTypes__default.default.string
2244
+ };
2245
+ ProcessIndicator.defaultProps = {
2246
+ status: exports.Status.PROCESSING,
2247
+ size: exports.Size.SMALL,
2248
+ onAnimationCompleted: null,
2249
+ className: undefined,
2250
+ 'data-testid': null
2251
+ };
2252
+ var ProcessIndicator$1 = ProcessIndicator;
2253
+
2129
2254
  var messages$8 = reactIntl.defineMessages({
2130
2255
  loadingAriaLabel: {
2131
2256
  id: "neptune.Button.loadingAriaLabel"
@@ -2220,6 +2345,9 @@ const Button = /*#__PURE__*/React.forwardRef(({
2220
2345
  // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
2221
2346
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2222
2347
  priorityClassMap[newPriority], className);
2348
+ function processIndicatorSize() {
2349
+ return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
2350
+ }
2223
2351
  const Element = component ?? 'button';
2224
2352
  let props;
2225
2353
  if (Element === 'button') {
@@ -2243,10 +2371,9 @@ const Button = /*#__PURE__*/React.forwardRef(({
2243
2371
  ...props,
2244
2372
  "aria-live": loading ? 'polite' : 'off',
2245
2373
  "aria-label": loading ? intl.formatMessage(messages$8.loadingAriaLabel) : undefined,
2246
- children: [children, loading && /*#__PURE__*/jsxRuntime.jsx("span", {
2247
- className: classNames__default.default('btn-loader', {
2248
- 'm-l-2': !block
2249
- })
2374
+ children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator$1, {
2375
+ size: processIndicatorSize(),
2376
+ className: "btn-loader"
2250
2377
  })]
2251
2378
  });
2252
2379
  });
@@ -5394,12 +5521,15 @@ const Tooltip = ({
5394
5521
  position = exports.Position.TOP,
5395
5522
  children = undefined,
5396
5523
  label,
5524
+ id,
5397
5525
  className
5398
5526
  }) => {
5399
5527
  const [open, setOpen] = React.useState(false);
5400
5528
  const anchorReference = React.useRef(null);
5401
5529
  const [arrowElement, setArrowElement] = React.useState(null);
5402
5530
  const [popperElement, setPopperElement] = React.useState(null);
5531
+ const fallbackId = reactId.useId();
5532
+ const tooltipId = id ?? fallbackId;
5403
5533
  const modifiers = [];
5404
5534
  modifiers.push({
5405
5535
  name: 'arrow',
@@ -5438,60 +5568,42 @@ const Tooltip = ({
5438
5568
  forceUpdate();
5439
5569
  }
5440
5570
  }, [open]);
5441
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5442
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
5571
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
5572
+ children: /*#__PURE__*/jsxRuntime.jsxs("span", {
5443
5573
  ref: anchorReference,
5444
- className: "d-inline-block",
5445
- children: children ? /*#__PURE__*/React.cloneElement(children, {
5446
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
5447
- onMouseOver: () => {
5448
- if (children?.props?.onMouseOver) {
5449
- children?.props?.onMouseOver();
5450
- }
5451
- setOpen(true);
5452
- },
5453
- onFocus: () => {
5454
- if (children?.props?.onFocus) {
5455
- children.props.onFocus();
5456
- }
5457
- setOpen(true);
5458
- },
5459
- onMouseOut: () => {
5460
- if (children?.props?.onMouseOver) {
5461
- children.props.onMouseOver();
5462
- }
5463
- setOpen(false);
5574
+ className: "tw-tooltip-container",
5575
+ onMouseOver: () => setOpen(true),
5576
+ onFocus: () => setOpen(true),
5577
+ onMouseOut: () => setOpen(false),
5578
+ onBlur: () => setOpen(false),
5579
+ children: [children ? /*#__PURE__*/React.cloneElement(children, {
5580
+ 'aria-describedby': `${tooltipId}-tooltip`
5581
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5582
+ // @ts-expect-error
5583
+ ref: setPopperElement,
5584
+ className: classNames__default.default('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
5585
+ // eslint-disable-next-line react/forbid-dom-props
5586
+ ,
5587
+ style: {
5588
+ ...styles.popper
5464
5589
  },
5465
- onBlur: () => {
5466
- if (children?.props?.onBlur) {
5467
- children.props.onBlur();
5468
- }
5469
- setOpen(false);
5470
- }
5471
- /* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */
5472
- }) : null
5473
- }), open ? /*#__PURE__*/jsxRuntime.jsx("div", {
5474
- // @ts-expect-error
5475
- ref: setPopperElement,
5476
- className: classNames__default.default('np-tooltip', 'np-panel', 'np-panel--open', 'bg-screen', className)
5477
- // eslint-disable-next-line react/forbid-dom-props
5478
- ,
5479
- style: {
5480
- ...styles.popper
5481
- },
5482
- ...attributes.popper,
5483
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5484
- className: "np-panel__content tooltip-inner",
5485
- children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
5486
- // @ts-expect-error
5487
- ref: setArrowElement,
5488
- className: classNames__default.default('np-panel__arrow')
5489
- // eslint-disable-next-line react/forbid-dom-props
5490
- ,
5491
- style: styles.arrow
5492
- })]
5493
- })
5494
- }) : null]
5590
+ ...attributes.popper,
5591
+ "aria-hidden": !open,
5592
+ role: "tooltip",
5593
+ id: `${tooltipId}-tooltip`,
5594
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5595
+ className: "np-panel__content tooltip-inner",
5596
+ children: [label, /*#__PURE__*/jsxRuntime.jsx("div", {
5597
+ // @ts-expect-error
5598
+ ref: setArrowElement,
5599
+ className: classNames__default.default('np-panel__arrow')
5600
+ // eslint-disable-next-line react/forbid-dom-props
5601
+ ,
5602
+ style: styles.arrow
5603
+ })]
5604
+ })
5605
+ })]
5606
+ })
5495
5607
  });
5496
5608
  };
5497
5609
  var Tooltip$1 = Tooltip;
@@ -6252,6 +6364,20 @@ function useScreenSize(size) {
6252
6364
  return useMedia(`(min-width: ${size}px)`);
6253
6365
  }
6254
6366
 
6367
+ const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function PolymorphicWithOverrides({
6368
+ __overrides: {
6369
+ as: Element,
6370
+ ...restOverrides
6371
+ },
6372
+ ...restProps
6373
+ }, ref) {
6374
+ return /*#__PURE__*/jsxRuntime.jsx(Element, {
6375
+ ref: ref,
6376
+ ...restProps,
6377
+ ...restOverrides
6378
+ });
6379
+ });
6380
+
6255
6381
  function wrapInFragment(value) {
6256
6382
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
6257
6383
  children: value
@@ -6498,7 +6624,8 @@ function inferSearchableStrings(value) {
6498
6624
  return [];
6499
6625
  }
6500
6626
  const SelectInputHasValueContext = /*#__PURE__*/React.createContext(false);
6501
- const SelectInputOptionContentCompactContext = /*#__PURE__*/React.createContext(false);
6627
+ const SelectInputTriggerButtonPropsContext = /*#__PURE__*/React.createContext({});
6628
+ const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
6502
6629
  function dedupeSelectInputOptionItem(item, existingValues) {
6503
6630
  if (existingValues.has(item.value)) {
6504
6631
  return {
@@ -6528,14 +6655,68 @@ function dedupeSelectInputItems(items) {
6528
6655
  return item;
6529
6656
  });
6530
6657
  }
6658
+ const defaultRenderTrigger = ({
6659
+ content,
6660
+ placeholderShown,
6661
+ clear,
6662
+ disabled,
6663
+ className
6664
+ }) => /*#__PURE__*/jsxRuntime.jsx(InputGroup, {
6665
+ addonEnd: {
6666
+ content: /*#__PURE__*/jsxRuntime.jsxs("span", {
6667
+ className: classNames__default.default('np-select-input-addon-container', disabled && 'disabled'),
6668
+ children: [clear != null && !placeholderShown ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6669
+ children: [/*#__PURE__*/jsxRuntime.jsx(SelectInputClearButton, {
6670
+ onClick: event => {
6671
+ event.preventDefault();
6672
+ clear();
6673
+ }
6674
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
6675
+ className: "np-select-input-addon-separator"
6676
+ })]
6677
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
6678
+ className: "np-select-input-addon",
6679
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronDown, {
6680
+ size: 16
6681
+ })
6682
+ })]
6683
+ }),
6684
+ padding: 'sm'
6685
+ },
6686
+ disabled: disabled,
6687
+ className: className,
6688
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButton, {
6689
+ as: ButtonInput,
6690
+ children: placeholderShown ? /*#__PURE__*/jsxRuntime.jsxs("span", {
6691
+ className: "np-select-input-placeholder",
6692
+ children: [" ", content]
6693
+ }) : content
6694
+ })
6695
+ });
6696
+ function SelectInputClearButton({
6697
+ className,
6698
+ onClick
6699
+ }) {
6700
+ const intl = reactIntl.useIntl();
6701
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
6702
+ type: "button",
6703
+ "aria-label": intl.formatMessage(messages$5.ariaLabel),
6704
+ className: classNames__default.default(className, 'np-select-input-addon np-select-input-addon--interactive'),
6705
+ onClick: onClick,
6706
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {
6707
+ size: 16
6708
+ })
6709
+ });
6710
+ }
6531
6711
  function SelectInput({
6532
6712
  name,
6533
6713
  placeholder,
6534
6714
  items,
6535
6715
  defaultValue,
6536
6716
  value: controlledValue,
6537
- renderValue = wrapInFragment,
6538
6717
  compareValues,
6718
+ renderValue = wrapInFragment,
6719
+ renderTrigger = defaultRenderTrigger,
6539
6720
  filterable,
6540
6721
  filterPlaceholder,
6541
6722
  disabled,
@@ -6543,7 +6724,6 @@ function SelectInput({
6543
6724
  onChange,
6544
6725
  onClear
6545
6726
  }) {
6546
- const intl = reactIntl.useIntl();
6547
6727
  const [open, setOpen] = React.useState(false);
6548
6728
  const triggerRef = React.useRef(null);
6549
6729
  const screenSm = useScreenSize(exports.Breakpoint.SMALL);
@@ -6569,87 +6749,75 @@ function SelectInput({
6569
6749
  value
6570
6750
  }) => /*#__PURE__*/jsxRuntime.jsx(SelectInputHasValueContext.Provider, {
6571
6751
  value: value != null,
6572
- children: /*#__PURE__*/jsxRuntime.jsx(InputGroup, {
6573
- addonEnd: {
6574
- content: /*#__PURE__*/jsxRuntime.jsxs("span", {
6575
- className: classNames__default.default('np-select-input-addon-container', uiDisabled && 'disabled'),
6576
- children: [onClear != null && value != null ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6577
- children: [/*#__PURE__*/jsxRuntime.jsx("button", {
6578
- type: "button",
6579
- "aria-label": intl.formatMessage(messages$5.ariaLabel),
6580
- disabled: uiDisabled,
6581
- className: "np-select-input-addon np-select-input-addon--interactive",
6582
- onClick: event => {
6583
- event.preventDefault();
6584
- onClear();
6585
- triggerRef.current?.focus({
6586
- preventScroll: true
6587
- });
6588
- },
6589
- children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {
6590
- size: 16
6591
- })
6592
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
6593
- className: "np-select-input-addon-separator"
6594
- })]
6595
- }) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
6596
- className: "np-select-input-addon",
6597
- children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronDown, {
6598
- size: 16
6599
- })
6600
- })]
6601
- }),
6602
- padding: 'sm'
6603
- },
6604
- className: className,
6605
- children: /*#__PURE__*/jsxRuntime.jsx(OptionsOverlay, {
6606
- open: open,
6607
- renderTrigger: ({
6608
- ref,
6609
- getInteractionProps
6610
- }) => /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox.Button, {
6752
+ children: /*#__PURE__*/jsxRuntime.jsx(OptionsOverlay, {
6753
+ open: open,
6754
+ renderTrigger: ({
6755
+ ref,
6756
+ getInteractionProps
6757
+ }) => /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButtonPropsContext.Provider, {
6758
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
6759
+ value: {
6611
6760
  ref: mergeRefs__default.default([ref, triggerRef]),
6612
- as: SelectInputButton,
6613
- overrides: getInteractionProps(),
6614
- onClick: () => {
6615
- setOpen(prev => !prev);
6616
- },
6617
- children: value != null ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentCompactContext.Provider, {
6761
+ ...mergeProps__default.default({
6762
+ onClick: () => {
6763
+ setOpen(prev => !prev);
6764
+ }
6765
+ }, getInteractionProps())
6766
+ },
6767
+ children: renderTrigger({
6768
+ content: value != null ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
6618
6769
  value: true,
6619
6770
  children: renderValue(value, true)
6620
- }) : /*#__PURE__*/jsxRuntime.jsx("span", {
6621
- className: "np-select-input-placeholder",
6622
- children: placeholder
6623
- })
6624
- }),
6625
- initialFocusRef: controllerRef,
6626
- padding: "none",
6627
- onClose: () => {
6628
- setOpen(false);
6629
- },
6630
- children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
6631
- items: items,
6632
- renderValue: renderValue,
6633
- filterable: filterable,
6634
- filterPlaceholder: filterPlaceholder,
6635
- searchInputRef: searchInputRef,
6636
- listboxRef: listboxRef
6771
+ }) : placeholder,
6772
+ placeholderShown: value == null,
6773
+ clear: onClear != null ? () => {
6774
+ onClear();
6775
+ triggerRef.current?.focus({
6776
+ preventScroll: true
6777
+ });
6778
+ } : undefined,
6779
+ disabled: uiDisabled,
6780
+ className: classNames__default.default(className, 'np-text-body-large')
6637
6781
  })
6782
+ }),
6783
+ initialFocusRef: controllerRef,
6784
+ padding: "none",
6785
+ onClose: () => {
6786
+ setOpen(false);
6787
+ },
6788
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
6789
+ items: items,
6790
+ renderValue: renderValue,
6791
+ filterable: filterable,
6792
+ filterPlaceholder: filterPlaceholder,
6793
+ searchInputRef: searchInputRef,
6794
+ listboxRef: listboxRef
6638
6795
  })
6639
6796
  })
6640
6797
  })
6641
6798
  });
6642
6799
  }
6643
- const SelectInputButton = /*#__PURE__*/React.forwardRef(function SelectInputButton({
6644
- overrides,
6800
+ function SelectInputTriggerButton({
6801
+ as = 'button',
6645
6802
  ...restProps
6646
- }, ref) {
6647
- return /*#__PURE__*/jsxRuntime.jsx(ButtonInput, {
6803
+ }) {
6804
+ const {
6805
+ ref,
6806
+ onClick,
6807
+ ...interactionProps
6808
+ } = React.useContext(SelectInputTriggerButtonPropsContext);
6809
+ return /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox.Button, {
6648
6810
  ref: ref,
6649
- ...restProps,
6650
- ...overrides
6811
+ as: PolymorphicWithOverrides,
6812
+ __overrides: {
6813
+ as,
6814
+ ...interactionProps
6815
+ },
6816
+ ...mergeProps__default.default({
6817
+ onClick
6818
+ }, restProps)
6651
6819
  });
6652
- });
6820
+ }
6653
6821
  const SelectInputOptionsContainer = /*#__PURE__*/React.forwardRef(function SelectInputOptionsContainer({
6654
6822
  'aria-orientation': ariaOrientation,
6655
6823
  'aria-activedescendant': ariaActiveDescendant,
@@ -6778,8 +6946,7 @@ function SelectInputItemView({
6778
6946
  {
6779
6947
  if (needle == null) {
6780
6948
  return /*#__PURE__*/jsxRuntime.jsx("hr", {
6781
- className: "np-select-input-separator-item",
6782
- "aria-hidden": true
6949
+ className: "np-select-input-separator-item"
6783
6950
  });
6784
6951
  }
6785
6952
  break;
@@ -6832,18 +6999,19 @@ function SelectInputOption({
6832
6999
  disabled: disabled,
6833
7000
  className: ({
6834
7001
  active,
7002
+ selected,
6835
7003
  disabled: uiDisabled
6836
- }) => classNames__default.default('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
7004
+ }) => classNames__default.default('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', selected && 'np-select-input-option-container--selected', uiDisabled && 'np-select-input-option-container--disabled'),
6837
7005
  children: ({
6838
7006
  selected
6839
7007
  }) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6840
- children: [cachedParentHasValue ? /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
6841
- size: 16,
6842
- className: classNames__default.default(!selected && 'np-select-input-option-check--not-selected')
6843
- }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
7008
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6844
7009
  className: "np-select-input-option",
6845
7010
  children: children
6846
- })]
7011
+ }), cachedParentHasValue ? /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
7012
+ size: 24,
7013
+ className: classNames__default.default('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
7014
+ }) : null]
6847
7015
  })
6848
7016
  });
6849
7017
  }
@@ -6853,16 +7021,16 @@ function SelectInputOptionContent({
6853
7021
  description,
6854
7022
  icon
6855
7023
  }) {
6856
- const compact = React.useContext(SelectInputOptionContentCompactContext);
7024
+ const withinTrigger = React.useContext(SelectInputOptionContentWithinTriggerContext);
6857
7025
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
6858
7026
  className: "np-select-input-option-content-container np-text-body-large",
6859
7027
  children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
6860
- className: classNames__default.default('np-select-input-option-content-icon', !compact && 'np-select-input-option-content-icon--not-compact'),
7028
+ className: classNames__default.default('np-select-input-option-content-icon', !withinTrigger && 'np-select-input-option-content-icon--not-within-trigger'),
6861
7029
  children: icon
6862
7030
  }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
6863
7031
  className: "np-select-input-option-content-text",
6864
7032
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
6865
- className: classNames__default.default('np-select-input-option-content-text-line-1', compact && 'np-select-input-option-content-text-compact'),
7033
+ className: classNames__default.default('np-select-input-option-content-text-line-1', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
6866
7034
  children: [/*#__PURE__*/jsxRuntime.jsx("h4", {
6867
7035
  className: "d-inline np-text-body-large",
6868
7036
  children: title
@@ -6871,7 +7039,7 @@ function SelectInputOptionContent({
6871
7039
  children: note
6872
7040
  }) : null]
6873
7041
  }), description ? /*#__PURE__*/jsxRuntime.jsx("div", {
6874
- className: classNames__default.default('np-select-input-option-content-text-secondary np-text-body-default', compact && 'np-select-input-option-content-text-compact'),
7042
+ className: classNames__default.default('np-select-input-option-content-text-secondary np-text-body-default', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
6875
7043
  children: description
6876
7044
  }) : null]
6877
7045
  })]
@@ -7321,47 +7489,48 @@ InputWithDisplayFormat.propTypes = {
7321
7489
  };
7322
7490
  var InputWithDisplayFormat$1 = InputWithDisplayFormat;
7323
7491
 
7324
- const InstructionsList = props => {
7325
- const {
7326
- isModern
7327
- } = componentsTheming.useTheme();
7328
- const {
7329
- dos,
7330
- donts
7331
- } = props;
7332
- const DontIcon = isModern ? icons.CrossCircleFill : icons.CrossCircle;
7333
- const DoIcon = isModern ? icons.CheckCircleFill : icons.CheckCircle;
7492
+ const InstructionsList = ({
7493
+ dos,
7494
+ donts
7495
+ }) => {
7334
7496
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
7335
7497
  className: "tw-instructions",
7336
7498
  children: [dos && dos.map((doThis, index) =>
7337
7499
  /*#__PURE__*/
7338
7500
  // eslint-disable-next-line react/no-array-index-key
7339
- jsxRuntime.jsxs("div", {
7340
- className: "instruction",
7341
- children: [/*#__PURE__*/jsxRuntime.jsx(DoIcon, {
7342
- size: 24,
7343
- className: "do"
7344
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
7345
- className: "text-primary",
7346
- type: exports.Typography.BODY_LARGE,
7347
- children: doThis
7348
- })]
7501
+ jsxRuntime.jsx(Instruction, {
7502
+ item: doThis,
7503
+ type: "do"
7349
7504
  }, index)), donts && donts.map((dont, index) =>
7350
7505
  /*#__PURE__*/
7351
7506
  // eslint-disable-next-line react/no-array-index-key
7352
- jsxRuntime.jsxs("div", {
7353
- className: "instruction",
7354
- children: [/*#__PURE__*/jsxRuntime.jsx(DontIcon, {
7355
- size: 24,
7356
- className: "dont"
7357
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
7358
- className: "text-primary",
7359
- type: exports.Typography.BODY_LARGE,
7360
- children: dont
7361
- })]
7507
+ jsxRuntime.jsx(Instruction, {
7508
+ item: dont,
7509
+ type: "dont"
7362
7510
  }, index))]
7363
7511
  });
7364
7512
  };
7513
+ function Instruction({
7514
+ item,
7515
+ type
7516
+ }) {
7517
+ const isInstructionNode = typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;
7518
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
7519
+ className: "instruction",
7520
+ "aria-label": isInstructionNode ? item['aria-label'] : undefined,
7521
+ children: [type === 'do' ? /*#__PURE__*/jsxRuntime.jsx(icons.CheckCircleFill, {
7522
+ size: 24,
7523
+ className: type
7524
+ }) : /*#__PURE__*/jsxRuntime.jsx(icons.CrossCircleFill, {
7525
+ size: 24,
7526
+ className: type
7527
+ }), /*#__PURE__*/jsxRuntime.jsx(Body, {
7528
+ className: "text-primary",
7529
+ type: exports.Typography.BODY_LARGE,
7530
+ children: isInstructionNode ? item.content : item
7531
+ })]
7532
+ });
7533
+ }
7365
7534
  var InstructionsList$1 = InstructionsList;
7366
7535
 
7367
7536
  const Loader = ({
@@ -10228,128 +10397,6 @@ PhoneNumberInput.defaultProps = {
10228
10397
  };
10229
10398
  var PhoneNumberInput$1 = PhoneNumberInput;
10230
10399
 
10231
- const radius = {
10232
- xs: 11,
10233
- sm: 22,
10234
- xl: 61
10235
- };
10236
- const ANIMATION_DURATION_IN_MS = 1500;
10237
- class ProcessIndicator extends React.Component {
10238
- constructor(props) {
10239
- super(props);
10240
- this.state = {
10241
- status: props.status,
10242
- size: props.size
10243
- };
10244
- this.interval = null;
10245
- this.timeout = null;
10246
- }
10247
-
10248
- /**
10249
- * Create interval for animation duration (1500ms)
10250
- * Update state only at the end of every interval
10251
- * (end of animation loop) if props changed before end of animation
10252
- */
10253
- componentDidMount() {
10254
- this.interval = setInterval(() => {
10255
- const statusFromState = this.state.status;
10256
- const sizeFromState = this.state.size;
10257
- const statusFromProps = this.props.status;
10258
- const sizeFromProps = this.props.size;
10259
- if (statusFromState !== statusFromProps) {
10260
- this.setState({
10261
- status: statusFromProps
10262
- }, this.runCallBack(statusFromProps));
10263
- }
10264
- if (sizeFromState !== sizeFromProps) {
10265
- this.setState({
10266
- size: sizeFromProps
10267
- });
10268
- }
10269
- }, ANIMATION_DURATION_IN_MS);
10270
- }
10271
-
10272
- /**
10273
- * Only trigger render if comopnent's state got
10274
- * updated from interval callback
10275
- *
10276
- * @param nextProps
10277
- * @param nextState
10278
- */
10279
- shouldComponentUpdate(nextProps, nextState) {
10280
- const isSameStatus = nextProps.status === nextState.status;
10281
- const isSameSize = nextProps.size === nextState.size;
10282
- return isSameStatus && isSameSize;
10283
- }
10284
-
10285
- // Clear interval before destroying component
10286
- componentWillUnmount() {
10287
- clearInterval(this.interval);
10288
- clearTimeout(this.timeout);
10289
- }
10290
- runCallBack = statusFromProps => {
10291
- const {
10292
- onAnimationCompleted
10293
- } = this.props;
10294
- if (onAnimationCompleted) {
10295
- this.timeouts = setTimeout(() => {
10296
- onAnimationCompleted(statusFromProps);
10297
- }, ANIMATION_DURATION_IN_MS);
10298
- }
10299
- };
10300
- render() {
10301
- const {
10302
- className,
10303
- 'data-testid': dataTestId
10304
- } = this.props;
10305
- const {
10306
- size,
10307
- status
10308
- } = this.state;
10309
- const classes = classNames__default.default(`process process-${size}`, className, {
10310
- [`process-danger`]: status === exports.Status.FAILED,
10311
- [`process-stopped`]: status === exports.Status.HIDDEN,
10312
- [`process-success`]: status === exports.Status.SUCCEEDED
10313
- });
10314
- return /*#__PURE__*/jsxRuntime.jsxs("span", {
10315
- className: classes,
10316
- "data-testid": dataTestId,
10317
- children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
10318
- className: "process-icon-container",
10319
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
10320
- className: "process-icon-horizontal"
10321
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
10322
- className: "process-icon-vertical"
10323
- })]
10324
- }), /*#__PURE__*/jsxRuntime.jsx("svg", {
10325
- xmlns: "http://www.w3.org/2000/svg",
10326
- children: /*#__PURE__*/jsxRuntime.jsx("circle", {
10327
- className: "process-circle",
10328
- cx: "50%",
10329
- cy: "50%",
10330
- r: radius[this.state.size],
10331
- fillOpacity: "0.0"
10332
- })
10333
- })]
10334
- });
10335
- }
10336
- }
10337
- ProcessIndicator.propTypes = {
10338
- status: PropTypes__default.default.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
10339
- size: PropTypes__default.default.oneOf(['xs', 'sm', 'xl']),
10340
- onAnimationCompleted: PropTypes__default.default.func,
10341
- className: PropTypes__default.default.string,
10342
- 'data-testid': PropTypes__default.default.string
10343
- };
10344
- ProcessIndicator.defaultProps = {
10345
- status: exports.Status.PROCESSING,
10346
- size: exports.Size.SMALL,
10347
- onAnimationCompleted: null,
10348
- className: undefined,
10349
- 'data-testid': null
10350
- };
10351
- var ProcessIndicator$1 = ProcessIndicator;
10352
-
10353
10400
  const Progress = ({
10354
10401
  className,
10355
10402
  id,