@juspay/svelte-ui-components 2.70.0 → 2.71.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.
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
presetCheckmark = false,
|
|
31
31
|
showDateInputs = false,
|
|
32
32
|
showTimeSelection = false,
|
|
33
|
+
presetToggle = false,
|
|
33
34
|
placeholder = 'Select date',
|
|
34
35
|
dualMonth,
|
|
35
36
|
timePicker,
|
|
@@ -388,6 +389,21 @@
|
|
|
388
389
|
}
|
|
389
390
|
|
|
390
391
|
function handlePreset(preset: DateRangePreset): void {
|
|
392
|
+
// presetToggle: clicking the already-selected preset deselects it and reverts the
|
|
393
|
+
// draft to the committed selection (mirrors openPicker). Lets a toggle-style preset
|
|
394
|
+
// such as "No Comparison" be switched back off without having to pick a calendar
|
|
395
|
+
// date, instead of being a one-way radio choice.
|
|
396
|
+
if (presetToggle && selectedPresetLabel === preset.label) {
|
|
397
|
+
draftStart = rangeStart;
|
|
398
|
+
draftEnd = rangeEnd;
|
|
399
|
+
draftValue = value;
|
|
400
|
+
selectedPresetLabel = committedPresetLabel;
|
|
401
|
+
const anchor = rangeStart !== null ? rangeStart : value !== null ? value : now;
|
|
402
|
+
leftYear = anchor.getFullYear();
|
|
403
|
+
leftMonth = anchor.getMonth();
|
|
404
|
+
calendarKey++;
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
391
407
|
// User explicitly picked a preset — clear the initial-preset display label
|
|
392
408
|
activePresetLabel = null;
|
|
393
409
|
const { start, end } = preset.getValue();
|
|
@@ -52,6 +52,13 @@ export type OptionalDateRangePickerProperties = {
|
|
|
52
52
|
* Opt-in. Default: false.
|
|
53
53
|
*/
|
|
54
54
|
showTimeSelection?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Make presets toggle instead of being one-way: clicking the already-selected
|
|
57
|
+
* preset deselects it and reverts the draft to the committed selection. Lets a
|
|
58
|
+
* toggle-style preset such as "No Comparison" be switched back off without having
|
|
59
|
+
* to pick a calendar date. Opt-in. Default: false.
|
|
60
|
+
*/
|
|
61
|
+
presetToggle?: boolean;
|
|
55
62
|
/** Placeholder shown when no range is selected. */
|
|
56
63
|
placeholder?: string;
|
|
57
64
|
/** Show two months side by side. Defaults to true for range mode, false for single. */
|