zds-pickers 4.0.3 → 4.0.6
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/.editorconfig +19 -0
- package/.github/workflows/codeql-analysis.yml +67 -0
- package/.nvmrc +1 -0
- package/.prettierignore +0 -0
- package/.prettierrc +13 -0
- package/.storybook/main.ts +42 -0
- package/.storybook/manager.ts +12 -0
- package/.storybook/preview.tsx +26 -0
- package/.vscode/extensions.json +32 -0
- package/.vscode/javascript.code-snippets +229 -0
- package/.vscode/settings.json +358 -0
- package/biome.jsonc +158 -0
- package/dist/index.cjs.js +15 -32
- package/dist/index.es.js +4144 -10129
- package/dist/types/hooks/useComponentSize.d.ts +5 -0
- package/dist/types/hooks/useStateWithDynamicDefault.d.ts +2 -0
- package/dist/types/index.d.ts +266 -2
- package/dist/types/main.d.ts +19 -0
- package/dist/types/midi/ccValues.d.ts +3 -0
- package/dist/types/midi/export.d.ts +22 -0
- package/dist/types/other/DefaultTooltip.d.ts +10 -0
- package/dist/types/other/OctavePlayer.d.ts +20 -0
- package/dist/types/other/SVGText.d.ts +17 -0
- package/dist/types/other/SoundFontProvider.d.ts +17 -0
- package/dist/types/pickers/CCPicker.d.ts +7 -0
- package/dist/types/pickers/ChannelMappingPicker.d.ts +14 -0
- package/dist/types/pickers/ChannelPicker.d.ts +8 -0
- package/dist/types/pickers/Knob.d.ts +12 -0
- package/dist/types/pickers/KnobPicker.d.ts +27 -0
- package/dist/types/pickers/LatchPicker.d.ts +8 -0
- package/dist/types/pickers/MappingPicker.d.ts +11 -0
- package/dist/types/pickers/NotePicker.d.ts +20 -0
- package/dist/types/pickers/PianoPicker.d.ts +9 -0
- package/dist/types/pickers/PolarityPicker.d.ts +14 -0
- package/dist/types/pickers/ResponseCurve.d.ts +40 -0
- package/dist/types/pickers/ResponseCurvePicker.d.ts +15 -0
- package/dist/types/pickers/Select.d.ts +29 -0
- package/dist/types/pickers/StatusPicker.d.ts +12 -0
- package/dist/types/pickers/ValuePicker.d.ts +15 -0
- package/dist/types/pickers/knobSkin10.d.ts +14 -0
- package/dist/types/rotaryKnob/InternalInput.d.ts +18 -0
- package/dist/types/rotaryKnob/Types.d.ts +5 -0
- package/dist/types/rotaryKnob/helpers/DrawCircle.d.ts +18 -0
- package/dist/types/rotaryKnob/helpers/DrawLine.d.ts +15 -0
- package/dist/types/rotaryKnob/helpers/HelpersOverlay.d.ts +11 -0
- package/dist/types/rotaryKnob/helpers/KnobVisualHelpers.d.ts +30 -0
- package/dist/types/rotaryKnob/index.d.ts +49 -0
- package/dist/types/rotaryKnob/knobdefaultskin.d.ts +6 -0
- package/dist/types/rotaryKnob/utils.d.ts +49 -0
- package/dist/types/utils.d.ts +9 -0
- package/lib/@types/nebiru-react-rotary-knob.d.ts +20 -0
- package/lib/@types/react-svgmt.d.ts +74 -0
- package/lib/@types/zds-mappings.d.ts +55 -0
- package/lib/@types/zds-react-piano.d.ts +17 -0
- package/lib/hooks/useComponentSize.ts +52 -0
- package/lib/hooks/useStateWithDynamicDefault.ts +13 -0
- package/lib/main.ts +34 -0
- package/lib/midi/ccValues.ts +139 -0
- package/lib/midi/export.ts +54 -0
- package/lib/other/DefaultTooltip.ts +14 -0
- package/lib/other/OctavePlayer.tsx +141 -0
- package/lib/other/SVGText.tsx +221 -0
- package/lib/other/SoundFontProvider.tsx +130 -0
- package/lib/pickers/CCPicker.tsx +28 -0
- package/lib/pickers/ChannelMappingPicker.tsx +135 -0
- package/lib/pickers/ChannelPicker.tsx +76 -0
- package/lib/pickers/Knob.tsx +93 -0
- package/lib/pickers/KnobPicker.tsx +93 -0
- package/lib/pickers/LatchPicker.tsx +33 -0
- package/lib/pickers/MappingPicker.tsx +68 -0
- package/lib/pickers/NotePicker.tsx +95 -0
- package/lib/pickers/PianoPicker.tsx +77 -0
- package/lib/pickers/PolarityPicker.tsx +39 -0
- package/lib/pickers/ResponseCurve.tsx +304 -0
- package/lib/pickers/ResponseCurvePicker.tsx +74 -0
- package/lib/pickers/Select.tsx +248 -0
- package/lib/pickers/StatusPicker.tsx +28 -0
- package/lib/pickers/ValuePicker.tsx +67 -0
- package/lib/pickers/knobSkin10.tsx +94 -0
- package/lib/rotaryKnob/InternalInput.tsx +43 -0
- package/lib/rotaryKnob/Types.ts +6 -0
- package/lib/rotaryKnob/helpers/DrawCircle.tsx +41 -0
- package/lib/rotaryKnob/helpers/DrawLine.tsx +32 -0
- package/lib/rotaryKnob/helpers/HelpersOverlay.tsx +43 -0
- package/lib/rotaryKnob/helpers/KnobVisualHelpers.tsx +138 -0
- package/lib/rotaryKnob/index.tsx +417 -0
- package/lib/rotaryKnob/knobdefaultskin.ts +56 -0
- package/lib/rotaryKnob/utils.ts +112 -0
- package/lib/temp/acoustic_grand_piano-mp3.js +94 -0
- package/lib/utils.ts +41 -0
- package/package.json +3 -7
- package/stories/assets/sampleStyles.css +349 -0
- package/stories/assets/utils.js +7 -0
- package/stories/picker.stories.tsx +313 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.json +34 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +45 -0
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.d.ts +0 -244
- package/dist/index.es.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const knobSkin10: {
|
|
2
|
+
knobX: number;
|
|
3
|
+
knobY: number;
|
|
4
|
+
svg: string;
|
|
5
|
+
updateAttributes: {
|
|
6
|
+
element: string;
|
|
7
|
+
content: (_props: React.CSSProperties, value: number) => string;
|
|
8
|
+
attrs: {
|
|
9
|
+
name: string;
|
|
10
|
+
value: () => string;
|
|
11
|
+
}[];
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
export default knobSkin10;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type InternalInputProps = {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
value: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
9
|
+
onChange: (val: number) => void;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
declare class InternalInput extends React.Component<InternalInputProps> {
|
|
13
|
+
static defaultProps: {
|
|
14
|
+
step: number;
|
|
15
|
+
};
|
|
16
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export default InternalInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Draws a circle with radius = r
|
|
4
|
+
* position must be handled by parent
|
|
5
|
+
*/
|
|
6
|
+
type DrawCircleProps = React.SVGProps<SVGCircleElement> & {
|
|
7
|
+
r: number;
|
|
8
|
+
borderColor?: string;
|
|
9
|
+
fillColor?: string;
|
|
10
|
+
borderWidth?: number;
|
|
11
|
+
fillOpacity: number;
|
|
12
|
+
cx: number;
|
|
13
|
+
cy: number;
|
|
14
|
+
};
|
|
15
|
+
declare class DrawCircle extends React.Component<DrawCircleProps> {
|
|
16
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export default DrawCircle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Point } from '../Types';
|
|
3
|
+
/**
|
|
4
|
+
* Draws a line from p1 to p2
|
|
5
|
+
*/
|
|
6
|
+
type DrawLineProps = React.SVGProps<SVGLineElement> & {
|
|
7
|
+
width?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
p1: Point;
|
|
10
|
+
p2: Point;
|
|
11
|
+
};
|
|
12
|
+
declare class DrawLine extends React.Component<DrawLineProps> {
|
|
13
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
}
|
|
15
|
+
export default DrawLine;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type HelpersOverlayProps = React.PropsWithChildren & {
|
|
3
|
+
overlayStyle?: React.CSSProperties;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Draws the overlay and the children
|
|
7
|
+
*/
|
|
8
|
+
declare class HelpersOverlay extends React.Component<HelpersOverlayProps> {
|
|
9
|
+
render(): React.ReactPortal;
|
|
10
|
+
}
|
|
11
|
+
export default HelpersOverlay;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Point } from '../Types';
|
|
3
|
+
/** Precision visual helpers */
|
|
4
|
+
/**
|
|
5
|
+
* Precision mode visual helpers
|
|
6
|
+
*/
|
|
7
|
+
type KnobVisualHelpersProps = {
|
|
8
|
+
svgRef?: SVGSVGElement;
|
|
9
|
+
radius: number;
|
|
10
|
+
minimumDragDistance: number;
|
|
11
|
+
valueAngle: number;
|
|
12
|
+
mousePos: Point;
|
|
13
|
+
};
|
|
14
|
+
type KnobVisualHelpersState = {
|
|
15
|
+
centerX: number;
|
|
16
|
+
centerY: number;
|
|
17
|
+
valueMarkerX: number;
|
|
18
|
+
valueMarkerY: number;
|
|
19
|
+
};
|
|
20
|
+
declare class KnobVisualHelpers extends React.Component<KnobVisualHelpersProps, KnobVisualHelpersState> {
|
|
21
|
+
state: {
|
|
22
|
+
centerX: number;
|
|
23
|
+
centerY: number;
|
|
24
|
+
valueMarkerX: number;
|
|
25
|
+
valueMarkerY: number;
|
|
26
|
+
};
|
|
27
|
+
static getDerivedStateFromProps(props: KnobVisualHelpersProps, state: KnobVisualHelpersState): KnobVisualHelpersState;
|
|
28
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
}
|
|
30
|
+
export { KnobVisualHelpers };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Show the rotation circle and marker
|
|
3
|
+
* dispatches drag events
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* type definition for the skin system attribute modification element
|
|
7
|
+
*/
|
|
8
|
+
type AttributeSetValue = {
|
|
9
|
+
name: string;
|
|
10
|
+
value: (props: unknown, value: unknown) => string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Type definition for the skin element manipulation block
|
|
14
|
+
*/
|
|
15
|
+
interface UpdateElement {
|
|
16
|
+
element: string;
|
|
17
|
+
content: (_props: React.CSSProperties, value: number) => string;
|
|
18
|
+
attrs: AttributeSetValue[];
|
|
19
|
+
}
|
|
20
|
+
interface Skin {
|
|
21
|
+
svg: string;
|
|
22
|
+
knobX: number;
|
|
23
|
+
knobY: number;
|
|
24
|
+
updateAttributes: UpdateElement[];
|
|
25
|
+
}
|
|
26
|
+
type KnobProps = Omit<React.ComponentProps<'div'>, 'onChange'> & {
|
|
27
|
+
clampMax?: number;
|
|
28
|
+
clampMin?: number;
|
|
29
|
+
defaultValue?: number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
format?: (val: number) => string;
|
|
32
|
+
max?: number;
|
|
33
|
+
min?: number;
|
|
34
|
+
onChange?: (val: number) => void;
|
|
35
|
+
onEnd?: () => void;
|
|
36
|
+
onStart?: () => void;
|
|
37
|
+
preciseMode?: boolean;
|
|
38
|
+
rotateDegrees?: number;
|
|
39
|
+
skin?: Skin;
|
|
40
|
+
step?: number;
|
|
41
|
+
style: React.CSSProperties;
|
|
42
|
+
unlockDistance?: number;
|
|
43
|
+
value?: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Generic knob component
|
|
47
|
+
*/
|
|
48
|
+
declare const RotaryKnob: (props: KnobProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export default RotaryKnob;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Note on viewbox/width
|
|
2
|
+
* This methods only work when the pixels match the svg units.
|
|
3
|
+
* when the viewbox is changed, or width is set they won't return
|
|
4
|
+
* the correct results
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns the global coordinates of a position given
|
|
8
|
+
* for a specific coordinate system
|
|
9
|
+
* @param {*} svgdoc
|
|
10
|
+
* @param {*} elem
|
|
11
|
+
* @param {*} x
|
|
12
|
+
* @param {*} y
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Converts a global position to a local one
|
|
16
|
+
* @param {*} svgdoc
|
|
17
|
+
* @param {*} elem
|
|
18
|
+
* @param {*} x
|
|
19
|
+
* @param {*} y
|
|
20
|
+
*/
|
|
21
|
+
declare function toRadians(angle: number): number;
|
|
22
|
+
declare function getQuadrant(x: number, y: number): 1 | 2 | 3 | 4;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the angle (degrees) given a point.
|
|
25
|
+
* Assumes 0,0 as the center of the circle
|
|
26
|
+
* @param {number} x
|
|
27
|
+
* @param {number} y
|
|
28
|
+
*/
|
|
29
|
+
declare function getAngleForPoint(x: number, y: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Transforms the top/left variables of the rectangle
|
|
32
|
+
* returned by getBoundingClientRect to document based coordinates
|
|
33
|
+
* without the scroll.
|
|
34
|
+
* UPDATE
|
|
35
|
+
* @param {Rect} box
|
|
36
|
+
*/
|
|
37
|
+
declare function transformBoundingClientRectToDocument(box: DOMRect): {
|
|
38
|
+
top: number;
|
|
39
|
+
left: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
declare const _default: {
|
|
44
|
+
toRadians: typeof toRadians;
|
|
45
|
+
getQuadrant: typeof getQuadrant;
|
|
46
|
+
getAngleForPoint: typeof getAngleForPoint;
|
|
47
|
+
transformBoundingClientRectToDocument: typeof transformBoundingClientRectToDocument;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const arraySequence: (numberOfElements: number) => number[];
|
|
2
|
+
declare const assertRange: (value: number | string, max?: number, min?: number) => number;
|
|
3
|
+
declare const findObj: <T>(key: keyof T, value: T[keyof T]) => (arr: T[]) => T | undefined;
|
|
4
|
+
declare const omit: <T extends Record<string, unknown>>(...keys: string[]) => (obj: T) => {};
|
|
5
|
+
declare const pick: <T extends object>(...keys: (keyof T)[]) => (obj: T) => {};
|
|
6
|
+
declare const set: <T>(key: keyof T, value: T[keyof T]) => (obj: T) => T & {
|
|
7
|
+
[x: string]: T[keyof T];
|
|
8
|
+
};
|
|
9
|
+
export { arraySequence, assertRange, findObj, omit, pick, set };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare module 'nebiru-react-rotary-knob' {
|
|
2
|
+
const Knob: React.ComponentType<{
|
|
3
|
+
clampMax: number
|
|
4
|
+
clampMin: number
|
|
5
|
+
className: string
|
|
6
|
+
disabled: boolean
|
|
7
|
+
max: number
|
|
8
|
+
min: number
|
|
9
|
+
onChange: (value: number) => void
|
|
10
|
+
onWheel?: (event: WheelEvent) => void
|
|
11
|
+
preciseMode: boolean
|
|
12
|
+
rotateDegrees: number
|
|
13
|
+
skin: typeof import('./knobSkin10').default
|
|
14
|
+
style: React.CSSProperties
|
|
15
|
+
unlockDistance: number
|
|
16
|
+
value: number
|
|
17
|
+
}>
|
|
18
|
+
|
|
19
|
+
export { Knob }
|
|
20
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
declare module 'react-svgmt' {
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
type DrawCircleProps = React.SVGProps<SVGCircleElement> & {
|
|
5
|
+
r: number
|
|
6
|
+
borderColor?: string
|
|
7
|
+
fillColor?: string
|
|
8
|
+
borderWidth?: number
|
|
9
|
+
fillOpacity: number
|
|
10
|
+
cx: number
|
|
11
|
+
cy: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class DrawCircle extends React.Component<DrawCircleProps> {
|
|
15
|
+
render(): React.JSX.Element
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type InternalInputProps = {
|
|
19
|
+
min: number
|
|
20
|
+
max: number
|
|
21
|
+
value: number
|
|
22
|
+
step?: number
|
|
23
|
+
inputRef: React.RefObject<HTMLInputElement>
|
|
24
|
+
onChange: (val: number) => void
|
|
25
|
+
style?: React.CSSProperties
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class InternalInput extends React.Component<InternalInputProps> {
|
|
29
|
+
static defaultProps: {
|
|
30
|
+
step: number
|
|
31
|
+
}
|
|
32
|
+
render(): React.JSX.Element
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Point = {
|
|
36
|
+
x: number
|
|
37
|
+
y: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type DrawLineProps = React.SVGProps<SVGLineElement> & {
|
|
41
|
+
width?: number
|
|
42
|
+
color?: string
|
|
43
|
+
p1: Point
|
|
44
|
+
p2: Point
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class DrawLine extends React.Component<DrawLineProps> {
|
|
48
|
+
render(): React.JSX.Element
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type SvgLoaderProps = {
|
|
52
|
+
svg?: string
|
|
53
|
+
svgXML?: string
|
|
54
|
+
width?: string | number
|
|
55
|
+
height?: string | number
|
|
56
|
+
style?: React.CSSProperties
|
|
57
|
+
onSVGReady?: (svg: SVGElement) => void
|
|
58
|
+
children?: React.ReactNode
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type SvgProxyProps = {
|
|
62
|
+
children?: React.ReactNode
|
|
63
|
+
selector: string
|
|
64
|
+
transform?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
class SvgLoader extends React.Component<SvgLoaderProps> {
|
|
68
|
+
render(): React.JSX.Element
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class SvgProxy extends React.Component<SvgProxyProps> {
|
|
72
|
+
render(): React.JSX.Element
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare module 'zds-mappings' {
|
|
2
|
+
function cloneMapping(mappingName: string): Mapping
|
|
3
|
+
function createUserMapping(mappingName: string): Mapping
|
|
4
|
+
function editUserMapping(
|
|
5
|
+
mappingName: string,
|
|
6
|
+
noteNum: number,
|
|
7
|
+
field: string,
|
|
8
|
+
value: string | number,
|
|
9
|
+
): Mapping
|
|
10
|
+
|
|
11
|
+
function getMapping(mappingName: string): Mapping
|
|
12
|
+
|
|
13
|
+
function emptyMapping(): Mapping
|
|
14
|
+
|
|
15
|
+
function getNextAvailableMappingName(path: string): string
|
|
16
|
+
function reverse(mapping: Mapping): string
|
|
17
|
+
function storeMapping(mappingName: string, rawContent: string): void
|
|
18
|
+
function validateContent(content: string): boolean
|
|
19
|
+
|
|
20
|
+
function getAvailableGroups(): { label: string; value: string }[]
|
|
21
|
+
function getStockNames(): string[]
|
|
22
|
+
function getUserMappingNames(): string[]
|
|
23
|
+
function removeMapping(mappingName: string): void
|
|
24
|
+
function renameUserMapping(
|
|
25
|
+
oldKey: string,
|
|
26
|
+
newKey: string,
|
|
27
|
+
): { [key: string]: string | number }
|
|
28
|
+
|
|
29
|
+
interface MapItem {
|
|
30
|
+
note: number
|
|
31
|
+
group: string
|
|
32
|
+
name: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Mapping = MapItem[]
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
cloneMapping,
|
|
39
|
+
createUserMapping,
|
|
40
|
+
emptyMapping,
|
|
41
|
+
editUserMapping,
|
|
42
|
+
getAvailableGroups,
|
|
43
|
+
getMapping,
|
|
44
|
+
getNextAvailableMappingName,
|
|
45
|
+
getStockNames,
|
|
46
|
+
getUserMappingNames,
|
|
47
|
+
removeMapping,
|
|
48
|
+
renameUserMapping,
|
|
49
|
+
reverse,
|
|
50
|
+
storeMapping,
|
|
51
|
+
validateContent,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type { MapItem, Mapping }
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'zds-react-piano' {
|
|
2
|
+
type NoteRange = {
|
|
3
|
+
first: number
|
|
4
|
+
last: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const ReactPiano: React.ComponentType<{
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
keyWidthToHeight: number
|
|
10
|
+
noteRange: NoteRange
|
|
11
|
+
width: number
|
|
12
|
+
}>
|
|
13
|
+
|
|
14
|
+
export { ReactPiano as Piano }
|
|
15
|
+
|
|
16
|
+
export type { NoteRange }
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const getSize = (el: HTMLDivElement | null) =>
|
|
4
|
+
el
|
|
5
|
+
? {
|
|
6
|
+
width: el.offsetWidth,
|
|
7
|
+
height: el.offsetHeight,
|
|
8
|
+
}
|
|
9
|
+
: {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const useComponentSize = (ref: React.RefObject<HTMLDivElement>) => {
|
|
15
|
+
const [componentSize, setComponentSize] = useState(
|
|
16
|
+
getSize(ref ? ref.current : null),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
const handleResize = useCallback(() => {
|
|
20
|
+
if (ref.current) {
|
|
21
|
+
setComponentSize(getSize(ref.current))
|
|
22
|
+
}
|
|
23
|
+
}, [ref])
|
|
24
|
+
|
|
25
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
if (!ref.current) return
|
|
28
|
+
|
|
29
|
+
handleResize()
|
|
30
|
+
|
|
31
|
+
if (typeof ResizeObserver === 'function') {
|
|
32
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
33
|
+
handleResize()
|
|
34
|
+
})
|
|
35
|
+
resizeObserver.observe(ref.current)
|
|
36
|
+
|
|
37
|
+
return () => {
|
|
38
|
+
resizeObserver.disconnect()
|
|
39
|
+
// resizeObserver = null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
window.addEventListener('resize', handleResize)
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
window.removeEventListener('resize', handleResize)
|
|
46
|
+
}
|
|
47
|
+
}, [ref.current])
|
|
48
|
+
|
|
49
|
+
return componentSize
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default useComponentSize
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const useStateWithDynamicDefault = <T>(defaultVal: T) => {
|
|
4
|
+
const [state, setState] = useState<T>(defaultVal)
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
setState(defaultVal)
|
|
8
|
+
}, [defaultVal])
|
|
9
|
+
|
|
10
|
+
return [state, setState] as const
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default useStateWithDynamicDefault
|
package/lib/main.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Pickers
|
|
2
|
+
export { default as CCPicker } from './pickers/CCPicker'
|
|
3
|
+
export { default as ChannelMappingPicker } from './pickers/ChannelMappingPicker'
|
|
4
|
+
export { default as ChannelPicker } from './pickers/ChannelPicker'
|
|
5
|
+
export { default as Knob } from './pickers/Knob'
|
|
6
|
+
export { default as KnobPicker } from './pickers/KnobPicker'
|
|
7
|
+
export { default as LatchPicker } from './pickers/LatchPicker'
|
|
8
|
+
export { default as MappingPicker } from './pickers/MappingPicker'
|
|
9
|
+
export { default as NotePicker } from './pickers/NotePicker'
|
|
10
|
+
export { default as OctavePlayer } from './other/OctavePlayer'
|
|
11
|
+
export { default as PianoPicker } from './pickers/PianoPicker'
|
|
12
|
+
export { default as PolarityPicker } from './pickers/PolarityPicker'
|
|
13
|
+
export { default as ResponseCurvePicker } from './pickers/ResponseCurvePicker'
|
|
14
|
+
export { default as Select } from './pickers/Select'
|
|
15
|
+
export { default as StatusPicker } from './pickers/StatusPicker'
|
|
16
|
+
export { default as SVGText } from './other/SVGText'
|
|
17
|
+
export { default as ValuePicker } from './pickers/ValuePicker'
|
|
18
|
+
|
|
19
|
+
// MIDI
|
|
20
|
+
export {
|
|
21
|
+
combineStatusWithChannel,
|
|
22
|
+
extractStatusAndChannel,
|
|
23
|
+
getStatusLabel,
|
|
24
|
+
MASK_CHANNEL,
|
|
25
|
+
MASK_STATUS,
|
|
26
|
+
Statuses,
|
|
27
|
+
} from './midi/export'
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
default as ResponseCurve,
|
|
31
|
+
RESPONSE_CURVES,
|
|
32
|
+
} from './pickers/ResponseCurve'
|
|
33
|
+
|
|
34
|
+
export { default as ccValues } from './midi/ccValues'
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { Option } from '../pickers/Select'
|
|
2
|
+
|
|
3
|
+
const CC_NAMES = [
|
|
4
|
+
'Bank Select',
|
|
5
|
+
'Modulation Wheel',
|
|
6
|
+
'Breath Controller',
|
|
7
|
+
'',
|
|
8
|
+
'Foot Control',
|
|
9
|
+
'Portamento Time',
|
|
10
|
+
'Data Entry Slider',
|
|
11
|
+
'Volume',
|
|
12
|
+
'Balance',
|
|
13
|
+
'',
|
|
14
|
+
'Pan',
|
|
15
|
+
'Expression',
|
|
16
|
+
'Effect Control 1',
|
|
17
|
+
'Effect Control 2',
|
|
18
|
+
'',
|
|
19
|
+
'',
|
|
20
|
+
'',
|
|
21
|
+
'',
|
|
22
|
+
'',
|
|
23
|
+
'',
|
|
24
|
+
'',
|
|
25
|
+
'',
|
|
26
|
+
'',
|
|
27
|
+
'',
|
|
28
|
+
'',
|
|
29
|
+
'',
|
|
30
|
+
'',
|
|
31
|
+
'',
|
|
32
|
+
'',
|
|
33
|
+
'',
|
|
34
|
+
'',
|
|
35
|
+
'',
|
|
36
|
+
'Controller 0',
|
|
37
|
+
'Controller 1',
|
|
38
|
+
'Controller 2',
|
|
39
|
+
'Controller 3',
|
|
40
|
+
'Controller 4',
|
|
41
|
+
'Controller 5',
|
|
42
|
+
'Controller 6',
|
|
43
|
+
'Controller 7',
|
|
44
|
+
'Controller 8',
|
|
45
|
+
'Controller 9',
|
|
46
|
+
'Controller 10',
|
|
47
|
+
'Controller 11',
|
|
48
|
+
'Controller 12',
|
|
49
|
+
'Controller 13',
|
|
50
|
+
'Controller 14',
|
|
51
|
+
'Controller 15',
|
|
52
|
+
'Controller 16',
|
|
53
|
+
'Controller 17',
|
|
54
|
+
'Controller 18',
|
|
55
|
+
'Controller 19',
|
|
56
|
+
'Controller 20',
|
|
57
|
+
'Controller 21',
|
|
58
|
+
'Controller 22',
|
|
59
|
+
'Controller 23',
|
|
60
|
+
'Controller 24',
|
|
61
|
+
'Controller 25',
|
|
62
|
+
'Controller 26',
|
|
63
|
+
'Controller 27',
|
|
64
|
+
'Controller 28',
|
|
65
|
+
'Controller 29',
|
|
66
|
+
'Controller 30',
|
|
67
|
+
'Controller 31',
|
|
68
|
+
'Sustain',
|
|
69
|
+
'Portamento',
|
|
70
|
+
'Sostenuto',
|
|
71
|
+
'Soft Pedal',
|
|
72
|
+
'Legato Pedal',
|
|
73
|
+
'Sustain 2',
|
|
74
|
+
'Sound Variation',
|
|
75
|
+
'Resonance/Timbre',
|
|
76
|
+
'Sound Release Time',
|
|
77
|
+
'Sound Attack Time',
|
|
78
|
+
'Frequency Cutoff',
|
|
79
|
+
'Sound Control 6',
|
|
80
|
+
'Sound Control 7',
|
|
81
|
+
'Sound Control 8',
|
|
82
|
+
'Sound Control 9',
|
|
83
|
+
'Sound Control 10',
|
|
84
|
+
'Decay or General 1',
|
|
85
|
+
'Hi-Pass or General 2',
|
|
86
|
+
'General 3',
|
|
87
|
+
'General 4',
|
|
88
|
+
'Portamento Amount',
|
|
89
|
+
'',
|
|
90
|
+
'',
|
|
91
|
+
'',
|
|
92
|
+
'',
|
|
93
|
+
'',
|
|
94
|
+
'',
|
|
95
|
+
'Reverb Level',
|
|
96
|
+
'Tremolo Depth',
|
|
97
|
+
'Chorus Level',
|
|
98
|
+
'Detune',
|
|
99
|
+
'Phaser Depth',
|
|
100
|
+
'Data Entry +1',
|
|
101
|
+
'Data Entry -1',
|
|
102
|
+
'Non-registered LSB',
|
|
103
|
+
'Non-registered MSB',
|
|
104
|
+
'Registered msb',
|
|
105
|
+
'Registered lsb',
|
|
106
|
+
'',
|
|
107
|
+
'',
|
|
108
|
+
'',
|
|
109
|
+
'',
|
|
110
|
+
'',
|
|
111
|
+
'',
|
|
112
|
+
'',
|
|
113
|
+
'',
|
|
114
|
+
'Shift 1',
|
|
115
|
+
'Shift 2',
|
|
116
|
+
'Shift 3',
|
|
117
|
+
'Shift 4',
|
|
118
|
+
'Shift 5',
|
|
119
|
+
'Shift 6',
|
|
120
|
+
'',
|
|
121
|
+
'',
|
|
122
|
+
'',
|
|
123
|
+
'',
|
|
124
|
+
'All Sound Off',
|
|
125
|
+
'All Controllers Off',
|
|
126
|
+
'Local Mode',
|
|
127
|
+
'All Notes Off',
|
|
128
|
+
'Omni Mode Off',
|
|
129
|
+
'Omni Mode On',
|
|
130
|
+
'Mono Mode On',
|
|
131
|
+
'Poly Mode',
|
|
132
|
+
].map(
|
|
133
|
+
(label, value): Option<number> => ({
|
|
134
|
+
label: String(label).length ? `${value} - ${label}` : String(value),
|
|
135
|
+
value,
|
|
136
|
+
}),
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
export default CC_NAMES
|