@bsginstitute/bsg-integra 0.0.2 → 0.0.3

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.
Binary file
@@ -6538,7 +6538,7 @@ const switchThumbVariants = cva(clsx(
6538
6538
  false: 'translate-x-0',
6539
6539
  },
6540
6540
  size: {
6541
- sm: 'size-3 data-[checked=true]:translate-x-3',
6541
+ sm: 'size-3 data-[checked=true]:translate-x-5',
6542
6542
  default: 'size-4 data-[checked=true]:translate-x-4',
6543
6543
  lg: 'size-5 data-[checked=true]:translate-x-5',
6544
6544
  },
@@ -7263,6 +7263,35 @@ class TimePickerComponent {
7263
7263
  this.selectedHour.set(hour);
7264
7264
  this.selectedMinute.set(Math.min(snappedMinute, 59));
7265
7265
  this.updateTimeValue();
7266
+ // Scroll to show selected values
7267
+ this.scrollToSelected();
7268
+ }
7269
+ /** Scroll both lists to show the selected values centered */
7270
+ scrollToSelected() {
7271
+ // Use setTimeout to allow Angular to render the changes first
7272
+ setTimeout(() => {
7273
+ this.scrollToElement(this.hoursList, this.selectedHour());
7274
+ this.scrollToElement(this.minutesList, this.selectedMinute());
7275
+ }, 0);
7276
+ }
7277
+ /** Scroll a list to center the element with the given value */
7278
+ scrollToElement(listRef, value) {
7279
+ if (!listRef?.nativeElement)
7280
+ return;
7281
+ const listElement = listRef.nativeElement;
7282
+ const optionElement = listElement.querySelector(`[data-value="${value}"]`);
7283
+ if (optionElement) {
7284
+ // Calculate scroll position to center the element
7285
+ const listHeight = listElement.clientHeight;
7286
+ const optionTop = optionElement.offsetTop;
7287
+ const optionHeight = optionElement.offsetHeight;
7288
+ // Scroll to center the option in the list
7289
+ const scrollTop = optionTop - listHeight / 2 + optionHeight / 2;
7290
+ listElement.scrollTo({
7291
+ top: Math.max(0, scrollTop),
7292
+ behavior: 'smooth',
7293
+ });
7294
+ }
7266
7295
  }
7267
7296
  clearTime() {
7268
7297
  if (this.state() === 'disabled')
@@ -7285,8 +7314,13 @@ class TimePickerComponent {
7285
7314
  toggleDropdown() {
7286
7315
  if (this.state() === 'disabled')
7287
7316
  return;
7317
+ const wasOpen = this.isOpen();
7288
7318
  this.isOpen.update((v) => !v);
7289
7319
  this.openChange.emit(this.isOpen());
7320
+ // Scroll to selected values when opening
7321
+ if (!wasOpen && this.internalValue()) {
7322
+ this.scrollToSelected();
7323
+ }
7290
7324
  }
7291
7325
  openDropdown() {
7292
7326
  if (this.state() === 'disabled')
@@ -7294,6 +7328,10 @@ class TimePickerComponent {
7294
7328
  if (!this.isOpen()) {
7295
7329
  this.isOpen.set(true);
7296
7330
  this.openChange.emit(true);
7331
+ // Scroll to selected values when opening
7332
+ if (this.internalValue()) {
7333
+ this.scrollToSelected();
7334
+ }
7297
7335
  }
7298
7336
  }
7299
7337
  closeDropdown() {