@juspay/svelte-ui-components 2.73.0 → 2.73.2

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
+ timeSelectionLayout = 'toggle',
33
34
  presetToggle = false,
34
35
  placeholder = 'Select date',
35
36
  dualMonth,
@@ -79,6 +80,14 @@
79
80
  let endTimeDisplay: string = $state('11:59 PM');
80
81
  let showTimeRow: boolean = $state(false);
81
82
 
83
+ // Inline time layout (timeSelectionLayout="inline"): the start/end time inputs
84
+ // render beside their date inputs on the same row, always visible — no clock
85
+ // toggle and no collapsible row. All seeding/validation/fold logic is shared
86
+ // with the default toggle layout (it keys off showTimeSelection, not the layout).
87
+ const isInlineTime: boolean = $derived(
88
+ showTimeSelection && timeSelectionLayout === 'inline' && mode === 'range'
89
+ );
90
+
82
91
  const MS_PER_DAY = 24 * 60 * 60 * 1000;
83
92
 
84
93
  function isBaseDisabledDate(date: Date): boolean {
@@ -411,6 +420,15 @@
411
420
  if (mode === 'range') {
412
421
  draftStart = start;
413
422
  draftEnd = end;
423
+ // Reseed the time-of-day inputs from the preset's own start/end so a
424
+ // time-bearing preset (e.g. "Last 30 minutes" / "Last 12 Hours") is not
425
+ // silently overwritten by a stale display string in handleApply's
426
+ // applyTimeDisplay. Without this, the committed range snaps back to the
427
+ // previous display time (often 12:00 AM) instead of the preset's window.
428
+ if (showTimeSelection) {
429
+ startTimeDisplay = formatTimeDisplay(start);
430
+ endTimeDisplay = formatTimeDisplay(end);
431
+ }
414
432
  // Navigate left calendar to show the preset's start month
415
433
  leftYear = start.getFullYear();
416
434
  leftMonth = start.getMonth();
@@ -668,32 +686,82 @@
668
686
  <!-- Calendar area -->
669
687
  <div class="drp-calendars">
670
688
  {#if (showDateInputs || showTimeSelection) && mode === 'range'}
671
- <div class="drp-datetime-header">
689
+ <div class="drp-datetime-header" class:drp-datetime-header-inline={isInlineTime}>
672
690
  <div class="drp-date-input-row">
673
- <div class="drp-date-input" data-pw={testId ? `${testId}-start-date` : null}>
674
- <span class="drp-date-input-value">{draftStartDateLabel || 'Start date'}</span>
675
- </div>
676
- <!-- eslint-disable-next-line svelte/no-at-html-tags -->
677
- <span class="drp-datetime-arrow" aria-hidden="true">{@html chevronRightSvg}</span>
678
- <div class="drp-date-input" data-pw={testId ? `${testId}-end-date` : null}>
679
- <span class="drp-date-input-value">{draftEndDateLabel || 'End date'}</span>
680
- </div>
681
- {#if showTimeSelection}
682
- <button
683
- type="button"
684
- class="drp-time-toggle"
685
- class:drp-time-toggle-active={showTimeRow}
686
- aria-label="Toggle time selection"
687
- aria-pressed={showTimeRow}
688
- data-pw={testId ? `${testId}-time-toggle` : null}
689
- onclick={() => (showTimeRow = !showTimeRow)}
690
- >
691
- <!-- eslint-disable-next-line svelte/no-at-html-tags -->
692
- <span class="drp-time-toggle-icon" aria-hidden="true">{@html clockSvg}</span>
693
- </button>
691
+ {#if isInlineTime}
692
+ <div class="drp-date-time-group">
693
+ <div class="drp-date-input" data-pw={testId ? `${testId}-start-date` : null}>
694
+ <span class="drp-date-input-value">{draftStartDateLabel || 'Start date'}</span
695
+ >
696
+ </div>
697
+ <div
698
+ class="drp-time-input drp-time-input-inline"
699
+ class:drp-time-input-invalid={!isStartTimeValid}
700
+ >
701
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
702
+ <span class="drp-time-input-icon" aria-hidden="true">{@html clockSvg}</span>
703
+ <input
704
+ type="text"
705
+ class="drp-time-field"
706
+ bind:value={startTimeDisplay}
707
+ maxlength="8"
708
+ placeholder="12:00 AM"
709
+ aria-label="Start time"
710
+ aria-invalid={!isStartTimeValid}
711
+ data-pw={testId ? `${testId}-start-time` : null}
712
+ />
713
+ </div>
714
+ </div>
715
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
716
+ <span class="drp-datetime-arrow" aria-hidden="true">{@html chevronRightSvg}</span>
717
+ <div class="drp-date-time-group">
718
+ <div class="drp-date-input" data-pw={testId ? `${testId}-end-date` : null}>
719
+ <span class="drp-date-input-value">{draftEndDateLabel || 'End date'}</span>
720
+ </div>
721
+ <div
722
+ class="drp-time-input drp-time-input-inline"
723
+ class:drp-time-input-invalid={!isEndTimeValid}
724
+ >
725
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
726
+ <span class="drp-time-input-icon" aria-hidden="true">{@html clockSvg}</span>
727
+ <input
728
+ type="text"
729
+ class="drp-time-field"
730
+ bind:value={endTimeDisplay}
731
+ maxlength="8"
732
+ placeholder="11:59 PM"
733
+ aria-label="End time"
734
+ aria-invalid={!isEndTimeValid}
735
+ data-pw={testId ? `${testId}-end-time` : null}
736
+ />
737
+ </div>
738
+ </div>
739
+ {:else}
740
+ <div class="drp-date-input" data-pw={testId ? `${testId}-start-date` : null}>
741
+ <span class="drp-date-input-value">{draftStartDateLabel || 'Start date'}</span>
742
+ </div>
743
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
744
+ <span class="drp-datetime-arrow" aria-hidden="true">{@html chevronRightSvg}</span>
745
+ <div class="drp-date-input" data-pw={testId ? `${testId}-end-date` : null}>
746
+ <span class="drp-date-input-value">{draftEndDateLabel || 'End date'}</span>
747
+ </div>
748
+ {#if showTimeSelection}
749
+ <button
750
+ type="button"
751
+ class="drp-time-toggle"
752
+ class:drp-time-toggle-active={showTimeRow}
753
+ aria-label="Toggle time selection"
754
+ aria-pressed={showTimeRow}
755
+ data-pw={testId ? `${testId}-time-toggle` : null}
756
+ onclick={() => (showTimeRow = !showTimeRow)}
757
+ >
758
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
759
+ <span class="drp-time-toggle-icon" aria-hidden="true">{@html clockSvg}</span>
760
+ </button>
761
+ {/if}
694
762
  {/if}
695
763
  </div>
696
- {#if showTimeSelection && showTimeRow}
764
+ {#if showTimeSelection && !isInlineTime && showTimeRow}
697
765
  <div class="drp-time-input-row">
698
766
  <div class="drp-time-input" class:drp-time-input-invalid={!isStartTimeValid}>
699
767
  <!-- eslint-disable-next-line svelte/no-at-html-tags -->
@@ -1207,6 +1275,25 @@
1207
1275
  color: var(--drp-time-field-placeholder-color, #aaaaaa);
1208
1276
  }
1209
1277
 
1278
+ /* ── Inline time layout (timeSelectionLayout="inline") ── */
1279
+ /* Each date input is paired with its time input on the same row: the date box
1280
+ flexes to fill, the time input takes a fixed compact width beside it. */
1281
+ .drp-date-time-group {
1282
+ display: flex;
1283
+ align-items: center;
1284
+ flex: 1;
1285
+ min-width: 0;
1286
+ gap: var(--drp-datetime-inline-gap, 8px);
1287
+ }
1288
+
1289
+ .drp-date-time-group .drp-date-input {
1290
+ flex: 1;
1291
+ }
1292
+
1293
+ .drp-time-input.drp-time-input-inline {
1294
+ flex: 0 0 var(--drp-time-inline-width, 116px);
1295
+ }
1296
+
1210
1297
  /* ── Compare calendar slot ── */
1211
1298
  .drp-compare-section {
1212
1299
  display: flex;
@@ -15,6 +15,7 @@ export type DateRangePreset = {
15
15
  };
16
16
  export type DateRangePickerMode = 'range' | 'single';
17
17
  export type DateRangePickerAlign = 'left' | 'right';
18
+ export type DateRangePickerTimeLayout = 'toggle' | 'inline';
18
19
  export type OptionalDateRangePickerProperties = {
19
20
  /** Currently selected start of range (bindable). */
20
21
  rangeStart?: Date | null;
@@ -52,6 +53,14 @@ export type OptionalDateRangePickerProperties = {
52
53
  * Opt-in. Default: false.
53
54
  */
54
55
  showTimeSelection?: boolean;
56
+ /**
57
+ * How the time-of-day inputs are presented when showTimeSelection is on (range mode):
58
+ * 'toggle' (default) shows a clock button that reveals a collapsible start/end time
59
+ * row below the dates; 'inline' renders each time input beside its date input on the
60
+ * same row, always visible, with no toggle. Has no effect unless showTimeSelection is
61
+ * true. Default: 'toggle'.
62
+ */
63
+ timeSelectionLayout?: DateRangePickerTimeLayout;
55
64
  /**
56
65
  * Make presets toggle instead of being one-way: clicking the already-selected
57
66
  * preset deselects it and reverts the draft to the committed selection. Lets a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.73.0",
3
+ "version": "2.73.2",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",