dash-core-components 4.0.0-rc6 → 4.1.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.
Files changed (55) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-mathjax.js +1 -1
  12. package/dash_core_components/async-slider.js +1 -1
  13. package/dash_core_components/async-slider.js.map +1 -1
  14. package/dash_core_components/async-upload.js +1 -2
  15. package/dash_core_components/async-upload.js.map +1 -1
  16. package/dash_core_components/dash_core_components-shared.js +1 -1
  17. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  18. package/dash_core_components/dash_core_components.js +1 -1
  19. package/dash_core_components/dash_core_components.js.map +1 -1
  20. package/dash_core_components/proptypes.js +3 -0
  21. package/lib/components/Checklist.tsx +1 -1
  22. package/lib/components/Clipboard.react.js +67 -105
  23. package/lib/components/ConfirmDialog.react.js +6 -5
  24. package/lib/components/ConfirmDialogProvider.react.js +6 -5
  25. package/lib/components/Download.react.js +3 -1
  26. package/lib/components/Graph.react.js +5 -10
  27. package/lib/components/Interval.react.js +4 -3
  28. package/lib/components/Link.react.js +13 -10
  29. package/lib/components/Location.react.js +11 -7
  30. package/lib/components/Markdown.react.js +1 -8
  31. package/lib/components/RadioItems.tsx +1 -1
  32. package/lib/components/RangeSlider.tsx +2 -0
  33. package/lib/components/Slider.tsx +2 -0
  34. package/lib/components/Store.react.js +16 -13
  35. package/lib/components/css/calendar.css +20 -3
  36. package/lib/components/css/datepickers.css +9 -2
  37. package/lib/components/css/dropdown.css +12 -0
  38. package/lib/components/css/optionslist.css +0 -1
  39. package/lib/fragments/DatePickerRange.tsx +201 -140
  40. package/lib/fragments/DatePickerSingle.tsx +132 -108
  41. package/lib/fragments/Dropdown.tsx +202 -131
  42. package/lib/fragments/Graph.react.js +43 -40
  43. package/lib/fragments/Markdown.react.js +27 -38
  44. package/lib/fragments/RangeSlider.tsx +2 -0
  45. package/lib/fragments/Upload.react.js +117 -202
  46. package/lib/types.ts +17 -0
  47. package/lib/utils/LoadingElement.js +3 -2
  48. package/lib/utils/ResizeDetector.js +5 -3
  49. package/lib/utils/calendar/Calendar.tsx +1 -3
  50. package/lib/utils/calendar/cssVariables.ts +41 -0
  51. package/lib/utils/calendar/helpers.ts +1 -0
  52. package/lib/utils/dropdownSearch.ts +36 -45
  53. package/lib/utils/optionRendering.tsx +284 -43
  54. package/lib/utils/optionTypes.ts +25 -11
  55. package/package.json +9 -8
@@ -1,4 +1,4 @@
1
- import {isNil, without, isEmpty} from 'ramda';
1
+ import {isNil, without, append, isEmpty} from 'ramda';
2
2
  import React, {
3
3
  useState,
4
4
  useCallback,
@@ -7,7 +7,7 @@ import React, {
7
7
  useRef,
8
8
  MouseEvent,
9
9
  } from 'react';
10
- import {createFilteredOptions} from '../utils/dropdownSearch';
10
+ import {sanitizeDropdownOptions, filterOptions} from '../utils/dropdownSearch';
11
11
  import {
12
12
  CaretDownIcon,
13
13
  MagnifyingGlassIcon,
@@ -18,7 +18,11 @@ import '../components/css/dropdown.css';
18
18
 
19
19
  import isEqual from 'react-fast-compare';
20
20
  import {DetailedOption, DropdownProps, OptionValue} from '../types';
21
- import {OptionsList, OptionLabel} from '../utils/optionRendering';
21
+ import {
22
+ OptionsList,
23
+ OptionsListHandle,
24
+ OptionLabel,
25
+ } from '../utils/optionRendering';
22
26
  import uuid from 'uniqid';
23
27
 
24
28
  const Dropdown = (props: DropdownProps) => {
@@ -27,6 +31,7 @@ const Dropdown = (props: DropdownProps) => {
27
31
  className,
28
32
  closeOnSelect,
29
33
  clearable,
34
+ debounce,
30
35
  disabled,
31
36
  labels,
32
37
  maxHeight,
@@ -42,44 +47,74 @@ const Dropdown = (props: DropdownProps) => {
42
47
  const [optionsCheck, setOptionsCheck] = useState<DetailedOption[]>();
43
48
  const [isOpen, setIsOpen] = useState(false);
44
49
  const [displayOptions, setDisplayOptions] = useState<DetailedOption[]>([]);
50
+ const [val, setVal] = useState<DropdownProps['value']>(value);
45
51
  const persistentOptions = useRef<DropdownProps['options']>([]);
46
52
  const dropdownContainerRef = useRef<HTMLButtonElement>(null);
47
53
  const dropdownContentRef = useRef<HTMLDivElement>(
48
54
  document.createElement('div')
49
55
  );
50
56
  const searchInputRef = useRef<HTMLInputElement>(null);
57
+ const optionsListRef = useRef<OptionsListHandle>(null);
58
+ const focusedIndexRef = useRef(-1);
59
+ const pendingSearchRef = useRef('');
51
60
 
52
61
  const ctx = window.dash_component_api.useDashContext();
53
62
  const loading = ctx.useLoading();
54
63
 
64
+ // Sync val when external value prop changes
65
+ useEffect(() => {
66
+ if (!isEqual(value, val)) {
67
+ setVal(value);
68
+ }
69
+ }, [value]);
70
+
55
71
  if (!persistentOptions || !isEqual(options, persistentOptions.current)) {
56
72
  persistentOptions.current = options;
57
73
  }
58
74
 
59
- const {sanitizedOptions, filteredOptions} = useMemo(
75
+ const sanitized = useMemo(
76
+ () => sanitizeDropdownOptions(persistentOptions.current),
77
+ [persistentOptions.current]
78
+ );
79
+ const sanitizedOptions = sanitized.options;
80
+
81
+ const filteredOptions = useMemo(
60
82
  () =>
61
- createFilteredOptions(
62
- persistentOptions.current,
63
- !!searchable,
64
- search_value
65
- ),
66
- [persistentOptions.current, searchable, search_value]
83
+ searchable
84
+ ? filterOptions(sanitized, search_value)
85
+ : sanitizedOptions,
86
+ [sanitized, searchable, search_value]
67
87
  );
68
88
 
69
89
  const sanitizedValues: OptionValue[] = useMemo(() => {
70
- if (value instanceof Array) {
71
- return value;
90
+ if (val instanceof Array) {
91
+ return val;
72
92
  }
73
- if (isNil(value)) {
93
+ if (isNil(val)) {
74
94
  return [];
75
95
  }
76
- return [value];
77
- }, [value]);
96
+ return [val];
97
+ }, [val]);
98
+
99
+ const handleSetProps = useCallback(
100
+ (newValue: DropdownProps['value']) => {
101
+ if (debounce && isOpen) {
102
+ // local only
103
+ setVal(newValue);
104
+ } else {
105
+ setVal(newValue);
106
+ setProps({value: newValue});
107
+ }
108
+ },
109
+ [debounce, isOpen, setProps]
110
+ );
78
111
 
79
112
  const updateSelection = useCallback(
80
113
  (selection: OptionValue[]) => {
81
114
  if (closeOnSelect !== false) {
82
115
  setIsOpen(false);
116
+ setProps({search_value: undefined});
117
+ pendingSearchRef.current = '';
83
118
  }
84
119
 
85
120
  if (multi) {
@@ -87,30 +122,28 @@ const Dropdown = (props: DropdownProps) => {
87
122
  if (selection.length === 0) {
88
123
  // Empty selection: only allow if clearable is true
89
124
  if (clearable) {
90
- setProps({value: []});
125
+ handleSetProps([]);
91
126
  }
92
127
  // If clearable is false and trying to set empty, do nothing
93
128
  // return;
94
129
  } else {
95
- // Non-empty selection: always allowed in multi-select
96
- setProps({value: selection});
130
+ handleSetProps(selection);
97
131
  }
98
132
  } else {
99
133
  // For single-select, take the first value or null
100
134
  if (selection.length === 0) {
101
135
  // Empty selection: only allow if clearable is true
102
136
  if (clearable) {
103
- setProps({value: null});
137
+ handleSetProps(null);
104
138
  }
105
139
  // If clearable is false and trying to set empty, do nothing
106
140
  // return;
107
141
  } else {
108
- // Take the first value for single-select
109
- setProps({value: selection[selection.length - 1]});
142
+ handleSetProps(selection[selection.length - 1]);
110
143
  }
111
144
  }
112
145
  },
113
- [multi, clearable, closeOnSelect]
146
+ [multi, clearable, closeOnSelect, handleSetProps]
114
147
  );
115
148
 
116
149
  const onInputChange = useCallback(
@@ -134,16 +167,16 @@ const Dropdown = (props: DropdownProps) => {
134
167
  !isNil(value) &&
135
168
  !isEmpty(value)
136
169
  ) {
137
- const values = sanitizedOptions.map(option => option.value);
170
+ const {valueSet} = sanitized;
138
171
  if (Array.isArray(value)) {
139
172
  if (multi) {
140
- const invalids = value.filter(v => !values.includes(v));
173
+ const invalids = value.filter(v => !valueSet.has(v));
141
174
  if (invalids.length) {
142
175
  setProps({value: without(invalids, value)});
143
176
  }
144
177
  }
145
178
  } else {
146
- if (!values.includes(value)) {
179
+ if (!valueSet.has(value)) {
147
180
  setProps({value: null});
148
181
  }
149
182
  }
@@ -179,8 +212,8 @@ const Dropdown = (props: DropdownProps) => {
179
212
 
180
213
  const handleClear = useCallback(() => {
181
214
  const finalValue: DropdownProps['value'] = multi ? [] : null;
182
- setProps({value: finalValue});
183
- }, [multi]);
215
+ handleSetProps(finalValue);
216
+ }, [multi, handleSetProps]);
184
217
 
185
218
  const handleSelectAll = useCallback(() => {
186
219
  if (multi) {
@@ -189,12 +222,12 @@ const Dropdown = (props: DropdownProps) => {
189
222
  .filter(option => !sanitizedValues.includes(option.value))
190
223
  .map(option => option.value)
191
224
  );
192
- setProps({value: allValues});
225
+ handleSetProps(allValues);
193
226
  }
194
227
  if (closeOnSelect) {
195
228
  setIsOpen(false);
196
229
  }
197
- }, [multi, displayOptions, sanitizedValues, closeOnSelect]);
230
+ }, [multi, displayOptions, sanitizedValues, closeOnSelect, handleSetProps]);
198
231
 
199
232
  const handleDeselectAll = useCallback(() => {
200
233
  if (multi) {
@@ -203,12 +236,12 @@ const Dropdown = (props: DropdownProps) => {
203
236
  displayOption => displayOption.value === option
204
237
  );
205
238
  });
206
- setProps({value: withDeselected});
239
+ handleSetProps(withDeselected);
207
240
  }
208
241
  if (closeOnSelect) {
209
242
  setIsOpen(false);
210
243
  }
211
- }, [multi, displayOptions, sanitizedValues, closeOnSelect]);
244
+ }, [multi, displayOptions, sanitizedValues, closeOnSelect, handleSetProps]);
212
245
 
213
246
  // Sort options when popover opens - selected options first
214
247
  // Update display options when filtered options or selection changes
@@ -235,134 +268,137 @@ const Dropdown = (props: DropdownProps) => {
235
268
  }
236
269
  }, [filteredOptions, isOpen]);
237
270
 
238
- // Focus first selected item or search input when dropdown opens
271
+ // Focus first selected item or search input when dropdown opens.
272
+ // Depends on displayOptions so it fires after OptionsList is mounted.
239
273
  useEffect(() => {
240
- if (!isOpen || search_value) {
274
+ if (!isOpen || pendingSearchRef.current || !displayOptions.length) {
275
+ return;
276
+ }
277
+
278
+ // Don't steal focus from the search input during search-driven
279
+ // re-renders (displayOptions changes while the user is typing).
280
+ if (document.activeElement === searchInputRef.current) {
241
281
  return;
242
282
  }
243
283
 
244
- // waiting for the DOM to be ready after the dropdown renders
245
284
  requestAnimationFrame(() => {
246
- // Try to focus the first selected item (for single-select)
247
285
  if (!multi) {
248
286
  const selectedValue = sanitizedValues[0];
249
287
  if (selectedValue) {
250
- const selectedElement =
251
- dropdownContentRef.current.querySelector(
252
- `.dash-options-list-option-checkbox[value="${selectedValue}"]`
253
- );
254
-
255
- if (selectedElement instanceof HTMLElement) {
256
- selectedElement.focus();
288
+ const selectedIndex = displayOptions.findIndex(
289
+ o => o.value === selectedValue
290
+ );
291
+ if (selectedIndex >= 0) {
292
+ focusedIndexRef.current = selectedIndex;
293
+ optionsListRef.current?.focusItem(selectedIndex);
257
294
  return;
258
295
  }
259
296
  }
260
297
  }
261
298
 
262
- // Fallback: focus search input if available and no selected item was focused
263
- if (searchable && searchInputRef.current) {
264
- searchInputRef.current.focus();
299
+ if (searchable) {
300
+ searchInputRef.current?.focus();
301
+ } else {
302
+ focusedIndexRef.current = 0;
303
+ optionsListRef.current?.focusItem(0);
265
304
  }
266
305
  });
267
306
  }, [isOpen, multi, displayOptions]);
268
307
 
269
- // Handle keyboard navigation in popover
270
- const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
271
- const relevantKeys = [
272
- 'ArrowDown',
273
- 'ArrowUp',
274
- 'PageDown',
275
- 'PageUp',
276
- 'Home',
277
- 'End',
278
- ];
279
- if (!relevantKeys.includes(e.key)) {
280
- return;
281
- }
282
-
283
- // Don't interfere with the event if the user is using Home/End keys on the search input
284
- if (
285
- ['Home', 'End'].includes(e.key) &&
286
- document.activeElement === searchInputRef.current
287
- ) {
288
- return;
289
- }
308
+ // Handle keyboard navigation in popover.
309
+ // Index -1 = search input, 0..N-1 = option index in displayOptions.
310
+ const handleKeyDown = useCallback(
311
+ (e: React.KeyboardEvent) => {
312
+ const relevantKeys = [
313
+ 'ArrowDown',
314
+ 'ArrowUp',
315
+ 'PageDown',
316
+ 'PageUp',
317
+ 'Home',
318
+ 'End',
319
+ ];
320
+ if (!relevantKeys.includes(e.key)) {
321
+ return;
322
+ }
290
323
 
291
- const focusableElements = e.currentTarget.querySelectorAll(
292
- 'input[type="search"], input:not([disabled])'
293
- ) as NodeListOf<HTMLElement>;
324
+ if (
325
+ ['Home', 'End'].includes(e.key) &&
326
+ document.activeElement === searchInputRef.current
327
+ ) {
328
+ return;
329
+ }
294
330
 
295
- // Don't interfere with the event if there aren't any options that the user can interact with
296
- if (focusableElements.length === 0) {
297
- return;
298
- }
331
+ if (displayOptions.length === 0) {
332
+ return;
333
+ }
299
334
 
300
- e.preventDefault();
335
+ e.preventDefault();
336
+
337
+ const hasSearch = !!searchable;
338
+ const current = focusedIndexRef.current;
339
+ const maxIndex = displayOptions.length - 1;
340
+ const minIndex = hasSearch ? -1 : 0;
341
+ let nextIndex: number;
342
+
343
+ switch (e.key) {
344
+ case 'ArrowDown':
345
+ nextIndex = current < maxIndex ? current + 1 : minIndex;
346
+ break;
347
+ case 'ArrowUp':
348
+ nextIndex = current > minIndex ? current - 1 : maxIndex;
349
+ break;
350
+ case 'PageDown':
351
+ nextIndex = Math.min(current + 10, maxIndex);
352
+ break;
353
+ case 'PageUp':
354
+ nextIndex = Math.max(current - 10, minIndex);
355
+ break;
356
+ case 'Home':
357
+ nextIndex = minIndex;
358
+ break;
359
+ case 'End':
360
+ nextIndex = maxIndex;
361
+ break;
362
+ default:
363
+ return;
364
+ }
301
365
 
302
- const currentIndex = Array.from(focusableElements).indexOf(
303
- document.activeElement as HTMLElement
304
- );
305
- let nextIndex = -1;
306
-
307
- switch (e.key) {
308
- case 'ArrowDown':
309
- nextIndex =
310
- currentIndex < focusableElements.length - 1
311
- ? currentIndex + 1
312
- : 0;
313
- break;
314
-
315
- case 'ArrowUp':
316
- nextIndex =
317
- currentIndex > 0
318
- ? currentIndex - 1
319
- : focusableElements.length - 1;
320
-
321
- break;
322
- case 'PageDown':
323
- nextIndex = Math.min(
324
- currentIndex + 10,
325
- focusableElements.length - 1
326
- );
327
- break;
328
- case 'PageUp':
329
- nextIndex = Math.max(currentIndex - 10, 0);
330
- break;
331
- case 'Home':
332
- nextIndex = 0;
333
- break;
334
- case 'End':
335
- nextIndex = focusableElements.length - 1;
336
- break;
337
- default:
338
- break;
339
- }
366
+ focusedIndexRef.current = nextIndex;
340
367
 
341
- if (nextIndex > -1) {
342
- focusableElements[nextIndex].focus();
343
- if (nextIndex === 0) {
344
- // first element is a sticky search bar, so if we are focusing
345
- // on that, also move the scroll to the top
368
+ if (nextIndex === -1) {
369
+ searchInputRef.current?.focus();
346
370
  dropdownContentRef.current?.scrollTo({top: 0});
347
371
  } else {
348
- focusableElements[nextIndex].scrollIntoView({
349
- behavior: 'auto',
350
- block: 'nearest',
351
- });
372
+ optionsListRef.current?.focusItem(nextIndex);
352
373
  }
353
- }
354
- }, []);
374
+ },
375
+ [displayOptions.length, searchable]
376
+ );
355
377
 
356
- // Handle popover open/close
357
378
  const handleOpenChange = useCallback(
358
379
  (open: boolean) => {
359
380
  setIsOpen(open);
381
+ focusedIndexRef.current = -1;
360
382
 
361
383
  if (!open) {
362
- setProps({search_value: undefined});
384
+ pendingSearchRef.current = '';
385
+ const updates: Partial<DropdownProps> = {};
386
+
387
+ if (!isNil(search_value)) {
388
+ updates.search_value = undefined;
389
+ }
390
+
391
+ // Commit debounced value on close only
392
+ if (debounce && !isEqual(value, val)) {
393
+ updates.value = val;
394
+ }
395
+
396
+ if (Object.keys(updates).length > 0) {
397
+ setProps(updates);
398
+ }
363
399
  }
364
400
  },
365
- [filteredOptions, sanitizedValues]
401
+ [debounce, value, val, search_value, setProps]
366
402
  );
367
403
 
368
404
  const accessibleId = id ?? uuid();
@@ -392,6 +428,14 @@ const Dropdown = (props: DropdownProps) => {
392
428
  ) {
393
429
  handleClear();
394
430
  }
431
+ if (e.key.length === 1 && searchable) {
432
+ pendingSearchRef.current += e.key;
433
+ setProps({search_value: pendingSearchRef.current});
434
+ setIsOpen(true);
435
+ requestAnimationFrame(() =>
436
+ searchInputRef.current?.focus()
437
+ );
438
+ }
395
439
  }}
396
440
  className={`dash-dropdown ${className ?? ''}`}
397
441
  aria-labelledby={`${accessibleId}-value-count ${accessibleId}-value`}
@@ -475,6 +519,31 @@ const Dropdown = (props: DropdownProps) => {
475
519
  value={search_value || ''}
476
520
  autoComplete="off"
477
521
  onChange={e => onInputChange(e.target.value)}
522
+ onKeyUp={e => {
523
+ if (
524
+ !search_value ||
525
+ e.key !== 'Enter' ||
526
+ !displayOptions.length
527
+ ) {
528
+ return;
529
+ }
530
+ const firstVal = displayOptions[0].value;
531
+ const isSelected =
532
+ sanitizedValues.includes(firstVal);
533
+ let newSelection;
534
+ if (isSelected) {
535
+ newSelection = without(
536
+ [firstVal],
537
+ sanitizedValues
538
+ );
539
+ } else {
540
+ newSelection = append(
541
+ firstVal,
542
+ sanitizedValues
543
+ );
544
+ }
545
+ updateSelection(newSelection);
546
+ }}
478
547
  ref={searchInputRef}
479
548
  />
480
549
  {search_value && (
@@ -512,17 +581,19 @@ const Dropdown = (props: DropdownProps) => {
512
581
  {isOpen && !!displayOptions.length && (
513
582
  <>
514
583
  <OptionsList
584
+ ref={optionsListRef}
515
585
  options={displayOptions}
516
586
  selected={sanitizedValues}
517
587
  onSelectionChange={updateSelection}
518
588
  inputType={multi ? 'checkbox' : 'radio'}
519
589
  className="dash-dropdown-options"
520
590
  optionClassName="dash-dropdown-option"
521
- optionStyle={{
522
- height: optionHeight
523
- ? `${optionHeight}px`
524
- : undefined,
525
- }}
591
+ optionHeight={
592
+ typeof optionHeight === 'number'
593
+ ? optionHeight
594
+ : undefined
595
+ }
596
+ maxHeight={maxHeight}
526
597
  />
527
598
  </>
528
599
  )}
@@ -17,13 +17,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
17
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
20
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
22
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
24
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
25
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /* global Plotly:true */
20
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* global Plotly:true */
27
21
  /**
28
22
  * `autosize: true` causes Plotly.js to conform to the parent element size.
29
23
  * This is necessary for `dcc.Graph` call to `Plotly.Plots.resize(target)` to do something.
@@ -155,12 +149,16 @@ class PlotlyGraph extends _react.Component {
155
149
  }
156
150
  plot(props) {
157
151
  var _figure, _figure2, _figure3;
158
- var figure = props.figure,
159
- config = props.config;
160
- var animate = props.animate,
161
- animation_options = props.animation_options,
162
- responsive = props.responsive,
163
- mathjax = props.mathjax;
152
+ var {
153
+ figure,
154
+ config
155
+ } = props;
156
+ var {
157
+ animate,
158
+ animation_options,
159
+ responsive,
160
+ mathjax
161
+ } = props;
164
162
  var gd = this.gd.current;
165
163
  figure = props._dashprivate_transformFigure(figure, gd);
166
164
  config = props._dashprivate_transformConfig(config, gd);
@@ -211,10 +209,14 @@ class PlotlyGraph extends _react.Component {
211
209
  });
212
210
  }
213
211
  amendTraces(p, oldProps, newProps) {
214
- var oldPrepend = oldProps.prependData,
215
- oldExtend = oldProps.extendData;
216
- var newPrepend = newProps.prependData,
217
- newExtend = newProps.extendData;
212
+ var {
213
+ prependData: oldPrepend,
214
+ extendData: oldExtend
215
+ } = oldProps;
216
+ var {
217
+ prependData: newPrepend,
218
+ extendData: newExtend
219
+ } = newProps;
218
220
  var _this = this;
219
221
  function mergeTraces(props, dataKey, plotlyFnKey) {
220
222
  var clearState = props.clearState;
@@ -223,10 +225,7 @@ class PlotlyGraph extends _react.Component {
223
225
  dataArray.forEach(data => {
224
226
  var updateData, traceIndices, maxPoints;
225
227
  if (Array.isArray(data) && typeof data[0] === 'object') {
226
- var _data = _slicedToArray(data, 3);
227
- updateData = _data[0];
228
- traceIndices = _data[1];
229
- maxPoints = _data[2];
228
+ [updateData, traceIndices, maxPoints] = data;
230
229
  } else {
231
230
  updateData = data;
232
231
  }
@@ -268,9 +267,10 @@ class PlotlyGraph extends _react.Component {
268
267
  return layout;
269
268
  }
270
269
  var override = this.getLayoutOverride(responsive);
271
- var _this$state = this.state,
272
- prev_override = _this$state.override,
273
- prev_originals = _this$state.originals;
270
+ var {
271
+ override: prev_override,
272
+ originals: prev_originals
273
+ } = this.state;
274
274
  // Store the original data that we're about to override
275
275
  var originals = {};
276
276
  for (var key in override) {
@@ -317,9 +317,11 @@ class PlotlyGraph extends _react.Component {
317
317
  }
318
318
  }
319
319
  isResponsive(props) {
320
- var config = props.config,
321
- figure = props.figure,
322
- responsive = props.responsive;
320
+ var {
321
+ config,
322
+ figure,
323
+ responsive
324
+ } = props;
323
325
  if ((0, _ramda.type)(responsive) === 'Boolean') {
324
326
  return responsive;
325
327
  }
@@ -340,13 +342,14 @@ class PlotlyGraph extends _react.Component {
340
342
  Plotly.Plots.resize(gd).catch(() => {}).finally(() => gd.classList.remove('dash-graph--pending'));
341
343
  }
342
344
  bindEvents() {
343
- var _this$props = this.props,
344
- setProps = _this$props.setProps,
345
- clear_on_unhover = _this$props.clear_on_unhover,
346
- relayoutData = _this$props.relayoutData,
347
- restyleData = _this$props.restyleData,
348
- hoverData = _this$props.hoverData,
349
- selectedData = _this$props.selectedData;
345
+ var {
346
+ setProps,
347
+ clear_on_unhover,
348
+ relayoutData,
349
+ restyleData,
350
+ hoverData,
351
+ selectedData
352
+ } = this.props;
350
353
  var gd = this.gd.current;
351
354
  gd.on('plotly_click', eventData => {
352
355
  var clickData = filterEventData(gd, eventData, 'click');
@@ -444,12 +447,12 @@ class PlotlyGraph extends _react.Component {
444
447
  }
445
448
  }
446
449
  render() {
447
- var _this$props2 = this.props,
448
- className = _this$props2.className,
449
- id = _this$props2.id,
450
- loading_state = _this$props2.loading_state,
451
- _this$props2$style = _this$props2.style,
452
- style = _this$props2$style === void 0 ? {} : _this$props2$style;
450
+ var {
451
+ className,
452
+ id,
453
+ loading_state,
454
+ style = {}
455
+ } = this.props;
453
456
  if (this.isResponsive(this.props)) {
454
457
  style.height || (style.height = '100%');
455
458
  }