@xsolla/xui-select 0.89.0 → 0.90.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/web/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/Select.tsx
2
- import React3, { useState, useRef, useEffect } from "react";
2
+ import React2, { useState, useRef, useEffect } from "react";
3
3
 
4
4
  // ../primitives-web/src/Box.tsx
5
5
  import React from "react";
@@ -202,54 +202,10 @@ var Text = ({
202
202
  );
203
203
  };
204
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
205
  // ../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`
206
+ import styled3 from "styled-components";
207
+ import { jsx as jsx3 } from "react/jsx-runtime";
208
+ var StyledIcon = styled3.div`
253
209
  display: flex;
254
210
  align-items: center;
255
211
  justify-content: center;
@@ -265,197 +221,13 @@ var StyledIcon = styled4.div`
265
221
  }
266
222
  `;
267
223
  var Icon = ({ children, ...props }) => {
268
- return /* @__PURE__ */ jsx4(StyledIcon, { ...props, children });
224
+ return /* @__PURE__ */ jsx3(StyledIcon, { ...props, children });
269
225
  };
270
226
 
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
227
  // src/Select.tsx
456
228
  import { useDesignSystem, isNative } from "@xsolla/xui-core";
457
- import { jsx as jsx8, jsxs } from "react/jsx-runtime";
458
- var ChevronDown = () => /* @__PURE__ */ jsx8(
229
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
230
+ var ChevronDown = () => /* @__PURE__ */ jsx4(
459
231
  "svg",
460
232
  {
461
233
  width: "100%",
@@ -463,7 +235,7 @@ var ChevronDown = () => /* @__PURE__ */ jsx8(
463
235
  viewBox: "0 0 18 18",
464
236
  fill: "none",
465
237
  xmlns: "http://www.w3.org/2000/svg",
466
- children: /* @__PURE__ */ jsx8(
238
+ children: /* @__PURE__ */ jsx4(
467
239
  "path",
468
240
  {
469
241
  d: "M4.5 6.75L9 11.25L13.5 6.75",
@@ -475,7 +247,7 @@ var ChevronDown = () => /* @__PURE__ */ jsx8(
475
247
  )
476
248
  }
477
249
  );
478
- var ChevronUp = () => /* @__PURE__ */ jsx8(
250
+ var ChevronUp = () => /* @__PURE__ */ jsx4(
479
251
  "svg",
480
252
  {
481
253
  width: "100%",
@@ -483,7 +255,7 @@ var ChevronUp = () => /* @__PURE__ */ jsx8(
483
255
  viewBox: "0 0 18 18",
484
256
  fill: "none",
485
257
  xmlns: "http://www.w3.org/2000/svg",
486
- children: /* @__PURE__ */ jsx8(
258
+ children: /* @__PURE__ */ jsx4(
487
259
  "path",
488
260
  {
489
261
  d: "M13.5 11.25L9 6.75L4.5 11.25",
@@ -505,15 +277,15 @@ var ExclamationMarkCr = () => /* @__PURE__ */ jsxs(
505
277
  style: { stroke: "none" },
506
278
  xmlns: "http://www.w3.org/2000/svg",
507
279
  children: [
508
- /* @__PURE__ */ jsx8(
280
+ /* @__PURE__ */ jsx4(
509
281
  "path",
510
282
  {
511
283
  d: "M9.75 12.75C9.75 13.16 9.41 13.5 9 13.5C8.59 13.5 8.25 13.16 8.25 12.75C8.25 12.34 8.59 12 9 12C9.41 12 9.75 12.34 9.75 12.75Z",
512
284
  fill: "currentColor"
513
285
  }
514
286
  ),
515
- /* @__PURE__ */ jsx8("path", { d: "M9.75 10.5H8.25V4.5H9.75V10.5Z", fill: "currentColor" }),
516
- /* @__PURE__ */ jsx8(
287
+ /* @__PURE__ */ jsx4("path", { d: "M9.75 10.5H8.25V4.5H9.75V10.5Z", fill: "currentColor" }),
288
+ /* @__PURE__ */ jsx4(
517
289
  "path",
518
290
  {
519
291
  fillRule: "evenodd",
@@ -534,7 +306,7 @@ var SearchIcon = () => /* @__PURE__ */ jsxs(
534
306
  fill: "none",
535
307
  xmlns: "http://www.w3.org/2000/svg",
536
308
  children: [
537
- /* @__PURE__ */ jsx8(
309
+ /* @__PURE__ */ jsx4(
538
310
  "path",
539
311
  {
540
312
  d: "M8.25 14.25C11.5637 14.25 14.25 11.5637 14.25 8.25C14.25 4.93629 11.5637 2.25 8.25 2.25C4.93629 2.25 2.25 4.93629 2.25 8.25C2.25 11.5637 4.93629 14.25 8.25 14.25Z",
@@ -544,7 +316,7 @@ var SearchIcon = () => /* @__PURE__ */ jsxs(
544
316
  strokeLinejoin: "round"
545
317
  }
546
318
  ),
547
- /* @__PURE__ */ jsx8(
319
+ /* @__PURE__ */ jsx4(
548
320
  "path",
549
321
  {
550
322
  d: "M15.75 15.75L12.4875 12.4875",
@@ -588,7 +360,7 @@ var Select = ({
588
360
  const isDisable = externalState === "disable" || disabled;
589
361
  const isError = externalState === "error" || !!errorMessage;
590
362
  const isFocus = externalState === "focus" || isOpen;
591
- React3.useEffect(() => {
363
+ React2.useEffect(() => {
592
364
  if (value !== void 0) {
593
365
  setSelectedValue(value);
594
366
  }
@@ -687,7 +459,7 @@ var Select = ({
687
459
  width: "100%",
688
460
  position: "relative",
689
461
  children: [
690
- label && /* @__PURE__ */ jsx8(
462
+ label && /* @__PURE__ */ jsx4(
691
463
  Text,
692
464
  {
693
465
  color: theme.colors.content.secondary,
@@ -717,8 +489,8 @@ var Select = ({
717
489
  borderColor: inputColors.borderHover
718
490
  } : void 0,
719
491
  children: [
720
- iconLeft && /* @__PURE__ */ jsx8(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconLeft }) }),
721
- !iconOnly && /* @__PURE__ */ jsx8(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ jsx8(
492
+ iconLeft && /* @__PURE__ */ jsx4(Box, { alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx4(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconLeft }) }),
493
+ !iconOnly && /* @__PURE__ */ jsx4(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ jsx4(
722
494
  Text,
723
495
  {
724
496
  color: textColor,
@@ -728,15 +500,15 @@ var Select = ({
728
500
  }
729
501
  ) }),
730
502
  /* @__PURE__ */ jsxs(Box, { flexDirection: "row", alignItems: "center", gap: 4, children: [
731
- isError && /* @__PURE__ */ jsx8(
503
+ isError && /* @__PURE__ */ jsx4(
732
504
  Icon,
733
505
  {
734
506
  size: sizeStyles.iconSize,
735
507
  color: theme.colors.content.alert.primary,
736
- children: /* @__PURE__ */ jsx8(ExclamationMarkCr, {})
508
+ children: /* @__PURE__ */ jsx4(ExclamationMarkCr, {})
737
509
  }
738
510
  ),
739
- /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconRight !== void 0 ? iconRight : isFocus ? /* @__PURE__ */ jsx8(ChevronUp, {}) : /* @__PURE__ */ jsx8(ChevronDown, {}) })
511
+ /* @__PURE__ */ jsx4(Icon, { size: sizeStyles.iconSize, color: iconColor, children: iconRight !== void 0 ? iconRight : isFocus ? /* @__PURE__ */ jsx4(ChevronUp, {}) : /* @__PURE__ */ jsx4(ChevronDown, {}) })
740
512
  ] })
741
513
  ]
742
514
  }
@@ -758,7 +530,7 @@ var Select = ({
758
530
  minWidth: iconOnly ? sizeStyles.height * 3 : void 0
759
531
  },
760
532
  children: [
761
- searchable && /* @__PURE__ */ jsx8(
533
+ searchable && /* @__PURE__ */ jsx4(
762
534
  Box,
763
535
  {
764
536
  paddingHorizontal: sizeStyles.paddingHorizontal,
@@ -773,15 +545,15 @@ var Select = ({
773
545
  gap: sizeStyles.paddingHorizontal / 2,
774
546
  paddingHorizontal: 4,
775
547
  children: [
776
- /* @__PURE__ */ jsx8(
548
+ /* @__PURE__ */ jsx4(
777
549
  Icon,
778
550
  {
779
551
  size: sizeStyles.iconSize - 2,
780
552
  color: inputColors.placeholder,
781
- children: /* @__PURE__ */ jsx8(SearchIcon, {})
553
+ children: /* @__PURE__ */ jsx4(SearchIcon, {})
782
554
  }
783
555
  ),
784
- /* @__PURE__ */ jsx8(
556
+ /* @__PURE__ */ jsx4(
785
557
  Box,
786
558
  {
787
559
  as: "input",
@@ -806,7 +578,7 @@ var Select = ({
806
578
  )
807
579
  }
808
580
  ),
809
- /* @__PURE__ */ jsx8(
581
+ /* @__PURE__ */ jsx4(
810
582
  Box,
811
583
  {
812
584
  paddingVertical: 4,
@@ -814,13 +586,13 @@ var Select = ({
814
586
  maxHeight: searchable ? maxHeight - 60 : maxHeight,
815
587
  overflowY: "auto"
816
588
  },
817
- children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx8(
589
+ children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx4(
818
590
  Box,
819
591
  {
820
592
  paddingVertical: sizeStyles.paddingVertical * 2,
821
593
  paddingHorizontal: sizeStyles.paddingHorizontal,
822
594
  alignItems: "center",
823
- children: /* @__PURE__ */ jsx8(
595
+ children: /* @__PURE__ */ jsx4(
824
596
  Text,
825
597
  {
826
598
  color: theme.colors.content.tertiary,
@@ -836,7 +608,7 @@ var Select = ({
836
608
  const isSelected = optionValue === selectedValue;
837
609
  const brandColors = theme.colors.control.brand.primary;
838
610
  const contentColors = theme.colors.content;
839
- return /* @__PURE__ */ jsx8(
611
+ return /* @__PURE__ */ jsx4(
840
612
  Box,
841
613
  {
842
614
  ref: isSelected ? selectedItemRef : void 0,
@@ -854,7 +626,7 @@ var Select = ({
854
626
  hoverStyle: !isSelected && !isOptionDisabled ? {
855
627
  backgroundColor: theme.colors.control.input.bgHover
856
628
  } : void 0,
857
- children: /* @__PURE__ */ jsx8(
629
+ children: /* @__PURE__ */ jsx4(
858
630
  Text,
859
631
  {
860
632
  color: isSelected ? contentColors.on.brand : theme.colors.content.secondary,
@@ -872,7 +644,7 @@ var Select = ({
872
644
  ]
873
645
  }
874
646
  ),
875
- isError && errorMessage && /* @__PURE__ */ jsx8(
647
+ isError && errorMessage && /* @__PURE__ */ jsx4(
876
648
  Text,
877
649
  {
878
650
  color: theme.colors.content.alert.primary,