@eagami/ui 5.82.0 → 5.82.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.
@@ -14774,10 +14774,36 @@ function clampAlpha(value) {
14774
14774
  if (value.endsWith("%")) return clamp01(parseFloat(value) / 100);
14775
14775
  return clamp01(parseFloat(value));
14776
14776
  }
14777
+ let latestRequest = 0;
14778
+ function focusOnReveal(isOpen, popover, focus) {
14779
+ const pending = signal(0, ...ngDevMode ? [{ debugName: "pending" }] : /* istanbul ignore next */ []);
14780
+ let focusedAtRequest = null;
14781
+ afterRenderEffect(() => {
14782
+ const request = pending();
14783
+ if (request === 0) return;
14784
+ if (!isOpen() || request !== latestRequest) {
14785
+ pending.set(0);
14786
+ return;
14787
+ }
14788
+ if (!popover()?.isPositioned()) return;
14789
+ untracked(() => {
14790
+ pending.set(0);
14791
+ const active = document.activeElement;
14792
+ if (active === focusedAtRequest || active === null || active === document.body) focus();
14793
+ });
14794
+ });
14795
+ return () => {
14796
+ latestRequest += 1;
14797
+ focusedAtRequest = typeof document === "undefined" ? null : document.activeElement;
14798
+ pending.set(latestRequest);
14799
+ };
14800
+ }
14777
14801
  var MenuComponent = class MenuComponent {
14778
14802
  injector = inject(Injector);
14779
14803
  i18n = inject(EagamiI18nService);
14780
14804
  listEl = viewChild("listEl", ...ngDevMode ? [{ debugName: "listEl" }] : /* istanbul ignore next */ []);
14805
+ popover = viewChild(PopoverComponent, ...ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []);
14806
+ focusFirstItemOnReveal = focusOnReveal(() => this.open(), () => this.popover(), () => this.focusFirstItem());
14781
14807
  placement = input("bottom-start", ...ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []);
14782
14808
  size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
14783
14809
  maxHeight = input("20rem", ...ngDevMode ? [{ debugName: "maxHeight" }] : /* istanbul ignore next */ []);
@@ -14836,7 +14862,7 @@ var MenuComponent = class MenuComponent {
14836
14862
  this.triggerEl.set(triggerEl);
14837
14863
  this.open.set(true);
14838
14864
  this.opened.emit();
14839
- afterNextRender(() => this.focusFirstItem(), { injector: this.injector });
14865
+ this.focusFirstItemOnReveal();
14840
14866
  }
14841
14867
  close(restoreFocus = false) {
14842
14868
  if (!this.open()) return;
@@ -14974,6 +15000,12 @@ var MenuComponent = class MenuComponent {
14974
15000
  predicate: ["listEl"],
14975
15001
  descendants: true,
14976
15002
  isSignal: true
15003
+ }, {
15004
+ propertyName: "popover",
15005
+ first: true,
15006
+ predicate: PopoverComponent,
15007
+ descendants: true,
15008
+ isSignal: true
14977
15009
  }],
14978
15010
  ngImport: i0,
14979
15011
  template: "<ea-popover\n [anchor]=\"triggerEl()\"\n [open]=\"open()\"\n [placement]=\"placement()\"\n [anchorPoint]=\"anchorPoint()\"\n [contextMenu]=\"asContextMenu()\"\n role=\"menu\"\n [surfaceId]=\"id()\"\n [aria-label]=\"resolvedAriaLabel()\"\n [closeOnEscape]=\"false\"\n scrollBehavior=\"reposition\"\n (closeRequested)=\"onPopoverCloseRequested()\">\n <div\n #listEl\n class=\"ea-menu__list ea-menu__list--{{ size() }}\"\n [style.max-height]=\"maxHeight()\">\n <ng-content />\n </div>\n</ea-popover>\n",
@@ -15028,6 +15060,10 @@ i0.ɵɵngDeclareClassMetadata({
15028
15060
  type: i0.ViewChild,
15029
15061
  args: ["listEl", { isSignal: true }]
15030
15062
  }],
15063
+ popover: [{
15064
+ type: i0.ViewChild,
15065
+ args: [i0.forwardRef(() => PopoverComponent), { isSignal: true }]
15066
+ }],
15031
15067
  placement: [{
15032
15068
  type: i0.Input,
15033
15069
  args: [{
@@ -16958,6 +16994,8 @@ function build(year, month, day) {
16958
16994
  var DatePickerComponent = class DatePickerComponent extends LabelledFieldControlBase {
16959
16995
  fieldEl = viewChild("fieldEl", ...ngDevMode ? [{ debugName: "fieldEl" }] : /* istanbul ignore next */ []);
16960
16996
  inputEl = viewChild("inputEl", ...ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []);
16997
+ popover = viewChild(PopoverComponent, ...ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []);
16998
+ focusDayCellOnReveal = focusOnReveal(() => this.isOpen(), () => this.popover(), () => this.focusFocusedDayCell());
16961
16999
  injector = inject(Injector);
16962
17000
  i18n = inject(EagamiI18nService);
16963
17001
  placeholder = input(void 0, ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
@@ -17110,7 +17148,7 @@ var DatePickerComponent = class DatePickerComponent extends LabelledFieldControl
17110
17148
  this.viewMonth.set(current.getMonth());
17111
17149
  this.focusedDate.set(this.startOfDay(current));
17112
17150
  this.isOpen.set(true);
17113
- afterNextRender(() => this.focusFocusedDayCell(), { injector: this.injector });
17151
+ this.focusDayCellOnReveal();
17114
17152
  }
17115
17153
  close() {
17116
17154
  this.isOpen.set(false);
@@ -17462,19 +17500,29 @@ var DatePickerComponent = class DatePickerComponent extends LabelledFieldControl
17462
17500
  useExisting: forwardRef(() => DatePickerComponent),
17463
17501
  multi: true
17464
17502
  }],
17465
- viewQueries: [{
17466
- propertyName: "fieldEl",
17467
- first: true,
17468
- predicate: ["fieldEl"],
17469
- descendants: true,
17470
- isSignal: true
17471
- }, {
17472
- propertyName: "inputEl",
17473
- first: true,
17474
- predicate: ["inputEl"],
17475
- descendants: true,
17476
- isSignal: true
17477
- }],
17503
+ viewQueries: [
17504
+ {
17505
+ propertyName: "fieldEl",
17506
+ first: true,
17507
+ predicate: ["fieldEl"],
17508
+ descendants: true,
17509
+ isSignal: true
17510
+ },
17511
+ {
17512
+ propertyName: "inputEl",
17513
+ first: true,
17514
+ predicate: ["inputEl"],
17515
+ descendants: true,
17516
+ isSignal: true
17517
+ },
17518
+ {
17519
+ propertyName: "popover",
17520
+ first: true,
17521
+ predicate: PopoverComponent,
17522
+ descendants: true,
17523
+ isSignal: true
17524
+ }
17525
+ ],
17478
17526
  usesInheritance: true,
17479
17527
  ngImport: i0,
17480
17528
  template: "<div class=\"ea-date-picker-field ea-date-picker-field--{{ size() }}\">\n @if (label(); as labelText) {\n <ea-field-label\n [text]=\"labelText\"\n [icon]=\"labelIcon()\"\n [help]=\"labelHelp()\"\n [forId]=\"id()\"\n [labelId]=\"id() + '-label'\"\n [required]=\"required()\"\n [optional]=\"optional()\" />\n }\n\n <div class=\"ea-date-picker\">\n <div\n #fieldEl\n class=\"ea-date-picker__field\"\n [ngClass]=\"fieldClasses()\">\n <button\n type=\"button\"\n class=\"ea-date-picker__calendar-button\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"i18n.messages().datePicker.dialogLabel\"\n [attr.aria-haspopup]=\"'dialog'\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-controls]=\"isOpen() ? dialogId() : null\"\n (click)=\"toggle()\">\n <ea-icon-calendar aria-hidden=\"true\" />\n </button>\n <input\n #inputEl\n type=\"text\"\n dir=\"auto\"\n autocomplete=\"off\"\n class=\"ea-date-picker__input\"\n [id]=\"id()\"\n [value]=\"inputText()\"\n [placeholder]=\"resolvedPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [attr.aria-label]=\"label() || ariaLabelledby() ? null : fallbackLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledby() || null\"\n [attr.aria-required]=\"required() || null\"\n [attr.aria-invalid]=\"hasError() || null\"\n [attr.aria-describedby]=\"\n showError() ? id() + '-error' : showHint() ? id() + '-hint' : null\n \"\n (input)=\"onInput($event)\"\n (keydown)=\"handleInputKeydown($event)\"\n (focus)=\"onInputFocus()\"\n (blur)=\"onInputBlur()\" />\n @if (value() && !isDisabled() && !readonly()) {\n <button\n type=\"button\"\n class=\"ea-date-picker__clear\"\n [attr.aria-label]=\"i18n.messages().datePicker.clear\"\n (click)=\"clear($event)\">\n <ea-icon-x\n class=\"ea-date-picker__clear-icon\"\n aria-hidden=\"true\" />\n </button>\n }\n </div>\n\n <ea-popover\n [anchor]=\"fieldEl\"\n [open]=\"isOpen()\"\n placement=\"bottom-start\"\n role=\"dialog\"\n [surfaceId]=\"dialogId()\"\n [aria-label]=\"i18n.messages().datePicker.dialogLabel\"\n [trapFocus]=\"true\"\n [closeOnEscape]=\"false\"\n scrollBehavior=\"close\"\n (closeRequested)=\"onPopoverCloseRequested()\">\n <div\n class=\"ea-date-picker__popover\"\n [ngClass]=\"popoverClasses()\"\n (keydown)=\"handleGridKeydown($event)\">\n <div class=\"ea-date-picker__header\">\n <button\n type=\"button\"\n class=\"ea-date-picker__nav-btn\"\n [attr.aria-label]=\"i18n.messages().datePicker.previousYear\"\n (click)=\"goToPrevYear()\">\n <ea-icon-chevron-left\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n <ea-icon-chevron-left\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n </button>\n <button\n type=\"button\"\n class=\"ea-date-picker__nav-btn\"\n [attr.aria-label]=\"i18n.messages().datePicker.previousMonth\"\n (click)=\"goToPrevMonth()\">\n <ea-icon-chevron-left\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n </button>\n <span\n class=\"ea-date-picker__month-label\"\n aria-live=\"polite\">\n {{ monthYearLabel() }}\n </span>\n <button\n type=\"button\"\n class=\"ea-date-picker__nav-btn\"\n [attr.aria-label]=\"i18n.messages().datePicker.nextMonth\"\n (click)=\"goToNextMonth()\">\n <ea-icon-chevron-right\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n </button>\n <button\n type=\"button\"\n class=\"ea-date-picker__nav-btn\"\n [attr.aria-label]=\"i18n.messages().datePicker.nextYear\"\n (click)=\"goToNextYear()\">\n <ea-icon-chevron-right\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n <ea-icon-chevron-right\n class=\"ea-rtl-flip\"\n aria-hidden=\"true\" />\n </button>\n </div>\n\n <div\n class=\"ea-date-picker__grid\"\n role=\"grid\">\n <div\n class=\"ea-date-picker__weekday-row\"\n role=\"row\">\n @for (label of weekdayLabels(); track label) {\n <div\n class=\"ea-date-picker__weekday\"\n role=\"columnheader\">\n {{ label }}\n </div>\n }\n </div>\n @for (week of weeks(); track $index) {\n <div\n class=\"ea-date-picker__week\"\n role=\"row\">\n @for (day of week; track day.date.getTime()) {\n <div\n class=\"ea-date-picker__cell\"\n role=\"gridcell\"\n [attr.aria-selected]=\"day.isSelected\">\n <button\n type=\"button\"\n class=\"ea-date-picker__day\"\n [class.ea-date-picker__day--outside]=\"!day.isCurrentMonth\"\n [class.ea-date-picker__day--today]=\"day.isToday\"\n [class.ea-date-picker__day--selected]=\"day.isSelected\"\n [class.ea-date-picker__day--focused]=\"day.isFocused\"\n [class.ea-date-picker__day--disabled]=\"day.isDisabled\"\n [attr.aria-disabled]=\"day.isDisabled || null\"\n [attr.aria-current]=\"day.isToday ? 'date' : null\"\n [attr.tabindex]=\"day.isFocused ? 0 : -1\"\n (click)=\"selectDay(day)\">\n {{ day.day }}\n </button>\n </div>\n }\n </div>\n }\n </div>\n\n <div class=\"ea-date-picker__footer\">\n <button\n type=\"button\"\n class=\"ea-date-picker__today-btn\"\n (click)=\"goToToday()\">\n {{ i18n.messages().datePicker.today }}\n </button>\n </div>\n </div>\n </ea-popover>\n </div>\n\n <ea-field-messages\n [id]=\"id()\"\n [error]=\"errorText()\"\n [hint]=\"showHint() ? hint() : null\" />\n</div>\n",
@@ -17599,6 +17647,10 @@ i0.ɵɵngDeclareClassMetadata({
17599
17647
  type: i0.ViewChild,
17600
17648
  args: ["inputEl", { isSignal: true }]
17601
17649
  }],
17650
+ popover: [{
17651
+ type: i0.ViewChild,
17652
+ args: [i0.forwardRef(() => PopoverComponent), { isSignal: true }]
17653
+ }],
17602
17654
  placeholder: [{
17603
17655
  type: i0.Input,
17604
17656
  args: [{
@@ -23650,7 +23702,10 @@ var MultiSelectComponent = class MultiSelectComponent extends LabelledFieldContr
23650
23702
  event.preventDefault();
23651
23703
  this.close();
23652
23704
  this.triggerEl()?.nativeElement.focus();
23653
- } else if (event.key === "Tab") this.close();
23705
+ } else if (event.key === "Tab") {
23706
+ this.triggerEl()?.nativeElement.focus();
23707
+ this.close();
23708
+ }
23654
23709
  }
23655
23710
  moveFocusedRow(row) {
23656
23711
  this.focusedIndex.set(row);
@@ -29340,6 +29395,12 @@ var TabsComponent = class TabsComponent {
29340
29395
  orientation = input("horizontal", ...ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []);
29341
29396
  ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
29342
29397
  activeTab = model("", ...ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []);
29398
+ selectedTab = computed(() => {
29399
+ const tabs = this.registeredTabs();
29400
+ const active = this.activeTab();
29401
+ if (tabs.some((t) => t.value() === active)) return active;
29402
+ return tabs.find((t) => !t.disabled())?.value();
29403
+ }, ...ngDevMode ? [{ debugName: "selectedTab" }] : /* istanbul ignore next */ []);
29343
29404
  changed = output();
29344
29405
  registerTab(tab) {
29345
29406
  this.registeredTabs.update((tabs) => [...tabs, tab]);
@@ -29353,7 +29414,7 @@ var TabsComponent = class TabsComponent {
29353
29414
  }
29354
29415
  handleKeydown(event) {
29355
29416
  const tabList = this.registeredTabs().filter((t) => !t.disabled());
29356
- const currentIndex = tabList.findIndex((t) => t.value() === this.activeTab());
29417
+ const currentIndex = tabList.findIndex((t) => t.value() === this.selectedTab());
29357
29418
  let forwardKey = "ArrowDown";
29358
29419
  let backwardKey = "ArrowUp";
29359
29420
  if (this.orientation() === "horizontal") {
@@ -29512,7 +29573,7 @@ var TabComponent = class TabComponent {
29512
29573
  label = input.required(...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
29513
29574
  disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
29514
29575
  id = input(uniqueId("ea-tab"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
29515
- isActive = computed(() => this.tabs.activeTab() === this.value(), ...ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []);
29576
+ isActive = computed(() => this.tabs.selectedTab() === this.value(), ...ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []);
29516
29577
  vertical = computed(() => this.tabs.orientation() === "vertical", ...ngDevMode ? [{ debugName: "vertical" }] : /* istanbul ignore next */ []);
29517
29578
  ngOnInit() {
29518
29579
  this.tabs.registerTab(this);
@@ -30279,7 +30340,12 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30279
30340
  secondsEl = viewChild("secondsEl", ...ngDevMode ? [{ debugName: "secondsEl" }] : /* istanbul ignore next */ []);
30280
30341
  i18n = inject(EagamiI18nService);
30281
30342
  destroyRef = inject(DestroyRef);
30282
- injector = inject(Injector);
30343
+ popover = viewChild(PopoverComponent, ...ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []);
30344
+ focusHoursOnReveal = focusOnReveal(() => this.isOpen(), () => this.popover(), () => {
30345
+ const el = this.hoursEl()?.nativeElement;
30346
+ el?.focus();
30347
+ el?.select();
30348
+ });
30283
30349
  placeholder = input(void 0, ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
30284
30350
  size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
30285
30351
  disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
@@ -30383,13 +30449,6 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30383
30449
  if (this.isDisabled() || this.readonly() || this.isOpen()) return;
30384
30450
  this.isOpen.set(true);
30385
30451
  }
30386
- focusHoursWhenReady() {
30387
- afterNextRender(() => {
30388
- const el = this.hoursEl()?.nativeElement;
30389
- el?.focus();
30390
- el?.select();
30391
- }, { injector: this.injector });
30392
- }
30393
30452
  close() {
30394
30453
  this.isOpen.set(false);
30395
30454
  }
@@ -30410,7 +30469,7 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30410
30469
  if (event.key === "ArrowDown") {
30411
30470
  event.preventDefault();
30412
30471
  if (!this.isOpen()) this.isOpen.set(true);
30413
- this.focusHoursWhenReady();
30472
+ this.focusHoursOnReveal();
30414
30473
  } else if (event.key === "Enter") {
30415
30474
  event.preventDefault();
30416
30475
  this.commitTyped();
@@ -30759,6 +30818,13 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30759
30818
  predicate: ["secondsEl"],
30760
30819
  descendants: true,
30761
30820
  isSignal: true
30821
+ },
30822
+ {
30823
+ propertyName: "popover",
30824
+ first: true,
30825
+ predicate: PopoverComponent,
30826
+ descendants: true,
30827
+ isSignal: true
30762
30828
  }
30763
30829
  ],
30764
30830
  usesInheritance: true,
@@ -30897,6 +30963,10 @@ i0.ɵɵngDeclareClassMetadata({
30897
30963
  type: i0.ViewChild,
30898
30964
  args: ["secondsEl", { isSignal: true }]
30899
30965
  }],
30966
+ popover: [{
30967
+ type: i0.ViewChild,
30968
+ args: [i0.forwardRef(() => PopoverComponent), { isSignal: true }]
30969
+ }],
30900
30970
  placeholder: [{
30901
30971
  type: i0.Input,
30902
30972
  args: [{