@xaui/native 0.0.16 → 0.0.18

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 (62) hide show
  1. package/dist/accordion/index.cjs +1 -1
  2. package/dist/accordion/index.js +5 -4
  3. package/dist/alert/index.js +352 -3
  4. package/dist/autocomplete/index.cjs +5 -11
  5. package/dist/autocomplete/index.js +1122 -5
  6. package/dist/avatar/index.js +276 -4
  7. package/dist/badge/index.js +193 -3
  8. package/dist/bottom-sheet/index.cjs +9 -20
  9. package/dist/bottom-sheet/index.js +364 -3
  10. package/dist/button/index.js +3 -2
  11. package/dist/card/index.cjs +429 -0
  12. package/dist/card/index.d.cts +186 -0
  13. package/dist/card/index.d.ts +186 -0
  14. package/dist/card/index.js +336 -0
  15. package/dist/carousel/index.cjs +458 -0
  16. package/dist/carousel/index.d.cts +147 -0
  17. package/dist/carousel/index.d.ts +147 -0
  18. package/dist/carousel/index.js +381 -0
  19. package/dist/checkbox/index.js +2 -1
  20. package/dist/chip/index.cjs +2 -8
  21. package/dist/chip/index.js +497 -5
  22. package/dist/chunk-DXXNBF5P.js +7 -0
  23. package/dist/{chunk-MKHBEJLO.js → chunk-F7WH4DMG.js} +1 -1
  24. package/dist/{chunk-II4QINLG.js → chunk-JEGEPGVU.js} +2 -2
  25. package/dist/{chunk-NBRASCX4.js → chunk-LTKYHG5V.js} +6 -13
  26. package/dist/{chunk-GNJIET26.js → chunk-LUBWRVI2.js} +1 -1
  27. package/dist/core/index.cjs +1 -1
  28. package/dist/core/index.js +5 -3
  29. package/dist/datepicker/index.js +1623 -3
  30. package/dist/divider/index.js +3 -2
  31. package/dist/fab/index.js +4 -3
  32. package/dist/fab-menu/index.cjs +4 -13
  33. package/dist/fab-menu/index.js +325 -6
  34. package/dist/index.cjs +0 -5709
  35. package/dist/index.d.cts +2 -17
  36. package/dist/index.d.ts +2 -17
  37. package/dist/index.js +0 -62
  38. package/dist/indicator/index.js +3 -2
  39. package/dist/menu/index.cjs +8 -7
  40. package/dist/menu/index.js +15 -9
  41. package/dist/progress/index.js +2 -1
  42. package/dist/segment-button/index.cjs +492 -0
  43. package/dist/segment-button/index.d.cts +141 -0
  44. package/dist/segment-button/index.d.ts +141 -0
  45. package/dist/segment-button/index.js +405 -0
  46. package/dist/select/index.js +2 -1
  47. package/dist/switch/index.js +2 -1
  48. package/dist/typography/index.js +146 -3
  49. package/dist/view/index.cjs +153 -78
  50. package/dist/view/index.d.cts +77 -1
  51. package/dist/view/index.d.ts +77 -1
  52. package/dist/view/index.js +125 -52
  53. package/package.json +16 -1
  54. package/dist/chunk-2T6FKPJW.js +0 -356
  55. package/dist/chunk-4LFRYVSR.js +0 -281
  56. package/dist/chunk-7OFTYKK4.js +0 -1627
  57. package/dist/chunk-EI5OMBFE.js +0 -338
  58. package/dist/chunk-GAOI4KIV.js +0 -379
  59. package/dist/chunk-NMZUPH3R.js +0 -1133
  60. package/dist/chunk-QLEQYKG5.js +0 -509
  61. package/dist/chunk-XJKA22BK.js +0 -197
  62. package/dist/chunk-ZYTBRHLJ.js +0 -150
@@ -1,509 +0,0 @@
1
- import {
2
- useXUITheme
3
- } from "./chunk-NBRASCX4.js";
4
-
5
- // src/components/chip/chip.tsx
6
- import React from "react";
7
- import { Animated, Easing, Pressable, View } from "react-native";
8
-
9
- // src/components/chip/chip.style.ts
10
- import { StyleSheet } from "react-native";
11
- var styles = StyleSheet.create({
12
- chip: {
13
- flexDirection: "row",
14
- alignItems: "center",
15
- alignSelf: "flex-start"
16
- },
17
- text: {
18
- fontWeight: "500",
19
- includeFontPadding: false,
20
- textAlignVertical: "center"
21
- },
22
- disabled: {
23
- opacity: 0.5
24
- },
25
- avatar: {
26
- marginRight: 4
27
- },
28
- startContent: {
29
- marginRight: 4
30
- },
31
- endContent: {
32
- marginLeft: 4
33
- },
34
- closeButton: {
35
- marginLeft: 4,
36
- alignItems: "center",
37
- justifyContent: "center"
38
- },
39
- dot: {
40
- borderRadius: 9999,
41
- marginRight: 6
42
- },
43
- groupContainer: {
44
- flexDirection: "row",
45
- flexWrap: "wrap"
46
- }
47
- });
48
-
49
- // src/components/chip/chip.hook.ts
50
- import { useMemo } from "react";
51
- import { getSafeThemeColor, withOpacity } from "@xaui/core";
52
- var sizeMap = {
53
- sm: { height: 32, paddingH: 12, fontSize: 13 },
54
- md: { height: 40, paddingH: 16, fontSize: 15 },
55
- lg: { height: 44, paddingH: 18, fontSize: 17 }
56
- };
57
- var dotSizeMap = {
58
- sm: 8,
59
- md: 10,
60
- lg: 11
61
- };
62
- var closeSizeMap = {
63
- sm: 14,
64
- md: 16,
65
- lg: 17
66
- };
67
- function useChipSizeStyles(size) {
68
- return useMemo(() => {
69
- const { height, paddingH, fontSize } = sizeMap[size];
70
- return { height, paddingHorizontal: paddingH, fontSize };
71
- }, [size]);
72
- }
73
- function useChipDotSize(size) {
74
- return useMemo(() => dotSizeMap[size], [size]);
75
- }
76
- function useChipCloseSize(size) {
77
- return useMemo(() => closeSizeMap[size], [size]);
78
- }
79
- function useChipRadiusStyles(radius, height) {
80
- const theme = useXUITheme();
81
- return useMemo(() => {
82
- if (radius === "full") {
83
- return { borderRadius: height / 2 };
84
- }
85
- return { borderRadius: theme.borderRadius[radius] };
86
- }, [height, radius, theme.borderRadius]);
87
- }
88
- function useChipVariantStyles(themeColor, variant) {
89
- const theme = useXUITheme();
90
- const safeColor = getSafeThemeColor(themeColor);
91
- const colorScheme = theme.colors[safeColor];
92
- return useMemo(() => {
93
- switch (variant) {
94
- case "bordered":
95
- return {
96
- backgroundColor: "transparent",
97
- color: colorScheme.main,
98
- borderWidth: 2,
99
- borderColor: colorScheme.main
100
- };
101
- case "light":
102
- return {
103
- backgroundColor: "transparent",
104
- color: colorScheme.main
105
- };
106
- case "flat":
107
- return {
108
- backgroundColor: colorScheme.background,
109
- color: colorScheme.main
110
- };
111
- case "faded":
112
- return {
113
- backgroundColor: withOpacity(colorScheme.background, 0.7),
114
- color: colorScheme.main,
115
- borderWidth: 1,
116
- borderColor: withOpacity(colorScheme.main, 0.3)
117
- };
118
- case "shadow":
119
- return {
120
- backgroundColor: colorScheme.main,
121
- color: colorScheme.foreground,
122
- shadow: theme.shadows.sm
123
- };
124
- case "dot":
125
- return {
126
- backgroundColor: colorScheme.background,
127
- color: colorScheme.main,
128
- dotColor: colorScheme.main
129
- };
130
- case "solid":
131
- default:
132
- return {
133
- backgroundColor: colorScheme.main,
134
- color: colorScheme.foreground
135
- };
136
- }
137
- }, [colorScheme, theme, variant]);
138
- }
139
-
140
- // src/components/chip/chip.tsx
141
- var Chip = ({
142
- children,
143
- variant = "solid",
144
- themeColor = "default",
145
- size = "md",
146
- radius = "full",
147
- avatar,
148
- startContent,
149
- endContent,
150
- isDisabled = false,
151
- customAppearance,
152
- onClose,
153
- onPress
154
- }) => {
155
- const [isClosed, setIsClosed] = React.useState(false);
156
- const [isClosing, setIsClosing] = React.useState(false);
157
- const sizeStyles = useChipSizeStyles(size);
158
- const radiusStyles = useChipRadiusStyles(radius, sizeStyles.height);
159
- const variantStyles = useChipVariantStyles(themeColor, variant);
160
- const dotSize = useChipDotSize(size);
161
- const closeSize = useChipCloseSize(size);
162
- const isDotVariant = variant === "dot";
163
- const hasClose = onClose !== void 0;
164
- const isInteractive = onPress !== void 0 || hasClose;
165
- const scale = React.useRef(new Animated.Value(1)).current;
166
- const opacity = React.useRef(new Animated.Value(1)).current;
167
- const isClosingRef = React.useRef(false);
168
- const colorProgress = React.useRef(new Animated.Value(1)).current;
169
- const targetBackgroundColor = variantStyles.backgroundColor ?? "transparent";
170
- const targetBorderColor = variantStyles.borderColor ?? "transparent";
171
- const targetTextColor = variantStyles.color ?? "#000000";
172
- const targetDotColor = variantStyles.dotColor ?? targetTextColor;
173
- const previousColorsRef = React.useRef({
174
- backgroundColor: targetBackgroundColor,
175
- borderColor: targetBorderColor,
176
- textColor: targetTextColor,
177
- dotColor: targetDotColor
178
- });
179
- React.useEffect(() => {
180
- if (previousColorsRef.current.backgroundColor === targetBackgroundColor && previousColorsRef.current.borderColor === targetBorderColor && previousColorsRef.current.textColor === targetTextColor && previousColorsRef.current.dotColor === targetDotColor) {
181
- return;
182
- }
183
- colorProgress.setValue(0);
184
- Animated.timing(colorProgress, {
185
- toValue: 1,
186
- duration: 180,
187
- easing: Easing.out(Easing.cubic),
188
- useNativeDriver: false
189
- }).start(() => {
190
- previousColorsRef.current = {
191
- backgroundColor: targetBackgroundColor,
192
- borderColor: targetBorderColor,
193
- textColor: targetTextColor,
194
- dotColor: targetDotColor
195
- };
196
- });
197
- }, [
198
- colorProgress,
199
- targetBackgroundColor,
200
- targetBorderColor,
201
- targetTextColor,
202
- targetDotColor
203
- ]);
204
- const animatedBackgroundColor = colorProgress.interpolate({
205
- inputRange: [0, 1],
206
- outputRange: [
207
- previousColorsRef.current.backgroundColor,
208
- targetBackgroundColor
209
- ]
210
- });
211
- const animatedBorderColor = colorProgress.interpolate({
212
- inputRange: [0, 1],
213
- outputRange: [previousColorsRef.current.borderColor, targetBorderColor]
214
- });
215
- const animatedTextColor = colorProgress.interpolate({
216
- inputRange: [0, 1],
217
- outputRange: [previousColorsRef.current.textColor, targetTextColor]
218
- });
219
- const animatedDotColor = colorProgress.interpolate({
220
- inputRange: [0, 1],
221
- outputRange: [previousColorsRef.current.dotColor, targetDotColor]
222
- });
223
- const handlePressIn = React.useCallback(() => {
224
- if (!isInteractive || isDisabled || isClosing || hasClose) return;
225
- Animated.timing(scale, {
226
- toValue: 0.97,
227
- duration: 90,
228
- easing: Easing.out(Easing.cubic),
229
- useNativeDriver: true
230
- }).start();
231
- }, [hasClose, isInteractive, isClosing, isDisabled, scale]);
232
- const handlePressOut = React.useCallback(() => {
233
- if (!isInteractive || isDisabled || isClosing || hasClose) return;
234
- Animated.timing(scale, {
235
- toValue: 1,
236
- duration: 120,
237
- easing: Easing.out(Easing.cubic),
238
- useNativeDriver: true
239
- }).start();
240
- }, [hasClose, isInteractive, isClosing, isDisabled, scale]);
241
- const handleChipPress = React.useCallback(() => {
242
- if (isDisabled || isClosing || isClosingRef.current) return;
243
- if (hasClose && onClose) {
244
- isClosingRef.current = true;
245
- setIsClosing(true);
246
- Animated.parallel([
247
- Animated.timing(opacity, {
248
- toValue: 0,
249
- duration: 180,
250
- easing: Easing.in(Easing.quad),
251
- useNativeDriver: true
252
- }),
253
- Animated.timing(scale, {
254
- toValue: 0.88,
255
- duration: 180,
256
- easing: Easing.in(Easing.quad),
257
- useNativeDriver: true
258
- })
259
- ]).start(() => {
260
- setIsClosed(true);
261
- onClose();
262
- setIsClosing(false);
263
- isClosingRef.current = false;
264
- });
265
- return;
266
- }
267
- onPress?.();
268
- }, [hasClose, isClosing, isDisabled, onClose, onPress, opacity, scale]);
269
- if (isClosed) {
270
- return null;
271
- }
272
- const chipContent = /* @__PURE__ */ React.createElement(Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ React.createElement(
273
- Animated.View,
274
- {
275
- style: [
276
- styles.chip,
277
- {
278
- height: sizeStyles.height,
279
- paddingHorizontal: sizeStyles.paddingHorizontal,
280
- backgroundColor: animatedBackgroundColor,
281
- borderWidth: variantStyles.borderWidth,
282
- borderColor: animatedBorderColor
283
- },
284
- radiusStyles,
285
- variantStyles.shadow,
286
- isDisabled && styles.disabled,
287
- customAppearance?.container
288
- ],
289
- accessible: true,
290
- accessibilityRole: "text"
291
- },
292
- isDotVariant && /* @__PURE__ */ React.createElement(
293
- Animated.View,
294
- {
295
- style: [
296
- styles.dot,
297
- {
298
- width: dotSize,
299
- height: dotSize,
300
- backgroundColor: animatedDotColor
301
- },
302
- customAppearance?.dot
303
- ]
304
- }
305
- ),
306
- avatar && /* @__PURE__ */ React.createElement(View, { style: styles.avatar }, avatar),
307
- startContent && !avatar && /* @__PURE__ */ React.createElement(View, { style: styles.startContent }, startContent),
308
- /* @__PURE__ */ React.createElement(
309
- Animated.Text,
310
- {
311
- style: [
312
- styles.text,
313
- { fontSize: sizeStyles.fontSize, color: animatedTextColor },
314
- customAppearance?.text
315
- ]
316
- },
317
- children
318
- ),
319
- endContent && !hasClose && /* @__PURE__ */ React.createElement(View, { style: styles.endContent }, endContent),
320
- hasClose && /* @__PURE__ */ React.createElement(
321
- View,
322
- {
323
- style: [
324
- styles.closeButton,
325
- { width: closeSize, height: closeSize },
326
- customAppearance?.closeButton
327
- ]
328
- },
329
- /* @__PURE__ */ React.createElement(
330
- Animated.Text,
331
- {
332
- style: {
333
- fontSize: closeSize - 2,
334
- color: animatedTextColor,
335
- lineHeight: closeSize
336
- }
337
- },
338
- "\u2715"
339
- )
340
- )
341
- ));
342
- if (isInteractive) {
343
- return /* @__PURE__ */ React.createElement(
344
- Pressable,
345
- {
346
- onPress: isDisabled || isClosing ? void 0 : handleChipPress,
347
- onPressIn: handlePressIn,
348
- onPressOut: handlePressOut,
349
- disabled: isDisabled || isClosing
350
- },
351
- chipContent
352
- );
353
- }
354
- return chipContent;
355
- };
356
-
357
- // src/components/chip/chip-group.tsx
358
- import React2 from "react";
359
- import { View as View2 } from "react-native";
360
-
361
- // src/components/chip/chip-context.ts
362
- import { createContext } from "react";
363
- var ChipGroupContext = createContext(null);
364
-
365
- // src/components/chip/chip-group.hook.ts
366
- import { useCallback, useMemo as useMemo2, useState } from "react";
367
- function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues, onSelectionChange) {
368
- const [internalValues, setInternalValues] = useState(
369
- defaultSelectedValues ?? []
370
- );
371
- const isControlled = selectedValues !== void 0;
372
- const currentValues = isControlled ? selectedValues : internalValues;
373
- const onToggle = useCallback(
374
- (value) => {
375
- const isSelected = currentValues.includes(value);
376
- let nextValues;
377
- if (selectMode === "single") {
378
- nextValues = isSelected ? [] : [value];
379
- } else {
380
- nextValues = isSelected ? currentValues.filter((v) => v !== value) : [...currentValues, value];
381
- }
382
- if (!isControlled) {
383
- setInternalValues(nextValues);
384
- }
385
- onSelectionChange?.(nextValues);
386
- },
387
- [currentValues, isControlled, onSelectionChange, selectMode]
388
- );
389
- return useMemo2(
390
- () => ({ currentValues, onToggle }),
391
- [currentValues, onToggle]
392
- );
393
- }
394
-
395
- // src/components/chip/chip-group.tsx
396
- var ChipGroup = ({
397
- children,
398
- isSelectable = false,
399
- selectMode = "single",
400
- variant = "solid",
401
- themeColor = "default",
402
- size = "md",
403
- radius = "full",
404
- isDisabled = false,
405
- selectedValues,
406
- defaultSelectedValues,
407
- onSelectionChange,
408
- spacing = 8,
409
- customAppearance
410
- }) => {
411
- const { currentValues, onToggle } = useChipGroupSelection(
412
- selectMode,
413
- selectedValues,
414
- defaultSelectedValues,
415
- onSelectionChange
416
- );
417
- const contextValue = React2.useMemo(
418
- () => ({
419
- variant,
420
- themeColor,
421
- size,
422
- radius,
423
- isDisabled,
424
- isSelectable,
425
- selectMode,
426
- selectedValues: currentValues,
427
- onToggle
428
- }),
429
- [
430
- variant,
431
- themeColor,
432
- size,
433
- radius,
434
- isDisabled,
435
- isSelectable,
436
- selectMode,
437
- currentValues,
438
- onToggle
439
- ]
440
- );
441
- return /* @__PURE__ */ React2.createElement(ChipGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ React2.createElement(
442
- View2,
443
- {
444
- style: [
445
- styles.groupContainer,
446
- { gap: spacing },
447
- customAppearance?.container
448
- ],
449
- accessible: true
450
- },
451
- children
452
- ));
453
- };
454
-
455
- // src/components/chip/chip-item.tsx
456
- import React3, { useContext } from "react";
457
- function getSelectableVariant(baseVariant, isSelected) {
458
- if (isSelected) {
459
- return baseVariant;
460
- }
461
- if (baseVariant === "solid" || baseVariant === "shadow") {
462
- return "bordered";
463
- }
464
- return "light";
465
- }
466
- var ChipItem = ({
467
- value,
468
- children,
469
- variant,
470
- themeColor,
471
- avatar,
472
- startContent,
473
- endContent,
474
- isDisabled,
475
- customAppearance
476
- }) => {
477
- const groupContext = useContext(ChipGroupContext);
478
- if (!groupContext) {
479
- return null;
480
- }
481
- const resolvedVariant = variant ?? groupContext.variant;
482
- const resolvedColor = themeColor ?? groupContext.themeColor;
483
- const resolvedDisabled = isDisabled ?? groupContext.isDisabled;
484
- const isSelected = groupContext.selectedValues.includes(value);
485
- const chipVariant = groupContext.isSelectable ? getSelectableVariant(resolvedVariant, isSelected) : resolvedVariant;
486
- const handlePress = groupContext.isSelectable ? () => groupContext.onToggle(value) : void 0;
487
- return /* @__PURE__ */ React3.createElement(
488
- Chip,
489
- {
490
- variant: chipVariant,
491
- themeColor: resolvedColor,
492
- size: groupContext.size,
493
- radius: groupContext.radius,
494
- isDisabled: resolvedDisabled,
495
- avatar,
496
- startContent,
497
- endContent,
498
- customAppearance,
499
- onPress: handlePress
500
- },
501
- children
502
- );
503
- };
504
-
505
- export {
506
- Chip,
507
- ChipGroup,
508
- ChipItem
509
- };
@@ -1,197 +0,0 @@
1
- import {
2
- useXUITheme
3
- } from "./chunk-NBRASCX4.js";
4
-
5
- // src/components/badge/badge.tsx
6
- import React from "react";
7
- import { Text, View } from "react-native";
8
-
9
- // src/components/badge/badge.style.ts
10
- import { StyleSheet } from "react-native";
11
- var styles = StyleSheet.create({
12
- container: {
13
- position: "relative",
14
- alignSelf: "flex-start"
15
- },
16
- badge: {
17
- position: "absolute",
18
- alignItems: "center",
19
- justifyContent: "center"
20
- },
21
- text: {
22
- textAlign: "center",
23
- fontWeight: "600",
24
- includeFontPadding: false,
25
- textAlignVertical: "center"
26
- }
27
- });
28
-
29
- // src/components/badge/badge.hook.ts
30
- import { useMemo } from "react";
31
- import { getSafeThemeColor, withOpacity } from "@xaui/core";
32
- var sizeMap = {
33
- sm: { height: 16, minWidth: 16, dot: 8 },
34
- md: { height: 20, minWidth: 20, dot: 10 },
35
- lg: { height: 24, minWidth: 24, dot: 12 }
36
- };
37
- var fontSizeMap = {
38
- sm: 9,
39
- md: 10,
40
- lg: 12
41
- };
42
- function useBadgeSizeStyles(size, isDot, isOneChar) {
43
- const theme = useXUITheme();
44
- return useMemo(() => {
45
- const { height, minWidth, dot } = sizeMap[size];
46
- const fontSize = fontSizeMap[size];
47
- if (isDot) {
48
- return {
49
- height: dot,
50
- minWidth: dot,
51
- paddingHorizontal: 0,
52
- fontSize
53
- };
54
- }
55
- if (isOneChar) {
56
- return {
57
- height,
58
- minWidth: height,
59
- paddingHorizontal: 0,
60
- fontSize
61
- };
62
- }
63
- const paddingHorizontal = size === "sm" ? theme.spacing.xs : theme.spacing.sm;
64
- return {
65
- height,
66
- minWidth,
67
- paddingHorizontal,
68
- fontSize
69
- };
70
- }, [isDot, isOneChar, size, theme]);
71
- }
72
- function useBadgeVariantStyles(themeColor, variant) {
73
- const theme = useXUITheme();
74
- const safeThemeColor = getSafeThemeColor(themeColor);
75
- const colorScheme = theme.colors[safeThemeColor];
76
- return useMemo(() => {
77
- if (variant === "flat") {
78
- return {
79
- backgroundColor: colorScheme.background,
80
- color: colorScheme.main
81
- };
82
- }
83
- if (variant === "faded") {
84
- return {
85
- backgroundColor: withOpacity(colorScheme.background, 0.7),
86
- color: colorScheme.main
87
- };
88
- }
89
- if (variant === "shadow") {
90
- return {
91
- backgroundColor: colorScheme.main,
92
- color: colorScheme.foreground,
93
- shadow: theme.shadows.sm
94
- };
95
- }
96
- return {
97
- backgroundColor: colorScheme.main,
98
- color: colorScheme.foreground
99
- };
100
- }, [colorScheme, theme, variant]);
101
- }
102
- function useBadgeRadiusStyles(radius, height) {
103
- const theme = useXUITheme();
104
- return useMemo(() => {
105
- if (radius === "full") {
106
- return { borderRadius: height / 2 };
107
- }
108
- return { borderRadius: theme.borderRadius[radius] };
109
- }, [height, radius, theme.borderRadius]);
110
- }
111
- function useBadgePlacementStyles(placement, height) {
112
- return useMemo(() => {
113
- const offset = Math.round(height * 0.3);
114
- switch (placement) {
115
- case "top-left":
116
- return { top: -offset, left: -offset };
117
- case "bottom-right":
118
- return { bottom: -offset, right: -offset };
119
- case "bottom-left":
120
- return { bottom: -offset, left: -offset };
121
- case "top-right":
122
- default:
123
- return { top: -offset, right: -offset };
124
- }
125
- }, [height, placement]);
126
- }
127
-
128
- // src/components/badge/badge.tsx
129
- var Badge = ({
130
- children,
131
- content,
132
- themeColor = "primary",
133
- variant = "solid",
134
- size = "md",
135
- radius = "full",
136
- placement = "top-right",
137
- showOutline = true,
138
- disableOutline = false,
139
- isInvisible = false,
140
- isDot = false,
141
- isOneChar = false,
142
- disableAnimation = false,
143
- customAppearance
144
- }) => {
145
- const shouldRender = !isInvisible && (isDot || content !== void 0);
146
- if (!shouldRender && !children) {
147
- return null;
148
- }
149
- const forceOneChar = isOneChar || radius === "full";
150
- const sizeStyles = useBadgeSizeStyles(size, isDot, forceOneChar);
151
- const variantStyles = useBadgeVariantStyles(themeColor, variant);
152
- const radiusStyles = useBadgeRadiusStyles(radius, sizeStyles.height);
153
- const placementStyles = useBadgePlacementStyles(placement, sizeStyles.height);
154
- const outlineEnabled = disableOutline ? false : showOutline;
155
- const outlineStyles = outlineEnabled ? { borderWidth: 1, borderColor: "#FFFFFF" } : { borderWidth: 0, borderColor: "transparent" };
156
- const badgeContent = isDot ? null : content;
157
- return /* @__PURE__ */ React.createElement(View, { style: [styles.container, customAppearance?.container] }, children, shouldRender && /* @__PURE__ */ React.createElement(
158
- View,
159
- {
160
- style: [
161
- styles.badge,
162
- {
163
- minWidth: sizeStyles.minWidth,
164
- height: sizeStyles.height,
165
- paddingHorizontal: sizeStyles.paddingHorizontal,
166
- backgroundColor: variantStyles.backgroundColor,
167
- opacity: disableAnimation ? 1 : 1
168
- },
169
- radiusStyles,
170
- placementStyles,
171
- outlineStyles,
172
- variantStyles.shadow,
173
- customAppearance?.badge
174
- ],
175
- accessible: true,
176
- accessibilityRole: "text"
177
- },
178
- badgeContent !== void 0 && badgeContent !== null && /* @__PURE__ */ React.createElement(
179
- Text,
180
- {
181
- style: [
182
- styles.text,
183
- {
184
- fontSize: sizeStyles.fontSize,
185
- color: variantStyles.color
186
- },
187
- customAppearance?.text
188
- ]
189
- },
190
- badgeContent
191
- )
192
- ));
193
- };
194
-
195
- export {
196
- Badge
197
- };