@transferwise/components 0.0.0-experimental-24e63f3 → 0.0.0-experimental-1d9df7f

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.js CHANGED
@@ -4878,12 +4878,29 @@ function InlineAlert({
4878
4878
  className,
4879
4879
  children
4880
4880
  }) {
4881
- const danger = type === 'negative' || type === 'error';
4881
+ const getStatusIcon = sentiment => {
4882
+ // TODO: When `Sentiment.SUCCESS` and `Sentiment.ERROR` will be completely removed from the codebase, we should rewrite this component to StatusIcon using only
4883
+ switch (sentiment) {
4884
+ case exports.Sentiment.POSITIVE:
4885
+ case exports.Sentiment.SUCCESS:
4886
+ return /*#__PURE__*/jsxRuntime.jsx(icons.CheckCircleFill, {});
4887
+ case exports.Sentiment.WARNING:
4888
+ return /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
4889
+ sentiment: sentiment,
4890
+ size: exports.Size.SMALL
4891
+ });
4892
+ case exports.Sentiment.NEGATIVE:
4893
+ case exports.Sentiment.ERROR:
4894
+ return /*#__PURE__*/jsxRuntime.jsx(icons.CrossCircleFill, {});
4895
+ default:
4896
+ return null;
4897
+ }
4898
+ };
4882
4899
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
4883
4900
  role: "alert",
4884
4901
  id: id,
4885
- className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4886
- children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
4902
+ className: classNames__default.default('alert alert-detach', `alert-${[exports.Sentiment.NEGATIVE, exports.Sentiment.ERROR].includes(type) ? 'danger' : type}`, className),
4903
+ children: [getStatusIcon(type), /*#__PURE__*/jsxRuntime.jsx("div", {
4887
4904
  children: children
4888
4905
  })]
4889
4906
  });
@@ -4898,7 +4915,7 @@ const Label = ({
4898
4915
  return /*#__PURE__*/jsxRuntime.jsx("label", {
4899
4916
  id: id,
4900
4917
  htmlFor: htmlFor,
4901
- className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
4918
+ className: classNames__default.default('control-label d-flex flex-column gap-y-xs m-b-0', className),
4902
4919
  children: children
4903
4920
  });
4904
4921
  };
@@ -4906,13 +4923,15 @@ const Label = ({
4906
4923
  const Field = ({
4907
4924
  id,
4908
4925
  label,
4909
- hint,
4910
- error,
4926
+ message: propMessage,
4927
+ type: propType,
4911
4928
  className,
4912
- children
4929
+ children,
4930
+ ...props
4913
4931
  }) => {
4914
- const hasError = Boolean(error);
4915
- const hasHint = Boolean(hint) && !hasError;
4932
+ const type = props.error ? exports.Sentiment.NEGATIVE : propType;
4933
+ const message = props.error || props.hint || propMessage;
4934
+ const hasError = type === exports.Sentiment.NEGATIVE;
4916
4935
  const labelId = React.useId();
4917
4936
  const fallbackInputId = React.useId();
4918
4937
  const inputId = id !== null ? id ?? fallbackInputId : undefined;
@@ -4922,26 +4941,24 @@ const Field = ({
4922
4941
  children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
4923
4942
  value: inputId,
4924
4943
  children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
4925
- value: hasError || hasHint ? descriptionId : undefined,
4944
+ value: message ? descriptionId : undefined,
4926
4945
  children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
4927
4946
  value: hasError,
4928
4947
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4929
4948
  className: classNames__default.default('form-group d-block', {
4949
+ 'has-success': type === exports.Sentiment.POSITIVE,
4950
+ 'has-warning': type === exports.Sentiment.WARNING,
4930
4951
  'has-error': hasError,
4931
- 'has-info': hasHint
4952
+ 'has-info': type === exports.Sentiment.NEUTRAL
4932
4953
  }, className),
4933
4954
  children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
4934
4955
  id: labelId,
4935
4956
  htmlFor: inputId,
4936
4957
  children: [label, children]
4937
- }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4938
- type: exports.Sentiment.NEUTRAL,
4958
+ }), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4959
+ type: type,
4939
4960
  id: descriptionId,
4940
- children: hint
4941
- }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4942
- type: exports.Sentiment.NEGATIVE,
4943
- id: descriptionId,
4944
- children: error
4961
+ children: message
4945
4962
  })]
4946
4963
  })
4947
4964
  })