@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 +35 -18
- package/build/index.js.map +1 -1
- package/build/index.mjs +36 -19
- package/build/index.mjs.map +1 -1
- package/build/types/field/Field.d.ts +6 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/field/Field.story.tsx +20 -6
- package/src/field/Field.tsx +23 -13
- package/src/inlineAlert/InlineAlert.story.tsx +8 -4
- package/src/inlineAlert/InlineAlert.tsx +28 -5
- package/src/label/Label.tsx +1 -1
package/build/index.js
CHANGED
|
@@ -4878,12 +4878,29 @@ function InlineAlert({
|
|
|
4878
4878
|
className,
|
|
4879
4879
|
children
|
|
4880
4880
|
}) {
|
|
4881
|
-
const
|
|
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-${
|
|
4886
|
-
children: [
|
|
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-
|
|
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
|
-
|
|
4910
|
-
|
|
4926
|
+
message: propMessage,
|
|
4927
|
+
type: propType,
|
|
4911
4928
|
className,
|
|
4912
|
-
children
|
|
4929
|
+
children,
|
|
4930
|
+
...props
|
|
4913
4931
|
}) => {
|
|
4914
|
-
const
|
|
4915
|
-
const
|
|
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:
|
|
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':
|
|
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
|
-
}),
|
|
4938
|
-
type:
|
|
4958
|
+
}), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
4959
|
+
type: type,
|
|
4939
4960
|
id: descriptionId,
|
|
4940
|
-
children:
|
|
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
|
})
|