funuicss 2.5.3 → 2.5.5

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.
@@ -49,7 +49,7 @@ var React = __importStar(require("react"));
49
49
  var pi_1 = require("react-icons/pi");
50
50
  function FunLoader(_a) {
51
51
  var funcss = _a.funcss, size = _a.size, fixed = _a.fixed, backdrop = _a.backdrop, color = _a.color, variant = _a.variant, rest = __rest(_a, ["funcss", "size", "fixed", "backdrop", "color", "variant"]);
52
- return (React.createElement("div", __assign({ className: "".concat(fixed ? 'fixedLoader' : '', " ").concat(backdrop && fixed ? 'backdropLoader' : '') }, rest), variant === 'simple' ?
52
+ return (React.createElement("div", __assign({ style: { lineHeight: "0" }, className: "".concat(fixed ? 'fixedLoader' : '', " ").concat(backdrop && fixed ? 'backdropLoader' : '') }, rest), variant === 'simple' ?
53
53
  React.createElement("span", { className: "rotate ".concat(funcss ? funcss : '', " text-").concat(color ? color : '') },
54
54
  React.createElement(pi_1.PiSpinnerDuotone, { style: { fontSize: size + "px", display: 'block' } }))
55
55
  : variant === 'duotone' ?
@@ -20,7 +20,7 @@ export default function FunLoader({
20
20
  ...rest
21
21
  }: FunLoaderProps) {
22
22
  return (
23
- <div className={`${fixed ? 'fixedLoader' : ''} ${backdrop && fixed ? 'backdropLoader' : ''}`} {...rest}>
23
+ <div style={{lineHeight:"0"}} className={`${fixed ? 'fixedLoader' : ''} ${backdrop && fixed ? 'backdropLoader' : ''}`} {...rest}>
24
24
 
25
25
  {
26
26
  variant === 'simple'?
@@ -4,11 +4,14 @@ interface ProgressBarProps {
4
4
  progress: number;
5
5
  height?: number;
6
6
  children?: React.ReactNode;
7
- content?: React.ReactNode;
7
+ content?: ((progress: number) => React.ReactNode) | React.ReactNode;
8
8
  bg?: string;
9
- lined?: boolean;
10
9
  raised?: boolean;
11
10
  rounded?: boolean;
11
+ type?: 'linear' | 'circle';
12
+ size?: number;
13
+ strokeWidth?: number;
12
14
  }
13
- export default function ProgressBar({ funcss, progress, height, children, content, raised, rounded, bg, lined, }: ProgressBarProps): React.JSX.Element;
15
+ export default function ProgressBar({ funcss, progress, height, children, content, raised, rounded, bg, // default CSS class name
16
+ type, size, strokeWidth, }: ProgressBarProps): React.JSX.Element;
14
17
  export {};
@@ -24,20 +24,60 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  var React = __importStar(require("react"));
27
+ var pi_1 = require("react-icons/pi");
27
28
  function ProgressBar(_a) {
28
- var funcss = _a.funcss, progress = _a.progress, height = _a.height, children = _a.children, content = _a.content, raised = _a.raised, rounded = _a.rounded, bg = _a.bg, lined = _a.lined;
29
- return (React.createElement(React.Fragment, null, lined ? (React.createElement("div", { className: " ".concat(funcss, " progressBar lined ").concat(bg) },
30
- children,
31
- " ",
32
- content,
33
- React.createElement("div", { className: " ".concat(funcss, " ").concat(bg, " linedProgress ").concat(raised ? 'raised' : '', " ").concat(rounded ? 'rounded' : ''), style: { width: "".concat(progress < 101 ? progress : '', "%"), height: "".concat(height, "px") } }))) : (React.createElement("div", { className: "progressBar ".concat(raised ? 'raised' : '', " ").concat(rounded ? 'rounded' : '') },
34
- React.createElement("div", { className: " ".concat(funcss, " progressInner ").concat(bg, " ").concat(rounded ? 'rounded' : ''), style: {
35
- width: "".concat(progress < 101 ? progress : '', "%"),
29
+ var funcss = _a.funcss, progress = _a.progress, _b = _a.height, height = _b === void 0 ? 16 : _b, children = _a.children, content = _a.content, raised = _a.raised, rounded = _a.rounded, _c = _a.bg, bg = _c === void 0 ? 'primary' : _c, // default CSS class name
30
+ _d = _a.type, // default CSS class name
31
+ type = _d === void 0 ? 'linear' : _d, _e = _a.size, size = _e === void 0 ? 60 : _e, _f = _a.strokeWidth, strokeWidth = _f === void 0 ? 6 : _f;
32
+ var clampedProgress = Math.min(100, Math.max(0, progress));
33
+ var isComplete = clampedProgress >= 100;
34
+ var effectiveBg = isComplete ? 'success' : bg;
35
+ var renderContent = function () {
36
+ if (React.isValidElement(content))
37
+ return content;
38
+ if (typeof content === 'function')
39
+ return content(clampedProgress);
40
+ if (typeof content === 'string')
41
+ return content;
42
+ return "".concat(clampedProgress, "%");
43
+ };
44
+ if (type === 'circle') {
45
+ var radius = (size - strokeWidth) / 2;
46
+ var circumference = 2 * Math.PI * radius;
47
+ var offset = circumference - (clampedProgress / 100) * circumference;
48
+ return (React.createElement("div", { className: "relative flex justify-center items-center ".concat(funcss), style: { width: size, height: size } },
49
+ React.createElement("svg", { width: size, height: size, className: "rotate-[-90deg]" },
50
+ React.createElement("circle", { cx: size / 2, cy: size / 2, r: radius, strokeWidth: strokeWidth, fill: "none", stroke: "#e5e7eb" // light gray background stroke
51
+ }),
52
+ React.createElement("circle", { cx: size / 2, cy: size / 2, r: radius, strokeWidth: strokeWidth, fill: "none", className: effectiveBg, strokeDasharray: circumference, strokeDashoffset: offset, strokeLinecap: "round", style: { transition: 'stroke-dashoffset 0.4s ease, stroke 0.3s ease' } })),
53
+ React.createElement("div", { className: "absolute text-center font-bold text-sm", style: {
54
+ top: '50%',
55
+ left: '50%',
56
+ transform: 'translate(-50%, -50%)',
57
+ display: 'flex',
58
+ alignItems: 'center',
59
+ justifyContent: 'center',
60
+ width: size,
61
+ height: size,
62
+ } }, isComplete ? React.createElement(pi_1.PiCheck, { className: "text-success800", size: size / 2.2 }) : renderContent())));
63
+ }
64
+ // Linear bar
65
+ return (React.createElement("div", { className: "progressBar ".concat(raised ? 'raised' : '', " ").concat(rounded ? 'rounded' : '', " ").concat(funcss || '') },
66
+ React.createElement("div", { className: "progressInner ".concat(rounded ? 'rounded' : '', " ").concat(effectiveBg), style: {
67
+ width: "".concat(clampedProgress, "%"),
36
68
  height: "".concat(height, "px"),
37
- padding: "".concat(progress > 0 ? '0 1rem' : ''),
69
+ padding: '0 1rem',
70
+ transition: 'width 0.3s ease, background-color 0.3s ease',
71
+ display: 'flex',
72
+ alignItems: 'center',
73
+ justifyContent: 'flex-end',
74
+ fontWeight: 'bold',
75
+ color: '#fff',
76
+ overflow: 'hidden',
77
+ whiteSpace: 'nowrap',
38
78
  } },
39
- children,
79
+ isComplete ? React.createElement(pi_1.PiCheck, null) : renderContent(),
40
80
  " ",
41
- content)))));
81
+ children)));
42
82
  }
43
83
  exports.default = ProgressBar;
@@ -1,52 +1,113 @@
1
1
  import * as React from 'react';
2
+ import { PiCheck } from 'react-icons/pi';
2
3
 
3
4
  interface ProgressBarProps {
4
5
  funcss?: string;
5
6
  progress: number;
6
7
  height?: number;
7
8
  children?: React.ReactNode;
8
- content?: React.ReactNode;
9
- bg?: string;
10
- lined?: boolean;
11
- raised?:boolean ,
12
- rounded?:boolean
9
+ content?: ((progress: number) => React.ReactNode) | React.ReactNode;
10
+ bg?: string; // Now CSS class names, e.g. 'primary', 'success'
11
+ raised?: boolean;
12
+ rounded?: boolean;
13
+ type?: 'linear' | 'circle';
14
+ size?: number;
15
+ strokeWidth?: number;
13
16
  }
14
17
 
15
18
  export default function ProgressBar({
16
19
  funcss,
17
20
  progress,
18
- height,
21
+ height = 16,
19
22
  children,
20
23
  content,
21
24
  raised,
22
25
  rounded,
23
- bg,
24
- lined,
26
+ bg = 'primary', // default CSS class name
27
+ type = 'linear',
28
+ size = 60,
29
+ strokeWidth = 6,
25
30
  }: ProgressBarProps) {
26
- return (
27
- <>
28
- {lined ? (
29
- <div className={` ${funcss} progressBar lined ${bg}`}>
30
- {children} {content}
31
- <div
32
- className={` ${funcss} ${bg} linedProgress ${raised ? 'raised' : ''} ${rounded ? 'rounded' : ''}`}
33
- style={{ width: `${progress < 101 ? progress : ''}%`, height: `${height}px` }}
34
- ></div>
35
- </div>
36
- ) : (
37
- <div className={`progressBar ${raised ? 'raised' : ''} ${rounded ? 'rounded' : ''}`}>
38
- <div
39
- className={` ${funcss} progressInner ${bg} ${rounded ? 'rounded' : ''}`}
40
- style={{
41
- width: `${progress < 101 ? progress : ''}%`,
42
- height: `${height}px`,
43
- padding: `${progress > 0 ? '0 1rem' : ''}`,
44
- }}
45
- >
46
- {children} {content}
47
- </div>
31
+ const clampedProgress = Math.min(100, Math.max(0, progress));
32
+ const isComplete = clampedProgress >= 100;
33
+ const effectiveBg = isComplete ? 'success' : bg;
34
+
35
+ const renderContent = () => {
36
+ if (React.isValidElement(content)) return content;
37
+ if (typeof content === 'function') return content(clampedProgress);
38
+ if (typeof content === 'string') return content;
39
+ return `${clampedProgress}%`;
40
+ };
41
+
42
+ if (type === 'circle') {
43
+ const radius = (size - strokeWidth) / 2;
44
+ const circumference = 2 * Math.PI * radius;
45
+ const offset = circumference - (clampedProgress / 100) * circumference;
46
+
47
+ return (
48
+ <div className={`relative flex justify-center items-center ${funcss}`} style={{ width: size, height: size }}>
49
+ <svg width={size} height={size} className="rotate-[-90deg]">
50
+ <circle
51
+ cx={size / 2}
52
+ cy={size / 2}
53
+ r={radius}
54
+ strokeWidth={strokeWidth}
55
+ fill="none"
56
+ stroke="#e5e7eb" // light gray background stroke
57
+ />
58
+ <circle
59
+ cx={size / 2}
60
+ cy={size / 2}
61
+ r={radius}
62
+ strokeWidth={strokeWidth}
63
+ fill="none"
64
+ className={effectiveBg}
65
+ strokeDasharray={circumference}
66
+ strokeDashoffset={offset}
67
+ strokeLinecap="round"
68
+ style={{ transition: 'stroke-dashoffset 0.4s ease, stroke 0.3s ease' }}
69
+ />
70
+ </svg>
71
+ <div
72
+ className="absolute text-center font-bold text-sm"
73
+ style={{
74
+ top: '50%',
75
+ left: '50%',
76
+ transform: 'translate(-50%, -50%)',
77
+ display: 'flex',
78
+ alignItems: 'center',
79
+ justifyContent: 'center',
80
+ width: size,
81
+ height: size,
82
+ }}
83
+ >
84
+ {isComplete ? <PiCheck className="text-success800" size={size / 2.2} /> : renderContent()}
48
85
  </div>
49
- )}
50
- </>
86
+ </div>
87
+ );
88
+ }
89
+
90
+ // Linear bar
91
+ return (
92
+ <div className={`progressBar ${raised ? 'raised' : ''} ${rounded ? 'rounded' : ''} ${funcss || ''}`}>
93
+ <div
94
+ className={`progressInner ${rounded ? 'rounded' : ''} ${effectiveBg}`}
95
+ style={{
96
+ width: `${clampedProgress}%`,
97
+ height: `${height}px`,
98
+ padding: '0 1rem',
99
+ transition: 'width 0.3s ease, background-color 0.3s ease',
100
+ display: 'flex',
101
+ alignItems: 'center',
102
+ justifyContent: 'flex-end',
103
+ fontWeight: 'bold',
104
+ color: '#fff',
105
+ overflow: 'hidden',
106
+ whiteSpace: 'nowrap',
107
+ }}
108
+ >
109
+ {isComplete ? <PiCheck /> : renderContent()} {children}
110
+ </div>
111
+ </div>
51
112
  );
52
113
  }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface ThemeProviderProps {
3
+ theme: 'light' | 'dark';
4
+ children: React.ReactNode;
5
+ }
6
+ declare const ThemeProvider: React.FC<ThemeProviderProps>;
7
+ export default ThemeProvider;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ var react_1 = __importStar(require("react"));
28
+ var ThemeProvider = function (_a) {
29
+ var theme = _a.theme, children = _a.children;
30
+ (0, react_1.useEffect)(function () {
31
+ var root = document.documentElement;
32
+ var lightTheme = {
33
+ '--page-bg': '#FFFFFF',
34
+ '--text-color': '#000000',
35
+ '--raiseThemes': '#FFFFFF',
36
+ };
37
+ var darkTheme = {
38
+ '--page-bg': '#121212',
39
+ '--text-color': '#FFFFFF',
40
+ '--raiseThemes': '#202020',
41
+ '--borderColor': '#333333',
42
+ '--lighter': '#202020',
43
+ };
44
+ var selectedTheme = theme === 'dark' ? darkTheme : lightTheme;
45
+ Object.entries(selectedTheme).forEach(function (_a) {
46
+ var key = _a[0], value = _a[1];
47
+ root.style.setProperty(key, value);
48
+ });
49
+ }, [theme]);
50
+ return (react_1.default.createElement("div", { className: "theme-".concat(theme), style: {
51
+ backgroundColor: 'var(--page-bg)',
52
+ color: 'var(--text-color)',
53
+ minHeight: '100vh',
54
+ } }, children));
55
+ };
56
+ exports.default = ThemeProvider;
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ import React, { useEffect } from 'react';
3
+
4
+ interface ThemeProviderProps {
5
+ theme: 'light' | 'dark';
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ const ThemeProvider: React.FC<ThemeProviderProps> = ({ theme, children }) => {
10
+ useEffect(() => {
11
+ const root = document.documentElement;
12
+
13
+ const lightTheme = {
14
+ '--page-bg': '#FFFFFF',
15
+ '--text-color': '#000000',
16
+ '--raiseThemes': '#FFFFFF',
17
+ };
18
+
19
+ const darkTheme = {
20
+ '--page-bg': '#121212',
21
+ '--text-color': '#FFFFFF',
22
+ '--raiseThemes': '#202020',
23
+ '--borderColor': '#333333',
24
+ '--lighter': '#202020',
25
+ };
26
+
27
+ const selectedTheme = theme === 'dark' ? darkTheme : lightTheme;
28
+
29
+ Object.entries(selectedTheme).forEach(([key, value]) => {
30
+ root.style.setProperty(key, value);
31
+ });
32
+ }, [theme]);
33
+
34
+ return (
35
+ <div
36
+ className={`theme-${theme}`}
37
+ style={{
38
+ backgroundColor: 'var(--page-bg)',
39
+ color: 'var(--text-color)',
40
+ minHeight: '100vh',
41
+ }}
42
+ >
43
+ {children}
44
+ </div>
45
+ );
46
+ };
47
+
48
+ export default ThemeProvider;
package/ui/tooltip/Tip.js CHANGED
@@ -48,13 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  var React = __importStar(require("react"));
49
49
  function Tip(_a) {
50
50
  var tip = _a.tip, funcss = _a.funcss, children = _a.children, content = _a.content, message = _a.message, animation = _a.animation, duration = _a.duration, rest = __rest(_a, ["tip", "funcss", "children", "content", "message", "animation", "duration"]);
51
- // Calculate width only if content is a string
52
51
  var text = message || content || children;
53
- // Check if content is a plain string to calculate width
54
- var isString = typeof text === 'string';
55
- var minWidth = isString
56
- ? "".concat(text.replace(/\s+/g, '').length * 8, "px")
57
- : 'auto';
58
- return (React.createElement("span", __assign({ className: "tip-".concat(tip, " tip ").concat(funcss ? funcss : ''), style: { animation: " ".concat(duration ? duration : 0, "s ").concat(animation ? animation : ''), minWidth: minWidth } }, rest), text));
52
+ return (React.createElement("span", __assign({ className: "tip-".concat(tip, " tip ").concat(funcss ? funcss : ''), style: { animation: " ".concat(duration ? duration : 0, "s ").concat(animation ? animation : '') } }, rest), text));
59
53
  }
60
54
  exports.default = Tip;
@@ -20,17 +20,11 @@ export default function Tip({
20
20
  duration,
21
21
  ...rest
22
22
  }: TipProps) {
23
- // Calculate width only if content is a string
24
23
  const text = message || content || children;
25
- // Check if content is a plain string to calculate width
26
- const isString = typeof text === 'string';
27
- const minWidth = isString
28
- ? `${text.replace(/\s+/g, '').length * 8}px`
29
- : 'auto';
30
24
  return (
31
25
  <span
32
26
  className={`tip-${tip} tip ${funcss ? funcss : ''}`}
33
- style={{ animation: ` ${duration ? duration : 0}s ${animation ? animation : ''}`, minWidth: minWidth }}
27
+ style={{ animation: ` ${duration ? duration : 0}s ${animation ? animation : ''}`}}
34
28
  {...rest}
35
29
  >
36
30
  {text}