@juspay/svelte-ui-components 2.63.0 → 2.64.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.
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import Calendar from '../Calendar/Calendar.svelte';
|
|
6
6
|
import Button from '../Button/Button.svelte';
|
|
7
7
|
import chevronDownSvg from '../assets/chevron-down.svg?raw';
|
|
8
|
+
import checkmarkSvg from '../assets/checkmark.svg?raw';
|
|
8
9
|
|
|
9
10
|
let {
|
|
10
11
|
rangeStart = $bindable(null),
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
disabledDates = [],
|
|
17
18
|
maxRangeDays = null,
|
|
18
19
|
presets = null,
|
|
20
|
+
presetCheckmark = false,
|
|
19
21
|
placeholder = 'Select date',
|
|
20
22
|
dualMonth,
|
|
21
23
|
timePicker,
|
|
@@ -391,6 +393,14 @@
|
|
|
391
393
|
) {
|
|
392
394
|
return preset.label === activePresetLabel;
|
|
393
395
|
}
|
|
396
|
+
// A preset was explicitly chosen this session — match it by label, not by date.
|
|
397
|
+
// Several presets can share a calendar day (e.g. "Today", "Last 30 minutes" and
|
|
398
|
+
// "Last 12 hours" all start today), so same-day matching would light up all of
|
|
399
|
+
// them at once. selectedPresetLabel is cleared on a direct calendar click, so the
|
|
400
|
+
// date-based fallbacks below still drive highlighting for manual selections.
|
|
401
|
+
if (selectedPresetLabel !== null) {
|
|
402
|
+
return preset.label === selectedPresetLabel;
|
|
403
|
+
}
|
|
394
404
|
if (mode === 'single') {
|
|
395
405
|
if (draftValue === null) {
|
|
396
406
|
return false;
|
|
@@ -537,11 +547,16 @@
|
|
|
537
547
|
type="button"
|
|
538
548
|
class="drp-preset-item"
|
|
539
549
|
class:drp-preset-active={isPresetActive(preset)}
|
|
550
|
+
class:drp-preset-checkable={presetCheckmark}
|
|
540
551
|
role="option"
|
|
541
552
|
aria-selected={isPresetActive(preset)}
|
|
542
553
|
onclick={() => handlePreset(preset)}
|
|
543
554
|
>
|
|
544
555
|
{preset.label}
|
|
556
|
+
{#if presetCheckmark && isPresetActive(preset)}
|
|
557
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
558
|
+
<span class="drp-preset-check" aria-hidden="true">{@html checkmarkSvg}</span>
|
|
559
|
+
{/if}
|
|
545
560
|
</button>
|
|
546
561
|
{/each}
|
|
547
562
|
</div>
|
|
@@ -778,6 +793,29 @@
|
|
|
778
793
|
background: var(--drp-preset-active-hover-background, #333333);
|
|
779
794
|
}
|
|
780
795
|
|
|
796
|
+
/* Opt-in checkmark layout: reserve a trailing slot so the active preset's tick
|
|
797
|
+
sits flush-right while the label stays left. A preset with no tick (or a
|
|
798
|
+
label-only preset) keeps its single flex child at the start, unchanged. */
|
|
799
|
+
.drp-preset-checkable {
|
|
800
|
+
display: flex;
|
|
801
|
+
align-items: center;
|
|
802
|
+
justify-content: space-between;
|
|
803
|
+
gap: var(--drp-preset-check-gap, 8px);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
.drp-preset-check {
|
|
807
|
+
display: inline-flex;
|
|
808
|
+
flex-shrink: 0;
|
|
809
|
+
width: var(--drp-preset-check-size, 16px);
|
|
810
|
+
height: var(--drp-preset-check-size, 16px);
|
|
811
|
+
color: var(--drp-preset-check-color, inherit);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.drp-preset-check :global(svg) {
|
|
815
|
+
width: 100%;
|
|
816
|
+
height: 100%;
|
|
817
|
+
}
|
|
818
|
+
|
|
781
819
|
/* ── Calendar area ── */
|
|
782
820
|
.drp-calendars {
|
|
783
821
|
display: flex;
|
|
@@ -33,6 +33,12 @@ export type OptionalDateRangePickerProperties = {
|
|
|
33
33
|
maxRangeDays?: number | null;
|
|
34
34
|
/** Preset options shown in the sidebar. Omit to hide the sidebar. */
|
|
35
35
|
presets?: DateRangePreset[] | null;
|
|
36
|
+
/**
|
|
37
|
+
* Show a trailing checkmark on the active preset in the sidebar. Opt-in, so
|
|
38
|
+
* existing layouts are unchanged; the active preset is always distinguished by
|
|
39
|
+
* its highlighted background regardless of this flag. Default: false.
|
|
40
|
+
*/
|
|
41
|
+
presetCheckmark?: boolean;
|
|
36
42
|
/** Placeholder shown when no range is selected. */
|
|
37
43
|
placeholder?: string;
|
|
38
44
|
/** Show two months side by side. Defaults to true for range mode, false for single. */
|