@xaui/native 0.2.8 → 0.9.1-alpha.1
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/dist/chunk-KFCORXWW.cjs +150 -0
- package/dist/chunk-M7P46XKI.cjs +100 -0
- package/dist/chunk-N357EQCZ.js +150 -0
- package/dist/chunk-NHPQQQ7P.cjs +734 -0
- package/dist/chunk-PBVPOX7D.js +734 -0
- package/dist/chunk-RBNCR5KB.js +100 -0
- package/dist/index.cjs +40 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +40 -0
- package/dist/system/index.cjs +7 -0
- package/dist/system/index.d.cts +83 -0
- package/dist/system/index.d.ts +83 -0
- package/dist/system/index.js +7 -0
- package/dist/theme/index.cjs +36 -0
- package/dist/theme/index.d.cts +539 -0
- package/dist/theme/index.d.ts +539 -0
- package/dist/theme/index.js +36 -0
- package/dist/theme.type-B3ODSLbB.d.cts +153 -0
- package/dist/theme.type-B3ODSLbB.d.ts +153 -0
- package/package.json +30 -248
- package/README.md +0 -178
- package/dist/alert/index.cjs +0 -340
- package/dist/alert/index.d.cts +0 -46
- package/dist/alert/index.d.ts +0 -46
- package/dist/alert/index.js +0 -340
- package/dist/app-bar/index.cjs +0 -148
- package/dist/app-bar/index.d.cts +0 -59
- package/dist/app-bar/index.d.ts +0 -59
- package/dist/app-bar/index.js +0 -148
- package/dist/autocomplete/index.cjs +0 -1122
- package/dist/autocomplete/index.d.cts +0 -88
- package/dist/autocomplete/index.d.ts +0 -88
- package/dist/autocomplete/index.js +0 -1122
- package/dist/avatar/index.cjs +0 -281
- package/dist/avatar/index.d.cts +0 -123
- package/dist/avatar/index.d.ts +0 -123
- package/dist/avatar/index.js +0 -281
- package/dist/badge/index.cjs +0 -197
- package/dist/badge/index.d.cts +0 -94
- package/dist/badge/index.d.ts +0 -94
- package/dist/badge/index.js +0 -197
- package/dist/bottom-sheet/index.cjs +0 -9
- package/dist/bottom-sheet/index.d.cts +0 -84
- package/dist/bottom-sheet/index.d.ts +0 -84
- package/dist/bottom-sheet/index.js +0 -9
- package/dist/bottom-tab-bar/index.cjs +0 -497
- package/dist/bottom-tab-bar/index.d.cts +0 -211
- package/dist/bottom-tab-bar/index.d.ts +0 -211
- package/dist/bottom-tab-bar/index.js +0 -497
- package/dist/button/index.cjs +0 -392
- package/dist/button/index.d.cts +0 -174
- package/dist/button/index.d.ts +0 -174
- package/dist/button/index.js +0 -392
- package/dist/button.type-j1ZdkkSl.d.cts +0 -4
- package/dist/button.type-j1ZdkkSl.d.ts +0 -4
- package/dist/card/index.cjs +0 -338
- package/dist/card/index.d.cts +0 -191
- package/dist/card/index.d.ts +0 -191
- package/dist/card/index.js +0 -338
- package/dist/carousel/index.cjs +0 -381
- package/dist/carousel/index.d.cts +0 -147
- package/dist/carousel/index.d.ts +0 -147
- package/dist/carousel/index.js +0 -381
- package/dist/chart/index.cjs +0 -1026
- package/dist/chart/index.d.cts +0 -218
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -1026
- package/dist/checkbox/index.cjs +0 -443
- package/dist/checkbox/index.d.cts +0 -73
- package/dist/checkbox/index.d.ts +0 -73
- package/dist/checkbox/index.js +0 -443
- package/dist/chip/index.cjs +0 -503
- package/dist/chip/index.d.cts +0 -195
- package/dist/chip/index.d.ts +0 -195
- package/dist/chip/index.js +0 -503
- package/dist/chunk-4JFWQ5XT.js +0 -368
- package/dist/chunk-56RPWZD2.cjs +0 -9
- package/dist/chunk-7UFBLUMV.cjs +0 -136
- package/dist/chunk-A45TVXU5.js +0 -337
- package/dist/chunk-BYWUAPC4.cjs +0 -368
- package/dist/chunk-DECMUMCI.js +0 -0
- package/dist/chunk-DHSTKO3K.cjs +0 -19
- package/dist/chunk-DJ4Q37UT.cjs +0 -75
- package/dist/chunk-EUQDGTST.cjs +0 -1
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-RBSA4NH4.js +0 -136
- package/dist/chunk-SHBDANQN.js +0 -9
- package/dist/chunk-UGEINZM7.cjs +0 -290
- package/dist/chunk-UU4HHBDN.js +0 -290
- package/dist/chunk-VSZEXOUN.js +0 -384
- package/dist/chunk-YIEUN3G5.cjs +0 -384
- package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
- package/dist/chunk-ZY7IUTAT.js +0 -75
- package/dist/color-picker/index.cjs +0 -457
- package/dist/color-picker/index.d.cts +0 -124
- package/dist/color-picker/index.d.ts +0 -124
- package/dist/color-picker/index.js +0 -457
- package/dist/core/index.cjs +0 -24
- package/dist/core/index.d.cts +0 -28
- package/dist/core/index.d.ts +0 -28
- package/dist/core/index.js +0 -24
- package/dist/datepicker/index.cjs +0 -1625
- package/dist/datepicker/index.d.cts +0 -45
- package/dist/datepicker/index.d.ts +0 -45
- package/dist/datepicker/index.js +0 -1625
- package/dist/dialog/index.cjs +0 -372
- package/dist/dialog/index.d.cts +0 -151
- package/dist/dialog/index.d.ts +0 -151
- package/dist/dialog/index.js +0 -372
- package/dist/divider/index.cjs +0 -8
- package/dist/divider/index.d.cts +0 -30
- package/dist/divider/index.d.ts +0 -30
- package/dist/divider/index.js +0 -8
- package/dist/drawer/index.cjs +0 -237
- package/dist/drawer/index.d.cts +0 -58
- package/dist/drawer/index.d.ts +0 -58
- package/dist/drawer/index.js +0 -237
- package/dist/expansion-panel/index.cjs +0 -441
- package/dist/expansion-panel/index.d.cts +0 -153
- package/dist/expansion-panel/index.d.ts +0 -153
- package/dist/expansion-panel/index.js +0 -441
- package/dist/fab/index.cjs +0 -9
- package/dist/fab/index.d.cts +0 -10
- package/dist/fab/index.d.ts +0 -10
- package/dist/fab/index.js +0 -9
- package/dist/fab-menu/index.cjs +0 -330
- package/dist/fab-menu/index.d.cts +0 -125
- package/dist/fab-menu/index.d.ts +0 -125
- package/dist/fab-menu/index.js +0 -330
- package/dist/fab.type-CkUHmXU_.d.ts +0 -86
- package/dist/fab.type-DN0vtAh6.d.cts +0 -86
- package/dist/feature-discovery/index.cjs +0 -464
- package/dist/feature-discovery/index.d.cts +0 -82
- package/dist/feature-discovery/index.d.ts +0 -82
- package/dist/feature-discovery/index.js +0 -464
- package/dist/indicator/index.cjs +0 -8
- package/dist/indicator/index.d.cts +0 -47
- package/dist/indicator/index.d.ts +0 -47
- package/dist/indicator/index.js +0 -8
- package/dist/input/index.cjs +0 -1462
- package/dist/input/index.d.cts +0 -522
- package/dist/input/index.d.ts +0 -522
- package/dist/input/index.js +0 -1462
- package/dist/input-trigger/index.cjs +0 -197
- package/dist/input-trigger/index.d.cts +0 -11
- package/dist/input-trigger/index.d.ts +0 -11
- package/dist/input-trigger/index.js +0 -197
- package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
- package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
- package/dist/list/index.cjs +0 -395
- package/dist/list/index.d.cts +0 -188
- package/dist/list/index.d.ts +0 -188
- package/dist/list/index.js +0 -395
- package/dist/menu/index.cjs +0 -316
- package/dist/menu/index.d.cts +0 -115
- package/dist/menu/index.d.ts +0 -115
- package/dist/menu/index.js +0 -316
- package/dist/menubox/index.cjs +0 -297
- package/dist/menubox/index.d.cts +0 -98
- package/dist/menubox/index.d.ts +0 -98
- package/dist/menubox/index.js +0 -297
- package/dist/pager/index.cjs +0 -205
- package/dist/pager/index.d.cts +0 -93
- package/dist/pager/index.d.ts +0 -93
- package/dist/pager/index.js +0 -205
- package/dist/picker/index.cjs +0 -244
- package/dist/picker/index.d.cts +0 -121
- package/dist/picker/index.d.ts +0 -121
- package/dist/picker/index.js +0 -244
- package/dist/progress/index.cjs +0 -219
- package/dist/progress/index.d.cts +0 -47
- package/dist/progress/index.d.ts +0 -47
- package/dist/progress/index.js +0 -219
- package/dist/radio/index.cjs +0 -465
- package/dist/radio/index.d.cts +0 -145
- package/dist/radio/index.d.ts +0 -145
- package/dist/radio/index.js +0 -465
- package/dist/refresh-control/index.cjs +0 -45
- package/dist/refresh-control/index.d.cts +0 -55
- package/dist/refresh-control/index.d.ts +0 -55
- package/dist/refresh-control/index.js +0 -45
- package/dist/segment-button/index.cjs +0 -405
- package/dist/segment-button/index.d.cts +0 -141
- package/dist/segment-button/index.d.ts +0 -141
- package/dist/segment-button/index.js +0 -405
- package/dist/select/index.cjs +0 -878
- package/dist/select/index.d.cts +0 -192
- package/dist/select/index.d.ts +0 -192
- package/dist/select/index.js +0 -878
- package/dist/skeleton/index.cjs +0 -89
- package/dist/skeleton/index.d.cts +0 -45
- package/dist/skeleton/index.d.ts +0 -45
- package/dist/skeleton/index.js +0 -89
- package/dist/slider/index.cjs +0 -576
- package/dist/slider/index.d.cts +0 -171
- package/dist/slider/index.d.ts +0 -171
- package/dist/slider/index.js +0 -576
- package/dist/snackbar/index.cjs +0 -436
- package/dist/snackbar/index.d.cts +0 -174
- package/dist/snackbar/index.d.ts +0 -174
- package/dist/snackbar/index.js +0 -436
- package/dist/snippet/index.cjs +0 -314
- package/dist/snippet/index.d.cts +0 -95
- package/dist/snippet/index.d.ts +0 -95
- package/dist/snippet/index.js +0 -314
- package/dist/stepper/index.cjs +0 -550
- package/dist/stepper/index.d.cts +0 -137
- package/dist/stepper/index.d.ts +0 -137
- package/dist/stepper/index.js +0 -550
- package/dist/switch/index.cjs +0 -358
- package/dist/switch/index.d.cts +0 -28
- package/dist/switch/index.d.ts +0 -28
- package/dist/switch/index.js +0 -358
- package/dist/tabs/index.cjs +0 -440
- package/dist/tabs/index.d.cts +0 -180
- package/dist/tabs/index.d.ts +0 -180
- package/dist/tabs/index.js +0 -440
- package/dist/timepicker/index.cjs +0 -823
- package/dist/timepicker/index.d.cts +0 -215
- package/dist/timepicker/index.d.ts +0 -215
- package/dist/timepicker/index.js +0 -823
- package/dist/toolbar/index.cjs +0 -333
- package/dist/toolbar/index.d.cts +0 -100
- package/dist/toolbar/index.d.ts +0 -100
- package/dist/toolbar/index.js +0 -333
- package/dist/typography/index.cjs +0 -238
- package/dist/typography/index.d.cts +0 -113
- package/dist/typography/index.d.ts +0 -113
- package/dist/typography/index.js +0 -238
- package/dist/view/index.cjs +0 -1361
- package/dist/view/index.d.cts +0 -833
- package/dist/view/index.d.ts +0 -833
- package/dist/view/index.js +0 -1361
package/dist/menu/index.d.cts
DELETED
|
@@ -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 };
|
package/dist/menu/index.d.ts
DELETED
|
@@ -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 };
|
package/dist/menu/index.js
DELETED
|
@@ -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
|
-
};
|