@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.
- package/dist/accordion/index.js +2 -2
- package/dist/alert/index.js +352 -4
- package/dist/autocomplete/index.js +1121 -5
- package/dist/avatar/index.js +276 -5
- package/dist/badge/index.js +193 -4
- package/dist/bottom-sheet/index.js +364 -4
- package/dist/button/index.js +2 -2
- package/dist/card/index.cjs +429 -0
- package/dist/card/index.d.cts +186 -0
- package/dist/card/index.d.ts +186 -0
- package/dist/card/index.js +336 -0
- package/dist/carousel/index.js +377 -3
- package/dist/checkbox/index.js +1 -1
- package/dist/chip/index.js +497 -6
- package/dist/{chunk-VUVE6PK7.js → chunk-F7WH4DMG.js} +1 -1
- package/dist/{chunk-TJ2FPLLZ.js → chunk-JEGEPGVU.js} +2 -2
- package/dist/{chunk-MZL77KV5.js → chunk-LTKYHG5V.js} +1 -1
- package/dist/{chunk-RIVFFZRO.js → chunk-LUBWRVI2.js} +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/datepicker/index.js +1623 -4
- package/dist/divider/index.js +2 -2
- package/dist/fab/index.js +3 -3
- package/dist/fab-menu/index.js +324 -6
- package/dist/index.cjs +0 -6446
- package/dist/index.d.cts +2 -19
- package/dist/index.d.ts +2 -19
- package/dist/index.js +0 -73
- package/dist/indicator/index.js +2 -2
- package/dist/menu/index.js +1 -1
- package/dist/progress/index.js +1 -1
- package/dist/segment-button/index.cjs +2 -2
- package/dist/segment-button/index.js +400 -5
- package/dist/select/index.js +1 -1
- package/dist/skeleton/index.cjs +160 -0
- package/dist/skeleton/index.d.cts +45 -0
- package/dist/skeleton/index.d.ts +45 -0
- package/dist/skeleton/index.js +89 -0
- package/dist/switch/index.js +1 -1
- package/dist/typography/index.js +146 -4
- package/package.json +11 -1
- package/dist/chunk-6PXMB5CH.js +0 -503
- package/dist/chunk-DBKVHMSA.js +0 -329
- package/dist/chunk-EW5YLICE.js +0 -382
- package/dist/chunk-JJOVGRNI.js +0 -1627
- package/dist/chunk-K2HSVISE.js +0 -281
- package/dist/chunk-OXVIVNIJ.js +0 -356
- package/dist/chunk-PWCUULAL.js +0 -150
- package/dist/chunk-S3MGBM3G.js +0 -368
- package/dist/chunk-STUNTRKJ.js +0 -405
- package/dist/chunk-UGDGCMGC.js +0 -197
- package/dist/chunk-XUYIAA3A.js +0 -1127
package/dist/chunk-K2HSVISE.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useXUITheme
|
|
3
|
-
} from "./chunk-MZL77KV5.js";
|
|
4
|
-
|
|
5
|
-
// src/components/avatar/avatar.tsx
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { Image, Text, View } from "react-native";
|
|
8
|
-
|
|
9
|
-
// src/components/avatar/avatar.style.ts
|
|
10
|
-
import { StyleSheet } from "react-native";
|
|
11
|
-
var styles = StyleSheet.create({
|
|
12
|
-
container: {
|
|
13
|
-
overflow: "hidden",
|
|
14
|
-
alignItems: "center",
|
|
15
|
-
justifyContent: "center"
|
|
16
|
-
},
|
|
17
|
-
image: {
|
|
18
|
-
width: "100%",
|
|
19
|
-
height: "100%"
|
|
20
|
-
},
|
|
21
|
-
fallback: {
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
justifyContent: "center"
|
|
24
|
-
},
|
|
25
|
-
group: {
|
|
26
|
-
flexDirection: "row",
|
|
27
|
-
alignItems: "center"
|
|
28
|
-
},
|
|
29
|
-
grid: {
|
|
30
|
-
flexDirection: "row",
|
|
31
|
-
flexWrap: "wrap",
|
|
32
|
-
alignItems: "flex-start"
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// src/components/avatar/avatar.hook.ts
|
|
37
|
-
import { useMemo } from "react";
|
|
38
|
-
import { getSafeThemeColor } from "@xaui/core";
|
|
39
|
-
var sizeMap = {
|
|
40
|
-
xs: 24,
|
|
41
|
-
sm: 32,
|
|
42
|
-
md: 40,
|
|
43
|
-
lg: 48
|
|
44
|
-
};
|
|
45
|
-
function resolveAvatarSize(size) {
|
|
46
|
-
if (typeof size === "number") {
|
|
47
|
-
return size;
|
|
48
|
-
}
|
|
49
|
-
return sizeMap[size];
|
|
50
|
-
}
|
|
51
|
-
function useAvatarSizeStyles(size) {
|
|
52
|
-
const theme = useXUITheme();
|
|
53
|
-
const resolvedSize = useMemo(() => resolveAvatarSize(size), [size]);
|
|
54
|
-
const fontSize = useMemo(() => {
|
|
55
|
-
if (typeof size === "number") {
|
|
56
|
-
return Math.max(10, Math.round(size * 0.4));
|
|
57
|
-
}
|
|
58
|
-
return theme.fontSizes[size];
|
|
59
|
-
}, [size, theme]);
|
|
60
|
-
return {
|
|
61
|
-
size: resolvedSize,
|
|
62
|
-
fontSize
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function useAvatarRadiusStyles(radius, size) {
|
|
66
|
-
const theme = useXUITheme();
|
|
67
|
-
return useMemo(() => {
|
|
68
|
-
if (radius === "full") {
|
|
69
|
-
return { borderRadius: size / 2 };
|
|
70
|
-
}
|
|
71
|
-
const radii = {
|
|
72
|
-
none: theme.borderRadius.none,
|
|
73
|
-
sm: theme.borderRadius.sm,
|
|
74
|
-
md: theme.borderRadius.md,
|
|
75
|
-
lg: theme.borderRadius.lg,
|
|
76
|
-
full: theme.borderRadius.full
|
|
77
|
-
};
|
|
78
|
-
return { borderRadius: radii[radius] };
|
|
79
|
-
}, [radius, size, theme]);
|
|
80
|
-
}
|
|
81
|
-
function useAvatarColors(themeColor, isDisabled) {
|
|
82
|
-
const theme = useXUITheme();
|
|
83
|
-
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
84
|
-
const colorScheme = theme.colors[safeThemeColor];
|
|
85
|
-
const backgroundColor = useMemo(() => {
|
|
86
|
-
if (isDisabled) {
|
|
87
|
-
return theme.colors.background;
|
|
88
|
-
}
|
|
89
|
-
return colorScheme.background;
|
|
90
|
-
}, [colorScheme.background, isDisabled, theme.colors.background]);
|
|
91
|
-
const textColor = useMemo(() => {
|
|
92
|
-
if (safeThemeColor === "default") {
|
|
93
|
-
return theme.colors.foreground;
|
|
94
|
-
}
|
|
95
|
-
return colorScheme.main;
|
|
96
|
-
}, [safeThemeColor, colorScheme.main, theme.colors.foreground]);
|
|
97
|
-
return {
|
|
98
|
-
backgroundColor,
|
|
99
|
-
textColor,
|
|
100
|
-
borderColor: colorScheme.main
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function getDefaultInitials(name) {
|
|
104
|
-
const trimmed = name.trim();
|
|
105
|
-
if (!trimmed) {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
const parts = trimmed.split(/\s+/);
|
|
109
|
-
if (parts.length === 1) {
|
|
110
|
-
return parts[0].slice(0, 2).toUpperCase();
|
|
111
|
-
}
|
|
112
|
-
return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/components/avatar/avatar.tsx
|
|
116
|
-
var Avatar = ({
|
|
117
|
-
src,
|
|
118
|
-
name,
|
|
119
|
-
icon,
|
|
120
|
-
fallback,
|
|
121
|
-
size = "md",
|
|
122
|
-
radius = "full",
|
|
123
|
-
themeColor = "default",
|
|
124
|
-
isBordered = false,
|
|
125
|
-
isDisabled = false,
|
|
126
|
-
showFallback = false,
|
|
127
|
-
getInitials,
|
|
128
|
-
customAppearance
|
|
129
|
-
}) => {
|
|
130
|
-
const [isError, setIsError] = React.useState(false);
|
|
131
|
-
const { size: resolvedSize, fontSize } = useAvatarSizeStyles(size);
|
|
132
|
-
const radiusStyles = useAvatarRadiusStyles(radius, resolvedSize);
|
|
133
|
-
const { backgroundColor, textColor, borderColor } = useAvatarColors(
|
|
134
|
-
themeColor,
|
|
135
|
-
isDisabled
|
|
136
|
-
);
|
|
137
|
-
const accessibilityLabel = name ?? "Avatar";
|
|
138
|
-
const shouldShowFallback = showFallback || !src || isError;
|
|
139
|
-
const initials = name ? (getInitials ?? getDefaultInitials)(name) : "";
|
|
140
|
-
return /* @__PURE__ */ React.createElement(
|
|
141
|
-
View,
|
|
142
|
-
{
|
|
143
|
-
style: [
|
|
144
|
-
styles.container,
|
|
145
|
-
{
|
|
146
|
-
width: resolvedSize,
|
|
147
|
-
height: resolvedSize,
|
|
148
|
-
backgroundColor,
|
|
149
|
-
opacity: isDisabled ? 0.6 : 1,
|
|
150
|
-
borderWidth: isBordered ? 1 : 0,
|
|
151
|
-
borderColor: isBordered ? borderColor : "transparent"
|
|
152
|
-
},
|
|
153
|
-
radiusStyles,
|
|
154
|
-
customAppearance?.container
|
|
155
|
-
],
|
|
156
|
-
accessible: true,
|
|
157
|
-
accessibilityRole: "image",
|
|
158
|
-
accessibilityLabel
|
|
159
|
-
},
|
|
160
|
-
!shouldShowFallback && src ? /* @__PURE__ */ React.createElement(
|
|
161
|
-
Image,
|
|
162
|
-
{
|
|
163
|
-
source: { uri: src },
|
|
164
|
-
style: [styles.image, radiusStyles, customAppearance?.image],
|
|
165
|
-
accessibilityLabel,
|
|
166
|
-
onError: () => setIsError(true)
|
|
167
|
-
}
|
|
168
|
-
) : /* @__PURE__ */ React.createElement(View, { style: [styles.fallback, { width: "100%", height: "100%" }] }, fallback ?? icon ?? /* @__PURE__ */ React.createElement(
|
|
169
|
-
Text,
|
|
170
|
-
{
|
|
171
|
-
style: [
|
|
172
|
-
{
|
|
173
|
-
color: textColor,
|
|
174
|
-
fontSize,
|
|
175
|
-
fontWeight: "600"
|
|
176
|
-
},
|
|
177
|
-
customAppearance?.text
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
initials
|
|
181
|
-
))
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// src/components/avatar/avatar-group.tsx
|
|
186
|
-
import React2 from "react";
|
|
187
|
-
import { Text as Text2, View as View2 } from "react-native";
|
|
188
|
-
var AvatarGroup = ({
|
|
189
|
-
children,
|
|
190
|
-
max,
|
|
191
|
-
total,
|
|
192
|
-
size = "md",
|
|
193
|
-
radius = "full",
|
|
194
|
-
themeColor = "default",
|
|
195
|
-
isBordered = false,
|
|
196
|
-
isDisabled = false,
|
|
197
|
-
isGrid = false,
|
|
198
|
-
renderCount,
|
|
199
|
-
customAppearance
|
|
200
|
-
}) => {
|
|
201
|
-
const theme = useXUITheme();
|
|
202
|
-
const resolvedSize = resolveAvatarSize(size);
|
|
203
|
-
const spacing = theme.spacing.xs;
|
|
204
|
-
const overlap = Math.round(resolvedSize * 0.28);
|
|
205
|
-
const allChildren = React2.Children.toArray(children).filter(
|
|
206
|
-
(child) => React2.isValidElement(child)
|
|
207
|
-
);
|
|
208
|
-
const totalCount = total ?? allChildren.length;
|
|
209
|
-
const maxCount = max ?? totalCount;
|
|
210
|
-
const visibleChildren = allChildren.slice(0, maxCount);
|
|
211
|
-
const remaining = Math.max(0, totalCount - maxCount);
|
|
212
|
-
const enhanced = visibleChildren.map((child, index) => {
|
|
213
|
-
const childProps = child.props;
|
|
214
|
-
return /* @__PURE__ */ React2.createElement(
|
|
215
|
-
View2,
|
|
216
|
-
{
|
|
217
|
-
key: child.key ?? index,
|
|
218
|
-
style: isGrid ? { marginRight: spacing, marginBottom: spacing } : { marginLeft: index === 0 ? 0 : -overlap, zIndex: index }
|
|
219
|
-
},
|
|
220
|
-
React2.cloneElement(child, {
|
|
221
|
-
size: childProps.size ?? size,
|
|
222
|
-
radius: childProps.radius ?? radius,
|
|
223
|
-
themeColor: childProps.themeColor ?? themeColor,
|
|
224
|
-
isBordered: childProps.isBordered ?? isBordered,
|
|
225
|
-
isDisabled: childProps.isDisabled ?? isDisabled
|
|
226
|
-
})
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
const countNode = remaining > 0 ? renderCount?.(remaining) ?? /* @__PURE__ */ React2.createElement(
|
|
230
|
-
Avatar,
|
|
231
|
-
{
|
|
232
|
-
name: `+${remaining}`,
|
|
233
|
-
showFallback: true,
|
|
234
|
-
size,
|
|
235
|
-
radius,
|
|
236
|
-
themeColor,
|
|
237
|
-
isBordered,
|
|
238
|
-
isDisabled,
|
|
239
|
-
fallback: /* @__PURE__ */ React2.createElement(
|
|
240
|
-
Text2,
|
|
241
|
-
{
|
|
242
|
-
style: {
|
|
243
|
-
color: theme.colors.foreground,
|
|
244
|
-
fontSize: Math.max(10, Math.round(resolvedSize * 0.35)),
|
|
245
|
-
fontWeight: "600"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
"+",
|
|
249
|
-
remaining
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
) : null;
|
|
253
|
-
if (countNode) {
|
|
254
|
-
enhanced.push(
|
|
255
|
-
/* @__PURE__ */ React2.createElement(
|
|
256
|
-
View2,
|
|
257
|
-
{
|
|
258
|
-
key: "avatar-count",
|
|
259
|
-
style: isGrid ? { marginRight: spacing, marginBottom: spacing } : {
|
|
260
|
-
marginLeft: enhanced.length === 0 ? 0 : -overlap,
|
|
261
|
-
zIndex: enhanced.length
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
countNode
|
|
265
|
-
)
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
return /* @__PURE__ */ React2.createElement(
|
|
269
|
-
View2,
|
|
270
|
-
{
|
|
271
|
-
style: [isGrid ? styles.grid : styles.group, customAppearance?.container],
|
|
272
|
-
accessible: true
|
|
273
|
-
},
|
|
274
|
-
enhanced
|
|
275
|
-
);
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export {
|
|
279
|
-
Avatar,
|
|
280
|
-
AvatarGroup
|
|
281
|
-
};
|
package/dist/chunk-OXVIVNIJ.js
DELETED
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useBorderRadiusStyles,
|
|
3
|
-
useXUITheme
|
|
4
|
-
} from "./chunk-MZL77KV5.js";
|
|
5
|
-
|
|
6
|
-
// src/components/alert/alert.tsx
|
|
7
|
-
import React2, {
|
|
8
|
-
cloneElement,
|
|
9
|
-
isValidElement,
|
|
10
|
-
useCallback,
|
|
11
|
-
useEffect,
|
|
12
|
-
useMemo as useMemo2,
|
|
13
|
-
useState
|
|
14
|
-
} from "react";
|
|
15
|
-
import { Pressable, Text, View } from "react-native";
|
|
16
|
-
import Animated, {
|
|
17
|
-
useSharedValue,
|
|
18
|
-
useAnimatedStyle,
|
|
19
|
-
withTiming,
|
|
20
|
-
runOnJS
|
|
21
|
-
} from "react-native-reanimated";
|
|
22
|
-
|
|
23
|
-
// src/components/alert/alert.style.ts
|
|
24
|
-
import { StyleSheet } from "react-native";
|
|
25
|
-
var styles = StyleSheet.create({
|
|
26
|
-
container: {
|
|
27
|
-
flexDirection: "row",
|
|
28
|
-
alignItems: "center",
|
|
29
|
-
width: "100%",
|
|
30
|
-
gap: 12
|
|
31
|
-
},
|
|
32
|
-
mainWrapper: {
|
|
33
|
-
flex: 1,
|
|
34
|
-
justifyContent: "center",
|
|
35
|
-
gap: 2
|
|
36
|
-
},
|
|
37
|
-
title: {
|
|
38
|
-
fontWeight: "600"
|
|
39
|
-
},
|
|
40
|
-
description: {
|
|
41
|
-
fontWeight: "400"
|
|
42
|
-
},
|
|
43
|
-
iconWrapper: {
|
|
44
|
-
width: 36,
|
|
45
|
-
height: 36,
|
|
46
|
-
borderRadius: 18,
|
|
47
|
-
alignItems: "center",
|
|
48
|
-
justifyContent: "center"
|
|
49
|
-
},
|
|
50
|
-
iconText: {
|
|
51
|
-
fontWeight: "600"
|
|
52
|
-
},
|
|
53
|
-
closeButton: {
|
|
54
|
-
alignSelf: "flex-start",
|
|
55
|
-
padding: 4
|
|
56
|
-
},
|
|
57
|
-
extraContent: {
|
|
58
|
-
marginTop: 4
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// src/components/alert/alert.hook.ts
|
|
63
|
-
import { useMemo } from "react";
|
|
64
|
-
import { getSafeThemeColor, withOpacity } from "@xaui/core";
|
|
65
|
-
var useAlertColorScheme = (themeColor) => {
|
|
66
|
-
const theme = useXUITheme();
|
|
67
|
-
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
68
|
-
return {
|
|
69
|
-
theme,
|
|
70
|
-
colorScheme: theme.colors[safeThemeColor],
|
|
71
|
-
isDefault: safeThemeColor === "default"
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
var useAlertContainerStyles = (themeColor, variant) => {
|
|
75
|
-
const { theme, colorScheme, isDefault } = useAlertColorScheme(themeColor);
|
|
76
|
-
const containerStyles = useMemo(() => {
|
|
77
|
-
const backgroundColor = variant === "solid" ? colorScheme.main : variant === "flat" ? colorScheme.background : variant === "faded" ? withOpacity(colorScheme.background, 0.75) : "transparent";
|
|
78
|
-
const borderWidth = variant === "bordered" || variant === "faded" ? theme.borderWidth.md : 0;
|
|
79
|
-
const borderColor = variant === "bordered" ? withOpacity(colorScheme.main, 0.75) : variant === "faded" ? withOpacity(isDefault ? theme.colors.foreground : colorScheme.main, 0.25) : "transparent";
|
|
80
|
-
return {
|
|
81
|
-
backgroundColor,
|
|
82
|
-
borderColor,
|
|
83
|
-
borderWidth,
|
|
84
|
-
paddingVertical: theme.spacing.sm,
|
|
85
|
-
paddingHorizontal: theme.spacing.md
|
|
86
|
-
};
|
|
87
|
-
}, [colorScheme, isDefault, theme, variant]);
|
|
88
|
-
return containerStyles;
|
|
89
|
-
};
|
|
90
|
-
var useAlertIconWrapperStyles = (themeColor, variant) => {
|
|
91
|
-
const { theme, colorScheme, isDefault } = useAlertColorScheme(themeColor);
|
|
92
|
-
const iconWrapperStyles = useMemo(() => {
|
|
93
|
-
const backgroundColor = variant === "solid" ? withOpacity(colorScheme.foreground, 0.16) : withOpacity(isDefault ? theme.colors.foreground : colorScheme.main, 0.12);
|
|
94
|
-
const borderWidth = variant === "bordered" || variant === "faded" ? theme.borderWidth.xs : 0;
|
|
95
|
-
const borderColor = withOpacity(
|
|
96
|
-
isDefault ? theme.colors.foreground : colorScheme.main,
|
|
97
|
-
0.2
|
|
98
|
-
);
|
|
99
|
-
return {
|
|
100
|
-
backgroundColor,
|
|
101
|
-
borderColor,
|
|
102
|
-
borderWidth
|
|
103
|
-
};
|
|
104
|
-
}, [colorScheme, isDefault, theme, variant]);
|
|
105
|
-
return iconWrapperStyles;
|
|
106
|
-
};
|
|
107
|
-
var useAlertTextStyles = (themeColor, variant) => {
|
|
108
|
-
const { theme, colorScheme, isDefault } = useAlertColorScheme(themeColor);
|
|
109
|
-
const textStyles = useMemo(() => {
|
|
110
|
-
const baseTextColor = variant === "solid" ? colorScheme.foreground : isDefault ? theme.colors.foreground : colorScheme.main;
|
|
111
|
-
return {
|
|
112
|
-
titleStyles: {
|
|
113
|
-
color: baseTextColor,
|
|
114
|
-
fontSize: theme.fontSizes.sm,
|
|
115
|
-
fontWeight: theme.fontWeights.semibold
|
|
116
|
-
},
|
|
117
|
-
descriptionStyles: {
|
|
118
|
-
color: withOpacity(baseTextColor, 0.75),
|
|
119
|
-
fontSize: theme.fontSizes.xs,
|
|
120
|
-
fontWeight: theme.fontWeights.normal
|
|
121
|
-
},
|
|
122
|
-
iconColor: baseTextColor,
|
|
123
|
-
closeButtonColor: baseTextColor
|
|
124
|
-
};
|
|
125
|
-
}, [colorScheme, isDefault, theme, variant]);
|
|
126
|
-
return textStyles;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// src/components/alert/alert-icons.tsx
|
|
130
|
-
import React from "react";
|
|
131
|
-
import Svg, { Circle, Line, Path } from "react-native-svg";
|
|
132
|
-
function InfoIcon({ color, size }) {
|
|
133
|
-
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React.createElement(Circle, { cx: 12, cy: 12, r: 10, stroke: color, strokeWidth: 2 }), /* @__PURE__ */ React.createElement(
|
|
134
|
-
Line,
|
|
135
|
-
{
|
|
136
|
-
x1: 12,
|
|
137
|
-
y1: 10,
|
|
138
|
-
x2: 12,
|
|
139
|
-
y2: 16,
|
|
140
|
-
stroke: color,
|
|
141
|
-
strokeWidth: 2,
|
|
142
|
-
strokeLinecap: "round"
|
|
143
|
-
}
|
|
144
|
-
), /* @__PURE__ */ React.createElement(Circle, { cx: 12, cy: 7, r: 1, fill: color }));
|
|
145
|
-
}
|
|
146
|
-
function SuccessIcon({ color, size }) {
|
|
147
|
-
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React.createElement(Circle, { cx: 12, cy: 12, r: 10, stroke: color, strokeWidth: 2 }), /* @__PURE__ */ React.createElement(
|
|
148
|
-
Path,
|
|
149
|
-
{
|
|
150
|
-
d: "M7 12.5L10.2 15.5L17 9",
|
|
151
|
-
stroke: color,
|
|
152
|
-
strokeWidth: 2,
|
|
153
|
-
strokeLinecap: "round",
|
|
154
|
-
strokeLinejoin: "round"
|
|
155
|
-
}
|
|
156
|
-
));
|
|
157
|
-
}
|
|
158
|
-
function WarningIcon({ color, size }) {
|
|
159
|
-
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React.createElement(
|
|
160
|
-
Path,
|
|
161
|
-
{
|
|
162
|
-
d: "M12 3L22 20H2L12 3Z",
|
|
163
|
-
stroke: color,
|
|
164
|
-
strokeWidth: 2,
|
|
165
|
-
strokeLinejoin: "round"
|
|
166
|
-
}
|
|
167
|
-
), /* @__PURE__ */ React.createElement(
|
|
168
|
-
Line,
|
|
169
|
-
{
|
|
170
|
-
x1: 12,
|
|
171
|
-
y1: 9,
|
|
172
|
-
x2: 12,
|
|
173
|
-
y2: 14,
|
|
174
|
-
stroke: color,
|
|
175
|
-
strokeWidth: 2,
|
|
176
|
-
strokeLinecap: "round"
|
|
177
|
-
}
|
|
178
|
-
), /* @__PURE__ */ React.createElement(Circle, { cx: 12, cy: 17, r: 1, fill: color }));
|
|
179
|
-
}
|
|
180
|
-
function DangerIcon({ color, size }) {
|
|
181
|
-
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React.createElement(Circle, { cx: 12, cy: 12, r: 10, stroke: color, strokeWidth: 2 }), /* @__PURE__ */ React.createElement(
|
|
182
|
-
Line,
|
|
183
|
-
{
|
|
184
|
-
x1: 9,
|
|
185
|
-
y1: 9,
|
|
186
|
-
x2: 15,
|
|
187
|
-
y2: 15,
|
|
188
|
-
stroke: color,
|
|
189
|
-
strokeWidth: 2,
|
|
190
|
-
strokeLinecap: "round"
|
|
191
|
-
}
|
|
192
|
-
), /* @__PURE__ */ React.createElement(
|
|
193
|
-
Line,
|
|
194
|
-
{
|
|
195
|
-
x1: 15,
|
|
196
|
-
y1: 9,
|
|
197
|
-
x2: 9,
|
|
198
|
-
y2: 15,
|
|
199
|
-
stroke: color,
|
|
200
|
-
strokeWidth: 2,
|
|
201
|
-
strokeLinecap: "round"
|
|
202
|
-
}
|
|
203
|
-
));
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// src/components/alert/alert.tsx
|
|
207
|
-
import { CloseIcon } from "@xaui/icons";
|
|
208
|
-
var iconMap = {
|
|
209
|
-
default: InfoIcon,
|
|
210
|
-
primary: InfoIcon,
|
|
211
|
-
secondary: InfoIcon,
|
|
212
|
-
tertiary: InfoIcon,
|
|
213
|
-
success: SuccessIcon,
|
|
214
|
-
warning: WarningIcon,
|
|
215
|
-
danger: DangerIcon
|
|
216
|
-
};
|
|
217
|
-
var Alert = ({
|
|
218
|
-
title,
|
|
219
|
-
description,
|
|
220
|
-
icon,
|
|
221
|
-
themeColor = "default",
|
|
222
|
-
variant = "flat",
|
|
223
|
-
radius = "md",
|
|
224
|
-
isClosable = false,
|
|
225
|
-
hideIcon = false,
|
|
226
|
-
closeButton,
|
|
227
|
-
isVisible,
|
|
228
|
-
customAppearance,
|
|
229
|
-
children,
|
|
230
|
-
onClose,
|
|
231
|
-
onVisibleChange
|
|
232
|
-
}) => {
|
|
233
|
-
const [internalVisible, setInternalVisible] = useState(isVisible ?? true);
|
|
234
|
-
const [shouldRender, setShouldRender] = useState(isVisible ?? true);
|
|
235
|
-
const isControlled = typeof isVisible === "boolean";
|
|
236
|
-
const visible = isControlled ? isVisible : internalVisible;
|
|
237
|
-
const opacity = useSharedValue(1);
|
|
238
|
-
const scale = useSharedValue(1);
|
|
239
|
-
const radiusStyles = useBorderRadiusStyles(radius);
|
|
240
|
-
const containerStyles = useAlertContainerStyles(themeColor, variant);
|
|
241
|
-
const iconWrapperStyles = useAlertIconWrapperStyles(themeColor, variant);
|
|
242
|
-
const { titleStyles, descriptionStyles, iconColor, closeButtonColor } = useAlertTextStyles(themeColor, variant);
|
|
243
|
-
const finishClosing = useCallback(() => {
|
|
244
|
-
setShouldRender(false);
|
|
245
|
-
if (!isControlled) {
|
|
246
|
-
setInternalVisible(false);
|
|
247
|
-
}
|
|
248
|
-
onVisibleChange?.(false);
|
|
249
|
-
onClose?.();
|
|
250
|
-
}, [isControlled, onClose, onVisibleChange]);
|
|
251
|
-
const handleClose = useCallback(() => {
|
|
252
|
-
if (!visible) return;
|
|
253
|
-
opacity.value = withTiming(0, { duration: 250 });
|
|
254
|
-
scale.value = withTiming(0.95, { duration: 250 }, (finished) => {
|
|
255
|
-
if (finished) {
|
|
256
|
-
runOnJS(finishClosing)();
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}, [finishClosing, opacity, scale, visible]);
|
|
260
|
-
useEffect(() => {
|
|
261
|
-
if (visible && !shouldRender) {
|
|
262
|
-
setShouldRender(true);
|
|
263
|
-
opacity.value = 0;
|
|
264
|
-
scale.value = 0.95;
|
|
265
|
-
opacity.value = withTiming(1, { duration: 250 });
|
|
266
|
-
scale.value = withTiming(1, { duration: 250 });
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (!visible && shouldRender) {
|
|
270
|
-
handleClose();
|
|
271
|
-
}
|
|
272
|
-
}, [visible, shouldRender, opacity, scale, handleClose]);
|
|
273
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
274
|
-
opacity: opacity.value,
|
|
275
|
-
transform: [{ scale: scale.value }]
|
|
276
|
-
}));
|
|
277
|
-
const IconComponent = iconMap[themeColor] ?? InfoIcon;
|
|
278
|
-
const shouldShowClose = Boolean(closeButton || isClosable || onClose);
|
|
279
|
-
const renderIcon = () => {
|
|
280
|
-
if (hideIcon) return null;
|
|
281
|
-
if (icon && isValidElement(icon)) {
|
|
282
|
-
return cloneElement(icon, { color: iconColor, size: 22 });
|
|
283
|
-
}
|
|
284
|
-
if (icon) {
|
|
285
|
-
return /* @__PURE__ */ React2.createElement(Text, { style: [styles.iconText, { color: iconColor }] }, icon);
|
|
286
|
-
}
|
|
287
|
-
return /* @__PURE__ */ React2.createElement(IconComponent, { color: iconColor, size: 22 });
|
|
288
|
-
};
|
|
289
|
-
const renderContentText = (content) => {
|
|
290
|
-
if (content === null || content === void 0) return null;
|
|
291
|
-
if (typeof content === "string" || typeof content === "number") {
|
|
292
|
-
return /* @__PURE__ */ React2.createElement(
|
|
293
|
-
Text,
|
|
294
|
-
{
|
|
295
|
-
style: [
|
|
296
|
-
styles.description,
|
|
297
|
-
descriptionStyles,
|
|
298
|
-
customAppearance?.description
|
|
299
|
-
]
|
|
300
|
-
},
|
|
301
|
-
content
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
return content;
|
|
305
|
-
};
|
|
306
|
-
const titleNode = useMemo2(() => {
|
|
307
|
-
if (title === null || title === void 0) return null;
|
|
308
|
-
if (typeof title === "string" || typeof title === "number") {
|
|
309
|
-
return /* @__PURE__ */ React2.createElement(Text, { style: [styles.title, titleStyles, customAppearance?.title] }, title);
|
|
310
|
-
}
|
|
311
|
-
return title;
|
|
312
|
-
}, [title, customAppearance?.title, titleStyles]);
|
|
313
|
-
const descriptionNode = renderContentText(description);
|
|
314
|
-
const childrenNode = renderContentText(children);
|
|
315
|
-
const closeButtonNode = useMemo2(() => {
|
|
316
|
-
if (!closeButton) return null;
|
|
317
|
-
if (!isValidElement(closeButton)) return closeButton;
|
|
318
|
-
const existingOnPress = closeButton.props.onPress;
|
|
319
|
-
return cloneElement(closeButton, {
|
|
320
|
-
onPress: (event) => {
|
|
321
|
-
existingOnPress?.(event);
|
|
322
|
-
handleClose();
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}, [closeButton, handleClose]);
|
|
326
|
-
if (!shouldRender) return null;
|
|
327
|
-
return /* @__PURE__ */ React2.createElement(
|
|
328
|
-
Animated.View,
|
|
329
|
-
{
|
|
330
|
-
accessibilityRole: "alert",
|
|
331
|
-
style: [
|
|
332
|
-
styles.container,
|
|
333
|
-
containerStyles,
|
|
334
|
-
radiusStyles,
|
|
335
|
-
customAppearance?.container,
|
|
336
|
-
animatedStyle
|
|
337
|
-
]
|
|
338
|
-
},
|
|
339
|
-
!hideIcon && /* @__PURE__ */ React2.createElement(View, { style: [styles.iconWrapper, iconWrapperStyles] }, renderIcon()),
|
|
340
|
-
/* @__PURE__ */ React2.createElement(View, { style: styles.mainWrapper }, titleNode, descriptionNode, childrenNode && /* @__PURE__ */ React2.createElement(View, { style: styles.extraContent }, childrenNode)),
|
|
341
|
-
shouldShowClose && /* @__PURE__ */ React2.createElement(View, null, closeButtonNode ?? /* @__PURE__ */ React2.createElement(
|
|
342
|
-
Pressable,
|
|
343
|
-
{
|
|
344
|
-
accessibilityRole: "button",
|
|
345
|
-
accessibilityLabel: "Close",
|
|
346
|
-
onPress: handleClose,
|
|
347
|
-
style: styles.closeButton
|
|
348
|
-
},
|
|
349
|
-
/* @__PURE__ */ React2.createElement(CloseIcon, { size: 20, color: closeButtonColor })
|
|
350
|
-
))
|
|
351
|
-
);
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
export {
|
|
355
|
-
Alert
|
|
356
|
-
};
|