@tremolo-ui/react 0.1.6 → 0.2.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 +166 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +109 -71
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +158 -152
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +160 -154
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -145
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Knob/index.css +20 -26
- package/src/components/Knob/index.tsx +7 -7
- package/src/components/NumberInput/index.css +31 -15
- package/src/components/NumberInput/index.tsx +19 -10
- package/src/components/Piano/index.css +7 -14
- package/src/components/Piano/index.tsx +10 -7
- package/src/components/Slider/Thumb.tsx +1 -1
- package/src/components/Slider/Track.tsx +1 -1
- package/src/components/Slider/index.css +33 -8
- package/src/components/Slider/index.tsx +23 -23
- package/src/components/XYPad/Area.tsx +4 -3
- package/src/components/XYPad/Thumb.tsx +8 -4
- package/src/components/XYPad/index.css +18 -4
- package/src/components/XYPad/index.tsx +23 -17
- package/src/index.ts +14 -26
- package/src/styles/global.css +0 -4
|
@@ -23,8 +23,8 @@ import { useDragWithElement } from '../../hooks/useDragWithElement'
|
|
|
23
23
|
import { useRefCallbackEvent } from '../../hooks/useRefCallbackEvent'
|
|
24
24
|
import { addNoSelect, removeNoSelect } from '../_util'
|
|
25
25
|
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { Area, XYPadAreaProps } from './Area'
|
|
27
|
+
import { Thumb, XYPadThumbMethods, XYPadThumbProps } from './Thumb'
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Two-dimensional slider component.
|
|
@@ -82,11 +82,7 @@ const defaultValueOptions = {
|
|
|
82
82
|
type Props = XYPadProps &
|
|
83
83
|
Omit<ComponentPropsWithoutRef<'div'>, keyof XYPadProps>
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
* Simple XYPad
|
|
87
|
-
* @category XYPad
|
|
88
|
-
*/
|
|
89
|
-
export const XYPad = forwardRef<XYPadMethods, Props>(
|
|
85
|
+
export const XYPadImpl = forwardRef<XYPadMethods, Props>(
|
|
90
86
|
(
|
|
91
87
|
{
|
|
92
88
|
x: _x,
|
|
@@ -125,15 +121,15 @@ export const XYPad = forwardRef<XYPadMethods, Props>(
|
|
|
125
121
|
const percentX = toFixed((x.reverse ? 1 - nx : nx) * 100)
|
|
126
122
|
const percentY = toFixed((y.reverse ? 1 - ny : ny) * 100)
|
|
127
123
|
|
|
128
|
-
let areaProps:
|
|
129
|
-
let thumbProps:
|
|
124
|
+
let areaProps: XYPadAreaProps = {}
|
|
125
|
+
let thumbProps: XYPadThumbProps = {}
|
|
130
126
|
if (children != undefined) {
|
|
131
127
|
React.Children.forEach(children, (child) => {
|
|
132
128
|
if (React.isValidElement(child)) {
|
|
133
|
-
if (child.type ==
|
|
134
|
-
thumbProps = child.props as
|
|
135
|
-
} else if (child.type ==
|
|
136
|
-
areaProps = child.props as
|
|
129
|
+
if (child.type == Thumb) {
|
|
130
|
+
thumbProps = child.props as XYPadThumbProps
|
|
131
|
+
} else if (child.type == Area) {
|
|
132
|
+
areaProps = child.props as XYPadAreaProps
|
|
137
133
|
} else {
|
|
138
134
|
throw new Error('only <XYPadThumb> or <XYPadArea>')
|
|
139
135
|
}
|
|
@@ -323,11 +319,12 @@ export const XYPad = forwardRef<XYPadMethods, Props>(
|
|
|
323
319
|
{...props}
|
|
324
320
|
>
|
|
325
321
|
<div className="tremolo-xy-pad-area-wrapper" ref={areaElementRef}>
|
|
326
|
-
<
|
|
322
|
+
<Area
|
|
327
323
|
__thumb={
|
|
328
|
-
<
|
|
324
|
+
<Thumb
|
|
329
325
|
ref={thumbRef}
|
|
330
326
|
__disabled={disabled}
|
|
327
|
+
__readonly={readonly}
|
|
331
328
|
__css={{
|
|
332
329
|
top: `${percentY}%`,
|
|
333
330
|
left: `${percentX}%`,
|
|
@@ -343,5 +340,14 @@ export const XYPad = forwardRef<XYPadMethods, Props>(
|
|
|
343
340
|
},
|
|
344
341
|
)
|
|
345
342
|
|
|
346
|
-
|
|
347
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Simple XYPad
|
|
345
|
+
* @category XYPad
|
|
346
|
+
*/
|
|
347
|
+
export const XYPad = Object.assign(XYPadImpl, {
|
|
348
|
+
Thumb,
|
|
349
|
+
Area,
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
export { type XYPadThumbProps, type XYPadThumbMethods } from './Thumb'
|
|
353
|
+
export { type XYPadAreaProps } from './Area'
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,8 @@ import './components/Slider/index.css'
|
|
|
7
7
|
import './components/XYPad/index.css'
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
|
-
type AbsoluteSizingProps,
|
|
11
10
|
AnimationCanvas,
|
|
11
|
+
type AbsoluteSizingProps,
|
|
12
12
|
type AnimationCanvasProps,
|
|
13
13
|
type CommonProps,
|
|
14
14
|
type DrawFunction,
|
|
@@ -17,65 +17,53 @@ export {
|
|
|
17
17
|
} from './components/AnimationCanvas'
|
|
18
18
|
export {
|
|
19
19
|
AnimationKnob,
|
|
20
|
-
type AnimationKnobMethods,
|
|
21
20
|
type AnimationKnobProps,
|
|
21
|
+
type AnimationKnobMethods,
|
|
22
22
|
} from './components/AnimationKnob'
|
|
23
23
|
export { DragObserver, type DragObserverProps } from './components/DragObserver'
|
|
24
|
-
export { Knob, type
|
|
24
|
+
export { Knob, type KnobProps, type KnobMethods } from './components/Knob'
|
|
25
25
|
export {
|
|
26
|
-
DecrementStepper,
|
|
27
|
-
type DecrementStepperProps,
|
|
28
|
-
IncrementStepper,
|
|
29
|
-
type IncrementStepperProps,
|
|
30
26
|
NumberInput,
|
|
31
|
-
type NumberInputMethods,
|
|
32
27
|
type NumberInputProps,
|
|
33
|
-
|
|
28
|
+
type NumberInputMethods,
|
|
34
29
|
type StepperProps,
|
|
30
|
+
type IncrementStepperProps,
|
|
31
|
+
type DecrementStepperProps,
|
|
35
32
|
} from './components/NumberInput'
|
|
36
33
|
export {
|
|
37
34
|
Piano,
|
|
35
|
+
getNoteRangeArray,
|
|
36
|
+
SHORTCUTS,
|
|
38
37
|
type PianoProps,
|
|
39
38
|
type PianoMethods,
|
|
40
|
-
getNoteRangeArray,
|
|
41
|
-
WhiteKey,
|
|
42
|
-
BlackKey,
|
|
43
39
|
type KeyProps,
|
|
44
40
|
type KeyMethods,
|
|
45
|
-
KeyLabel,
|
|
46
41
|
type KeyLabelProps,
|
|
47
|
-
SHORTCUTS,
|
|
48
42
|
type KeyboardShortcuts,
|
|
49
43
|
} from './components/Piano'
|
|
50
44
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
Slider,
|
|
46
|
+
useSliderContext,
|
|
53
47
|
type ScaleOptionProps,
|
|
54
48
|
type ScaleProps,
|
|
55
|
-
Slider,
|
|
56
49
|
type SliderMethods,
|
|
57
50
|
type SliderProps,
|
|
58
|
-
SliderThumb,
|
|
59
51
|
type SliderThumbMethods,
|
|
60
52
|
type SliderThumbProps,
|
|
61
|
-
SliderTrack,
|
|
62
53
|
type SliderTrackProps,
|
|
63
|
-
useSliderContext,
|
|
64
54
|
} from './components/Slider'
|
|
65
55
|
export {
|
|
66
56
|
WheelObserver,
|
|
67
57
|
type WheelObserverProps,
|
|
68
58
|
} from './components/WheelObserver'
|
|
69
59
|
export {
|
|
70
|
-
type AreaProps,
|
|
71
|
-
type ThumbProps,
|
|
72
|
-
type ValueOptions,
|
|
73
60
|
XYPad,
|
|
74
|
-
XYPadArea,
|
|
75
|
-
type XYPadMethods,
|
|
76
61
|
type XYPadProps,
|
|
77
|
-
|
|
62
|
+
type XYPadMethods,
|
|
63
|
+
type XYPadAreaProps,
|
|
64
|
+
type XYPadThumbProps,
|
|
78
65
|
type XYPadThumbMethods,
|
|
66
|
+
type ValueOptions,
|
|
79
67
|
} from './components/XYPad'
|
|
80
68
|
|
|
81
69
|
// hooks
|