@xsolla/xui-slider 0.89.0 → 0.91.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.js CHANGED
@@ -35,7 +35,7 @@ __export(index_exports, {
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/Slider.tsx
38
- var import_react4 = require("react");
38
+ var import_react2 = require("react");
39
39
 
40
40
  // ../primitives-web/src/Box.tsx
41
41
  var import_react = __toESM(require("react"));
@@ -238,257 +238,10 @@ var Text = ({
238
238
  );
239
239
  };
240
240
 
241
- // ../primitives-web/src/Spinner.tsx
242
- var import_styled_components3 = __toESM(require("styled-components"));
243
- var import_jsx_runtime3 = require("react/jsx-runtime");
244
- var rotate = import_styled_components3.keyframes`
245
- from {
246
- transform: rotate(0deg);
247
- }
248
- to {
249
- transform: rotate(360deg);
250
- }
251
- `;
252
- var StyledSpinner = import_styled_components3.default.div`
253
- width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
254
- height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
255
- border: ${(props) => props.strokeWidth || 2}px solid
256
- ${(props) => props.color || "currentColor"};
257
- border-bottom-color: transparent;
258
- border-radius: 50%;
259
- display: inline-block;
260
- box-sizing: border-box;
261
- animation: ${rotate} 1s linear infinite;
262
- `;
263
- var Spinner = ({
264
- role = "status",
265
- "aria-label": ariaLabel,
266
- "aria-live": ariaLive = "polite",
267
- "aria-describedby": ariaDescribedBy,
268
- testID,
269
- ...props
270
- }) => {
271
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
272
- StyledSpinner,
273
- {
274
- role,
275
- "aria-label": ariaLabel,
276
- "aria-live": ariaLive,
277
- "aria-describedby": ariaDescribedBy,
278
- "data-testid": testID,
279
- ...props
280
- }
281
- );
282
- };
283
- Spinner.displayName = "Spinner";
284
-
285
- // ../primitives-web/src/Icon.tsx
286
- var import_styled_components4 = __toESM(require("styled-components"));
287
- var import_jsx_runtime4 = require("react/jsx-runtime");
288
- var StyledIcon = import_styled_components4.default.div`
289
- display: flex;
290
- align-items: center;
291
- justify-content: center;
292
- width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
293
- height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
294
- color: ${(props) => props.color || "currentColor"};
295
-
296
- svg {
297
- width: 100%;
298
- height: 100%;
299
- fill: none;
300
- stroke: currentColor;
301
- }
302
- `;
303
-
304
- // ../primitives-web/src/Divider.tsx
305
- var import_styled_components5 = __toESM(require("styled-components"));
306
- var import_jsx_runtime5 = require("react/jsx-runtime");
307
- var StyledDivider = import_styled_components5.default.div`
308
- background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
309
- width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
310
- height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
311
-
312
- ${(props) => props.dashStroke && `
313
- border-style: dashed;
314
- border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
315
- border-width: 0;
316
- ${props.vertical ? `
317
- border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
318
- height: 100%;
319
- ` : `
320
- border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
321
- width: 100%;
322
- `}
323
- `}
324
- `;
325
-
326
- // ../primitives-web/src/Input.tsx
327
- var import_react2 = require("react");
328
- var import_styled_components6 = __toESM(require("styled-components"));
329
- var import_jsx_runtime6 = require("react/jsx-runtime");
330
- var StyledInput = import_styled_components6.default.input`
331
- background: transparent;
332
- border: none;
333
- outline: none;
334
- width: 100%;
335
- height: 100%;
336
- padding: 0;
337
- margin: 0;
338
- color: ${(props) => props.color || "inherit"};
339
- font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
340
- font-family: inherit;
341
- text-align: inherit;
342
-
343
- &::placeholder {
344
- color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
345
- }
346
-
347
- &:disabled {
348
- cursor: not-allowed;
349
- }
350
- `;
351
- var InputPrimitive = (0, import_react2.forwardRef)(
352
- ({
353
- value,
354
- placeholder,
355
- onChange,
356
- onChangeText,
357
- onFocus,
358
- onBlur,
359
- onKeyDown,
360
- disabled,
361
- secureTextEntry,
362
- style,
363
- color,
364
- fontSize,
365
- placeholderTextColor,
366
- maxLength,
367
- name,
368
- type,
369
- inputMode,
370
- autoComplete,
371
- id,
372
- "aria-invalid": ariaInvalid,
373
- "aria-describedby": ariaDescribedBy,
374
- "aria-labelledby": ariaLabelledBy,
375
- "aria-label": ariaLabel,
376
- "aria-disabled": ariaDisabled,
377
- "data-testid": dataTestId,
378
- ...rest
379
- }, ref) => {
380
- const handleChange = (e) => {
381
- if (onChange) {
382
- onChange(e);
383
- }
384
- if (onChangeText) {
385
- onChangeText(e.target.value);
386
- }
387
- };
388
- const inputValue = value !== void 0 ? value : "";
389
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
390
- StyledInput,
391
- {
392
- ref,
393
- id,
394
- value: inputValue,
395
- name,
396
- placeholder,
397
- onChange: handleChange,
398
- onFocus,
399
- onBlur,
400
- onKeyDown,
401
- disabled,
402
- type: secureTextEntry ? "password" : type || "text",
403
- inputMode,
404
- autoComplete,
405
- style,
406
- color,
407
- fontSize,
408
- placeholderTextColor,
409
- maxLength,
410
- "aria-invalid": ariaInvalid,
411
- "aria-describedby": ariaDescribedBy,
412
- "aria-labelledby": ariaLabelledBy,
413
- "aria-label": ariaLabel,
414
- "aria-disabled": ariaDisabled,
415
- "data-testid": dataTestId,
416
- ...rest
417
- }
418
- );
419
- }
420
- );
421
- InputPrimitive.displayName = "InputPrimitive";
422
-
423
- // ../primitives-web/src/TextArea.tsx
424
- var import_react3 = require("react");
425
- var import_styled_components7 = __toESM(require("styled-components"));
426
- var import_jsx_runtime7 = require("react/jsx-runtime");
427
- var StyledTextArea = import_styled_components7.default.textarea`
428
- background: transparent;
429
- border: none;
430
- outline: none;
431
- width: 100%;
432
- height: 100%;
433
- padding: 0;
434
- margin: 0;
435
- color: ${(props) => props.color || "inherit"};
436
- font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
437
- font-family: inherit;
438
- text-align: inherit;
439
- resize: none;
440
-
441
- &::placeholder {
442
- color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
443
- }
444
-
445
- &:disabled {
446
- cursor: not-allowed;
447
- }
448
- `;
449
- var TextAreaPrimitive = (0, import_react3.forwardRef)(
450
- ({
451
- value,
452
- placeholder,
453
- onChangeText,
454
- onFocus,
455
- onBlur,
456
- onKeyDown,
457
- disabled,
458
- style,
459
- color,
460
- fontSize,
461
- placeholderTextColor,
462
- maxLength,
463
- rows
464
- }, ref) => {
465
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
466
- StyledTextArea,
467
- {
468
- ref,
469
- value,
470
- placeholder,
471
- onChange: (e) => onChangeText?.(e.target.value),
472
- onFocus,
473
- onBlur,
474
- onKeyDown,
475
- disabled,
476
- style,
477
- color,
478
- fontSize,
479
- placeholderTextColor,
480
- maxLength,
481
- rows
482
- }
483
- );
484
- }
485
- );
486
- TextAreaPrimitive.displayName = "TextAreaPrimitive";
487
-
488
241
  // src/Slider.tsx
489
242
  var import_xui_core = require("@xsolla/xui-core");
490
243
  var import_xui_input = require("@xsolla/xui-input");
491
- var import_jsx_runtime8 = require("react/jsx-runtime");
244
+ var import_jsx_runtime3 = require("react/jsx-runtime");
492
245
  var sizeConfig = {
493
246
  xl: {
494
247
  height: 56,
@@ -569,20 +322,20 @@ var Slider = ({
569
322
  const safeId = rawId.replace(/:/g, "");
570
323
  const sliderId = `slider-${safeId}`;
571
324
  const labelId = `${sliderId}-label`;
572
- const [value, setValue] = (0, import_react4.useState)(propValue);
573
- const [rangeMin, setRangeMin] = (0, import_react4.useState)(propMinValue ?? min);
574
- const [rangeMax, setRangeMax] = (0, import_react4.useState)(propMaxValue ?? max);
575
- const [isHovered, setIsHovered] = (0, import_react4.useState)(false);
576
- const [activeThumb, setActiveThumb] = (0, import_react4.useState)(null);
577
- const trackRef = (0, import_react4.useRef)(null);
325
+ const [value, setValue] = (0, import_react2.useState)(propValue);
326
+ const [rangeMin, setRangeMin] = (0, import_react2.useState)(propMinValue ?? min);
327
+ const [rangeMax, setRangeMax] = (0, import_react2.useState)(propMaxValue ?? max);
328
+ const [isHovered, setIsHovered] = (0, import_react2.useState)(false);
329
+ const [activeThumb, setActiveThumb] = (0, import_react2.useState)(null);
330
+ const trackRef = (0, import_react2.useRef)(null);
578
331
  const isWeb = typeof window !== "undefined" && typeof document !== "undefined";
579
- (0, import_react4.useEffect)(() => {
332
+ (0, import_react2.useEffect)(() => {
580
333
  setValue(propValue);
581
334
  }, [propValue]);
582
- (0, import_react4.useEffect)(() => {
335
+ (0, import_react2.useEffect)(() => {
583
336
  if (propMinValue !== void 0) setRangeMin(propMinValue);
584
337
  }, [propMinValue]);
585
- (0, import_react4.useEffect)(() => {
338
+ (0, import_react2.useEffect)(() => {
586
339
  if (propMaxValue !== void 0) setRangeMax(propMaxValue);
587
340
  }, [propMaxValue]);
588
341
  const sizing = sizeConfig[size];
@@ -612,7 +365,7 @@ var Slider = ({
612
365
  const thumbBgColor = disabled ? disabledColor : activeColors.bg;
613
366
  const thumbBgHoverColor = disabled ? disabledColor : activeColors.bgHover;
614
367
  const thumbShadow = "0px 1px 2px rgba(7, 7, 8, 0.2), 0px 1px 3px 1px rgba(7, 7, 8, 0.1)";
615
- const calculateValue = (0, import_react4.useCallback)(
368
+ const calculateValue = (0, import_react2.useCallback)(
616
369
  (clientX) => {
617
370
  if (!trackRef.current) return value;
618
371
  const rect = trackRef.current.getBoundingClientRect();
@@ -625,7 +378,7 @@ var Slider = ({
625
378
  },
626
379
  [min, max, step, value]
627
380
  );
628
- const handleSingleMove = (0, import_react4.useCallback)(
381
+ const handleSingleMove = (0, import_react2.useCallback)(
629
382
  (clientX) => {
630
383
  if (disabled) return;
631
384
  const newValue = calculateValue(clientX);
@@ -634,7 +387,7 @@ var Slider = ({
634
387
  },
635
388
  [disabled, calculateValue, onChange]
636
389
  );
637
- const handleRangeMove = (0, import_react4.useCallback)(
390
+ const handleRangeMove = (0, import_react2.useCallback)(
638
391
  (clientX, thumb) => {
639
392
  if (disabled) return;
640
393
  const newValue = calculateValue(clientX);
@@ -686,7 +439,7 @@ var Slider = ({
686
439
  document.addEventListener("mouseup", onMouseUp);
687
440
  }
688
441
  };
689
- const handleKeyDown = (0, import_react4.useCallback)(
442
+ const handleKeyDown = (0, import_react2.useCallback)(
690
443
  (e, thumbType) => {
691
444
  if (disabled) return;
692
445
  const stepValue = e.shiftKey ? step * 10 : step;
@@ -773,7 +526,7 @@ var Slider = ({
773
526
  onRangeChange
774
527
  ]
775
528
  );
776
- const handleResponderGrant = (0, import_react4.useCallback)(
529
+ const handleResponderGrant = (0, import_react2.useCallback)(
777
530
  (e, thumbType) => {
778
531
  if (disabled) return;
779
532
  const locationX = e.nativeEvent?.locationX ?? e.nativeEvent?.pageX ?? 0;
@@ -795,7 +548,7 @@ var Slider = ({
795
548
  },
796
549
  [disabled, range, min, max, rangeMin, rangeMax]
797
550
  );
798
- const handleResponderMove = (0, import_react4.useCallback)(
551
+ const handleResponderMove = (0, import_react2.useCallback)(
799
552
  (e, thumbType) => {
800
553
  if (disabled || !trackRef.current) return;
801
554
  const locationX = e.nativeEvent?.locationX ?? e.nativeEvent?.pageX ?? 0;
@@ -836,7 +589,7 @@ var Slider = ({
836
589
  onRangeChange
837
590
  ]
838
591
  );
839
- const handleResponderRelease = (0, import_react4.useCallback)(() => {
592
+ const handleResponderRelease = (0, import_react2.useCallback)(() => {
840
593
  setActiveThumb(null);
841
594
  }, []);
842
595
  const handleInputChange = (e, type) => {
@@ -928,7 +681,7 @@ var Slider = ({
928
681
  const inputIconLeft = iconInside && effectiveIconPosition === "left" ? iconInside : void 0;
929
682
  const inputIconRight = iconInside && effectiveIconPosition === "right" ? iconInside : void 0;
930
683
  const inputWidth = iconInside ? sizing.inputWidth + sizing.inputIconSize + sizing.inputIconGap : sizing.inputWidth;
931
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { width: inputWidth, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
684
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { width: inputWidth, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
932
685
  import_xui_input.Input,
933
686
  {
934
687
  value: String(inputValue),
@@ -954,7 +707,7 @@ var Slider = ({
954
707
  const thumbAriaLabel = range ? thumbType === "min" ? minThumbAriaLabel : maxThumbAriaLabel : ariaLabel || label || "Slider value";
955
708
  const currentThumbBg = thumbHovered && !disabled ? thumbBgHoverColor : thumbBgColor;
956
709
  const thumbBaseBg = disabled ? theme.colors.background.primary : currentThumbBg;
957
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
710
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
958
711
  Box,
959
712
  {
960
713
  role: "slider",
@@ -996,7 +749,7 @@ var Slider = ({
996
749
  "aria-valuemin": range && thumbType === "max" ? rangeMin + step : min,
997
750
  "aria-valuemax": range && thumbType === "min" ? rangeMax - step : max,
998
751
  "aria-orientation": "horizontal",
999
- children: disabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
752
+ children: disabled && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1000
753
  Box,
1001
754
  {
1002
755
  position: "absolute",
@@ -1013,7 +766,7 @@ var Slider = ({
1013
766
  }
1014
767
  );
1015
768
  };
1016
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
769
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1017
770
  Box,
1018
771
  {
1019
772
  flexDirection: "column",
@@ -1023,7 +776,7 @@ var Slider = ({
1023
776
  onMouseEnter: () => setIsHovered(true),
1024
777
  onMouseLeave: () => setIsHovered(false),
1025
778
  children: [
1026
- label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
779
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1027
780
  Text,
1028
781
  {
1029
782
  id: labelId,
@@ -1032,7 +785,7 @@ var Slider = ({
1032
785
  children: label
1033
786
  }
1034
787
  ),
1035
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
788
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1036
789
  Box,
1037
790
  {
1038
791
  flexDirection: "row",
@@ -1041,7 +794,7 @@ var Slider = ({
1041
794
  height: sizing.height,
1042
795
  children: [
1043
796
  (inputPosition === "left" || inputPosition === "both") && (range ? renderInput(rangeMin, "min", "left") : renderInput(value, "single", "left")),
1044
- iconLeft && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
797
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1045
798
  Box,
1046
799
  {
1047
800
  flexShrink: 0,
@@ -1053,7 +806,7 @@ var Slider = ({
1053
806
  children: iconLeft
1054
807
  }
1055
808
  ),
1056
- showLabels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
809
+ showLabels && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1057
810
  Text,
1058
811
  {
1059
812
  color: disabled ? inputColors.textDisable : inputColors.text,
@@ -1062,7 +815,7 @@ var Slider = ({
1062
815
  children: min
1063
816
  }
1064
817
  ),
1065
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
818
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1066
819
  Box,
1067
820
  {
1068
821
  flex: 1,
@@ -1070,7 +823,7 @@ var Slider = ({
1070
823
  height: sizing.height,
1071
824
  alignItems: "center",
1072
825
  justifyContent: "center",
1073
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
826
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1074
827
  Box,
1075
828
  {
1076
829
  ref: trackRef,
@@ -1088,8 +841,8 @@ var Slider = ({
1088
841
  onResponderMove: (e) => handleResponderMove(e),
1089
842
  onResponderRelease: handleResponderRelease,
1090
843
  onResponderTerminate: handleResponderRelease,
1091
- children: range ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1092
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
844
+ children: range ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
845
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1093
846
  Box,
1094
847
  {
1095
848
  position: "absolute",
@@ -1103,8 +856,8 @@ var Slider = ({
1103
856
  ),
1104
857
  renderThumb(rangeMinPercentage, "min"),
1105
858
  renderThumb(rangeMaxPercentage, "max")
1106
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1107
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
859
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
860
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1108
861
  Box,
1109
862
  {
1110
863
  position: "absolute",
@@ -1122,7 +875,7 @@ var Slider = ({
1122
875
  )
1123
876
  }
1124
877
  ),
1125
- showLabels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
878
+ showLabels && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1126
879
  Text,
1127
880
  {
1128
881
  color: disabled ? inputColors.textDisable : inputColors.text,
@@ -1131,7 +884,7 @@ var Slider = ({
1131
884
  children: max
1132
885
  }
1133
886
  ),
1134
- iconRight && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
887
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1135
888
  Box,
1136
889
  {
1137
890
  flexShrink: 0,