@particle-network/ui-react 0.5.1-beta.13 → 0.5.1-beta.14
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/dist/components/UXToast/index.d.ts +1 -1
- package/dist/components/UXToast/index.js +8 -2
- package/dist/components/UXTooltip/index.js +4 -12
- package/dist/components/WrapText/index.d.ts +6 -0
- package/dist/components/WrapText/index.js +15 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/typography/Text.js +14 -4
- package/dist/components/typography/Text.type.d.ts +1 -0
- package/package.json +3 -3
|
@@ -12,7 +12,7 @@ export declare const toast: {
|
|
|
12
12
|
error: (message: ReactNode, props?: Partial<ToastProps>) => string | null;
|
|
13
13
|
loading: (message: ReactNode, props?: Partial<ToastProps>) => string | null;
|
|
14
14
|
show: (props?: Partial<ToastProps> & {
|
|
15
|
-
type
|
|
15
|
+
type?: UXToastType;
|
|
16
16
|
}) => string | null;
|
|
17
17
|
closeAll: () => void;
|
|
18
18
|
close: (key: string) => void;
|
|
@@ -5,6 +5,7 @@ import CircleCloseIcon from "@particle-network/icons/web/CircleCloseIcon";
|
|
|
5
5
|
import CloseIcon from "@particle-network/icons/web/CloseIcon";
|
|
6
6
|
import { hasLongWord } from "../../utils/index.js";
|
|
7
7
|
import { UXSpinner } from "../UXSpinner/index.js";
|
|
8
|
+
import { WrapText } from "../WrapText/index.js";
|
|
8
9
|
const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
|
|
9
10
|
disableAnimation: true,
|
|
10
11
|
placement: "top-center",
|
|
@@ -32,7 +33,7 @@ const getIcon = (type)=>{
|
|
|
32
33
|
return null;
|
|
33
34
|
};
|
|
34
35
|
const show = (props)=>{
|
|
35
|
-
const { type, hideCloseButton, icon, variant, classNames, description, ...toastProps } = props ?? {};
|
|
36
|
+
const { type = 'info', hideCloseButton, icon, variant, classNames, title, description, ...toastProps } = props ?? {};
|
|
36
37
|
const { base, description: descriptionClassName, icon: iconClassName, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
|
|
37
38
|
return addToast({
|
|
38
39
|
classNames: {
|
|
@@ -68,7 +69,12 @@ const show = (props)=>{
|
|
|
68
69
|
],
|
|
69
70
|
...restClassNames
|
|
70
71
|
},
|
|
71
|
-
|
|
72
|
+
title: /*#__PURE__*/ jsx(WrapText, {
|
|
73
|
+
children: title
|
|
74
|
+
}),
|
|
75
|
+
description: /*#__PURE__*/ jsx(WrapText, {
|
|
76
|
+
children: description
|
|
77
|
+
}),
|
|
72
78
|
icon: icon ?? getIcon(type),
|
|
73
79
|
hideIcon: !icon && !getIcon(type),
|
|
74
80
|
closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { hasLongWord } from "../../utils/index.js";
|
|
4
|
+
import { WrapText } from "../WrapText/index.js";
|
|
4
5
|
import tooltip_extend from "./tooltip.extend.js";
|
|
5
|
-
const renderContent = (content)=>{
|
|
6
|
-
if (!content) return null;
|
|
7
|
-
if ('string' != typeof content) return content;
|
|
8
|
-
if (!content.includes('\n')) return content;
|
|
9
|
-
return content.split('\n').flatMap((x, i, arr)=>i < arr.length - 1 ? [
|
|
10
|
-
x,
|
|
11
|
-
/*#__PURE__*/ jsx("br", {}, i)
|
|
12
|
-
] : [
|
|
13
|
-
x
|
|
14
|
-
]);
|
|
15
|
-
};
|
|
16
6
|
const UXTooltip = (props)=>{
|
|
17
7
|
const { content, classNames, ...restProps } = props;
|
|
18
8
|
const { content: contentClassName, ...restClassNames } = classNames ?? {};
|
|
19
9
|
return /*#__PURE__*/ jsx(tooltip_extend, {
|
|
20
|
-
content:
|
|
10
|
+
content: /*#__PURE__*/ jsx(WrapText, {
|
|
11
|
+
children: content
|
|
12
|
+
}),
|
|
21
13
|
classNames: {
|
|
22
14
|
content: [
|
|
23
15
|
hasLongWord(content) && 'break-all',
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WarpTextProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare const WrapText: (props: WarpTextProps) => string | number | bigint | true | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | (string | import("react/jsx-runtime").JSX.Element)[] | null;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const WrapText = (props)=>{
|
|
4
|
+
const { children } = props;
|
|
5
|
+
if (!children) return null;
|
|
6
|
+
if ('string' != typeof children) return children;
|
|
7
|
+
if (!children.includes('\n')) return children;
|
|
8
|
+
return children.split('\n').flatMap((x, i, arr)=>i < arr.length - 1 ? [
|
|
9
|
+
x,
|
|
10
|
+
/*#__PURE__*/ jsx("br", {}, i)
|
|
11
|
+
] : [
|
|
12
|
+
x
|
|
13
|
+
]);
|
|
14
|
+
};
|
|
15
|
+
export { WrapText };
|
package/dist/components/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
3
|
import { Box } from "../layout/index.js";
|
|
4
|
+
import { WrapText } from "../WrapText/index.js";
|
|
4
5
|
import { textVariants } from "./text-theme.js";
|
|
5
|
-
const Text = /*#__PURE__*/ forwardRef(({ variant, className, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, fontWeight, lineHeight, align, textAlign, ...props }, ref)
|
|
6
|
+
const Text = /*#__PURE__*/ forwardRef(({ variant, className, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, fontWeight, lineHeight, align, textAlign, wrapText, children, ...props }, ref)=>{
|
|
7
|
+
const content = useMemo(()=>wrapText ? /*#__PURE__*/ jsx(WrapText, {
|
|
8
|
+
children: children
|
|
9
|
+
}) : children, [
|
|
10
|
+
children,
|
|
11
|
+
wrapText
|
|
12
|
+
]);
|
|
13
|
+
return /*#__PURE__*/ jsx(Box, {
|
|
6
14
|
ref: ref,
|
|
7
15
|
as: "span",
|
|
8
16
|
textAlign: textAlign || align,
|
|
@@ -23,7 +31,9 @@ const Text = /*#__PURE__*/ forwardRef(({ variant, className, h1, h2, h3, body1,
|
|
|
23
31
|
lineHeight,
|
|
24
32
|
className
|
|
25
33
|
}),
|
|
26
|
-
...props
|
|
27
|
-
|
|
34
|
+
...props,
|
|
35
|
+
children: content
|
|
36
|
+
});
|
|
37
|
+
});
|
|
28
38
|
Text.displayName = 'UX.Text';
|
|
29
39
|
export { Text };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-react",
|
|
3
|
-
"version": "0.5.1-beta.
|
|
3
|
+
"version": "0.5.1-beta.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"react-aria-components": "^1.14.0",
|
|
53
53
|
"values.js": "^2.1.1",
|
|
54
54
|
"zustand": "^5.0.8",
|
|
55
|
-
"@particle-network/
|
|
56
|
-
"@particle-network/
|
|
55
|
+
"@particle-network/icons": "0.5.1-beta.6",
|
|
56
|
+
"@particle-network/ui-shared": "0.4.1-beta.5"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "rslib build",
|