zds-pickers 4.0.20 → 4.0.22

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.
@@ -19,6 +19,8 @@ import ReactSelect, {
19
19
  } from 'react-select'
20
20
  import { omit } from '../utils'
21
21
 
22
+ const noSelection = 255
23
+
22
24
  const { IndicatorsContainer, Placeholder, ValueContainer } = originalComponents
23
25
 
24
26
  type PassedSelectProps = {
@@ -32,6 +34,11 @@ type Option<T> = {
32
34
  value: T
33
35
  }
34
36
 
37
+ const noSelectionOption: Option<number> = {
38
+ label: '--',
39
+ value: noSelection,
40
+ }
41
+
35
42
  interface CustomIndicatorsContainerProps<T>
36
43
  extends Omit<IndicatorsContainerProps<Option<T>, false>, 'selectProps'> {
37
44
  children: React.ReactNode
@@ -39,10 +46,10 @@ interface CustomIndicatorsContainerProps<T>
39
46
  PassedSelectProps
40
47
  }
41
48
 
42
- const CustomIndicatorsContainer = <T,>({
43
- children,
44
- ...rest
45
- }: CustomIndicatorsContainerProps<T>) => {
49
+ const CustomIndicatorsContainer = <T,>(
50
+ props: CustomIndicatorsContainerProps<T>,
51
+ ) => {
52
+ const { children, ...rest } = props
46
53
  const actionButton = rest.selectProps?.actionButton
47
54
 
48
55
  return (
@@ -92,6 +99,7 @@ type SelectProps<T> = SelectComponentsConfig<
92
99
  false,
93
100
  GroupBase<Option<T>>
94
101
  > & {
102
+ actionButton?: React.ReactNode
95
103
  className?: string
96
104
  components?: object
97
105
  disabled?: boolean
@@ -110,7 +118,7 @@ type SelectProps<T> = SelectComponentsConfig<
110
118
  preserveMenuWidth?: boolean
111
119
  selectProps?: PassedSelectProps
112
120
  shrinkLabel?: boolean
113
- value: Option<T>['value']
121
+ value?: Option<T>['value']
114
122
  }
115
123
 
116
124
  const Select = forwardRef(
@@ -255,6 +263,6 @@ const Select = forwardRef(
255
263
  },
256
264
  ) => JSX.Element
257
265
 
258
- export { Select }
266
+ export { noSelection, noSelectionOption, Select }
259
267
 
260
268
  export type { Option, SelectProps }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zds-pickers",
3
- "version": "4.0.20",
3
+ "version": "4.0.22",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -60,6 +60,7 @@
60
60
  "prop-types": "15.8.1",
61
61
  "react-dom": "18.2.0",
62
62
  "react": "18.2.0",
63
+ "rc-slider": "11.1.8",
63
64
  "storybook": "8.5.0",
64
65
  "typescript": "5.7.3",
65
66
  "vite": "6.0.7",
@@ -17,6 +17,11 @@ import { PianoPicker } from '../lib/pickers/PianoPicker'
17
17
  import { PolarityPicker } from '../lib/pickers/PolarityPicker'
18
18
  import { ResponseCurve } from '../lib/pickers/ResponseCurve'
19
19
  import { ResponseCurvePicker } from '../lib/pickers/ResponseCurvePicker'
20
+ import {
21
+ type Option,
22
+ noSelection,
23
+ noSelectionOption,
24
+ } from '../lib/pickers/Select'
20
25
  import { StatusPicker } from '../lib/pickers/StatusPicker'
21
26
  import { ValuePicker } from '../lib/pickers/ValuePicker'
22
27
 
@@ -36,6 +41,16 @@ const CCPickerStory: StoryObj<typeof CCPicker> = {
36
41
  },
37
42
  }
38
43
 
44
+ const CCPickerUndefinedStory: StoryObj<typeof CCPicker> = {
45
+ render: args => <CCPicker {...args} />,
46
+ args: {
47
+ disabled: false,
48
+ label: 'CC #',
49
+ shrinkLabel: false,
50
+ value: noSelection,
51
+ },
52
+ }
53
+
39
54
  const ChannelPickerStory: StoryObj<typeof ChannelPicker> = {
40
55
  render: args => <ChannelPicker {...args} />,
41
56
  args: {
@@ -46,6 +61,16 @@ const ChannelPickerStory: StoryObj<typeof ChannelPicker> = {
46
61
  },
47
62
  }
48
63
 
64
+ const ChannelPickerUndefinedStory: StoryObj<typeof ChannelPicker> = {
65
+ render: args => <ChannelPicker {...args} />,
66
+ args: {
67
+ disabled: false,
68
+ label: 'Channel',
69
+ shrinkLabel: false,
70
+ value: noSelection,
71
+ },
72
+ }
73
+
49
74
  const ChannelMappingPickerStory: StoryObj<typeof ChannelMappingPicker> = {
50
75
  render: args => <ChannelMappingPicker {...args} />,
51
76
  args: {
@@ -74,6 +99,39 @@ const ChannelMappingPickerStory: StoryObj<typeof ChannelMappingPicker> = {
74
99
  },
75
100
  }
76
101
 
102
+ const ChannelMappingPickerUndefinedStory: StoryObj<
103
+ typeof ChannelMappingPicker
104
+ > = {
105
+ render: args => <ChannelMappingPicker {...args} />,
106
+ args: {
107
+ channels: [
108
+ ...[
109
+ '',
110
+ 'No Mapping',
111
+ '',
112
+ 'Alesis DM Pro',
113
+ '',
114
+ '',
115
+ '',
116
+ 'BFD3',
117
+ '',
118
+ '',
119
+ 'Roland TD-20',
120
+ 'Roland TD-30 Perc 1 (Latin)',
121
+ '',
122
+ '',
123
+ '',
124
+ '',
125
+ ].map((label, value): Option<number> => ({ label, value })),
126
+ noSelectionOption,
127
+ ],
128
+ disabled: false,
129
+ label: 'Channel',
130
+ shrinkLabel: false,
131
+ value: noSelection,
132
+ },
133
+ }
134
+
77
135
  const KnobStory: StoryObj<typeof Knob> = {
78
136
  render: args => <Knob {...args} />,
79
137
  args: {
@@ -155,22 +213,33 @@ const NotePickerStory3: StoryObj<typeof NotePicker> = {
155
213
  isMelodicMode: false,
156
214
  label: 'Action button',
157
215
  mapping: gmMapping,
158
- selectProps: {
159
- actionButton: (
160
- <button
161
- type="button"
162
- onClick={() => {
163
- window.alert('click')
164
- }}>
165
- ?
166
- </button>
167
- ),
168
- },
216
+ actionButton: (
217
+ <button
218
+ type="button"
219
+ onClick={() => {
220
+ window.alert('click')
221
+ }}>
222
+ ?
223
+ </button>
224
+ ),
169
225
  shrinkLabel: false,
170
226
  value: 38,
171
227
  },
172
228
  }
173
229
 
230
+ const NotePickerStory4: StoryObj<typeof NotePicker> = {
231
+ render: args => <NotePicker {...args} />,
232
+ args: {
233
+ channel: 0,
234
+ disabled: false,
235
+ isMelodicMode: false,
236
+ label: 'Note #',
237
+ mapping: gmMapping,
238
+ shrinkLabel: false,
239
+ value: undefined,
240
+ },
241
+ }
242
+
174
243
  const OctavePlayerStory: StoryObj<typeof OctavePlayer> = {
175
244
  render: args => <OctavePlayer {...args} />,
176
245
  args: {
@@ -184,49 +253,6 @@ const OctavePlayerStory: StoryObj<typeof OctavePlayer> = {
184
253
  },
185
254
  }
186
255
 
187
- // # NotePicker
188
- // <Canvas withToolbar>
189
- // <Story
190
- // height={120}
191
- // name="NotePicker"
192
- // >
193
- // <NotePicker
194
- // channel={number('channel', 0, 'NotePicker')}
195
- // disabled={boolean('disabled', false, 'NotePicker')}
196
- // isMelodicMode={boolean('isMelodicMode', false, 'NotePicker')}
197
- // label={text('label', 'Note #', 'NotePicker')}
198
- // mapping={gmMapping}
199
- // onChange={action('handleChange')}
200
- // shrinkLabel={boolean('shrinkLabel', false, 'NotePicker')}
201
- // value={number('value', 38, {}, 'NotePicker')}
202
- // />
203
- // <br />
204
- // <NotePicker
205
- // channel={number('channel', 0, 'NotePicker2')}
206
- // disabled={boolean('disabled', false, 'NotePicker2')}
207
- // isMelodicMode={boolean('isMelodicMode', false, 'NotePicker2')}
208
- // label="No mapping"
209
- // onChange={action('handleChange2')}
210
- // shrinkLabel={boolean('shrinkLabel', false, 'NotePicker')}
211
- // value={number('value', 38, {}, 'NotePicker2')}
212
- // />
213
- // <br />
214
- // <NotePicker
215
- // channel={number('channel', 0, 'NotePicker3')}
216
- // disabled={boolean('disabled', false, 'NotePicker3')}
217
- // isMelodicMode={boolean('isMelodicMode', false, 'NotePicker3')}
218
- // label="Action button"
219
- // mapping={gmMapping}
220
- // onChange={action('handleChange3')}
221
- // selectProps={{actionButton:<button onClick={e=>{
222
- // console.log('click')
223
- // }}>?</button>}}
224
- // shrinkLabel={boolean('shrinkLabel', false, 'NotePicker')}
225
- // value={number('value', 38, {}, 'NotePicker3')}
226
- // />
227
- // </Story>
228
- // </Canvas>
229
-
230
256
  const PianoPickerStory: StoryObj<typeof PianoPicker> = {
231
257
  render: args => <PianoPicker {...args} />,
232
258
  args: {
@@ -248,6 +274,18 @@ const PolarityPickerStory: StoryObj<typeof PolarityPicker> = {
248
274
  },
249
275
  }
250
276
 
277
+ const PolarityPickerUndefinedStory: StoryObj<typeof PolarityPicker> = {
278
+ render: args => <PolarityPicker {...args} />,
279
+ args: {
280
+ disabled: false,
281
+ label: 'Polarity',
282
+ labelOff: 'Normally Off',
283
+ labelOn: 'Normally On',
284
+ shrinkLabel: false,
285
+ value: noSelection,
286
+ },
287
+ }
288
+
251
289
  const ResponseCurveStory: StoryObj<typeof ResponseCurve> = {
252
290
  render: args => <ResponseCurve {...args} />,
253
291
  args: {
@@ -268,6 +306,18 @@ const ResponseCurvePickerStory: StoryObj<typeof ResponseCurvePicker> = {
268
306
  },
269
307
  }
270
308
 
309
+ const ResponseCurvePickerUndefinedStory: StoryObj<typeof ResponseCurvePicker> =
310
+ {
311
+ render: args => <ResponseCurvePicker {...args} />,
312
+ args: {
313
+ disabled: false,
314
+ inverted: false,
315
+ label: 'Response',
316
+ shrinkLabel: false,
317
+ value: noSelection,
318
+ },
319
+ }
320
+
271
321
  const StatusPickerStory: StoryObj<typeof StatusPicker> = {
272
322
  render: args => <StatusPicker {...args} />,
273
323
  args: {
@@ -279,6 +329,17 @@ const StatusPickerStory: StoryObj<typeof StatusPicker> = {
279
329
  },
280
330
  }
281
331
 
332
+ const StatusPickerUndefinedStory: StoryObj<typeof StatusPicker> = {
333
+ render: args => <StatusPicker {...args} />,
334
+ args: {
335
+ disabled: false,
336
+ label: 'Status Msg',
337
+ shrinkLabel: false,
338
+ statuses: statusOptions,
339
+ value: noSelection,
340
+ },
341
+ }
342
+
282
343
  const ValuePickerStory: StoryObj<typeof ValuePicker> = {
283
344
  render: args => <ValuePicker {...args} />,
284
345
  args: {
@@ -291,10 +352,26 @@ const ValuePickerStory: StoryObj<typeof ValuePicker> = {
291
352
  },
292
353
  }
293
354
 
355
+ const ValuePickerUndefinedStory: StoryObj<typeof ValuePicker> = {
356
+ render: args => <ValuePicker {...args} />,
357
+ args: {
358
+ disabled: false,
359
+ highToLow: false,
360
+ label: 'Value',
361
+ max: 127,
362
+ min: 0,
363
+ shrinkLabel: false,
364
+ value: noSelection,
365
+ },
366
+ }
367
+
294
368
  export {
295
369
  ChannelPickerStory as ChannelPicker,
370
+ ChannelPickerUndefinedStory as ChannelPickerNoValue,
296
371
  ChannelMappingPickerStory as ChannelMappingPicker,
297
- CCPickerStory as ContinuousChangePicker,
372
+ ChannelMappingPickerUndefinedStory as ChannelMappingPickerNoValue,
373
+ CCPickerStory as ChangeController,
374
+ CCPickerUndefinedStory as ChangeControllerNoValue,
298
375
  KnobStory as Knob,
299
376
  KnobPickerStory as KnobPicker,
300
377
  LatchPickerStory as LatchPicker,
@@ -302,13 +379,18 @@ export {
302
379
  NotePickerStory1 as NotePickerSimple,
303
380
  NotePickerStory2 as NotePickerNoMapping,
304
381
  NotePickerStory3 as NotePickerActionButton,
382
+ NotePickerStory4 as NotePickerNoValue,
305
383
  OctavePlayerStory as OctavePlayer,
306
384
  PianoPickerStory as PianoPicker,
307
385
  PolarityPickerStory as PolarityPicker,
386
+ PolarityPickerUndefinedStory as PolarityPickerNoValue,
308
387
  ResponseCurveStory as ResponseCurve,
309
388
  ResponseCurvePickerStory as ResponseCurvePicker,
389
+ ResponseCurvePickerUndefinedStory as ResponseCurvePickerNoValue,
310
390
  StatusPickerStory as StatusPicker,
391
+ StatusPickerUndefinedStory as StatusPickerNoValue,
311
392
  ValuePickerStory as ValuePicker,
393
+ ValuePickerUndefinedStory as ValuePickerNoValue,
312
394
  }
313
395
 
314
396
  export default meta