@xaui/native 0.0.21 → 0.0.24

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 (113) hide show
  1. package/README.md +195 -2
  2. package/dist/alert/index.js +1 -2
  3. package/dist/app-bar/index.cjs +217 -0
  4. package/dist/app-bar/index.d.cts +52 -0
  5. package/dist/app-bar/index.d.ts +52 -0
  6. package/dist/app-bar/index.js +142 -0
  7. package/dist/autocomplete/index.js +48 -36
  8. package/dist/avatar/index.js +1 -2
  9. package/dist/badge/index.js +1 -2
  10. package/dist/bottom-sheet/index.js +1 -2
  11. package/dist/bottom-tab-bar/index.cjs +571 -0
  12. package/dist/bottom-tab-bar/index.d.cts +211 -0
  13. package/dist/bottom-tab-bar/index.d.ts +211 -0
  14. package/dist/bottom-tab-bar/index.js +497 -0
  15. package/dist/button/index.d.cts +102 -5
  16. package/dist/button/index.d.ts +102 -5
  17. package/dist/button/index.js +2 -3
  18. package/dist/button.type-j1ZdkkSl.d.cts +4 -0
  19. package/dist/button.type-j1ZdkkSl.d.ts +4 -0
  20. package/dist/card/index.cjs +2 -0
  21. package/dist/card/index.d.cts +6 -1
  22. package/dist/card/index.d.ts +6 -1
  23. package/dist/card/index.js +4 -2
  24. package/dist/carousel/index.js +1 -1
  25. package/dist/chart/index.cjs +1067 -0
  26. package/dist/chart/index.d.cts +218 -0
  27. package/dist/chart/index.d.ts +218 -0
  28. package/dist/chart/index.js +1026 -0
  29. package/dist/checkbox/index.js +1 -2
  30. package/dist/chip/index.js +1 -2
  31. package/dist/chunk-3XSXTM3G.js +661 -0
  32. package/dist/chunk-4KSZLONZ.js +79 -0
  33. package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
  34. package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
  35. package/dist/chunk-I4V5Y5GD.js +76 -0
  36. package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
  37. package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
  38. package/dist/chunk-URBEEDFX.js +79 -0
  39. package/dist/core/index.js +3 -5
  40. package/dist/datepicker/index.js +1 -2
  41. package/dist/divider/index.js +2 -3
  42. package/dist/drawer/index.cjs +310 -0
  43. package/dist/drawer/index.d.cts +58 -0
  44. package/dist/drawer/index.d.ts +58 -0
  45. package/dist/drawer/index.js +236 -0
  46. package/dist/{accordion → expansion-panel}/index.cjs +45 -45
  47. package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
  48. package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
  49. package/dist/{accordion → expansion-panel}/index.js +40 -41
  50. package/dist/fab/index.d.cts +3 -3
  51. package/dist/fab/index.d.ts +3 -3
  52. package/dist/fab/index.js +3 -4
  53. package/dist/fab-menu/index.d.cts +2 -2
  54. package/dist/fab-menu/index.d.ts +2 -2
  55. package/dist/fab-menu/index.js +3 -4
  56. package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
  57. package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
  58. package/dist/feature-discovery/index.cjs +531 -0
  59. package/dist/feature-discovery/index.d.cts +82 -0
  60. package/dist/feature-discovery/index.d.ts +82 -0
  61. package/dist/feature-discovery/index.js +464 -0
  62. package/dist/indicator/index.js +2 -3
  63. package/dist/input/index.cjs +258 -164
  64. package/dist/input/index.d.cts +15 -1
  65. package/dist/input/index.d.ts +15 -1
  66. package/dist/input/index.js +219 -126
  67. package/dist/list/index.js +1 -2
  68. package/dist/menu/index.js +2 -2
  69. package/dist/menubox/index.cjs +369 -0
  70. package/dist/menubox/index.d.cts +98 -0
  71. package/dist/menubox/index.d.ts +98 -0
  72. package/dist/menubox/index.js +296 -0
  73. package/dist/pager/index.cjs +243 -0
  74. package/dist/pager/index.d.cts +93 -0
  75. package/dist/pager/index.d.ts +93 -0
  76. package/dist/pager/index.js +205 -0
  77. package/dist/progress/index.js +1 -2
  78. package/dist/radio/index.cjs +537 -0
  79. package/dist/radio/index.d.cts +145 -0
  80. package/dist/radio/index.d.ts +145 -0
  81. package/dist/radio/index.js +464 -0
  82. package/dist/segment-button/index.js +2 -2
  83. package/dist/select/index.js +22 -10
  84. package/dist/skeleton/index.js +2 -2
  85. package/dist/slider/index.cjs +655 -0
  86. package/dist/slider/index.d.cts +171 -0
  87. package/dist/slider/index.d.ts +171 -0
  88. package/dist/slider/index.js +575 -0
  89. package/dist/stepper/index.cjs +624 -0
  90. package/dist/stepper/index.d.cts +137 -0
  91. package/dist/stepper/index.d.ts +137 -0
  92. package/dist/stepper/index.js +549 -0
  93. package/dist/switch/index.js +1 -2
  94. package/dist/tabs/index.cjs +523 -0
  95. package/dist/tabs/index.d.cts +176 -0
  96. package/dist/tabs/index.d.ts +176 -0
  97. package/dist/tabs/index.js +438 -0
  98. package/dist/timepicker/index.cjs +1280 -0
  99. package/dist/timepicker/index.d.cts +215 -0
  100. package/dist/timepicker/index.d.ts +215 -0
  101. package/dist/timepicker/index.js +1181 -0
  102. package/dist/toolbar/index.cjs +395 -0
  103. package/dist/toolbar/index.d.cts +100 -0
  104. package/dist/toolbar/index.d.ts +100 -0
  105. package/dist/toolbar/index.js +325 -0
  106. package/dist/typography/index.js +1 -2
  107. package/dist/view/index.cjs +16 -2
  108. package/dist/view/index.js +16 -2
  109. package/package.json +73 -8
  110. package/dist/button.type-D8tzEBo7.d.ts +0 -104
  111. package/dist/button.type-ikaWzhIg.d.cts +0 -104
  112. package/dist/chunk-GBHQCAKW.js +0 -19
  113. package/dist/chunk-JEGEPGVU.js +0 -287
@@ -0,0 +1,93 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+
4
+ type PagerIndicatorRenderState = {
5
+ index: number;
6
+ isActive: boolean;
7
+ total: number;
8
+ };
9
+ type PagerCustomAppearance = {
10
+ /**
11
+ * Custom styles for the outer wrapper.
12
+ */
13
+ container?: ViewStyle;
14
+ /**
15
+ * Custom styles for the internal scroll view.
16
+ */
17
+ scrollView?: ViewStyle;
18
+ /**
19
+ * Custom styles applied to each page wrapper.
20
+ */
21
+ page?: ViewStyle;
22
+ /**
23
+ * Custom styles for the indicator row.
24
+ */
25
+ indicatorContainer?: ViewStyle;
26
+ /**
27
+ * Custom styles for each indicator item.
28
+ */
29
+ indicator?: ViewStyle;
30
+ /**
31
+ * Custom styles for the active indicator item.
32
+ */
33
+ activeIndicator?: ViewStyle;
34
+ };
35
+ type PagerProps = {
36
+ /**
37
+ * Whether the pager should fill its parent and render indicators inside.
38
+ * @default false
39
+ */
40
+ isFullscreen?: boolean;
41
+ /**
42
+ * Alias of `isFullscreen`.
43
+ * @default false
44
+ */
45
+ isfullscreen?: boolean;
46
+ /**
47
+ * Controlled active page index.
48
+ */
49
+ page?: number;
50
+ /**
51
+ * Default active page index (uncontrolled mode).
52
+ * @default 0
53
+ */
54
+ defaultPage?: number;
55
+ /**
56
+ * Callback fired when active page changes.
57
+ */
58
+ onPageChange?: (page: number) => void;
59
+ /**
60
+ * Whether swipe gesture is enabled.
61
+ * @default true
62
+ */
63
+ swipeEnabled?: boolean;
64
+ /**
65
+ * Whether to render indicators.
66
+ * @default true
67
+ */
68
+ showIndicator?: boolean;
69
+ /**
70
+ * Optional custom indicator renderer.
71
+ */
72
+ renderIndicator?: (state: PagerIndicatorRenderState) => ReactNode;
73
+ /**
74
+ * Pager pages. Prefer using `PagerItem`.
75
+ */
76
+ children: ReactNode;
77
+ /**
78
+ * Appearance overrides.
79
+ */
80
+ customAppearance?: PagerCustomAppearance;
81
+ };
82
+ type PagerItemProps = {
83
+ /**
84
+ * Page content.
85
+ */
86
+ children?: ReactNode;
87
+ };
88
+
89
+ declare const Pager: React.FC<PagerProps>;
90
+
91
+ declare const PagerItem: React.FC<PagerItemProps>;
92
+
93
+ export { Pager, type PagerIndicatorRenderState, PagerItem, type PagerItemProps, type PagerProps };
@@ -0,0 +1,205 @@
1
+ // src/components/pager/pager.tsx
2
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { ScrollView, View } from "react-native";
4
+
5
+ // src/components/pager/pager.style.ts
6
+ import { StyleSheet } from "react-native";
7
+ var styles = StyleSheet.create({
8
+ container: {
9
+ width: "100%"
10
+ },
11
+ fullscreenContainer: {
12
+ flex: 1
13
+ },
14
+ fullscreenScrollView: {
15
+ flex: 1
16
+ },
17
+ page: {
18
+ width: "100%"
19
+ },
20
+ fullscreenPage: {
21
+ flex: 1
22
+ },
23
+ indicatorContainer: {
24
+ marginTop: 12,
25
+ flexDirection: "row",
26
+ alignItems: "center",
27
+ justifyContent: "center"
28
+ },
29
+ fullscreenIndicatorContainer: {
30
+ position: "absolute",
31
+ bottom: 16,
32
+ left: 16,
33
+ right: 16,
34
+ marginTop: 0,
35
+ zIndex: 1,
36
+ elevation: 1
37
+ },
38
+ indicator: {
39
+ width: 8,
40
+ height: 8,
41
+ marginHorizontal: 3,
42
+ borderRadius: 999,
43
+ backgroundColor: "#D1D5DB"
44
+ },
45
+ activeIndicator: {
46
+ width: 18,
47
+ backgroundColor: "#111827"
48
+ }
49
+ });
50
+
51
+ // src/components/pager/pager-item.tsx
52
+ var PagerItem = () => null;
53
+ PagerItem.displayName = "PagerItem";
54
+
55
+ // src/components/pager/pager.tsx
56
+ function clampPage(page, max) {
57
+ return Math.max(0, Math.min(page, max));
58
+ }
59
+ function toPages(children) {
60
+ return React.Children.toArray(children).flatMap((child, index) => {
61
+ if (!React.isValidElement(child) || child.type !== PagerItem) {
62
+ return [];
63
+ }
64
+ return [
65
+ {
66
+ key: child.key != null ? String(child.key) : `page-${String(index)}`,
67
+ content: child.props.children
68
+ }
69
+ ];
70
+ });
71
+ }
72
+ var Pager = ({
73
+ isFullscreen = false,
74
+ isfullscreen,
75
+ page: controlledPage,
76
+ defaultPage = 0,
77
+ onPageChange,
78
+ swipeEnabled = true,
79
+ showIndicator = true,
80
+ renderIndicator,
81
+ children,
82
+ customAppearance
83
+ }) => {
84
+ const isPagerFullscreen = isFullscreen || isfullscreen === true;
85
+ const pages = useMemo(() => toPages(children), [children]);
86
+ const maxPage = Math.max(0, pages.length - 1);
87
+ const isControlled = controlledPage !== void 0;
88
+ const [internalPage, setInternalPage] = useState(clampPage(defaultPage, maxPage));
89
+ const [containerWidth, setContainerWidth] = useState(0);
90
+ const scrollViewRef = useRef(null);
91
+ const initialScrollAppliedRef = useRef(false);
92
+ const activePage = clampPage(
93
+ isControlled ? controlledPage ?? 0 : internalPage,
94
+ maxPage
95
+ );
96
+ useEffect(() => {
97
+ if (isControlled || pages.length === 0) return;
98
+ setInternalPage((prev) => clampPage(prev, maxPage));
99
+ }, [isControlled, maxPage, pages.length]);
100
+ useEffect(() => {
101
+ if (containerWidth <= 0) return;
102
+ if (pages.length <= 1) return;
103
+ const x = activePage * containerWidth;
104
+ if (!initialScrollAppliedRef.current) {
105
+ initialScrollAppliedRef.current = true;
106
+ scrollViewRef.current?.scrollTo({ x, animated: false });
107
+ return;
108
+ }
109
+ scrollViewRef.current?.scrollTo({ x, animated: true });
110
+ }, [activePage, containerWidth, pages.length]);
111
+ const handleLayout = useCallback((event) => {
112
+ setContainerWidth(event.nativeEvent.layout.width);
113
+ }, []);
114
+ const commitPageChange = useCallback(
115
+ (nextPage) => {
116
+ if (!isControlled) {
117
+ setInternalPage(nextPage);
118
+ }
119
+ onPageChange?.(nextPage);
120
+ },
121
+ [isControlled, onPageChange]
122
+ );
123
+ const handleMomentumScrollEnd = useCallback(
124
+ (event) => {
125
+ if (containerWidth <= 0 || pages.length === 0) return;
126
+ const rawPage = Math.round(event.nativeEvent.contentOffset.x / containerWidth);
127
+ const nextPage = clampPage(rawPage, maxPage);
128
+ if (nextPage !== activePage) {
129
+ commitPageChange(nextPage);
130
+ }
131
+ },
132
+ [activePage, commitPageChange, containerWidth, maxPage, pages.length]
133
+ );
134
+ return /* @__PURE__ */ React.createElement(
135
+ View,
136
+ {
137
+ onLayout: handleLayout,
138
+ style: [
139
+ styles.container,
140
+ isPagerFullscreen && styles.fullscreenContainer,
141
+ customAppearance?.container
142
+ ]
143
+ },
144
+ /* @__PURE__ */ React.createElement(
145
+ ScrollView,
146
+ {
147
+ ref: scrollViewRef,
148
+ horizontal: true,
149
+ pagingEnabled: true,
150
+ showsHorizontalScrollIndicator: false,
151
+ scrollEnabled: swipeEnabled,
152
+ onMomentumScrollEnd: handleMomentumScrollEnd,
153
+ style: [
154
+ isPagerFullscreen && styles.fullscreenScrollView,
155
+ customAppearance?.scrollView
156
+ ]
157
+ },
158
+ pages.map((pagerPage) => /* @__PURE__ */ React.createElement(
159
+ View,
160
+ {
161
+ key: pagerPage.key,
162
+ style: [
163
+ styles.page,
164
+ isPagerFullscreen && styles.fullscreenPage,
165
+ customAppearance?.page,
166
+ containerWidth > 0 && { width: containerWidth }
167
+ ]
168
+ },
169
+ pagerPage.content
170
+ ))
171
+ ),
172
+ showIndicator && pages.length > 1 && /* @__PURE__ */ React.createElement(
173
+ View,
174
+ {
175
+ style: [
176
+ styles.indicatorContainer,
177
+ customAppearance?.indicatorContainer,
178
+ isPagerFullscreen && styles.fullscreenIndicatorContainer
179
+ ]
180
+ },
181
+ pages.map((_, index) => {
182
+ const isActive = index === activePage;
183
+ if (renderIndicator) {
184
+ return /* @__PURE__ */ React.createElement(React.Fragment, { key: `indicator-${String(index)}` }, renderIndicator({ index, isActive, total: pages.length }));
185
+ }
186
+ return /* @__PURE__ */ React.createElement(
187
+ View,
188
+ {
189
+ key: `indicator-${String(index)}`,
190
+ style: [
191
+ styles.indicator,
192
+ customAppearance?.indicator,
193
+ isActive && styles.activeIndicator,
194
+ isActive && customAppearance?.activeIndicator
195
+ ]
196
+ }
197
+ );
198
+ })
199
+ )
200
+ );
201
+ };
202
+ export {
203
+ Pager,
204
+ PagerItem
205
+ };
@@ -1,7 +1,6 @@
1
- import "../chunk-DXXNBF5P.js";
2
1
  import {
3
2
  useXUITheme
4
- } from "../chunk-LTKYHG5V.js";
3
+ } from "../chunk-GHCVNQET.js";
5
4
 
6
5
  // src/components/progress/progress.tsx
7
6
  import React3 from "react";