@xaui/native 0.9.1-alpha.11 → 0.9.1-alpha.13
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-7XGOXTGT.js → chunk-4O3PXFQ7.js} +15 -31
- package/dist/{chunk-3QBT3Q65.cjs → chunk-6N5JXRUZ.cjs} +26 -3
- package/dist/chunk-B3EAZ2CC.js +1010 -0
- package/dist/{chunk-2FEDC7U5.cjs → chunk-DDYMIWLW.cjs} +41 -57
- package/dist/chunk-IVVFYUDW.cjs +1044 -0
- package/dist/{chunk-6OHFG32Y.cjs → chunk-MLJ543GP.cjs} +41 -53
- package/dist/{chunk-NQ5WWF77.js → chunk-RWLODK55.js} +35 -47
- package/dist/{chunk-X2K2FX3W.js → chunk-XJARE6SC.js} +24 -1
- package/dist/components/button/index.cjs +4 -4
- package/dist/components/button/index.d.cts +162 -13
- package/dist/components/button/index.d.ts +162 -13
- package/dist/components/button/index.js +3 -3
- package/dist/{create-recipe-Dn9kj5Rs.d.ts → create-recipe-3OPwcC6P.d.ts} +81 -21
- package/dist/{create-recipe-BjSP0zL_.d.cts → create-recipe-oiLAlJ4u.d.cts} +81 -21
- package/dist/index.cjs +28 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -12
- package/dist/system/index.cjs +24 -4
- package/dist/system/index.d.cts +160 -35
- package/dist/system/index.d.ts +160 -35
- package/dist/system/index.js +31 -11
- package/dist/theme/index.cjs +3 -3
- package/dist/theme/index.d.cts +19 -8
- package/dist/theme/index.d.ts +19 -8
- package/dist/theme/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-E2UGZJBT.cjs +0 -959
- package/dist/chunk-R4HJCQPI.js +0 -889
- /package/dist/{chunk-LMUPNKPH.cjs → chunk-2FOEFUPM.cjs} +0 -0
- /package/dist/{chunk-3TIDEII6.js → chunk-TO6DAGFB.js} +0 -0
|
@@ -0,0 +1,1010 @@
|
|
|
1
|
+
import { contrastOn, deriveTint, isHex, stableHash, useXAUITheme } from "./chunk-XJARE6SC.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/style-props/use-style-props.ts
|
|
165
|
+
import { useMemo } from "react";
|
|
166
|
+
|
|
167
|
+
// src/utils/style-props.ts
|
|
168
|
+
var STYLE_PROP_KEYS = [
|
|
169
|
+
// Flex and layout
|
|
170
|
+
"alignContent", "alignItems", "alignSelf", "aspectRatio", "boxSizing", "columnGap", "direction", "display", "flex", "flexBasis", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "justifyContent", "overflow", "rowGap",
|
|
171
|
+
// Position
|
|
172
|
+
"bottom", "end", "inset", "insetBlock", "insetBlockEnd", "insetBlockStart", "insetInline", "insetInlineEnd", "insetInlineStart", "position", "start", "top", "zIndex",
|
|
173
|
+
// Margin
|
|
174
|
+
"margin", "marginBlock", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginEnd", "marginHorizontal", "marginInline", "marginInlineEnd", "marginInlineStart", "marginStart", "marginTop", "marginVertical",
|
|
175
|
+
// Padding
|
|
176
|
+
"padding", "paddingBlock", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingEnd", "paddingHorizontal", "paddingInline", "paddingInlineEnd", "paddingInlineStart", "paddingStart", "paddingTop", "paddingVertical",
|
|
177
|
+
// Size
|
|
178
|
+
"height", "maxHeight", "maxWidth", "minHeight", "minWidth", "width",
|
|
179
|
+
// Border
|
|
180
|
+
"borderBlockColor", "borderBlockEndColor", "borderBlockStartColor", "borderBottomColor", "borderBottomEndRadius", "borderBottomStartRadius", "borderBottomWidth", "borderColor", "borderCurve", "borderEndColor", "borderEndEndRadius", "borderEndStartRadius", "borderEndWidth", "borderRadius", "borderStartColor", "borderStartEndRadius", "borderStartStartRadius", "borderStartWidth", "borderStyle", "borderTopColor", "borderTopEndRadius", "borderTopStartRadius", "borderTopWidth", "borderWidth",
|
|
181
|
+
// Fill, shadow, and the rest of a box's paint
|
|
182
|
+
"backfaceVisibility", "backgroundColor", "boxShadow", "cursor", "elevation", "experimental_backgroundImage", "filter", "isolation", "mixBlendMode", "opacity", "outlineColor", "outlineOffset", "outlineStyle", "outlineWidth", "shadowColor", "shadowOffset", "shadowOpacity", "shadowRadius",
|
|
183
|
+
// Transform
|
|
184
|
+
"rotation", "scaleX", "scaleY", "transform", "transformMatrix", "transformOrigin", "translateX", "translateY",
|
|
185
|
+
// Text — a text slot only
|
|
186
|
+
"color", "fontFamily", "fontSize", "fontStyle", "fontVariant", "fontWeight", "includeFontPadding", "letterSpacing", "lineHeight", "textAlign", "textAlignVertical", "textDecorationColor", "textDecorationLine", "textDecorationStyle", "textShadowColor", "textShadowOffset", "textShadowRadius", "textTransform", "userSelect", "verticalAlign", "writingDirection",
|
|
187
|
+
// Image — an image slot only
|
|
188
|
+
"objectFit", "overlayColor", "resizeMode", "tintColor"];
|
|
189
|
+
var STYLE_PROP_KEY_SET = new Set(STYLE_PROP_KEYS);
|
|
190
|
+
function splitStyleProps(props) {
|
|
191
|
+
const styleProps = {};
|
|
192
|
+
const rest = {};
|
|
193
|
+
for (const [key, value] of Object.entries(props)) {
|
|
194
|
+
if (STYLE_PROP_KEY_SET.has(key)) styleProps[key] = value;else rest[key] = value;
|
|
195
|
+
}
|
|
196
|
+
return [styleProps, rest];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/system/style-props/use-style-props.ts
|
|
200
|
+
function useStyleProps(props) {
|
|
201
|
+
const [styleProps, rest] = splitStyleProps(props);
|
|
202
|
+
const key = stableHash(styleProps);
|
|
203
|
+
return [useMemo(() => styleProps, [key]), rest];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/system/pressable-feedback/pressable-feedback-context.ts
|
|
207
|
+
import { createContext as createContext3 } from "react";
|
|
208
|
+
var [FeedbackProvider, useFeedback] = createSlotContext("PressableFeedback");
|
|
209
|
+
var DisableAllContext = createContext3(false);
|
|
210
|
+
|
|
211
|
+
// src/system/pressable-feedback/pressable-feedback.animation.ts
|
|
212
|
+
var PRESS_SCALE = 0.985;
|
|
213
|
+
var PRESS_DURATION = 300;
|
|
214
|
+
var SCALE_REFERENCE_WIDTH = 300;
|
|
215
|
+
const _worklet_6691672065997_init_data = {
|
|
216
|
+
code: "function pressScaleFor_chunkB3EAZ2CCJs1(width){const{SCALE_REFERENCE_WIDTH,PRESS_SCALE}=this.__closure;const coefficient=width>0?SCALE_REFERENCE_WIDTH/width:1;return 1-(1-PRESS_SCALE)*coefficient;}",
|
|
217
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
218
|
+
sourceMap: "{\"version\":3,\"names\":[\"pressScaleFor_chunkB3EAZ2CCJs1\",\"width\",\"SCALE_REFERENCE_WIDTH\",\"PRESS_SCALE\",\"__closure\",\"coefficient\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AAwWA,SAAAA,8BAA8BA,CAAAC,KAAA,QAAAC,qBAAA,CAAAC,WAAA,OAAAC,SAAA,CAE5B,KAAM,CAAAC,WAAW,CAAGJ,KAAK,CAAG,CAAC,CAAGC,qBAAqB,CAAGD,KAAK,CAAG,CAAC,CACjE,MAAO,EAAC,CAAG,CAAC,CAAC,CAAGE,WAAW,EAAIE,WAAW,CAC5C\",\"ignoreList\":[]}"
|
|
219
|
+
};
|
|
220
|
+
const pressScaleFor = function pressScaleFor_chunkB3EAZ2CCJs1Factory({
|
|
221
|
+
_worklet_6691672065997_init_data,
|
|
222
|
+
SCALE_REFERENCE_WIDTH,
|
|
223
|
+
PRESS_SCALE
|
|
224
|
+
}) {
|
|
225
|
+
const _e = [new global.Error(), -3, -27];
|
|
226
|
+
const pressScaleFor = function (width) {
|
|
227
|
+
const coefficient = width > 0 ? SCALE_REFERENCE_WIDTH / width : 1;
|
|
228
|
+
return 1 - (1 - PRESS_SCALE) * coefficient;
|
|
229
|
+
};
|
|
230
|
+
pressScaleFor.__closure = {
|
|
231
|
+
SCALE_REFERENCE_WIDTH,
|
|
232
|
+
PRESS_SCALE
|
|
233
|
+
};
|
|
234
|
+
pressScaleFor.__workletHash = 6691672065997;
|
|
235
|
+
pressScaleFor.__pluginVersion = "0.7.4";
|
|
236
|
+
pressScaleFor.__initData = _worklet_6691672065997_init_data;
|
|
237
|
+
pressScaleFor.__stackDetails = _e;
|
|
238
|
+
return pressScaleFor;
|
|
239
|
+
}({
|
|
240
|
+
_worklet_6691672065997_init_data,
|
|
241
|
+
SCALE_REFERENCE_WIDTH,
|
|
242
|
+
PRESS_SCALE
|
|
243
|
+
});
|
|
244
|
+
var HIGHLIGHT_OPACITY = 0.1;
|
|
245
|
+
var HIGHLIGHT_DURATION = 200;
|
|
246
|
+
var RIPPLE_OPACITY = 0.1;
|
|
247
|
+
var RIPPLE_START_SCALE = 0.3;
|
|
248
|
+
var RIPPLE_EXPAND_DURATION = 1e3;
|
|
249
|
+
var RIPPLE_CONFIRM_DURATION = 225;
|
|
250
|
+
var RIPPLE_FADE_IN = 75;
|
|
251
|
+
var RIPPLE_FADE_OUT_DELAY = 225;
|
|
252
|
+
var RIPPLE_FADE_OUT = 150;
|
|
253
|
+
const _worklet_9510765573814_init_data = {
|
|
254
|
+
code: "function rippleRadiusFor_chunkB3EAZ2CCJs2(width,height){return Math.sqrt(width*width+height*height)/2+5;}",
|
|
255
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
256
|
+
sourceMap: "{\"version\":3,\"names\":[\"rippleRadiusFor_chunkB3EAZ2CCJs2\",\"width\",\"height\",\"Math\",\"sqrt\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AAsXA,SAAAA,gCAAwCA,CAAAC,KAAA,CAAAC,MAAA,EAEtC,MAAO,CAAAC,IAAI,CAACC,IAAI,CAACH,KAAK,CAAGA,KAAK,CAAGC,MAAM,CAAGA,MAAM,CAAC,CAAG,CAAC,CAAG,CAAC,CAC3D\",\"ignoreList\":[]}"
|
|
257
|
+
};
|
|
258
|
+
const rippleRadiusFor = function rippleRadiusFor_chunkB3EAZ2CCJs2Factory({
|
|
259
|
+
_worklet_9510765573814_init_data
|
|
260
|
+
}) {
|
|
261
|
+
const _e = [new global.Error(), 1, -27];
|
|
262
|
+
const rippleRadiusFor = function (width, height) {
|
|
263
|
+
return Math.sqrt(width * width + height * height) / 2 + 5;
|
|
264
|
+
};
|
|
265
|
+
rippleRadiusFor.__closure = {};
|
|
266
|
+
rippleRadiusFor.__workletHash = 9510765573814;
|
|
267
|
+
rippleRadiusFor.__pluginVersion = "0.7.4";
|
|
268
|
+
rippleRadiusFor.__initData = _worklet_9510765573814_init_data;
|
|
269
|
+
rippleRadiusFor.__stackDetails = _e;
|
|
270
|
+
return rippleRadiusFor;
|
|
271
|
+
}({
|
|
272
|
+
_worklet_9510765573814_init_data
|
|
273
|
+
});
|
|
274
|
+
var ALL_OFF = {
|
|
275
|
+
scale: false,
|
|
276
|
+
highlight: false,
|
|
277
|
+
ripple: false,
|
|
278
|
+
none: true
|
|
279
|
+
};
|
|
280
|
+
var ALL_ON = {
|
|
281
|
+
scale: true,
|
|
282
|
+
highlight: true,
|
|
283
|
+
ripple: true,
|
|
284
|
+
none: false
|
|
285
|
+
};
|
|
286
|
+
function resolveAnimation(animation, inheritedDisableAll = false) {
|
|
287
|
+
if (inheritedDisableAll) return {
|
|
288
|
+
...ALL_OFF,
|
|
289
|
+
disableAll: true
|
|
290
|
+
};
|
|
291
|
+
if (animation === false || animation === "disabled") {
|
|
292
|
+
return {
|
|
293
|
+
...ALL_OFF,
|
|
294
|
+
disableAll: false
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (animation === "disable-all") return {
|
|
298
|
+
...ALL_OFF,
|
|
299
|
+
disableAll: true
|
|
300
|
+
};
|
|
301
|
+
if (animation === void 0 || animation === true) {
|
|
302
|
+
return {
|
|
303
|
+
...ALL_ON,
|
|
304
|
+
disableAll: false
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const scale = animation.scale ?? true;
|
|
308
|
+
const highlight = animation.highlight ?? true;
|
|
309
|
+
const ripple = animation.ripple ?? true;
|
|
310
|
+
return {
|
|
311
|
+
scale,
|
|
312
|
+
highlight,
|
|
313
|
+
ripple,
|
|
314
|
+
none: !scale && !highlight && !ripple,
|
|
315
|
+
disableAll: false
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function resolveSlotAnimation(override, enabledByRoot, defaultOpacity, defaultDuration = PRESS_DURATION) {
|
|
319
|
+
const fallback = {
|
|
320
|
+
enabled: enabledByRoot,
|
|
321
|
+
duration: defaultDuration,
|
|
322
|
+
opacity: defaultOpacity
|
|
323
|
+
};
|
|
324
|
+
if (override === void 0 || override === true) return fallback;
|
|
325
|
+
if (override === false) return {
|
|
326
|
+
...fallback,
|
|
327
|
+
enabled: false
|
|
328
|
+
};
|
|
329
|
+
return {
|
|
330
|
+
enabled: enabledByRoot,
|
|
331
|
+
duration: override.duration ?? defaultDuration,
|
|
332
|
+
opacity: override.opacity ?? defaultOpacity
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/system/pressable-feedback/pressable-feedback.overlay.ts
|
|
337
|
+
import { Children, isValidElement as isValidElement4 } from "react";
|
|
338
|
+
var FEEDBACK_OVERLAY = /* @__PURE__ */Symbol.for("xaui.PressableFeedback.overlay");
|
|
339
|
+
function markOverlay(component) {
|
|
340
|
+
return Object.assign(component, {
|
|
341
|
+
[FEEDBACK_OVERLAY]: true
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function isBareOverlay(node) {
|
|
345
|
+
if (!isValidElement4(node)) return false;
|
|
346
|
+
const type = node.type;
|
|
347
|
+
if (typeof type !== "function" && typeof type !== "object") return false;
|
|
348
|
+
if (type === null) return false;
|
|
349
|
+
if (type[FEEDBACK_OVERLAY] !== true) return false;
|
|
350
|
+
return node.props.children === void 0;
|
|
351
|
+
}
|
|
352
|
+
function partitionOverlays(children) {
|
|
353
|
+
const all = Children.toArray(children);
|
|
354
|
+
const overlays = all.filter(isBareOverlay);
|
|
355
|
+
if (overlays.length === 0) return {
|
|
356
|
+
overlays: null,
|
|
357
|
+
content: children
|
|
358
|
+
};
|
|
359
|
+
return {
|
|
360
|
+
overlays,
|
|
361
|
+
content: all.filter(node => !isBareOverlay(node))
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/system/pressable-feedback/pressable-feedback.tsx
|
|
366
|
+
import { forwardRef as forwardRef2, useContext as useContext3, useEffect, useMemo as useMemo2, useRef } from "react";
|
|
367
|
+
import { Pressable, StyleSheet } from "react-native";
|
|
368
|
+
import Animated, { Easing, useAnimatedStyle, useDerivedValue, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
|
|
369
|
+
|
|
370
|
+
// src/system/pressable-feedback/pressable-feedback.surface.ts
|
|
371
|
+
function inkFor(background, colors) {
|
|
372
|
+
if (typeof background !== "string" || !isHex(background)) return colors.foreground;
|
|
373
|
+
return contrastOn(background, colors.snow, colors.eclipse);
|
|
374
|
+
}
|
|
375
|
+
var RADIUS_KEYS = ["borderRadius", "borderStartStartRadius", "borderStartEndRadius", "borderEndStartRadius", "borderEndEndRadius"];
|
|
376
|
+
function radiusFrom(style) {
|
|
377
|
+
if (!style) return {};
|
|
378
|
+
const radius = {};
|
|
379
|
+
for (const key of RADIUS_KEYS) {
|
|
380
|
+
const value = style[key];
|
|
381
|
+
if (value !== void 0) radius[key] = value;
|
|
382
|
+
}
|
|
383
|
+
return radius;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// src/system/pressable-feedback/pressable-feedback.tsx
|
|
387
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
388
|
+
var AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
389
|
+
var AnimatedSlot = Animated.createAnimatedComponent(Slot);
|
|
390
|
+
var PressableFeedback = forwardRef2(function PressableFeedback2({
|
|
391
|
+
animation,
|
|
392
|
+
...rest
|
|
393
|
+
}, ref) {
|
|
394
|
+
const inheritedDisableAll = useContext3(DisableAllContext);
|
|
395
|
+
const resolved = resolveAnimation(animation, inheritedDisableAll);
|
|
396
|
+
const Feedback = resolved.none ? StaticFeedback : AnimatedFeedback;
|
|
397
|
+
const body = /* @__PURE__ */jsx2(Feedback, {
|
|
398
|
+
ref,
|
|
399
|
+
animation: resolved,
|
|
400
|
+
...rest
|
|
401
|
+
});
|
|
402
|
+
return resolved.disableAll ? /* @__PURE__ */jsx2(DisableAllContext.Provider, {
|
|
403
|
+
value: true,
|
|
404
|
+
children: body
|
|
405
|
+
}) : body;
|
|
406
|
+
});
|
|
407
|
+
var StaticFeedback = forwardRef2(function StaticFeedback2({
|
|
408
|
+
isPressed = false,
|
|
409
|
+
isDisabled,
|
|
410
|
+
asChild = false,
|
|
411
|
+
animation,
|
|
412
|
+
children,
|
|
413
|
+
style,
|
|
414
|
+
...rest
|
|
415
|
+
}, ref) {
|
|
416
|
+
const surface = useSurface(style);
|
|
417
|
+
const context = useMemo2(() => ({
|
|
418
|
+
isPressed,
|
|
419
|
+
animation,
|
|
420
|
+
...surface
|
|
421
|
+
}), [isPressed, animation, surface]);
|
|
422
|
+
const Root = asChild ? Slot : Pressable;
|
|
423
|
+
const {
|
|
424
|
+
overlays,
|
|
425
|
+
content
|
|
426
|
+
} = partitionOverlays(children);
|
|
427
|
+
return /* @__PURE__ */jsx2(FeedbackProvider, {
|
|
428
|
+
value: context,
|
|
429
|
+
children: /* @__PURE__ */jsxs(Root, {
|
|
430
|
+
ref,
|
|
431
|
+
style,
|
|
432
|
+
disabled: isDisabled,
|
|
433
|
+
...rest,
|
|
434
|
+
children: [overlays, content]
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
const _worklet_2835586366723_init_data = {
|
|
439
|
+
code: "function chunkB3EAZ2CCJs3(){const{pressScaleFor,size}=this.__closure;return pressScaleFor(size.value.width);}",
|
|
440
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
441
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkB3EAZ2CCJs3\",\"pressScaleFor\",\"size\",\"__closure\",\"value\",\"width\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AAyhBuC,SAAAA,iBAAA,QAAAC,aAAA,CAAAC,IAAA,OAAAC,SAAA,OAAM,CAAAF,aAAc,CAAAC,IAAK,CAAAE,KAAM,CAAAC,KAAK\",\"ignoreList\":[]}"
|
|
442
|
+
};
|
|
443
|
+
const _worklet_629504988883_init_data = {
|
|
444
|
+
code: "function chunkB3EAZ2CCJs4(){const{animation,pressedScale,progress}=this.__closure;if(!animation.scale)return{};return{transform:[{scale:1-(1-pressedScale.value)*progress.value}]};}",
|
|
445
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
446
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkB3EAZ2CCJs4\",\"animation\",\"pressedScale\",\"progress\",\"__closure\",\"scale\",\"transform\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AA0hByC,SAAAA,gBAAMA,CAAA,QAAAC,SAAA,CAAAC,YAAA,CAAAC,QAAA,OAAAC,SAAA,CAE3C,GAAI,CAACH,SAAS,CAACI,KAAK,CAAE,MAAO,CAAC,CAAC,CAC/B,MAAO,CAAEC,SAAS,CAAE,CAAC,CAAED,KAAK,CAAE,CAAC,CAAG,CAAC,CAAC,CAAGH,YAAY,CAACK,KAAK,EAAIJ,QAAQ,CAACI,KAAM,CAAC,CAAE,CAAC,CAClF\",\"ignoreList\":[]}"
|
|
447
|
+
};
|
|
448
|
+
var AnimatedFeedback = forwardRef2(function AnimatedFeedback2({
|
|
449
|
+
isPressed = false,
|
|
450
|
+
isDisabled,
|
|
451
|
+
asChild = false,
|
|
452
|
+
animation,
|
|
453
|
+
children,
|
|
454
|
+
style,
|
|
455
|
+
onLayout,
|
|
456
|
+
onTouchStart,
|
|
457
|
+
onTouchEnd,
|
|
458
|
+
onTouchCancel,
|
|
459
|
+
...rest
|
|
460
|
+
}, ref) {
|
|
461
|
+
const progress = useSharedValue(0);
|
|
462
|
+
const size = useSharedValue({
|
|
463
|
+
width: 0,
|
|
464
|
+
height: 0
|
|
465
|
+
});
|
|
466
|
+
const waves = [useWave(), useWave()];
|
|
467
|
+
const nextWave = useRef(0);
|
|
468
|
+
useEffect(() => {
|
|
469
|
+
progress.value = withTiming(isPressed ? 1 : 0, {
|
|
470
|
+
duration: PRESS_DURATION,
|
|
471
|
+
easing: Easing.out(Easing.ease)
|
|
472
|
+
});
|
|
473
|
+
}, [isPressed, progress]);
|
|
474
|
+
const pressedScale = useDerivedValue(function chunkB3EAZ2CCJs3Factory({
|
|
475
|
+
_worklet_2835586366723_init_data,
|
|
476
|
+
pressScaleFor,
|
|
477
|
+
size
|
|
478
|
+
}) {
|
|
479
|
+
const _e = [new global.Error(), -3, -27];
|
|
480
|
+
const chunkB3EAZ2CCJs3 = () => pressScaleFor(size.value.width);
|
|
481
|
+
chunkB3EAZ2CCJs3.__closure = {
|
|
482
|
+
pressScaleFor,
|
|
483
|
+
size
|
|
484
|
+
};
|
|
485
|
+
chunkB3EAZ2CCJs3.__workletHash = 2835586366723;
|
|
486
|
+
chunkB3EAZ2CCJs3.__pluginVersion = "0.7.4";
|
|
487
|
+
chunkB3EAZ2CCJs3.__initData = _worklet_2835586366723_init_data;
|
|
488
|
+
chunkB3EAZ2CCJs3.__stackDetails = _e;
|
|
489
|
+
return chunkB3EAZ2CCJs3;
|
|
490
|
+
}({
|
|
491
|
+
_worklet_2835586366723_init_data,
|
|
492
|
+
pressScaleFor,
|
|
493
|
+
size
|
|
494
|
+
}));
|
|
495
|
+
const animatedStyle = useAnimatedStyle(function chunkB3EAZ2CCJs4Factory({
|
|
496
|
+
_worklet_629504988883_init_data,
|
|
497
|
+
animation,
|
|
498
|
+
pressedScale,
|
|
499
|
+
progress
|
|
500
|
+
}) {
|
|
501
|
+
const _e = [new global.Error(), -4, -27];
|
|
502
|
+
const chunkB3EAZ2CCJs4 = function () {
|
|
503
|
+
if (!animation.scale) return {};
|
|
504
|
+
return {
|
|
505
|
+
transform: [{
|
|
506
|
+
scale: 1 - (1 - pressedScale.value) * progress.value
|
|
507
|
+
}]
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
chunkB3EAZ2CCJs4.__closure = {
|
|
511
|
+
animation,
|
|
512
|
+
pressedScale,
|
|
513
|
+
progress
|
|
514
|
+
};
|
|
515
|
+
chunkB3EAZ2CCJs4.__workletHash = 629504988883;
|
|
516
|
+
chunkB3EAZ2CCJs4.__pluginVersion = "0.7.4";
|
|
517
|
+
chunkB3EAZ2CCJs4.__initData = _worklet_629504988883_init_data;
|
|
518
|
+
chunkB3EAZ2CCJs4.__stackDetails = _e;
|
|
519
|
+
return chunkB3EAZ2CCJs4;
|
|
520
|
+
}({
|
|
521
|
+
_worklet_629504988883_init_data,
|
|
522
|
+
animation,
|
|
523
|
+
pressedScale,
|
|
524
|
+
progress
|
|
525
|
+
}), [animation.scale, progress, pressedScale]);
|
|
526
|
+
const surface = useSurface(style);
|
|
527
|
+
const context = useMemo2(() => ({
|
|
528
|
+
isPressed,
|
|
529
|
+
animation,
|
|
530
|
+
progress,
|
|
531
|
+
size,
|
|
532
|
+
waves,
|
|
533
|
+
...surface
|
|
534
|
+
}), [isPressed, animation, progress, size, waves, surface]);
|
|
535
|
+
const handleTouchStart = event => {
|
|
536
|
+
const wave = waves[nextWave.current];
|
|
537
|
+
nextWave.current = nextWave.current === 0 ? 1 : 0;
|
|
538
|
+
const {
|
|
539
|
+
locationX,
|
|
540
|
+
locationY
|
|
541
|
+
} = event.nativeEvent;
|
|
542
|
+
wave.origin.value = {
|
|
543
|
+
x: locationX,
|
|
544
|
+
y: locationY
|
|
545
|
+
};
|
|
546
|
+
wave.expand.value = 0;
|
|
547
|
+
wave.expand.value = withTiming(1, {
|
|
548
|
+
duration: RIPPLE_EXPAND_DURATION,
|
|
549
|
+
easing: Easing.ease
|
|
550
|
+
});
|
|
551
|
+
wave.alpha.value = withTiming(1, {
|
|
552
|
+
duration: RIPPLE_FADE_IN
|
|
553
|
+
});
|
|
554
|
+
onTouchStart?.(event);
|
|
555
|
+
};
|
|
556
|
+
const releaseWave = () => {
|
|
557
|
+
const wave = waves[nextWave.current === 0 ? 1 : 0];
|
|
558
|
+
wave.expand.value = withTiming(1, {
|
|
559
|
+
duration: RIPPLE_CONFIRM_DURATION,
|
|
560
|
+
easing: Easing.ease
|
|
561
|
+
});
|
|
562
|
+
wave.alpha.value = withDelay(RIPPLE_FADE_OUT_DELAY, withTiming(0, {
|
|
563
|
+
duration: RIPPLE_FADE_OUT
|
|
564
|
+
}));
|
|
565
|
+
};
|
|
566
|
+
const handleTouchEnd = event => {
|
|
567
|
+
releaseWave();
|
|
568
|
+
onTouchEnd?.(event);
|
|
569
|
+
};
|
|
570
|
+
const handleTouchCancel = event => {
|
|
571
|
+
releaseWave();
|
|
572
|
+
onTouchCancel?.(event);
|
|
573
|
+
};
|
|
574
|
+
const handleLayout = event => {
|
|
575
|
+
const {
|
|
576
|
+
width,
|
|
577
|
+
height
|
|
578
|
+
} = event.nativeEvent.layout;
|
|
579
|
+
size.value = {
|
|
580
|
+
width,
|
|
581
|
+
height
|
|
582
|
+
};
|
|
583
|
+
onLayout?.(event);
|
|
584
|
+
};
|
|
585
|
+
const Root = asChild ? AnimatedSlot : AnimatedPressable;
|
|
586
|
+
const {
|
|
587
|
+
overlays,
|
|
588
|
+
content
|
|
589
|
+
} = partitionOverlays(children);
|
|
590
|
+
return /* @__PURE__ */jsx2(FeedbackProvider, {
|
|
591
|
+
value: context,
|
|
592
|
+
children: /* @__PURE__ */jsxs(Root, {
|
|
593
|
+
ref,
|
|
594
|
+
style: [style, animatedStyle],
|
|
595
|
+
disabled: isDisabled,
|
|
596
|
+
onLayout: handleLayout,
|
|
597
|
+
onTouchStart: handleTouchStart,
|
|
598
|
+
onTouchEnd: handleTouchEnd,
|
|
599
|
+
onTouchCancel: handleTouchCancel,
|
|
600
|
+
...rest,
|
|
601
|
+
children: [overlays, content]
|
|
602
|
+
})
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
PressableFeedback.displayName = "XAUI.PressableFeedback";
|
|
606
|
+
function useWave() {
|
|
607
|
+
return {
|
|
608
|
+
expand: useSharedValue(0),
|
|
609
|
+
alpha: useSharedValue(0),
|
|
610
|
+
origin: useSharedValue({
|
|
611
|
+
x: 0,
|
|
612
|
+
y: 0
|
|
613
|
+
})
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function useSurface(style) {
|
|
617
|
+
const theme = useXAUITheme();
|
|
618
|
+
return useMemo2(() => {
|
|
619
|
+
const flat = StyleSheet.flatten(style);
|
|
620
|
+
return {
|
|
621
|
+
ink: inkFor(flat?.backgroundColor, theme.colors),
|
|
622
|
+
corners: radiusFrom(flat)
|
|
623
|
+
};
|
|
624
|
+
}, [style, theme]);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/system/pressable-feedback/pressable-feedback-highlight.tsx
|
|
628
|
+
import { useEffect as useEffect2 } from "react";
|
|
629
|
+
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
630
|
+
import Animated2, { useAnimatedStyle as useAnimatedStyle2, useSharedValue as useSharedValue2, withTiming as withTiming2 } from "react-native-reanimated";
|
|
631
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
632
|
+
function PressableFeedbackHighlight({
|
|
633
|
+
style,
|
|
634
|
+
animation: override,
|
|
635
|
+
children
|
|
636
|
+
}) {
|
|
637
|
+
const {
|
|
638
|
+
isPressed,
|
|
639
|
+
animation,
|
|
640
|
+
progress,
|
|
641
|
+
ink,
|
|
642
|
+
corners
|
|
643
|
+
} = useFeedback();
|
|
644
|
+
const settings = resolveSlotAnimation(override, animation.highlight, HIGHLIGHT_OPACITY, HIGHLIGHT_DURATION);
|
|
645
|
+
const base = [StyleSheet2.absoluteFillObject, {
|
|
646
|
+
backgroundColor: ink,
|
|
647
|
+
pointerEvents: "none"
|
|
648
|
+
}, corners, style];
|
|
649
|
+
if (!progress || !settings.enabled) {
|
|
650
|
+
return /* @__PURE__ */jsxs2(Fragment, {
|
|
651
|
+
children: [/* @__PURE__ */jsx3(View2, {
|
|
652
|
+
style: [base, {
|
|
653
|
+
opacity: isPressed ? settings.opacity : 0
|
|
654
|
+
}]
|
|
655
|
+
}), children]
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
return /* @__PURE__ */jsxs2(Fragment, {
|
|
659
|
+
children: [/* @__PURE__ */jsx3(AnimatedHighlight, {
|
|
660
|
+
base,
|
|
661
|
+
duration: settings.duration,
|
|
662
|
+
opacity: settings.opacity
|
|
663
|
+
}), children]
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
PressableFeedbackHighlight.displayName = "XAUI.PressableFeedback.Highlight";
|
|
667
|
+
markOverlay(PressableFeedbackHighlight);
|
|
668
|
+
const _worklet_15840805364323_init_data = {
|
|
669
|
+
code: "function chunkB3EAZ2CCJs5(){const{shown,opacity}=this.__closure;return{opacity:shown.value*opacity};}",
|
|
670
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
671
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkB3EAZ2CCJs5\",\"shown\",\"opacity\",\"__closure\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AAyqB0C,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,CAAAC,OAAA,OAAAC,SAAA,CAE5C,MAAO,CAAED,OAAO,CAAED,KAAK,CAACG,KAAK,CAAGF,OAAQ,CAAC,CAC3C\",\"ignoreList\":[]}"
|
|
672
|
+
};
|
|
673
|
+
function AnimatedHighlight({
|
|
674
|
+
base,
|
|
675
|
+
duration,
|
|
676
|
+
opacity
|
|
677
|
+
}) {
|
|
678
|
+
const {
|
|
679
|
+
isPressed
|
|
680
|
+
} = useFeedback();
|
|
681
|
+
const shown = useSharedValue2(0);
|
|
682
|
+
useEffect2(() => {
|
|
683
|
+
shown.value = withTiming2(isPressed ? 1 : 0, {
|
|
684
|
+
duration
|
|
685
|
+
});
|
|
686
|
+
}, [isPressed, shown, duration]);
|
|
687
|
+
const animatedStyle = useAnimatedStyle2(function chunkB3EAZ2CCJs5Factory({
|
|
688
|
+
_worklet_15840805364323_init_data,
|
|
689
|
+
shown,
|
|
690
|
+
opacity
|
|
691
|
+
}) {
|
|
692
|
+
const _e = [new global.Error(), -3, -27];
|
|
693
|
+
const chunkB3EAZ2CCJs5 = function () {
|
|
694
|
+
return {
|
|
695
|
+
opacity: shown.value * opacity
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
chunkB3EAZ2CCJs5.__closure = {
|
|
699
|
+
shown,
|
|
700
|
+
opacity
|
|
701
|
+
};
|
|
702
|
+
chunkB3EAZ2CCJs5.__workletHash = 15840805364323;
|
|
703
|
+
chunkB3EAZ2CCJs5.__pluginVersion = "0.7.4";
|
|
704
|
+
chunkB3EAZ2CCJs5.__initData = _worklet_15840805364323_init_data;
|
|
705
|
+
chunkB3EAZ2CCJs5.__stackDetails = _e;
|
|
706
|
+
return chunkB3EAZ2CCJs5;
|
|
707
|
+
}({
|
|
708
|
+
_worklet_15840805364323_init_data,
|
|
709
|
+
shown,
|
|
710
|
+
opacity
|
|
711
|
+
}), [shown, opacity]);
|
|
712
|
+
return /* @__PURE__ */jsx3(Animated2.View, {
|
|
713
|
+
style: [base, animatedStyle]
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/system/pressable-feedback/pressable-feedback-ripple.tsx
|
|
718
|
+
import { useState } from "react";
|
|
719
|
+
import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
|
|
720
|
+
import Animated3, { useAnimatedStyle as useAnimatedStyle3 } from "react-native-reanimated";
|
|
721
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
722
|
+
function PressableFeedbackRipple({
|
|
723
|
+
style,
|
|
724
|
+
animation: override,
|
|
725
|
+
children
|
|
726
|
+
}) {
|
|
727
|
+
const {
|
|
728
|
+
animation,
|
|
729
|
+
waves,
|
|
730
|
+
ink,
|
|
731
|
+
corners
|
|
732
|
+
} = useFeedback();
|
|
733
|
+
const settings = resolveSlotAnimation(override, animation.ripple, RIPPLE_OPACITY);
|
|
734
|
+
const [size, setSize] = useState({
|
|
735
|
+
width: 0,
|
|
736
|
+
height: 0
|
|
737
|
+
});
|
|
738
|
+
const handleLayout = event => {
|
|
739
|
+
const {
|
|
740
|
+
width,
|
|
741
|
+
height
|
|
742
|
+
} = event.nativeEvent.layout;
|
|
743
|
+
setSize(current => current.width === width && current.height === height ? current : {
|
|
744
|
+
width,
|
|
745
|
+
height
|
|
746
|
+
});
|
|
747
|
+
};
|
|
748
|
+
if (!waves || !settings.enabled) return /* @__PURE__ */jsx4(Fragment2, {
|
|
749
|
+
children
|
|
750
|
+
});
|
|
751
|
+
const radius = rippleRadiusFor(size.width, size.height);
|
|
752
|
+
return /* @__PURE__ */jsxs3(Fragment2, {
|
|
753
|
+
children: [/* @__PURE__ */jsx4(View3, {
|
|
754
|
+
style: [StyleSheet3.absoluteFill, styles.clip, corners],
|
|
755
|
+
onLayout: handleLayout,
|
|
756
|
+
children: waves.map((wave, index) => /* @__PURE__ */jsx4(RippleWave, {
|
|
757
|
+
wave,
|
|
758
|
+
radius,
|
|
759
|
+
center: {
|
|
760
|
+
x: size.width / 2,
|
|
761
|
+
y: size.height / 2
|
|
762
|
+
},
|
|
763
|
+
color: ink,
|
|
764
|
+
opacity: settings.opacity,
|
|
765
|
+
style
|
|
766
|
+
}, index))
|
|
767
|
+
}), children]
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
PressableFeedbackRipple.displayName = "XAUI.PressableFeedback.Ripple";
|
|
771
|
+
markOverlay(PressableFeedbackRipple);
|
|
772
|
+
const _worklet_7503622698860_init_data = {
|
|
773
|
+
code: "function chunkB3EAZ2CCJs6(){const{wave,RIPPLE_START_SCALE,center,opacity,radius}=this.__closure;const t=wave.expand.value;const from=wave.origin.value;const scale=RIPPLE_START_SCALE+(1-RIPPLE_START_SCALE)*t;const x=from.x+(center.x-from.x)*t;const y=from.y+(center.y-from.y)*t;return{opacity:wave.alpha.value*opacity,transform:[{translateX:x-radius},{translateY:y-radius},{scale:scale}]};}",
|
|
774
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js",
|
|
775
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkB3EAZ2CCJs6\",\"wave\",\"RIPPLE_START_SCALE\",\"center\",\"opacity\",\"radius\",\"__closure\",\"t\",\"expand\",\"value\",\"from\",\"origin\",\"scale\",\"x\",\"y\",\"alpha\",\"transform\",\"translateX\",\"translateY\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-B3EAZ2CC.js\"],\"mappings\":\"AAsuB0C,SAAAA,gBAAMA,CAAA,QAAAC,IAAA,CAAAC,kBAAA,CAAAC,MAAA,CAAAC,OAAA,CAAAC,MAAA,OAAAC,SAAA,CAE5C,KAAM,CAAAC,CAAC,CAAGN,IAAI,CAACO,MAAM,CAACC,KAAK,CAC3B,KAAM,CAAAC,IAAI,CAAGT,IAAI,CAACU,MAAM,CAACF,KAAK,CAC9B,KAAM,CAAAG,KAAK,CAAGV,kBAAkB,CAAG,CAAC,CAAC,CAAGA,kBAAkB,EAAIK,CAAC,CAC/D,KAAM,CAAAM,CAAC,CAAGH,IAAI,CAACG,CAAC,CAAG,CAACV,MAAM,CAACU,CAAC,CAAGH,IAAI,CAACG,CAAC,EAAIN,CAAC,CAC1C,KAAM,CAAAO,CAAC,CAAGJ,IAAI,CAACI,CAAC,CAAG,CAACX,MAAM,CAACW,CAAC,CAAGJ,IAAI,CAACI,CAAC,EAAIP,CAAC,CAC1C,MAAO,CAELH,OAAO,CAAEH,IAAI,CAACc,KAAK,CAACN,KAAK,CAAGL,OAAO,CACnCY,SAAS,CAAE,CAAC,CAAEC,UAAU,CAAEJ,CAAC,CAAGR,MAAO,CAAC,CAAE,CAAEa,UAAU,CAAEJ,CAAC,CAAGT,MAAO,CAAC,CAAE,CAAEO,KAAA,CAAAA,KAAM,CAAC,CAC/E,CAAC,CACH\",\"ignoreList\":[]}"
|
|
776
|
+
};
|
|
777
|
+
function RippleWave({
|
|
778
|
+
wave,
|
|
779
|
+
radius,
|
|
780
|
+
center,
|
|
781
|
+
color,
|
|
782
|
+
opacity,
|
|
783
|
+
style
|
|
784
|
+
}) {
|
|
785
|
+
const animatedStyle = useAnimatedStyle3(function chunkB3EAZ2CCJs6Factory({
|
|
786
|
+
_worklet_7503622698860_init_data,
|
|
787
|
+
wave,
|
|
788
|
+
RIPPLE_START_SCALE,
|
|
789
|
+
center,
|
|
790
|
+
opacity,
|
|
791
|
+
radius
|
|
792
|
+
}) {
|
|
793
|
+
const _e = [new global.Error(), -6, -27];
|
|
794
|
+
const chunkB3EAZ2CCJs6 = function () {
|
|
795
|
+
const t = wave.expand.value;
|
|
796
|
+
const from = wave.origin.value;
|
|
797
|
+
const scale = RIPPLE_START_SCALE + (1 - RIPPLE_START_SCALE) * t;
|
|
798
|
+
const x = from.x + (center.x - from.x) * t;
|
|
799
|
+
const y = from.y + (center.y - from.y) * t;
|
|
800
|
+
return {
|
|
801
|
+
// Its own curve, not the expansion's: full ink in 75ms, held while the circle grows.
|
|
802
|
+
opacity: wave.alpha.value * opacity,
|
|
803
|
+
transform: [{
|
|
804
|
+
translateX: x - radius
|
|
805
|
+
}, {
|
|
806
|
+
translateY: y - radius
|
|
807
|
+
}, {
|
|
808
|
+
scale
|
|
809
|
+
}]
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
chunkB3EAZ2CCJs6.__closure = {
|
|
813
|
+
wave,
|
|
814
|
+
RIPPLE_START_SCALE,
|
|
815
|
+
center,
|
|
816
|
+
opacity,
|
|
817
|
+
radius
|
|
818
|
+
};
|
|
819
|
+
chunkB3EAZ2CCJs6.__workletHash = 7503622698860;
|
|
820
|
+
chunkB3EAZ2CCJs6.__pluginVersion = "0.7.4";
|
|
821
|
+
chunkB3EAZ2CCJs6.__initData = _worklet_7503622698860_init_data;
|
|
822
|
+
chunkB3EAZ2CCJs6.__stackDetails = _e;
|
|
823
|
+
return chunkB3EAZ2CCJs6;
|
|
824
|
+
}({
|
|
825
|
+
_worklet_7503622698860_init_data,
|
|
826
|
+
wave,
|
|
827
|
+
RIPPLE_START_SCALE,
|
|
828
|
+
center,
|
|
829
|
+
opacity,
|
|
830
|
+
radius
|
|
831
|
+
}), [wave, radius, center, opacity]);
|
|
832
|
+
return /* @__PURE__ */jsx4(Animated3.View, {
|
|
833
|
+
style: [styles.wave, {
|
|
834
|
+
backgroundColor: color,
|
|
835
|
+
width: radius * 2,
|
|
836
|
+
height: radius * 2,
|
|
837
|
+
borderRadius: radius
|
|
838
|
+
}, style, animatedStyle]
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
var styles = StyleSheet3.create({
|
|
842
|
+
// `pointerEvents` in the style rather than as a prop: the prop form is deprecated, and it
|
|
843
|
+
// is not decoration — a container that ate touches would claim every press meant for the
|
|
844
|
+
// control it covers.
|
|
845
|
+
clip: {
|
|
846
|
+
overflow: "hidden",
|
|
847
|
+
pointerEvents: "none"
|
|
848
|
+
},
|
|
849
|
+
wave: {
|
|
850
|
+
position: "absolute",
|
|
851
|
+
top: 0,
|
|
852
|
+
start: 0
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
// src/system/pressable-feedback/index.ts
|
|
857
|
+
var PressableFeedback3 = Object.assign(PressableFeedback, {
|
|
858
|
+
Highlight: PressableFeedbackHighlight,
|
|
859
|
+
Ripple: PressableFeedbackRipple
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// src/system/recipe/resolve-tint.ts
|
|
863
|
+
var TINT_SLICE_BY_SUFFIX = [[/SoftForeground$/, "softForeground"], [/SoftPressed$/, "softPressed"], [/Soft$/, "soft"], [/Foreground$/, "foreground"], [/Pressed$/, "pressed"]];
|
|
864
|
+
function tintSliceFor(token) {
|
|
865
|
+
for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
|
|
866
|
+
if (suffix.test(token)) return slice;
|
|
867
|
+
}
|
|
868
|
+
return "base";
|
|
869
|
+
}
|
|
870
|
+
function resolveTint(tokens, color, theme) {
|
|
871
|
+
const tint = deriveTint(color, theme);
|
|
872
|
+
const colors = {};
|
|
873
|
+
for (const [role, token] of Object.entries(tokens ?? {})) {
|
|
874
|
+
colors[role] = tint[tintSliceFor(token)];
|
|
875
|
+
}
|
|
876
|
+
return colors;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/system/recipe/style-cache.ts
|
|
880
|
+
import { StyleSheet as StyleSheet4 } from "react-native";
|
|
881
|
+
|
|
882
|
+
// src/system/recipe/variant-map.ts
|
|
883
|
+
var STATE_ORDER = ["focused", "pressed", "disabled"];
|
|
884
|
+
function resolveSelection(defaultVariants, selection) {
|
|
885
|
+
const resolved = {
|
|
886
|
+
...defaultVariants
|
|
887
|
+
};
|
|
888
|
+
for (const [axis, value] of Object.entries(selection ?? {})) {
|
|
889
|
+
if (value !== void 0) resolved[axis] = value;
|
|
890
|
+
}
|
|
891
|
+
return resolved;
|
|
892
|
+
}
|
|
893
|
+
function resolveVariantColors(tokens, theme) {
|
|
894
|
+
const colors = {};
|
|
895
|
+
for (const [role, token] of entriesOf(tokens)) {
|
|
896
|
+
const value = theme.colors[token];
|
|
897
|
+
if (value === void 0) {
|
|
898
|
+
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.`);
|
|
899
|
+
}
|
|
900
|
+
colors[role] = value;
|
|
901
|
+
}
|
|
902
|
+
return colors;
|
|
903
|
+
}
|
|
904
|
+
function activeStateFns(states, active) {
|
|
905
|
+
const fns = [];
|
|
906
|
+
for (const state of STATE_ORDER) {
|
|
907
|
+
const fn = active[state] ? states?.[state] : void 0;
|
|
908
|
+
if (fn) fns.push(fn);
|
|
909
|
+
}
|
|
910
|
+
return fns;
|
|
911
|
+
}
|
|
912
|
+
function collectStyleFns(config, selection, states) {
|
|
913
|
+
const fns = [];
|
|
914
|
+
if (config.base) fns.push(config.base);
|
|
915
|
+
if (config.paint) fns.push(config.paint);
|
|
916
|
+
for (const [axis, values] of Object.entries(config.variants ?? {})) {
|
|
917
|
+
const value = selection[axis];
|
|
918
|
+
const fn = value === void 0 ? void 0 : values[value];
|
|
919
|
+
if (fn) fns.push(fn);
|
|
920
|
+
}
|
|
921
|
+
for (const compound of config.compoundVariants ?? []) {
|
|
922
|
+
if (appliesTo(compound.when, selection)) fns.push(compound.style);
|
|
923
|
+
}
|
|
924
|
+
return [...fns, ...activeStateFns(config.states, states)];
|
|
925
|
+
}
|
|
926
|
+
function appliesTo(when, selection) {
|
|
927
|
+
return Object.entries(when).every(([axis, value]) => selection[axis] === value);
|
|
928
|
+
}
|
|
929
|
+
function entriesOf(tokens) {
|
|
930
|
+
return Object.entries(tokens ?? {});
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/system/recipe/style-cache.ts
|
|
934
|
+
function createStyleCache(slots) {
|
|
935
|
+
const entries = /* @__PURE__ */new Map();
|
|
936
|
+
return {
|
|
937
|
+
read(key, build) {
|
|
938
|
+
const hit = entries.get(key);
|
|
939
|
+
if (hit) return hit;
|
|
940
|
+
const built = build();
|
|
941
|
+
const complete = {};
|
|
942
|
+
for (const slot of slots) complete[slot] = built[slot] ?? {};
|
|
943
|
+
const created = StyleSheet4.create(complete);
|
|
944
|
+
entries.set(key, created);
|
|
945
|
+
return created;
|
|
946
|
+
},
|
|
947
|
+
get size() {
|
|
948
|
+
return entries.size;
|
|
949
|
+
},
|
|
950
|
+
clear() {
|
|
951
|
+
entries.clear();
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
function cacheKey(theme, selection, states) {
|
|
956
|
+
const axes = Object.keys(selection).sort().map(axis => `${axis}:${selection[axis] ?? "-"}`).join("|");
|
|
957
|
+
const active = STATE_ORDER.filter(state => states[state]).join(",");
|
|
958
|
+
return `${theme.id}|${theme.mode}|${axes}|${active}`;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// src/system/recipe/create-recipe.ts
|
|
962
|
+
function createRecipe(config) {
|
|
963
|
+
const cache = createStyleCache(config.slots);
|
|
964
|
+
const tokensFor = variant => variant === void 0 ? void 0 : config.variantTokens?.[variant];
|
|
965
|
+
return {
|
|
966
|
+
slots: config.slots,
|
|
967
|
+
resolve({
|
|
968
|
+
theme,
|
|
969
|
+
selection,
|
|
970
|
+
states = {}
|
|
971
|
+
}) {
|
|
972
|
+
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
973
|
+
return cache.read(cacheKey(theme, resolved, states), () => {
|
|
974
|
+
const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
|
|
975
|
+
return apply(collectStyleFns(config, resolved, states), theme, colors);
|
|
976
|
+
});
|
|
977
|
+
},
|
|
978
|
+
tint({
|
|
979
|
+
theme,
|
|
980
|
+
color,
|
|
981
|
+
selection,
|
|
982
|
+
states = {}
|
|
983
|
+
}) {
|
|
984
|
+
if (!config.paint) return {};
|
|
985
|
+
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
986
|
+
const tokens = tokensFor(resolved.variant);
|
|
987
|
+
if (!tokens) return {};
|
|
988
|
+
const colors = resolveTint(tokens, color, theme);
|
|
989
|
+
const fns = [config.paint, ...activeStateFns(config.states, states)];
|
|
990
|
+
return apply(fns, theme, colors);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
function apply(fns, theme, colors) {
|
|
995
|
+
const merged = {};
|
|
996
|
+
for (const fn of fns) {
|
|
997
|
+
const produced = fn(theme, colors);
|
|
998
|
+
for (const slot of Object.keys(produced)) {
|
|
999
|
+
const style = produced[slot];
|
|
1000
|
+
if (!style) continue;
|
|
1001
|
+
const previous = merged[slot];
|
|
1002
|
+
merged[slot] = previous ? {
|
|
1003
|
+
...previous,
|
|
1004
|
+
...style
|
|
1005
|
+
} : style;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return merged;
|
|
1009
|
+
}
|
|
1010
|
+
export { IconContext, useIconContext, Icon, childrenToString, createSlotContext, mergeRefs, mergeProps, Slot, useStyleProps, useFeedback, PRESS_SCALE, PRESS_DURATION, SCALE_REFERENCE_WIDTH, pressScaleFor, HIGHLIGHT_OPACITY, HIGHLIGHT_DURATION, RIPPLE_OPACITY, RIPPLE_START_SCALE, RIPPLE_EXPAND_DURATION, RIPPLE_CONFIRM_DURATION, RIPPLE_FADE_IN, RIPPLE_FADE_OUT_DELAY, RIPPLE_FADE_OUT, rippleRadiusFor, resolveAnimation, resolveSlotAnimation, FEEDBACK_OVERLAY, markOverlay, PressableFeedback3 as PressableFeedback, createRecipe };
|