@xaui/native 0.9.1-alpha.1 → 0.9.1-alpha.11

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.
@@ -0,0 +1,889 @@
1
+ import { deriveTint, useXAUITheme } from "./chunk-X2K2FX3W.js";
2
+
3
+ // src/system/icon/icon-context.ts
4
+ import { createContext, useContext } from "react";
5
+ var IconContext = createContext({});
6
+ IconContext.displayName = "XAUI.Icon.Context";
7
+ function useIconContext() {
8
+ return useContext(IconContext);
9
+ }
10
+
11
+ // src/system/icon/icon.tsx
12
+ import { cloneElement, isValidElement } from "react";
13
+ import { Image } from "react-native";
14
+ import { jsx } from "react/jsx-runtime";
15
+ function Icon({
16
+ as: Component,
17
+ children,
18
+ source,
19
+ size,
20
+ color,
21
+ style
22
+ }) {
23
+ const inherited = useIconContext();
24
+ const theme = useXAUITheme();
25
+ const resolvedSize = size ?? inherited.size ?? theme.fontSizes.md;
26
+ const resolvedColor = color ?? inherited.color ?? theme.colors.foreground;
27
+ if (Component) {
28
+ return /* @__PURE__ */jsx(Component, {
29
+ size: resolvedSize,
30
+ color: resolvedColor
31
+ });
32
+ }
33
+ if (isValidElement(children)) {
34
+ return cloneElement(children, {
35
+ width: resolvedSize,
36
+ height: resolvedSize,
37
+ color: resolvedColor
38
+ });
39
+ }
40
+ if (source) {
41
+ return /* @__PURE__ */jsx(Image, {
42
+ source,
43
+ style: [{
44
+ width: resolvedSize,
45
+ height: resolvedSize,
46
+ tintColor: resolvedColor
47
+ }, style]
48
+ });
49
+ }
50
+ throw new Error("XAUI: Icon needs one of `as` (an icon component), a raw SVG element as its child, or `source` (an image). It renders nothing on its own.");
51
+ }
52
+ Icon.displayName = "XAUI.Icon";
53
+
54
+ // src/system/slot/children-to-string.ts
55
+ import { isValidElement as isValidElement2 } from "react";
56
+ function childrenToString(children) {
57
+ const text = stringify(children);
58
+ return text === null || text === "" ? null : text;
59
+ }
60
+ function stringify(node) {
61
+ if (node === null || node === void 0 || typeof node === "boolean") return "";
62
+ if (typeof node === "string") return node;
63
+ if (typeof node === "number") return String(node);
64
+ if (isValidElement2(node)) return null;
65
+ if (Array.isArray(node)) {
66
+ let text = "";
67
+ for (const child of node) {
68
+ const part = stringify(child);
69
+ if (part === null) return null;
70
+ text += part;
71
+ }
72
+ return text;
73
+ }
74
+ return null;
75
+ }
76
+
77
+ // src/system/slot/create-slot-context.ts
78
+ import { createContext as createContext2, useContext as useContext2 } from "react";
79
+ function createSlotContext(name) {
80
+ const Context = createContext2(null);
81
+ Context.displayName = `XAUI.${name}.Context`;
82
+ function useSlotContext() {
83
+ const value = useContext2(Context);
84
+ if (value === null) {
85
+ const error = new Error(`XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`);
86
+ Error.captureStackTrace?.(error, useSlotContext);
87
+ throw error;
88
+ }
89
+ return value;
90
+ }
91
+ return [Context.Provider, useSlotContext];
92
+ }
93
+
94
+ // src/system/slot/merge-refs.ts
95
+ function mergeRefs(...refs) {
96
+ return value => {
97
+ for (const ref of refs) {
98
+ if (typeof ref === "function") ref(value);else if (ref) ref.current = value;
99
+ }
100
+ };
101
+ }
102
+
103
+ // src/system/slot/merge-props.ts
104
+ var EVENT_HANDLER = /^on[A-Z]/;
105
+ function mergeProps(ours, theirs) {
106
+ const merged = {
107
+ ...ours
108
+ };
109
+ for (const key of Object.keys(theirs)) {
110
+ const ourValue = ours[key];
111
+ const theirValue = theirs[key];
112
+ if (EVENT_HANDLER.test(key)) {
113
+ merged[key] = composeHandlers(ourValue, theirValue);
114
+ } else if (key === "style") {
115
+ merged[key] = mergeStyles(ourValue, theirValue);
116
+ } else if (key === "ref") {
117
+ merged[key] = mergeRefs(ourValue, theirValue);
118
+ } else {
119
+ merged[key] = theirValue;
120
+ }
121
+ }
122
+ return merged;
123
+ }
124
+ function composeHandlers(ours, theirs) {
125
+ if (typeof ours !== "function") return theirs;
126
+ if (typeof theirs !== "function") return ours;
127
+ return (...args) => {
128
+ ;
129
+ ours(...args);
130
+ return theirs(...args);
131
+ };
132
+ }
133
+ function mergeStyles(ours, theirs) {
134
+ if (typeof ours === "function" || typeof theirs === "function") {
135
+ return state => [resolveStyle(ours, state), resolveStyle(theirs, state)];
136
+ }
137
+ return [ours, theirs];
138
+ }
139
+ function resolveStyle(style, state) {
140
+ return typeof style === "function" ? style(state) : style;
141
+ }
142
+
143
+ // src/system/slot/slot.tsx
144
+ import { cloneElement as cloneElement2, forwardRef, isValidElement as isValidElement3 } from "react";
145
+ var Slot = forwardRef(function Slot2({
146
+ children,
147
+ ...ours
148
+ }, ref) {
149
+ if (!isValidElement3(children)) {
150
+ throw new Error("XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself.");
151
+ }
152
+ const child = children;
153
+ const merged = mergeProps(ours, child.props);
154
+ merged.ref = mergeRefs(ref, refOf(child));
155
+ return cloneElement2(child, merged);
156
+ });
157
+ Slot.displayName = "XAUI.Slot";
158
+ function refOf(element) {
159
+ const fromProps = element.props.ref;
160
+ const fromElement = element.ref;
161
+ return fromProps ?? fromElement;
162
+ }
163
+
164
+ // src/system/pressable-feedback/pressable-feedback-context.ts
165
+ import { createContext as createContext3 } from "react";
166
+ var [FeedbackProvider, useFeedback] = createSlotContext("PressableFeedback");
167
+ var DisableAllContext = createContext3(false);
168
+
169
+ // src/system/pressable-feedback/pressable-feedback.animation.ts
170
+ var PRESS_SCALE = 0.975;
171
+ var PRESS_DURATION = 100;
172
+ var RELEASE_DURATION = 150;
173
+ var HIGHLIGHT_OPACITY = 0.08;
174
+ var RIPPLE_OPACITY = 0.12;
175
+ var RIPPLE_DURATION = 350;
176
+ var RIPPLE_COVERAGE = 1.25;
177
+ var ALL_OFF = {
178
+ scale: false,
179
+ highlight: false,
180
+ ripple: false,
181
+ none: true
182
+ };
183
+ var ALL_ON = {
184
+ scale: true,
185
+ highlight: true,
186
+ ripple: true,
187
+ none: false
188
+ };
189
+ function resolveAnimation(animation, inheritedDisableAll = false) {
190
+ if (inheritedDisableAll) return {
191
+ ...ALL_OFF,
192
+ disableAll: true
193
+ };
194
+ if (animation === false || animation === "disabled") {
195
+ return {
196
+ ...ALL_OFF,
197
+ disableAll: false
198
+ };
199
+ }
200
+ if (animation === "disable-all") return {
201
+ ...ALL_OFF,
202
+ disableAll: true
203
+ };
204
+ if (animation === void 0 || animation === true) {
205
+ return {
206
+ ...ALL_ON,
207
+ disableAll: false
208
+ };
209
+ }
210
+ const scale = animation.scale ?? true;
211
+ const highlight = animation.highlight ?? true;
212
+ const ripple = animation.ripple ?? true;
213
+ return {
214
+ scale,
215
+ highlight,
216
+ ripple,
217
+ none: !scale && !highlight && !ripple,
218
+ disableAll: false
219
+ };
220
+ }
221
+ function resolveSlotAnimation(override, enabledByRoot, defaultOpacity, defaultDuration = PRESS_DURATION) {
222
+ const fallback = {
223
+ enabled: enabledByRoot,
224
+ duration: defaultDuration,
225
+ opacity: defaultOpacity
226
+ };
227
+ if (override === void 0 || override === true) return fallback;
228
+ if (override === false) return {
229
+ ...fallback,
230
+ enabled: false
231
+ };
232
+ return {
233
+ enabled: enabledByRoot,
234
+ duration: override.duration ?? defaultDuration,
235
+ opacity: override.opacity ?? defaultOpacity
236
+ };
237
+ }
238
+
239
+ // src/system/pressable-feedback/pressable-feedback.tsx
240
+ import { forwardRef as forwardRef2, useContext as useContext3, useEffect as useEffect2, useMemo } from "react";
241
+ import { Pressable } from "react-native";
242
+ import Animated3, { useAnimatedStyle as useAnimatedStyle3, useSharedValue as useSharedValue3, withTiming as withTiming3 } from "react-native-reanimated";
243
+
244
+ // src/system/pressable-feedback/pressable-feedback-highlight.tsx
245
+ import { useEffect } from "react";
246
+ import { StyleSheet, View } from "react-native";
247
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
248
+ import { jsx as jsx2 } from "react/jsx-runtime";
249
+ function PressableFeedbackHighlight({
250
+ style,
251
+ animation: override
252
+ }) {
253
+ const {
254
+ isPressed,
255
+ animation,
256
+ progress
257
+ } = useFeedback();
258
+ const theme = useXAUITheme();
259
+ const settings = resolveSlotAnimation(override, animation.highlight, HIGHLIGHT_OPACITY);
260
+ const base = [StyleSheet.absoluteFillObject, {
261
+ backgroundColor: theme.colors.foreground
262
+ }, style];
263
+ if (!progress || !settings.enabled) {
264
+ return /* @__PURE__ */jsx2(View, {
265
+ pointerEvents: "none",
266
+ style: [base, {
267
+ opacity: isPressed ? settings.opacity : 0
268
+ }]
269
+ });
270
+ }
271
+ return /* @__PURE__ */jsx2(AnimatedHighlight, {
272
+ base,
273
+ duration: settings.duration,
274
+ opacity: settings.opacity
275
+ });
276
+ }
277
+ PressableFeedbackHighlight.displayName = "XAUI.PressableFeedback.Highlight";
278
+ const _worklet_6834204559797_init_data = {
279
+ code: "function chunkR4HJCQPIJs1(){const{shown,opacity}=this.__closure;return{opacity:shown.value*opacity};}",
280
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js",
281
+ sourceMap: "{\"version\":3,\"names\":[\"chunkR4HJCQPIJs1\",\"shown\",\"opacity\",\"__closure\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js\"],\"mappings\":\"AA2SyC,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,CAAAC,OAAA,OAAAC,SAAA,CAE3C,MAAO,CAAED,OAAO,CAAED,KAAK,CAACG,KAAK,CAAGF,OAAQ,CAAC,CAC3C\",\"ignoreList\":[]}"
282
+ };
283
+ function AnimatedHighlight({
284
+ base,
285
+ duration,
286
+ opacity
287
+ }) {
288
+ const {
289
+ isPressed
290
+ } = useFeedback();
291
+ const shown = useSharedValue(0);
292
+ useEffect(() => {
293
+ shown.value = withTiming(isPressed ? 1 : 0, {
294
+ duration
295
+ });
296
+ }, [isPressed, shown, duration]);
297
+ const animatedStyle = useAnimatedStyle(function chunkR4HJCQPIJs1Factory({
298
+ _worklet_6834204559797_init_data,
299
+ shown,
300
+ opacity
301
+ }) {
302
+ const _e = [new global.Error(), -3, -27];
303
+ const chunkR4HJCQPIJs1 = function () {
304
+ return {
305
+ opacity: shown.value * opacity
306
+ };
307
+ };
308
+ chunkR4HJCQPIJs1.__closure = {
309
+ shown,
310
+ opacity
311
+ };
312
+ chunkR4HJCQPIJs1.__workletHash = 6834204559797;
313
+ chunkR4HJCQPIJs1.__pluginVersion = "0.7.4";
314
+ chunkR4HJCQPIJs1.__initData = _worklet_6834204559797_init_data;
315
+ chunkR4HJCQPIJs1.__stackDetails = _e;
316
+ return chunkR4HJCQPIJs1;
317
+ }({
318
+ _worklet_6834204559797_init_data,
319
+ shown,
320
+ opacity
321
+ }), [shown, opacity]);
322
+ return /* @__PURE__ */jsx2(Animated.View, {
323
+ pointerEvents: "none",
324
+ style: [base, animatedStyle]
325
+ });
326
+ }
327
+
328
+ // src/system/pressable-feedback/pressable-feedback-ripple.tsx
329
+ import Animated2, { useAnimatedReaction, useAnimatedStyle as useAnimatedStyle2, useSharedValue as useSharedValue2, withTiming as withTiming2 } from "react-native-reanimated";
330
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
331
+ function PressableFeedbackRipple({
332
+ style,
333
+ animation: override
334
+ }) {
335
+ const {
336
+ animation,
337
+ progress,
338
+ pressCount,
339
+ origin,
340
+ size
341
+ } = useFeedback();
342
+ const theme = useXAUITheme();
343
+ const settings = resolveSlotAnimation(override, animation.ripple, RIPPLE_OPACITY, RIPPLE_DURATION);
344
+ if (!progress || !pressCount || !origin || !size || !settings.enabled) return null;
345
+ return /* @__PURE__ */jsx3(AnimatedRipple, {
346
+ color: theme.colors.foreground,
347
+ duration: settings.duration,
348
+ opacity: settings.opacity,
349
+ style
350
+ });
351
+ }
352
+ PressableFeedbackRipple.displayName = "XAUI.PressableFeedback.Ripple";
353
+ const _worklet_2345335598483_init_data = {
354
+ code: "function chunkR4HJCQPIJs2(){const{pressCount}=this.__closure;var _pressCount$value,_pressCount;return(_pressCount$value=(_pressCount=pressCount)===null||_pressCount===void 0?void 0:_pressCount.value)!==null&&_pressCount$value!==void 0?_pressCount$value:0;}",
355
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js",
356
+ sourceMap: "{\"version\":3,\"names\":[\"chunkR4HJCQPIJs2\",\"pressCount\",\"__closure\",\"_pressCount$value\",\"_pressCount\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js\"],\"mappings\":\"AA+VI,SAAAA,gBAAMA,CAAA,QAAAC,UAAA,OAAAC,SAAA,KAAAC,iBAAA,CAAAC,WAAA,CAEJ,OAAAD,iBAAA,EAAAC,WAAA,CAAOH,UAAU,UAAAG,WAAA,iBAAVA,WAAA,CAAYC,KAAK,UAAAF,iBAAA,UAAAA,iBAAA,CAAI,CAAC,CAC/B\",\"ignoreList\":[]}"
357
+ };
358
+ const _worklet_10706360407264_init_data = {
359
+ code: "function chunkR4HJCQPIJs3(count,previous){const{useA,waveA,waveB,fromA,fromB,origin,withTiming2,duration}=this.__closure;var _origin$value,_origin;if(previous===null||count===previous)return;const wave=useA.value?waveA:waveB;const from=useA.value?fromA:fromB;from.value=(_origin$value=(_origin=origin)===null||_origin===void 0?void 0:_origin.value)!==null&&_origin$value!==void 0?_origin$value:{x:0,y:0};wave.value=0;wave.value=withTiming2(1,{duration:duration});useA.value=!useA.value;}",
360
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js",
361
+ sourceMap: "{\"version\":3,\"names\":[\"chunkR4HJCQPIJs3\",\"count\",\"previous\",\"useA\",\"waveA\",\"waveB\",\"fromA\",\"fromB\",\"origin\",\"withTiming2\",\"duration\",\"__closure\",\"_origin$value\",\"_origin\",\"wave\",\"value\",\"from\",\"x\",\"y\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js\"],\"mappings\":\"AAmWI,QAAC,CAAAA,gBAAOA,CAAQC,KAAK,CAAAC,QAAA,QAAAC,IAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,MAAA,CAAAC,WAAA,CAAAC,QAAA,OAAAC,SAAA,KAAAC,aAAA,CAAAC,OAAA,CAEnB,GAAIX,QAAQ,GAAK,IAAI,EAAID,KAAK,GAAKC,QAAQ,CAAE,OAC7C,KAAM,CAAAY,IAAI,CAAGX,IAAI,CAACY,KAAK,CAAGX,KAAK,CAAGC,KAAK,CACvC,KAAM,CAAAW,IAAI,CAAGb,IAAI,CAACY,KAAK,CAAGT,KAAK,CAAGC,KAAK,CACvCS,IAAI,CAACD,KAAK,EAAAH,aAAA,EAAAC,OAAA,CAAGL,MAAM,UAAAK,OAAA,iBAANA,OAAA,CAAQE,KAAK,UAAAH,aAAA,UAAAA,aAAA,CAAI,CAAEK,CAAC,CAAE,CAAC,CAAEC,CAAC,CAAE,CAAE,CAAC,CAC5CJ,IAAI,CAACC,KAAK,CAAG,CAAC,CACdD,IAAI,CAACC,KAAK,CAAGN,WAAW,CAAC,CAAC,CAAE,CAAEC,QAAA,CAAAA,QAAS,CAAC,CAAC,CACzCP,IAAI,CAACY,KAAK,CAAG,CAACZ,IAAI,CAACY,KAAK,CAC1B\",\"ignoreList\":[]}"
362
+ };
363
+ function AnimatedRipple({
364
+ color,
365
+ duration,
366
+ opacity,
367
+ style
368
+ }) {
369
+ const {
370
+ pressCount,
371
+ origin,
372
+ size
373
+ } = useFeedback();
374
+ const waveA = useSharedValue2(0);
375
+ const waveB = useSharedValue2(0);
376
+ const fromA = useSharedValue2({
377
+ x: 0,
378
+ y: 0
379
+ });
380
+ const fromB = useSharedValue2({
381
+ x: 0,
382
+ y: 0
383
+ });
384
+ const useA = useSharedValue2(true);
385
+ useAnimatedReaction(function chunkR4HJCQPIJs2Factory({
386
+ _worklet_2345335598483_init_data,
387
+ pressCount
388
+ }) {
389
+ const _e = [new global.Error(), -2, -27];
390
+ const chunkR4HJCQPIJs2 = function () {
391
+ return pressCount?.value ?? 0;
392
+ };
393
+ chunkR4HJCQPIJs2.__closure = {
394
+ pressCount
395
+ };
396
+ chunkR4HJCQPIJs2.__workletHash = 2345335598483;
397
+ chunkR4HJCQPIJs2.__pluginVersion = "0.7.4";
398
+ chunkR4HJCQPIJs2.__initData = _worklet_2345335598483_init_data;
399
+ chunkR4HJCQPIJs2.__stackDetails = _e;
400
+ return chunkR4HJCQPIJs2;
401
+ }({
402
+ _worklet_2345335598483_init_data,
403
+ pressCount
404
+ }), function chunkR4HJCQPIJs3Factory({
405
+ _worklet_10706360407264_init_data,
406
+ useA,
407
+ waveA,
408
+ waveB,
409
+ fromA,
410
+ fromB,
411
+ origin,
412
+ withTiming2,
413
+ duration
414
+ }) {
415
+ const _e = [new global.Error(), -9, -27];
416
+ const chunkR4HJCQPIJs3 = function (count, previous) {
417
+ if (previous === null || count === previous) return;
418
+ const wave = useA.value ? waveA : waveB;
419
+ const from = useA.value ? fromA : fromB;
420
+ from.value = origin?.value ?? {
421
+ x: 0,
422
+ y: 0
423
+ };
424
+ wave.value = 0;
425
+ wave.value = withTiming2(1, {
426
+ duration
427
+ });
428
+ useA.value = !useA.value;
429
+ };
430
+ chunkR4HJCQPIJs3.__closure = {
431
+ useA,
432
+ waveA,
433
+ waveB,
434
+ fromA,
435
+ fromB,
436
+ origin,
437
+ withTiming2,
438
+ duration
439
+ };
440
+ chunkR4HJCQPIJs3.__workletHash = 10706360407264;
441
+ chunkR4HJCQPIJs3.__pluginVersion = "0.7.4";
442
+ chunkR4HJCQPIJs3.__initData = _worklet_10706360407264_init_data;
443
+ chunkR4HJCQPIJs3.__stackDetails = _e;
444
+ return chunkR4HJCQPIJs3;
445
+ }({
446
+ _worklet_10706360407264_init_data,
447
+ useA,
448
+ waveA,
449
+ waveB,
450
+ fromA,
451
+ fromB,
452
+ origin,
453
+ withTiming2,
454
+ duration
455
+ }), [pressCount, origin, duration, waveA, waveB, fromA, fromB, useA]);
456
+ return /* @__PURE__ */jsxs(Fragment, {
457
+ children: [/* @__PURE__ */jsx3(RippleWave, {
458
+ wave: waveA,
459
+ from: fromA,
460
+ size,
461
+ color,
462
+ opacity,
463
+ style
464
+ }), /* @__PURE__ */jsx3(RippleWave, {
465
+ wave: waveB,
466
+ from: fromB,
467
+ size,
468
+ color,
469
+ opacity,
470
+ style
471
+ })]
472
+ });
473
+ }
474
+ const _worklet_4774866344303_init_data = {
475
+ code: "function chunkR4HJCQPIJs4(){const{size,RIPPLE_COVERAGE,from,progress,opacity,wave}=this.__closure;var _size$value,_size,_progress$value,_progress;const within=(_size$value=(_size=size)===null||_size===void 0?void 0:_size.value)!==null&&_size$value!==void 0?_size$value:{width:0,height:0};const radius=Math.sqrt(within.width*within.width+within.height*within.height)*RIPPLE_COVERAGE;const at=from.value;return{width:radius*2,height:radius*2,borderRadius:radius,opacity:((_progress$value=(_progress=progress)===null||_progress===void 0?void 0:_progress.value)!==null&&_progress$value!==void 0?_progress$value:0)*opacity,transform:[{translateX:at.x-radius},{translateY:at.y-radius},{scale:wave.value}]};}",
476
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js",
477
+ sourceMap: "{\"version\":3,\"names\":[\"chunkR4HJCQPIJs4\",\"size\",\"RIPPLE_COVERAGE\",\"from\",\"progress\",\"opacity\",\"wave\",\"__closure\",\"_size$value\",\"_size\",\"_progress$value\",\"_progress\",\"within\",\"value\",\"width\",\"height\",\"radius\",\"Math\",\"sqrt\",\"at\",\"borderRadius\",\"transform\",\"translateX\",\"x\",\"translateY\",\"y\",\"scale\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js\"],\"mappings\":\"AAiZ0C,SAAAA,gBAAMA,CAAA,QAAAC,IAAA,CAAAC,eAAA,CAAAC,IAAA,CAAAC,QAAA,CAAAC,OAAA,CAAAC,IAAA,OAAAC,SAAA,KAAAC,WAAA,CAAAC,KAAA,CAAAC,eAAA,CAAAC,SAAA,CAE5C,KAAM,CAAAC,MAAM,EAAAJ,WAAA,EAAAC,KAAA,CAAGR,IAAI,UAAAQ,KAAA,iBAAJA,KAAA,CAAMI,KAAK,UAAAL,WAAA,UAAAA,WAAA,CAAI,CAAEM,KAAK,CAAE,CAAC,CAAEC,MAAM,CAAE,CAAE,CAAC,CACrD,KAAM,CAAAC,MAAM,CAAGC,IAAI,CAACC,IAAI,CAACN,MAAM,CAACE,KAAK,CAAGF,MAAM,CAACE,KAAK,CAAGF,MAAM,CAACG,MAAM,CAAGH,MAAM,CAACG,MAAM,CAAC,CAAGb,eAAe,CACvG,KAAM,CAAAiB,EAAE,CAAGhB,IAAI,CAACU,KAAK,CACrB,MAAO,CACLC,KAAK,CAAEE,MAAM,CAAG,CAAC,CACjBD,MAAM,CAAEC,MAAM,CAAG,CAAC,CAClBI,YAAY,CAAEJ,MAAM,CAGpBX,OAAO,CAAE,EAAAK,eAAA,EAAAC,SAAA,CAACP,QAAQ,UAAAO,SAAA,iBAARA,SAAA,CAAUE,KAAK,UAAAH,eAAA,UAAAA,eAAA,CAAI,CAAC,EAAIL,OAAO,CACzCgB,SAAS,CAAE,CACT,CAAEC,UAAU,CAAEH,EAAE,CAACI,CAAC,CAAGP,MAAO,CAAC,CAC7B,CAAEQ,UAAU,CAAEL,EAAE,CAACM,CAAC,CAAGT,MAAO,CAAC,CAC7B,CAAEU,KAAK,CAAEpB,IAAI,CAACO,KAAM,CAAC,CAEzB,CAAC,CACH\",\"ignoreList\":[]}"
478
+ };
479
+ function RippleWave({
480
+ wave,
481
+ from,
482
+ size,
483
+ color,
484
+ opacity,
485
+ style
486
+ }) {
487
+ const {
488
+ progress
489
+ } = useFeedback();
490
+ const animatedStyle = useAnimatedStyle2(function chunkR4HJCQPIJs4Factory({
491
+ _worklet_4774866344303_init_data,
492
+ size,
493
+ RIPPLE_COVERAGE,
494
+ from,
495
+ progress,
496
+ opacity,
497
+ wave
498
+ }) {
499
+ const _e = [new global.Error(), -7, -27];
500
+ const chunkR4HJCQPIJs4 = function () {
501
+ const within = size?.value ?? {
502
+ width: 0,
503
+ height: 0
504
+ };
505
+ const radius = Math.sqrt(within.width * within.width + within.height * within.height) * RIPPLE_COVERAGE;
506
+ const at = from.value;
507
+ return {
508
+ width: radius * 2,
509
+ height: radius * 2,
510
+ borderRadius: radius,
511
+ // The press, not the expansion. The wave is at full strength the instant it is
512
+ // touched, stays while the finger stays, and drains when it lifts.
513
+ opacity: (progress?.value ?? 0) * opacity,
514
+ transform: [{
515
+ translateX: at.x - radius
516
+ }, {
517
+ translateY: at.y - radius
518
+ }, {
519
+ scale: wave.value
520
+ }]
521
+ };
522
+ };
523
+ chunkR4HJCQPIJs4.__closure = {
524
+ size,
525
+ RIPPLE_COVERAGE,
526
+ from,
527
+ progress,
528
+ opacity,
529
+ wave
530
+ };
531
+ chunkR4HJCQPIJs4.__workletHash = 4774866344303;
532
+ chunkR4HJCQPIJs4.__pluginVersion = "0.7.4";
533
+ chunkR4HJCQPIJs4.__initData = _worklet_4774866344303_init_data;
534
+ chunkR4HJCQPIJs4.__stackDetails = _e;
535
+ return chunkR4HJCQPIJs4;
536
+ }({
537
+ _worklet_4774866344303_init_data,
538
+ size,
539
+ RIPPLE_COVERAGE,
540
+ from,
541
+ progress,
542
+ opacity,
543
+ wave
544
+ }), [wave, from, size, opacity, progress]);
545
+ return /* @__PURE__ */jsx3(Animated2.View, {
546
+ pointerEvents: "none",
547
+ style: [{
548
+ position: "absolute",
549
+ backgroundColor: color
550
+ }, animatedStyle, style]
551
+ });
552
+ }
553
+
554
+ // src/system/pressable-feedback/pressable-feedback.tsx
555
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
556
+ var AnimatedPressable = Animated3.createAnimatedComponent(Pressable);
557
+ var AnimatedSlot = Animated3.createAnimatedComponent(Slot);
558
+ var PressableFeedback = forwardRef2(function PressableFeedback2({
559
+ animation,
560
+ feedbackVariant = "scale-highlight",
561
+ ...rest
562
+ }, ref) {
563
+ const inheritedDisableAll = useContext3(DisableAllContext);
564
+ const resolved = resolveAnimation(animation, inheritedDisableAll);
565
+ const Feedback = resolved.none || feedbackVariant === "none" ? StaticFeedback : AnimatedFeedback;
566
+ const body2 = /* @__PURE__ */jsx4(Feedback, {
567
+ ref,
568
+ animation: resolved,
569
+ feedbackVariant,
570
+ ...rest
571
+ });
572
+ return resolved.disableAll ? /* @__PURE__ */jsx4(DisableAllContext.Provider, {
573
+ value: true,
574
+ children: body2
575
+ }) : body2;
576
+ });
577
+ var StaticFeedback = forwardRef2(function StaticFeedback2({
578
+ isPressed = false,
579
+ isDisabled,
580
+ asChild = false,
581
+ animation,
582
+ feedbackVariant,
583
+ children,
584
+ style,
585
+ ...rest
586
+ }, ref) {
587
+ const context = useMemo(() => ({
588
+ isPressed,
589
+ animation
590
+ }), [isPressed, animation]);
591
+ const Root = asChild ? Slot : Pressable;
592
+ return /* @__PURE__ */jsx4(FeedbackProvider, {
593
+ value: context,
594
+ children: /* @__PURE__ */jsx4(Root, {
595
+ ref,
596
+ style: [clipFor(feedbackVariant, asChild), style],
597
+ disabled: isDisabled,
598
+ ...rest,
599
+ children: body(asChild, feedbackVariant, children)
600
+ })
601
+ });
602
+ });
603
+ const _worklet_6138658545541_init_data = {
604
+ code: "function chunkR4HJCQPIJs5(){const{animation,PRESS_SCALE,progress}=this.__closure;if(!animation.scale)return{};return{transform:[{scale:1-(1-PRESS_SCALE)*progress.value}]};}",
605
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js",
606
+ sourceMap: "{\"version\":3,\"names\":[\"chunkR4HJCQPIJs5\",\"animation\",\"PRESS_SCALE\",\"progress\",\"__closure\",\"scale\",\"transform\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-R4HJCQPI.js\"],\"mappings\":\"AAkf0C,SAAAA,gBAAMA,CAAA,QAAAC,SAAA,CAAAC,WAAA,CAAAC,QAAA,OAAAC,SAAA,CAE5C,GAAI,CAACH,SAAS,CAACI,KAAK,CAAE,MAAO,CAAC,CAAC,CAC/B,MAAO,CAAEC,SAAS,CAAE,CAAC,CAAED,KAAK,CAAE,CAAC,CAAG,CAAC,CAAC,CAAGH,WAAW,EAAIC,QAAQ,CAACI,KAAM,CAAC,CAAE,CAAC,CAC3E\",\"ignoreList\":[]}"
607
+ };
608
+ var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
609
+ isPressed = false,
610
+ isDisabled,
611
+ asChild = false,
612
+ animation,
613
+ feedbackVariant,
614
+ children,
615
+ style,
616
+ onPressIn,
617
+ onLayout,
618
+ ...rest
619
+ }, ref) {
620
+ const progress = useSharedValue3(0);
621
+ const pressCount = useSharedValue3(0);
622
+ const origin = useSharedValue3({
623
+ x: 0,
624
+ y: 0
625
+ });
626
+ const size = useSharedValue3({
627
+ width: 0,
628
+ height: 0
629
+ });
630
+ useEffect2(() => {
631
+ progress.value = withTiming3(isPressed ? 1 : 0, {
632
+ duration: isPressed ? PRESS_DURATION : RELEASE_DURATION
633
+ });
634
+ }, [isPressed, progress]);
635
+ const animatedStyle = useAnimatedStyle3(function chunkR4HJCQPIJs5Factory({
636
+ _worklet_6138658545541_init_data,
637
+ animation,
638
+ PRESS_SCALE,
639
+ progress
640
+ }) {
641
+ const _e = [new global.Error(), -4, -27];
642
+ const chunkR4HJCQPIJs5 = function () {
643
+ if (!animation.scale) return {};
644
+ return {
645
+ transform: [{
646
+ scale: 1 - (1 - PRESS_SCALE) * progress.value
647
+ }]
648
+ };
649
+ };
650
+ chunkR4HJCQPIJs5.__closure = {
651
+ animation,
652
+ PRESS_SCALE,
653
+ progress
654
+ };
655
+ chunkR4HJCQPIJs5.__workletHash = 6138658545541;
656
+ chunkR4HJCQPIJs5.__pluginVersion = "0.7.4";
657
+ chunkR4HJCQPIJs5.__initData = _worklet_6138658545541_init_data;
658
+ chunkR4HJCQPIJs5.__stackDetails = _e;
659
+ return chunkR4HJCQPIJs5;
660
+ }({
661
+ _worklet_6138658545541_init_data,
662
+ animation,
663
+ PRESS_SCALE,
664
+ progress
665
+ }), [animation.scale, progress]);
666
+ const context = useMemo(() => ({
667
+ isPressed,
668
+ animation,
669
+ progress,
670
+ pressCount,
671
+ origin,
672
+ size
673
+ }), [isPressed, animation, progress, pressCount, origin, size]);
674
+ const handlePressIn = event => {
675
+ const {
676
+ locationX,
677
+ locationY
678
+ } = event.nativeEvent;
679
+ origin.value = {
680
+ x: locationX,
681
+ y: locationY
682
+ };
683
+ pressCount.value += 1;
684
+ onPressIn?.(event);
685
+ };
686
+ const handleLayout = event => {
687
+ const {
688
+ width,
689
+ height
690
+ } = event.nativeEvent.layout;
691
+ size.value = {
692
+ width,
693
+ height
694
+ };
695
+ onLayout?.(event);
696
+ };
697
+ const Root = asChild ? AnimatedSlot : AnimatedPressable;
698
+ return /* @__PURE__ */jsx4(FeedbackProvider, {
699
+ value: context,
700
+ children: /* @__PURE__ */jsx4(Root, {
701
+ ref,
702
+ style: [clipFor(feedbackVariant, asChild), style, animatedStyle],
703
+ disabled: isDisabled,
704
+ onPressIn: handlePressIn,
705
+ onLayout: handleLayout,
706
+ ...rest,
707
+ children: body(asChild, feedbackVariant, children)
708
+ })
709
+ });
710
+ });
711
+ function body(asChild, variant, children) {
712
+ if (asChild) return children;
713
+ return /* @__PURE__ */jsxs2(Fragment2, {
714
+ children: [/* @__PURE__ */jsx4(DefaultOverlay, {
715
+ variant
716
+ }), children]
717
+ });
718
+ }
719
+ var OVERLAY_CLIP = {
720
+ overflow: "hidden"
721
+ };
722
+ function clipFor(variant, asChild) {
723
+ if (asChild) return null;
724
+ const mountsOverlay = variant === "scale-highlight" || variant === "scale-ripple";
725
+ return mountsOverlay ? OVERLAY_CLIP : null;
726
+ }
727
+ function DefaultOverlay({
728
+ variant
729
+ }) {
730
+ if (variant === "scale-highlight") return /* @__PURE__ */jsx4(PressableFeedbackHighlight, {});
731
+ if (variant === "scale-ripple") return /* @__PURE__ */jsx4(PressableFeedbackRipple, {});
732
+ return null;
733
+ }
734
+
735
+ // src/system/pressable-feedback/index.ts
736
+ var PressableFeedback3 = Object.assign(PressableFeedback, {
737
+ Highlight: PressableFeedbackHighlight,
738
+ Ripple: PressableFeedbackRipple
739
+ });
740
+
741
+ // src/system/recipe/resolve-tint.ts
742
+ var TINT_SLICE_BY_SUFFIX = [[/SoftForeground$/, "softForeground"], [/SoftPressed$/, "softPressed"], [/Soft$/, "soft"], [/Foreground$/, "foreground"], [/Pressed$/, "pressed"]];
743
+ function tintSliceFor(token) {
744
+ for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
745
+ if (suffix.test(token)) return slice;
746
+ }
747
+ return "base";
748
+ }
749
+ function resolveTint(tokens, color, theme) {
750
+ const tint = deriveTint(color, theme);
751
+ const colors = {};
752
+ for (const [role, token] of Object.entries(tokens ?? {})) {
753
+ colors[role] = tint[tintSliceFor(token)];
754
+ }
755
+ return colors;
756
+ }
757
+
758
+ // src/system/recipe/style-cache.ts
759
+ import { StyleSheet as StyleSheet2 } from "react-native";
760
+
761
+ // src/system/recipe/variant-map.ts
762
+ var STATE_ORDER = ["focused", "pressed", "disabled"];
763
+ function resolveSelection(defaultVariants, selection) {
764
+ const resolved = {
765
+ ...defaultVariants
766
+ };
767
+ for (const [axis, value] of Object.entries(selection ?? {})) {
768
+ if (value !== void 0) resolved[axis] = value;
769
+ }
770
+ return resolved;
771
+ }
772
+ function resolveVariantColors(tokens, theme) {
773
+ const colors = {};
774
+ for (const [role, token] of entriesOf(tokens)) {
775
+ const value = theme.colors[token];
776
+ if (value === void 0) {
777
+ throw new Error(`XAUI: the recipe names "${token}" for its "${role}" role, but the theme has no such colour token. Check the spelling against XAUIColors.`);
778
+ }
779
+ colors[role] = value;
780
+ }
781
+ return colors;
782
+ }
783
+ function activeStateFns(states, active) {
784
+ const fns = [];
785
+ for (const state of STATE_ORDER) {
786
+ const fn = active[state] ? states?.[state] : void 0;
787
+ if (fn) fns.push(fn);
788
+ }
789
+ return fns;
790
+ }
791
+ function collectStyleFns(config, selection, states) {
792
+ const fns = [];
793
+ if (config.base) fns.push(config.base);
794
+ if (config.paint) fns.push(config.paint);
795
+ for (const [axis, values] of Object.entries(config.variants ?? {})) {
796
+ const value = selection[axis];
797
+ const fn = value === void 0 ? void 0 : values[value];
798
+ if (fn) fns.push(fn);
799
+ }
800
+ for (const compound of config.compoundVariants ?? []) {
801
+ if (appliesTo(compound.when, selection)) fns.push(compound.style);
802
+ }
803
+ return [...fns, ...activeStateFns(config.states, states)];
804
+ }
805
+ function appliesTo(when, selection) {
806
+ return Object.entries(when).every(([axis, value]) => selection[axis] === value);
807
+ }
808
+ function entriesOf(tokens) {
809
+ return Object.entries(tokens ?? {});
810
+ }
811
+
812
+ // src/system/recipe/style-cache.ts
813
+ function createStyleCache(slots) {
814
+ const entries = /* @__PURE__ */new Map();
815
+ return {
816
+ read(key, build) {
817
+ const hit = entries.get(key);
818
+ if (hit) return hit;
819
+ const built = build();
820
+ const complete = {};
821
+ for (const slot of slots) complete[slot] = built[slot] ?? {};
822
+ const created = StyleSheet2.create(complete);
823
+ entries.set(key, created);
824
+ return created;
825
+ },
826
+ get size() {
827
+ return entries.size;
828
+ },
829
+ clear() {
830
+ entries.clear();
831
+ }
832
+ };
833
+ }
834
+ function cacheKey(theme, selection, states) {
835
+ const axes = Object.keys(selection).sort().map(axis => `${axis}:${selection[axis] ?? "-"}`).join("|");
836
+ const active = STATE_ORDER.filter(state => states[state]).join(",");
837
+ return `${theme.id}|${theme.mode}|${axes}|${active}`;
838
+ }
839
+
840
+ // src/system/recipe/create-recipe.ts
841
+ function createRecipe(config) {
842
+ const cache = createStyleCache(config.slots);
843
+ const tokensFor = variant => variant === void 0 ? void 0 : config.variantTokens?.[variant];
844
+ return {
845
+ slots: config.slots,
846
+ resolve({
847
+ theme,
848
+ selection,
849
+ states = {}
850
+ }) {
851
+ const resolved = resolveSelection(config.defaultVariants, selection);
852
+ return cache.read(cacheKey(theme, resolved, states), () => {
853
+ const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
854
+ return apply(collectStyleFns(config, resolved, states), theme, colors);
855
+ });
856
+ },
857
+ tint({
858
+ theme,
859
+ color,
860
+ selection,
861
+ states = {}
862
+ }) {
863
+ if (!config.paint) return {};
864
+ const resolved = resolveSelection(config.defaultVariants, selection);
865
+ const tokens = tokensFor(resolved.variant);
866
+ if (!tokens) return {};
867
+ const colors = resolveTint(tokens, color, theme);
868
+ const fns = [config.paint, ...activeStateFns(config.states, states)];
869
+ return apply(fns, theme, colors);
870
+ }
871
+ };
872
+ }
873
+ function apply(fns, theme, colors) {
874
+ const merged = {};
875
+ for (const fn of fns) {
876
+ const produced = fn(theme, colors);
877
+ for (const slot of Object.keys(produced)) {
878
+ const style = produced[slot];
879
+ if (!style) continue;
880
+ const previous = merged[slot];
881
+ merged[slot] = previous ? {
882
+ ...previous,
883
+ ...style
884
+ } : style;
885
+ }
886
+ }
887
+ return merged;
888
+ }
889
+ export { IconContext, useIconContext, Icon, childrenToString, createSlotContext, mergeRefs, mergeProps, Slot, useFeedback, PRESS_SCALE, PRESS_DURATION, RELEASE_DURATION, HIGHLIGHT_OPACITY, RIPPLE_OPACITY, RIPPLE_DURATION, RIPPLE_COVERAGE, resolveAnimation, resolveSlotAnimation, PressableFeedback3 as PressableFeedback, createRecipe };