@transferwise/components 0.0.0-experimental-ffd4b26 → 0.0.0-experimental-dfa8310

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
@@ -2,7 +2,7 @@ import * as React from 'react';
2
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
- 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-${type === Sentiment.NEGATIVE || type === Sentiment.ERROR ? '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 = Sentiment.NEUTRAL,
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,6 +6236,11 @@ const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWit
6230
6236
  });
6231
6237
  });
6232
6238
 
6239
+ /**
6240
+ * This progressive enhancement uses an experimental API, it might change,
6241
+ * and at the time of authoring is not supported on iOS or mobile Firefox.
6242
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard
6243
+ */
6233
6244
  function useVirtualKeyboard() {
6234
6245
  useEffect(() => {
6235
6246
  /* eslint-disable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */