@xaui/native 0.0.17 → 0.0.18

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.
Files changed (47) hide show
  1. package/dist/accordion/index.js +2 -2
  2. package/dist/alert/index.js +352 -4
  3. package/dist/autocomplete/index.js +1121 -5
  4. package/dist/avatar/index.js +276 -5
  5. package/dist/badge/index.js +193 -4
  6. package/dist/bottom-sheet/index.js +364 -4
  7. package/dist/button/index.js +2 -2
  8. package/dist/card/index.cjs +429 -0
  9. package/dist/card/index.d.cts +186 -0
  10. package/dist/card/index.d.ts +186 -0
  11. package/dist/card/index.js +336 -0
  12. package/dist/carousel/index.js +377 -3
  13. package/dist/checkbox/index.js +1 -1
  14. package/dist/chip/index.js +497 -6
  15. package/dist/{chunk-VUVE6PK7.js → chunk-F7WH4DMG.js} +1 -1
  16. package/dist/{chunk-TJ2FPLLZ.js → chunk-JEGEPGVU.js} +2 -2
  17. package/dist/{chunk-MZL77KV5.js → chunk-LTKYHG5V.js} +1 -1
  18. package/dist/{chunk-RIVFFZRO.js → chunk-LUBWRVI2.js} +1 -1
  19. package/dist/core/index.cjs +1 -1
  20. package/dist/core/index.js +1 -1
  21. package/dist/datepicker/index.js +1623 -4
  22. package/dist/divider/index.js +2 -2
  23. package/dist/fab/index.js +3 -3
  24. package/dist/fab-menu/index.js +324 -6
  25. package/dist/index.cjs +0 -6446
  26. package/dist/index.d.cts +2 -19
  27. package/dist/index.d.ts +2 -19
  28. package/dist/index.js +0 -73
  29. package/dist/indicator/index.js +2 -2
  30. package/dist/menu/index.js +1 -1
  31. package/dist/progress/index.js +1 -1
  32. package/dist/segment-button/index.js +400 -5
  33. package/dist/select/index.js +1 -1
  34. package/dist/switch/index.js +1 -1
  35. package/dist/typography/index.js +146 -4
  36. package/package.json +6 -1
  37. package/dist/chunk-6PXMB5CH.js +0 -503
  38. package/dist/chunk-DBKVHMSA.js +0 -329
  39. package/dist/chunk-EW5YLICE.js +0 -382
  40. package/dist/chunk-JJOVGRNI.js +0 -1627
  41. package/dist/chunk-K2HSVISE.js +0 -281
  42. package/dist/chunk-OXVIVNIJ.js +0 -356
  43. package/dist/chunk-PWCUULAL.js +0 -150
  44. package/dist/chunk-S3MGBM3G.js +0 -368
  45. package/dist/chunk-STUNTRKJ.js +0 -405
  46. package/dist/chunk-UGDGCMGC.js +0 -197
  47. package/dist/chunk-XUYIAA3A.js +0 -1127
@@ -1,405 +0,0 @@
1
- import {
2
- useBorderRadiusStyles,
3
- useXUITheme
4
- } from "./chunk-MZL77KV5.js";
5
-
6
- // src/components/segment-button/segment-button.tsx
7
- import React, { useCallback, useMemo as useMemo2, useState } from "react";
8
- import { View } from "react-native";
9
-
10
- // src/components/segment-button/segment-button.style.ts
11
- import { StyleSheet } from "react-native";
12
- var styles = StyleSheet.create({
13
- container: {
14
- flexDirection: "row",
15
- alignItems: "stretch",
16
- overflow: "hidden",
17
- alignSelf: "flex-start"
18
- },
19
- fullWidth: {
20
- width: "100%",
21
- alignSelf: "stretch"
22
- },
23
- segment: {
24
- flex: 1
25
- },
26
- segmentInner: {
27
- flex: 1,
28
- flexDirection: "row",
29
- alignItems: "center",
30
- justifyContent: "center"
31
- },
32
- segmentContent: {
33
- flexDirection: "row",
34
- alignItems: "center",
35
- justifyContent: "center",
36
- gap: 4
37
- },
38
- segmentText: {
39
- fontWeight: "500",
40
- textAlign: "center"
41
- },
42
- disabled: {
43
- opacity: 0.5
44
- },
45
- divider: {
46
- width: 1,
47
- alignSelf: "stretch"
48
- }
49
- });
50
-
51
- // src/components/segment-button/segment-button.hook.ts
52
- import { useMemo } from "react";
53
- import { getSafeThemeColor, withPaletteNumber } from "@xaui/core";
54
- function useSegmentSizeStyles(size) {
55
- const theme = useXUITheme();
56
- return useMemo(() => {
57
- const sizes = {
58
- xs: {
59
- paddingHorizontal: theme.spacing.sm,
60
- paddingVertical: theme.spacing.xs,
61
- minHeight: 32,
62
- fontSize: theme.fontSizes.xs,
63
- iconSize: 14
64
- },
65
- sm: {
66
- paddingHorizontal: theme.spacing.md,
67
- paddingVertical: theme.spacing.xs,
68
- minHeight: 36,
69
- fontSize: theme.fontSizes.sm,
70
- iconSize: 16
71
- },
72
- md: {
73
- paddingHorizontal: theme.spacing.md,
74
- paddingVertical: theme.spacing.sm,
75
- minHeight: 40,
76
- fontSize: theme.fontSizes.md,
77
- iconSize: 18
78
- },
79
- lg: {
80
- paddingHorizontal: theme.spacing.lg,
81
- paddingVertical: theme.spacing.md,
82
- minHeight: 48,
83
- fontSize: theme.fontSizes.lg,
84
- iconSize: 20
85
- }
86
- };
87
- return sizes[size];
88
- }, [size, theme]);
89
- }
90
- function useSegmentVariantStyles(themeColor, variant, elevation = 0) {
91
- const theme = useXUITheme();
92
- const safeThemeColor = getSafeThemeColor(themeColor);
93
- const colorScheme = theme.colors[safeThemeColor];
94
- const selectedBackgroundColor = withPaletteNumber(colorScheme.main, 400);
95
- return useMemo(() => {
96
- const variants = {
97
- outlined: {
98
- containerBackground: "transparent",
99
- containerBorderWidth: theme.borderWidth.sm,
100
- containerBorderColor: colorScheme.main,
101
- selectedBackground: selectedBackgroundColor,
102
- unselectedBackground: "transparent",
103
- selectedTextColor: colorScheme.foreground,
104
- unselectedTextColor: colorScheme.main
105
- },
106
- flat: {
107
- containerBackground: colorScheme.background,
108
- containerBorderWidth: 0,
109
- containerBorderColor: "transparent",
110
- selectedBackground: selectedBackgroundColor,
111
- unselectedBackground: "transparent",
112
- selectedTextColor: colorScheme.foreground,
113
- unselectedTextColor: colorScheme.main
114
- },
115
- light: {
116
- containerBackground: "transparent",
117
- containerBorderWidth: 0,
118
- containerBorderColor: "transparent",
119
- selectedBackground: selectedBackgroundColor,
120
- unselectedBackground: "transparent",
121
- selectedTextColor: colorScheme.foreground,
122
- unselectedTextColor: colorScheme.main
123
- },
124
- faded: {
125
- containerBackground: `${colorScheme.background}95`,
126
- containerBorderWidth: theme.borderWidth.sm,
127
- containerBorderColor: `${colorScheme.main}90`,
128
- selectedBackground: selectedBackgroundColor,
129
- unselectedBackground: "transparent",
130
- selectedTextColor: colorScheme.foreground,
131
- unselectedTextColor: colorScheme.main
132
- }
133
- };
134
- const baseStyle = variants[variant] ?? variants.outlined;
135
- const shouldApplyElevation = variant !== "outlined" && variant !== "light";
136
- const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
137
- return {
138
- ...baseStyle,
139
- containerShadow: shouldApplyElevation && elevation > 0 ? shadowStyles : baseStyle.containerShadow
140
- };
141
- }, [variant, colorScheme, theme, elevation]);
142
- }
143
-
144
- // src/components/segment-button/segment-button-context.ts
145
- import { createContext, useContext } from "react";
146
- var SegmentButtonContext = createContext(void 0);
147
- var useSegmentButtonContext = () => {
148
- const context = useContext(SegmentButtonContext);
149
- if (!context) {
150
- throw new Error(
151
- "SegmentButtonItem must be used within a SegmentButton component"
152
- );
153
- }
154
- return context;
155
- };
156
-
157
- // src/components/segment-button/segment-button.tsx
158
- var SegmentButton = ({
159
- children,
160
- selected: controlledSelected,
161
- defaultSelected,
162
- onSelectionChange,
163
- selectionMode = "single",
164
- themeColor = "primary",
165
- variant = "outlined",
166
- size = "md",
167
- radius = "full",
168
- fullWidth = false,
169
- isDisabled = false,
170
- showCheckmark = true,
171
- elevation = 0,
172
- customAppearance
173
- }) => {
174
- const isControlled = controlledSelected !== void 0;
175
- const [internalSelected, setInternalSelected] = useState(
176
- () => defaultSelected ?? ""
177
- );
178
- const selected = isControlled ? controlledSelected : internalSelected;
179
- const selectedKeys = useMemo2(() => {
180
- if (Array.isArray(selected)) return selected;
181
- return selected ? [selected] : [];
182
- }, [selected]);
183
- const variantStyles = useSegmentVariantStyles(themeColor, variant, elevation);
184
- const radiusStyles = useBorderRadiusStyles(radius);
185
- const toggleItem = useCallback(
186
- (key) => {
187
- let nextSelected;
188
- if (selectionMode === "single") {
189
- nextSelected = key;
190
- } else {
191
- const isCurrentlySelected = selectedKeys.includes(key);
192
- if (isCurrentlySelected && selectedKeys.length > 1) {
193
- nextSelected = selectedKeys.filter((k) => k !== key);
194
- } else if (!isCurrentlySelected) {
195
- nextSelected = [...selectedKeys, key];
196
- } else {
197
- return;
198
- }
199
- }
200
- if (!isControlled) {
201
- setInternalSelected(nextSelected);
202
- }
203
- onSelectionChange?.(nextSelected);
204
- },
205
- [selectionMode, selectedKeys, onSelectionChange, isControlled]
206
- );
207
- const contextValue = useMemo2(
208
- () => ({
209
- selectedKeys,
210
- toggleItem,
211
- themeColor,
212
- variant,
213
- size,
214
- elevation,
215
- isDisabled,
216
- showCheckmark
217
- }),
218
- [
219
- selectedKeys,
220
- toggleItem,
221
- themeColor,
222
- variant,
223
- size,
224
- elevation,
225
- isDisabled,
226
- showCheckmark
227
- ]
228
- );
229
- const showDivider = variant === "outlined" || variant === "faded";
230
- const childrenArray = React.Children.toArray(children);
231
- const getItemKey = (child) => {
232
- if (!React.isValidElement(child)) {
233
- return void 0;
234
- }
235
- return child.props.itemKey;
236
- };
237
- return /* @__PURE__ */ React.createElement(SegmentButtonContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(
238
- View,
239
- {
240
- style: [
241
- styles.container,
242
- {
243
- backgroundColor: variantStyles.containerBackground,
244
- borderWidth: variantStyles.containerBorderWidth,
245
- borderColor: variantStyles.containerBorderColor,
246
- borderRadius: radiusStyles.borderRadius,
247
- ...variantStyles.containerShadow
248
- },
249
- fullWidth && styles.fullWidth,
250
- customAppearance?.container
251
- ]
252
- },
253
- childrenArray.map((child, index) => {
254
- const isLast = index === childrenArray.length - 1;
255
- const childItemKey = getItemKey(child);
256
- const childKey = childItemKey ?? index;
257
- const isSelected = selectedKeys.includes(String(childKey));
258
- const nextChildKey = !isLast ? getItemKey(childrenArray[index + 1]) : void 0;
259
- const nextSelected = nextChildKey ? selectedKeys.includes(String(nextChildKey)) : false;
260
- return /* @__PURE__ */ React.createElement(React.Fragment, { key: childKey }, child, showDivider && !isLast && !isSelected && !nextSelected && /* @__PURE__ */ React.createElement(
261
- View,
262
- {
263
- style: [
264
- styles.divider,
265
- {
266
- backgroundColor: variantStyles.containerBorderColor
267
- }
268
- ]
269
- }
270
- ));
271
- })
272
- ));
273
- };
274
-
275
- // src/components/segment-button/segment-button-item.tsx
276
- import React2, { useEffect, useRef } from "react";
277
- import { Pressable, Text, View as View2, Animated as Animated2 } from "react-native";
278
- import Svg, { Path } from "react-native-svg";
279
-
280
- // src/components/segment-button/segment-button.animation.ts
281
- import { Animated } from "react-native";
282
- var runCheckmarkEnterAnimation = (animatedValue) => {
283
- animatedValue.setValue(0);
284
- Animated.timing(animatedValue, {
285
- toValue: 1,
286
- duration: 200,
287
- useNativeDriver: true
288
- }).start();
289
- };
290
- var runCheckmarkExitAnimation = (animatedValue) => {
291
- Animated.timing(animatedValue, {
292
- toValue: 0,
293
- duration: 150,
294
- useNativeDriver: true
295
- }).start();
296
- };
297
-
298
- // src/components/segment-button/segment-button-item.tsx
299
- var CheckIcon = ({ size, color }) => /* @__PURE__ */ React2.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React2.createElement(
300
- Path,
301
- {
302
- d: "M20 6L9 17l-5-5",
303
- stroke: color,
304
- strokeWidth: 2.5,
305
- strokeLinecap: "round",
306
- strokeLinejoin: "round"
307
- }
308
- ));
309
- var SegmentButtonItem = ({
310
- itemKey,
311
- label,
312
- startContent,
313
- icon,
314
- endContent,
315
- checkIndicator,
316
- isDisabled: itemDisabled = false,
317
- customAppearance
318
- }) => {
319
- const {
320
- selectedKeys,
321
- toggleItem,
322
- themeColor,
323
- variant,
324
- size,
325
- elevation,
326
- isDisabled: groupDisabled,
327
- showCheckmark
328
- } = useSegmentButtonContext();
329
- const isSelected = selectedKeys.includes(itemKey);
330
- const disabled = groupDisabled || itemDisabled;
331
- const checkmarkAnim = useRef(new Animated2.Value(isSelected ? 1 : 0)).current;
332
- const prevSelected = useRef(isSelected);
333
- useEffect(() => {
334
- if (isSelected && !prevSelected.current) {
335
- runCheckmarkEnterAnimation(checkmarkAnim);
336
- } else if (!isSelected && prevSelected.current) {
337
- runCheckmarkExitAnimation(checkmarkAnim);
338
- }
339
- prevSelected.current = isSelected;
340
- }, [isSelected, checkmarkAnim]);
341
- const sizeStyles = useSegmentSizeStyles(size);
342
- const variantStyles = useSegmentVariantStyles(themeColor, variant, elevation);
343
- const handlePress = () => {
344
- if (!disabled) {
345
- toggleItem(itemKey);
346
- }
347
- };
348
- const backgroundColor = isSelected ? variantStyles.selectedBackground : variantStyles.unselectedBackground;
349
- const textColor = isSelected ? variantStyles.selectedTextColor : variantStyles.unselectedTextColor;
350
- const showCheck = isSelected && showCheckmark;
351
- const startNode = showCheck ? checkIndicator ?? /* @__PURE__ */ React2.createElement(CheckIcon, { size: sizeStyles.iconSize, color: textColor }) : startContent ?? icon;
352
- return /* @__PURE__ */ React2.createElement(
353
- Pressable,
354
- {
355
- style: [styles.segment, disabled && styles.disabled],
356
- onPress: handlePress,
357
- disabled
358
- },
359
- /* @__PURE__ */ React2.createElement(
360
- View2,
361
- {
362
- style: [
363
- styles.segmentInner,
364
- {
365
- paddingHorizontal: sizeStyles.paddingHorizontal,
366
- paddingVertical: sizeStyles.paddingVertical,
367
- minHeight: sizeStyles.minHeight,
368
- backgroundColor
369
- },
370
- isSelected ? customAppearance?.selectedSegment : customAppearance?.segment
371
- ]
372
- },
373
- /* @__PURE__ */ React2.createElement(View2, { style: styles.segmentContent }, startNode && /* @__PURE__ */ React2.createElement(
374
- Animated2.View,
375
- {
376
- style: {
377
- opacity: showCheck ? checkmarkAnim : 1,
378
- transform: [{ scale: showCheck ? checkmarkAnim : 1 }]
379
- }
380
- },
381
- startNode
382
- ), /* @__PURE__ */ React2.createElement(
383
- Text,
384
- {
385
- numberOfLines: 1,
386
- style: [
387
- styles.segmentText,
388
- {
389
- fontSize: sizeStyles.fontSize,
390
- color: textColor
391
- },
392
- isSelected ? customAppearance?.selectedText : customAppearance?.text
393
- ]
394
- },
395
- label
396
- ), endContent)
397
- )
398
- );
399
- };
400
- SegmentButtonItem.displayName = "SegmentButtonItem";
401
-
402
- export {
403
- SegmentButton,
404
- SegmentButtonItem
405
- };
@@ -1,197 +0,0 @@
1
- import {
2
- useXUITheme
3
- } from "./chunk-MZL77KV5.js";
4
-
5
- // src/components/badge/badge.tsx
6
- import React from "react";
7
- import { Text, View } from "react-native";
8
-
9
- // src/components/badge/badge.style.ts
10
- import { StyleSheet } from "react-native";
11
- var styles = StyleSheet.create({
12
- container: {
13
- position: "relative",
14
- alignSelf: "flex-start"
15
- },
16
- badge: {
17
- position: "absolute",
18
- alignItems: "center",
19
- justifyContent: "center"
20
- },
21
- text: {
22
- textAlign: "center",
23
- fontWeight: "600",
24
- includeFontPadding: false,
25
- textAlignVertical: "center"
26
- }
27
- });
28
-
29
- // src/components/badge/badge.hook.ts
30
- import { useMemo } from "react";
31
- import { getSafeThemeColor, withOpacity } from "@xaui/core";
32
- var sizeMap = {
33
- sm: { height: 16, minWidth: 16, dot: 8 },
34
- md: { height: 20, minWidth: 20, dot: 10 },
35
- lg: { height: 24, minWidth: 24, dot: 12 }
36
- };
37
- var fontSizeMap = {
38
- sm: 9,
39
- md: 10,
40
- lg: 12
41
- };
42
- function useBadgeSizeStyles(size, isDot, isOneChar) {
43
- const theme = useXUITheme();
44
- return useMemo(() => {
45
- const { height, minWidth, dot } = sizeMap[size];
46
- const fontSize = fontSizeMap[size];
47
- if (isDot) {
48
- return {
49
- height: dot,
50
- minWidth: dot,
51
- paddingHorizontal: 0,
52
- fontSize
53
- };
54
- }
55
- if (isOneChar) {
56
- return {
57
- height,
58
- minWidth: height,
59
- paddingHorizontal: 0,
60
- fontSize
61
- };
62
- }
63
- const paddingHorizontal = size === "sm" ? theme.spacing.xs : theme.spacing.sm;
64
- return {
65
- height,
66
- minWidth,
67
- paddingHorizontal,
68
- fontSize
69
- };
70
- }, [isDot, isOneChar, size, theme]);
71
- }
72
- function useBadgeVariantStyles(themeColor, variant) {
73
- const theme = useXUITheme();
74
- const safeThemeColor = getSafeThemeColor(themeColor);
75
- const colorScheme = theme.colors[safeThemeColor];
76
- return useMemo(() => {
77
- if (variant === "flat") {
78
- return {
79
- backgroundColor: colorScheme.background,
80
- color: colorScheme.main
81
- };
82
- }
83
- if (variant === "faded") {
84
- return {
85
- backgroundColor: withOpacity(colorScheme.background, 0.7),
86
- color: colorScheme.main
87
- };
88
- }
89
- if (variant === "shadow") {
90
- return {
91
- backgroundColor: colorScheme.main,
92
- color: colorScheme.foreground,
93
- shadow: theme.shadows.sm
94
- };
95
- }
96
- return {
97
- backgroundColor: colorScheme.main,
98
- color: colorScheme.foreground
99
- };
100
- }, [colorScheme, theme, variant]);
101
- }
102
- function useBadgeRadiusStyles(radius, height) {
103
- const theme = useXUITheme();
104
- return useMemo(() => {
105
- if (radius === "full") {
106
- return { borderRadius: height / 2 };
107
- }
108
- return { borderRadius: theme.borderRadius[radius] };
109
- }, [height, radius, theme.borderRadius]);
110
- }
111
- function useBadgePlacementStyles(placement, height) {
112
- return useMemo(() => {
113
- const offset = Math.round(height * 0.3);
114
- switch (placement) {
115
- case "top-left":
116
- return { top: -offset, left: -offset };
117
- case "bottom-right":
118
- return { bottom: -offset, right: -offset };
119
- case "bottom-left":
120
- return { bottom: -offset, left: -offset };
121
- case "top-right":
122
- default:
123
- return { top: -offset, right: -offset };
124
- }
125
- }, [height, placement]);
126
- }
127
-
128
- // src/components/badge/badge.tsx
129
- var Badge = ({
130
- children,
131
- content,
132
- themeColor = "primary",
133
- variant = "solid",
134
- size = "md",
135
- radius = "full",
136
- placement = "top-right",
137
- showOutline = true,
138
- disableOutline = false,
139
- isInvisible = false,
140
- isDot = false,
141
- isOneChar = false,
142
- disableAnimation = false,
143
- customAppearance
144
- }) => {
145
- const shouldRender = !isInvisible && (isDot || content !== void 0);
146
- if (!shouldRender && !children) {
147
- return null;
148
- }
149
- const forceOneChar = isOneChar || radius === "full";
150
- const sizeStyles = useBadgeSizeStyles(size, isDot, forceOneChar);
151
- const variantStyles = useBadgeVariantStyles(themeColor, variant);
152
- const radiusStyles = useBadgeRadiusStyles(radius, sizeStyles.height);
153
- const placementStyles = useBadgePlacementStyles(placement, sizeStyles.height);
154
- const outlineEnabled = disableOutline ? false : showOutline;
155
- const outlineStyles = outlineEnabled ? { borderWidth: 1, borderColor: "#FFFFFF" } : { borderWidth: 0, borderColor: "transparent" };
156
- const badgeContent = isDot ? null : content;
157
- return /* @__PURE__ */ React.createElement(View, { style: [styles.container, customAppearance?.container] }, children, shouldRender && /* @__PURE__ */ React.createElement(
158
- View,
159
- {
160
- style: [
161
- styles.badge,
162
- {
163
- minWidth: sizeStyles.minWidth,
164
- height: sizeStyles.height,
165
- paddingHorizontal: sizeStyles.paddingHorizontal,
166
- backgroundColor: variantStyles.backgroundColor,
167
- opacity: disableAnimation ? 1 : 1
168
- },
169
- radiusStyles,
170
- placementStyles,
171
- outlineStyles,
172
- variantStyles.shadow,
173
- customAppearance?.badge
174
- ],
175
- accessible: true,
176
- accessibilityRole: "text"
177
- },
178
- badgeContent !== void 0 && badgeContent !== null && /* @__PURE__ */ React.createElement(
179
- Text,
180
- {
181
- style: [
182
- styles.text,
183
- {
184
- fontSize: sizeStyles.fontSize,
185
- color: variantStyles.color
186
- },
187
- customAppearance?.text
188
- ]
189
- },
190
- badgeContent
191
- )
192
- ));
193
- };
194
-
195
- export {
196
- Badge
197
- };