@vitessce/layer-controller 3.1.0 → 3.1.2

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.
Files changed (44) hide show
  1. package/dist/{deflate-806a8813.js → deflate-460ebda8.js} +1 -1
  2. package/dist/{index-f05b8dd7.js → index-7295e6e7.js} +561 -108
  3. package/dist/index.js +1 -1
  4. package/dist/{jpeg-ad5bae1d.js → jpeg-5e6a02ae.js} +1 -1
  5. package/dist/{lerc-588ff773.js → lerc-f147b9b3.js} +1 -1
  6. package/dist/{lzw-8827a384.js → lzw-328dcf22.js} +1 -1
  7. package/dist/{packbits-88aef591.js → packbits-d1842d12.js} +1 -1
  8. package/dist/{raw-86577f38.js → raw-e59a20ba.js} +1 -1
  9. package/dist/{webimage-c9cb4e30.js → webimage-30f949aa.js} +1 -1
  10. package/dist-tsc/BitmaskChannelController.d.ts.map +1 -1
  11. package/dist-tsc/BitmaskChannelController.js +1 -1
  12. package/dist-tsc/ChannelOptions.d.ts.map +1 -1
  13. package/dist-tsc/ChannelOptions.js +1 -1
  14. package/dist-tsc/ColorPalette.d.ts.map +1 -1
  15. package/dist-tsc/ColorPalette.js +1 -1
  16. package/dist-tsc/ImageAddButton.d.ts.map +1 -1
  17. package/dist-tsc/ImageAddButton.js +1 -1
  18. package/dist-tsc/LayerController.d.ts.map +1 -1
  19. package/dist-tsc/LayerController.js +6 -5
  20. package/dist-tsc/LayerOptions.d.ts.map +1 -1
  21. package/dist-tsc/LayerOptions.js +19 -13
  22. package/dist-tsc/RasterChannelController.d.ts.map +1 -1
  23. package/dist-tsc/RasterChannelController.js +6 -1
  24. package/dist-tsc/VectorLayerController.d.ts.map +1 -1
  25. package/dist-tsc/VectorLayerController.js +4 -1
  26. package/dist-tsc/VolumeOptions.d.ts.map +1 -1
  27. package/dist-tsc/VolumeOptions.js +3 -2
  28. package/dist-tsc/shared-channel-controls.d.ts.map +1 -1
  29. package/dist-tsc/shared-channel-controls.js +2 -2
  30. package/dist-tsc/styles.d.ts +1 -0
  31. package/dist-tsc/styles.d.ts.map +1 -1
  32. package/dist-tsc/styles.js +9 -0
  33. package/package.json +6 -6
  34. package/src/BitmaskChannelController.js +5 -1
  35. package/src/ChannelOptions.js +14 -3
  36. package/src/ColorPalette.js +2 -1
  37. package/src/ImageAddButton.js +1 -0
  38. package/src/LayerController.js +13 -4
  39. package/src/LayerOptions.js +39 -16
  40. package/src/RasterChannelController.js +11 -1
  41. package/src/VectorLayerController.js +10 -1
  42. package/src/VolumeOptions.js +5 -1
  43. package/src/shared-channel-controls.js +2 -0
  44. package/src/styles.js +10 -0
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useId } from 'react';
2
2
  import { range } from 'lodash-es';
3
3
  import { Matrix4 } from 'math.gl';
4
4
  import { Grid, Slider, InputLabel, Select, Checkbox } from '@material-ui/core';
@@ -13,7 +13,8 @@ import {
13
13
  import {
14
14
  getBoundingCube, getMultiSelectionStats,
15
15
  } from './utils.js';
16
- import { useSelectionSliderStyles, useSelectStyles } from './styles.js';
16
+
17
+ import { useSelectionSliderStyles, useSelectStyles, useChannelSliderStyles } from './styles.js';
17
18
 
18
19
  const DOMAIN_OPTIONS = ['Full', 'Min/Max'];
19
20
 
@@ -125,6 +126,7 @@ function VolumeDropdown({
125
126
  e.target.value === '2D' ? e.target.value : Number(e.target.value),
126
127
  )
127
128
  }
129
+ inputProps={{ 'aria-label': 'Resolution selector' }}
128
130
  classes={{ root: classes.selectRoot }}
129
131
  >
130
132
  <option key="2D" value="2D">
@@ -179,7 +181,7 @@ function ColormapSelect({ value, inputId, handleChange }) {
179
181
  native
180
182
  onChange={e => handleChange(e.target.value === '' ? null : e.target.value)}
181
183
  value={value}
182
- inputProps={{ name: 'colormap', id: inputId }}
184
+ inputProps={{ name: 'colormap', id: inputId, 'aria-label': 'Colormap selector' }}
183
185
  style={{ width: '100%' }}
184
186
  classes={{ root: classes.selectRoot }}
185
187
  >
@@ -193,7 +195,7 @@ function ColormapSelect({ value, inputId, handleChange }) {
193
195
  );
194
196
  }
195
197
 
196
- function TransparentColorCheckbox({ value, handleChange }) {
198
+ function TransparentColorCheckbox({ value, inputId, handleChange }) {
197
199
  return (
198
200
  <Checkbox
199
201
  style={{ float: 'left', padding: 0 }}
@@ -206,6 +208,8 @@ function TransparentColorCheckbox({ value, handleChange }) {
206
208
  }
207
209
  }}
208
210
  checked={Boolean(value)}
211
+ id={inputId}
212
+ inputProps={{ 'aria-label': 'Enable or disable color transparency' }}
209
213
  />
210
214
  );
211
215
  }
@@ -215,18 +219,21 @@ function TransparentColorCheckbox({ value, handleChange }) {
215
219
  * @prop {string} value Currently selected value between 0 and 1.
216
220
  * @prop {function} handleChange Callback for every change in opacity.
217
221
  */
218
- function OpacitySlider({ value, handleChange }) {
222
+ function OpacitySlider({ value, inputId, handleChange }) {
223
+ const classes = useChannelSliderStyles();
224
+
219
225
  return (
220
226
  <Slider
227
+ classes={{ valueLabel: classes.valueLabel }}
221
228
  value={value}
222
229
  onChange={(e, v) => handleChange(v)}
223
230
  valueLabelDisplay="auto"
224
- getAriaLabel={() => 'opacity slider'}
231
+ aria-label="Layer opacity slider"
232
+ id={inputId}
225
233
  min={0}
226
234
  max={1}
227
235
  step={0.01}
228
236
  orientation="horizontal"
229
- style={{ marginTop: '7px' }}
230
237
  />
231
238
  );
232
239
  }
@@ -244,7 +251,8 @@ function SliderDomainSelector({ value, inputId, handleChange }) {
244
251
  native
245
252
  onChange={e => handleChange(e.target.value)}
246
253
  value={value}
247
- inputProps={{ name: 'domain-selector', id: inputId }}
254
+ id={inputId}
255
+ inputProps={{ name: 'domain-selector', 'aria-label': 'Domain type selector' }}
248
256
  style={{ width: '100%' }}
249
257
  classes={{ root: classes.selectRoot }}
250
258
  >
@@ -267,6 +275,7 @@ function SliderDomainSelector({ value, inputId, handleChange }) {
267
275
  function GlobalSelectionSlider({
268
276
  field,
269
277
  value,
278
+ inputId,
270
279
  handleChange,
271
280
  possibleValues,
272
281
  }) {
@@ -288,7 +297,8 @@ function GlobalSelectionSlider({
288
297
  }
289
298
  }
290
299
  valueLabelDisplay="auto"
291
- getAriaLabel={() => `${field} slider`}
300
+ aria-label={`${field} slider`}
301
+ id={inputId}
292
302
  marks={possibleValues.map(val => ({ value: val }))}
293
303
  min={Number(possibleValues[0])}
294
304
  max={Number(possibleValues.slice(-1))}
@@ -369,6 +379,12 @@ function LayerOptions({
369
379
  const hasViewableResolutions = Boolean(Array.from({
370
380
  length: loader.data.length,
371
381
  }).filter((_, res) => canLoadResolution(loader.data, res)).length);
382
+
383
+ const globalSelectionSliderId = useId();
384
+ const colormapSelectId = useId();
385
+ const domainSelectorId = useId();
386
+ const opacitySliderId = useId();
387
+ const zeroTransparentId = useId();
372
388
  return (
373
389
  <Grid container direction="column" style={{ width: '100%' }}>
374
390
  {hasZStack
@@ -397,9 +413,10 @@ function LayerOptions({
397
413
  && !use3d
398
414
  && globalControlLabels.map(
399
415
  field => shape[labels.indexOf(field)] > 1 && (
400
- <LayerOption name={field} inputId={`${field}-slider`} key={field}>
416
+ <LayerOption name={field} inputId={`${field}-${globalSelectionSliderId}`} key={field}>
401
417
  <GlobalSelectionSlider
402
418
  field={field}
419
+ inputId={`${field}-${globalSelectionSliderId}`}
403
420
  value={globalLabelValues[field]}
404
421
  handleChange={handleGlobalChannelsSelectionChange}
405
422
  possibleValues={range(shape[labels.indexOf(field)])}
@@ -411,10 +428,10 @@ function LayerOptions({
411
428
  <>
412
429
  {shouldShowColormap && (
413
430
  <Grid item>
414
- <LayerOption name="Colormap" inputId="colormap-select">
431
+ <LayerOption name="Colormap" inputId={colormapSelectId}>
415
432
  <ColormapSelect
416
433
  value={colormap || ''}
417
- inputId="colormap-select"
434
+ inputId={colormapSelectId}
418
435
  handleChange={handleColormapChange}
419
436
  />
420
437
  </LayerOption>
@@ -422,9 +439,10 @@ function LayerOptions({
422
439
  )}
423
440
  {shouldShowDomain && (
424
441
  <Grid item>
425
- <LayerOption name="Domain" inputId="domain-selector">
442
+ <LayerOption name="Domain" inputId={domainSelectorId}>
426
443
  <SliderDomainSelector
427
444
  value={domainType || DEFAULT_RASTER_DOMAIN_TYPE}
445
+ inputId={domainSelectorId}
428
446
  handleChange={(value) => {
429
447
  handleDomainChange(value);
430
448
  }}
@@ -436,8 +454,12 @@ function LayerOptions({
436
454
  ) : null}
437
455
  {!use3d && (
438
456
  <Grid item>
439
- <LayerOption name="Opacity" inputId="opacity-slider">
440
- <OpacitySlider value={opacity} handleChange={handleOpacityChange} />
457
+ <LayerOption name="Opacity" inputId={opacitySliderId}>
458
+ <OpacitySlider
459
+ value={opacity}
460
+ handleChange={handleOpacityChange}
461
+ inputId={opacitySliderId}
462
+ />
441
463
  </LayerOption>
442
464
  </Grid>
443
465
  )}
@@ -445,11 +467,12 @@ function LayerOptions({
445
467
  <Grid item>
446
468
  <LayerOption
447
469
  name="Zero Transparent"
448
- inputId="transparent-color-selector"
470
+ inputId={zeroTransparentId}
449
471
  >
450
472
  <TransparentColorCheckbox
451
473
  value={transparentColor}
452
474
  handleChange={handleTransparentColorChange}
475
+ inputId={zeroTransparentId}
453
476
  />
454
477
  </LayerOption>
455
478
  </Grid>
@@ -11,6 +11,7 @@ import {
11
11
  ChannelSelectionDropdown,
12
12
  ChannelVisibilityCheckbox,
13
13
  } from './shared-channel-controls.js';
14
+ import { useChannelSliderStyles } from './styles.js';
14
15
 
15
16
  function abbreviateNumber(value) {
16
17
  // Return an abbreviated representation of value, in 5 characters or less.
@@ -65,14 +66,22 @@ function ChannelSlider({
65
66
  debounce(handleChange, 3, { trailing: true }),
66
67
  [handleChange],
67
68
  );
69
+
70
+ const classes = useChannelSliderStyles();
71
+
68
72
  const step = max - min < 500 && dtype.startsWith('Float') ? (max - min) / 500 : 1;
69
73
  return (
70
74
  <Slider
75
+ classes={{ valueLabel: classes.valueLabel }}
71
76
  value={slider}
72
77
  valueLabelFormat={abbreviateNumber}
73
78
  onChange={(e, v) => handleChangeDebounced(v)}
74
79
  valueLabelDisplay="auto"
75
- getAriaLabel={() => `${color}-${slider}`}
80
+ getAriaLabel={(index) => {
81
+ const labelPrefix = index === 0 ? 'Low value slider' : 'High value slider';
82
+ return `${labelPrefix} for ${color} colormap channel`;
83
+ }}
84
+ getAriaValueText={() => `Current colormap values: ${color}-${slider}`}
76
85
  min={min}
77
86
  max={max}
78
87
  step={step}
@@ -123,6 +132,7 @@ function RasterChannelController({
123
132
  const [selection, setSelection] = useState([
124
133
  { ...channels[channelId].selection },
125
134
  ]);
135
+
126
136
  const rgbColor = toRgbUIString(colormapOn, color, theme);
127
137
 
128
138
  useEffect(() => {
@@ -41,7 +41,12 @@ export default function VectorLayerController(props) {
41
41
  </Typography>
42
42
  <Grid container direction="row" justifyContent="space-between">
43
43
  <Grid item xs={2}>
44
- <Checkbox color="primary" checked={isOn} onChange={(e, v) => handleCheckBoxChange(v)} />
44
+ <Checkbox
45
+ color="primary"
46
+ checked={isOn}
47
+ onChange={(e, v) => handleCheckBoxChange(v)}
48
+ inputProps={{ 'aria-label': 'Show or hide vector layer' }}
49
+ />
45
50
  </Grid>
46
51
  <Grid item xs={9} style={{ paddingRight: '8px' }}>
47
52
  <Slider
@@ -52,6 +57,10 @@ export default function VectorLayerController(props) {
52
57
  onChange={(e, v) => handleSliderChange(v)}
53
58
  style={{ marginTop: '7px' }}
54
59
  orientation="horizontal"
60
+ getAriaLabel={(index) => {
61
+ const labelPrefix = index === 0 ? 'Low value slider' : 'High value slider';
62
+ return `${labelPrefix} for ${label} layer controller`;
63
+ }}
55
64
  />
56
65
  </Grid>
57
66
  </Grid>
@@ -60,6 +60,7 @@ const Slicer = ({
60
60
  zSliceInit,
61
61
  ],
62
62
  ];
63
+
63
64
  const classes = useSlicerStyles();
64
65
  const Slicers = sliceValuesAndSetSliceFunctions.map(
65
66
  ([val, setVal, label, [min, max]]) => (
@@ -74,6 +75,7 @@ const Slicer = ({
74
75
  <Typography
75
76
  className={!use3d ? classes.disabled : classes.enabled}
76
77
  style={{ marginBottom: 0 }}
78
+ variant="h2"
77
79
  >
78
80
  {label}:
79
81
  </Typography>
@@ -86,7 +88,7 @@ const Slicer = ({
86
88
  onChange={(e, v) => setVal(v)}
87
89
  valueLabelDisplay="auto"
88
90
  valueLabelFormat={v => abbreviateNumber(v)}
89
- getAriaLabel={() => `${label} slider`}
91
+ aria-label={`Volume options ${label} slider`}
90
92
  min={min}
91
93
  max={max}
92
94
  step={0.005}
@@ -101,6 +103,7 @@ const Slicer = ({
101
103
  <Typography
102
104
  className={!use3d ? classes.disabled : classes.enabled}
103
105
  style={{ marginTop: 16, marginBottom: 0 }}
106
+ variant="h2"
104
107
  >
105
108
  Clipping Planes:{' '}
106
109
  </Typography>{' '}
@@ -129,6 +132,7 @@ function RenderingModeSelect({
129
132
  inputProps={{
130
133
  name: 'rendering-mode',
131
134
  id: 'rendering-mode-select',
135
+ 'aria-label': 'Select rendering mode option',
132
136
  }}
133
137
  disabled={!use3d}
134
138
  classes={{ root: classes.selectRoot }}
@@ -23,6 +23,7 @@ export function ChannelSelectionDropdown({
23
23
  native
24
24
  value={selectionIndex}
25
25
  onChange={e => handleChange(Number(e.target.value))}
26
+ inputProps={{ 'aria-label': 'Select a channel' }}
26
27
  >
27
28
  {channelOptions.map((opt, i) => (
28
29
  <option disabled={disabled} key={opt} value={i}>
@@ -49,6 +50,7 @@ export function ChannelVisibilityCheckbox({
49
50
  checked={checked}
50
51
  disabled={disabled}
51
52
  style={{ color, '&$checked': { color } }}
53
+ inputProps={{ 'aria-label': 'Toggle on or off a channel' }}
52
54
  />
53
55
  );
54
56
  }
package/src/styles.js CHANGED
@@ -9,6 +9,16 @@ const useSpanStyles = makeStyles(() => ({
9
9
  },
10
10
  }));
11
11
 
12
+ export const useChannelSliderStyles = makeStyles(theme => ({
13
+ valueLabel: {
14
+ marginTop: '7px',
15
+ '& span': {
16
+ color: theme.palette.secondaryForeground, // Change color here
17
+ backgroundColor: theme.palette.secondaryBackgroundDim, // Change color here
18
+ },
19
+ },
20
+ }));
21
+
12
22
  export function MuiSpan(props) {
13
23
  const { children } = props;
14
24
  const classes = useSpanStyles();