zds-pickers 4.0.14 → 4.0.16

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.
@@ -22,7 +22,7 @@ const SoundfontProvider = (props) => {
22
22
  setInstrument(newInstrument);
23
23
  });
24
24
  }
25
- else if (isDefined(instrumentName)) {
25
+ else if (instrumentName) {
26
26
  // the host app has already injected the soundfont into global space
27
27
  Soundfont.instrument(audioContext, instrumentName).then(newInstrument => {
28
28
  setInstrument(newInstrument);
@@ -34,7 +34,9 @@ const SoundfontProvider = (props) => {
34
34
  }
35
35
  }, [audioContext, format, hostname, instrumentName, soundfont]);
36
36
  useEffect(() => {
37
- loadInstrument(instrumentName);
37
+ if (instrumentName) {
38
+ loadInstrument(instrumentName);
39
+ }
38
40
  }, [instrumentName, loadInstrument]);
39
41
  useEffect(() => {
40
42
  if (isDefined(instrumentName)) {
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
+ import { toRadians } from '../utils';
3
4
  import { DrawCircle } from './DrawCircle';
4
5
  import { DrawLine } from './DrawLine';
5
6
  import { HelpersOverlay } from './HelpersOverlay';
6
- import { toRadians } from '../utils';
7
7
  class KnobVisualHelpers extends React.Component {
8
8
  constructor() {
9
9
  super(...arguments);
@@ -8,7 +8,7 @@ declare const Statuses: {
8
8
  readonly channelPressure: 13;
9
9
  readonly pitchWheel: 14;
10
10
  };
11
- type Status = (typeof Statuses)[keyof typeof Statuses];
11
+ type Status = 8 | 9 | 10 | 11 | 12 | 13 | 14;
12
12
  declare const MASK_CHANNEL = 15;
13
13
  declare const MASK_STATUS = 240;
14
14
  declare const statusOptions: Option<Status>[];
@@ -1,5 +1,11 @@
1
1
  import type Soundfont from 'soundfont-player';
2
2
  import type { TooltipProps } from './DefaultTooltip';
3
+ type PianoMidiNote = {
4
+ accidental: boolean;
5
+ left: number;
6
+ midiNumber: number;
7
+ width: number;
8
+ };
3
9
  type OctavePlayerProps = {
4
10
  disabled?: boolean;
5
11
  height: number;
@@ -10,12 +16,12 @@ type WithProviderProps = {
10
16
  format?: 'mp3' | 'ogg';
11
17
  height: number;
12
18
  hostname?: string;
13
- instrumentName: Soundfont.InstrumentName;
19
+ instrumentName?: Soundfont.InstrumentName;
14
20
  octave?: number;
15
21
  onChange?: (note: number) => void;
16
22
  onClick?: (note: number) => void;
17
23
  onDoubleClick?: (note: number) => void;
18
- onKeyMouseEnter?: (note: number) => void;
24
+ onKeyMouseEnter?: (note: PianoMidiNote) => void;
19
25
  onKeyMouseLeave?: (note: number) => void;
20
26
  soundfont?: 'MusyngKite' | 'FluidR3_GM';
21
27
  Tooltip?: TooltipProps;
@@ -23,4 +29,4 @@ type WithProviderProps = {
23
29
  };
24
30
  declare const WithProvider: ({ format, height, hostname, instrumentName, octave, onChange, onClick, onDoubleClick, onKeyMouseEnter, onKeyMouseLeave, soundfont, Tooltip, width, }: WithProviderProps) => import("react/jsx-runtime").JSX.Element;
25
31
  export { WithProvider as OctavePlayer };
26
- export type { OctavePlayerProps, WithProviderProps };
32
+ export type { OctavePlayerProps, PianoMidiNote, WithProviderProps };
@@ -3,7 +3,7 @@ type SoundfontProviderProps = {
3
3
  audioContext: AudioContext;
4
4
  format?: 'mp3' | 'ogg';
5
5
  hostname?: string;
6
- instrumentName: Soundfont.InstrumentName;
6
+ instrumentName?: Soundfont.InstrumentName;
7
7
  onChange?: (midiNumber: number) => void;
8
8
  render: (props: {
9
9
  isLoading: boolean;
@@ -1,5 +1,10 @@
1
1
  import { type JSX } from 'react';
2
2
  import { type GroupBase, type SelectInstance } from 'react-select';
3
+ type PassedSelectProps = {
4
+ actionButton?: React.ReactNode;
5
+ inputValue?: string;
6
+ placeholder?: React.ReactNode;
7
+ };
3
8
  type Option<T> = {
4
9
  label: React.ReactNode;
5
10
  value: T;
@@ -19,6 +24,7 @@ type SelectProps<T> = {
19
24
  entries: Option<T>[];
20
25
  }[];
21
26
  preserveMenuWidth?: boolean;
27
+ selectProps?: PassedSelectProps;
22
28
  shrinkLabel?: boolean;
23
29
  value: Option<T>['value'];
24
30
  };
@@ -10,7 +10,8 @@ const Statuses = {
10
10
  pitchWheel: 14, // 1110
11
11
  } as const
12
12
 
13
- type Status = (typeof Statuses)[keyof typeof Statuses]
13
+ // Define type as union of literal values
14
+ type Status = 8 | 9 | 10 | 11 | 12 | 13 | 14
14
15
 
15
16
  const MASK_CHANNEL = 15 // 00001111
16
17
  const MASK_STATUS = 240 // 01110000
@@ -4,6 +4,13 @@ import { Piano as ReactPiano } from 'zds-react-piano'
4
4
  import type { TooltipProps } from './DefaultTooltip'
5
5
  import { SoundfontProvider } from './SoundFontProvider'
6
6
 
7
+ type PianoMidiNote = {
8
+ accidental: boolean
9
+ left: number
10
+ midiNumber: number
11
+ width: number
12
+ }
13
+
7
14
  const baseNotes = [
8
15
  'C',
9
16
  'C#',
@@ -67,12 +74,12 @@ type WithProviderProps = {
67
74
  format?: 'mp3' | 'ogg'
68
75
  height: number
69
76
  hostname?: string
70
- instrumentName: Soundfont.InstrumentName
77
+ instrumentName?: Soundfont.InstrumentName
71
78
  octave?: number
72
79
  onChange?: (note: number) => void
73
80
  onClick?: (note: number) => void
74
81
  onDoubleClick?: (note: number) => void
75
- onKeyMouseEnter?: (note: number) => void
82
+ onKeyMouseEnter?: (note: PianoMidiNote) => void
76
83
  onKeyMouseLeave?: (note: number) => void
77
84
  soundfont?: 'MusyngKite' | 'FluidR3_GM'
78
85
  Tooltip?: TooltipProps
@@ -138,4 +145,4 @@ const WithProvider = ({
138
145
 
139
146
  export { WithProvider as OctavePlayer }
140
147
 
141
- export type { OctavePlayerProps, WithProviderProps }
148
+ export type { OctavePlayerProps, PianoMidiNote, WithProviderProps }
@@ -11,7 +11,7 @@ type SoundfontProviderProps = {
11
11
  audioContext: AudioContext
12
12
  format?: 'mp3' | 'ogg'
13
13
  hostname?: string
14
- instrumentName: Soundfont.InstrumentName
14
+ instrumentName?: Soundfont.InstrumentName
15
15
  onChange?: (midiNumber: number) => void
16
16
  render: (props: {
17
17
  isLoading: boolean
@@ -54,7 +54,7 @@ const SoundfontProvider = (props: SoundfontProviderProps) => {
54
54
  }).then(newInstrument => {
55
55
  setInstrument(newInstrument)
56
56
  })
57
- } else if (isDefined(instrumentName)) {
57
+ } else if (instrumentName) {
58
58
  // the host app has already injected the soundfont into global space
59
59
  Soundfont.instrument(audioContext, instrumentName).then(
60
60
  newInstrument => {
@@ -70,7 +70,9 @@ const SoundfontProvider = (props: SoundfontProviderProps) => {
70
70
  )
71
71
 
72
72
  useEffect(() => {
73
- loadInstrument(instrumentName)
73
+ if (instrumentName) {
74
+ loadInstrument(instrumentName)
75
+ }
74
76
  }, [instrumentName, loadInstrument])
75
77
 
76
78
  useEffect(() => {
@@ -20,6 +20,12 @@ import { omit } from '../utils'
20
20
 
21
21
  const { IndicatorsContainer, Placeholder, ValueContainer } = originalComponents
22
22
 
23
+ type PassedSelectProps = {
24
+ actionButton?: React.ReactNode
25
+ inputValue?: string
26
+ placeholder?: React.ReactNode
27
+ }
28
+
23
29
  type Option<T> = {
24
30
  label: React.ReactNode
25
31
  value: T
@@ -28,11 +34,8 @@ type Option<T> = {
28
34
  interface CustomIndicatorsContainerProps<T>
29
35
  extends Omit<IndicatorsContainerProps<Option<T>, false>, 'selectProps'> {
30
36
  children: React.ReactNode
31
- selectProps: IndicatorsContainerProps<Option<T>, false>['selectProps'] & {
32
- actionButton?: React.ReactNode
33
- inputValue?: string
34
- placeholder?: React.ReactNode
35
- }
37
+ selectProps: IndicatorsContainerProps<Option<T>, false>['selectProps'] &
38
+ PassedSelectProps
36
39
  }
37
40
 
38
41
  const CustomIndicatorsContainer = <T,>({
@@ -97,6 +100,7 @@ type SelectProps<T> = {
97
100
  onChange: (value: Option<T>['value']) => void
98
101
  options: Option<T>[] | { entries: Option<T>[] }[]
99
102
  preserveMenuWidth?: boolean
103
+ selectProps?: PassedSelectProps
100
104
  shrinkLabel?: boolean
101
105
  value: Option<T>['value']
102
106
  }
@@ -1,9 +1,9 @@
1
1
  import React from 'react'
2
2
  import type { Point } from '../Types'
3
+ import { toRadians } from '../utils'
3
4
  import { DrawCircle } from './DrawCircle'
4
5
  import { DrawLine } from './DrawLine'
5
6
  import { HelpersOverlay } from './HelpersOverlay'
6
- import { toRadians } from '../utils'
7
7
 
8
8
  /** Precision visual helpers */
9
9
 
@@ -50,7 +50,8 @@ class KnobVisualHelpers extends React.Component<
50
50
  //Note: Not sure why we need to subtract 90 here
51
51
  const valueMarkerX =
52
52
  props.radius * Math.cos(toRadians(props.valueAngle - 90))
53
- const valueMarkerY = props.radius * Math.sin(toRadians(props.valueAngle - 90))
53
+ const valueMarkerY =
54
+ props.radius * Math.sin(toRadians(props.valueAngle - 90))
54
55
 
55
56
  return {
56
57
  ...state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zds-pickers",
3
- "version": "4.0.14",
3
+ "version": "4.0.16",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -155,16 +155,17 @@ const NotePickerStory3: StoryObj<typeof NotePicker> = {
155
155
  isMelodicMode: false,
156
156
  label: 'Action button',
157
157
  mapping: gmMapping,
158
- // selectProps: {
159
- // actionButton: (
160
- // <button
161
- // onClick={e => {
162
- // window.alert('click')
163
- // }}>
164
- // ?
165
- // </button>
166
- // ),
167
- // },
158
+ selectProps: {
159
+ actionButton: (
160
+ <button
161
+ type="button"
162
+ onClick={() => {
163
+ window.alert('click')
164
+ }}>
165
+ ?
166
+ </button>
167
+ ),
168
+ },
168
169
  shrinkLabel: false,
169
170
  value: 38,
170
171
  },