@xaui/native 0.2.8 → 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 -340
  14. package/dist/alert/index.d.cts +0 -46
  15. package/dist/alert/index.d.ts +0 -46
  16. package/dist/alert/index.js +0 -340
  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,1361 +0,0 @@
1
- import "../chunk-SHBDANQN.js";
2
- import {
3
- useBorderRadiusStyles,
4
- useXUITheme
5
- } from "../chunk-RBSA4NH4.js";
6
-
7
- // src/components/view/container/container.tsx
8
- import React from "react";
9
- import { View, Pressable } from "react-native";
10
-
11
- // src/components/view/container/container.utils.ts
12
- var resolveEdgeInsets = (value, prefix) => {
13
- if (typeof value === "number") {
14
- return prefix === "padding" ? { padding: value } : { margin: value };
15
- }
16
- const style = {};
17
- if (prefix === "padding") {
18
- if (value.horizontal !== void 0) style.paddingHorizontal = value.horizontal;
19
- if (value.vertical !== void 0) style.paddingVertical = value.vertical;
20
- if (value.top !== void 0) style.paddingTop = value.top;
21
- if (value.bottom !== void 0) style.paddingBottom = value.bottom;
22
- if (value.left !== void 0) style.paddingLeft = value.left;
23
- if (value.right !== void 0) style.paddingRight = value.right;
24
- } else {
25
- if (value.horizontal !== void 0) style.marginHorizontal = value.horizontal;
26
- if (value.vertical !== void 0) style.marginVertical = value.vertical;
27
- if (value.top !== void 0) style.marginTop = value.top;
28
- if (value.bottom !== void 0) style.marginBottom = value.bottom;
29
- if (value.left !== void 0) style.marginLeft = value.left;
30
- if (value.right !== void 0) style.marginRight = value.right;
31
- }
32
- return style;
33
- };
34
- var ALIGNMENT_MAP = {
35
- topLeft: { justifyContent: "flex-start", alignItems: "flex-start" },
36
- topCenter: { justifyContent: "flex-start", alignItems: "center" },
37
- topRight: { justifyContent: "flex-start", alignItems: "flex-end" },
38
- centerLeft: { justifyContent: "center", alignItems: "flex-start" },
39
- center: { justifyContent: "center", alignItems: "center" },
40
- centerRight: { justifyContent: "center", alignItems: "flex-end" },
41
- bottomLeft: { justifyContent: "flex-end", alignItems: "flex-start" },
42
- bottomCenter: { justifyContent: "flex-end", alignItems: "center" },
43
- bottomRight: { justifyContent: "flex-end", alignItems: "flex-end" }
44
- };
45
- var toFlexPosition = (v) => {
46
- if (v <= 0) return "flex-start";
47
- if (v >= 1) return "flex-end";
48
- return "center";
49
- };
50
- var resolveAlignment = (value) => {
51
- if (typeof value === "object") {
52
- return {
53
- justifyContent: toFlexPosition(value.y),
54
- alignItems: toFlexPosition(value.x)
55
- };
56
- }
57
- return ALIGNMENT_MAP[value] ?? {
58
- justifyContent: "flex-start",
59
- alignItems: "flex-start"
60
- };
61
- };
62
- var resolveBorderRadius = (value) => {
63
- if (typeof value === "number") {
64
- return { borderRadius: value };
65
- }
66
- const style = {};
67
- if (value.topLeft !== void 0) style.borderTopLeftRadius = value.topLeft;
68
- if (value.topRight !== void 0) style.borderTopRightRadius = value.topRight;
69
- if (value.bottomLeft !== void 0) style.borderBottomLeftRadius = value.bottomLeft;
70
- if (value.bottomRight !== void 0)
71
- style.borderBottomRightRadius = value.bottomRight;
72
- return style;
73
- };
74
- var resolveBorderSide = (side, position) => {
75
- const style = {};
76
- if (position === "") {
77
- if (side.width !== void 0) style.borderWidth = side.width;
78
- if (side.color !== void 0) style.borderColor = side.color;
79
- if (side.style !== void 0) style.borderStyle = side.style;
80
- return style;
81
- }
82
- if (position === "Top") {
83
- if (side.width !== void 0) style.borderTopWidth = side.width;
84
- if (side.color !== void 0) style.borderTopColor = side.color;
85
- } else if (position === "Bottom") {
86
- if (side.width !== void 0) style.borderBottomWidth = side.width;
87
- if (side.color !== void 0) style.borderBottomColor = side.color;
88
- } else if (position === "Left") {
89
- if (side.width !== void 0) style.borderLeftWidth = side.width;
90
- if (side.color !== void 0) style.borderLeftColor = side.color;
91
- } else {
92
- if (side.width !== void 0) style.borderRightWidth = side.width;
93
- if (side.color !== void 0) style.borderRightColor = side.color;
94
- }
95
- return style;
96
- };
97
- var resolveBorder = (value) => {
98
- const dir = value;
99
- if (dir.top !== void 0 || dir.bottom !== void 0 || dir.left !== void 0 || dir.right !== void 0) {
100
- return {
101
- ...dir.top ? resolveBorderSide(dir.top, "Top") : {},
102
- ...dir.bottom ? resolveBorderSide(dir.bottom, "Bottom") : {},
103
- ...dir.left ? resolveBorderSide(dir.left, "Left") : {},
104
- ...dir.right ? resolveBorderSide(dir.right, "Right") : {}
105
- };
106
- }
107
- return resolveBorderSide(value, "");
108
- };
109
- var resolveShadow = (value) => ({
110
- shadowColor: value.color ?? "#000000",
111
- shadowOffset: {
112
- width: value.offset?.x ?? 0,
113
- height: value.offset?.y ?? 4
114
- },
115
- shadowOpacity: value.opacity ?? 0.1,
116
- shadowRadius: value.blur ?? 4,
117
- elevation: value.elevation ?? 2
118
- });
119
- var resolveTransform = (value) => {
120
- const transforms = [];
121
- if (value.rotate !== void 0) transforms.push({ rotate: value.rotate });
122
- if (value.rotateX !== void 0) transforms.push({ rotateX: value.rotateX });
123
- if (value.rotateY !== void 0) transforms.push({ rotateY: value.rotateY });
124
- if (value.scale !== void 0) transforms.push({ scale: value.scale });
125
- if (value.scaleX !== void 0) transforms.push({ scaleX: value.scaleX });
126
- if (value.scaleY !== void 0) transforms.push({ scaleY: value.scaleY });
127
- if (value.translateX !== void 0)
128
- transforms.push({ translateX: value.translateX });
129
- if (value.translateY !== void 0)
130
- transforms.push({ translateY: value.translateY });
131
- if (value.skewX !== void 0) transforms.push({ skewX: value.skewX });
132
- if (value.skewY !== void 0) transforms.push({ skewY: value.skewY });
133
- return transforms;
134
- };
135
-
136
- // src/components/view/container/container.tsx
137
- var buildStyle = (props) => ({
138
- ...props.width !== void 0 && { width: props.width },
139
- ...props.height !== void 0 && { height: props.height },
140
- ...props.minWidth !== void 0 && { minWidth: props.minWidth },
141
- ...props.maxWidth !== void 0 && { maxWidth: props.maxWidth },
142
- ...props.minHeight !== void 0 && { minHeight: props.minHeight },
143
- ...props.maxHeight !== void 0 && { maxHeight: props.maxHeight },
144
- ...props.aspectRatio !== void 0 && { aspectRatio: props.aspectRatio },
145
- ...props.flex !== void 0 && { flex: props.flex },
146
- ...props.color !== void 0 && { backgroundColor: props.color },
147
- ...props.clip && { overflow: "hidden" },
148
- ...props.opacity !== void 0 && { opacity: props.opacity },
149
- ...props.padding !== void 0 && resolveEdgeInsets(props.padding, "padding"),
150
- ...props.margin !== void 0 && resolveEdgeInsets(props.margin, "margin"),
151
- ...props.alignment !== void 0 && resolveAlignment(props.alignment),
152
- ...props.borderRadius !== void 0 && resolveBorderRadius(props.borderRadius),
153
- ...props.border !== void 0 && resolveBorder(props.border),
154
- ...props.shadow !== void 0 && resolveShadow(props.shadow),
155
- ...props.transform !== void 0 && {
156
- transform: resolveTransform(props.transform)
157
- }
158
- });
159
- var Container = (props) => {
160
- const {
161
- children,
162
- onPress,
163
- onLongPress,
164
- onPressIn,
165
- onPressOut,
166
- disabled = false,
167
- accessibilityLabel,
168
- accessibilityRole,
169
- accessibilityState,
170
- accessible,
171
- testID,
172
- style
173
- } = props;
174
- const containerStyle = buildStyle(props);
175
- const isInteractive = !!(onPress ?? onLongPress ?? onPressIn ?? onPressOut);
176
- if (isInteractive) {
177
- return /* @__PURE__ */ React.createElement(
178
- Pressable,
179
- {
180
- onPress: disabled ? void 0 : onPress,
181
- onLongPress: disabled ? void 0 : onLongPress,
182
- onPressIn: disabled ? void 0 : onPressIn,
183
- onPressOut: disabled ? void 0 : onPressOut,
184
- disabled,
185
- accessibilityLabel,
186
- accessibilityRole,
187
- accessibilityState,
188
- accessible,
189
- testID,
190
- style: [containerStyle, style]
191
- },
192
- children
193
- );
194
- }
195
- return /* @__PURE__ */ React.createElement(
196
- View,
197
- {
198
- accessibilityLabel,
199
- accessibilityRole,
200
- accessibilityState,
201
- accessible,
202
- testID,
203
- style: [containerStyle, style]
204
- },
205
- children
206
- );
207
- };
208
- Container.displayName = "Container";
209
-
210
- // src/components/view/flex/flex.tsx
211
- import React2 from "react";
212
- import { View as View2 } from "react-native";
213
-
214
- // src/components/view/layout-utils.ts
215
- var MAIN_AXIS_JUSTIFY_MAP = {
216
- start: "flex-start",
217
- center: "center",
218
- end: "flex-end",
219
- spaceBetween: "space-between",
220
- spaceAround: "space-around",
221
- spaceEvenly: "space-evenly"
222
- };
223
- var CROSS_AXIS_ALIGN_MAP = {
224
- start: "flex-start",
225
- center: "center",
226
- end: "flex-end",
227
- stretch: "stretch"
228
- };
229
- var resolveMainAxisAlignment = (alignment) => MAIN_AXIS_JUSTIFY_MAP[alignment ?? "start"];
230
- var resolveCrossAxisAlignment = (alignment) => CROSS_AXIS_ALIGN_MAP[alignment ?? "center"];
231
- var resolveMainAxisSize = (size = "max", direction) => {
232
- if (size === "min") return {};
233
- return direction === "vertical" ? { flex: 1 } : { width: "100%" };
234
- };
235
-
236
- // src/components/view/flex/flex.tsx
237
- var Flex = ({
238
- children,
239
- direction,
240
- mainAxisAlignment,
241
- crossAxisAlignment,
242
- mainAxisSize,
243
- wrap = false,
244
- gap,
245
- reversed = false,
246
- flex,
247
- style,
248
- testID
249
- }) => {
250
- const flexDir = direction === "horizontal" ? reversed ? "row-reverse" : "row" : reversed ? "column-reverse" : "column";
251
- return /* @__PURE__ */ React2.createElement(
252
- View2,
253
- {
254
- testID,
255
- style: [
256
- resolveMainAxisSize(mainAxisSize, direction),
257
- {
258
- flexDirection: flexDir,
259
- justifyContent: resolveMainAxisAlignment(mainAxisAlignment),
260
- alignItems: resolveCrossAxisAlignment(crossAxisAlignment),
261
- flexWrap: wrap ? "wrap" : "nowrap",
262
- ...gap !== void 0 && { gap },
263
- ...flex !== void 0 && { flex }
264
- },
265
- style
266
- ]
267
- },
268
- children
269
- );
270
- };
271
- Flex.displayName = "Flex";
272
-
273
- // src/components/view/column/column.tsx
274
- import React3 from "react";
275
- var Column = (props) => /* @__PURE__ */ React3.createElement(Flex, { ...props, direction: "vertical" });
276
- Column.displayName = "Column";
277
-
278
- // src/components/view/row/row.tsx
279
- import React4 from "react";
280
- var Row = (props) => /* @__PURE__ */ React4.createElement(Flex, { ...props, direction: "horizontal" });
281
- Row.displayName = "Row";
282
-
283
- // src/components/view/expanded/expanded.tsx
284
- import React5 from "react";
285
- import { View as View3 } from "react-native";
286
- var Expanded = ({
287
- children,
288
- flex = 1,
289
- style,
290
- testID
291
- }) => /* @__PURE__ */ React5.createElement(View3, { testID, style: [{ flex }, style] }, children);
292
- Expanded.displayName = "Expanded";
293
-
294
- // src/components/view/flexible/flexible.tsx
295
- import React6 from "react";
296
- import { View as View4 } from "react-native";
297
- var Flexible = ({
298
- children,
299
- flex = 1,
300
- fit = "loose",
301
- style,
302
- testID
303
- }) => /* @__PURE__ */ React6.createElement(
304
- View4,
305
- {
306
- testID,
307
- style: [
308
- fit === "tight" ? { flex } : { flexGrow: flex, flexShrink: 1, flexBasis: "auto" },
309
- style
310
- ]
311
- },
312
- children
313
- );
314
- Flexible.displayName = "Flexible";
315
-
316
- // src/components/view/spacer/spacer.tsx
317
- import React7 from "react";
318
- import { View as View5 } from "react-native";
319
- var Spacer = ({ flex = 1, style }) => {
320
- return /* @__PURE__ */ React7.createElement(
321
- View5,
322
- {
323
- style: [
324
- {
325
- flexGrow: flex,
326
- flexShrink: 1,
327
- flexBasis: 0
328
- },
329
- style
330
- ]
331
- }
332
- );
333
- };
334
- Spacer.displayName = "Spacer";
335
-
336
- // src/components/view/wrap/wrap.tsx
337
- import React8 from "react";
338
- import { View as View6 } from "react-native";
339
- var Wrap = ({
340
- children,
341
- direction = "horizontal",
342
- alignment,
343
- runAlignment,
344
- spacing = 0,
345
- runSpacing = 0,
346
- style,
347
- testID
348
- }) => /* @__PURE__ */ React8.createElement(
349
- View6,
350
- {
351
- testID,
352
- style: [
353
- {
354
- flexDirection: direction === "horizontal" ? "row" : "column",
355
- flexWrap: "wrap",
356
- justifyContent: resolveMainAxisAlignment(alignment),
357
- alignContent: resolveMainAxisAlignment(runAlignment),
358
- gap: spacing,
359
- rowGap: direction === "horizontal" ? runSpacing : spacing,
360
- columnGap: direction === "horizontal" ? spacing : runSpacing
361
- },
362
- style
363
- ]
364
- },
365
- children
366
- );
367
- Wrap.displayName = "Wrap";
368
-
369
- // src/components/view/padding/padding.tsx
370
- import React9 from "react";
371
- import { View as View7 } from "react-native";
372
- var Padding = ({ children, padding, style }) => /* @__PURE__ */ React9.createElement(View7, { style: [resolveEdgeInsets(padding, "padding"), style] }, children);
373
- Padding.displayName = "Padding";
374
-
375
- // src/components/view/margin/margin.tsx
376
- import React10 from "react";
377
- import { View as View8 } from "react-native";
378
- var Margin = ({ children, margin, style }) => /* @__PURE__ */ React10.createElement(View8, { style: [resolveEdgeInsets(margin, "margin"), style] }, children);
379
- Margin.displayName = "Margin";
380
-
381
- // src/components/view/sized-box/sized-box.tsx
382
- import React11 from "react";
383
- import { View as View9 } from "react-native";
384
- var SizedBox = ({
385
- children,
386
- width,
387
- height,
388
- expand,
389
- shrink,
390
- style,
391
- testID
392
- }) => {
393
- if (shrink) {
394
- return /* @__PURE__ */ React11.createElement(
395
- View9,
396
- {
397
- testID,
398
- style: [{ width: 0, height: 0, overflow: "hidden" }, style]
399
- },
400
- children
401
- );
402
- }
403
- if (expand) {
404
- return /* @__PURE__ */ React11.createElement(View9, { testID, style: [{ flex: 1, alignSelf: "stretch" }, style] }, children);
405
- }
406
- return /* @__PURE__ */ React11.createElement(View9, { testID, style: [{ width, height }, style] }, children);
407
- };
408
- SizedBox.displayName = "SizedBox";
409
-
410
- // src/components/view/constrained-box/constrained-box.tsx
411
- import React12 from "react";
412
- import { View as View10 } from "react-native";
413
- var ConstrainedBox = ({
414
- children,
415
- constraints,
416
- style,
417
- testID
418
- }) => /* @__PURE__ */ React12.createElement(
419
- View10,
420
- {
421
- testID,
422
- style: [
423
- {
424
- minWidth: constraints.minWidth,
425
- maxWidth: constraints.maxWidth,
426
- minHeight: constraints.minHeight,
427
- maxHeight: constraints.maxHeight
428
- },
429
- style
430
- ]
431
- },
432
- children
433
- );
434
- ConstrainedBox.displayName = "ConstrainedBox";
435
-
436
- // src/components/view/fractionally-sized-box/fractionally-sized-box.tsx
437
- import React13 from "react";
438
- import { View as View11 } from "react-native";
439
- var FractionallySizedBox = ({
440
- children,
441
- widthFactor,
442
- heightFactor,
443
- alignment,
444
- style,
445
- testID
446
- }) => {
447
- const sizedStyle = {};
448
- if (widthFactor !== void 0) sizedStyle.width = `${widthFactor * 100}%`;
449
- if (heightFactor !== void 0) sizedStyle.height = `${heightFactor * 100}%`;
450
- const alignStyle = alignment ? resolveAlignment(alignment) : {};
451
- return /* @__PURE__ */ React13.createElement(View11, { testID, style: [sizedStyle, alignStyle, style] }, children);
452
- };
453
- FractionallySizedBox.displayName = "FractionallySizedBox";
454
-
455
- // src/components/view/positioned-view/positioned-view.tsx
456
- import React14 from "react";
457
- import { View as View12 } from "react-native";
458
- var PositionedView = ({
459
- children,
460
- top,
461
- right,
462
- bottom,
463
- left,
464
- zIndex,
465
- style
466
- }) => {
467
- return /* @__PURE__ */ React14.createElement(
468
- View12,
469
- {
470
- style: [
471
- {
472
- position: "absolute",
473
- top,
474
- right,
475
- bottom,
476
- left,
477
- zIndex
478
- },
479
- style
480
- ]
481
- },
482
- children
483
- );
484
- };
485
- PositionedView.displayName = "PositionedView";
486
-
487
- // src/components/view/blur-view/blur-view.tsx
488
- import React15, { useEffect, useRef } from "react";
489
- import { Animated, StyleSheet, View as View13 } from "react-native";
490
- var styles = StyleSheet.create({
491
- container: {
492
- position: "relative"
493
- },
494
- overlay: {
495
- ...StyleSheet.absoluteFillObject
496
- }
497
- });
498
- var BlurView = ({
499
- children,
500
- unlockable = false,
501
- intensity = 0.6,
502
- overlayColor = "rgba(0, 0, 0, 0.12)",
503
- style
504
- }) => {
505
- const overlayOpacity = Math.min(1, Math.max(0, intensity));
506
- const overlayAnim = useRef(
507
- new Animated.Value(unlockable ? 0 : overlayOpacity)
508
- ).current;
509
- const scaleAnim = useRef(new Animated.Value(unlockable ? 1 : 0.98)).current;
510
- useEffect(() => {
511
- if (unlockable) {
512
- Animated.parallel([
513
- Animated.timing(overlayAnim, {
514
- toValue: 0,
515
- duration: 220,
516
- useNativeDriver: true
517
- }),
518
- Animated.timing(scaleAnim, {
519
- toValue: 1,
520
- duration: 220,
521
- useNativeDriver: true
522
- })
523
- ]).start();
524
- return;
525
- }
526
- overlayAnim.setValue(overlayOpacity);
527
- scaleAnim.setValue(0.98);
528
- }, [overlayAnim, overlayOpacity, scaleAnim, unlockable]);
529
- return /* @__PURE__ */ React15.createElement(View13, { style: [styles.container, style] }, /* @__PURE__ */ React15.createElement(Animated.View, { style: { transform: [{ scale: scaleAnim }] } }, children), /* @__PURE__ */ React15.createElement(
530
- Animated.View,
531
- {
532
- pointerEvents: unlockable ? "none" : "auto",
533
- style: [styles.overlay, { opacity: overlayAnim }]
534
- },
535
- /* @__PURE__ */ React15.createElement(View13, { style: [styles.overlay, { backgroundColor: overlayColor }] })
536
- ));
537
- };
538
- BlurView.displayName = "BlurView";
539
-
540
- // src/components/view/rounded-view/rounded-view.tsx
541
- import React16 from "react";
542
- import { View as View14 } from "react-native";
543
-
544
- // src/components/view/rounded-view/rounded-view.hook.ts
545
- import { useMemo } from "react";
546
- var useRoundedViewStyle = (props) => {
547
- const {
548
- all = 0,
549
- top,
550
- bottom,
551
- left,
552
- right,
553
- topLeft,
554
- topRight,
555
- bottomLeft,
556
- bottomRight
557
- } = props;
558
- return useMemo(() => {
559
- return {
560
- borderTopLeftRadius: topLeft ?? top ?? left ?? all,
561
- borderTopRightRadius: topRight ?? top ?? right ?? all,
562
- borderBottomLeftRadius: bottomLeft ?? bottom ?? left ?? all,
563
- borderBottomRightRadius: bottomRight ?? bottom ?? right ?? all
564
- };
565
- }, [all, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight]);
566
- };
567
-
568
- // src/components/view/rounded-view/rounded-view.tsx
569
- var RoundedView = ({
570
- children,
571
- all,
572
- top,
573
- bottom,
574
- left,
575
- right,
576
- topLeft,
577
- topRight,
578
- bottomLeft,
579
- bottomRight,
580
- fullWidth = false,
581
- backgroundColor,
582
- style,
583
- noGrowth = false
584
- }) => {
585
- const borderRadiusStyle = useRoundedViewStyle({
586
- all,
587
- top,
588
- bottom,
589
- left,
590
- right,
591
- topLeft,
592
- topRight,
593
- bottomLeft,
594
- bottomRight
595
- });
596
- return /* @__PURE__ */ React16.createElement(
597
- View14,
598
- {
599
- style: [
600
- borderRadiusStyle,
601
- fullWidth && { width: "100%" },
602
- noGrowth ? void 0 : { flex: 1 },
603
- backgroundColor && { backgroundColor },
604
- style
605
- ]
606
- },
607
- children
608
- );
609
- };
610
-
611
- // src/components/view/aspect-ratio/aspect-ratio.tsx
612
- import React17 from "react";
613
- import { View as View15 } from "react-native";
614
- var AspectRatio = ({
615
- children,
616
- ratio,
617
- alignment,
618
- clip,
619
- style,
620
- testID
621
- }) => {
622
- const alignStyle = alignment ? resolveAlignment(alignment) : {};
623
- return /* @__PURE__ */ React17.createElement(
624
- View15,
625
- {
626
- testID,
627
- style: [
628
- {
629
- aspectRatio: ratio,
630
- overflow: clip ? "hidden" : "visible"
631
- },
632
- alignStyle,
633
- style
634
- ]
635
- },
636
- children
637
- );
638
- };
639
- AspectRatio.displayName = "AspectRatio";
640
-
641
- // src/components/view/surface/surface.tsx
642
- import React18 from "react";
643
- import { View as View16 } from "react-native";
644
- import { getSafeThemeColor } from "@xaui/core";
645
- var resolveBackgroundColor = (color, theme) => {
646
- if (color === "background" || color === "foreground") {
647
- return theme.colors[color];
648
- }
649
- const safeColor = getSafeThemeColor(color);
650
- return theme.colors[safeColor].container;
651
- };
652
- var Surface = ({
653
- children,
654
- themeColor = "background",
655
- padding,
656
- radius = "none",
657
- fullWidth = false,
658
- style
659
- }) => {
660
- const theme = useXUITheme();
661
- const radiusStyle = useBorderRadiusStyles(radius);
662
- const background = resolveBackgroundColor(themeColor, theme);
663
- return /* @__PURE__ */ React18.createElement(
664
- View16,
665
- {
666
- style: [
667
- radiusStyle,
668
- fullWidth && { flexShrink: 1, flexBasis: "auto", width: "100%" },
669
- {
670
- backgroundColor: background,
671
- padding
672
- },
673
- style
674
- ]
675
- },
676
- children
677
- );
678
- };
679
- Surface.displayName = "Surface";
680
-
681
- // src/components/view/screen/screen.tsx
682
- import React19 from "react";
683
- import { View as View17 } from "react-native";
684
- import { SafeAreaView } from "react-native-safe-area-context";
685
- var Screen = ({
686
- children,
687
- padding,
688
- backgroundColor,
689
- safeArea = false,
690
- style
691
- }) => {
692
- const theme = useXUITheme();
693
- const resolvedBackgroundColor = backgroundColor ?? theme.colors.background;
694
- const containerStyle = [
695
- { flex: 1, backgroundColor: resolvedBackgroundColor, padding },
696
- style
697
- ];
698
- if (safeArea) {
699
- return /* @__PURE__ */ React19.createElement(SafeAreaView, { style: containerStyle }, children);
700
- }
701
- return /* @__PURE__ */ React19.createElement(View17, { style: containerStyle }, children);
702
- };
703
- Screen.displayName = "Screen";
704
-
705
- // src/components/view/align/align.tsx
706
- import React20 from "react";
707
- import { View as View18 } from "react-native";
708
- var Align = ({ children, alignment, style }) => /* @__PURE__ */ React20.createElement(View18, { style: [{ flex: 1 }, resolveAlignment(alignment), style] }, children);
709
- Align.displayName = "Align";
710
-
711
- // src/components/view/center/center.tsx
712
- import React21 from "react";
713
- var Center = ({ children, style }) => /* @__PURE__ */ React21.createElement(Align, { alignment: "center", style }, children);
714
- Center.displayName = "Center";
715
-
716
- // src/components/view/grid/grid.tsx
717
- import React23, { useMemo as useMemo2, useState } from "react";
718
- import {
719
- View as View20
720
- } from "react-native";
721
-
722
- // src/components/view/grid/grid-item.tsx
723
- import React22 from "react";
724
- import { View as View19 } from "react-native";
725
- var GridItem = ({ children, style }) => {
726
- return /* @__PURE__ */ React22.createElement(View19, { style }, children);
727
- };
728
- GridItem.displayName = "GridItem";
729
-
730
- // src/components/view/grid/grid.tsx
731
- var getSafeColumns = (columns) => {
732
- if (!columns || columns <= 0) return 1;
733
- return Math.floor(columns);
734
- };
735
- var getSafeSpan = (span, columns) => {
736
- if (!span || span <= 0) return 1;
737
- return Math.min(Math.floor(span), columns);
738
- };
739
- var isGridItemElement = (child) => {
740
- if (!React23.isValidElement(child)) return false;
741
- if (child.type === GridItem) return true;
742
- const displayName = child.type.displayName;
743
- return displayName === "GridItem";
744
- };
745
- var Grid = ({
746
- children,
747
- columns = 2,
748
- spacing,
749
- rowSpacing,
750
- columnSpacing,
751
- style,
752
- itemStyle
753
- }) => {
754
- const [containerWidth, setContainerWidth] = useState();
755
- const safeColumns = getSafeColumns(columns);
756
- const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
757
- const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
758
- const itemWidth = `${100 / safeColumns}%`;
759
- const items = React23.Children.toArray(children);
760
- const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
761
- const baseItemWidth = useMemo2(() => {
762
- if (!containerWidth) return void 0;
763
- return (containerWidth - totalColumnGap) / safeColumns;
764
- }, [containerWidth, safeColumns, totalColumnGap]);
765
- let currentColumn = 0;
766
- return /* @__PURE__ */ React23.createElement(
767
- View20,
768
- {
769
- style: [
770
- {
771
- flexDirection: "row",
772
- flexWrap: "wrap",
773
- rowGap: resolvedRowSpacing
774
- },
775
- style
776
- ],
777
- onLayout: (event) => {
778
- const nextWidth = event.nativeEvent.layout.width;
779
- if (!nextWidth || nextWidth === containerWidth) return;
780
- setContainerWidth(nextWidth);
781
- }
782
- },
783
- items.map((child, index) => {
784
- const key = React23.isValidElement(child) && child.key ? child.key : `grid-${index}`;
785
- const span = isGridItemElement(child) ? getSafeSpan(child.props.span, safeColumns) : 1;
786
- const spanWidth = baseItemWidth === void 0 ? `${100 / safeColumns * span}%` : baseItemWidth * span + resolvedColumnSpacing * (span - 1);
787
- if (currentColumn + span > safeColumns) {
788
- currentColumn = 0;
789
- }
790
- const isEndOfRow = currentColumn + span >= safeColumns;
791
- const marginRight = isEndOfRow ? 0 : resolvedColumnSpacing;
792
- if (isGridItemElement(child)) {
793
- const mergedStyle = [
794
- {
795
- flexBasis: spanWidth,
796
- maxWidth: spanWidth,
797
- flexGrow: 0,
798
- flexShrink: 0,
799
- marginRight
800
- },
801
- itemStyle,
802
- child.props.style
803
- ];
804
- const element2 = React23.cloneElement(child, {
805
- key,
806
- style: mergedStyle
807
- });
808
- currentColumn = isEndOfRow ? 0 : currentColumn + span;
809
- return element2;
810
- }
811
- const defaultItemWidth = baseItemWidth === void 0 ? itemWidth : baseItemWidth;
812
- const element = /* @__PURE__ */ React23.createElement(
813
- View20,
814
- {
815
- key,
816
- style: [
817
- {
818
- flexBasis: defaultItemWidth,
819
- maxWidth: defaultItemWidth,
820
- flexGrow: 0,
821
- flexShrink: 0,
822
- marginRight
823
- },
824
- itemStyle
825
- ]
826
- },
827
- child
828
- );
829
- currentColumn = isEndOfRow ? 0 : currentColumn + span;
830
- return element;
831
- })
832
- );
833
- };
834
-
835
- // src/components/view/grid/grid-builder.tsx
836
- import React24, { useMemo as useMemo3 } from "react";
837
- import {
838
- FlatList,
839
- StyleSheet as StyleSheet2,
840
- View as View21
841
- } from "react-native";
842
- var getSafeColumns2 = (columns) => {
843
- if (!columns || columns <= 0) return 1;
844
- return Math.floor(columns);
845
- };
846
- var resolveGridData = (data, itemCount) => {
847
- if (data) return data;
848
- if (!itemCount || itemCount <= 0) return [];
849
- return Array.from({ length: itemCount }, (_, index) => index);
850
- };
851
- var GridBuilder = ({
852
- data,
853
- itemCount,
854
- renderItem,
855
- itemBuilder,
856
- keyExtractor,
857
- columns = 2,
858
- spacing,
859
- rowSpacing,
860
- columnSpacing,
861
- style,
862
- itemStyle,
863
- scrollEnabled,
864
- onEndReached,
865
- onEndReachedThreshold = 0.1,
866
- contentContainerStyle,
867
- header,
868
- footer
869
- }) => {
870
- const safeColumns = getSafeColumns2(columns);
871
- const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
872
- const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
873
- const resolvedData = useMemo3(
874
- () => resolveGridData(data, itemCount),
875
- [data, itemCount]
876
- );
877
- const paddedData = useMemo3(() => {
878
- const remainder = resolvedData.length % safeColumns;
879
- const placeholders = remainder === 0 ? 0 : safeColumns - remainder;
880
- if (placeholders === 0)
881
- return resolvedData.map((item, index) => ({
882
- type: "data",
883
- item,
884
- index
885
- }));
886
- return [
887
- ...resolvedData.map((item, index) => ({
888
- type: "data",
889
- item,
890
- index
891
- })),
892
- ...Array.from({ length: placeholders }, (_, index) => ({
893
- type: "placeholder",
894
- key: `placeholder-${resolvedData.length + index}`
895
- }))
896
- ];
897
- }, [resolvedData, safeColumns]);
898
- const resolvedKeyExtractor = useMemo3(() => {
899
- if (keyExtractor)
900
- return (item, index) => item.type === "data" ? keyExtractor(item.item, item.index) : item.key ?? `placeholder-${index}`;
901
- return (item, index) => item.type === "data" ? `grid-${item.index}` : item.key ?? `placeholder-${index}`;
902
- }, [keyExtractor]);
903
- const resolvedRenderer = useMemo3(() => {
904
- if (renderItem) return renderItem;
905
- if (itemBuilder)
906
- return ({ item, index }) => itemBuilder({ item, index });
907
- return void 0;
908
- }, [renderItem, itemBuilder]);
909
- if (!resolvedRenderer) return null;
910
- const renderGridItem = ({
911
- item,
912
- index
913
- }) => {
914
- if (item.type === "placeholder") {
915
- const isLastColumn2 = (index + 1) % safeColumns === 0;
916
- const totalItems2 = paddedData.length;
917
- const lastRowStart2 = totalItems2 === 0 ? 0 : totalItems2 - (totalItems2 % safeColumns || safeColumns);
918
- const isLastRow2 = index >= lastRowStart2;
919
- const placeholderStyle = [
920
- {
921
- flex: 1,
922
- marginRight: isLastColumn2 ? 0 : resolvedColumnSpacing,
923
- marginBottom: isLastRow2 ? 0 : resolvedRowSpacing
924
- },
925
- itemStyle
926
- ];
927
- return /* @__PURE__ */ React24.createElement(View21, { style: placeholderStyle, pointerEvents: "none" });
928
- }
929
- const element = resolvedRenderer({ item: item.item, index: item.index });
930
- if (element === null) return null;
931
- const isLastColumn = (index + 1) % safeColumns === 0;
932
- const totalItems = paddedData.length;
933
- const lastRowStart = totalItems === 0 ? 0 : totalItems - (totalItems % safeColumns || safeColumns);
934
- const isLastRow = index >= lastRowStart;
935
- const wrapperStyle = [
936
- {
937
- flex: 1,
938
- marginRight: isLastColumn ? 0 : resolvedColumnSpacing,
939
- marginBottom: isLastRow ? 0 : resolvedRowSpacing
940
- },
941
- itemStyle
942
- ];
943
- return /* @__PURE__ */ React24.createElement(View21, { style: wrapperStyle }, element);
944
- };
945
- const flattenedStyle = StyleSheet2.flatten(style) ?? {};
946
- const {
947
- alignItems,
948
- justifyContent,
949
- alignContent,
950
- gap,
951
- rowGap,
952
- columnGap,
953
- ...restStyle
954
- } = flattenedStyle;
955
- const layoutStyle = {
956
- ...alignItems !== void 0 ? { alignItems } : {},
957
- ...justifyContent !== void 0 ? { justifyContent } : {},
958
- ...alignContent !== void 0 ? { alignContent } : {},
959
- ...gap !== void 0 ? { gap } : {},
960
- ...rowGap !== void 0 ? { rowGap } : {},
961
- ...columnGap !== void 0 ? { columnGap } : {}
962
- };
963
- const hasLayoutStyle = Object.keys(layoutStyle).length > 0;
964
- return /* @__PURE__ */ React24.createElement(
965
- FlatList,
966
- {
967
- data: paddedData,
968
- renderItem: renderGridItem,
969
- keyExtractor: resolvedKeyExtractor,
970
- numColumns: safeColumns,
971
- scrollEnabled,
972
- onEndReached,
973
- onEndReachedThreshold,
974
- contentContainerStyle: hasLayoutStyle ? [contentContainerStyle, layoutStyle] : contentContainerStyle,
975
- ListHeaderComponent: header,
976
- ListFooterComponent: footer,
977
- style: Object.keys(restStyle).length > 0 ? restStyle : void 0
978
- }
979
- );
980
- };
981
- GridBuilder.displayName = "GridBuilder";
982
-
983
- // src/components/view/conditional/conditional-view.tsx
984
- import React25, { useEffect as useEffect2, useMemo as useMemo4, useRef as useRef2, useState as useState2 } from "react";
985
- import { Animated as Animated3 } from "react-native";
986
-
987
- // src/components/view/conditional/conditional-view.utils.ts
988
- var FINAL_VALUES = {
989
- opacity: 1,
990
- scale: 1,
991
- translateX: 0,
992
- translateY: 0
993
- };
994
- var getInitialValues = (animation) => {
995
- switch (animation) {
996
- case "fade":
997
- return { opacity: 0.5, scale: 1, translateX: 0, translateY: 0 };
998
- case "scale":
999
- default:
1000
- return { opacity: 1, scale: 0.5, translateX: 0, translateY: 0 };
1001
- }
1002
- };
1003
- var getExitValues = (animation) => {
1004
- switch (animation) {
1005
- case "fade":
1006
- return { opacity: 0.5, scale: 1, translateX: 0, translateY: 0 };
1007
- case "scale":
1008
- default:
1009
- return getInitialValues(animation);
1010
- }
1011
- };
1012
-
1013
- // src/components/view/conditional/conditional-view.animation.ts
1014
- import { Animated as Animated2, Easing } from "react-native";
1015
- var runConditionalViewAnimation = ({
1016
- opacity,
1017
- scale,
1018
- translateX,
1019
- translateY,
1020
- toValues,
1021
- onComplete
1022
- }) => {
1023
- const easing = Easing.out(Easing.cubic);
1024
- const animation = Animated2.parallel([
1025
- Animated2.timing(opacity, {
1026
- toValue: toValues.opacity,
1027
- duration: 800,
1028
- easing,
1029
- useNativeDriver: true
1030
- }),
1031
- Animated2.timing(scale, {
1032
- toValue: toValues.scale,
1033
- duration: 800,
1034
- easing,
1035
- useNativeDriver: true
1036
- }),
1037
- Animated2.timing(translateX, {
1038
- toValue: toValues.translateX,
1039
- duration: 800,
1040
- easing,
1041
- useNativeDriver: true
1042
- }),
1043
- Animated2.timing(translateY, {
1044
- toValue: toValues.translateY,
1045
- duration: 800,
1046
- easing,
1047
- useNativeDriver: true
1048
- })
1049
- ]);
1050
- animation.start(({ finished }) => {
1051
- if (finished) {
1052
- onComplete?.();
1053
- }
1054
- });
1055
- return animation;
1056
- };
1057
-
1058
- // src/components/view/conditional/conditional-view.tsx
1059
- var ConditionalView = ({
1060
- isVisible,
1061
- children,
1062
- animation = "fade",
1063
- disableAnimation = false
1064
- }) => {
1065
- const [shouldRender, setShouldRender] = useState2(isVisible);
1066
- const animationRef = useRef2(null);
1067
- const initialValues = useMemo4(() => getInitialValues(animation), [animation]);
1068
- const exitValues = useMemo4(() => getExitValues(animation), [animation]);
1069
- const opacity = useRef2(
1070
- new Animated3.Value(
1071
- disableAnimation ? FINAL_VALUES.opacity : initialValues.opacity
1072
- )
1073
- ).current;
1074
- const scale = useRef2(
1075
- new Animated3.Value(disableAnimation ? FINAL_VALUES.scale : initialValues.scale)
1076
- ).current;
1077
- const translateX = useRef2(
1078
- new Animated3.Value(
1079
- disableAnimation ? FINAL_VALUES.translateX : initialValues.translateX
1080
- )
1081
- ).current;
1082
- const translateY = useRef2(
1083
- new Animated3.Value(
1084
- disableAnimation ? FINAL_VALUES.translateY : initialValues.translateY
1085
- )
1086
- ).current;
1087
- useEffect2(() => {
1088
- if (isVisible) {
1089
- setShouldRender(true);
1090
- }
1091
- }, [isVisible]);
1092
- useEffect2(() => {
1093
- if (!shouldRender) return;
1094
- const startValues = isVisible ? disableAnimation ? FINAL_VALUES : initialValues : FINAL_VALUES;
1095
- const targetValues = isVisible ? FINAL_VALUES : exitValues;
1096
- opacity.setValue(startValues.opacity);
1097
- scale.setValue(startValues.scale);
1098
- translateX.setValue(startValues.translateX);
1099
- translateY.setValue(startValues.translateY);
1100
- if (disableAnimation) {
1101
- if (!isVisible) {
1102
- setShouldRender(false);
1103
- }
1104
- return;
1105
- }
1106
- animationRef.current?.stop();
1107
- animationRef.current = runConditionalViewAnimation({
1108
- opacity,
1109
- scale,
1110
- translateX,
1111
- translateY,
1112
- toValues: targetValues,
1113
- onComplete: !isVisible ? () => setShouldRender(false) : void 0
1114
- });
1115
- }, [
1116
- isVisible,
1117
- shouldRender,
1118
- disableAnimation,
1119
- initialValues,
1120
- exitValues,
1121
- opacity,
1122
- scale,
1123
- translateX,
1124
- translateY
1125
- ]);
1126
- const animatedStyle = useMemo4(
1127
- () => ({
1128
- opacity,
1129
- transform: [{ translateX }, { translateY }, { scale }]
1130
- }),
1131
- [opacity, scale, translateX, translateY]
1132
- );
1133
- if (!shouldRender) {
1134
- return null;
1135
- }
1136
- return /* @__PURE__ */ React25.createElement(Animated3.View, { style: animatedStyle }, children);
1137
- };
1138
-
1139
- // src/components/view/masonry-grid/masonry-grid.tsx
1140
- import React26, { useMemo as useMemo5, useRef as useRef3, useState as useState3 } from "react";
1141
- import { View as View22 } from "react-native";
1142
- var getSafeColumns3 = (columns) => {
1143
- if (!columns || columns <= 0) return 1;
1144
- return Math.floor(columns);
1145
- };
1146
- var getItemKey = (child, index) => {
1147
- return React26.isValidElement(child) && child.key ? String(child.key) : `masonry-${index}`;
1148
- };
1149
- var MasonryGrid = ({
1150
- children,
1151
- columns = 2,
1152
- spacing,
1153
- rowSpacing,
1154
- columnSpacing,
1155
- style,
1156
- columnStyle
1157
- }) => {
1158
- const [containerWidth, setContainerWidth] = useState3();
1159
- const heightMapRef = useRef3({});
1160
- const [layoutVersion, setLayoutVersion] = useState3(0);
1161
- const safeColumns = getSafeColumns3(columns);
1162
- const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
1163
- const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
1164
- const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
1165
- const columnWidth = useMemo5(() => {
1166
- if (!containerWidth) return void 0;
1167
- return (containerWidth - totalColumnGap) / safeColumns;
1168
- }, [containerWidth, safeColumns, totalColumnGap]);
1169
- const items = useMemo5(
1170
- () => React26.Children.toArray(children).map((child, index) => ({
1171
- key: getItemKey(child, index),
1172
- element: child
1173
- })),
1174
- [children]
1175
- );
1176
- const columnsItems = useMemo5(() => {
1177
- const buckets = Array.from({ length: safeColumns }, () => []);
1178
- const heights = new Array(safeColumns).fill(0);
1179
- items.forEach((item) => {
1180
- const height = heightMapRef.current[item.key];
1181
- const targetIndex = heights.indexOf(Math.min(...heights));
1182
- buckets[targetIndex].push(item);
1183
- heights[targetIndex] += (height ?? 0) + resolvedRowSpacing;
1184
- });
1185
- return buckets;
1186
- }, [items, layoutVersion, resolvedRowSpacing, safeColumns]);
1187
- return /* @__PURE__ */ React26.createElement(
1188
- View22,
1189
- {
1190
- style: [
1191
- {
1192
- flexDirection: "row"
1193
- },
1194
- style
1195
- ],
1196
- onLayout: (event) => {
1197
- const nextWidth = event.nativeEvent.layout.width;
1198
- if (!nextWidth || nextWidth === containerWidth) return;
1199
- setContainerWidth(nextWidth);
1200
- }
1201
- },
1202
- columnsItems.map((column, columnIndex) => {
1203
- const isLastColumn = columnIndex === columnsItems.length - 1;
1204
- const columnStyles = [
1205
- {
1206
- width: columnWidth,
1207
- marginRight: isLastColumn ? 0 : resolvedColumnSpacing
1208
- },
1209
- columnStyle
1210
- ];
1211
- return /* @__PURE__ */ React26.createElement(View22, { key: `masonry-col-${columnIndex}`, style: columnStyles }, column.map((item, index) => {
1212
- const isLastRow = index === column.length - 1;
1213
- return /* @__PURE__ */ React26.createElement(
1214
- View22,
1215
- {
1216
- key: item.key,
1217
- style: { marginBottom: isLastRow ? 0 : resolvedRowSpacing },
1218
- onLayout: (event) => {
1219
- const nextHeight = event.nativeEvent.layout.height;
1220
- if (heightMapRef.current[item.key] === nextHeight) return;
1221
- heightMapRef.current[item.key] = nextHeight;
1222
- setLayoutVersion((value) => value + 1);
1223
- }
1224
- },
1225
- item.element
1226
- );
1227
- }));
1228
- })
1229
- );
1230
- };
1231
-
1232
- // src/components/view/masonry-grid/masonry-grid-item.tsx
1233
- import React27 from "react";
1234
- import { View as View23 } from "react-native";
1235
- var MasonryGridItem = ({
1236
- children,
1237
- style
1238
- }) => {
1239
- return /* @__PURE__ */ React27.createElement(View23, { style }, children);
1240
- };
1241
- MasonryGridItem.displayName = "MasonryGridItem";
1242
-
1243
- // src/components/view/masonry-grid/masonry-grid-builder.tsx
1244
- import React28, { useMemo as useMemo6, useRef as useRef4 } from "react";
1245
- import {
1246
- ScrollView
1247
- } from "react-native";
1248
- var resolveMasonryData = (data, itemCount) => {
1249
- if (data) return data;
1250
- if (!itemCount || itemCount <= 0) return [];
1251
- return Array.from({ length: itemCount }, (_, index) => index);
1252
- };
1253
- var MasonryGridBuilder = ({
1254
- data,
1255
- itemCount,
1256
- renderItem,
1257
- itemBuilder,
1258
- keyExtractor,
1259
- columns = 2,
1260
- spacing,
1261
- rowSpacing,
1262
- columnSpacing,
1263
- style,
1264
- columnStyle,
1265
- onEndReached,
1266
- onEndReachedThreshold = 0.1,
1267
- header,
1268
- footer,
1269
- scrollEnabled,
1270
- contentContainerStyle,
1271
- showsVerticalScrollIndicator,
1272
- showsHorizontalScrollIndicator,
1273
- bounces,
1274
- onScroll
1275
- }) => {
1276
- const resolvedData = useMemo6(
1277
- () => resolveMasonryData(data, itemCount),
1278
- [data, itemCount]
1279
- );
1280
- const resolvedKeyExtractor = useMemo6(() => {
1281
- if (keyExtractor) return keyExtractor;
1282
- return (_, index) => `masonry-${index}`;
1283
- }, [keyExtractor]);
1284
- const resolvedRenderer = useMemo6(() => {
1285
- if (renderItem) return renderItem;
1286
- if (itemBuilder)
1287
- return ({ item, index }) => itemBuilder({ item, index });
1288
- return void 0;
1289
- }, [renderItem, itemBuilder]);
1290
- const lastEndReachedHeight = useRef4(0);
1291
- if (!resolvedRenderer) return null;
1292
- const handleScroll = (event) => {
1293
- onScroll?.(event);
1294
- if (!onEndReached) return;
1295
- const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
1296
- if (!layoutMeasurement?.height) return;
1297
- const distanceFromEnd = contentSize.height - (layoutMeasurement.height + contentOffset.y);
1298
- const threshold = onEndReachedThreshold * layoutMeasurement.height;
1299
- if (distanceFromEnd <= threshold && contentSize.height !== lastEndReachedHeight.current) {
1300
- lastEndReachedHeight.current = contentSize.height;
1301
- onEndReached();
1302
- }
1303
- };
1304
- return /* @__PURE__ */ React28.createElement(
1305
- ScrollView,
1306
- {
1307
- scrollEventThrottle: 16,
1308
- scrollEnabled,
1309
- contentContainerStyle,
1310
- showsVerticalScrollIndicator,
1311
- showsHorizontalScrollIndicator,
1312
- bounces,
1313
- onScroll: handleScroll
1314
- },
1315
- header,
1316
- /* @__PURE__ */ React28.createElement(
1317
- MasonryGrid,
1318
- {
1319
- columns,
1320
- spacing,
1321
- rowSpacing,
1322
- columnSpacing,
1323
- style: [{ width: "100%" }, style],
1324
- columnStyle
1325
- },
1326
- resolvedData.map((item, index) => /* @__PURE__ */ React28.createElement(MasonryGridItem, { key: resolvedKeyExtractor(item, index) }, resolvedRenderer({ item, index })))
1327
- ),
1328
- footer
1329
- );
1330
- };
1331
- MasonryGridBuilder.displayName = "MasonryGridBuilder";
1332
- export {
1333
- Align,
1334
- AspectRatio,
1335
- BlurView,
1336
- Center,
1337
- Column,
1338
- ConditionalView,
1339
- ConstrainedBox,
1340
- Container,
1341
- Expanded,
1342
- Flex,
1343
- Flexible,
1344
- FractionallySizedBox,
1345
- Grid,
1346
- GridBuilder,
1347
- GridItem,
1348
- Margin,
1349
- MasonryGrid,
1350
- MasonryGridBuilder,
1351
- MasonryGridItem,
1352
- Padding,
1353
- PositionedView,
1354
- RoundedView,
1355
- Row,
1356
- Screen,
1357
- SizedBox,
1358
- Spacer,
1359
- Surface,
1360
- Wrap
1361
- };