@particle-network/ui-react 0.3.0-beta.8 → 0.3.0-beta.9

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,13 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { cn } from "@heroui/theme";
4
- import { getHexColorFromCSSVariable } from "@particle-network/ui-shared";
4
+ import { colorToClassName } from "@particle-network/ui-shared";
5
5
  import { Square } from "../layout/index.js";
6
6
  import { SpinnerIcon } from "./SpinnerIcon.js";
7
7
  const UXSpinner = ({ size = 18, color = 'primary', duration = 1000, className, style, ...restProps })=>{
8
8
  const [currentIndex, setCurrentIndex] = useState(0);
9
9
  const animationRef = useRef(null);
10
- const actualColor = 'currentColor' === color ? 'currentColor' : getHexColorFromCSSVariable(color);
10
+ const iconClassName = 'currentColor' === color ? void 0 : colorToClassName[color];
11
11
  useEffect(()=>{
12
12
  const stepDuration = duration / 12;
13
13
  const animate = ()=>{
@@ -29,9 +29,7 @@ const UXSpinner = ({ size = 18, color = 'primary', duration = 1000, className, s
29
29
  children: /*#__PURE__*/ jsx(SpinnerIcon, {
30
30
  width: size,
31
31
  height: size,
32
- style: {
33
- color: actualColor
34
- },
32
+ className: iconClassName,
35
33
  currentIndex: currentIndex
36
34
  })
37
35
  });
@@ -1 +1,16 @@
1
- export * from '@heroui/toast';
1
+ import type { ToastProps } from '@heroui/toast';
2
+ export type UXToastType = 'success' | 'error' | 'loading';
3
+ export type UXToastProps = Partial<ToastProps> & {
4
+ type: UXToastType;
5
+ };
6
+ export declare const UXToastProvider: () => import("react/jsx-runtime").JSX.Element;
7
+ export declare const UXToast: {
8
+ success: (message: string, props?: Partial<ToastProps>) => string | null;
9
+ error: (message: string, props?: Partial<ToastProps>) => string | null;
10
+ loading: (message: string, props?: Partial<ToastProps>) => string | null;
11
+ show: (props?: Partial<ToastProps> & {
12
+ type: UXToastType;
13
+ }) => string | null;
14
+ closeAll: () => void;
15
+ closeToast: (key: string) => void;
16
+ };
@@ -1 +1,91 @@
1
- export * from "@heroui/toast";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ToastProvider, addToast, closeAll, closeToast } from "@heroui/toast";
3
+ import CircleCheckIcon from "@particle-network/icons/web/CircleCheckIcon";
4
+ import CircleCloseIcon from "@particle-network/icons/web/CircleCloseIcon";
5
+ import CloseIcon from "@particle-network/icons/web/CloseIcon";
6
+ import { UXSpinner } from "../UXSpinner/index.js";
7
+ const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
8
+ placement: "top-center",
9
+ maxVisibleToasts: 5,
10
+ toastOffset: 40,
11
+ toastProps: {
12
+ timeout: 4000
13
+ }
14
+ });
15
+ const getIcon = (type)=>{
16
+ if ('success' === type) return /*#__PURE__*/ jsx(CircleCheckIcon, {
17
+ size: 18
18
+ });
19
+ if ('error' === type) return /*#__PURE__*/ jsx(CircleCloseIcon, {
20
+ size: 18
21
+ });
22
+ if ('loading' === type) return /*#__PURE__*/ jsx(UXSpinner, {
23
+ size: 18
24
+ });
25
+ return null;
26
+ };
27
+ const show = (props)=>{
28
+ const { type, hideCloseButton, variant, classNames, ...toastProps } = props ?? {};
29
+ return addToast({
30
+ classNames: {
31
+ base: [
32
+ 'bg-tertiary rounded-xl px-3.5 py-3 shadow-none !w-fit max-w-[350px]',
33
+ !hideCloseButton && 'pr-12',
34
+ 'flat' === variant && 'success' === type && 'bg-[#0E3728]',
35
+ 'flat' === variant && 'error' === type && 'bg-[#501D1D]'
36
+ ],
37
+ description: [
38
+ 'text-foreground text-xs font-medium me-0 leading-4',
39
+ 'flat' === variant && 'text-white'
40
+ ],
41
+ icon: [
42
+ 'shrink-0 h-5 w-5',
43
+ 'success' === type && 'text-success',
44
+ 'error' === type && 'text-danger',
45
+ 'loading' === type && 'text-primary'
46
+ ],
47
+ loadingComponent: [
48
+ 'text-primary h-5 w-5'
49
+ ],
50
+ content: [
51
+ 'gap-x-2.5'
52
+ ],
53
+ closeButton: [
54
+ 'absolute right-3 top-1/2 -translate-y-1/2',
55
+ hideCloseButton ? 'opacity-0' : 'opacity-100'
56
+ ],
57
+ ...classNames
58
+ },
59
+ icon: getIcon(type),
60
+ closeIcon: /*#__PURE__*/ jsx(CloseIcon, {
61
+ className: 'flat' === variant ? 'text-white' : 'text-foreground'
62
+ }),
63
+ loadingComponent: /*#__PURE__*/ jsx(UXSpinner, {
64
+ size: 18
65
+ }),
66
+ timeout: 'loading' === type ? 1 / 0 : 4000,
67
+ ...toastProps
68
+ });
69
+ };
70
+ const UXToast = {
71
+ success: (message, props)=>show({
72
+ type: 'success',
73
+ description: message,
74
+ ...props
75
+ }),
76
+ error: (message, props)=>show({
77
+ type: 'error',
78
+ description: message,
79
+ ...props
80
+ }),
81
+ loading: (message, props)=>show({
82
+ type: 'loading',
83
+ description: message,
84
+ timeout: 1 / 0,
85
+ ...props
86
+ }),
87
+ show,
88
+ closeAll: closeAll,
89
+ closeToast: closeToast
90
+ };
91
+ export { UXToast, UXToastProvider };
@@ -4,7 +4,10 @@ import { cn } from "@heroui/theme";
4
4
  import { textClasses } from "./Text.type.js";
5
5
  const Text = /*#__PURE__*/ forwardRef(({ variant = 'body2Bold', fontWeight, color, lineHeight, align, className, h1, h2, h3, body1, body1Bold, body2, body2Bold, body3, body3Bold, caption1, caption1Bold, ...props }, ref)=>/*#__PURE__*/ jsx("span", {
6
6
  ref: ref,
7
- className: cn(textClasses.variant[variant], h1 && textClasses.variant.h1, h2 && textClasses.variant.h2, h3 && textClasses.variant.h3, body1 && textClasses.variant.body1, body1Bold && textClasses.variant.body1Bold, body2 && textClasses.variant.body2, body2Bold && textClasses.variant.body2Bold, body3 && textClasses.variant.body3, body3Bold && textClasses.variant.body3Bold, caption1 && textClasses.variant.caption1, caption1Bold && textClasses.variant.caption1Bold, textClasses.fontWeight[fontWeight], textClasses.color[color], textClasses.lineHeight[lineHeight], textClasses.align[align], className),
7
+ style: {
8
+ color: color?.startsWith('#') ? color : void 0
9
+ },
10
+ className: cn(textClasses.variant[variant], h1 && textClasses.variant.h1, h2 && textClasses.variant.h2, h3 && textClasses.variant.h3, body1 && textClasses.variant.body1, body1Bold && textClasses.variant.body1Bold, body2 && textClasses.variant.body2, body2Bold && textClasses.variant.body2Bold, body3 && textClasses.variant.body3, body3Bold && textClasses.variant.body3Bold, caption1 && textClasses.variant.caption1, caption1Bold && textClasses.variant.caption1Bold, textClasses.fontWeight[fontWeight], !color?.startsWith('#') && textClasses.color[color], textClasses.lineHeight[lineHeight], textClasses.align[align], className),
8
11
  ...props
9
12
  }));
10
13
  Text.displayName = 'UX.Text';
@@ -89,7 +89,7 @@ export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
89
89
  * | warning | #FF9821 | #FF9821 |
90
90
  * | gold | #FFB800 | #F38300 |
91
91
  */
92
- color?: UXForegroundColor;
92
+ color?: UXForegroundColor | `#${string}`;
93
93
  lineHeight?: TextLineHeight;
94
94
  align?: TextAlign;
95
95
  }
@@ -41,7 +41,7 @@ const inputClasses = {
41
41
  color: {
42
42
  default: {
43
43
  inputWrapper: 'caret-foreground',
44
- input: 'text-foreground-100'
44
+ input: 'text-foreground'
45
45
  },
46
46
  primary: {
47
47
  inputWrapper: 'caret-primary',
@@ -49,7 +49,7 @@ const inputClasses = {
49
49
  },
50
50
  secondary: {
51
51
  inputWrapper: 'caret-foreground',
52
- input: 'text-foreground-300'
52
+ input: 'text-secondary'
53
53
  },
54
54
  success: {
55
55
  inputWrapper: 'caret-success',
@@ -185,9 +185,9 @@ const inputClasses = {
185
185
  'lg'
186
186
  ],
187
187
  class: {
188
- inputWrapper: 'bg-background-200 text-foreground-100 font-medium',
188
+ inputWrapper: 'bg-background-200 text-tertiary font-medium',
189
189
  label: 'font-medium',
190
- input: '!outline-none placeholder:text-foreground-100 placeholder:font-medium font-medium text-foreground'
190
+ input: '!outline-none placeholder:text-tertiary dark:placeholder:text-tertiary placeholder:font-medium font-medium text-foreground'
191
191
  }
192
192
  },
193
193
  {
@@ -195,7 +195,7 @@ const inputClasses = {
195
195
  color: 'default',
196
196
  isInvalid: false,
197
197
  class: {
198
- inputWrapper: 'group-data-[focus=true]:border-foreground-100'
198
+ inputWrapper: 'group-data-[focus=true]:border-foreground'
199
199
  }
200
200
  },
201
201
  {
@@ -211,7 +211,7 @@ const inputClasses = {
211
211
  color: 'secondary',
212
212
  isInvalid: false,
213
213
  class: {
214
- inputWrapper: 'group-data-[focus=true]:border-foreground-300'
214
+ inputWrapper: 'group-data-[focus=true]:border-secondary'
215
215
  }
216
216
  },
217
217
  {
@@ -260,9 +260,9 @@ const inputClasses = {
260
260
  isInvalid: false,
261
261
  class: {
262
262
  inputWrapper: [
263
- 'border-foreground-100',
264
- 'data-[hover=true]:border-foreground-100',
265
- 'group-data-[focus=true]:border-foreground-100'
263
+ 'border-foreground',
264
+ 'data-[hover=true]:border-foreground',
265
+ 'group-data-[focus=true]:border-foreground'
266
266
  ]
267
267
  }
268
268
  },
@@ -284,9 +284,9 @@ const inputClasses = {
284
284
  isInvalid: false,
285
285
  class: {
286
286
  inputWrapper: [
287
- 'border-foreground-300',
287
+ 'border-secondary',
288
288
  'data-[hover=true]:bg-background-200/70',
289
- 'group-data-[focus=true]:border-foreground-300'
289
+ 'group-data-[focus=true]:border-secondary'
290
290
  ]
291
291
  }
292
292
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-react",
3
- "version": "0.3.0-beta.8",
3
+ "version": "0.3.0-beta.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -48,7 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "ahooks": "^3.9.4",
51
- "@particle-network/ui-shared": "0.2.0-beta.2"
51
+ "@particle-network/ui-shared": "0.2.0-beta.3",
52
+ "@particle-network/icons": "0.3.0-beta.6"
52
53
  },
53
54
  "scripts": {
54
55
  "build": "rslib build",