@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.
Files changed (113) hide show
  1. package/README.md +195 -2
  2. package/dist/alert/index.js +1 -2
  3. package/dist/app-bar/index.cjs +217 -0
  4. package/dist/app-bar/index.d.cts +52 -0
  5. package/dist/app-bar/index.d.ts +52 -0
  6. package/dist/app-bar/index.js +142 -0
  7. package/dist/autocomplete/index.js +48 -36
  8. package/dist/avatar/index.js +1 -2
  9. package/dist/badge/index.js +1 -2
  10. package/dist/bottom-sheet/index.js +1 -2
  11. package/dist/bottom-tab-bar/index.cjs +571 -0
  12. package/dist/bottom-tab-bar/index.d.cts +211 -0
  13. package/dist/bottom-tab-bar/index.d.ts +211 -0
  14. package/dist/bottom-tab-bar/index.js +497 -0
  15. package/dist/button/index.d.cts +102 -5
  16. package/dist/button/index.d.ts +102 -5
  17. package/dist/button/index.js +2 -3
  18. package/dist/button.type-j1ZdkkSl.d.cts +4 -0
  19. package/dist/button.type-j1ZdkkSl.d.ts +4 -0
  20. package/dist/card/index.cjs +2 -0
  21. package/dist/card/index.d.cts +6 -1
  22. package/dist/card/index.d.ts +6 -1
  23. package/dist/card/index.js +4 -2
  24. package/dist/carousel/index.js +1 -1
  25. package/dist/chart/index.cjs +1067 -0
  26. package/dist/chart/index.d.cts +218 -0
  27. package/dist/chart/index.d.ts +218 -0
  28. package/dist/chart/index.js +1026 -0
  29. package/dist/checkbox/index.js +1 -2
  30. package/dist/chip/index.js +1 -2
  31. package/dist/chunk-3XSXTM3G.js +661 -0
  32. package/dist/chunk-4KSZLONZ.js +79 -0
  33. package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
  34. package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
  35. package/dist/chunk-I4V5Y5GD.js +76 -0
  36. package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
  37. package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
  38. package/dist/chunk-URBEEDFX.js +79 -0
  39. package/dist/core/index.js +3 -5
  40. package/dist/datepicker/index.js +1 -2
  41. package/dist/divider/index.js +2 -3
  42. package/dist/drawer/index.cjs +310 -0
  43. package/dist/drawer/index.d.cts +58 -0
  44. package/dist/drawer/index.d.ts +58 -0
  45. package/dist/drawer/index.js +236 -0
  46. package/dist/{accordion → expansion-panel}/index.cjs +45 -45
  47. package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
  48. package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
  49. package/dist/{accordion → expansion-panel}/index.js +40 -41
  50. package/dist/fab/index.d.cts +3 -3
  51. package/dist/fab/index.d.ts +3 -3
  52. package/dist/fab/index.js +3 -4
  53. package/dist/fab-menu/index.d.cts +2 -2
  54. package/dist/fab-menu/index.d.ts +2 -2
  55. package/dist/fab-menu/index.js +3 -4
  56. package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
  57. package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
  58. package/dist/feature-discovery/index.cjs +531 -0
  59. package/dist/feature-discovery/index.d.cts +82 -0
  60. package/dist/feature-discovery/index.d.ts +82 -0
  61. package/dist/feature-discovery/index.js +464 -0
  62. package/dist/indicator/index.js +2 -3
  63. package/dist/input/index.cjs +258 -164
  64. package/dist/input/index.d.cts +15 -1
  65. package/dist/input/index.d.ts +15 -1
  66. package/dist/input/index.js +219 -126
  67. package/dist/list/index.js +1 -2
  68. package/dist/menu/index.js +2 -2
  69. package/dist/menubox/index.cjs +369 -0
  70. package/dist/menubox/index.d.cts +98 -0
  71. package/dist/menubox/index.d.ts +98 -0
  72. package/dist/menubox/index.js +296 -0
  73. package/dist/pager/index.cjs +243 -0
  74. package/dist/pager/index.d.cts +93 -0
  75. package/dist/pager/index.d.ts +93 -0
  76. package/dist/pager/index.js +205 -0
  77. package/dist/progress/index.js +1 -2
  78. package/dist/radio/index.cjs +537 -0
  79. package/dist/radio/index.d.cts +145 -0
  80. package/dist/radio/index.d.ts +145 -0
  81. package/dist/radio/index.js +464 -0
  82. package/dist/segment-button/index.js +2 -2
  83. package/dist/select/index.js +22 -10
  84. package/dist/skeleton/index.js +2 -2
  85. package/dist/slider/index.cjs +655 -0
  86. package/dist/slider/index.d.cts +171 -0
  87. package/dist/slider/index.d.ts +171 -0
  88. package/dist/slider/index.js +575 -0
  89. package/dist/stepper/index.cjs +624 -0
  90. package/dist/stepper/index.d.cts +137 -0
  91. package/dist/stepper/index.d.ts +137 -0
  92. package/dist/stepper/index.js +549 -0
  93. package/dist/switch/index.js +1 -2
  94. package/dist/tabs/index.cjs +523 -0
  95. package/dist/tabs/index.d.cts +176 -0
  96. package/dist/tabs/index.d.ts +176 -0
  97. package/dist/tabs/index.js +438 -0
  98. package/dist/timepicker/index.cjs +1280 -0
  99. package/dist/timepicker/index.d.cts +215 -0
  100. package/dist/timepicker/index.d.ts +215 -0
  101. package/dist/timepicker/index.js +1181 -0
  102. package/dist/toolbar/index.cjs +395 -0
  103. package/dist/toolbar/index.d.cts +100 -0
  104. package/dist/toolbar/index.d.ts +100 -0
  105. package/dist/toolbar/index.js +325 -0
  106. package/dist/typography/index.js +1 -2
  107. package/dist/view/index.cjs +16 -2
  108. package/dist/view/index.js +16 -2
  109. package/package.json +73 -8
  110. package/dist/button.type-D8tzEBo7.d.ts +0 -104
  111. package/dist/button.type-ikaWzhIg.d.cts +0 -104
  112. package/dist/chunk-GBHQCAKW.js +0 -19
  113. 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,7 +1,2 @@
1
1
  // src/core/index.ts
2
2
  import { defaultDarkTheme, defaultTheme } from "@xaui/core/theme";
3
-
4
- export {
5
- defaultDarkTheme,
6
- defaultTheme
7
- };
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useXUITheme
3
- } from "./chunk-LTKYHG5V.js";
3
+ } from "./chunk-GHCVNQET.js";
4
4
 
5
5
  // src/components/indicator/indicator.tsx
6
6
  import React3 from "react";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useXUITheme
3
- } from "./chunk-LTKYHG5V.js";
3
+ } from "./chunk-GHCVNQET.js";
4
4
 
5
5
  // src/components/divider/divider.tsx
6
6
  import React from "react";
@@ -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
+ };
@@ -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-LTKYHG5V.js";
10
+ } from "../chunk-GHCVNQET.js";
13
11
  export {
14
12
  Portal,
15
13
  PortalHost,
@@ -1,8 +1,7 @@
1
- import "../chunk-DXXNBF5P.js";
2
1
  import {
3
2
  Portal,
4
3
  useXUITheme
5
- } from "../chunk-LTKYHG5V.js";
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";
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  Divider
3
- } from "../chunk-LUBWRVI2.js";
4
- import "../chunk-DXXNBF5P.js";
5
- import "../chunk-LTKYHG5V.js";
3
+ } from "../chunk-ULJSCNPE.js";
4
+ import "../chunk-GHCVNQET.js";
6
5
  export {
7
6
  Divider
8
7
  };
@@ -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
+ });