@xaui/native 0.0.17 → 0.0.19

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 (52) hide show
  1. package/dist/accordion/index.js +2 -2
  2. package/dist/alert/index.js +352 -4
  3. package/dist/autocomplete/index.js +1121 -5
  4. package/dist/avatar/index.js +276 -5
  5. package/dist/badge/index.js +193 -4
  6. package/dist/bottom-sheet/index.js +364 -4
  7. package/dist/button/index.js +2 -2
  8. package/dist/card/index.cjs +429 -0
  9. package/dist/card/index.d.cts +186 -0
  10. package/dist/card/index.d.ts +186 -0
  11. package/dist/card/index.js +336 -0
  12. package/dist/carousel/index.js +377 -3
  13. package/dist/checkbox/index.js +1 -1
  14. package/dist/chip/index.js +497 -6
  15. package/dist/{chunk-VUVE6PK7.js → chunk-F7WH4DMG.js} +1 -1
  16. package/dist/{chunk-TJ2FPLLZ.js → chunk-JEGEPGVU.js} +2 -2
  17. package/dist/{chunk-MZL77KV5.js → chunk-LTKYHG5V.js} +1 -1
  18. package/dist/{chunk-RIVFFZRO.js → chunk-LUBWRVI2.js} +1 -1
  19. package/dist/core/index.cjs +1 -1
  20. package/dist/core/index.js +1 -1
  21. package/dist/datepicker/index.js +1623 -4
  22. package/dist/divider/index.js +2 -2
  23. package/dist/fab/index.js +3 -3
  24. package/dist/fab-menu/index.js +324 -6
  25. package/dist/index.cjs +0 -6446
  26. package/dist/index.d.cts +2 -19
  27. package/dist/index.d.ts +2 -19
  28. package/dist/index.js +0 -73
  29. package/dist/indicator/index.js +2 -2
  30. package/dist/menu/index.js +1 -1
  31. package/dist/progress/index.js +1 -1
  32. package/dist/segment-button/index.cjs +2 -2
  33. package/dist/segment-button/index.js +400 -5
  34. package/dist/select/index.js +1 -1
  35. package/dist/skeleton/index.cjs +160 -0
  36. package/dist/skeleton/index.d.cts +45 -0
  37. package/dist/skeleton/index.d.ts +45 -0
  38. package/dist/skeleton/index.js +89 -0
  39. package/dist/switch/index.js +1 -1
  40. package/dist/typography/index.js +146 -4
  41. package/package.json +11 -1
  42. package/dist/chunk-6PXMB5CH.js +0 -503
  43. package/dist/chunk-DBKVHMSA.js +0 -329
  44. package/dist/chunk-EW5YLICE.js +0 -382
  45. package/dist/chunk-JJOVGRNI.js +0 -1627
  46. package/dist/chunk-K2HSVISE.js +0 -281
  47. package/dist/chunk-OXVIVNIJ.js +0 -356
  48. package/dist/chunk-PWCUULAL.js +0 -150
  49. package/dist/chunk-S3MGBM3G.js +0 -368
  50. package/dist/chunk-STUNTRKJ.js +0 -405
  51. package/dist/chunk-UGDGCMGC.js +0 -197
  52. package/dist/chunk-XUYIAA3A.js +0 -1127
@@ -0,0 +1,186 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, TextStyle, GestureResponderEvent } from 'react-native';
3
+ import { T as ThemeColor, R as Radius } from '../index-BOw6tbkc.js';
4
+ import { E as ElevationLevel } from '../button.type-D8tzEBo7.js';
5
+
6
+ type CardCustomAppearance = {
7
+ /**
8
+ * Custom styles for the card container
9
+ */
10
+ container?: ViewStyle;
11
+ /**
12
+ * Custom styles for the card header section
13
+ */
14
+ header?: ViewStyle;
15
+ /**
16
+ * Custom styles for the card body section
17
+ */
18
+ body?: ViewStyle;
19
+ /**
20
+ * Custom styles for the card footer section
21
+ */
22
+ footer?: ViewStyle;
23
+ /**
24
+ * Custom styles for title text
25
+ */
26
+ title?: TextStyle;
27
+ /**
28
+ * Custom styles for description text
29
+ */
30
+ description?: TextStyle;
31
+ };
32
+ type CardProps = {
33
+ /**
34
+ * Content to render inside the card.
35
+ */
36
+ children: ReactNode;
37
+ /**
38
+ * The theme color of the card.
39
+ * @default 'default'
40
+ */
41
+ themeColor?: ThemeColor;
42
+ /**
43
+ * Card corner radius.
44
+ * @default 'lg'
45
+ */
46
+ radius?: Radius;
47
+ /**
48
+ * Android elevation level from 0 to 4.
49
+ * @default 0
50
+ */
51
+ elevation?: ElevationLevel;
52
+ /**
53
+ * Whether the card should take full width of its container.
54
+ * @default false
55
+ */
56
+ fullWidth?: boolean;
57
+ /**
58
+ * Whether hover interactions are enabled.
59
+ * @default false
60
+ */
61
+ isHoverable?: boolean;
62
+ /**
63
+ * Whether press interactions are enabled.
64
+ * @default false
65
+ */
66
+ isPressable?: boolean;
67
+ /**
68
+ * Whether the whole card should be blurred.
69
+ * @default false
70
+ */
71
+ isBlurred?: boolean;
72
+ /**
73
+ * Whether the footer section should be blurred.
74
+ * @default false
75
+ */
76
+ isFooterBlurred?: boolean;
77
+ /**
78
+ * Whether the card is disabled.
79
+ * @default false
80
+ */
81
+ isDisabled?: boolean;
82
+ /**
83
+ * Disable all card animations.
84
+ * @default false
85
+ */
86
+ disableAnimation?: boolean;
87
+ /**
88
+ * Disable press ripple animation.
89
+ * @default false
90
+ */
91
+ disableRipple?: boolean;
92
+ /**
93
+ * Allow text selection while pressing a pressable card.
94
+ * @default false
95
+ */
96
+ allowTextSelectionOnPress?: boolean;
97
+ /**
98
+ * Custom appearance styles for card parts.
99
+ */
100
+ customAppearance?: CardCustomAppearance;
101
+ /**
102
+ * Callback fired when card is pressed.
103
+ */
104
+ onPress?: (event: GestureResponderEvent) => void;
105
+ /**
106
+ * Callback fired when card is long pressed.
107
+ */
108
+ onLongPress?: (event: GestureResponderEvent) => void;
109
+ /**
110
+ * Callback fired when card press starts.
111
+ */
112
+ onPressIn?: (event: GestureResponderEvent) => void;
113
+ /**
114
+ * Callback fired when card press ends.
115
+ */
116
+ onPressOut?: (event: GestureResponderEvent) => void;
117
+ };
118
+ type CardHeaderProps = {
119
+ /**
120
+ * Header content.
121
+ */
122
+ children: ReactNode;
123
+ /**
124
+ * Custom styles for the header container.
125
+ */
126
+ customAppearance?: {
127
+ container?: ViewStyle;
128
+ };
129
+ };
130
+ type CardBodyProps = {
131
+ /**
132
+ * Body content.
133
+ */
134
+ children: ReactNode;
135
+ /**
136
+ * Custom styles for the body container.
137
+ */
138
+ customAppearance?: {
139
+ container?: ViewStyle;
140
+ };
141
+ };
142
+ type CardFooterProps = {
143
+ /**
144
+ * Footer content.
145
+ */
146
+ children: ReactNode;
147
+ /**
148
+ * Custom styles for the footer container.
149
+ */
150
+ customAppearance?: {
151
+ container?: ViewStyle;
152
+ };
153
+ };
154
+ type CardTitleProps = {
155
+ /**
156
+ * Title content.
157
+ */
158
+ children: ReactNode;
159
+ /**
160
+ * Custom styles for the title text.
161
+ */
162
+ customAppearance?: {
163
+ text?: TextStyle;
164
+ };
165
+ };
166
+ type CardDescriptionProps = {
167
+ /**
168
+ * Description content.
169
+ */
170
+ children: ReactNode;
171
+ /**
172
+ * Custom styles for the description text.
173
+ */
174
+ customAppearance?: {
175
+ text?: TextStyle;
176
+ };
177
+ };
178
+
179
+ declare const Card: React.FC<CardProps>;
180
+ declare const CardHeader: React.FC<CardHeaderProps>;
181
+ declare const CardBody: React.FC<CardBodyProps>;
182
+ declare const CardFooter: React.FC<CardFooterProps>;
183
+ declare const CardTitle: React.FC<CardTitleProps>;
184
+ declare const CardDescription: React.FC<CardDescriptionProps>;
185
+
186
+ export { Card, CardBody, type CardBodyProps, type CardCustomAppearance, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps };
@@ -0,0 +1,336 @@
1
+ import "../chunk-DXXNBF5P.js";
2
+ import {
3
+ useBorderRadiusStyles,
4
+ useXUITheme
5
+ } from "../chunk-LTKYHG5V.js";
6
+
7
+ // src/components/card/card.tsx
8
+ import React from "react";
9
+ import { Animated, Pressable, Text, View } from "react-native";
10
+
11
+ // src/components/card/card.style.ts
12
+ import { StyleSheet } from "react-native";
13
+ var styles = StyleSheet.create({
14
+ card: {
15
+ overflow: "hidden",
16
+ borderWidth: 1
17
+ },
18
+ fullWidth: {
19
+ flexShrink: 1,
20
+ flexBasis: "auto",
21
+ width: "100%"
22
+ },
23
+ disabled: {
24
+ opacity: 0.55
25
+ },
26
+ header: {
27
+ flexDirection: "row",
28
+ alignItems: "center",
29
+ gap: 12,
30
+ paddingHorizontal: 16,
31
+ paddingTop: 14,
32
+ paddingBottom: 10
33
+ },
34
+ body: {
35
+ paddingHorizontal: 16,
36
+ paddingVertical: 12
37
+ },
38
+ footer: {
39
+ flexDirection: "row",
40
+ alignItems: "center",
41
+ gap: 12,
42
+ paddingHorizontal: 16,
43
+ paddingTop: 10,
44
+ paddingBottom: 14
45
+ },
46
+ title: {
47
+ fontSize: 16,
48
+ fontWeight: "600",
49
+ includeFontPadding: false
50
+ },
51
+ description: {
52
+ fontSize: 14,
53
+ lineHeight: 20,
54
+ includeFontPadding: false
55
+ }
56
+ });
57
+
58
+ // src/components/card/card.hook.ts
59
+ import { useMemo } from "react";
60
+ import { getSafeThemeColor, withOpacity } from "@xaui/core";
61
+ var useCardContainerStyles = (themeColor, isBlurred) => {
62
+ const theme = useXUITheme();
63
+ return useMemo(() => {
64
+ const safeThemeColor = getSafeThemeColor(themeColor);
65
+ const colorScheme = theme.colors[safeThemeColor];
66
+ const isDefaultThemeColor = safeThemeColor === "default";
67
+ const defaultBackgroundColor = theme.mode === "dark" ? theme.colors.default.background : "#FFFFFF";
68
+ return {
69
+ backgroundColor: isBlurred ? theme.mode === "dark" ? "rgba(24, 24, 27, 0.82)" : "rgba(255, 255, 255, 0.82)" : isDefaultThemeColor ? defaultBackgroundColor : colorScheme.background,
70
+ borderColor: withOpacity(colorScheme.main, 0.05)
71
+ };
72
+ }, [isBlurred, theme, themeColor]);
73
+ };
74
+ var useCardElevationStyles = (elevation = 0) => {
75
+ const theme = useXUITheme();
76
+ return useMemo(() => {
77
+ const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
78
+ return {
79
+ ...shadowStyles,
80
+ ...elevation > 0 ? { elevation } : {}
81
+ };
82
+ }, [elevation, theme]);
83
+ };
84
+ var useCardTextStyles = (themeColor) => {
85
+ const theme = useXUITheme();
86
+ return useMemo(() => {
87
+ const safeThemeColor = getSafeThemeColor(themeColor);
88
+ const colorScheme = theme.colors[safeThemeColor];
89
+ return {
90
+ titleColor: colorScheme.main,
91
+ descriptionColor: theme.mode === "dark" ? withOpacity(theme.colors.foreground, 0.8) : withOpacity(theme.colors.foreground, 0.72)
92
+ };
93
+ }, [theme, themeColor]);
94
+ };
95
+ var useCardFooterStyles = (themeColor, isFooterBlurred) => {
96
+ const theme = useXUITheme();
97
+ return useMemo(() => {
98
+ const safeThemeColor = getSafeThemeColor(themeColor);
99
+ const colorScheme = theme.colors[safeThemeColor];
100
+ if (!isFooterBlurred) {
101
+ return {};
102
+ }
103
+ return {
104
+ backgroundColor: theme.mode === "dark" ? "rgba(24, 24, 27, 0.68)" : "rgba(255, 255, 255, 0.72)",
105
+ borderTopWidth: theme.borderWidth.sm,
106
+ borderTopColor: theme.mode === "dark" ? withOpacity(colorScheme.main, 0.4) : withOpacity(colorScheme.main, 0.18)
107
+ };
108
+ }, [isFooterBlurred, theme, themeColor]);
109
+ };
110
+
111
+ // src/components/card/card.tsx
112
+ var CardContext = React.createContext({
113
+ themeColor: "default",
114
+ isFooterBlurred: false
115
+ });
116
+ var Card = ({
117
+ children,
118
+ themeColor = "default",
119
+ radius = "lg",
120
+ elevation = 0,
121
+ fullWidth = false,
122
+ isHoverable = false,
123
+ isPressable = false,
124
+ isBlurred = false,
125
+ isFooterBlurred = false,
126
+ isDisabled = false,
127
+ disableAnimation = false,
128
+ disableRipple: _disableRipple = false,
129
+ allowTextSelectionOnPress: _allowTextSelectionOnPress = false,
130
+ customAppearance,
131
+ onPress,
132
+ onLongPress,
133
+ onPressIn,
134
+ onPressOut
135
+ }) => {
136
+ const animatedScale = React.useRef(new Animated.Value(1)).current;
137
+ const animatedOpacity = React.useRef(new Animated.Value(1)).current;
138
+ const radiusStyles = useBorderRadiusStyles(radius);
139
+ const containerStyles = useCardContainerStyles(themeColor, isBlurred);
140
+ const elevationStyles = useCardElevationStyles(elevation);
141
+ const contextValue = React.useMemo(
142
+ () => ({
143
+ themeColor,
144
+ isFooterBlurred,
145
+ customAppearance
146
+ }),
147
+ [customAppearance, isFooterBlurred, themeColor]
148
+ );
149
+ const animateTo = React.useCallback(
150
+ (scale, opacity, duration) => {
151
+ if (disableAnimation) {
152
+ animatedScale.setValue(scale);
153
+ animatedOpacity.setValue(opacity);
154
+ return;
155
+ }
156
+ Animated.parallel([
157
+ Animated.timing(animatedScale, {
158
+ toValue: scale,
159
+ duration,
160
+ useNativeDriver: true
161
+ }),
162
+ Animated.timing(animatedOpacity, {
163
+ toValue: opacity,
164
+ duration,
165
+ useNativeDriver: true
166
+ })
167
+ ]).start();
168
+ },
169
+ [animatedOpacity, animatedScale, disableAnimation]
170
+ );
171
+ const handlePressIn = React.useCallback(
172
+ (event) => {
173
+ if (!isDisabled && isPressable) {
174
+ animateTo(0.985, 0.95, 110);
175
+ }
176
+ onPressIn?.(event);
177
+ },
178
+ [animateTo, isDisabled, isPressable, onPressIn]
179
+ );
180
+ const handlePressOut = React.useCallback(
181
+ (event) => {
182
+ if (!isDisabled && isPressable) {
183
+ animateTo(1, 1, 140);
184
+ }
185
+ onPressOut?.(event);
186
+ },
187
+ [animateTo, isDisabled, isPressable, onPressOut]
188
+ );
189
+ const handleHoverIn = React.useCallback(() => {
190
+ if (!isDisabled && isHoverable && !isPressable) {
191
+ animateTo(1.01, 1, 130);
192
+ }
193
+ }, [animateTo, isDisabled, isHoverable, isPressable]);
194
+ const handleHoverOut = React.useCallback(() => {
195
+ if (!isDisabled && isHoverable && !isPressable) {
196
+ animateTo(1, 1, 130);
197
+ }
198
+ }, [animateTo, isDisabled, isHoverable, isPressable]);
199
+ const cardContent = /* @__PURE__ */ React.createElement(
200
+ Animated.View,
201
+ {
202
+ style: [
203
+ styles.card,
204
+ radiusStyles,
205
+ containerStyles,
206
+ elevationStyles,
207
+ fullWidth && styles.fullWidth,
208
+ isDisabled && styles.disabled,
209
+ {
210
+ transform: [{ scale: animatedScale }],
211
+ opacity: animatedOpacity
212
+ },
213
+ customAppearance?.container
214
+ ]
215
+ },
216
+ /* @__PURE__ */ React.createElement(CardContext.Provider, { value: contextValue }, children)
217
+ );
218
+ if (!isPressable) {
219
+ return cardContent;
220
+ }
221
+ return /* @__PURE__ */ React.createElement(
222
+ Pressable,
223
+ {
224
+ onPress: isDisabled ? void 0 : onPress,
225
+ onLongPress: isDisabled ? void 0 : onLongPress,
226
+ onPressIn: handlePressIn,
227
+ onPressOut: handlePressOut,
228
+ onHoverIn: isHoverable ? handleHoverIn : void 0,
229
+ onHoverOut: isHoverable ? handleHoverOut : void 0,
230
+ disabled: isDisabled
231
+ },
232
+ cardContent
233
+ );
234
+ };
235
+ var CardHeader = ({
236
+ children,
237
+ customAppearance
238
+ }) => {
239
+ const cardContext = React.useContext(CardContext);
240
+ return /* @__PURE__ */ React.createElement(
241
+ View,
242
+ {
243
+ style: [
244
+ styles.header,
245
+ cardContext.customAppearance?.header,
246
+ customAppearance?.container
247
+ ]
248
+ },
249
+ children
250
+ );
251
+ };
252
+ var CardBody = ({
253
+ children,
254
+ customAppearance
255
+ }) => {
256
+ const cardContext = React.useContext(CardContext);
257
+ return /* @__PURE__ */ React.createElement(
258
+ View,
259
+ {
260
+ style: [
261
+ styles.body,
262
+ cardContext.customAppearance?.body,
263
+ customAppearance?.container
264
+ ]
265
+ },
266
+ children
267
+ );
268
+ };
269
+ var CardFooter = ({
270
+ children,
271
+ customAppearance
272
+ }) => {
273
+ const cardContext = React.useContext(CardContext);
274
+ const footerStyles = useCardFooterStyles(
275
+ cardContext.themeColor,
276
+ cardContext.isFooterBlurred
277
+ );
278
+ return /* @__PURE__ */ React.createElement(
279
+ View,
280
+ {
281
+ style: [
282
+ styles.footer,
283
+ footerStyles,
284
+ cardContext.customAppearance?.footer,
285
+ customAppearance?.container
286
+ ]
287
+ },
288
+ children
289
+ );
290
+ };
291
+ var CardTitle = ({
292
+ children,
293
+ customAppearance
294
+ }) => {
295
+ const cardContext = React.useContext(CardContext);
296
+ const { titleColor } = useCardTextStyles(cardContext.themeColor);
297
+ return /* @__PURE__ */ React.createElement(
298
+ Text,
299
+ {
300
+ style: [
301
+ styles.title,
302
+ { color: titleColor },
303
+ cardContext.customAppearance?.title,
304
+ customAppearance?.text
305
+ ]
306
+ },
307
+ children
308
+ );
309
+ };
310
+ var CardDescription = ({
311
+ children,
312
+ customAppearance
313
+ }) => {
314
+ const cardContext = React.useContext(CardContext);
315
+ const { descriptionColor } = useCardTextStyles(cardContext.themeColor);
316
+ return /* @__PURE__ */ React.createElement(
317
+ Text,
318
+ {
319
+ style: [
320
+ styles.description,
321
+ { color: descriptionColor },
322
+ cardContext.customAppearance?.description,
323
+ customAppearance?.text
324
+ ]
325
+ },
326
+ children
327
+ );
328
+ };
329
+ export {
330
+ Card,
331
+ CardBody,
332
+ CardDescription,
333
+ CardFooter,
334
+ CardHeader,
335
+ CardTitle
336
+ };