@particle-network/ui-react 0.3.0-beta.12 → 0.3.0-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.
@@ -1,4 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import "react";
2
3
  import { ToastProvider, addToast, closeAll, closeToast } from "@heroui/toast";
3
4
  import CircleCheckIcon from "@particle-network/icons/web/CircleCheckIcon";
4
5
  import CircleCloseIcon from "@particle-network/icons/web/CircleCloseIcon";
@@ -11,6 +12,9 @@ const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
11
12
  toastOffset: 40,
12
13
  toastProps: {
13
14
  timeout: 3000
15
+ },
16
+ regionProps: {
17
+ className: 'items-center'
14
18
  }
15
19
  });
16
20
  const getIcon = (type)=>{
@@ -25,38 +29,54 @@ const getIcon = (type)=>{
25
29
  });
26
30
  return null;
27
31
  };
32
+ const hasLongWord = (text)=>{
33
+ if ('string' != typeof text) return false;
34
+ const englishWords = text.match(/[a-zA-Z0-9_-]+/g);
35
+ if (!englishWords) return false;
36
+ return englishWords.some((word)=>word.length > 30);
37
+ };
28
38
  const show = (props)=>{
29
- const { type, hideCloseButton, variant, classNames, ...toastProps } = props ?? {};
39
+ const { type, hideCloseButton, variant, classNames, description, ...toastProps } = props ?? {};
40
+ const { base, description: descriptionClassName, icon, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
30
41
  return addToast({
31
42
  classNames: {
32
43
  base: [
33
- 'bg-tertiary rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[350px]',
44
+ 'bg-tertiary rounded-xl px-3.5 py-3 shadow-none border-none !w-fit',
34
45
  !hideCloseButton && 'pr-12',
35
46
  'flat' === variant && 'success' === type && 'bg-[#0E3728]',
36
- 'flat' === variant && 'error' === type && 'bg-[#501D1D]'
47
+ 'flat' === variant && 'error' === type && 'bg-[#501D1D]',
48
+ hasLongWord(description) ? 'md:max-w-[480px] max-w-[360px]' : 'max-w-[360px]',
49
+ base
37
50
  ],
38
51
  description: [
39
- 'text-foreground text-xs font-medium me-0 leading-4',
40
- 'flat' === variant && 'text-white'
52
+ 'text-foreground text-xs font-medium me-0 leading-4 line-clamp-4',
53
+ 'flat' === variant && 'text-white',
54
+ hasLongWord(description) && 'break-all',
55
+ descriptionClassName
41
56
  ],
42
57
  icon: [
43
58
  'shrink-0 h-5 w-5',
44
59
  'success' === type && 'text-success',
45
60
  'error' === type && 'text-danger',
46
- 'loading' === type && 'text-primary'
61
+ 'loading' === type && 'text-primary',
62
+ icon
47
63
  ],
48
64
  loadingComponent: [
49
- 'text-primary h-5 w-5'
65
+ 'text-primary h-5 w-5',
66
+ loadingComponent
50
67
  ],
51
68
  content: [
52
- 'gap-x-2.5'
69
+ 'gap-x-2.5',
70
+ content
53
71
  ],
54
72
  closeButton: [
55
73
  'absolute right-3 top-1/2 -translate-y-1/2',
56
- hideCloseButton ? 'opacity-0' : 'opacity-100'
74
+ hideCloseButton ? 'opacity-0' : 'opacity-100',
75
+ closeButton
57
76
  ],
58
- ...classNames
77
+ ...restClassNames
59
78
  },
79
+ description,
60
80
  icon: getIcon(type),
61
81
  closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
62
82
  className: 'flat' === variant ? 'text-white' : 'text-foreground'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-react",
3
- "version": "0.3.0-beta.12",
3
+ "version": "0.3.0-beta.14",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "ahooks": "^3.9.4",
51
- "@particle-network/ui-shared": "0.2.0-beta.3",
52
- "@particle-network/icons": "0.3.0-beta.6"
51
+ "@particle-network/icons": "0.3.0-beta.6",
52
+ "@particle-network/ui-shared": "0.2.0-beta.3"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "rslib build",