@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,497 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-56RPWZD2.cjs');
2
-
3
-
4
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
5
-
6
- // src/components/bottom-tab-bar/bottom-tab-bar.tsx
7
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
8
- var _reactnative = require('react-native');
9
-
10
- // src/components/bottom-tab-bar/bottom-tab-bar.hook.ts
11
-
12
- var _core = require('@xaui/core');
13
- var sizeMap = {
14
- sm: {
15
- minHeight: 68,
16
- iconSize: 20,
17
- indicatorWidth: 58,
18
- indicatorHeight: 30,
19
- indicatorRadius: 15,
20
- itemPaddingTop: 8,
21
- itemPaddingBottom: 6,
22
- labelSize: 11,
23
- labelSpacing: 4
24
- },
25
- md: {
26
- minHeight: 78,
27
- iconSize: 24,
28
- indicatorWidth: 64,
29
- indicatorHeight: 32,
30
- indicatorRadius: 16,
31
- itemPaddingTop: 10,
32
- itemPaddingBottom: 8,
33
- labelSize: 12,
34
- labelSpacing: 4
35
- },
36
- lg: {
37
- minHeight: 86,
38
- iconSize: 26,
39
- indicatorWidth: 70,
40
- indicatorHeight: 36,
41
- indicatorRadius: 18,
42
- itemPaddingTop: 11,
43
- itemPaddingBottom: 10,
44
- labelSize: 13,
45
- labelSpacing: 5
46
- }
47
- };
48
- var useBottomTabBarSizeStyles = (size) => {
49
- return _react.useMemo.call(void 0, () => sizeMap[size], [size]);
50
- };
51
- var useBottomTabBarColors = (themeColor, activeColor, inactiveColor, indicatorColor) => {
52
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
53
- const colorScheme = theme.colors[_core.getSafeThemeColor.call(void 0, themeColor)];
54
- return _react.useMemo.call(void 0, () => {
55
- return {
56
- activeColor: _nullishCoalesce(activeColor, () => ( colorScheme.main)),
57
- inactiveColor: _nullishCoalesce(inactiveColor, () => ( _core.withOpacity.call(void 0, theme.colors.foreground, 0.66))),
58
- indicatorColor: _nullishCoalesce(indicatorColor, () => ( _core.withOpacity.call(void 0, colorScheme.main, theme.mode === "dark" ? 0.28 : 0.16))),
59
- containerColor: theme.colors.background,
60
- borderColor: _core.withOpacity.call(void 0, theme.colors.foreground, 0.08)
61
- };
62
- }, [activeColor, colorScheme.main, indicatorColor, inactiveColor, theme]);
63
- };
64
-
65
- // src/components/bottom-tab-bar/bottom-tab-bar-context.ts
66
-
67
- var BottomTabBarContext = _react.createContext.call(void 0,
68
- null
69
- );
70
- var useBottomTabBarContext = () => {
71
- return _react.useContext.call(void 0, BottomTabBarContext);
72
- };
73
-
74
- // src/components/bottom-tab-bar/bottom-tab-bar-item.tsx
75
-
76
-
77
-
78
- // src/components/bottom-tab-bar/bottom-tab-bar.style.ts
79
-
80
- var styles = _reactnative.StyleSheet.create({
81
- container: {
82
- flexDirection: "row",
83
- alignItems: "stretch",
84
- width: "100%",
85
- borderTopWidth: 1
86
- },
87
- itemPressable: {
88
- flex: 1
89
- },
90
- itemContainer: {
91
- flex: 1,
92
- alignItems: "center",
93
- justifyContent: "center"
94
- },
95
- itemContainerInline: {
96
- flexDirection: "row"
97
- },
98
- indicator: {
99
- alignItems: "center",
100
- justifyContent: "center",
101
- position: "relative"
102
- },
103
- indicatorContent: {
104
- flexDirection: "row",
105
- alignItems: "center",
106
- justifyContent: "center"
107
- },
108
- indicatorBackground: {
109
- position: "absolute"
110
- },
111
- label: {
112
- fontWeight: "600",
113
- letterSpacing: 0.1
114
- },
115
- inlineLabel: {
116
- marginLeft: 6
117
- },
118
- badgeContainer: {
119
- position: "absolute",
120
- top: -4,
121
- right: -10
122
- },
123
- disabled: {
124
- opacity: 0.5
125
- }
126
- });
127
-
128
- // src/components/bottom-tab-bar/bottom-tab-bar-item.tsx
129
- var resolveIconNode = (icon, params) => {
130
- if (typeof icon === "function") {
131
- return icon(params);
132
- }
133
- return icon;
134
- };
135
- var BottomTabBarItem = ({
136
- itemKey,
137
- label,
138
- icon,
139
- activeIcon,
140
- badge,
141
- isDisabled = false,
142
- isSelected,
143
- showLabel,
144
- activeColor,
145
- inactiveColor,
146
- indicatorColor,
147
- style,
148
- customAppearance,
149
- onPress,
150
- onLongPress,
151
- accessibilityLabel,
152
- testID
153
- }) => {
154
- const INLINE_INDICATOR_HORIZONTAL_PADDING = 10;
155
- const INLINE_INDICATOR_VERTICAL_PADDING = 14;
156
- const ICON_ONLY_INDICATOR_HORIZONTAL_PADDING = 10;
157
- const ICON_ONLY_INDICATOR_VERTICAL_PADDING = 10;
158
- const context = useBottomTabBarContext();
159
- const selected = _nullishCoalesce(isSelected, () => ( _optionalChain([context, 'optionalAccess', _ => _.selectedKey]) === itemKey));
160
- const disabled = isDisabled || !!_optionalChain([context, 'optionalAccess', _2 => _2.isDisabled]);
161
- const resolvedVariant = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _3 => _3.variant]), () => ( "stacked"));
162
- const isIconOnly = resolvedVariant === "icon-only";
163
- const resolvedShowLabel = isIconOnly ? false : _nullishCoalesce(_nullishCoalesce(showLabel, () => ( _optionalChain([context, 'optionalAccess', _4 => _4.showLabel]))), () => ( true));
164
- const isInline = resolvedVariant === "inline";
165
- const resolvedSize = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _5 => _5.size]), () => ( "md"));
166
- const resolvedThemeColor = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _6 => _6.themeColor]), () => ( "primary"));
167
- const [contentSize, setContentSize] = _react.useState.call(void 0, { width: 0, height: 0 });
168
- const sizeStyles = useBottomTabBarSizeStyles(resolvedSize);
169
- const resolvedIndicatorWidth = isInline ? Math.max(
170
- sizeStyles.indicatorHeight,
171
- contentSize.width + INLINE_INDICATOR_HORIZONTAL_PADDING * 2
172
- ) : isIconOnly ? Math.max(
173
- sizeStyles.indicatorWidth,
174
- contentSize.width + ICON_ONLY_INDICATOR_HORIZONTAL_PADDING * 2
175
- ) : sizeStyles.indicatorWidth;
176
- const resolvedIndicatorHeight = isInline ? Math.max(
177
- sizeStyles.indicatorHeight,
178
- contentSize.height + INLINE_INDICATOR_VERTICAL_PADDING * 1.35
179
- ) : isIconOnly ? Math.max(
180
- sizeStyles.indicatorHeight,
181
- contentSize.height + ICON_ONLY_INDICATOR_VERTICAL_PADDING * 2
182
- ) : sizeStyles.indicatorHeight;
183
- const colors = useBottomTabBarColors(
184
- resolvedThemeColor,
185
- _nullishCoalesce(activeColor, () => ( _optionalChain([context, 'optionalAccess', _7 => _7.activeColor]))),
186
- _nullishCoalesce(inactiveColor, () => ( _optionalChain([context, 'optionalAccess', _8 => _8.inactiveColor]))),
187
- _nullishCoalesce(indicatorColor, () => ( _optionalChain([context, 'optionalAccess', _9 => _9.indicatorColor])))
188
- );
189
- const indicatorScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(selected ? 1 : 0.75)).current;
190
- const indicatorOpacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(selected ? 1 : 0)).current;
191
- _react.useEffect.call(void 0, () => {
192
- _reactnative.Animated.parallel([
193
- _reactnative.Animated.spring(indicatorScale, {
194
- toValue: selected ? 1 : 0.75,
195
- friction: 9,
196
- tension: 95,
197
- useNativeDriver: true
198
- }),
199
- _reactnative.Animated.timing(indicatorOpacity, {
200
- toValue: selected ? 1 : 0,
201
- duration: selected ? 180 : 140,
202
- useNativeDriver: true
203
- })
204
- ]).start();
205
- }, [indicatorOpacity, indicatorScale, selected]);
206
- const iconColor = selected ? colors.activeColor : colors.inactiveColor;
207
- const iconNode = _react.useMemo.call(void 0, () => {
208
- const params = {
209
- focused: !!selected,
210
- color: iconColor,
211
- size: sizeStyles.iconSize
212
- };
213
- if (selected && activeIcon) {
214
- return resolveIconNode(activeIcon, params);
215
- }
216
- return resolveIconNode(icon, params);
217
- }, [activeIcon, icon, iconColor, selected, sizeStyles.iconSize]);
218
- const labelNode = resolvedShowLabel ? /* @__PURE__ */ _react2.default.createElement(
219
- _reactnative.Text,
220
- {
221
- numberOfLines: 1,
222
- style: [
223
- styles.label,
224
- isInline && styles.inlineLabel,
225
- {
226
- color: iconColor,
227
- fontSize: sizeStyles.labelSize
228
- },
229
- _optionalChain([customAppearance, 'optionalAccess', _10 => _10.label])
230
- ]
231
- },
232
- label
233
- ) : null;
234
- return /* @__PURE__ */ _react2.default.createElement(
235
- _reactnative.Pressable,
236
- {
237
- onPress: (event) => {
238
- if (disabled) return;
239
- _optionalChain([context, 'optionalAccess', _11 => _11.onSelectionChange, 'optionalCall', _12 => _12(itemKey)]);
240
- _optionalChain([onPress, 'optionalCall', _13 => _13(event)]);
241
- },
242
- onLongPress,
243
- disabled,
244
- accessibilityRole: "tab",
245
- accessibilityState: { selected: !!selected, disabled },
246
- accessibilityLabel,
247
- testID,
248
- style: styles.itemPressable
249
- },
250
- /* @__PURE__ */ _react2.default.createElement(
251
- _reactnative.View,
252
- {
253
- style: [
254
- styles.itemContainer,
255
- isInline && styles.itemContainerInline,
256
- {
257
- paddingTop: sizeStyles.itemPaddingTop,
258
- paddingBottom: sizeStyles.itemPaddingBottom
259
- },
260
- disabled && styles.disabled,
261
- style,
262
- _optionalChain([customAppearance, 'optionalAccess', _14 => _14.container])
263
- ]
264
- },
265
- /* @__PURE__ */ _react2.default.createElement(
266
- _reactnative.Animated.View,
267
- {
268
- style: [
269
- styles.indicator,
270
- {
271
- width: resolvedIndicatorWidth,
272
- height: resolvedIndicatorHeight,
273
- marginBottom: !isInline && resolvedShowLabel ? sizeStyles.labelSpacing : 0
274
- },
275
- _optionalChain([customAppearance, 'optionalAccess', _15 => _15.indicator])
276
- ]
277
- },
278
- /* @__PURE__ */ _react2.default.createElement(
279
- _reactnative.Animated.View,
280
- {
281
- style: [
282
- styles.indicatorBackground,
283
- {
284
- width: resolvedIndicatorWidth,
285
- height: resolvedIndicatorHeight,
286
- borderRadius: resolvedIndicatorHeight / 2,
287
- backgroundColor: colors.indicatorColor,
288
- transform: [{ scale: indicatorScale }],
289
- opacity: indicatorOpacity
290
- }
291
- ]
292
- }
293
- ),
294
- /* @__PURE__ */ _react2.default.createElement(
295
- _reactnative.View,
296
- {
297
- style: styles.indicatorContent,
298
- onLayout: (event) => {
299
- if (!isInline && !isIconOnly) return;
300
- const nextWidth = Math.ceil(event.nativeEvent.layout.width);
301
- const nextHeight = Math.ceil(event.nativeEvent.layout.height);
302
- setContentSize(
303
- (prev) => prev.width === nextWidth && prev.height === nextHeight ? prev : { width: nextWidth, height: nextHeight }
304
- );
305
- }
306
- },
307
- iconNode,
308
- badge ? /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.badgeContainer }, badge) : null,
309
- isInline ? labelNode : null
310
- )
311
- ),
312
- !isInline ? labelNode : null
313
- )
314
- );
315
- };
316
-
317
- // src/components/bottom-tab-bar/bottom-tab-bar.tsx
318
- var isExpoRouterMode = (props) => {
319
- return "state" in props && "navigation" in props && "descriptors" in props && !!props.state && !!props.navigation && !!props.descriptors;
320
- };
321
- var getRouteLabel = (route, options, focused, color, variant) => {
322
- if (typeof options.tabBarLabel === "function") {
323
- return options.tabBarLabel({
324
- focused,
325
- color,
326
- children: _nullishCoalesce(options.title, () => ( route.name)),
327
- position: variant === "inline" ? "beside-icon" : "below-icon"
328
- });
329
- }
330
- if (typeof options.tabBarLabel === "string") {
331
- return options.tabBarLabel;
332
- }
333
- if (typeof options.title === "string") {
334
- return options.title;
335
- }
336
- return route.name;
337
- };
338
- var BottomTabBar = (props) => {
339
- const {
340
- themeColor = "primary",
341
- size = "md",
342
- variant = "stacked",
343
- isDisabled = false,
344
- showLabel = true,
345
- insetBottom = 0,
346
- indicatorColor,
347
- activeColor,
348
- inactiveColor,
349
- style,
350
- customAppearance
351
- } = props;
352
- const sizeStyles = useBottomTabBarSizeStyles(size);
353
- const colors = useBottomTabBarColors(
354
- themeColor,
355
- activeColor,
356
- inactiveColor,
357
- indicatorColor
358
- );
359
- if (isExpoRouterMode(props)) {
360
- const { state, descriptors, navigation, insets } = props;
361
- const currentRoute = state.routes[state.index];
362
- const focusedOptions = _optionalChain([descriptors, 'access', _16 => _16[currentRoute.key], 'optionalAccess', _17 => _17.options]);
363
- const focusedStyle = _optionalChain([focusedOptions, 'optionalAccess', _18 => _18.tabBarStyle]);
364
- if (_optionalChain([focusedStyle, 'optionalAccess', _19 => _19.display]) === "none") {
365
- return null;
366
- }
367
- const routerInsetBottom = _nullishCoalesce(_optionalChain([insets, 'optionalAccess', _20 => _20.bottom]), () => ( insetBottom));
368
- return /* @__PURE__ */ _react2.default.createElement(
369
- _reactnative.View,
370
- {
371
- style: [
372
- styles.container,
373
- {
374
- minHeight: sizeStyles.minHeight + routerInsetBottom,
375
- paddingBottom: routerInsetBottom,
376
- backgroundColor: colors.containerColor,
377
- borderTopColor: colors.borderColor
378
- },
379
- style,
380
- _optionalChain([customAppearance, 'optionalAccess', _21 => _21.container])
381
- ]
382
- },
383
- state.routes.filter((route) => _optionalChain([descriptors, 'access', _22 => _22[route.key], 'optionalAccess', _23 => _23.options, 'access', _24 => _24.href]) !== null).map((route) => {
384
- const routeOptions = _nullishCoalesce(_optionalChain([descriptors, 'access', _25 => _25[route.key], 'optionalAccess', _26 => _26.options]), () => ( {}));
385
- const focused = currentRoute.key === route.key;
386
- const routeActiveColor = _nullishCoalesce(routeOptions.tabBarActiveTintColor, () => ( activeColor));
387
- const routeInactiveColor = _nullishCoalesce(routeOptions.tabBarInactiveTintColor, () => ( inactiveColor));
388
- const labelColor = focused ? _nullishCoalesce(routeActiveColor, () => ( colors.activeColor)) : _nullishCoalesce(routeInactiveColor, () => ( colors.inactiveColor));
389
- return /* @__PURE__ */ _react2.default.createElement(
390
- BottomTabBarItem,
391
- {
392
- key: route.key,
393
- itemKey: route.key,
394
- label: getRouteLabel(
395
- route,
396
- routeOptions,
397
- focused,
398
- labelColor,
399
- variant
400
- ),
401
- icon: routeOptions.tabBarIcon,
402
- isSelected: focused,
403
- showLabel: _nullishCoalesce(routeOptions.tabBarShowLabel, () => ( showLabel)),
404
- activeColor: routeActiveColor,
405
- inactiveColor: routeInactiveColor,
406
- badge: routeOptions.tabBarBadge,
407
- accessibilityLabel: routeOptions.tabBarAccessibilityLabel,
408
- testID: routeOptions.tabBarButtonTestID,
409
- style: routeOptions.tabBarItemStyle,
410
- isDisabled,
411
- onPress: () => {
412
- const event = navigation.emit({
413
- type: "tabPress",
414
- target: route.key,
415
- canPreventDefault: true
416
- });
417
- if (!focused && !event.defaultPrevented) {
418
- navigation.navigate(route.name, route.params);
419
- }
420
- },
421
- onLongPress: () => {
422
- navigation.emit({
423
- type: "tabLongPress",
424
- target: route.key
425
- });
426
- }
427
- }
428
- );
429
- })
430
- );
431
- }
432
- const { children, selectedKey, defaultSelectedKey, onSelectionChange } = props;
433
- const firstItemKey = _react2.default.useMemo(() => {
434
- const child = _react2.default.Children.toArray(children)[0];
435
- if (_react2.default.isValidElement(child)) {
436
- return child.props.itemKey;
437
- }
438
- return void 0;
439
- }, [children]);
440
- const isControlled = typeof selectedKey === "string";
441
- const [internalSelectedKey, setInternalSelectedKey] = _react.useState.call(void 0,
442
- _nullishCoalesce(defaultSelectedKey, () => ( firstItemKey))
443
- );
444
- const resolvedSelectedKey = isControlled ? selectedKey : internalSelectedKey;
445
- const handleSelectionChange = (nextKey) => {
446
- if (!isControlled) {
447
- setInternalSelectedKey(nextKey);
448
- }
449
- _optionalChain([onSelectionChange, 'optionalCall', _27 => _27(nextKey)]);
450
- };
451
- const contextValue = _react.useMemo.call(void 0,
452
- () => ({
453
- selectedKey: resolvedSelectedKey,
454
- onSelectionChange: handleSelectionChange,
455
- isDisabled,
456
- showLabel,
457
- size,
458
- variant,
459
- themeColor,
460
- indicatorColor,
461
- activeColor,
462
- inactiveColor
463
- }),
464
- [
465
- activeColor,
466
- inactiveColor,
467
- indicatorColor,
468
- isDisabled,
469
- resolvedSelectedKey,
470
- showLabel,
471
- size,
472
- variant,
473
- themeColor
474
- ]
475
- );
476
- return /* @__PURE__ */ _react2.default.createElement(BottomTabBarContext.Provider, { value: contextValue }, /* @__PURE__ */ _react2.default.createElement(
477
- _reactnative.View,
478
- {
479
- style: [
480
- styles.container,
481
- {
482
- minHeight: sizeStyles.minHeight + insetBottom,
483
- paddingBottom: insetBottom,
484
- backgroundColor: colors.containerColor,
485
- borderTopColor: colors.borderColor
486
- },
487
- style,
488
- _optionalChain([customAppearance, 'optionalAccess', _28 => _28.container])
489
- ]
490
- },
491
- children
492
- ));
493
- };
494
-
495
-
496
-
497
- exports.BottomTabBar = BottomTabBar; exports.BottomTabBarItem = BottomTabBarItem;
@@ -1,211 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { StyleProp, ViewStyle, Insets, TextStyle, GestureResponderEvent } from 'react-native';
3
- import { ThemeColor } from '@xaui/core/types';
4
-
5
- type BottomTabBarSize = 'sm' | 'md' | 'lg';
6
- type BottomTabBarVariant = 'stacked' | 'inline' | 'icon-only';
7
- type BottomTabBarIconRenderParams = {
8
- focused: boolean;
9
- color: string;
10
- size: number;
11
- };
12
- type BottomTabBarItemLabelRenderParams = {
13
- focused: boolean;
14
- color: string;
15
- children: string;
16
- position: 'below-icon' | 'beside-icon';
17
- };
18
- type BottomTabBarItemCustomAppearance = {
19
- container?: StyleProp<ViewStyle>;
20
- indicator?: StyleProp<ViewStyle>;
21
- label?: StyleProp<TextStyle>;
22
- };
23
- type BottomTabBarItemProps = {
24
- /**
25
- * Unique key for this tab item.
26
- */
27
- itemKey: string;
28
- /**
29
- * Label shown under icon.
30
- */
31
- label: ReactNode;
32
- /**
33
- * Icon content or icon render function.
34
- */
35
- icon?: ReactNode | ((params: BottomTabBarIconRenderParams) => ReactNode);
36
- /**
37
- * Optional icon when selected.
38
- */
39
- activeIcon?: ReactNode | ((params: BottomTabBarIconRenderParams) => ReactNode);
40
- /**
41
- * Optional badge shown near icon.
42
- */
43
- badge?: ReactNode;
44
- /**
45
- * Whether this item is disabled.
46
- * @default false
47
- */
48
- isDisabled?: boolean;
49
- /**
50
- * Controlled selected state (standalone mode).
51
- */
52
- isSelected?: boolean;
53
- /**
54
- * Whether to show label.
55
- */
56
- showLabel?: boolean;
57
- /**
58
- * Per-item active color override.
59
- */
60
- activeColor?: string;
61
- /**
62
- * Per-item inactive color override.
63
- */
64
- inactiveColor?: string;
65
- /**
66
- * Per-item active indicator color override.
67
- */
68
- indicatorColor?: string;
69
- /**
70
- * Custom style for item.
71
- */
72
- style?: StyleProp<ViewStyle>;
73
- /**
74
- * Custom appearance styles.
75
- */
76
- customAppearance?: BottomTabBarItemCustomAppearance;
77
- /**
78
- * Callback fired when item is pressed.
79
- */
80
- onPress?: (event: GestureResponderEvent) => void;
81
- /**
82
- * Callback fired when item is long-pressed.
83
- */
84
- onLongPress?: (event: GestureResponderEvent) => void;
85
- /**
86
- * Accessibility label.
87
- */
88
- accessibilityLabel?: string;
89
- /**
90
- * testID for e2e tests.
91
- */
92
- testID?: string;
93
- };
94
- type ExpoRouterTabRoute = {
95
- key: string;
96
- name: string;
97
- params?: Record<string, unknown>;
98
- };
99
- type ExpoRouterTabState = {
100
- index: number;
101
- routes: ExpoRouterTabRoute[];
102
- };
103
- type ExpoRouterTabDescriptorOptions = {
104
- title?: string;
105
- tabBarLabel?: string | ((props: BottomTabBarItemLabelRenderParams) => ReactNode);
106
- tabBarIcon?: (props: BottomTabBarIconRenderParams) => ReactNode;
107
- tabBarActiveTintColor?: string;
108
- tabBarInactiveTintColor?: string;
109
- tabBarBadge?: ReactNode;
110
- tabBarShowLabel?: boolean;
111
- tabBarButtonTestID?: string;
112
- tabBarAccessibilityLabel?: string;
113
- tabBarItemStyle?: StyleProp<ViewStyle>;
114
- tabBarStyle?: StyleProp<ViewStyle>;
115
- href?: string | null;
116
- };
117
- type ExpoRouterTabDescriptor = {
118
- options: ExpoRouterTabDescriptorOptions;
119
- };
120
- type ExpoRouterTabDescriptors = Record<string, ExpoRouterTabDescriptor>;
121
- type ExpoRouterTabNavigation = {
122
- emit: (options: {
123
- type: 'tabPress' | 'tabLongPress';
124
- target?: string;
125
- canPreventDefault?: boolean;
126
- }) => {
127
- defaultPrevented?: boolean;
128
- };
129
- navigate: (name: string, params?: Record<string, unknown>) => void;
130
- };
131
- type ExpoRouterBottomTabBarCompatibleProps = {
132
- state: ExpoRouterTabState;
133
- descriptors: ExpoRouterTabDescriptors;
134
- navigation: ExpoRouterTabNavigation;
135
- insets?: Partial<Insets>;
136
- };
137
- type BottomTabBarBaseProps = {
138
- /**
139
- * Shared theme color.
140
- * @default 'primary'
141
- */
142
- themeColor?: ThemeColor;
143
- /**
144
- * Bar size.
145
- * @default 'md'
146
- */
147
- size?: BottomTabBarSize;
148
- /**
149
- * Layout variant for each tab item.
150
- * @default 'stacked'
151
- */
152
- variant?: BottomTabBarVariant;
153
- /**
154
- * Whether all items are disabled.
155
- * @default false
156
- */
157
- isDisabled?: boolean;
158
- /**
159
- * Whether labels are shown by default.
160
- * @default true
161
- */
162
- showLabel?: boolean;
163
- /**
164
- * Safe area bottom inset (manual mode). In expo-router mode this comes from `insets.bottom`.
165
- */
166
- insetBottom?: number;
167
- /**
168
- * Active indicator color override.
169
- */
170
- indicatorColor?: string;
171
- /**
172
- * Active icon/label color override.
173
- */
174
- activeColor?: string;
175
- /**
176
- * Inactive icon/label color override.
177
- */
178
- inactiveColor?: string;
179
- /**
180
- * Bar container style.
181
- */
182
- style?: StyleProp<ViewStyle>;
183
- /**
184
- * Custom appearance styles.
185
- */
186
- customAppearance?: {
187
- container?: StyleProp<ViewStyle>;
188
- };
189
- };
190
- type BottomTabBarComposableProps = BottomTabBarBaseProps & {
191
- children: ReactNode;
192
- /**
193
- * Controlled selected item key.
194
- */
195
- selectedKey?: string;
196
- /**
197
- * Uncontrolled default selected item key.
198
- */
199
- defaultSelectedKey?: string;
200
- /**
201
- * Callback fired when selected item changes.
202
- */
203
- onSelectionChange?: (key: string) => void;
204
- };
205
- type BottomTabBarProps = BottomTabBarComposableProps | (BottomTabBarBaseProps & ExpoRouterBottomTabBarCompatibleProps);
206
-
207
- declare const BottomTabBar: React.FC<BottomTabBarProps>;
208
-
209
- declare const BottomTabBarItem: React.FC<BottomTabBarItemProps>;
210
-
211
- export { BottomTabBar, type BottomTabBarComposableProps, type BottomTabBarIconRenderParams, BottomTabBarItem, type BottomTabBarItemCustomAppearance, type BottomTabBarItemLabelRenderParams, type BottomTabBarItemProps, type BottomTabBarProps, type BottomTabBarSize, type BottomTabBarVariant, type ExpoRouterBottomTabBarCompatibleProps, type ExpoRouterTabDescriptor, type ExpoRouterTabDescriptorOptions, type ExpoRouterTabDescriptors, type ExpoRouterTabNavigation, type ExpoRouterTabRoute, type ExpoRouterTabState };