@xaui/native 0.9.1-alpha.8 → 0.9.1-alpha.9
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-AW63PTQ4.cjs → chunk-2FEDC7U5.cjs} +2 -1
- package/dist/chunk-3TIDEII6.js +57 -0
- package/dist/{chunk-2KXQATVL.js → chunk-7XGOXTGT.js} +2 -1
- package/dist/chunk-LMUPNKPH.cjs +57 -0
- package/dist/chunk-PBRPIZZ2.js +350 -0
- package/dist/{chunk-NUF3UUTE.js → chunk-U3C6VN4X.js} +187 -233
- package/dist/chunk-V42SPPP3.cjs +350 -0
- package/dist/{chunk-OS5ABUCG.cjs → chunk-VGWN4JTL.cjs} +178 -224
- package/dist/components/button/index.cjs +12 -0
- package/dist/components/button/index.d.cts +192 -0
- package/dist/components/button/index.d.ts +192 -0
- package/dist/components/button/index.js +12 -0
- package/dist/create-recipe-BjxSp9_k.d.cts +197 -0
- package/dist/create-recipe-M99yoHrG.d.ts +197 -0
- package/dist/index.cjs +17 -31
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +19 -33
- package/dist/system/index.cjs +4 -2
- package/dist/system/index.d.cts +54 -243
- package/dist/system/index.d.ts +54 -243
- package/dist/system/index.js +6 -4
- package/dist/theme/index.cjs +2 -2
- package/dist/theme/index.js +1 -1
- package/package.json +6 -1
|
@@ -3,10 +3,6 @@ import {
|
|
|
3
3
|
useXAUITheme
|
|
4
4
|
} from "./chunk-X2K2FX3W.js";
|
|
5
5
|
|
|
6
|
-
// src/system/icon/icon.tsx
|
|
7
|
-
import { cloneElement, isValidElement } from "react";
|
|
8
|
-
import { Image } from "react-native";
|
|
9
|
-
|
|
10
6
|
// src/system/icon/icon-context.ts
|
|
11
7
|
import { createContext, useContext } from "react";
|
|
12
8
|
var IconContext = createContext({});
|
|
@@ -16,6 +12,9 @@ function useIconContext() {
|
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
// src/system/icon/icon.tsx
|
|
15
|
+
import { cloneElement, isValidElement } from "react";
|
|
16
|
+
import { Image } from "react-native";
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
18
|
function Icon({
|
|
20
19
|
as: Component,
|
|
21
20
|
children,
|
|
@@ -29,7 +28,7 @@ function Icon({
|
|
|
29
28
|
const resolvedSize = size ?? inherited.size ?? theme.fontSizes.md;
|
|
30
29
|
const resolvedColor = color ?? inherited.color ?? theme.colors.foreground;
|
|
31
30
|
if (Component) {
|
|
32
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ jsx(Component, { size: resolvedSize, color: resolvedColor });
|
|
33
32
|
}
|
|
34
33
|
if (isValidElement(children)) {
|
|
35
34
|
return cloneElement(children, {
|
|
@@ -39,7 +38,7 @@ function Icon({
|
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
40
|
if (source) {
|
|
42
|
-
return /* @__PURE__ */
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
43
42
|
Image,
|
|
44
43
|
{
|
|
45
44
|
source,
|
|
@@ -56,73 +55,36 @@ function Icon({
|
|
|
56
55
|
}
|
|
57
56
|
Icon.displayName = "XAUI.Icon";
|
|
58
57
|
|
|
59
|
-
// src/system/
|
|
60
|
-
import {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var PortalContext = createContext2(null);
|
|
65
|
-
|
|
66
|
-
// src/system/portal/portal.tsx
|
|
67
|
-
function Portal({ children }) {
|
|
68
|
-
const context = useContext2(PortalContext);
|
|
69
|
-
const key = useId();
|
|
70
|
-
useLayoutEffect(() => {
|
|
71
|
-
context?.addPortal(key, children);
|
|
72
|
-
}, [children, context, key]);
|
|
73
|
-
useLayoutEffect(() => {
|
|
74
|
-
return () => context?.removePortal(key);
|
|
75
|
-
}, [context, key]);
|
|
76
|
-
return null;
|
|
58
|
+
// src/system/slot/children-to-string.ts
|
|
59
|
+
import { isValidElement as isValidElement2 } from "react";
|
|
60
|
+
function childrenToString(children) {
|
|
61
|
+
const text = stringify(children);
|
|
62
|
+
return text === null || text === "" ? null : text;
|
|
77
63
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!current.has(key)) return current;
|
|
94
|
-
const next = new Map(current);
|
|
95
|
-
next.delete(key);
|
|
96
|
-
return next;
|
|
97
|
-
});
|
|
98
|
-
}, []);
|
|
99
|
-
const methods = useMemo(
|
|
100
|
-
() => ({ addPortal, removePortal }),
|
|
101
|
-
[addPortal, removePortal]
|
|
102
|
-
);
|
|
103
|
-
return /* @__PURE__ */ React.createElement(PortalContext.Provider, { value: methods }, /* @__PURE__ */ React.createElement(View, { style: styles.container }, children, Array.from(portals, ([key, element]) => /* @__PURE__ */ React.createElement(Fragment, { key }, element))));
|
|
64
|
+
function stringify(node) {
|
|
65
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
66
|
+
if (typeof node === "string") return node;
|
|
67
|
+
if (typeof node === "number") return String(node);
|
|
68
|
+
if (isValidElement2(node)) return null;
|
|
69
|
+
if (Array.isArray(node)) {
|
|
70
|
+
let text = "";
|
|
71
|
+
for (const child of node) {
|
|
72
|
+
const part = stringify(child);
|
|
73
|
+
if (part === null) return null;
|
|
74
|
+
text += part;
|
|
75
|
+
}
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
104
79
|
}
|
|
105
|
-
PortalHost.displayName = "XAUI.PortalHost";
|
|
106
|
-
|
|
107
|
-
// src/system/pressable-feedback/pressable-feedback.tsx
|
|
108
|
-
import { forwardRef as forwardRef2, useContext as useContext4, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
109
|
-
import { Pressable } from "react-native";
|
|
110
|
-
import Animated3, {
|
|
111
|
-
useAnimatedStyle as useAnimatedStyle3,
|
|
112
|
-
useSharedValue as useSharedValue3,
|
|
113
|
-
withTiming as withTiming3
|
|
114
|
-
} from "react-native-reanimated";
|
|
115
|
-
|
|
116
|
-
// src/system/pressable-feedback/pressable-feedback-context.ts
|
|
117
|
-
import { createContext as createContext4 } from "react";
|
|
118
80
|
|
|
119
81
|
// src/system/slot/create-slot-context.ts
|
|
120
|
-
import { createContext as
|
|
82
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
121
83
|
function createSlotContext(name) {
|
|
122
|
-
const Context =
|
|
84
|
+
const Context = createContext2(null);
|
|
123
85
|
Context.displayName = `XAUI.${name}.Context`;
|
|
124
86
|
function useSlotContext() {
|
|
125
|
-
const value =
|
|
87
|
+
const value = useContext2(Context);
|
|
126
88
|
if (value === null) {
|
|
127
89
|
const error = new Error(
|
|
128
90
|
`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.`
|
|
@@ -138,18 +100,84 @@ function createSlotContext(name) {
|
|
|
138
100
|
return [Context.Provider, useSlotContext];
|
|
139
101
|
}
|
|
140
102
|
|
|
103
|
+
// src/system/slot/merge-refs.ts
|
|
104
|
+
function mergeRefs(...refs) {
|
|
105
|
+
return (value) => {
|
|
106
|
+
for (const ref of refs) {
|
|
107
|
+
if (typeof ref === "function") ref(value);
|
|
108
|
+
else if (ref) ref.current = value;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/system/slot/merge-props.ts
|
|
114
|
+
var EVENT_HANDLER = /^on[A-Z]/;
|
|
115
|
+
function mergeProps(ours, theirs) {
|
|
116
|
+
const merged = { ...ours };
|
|
117
|
+
for (const key of Object.keys(theirs)) {
|
|
118
|
+
const ourValue = ours[key];
|
|
119
|
+
const theirValue = theirs[key];
|
|
120
|
+
if (EVENT_HANDLER.test(key)) {
|
|
121
|
+
merged[key] = composeHandlers(ourValue, theirValue);
|
|
122
|
+
} else if (key === "style") {
|
|
123
|
+
merged[key] = mergeStyles(ourValue, theirValue);
|
|
124
|
+
} else if (key === "ref") {
|
|
125
|
+
merged[key] = mergeRefs(
|
|
126
|
+
ourValue,
|
|
127
|
+
theirValue
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
merged[key] = theirValue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return merged;
|
|
134
|
+
}
|
|
135
|
+
function composeHandlers(ours, theirs) {
|
|
136
|
+
if (typeof ours !== "function") return theirs;
|
|
137
|
+
if (typeof theirs !== "function") return ours;
|
|
138
|
+
return (...args) => {
|
|
139
|
+
;
|
|
140
|
+
ours(...args);
|
|
141
|
+
return theirs(...args);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function mergeStyles(ours, theirs) {
|
|
145
|
+
if (typeof ours === "function" || typeof theirs === "function") {
|
|
146
|
+
return (state) => [
|
|
147
|
+
resolveStyle(ours, state),
|
|
148
|
+
resolveStyle(theirs, state)
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
return [ours, theirs];
|
|
152
|
+
}
|
|
153
|
+
function resolveStyle(style, state) {
|
|
154
|
+
return typeof style === "function" ? style(state) : style;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/system/slot/slot.tsx
|
|
158
|
+
import { cloneElement as cloneElement2, forwardRef, isValidElement as isValidElement3 } from "react";
|
|
159
|
+
var Slot = forwardRef(function Slot2({ children, ...ours }, ref) {
|
|
160
|
+
if (!isValidElement3(children)) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
"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."
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
const child = children;
|
|
166
|
+
const merged = mergeProps(ours, child.props);
|
|
167
|
+
merged.ref = mergeRefs(ref, refOf(child));
|
|
168
|
+
return cloneElement2(child, merged);
|
|
169
|
+
});
|
|
170
|
+
Slot.displayName = "XAUI.Slot";
|
|
171
|
+
function refOf(element) {
|
|
172
|
+
const fromProps = element.props.ref;
|
|
173
|
+
const fromElement = element.ref;
|
|
174
|
+
return fromProps ?? fromElement;
|
|
175
|
+
}
|
|
176
|
+
|
|
141
177
|
// src/system/pressable-feedback/pressable-feedback-context.ts
|
|
178
|
+
import { createContext as createContext3 } from "react";
|
|
142
179
|
var [FeedbackProvider, useFeedback] = createSlotContext("PressableFeedback");
|
|
143
|
-
var DisableAllContext =
|
|
144
|
-
|
|
145
|
-
// src/system/pressable-feedback/pressable-feedback-highlight.tsx
|
|
146
|
-
import { useEffect } from "react";
|
|
147
|
-
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
148
|
-
import Animated, {
|
|
149
|
-
useAnimatedStyle,
|
|
150
|
-
useSharedValue,
|
|
151
|
-
withTiming
|
|
152
|
-
} from "react-native-reanimated";
|
|
180
|
+
var DisableAllContext = createContext3(false);
|
|
153
181
|
|
|
154
182
|
// src/system/pressable-feedback/pressable-feedback.animation.ts
|
|
155
183
|
var PRESS_SCALE = 0.975;
|
|
@@ -206,7 +234,24 @@ function resolveSlotAnimation(override, enabledByRoot, defaultOpacity, defaultDu
|
|
|
206
234
|
};
|
|
207
235
|
}
|
|
208
236
|
|
|
237
|
+
// src/system/pressable-feedback/pressable-feedback.tsx
|
|
238
|
+
import { forwardRef as forwardRef2, useContext as useContext3, useEffect as useEffect2, useMemo } from "react";
|
|
239
|
+
import { Pressable } from "react-native";
|
|
240
|
+
import Animated3, {
|
|
241
|
+
useAnimatedStyle as useAnimatedStyle3,
|
|
242
|
+
useSharedValue as useSharedValue3,
|
|
243
|
+
withTiming as withTiming3
|
|
244
|
+
} from "react-native-reanimated";
|
|
245
|
+
|
|
209
246
|
// src/system/pressable-feedback/pressable-feedback-highlight.tsx
|
|
247
|
+
import { useEffect } from "react";
|
|
248
|
+
import { StyleSheet, View } from "react-native";
|
|
249
|
+
import Animated, {
|
|
250
|
+
useAnimatedStyle,
|
|
251
|
+
useSharedValue,
|
|
252
|
+
withTiming
|
|
253
|
+
} from "react-native-reanimated";
|
|
254
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
210
255
|
function PressableFeedbackHighlight({
|
|
211
256
|
style,
|
|
212
257
|
animation: override
|
|
@@ -219,20 +264,20 @@ function PressableFeedbackHighlight({
|
|
|
219
264
|
HIGHLIGHT_OPACITY
|
|
220
265
|
);
|
|
221
266
|
const base = [
|
|
222
|
-
|
|
267
|
+
StyleSheet.absoluteFillObject,
|
|
223
268
|
{ backgroundColor: theme.colors.foreground },
|
|
224
269
|
style
|
|
225
270
|
];
|
|
226
271
|
if (!progress || !settings.enabled) {
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
|
|
272
|
+
return /* @__PURE__ */ jsx2(
|
|
273
|
+
View,
|
|
229
274
|
{
|
|
230
275
|
pointerEvents: "none",
|
|
231
276
|
style: [base, { opacity: isPressed ? settings.opacity : 0 }]
|
|
232
277
|
}
|
|
233
278
|
);
|
|
234
279
|
}
|
|
235
|
-
return /* @__PURE__ */
|
|
280
|
+
return /* @__PURE__ */ jsx2(
|
|
236
281
|
AnimatedHighlight,
|
|
237
282
|
{
|
|
238
283
|
base,
|
|
@@ -252,10 +297,11 @@ function AnimatedHighlight({
|
|
|
252
297
|
useEffect(() => {
|
|
253
298
|
shown.value = withTiming(isPressed ? 1 : 0, { duration });
|
|
254
299
|
}, [isPressed, shown, duration]);
|
|
255
|
-
const animatedStyle = useAnimatedStyle(
|
|
256
|
-
opacity: shown.value * opacity
|
|
257
|
-
|
|
258
|
-
|
|
300
|
+
const animatedStyle = useAnimatedStyle(
|
|
301
|
+
() => ({ opacity: shown.value * opacity }),
|
|
302
|
+
[shown, opacity]
|
|
303
|
+
);
|
|
304
|
+
return /* @__PURE__ */ jsx2(Animated.View, { pointerEvents: "none", style: [base, animatedStyle] });
|
|
259
305
|
}
|
|
260
306
|
|
|
261
307
|
// src/system/pressable-feedback/pressable-feedback-ripple.tsx
|
|
@@ -266,6 +312,7 @@ import Animated2, {
|
|
|
266
312
|
useSharedValue as useSharedValue2,
|
|
267
313
|
withTiming as withTiming2
|
|
268
314
|
} from "react-native-reanimated";
|
|
315
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
269
316
|
function PressableFeedbackRipple({
|
|
270
317
|
style,
|
|
271
318
|
animation: override
|
|
@@ -279,7 +326,7 @@ function PressableFeedbackRipple({
|
|
|
279
326
|
RIPPLE_DURATION
|
|
280
327
|
);
|
|
281
328
|
if (!progress || !pressCount || !origin || !size || !settings.enabled) return null;
|
|
282
|
-
return /* @__PURE__ */
|
|
329
|
+
return /* @__PURE__ */ jsx3(
|
|
283
330
|
AnimatedRipple,
|
|
284
331
|
{
|
|
285
332
|
color: theme.colors.foreground,
|
|
@@ -312,29 +359,33 @@ function AnimatedRipple({
|
|
|
312
359
|
wave.value = 0;
|
|
313
360
|
wave.value = withTiming2(2, { duration: duration * 2 });
|
|
314
361
|
useA.value = !useA.value;
|
|
315
|
-
}
|
|
362
|
+
},
|
|
363
|
+
[pressCount, origin, duration, waveA, waveB, fromA, fromB, useA]
|
|
316
364
|
);
|
|
317
|
-
return /* @__PURE__ */
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
365
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
366
|
+
/* @__PURE__ */ jsx3(
|
|
367
|
+
RippleWave,
|
|
368
|
+
{
|
|
369
|
+
wave: waveA,
|
|
370
|
+
from: fromA,
|
|
371
|
+
size,
|
|
372
|
+
color,
|
|
373
|
+
opacity,
|
|
374
|
+
style
|
|
375
|
+
}
|
|
376
|
+
),
|
|
377
|
+
/* @__PURE__ */ jsx3(
|
|
378
|
+
RippleWave,
|
|
379
|
+
{
|
|
380
|
+
wave: waveB,
|
|
381
|
+
from: fromB,
|
|
382
|
+
size,
|
|
383
|
+
color,
|
|
384
|
+
opacity,
|
|
385
|
+
style
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
] });
|
|
338
389
|
}
|
|
339
390
|
function RippleWave({
|
|
340
391
|
wave,
|
|
@@ -361,8 +412,8 @@ function RippleWave({
|
|
|
361
412
|
{ scale: interpolate(wave.value, [0, 1, 2], [0, 1, 1]) }
|
|
362
413
|
]
|
|
363
414
|
};
|
|
364
|
-
});
|
|
365
|
-
return /* @__PURE__ */
|
|
415
|
+
}, [wave, from, size, opacity]);
|
|
416
|
+
return /* @__PURE__ */ jsx3(
|
|
366
417
|
Animated2.View,
|
|
367
418
|
{
|
|
368
419
|
pointerEvents: "none",
|
|
@@ -375,91 +426,16 @@ function RippleWave({
|
|
|
375
426
|
);
|
|
376
427
|
}
|
|
377
428
|
|
|
378
|
-
// src/system/slot/slot.tsx
|
|
379
|
-
import { cloneElement as cloneElement2, forwardRef, isValidElement as isValidElement2 } from "react";
|
|
380
|
-
|
|
381
|
-
// src/system/slot/merge-refs.ts
|
|
382
|
-
function mergeRefs(...refs) {
|
|
383
|
-
return (value) => {
|
|
384
|
-
for (const ref of refs) {
|
|
385
|
-
if (typeof ref === "function") ref(value);
|
|
386
|
-
else if (ref) ref.current = value;
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// src/system/slot/merge-props.ts
|
|
392
|
-
var EVENT_HANDLER = /^on[A-Z]/;
|
|
393
|
-
function mergeProps(ours, theirs) {
|
|
394
|
-
const merged = { ...ours };
|
|
395
|
-
for (const key of Object.keys(theirs)) {
|
|
396
|
-
const ourValue = ours[key];
|
|
397
|
-
const theirValue = theirs[key];
|
|
398
|
-
if (EVENT_HANDLER.test(key)) {
|
|
399
|
-
merged[key] = composeHandlers(ourValue, theirValue);
|
|
400
|
-
} else if (key === "style") {
|
|
401
|
-
merged[key] = mergeStyles(ourValue, theirValue);
|
|
402
|
-
} else if (key === "ref") {
|
|
403
|
-
merged[key] = mergeRefs(
|
|
404
|
-
ourValue,
|
|
405
|
-
theirValue
|
|
406
|
-
);
|
|
407
|
-
} else {
|
|
408
|
-
merged[key] = theirValue;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return merged;
|
|
412
|
-
}
|
|
413
|
-
function composeHandlers(ours, theirs) {
|
|
414
|
-
if (typeof ours !== "function") return theirs;
|
|
415
|
-
if (typeof theirs !== "function") return ours;
|
|
416
|
-
return (...args) => {
|
|
417
|
-
;
|
|
418
|
-
ours(...args);
|
|
419
|
-
return theirs(...args);
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
function mergeStyles(ours, theirs) {
|
|
423
|
-
if (typeof ours === "function" || typeof theirs === "function") {
|
|
424
|
-
return (state) => [
|
|
425
|
-
resolveStyle(ours, state),
|
|
426
|
-
resolveStyle(theirs, state)
|
|
427
|
-
];
|
|
428
|
-
}
|
|
429
|
-
return [ours, theirs];
|
|
430
|
-
}
|
|
431
|
-
function resolveStyle(style, state) {
|
|
432
|
-
return typeof style === "function" ? style(state) : style;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// src/system/slot/slot.tsx
|
|
436
|
-
var Slot = forwardRef(function Slot2({ children, ...ours }, ref) {
|
|
437
|
-
if (!isValidElement2(children)) {
|
|
438
|
-
throw new Error(
|
|
439
|
-
"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."
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
const child = children;
|
|
443
|
-
const merged = mergeProps(ours, child.props);
|
|
444
|
-
merged.ref = mergeRefs(ref, refOf(child));
|
|
445
|
-
return cloneElement2(child, merged);
|
|
446
|
-
});
|
|
447
|
-
Slot.displayName = "XAUI.Slot";
|
|
448
|
-
function refOf(element) {
|
|
449
|
-
const fromProps = element.props.ref;
|
|
450
|
-
const fromElement = element.ref;
|
|
451
|
-
return fromProps ?? fromElement;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
429
|
// src/system/pressable-feedback/pressable-feedback.tsx
|
|
430
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
455
431
|
var AnimatedPressable = Animated3.createAnimatedComponent(Pressable);
|
|
456
432
|
var AnimatedSlot = Animated3.createAnimatedComponent(Slot);
|
|
457
433
|
var PressableFeedback = forwardRef2(
|
|
458
434
|
function PressableFeedback2({ animation, feedbackVariant = "scale-highlight", ...rest }, ref) {
|
|
459
|
-
const inheritedDisableAll =
|
|
435
|
+
const inheritedDisableAll = useContext3(DisableAllContext);
|
|
460
436
|
const resolved = resolveAnimation(animation, inheritedDisableAll);
|
|
461
437
|
const Feedback = resolved.none || feedbackVariant === "none" ? StaticFeedback : AnimatedFeedback;
|
|
462
|
-
const body2 = /* @__PURE__ */
|
|
438
|
+
const body2 = /* @__PURE__ */ jsx4(
|
|
463
439
|
Feedback,
|
|
464
440
|
{
|
|
465
441
|
ref,
|
|
@@ -468,7 +444,7 @@ var PressableFeedback = forwardRef2(
|
|
|
468
444
|
...rest
|
|
469
445
|
}
|
|
470
446
|
);
|
|
471
|
-
return resolved.disableAll ? /* @__PURE__ */
|
|
447
|
+
return resolved.disableAll ? /* @__PURE__ */ jsx4(DisableAllContext.Provider, { value: true, children: body2 }) : body2;
|
|
472
448
|
}
|
|
473
449
|
);
|
|
474
450
|
var StaticFeedback = forwardRef2(function StaticFeedback2({
|
|
@@ -481,9 +457,9 @@ var StaticFeedback = forwardRef2(function StaticFeedback2({
|
|
|
481
457
|
style,
|
|
482
458
|
...rest
|
|
483
459
|
}, ref) {
|
|
484
|
-
const context =
|
|
460
|
+
const context = useMemo(() => ({ isPressed, animation }), [isPressed, animation]);
|
|
485
461
|
const Root = asChild ? Slot : Pressable;
|
|
486
|
-
return /* @__PURE__ */
|
|
462
|
+
return /* @__PURE__ */ jsx4(FeedbackProvider, { value: context, children: /* @__PURE__ */ jsx4(Root, { ref, style, disabled: isDisabled, ...rest, children: body(asChild, feedbackVariant, children) }) });
|
|
487
463
|
});
|
|
488
464
|
var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
|
|
489
465
|
isPressed = false,
|
|
@@ -507,9 +483,10 @@ var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
|
|
|
507
483
|
});
|
|
508
484
|
}, [isPressed, progress]);
|
|
509
485
|
const animatedStyle = useAnimatedStyle3(
|
|
510
|
-
() => animation.scale ? { transform: [{ scale: 1 - (1 - PRESS_SCALE) * progress.value }] } : {}
|
|
486
|
+
() => animation.scale ? { transform: [{ scale: 1 - (1 - PRESS_SCALE) * progress.value }] } : {},
|
|
487
|
+
[animation.scale, progress]
|
|
511
488
|
);
|
|
512
|
-
const context =
|
|
489
|
+
const context = useMemo(
|
|
513
490
|
() => ({ isPressed, animation, progress, pressCount, origin, size }),
|
|
514
491
|
[isPressed, animation, progress, pressCount, origin, size]
|
|
515
492
|
);
|
|
@@ -526,7 +503,7 @@ var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
|
|
|
526
503
|
};
|
|
527
504
|
const clip = feedbackVariant === "scale-ripple" ? { overflow: "hidden" } : null;
|
|
528
505
|
const Root = asChild ? AnimatedSlot : AnimatedPressable;
|
|
529
|
-
return /* @__PURE__ */
|
|
506
|
+
return /* @__PURE__ */ jsx4(FeedbackProvider, { value: context, children: /* @__PURE__ */ jsx4(
|
|
530
507
|
Root,
|
|
531
508
|
{
|
|
532
509
|
ref,
|
|
@@ -534,18 +511,21 @@ var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
|
|
|
534
511
|
disabled: isDisabled,
|
|
535
512
|
onPressIn: handlePressIn,
|
|
536
513
|
onLayout: handleLayout,
|
|
537
|
-
...rest
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
));
|
|
514
|
+
...rest,
|
|
515
|
+
children: body(asChild, feedbackVariant, children)
|
|
516
|
+
}
|
|
517
|
+
) });
|
|
541
518
|
});
|
|
542
519
|
function body(asChild, variant, children) {
|
|
543
520
|
if (asChild) return children;
|
|
544
|
-
return /* @__PURE__ */
|
|
521
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
522
|
+
/* @__PURE__ */ jsx4(DefaultOverlay, { variant }),
|
|
523
|
+
children
|
|
524
|
+
] });
|
|
545
525
|
}
|
|
546
526
|
function DefaultOverlay({ variant }) {
|
|
547
|
-
if (variant === "scale-highlight") return /* @__PURE__ */
|
|
548
|
-
if (variant === "scale-ripple") return /* @__PURE__ */
|
|
527
|
+
if (variant === "scale-highlight") return /* @__PURE__ */ jsx4(PressableFeedbackHighlight, {});
|
|
528
|
+
if (variant === "scale-ripple") return /* @__PURE__ */ jsx4(PressableFeedbackRipple, {});
|
|
549
529
|
return null;
|
|
550
530
|
}
|
|
551
531
|
|
|
@@ -579,7 +559,7 @@ function resolveTint(tokens, color, theme) {
|
|
|
579
559
|
}
|
|
580
560
|
|
|
581
561
|
// src/system/recipe/style-cache.ts
|
|
582
|
-
import { StyleSheet as
|
|
562
|
+
import { StyleSheet as StyleSheet2 } from "react-native";
|
|
583
563
|
|
|
584
564
|
// src/system/recipe/variant-map.ts
|
|
585
565
|
var STATE_ORDER = ["focused", "pressed", "disabled"];
|
|
@@ -642,7 +622,7 @@ function createStyleCache(slots) {
|
|
|
642
622
|
const built = build();
|
|
643
623
|
const complete = {};
|
|
644
624
|
for (const slot of slots) complete[slot] = built[slot] ?? {};
|
|
645
|
-
const created =
|
|
625
|
+
const created = StyleSheet2.create(complete);
|
|
646
626
|
entries.set(key, created);
|
|
647
627
|
return created;
|
|
648
628
|
},
|
|
@@ -698,38 +678,15 @@ function apply(fns, theme, colors) {
|
|
|
698
678
|
return merged;
|
|
699
679
|
}
|
|
700
680
|
|
|
701
|
-
// src/system/slot/children-to-string.ts
|
|
702
|
-
import { isValidElement as isValidElement3 } from "react";
|
|
703
|
-
function childrenToString(children) {
|
|
704
|
-
const text = stringify(children);
|
|
705
|
-
return text === null || text === "" ? null : text;
|
|
706
|
-
}
|
|
707
|
-
function stringify(node) {
|
|
708
|
-
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
709
|
-
if (typeof node === "string") return node;
|
|
710
|
-
if (typeof node === "number") return String(node);
|
|
711
|
-
if (isValidElement3(node)) return null;
|
|
712
|
-
if (Array.isArray(node)) {
|
|
713
|
-
let text = "";
|
|
714
|
-
for (const child of node) {
|
|
715
|
-
const part = stringify(child);
|
|
716
|
-
if (part === null) return null;
|
|
717
|
-
text += part;
|
|
718
|
-
}
|
|
719
|
-
return text;
|
|
720
|
-
}
|
|
721
|
-
return null;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
681
|
export {
|
|
725
|
-
mergeRefs,
|
|
726
682
|
IconContext,
|
|
727
683
|
useIconContext,
|
|
728
684
|
Icon,
|
|
729
|
-
|
|
730
|
-
Portal,
|
|
731
|
-
PortalHost,
|
|
685
|
+
childrenToString,
|
|
732
686
|
createSlotContext,
|
|
687
|
+
mergeRefs,
|
|
688
|
+
mergeProps,
|
|
689
|
+
Slot,
|
|
733
690
|
useFeedback,
|
|
734
691
|
PRESS_SCALE,
|
|
735
692
|
PRESS_DURATION,
|
|
@@ -740,9 +697,6 @@ export {
|
|
|
740
697
|
RIPPLE_COVERAGE,
|
|
741
698
|
resolveAnimation,
|
|
742
699
|
resolveSlotAnimation,
|
|
743
|
-
mergeProps,
|
|
744
|
-
Slot,
|
|
745
700
|
PressableFeedback3 as PressableFeedback,
|
|
746
|
-
createRecipe
|
|
747
|
-
childrenToString
|
|
701
|
+
createRecipe
|
|
748
702
|
};
|