@mediafly/js-ui 51.5.0 → 51.5.1-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.
@@ -18,6 +18,7 @@ export default class MflyModalComponentController implements IComponentControlle
18
18
  modalHeaderClass?: string | undefined;
19
19
  modalSize?: 'large' | 'full' | undefined;
20
20
  modalId: string | undefined;
21
+ focusModal?: boolean | undefined;
21
22
  modalCloseCallback: () => void;
22
23
  /** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
23
24
  modalConfirmDismissCallback?: () => ModalDismissConfirmation | undefined;
@@ -28,6 +29,7 @@ export default class MflyModalComponentController implements IComponentControlle
28
29
  private firstFocusable;
29
30
  private keyDownHandler;
30
31
  private lastFocusable;
32
+ private modalElement;
31
33
  constructor($attrs: ng.IAttributes, $element: ng.IAugmentedJQuery, $timeout: ng.ITimeoutService, $transclude: ng.ITranscludeFunction, $window: ng.IWindowService, mflyModalService: MflyModalService);
32
34
  $onDestroy(): void;
33
35
  $onInit(): void;
@@ -4,7 +4,9 @@
4
4
  ng-class="{
5
5
  'is-large': $ctrl.modalSize === 'large',
6
6
  'is-full': $ctrl.modalSize === 'full',
7
- }">
7
+ }"
8
+ tabindex="-1"
9
+ >
8
10
 
9
11
  <div ng-class="{ 'o-container': $ctrl.modalSize === 'full'}">
10
12
  <div class="c-modal__header" ng-if="$ctrl.hasHeaderTransclusion" ng-transclude="header"></div>
@@ -64,8 +64,14 @@ let MflyModalComponentController = class MflyModalComponentController {
64
64
  });
65
65
  // Timeout 0 only intermittently fires the animation; 50ms seems to be reliable.
66
66
  this.$timeout(() => {
67
+ var _a;
67
68
  this.$element.find('.c-modal__backdrop').addClass('is-visible');
68
- this.firstFocusable.focus();
69
+ if (this.focusModal) {
70
+ (_a = this.modalElement) === null || _a === void 0 ? void 0 : _a.focus();
71
+ }
72
+ else {
73
+ this.firstFocusable.focus();
74
+ }
69
75
  }, 50);
70
76
  }
71
77
  cancelDismiss() {
@@ -95,6 +101,14 @@ let MflyModalComponentController = class MflyModalComponentController {
95
101
  if (event.metaKey || event.ctrlKey || event.altKey) {
96
102
  return;
97
103
  }
104
+ if (event.key === 'Tab' && !event.shiftKey && event.target === this.modalElement) {
105
+ this.firstFocusable.focus();
106
+ event.preventDefault();
107
+ }
108
+ if (event.key === 'Tab' && event.shiftKey && event.target === this.modalElement) {
109
+ this.lastFocusable.focus();
110
+ event.preventDefault();
111
+ }
98
112
  if (event.key === 'Tab' && event.shiftKey && event.target === this.firstFocusable) {
99
113
  this.lastFocusable.focus();
100
114
  event.preventDefault();
@@ -118,6 +132,7 @@ let MflyModalComponentController = class MflyModalComponentController {
118
132
  if (!this.$element) {
119
133
  return;
120
134
  }
135
+ this.modalElement = this.$element.find('.c-modal')[0];
121
136
  this.focusableElementsInModal = this.$element.find(selectors.join(','));
122
137
  this.firstFocusable = this.focusableElementsInModal[0];
123
138
  this.lastFocusable = this.focusableElementsInModal[this.focusableElementsInModal.length - 1];
@@ -139,6 +154,10 @@ __decorate([
139
154
  decorators_1.Input('@'),
140
155
  __metadata("design:type", Object)
141
156
  ], MflyModalComponentController.prototype, "modalId", void 0);
157
+ __decorate([
158
+ decorators_1.Input('@'),
159
+ __metadata("design:type", Object)
160
+ ], MflyModalComponentController.prototype, "focusModal", void 0);
142
161
  __decorate([
143
162
  decorators_1.Output(),
144
163
  __metadata("design:type", Function)
@@ -1 +1 @@
1
- {"version":3,"file":"modal.component.js","sourceRoot":"","sources":["../../src/components/modal/modal.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,oDAAsB;AACtB,8CAAgE;AAChE,oEAA8C;AAkB9C,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;IAoBhD,YAC2B,MAAsB,EACpB,QAA6B,EAC7B,QAA4B,EACzB,WAAmC,EACvC,OAA0B,EACjB,gBAAkC;QAL5C,WAAM,GAAN,MAAM,CAAgB;QACpB,aAAQ,GAAR,QAAQ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CAAC,CAAA;IAChB,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,aAAa,CAAC,CAAA;IACrB,WAAA,mBAAM,CAAC,SAAS,CAAC,CAAA;IACjB,WAAA,mBAAM,CAAC,kBAAkB,CAAC,CAAA;iFAA2B,uBAAgB;GA9BnD,4BAA4B,CAwKhD;kBAxKoB,4BAA4B"}
@@ -1197,8 +1197,8 @@
1197
1197
  "affectsGlobalScope": false
1198
1198
  },
1199
1199
  "../src/components/modal/modal.component.ts": {
1200
- "version": "227ba74b1111ea22f512733c39e9bbd9c351a283277632b99bb7a1acf35c77c9",
1201
- "signature": "073ecb881da36223137fca6af8d82eb7938d024ff3645373b69565426472f14c",
1200
+ "version": "6fbd990797918ed63571aa45adea0a7fccf76e4769685fc46fbd0805c4c00e1a",
1201
+ "signature": "ccb3396525ebcf1d435a35c6c1eea2a70ec934bd3f15cc99444422bfa21b9d8c",
1202
1202
  "affectsGlobalScope": false
1203
1203
  },
1204
1204
  "../src/components/modal/index.ts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediafly/js-ui",
3
- "version": "51.5.0",
3
+ "version": "51.5.1-1",
4
4
  "license": "UNLICENSED",
5
5
  "description": "UI components for Mediafly Angular applications",
6
6
  "repository": {
@@ -4,7 +4,9 @@
4
4
  ng-class="{
5
5
  'is-large': $ctrl.modalSize === 'large',
6
6
  'is-full': $ctrl.modalSize === 'full',
7
- }">
7
+ }"
8
+ tabindex="-1"
9
+ >
8
10
 
9
11
  <div ng-class="{ 'o-container': $ctrl.modalSize === 'full'}">
10
12
  <div class="c-modal__header" ng-if="$ctrl.hasHeaderTransclusion" ng-transclude="header"></div>
@@ -25,6 +25,9 @@ export default class MflyModalComponentController implements IComponentControlle
25
25
  @Input('@') modalHeaderClass?: string | undefined
26
26
  @Input('@') modalSize?: 'large' | 'full' | undefined
27
27
  @Input('@') modalId: string | undefined
28
+ // This focuses the modal element itself rather than the first focusable child.
29
+ // It is primarily for use by modals that load their content asynchronously.
30
+ @Input('@') focusModal?: boolean | undefined
28
31
 
29
32
  @Output() modalCloseCallback: () => void
30
33
  /** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
@@ -38,6 +41,7 @@ export default class MflyModalComponentController implements IComponentControlle
38
41
  private firstFocusable: HTMLElement
39
42
  private keyDownHandler: (event: KeyboardEvent) => void
40
43
  private lastFocusable: HTMLElement
44
+ private modalElement: HTMLElement
41
45
 
42
46
  constructor(
43
47
  @Inject('$attrs') private $attrs: ng.IAttributes,
@@ -98,7 +102,11 @@ export default class MflyModalComponentController implements IComponentControlle
98
102
  // Timeout 0 only intermittently fires the animation; 50ms seems to be reliable.
99
103
  this.$timeout(() => {
100
104
  this.$element.find('.c-modal__backdrop').addClass('is-visible')
101
- this.firstFocusable.focus()
105
+ if (this.focusModal) {
106
+ this.modalElement?.focus()
107
+ } else {
108
+ this.firstFocusable.focus()
109
+ }
102
110
  }, 50)
103
111
  }
104
112
 
@@ -139,6 +147,16 @@ export default class MflyModalComponentController implements IComponentControlle
139
147
  return
140
148
  }
141
149
 
150
+ if (event.key === 'Tab' && !event.shiftKey && event.target === this.modalElement) {
151
+ this.firstFocusable.focus()
152
+ event.preventDefault()
153
+ }
154
+
155
+ if (event.key === 'Tab' && event.shiftKey && event.target === this.modalElement) {
156
+ this.lastFocusable.focus()
157
+ event.preventDefault()
158
+ }
159
+
142
160
  if (event.key === 'Tab' && event.shiftKey && event.target === this.firstFocusable) {
143
161
  this.lastFocusable.focus()
144
162
  event.preventDefault()
@@ -164,6 +182,7 @@ export default class MflyModalComponentController implements IComponentControlle
164
182
  ]
165
183
  if (!this.$element) { return }
166
184
 
185
+ this.modalElement = this.$element.find('.c-modal')[0]
167
186
  this.focusableElementsInModal = this.$element.find(selectors.join(','))
168
187
  this.firstFocusable = this.focusableElementsInModal[0]
169
188
  this.lastFocusable = this.focusableElementsInModal[this.focusableElementsInModal.length - 1]