@xaui/native 0.0.7 → 0.0.8

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.
@@ -0,0 +1,960 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/view/index.ts
31
+ var view_exports = {};
32
+ __export(view_exports, {
33
+ BlurView: () => BlurView,
34
+ Column: () => Column,
35
+ ConditionalView: () => ConditionalView,
36
+ Grid: () => Grid,
37
+ GridBuilder: () => GridBuilder,
38
+ GridItem: () => GridItem,
39
+ Margin: () => Margin,
40
+ MasonryGrid: () => MasonryGrid,
41
+ MasonryGridBuilder: () => MasonryGridBuilder,
42
+ MasonryGridItem: () => MasonryGridItem,
43
+ Padding: () => Padding,
44
+ PositionedView: () => PositionedView,
45
+ Row: () => Row,
46
+ SizedBox: () => SizedBox,
47
+ Spacer: () => Spacer
48
+ });
49
+ module.exports = __toCommonJS(view_exports);
50
+
51
+ // src/components/view/column/column.tsx
52
+ var import_react = __toESM(require("react"), 1);
53
+ var import_react_native = require("react-native");
54
+
55
+ // src/components/view/layout-utils.ts
56
+ var MAIN_AXIS_JUSTIFY_MAP = {
57
+ start: "flex-start",
58
+ center: "center",
59
+ end: "flex-end",
60
+ "space-between": "space-between",
61
+ "space-around": "space-around",
62
+ "space-evenly": "space-evenly"
63
+ };
64
+ var CROSS_AXIS_ALIGN_MAP = {
65
+ start: "flex-start",
66
+ center: "center",
67
+ end: "flex-end",
68
+ stretch: "stretch",
69
+ baseline: "baseline"
70
+ };
71
+ var resolveMainAxisAlignment = (alignment) => {
72
+ return MAIN_AXIS_JUSTIFY_MAP[alignment ?? "start"];
73
+ };
74
+ var resolveCrossAxisAlignment = (alignment) => {
75
+ return CROSS_AXIS_ALIGN_MAP[alignment ?? "center"];
76
+ };
77
+
78
+ // src/components/view/column/column.tsx
79
+ var Column = ({
80
+ children,
81
+ mainAxisAlignment,
82
+ crossAxisAlignment,
83
+ spacing,
84
+ reverse = false,
85
+ fullWidth,
86
+ style
87
+ }) => {
88
+ const gapStyle = spacing === void 0 ? void 0 : { gap: spacing };
89
+ const fullWidthStyle = fullWidth ? { flexShrink: 1, flexBasis: "auto", width: "100%" } : void 0;
90
+ return /* @__PURE__ */ import_react.default.createElement(
91
+ import_react_native.View,
92
+ {
93
+ style: [
94
+ {
95
+ flexDirection: reverse ? "column-reverse" : "column",
96
+ justifyContent: resolveMainAxisAlignment(mainAxisAlignment),
97
+ alignItems: resolveCrossAxisAlignment(crossAxisAlignment)
98
+ },
99
+ fullWidthStyle,
100
+ gapStyle,
101
+ style
102
+ ]
103
+ },
104
+ children
105
+ );
106
+ };
107
+
108
+ // src/components/view/row/row.tsx
109
+ var import_react2 = __toESM(require("react"), 1);
110
+ var import_react_native2 = require("react-native");
111
+ var Row = ({
112
+ children,
113
+ mainAxisAlignment,
114
+ crossAxisAlignment,
115
+ spacing,
116
+ reverse = false,
117
+ fullWidth,
118
+ style
119
+ }) => {
120
+ const gapStyle = spacing === void 0 ? void 0 : { gap: spacing };
121
+ const fullWidthStyle = fullWidth ? { flexShrink: 1, flexBasis: "auto", width: "100%" } : void 0;
122
+ return /* @__PURE__ */ import_react2.default.createElement(
123
+ import_react_native2.View,
124
+ {
125
+ style: [
126
+ {
127
+ flexDirection: reverse ? "row-reverse" : "row",
128
+ justifyContent: resolveMainAxisAlignment(mainAxisAlignment),
129
+ alignItems: resolveCrossAxisAlignment(crossAxisAlignment)
130
+ },
131
+ fullWidthStyle,
132
+ gapStyle,
133
+ style
134
+ ]
135
+ },
136
+ children
137
+ );
138
+ };
139
+
140
+ // src/components/view/spacer/spacer.tsx
141
+ var import_react3 = __toESM(require("react"), 1);
142
+ var import_react_native3 = require("react-native");
143
+ var Spacer = ({ flex = 1, style }) => {
144
+ return /* @__PURE__ */ import_react3.default.createElement(
145
+ import_react_native3.View,
146
+ {
147
+ style: [
148
+ {
149
+ flexGrow: flex,
150
+ flexShrink: 1,
151
+ flexBasis: 0
152
+ },
153
+ style
154
+ ]
155
+ }
156
+ );
157
+ };
158
+ Spacer.displayName = "Spacer";
159
+
160
+ // src/components/view/padding/padding.tsx
161
+ var import_react4 = __toESM(require("react"), 1);
162
+ var import_react_native4 = require("react-native");
163
+ var Padding = ({
164
+ children,
165
+ all,
166
+ horizontal,
167
+ vertical,
168
+ top,
169
+ right,
170
+ bottom,
171
+ left,
172
+ style
173
+ }) => {
174
+ return /* @__PURE__ */ import_react4.default.createElement(
175
+ import_react_native4.View,
176
+ {
177
+ style: [
178
+ {
179
+ padding: all,
180
+ paddingHorizontal: horizontal,
181
+ paddingVertical: vertical,
182
+ paddingTop: top,
183
+ paddingRight: right,
184
+ paddingBottom: bottom,
185
+ paddingLeft: left
186
+ },
187
+ style
188
+ ]
189
+ },
190
+ children
191
+ );
192
+ };
193
+ Padding.displayName = "Padding";
194
+
195
+ // src/components/view/margin/margin.tsx
196
+ var import_react5 = __toESM(require("react"), 1);
197
+ var import_react_native5 = require("react-native");
198
+ var Margin = ({
199
+ children,
200
+ value,
201
+ horizontal,
202
+ vertical,
203
+ top,
204
+ right,
205
+ bottom,
206
+ left,
207
+ style
208
+ }) => {
209
+ return /* @__PURE__ */ import_react5.default.createElement(
210
+ import_react_native5.View,
211
+ {
212
+ style: [
213
+ {
214
+ margin: value,
215
+ marginHorizontal: horizontal,
216
+ marginVertical: vertical,
217
+ marginTop: top,
218
+ marginRight: right,
219
+ marginBottom: bottom,
220
+ marginLeft: left
221
+ },
222
+ style
223
+ ]
224
+ },
225
+ children
226
+ );
227
+ };
228
+ Margin.displayName = "Margin";
229
+
230
+ // src/components/view/sized-box/sized-box.tsx
231
+ var import_react6 = __toESM(require("react"), 1);
232
+ var import_react_native6 = require("react-native");
233
+ var SizedBox = ({
234
+ children,
235
+ width,
236
+ height,
237
+ style
238
+ }) => {
239
+ return /* @__PURE__ */ import_react6.default.createElement(
240
+ import_react_native6.View,
241
+ {
242
+ style: [
243
+ {
244
+ width,
245
+ height
246
+ },
247
+ style
248
+ ]
249
+ },
250
+ children
251
+ );
252
+ };
253
+ SizedBox.displayName = "SizedBox";
254
+
255
+ // src/components/view/positioned-view/positioned-view.tsx
256
+ var import_react7 = __toESM(require("react"), 1);
257
+ var import_react_native7 = require("react-native");
258
+ var PositionedView = ({
259
+ children,
260
+ top,
261
+ right,
262
+ bottom,
263
+ left,
264
+ zIndex,
265
+ style
266
+ }) => {
267
+ return /* @__PURE__ */ import_react7.default.createElement(
268
+ import_react_native7.View,
269
+ {
270
+ style: [
271
+ {
272
+ position: "absolute",
273
+ top,
274
+ right,
275
+ bottom,
276
+ left,
277
+ zIndex
278
+ },
279
+ style
280
+ ]
281
+ },
282
+ children
283
+ );
284
+ };
285
+ PositionedView.displayName = "PositionedView";
286
+
287
+ // src/components/view/blur-view/blur-view.tsx
288
+ var import_react8 = __toESM(require("react"), 1);
289
+ var import_react_native8 = require("react-native");
290
+ var styles = import_react_native8.StyleSheet.create({
291
+ container: {
292
+ position: "relative"
293
+ },
294
+ overlay: {
295
+ ...import_react_native8.StyleSheet.absoluteFillObject
296
+ }
297
+ });
298
+ var BlurView = ({
299
+ children,
300
+ unlockable = false,
301
+ intensity = 0.6,
302
+ overlayColor = "rgba(0, 0, 0, 0.12)",
303
+ style
304
+ }) => {
305
+ const overlayOpacity = Math.min(1, Math.max(0, intensity));
306
+ const overlayAnim = (0, import_react8.useRef)(new import_react_native8.Animated.Value(unlockable ? 0 : overlayOpacity)).current;
307
+ const scaleAnim = (0, import_react8.useRef)(new import_react_native8.Animated.Value(unlockable ? 1 : 0.98)).current;
308
+ (0, import_react8.useEffect)(() => {
309
+ if (unlockable) {
310
+ import_react_native8.Animated.parallel([
311
+ import_react_native8.Animated.timing(overlayAnim, {
312
+ toValue: 0,
313
+ duration: 220,
314
+ useNativeDriver: true
315
+ }),
316
+ import_react_native8.Animated.timing(scaleAnim, {
317
+ toValue: 1,
318
+ duration: 220,
319
+ useNativeDriver: true
320
+ })
321
+ ]).start();
322
+ return;
323
+ }
324
+ overlayAnim.setValue(overlayOpacity);
325
+ scaleAnim.setValue(0.98);
326
+ }, [overlayAnim, overlayOpacity, scaleAnim, unlockable]);
327
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: [styles.container, style] }, /* @__PURE__ */ import_react8.default.createElement(import_react_native8.Animated.View, { style: { transform: [{ scale: scaleAnim }] } }, children), /* @__PURE__ */ import_react8.default.createElement(
328
+ import_react_native8.Animated.View,
329
+ {
330
+ pointerEvents: unlockable ? "none" : "auto",
331
+ style: [styles.overlay, { opacity: overlayAnim }]
332
+ },
333
+ /* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: [styles.overlay, { backgroundColor: overlayColor }] })
334
+ ));
335
+ };
336
+ BlurView.displayName = "BlurView";
337
+
338
+ // src/components/view/grid/grid.tsx
339
+ var import_react10 = __toESM(require("react"), 1);
340
+ var import_react_native10 = require("react-native");
341
+
342
+ // src/components/view/grid/grid-item.tsx
343
+ var import_react9 = __toESM(require("react"), 1);
344
+ var import_react_native9 = require("react-native");
345
+ var GridItem = ({ children, style }) => {
346
+ return /* @__PURE__ */ import_react9.default.createElement(import_react_native9.View, { style }, children);
347
+ };
348
+ GridItem.displayName = "GridItem";
349
+
350
+ // src/components/view/grid/grid.tsx
351
+ var getSafeColumns = (columns) => {
352
+ if (!columns || columns <= 0) return 1;
353
+ return Math.floor(columns);
354
+ };
355
+ var getSafeSpan = (span, columns) => {
356
+ if (!span || span <= 0) return 1;
357
+ return Math.min(Math.floor(span), columns);
358
+ };
359
+ var isGridItemElement = (child) => {
360
+ if (!import_react10.default.isValidElement(child)) return false;
361
+ if (child.type === GridItem) return true;
362
+ const displayName = child.type.displayName;
363
+ return displayName === "GridItem";
364
+ };
365
+ var Grid = ({
366
+ children,
367
+ columns = 2,
368
+ spacing,
369
+ rowSpacing,
370
+ columnSpacing,
371
+ style,
372
+ itemStyle
373
+ }) => {
374
+ const [containerWidth, setContainerWidth] = (0, import_react10.useState)();
375
+ const safeColumns = getSafeColumns(columns);
376
+ const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
377
+ const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
378
+ const itemWidth = `${100 / safeColumns}%`;
379
+ const items = import_react10.default.Children.toArray(children);
380
+ const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
381
+ const baseItemWidth = (0, import_react10.useMemo)(() => {
382
+ if (!containerWidth) return void 0;
383
+ return (containerWidth - totalColumnGap) / safeColumns;
384
+ }, [containerWidth, safeColumns, totalColumnGap]);
385
+ let currentColumn = 0;
386
+ return /* @__PURE__ */ import_react10.default.createElement(
387
+ import_react_native10.View,
388
+ {
389
+ style: [
390
+ {
391
+ flexDirection: "row",
392
+ flexWrap: "wrap",
393
+ rowGap: resolvedRowSpacing
394
+ },
395
+ style
396
+ ],
397
+ onLayout: (event) => {
398
+ const nextWidth = event.nativeEvent.layout.width;
399
+ if (!nextWidth || nextWidth === containerWidth) return;
400
+ setContainerWidth(nextWidth);
401
+ }
402
+ },
403
+ items.map((child, index) => {
404
+ const key = import_react10.default.isValidElement(child) && child.key ? child.key : `grid-${index}`;
405
+ const span = isGridItemElement(child) ? getSafeSpan(child.props.span, safeColumns) : 1;
406
+ const spanWidth = baseItemWidth === void 0 ? `${100 / safeColumns * span}%` : baseItemWidth * span + resolvedColumnSpacing * (span - 1);
407
+ if (currentColumn + span > safeColumns) {
408
+ currentColumn = 0;
409
+ }
410
+ const isEndOfRow = currentColumn + span >= safeColumns;
411
+ const marginRight = isEndOfRow ? 0 : resolvedColumnSpacing;
412
+ if (isGridItemElement(child)) {
413
+ const mergedStyle = [
414
+ {
415
+ flexBasis: spanWidth,
416
+ maxWidth: spanWidth,
417
+ flexGrow: 0,
418
+ flexShrink: 0,
419
+ marginRight
420
+ },
421
+ itemStyle,
422
+ child.props.style
423
+ ];
424
+ const element2 = import_react10.default.cloneElement(child, {
425
+ key,
426
+ style: mergedStyle
427
+ });
428
+ currentColumn = isEndOfRow ? 0 : currentColumn + span;
429
+ return element2;
430
+ }
431
+ const defaultItemWidth = baseItemWidth === void 0 ? itemWidth : baseItemWidth;
432
+ const element = /* @__PURE__ */ import_react10.default.createElement(
433
+ import_react_native10.View,
434
+ {
435
+ key,
436
+ style: [
437
+ {
438
+ flexBasis: defaultItemWidth,
439
+ maxWidth: defaultItemWidth,
440
+ flexGrow: 0,
441
+ flexShrink: 0,
442
+ marginRight
443
+ },
444
+ itemStyle
445
+ ]
446
+ },
447
+ child
448
+ );
449
+ currentColumn = isEndOfRow ? 0 : currentColumn + span;
450
+ return element;
451
+ })
452
+ );
453
+ };
454
+
455
+ // src/components/view/grid/grid-builder.tsx
456
+ var import_react11 = __toESM(require("react"), 1);
457
+ var import_react_native11 = require("react-native");
458
+ var getSafeColumns2 = (columns) => {
459
+ if (!columns || columns <= 0) return 1;
460
+ return Math.floor(columns);
461
+ };
462
+ var resolveGridData = (data, itemCount) => {
463
+ if (data) return data;
464
+ if (!itemCount || itemCount <= 0) return [];
465
+ return Array.from({ length: itemCount }, (_, index) => index);
466
+ };
467
+ var GridBuilder = ({
468
+ data,
469
+ itemCount,
470
+ renderItem,
471
+ itemBuilder,
472
+ keyExtractor,
473
+ columns = 2,
474
+ spacing,
475
+ rowSpacing,
476
+ columnSpacing,
477
+ style,
478
+ itemStyle,
479
+ scrollEnabled,
480
+ onEndReached,
481
+ onEndReachedThreshold = 0.1,
482
+ contentContainerStyle,
483
+ header,
484
+ footer
485
+ }) => {
486
+ const safeColumns = getSafeColumns2(columns);
487
+ const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
488
+ const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
489
+ const resolvedData = (0, import_react11.useMemo)(
490
+ () => resolveGridData(data, itemCount),
491
+ [data, itemCount]
492
+ );
493
+ const paddedData = (0, import_react11.useMemo)(() => {
494
+ const remainder = resolvedData.length % safeColumns;
495
+ const placeholders = remainder === 0 ? 0 : safeColumns - remainder;
496
+ if (placeholders === 0) return resolvedData.map((item, index) => ({
497
+ type: "data",
498
+ item,
499
+ index
500
+ }));
501
+ return [
502
+ ...resolvedData.map((item, index) => ({
503
+ type: "data",
504
+ item,
505
+ index
506
+ })),
507
+ ...Array.from({ length: placeholders }, (_, index) => ({
508
+ type: "placeholder",
509
+ key: `placeholder-${resolvedData.length + index}`
510
+ }))
511
+ ];
512
+ }, [resolvedData, safeColumns]);
513
+ const resolvedKeyExtractor = (0, import_react11.useMemo)(() => {
514
+ if (keyExtractor)
515
+ return (item, index) => item.type === "data" ? keyExtractor(item.item, item.index) : item.key ?? `placeholder-${index}`;
516
+ return (item, index) => item.type === "data" ? `grid-${item.index}` : item.key ?? `placeholder-${index}`;
517
+ }, [keyExtractor]);
518
+ const resolvedRenderer = (0, import_react11.useMemo)(() => {
519
+ if (renderItem) return renderItem;
520
+ if (itemBuilder)
521
+ return ({ item, index }) => itemBuilder({ item, index });
522
+ return void 0;
523
+ }, [renderItem, itemBuilder]);
524
+ if (!resolvedRenderer) return null;
525
+ const renderGridItem = ({
526
+ item,
527
+ index
528
+ }) => {
529
+ if (item.type === "placeholder") {
530
+ const isLastColumn2 = (index + 1) % safeColumns === 0;
531
+ const totalItems2 = paddedData.length;
532
+ const lastRowStart2 = totalItems2 === 0 ? 0 : totalItems2 - (totalItems2 % safeColumns || safeColumns);
533
+ const isLastRow2 = index >= lastRowStart2;
534
+ const placeholderStyle = [
535
+ {
536
+ flex: 1,
537
+ marginRight: isLastColumn2 ? 0 : resolvedColumnSpacing,
538
+ marginBottom: isLastRow2 ? 0 : resolvedRowSpacing
539
+ },
540
+ itemStyle
541
+ ];
542
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_native11.View, { style: placeholderStyle, pointerEvents: "none" });
543
+ }
544
+ const element = resolvedRenderer({ item: item.item, index: item.index });
545
+ if (element === null) return null;
546
+ const isLastColumn = (index + 1) % safeColumns === 0;
547
+ const totalItems = paddedData.length;
548
+ const lastRowStart = totalItems === 0 ? 0 : totalItems - (totalItems % safeColumns || safeColumns);
549
+ const isLastRow = index >= lastRowStart;
550
+ const wrapperStyle = [
551
+ {
552
+ flex: 1,
553
+ marginRight: isLastColumn ? 0 : resolvedColumnSpacing,
554
+ marginBottom: isLastRow ? 0 : resolvedRowSpacing
555
+ },
556
+ itemStyle
557
+ ];
558
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_native11.View, { style: wrapperStyle }, element);
559
+ };
560
+ const flattenedStyle = import_react_native11.StyleSheet.flatten(style) ?? {};
561
+ const {
562
+ alignItems,
563
+ justifyContent,
564
+ alignContent,
565
+ gap,
566
+ rowGap,
567
+ columnGap,
568
+ ...restStyle
569
+ } = flattenedStyle;
570
+ const layoutStyle = {
571
+ ...alignItems !== void 0 ? { alignItems } : {},
572
+ ...justifyContent !== void 0 ? { justifyContent } : {},
573
+ ...alignContent !== void 0 ? { alignContent } : {},
574
+ ...gap !== void 0 ? { gap } : {},
575
+ ...rowGap !== void 0 ? { rowGap } : {},
576
+ ...columnGap !== void 0 ? { columnGap } : {}
577
+ };
578
+ const hasLayoutStyle = Object.keys(layoutStyle).length > 0;
579
+ return /* @__PURE__ */ import_react11.default.createElement(
580
+ import_react_native11.FlatList,
581
+ {
582
+ data: paddedData,
583
+ renderItem: renderGridItem,
584
+ keyExtractor: resolvedKeyExtractor,
585
+ numColumns: safeColumns,
586
+ scrollEnabled,
587
+ onEndReached,
588
+ onEndReachedThreshold,
589
+ contentContainerStyle: hasLayoutStyle ? [contentContainerStyle, layoutStyle] : contentContainerStyle,
590
+ ListHeaderComponent: header,
591
+ ListFooterComponent: footer,
592
+ style: Object.keys(restStyle).length > 0 ? restStyle : void 0
593
+ }
594
+ );
595
+ };
596
+ GridBuilder.displayName = "GridBuilder";
597
+
598
+ // src/components/view/conditional/conditional-view.tsx
599
+ var import_react12 = __toESM(require("react"), 1);
600
+ var import_react_native13 = require("react-native");
601
+
602
+ // src/components/view/conditional/conditional-view.utils.ts
603
+ var FINAL_VALUES = {
604
+ opacity: 1,
605
+ scale: 1,
606
+ translateX: 0,
607
+ translateY: 0
608
+ };
609
+ var getInitialValues = (animation) => {
610
+ switch (animation) {
611
+ case "fade":
612
+ return { opacity: 0.5, scale: 1, translateX: 0, translateY: 0 };
613
+ case "scale":
614
+ default:
615
+ return { opacity: 1, scale: 0.5, translateX: 0, translateY: 0 };
616
+ }
617
+ };
618
+ var getExitValues = (animation) => {
619
+ switch (animation) {
620
+ case "fade":
621
+ return { opacity: 0.5, scale: 1, translateX: 0, translateY: 0 };
622
+ case "scale":
623
+ default:
624
+ return getInitialValues(animation);
625
+ }
626
+ };
627
+
628
+ // src/components/view/conditional/conditional-view.animation.ts
629
+ var import_react_native12 = require("react-native");
630
+ var runConditionalViewAnimation = ({
631
+ opacity,
632
+ scale,
633
+ translateX,
634
+ translateY,
635
+ toValues,
636
+ onComplete
637
+ }) => {
638
+ const easing = import_react_native12.Easing.out(import_react_native12.Easing.cubic);
639
+ const animation = import_react_native12.Animated.parallel([
640
+ import_react_native12.Animated.timing(opacity, {
641
+ toValue: toValues.opacity,
642
+ duration: 800,
643
+ easing,
644
+ useNativeDriver: true
645
+ }),
646
+ import_react_native12.Animated.timing(scale, {
647
+ toValue: toValues.scale,
648
+ duration: 800,
649
+ easing,
650
+ useNativeDriver: true
651
+ }),
652
+ import_react_native12.Animated.timing(translateX, {
653
+ toValue: toValues.translateX,
654
+ duration: 800,
655
+ easing,
656
+ useNativeDriver: true
657
+ }),
658
+ import_react_native12.Animated.timing(translateY, {
659
+ toValue: toValues.translateY,
660
+ duration: 800,
661
+ easing,
662
+ useNativeDriver: true
663
+ })
664
+ ]);
665
+ animation.start(({ finished }) => {
666
+ if (finished) {
667
+ onComplete?.();
668
+ }
669
+ });
670
+ return animation;
671
+ };
672
+
673
+ // src/components/view/conditional/conditional-view.tsx
674
+ var ConditionalView = ({
675
+ isVisible,
676
+ children,
677
+ animation = "fade",
678
+ disableAnimation = false
679
+ }) => {
680
+ const [shouldRender, setShouldRender] = (0, import_react12.useState)(isVisible);
681
+ const animationRef = (0, import_react12.useRef)(null);
682
+ const initialValues = (0, import_react12.useMemo)(() => getInitialValues(animation), [animation]);
683
+ const exitValues = (0, import_react12.useMemo)(() => getExitValues(animation), [animation]);
684
+ const opacity = (0, import_react12.useRef)(
685
+ new import_react_native13.Animated.Value(disableAnimation ? FINAL_VALUES.opacity : initialValues.opacity)
686
+ ).current;
687
+ const scale = (0, import_react12.useRef)(
688
+ new import_react_native13.Animated.Value(disableAnimation ? FINAL_VALUES.scale : initialValues.scale)
689
+ ).current;
690
+ const translateX = (0, import_react12.useRef)(
691
+ new import_react_native13.Animated.Value(
692
+ disableAnimation ? FINAL_VALUES.translateX : initialValues.translateX
693
+ )
694
+ ).current;
695
+ const translateY = (0, import_react12.useRef)(
696
+ new import_react_native13.Animated.Value(
697
+ disableAnimation ? FINAL_VALUES.translateY : initialValues.translateY
698
+ )
699
+ ).current;
700
+ (0, import_react12.useEffect)(() => {
701
+ if (isVisible) {
702
+ setShouldRender(true);
703
+ }
704
+ }, [isVisible]);
705
+ (0, import_react12.useEffect)(() => {
706
+ if (!shouldRender) return;
707
+ const startValues = isVisible ? disableAnimation ? FINAL_VALUES : initialValues : FINAL_VALUES;
708
+ const targetValues = isVisible ? FINAL_VALUES : exitValues;
709
+ opacity.setValue(startValues.opacity);
710
+ scale.setValue(startValues.scale);
711
+ translateX.setValue(startValues.translateX);
712
+ translateY.setValue(startValues.translateY);
713
+ if (disableAnimation) {
714
+ if (!isVisible) {
715
+ setShouldRender(false);
716
+ }
717
+ return;
718
+ }
719
+ animationRef.current?.stop();
720
+ animationRef.current = runConditionalViewAnimation({
721
+ opacity,
722
+ scale,
723
+ translateX,
724
+ translateY,
725
+ toValues: targetValues,
726
+ onComplete: !isVisible ? () => setShouldRender(false) : void 0
727
+ });
728
+ }, [
729
+ isVisible,
730
+ shouldRender,
731
+ disableAnimation,
732
+ initialValues,
733
+ exitValues,
734
+ opacity,
735
+ scale,
736
+ translateX,
737
+ translateY
738
+ ]);
739
+ const animatedStyle = (0, import_react12.useMemo)(
740
+ () => ({
741
+ opacity,
742
+ transform: [{ translateX }, { translateY }, { scale }]
743
+ }),
744
+ [opacity, scale, translateX, translateY]
745
+ );
746
+ if (!shouldRender) {
747
+ return null;
748
+ }
749
+ return /* @__PURE__ */ import_react12.default.createElement(import_react_native13.Animated.View, { style: animatedStyle }, children);
750
+ };
751
+
752
+ // src/components/view/masonry-grid/masonry-grid.tsx
753
+ var import_react13 = __toESM(require("react"), 1);
754
+ var import_react_native14 = require("react-native");
755
+ var getSafeColumns3 = (columns) => {
756
+ if (!columns || columns <= 0) return 1;
757
+ return Math.floor(columns);
758
+ };
759
+ var getItemKey = (child, index) => {
760
+ return import_react13.default.isValidElement(child) && child.key ? String(child.key) : `masonry-${index}`;
761
+ };
762
+ var MasonryGrid = ({
763
+ children,
764
+ columns = 2,
765
+ spacing,
766
+ rowSpacing,
767
+ columnSpacing,
768
+ style,
769
+ columnStyle
770
+ }) => {
771
+ const [containerWidth, setContainerWidth] = (0, import_react13.useState)();
772
+ const heightMapRef = (0, import_react13.useRef)({});
773
+ const [layoutVersion, setLayoutVersion] = (0, import_react13.useState)(0);
774
+ const safeColumns = getSafeColumns3(columns);
775
+ const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
776
+ const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
777
+ const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
778
+ const columnWidth = (0, import_react13.useMemo)(() => {
779
+ if (!containerWidth) return void 0;
780
+ return (containerWidth - totalColumnGap) / safeColumns;
781
+ }, [containerWidth, safeColumns, totalColumnGap]);
782
+ const items = (0, import_react13.useMemo)(
783
+ () => import_react13.default.Children.toArray(children).map((child, index) => ({
784
+ key: getItemKey(child, index),
785
+ element: child
786
+ })),
787
+ [children]
788
+ );
789
+ const columnsItems = (0, import_react13.useMemo)(() => {
790
+ const buckets = Array.from({ length: safeColumns }, () => []);
791
+ const heights = new Array(safeColumns).fill(0);
792
+ items.forEach((item) => {
793
+ const height = heightMapRef.current[item.key];
794
+ const targetIndex = heights.indexOf(Math.min(...heights));
795
+ buckets[targetIndex].push(item);
796
+ heights[targetIndex] += (height ?? 0) + resolvedRowSpacing;
797
+ });
798
+ return buckets;
799
+ }, [items, layoutVersion, resolvedRowSpacing, safeColumns]);
800
+ return /* @__PURE__ */ import_react13.default.createElement(
801
+ import_react_native14.View,
802
+ {
803
+ style: [
804
+ {
805
+ flexDirection: "row"
806
+ },
807
+ style
808
+ ],
809
+ onLayout: (event) => {
810
+ const nextWidth = event.nativeEvent.layout.width;
811
+ if (!nextWidth || nextWidth === containerWidth) return;
812
+ setContainerWidth(nextWidth);
813
+ }
814
+ },
815
+ columnsItems.map((column, columnIndex) => {
816
+ const isLastColumn = columnIndex === columnsItems.length - 1;
817
+ const columnStyles = [
818
+ {
819
+ width: columnWidth,
820
+ marginRight: isLastColumn ? 0 : resolvedColumnSpacing
821
+ },
822
+ columnStyle
823
+ ];
824
+ return /* @__PURE__ */ import_react13.default.createElement(import_react_native14.View, { key: `masonry-col-${columnIndex}`, style: columnStyles }, column.map((item, index) => {
825
+ const isLastRow = index === column.length - 1;
826
+ return /* @__PURE__ */ import_react13.default.createElement(
827
+ import_react_native14.View,
828
+ {
829
+ key: item.key,
830
+ style: { marginBottom: isLastRow ? 0 : resolvedRowSpacing },
831
+ onLayout: (event) => {
832
+ const nextHeight = event.nativeEvent.layout.height;
833
+ if (heightMapRef.current[item.key] === nextHeight) return;
834
+ heightMapRef.current[item.key] = nextHeight;
835
+ setLayoutVersion((value) => value + 1);
836
+ }
837
+ },
838
+ item.element
839
+ );
840
+ }));
841
+ })
842
+ );
843
+ };
844
+
845
+ // src/components/view/masonry-grid/masonry-grid-item.tsx
846
+ var import_react14 = __toESM(require("react"), 1);
847
+ var import_react_native15 = require("react-native");
848
+ var MasonryGridItem = ({
849
+ children,
850
+ style
851
+ }) => {
852
+ return /* @__PURE__ */ import_react14.default.createElement(import_react_native15.View, { style }, children);
853
+ };
854
+ MasonryGridItem.displayName = "MasonryGridItem";
855
+
856
+ // src/components/view/masonry-grid/masonry-grid-builder.tsx
857
+ var import_react15 = __toESM(require("react"), 1);
858
+ var import_react_native16 = require("react-native");
859
+ var resolveMasonryData = (data, itemCount) => {
860
+ if (data) return data;
861
+ if (!itemCount || itemCount <= 0) return [];
862
+ return Array.from({ length: itemCount }, (_, index) => index);
863
+ };
864
+ var MasonryGridBuilder = ({
865
+ data,
866
+ itemCount,
867
+ renderItem,
868
+ itemBuilder,
869
+ keyExtractor,
870
+ columns = 2,
871
+ spacing,
872
+ rowSpacing,
873
+ columnSpacing,
874
+ style,
875
+ columnStyle,
876
+ onEndReached,
877
+ onEndReachedThreshold = 0.1,
878
+ header,
879
+ footer,
880
+ scrollEnabled,
881
+ contentContainerStyle,
882
+ showsVerticalScrollIndicator,
883
+ showsHorizontalScrollIndicator,
884
+ bounces,
885
+ onScroll
886
+ }) => {
887
+ const resolvedData = (0, import_react15.useMemo)(
888
+ () => resolveMasonryData(data, itemCount),
889
+ [data, itemCount]
890
+ );
891
+ const resolvedKeyExtractor = (0, import_react15.useMemo)(() => {
892
+ if (keyExtractor) return keyExtractor;
893
+ return (_, index) => `masonry-${index}`;
894
+ }, [keyExtractor]);
895
+ const resolvedRenderer = (0, import_react15.useMemo)(() => {
896
+ if (renderItem) return renderItem;
897
+ if (itemBuilder)
898
+ return ({ item, index }) => itemBuilder({ item, index });
899
+ return void 0;
900
+ }, [renderItem, itemBuilder]);
901
+ const lastEndReachedHeight = (0, import_react15.useRef)(0);
902
+ if (!resolvedRenderer) return null;
903
+ const handleScroll = (event) => {
904
+ onScroll?.(event);
905
+ if (!onEndReached) return;
906
+ const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
907
+ if (!layoutMeasurement?.height) return;
908
+ const distanceFromEnd = contentSize.height - (layoutMeasurement.height + contentOffset.y);
909
+ const threshold = onEndReachedThreshold * layoutMeasurement.height;
910
+ if (distanceFromEnd <= threshold && contentSize.height !== lastEndReachedHeight.current) {
911
+ lastEndReachedHeight.current = contentSize.height;
912
+ onEndReached();
913
+ }
914
+ };
915
+ return /* @__PURE__ */ import_react15.default.createElement(
916
+ import_react_native16.ScrollView,
917
+ {
918
+ scrollEventThrottle: 16,
919
+ scrollEnabled,
920
+ contentContainerStyle,
921
+ showsVerticalScrollIndicator,
922
+ showsHorizontalScrollIndicator,
923
+ bounces,
924
+ onScroll: handleScroll
925
+ },
926
+ header,
927
+ /* @__PURE__ */ import_react15.default.createElement(
928
+ MasonryGrid,
929
+ {
930
+ columns,
931
+ spacing,
932
+ rowSpacing,
933
+ columnSpacing,
934
+ style: [{ width: "100%" }, style],
935
+ columnStyle
936
+ },
937
+ resolvedData.map((item, index) => /* @__PURE__ */ import_react15.default.createElement(MasonryGridItem, { key: resolvedKeyExtractor(item, index) }, resolvedRenderer({ item, index })))
938
+ ),
939
+ footer
940
+ );
941
+ };
942
+ MasonryGridBuilder.displayName = "MasonryGridBuilder";
943
+ // Annotate the CommonJS export names for ESM import in node:
944
+ 0 && (module.exports = {
945
+ BlurView,
946
+ Column,
947
+ ConditionalView,
948
+ Grid,
949
+ GridBuilder,
950
+ GridItem,
951
+ Margin,
952
+ MasonryGrid,
953
+ MasonryGridBuilder,
954
+ MasonryGridItem,
955
+ Padding,
956
+ PositionedView,
957
+ Row,
958
+ SizedBox,
959
+ Spacer
960
+ });