@transferwise/components 46.42.0 → 46.43.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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { forwardRef, useId, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useSyncExternalStore, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
2
+ import React__default, { forwardRef, useId, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useSyncExternalStore, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Fragment as Fragment$1, Children } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { ChevronUp, CrossCircleFill, Cross, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, NavigateAway, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, Bin } from '@transferwise/icons';
@@ -5737,25 +5737,45 @@ function InputGroup({
5737
5737
  className,
5738
5738
  children
5739
5739
  }) {
5740
+ const inputAttributes = useInputAttributes({
5741
+ nonLabelable: true
5742
+ });
5740
5743
  const [paddingStart, setPaddingStart] = useState(inputPaddingInitialState(addonStart));
5741
5744
  const [paddingEnd, setPaddingEnd] = useState(inputPaddingInitialState(addonEnd));
5742
- return /*#__PURE__*/jsx(InputPaddingStartContext.Provider, {
5743
- value: useMemo(() => [paddingStart, setPaddingStart], [paddingStart]),
5744
- children: /*#__PURE__*/jsx(InputPaddingEndContext.Provider, {
5745
- value: useMemo(() => [paddingEnd, setPaddingEnd], [paddingEnd]),
5746
- children: /*#__PURE__*/jsxs("fieldset", {
5747
- disabled: disabled,
5748
- className: classNames(className, 'np-input-group'),
5749
- children: [addonStart != null ? /*#__PURE__*/jsx(InputAddon, {
5750
- placement: "start",
5751
- ...addonStart
5752
- }) : null, children, addonEnd != null ? /*#__PURE__*/jsx(InputAddon, {
5753
- placement: "end",
5754
- ...addonEnd
5755
- }) : null]
5745
+ return (
5746
+ /*#__PURE__*/
5747
+ /* Prevent nested controls from being labeled redundantly */
5748
+ jsx(FieldLabelIdContextProvider, {
5749
+ value: undefined,
5750
+ children: /*#__PURE__*/jsx(InputIdContextProvider, {
5751
+ value: undefined,
5752
+ children: /*#__PURE__*/jsx(InputDescribedByProvider, {
5753
+ value: undefined,
5754
+ children: /*#__PURE__*/jsx(InputInvalidProvider, {
5755
+ value: undefined,
5756
+ children: /*#__PURE__*/jsx(InputPaddingStartContext.Provider, {
5757
+ value: useMemo(() => [paddingStart, setPaddingStart], [paddingStart]),
5758
+ children: /*#__PURE__*/jsx(InputPaddingEndContext.Provider, {
5759
+ value: useMemo(() => [paddingEnd, setPaddingEnd], [paddingEnd]),
5760
+ children: /*#__PURE__*/jsxs("fieldset", {
5761
+ ...inputAttributes,
5762
+ disabled: disabled,
5763
+ className: classNames(className, 'np-input-group'),
5764
+ children: [addonStart != null ? /*#__PURE__*/jsx(InputAddon, {
5765
+ placement: "start",
5766
+ ...addonStart
5767
+ }) : null, children, addonEnd != null ? /*#__PURE__*/jsx(InputAddon, {
5768
+ placement: "end",
5769
+ ...addonEnd
5770
+ }) : null]
5771
+ })
5772
+ })
5773
+ })
5774
+ })
5775
+ })
5756
5776
  })
5757
5777
  })
5758
- });
5778
+ );
5759
5779
  }
5760
5780
  const inputAddonContentWidthAddendByPadding = {
5761
5781
  none: 0,
@@ -6233,6 +6253,26 @@ const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWit
6233
6253
  });
6234
6254
  });
6235
6255
 
6256
+ /**
6257
+ * This progressive enhancement uses an experimental API, it might change,
6258
+ * and at the time of authoring is not supported on iOS or mobile Firefox.
6259
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard
6260
+ */
6261
+ function useVirtualKeyboard() {
6262
+ useEffect(() => {
6263
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6264
+ if ('virtualKeyboard' in navigator) {
6265
+ const virtualKeyboard = navigator.virtualKeyboard;
6266
+ const initialOverlaysContent = virtualKeyboard.overlaysContent;
6267
+ virtualKeyboard.overlaysContent = true;
6268
+ return () => {
6269
+ virtualKeyboard.overlaysContent = initialOverlaysContent;
6270
+ };
6271
+ }
6272
+ /* eslint-enable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6273
+ }, []);
6274
+ }
6275
+
6236
6276
  function PreventScroll() {
6237
6277
  usePreventScroll();
6238
6278
  return null;
@@ -6248,6 +6288,7 @@ function BottomSheet({
6248
6288
  onClose,
6249
6289
  onCloseEnd
6250
6290
  }) {
6291
+ useVirtualKeyboard();
6251
6292
  const {
6252
6293
  refs,
6253
6294
  context
@@ -6287,29 +6328,21 @@ function BottomSheet({
6287
6328
  },
6288
6329
  afterLeave: onCloseEnd,
6289
6330
  children: [/*#__PURE__*/jsx(Transition.Child, {
6290
- enter: "np-bottom-sheet-v2-backdrop-container--enter",
6291
- enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6292
- leave: "np-bottom-sheet-v2-backdrop-container--leave",
6293
- leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6294
- children: /*#__PURE__*/jsx("div", {
6295
- className: "np-bottom-sheet-v2-backdrop"
6296
- })
6331
+ className: "np-bottom-sheet-v2-backdrop",
6332
+ enterFrom: "np-bottom-sheet-v2-backdrop--closed",
6333
+ leaveTo: "np-bottom-sheet-v2-backdrop--closed"
6297
6334
  }), /*#__PURE__*/jsx("div", {
6298
6335
  className: "np-bottom-sheet-v2",
6299
- children: /*#__PURE__*/jsx(Transition.Child, {
6300
- className: "np-bottom-sheet-v2-content",
6301
- enter: "np-bottom-sheet-v2-content--enter",
6302
- enterFrom: "np-bottom-sheet-v2-content--enter-from",
6303
- leave: "np-bottom-sheet-v2-content--leave",
6304
- leaveTo: "np-bottom-sheet-v2-content--leave-to",
6305
- children: /*#__PURE__*/jsx(FocusScope, {
6306
- children: /*#__PURE__*/jsx(FloatingFocusManager, {
6307
- context: context,
6308
- initialFocus: initialFocusRef,
6309
- children: /*#__PURE__*/jsxs("div", {
6310
- // Force inner state invalidation on open
6336
+ children: /*#__PURE__*/jsx(FocusScope, {
6337
+ children: /*#__PURE__*/jsx(FloatingFocusManager, {
6338
+ context: context,
6339
+ initialFocus: initialFocusRef,
6340
+ children: /*#__PURE__*/jsx(Fragment$1, {
6341
+ children: /*#__PURE__*/jsxs(Transition.Child, {
6311
6342
  ref: refs.setFloating,
6312
- className: "np-bottom-sheet-v2-content-inner-container",
6343
+ className: "np-bottom-sheet-v2-content",
6344
+ enterFrom: "np-bottom-sheet-v2-content--closed",
6345
+ leaveTo: "np-bottom-sheet-v2-content--closed",
6313
6346
  ...getFloatingProps(),
6314
6347
  children: [/*#__PURE__*/jsx("div", {
6315
6348
  className: "np-bottom-sheet-v2-header",
@@ -6320,9 +6353,7 @@ function BottomSheet({
6320
6353
  }
6321
6354
  })
6322
6355
  }), /*#__PURE__*/jsxs("div", {
6323
- className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6324
- 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6325
- }),
6356
+ className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', padding === 'md' && 'np-bottom-sheet-v2-content-inner--padding-md'),
6326
6357
  children: [title ? /*#__PURE__*/jsx("h2", {
6327
6358
  className: "np-bottom-sheet-v2-title np-text-title-body",
6328
6359
  children: title
@@ -6331,8 +6362,8 @@ function BottomSheet({
6331
6362
  children: children
6332
6363
  })]
6333
6364
  })]
6334
- }, floatingKey)
6335
- })
6365
+ })
6366
+ }, floatingKey)
6336
6367
  })
6337
6368
  })
6338
6369
  })]
@@ -6609,6 +6640,7 @@ function SelectInput({
6609
6640
  disabled,
6610
6641
  size = 'md',
6611
6642
  className,
6643
+ UNSAFE_triggerButtonProps,
6612
6644
  onFilterChange = noop,
6613
6645
  onChange,
6614
6646
  onClose,
@@ -6677,6 +6709,7 @@ function SelectInput({
6677
6709
  triggerRef.current = node;
6678
6710
  },
6679
6711
  ...inputAttributes,
6712
+ ...UNSAFE_triggerButtonProps,
6680
6713
  id,
6681
6714
  ...mergeProps({
6682
6715
  onClick: () => {