@xsolla/xui-button 0.199.0 → 0.201.0
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/native/index.js +66 -5
- package/native/index.js.map +1 -1
- package/native/index.mjs +66 -5
- package/native/index.mjs.map +1 -1
- package/package.json +4 -4
package/native/index.js
CHANGED
|
@@ -45,6 +45,38 @@ var import_react2 = __toESM(require("react"));
|
|
|
45
45
|
// ../../foundation/primitives-native/src/Box.tsx
|
|
46
46
|
var import_react_native = require("react-native");
|
|
47
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var roleToAccessibilityRole = {
|
|
49
|
+
button: "button",
|
|
50
|
+
link: "link",
|
|
51
|
+
img: "image",
|
|
52
|
+
image: "image",
|
|
53
|
+
summary: "summary",
|
|
54
|
+
switch: "switch",
|
|
55
|
+
checkbox: "checkbox",
|
|
56
|
+
radio: "radio",
|
|
57
|
+
heading: "header",
|
|
58
|
+
text: "text",
|
|
59
|
+
search: "search",
|
|
60
|
+
alert: "alert",
|
|
61
|
+
none: "none",
|
|
62
|
+
presentation: "none",
|
|
63
|
+
progressbar: "progressbar",
|
|
64
|
+
scrollbar: "scrollbar",
|
|
65
|
+
adjustable: "adjustable",
|
|
66
|
+
tab: "tab",
|
|
67
|
+
menu: "menu",
|
|
68
|
+
menuitem: "menuitem",
|
|
69
|
+
list: "list",
|
|
70
|
+
timer: "timer"
|
|
71
|
+
};
|
|
72
|
+
var toGapValue = (gap) => {
|
|
73
|
+
if (gap === void 0) return void 0;
|
|
74
|
+
if (typeof gap === "number") return gap;
|
|
75
|
+
const pxMatch = /^(\d+(?:\.\d+)?)px$/.exec(gap);
|
|
76
|
+
if (pxMatch) return Number(pxMatch[1]);
|
|
77
|
+
const asNumber = Number(gap);
|
|
78
|
+
return Number.isFinite(asNumber) ? asNumber : void 0;
|
|
79
|
+
};
|
|
48
80
|
var Box = ({
|
|
49
81
|
children,
|
|
50
82
|
onPress,
|
|
@@ -77,8 +109,10 @@ var Box = ({
|
|
|
77
109
|
marginLeft,
|
|
78
110
|
marginRight,
|
|
79
111
|
flexDirection,
|
|
112
|
+
flexWrap,
|
|
80
113
|
alignItems,
|
|
81
114
|
justifyContent,
|
|
115
|
+
alignSelf,
|
|
82
116
|
position,
|
|
83
117
|
top,
|
|
84
118
|
bottom,
|
|
@@ -90,11 +124,14 @@ var Box = ({
|
|
|
90
124
|
maxWidth,
|
|
91
125
|
maxHeight,
|
|
92
126
|
flex,
|
|
127
|
+
flexShrink,
|
|
128
|
+
gap,
|
|
93
129
|
overflow,
|
|
94
130
|
zIndex,
|
|
95
131
|
hoverStyle,
|
|
96
132
|
pressStyle,
|
|
97
133
|
style,
|
|
134
|
+
disabled,
|
|
98
135
|
"data-testid": dataTestId,
|
|
99
136
|
testID,
|
|
100
137
|
as,
|
|
@@ -133,14 +170,18 @@ var Box = ({
|
|
|
133
170
|
marginLeft,
|
|
134
171
|
marginRight,
|
|
135
172
|
flexDirection,
|
|
173
|
+
flexWrap,
|
|
136
174
|
alignItems,
|
|
137
175
|
justifyContent,
|
|
176
|
+
alignSelf,
|
|
138
177
|
position,
|
|
139
178
|
top,
|
|
140
179
|
bottom,
|
|
141
180
|
left,
|
|
142
181
|
right,
|
|
143
182
|
flex,
|
|
183
|
+
flexShrink,
|
|
184
|
+
gap: toGapValue(gap),
|
|
144
185
|
...style
|
|
145
186
|
});
|
|
146
187
|
const finalTestID = dataTestId || testID;
|
|
@@ -149,15 +190,25 @@ var Box = ({
|
|
|
149
190
|
tabIndex,
|
|
150
191
|
onKeyDown,
|
|
151
192
|
onKeyUp,
|
|
152
|
-
"aria-label":
|
|
193
|
+
"aria-label": ariaLabel,
|
|
153
194
|
"aria-labelledby": _ariaLabelledBy,
|
|
154
195
|
"aria-current": _ariaCurrent,
|
|
155
|
-
"aria-disabled":
|
|
156
|
-
"aria-live":
|
|
196
|
+
"aria-disabled": ariaDisabled,
|
|
197
|
+
"aria-live": ariaLive,
|
|
198
|
+
"aria-busy": ariaBusy,
|
|
157
199
|
className,
|
|
158
200
|
"data-testid": _dataTestId,
|
|
201
|
+
cursor: _cursor,
|
|
202
|
+
type: _type,
|
|
159
203
|
...nativeRest
|
|
160
204
|
} = rest;
|
|
205
|
+
const accessibilityRole = typeof role === "string" && roleToAccessibilityRole[role] || (as === "button" ? "button" : void 0);
|
|
206
|
+
const isDisabled = Boolean(disabled || ariaDisabled);
|
|
207
|
+
const accessibilityState = {
|
|
208
|
+
disabled: isDisabled || void 0,
|
|
209
|
+
busy: Boolean(ariaBusy) || void 0
|
|
210
|
+
};
|
|
211
|
+
const accessibilityLiveRegion = ariaLive === "polite" || ariaLive === "assertive" ? ariaLive : void 0;
|
|
161
212
|
if (as === "img" && src) {
|
|
162
213
|
const imageStyle = {
|
|
163
214
|
width,
|
|
@@ -176,16 +227,18 @@ var Box = ({
|
|
|
176
227
|
source: { uri: src },
|
|
177
228
|
style: imageStyle,
|
|
178
229
|
testID: finalTestID,
|
|
230
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : alt,
|
|
179
231
|
resizeMode: "cover",
|
|
180
232
|
...nativeRest
|
|
181
233
|
}
|
|
182
234
|
);
|
|
183
235
|
}
|
|
184
|
-
if (onPress) {
|
|
236
|
+
if (onPress || as === "button") {
|
|
185
237
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
186
238
|
import_react_native.Pressable,
|
|
187
239
|
{
|
|
188
|
-
onPress,
|
|
240
|
+
onPress: !isDisabled && onPress ? onPress : void 0,
|
|
241
|
+
disabled: isDisabled,
|
|
189
242
|
onLayout,
|
|
190
243
|
onMoveShouldSetResponder,
|
|
191
244
|
onResponderGrant,
|
|
@@ -194,6 +247,10 @@ var Box = ({
|
|
|
194
247
|
onResponderTerminate,
|
|
195
248
|
style: ({ pressed }) => getContainerStyle(pressed),
|
|
196
249
|
testID: finalTestID,
|
|
250
|
+
accessibilityRole,
|
|
251
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
|
|
252
|
+
accessibilityState,
|
|
253
|
+
accessibilityLiveRegion,
|
|
197
254
|
...nativeRest,
|
|
198
255
|
children
|
|
199
256
|
}
|
|
@@ -210,6 +267,10 @@ var Box = ({
|
|
|
210
267
|
onResponderMove,
|
|
211
268
|
onResponderRelease,
|
|
212
269
|
onResponderTerminate,
|
|
270
|
+
accessibilityRole,
|
|
271
|
+
accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
|
|
272
|
+
accessibilityState,
|
|
273
|
+
accessibilityLiveRegion,
|
|
213
274
|
...nativeRest,
|
|
214
275
|
children
|
|
215
276
|
}
|