@xaui/native 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,266 @@
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/components/progress/progress.tsx
38
+ var import_react6 = __toESM(require("react"), 1);
39
+ var import_react_native6 = require("react-native");
40
+
41
+ // src/core/theme-context.tsx
42
+ var import_react = __toESM(require("react"), 1);
43
+ var import_react_native = require("react-native");
44
+ var import_theme = require("@xaui/core/theme");
45
+ var XUIThemeContext = (0, import_react.createContext)(null);
46
+
47
+ // src/core/theme-hooks.ts
48
+ var import_react2 = require("react");
49
+ var import_react_native2 = require("react-native");
50
+ function useXUITheme() {
51
+ const theme = (0, import_react2.useContext)(XUIThemeContext);
52
+ if (!theme) {
53
+ throw new Error("useXUITheme must be used within XUIProvider");
54
+ }
55
+ return theme;
56
+ }
57
+
58
+ // src/components/progress/circular-progress-indicator.tsx
59
+ var import_react4 = __toESM(require("react"), 1);
60
+ var import_react_native4 = require("react-native");
61
+ var import_react_native_reanimated2 = __toESM(require("react-native-reanimated"), 1);
62
+ var import_react_native_svg = __toESM(require("react-native-svg"), 1);
63
+
64
+ // src/components/progress/progress.hook.ts
65
+ var import_react3 = require("react");
66
+ var import_react_native_reanimated = require("react-native-reanimated");
67
+ var MIN_VALUE = 0;
68
+ var MAX_VALUE = 1;
69
+ var clampProgress = (value) => Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));
70
+ var useProgressAnimation = (value, disableAnimation) => {
71
+ const progressAnim = (0, import_react_native_reanimated.useSharedValue)(clampProgress(value));
72
+ (0, import_react3.useEffect)(() => {
73
+ const clampedValue = clampProgress(value);
74
+ if (disableAnimation) {
75
+ progressAnim.value = clampedValue;
76
+ return;
77
+ }
78
+ progressAnim.value = (0, import_react_native_reanimated.withTiming)(clampedValue, {
79
+ duration: 500,
80
+ easing: import_react_native_reanimated.Easing.bezier(0, 0, 0.2, 1)
81
+ });
82
+ }, [value, disableAnimation, progressAnim]);
83
+ return progressAnim;
84
+ };
85
+
86
+ // src/components/progress/progress.style.ts
87
+ var import_react_native3 = require("react-native");
88
+ var styles = import_react_native3.StyleSheet.create({
89
+ container: {
90
+ width: "100%"
91
+ },
92
+ track: {
93
+ width: "100%",
94
+ overflow: "hidden"
95
+ },
96
+ progress: {
97
+ height: "100%"
98
+ },
99
+ circleContainer: {
100
+ justifyContent: "center",
101
+ alignItems: "center"
102
+ }
103
+ });
104
+
105
+ // src/components/progress/circular-progress-indicator.tsx
106
+ var AnimatedCircle = import_react_native_reanimated2.default.createAnimatedComponent(import_react_native_svg.Circle);
107
+ var CircularProgressIndicator = ({
108
+ size = 40,
109
+ color,
110
+ backgroundColor,
111
+ value,
112
+ borderRadius,
113
+ disableAnimation
114
+ }) => {
115
+ const progressAnim = useProgressAnimation(value, disableAnimation);
116
+ const strokeWidth = size * 0.1;
117
+ const radius = (size - strokeWidth) / 2;
118
+ const circumference = 2 * Math.PI * radius;
119
+ const center = size / 2;
120
+ const strokeCap = borderRadius && borderRadius > 0 ? "round" : "butt";
121
+ const animatedProps = (0, import_react_native_reanimated2.useAnimatedProps)(() => ({
122
+ strokeDashoffset: circumference * (1 - progressAnim.value)
123
+ }));
124
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_native4.View, { style: [styles.circleContainer, { width: size, height: size }] }, /* @__PURE__ */ import_react4.default.createElement(import_react_native_svg.default, { width: size, height: size, style: { transform: [{ rotate: "-90deg" }] } }, /* @__PURE__ */ import_react4.default.createElement(
125
+ import_react_native_svg.Circle,
126
+ {
127
+ cx: center,
128
+ cy: center,
129
+ r: radius,
130
+ stroke: backgroundColor,
131
+ strokeWidth,
132
+ fill: "none"
133
+ }
134
+ ), /* @__PURE__ */ import_react4.default.createElement(
135
+ AnimatedCircle,
136
+ {
137
+ cx: center,
138
+ cy: center,
139
+ r: radius,
140
+ stroke: color,
141
+ strokeWidth,
142
+ strokeLinecap: strokeCap,
143
+ strokeDasharray: circumference,
144
+ animatedProps,
145
+ fill: "none"
146
+ }
147
+ )));
148
+ };
149
+
150
+ // src/components/progress/linear-progress-indicator.tsx
151
+ var import_react5 = __toESM(require("react"), 1);
152
+ var import_react_native5 = require("react-native");
153
+ var import_react_native_reanimated3 = __toESM(require("react-native-reanimated"), 1);
154
+ var LinearProgressIndicator = ({
155
+ size = 4,
156
+ color,
157
+ backgroundColor,
158
+ value,
159
+ borderRadius,
160
+ disableAnimation
161
+ }) => {
162
+ const progressAnim = useProgressAnimation(value, disableAnimation);
163
+ const radius = Math.max(0, Math.min(size / 2, borderRadius ?? 0));
164
+ const animatedStyle = (0, import_react_native_reanimated3.useAnimatedStyle)(() => ({
165
+ width: `${progressAnim.value * 100}%`
166
+ }));
167
+ return /* @__PURE__ */ import_react5.default.createElement(
168
+ import_react_native5.View,
169
+ {
170
+ style: [
171
+ styles.track,
172
+ {
173
+ height: size,
174
+ backgroundColor,
175
+ borderRadius: radius
176
+ }
177
+ ]
178
+ },
179
+ /* @__PURE__ */ import_react5.default.createElement(
180
+ import_react_native_reanimated3.default.View,
181
+ {
182
+ style: [
183
+ styles.progress,
184
+ animatedStyle,
185
+ {
186
+ backgroundColor: color,
187
+ borderRadius: radius
188
+ }
189
+ ]
190
+ }
191
+ )
192
+ );
193
+ };
194
+
195
+ // src/components/progress/progress.tsx
196
+ var Progress = (props) => {
197
+ const {
198
+ variant = "linear",
199
+ themeColor = "primary",
200
+ value,
201
+ color,
202
+ backgroundColor,
203
+ size,
204
+ disableAnimation = false
205
+ } = props;
206
+ const theme = useXUITheme();
207
+ const colorScheme = theme.colors[themeColor];
208
+ const mainColor = color ?? colorScheme.main;
209
+ const trackColor = backgroundColor ?? colorScheme.background;
210
+ const clampedValue = clampProgress(value);
211
+ const accessibilityValue = {
212
+ min: 0,
213
+ max: 100,
214
+ now: clampedValue * 100
215
+ };
216
+ if (variant === "circular") {
217
+ const circleSize = size ?? 40;
218
+ const borderRadius2 = "borderRadius" in props ? props.borderRadius : void 0;
219
+ return /* @__PURE__ */ import_react6.default.createElement(
220
+ import_react_native6.View,
221
+ {
222
+ style: [styles.circleContainer, { width: circleSize, height: circleSize }],
223
+ accessible: true,
224
+ accessibilityRole: "progressbar",
225
+ accessibilityValue
226
+ },
227
+ /* @__PURE__ */ import_react6.default.createElement(
228
+ CircularProgressIndicator,
229
+ {
230
+ size: circleSize,
231
+ color: mainColor,
232
+ backgroundColor: trackColor,
233
+ value: clampedValue,
234
+ borderRadius: borderRadius2,
235
+ disableAnimation
236
+ }
237
+ )
238
+ );
239
+ }
240
+ const linearSize = size ?? 4;
241
+ const borderRadius = "borderRadius" in props ? props.borderRadius : void 0;
242
+ return /* @__PURE__ */ import_react6.default.createElement(
243
+ import_react_native6.View,
244
+ {
245
+ style: styles.container,
246
+ accessible: true,
247
+ accessibilityRole: "progressbar",
248
+ accessibilityValue
249
+ },
250
+ /* @__PURE__ */ import_react6.default.createElement(
251
+ LinearProgressIndicator,
252
+ {
253
+ size: linearSize,
254
+ color: mainColor,
255
+ backgroundColor: trackColor,
256
+ value: clampedValue,
257
+ borderRadius,
258
+ disableAnimation
259
+ }
260
+ )
261
+ );
262
+ };
263
+ // Annotate the CommonJS export names for ESM import in node:
264
+ 0 && (module.exports = {
265
+ Progress
266
+ });
@@ -0,0 +1,47 @@
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
+
45
+ declare const Progress: React.FC<ProgressIndicatorProps>;
46
+
47
+ export { Progress, type ProgressIndicatorProps };
@@ -0,0 +1,47 @@
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
+
45
+ declare const Progress: React.FC<ProgressIndicatorProps>;
46
+
47
+ export { Progress, type ProgressIndicatorProps };
@@ -0,0 +1,216 @@
1
+ import {
2
+ useXUITheme
3
+ } from "../chunk-SHT66VET.js";
4
+
5
+ // src/components/progress/progress.tsx
6
+ import React3 from "react";
7
+ import { View as View3 } from "react-native";
8
+
9
+ // src/components/progress/circular-progress-indicator.tsx
10
+ import React from "react";
11
+ import { View } from "react-native";
12
+ import Animated, { useAnimatedProps } from "react-native-reanimated";
13
+ import Svg, { Circle } from "react-native-svg";
14
+
15
+ // src/components/progress/progress.hook.ts
16
+ import { useEffect } from "react";
17
+ import { Easing, useSharedValue, withTiming } from "react-native-reanimated";
18
+ var MIN_VALUE = 0;
19
+ var MAX_VALUE = 1;
20
+ var clampProgress = (value) => Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));
21
+ var useProgressAnimation = (value, disableAnimation) => {
22
+ const progressAnim = useSharedValue(clampProgress(value));
23
+ useEffect(() => {
24
+ const clampedValue = clampProgress(value);
25
+ if (disableAnimation) {
26
+ progressAnim.value = clampedValue;
27
+ return;
28
+ }
29
+ progressAnim.value = withTiming(clampedValue, {
30
+ duration: 500,
31
+ easing: Easing.bezier(0, 0, 0.2, 1)
32
+ });
33
+ }, [value, disableAnimation, progressAnim]);
34
+ return progressAnim;
35
+ };
36
+
37
+ // src/components/progress/progress.style.ts
38
+ import { StyleSheet } from "react-native";
39
+ var styles = StyleSheet.create({
40
+ container: {
41
+ width: "100%"
42
+ },
43
+ track: {
44
+ width: "100%",
45
+ overflow: "hidden"
46
+ },
47
+ progress: {
48
+ height: "100%"
49
+ },
50
+ circleContainer: {
51
+ justifyContent: "center",
52
+ alignItems: "center"
53
+ }
54
+ });
55
+
56
+ // src/components/progress/circular-progress-indicator.tsx
57
+ var AnimatedCircle = Animated.createAnimatedComponent(Circle);
58
+ var CircularProgressIndicator = ({
59
+ size = 40,
60
+ color,
61
+ backgroundColor,
62
+ value,
63
+ borderRadius,
64
+ disableAnimation
65
+ }) => {
66
+ const progressAnim = useProgressAnimation(value, disableAnimation);
67
+ const strokeWidth = size * 0.1;
68
+ const radius = (size - strokeWidth) / 2;
69
+ const circumference = 2 * Math.PI * radius;
70
+ const center = size / 2;
71
+ const strokeCap = borderRadius && borderRadius > 0 ? "round" : "butt";
72
+ const animatedProps = useAnimatedProps(() => ({
73
+ strokeDashoffset: circumference * (1 - progressAnim.value)
74
+ }));
75
+ return /* @__PURE__ */ React.createElement(View, { style: [styles.circleContainer, { width: size, height: size }] }, /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, style: { transform: [{ rotate: "-90deg" }] } }, /* @__PURE__ */ React.createElement(
76
+ Circle,
77
+ {
78
+ cx: center,
79
+ cy: center,
80
+ r: radius,
81
+ stroke: backgroundColor,
82
+ strokeWidth,
83
+ fill: "none"
84
+ }
85
+ ), /* @__PURE__ */ React.createElement(
86
+ AnimatedCircle,
87
+ {
88
+ cx: center,
89
+ cy: center,
90
+ r: radius,
91
+ stroke: color,
92
+ strokeWidth,
93
+ strokeLinecap: strokeCap,
94
+ strokeDasharray: circumference,
95
+ animatedProps,
96
+ fill: "none"
97
+ }
98
+ )));
99
+ };
100
+
101
+ // src/components/progress/linear-progress-indicator.tsx
102
+ import React2 from "react";
103
+ import { View as View2 } from "react-native";
104
+ import Animated2, { useAnimatedStyle } from "react-native-reanimated";
105
+ var LinearProgressIndicator = ({
106
+ size = 4,
107
+ color,
108
+ backgroundColor,
109
+ value,
110
+ borderRadius,
111
+ disableAnimation
112
+ }) => {
113
+ const progressAnim = useProgressAnimation(value, disableAnimation);
114
+ const radius = Math.max(0, Math.min(size / 2, borderRadius ?? 0));
115
+ const animatedStyle = useAnimatedStyle(() => ({
116
+ width: `${progressAnim.value * 100}%`
117
+ }));
118
+ return /* @__PURE__ */ React2.createElement(
119
+ View2,
120
+ {
121
+ style: [
122
+ styles.track,
123
+ {
124
+ height: size,
125
+ backgroundColor,
126
+ borderRadius: radius
127
+ }
128
+ ]
129
+ },
130
+ /* @__PURE__ */ React2.createElement(
131
+ Animated2.View,
132
+ {
133
+ style: [
134
+ styles.progress,
135
+ animatedStyle,
136
+ {
137
+ backgroundColor: color,
138
+ borderRadius: radius
139
+ }
140
+ ]
141
+ }
142
+ )
143
+ );
144
+ };
145
+
146
+ // src/components/progress/progress.tsx
147
+ var Progress = (props) => {
148
+ const {
149
+ variant = "linear",
150
+ themeColor = "primary",
151
+ value,
152
+ color,
153
+ backgroundColor,
154
+ size,
155
+ disableAnimation = false
156
+ } = props;
157
+ const theme = useXUITheme();
158
+ const colorScheme = theme.colors[themeColor];
159
+ const mainColor = color ?? colorScheme.main;
160
+ const trackColor = backgroundColor ?? colorScheme.background;
161
+ const clampedValue = clampProgress(value);
162
+ const accessibilityValue = {
163
+ min: 0,
164
+ max: 100,
165
+ now: clampedValue * 100
166
+ };
167
+ if (variant === "circular") {
168
+ const circleSize = size ?? 40;
169
+ const borderRadius2 = "borderRadius" in props ? props.borderRadius : void 0;
170
+ return /* @__PURE__ */ React3.createElement(
171
+ View3,
172
+ {
173
+ style: [styles.circleContainer, { width: circleSize, height: circleSize }],
174
+ accessible: true,
175
+ accessibilityRole: "progressbar",
176
+ accessibilityValue
177
+ },
178
+ /* @__PURE__ */ React3.createElement(
179
+ CircularProgressIndicator,
180
+ {
181
+ size: circleSize,
182
+ color: mainColor,
183
+ backgroundColor: trackColor,
184
+ value: clampedValue,
185
+ borderRadius: borderRadius2,
186
+ disableAnimation
187
+ }
188
+ )
189
+ );
190
+ }
191
+ const linearSize = size ?? 4;
192
+ const borderRadius = "borderRadius" in props ? props.borderRadius : void 0;
193
+ return /* @__PURE__ */ React3.createElement(
194
+ View3,
195
+ {
196
+ style: styles.container,
197
+ accessible: true,
198
+ accessibilityRole: "progressbar",
199
+ accessibilityValue
200
+ },
201
+ /* @__PURE__ */ React3.createElement(
202
+ LinearProgressIndicator,
203
+ {
204
+ size: linearSize,
205
+ color: mainColor,
206
+ backgroundColor: trackColor,
207
+ value: clampedValue,
208
+ borderRadius,
209
+ disableAnimation
210
+ }
211
+ )
212
+ );
213
+ };
214
+ export {
215
+ Progress
216
+ };
@@ -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 };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@xaui/native",
3
+ "version": "0.0.2",
4
+ "description": "Mobile UI components for XUI",
5
+ "keywords": [
6
+ "react-native",
7
+ "mobile",
8
+ "ui",
9
+ "components",
10
+ "xaui"
11
+ ],
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.js"
20
+ },
21
+ "./core": {
22
+ "types": "./dist/core/index.d.ts",
23
+ "import": "./dist/core/index.js",
24
+ "require": "./dist/core/index.js"
25
+ },
26
+ "./button": {
27
+ "types": "./dist/button/index.d.ts",
28
+ "import": "./dist/button/index.js",
29
+ "require": "./dist/button/index.js"
30
+ },
31
+ "./progress": {
32
+ "types": "./dist/progress/index.d.ts",
33
+ "import": "./dist/progress/index.js",
34
+ "require": "./dist/progress/index.js"
35
+ },
36
+ "./indicator": {
37
+ "types": "./dist/indicator/index.d.ts",
38
+ "import": "./dist/indicator/index.js",
39
+ "require": "./dist/indicator/index.js"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "package.json"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/rygrams/xaui.git",
49
+ "directory": "packages/mobile"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup --config tsup.config.ts",
53
+ "dev": "tsup --config tsup.config.ts --watch",
54
+ "test": "vitest",
55
+ "lint": "eslint src/",
56
+ "type-check": "tsc --noEmit"
57
+ },
58
+ "dependencies": {
59
+ "@xaui/core": "workspace:*"
60
+ },
61
+ "peerDependencies": {
62
+ "react": "^18.0.0 || ^19.0.0",
63
+ "react-native": ">=0.70.0",
64
+ "react-native-reanimated": ">=4.0.0",
65
+ "react-native-svg": ">=15.0.0"
66
+ },
67
+ "devDependencies": {
68
+ "@types/react": "^19.1.0",
69
+ "@types/react-native": "^0.73.0",
70
+ "react": "19.1.0",
71
+ "react-native": "^0.81.5",
72
+ "react-native-reanimated": "^4.0.0",
73
+ "react-native-svg": "^15.8.0",
74
+ "tsup": "^8.5.1",
75
+ "typescript": "^5.9.3"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
79
+ }
80
+ }