@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.
Files changed (234) hide show
  1. package/dist/chunk-KFCORXWW.cjs +150 -0
  2. package/dist/chunk-M7P46XKI.cjs +100 -0
  3. package/dist/chunk-N357EQCZ.js +150 -0
  4. package/dist/chunk-NHPQQQ7P.cjs +734 -0
  5. package/dist/chunk-PBVPOX7D.js +734 -0
  6. package/dist/chunk-RBNCR5KB.js +100 -0
  7. package/dist/index.cjs +40 -1
  8. package/dist/index.d.cts +5 -2
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.js +40 -0
  11. package/dist/system/index.cjs +7 -0
  12. package/dist/system/index.d.cts +83 -0
  13. package/dist/system/index.d.ts +83 -0
  14. package/dist/system/index.js +7 -0
  15. package/dist/theme/index.cjs +36 -0
  16. package/dist/theme/index.d.cts +539 -0
  17. package/dist/theme/index.d.ts +539 -0
  18. package/dist/theme/index.js +36 -0
  19. package/dist/theme.type-B3ODSLbB.d.cts +153 -0
  20. package/dist/theme.type-B3ODSLbB.d.ts +153 -0
  21. package/package.json +30 -248
  22. package/README.md +0 -178
  23. package/dist/alert/index.cjs +0 -340
  24. package/dist/alert/index.d.cts +0 -46
  25. package/dist/alert/index.d.ts +0 -46
  26. package/dist/alert/index.js +0 -340
  27. package/dist/app-bar/index.cjs +0 -148
  28. package/dist/app-bar/index.d.cts +0 -59
  29. package/dist/app-bar/index.d.ts +0 -59
  30. package/dist/app-bar/index.js +0 -148
  31. package/dist/autocomplete/index.cjs +0 -1122
  32. package/dist/autocomplete/index.d.cts +0 -88
  33. package/dist/autocomplete/index.d.ts +0 -88
  34. package/dist/autocomplete/index.js +0 -1122
  35. package/dist/avatar/index.cjs +0 -281
  36. package/dist/avatar/index.d.cts +0 -123
  37. package/dist/avatar/index.d.ts +0 -123
  38. package/dist/avatar/index.js +0 -281
  39. package/dist/badge/index.cjs +0 -197
  40. package/dist/badge/index.d.cts +0 -94
  41. package/dist/badge/index.d.ts +0 -94
  42. package/dist/badge/index.js +0 -197
  43. package/dist/bottom-sheet/index.cjs +0 -9
  44. package/dist/bottom-sheet/index.d.cts +0 -84
  45. package/dist/bottom-sheet/index.d.ts +0 -84
  46. package/dist/bottom-sheet/index.js +0 -9
  47. package/dist/bottom-tab-bar/index.cjs +0 -497
  48. package/dist/bottom-tab-bar/index.d.cts +0 -211
  49. package/dist/bottom-tab-bar/index.d.ts +0 -211
  50. package/dist/bottom-tab-bar/index.js +0 -497
  51. package/dist/button/index.cjs +0 -392
  52. package/dist/button/index.d.cts +0 -174
  53. package/dist/button/index.d.ts +0 -174
  54. package/dist/button/index.js +0 -392
  55. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  56. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  57. package/dist/card/index.cjs +0 -338
  58. package/dist/card/index.d.cts +0 -191
  59. package/dist/card/index.d.ts +0 -191
  60. package/dist/card/index.js +0 -338
  61. package/dist/carousel/index.cjs +0 -381
  62. package/dist/carousel/index.d.cts +0 -147
  63. package/dist/carousel/index.d.ts +0 -147
  64. package/dist/carousel/index.js +0 -381
  65. package/dist/chart/index.cjs +0 -1026
  66. package/dist/chart/index.d.cts +0 -218
  67. package/dist/chart/index.d.ts +0 -218
  68. package/dist/chart/index.js +0 -1026
  69. package/dist/checkbox/index.cjs +0 -443
  70. package/dist/checkbox/index.d.cts +0 -73
  71. package/dist/checkbox/index.d.ts +0 -73
  72. package/dist/checkbox/index.js +0 -443
  73. package/dist/chip/index.cjs +0 -503
  74. package/dist/chip/index.d.cts +0 -195
  75. package/dist/chip/index.d.ts +0 -195
  76. package/dist/chip/index.js +0 -503
  77. package/dist/chunk-4JFWQ5XT.js +0 -368
  78. package/dist/chunk-56RPWZD2.cjs +0 -9
  79. package/dist/chunk-7UFBLUMV.cjs +0 -136
  80. package/dist/chunk-A45TVXU5.js +0 -337
  81. package/dist/chunk-BYWUAPC4.cjs +0 -368
  82. package/dist/chunk-DECMUMCI.js +0 -0
  83. package/dist/chunk-DHSTKO3K.cjs +0 -19
  84. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  85. package/dist/chunk-EUQDGTST.cjs +0 -1
  86. package/dist/chunk-GBHQCAKW.js +0 -19
  87. package/dist/chunk-RBSA4NH4.js +0 -136
  88. package/dist/chunk-SHBDANQN.js +0 -9
  89. package/dist/chunk-UGEINZM7.cjs +0 -290
  90. package/dist/chunk-UU4HHBDN.js +0 -290
  91. package/dist/chunk-VSZEXOUN.js +0 -384
  92. package/dist/chunk-YIEUN3G5.cjs +0 -384
  93. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  94. package/dist/chunk-ZY7IUTAT.js +0 -75
  95. package/dist/color-picker/index.cjs +0 -457
  96. package/dist/color-picker/index.d.cts +0 -124
  97. package/dist/color-picker/index.d.ts +0 -124
  98. package/dist/color-picker/index.js +0 -457
  99. package/dist/core/index.cjs +0 -24
  100. package/dist/core/index.d.cts +0 -28
  101. package/dist/core/index.d.ts +0 -28
  102. package/dist/core/index.js +0 -24
  103. package/dist/datepicker/index.cjs +0 -1625
  104. package/dist/datepicker/index.d.cts +0 -45
  105. package/dist/datepicker/index.d.ts +0 -45
  106. package/dist/datepicker/index.js +0 -1625
  107. package/dist/dialog/index.cjs +0 -372
  108. package/dist/dialog/index.d.cts +0 -151
  109. package/dist/dialog/index.d.ts +0 -151
  110. package/dist/dialog/index.js +0 -372
  111. package/dist/divider/index.cjs +0 -8
  112. package/dist/divider/index.d.cts +0 -30
  113. package/dist/divider/index.d.ts +0 -30
  114. package/dist/divider/index.js +0 -8
  115. package/dist/drawer/index.cjs +0 -237
  116. package/dist/drawer/index.d.cts +0 -58
  117. package/dist/drawer/index.d.ts +0 -58
  118. package/dist/drawer/index.js +0 -237
  119. package/dist/expansion-panel/index.cjs +0 -441
  120. package/dist/expansion-panel/index.d.cts +0 -153
  121. package/dist/expansion-panel/index.d.ts +0 -153
  122. package/dist/expansion-panel/index.js +0 -441
  123. package/dist/fab/index.cjs +0 -9
  124. package/dist/fab/index.d.cts +0 -10
  125. package/dist/fab/index.d.ts +0 -10
  126. package/dist/fab/index.js +0 -9
  127. package/dist/fab-menu/index.cjs +0 -330
  128. package/dist/fab-menu/index.d.cts +0 -125
  129. package/dist/fab-menu/index.d.ts +0 -125
  130. package/dist/fab-menu/index.js +0 -330
  131. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  132. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  133. package/dist/feature-discovery/index.cjs +0 -464
  134. package/dist/feature-discovery/index.d.cts +0 -82
  135. package/dist/feature-discovery/index.d.ts +0 -82
  136. package/dist/feature-discovery/index.js +0 -464
  137. package/dist/indicator/index.cjs +0 -8
  138. package/dist/indicator/index.d.cts +0 -47
  139. package/dist/indicator/index.d.ts +0 -47
  140. package/dist/indicator/index.js +0 -8
  141. package/dist/input/index.cjs +0 -1462
  142. package/dist/input/index.d.cts +0 -522
  143. package/dist/input/index.d.ts +0 -522
  144. package/dist/input/index.js +0 -1462
  145. package/dist/input-trigger/index.cjs +0 -197
  146. package/dist/input-trigger/index.d.cts +0 -11
  147. package/dist/input-trigger/index.d.ts +0 -11
  148. package/dist/input-trigger/index.js +0 -197
  149. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  150. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  151. package/dist/list/index.cjs +0 -395
  152. package/dist/list/index.d.cts +0 -188
  153. package/dist/list/index.d.ts +0 -188
  154. package/dist/list/index.js +0 -395
  155. package/dist/menu/index.cjs +0 -316
  156. package/dist/menu/index.d.cts +0 -115
  157. package/dist/menu/index.d.ts +0 -115
  158. package/dist/menu/index.js +0 -316
  159. package/dist/menubox/index.cjs +0 -297
  160. package/dist/menubox/index.d.cts +0 -98
  161. package/dist/menubox/index.d.ts +0 -98
  162. package/dist/menubox/index.js +0 -297
  163. package/dist/pager/index.cjs +0 -205
  164. package/dist/pager/index.d.cts +0 -93
  165. package/dist/pager/index.d.ts +0 -93
  166. package/dist/pager/index.js +0 -205
  167. package/dist/picker/index.cjs +0 -244
  168. package/dist/picker/index.d.cts +0 -121
  169. package/dist/picker/index.d.ts +0 -121
  170. package/dist/picker/index.js +0 -244
  171. package/dist/progress/index.cjs +0 -219
  172. package/dist/progress/index.d.cts +0 -47
  173. package/dist/progress/index.d.ts +0 -47
  174. package/dist/progress/index.js +0 -219
  175. package/dist/radio/index.cjs +0 -465
  176. package/dist/radio/index.d.cts +0 -145
  177. package/dist/radio/index.d.ts +0 -145
  178. package/dist/radio/index.js +0 -465
  179. package/dist/refresh-control/index.cjs +0 -45
  180. package/dist/refresh-control/index.d.cts +0 -55
  181. package/dist/refresh-control/index.d.ts +0 -55
  182. package/dist/refresh-control/index.js +0 -45
  183. package/dist/segment-button/index.cjs +0 -405
  184. package/dist/segment-button/index.d.cts +0 -141
  185. package/dist/segment-button/index.d.ts +0 -141
  186. package/dist/segment-button/index.js +0 -405
  187. package/dist/select/index.cjs +0 -878
  188. package/dist/select/index.d.cts +0 -192
  189. package/dist/select/index.d.ts +0 -192
  190. package/dist/select/index.js +0 -878
  191. package/dist/skeleton/index.cjs +0 -89
  192. package/dist/skeleton/index.d.cts +0 -45
  193. package/dist/skeleton/index.d.ts +0 -45
  194. package/dist/skeleton/index.js +0 -89
  195. package/dist/slider/index.cjs +0 -576
  196. package/dist/slider/index.d.cts +0 -171
  197. package/dist/slider/index.d.ts +0 -171
  198. package/dist/slider/index.js +0 -576
  199. package/dist/snackbar/index.cjs +0 -436
  200. package/dist/snackbar/index.d.cts +0 -174
  201. package/dist/snackbar/index.d.ts +0 -174
  202. package/dist/snackbar/index.js +0 -436
  203. package/dist/snippet/index.cjs +0 -314
  204. package/dist/snippet/index.d.cts +0 -95
  205. package/dist/snippet/index.d.ts +0 -95
  206. package/dist/snippet/index.js +0 -314
  207. package/dist/stepper/index.cjs +0 -550
  208. package/dist/stepper/index.d.cts +0 -137
  209. package/dist/stepper/index.d.ts +0 -137
  210. package/dist/stepper/index.js +0 -550
  211. package/dist/switch/index.cjs +0 -358
  212. package/dist/switch/index.d.cts +0 -28
  213. package/dist/switch/index.d.ts +0 -28
  214. package/dist/switch/index.js +0 -358
  215. package/dist/tabs/index.cjs +0 -440
  216. package/dist/tabs/index.d.cts +0 -180
  217. package/dist/tabs/index.d.ts +0 -180
  218. package/dist/tabs/index.js +0 -440
  219. package/dist/timepicker/index.cjs +0 -823
  220. package/dist/timepicker/index.d.cts +0 -215
  221. package/dist/timepicker/index.d.ts +0 -215
  222. package/dist/timepicker/index.js +0 -823
  223. package/dist/toolbar/index.cjs +0 -333
  224. package/dist/toolbar/index.d.cts +0 -100
  225. package/dist/toolbar/index.d.ts +0 -100
  226. package/dist/toolbar/index.js +0 -333
  227. package/dist/typography/index.cjs +0 -238
  228. package/dist/typography/index.d.cts +0 -113
  229. package/dist/typography/index.d.ts +0 -113
  230. package/dist/typography/index.js +0 -238
  231. package/dist/view/index.cjs +0 -1361
  232. package/dist/view/index.d.cts +0 -833
  233. package/dist/view/index.d.ts +0 -833
  234. package/dist/view/index.js +0 -1361
@@ -1,392 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }
2
-
3
- var _chunkYIEUN3G5cjs = require('../chunk-YIEUN3G5.cjs');
4
- require('../chunk-56RPWZD2.cjs');
5
-
6
-
7
-
8
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
9
-
10
- // src/components/button/button.tsx
11
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
12
- var _reactnative = require('react-native');
13
-
14
- // src/components/button/button.style.ts
15
-
16
- var styles = _reactnative.StyleSheet.create({
17
- button: {
18
- flexDirection: "row",
19
- alignItems: "center",
20
- justifyContent: "center",
21
- overflow: "hidden"
22
- },
23
- contentContainer: {
24
- flexDirection: "row",
25
- alignItems: "center",
26
- justifyContent: "center",
27
- gap: 8
28
- },
29
- text: {
30
- fontWeight: "500",
31
- textAlign: "center"
32
- },
33
- startContent: {
34
- marginRight: 4
35
- },
36
- endContent: {
37
- marginLeft: 4
38
- },
39
- spinner: {
40
- marginHorizontal: 4
41
- },
42
- fullWidth: {
43
- flexShrink: 1,
44
- flexBasis: "auto",
45
- width: "100%"
46
- },
47
- disabled: {
48
- opacity: 0.5
49
- },
50
- disabledText: {
51
- opacity: 0.7
52
- }
53
- });
54
-
55
- // src/components/button/button.hook.ts
56
-
57
- var _core = require('@xaui/core');
58
- var useTextStyles = (themeColor, variant) => {
59
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
60
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
61
- const colorScheme = theme.colors[safeThemeColor];
62
- const textColor = _react.useMemo.call(void 0, () => {
63
- if (variant === "solid") return colorScheme.onMain;
64
- if (variant === "flat" || variant === "faded") return colorScheme.onContainer;
65
- return colorScheme.main;
66
- }, [variant, colorScheme]);
67
- return {
68
- textColor
69
- };
70
- };
71
- function useSizesStyles(size) {
72
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
73
- const sizeStyles = _react.useMemo.call(void 0, () => {
74
- const sizes = {
75
- xs: {
76
- paddingHorizontal: theme.spacing.sm,
77
- paddingVertical: theme.spacing.xs,
78
- minHeight: theme.componentSizes.xs,
79
- fontSize: theme.fontSizes.xs
80
- },
81
- sm: {
82
- paddingHorizontal: theme.spacing.md,
83
- paddingVertical: theme.spacing.xs,
84
- minHeight: theme.componentSizes.sm,
85
- fontSize: theme.fontSizes.sm
86
- },
87
- md: {
88
- paddingHorizontal: theme.spacing.md,
89
- paddingVertical: theme.spacing.sm,
90
- minHeight: theme.componentSizes.md,
91
- fontSize: theme.fontSizes.md
92
- },
93
- lg: {
94
- paddingHorizontal: theme.spacing.lg,
95
- paddingVertical: theme.spacing.md,
96
- minHeight: theme.componentSizes.lg,
97
- fontSize: theme.fontSizes.lg
98
- }
99
- };
100
- return sizes[size];
101
- }, [size, theme]);
102
- const spinnerSize = _react.useMemo.call(void 0, () => {
103
- const sizes = {
104
- xs: 14,
105
- sm: 16,
106
- md: 18,
107
- lg: 20
108
- };
109
- return sizes[size];
110
- }, [size]);
111
- return { sizeStyles, spinnerSize };
112
- }
113
- function useVariantSizesStyles(themeColor, variant, elevation = 0) {
114
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
115
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
116
- const colorScheme = theme.colors[safeThemeColor];
117
- const variantStyles = _react.useMemo.call(void 0, () => {
118
- const styles2 = {
119
- solid: {
120
- backgroundColor: colorScheme.main,
121
- borderWidth: 0
122
- },
123
- bordered: {
124
- backgroundColor: "transparent",
125
- borderWidth: theme.borderWidth.md,
126
- borderColor: colorScheme.main
127
- },
128
- flat: {
129
- backgroundColor: colorScheme.container,
130
- borderWidth: 0
131
- },
132
- light: {
133
- backgroundColor: "transparent",
134
- borderWidth: 0
135
- },
136
- faded: {
137
- backgroundColor: colorScheme.container,
138
- borderWidth: theme.borderWidth.md,
139
- borderColor: colorScheme.main
140
- }
141
- };
142
- const baseStyle = styles2[variant];
143
- const shouldApplyElevation = variant !== "bordered" && variant !== "light";
144
- const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
145
- return {
146
- ...baseStyle,
147
- ...shouldApplyElevation ? shadowStyles : {},
148
- ...shouldApplyElevation && elevation > 0 ? { elevation } : {}
149
- };
150
- }, [variant, colorScheme, theme, elevation]);
151
- return variantStyles;
152
- }
153
-
154
- // src/components/button/button.animation.ts
155
-
156
- var runPressInAnimation = (animatedScale, animatedOpacity) => {
157
- _reactnative.Animated.parallel([
158
- _reactnative.Animated.spring(animatedScale, {
159
- toValue: 0.975,
160
- useNativeDriver: true,
161
- speed: 50,
162
- bounciness: 0
163
- }),
164
- _reactnative.Animated.timing(animatedOpacity, {
165
- toValue: 0.9,
166
- duration: 100,
167
- useNativeDriver: true
168
- })
169
- ]).start();
170
- };
171
- var runPressOutAnimation = (animatedScale, animatedOpacity) => {
172
- _reactnative.Animated.parallel([
173
- _reactnative.Animated.spring(animatedScale, {
174
- toValue: 1,
175
- useNativeDriver: true,
176
- speed: 50,
177
- bounciness: 0
178
- }),
179
- _reactnative.Animated.timing(animatedOpacity, {
180
- toValue: 1,
181
- duration: 100,
182
- useNativeDriver: true
183
- })
184
- ]).start();
185
- };
186
-
187
- // src/components/button/button.tsx
188
- var Button = ({
189
- children,
190
- themeColor = "primary",
191
- variant = "solid",
192
- size = "md",
193
- radius = "md",
194
- startContent,
195
- endContent,
196
- spinnerPlacement = "start",
197
- fullWidth = false,
198
- isDisabled = false,
199
- isLoading = false,
200
- elevation = 0,
201
- customAppearance,
202
- onPress,
203
- onLongPress,
204
- onPressIn,
205
- onPressOut
206
- }) => {
207
- const animatedScale = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
208
- const animatedOpacity = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
209
- const { sizeStyles, spinnerSize } = useSizesStyles(size);
210
- const radiusStyles = _chunk7UFBLUMVcjs.useBorderRadiusStyles.call(void 0, radius);
211
- const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
212
- const { textColor } = useTextStyles(themeColor, variant);
213
- const handlePressIn = (event) => {
214
- if (!isDisabled && !isLoading) {
215
- runPressInAnimation(animatedScale, animatedOpacity);
216
- }
217
- _optionalChain([onPressIn, 'optionalCall', _ => _(event)]);
218
- };
219
- const handlePressOut = (event) => {
220
- if (!isDisabled && !isLoading) {
221
- runPressOutAnimation(animatedScale, animatedOpacity);
222
- }
223
- _optionalChain([onPressOut, 'optionalCall', _2 => _2(event)]);
224
- };
225
- const spinner = /* @__PURE__ */ _react2.default.createElement(
226
- _chunkYIEUN3G5cjs.ActivityIndicator,
227
- {
228
- variant: "circular",
229
- themeColor: variant === "solid" ? void 0 : themeColor,
230
- color: variant === "solid" ? textColor : void 0,
231
- size: spinnerSize
232
- }
233
- );
234
- return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [fullWidth && styles.fullWidth, _optionalChain([customAppearance, 'optionalAccess', _3 => _3.container])] }, /* @__PURE__ */ _react2.default.createElement(
235
- _reactnative.Pressable,
236
- {
237
- onPress: isDisabled || isLoading ? void 0 : onPress,
238
- onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
239
- onPressIn: handlePressIn,
240
- onPressOut: handlePressOut,
241
- disabled: isDisabled || isLoading
242
- },
243
- /* @__PURE__ */ _react2.default.createElement(
244
- _reactnative.Animated.View,
245
- {
246
- style: [
247
- styles.button,
248
- sizeStyles,
249
- radiusStyles,
250
- variantStyles,
251
- fullWidth && styles.fullWidth,
252
- isDisabled && styles.disabled,
253
- {
254
- transform: [{ scale: animatedScale }],
255
- opacity: animatedOpacity
256
- },
257
- _optionalChain([customAppearance, 'optionalAccess', _4 => _4.button])
258
- ]
259
- },
260
- /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.contentContainer }, startContent && (!isLoading || spinnerPlacement !== "start") && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.startContent }, startContent), isLoading && spinnerPlacement === "start" && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.spinner }, spinner), /* @__PURE__ */ _react2.default.createElement(
261
- _reactnative.Text,
262
- {
263
- style: [
264
- styles.text,
265
- { fontSize: sizeStyles.fontSize, color: textColor },
266
- isDisabled && styles.disabledText,
267
- _optionalChain([customAppearance, 'optionalAccess', _5 => _5.text])
268
- ]
269
- },
270
- children
271
- ), isLoading && spinnerPlacement === "end" && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.spinner }, spinner), endContent && (!isLoading || spinnerPlacement !== "end") && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.endContent }, endContent))
272
- )
273
- ));
274
- };
275
-
276
- // src/components/button/icon-button.tsx
277
-
278
-
279
-
280
- // src/components/button/icon-button.style.ts
281
-
282
- var iconButtonStyles = _reactnative.StyleSheet.create({
283
- container: {
284
- alignItems: "center",
285
- justifyContent: "center"
286
- },
287
- button: {
288
- alignItems: "center",
289
- justifyContent: "center",
290
- aspectRatio: 1
291
- },
292
- disabled: {
293
- opacity: 0.5
294
- }
295
- });
296
-
297
- // src/components/button/icon-button.hook.ts
298
-
299
- var useIconButtonSizeStyles = (size) => {
300
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
301
- return _react.useMemo.call(void 0, () => {
302
- const sizeMap = {
303
- xs: { width: theme.componentSizes.xs, height: theme.componentSizes.xs },
304
- sm: { width: theme.componentSizes.sm, height: theme.componentSizes.sm },
305
- md: { width: theme.componentSizes.md, height: theme.componentSizes.md },
306
- lg: { width: theme.componentSizes.lg, height: theme.componentSizes.md }
307
- };
308
- return sizeMap[size];
309
- }, [size, theme]);
310
- };
311
-
312
- // src/components/button/icon-button.tsx
313
- var IconButton = ({
314
- icon,
315
- themeColor = "primary",
316
- variant = "solid",
317
- size = "md",
318
- radius = "md",
319
- isDisabled = false,
320
- isLoading = false,
321
- elevation = 0,
322
- customAppearance,
323
- onPress,
324
- onLongPress,
325
- onPressIn,
326
- onPressOut
327
- }) => {
328
- const animatedScale = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
329
- const animatedOpacity = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
330
- const sizeStyles = useIconButtonSizeStyles(size);
331
- const radiusStyles = _chunk7UFBLUMVcjs.useBorderRadiusStyles.call(void 0, radius);
332
- const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
333
- const { textColor } = useTextStyles(themeColor, variant);
334
- const handlePressIn = (event) => {
335
- if (!isDisabled && !isLoading) {
336
- runPressInAnimation(animatedScale, animatedOpacity);
337
- }
338
- _optionalChain([onPressIn, 'optionalCall', _6 => _6(event)]);
339
- };
340
- const handlePressOut = (event) => {
341
- if (!isDisabled && !isLoading) {
342
- runPressOutAnimation(animatedScale, animatedOpacity);
343
- }
344
- _optionalChain([onPressOut, 'optionalCall', _7 => _7(event)]);
345
- };
346
- const spinnerSize = {
347
- xs: 14,
348
- sm: 16,
349
- md: 18,
350
- lg: 20
351
- }[size];
352
- return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [iconButtonStyles.container, _optionalChain([customAppearance, 'optionalAccess', _8 => _8.container])] }, /* @__PURE__ */ _react2.default.createElement(
353
- _reactnative.Pressable,
354
- {
355
- onPress: isDisabled || isLoading ? void 0 : onPress,
356
- onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
357
- onPressIn: handlePressIn,
358
- onPressOut: handlePressOut,
359
- disabled: isDisabled || isLoading
360
- },
361
- /* @__PURE__ */ _react2.default.createElement(
362
- _reactnative.Animated.View,
363
- {
364
- style: [
365
- iconButtonStyles.button,
366
- sizeStyles,
367
- radiusStyles,
368
- variantStyles,
369
- isDisabled && iconButtonStyles.disabled,
370
- {
371
- transform: [{ scale: animatedScale }],
372
- opacity: animatedOpacity
373
- },
374
- _optionalChain([customAppearance, 'optionalAccess', _9 => _9.button])
375
- ]
376
- },
377
- isLoading ? /* @__PURE__ */ _react2.default.createElement(
378
- _chunkYIEUN3G5cjs.ActivityIndicator,
379
- {
380
- variant: "circular",
381
- themeColor: variant === "solid" ? void 0 : themeColor,
382
- color: variant === "solid" ? textColor : void 0,
383
- size: spinnerSize
384
- }
385
- ) : icon
386
- )
387
- ));
388
- };
389
-
390
-
391
-
392
- exports.Button = Button; exports.IconButton = IconButton;
@@ -1,174 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ViewStyle, TextStyle, GestureResponderEvent } from 'react-native';
3
- import { ThemeColor, Size } from '@xaui/core/types';
4
-
5
- type ButtonVariant = 'solid' | 'bordered' | 'flat' | 'light' | 'faded';
6
- type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
7
- type SpinnerPlacement = 'start' | 'end';
8
- type ElevationLevel = 0 | 1 | 2 | 3 | 4;
9
- type ButtonCustomAppearance = {
10
- /**
11
- * Custom styles for the outer container
12
- */
13
- container?: ViewStyle;
14
- /**
15
- * Custom styles for the button
16
- */
17
- button?: ViewStyle;
18
- /**
19
- * Custom styles for the button text
20
- */
21
- text?: TextStyle;
22
- };
23
- type ButtonProps = {
24
- /**
25
- * The content to display in the button.
26
- */
27
- children: ReactNode;
28
- /**
29
- * The theme color of the button.
30
- * @default 'default'
31
- */
32
- themeColor?: ThemeColor;
33
- /**
34
- * The variant of the button.
35
- * @default 'solid'
36
- */
37
- variant?: ButtonVariant;
38
- /**
39
- * The size of the button.
40
- * @default 'md'
41
- */
42
- size?: Size;
43
- /**
44
- * The border radius of the button.
45
- * @default 'md'
46
- */
47
- radius?: ButtonRadius;
48
- /**
49
- * Content to display at the start of the button.
50
- */
51
- startContent?: ReactNode;
52
- /**
53
- * Content to display at the end of the button.
54
- */
55
- endContent?: ReactNode;
56
- /**
57
- * The placement of the spinner when isLoading is true.
58
- * @default 'start'
59
- */
60
- spinnerPlacement?: SpinnerPlacement;
61
- /**
62
- * Whether the button should take the full width of its container.
63
- * @default false
64
- */
65
- fullWidth?: boolean;
66
- /**
67
- * Whether the button is disabled.
68
- * @default false
69
- */
70
- isDisabled?: boolean;
71
- /**
72
- * Whether the button is in a loading state.
73
- * @default false
74
- */
75
- isLoading?: boolean;
76
- /**
77
- * Android elevation level from 0 to 4.
78
- * Does not apply to `bordered` and `light` variants.
79
- * @default 0
80
- */
81
- elevation?: ElevationLevel;
82
- /**
83
- * Custom appearance styles for button parts
84
- */
85
- customAppearance?: ButtonCustomAppearance;
86
- /**
87
- * Callback fired when the button is pressed.
88
- */
89
- onPress?: (event: GestureResponderEvent) => void;
90
- /**
91
- * Callback fired when the button is long pressed.
92
- */
93
- onLongPress?: (event: GestureResponderEvent) => void;
94
- /**
95
- * Callback fired when the button press starts.
96
- */
97
- onPressIn?: (event: GestureResponderEvent) => void;
98
- /**
99
- * Callback fired when the button press ends.
100
- */
101
- onPressOut?: (event: GestureResponderEvent) => void;
102
- };
103
-
104
- declare const Button: React.FC<ButtonProps>;
105
-
106
- type IconButtonProps = {
107
- /**
108
- * Icon to display in the button
109
- */
110
- icon: ReactNode;
111
- /**
112
- * Button size
113
- * @default 'md'
114
- */
115
- size?: Size;
116
- /**
117
- * Button variant
118
- * @default 'solid'
119
- */
120
- variant?: ButtonVariant;
121
- /**
122
- * Theme color
123
- * @default 'primary'
124
- */
125
- themeColor?: ThemeColor;
126
- /**
127
- * Border radius
128
- * @default 'md'
129
- */
130
- radius?: ButtonRadius;
131
- /**
132
- * Whether the button is disabled
133
- * @default false
134
- */
135
- isDisabled?: boolean;
136
- /**
137
- * Whether the button is loading
138
- * @default false
139
- */
140
- isLoading?: boolean;
141
- /**
142
- * Android elevation level from 0 to 4.
143
- * Does not apply to `bordered` and `light` variants.
144
- * @default 0
145
- */
146
- elevation?: ElevationLevel;
147
- /**
148
- * Custom appearance overrides
149
- */
150
- customAppearance?: {
151
- container?: ViewStyle;
152
- button?: ViewStyle;
153
- };
154
- /**
155
- * Press handler
156
- */
157
- onPress?: (event: GestureResponderEvent) => void;
158
- /**
159
- * Long press handler
160
- */
161
- onLongPress?: (event: GestureResponderEvent) => void;
162
- /**
163
- * Press in handler
164
- */
165
- onPressIn?: (event: GestureResponderEvent) => void;
166
- /**
167
- * Press out handler
168
- */
169
- onPressOut?: (event: GestureResponderEvent) => void;
170
- };
171
-
172
- declare const IconButton: React.FC<IconButtonProps>;
173
-
174
- export { Button, type ButtonProps, type ButtonRadius, type ButtonVariant, IconButton, type IconButtonProps, type SpinnerPlacement };