@tremolo-ui/react 0.8.0 → 0.9.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/index.cjs +416 -252
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +256 -110
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +256 -110
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +368 -203
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/components/AnimationCanvas/index.tsx +4 -18
- package/src/components/FileInput/index.tsx +4 -1
- package/src/components/Knob/Thumb.tsx +19 -19
- package/src/components/Knob/index.tsx +85 -41
- package/src/components/NumberInput/InputField.tsx +9 -7
- package/src/components/NumberInput/Stepper.tsx +30 -6
- package/src/components/NumberInput/StepperButton.tsx +12 -4
- package/src/components/NumberInput/context.tsx +24 -2
- package/src/components/NumberInput/index.tsx +142 -27
- package/src/components/Piano/index.tsx +24 -7
- package/src/components/PointsEditor/Container.tsx +1 -1
- package/src/components/PointsEditor/Point.tsx +61 -30
- package/src/components/PointsEditor/context.tsx +3 -4
- package/src/components/PointsEditor/index.tsx +14 -15
- package/src/components/Slider/Marks.tsx +3 -2
- package/src/components/Slider/MarksOption.tsx +3 -2
- package/src/components/Slider/Thumb.tsx +20 -11
- package/src/components/Slider/Track.tsx +15 -13
- package/src/components/Slider/context.tsx +3 -3
- package/src/components/Slider/index.tsx +85 -48
- package/src/components/XYPad/Thumb.tsx +18 -8
- package/src/components/XYPad/context.tsx +1 -1
- package/src/components/XYPad/index.tsx +74 -42
- package/src/components/_util/VisuallyHiddenRangeInput.tsx +1 -1
- package/src/hooks/_internal/useChangeGesture.ts +93 -0
- package/src/hooks/_internal/useCheckSteps.ts +1 -1
- package/src/hooks/useAnimationFrame.ts +37 -15
- package/src/hooks/useEventListener.ts +93 -22
- package/src/hooks/useWheel.ts +4 -4
- package/src/index.ts +9 -5
- package/src/hooks/useInterval.ts +0 -27
package/src/hooks/useWheel.ts
CHANGED
|
@@ -4,9 +4,8 @@ import { createWheel, type WheelOptions } from '@tremolo-ui/dom'
|
|
|
4
4
|
|
|
5
5
|
import { useCallbackRef } from './_internal/useCallbackRef'
|
|
6
6
|
|
|
7
|
-
// `onWheel` is left out:
|
|
8
|
-
// the
|
|
9
|
-
// option would be silently ignored.
|
|
7
|
+
// `onWheel` is left out: this hook takes the handler as its first argument, so
|
|
8
|
+
// the option would be a second way to say the same thing.
|
|
10
9
|
export interface UseWheelOptions extends Omit<WheelOptions, 'onWheel'> {
|
|
11
10
|
/**
|
|
12
11
|
* Listen on this element rather than on the one the returned ref callback is
|
|
@@ -43,7 +42,8 @@ export function useWheel<T extends Element>(
|
|
|
43
42
|
const element = target ? target.current : node
|
|
44
43
|
if (!element) return
|
|
45
44
|
|
|
46
|
-
const instance = createWheel(element,
|
|
45
|
+
const instance = createWheel(element, {
|
|
46
|
+
onWheel: (event) => wheelHandler(event),
|
|
47
47
|
requireFocus,
|
|
48
48
|
})
|
|
49
49
|
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,6 @@ export {
|
|
|
4
4
|
type AnimationCanvasFixedProps,
|
|
5
5
|
type AnimationCanvasProps,
|
|
6
6
|
type AnimationCanvasResizableProps,
|
|
7
|
-
type DrawFunction,
|
|
8
|
-
type InitFunction,
|
|
9
7
|
} from './components/AnimationCanvas'
|
|
10
8
|
export { DropZone, type DropZoneProps } from './components/DropZone'
|
|
11
9
|
export {
|
|
@@ -70,12 +68,18 @@ export {
|
|
|
70
68
|
export { type CSSVariables } from './css-variables'
|
|
71
69
|
|
|
72
70
|
// hooks
|
|
73
|
-
export {
|
|
71
|
+
export {
|
|
72
|
+
useAnimationFrame,
|
|
73
|
+
type UseAnimationFrameOptions,
|
|
74
|
+
} from './hooks/useAnimationFrame'
|
|
74
75
|
export { useDrag, type UseDragOptions } from './hooks/useDrag'
|
|
75
76
|
export { useDragValue, type UseDragValueOptions } from './hooks/useDragValue'
|
|
76
77
|
export { useDropZone, type UseDropZoneOptions } from './hooks/useDropZone'
|
|
77
|
-
export {
|
|
78
|
-
|
|
78
|
+
export {
|
|
79
|
+
useEventListener,
|
|
80
|
+
type UseEventListenerOptions,
|
|
81
|
+
type UseEventListenerTarget,
|
|
82
|
+
} from './hooks/useEventListener'
|
|
79
83
|
export { useLongPress } from './hooks/useLongPress'
|
|
80
84
|
export { useMIDIAccess } from './hooks/useMIDIAccess'
|
|
81
85
|
export { useMIDIInput } from './hooks/useMIDIInput'
|
package/src/hooks/useInterval.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
export function useInterval(callback: () => void, delay: number | null) {
|
|
4
|
-
const savedCallback = useRef(callback)
|
|
5
|
-
|
|
6
|
-
// Remember the latest callback if it changes.
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
savedCallback.current = callback
|
|
9
|
-
}, [callback])
|
|
10
|
-
|
|
11
|
-
// Set up the interval.
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
// Don't schedule if no delay is specified.
|
|
14
|
-
// Note: 0 is a valid value for delay.
|
|
15
|
-
if (delay === null) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const id = setInterval(() => {
|
|
20
|
-
savedCallback.current()
|
|
21
|
-
}, delay)
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
clearInterval(id)
|
|
25
|
-
}
|
|
26
|
-
}, [delay])
|
|
27
|
-
}
|