@eagami/ui 5.82.0 → 5.82.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.
@@ -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: [{
@@ -30279,7 +30331,12 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30279
30331
  secondsEl = viewChild("secondsEl", ...ngDevMode ? [{ debugName: "secondsEl" }] : /* istanbul ignore next */ []);
30280
30332
  i18n = inject(EagamiI18nService);
30281
30333
  destroyRef = inject(DestroyRef);
30282
- injector = inject(Injector);
30334
+ popover = viewChild(PopoverComponent, ...ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []);
30335
+ focusHoursOnReveal = focusOnReveal(() => this.isOpen(), () => this.popover(), () => {
30336
+ const el = this.hoursEl()?.nativeElement;
30337
+ el?.focus();
30338
+ el?.select();
30339
+ });
30283
30340
  placeholder = input(void 0, ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
30284
30341
  size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
30285
30342
  disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
@@ -30383,13 +30440,6 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30383
30440
  if (this.isDisabled() || this.readonly() || this.isOpen()) return;
30384
30441
  this.isOpen.set(true);
30385
30442
  }
30386
- focusHoursWhenReady() {
30387
- afterNextRender(() => {
30388
- const el = this.hoursEl()?.nativeElement;
30389
- el?.focus();
30390
- el?.select();
30391
- }, { injector: this.injector });
30392
- }
30393
30443
  close() {
30394
30444
  this.isOpen.set(false);
30395
30445
  }
@@ -30410,7 +30460,7 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30410
30460
  if (event.key === "ArrowDown") {
30411
30461
  event.preventDefault();
30412
30462
  if (!this.isOpen()) this.isOpen.set(true);
30413
- this.focusHoursWhenReady();
30463
+ this.focusHoursOnReveal();
30414
30464
  } else if (event.key === "Enter") {
30415
30465
  event.preventDefault();
30416
30466
  this.commitTyped();
@@ -30759,6 +30809,13 @@ var TimePickerComponent = class TimePickerComponent extends LabelledFieldControl
30759
30809
  predicate: ["secondsEl"],
30760
30810
  descendants: true,
30761
30811
  isSignal: true
30812
+ },
30813
+ {
30814
+ propertyName: "popover",
30815
+ first: true,
30816
+ predicate: PopoverComponent,
30817
+ descendants: true,
30818
+ isSignal: true
30762
30819
  }
30763
30820
  ],
30764
30821
  usesInheritance: true,
@@ -30897,6 +30954,10 @@ i0.ɵɵngDeclareClassMetadata({
30897
30954
  type: i0.ViewChild,
30898
30955
  args: ["secondsEl", { isSignal: true }]
30899
30956
  }],
30957
+ popover: [{
30958
+ type: i0.ViewChild,
30959
+ args: [i0.forwardRef(() => PopoverComponent), { isSignal: true }]
30960
+ }],
30900
30961
  placeholder: [{
30901
30962
  type: i0.Input,
30902
30963
  args: [{