@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 +27 -21
- package/build/index.js.map +1 -1
- package/build/index.mjs +28 -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/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/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.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,
|
|
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',
|
|
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
|
-
|
|
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-${
|
|
4845
|
-
children:
|
|
4846
|
-
|
|
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
|
-
|
|
4869
|
-
|
|
4874
|
+
message: propMessage,
|
|
4875
|
+
sentiment: propType = Sentiment.NEUTRAL,
|
|
4870
4876
|
className,
|
|
4871
|
-
children
|
|
4877
|
+
children,
|
|
4878
|
+
...props
|
|
4872
4879
|
}) => {
|
|
4873
|
-
const
|
|
4874
|
-
const
|
|
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:
|
|
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':
|
|
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
|
-
}),
|
|
4897
|
-
type:
|
|
4898
|
-
id: descriptionId,
|
|
4899
|
-
children: hint
|
|
4900
|
-
}), hasError && /*#__PURE__*/jsx(InlineAlert, {
|
|
4901
|
-
type: Sentiment.NEGATIVE,
|
|
4906
|
+
}), message && /*#__PURE__*/jsx(InlineAlert, {
|
|
4907
|
+
type: sentiment,
|
|
4902
4908
|
id: descriptionId,
|
|
4903
|
-
children:
|
|
4909
|
+
children: message
|
|
4904
4910
|
})]
|
|
4905
4911
|
})
|
|
4906
4912
|
})
|