dash-core-components 4.0.0 → 4.2.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 (36) 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-slider.js.map +1 -1
  12. package/dash_core_components/async-upload.js.map +1 -1
  13. package/dash_core_components/dash_core_components-shared.js +1 -1
  14. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  15. package/dash_core_components/dash_core_components.js +1 -1
  16. package/dash_core_components/dash_core_components.js.map +1 -1
  17. package/dash_core_components/proptypes.js +2 -0
  18. package/lib/components/Checklist.tsx +1 -1
  19. package/lib/components/Graph.react.js +5 -1
  20. package/lib/components/Input.tsx +2 -2
  21. package/lib/components/RadioItems.tsx +1 -1
  22. package/lib/components/css/datepickers.css +5 -0
  23. package/lib/components/css/dropdown.css +18 -0
  24. package/lib/components/css/sliders.css +1 -0
  25. package/lib/fragments/DatePickerRange.tsx +56 -5
  26. package/lib/fragments/DatePickerSingle.tsx +15 -1
  27. package/lib/fragments/Dropdown.tsx +242 -131
  28. package/lib/fragments/Graph.react.js +31 -4
  29. package/lib/types.ts +12 -0
  30. package/lib/utils/calendar/Calendar.tsx +1 -3
  31. package/lib/utils/calendar/helpers.ts +1 -0
  32. package/lib/utils/dropdownSearch.ts +54 -43
  33. package/lib/utils/optionRendering.tsx +287 -43
  34. package/lib/utils/optionTypes.ts +25 -11
  35. package/package.json +5 -4
  36. package/dash_core_components/plotly.min.js +0 -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,
@@ -36,50 +41,81 @@ const Dropdown = (props: DropdownProps) => {
36
41
  setProps,
37
42
  searchable,
38
43
  search_value,
44
+ search_order,
39
45
  style,
40
46
  value,
41
47
  } = props;
42
48
  const [optionsCheck, setOptionsCheck] = useState<DetailedOption[]>();
43
49
  const [isOpen, setIsOpen] = useState(false);
44
50
  const [displayOptions, setDisplayOptions] = useState<DetailedOption[]>([]);
51
+ const [val, setVal] = useState<DropdownProps['value']>(value);
45
52
  const persistentOptions = useRef<DropdownProps['options']>([]);
46
53
  const dropdownContainerRef = useRef<HTMLButtonElement>(null);
47
54
  const dropdownContentRef = useRef<HTMLDivElement>(
48
55
  document.createElement('div')
49
56
  );
50
57
  const searchInputRef = useRef<HTMLInputElement>(null);
58
+ const optionsListRef = useRef<OptionsListHandle>(null);
59
+ const focusedIndexRef = useRef(-1);
60
+ const pendingSearchRef = useRef('');
51
61
 
52
62
  const ctx = window.dash_component_api.useDashContext();
53
63
  const loading = ctx.useLoading();
54
64
 
65
+ // Sync val when external value prop changes
66
+ useEffect(() => {
67
+ if (!isEqual(value, val)) {
68
+ setVal(value);
69
+ }
70
+ }, [value]);
71
+
55
72
  if (!persistentOptions || !isEqual(options, persistentOptions.current)) {
56
73
  persistentOptions.current = options;
57
74
  }
58
75
 
59
- const {sanitizedOptions, filteredOptions} = useMemo(
76
+ const sanitized = useMemo(
77
+ () => sanitizeDropdownOptions(persistentOptions.current),
78
+ [persistentOptions.current]
79
+ );
80
+ const sanitizedOptions = sanitized.options;
81
+
82
+ const filteredOptions = useMemo(
60
83
  () =>
61
- createFilteredOptions(
62
- persistentOptions.current,
63
- !!searchable,
64
- search_value
65
- ),
66
- [persistentOptions.current, searchable, search_value]
84
+ searchable
85
+ ? filterOptions(sanitized, search_value, search_order)
86
+ : sanitizedOptions,
87
+ [sanitized, searchable, search_value, search_order]
67
88
  );
68
89
 
69
90
  const sanitizedValues: OptionValue[] = useMemo(() => {
70
- if (value instanceof Array) {
71
- return value;
91
+ if (val instanceof Array) {
92
+ return val;
72
93
  }
73
- if (isNil(value)) {
94
+ if (isNil(val)) {
74
95
  return [];
75
96
  }
76
- return [value];
77
- }, [value]);
97
+ return [val];
98
+ }, [val]);
99
+
100
+ const handleSetProps = useCallback(
101
+ (newValue: DropdownProps['value']) => {
102
+ if (debounce && isOpen) {
103
+ // local only
104
+ setVal(newValue);
105
+ } else {
106
+ setVal(newValue);
107
+ setProps({value: newValue});
108
+ }
109
+ },
110
+ [debounce, isOpen, setProps]
111
+ );
78
112
 
79
113
  const updateSelection = useCallback(
80
114
  (selection: OptionValue[]) => {
81
115
  if (closeOnSelect !== false) {
82
116
  setIsOpen(false);
117
+ setProps({search_value: undefined});
118
+ pendingSearchRef.current = '';
83
119
  }
84
120
 
85
121
  if (multi) {
@@ -87,30 +123,28 @@ const Dropdown = (props: DropdownProps) => {
87
123
  if (selection.length === 0) {
88
124
  // Empty selection: only allow if clearable is true
89
125
  if (clearable) {
90
- setProps({value: []});
126
+ handleSetProps([]);
91
127
  }
92
128
  // If clearable is false and trying to set empty, do nothing
93
129
  // return;
94
130
  } else {
95
- // Non-empty selection: always allowed in multi-select
96
- setProps({value: selection});
131
+ handleSetProps(selection);
97
132
  }
98
133
  } else {
99
134
  // For single-select, take the first value or null
100
135
  if (selection.length === 0) {
101
136
  // Empty selection: only allow if clearable is true
102
137
  if (clearable) {
103
- setProps({value: null});
138
+ handleSetProps(null);
104
139
  }
105
140
  // If clearable is false and trying to set empty, do nothing
106
141
  // return;
107
142
  } else {
108
- // Take the first value for single-select
109
- setProps({value: selection[selection.length - 1]});
143
+ handleSetProps(selection[selection.length - 1]);
110
144
  }
111
145
  }
112
146
  },
113
- [multi, clearable, closeOnSelect]
147
+ [multi, clearable, closeOnSelect, handleSetProps]
114
148
  );
115
149
 
116
150
  const onInputChange = useCallback(
@@ -134,16 +168,16 @@ const Dropdown = (props: DropdownProps) => {
134
168
  !isNil(value) &&
135
169
  !isEmpty(value)
136
170
  ) {
137
- const values = sanitizedOptions.map(option => option.value);
171
+ const {valueSet} = sanitized;
138
172
  if (Array.isArray(value)) {
139
173
  if (multi) {
140
- const invalids = value.filter(v => !values.includes(v));
174
+ const invalids = value.filter(v => !valueSet.has(v));
141
175
  if (invalids.length) {
142
176
  setProps({value: without(invalids, value)});
143
177
  }
144
178
  }
145
179
  } else {
146
- if (!values.includes(value)) {
180
+ if (!valueSet.has(value)) {
147
181
  setProps({value: null});
148
182
  }
149
183
  }
@@ -179,8 +213,8 @@ const Dropdown = (props: DropdownProps) => {
179
213
 
180
214
  const handleClear = useCallback(() => {
181
215
  const finalValue: DropdownProps['value'] = multi ? [] : null;
182
- setProps({value: finalValue});
183
- }, [multi]);
216
+ handleSetProps(finalValue);
217
+ }, [multi, handleSetProps]);
184
218
 
185
219
  const handleSelectAll = useCallback(() => {
186
220
  if (multi) {
@@ -189,12 +223,12 @@ const Dropdown = (props: DropdownProps) => {
189
223
  .filter(option => !sanitizedValues.includes(option.value))
190
224
  .map(option => option.value)
191
225
  );
192
- setProps({value: allValues});
226
+ handleSetProps(allValues);
193
227
  }
194
228
  if (closeOnSelect) {
195
229
  setIsOpen(false);
196
230
  }
197
- }, [multi, displayOptions, sanitizedValues, closeOnSelect]);
231
+ }, [multi, displayOptions, sanitizedValues, closeOnSelect, handleSetProps]);
198
232
 
199
233
  const handleDeselectAll = useCallback(() => {
200
234
  if (multi) {
@@ -203,12 +237,12 @@ const Dropdown = (props: DropdownProps) => {
203
237
  displayOption => displayOption.value === option
204
238
  );
205
239
  });
206
- setProps({value: withDeselected});
240
+ handleSetProps(withDeselected);
207
241
  }
208
242
  if (closeOnSelect) {
209
243
  setIsOpen(false);
210
244
  }
211
- }, [multi, displayOptions, sanitizedValues, closeOnSelect]);
245
+ }, [multi, displayOptions, sanitizedValues, closeOnSelect, handleSetProps]);
212
246
 
213
247
  // Sort options when popover opens - selected options first
214
248
  // Update display options when filtered options or selection changes
@@ -235,134 +269,151 @@ const Dropdown = (props: DropdownProps) => {
235
269
  }
236
270
  }, [filteredOptions, isOpen]);
237
271
 
238
- // Focus first selected item or search input when dropdown opens
272
+ // Focus first selected item or search input when dropdown opens.
273
+ // Depends on displayOptions so it fires after OptionsList is mounted.
239
274
  useEffect(() => {
240
- if (!isOpen || search_value) {
275
+ if (!isOpen || pendingSearchRef.current || !displayOptions.length) {
276
+ return;
277
+ }
278
+
279
+ // Don't steal focus from the search input during search-driven
280
+ // re-renders (displayOptions changes while the user is typing).
281
+ if (document.activeElement === searchInputRef.current) {
241
282
  return;
242
283
  }
243
284
 
244
- // waiting for the DOM to be ready after the dropdown renders
245
285
  requestAnimationFrame(() => {
246
- // Try to focus the first selected item (for single-select)
247
286
  if (!multi) {
248
287
  const selectedValue = sanitizedValues[0];
249
288
  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();
289
+ const selectedIndex = displayOptions.findIndex(
290
+ o => o.value === selectedValue
291
+ );
292
+ if (selectedIndex >= 0) {
293
+ focusedIndexRef.current = selectedIndex;
294
+ optionsListRef.current?.focusItem(selectedIndex);
257
295
  return;
258
296
  }
259
297
  }
260
298
  }
261
299
 
262
- // Fallback: focus search input if available and no selected item was focused
263
- if (searchable && searchInputRef.current) {
264
- searchInputRef.current.focus();
300
+ if (searchable) {
301
+ searchInputRef.current?.focus();
302
+ } else {
303
+ focusedIndexRef.current = 0;
304
+ optionsListRef.current?.focusItem(0);
265
305
  }
266
306
  });
267
307
  }, [isOpen, multi, displayOptions]);
268
308
 
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
- }
309
+ // Handle keyboard navigation in popover.
310
+ // Index -1 = search input, 0..N-1 = option index in displayOptions.
311
+ const handleKeyDown = useCallback(
312
+ (e: React.KeyboardEvent) => {
313
+ const relevantKeys = [
314
+ 'ArrowDown',
315
+ 'ArrowUp',
316
+ 'Tab',
317
+ 'PageDown',
318
+ 'PageUp',
319
+ 'Home',
320
+ 'End',
321
+ ];
322
+ if (!relevantKeys.includes(e.key)) {
323
+ return;
324
+ }
290
325
 
291
- const focusableElements = e.currentTarget.querySelectorAll(
292
- 'input[type="search"], input:not([disabled])'
293
- ) as NodeListOf<HTMLElement>;
326
+ if (
327
+ ['Home', 'End'].includes(e.key) &&
328
+ document.activeElement === searchInputRef.current
329
+ ) {
330
+ return;
331
+ }
294
332
 
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
- }
333
+ if (displayOptions.length === 0) {
334
+ return;
335
+ }
299
336
 
300
- e.preventDefault();
337
+ e.preventDefault();
338
+
339
+ const hasSearch = !!searchable;
340
+ const current = focusedIndexRef.current;
341
+ const maxIndex = displayOptions.length - 1;
342
+ const minIndex = hasSearch ? -1 : 0;
343
+ let nextIndex: number;
344
+
345
+ switch (e.key) {
346
+ case 'Tab': {
347
+ // Trap Tab inside the popover so Safari (which
348
+ // skips non-text inputs) can navigate options.
349
+ const next = current + (e.shiftKey ? -1 : 1);
350
+ if (next < minIndex) {
351
+ nextIndex = maxIndex;
352
+ } else if (next > maxIndex) {
353
+ nextIndex = minIndex;
354
+ } else {
355
+ nextIndex = next;
356
+ }
357
+ break;
358
+ }
359
+ case 'ArrowDown':
360
+ nextIndex = current < maxIndex ? current + 1 : minIndex;
361
+ break;
362
+ case 'ArrowUp':
363
+ nextIndex = current > minIndex ? current - 1 : maxIndex;
364
+ break;
365
+ case 'PageDown':
366
+ nextIndex = Math.min(current + 10, maxIndex);
367
+ break;
368
+ case 'PageUp':
369
+ nextIndex = Math.max(current - 10, minIndex);
370
+ break;
371
+ case 'Home':
372
+ nextIndex = minIndex;
373
+ break;
374
+ case 'End':
375
+ nextIndex = maxIndex;
376
+ break;
377
+ default:
378
+ return;
379
+ }
301
380
 
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
- }
381
+ focusedIndexRef.current = nextIndex;
340
382
 
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
383
+ if (nextIndex === -1) {
384
+ searchInputRef.current?.focus();
346
385
  dropdownContentRef.current?.scrollTo({top: 0});
347
386
  } else {
348
- focusableElements[nextIndex].scrollIntoView({
349
- behavior: 'auto',
350
- block: 'nearest',
351
- });
387
+ optionsListRef.current?.focusItem(nextIndex);
352
388
  }
353
- }
354
- }, []);
389
+ },
390
+ [displayOptions.length, searchable]
391
+ );
355
392
 
356
- // Handle popover open/close
357
393
  const handleOpenChange = useCallback(
358
394
  (open: boolean) => {
359
395
  setIsOpen(open);
396
+ focusedIndexRef.current = -1;
360
397
 
361
398
  if (!open) {
362
- setProps({search_value: undefined});
399
+ pendingSearchRef.current = '';
400
+ const updates: Partial<DropdownProps> = {};
401
+
402
+ if (!isNil(search_value)) {
403
+ updates.search_value = undefined;
404
+ }
405
+
406
+ // Commit debounced value on close only
407
+ if (debounce && !isEqual(value, val)) {
408
+ updates.value = val;
409
+ }
410
+
411
+ if (Object.keys(updates).length > 0) {
412
+ setProps(updates);
413
+ }
363
414
  }
364
415
  },
365
- [filteredOptions, sanitizedValues]
416
+ [debounce, value, val, search_value, setProps]
366
417
  );
367
418
 
368
419
  const accessibleId = id ?? uuid();
@@ -371,12 +422,37 @@ const Dropdown = (props: DropdownProps) => {
371
422
 
372
423
  const popover = (
373
424
  <Popover.Root open={isOpen} onOpenChange={handleOpenChange}>
425
+ {/* Safari skips <button> in the Tab order; this hidden
426
+ input receives Tab focus and delegates to the button. */}
427
+ <input
428
+ className="dash-dropdown-focus-target"
429
+ tabIndex={disabled ? -1 : 0}
430
+ readOnly
431
+ aria-hidden="true"
432
+ onFocus={e => {
433
+ if (e.relatedTarget !== dropdownContainerRef.current) {
434
+ e.currentTarget.tabIndex = -1;
435
+ dropdownContainerRef.current?.focus();
436
+ }
437
+ }}
438
+ onClick={() => {
439
+ dropdownContainerRef.current?.click();
440
+ }}
441
+ />
374
442
  <Popover.Trigger asChild>
375
443
  <button
376
444
  id={id}
377
445
  ref={dropdownContainerRef}
378
446
  disabled={disabled}
379
447
  type="button"
448
+ tabIndex={-1}
449
+ onBlur={e => {
450
+ const dummyInput =
451
+ e.currentTarget.previousElementSibling;
452
+ if (dummyInput instanceof HTMLElement) {
453
+ dummyInput.tabIndex = 0;
454
+ }
455
+ }}
380
456
  onKeyDown={e => {
381
457
  if (['ArrowDown', 'Enter'].includes(e.key)) {
382
458
  e.preventDefault();
@@ -392,6 +468,14 @@ const Dropdown = (props: DropdownProps) => {
392
468
  ) {
393
469
  handleClear();
394
470
  }
471
+ if (e.key.length === 1 && searchable) {
472
+ pendingSearchRef.current += e.key;
473
+ setProps({search_value: pendingSearchRef.current});
474
+ setIsOpen(true);
475
+ requestAnimationFrame(() =>
476
+ searchInputRef.current?.focus()
477
+ );
478
+ }
395
479
  }}
396
480
  className={`dash-dropdown ${className ?? ''}`}
397
481
  aria-labelledby={`${accessibleId}-value-count ${accessibleId}-value`}
@@ -475,6 +559,31 @@ const Dropdown = (props: DropdownProps) => {
475
559
  value={search_value || ''}
476
560
  autoComplete="off"
477
561
  onChange={e => onInputChange(e.target.value)}
562
+ onKeyUp={e => {
563
+ if (
564
+ !search_value ||
565
+ e.key !== 'Enter' ||
566
+ !displayOptions.length
567
+ ) {
568
+ return;
569
+ }
570
+ const firstVal = displayOptions[0].value;
571
+ const isSelected =
572
+ sanitizedValues.includes(firstVal);
573
+ let newSelection;
574
+ if (isSelected) {
575
+ newSelection = without(
576
+ [firstVal],
577
+ sanitizedValues
578
+ );
579
+ } else {
580
+ newSelection = append(
581
+ firstVal,
582
+ sanitizedValues
583
+ );
584
+ }
585
+ updateSelection(newSelection);
586
+ }}
478
587
  ref={searchInputRef}
479
588
  />
480
589
  {search_value && (
@@ -512,17 +621,19 @@ const Dropdown = (props: DropdownProps) => {
512
621
  {isOpen && !!displayOptions.length && (
513
622
  <>
514
623
  <OptionsList
624
+ ref={optionsListRef}
515
625
  options={displayOptions}
516
626
  selected={sanitizedValues}
517
627
  onSelectionChange={updateSelection}
518
628
  inputType={multi ? 'checkbox' : 'radio'}
519
629
  className="dash-dropdown-options"
520
630
  optionClassName="dash-dropdown-option"
521
- optionStyle={{
522
- height: optionHeight
523
- ? `${optionHeight}px`
524
- : undefined,
525
- }}
631
+ optionHeight={
632
+ typeof optionHeight === 'number'
633
+ ? optionHeight
634
+ : undefined
635
+ }
636
+ maxHeight={maxHeight}
526
637
  />
527
638
  </>
528
639
  )}
@@ -263,10 +263,12 @@ class PlotlyGraph extends _react.Component {
263
263
  getConfig(config, responsive) {
264
264
  return (0, _ramda.mergeDeepRight)(config, this.getConfigOverride(responsive));
265
265
  }
266
- getLayout(layout, responsive) {
267
- if (!layout) {
268
- return layout;
266
+ getLayout(originalLayout, responsive) {
267
+ if (!originalLayout) {
268
+ return originalLayout;
269
269
  }
270
+ // Clone layout to avoid mutating the original (important for Patch)
271
+ var layout = (0, _ramda.clone)(originalLayout);
270
272
  var override = this.getLayoutOverride(responsive);
271
273
  var _this$state = this.state,
272
274
  prev_override = _this$state.override,
@@ -294,7 +296,7 @@ class PlotlyGraph extends _react.Component {
294
296
  for (var _key2 in override) {
295
297
  layout[_key2] = override[_key2];
296
298
  }
297
- return layout; // not really a clone
299
+ return layout;
298
300
  }
299
301
  getConfigOverride(responsive) {
300
302
  switch (responsive) {
@@ -351,6 +353,8 @@ class PlotlyGraph extends _react.Component {
351
353
  gd.on('plotly_click', eventData => {
352
354
  var clickData = filterEventData(gd, eventData, 'click');
353
355
  if (!(0, _ramda.isNil)(clickData)) {
356
+ // Add timestamp to ensure each click is unique (for DashWrapper deduplication)
357
+ clickData.timestamp = Date.now();
354
358
  setProps({
355
359
  clickData
356
360
  });
@@ -358,6 +362,8 @@ class PlotlyGraph extends _react.Component {
358
362
  });
359
363
  gd.on('plotly_clickannotation', eventData => {
360
364
  var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
365
+ // Add timestamp to ensure each click is unique (for DashWrapper deduplication)
366
+ clickAnnotationData.timestamp = Date.now();
361
367
  setProps({
362
368
  clickAnnotationData
363
369
  });
@@ -390,6 +396,27 @@ class PlotlyGraph extends _react.Component {
390
396
  relayoutData: relayout
391
397
  });
392
398
  }
399
+ // Sync shapes from gd.layout to figure when shapes are modified by user
400
+ // This is needed because getLayout() clones layout to prevent mutation issues
401
+ if (eventData && gd.layout) {
402
+ var hasShapeChanges = Object.keys(eventData).some(key => key === 'shapes' || key.startsWith('shapes['));
403
+ if (hasShapeChanges) {
404
+ var _figure$layout;
405
+ var _this$props$figure = this.props.figure,
406
+ figure = _this$props$figure === void 0 ? {} : _this$props$figure;
407
+ var currentShapes = figure === null || figure === void 0 || (_figure$layout = figure.layout) === null || _figure$layout === void 0 ? void 0 : _figure$layout.shapes;
408
+ var newShapes = gd.layout.shapes;
409
+ if (!(0, _ramda.equals)(currentShapes, newShapes)) {
410
+ setProps({
411
+ figure: _objectSpread(_objectSpread({}, figure), {}, {
412
+ layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), {}, {
413
+ shapes: newShapes
414
+ })
415
+ })
416
+ });
417
+ }
418
+ }
419
+ }
393
420
  });
394
421
  gd.on('plotly_restyle', eventData => {
395
422
  var restyle = filterEventData(gd, eventData, 'restyle');
package/lib/types.ts CHANGED
@@ -741,6 +741,18 @@ export interface DropdownProps extends BaseDccProps<DropdownProps> {
741
741
  clear_selection?: string;
742
742
  no_options_found?: string;
743
743
  };
744
+ /**
745
+ * If True, changes to input values will be sent back to the Dash server only when dropdown menu closes.
746
+ * Use with `closeOnSelect=False`
747
+ */
748
+ debounce?: boolean;
749
+
750
+ /**
751
+ * The order in which to search results appear. 'index' (the default) means that
752
+ * options are presented based on search relevance, while 'original' keeps the
753
+ * order of options as they were originally provided.
754
+ */
755
+ search_order?: 'index' | 'original';
744
756
  }
745
757
 
746
758
  export interface ChecklistProps extends BaseDccProps<ChecklistProps> {
@@ -188,9 +188,7 @@ const CalendarComponent = ({
188
188
  // Complete the selection with an end date
189
189
  if (selectionStart && !selectionEnd) {
190
190
  // Incomplete selection exists (range picker mid-selection)
191
- if (!isSameDay(selectionStart, date)) {
192
- onSelectionChange(selectionStart, date);
193
- }
191
+ onSelectionChange(selectionStart, date);
194
192
  } else {
195
193
  // Complete selection exists or a single date was chosen
196
194
  onSelectionChange(date, date);