@juspay/svelte-ui-components 2.80.7 → 2.80.8

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.
@@ -154,6 +154,12 @@
154
154
  return n;
155
155
  }
156
156
 
157
+ function endOfDay(d: Date): Date {
158
+ const newDate = new SvelteDate(d);
159
+ newDate.setHours(23, 59, 59, 999);
160
+ return newDate;
161
+ }
162
+
157
163
  function isSameDay(a: Date, b: Date): boolean {
158
164
  return (
159
165
  a.getFullYear() === b.getFullYear() &&
@@ -206,6 +212,8 @@
206
212
  if (date.getTime() < normalizeDate(start).getTime()) {
207
213
  rangeEnd = start;
208
214
  rangeStart = date;
215
+ } else if (isSameDay(date, start)) {
216
+ rangeEnd = endOfDay(date);
209
217
  } else {
210
218
  rangeEnd = date;
211
219
  }
@@ -347,10 +347,10 @@
347
347
  if (draftStart !== null && draftEnd !== null) {
348
348
  // Fold the time-of-day inputs onto the committed dates when time selection is on.
349
349
  const appliedStart = showTimeSelection
350
- ? (applyTimeDisplay(draftStart, startTimeDisplay) ?? draftStart)
350
+ ? (applyTimeDisplay(draftStart, startTimeDisplay, 'start') ?? draftStart)
351
351
  : draftStart;
352
352
  const appliedEnd = showTimeSelection
353
- ? (applyTimeDisplay(draftEnd, endTimeDisplay) ?? draftEnd)
353
+ ? (applyTimeDisplay(draftEnd, endTimeDisplay, 'end') ?? draftEnd)
354
354
  : draftEnd;
355
355
  rangeStart = appliedStart;
356
356
  rangeEnd = appliedEnd;
@@ -16,6 +16,7 @@ export type DateRangePreset = {
16
16
  export type DateRangePickerMode = 'range' | 'single';
17
17
  export type DateRangePickerAlign = 'left' | 'right';
18
18
  export type DateRangePickerTimeLayout = 'toggle' | 'inline';
19
+ export type TimeDisplayBoundary = 'start' | 'end';
19
20
  export type OptionalDateRangePickerProperties = {
20
21
  /** Currently selected start of range (bindable). */
21
22
  rangeStart?: Date | null;
@@ -1,3 +1,4 @@
1
+ import type { TimeDisplayBoundary } from './properties';
1
2
  /** Matches a 12-hour clock display such as "2:30 PM" or "02:05 am". */
2
3
  export declare const TIME_DISPLAY_PATTERN: RegExp;
3
4
  /** Parse a 12-hour display string into 24-hour hours/minutes, or null when invalid. */
@@ -8,6 +9,6 @@ export declare const parseTimeDisplay: (display: string) => {
8
9
  /** Format a Date's time-of-day as a 12-hour display string, e.g. "02:30 PM". */
9
10
  export declare const formatTimeDisplay: (date: Date) => string;
10
11
  /** Return a new Date with the time-of-day from a 12-hour display string applied, or null when invalid. */
11
- export declare const applyTimeDisplay: (date: Date, display: string) => Date | null;
12
+ export declare const applyTimeDisplay: (date: Date, display: string, boundary: TimeDisplayBoundary) => Date | null;
12
13
  /** Minutes-since-midnight for ordering comparisons, or null when the display is invalid. */
13
14
  export declare const toMinutesOfDay: (display: string) => number | null;
@@ -1,4 +1,3 @@
1
- // Time-of-day helpers for the DateRangePicker's built-in date + time inputs.
2
1
  /** Matches a 12-hour clock display such as "2:30 PM" or "02:05 am". */
3
2
  export const TIME_DISPLAY_PATTERN = /^(1[0-2]|0?[1-9]):([0-5][0-9])\s?(AM|PM)$/i;
4
3
  const pad = (n) => n.toString().padStart(2, '0');
@@ -27,13 +26,18 @@ export const formatTimeDisplay = (date) => {
27
26
  return `${pad(hours12)}:${pad(date.getMinutes())} ${meridiem}`;
28
27
  };
29
28
  /** Return a new Date with the time-of-day from a 12-hour display string applied, or null when invalid. */
30
- export const applyTimeDisplay = (date, display) => {
29
+ export const applyTimeDisplay = (date, display, boundary) => {
31
30
  const parsed = parseTimeDisplay(display);
32
31
  if (parsed === null) {
33
32
  return null;
34
33
  }
35
34
  const next = new Date(date.getTime());
36
- next.setHours(parsed.hours, parsed.minutes, 0, 0);
35
+ if (boundary === 'end') {
36
+ next.setHours(parsed.hours, parsed.minutes, 59, 999);
37
+ }
38
+ else {
39
+ next.setHours(parsed.hours, parsed.minutes, 0, 0);
40
+ }
37
41
  return next;
38
42
  };
39
43
  /** Minutes-since-midnight for ordering comparisons, or null when the display is invalid. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.80.7",
3
+ "version": "2.80.8",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",