@xaui/native 0.2.7 → 0.9.1-alpha.0

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 (224) hide show
  1. package/dist/chunk-JDS6KGCM.cjs +791 -0
  2. package/dist/chunk-T3ZI2PZ6.js +791 -0
  3. package/dist/index.cjs +32 -1
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +32 -0
  7. package/dist/theme/index.cjs +32 -0
  8. package/dist/theme/index.d.cts +669 -0
  9. package/dist/theme/index.d.ts +669 -0
  10. package/dist/theme/index.js +32 -0
  11. package/package.json +26 -249
  12. package/README.md +0 -178
  13. package/dist/alert/index.cjs +0 -356
  14. package/dist/alert/index.d.cts +0 -90
  15. package/dist/alert/index.d.ts +0 -90
  16. package/dist/alert/index.js +0 -356
  17. package/dist/app-bar/index.cjs +0 -148
  18. package/dist/app-bar/index.d.cts +0 -59
  19. package/dist/app-bar/index.d.ts +0 -59
  20. package/dist/app-bar/index.js +0 -148
  21. package/dist/autocomplete/index.cjs +0 -1122
  22. package/dist/autocomplete/index.d.cts +0 -88
  23. package/dist/autocomplete/index.d.ts +0 -88
  24. package/dist/autocomplete/index.js +0 -1122
  25. package/dist/avatar/index.cjs +0 -281
  26. package/dist/avatar/index.d.cts +0 -123
  27. package/dist/avatar/index.d.ts +0 -123
  28. package/dist/avatar/index.js +0 -281
  29. package/dist/badge/index.cjs +0 -197
  30. package/dist/badge/index.d.cts +0 -94
  31. package/dist/badge/index.d.ts +0 -94
  32. package/dist/badge/index.js +0 -197
  33. package/dist/bottom-sheet/index.cjs +0 -9
  34. package/dist/bottom-sheet/index.d.cts +0 -84
  35. package/dist/bottom-sheet/index.d.ts +0 -84
  36. package/dist/bottom-sheet/index.js +0 -9
  37. package/dist/bottom-tab-bar/index.cjs +0 -497
  38. package/dist/bottom-tab-bar/index.d.cts +0 -211
  39. package/dist/bottom-tab-bar/index.d.ts +0 -211
  40. package/dist/bottom-tab-bar/index.js +0 -497
  41. package/dist/button/index.cjs +0 -392
  42. package/dist/button/index.d.cts +0 -174
  43. package/dist/button/index.d.ts +0 -174
  44. package/dist/button/index.js +0 -392
  45. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  46. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  47. package/dist/card/index.cjs +0 -338
  48. package/dist/card/index.d.cts +0 -191
  49. package/dist/card/index.d.ts +0 -191
  50. package/dist/card/index.js +0 -338
  51. package/dist/carousel/index.cjs +0 -381
  52. package/dist/carousel/index.d.cts +0 -147
  53. package/dist/carousel/index.d.ts +0 -147
  54. package/dist/carousel/index.js +0 -381
  55. package/dist/chart/index.cjs +0 -1026
  56. package/dist/chart/index.d.cts +0 -218
  57. package/dist/chart/index.d.ts +0 -218
  58. package/dist/chart/index.js +0 -1026
  59. package/dist/checkbox/index.cjs +0 -443
  60. package/dist/checkbox/index.d.cts +0 -73
  61. package/dist/checkbox/index.d.ts +0 -73
  62. package/dist/checkbox/index.js +0 -443
  63. package/dist/chip/index.cjs +0 -503
  64. package/dist/chip/index.d.cts +0 -195
  65. package/dist/chip/index.d.ts +0 -195
  66. package/dist/chip/index.js +0 -503
  67. package/dist/chunk-4JFWQ5XT.js +0 -368
  68. package/dist/chunk-56RPWZD2.cjs +0 -9
  69. package/dist/chunk-7UFBLUMV.cjs +0 -136
  70. package/dist/chunk-A45TVXU5.js +0 -337
  71. package/dist/chunk-BYWUAPC4.cjs +0 -368
  72. package/dist/chunk-DECMUMCI.js +0 -0
  73. package/dist/chunk-DHSTKO3K.cjs +0 -19
  74. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  75. package/dist/chunk-EUQDGTST.cjs +0 -1
  76. package/dist/chunk-GBHQCAKW.js +0 -19
  77. package/dist/chunk-RBSA4NH4.js +0 -136
  78. package/dist/chunk-SHBDANQN.js +0 -9
  79. package/dist/chunk-UGEINZM7.cjs +0 -290
  80. package/dist/chunk-UU4HHBDN.js +0 -290
  81. package/dist/chunk-VSZEXOUN.js +0 -384
  82. package/dist/chunk-YIEUN3G5.cjs +0 -384
  83. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  84. package/dist/chunk-ZY7IUTAT.js +0 -75
  85. package/dist/color-picker/index.cjs +0 -457
  86. package/dist/color-picker/index.d.cts +0 -124
  87. package/dist/color-picker/index.d.ts +0 -124
  88. package/dist/color-picker/index.js +0 -457
  89. package/dist/core/index.cjs +0 -24
  90. package/dist/core/index.d.cts +0 -28
  91. package/dist/core/index.d.ts +0 -28
  92. package/dist/core/index.js +0 -24
  93. package/dist/datepicker/index.cjs +0 -1625
  94. package/dist/datepicker/index.d.cts +0 -45
  95. package/dist/datepicker/index.d.ts +0 -45
  96. package/dist/datepicker/index.js +0 -1625
  97. package/dist/dialog/index.cjs +0 -372
  98. package/dist/dialog/index.d.cts +0 -151
  99. package/dist/dialog/index.d.ts +0 -151
  100. package/dist/dialog/index.js +0 -372
  101. package/dist/divider/index.cjs +0 -8
  102. package/dist/divider/index.d.cts +0 -30
  103. package/dist/divider/index.d.ts +0 -30
  104. package/dist/divider/index.js +0 -8
  105. package/dist/drawer/index.cjs +0 -237
  106. package/dist/drawer/index.d.cts +0 -58
  107. package/dist/drawer/index.d.ts +0 -58
  108. package/dist/drawer/index.js +0 -237
  109. package/dist/expansion-panel/index.cjs +0 -441
  110. package/dist/expansion-panel/index.d.cts +0 -153
  111. package/dist/expansion-panel/index.d.ts +0 -153
  112. package/dist/expansion-panel/index.js +0 -441
  113. package/dist/fab/index.cjs +0 -9
  114. package/dist/fab/index.d.cts +0 -10
  115. package/dist/fab/index.d.ts +0 -10
  116. package/dist/fab/index.js +0 -9
  117. package/dist/fab-menu/index.cjs +0 -330
  118. package/dist/fab-menu/index.d.cts +0 -125
  119. package/dist/fab-menu/index.d.ts +0 -125
  120. package/dist/fab-menu/index.js +0 -330
  121. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  122. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  123. package/dist/feature-discovery/index.cjs +0 -464
  124. package/dist/feature-discovery/index.d.cts +0 -82
  125. package/dist/feature-discovery/index.d.ts +0 -82
  126. package/dist/feature-discovery/index.js +0 -464
  127. package/dist/indicator/index.cjs +0 -8
  128. package/dist/indicator/index.d.cts +0 -47
  129. package/dist/indicator/index.d.ts +0 -47
  130. package/dist/indicator/index.js +0 -8
  131. package/dist/input/index.cjs +0 -1462
  132. package/dist/input/index.d.cts +0 -522
  133. package/dist/input/index.d.ts +0 -522
  134. package/dist/input/index.js +0 -1462
  135. package/dist/input-trigger/index.cjs +0 -197
  136. package/dist/input-trigger/index.d.cts +0 -11
  137. package/dist/input-trigger/index.d.ts +0 -11
  138. package/dist/input-trigger/index.js +0 -197
  139. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  140. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  141. package/dist/list/index.cjs +0 -395
  142. package/dist/list/index.d.cts +0 -188
  143. package/dist/list/index.d.ts +0 -188
  144. package/dist/list/index.js +0 -395
  145. package/dist/menu/index.cjs +0 -316
  146. package/dist/menu/index.d.cts +0 -115
  147. package/dist/menu/index.d.ts +0 -115
  148. package/dist/menu/index.js +0 -316
  149. package/dist/menubox/index.cjs +0 -297
  150. package/dist/menubox/index.d.cts +0 -98
  151. package/dist/menubox/index.d.ts +0 -98
  152. package/dist/menubox/index.js +0 -297
  153. package/dist/pager/index.cjs +0 -205
  154. package/dist/pager/index.d.cts +0 -93
  155. package/dist/pager/index.d.ts +0 -93
  156. package/dist/pager/index.js +0 -205
  157. package/dist/picker/index.cjs +0 -244
  158. package/dist/picker/index.d.cts +0 -121
  159. package/dist/picker/index.d.ts +0 -121
  160. package/dist/picker/index.js +0 -244
  161. package/dist/progress/index.cjs +0 -219
  162. package/dist/progress/index.d.cts +0 -47
  163. package/dist/progress/index.d.ts +0 -47
  164. package/dist/progress/index.js +0 -219
  165. package/dist/radio/index.cjs +0 -465
  166. package/dist/radio/index.d.cts +0 -145
  167. package/dist/radio/index.d.ts +0 -145
  168. package/dist/radio/index.js +0 -465
  169. package/dist/refresh-control/index.cjs +0 -45
  170. package/dist/refresh-control/index.d.cts +0 -55
  171. package/dist/refresh-control/index.d.ts +0 -55
  172. package/dist/refresh-control/index.js +0 -45
  173. package/dist/segment-button/index.cjs +0 -405
  174. package/dist/segment-button/index.d.cts +0 -141
  175. package/dist/segment-button/index.d.ts +0 -141
  176. package/dist/segment-button/index.js +0 -405
  177. package/dist/select/index.cjs +0 -878
  178. package/dist/select/index.d.cts +0 -192
  179. package/dist/select/index.d.ts +0 -192
  180. package/dist/select/index.js +0 -878
  181. package/dist/skeleton/index.cjs +0 -89
  182. package/dist/skeleton/index.d.cts +0 -45
  183. package/dist/skeleton/index.d.ts +0 -45
  184. package/dist/skeleton/index.js +0 -89
  185. package/dist/slider/index.cjs +0 -576
  186. package/dist/slider/index.d.cts +0 -171
  187. package/dist/slider/index.d.ts +0 -171
  188. package/dist/slider/index.js +0 -576
  189. package/dist/snackbar/index.cjs +0 -436
  190. package/dist/snackbar/index.d.cts +0 -174
  191. package/dist/snackbar/index.d.ts +0 -174
  192. package/dist/snackbar/index.js +0 -436
  193. package/dist/snippet/index.cjs +0 -314
  194. package/dist/snippet/index.d.cts +0 -95
  195. package/dist/snippet/index.d.ts +0 -95
  196. package/dist/snippet/index.js +0 -314
  197. package/dist/stepper/index.cjs +0 -550
  198. package/dist/stepper/index.d.cts +0 -137
  199. package/dist/stepper/index.d.ts +0 -137
  200. package/dist/stepper/index.js +0 -550
  201. package/dist/switch/index.cjs +0 -358
  202. package/dist/switch/index.d.cts +0 -28
  203. package/dist/switch/index.d.ts +0 -28
  204. package/dist/switch/index.js +0 -358
  205. package/dist/tabs/index.cjs +0 -440
  206. package/dist/tabs/index.d.cts +0 -180
  207. package/dist/tabs/index.d.ts +0 -180
  208. package/dist/tabs/index.js +0 -440
  209. package/dist/timepicker/index.cjs +0 -823
  210. package/dist/timepicker/index.d.cts +0 -215
  211. package/dist/timepicker/index.d.ts +0 -215
  212. package/dist/timepicker/index.js +0 -823
  213. package/dist/toolbar/index.cjs +0 -333
  214. package/dist/toolbar/index.d.cts +0 -100
  215. package/dist/toolbar/index.d.ts +0 -100
  216. package/dist/toolbar/index.js +0 -333
  217. package/dist/typography/index.cjs +0 -238
  218. package/dist/typography/index.d.cts +0 -113
  219. package/dist/typography/index.d.ts +0 -113
  220. package/dist/typography/index.js +0 -238
  221. package/dist/view/index.cjs +0 -1361
  222. package/dist/view/index.d.cts +0 -833
  223. package/dist/view/index.d.ts +0 -833
  224. package/dist/view/index.js +0 -1361
@@ -1,195 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ViewStyle, TextStyle } from 'react-native';
3
- import { ThemeColor } from '@xaui/core/types';
4
-
5
- type ChipVariant = 'solid' | 'bordered' | 'light' | 'flat' | 'faded' | 'shadow' | 'dot';
6
- type ChipSize = 'sm' | 'md' | 'lg';
7
- type ChipRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
8
- type ChipSelectMode = 'single' | 'multiple';
9
- type ChipCustomAppearance = {
10
- /**
11
- * Custom styles for the chip container
12
- */
13
- container?: ViewStyle;
14
- /**
15
- * Custom styles for the chip text
16
- */
17
- text?: TextStyle;
18
- /**
19
- * Custom styles for the close button
20
- */
21
- closeButton?: ViewStyle;
22
- /**
23
- * Custom styles for the dot indicator
24
- */
25
- dot?: ViewStyle;
26
- };
27
- type ChipProps = {
28
- /**
29
- * The content to display inside the chip.
30
- */
31
- children: ReactNode;
32
- /**
33
- * The visual variant of the chip.
34
- * @default 'solid'
35
- */
36
- variant?: ChipVariant;
37
- /**
38
- * The theme color of the chip.
39
- * @default 'default'
40
- */
41
- themeColor?: ThemeColor;
42
- /**
43
- * The size of the chip.
44
- * @default 'md'
45
- */
46
- size?: ChipSize;
47
- /**
48
- * The border radius of the chip.
49
- * @default 'full'
50
- */
51
- radius?: ChipRadius;
52
- /**
53
- * Avatar or image to display at the start.
54
- */
55
- avatar?: ReactNode;
56
- /**
57
- * Content to display at the start of the chip.
58
- */
59
- startContent?: ReactNode;
60
- /**
61
- * Content to display at the end of the chip.
62
- */
63
- endContent?: ReactNode;
64
- /**
65
- * Whether the chip is disabled.
66
- * @default false
67
- */
68
- isDisabled?: boolean;
69
- /**
70
- * Custom appearance styles for chip parts.
71
- */
72
- customAppearance?: ChipCustomAppearance;
73
- /**
74
- * Callback fired when the close button is pressed.
75
- * When provided, a close button is rendered.
76
- */
77
- onClose?: () => void;
78
- /**
79
- * Callback fired when the chip is pressed.
80
- */
81
- onPress?: () => void;
82
- };
83
- type ChipItemProps = {
84
- /**
85
- * Unique key for the chip item within a group.
86
- */
87
- value: string;
88
- /**
89
- * The content to display inside the chip item.
90
- */
91
- children: ReactNode;
92
- /**
93
- * The visual variant of the chip item.
94
- * Overrides the group variant if set.
95
- */
96
- variant?: ChipVariant;
97
- /**
98
- * The theme color of the chip item.
99
- * Overrides the group color if set.
100
- */
101
- themeColor?: ThemeColor;
102
- /**
103
- * Avatar or image to display at the start.
104
- */
105
- avatar?: ReactNode;
106
- /**
107
- * Content to display at the start of the chip.
108
- */
109
- startContent?: ReactNode;
110
- /**
111
- * Content to display at the end of the chip.
112
- */
113
- endContent?: ReactNode;
114
- /**
115
- * Whether the chip item is disabled.
116
- * @default false
117
- */
118
- isDisabled?: boolean;
119
- /**
120
- * Custom appearance styles for chip parts.
121
- */
122
- customAppearance?: ChipCustomAppearance;
123
- };
124
- type ChipGroupProps = {
125
- /**
126
- * ChipItem children.
127
- */
128
- children: ReactNode;
129
- /**
130
- * Whether chips in the group are selectable.
131
- * @default false
132
- */
133
- isSelectable?: boolean;
134
- /**
135
- * Selection mode when isSelectable is true.
136
- * @default 'single'
137
- */
138
- selectMode?: ChipSelectMode;
139
- /**
140
- * The visual variant applied to all chips.
141
- * @default 'solid'
142
- */
143
- variant?: ChipVariant;
144
- /**
145
- * The theme color applied to all chips.
146
- * @default 'default'
147
- */
148
- themeColor?: ThemeColor;
149
- /**
150
- * The size applied to all chips.
151
- * @default 'md'
152
- */
153
- size?: ChipSize;
154
- /**
155
- * The border radius applied to all chips.
156
- * @default 'full'
157
- */
158
- radius?: ChipRadius;
159
- /**
160
- * Whether all chips in the group are disabled.
161
- * @default false
162
- */
163
- isDisabled?: boolean;
164
- /**
165
- * Controlled selected values.
166
- */
167
- selectedValues?: string[];
168
- /**
169
- * Default selected values for uncontrolled mode.
170
- */
171
- defaultSelectedValues?: string[];
172
- /**
173
- * Callback fired when the selection changes.
174
- */
175
- onSelectionChange?: (values: string[]) => void;
176
- /**
177
- * Spacing between chips.
178
- * @default 8
179
- */
180
- spacing?: number;
181
- /**
182
- * Custom appearance styles for the group container.
183
- */
184
- customAppearance?: {
185
- container?: ViewStyle;
186
- };
187
- };
188
-
189
- declare const Chip: React.FC<ChipProps>;
190
-
191
- declare const ChipGroup: React.FC<ChipGroupProps>;
192
-
193
- declare const ChipItem: React.FC<ChipItemProps>;
194
-
195
- export { Chip, ChipGroup, type ChipGroupProps, ChipItem, type ChipItemProps, type ChipProps, type ChipRadius, type ChipSelectMode, type ChipSize, type ChipVariant };
@@ -1,503 +0,0 @@
1
- import "../chunk-SHBDANQN.js";
2
- import {
3
- useXUITheme
4
- } from "../chunk-RBSA4NH4.js";
5
-
6
- // src/components/chip/chip.tsx
7
- import React from "react";
8
- import { Animated, Easing, Pressable, View } from "react-native";
9
-
10
- // src/components/chip/chip.style.ts
11
- import { StyleSheet } from "react-native";
12
- var styles = StyleSheet.create({
13
- chip: {
14
- flexDirection: "row",
15
- alignItems: "center",
16
- alignSelf: "flex-start"
17
- },
18
- text: {
19
- fontWeight: "500",
20
- includeFontPadding: false,
21
- textAlignVertical: "center"
22
- },
23
- disabled: {
24
- opacity: 0.5
25
- },
26
- avatar: {
27
- marginRight: 4
28
- },
29
- startContent: {
30
- marginRight: 4
31
- },
32
- endContent: {
33
- marginLeft: 4
34
- },
35
- closeButton: {
36
- marginLeft: 4,
37
- alignItems: "center",
38
- justifyContent: "center"
39
- },
40
- dot: {
41
- borderRadius: 9999,
42
- marginRight: 6
43
- },
44
- groupContainer: {
45
- flexDirection: "row",
46
- flexWrap: "wrap"
47
- }
48
- });
49
-
50
- // src/components/chip/chip.hook.ts
51
- import { useMemo } from "react";
52
- import { getSafeThemeColor, withOpacity } from "@xaui/core";
53
- var sizeMap = {
54
- sm: { height: 32, paddingH: 12, fontSize: 13 },
55
- md: { height: 40, paddingH: 16, fontSize: 15 },
56
- lg: { height: 44, paddingH: 18, fontSize: 17 }
57
- };
58
- var dotSizeMap = {
59
- sm: 8,
60
- md: 10,
61
- lg: 11
62
- };
63
- var closeSizeMap = {
64
- sm: 14,
65
- md: 16,
66
- lg: 17
67
- };
68
- function useChipSizeStyles(size) {
69
- return useMemo(() => {
70
- const { height, paddingH, fontSize } = sizeMap[size];
71
- return { height, paddingHorizontal: paddingH, fontSize };
72
- }, [size]);
73
- }
74
- function useChipDotSize(size) {
75
- return useMemo(() => dotSizeMap[size], [size]);
76
- }
77
- function useChipCloseSize(size) {
78
- return useMemo(() => closeSizeMap[size], [size]);
79
- }
80
- function useChipRadiusStyles(radius, height) {
81
- const theme = useXUITheme();
82
- return useMemo(() => {
83
- if (radius === "full") {
84
- return { borderRadius: height / 2 };
85
- }
86
- return { borderRadius: theme.borderRadius[radius] };
87
- }, [height, radius, theme.borderRadius]);
88
- }
89
- function useChipVariantStyles(themeColor, variant) {
90
- const theme = useXUITheme();
91
- const safeColor = getSafeThemeColor(themeColor);
92
- const colorScheme = theme.colors[safeColor];
93
- return useMemo(() => {
94
- switch (variant) {
95
- case "bordered":
96
- return {
97
- backgroundColor: "transparent",
98
- color: colorScheme.main,
99
- borderWidth: 2,
100
- borderColor: colorScheme.main
101
- };
102
- case "light":
103
- return {
104
- backgroundColor: "transparent",
105
- color: colorScheme.main
106
- };
107
- case "flat":
108
- return {
109
- backgroundColor: colorScheme.container,
110
- color: colorScheme.onContainer
111
- };
112
- case "faded":
113
- return {
114
- backgroundColor: withOpacity(colorScheme.container, 0.7),
115
- color: colorScheme.onContainer,
116
- borderWidth: 1,
117
- borderColor: withOpacity(colorScheme.main, 0.3)
118
- };
119
- case "shadow":
120
- return {
121
- backgroundColor: colorScheme.main,
122
- color: colorScheme.onMain,
123
- shadow: theme.shadows.sm
124
- };
125
- case "dot":
126
- return {
127
- backgroundColor: colorScheme.container,
128
- color: colorScheme.onContainer,
129
- dotColor: colorScheme.main
130
- };
131
- case "solid":
132
- default:
133
- return {
134
- backgroundColor: colorScheme.main,
135
- color: colorScheme.onMain
136
- };
137
- }
138
- }, [colorScheme, theme, variant]);
139
- }
140
-
141
- // src/components/chip/chip.tsx
142
- var Chip = ({
143
- children,
144
- variant = "solid",
145
- themeColor = "default",
146
- size = "md",
147
- radius = "full",
148
- avatar,
149
- startContent,
150
- endContent,
151
- isDisabled = false,
152
- customAppearance,
153
- onClose,
154
- onPress
155
- }) => {
156
- const [isClosed, setIsClosed] = React.useState(false);
157
- const [isClosing, setIsClosing] = React.useState(false);
158
- const sizeStyles = useChipSizeStyles(size);
159
- const radiusStyles = useChipRadiusStyles(radius, sizeStyles.height);
160
- const variantStyles = useChipVariantStyles(themeColor, variant);
161
- const dotSize = useChipDotSize(size);
162
- const closeSize = useChipCloseSize(size);
163
- const isDotVariant = variant === "dot";
164
- const hasClose = onClose !== void 0;
165
- const isInteractive = onPress !== void 0 || hasClose;
166
- const scale = React.useRef(new Animated.Value(1)).current;
167
- const opacity = React.useRef(new Animated.Value(1)).current;
168
- const isClosingRef = React.useRef(false);
169
- const colorProgress = React.useRef(new Animated.Value(1)).current;
170
- const targetBackgroundColor = variantStyles.backgroundColor ?? "transparent";
171
- const targetBorderColor = variantStyles.borderColor ?? "transparent";
172
- const targetTextColor = variantStyles.color ?? "#000000";
173
- const targetDotColor = variantStyles.dotColor ?? targetTextColor;
174
- const previousColorsRef = React.useRef({
175
- backgroundColor: targetBackgroundColor,
176
- borderColor: targetBorderColor,
177
- textColor: targetTextColor,
178
- dotColor: targetDotColor
179
- });
180
- React.useEffect(() => {
181
- if (previousColorsRef.current.backgroundColor === targetBackgroundColor && previousColorsRef.current.borderColor === targetBorderColor && previousColorsRef.current.textColor === targetTextColor && previousColorsRef.current.dotColor === targetDotColor) {
182
- return;
183
- }
184
- colorProgress.setValue(0);
185
- Animated.timing(colorProgress, {
186
- toValue: 1,
187
- duration: 180,
188
- easing: Easing.out(Easing.cubic),
189
- useNativeDriver: false
190
- }).start(() => {
191
- previousColorsRef.current = {
192
- backgroundColor: targetBackgroundColor,
193
- borderColor: targetBorderColor,
194
- textColor: targetTextColor,
195
- dotColor: targetDotColor
196
- };
197
- });
198
- }, [
199
- colorProgress,
200
- targetBackgroundColor,
201
- targetBorderColor,
202
- targetTextColor,
203
- targetDotColor
204
- ]);
205
- const animatedBackgroundColor = colorProgress.interpolate({
206
- inputRange: [0, 1],
207
- outputRange: [previousColorsRef.current.backgroundColor, targetBackgroundColor]
208
- });
209
- const animatedBorderColor = colorProgress.interpolate({
210
- inputRange: [0, 1],
211
- outputRange: [previousColorsRef.current.borderColor, targetBorderColor]
212
- });
213
- const animatedTextColor = colorProgress.interpolate({
214
- inputRange: [0, 1],
215
- outputRange: [previousColorsRef.current.textColor, targetTextColor]
216
- });
217
- const animatedDotColor = colorProgress.interpolate({
218
- inputRange: [0, 1],
219
- outputRange: [previousColorsRef.current.dotColor, targetDotColor]
220
- });
221
- const handlePressIn = React.useCallback(() => {
222
- if (!isInteractive || isDisabled || isClosing || hasClose) return;
223
- Animated.timing(scale, {
224
- toValue: 0.97,
225
- duration: 90,
226
- easing: Easing.out(Easing.cubic),
227
- useNativeDriver: true
228
- }).start();
229
- }, [hasClose, isInteractive, isClosing, isDisabled, scale]);
230
- const handlePressOut = React.useCallback(() => {
231
- if (!isInteractive || isDisabled || isClosing || hasClose) return;
232
- Animated.timing(scale, {
233
- toValue: 1,
234
- duration: 120,
235
- easing: Easing.out(Easing.cubic),
236
- useNativeDriver: true
237
- }).start();
238
- }, [hasClose, isInteractive, isClosing, isDisabled, scale]);
239
- const handleChipPress = React.useCallback(() => {
240
- if (isDisabled || isClosing || isClosingRef.current) return;
241
- if (hasClose && onClose) {
242
- isClosingRef.current = true;
243
- setIsClosing(true);
244
- Animated.parallel([
245
- Animated.timing(opacity, {
246
- toValue: 0,
247
- duration: 180,
248
- easing: Easing.in(Easing.quad),
249
- useNativeDriver: true
250
- }),
251
- Animated.timing(scale, {
252
- toValue: 0.88,
253
- duration: 180,
254
- easing: Easing.in(Easing.quad),
255
- useNativeDriver: true
256
- })
257
- ]).start(() => {
258
- setIsClosed(true);
259
- onClose();
260
- setIsClosing(false);
261
- isClosingRef.current = false;
262
- });
263
- return;
264
- }
265
- onPress?.();
266
- }, [hasClose, isClosing, isDisabled, onClose, onPress, opacity, scale]);
267
- if (isClosed) {
268
- return null;
269
- }
270
- const chipContent = /* @__PURE__ */ React.createElement(Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ React.createElement(
271
- Animated.View,
272
- {
273
- style: [
274
- styles.chip,
275
- {
276
- height: sizeStyles.height,
277
- paddingHorizontal: sizeStyles.paddingHorizontal,
278
- backgroundColor: animatedBackgroundColor,
279
- borderWidth: variantStyles.borderWidth,
280
- borderColor: animatedBorderColor
281
- },
282
- radiusStyles,
283
- variantStyles.shadow,
284
- isDisabled && styles.disabled,
285
- customAppearance?.container
286
- ],
287
- accessible: true,
288
- accessibilityRole: "text"
289
- },
290
- isDotVariant && /* @__PURE__ */ React.createElement(
291
- Animated.View,
292
- {
293
- style: [
294
- styles.dot,
295
- {
296
- width: dotSize,
297
- height: dotSize,
298
- backgroundColor: animatedDotColor
299
- },
300
- customAppearance?.dot
301
- ]
302
- }
303
- ),
304
- avatar && /* @__PURE__ */ React.createElement(View, { style: styles.avatar }, avatar),
305
- startContent && !avatar && /* @__PURE__ */ React.createElement(View, { style: styles.startContent }, startContent),
306
- /* @__PURE__ */ React.createElement(
307
- Animated.Text,
308
- {
309
- style: [
310
- styles.text,
311
- { fontSize: sizeStyles.fontSize, color: animatedTextColor },
312
- customAppearance?.text
313
- ]
314
- },
315
- children
316
- ),
317
- endContent && !hasClose && /* @__PURE__ */ React.createElement(View, { style: styles.endContent }, endContent),
318
- hasClose && /* @__PURE__ */ React.createElement(
319
- View,
320
- {
321
- style: [
322
- styles.closeButton,
323
- { width: closeSize, height: closeSize },
324
- customAppearance?.closeButton
325
- ]
326
- },
327
- /* @__PURE__ */ React.createElement(
328
- Animated.Text,
329
- {
330
- style: {
331
- fontSize: closeSize - 2,
332
- color: animatedTextColor,
333
- lineHeight: closeSize
334
- }
335
- },
336
- "\u2715"
337
- )
338
- )
339
- ));
340
- if (isInteractive) {
341
- return /* @__PURE__ */ React.createElement(
342
- Pressable,
343
- {
344
- onPress: isDisabled || isClosing ? void 0 : handleChipPress,
345
- onPressIn: handlePressIn,
346
- onPressOut: handlePressOut,
347
- disabled: isDisabled || isClosing
348
- },
349
- chipContent
350
- );
351
- }
352
- return chipContent;
353
- };
354
-
355
- // src/components/chip/chip-group.tsx
356
- import React2 from "react";
357
- import { View as View2 } from "react-native";
358
-
359
- // src/components/chip/chip-context.ts
360
- import { createContext } from "react";
361
- var ChipGroupContext = createContext(null);
362
-
363
- // src/components/chip/chip-group.hook.ts
364
- import { useCallback, useMemo as useMemo2, useState } from "react";
365
- function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues, onSelectionChange) {
366
- const [internalValues, setInternalValues] = useState(
367
- defaultSelectedValues ?? []
368
- );
369
- const isControlled = selectedValues !== void 0;
370
- const currentValues = isControlled ? selectedValues : internalValues;
371
- const onToggle = useCallback(
372
- (value) => {
373
- const isSelected = currentValues.includes(value);
374
- let nextValues;
375
- if (selectMode === "single") {
376
- nextValues = isSelected ? [] : [value];
377
- } else {
378
- nextValues = isSelected ? currentValues.filter((v) => v !== value) : [...currentValues, value];
379
- }
380
- if (!isControlled) {
381
- setInternalValues(nextValues);
382
- }
383
- onSelectionChange?.(nextValues);
384
- },
385
- [currentValues, isControlled, onSelectionChange, selectMode]
386
- );
387
- return useMemo2(() => ({ currentValues, onToggle }), [currentValues, onToggle]);
388
- }
389
-
390
- // src/components/chip/chip-group.tsx
391
- var ChipGroup = ({
392
- children,
393
- isSelectable = false,
394
- selectMode = "single",
395
- variant = "solid",
396
- themeColor = "default",
397
- size = "md",
398
- radius = "full",
399
- isDisabled = false,
400
- selectedValues,
401
- defaultSelectedValues,
402
- onSelectionChange,
403
- spacing = 8,
404
- customAppearance
405
- }) => {
406
- const { currentValues, onToggle } = useChipGroupSelection(
407
- selectMode,
408
- selectedValues,
409
- defaultSelectedValues,
410
- onSelectionChange
411
- );
412
- const contextValue = React2.useMemo(
413
- () => ({
414
- variant,
415
- themeColor,
416
- size,
417
- radius,
418
- isDisabled,
419
- isSelectable,
420
- selectMode,
421
- selectedValues: currentValues,
422
- onToggle
423
- }),
424
- [
425
- variant,
426
- themeColor,
427
- size,
428
- radius,
429
- isDisabled,
430
- isSelectable,
431
- selectMode,
432
- currentValues,
433
- onToggle
434
- ]
435
- );
436
- return /* @__PURE__ */ React2.createElement(ChipGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ React2.createElement(
437
- View2,
438
- {
439
- style: [
440
- styles.groupContainer,
441
- { gap: spacing },
442
- customAppearance?.container
443
- ],
444
- accessible: true
445
- },
446
- children
447
- ));
448
- };
449
-
450
- // src/components/chip/chip-item.tsx
451
- import React3, { useContext } from "react";
452
- function getSelectableVariant(baseVariant, isSelected) {
453
- if (isSelected) {
454
- return baseVariant;
455
- }
456
- if (baseVariant === "solid" || baseVariant === "shadow") {
457
- return "bordered";
458
- }
459
- return "light";
460
- }
461
- var ChipItem = ({
462
- value,
463
- children,
464
- variant,
465
- themeColor,
466
- avatar,
467
- startContent,
468
- endContent,
469
- isDisabled,
470
- customAppearance
471
- }) => {
472
- const groupContext = useContext(ChipGroupContext);
473
- if (!groupContext) {
474
- return null;
475
- }
476
- const resolvedVariant = variant ?? groupContext.variant;
477
- const resolvedColor = themeColor ?? groupContext.themeColor;
478
- const resolvedDisabled = isDisabled ?? groupContext.isDisabled;
479
- const isSelected = groupContext.selectedValues.includes(value);
480
- const chipVariant = groupContext.isSelectable ? getSelectableVariant(resolvedVariant, isSelected) : resolvedVariant;
481
- const handlePress = groupContext.isSelectable ? () => groupContext.onToggle(value) : void 0;
482
- return /* @__PURE__ */ React3.createElement(
483
- Chip,
484
- {
485
- variant: chipVariant,
486
- themeColor: resolvedColor,
487
- size: groupContext.size,
488
- radius: groupContext.radius,
489
- isDisabled: resolvedDisabled,
490
- avatar,
491
- startContent,
492
- endContent,
493
- customAppearance,
494
- onPress: handlePress
495
- },
496
- children
497
- );
498
- };
499
- export {
500
- Chip,
501
- ChipGroup,
502
- ChipItem
503
- };