@xaui/native 0.9.1-alpha.91 → 0.9.1-alpha.92

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 (86) hide show
  1. package/dist/chunk-3A5RK2R7.js +40 -0
  2. package/dist/chunk-6JAGPPZU.cjs +788 -0
  3. package/dist/chunk-7NQL5DXY.js +302 -0
  4. package/dist/chunk-FTPPUTWL.cjs +40 -0
  5. package/dist/chunk-GGP2ERSV.js +487 -0
  6. package/dist/chunk-KPKEZWZM.js +517 -0
  7. package/dist/chunk-LKRQUQZQ.cjs +487 -0
  8. package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
  9. package/dist/chunk-UR37LVPU.cjs +382 -0
  10. package/dist/chunk-XWIPLZTD.cjs +302 -0
  11. package/dist/components/carousel/index.cjs +3 -2
  12. package/dist/components/carousel/index.js +2 -1
  13. package/dist/components/index.d.cts +3 -0
  14. package/dist/components/index.d.ts +3 -0
  15. package/dist/components/number-pad/index.cjs +40 -0
  16. package/dist/components/number-pad/index.d.cts +60 -0
  17. package/dist/components/number-pad/index.d.ts +60 -0
  18. package/dist/components/number-pad/index.js +40 -0
  19. package/dist/components/number-pad/number-pad-action.d.cts +24 -0
  20. package/dist/components/number-pad/number-pad-action.d.ts +24 -0
  21. package/dist/components/number-pad/number-pad-backspace.d.cts +18 -0
  22. package/dist/components/number-pad/number-pad-backspace.d.ts +18 -0
  23. package/dist/components/number-pad/number-pad-cell.d.cts +7 -0
  24. package/dist/components/number-pad/number-pad-cell.d.ts +7 -0
  25. package/dist/components/number-pad/number-pad-icon.d.cts +13 -0
  26. package/dist/components/number-pad/number-pad-icon.d.ts +13 -0
  27. package/dist/components/number-pad/number-pad-key.d.cts +24 -0
  28. package/dist/components/number-pad/number-pad-key.d.ts +24 -0
  29. package/dist/components/number-pad/number-pad-label.d.cts +14 -0
  30. package/dist/components/number-pad/number-pad-label.d.ts +14 -0
  31. package/dist/components/number-pad/number-pad.context.d.cts +18 -0
  32. package/dist/components/number-pad/number-pad.context.d.ts +18 -0
  33. package/dist/components/number-pad/number-pad.d.cts +57 -0
  34. package/dist/components/number-pad/number-pad.d.ts +57 -0
  35. package/dist/components/number-pad/number-pad.recipe.d.cts +11 -0
  36. package/dist/components/number-pad/number-pad.recipe.d.ts +11 -0
  37. package/dist/components/number-pad/number-pad.style.d.cts +13 -0
  38. package/dist/components/number-pad/number-pad.style.d.ts +13 -0
  39. package/dist/components/number-pad/number-pad.type.d.cts +135 -0
  40. package/dist/components/number-pad/number-pad.type.d.ts +135 -0
  41. package/dist/components/number-pad/number-pad.utils.d.cts +34 -0
  42. package/dist/components/number-pad/number-pad.utils.d.ts +34 -0
  43. package/dist/components/pager/index.cjs +31 -0
  44. package/dist/components/pager/index.d.cts +60 -0
  45. package/dist/components/pager/index.d.ts +60 -0
  46. package/dist/components/pager/index.js +31 -0
  47. package/dist/components/pager/pager-content.d.cts +24 -0
  48. package/dist/components/pager/pager-content.d.ts +24 -0
  49. package/dist/components/pager/pager-indicator.d.cts +47 -0
  50. package/dist/components/pager/pager-indicator.d.ts +47 -0
  51. package/dist/components/pager/pager-page.d.cts +16 -0
  52. package/dist/components/pager/pager-page.d.ts +16 -0
  53. package/dist/components/pager/pager.context.d.cts +7 -0
  54. package/dist/components/pager/pager.context.d.ts +7 -0
  55. package/dist/components/pager/pager.d.cts +71 -0
  56. package/dist/components/pager/pager.d.ts +71 -0
  57. package/dist/components/pager/pager.recipe.d.cts +15 -0
  58. package/dist/components/pager/pager.recipe.d.ts +15 -0
  59. package/dist/components/pager/pager.type.d.cts +108 -0
  60. package/dist/components/pager/pager.type.d.ts +108 -0
  61. package/dist/components/rating/index.cjs +30 -0
  62. package/dist/components/rating/index.d.cts +41 -0
  63. package/dist/components/rating/index.d.ts +41 -0
  64. package/dist/components/rating/index.js +30 -0
  65. package/dist/components/rating/rating-icon.d.cts +16 -0
  66. package/dist/components/rating/rating-icon.d.ts +16 -0
  67. package/dist/components/rating/rating-item.d.cts +23 -0
  68. package/dist/components/rating/rating-item.d.ts +23 -0
  69. package/dist/components/rating/rating-star.d.cts +19 -0
  70. package/dist/components/rating/rating-star.d.ts +19 -0
  71. package/dist/components/rating/rating.context.d.cts +16 -0
  72. package/dist/components/rating/rating.context.d.ts +16 -0
  73. package/dist/components/rating/rating.d.cts +59 -0
  74. package/dist/components/rating/rating.d.ts +59 -0
  75. package/dist/components/rating/rating.recipe.d.cts +11 -0
  76. package/dist/components/rating/rating.recipe.d.ts +11 -0
  77. package/dist/components/rating/rating.style.d.cts +24 -0
  78. package/dist/components/rating/rating.style.d.ts +24 -0
  79. package/dist/components/rating/rating.type.d.cts +108 -0
  80. package/dist/components/rating/rating.type.d.ts +108 -0
  81. package/dist/components/rating/rating.utils.d.cts +28 -0
  82. package/dist/components/rating/rating.utils.d.ts +28 -0
  83. package/dist/index.cjs +90 -29
  84. package/dist/index.js +146 -85
  85. package/package.json +31 -1
  86. package/dist/chunk-K5UO3HBW.cjs +0 -1007
@@ -0,0 +1,302 @@
1
+ import {
2
+ useControllableState
3
+ } from "./chunk-F6W3JQ7K.js";
4
+ import {
5
+ PressableFeedback
6
+ } from "./chunk-2AFA5HA2.js";
7
+ import {
8
+ usePressState
9
+ } from "./chunk-423RQBOX.js";
10
+ import {
11
+ Icon
12
+ } from "./chunk-JN6IRT2M.js";
13
+ import {
14
+ createRecipe
15
+ } from "./chunk-DKVXTMIJ.js";
16
+ import {
17
+ createSlotContext
18
+ } from "./chunk-TTZOIXKE.js";
19
+ import {
20
+ warnDev
21
+ } from "./chunk-EGLLDKN6.js";
22
+ import {
23
+ useXAUITheme
24
+ } from "./chunk-Z6JBWRPL.js";
25
+ import {
26
+ useStyleProps
27
+ } from "./chunk-M63GFNKV.js";
28
+
29
+ // src/components/rating/rating.context.ts
30
+ var [RatingProvider, useRating] = createSlotContext("Rating");
31
+ var [RatingLayerProvider, useRatingLayer] = createSlotContext("Rating.Layer");
32
+
33
+ // src/components/rating/rating-icon.tsx
34
+ import { jsx } from "react/jsx-runtime";
35
+ function RatingIcon({ size, color, ...rest }) {
36
+ const { icon, iconFill } = useRating();
37
+ const { tone } = useRatingLayer();
38
+ const resolved = tone === "fill" ? iconFill : icon;
39
+ return /* @__PURE__ */ jsx(Icon, { size: size ?? resolved.size, color: color ?? resolved.color, ...rest });
40
+ }
41
+ RatingIcon.displayName = "XAUI.Rating.Icon";
42
+
43
+ // src/components/rating/rating-item.tsx
44
+ import { forwardRef, useMemo } from "react";
45
+ import { View } from "react-native";
46
+
47
+ // src/components/rating/rating-star.tsx
48
+ import { Text } from "react-native";
49
+ import { jsx as jsx2 } from "react/jsx-runtime";
50
+ function RatingStar() {
51
+ const { glyphStyle, glyphFillStyle, markSize } = useRating();
52
+ const { tone } = useRatingLayer();
53
+ return /* @__PURE__ */ jsx2(
54
+ Text,
55
+ {
56
+ style: [tone === "fill" ? glyphFillStyle : glyphStyle, { width: markSize }],
57
+ children: "\u2605"
58
+ }
59
+ );
60
+ }
61
+ RatingStar.displayName = "XAUI.Rating.Star";
62
+
63
+ // src/components/rating/rating.style.ts
64
+ import { StyleSheet } from "react-native";
65
+ var ratingSheet = StyleSheet.create({
66
+ clip: { position: "absolute", top: 0, start: 0, bottom: 0, overflow: "hidden" }
67
+ });
68
+
69
+ // src/components/rating/rating.utils.ts
70
+ function fillFor(value, index) {
71
+ return Math.min(1, Math.max(0, value - index));
72
+ }
73
+ function snapValue({ raw, precision, max }) {
74
+ if (precision <= 0) return Math.min(max, Math.max(0, raw));
75
+ const stepped = Math.ceil(raw / precision) * precision;
76
+ const clamped = Math.min(max, Math.max(precision, stepped));
77
+ return Math.round(clamped * 1e3) / 1e3;
78
+ }
79
+
80
+ // src/components/rating/rating-item.tsx
81
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
82
+ var RatingItem = forwardRef(function RatingItem2({
83
+ index,
84
+ children,
85
+ accessibilityRole,
86
+ accessibilityState,
87
+ style,
88
+ onPress,
89
+ onPressIn,
90
+ onPressOut,
91
+ ...props
92
+ }, ref) {
93
+ const { itemStyle, markSize, value, max, select, isReadOnly, isDisabled } = useRating();
94
+ const [styleProps, rest] = useStyleProps(props);
95
+ const [isPressed, press] = usePressState({ onPressIn, onPressOut });
96
+ const fill = fillFor(value, index);
97
+ const inert = isReadOnly || isDisabled;
98
+ const empty = useMemo(() => ({ tone: "empty" }), []);
99
+ const filled = useMemo(() => ({ tone: "fill" }), []);
100
+ const handlePress = (event) => {
101
+ onPress?.(event);
102
+ const ratio = markSize > 0 ? event.nativeEvent.locationX / markSize : 1;
103
+ select(index, ratio);
104
+ };
105
+ const glyph = children ?? /* @__PURE__ */ jsx3(RatingStar, {});
106
+ return /* @__PURE__ */ jsxs(
107
+ PressableFeedback,
108
+ {
109
+ ref,
110
+ isPressed,
111
+ isDisabled: inert,
112
+ accessibilityRole: accessibilityRole ?? (isReadOnly ? "image" : "button"),
113
+ accessibilityState: { disabled: isDisabled, ...accessibilityState },
114
+ accessibilityValue: isReadOnly ? void 0 : { now: index + 1, min: 1, max },
115
+ animation: false,
116
+ ...rest,
117
+ style: [
118
+ itemStyle,
119
+ styleProps,
120
+ typeof style === "function" ? style({ pressed: isPressed }) : style
121
+ ],
122
+ onPress: handlePress,
123
+ onPressIn: press.onPressIn,
124
+ onPressOut: press.onPressOut,
125
+ children: [
126
+ /* @__PURE__ */ jsx3(RatingLayerProvider, { value: empty, children: glyph }),
127
+ fill > 0 ? /* @__PURE__ */ jsx3(View, { style: [ratingSheet.clip, { width: markSize * fill }], children: /* @__PURE__ */ jsx3(RatingLayerProvider, { value: filled, children: glyph }) }) : null
128
+ ]
129
+ }
130
+ );
131
+ });
132
+ RatingItem.displayName = "XAUI.Rating.Item";
133
+
134
+ // src/components/rating/rating.tsx
135
+ import { forwardRef as forwardRef2, useCallback, useMemo as useMemo2 } from "react";
136
+ import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
137
+
138
+ // src/components/rating/rating.recipe.ts
139
+ var SLOTS = ["root", "item", "glyph", "glyphFill"];
140
+ var VARIANT_TOKENS = {
141
+ primary: { bgSelected: "accent" },
142
+ secondary: { bgSelected: "defaultForeground" },
143
+ tertiary: { bgSelected: "foreground" }
144
+ };
145
+ var SIZES = {
146
+ xs: { glyph: "sm", gap: 0.5 },
147
+ sm: { glyph: "md", gap: 0.5 },
148
+ md: { glyph: "xl", gap: 1 },
149
+ lg: { glyph: "2xl", gap: 1 }
150
+ };
151
+ function sizeAxis(step) {
152
+ const { glyph, gap } = step;
153
+ return (theme) => {
154
+ const type = {
155
+ fontSize: theme.fontSizes[glyph],
156
+ lineHeight: theme.lineHeights[glyph]
157
+ };
158
+ return {
159
+ root: { gap: theme.spacing(gap) },
160
+ glyph: type,
161
+ glyphFill: type
162
+ };
163
+ };
164
+ }
165
+ var ratingRecipe = createRecipe({
166
+ slots: SLOTS,
167
+ base: (theme) => ({
168
+ root: { flexDirection: "row", alignItems: "center" },
169
+ // A mark is as wide as its glyph, and the fill layer is positioned against its start
170
+ // edge — `relative` is what that layer's `position: absolute` is measured from.
171
+ item: { position: "relative" },
172
+ /**
173
+ * The unfilled mark reads the **neutral fill** token rather than a faint version of the
174
+ * filled colour: a pale tint of the accent under a row of stars looks like a control
175
+ * that half failed to load, where a neutral one looks like a mark that is simply not
176
+ * given yet. It is the same choice the `Carousel`'s inactive dots make.
177
+ */
178
+ glyph: {
179
+ fontFamily: theme.fontFamilies.body,
180
+ color: theme.colors.default
181
+ },
182
+ glyphFill: { fontFamily: theme.fontFamilies.body }
183
+ }),
184
+ variantTokens: VARIANT_TOKENS,
185
+ paint: (_theme, colors) => ({
186
+ glyphFill: { color: colors.bgSelected }
187
+ }),
188
+ variants: {
189
+ size: {
190
+ xs: sizeAxis(SIZES.xs),
191
+ sm: sizeAxis(SIZES.sm),
192
+ md: sizeAxis(SIZES.md),
193
+ lg: sizeAxis(SIZES.lg)
194
+ }
195
+ },
196
+ states: {
197
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
198
+ },
199
+ defaultVariants: { variant: "primary", size: "md" }
200
+ });
201
+
202
+ // src/components/rating/rating.tsx
203
+ import { jsx as jsx4 } from "react/jsx-runtime";
204
+ var RatingRoot = forwardRef2(function Rating({
205
+ children,
206
+ variant,
207
+ size,
208
+ color,
209
+ max = 5,
210
+ value: controlledValue,
211
+ defaultValue = 0,
212
+ onValueChange,
213
+ precision = 1,
214
+ isReadOnly = false,
215
+ isDisabled = false,
216
+ accessibilityRole = "none",
217
+ style,
218
+ ...props
219
+ }, ref) {
220
+ const theme = useXAUITheme();
221
+ const [styleProps, rest] = useStyleProps(props);
222
+ const [value, setValue] = useControllableState({
223
+ value: controlledValue,
224
+ defaultValue,
225
+ onChange: onValueChange
226
+ });
227
+ const selection = { variant, size };
228
+ const states = { disabled: isDisabled };
229
+ const styles = ratingRecipe.resolve({ theme, selection, states });
230
+ const tint = color ? ratingRecipe.tint({ theme, color, selection, states }) : void 0;
231
+ const select = useCallback(
232
+ (index, ratio) => {
233
+ if (isReadOnly || isDisabled) return;
234
+ setValue(snapValue({ raw: index + ratio, precision, max }));
235
+ },
236
+ [isReadOnly, isDisabled, setValue, precision, max]
237
+ );
238
+ const context = useMemo2(() => {
239
+ const glyph = (...layers) => {
240
+ const flat = StyleSheet2.flatten(layers);
241
+ return {
242
+ size: flat.fontSize,
243
+ // `ColorValue` also covers the platform's opaque colours, which `Icon` cannot hand
244
+ // to a third-party component expecting a string.
245
+ color: typeof flat.color === "string" ? flat.color : void 0
246
+ };
247
+ };
248
+ const fill = glyph(styles.glyphFill, tint?.glyphFill);
249
+ return {
250
+ itemStyle: styles.item,
251
+ glyphStyle: styles.glyph,
252
+ glyphFillStyle: tint ? [styles.glyphFill, tint.glyphFill] : styles.glyphFill,
253
+ icon: glyph(styles.glyph),
254
+ iconFill: fill,
255
+ // The mark's width *is* its type size: a glyph is text, and the clip over it has to be
256
+ // measured in the same unit the glyph was set in. Read off the resolved slot rather
257
+ // than recomputed, so the recipe stays the only place a size is decided.
258
+ markSize: fill.size ?? 0,
259
+ value,
260
+ max,
261
+ precision,
262
+ select,
263
+ isReadOnly,
264
+ isDisabled
265
+ };
266
+ }, [styles, tint, value, max, precision, select, isReadOnly, isDisabled]);
267
+ const rootStyle = [styles.root, tint?.root, styleProps, style];
268
+ if (!Number.isInteger(max) || max < 1) {
269
+ warnDev(
270
+ `Rating: \`max\` is ${max}, and it has to be a whole number of at least one \u2014 a row of marks cannot be a fraction of a mark long.`
271
+ );
272
+ }
273
+ const count = Math.max(1, Math.floor(max));
274
+ return /* @__PURE__ */ jsx4(RatingProvider, { value: context, children: /* @__PURE__ */ jsx4(
275
+ View2,
276
+ {
277
+ ref,
278
+ accessibilityRole,
279
+ accessibilityLabel: isReadOnly ? `${value} out of ${count}` : rest.accessibilityLabel,
280
+ ...rest,
281
+ style: rootStyle,
282
+ children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsx4(RatingItem, { index, children }, index))
283
+ }
284
+ ) });
285
+ });
286
+ RatingRoot.displayName = "XAUI.Rating.Root";
287
+
288
+ // src/components/rating/index.ts
289
+ var Rating2 = Object.assign(RatingRoot, {
290
+ Item: RatingItem,
291
+ Icon: RatingIcon
292
+ });
293
+
294
+ export {
295
+ useRating,
296
+ useRatingLayer,
297
+ RatingIcon,
298
+ RatingItem,
299
+ ratingRecipe,
300
+ RatingRoot,
301
+ Rating2 as Rating
302
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/carousel.ts
2
+ function clamp(value, low, high) {
3
+ "worklet";
4
+ return Math.min(Math.max(value, low), high);
5
+ }
6
+ function carouselMetrics({
7
+ width,
8
+ itemsPerView,
9
+ gap,
10
+ peek
11
+ }) {
12
+ const perView = Math.max(1, Math.floor(itemsPerView));
13
+ const inset = peek > 0 ? peek + gap : 0;
14
+ const between = gap * (perView - 1);
15
+ const itemWidth = Math.max(0, (width - 2 * inset - between) / perView);
16
+ return { itemWidth, step: itemWidth + gap, gap, inset };
17
+ }
18
+ function indexFromOffset(offset, step, count) {
19
+ "worklet";
20
+ if (step <= 0 || count <= 0) return 0;
21
+ return clamp(Math.round(offset / step), 0, count - 1);
22
+ }
23
+ function progressFromOffset(offset, step, count) {
24
+ "worklet";
25
+ if (step <= 0 || count <= 0) return 0;
26
+ return clamp(offset / step, 0, count - 1);
27
+ }
28
+ function stepIndex(index, delta, count, hasLoop) {
29
+ if (count <= 0) return 0;
30
+ const next = index + delta;
31
+ if (hasLoop) return (next % count + count) % count;
32
+ return clamp(next, 0, count - 1);
33
+ }
34
+
35
+
36
+
37
+
38
+
39
+
40
+ exports.carouselMetrics = carouselMetrics; exports.indexFromOffset = indexFromOffset; exports.progressFromOffset = progressFromOffset; exports.stepIndex = stepIndex;