@juspay/svelte-ui-components 2.64.0 → 2.65.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.
@@ -21,6 +21,7 @@
21
21
  placeholder = 'Select date',
22
22
  dualMonth,
23
23
  timePicker,
24
+ align = 'left',
24
25
  compareStart = $bindable(null),
25
26
  compareEnd = $bindable(null),
26
27
  compareCalendar,
@@ -112,6 +113,13 @@
112
113
 
113
114
  let activePresetLabel: string | null = $state(resolvedInitialPresetLabel);
114
115
 
116
+ // The preset whose range is currently committed (seeded from initialPresetLabel,
117
+ // updated on every Apply). Unlike activePresetLabel — which is cleared the moment
118
+ // the user interacts so the trigger can fall back to a date range — this survives
119
+ // the open/apply cycle so re-opening the picker re-highlights the committed preset
120
+ // by label instead of date-matching (which lights up every same-day preset at once).
121
+ let committedPresetLabel: string | null = $state(resolvedInitialPresetLabel);
122
+
115
123
  // Seed draft from initialPresetLabel whenever presets become available so
116
124
  // the calendar shows the preset's date selection when the picker is first
117
125
  // opened — even if presets arrive asynchronously after initial render.
@@ -194,8 +202,9 @@
194
202
  draftCompareStart = compareStart;
195
203
  draftCompareEnd = compareEnd;
196
204
 
197
- // Reset preset tracking so each picker session starts clean.
198
- selectedPresetLabel = null;
205
+ // Re-seed the session from the committed preset so the sidebar re-highlights it
206
+ // by label. A direct calendar click later clears this, reverting to date matching.
207
+ selectedPresetLabel = committedPresetLabel;
199
208
 
200
209
  // Navigate left calendar so it shows the committed start month (or today)
201
210
  const anchor = rangeStart !== null ? rangeStart : value !== null ? value : now;
@@ -266,6 +275,7 @@
266
275
  if (draftStart !== null && draftEnd !== null) {
267
276
  rangeStart = draftStart;
268
277
  rangeEnd = draftEnd;
278
+ committedPresetLabel = selectedPresetLabel;
269
279
  onapply?.({ rangeStart: draftStart, rangeEnd: draftEnd, presetLabel: selectedPresetLabel });
270
280
  }
271
281
  if (
@@ -284,6 +294,7 @@
284
294
  } else {
285
295
  if (draftValue !== null) {
286
296
  value = draftValue;
297
+ committedPresetLabel = selectedPresetLabel;
287
298
  onapplysingle?.({ date: draftValue, presetLabel: selectedPresetLabel });
288
299
  }
289
300
  }
@@ -293,6 +304,7 @@
293
304
  function handleClear(): void {
294
305
  value = null;
295
306
  draftValue = null;
307
+ committedPresetLabel = null;
296
308
  onclear?.();
297
309
  closePicker();
298
310
  }
@@ -524,6 +536,8 @@
524
536
  <div
525
537
  bind:this={panelRef}
526
538
  class="drp-panel"
539
+ class:drp-panel-align-left={align === 'left'}
540
+ class:drp-panel-align-right={align === 'right'}
527
541
  role="dialog"
528
542
  aria-label="Date range picker"
529
543
  aria-modal="true"
@@ -736,7 +750,6 @@
736
750
  .drp-panel {
737
751
  position: absolute;
738
752
  top: calc(100% + var(--drp-panel-offset, 6px));
739
- left: 0;
740
753
  z-index: var(--drp-panel-z-index, 1000);
741
754
  background: var(--drp-panel-background, inherit);
742
755
  border: var(--drp-panel-border, 1px solid #e0e0e0);
@@ -749,6 +762,16 @@
749
762
  overflow: hidden;
750
763
  }
751
764
 
765
+ .drp-panel-align-left {
766
+ left: 0;
767
+ right: auto;
768
+ }
769
+
770
+ .drp-panel-align-right {
771
+ right: 0;
772
+ left: auto;
773
+ }
774
+
752
775
  .drp-panel-inner {
753
776
  display: flex;
754
777
  flex-direction: row;
@@ -14,6 +14,7 @@ export type DateRangePreset = {
14
14
  group?: string;
15
15
  };
16
16
  export type DateRangePickerMode = 'range' | 'single';
17
+ export type DateRangePickerAlign = 'left' | 'right';
17
18
  export type OptionalDateRangePickerProperties = {
18
19
  /** Currently selected start of range (bindable). */
19
20
  rangeStart?: Date | null;
@@ -43,6 +44,8 @@ export type OptionalDateRangePickerProperties = {
43
44
  placeholder?: string;
44
45
  /** Show two months side by side. Defaults to true for range mode, false for single. */
45
46
  dualMonth?: boolean;
47
+ /** Align the dropdown panel to the left or right edge of the trigger. Default: 'left'. */
48
+ align?: DateRangePickerAlign;
46
49
  /** Snippet rendered in the time-picker slot. Consumer controls all time UI. */
47
50
  timePicker?: Snippet;
48
51
  /** Start of compare range (bindable). Used when compareCalendar snippet is provided. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.64.0",
3
+ "version": "2.65.0",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",