@xaui/native 0.2.7 → 0.9.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-JDS6KGCM.cjs +791 -0
- package/dist/chunk-T3ZI2PZ6.js +791 -0
- package/dist/index.cjs +32 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -0
- package/dist/theme/index.cjs +32 -0
- package/dist/theme/index.d.cts +669 -0
- package/dist/theme/index.d.ts +669 -0
- package/dist/theme/index.js +32 -0
- package/package.json +26 -249
- package/README.md +0 -178
- package/dist/alert/index.cjs +0 -356
- package/dist/alert/index.d.cts +0 -90
- package/dist/alert/index.d.ts +0 -90
- package/dist/alert/index.js +0 -356
- package/dist/app-bar/index.cjs +0 -148
- package/dist/app-bar/index.d.cts +0 -59
- package/dist/app-bar/index.d.ts +0 -59
- package/dist/app-bar/index.js +0 -148
- package/dist/autocomplete/index.cjs +0 -1122
- package/dist/autocomplete/index.d.cts +0 -88
- package/dist/autocomplete/index.d.ts +0 -88
- package/dist/autocomplete/index.js +0 -1122
- package/dist/avatar/index.cjs +0 -281
- package/dist/avatar/index.d.cts +0 -123
- package/dist/avatar/index.d.ts +0 -123
- package/dist/avatar/index.js +0 -281
- package/dist/badge/index.cjs +0 -197
- package/dist/badge/index.d.cts +0 -94
- package/dist/badge/index.d.ts +0 -94
- package/dist/badge/index.js +0 -197
- package/dist/bottom-sheet/index.cjs +0 -9
- package/dist/bottom-sheet/index.d.cts +0 -84
- package/dist/bottom-sheet/index.d.ts +0 -84
- package/dist/bottom-sheet/index.js +0 -9
- package/dist/bottom-tab-bar/index.cjs +0 -497
- package/dist/bottom-tab-bar/index.d.cts +0 -211
- package/dist/bottom-tab-bar/index.d.ts +0 -211
- package/dist/bottom-tab-bar/index.js +0 -497
- package/dist/button/index.cjs +0 -392
- package/dist/button/index.d.cts +0 -174
- package/dist/button/index.d.ts +0 -174
- package/dist/button/index.js +0 -392
- package/dist/button.type-j1ZdkkSl.d.cts +0 -4
- package/dist/button.type-j1ZdkkSl.d.ts +0 -4
- package/dist/card/index.cjs +0 -338
- package/dist/card/index.d.cts +0 -191
- package/dist/card/index.d.ts +0 -191
- package/dist/card/index.js +0 -338
- package/dist/carousel/index.cjs +0 -381
- package/dist/carousel/index.d.cts +0 -147
- package/dist/carousel/index.d.ts +0 -147
- package/dist/carousel/index.js +0 -381
- package/dist/chart/index.cjs +0 -1026
- package/dist/chart/index.d.cts +0 -218
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -1026
- package/dist/checkbox/index.cjs +0 -443
- package/dist/checkbox/index.d.cts +0 -73
- package/dist/checkbox/index.d.ts +0 -73
- package/dist/checkbox/index.js +0 -443
- package/dist/chip/index.cjs +0 -503
- package/dist/chip/index.d.cts +0 -195
- package/dist/chip/index.d.ts +0 -195
- package/dist/chip/index.js +0 -503
- package/dist/chunk-4JFWQ5XT.js +0 -368
- package/dist/chunk-56RPWZD2.cjs +0 -9
- package/dist/chunk-7UFBLUMV.cjs +0 -136
- package/dist/chunk-A45TVXU5.js +0 -337
- package/dist/chunk-BYWUAPC4.cjs +0 -368
- package/dist/chunk-DECMUMCI.js +0 -0
- package/dist/chunk-DHSTKO3K.cjs +0 -19
- package/dist/chunk-DJ4Q37UT.cjs +0 -75
- package/dist/chunk-EUQDGTST.cjs +0 -1
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-RBSA4NH4.js +0 -136
- package/dist/chunk-SHBDANQN.js +0 -9
- package/dist/chunk-UGEINZM7.cjs +0 -290
- package/dist/chunk-UU4HHBDN.js +0 -290
- package/dist/chunk-VSZEXOUN.js +0 -384
- package/dist/chunk-YIEUN3G5.cjs +0 -384
- package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
- package/dist/chunk-ZY7IUTAT.js +0 -75
- package/dist/color-picker/index.cjs +0 -457
- package/dist/color-picker/index.d.cts +0 -124
- package/dist/color-picker/index.d.ts +0 -124
- package/dist/color-picker/index.js +0 -457
- package/dist/core/index.cjs +0 -24
- package/dist/core/index.d.cts +0 -28
- package/dist/core/index.d.ts +0 -28
- package/dist/core/index.js +0 -24
- package/dist/datepicker/index.cjs +0 -1625
- package/dist/datepicker/index.d.cts +0 -45
- package/dist/datepicker/index.d.ts +0 -45
- package/dist/datepicker/index.js +0 -1625
- package/dist/dialog/index.cjs +0 -372
- package/dist/dialog/index.d.cts +0 -151
- package/dist/dialog/index.d.ts +0 -151
- package/dist/dialog/index.js +0 -372
- package/dist/divider/index.cjs +0 -8
- package/dist/divider/index.d.cts +0 -30
- package/dist/divider/index.d.ts +0 -30
- package/dist/divider/index.js +0 -8
- package/dist/drawer/index.cjs +0 -237
- package/dist/drawer/index.d.cts +0 -58
- package/dist/drawer/index.d.ts +0 -58
- package/dist/drawer/index.js +0 -237
- package/dist/expansion-panel/index.cjs +0 -441
- package/dist/expansion-panel/index.d.cts +0 -153
- package/dist/expansion-panel/index.d.ts +0 -153
- package/dist/expansion-panel/index.js +0 -441
- package/dist/fab/index.cjs +0 -9
- package/dist/fab/index.d.cts +0 -10
- package/dist/fab/index.d.ts +0 -10
- package/dist/fab/index.js +0 -9
- package/dist/fab-menu/index.cjs +0 -330
- package/dist/fab-menu/index.d.cts +0 -125
- package/dist/fab-menu/index.d.ts +0 -125
- package/dist/fab-menu/index.js +0 -330
- package/dist/fab.type-CkUHmXU_.d.ts +0 -86
- package/dist/fab.type-DN0vtAh6.d.cts +0 -86
- package/dist/feature-discovery/index.cjs +0 -464
- package/dist/feature-discovery/index.d.cts +0 -82
- package/dist/feature-discovery/index.d.ts +0 -82
- package/dist/feature-discovery/index.js +0 -464
- package/dist/indicator/index.cjs +0 -8
- package/dist/indicator/index.d.cts +0 -47
- package/dist/indicator/index.d.ts +0 -47
- package/dist/indicator/index.js +0 -8
- package/dist/input/index.cjs +0 -1462
- package/dist/input/index.d.cts +0 -522
- package/dist/input/index.d.ts +0 -522
- package/dist/input/index.js +0 -1462
- package/dist/input-trigger/index.cjs +0 -197
- package/dist/input-trigger/index.d.cts +0 -11
- package/dist/input-trigger/index.d.ts +0 -11
- package/dist/input-trigger/index.js +0 -197
- package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
- package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
- package/dist/list/index.cjs +0 -395
- package/dist/list/index.d.cts +0 -188
- package/dist/list/index.d.ts +0 -188
- package/dist/list/index.js +0 -395
- package/dist/menu/index.cjs +0 -316
- package/dist/menu/index.d.cts +0 -115
- package/dist/menu/index.d.ts +0 -115
- package/dist/menu/index.js +0 -316
- package/dist/menubox/index.cjs +0 -297
- package/dist/menubox/index.d.cts +0 -98
- package/dist/menubox/index.d.ts +0 -98
- package/dist/menubox/index.js +0 -297
- package/dist/pager/index.cjs +0 -205
- package/dist/pager/index.d.cts +0 -93
- package/dist/pager/index.d.ts +0 -93
- package/dist/pager/index.js +0 -205
- package/dist/picker/index.cjs +0 -244
- package/dist/picker/index.d.cts +0 -121
- package/dist/picker/index.d.ts +0 -121
- package/dist/picker/index.js +0 -244
- package/dist/progress/index.cjs +0 -219
- package/dist/progress/index.d.cts +0 -47
- package/dist/progress/index.d.ts +0 -47
- package/dist/progress/index.js +0 -219
- package/dist/radio/index.cjs +0 -465
- package/dist/radio/index.d.cts +0 -145
- package/dist/radio/index.d.ts +0 -145
- package/dist/radio/index.js +0 -465
- package/dist/refresh-control/index.cjs +0 -45
- package/dist/refresh-control/index.d.cts +0 -55
- package/dist/refresh-control/index.d.ts +0 -55
- package/dist/refresh-control/index.js +0 -45
- package/dist/segment-button/index.cjs +0 -405
- package/dist/segment-button/index.d.cts +0 -141
- package/dist/segment-button/index.d.ts +0 -141
- package/dist/segment-button/index.js +0 -405
- package/dist/select/index.cjs +0 -878
- package/dist/select/index.d.cts +0 -192
- package/dist/select/index.d.ts +0 -192
- package/dist/select/index.js +0 -878
- package/dist/skeleton/index.cjs +0 -89
- package/dist/skeleton/index.d.cts +0 -45
- package/dist/skeleton/index.d.ts +0 -45
- package/dist/skeleton/index.js +0 -89
- package/dist/slider/index.cjs +0 -576
- package/dist/slider/index.d.cts +0 -171
- package/dist/slider/index.d.ts +0 -171
- package/dist/slider/index.js +0 -576
- package/dist/snackbar/index.cjs +0 -436
- package/dist/snackbar/index.d.cts +0 -174
- package/dist/snackbar/index.d.ts +0 -174
- package/dist/snackbar/index.js +0 -436
- package/dist/snippet/index.cjs +0 -314
- package/dist/snippet/index.d.cts +0 -95
- package/dist/snippet/index.d.ts +0 -95
- package/dist/snippet/index.js +0 -314
- package/dist/stepper/index.cjs +0 -550
- package/dist/stepper/index.d.cts +0 -137
- package/dist/stepper/index.d.ts +0 -137
- package/dist/stepper/index.js +0 -550
- package/dist/switch/index.cjs +0 -358
- package/dist/switch/index.d.cts +0 -28
- package/dist/switch/index.d.ts +0 -28
- package/dist/switch/index.js +0 -358
- package/dist/tabs/index.cjs +0 -440
- package/dist/tabs/index.d.cts +0 -180
- package/dist/tabs/index.d.ts +0 -180
- package/dist/tabs/index.js +0 -440
- package/dist/timepicker/index.cjs +0 -823
- package/dist/timepicker/index.d.cts +0 -215
- package/dist/timepicker/index.d.ts +0 -215
- package/dist/timepicker/index.js +0 -823
- package/dist/toolbar/index.cjs +0 -333
- package/dist/toolbar/index.d.cts +0 -100
- package/dist/toolbar/index.d.ts +0 -100
- package/dist/toolbar/index.js +0 -333
- package/dist/typography/index.cjs +0 -238
- package/dist/typography/index.d.cts +0 -113
- package/dist/typography/index.d.ts +0 -113
- package/dist/typography/index.js +0 -238
- package/dist/view/index.cjs +0 -1361
- package/dist/view/index.d.cts +0 -833
- package/dist/view/index.d.ts +0 -833
- package/dist/view/index.js +0 -1361
package/dist/tabs/index.cjs
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-56RPWZD2.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
|
|
6
|
-
|
|
7
|
-
// src/components/tabs/tabs.tsx
|
|
8
|
-
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _reactnative = require('react-native');
|
|
15
|
-
|
|
16
|
-
// src/components/tabs/tabs.animation.ts
|
|
17
|
-
|
|
18
|
-
var runTabsCursorAnimation = (translateX, width, scaleX, toX, toWidth, duration) => {
|
|
19
|
-
scaleX.setValue(0.75);
|
|
20
|
-
_reactnative.Animated.parallel([
|
|
21
|
-
_reactnative.Animated.timing(translateX, {
|
|
22
|
-
toValue: toX,
|
|
23
|
-
duration,
|
|
24
|
-
easing: _reactnative.Easing.inOut(_reactnative.Easing.quad),
|
|
25
|
-
useNativeDriver: false
|
|
26
|
-
}),
|
|
27
|
-
_reactnative.Animated.timing(width, {
|
|
28
|
-
toValue: toWidth,
|
|
29
|
-
duration,
|
|
30
|
-
easing: _reactnative.Easing.inOut(_reactnative.Easing.quad),
|
|
31
|
-
useNativeDriver: false
|
|
32
|
-
}),
|
|
33
|
-
_reactnative.Animated.timing(scaleX, {
|
|
34
|
-
toValue: 1,
|
|
35
|
-
duration,
|
|
36
|
-
easing: _reactnative.Easing.out(_reactnative.Easing.quad),
|
|
37
|
-
useNativeDriver: false
|
|
38
|
-
})
|
|
39
|
-
]).start();
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/components/tabs/tabs.hook.ts
|
|
43
|
-
|
|
44
|
-
var _core = require('@xaui/core');
|
|
45
|
-
function useTabsSizeStyles(size) {
|
|
46
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
47
|
-
return _react.useMemo.call(void 0, () => {
|
|
48
|
-
const sizes = {
|
|
49
|
-
xs: {
|
|
50
|
-
minHeight: theme.componentSizes.xs,
|
|
51
|
-
paddingHorizontal: theme.spacing.sm,
|
|
52
|
-
paddingVertical: theme.spacing.xs,
|
|
53
|
-
fontSize: theme.fontSizes.xs
|
|
54
|
-
},
|
|
55
|
-
sm: {
|
|
56
|
-
minHeight: theme.componentSizes.sm,
|
|
57
|
-
paddingHorizontal: theme.spacing.md,
|
|
58
|
-
paddingVertical: theme.spacing.xs,
|
|
59
|
-
fontSize: theme.fontSizes.sm
|
|
60
|
-
},
|
|
61
|
-
md: {
|
|
62
|
-
minHeight: theme.componentSizes.md,
|
|
63
|
-
paddingHorizontal: theme.spacing.md,
|
|
64
|
-
paddingVertical: theme.spacing.sm,
|
|
65
|
-
fontSize: theme.fontSizes.md
|
|
66
|
-
},
|
|
67
|
-
lg: {
|
|
68
|
-
minHeight: theme.componentSizes.lg,
|
|
69
|
-
paddingHorizontal: theme.spacing.lg,
|
|
70
|
-
paddingVertical: theme.spacing.md,
|
|
71
|
-
fontSize: theme.fontSizes.lg
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return sizes[size];
|
|
75
|
-
}, [size, theme]);
|
|
76
|
-
}
|
|
77
|
-
function useTabsVariantStyles(color, variant) {
|
|
78
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
79
|
-
const safeColor = _core.getSafeThemeColor.call(void 0, color);
|
|
80
|
-
const palette = theme.colors[safeColor];
|
|
81
|
-
const cursorSolidColor = _core.withPaletteNumber.call(void 0, palette.main, 400);
|
|
82
|
-
return _react.useMemo.call(void 0, () => {
|
|
83
|
-
const variants = {
|
|
84
|
-
solid: {
|
|
85
|
-
listBackgroundColor: palette.container,
|
|
86
|
-
listBorderColor: "transparent",
|
|
87
|
-
listBorderWidth: 0,
|
|
88
|
-
listPaddingHorizontal: 4,
|
|
89
|
-
cursorColor: cursorSolidColor,
|
|
90
|
-
textColor: palette.main,
|
|
91
|
-
selectedTextColor: palette.onMain,
|
|
92
|
-
cursorHeight: void 0,
|
|
93
|
-
cursorTop: 4,
|
|
94
|
-
cursorBottom: 4,
|
|
95
|
-
cursorShadow: true
|
|
96
|
-
},
|
|
97
|
-
bordered: {
|
|
98
|
-
listBackgroundColor: "transparent",
|
|
99
|
-
listBorderColor: `${palette.main}30`,
|
|
100
|
-
listBorderWidth: theme.borderWidth.md,
|
|
101
|
-
listPaddingHorizontal: 0,
|
|
102
|
-
cursorColor: cursorSolidColor,
|
|
103
|
-
textColor: palette.main,
|
|
104
|
-
selectedTextColor: palette.onMain,
|
|
105
|
-
cursorHeight: void 0,
|
|
106
|
-
cursorTop: 0,
|
|
107
|
-
cursorBottom: 0,
|
|
108
|
-
cursorShadow: false
|
|
109
|
-
},
|
|
110
|
-
light: {
|
|
111
|
-
listBackgroundColor: "transparent",
|
|
112
|
-
listBorderColor: "transparent",
|
|
113
|
-
listBorderWidth: 0,
|
|
114
|
-
listPaddingHorizontal: 0,
|
|
115
|
-
cursorColor: `${cursorSolidColor}25`,
|
|
116
|
-
textColor: palette.main,
|
|
117
|
-
selectedTextColor: palette.main,
|
|
118
|
-
cursorHeight: void 0,
|
|
119
|
-
cursorTop: 0,
|
|
120
|
-
cursorBottom: 0,
|
|
121
|
-
cursorShadow: false
|
|
122
|
-
},
|
|
123
|
-
underlined: {
|
|
124
|
-
listBackgroundColor: "transparent",
|
|
125
|
-
listBorderColor: `${palette.main}45`,
|
|
126
|
-
listBorderWidth: 0,
|
|
127
|
-
listPaddingHorizontal: 0,
|
|
128
|
-
cursorColor: cursorSolidColor,
|
|
129
|
-
textColor: `${palette.main}B0`,
|
|
130
|
-
selectedTextColor: palette.main,
|
|
131
|
-
cursorHeight: 2,
|
|
132
|
-
cursorTop: void 0,
|
|
133
|
-
cursorBottom: -2,
|
|
134
|
-
cursorShadow: false
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
return variants[variant];
|
|
138
|
-
}, [cursorSolidColor, palette, theme.borderWidth.md, variant]);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/components/tabs/tabs.style.ts
|
|
142
|
-
|
|
143
|
-
var styles = _reactnative.StyleSheet.create({
|
|
144
|
-
container: {
|
|
145
|
-
width: "100%"
|
|
146
|
-
},
|
|
147
|
-
list: {
|
|
148
|
-
position: "relative",
|
|
149
|
-
flexDirection: "row",
|
|
150
|
-
alignItems: "stretch",
|
|
151
|
-
alignSelf: "flex-start"
|
|
152
|
-
},
|
|
153
|
-
fullWidth: {
|
|
154
|
-
width: "100%",
|
|
155
|
-
alignSelf: "stretch"
|
|
156
|
-
},
|
|
157
|
-
tabPressable: {
|
|
158
|
-
flex: 1,
|
|
159
|
-
zIndex: 1
|
|
160
|
-
},
|
|
161
|
-
tab: {
|
|
162
|
-
minWidth: 64,
|
|
163
|
-
alignItems: "center",
|
|
164
|
-
justifyContent: "center",
|
|
165
|
-
flexDirection: "row",
|
|
166
|
-
gap: 6
|
|
167
|
-
},
|
|
168
|
-
text: {
|
|
169
|
-
textAlign: "center",
|
|
170
|
-
fontWeight: "500"
|
|
171
|
-
},
|
|
172
|
-
cursor: {
|
|
173
|
-
position: "absolute",
|
|
174
|
-
left: 0
|
|
175
|
-
},
|
|
176
|
-
disabled: {
|
|
177
|
-
opacity: 0.5
|
|
178
|
-
},
|
|
179
|
-
content: {
|
|
180
|
-
marginTop: 12
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// src/components/tabs/tabs.tsx
|
|
185
|
-
function isTabDisabled(item, disabledKeys, isDisabled) {
|
|
186
|
-
return isDisabled || item.isDisabled === true || _optionalChain([disabledKeys, 'optionalAccess', _ => _.includes, 'call', _2 => _2(item.key)]) === true;
|
|
187
|
-
}
|
|
188
|
-
function getFallbackKey(items, disabledKeys, isDisabled) {
|
|
189
|
-
if (isDisabled) return "";
|
|
190
|
-
const firstEnabled = items.find((item) => !isTabDisabled(item, disabledKeys, false));
|
|
191
|
-
return _nullishCoalesce(_optionalChain([firstEnabled, 'optionalAccess', _3 => _3.key]), () => ( ""));
|
|
192
|
-
}
|
|
193
|
-
var Tab = () => null;
|
|
194
|
-
Tab.displayName = "Tab";
|
|
195
|
-
function toTabItems(children) {
|
|
196
|
-
return _react2.default.Children.toArray(children).flatMap((child) => {
|
|
197
|
-
if (!_react2.default.isValidElement(child) || child.type !== Tab) {
|
|
198
|
-
return [];
|
|
199
|
-
}
|
|
200
|
-
const tabKey = child.props.tabKey;
|
|
201
|
-
if (!tabKey) {
|
|
202
|
-
return [];
|
|
203
|
-
}
|
|
204
|
-
return [
|
|
205
|
-
{
|
|
206
|
-
key: tabKey,
|
|
207
|
-
title: child.props.title,
|
|
208
|
-
startContent: child.props.startContent,
|
|
209
|
-
endContent: child.props.endContent,
|
|
210
|
-
isDisabled: child.props.isDisabled,
|
|
211
|
-
content: child.props.children
|
|
212
|
-
}
|
|
213
|
-
];
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
var Tabs = ({
|
|
217
|
-
selectedKey: controlledSelectedKey,
|
|
218
|
-
defaultSelectedKey,
|
|
219
|
-
onSelectionChange,
|
|
220
|
-
disabledKeys,
|
|
221
|
-
color = "primary",
|
|
222
|
-
variant = "solid",
|
|
223
|
-
size = "md",
|
|
224
|
-
radius = "full",
|
|
225
|
-
fullWidth = false,
|
|
226
|
-
isDisabled = false,
|
|
227
|
-
disableAnimation = false,
|
|
228
|
-
animationDuration = 220,
|
|
229
|
-
renderTab,
|
|
230
|
-
children,
|
|
231
|
-
content,
|
|
232
|
-
customAppearance
|
|
233
|
-
}) => {
|
|
234
|
-
const items = _react.useMemo.call(void 0, () => toTabItems(children), [children]);
|
|
235
|
-
const isControlled = controlledSelectedKey !== void 0;
|
|
236
|
-
const initialKey = _react.useMemo.call(void 0, () => {
|
|
237
|
-
if (defaultSelectedKey) return defaultSelectedKey;
|
|
238
|
-
return getFallbackKey(items, disabledKeys, isDisabled);
|
|
239
|
-
}, [defaultSelectedKey, disabledKeys, isDisabled, items]);
|
|
240
|
-
const [internalSelectedKey, setInternalSelectedKey] = _react.useState.call(void 0, initialKey);
|
|
241
|
-
const [layouts, setLayouts] = _react.useState.call(void 0, {});
|
|
242
|
-
const [listWidth, setListWidth] = _react.useState.call(void 0, 0);
|
|
243
|
-
const selectedKey = _nullishCoalesce((isControlled ? controlledSelectedKey : internalSelectedKey), () => ( ""));
|
|
244
|
-
const selectedItem = _react.useMemo.call(void 0,
|
|
245
|
-
() => items.find((item) => item.key === selectedKey),
|
|
246
|
-
[items, selectedKey]
|
|
247
|
-
);
|
|
248
|
-
const sizeStyles = useTabsSizeStyles(size);
|
|
249
|
-
const variantStyles = useTabsVariantStyles(color, variant);
|
|
250
|
-
const radiusStyles = _chunk7UFBLUMVcjs.useBorderRadiusStyles.call(void 0, radius);
|
|
251
|
-
const cursorTranslateX = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
252
|
-
const cursorWidth = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
253
|
-
const cursorScaleX = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
|
|
254
|
-
const prevCursorLayout = _react.useRef.call(void 0, null);
|
|
255
|
-
_react.useEffect.call(void 0, () => {
|
|
256
|
-
if (isControlled || selectedKey) return;
|
|
257
|
-
const nextFallback = getFallbackKey(items, disabledKeys, isDisabled);
|
|
258
|
-
if (nextFallback && nextFallback !== selectedKey) {
|
|
259
|
-
setInternalSelectedKey(nextFallback);
|
|
260
|
-
}
|
|
261
|
-
}, [disabledKeys, isControlled, isDisabled, items, selectedKey]);
|
|
262
|
-
_react.useEffect.call(void 0, () => {
|
|
263
|
-
if (!selectedKey) return;
|
|
264
|
-
const selectedLayout = layouts[selectedKey];
|
|
265
|
-
if (!selectedLayout) return;
|
|
266
|
-
const from = prevCursorLayout.current;
|
|
267
|
-
prevCursorLayout.current = selectedLayout;
|
|
268
|
-
if (disableAnimation || !from) {
|
|
269
|
-
cursorTranslateX.setValue(selectedLayout.x);
|
|
270
|
-
cursorWidth.setValue(selectedLayout.width);
|
|
271
|
-
cursorScaleX.setValue(1);
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
runTabsCursorAnimation(
|
|
275
|
-
cursorTranslateX,
|
|
276
|
-
cursorWidth,
|
|
277
|
-
cursorScaleX,
|
|
278
|
-
selectedLayout.x,
|
|
279
|
-
selectedLayout.width,
|
|
280
|
-
animationDuration
|
|
281
|
-
);
|
|
282
|
-
}, [
|
|
283
|
-
animationDuration,
|
|
284
|
-
cursorTranslateX,
|
|
285
|
-
cursorWidth,
|
|
286
|
-
cursorScaleX,
|
|
287
|
-
disableAnimation,
|
|
288
|
-
layouts,
|
|
289
|
-
selectedKey
|
|
290
|
-
]);
|
|
291
|
-
const onTabLayout = _react.useCallback.call(void 0,
|
|
292
|
-
(key, event) => {
|
|
293
|
-
const nextLayout = event.nativeEvent.layout;
|
|
294
|
-
setLayouts((prev) => {
|
|
295
|
-
const current = prev[key];
|
|
296
|
-
if (current && current.x === nextLayout.x && current.width === nextLayout.width) {
|
|
297
|
-
return prev;
|
|
298
|
-
}
|
|
299
|
-
const isBordered = variant === "bordered";
|
|
300
|
-
const isFirstTab = _optionalChain([items, 'access', _4 => _4[0], 'optionalAccess', _5 => _5.key]) === key;
|
|
301
|
-
let cursorWidth2 = nextLayout.width;
|
|
302
|
-
let cursorX = nextLayout.x;
|
|
303
|
-
if (isBordered) {
|
|
304
|
-
cursorWidth2 = nextLayout.width;
|
|
305
|
-
cursorX = nextLayout.x;
|
|
306
|
-
if (isFirstTab) {
|
|
307
|
-
cursorWidth2 = nextLayout.width + variantStyles.listBorderWidth;
|
|
308
|
-
cursorX = Math.max(0, nextLayout.x - variantStyles.listBorderWidth);
|
|
309
|
-
}
|
|
310
|
-
if (listWidth > 0) {
|
|
311
|
-
const maxWidth = Math.max(0, listWidth - cursorX);
|
|
312
|
-
cursorWidth2 = Math.min(cursorWidth2, maxWidth);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
...prev,
|
|
317
|
-
[key]: { x: cursorX, width: cursorWidth2 }
|
|
318
|
-
};
|
|
319
|
-
});
|
|
320
|
-
},
|
|
321
|
-
[items, listWidth, setLayouts, variant, variantStyles.listBorderWidth]
|
|
322
|
-
);
|
|
323
|
-
const handleTabPress = _react.useCallback.call(void 0,
|
|
324
|
-
(item) => {
|
|
325
|
-
if (isTabDisabled(item, disabledKeys, isDisabled)) return;
|
|
326
|
-
if (!isControlled) {
|
|
327
|
-
setInternalSelectedKey(item.key);
|
|
328
|
-
}
|
|
329
|
-
_optionalChain([onSelectionChange, 'optionalCall', _6 => _6(item.key)]);
|
|
330
|
-
},
|
|
331
|
-
[disabledKeys, isControlled, isDisabled, onSelectionChange]
|
|
332
|
-
);
|
|
333
|
-
const shouldShowCursor = !!selectedKey && !!layouts[selectedKey] && !isDisabled && items.length > 0;
|
|
334
|
-
const resolvedContent = typeof content === "function" ? content({ selectedKey, selectedItem }) : _nullishCoalesce(content, () => ( _optionalChain([selectedItem, 'optionalAccess', _7 => _7.content])));
|
|
335
|
-
return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.container, _optionalChain([customAppearance, 'optionalAccess', _8 => _8.container])] }, /* @__PURE__ */ _react2.default.createElement(
|
|
336
|
-
_reactnative.View,
|
|
337
|
-
{
|
|
338
|
-
onLayout: (event) => setListWidth(event.nativeEvent.layout.width),
|
|
339
|
-
style: [
|
|
340
|
-
styles.list,
|
|
341
|
-
{
|
|
342
|
-
borderRadius: variant === "underlined" ? 0 : radiusStyles.borderRadius,
|
|
343
|
-
backgroundColor: variantStyles.listBackgroundColor,
|
|
344
|
-
borderColor: variantStyles.listBorderColor,
|
|
345
|
-
borderWidth: variantStyles.listBorderWidth,
|
|
346
|
-
borderBottomWidth: variant === "underlined" ? _nullishCoalesce(variantStyles.cursorHeight, () => ( 2)) : variantStyles.listBorderWidth,
|
|
347
|
-
paddingHorizontal: variantStyles.listPaddingHorizontal,
|
|
348
|
-
...variant === "bordered" && { overflow: "hidden" }
|
|
349
|
-
},
|
|
350
|
-
fullWidth && styles.fullWidth,
|
|
351
|
-
_optionalChain([customAppearance, 'optionalAccess', _9 => _9.list])
|
|
352
|
-
]
|
|
353
|
-
},
|
|
354
|
-
shouldShowCursor && /* @__PURE__ */ _react2.default.createElement(
|
|
355
|
-
_reactnative.Animated.View,
|
|
356
|
-
{
|
|
357
|
-
pointerEvents: "none",
|
|
358
|
-
style: [
|
|
359
|
-
styles.cursor,
|
|
360
|
-
{
|
|
361
|
-
bottom: variantStyles.cursorBottom,
|
|
362
|
-
borderRadius: variant === "underlined" ? 0 : Math.max(
|
|
363
|
-
0,
|
|
364
|
-
radiusStyles.borderRadius - variantStyles.listBorderWidth
|
|
365
|
-
),
|
|
366
|
-
width: cursorWidth,
|
|
367
|
-
backgroundColor: variantStyles.cursorColor,
|
|
368
|
-
transform: [
|
|
369
|
-
{ translateX: cursorTranslateX },
|
|
370
|
-
{ scaleX: cursorScaleX }
|
|
371
|
-
],
|
|
372
|
-
...variantStyles.cursorTop !== void 0 && {
|
|
373
|
-
top: variantStyles.cursorTop
|
|
374
|
-
},
|
|
375
|
-
...variantStyles.cursorHeight !== void 0 && {
|
|
376
|
-
height: variantStyles.cursorHeight
|
|
377
|
-
},
|
|
378
|
-
...variantStyles.cursorShadow && {
|
|
379
|
-
shadowColor: "#000",
|
|
380
|
-
shadowOffset: { width: 0, height: 1 },
|
|
381
|
-
shadowOpacity: 0.15,
|
|
382
|
-
shadowRadius: 3,
|
|
383
|
-
elevation: 2
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
_optionalChain([customAppearance, 'optionalAccess', _10 => _10.cursor])
|
|
387
|
-
]
|
|
388
|
-
}
|
|
389
|
-
),
|
|
390
|
-
items.map((item) => {
|
|
391
|
-
const isSelected = selectedKey === item.key;
|
|
392
|
-
const disabled = isTabDisabled(item, disabledKeys, isDisabled);
|
|
393
|
-
return /* @__PURE__ */ _react2.default.createElement(
|
|
394
|
-
_reactnative.Pressable,
|
|
395
|
-
{
|
|
396
|
-
key: item.key,
|
|
397
|
-
onLayout: (event) => onTabLayout(item.key, event),
|
|
398
|
-
onPress: () => handleTabPress(item),
|
|
399
|
-
disabled,
|
|
400
|
-
style: [styles.tabPressable, disabled && styles.disabled]
|
|
401
|
-
},
|
|
402
|
-
/* @__PURE__ */ _react2.default.createElement(
|
|
403
|
-
_reactnative.View,
|
|
404
|
-
{
|
|
405
|
-
style: [
|
|
406
|
-
styles.tab,
|
|
407
|
-
{
|
|
408
|
-
minHeight: sizeStyles.minHeight,
|
|
409
|
-
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
410
|
-
paddingVertical: sizeStyles.paddingVertical
|
|
411
|
-
},
|
|
412
|
-
_optionalChain([customAppearance, 'optionalAccess', _11 => _11.tab]),
|
|
413
|
-
isSelected && _optionalChain([customAppearance, 'optionalAccess', _12 => _12.selectedTab])
|
|
414
|
-
]
|
|
415
|
-
},
|
|
416
|
-
renderTab ? renderTab(item, { isSelected, isDisabled: disabled }) : /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, item.startContent, /* @__PURE__ */ _react2.default.createElement(
|
|
417
|
-
_reactnative.Text,
|
|
418
|
-
{
|
|
419
|
-
numberOfLines: 1,
|
|
420
|
-
style: [
|
|
421
|
-
styles.text,
|
|
422
|
-
{
|
|
423
|
-
color: isSelected ? variantStyles.selectedTextColor : variantStyles.textColor,
|
|
424
|
-
fontSize: sizeStyles.fontSize
|
|
425
|
-
},
|
|
426
|
-
_optionalChain([customAppearance, 'optionalAccess', _13 => _13.text]),
|
|
427
|
-
isSelected && _optionalChain([customAppearance, 'optionalAccess', _14 => _14.selectedText])
|
|
428
|
-
]
|
|
429
|
-
},
|
|
430
|
-
item.title
|
|
431
|
-
), item.endContent)
|
|
432
|
-
)
|
|
433
|
-
);
|
|
434
|
-
})
|
|
435
|
-
), resolvedContent !== void 0 && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.content, _optionalChain([customAppearance, 'optionalAccess', _15 => _15.content])] }, resolvedContent));
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
exports.Tab = Tab; exports.Tabs = Tabs;
|
package/dist/tabs/index.d.cts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
3
|
-
import { ThemeColor, Size, Radius } from '@xaui/core/types';
|
|
4
|
-
|
|
5
|
-
type TabsVariant = 'solid' | 'bordered' | 'light' | 'underlined';
|
|
6
|
-
type TabsItem = {
|
|
7
|
-
/**
|
|
8
|
-
* Unique key for the tab.
|
|
9
|
-
*/
|
|
10
|
-
key: string;
|
|
11
|
-
/**
|
|
12
|
-
* Label content for the tab trigger.
|
|
13
|
-
*/
|
|
14
|
-
title: ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Optional content displayed before the title.
|
|
17
|
-
*/
|
|
18
|
-
startContent?: ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Optional content displayed after the title.
|
|
21
|
-
*/
|
|
22
|
-
endContent?: ReactNode;
|
|
23
|
-
/**
|
|
24
|
-
* Whether this tab is disabled.
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
isDisabled?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Optional content rendered when this tab is selected.
|
|
30
|
-
*/
|
|
31
|
-
content?: ReactNode;
|
|
32
|
-
};
|
|
33
|
-
type TabProps = {
|
|
34
|
-
/**
|
|
35
|
-
* Unique identifier for the tab. Used for selection, disabled state, and content rendering.
|
|
36
|
-
*/
|
|
37
|
-
tabKey: string;
|
|
38
|
-
/**
|
|
39
|
-
* Label content for the tab trigger.
|
|
40
|
-
*/
|
|
41
|
-
title: ReactNode;
|
|
42
|
-
/**
|
|
43
|
-
* Optional content displayed before the title.
|
|
44
|
-
*/
|
|
45
|
-
startContent?: ReactNode;
|
|
46
|
-
/**
|
|
47
|
-
* Optional content displayed after the title.
|
|
48
|
-
*/
|
|
49
|
-
endContent?: ReactNode;
|
|
50
|
-
/**
|
|
51
|
-
* Whether this tab is disabled.
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
isDisabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Optional content rendered when this tab is selected.
|
|
57
|
-
*/
|
|
58
|
-
children?: ReactNode;
|
|
59
|
-
};
|
|
60
|
-
type TabsCustomAppearance = {
|
|
61
|
-
/**
|
|
62
|
-
* Custom styles for the outer container.
|
|
63
|
-
*/
|
|
64
|
-
container?: ViewStyle;
|
|
65
|
-
/**
|
|
66
|
-
* Custom styles for the tabs list wrapper.
|
|
67
|
-
*/
|
|
68
|
-
list?: ViewStyle;
|
|
69
|
-
/**
|
|
70
|
-
* Custom styles for each tab trigger.
|
|
71
|
-
*/
|
|
72
|
-
tab?: ViewStyle;
|
|
73
|
-
/**
|
|
74
|
-
* Custom styles for the selected tab trigger.
|
|
75
|
-
*/
|
|
76
|
-
selectedTab?: ViewStyle;
|
|
77
|
-
/**
|
|
78
|
-
* Custom styles for tab title text.
|
|
79
|
-
*/
|
|
80
|
-
text?: TextStyle;
|
|
81
|
-
/**
|
|
82
|
-
* Custom styles for selected tab title text.
|
|
83
|
-
*/
|
|
84
|
-
selectedText?: TextStyle;
|
|
85
|
-
/**
|
|
86
|
-
* Custom styles for the animated cursor.
|
|
87
|
-
*/
|
|
88
|
-
cursor?: ViewStyle;
|
|
89
|
-
/**
|
|
90
|
-
* Custom styles for optional content area.
|
|
91
|
-
*/
|
|
92
|
-
content?: ViewStyle;
|
|
93
|
-
};
|
|
94
|
-
type RenderTabState = {
|
|
95
|
-
isSelected: boolean;
|
|
96
|
-
isDisabled: boolean;
|
|
97
|
-
};
|
|
98
|
-
type RenderChildrenState = {
|
|
99
|
-
selectedKey: string;
|
|
100
|
-
selectedItem?: TabsItem;
|
|
101
|
-
};
|
|
102
|
-
type TabsProps = {
|
|
103
|
-
/**
|
|
104
|
-
* Controlled selected key.
|
|
105
|
-
*/
|
|
106
|
-
selectedKey?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Default selected key in uncontrolled mode.
|
|
109
|
-
*/
|
|
110
|
-
defaultSelectedKey?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Callback fired when selection changes.
|
|
113
|
-
*/
|
|
114
|
-
onSelectionChange?: (key: string) => void;
|
|
115
|
-
/**
|
|
116
|
-
* Keys that should be disabled.
|
|
117
|
-
*/
|
|
118
|
-
disabledKeys?: string[];
|
|
119
|
-
/**
|
|
120
|
-
* Theme color of tabs.
|
|
121
|
-
* @default 'primary'
|
|
122
|
-
*/
|
|
123
|
-
color?: ThemeColor;
|
|
124
|
-
/**
|
|
125
|
-
* Visual variant.
|
|
126
|
-
* @default 'solid'
|
|
127
|
-
*/
|
|
128
|
-
variant?: TabsVariant;
|
|
129
|
-
/**
|
|
130
|
-
* Size of tab triggers.
|
|
131
|
-
* @default 'md'
|
|
132
|
-
*/
|
|
133
|
-
size?: Size;
|
|
134
|
-
/**
|
|
135
|
-
* Border radius for list and cursor.
|
|
136
|
-
* @default 'full'
|
|
137
|
-
*/
|
|
138
|
-
radius?: Radius;
|
|
139
|
-
/**
|
|
140
|
-
* Whether tabs should stretch to full width.
|
|
141
|
-
* @default false
|
|
142
|
-
*/
|
|
143
|
-
fullWidth?: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Whether all tabs are disabled.
|
|
146
|
-
* @default false
|
|
147
|
-
*/
|
|
148
|
-
isDisabled?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Disable cursor animation.
|
|
151
|
-
* @default false
|
|
152
|
-
*/
|
|
153
|
-
disableAnimation?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Animation duration in milliseconds.
|
|
156
|
-
* @default 220
|
|
157
|
-
*/
|
|
158
|
-
animationDuration?: number;
|
|
159
|
-
/**
|
|
160
|
-
* Optional custom tab renderer.
|
|
161
|
-
*/
|
|
162
|
-
renderTab?: (item: TabsItem, state: RenderTabState) => ReactNode;
|
|
163
|
-
/**
|
|
164
|
-
* Tab items as children.
|
|
165
|
-
*/
|
|
166
|
-
children: ReactNode;
|
|
167
|
-
/**
|
|
168
|
-
* Optional content area rendered below the tabs.
|
|
169
|
-
*/
|
|
170
|
-
content?: ReactNode | ((state: RenderChildrenState) => ReactNode);
|
|
171
|
-
/**
|
|
172
|
-
* Custom appearance overrides.
|
|
173
|
-
*/
|
|
174
|
-
customAppearance?: TabsCustomAppearance;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
declare const Tab: React.FC<TabProps>;
|
|
178
|
-
declare const Tabs: React.FC<TabsProps>;
|
|
179
|
-
|
|
180
|
-
export { Tab, type TabProps, Tabs, type TabsItem, type TabsProps, type TabsVariant };
|