@xaui/native 0.0.27 → 0.0.28
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/LICENSE +21 -0
- package/README.md +105 -228
- package/dist/alert/index.cjs +92 -166
- package/dist/alert/index.js +2 -1
- package/dist/app-bar/index.cjs +24 -98
- package/dist/app-bar/index.js +2 -1
- package/dist/autocomplete/index.cjs +192 -281
- package/dist/autocomplete/index.js +36 -48
- package/dist/avatar/index.cjs +59 -133
- package/dist/avatar/index.js +2 -1
- package/dist/badge/index.cjs +26 -99
- package/dist/badge/index.js +2 -1
- package/dist/bottom-sheet/index.cjs +5 -456
- package/dist/bottom-sheet/index.js +4 -363
- package/dist/bottom-tab-bar/index.cjs +93 -167
- package/dist/bottom-tab-bar/index.js +2 -2
- package/dist/button/index.cjs +73 -525
- package/dist/button/index.js +3 -2
- package/dist/card/index.cjs +76 -169
- package/dist/card/index.js +2 -2
- package/dist/carousel/index.cjs +68 -145
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +132 -173
- package/dist/checkbox/index.cjs +70 -143
- package/dist/checkbox/index.js +2 -1
- package/dist/chip/index.cjs +89 -164
- package/dist/chip/index.js +2 -1
- package/dist/chunk-BD72HIPR.cjs +75 -0
- package/dist/chunk-DHSTKO3K.cjs +19 -0
- package/dist/{chunk-CZFDZPAS.js → chunk-DXXNBF5P.js} +5 -0
- package/dist/{chunk-UI5L26KD.js → chunk-F7WH4DMG.js} +1 -1
- package/dist/chunk-GBHQCAKW.js +19 -0
- package/dist/chunk-HC2SSHNU.js +368 -0
- package/dist/chunk-HSPTLUFA.cjs +7 -0
- package/dist/chunk-JEGEPGVU.js +287 -0
- package/dist/chunk-KTLGDLCB.cjs +287 -0
- package/dist/{chunk-GHCVNQET.js → chunk-LTKYHG5V.js} +5 -12
- package/dist/{chunk-ULJSCNPE.js → chunk-LUBWRVI2.js} +1 -1
- package/dist/chunk-OQ2BLOOG.cjs +138 -0
- package/dist/chunk-QMYWIWSX.cjs +384 -0
- package/dist/chunk-XFPPR2VB.cjs +368 -0
- package/dist/core/index.cjs +22 -168
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +5 -3
- package/dist/datepicker/index.cjs +239 -320
- package/dist/datepicker/index.js +2 -1
- package/dist/divider/index.cjs +5 -145
- package/dist/divider/index.js +3 -2
- package/dist/drawer/index.cjs +39 -112
- package/dist/drawer/index.js +2 -1
- package/dist/expansion-panel/index.cjs +91 -230
- package/dist/expansion-panel/index.js +3 -2
- package/dist/fab/index.cjs +6 -722
- package/dist/fab/index.js +4 -3
- package/dist/fab-menu/index.cjs +81 -814
- package/dist/fab-menu/index.js +4 -3
- package/dist/feature-discovery/index.cjs +72 -139
- package/dist/feature-discovery/index.js +2 -2
- package/dist/index.cjs +1 -18
- package/dist/indicator/index.cjs +5 -445
- package/dist/indicator/index.js +3 -2
- package/dist/input/index.cjs +214 -282
- package/dist/input/index.js +2 -2
- package/dist/list/index.cjs +71 -146
- package/dist/list/index.js +2 -1
- package/dist/menu/index.cjs +59 -127
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +60 -132
- package/dist/menubox/index.js +2 -1
- package/dist/pager/index.cjs +42 -80
- package/dist/progress/index.cjs +43 -114
- package/dist/progress/index.js +2 -1
- package/dist/radio/index.cjs +82 -154
- package/dist/radio/index.js +2 -1
- package/dist/segment-button/index.cjs +60 -147
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.cjs +149 -224
- package/dist/select/index.js +10 -22
- package/dist/skeleton/index.cjs +23 -94
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +77 -156
- package/dist/slider/index.js +2 -1
- package/dist/snackbar/index.cjs +420 -0
- package/dist/snackbar/index.d.cts +175 -0
- package/dist/snackbar/index.d.ts +175 -0
- package/dist/snackbar/index.js +420 -0
- package/dist/stepper/index.cjs +121 -195
- package/dist/stepper/index.js +2 -1
- package/dist/switch/index.cjs +48 -121
- package/dist/switch/index.js +2 -1
- package/dist/tabs/index.cjs +67 -151
- package/dist/tabs/index.js +2 -1
- package/dist/timepicker/index.cjs +135 -593
- package/dist/timepicker/index.js +24 -383
- package/dist/toolbar/index.cjs +59 -128
- package/dist/toolbar/index.js +2 -1
- package/dist/typography/index.cjs +37 -92
- package/dist/typography/index.d.cts +1 -1
- package/dist/typography/index.d.ts +1 -1
- package/dist/typography/index.js +20 -1
- package/dist/view/index.cjs +178 -223
- package/package.json +6 -1
- package/dist/chunk-3XSXTM3G.js +0 -661
- package/dist/chunk-4KSZLONZ.js +0 -79
- package/dist/chunk-I4V5Y5GD.js +0 -76
- package/dist/chunk-URBEEDFX.js +0 -79
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckmarkIcon
|
|
3
|
+
} from "../chunk-GBHQCAKW.js";
|
|
4
|
+
import "../chunk-DXXNBF5P.js";
|
|
1
5
|
import {
|
|
2
6
|
Portal,
|
|
3
7
|
useXUITheme
|
|
4
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-LTKYHG5V.js";
|
|
5
9
|
|
|
6
10
|
// src/components/autocomplete/autocomplete.tsx
|
|
7
|
-
import
|
|
11
|
+
import React4, { useCallback as useCallback3, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
8
12
|
import { Keyboard as Keyboard2, Text as Text3, View as View4 } from "react-native";
|
|
9
13
|
|
|
10
14
|
// src/components/autocomplete/autocomplete-context.ts
|
|
@@ -314,7 +318,7 @@ var defaultFilterFunction = (textValue, inputValue) => {
|
|
|
314
318
|
};
|
|
315
319
|
|
|
316
320
|
// src/components/dialogs/autocomplete-dialog/autocomplete-dialog.tsx
|
|
317
|
-
import
|
|
321
|
+
import React2, { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
318
322
|
import {
|
|
319
323
|
Animated as Animated3,
|
|
320
324
|
BackHandler,
|
|
@@ -327,24 +331,8 @@ import {
|
|
|
327
331
|
useWindowDimensions
|
|
328
332
|
} from "react-native";
|
|
329
333
|
|
|
330
|
-
// src/components/select/checkmark-icon.tsx
|
|
331
|
-
import React from "react";
|
|
332
|
-
import Svg, { Polyline } from "react-native-svg";
|
|
333
|
-
function CheckmarkIcon({ color, size }) {
|
|
334
|
-
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 17 18", fill: "none" }, /* @__PURE__ */ React.createElement(
|
|
335
|
-
Polyline,
|
|
336
|
-
{
|
|
337
|
-
points: "1 9 7 14 15 4",
|
|
338
|
-
stroke: color,
|
|
339
|
-
strokeWidth: 2,
|
|
340
|
-
strokeLinecap: "round",
|
|
341
|
-
strokeLinejoin: "round"
|
|
342
|
-
}
|
|
343
|
-
));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
334
|
// src/components/dialogs/autocomplete-dialog/autocomplete-dialog-header.tsx
|
|
347
|
-
import
|
|
335
|
+
import React from "react";
|
|
348
336
|
import {
|
|
349
337
|
Animated,
|
|
350
338
|
Pressable,
|
|
@@ -447,7 +435,7 @@ var AutocompleteDialogHeader = ({
|
|
|
447
435
|
onBlur
|
|
448
436
|
}) => {
|
|
449
437
|
const theme = useXUITheme();
|
|
450
|
-
return /* @__PURE__ */
|
|
438
|
+
return /* @__PURE__ */ React.createElement(View, { style: styles2.header }, title ? /* @__PURE__ */ React.createElement(View, { style: styles2.titleRow }, /* @__PURE__ */ React.createElement(
|
|
451
439
|
Pressable,
|
|
452
440
|
{
|
|
453
441
|
style: styles2.backButton,
|
|
@@ -455,8 +443,8 @@ var AutocompleteDialogHeader = ({
|
|
|
455
443
|
accessibilityLabel: "Back",
|
|
456
444
|
accessibilityRole: "button"
|
|
457
445
|
},
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
), /* @__PURE__ */
|
|
446
|
+
/* @__PURE__ */ React.createElement(ArrowBackIcon, { size: 20, color: theme.colors.foreground })
|
|
447
|
+
), /* @__PURE__ */ React.createElement(Text, { style: [styles2.title, { color: theme.colors.foreground }] }, title)) : null, /* @__PURE__ */ React.createElement(View, { style: styles2.inputContainer }, /* @__PURE__ */ React.createElement(Animated.View, { style: [styles2.inputWrapper, inputAnimatedStyle] }, /* @__PURE__ */ React.createElement(
|
|
460
448
|
TextInput,
|
|
461
449
|
{
|
|
462
450
|
ref: inputRef,
|
|
@@ -478,7 +466,7 @@ var AutocompleteDialogHeader = ({
|
|
|
478
466
|
onFocus,
|
|
479
467
|
onBlur
|
|
480
468
|
}
|
|
481
|
-
), inputValue ? /* @__PURE__ */
|
|
469
|
+
), inputValue ? /* @__PURE__ */ React.createElement(
|
|
482
470
|
Pressable,
|
|
483
471
|
{
|
|
484
472
|
style: styles2.clearInputButton,
|
|
@@ -486,7 +474,7 @@ var AutocompleteDialogHeader = ({
|
|
|
486
474
|
accessibilityLabel: "Clear input",
|
|
487
475
|
accessibilityRole: "button"
|
|
488
476
|
},
|
|
489
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ React.createElement(CloseIcon, { color: theme.colors.foreground })
|
|
490
478
|
) : null)));
|
|
491
479
|
};
|
|
492
480
|
|
|
@@ -568,8 +556,8 @@ var AutocompleteDialog = ({
|
|
|
568
556
|
};
|
|
569
557
|
}, []);
|
|
570
558
|
const items = useMemo2(
|
|
571
|
-
() =>
|
|
572
|
-
|
|
559
|
+
() => React2.Children.toArray(children).filter(
|
|
560
|
+
React2.isValidElement
|
|
573
561
|
),
|
|
574
562
|
[children]
|
|
575
563
|
);
|
|
@@ -628,7 +616,7 @@ var AutocompleteDialog = ({
|
|
|
628
616
|
const inputAnimatedStyle = {
|
|
629
617
|
transform: [{ scaleX: scaleAnim }]
|
|
630
618
|
};
|
|
631
|
-
const listHeader = /* @__PURE__ */
|
|
619
|
+
const listHeader = /* @__PURE__ */ React2.createElement(
|
|
632
620
|
AutocompleteDialogHeader,
|
|
633
621
|
{
|
|
634
622
|
title,
|
|
@@ -644,13 +632,13 @@ var AutocompleteDialog = ({
|
|
|
644
632
|
onBlur
|
|
645
633
|
}
|
|
646
634
|
);
|
|
647
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ React2.createElement(Portal, null, /* @__PURE__ */ React2.createElement(View2, { style: [overlayStyle, style] }, /* @__PURE__ */ React2.createElement(Animated3.View, { style: [styles2.backdrop, { opacity: fadeAnim }] }), /* @__PURE__ */ React2.createElement(Animated3.View, { style: [styles2.dialogContainer, containerAnimatedStyle] }, /* @__PURE__ */ React2.createElement(
|
|
648
636
|
View2,
|
|
649
637
|
{
|
|
650
638
|
style: [styles2.container, { backgroundColor: theme.colors.background }]
|
|
651
639
|
},
|
|
652
640
|
listHeader,
|
|
653
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ React2.createElement(
|
|
654
642
|
FlatList,
|
|
655
643
|
{
|
|
656
644
|
data: items,
|
|
@@ -665,7 +653,7 @@ var AutocompleteDialog = ({
|
|
|
665
653
|
showsVerticalScrollIndicator: false
|
|
666
654
|
}
|
|
667
655
|
),
|
|
668
|
-
showCheckmark ? /* @__PURE__ */
|
|
656
|
+
showCheckmark ? /* @__PURE__ */ React2.createElement(View2, { style: styles2.checkmarkButtonContainer }, /* @__PURE__ */ React2.createElement(
|
|
669
657
|
Pressable2,
|
|
670
658
|
{
|
|
671
659
|
style: [
|
|
@@ -676,13 +664,13 @@ var AutocompleteDialog = ({
|
|
|
676
664
|
accessibilityLabel: "Confirm",
|
|
677
665
|
accessibilityRole: "button"
|
|
678
666
|
},
|
|
679
|
-
checkmarkIcon ?? /* @__PURE__ */
|
|
667
|
+
checkmarkIcon ?? /* @__PURE__ */ React2.createElement(CheckmarkIcon, { color: checkmarkColor, size: 20 })
|
|
680
668
|
)) : null
|
|
681
669
|
))));
|
|
682
670
|
};
|
|
683
671
|
|
|
684
672
|
// src/components/autocomplete/autocomplete-trigger.tsx
|
|
685
|
-
import
|
|
673
|
+
import React3 from "react";
|
|
686
674
|
import { Pressable as Pressable3, Text as Text2, TouchableOpacity, View as View3 } from "react-native";
|
|
687
675
|
import { CloseIcon as CloseIcon2 } from "@xaui/icons";
|
|
688
676
|
var AutocompleteTrigger = ({
|
|
@@ -707,7 +695,7 @@ var AutocompleteTrigger = ({
|
|
|
707
695
|
onLayout: handleTriggerLayout
|
|
708
696
|
}) => {
|
|
709
697
|
const renderLabel = isLabelInside && label;
|
|
710
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ React3.createElement(
|
|
711
699
|
Pressable3,
|
|
712
700
|
{
|
|
713
701
|
ref: triggerRef,
|
|
@@ -730,7 +718,7 @@ var AutocompleteTrigger = ({
|
|
|
730
718
|
accessibilityRole: "button",
|
|
731
719
|
accessibilityState: { disabled: isDisabled }
|
|
732
720
|
},
|
|
733
|
-
/* @__PURE__ */
|
|
721
|
+
/* @__PURE__ */ React3.createElement(View3, { style: styles.triggerContent }, isLabelInside && renderLabel, /* @__PURE__ */ React3.createElement(
|
|
734
722
|
Text2,
|
|
735
723
|
{
|
|
736
724
|
style: [
|
|
@@ -744,14 +732,14 @@ var AutocompleteTrigger = ({
|
|
|
744
732
|
},
|
|
745
733
|
displayValue
|
|
746
734
|
)),
|
|
747
|
-
isClearable && (currentSelectedKey || currentInputValue) ? /* @__PURE__ */
|
|
735
|
+
isClearable && (currentSelectedKey || currentInputValue) ? /* @__PURE__ */ React3.createElement(
|
|
748
736
|
TouchableOpacity,
|
|
749
737
|
{
|
|
750
738
|
onPress: handleClear,
|
|
751
739
|
style: styles.clearButton,
|
|
752
740
|
hitSlop: { top: 8, right: 8, bottom: 8, left: 8 }
|
|
753
741
|
},
|
|
754
|
-
clearIcon ?? /* @__PURE__ */
|
|
742
|
+
clearIcon ?? /* @__PURE__ */ React3.createElement(CloseIcon2, { color: theme.colors.foreground, size: 20 })
|
|
755
743
|
) : null
|
|
756
744
|
);
|
|
757
745
|
};
|
|
@@ -810,9 +798,9 @@ var Autocomplete = ({
|
|
|
810
798
|
});
|
|
811
799
|
}, []);
|
|
812
800
|
const items = useMemo3(() => {
|
|
813
|
-
const elements =
|
|
801
|
+
const elements = React4.Children.toArray(children).filter(Boolean);
|
|
814
802
|
return elements.map((child, index) => {
|
|
815
|
-
if (!
|
|
803
|
+
if (!React4.isValidElement(child)) {
|
|
816
804
|
return null;
|
|
817
805
|
}
|
|
818
806
|
const key = child.props.value ?? String(index);
|
|
@@ -905,7 +893,7 @@ var Autocomplete = ({
|
|
|
905
893
|
handleItemSelection(item.key, item.labelText);
|
|
906
894
|
itemProps.onSelected?.();
|
|
907
895
|
};
|
|
908
|
-
return
|
|
896
|
+
return React4.cloneElement(item.element, {
|
|
909
897
|
key: item.key,
|
|
910
898
|
isDisabled: itemDisabled,
|
|
911
899
|
isSelected: itemSelected,
|
|
@@ -916,10 +904,10 @@ var Autocomplete = ({
|
|
|
916
904
|
const isLabelInside = labelPlacement === "inside";
|
|
917
905
|
const isLabelOutsideLeft = labelPlacement === "outside-left";
|
|
918
906
|
const isLabelOutside = labelPlacement === "outside" || labelPlacement === "outside-top";
|
|
919
|
-
const renderLabel = label ? typeof label === "string" || typeof label === "number" ? /* @__PURE__ */
|
|
907
|
+
const renderLabel = label ? typeof label === "string" || typeof label === "number" ? /* @__PURE__ */ React4.createElement(Text3, { style: [styles.label, labelStyle] }, label) : /* @__PURE__ */ React4.createElement(View4, null, label) : null;
|
|
920
908
|
const shouldShowHelper = Boolean(description || errorMessage);
|
|
921
909
|
const helperContent = isInvalid && errorMessage ? errorMessage : description;
|
|
922
|
-
const triggerContent = /* @__PURE__ */
|
|
910
|
+
const triggerContent = /* @__PURE__ */ React4.createElement(
|
|
923
911
|
AutocompleteTrigger,
|
|
924
912
|
{
|
|
925
913
|
triggerRef,
|
|
@@ -944,7 +932,7 @@ var Autocomplete = ({
|
|
|
944
932
|
}
|
|
945
933
|
);
|
|
946
934
|
const labelBlock = isLabelOutside || isLabelInside ? renderLabel : null;
|
|
947
|
-
return /* @__PURE__ */
|
|
935
|
+
return /* @__PURE__ */ React4.createElement(View4, { style: [styles.container, fullWidth ? styles.fullWidth : styles.minWidth] }, isLabelOutside && labelBlock, isLabelOutsideLeft ? /* @__PURE__ */ React4.createElement(View4, { style: styles.outsideLeftRow }, renderLabel, triggerContent) : triggerContent, shouldShowHelper && helperContent ? typeof helperContent === "string" || typeof helperContent === "number" ? /* @__PURE__ */ React4.createElement(Text3, { style: [styles.helperText, { color: helperColor }] }, helperContent) : /* @__PURE__ */ React4.createElement(View4, null, helperContent) : null, /* @__PURE__ */ React4.createElement(
|
|
948
936
|
AutocompleteDialog,
|
|
949
937
|
{
|
|
950
938
|
visible: isOpen,
|
|
@@ -958,12 +946,12 @@ var Autocomplete = ({
|
|
|
958
946
|
onClose: () => setOpen(false),
|
|
959
947
|
onCheckmark: handleCheckmark
|
|
960
948
|
},
|
|
961
|
-
/* @__PURE__ */
|
|
949
|
+
/* @__PURE__ */ React4.createElement(AutocompleteContext.Provider, { value: { size, themeColor, isDisabled } }, showEmptyMessage ? /* @__PURE__ */ React4.createElement(Text3, { style: [styles.emptyMessage, { color: theme.colors.foreground }] }, "No results found") : listItems)
|
|
962
950
|
));
|
|
963
951
|
};
|
|
964
952
|
|
|
965
953
|
// src/components/autocomplete/autocomplete-item.tsx
|
|
966
|
-
import
|
|
954
|
+
import React5, { useContext as useContext2 } from "react";
|
|
967
955
|
import { Pressable as Pressable4, Text as Text4, View as View5 } from "react-native";
|
|
968
956
|
|
|
969
957
|
// src/components/autocomplete/autocomplete-item.style.ts
|
|
@@ -1093,7 +1081,7 @@ var AutocompleteItem = ({
|
|
|
1093
1081
|
}
|
|
1094
1082
|
onSelected?.();
|
|
1095
1083
|
};
|
|
1096
|
-
return /* @__PURE__ */
|
|
1084
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1097
1085
|
Pressable4,
|
|
1098
1086
|
{
|
|
1099
1087
|
onPress: handlePress,
|
|
@@ -1110,7 +1098,7 @@ var AutocompleteItem = ({
|
|
|
1110
1098
|
]
|
|
1111
1099
|
},
|
|
1112
1100
|
startContent,
|
|
1113
|
-
/* @__PURE__ */
|
|
1101
|
+
/* @__PURE__ */ React5.createElement(View5, { style: styles3.content }, /* @__PURE__ */ React5.createElement(
|
|
1114
1102
|
Text4,
|
|
1115
1103
|
{
|
|
1116
1104
|
style: [
|
|
@@ -1120,7 +1108,7 @@ var AutocompleteItem = ({
|
|
|
1120
1108
|
]
|
|
1121
1109
|
},
|
|
1122
1110
|
label
|
|
1123
|
-
), description && /* @__PURE__ */
|
|
1111
|
+
), description && /* @__PURE__ */ React5.createElement(
|
|
1124
1112
|
Text4,
|
|
1125
1113
|
{
|
|
1126
1114
|
style: [
|
package/dist/avatar/index.cjs
CHANGED
|
@@ -1,47 +1,15 @@
|
|
|
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);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-HSPTLUFA.cjs');
|
|
29
2
|
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
__export(avatar_exports, {
|
|
33
|
-
Avatar: () => Avatar,
|
|
34
|
-
AvatarGroup: () => AvatarGroup
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(avatar_exports);
|
|
3
|
+
|
|
4
|
+
var _chunkOQ2BLOOGcjs = require('../chunk-OQ2BLOOG.cjs');
|
|
37
5
|
|
|
38
6
|
// src/components/avatar/avatar.tsx
|
|
39
|
-
var
|
|
40
|
-
var
|
|
7
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
8
|
+
var _reactnative = require('react-native');
|
|
41
9
|
|
|
42
10
|
// src/components/avatar/avatar.style.ts
|
|
43
|
-
|
|
44
|
-
var styles =
|
|
11
|
+
|
|
12
|
+
var styles = _reactnative.StyleSheet.create({
|
|
45
13
|
container: {
|
|
46
14
|
overflow: "hidden",
|
|
47
15
|
alignItems: "center",
|
|
@@ -67,49 +35,8 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
67
35
|
});
|
|
68
36
|
|
|
69
37
|
// src/components/avatar/avatar.hook.ts
|
|
70
|
-
var import_react6 = require("react");
|
|
71
|
-
var import_core = require("@xaui/core");
|
|
72
|
-
|
|
73
|
-
// src/core/theme-context.tsx
|
|
74
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
75
|
-
var import_react_native3 = require("react-native");
|
|
76
|
-
var import_theme = require("@xaui/core/theme");
|
|
77
|
-
var import_palette = require("@xaui/core/palette");
|
|
78
|
-
|
|
79
|
-
// src/core/portal/portal.tsx
|
|
80
|
-
var import_react2 = require("react");
|
|
81
|
-
|
|
82
|
-
// src/core/portal/portal-context.ts
|
|
83
|
-
var import_react = require("react");
|
|
84
|
-
var PortalContext = (0, import_react.createContext)(null);
|
|
85
|
-
|
|
86
|
-
// src/core/portal/portal-host.tsx
|
|
87
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
88
|
-
var import_react_native2 = require("react-native");
|
|
89
|
-
var hostStyles = import_react_native2.StyleSheet.create({
|
|
90
|
-
container: {
|
|
91
|
-
flex: 1
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
38
|
|
|
95
|
-
|
|
96
|
-
var XUIThemeContext = (0, import_react4.createContext)(null);
|
|
97
|
-
|
|
98
|
-
// src/core/theme-hooks.ts
|
|
99
|
-
var import_react5 = require("react");
|
|
100
|
-
var import_react_native4 = require("react-native");
|
|
101
|
-
function useXUITheme() {
|
|
102
|
-
const theme = (0, import_react5.useContext)(XUIThemeContext);
|
|
103
|
-
if (!theme) {
|
|
104
|
-
throw new Error("useXUITheme must be used within XUIProvider");
|
|
105
|
-
}
|
|
106
|
-
return theme;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/core/index.ts
|
|
110
|
-
var import_theme2 = require("@xaui/core/theme");
|
|
111
|
-
|
|
112
|
-
// src/components/avatar/avatar.hook.ts
|
|
39
|
+
var _core = require('@xaui/core');
|
|
113
40
|
var sizeMap = {
|
|
114
41
|
xs: 24,
|
|
115
42
|
sm: 32,
|
|
@@ -123,9 +50,9 @@ function resolveAvatarSize(size) {
|
|
|
123
50
|
return sizeMap[size];
|
|
124
51
|
}
|
|
125
52
|
function useAvatarSizeStyles(size) {
|
|
126
|
-
const theme = useXUITheme();
|
|
127
|
-
const resolvedSize = (0,
|
|
128
|
-
const fontSize = (0,
|
|
53
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
54
|
+
const resolvedSize = _react.useMemo.call(void 0, () => resolveAvatarSize(size), [size]);
|
|
55
|
+
const fontSize = _react.useMemo.call(void 0, () => {
|
|
129
56
|
if (typeof size === "number") {
|
|
130
57
|
return Math.max(10, Math.round(size * 0.4));
|
|
131
58
|
}
|
|
@@ -137,8 +64,8 @@ function useAvatarSizeStyles(size) {
|
|
|
137
64
|
};
|
|
138
65
|
}
|
|
139
66
|
function useAvatarRadiusStyles(radius, size) {
|
|
140
|
-
const theme = useXUITheme();
|
|
141
|
-
return (0,
|
|
67
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
68
|
+
return _react.useMemo.call(void 0, () => {
|
|
142
69
|
if (radius === "full") {
|
|
143
70
|
return { borderRadius: size / 2 };
|
|
144
71
|
}
|
|
@@ -153,16 +80,16 @@ function useAvatarRadiusStyles(radius, size) {
|
|
|
153
80
|
}, [radius, size, theme]);
|
|
154
81
|
}
|
|
155
82
|
function useAvatarColors(themeColor, isDisabled) {
|
|
156
|
-
const theme = useXUITheme();
|
|
157
|
-
const safeThemeColor = (0,
|
|
83
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
84
|
+
const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
158
85
|
const colorScheme = theme.colors[safeThemeColor];
|
|
159
|
-
const backgroundColor = (0,
|
|
86
|
+
const backgroundColor = _react.useMemo.call(void 0, () => {
|
|
160
87
|
if (isDisabled) {
|
|
161
88
|
return theme.colors.background;
|
|
162
89
|
}
|
|
163
90
|
return colorScheme.background;
|
|
164
91
|
}, [colorScheme.background, isDisabled, theme.colors.background]);
|
|
165
|
-
const textColor = (0,
|
|
92
|
+
const textColor = _react.useMemo.call(void 0, () => {
|
|
166
93
|
if (safeThemeColor === "default") {
|
|
167
94
|
return theme.colors.foreground;
|
|
168
95
|
}
|
|
@@ -201,18 +128,18 @@ var Avatar = ({
|
|
|
201
128
|
getInitials,
|
|
202
129
|
customAppearance
|
|
203
130
|
}) => {
|
|
204
|
-
const [isError, setIsError] =
|
|
131
|
+
const [isError, setIsError] = _react2.default.useState(false);
|
|
205
132
|
const { size: resolvedSize, fontSize } = useAvatarSizeStyles(size);
|
|
206
133
|
const radiusStyles = useAvatarRadiusStyles(radius, resolvedSize);
|
|
207
134
|
const { backgroundColor, textColor, borderColor } = useAvatarColors(
|
|
208
135
|
themeColor,
|
|
209
136
|
isDisabled
|
|
210
137
|
);
|
|
211
|
-
const accessibilityLabel = name
|
|
138
|
+
const accessibilityLabel = _nullishCoalesce(name, () => ( "Avatar"));
|
|
212
139
|
const shouldShowFallback = showFallback || !src || isError;
|
|
213
|
-
const initials = name ? (getInitials
|
|
214
|
-
return /* @__PURE__ */
|
|
215
|
-
|
|
140
|
+
const initials = name ? (_nullishCoalesce(getInitials, () => ( getDefaultInitials)))(name) : "";
|
|
141
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
142
|
+
_reactnative.View,
|
|
216
143
|
{
|
|
217
144
|
style: [
|
|
218
145
|
styles.container,
|
|
@@ -225,22 +152,22 @@ var Avatar = ({
|
|
|
225
152
|
borderColor: isBordered ? borderColor : "transparent"
|
|
226
153
|
},
|
|
227
154
|
radiusStyles,
|
|
228
|
-
customAppearance
|
|
155
|
+
_optionalChain([customAppearance, 'optionalAccess', _ => _.container])
|
|
229
156
|
],
|
|
230
157
|
accessible: true,
|
|
231
158
|
accessibilityRole: "image",
|
|
232
159
|
accessibilityLabel
|
|
233
160
|
},
|
|
234
|
-
!shouldShowFallback && src ? /* @__PURE__ */
|
|
235
|
-
|
|
161
|
+
!shouldShowFallback && src ? /* @__PURE__ */ _react2.default.createElement(
|
|
162
|
+
_reactnative.Image,
|
|
236
163
|
{
|
|
237
164
|
source: { uri: src },
|
|
238
|
-
style: [styles.image, radiusStyles, customAppearance
|
|
165
|
+
style: [styles.image, radiusStyles, _optionalChain([customAppearance, 'optionalAccess', _2 => _2.image])],
|
|
239
166
|
accessibilityLabel,
|
|
240
167
|
onError: () => setIsError(true)
|
|
241
168
|
}
|
|
242
|
-
) : /* @__PURE__ */
|
|
243
|
-
|
|
169
|
+
) : /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.fallback, { width: "100%", height: "100%" }] }, _nullishCoalesce(_nullishCoalesce(fallback, () => ( icon)), () => ( /* @__PURE__ */ _react2.default.createElement(
|
|
170
|
+
_reactnative.Text,
|
|
244
171
|
{
|
|
245
172
|
style: [
|
|
246
173
|
{
|
|
@@ -248,17 +175,17 @@ var Avatar = ({
|
|
|
248
175
|
fontSize,
|
|
249
176
|
fontWeight: "600"
|
|
250
177
|
},
|
|
251
|
-
customAppearance
|
|
178
|
+
_optionalChain([customAppearance, 'optionalAccess', _3 => _3.text])
|
|
252
179
|
]
|
|
253
180
|
},
|
|
254
181
|
initials
|
|
255
|
-
))
|
|
182
|
+
))))
|
|
256
183
|
);
|
|
257
184
|
};
|
|
258
185
|
|
|
259
186
|
// src/components/avatar/avatar-group.tsx
|
|
260
|
-
|
|
261
|
-
|
|
187
|
+
|
|
188
|
+
|
|
262
189
|
var AvatarGroup = ({
|
|
263
190
|
children,
|
|
264
191
|
max,
|
|
@@ -272,35 +199,35 @@ var AvatarGroup = ({
|
|
|
272
199
|
renderCount,
|
|
273
200
|
customAppearance
|
|
274
201
|
}) => {
|
|
275
|
-
const theme = useXUITheme();
|
|
202
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
276
203
|
const resolvedSize = resolveAvatarSize(size);
|
|
277
204
|
const spacing = theme.spacing.xs;
|
|
278
205
|
const overlap = Math.round(resolvedSize * 0.28);
|
|
279
|
-
const allChildren =
|
|
280
|
-
(child) =>
|
|
206
|
+
const allChildren = _react2.default.Children.toArray(children).filter(
|
|
207
|
+
(child) => _react2.default.isValidElement(child)
|
|
281
208
|
);
|
|
282
|
-
const totalCount = total
|
|
283
|
-
const maxCount = max
|
|
209
|
+
const totalCount = _nullishCoalesce(total, () => ( allChildren.length));
|
|
210
|
+
const maxCount = _nullishCoalesce(max, () => ( totalCount));
|
|
284
211
|
const visibleChildren = allChildren.slice(0, maxCount);
|
|
285
212
|
const remaining = Math.max(0, totalCount - maxCount);
|
|
286
213
|
const enhanced = visibleChildren.map((child, index) => {
|
|
287
214
|
const childProps = child.props;
|
|
288
|
-
return /* @__PURE__ */
|
|
289
|
-
|
|
215
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
216
|
+
_reactnative.View,
|
|
290
217
|
{
|
|
291
|
-
key: child.key
|
|
218
|
+
key: _nullishCoalesce(child.key, () => ( index)),
|
|
292
219
|
style: isGrid ? { marginRight: spacing, marginBottom: spacing } : { marginLeft: index === 0 ? 0 : -overlap, zIndex: index }
|
|
293
220
|
},
|
|
294
|
-
|
|
295
|
-
size: childProps.size
|
|
296
|
-
radius: childProps.radius
|
|
297
|
-
themeColor: childProps.themeColor
|
|
298
|
-
isBordered: childProps.isBordered
|
|
299
|
-
isDisabled: childProps.isDisabled
|
|
221
|
+
_react2.default.cloneElement(child, {
|
|
222
|
+
size: _nullishCoalesce(childProps.size, () => ( size)),
|
|
223
|
+
radius: _nullishCoalesce(childProps.radius, () => ( radius)),
|
|
224
|
+
themeColor: _nullishCoalesce(childProps.themeColor, () => ( themeColor)),
|
|
225
|
+
isBordered: _nullishCoalesce(childProps.isBordered, () => ( isBordered)),
|
|
226
|
+
isDisabled: _nullishCoalesce(childProps.isDisabled, () => ( isDisabled))
|
|
300
227
|
})
|
|
301
228
|
);
|
|
302
229
|
});
|
|
303
|
-
const countNode = remaining > 0 ? renderCount
|
|
230
|
+
const countNode = remaining > 0 ? _nullishCoalesce(_optionalChain([renderCount, 'optionalCall', _4 => _4(remaining)]), () => ( /* @__PURE__ */ _react2.default.createElement(
|
|
304
231
|
Avatar,
|
|
305
232
|
{
|
|
306
233
|
name: `+${remaining}`,
|
|
@@ -310,8 +237,8 @@ var AvatarGroup = ({
|
|
|
310
237
|
themeColor,
|
|
311
238
|
isBordered,
|
|
312
239
|
isDisabled,
|
|
313
|
-
fallback: /* @__PURE__ */
|
|
314
|
-
|
|
240
|
+
fallback: /* @__PURE__ */ _react2.default.createElement(
|
|
241
|
+
_reactnative.Text,
|
|
315
242
|
{
|
|
316
243
|
style: {
|
|
317
244
|
color: theme.colors.foreground,
|
|
@@ -323,11 +250,11 @@ var AvatarGroup = ({
|
|
|
323
250
|
remaining
|
|
324
251
|
)
|
|
325
252
|
}
|
|
326
|
-
) : null;
|
|
253
|
+
))) : null;
|
|
327
254
|
if (countNode) {
|
|
328
255
|
enhanced.push(
|
|
329
|
-
/* @__PURE__ */
|
|
330
|
-
|
|
256
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
257
|
+
_reactnative.View,
|
|
331
258
|
{
|
|
332
259
|
key: "avatar-count",
|
|
333
260
|
style: isGrid ? { marginRight: spacing, marginBottom: spacing } : {
|
|
@@ -339,17 +266,16 @@ var AvatarGroup = ({
|
|
|
339
266
|
)
|
|
340
267
|
);
|
|
341
268
|
}
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
|
|
269
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
270
|
+
_reactnative.View,
|
|
344
271
|
{
|
|
345
|
-
style: [isGrid ? styles.grid : styles.group, customAppearance
|
|
272
|
+
style: [isGrid ? styles.grid : styles.group, _optionalChain([customAppearance, 'optionalAccess', _5 => _5.container])],
|
|
346
273
|
accessible: true
|
|
347
274
|
},
|
|
348
275
|
enhanced
|
|
349
276
|
);
|
|
350
277
|
};
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
});
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
exports.Avatar = Avatar; exports.AvatarGroup = AvatarGroup;
|