@xaui/native 0.0.18 → 0.0.19
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.
|
@@ -183,7 +183,7 @@ function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
|
|
|
183
183
|
const variants = {
|
|
184
184
|
outlined: {
|
|
185
185
|
containerBackground: "transparent",
|
|
186
|
-
containerBorderWidth: theme.borderWidth.
|
|
186
|
+
containerBorderWidth: theme.borderWidth.md,
|
|
187
187
|
containerBorderColor: colorScheme.main,
|
|
188
188
|
selectedBackground: selectedBackgroundColor,
|
|
189
189
|
unselectedBackground: "transparent",
|
|
@@ -210,7 +210,7 @@ function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
|
|
|
210
210
|
},
|
|
211
211
|
faded: {
|
|
212
212
|
containerBackground: `${colorScheme.background}95`,
|
|
213
|
-
containerBorderWidth: theme.borderWidth.
|
|
213
|
+
containerBorderWidth: theme.borderWidth.md,
|
|
214
214
|
containerBorderColor: `${colorScheme.main}90`,
|
|
215
215
|
selectedBackground: selectedBackgroundColor,
|
|
216
216
|
unselectedBackground: "transparent",
|
|
@@ -97,7 +97,7 @@ function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
|
|
|
97
97
|
const variants = {
|
|
98
98
|
outlined: {
|
|
99
99
|
containerBackground: "transparent",
|
|
100
|
-
containerBorderWidth: theme.borderWidth.
|
|
100
|
+
containerBorderWidth: theme.borderWidth.md,
|
|
101
101
|
containerBorderColor: colorScheme.main,
|
|
102
102
|
selectedBackground: selectedBackgroundColor,
|
|
103
103
|
unselectedBackground: "transparent",
|
|
@@ -124,7 +124,7 @@ function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
|
|
|
124
124
|
},
|
|
125
125
|
faded: {
|
|
126
126
|
containerBackground: `${colorScheme.background}95`,
|
|
127
|
-
containerBorderWidth: theme.borderWidth.
|
|
127
|
+
containerBorderWidth: theme.borderWidth.md,
|
|
128
128
|
containerBorderColor: `${colorScheme.main}90`,
|
|
129
129
|
selectedBackground: selectedBackgroundColor,
|
|
130
130
|
unselectedBackground: "transparent",
|
|
@@ -0,0 +1,160 @@
|
|
|
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/skeleton/index.ts
|
|
31
|
+
var skeleton_exports = {};
|
|
32
|
+
__export(skeleton_exports, {
|
|
33
|
+
Skeleton: () => Skeleton
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(skeleton_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/skeleton/skeleton.tsx
|
|
38
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
39
|
+
var import_react_native5 = require("react-native");
|
|
40
|
+
|
|
41
|
+
// src/components/skeleton/skeleton.style.ts
|
|
42
|
+
var import_react_native = require("react-native");
|
|
43
|
+
var styles = import_react_native.StyleSheet.create({
|
|
44
|
+
skeleton: {
|
|
45
|
+
width: "100%",
|
|
46
|
+
height: 16,
|
|
47
|
+
borderRadius: 8,
|
|
48
|
+
overflow: "hidden"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/core/theme-context.tsx
|
|
53
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
54
|
+
var import_react_native3 = require("react-native");
|
|
55
|
+
var import_theme = require("@xaui/core/theme");
|
|
56
|
+
var import_palette = require("@xaui/core/palette");
|
|
57
|
+
|
|
58
|
+
// src/core/portal/portal.tsx
|
|
59
|
+
var import_react2 = require("react");
|
|
60
|
+
|
|
61
|
+
// src/core/portal/portal-context.ts
|
|
62
|
+
var import_react = require("react");
|
|
63
|
+
var PortalContext = (0, import_react.createContext)(null);
|
|
64
|
+
|
|
65
|
+
// src/core/portal/portal-host.tsx
|
|
66
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
67
|
+
var import_react_native2 = require("react-native");
|
|
68
|
+
var hostStyles = import_react_native2.StyleSheet.create({
|
|
69
|
+
container: {
|
|
70
|
+
flex: 1
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// src/core/theme-context.tsx
|
|
75
|
+
var XUIThemeContext = (0, import_react4.createContext)(null);
|
|
76
|
+
|
|
77
|
+
// src/core/theme-hooks.ts
|
|
78
|
+
var import_react5 = require("react");
|
|
79
|
+
var import_react_native4 = require("react-native");
|
|
80
|
+
function useXUITheme() {
|
|
81
|
+
const theme = (0, import_react5.useContext)(XUIThemeContext);
|
|
82
|
+
if (!theme) {
|
|
83
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
84
|
+
}
|
|
85
|
+
return theme;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/core/index.ts
|
|
89
|
+
var import_theme2 = require("@xaui/core/theme");
|
|
90
|
+
|
|
91
|
+
// src/components/skeleton/skeleton.tsx
|
|
92
|
+
var Skeleton = ({
|
|
93
|
+
children,
|
|
94
|
+
isLoaded,
|
|
95
|
+
disableAnimation = false,
|
|
96
|
+
skeletonColor,
|
|
97
|
+
width,
|
|
98
|
+
height,
|
|
99
|
+
radius = "md",
|
|
100
|
+
style
|
|
101
|
+
}) => {
|
|
102
|
+
const theme = useXUITheme();
|
|
103
|
+
const opacity = (0, import_react6.useRef)(new import_react_native5.Animated.Value(0.6)).current;
|
|
104
|
+
const resolvedColor = (0, import_react6.useMemo)(
|
|
105
|
+
() => skeletonColor ?? theme.colors.default.background,
|
|
106
|
+
[skeletonColor, theme.colors.default.background]
|
|
107
|
+
);
|
|
108
|
+
const resolvedRadius = (0, import_react6.useMemo)(
|
|
109
|
+
() => theme.borderRadius[radius],
|
|
110
|
+
[radius, theme.borderRadius]
|
|
111
|
+
);
|
|
112
|
+
(0, import_react6.useEffect)(() => {
|
|
113
|
+
if (isLoaded || disableAnimation) {
|
|
114
|
+
opacity.setValue(1);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const loop = import_react_native5.Animated.loop(
|
|
118
|
+
import_react_native5.Animated.sequence([
|
|
119
|
+
import_react_native5.Animated.timing(opacity, {
|
|
120
|
+
toValue: 0.35,
|
|
121
|
+
duration: 700,
|
|
122
|
+
useNativeDriver: true
|
|
123
|
+
}),
|
|
124
|
+
import_react_native5.Animated.timing(opacity, {
|
|
125
|
+
toValue: 0.9,
|
|
126
|
+
duration: 700,
|
|
127
|
+
useNativeDriver: true
|
|
128
|
+
})
|
|
129
|
+
])
|
|
130
|
+
);
|
|
131
|
+
loop.start();
|
|
132
|
+
return () => {
|
|
133
|
+
loop.stop();
|
|
134
|
+
};
|
|
135
|
+
}, [disableAnimation, isLoaded, opacity]);
|
|
136
|
+
if (isLoaded) {
|
|
137
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, children);
|
|
138
|
+
}
|
|
139
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
140
|
+
import_react_native5.Animated.View,
|
|
141
|
+
{
|
|
142
|
+
style: [
|
|
143
|
+
styles.skeleton,
|
|
144
|
+
{
|
|
145
|
+
backgroundColor: resolvedColor,
|
|
146
|
+
width,
|
|
147
|
+
height,
|
|
148
|
+
borderRadius: resolvedRadius,
|
|
149
|
+
opacity
|
|
150
|
+
},
|
|
151
|
+
style
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
Skeleton.displayName = "Skeleton";
|
|
157
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
+
0 && (module.exports = {
|
|
159
|
+
Skeleton
|
|
160
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ColorValue, DimensionValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { R as Radius } from '../index-BOw6tbkc.cjs';
|
|
4
|
+
|
|
5
|
+
type SkeletonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The content to display when loading completes.
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the content is loaded.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
isLoaded: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to disable the animation.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
disableAnimation?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom background color for the skeleton.
|
|
22
|
+
*/
|
|
23
|
+
skeletonColor?: ColorValue;
|
|
24
|
+
/**
|
|
25
|
+
* Width of the skeleton.
|
|
26
|
+
*/
|
|
27
|
+
width?: DimensionValue;
|
|
28
|
+
/**
|
|
29
|
+
* Height of the skeleton.
|
|
30
|
+
*/
|
|
31
|
+
height?: DimensionValue;
|
|
32
|
+
/**
|
|
33
|
+
* Border radius of the skeleton.
|
|
34
|
+
* @default 'md'
|
|
35
|
+
*/
|
|
36
|
+
radius?: Radius;
|
|
37
|
+
/**
|
|
38
|
+
* Custom style for the skeleton container.
|
|
39
|
+
*/
|
|
40
|
+
style?: StyleProp<ViewStyle>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
declare const Skeleton: React.FC<SkeletonProps>;
|
|
44
|
+
|
|
45
|
+
export { Skeleton, type SkeletonProps };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ColorValue, DimensionValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { R as Radius } from '../index-BOw6tbkc.js';
|
|
4
|
+
|
|
5
|
+
type SkeletonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The content to display when loading completes.
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the content is loaded.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
isLoaded: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to disable the animation.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
disableAnimation?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom background color for the skeleton.
|
|
22
|
+
*/
|
|
23
|
+
skeletonColor?: ColorValue;
|
|
24
|
+
/**
|
|
25
|
+
* Width of the skeleton.
|
|
26
|
+
*/
|
|
27
|
+
width?: DimensionValue;
|
|
28
|
+
/**
|
|
29
|
+
* Height of the skeleton.
|
|
30
|
+
*/
|
|
31
|
+
height?: DimensionValue;
|
|
32
|
+
/**
|
|
33
|
+
* Border radius of the skeleton.
|
|
34
|
+
* @default 'md'
|
|
35
|
+
*/
|
|
36
|
+
radius?: Radius;
|
|
37
|
+
/**
|
|
38
|
+
* Custom style for the skeleton container.
|
|
39
|
+
*/
|
|
40
|
+
style?: StyleProp<ViewStyle>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
declare const Skeleton: React.FC<SkeletonProps>;
|
|
44
|
+
|
|
45
|
+
export { Skeleton, type SkeletonProps };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import "../chunk-DXXNBF5P.js";
|
|
2
|
+
import {
|
|
3
|
+
useXUITheme
|
|
4
|
+
} from "../chunk-LTKYHG5V.js";
|
|
5
|
+
|
|
6
|
+
// src/components/skeleton/skeleton.tsx
|
|
7
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
8
|
+
import { Animated } from "react-native";
|
|
9
|
+
|
|
10
|
+
// src/components/skeleton/skeleton.style.ts
|
|
11
|
+
import { StyleSheet } from "react-native";
|
|
12
|
+
var styles = StyleSheet.create({
|
|
13
|
+
skeleton: {
|
|
14
|
+
width: "100%",
|
|
15
|
+
height: 16,
|
|
16
|
+
borderRadius: 8,
|
|
17
|
+
overflow: "hidden"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// src/components/skeleton/skeleton.tsx
|
|
22
|
+
var Skeleton = ({
|
|
23
|
+
children,
|
|
24
|
+
isLoaded,
|
|
25
|
+
disableAnimation = false,
|
|
26
|
+
skeletonColor,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
radius = "md",
|
|
30
|
+
style
|
|
31
|
+
}) => {
|
|
32
|
+
const theme = useXUITheme();
|
|
33
|
+
const opacity = useRef(new Animated.Value(0.6)).current;
|
|
34
|
+
const resolvedColor = useMemo(
|
|
35
|
+
() => skeletonColor ?? theme.colors.default.background,
|
|
36
|
+
[skeletonColor, theme.colors.default.background]
|
|
37
|
+
);
|
|
38
|
+
const resolvedRadius = useMemo(
|
|
39
|
+
() => theme.borderRadius[radius],
|
|
40
|
+
[radius, theme.borderRadius]
|
|
41
|
+
);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isLoaded || disableAnimation) {
|
|
44
|
+
opacity.setValue(1);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const loop = Animated.loop(
|
|
48
|
+
Animated.sequence([
|
|
49
|
+
Animated.timing(opacity, {
|
|
50
|
+
toValue: 0.35,
|
|
51
|
+
duration: 700,
|
|
52
|
+
useNativeDriver: true
|
|
53
|
+
}),
|
|
54
|
+
Animated.timing(opacity, {
|
|
55
|
+
toValue: 0.9,
|
|
56
|
+
duration: 700,
|
|
57
|
+
useNativeDriver: true
|
|
58
|
+
})
|
|
59
|
+
])
|
|
60
|
+
);
|
|
61
|
+
loop.start();
|
|
62
|
+
return () => {
|
|
63
|
+
loop.stop();
|
|
64
|
+
};
|
|
65
|
+
}, [disableAnimation, isLoaded, opacity]);
|
|
66
|
+
if (isLoaded) {
|
|
67
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
68
|
+
}
|
|
69
|
+
return /* @__PURE__ */ React.createElement(
|
|
70
|
+
Animated.View,
|
|
71
|
+
{
|
|
72
|
+
style: [
|
|
73
|
+
styles.skeleton,
|
|
74
|
+
{
|
|
75
|
+
backgroundColor: resolvedColor,
|
|
76
|
+
width,
|
|
77
|
+
height,
|
|
78
|
+
borderRadius: resolvedRadius,
|
|
79
|
+
opacity
|
|
80
|
+
},
|
|
81
|
+
style
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
Skeleton.displayName = "Skeleton";
|
|
87
|
+
export {
|
|
88
|
+
Skeleton
|
|
89
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaui/native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
"import": "./dist/divider/index.js",
|
|
68
68
|
"require": "./dist/divider/index.js"
|
|
69
69
|
},
|
|
70
|
+
"./skeleton": {
|
|
71
|
+
"types": "./dist/skeleton/index.d.ts",
|
|
72
|
+
"import": "./dist/skeleton/index.js",
|
|
73
|
+
"require": "./dist/skeleton/index.js"
|
|
74
|
+
},
|
|
70
75
|
"./avatar": {
|
|
71
76
|
"types": "./dist/avatar/index.d.ts",
|
|
72
77
|
"import": "./dist/avatar/index.js",
|