@ferrlabs/ui-ng 1.45.0 → 1.45.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.
@@ -6,7 +6,7 @@ import { FormsModule, NG_VALUE_ACCESSOR } from "@angular/forms";
6
6
  import * as i1$2 from "@angular/cdk/overlay";
7
7
  import { Overlay, OverlayModule } from "@angular/cdk/overlay";
8
8
  import * as i1$1 from "@angular/cdk/a11y";
9
- import { A11yModule, LiveAnnouncer } from "@angular/cdk/a11y";
9
+ import { A11yModule, FocusKeyManager, LiveAnnouncer } from "@angular/cdk/a11y";
10
10
  import { TemplatePortal } from "@angular/cdk/portal";
11
11
  import { DomSanitizer, Meta, Title } from "@angular/platform-browser";
12
12
  const SIZE$6 = {
@@ -9968,6 +9968,7 @@ function switcherState(apps) {
9968
9968
  hubHref: apps.find((app) => app.id === "ferrlabs")?.href ?? null
9969
9969
  };
9970
9970
  }
9971
+ const FOCUSABLE = "button, a[href], input, select, textarea, [tabindex]";
9971
9972
  var MenuComponent = class MenuComponent {
9972
9973
  constructor() {
9973
9974
  this.align = input("start", ...ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []);
@@ -9976,6 +9977,7 @@ var MenuComponent = class MenuComponent {
9976
9977
  this.minWidth = input(220, ...ngDevMode ? [{ debugName: "minWidth" }] : /* istanbul ignore next */ []);
9977
9978
  this.open = model(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
9978
9979
  this.host = inject(ElementRef);
9980
+ this.injector = inject(Injector);
9979
9981
  this.positions = computed(() => {
9980
9982
  const x = this.align() === "end" ? "end" : "start";
9981
9983
  const below = {
@@ -9994,6 +9996,22 @@ var MenuComponent = class MenuComponent {
9994
9996
  };
9995
9997
  return this.direction() === "up" ? [above, below] : [below, above];
9996
9998
  }, ...ngDevMode ? [{ debugName: "positions" }] : /* istanbul ignore next */ []);
9999
+ this.items = contentChildren(MenuItemComponent, {
10000
+ ...ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {},
10001
+ descendants: true
10002
+ });
10003
+ this.optionsByItem = /* @__PURE__ */ new WeakMap();
10004
+ this.options = computed(() => this.items().map((item) => {
10005
+ const option = this.optionsByItem.get(item) ?? {
10006
+ focus: () => item.focus(),
10007
+ get disabled() {
10008
+ return item.disabled();
10009
+ }
10010
+ };
10011
+ this.optionsByItem.set(item, option);
10012
+ return option;
10013
+ }), ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
10014
+ this.keyManager = new FocusKeyManager(this.options, this.injector).withWrap().withHomeAndEnd().withTypeAhead().skipPredicate((item) => item.disabled === true);
9997
10015
  afterRenderEffect(() => {
9998
10016
  const expanded = this.open();
9999
10017
  const trigger = this.host.nativeElement.querySelector("[flr-menu-trigger]");
@@ -10005,6 +10023,24 @@ var MenuComponent = class MenuComponent {
10005
10023
  toggle() {
10006
10024
  this.open.set(!this.open());
10007
10025
  }
10026
+ onAttach() {
10027
+ afterNextRender(() => this.keyManager.setFirstItemActive(), { injector: this.injector });
10028
+ }
10029
+ onDetach() {
10030
+ this.open.set(false);
10031
+ const active = document.activeElement;
10032
+ if (!active || active === document.body) {
10033
+ const trigger = this.host.nativeElement.querySelector("[flr-menu-trigger]");
10034
+ (trigger?.matches(FOCUSABLE) ? trigger : trigger?.querySelector(FOCUSABLE))?.focus();
10035
+ }
10036
+ }
10037
+ onKeydown(event) {
10038
+ if (event.key === "Tab") {
10039
+ this.open.set(false);
10040
+ return;
10041
+ }
10042
+ this.keyManager.onKeydown(event);
10043
+ }
10008
10044
  static {
10009
10045
  this.ɵfac = i0.ɵɵngDeclareFactory({
10010
10046
  minVersion: "12.0.0",
@@ -10017,7 +10053,7 @@ var MenuComponent = class MenuComponent {
10017
10053
  }
10018
10054
  static {
10019
10055
  this.ɵcmp = i0.ɵɵngDeclareComponent({
10020
- minVersion: "17.1.0",
10056
+ minVersion: "17.2.0",
10021
10057
  version: "22.2.3",
10022
10058
  type: MenuComponent,
10023
10059
  isStandalone: true,
@@ -10061,6 +10097,12 @@ var MenuComponent = class MenuComponent {
10061
10097
  },
10062
10098
  outputs: { open: "openChange" },
10063
10099
  host: { properties: { "class.flr-menu--block": "block()" } },
10100
+ queries: [{
10101
+ propertyName: "items",
10102
+ predicate: MenuItemComponent,
10103
+ descendants: true,
10104
+ isSignal: true
10105
+ }],
10064
10106
  ngImport: i0,
10065
10107
  template: `
10066
10108
  <!-- TODO(#122): the click handler sits on this wrapper rather than on the projected
@@ -10079,14 +10121,16 @@ var MenuComponent = class MenuComponent {
10079
10121
  [cdkConnectedOverlayHasBackdrop]="true"
10080
10122
  cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
10081
10123
  (backdropClick)="open.set(false)"
10082
- (detach)="open.set(false)"
10124
+ (attach)="onAttach()"
10125
+ (detach)="onDetach()"
10083
10126
  >
10084
- <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
10127
+ <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->
10085
10128
  <div
10086
10129
  class="flr-menu__panel"
10087
10130
  role="menu"
10088
10131
  [style.min-width.px]="minWidth()"
10089
10132
  (click)="open.set(false)"
10133
+ (keydown)="onKeydown($event)"
10090
10134
  >
10091
10135
  <ng-content select="[flr-menu-content]" />
10092
10136
  </div>
@@ -10182,14 +10226,16 @@ i0.ɵɵngDeclareClassMetadata({
10182
10226
  [cdkConnectedOverlayHasBackdrop]="true"
10183
10227
  cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
10184
10228
  (backdropClick)="open.set(false)"
10185
- (detach)="open.set(false)"
10229
+ (attach)="onAttach()"
10230
+ (detach)="onDetach()"
10186
10231
  >
10187
- <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
10232
+ <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->
10188
10233
  <div
10189
10234
  class="flr-menu__panel"
10190
10235
  role="menu"
10191
10236
  [style.min-width.px]="minWidth()"
10192
10237
  (click)="open.set(false)"
10238
+ (keydown)="onKeydown($event)"
10193
10239
  >
10194
10240
  <ng-content select="[flr-menu-content]" />
10195
10241
  </div>
@@ -10242,6 +10288,13 @@ i0.ɵɵngDeclareClassMetadata({
10242
10288
  }, {
10243
10289
  type: i0.Output,
10244
10290
  args: ["openChange"]
10291
+ }],
10292
+ items: [{
10293
+ type: i0.ContentChildren,
10294
+ args: [i0.forwardRef(() => MenuItemComponent), {
10295
+ descendants: true,
10296
+ isSignal: true
10297
+ }]
10245
10298
  }]
10246
10299
  }
10247
10300
  });
@@ -10251,6 +10304,10 @@ var MenuItemComponent = class MenuItemComponent {
10251
10304
  this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
10252
10305
  this.destructive = input(false, ...ngDevMode ? [{ debugName: "destructive" }] : /* istanbul ignore next */ []);
10253
10306
  this.selected = output();
10307
+ this.control = viewChild("control", ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
10308
+ }
10309
+ focus() {
10310
+ this.control()?.nativeElement.focus();
10254
10311
  }
10255
10312
  onClick() {
10256
10313
  if (this.disabled()) return;
@@ -10297,6 +10354,13 @@ var MenuItemComponent = class MenuItemComponent {
10297
10354
  }
10298
10355
  },
10299
10356
  outputs: { selected: "selected" },
10357
+ viewQueries: [{
10358
+ propertyName: "control",
10359
+ first: true,
10360
+ predicate: ["control"],
10361
+ descendants: true,
10362
+ isSignal: true
10363
+ }],
10300
10364
  ngImport: i0,
10301
10365
  template: `
10302
10366
  @if (href() && !disabled()) {
@@ -10305,6 +10369,7 @@ var MenuItemComponent = class MenuItemComponent {
10305
10369
  [class.flr-menu-item--danger]="destructive()"
10306
10370
  [href]="href()"
10307
10371
  role="menuitem"
10372
+ #control
10308
10373
  >
10309
10374
  <ng-container [ngTemplateOutlet]="body" />
10310
10375
  </a>
@@ -10314,6 +10379,7 @@ var MenuItemComponent = class MenuItemComponent {
10314
10379
  class="flr-menu-item"
10315
10380
  [class.flr-menu-item--danger]="destructive()"
10316
10381
  role="menuitem"
10382
+ #control
10317
10383
  [disabled]="disabled()"
10318
10384
  (click)="onClick()"
10319
10385
  >
@@ -10361,6 +10427,7 @@ i0.ɵɵngDeclareClassMetadata({
10361
10427
  [class.flr-menu-item--danger]="destructive()"
10362
10428
  [href]="href()"
10363
10429
  role="menuitem"
10430
+ #control
10364
10431
  >
10365
10432
  <ng-container [ngTemplateOutlet]="body" />
10366
10433
  </a>
@@ -10370,6 +10437,7 @@ i0.ɵɵngDeclareClassMetadata({
10370
10437
  class="flr-menu-item"
10371
10438
  [class.flr-menu-item--danger]="destructive()"
10372
10439
  role="menuitem"
10440
+ #control
10373
10441
  [disabled]="disabled()"
10374
10442
  (click)="onClick()"
10375
10443
  >
@@ -10414,6 +10482,10 @@ i0.ɵɵngDeclareClassMetadata({
10414
10482
  selected: [{
10415
10483
  type: i0.Output,
10416
10484
  args: ["selected"]
10485
+ }],
10486
+ control: [{
10487
+ type: i0.ViewChild,
10488
+ args: ["control", { isSignal: true }]
10417
10489
  }]
10418
10490
  }
10419
10491
  });
@@ -10964,7 +11036,6 @@ var BrandDropdownComponent = class BrandDropdownComponent {
10964
11036
  <button
10965
11037
  type="button"
10966
11038
  class="flr-bd__trigger"
10967
- [attr.aria-haspopup]="'menu'"
10968
11039
  [attr.aria-expanded]="open()"
10969
11040
  [title]="triggerTitle()"
10970
11041
  (click)="open.set(!open())"
@@ -10976,7 +11047,7 @@ var BrandDropdownComponent = class BrandDropdownComponent {
10976
11047
  </button>
10977
11048
 
10978
11049
  @if (open()) {
10979
- <div class="flr-bd__panel" role="menu">
11050
+ <div class="flr-bd__panel">
10980
11051
  @if (!collapsed()) {
10981
11052
  <div class="mono flr-bd__eyebrow">Switch app</div>
10982
11053
  }
@@ -10991,7 +11062,6 @@ var BrandDropdownComponent = class BrandDropdownComponent {
10991
11062
  [class.flr-bd__app--current]="row.app.id === current()"
10992
11063
  [class.flr-bd__app--collapsed]="collapsed()"
10993
11064
  [href]="row.app.href"
10994
- role="menuitem"
10995
11065
  [attr.target]="row.app.newTab ? '_blank' : null"
10996
11066
  [attr.rel]="row.app.newTab ? 'noreferrer noopener' : null"
10997
11067
  [attr.aria-current]="row.app.id === current() ? 'page' : null"
@@ -11073,7 +11143,6 @@ i0.ɵɵngDeclareClassMetadata({
11073
11143
  <button
11074
11144
  type="button"
11075
11145
  class="flr-bd__trigger"
11076
- [attr.aria-haspopup]="'menu'"
11077
11146
  [attr.aria-expanded]="open()"
11078
11147
  [title]="triggerTitle()"
11079
11148
  (click)="open.set(!open())"
@@ -11085,7 +11154,7 @@ i0.ɵɵngDeclareClassMetadata({
11085
11154
  </button>
11086
11155
 
11087
11156
  @if (open()) {
11088
- <div class="flr-bd__panel" role="menu">
11157
+ <div class="flr-bd__panel">
11089
11158
  @if (!collapsed()) {
11090
11159
  <div class="mono flr-bd__eyebrow">Switch app</div>
11091
11160
  }
@@ -11100,7 +11169,6 @@ i0.ɵɵngDeclareClassMetadata({
11100
11169
  [class.flr-bd__app--current]="row.app.id === current()"
11101
11170
  [class.flr-bd__app--collapsed]="collapsed()"
11102
11171
  [href]="row.app.href"
11103
- role="menuitem"
11104
11172
  [attr.target]="row.app.newTab ? '_blank' : null"
11105
11173
  [attr.rel]="row.app.newTab ? 'noreferrer noopener' : null"
11106
11174
  [attr.aria-current]="row.app.id === current() ? 'page' : null"