@transferwise/components 0.0.0-experimental-ffd4b26 → 0.0.0-experimental-45ef85b

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
@@ -746,7 +746,7 @@ const StatusIcon = ({
746
746
  const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
747
747
  return /*#__PURE__*/jsxRuntime.jsx("span", {
748
748
  "data-testid": "status-icon",
749
- className: classNames__default.default('status-circle', 'status-circle-' + size, sentiment),
749
+ className: classNames__default.default('status-circle', `status-circle-${size}`, sentiment),
750
750
  children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
751
751
  className: classNames__default.default('status-icon', iconColor)
752
752
  })
@@ -4866,14 +4866,20 @@ function InlineAlert({
4866
4866
  className,
4867
4867
  children
4868
4868
  }) {
4869
- const danger = type === 'negative' || type === 'error';
4870
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
4869
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
4871
4870
  role: "alert",
4872
4871
  id: id,
4873
- className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4874
- children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
4875
- children: children
4876
- })]
4872
+ className: classNames__default.default('alert alert-detach', `alert-${type === exports.Sentiment.NEGATIVE || type === exports.Sentiment.ERROR ? 'danger' : type}`, className),
4873
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4874
+ className: "d-inline-flex",
4875
+ children: [type !== exports.Sentiment.NEUTRAL && type !== exports.Sentiment.PENDING && /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
4876
+ sentiment: type,
4877
+ size: exports.Size.SMALL
4878
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
4879
+ className: "np-text-body-default",
4880
+ children: children
4881
+ })]
4882
+ })
4877
4883
  });
4878
4884
  }
4879
4885
 
@@ -4894,13 +4900,15 @@ const Label = ({
4894
4900
  const Field = ({
4895
4901
  id,
4896
4902
  label,
4897
- hint,
4898
- error,
4903
+ message: propMessage,
4904
+ sentiment: propType = exports.Sentiment.NEUTRAL,
4899
4905
  className,
4900
- children
4906
+ children,
4907
+ ...props
4901
4908
  }) => {
4902
- const hasError = Boolean(error);
4903
- const hasHint = Boolean(hint) && !hasError;
4909
+ const sentiment = props.error ? exports.Sentiment.NEGATIVE : propType;
4910
+ const message = props.error || props.hint || propMessage;
4911
+ const hasError = sentiment === exports.Sentiment.NEGATIVE;
4904
4912
  const labelId = React.useId();
4905
4913
  const fallbackInputId = React.useId();
4906
4914
  const inputId = id !== null ? id ?? fallbackInputId : undefined;
@@ -4910,26 +4918,24 @@ const Field = ({
4910
4918
  children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
4911
4919
  value: inputId,
4912
4920
  children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
4913
- value: hasError || hasHint ? descriptionId : undefined,
4921
+ value: message ? descriptionId : undefined,
4914
4922
  children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
4915
4923
  value: hasError,
4916
4924
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4917
4925
  className: classNames__default.default('form-group d-block', {
4926
+ 'has-success': sentiment === exports.Sentiment.POSITIVE,
4927
+ 'has-warning': sentiment === exports.Sentiment.WARNING,
4918
4928
  'has-error': hasError,
4919
- 'has-info': hasHint
4929
+ 'has-info': sentiment === exports.Sentiment.NEUTRAL
4920
4930
  }, className),
4921
4931
  children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
4922
4932
  id: labelId,
4923
4933
  htmlFor: inputId,
4924
4934
  children: [label, children]
4925
- }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4926
- type: exports.Sentiment.NEUTRAL,
4927
- id: descriptionId,
4928
- children: hint
4929
- }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4930
- type: exports.Sentiment.NEGATIVE,
4935
+ }), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4936
+ type: sentiment,
4931
4937
  id: descriptionId,
4932
- children: error
4938
+ children: message
4933
4939
  })]
4934
4940
  })
4935
4941
  })