@acorex/cdk 22.4.61 → 22.4.62

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.
@@ -1,39 +1,40 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, inject, ElementRef, signal, afterNextRender, HostListener, Directive } from '@angular/core';
2
+ import { input, inject, ElementRef, Directive } from '@angular/core';
3
3
 
4
+ const FOCUSABLE_SELECTORS = [
5
+ 'a[href]',
6
+ 'button:not([disabled])',
7
+ 'textarea:not([disabled])',
8
+ 'input:not([disabled])',
9
+ 'select:not([disabled])',
10
+ '[tabindex]:not([tabindex="-1"])',
11
+ ].join(',');
4
12
  class AXFocusTrapDirective {
5
13
  constructor() {
6
14
  this.arrowNavigation = input(false, { ...(ngDevMode ? { debugName: "arrowNavigation" } : /* istanbul ignore next */ {}), alias: 'axFocusTrapArrowNavigation' });
7
- this.el = inject(ElementRef);
8
- this.focusableElements = [];
9
- this.nativeElement = signal(null, /* @ts-ignore */
10
- ...(ngDevMode ? [{ debugName: "nativeElement" }] : /* istanbul ignore next */ []));
11
- this.observer = new MutationObserver(() => this.setFocusableElements());
12
- this.#init = afterNextRender(() => {
13
- this.nativeElement.set(this.el.nativeElement);
14
- this.setFocusableElements();
15
- this.observer.observe(this.el.nativeElement, { childList: true, subtree: true });
16
- });
17
- }
18
- #init;
19
- ngOnDestroy() {
20
- this.observer.disconnect();
15
+ this.el = inject((ElementRef));
21
16
  }
22
- setFocusableElements() {
23
- const focusableSelectors = [
24
- 'a[href]',
25
- 'button:not([disabled])',
26
- 'textarea:not([disabled])',
27
- 'input:not([disabled])',
28
- 'select:not([disabled])',
29
- '[tabindex]:not([tabindex="-1"])',
30
- ];
31
- this.focusableElements = Array.from(this.nativeElement().querySelectorAll(focusableSelectors.join(',')))
32
- .filter((el) => !el.hasAttribute('disabled'))
33
- .map((el) => el);
17
+ /**
18
+ * Collected on keydown instead of a subtree MutationObserver.
19
+ * A popup full of editors mutates constantly while it opens; rescanning on every mutation
20
+ * walks the whole dialog again for each inserted node.
21
+ */
22
+ queryFocusableElements() {
23
+ const items = [];
24
+ this.el.nativeElement.querySelectorAll(FOCUSABLE_SELECTORS).forEach((node) => {
25
+ if (node instanceof HTMLElement && !node.hasAttribute('disabled')) {
26
+ items.push(node);
27
+ }
28
+ });
29
+ return items;
34
30
  }
35
31
  handleKeyboardEvent(event) {
36
- const items = this.focusableElements;
32
+ const isTab = event.key === 'Tab';
33
+ const isArrow = this.arrowNavigation() && (event.key === 'ArrowLeft' || event.key === 'ArrowRight');
34
+ if (!isTab && !isArrow) {
35
+ return;
36
+ }
37
+ const items = this.queryFocusableElements();
37
38
  if (!items.length)
38
39
  return;
39
40
  const activeIndex = items.indexOf(document.activeElement);
@@ -58,11 +59,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
58
59
  type: Directive,
59
60
  args: [{
60
61
  selector: '[axFocusTrap]',
62
+ host: {
63
+ '(keydown)': 'handleKeyboardEvent($event)',
64
+ },
61
65
  }]
62
- }], propDecorators: { arrowNavigation: [{ type: i0.Input, args: [{ isSignal: true, alias: "axFocusTrapArrowNavigation", required: false }] }], handleKeyboardEvent: [{
63
- type: HostListener,
64
- args: ['keydown', ['$event']]
65
- }] } });
66
+ }], propDecorators: { arrowNavigation: [{ type: i0.Input, args: [{ isSignal: true, alias: "axFocusTrapArrowNavigation", required: false }] }] } });
66
67
 
67
68
  /**
68
69
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"acorex-cdk-focus-trap.mjs","sources":["../../../../packages/cdk/focus-trap/src/lib/focus-trap.directive.ts","../../../../packages/cdk/focus-trap/src/acorex-cdk-focus-trap.ts"],"sourcesContent":["import { afterNextRender, Directive, ElementRef, HostListener, inject, input, OnDestroy, signal } from '@angular/core';\n\n@Directive({\n selector: '[axFocusTrap]',\n})\nexport class AXFocusTrapDirective implements OnDestroy {\n arrowNavigation = input(false, { alias: 'axFocusTrapArrowNavigation' });\n\n private el = inject(ElementRef);\n private focusableElements: HTMLElement[] = [];\n private nativeElement = signal<HTMLElement>(null);\n private observer = new MutationObserver(() => this.setFocusableElements());\n\n #init = afterNextRender(() => {\n this.nativeElement.set(this.el.nativeElement);\n this.setFocusableElements();\n this.observer.observe(this.el.nativeElement, { childList: true, subtree: true });\n });\n\n ngOnDestroy(): void {\n this.observer.disconnect();\n }\n\n private setFocusableElements() {\n const focusableSelectors = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ];\n\n this.focusableElements = Array.from(this.nativeElement().querySelectorAll(focusableSelectors.join(',')))\n .filter((el: Element) => !el.hasAttribute('disabled'))\n .map((el) => el as HTMLElement);\n }\n\n @HostListener('keydown', ['$event'])\n handleKeyboardEvent(event: KeyboardEvent): void {\n const items = this.focusableElements;\n if (!items.length) return;\n\n const activeIndex = items.indexOf(document.activeElement as HTMLElement);\n\n if (event.key === 'Tab') {\n if (event.shiftKey ? activeIndex === 0 : activeIndex === items.length - 1) {\n event.preventDefault();\n items[event.shiftKey ? items.length - 1 : 0]?.focus();\n }\n return;\n }\n\n if (!this.arrowNavigation() || (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') || activeIndex === -1) {\n return;\n }\n\n event.preventDefault();\n const delta = event.key === 'ArrowRight' ? 1 : -1;\n items[(activeIndex + delta + items.length) % items.length]?.focus();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAKa,oBAAoB,CAAA;AAHjC,IAAA,WAAA,GAAA;QAIE,IAAA,CAAA,eAAe,GAAG,KAAK,CAAC,KAAK,uFAAI,KAAK,EAAE,4BAA4B,EAAA,CAAG;AAE/D,QAAA,IAAA,CAAA,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;QACvB,IAAA,CAAA,iBAAiB,GAAkB,EAAE;QACrC,IA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SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AAC1B,iBAAA;;sBAkCE,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;ACtCrC;;AAEG;;"}
1
+ {"version":3,"file":"acorex-cdk-focus-trap.mjs","sources":["../../../../packages/cdk/focus-trap/src/lib/focus-trap.directive.ts","../../../../packages/cdk/focus-trap/src/acorex-cdk-focus-trap.ts"],"sourcesContent":["import { Directive, ElementRef, inject, input } from '@angular/core';\n\nconst FOCUSABLE_SELECTORS = [\n 'a[href]',\n 'button:not([disabled])',\n 'textarea:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(',');\n\n@Directive({\n selector: '[axFocusTrap]',\n host: {\n '(keydown)': 'handleKeyboardEvent($event)',\n },\n})\nexport class AXFocusTrapDirective {\n arrowNavigation = input(false, { alias: 'axFocusTrapArrowNavigation' });\n\n private el = inject(ElementRef<HTMLElement>);\n\n /**\n * Collected on keydown instead of a subtree MutationObserver.\n * A popup full of editors mutates constantly while it opens; rescanning on every mutation\n * walks the whole dialog again for each inserted node.\n */\n private queryFocusableElements(): HTMLElement[] {\n const items: HTMLElement[] = [];\n this.el.nativeElement.querySelectorAll(FOCUSABLE_SELECTORS).forEach((node) => {\n if (node instanceof HTMLElement && !node.hasAttribute('disabled')) {\n items.push(node);\n }\n });\n return items;\n }\n\n protected handleKeyboardEvent(event: KeyboardEvent): void {\n const isTab = event.key === 'Tab';\n const isArrow = this.arrowNavigation() && (event.key === 'ArrowLeft' || event.key === 'ArrowRight');\n if (!isTab && !isArrow) {\n return;\n }\n\n const items = this.queryFocusableElements();\n if (!items.length) return;\n\n const activeIndex = items.indexOf(document.activeElement as HTMLElement);\n\n if (event.key === 'Tab') {\n if (event.shiftKey ? activeIndex === 0 : activeIndex === items.length - 1) {\n event.preventDefault();\n items[event.shiftKey ? items.length - 1 : 0]?.focus();\n }\n return;\n }\n\n if (!this.arrowNavigation() || (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') || activeIndex === -1) {\n return;\n }\n\n event.preventDefault();\n const delta = event.key === 'ArrowRight' ? 1 : -1;\n items[(activeIndex + delta + items.length) % items.length]?.focus();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAEA,MAAM,mBAAmB,GAAG;IAC1B,SAAS;IACT,wBAAwB;IACxB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,iCAAiC;AAClC,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC;MAQE,oBAAoB,CAAA;AANjC,IAAA,WAAA,GAAA;QAOE,IAAA,CAAA,eAAe,GAAG,KAAK,CAAC,KAAK,uFAAI,KAAK,EAAE,4BAA4B,EAAA,CAAG;AAE/D,QAAA,IAAA,CAAA,EAAE,GAAG,MAAM,EAAC,UAAuB,EAAC;AA6C7C,IAAA;AA3CC;;;;AAIG;IACK,sBAAsB,GAAA;QAC5B,MAAM,KAAK,GAAkB,EAAE;AAC/B,QAAA,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC3E,YAAA,IAAI,IAAI,YAAY,WAAW,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;AACjE,gBAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAClB;AACF,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,KAAK;IACd;AAEU,IAAA,mBAAmB,CAAC,KAAoB,EAAA;AAChD,QAAA,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,KAAK;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,WAAW,IAAI,KAAK,CAAC,GAAG,KAAK,YAAY,CAAC;AACnG,QAAA,IAAI,CAAC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AAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,SAAA,EAAA,6BAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBANhC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,IAAI,EAAE;AACJ,wBAAA,WAAW,EAAE,6BAA6B;AAC3C,qBAAA;AACF,iBAAA;;;AChBD;;AAEG;;"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@acorex/cdk",
3
- "version": "22.4.61",
3
+ "version": "22.4.62",
4
4
  "peerDependencies": {
5
- "@acorex/core": "22.4.61",
5
+ "@acorex/core": "22.4.62",
6
6
  "@tiptap/core": ">=3.31.4",
7
7
  "@tiptap/extension-color": ">=3.31.4",
8
8
  "@tiptap/extension-highlight": ">=3.31.4",
@@ -1,16 +1,15 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnDestroy } from '@angular/core';
3
2
 
4
- declare class AXFocusTrapDirective implements OnDestroy {
5
- #private;
3
+ declare class AXFocusTrapDirective {
6
4
  arrowNavigation: i0.InputSignal<boolean>;
7
5
  private el;
8
- private focusableElements;
9
- private nativeElement;
10
- private observer;
11
- ngOnDestroy(): void;
12
- private setFocusableElements;
13
- handleKeyboardEvent(event: KeyboardEvent): void;
6
+ /**
7
+ * Collected on keydown instead of a subtree MutationObserver.
8
+ * A popup full of editors mutates constantly while it opens; rescanning on every mutation
9
+ * walks the whole dialog again for each inserted node.
10
+ */
11
+ private queryFocusableElements;
12
+ protected handleKeyboardEvent(event: KeyboardEvent): void;
14
13
  static ɵfac: i0.ɵɵFactoryDeclaration<AXFocusTrapDirective, never>;
15
14
  static ɵdir: i0.ɵɵDirectiveDeclaration<AXFocusTrapDirective, "[axFocusTrap]", never, { "arrowNavigation": { "alias": "axFocusTrapArrowNavigation"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
16
15
  }