@xaui/native 0.2.8 → 0.9.1-alpha.1

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 (234) hide show
  1. package/dist/chunk-KFCORXWW.cjs +150 -0
  2. package/dist/chunk-M7P46XKI.cjs +100 -0
  3. package/dist/chunk-N357EQCZ.js +150 -0
  4. package/dist/chunk-NHPQQQ7P.cjs +734 -0
  5. package/dist/chunk-PBVPOX7D.js +734 -0
  6. package/dist/chunk-RBNCR5KB.js +100 -0
  7. package/dist/index.cjs +40 -1
  8. package/dist/index.d.cts +5 -2
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.js +40 -0
  11. package/dist/system/index.cjs +7 -0
  12. package/dist/system/index.d.cts +83 -0
  13. package/dist/system/index.d.ts +83 -0
  14. package/dist/system/index.js +7 -0
  15. package/dist/theme/index.cjs +36 -0
  16. package/dist/theme/index.d.cts +539 -0
  17. package/dist/theme/index.d.ts +539 -0
  18. package/dist/theme/index.js +36 -0
  19. package/dist/theme.type-B3ODSLbB.d.cts +153 -0
  20. package/dist/theme.type-B3ODSLbB.d.ts +153 -0
  21. package/package.json +30 -248
  22. package/README.md +0 -178
  23. package/dist/alert/index.cjs +0 -340
  24. package/dist/alert/index.d.cts +0 -46
  25. package/dist/alert/index.d.ts +0 -46
  26. package/dist/alert/index.js +0 -340
  27. package/dist/app-bar/index.cjs +0 -148
  28. package/dist/app-bar/index.d.cts +0 -59
  29. package/dist/app-bar/index.d.ts +0 -59
  30. package/dist/app-bar/index.js +0 -148
  31. package/dist/autocomplete/index.cjs +0 -1122
  32. package/dist/autocomplete/index.d.cts +0 -88
  33. package/dist/autocomplete/index.d.ts +0 -88
  34. package/dist/autocomplete/index.js +0 -1122
  35. package/dist/avatar/index.cjs +0 -281
  36. package/dist/avatar/index.d.cts +0 -123
  37. package/dist/avatar/index.d.ts +0 -123
  38. package/dist/avatar/index.js +0 -281
  39. package/dist/badge/index.cjs +0 -197
  40. package/dist/badge/index.d.cts +0 -94
  41. package/dist/badge/index.d.ts +0 -94
  42. package/dist/badge/index.js +0 -197
  43. package/dist/bottom-sheet/index.cjs +0 -9
  44. package/dist/bottom-sheet/index.d.cts +0 -84
  45. package/dist/bottom-sheet/index.d.ts +0 -84
  46. package/dist/bottom-sheet/index.js +0 -9
  47. package/dist/bottom-tab-bar/index.cjs +0 -497
  48. package/dist/bottom-tab-bar/index.d.cts +0 -211
  49. package/dist/bottom-tab-bar/index.d.ts +0 -211
  50. package/dist/bottom-tab-bar/index.js +0 -497
  51. package/dist/button/index.cjs +0 -392
  52. package/dist/button/index.d.cts +0 -174
  53. package/dist/button/index.d.ts +0 -174
  54. package/dist/button/index.js +0 -392
  55. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  56. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  57. package/dist/card/index.cjs +0 -338
  58. package/dist/card/index.d.cts +0 -191
  59. package/dist/card/index.d.ts +0 -191
  60. package/dist/card/index.js +0 -338
  61. package/dist/carousel/index.cjs +0 -381
  62. package/dist/carousel/index.d.cts +0 -147
  63. package/dist/carousel/index.d.ts +0 -147
  64. package/dist/carousel/index.js +0 -381
  65. package/dist/chart/index.cjs +0 -1026
  66. package/dist/chart/index.d.cts +0 -218
  67. package/dist/chart/index.d.ts +0 -218
  68. package/dist/chart/index.js +0 -1026
  69. package/dist/checkbox/index.cjs +0 -443
  70. package/dist/checkbox/index.d.cts +0 -73
  71. package/dist/checkbox/index.d.ts +0 -73
  72. package/dist/checkbox/index.js +0 -443
  73. package/dist/chip/index.cjs +0 -503
  74. package/dist/chip/index.d.cts +0 -195
  75. package/dist/chip/index.d.ts +0 -195
  76. package/dist/chip/index.js +0 -503
  77. package/dist/chunk-4JFWQ5XT.js +0 -368
  78. package/dist/chunk-56RPWZD2.cjs +0 -9
  79. package/dist/chunk-7UFBLUMV.cjs +0 -136
  80. package/dist/chunk-A45TVXU5.js +0 -337
  81. package/dist/chunk-BYWUAPC4.cjs +0 -368
  82. package/dist/chunk-DECMUMCI.js +0 -0
  83. package/dist/chunk-DHSTKO3K.cjs +0 -19
  84. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  85. package/dist/chunk-EUQDGTST.cjs +0 -1
  86. package/dist/chunk-GBHQCAKW.js +0 -19
  87. package/dist/chunk-RBSA4NH4.js +0 -136
  88. package/dist/chunk-SHBDANQN.js +0 -9
  89. package/dist/chunk-UGEINZM7.cjs +0 -290
  90. package/dist/chunk-UU4HHBDN.js +0 -290
  91. package/dist/chunk-VSZEXOUN.js +0 -384
  92. package/dist/chunk-YIEUN3G5.cjs +0 -384
  93. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  94. package/dist/chunk-ZY7IUTAT.js +0 -75
  95. package/dist/color-picker/index.cjs +0 -457
  96. package/dist/color-picker/index.d.cts +0 -124
  97. package/dist/color-picker/index.d.ts +0 -124
  98. package/dist/color-picker/index.js +0 -457
  99. package/dist/core/index.cjs +0 -24
  100. package/dist/core/index.d.cts +0 -28
  101. package/dist/core/index.d.ts +0 -28
  102. package/dist/core/index.js +0 -24
  103. package/dist/datepicker/index.cjs +0 -1625
  104. package/dist/datepicker/index.d.cts +0 -45
  105. package/dist/datepicker/index.d.ts +0 -45
  106. package/dist/datepicker/index.js +0 -1625
  107. package/dist/dialog/index.cjs +0 -372
  108. package/dist/dialog/index.d.cts +0 -151
  109. package/dist/dialog/index.d.ts +0 -151
  110. package/dist/dialog/index.js +0 -372
  111. package/dist/divider/index.cjs +0 -8
  112. package/dist/divider/index.d.cts +0 -30
  113. package/dist/divider/index.d.ts +0 -30
  114. package/dist/divider/index.js +0 -8
  115. package/dist/drawer/index.cjs +0 -237
  116. package/dist/drawer/index.d.cts +0 -58
  117. package/dist/drawer/index.d.ts +0 -58
  118. package/dist/drawer/index.js +0 -237
  119. package/dist/expansion-panel/index.cjs +0 -441
  120. package/dist/expansion-panel/index.d.cts +0 -153
  121. package/dist/expansion-panel/index.d.ts +0 -153
  122. package/dist/expansion-panel/index.js +0 -441
  123. package/dist/fab/index.cjs +0 -9
  124. package/dist/fab/index.d.cts +0 -10
  125. package/dist/fab/index.d.ts +0 -10
  126. package/dist/fab/index.js +0 -9
  127. package/dist/fab-menu/index.cjs +0 -330
  128. package/dist/fab-menu/index.d.cts +0 -125
  129. package/dist/fab-menu/index.d.ts +0 -125
  130. package/dist/fab-menu/index.js +0 -330
  131. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  132. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  133. package/dist/feature-discovery/index.cjs +0 -464
  134. package/dist/feature-discovery/index.d.cts +0 -82
  135. package/dist/feature-discovery/index.d.ts +0 -82
  136. package/dist/feature-discovery/index.js +0 -464
  137. package/dist/indicator/index.cjs +0 -8
  138. package/dist/indicator/index.d.cts +0 -47
  139. package/dist/indicator/index.d.ts +0 -47
  140. package/dist/indicator/index.js +0 -8
  141. package/dist/input/index.cjs +0 -1462
  142. package/dist/input/index.d.cts +0 -522
  143. package/dist/input/index.d.ts +0 -522
  144. package/dist/input/index.js +0 -1462
  145. package/dist/input-trigger/index.cjs +0 -197
  146. package/dist/input-trigger/index.d.cts +0 -11
  147. package/dist/input-trigger/index.d.ts +0 -11
  148. package/dist/input-trigger/index.js +0 -197
  149. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  150. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  151. package/dist/list/index.cjs +0 -395
  152. package/dist/list/index.d.cts +0 -188
  153. package/dist/list/index.d.ts +0 -188
  154. package/dist/list/index.js +0 -395
  155. package/dist/menu/index.cjs +0 -316
  156. package/dist/menu/index.d.cts +0 -115
  157. package/dist/menu/index.d.ts +0 -115
  158. package/dist/menu/index.js +0 -316
  159. package/dist/menubox/index.cjs +0 -297
  160. package/dist/menubox/index.d.cts +0 -98
  161. package/dist/menubox/index.d.ts +0 -98
  162. package/dist/menubox/index.js +0 -297
  163. package/dist/pager/index.cjs +0 -205
  164. package/dist/pager/index.d.cts +0 -93
  165. package/dist/pager/index.d.ts +0 -93
  166. package/dist/pager/index.js +0 -205
  167. package/dist/picker/index.cjs +0 -244
  168. package/dist/picker/index.d.cts +0 -121
  169. package/dist/picker/index.d.ts +0 -121
  170. package/dist/picker/index.js +0 -244
  171. package/dist/progress/index.cjs +0 -219
  172. package/dist/progress/index.d.cts +0 -47
  173. package/dist/progress/index.d.ts +0 -47
  174. package/dist/progress/index.js +0 -219
  175. package/dist/radio/index.cjs +0 -465
  176. package/dist/radio/index.d.cts +0 -145
  177. package/dist/radio/index.d.ts +0 -145
  178. package/dist/radio/index.js +0 -465
  179. package/dist/refresh-control/index.cjs +0 -45
  180. package/dist/refresh-control/index.d.cts +0 -55
  181. package/dist/refresh-control/index.d.ts +0 -55
  182. package/dist/refresh-control/index.js +0 -45
  183. package/dist/segment-button/index.cjs +0 -405
  184. package/dist/segment-button/index.d.cts +0 -141
  185. package/dist/segment-button/index.d.ts +0 -141
  186. package/dist/segment-button/index.js +0 -405
  187. package/dist/select/index.cjs +0 -878
  188. package/dist/select/index.d.cts +0 -192
  189. package/dist/select/index.d.ts +0 -192
  190. package/dist/select/index.js +0 -878
  191. package/dist/skeleton/index.cjs +0 -89
  192. package/dist/skeleton/index.d.cts +0 -45
  193. package/dist/skeleton/index.d.ts +0 -45
  194. package/dist/skeleton/index.js +0 -89
  195. package/dist/slider/index.cjs +0 -576
  196. package/dist/slider/index.d.cts +0 -171
  197. package/dist/slider/index.d.ts +0 -171
  198. package/dist/slider/index.js +0 -576
  199. package/dist/snackbar/index.cjs +0 -436
  200. package/dist/snackbar/index.d.cts +0 -174
  201. package/dist/snackbar/index.d.ts +0 -174
  202. package/dist/snackbar/index.js +0 -436
  203. package/dist/snippet/index.cjs +0 -314
  204. package/dist/snippet/index.d.cts +0 -95
  205. package/dist/snippet/index.d.ts +0 -95
  206. package/dist/snippet/index.js +0 -314
  207. package/dist/stepper/index.cjs +0 -550
  208. package/dist/stepper/index.d.cts +0 -137
  209. package/dist/stepper/index.d.ts +0 -137
  210. package/dist/stepper/index.js +0 -550
  211. package/dist/switch/index.cjs +0 -358
  212. package/dist/switch/index.d.cts +0 -28
  213. package/dist/switch/index.d.ts +0 -28
  214. package/dist/switch/index.js +0 -358
  215. package/dist/tabs/index.cjs +0 -440
  216. package/dist/tabs/index.d.cts +0 -180
  217. package/dist/tabs/index.d.ts +0 -180
  218. package/dist/tabs/index.js +0 -440
  219. package/dist/timepicker/index.cjs +0 -823
  220. package/dist/timepicker/index.d.cts +0 -215
  221. package/dist/timepicker/index.d.ts +0 -215
  222. package/dist/timepicker/index.js +0 -823
  223. package/dist/toolbar/index.cjs +0 -333
  224. package/dist/toolbar/index.d.cts +0 -100
  225. package/dist/toolbar/index.d.ts +0 -100
  226. package/dist/toolbar/index.js +0 -333
  227. package/dist/typography/index.cjs +0 -238
  228. package/dist/typography/index.d.cts +0 -113
  229. package/dist/typography/index.d.ts +0 -113
  230. package/dist/typography/index.js +0 -238
  231. package/dist/view/index.cjs +0 -1361
  232. package/dist/view/index.d.cts +0 -833
  233. package/dist/view/index.d.ts +0 -833
  234. 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
- };