@vuer-ai/vuer-uikit 0.0.22 → 0.0.24

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.
@@ -2,10 +2,13 @@
2
2
 
3
3
  var chunkSKO72K64_js = require('./chunk-SKO72K64.js');
4
4
  var chunkXXWQ4RVP_js = require('./chunk-XXWQ4RVP.js');
5
- var react$1 = require('@use-gesture/react');
6
- var react = require('react');
5
+ var React = require('react');
7
6
  var jsxRuntime = require('react/jsx-runtime');
8
7
 
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
11
+
9
12
  var getHoverElementAndIndex = (element, inputs) => {
10
13
  if (!element) return null;
11
14
  const container = element == null ? void 0 : element.closest("[data-input]");
@@ -26,12 +29,14 @@ var changeElementsHoverState = (inputs, range, changed) => {
26
29
  }
27
30
  });
28
31
  };
29
- var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValuesChange, prefix, step = 0.1 }, ref) {
30
- const inputs = react.useRef(/* @__PURE__ */ new Map());
31
- const selectRange = react.useRef([null, null]);
32
- const inputChange = react.useRef(false);
33
- const stopClick = react.useCallback(() => {
34
- if (typeof document === "undefined") return;
32
+ var InputNumbers = React.forwardRef(function InputNumbers2({ size, value, onValuesChange, prefix, step = 0.1 }, ref) {
33
+ const inputs = React.useRef(/* @__PURE__ */ new Map());
34
+ const selectRange = React.useRef([null, null]);
35
+ const inputChange = React.useRef(false);
36
+ const [isDragging, setIsDragging] = React.useState(false);
37
+ const dragStart = React.useRef({ x: 0, y: 0 });
38
+ const accumulatedDelta = React.useRef(0);
39
+ const stopClick = React.useCallback(() => {
35
40
  const stopClick2 = (e) => {
36
41
  e.stopPropagation();
37
42
  e.preventDefault();
@@ -39,51 +44,84 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
39
44
  };
40
45
  document.addEventListener("click", stopClick2, true);
41
46
  }, []);
42
- const bind = react$1.useGesture({
43
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
44
- event.stopPropagation();
45
- event.preventDefault();
46
- if (selectRange.current[0] === null) {
47
- selectRange.current[0] = getHoverElementAndIndex(
48
- typeof document !== "undefined" ? document.elementFromPoint(...initial) : null,
49
- inputs.current
50
- );
51
- }
52
- let newMX = memo + dx / 2;
53
- if (Math.abs(newMX) >= (inputChange.current ? 1 : 5)) {
54
- const multiplyStep = event.shiftKey ? 5 : event.altKey ? 1 / 5 : 1;
47
+ const handleMouseDown = React.useCallback((e) => {
48
+ if (e.button !== 0) return;
49
+ e.preventDefault();
50
+ e.stopPropagation();
51
+ setIsDragging(true);
52
+ dragStart.current = { x: e.clientX, y: e.clientY };
53
+ accumulatedDelta.current = 0;
54
+ inputChange.current = false;
55
+ selectRange.current[0] = getHoverElementAndIndex(
56
+ document.elementFromPoint(e.clientX, e.clientY),
57
+ inputs.current
58
+ );
59
+ }, []);
60
+ const handleMouseMove = React.useCallback(
61
+ (e) => {
62
+ if (!isDragging) return;
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ const deltaX = e.clientX - dragStart.current.x;
66
+ const deltaY = e.clientY - dragStart.current.y;
67
+ accumulatedDelta.current += deltaX / 2;
68
+ dragStart.current = { x: e.clientX, y: e.clientY };
69
+ if (Math.abs(accumulatedDelta.current) >= (inputChange.current ? 1 : 5)) {
70
+ const multiplyStep = e.shiftKey ? 5 : e.altKey ? 1 / 5 : 1;
55
71
  const newValue = value.map((v, i) => {
56
72
  const [first, last] = selectRange.current;
57
73
  if (first === null || last === null) {
58
74
  return v;
59
75
  } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
60
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
76
+ return Number(
77
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
78
+ 6
79
+ )
80
+ );
61
81
  } else {
62
82
  return v;
63
83
  }
64
84
  });
65
85
  onValuesChange == null ? void 0 : onValuesChange(newValue);
66
- newMX = 0;
86
+ accumulatedDelta.current = 0;
67
87
  inputChange.current = true;
68
88
  changeElementsHoverState(inputs.current, selectRange.current, "x");
69
89
  stopClick();
70
90
  }
71
91
  if (!inputChange.current) {
72
- const currentElement = typeof document !== "undefined" ? document.elementFromPoint(...xy) : null;
92
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
73
93
  const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
74
94
  selectRange.current[1] = currentIndex ?? selectRange.current[1];
75
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
95
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
76
96
  stopClick();
77
97
  }
78
- return newMX;
79
98
  },
80
- onDragEnd: () => {
81
- selectRange.current = [null, null];
82
- inputChange.current = false;
83
- changeElementsHoverState(inputs.current, selectRange.current, "none");
99
+ [isDragging, value, onValuesChange, step, stopClick]
100
+ );
101
+ const handleMouseUp = React.useCallback(() => {
102
+ if (!isDragging) return;
103
+ setIsDragging(false);
104
+ selectRange.current = [null, null];
105
+ inputChange.current = false;
106
+ changeElementsHoverState(inputs.current, selectRange.current, "none");
107
+ }, [isDragging]);
108
+ React__default.default.useEffect(() => {
109
+ if (isDragging) {
110
+ const handleGlobalMouseMove = (e) => {
111
+ handleMouseMove(e);
112
+ };
113
+ const handleGlobalMouseUp = () => {
114
+ handleMouseUp();
115
+ };
116
+ document.addEventListener("mousemove", handleGlobalMouseMove);
117
+ document.addEventListener("mouseup", handleGlobalMouseUp);
118
+ return () => {
119
+ document.removeEventListener("mousemove", handleGlobalMouseMove);
120
+ document.removeEventListener("mouseup", handleGlobalMouseUp);
121
+ };
84
122
  }
85
- });
86
- const valueChangeHandler = react.useCallback(
123
+ }, [isDragging, handleMouseMove, handleMouseUp]);
124
+ const valueChangeHandler = React.useCallback(
87
125
  (index) => {
88
126
  return (e) => {
89
127
  const inputValue = e.target.value;
@@ -107,7 +145,7 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
107
145
  "div",
108
146
  {
109
147
  ref,
110
- ...bind(),
148
+ onMouseDown: handleMouseDown,
111
149
  className: chunkXXWQ4RVP_js.cn("gap-xs flex cursor-crosshair touch-none flex-col select-none"),
112
150
  children: value.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
113
151
  chunkSKO72K64_js.InputRoot,
@@ -134,13 +172,13 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
134
172
  "data-[hover=y]:bg-bg-tertiary",
135
173
  "data-[hover=down]:cursor-move",
136
174
  "data-[hover=x]:cursor-col-resize",
137
- "data-[hover=y]:cursor-ns-resize"
175
+ "data-[hover=y]:cursor-row-resize"
138
176
  ]),
139
177
  inputClassName: chunkXXWQ4RVP_js.cn([
140
178
  "cursor-crosshair",
141
179
  "group-data-[hover=down]/number-input:cursor-move",
142
180
  "group-data-[hover=x]/number-input:cursor-col-resize",
143
- "group-data-[hover=y]/number-input:cursor-ns-resize"
181
+ "group-data-[hover=y]/number-input:cursor-row-resize"
144
182
  ]),
145
183
  children: /* @__PURE__ */ jsxRuntime.jsx(
146
184
  chunkSKO72K64_js.InputSlot,
@@ -149,7 +187,7 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
149
187
  "cursor-crosshair",
150
188
  "group-data-[hover=down]/number-input:cursor-move",
151
189
  "group-data-[hover=x]/number-input:cursor-col-resize",
152
- "group-data-[hover=y]/number-input:cursor-ns-resize"
190
+ "group-data-[hover=y]/number-input:cursor-row-resize"
153
191
  ),
154
192
  children: prefix == null ? void 0 : prefix[index]
155
193
  }
@@ -1,7 +1,7 @@
1
1
  import { Badge } from './chunk-WO3WHXDP.mjs';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
- var PACKAGE_VERSION = "0.0.22" ;
4
+ var PACKAGE_VERSION = "0.0.24" ;
5
5
  var PACKAGE_NAME = "@vuer-ai/vuer-uikit" ;
6
6
  function VersionBadge({
7
7
  className,
@@ -1,7 +1,6 @@
1
1
  import { InputRoot, InputSlot } from './chunk-QYRRQ65X.mjs';
2
2
  import { cn } from './chunk-KTNZSZ5Y.mjs';
3
- import { useGesture } from '@use-gesture/react';
4
- import { forwardRef, useRef, useCallback } from 'react';
3
+ import React, { forwardRef, useRef, useState, useCallback } from 'react';
5
4
  import { jsx } from 'react/jsx-runtime';
6
5
 
7
6
  var getHoverElementAndIndex = (element, inputs) => {
@@ -28,8 +27,10 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
28
27
  const inputs = useRef(/* @__PURE__ */ new Map());
29
28
  const selectRange = useRef([null, null]);
30
29
  const inputChange = useRef(false);
30
+ const [isDragging, setIsDragging] = useState(false);
31
+ const dragStart = useRef({ x: 0, y: 0 });
32
+ const accumulatedDelta = useRef(0);
31
33
  const stopClick = useCallback(() => {
32
- if (typeof document === "undefined") return;
33
34
  const stopClick2 = (e) => {
34
35
  e.stopPropagation();
35
36
  e.preventDefault();
@@ -37,50 +38,83 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
37
38
  };
38
39
  document.addEventListener("click", stopClick2, true);
39
40
  }, []);
40
- const bind = useGesture({
41
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
42
- event.stopPropagation();
43
- event.preventDefault();
44
- if (selectRange.current[0] === null) {
45
- selectRange.current[0] = getHoverElementAndIndex(
46
- typeof document !== "undefined" ? document.elementFromPoint(...initial) : null,
47
- inputs.current
48
- );
49
- }
50
- let newMX = memo + dx / 2;
51
- if (Math.abs(newMX) >= (inputChange.current ? 1 : 5)) {
52
- const multiplyStep = event.shiftKey ? 5 : event.altKey ? 1 / 5 : 1;
41
+ const handleMouseDown = useCallback((e) => {
42
+ if (e.button !== 0) return;
43
+ e.preventDefault();
44
+ e.stopPropagation();
45
+ setIsDragging(true);
46
+ dragStart.current = { x: e.clientX, y: e.clientY };
47
+ accumulatedDelta.current = 0;
48
+ inputChange.current = false;
49
+ selectRange.current[0] = getHoverElementAndIndex(
50
+ document.elementFromPoint(e.clientX, e.clientY),
51
+ inputs.current
52
+ );
53
+ }, []);
54
+ const handleMouseMove = useCallback(
55
+ (e) => {
56
+ if (!isDragging) return;
57
+ e.preventDefault();
58
+ e.stopPropagation();
59
+ const deltaX = e.clientX - dragStart.current.x;
60
+ const deltaY = e.clientY - dragStart.current.y;
61
+ accumulatedDelta.current += deltaX / 2;
62
+ dragStart.current = { x: e.clientX, y: e.clientY };
63
+ if (Math.abs(accumulatedDelta.current) >= (inputChange.current ? 1 : 5)) {
64
+ const multiplyStep = e.shiftKey ? 5 : e.altKey ? 1 / 5 : 1;
53
65
  const newValue = value.map((v, i) => {
54
66
  const [first, last] = selectRange.current;
55
67
  if (first === null || last === null) {
56
68
  return v;
57
69
  } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
58
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
70
+ return Number(
71
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
72
+ 6
73
+ )
74
+ );
59
75
  } else {
60
76
  return v;
61
77
  }
62
78
  });
63
79
  onValuesChange == null ? void 0 : onValuesChange(newValue);
64
- newMX = 0;
80
+ accumulatedDelta.current = 0;
65
81
  inputChange.current = true;
66
82
  changeElementsHoverState(inputs.current, selectRange.current, "x");
67
83
  stopClick();
68
84
  }
69
85
  if (!inputChange.current) {
70
- const currentElement = typeof document !== "undefined" ? document.elementFromPoint(...xy) : null;
86
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
71
87
  const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
72
88
  selectRange.current[1] = currentIndex ?? selectRange.current[1];
73
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
89
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
74
90
  stopClick();
75
91
  }
76
- return newMX;
77
92
  },
78
- onDragEnd: () => {
79
- selectRange.current = [null, null];
80
- inputChange.current = false;
81
- changeElementsHoverState(inputs.current, selectRange.current, "none");
93
+ [isDragging, value, onValuesChange, step, stopClick]
94
+ );
95
+ const handleMouseUp = useCallback(() => {
96
+ if (!isDragging) return;
97
+ setIsDragging(false);
98
+ selectRange.current = [null, null];
99
+ inputChange.current = false;
100
+ changeElementsHoverState(inputs.current, selectRange.current, "none");
101
+ }, [isDragging]);
102
+ React.useEffect(() => {
103
+ if (isDragging) {
104
+ const handleGlobalMouseMove = (e) => {
105
+ handleMouseMove(e);
106
+ };
107
+ const handleGlobalMouseUp = () => {
108
+ handleMouseUp();
109
+ };
110
+ document.addEventListener("mousemove", handleGlobalMouseMove);
111
+ document.addEventListener("mouseup", handleGlobalMouseUp);
112
+ return () => {
113
+ document.removeEventListener("mousemove", handleGlobalMouseMove);
114
+ document.removeEventListener("mouseup", handleGlobalMouseUp);
115
+ };
82
116
  }
83
- });
117
+ }, [isDragging, handleMouseMove, handleMouseUp]);
84
118
  const valueChangeHandler = useCallback(
85
119
  (index) => {
86
120
  return (e) => {
@@ -105,7 +139,7 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
105
139
  "div",
106
140
  {
107
141
  ref,
108
- ...bind(),
142
+ onMouseDown: handleMouseDown,
109
143
  className: cn("gap-xs flex cursor-crosshair touch-none flex-col select-none"),
110
144
  children: value.map((item, index) => /* @__PURE__ */ jsx(
111
145
  InputRoot,
@@ -132,13 +166,13 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
132
166
  "data-[hover=y]:bg-bg-tertiary",
133
167
  "data-[hover=down]:cursor-move",
134
168
  "data-[hover=x]:cursor-col-resize",
135
- "data-[hover=y]:cursor-ns-resize"
169
+ "data-[hover=y]:cursor-row-resize"
136
170
  ]),
137
171
  inputClassName: cn([
138
172
  "cursor-crosshair",
139
173
  "group-data-[hover=down]/number-input:cursor-move",
140
174
  "group-data-[hover=x]/number-input:cursor-col-resize",
141
- "group-data-[hover=y]/number-input:cursor-ns-resize"
175
+ "group-data-[hover=y]/number-input:cursor-row-resize"
142
176
  ]),
143
177
  children: /* @__PURE__ */ jsx(
144
178
  InputSlot,
@@ -147,7 +181,7 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
147
181
  "cursor-crosshair",
148
182
  "group-data-[hover=down]/number-input:cursor-move",
149
183
  "group-data-[hover=x]/number-input:cursor-col-resize",
150
- "group-data-[hover=y]/number-input:cursor-ns-resize"
184
+ "group-data-[hover=y]/number-input:cursor-row-resize"
151
185
  ),
152
186
  children: prefix == null ? void 0 : prefix[index]
153
187
  }
@@ -3,7 +3,7 @@
3
3
  var chunkEFIRD3FN_js = require('./chunk-EFIRD3FN.js');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
 
6
- var PACKAGE_VERSION = "0.0.22" ;
6
+ var PACKAGE_VERSION = "0.0.24" ;
7
7
  var PACKAGE_NAME = "@vuer-ai/vuer-uikit" ;
8
8
  function VersionBadge({
9
9
  className,
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require('./chunk-N7CINZS2.js');
4
4
  var chunk2YCL2ET2_js = require('./chunk-2YCL2ET2.js');
5
- var chunk6ESGGXBG_js = require('./chunk-6ESGGXBG.js');
5
+ var chunkOO7LYJQL_js = require('./chunk-OO7LYJQL.js');
6
6
  var chunkH5P4IX7R_js = require('./chunk-H5P4IX7R.js');
7
7
  var chunkPVRQNCSJ_js = require('./chunk-PVRQNCSJ.js');
8
8
  var chunkAOUGWGQR_js = require('./chunk-AOUGWGQR.js');
@@ -22,7 +22,7 @@ var chunkX55EAYE2_js = require('./chunk-X55EAYE2.js');
22
22
  var chunk5TVG5JK5_js = require('./chunk-5TVG5JK5.js');
23
23
  var chunk2JCULHBM_js = require('./chunk-2JCULHBM.js');
24
24
  var chunkFP26SRGL_js = require('./chunk-FP26SRGL.js');
25
- var chunkFORVP7XH_js = require('./chunk-FORVP7XH.js');
25
+ var chunk6RTJSAVW_js = require('./chunk-6RTJSAVW.js');
26
26
  var chunk6N5422RT_js = require('./chunk-6N5422RT.js');
27
27
  require('./chunk-KJ42IGH6.js');
28
28
  var chunkQEY7BWIR_js = require('./chunk-QEY7BWIR.js');
@@ -47,7 +47,7 @@ Object.defineProperty(exports, "TreeView", {
47
47
  });
48
48
  Object.defineProperty(exports, "VersionBadge", {
49
49
  enumerable: true,
50
- get: function () { return chunk6ESGGXBG_js.VersionBadge; }
50
+ get: function () { return chunkOO7LYJQL_js.VersionBadge; }
51
51
  });
52
52
  Object.defineProperty(exports, "Switch", {
53
53
  enumerable: true,
@@ -327,7 +327,7 @@ Object.defineProperty(exports, "DropdownMenuTrigger", {
327
327
  });
328
328
  Object.defineProperty(exports, "InputNumbers", {
329
329
  enumerable: true,
330
- get: function () { return chunkFORVP7XH_js.InputNumbers; }
330
+ get: function () { return chunk6RTJSAVW_js.InputNumbers; }
331
331
  });
332
332
  Object.defineProperty(exports, "Avatar", {
333
333
  enumerable: true,
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import './chunk-F56ZKT7B.mjs';
2
2
  export { TreeView } from './chunk-UKFVRXAR.mjs';
3
- export { VersionBadge } from './chunk-YW3YL6GR.mjs';
3
+ export { VersionBadge } from './chunk-FEYQ2OWB.mjs';
4
4
  export { Switch } from './chunk-JAMJUXBY.mjs';
5
5
  export { ThemeProvider, useTheme } from './chunk-LEPXSM36.mjs';
6
6
  export { Timeline } from './chunk-ZVG2UKKC.mjs';
@@ -20,7 +20,7 @@ export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader,
20
20
  export { Checkbox } from './chunk-G6PRZVSE.mjs';
21
21
  export { Collapsible, CollapsibleContent, CollapsibleTrigger } from './chunk-FRT225GK.mjs';
22
22
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './chunk-EUY74AXP.mjs';
23
- export { InputNumbers } from './chunk-G5KMD72J.mjs';
23
+ export { InputNumbers } from './chunk-H5C3BWSK.mjs';
24
24
  export { Avatar, AvatarFallback, AvatarGroup, AvatarImage } from './chunk-F776EMXP.mjs';
25
25
  import './chunk-VGCVIHBR.mjs';
26
26
  export { CursorProvider } from './chunk-OOI3SJDU.mjs';
package/dist/ui/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require('../chunk-N7CINZS2.js');
4
4
  var chunk2YCL2ET2_js = require('../chunk-2YCL2ET2.js');
5
- var chunk6ESGGXBG_js = require('../chunk-6ESGGXBG.js');
5
+ var chunkOO7LYJQL_js = require('../chunk-OO7LYJQL.js');
6
6
  var chunkH5P4IX7R_js = require('../chunk-H5P4IX7R.js');
7
7
  var chunkPVRQNCSJ_js = require('../chunk-PVRQNCSJ.js');
8
8
  var chunkAOUGWGQR_js = require('../chunk-AOUGWGQR.js');
@@ -22,7 +22,7 @@ var chunkX55EAYE2_js = require('../chunk-X55EAYE2.js');
22
22
  var chunk5TVG5JK5_js = require('../chunk-5TVG5JK5.js');
23
23
  var chunk2JCULHBM_js = require('../chunk-2JCULHBM.js');
24
24
  var chunkFP26SRGL_js = require('../chunk-FP26SRGL.js');
25
- var chunkFORVP7XH_js = require('../chunk-FORVP7XH.js');
25
+ var chunk6RTJSAVW_js = require('../chunk-6RTJSAVW.js');
26
26
  var chunk6N5422RT_js = require('../chunk-6N5422RT.js');
27
27
  var chunkIXHMIR5P_js = require('../chunk-IXHMIR5P.js');
28
28
  var chunk5OUTEHVX_js = require('../chunk-5OUTEHVX.js');
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "TreeView", {
42
42
  });
43
43
  Object.defineProperty(exports, "VersionBadge", {
44
44
  enumerable: true,
45
- get: function () { return chunk6ESGGXBG_js.VersionBadge; }
45
+ get: function () { return chunkOO7LYJQL_js.VersionBadge; }
46
46
  });
47
47
  Object.defineProperty(exports, "Switch", {
48
48
  enumerable: true,
@@ -322,7 +322,7 @@ Object.defineProperty(exports, "DropdownMenuTrigger", {
322
322
  });
323
323
  Object.defineProperty(exports, "InputNumbers", {
324
324
  enumerable: true,
325
- get: function () { return chunkFORVP7XH_js.InputNumbers; }
325
+ get: function () { return chunk6RTJSAVW_js.InputNumbers; }
326
326
  });
327
327
  Object.defineProperty(exports, "Avatar", {
328
328
  enumerable: true,
package/dist/ui/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../chunk-F56ZKT7B.mjs';
2
2
  export { TreeView } from '../chunk-UKFVRXAR.mjs';
3
- export { VersionBadge } from '../chunk-YW3YL6GR.mjs';
3
+ export { VersionBadge } from '../chunk-FEYQ2OWB.mjs';
4
4
  export { Switch } from '../chunk-JAMJUXBY.mjs';
5
5
  export { ThemeProvider, useTheme } from '../chunk-LEPXSM36.mjs';
6
6
  export { Timeline } from '../chunk-ZVG2UKKC.mjs';
@@ -20,7 +20,7 @@ export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader,
20
20
  export { Checkbox } from '../chunk-G6PRZVSE.mjs';
21
21
  export { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../chunk-FRT225GK.mjs';
22
22
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from '../chunk-EUY74AXP.mjs';
23
- export { InputNumbers } from '../chunk-G5KMD72J.mjs';
23
+ export { InputNumbers } from '../chunk-H5C3BWSK.mjs';
24
24
  export { Avatar, AvatarFallback, AvatarGroup, AvatarImage } from '../chunk-F776EMXP.mjs';
25
25
  export { Tabs, TabsContent, TabsList, TabsTrigger } from '../chunk-MRVMXKZO.mjs';
26
26
  export { Textarea } from '../chunk-DDOX4EEM.mjs';
@@ -1,5 +1,4 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
1
+ import react__default, { ReactNode } from 'react';
3
2
  import { InputRootProps } from './input.mjs';
4
3
  import 'class-variance-authority/types';
5
4
  import 'class-variance-authority';
@@ -10,6 +9,6 @@ interface InputNumbersProps extends Pick<InputRootProps, "size"> {
10
9
  prefix?: ReactNode[];
11
10
  onValuesChange?: (value: Array<number>) => void;
12
11
  }
13
- declare const InputNumbers: react.ForwardRefExoticComponent<InputNumbersProps & react.RefAttributes<HTMLDivElement>>;
12
+ declare const InputNumbers: react__default.ForwardRefExoticComponent<InputNumbersProps & react__default.RefAttributes<HTMLDivElement>>;
14
13
 
15
14
  export { InputNumbers, type InputNumbersProps };
@@ -1,5 +1,4 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
1
+ import react__default, { ReactNode } from 'react';
3
2
  import { InputRootProps } from './input.js';
4
3
  import 'class-variance-authority/types';
5
4
  import 'class-variance-authority';
@@ -10,6 +9,6 @@ interface InputNumbersProps extends Pick<InputRootProps, "size"> {
10
9
  prefix?: ReactNode[];
11
10
  onValuesChange?: (value: Array<number>) => void;
12
11
  }
13
- declare const InputNumbers: react.ForwardRefExoticComponent<InputNumbersProps & react.RefAttributes<HTMLDivElement>>;
12
+ declare const InputNumbers: react__default.ForwardRefExoticComponent<InputNumbersProps & react__default.RefAttributes<HTMLDivElement>>;
14
13
 
15
14
  export { InputNumbers, type InputNumbersProps };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFORVP7XH_js = require('../chunk-FORVP7XH.js');
3
+ var chunk6RTJSAVW_js = require('../chunk-6RTJSAVW.js');
4
4
  require('../chunk-SKO72K64.js');
5
5
  require('../chunk-XWS4SIB5.js');
6
6
  require('../chunk-EOFYA6CS.js');
@@ -10,5 +10,5 @@ require('../chunk-XXWQ4RVP.js');
10
10
 
11
11
  Object.defineProperty(exports, "InputNumbers", {
12
12
  enumerable: true,
13
- get: function () { return chunkFORVP7XH_js.InputNumbers; }
13
+ get: function () { return chunk6RTJSAVW_js.InputNumbers; }
14
14
  });
@@ -1,4 +1,4 @@
1
- export { InputNumbers } from '../chunk-G5KMD72J.mjs';
1
+ export { InputNumbers } from '../chunk-H5C3BWSK.mjs';
2
2
  import '../chunk-QYRRQ65X.mjs';
3
3
  import '../chunk-M4IVLZIH.mjs';
4
4
  import '../chunk-Q5KEB4UK.mjs';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk6ESGGXBG_js = require('../chunk-6ESGGXBG.js');
3
+ var chunkOO7LYJQL_js = require('../chunk-OO7LYJQL.js');
4
4
  require('../chunk-EFIRD3FN.js');
5
5
  require('../chunk-XWS4SIB5.js');
6
6
  require('../chunk-EOFYA6CS.js');
@@ -10,5 +10,5 @@ require('../chunk-XXWQ4RVP.js');
10
10
 
11
11
  Object.defineProperty(exports, "VersionBadge", {
12
12
  enumerable: true,
13
- get: function () { return chunk6ESGGXBG_js.VersionBadge; }
13
+ get: function () { return chunkOO7LYJQL_js.VersionBadge; }
14
14
  });
@@ -1,4 +1,4 @@
1
- export { VersionBadge } from '../chunk-YW3YL6GR.mjs';
1
+ export { VersionBadge } from '../chunk-FEYQ2OWB.mjs';
2
2
  import '../chunk-WO3WHXDP.mjs';
3
3
  import '../chunk-M4IVLZIH.mjs';
4
4
  import '../chunk-Q5KEB4UK.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuer-ai/vuer-uikit",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "React UI Kit components",
5
5
  "keywords": [
6
6
  "react",
@@ -52,7 +52,6 @@
52
52
  "@radix-ui/react-toggle": "^1.1.1",
53
53
  "@radix-ui/react-toggle-group": "^1.1.1",
54
54
  "@radix-ui/react-tooltip": "^1.1.10",
55
- "@use-gesture/react": "^10.3.1",
56
55
  "class-variance-authority": "^0.7.1",
57
56
  "clsx": "^2.1.1",
58
57
  "framer-motion": "^11.15.0",
@@ -1,5 +1,12 @@
1
- import { useGesture } from "@use-gesture/react";
2
- import { ChangeEvent, forwardRef, ReactNode, useCallback, useRef } from "react";
1
+ import React, {
2
+ ChangeEvent,
3
+ forwardRef,
4
+ ReactNode,
5
+ useCallback,
6
+ useRef,
7
+ useState,
8
+ MouseEvent as ReactMouseEvent,
9
+ } from "react";
3
10
 
4
11
  import { InputRoot, InputRootProps, InputSlot } from "./input";
5
12
  import { cn } from "../utils";
@@ -51,11 +58,12 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
51
58
  const inputs = useRef<Map<string, HTMLInputElement | null>>(new Map());
52
59
  const selectRange = useRef<[number | null, number | null]>([null, null]);
53
60
  const inputChange = useRef(false);
61
+ const [isDragging, setIsDragging] = useState(false);
62
+ const dragStart = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
63
+ const accumulatedDelta = useRef(0);
54
64
 
55
65
  const stopClick = useCallback(() => {
56
- if (typeof document === "undefined") return;
57
-
58
- const stopClick = (e: MouseEvent) => {
66
+ const stopClick = (e: Event) => {
59
67
  e.stopPropagation();
60
68
  e.preventDefault();
61
69
  document.removeEventListener("click", stopClick, true);
@@ -63,62 +71,101 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
63
71
  document.addEventListener("click", stopClick, true);
64
72
  }, []);
65
73
 
66
- const bind = useGesture({
67
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
68
- event.stopPropagation();
69
- event.preventDefault();
74
+ const handleMouseDown = useCallback((e: ReactMouseEvent) => {
75
+ if (e.button !== 0) return; // Only left mouse button
70
76
 
71
- if (selectRange.current[0] === null) {
72
- selectRange.current[0] = getHoverElementAndIndex(
73
- typeof document !== "undefined" ? document.elementFromPoint(...initial) : null,
74
- inputs.current,
75
- );
76
- }
77
+ e.preventDefault();
78
+ e.stopPropagation();
77
79
 
78
- let newMX: number = memo + dx / 2;
80
+ setIsDragging(true);
81
+ dragStart.current = { x: e.clientX, y: e.clientY };
82
+ accumulatedDelta.current = 0;
83
+ inputChange.current = false;
84
+
85
+ selectRange.current[0] = getHoverElementAndIndex(
86
+ document.elementFromPoint(e.clientX, e.clientY),
87
+ inputs.current,
88
+ );
89
+ }, []);
79
90
 
80
- if (Math.abs(newMX) >= (inputChange.current ? 1 : 5)) {
81
- const multiplyStep = event.shiftKey ? 5 : event.altKey ? 1 / 5 : 1;
91
+ const handleMouseMove = useCallback(
92
+ (e: MouseEvent) => {
93
+ if (!isDragging) return;
94
+
95
+ e.preventDefault();
96
+ e.stopPropagation();
97
+
98
+ const deltaX = e.clientX - dragStart.current.x;
99
+ const deltaY = e.clientY - dragStart.current.y;
100
+
101
+ accumulatedDelta.current += deltaX / 2;
102
+ dragStart.current = { x: e.clientX, y: e.clientY };
103
+
104
+ if (Math.abs(accumulatedDelta.current) >= (inputChange.current ? 1 : 5)) {
105
+ const multiplyStep = e.shiftKey ? 5 : e.altKey ? 1 / 5 : 1;
82
106
 
83
107
  const newValue = value.map((v, i) => {
84
108
  const [first, last] = selectRange.current;
85
109
  if (first === null || last === null) {
86
110
  return v;
87
111
  } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
88
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
112
+ return Number(
113
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
114
+ 6,
115
+ ),
116
+ );
89
117
  } else {
90
118
  return v;
91
119
  }
92
120
  });
93
121
  onValuesChange?.(newValue);
94
- newMX = 0;
122
+ accumulatedDelta.current = 0;
95
123
  inputChange.current = true;
96
124
 
97
125
  changeElementsHoverState(inputs.current, selectRange.current, "x");
98
-
99
126
  stopClick();
100
127
  }
101
128
 
102
129
  if (!inputChange.current) {
103
- const currentElement =
104
- typeof document !== "undefined" ? document.elementFromPoint(...xy) : null;
105
-
130
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
106
131
  const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
107
132
  selectRange.current[1] = currentIndex ?? selectRange.current[1];
108
133
 
109
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
110
-
134
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
111
135
  stopClick();
112
136
  }
113
-
114
- return newMX;
115
- },
116
- onDragEnd: () => {
117
- selectRange.current = [null, null];
118
- inputChange.current = false;
119
- changeElementsHoverState(inputs.current, selectRange.current, "none");
120
137
  },
121
- });
138
+ [isDragging, value, onValuesChange, step, stopClick],
139
+ );
140
+
141
+ const handleMouseUp = useCallback(() => {
142
+ if (!isDragging) return;
143
+
144
+ setIsDragging(false);
145
+ selectRange.current = [null, null];
146
+ inputChange.current = false;
147
+ changeElementsHoverState(inputs.current, selectRange.current, "none");
148
+ }, [isDragging]);
149
+
150
+ // Add global mouse event listeners
151
+ React.useEffect(() => {
152
+ if (isDragging) {
153
+ const handleGlobalMouseMove = (e: MouseEvent) => {
154
+ handleMouseMove(e);
155
+ };
156
+ const handleGlobalMouseUp = () => {
157
+ handleMouseUp();
158
+ };
159
+
160
+ document.addEventListener("mousemove", handleGlobalMouseMove);
161
+ document.addEventListener("mouseup", handleGlobalMouseUp);
162
+
163
+ return () => {
164
+ document.removeEventListener("mousemove", handleGlobalMouseMove);
165
+ document.removeEventListener("mouseup", handleGlobalMouseUp);
166
+ };
167
+ }
168
+ }, [isDragging, handleMouseMove, handleMouseUp]);
122
169
 
123
170
  const valueChangeHandler = useCallback(
124
171
  (index: number) => {
@@ -145,7 +192,7 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
145
192
  return (
146
193
  <div
147
194
  ref={ref}
148
- {...bind()}
195
+ onMouseDown={handleMouseDown}
149
196
  className={cn("gap-xs flex cursor-crosshair touch-none flex-col select-none")}
150
197
  >
151
198
  {value.map((item, index) => (
@@ -172,13 +219,13 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
172
219
  "data-[hover=y]:bg-bg-tertiary",
173
220
  "data-[hover=down]:cursor-move",
174
221
  "data-[hover=x]:cursor-col-resize",
175
- "data-[hover=y]:cursor-ns-resize",
222
+ "data-[hover=y]:cursor-row-resize",
176
223
  ])}
177
224
  inputClassName={cn([
178
225
  "cursor-crosshair",
179
226
  "group-data-[hover=down]/number-input:cursor-move",
180
227
  "group-data-[hover=x]/number-input:cursor-col-resize",
181
- "group-data-[hover=y]/number-input:cursor-ns-resize",
228
+ "group-data-[hover=y]/number-input:cursor-row-resize",
182
229
  ])}
183
230
  >
184
231
  <InputSlot
@@ -186,7 +233,7 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
186
233
  "cursor-crosshair",
187
234
  "group-data-[hover=down]/number-input:cursor-move",
188
235
  "group-data-[hover=x]/number-input:cursor-col-resize",
189
- "group-data-[hover=y]/number-input:cursor-ns-resize",
236
+ "group-data-[hover=y]/number-input:cursor-row-resize",
190
237
  )}
191
238
  >
192
239
  {prefix?.[index]}