@xaui/native 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/accordion/index.cjs +1 -1
- package/dist/accordion/index.js +5 -4
- package/dist/alert/index.js +3 -2
- package/dist/autocomplete/index.cjs +5 -11
- package/dist/autocomplete/index.js +3 -2
- package/dist/avatar/index.js +3 -2
- package/dist/badge/index.js +3 -2
- package/dist/bottom-sheet/index.cjs +9 -20
- package/dist/bottom-sheet/index.js +3 -2
- package/dist/button/index.cjs +19 -15
- package/dist/button/index.d.cts +11 -95
- package/dist/button/index.d.ts +11 -95
- package/dist/button/index.js +22 -17
- package/dist/button.type-D8tzEBo7.d.ts +104 -0
- package/dist/button.type-ikaWzhIg.d.cts +104 -0
- package/dist/carousel/index.cjs +458 -0
- package/dist/carousel/index.d.cts +147 -0
- package/dist/carousel/index.d.ts +147 -0
- package/dist/carousel/index.js +7 -0
- package/dist/checkbox/index.js +2 -1
- package/dist/chip/index.cjs +2 -8
- package/dist/chip/index.js +3 -2
- package/dist/{chunk-QLEQYKG5.js → chunk-6PXMB5CH.js} +3 -9
- package/dist/chunk-DBKVHMSA.js +329 -0
- package/dist/chunk-DXXNBF5P.js +7 -0
- package/dist/chunk-EW5YLICE.js +382 -0
- package/dist/{chunk-7OFTYKK4.js → chunk-JJOVGRNI.js} +1 -1
- package/dist/{chunk-4LFRYVSR.js → chunk-K2HSVISE.js} +1 -1
- package/dist/{chunk-NBRASCX4.js → chunk-MZL77KV5.js} +5 -12
- package/dist/{chunk-2T6FKPJW.js → chunk-OXVIVNIJ.js} +1 -1
- package/dist/{chunk-ZYTBRHLJ.js → chunk-PWCUULAL.js} +1 -1
- package/dist/{chunk-GNJIET26.js → chunk-RIVFFZRO.js} +1 -1
- package/dist/{chunk-GAOI4KIV.js → chunk-S3MGBM3G.js} +10 -21
- package/dist/chunk-STUNTRKJ.js +405 -0
- package/dist/chunk-TJ2FPLLZ.js +287 -0
- package/dist/{chunk-XJKA22BK.js → chunk-UGDGCMGC.js} +1 -1
- package/dist/{chunk-MKHBEJLO.js → chunk-VUVE6PK7.js} +1 -1
- package/dist/{chunk-NMZUPH3R.js → chunk-XUYIAA3A.js} +3 -9
- package/dist/core/index.js +5 -3
- package/dist/datepicker/index.js +3 -2
- package/dist/divider/index.js +3 -2
- package/dist/fab/index.cjs +725 -0
- package/dist/fab/index.d.cts +10 -0
- package/dist/fab/index.d.ts +10 -0
- package/dist/fab/index.js +9 -0
- package/dist/fab-menu/index.cjs +1063 -0
- package/dist/fab-menu/index.d.cts +125 -0
- package/dist/fab-menu/index.d.ts +125 -0
- package/dist/fab-menu/index.js +12 -0
- package/dist/fab.type-Ba0QMprb.d.ts +86 -0
- package/dist/fab.type-U09H8B7D.d.cts +86 -0
- package/dist/index.cjs +1712 -366
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +32 -11
- package/dist/indicator/index.js +3 -2
- package/dist/menu/index.cjs +8 -7
- package/dist/menu/index.js +15 -9
- package/dist/progress/index.js +2 -1
- package/dist/segment-button/index.cjs +492 -0
- package/dist/segment-button/index.d.cts +141 -0
- package/dist/segment-button/index.d.ts +141 -0
- package/dist/segment-button/index.js +10 -0
- package/dist/select/index.js +2 -1
- package/dist/switch/index.js +2 -1
- package/dist/typography/index.js +3 -2
- package/dist/view/index.cjs +153 -78
- package/dist/view/index.d.cts +77 -1
- package/dist/view/index.d.ts +77 -1
- package/dist/view/index.js +125 -52
- package/package.json +21 -1
package/dist/view/index.d.ts
CHANGED
|
@@ -213,6 +213,82 @@ type BlurViewProps = {
|
|
|
213
213
|
|
|
214
214
|
declare const BlurView: React.FC<BlurViewProps>;
|
|
215
215
|
|
|
216
|
+
type RoundedViewProps = {
|
|
217
|
+
/**
|
|
218
|
+
* Content to be displayed inside the rounded view
|
|
219
|
+
*/
|
|
220
|
+
children: ReactNode;
|
|
221
|
+
/**
|
|
222
|
+
* Border radius for all corners in pixels
|
|
223
|
+
*/
|
|
224
|
+
all?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Border radius for top corners (topLeft and topRight) in pixels
|
|
227
|
+
*/
|
|
228
|
+
top?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Border radius for bottom corners (bottomLeft and bottomRight) in pixels
|
|
231
|
+
*/
|
|
232
|
+
bottom?: number;
|
|
233
|
+
/**
|
|
234
|
+
* Border radius for left corners (topLeft and bottomLeft) in pixels
|
|
235
|
+
*/
|
|
236
|
+
left?: number;
|
|
237
|
+
/**
|
|
238
|
+
* Border radius for right corners (topRight and bottomRight) in pixels
|
|
239
|
+
*/
|
|
240
|
+
right?: number;
|
|
241
|
+
/**
|
|
242
|
+
* Border radius for top-left corner in pixels
|
|
243
|
+
*/
|
|
244
|
+
topLeft?: number;
|
|
245
|
+
/**
|
|
246
|
+
* Border radius for top-right corner in pixels
|
|
247
|
+
*/
|
|
248
|
+
topRight?: number;
|
|
249
|
+
/**
|
|
250
|
+
* Border radius for bottom-left corner in pixels
|
|
251
|
+
*/
|
|
252
|
+
bottomLeft?: number;
|
|
253
|
+
/**
|
|
254
|
+
* Border radius for bottom-right corner in pixels
|
|
255
|
+
*/
|
|
256
|
+
bottomRight?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Whether the view should take full width
|
|
259
|
+
* @default false
|
|
260
|
+
*/
|
|
261
|
+
fullWidth?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Background color of the view
|
|
264
|
+
*/
|
|
265
|
+
backgroundColor?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Custom style for the view
|
|
268
|
+
*/
|
|
269
|
+
style?: ViewStyle;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
declare const RoundedView: React.FC<RoundedViewProps>;
|
|
273
|
+
|
|
274
|
+
type AspectRatioProps = {
|
|
275
|
+
/**
|
|
276
|
+
* Content to be displayed inside the aspect ratio container
|
|
277
|
+
*/
|
|
278
|
+
children: ReactNode;
|
|
279
|
+
/**
|
|
280
|
+
* Aspect ratio as a number (width / height)
|
|
281
|
+
* Examples: 16/9, 4/3, 1, 2/1
|
|
282
|
+
*/
|
|
283
|
+
ratio: number;
|
|
284
|
+
/**
|
|
285
|
+
* Custom style for the container
|
|
286
|
+
*/
|
|
287
|
+
style?: ViewStyle;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
declare const AspectRatio: React.FC<AspectRatioProps>;
|
|
291
|
+
|
|
216
292
|
type GridProps = {
|
|
217
293
|
/**
|
|
218
294
|
* The grid items to render.
|
|
@@ -524,4 +600,4 @@ declare const MasonryGridBuilder: {
|
|
|
524
600
|
displayName: string;
|
|
525
601
|
};
|
|
526
602
|
|
|
527
|
-
export { BlurView, type BlurViewProps, Column, type ColumnProps, ConditionalView, type ConditionalViewAnimation, type ConditionalViewProps, type CrossAxisAlignment, Grid, GridBuilder, type GridBuilderProps, GridItem, type GridItemProps, type GridProps, type MainAxisAlignment, Margin, type MarginProps, MasonryGrid, MasonryGridBuilder, type MasonryGridBuilderProps, MasonryGridItem, type MasonryGridItemProps, type MasonryGridProps, Padding, type PaddingProps, PositionedView, type PositionedViewProps, Row, type RowProps, SizedBox, type SizedBoxProps, Spacer, type SpacerProps };
|
|
603
|
+
export { AspectRatio, type AspectRatioProps, BlurView, type BlurViewProps, Column, type ColumnProps, ConditionalView, type ConditionalViewAnimation, type ConditionalViewProps, type CrossAxisAlignment, Grid, GridBuilder, type GridBuilderProps, GridItem, type GridItemProps, type GridProps, type MainAxisAlignment, Margin, type MarginProps, MasonryGrid, MasonryGridBuilder, type MasonryGridBuilderProps, MasonryGridItem, type MasonryGridItemProps, type MasonryGridProps, Padding, type PaddingProps, PositionedView, type PositionedViewProps, RoundedView, type RoundedViewProps, Row, type RowProps, SizedBox, type SizedBoxProps, Spacer, type SpacerProps };
|
package/dist/view/index.js
CHANGED
|
@@ -293,17 +293,88 @@ var BlurView = ({
|
|
|
293
293
|
};
|
|
294
294
|
BlurView.displayName = "BlurView";
|
|
295
295
|
|
|
296
|
+
// src/components/view/rounded-view/rounded-view.tsx
|
|
297
|
+
import React9 from "react";
|
|
298
|
+
import { View as View9, StyleSheet as StyleSheet2 } from "react-native";
|
|
299
|
+
|
|
300
|
+
// src/components/view/rounded-view/rounded-view.hook.ts
|
|
301
|
+
import { useMemo } from "react";
|
|
302
|
+
var useRoundedViewStyle = (props) => {
|
|
303
|
+
const { all = 0, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight } = props;
|
|
304
|
+
return useMemo(() => {
|
|
305
|
+
return {
|
|
306
|
+
borderTopLeftRadius: topLeft ?? top ?? left ?? all,
|
|
307
|
+
borderTopRightRadius: topRight ?? top ?? right ?? all,
|
|
308
|
+
borderBottomLeftRadius: bottomLeft ?? bottom ?? left ?? all,
|
|
309
|
+
borderBottomRightRadius: bottomRight ?? bottom ?? right ?? all
|
|
310
|
+
};
|
|
311
|
+
}, [all, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight]);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// src/components/view/rounded-view/rounded-view.tsx
|
|
315
|
+
var RoundedView = ({
|
|
316
|
+
children,
|
|
317
|
+
all,
|
|
318
|
+
top,
|
|
319
|
+
bottom,
|
|
320
|
+
left,
|
|
321
|
+
right,
|
|
322
|
+
topLeft,
|
|
323
|
+
topRight,
|
|
324
|
+
bottomLeft,
|
|
325
|
+
bottomRight,
|
|
326
|
+
fullWidth = false,
|
|
327
|
+
backgroundColor,
|
|
328
|
+
style
|
|
329
|
+
}) => {
|
|
330
|
+
const borderRadiusStyle = useRoundedViewStyle({
|
|
331
|
+
all,
|
|
332
|
+
top,
|
|
333
|
+
bottom,
|
|
334
|
+
left,
|
|
335
|
+
right,
|
|
336
|
+
topLeft,
|
|
337
|
+
topRight,
|
|
338
|
+
bottomLeft,
|
|
339
|
+
bottomRight
|
|
340
|
+
});
|
|
341
|
+
return /* @__PURE__ */ React9.createElement(
|
|
342
|
+
View9,
|
|
343
|
+
{
|
|
344
|
+
style: [
|
|
345
|
+
borderRadiusStyle,
|
|
346
|
+
fullWidth && styles2.fullWidth,
|
|
347
|
+
backgroundColor && { backgroundColor },
|
|
348
|
+
style
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
children
|
|
352
|
+
);
|
|
353
|
+
};
|
|
354
|
+
var styles2 = StyleSheet2.create({
|
|
355
|
+
fullWidth: {
|
|
356
|
+
width: "100%"
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// src/components/view/aspect-ratio/aspect-ratio.tsx
|
|
361
|
+
import React10 from "react";
|
|
362
|
+
import { View as View10 } from "react-native";
|
|
363
|
+
var AspectRatio = ({ children, ratio, style }) => {
|
|
364
|
+
return /* @__PURE__ */ React10.createElement(View10, { style: [{ aspectRatio: ratio }, style] }, children);
|
|
365
|
+
};
|
|
366
|
+
|
|
296
367
|
// src/components/view/grid/grid.tsx
|
|
297
|
-
import
|
|
368
|
+
import React12, { useMemo as useMemo2, useState } from "react";
|
|
298
369
|
import {
|
|
299
|
-
View as
|
|
370
|
+
View as View12
|
|
300
371
|
} from "react-native";
|
|
301
372
|
|
|
302
373
|
// src/components/view/grid/grid-item.tsx
|
|
303
|
-
import
|
|
304
|
-
import { View as
|
|
374
|
+
import React11 from "react";
|
|
375
|
+
import { View as View11 } from "react-native";
|
|
305
376
|
var GridItem = ({ children, style }) => {
|
|
306
|
-
return /* @__PURE__ */
|
|
377
|
+
return /* @__PURE__ */ React11.createElement(View11, { style }, children);
|
|
307
378
|
};
|
|
308
379
|
GridItem.displayName = "GridItem";
|
|
309
380
|
|
|
@@ -317,7 +388,7 @@ var getSafeSpan = (span, columns) => {
|
|
|
317
388
|
return Math.min(Math.floor(span), columns);
|
|
318
389
|
};
|
|
319
390
|
var isGridItemElement = (child) => {
|
|
320
|
-
if (!
|
|
391
|
+
if (!React12.isValidElement(child)) return false;
|
|
321
392
|
if (child.type === GridItem) return true;
|
|
322
393
|
const displayName = child.type.displayName;
|
|
323
394
|
return displayName === "GridItem";
|
|
@@ -336,15 +407,15 @@ var Grid = ({
|
|
|
336
407
|
const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
|
|
337
408
|
const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
|
|
338
409
|
const itemWidth = `${100 / safeColumns}%`;
|
|
339
|
-
const items =
|
|
410
|
+
const items = React12.Children.toArray(children);
|
|
340
411
|
const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
|
|
341
|
-
const baseItemWidth =
|
|
412
|
+
const baseItemWidth = useMemo2(() => {
|
|
342
413
|
if (!containerWidth) return void 0;
|
|
343
414
|
return (containerWidth - totalColumnGap) / safeColumns;
|
|
344
415
|
}, [containerWidth, safeColumns, totalColumnGap]);
|
|
345
416
|
let currentColumn = 0;
|
|
346
|
-
return /* @__PURE__ */
|
|
347
|
-
|
|
417
|
+
return /* @__PURE__ */ React12.createElement(
|
|
418
|
+
View12,
|
|
348
419
|
{
|
|
349
420
|
style: [
|
|
350
421
|
{
|
|
@@ -361,7 +432,7 @@ var Grid = ({
|
|
|
361
432
|
}
|
|
362
433
|
},
|
|
363
434
|
items.map((child, index) => {
|
|
364
|
-
const key =
|
|
435
|
+
const key = React12.isValidElement(child) && child.key ? child.key : `grid-${index}`;
|
|
365
436
|
const span = isGridItemElement(child) ? getSafeSpan(child.props.span, safeColumns) : 1;
|
|
366
437
|
const spanWidth = baseItemWidth === void 0 ? `${100 / safeColumns * span}%` : baseItemWidth * span + resolvedColumnSpacing * (span - 1);
|
|
367
438
|
if (currentColumn + span > safeColumns) {
|
|
@@ -381,7 +452,7 @@ var Grid = ({
|
|
|
381
452
|
itemStyle,
|
|
382
453
|
child.props.style
|
|
383
454
|
];
|
|
384
|
-
const element2 =
|
|
455
|
+
const element2 = React12.cloneElement(child, {
|
|
385
456
|
key,
|
|
386
457
|
style: mergedStyle
|
|
387
458
|
});
|
|
@@ -389,8 +460,8 @@ var Grid = ({
|
|
|
389
460
|
return element2;
|
|
390
461
|
}
|
|
391
462
|
const defaultItemWidth = baseItemWidth === void 0 ? itemWidth : baseItemWidth;
|
|
392
|
-
const element = /* @__PURE__ */
|
|
393
|
-
|
|
463
|
+
const element = /* @__PURE__ */ React12.createElement(
|
|
464
|
+
View12,
|
|
394
465
|
{
|
|
395
466
|
key,
|
|
396
467
|
style: [
|
|
@@ -413,11 +484,11 @@ var Grid = ({
|
|
|
413
484
|
};
|
|
414
485
|
|
|
415
486
|
// src/components/view/grid/grid-builder.tsx
|
|
416
|
-
import
|
|
487
|
+
import React13, { useMemo as useMemo3 } from "react";
|
|
417
488
|
import {
|
|
418
489
|
FlatList,
|
|
419
|
-
StyleSheet as
|
|
420
|
-
View as
|
|
490
|
+
StyleSheet as StyleSheet3,
|
|
491
|
+
View as View13
|
|
421
492
|
} from "react-native";
|
|
422
493
|
var getSafeColumns2 = (columns) => {
|
|
423
494
|
if (!columns || columns <= 0) return 1;
|
|
@@ -450,11 +521,11 @@ var GridBuilder = ({
|
|
|
450
521
|
const safeColumns = getSafeColumns2(columns);
|
|
451
522
|
const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
|
|
452
523
|
const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
|
|
453
|
-
const resolvedData =
|
|
524
|
+
const resolvedData = useMemo3(
|
|
454
525
|
() => resolveGridData(data, itemCount),
|
|
455
526
|
[data, itemCount]
|
|
456
527
|
);
|
|
457
|
-
const paddedData =
|
|
528
|
+
const paddedData = useMemo3(() => {
|
|
458
529
|
const remainder = resolvedData.length % safeColumns;
|
|
459
530
|
const placeholders = remainder === 0 ? 0 : safeColumns - remainder;
|
|
460
531
|
if (placeholders === 0)
|
|
@@ -475,12 +546,12 @@ var GridBuilder = ({
|
|
|
475
546
|
}))
|
|
476
547
|
];
|
|
477
548
|
}, [resolvedData, safeColumns]);
|
|
478
|
-
const resolvedKeyExtractor =
|
|
549
|
+
const resolvedKeyExtractor = useMemo3(() => {
|
|
479
550
|
if (keyExtractor)
|
|
480
551
|
return (item, index) => item.type === "data" ? keyExtractor(item.item, item.index) : item.key ?? `placeholder-${index}`;
|
|
481
552
|
return (item, index) => item.type === "data" ? `grid-${item.index}` : item.key ?? `placeholder-${index}`;
|
|
482
553
|
}, [keyExtractor]);
|
|
483
|
-
const resolvedRenderer =
|
|
554
|
+
const resolvedRenderer = useMemo3(() => {
|
|
484
555
|
if (renderItem) return renderItem;
|
|
485
556
|
if (itemBuilder)
|
|
486
557
|
return ({ item, index }) => itemBuilder({ item, index });
|
|
@@ -504,7 +575,7 @@ var GridBuilder = ({
|
|
|
504
575
|
},
|
|
505
576
|
itemStyle
|
|
506
577
|
];
|
|
507
|
-
return /* @__PURE__ */
|
|
578
|
+
return /* @__PURE__ */ React13.createElement(View13, { style: placeholderStyle, pointerEvents: "none" });
|
|
508
579
|
}
|
|
509
580
|
const element = resolvedRenderer({ item: item.item, index: item.index });
|
|
510
581
|
if (element === null) return null;
|
|
@@ -520,9 +591,9 @@ var GridBuilder = ({
|
|
|
520
591
|
},
|
|
521
592
|
itemStyle
|
|
522
593
|
];
|
|
523
|
-
return /* @__PURE__ */
|
|
594
|
+
return /* @__PURE__ */ React13.createElement(View13, { style: wrapperStyle }, element);
|
|
524
595
|
};
|
|
525
|
-
const flattenedStyle =
|
|
596
|
+
const flattenedStyle = StyleSheet3.flatten(style) ?? {};
|
|
526
597
|
const {
|
|
527
598
|
alignItems,
|
|
528
599
|
justifyContent,
|
|
@@ -541,7 +612,7 @@ var GridBuilder = ({
|
|
|
541
612
|
...columnGap !== void 0 ? { columnGap } : {}
|
|
542
613
|
};
|
|
543
614
|
const hasLayoutStyle = Object.keys(layoutStyle).length > 0;
|
|
544
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ React13.createElement(
|
|
545
616
|
FlatList,
|
|
546
617
|
{
|
|
547
618
|
data: paddedData,
|
|
@@ -561,7 +632,7 @@ var GridBuilder = ({
|
|
|
561
632
|
GridBuilder.displayName = "GridBuilder";
|
|
562
633
|
|
|
563
634
|
// src/components/view/conditional/conditional-view.tsx
|
|
564
|
-
import
|
|
635
|
+
import React14, { useEffect as useEffect2, useMemo as useMemo4, useRef as useRef2, useState as useState2 } from "react";
|
|
565
636
|
import { Animated as Animated3 } from "react-native";
|
|
566
637
|
|
|
567
638
|
// src/components/view/conditional/conditional-view.utils.ts
|
|
@@ -644,8 +715,8 @@ var ConditionalView = ({
|
|
|
644
715
|
}) => {
|
|
645
716
|
const [shouldRender, setShouldRender] = useState2(isVisible);
|
|
646
717
|
const animationRef = useRef2(null);
|
|
647
|
-
const initialValues =
|
|
648
|
-
const exitValues =
|
|
718
|
+
const initialValues = useMemo4(() => getInitialValues(animation), [animation]);
|
|
719
|
+
const exitValues = useMemo4(() => getExitValues(animation), [animation]);
|
|
649
720
|
const opacity = useRef2(
|
|
650
721
|
new Animated3.Value(
|
|
651
722
|
disableAnimation ? FINAL_VALUES.opacity : initialValues.opacity
|
|
@@ -703,7 +774,7 @@ var ConditionalView = ({
|
|
|
703
774
|
translateX,
|
|
704
775
|
translateY
|
|
705
776
|
]);
|
|
706
|
-
const animatedStyle =
|
|
777
|
+
const animatedStyle = useMemo4(
|
|
707
778
|
() => ({
|
|
708
779
|
opacity,
|
|
709
780
|
transform: [{ translateX }, { translateY }, { scale }]
|
|
@@ -713,18 +784,18 @@ var ConditionalView = ({
|
|
|
713
784
|
if (!shouldRender) {
|
|
714
785
|
return null;
|
|
715
786
|
}
|
|
716
|
-
return /* @__PURE__ */
|
|
787
|
+
return /* @__PURE__ */ React14.createElement(Animated3.View, { style: animatedStyle }, children);
|
|
717
788
|
};
|
|
718
789
|
|
|
719
790
|
// src/components/view/masonry-grid/masonry-grid.tsx
|
|
720
|
-
import
|
|
721
|
-
import { View as
|
|
791
|
+
import React15, { useMemo as useMemo5, useRef as useRef3, useState as useState3 } from "react";
|
|
792
|
+
import { View as View14 } from "react-native";
|
|
722
793
|
var getSafeColumns3 = (columns) => {
|
|
723
794
|
if (!columns || columns <= 0) return 1;
|
|
724
795
|
return Math.floor(columns);
|
|
725
796
|
};
|
|
726
797
|
var getItemKey = (child, index) => {
|
|
727
|
-
return
|
|
798
|
+
return React15.isValidElement(child) && child.key ? String(child.key) : `masonry-${index}`;
|
|
728
799
|
};
|
|
729
800
|
var MasonryGrid = ({
|
|
730
801
|
children,
|
|
@@ -742,18 +813,18 @@ var MasonryGrid = ({
|
|
|
742
813
|
const resolvedRowSpacing = rowSpacing ?? spacing ?? 0;
|
|
743
814
|
const resolvedColumnSpacing = columnSpacing ?? spacing ?? 0;
|
|
744
815
|
const totalColumnGap = resolvedColumnSpacing * (safeColumns - 1);
|
|
745
|
-
const columnWidth =
|
|
816
|
+
const columnWidth = useMemo5(() => {
|
|
746
817
|
if (!containerWidth) return void 0;
|
|
747
818
|
return (containerWidth - totalColumnGap) / safeColumns;
|
|
748
819
|
}, [containerWidth, safeColumns, totalColumnGap]);
|
|
749
|
-
const items =
|
|
750
|
-
() =>
|
|
820
|
+
const items = useMemo5(
|
|
821
|
+
() => React15.Children.toArray(children).map((child, index) => ({
|
|
751
822
|
key: getItemKey(child, index),
|
|
752
823
|
element: child
|
|
753
824
|
})),
|
|
754
825
|
[children]
|
|
755
826
|
);
|
|
756
|
-
const columnsItems =
|
|
827
|
+
const columnsItems = useMemo5(() => {
|
|
757
828
|
const buckets = Array.from({ length: safeColumns }, () => []);
|
|
758
829
|
const heights = new Array(safeColumns).fill(0);
|
|
759
830
|
items.forEach((item) => {
|
|
@@ -764,8 +835,8 @@ var MasonryGrid = ({
|
|
|
764
835
|
});
|
|
765
836
|
return buckets;
|
|
766
837
|
}, [items, layoutVersion, resolvedRowSpacing, safeColumns]);
|
|
767
|
-
return /* @__PURE__ */
|
|
768
|
-
|
|
838
|
+
return /* @__PURE__ */ React15.createElement(
|
|
839
|
+
View14,
|
|
769
840
|
{
|
|
770
841
|
style: [
|
|
771
842
|
{
|
|
@@ -788,10 +859,10 @@ var MasonryGrid = ({
|
|
|
788
859
|
},
|
|
789
860
|
columnStyle
|
|
790
861
|
];
|
|
791
|
-
return /* @__PURE__ */
|
|
862
|
+
return /* @__PURE__ */ React15.createElement(View14, { key: `masonry-col-${columnIndex}`, style: columnStyles }, column.map((item, index) => {
|
|
792
863
|
const isLastRow = index === column.length - 1;
|
|
793
|
-
return /* @__PURE__ */
|
|
794
|
-
|
|
864
|
+
return /* @__PURE__ */ React15.createElement(
|
|
865
|
+
View14,
|
|
795
866
|
{
|
|
796
867
|
key: item.key,
|
|
797
868
|
style: { marginBottom: isLastRow ? 0 : resolvedRowSpacing },
|
|
@@ -810,18 +881,18 @@ var MasonryGrid = ({
|
|
|
810
881
|
};
|
|
811
882
|
|
|
812
883
|
// src/components/view/masonry-grid/masonry-grid-item.tsx
|
|
813
|
-
import
|
|
814
|
-
import { View as
|
|
884
|
+
import React16 from "react";
|
|
885
|
+
import { View as View15 } from "react-native";
|
|
815
886
|
var MasonryGridItem = ({
|
|
816
887
|
children,
|
|
817
888
|
style
|
|
818
889
|
}) => {
|
|
819
|
-
return /* @__PURE__ */
|
|
890
|
+
return /* @__PURE__ */ React16.createElement(View15, { style }, children);
|
|
820
891
|
};
|
|
821
892
|
MasonryGridItem.displayName = "MasonryGridItem";
|
|
822
893
|
|
|
823
894
|
// src/components/view/masonry-grid/masonry-grid-builder.tsx
|
|
824
|
-
import
|
|
895
|
+
import React17, { useMemo as useMemo6, useRef as useRef4 } from "react";
|
|
825
896
|
import {
|
|
826
897
|
ScrollView
|
|
827
898
|
} from "react-native";
|
|
@@ -853,15 +924,15 @@ var MasonryGridBuilder = ({
|
|
|
853
924
|
bounces,
|
|
854
925
|
onScroll
|
|
855
926
|
}) => {
|
|
856
|
-
const resolvedData =
|
|
927
|
+
const resolvedData = useMemo6(
|
|
857
928
|
() => resolveMasonryData(data, itemCount),
|
|
858
929
|
[data, itemCount]
|
|
859
930
|
);
|
|
860
|
-
const resolvedKeyExtractor =
|
|
931
|
+
const resolvedKeyExtractor = useMemo6(() => {
|
|
861
932
|
if (keyExtractor) return keyExtractor;
|
|
862
933
|
return (_, index) => `masonry-${index}`;
|
|
863
934
|
}, [keyExtractor]);
|
|
864
|
-
const resolvedRenderer =
|
|
935
|
+
const resolvedRenderer = useMemo6(() => {
|
|
865
936
|
if (renderItem) return renderItem;
|
|
866
937
|
if (itemBuilder)
|
|
867
938
|
return ({ item, index }) => itemBuilder({ item, index });
|
|
@@ -881,7 +952,7 @@ var MasonryGridBuilder = ({
|
|
|
881
952
|
onEndReached();
|
|
882
953
|
}
|
|
883
954
|
};
|
|
884
|
-
return /* @__PURE__ */
|
|
955
|
+
return /* @__PURE__ */ React17.createElement(
|
|
885
956
|
ScrollView,
|
|
886
957
|
{
|
|
887
958
|
scrollEventThrottle: 16,
|
|
@@ -893,7 +964,7 @@ var MasonryGridBuilder = ({
|
|
|
893
964
|
onScroll: handleScroll
|
|
894
965
|
},
|
|
895
966
|
header,
|
|
896
|
-
/* @__PURE__ */
|
|
967
|
+
/* @__PURE__ */ React17.createElement(
|
|
897
968
|
MasonryGrid,
|
|
898
969
|
{
|
|
899
970
|
columns,
|
|
@@ -903,13 +974,14 @@ var MasonryGridBuilder = ({
|
|
|
903
974
|
style: [{ width: "100%" }, style],
|
|
904
975
|
columnStyle
|
|
905
976
|
},
|
|
906
|
-
resolvedData.map((item, index) => /* @__PURE__ */
|
|
977
|
+
resolvedData.map((item, index) => /* @__PURE__ */ React17.createElement(MasonryGridItem, { key: resolvedKeyExtractor(item, index) }, resolvedRenderer({ item, index })))
|
|
907
978
|
),
|
|
908
979
|
footer
|
|
909
980
|
);
|
|
910
981
|
};
|
|
911
982
|
MasonryGridBuilder.displayName = "MasonryGridBuilder";
|
|
912
983
|
export {
|
|
984
|
+
AspectRatio,
|
|
913
985
|
BlurView,
|
|
914
986
|
Column,
|
|
915
987
|
ConditionalView,
|
|
@@ -922,6 +994,7 @@ export {
|
|
|
922
994
|
MasonryGridItem,
|
|
923
995
|
Padding,
|
|
924
996
|
PositionedView,
|
|
997
|
+
RoundedView,
|
|
925
998
|
Row,
|
|
926
999
|
SizedBox,
|
|
927
1000
|
Spacer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaui/native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -102,6 +102,16 @@
|
|
|
102
102
|
"import": "./dist/view/index.js",
|
|
103
103
|
"require": "./dist/view/index.js"
|
|
104
104
|
},
|
|
105
|
+
"./carousel": {
|
|
106
|
+
"types": "./dist/carousel/index.d.ts",
|
|
107
|
+
"import": "./dist/carousel/index.js",
|
|
108
|
+
"require": "./dist/carousel/index.js"
|
|
109
|
+
},
|
|
110
|
+
"./segment-button": {
|
|
111
|
+
"types": "./dist/segment-button/index.d.ts",
|
|
112
|
+
"import": "./dist/segment-button/index.js",
|
|
113
|
+
"require": "./dist/segment-button/index.js"
|
|
114
|
+
},
|
|
105
115
|
"./chip": {
|
|
106
116
|
"types": "./dist/chip/index.d.ts",
|
|
107
117
|
"import": "./dist/chip/index.js",
|
|
@@ -116,6 +126,16 @@
|
|
|
116
126
|
"types": "./dist/menu/index.d.ts",
|
|
117
127
|
"import": "./dist/menu/index.js",
|
|
118
128
|
"require": "./dist/menu/index.js"
|
|
129
|
+
},
|
|
130
|
+
"./fab": {
|
|
131
|
+
"types": "./dist/fab/index.d.ts",
|
|
132
|
+
"import": "./dist/fab/index.js",
|
|
133
|
+
"require": "./dist/fab/index.js"
|
|
134
|
+
},
|
|
135
|
+
"./fab-menu": {
|
|
136
|
+
"types": "./dist/fab-menu/index.d.ts",
|
|
137
|
+
"import": "./dist/fab-menu/index.js",
|
|
138
|
+
"require": "./dist/fab-menu/index.js"
|
|
119
139
|
}
|
|
120
140
|
},
|
|
121
141
|
"files": [
|