@xaui/native 0.2.7 → 0.9.1-alpha.0

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 (224) hide show
  1. package/dist/chunk-JDS6KGCM.cjs +791 -0
  2. package/dist/chunk-T3ZI2PZ6.js +791 -0
  3. package/dist/index.cjs +32 -1
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +32 -0
  7. package/dist/theme/index.cjs +32 -0
  8. package/dist/theme/index.d.cts +669 -0
  9. package/dist/theme/index.d.ts +669 -0
  10. package/dist/theme/index.js +32 -0
  11. package/package.json +26 -249
  12. package/README.md +0 -178
  13. package/dist/alert/index.cjs +0 -356
  14. package/dist/alert/index.d.cts +0 -90
  15. package/dist/alert/index.d.ts +0 -90
  16. package/dist/alert/index.js +0 -356
  17. package/dist/app-bar/index.cjs +0 -148
  18. package/dist/app-bar/index.d.cts +0 -59
  19. package/dist/app-bar/index.d.ts +0 -59
  20. package/dist/app-bar/index.js +0 -148
  21. package/dist/autocomplete/index.cjs +0 -1122
  22. package/dist/autocomplete/index.d.cts +0 -88
  23. package/dist/autocomplete/index.d.ts +0 -88
  24. package/dist/autocomplete/index.js +0 -1122
  25. package/dist/avatar/index.cjs +0 -281
  26. package/dist/avatar/index.d.cts +0 -123
  27. package/dist/avatar/index.d.ts +0 -123
  28. package/dist/avatar/index.js +0 -281
  29. package/dist/badge/index.cjs +0 -197
  30. package/dist/badge/index.d.cts +0 -94
  31. package/dist/badge/index.d.ts +0 -94
  32. package/dist/badge/index.js +0 -197
  33. package/dist/bottom-sheet/index.cjs +0 -9
  34. package/dist/bottom-sheet/index.d.cts +0 -84
  35. package/dist/bottom-sheet/index.d.ts +0 -84
  36. package/dist/bottom-sheet/index.js +0 -9
  37. package/dist/bottom-tab-bar/index.cjs +0 -497
  38. package/dist/bottom-tab-bar/index.d.cts +0 -211
  39. package/dist/bottom-tab-bar/index.d.ts +0 -211
  40. package/dist/bottom-tab-bar/index.js +0 -497
  41. package/dist/button/index.cjs +0 -392
  42. package/dist/button/index.d.cts +0 -174
  43. package/dist/button/index.d.ts +0 -174
  44. package/dist/button/index.js +0 -392
  45. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  46. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  47. package/dist/card/index.cjs +0 -338
  48. package/dist/card/index.d.cts +0 -191
  49. package/dist/card/index.d.ts +0 -191
  50. package/dist/card/index.js +0 -338
  51. package/dist/carousel/index.cjs +0 -381
  52. package/dist/carousel/index.d.cts +0 -147
  53. package/dist/carousel/index.d.ts +0 -147
  54. package/dist/carousel/index.js +0 -381
  55. package/dist/chart/index.cjs +0 -1026
  56. package/dist/chart/index.d.cts +0 -218
  57. package/dist/chart/index.d.ts +0 -218
  58. package/dist/chart/index.js +0 -1026
  59. package/dist/checkbox/index.cjs +0 -443
  60. package/dist/checkbox/index.d.cts +0 -73
  61. package/dist/checkbox/index.d.ts +0 -73
  62. package/dist/checkbox/index.js +0 -443
  63. package/dist/chip/index.cjs +0 -503
  64. package/dist/chip/index.d.cts +0 -195
  65. package/dist/chip/index.d.ts +0 -195
  66. package/dist/chip/index.js +0 -503
  67. package/dist/chunk-4JFWQ5XT.js +0 -368
  68. package/dist/chunk-56RPWZD2.cjs +0 -9
  69. package/dist/chunk-7UFBLUMV.cjs +0 -136
  70. package/dist/chunk-A45TVXU5.js +0 -337
  71. package/dist/chunk-BYWUAPC4.cjs +0 -368
  72. package/dist/chunk-DECMUMCI.js +0 -0
  73. package/dist/chunk-DHSTKO3K.cjs +0 -19
  74. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  75. package/dist/chunk-EUQDGTST.cjs +0 -1
  76. package/dist/chunk-GBHQCAKW.js +0 -19
  77. package/dist/chunk-RBSA4NH4.js +0 -136
  78. package/dist/chunk-SHBDANQN.js +0 -9
  79. package/dist/chunk-UGEINZM7.cjs +0 -290
  80. package/dist/chunk-UU4HHBDN.js +0 -290
  81. package/dist/chunk-VSZEXOUN.js +0 -384
  82. package/dist/chunk-YIEUN3G5.cjs +0 -384
  83. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  84. package/dist/chunk-ZY7IUTAT.js +0 -75
  85. package/dist/color-picker/index.cjs +0 -457
  86. package/dist/color-picker/index.d.cts +0 -124
  87. package/dist/color-picker/index.d.ts +0 -124
  88. package/dist/color-picker/index.js +0 -457
  89. package/dist/core/index.cjs +0 -24
  90. package/dist/core/index.d.cts +0 -28
  91. package/dist/core/index.d.ts +0 -28
  92. package/dist/core/index.js +0 -24
  93. package/dist/datepicker/index.cjs +0 -1625
  94. package/dist/datepicker/index.d.cts +0 -45
  95. package/dist/datepicker/index.d.ts +0 -45
  96. package/dist/datepicker/index.js +0 -1625
  97. package/dist/dialog/index.cjs +0 -372
  98. package/dist/dialog/index.d.cts +0 -151
  99. package/dist/dialog/index.d.ts +0 -151
  100. package/dist/dialog/index.js +0 -372
  101. package/dist/divider/index.cjs +0 -8
  102. package/dist/divider/index.d.cts +0 -30
  103. package/dist/divider/index.d.ts +0 -30
  104. package/dist/divider/index.js +0 -8
  105. package/dist/drawer/index.cjs +0 -237
  106. package/dist/drawer/index.d.cts +0 -58
  107. package/dist/drawer/index.d.ts +0 -58
  108. package/dist/drawer/index.js +0 -237
  109. package/dist/expansion-panel/index.cjs +0 -441
  110. package/dist/expansion-panel/index.d.cts +0 -153
  111. package/dist/expansion-panel/index.d.ts +0 -153
  112. package/dist/expansion-panel/index.js +0 -441
  113. package/dist/fab/index.cjs +0 -9
  114. package/dist/fab/index.d.cts +0 -10
  115. package/dist/fab/index.d.ts +0 -10
  116. package/dist/fab/index.js +0 -9
  117. package/dist/fab-menu/index.cjs +0 -330
  118. package/dist/fab-menu/index.d.cts +0 -125
  119. package/dist/fab-menu/index.d.ts +0 -125
  120. package/dist/fab-menu/index.js +0 -330
  121. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  122. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  123. package/dist/feature-discovery/index.cjs +0 -464
  124. package/dist/feature-discovery/index.d.cts +0 -82
  125. package/dist/feature-discovery/index.d.ts +0 -82
  126. package/dist/feature-discovery/index.js +0 -464
  127. package/dist/indicator/index.cjs +0 -8
  128. package/dist/indicator/index.d.cts +0 -47
  129. package/dist/indicator/index.d.ts +0 -47
  130. package/dist/indicator/index.js +0 -8
  131. package/dist/input/index.cjs +0 -1462
  132. package/dist/input/index.d.cts +0 -522
  133. package/dist/input/index.d.ts +0 -522
  134. package/dist/input/index.js +0 -1462
  135. package/dist/input-trigger/index.cjs +0 -197
  136. package/dist/input-trigger/index.d.cts +0 -11
  137. package/dist/input-trigger/index.d.ts +0 -11
  138. package/dist/input-trigger/index.js +0 -197
  139. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  140. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  141. package/dist/list/index.cjs +0 -395
  142. package/dist/list/index.d.cts +0 -188
  143. package/dist/list/index.d.ts +0 -188
  144. package/dist/list/index.js +0 -395
  145. package/dist/menu/index.cjs +0 -316
  146. package/dist/menu/index.d.cts +0 -115
  147. package/dist/menu/index.d.ts +0 -115
  148. package/dist/menu/index.js +0 -316
  149. package/dist/menubox/index.cjs +0 -297
  150. package/dist/menubox/index.d.cts +0 -98
  151. package/dist/menubox/index.d.ts +0 -98
  152. package/dist/menubox/index.js +0 -297
  153. package/dist/pager/index.cjs +0 -205
  154. package/dist/pager/index.d.cts +0 -93
  155. package/dist/pager/index.d.ts +0 -93
  156. package/dist/pager/index.js +0 -205
  157. package/dist/picker/index.cjs +0 -244
  158. package/dist/picker/index.d.cts +0 -121
  159. package/dist/picker/index.d.ts +0 -121
  160. package/dist/picker/index.js +0 -244
  161. package/dist/progress/index.cjs +0 -219
  162. package/dist/progress/index.d.cts +0 -47
  163. package/dist/progress/index.d.ts +0 -47
  164. package/dist/progress/index.js +0 -219
  165. package/dist/radio/index.cjs +0 -465
  166. package/dist/radio/index.d.cts +0 -145
  167. package/dist/radio/index.d.ts +0 -145
  168. package/dist/radio/index.js +0 -465
  169. package/dist/refresh-control/index.cjs +0 -45
  170. package/dist/refresh-control/index.d.cts +0 -55
  171. package/dist/refresh-control/index.d.ts +0 -55
  172. package/dist/refresh-control/index.js +0 -45
  173. package/dist/segment-button/index.cjs +0 -405
  174. package/dist/segment-button/index.d.cts +0 -141
  175. package/dist/segment-button/index.d.ts +0 -141
  176. package/dist/segment-button/index.js +0 -405
  177. package/dist/select/index.cjs +0 -878
  178. package/dist/select/index.d.cts +0 -192
  179. package/dist/select/index.d.ts +0 -192
  180. package/dist/select/index.js +0 -878
  181. package/dist/skeleton/index.cjs +0 -89
  182. package/dist/skeleton/index.d.cts +0 -45
  183. package/dist/skeleton/index.d.ts +0 -45
  184. package/dist/skeleton/index.js +0 -89
  185. package/dist/slider/index.cjs +0 -576
  186. package/dist/slider/index.d.cts +0 -171
  187. package/dist/slider/index.d.ts +0 -171
  188. package/dist/slider/index.js +0 -576
  189. package/dist/snackbar/index.cjs +0 -436
  190. package/dist/snackbar/index.d.cts +0 -174
  191. package/dist/snackbar/index.d.ts +0 -174
  192. package/dist/snackbar/index.js +0 -436
  193. package/dist/snippet/index.cjs +0 -314
  194. package/dist/snippet/index.d.cts +0 -95
  195. package/dist/snippet/index.d.ts +0 -95
  196. package/dist/snippet/index.js +0 -314
  197. package/dist/stepper/index.cjs +0 -550
  198. package/dist/stepper/index.d.cts +0 -137
  199. package/dist/stepper/index.d.ts +0 -137
  200. package/dist/stepper/index.js +0 -550
  201. package/dist/switch/index.cjs +0 -358
  202. package/dist/switch/index.d.cts +0 -28
  203. package/dist/switch/index.d.ts +0 -28
  204. package/dist/switch/index.js +0 -358
  205. package/dist/tabs/index.cjs +0 -440
  206. package/dist/tabs/index.d.cts +0 -180
  207. package/dist/tabs/index.d.ts +0 -180
  208. package/dist/tabs/index.js +0 -440
  209. package/dist/timepicker/index.cjs +0 -823
  210. package/dist/timepicker/index.d.cts +0 -215
  211. package/dist/timepicker/index.d.ts +0 -215
  212. package/dist/timepicker/index.js +0 -823
  213. package/dist/toolbar/index.cjs +0 -333
  214. package/dist/toolbar/index.d.cts +0 -100
  215. package/dist/toolbar/index.d.ts +0 -100
  216. package/dist/toolbar/index.js +0 -333
  217. package/dist/typography/index.cjs +0 -238
  218. package/dist/typography/index.d.cts +0 -113
  219. package/dist/typography/index.d.ts +0 -113
  220. package/dist/typography/index.js +0 -238
  221. package/dist/view/index.cjs +0 -1361
  222. package/dist/view/index.d.cts +0 -833
  223. package/dist/view/index.d.ts +0 -833
  224. package/dist/view/index.js +0 -1361
@@ -1,115 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ViewStyle, GestureResponderEvent, TextStyle } from 'react-native';
3
-
4
- type MenuPosition = 'top' | 'bottom';
5
- type MenuCustomAppearance = {
6
- /**
7
- * Custom styles for the overlay container
8
- */
9
- overlay?: ViewStyle;
10
- /**
11
- * Custom styles for the menu container
12
- */
13
- container?: ViewStyle;
14
- /**
15
- * Custom styles for the menu content
16
- */
17
- content?: ViewStyle;
18
- };
19
- type MenuProps = {
20
- /**
21
- * Whether the Menu is currently visible.
22
- */
23
- visible: boolean;
24
- /**
25
- * The trigger element to open the menu from. This is the component that will trigger the menu display.
26
- */
27
- trigger: ReactNode;
28
- /**
29
- * Whether the menu should open at the top of the trigger or at its bottom.
30
- * @default 'bottom'
31
- */
32
- position?: MenuPosition;
33
- /**
34
- * Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
35
- */
36
- onDismiss?: () => void;
37
- /**
38
- * Callback fired when a MenuItem with an `itemKey` is pressed.
39
- */
40
- onItemPress?: (itemKey: string) => void;
41
- /**
42
- * Content of the Menu.
43
- */
44
- children: ReactNode;
45
- /**
46
- * Custom appearance styles for menu parts
47
- */
48
- customAppearance?: MenuCustomAppearance;
49
- /**
50
- * Maximum height of the scrollable menu content
51
- * @default 280
52
- */
53
- maxHeight?: number;
54
- };
55
-
56
- declare const Menu: React.FC<MenuProps>;
57
-
58
- type MenuItemCustomAppearance = {
59
- /**
60
- * Custom styles for the item container
61
- */
62
- container?: ViewStyle;
63
- /**
64
- * Custom styles for the item content
65
- */
66
- content?: ViewStyle;
67
- /**
68
- * Custom styles for the title text
69
- */
70
- title?: TextStyle;
71
- };
72
- type MenuItemProps = {
73
- /**
74
- * Optional key emitted via Menu `onItemPress`.
75
- */
76
- itemKey?: string;
77
- /**
78
- * Title text for the MenuItem.
79
- */
80
- title: ReactNode;
81
- /**
82
- * Content to display at the start of the item.
83
- */
84
- startContent?: ReactNode;
85
- /**
86
- * Content to display at the end of the item.
87
- */
88
- endContent?: ReactNode;
89
- /**
90
- * Whether the item is disabled. A disabled item is greyed out and onPress is not called on touch.
91
- * @default false
92
- */
93
- isDisabled?: boolean;
94
- /**
95
- * Sets min height with densed layout.
96
- * @default false
97
- */
98
- dense?: boolean;
99
- /**
100
- * Function to execute on press.
101
- */
102
- onPress?: (e: GestureResponderEvent) => void;
103
- /**
104
- * Custom appearance styles for item parts
105
- */
106
- customAppearance?: MenuItemCustomAppearance;
107
- /**
108
- * Accessibility label for the item. This is read by the screen reader when the user taps the component.
109
- */
110
- accessibilityLabel?: string;
111
- };
112
-
113
- declare const MenuItem: React.FC<MenuItemProps>;
114
-
115
- export { Menu, type MenuCustomAppearance, MenuItem, type MenuItemCustomAppearance, type MenuItemProps, type MenuPosition, type MenuProps };
@@ -1,115 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ViewStyle, GestureResponderEvent, TextStyle } from 'react-native';
3
-
4
- type MenuPosition = 'top' | 'bottom';
5
- type MenuCustomAppearance = {
6
- /**
7
- * Custom styles for the overlay container
8
- */
9
- overlay?: ViewStyle;
10
- /**
11
- * Custom styles for the menu container
12
- */
13
- container?: ViewStyle;
14
- /**
15
- * Custom styles for the menu content
16
- */
17
- content?: ViewStyle;
18
- };
19
- type MenuProps = {
20
- /**
21
- * Whether the Menu is currently visible.
22
- */
23
- visible: boolean;
24
- /**
25
- * The trigger element to open the menu from. This is the component that will trigger the menu display.
26
- */
27
- trigger: ReactNode;
28
- /**
29
- * Whether the menu should open at the top of the trigger or at its bottom.
30
- * @default 'bottom'
31
- */
32
- position?: MenuPosition;
33
- /**
34
- * Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
35
- */
36
- onDismiss?: () => void;
37
- /**
38
- * Callback fired when a MenuItem with an `itemKey` is pressed.
39
- */
40
- onItemPress?: (itemKey: string) => void;
41
- /**
42
- * Content of the Menu.
43
- */
44
- children: ReactNode;
45
- /**
46
- * Custom appearance styles for menu parts
47
- */
48
- customAppearance?: MenuCustomAppearance;
49
- /**
50
- * Maximum height of the scrollable menu content
51
- * @default 280
52
- */
53
- maxHeight?: number;
54
- };
55
-
56
- declare const Menu: React.FC<MenuProps>;
57
-
58
- type MenuItemCustomAppearance = {
59
- /**
60
- * Custom styles for the item container
61
- */
62
- container?: ViewStyle;
63
- /**
64
- * Custom styles for the item content
65
- */
66
- content?: ViewStyle;
67
- /**
68
- * Custom styles for the title text
69
- */
70
- title?: TextStyle;
71
- };
72
- type MenuItemProps = {
73
- /**
74
- * Optional key emitted via Menu `onItemPress`.
75
- */
76
- itemKey?: string;
77
- /**
78
- * Title text for the MenuItem.
79
- */
80
- title: ReactNode;
81
- /**
82
- * Content to display at the start of the item.
83
- */
84
- startContent?: ReactNode;
85
- /**
86
- * Content to display at the end of the item.
87
- */
88
- endContent?: ReactNode;
89
- /**
90
- * Whether the item is disabled. A disabled item is greyed out and onPress is not called on touch.
91
- * @default false
92
- */
93
- isDisabled?: boolean;
94
- /**
95
- * Sets min height with densed layout.
96
- * @default false
97
- */
98
- dense?: boolean;
99
- /**
100
- * Function to execute on press.
101
- */
102
- onPress?: (e: GestureResponderEvent) => void;
103
- /**
104
- * Custom appearance styles for item parts
105
- */
106
- customAppearance?: MenuItemCustomAppearance;
107
- /**
108
- * Accessibility label for the item. This is read by the screen reader when the user taps the component.
109
- */
110
- accessibilityLabel?: string;
111
- };
112
-
113
- declare const MenuItem: React.FC<MenuItemProps>;
114
-
115
- export { Menu, type MenuCustomAppearance, MenuItem, type MenuItemCustomAppearance, type MenuItemProps, type MenuPosition, type MenuProps };
@@ -1,316 +0,0 @@
1
- import "../chunk-SHBDANQN.js";
2
- import {
3
- useXUITheme
4
- } from "../chunk-RBSA4NH4.js";
5
-
6
- // src/components/menu/menu.tsx
7
- import React from "react";
8
- import { Animated as Animated2, Modal, Pressable, ScrollView, View } from "react-native";
9
-
10
- // src/components/menu/menu.style.ts
11
- import { StyleSheet } from "react-native";
12
- var SCREEN_INDENT = 8;
13
- var MENU_GAP = 4;
14
- var styles = StyleSheet.create({
15
- wrapper: {
16
- position: "absolute"
17
- },
18
- overlay: {
19
- ...StyleSheet.absoluteFillObject
20
- },
21
- menuContainer: {
22
- position: "absolute",
23
- paddingVertical: 8,
24
- minWidth: 200,
25
- maxWidth: 320
26
- }
27
- });
28
- var MENU_SCREEN_INDENT = SCREEN_INDENT;
29
- var MENU_TRIGGER_GAP = MENU_GAP;
30
-
31
- // src/components/menu/menu.hook.ts
32
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
33
- import {
34
- Animated,
35
- Dimensions,
36
- Easing
37
- } from "react-native";
38
- var useMenuTriggerMeasurements = (visible) => {
39
- const triggerRef = useRef(null);
40
- const [triggerPosition, setTriggerPosition] = useState(
41
- null
42
- );
43
- useEffect(() => {
44
- if (!visible) {
45
- setTriggerPosition(null);
46
- return;
47
- }
48
- const measureTrigger = (attempt) => {
49
- triggerRef.current?.measure((_, __, width, height, pageX, pageY) => {
50
- if ((width <= 0 || height <= 0) && attempt < 5) {
51
- globalThis.requestAnimationFrame(() => measureTrigger(attempt + 1));
52
- return;
53
- }
54
- setTriggerPosition({
55
- x: pageX,
56
- y: pageY,
57
- width: Math.max(0, width),
58
- height: Math.max(0, height)
59
- });
60
- });
61
- };
62
- const frameId = globalThis.setTimeout(() => measureTrigger(0), 0);
63
- return () => globalThis.clearTimeout(frameId);
64
- }, [visible]);
65
- return { triggerRef, triggerPosition };
66
- };
67
- var useMenuContentLayout = (visible) => {
68
- const [contentSize, setContentSize] = useState({ width: 0, height: 0 });
69
- const [isMeasured, setIsMeasured] = useState(false);
70
- useEffect(() => {
71
- if (!visible) {
72
- setIsMeasured(false);
73
- }
74
- }, [visible]);
75
- const handleContentLayout = useCallback((event) => {
76
- const { width, height } = event.nativeEvent.layout;
77
- if (width > 0 && height > 0) {
78
- setContentSize({ width, height });
79
- setIsMeasured(true);
80
- }
81
- }, []);
82
- return { contentSize, handleContentLayout, isMeasured };
83
- };
84
- var useMenuPosition = (triggerPosition, contentSize, position) => {
85
- return useMemo(() => {
86
- if (!triggerPosition) return { top: 0, left: 0 };
87
- const screenWidth = Dimensions.get("window").width;
88
- const screenHeight = Dimensions.get("window").height;
89
- let top;
90
- let left = triggerPosition.x;
91
- const hasEnoughSpaceBelow = triggerPosition.y + triggerPosition.height + contentSize.height <= screenHeight - MENU_SCREEN_INDENT;
92
- const hasEnoughSpaceAbove = triggerPosition.y - contentSize.height >= MENU_SCREEN_INDENT;
93
- if (position === "bottom") {
94
- if (hasEnoughSpaceBelow) {
95
- top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
96
- } else if (hasEnoughSpaceAbove) {
97
- top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
98
- } else {
99
- top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
100
- }
101
- } else {
102
- if (hasEnoughSpaceAbove) {
103
- top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
104
- } else if (hasEnoughSpaceBelow) {
105
- top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
106
- } else {
107
- top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
108
- }
109
- }
110
- if (contentSize.width > 0 && left + contentSize.width > screenWidth - MENU_SCREEN_INDENT) {
111
- left = Math.max(
112
- MENU_SCREEN_INDENT,
113
- triggerPosition.x + triggerPosition.width - contentSize.width
114
- );
115
- }
116
- if (left < MENU_SCREEN_INDENT) {
117
- left = MENU_SCREEN_INDENT;
118
- }
119
- const maxTop = Math.max(
120
- MENU_SCREEN_INDENT,
121
- screenHeight - MENU_SCREEN_INDENT - contentSize.height
122
- );
123
- const clampedTop = Math.min(maxTop, Math.max(MENU_SCREEN_INDENT, top));
124
- return { top: clampedTop, left };
125
- }, [triggerPosition, contentSize, position]);
126
- };
127
- var useMenuAnimation = (visible) => {
128
- const opacity = useRef(new Animated.Value(0)).current;
129
- const scale = useRef(new Animated.Value(0)).current;
130
- useEffect(() => {
131
- if (!visible) return;
132
- opacity.setValue(0);
133
- scale.setValue(0);
134
- Animated.parallel([
135
- Animated.timing(opacity, {
136
- toValue: 1,
137
- duration: 200,
138
- easing: Easing.bezier(0.4, 0, 0.2, 1),
139
- useNativeDriver: true
140
- }),
141
- Animated.spring(scale, {
142
- toValue: 1,
143
- friction: 9,
144
- tension: 100,
145
- useNativeDriver: true
146
- })
147
- ]).start();
148
- }, [visible, opacity, scale]);
149
- return { opacity, scale };
150
- };
151
-
152
- // src/components/menu/menu.tsx
153
- var Menu = ({
154
- visible,
155
- trigger,
156
- position = "bottom",
157
- onDismiss,
158
- onItemPress,
159
- children,
160
- customAppearance,
161
- maxHeight = 280
162
- }) => {
163
- const theme = useXUITheme();
164
- const { triggerRef, triggerPosition } = useMenuTriggerMeasurements(visible);
165
- const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
166
- const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
167
- const { opacity, scale } = useMenuAnimation(visible);
168
- const handledChildren = React.Children.map(children, (child) => {
169
- if (!React.isValidElement(child)) return child;
170
- const { onPress, itemKey } = child.props;
171
- if (!onPress && !itemKey) return child;
172
- return React.cloneElement(child, {
173
- onPress: (e) => {
174
- onPress?.(e);
175
- if (itemKey) onItemPress?.(itemKey);
176
- }
177
- });
178
- });
179
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ React.createElement(
180
- Modal,
181
- {
182
- visible,
183
- transparent: true,
184
- animationType: "fade",
185
- onRequestClose: onDismiss
186
- },
187
- /* @__PURE__ */ React.createElement(
188
- Pressable,
189
- {
190
- style: [styles.overlay, customAppearance?.overlay],
191
- onPress: onDismiss,
192
- accessibilityRole: "button",
193
- accessibilityLabel: "Close menu"
194
- },
195
- /* @__PURE__ */ React.createElement(
196
- Animated2.View,
197
- {
198
- onLayout: handleContentLayout,
199
- style: [
200
- styles.menuContainer,
201
- {
202
- top: isMeasured ? menuPosition.top : -9999,
203
- left: isMeasured ? menuPosition.left : -9999,
204
- backgroundColor: theme.mode === "dark" ? theme.colors.default.container : theme.colors.background,
205
- borderRadius: theme.borderRadius.md,
206
- opacity: isMeasured ? opacity : 0,
207
- transform: [{ scale }],
208
- ...theme.shadows.md
209
- },
210
- customAppearance?.container
211
- ]
212
- },
213
- /* @__PURE__ */ React.createElement(Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(View, { style: customAppearance?.content }, /* @__PURE__ */ React.createElement(ScrollView, { style: { maxHeight } }, handledChildren)))
214
- )
215
- )
216
- ));
217
- };
218
-
219
- // src/components/menu/menu-item.tsx
220
- import React2 from "react";
221
- import { Pressable as Pressable2, Text, View as View2 } from "react-native";
222
-
223
- // src/components/menu/menu-item.style.ts
224
- import { StyleSheet as StyleSheet2 } from "react-native";
225
- var MIN_WIDTH = 112;
226
- var MAX_WIDTH = 280;
227
- var styles2 = StyleSheet2.create({
228
- container: {
229
- minWidth: MIN_WIDTH,
230
- maxWidth: MAX_WIDTH,
231
- height: 48,
232
- justifyContent: "center",
233
- paddingHorizontal: 12
234
- },
235
- denseContainer: {
236
- height: 32
237
- },
238
- row: {
239
- flexDirection: "row",
240
- alignItems: "center"
241
- },
242
- content: {
243
- flex: 1,
244
- justifyContent: "center"
245
- },
246
- titleText: {
247
- fontSize: 16
248
- },
249
- startContent: {
250
- width: 24,
251
- marginRight: 12,
252
- alignItems: "center",
253
- justifyContent: "center"
254
- },
255
- endContent: {
256
- width: 24,
257
- marginLeft: 12,
258
- alignItems: "center",
259
- justifyContent: "center"
260
- },
261
- disabled: {
262
- opacity: 0.5
263
- }
264
- });
265
-
266
- // src/components/menu/menu-item.tsx
267
- var MenuItem = ({
268
- title,
269
- startContent,
270
- endContent,
271
- isDisabled = false,
272
- dense = false,
273
- onPress,
274
- customAppearance,
275
- accessibilityLabel
276
- }) => {
277
- const theme = useXUITheme();
278
- const titleColor = isDisabled ? theme.colors.foreground + "50" : theme.colors.foreground;
279
- const renderTitle = () => {
280
- if (typeof title === "string" || typeof title === "number") {
281
- return /* @__PURE__ */ React2.createElement(
282
- Text,
283
- {
284
- style: [styles2.titleText, { color: titleColor }, customAppearance?.title],
285
- numberOfLines: 1
286
- },
287
- title
288
- );
289
- }
290
- return title;
291
- };
292
- return /* @__PURE__ */ React2.createElement(
293
- Pressable2,
294
- {
295
- onPress: isDisabled ? void 0 : onPress,
296
- disabled: isDisabled,
297
- accessibilityRole: "menuitem",
298
- accessibilityLabel,
299
- accessibilityState: { disabled: isDisabled },
300
- style: ({ pressed }) => [
301
- styles2.container,
302
- dense && styles2.denseContainer,
303
- isDisabled && styles2.disabled,
304
- pressed && !isDisabled && {
305
- backgroundColor: theme.colors.foreground + "10"
306
- },
307
- customAppearance?.container
308
- ]
309
- },
310
- /* @__PURE__ */ React2.createElement(View2, { style: [styles2.row, customAppearance?.content] }, startContent && /* @__PURE__ */ React2.createElement(View2, { style: styles2.startContent }, startContent), /* @__PURE__ */ React2.createElement(View2, { style: styles2.content }, renderTitle()), endContent && /* @__PURE__ */ React2.createElement(View2, { style: styles2.endContent }, endContent))
311
- );
312
- };
313
- export {
314
- Menu,
315
- MenuItem
316
- };