@xaui/native 0.0.15 → 0.0.17

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 (72) hide show
  1. package/README.md +3 -2
  2. package/dist/accordion/index.cjs +1 -1
  3. package/dist/accordion/index.js +5 -4
  4. package/dist/alert/index.js +3 -2
  5. package/dist/autocomplete/index.cjs +5 -11
  6. package/dist/autocomplete/index.js +3 -2
  7. package/dist/avatar/index.js +3 -2
  8. package/dist/badge/index.js +3 -2
  9. package/dist/bottom-sheet/index.cjs +9 -20
  10. package/dist/bottom-sheet/index.js +3 -2
  11. package/dist/button/index.cjs +19 -15
  12. package/dist/button/index.d.cts +11 -95
  13. package/dist/button/index.d.ts +11 -95
  14. package/dist/button/index.js +22 -17
  15. package/dist/button.type-D8tzEBo7.d.ts +104 -0
  16. package/dist/button.type-ikaWzhIg.d.cts +104 -0
  17. package/dist/carousel/index.cjs +458 -0
  18. package/dist/carousel/index.d.cts +147 -0
  19. package/dist/carousel/index.d.ts +147 -0
  20. package/dist/carousel/index.js +7 -0
  21. package/dist/checkbox/index.js +2 -1
  22. package/dist/chip/index.cjs +2 -8
  23. package/dist/chip/index.js +3 -2
  24. package/dist/{chunk-QLEQYKG5.js → chunk-6PXMB5CH.js} +3 -9
  25. package/dist/chunk-DBKVHMSA.js +329 -0
  26. package/dist/chunk-DXXNBF5P.js +7 -0
  27. package/dist/chunk-EW5YLICE.js +382 -0
  28. package/dist/{chunk-7OFTYKK4.js → chunk-JJOVGRNI.js} +1 -1
  29. package/dist/{chunk-4LFRYVSR.js → chunk-K2HSVISE.js} +1 -1
  30. package/dist/{chunk-NBRASCX4.js → chunk-MZL77KV5.js} +5 -12
  31. package/dist/{chunk-2T6FKPJW.js → chunk-OXVIVNIJ.js} +1 -1
  32. package/dist/{chunk-ZYTBRHLJ.js → chunk-PWCUULAL.js} +1 -1
  33. package/dist/{chunk-GNJIET26.js → chunk-RIVFFZRO.js} +1 -1
  34. package/dist/{chunk-GAOI4KIV.js → chunk-S3MGBM3G.js} +10 -21
  35. package/dist/chunk-STUNTRKJ.js +405 -0
  36. package/dist/chunk-TJ2FPLLZ.js +287 -0
  37. package/dist/{chunk-XJKA22BK.js → chunk-UGDGCMGC.js} +1 -1
  38. package/dist/{chunk-MKHBEJLO.js → chunk-VUVE6PK7.js} +1 -1
  39. package/dist/{chunk-NMZUPH3R.js → chunk-XUYIAA3A.js} +3 -9
  40. package/dist/core/index.js +5 -3
  41. package/dist/datepicker/index.js +3 -2
  42. package/dist/divider/index.js +3 -2
  43. package/dist/fab/index.cjs +725 -0
  44. package/dist/fab/index.d.cts +10 -0
  45. package/dist/fab/index.d.ts +10 -0
  46. package/dist/fab/index.js +9 -0
  47. package/dist/fab-menu/index.cjs +1063 -0
  48. package/dist/fab-menu/index.d.cts +125 -0
  49. package/dist/fab-menu/index.d.ts +125 -0
  50. package/dist/fab-menu/index.js +12 -0
  51. package/dist/fab.type-Ba0QMprb.d.ts +86 -0
  52. package/dist/fab.type-U09H8B7D.d.cts +86 -0
  53. package/dist/index.cjs +1712 -366
  54. package/dist/index.d.cts +6 -0
  55. package/dist/index.d.ts +6 -0
  56. package/dist/index.js +32 -11
  57. package/dist/indicator/index.js +3 -2
  58. package/dist/menu/index.cjs +8 -7
  59. package/dist/menu/index.js +15 -9
  60. package/dist/progress/index.js +2 -1
  61. package/dist/segment-button/index.cjs +492 -0
  62. package/dist/segment-button/index.d.cts +141 -0
  63. package/dist/segment-button/index.d.ts +141 -0
  64. package/dist/segment-button/index.js +10 -0
  65. package/dist/select/index.js +2 -1
  66. package/dist/switch/index.js +2 -1
  67. package/dist/typography/index.js +3 -2
  68. package/dist/view/index.cjs +153 -78
  69. package/dist/view/index.d.cts +77 -1
  70. package/dist/view/index.d.ts +77 -1
  71. package/dist/view/index.js +125 -52
  72. package/package.json +21 -1
package/README.md CHANGED
@@ -58,7 +58,7 @@ function Banner() {
58
58
 
59
59
  ### `Button`
60
60
 
61
- - Variants: `solid`, `outlined`, `flat`, `light`, `elevated`, `faded`
61
+ - Variants: `solid`, `outlined`, `flat`, `light`, `faded`
62
62
  - Sizes: `xs`, `sm`, `md`, `lg`
63
63
  - Radii: `none`, `sm`, `md`, `lg`, `full`
64
64
  - Supports start/end content, `fullWidth`, `isDisabled`, `isLoading` with an integrated spinner
@@ -67,7 +67,8 @@ function Banner() {
67
67
  ```tsx
68
68
  <Button
69
69
  themeColor="primary"
70
- variant="elevated"
70
+ variant="solid"
71
+ elevation={2}
71
72
  size="lg"
72
73
  radius="full"
73
74
  isLoading={saving}
@@ -290,7 +290,7 @@ var useBaseStyles = (variant, isDisabled) => {
290
290
  const base = { overflow: "hidden" };
291
291
  if (variant === "splitted") {
292
292
  base.paddingHorizontal = theme.spacing.md;
293
- base.backgroundColor = (0, import_core3.addOpacityToColor)(theme.colors.default.background, 0.5);
293
+ base.backgroundColor = (0, import_core3.withOpacity)(theme.colors.default.background, 0.5);
294
294
  base.borderRadius = theme.borderRadius.md;
295
295
  base.marginBottom = theme.spacing.xs;
296
296
  } else if (variant === "bordered") {
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  Divider
3
- } from "../chunk-GNJIET26.js";
3
+ } from "../chunk-RIVFFZRO.js";
4
+ import "../chunk-DXXNBF5P.js";
4
5
  import {
5
6
  useXUIPalette,
6
7
  useXUITheme
7
- } from "../chunk-NBRASCX4.js";
8
+ } from "../chunk-MZL77KV5.js";
8
9
 
9
10
  // src/components/accordion/accordion.tsx
10
11
  import React4 from "react";
@@ -139,7 +140,7 @@ import {
139
140
  Easing
140
141
  } from "react-native";
141
142
  import { colors as palette } from "@xaui/core/palette";
142
- import { addOpacityToColor } from "@xaui/core";
143
+ import { withOpacity } from "@xaui/core";
143
144
  var useAccordionItemState = (itemKey) => {
144
145
  const context = useAccordionContext();
145
146
  const resolvedItemKey = itemKey ?? "";
@@ -219,7 +220,7 @@ var useBaseStyles = (variant, isDisabled) => {
219
220
  const base = { overflow: "hidden" };
220
221
  if (variant === "splitted") {
221
222
  base.paddingHorizontal = theme.spacing.md;
222
- base.backgroundColor = addOpacityToColor(theme.colors.default.background, 0.5);
223
+ base.backgroundColor = withOpacity(theme.colors.default.background, 0.5);
223
224
  base.borderRadius = theme.borderRadius.md;
224
225
  base.marginBottom = theme.spacing.xs;
225
226
  } else if (variant === "bordered") {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  Alert
3
- } from "../chunk-2T6FKPJW.js";
4
- import "../chunk-NBRASCX4.js";
3
+ } from "../chunk-OXVIVNIJ.js";
4
+ import "../chunk-DXXNBF5P.js";
5
+ import "../chunk-MZL77KV5.js";
5
6
  export {
6
7
  Alert
7
8
  };
@@ -508,13 +508,7 @@ var styles2 = import_react_native5.StyleSheet.create({
508
508
  });
509
509
 
510
510
  // src/components/dialogs/autocomplete-dialog/autocomplete-dialog-header.tsx
511
- var addOpacityToColor = (color, opacity) => {
512
- const hex = color.replace("#", "");
513
- const r = parseInt(hex.substring(0, 2), 16);
514
- const g = parseInt(hex.substring(2, 4), 16);
515
- const b = parseInt(hex.substring(4, 6), 16);
516
- return `rgba(${r}, ${g}, ${b}, ${opacity})`;
517
- };
511
+ var import_core4 = require("@xaui/core");
518
512
  var AutocompleteDialogHeader = ({
519
513
  title,
520
514
  inputValue,
@@ -545,7 +539,7 @@ var AutocompleteDialogHeader = ({
545
539
  value: inputValue,
546
540
  onChangeText: onInputChange,
547
541
  placeholder,
548
- placeholderTextColor: addOpacityToColor(theme.colors.foreground, 0.5),
542
+ placeholderTextColor: (0, import_core4.withOpacity)(theme.colors.foreground, 0.5),
549
543
  style: [
550
544
  styles2.input,
551
545
  {
@@ -1073,7 +1067,7 @@ var styles3 = import_react_native11.StyleSheet.create({
1073
1067
 
1074
1068
  // src/components/autocomplete/autocomplete-item.hook.ts
1075
1069
  var import_react15 = require("react");
1076
- var import_core6 = require("@xaui/core");
1070
+ var import_core7 = require("@xaui/core");
1077
1071
  var useAutocompleteItemSizeStyles = (size) => {
1078
1072
  const theme = useXUITheme();
1079
1073
  return (0, import_react15.useMemo)(() => {
@@ -1108,7 +1102,7 @@ var useAutocompleteItemSizeStyles = (size) => {
1108
1102
  };
1109
1103
  var useAutocompleteItemBackgroundColor = (themeColor, isSelected) => {
1110
1104
  const theme = useXUITheme();
1111
- const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
1105
+ const safeThemeColor = (0, import_core7.getSafeThemeColor)(themeColor);
1112
1106
  const colorScheme = theme.colors[safeThemeColor];
1113
1107
  return (0, import_react15.useMemo)(() => {
1114
1108
  return "transparent";
@@ -1125,7 +1119,7 @@ var useAutocompleteItemTextColors = () => {
1125
1119
  };
1126
1120
  var useAutocompleteItemCheckmarkColor = (themeColor) => {
1127
1121
  const theme = useXUITheme();
1128
- const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
1122
+ const safeThemeColor = (0, import_core7.getSafeThemeColor)(themeColor);
1129
1123
  const colorScheme = theme.colors[safeThemeColor];
1130
1124
  return (0, import_react15.useMemo)(() => {
1131
1125
  if (themeColor === "default") {
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  Autocomplete,
3
3
  AutocompleteItem
4
- } from "../chunk-NMZUPH3R.js";
4
+ } from "../chunk-XUYIAA3A.js";
5
5
  import "../chunk-GBHQCAKW.js";
6
- import "../chunk-NBRASCX4.js";
6
+ import "../chunk-DXXNBF5P.js";
7
+ import "../chunk-MZL77KV5.js";
7
8
  export {
8
9
  Autocomplete,
9
10
  AutocompleteItem
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  Avatar,
3
3
  AvatarGroup
4
- } from "../chunk-4LFRYVSR.js";
5
- import "../chunk-NBRASCX4.js";
4
+ } from "../chunk-K2HSVISE.js";
5
+ import "../chunk-DXXNBF5P.js";
6
+ import "../chunk-MZL77KV5.js";
6
7
  export {
7
8
  Avatar,
8
9
  AvatarGroup
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  Badge
3
- } from "../chunk-XJKA22BK.js";
4
- import "../chunk-NBRASCX4.js";
3
+ } from "../chunk-UGDGCMGC.js";
4
+ import "../chunk-DXXNBF5P.js";
5
+ import "../chunk-MZL77KV5.js";
5
6
  export {
6
7
  Badge
7
8
  };
@@ -242,7 +242,13 @@ var useBottomSheetAnimation = ({
242
242
  snapTranslateValues[clampedIndex]
243
243
  );
244
244
  },
245
- [sortedSnapPoints, snapTranslateValues, disableAnimation, translateY, onSnapChange]
245
+ [
246
+ sortedSnapPoints,
247
+ snapTranslateValues,
248
+ disableAnimation,
249
+ translateY,
250
+ onSnapChange
251
+ ]
246
252
  );
247
253
  (0, import_react6.useEffect)(() => {
248
254
  if (isOpen) {
@@ -417,19 +423,7 @@ var BottomSheet = ({
417
423
  close();
418
424
  }
419
425
  };
420
- return /* @__PURE__ */ import_react7.default.createElement(Portal, null, showBackdrop && /* @__PURE__ */ import_react7.default.createElement(
421
- import_react_native7.Animated.View,
422
- {
423
- style: [styles.backdrop, { opacity: backdropOpacity }]
424
- },
425
- /* @__PURE__ */ import_react7.default.createElement(
426
- import_react_native7.Pressable,
427
- {
428
- style: styles.backdrop,
429
- onPress: handleBackdropPress
430
- }
431
- )
432
- ), /* @__PURE__ */ import_react7.default.createElement(
426
+ return /* @__PURE__ */ import_react7.default.createElement(Portal, null, showBackdrop && /* @__PURE__ */ import_react7.default.createElement(import_react_native7.Animated.View, { style: [styles.backdrop, { opacity: backdropOpacity }] }, /* @__PURE__ */ import_react7.default.createElement(import_react_native7.Pressable, { style: styles.backdrop, onPress: handleBackdropPress })), /* @__PURE__ */ import_react7.default.createElement(
433
427
  import_react_native7.Animated.View,
434
428
  {
435
429
  style: [
@@ -443,12 +437,7 @@ var BottomSheet = ({
443
437
  /* @__PURE__ */ import_react7.default.createElement(
444
438
  import_react_native7.View,
445
439
  {
446
- style: [
447
- styles.sheet,
448
- { height: screenHeight },
449
- sheetStyles,
450
- style
451
- ],
440
+ style: [styles.sheet, { height: screenHeight }, sheetStyles, style],
452
441
  ...panResponder.panHandlers
453
442
  },
454
443
  showHandle && /* @__PURE__ */ import_react7.default.createElement(import_react_native7.View, { style: styles.handle }, handleContent ?? /* @__PURE__ */ import_react7.default.createElement(
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  BottomSheet
3
- } from "../chunk-GAOI4KIV.js";
4
- import "../chunk-NBRASCX4.js";
3
+ } from "../chunk-S3MGBM3G.js";
4
+ import "../chunk-DXXNBF5P.js";
5
+ import "../chunk-MZL77KV5.js";
5
6
  export {
6
7
  BottomSheet
7
8
  };
@@ -511,7 +511,7 @@ var useTextStyles = (themeColor, variant) => {
511
511
  const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
512
512
  const colorScheme = theme.colors[safeThemeColor];
513
513
  const textColor = (0, import_react10.useMemo)(() => {
514
- if (variant === "solid" || variant === "elevated") {
514
+ if (variant === "solid") {
515
515
  return colorScheme.foreground;
516
516
  }
517
517
  return colorScheme.main;
@@ -562,7 +562,7 @@ function useSizesStyles(size) {
562
562
  }, [size]);
563
563
  return { sizeStyles, spinnerSize };
564
564
  }
565
- function useVariantSizesStyles(themeColor, variant) {
565
+ function useVariantSizesStyles(themeColor, variant, elevation = 0) {
566
566
  const theme = useXUITheme();
567
567
  const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
568
568
  const colorScheme = theme.colors[safeThemeColor];
@@ -585,19 +585,21 @@ function useVariantSizesStyles(themeColor, variant) {
585
585
  backgroundColor: "transparent",
586
586
  borderWidth: 0
587
587
  },
588
- elevated: {
589
- backgroundColor: colorScheme.main,
590
- borderWidth: 0,
591
- ...theme.shadows.md
592
- },
593
588
  faded: {
594
589
  backgroundColor: `${colorScheme.background}95`,
595
590
  borderWidth: theme.borderWidth.md,
596
591
  borderColor: `${colorScheme.main}90`
597
592
  }
598
593
  };
599
- return styles3[variant];
600
- }, [variant, colorScheme, theme]);
594
+ const baseStyle = styles3[variant];
595
+ const shouldApplyElevation = variant !== "outlined" && variant !== "light";
596
+ const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
597
+ return {
598
+ ...baseStyle,
599
+ ...shouldApplyElevation ? shadowStyles : {},
600
+ ...shouldApplyElevation && elevation > 0 ? { elevation } : {}
601
+ };
602
+ }, [variant, colorScheme, theme, elevation]);
601
603
  return variantStyles;
602
604
  }
603
605
 
@@ -647,6 +649,7 @@ var Button = ({
647
649
  fullWidth = false,
648
650
  isDisabled = false,
649
651
  isLoading = false,
652
+ elevation = 0,
650
653
  customAppearance,
651
654
  onPress,
652
655
  onLongPress,
@@ -657,7 +660,7 @@ var Button = ({
657
660
  const animatedOpacity = import_react11.default.useRef(new import_react_native10.Animated.Value(1)).current;
658
661
  const { sizeStyles, spinnerSize } = useSizesStyles(size);
659
662
  const radiusStyles = useBorderRadiusStyles(radius);
660
- const variantStyles = useVariantSizesStyles(themeColor, variant);
663
+ const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
661
664
  const { textColor } = useTextStyles(themeColor, variant);
662
665
  const handlePressIn = (event) => {
663
666
  if (!isDisabled && !isLoading) {
@@ -675,8 +678,8 @@ var Button = ({
675
678
  ActivityIndicator,
676
679
  {
677
680
  variant: "circular",
678
- themeColor: variant === "solid" || variant === "elevated" ? void 0 : themeColor,
679
- color: variant === "solid" || variant === "elevated" ? textColor : void 0,
681
+ themeColor: variant === "solid" ? void 0 : themeColor,
682
+ color: variant === "solid" ? textColor : void 0,
680
683
  size: spinnerSize
681
684
  }
682
685
  );
@@ -767,6 +770,7 @@ var IconButton = ({
767
770
  radius = "md",
768
771
  isDisabled = false,
769
772
  isLoading = false,
773
+ elevation = 0,
770
774
  customAppearance,
771
775
  onPress,
772
776
  onLongPress,
@@ -777,7 +781,7 @@ var IconButton = ({
777
781
  const animatedOpacity = import_react13.default.useRef(new import_react_native12.Animated.Value(1)).current;
778
782
  const sizeStyles = useIconButtonSizeStyles(size);
779
783
  const radiusStyles = useBorderRadiusStyles(radius);
780
- const variantStyles = useVariantSizesStyles(themeColor, variant);
784
+ const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
781
785
  const { textColor } = useTextStyles(themeColor, variant);
782
786
  const handlePressIn = (event) => {
783
787
  if (!isDisabled && !isLoading) {
@@ -826,8 +830,8 @@ var IconButton = ({
826
830
  ActivityIndicator,
827
831
  {
828
832
  variant: "circular",
829
- themeColor: variant === "solid" || variant === "elevated" ? void 0 : themeColor,
830
- color: variant === "solid" || variant === "elevated" ? textColor : void 0,
833
+ themeColor: variant === "solid" ? void 0 : themeColor,
834
+ color: variant === "solid" ? textColor : void 0,
831
835
  size: spinnerSize
832
836
  }
833
837
  ) : icon
@@ -1,98 +1,8 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { ViewStyle, TextStyle, GestureResponderEvent } from 'react-native';
3
- import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.cjs';
4
-
5
- type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
6
- type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
7
- type SpinnerPlacement = 'start' | 'end';
8
- type ButtonCustomAppearance = {
9
- /**
10
- * Custom styles for the outer container
11
- */
12
- container?: ViewStyle;
13
- /**
14
- * Custom styles for the button
15
- */
16
- button?: ViewStyle;
17
- /**
18
- * Custom styles for the button text
19
- */
20
- text?: TextStyle;
21
- };
22
- type ButtonProps = {
23
- /**
24
- * The content to display in the button.
25
- */
26
- children: ReactNode;
27
- /**
28
- * The theme color of the button.
29
- * @default 'default'
30
- */
31
- themeColor?: ThemeColor;
32
- /**
33
- * The variant of the button.
34
- * @default 'solid'
35
- */
36
- variant?: ButtonVariant;
37
- /**
38
- * The size of the button.
39
- * @default 'md'
40
- */
41
- size?: Size;
42
- /**
43
- * The border radius of the button.
44
- * @default 'md'
45
- */
46
- radius?: ButtonRadius;
47
- /**
48
- * Content to display at the start of the button.
49
- */
50
- startContent?: ReactNode;
51
- /**
52
- * Content to display at the end of the button.
53
- */
54
- endContent?: ReactNode;
55
- /**
56
- * The placement of the spinner when isLoading is true.
57
- * @default 'start'
58
- */
59
- spinnerPlacement?: SpinnerPlacement;
60
- /**
61
- * Whether the button should take the full width of its container.
62
- * @default false
63
- */
64
- fullWidth?: boolean;
65
- /**
66
- * Whether the button is disabled.
67
- * @default false
68
- */
69
- isDisabled?: boolean;
70
- /**
71
- * Whether the button is in a loading state.
72
- * @default false
73
- */
74
- isLoading?: boolean;
75
- /**
76
- * Custom appearance styles for button parts
77
- */
78
- customAppearance?: ButtonCustomAppearance;
79
- /**
80
- * Callback fired when the button is pressed.
81
- */
82
- onPress?: (event: GestureResponderEvent) => void;
83
- /**
84
- * Callback fired when the button is long pressed.
85
- */
86
- onLongPress?: (event: GestureResponderEvent) => void;
87
- /**
88
- * Callback fired when the button press starts.
89
- */
90
- onPressIn?: (event: GestureResponderEvent) => void;
91
- /**
92
- * Callback fired when the button press ends.
93
- */
94
- onPressOut?: (event: GestureResponderEvent) => void;
95
- };
2
+ import { a as ButtonProps, b as ButtonVariant, B as ButtonRadius, E as ElevationLevel } from '../button.type-ikaWzhIg.cjs';
3
+ export { S as SpinnerPlacement } from '../button.type-ikaWzhIg.cjs';
4
+ import { ViewStyle, GestureResponderEvent } from 'react-native';
5
+ import { S as Size, T as ThemeColor } from '../index-BOw6tbkc.cjs';
96
6
 
97
7
  declare const Button: React.FC<ButtonProps>;
98
8
 
@@ -131,6 +41,12 @@ type IconButtonProps = {
131
41
  * @default false
132
42
  */
133
43
  isLoading?: boolean;
44
+ /**
45
+ * Android elevation level from 0 to 4.
46
+ * Does not apply to `outlined` and `light` variants.
47
+ * @default 0
48
+ */
49
+ elevation?: ElevationLevel;
134
50
  /**
135
51
  * Custom appearance overrides
136
52
  */
@@ -158,4 +74,4 @@ type IconButtonProps = {
158
74
 
159
75
  declare const IconButton: React.FC<IconButtonProps>;
160
76
 
161
- export { Button, type ButtonProps, type ButtonRadius, type ButtonVariant, IconButton, type IconButtonProps, type SpinnerPlacement };
77
+ export { Button, ButtonProps, ButtonRadius, ButtonVariant, IconButton, type IconButtonProps };
@@ -1,98 +1,8 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { ViewStyle, TextStyle, GestureResponderEvent } from 'react-native';
3
- import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.js';
4
-
5
- type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
6
- type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
7
- type SpinnerPlacement = 'start' | 'end';
8
- type ButtonCustomAppearance = {
9
- /**
10
- * Custom styles for the outer container
11
- */
12
- container?: ViewStyle;
13
- /**
14
- * Custom styles for the button
15
- */
16
- button?: ViewStyle;
17
- /**
18
- * Custom styles for the button text
19
- */
20
- text?: TextStyle;
21
- };
22
- type ButtonProps = {
23
- /**
24
- * The content to display in the button.
25
- */
26
- children: ReactNode;
27
- /**
28
- * The theme color of the button.
29
- * @default 'default'
30
- */
31
- themeColor?: ThemeColor;
32
- /**
33
- * The variant of the button.
34
- * @default 'solid'
35
- */
36
- variant?: ButtonVariant;
37
- /**
38
- * The size of the button.
39
- * @default 'md'
40
- */
41
- size?: Size;
42
- /**
43
- * The border radius of the button.
44
- * @default 'md'
45
- */
46
- radius?: ButtonRadius;
47
- /**
48
- * Content to display at the start of the button.
49
- */
50
- startContent?: ReactNode;
51
- /**
52
- * Content to display at the end of the button.
53
- */
54
- endContent?: ReactNode;
55
- /**
56
- * The placement of the spinner when isLoading is true.
57
- * @default 'start'
58
- */
59
- spinnerPlacement?: SpinnerPlacement;
60
- /**
61
- * Whether the button should take the full width of its container.
62
- * @default false
63
- */
64
- fullWidth?: boolean;
65
- /**
66
- * Whether the button is disabled.
67
- * @default false
68
- */
69
- isDisabled?: boolean;
70
- /**
71
- * Whether the button is in a loading state.
72
- * @default false
73
- */
74
- isLoading?: boolean;
75
- /**
76
- * Custom appearance styles for button parts
77
- */
78
- customAppearance?: ButtonCustomAppearance;
79
- /**
80
- * Callback fired when the button is pressed.
81
- */
82
- onPress?: (event: GestureResponderEvent) => void;
83
- /**
84
- * Callback fired when the button is long pressed.
85
- */
86
- onLongPress?: (event: GestureResponderEvent) => void;
87
- /**
88
- * Callback fired when the button press starts.
89
- */
90
- onPressIn?: (event: GestureResponderEvent) => void;
91
- /**
92
- * Callback fired when the button press ends.
93
- */
94
- onPressOut?: (event: GestureResponderEvent) => void;
95
- };
2
+ import { a as ButtonProps, b as ButtonVariant, B as ButtonRadius, E as ElevationLevel } from '../button.type-D8tzEBo7.js';
3
+ export { S as SpinnerPlacement } from '../button.type-D8tzEBo7.js';
4
+ import { ViewStyle, GestureResponderEvent } from 'react-native';
5
+ import { S as Size, T as ThemeColor } from '../index-BOw6tbkc.js';
96
6
 
97
7
  declare const Button: React.FC<ButtonProps>;
98
8
 
@@ -131,6 +41,12 @@ type IconButtonProps = {
131
41
  * @default false
132
42
  */
133
43
  isLoading?: boolean;
44
+ /**
45
+ * Android elevation level from 0 to 4.
46
+ * Does not apply to `outlined` and `light` variants.
47
+ * @default 0
48
+ */
49
+ elevation?: ElevationLevel;
134
50
  /**
135
51
  * Custom appearance overrides
136
52
  */
@@ -158,4 +74,4 @@ type IconButtonProps = {
158
74
 
159
75
  declare const IconButton: React.FC<IconButtonProps>;
160
76
 
161
- export { Button, type ButtonProps, type ButtonRadius, type ButtonVariant, IconButton, type IconButtonProps, type SpinnerPlacement };
77
+ export { Button, ButtonProps, ButtonRadius, ButtonVariant, IconButton, type IconButtonProps };
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  ActivityIndicator
3
- } from "../chunk-MKHBEJLO.js";
3
+ } from "../chunk-VUVE6PK7.js";
4
+ import "../chunk-DXXNBF5P.js";
4
5
  import {
5
6
  useBorderRadiusStyles,
6
7
  useXUITheme
7
- } from "../chunk-NBRASCX4.js";
8
+ } from "../chunk-MZL77KV5.js";
8
9
 
9
10
  // src/components/button/button.tsx
10
11
  import React from "react";
@@ -59,7 +60,7 @@ var useTextStyles = (themeColor, variant) => {
59
60
  const safeThemeColor = getSafeThemeColor(themeColor);
60
61
  const colorScheme = theme.colors[safeThemeColor];
61
62
  const textColor = useMemo(() => {
62
- if (variant === "solid" || variant === "elevated") {
63
+ if (variant === "solid") {
63
64
  return colorScheme.foreground;
64
65
  }
65
66
  return colorScheme.main;
@@ -110,7 +111,7 @@ function useSizesStyles(size) {
110
111
  }, [size]);
111
112
  return { sizeStyles, spinnerSize };
112
113
  }
113
- function useVariantSizesStyles(themeColor, variant) {
114
+ function useVariantSizesStyles(themeColor, variant, elevation = 0) {
114
115
  const theme = useXUITheme();
115
116
  const safeThemeColor = getSafeThemeColor(themeColor);
116
117
  const colorScheme = theme.colors[safeThemeColor];
@@ -133,19 +134,21 @@ function useVariantSizesStyles(themeColor, variant) {
133
134
  backgroundColor: "transparent",
134
135
  borderWidth: 0
135
136
  },
136
- elevated: {
137
- backgroundColor: colorScheme.main,
138
- borderWidth: 0,
139
- ...theme.shadows.md
140
- },
141
137
  faded: {
142
138
  backgroundColor: `${colorScheme.background}95`,
143
139
  borderWidth: theme.borderWidth.md,
144
140
  borderColor: `${colorScheme.main}90`
145
141
  }
146
142
  };
147
- return styles2[variant];
148
- }, [variant, colorScheme, theme]);
143
+ const baseStyle = styles2[variant];
144
+ const shouldApplyElevation = variant !== "outlined" && variant !== "light";
145
+ const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
146
+ return {
147
+ ...baseStyle,
148
+ ...shouldApplyElevation ? shadowStyles : {},
149
+ ...shouldApplyElevation && elevation > 0 ? { elevation } : {}
150
+ };
151
+ }, [variant, colorScheme, theme, elevation]);
149
152
  return variantStyles;
150
153
  }
151
154
 
@@ -195,6 +198,7 @@ var Button = ({
195
198
  fullWidth = false,
196
199
  isDisabled = false,
197
200
  isLoading = false,
201
+ elevation = 0,
198
202
  customAppearance,
199
203
  onPress,
200
204
  onLongPress,
@@ -205,7 +209,7 @@ var Button = ({
205
209
  const animatedOpacity = React.useRef(new Animated2.Value(1)).current;
206
210
  const { sizeStyles, spinnerSize } = useSizesStyles(size);
207
211
  const radiusStyles = useBorderRadiusStyles(radius);
208
- const variantStyles = useVariantSizesStyles(themeColor, variant);
212
+ const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
209
213
  const { textColor } = useTextStyles(themeColor, variant);
210
214
  const handlePressIn = (event) => {
211
215
  if (!isDisabled && !isLoading) {
@@ -223,8 +227,8 @@ var Button = ({
223
227
  ActivityIndicator,
224
228
  {
225
229
  variant: "circular",
226
- themeColor: variant === "solid" || variant === "elevated" ? void 0 : themeColor,
227
- color: variant === "solid" || variant === "elevated" ? textColor : void 0,
230
+ themeColor: variant === "solid" ? void 0 : themeColor,
231
+ color: variant === "solid" ? textColor : void 0,
228
232
  size: spinnerSize
229
233
  }
230
234
  );
@@ -315,6 +319,7 @@ var IconButton = ({
315
319
  radius = "md",
316
320
  isDisabled = false,
317
321
  isLoading = false,
322
+ elevation = 0,
318
323
  customAppearance,
319
324
  onPress,
320
325
  onLongPress,
@@ -325,7 +330,7 @@ var IconButton = ({
325
330
  const animatedOpacity = React2.useRef(new Animated3.Value(1)).current;
326
331
  const sizeStyles = useIconButtonSizeStyles(size);
327
332
  const radiusStyles = useBorderRadiusStyles(radius);
328
- const variantStyles = useVariantSizesStyles(themeColor, variant);
333
+ const variantStyles = useVariantSizesStyles(themeColor, variant, elevation);
329
334
  const { textColor } = useTextStyles(themeColor, variant);
330
335
  const handlePressIn = (event) => {
331
336
  if (!isDisabled && !isLoading) {
@@ -374,8 +379,8 @@ var IconButton = ({
374
379
  ActivityIndicator,
375
380
  {
376
381
  variant: "circular",
377
- themeColor: variant === "solid" || variant === "elevated" ? void 0 : themeColor,
378
- color: variant === "solid" || variant === "elevated" ? textColor : void 0,
382
+ themeColor: variant === "solid" ? void 0 : themeColor,
383
+ color: variant === "solid" ? textColor : void 0,
379
384
  size: spinnerSize
380
385
  }
381
386
  ) : icon