@juspay/svelte-ui-components 2.64.0 → 2.64.1
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.
|
@@ -112,6 +112,13 @@
|
|
|
112
112
|
|
|
113
113
|
let activePresetLabel: string | null = $state(resolvedInitialPresetLabel);
|
|
114
114
|
|
|
115
|
+
// The preset whose range is currently committed (seeded from initialPresetLabel,
|
|
116
|
+
// updated on every Apply). Unlike activePresetLabel — which is cleared the moment
|
|
117
|
+
// the user interacts so the trigger can fall back to a date range — this survives
|
|
118
|
+
// the open/apply cycle so re-opening the picker re-highlights the committed preset
|
|
119
|
+
// by label instead of date-matching (which lights up every same-day preset at once).
|
|
120
|
+
let committedPresetLabel: string | null = $state(resolvedInitialPresetLabel);
|
|
121
|
+
|
|
115
122
|
// Seed draft from initialPresetLabel whenever presets become available so
|
|
116
123
|
// the calendar shows the preset's date selection when the picker is first
|
|
117
124
|
// opened — even if presets arrive asynchronously after initial render.
|
|
@@ -194,8 +201,9 @@
|
|
|
194
201
|
draftCompareStart = compareStart;
|
|
195
202
|
draftCompareEnd = compareEnd;
|
|
196
203
|
|
|
197
|
-
//
|
|
198
|
-
|
|
204
|
+
// Re-seed the session from the committed preset so the sidebar re-highlights it
|
|
205
|
+
// by label. A direct calendar click later clears this, reverting to date matching.
|
|
206
|
+
selectedPresetLabel = committedPresetLabel;
|
|
199
207
|
|
|
200
208
|
// Navigate left calendar so it shows the committed start month (or today)
|
|
201
209
|
const anchor = rangeStart !== null ? rangeStart : value !== null ? value : now;
|
|
@@ -266,6 +274,7 @@
|
|
|
266
274
|
if (draftStart !== null && draftEnd !== null) {
|
|
267
275
|
rangeStart = draftStart;
|
|
268
276
|
rangeEnd = draftEnd;
|
|
277
|
+
committedPresetLabel = selectedPresetLabel;
|
|
269
278
|
onapply?.({ rangeStart: draftStart, rangeEnd: draftEnd, presetLabel: selectedPresetLabel });
|
|
270
279
|
}
|
|
271
280
|
if (
|
|
@@ -284,6 +293,7 @@
|
|
|
284
293
|
} else {
|
|
285
294
|
if (draftValue !== null) {
|
|
286
295
|
value = draftValue;
|
|
296
|
+
committedPresetLabel = selectedPresetLabel;
|
|
287
297
|
onapplysingle?.({ date: draftValue, presetLabel: selectedPresetLabel });
|
|
288
298
|
}
|
|
289
299
|
}
|
|
@@ -293,6 +303,7 @@
|
|
|
293
303
|
function handleClear(): void {
|
|
294
304
|
value = null;
|
|
295
305
|
draftValue = null;
|
|
306
|
+
committedPresetLabel = null;
|
|
296
307
|
onclear?.();
|
|
297
308
|
closePicker();
|
|
298
309
|
}
|