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.
- package/dash_core_components/async-datepicker.js +1 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-highlight.js +1 -1
- package/dash_core_components/async-highlight.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components-shared.js +1 -1
- package/dash_core_components/dash_core_components-shared.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/dash_core_components/proptypes.js +2 -0
- package/lib/components/Checklist.tsx +1 -1
- package/lib/components/Graph.react.js +5 -1
- package/lib/components/Input.tsx +2 -2
- package/lib/components/RadioItems.tsx +1 -1
- package/lib/components/css/datepickers.css +5 -0
- package/lib/components/css/dropdown.css +18 -0
- package/lib/components/css/sliders.css +1 -0
- package/lib/fragments/DatePickerRange.tsx +56 -5
- package/lib/fragments/DatePickerSingle.tsx +15 -1
- package/lib/fragments/Dropdown.tsx +242 -131
- package/lib/fragments/Graph.react.js +31 -4
- package/lib/types.ts +12 -0
- package/lib/utils/calendar/Calendar.tsx +1 -3
- package/lib/utils/calendar/helpers.ts +1 -0
- package/lib/utils/dropdownSearch.ts +54 -43
- package/lib/utils/optionRendering.tsx +287 -43
- package/lib/utils/optionTypes.ts +25 -11
- package/package.json +5 -4
- package/dash_core_components/plotly.min.js +0 -8
|
@@ -128,6 +128,8 @@ pk.Dropdown.propTypes = {options:pt.any,
|
|
|
128
128
|
maxHeight:pt.oneOfType([pt.number]),
|
|
129
129
|
style:pt.any,
|
|
130
130
|
labels:pt.oneOfType([pt.shape({select_all:pt.oneOfType([pt.string]),deselect_all:pt.oneOfType([pt.string]),selected_count:pt.oneOfType([pt.string]),search:pt.oneOfType([pt.string]),clear_search:pt.oneOfType([pt.string]),clear_selection:pt.oneOfType([pt.string]),no_options_found:pt.oneOfType([pt.string])})]),
|
|
131
|
+
debounce:pt.oneOfType([pt.bool]),
|
|
132
|
+
search_order:pt.oneOf(['index','original']),
|
|
131
133
|
className:pt.oneOfType([pt.string]),
|
|
132
134
|
setProps:pt.any,
|
|
133
135
|
persistence:pt.oneOfType([pt.string,pt.number,pt.bool]),
|
|
@@ -458,7 +458,11 @@ PlotlyGraph.propTypes = _objectSpread(_objectSpread({}, _Graph.privatePropTypes)
|
|
|
458
458
|
* Localization definitions, if you choose to provide them with the
|
|
459
459
|
* plot rather than registering them globally.
|
|
460
460
|
*/
|
|
461
|
-
locales: _propTypes.default.object
|
|
461
|
+
locales: _propTypes.default.object,
|
|
462
|
+
/**
|
|
463
|
+
* Determines whether or not notifier is displayed
|
|
464
|
+
*/
|
|
465
|
+
displayNotifier: _propTypes.default.bool
|
|
462
466
|
}),
|
|
463
467
|
/**
|
|
464
468
|
* Function that updates the state tree.
|
package/lib/components/Input.tsx
CHANGED
|
@@ -188,13 +188,13 @@ function Input({
|
|
|
188
188
|
|
|
189
189
|
// Apply min/max constraints
|
|
190
190
|
let constrainedValue = newValue;
|
|
191
|
-
if (props.min !== undefined) {
|
|
191
|
+
if (props.min !== null && props.min !== undefined) {
|
|
192
192
|
constrainedValue = Math.max(
|
|
193
193
|
constrainedValue,
|
|
194
194
|
parseFloat(props.min as string)
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
|
-
if (props.max !== undefined) {
|
|
197
|
+
if (props.max !== null && props.min !== undefined) {
|
|
198
198
|
constrainedValue = Math.min(
|
|
199
199
|
constrainedValue,
|
|
200
200
|
parseFloat(props.max as string)
|
|
@@ -55,6 +55,12 @@
|
|
|
55
55
|
cursor: not-allowed;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
.dash-dropdown-focus-target {
|
|
59
|
+
position: absolute;
|
|
60
|
+
opacity: 0;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
.dash-dropdown-value {
|
|
59
65
|
max-width: 100%;
|
|
60
66
|
text-align: left;
|
|
@@ -218,6 +224,18 @@
|
|
|
218
224
|
overflow-y: auto;
|
|
219
225
|
}
|
|
220
226
|
|
|
227
|
+
.dash-dropdown-content:has(.dash-options-list-virtualized) {
|
|
228
|
+
overflow-y: hidden;
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-direction: column;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.dash-dropdown-options:has(.dash-options-list-virtualized) {
|
|
234
|
+
overflow-y: visible;
|
|
235
|
+
flex: 1;
|
|
236
|
+
min-height: 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
221
239
|
.dash-dropdown-option {
|
|
222
240
|
padding: calc(var(--Dash-Spacing) * 2) calc(var(--Dash-Spacing) * 3);
|
|
223
241
|
box-shadow: 0 -1px 0 0 var(--Dash-Fill-Disabled) inset;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
CaretDownIcon,
|
|
7
7
|
Cross1Icon,
|
|
8
8
|
} from '@radix-ui/react-icons';
|
|
9
|
-
import {addDays, subDays} from 'date-fns';
|
|
9
|
+
import {addDays, subDays, differenceInCalendarDays} from 'date-fns';
|
|
10
10
|
import AutosizeInput from 'react-input-autosize';
|
|
11
11
|
import uuid from 'uniqid';
|
|
12
12
|
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
strAsDate,
|
|
21
21
|
} from '../utils/calendar/helpers';
|
|
22
22
|
import {captureCSSForPortal} from '../utils/calendar/cssVariables';
|
|
23
|
+
import ResizeDetector from '../utils/ResizeDetector';
|
|
23
24
|
import '../components/css/datepickers.css';
|
|
24
25
|
|
|
25
26
|
const DatePickerRange = ({
|
|
@@ -104,7 +105,10 @@ const DatePickerRange = ({
|
|
|
104
105
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
105
106
|
const startInputRef = useRef<HTMLInputElement | null>(null);
|
|
106
107
|
const endInputRef = useRef<HTMLInputElement | null>(null);
|
|
108
|
+
const startAutosizeRef = useRef<any>(null);
|
|
109
|
+
const endAutosizeRef = useRef<any>(null);
|
|
107
110
|
const calendarRef = useRef<CalendarHandle>(null);
|
|
111
|
+
const isNewRangeRef = useRef(false);
|
|
108
112
|
const hasPortal = with_portal || with_full_screen_portal;
|
|
109
113
|
|
|
110
114
|
// Capture CSS variables for portal mode
|
|
@@ -128,6 +132,19 @@ const DatePickerRange = ({
|
|
|
128
132
|
setEndInputValue(formatDate(internalEndDate, display_format));
|
|
129
133
|
}, [internalEndDate, display_format]);
|
|
130
134
|
|
|
135
|
+
const handleResize = useCallback(() => {
|
|
136
|
+
startAutosizeRef.current?.updateInputWidth?.();
|
|
137
|
+
endAutosizeRef.current?.updateInputWidth?.();
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
startAutosizeRef.current?.updateInputWidth?.();
|
|
142
|
+
}, [startInputValue]);
|
|
143
|
+
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
endAutosizeRef.current?.updateInputWidth?.();
|
|
146
|
+
}, [endInputValue]);
|
|
147
|
+
|
|
131
148
|
useEffect(() => {
|
|
132
149
|
// Controls when setProps is called. Basically, whenever internal state
|
|
133
150
|
// diverges from props (i.e., user interaction)
|
|
@@ -145,11 +162,17 @@ const DatePickerRange = ({
|
|
|
145
162
|
end_date: dateAsStr(internalEndDate),
|
|
146
163
|
});
|
|
147
164
|
} else if (!internalStartDate && !internalEndDate) {
|
|
148
|
-
// Both dates cleared - send
|
|
165
|
+
// Both dates cleared - send both
|
|
149
166
|
setProps({
|
|
150
167
|
start_date: dateAsStr(internalStartDate),
|
|
151
168
|
end_date: dateAsStr(internalEndDate),
|
|
152
169
|
});
|
|
170
|
+
} else if (endChanged && !internalEndDate) {
|
|
171
|
+
// End date was cleared (user started a new range).
|
|
172
|
+
setProps({
|
|
173
|
+
start_date: dateAsStr(internalStartDate) ?? null,
|
|
174
|
+
end_date: null,
|
|
175
|
+
});
|
|
153
176
|
} else if (updatemode === 'singledate' && internalStartDate) {
|
|
154
177
|
// Only start changed - send just that one
|
|
155
178
|
setProps({start_date: dateAsStr(internalStartDate)});
|
|
@@ -295,6 +318,22 @@ const DatePickerRange = ({
|
|
|
295
318
|
setInternalStartDate(start);
|
|
296
319
|
setInternalEndDate(undefined);
|
|
297
320
|
} else {
|
|
321
|
+
// Skip the mouseUp from the same click that started this range
|
|
322
|
+
if (isNewRangeRef.current && isSameDay(start, end)) {
|
|
323
|
+
isNewRangeRef.current = false;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
isNewRangeRef.current = !!(start && !end);
|
|
327
|
+
|
|
328
|
+
if (start && end && minimum_nights) {
|
|
329
|
+
const numNights = Math.abs(
|
|
330
|
+
differenceInCalendarDays(end, start)
|
|
331
|
+
);
|
|
332
|
+
if (numNights < minimum_nights) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
298
337
|
// Normalize dates: ensure start <= end
|
|
299
338
|
if (start && end && start > end) {
|
|
300
339
|
setInternalStartDate(end);
|
|
@@ -309,11 +348,17 @@ const DatePickerRange = ({
|
|
|
309
348
|
}
|
|
310
349
|
}
|
|
311
350
|
},
|
|
312
|
-
[
|
|
351
|
+
[
|
|
352
|
+
internalStartDate,
|
|
353
|
+
internalEndDate,
|
|
354
|
+
stay_open_on_select,
|
|
355
|
+
minimum_nights,
|
|
356
|
+
]
|
|
313
357
|
);
|
|
314
358
|
|
|
315
359
|
return (
|
|
316
360
|
<div className="dash-datepicker" ref={containerRef}>
|
|
361
|
+
<ResizeDetector onResize={handleResize} targets={[containerRef]}/>
|
|
317
362
|
<Popover.Root
|
|
318
363
|
open={!disabled && isCalendarOpen}
|
|
319
364
|
onOpenChange={disabled ? undefined : setIsCalendarOpen}
|
|
@@ -335,6 +380,7 @@ const DatePickerRange = ({
|
|
|
335
380
|
}}
|
|
336
381
|
>
|
|
337
382
|
<AutosizeInput
|
|
383
|
+
ref={startAutosizeRef}
|
|
338
384
|
inputRef={node => {
|
|
339
385
|
startInputRef.current = node;
|
|
340
386
|
}}
|
|
@@ -342,7 +388,9 @@ const DatePickerRange = ({
|
|
|
342
388
|
id={start_date_id || accessibleId}
|
|
343
389
|
inputClassName="dash-datepicker-input dash-datepicker-start-date"
|
|
344
390
|
value={startInputValue}
|
|
345
|
-
onChange={e =>
|
|
391
|
+
onChange={e =>
|
|
392
|
+
setStartInputValue(e.target?.value)
|
|
393
|
+
}
|
|
346
394
|
onKeyDown={handleStartInputKeyDown}
|
|
347
395
|
onFocus={() => {
|
|
348
396
|
if (isCalendarOpen) {
|
|
@@ -356,6 +404,7 @@ const DatePickerRange = ({
|
|
|
356
404
|
/>
|
|
357
405
|
<ArrowIcon className="dash-datepicker-range-arrow" />
|
|
358
406
|
<AutosizeInput
|
|
407
|
+
ref={endAutosizeRef}
|
|
359
408
|
inputRef={node => {
|
|
360
409
|
endInputRef.current = node;
|
|
361
410
|
}}
|
|
@@ -363,7 +412,9 @@ const DatePickerRange = ({
|
|
|
363
412
|
id={end_date_id || accessibleId + '-end-date'}
|
|
364
413
|
inputClassName="dash-datepicker-input dash-datepicker-end-date"
|
|
365
414
|
value={endInputValue}
|
|
366
|
-
onChange={e =>
|
|
415
|
+
onChange={e =>
|
|
416
|
+
setEndInputValue(e.target?.value)
|
|
417
|
+
}
|
|
367
418
|
onKeyDown={handleEndInputKeyDown}
|
|
368
419
|
onFocus={() => {
|
|
369
420
|
if (isCalendarOpen) {
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
strAsDate,
|
|
15
15
|
} from '../utils/calendar/helpers';
|
|
16
16
|
import {captureCSSForPortal} from '../utils/calendar/cssVariables';
|
|
17
|
+
import ResizeDetector from '../utils/ResizeDetector';
|
|
17
18
|
import '../components/css/datepickers.css';
|
|
18
19
|
|
|
19
20
|
const DatePickerSingle = ({
|
|
@@ -63,6 +64,7 @@ const DatePickerSingle = ({
|
|
|
63
64
|
|
|
64
65
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
65
66
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
67
|
+
const autosizeRef = useRef<any>(null);
|
|
66
68
|
const calendarRef = useRef<CalendarHandle>(null);
|
|
67
69
|
const hasPortal = with_portal || with_full_screen_portal;
|
|
68
70
|
|
|
@@ -87,6 +89,14 @@ const DatePickerSingle = ({
|
|
|
87
89
|
}
|
|
88
90
|
}, [internalDate]);
|
|
89
91
|
|
|
92
|
+
const handleResize = useCallback(() => {
|
|
93
|
+
autosizeRef.current?.updateInputWidth?.();
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
autosizeRef.current?.updateInputWidth?.();
|
|
98
|
+
}, [inputValue]);
|
|
99
|
+
|
|
90
100
|
const parseUserInput = useCallback(
|
|
91
101
|
(focusCalendar = false) => {
|
|
92
102
|
if (inputValue === '') {
|
|
@@ -158,6 +168,7 @@ const DatePickerSingle = ({
|
|
|
158
168
|
|
|
159
169
|
return (
|
|
160
170
|
<div className="dash-datepicker" ref={containerRef}>
|
|
171
|
+
<ResizeDetector onResize={handleResize} targets={[containerRef]}/>
|
|
161
172
|
<Popover.Root
|
|
162
173
|
open={!disabled && isCalendarOpen}
|
|
163
174
|
onOpenChange={disabled ? undefined : setIsCalendarOpen}
|
|
@@ -179,6 +190,7 @@ const DatePickerSingle = ({
|
|
|
179
190
|
}}
|
|
180
191
|
>
|
|
181
192
|
<AutosizeInput
|
|
193
|
+
ref={autosizeRef}
|
|
182
194
|
inputRef={node => {
|
|
183
195
|
inputRef.current = node;
|
|
184
196
|
}}
|
|
@@ -231,7 +243,9 @@ const DatePickerSingle = ({
|
|
|
231
243
|
onCloseAutoFocus={e => {
|
|
232
244
|
e.preventDefault();
|
|
233
245
|
// Only focus if focus is not already on the input
|
|
234
|
-
if (
|
|
246
|
+
if (
|
|
247
|
+
document.activeElement !== inputRef.current
|
|
248
|
+
) {
|
|
235
249
|
inputRef.current?.focus();
|
|
236
250
|
}
|
|
237
251
|
}}
|