@vuer-ai/vuer-uikit 0.0.23 → 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,59 +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
- {
44
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
45
- if (typeof document === "undefined") return memo || 0;
46
- event.stopPropagation();
47
- event.preventDefault();
48
- if (selectRange.current[0] === null) {
49
- selectRange.current[0] = getHoverElementAndIndex(
50
- document.elementFromPoint(...initial),
51
- inputs.current
52
- );
53
- }
54
- let newMX = memo + dx / 2;
55
- if (Math.abs(newMX) >= (inputChange.current ? 1 : 5)) {
56
- const multiplyStep = event.shiftKey ? 5 : event.altKey ? 1 / 5 : 1;
57
- const newValue = value.map((v, i) => {
58
- const [first, last] = selectRange.current;
59
- if (first === null || last === null) {
60
- return v;
61
- } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
62
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
63
- } else {
64
- return v;
65
- }
66
- });
67
- onValuesChange == null ? void 0 : onValuesChange(newValue);
68
- newMX = 0;
69
- inputChange.current = true;
70
- changeElementsHoverState(inputs.current, selectRange.current, "x");
71
- stopClick();
72
- }
73
- if (!inputChange.current) {
74
- const currentElement = document.elementFromPoint(...xy);
75
- const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
76
- selectRange.current[1] = currentIndex ?? selectRange.current[1];
77
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
78
- stopClick();
79
- }
80
- return newMX;
81
- },
82
- onDragEnd: () => {
83
- if (typeof document === "undefined") return;
84
- selectRange.current = [null, null];
85
- inputChange.current = false;
86
- changeElementsHoverState(inputs.current, selectRange.current, "none");
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;
71
+ const newValue = value.map((v, i) => {
72
+ const [first, last] = selectRange.current;
73
+ if (first === null || last === null) {
74
+ return v;
75
+ } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
76
+ return Number(
77
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
78
+ 6
79
+ )
80
+ );
81
+ } else {
82
+ return v;
83
+ }
84
+ });
85
+ onValuesChange == null ? void 0 : onValuesChange(newValue);
86
+ accumulatedDelta.current = 0;
87
+ inputChange.current = true;
88
+ changeElementsHoverState(inputs.current, selectRange.current, "x");
89
+ stopClick();
90
+ }
91
+ if (!inputChange.current) {
92
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
93
+ const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
94
+ selectRange.current[1] = currentIndex ?? selectRange.current[1];
95
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
96
+ stopClick();
87
97
  }
88
98
  },
89
- {
90
- // Pass config options to make gesture library SSR-safe
91
- enabled: typeof document !== "undefined"
92
- }
99
+ [isDragging, value, onValuesChange, step, stopClick]
93
100
  );
94
- const valueChangeHandler = react.useCallback(
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
+ };
122
+ }
123
+ }, [isDragging, handleMouseMove, handleMouseUp]);
124
+ const valueChangeHandler = React.useCallback(
95
125
  (index) => {
96
126
  return (e) => {
97
127
  const inputValue = e.target.value;
@@ -115,7 +145,7 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
115
145
  "div",
116
146
  {
117
147
  ref,
118
- ...bind(),
148
+ onMouseDown: handleMouseDown,
119
149
  className: chunkXXWQ4RVP_js.cn("gap-xs flex cursor-crosshair touch-none flex-col select-none"),
120
150
  children: value.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
121
151
  chunkSKO72K64_js.InputRoot,
@@ -142,13 +172,13 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
142
172
  "data-[hover=y]:bg-bg-tertiary",
143
173
  "data-[hover=down]:cursor-move",
144
174
  "data-[hover=x]:cursor-col-resize",
145
- "data-[hover=y]:cursor-ns-resize"
175
+ "data-[hover=y]:cursor-row-resize"
146
176
  ]),
147
177
  inputClassName: chunkXXWQ4RVP_js.cn([
148
178
  "cursor-crosshair",
149
179
  "group-data-[hover=down]/number-input:cursor-move",
150
180
  "group-data-[hover=x]/number-input:cursor-col-resize",
151
- "group-data-[hover=y]/number-input:cursor-ns-resize"
181
+ "group-data-[hover=y]/number-input:cursor-row-resize"
152
182
  ]),
153
183
  children: /* @__PURE__ */ jsxRuntime.jsx(
154
184
  chunkSKO72K64_js.InputSlot,
@@ -157,7 +187,7 @@ var InputNumbers = react.forwardRef(function InputNumbers2({ size, value, onValu
157
187
  "cursor-crosshair",
158
188
  "group-data-[hover=down]/number-input:cursor-move",
159
189
  "group-data-[hover=x]/number-input:cursor-col-resize",
160
- "group-data-[hover=y]/number-input:cursor-ns-resize"
190
+ "group-data-[hover=y]/number-input:cursor-row-resize"
161
191
  ),
162
192
  children: prefix == null ? void 0 : prefix[index]
163
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.23" ;
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,58 +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
- {
42
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
43
- if (typeof document === "undefined") return memo || 0;
44
- event.stopPropagation();
45
- event.preventDefault();
46
- if (selectRange.current[0] === null) {
47
- selectRange.current[0] = getHoverElementAndIndex(
48
- document.elementFromPoint(...initial),
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;
55
- const newValue = value.map((v, i) => {
56
- const [first, last] = selectRange.current;
57
- if (first === null || last === null) {
58
- return v;
59
- } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
60
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
61
- } else {
62
- return v;
63
- }
64
- });
65
- onValuesChange == null ? void 0 : onValuesChange(newValue);
66
- newMX = 0;
67
- inputChange.current = true;
68
- changeElementsHoverState(inputs.current, selectRange.current, "x");
69
- stopClick();
70
- }
71
- if (!inputChange.current) {
72
- const currentElement = document.elementFromPoint(...xy);
73
- const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
74
- selectRange.current[1] = currentIndex ?? selectRange.current[1];
75
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
76
- stopClick();
77
- }
78
- return newMX;
79
- },
80
- onDragEnd: () => {
81
- if (typeof document === "undefined") return;
82
- selectRange.current = [null, null];
83
- inputChange.current = false;
84
- changeElementsHoverState(inputs.current, selectRange.current, "none");
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;
65
+ const newValue = value.map((v, i) => {
66
+ const [first, last] = selectRange.current;
67
+ if (first === null || last === null) {
68
+ return v;
69
+ } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
70
+ return Number(
71
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
72
+ 6
73
+ )
74
+ );
75
+ } else {
76
+ return v;
77
+ }
78
+ });
79
+ onValuesChange == null ? void 0 : onValuesChange(newValue);
80
+ accumulatedDelta.current = 0;
81
+ inputChange.current = true;
82
+ changeElementsHoverState(inputs.current, selectRange.current, "x");
83
+ stopClick();
84
+ }
85
+ if (!inputChange.current) {
86
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
87
+ const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
88
+ selectRange.current[1] = currentIndex ?? selectRange.current[1];
89
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
90
+ stopClick();
85
91
  }
86
92
  },
87
- {
88
- // Pass config options to make gesture library SSR-safe
89
- enabled: typeof document !== "undefined"
90
- }
93
+ [isDragging, value, onValuesChange, step, stopClick]
91
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
+ };
116
+ }
117
+ }, [isDragging, handleMouseMove, handleMouseUp]);
92
118
  const valueChangeHandler = useCallback(
93
119
  (index) => {
94
120
  return (e) => {
@@ -113,7 +139,7 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
113
139
  "div",
114
140
  {
115
141
  ref,
116
- ...bind(),
142
+ onMouseDown: handleMouseDown,
117
143
  className: cn("gap-xs flex cursor-crosshair touch-none flex-col select-none"),
118
144
  children: value.map((item, index) => /* @__PURE__ */ jsx(
119
145
  InputRoot,
@@ -140,13 +166,13 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
140
166
  "data-[hover=y]:bg-bg-tertiary",
141
167
  "data-[hover=down]:cursor-move",
142
168
  "data-[hover=x]:cursor-col-resize",
143
- "data-[hover=y]:cursor-ns-resize"
169
+ "data-[hover=y]:cursor-row-resize"
144
170
  ]),
145
171
  inputClassName: cn([
146
172
  "cursor-crosshair",
147
173
  "group-data-[hover=down]/number-input:cursor-move",
148
174
  "group-data-[hover=x]/number-input:cursor-col-resize",
149
- "group-data-[hover=y]/number-input:cursor-ns-resize"
175
+ "group-data-[hover=y]/number-input:cursor-row-resize"
150
176
  ]),
151
177
  children: /* @__PURE__ */ jsx(
152
178
  InputSlot,
@@ -155,7 +181,7 @@ var InputNumbers = forwardRef(function InputNumbers2({ size, value, onValuesChan
155
181
  "cursor-crosshair",
156
182
  "group-data-[hover=down]/number-input:cursor-move",
157
183
  "group-data-[hover=x]/number-input:cursor-col-resize",
158
- "group-data-[hover=y]/number-input:cursor-ns-resize"
184
+ "group-data-[hover=y]/number-input:cursor-row-resize"
159
185
  ),
160
186
  children: prefix == null ? void 0 : prefix[index]
161
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.23" ;
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 chunkC7VFXWS6_js = require('./chunk-C7VFXWS6.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 chunkFUQCOZWA_js = require('./chunk-FUQCOZWA.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 chunkC7VFXWS6_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 chunkFUQCOZWA_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-QZVQRU25.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-7JAADHQO.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 chunkC7VFXWS6_js = require('../chunk-C7VFXWS6.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 chunkFUQCOZWA_js = require('../chunk-FUQCOZWA.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 chunkC7VFXWS6_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 chunkFUQCOZWA_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-QZVQRU25.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-7JAADHQO.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 chunkFUQCOZWA_js = require('../chunk-FUQCOZWA.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 chunkFUQCOZWA_js.InputNumbers; }
13
+ get: function () { return chunk6RTJSAVW_js.InputNumbers; }
14
14
  });
@@ -1,4 +1,4 @@
1
- export { InputNumbers } from '../chunk-7JAADHQO.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 chunkC7VFXWS6_js = require('../chunk-C7VFXWS6.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 chunkC7VFXWS6_js.VersionBadge; }
13
+ get: function () { return chunkOO7LYJQL_js.VersionBadge; }
14
14
  });
@@ -1,4 +1,4 @@
1
- export { VersionBadge } from '../chunk-QZVQRU25.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.23",
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,73 +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
- {
68
- onDrag: ({ delta: [dx], event, initial, distance: [, oy], xy, memo = 0 }) => {
69
- // SSR guard - if no document, return early
70
- if (typeof document === "undefined") return memo || 0;
71
-
72
- event.stopPropagation();
73
- event.preventDefault();
74
-
75
- if (selectRange.current[0] === null) {
76
- selectRange.current[0] = getHoverElementAndIndex(
77
- document.elementFromPoint(...initial),
78
- inputs.current,
79
- );
80
- }
74
+ const handleMouseDown = useCallback((e: ReactMouseEvent) => {
75
+ if (e.button !== 0) return; // Only left mouse button
81
76
 
82
- let newMX: number = memo + dx / 2;
77
+ e.preventDefault();
78
+ e.stopPropagation();
83
79
 
84
- if (Math.abs(newMX) >= (inputChange.current ? 1 : 5)) {
85
- const multiplyStep = event.shiftKey ? 5 : event.altKey ? 1 / 5 : 1;
80
+ setIsDragging(true);
81
+ dragStart.current = { x: e.clientX, y: e.clientY };
82
+ accumulatedDelta.current = 0;
83
+ inputChange.current = false;
86
84
 
87
- const newValue = value.map((v, i) => {
88
- const [first, last] = selectRange.current;
89
- if (first === null || last === null) {
90
- return v;
91
- } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
92
- return Number(((v || 0) + Math.floor(newMX) * step * multiplyStep).toPrecision(6));
93
- } else {
94
- return v;
95
- }
96
- });
97
- onValuesChange?.(newValue);
98
- newMX = 0;
99
- inputChange.current = true;
85
+ selectRange.current[0] = getHoverElementAndIndex(
86
+ document.elementFromPoint(e.clientX, e.clientY),
87
+ inputs.current,
88
+ );
89
+ }, []);
100
90
 
101
- changeElementsHoverState(inputs.current, selectRange.current, "x");
91
+ const handleMouseMove = useCallback(
92
+ (e: MouseEvent) => {
93
+ if (!isDragging) return;
102
94
 
103
- stopClick();
104
- }
95
+ e.preventDefault();
96
+ e.stopPropagation();
105
97
 
106
- if (!inputChange.current) {
107
- const currentElement = document.elementFromPoint(...xy);
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;
106
+
107
+ const newValue = value.map((v, i) => {
108
+ const [first, last] = selectRange.current;
109
+ if (first === null || last === null) {
110
+ return v;
111
+ } else if (i <= Math.max(first, last) && i >= Math.min(first, last)) {
112
+ return Number(
113
+ ((v || 0) + Math.floor(accumulatedDelta.current) * step * multiplyStep).toPrecision(
114
+ 6,
115
+ ),
116
+ );
117
+ } else {
118
+ return v;
119
+ }
120
+ });
121
+ onValuesChange?.(newValue);
122
+ accumulatedDelta.current = 0;
123
+ inputChange.current = true;
124
+
125
+ changeElementsHoverState(inputs.current, selectRange.current, "x");
126
+ stopClick();
127
+ }
128
+
129
+ if (!inputChange.current) {
130
+ const currentElement = document.elementFromPoint(e.clientX, e.clientY);
131
+ const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
132
+ selectRange.current[1] = currentIndex ?? selectRange.current[1];
133
+
134
+ changeElementsHoverState(inputs.current, selectRange.current, deltaY !== 0 ? "y" : "none");
135
+ stopClick();
136
+ }
137
+ },
138
+ [isDragging, value, onValuesChange, step, stopClick],
139
+ );
108
140
 
109
- const currentIndex = getHoverElementAndIndex(currentElement, inputs.current);
110
- selectRange.current[1] = currentIndex ?? selectRange.current[1];
141
+ const handleMouseUp = useCallback(() => {
142
+ if (!isDragging) return;
111
143
 
112
- changeElementsHoverState(inputs.current, selectRange.current, oy !== 0 ? "y" : "none");
144
+ setIsDragging(false);
145
+ selectRange.current = [null, null];
146
+ inputChange.current = false;
147
+ changeElementsHoverState(inputs.current, selectRange.current, "none");
148
+ }, [isDragging]);
113
149
 
114
- stopClick();
115
- }
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
+ };
116
159
 
117
- return newMX;
118
- },
119
- onDragEnd: () => {
120
- // SSR guard
121
- if (typeof document === "undefined") return;
160
+ document.addEventListener("mousemove", handleGlobalMouseMove);
161
+ document.addEventListener("mouseup", handleGlobalMouseUp);
122
162
 
123
- selectRange.current = [null, null];
124
- inputChange.current = false;
125
- changeElementsHoverState(inputs.current, selectRange.current, "none");
126
- },
127
- },
128
- {
129
- // Pass config options to make gesture library SSR-safe
130
- enabled: typeof document !== "undefined",
131
- },
132
- );
163
+ return () => {
164
+ document.removeEventListener("mousemove", handleGlobalMouseMove);
165
+ document.removeEventListener("mouseup", handleGlobalMouseUp);
166
+ };
167
+ }
168
+ }, [isDragging, handleMouseMove, handleMouseUp]);
133
169
 
134
170
  const valueChangeHandler = useCallback(
135
171
  (index: number) => {
@@ -156,7 +192,7 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
156
192
  return (
157
193
  <div
158
194
  ref={ref}
159
- {...bind()}
195
+ onMouseDown={handleMouseDown}
160
196
  className={cn("gap-xs flex cursor-crosshair touch-none flex-col select-none")}
161
197
  >
162
198
  {value.map((item, index) => (
@@ -183,13 +219,13 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
183
219
  "data-[hover=y]:bg-bg-tertiary",
184
220
  "data-[hover=down]:cursor-move",
185
221
  "data-[hover=x]:cursor-col-resize",
186
- "data-[hover=y]:cursor-ns-resize",
222
+ "data-[hover=y]:cursor-row-resize",
187
223
  ])}
188
224
  inputClassName={cn([
189
225
  "cursor-crosshair",
190
226
  "group-data-[hover=down]/number-input:cursor-move",
191
227
  "group-data-[hover=x]/number-input:cursor-col-resize",
192
- "group-data-[hover=y]/number-input:cursor-ns-resize",
228
+ "group-data-[hover=y]/number-input:cursor-row-resize",
193
229
  ])}
194
230
  >
195
231
  <InputSlot
@@ -197,7 +233,7 @@ const InputNumbers = forwardRef<HTMLDivElement, InputNumbersProps>(function Inpu
197
233
  "cursor-crosshair",
198
234
  "group-data-[hover=down]/number-input:cursor-move",
199
235
  "group-data-[hover=x]/number-input:cursor-col-resize",
200
- "group-data-[hover=y]/number-input:cursor-ns-resize",
236
+ "group-data-[hover=y]/number-input:cursor-row-resize",
201
237
  )}
202
238
  >
203
239
  {prefix?.[index]}