@tremolo-ui/react 0.1.0 → 0.1.2
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/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/hooks/useAnimationFrame.d.ts +1 -1
- package/dist/cjs/types/hooks/useAnimationFrame.d.ts.map +1 -1
- package/dist/cjs/types/hooks/useDrag.d.ts +2 -3
- package/dist/cjs/types/hooks/useDrag.d.ts.map +1 -1
- package/dist/cjs/types/hooks/useDragWithElement.d.ts +2 -3
- package/dist/cjs/types/hooks/useDragWithElement.d.ts.map +1 -1
- package/dist/cjs/types/index.d.ts +15 -15
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/hooks/useAnimationFrame.d.ts +1 -1
- package/dist/esm/types/hooks/useAnimationFrame.d.ts.map +1 -1
- package/dist/esm/types/hooks/useDrag.d.ts +2 -3
- package/dist/esm/types/hooks/useDrag.d.ts.map +1 -1
- package/dist/esm/types/hooks/useDragWithElement.d.ts +2 -3
- package/dist/esm/types/hooks/useDragWithElement.d.ts.map +1 -1
- package/dist/esm/types/index.d.ts +15 -15
- package/dist/esm/types/index.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/Globals.d.ts +1 -0
- package/src/hooks/useAnimationFrame.ts +2 -2
- package/src/hooks/useDrag.ts +2 -2
- package/src/hooks/useDragWithElement.ts +2 -2
- package/src/index.ts +79 -15
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function useAnimationFrame(callback?: () => void, deps?: DependencyList): void;
|
|
3
3
|
//# sourceMappingURL=useAnimationFrame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimationFrame.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAnimationFrame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,OAAO,CAAA;AAEtE,
|
|
1
|
+
{"version":3,"file":"useAnimationFrame.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAnimationFrame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,OAAO,CAAA;AAEtE,wBAAgB,iBAAiB,CAC/B,QAAQ,aAAW,EACnB,IAAI,GAAE,cAAmB,QAa1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface UseDragProps {
|
|
2
2
|
threshold?: number;
|
|
3
3
|
onDrag: (x: number, y: number, deltaX: number, deltaY: number) => void;
|
|
4
4
|
onDragStart?: () => void;
|
|
@@ -7,9 +7,8 @@ interface Props {
|
|
|
7
7
|
/**
|
|
8
8
|
* @returns [refCallback, pointerDownHandler]
|
|
9
9
|
*/
|
|
10
|
-
export declare function useDrag<T extends Element>({ threshold, onDrag, onDragStart, onDragEnd, }:
|
|
10
|
+
export declare function useDrag<T extends Element>({ threshold, onDrag, onDragStart, onDragEnd, }: UseDragProps): [
|
|
11
11
|
(div: EventTarget | null) => void,
|
|
12
12
|
(event: React.PointerEvent<T>) => void
|
|
13
13
|
];
|
|
14
|
-
export {};
|
|
15
14
|
//# sourceMappingURL=useDrag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrag.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDrag.ts"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"useDrag.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDrag.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACtE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EACzC,SAAa,EACb,MAAM,EACN,WAAW,EACX,SAAS,GACV,EAAE,YAAY,GAAG;IAChB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI;IACjC,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;CACvC,CAkEA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
interface
|
|
2
|
+
export interface UseDragWithElementProps<T extends Element> {
|
|
3
3
|
baseElementRef: RefObject<T | null>;
|
|
4
4
|
onDrag: (normalizedX: number, normalizedY: number) => void;
|
|
5
5
|
onDragStart?: (normalizedX: number, normalizedY: number) => void;
|
|
@@ -8,9 +8,8 @@ interface Props<T extends Element> {
|
|
|
8
8
|
/**
|
|
9
9
|
* @returns [refCallback, pointerDownHandler]
|
|
10
10
|
*/
|
|
11
|
-
export declare function useDragWithElement<T extends Element>({ baseElementRef, onDrag, onDragStart, onDragEnd, }:
|
|
11
|
+
export declare function useDragWithElement<T extends Element>({ baseElementRef, onDrag, onDragStart, onDragEnd, }: UseDragWithElementProps<T>): [
|
|
12
12
|
(div: EventTarget | null) => void,
|
|
13
13
|
(event: React.PointerEvent<T>) => void
|
|
14
14
|
];
|
|
15
|
-
export {};
|
|
16
15
|
//# sourceMappingURL=useDragWithElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragWithElement.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDragWithElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAE,MAAM,OAAO,CAAA;AAOtD,
|
|
1
|
+
{"version":3,"file":"useDragWithElement.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDragWithElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAE,MAAM,OAAO,CAAA;AAOtD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,OAAO;IACxD,cAAc,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IACnC,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1D,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAChE,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,OAAO,EAAE,EACpD,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,GACV,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG;IAC9B,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI;IACjC,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;CACvC,CAkDA"}
|
|
@@ -4,19 +4,19 @@ import './components/NumberInput/index.css';
|
|
|
4
4
|
import './components/Piano/index.css';
|
|
5
5
|
import './components/Slider/index.css';
|
|
6
6
|
import './components/XYPad/index.css';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
7
|
+
export { type AbsoluteSizingProps, AnimationCanvas, type AnimationCanvasProps, type CommonProps, type DrawFunction, type InitFunction, type RelativeSizingProps, } from './components/AnimationCanvas';
|
|
8
|
+
export { AnimationKnob, type AnimationKnobMethods, type AnimationKnobProps, } from './components/AnimationKnob';
|
|
9
|
+
export { DragObserver, type DragObserverProps } from './components/DragObserver';
|
|
10
|
+
export { Knob, type KnobMethods, type KnobProps } from './components/Knob';
|
|
11
|
+
export { DecrementStepper, type DecrementStepperProps, IncrementStepper, type IncrementStepperProps, NumberInput, type NumberInputMethods, type NumberInputProps, Stepper, type StepperProps, } from './components/NumberInput';
|
|
12
|
+
export { BlackKey, KeyLabel, type KeyLabelProps, type KeyMethods, type KeyProps, type KeyboardShortcuts, Piano, type PianoProps, SHORTCUTS, WhiteKey, getNoteRangeArray, } from './components/Piano';
|
|
13
|
+
export { Scale, ScaleOption, type ScaleOptionProps, type ScaleProps, Slider, type SliderMethods, type SliderProps, SliderThumb, type SliderThumbMethods, type SliderThumbProps, SliderTrack, type SliderTrackProps, useSliderContext, } from './components/Slider';
|
|
14
|
+
export { WheelObserver, type WheelObserverProps, } from './components/WheelObserver';
|
|
15
|
+
export { type AreaProps, type ThumbProps, type ValueOptions, XYPad, XYPadArea, type XYPadMethods, type XYPadProps, XYPadThumb, type XYPadThumbMethods, } from './components/XYPad';
|
|
16
|
+
export { useAnimationFrame } from './hooks/useAnimationFrame';
|
|
17
|
+
export { useDrag, type UseDragProps } from './hooks/useDrag';
|
|
18
|
+
export { useDragWithElement, type UseDragWithElementProps, } from './hooks/useDragWithElement';
|
|
19
|
+
export { useEventListener } from './hooks/useEventListener';
|
|
20
|
+
export { useInterval } from './hooks/useInterval';
|
|
21
|
+
export { useLongPress } from './hooks/useLongPress';
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6BAA6B,CAAA;AACpC,OAAO,oCAAoC,CAAA;AAC3C,OAAO,8BAA8B,CAAA;AACrC,OAAO,+BAA+B,CAAA;AACtC,OAAO,8BAA8B,CAAA;AAErC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6BAA6B,CAAA;AACpC,OAAO,oCAAoC,CAAA;AAC3C,OAAO,8BAA8B,CAAA;AACrC,OAAO,+BAA+B,CAAA;AACtC,OAAO,8BAA8B,CAAA;AAErC,OAAO,EACL,KAAK,mBAAmB,EACxB,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,EACL,KAAK,UAAU,EACf,SAAS,EACT,QAAQ,EACR,iBAAiB,GAClB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,KAAK,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,WAAW,EACX,KAAK,gBAAgB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,EACL,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,UAAU,EACV,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tremolo-ui/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React component library for audio app",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.css"
|
|
8
|
+
],
|
|
5
9
|
"main": "dist/cjs/index.js",
|
|
6
10
|
"module": "dist/esm/index.js",
|
|
7
|
-
"type": "module",
|
|
8
11
|
"types": "dist/cjs/types/index.d.ts",
|
|
9
12
|
"scripts": {
|
|
10
13
|
"sb": "storybook dev -p 6006",
|
package/src/Globals.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DependencyList, useCallback, useEffect, useRef } from 'react'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export function useAnimationFrame(
|
|
4
4
|
callback = () => {},
|
|
5
5
|
deps: DependencyList = [],
|
|
6
|
-
)
|
|
6
|
+
) {
|
|
7
7
|
const reqIdRef = useRef(-1)
|
|
8
8
|
const loop = useCallback(() => {
|
|
9
9
|
reqIdRef.current = requestAnimationFrame(loop)
|
package/src/hooks/useDrag.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { useRef, useCallback } from 'react'
|
|
|
3
3
|
import { useEventListener } from './useEventListener'
|
|
4
4
|
import { useRefCallbackEvent } from './useRefCallbackEvent'
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
export interface UseDragProps {
|
|
7
7
|
threshold?: number
|
|
8
8
|
|
|
9
9
|
onDrag: (x: number, y: number, deltaX: number, deltaY: number) => void
|
|
@@ -19,7 +19,7 @@ export function useDrag<T extends Element>({
|
|
|
19
19
|
onDrag,
|
|
20
20
|
onDragStart,
|
|
21
21
|
onDragEnd,
|
|
22
|
-
}:
|
|
22
|
+
}: UseDragProps): [
|
|
23
23
|
(div: EventTarget | null) => void,
|
|
24
24
|
(event: React.PointerEvent<T>) => void,
|
|
25
25
|
] {
|
|
@@ -5,7 +5,7 @@ import { normalizeValue } from '@tremolo-ui/functions'
|
|
|
5
5
|
import { useEventListener } from './useEventListener'
|
|
6
6
|
import { useRefCallbackEvent } from './useRefCallbackEvent'
|
|
7
7
|
|
|
8
|
-
interface
|
|
8
|
+
export interface UseDragWithElementProps<T extends Element> {
|
|
9
9
|
baseElementRef: RefObject<T | null>
|
|
10
10
|
onDrag: (normalizedX: number, normalizedY: number) => void
|
|
11
11
|
onDragStart?: (normalizedX: number, normalizedY: number) => void
|
|
@@ -20,7 +20,7 @@ export function useDragWithElement<T extends Element>({
|
|
|
20
20
|
onDrag,
|
|
21
21
|
onDragStart,
|
|
22
22
|
onDragEnd,
|
|
23
|
-
}:
|
|
23
|
+
}: UseDragWithElementProps<T>): [
|
|
24
24
|
(div: EventTarget | null) => void,
|
|
25
25
|
(event: React.PointerEvent<T>) => void,
|
|
26
26
|
] {
|
package/src/index.ts
CHANGED
|
@@ -5,19 +5,83 @@ import './components/Piano/index.css'
|
|
|
5
5
|
import './components/Slider/index.css'
|
|
6
6
|
import './components/XYPad/index.css'
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export {
|
|
9
|
+
type AbsoluteSizingProps,
|
|
10
|
+
AnimationCanvas,
|
|
11
|
+
type AnimationCanvasProps,
|
|
12
|
+
type CommonProps,
|
|
13
|
+
type DrawFunction,
|
|
14
|
+
type InitFunction,
|
|
15
|
+
type RelativeSizingProps,
|
|
16
|
+
} from './components/AnimationCanvas'
|
|
17
|
+
export {
|
|
18
|
+
AnimationKnob,
|
|
19
|
+
type AnimationKnobMethods,
|
|
20
|
+
type AnimationKnobProps,
|
|
21
|
+
} from './components/AnimationKnob'
|
|
22
|
+
export { DragObserver, type DragObserverProps } from './components/DragObserver'
|
|
23
|
+
export { Knob, type KnobMethods, type KnobProps } from './components/Knob'
|
|
24
|
+
export {
|
|
25
|
+
DecrementStepper,
|
|
26
|
+
type DecrementStepperProps,
|
|
27
|
+
IncrementStepper,
|
|
28
|
+
type IncrementStepperProps,
|
|
29
|
+
NumberInput,
|
|
30
|
+
type NumberInputMethods,
|
|
31
|
+
type NumberInputProps,
|
|
32
|
+
Stepper,
|
|
33
|
+
type StepperProps,
|
|
34
|
+
} from './components/NumberInput'
|
|
35
|
+
export {
|
|
36
|
+
BlackKey,
|
|
37
|
+
KeyLabel,
|
|
38
|
+
type KeyLabelProps,
|
|
39
|
+
type KeyMethods,
|
|
40
|
+
type KeyProps,
|
|
41
|
+
type KeyboardShortcuts,
|
|
42
|
+
Piano,
|
|
43
|
+
type PianoProps,
|
|
44
|
+
SHORTCUTS,
|
|
45
|
+
WhiteKey,
|
|
46
|
+
getNoteRangeArray,
|
|
47
|
+
} from './components/Piano'
|
|
48
|
+
export {
|
|
49
|
+
Scale,
|
|
50
|
+
ScaleOption,
|
|
51
|
+
type ScaleOptionProps,
|
|
52
|
+
type ScaleProps,
|
|
53
|
+
Slider,
|
|
54
|
+
type SliderMethods,
|
|
55
|
+
type SliderProps,
|
|
56
|
+
SliderThumb,
|
|
57
|
+
type SliderThumbMethods,
|
|
58
|
+
type SliderThumbProps,
|
|
59
|
+
SliderTrack,
|
|
60
|
+
type SliderTrackProps,
|
|
61
|
+
useSliderContext,
|
|
62
|
+
} from './components/Slider'
|
|
63
|
+
export {
|
|
64
|
+
WheelObserver,
|
|
65
|
+
type WheelObserverProps,
|
|
66
|
+
} from './components/WheelObserver'
|
|
67
|
+
export {
|
|
68
|
+
type AreaProps,
|
|
69
|
+
type ThumbProps,
|
|
70
|
+
type ValueOptions,
|
|
71
|
+
XYPad,
|
|
72
|
+
XYPadArea,
|
|
73
|
+
type XYPadMethods,
|
|
74
|
+
type XYPadProps,
|
|
75
|
+
XYPadThumb,
|
|
76
|
+
type XYPadThumbMethods,
|
|
77
|
+
} from './components/XYPad'
|
|
17
78
|
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
79
|
+
export { useAnimationFrame } from './hooks/useAnimationFrame'
|
|
80
|
+
export { useDrag, type UseDragProps } from './hooks/useDrag'
|
|
81
|
+
export {
|
|
82
|
+
useDragWithElement,
|
|
83
|
+
type UseDragWithElementProps,
|
|
84
|
+
} from './hooks/useDragWithElement'
|
|
85
|
+
export { useEventListener } from './hooks/useEventListener'
|
|
86
|
+
export { useInterval } from './hooks/useInterval'
|
|
87
|
+
export { useLongPress } from './hooks/useLongPress'
|