@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.js +32 -21
- package/build/index.js.map +1 -1
- package/build/index.mjs +33 -22
- package/build/index.mjs.map +1 -1
- package/build/main.css +4 -2
- package/build/styles/main.css +4 -2
- package/build/styles/statusIcon/StatusIcon.css +4 -2
- package/build/types/common/hooks/useVirtualKeyboard.d.ts +5 -0
- package/build/types/common/hooks/useVirtualKeyboard.d.ts.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 +2 -2
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/hooks/useVirtualKeyboard.ts +5 -0
- package/src/field/Field.story.tsx +17 -36
- package/src/field/Field.tests.story.tsx +33 -0
- package/src/field/Field.tsx +23 -13
- package/src/inlineAlert/InlineAlert.story.tsx +13 -5
- package/src/inlineAlert/InlineAlert.tsx +14 -7
- package/src/main.css +4 -2
- package/src/statusIcon/StatusIcon.css +4 -2
- package/src/statusIcon/StatusIcon.less +4 -2
- package/src/statusIcon/StatusIcon.tsx +1 -1
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',
|
|
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
|
-
|
|
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-${
|
|
4874
|
-
children:
|
|
4875
|
-
|
|
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
|
-
|
|
4898
|
-
|
|
4903
|
+
message: propMessage,
|
|
4904
|
+
sentiment: propType = exports.Sentiment.NEUTRAL,
|
|
4899
4905
|
className,
|
|
4900
|
-
children
|
|
4906
|
+
children,
|
|
4907
|
+
...props
|
|
4901
4908
|
}) => {
|
|
4902
|
-
const
|
|
4903
|
-
const
|
|
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:
|
|
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':
|
|
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
|
-
}),
|
|
4926
|
-
type:
|
|
4935
|
+
}), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
4936
|
+
type: sentiment,
|
|
4927
4937
|
id: descriptionId,
|
|
4928
|
-
children:
|
|
4929
|
-
}), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
4930
|
-
type: exports.Sentiment.NEGATIVE,
|
|
4931
|
-
id: descriptionId,
|
|
4932
|
-
children: error
|
|
4938
|
+
children: message
|
|
4933
4939
|
})]
|
|
4934
4940
|
})
|
|
4935
4941
|
})
|
|
@@ -6259,6 +6265,11 @@ const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function Polymorp
|
|
|
6259
6265
|
});
|
|
6260
6266
|
});
|
|
6261
6267
|
|
|
6268
|
+
/**
|
|
6269
|
+
* This progressive enhancement uses an experimental API, it might change,
|
|
6270
|
+
* and at the time of authoring is not supported on iOS or mobile Firefox.
|
|
6271
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard
|
|
6272
|
+
*/
|
|
6262
6273
|
function useVirtualKeyboard() {
|
|
6263
6274
|
React.useEffect(() => {
|
|
6264
6275
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
|