tera-system-ui 0.1.5 → 0.1.6

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.
@@ -4,6 +4,12 @@ type SliderVariants = VariantProps<typeof styles>;
4
4
  export interface SliderProps extends SliderVariants {
5
5
  children?: any;
6
6
  class?: string;
7
+ min: number;
8
+ max: number;
9
+ step: number;
10
+ value: number;
11
+ showTicks: boolean;
12
+ onchange: (value: number) => void;
7
13
  }
8
14
  export type SliderContextProps = {};
9
15
  export {};
@@ -38,13 +38,13 @@
38
38
  slider.addEventListener('touchstart', (e) => {
39
39
  sliderHandle.setAttribute('data-state', 'dragging');
40
40
  onDrag(e)
41
- document.addEventListener('touchmove', onDrag);
41
+ document.addEventListener('touchmove', onDrag, { passive: false });
42
42
  document.addEventListener('touchend', () => {
43
43
  document.removeEventListener('touchmove', onDrag);
44
44
  toggleToolTip(false)
45
45
  sliderHandle.removeAttribute('data-state');
46
46
  }, {once: true});
47
- });
47
+ }, { passive: false });
48
48
 
49
49
  sliderHandle.addEventListener('pointerenter', (e) => {
50
50
  toggleToolTip(true)
@@ -72,16 +72,18 @@
72
72
 
73
73
  const calculateValue = (position) => {
74
74
  const sliderWidth = sliderRail.offsetWidth;
75
-
76
- // calculate step size in px
77
- const stepSize = sliderWidth / ((max - min) / step)
75
+ const totalSteps = (max - min) / step;
76
+ const stepSize = sliderWidth / totalSteps;
78
77
 
79
78
  // Clamp position within the slider width
80
79
  const clampedPosition = Math.max(0, Math.min(position, sliderWidth));
81
- // Calculate nearest step position
80
+ // Calculate steps with decimal precision
82
81
  const stepCount = Math.round(clampedPosition / stepSize);
83
82
 
84
- return min + stepCount
83
+ // Calculate the value with proper decimal precision
84
+ const value = min + (stepCount * step);
85
+ // Round to avoid floating-point precision errors
86
+ return Number(value.toFixed(10));
85
87
  };
86
88
 
87
89
  const onDrag = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run customPrepublish && npm run generate-index && vite build && npm run package && npm run postpublish",