@xaui/native 0.0.21 → 0.0.24
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.
- package/README.md +195 -2
- package/dist/alert/index.js +1 -2
- package/dist/app-bar/index.cjs +217 -0
- package/dist/app-bar/index.d.cts +52 -0
- package/dist/app-bar/index.d.ts +52 -0
- package/dist/app-bar/index.js +142 -0
- package/dist/autocomplete/index.js +48 -36
- package/dist/avatar/index.js +1 -2
- package/dist/badge/index.js +1 -2
- package/dist/bottom-sheet/index.js +1 -2
- package/dist/bottom-tab-bar/index.cjs +571 -0
- package/dist/bottom-tab-bar/index.d.cts +211 -0
- package/dist/bottom-tab-bar/index.d.ts +211 -0
- package/dist/bottom-tab-bar/index.js +497 -0
- package/dist/button/index.d.cts +102 -5
- package/dist/button/index.d.ts +102 -5
- package/dist/button/index.js +2 -3
- package/dist/button.type-j1ZdkkSl.d.cts +4 -0
- package/dist/button.type-j1ZdkkSl.d.ts +4 -0
- package/dist/card/index.cjs +2 -0
- package/dist/card/index.d.cts +6 -1
- package/dist/card/index.d.ts +6 -1
- package/dist/card/index.js +4 -2
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +1067 -0
- package/dist/chart/index.d.cts +218 -0
- package/dist/chart/index.d.ts +218 -0
- package/dist/chart/index.js +1026 -0
- package/dist/checkbox/index.js +1 -2
- package/dist/chip/index.js +1 -2
- package/dist/chunk-3XSXTM3G.js +661 -0
- package/dist/chunk-4KSZLONZ.js +79 -0
- package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
- package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
- package/dist/chunk-I4V5Y5GD.js +76 -0
- package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
- package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
- package/dist/chunk-URBEEDFX.js +79 -0
- package/dist/core/index.js +3 -5
- package/dist/datepicker/index.js +1 -2
- package/dist/divider/index.js +2 -3
- package/dist/drawer/index.cjs +310 -0
- package/dist/drawer/index.d.cts +58 -0
- package/dist/drawer/index.d.ts +58 -0
- package/dist/drawer/index.js +236 -0
- package/dist/{accordion → expansion-panel}/index.cjs +45 -45
- package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
- package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
- package/dist/{accordion → expansion-panel}/index.js +40 -41
- package/dist/fab/index.d.cts +3 -3
- package/dist/fab/index.d.ts +3 -3
- package/dist/fab/index.js +3 -4
- package/dist/fab-menu/index.d.cts +2 -2
- package/dist/fab-menu/index.d.ts +2 -2
- package/dist/fab-menu/index.js +3 -4
- package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
- package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
- package/dist/feature-discovery/index.cjs +531 -0
- package/dist/feature-discovery/index.d.cts +82 -0
- package/dist/feature-discovery/index.d.ts +82 -0
- package/dist/feature-discovery/index.js +464 -0
- package/dist/indicator/index.js +2 -3
- package/dist/input/index.cjs +258 -164
- package/dist/input/index.d.cts +15 -1
- package/dist/input/index.d.ts +15 -1
- package/dist/input/index.js +219 -126
- package/dist/list/index.js +1 -2
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +369 -0
- package/dist/menubox/index.d.cts +98 -0
- package/dist/menubox/index.d.ts +98 -0
- package/dist/menubox/index.js +296 -0
- package/dist/pager/index.cjs +243 -0
- package/dist/pager/index.d.cts +93 -0
- package/dist/pager/index.d.ts +93 -0
- package/dist/pager/index.js +205 -0
- package/dist/progress/index.js +1 -2
- package/dist/radio/index.cjs +537 -0
- package/dist/radio/index.d.cts +145 -0
- package/dist/radio/index.d.ts +145 -0
- package/dist/radio/index.js +464 -0
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.js +22 -10
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +655 -0
- package/dist/slider/index.d.cts +171 -0
- package/dist/slider/index.d.ts +171 -0
- package/dist/slider/index.js +575 -0
- package/dist/stepper/index.cjs +624 -0
- package/dist/stepper/index.d.cts +137 -0
- package/dist/stepper/index.d.ts +137 -0
- package/dist/stepper/index.js +549 -0
- package/dist/switch/index.js +1 -2
- package/dist/tabs/index.cjs +523 -0
- package/dist/tabs/index.d.cts +176 -0
- package/dist/tabs/index.d.ts +176 -0
- package/dist/tabs/index.js +438 -0
- package/dist/timepicker/index.cjs +1280 -0
- package/dist/timepicker/index.d.cts +215 -0
- package/dist/timepicker/index.d.ts +215 -0
- package/dist/timepicker/index.js +1181 -0
- package/dist/toolbar/index.cjs +395 -0
- package/dist/toolbar/index.d.cts +100 -0
- package/dist/toolbar/index.d.ts +100 -0
- package/dist/toolbar/index.js +325 -0
- package/dist/typography/index.js +1 -2
- package/dist/view/index.cjs +16 -2
- package/dist/view/index.js +16 -2
- package/package.json +73 -8
- package/dist/button.type-D8tzEBo7.d.ts +0 -104
- package/dist/button.type-ikaWzhIg.d.cts +0 -104
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-JEGEPGVU.js +0 -287
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/core/theme-hooks.ts
|
|
2
|
+
import { useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
3
|
+
import { useColorScheme as useColorScheme2 } from "react-native";
|
|
4
|
+
|
|
5
|
+
// src/core/theme-context.tsx
|
|
6
|
+
import React3, { createContext as createContext2 } from "react";
|
|
7
|
+
import { useColorScheme } from "react-native";
|
|
8
|
+
import { defaultTheme } from "@xaui/core/theme";
|
|
9
|
+
import { colors } from "@xaui/core/palette";
|
|
10
|
+
|
|
11
|
+
// src/core/portal/portal.tsx
|
|
12
|
+
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
13
|
+
|
|
14
|
+
// src/core/portal/portal-context.ts
|
|
15
|
+
import { createContext } from "react";
|
|
16
|
+
var PortalContext = createContext(null);
|
|
17
|
+
|
|
18
|
+
// src/core/portal/portal.tsx
|
|
19
|
+
var portalId = 0;
|
|
20
|
+
var Portal = ({ children }) => {
|
|
21
|
+
const context = useContext(PortalContext);
|
|
22
|
+
const keyRef = useRef(`portal-${++portalId}`);
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
if (!context) return;
|
|
25
|
+
context.addPortal(keyRef.current, children);
|
|
26
|
+
}, [children, context]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!context) return;
|
|
29
|
+
const key = keyRef.current;
|
|
30
|
+
return () => {
|
|
31
|
+
context.removePortal(key);
|
|
32
|
+
};
|
|
33
|
+
}, [context]);
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/core/portal/portal-host.tsx
|
|
38
|
+
import React2, { useCallback, useMemo, useRef as useRef2, useState } from "react";
|
|
39
|
+
import { StyleSheet, View } from "react-native";
|
|
40
|
+
var hostStyles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
flex: 1
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/core/theme-context.tsx
|
|
47
|
+
var XUIThemeContext = createContext2(null);
|
|
48
|
+
|
|
49
|
+
// src/core/theme-hooks.ts
|
|
50
|
+
function useXUITheme() {
|
|
51
|
+
const theme = useContext2(XUIThemeContext);
|
|
52
|
+
if (!theme) {
|
|
53
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
54
|
+
}
|
|
55
|
+
return theme;
|
|
56
|
+
}
|
|
57
|
+
function useBorderRadiusStyles(radius) {
|
|
58
|
+
const theme = useXUITheme();
|
|
59
|
+
const borderRadius = useMemo2(() => {
|
|
60
|
+
const radiusMap = {
|
|
61
|
+
none: theme.borderRadius.none,
|
|
62
|
+
sm: theme.borderRadius.sm,
|
|
63
|
+
md: theme.borderRadius.md,
|
|
64
|
+
lg: theme.borderRadius.lg,
|
|
65
|
+
full: theme.borderRadius.full
|
|
66
|
+
};
|
|
67
|
+
return { borderRadius: radiusMap[radius] };
|
|
68
|
+
}, [radius, theme]);
|
|
69
|
+
return borderRadius;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/core/index.ts
|
|
73
|
+
import { defaultDarkTheme, defaultTheme as defaultTheme2 } from "@xaui/core/theme";
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
Portal,
|
|
77
|
+
useXUITheme,
|
|
78
|
+
useBorderRadiusStyles
|
|
79
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// src/core/theme-context.tsx
|
|
2
|
+
import React3, { createContext as createContext2 } from "react";
|
|
3
|
+
import { useColorScheme } from "react-native";
|
|
4
|
+
import { defaultTheme } from "@xaui/core/theme";
|
|
5
|
+
import { colors } from "@xaui/core/palette";
|
|
6
|
+
|
|
1
7
|
// src/core/portal/portal.tsx
|
|
2
8
|
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
3
9
|
|
|
@@ -51,10 +57,6 @@ var PortalHost = ({ children }) => {
|
|
|
51
57
|
};
|
|
52
58
|
|
|
53
59
|
// src/core/theme-context.tsx
|
|
54
|
-
import React3, { createContext as createContext2 } from "react";
|
|
55
|
-
import { useColorScheme } from "react-native";
|
|
56
|
-
import { defaultTheme } from "@xaui/core/theme";
|
|
57
|
-
import { colors } from "@xaui/core/palette";
|
|
58
60
|
var XUIThemeContext = createContext2(null);
|
|
59
61
|
function XUIProvider({
|
|
60
62
|
children,
|
|
@@ -126,6 +128,9 @@ function useBorderRadiusStyles(radius) {
|
|
|
126
128
|
return borderRadius;
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
// src/core/index.ts
|
|
132
|
+
import { defaultDarkTheme, defaultTheme as defaultTheme2 } from "@xaui/core/theme";
|
|
133
|
+
|
|
129
134
|
export {
|
|
130
135
|
Portal,
|
|
131
136
|
PortalHost,
|
|
@@ -134,5 +139,7 @@ export {
|
|
|
134
139
|
useXUITheme,
|
|
135
140
|
useXUIColors,
|
|
136
141
|
useXUIPalette,
|
|
137
|
-
useBorderRadiusStyles
|
|
142
|
+
useBorderRadiusStyles,
|
|
143
|
+
defaultDarkTheme,
|
|
144
|
+
defaultTheme2 as defaultTheme
|
|
138
145
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/core/portal/portal.tsx
|
|
2
|
+
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
// src/core/portal/portal-context.ts
|
|
5
|
+
import { createContext } from "react";
|
|
6
|
+
var PortalContext = createContext(null);
|
|
7
|
+
|
|
8
|
+
// src/core/portal/portal.tsx
|
|
9
|
+
var portalId = 0;
|
|
10
|
+
var Portal = ({ children }) => {
|
|
11
|
+
const context = useContext(PortalContext);
|
|
12
|
+
const keyRef = useRef(`portal-${++portalId}`);
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
if (!context) return;
|
|
15
|
+
context.addPortal(keyRef.current, children);
|
|
16
|
+
}, [children, context]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!context) return;
|
|
19
|
+
const key = keyRef.current;
|
|
20
|
+
return () => {
|
|
21
|
+
context.removePortal(key);
|
|
22
|
+
};
|
|
23
|
+
}, [context]);
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/core/theme-hooks.ts
|
|
28
|
+
import { useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
29
|
+
import { useColorScheme as useColorScheme2 } from "react-native";
|
|
30
|
+
|
|
31
|
+
// src/core/theme-context.tsx
|
|
32
|
+
import React3, { createContext as createContext2 } from "react";
|
|
33
|
+
import { useColorScheme } from "react-native";
|
|
34
|
+
import { defaultTheme } from "@xaui/core/theme";
|
|
35
|
+
import { colors } from "@xaui/core/palette";
|
|
36
|
+
|
|
37
|
+
// src/core/portal/portal-host.tsx
|
|
38
|
+
import React2, { useCallback, useMemo, useRef as useRef2, useState } from "react";
|
|
39
|
+
import { StyleSheet, View } from "react-native";
|
|
40
|
+
var hostStyles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
flex: 1
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/core/theme-context.tsx
|
|
47
|
+
var XUIThemeContext = createContext2(null);
|
|
48
|
+
|
|
49
|
+
// src/core/theme-hooks.ts
|
|
50
|
+
function useXUITheme() {
|
|
51
|
+
const theme = useContext2(XUIThemeContext);
|
|
52
|
+
if (!theme) {
|
|
53
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
54
|
+
}
|
|
55
|
+
return theme;
|
|
56
|
+
}
|
|
57
|
+
function useBorderRadiusStyles(radius) {
|
|
58
|
+
const theme = useXUITheme();
|
|
59
|
+
const borderRadius = useMemo2(() => {
|
|
60
|
+
const radiusMap = {
|
|
61
|
+
none: theme.borderRadius.none,
|
|
62
|
+
sm: theme.borderRadius.sm,
|
|
63
|
+
md: theme.borderRadius.md,
|
|
64
|
+
lg: theme.borderRadius.lg,
|
|
65
|
+
full: theme.borderRadius.full
|
|
66
|
+
};
|
|
67
|
+
return { borderRadius: radiusMap[radius] };
|
|
68
|
+
}, [radius, theme]);
|
|
69
|
+
return borderRadius;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
Portal,
|
|
74
|
+
useXUITheme,
|
|
75
|
+
useBorderRadiusStyles
|
|
76
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/core/portal/portal.tsx
|
|
2
|
+
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
// src/core/portal/portal-context.ts
|
|
5
|
+
import { createContext } from "react";
|
|
6
|
+
var PortalContext = createContext(null);
|
|
7
|
+
|
|
8
|
+
// src/core/portal/portal.tsx
|
|
9
|
+
var portalId = 0;
|
|
10
|
+
var Portal = ({ children }) => {
|
|
11
|
+
const context = useContext(PortalContext);
|
|
12
|
+
const keyRef = useRef(`portal-${++portalId}`);
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
if (!context) return;
|
|
15
|
+
context.addPortal(keyRef.current, children);
|
|
16
|
+
}, [children, context]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!context) return;
|
|
19
|
+
const key = keyRef.current;
|
|
20
|
+
return () => {
|
|
21
|
+
context.removePortal(key);
|
|
22
|
+
};
|
|
23
|
+
}, [context]);
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/core/theme-hooks.ts
|
|
28
|
+
import { useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
29
|
+
import { useColorScheme as useColorScheme2 } from "react-native";
|
|
30
|
+
|
|
31
|
+
// src/core/theme-context.tsx
|
|
32
|
+
import React3, { createContext as createContext2 } from "react";
|
|
33
|
+
import { useColorScheme } from "react-native";
|
|
34
|
+
import { defaultTheme } from "@xaui/core/theme";
|
|
35
|
+
import { colors } from "@xaui/core/palette";
|
|
36
|
+
|
|
37
|
+
// src/core/portal/portal-host.tsx
|
|
38
|
+
import React2, { useCallback, useMemo, useRef as useRef2, useState } from "react";
|
|
39
|
+
import { StyleSheet, View } from "react-native";
|
|
40
|
+
var hostStyles = StyleSheet.create({
|
|
41
|
+
container: {
|
|
42
|
+
flex: 1
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// src/core/theme-context.tsx
|
|
47
|
+
var XUIThemeContext = createContext2(null);
|
|
48
|
+
|
|
49
|
+
// src/core/theme-hooks.ts
|
|
50
|
+
function useXUITheme() {
|
|
51
|
+
const theme = useContext2(XUIThemeContext);
|
|
52
|
+
if (!theme) {
|
|
53
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
54
|
+
}
|
|
55
|
+
return theme;
|
|
56
|
+
}
|
|
57
|
+
function useBorderRadiusStyles(radius) {
|
|
58
|
+
const theme = useXUITheme();
|
|
59
|
+
const borderRadius = useMemo2(() => {
|
|
60
|
+
const radiusMap = {
|
|
61
|
+
none: theme.borderRadius.none,
|
|
62
|
+
sm: theme.borderRadius.sm,
|
|
63
|
+
md: theme.borderRadius.md,
|
|
64
|
+
lg: theme.borderRadius.lg,
|
|
65
|
+
full: theme.borderRadius.full
|
|
66
|
+
};
|
|
67
|
+
return { borderRadius: radiusMap[radius] };
|
|
68
|
+
}, [radius, theme]);
|
|
69
|
+
return borderRadius;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/core/index.ts
|
|
73
|
+
import { defaultDarkTheme, defaultTheme as defaultTheme2 } from "@xaui/core/theme";
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
Portal,
|
|
77
|
+
useXUITheme,
|
|
78
|
+
useBorderRadiusStyles
|
|
79
|
+
};
|
package/dist/core/index.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultDarkTheme,
|
|
3
|
-
defaultTheme
|
|
4
|
-
} from "../chunk-DXXNBF5P.js";
|
|
5
1
|
import {
|
|
6
2
|
Portal,
|
|
7
3
|
PortalHost,
|
|
8
4
|
XUIProvider,
|
|
5
|
+
defaultDarkTheme,
|
|
6
|
+
defaultTheme,
|
|
9
7
|
useColorMode,
|
|
10
8
|
useXUIColors,
|
|
11
9
|
useXUITheme
|
|
12
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-GHCVNQET.js";
|
|
13
11
|
export {
|
|
14
12
|
Portal,
|
|
15
13
|
PortalHost,
|
package/dist/datepicker/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "../chunk-DXXNBF5P.js";
|
|
2
1
|
import {
|
|
3
2
|
Portal,
|
|
4
3
|
useXUITheme
|
|
5
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-URBEEDFX.js";
|
|
6
5
|
|
|
7
6
|
// src/components/datepicker/datepicker.tsx
|
|
8
7
|
import React7, { useCallback as useCallback5, useMemo as useMemo6, useRef as useRef6 } from "react";
|
package/dist/divider/index.js
CHANGED
|
@@ -0,0 +1,310 @@
|
|
|
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/drawer/index.ts
|
|
31
|
+
var drawer_exports = {};
|
|
32
|
+
__export(drawer_exports, {
|
|
33
|
+
Drawer: () => Drawer
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(drawer_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/drawer/drawer.tsx
|
|
38
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
39
|
+
var import_react_native5 = require("react-native");
|
|
40
|
+
|
|
41
|
+
// src/components/drawer/drawer.hook.ts
|
|
42
|
+
var import_react6 = require("react");
|
|
43
|
+
var import_core = require("@xaui/core");
|
|
44
|
+
|
|
45
|
+
// src/core/theme-context.tsx
|
|
46
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
47
|
+
var import_react_native2 = require("react-native");
|
|
48
|
+
var import_theme = require("@xaui/core/theme");
|
|
49
|
+
var import_palette = require("@xaui/core/palette");
|
|
50
|
+
|
|
51
|
+
// src/core/portal/portal.tsx
|
|
52
|
+
var import_react2 = require("react");
|
|
53
|
+
|
|
54
|
+
// src/core/portal/portal-context.ts
|
|
55
|
+
var import_react = require("react");
|
|
56
|
+
var PortalContext = (0, import_react.createContext)(null);
|
|
57
|
+
|
|
58
|
+
// src/core/portal/portal-host.tsx
|
|
59
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
60
|
+
var import_react_native = require("react-native");
|
|
61
|
+
var hostStyles = import_react_native.StyleSheet.create({
|
|
62
|
+
container: {
|
|
63
|
+
flex: 1
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// src/core/theme-context.tsx
|
|
68
|
+
var XUIThemeContext = (0, import_react4.createContext)(null);
|
|
69
|
+
|
|
70
|
+
// src/core/theme-hooks.ts
|
|
71
|
+
var import_react5 = require("react");
|
|
72
|
+
var import_react_native3 = require("react-native");
|
|
73
|
+
function useXUITheme() {
|
|
74
|
+
const theme = (0, import_react5.useContext)(XUIThemeContext);
|
|
75
|
+
if (!theme) {
|
|
76
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
77
|
+
}
|
|
78
|
+
return theme;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/core/index.ts
|
|
82
|
+
var import_theme2 = require("@xaui/core/theme");
|
|
83
|
+
|
|
84
|
+
// src/components/drawer/drawer.hook.ts
|
|
85
|
+
var useDrawerStyles = (themeColor, position, width, height) => {
|
|
86
|
+
const theme = useXUITheme();
|
|
87
|
+
return (0, import_react6.useMemo)(() => {
|
|
88
|
+
const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
|
|
89
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
90
|
+
const isDefaultThemeColor = safeThemeColor === "default";
|
|
91
|
+
const defaultBackgroundColor = theme.mode === "dark" ? theme.colors.default.background : "#FFFFFF";
|
|
92
|
+
const backgroundColor = isDefaultThemeColor ? defaultBackgroundColor : colorScheme.background;
|
|
93
|
+
const sizeStyle = position === "left" || position === "right" ? { width } : { height };
|
|
94
|
+
return {
|
|
95
|
+
backgroundColor,
|
|
96
|
+
...sizeStyle
|
|
97
|
+
};
|
|
98
|
+
}, [height, position, theme, themeColor, width]);
|
|
99
|
+
};
|
|
100
|
+
var getTranslateValue = (position, size) => {
|
|
101
|
+
switch (position) {
|
|
102
|
+
case "left":
|
|
103
|
+
return { x: -size, y: 0 };
|
|
104
|
+
case "right":
|
|
105
|
+
return { x: size, y: 0 };
|
|
106
|
+
case "top":
|
|
107
|
+
return { x: 0, y: -size };
|
|
108
|
+
case "bottom":
|
|
109
|
+
return { x: 0, y: size };
|
|
110
|
+
default:
|
|
111
|
+
return { x: -size, y: 0 };
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/components/drawer/drawer.style.ts
|
|
116
|
+
var import_react_native4 = require("react-native");
|
|
117
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
118
|
+
overlay: {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
top: 0,
|
|
121
|
+
left: 0,
|
|
122
|
+
right: 0,
|
|
123
|
+
bottom: 0,
|
|
124
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
125
|
+
},
|
|
126
|
+
drawerContainer: {
|
|
127
|
+
position: "absolute",
|
|
128
|
+
backgroundColor: "#ffffff"
|
|
129
|
+
},
|
|
130
|
+
drawerLeft: {
|
|
131
|
+
top: 0,
|
|
132
|
+
left: 0,
|
|
133
|
+
bottom: 0
|
|
134
|
+
},
|
|
135
|
+
drawerRight: {
|
|
136
|
+
top: 0,
|
|
137
|
+
right: 0,
|
|
138
|
+
bottom: 0
|
|
139
|
+
},
|
|
140
|
+
drawerTop: {
|
|
141
|
+
top: 0,
|
|
142
|
+
left: 0,
|
|
143
|
+
right: 0
|
|
144
|
+
},
|
|
145
|
+
drawerBottom: {
|
|
146
|
+
bottom: 0,
|
|
147
|
+
left: 0,
|
|
148
|
+
right: 0
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// src/components/drawer/drawer.tsx
|
|
153
|
+
var Drawer = ({
|
|
154
|
+
children,
|
|
155
|
+
isOpen,
|
|
156
|
+
position = "left",
|
|
157
|
+
themeColor = "default",
|
|
158
|
+
width = 280,
|
|
159
|
+
height = 280,
|
|
160
|
+
showOverlay = true,
|
|
161
|
+
onClose,
|
|
162
|
+
customStyle,
|
|
163
|
+
disableAnimation = false
|
|
164
|
+
}) => {
|
|
165
|
+
const DRAWER_ANIMATION_DURATION = 250;
|
|
166
|
+
const [isModalMounted, setIsModalMounted] = (0, import_react7.useState)(false);
|
|
167
|
+
const [isModalVisible, setIsModalVisible] = (0, import_react7.useState)(false);
|
|
168
|
+
const isModalMountedRef = (0, import_react7.useRef)(false);
|
|
169
|
+
const animationRef = (0, import_react7.useRef)(null);
|
|
170
|
+
const size = position === "left" || position === "right" ? width : height;
|
|
171
|
+
const initialTranslateValues = (0, import_react7.useMemo)(
|
|
172
|
+
() => getTranslateValue(position, size),
|
|
173
|
+
[position, size]
|
|
174
|
+
);
|
|
175
|
+
const translateX = (0, import_react7.useRef)(new import_react_native5.Animated.Value(initialTranslateValues.x)).current;
|
|
176
|
+
const translateY = (0, import_react7.useRef)(new import_react_native5.Animated.Value(initialTranslateValues.y)).current;
|
|
177
|
+
const overlayOpacity = (0, import_react7.useRef)(new import_react_native5.Animated.Value(0)).current;
|
|
178
|
+
const containerStyle = useDrawerStyles(themeColor, position, width, height);
|
|
179
|
+
const positionStyle = position === "left" ? styles.drawerLeft : position === "right" ? styles.drawerRight : position === "top" ? styles.drawerTop : styles.drawerBottom;
|
|
180
|
+
(0, import_react7.useEffect)(() => {
|
|
181
|
+
const translateValues = getTranslateValue(position, size);
|
|
182
|
+
if (animationRef.current) {
|
|
183
|
+
animationRef.current.stop();
|
|
184
|
+
animationRef.current = null;
|
|
185
|
+
}
|
|
186
|
+
if (isOpen) {
|
|
187
|
+
if (!isModalMountedRef.current) {
|
|
188
|
+
translateX.setValue(translateValues.x);
|
|
189
|
+
translateY.setValue(translateValues.y);
|
|
190
|
+
overlayOpacity.setValue(0);
|
|
191
|
+
isModalMountedRef.current = true;
|
|
192
|
+
setIsModalMounted(true);
|
|
193
|
+
setIsModalVisible(true);
|
|
194
|
+
}
|
|
195
|
+
if (disableAnimation) {
|
|
196
|
+
translateX.setValue(0);
|
|
197
|
+
translateY.setValue(0);
|
|
198
|
+
overlayOpacity.setValue(1);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const animation2 = import_react_native5.Animated.parallel([
|
|
202
|
+
import_react_native5.Animated.timing(translateX, {
|
|
203
|
+
toValue: 0,
|
|
204
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
205
|
+
easing: import_react_native5.Easing.out(import_react_native5.Easing.cubic),
|
|
206
|
+
useNativeDriver: true
|
|
207
|
+
}),
|
|
208
|
+
import_react_native5.Animated.timing(translateY, {
|
|
209
|
+
toValue: 0,
|
|
210
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
211
|
+
easing: import_react_native5.Easing.out(import_react_native5.Easing.cubic),
|
|
212
|
+
useNativeDriver: true
|
|
213
|
+
}),
|
|
214
|
+
import_react_native5.Animated.timing(overlayOpacity, {
|
|
215
|
+
toValue: 1,
|
|
216
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
217
|
+
useNativeDriver: true
|
|
218
|
+
})
|
|
219
|
+
]);
|
|
220
|
+
animationRef.current = animation2;
|
|
221
|
+
animation2.start(() => {
|
|
222
|
+
if (animationRef.current === animation2) {
|
|
223
|
+
animationRef.current = null;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (!isModalMountedRef.current) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (disableAnimation) {
|
|
232
|
+
translateX.setValue(translateValues.x);
|
|
233
|
+
translateY.setValue(translateValues.y);
|
|
234
|
+
overlayOpacity.setValue(0);
|
|
235
|
+
isModalMountedRef.current = false;
|
|
236
|
+
setIsModalVisible(false);
|
|
237
|
+
setIsModalMounted(false);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const animation = import_react_native5.Animated.parallel([
|
|
241
|
+
import_react_native5.Animated.timing(translateX, {
|
|
242
|
+
toValue: translateValues.x,
|
|
243
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
244
|
+
easing: import_react_native5.Easing.in(import_react_native5.Easing.cubic),
|
|
245
|
+
useNativeDriver: true
|
|
246
|
+
}),
|
|
247
|
+
import_react_native5.Animated.timing(translateY, {
|
|
248
|
+
toValue: translateValues.y,
|
|
249
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
250
|
+
easing: import_react_native5.Easing.in(import_react_native5.Easing.cubic),
|
|
251
|
+
useNativeDriver: true
|
|
252
|
+
}),
|
|
253
|
+
import_react_native5.Animated.timing(overlayOpacity, {
|
|
254
|
+
toValue: 0,
|
|
255
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
256
|
+
useNativeDriver: true
|
|
257
|
+
})
|
|
258
|
+
]);
|
|
259
|
+
animationRef.current = animation;
|
|
260
|
+
animation.start(({ finished }) => {
|
|
261
|
+
if (animationRef.current === animation) {
|
|
262
|
+
animationRef.current = null;
|
|
263
|
+
}
|
|
264
|
+
if (finished) {
|
|
265
|
+
isModalMountedRef.current = false;
|
|
266
|
+
setIsModalVisible(false);
|
|
267
|
+
setIsModalMounted(false);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}, [
|
|
271
|
+
isOpen,
|
|
272
|
+
position,
|
|
273
|
+
size,
|
|
274
|
+
disableAnimation,
|
|
275
|
+
translateX,
|
|
276
|
+
translateY,
|
|
277
|
+
overlayOpacity
|
|
278
|
+
]);
|
|
279
|
+
if (!isModalMounted) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
283
|
+
import_react_native5.Modal,
|
|
284
|
+
{
|
|
285
|
+
transparent: true,
|
|
286
|
+
visible: isModalVisible,
|
|
287
|
+
animationType: "none",
|
|
288
|
+
onRequestClose: onClose
|
|
289
|
+
},
|
|
290
|
+
/* @__PURE__ */ import_react7.default.createElement(import_react_native5.View, { style: { flex: 1 } }, showOverlay && /* @__PURE__ */ import_react7.default.createElement(import_react_native5.Pressable, { onPress: onClose, style: { flex: 1 } }, /* @__PURE__ */ import_react7.default.createElement(import_react_native5.Animated.View, { style: [styles.overlay, { opacity: overlayOpacity }] })), /* @__PURE__ */ import_react7.default.createElement(
|
|
291
|
+
import_react_native5.Animated.View,
|
|
292
|
+
{
|
|
293
|
+
style: [
|
|
294
|
+
styles.drawerContainer,
|
|
295
|
+
positionStyle,
|
|
296
|
+
containerStyle,
|
|
297
|
+
{
|
|
298
|
+
transform: [{ translateX }, { translateY }]
|
|
299
|
+
},
|
|
300
|
+
customStyle
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
children
|
|
304
|
+
))
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
308
|
+
0 && (module.exports = {
|
|
309
|
+
Drawer
|
|
310
|
+
});
|