@sqlrooms/ui 0.4.1 → 0.5.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/dist/components/slider.d.ts +5 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +8 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/hooks/useRelativeCoordinates.d.ts +47 -0
- package/dist/hooks/useRelativeCoordinates.d.ts.map +1 -0
- package/dist/hooks/useRelativeCoordinates.js +55 -0
- package/dist/hooks/useRelativeCoordinates.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
3
|
+
declare const Slider: React.ForwardRefExoticComponent<Omit<SliderPrimitive.SliderProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
export { Slider };
|
|
5
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../src/components/slider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAG1D,QAAA,MAAM,MAAM,yJAiBV,CAAC;AAGH,OAAO,EAAC,MAAM,EAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => (_jsxs(SliderPrimitive.Root, { ref: ref, className: cn('relative flex w-full touch-none select-none items-center', className), ...props, children: [_jsx(SliderPrimitive.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: _jsx(SliderPrimitive.Range, { className: "absolute h-full bg-primary" }) }), _jsx(SliderPrimitive.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })] })));
|
|
6
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
7
|
+
export { Slider };
|
|
8
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../src/components/slider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAEhC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAG7B,CAAC,EAAC,SAAS,EAAE,GAAG,KAAK,EAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,MAAC,eAAe,CAAC,IAAI,IACnB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,0DAA0D,EAC1D,SAAS,CACV,KACG,KAAK,aAET,KAAC,eAAe,CAAC,KAAK,IAAC,SAAS,EAAC,uEAAuE,YACtG,KAAC,eAAe,CAAC,KAAK,IAAC,SAAS,EAAC,4BAA4B,GAAG,GAC1C,EACxB,KAAC,eAAe,CAAC,KAAK,IAAC,SAAS,EAAC,qNAAqN,GAAG,IACpO,CACxB,CAAC,CAAC;AACH,MAAM,CAAC,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC;AAEtD,OAAO,EAAC,MAAM,EAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook that converts absolute screen coordinates to coordinates relative to a container element.
|
|
3
|
+
*
|
|
4
|
+
* This hook is useful when you need to position elements (like tooltips, popovers, or context menus)
|
|
5
|
+
* relative to a container, especially when dealing with mouse or touch events.
|
|
6
|
+
*
|
|
7
|
+
* @param containerRef - A React ref object pointing to the container HTML element
|
|
8
|
+
* @returns A callback function that converts absolute coordinates to relative ones
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const MyComponent = () => {
|
|
13
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
14
|
+
* const getRelativeCoords = useRelativeCoordinates(containerRef);
|
|
15
|
+
*
|
|
16
|
+
* const handleMouseMove = (e: React.MouseEvent) => {
|
|
17
|
+
* // Convert screen coordinates to container-relative coordinates
|
|
18
|
+
* const [relativeX, relativeY] = getRelativeCoords(e.clientX, e.clientY);
|
|
19
|
+
*
|
|
20
|
+
* // Use the coordinates to position a tooltip, etc.
|
|
21
|
+
* setTooltipPosition({ x: relativeX, y: relativeY });
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <div
|
|
26
|
+
* ref={containerRef}
|
|
27
|
+
* onMouseMove={handleMouseMove}
|
|
28
|
+
* className="relative"
|
|
29
|
+
* >
|
|
30
|
+
* Content
|
|
31
|
+
* </div>
|
|
32
|
+
* );
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Using with touch events
|
|
39
|
+
* const handleTouch = (e: React.TouchEvent) => {
|
|
40
|
+
* const touch = e.touches[0];
|
|
41
|
+
* const [x, y] = getRelativeCoords(touch.clientX, touch.clientY);
|
|
42
|
+
* // Position elements based on touch coordinates
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const useRelativeCoordinates: (containerRef: React.RefObject<HTMLElement>) => (x: number, y: number) => [number, number];
|
|
47
|
+
//# sourceMappingURL=useRelativeCoordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRelativeCoordinates.d.ts","sourceRoot":"","sources":["../../src/hooks/useRelativeCoordinates.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,sBAAsB,iBACnB,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,SAGpC,MAAM,KAAK,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAO1C,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that converts absolute screen coordinates to coordinates relative to a container element.
|
|
4
|
+
*
|
|
5
|
+
* This hook is useful when you need to position elements (like tooltips, popovers, or context menus)
|
|
6
|
+
* relative to a container, especially when dealing with mouse or touch events.
|
|
7
|
+
*
|
|
8
|
+
* @param containerRef - A React ref object pointing to the container HTML element
|
|
9
|
+
* @returns A callback function that converts absolute coordinates to relative ones
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const MyComponent = () => {
|
|
14
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
* const getRelativeCoords = useRelativeCoordinates(containerRef);
|
|
16
|
+
*
|
|
17
|
+
* const handleMouseMove = (e: React.MouseEvent) => {
|
|
18
|
+
* // Convert screen coordinates to container-relative coordinates
|
|
19
|
+
* const [relativeX, relativeY] = getRelativeCoords(e.clientX, e.clientY);
|
|
20
|
+
*
|
|
21
|
+
* // Use the coordinates to position a tooltip, etc.
|
|
22
|
+
* setTooltipPosition({ x: relativeX, y: relativeY });
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <div
|
|
27
|
+
* ref={containerRef}
|
|
28
|
+
* onMouseMove={handleMouseMove}
|
|
29
|
+
* className="relative"
|
|
30
|
+
* >
|
|
31
|
+
* Content
|
|
32
|
+
* </div>
|
|
33
|
+
* );
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Using with touch events
|
|
40
|
+
* const handleTouch = (e: React.TouchEvent) => {
|
|
41
|
+
* const touch = e.touches[0];
|
|
42
|
+
* const [x, y] = getRelativeCoords(touch.clientX, touch.clientY);
|
|
43
|
+
* // Position elements based on touch coordinates
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const useRelativeCoordinates = (containerRef) => {
|
|
48
|
+
return useCallback((x, y) => {
|
|
49
|
+
if (!containerRef.current)
|
|
50
|
+
return [0, 0];
|
|
51
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
52
|
+
return [x - rect.left, y - rect.top];
|
|
53
|
+
}, [containerRef]);
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=useRelativeCoordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRelativeCoordinates.js","sourceRoot":"","sources":["../../src/hooks/useRelativeCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,YAA0C,EAC1C,EAAE;IACF,OAAO,WAAW,CAChB,CAAC,CAAS,EAAE,CAAS,EAAoB,EAAE;QACzC,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QAC1D,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,9 @@ export * from './components/tooltip';
|
|
|
33
33
|
export * from './hooks/use-toast';
|
|
34
34
|
export * from './hooks/useDisclosure';
|
|
35
35
|
export * from './hooks/useAspectRatioDimensions';
|
|
36
|
+
export * from './hooks/useRelativeCoordinates';
|
|
36
37
|
export * from './lib/utils';
|
|
37
38
|
export * from './tailwind-preset';
|
|
38
39
|
export * from './theme/theme-provider';
|
|
40
|
+
export * from './components/slider';
|
|
39
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC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AsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,9 @@ export * from './components/tooltip';
|
|
|
33
33
|
export * from './hooks/use-toast';
|
|
34
34
|
export * from './hooks/useDisclosure';
|
|
35
35
|
export * from './hooks/useAspectRatioDimensions';
|
|
36
|
+
export * from './hooks/useRelativeCoordinates';
|
|
36
37
|
export * from './lib/utils';
|
|
37
38
|
export * from './tailwind-preset';
|
|
38
39
|
export * from './theme/theme-provider';
|
|
40
|
+
export * from './components/slider';
|
|
39
41
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC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B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@radix-ui/react-popover": "^1.1.4",
|
|
43
43
|
"@radix-ui/react-progress": "^1.1.1",
|
|
44
44
|
"@radix-ui/react-select": "^2.1.4",
|
|
45
|
+
"@radix-ui/react-slider": "^1.2.3",
|
|
45
46
|
"@radix-ui/react-slot": "^1.1.1",
|
|
46
47
|
"@radix-ui/react-switch": "^1.1.2",
|
|
47
48
|
"@radix-ui/react-tabs": "^1.1.2",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"autoprefixer": "^10.4.20",
|
|
62
63
|
"tailwindcss": "^3.4.17"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2a27ef8a774f934c8150dce57aac22699fb6d22f"
|
|
65
66
|
}
|