tera-system-ui 0.1.5 → 0.1.7

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 {};
@@ -22,36 +22,42 @@
22
22
 
23
23
  $effect(() => {
24
24
  if (!slider || !sliderHandle || !sliderTrack || !sliderRail) return
25
+
26
+ const stopDragging = () => {
27
+ document.removeEventListener('pointermove', onDrag);
28
+ document.removeEventListener('touchmove', onDrag);
29
+ sliderHandle?.removeAttribute('data-state');
30
+ toggleToolTip(false);
31
+ };
32
+
25
33
  slider.addEventListener('pointerdown', (e) => {
26
34
  sliderHandle.setAttribute('data-state', 'dragging');
27
- onDrag(e)
35
+ onDrag(e);
28
36
  document.addEventListener('pointermove', onDrag);
29
- document.addEventListener('pointerup', () => {
30
- document.removeEventListener('pointermove', onDrag);
31
- sliderHandle.removeAttribute('data-state');
32
- toggleToolTip(false)
33
-
34
- }, {once: true});
37
+ document.addEventListener('pointerup', stopDragging, {once: true});
38
+
39
+ // Add mouseout listener to window
40
+ window.addEventListener('mouseout', (e) => {
41
+ if ((e.relatedTarget as HTMLElement)?.tagName === 'IFRAME') { // Mouse left the window
42
+ stopDragging();
43
+ }
44
+ });
35
45
  });
36
46
 
37
47
  // For touch support
38
48
  slider.addEventListener('touchstart', (e) => {
39
49
  sliderHandle.setAttribute('data-state', 'dragging');
40
- onDrag(e)
41
- document.addEventListener('touchmove', onDrag);
42
- document.addEventListener('touchend', () => {
43
- document.removeEventListener('touchmove', onDrag);
44
- toggleToolTip(false)
45
- sliderHandle.removeAttribute('data-state');
46
- }, {once: true});
47
- });
50
+ onDrag(e);
51
+ document.addEventListener('touchmove', onDrag, {passive: false});
52
+ document.addEventListener('touchend', stopDragging, {once: true});
53
+ }, {passive: false});
48
54
 
49
55
  sliderHandle.addEventListener('pointerenter', (e) => {
50
- toggleToolTip(true)
56
+ toggleToolTip(true);
51
57
  sliderHandle.addEventListener('pointerleave', (e) => {
52
- toggleToolTip(false)
58
+ toggleToolTip(false);
53
59
  }, {once: true});
54
- })
60
+ });
55
61
 
56
62
  })
57
63
 
@@ -61,10 +67,10 @@
61
67
  if (tooltipInterval) clearInterval(tooltipInterval)
62
68
 
63
69
  if (open) {
64
- sliderTooltip.classList.add('show');
70
+ sliderTooltip?.classList.add('show');
65
71
  } else {
66
72
  tooltipInterval = setTimeout(() => {
67
- sliderTooltip.classList.remove('show');
73
+ sliderTooltip?.classList.remove('show');
68
74
  }, 300)
69
75
 
70
76
  }
@@ -72,16 +78,18 @@
72
78
 
73
79
  const calculateValue = (position) => {
74
80
  const sliderWidth = sliderRail.offsetWidth;
75
-
76
- // calculate step size in px
77
- const stepSize = sliderWidth / ((max - min) / step)
81
+ const totalSteps = (max - min) / step;
82
+ const stepSize = sliderWidth / totalSteps;
78
83
 
79
84
  // Clamp position within the slider width
80
85
  const clampedPosition = Math.max(0, Math.min(position, sliderWidth));
81
- // Calculate nearest step position
86
+ // Calculate steps with decimal precision
82
87
  const stepCount = Math.round(clampedPosition / stepSize);
83
88
 
84
- return min + stepCount
89
+ // Calculate the value with proper decimal precision
90
+ const value = min + (stepCount * step);
91
+ // Round to avoid floating-point precision errors
92
+ return Number(value.toFixed(10));
85
93
  };
86
94
 
87
95
  const onDrag = (event) => {
@@ -1,3 +1,2 @@
1
1
  import { OpenAI } from "openai";
2
2
  new OpenAI();
3
- i18n / projects / { projectName } / project.;
@@ -8,7 +8,7 @@
8
8
  "text_age_calculator_description": "இரண்டு தேதிகளுக்கிடையேயான துல்லியமான வயது அல்லது இடைவெளியை கணக்கிடுங்கள்",
9
9
  "text_date_of_birth_need_to_earlier_than_the_age_at_date": "பிறந்த தேதி, வயது வரை தேதிக்குள் இருக்க வேண்டும்!",
10
10
  "text_date_of_birth": "பிறந்த தேதி",
11
- "text_age_at_the_date_of": "{date} தேதி வரை வயது",
11
+ "text_age_at_the_date_of": "தேதி வரை வயது",
12
12
  "text_calculating": "கணக்கிட்டுக்கொண்டிருக்கிறது...",
13
13
  "text_result": "முடிவு",
14
14
  "text_message": "செய்தி",
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.7",
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",