@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/native/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.tsx
@@ -35,7 +25,7 @@ __export(index_exports, {
35
25
  module.exports = __toCommonJS(index_exports);
36
26
 
37
27
  // src/Slider.tsx
38
- var import_react4 = require("react");
28
+ var import_react = require("react");
39
29
 
40
30
  // ../primitives-native/src/Box.tsx
41
31
  var import_react_native = require("react-native");
@@ -238,263 +228,10 @@ var Text = ({
238
228
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
239
229
  };
240
230
 
241
- // ../primitives-native/src/Spinner.tsx
242
- var import_react_native3 = require("react-native");
243
- var import_jsx_runtime3 = require("react/jsx-runtime");
244
- var Spinner = ({
245
- color,
246
- size,
247
- role,
248
- "aria-label": ariaLabel,
249
- "aria-live": ariaLive,
250
- testID
251
- }) => {
252
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
253
- import_react_native3.View,
254
- {
255
- accessible: true,
256
- accessibilityRole: role === "status" ? "none" : void 0,
257
- accessibilityLabel: ariaLabel,
258
- accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
259
- testID,
260
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
261
- import_react_native3.ActivityIndicator,
262
- {
263
- color,
264
- size: typeof size === "number" ? size : "small"
265
- }
266
- )
267
- }
268
- );
269
- };
270
- Spinner.displayName = "Spinner";
271
-
272
- // ../primitives-native/src/Icon.tsx
273
- var import_react = __toESM(require("react"));
274
- var import_react_native4 = require("react-native");
275
- var import_jsx_runtime4 = require("react/jsx-runtime");
276
-
277
- // ../primitives-native/src/Divider.tsx
278
- var import_react_native5 = require("react-native");
279
- var import_jsx_runtime5 = require("react/jsx-runtime");
280
-
281
- // ../primitives-native/src/Input.tsx
282
- var import_react2 = require("react");
283
- var import_react_native6 = require("react-native");
284
- var import_jsx_runtime6 = require("react/jsx-runtime");
285
- var keyboardTypeMap = {
286
- text: "default",
287
- number: "numeric",
288
- email: "email-address",
289
- tel: "phone-pad",
290
- url: "url",
291
- decimal: "decimal-pad"
292
- };
293
- var inputModeToKeyboardType = {
294
- none: "default",
295
- text: "default",
296
- decimal: "decimal-pad",
297
- numeric: "number-pad",
298
- tel: "phone-pad",
299
- search: "default",
300
- email: "email-address",
301
- url: "url"
302
- };
303
- var autoCompleteToTextContentType = {
304
- "one-time-code": "oneTimeCode",
305
- email: "emailAddress",
306
- username: "username",
307
- password: "password",
308
- "new-password": "newPassword",
309
- tel: "telephoneNumber",
310
- "postal-code": "postalCode",
311
- name: "name"
312
- };
313
- var InputPrimitive = (0, import_react2.forwardRef)(
314
- ({
315
- value,
316
- placeholder,
317
- onChange,
318
- onChangeText,
319
- onFocus,
320
- onBlur,
321
- onKeyDown,
322
- disabled,
323
- secureTextEntry,
324
- style,
325
- color,
326
- fontSize,
327
- placeholderTextColor,
328
- maxLength,
329
- type,
330
- inputMode,
331
- autoComplete,
332
- id,
333
- "aria-describedby": ariaDescribedBy,
334
- "aria-label": ariaLabel,
335
- "aria-disabled": ariaDisabled,
336
- "data-testid": dataTestId
337
- }, ref) => {
338
- const handleChangeText = (text) => {
339
- onChangeText?.(text);
340
- if (onChange) {
341
- const syntheticEvent = {
342
- target: { value: text },
343
- currentTarget: { value: text },
344
- type: "change",
345
- nativeEvent: { text },
346
- preventDefault: () => {
347
- },
348
- stopPropagation: () => {
349
- },
350
- isTrusted: false
351
- };
352
- onChange(syntheticEvent);
353
- }
354
- };
355
- const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
356
- const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
357
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
358
- import_react_native6.TextInput,
359
- {
360
- ref,
361
- value,
362
- placeholder,
363
- onChangeText: handleChangeText,
364
- onFocus,
365
- onBlur,
366
- onKeyPress: (e) => {
367
- if (onKeyDown) {
368
- onKeyDown({
369
- key: e.nativeEvent.key,
370
- preventDefault: () => {
371
- }
372
- });
373
- }
374
- },
375
- editable: !disabled,
376
- secureTextEntry: secureTextEntry || type === "password",
377
- keyboardType,
378
- textContentType,
379
- style: [
380
- {
381
- color,
382
- fontSize: typeof fontSize === "number" ? fontSize : void 0,
383
- flex: 1,
384
- padding: 0,
385
- textAlign: style?.textAlign || "left"
386
- },
387
- style
388
- ],
389
- placeholderTextColor,
390
- maxLength,
391
- testID: dataTestId || id,
392
- accessibilityLabel: ariaLabel,
393
- accessibilityHint: ariaDescribedBy,
394
- accessibilityState: {
395
- disabled: disabled || ariaDisabled
396
- },
397
- accessible: true
398
- }
399
- );
400
- }
401
- );
402
- InputPrimitive.displayName = "InputPrimitive";
403
-
404
- // ../primitives-native/src/TextArea.tsx
405
- var import_react3 = require("react");
406
- var import_react_native7 = require("react-native");
407
- var import_jsx_runtime7 = require("react/jsx-runtime");
408
- var TextAreaPrimitive = (0, import_react3.forwardRef)(
409
- ({
410
- value,
411
- placeholder,
412
- onChange,
413
- onChangeText,
414
- onFocus,
415
- onBlur,
416
- onKeyDown,
417
- disabled,
418
- style,
419
- color,
420
- fontSize,
421
- placeholderTextColor,
422
- maxLength,
423
- rows,
424
- id,
425
- "aria-describedby": ariaDescribedBy,
426
- "aria-label": ariaLabel,
427
- "aria-disabled": ariaDisabled,
428
- "data-testid": dataTestId
429
- }, ref) => {
430
- const handleChangeText = (text) => {
431
- onChangeText?.(text);
432
- if (onChange) {
433
- const syntheticEvent = {
434
- target: { value: text },
435
- currentTarget: { value: text },
436
- type: "change",
437
- nativeEvent: { text },
438
- preventDefault: () => {
439
- },
440
- stopPropagation: () => {
441
- },
442
- isTrusted: false
443
- };
444
- onChange(syntheticEvent);
445
- }
446
- };
447
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
448
- import_react_native7.TextInput,
449
- {
450
- ref,
451
- value,
452
- placeholder,
453
- onChangeText: handleChangeText,
454
- onFocus,
455
- onBlur,
456
- onKeyPress: (e) => {
457
- if (onKeyDown) {
458
- onKeyDown({
459
- key: e.nativeEvent.key,
460
- preventDefault: () => {
461
- }
462
- });
463
- }
464
- },
465
- editable: !disabled,
466
- multiline: true,
467
- numberOfLines: rows || 4,
468
- style: [
469
- {
470
- color,
471
- fontSize: typeof fontSize === "number" ? fontSize : void 0,
472
- flex: 1,
473
- padding: 0,
474
- textAlignVertical: "top",
475
- textAlign: style?.textAlign || "left"
476
- },
477
- style
478
- ],
479
- placeholderTextColor,
480
- maxLength,
481
- testID: dataTestId || id,
482
- accessibilityLabel: ariaLabel,
483
- accessibilityHint: ariaDescribedBy,
484
- accessibilityState: {
485
- disabled: disabled || ariaDisabled
486
- },
487
- accessible: true
488
- }
489
- );
490
- }
491
- );
492
- TextAreaPrimitive.displayName = "TextAreaPrimitive";
493
-
494
231
  // src/Slider.tsx
495
232
  var import_xui_core = require("@xsolla/xui-core");
496
233
  var import_xui_input = require("@xsolla/xui-input");
497
- var import_jsx_runtime8 = require("react/jsx-runtime");
234
+ var import_jsx_runtime3 = require("react/jsx-runtime");
498
235
  var sizeConfig = {
499
236
  xl: {
500
237
  height: 56,
@@ -575,20 +312,20 @@ var Slider = ({
575
312
  const safeId = rawId.replace(/:/g, "");
576
313
  const sliderId = `slider-${safeId}`;
577
314
  const labelId = `${sliderId}-label`;
578
- const [value, setValue] = (0, import_react4.useState)(propValue);
579
- const [rangeMin, setRangeMin] = (0, import_react4.useState)(propMinValue ?? min);
580
- const [rangeMax, setRangeMax] = (0, import_react4.useState)(propMaxValue ?? max);
581
- const [isHovered, setIsHovered] = (0, import_react4.useState)(false);
582
- const [activeThumb, setActiveThumb] = (0, import_react4.useState)(null);
583
- const trackRef = (0, import_react4.useRef)(null);
315
+ const [value, setValue] = (0, import_react.useState)(propValue);
316
+ const [rangeMin, setRangeMin] = (0, import_react.useState)(propMinValue ?? min);
317
+ const [rangeMax, setRangeMax] = (0, import_react.useState)(propMaxValue ?? max);
318
+ const [isHovered, setIsHovered] = (0, import_react.useState)(false);
319
+ const [activeThumb, setActiveThumb] = (0, import_react.useState)(null);
320
+ const trackRef = (0, import_react.useRef)(null);
584
321
  const isWeb = typeof window !== "undefined" && typeof document !== "undefined";
585
- (0, import_react4.useEffect)(() => {
322
+ (0, import_react.useEffect)(() => {
586
323
  setValue(propValue);
587
324
  }, [propValue]);
588
- (0, import_react4.useEffect)(() => {
325
+ (0, import_react.useEffect)(() => {
589
326
  if (propMinValue !== void 0) setRangeMin(propMinValue);
590
327
  }, [propMinValue]);
591
- (0, import_react4.useEffect)(() => {
328
+ (0, import_react.useEffect)(() => {
592
329
  if (propMaxValue !== void 0) setRangeMax(propMaxValue);
593
330
  }, [propMaxValue]);
594
331
  const sizing = sizeConfig[size];
@@ -618,7 +355,7 @@ var Slider = ({
618
355
  const thumbBgColor = disabled ? disabledColor : activeColors.bg;
619
356
  const thumbBgHoverColor = disabled ? disabledColor : activeColors.bgHover;
620
357
  const thumbShadow = "0px 1px 2px rgba(7, 7, 8, 0.2), 0px 1px 3px 1px rgba(7, 7, 8, 0.1)";
621
- const calculateValue = (0, import_react4.useCallback)(
358
+ const calculateValue = (0, import_react.useCallback)(
622
359
  (clientX) => {
623
360
  if (!trackRef.current) return value;
624
361
  const rect = trackRef.current.getBoundingClientRect();
@@ -631,7 +368,7 @@ var Slider = ({
631
368
  },
632
369
  [min, max, step, value]
633
370
  );
634
- const handleSingleMove = (0, import_react4.useCallback)(
371
+ const handleSingleMove = (0, import_react.useCallback)(
635
372
  (clientX) => {
636
373
  if (disabled) return;
637
374
  const newValue = calculateValue(clientX);
@@ -640,7 +377,7 @@ var Slider = ({
640
377
  },
641
378
  [disabled, calculateValue, onChange]
642
379
  );
643
- const handleRangeMove = (0, import_react4.useCallback)(
380
+ const handleRangeMove = (0, import_react.useCallback)(
644
381
  (clientX, thumb) => {
645
382
  if (disabled) return;
646
383
  const newValue = calculateValue(clientX);
@@ -692,7 +429,7 @@ var Slider = ({
692
429
  document.addEventListener("mouseup", onMouseUp);
693
430
  }
694
431
  };
695
- const handleKeyDown = (0, import_react4.useCallback)(
432
+ const handleKeyDown = (0, import_react.useCallback)(
696
433
  (e, thumbType) => {
697
434
  if (disabled) return;
698
435
  const stepValue = e.shiftKey ? step * 10 : step;
@@ -779,7 +516,7 @@ var Slider = ({
779
516
  onRangeChange
780
517
  ]
781
518
  );
782
- const handleResponderGrant = (0, import_react4.useCallback)(
519
+ const handleResponderGrant = (0, import_react.useCallback)(
783
520
  (e, thumbType) => {
784
521
  if (disabled) return;
785
522
  const locationX = e.nativeEvent?.locationX ?? e.nativeEvent?.pageX ?? 0;
@@ -801,7 +538,7 @@ var Slider = ({
801
538
  },
802
539
  [disabled, range, min, max, rangeMin, rangeMax]
803
540
  );
804
- const handleResponderMove = (0, import_react4.useCallback)(
541
+ const handleResponderMove = (0, import_react.useCallback)(
805
542
  (e, thumbType) => {
806
543
  if (disabled || !trackRef.current) return;
807
544
  const locationX = e.nativeEvent?.locationX ?? e.nativeEvent?.pageX ?? 0;
@@ -842,7 +579,7 @@ var Slider = ({
842
579
  onRangeChange
843
580
  ]
844
581
  );
845
- const handleResponderRelease = (0, import_react4.useCallback)(() => {
582
+ const handleResponderRelease = (0, import_react.useCallback)(() => {
846
583
  setActiveThumb(null);
847
584
  }, []);
848
585
  const handleInputChange = (e, type) => {
@@ -934,7 +671,7 @@ var Slider = ({
934
671
  const inputIconLeft = iconInside && effectiveIconPosition === "left" ? iconInside : void 0;
935
672
  const inputIconRight = iconInside && effectiveIconPosition === "right" ? iconInside : void 0;
936
673
  const inputWidth = iconInside ? sizing.inputWidth + sizing.inputIconSize + sizing.inputIconGap : sizing.inputWidth;
937
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { width: inputWidth, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
674
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { width: inputWidth, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
938
675
  import_xui_input.Input,
939
676
  {
940
677
  value: String(inputValue),
@@ -960,7 +697,7 @@ var Slider = ({
960
697
  const thumbAriaLabel = range ? thumbType === "min" ? minThumbAriaLabel : maxThumbAriaLabel : ariaLabel || label || "Slider value";
961
698
  const currentThumbBg = thumbHovered && !disabled ? thumbBgHoverColor : thumbBgColor;
962
699
  const thumbBaseBg = disabled ? theme.colors.background.primary : currentThumbBg;
963
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
700
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
964
701
  Box,
965
702
  {
966
703
  role: "slider",
@@ -1002,7 +739,7 @@ var Slider = ({
1002
739
  "aria-valuemin": range && thumbType === "max" ? rangeMin + step : min,
1003
740
  "aria-valuemax": range && thumbType === "min" ? rangeMax - step : max,
1004
741
  "aria-orientation": "horizontal",
1005
- children: disabled && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
742
+ children: disabled && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1006
743
  Box,
1007
744
  {
1008
745
  position: "absolute",
@@ -1019,7 +756,7 @@ var Slider = ({
1019
756
  }
1020
757
  );
1021
758
  };
1022
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
759
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1023
760
  Box,
1024
761
  {
1025
762
  flexDirection: "column",
@@ -1029,7 +766,7 @@ var Slider = ({
1029
766
  onMouseEnter: () => setIsHovered(true),
1030
767
  onMouseLeave: () => setIsHovered(false),
1031
768
  children: [
1032
- label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
769
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1033
770
  Text,
1034
771
  {
1035
772
  id: labelId,
@@ -1038,7 +775,7 @@ var Slider = ({
1038
775
  children: label
1039
776
  }
1040
777
  ),
1041
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
778
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1042
779
  Box,
1043
780
  {
1044
781
  flexDirection: "row",
@@ -1047,7 +784,7 @@ var Slider = ({
1047
784
  height: sizing.height,
1048
785
  children: [
1049
786
  (inputPosition === "left" || inputPosition === "both") && (range ? renderInput(rangeMin, "min", "left") : renderInput(value, "single", "left")),
1050
- iconLeft && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
787
+ iconLeft && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1051
788
  Box,
1052
789
  {
1053
790
  flexShrink: 0,
@@ -1059,7 +796,7 @@ var Slider = ({
1059
796
  children: iconLeft
1060
797
  }
1061
798
  ),
1062
- showLabels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
799
+ showLabels && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1063
800
  Text,
1064
801
  {
1065
802
  color: disabled ? inputColors.textDisable : inputColors.text,
@@ -1068,7 +805,7 @@ var Slider = ({
1068
805
  children: min
1069
806
  }
1070
807
  ),
1071
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
808
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1072
809
  Box,
1073
810
  {
1074
811
  flex: 1,
@@ -1076,7 +813,7 @@ var Slider = ({
1076
813
  height: sizing.height,
1077
814
  alignItems: "center",
1078
815
  justifyContent: "center",
1079
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
816
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1080
817
  Box,
1081
818
  {
1082
819
  ref: trackRef,
@@ -1094,8 +831,8 @@ var Slider = ({
1094
831
  onResponderMove: (e) => handleResponderMove(e),
1095
832
  onResponderRelease: handleResponderRelease,
1096
833
  onResponderTerminate: handleResponderRelease,
1097
- children: range ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1098
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
834
+ children: range ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
835
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1099
836
  Box,
1100
837
  {
1101
838
  position: "absolute",
@@ -1109,8 +846,8 @@ var Slider = ({
1109
846
  ),
1110
847
  renderThumb(rangeMinPercentage, "min"),
1111
848
  renderThumb(rangeMaxPercentage, "max")
1112
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1113
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
849
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
850
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1114
851
  Box,
1115
852
  {
1116
853
  position: "absolute",
@@ -1128,7 +865,7 @@ var Slider = ({
1128
865
  )
1129
866
  }
1130
867
  ),
1131
- showLabels && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
868
+ showLabels && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1132
869
  Text,
1133
870
  {
1134
871
  color: disabled ? inputColors.textDisable : inputColors.text,
@@ -1137,7 +874,7 @@ var Slider = ({
1137
874
  children: max
1138
875
  }
1139
876
  ),
1140
- iconRight && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
877
+ iconRight && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1141
878
  Box,
1142
879
  {
1143
880
  flexShrink: 0,