dash-core-components 4.0.0 → 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.
- 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 +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -2
- 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 +1 -0
- package/lib/components/Checklist.tsx +1 -1
- package/lib/components/Clipboard.react.js +53 -100
- package/lib/components/ConfirmDialog.react.js +6 -5
- package/lib/components/ConfirmDialogProvider.react.js +6 -5
- package/lib/components/Download.react.js +3 -1
- package/lib/components/Graph.react.js +5 -10
- package/lib/components/Interval.react.js +4 -3
- package/lib/components/Link.react.js +13 -10
- package/lib/components/Location.react.js +11 -7
- package/lib/components/Markdown.react.js +1 -8
- package/lib/components/RadioItems.tsx +1 -1
- package/lib/components/Store.react.js +16 -13
- package/lib/components/css/datepickers.css +5 -0
- package/lib/components/css/dropdown.css +12 -0
- package/lib/fragments/DatePickerRange.tsx +195 -143
- package/lib/fragments/DatePickerSingle.tsx +126 -111
- package/lib/fragments/Dropdown.tsx +202 -131
- package/lib/fragments/Graph.react.js +43 -40
- package/lib/fragments/Markdown.react.js +27 -38
- package/lib/fragments/Upload.react.js +117 -202
- package/lib/types.ts +5 -0
- package/lib/utils/LoadingElement.js +3 -2
- package/lib/utils/ResizeDetector.js +5 -3
- package/lib/utils/calendar/Calendar.tsx +1 -3
- package/lib/utils/calendar/helpers.ts +1 -0
- package/lib/utils/dropdownSearch.ts +36 -45
- package/lib/utils/optionRendering.tsx +284 -43
- package/lib/utils/optionTypes.ts +25 -11
- package/package.json +4 -3
|
@@ -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 === '') {
|
|
@@ -157,123 +167,128 @@ const DatePickerSingle = ({
|
|
|
157
167
|
}
|
|
158
168
|
|
|
159
169
|
return (
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
e
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
>
|
|
181
|
-
<AutosizeInput
|
|
182
|
-
inputRef={node => {
|
|
183
|
-
inputRef.current = node;
|
|
170
|
+
<ResizeDetector onResize={handleResize} targets={[containerRef]}>
|
|
171
|
+
<div className="dash-datepicker" ref={containerRef}>
|
|
172
|
+
<Popover.Root
|
|
173
|
+
open={!disabled && isCalendarOpen}
|
|
174
|
+
onOpenChange={disabled ? undefined : setIsCalendarOpen}
|
|
175
|
+
>
|
|
176
|
+
<Popover.Trigger asChild disabled={disabled}>
|
|
177
|
+
<div
|
|
178
|
+
id={accessibleId + '-wrapper'}
|
|
179
|
+
className={classNames}
|
|
180
|
+
style={style}
|
|
181
|
+
aria-labelledby={`${accessibleId}`}
|
|
182
|
+
aria-haspopup="dialog"
|
|
183
|
+
aria-expanded={isCalendarOpen}
|
|
184
|
+
aria-disabled={disabled}
|
|
185
|
+
onClick={e => {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
if (!isCalendarOpen && !disabled) {
|
|
188
|
+
setIsCalendarOpen(true);
|
|
189
|
+
}
|
|
184
190
|
}}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
aria-label=
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
191
|
+
>
|
|
192
|
+
<AutosizeInput
|
|
193
|
+
ref={autosizeRef}
|
|
194
|
+
inputRef={node => {
|
|
195
|
+
inputRef.current = node;
|
|
196
|
+
}}
|
|
197
|
+
type="text"
|
|
198
|
+
id={accessibleId}
|
|
199
|
+
inputClassName="dash-datepicker-input dash-datepicker-end-date"
|
|
200
|
+
value={inputValue}
|
|
201
|
+
onChange={e => setInputValue(e.target?.value)}
|
|
202
|
+
onKeyDown={handleInputKeyDown}
|
|
203
|
+
placeholder={placeholder}
|
|
204
|
+
disabled={disabled}
|
|
205
|
+
dir={direction}
|
|
206
|
+
aria-label={placeholder}
|
|
207
|
+
/>
|
|
208
|
+
{clearable && !disabled && !!date && (
|
|
209
|
+
<a
|
|
210
|
+
className="dash-datepicker-clear"
|
|
211
|
+
onClick={clearSelection}
|
|
212
|
+
aria-label="Clear date"
|
|
213
|
+
>
|
|
214
|
+
<Cross1Icon />
|
|
215
|
+
</a>
|
|
216
|
+
)}
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
<CaretDownIcon className="dash-datepicker-caret-icon" />
|
|
219
|
+
</div>
|
|
220
|
+
</Popover.Trigger>
|
|
209
221
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
>
|
|
213
|
-
<Popover.Content
|
|
214
|
-
className={`dash-datepicker-content${
|
|
215
|
-
hasPortal ? ' dash-datepicker-portal' : ''
|
|
216
|
-
}${
|
|
217
|
-
with_full_screen_portal
|
|
218
|
-
? ' dash-datepicker-fullscreen'
|
|
219
|
-
: ''
|
|
220
|
-
}`}
|
|
221
|
-
style={portalStyle}
|
|
222
|
-
align={hasPortal ? 'center' : 'start'}
|
|
223
|
-
sideOffset={hasPortal ? 0 : 5}
|
|
224
|
-
avoidCollisions={!hasPortal}
|
|
225
|
-
onInteractOutside={
|
|
226
|
-
with_full_screen_portal
|
|
227
|
-
? e => e.preventDefault()
|
|
228
|
-
: undefined
|
|
229
|
-
}
|
|
230
|
-
onOpenAutoFocus={e => e.preventDefault()}
|
|
231
|
-
onCloseAutoFocus={e => {
|
|
232
|
-
e.preventDefault();
|
|
233
|
-
// Only focus if focus is not already on the input
|
|
234
|
-
if (document.activeElement !== inputRef.current) {
|
|
235
|
-
inputRef.current?.focus();
|
|
236
|
-
}
|
|
237
|
-
}}
|
|
222
|
+
<Popover.Portal
|
|
223
|
+
container={hasPortal ? undefined : containerRef.current}
|
|
238
224
|
>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (!selection) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
setInternalDate(selection);
|
|
268
|
-
if (!stay_open_on_select) {
|
|
269
|
-
setIsCalendarOpen(false);
|
|
225
|
+
<Popover.Content
|
|
226
|
+
className={`dash-datepicker-content${
|
|
227
|
+
hasPortal ? ' dash-datepicker-portal' : ''
|
|
228
|
+
}${
|
|
229
|
+
with_full_screen_portal
|
|
230
|
+
? ' dash-datepicker-fullscreen'
|
|
231
|
+
: ''
|
|
232
|
+
}`}
|
|
233
|
+
style={portalStyle}
|
|
234
|
+
align={hasPortal ? 'center' : 'start'}
|
|
235
|
+
sideOffset={hasPortal ? 0 : 5}
|
|
236
|
+
avoidCollisions={!hasPortal}
|
|
237
|
+
onInteractOutside={
|
|
238
|
+
with_full_screen_portal
|
|
239
|
+
? e => e.preventDefault()
|
|
240
|
+
: undefined
|
|
241
|
+
}
|
|
242
|
+
onOpenAutoFocus={e => e.preventDefault()}
|
|
243
|
+
onCloseAutoFocus={e => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
// Only focus if focus is not already on the input
|
|
246
|
+
if (
|
|
247
|
+
document.activeElement !== inputRef.current
|
|
248
|
+
) {
|
|
249
|
+
inputRef.current?.focus();
|
|
270
250
|
}
|
|
271
251
|
}}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
252
|
+
>
|
|
253
|
+
{with_full_screen_portal && (
|
|
254
|
+
<button
|
|
255
|
+
className="dash-datepicker-close-button"
|
|
256
|
+
onClick={() => setIsCalendarOpen(false)}
|
|
257
|
+
aria-label="Close calendar"
|
|
258
|
+
>
|
|
259
|
+
<Cross1Icon />
|
|
260
|
+
</button>
|
|
261
|
+
)}
|
|
262
|
+
<Calendar
|
|
263
|
+
ref={calendarRef}
|
|
264
|
+
initialVisibleDate={initialMonth}
|
|
265
|
+
selectionStart={internalDate}
|
|
266
|
+
selectionEnd={internalDate}
|
|
267
|
+
minDateAllowed={minDate}
|
|
268
|
+
maxDateAllowed={maxDate}
|
|
269
|
+
disabledDates={disabledDates}
|
|
270
|
+
firstDayOfWeek={first_day_of_week}
|
|
271
|
+
showOutsideDays={show_outside_days}
|
|
272
|
+
monthFormat={month_format}
|
|
273
|
+
numberOfMonthsShown={number_of_months_shown}
|
|
274
|
+
calendarOrientation={calendar_orientation}
|
|
275
|
+
daySize={day_size}
|
|
276
|
+
direction={direction}
|
|
277
|
+
onSelectionChange={(_, selection) => {
|
|
278
|
+
if (!selection) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
setInternalDate(selection);
|
|
282
|
+
if (!stay_open_on_select) {
|
|
283
|
+
setIsCalendarOpen(false);
|
|
284
|
+
}
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
</Popover.Content>
|
|
288
|
+
</Popover.Portal>
|
|
289
|
+
</Popover.Root>
|
|
290
|
+
</div>
|
|
291
|
+
</ResizeDetector>
|
|
277
292
|
);
|
|
278
293
|
};
|
|
279
294
|
|