@xsolla/xui-button 0.64.0-pr56.1768440195
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.d.mts +249 -0
- package/native/index.d.ts +249 -0
- package/native/index.js +1272 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +1236 -0
- package/native/index.mjs.map +1 -0
- package/package.json +47 -0
- package/web/index.d.mts +249 -0
- package/web/index.d.ts +249 -0
- package/web/index.js +1227 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +1187 -0
- package/web/index.mjs.map +1 -0
package/web/index.mjs
ADDED
|
@@ -0,0 +1,1187 @@
|
|
|
1
|
+
// src/Button.tsx
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
// ../primitives-web/src/Box.tsx
|
|
5
|
+
import React from "react";
|
|
6
|
+
import styled from "styled-components";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var StyledBox = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
12
|
+
border-color: ${(props) => props.borderColor || "transparent"};
|
|
13
|
+
border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
|
|
14
|
+
|
|
15
|
+
${(props) => props.borderBottomWidth !== void 0 && `
|
|
16
|
+
border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
|
|
17
|
+
border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
|
|
18
|
+
border-bottom-style: solid;
|
|
19
|
+
`}
|
|
20
|
+
${(props) => props.borderTopWidth !== void 0 && `
|
|
21
|
+
border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
|
|
22
|
+
border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
|
|
23
|
+
border-top-style: solid;
|
|
24
|
+
`}
|
|
25
|
+
${(props) => props.borderLeftWidth !== void 0 && `
|
|
26
|
+
border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
|
|
27
|
+
border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
|
|
28
|
+
border-left-style: solid;
|
|
29
|
+
`}
|
|
30
|
+
${(props) => props.borderRightWidth !== void 0 && `
|
|
31
|
+
border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
|
|
32
|
+
border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
|
|
33
|
+
border-right-style: solid;
|
|
34
|
+
`}
|
|
35
|
+
|
|
36
|
+
border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
|
|
37
|
+
border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
|
|
38
|
+
height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
|
|
39
|
+
width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
|
|
40
|
+
min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
|
|
41
|
+
min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
|
|
42
|
+
|
|
43
|
+
padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
|
|
44
|
+
${(props) => props.paddingHorizontal && `
|
|
45
|
+
padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
46
|
+
padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
47
|
+
`}
|
|
48
|
+
${(props) => props.paddingVertical && `
|
|
49
|
+
padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
50
|
+
padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
51
|
+
`}
|
|
52
|
+
${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
|
|
53
|
+
${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
|
|
54
|
+
${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
|
|
55
|
+
${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
|
|
56
|
+
|
|
57
|
+
margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
|
|
58
|
+
${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
|
|
59
|
+
${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
|
|
60
|
+
${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
|
|
61
|
+
${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
|
|
62
|
+
|
|
63
|
+
flex-direction: ${(props) => props.flexDirection || "column"};
|
|
64
|
+
flex-wrap: ${(props) => props.flexWrap || "nowrap"};
|
|
65
|
+
align-items: ${(props) => props.alignItems || "stretch"};
|
|
66
|
+
justify-content: ${(props) => props.justifyContent || "flex-start"};
|
|
67
|
+
cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
|
|
68
|
+
position: ${(props) => props.position || "static"};
|
|
69
|
+
top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
|
|
70
|
+
bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
|
|
71
|
+
left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
|
|
72
|
+
right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
|
|
73
|
+
flex: ${(props) => props.flex};
|
|
74
|
+
flex-shrink: ${(props) => props.flexShrink ?? 1};
|
|
75
|
+
gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
|
|
76
|
+
align-self: ${(props) => props.alignSelf || "auto"};
|
|
77
|
+
overflow: ${(props) => props.overflow || "visible"};
|
|
78
|
+
overflow-x: ${(props) => props.overflowX || "visible"};
|
|
79
|
+
overflow-y: ${(props) => props.overflowY || "visible"};
|
|
80
|
+
z-index: ${(props) => props.zIndex};
|
|
81
|
+
opacity: ${(props) => props.disabled ? 0.5 : 1};
|
|
82
|
+
pointer-events: ${(props) => props.disabled ? "none" : "auto"};
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
|
|
86
|
+
${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:active {
|
|
90
|
+
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
var Box = React.forwardRef(
|
|
94
|
+
({
|
|
95
|
+
children,
|
|
96
|
+
onPress,
|
|
97
|
+
onKeyDown,
|
|
98
|
+
onKeyUp,
|
|
99
|
+
role,
|
|
100
|
+
"aria-label": ariaLabel,
|
|
101
|
+
"aria-labelledby": ariaLabelledBy,
|
|
102
|
+
"aria-current": ariaCurrent,
|
|
103
|
+
"aria-disabled": ariaDisabled,
|
|
104
|
+
"aria-live": ariaLive,
|
|
105
|
+
"aria-busy": ariaBusy,
|
|
106
|
+
"aria-describedby": ariaDescribedBy,
|
|
107
|
+
"aria-expanded": ariaExpanded,
|
|
108
|
+
"aria-haspopup": ariaHasPopup,
|
|
109
|
+
"aria-pressed": ariaPressed,
|
|
110
|
+
"aria-controls": ariaControls,
|
|
111
|
+
tabIndex,
|
|
112
|
+
as,
|
|
113
|
+
src,
|
|
114
|
+
alt,
|
|
115
|
+
type,
|
|
116
|
+
disabled,
|
|
117
|
+
id,
|
|
118
|
+
...props
|
|
119
|
+
}, ref) => {
|
|
120
|
+
if (as === "img" && src) {
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
"img",
|
|
123
|
+
{
|
|
124
|
+
src,
|
|
125
|
+
alt: alt || "",
|
|
126
|
+
style: {
|
|
127
|
+
display: "block",
|
|
128
|
+
objectFit: "cover",
|
|
129
|
+
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
130
|
+
height: typeof props.height === "number" ? `${props.height}px` : props.height,
|
|
131
|
+
borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
|
|
132
|
+
position: props.position,
|
|
133
|
+
top: typeof props.top === "number" ? `${props.top}px` : props.top,
|
|
134
|
+
left: typeof props.left === "number" ? `${props.left}px` : props.left,
|
|
135
|
+
right: typeof props.right === "number" ? `${props.right}px` : props.right,
|
|
136
|
+
bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
StyledBox,
|
|
143
|
+
{
|
|
144
|
+
ref,
|
|
145
|
+
as,
|
|
146
|
+
id,
|
|
147
|
+
type: as === "button" ? type || "button" : void 0,
|
|
148
|
+
disabled: as === "button" ? disabled : void 0,
|
|
149
|
+
onClick: onPress,
|
|
150
|
+
onKeyDown,
|
|
151
|
+
onKeyUp,
|
|
152
|
+
role,
|
|
153
|
+
"aria-label": ariaLabel,
|
|
154
|
+
"aria-labelledby": ariaLabelledBy,
|
|
155
|
+
"aria-current": ariaCurrent,
|
|
156
|
+
"aria-disabled": ariaDisabled,
|
|
157
|
+
"aria-busy": ariaBusy,
|
|
158
|
+
"aria-describedby": ariaDescribedBy,
|
|
159
|
+
"aria-expanded": ariaExpanded,
|
|
160
|
+
"aria-haspopup": ariaHasPopup,
|
|
161
|
+
"aria-pressed": ariaPressed,
|
|
162
|
+
"aria-controls": ariaControls,
|
|
163
|
+
"aria-live": ariaLive,
|
|
164
|
+
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
165
|
+
...props,
|
|
166
|
+
children
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
Box.displayName = "Box";
|
|
172
|
+
|
|
173
|
+
// ../primitives-web/src/Text.tsx
|
|
174
|
+
import styled2 from "styled-components";
|
|
175
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
176
|
+
var StyledText = styled2.span`
|
|
177
|
+
color: ${(props) => props.color || "inherit"};
|
|
178
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
179
|
+
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
180
|
+
font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
|
|
181
|
+
line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
|
|
182
|
+
white-space: ${(props) => props.whiteSpace || "normal"};
|
|
183
|
+
text-align: ${(props) => props.textAlign || "inherit"};
|
|
184
|
+
text-decoration: ${(props) => props.textDecoration || "none"};
|
|
185
|
+
`;
|
|
186
|
+
var Text = ({
|
|
187
|
+
style,
|
|
188
|
+
className,
|
|
189
|
+
id,
|
|
190
|
+
role,
|
|
191
|
+
...props
|
|
192
|
+
}) => {
|
|
193
|
+
return /* @__PURE__ */ jsx2(
|
|
194
|
+
StyledText,
|
|
195
|
+
{
|
|
196
|
+
...props,
|
|
197
|
+
style,
|
|
198
|
+
className,
|
|
199
|
+
id,
|
|
200
|
+
role
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// ../primitives-web/src/Spinner.tsx
|
|
206
|
+
import styled3, { keyframes } from "styled-components";
|
|
207
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
208
|
+
var rotate = keyframes`
|
|
209
|
+
from {
|
|
210
|
+
transform: rotate(0deg);
|
|
211
|
+
}
|
|
212
|
+
to {
|
|
213
|
+
transform: rotate(360deg);
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
var StyledSpinner = styled3.div`
|
|
217
|
+
width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
218
|
+
height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
219
|
+
border: ${(props) => props.strokeWidth || 2}px solid
|
|
220
|
+
${(props) => props.color || "currentColor"};
|
|
221
|
+
border-bottom-color: transparent;
|
|
222
|
+
border-radius: 50%;
|
|
223
|
+
display: inline-block;
|
|
224
|
+
box-sizing: border-box;
|
|
225
|
+
animation: ${rotate} 1s linear infinite;
|
|
226
|
+
`;
|
|
227
|
+
var Spinner = ({
|
|
228
|
+
role = "status",
|
|
229
|
+
"aria-label": ariaLabel,
|
|
230
|
+
"aria-live": ariaLive = "polite",
|
|
231
|
+
"aria-describedby": ariaDescribedBy,
|
|
232
|
+
testID,
|
|
233
|
+
...props
|
|
234
|
+
}) => {
|
|
235
|
+
return /* @__PURE__ */ jsx3(
|
|
236
|
+
StyledSpinner,
|
|
237
|
+
{
|
|
238
|
+
role,
|
|
239
|
+
"aria-label": ariaLabel,
|
|
240
|
+
"aria-live": ariaLive,
|
|
241
|
+
"aria-describedby": ariaDescribedBy,
|
|
242
|
+
"data-testid": testID,
|
|
243
|
+
...props
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
Spinner.displayName = "Spinner";
|
|
248
|
+
|
|
249
|
+
// ../primitives-web/src/Icon.tsx
|
|
250
|
+
import styled4 from "styled-components";
|
|
251
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
252
|
+
var StyledIcon = styled4.div`
|
|
253
|
+
display: flex;
|
|
254
|
+
align-items: center;
|
|
255
|
+
justify-content: center;
|
|
256
|
+
width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
257
|
+
height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
|
|
258
|
+
color: ${(props) => props.color || "currentColor"};
|
|
259
|
+
|
|
260
|
+
svg {
|
|
261
|
+
width: 100%;
|
|
262
|
+
height: 100%;
|
|
263
|
+
fill: none;
|
|
264
|
+
stroke: currentColor;
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
267
|
+
var Icon = ({ children, ...props }) => {
|
|
268
|
+
return /* @__PURE__ */ jsx4(StyledIcon, { ...props, children });
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// ../primitives-web/src/Divider.tsx
|
|
272
|
+
import styled5 from "styled-components";
|
|
273
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
274
|
+
var StyledDivider = styled5.div`
|
|
275
|
+
background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
|
|
276
|
+
width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
|
|
277
|
+
height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
|
|
278
|
+
|
|
279
|
+
${(props) => props.dashStroke && `
|
|
280
|
+
border-style: dashed;
|
|
281
|
+
border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
|
|
282
|
+
border-width: 0;
|
|
283
|
+
${props.vertical ? `
|
|
284
|
+
border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
|
|
285
|
+
height: 100%;
|
|
286
|
+
` : `
|
|
287
|
+
border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
|
|
288
|
+
width: 100%;
|
|
289
|
+
`}
|
|
290
|
+
`}
|
|
291
|
+
`;
|
|
292
|
+
var Divider = (props) => {
|
|
293
|
+
return /* @__PURE__ */ jsx5(StyledDivider, { ...props });
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// ../primitives-web/src/Input.tsx
|
|
297
|
+
import { forwardRef } from "react";
|
|
298
|
+
import styled6 from "styled-components";
|
|
299
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
300
|
+
var StyledInput = styled6.input`
|
|
301
|
+
background: transparent;
|
|
302
|
+
border: none;
|
|
303
|
+
outline: none;
|
|
304
|
+
width: 100%;
|
|
305
|
+
height: 100%;
|
|
306
|
+
padding: 0;
|
|
307
|
+
margin: 0;
|
|
308
|
+
color: ${(props) => props.color || "inherit"};
|
|
309
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
310
|
+
font-family: inherit;
|
|
311
|
+
text-align: inherit;
|
|
312
|
+
|
|
313
|
+
&::placeholder {
|
|
314
|
+
color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
&:disabled {
|
|
318
|
+
cursor: not-allowed;
|
|
319
|
+
}
|
|
320
|
+
`;
|
|
321
|
+
var InputPrimitive = forwardRef(
|
|
322
|
+
({
|
|
323
|
+
value,
|
|
324
|
+
placeholder,
|
|
325
|
+
onChange,
|
|
326
|
+
onChangeText,
|
|
327
|
+
onFocus,
|
|
328
|
+
onBlur,
|
|
329
|
+
onKeyDown,
|
|
330
|
+
disabled,
|
|
331
|
+
secureTextEntry,
|
|
332
|
+
style,
|
|
333
|
+
color,
|
|
334
|
+
fontSize,
|
|
335
|
+
placeholderTextColor,
|
|
336
|
+
maxLength,
|
|
337
|
+
name,
|
|
338
|
+
type,
|
|
339
|
+
inputMode,
|
|
340
|
+
autoComplete,
|
|
341
|
+
id,
|
|
342
|
+
"aria-invalid": ariaInvalid,
|
|
343
|
+
"aria-describedby": ariaDescribedBy,
|
|
344
|
+
"aria-labelledby": ariaLabelledBy,
|
|
345
|
+
"aria-label": ariaLabel,
|
|
346
|
+
"aria-disabled": ariaDisabled,
|
|
347
|
+
"data-testid": dataTestId,
|
|
348
|
+
...rest
|
|
349
|
+
}, ref) => {
|
|
350
|
+
const handleChange = (e) => {
|
|
351
|
+
if (onChange) {
|
|
352
|
+
onChange(e);
|
|
353
|
+
}
|
|
354
|
+
if (onChangeText) {
|
|
355
|
+
onChangeText(e.target.value);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const inputValue = value !== void 0 ? value : "";
|
|
359
|
+
return /* @__PURE__ */ jsx6(
|
|
360
|
+
StyledInput,
|
|
361
|
+
{
|
|
362
|
+
ref,
|
|
363
|
+
id,
|
|
364
|
+
value: inputValue,
|
|
365
|
+
name,
|
|
366
|
+
placeholder,
|
|
367
|
+
onChange: handleChange,
|
|
368
|
+
onFocus,
|
|
369
|
+
onBlur,
|
|
370
|
+
onKeyDown,
|
|
371
|
+
disabled,
|
|
372
|
+
type: secureTextEntry ? "password" : type || "text",
|
|
373
|
+
inputMode,
|
|
374
|
+
autoComplete,
|
|
375
|
+
style,
|
|
376
|
+
color,
|
|
377
|
+
fontSize,
|
|
378
|
+
placeholderTextColor,
|
|
379
|
+
maxLength,
|
|
380
|
+
"aria-invalid": ariaInvalid,
|
|
381
|
+
"aria-describedby": ariaDescribedBy,
|
|
382
|
+
"aria-labelledby": ariaLabelledBy,
|
|
383
|
+
"aria-label": ariaLabel,
|
|
384
|
+
"aria-disabled": ariaDisabled,
|
|
385
|
+
"data-testid": dataTestId,
|
|
386
|
+
...rest
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
InputPrimitive.displayName = "InputPrimitive";
|
|
392
|
+
|
|
393
|
+
// ../primitives-web/src/TextArea.tsx
|
|
394
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
395
|
+
import styled7 from "styled-components";
|
|
396
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
397
|
+
var StyledTextArea = styled7.textarea`
|
|
398
|
+
background: transparent;
|
|
399
|
+
border: none;
|
|
400
|
+
outline: none;
|
|
401
|
+
width: 100%;
|
|
402
|
+
height: 100%;
|
|
403
|
+
padding: 0;
|
|
404
|
+
margin: 0;
|
|
405
|
+
color: ${(props) => props.color || "inherit"};
|
|
406
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
407
|
+
font-family: inherit;
|
|
408
|
+
text-align: inherit;
|
|
409
|
+
resize: none;
|
|
410
|
+
|
|
411
|
+
&::placeholder {
|
|
412
|
+
color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
&:disabled {
|
|
416
|
+
cursor: not-allowed;
|
|
417
|
+
}
|
|
418
|
+
`;
|
|
419
|
+
var TextAreaPrimitive = forwardRef2(
|
|
420
|
+
({
|
|
421
|
+
value,
|
|
422
|
+
placeholder,
|
|
423
|
+
onChangeText,
|
|
424
|
+
onFocus,
|
|
425
|
+
onBlur,
|
|
426
|
+
onKeyDown,
|
|
427
|
+
disabled,
|
|
428
|
+
style,
|
|
429
|
+
color,
|
|
430
|
+
fontSize,
|
|
431
|
+
placeholderTextColor,
|
|
432
|
+
maxLength,
|
|
433
|
+
rows
|
|
434
|
+
}, ref) => {
|
|
435
|
+
return /* @__PURE__ */ jsx7(
|
|
436
|
+
StyledTextArea,
|
|
437
|
+
{
|
|
438
|
+
ref,
|
|
439
|
+
value,
|
|
440
|
+
placeholder,
|
|
441
|
+
onChange: (e) => onChangeText?.(e.target.value),
|
|
442
|
+
onFocus,
|
|
443
|
+
onBlur,
|
|
444
|
+
onKeyDown,
|
|
445
|
+
disabled,
|
|
446
|
+
style,
|
|
447
|
+
color,
|
|
448
|
+
fontSize,
|
|
449
|
+
placeholderTextColor,
|
|
450
|
+
maxLength,
|
|
451
|
+
rows
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
TextAreaPrimitive.displayName = "TextAreaPrimitive";
|
|
457
|
+
|
|
458
|
+
// src/Button.tsx
|
|
459
|
+
import { useDesignSystem } from "@xsolla/xui-core";
|
|
460
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
461
|
+
var Button = ({
|
|
462
|
+
variant = "primary",
|
|
463
|
+
tone = "brand",
|
|
464
|
+
size = "m",
|
|
465
|
+
disabled = false,
|
|
466
|
+
loading = false,
|
|
467
|
+
children,
|
|
468
|
+
onPress,
|
|
469
|
+
iconLeft,
|
|
470
|
+
iconRight,
|
|
471
|
+
"aria-label": ariaLabel,
|
|
472
|
+
"aria-describedby": ariaDescribedBy,
|
|
473
|
+
"aria-expanded": ariaExpanded,
|
|
474
|
+
"aria-haspopup": ariaHasPopup,
|
|
475
|
+
"aria-pressed": ariaPressed,
|
|
476
|
+
"aria-controls": ariaControls,
|
|
477
|
+
testID,
|
|
478
|
+
id,
|
|
479
|
+
type = "button",
|
|
480
|
+
fullWidth = false
|
|
481
|
+
}) => {
|
|
482
|
+
const { theme } = useDesignSystem();
|
|
483
|
+
const [isKeyboardPressed, setIsKeyboardPressed] = useState(false);
|
|
484
|
+
const isDisabled = disabled || loading;
|
|
485
|
+
const sizeStyles = theme.sizing.button(size);
|
|
486
|
+
const variantStyles = theme?.colors?.control?.[tone]?.[variant] || theme?.colors?.control?.brand?.primary || {
|
|
487
|
+
bg: "transparent",
|
|
488
|
+
text: { primary: "#000" }
|
|
489
|
+
};
|
|
490
|
+
const handlePress = () => {
|
|
491
|
+
if (!isDisabled && onPress) {
|
|
492
|
+
onPress();
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
const handleKeyDown = (e) => {
|
|
496
|
+
if (isDisabled) return;
|
|
497
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
498
|
+
e.preventDefault();
|
|
499
|
+
setIsKeyboardPressed(true);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
const handleKeyUp = (e) => {
|
|
503
|
+
if (isDisabled) return;
|
|
504
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
505
|
+
e.preventDefault();
|
|
506
|
+
setIsKeyboardPressed(false);
|
|
507
|
+
if (onPress) {
|
|
508
|
+
onPress();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
const styles = variantStyles;
|
|
513
|
+
let backgroundColor = styles.bg;
|
|
514
|
+
if (disabled) {
|
|
515
|
+
backgroundColor = styles.bgDisable || styles.bg;
|
|
516
|
+
} else if (isKeyboardPressed) {
|
|
517
|
+
backgroundColor = styles.bgPress || styles.bg;
|
|
518
|
+
}
|
|
519
|
+
const borderColor = disabled ? styles.borderDisable || styles.border : styles.border;
|
|
520
|
+
const textColor = disabled ? styles.text?.disable || styles.text?.primary : styles.text?.primary;
|
|
521
|
+
const isDarkText = textColor === "#000000" || textColor === "black" || textColor.startsWith("rgba(0, 0, 0");
|
|
522
|
+
const dividerColor = isDarkText ? "rgba(0, 0, 0, 0.2)" : "rgba(255, 255, 255, 0.2)";
|
|
523
|
+
const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
|
|
524
|
+
return /* @__PURE__ */ jsxs(
|
|
525
|
+
Box,
|
|
526
|
+
{
|
|
527
|
+
as: "button",
|
|
528
|
+
type,
|
|
529
|
+
id,
|
|
530
|
+
onPress: handlePress,
|
|
531
|
+
onKeyDown: handleKeyDown,
|
|
532
|
+
onKeyUp: handleKeyUp,
|
|
533
|
+
disabled: isDisabled,
|
|
534
|
+
"aria-label": computedAriaLabel,
|
|
535
|
+
"aria-disabled": isDisabled || void 0,
|
|
536
|
+
"aria-busy": loading || void 0,
|
|
537
|
+
"aria-describedby": ariaDescribedBy,
|
|
538
|
+
"aria-expanded": ariaExpanded,
|
|
539
|
+
"aria-haspopup": ariaHasPopup,
|
|
540
|
+
"aria-pressed": ariaPressed,
|
|
541
|
+
"aria-controls": ariaControls,
|
|
542
|
+
testID,
|
|
543
|
+
backgroundColor,
|
|
544
|
+
borderColor,
|
|
545
|
+
borderWidth: borderColor !== "transparent" && borderColor !== "rgba(255, 255, 255, 0)" ? 1 : 0,
|
|
546
|
+
borderRadius: theme.radius.button,
|
|
547
|
+
height: sizeStyles.height,
|
|
548
|
+
width: fullWidth ? "100%" : void 0,
|
|
549
|
+
padding: 0,
|
|
550
|
+
flexDirection: "row",
|
|
551
|
+
alignItems: "center",
|
|
552
|
+
justifyContent: "center",
|
|
553
|
+
position: "relative",
|
|
554
|
+
cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
|
|
555
|
+
opacity: disabled ? 0.6 : 1,
|
|
556
|
+
hoverStyle: !isDisabled ? {
|
|
557
|
+
backgroundColor: variantStyles?.bgHover
|
|
558
|
+
} : void 0,
|
|
559
|
+
pressStyle: !isDisabled ? {
|
|
560
|
+
backgroundColor: variantStyles?.bgPress
|
|
561
|
+
} : void 0,
|
|
562
|
+
focusStyle: {
|
|
563
|
+
outlineColor: theme.colors.border.brand,
|
|
564
|
+
outlineWidth: 2,
|
|
565
|
+
outlineOffset: 2,
|
|
566
|
+
outlineStyle: "solid"
|
|
567
|
+
},
|
|
568
|
+
children: [
|
|
569
|
+
!loading && iconLeft && /* @__PURE__ */ jsxs(
|
|
570
|
+
Box,
|
|
571
|
+
{
|
|
572
|
+
height: "100%",
|
|
573
|
+
flexDirection: "row",
|
|
574
|
+
alignItems: "center",
|
|
575
|
+
justifyContent: "center",
|
|
576
|
+
"aria-hidden": true,
|
|
577
|
+
children: [
|
|
578
|
+
/* @__PURE__ */ jsx8(
|
|
579
|
+
Box,
|
|
580
|
+
{
|
|
581
|
+
alignItems: "center",
|
|
582
|
+
justifyContent: "center",
|
|
583
|
+
paddingHorizontal: sizeStyles.iconPadding,
|
|
584
|
+
children: /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: textColor, children: iconLeft })
|
|
585
|
+
}
|
|
586
|
+
),
|
|
587
|
+
/* @__PURE__ */ jsx8(Divider, { vertical: true, color: dividerColor, height: "100%" })
|
|
588
|
+
]
|
|
589
|
+
}
|
|
590
|
+
),
|
|
591
|
+
/* @__PURE__ */ jsx8(
|
|
592
|
+
Box,
|
|
593
|
+
{
|
|
594
|
+
flex: fullWidth ? 1 : void 0,
|
|
595
|
+
flexDirection: "row",
|
|
596
|
+
alignItems: "center",
|
|
597
|
+
justifyContent: "center",
|
|
598
|
+
paddingHorizontal: loading ? sizeStyles.loadingPadding : sizeStyles.padding,
|
|
599
|
+
height: "100%",
|
|
600
|
+
children: loading ? /* @__PURE__ */ jsx8(
|
|
601
|
+
Spinner,
|
|
602
|
+
{
|
|
603
|
+
color: textColor,
|
|
604
|
+
size: sizeStyles.spinnerSize,
|
|
605
|
+
"aria-hidden": true
|
|
606
|
+
}
|
|
607
|
+
) : /* @__PURE__ */ jsx8(
|
|
608
|
+
Text,
|
|
609
|
+
{
|
|
610
|
+
color: textColor,
|
|
611
|
+
fontSize: sizeStyles.fontSize,
|
|
612
|
+
fontWeight: "500",
|
|
613
|
+
"aria-hidden": computedAriaLabel ? true : void 0,
|
|
614
|
+
children
|
|
615
|
+
}
|
|
616
|
+
)
|
|
617
|
+
}
|
|
618
|
+
),
|
|
619
|
+
!loading && iconRight && /* @__PURE__ */ jsxs(
|
|
620
|
+
Box,
|
|
621
|
+
{
|
|
622
|
+
height: "100%",
|
|
623
|
+
flexDirection: "row",
|
|
624
|
+
alignItems: "center",
|
|
625
|
+
justifyContent: "center",
|
|
626
|
+
"aria-hidden": true,
|
|
627
|
+
children: [
|
|
628
|
+
/* @__PURE__ */ jsx8(Divider, { vertical: true, color: dividerColor, height: "100%" }),
|
|
629
|
+
/* @__PURE__ */ jsx8(
|
|
630
|
+
Box,
|
|
631
|
+
{
|
|
632
|
+
alignItems: "center",
|
|
633
|
+
justifyContent: "center",
|
|
634
|
+
paddingHorizontal: sizeStyles.iconPadding,
|
|
635
|
+
children: /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: textColor, children: iconRight })
|
|
636
|
+
}
|
|
637
|
+
)
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
]
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
};
|
|
645
|
+
Button.displayName = "Button";
|
|
646
|
+
|
|
647
|
+
// src/IconButton.tsx
|
|
648
|
+
import { useState as useState2 } from "react";
|
|
649
|
+
import { useDesignSystem as useDesignSystem2 } from "@xsolla/xui-core";
|
|
650
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
651
|
+
var IconButton = ({
|
|
652
|
+
variant = "primary",
|
|
653
|
+
tone = "brand",
|
|
654
|
+
size = "m",
|
|
655
|
+
disabled = false,
|
|
656
|
+
loading = false,
|
|
657
|
+
icon,
|
|
658
|
+
onPress,
|
|
659
|
+
"aria-label": ariaLabel,
|
|
660
|
+
"aria-describedby": ariaDescribedBy,
|
|
661
|
+
"aria-expanded": ariaExpanded,
|
|
662
|
+
"aria-haspopup": ariaHasPopup,
|
|
663
|
+
"aria-pressed": ariaPressed,
|
|
664
|
+
"aria-controls": ariaControls,
|
|
665
|
+
testID,
|
|
666
|
+
id,
|
|
667
|
+
type = "button"
|
|
668
|
+
}) => {
|
|
669
|
+
const { theme } = useDesignSystem2();
|
|
670
|
+
const [isKeyboardPressed, setIsKeyboardPressed] = useState2(false);
|
|
671
|
+
const isDisabled = disabled || loading;
|
|
672
|
+
const sizeStyles = theme.sizing.button(size);
|
|
673
|
+
const variantStyles = theme?.colors?.control?.[tone]?.[variant] || theme?.colors?.control?.brand?.primary || {
|
|
674
|
+
bg: "transparent",
|
|
675
|
+
text: { primary: "#000" }
|
|
676
|
+
};
|
|
677
|
+
const handlePress = () => {
|
|
678
|
+
if (!isDisabled && onPress) {
|
|
679
|
+
onPress();
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
const handleKeyDown = (e) => {
|
|
683
|
+
if (isDisabled) return;
|
|
684
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
685
|
+
e.preventDefault();
|
|
686
|
+
setIsKeyboardPressed(true);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
const handleKeyUp = (e) => {
|
|
690
|
+
if (isDisabled) return;
|
|
691
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
692
|
+
e.preventDefault();
|
|
693
|
+
setIsKeyboardPressed(false);
|
|
694
|
+
if (onPress) {
|
|
695
|
+
onPress();
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
const styles = variantStyles;
|
|
700
|
+
let backgroundColor = styles.bg;
|
|
701
|
+
if (disabled) {
|
|
702
|
+
backgroundColor = styles.bgDisable || styles.bg;
|
|
703
|
+
} else if (isKeyboardPressed) {
|
|
704
|
+
backgroundColor = styles.bgPress || styles.bg;
|
|
705
|
+
}
|
|
706
|
+
const borderColor = disabled ? styles.borderDisable || styles.border : styles.border;
|
|
707
|
+
const textColor = disabled ? styles.text?.disable || styles.text?.primary : styles.text?.primary;
|
|
708
|
+
return /* @__PURE__ */ jsx9(
|
|
709
|
+
Box,
|
|
710
|
+
{
|
|
711
|
+
as: "button",
|
|
712
|
+
type,
|
|
713
|
+
id,
|
|
714
|
+
onPress: handlePress,
|
|
715
|
+
onKeyDown: handleKeyDown,
|
|
716
|
+
onKeyUp: handleKeyUp,
|
|
717
|
+
disabled: isDisabled,
|
|
718
|
+
"aria-label": ariaLabel,
|
|
719
|
+
"aria-disabled": isDisabled || void 0,
|
|
720
|
+
"aria-busy": loading || void 0,
|
|
721
|
+
"aria-describedby": ariaDescribedBy,
|
|
722
|
+
"aria-expanded": ariaExpanded,
|
|
723
|
+
"aria-haspopup": ariaHasPopup,
|
|
724
|
+
"aria-pressed": ariaPressed,
|
|
725
|
+
"aria-controls": ariaControls,
|
|
726
|
+
testID,
|
|
727
|
+
backgroundColor,
|
|
728
|
+
borderColor,
|
|
729
|
+
borderWidth: borderColor !== "transparent" && borderColor !== "rgba(255, 255, 255, 0)" ? 1 : 0,
|
|
730
|
+
borderRadius: theme.radius.button,
|
|
731
|
+
height: sizeStyles.height,
|
|
732
|
+
width: sizeStyles.height,
|
|
733
|
+
padding: 0,
|
|
734
|
+
flexDirection: "row",
|
|
735
|
+
alignItems: "center",
|
|
736
|
+
justifyContent: "center",
|
|
737
|
+
position: "relative",
|
|
738
|
+
cursor: disabled ? "not-allowed" : loading ? "wait" : "pointer",
|
|
739
|
+
opacity: disabled ? 0.6 : 1,
|
|
740
|
+
hoverStyle: !isDisabled ? {
|
|
741
|
+
backgroundColor: styles.bgHover
|
|
742
|
+
} : void 0,
|
|
743
|
+
pressStyle: !isDisabled ? {
|
|
744
|
+
backgroundColor: styles.bgPress
|
|
745
|
+
} : void 0,
|
|
746
|
+
focusStyle: {
|
|
747
|
+
outlineColor: theme.colors.border.brand,
|
|
748
|
+
outlineWidth: 2,
|
|
749
|
+
outlineOffset: 2,
|
|
750
|
+
outlineStyle: "solid"
|
|
751
|
+
},
|
|
752
|
+
children: loading ? /* @__PURE__ */ jsx9(
|
|
753
|
+
Spinner,
|
|
754
|
+
{
|
|
755
|
+
color: textColor,
|
|
756
|
+
size: sizeStyles.spinnerSize,
|
|
757
|
+
"aria-hidden": true
|
|
758
|
+
}
|
|
759
|
+
) : /* @__PURE__ */ jsx9(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: icon })
|
|
760
|
+
}
|
|
761
|
+
);
|
|
762
|
+
};
|
|
763
|
+
IconButton.displayName = "IconButton";
|
|
764
|
+
|
|
765
|
+
// src/FlexButton.tsx
|
|
766
|
+
import { useRef, useState as useState3 } from "react";
|
|
767
|
+
import { useDesignSystem as useDesignSystem3 } from "@xsolla/xui-core";
|
|
768
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
769
|
+
var ICON_SIZES = {
|
|
770
|
+
xs: 12,
|
|
771
|
+
s: 14,
|
|
772
|
+
m: 16,
|
|
773
|
+
l: 18,
|
|
774
|
+
xl: 20
|
|
775
|
+
};
|
|
776
|
+
var SPINNER_SIZES = {
|
|
777
|
+
xs: 12,
|
|
778
|
+
s: 14,
|
|
779
|
+
m: 16,
|
|
780
|
+
l: 18,
|
|
781
|
+
xl: 20
|
|
782
|
+
};
|
|
783
|
+
var LINE_HEIGHTS = {
|
|
784
|
+
xs: "14px",
|
|
785
|
+
s: "16px",
|
|
786
|
+
m: "18px",
|
|
787
|
+
l: "20px",
|
|
788
|
+
xl: "22px"
|
|
789
|
+
};
|
|
790
|
+
var FONT_SIZES = {
|
|
791
|
+
xs: 12,
|
|
792
|
+
s: 14,
|
|
793
|
+
m: 14,
|
|
794
|
+
l: 16,
|
|
795
|
+
xl: 18
|
|
796
|
+
};
|
|
797
|
+
var BORDER_RADIUS = {
|
|
798
|
+
xl: 4,
|
|
799
|
+
l: 4,
|
|
800
|
+
m: 2,
|
|
801
|
+
s: 2,
|
|
802
|
+
xs: 2
|
|
803
|
+
};
|
|
804
|
+
var FlexButton = ({
|
|
805
|
+
children,
|
|
806
|
+
variant = "brand",
|
|
807
|
+
size = "m",
|
|
808
|
+
background = false,
|
|
809
|
+
disabled = false,
|
|
810
|
+
loading = false,
|
|
811
|
+
iconLeft,
|
|
812
|
+
iconRight,
|
|
813
|
+
onPress,
|
|
814
|
+
onClick,
|
|
815
|
+
className,
|
|
816
|
+
type = "button",
|
|
817
|
+
"aria-label": ariaLabel,
|
|
818
|
+
"aria-describedby": ariaDescribedBy,
|
|
819
|
+
"aria-expanded": ariaExpanded,
|
|
820
|
+
"aria-haspopup": ariaHasPopup,
|
|
821
|
+
"aria-pressed": ariaPressed,
|
|
822
|
+
"aria-controls": ariaControls,
|
|
823
|
+
testID,
|
|
824
|
+
tabIndex = 0,
|
|
825
|
+
...buttonProps
|
|
826
|
+
}) => {
|
|
827
|
+
const { theme } = useDesignSystem3();
|
|
828
|
+
const [state, setState] = useState3("default");
|
|
829
|
+
const [isFocused, setIsFocused] = useState3(false);
|
|
830
|
+
const isMouseOverRef = useRef(false);
|
|
831
|
+
const isDisabled = disabled || loading;
|
|
832
|
+
const getVariantColors = (currentState) => {
|
|
833
|
+
if (isDisabled) {
|
|
834
|
+
return {
|
|
835
|
+
bg: background ? theme.colors.overlay.mono : "transparent",
|
|
836
|
+
text: theme.colors.control.text.disable,
|
|
837
|
+
border: void 0
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
const effectiveBackground = loading ? false : background;
|
|
841
|
+
switch (variant) {
|
|
842
|
+
case "brand":
|
|
843
|
+
if (effectiveBackground) {
|
|
844
|
+
return {
|
|
845
|
+
bg: currentState === "press" ? theme.colors.control.brand.primary.bgPress : currentState === "hover" ? theme.colors.control.brand.primary.bgHover : theme.colors.background.brand.primary,
|
|
846
|
+
text: theme.colors.content.on.brand,
|
|
847
|
+
border: void 0
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
return {
|
|
851
|
+
bg: currentState === "press" ? theme.colors.background.brand.primary : currentState === "hover" ? theme.colors.overlay.brand : "transparent",
|
|
852
|
+
text: currentState === "press" ? theme.colors.content.on.brand : theme.colors.content.brand.primary,
|
|
853
|
+
border: void 0
|
|
854
|
+
};
|
|
855
|
+
case "primary":
|
|
856
|
+
if (effectiveBackground) {
|
|
857
|
+
return {
|
|
858
|
+
bg: theme.colors.background.primary,
|
|
859
|
+
text: theme.colors.content.primary,
|
|
860
|
+
border: currentState === "press" ? theme.colors.border.primary : void 0
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
return {
|
|
864
|
+
bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
865
|
+
text: theme.colors.content.primary,
|
|
866
|
+
border: currentState === "press" ? theme.colors.border.primary : void 0
|
|
867
|
+
};
|
|
868
|
+
case "secondary":
|
|
869
|
+
if (effectiveBackground) {
|
|
870
|
+
return {
|
|
871
|
+
bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
|
|
872
|
+
text: theme.colors.content.secondary,
|
|
873
|
+
border: void 0
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
return {
|
|
877
|
+
bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
878
|
+
text: currentState === "press" ? theme.colors.content.primary : currentState === "hover" ? theme.colors.content.secondary : theme.colors.content.secondary,
|
|
879
|
+
border: void 0
|
|
880
|
+
};
|
|
881
|
+
case "tertiary":
|
|
882
|
+
if (effectiveBackground) {
|
|
883
|
+
return {
|
|
884
|
+
bg: currentState === "press" ? theme.colors.control.mono.secondary.bgPress : currentState === "hover" ? theme.colors.control.mono.secondary.bgHover : theme.colors.background.secondary,
|
|
885
|
+
text: theme.colors.content.tertiary,
|
|
886
|
+
border: void 0
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
891
|
+
text: currentState === "press" ? theme.colors.content.secondary : currentState === "hover" ? theme.colors.content.tertiary : theme.colors.content.tertiary,
|
|
892
|
+
border: void 0
|
|
893
|
+
};
|
|
894
|
+
case "brandExtra":
|
|
895
|
+
if (effectiveBackground) {
|
|
896
|
+
return {
|
|
897
|
+
bg: currentState === "press" ? theme.colors.control.brandExtra.primary.bgPress : currentState === "hover" ? theme.colors.control.brandExtra.primary.bgHover : theme.colors.background.brandExtra.primary,
|
|
898
|
+
text: theme.colors.content.on.brandExtra,
|
|
899
|
+
border: void 0
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
bg: currentState === "press" ? theme.colors.background.brandExtra.primary : currentState === "hover" ? theme.colors.overlay.brandExtra : "transparent",
|
|
904
|
+
text: currentState === "press" ? theme.colors.content.on.brandExtra : theme.colors.content.brandExtra.secondary,
|
|
905
|
+
border: void 0
|
|
906
|
+
};
|
|
907
|
+
case "inverse":
|
|
908
|
+
if (effectiveBackground) {
|
|
909
|
+
return {
|
|
910
|
+
bg: currentState === "press" ? theme.colors.control.mono.primary.bgPress : currentState === "hover" ? theme.colors.control.mono.primary.bgHover : theme.colors.background.inverse,
|
|
911
|
+
text: theme.colors.content.inverse,
|
|
912
|
+
border: void 0
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
return {
|
|
916
|
+
bg: currentState === "press" || currentState === "hover" ? theme.colors.overlay.mono : "transparent",
|
|
917
|
+
text: theme.colors.content.inverse,
|
|
918
|
+
border: void 0
|
|
919
|
+
};
|
|
920
|
+
default:
|
|
921
|
+
return {
|
|
922
|
+
bg: "transparent",
|
|
923
|
+
text: theme.colors.content.primary,
|
|
924
|
+
border: void 0
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
const getFocusRingColor = () => {
|
|
929
|
+
switch (variant) {
|
|
930
|
+
case "brand":
|
|
931
|
+
return theme.colors.overlay.brand;
|
|
932
|
+
case "brandExtra":
|
|
933
|
+
return theme.colors.overlay.brandExtra;
|
|
934
|
+
case "inverse":
|
|
935
|
+
return "rgba(255, 255, 255, 0.3)";
|
|
936
|
+
default:
|
|
937
|
+
return theme.colors.overlay.mono;
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
const getSpinnerColor = () => {
|
|
941
|
+
switch (variant) {
|
|
942
|
+
case "brand":
|
|
943
|
+
return theme.colors.content.brand.primary;
|
|
944
|
+
case "primary":
|
|
945
|
+
return theme.colors.content.primary;
|
|
946
|
+
case "secondary":
|
|
947
|
+
return theme.colors.content.secondary;
|
|
948
|
+
case "tertiary":
|
|
949
|
+
return theme.colors.content.tertiary;
|
|
950
|
+
case "brandExtra":
|
|
951
|
+
return theme.colors.content.brandExtra.secondary;
|
|
952
|
+
case "inverse":
|
|
953
|
+
return theme.colors.content.inverse;
|
|
954
|
+
default:
|
|
955
|
+
return theme.colors.content.brand.primary;
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
const colors = getVariantColors(state);
|
|
959
|
+
const focusRingColor = getFocusRingColor();
|
|
960
|
+
const spinnerColor = getSpinnerColor();
|
|
961
|
+
const iconSize = ICON_SIZES[size];
|
|
962
|
+
const spinnerSize = SPINNER_SIZES[size];
|
|
963
|
+
const fontSize = FONT_SIZES[size];
|
|
964
|
+
const borderRadius = BORDER_RADIUS[size];
|
|
965
|
+
const lineHeight = LINE_HEIGHTS[size];
|
|
966
|
+
const handleMouseEnter = () => {
|
|
967
|
+
if (!isDisabled) {
|
|
968
|
+
isMouseOverRef.current = true;
|
|
969
|
+
setState("hover");
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
const handleMouseLeave = () => {
|
|
973
|
+
if (!isDisabled) {
|
|
974
|
+
isMouseOverRef.current = false;
|
|
975
|
+
setState("default");
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
const handleMouseDown = () => {
|
|
979
|
+
if (!isDisabled) {
|
|
980
|
+
setState("press");
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
const handleMouseUp = () => {
|
|
984
|
+
if (!isDisabled) {
|
|
985
|
+
setState(isMouseOverRef.current ? "hover" : "default");
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
const handleFocus = () => {
|
|
989
|
+
if (!isDisabled) {
|
|
990
|
+
setIsFocused(true);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
const handleBlur = () => {
|
|
994
|
+
setIsFocused(false);
|
|
995
|
+
};
|
|
996
|
+
const handleClick = (event) => {
|
|
997
|
+
if (isDisabled) return;
|
|
998
|
+
if (onPress) {
|
|
999
|
+
onPress();
|
|
1000
|
+
}
|
|
1001
|
+
if (onClick) {
|
|
1002
|
+
onClick(event);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
const handleKeyDown = (event) => {
|
|
1006
|
+
if (isDisabled) return;
|
|
1007
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1008
|
+
event.preventDefault();
|
|
1009
|
+
setState("press");
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
const handleKeyUp = (event) => {
|
|
1013
|
+
if (isDisabled) return;
|
|
1014
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1015
|
+
event.preventDefault();
|
|
1016
|
+
setState(isMouseOverRef.current ? "hover" : "default");
|
|
1017
|
+
if (onPress) {
|
|
1018
|
+
onPress();
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
const borderShadow = colors.border ? `inset 0 0 0 1px ${colors.border}` : void 0;
|
|
1023
|
+
const focusShadow = isFocused && !isDisabled ? `0 0 0 2px ${focusRingColor}` : void 0;
|
|
1024
|
+
const boxShadows = [];
|
|
1025
|
+
if (borderShadow) boxShadows.push(borderShadow);
|
|
1026
|
+
if (focusShadow) boxShadows.push(focusShadow);
|
|
1027
|
+
const combinedBoxShadow = boxShadows.length > 0 ? boxShadows.join(", ") : "none";
|
|
1028
|
+
const buttonStyle = {
|
|
1029
|
+
display: "inline-flex",
|
|
1030
|
+
alignItems: "center",
|
|
1031
|
+
justifyContent: "center",
|
|
1032
|
+
gap: "2px",
|
|
1033
|
+
padding: "4px",
|
|
1034
|
+
backgroundColor: loading ? "transparent" : colors.bg,
|
|
1035
|
+
color: colors.text,
|
|
1036
|
+
border: "none",
|
|
1037
|
+
borderWidth: "0px",
|
|
1038
|
+
borderRadius: `${borderRadius}px`,
|
|
1039
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
1040
|
+
fontSize: `${fontSize}px`,
|
|
1041
|
+
fontWeight: 500,
|
|
1042
|
+
lineHeight,
|
|
1043
|
+
fontFamily: "inherit",
|
|
1044
|
+
transition: "background-color 100ms ease-in-out, color 100ms ease-in-out, box-shadow 100ms ease-in-out",
|
|
1045
|
+
outline: "none",
|
|
1046
|
+
boxShadow: combinedBoxShadow,
|
|
1047
|
+
opacity: isDisabled && !loading ? 0.6 : 1
|
|
1048
|
+
};
|
|
1049
|
+
const contentStyle = {
|
|
1050
|
+
display: "flex",
|
|
1051
|
+
alignItems: "center",
|
|
1052
|
+
justifyContent: "center",
|
|
1053
|
+
gap: "2px"
|
|
1054
|
+
};
|
|
1055
|
+
const spinnerStyle = {
|
|
1056
|
+
display: "flex",
|
|
1057
|
+
alignItems: "center",
|
|
1058
|
+
justifyContent: "center",
|
|
1059
|
+
backgroundColor: "transparent",
|
|
1060
|
+
height: lineHeight
|
|
1061
|
+
};
|
|
1062
|
+
const computedAriaLabel = ariaLabel || (typeof children === "string" ? children : void 0);
|
|
1063
|
+
return /* @__PURE__ */ jsx10(
|
|
1064
|
+
"button",
|
|
1065
|
+
{
|
|
1066
|
+
...buttonProps,
|
|
1067
|
+
type,
|
|
1068
|
+
className,
|
|
1069
|
+
disabled: isDisabled,
|
|
1070
|
+
onClick: handleClick,
|
|
1071
|
+
onMouseEnter: handleMouseEnter,
|
|
1072
|
+
onMouseLeave: handleMouseLeave,
|
|
1073
|
+
onMouseDown: handleMouseDown,
|
|
1074
|
+
onMouseUp: handleMouseUp,
|
|
1075
|
+
onKeyDown: handleKeyDown,
|
|
1076
|
+
onKeyUp: handleKeyUp,
|
|
1077
|
+
onFocus: handleFocus,
|
|
1078
|
+
onBlur: handleBlur,
|
|
1079
|
+
"aria-label": computedAriaLabel,
|
|
1080
|
+
"aria-busy": loading || void 0,
|
|
1081
|
+
"aria-disabled": isDisabled || void 0,
|
|
1082
|
+
"aria-describedby": ariaDescribedBy,
|
|
1083
|
+
"aria-expanded": ariaExpanded,
|
|
1084
|
+
"aria-haspopup": ariaHasPopup,
|
|
1085
|
+
"aria-pressed": ariaPressed,
|
|
1086
|
+
"aria-controls": ariaControls,
|
|
1087
|
+
tabIndex,
|
|
1088
|
+
style: buttonStyle,
|
|
1089
|
+
"data-testid": testID || "flex-button",
|
|
1090
|
+
children: /* @__PURE__ */ jsx10("span", { style: contentStyle, children: loading ? /* @__PURE__ */ jsx10("span", { style: spinnerStyle, children: /* @__PURE__ */ jsx10(Spinner, { size: spinnerSize, color: spinnerColor }) }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1091
|
+
iconLeft && /* @__PURE__ */ jsx10(Icon, { size: iconSize, color: colors.text, children: iconLeft }),
|
|
1092
|
+
/* @__PURE__ */ jsx10("span", { children }),
|
|
1093
|
+
iconRight && /* @__PURE__ */ jsx10(Icon, { size: iconSize, color: colors.text, children: iconRight })
|
|
1094
|
+
] }) })
|
|
1095
|
+
}
|
|
1096
|
+
);
|
|
1097
|
+
};
|
|
1098
|
+
FlexButton.displayName = "FlexButton";
|
|
1099
|
+
|
|
1100
|
+
// src/ButtonGroup.tsx
|
|
1101
|
+
import { useDesignSystem as useDesignSystem4 } from "@xsolla/xui-core";
|
|
1102
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1103
|
+
var ButtonGroup = ({
|
|
1104
|
+
orientation = "horizontal",
|
|
1105
|
+
size = "m",
|
|
1106
|
+
children,
|
|
1107
|
+
description,
|
|
1108
|
+
error,
|
|
1109
|
+
gap,
|
|
1110
|
+
"aria-label": ariaLabel,
|
|
1111
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1112
|
+
"aria-describedby": ariaDescribedBy,
|
|
1113
|
+
id,
|
|
1114
|
+
testID
|
|
1115
|
+
}) => {
|
|
1116
|
+
const { theme } = useDesignSystem4();
|
|
1117
|
+
const verticalGapMap = {
|
|
1118
|
+
xl: 16,
|
|
1119
|
+
l: 16,
|
|
1120
|
+
m: 12,
|
|
1121
|
+
s: 8,
|
|
1122
|
+
xs: 4
|
|
1123
|
+
};
|
|
1124
|
+
const horizontalGapMap = {
|
|
1125
|
+
xl: 16,
|
|
1126
|
+
l: 16,
|
|
1127
|
+
m: 16,
|
|
1128
|
+
s: 12,
|
|
1129
|
+
xs: 12
|
|
1130
|
+
};
|
|
1131
|
+
const computedGap = gap ?? (orientation === "vertical" ? verticalGapMap[size] : horizontalGapMap[size]);
|
|
1132
|
+
const descriptionId = id ? `${id}-description` : void 0;
|
|
1133
|
+
const errorId = id ? `${id}-error` : void 0;
|
|
1134
|
+
const computedAriaDescribedBy = [
|
|
1135
|
+
ariaDescribedBy,
|
|
1136
|
+
error && errorId ? errorId : void 0,
|
|
1137
|
+
description && !error && descriptionId ? descriptionId : void 0
|
|
1138
|
+
].filter(Boolean).join(" ") || void 0;
|
|
1139
|
+
return /* @__PURE__ */ jsxs3(Box, { flexDirection: "column", width: "100%", gap: 8, children: [
|
|
1140
|
+
/* @__PURE__ */ jsx11(
|
|
1141
|
+
Box,
|
|
1142
|
+
{
|
|
1143
|
+
role: "group",
|
|
1144
|
+
"aria-label": ariaLabel,
|
|
1145
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1146
|
+
"aria-describedby": computedAriaDescribedBy,
|
|
1147
|
+
id,
|
|
1148
|
+
testID,
|
|
1149
|
+
flexDirection: orientation === "horizontal" ? "row" : "column",
|
|
1150
|
+
alignItems: "stretch",
|
|
1151
|
+
gap: computedGap,
|
|
1152
|
+
width: "100%",
|
|
1153
|
+
children
|
|
1154
|
+
}
|
|
1155
|
+
),
|
|
1156
|
+
error && /* @__PURE__ */ jsx11(Box, { marginTop: 4, children: /* @__PURE__ */ jsx11(
|
|
1157
|
+
Text,
|
|
1158
|
+
{
|
|
1159
|
+
id: errorId,
|
|
1160
|
+
role: "alert",
|
|
1161
|
+
"aria-live": "assertive",
|
|
1162
|
+
color: theme.colors.content.alert.primary,
|
|
1163
|
+
fontSize: 14,
|
|
1164
|
+
fontWeight: "400",
|
|
1165
|
+
children: error
|
|
1166
|
+
}
|
|
1167
|
+
) }),
|
|
1168
|
+
description && !error && /* @__PURE__ */ jsx11(Box, { marginTop: 4, children: /* @__PURE__ */ jsx11(
|
|
1169
|
+
Text,
|
|
1170
|
+
{
|
|
1171
|
+
id: descriptionId,
|
|
1172
|
+
color: theme.colors.content.tertiary,
|
|
1173
|
+
fontSize: 14,
|
|
1174
|
+
fontWeight: "400",
|
|
1175
|
+
children: description
|
|
1176
|
+
}
|
|
1177
|
+
) })
|
|
1178
|
+
] });
|
|
1179
|
+
};
|
|
1180
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
1181
|
+
export {
|
|
1182
|
+
Button,
|
|
1183
|
+
ButtonGroup,
|
|
1184
|
+
FlexButton,
|
|
1185
|
+
IconButton
|
|
1186
|
+
};
|
|
1187
|
+
//# sourceMappingURL=index.mjs.map
|