@xaui/hybrid 0.0.2

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.
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/progress/index.ts
31
+ var progress_exports = {};
32
+ __export(progress_exports, {
33
+ Progress: () => Progress
34
+ });
35
+ module.exports = __toCommonJS(progress_exports);
36
+
37
+ // src/core/theme-context.tsx
38
+ var import_react2 = __toESM(require("react"), 1);
39
+
40
+ // src/core/theme-hooks.ts
41
+ var import_react = require("react");
42
+ function useXUITheme() {
43
+ const theme = (0, import_react.useContext)(XUIThemeContext);
44
+ if (!theme) {
45
+ throw new Error("useXUITheme must be used within XUIProvider");
46
+ }
47
+ return theme;
48
+ }
49
+
50
+ // src/core/theme-context.tsx
51
+ var import_theme = require("@xaui/core/theme");
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ var XUIThemeContext = (0, import_react2.createContext)(null);
54
+
55
+ // src/components/progress/circular-progress-indicator.tsx
56
+ var import_framer_motion = require("framer-motion");
57
+
58
+ // src/components/progress/progress.hook.ts
59
+ var import_react3 = require("react");
60
+ var MIN_VALUE = 0;
61
+ var MAX_VALUE = 1;
62
+ var clampProgress = (value) => Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));
63
+ var useProgressAnimation = (value, disableAnimation) => {
64
+ const [progressValue, setProgressValue] = (0, import_react3.useState)(() => clampProgress(value));
65
+ (0, import_react3.useEffect)(() => {
66
+ setProgressValue(clampProgress(value));
67
+ }, [value, disableAnimation]);
68
+ return progressValue;
69
+ };
70
+
71
+ // src/components/progress/progress.style.ts
72
+ var import_tailwind_variants = require("tailwind-variants");
73
+ var progressStyles = (0, import_tailwind_variants.tv)({
74
+ slots: {
75
+ base: "relative flex items-center justify-center overflow-hidden",
76
+ track: "overflow-hidden",
77
+ indicator: ""
78
+ },
79
+ variants: {
80
+ variant: {
81
+ linear: {
82
+ base: "w-full",
83
+ track: "w-full h-full",
84
+ indicator: "h-full bg-blue-400 transition-all"
85
+ },
86
+ circular: {
87
+ base: "inline-flex shrink-0",
88
+ track: "fill-none w-auto h-auto",
89
+ indicator: "fill-none w-auto h-auto"
90
+ }
91
+ }
92
+ },
93
+ defaultVariants: {
94
+ variant: "linear"
95
+ }
96
+ });
97
+
98
+ // src/components/progress/circular-progress-indicator.tsx
99
+ var import_jsx_runtime2 = require("react/jsx-runtime");
100
+ var CircularProgressIndicator = ({
101
+ value,
102
+ size = 40,
103
+ themeColor = "primary",
104
+ color,
105
+ backgroundColor,
106
+ borderRadius,
107
+ disableAnimation = false,
108
+ className
109
+ }) => {
110
+ const { base, track, indicator } = progressStyles({ variant: "circular" });
111
+ const theme = useXUITheme();
112
+ const colorScheme = theme.colors[themeColor];
113
+ const resolvedColor = color ?? colorScheme.main;
114
+ const resolvedBackground = backgroundColor ?? colorScheme.background;
115
+ const progressValue = useProgressAnimation(value, disableAnimation);
116
+ const strokeWidth = size * 0.1;
117
+ const center = size / 2;
118
+ const radius = (size - strokeWidth) / 2;
119
+ const circumference = 2 * Math.PI * radius;
120
+ const strokeCap = borderRadius && borderRadius > 0 ? "round" : "butt";
121
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
122
+ "div",
123
+ {
124
+ className: base({ className }),
125
+ style: {
126
+ width: size,
127
+ height: size,
128
+ display: "flex",
129
+ alignItems: "center",
130
+ justifyContent: "center"
131
+ },
132
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
133
+ "svg",
134
+ {
135
+ width: size,
136
+ height: size,
137
+ viewBox: `0 0 ${size} ${size}`,
138
+ style: {
139
+ transform: "rotate(-90deg)",
140
+ overflow: "visible",
141
+ transformOrigin: "center"
142
+ },
143
+ children: [
144
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
145
+ "circle",
146
+ {
147
+ cx: center,
148
+ cy: center,
149
+ r: radius,
150
+ fill: "none",
151
+ className: track(),
152
+ stroke: resolvedBackground,
153
+ strokeWidth
154
+ }
155
+ ),
156
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
157
+ import_framer_motion.motion.circle,
158
+ {
159
+ cx: center,
160
+ cy: center,
161
+ r: radius,
162
+ fill: "none",
163
+ className: indicator(),
164
+ stroke: resolvedColor,
165
+ strokeWidth,
166
+ strokeLinecap: strokeCap,
167
+ strokeDasharray: circumference,
168
+ initial: disableAnimation ? false : { strokeDashoffset: circumference },
169
+ animate: { strokeDashoffset: circumference * (1 - progressValue) },
170
+ transition: disableAnimation ? { duration: 0 } : { duration: 0.5, ease: [0, 0, 0.2, 1] }
171
+ }
172
+ )
173
+ ]
174
+ }
175
+ )
176
+ }
177
+ );
178
+ };
179
+
180
+ // src/components/progress/linear-progress-indicator.tsx
181
+ var import_framer_motion2 = require("framer-motion");
182
+ var import_jsx_runtime3 = require("react/jsx-runtime");
183
+ var LinearProgressIndicator = ({
184
+ value,
185
+ size = 4,
186
+ color,
187
+ backgroundColor,
188
+ borderRadius,
189
+ disableAnimation = false,
190
+ className
191
+ }) => {
192
+ const { track, indicator } = progressStyles({ variant: "linear" });
193
+ const progressValue = useProgressAnimation(value, disableAnimation);
194
+ const radius = Math.max(0, Math.min(size / 2, borderRadius ?? 0));
195
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
196
+ "div",
197
+ {
198
+ className: track({ className }),
199
+ style: {
200
+ height: size,
201
+ backgroundColor,
202
+ borderRadius: radius
203
+ },
204
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
205
+ import_framer_motion2.motion.div,
206
+ {
207
+ className: indicator(),
208
+ initial: disableAnimation ? false : { width: 0 },
209
+ animate: { width: `${progressValue * 100}%` },
210
+ transition: disableAnimation ? { duration: 0 } : { duration: 0.5, ease: [0, 0, 0.2, 1] },
211
+ style: {
212
+ backgroundColor: color,
213
+ borderRadius: radius,
214
+ height: size
215
+ }
216
+ }
217
+ )
218
+ }
219
+ );
220
+ };
221
+
222
+ // src/components/progress/progress.tsx
223
+ var import_jsx_runtime4 = require("react/jsx-runtime");
224
+ var Progress = (props) => {
225
+ const {
226
+ variant = "linear",
227
+ themeColor = "primary",
228
+ value,
229
+ color,
230
+ backgroundColor,
231
+ size,
232
+ disableAnimation = false,
233
+ className,
234
+ borderRadius
235
+ } = props;
236
+ const theme = useXUITheme();
237
+ const colorScheme = theme.colors[themeColor];
238
+ const mainColor = color ?? colorScheme.main;
239
+ const trackColor = backgroundColor ?? colorScheme.background;
240
+ const clampedValue = clampProgress(value);
241
+ const ariaValue = clampedValue * 100;
242
+ if (variant === "circular") {
243
+ const circleSize = size ?? 40;
244
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
245
+ "div",
246
+ {
247
+ role: "progressbar",
248
+ "aria-valuemin": 0,
249
+ "aria-valuemax": 100,
250
+ "aria-valuenow": ariaValue,
251
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
252
+ CircularProgressIndicator,
253
+ {
254
+ size: circleSize,
255
+ color: mainColor,
256
+ backgroundColor: trackColor,
257
+ value: clampedValue,
258
+ borderRadius,
259
+ disableAnimation,
260
+ className
261
+ }
262
+ )
263
+ }
264
+ );
265
+ }
266
+ const linearSize = size ?? 4;
267
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
268
+ "div",
269
+ {
270
+ role: "progressbar",
271
+ "aria-valuemin": 0,
272
+ "aria-valuemax": 100,
273
+ "aria-valuenow": ariaValue,
274
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
275
+ LinearProgressIndicator,
276
+ {
277
+ size: linearSize,
278
+ color: mainColor,
279
+ backgroundColor: trackColor,
280
+ value: clampedValue,
281
+ borderRadius,
282
+ disableAnimation,
283
+ className
284
+ }
285
+ )
286
+ }
287
+ );
288
+ };
289
+ // Annotate the CommonJS export names for ESM import in node:
290
+ 0 && (module.exports = {
291
+ Progress
292
+ });
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { T as ThemeColor } from '../theme-qvIXI4kF.cjs';
3
+
4
+ type ProgressVariant = 'linear' | 'circular';
5
+ type ProgressIndicatorProps = {
6
+ /**
7
+ * The variant of the progress indicator.
8
+ * @default 'linear'
9
+ */
10
+ variant?: ProgressVariant;
11
+ /**
12
+ * The size of the progress indicator (height for linear, diameter for circular).
13
+ * @default 4 for linear, 40 for circular
14
+ */
15
+ size?: number;
16
+ /**
17
+ * The theme color of the progress indicator.
18
+ * @default 'primary'
19
+ */
20
+ themeColor?: ThemeColor;
21
+ /**
22
+ * The custom color of the progress indicator.
23
+ * Overrides themeColor.
24
+ */
25
+ color?: string;
26
+ /**
27
+ * The background color of the track.
28
+ */
29
+ backgroundColor?: string;
30
+ /**
31
+ * The current value of the progress bar (0 to 1).
32
+ */
33
+ value: number;
34
+ /**
35
+ * Whether to disable the animation.
36
+ * @default false
37
+ */
38
+ disableAnimation?: boolean;
39
+ /**
40
+ * The border radius of the indicator and track.
41
+ */
42
+ borderRadius?: number;
43
+ /**
44
+ * Custom class names for the component.
45
+ */
46
+ className?: string;
47
+ };
48
+
49
+ declare const Progress: React.FC<ProgressIndicatorProps>;
50
+
51
+ export { Progress, type ProgressIndicatorProps };
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { T as ThemeColor } from '../theme-qvIXI4kF.js';
3
+
4
+ type ProgressVariant = 'linear' | 'circular';
5
+ type ProgressIndicatorProps = {
6
+ /**
7
+ * The variant of the progress indicator.
8
+ * @default 'linear'
9
+ */
10
+ variant?: ProgressVariant;
11
+ /**
12
+ * The size of the progress indicator (height for linear, diameter for circular).
13
+ * @default 4 for linear, 40 for circular
14
+ */
15
+ size?: number;
16
+ /**
17
+ * The theme color of the progress indicator.
18
+ * @default 'primary'
19
+ */
20
+ themeColor?: ThemeColor;
21
+ /**
22
+ * The custom color of the progress indicator.
23
+ * Overrides themeColor.
24
+ */
25
+ color?: string;
26
+ /**
27
+ * The background color of the track.
28
+ */
29
+ backgroundColor?: string;
30
+ /**
31
+ * The current value of the progress bar (0 to 1).
32
+ */
33
+ value: number;
34
+ /**
35
+ * Whether to disable the animation.
36
+ * @default false
37
+ */
38
+ disableAnimation?: boolean;
39
+ /**
40
+ * The border radius of the indicator and track.
41
+ */
42
+ borderRadius?: number;
43
+ /**
44
+ * Custom class names for the component.
45
+ */
46
+ className?: string;
47
+ };
48
+
49
+ declare const Progress: React.FC<ProgressIndicatorProps>;
50
+
51
+ export { Progress, type ProgressIndicatorProps };
@@ -0,0 +1,241 @@
1
+ import {
2
+ useXUITheme
3
+ } from "../chunk-4GTYR4N2.js";
4
+
5
+ // src/components/progress/circular-progress-indicator.tsx
6
+ import { motion } from "framer-motion";
7
+
8
+ // src/components/progress/progress.hook.ts
9
+ import { useEffect, useState } from "react";
10
+ var MIN_VALUE = 0;
11
+ var MAX_VALUE = 1;
12
+ var clampProgress = (value) => Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));
13
+ var useProgressAnimation = (value, disableAnimation) => {
14
+ const [progressValue, setProgressValue] = useState(() => clampProgress(value));
15
+ useEffect(() => {
16
+ setProgressValue(clampProgress(value));
17
+ }, [value, disableAnimation]);
18
+ return progressValue;
19
+ };
20
+
21
+ // src/components/progress/progress.style.ts
22
+ import { tv } from "tailwind-variants";
23
+ var progressStyles = tv({
24
+ slots: {
25
+ base: "relative flex items-center justify-center overflow-hidden",
26
+ track: "overflow-hidden",
27
+ indicator: ""
28
+ },
29
+ variants: {
30
+ variant: {
31
+ linear: {
32
+ base: "w-full",
33
+ track: "w-full h-full",
34
+ indicator: "h-full bg-blue-400 transition-all"
35
+ },
36
+ circular: {
37
+ base: "inline-flex shrink-0",
38
+ track: "fill-none w-auto h-auto",
39
+ indicator: "fill-none w-auto h-auto"
40
+ }
41
+ }
42
+ },
43
+ defaultVariants: {
44
+ variant: "linear"
45
+ }
46
+ });
47
+
48
+ // src/components/progress/circular-progress-indicator.tsx
49
+ import { jsx, jsxs } from "react/jsx-runtime";
50
+ var CircularProgressIndicator = ({
51
+ value,
52
+ size = 40,
53
+ themeColor = "primary",
54
+ color,
55
+ backgroundColor,
56
+ borderRadius,
57
+ disableAnimation = false,
58
+ className
59
+ }) => {
60
+ const { base, track, indicator } = progressStyles({ variant: "circular" });
61
+ const theme = useXUITheme();
62
+ const colorScheme = theme.colors[themeColor];
63
+ const resolvedColor = color ?? colorScheme.main;
64
+ const resolvedBackground = backgroundColor ?? colorScheme.background;
65
+ const progressValue = useProgressAnimation(value, disableAnimation);
66
+ const strokeWidth = size * 0.1;
67
+ const center = size / 2;
68
+ const radius = (size - strokeWidth) / 2;
69
+ const circumference = 2 * Math.PI * radius;
70
+ const strokeCap = borderRadius && borderRadius > 0 ? "round" : "butt";
71
+ return /* @__PURE__ */ jsx(
72
+ "div",
73
+ {
74
+ className: base({ className }),
75
+ style: {
76
+ width: size,
77
+ height: size,
78
+ display: "flex",
79
+ alignItems: "center",
80
+ justifyContent: "center"
81
+ },
82
+ children: /* @__PURE__ */ jsxs(
83
+ "svg",
84
+ {
85
+ width: size,
86
+ height: size,
87
+ viewBox: `0 0 ${size} ${size}`,
88
+ style: {
89
+ transform: "rotate(-90deg)",
90
+ overflow: "visible",
91
+ transformOrigin: "center"
92
+ },
93
+ children: [
94
+ /* @__PURE__ */ jsx(
95
+ "circle",
96
+ {
97
+ cx: center,
98
+ cy: center,
99
+ r: radius,
100
+ fill: "none",
101
+ className: track(),
102
+ stroke: resolvedBackground,
103
+ strokeWidth
104
+ }
105
+ ),
106
+ /* @__PURE__ */ jsx(
107
+ motion.circle,
108
+ {
109
+ cx: center,
110
+ cy: center,
111
+ r: radius,
112
+ fill: "none",
113
+ className: indicator(),
114
+ stroke: resolvedColor,
115
+ strokeWidth,
116
+ strokeLinecap: strokeCap,
117
+ strokeDasharray: circumference,
118
+ initial: disableAnimation ? false : { strokeDashoffset: circumference },
119
+ animate: { strokeDashoffset: circumference * (1 - progressValue) },
120
+ transition: disableAnimation ? { duration: 0 } : { duration: 0.5, ease: [0, 0, 0.2, 1] }
121
+ }
122
+ )
123
+ ]
124
+ }
125
+ )
126
+ }
127
+ );
128
+ };
129
+
130
+ // src/components/progress/linear-progress-indicator.tsx
131
+ import { motion as motion2 } from "framer-motion";
132
+ import { jsx as jsx2 } from "react/jsx-runtime";
133
+ var LinearProgressIndicator = ({
134
+ value,
135
+ size = 4,
136
+ color,
137
+ backgroundColor,
138
+ borderRadius,
139
+ disableAnimation = false,
140
+ className
141
+ }) => {
142
+ const { track, indicator } = progressStyles({ variant: "linear" });
143
+ const progressValue = useProgressAnimation(value, disableAnimation);
144
+ const radius = Math.max(0, Math.min(size / 2, borderRadius ?? 0));
145
+ return /* @__PURE__ */ jsx2(
146
+ "div",
147
+ {
148
+ className: track({ className }),
149
+ style: {
150
+ height: size,
151
+ backgroundColor,
152
+ borderRadius: radius
153
+ },
154
+ children: /* @__PURE__ */ jsx2(
155
+ motion2.div,
156
+ {
157
+ className: indicator(),
158
+ initial: disableAnimation ? false : { width: 0 },
159
+ animate: { width: `${progressValue * 100}%` },
160
+ transition: disableAnimation ? { duration: 0 } : { duration: 0.5, ease: [0, 0, 0.2, 1] },
161
+ style: {
162
+ backgroundColor: color,
163
+ borderRadius: radius,
164
+ height: size
165
+ }
166
+ }
167
+ )
168
+ }
169
+ );
170
+ };
171
+
172
+ // src/components/progress/progress.tsx
173
+ import { jsx as jsx3 } from "react/jsx-runtime";
174
+ var Progress = (props) => {
175
+ const {
176
+ variant = "linear",
177
+ themeColor = "primary",
178
+ value,
179
+ color,
180
+ backgroundColor,
181
+ size,
182
+ disableAnimation = false,
183
+ className,
184
+ borderRadius
185
+ } = props;
186
+ const theme = useXUITheme();
187
+ const colorScheme = theme.colors[themeColor];
188
+ const mainColor = color ?? colorScheme.main;
189
+ const trackColor = backgroundColor ?? colorScheme.background;
190
+ const clampedValue = clampProgress(value);
191
+ const ariaValue = clampedValue * 100;
192
+ if (variant === "circular") {
193
+ const circleSize = size ?? 40;
194
+ return /* @__PURE__ */ jsx3(
195
+ "div",
196
+ {
197
+ role: "progressbar",
198
+ "aria-valuemin": 0,
199
+ "aria-valuemax": 100,
200
+ "aria-valuenow": ariaValue,
201
+ children: /* @__PURE__ */ jsx3(
202
+ CircularProgressIndicator,
203
+ {
204
+ size: circleSize,
205
+ color: mainColor,
206
+ backgroundColor: trackColor,
207
+ value: clampedValue,
208
+ borderRadius,
209
+ disableAnimation,
210
+ className
211
+ }
212
+ )
213
+ }
214
+ );
215
+ }
216
+ const linearSize = size ?? 4;
217
+ return /* @__PURE__ */ jsx3(
218
+ "div",
219
+ {
220
+ role: "progressbar",
221
+ "aria-valuemin": 0,
222
+ "aria-valuemax": 100,
223
+ "aria-valuenow": ariaValue,
224
+ children: /* @__PURE__ */ jsx3(
225
+ LinearProgressIndicator,
226
+ {
227
+ size: linearSize,
228
+ color: mainColor,
229
+ backgroundColor: trackColor,
230
+ value: clampedValue,
231
+ borderRadius,
232
+ disableAnimation,
233
+ className
234
+ }
235
+ )
236
+ }
237
+ );
238
+ };
239
+ export {
240
+ Progress
241
+ };
@@ -0,0 +1,3 @@
1
+ type ThemeColor = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'default';
2
+
3
+ export type { ThemeColor as T };
@@ -0,0 +1,3 @@
1
+ type ThemeColor = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'default';
2
+
3
+ export type { ThemeColor as T };