@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/index.cjs
CHANGED
|
@@ -38,11 +38,17 @@ __export(src_exports, {
|
|
|
38
38
|
AvatarGroup: () => AvatarGroup,
|
|
39
39
|
Badge: () => Badge,
|
|
40
40
|
BottomSheet: () => BottomSheet,
|
|
41
|
+
Carousel: () => Carousel,
|
|
41
42
|
Chip: () => Chip,
|
|
42
43
|
ChipGroup: () => ChipGroup,
|
|
43
44
|
ChipItem: () => ChipItem,
|
|
44
45
|
DatePicker: () => DatePicker,
|
|
45
46
|
Divider: () => Divider,
|
|
47
|
+
Fab: () => Fab,
|
|
48
|
+
FabMenu: () => FabMenu,
|
|
49
|
+
FabMenuItem: () => FabMenuItem,
|
|
50
|
+
SegmentButton: () => SegmentButton,
|
|
51
|
+
SegmentButtonItem: () => SegmentButtonItem,
|
|
46
52
|
Typography: () => Typography
|
|
47
53
|
});
|
|
48
54
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -1445,7 +1451,7 @@ var useAutocompleteVariantStyles = (themeColor, variant, isInvalid) => {
|
|
|
1445
1451
|
if ((variant === "outlined" || variant === "faded") && themeColor === "default") {
|
|
1446
1452
|
borderColor = import_palette2.colors.gray[300];
|
|
1447
1453
|
}
|
|
1448
|
-
const
|
|
1454
|
+
const styles18 = {
|
|
1449
1455
|
outlined: {
|
|
1450
1456
|
backgroundColor: "transparent",
|
|
1451
1457
|
borderWidth: theme.borderWidth.md,
|
|
@@ -1470,7 +1476,7 @@ var useAutocompleteVariantStyles = (themeColor, variant, isInvalid) => {
|
|
|
1470
1476
|
borderColor
|
|
1471
1477
|
}
|
|
1472
1478
|
};
|
|
1473
|
-
return
|
|
1479
|
+
return styles18[variant];
|
|
1474
1480
|
}, [variant, theme, colorScheme, isInvalid, themeColor]);
|
|
1475
1481
|
};
|
|
1476
1482
|
var useAutocompleteLabelStyle = (themeColor, isInvalid, labelSize) => {
|
|
@@ -1769,13 +1775,7 @@ var styles7 = import_react_native18.StyleSheet.create({
|
|
|
1769
1775
|
});
|
|
1770
1776
|
|
|
1771
1777
|
// src/components/dialogs/autocomplete-dialog/autocomplete-dialog-header.tsx
|
|
1772
|
-
var
|
|
1773
|
-
const hex = color.replace("#", "");
|
|
1774
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
1775
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
1776
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
1777
|
-
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
1778
|
-
};
|
|
1778
|
+
var import_core17 = require("@xaui/core");
|
|
1779
1779
|
var AutocompleteDialogHeader = ({
|
|
1780
1780
|
title,
|
|
1781
1781
|
inputValue,
|
|
@@ -1806,7 +1806,7 @@ var AutocompleteDialogHeader = ({
|
|
|
1806
1806
|
value: inputValue,
|
|
1807
1807
|
onChangeText: onInputChange,
|
|
1808
1808
|
placeholder,
|
|
1809
|
-
placeholderTextColor:
|
|
1809
|
+
placeholderTextColor: (0, import_core17.withOpacity)(theme.colors.foreground, 0.5),
|
|
1810
1810
|
style: [
|
|
1811
1811
|
styles7.input,
|
|
1812
1812
|
{
|
|
@@ -2334,7 +2334,7 @@ var styles8 = import_react_native24.StyleSheet.create({
|
|
|
2334
2334
|
|
|
2335
2335
|
// src/components/autocomplete/autocomplete-item.hook.ts
|
|
2336
2336
|
var import_react29 = require("react");
|
|
2337
|
-
var
|
|
2337
|
+
var import_core20 = require("@xaui/core");
|
|
2338
2338
|
var useAutocompleteItemSizeStyles = (size) => {
|
|
2339
2339
|
const theme = useXUITheme();
|
|
2340
2340
|
return (0, import_react29.useMemo)(() => {
|
|
@@ -2369,7 +2369,7 @@ var useAutocompleteItemSizeStyles = (size) => {
|
|
|
2369
2369
|
};
|
|
2370
2370
|
var useAutocompleteItemBackgroundColor = (themeColor, isSelected) => {
|
|
2371
2371
|
const theme = useXUITheme();
|
|
2372
|
-
const safeThemeColor = (0,
|
|
2372
|
+
const safeThemeColor = (0, import_core20.getSafeThemeColor)(themeColor);
|
|
2373
2373
|
const colorScheme = theme.colors[safeThemeColor];
|
|
2374
2374
|
return (0, import_react29.useMemo)(() => {
|
|
2375
2375
|
return "transparent";
|
|
@@ -2386,7 +2386,7 @@ var useAutocompleteItemTextColors = () => {
|
|
|
2386
2386
|
};
|
|
2387
2387
|
var useAutocompleteItemCheckmarkColor = (themeColor) => {
|
|
2388
2388
|
const theme = useXUITheme();
|
|
2389
|
-
const safeThemeColor = (0,
|
|
2389
|
+
const safeThemeColor = (0, import_core20.getSafeThemeColor)(themeColor);
|
|
2390
2390
|
const colorScheme = theme.colors[safeThemeColor];
|
|
2391
2391
|
return (0, import_react29.useMemo)(() => {
|
|
2392
2392
|
if (themeColor === "default") {
|
|
@@ -2483,11 +2483,11 @@ var import_react_native35 = require("react-native");
|
|
|
2483
2483
|
|
|
2484
2484
|
// src/components/datepicker/datepicker.hook.ts
|
|
2485
2485
|
var import_react31 = require("react");
|
|
2486
|
-
var
|
|
2486
|
+
var import_core22 = require("@xaui/core");
|
|
2487
2487
|
var import_palette3 = require("@xaui/core/palette");
|
|
2488
2488
|
var useDatePickerColorScheme = (themeColor) => {
|
|
2489
2489
|
const theme = useXUITheme();
|
|
2490
|
-
const safeThemeColor = (0,
|
|
2490
|
+
const safeThemeColor = (0, import_core22.getSafeThemeColor)(themeColor);
|
|
2491
2491
|
const colorScheme = theme.colors[safeThemeColor];
|
|
2492
2492
|
return { theme, colorScheme };
|
|
2493
2493
|
};
|
|
@@ -4100,7 +4100,7 @@ var styles11 = import_react_native36.StyleSheet.create({
|
|
|
4100
4100
|
|
|
4101
4101
|
// src/components/typography/typography.hook.ts
|
|
4102
4102
|
var import_react41 = require("react");
|
|
4103
|
-
var
|
|
4103
|
+
var import_core31 = require("@xaui/core");
|
|
4104
4104
|
var knownVariants = {
|
|
4105
4105
|
caption: true,
|
|
4106
4106
|
headlineLarge: true,
|
|
@@ -4122,7 +4122,7 @@ var useTypographyColor = (themeColor) => {
|
|
|
4122
4122
|
if (themeColor === "default") {
|
|
4123
4123
|
return theme.colors.foreground;
|
|
4124
4124
|
}
|
|
4125
|
-
const safeThemeColor = (0,
|
|
4125
|
+
const safeThemeColor = (0, import_core31.getSafeThemeColor)(themeColor);
|
|
4126
4126
|
return theme.colors[safeThemeColor].main;
|
|
4127
4127
|
}, [theme, themeColor]);
|
|
4128
4128
|
return color;
|
|
@@ -4137,7 +4137,7 @@ var useTypographyVariantStyles = (variant) => {
|
|
|
4137
4137
|
fontWeight: theme.fontWeights.normal
|
|
4138
4138
|
};
|
|
4139
4139
|
}
|
|
4140
|
-
const
|
|
4140
|
+
const styles18 = {
|
|
4141
4141
|
caption: {
|
|
4142
4142
|
fontFamily: theme.fontFamilies.body,
|
|
4143
4143
|
fontSize: theme.fontSizes.xs,
|
|
@@ -4189,7 +4189,7 @@ var useTypographyVariantStyles = (variant) => {
|
|
|
4189
4189
|
fontWeight: theme.fontWeights.normal
|
|
4190
4190
|
}
|
|
4191
4191
|
};
|
|
4192
|
-
return
|
|
4192
|
+
return styles18[variant];
|
|
4193
4193
|
}, [theme, variant]);
|
|
4194
4194
|
return variantStyles;
|
|
4195
4195
|
};
|
|
@@ -4229,298 +4229,1058 @@ var Typography = ({
|
|
|
4229
4229
|
);
|
|
4230
4230
|
};
|
|
4231
4231
|
|
|
4232
|
-
// src/components/
|
|
4233
|
-
var
|
|
4234
|
-
var
|
|
4232
|
+
// src/components/carousel/carousel.tsx
|
|
4233
|
+
var import_react46 = __toESM(require("react"), 1);
|
|
4234
|
+
var import_react_native40 = require("react-native");
|
|
4235
|
+
var import_react_native_reanimated5 = __toESM(require("react-native-reanimated"), 1);
|
|
4235
4236
|
|
|
4236
|
-
// src/components/
|
|
4237
|
+
// src/components/carousel/carousel.style.ts
|
|
4237
4238
|
var import_react_native38 = require("react-native");
|
|
4238
4239
|
var styles12 = import_react_native38.StyleSheet.create({
|
|
4239
|
-
|
|
4240
|
+
scrollContent: {
|
|
4240
4241
|
flexDirection: "row",
|
|
4241
|
-
alignItems: "center"
|
|
4242
|
-
alignSelf: "flex-start"
|
|
4243
|
-
},
|
|
4244
|
-
text: {
|
|
4245
|
-
fontWeight: "500",
|
|
4246
|
-
includeFontPadding: false,
|
|
4247
|
-
textAlignVertical: "center"
|
|
4248
|
-
},
|
|
4249
|
-
disabled: {
|
|
4250
|
-
opacity: 0.5
|
|
4251
|
-
},
|
|
4252
|
-
avatar: {
|
|
4253
|
-
marginRight: 4
|
|
4254
|
-
},
|
|
4255
|
-
startContent: {
|
|
4256
|
-
marginRight: 4
|
|
4242
|
+
alignItems: "center"
|
|
4257
4243
|
},
|
|
4258
|
-
|
|
4259
|
-
|
|
4244
|
+
item: {
|
|
4245
|
+
overflow: "hidden"
|
|
4260
4246
|
},
|
|
4261
|
-
|
|
4262
|
-
|
|
4247
|
+
indicatorContainer: {
|
|
4248
|
+
flexDirection: "row",
|
|
4249
|
+
justifyContent: "center",
|
|
4263
4250
|
alignItems: "center",
|
|
4264
|
-
|
|
4251
|
+
paddingVertical: 12,
|
|
4252
|
+
gap: 8
|
|
4265
4253
|
},
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4254
|
+
indicator: {
|
|
4255
|
+
width: 8,
|
|
4256
|
+
height: 8,
|
|
4257
|
+
borderRadius: 4,
|
|
4258
|
+
backgroundColor: "#CAC4D0"
|
|
4269
4259
|
},
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4260
|
+
activeIndicator: {
|
|
4261
|
+
width: 24,
|
|
4262
|
+
borderRadius: 4,
|
|
4263
|
+
backgroundColor: "#49454F"
|
|
4273
4264
|
}
|
|
4274
4265
|
});
|
|
4275
4266
|
|
|
4276
|
-
// src/components/
|
|
4267
|
+
// src/components/carousel/carousel.hook.ts
|
|
4277
4268
|
var import_react43 = require("react");
|
|
4278
|
-
var
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
md: 10,
|
|
4287
|
-
lg: 11
|
|
4288
|
-
};
|
|
4289
|
-
var closeSizeMap = {
|
|
4290
|
-
sm: 14,
|
|
4291
|
-
md: 16,
|
|
4292
|
-
lg: 17
|
|
4293
|
-
};
|
|
4294
|
-
function useChipSizeStyles(size) {
|
|
4295
|
-
return (0, import_react43.useMemo)(() => {
|
|
4296
|
-
const { height, paddingH, fontSize } = sizeMap3[size];
|
|
4297
|
-
return { height, paddingHorizontal: paddingH, fontSize };
|
|
4298
|
-
}, [size]);
|
|
4269
|
+
var HERO_PEEK_WIDTH = 56;
|
|
4270
|
+
function computeMultiBrowseLayout(config) {
|
|
4271
|
+
const { preferredItemWidth, itemSpacing } = config;
|
|
4272
|
+
return {
|
|
4273
|
+
computedItemWidth: preferredItemWidth,
|
|
4274
|
+
snapInterval: preferredItemWidth + itemSpacing,
|
|
4275
|
+
pagingEnabled: false
|
|
4276
|
+
};
|
|
4299
4277
|
}
|
|
4300
|
-
function
|
|
4301
|
-
|
|
4278
|
+
function computeUncontainedLayout(config) {
|
|
4279
|
+
const { preferredItemWidth, itemSpacing } = config;
|
|
4280
|
+
return {
|
|
4281
|
+
computedItemWidth: preferredItemWidth,
|
|
4282
|
+
snapInterval: preferredItemWidth + itemSpacing,
|
|
4283
|
+
pagingEnabled: false
|
|
4284
|
+
};
|
|
4302
4285
|
}
|
|
4303
|
-
function
|
|
4304
|
-
|
|
4286
|
+
function computeHeroLayout(config) {
|
|
4287
|
+
const { containerWidth, contentPadding, itemSpacing } = config;
|
|
4288
|
+
const availableWidth = containerWidth - 2 * contentPadding;
|
|
4289
|
+
const largeItemWidth = availableWidth - HERO_PEEK_WIDTH - itemSpacing;
|
|
4290
|
+
return {
|
|
4291
|
+
computedItemWidth: Math.max(largeItemWidth, 0),
|
|
4292
|
+
snapInterval: Math.max(largeItemWidth + itemSpacing, 1),
|
|
4293
|
+
pagingEnabled: false
|
|
4294
|
+
};
|
|
4305
4295
|
}
|
|
4306
|
-
function
|
|
4307
|
-
const
|
|
4308
|
-
return
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
}, [height, radius, theme.borderRadius]);
|
|
4296
|
+
function computeFullScreenLayout(config) {
|
|
4297
|
+
const { containerWidth } = config;
|
|
4298
|
+
return {
|
|
4299
|
+
computedItemWidth: containerWidth,
|
|
4300
|
+
snapInterval: containerWidth,
|
|
4301
|
+
pagingEnabled: true
|
|
4302
|
+
};
|
|
4314
4303
|
}
|
|
4315
|
-
function
|
|
4316
|
-
const theme = useXUITheme();
|
|
4317
|
-
const safeColor = (0, import_core31.getSafeThemeColor)(themeColor);
|
|
4318
|
-
const colorScheme = theme.colors[safeColor];
|
|
4304
|
+
function useCarouselLayout(config) {
|
|
4319
4305
|
return (0, import_react43.useMemo)(() => {
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
backgroundColor: colorScheme.background,
|
|
4336
|
-
color: colorScheme.main
|
|
4337
|
-
};
|
|
4338
|
-
case "faded":
|
|
4339
|
-
return {
|
|
4340
|
-
backgroundColor: (0, import_core31.withOpacity)(colorScheme.background, 0.7),
|
|
4341
|
-
color: colorScheme.main,
|
|
4342
|
-
borderWidth: 1,
|
|
4343
|
-
borderColor: (0, import_core31.withOpacity)(colorScheme.main, 0.3)
|
|
4344
|
-
};
|
|
4345
|
-
case "shadow":
|
|
4346
|
-
return {
|
|
4347
|
-
backgroundColor: colorScheme.main,
|
|
4348
|
-
color: colorScheme.foreground,
|
|
4349
|
-
shadow: theme.shadows.sm
|
|
4350
|
-
};
|
|
4351
|
-
case "dot":
|
|
4352
|
-
return {
|
|
4353
|
-
backgroundColor: colorScheme.background,
|
|
4354
|
-
color: colorScheme.main,
|
|
4355
|
-
dotColor: colorScheme.main
|
|
4356
|
-
};
|
|
4357
|
-
case "solid":
|
|
4358
|
-
default:
|
|
4359
|
-
return {
|
|
4360
|
-
backgroundColor: colorScheme.main,
|
|
4361
|
-
color: colorScheme.foreground
|
|
4362
|
-
};
|
|
4363
|
-
}
|
|
4364
|
-
}, [colorScheme, theme, variant]);
|
|
4306
|
+
const layoutMap = {
|
|
4307
|
+
"multi-browse": computeMultiBrowseLayout,
|
|
4308
|
+
uncontained: computeUncontainedLayout,
|
|
4309
|
+
hero: computeHeroLayout,
|
|
4310
|
+
"full-screen": computeFullScreenLayout
|
|
4311
|
+
};
|
|
4312
|
+
const compute = layoutMap[config.layout] ?? computeMultiBrowseLayout;
|
|
4313
|
+
return compute(config);
|
|
4314
|
+
}, [
|
|
4315
|
+
config.layout,
|
|
4316
|
+
config.containerWidth,
|
|
4317
|
+
config.preferredItemWidth,
|
|
4318
|
+
config.itemSpacing,
|
|
4319
|
+
config.contentPadding
|
|
4320
|
+
]);
|
|
4365
4321
|
}
|
|
4366
4322
|
|
|
4367
|
-
// src/components/
|
|
4368
|
-
var
|
|
4323
|
+
// src/components/carousel/carousel-item.tsx
|
|
4324
|
+
var import_react44 = __toESM(require("react"), 1);
|
|
4325
|
+
var import_react_native39 = require("react-native");
|
|
4326
|
+
var CarouselItem = ({
|
|
4369
4327
|
children,
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4328
|
+
width,
|
|
4329
|
+
height,
|
|
4330
|
+
radius,
|
|
4331
|
+
spacing,
|
|
4332
|
+
isLast,
|
|
4333
|
+
customStyle
|
|
4334
|
+
}) => /* @__PURE__ */ import_react44.default.createElement(
|
|
4335
|
+
import_react_native39.View,
|
|
4336
|
+
{
|
|
4337
|
+
style: [
|
|
4338
|
+
styles12.item,
|
|
4339
|
+
{
|
|
4340
|
+
width,
|
|
4341
|
+
height,
|
|
4342
|
+
borderRadius: radius,
|
|
4343
|
+
marginRight: isLast ? 0 : spacing
|
|
4344
|
+
},
|
|
4345
|
+
customStyle
|
|
4346
|
+
]
|
|
4347
|
+
},
|
|
4348
|
+
children
|
|
4349
|
+
);
|
|
4350
|
+
|
|
4351
|
+
// src/components/carousel/animated-carousel-item.tsx
|
|
4352
|
+
var import_react45 = __toESM(require("react"), 1);
|
|
4353
|
+
var import_react_native_reanimated4 = __toESM(require("react-native-reanimated"), 1);
|
|
4354
|
+
var AnimatedCarouselItem = ({
|
|
4355
|
+
children,
|
|
4356
|
+
index,
|
|
4357
|
+
scrollX,
|
|
4358
|
+
width,
|
|
4359
|
+
height,
|
|
4360
|
+
radius,
|
|
4361
|
+
spacing,
|
|
4362
|
+
isLast,
|
|
4363
|
+
customStyle,
|
|
4364
|
+
layout,
|
|
4365
|
+
snapInterval,
|
|
4366
|
+
containerWidth,
|
|
4367
|
+
contentPadding
|
|
4381
4368
|
}) => {
|
|
4382
|
-
const
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
});
|
|
4406
|
-
import_react44.default.useEffect(() => {
|
|
4407
|
-
if (previousColorsRef.current.backgroundColor === targetBackgroundColor && previousColorsRef.current.borderColor === targetBorderColor && previousColorsRef.current.textColor === targetTextColor && previousColorsRef.current.dotColor === targetDotColor) {
|
|
4408
|
-
return;
|
|
4369
|
+
const animatedStyle = (0, import_react_native_reanimated4.useAnimatedStyle)(() => {
|
|
4370
|
+
const inputRange = [
|
|
4371
|
+
(index - 1) * snapInterval,
|
|
4372
|
+
index * snapInterval,
|
|
4373
|
+
(index + 1) * snapInterval
|
|
4374
|
+
];
|
|
4375
|
+
if (layout === "multi-browse") {
|
|
4376
|
+
const scale = (0, import_react_native_reanimated4.interpolate)(
|
|
4377
|
+
scrollX.value,
|
|
4378
|
+
inputRange,
|
|
4379
|
+
[0.85, 1, 0.85],
|
|
4380
|
+
import_react_native_reanimated4.Extrapolation.CLAMP
|
|
4381
|
+
);
|
|
4382
|
+
const opacity = (0, import_react_native_reanimated4.interpolate)(
|
|
4383
|
+
scrollX.value,
|
|
4384
|
+
inputRange,
|
|
4385
|
+
[0.6, 1, 0.6],
|
|
4386
|
+
import_react_native_reanimated4.Extrapolation.CLAMP
|
|
4387
|
+
);
|
|
4388
|
+
return {
|
|
4389
|
+
transform: [{ scale }],
|
|
4390
|
+
opacity
|
|
4391
|
+
};
|
|
4409
4392
|
}
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4393
|
+
if (layout === "hero") {
|
|
4394
|
+
const centerOffset = containerWidth / 2 - contentPadding - width / 2;
|
|
4395
|
+
const itemPosition = index * snapInterval + contentPadding;
|
|
4396
|
+
const inputRangeHero = [
|
|
4397
|
+
itemPosition - centerOffset - snapInterval,
|
|
4398
|
+
itemPosition - centerOffset,
|
|
4399
|
+
itemPosition - centerOffset + snapInterval
|
|
4400
|
+
];
|
|
4401
|
+
const scale = (0, import_react_native_reanimated4.interpolate)(
|
|
4402
|
+
scrollX.value,
|
|
4403
|
+
inputRangeHero,
|
|
4404
|
+
[0.9, 1, 0.9],
|
|
4405
|
+
import_react_native_reanimated4.Extrapolation.CLAMP
|
|
4406
|
+
);
|
|
4407
|
+
const opacity = (0, import_react_native_reanimated4.interpolate)(
|
|
4408
|
+
scrollX.value,
|
|
4409
|
+
inputRangeHero,
|
|
4410
|
+
[0.5, 1, 0.5],
|
|
4411
|
+
import_react_native_reanimated4.Extrapolation.CLAMP
|
|
4412
|
+
);
|
|
4413
|
+
const translateX = (0, import_react_native_reanimated4.interpolate)(
|
|
4414
|
+
scrollX.value,
|
|
4415
|
+
inputRangeHero,
|
|
4416
|
+
[-10, 0, 10],
|
|
4417
|
+
import_react_native_reanimated4.Extrapolation.CLAMP
|
|
4418
|
+
);
|
|
4419
|
+
return {
|
|
4420
|
+
transform: [{ scale }, { translateX }],
|
|
4421
|
+
opacity
|
|
4422
4422
|
};
|
|
4423
|
-
});
|
|
4424
|
-
}, [
|
|
4425
|
-
colorProgress,
|
|
4426
|
-
targetBackgroundColor,
|
|
4427
|
-
targetBorderColor,
|
|
4428
|
-
targetTextColor,
|
|
4429
|
-
targetDotColor
|
|
4430
|
-
]);
|
|
4431
|
-
const animatedBackgroundColor = colorProgress.interpolate({
|
|
4432
|
-
inputRange: [0, 1],
|
|
4433
|
-
outputRange: [
|
|
4434
|
-
previousColorsRef.current.backgroundColor,
|
|
4435
|
-
targetBackgroundColor
|
|
4436
|
-
]
|
|
4437
|
-
});
|
|
4438
|
-
const animatedBorderColor = colorProgress.interpolate({
|
|
4439
|
-
inputRange: [0, 1],
|
|
4440
|
-
outputRange: [previousColorsRef.current.borderColor, targetBorderColor]
|
|
4441
|
-
});
|
|
4442
|
-
const animatedTextColor = colorProgress.interpolate({
|
|
4443
|
-
inputRange: [0, 1],
|
|
4444
|
-
outputRange: [previousColorsRef.current.textColor, targetTextColor]
|
|
4445
|
-
});
|
|
4446
|
-
const animatedDotColor = colorProgress.interpolate({
|
|
4447
|
-
inputRange: [0, 1],
|
|
4448
|
-
outputRange: [previousColorsRef.current.dotColor, targetDotColor]
|
|
4449
|
-
});
|
|
4450
|
-
const handlePressIn = import_react44.default.useCallback(() => {
|
|
4451
|
-
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
4452
|
-
import_react_native39.Animated.timing(scale, {
|
|
4453
|
-
toValue: 0.97,
|
|
4454
|
-
duration: 90,
|
|
4455
|
-
easing: import_react_native39.Easing.out(import_react_native39.Easing.cubic),
|
|
4456
|
-
useNativeDriver: true
|
|
4457
|
-
}).start();
|
|
4458
|
-
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
4459
|
-
const handlePressOut = import_react44.default.useCallback(() => {
|
|
4460
|
-
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
4461
|
-
import_react_native39.Animated.timing(scale, {
|
|
4462
|
-
toValue: 1,
|
|
4463
|
-
duration: 120,
|
|
4464
|
-
easing: import_react_native39.Easing.out(import_react_native39.Easing.cubic),
|
|
4465
|
-
useNativeDriver: true
|
|
4466
|
-
}).start();
|
|
4467
|
-
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
4468
|
-
const handleChipPress = import_react44.default.useCallback(() => {
|
|
4469
|
-
if (isDisabled || isClosing || isClosingRef.current) return;
|
|
4470
|
-
if (hasClose && onClose) {
|
|
4471
|
-
isClosingRef.current = true;
|
|
4472
|
-
setIsClosing(true);
|
|
4473
|
-
import_react_native39.Animated.parallel([
|
|
4474
|
-
import_react_native39.Animated.timing(opacity, {
|
|
4475
|
-
toValue: 0,
|
|
4476
|
-
duration: 180,
|
|
4477
|
-
easing: import_react_native39.Easing.in(import_react_native39.Easing.quad),
|
|
4478
|
-
useNativeDriver: true
|
|
4479
|
-
}),
|
|
4480
|
-
import_react_native39.Animated.timing(scale, {
|
|
4481
|
-
toValue: 0.88,
|
|
4482
|
-
duration: 180,
|
|
4483
|
-
easing: import_react_native39.Easing.in(import_react_native39.Easing.quad),
|
|
4484
|
-
useNativeDriver: true
|
|
4485
|
-
})
|
|
4486
|
-
]).start(() => {
|
|
4487
|
-
setIsClosed(true);
|
|
4488
|
-
onClose();
|
|
4489
|
-
setIsClosing(false);
|
|
4490
|
-
isClosingRef.current = false;
|
|
4491
|
-
});
|
|
4492
|
-
return;
|
|
4493
4423
|
}
|
|
4494
|
-
|
|
4495
|
-
}, [
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
}
|
|
4499
|
-
const chipContent = /* @__PURE__ */ import_react44.default.createElement(import_react_native39.Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ import_react44.default.createElement(
|
|
4500
|
-
import_react_native39.Animated.View,
|
|
4424
|
+
return {};
|
|
4425
|
+
}, [index, snapInterval, layout, containerWidth, contentPadding, width]);
|
|
4426
|
+
return /* @__PURE__ */ import_react45.default.createElement(
|
|
4427
|
+
import_react_native_reanimated4.default.View,
|
|
4501
4428
|
{
|
|
4502
4429
|
style: [
|
|
4503
|
-
styles12.
|
|
4430
|
+
styles12.item,
|
|
4504
4431
|
{
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
borderColor: animatedBorderColor
|
|
4432
|
+
width,
|
|
4433
|
+
height,
|
|
4434
|
+
borderRadius: radius,
|
|
4435
|
+
marginRight: isLast ? 0 : spacing
|
|
4510
4436
|
},
|
|
4511
|
-
|
|
4437
|
+
customStyle,
|
|
4438
|
+
animatedStyle
|
|
4439
|
+
]
|
|
4440
|
+
},
|
|
4441
|
+
children
|
|
4442
|
+
);
|
|
4443
|
+
};
|
|
4444
|
+
|
|
4445
|
+
// src/components/carousel/carousel.tsx
|
|
4446
|
+
var DEFAULT_ITEM_WIDTH = 196;
|
|
4447
|
+
var DEFAULT_ITEM_HEIGHT = 205;
|
|
4448
|
+
var DEFAULT_ITEM_SPACING = 8;
|
|
4449
|
+
var DEFAULT_ITEM_SPACING_MULTI_BROWSE = 4;
|
|
4450
|
+
var DEFAULT_CONTENT_PADDING = 16;
|
|
4451
|
+
var DEFAULT_AUTO_PLAY_INTERVAL = 3e3;
|
|
4452
|
+
function Carousel({
|
|
4453
|
+
data,
|
|
4454
|
+
renderItem,
|
|
4455
|
+
keyExtractor,
|
|
4456
|
+
layout = "multi-browse",
|
|
4457
|
+
itemWidth = DEFAULT_ITEM_WIDTH,
|
|
4458
|
+
itemHeight = DEFAULT_ITEM_HEIGHT,
|
|
4459
|
+
itemSpacing,
|
|
4460
|
+
contentPadding = DEFAULT_CONTENT_PADDING,
|
|
4461
|
+
radius = "lg",
|
|
4462
|
+
showIndicator = false,
|
|
4463
|
+
autoPlay = false,
|
|
4464
|
+
autoPlayInterval = DEFAULT_AUTO_PLAY_INTERVAL,
|
|
4465
|
+
initialIndex = 0,
|
|
4466
|
+
onActiveItemChange,
|
|
4467
|
+
customAppearance
|
|
4468
|
+
}) {
|
|
4469
|
+
const [containerWidth, setContainerWidth] = (0, import_react46.useState)(0);
|
|
4470
|
+
const [activeIndex, setActiveIndex] = (0, import_react46.useState)(initialIndex);
|
|
4471
|
+
const scrollRef = (0, import_react_native_reanimated5.useAnimatedRef)();
|
|
4472
|
+
const onActiveItemChangeRef = (0, import_react46.useRef)(onActiveItemChange);
|
|
4473
|
+
onActiveItemChangeRef.current = onActiveItemChange;
|
|
4474
|
+
const scrollX = (0, import_react_native_reanimated5.useSharedValue)(0);
|
|
4475
|
+
const { borderRadius } = useBorderRadiusStyles(radius);
|
|
4476
|
+
const defaultSpacing = layout === "multi-browse" ? DEFAULT_ITEM_SPACING_MULTI_BROWSE : DEFAULT_ITEM_SPACING;
|
|
4477
|
+
const resolvedSpacing = itemSpacing ?? defaultSpacing;
|
|
4478
|
+
const isFullScreen = layout === "full-screen";
|
|
4479
|
+
const effectivePadding = isFullScreen ? 0 : contentPadding;
|
|
4480
|
+
const effectiveSpacing = isFullScreen ? 0 : resolvedSpacing;
|
|
4481
|
+
const { computedItemWidth, snapInterval, pagingEnabled } = useCarouselLayout({
|
|
4482
|
+
layout,
|
|
4483
|
+
containerWidth,
|
|
4484
|
+
preferredItemWidth: itemWidth,
|
|
4485
|
+
itemSpacing: effectiveSpacing,
|
|
4486
|
+
contentPadding: effectivePadding
|
|
4487
|
+
});
|
|
4488
|
+
const handleLayout = (0, import_react46.useCallback)((event) => {
|
|
4489
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
4490
|
+
}, []);
|
|
4491
|
+
const scrollHandler = (0, import_react_native_reanimated5.useAnimatedScrollHandler)({
|
|
4492
|
+
onScroll: (event) => {
|
|
4493
|
+
scrollX.value = event.contentOffset.x;
|
|
4494
|
+
}
|
|
4495
|
+
});
|
|
4496
|
+
const handleMomentumScrollEnd = (0, import_react46.useCallback)(
|
|
4497
|
+
(event) => {
|
|
4498
|
+
if (snapInterval <= 0) return;
|
|
4499
|
+
const offsetX = event.nativeEvent.contentOffset.x;
|
|
4500
|
+
const newIndex = Math.round(offsetX / snapInterval);
|
|
4501
|
+
const clampedIndex = Math.max(0, Math.min(newIndex, data.length - 1));
|
|
4502
|
+
setActiveIndex(clampedIndex);
|
|
4503
|
+
onActiveItemChangeRef.current?.(clampedIndex);
|
|
4504
|
+
},
|
|
4505
|
+
[snapInterval, data.length]
|
|
4506
|
+
);
|
|
4507
|
+
(0, import_react46.useEffect)(() => {
|
|
4508
|
+
if (!autoPlay || data.length <= 1) return;
|
|
4509
|
+
if (containerWidth <= 0 || snapInterval <= 0) return;
|
|
4510
|
+
const timer = setInterval(() => {
|
|
4511
|
+
setActiveIndex((prev) => {
|
|
4512
|
+
const nextIndex = (prev + 1) % data.length;
|
|
4513
|
+
scrollRef.current?.scrollTo({ x: nextIndex * snapInterval, animated: true });
|
|
4514
|
+
onActiveItemChangeRef.current?.(nextIndex);
|
|
4515
|
+
return nextIndex;
|
|
4516
|
+
});
|
|
4517
|
+
}, autoPlayInterval);
|
|
4518
|
+
return () => clearInterval(timer);
|
|
4519
|
+
}, [autoPlay, autoPlayInterval, data.length, snapInterval, containerWidth]);
|
|
4520
|
+
if (containerWidth <= 0) {
|
|
4521
|
+
return /* @__PURE__ */ import_react46.default.createElement(import_react_native40.View, { style: customAppearance?.container, onLayout: handleLayout });
|
|
4522
|
+
}
|
|
4523
|
+
const shouldAnimate = layout === "multi-browse" || layout === "hero";
|
|
4524
|
+
return /* @__PURE__ */ import_react46.default.createElement(import_react_native40.View, { style: customAppearance?.container, onLayout: handleLayout }, /* @__PURE__ */ import_react46.default.createElement(
|
|
4525
|
+
import_react_native_reanimated5.default.ScrollView,
|
|
4526
|
+
{
|
|
4527
|
+
ref: scrollRef,
|
|
4528
|
+
horizontal: true,
|
|
4529
|
+
showsHorizontalScrollIndicator: false,
|
|
4530
|
+
snapToInterval: pagingEnabled ? void 0 : snapInterval,
|
|
4531
|
+
pagingEnabled,
|
|
4532
|
+
decelerationRate: "fast",
|
|
4533
|
+
contentContainerStyle: [
|
|
4534
|
+
styles12.scrollContent,
|
|
4535
|
+
{ paddingHorizontal: effectivePadding }
|
|
4536
|
+
],
|
|
4537
|
+
onScroll: scrollHandler,
|
|
4538
|
+
scrollEventThrottle: 16,
|
|
4539
|
+
onMomentumScrollEnd: handleMomentumScrollEnd,
|
|
4540
|
+
contentOffset: { x: initialIndex * snapInterval, y: 0 }
|
|
4541
|
+
},
|
|
4542
|
+
data.map((item, index) => {
|
|
4543
|
+
const content = renderItem({ item, index });
|
|
4544
|
+
if (shouldAnimate) {
|
|
4545
|
+
return /* @__PURE__ */ import_react46.default.createElement(
|
|
4546
|
+
AnimatedCarouselItem,
|
|
4547
|
+
{
|
|
4548
|
+
key: keyExtractor ? keyExtractor(item, index) : String(index),
|
|
4549
|
+
index,
|
|
4550
|
+
scrollX,
|
|
4551
|
+
width: computedItemWidth,
|
|
4552
|
+
height: itemHeight,
|
|
4553
|
+
radius: borderRadius,
|
|
4554
|
+
spacing: effectiveSpacing,
|
|
4555
|
+
isLast: index === data.length - 1,
|
|
4556
|
+
customStyle: customAppearance?.item,
|
|
4557
|
+
layout,
|
|
4558
|
+
snapInterval,
|
|
4559
|
+
containerWidth,
|
|
4560
|
+
contentPadding: effectivePadding
|
|
4561
|
+
},
|
|
4562
|
+
content
|
|
4563
|
+
);
|
|
4564
|
+
}
|
|
4565
|
+
return /* @__PURE__ */ import_react46.default.createElement(
|
|
4566
|
+
CarouselItem,
|
|
4567
|
+
{
|
|
4568
|
+
key: keyExtractor ? keyExtractor(item, index) : String(index),
|
|
4569
|
+
width: computedItemWidth,
|
|
4570
|
+
height: itemHeight,
|
|
4571
|
+
radius: borderRadius,
|
|
4572
|
+
spacing: effectiveSpacing,
|
|
4573
|
+
isLast: index === data.length - 1,
|
|
4574
|
+
customStyle: customAppearance?.item
|
|
4575
|
+
},
|
|
4576
|
+
content
|
|
4577
|
+
);
|
|
4578
|
+
})
|
|
4579
|
+
), showIndicator && data.length > 1 && /* @__PURE__ */ import_react46.default.createElement(
|
|
4580
|
+
import_react_native40.View,
|
|
4581
|
+
{
|
|
4582
|
+
style: [styles12.indicatorContainer, customAppearance?.indicatorContainer]
|
|
4583
|
+
},
|
|
4584
|
+
data.map((_, index) => /* @__PURE__ */ import_react46.default.createElement(
|
|
4585
|
+
import_react_native40.View,
|
|
4586
|
+
{
|
|
4587
|
+
key: `indicator-${String(index)}`,
|
|
4588
|
+
style: [
|
|
4589
|
+
styles12.indicator,
|
|
4590
|
+
customAppearance?.indicator,
|
|
4591
|
+
activeIndex === index && styles12.activeIndicator,
|
|
4592
|
+
activeIndex === index && customAppearance?.activeIndicator
|
|
4593
|
+
]
|
|
4594
|
+
}
|
|
4595
|
+
))
|
|
4596
|
+
));
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4599
|
+
// src/components/segment-button/segment-button.tsx
|
|
4600
|
+
var import_react49 = __toESM(require("react"), 1);
|
|
4601
|
+
var import_react_native42 = require("react-native");
|
|
4602
|
+
|
|
4603
|
+
// src/components/segment-button/segment-button.style.ts
|
|
4604
|
+
var import_react_native41 = require("react-native");
|
|
4605
|
+
var styles13 = import_react_native41.StyleSheet.create({
|
|
4606
|
+
container: {
|
|
4607
|
+
flexDirection: "row",
|
|
4608
|
+
alignItems: "stretch",
|
|
4609
|
+
overflow: "hidden",
|
|
4610
|
+
alignSelf: "flex-start"
|
|
4611
|
+
},
|
|
4612
|
+
fullWidth: {
|
|
4613
|
+
width: "100%",
|
|
4614
|
+
alignSelf: "stretch"
|
|
4615
|
+
},
|
|
4616
|
+
segment: {
|
|
4617
|
+
flex: 1
|
|
4618
|
+
},
|
|
4619
|
+
segmentInner: {
|
|
4620
|
+
flex: 1,
|
|
4621
|
+
flexDirection: "row",
|
|
4622
|
+
alignItems: "center",
|
|
4623
|
+
justifyContent: "center"
|
|
4624
|
+
},
|
|
4625
|
+
segmentContent: {
|
|
4626
|
+
flexDirection: "row",
|
|
4627
|
+
alignItems: "center",
|
|
4628
|
+
justifyContent: "center",
|
|
4629
|
+
gap: 4
|
|
4630
|
+
},
|
|
4631
|
+
segmentText: {
|
|
4632
|
+
fontWeight: "500",
|
|
4633
|
+
textAlign: "center"
|
|
4634
|
+
},
|
|
4635
|
+
disabled: {
|
|
4636
|
+
opacity: 0.5
|
|
4637
|
+
},
|
|
4638
|
+
divider: {
|
|
4639
|
+
width: 1,
|
|
4640
|
+
alignSelf: "stretch"
|
|
4641
|
+
}
|
|
4642
|
+
});
|
|
4643
|
+
|
|
4644
|
+
// src/components/segment-button/segment-button.hook.ts
|
|
4645
|
+
var import_react47 = require("react");
|
|
4646
|
+
var import_core33 = require("@xaui/core");
|
|
4647
|
+
function useSegmentSizeStyles(size) {
|
|
4648
|
+
const theme = useXUITheme();
|
|
4649
|
+
return (0, import_react47.useMemo)(() => {
|
|
4650
|
+
const sizes = {
|
|
4651
|
+
xs: {
|
|
4652
|
+
paddingHorizontal: theme.spacing.sm,
|
|
4653
|
+
paddingVertical: theme.spacing.xs,
|
|
4654
|
+
minHeight: 32,
|
|
4655
|
+
fontSize: theme.fontSizes.xs,
|
|
4656
|
+
iconSize: 14
|
|
4657
|
+
},
|
|
4658
|
+
sm: {
|
|
4659
|
+
paddingHorizontal: theme.spacing.md,
|
|
4660
|
+
paddingVertical: theme.spacing.xs,
|
|
4661
|
+
minHeight: 36,
|
|
4662
|
+
fontSize: theme.fontSizes.sm,
|
|
4663
|
+
iconSize: 16
|
|
4664
|
+
},
|
|
4665
|
+
md: {
|
|
4666
|
+
paddingHorizontal: theme.spacing.md,
|
|
4667
|
+
paddingVertical: theme.spacing.sm,
|
|
4668
|
+
minHeight: 40,
|
|
4669
|
+
fontSize: theme.fontSizes.md,
|
|
4670
|
+
iconSize: 18
|
|
4671
|
+
},
|
|
4672
|
+
lg: {
|
|
4673
|
+
paddingHorizontal: theme.spacing.lg,
|
|
4674
|
+
paddingVertical: theme.spacing.md,
|
|
4675
|
+
minHeight: 48,
|
|
4676
|
+
fontSize: theme.fontSizes.lg,
|
|
4677
|
+
iconSize: 20
|
|
4678
|
+
}
|
|
4679
|
+
};
|
|
4680
|
+
return sizes[size];
|
|
4681
|
+
}, [size, theme]);
|
|
4682
|
+
}
|
|
4683
|
+
function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
|
|
4684
|
+
const theme = useXUITheme();
|
|
4685
|
+
const safeThemeColor = (0, import_core33.getSafeThemeColor)(themeColor);
|
|
4686
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
4687
|
+
const selectedBackgroundColor = (0, import_core33.withPaletteNumber)(colorScheme.main, 400);
|
|
4688
|
+
return (0, import_react47.useMemo)(() => {
|
|
4689
|
+
const variants = {
|
|
4690
|
+
outlined: {
|
|
4691
|
+
containerBackground: "transparent",
|
|
4692
|
+
containerBorderWidth: theme.borderWidth.sm,
|
|
4693
|
+
containerBorderColor: colorScheme.main,
|
|
4694
|
+
selectedBackground: selectedBackgroundColor,
|
|
4695
|
+
unselectedBackground: "transparent",
|
|
4696
|
+
selectedTextColor: colorScheme.foreground,
|
|
4697
|
+
unselectedTextColor: colorScheme.main
|
|
4698
|
+
},
|
|
4699
|
+
flat: {
|
|
4700
|
+
containerBackground: colorScheme.background,
|
|
4701
|
+
containerBorderWidth: 0,
|
|
4702
|
+
containerBorderColor: "transparent",
|
|
4703
|
+
selectedBackground: selectedBackgroundColor,
|
|
4704
|
+
unselectedBackground: "transparent",
|
|
4705
|
+
selectedTextColor: colorScheme.foreground,
|
|
4706
|
+
unselectedTextColor: colorScheme.main
|
|
4707
|
+
},
|
|
4708
|
+
light: {
|
|
4709
|
+
containerBackground: "transparent",
|
|
4710
|
+
containerBorderWidth: 0,
|
|
4711
|
+
containerBorderColor: "transparent",
|
|
4712
|
+
selectedBackground: selectedBackgroundColor,
|
|
4713
|
+
unselectedBackground: "transparent",
|
|
4714
|
+
selectedTextColor: colorScheme.foreground,
|
|
4715
|
+
unselectedTextColor: colorScheme.main
|
|
4716
|
+
},
|
|
4717
|
+
faded: {
|
|
4718
|
+
containerBackground: `${colorScheme.background}95`,
|
|
4719
|
+
containerBorderWidth: theme.borderWidth.sm,
|
|
4720
|
+
containerBorderColor: `${colorScheme.main}90`,
|
|
4721
|
+
selectedBackground: selectedBackgroundColor,
|
|
4722
|
+
unselectedBackground: "transparent",
|
|
4723
|
+
selectedTextColor: colorScheme.foreground,
|
|
4724
|
+
unselectedTextColor: colorScheme.main
|
|
4725
|
+
}
|
|
4726
|
+
};
|
|
4727
|
+
const baseStyle = variants[variant] ?? variants.outlined;
|
|
4728
|
+
const shouldApplyElevation = variant !== "outlined" && variant !== "light";
|
|
4729
|
+
const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
|
|
4730
|
+
return {
|
|
4731
|
+
...baseStyle,
|
|
4732
|
+
containerShadow: shouldApplyElevation && elevation > 0 ? shadowStyles : baseStyle.containerShadow
|
|
4733
|
+
};
|
|
4734
|
+
}, [variant, colorScheme, theme, elevation]);
|
|
4735
|
+
}
|
|
4736
|
+
|
|
4737
|
+
// src/components/segment-button/segment-button-context.ts
|
|
4738
|
+
var import_react48 = require("react");
|
|
4739
|
+
var SegmentButtonContext = (0, import_react48.createContext)(void 0);
|
|
4740
|
+
var useSegmentButtonContext = () => {
|
|
4741
|
+
const context = (0, import_react48.useContext)(SegmentButtonContext);
|
|
4742
|
+
if (!context) {
|
|
4743
|
+
throw new Error(
|
|
4744
|
+
"SegmentButtonItem must be used within a SegmentButton component"
|
|
4745
|
+
);
|
|
4746
|
+
}
|
|
4747
|
+
return context;
|
|
4748
|
+
};
|
|
4749
|
+
|
|
4750
|
+
// src/components/segment-button/segment-button.tsx
|
|
4751
|
+
var SegmentButton = ({
|
|
4752
|
+
children,
|
|
4753
|
+
selected: controlledSelected,
|
|
4754
|
+
defaultSelected,
|
|
4755
|
+
onSelectionChange,
|
|
4756
|
+
selectionMode = "single",
|
|
4757
|
+
themeColor = "primary",
|
|
4758
|
+
variant = "outlined",
|
|
4759
|
+
size = "md",
|
|
4760
|
+
radius = "full",
|
|
4761
|
+
fullWidth = false,
|
|
4762
|
+
isDisabled = false,
|
|
4763
|
+
showCheckmark = true,
|
|
4764
|
+
elevation = 0,
|
|
4765
|
+
customAppearance
|
|
4766
|
+
}) => {
|
|
4767
|
+
const isControlled = controlledSelected !== void 0;
|
|
4768
|
+
const [internalSelected, setInternalSelected] = (0, import_react49.useState)(
|
|
4769
|
+
() => defaultSelected ?? ""
|
|
4770
|
+
);
|
|
4771
|
+
const selected = isControlled ? controlledSelected : internalSelected;
|
|
4772
|
+
const selectedKeys = (0, import_react49.useMemo)(() => {
|
|
4773
|
+
if (Array.isArray(selected)) return selected;
|
|
4774
|
+
return selected ? [selected] : [];
|
|
4775
|
+
}, [selected]);
|
|
4776
|
+
const variantStyles = useSegmentVariantStyles(themeColor, variant, elevation);
|
|
4777
|
+
const radiusStyles = useBorderRadiusStyles(radius);
|
|
4778
|
+
const toggleItem = (0, import_react49.useCallback)(
|
|
4779
|
+
(key) => {
|
|
4780
|
+
let nextSelected;
|
|
4781
|
+
if (selectionMode === "single") {
|
|
4782
|
+
nextSelected = key;
|
|
4783
|
+
} else {
|
|
4784
|
+
const isCurrentlySelected = selectedKeys.includes(key);
|
|
4785
|
+
if (isCurrentlySelected && selectedKeys.length > 1) {
|
|
4786
|
+
nextSelected = selectedKeys.filter((k) => k !== key);
|
|
4787
|
+
} else if (!isCurrentlySelected) {
|
|
4788
|
+
nextSelected = [...selectedKeys, key];
|
|
4789
|
+
} else {
|
|
4790
|
+
return;
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
if (!isControlled) {
|
|
4794
|
+
setInternalSelected(nextSelected);
|
|
4795
|
+
}
|
|
4796
|
+
onSelectionChange?.(nextSelected);
|
|
4797
|
+
},
|
|
4798
|
+
[selectionMode, selectedKeys, onSelectionChange, isControlled]
|
|
4799
|
+
);
|
|
4800
|
+
const contextValue = (0, import_react49.useMemo)(
|
|
4801
|
+
() => ({
|
|
4802
|
+
selectedKeys,
|
|
4803
|
+
toggleItem,
|
|
4804
|
+
themeColor,
|
|
4805
|
+
variant,
|
|
4806
|
+
size,
|
|
4807
|
+
elevation,
|
|
4808
|
+
isDisabled,
|
|
4809
|
+
showCheckmark
|
|
4810
|
+
}),
|
|
4811
|
+
[
|
|
4812
|
+
selectedKeys,
|
|
4813
|
+
toggleItem,
|
|
4814
|
+
themeColor,
|
|
4815
|
+
variant,
|
|
4816
|
+
size,
|
|
4817
|
+
elevation,
|
|
4818
|
+
isDisabled,
|
|
4819
|
+
showCheckmark
|
|
4820
|
+
]
|
|
4821
|
+
);
|
|
4822
|
+
const showDivider = variant === "outlined" || variant === "faded";
|
|
4823
|
+
const childrenArray = import_react49.default.Children.toArray(children);
|
|
4824
|
+
const getItemKey = (child) => {
|
|
4825
|
+
if (!import_react49.default.isValidElement(child)) {
|
|
4826
|
+
return void 0;
|
|
4827
|
+
}
|
|
4828
|
+
return child.props.itemKey;
|
|
4829
|
+
};
|
|
4830
|
+
return /* @__PURE__ */ import_react49.default.createElement(SegmentButtonContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react49.default.createElement(
|
|
4831
|
+
import_react_native42.View,
|
|
4832
|
+
{
|
|
4833
|
+
style: [
|
|
4834
|
+
styles13.container,
|
|
4835
|
+
{
|
|
4836
|
+
backgroundColor: variantStyles.containerBackground,
|
|
4837
|
+
borderWidth: variantStyles.containerBorderWidth,
|
|
4838
|
+
borderColor: variantStyles.containerBorderColor,
|
|
4839
|
+
borderRadius: radiusStyles.borderRadius,
|
|
4840
|
+
...variantStyles.containerShadow
|
|
4841
|
+
},
|
|
4842
|
+
fullWidth && styles13.fullWidth,
|
|
4843
|
+
customAppearance?.container
|
|
4844
|
+
]
|
|
4845
|
+
},
|
|
4846
|
+
childrenArray.map((child, index) => {
|
|
4847
|
+
const isLast = index === childrenArray.length - 1;
|
|
4848
|
+
const childItemKey = getItemKey(child);
|
|
4849
|
+
const childKey = childItemKey ?? index;
|
|
4850
|
+
const isSelected = selectedKeys.includes(String(childKey));
|
|
4851
|
+
const nextChildKey = !isLast ? getItemKey(childrenArray[index + 1]) : void 0;
|
|
4852
|
+
const nextSelected = nextChildKey ? selectedKeys.includes(String(nextChildKey)) : false;
|
|
4853
|
+
return /* @__PURE__ */ import_react49.default.createElement(import_react49.default.Fragment, { key: childKey }, child, showDivider && !isLast && !isSelected && !nextSelected && /* @__PURE__ */ import_react49.default.createElement(
|
|
4854
|
+
import_react_native42.View,
|
|
4855
|
+
{
|
|
4856
|
+
style: [
|
|
4857
|
+
styles13.divider,
|
|
4858
|
+
{
|
|
4859
|
+
backgroundColor: variantStyles.containerBorderColor
|
|
4860
|
+
}
|
|
4861
|
+
]
|
|
4862
|
+
}
|
|
4863
|
+
));
|
|
4864
|
+
})
|
|
4865
|
+
));
|
|
4866
|
+
};
|
|
4867
|
+
|
|
4868
|
+
// src/components/segment-button/segment-button-item.tsx
|
|
4869
|
+
var import_react50 = __toESM(require("react"), 1);
|
|
4870
|
+
var import_react_native44 = require("react-native");
|
|
4871
|
+
var import_react_native_svg3 = __toESM(require("react-native-svg"), 1);
|
|
4872
|
+
|
|
4873
|
+
// src/components/segment-button/segment-button.animation.ts
|
|
4874
|
+
var import_react_native43 = require("react-native");
|
|
4875
|
+
var runCheckmarkEnterAnimation = (animatedValue) => {
|
|
4876
|
+
animatedValue.setValue(0);
|
|
4877
|
+
import_react_native43.Animated.timing(animatedValue, {
|
|
4878
|
+
toValue: 1,
|
|
4879
|
+
duration: 200,
|
|
4880
|
+
useNativeDriver: true
|
|
4881
|
+
}).start();
|
|
4882
|
+
};
|
|
4883
|
+
var runCheckmarkExitAnimation = (animatedValue) => {
|
|
4884
|
+
import_react_native43.Animated.timing(animatedValue, {
|
|
4885
|
+
toValue: 0,
|
|
4886
|
+
duration: 150,
|
|
4887
|
+
useNativeDriver: true
|
|
4888
|
+
}).start();
|
|
4889
|
+
};
|
|
4890
|
+
|
|
4891
|
+
// src/components/segment-button/segment-button-item.tsx
|
|
4892
|
+
var CheckIcon = ({ size, color }) => /* @__PURE__ */ import_react50.default.createElement(import_react_native_svg3.default, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ import_react50.default.createElement(
|
|
4893
|
+
import_react_native_svg3.Path,
|
|
4894
|
+
{
|
|
4895
|
+
d: "M20 6L9 17l-5-5",
|
|
4896
|
+
stroke: color,
|
|
4897
|
+
strokeWidth: 2.5,
|
|
4898
|
+
strokeLinecap: "round",
|
|
4899
|
+
strokeLinejoin: "round"
|
|
4900
|
+
}
|
|
4901
|
+
));
|
|
4902
|
+
var SegmentButtonItem = ({
|
|
4903
|
+
itemKey,
|
|
4904
|
+
label,
|
|
4905
|
+
startContent,
|
|
4906
|
+
icon,
|
|
4907
|
+
endContent,
|
|
4908
|
+
checkIndicator,
|
|
4909
|
+
isDisabled: itemDisabled = false,
|
|
4910
|
+
customAppearance
|
|
4911
|
+
}) => {
|
|
4912
|
+
const {
|
|
4913
|
+
selectedKeys,
|
|
4914
|
+
toggleItem,
|
|
4915
|
+
themeColor,
|
|
4916
|
+
variant,
|
|
4917
|
+
size,
|
|
4918
|
+
elevation,
|
|
4919
|
+
isDisabled: groupDisabled,
|
|
4920
|
+
showCheckmark
|
|
4921
|
+
} = useSegmentButtonContext();
|
|
4922
|
+
const isSelected = selectedKeys.includes(itemKey);
|
|
4923
|
+
const disabled = groupDisabled || itemDisabled;
|
|
4924
|
+
const checkmarkAnim = (0, import_react50.useRef)(new import_react_native44.Animated.Value(isSelected ? 1 : 0)).current;
|
|
4925
|
+
const prevSelected = (0, import_react50.useRef)(isSelected);
|
|
4926
|
+
(0, import_react50.useEffect)(() => {
|
|
4927
|
+
if (isSelected && !prevSelected.current) {
|
|
4928
|
+
runCheckmarkEnterAnimation(checkmarkAnim);
|
|
4929
|
+
} else if (!isSelected && prevSelected.current) {
|
|
4930
|
+
runCheckmarkExitAnimation(checkmarkAnim);
|
|
4931
|
+
}
|
|
4932
|
+
prevSelected.current = isSelected;
|
|
4933
|
+
}, [isSelected, checkmarkAnim]);
|
|
4934
|
+
const sizeStyles = useSegmentSizeStyles(size);
|
|
4935
|
+
const variantStyles = useSegmentVariantStyles(themeColor, variant, elevation);
|
|
4936
|
+
const handlePress = () => {
|
|
4937
|
+
if (!disabled) {
|
|
4938
|
+
toggleItem(itemKey);
|
|
4939
|
+
}
|
|
4940
|
+
};
|
|
4941
|
+
const backgroundColor = isSelected ? variantStyles.selectedBackground : variantStyles.unselectedBackground;
|
|
4942
|
+
const textColor = isSelected ? variantStyles.selectedTextColor : variantStyles.unselectedTextColor;
|
|
4943
|
+
const showCheck = isSelected && showCheckmark;
|
|
4944
|
+
const startNode = showCheck ? checkIndicator ?? /* @__PURE__ */ import_react50.default.createElement(CheckIcon, { size: sizeStyles.iconSize, color: textColor }) : startContent ?? icon;
|
|
4945
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
4946
|
+
import_react_native44.Pressable,
|
|
4947
|
+
{
|
|
4948
|
+
style: [styles13.segment, disabled && styles13.disabled],
|
|
4949
|
+
onPress: handlePress,
|
|
4950
|
+
disabled
|
|
4951
|
+
},
|
|
4952
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4953
|
+
import_react_native44.View,
|
|
4954
|
+
{
|
|
4955
|
+
style: [
|
|
4956
|
+
styles13.segmentInner,
|
|
4957
|
+
{
|
|
4958
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
4959
|
+
paddingVertical: sizeStyles.paddingVertical,
|
|
4960
|
+
minHeight: sizeStyles.minHeight,
|
|
4961
|
+
backgroundColor
|
|
4962
|
+
},
|
|
4963
|
+
isSelected ? customAppearance?.selectedSegment : customAppearance?.segment
|
|
4964
|
+
]
|
|
4965
|
+
},
|
|
4966
|
+
/* @__PURE__ */ import_react50.default.createElement(import_react_native44.View, { style: styles13.segmentContent }, startNode && /* @__PURE__ */ import_react50.default.createElement(
|
|
4967
|
+
import_react_native44.Animated.View,
|
|
4968
|
+
{
|
|
4969
|
+
style: {
|
|
4970
|
+
opacity: showCheck ? checkmarkAnim : 1,
|
|
4971
|
+
transform: [{ scale: showCheck ? checkmarkAnim : 1 }]
|
|
4972
|
+
}
|
|
4973
|
+
},
|
|
4974
|
+
startNode
|
|
4975
|
+
), /* @__PURE__ */ import_react50.default.createElement(
|
|
4976
|
+
import_react_native44.Text,
|
|
4977
|
+
{
|
|
4978
|
+
numberOfLines: 1,
|
|
4979
|
+
style: [
|
|
4980
|
+
styles13.segmentText,
|
|
4981
|
+
{
|
|
4982
|
+
fontSize: sizeStyles.fontSize,
|
|
4983
|
+
color: textColor
|
|
4984
|
+
},
|
|
4985
|
+
isSelected ? customAppearance?.selectedText : customAppearance?.text
|
|
4986
|
+
]
|
|
4987
|
+
},
|
|
4988
|
+
label
|
|
4989
|
+
), endContent)
|
|
4990
|
+
)
|
|
4991
|
+
);
|
|
4992
|
+
};
|
|
4993
|
+
SegmentButtonItem.displayName = "SegmentButtonItem";
|
|
4994
|
+
|
|
4995
|
+
// src/components/chip/chip.tsx
|
|
4996
|
+
var import_react52 = __toESM(require("react"), 1);
|
|
4997
|
+
var import_react_native46 = require("react-native");
|
|
4998
|
+
|
|
4999
|
+
// src/components/chip/chip.style.ts
|
|
5000
|
+
var import_react_native45 = require("react-native");
|
|
5001
|
+
var styles14 = import_react_native45.StyleSheet.create({
|
|
5002
|
+
chip: {
|
|
5003
|
+
flexDirection: "row",
|
|
5004
|
+
alignItems: "center",
|
|
5005
|
+
alignSelf: "flex-start"
|
|
5006
|
+
},
|
|
5007
|
+
text: {
|
|
5008
|
+
fontWeight: "500",
|
|
5009
|
+
includeFontPadding: false,
|
|
5010
|
+
textAlignVertical: "center"
|
|
5011
|
+
},
|
|
5012
|
+
disabled: {
|
|
5013
|
+
opacity: 0.5
|
|
5014
|
+
},
|
|
5015
|
+
avatar: {
|
|
5016
|
+
marginRight: 4
|
|
5017
|
+
},
|
|
5018
|
+
startContent: {
|
|
5019
|
+
marginRight: 4
|
|
5020
|
+
},
|
|
5021
|
+
endContent: {
|
|
5022
|
+
marginLeft: 4
|
|
5023
|
+
},
|
|
5024
|
+
closeButton: {
|
|
5025
|
+
marginLeft: 4,
|
|
5026
|
+
alignItems: "center",
|
|
5027
|
+
justifyContent: "center"
|
|
5028
|
+
},
|
|
5029
|
+
dot: {
|
|
5030
|
+
borderRadius: 9999,
|
|
5031
|
+
marginRight: 6
|
|
5032
|
+
},
|
|
5033
|
+
groupContainer: {
|
|
5034
|
+
flexDirection: "row",
|
|
5035
|
+
flexWrap: "wrap"
|
|
5036
|
+
}
|
|
5037
|
+
});
|
|
5038
|
+
|
|
5039
|
+
// src/components/chip/chip.hook.ts
|
|
5040
|
+
var import_react51 = require("react");
|
|
5041
|
+
var import_core34 = require("@xaui/core");
|
|
5042
|
+
var sizeMap3 = {
|
|
5043
|
+
sm: { height: 32, paddingH: 12, fontSize: 13 },
|
|
5044
|
+
md: { height: 40, paddingH: 16, fontSize: 15 },
|
|
5045
|
+
lg: { height: 44, paddingH: 18, fontSize: 17 }
|
|
5046
|
+
};
|
|
5047
|
+
var dotSizeMap = {
|
|
5048
|
+
sm: 8,
|
|
5049
|
+
md: 10,
|
|
5050
|
+
lg: 11
|
|
5051
|
+
};
|
|
5052
|
+
var closeSizeMap = {
|
|
5053
|
+
sm: 14,
|
|
5054
|
+
md: 16,
|
|
5055
|
+
lg: 17
|
|
5056
|
+
};
|
|
5057
|
+
function useChipSizeStyles(size) {
|
|
5058
|
+
return (0, import_react51.useMemo)(() => {
|
|
5059
|
+
const { height, paddingH, fontSize } = sizeMap3[size];
|
|
5060
|
+
return { height, paddingHorizontal: paddingH, fontSize };
|
|
5061
|
+
}, [size]);
|
|
5062
|
+
}
|
|
5063
|
+
function useChipDotSize(size) {
|
|
5064
|
+
return (0, import_react51.useMemo)(() => dotSizeMap[size], [size]);
|
|
5065
|
+
}
|
|
5066
|
+
function useChipCloseSize(size) {
|
|
5067
|
+
return (0, import_react51.useMemo)(() => closeSizeMap[size], [size]);
|
|
5068
|
+
}
|
|
5069
|
+
function useChipRadiusStyles(radius, height) {
|
|
5070
|
+
const theme = useXUITheme();
|
|
5071
|
+
return (0, import_react51.useMemo)(() => {
|
|
5072
|
+
if (radius === "full") {
|
|
5073
|
+
return { borderRadius: height / 2 };
|
|
5074
|
+
}
|
|
5075
|
+
return { borderRadius: theme.borderRadius[radius] };
|
|
5076
|
+
}, [height, radius, theme.borderRadius]);
|
|
5077
|
+
}
|
|
5078
|
+
function useChipVariantStyles(themeColor, variant) {
|
|
5079
|
+
const theme = useXUITheme();
|
|
5080
|
+
const safeColor = (0, import_core34.getSafeThemeColor)(themeColor);
|
|
5081
|
+
const colorScheme = theme.colors[safeColor];
|
|
5082
|
+
return (0, import_react51.useMemo)(() => {
|
|
5083
|
+
switch (variant) {
|
|
5084
|
+
case "bordered":
|
|
5085
|
+
return {
|
|
5086
|
+
backgroundColor: "transparent",
|
|
5087
|
+
color: colorScheme.main,
|
|
5088
|
+
borderWidth: 2,
|
|
5089
|
+
borderColor: colorScheme.main
|
|
5090
|
+
};
|
|
5091
|
+
case "light":
|
|
5092
|
+
return {
|
|
5093
|
+
backgroundColor: "transparent",
|
|
5094
|
+
color: colorScheme.main
|
|
5095
|
+
};
|
|
5096
|
+
case "flat":
|
|
5097
|
+
return {
|
|
5098
|
+
backgroundColor: colorScheme.background,
|
|
5099
|
+
color: colorScheme.main
|
|
5100
|
+
};
|
|
5101
|
+
case "faded":
|
|
5102
|
+
return {
|
|
5103
|
+
backgroundColor: (0, import_core34.withOpacity)(colorScheme.background, 0.7),
|
|
5104
|
+
color: colorScheme.main,
|
|
5105
|
+
borderWidth: 1,
|
|
5106
|
+
borderColor: (0, import_core34.withOpacity)(colorScheme.main, 0.3)
|
|
5107
|
+
};
|
|
5108
|
+
case "shadow":
|
|
5109
|
+
return {
|
|
5110
|
+
backgroundColor: colorScheme.main,
|
|
5111
|
+
color: colorScheme.foreground,
|
|
5112
|
+
shadow: theme.shadows.sm
|
|
5113
|
+
};
|
|
5114
|
+
case "dot":
|
|
5115
|
+
return {
|
|
5116
|
+
backgroundColor: colorScheme.background,
|
|
5117
|
+
color: colorScheme.main,
|
|
5118
|
+
dotColor: colorScheme.main
|
|
5119
|
+
};
|
|
5120
|
+
case "solid":
|
|
5121
|
+
default:
|
|
5122
|
+
return {
|
|
5123
|
+
backgroundColor: colorScheme.main,
|
|
5124
|
+
color: colorScheme.foreground
|
|
5125
|
+
};
|
|
5126
|
+
}
|
|
5127
|
+
}, [colorScheme, theme, variant]);
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
// src/components/chip/chip.tsx
|
|
5131
|
+
var Chip = ({
|
|
5132
|
+
children,
|
|
5133
|
+
variant = "solid",
|
|
5134
|
+
themeColor = "default",
|
|
5135
|
+
size = "md",
|
|
5136
|
+
radius = "full",
|
|
5137
|
+
avatar,
|
|
5138
|
+
startContent,
|
|
5139
|
+
endContent,
|
|
5140
|
+
isDisabled = false,
|
|
5141
|
+
customAppearance,
|
|
5142
|
+
onClose,
|
|
5143
|
+
onPress
|
|
5144
|
+
}) => {
|
|
5145
|
+
const [isClosed, setIsClosed] = import_react52.default.useState(false);
|
|
5146
|
+
const [isClosing, setIsClosing] = import_react52.default.useState(false);
|
|
5147
|
+
const sizeStyles = useChipSizeStyles(size);
|
|
5148
|
+
const radiusStyles = useChipRadiusStyles(radius, sizeStyles.height);
|
|
5149
|
+
const variantStyles = useChipVariantStyles(themeColor, variant);
|
|
5150
|
+
const dotSize = useChipDotSize(size);
|
|
5151
|
+
const closeSize = useChipCloseSize(size);
|
|
5152
|
+
const isDotVariant = variant === "dot";
|
|
5153
|
+
const hasClose = onClose !== void 0;
|
|
5154
|
+
const isInteractive = onPress !== void 0 || hasClose;
|
|
5155
|
+
const scale = import_react52.default.useRef(new import_react_native46.Animated.Value(1)).current;
|
|
5156
|
+
const opacity = import_react52.default.useRef(new import_react_native46.Animated.Value(1)).current;
|
|
5157
|
+
const isClosingRef = import_react52.default.useRef(false);
|
|
5158
|
+
const colorProgress = import_react52.default.useRef(new import_react_native46.Animated.Value(1)).current;
|
|
5159
|
+
const targetBackgroundColor = variantStyles.backgroundColor ?? "transparent";
|
|
5160
|
+
const targetBorderColor = variantStyles.borderColor ?? "transparent";
|
|
5161
|
+
const targetTextColor = variantStyles.color ?? "#000000";
|
|
5162
|
+
const targetDotColor = variantStyles.dotColor ?? targetTextColor;
|
|
5163
|
+
const previousColorsRef = import_react52.default.useRef({
|
|
5164
|
+
backgroundColor: targetBackgroundColor,
|
|
5165
|
+
borderColor: targetBorderColor,
|
|
5166
|
+
textColor: targetTextColor,
|
|
5167
|
+
dotColor: targetDotColor
|
|
5168
|
+
});
|
|
5169
|
+
import_react52.default.useEffect(() => {
|
|
5170
|
+
if (previousColorsRef.current.backgroundColor === targetBackgroundColor && previousColorsRef.current.borderColor === targetBorderColor && previousColorsRef.current.textColor === targetTextColor && previousColorsRef.current.dotColor === targetDotColor) {
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5173
|
+
colorProgress.setValue(0);
|
|
5174
|
+
import_react_native46.Animated.timing(colorProgress, {
|
|
5175
|
+
toValue: 1,
|
|
5176
|
+
duration: 180,
|
|
5177
|
+
easing: import_react_native46.Easing.out(import_react_native46.Easing.cubic),
|
|
5178
|
+
useNativeDriver: false
|
|
5179
|
+
}).start(() => {
|
|
5180
|
+
previousColorsRef.current = {
|
|
5181
|
+
backgroundColor: targetBackgroundColor,
|
|
5182
|
+
borderColor: targetBorderColor,
|
|
5183
|
+
textColor: targetTextColor,
|
|
5184
|
+
dotColor: targetDotColor
|
|
5185
|
+
};
|
|
5186
|
+
});
|
|
5187
|
+
}, [
|
|
5188
|
+
colorProgress,
|
|
5189
|
+
targetBackgroundColor,
|
|
5190
|
+
targetBorderColor,
|
|
5191
|
+
targetTextColor,
|
|
5192
|
+
targetDotColor
|
|
5193
|
+
]);
|
|
5194
|
+
const animatedBackgroundColor = colorProgress.interpolate({
|
|
5195
|
+
inputRange: [0, 1],
|
|
5196
|
+
outputRange: [previousColorsRef.current.backgroundColor, targetBackgroundColor]
|
|
5197
|
+
});
|
|
5198
|
+
const animatedBorderColor = colorProgress.interpolate({
|
|
5199
|
+
inputRange: [0, 1],
|
|
5200
|
+
outputRange: [previousColorsRef.current.borderColor, targetBorderColor]
|
|
5201
|
+
});
|
|
5202
|
+
const animatedTextColor = colorProgress.interpolate({
|
|
5203
|
+
inputRange: [0, 1],
|
|
5204
|
+
outputRange: [previousColorsRef.current.textColor, targetTextColor]
|
|
5205
|
+
});
|
|
5206
|
+
const animatedDotColor = colorProgress.interpolate({
|
|
5207
|
+
inputRange: [0, 1],
|
|
5208
|
+
outputRange: [previousColorsRef.current.dotColor, targetDotColor]
|
|
5209
|
+
});
|
|
5210
|
+
const handlePressIn = import_react52.default.useCallback(() => {
|
|
5211
|
+
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
5212
|
+
import_react_native46.Animated.timing(scale, {
|
|
5213
|
+
toValue: 0.97,
|
|
5214
|
+
duration: 90,
|
|
5215
|
+
easing: import_react_native46.Easing.out(import_react_native46.Easing.cubic),
|
|
5216
|
+
useNativeDriver: true
|
|
5217
|
+
}).start();
|
|
5218
|
+
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
5219
|
+
const handlePressOut = import_react52.default.useCallback(() => {
|
|
5220
|
+
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
5221
|
+
import_react_native46.Animated.timing(scale, {
|
|
5222
|
+
toValue: 1,
|
|
5223
|
+
duration: 120,
|
|
5224
|
+
easing: import_react_native46.Easing.out(import_react_native46.Easing.cubic),
|
|
5225
|
+
useNativeDriver: true
|
|
5226
|
+
}).start();
|
|
5227
|
+
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
5228
|
+
const handleChipPress = import_react52.default.useCallback(() => {
|
|
5229
|
+
if (isDisabled || isClosing || isClosingRef.current) return;
|
|
5230
|
+
if (hasClose && onClose) {
|
|
5231
|
+
isClosingRef.current = true;
|
|
5232
|
+
setIsClosing(true);
|
|
5233
|
+
import_react_native46.Animated.parallel([
|
|
5234
|
+
import_react_native46.Animated.timing(opacity, {
|
|
5235
|
+
toValue: 0,
|
|
5236
|
+
duration: 180,
|
|
5237
|
+
easing: import_react_native46.Easing.in(import_react_native46.Easing.quad),
|
|
5238
|
+
useNativeDriver: true
|
|
5239
|
+
}),
|
|
5240
|
+
import_react_native46.Animated.timing(scale, {
|
|
5241
|
+
toValue: 0.88,
|
|
5242
|
+
duration: 180,
|
|
5243
|
+
easing: import_react_native46.Easing.in(import_react_native46.Easing.quad),
|
|
5244
|
+
useNativeDriver: true
|
|
5245
|
+
})
|
|
5246
|
+
]).start(() => {
|
|
5247
|
+
setIsClosed(true);
|
|
5248
|
+
onClose();
|
|
5249
|
+
setIsClosing(false);
|
|
5250
|
+
isClosingRef.current = false;
|
|
5251
|
+
});
|
|
5252
|
+
return;
|
|
5253
|
+
}
|
|
5254
|
+
onPress?.();
|
|
5255
|
+
}, [hasClose, isClosing, isDisabled, onClose, onPress, opacity, scale]);
|
|
5256
|
+
if (isClosed) {
|
|
5257
|
+
return null;
|
|
5258
|
+
}
|
|
5259
|
+
const chipContent = /* @__PURE__ */ import_react52.default.createElement(import_react_native46.Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ import_react52.default.createElement(
|
|
5260
|
+
import_react_native46.Animated.View,
|
|
5261
|
+
{
|
|
5262
|
+
style: [
|
|
5263
|
+
styles14.chip,
|
|
5264
|
+
{
|
|
5265
|
+
height: sizeStyles.height,
|
|
5266
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
5267
|
+
backgroundColor: animatedBackgroundColor,
|
|
5268
|
+
borderWidth: variantStyles.borderWidth,
|
|
5269
|
+
borderColor: animatedBorderColor
|
|
5270
|
+
},
|
|
5271
|
+
radiusStyles,
|
|
4512
5272
|
variantStyles.shadow,
|
|
4513
|
-
isDisabled &&
|
|
5273
|
+
isDisabled && styles14.disabled,
|
|
4514
5274
|
customAppearance?.container
|
|
4515
5275
|
],
|
|
4516
5276
|
accessible: true,
|
|
4517
5277
|
accessibilityRole: "text"
|
|
4518
5278
|
},
|
|
4519
|
-
isDotVariant && /* @__PURE__ */
|
|
4520
|
-
|
|
5279
|
+
isDotVariant && /* @__PURE__ */ import_react52.default.createElement(
|
|
5280
|
+
import_react_native46.Animated.View,
|
|
4521
5281
|
{
|
|
4522
5282
|
style: [
|
|
4523
|
-
|
|
5283
|
+
styles14.dot,
|
|
4524
5284
|
{
|
|
4525
5285
|
width: dotSize,
|
|
4526
5286
|
height: dotSize,
|
|
@@ -4530,31 +5290,31 @@ var Chip = ({
|
|
|
4530
5290
|
]
|
|
4531
5291
|
}
|
|
4532
5292
|
),
|
|
4533
|
-
avatar && /* @__PURE__ */
|
|
4534
|
-
startContent && !avatar && /* @__PURE__ */
|
|
4535
|
-
/* @__PURE__ */
|
|
4536
|
-
|
|
5293
|
+
avatar && /* @__PURE__ */ import_react52.default.createElement(import_react_native46.View, { style: styles14.avatar }, avatar),
|
|
5294
|
+
startContent && !avatar && /* @__PURE__ */ import_react52.default.createElement(import_react_native46.View, { style: styles14.startContent }, startContent),
|
|
5295
|
+
/* @__PURE__ */ import_react52.default.createElement(
|
|
5296
|
+
import_react_native46.Animated.Text,
|
|
4537
5297
|
{
|
|
4538
5298
|
style: [
|
|
4539
|
-
|
|
5299
|
+
styles14.text,
|
|
4540
5300
|
{ fontSize: sizeStyles.fontSize, color: animatedTextColor },
|
|
4541
5301
|
customAppearance?.text
|
|
4542
5302
|
]
|
|
4543
5303
|
},
|
|
4544
5304
|
children
|
|
4545
5305
|
),
|
|
4546
|
-
endContent && !hasClose && /* @__PURE__ */
|
|
4547
|
-
hasClose && /* @__PURE__ */
|
|
4548
|
-
|
|
5306
|
+
endContent && !hasClose && /* @__PURE__ */ import_react52.default.createElement(import_react_native46.View, { style: styles14.endContent }, endContent),
|
|
5307
|
+
hasClose && /* @__PURE__ */ import_react52.default.createElement(
|
|
5308
|
+
import_react_native46.View,
|
|
4549
5309
|
{
|
|
4550
5310
|
style: [
|
|
4551
|
-
|
|
5311
|
+
styles14.closeButton,
|
|
4552
5312
|
{ width: closeSize, height: closeSize },
|
|
4553
5313
|
customAppearance?.closeButton
|
|
4554
5314
|
]
|
|
4555
5315
|
},
|
|
4556
|
-
/* @__PURE__ */
|
|
4557
|
-
|
|
5316
|
+
/* @__PURE__ */ import_react52.default.createElement(
|
|
5317
|
+
import_react_native46.Animated.Text,
|
|
4558
5318
|
{
|
|
4559
5319
|
style: {
|
|
4560
5320
|
fontSize: closeSize - 2,
|
|
@@ -4567,8 +5327,8 @@ var Chip = ({
|
|
|
4567
5327
|
)
|
|
4568
5328
|
));
|
|
4569
5329
|
if (isInteractive) {
|
|
4570
|
-
return /* @__PURE__ */
|
|
4571
|
-
|
|
5330
|
+
return /* @__PURE__ */ import_react52.default.createElement(
|
|
5331
|
+
import_react_native46.Pressable,
|
|
4572
5332
|
{
|
|
4573
5333
|
onPress: isDisabled || isClosing ? void 0 : handleChipPress,
|
|
4574
5334
|
onPressIn: handlePressIn,
|
|
@@ -4582,22 +5342,22 @@ var Chip = ({
|
|
|
4582
5342
|
};
|
|
4583
5343
|
|
|
4584
5344
|
// src/components/chip/chip-group.tsx
|
|
4585
|
-
var
|
|
4586
|
-
var
|
|
5345
|
+
var import_react55 = __toESM(require("react"), 1);
|
|
5346
|
+
var import_react_native47 = require("react-native");
|
|
4587
5347
|
|
|
4588
5348
|
// src/components/chip/chip-context.ts
|
|
4589
|
-
var
|
|
4590
|
-
var ChipGroupContext = (0,
|
|
5349
|
+
var import_react53 = require("react");
|
|
5350
|
+
var ChipGroupContext = (0, import_react53.createContext)(null);
|
|
4591
5351
|
|
|
4592
5352
|
// src/components/chip/chip-group.hook.ts
|
|
4593
|
-
var
|
|
5353
|
+
var import_react54 = require("react");
|
|
4594
5354
|
function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues, onSelectionChange) {
|
|
4595
|
-
const [internalValues, setInternalValues] = (0,
|
|
5355
|
+
const [internalValues, setInternalValues] = (0, import_react54.useState)(
|
|
4596
5356
|
defaultSelectedValues ?? []
|
|
4597
5357
|
);
|
|
4598
5358
|
const isControlled = selectedValues !== void 0;
|
|
4599
5359
|
const currentValues = isControlled ? selectedValues : internalValues;
|
|
4600
|
-
const onToggle = (0,
|
|
5360
|
+
const onToggle = (0, import_react54.useCallback)(
|
|
4601
5361
|
(value) => {
|
|
4602
5362
|
const isSelected = currentValues.includes(value);
|
|
4603
5363
|
let nextValues;
|
|
@@ -4613,10 +5373,7 @@ function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues
|
|
|
4613
5373
|
},
|
|
4614
5374
|
[currentValues, isControlled, onSelectionChange, selectMode]
|
|
4615
5375
|
);
|
|
4616
|
-
return (0,
|
|
4617
|
-
() => ({ currentValues, onToggle }),
|
|
4618
|
-
[currentValues, onToggle]
|
|
4619
|
-
);
|
|
5376
|
+
return (0, import_react54.useMemo)(() => ({ currentValues, onToggle }), [currentValues, onToggle]);
|
|
4620
5377
|
}
|
|
4621
5378
|
|
|
4622
5379
|
// src/components/chip/chip-group.tsx
|
|
@@ -4641,7 +5398,7 @@ var ChipGroup = ({
|
|
|
4641
5398
|
defaultSelectedValues,
|
|
4642
5399
|
onSelectionChange
|
|
4643
5400
|
);
|
|
4644
|
-
const contextValue =
|
|
5401
|
+
const contextValue = import_react55.default.useMemo(
|
|
4645
5402
|
() => ({
|
|
4646
5403
|
variant,
|
|
4647
5404
|
themeColor,
|
|
@@ -4665,11 +5422,11 @@ var ChipGroup = ({
|
|
|
4665
5422
|
onToggle
|
|
4666
5423
|
]
|
|
4667
5424
|
);
|
|
4668
|
-
return /* @__PURE__ */
|
|
4669
|
-
|
|
5425
|
+
return /* @__PURE__ */ import_react55.default.createElement(ChipGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react55.default.createElement(
|
|
5426
|
+
import_react_native47.View,
|
|
4670
5427
|
{
|
|
4671
5428
|
style: [
|
|
4672
|
-
|
|
5429
|
+
styles14.groupContainer,
|
|
4673
5430
|
{ gap: spacing },
|
|
4674
5431
|
customAppearance?.container
|
|
4675
5432
|
],
|
|
@@ -4680,7 +5437,7 @@ var ChipGroup = ({
|
|
|
4680
5437
|
};
|
|
4681
5438
|
|
|
4682
5439
|
// src/components/chip/chip-item.tsx
|
|
4683
|
-
var
|
|
5440
|
+
var import_react56 = __toESM(require("react"), 1);
|
|
4684
5441
|
function getSelectableVariant(baseVariant, isSelected) {
|
|
4685
5442
|
if (isSelected) {
|
|
4686
5443
|
return baseVariant;
|
|
@@ -4701,7 +5458,7 @@ var ChipItem = ({
|
|
|
4701
5458
|
isDisabled,
|
|
4702
5459
|
customAppearance
|
|
4703
5460
|
}) => {
|
|
4704
|
-
const groupContext = (0,
|
|
5461
|
+
const groupContext = (0, import_react56.useContext)(ChipGroupContext);
|
|
4705
5462
|
if (!groupContext) {
|
|
4706
5463
|
return null;
|
|
4707
5464
|
}
|
|
@@ -4711,7 +5468,7 @@ var ChipItem = ({
|
|
|
4711
5468
|
const isSelected = groupContext.selectedValues.includes(value);
|
|
4712
5469
|
const chipVariant = groupContext.isSelectable ? getSelectableVariant(resolvedVariant, isSelected) : resolvedVariant;
|
|
4713
5470
|
const handlePress = groupContext.isSelectable ? () => groupContext.onToggle(value) : void 0;
|
|
4714
|
-
return /* @__PURE__ */
|
|
5471
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
4715
5472
|
Chip,
|
|
4716
5473
|
{
|
|
4717
5474
|
variant: chipVariant,
|
|
@@ -4730,16 +5487,16 @@ var ChipItem = ({
|
|
|
4730
5487
|
};
|
|
4731
5488
|
|
|
4732
5489
|
// src/components/bottom-sheet/bottom-sheet.tsx
|
|
4733
|
-
var
|
|
4734
|
-
var
|
|
5490
|
+
var import_react58 = __toESM(require("react"), 1);
|
|
5491
|
+
var import_react_native51 = require("react-native");
|
|
4735
5492
|
|
|
4736
5493
|
// src/components/bottom-sheet/bottom-sheet.hook.ts
|
|
4737
|
-
var
|
|
4738
|
-
var
|
|
4739
|
-
var
|
|
5494
|
+
var import_react57 = require("react");
|
|
5495
|
+
var import_react_native49 = require("react-native");
|
|
5496
|
+
var import_core37 = require("@xaui/core");
|
|
4740
5497
|
|
|
4741
5498
|
// src/components/bottom-sheet/bottom-sheet.animation.ts
|
|
4742
|
-
var
|
|
5499
|
+
var import_react_native48 = require("react-native");
|
|
4743
5500
|
var SPRING_CONFIG = {
|
|
4744
5501
|
useNativeDriver: true,
|
|
4745
5502
|
speed: 14,
|
|
@@ -4747,16 +5504,16 @@ var SPRING_CONFIG = {
|
|
|
4747
5504
|
};
|
|
4748
5505
|
var TIMING_CONFIG = {
|
|
4749
5506
|
duration: 280,
|
|
4750
|
-
easing:
|
|
5507
|
+
easing: import_react_native48.Easing.bezier(0.2, 0, 0, 1),
|
|
4751
5508
|
useNativeDriver: true
|
|
4752
5509
|
};
|
|
4753
5510
|
var runOpenAnimation = (translateY, backdropOpacity, targetTranslateY) => {
|
|
4754
|
-
const animation =
|
|
4755
|
-
|
|
5511
|
+
const animation = import_react_native48.Animated.parallel([
|
|
5512
|
+
import_react_native48.Animated.spring(translateY, {
|
|
4756
5513
|
...SPRING_CONFIG,
|
|
4757
5514
|
toValue: targetTranslateY
|
|
4758
5515
|
}),
|
|
4759
|
-
|
|
5516
|
+
import_react_native48.Animated.timing(backdropOpacity, {
|
|
4760
5517
|
...TIMING_CONFIG,
|
|
4761
5518
|
toValue: 1
|
|
4762
5519
|
})
|
|
@@ -4765,12 +5522,12 @@ var runOpenAnimation = (translateY, backdropOpacity, targetTranslateY) => {
|
|
|
4765
5522
|
return animation;
|
|
4766
5523
|
};
|
|
4767
5524
|
var runCloseAnimation = (translateY, backdropOpacity, screenHeight, onComplete) => {
|
|
4768
|
-
const animation =
|
|
4769
|
-
|
|
5525
|
+
const animation = import_react_native48.Animated.parallel([
|
|
5526
|
+
import_react_native48.Animated.timing(translateY, {
|
|
4770
5527
|
...TIMING_CONFIG,
|
|
4771
5528
|
toValue: screenHeight
|
|
4772
5529
|
}),
|
|
4773
|
-
|
|
5530
|
+
import_react_native48.Animated.timing(backdropOpacity, {
|
|
4774
5531
|
...TIMING_CONFIG,
|
|
4775
5532
|
toValue: 0
|
|
4776
5533
|
})
|
|
@@ -4783,7 +5540,7 @@ var runCloseAnimation = (translateY, backdropOpacity, screenHeight, onComplete)
|
|
|
4783
5540
|
return animation;
|
|
4784
5541
|
};
|
|
4785
5542
|
var runSnapAnimation = (translateY, targetTranslateY) => {
|
|
4786
|
-
const animation =
|
|
5543
|
+
const animation = import_react_native48.Animated.spring(translateY, {
|
|
4787
5544
|
...SPRING_CONFIG,
|
|
4788
5545
|
toValue: targetTranslateY
|
|
4789
5546
|
});
|
|
@@ -4794,7 +5551,7 @@ var runSnapAnimation = (translateY, targetTranslateY) => {
|
|
|
4794
5551
|
// src/components/bottom-sheet/bottom-sheet.hook.ts
|
|
4795
5552
|
var DISMISS_VELOCITY_THRESHOLD = 0.5;
|
|
4796
5553
|
var DISMISS_DISTANCE_FRACTION = 0.3;
|
|
4797
|
-
var SCREEN_HEIGHT =
|
|
5554
|
+
var SCREEN_HEIGHT = import_react_native49.Dimensions.get("window").height;
|
|
4798
5555
|
var getTranslateYForSnap = (snapFraction) => SCREEN_HEIGHT * (1 - snapFraction);
|
|
4799
5556
|
var useBottomSheetAnimation = ({
|
|
4800
5557
|
isOpen,
|
|
@@ -4805,20 +5562,20 @@ var useBottomSheetAnimation = ({
|
|
|
4805
5562
|
onClose,
|
|
4806
5563
|
onSnapChange
|
|
4807
5564
|
}) => {
|
|
4808
|
-
const [shouldRender, setShouldRender] = (0,
|
|
4809
|
-
const currentSnapIndex = (0,
|
|
4810
|
-
const animationRef = (0,
|
|
4811
|
-
const translateY = (0,
|
|
4812
|
-
const backdropOpacity = (0,
|
|
4813
|
-
const sortedSnapPoints = (0,
|
|
5565
|
+
const [shouldRender, setShouldRender] = (0, import_react57.useState)(false);
|
|
5566
|
+
const currentSnapIndex = (0, import_react57.useRef)(initialSnapIndex);
|
|
5567
|
+
const animationRef = (0, import_react57.useRef)(null);
|
|
5568
|
+
const translateY = (0, import_react57.useRef)(new import_react_native49.Animated.Value(SCREEN_HEIGHT)).current;
|
|
5569
|
+
const backdropOpacity = (0, import_react57.useRef)(new import_react_native49.Animated.Value(0)).current;
|
|
5570
|
+
const sortedSnapPoints = (0, import_react57.useMemo)(
|
|
4814
5571
|
() => [...snapPoints].sort((a, b) => a - b),
|
|
4815
5572
|
[snapPoints]
|
|
4816
5573
|
);
|
|
4817
|
-
const snapTranslateValues = (0,
|
|
5574
|
+
const snapTranslateValues = (0, import_react57.useMemo)(
|
|
4818
5575
|
() => sortedSnapPoints.map(getTranslateYForSnap),
|
|
4819
5576
|
[sortedSnapPoints]
|
|
4820
5577
|
);
|
|
4821
|
-
const open = (0,
|
|
5578
|
+
const open = (0, import_react57.useCallback)(() => {
|
|
4822
5579
|
setShouldRender(true);
|
|
4823
5580
|
const targetIndex = Math.min(initialSnapIndex, sortedSnapPoints.length - 1);
|
|
4824
5581
|
currentSnapIndex.current = targetIndex;
|
|
@@ -4843,7 +5600,7 @@ var useBottomSheetAnimation = ({
|
|
|
4843
5600
|
translateY,
|
|
4844
5601
|
backdropOpacity
|
|
4845
5602
|
]);
|
|
4846
|
-
const close = (0,
|
|
5603
|
+
const close = (0, import_react57.useCallback)(() => {
|
|
4847
5604
|
if (disableAnimation) {
|
|
4848
5605
|
translateY.setValue(SCREEN_HEIGHT);
|
|
4849
5606
|
backdropOpacity.setValue(0);
|
|
@@ -4862,7 +5619,7 @@ var useBottomSheetAnimation = ({
|
|
|
4862
5619
|
}
|
|
4863
5620
|
);
|
|
4864
5621
|
}, [disableAnimation, translateY, backdropOpacity, onClose]);
|
|
4865
|
-
const snapTo = (0,
|
|
5622
|
+
const snapTo = (0, import_react57.useCallback)(
|
|
4866
5623
|
(index) => {
|
|
4867
5624
|
const clampedIndex = Math.max(0, Math.min(index, sortedSnapPoints.length - 1));
|
|
4868
5625
|
currentSnapIndex.current = clampedIndex;
|
|
@@ -4877,17 +5634,23 @@ var useBottomSheetAnimation = ({
|
|
|
4877
5634
|
snapTranslateValues[clampedIndex]
|
|
4878
5635
|
);
|
|
4879
5636
|
},
|
|
4880
|
-
[
|
|
5637
|
+
[
|
|
5638
|
+
sortedSnapPoints,
|
|
5639
|
+
snapTranslateValues,
|
|
5640
|
+
disableAnimation,
|
|
5641
|
+
translateY,
|
|
5642
|
+
onSnapChange
|
|
5643
|
+
]
|
|
4881
5644
|
);
|
|
4882
|
-
(0,
|
|
5645
|
+
(0, import_react57.useEffect)(() => {
|
|
4883
5646
|
if (isOpen) {
|
|
4884
5647
|
open();
|
|
4885
5648
|
} else if (shouldRender) {
|
|
4886
5649
|
close();
|
|
4887
5650
|
}
|
|
4888
5651
|
}, [isOpen]);
|
|
4889
|
-
const panResponder = (0,
|
|
4890
|
-
() =>
|
|
5652
|
+
const panResponder = (0, import_react57.useMemo)(
|
|
5653
|
+
() => import_react_native49.PanResponder.create({
|
|
4891
5654
|
onStartShouldSetPanResponder: () => true,
|
|
4892
5655
|
onMoveShouldSetPanResponder: (_, gestureState) => Math.abs(gestureState.dy) > 5,
|
|
4893
5656
|
onPanResponderMove: (_, gestureState) => {
|
|
@@ -4954,9 +5717,9 @@ var useBottomSheetAnimation = ({
|
|
|
4954
5717
|
};
|
|
4955
5718
|
var useBottomSheetStyles = (themeColor, radius) => {
|
|
4956
5719
|
const theme = useXUITheme();
|
|
4957
|
-
const safeThemeColor = (0,
|
|
5720
|
+
const safeThemeColor = (0, import_core37.getSafeThemeColor)(themeColor);
|
|
4958
5721
|
const colorScheme = theme.colors[safeThemeColor];
|
|
4959
|
-
const sheetStyles = (0,
|
|
5722
|
+
const sheetStyles = (0, import_react57.useMemo)(
|
|
4960
5723
|
() => ({
|
|
4961
5724
|
backgroundColor: colorScheme.background ?? theme.colors.background ?? "#ffffff",
|
|
4962
5725
|
borderTopLeftRadius: theme.borderRadius[radius],
|
|
@@ -4964,7 +5727,7 @@ var useBottomSheetStyles = (themeColor, radius) => {
|
|
|
4964
5727
|
}),
|
|
4965
5728
|
[theme, colorScheme, radius]
|
|
4966
5729
|
);
|
|
4967
|
-
const handleIndicatorColor = (0,
|
|
5730
|
+
const handleIndicatorColor = (0, import_react57.useMemo)(
|
|
4968
5731
|
() => theme.mode === "dark" ? `${colorScheme.main}60` : `${colorScheme.main}40`,
|
|
4969
5732
|
[theme, colorScheme]
|
|
4970
5733
|
);
|
|
@@ -4972,8 +5735,8 @@ var useBottomSheetStyles = (themeColor, radius) => {
|
|
|
4972
5735
|
};
|
|
4973
5736
|
|
|
4974
5737
|
// src/components/bottom-sheet/bottom-sheet.style.ts
|
|
4975
|
-
var
|
|
4976
|
-
var
|
|
5738
|
+
var import_react_native50 = require("react-native");
|
|
5739
|
+
var styles15 = import_react_native50.StyleSheet.create({
|
|
4977
5740
|
backdrop: {
|
|
4978
5741
|
position: "absolute",
|
|
4979
5742
|
top: 0,
|
|
@@ -5052,53 +5815,630 @@ var BottomSheet = ({
|
|
|
5052
5815
|
close();
|
|
5053
5816
|
}
|
|
5054
5817
|
};
|
|
5055
|
-
return /* @__PURE__ */
|
|
5056
|
-
|
|
5057
|
-
{
|
|
5058
|
-
style: [styles13.backdrop, { opacity: backdropOpacity }]
|
|
5059
|
-
},
|
|
5060
|
-
/* @__PURE__ */ import_react50.default.createElement(
|
|
5061
|
-
import_react_native44.Pressable,
|
|
5062
|
-
{
|
|
5063
|
-
style: styles13.backdrop,
|
|
5064
|
-
onPress: handleBackdropPress
|
|
5065
|
-
}
|
|
5066
|
-
)
|
|
5067
|
-
), /* @__PURE__ */ import_react50.default.createElement(
|
|
5068
|
-
import_react_native44.Animated.View,
|
|
5818
|
+
return /* @__PURE__ */ import_react58.default.createElement(Portal, null, showBackdrop && /* @__PURE__ */ import_react58.default.createElement(import_react_native51.Animated.View, { style: [styles15.backdrop, { opacity: backdropOpacity }] }, /* @__PURE__ */ import_react58.default.createElement(import_react_native51.Pressable, { style: styles15.backdrop, onPress: handleBackdropPress })), /* @__PURE__ */ import_react58.default.createElement(
|
|
5819
|
+
import_react_native51.Animated.View,
|
|
5069
5820
|
{
|
|
5070
5821
|
style: [
|
|
5071
|
-
|
|
5822
|
+
styles15.container,
|
|
5072
5823
|
{
|
|
5073
5824
|
height: screenHeight,
|
|
5074
5825
|
transform: [{ translateY }]
|
|
5075
5826
|
}
|
|
5076
5827
|
]
|
|
5077
5828
|
},
|
|
5078
|
-
/* @__PURE__ */
|
|
5079
|
-
|
|
5829
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5830
|
+
import_react_native51.View,
|
|
5080
5831
|
{
|
|
5081
|
-
style: [
|
|
5082
|
-
styles13.sheet,
|
|
5083
|
-
{ height: screenHeight },
|
|
5084
|
-
sheetStyles,
|
|
5085
|
-
style
|
|
5086
|
-
],
|
|
5832
|
+
style: [styles15.sheet, { height: screenHeight }, sheetStyles, style],
|
|
5087
5833
|
...panResponder.panHandlers
|
|
5088
5834
|
},
|
|
5089
|
-
showHandle && /* @__PURE__ */
|
|
5090
|
-
|
|
5835
|
+
showHandle && /* @__PURE__ */ import_react58.default.createElement(import_react_native51.View, { style: styles15.handle }, handleContent ?? /* @__PURE__ */ import_react58.default.createElement(
|
|
5836
|
+
import_react_native51.View,
|
|
5091
5837
|
{
|
|
5092
5838
|
style: [
|
|
5093
|
-
|
|
5839
|
+
styles15.handleIndicator,
|
|
5094
5840
|
{ backgroundColor: handleIndicatorColor }
|
|
5095
5841
|
]
|
|
5096
5842
|
}
|
|
5097
5843
|
)),
|
|
5098
|
-
/* @__PURE__ */
|
|
5844
|
+
/* @__PURE__ */ import_react58.default.createElement(import_react_native51.View, { style: styles15.content }, children)
|
|
5845
|
+
)
|
|
5846
|
+
));
|
|
5847
|
+
};
|
|
5848
|
+
|
|
5849
|
+
// src/components/fab/fab.tsx
|
|
5850
|
+
var import_react60 = __toESM(require("react"), 1);
|
|
5851
|
+
var import_react_native54 = require("react-native");
|
|
5852
|
+
|
|
5853
|
+
// src/components/fab/fab.style.ts
|
|
5854
|
+
var import_react_native52 = require("react-native");
|
|
5855
|
+
var styles16 = import_react_native52.StyleSheet.create({
|
|
5856
|
+
container: {
|
|
5857
|
+
alignSelf: "flex-start"
|
|
5858
|
+
},
|
|
5859
|
+
fab: {
|
|
5860
|
+
flexDirection: "row",
|
|
5861
|
+
alignItems: "center",
|
|
5862
|
+
justifyContent: "center",
|
|
5863
|
+
overflow: "hidden"
|
|
5864
|
+
},
|
|
5865
|
+
contentContainer: {
|
|
5866
|
+
flexDirection: "row",
|
|
5867
|
+
alignItems: "center",
|
|
5868
|
+
justifyContent: "center",
|
|
5869
|
+
gap: 12
|
|
5870
|
+
},
|
|
5871
|
+
label: {
|
|
5872
|
+
fontWeight: "500"
|
|
5873
|
+
},
|
|
5874
|
+
disabled: {
|
|
5875
|
+
opacity: 0.5
|
|
5876
|
+
}
|
|
5877
|
+
});
|
|
5878
|
+
|
|
5879
|
+
// src/components/fab/fab.hook.ts
|
|
5880
|
+
var import_react59 = require("react");
|
|
5881
|
+
var import_core39 = require("@xaui/core");
|
|
5882
|
+
function useFabSizeStyles(size) {
|
|
5883
|
+
const theme = useXUITheme();
|
|
5884
|
+
const sizeStyles = (0, import_react59.useMemo)(() => {
|
|
5885
|
+
const sizes = {
|
|
5886
|
+
sm: {
|
|
5887
|
+
width: 40,
|
|
5888
|
+
height: 40,
|
|
5889
|
+
borderRadius: theme.borderRadius.lg,
|
|
5890
|
+
iconSize: 24,
|
|
5891
|
+
fontSize: theme.fontSizes.sm
|
|
5892
|
+
},
|
|
5893
|
+
md: {
|
|
5894
|
+
width: 56,
|
|
5895
|
+
height: 56,
|
|
5896
|
+
borderRadius: theme.borderRadius.xl,
|
|
5897
|
+
iconSize: 24,
|
|
5898
|
+
fontSize: theme.fontSizes.md
|
|
5899
|
+
},
|
|
5900
|
+
lg: {
|
|
5901
|
+
width: 96,
|
|
5902
|
+
height: 96,
|
|
5903
|
+
borderRadius: theme.borderRadius["2xl"],
|
|
5904
|
+
iconSize: 36,
|
|
5905
|
+
fontSize: theme.fontSizes.lg
|
|
5906
|
+
}
|
|
5907
|
+
};
|
|
5908
|
+
return sizes[size];
|
|
5909
|
+
}, [size, theme]);
|
|
5910
|
+
const extendedSizeStyles = (0, import_react59.useMemo)(() => {
|
|
5911
|
+
const sizes = {
|
|
5912
|
+
sm: {
|
|
5913
|
+
height: 40,
|
|
5914
|
+
borderRadius: theme.borderRadius.lg,
|
|
5915
|
+
paddingHorizontal: theme.spacing.md,
|
|
5916
|
+
iconSize: 20,
|
|
5917
|
+
fontSize: theme.fontSizes.sm
|
|
5918
|
+
},
|
|
5919
|
+
md: {
|
|
5920
|
+
height: 56,
|
|
5921
|
+
borderRadius: theme.borderRadius.xl,
|
|
5922
|
+
paddingHorizontal: theme.spacing.lg,
|
|
5923
|
+
iconSize: 24,
|
|
5924
|
+
fontSize: theme.fontSizes.md
|
|
5925
|
+
},
|
|
5926
|
+
lg: {
|
|
5927
|
+
height: 80,
|
|
5928
|
+
borderRadius: theme.borderRadius["2xl"],
|
|
5929
|
+
paddingHorizontal: theme.spacing.xl,
|
|
5930
|
+
iconSize: 28,
|
|
5931
|
+
fontSize: theme.fontSizes.lg
|
|
5932
|
+
}
|
|
5933
|
+
};
|
|
5934
|
+
return sizes[size];
|
|
5935
|
+
}, [size, theme]);
|
|
5936
|
+
return { sizeStyles, extendedSizeStyles };
|
|
5937
|
+
}
|
|
5938
|
+
function useFabVariantStyles(themeColor, variant, elevation = 0) {
|
|
5939
|
+
const theme = useXUITheme();
|
|
5940
|
+
const safeThemeColor = (0, import_core39.getSafeThemeColor)(themeColor);
|
|
5941
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
5942
|
+
const variantStyles = (0, import_react59.useMemo)(() => {
|
|
5943
|
+
const variantMap = {
|
|
5944
|
+
solid: {
|
|
5945
|
+
backgroundColor: colorScheme.main,
|
|
5946
|
+
borderWidth: 0
|
|
5947
|
+
},
|
|
5948
|
+
flat: {
|
|
5949
|
+
backgroundColor: colorScheme.background,
|
|
5950
|
+
borderWidth: 0
|
|
5951
|
+
},
|
|
5952
|
+
outlined: {
|
|
5953
|
+
backgroundColor: "transparent",
|
|
5954
|
+
borderWidth: theme.borderWidth.md,
|
|
5955
|
+
borderColor: colorScheme.main
|
|
5956
|
+
}
|
|
5957
|
+
};
|
|
5958
|
+
const baseStyle = variantMap[variant];
|
|
5959
|
+
const shouldApplyElevation = variant !== "outlined";
|
|
5960
|
+
const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
|
|
5961
|
+
return {
|
|
5962
|
+
...baseStyle,
|
|
5963
|
+
...shouldApplyElevation ? shadowStyles : {},
|
|
5964
|
+
...shouldApplyElevation && elevation > 0 ? { elevation } : {}
|
|
5965
|
+
};
|
|
5966
|
+
}, [variant, colorScheme, theme, elevation]);
|
|
5967
|
+
return variantStyles;
|
|
5968
|
+
}
|
|
5969
|
+
function useFabIconColor(themeColor, variant) {
|
|
5970
|
+
const theme = useXUITheme();
|
|
5971
|
+
const safeThemeColor = (0, import_core39.getSafeThemeColor)(themeColor);
|
|
5972
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
5973
|
+
const iconColor = (0, import_react59.useMemo)(() => {
|
|
5974
|
+
if (variant === "solid") {
|
|
5975
|
+
return colorScheme.foreground;
|
|
5976
|
+
}
|
|
5977
|
+
return colorScheme.main;
|
|
5978
|
+
}, [variant, colorScheme]);
|
|
5979
|
+
return { iconColor };
|
|
5980
|
+
}
|
|
5981
|
+
function useFabRadiusValue(radius, fallback) {
|
|
5982
|
+
const theme = useXUITheme();
|
|
5983
|
+
return (0, import_react59.useMemo)(() => {
|
|
5984
|
+
if (!radius) return fallback;
|
|
5985
|
+
const radiusMap = {
|
|
5986
|
+
none: theme.borderRadius.none,
|
|
5987
|
+
sm: theme.borderRadius.sm,
|
|
5988
|
+
md: theme.borderRadius.md,
|
|
5989
|
+
lg: theme.borderRadius.lg,
|
|
5990
|
+
full: theme.borderRadius.full
|
|
5991
|
+
};
|
|
5992
|
+
return radiusMap[radius];
|
|
5993
|
+
}, [fallback, radius, theme]);
|
|
5994
|
+
}
|
|
5995
|
+
|
|
5996
|
+
// src/components/fab/fab.animation.ts
|
|
5997
|
+
var import_react_native53 = require("react-native");
|
|
5998
|
+
var runFabPressInAnimation = (animatedScale, animatedOpacity) => {
|
|
5999
|
+
import_react_native53.Animated.parallel([
|
|
6000
|
+
import_react_native53.Animated.spring(animatedScale, {
|
|
6001
|
+
toValue: 0.92,
|
|
6002
|
+
useNativeDriver: true,
|
|
6003
|
+
speed: 50,
|
|
6004
|
+
bounciness: 0
|
|
6005
|
+
}),
|
|
6006
|
+
import_react_native53.Animated.timing(animatedOpacity, {
|
|
6007
|
+
toValue: 0.85,
|
|
6008
|
+
duration: 100,
|
|
6009
|
+
useNativeDriver: true
|
|
6010
|
+
})
|
|
6011
|
+
]).start();
|
|
6012
|
+
};
|
|
6013
|
+
var runFabPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
6014
|
+
import_react_native53.Animated.parallel([
|
|
6015
|
+
import_react_native53.Animated.spring(animatedScale, {
|
|
6016
|
+
toValue: 1,
|
|
6017
|
+
useNativeDriver: true,
|
|
6018
|
+
speed: 50,
|
|
6019
|
+
bounciness: 0
|
|
6020
|
+
}),
|
|
6021
|
+
import_react_native53.Animated.timing(animatedOpacity, {
|
|
6022
|
+
toValue: 1,
|
|
6023
|
+
duration: 100,
|
|
6024
|
+
useNativeDriver: true
|
|
6025
|
+
})
|
|
6026
|
+
]).start();
|
|
6027
|
+
};
|
|
6028
|
+
|
|
6029
|
+
// src/components/fab/fab.tsx
|
|
6030
|
+
var Fab = ({
|
|
6031
|
+
icon,
|
|
6032
|
+
label,
|
|
6033
|
+
themeColor = "primary",
|
|
6034
|
+
variant = "solid",
|
|
6035
|
+
size = "md",
|
|
6036
|
+
radius,
|
|
6037
|
+
isDisabled = false,
|
|
6038
|
+
isLoading = false,
|
|
6039
|
+
elevation = 0,
|
|
6040
|
+
customAppearance,
|
|
6041
|
+
onPress,
|
|
6042
|
+
onLongPress,
|
|
6043
|
+
onPressIn,
|
|
6044
|
+
onPressOut
|
|
6045
|
+
}) => {
|
|
6046
|
+
const animatedScale = import_react60.default.useRef(new import_react_native54.Animated.Value(1)).current;
|
|
6047
|
+
const animatedOpacity = import_react60.default.useRef(new import_react_native54.Animated.Value(1)).current;
|
|
6048
|
+
const { sizeStyles, extendedSizeStyles } = useFabSizeStyles(size);
|
|
6049
|
+
const variantStyles = useFabVariantStyles(themeColor, variant, elevation);
|
|
6050
|
+
const { iconColor } = useFabIconColor(themeColor, variant);
|
|
6051
|
+
const isExtended = !!label;
|
|
6052
|
+
const resolvedRadius = useFabRadiusValue(
|
|
6053
|
+
radius,
|
|
6054
|
+
isExtended ? extendedSizeStyles.borderRadius : sizeStyles.borderRadius
|
|
6055
|
+
);
|
|
6056
|
+
const handlePressIn = (event) => {
|
|
6057
|
+
if (!isDisabled && !isLoading) {
|
|
6058
|
+
runFabPressInAnimation(animatedScale, animatedOpacity);
|
|
6059
|
+
}
|
|
6060
|
+
onPressIn?.(event);
|
|
6061
|
+
};
|
|
6062
|
+
const handlePressOut = (event) => {
|
|
6063
|
+
if (!isDisabled && !isLoading) {
|
|
6064
|
+
runFabPressOutAnimation(animatedScale, animatedOpacity);
|
|
6065
|
+
}
|
|
6066
|
+
onPressOut?.(event);
|
|
6067
|
+
};
|
|
6068
|
+
const fabDimensionStyles = isExtended ? {
|
|
6069
|
+
height: extendedSizeStyles.height,
|
|
6070
|
+
borderRadius: resolvedRadius,
|
|
6071
|
+
paddingHorizontal: extendedSizeStyles.paddingHorizontal
|
|
6072
|
+
} : {
|
|
6073
|
+
width: sizeStyles.width,
|
|
6074
|
+
height: sizeStyles.height,
|
|
6075
|
+
borderRadius: resolvedRadius
|
|
6076
|
+
};
|
|
6077
|
+
return /* @__PURE__ */ import_react60.default.createElement(import_react_native54.View, { style: [styles16.container, customAppearance?.container] }, /* @__PURE__ */ import_react60.default.createElement(
|
|
6078
|
+
import_react_native54.Pressable,
|
|
6079
|
+
{
|
|
6080
|
+
onPress: isDisabled || isLoading ? void 0 : onPress,
|
|
6081
|
+
onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
|
|
6082
|
+
onPressIn: handlePressIn,
|
|
6083
|
+
onPressOut: handlePressOut,
|
|
6084
|
+
disabled: isDisabled || isLoading
|
|
6085
|
+
},
|
|
6086
|
+
/* @__PURE__ */ import_react60.default.createElement(
|
|
6087
|
+
import_react_native54.Animated.View,
|
|
6088
|
+
{
|
|
6089
|
+
style: [
|
|
6090
|
+
styles16.fab,
|
|
6091
|
+
fabDimensionStyles,
|
|
6092
|
+
variantStyles,
|
|
6093
|
+
isDisabled && styles16.disabled,
|
|
6094
|
+
{
|
|
6095
|
+
transform: [{ scale: animatedScale }],
|
|
6096
|
+
opacity: animatedOpacity
|
|
6097
|
+
},
|
|
6098
|
+
customAppearance?.fab
|
|
6099
|
+
]
|
|
6100
|
+
},
|
|
6101
|
+
isLoading ? /* @__PURE__ */ import_react60.default.createElement(
|
|
6102
|
+
ActivityIndicator,
|
|
6103
|
+
{
|
|
6104
|
+
variant: "circular",
|
|
6105
|
+
themeColor: variant === "solid" ? void 0 : themeColor,
|
|
6106
|
+
color: variant === "solid" ? iconColor : void 0,
|
|
6107
|
+
size: isExtended ? extendedSizeStyles.iconSize : sizeStyles.iconSize
|
|
6108
|
+
}
|
|
6109
|
+
) : /* @__PURE__ */ import_react60.default.createElement(import_react_native54.View, { style: styles16.contentContainer }, icon, isExtended && /* @__PURE__ */ import_react60.default.createElement(
|
|
6110
|
+
import_react_native54.Text,
|
|
6111
|
+
{
|
|
6112
|
+
style: [
|
|
6113
|
+
styles16.label,
|
|
6114
|
+
{
|
|
6115
|
+
fontSize: isExtended ? extendedSizeStyles.fontSize : sizeStyles.fontSize,
|
|
6116
|
+
color: iconColor
|
|
6117
|
+
}
|
|
6118
|
+
]
|
|
6119
|
+
},
|
|
6120
|
+
label
|
|
6121
|
+
))
|
|
5099
6122
|
)
|
|
5100
6123
|
));
|
|
5101
6124
|
};
|
|
6125
|
+
|
|
6126
|
+
// src/components/fab-menu/fab-menu.tsx
|
|
6127
|
+
var import_react62 = __toESM(require("react"), 1);
|
|
6128
|
+
var import_react_native57 = require("react-native");
|
|
6129
|
+
|
|
6130
|
+
// src/components/fab-menu/fab-menu.style.ts
|
|
6131
|
+
var import_react_native55 = require("react-native");
|
|
6132
|
+
var styles17 = import_react_native55.StyleSheet.create({
|
|
6133
|
+
container: {
|
|
6134
|
+
position: "relative",
|
|
6135
|
+
alignItems: "flex-end"
|
|
6136
|
+
},
|
|
6137
|
+
portalRoot: {
|
|
6138
|
+
...import_react_native55.StyleSheet.absoluteFillObject
|
|
6139
|
+
},
|
|
6140
|
+
overlay: {
|
|
6141
|
+
...import_react_native55.StyleSheet.absoluteFillObject
|
|
6142
|
+
},
|
|
6143
|
+
overlayPressable: {
|
|
6144
|
+
flex: 1
|
|
6145
|
+
},
|
|
6146
|
+
portalContent: {
|
|
6147
|
+
...import_react_native55.StyleSheet.absoluteFillObject,
|
|
6148
|
+
justifyContent: "flex-end",
|
|
6149
|
+
alignItems: "flex-end",
|
|
6150
|
+
padding: 16
|
|
6151
|
+
},
|
|
6152
|
+
menuContainer: {
|
|
6153
|
+
alignItems: "flex-end",
|
|
6154
|
+
marginBottom: 16
|
|
6155
|
+
},
|
|
6156
|
+
menuItem: {
|
|
6157
|
+
marginBottom: 12
|
|
6158
|
+
},
|
|
6159
|
+
menuItemChip: {
|
|
6160
|
+
flexDirection: "row",
|
|
6161
|
+
alignItems: "center",
|
|
6162
|
+
paddingVertical: 12,
|
|
6163
|
+
paddingLeft: 16,
|
|
6164
|
+
paddingRight: 20,
|
|
6165
|
+
gap: 8
|
|
6166
|
+
},
|
|
6167
|
+
menuItemLabel: {
|
|
6168
|
+
fontWeight: "500"
|
|
6169
|
+
},
|
|
6170
|
+
disabled: {
|
|
6171
|
+
opacity: 0.5
|
|
6172
|
+
}
|
|
6173
|
+
});
|
|
6174
|
+
|
|
6175
|
+
// src/components/fab-menu/fab-menu.hook.ts
|
|
6176
|
+
var import_react61 = require("react");
|
|
6177
|
+
var import_core41 = require("@xaui/core");
|
|
6178
|
+
function useFabMenuState(controlledExpanded, onToggle) {
|
|
6179
|
+
const [internalExpanded, setInternalExpanded] = (0, import_react61.useState)(false);
|
|
6180
|
+
const isControlled = controlledExpanded !== void 0;
|
|
6181
|
+
const expanded = isControlled ? controlledExpanded : internalExpanded;
|
|
6182
|
+
const toggle = (0, import_react61.useCallback)(() => {
|
|
6183
|
+
const next = !expanded;
|
|
6184
|
+
if (!isControlled) {
|
|
6185
|
+
setInternalExpanded(next);
|
|
6186
|
+
}
|
|
6187
|
+
onToggle?.(next);
|
|
6188
|
+
}, [expanded, isControlled, onToggle]);
|
|
6189
|
+
const close = (0, import_react61.useCallback)(() => {
|
|
6190
|
+
if (!isControlled) {
|
|
6191
|
+
setInternalExpanded(false);
|
|
6192
|
+
}
|
|
6193
|
+
onToggle?.(false);
|
|
6194
|
+
}, [isControlled, onToggle]);
|
|
6195
|
+
return { expanded, toggle, close };
|
|
6196
|
+
}
|
|
6197
|
+
function useFabMenuItemStyles(themeColor) {
|
|
6198
|
+
const theme = useXUITheme();
|
|
6199
|
+
const safeThemeColor = (0, import_core41.getSafeThemeColor)(themeColor);
|
|
6200
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
6201
|
+
const itemStyles = (0, import_react61.useMemo)(() => {
|
|
6202
|
+
const chipStyles = {
|
|
6203
|
+
backgroundColor: colorScheme.background,
|
|
6204
|
+
borderRadius: theme.borderRadius.full,
|
|
6205
|
+
color: colorScheme.main,
|
|
6206
|
+
fontSize: theme.fontSizes.md
|
|
6207
|
+
};
|
|
6208
|
+
const iconColor = colorScheme.main;
|
|
6209
|
+
return { chipStyles, iconColor };
|
|
6210
|
+
}, [colorScheme, theme]);
|
|
6211
|
+
return itemStyles;
|
|
6212
|
+
}
|
|
6213
|
+
function useFabMenuOverlayColor() {
|
|
6214
|
+
const theme = useXUITheme();
|
|
6215
|
+
return (0, import_react61.useMemo)(() => {
|
|
6216
|
+
return theme.mode === "dark" ? "rgba(0, 0, 0, 0.5)" : "rgba(0, 0, 0, 0.3)";
|
|
6217
|
+
}, [theme.mode]);
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
// src/components/fab-menu/fab-menu.animation.ts
|
|
6221
|
+
var import_react_native56 = require("react-native");
|
|
6222
|
+
var runMenuExpandAnimation = (overlayOpacity, itemAnimations) => {
|
|
6223
|
+
const itemSequence = itemAnimations.map(
|
|
6224
|
+
(anim, index) => import_react_native56.Animated.timing(anim, {
|
|
6225
|
+
toValue: 1,
|
|
6226
|
+
duration: 150,
|
|
6227
|
+
delay: index * 50,
|
|
6228
|
+
useNativeDriver: true
|
|
6229
|
+
})
|
|
6230
|
+
);
|
|
6231
|
+
import_react_native56.Animated.parallel([
|
|
6232
|
+
import_react_native56.Animated.timing(overlayOpacity, {
|
|
6233
|
+
toValue: 1,
|
|
6234
|
+
duration: 200,
|
|
6235
|
+
useNativeDriver: true
|
|
6236
|
+
}),
|
|
6237
|
+
import_react_native56.Animated.stagger(50, itemSequence)
|
|
6238
|
+
]).start();
|
|
6239
|
+
};
|
|
6240
|
+
var runMenuCollapseAnimation = (overlayOpacity, itemAnimations, onComplete) => {
|
|
6241
|
+
const reversed = [...itemAnimations].reverse();
|
|
6242
|
+
const itemSequence = reversed.map(
|
|
6243
|
+
(anim, index) => import_react_native56.Animated.timing(anim, {
|
|
6244
|
+
toValue: 0,
|
|
6245
|
+
duration: 120,
|
|
6246
|
+
delay: index * 30,
|
|
6247
|
+
useNativeDriver: true
|
|
6248
|
+
})
|
|
6249
|
+
);
|
|
6250
|
+
import_react_native56.Animated.parallel([
|
|
6251
|
+
import_react_native56.Animated.timing(overlayOpacity, {
|
|
6252
|
+
toValue: 0,
|
|
6253
|
+
duration: 200,
|
|
6254
|
+
useNativeDriver: true
|
|
6255
|
+
}),
|
|
6256
|
+
import_react_native56.Animated.stagger(30, itemSequence)
|
|
6257
|
+
]).start(onComplete);
|
|
6258
|
+
};
|
|
6259
|
+
var runFabRotateAnimation = (rotateValue, toExpanded) => {
|
|
6260
|
+
import_react_native56.Animated.spring(rotateValue, {
|
|
6261
|
+
toValue: toExpanded ? 1 : 0,
|
|
6262
|
+
useNativeDriver: true,
|
|
6263
|
+
speed: 20,
|
|
6264
|
+
bounciness: 0
|
|
6265
|
+
}).start();
|
|
6266
|
+
};
|
|
6267
|
+
|
|
6268
|
+
// src/components/fab-menu/fab-menu.tsx
|
|
6269
|
+
var FabMenu = ({
|
|
6270
|
+
icon,
|
|
6271
|
+
label,
|
|
6272
|
+
expandedIcon,
|
|
6273
|
+
children,
|
|
6274
|
+
themeColor = "primary",
|
|
6275
|
+
variant = "solid",
|
|
6276
|
+
size = "md",
|
|
6277
|
+
radius,
|
|
6278
|
+
elevation = 0,
|
|
6279
|
+
isExpanded: controlledExpanded,
|
|
6280
|
+
onToggle,
|
|
6281
|
+
showOverlay = true,
|
|
6282
|
+
customAppearance
|
|
6283
|
+
}) => {
|
|
6284
|
+
const { expanded, toggle, close } = useFabMenuState(controlledExpanded, onToggle);
|
|
6285
|
+
const overlayColor = useFabMenuOverlayColor();
|
|
6286
|
+
const [isPortalVisible, setIsPortalVisible] = import_react62.default.useState(expanded);
|
|
6287
|
+
const childArray = import_react62.default.Children.toArray(children);
|
|
6288
|
+
const overlayOpacity = import_react62.default.useRef(new import_react_native57.Animated.Value(expanded ? 1 : 0)).current;
|
|
6289
|
+
const rotateValue = import_react62.default.useRef(new import_react_native57.Animated.Value(expanded ? 1 : 0)).current;
|
|
6290
|
+
const itemAnimationsRef = import_react62.default.useRef(childArray.map(() => new import_react_native57.Animated.Value(0)));
|
|
6291
|
+
const itemAnimations = itemAnimationsRef.current;
|
|
6292
|
+
const prevExpanded = import_react62.default.useRef(expanded);
|
|
6293
|
+
import_react62.default.useEffect(() => {
|
|
6294
|
+
if (itemAnimations.length === childArray.length) return;
|
|
6295
|
+
itemAnimationsRef.current = childArray.map(
|
|
6296
|
+
(_, index) => itemAnimations[index] ?? new import_react_native57.Animated.Value(expanded ? 1 : 0)
|
|
6297
|
+
);
|
|
6298
|
+
}, [expanded, itemAnimations, childArray]);
|
|
6299
|
+
import_react62.default.useEffect(() => {
|
|
6300
|
+
if (prevExpanded.current === expanded) return;
|
|
6301
|
+
prevExpanded.current = expanded;
|
|
6302
|
+
if (expanded) {
|
|
6303
|
+
setIsPortalVisible(true);
|
|
6304
|
+
runMenuExpandAnimation(overlayOpacity, itemAnimations);
|
|
6305
|
+
runFabRotateAnimation(rotateValue, true);
|
|
6306
|
+
} else {
|
|
6307
|
+
runMenuCollapseAnimation(overlayOpacity, itemAnimations, () => {
|
|
6308
|
+
setIsPortalVisible(false);
|
|
6309
|
+
});
|
|
6310
|
+
runFabRotateAnimation(rotateValue, false);
|
|
6311
|
+
}
|
|
6312
|
+
}, [expanded, overlayOpacity, itemAnimations, rotateValue]);
|
|
6313
|
+
const rotation = rotateValue.interpolate({
|
|
6314
|
+
inputRange: [0, 1],
|
|
6315
|
+
outputRange: ["0deg", "45deg"]
|
|
6316
|
+
});
|
|
6317
|
+
const currentIcon = expanded && expandedIcon ? expandedIcon : icon;
|
|
6318
|
+
const renderFabToggle = () => /* @__PURE__ */ import_react62.default.createElement(
|
|
6319
|
+
import_react_native57.Animated.View,
|
|
6320
|
+
{
|
|
6321
|
+
style: {
|
|
6322
|
+
alignSelf: "flex-end",
|
|
6323
|
+
transform: [{ rotate: expandedIcon ? "0deg" : rotation }]
|
|
6324
|
+
}
|
|
6325
|
+
},
|
|
6326
|
+
/* @__PURE__ */ import_react62.default.createElement(
|
|
6327
|
+
Fab,
|
|
6328
|
+
{
|
|
6329
|
+
icon: currentIcon,
|
|
6330
|
+
label,
|
|
6331
|
+
themeColor,
|
|
6332
|
+
variant,
|
|
6333
|
+
size,
|
|
6334
|
+
radius,
|
|
6335
|
+
elevation,
|
|
6336
|
+
onPress: toggle,
|
|
6337
|
+
customAppearance: { fab: customAppearance?.fab }
|
|
6338
|
+
}
|
|
6339
|
+
)
|
|
6340
|
+
);
|
|
6341
|
+
const renderMenuItems = () => /* @__PURE__ */ import_react62.default.createElement(import_react_native57.View, { style: [styles17.menuContainer, customAppearance?.menuContainer] }, childArray.map((child, index) => {
|
|
6342
|
+
const childElement = child;
|
|
6343
|
+
const isDisabled = childElement.props?.isDisabled;
|
|
6344
|
+
return /* @__PURE__ */ import_react62.default.createElement(
|
|
6345
|
+
import_react_native57.Animated.View,
|
|
6346
|
+
{
|
|
6347
|
+
key: childElement.key ?? index,
|
|
6348
|
+
style: [
|
|
6349
|
+
styles17.menuItem,
|
|
6350
|
+
isDisabled && styles17.disabled,
|
|
6351
|
+
{
|
|
6352
|
+
opacity: itemAnimations[index],
|
|
6353
|
+
transform: [
|
|
6354
|
+
{
|
|
6355
|
+
translateY: itemAnimations[index].interpolate({
|
|
6356
|
+
inputRange: [0, 1],
|
|
6357
|
+
outputRange: [20, 0]
|
|
6358
|
+
})
|
|
6359
|
+
},
|
|
6360
|
+
{
|
|
6361
|
+
scale: itemAnimations[index].interpolate({
|
|
6362
|
+
inputRange: [0, 1],
|
|
6363
|
+
outputRange: [0.8, 1]
|
|
6364
|
+
})
|
|
6365
|
+
}
|
|
6366
|
+
]
|
|
6367
|
+
},
|
|
6368
|
+
customAppearance?.menuItem
|
|
6369
|
+
]
|
|
6370
|
+
},
|
|
6371
|
+
import_react62.default.cloneElement(childElement, {
|
|
6372
|
+
_onClose: close,
|
|
6373
|
+
themeColor: childElement.props?.themeColor ?? themeColor
|
|
6374
|
+
})
|
|
6375
|
+
);
|
|
6376
|
+
}));
|
|
6377
|
+
return /* @__PURE__ */ import_react62.default.createElement(import_react_native57.View, { style: [styles17.container, customAppearance?.container] }, isPortalVisible && /* @__PURE__ */ import_react62.default.createElement(Portal, null, /* @__PURE__ */ import_react62.default.createElement(import_react_native57.View, { style: styles17.portalRoot }, showOverlay && /* @__PURE__ */ import_react62.default.createElement(
|
|
6378
|
+
import_react_native57.Animated.View,
|
|
6379
|
+
{
|
|
6380
|
+
style: [
|
|
6381
|
+
styles17.overlay,
|
|
6382
|
+
{ backgroundColor: overlayColor, opacity: overlayOpacity },
|
|
6383
|
+
customAppearance?.overlay
|
|
6384
|
+
]
|
|
6385
|
+
},
|
|
6386
|
+
/* @__PURE__ */ import_react62.default.createElement(import_react_native57.Pressable, { style: styles17.overlayPressable, onPress: close })
|
|
6387
|
+
), /* @__PURE__ */ import_react62.default.createElement(import_react_native57.View, { style: styles17.portalContent }, renderMenuItems(), renderFabToggle()))), !isPortalVisible && renderFabToggle());
|
|
6388
|
+
};
|
|
6389
|
+
|
|
6390
|
+
// src/components/fab-menu/fab-menu-item.tsx
|
|
6391
|
+
var import_react63 = __toESM(require("react"), 1);
|
|
6392
|
+
var import_react_native58 = require("react-native");
|
|
6393
|
+
var FabMenuItem = ({
|
|
6394
|
+
icon,
|
|
6395
|
+
label,
|
|
6396
|
+
themeColor = "primary",
|
|
6397
|
+
onPress,
|
|
6398
|
+
isDisabled,
|
|
6399
|
+
_onClose
|
|
6400
|
+
}) => {
|
|
6401
|
+
const itemStyles = useFabMenuItemStyles(themeColor);
|
|
6402
|
+
const renderIcon = (menuIcon) => {
|
|
6403
|
+
if (!import_react63.default.isValidElement(menuIcon)) return menuIcon;
|
|
6404
|
+
return import_react63.default.cloneElement(
|
|
6405
|
+
menuIcon,
|
|
6406
|
+
{ color: itemStyles.iconColor }
|
|
6407
|
+
);
|
|
6408
|
+
};
|
|
6409
|
+
return /* @__PURE__ */ import_react63.default.createElement(
|
|
6410
|
+
import_react_native58.Pressable,
|
|
6411
|
+
{
|
|
6412
|
+
style: [
|
|
6413
|
+
styles17.menuItemChip,
|
|
6414
|
+
{
|
|
6415
|
+
backgroundColor: itemStyles.chipStyles.backgroundColor,
|
|
6416
|
+
borderRadius: itemStyles.chipStyles.borderRadius
|
|
6417
|
+
}
|
|
6418
|
+
],
|
|
6419
|
+
onPress: (event) => {
|
|
6420
|
+
if (isDisabled) return;
|
|
6421
|
+
onPress?.(event);
|
|
6422
|
+
_onClose?.();
|
|
6423
|
+
},
|
|
6424
|
+
disabled: isDisabled
|
|
6425
|
+
},
|
|
6426
|
+
renderIcon(icon),
|
|
6427
|
+
/* @__PURE__ */ import_react63.default.createElement(
|
|
6428
|
+
import_react_native58.Text,
|
|
6429
|
+
{
|
|
6430
|
+
style: [
|
|
6431
|
+
styles17.menuItemLabel,
|
|
6432
|
+
{
|
|
6433
|
+
color: itemStyles.chipStyles.color,
|
|
6434
|
+
fontSize: itemStyles.chipStyles.fontSize
|
|
6435
|
+
}
|
|
6436
|
+
]
|
|
6437
|
+
},
|
|
6438
|
+
label
|
|
6439
|
+
)
|
|
6440
|
+
);
|
|
6441
|
+
};
|
|
5102
6442
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5103
6443
|
0 && (module.exports = {
|
|
5104
6444
|
ActivityIndicator,
|
|
@@ -5109,10 +6449,16 @@ var BottomSheet = ({
|
|
|
5109
6449
|
AvatarGroup,
|
|
5110
6450
|
Badge,
|
|
5111
6451
|
BottomSheet,
|
|
6452
|
+
Carousel,
|
|
5112
6453
|
Chip,
|
|
5113
6454
|
ChipGroup,
|
|
5114
6455
|
ChipItem,
|
|
5115
6456
|
DatePicker,
|
|
5116
6457
|
Divider,
|
|
6458
|
+
Fab,
|
|
6459
|
+
FabMenu,
|
|
6460
|
+
FabMenuItem,
|
|
6461
|
+
SegmentButton,
|
|
6462
|
+
SegmentButtonItem,
|
|
5117
6463
|
Typography
|
|
5118
6464
|
});
|