@xsolla/xui-select-web 0.64.0-pr56.1768348754
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/index.d.mts +25 -0
- package/index.d.ts +25 -0
- package/index.js +687 -0
- package/index.js.map +1 -0
- package/index.mjs +650 -0
- package/index.mjs.map +1 -0
- package/package.json +24 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
// src/Select.tsx
|
|
2
|
+
import React4, { 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
|
+
|
|
293
|
+
// ../primitives-web/src/Input.tsx
|
|
294
|
+
import { forwardRef } from "react";
|
|
295
|
+
import styled6 from "styled-components";
|
|
296
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
297
|
+
var StyledInput = styled6.input`
|
|
298
|
+
background: transparent;
|
|
299
|
+
border: none;
|
|
300
|
+
outline: none;
|
|
301
|
+
width: 100%;
|
|
302
|
+
height: 100%;
|
|
303
|
+
padding: 0;
|
|
304
|
+
margin: 0;
|
|
305
|
+
color: ${(props) => props.color || "inherit"};
|
|
306
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
307
|
+
font-family: inherit;
|
|
308
|
+
text-align: inherit;
|
|
309
|
+
|
|
310
|
+
&::placeholder {
|
|
311
|
+
color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
&:disabled {
|
|
315
|
+
cursor: not-allowed;
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
var InputPrimitive = forwardRef(
|
|
319
|
+
({
|
|
320
|
+
value,
|
|
321
|
+
placeholder,
|
|
322
|
+
onChange,
|
|
323
|
+
onChangeText,
|
|
324
|
+
onFocus,
|
|
325
|
+
onBlur,
|
|
326
|
+
onKeyDown,
|
|
327
|
+
disabled,
|
|
328
|
+
secureTextEntry,
|
|
329
|
+
style,
|
|
330
|
+
color,
|
|
331
|
+
fontSize,
|
|
332
|
+
placeholderTextColor,
|
|
333
|
+
maxLength,
|
|
334
|
+
name,
|
|
335
|
+
type,
|
|
336
|
+
inputMode,
|
|
337
|
+
autoComplete,
|
|
338
|
+
id,
|
|
339
|
+
"aria-invalid": ariaInvalid,
|
|
340
|
+
"aria-describedby": ariaDescribedBy,
|
|
341
|
+
"aria-labelledby": ariaLabelledBy,
|
|
342
|
+
"aria-label": ariaLabel,
|
|
343
|
+
"aria-disabled": ariaDisabled,
|
|
344
|
+
"data-testid": dataTestId,
|
|
345
|
+
...rest
|
|
346
|
+
}, ref) => {
|
|
347
|
+
const handleChange = (e) => {
|
|
348
|
+
if (onChange) {
|
|
349
|
+
onChange(e);
|
|
350
|
+
}
|
|
351
|
+
if (onChangeText) {
|
|
352
|
+
onChangeText(e.target.value);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const inputValue = value !== void 0 ? value : "";
|
|
356
|
+
return /* @__PURE__ */ jsx6(
|
|
357
|
+
StyledInput,
|
|
358
|
+
{
|
|
359
|
+
ref,
|
|
360
|
+
id,
|
|
361
|
+
value: inputValue,
|
|
362
|
+
name,
|
|
363
|
+
placeholder,
|
|
364
|
+
onChange: handleChange,
|
|
365
|
+
onFocus,
|
|
366
|
+
onBlur,
|
|
367
|
+
onKeyDown,
|
|
368
|
+
disabled,
|
|
369
|
+
type: secureTextEntry ? "password" : type || "text",
|
|
370
|
+
inputMode,
|
|
371
|
+
autoComplete,
|
|
372
|
+
style,
|
|
373
|
+
color,
|
|
374
|
+
fontSize,
|
|
375
|
+
placeholderTextColor,
|
|
376
|
+
maxLength,
|
|
377
|
+
"aria-invalid": ariaInvalid,
|
|
378
|
+
"aria-describedby": ariaDescribedBy,
|
|
379
|
+
"aria-labelledby": ariaLabelledBy,
|
|
380
|
+
"aria-label": ariaLabel,
|
|
381
|
+
"aria-disabled": ariaDisabled,
|
|
382
|
+
"data-testid": dataTestId,
|
|
383
|
+
...rest
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
InputPrimitive.displayName = "InputPrimitive";
|
|
389
|
+
|
|
390
|
+
// ../primitives-web/src/TextArea.tsx
|
|
391
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
392
|
+
import styled7 from "styled-components";
|
|
393
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
394
|
+
var StyledTextArea = styled7.textarea`
|
|
395
|
+
background: transparent;
|
|
396
|
+
border: none;
|
|
397
|
+
outline: none;
|
|
398
|
+
width: 100%;
|
|
399
|
+
height: 100%;
|
|
400
|
+
padding: 0;
|
|
401
|
+
margin: 0;
|
|
402
|
+
color: ${(props) => props.color || "inherit"};
|
|
403
|
+
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
404
|
+
font-family: inherit;
|
|
405
|
+
text-align: inherit;
|
|
406
|
+
resize: none;
|
|
407
|
+
|
|
408
|
+
&::placeholder {
|
|
409
|
+
color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
&:disabled {
|
|
413
|
+
cursor: not-allowed;
|
|
414
|
+
}
|
|
415
|
+
`;
|
|
416
|
+
var TextAreaPrimitive = forwardRef2(
|
|
417
|
+
({
|
|
418
|
+
value,
|
|
419
|
+
placeholder,
|
|
420
|
+
onChangeText,
|
|
421
|
+
onFocus,
|
|
422
|
+
onBlur,
|
|
423
|
+
onKeyDown,
|
|
424
|
+
disabled,
|
|
425
|
+
style,
|
|
426
|
+
color,
|
|
427
|
+
fontSize,
|
|
428
|
+
placeholderTextColor,
|
|
429
|
+
maxLength,
|
|
430
|
+
rows
|
|
431
|
+
}, ref) => {
|
|
432
|
+
return /* @__PURE__ */ jsx7(
|
|
433
|
+
StyledTextArea,
|
|
434
|
+
{
|
|
435
|
+
ref,
|
|
436
|
+
value,
|
|
437
|
+
placeholder,
|
|
438
|
+
onChange: (e) => onChangeText?.(e.target.value),
|
|
439
|
+
onFocus,
|
|
440
|
+
onBlur,
|
|
441
|
+
onKeyDown,
|
|
442
|
+
disabled,
|
|
443
|
+
style,
|
|
444
|
+
color,
|
|
445
|
+
fontSize,
|
|
446
|
+
placeholderTextColor,
|
|
447
|
+
maxLength,
|
|
448
|
+
rows
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
TextAreaPrimitive.displayName = "TextAreaPrimitive";
|
|
454
|
+
|
|
455
|
+
// src/Select.tsx
|
|
456
|
+
import { useDesignSystem } from "@xsolla/xui-core";
|
|
457
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
458
|
+
var ChevronDown = () => /* @__PURE__ */ jsx8(
|
|
459
|
+
"svg",
|
|
460
|
+
{
|
|
461
|
+
width: "100%",
|
|
462
|
+
height: "100%",
|
|
463
|
+
viewBox: "0 0 18 18",
|
|
464
|
+
fill: "none",
|
|
465
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
466
|
+
children: /* @__PURE__ */ jsx8(
|
|
467
|
+
"path",
|
|
468
|
+
{
|
|
469
|
+
d: "M4.5 6.75L9 11.25L13.5 6.75",
|
|
470
|
+
stroke: "currentColor",
|
|
471
|
+
strokeWidth: "1.5",
|
|
472
|
+
strokeLinecap: "round",
|
|
473
|
+
strokeLinejoin: "round"
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
var Select = ({
|
|
479
|
+
value,
|
|
480
|
+
placeholder = "Select",
|
|
481
|
+
onPress,
|
|
482
|
+
size = "m",
|
|
483
|
+
state: externalState,
|
|
484
|
+
label,
|
|
485
|
+
errorLabel,
|
|
486
|
+
iconLeft,
|
|
487
|
+
iconRight = /* @__PURE__ */ jsx8(ChevronDown, {}),
|
|
488
|
+
filled = true,
|
|
489
|
+
iconOnly = false,
|
|
490
|
+
options = [],
|
|
491
|
+
onSelect,
|
|
492
|
+
onValueChange
|
|
493
|
+
}) => {
|
|
494
|
+
const { theme } = useDesignSystem();
|
|
495
|
+
const [internalState, setInternalState] = useState(
|
|
496
|
+
"default"
|
|
497
|
+
);
|
|
498
|
+
const [selectedValue, setSelectedValue] = useState(value);
|
|
499
|
+
const state = externalState || internalState;
|
|
500
|
+
const isDisable = state === "disable";
|
|
501
|
+
const isError = state === "error";
|
|
502
|
+
const isFocus = state === "focus";
|
|
503
|
+
React4.useEffect(() => {
|
|
504
|
+
if (value !== void 0) {
|
|
505
|
+
setSelectedValue(value);
|
|
506
|
+
}
|
|
507
|
+
}, [value]);
|
|
508
|
+
const getOptionLabel = (option) => {
|
|
509
|
+
if (typeof option === "string") return option;
|
|
510
|
+
return option.label;
|
|
511
|
+
};
|
|
512
|
+
const getOptionValue = (option) => {
|
|
513
|
+
if (typeof option === "string") return option;
|
|
514
|
+
return option.value;
|
|
515
|
+
};
|
|
516
|
+
const sizeStyles = theme.sizing.input(size);
|
|
517
|
+
const inputColors = theme.colors.control.input;
|
|
518
|
+
const handlePress = () => {
|
|
519
|
+
if (!isDisable) {
|
|
520
|
+
if (onPress) onPress();
|
|
521
|
+
setInternalState(internalState === "default" ? "focus" : "default");
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
const handleSelect = (option) => {
|
|
525
|
+
const val = getOptionValue(option);
|
|
526
|
+
setSelectedValue(val);
|
|
527
|
+
setInternalState("default");
|
|
528
|
+
if (onSelect) onSelect(val);
|
|
529
|
+
if (onValueChange) onValueChange(val);
|
|
530
|
+
};
|
|
531
|
+
let backgroundColor = inputColors.bg;
|
|
532
|
+
let borderColor = inputColors.border;
|
|
533
|
+
if (isDisable) {
|
|
534
|
+
backgroundColor = inputColors.bgDisable;
|
|
535
|
+
borderColor = inputColors.borderDisable;
|
|
536
|
+
} else if (isError) {
|
|
537
|
+
borderColor = theme.colors.border.alert;
|
|
538
|
+
} else if (isFocus) {
|
|
539
|
+
backgroundColor = theme.colors.control.focus.bg;
|
|
540
|
+
borderColor = inputColors.borderHover;
|
|
541
|
+
} else if (state === "hover") {
|
|
542
|
+
backgroundColor = inputColors.bgHover;
|
|
543
|
+
borderColor = inputColors.borderHover;
|
|
544
|
+
}
|
|
545
|
+
if (filled === false && !isFocus && !isError && state !== "hover") {
|
|
546
|
+
backgroundColor = "transparent";
|
|
547
|
+
}
|
|
548
|
+
const currentLabel = selectedValue ? getOptionLabel(options.find((o) => getOptionValue(o) === selectedValue) || selectedValue) : placeholder;
|
|
549
|
+
const textColor = isDisable ? inputColors.textDisable : selectedValue ? inputColors.text : inputColors.placeholder;
|
|
550
|
+
const iconColor = isDisable ? inputColors.textDisable : inputColors.text;
|
|
551
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 8, width: "100%", position: "relative", children: [
|
|
552
|
+
label && /* @__PURE__ */ jsx8(
|
|
553
|
+
Text,
|
|
554
|
+
{
|
|
555
|
+
color: theme.colors.content.secondary,
|
|
556
|
+
fontSize: sizeStyles.fontSize - 2,
|
|
557
|
+
fontWeight: "500",
|
|
558
|
+
children: label
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ jsxs(
|
|
562
|
+
Box,
|
|
563
|
+
{
|
|
564
|
+
onPress: handlePress,
|
|
565
|
+
backgroundColor,
|
|
566
|
+
borderColor,
|
|
567
|
+
borderWidth: borderColor !== "transparent" ? 1 : 0,
|
|
568
|
+
borderRadius: theme.radius.button,
|
|
569
|
+
height: sizeStyles.height,
|
|
570
|
+
width: iconOnly ? sizeStyles.height : "100%",
|
|
571
|
+
paddingHorizontal: iconOnly ? 0 : sizeStyles.padding,
|
|
572
|
+
flexDirection: "row",
|
|
573
|
+
alignItems: "center",
|
|
574
|
+
justifyContent: iconOnly ? "center" : "flex-start",
|
|
575
|
+
gap: iconOnly ? 4 : 12,
|
|
576
|
+
position: "relative",
|
|
577
|
+
hoverStyle: !isDisable && !isFocus && !isError ? {
|
|
578
|
+
backgroundColor: inputColors.bgHover,
|
|
579
|
+
borderColor: inputColors.borderHover
|
|
580
|
+
} : void 0,
|
|
581
|
+
children: [
|
|
582
|
+
iconLeft && /* @__PURE__ */ jsx8(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconLeft }) }),
|
|
583
|
+
!iconOnly && /* @__PURE__ */ jsx8(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ jsx8(
|
|
584
|
+
Text,
|
|
585
|
+
{
|
|
586
|
+
color: textColor,
|
|
587
|
+
fontSize: sizeStyles.fontSize,
|
|
588
|
+
numberOfLines: 1,
|
|
589
|
+
children: currentLabel
|
|
590
|
+
}
|
|
591
|
+
) }),
|
|
592
|
+
iconRight && /* @__PURE__ */ jsx8(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconRight }) })
|
|
593
|
+
]
|
|
594
|
+
}
|
|
595
|
+
),
|
|
596
|
+
isFocus && options.length > 0 && /* @__PURE__ */ jsx8(
|
|
597
|
+
Box,
|
|
598
|
+
{
|
|
599
|
+
position: "absolute",
|
|
600
|
+
top: sizeStyles.height + (label ? 30 : 0),
|
|
601
|
+
left: 0,
|
|
602
|
+
right: 0,
|
|
603
|
+
backgroundColor: theme.colors.background.secondary,
|
|
604
|
+
borderColor: theme.colors.border.secondary,
|
|
605
|
+
borderWidth: 1,
|
|
606
|
+
borderRadius: theme.radius.button,
|
|
607
|
+
paddingVertical: 4,
|
|
608
|
+
style: { zIndex: 1e3, boxShadow: "0 4px 12px rgba(0,0,0,0.1)" },
|
|
609
|
+
children: options.map((option, index) => {
|
|
610
|
+
const optionValue = getOptionValue(option);
|
|
611
|
+
const optionLabel = getOptionLabel(option);
|
|
612
|
+
const isSelected = optionValue === selectedValue;
|
|
613
|
+
return /* @__PURE__ */ jsx8(
|
|
614
|
+
Box,
|
|
615
|
+
{
|
|
616
|
+
paddingHorizontal: sizeStyles.padding,
|
|
617
|
+
paddingVertical: 8,
|
|
618
|
+
onPress: () => handleSelect(option),
|
|
619
|
+
hoverStyle: {
|
|
620
|
+
backgroundColor: theme.colors.control.input.bgHover
|
|
621
|
+
},
|
|
622
|
+
children: /* @__PURE__ */ jsx8(
|
|
623
|
+
Text,
|
|
624
|
+
{
|
|
625
|
+
color: isSelected ? theme.colors.content.primary : theme.colors.content.secondary,
|
|
626
|
+
fontSize: sizeStyles.fontSize,
|
|
627
|
+
fontWeight: isSelected ? "600" : "400",
|
|
628
|
+
children: optionLabel
|
|
629
|
+
}
|
|
630
|
+
)
|
|
631
|
+
},
|
|
632
|
+
index
|
|
633
|
+
);
|
|
634
|
+
})
|
|
635
|
+
}
|
|
636
|
+
),
|
|
637
|
+
isError && errorLabel && /* @__PURE__ */ jsx8(
|
|
638
|
+
Text,
|
|
639
|
+
{
|
|
640
|
+
color: theme.colors.content.alert.primary,
|
|
641
|
+
fontSize: sizeStyles.fontSize - 2,
|
|
642
|
+
children: errorLabel
|
|
643
|
+
}
|
|
644
|
+
)
|
|
645
|
+
] });
|
|
646
|
+
};
|
|
647
|
+
export {
|
|
648
|
+
Select
|
|
649
|
+
};
|
|
650
|
+
//# sourceMappingURL=index.mjs.map
|