@transferwise/components 0.0.0-experimental-1d9df7f → 0.0.0-experimental-a44fd6f
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 +17 -1
- package/build/index.js.map +1 -1
- package/build/index.mjs +17 -1
- package/build/index.mjs.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 +3 -3
- package/src/inlineAlert/InlineAlert.tsx +23 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { Sentiment } from '../common';
|
|
3
3
|
export interface InlineAlertProps {
|
|
4
4
|
id?: string;
|
|
@@ -6,5 +6,5 @@ export interface InlineAlertProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
|
-
export default function InlineAlert({ id, type, className, children, }: InlineAlertProps):
|
|
9
|
+
export default function InlineAlert({ id, type, className, children, }: InlineAlertProps): React.JSX.Element;
|
|
10
10
|
//# sourceMappingURL=InlineAlert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../src/inlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../src/inlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAQ,MAAM,WAAW,CAAC;AAG5C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,EAAE,EACF,IAAgB,EAChB,SAAS,EACT,QAAQ,GACT,EAAE,gBAAgB,qBAoDlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-a44fd6f",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -93,12 +93,12 @@
|
|
|
93
93
|
"rollup": "^4.17.2",
|
|
94
94
|
"storybook": "^8.1.10",
|
|
95
95
|
"@transferwise/less-config": "3.1.0",
|
|
96
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
96
|
+
"@transferwise/neptune-css": "0.0.0-experimental-a44fd6f",
|
|
97
97
|
"@wise/components-theming": "1.3.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"@transferwise/icons": "^3.7.0",
|
|
101
|
-
"@transferwise/neptune-css": "0.0.0-experimental-
|
|
101
|
+
"@transferwise/neptune-css": "0.0.0-experimental-a44fd6f",
|
|
102
102
|
"@wise/art": "^2.7.0",
|
|
103
103
|
"@wise/components-theming": "^1.0.0",
|
|
104
104
|
"react": ">=18",
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
CrossCircleFill as CrossCircleIcon,
|
|
4
4
|
} from '@transferwise/icons';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { ReactNode } from 'react';
|
|
6
|
+
import React, { ReactNode } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Sentiment, Size } from '../common';
|
|
9
9
|
import StatusIcon from '../statusIcon';
|
|
@@ -37,6 +37,26 @@ export default function InlineAlert({
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const hasTextChildren = (content: ReactNode) => {
|
|
41
|
+
let label = '';
|
|
42
|
+
|
|
43
|
+
const fillLabel = (childrenNodes: ReactNode) => {
|
|
44
|
+
React.Children.map(childrenNodes, (child: ReactNode) => {
|
|
45
|
+
if (typeof child === 'string') {
|
|
46
|
+
label += child;
|
|
47
|
+
}
|
|
48
|
+
if (typeof child === 'object' && React.isValidElement(child)) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
50
|
+
fillLabel(child?.props?.children as ReactNode);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
fillLabel(content);
|
|
56
|
+
|
|
57
|
+
return !!label.length;
|
|
58
|
+
};
|
|
59
|
+
|
|
40
60
|
return (
|
|
41
61
|
<div
|
|
42
62
|
role="alert"
|
|
@@ -47,7 +67,8 @@ export default function InlineAlert({
|
|
|
47
67
|
className,
|
|
48
68
|
)}
|
|
49
69
|
>
|
|
50
|
-
{
|
|
70
|
+
{/* We should show the status icon only if we have some text to show */}
|
|
71
|
+
{hasTextChildren(children) && getStatusIcon(type as Sentiment)}
|
|
51
72
|
<div>{children}</div>
|
|
52
73
|
</div>
|
|
53
74
|
);
|