@shoper/phoenix_design_system 1.18.23-5 → 1.18.23-6

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.
Files changed (27) hide show
  1. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +3 -21
  2. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +1 -1
  4. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +22 -0
  5. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  6. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js +14 -10
  7. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -1
  8. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +4 -13
  9. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +3 -21
  10. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -1
  11. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.d.ts +6 -2
  12. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +1 -1
  13. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.d.ts +2 -1
  14. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +13 -0
  15. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +17 -0
  16. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  17. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.d.ts +15 -0
  18. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.js +2 -0
  19. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.js.map +1 -0
  20. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.d.ts +2 -1
  21. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js +15 -11
  22. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -1
  23. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.d.ts +2 -1
  24. package/package.json +1 -1
  25. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/index.d.ts +0 -6
  26. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/index.js +0 -5
  27. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/index.js.map +0 -1
@@ -4,33 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  require('lit');
7
- var sentinel_focus_trap_strategy = require('./strategies/sentinel_focus_trap_strategy.js');
8
- var cyclic_focus_trap_strategy = require('./strategies/cyclic_focus_trap_strategy.js');
9
- var toggler_focus_trap_strategy = require('./strategies/toggler_focus_trap_strategy.js');
7
+ var focus_trap_strategy_constants = require('./strategies/focus_trap_strategy_constants.js');
10
8
 
11
9
  var _FocusTrapController_strategy;
12
- function createStrategy(props) {
13
- switch (props.mode) {
14
- case 'sentinel': return new sentinel_focus_trap_strategy.SentinelFocusTrapStrategy({ getContainer: props.getContainer, noAutofocus: props.noAutofocus });
15
- case 'cyclic': return new cyclic_focus_trap_strategy.CyclicFocusTrapStrategy(props.getContainer);
16
- case 'toggler': return new toggler_focus_trap_strategy.TogglerFocusTrapStrategy({ getContainer: props.getContainer, getToggler: props.getToggler });
17
- }
18
- }
19
- /**
20
- * A thin Lit ReactiveController that owns the lifecycle of a FocusTrapStrategy.
21
- *
22
- * Pass a discriminated-union `props` object with `mode: 'sentinel' | 'cyclic' | 'toggler'`
23
- * and the required options for that mode. The controller creates the correct strategy
24
- * internally and exposes it as a typed `.strategy` property for mode-specific API access
25
- * (e.g. `controller.strategy.setSentinels(...)` when mode is 'sentinel').
26
- */
27
10
  class FocusTrapController {
28
- constructor(host, props) {
11
+ constructor(host, { mode, ...strategyProps }) {
29
12
  _FocusTrapController_strategy.set(this, void 0);
30
- tslib_es6.__classPrivateFieldSet(this, _FocusTrapController_strategy, createStrategy(props), "f");
13
+ tslib_es6.__classPrivateFieldSet(this, _FocusTrapController_strategy, new focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_STRATEGIES[mode](strategyProps), "f");
31
14
  host.addController(this);
32
15
  }
33
- /** The underlying strategy instance, typed to match the mode passed at construction. */
34
16
  get strategy() {
35
17
  return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
36
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -15,7 +15,7 @@ var focus_trap_strategy = require('./focus_trap_strategy.js');
15
15
  * (e.g. a full-screen search overlay on mobile).
16
16
  */
17
17
  class CyclicFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
18
- constructor(getContainer) {
18
+ constructor({ getContainer }) {
19
19
  super(getContainer);
20
20
  this._handleKeyDown = (ev) => {
21
21
  if (!this.active || ev.code !== 'Tab')
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var cyclic_focus_trap_strategy = require('./cyclic_focus_trap_strategy.js');
6
+ var toggler_focus_trap_strategy = require('./toggler_focus_trap_strategy.js');
7
+ var sentinel_focus_trap_strategy = require('./sentinel_focus_trap_strategy.js');
8
+
9
+ const FOCUS_TRAP_STRATEGY_TYPES = {
10
+ cyclic: 'cyclic',
11
+ toggler: 'toggler',
12
+ sentinel: 'sentinel',
13
+ };
14
+ const FOCUS_TRAP_STRATEGY_STRATEGIES = {
15
+ [FOCUS_TRAP_STRATEGY_TYPES.cyclic]: cyclic_focus_trap_strategy.CyclicFocusTrapStrategy,
16
+ [FOCUS_TRAP_STRATEGY_TYPES.toggler]: toggler_focus_trap_strategy.TogglerFocusTrapStrategy,
17
+ [FOCUS_TRAP_STRATEGY_TYPES.sentinel]: sentinel_focus_trap_strategy.SentinelFocusTrapStrategy,
18
+ };
19
+
20
+ exports.FOCUS_TRAP_STRATEGY_STRATEGIES = FOCUS_TRAP_STRATEGY_STRATEGIES;
21
+ exports.FOCUS_TRAP_STRATEGY_TYPES = FOCUS_TRAP_STRATEGY_TYPES;
22
+ //# sourceMappingURL=focus_trap_strategy_constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../../external/tslib/tslib.es6.js');
6
- var utilities = require('@dreamcommerce/utilities');
6
+ require('@dreamcommerce/utilities');
7
7
  var focus_trap_strategy = require('./focus_trap_strategy.js');
8
8
 
9
9
  var _SentinelFocusTrapStrategy_sentinelStart, _SentinelFocusTrapStrategy_sentinelEnd;
@@ -23,22 +23,26 @@ class SentinelFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
23
23
  _SentinelFocusTrapStrategy_sentinelStart.set(this, void 0);
24
24
  _SentinelFocusTrapStrategy_sentinelEnd.set(this, void 0);
25
25
  this._handleKeyUp = (ev) => {
26
- var _a;
27
26
  if (!this.active || ev.code !== 'Tab')
28
27
  return;
29
28
  const container = this.getContainer();
30
29
  if (!container)
31
30
  return;
31
+ const focusableElements = this.getFocusableElements(container);
32
+ if (focusableElements.length === 0)
33
+ return;
34
+ const $target = ev.target;
32
35
  if (ev.shiftKey) {
33
- if (document.activeElement === tslib_es6.__classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelStart, "f")) {
34
- const focusableElements = this.getFocusableElements(container);
35
- (_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
36
+ if ($target === focusableElements[0]) {
36
37
  ev.preventDefault();
38
+ focusableElements[focusableElements.length - 1].focus();
37
39
  }
38
40
  }
39
- else if (document.activeElement === tslib_es6.__classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelEnd, "f")) {
40
- utilities.UiDomUtils.setFocusToFirstFocusableElementInContainer(container);
41
- ev.preventDefault();
41
+ else {
42
+ if ($target === focusableElements[focusableElements.length - 1]) {
43
+ ev.preventDefault();
44
+ focusableElements[0].focus();
45
+ }
42
46
  }
43
47
  };
44
48
  this.noAutofocus = noAutofocus;
@@ -66,10 +70,10 @@ class SentinelFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
66
70
  });
67
71
  }
68
72
  attach() {
69
- document.addEventListener('keyup', this._handleKeyUp);
73
+ document.addEventListener('keydown', this._handleKeyUp);
70
74
  }
71
75
  detach() {
72
- document.removeEventListener('keyup', this._handleKeyUp);
76
+ document.removeEventListener('keydown', this._handleKeyUp);
73
77
  }
74
78
  activate() {
75
79
  this.active = true;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,21 +1,12 @@
1
1
  import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- import { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy';
3
- import { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy';
4
- import { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy';
2
+ import type { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy';
3
+ import type { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy';
4
+ import type { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy';
5
5
  import type { TFocusTrapProps, TSentinelFocusTrapProps, TCyclicFocusTrapProps } from './focus_trap_controller_types';
6
6
  declare type StrategyFor<T extends TFocusTrapProps> = T extends TSentinelFocusTrapProps ? SentinelFocusTrapStrategy : T extends TCyclicFocusTrapProps ? CyclicFocusTrapStrategy : TogglerFocusTrapStrategy;
7
- /**
8
- * A thin Lit ReactiveController that owns the lifecycle of a FocusTrapStrategy.
9
- *
10
- * Pass a discriminated-union `props` object with `mode: 'sentinel' | 'cyclic' | 'toggler'`
11
- * and the required options for that mode. The controller creates the correct strategy
12
- * internally and exposes it as a typed `.strategy` property for mode-specific API access
13
- * (e.g. `controller.strategy.setSentinels(...)` when mode is 'sentinel').
14
- */
15
7
  export declare class FocusTrapController<TProps extends TFocusTrapProps = TFocusTrapProps> implements ReactiveController {
16
8
  #private;
17
- constructor(host: ReactiveControllerHost, props: TProps);
18
- /** The underlying strategy instance, typed to match the mode passed at construction. */
9
+ constructor(host: ReactiveControllerHost, { mode, ...strategyProps }: TProps);
19
10
  get strategy(): StrategyFor<TProps>;
20
11
  hostConnected(): void;
21
12
  hostDisconnected(): void;
@@ -1,32 +1,14 @@
1
1
  import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../external/tslib/tslib.es6.js';
2
2
  import 'lit';
3
- import { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy.js';
4
- import { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy.js';
5
- import { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy.js';
3
+ import { FOCUS_TRAP_STRATEGY_STRATEGIES } from './strategies/focus_trap_strategy_constants.js';
6
4
 
7
5
  var _FocusTrapController_strategy;
8
- function createStrategy(props) {
9
- switch (props.mode) {
10
- case 'sentinel': return new SentinelFocusTrapStrategy({ getContainer: props.getContainer, noAutofocus: props.noAutofocus });
11
- case 'cyclic': return new CyclicFocusTrapStrategy(props.getContainer);
12
- case 'toggler': return new TogglerFocusTrapStrategy({ getContainer: props.getContainer, getToggler: props.getToggler });
13
- }
14
- }
15
- /**
16
- * A thin Lit ReactiveController that owns the lifecycle of a FocusTrapStrategy.
17
- *
18
- * Pass a discriminated-union `props` object with `mode: 'sentinel' | 'cyclic' | 'toggler'`
19
- * and the required options for that mode. The controller creates the correct strategy
20
- * internally and exposes it as a typed `.strategy` property for mode-specific API access
21
- * (e.g. `controller.strategy.setSentinels(...)` when mode is 'sentinel').
22
- */
23
6
  class FocusTrapController {
24
- constructor(host, props) {
7
+ constructor(host, { mode, ...strategyProps }) {
25
8
  _FocusTrapController_strategy.set(this, void 0);
26
- __classPrivateFieldSet(this, _FocusTrapController_strategy, createStrategy(props), "f");
9
+ __classPrivateFieldSet(this, _FocusTrapController_strategy, new FOCUS_TRAP_STRATEGY_STRATEGIES[mode](strategyProps), "f");
27
10
  host.addController(this);
28
11
  }
29
- /** The underlying strategy instance, typed to match the mode passed at construction. */
30
12
  get strategy() {
31
13
  return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
32
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,4 +1,8 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
+ import { ICyclicFocusTrapStrategy } from './focus_trap_strategy_types';
3
+ export declare type TCyclicFocusTrapStrategyProps = {
4
+ getContainer: () => HTMLElement | undefined;
5
+ };
2
6
  /**
3
7
  * Cyclic keydown focus trap.
4
8
  *
@@ -9,8 +13,8 @@ import { FocusTrapStrategy } from './focus_trap_strategy';
9
13
  * Suitable when the host is not portaled and `inert` is not applied to background content
10
14
  * (e.g. a full-screen search overlay on mobile).
11
15
  */
12
- export declare class CyclicFocusTrapStrategy extends FocusTrapStrategy {
13
- constructor(getContainer: () => HTMLElement | undefined);
16
+ export declare class CyclicFocusTrapStrategy extends FocusTrapStrategy implements ICyclicFocusTrapStrategy {
17
+ constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
14
18
  attach(): void;
15
19
  detach(): void;
16
20
  private _handleKeyDown;
@@ -11,7 +11,7 @@ import { FocusTrapStrategy } from './focus_trap_strategy.js';
11
11
  * (e.g. a full-screen search overlay on mobile).
12
12
  */
13
13
  class CyclicFocusTrapStrategy extends FocusTrapStrategy {
14
- constructor(getContainer) {
14
+ constructor({ getContainer }) {
15
15
  super(getContainer);
16
16
  this._handleKeyDown = (ev) => {
17
17
  if (!this.active || ev.code !== 'Tab')
@@ -1,4 +1,5 @@
1
- export declare abstract class FocusTrapStrategy {
1
+ import { IFocusTrapStrategy } from './focus_trap_strategy_types';
2
+ export declare abstract class FocusTrapStrategy implements IFocusTrapStrategy {
2
3
  protected readonly getContainer: () => HTMLElement | undefined;
3
4
  protected active: boolean;
4
5
  constructor(getContainer: () => HTMLElement | undefined);
@@ -0,0 +1,13 @@
1
+ import { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy';
2
+ import { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy';
3
+ import { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy';
4
+ export declare const FOCUS_TRAP_STRATEGY_TYPES: {
5
+ readonly cyclic: "cyclic";
6
+ readonly toggler: "toggler";
7
+ readonly sentinel: "sentinel";
8
+ };
9
+ export declare const FOCUS_TRAP_STRATEGY_STRATEGIES: {
10
+ readonly cyclic: typeof CyclicFocusTrapStrategy;
11
+ readonly toggler: typeof TogglerFocusTrapStrategy;
12
+ readonly sentinel: typeof SentinelFocusTrapStrategy;
13
+ };
@@ -0,0 +1,17 @@
1
+ import { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy.js';
2
+ import { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy.js';
3
+ import { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy.js';
4
+
5
+ const FOCUS_TRAP_STRATEGY_TYPES = {
6
+ cyclic: 'cyclic',
7
+ toggler: 'toggler',
8
+ sentinel: 'sentinel',
9
+ };
10
+ const FOCUS_TRAP_STRATEGY_STRATEGIES = {
11
+ [FOCUS_TRAP_STRATEGY_TYPES.cyclic]: CyclicFocusTrapStrategy,
12
+ [FOCUS_TRAP_STRATEGY_TYPES.toggler]: TogglerFocusTrapStrategy,
13
+ [FOCUS_TRAP_STRATEGY_TYPES.sentinel]: SentinelFocusTrapStrategy,
14
+ };
15
+
16
+ export { FOCUS_TRAP_STRATEGY_STRATEGIES, FOCUS_TRAP_STRATEGY_TYPES };
17
+ //# sourceMappingURL=focus_trap_strategy_constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,15 @@
1
+ export interface IFocusTrapStrategy {
2
+ attach(): void;
3
+ detach(): void;
4
+ activate(): void;
5
+ deactivate(): void;
6
+ getFocusableElements(container: HTMLElement): HTMLElement[];
7
+ }
8
+ export interface ICyclicFocusTrapStrategy extends IFocusTrapStrategy {
9
+ }
10
+ export interface ITogglerFocusTrapStrategy extends IFocusTrapStrategy {
11
+ }
12
+ export interface ISentinelFocusTrapStrategy extends IFocusTrapStrategy {
13
+ setSentinels(start: HTMLElement, end: HTMLElement): void;
14
+ focusFirst(): void;
15
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=focus_trap_strategy_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
+ import { ISentinelFocusTrapStrategy } from './focus_trap_strategy_types';
2
3
  export declare type TSentinelFocusTrapStrategyProps = {
3
4
  getContainer: () => HTMLElement | undefined;
4
5
  noAutofocus?: boolean;
@@ -13,7 +14,7 @@ export declare type TSentinelFocusTrapStrategyProps = {
13
14
  * Reacts on `keyup` so that the browser's native focus movement has already completed
14
15
  * before we redirect it.
15
16
  */
16
- export declare class SentinelFocusTrapStrategy extends FocusTrapStrategy {
17
+ export declare class SentinelFocusTrapStrategy extends FocusTrapStrategy implements ISentinelFocusTrapStrategy {
17
18
  #private;
18
19
  noAutofocus: boolean;
19
20
  constructor({ getContainer, noAutofocus }: TSentinelFocusTrapStrategyProps);
@@ -1,5 +1,5 @@
1
- import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../../external/tslib/tslib.es6.js';
2
- import { UiDomUtils } from '@dreamcommerce/utilities';
1
+ import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import '@dreamcommerce/utilities';
3
3
  import { FocusTrapStrategy } from './focus_trap_strategy.js';
4
4
 
5
5
  var _SentinelFocusTrapStrategy_sentinelStart, _SentinelFocusTrapStrategy_sentinelEnd;
@@ -19,22 +19,26 @@ class SentinelFocusTrapStrategy extends FocusTrapStrategy {
19
19
  _SentinelFocusTrapStrategy_sentinelStart.set(this, void 0);
20
20
  _SentinelFocusTrapStrategy_sentinelEnd.set(this, void 0);
21
21
  this._handleKeyUp = (ev) => {
22
- var _a;
23
22
  if (!this.active || ev.code !== 'Tab')
24
23
  return;
25
24
  const container = this.getContainer();
26
25
  if (!container)
27
26
  return;
27
+ const focusableElements = this.getFocusableElements(container);
28
+ if (focusableElements.length === 0)
29
+ return;
30
+ const $target = ev.target;
28
31
  if (ev.shiftKey) {
29
- if (document.activeElement === __classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelStart, "f")) {
30
- const focusableElements = this.getFocusableElements(container);
31
- (_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
32
+ if ($target === focusableElements[0]) {
32
33
  ev.preventDefault();
34
+ focusableElements[focusableElements.length - 1].focus();
33
35
  }
34
36
  }
35
- else if (document.activeElement === __classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelEnd, "f")) {
36
- UiDomUtils.setFocusToFirstFocusableElementInContainer(container);
37
- ev.preventDefault();
37
+ else {
38
+ if ($target === focusableElements[focusableElements.length - 1]) {
39
+ ev.preventDefault();
40
+ focusableElements[0].focus();
41
+ }
38
42
  }
39
43
  };
40
44
  this.noAutofocus = noAutofocus;
@@ -62,10 +66,10 @@ class SentinelFocusTrapStrategy extends FocusTrapStrategy {
62
66
  });
63
67
  }
64
68
  attach() {
65
- document.addEventListener('keyup', this._handleKeyUp);
69
+ document.addEventListener('keydown', this._handleKeyUp);
66
70
  }
67
71
  detach() {
68
- document.removeEventListener('keyup', this._handleKeyUp);
72
+ document.removeEventListener('keydown', this._handleKeyUp);
69
73
  }
70
74
  activate() {
71
75
  this.active = true;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,+CAAmD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,+CAAmD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,4 +1,5 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
+ import { ITogglerFocusTrapStrategy } from './focus_trap_strategy_types';
2
3
  export declare type TTogglerFocusTrapStrategyProps = {
3
4
  getContainer: () => HTMLElement | undefined;
4
5
  getToggler: () => HTMLElement | null | undefined;
@@ -12,7 +13,7 @@ export declare type TTogglerFocusTrapStrategyProps = {
12
13
  * Suitable for dropdowns where the toggler button should stay in the Tab cycle
13
14
  * alongside the dropdown content.
14
15
  */
15
- export declare class TogglerFocusTrapStrategy extends FocusTrapStrategy {
16
+ export declare class TogglerFocusTrapStrategy extends FocusTrapStrategy implements ITogglerFocusTrapStrategy {
16
17
  #private;
17
18
  constructor({ getContainer, getToggler }: TTogglerFocusTrapStrategyProps);
18
19
  attach(): void;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/phoenix_design_system",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "1.18.23-5",
5
+ "version": "1.18.23-6",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- export { FocusTrapStrategy } from './focus_trap_strategy';
2
- export { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy';
3
- export type { TSentinelFocusTrapStrategyProps } from './sentinel_focus_trap_strategy';
4
- export { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy';
5
- export { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy';
6
- export type { TTogglerFocusTrapStrategyProps } from './toggler_focus_trap_strategy';
@@ -1,5 +0,0 @@
1
- export { FocusTrapStrategy } from './focus_trap_strategy';
2
- export { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy';
3
- export { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy';
4
- export { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../src/controllers/focus_trap_controller/strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}