@transferwise/components 0.0.0-experimental-94569f6 → 0.0.0-experimental-5769182

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,8 +1,8 @@
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, Fragment as Fragment$1, Children } 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';
3
3
  import classNames from 'classnames';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { ChevronUp, CrossCircleFill, Cross, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, NavigateAway, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, AlertCircle, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, Bin } from '@transferwise/icons';
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';
6
6
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
7
7
  import commonmark from 'commonmark';
8
8
  import { useTheme, ThemeProvider } from '@wise/components-theming';
@@ -717,7 +717,7 @@ const StatusIcon = ({
717
717
  const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
718
718
  return /*#__PURE__*/jsx("span", {
719
719
  "data-testid": "status-icon",
720
- className: classNames('status-circle', 'status-circle-' + size, sentiment),
720
+ className: classNames('status-circle', `status-circle-${size}`, sentiment),
721
721
  children: /*#__PURE__*/jsx(Icon, {
722
722
  className: classNames('status-icon', iconColor)
723
723
  })
@@ -4837,14 +4837,20 @@ function InlineAlert({
4837
4837
  className,
4838
4838
  children
4839
4839
  }) {
4840
- const danger = type === 'negative' || type === 'error';
4841
- return /*#__PURE__*/jsxs("div", {
4840
+ return /*#__PURE__*/jsx("div", {
4842
4841
  role: "alert",
4843
4842
  id: id,
4844
- className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4845
- children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
4846
- children: children
4847
- })]
4843
+ className: classNames('alert alert-detach', `alert-${[Sentiment.NEGATIVE, Sentiment.ERROR].includes(type) ? 'danger' : type}`, className),
4844
+ children: /*#__PURE__*/jsxs("div", {
4845
+ className: "d-inline-flex",
4846
+ children: [type !== Sentiment.NEUTRAL && type !== Sentiment.PENDING && /*#__PURE__*/jsx(StatusIcon, {
4847
+ sentiment: type,
4848
+ size: Size.SMALL
4849
+ }), /*#__PURE__*/jsx("div", {
4850
+ className: "np-text-body-default",
4851
+ children: children
4852
+ })]
4853
+ })
4848
4854
  });
4849
4855
  }
4850
4856
 
@@ -4865,13 +4871,15 @@ const Label = ({
4865
4871
  const Field = ({
4866
4872
  id,
4867
4873
  label,
4868
- hint,
4869
- error,
4874
+ message: propMessage,
4875
+ sentiment: propType,
4870
4876
  className,
4871
- children
4877
+ children,
4878
+ ...props
4872
4879
  }) => {
4873
- const hasError = Boolean(error);
4874
- const hasHint = Boolean(hint) && !hasError;
4880
+ const sentiment = props.error ? Sentiment.NEGATIVE : propType;
4881
+ const message = props.error || props.hint || propMessage;
4882
+ const hasError = sentiment === Sentiment.NEGATIVE;
4875
4883
  const labelId = useId();
4876
4884
  const fallbackInputId = useId();
4877
4885
  const inputId = id !== null ? id ?? fallbackInputId : undefined;
@@ -4881,26 +4889,24 @@ const Field = ({
4881
4889
  children: /*#__PURE__*/jsx(InputIdContextProvider, {
4882
4890
  value: inputId,
4883
4891
  children: /*#__PURE__*/jsx(InputDescribedByProvider, {
4884
- value: hasError || hasHint ? descriptionId : undefined,
4892
+ value: message ? descriptionId : undefined,
4885
4893
  children: /*#__PURE__*/jsx(InputInvalidProvider, {
4886
4894
  value: hasError,
4887
4895
  children: /*#__PURE__*/jsxs("div", {
4888
4896
  className: classNames('form-group d-block', {
4897
+ 'has-success': sentiment === Sentiment.POSITIVE,
4898
+ 'has-warning': sentiment === Sentiment.WARNING,
4889
4899
  'has-error': hasError,
4890
- 'has-info': hasHint
4900
+ 'has-info': sentiment === Sentiment.NEUTRAL
4891
4901
  }, className),
4892
4902
  children: [/*#__PURE__*/jsxs(Label, {
4893
4903
  id: labelId,
4894
4904
  htmlFor: inputId,
4895
4905
  children: [label, children]
4896
- }), hasHint && /*#__PURE__*/jsx(InlineAlert, {
4897
- type: Sentiment.NEUTRAL,
4906
+ }), message && /*#__PURE__*/jsx(InlineAlert, {
4907
+ type: sentiment,
4898
4908
  id: descriptionId,
4899
- children: hint
4900
- }), hasError && /*#__PURE__*/jsx(InlineAlert, {
4901
- type: Sentiment.NEGATIVE,
4902
- id: descriptionId,
4903
- children: error
4909
+ children: message
4904
4910
  })]
4905
4911
  })
4906
4912
  })
@@ -6230,21 +6236,6 @@ const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWit
6230
6236
  });
6231
6237
  });
6232
6238
 
6233
- function useVirtualKeyboard() {
6234
- useEffect(() => {
6235
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6236
- if ('virtualKeyboard' in navigator) {
6237
- navigator.virtualKeyboard.overlaysContent = true;
6238
- }
6239
- return () => {
6240
- if ('virtualKeyboard' in navigator) {
6241
- navigator.virtualKeyboard.overlaysContent = false;
6242
- }
6243
- };
6244
- /* eslint-enable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6245
- }, []);
6246
- }
6247
-
6248
6239
  function PreventScroll() {
6249
6240
  usePreventScroll();
6250
6241
  return null;
@@ -6260,7 +6251,6 @@ function BottomSheet({
6260
6251
  onClose,
6261
6252
  onCloseEnd
6262
6253
  }) {
6263
- useVirtualKeyboard();
6264
6254
  const {
6265
6255
  refs,
6266
6256
  context
@@ -6300,21 +6290,29 @@ function BottomSheet({
6300
6290
  },
6301
6291
  afterLeave: onCloseEnd,
6302
6292
  children: [/*#__PURE__*/jsx(Transition.Child, {
6303
- className: "np-bottom-sheet-v2-backdrop",
6304
- enterFrom: "np-bottom-sheet-v2-backdrop--closed",
6305
- leaveTo: "np-bottom-sheet-v2-backdrop--closed"
6293
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6294
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6295
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6296
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6297
+ children: /*#__PURE__*/jsx("div", {
6298
+ className: "np-bottom-sheet-v2-backdrop"
6299
+ })
6306
6300
  }), /*#__PURE__*/jsx("div", {
6307
6301
  className: "np-bottom-sheet-v2",
6308
- children: /*#__PURE__*/jsx(FocusScope, {
6309
- children: /*#__PURE__*/jsx(FloatingFocusManager, {
6310
- context: context,
6311
- initialFocus: initialFocusRef,
6312
- children: /*#__PURE__*/jsx(Fragment$1, {
6313
- children: /*#__PURE__*/jsxs(Transition.Child, {
6302
+ children: /*#__PURE__*/jsx(Transition.Child, {
6303
+ className: "np-bottom-sheet-v2-content",
6304
+ enter: "np-bottom-sheet-v2-content--enter",
6305
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6306
+ leave: "np-bottom-sheet-v2-content--leave",
6307
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6308
+ children: /*#__PURE__*/jsx(FocusScope, {
6309
+ children: /*#__PURE__*/jsx(FloatingFocusManager, {
6310
+ context: context,
6311
+ initialFocus: initialFocusRef,
6312
+ children: /*#__PURE__*/jsxs("div", {
6313
+ // Force inner state invalidation on open
6314
6314
  ref: refs.setFloating,
6315
- className: "np-bottom-sheet-v2-content",
6316
- enterFrom: "np-bottom-sheet-v2-content--closed",
6317
- leaveTo: "np-bottom-sheet-v2-content--closed",
6315
+ className: "np-bottom-sheet-v2-content-inner-container",
6318
6316
  ...getFloatingProps(),
6319
6317
  children: [/*#__PURE__*/jsx("div", {
6320
6318
  className: "np-bottom-sheet-v2-header",
@@ -6325,7 +6323,9 @@ function BottomSheet({
6325
6323
  }
6326
6324
  })
6327
6325
  }), /*#__PURE__*/jsxs("div", {
6328
- className: classNames('np-bottom-sheet-v2-content-inner', padding === 'md' && 'np-bottom-sheet-v2-content-inner--padding-md'),
6326
+ className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6327
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6328
+ }),
6329
6329
  children: [title ? /*#__PURE__*/jsx("h2", {
6330
6330
  className: "np-bottom-sheet-v2-title np-text-title-body",
6331
6331
  children: title
@@ -6334,8 +6334,8 @@ function BottomSheet({
6334
6334
  children: children
6335
6335
  })]
6336
6336
  })]
6337
- })
6338
- }, floatingKey)
6337
+ }, floatingKey)
6338
+ })
6339
6339
  })
6340
6340
  })
6341
6341
  })]