@mediafly/js-ui 50.4.4 → 50.5.0-0

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,6 +1,12 @@
1
1
  /// <reference types="angular" />
2
2
  /// <reference types="angular-mocks" />
3
3
  import MflyModalService from './modal.service';
4
+ export interface ModalDismissConfirmation {
5
+ cancelButtonText: string;
6
+ confirmButtonText: string;
7
+ message: string;
8
+ title: string;
9
+ }
4
10
  export default class MflyModalComponentController implements ng.IComponentController {
5
11
  private $attrs;
6
12
  private $element;
@@ -13,16 +19,22 @@ export default class MflyModalComponentController implements ng.IComponentContro
13
19
  modalSize?: 'large' | 'full' | undefined;
14
20
  modalId: string | undefined;
15
21
  modalCloseCallback: () => void;
16
- protected hasHeaderTransclusion: boolean;
22
+ /** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
23
+ modalConfirmDismissCallback?: () => ModalDismissConfirmation | undefined;
24
+ protected dismissConfirmation: ModalDismissConfirmation | undefined;
17
25
  protected hasFooterTransclusion: boolean;
26
+ protected hasHeaderTransclusion: boolean;
18
27
  private focusableElementsInModal;
19
28
  private firstFocusable;
29
+ private keyDownHandler;
20
30
  private lastFocusable;
21
31
  constructor($attrs: ng.IAttributes, $element: ng.IAugmentedJQuery, $timeout: ng.ITimeoutService, $transclude: ng.ITranscludeFunction, $window: ng.IWindowService, mflyModalService: MflyModalService);
22
32
  $onDestroy(): void;
23
33
  $onInit(): void;
24
34
  $postLink(): void;
25
- dismiss(): void;
35
+ protected cancelDismiss(): void;
36
+ protected confirmDismiss(): void;
37
+ protected dismiss(): void;
26
38
  /** While the modal's open, trap focus and handle ESC to close. */
27
39
  private handleKeydown;
28
40
  private calculateFocusableElements;
@@ -17,5 +17,23 @@
17
17
  class="c-modal__close">
18
18
  <span class="c-modal__close__x"></span><span class="sr-only" translate>CLOSE</span>
19
19
  </button>
20
+
21
+ <div
22
+ ng-if="!!$ctrl.dismissConfirmation"
23
+ class="c-modal__backdrop is-visible" tabindex="-1" role="dialog" aria-modal="true">
24
+ <div class="c-modal c-modal__dismiss_confirmation">
25
+ <div class="c-modal__header" ng-if="$ctrl.dismissConfirmation.title">
26
+ {{ $ctrl.dismissConfirmation.title }}
27
+ </div>
28
+ <div class="c-modal__body" ng-if="$ctrl.dismissConfirmation.message">
29
+ {{ $ctrl.dismissConfirmation.message }}
30
+ </div>
31
+ <div class="c-modal__footer">
32
+ <button class="o-button" ng-click="$ctrl.confirmDismiss()">{{ $ctrl.dismissConfirmation.confirmButtonText }}</button>
33
+ <button class="o-button o-button--primary" ng-click="$ctrl.cancelDismiss()">{{ $ctrl.dismissConfirmation.cancelButtonText }}</button>
34
+ </div>
35
+ </div>
36
+ </div>
20
37
  </div>
38
+
21
39
  </div>
@@ -28,13 +28,14 @@ let MflyModalComponentController = class MflyModalComponentController {
28
28
  this.mflyModalService = mflyModalService;
29
29
  }
30
30
  $onDestroy() {
31
- this.$window.removeEventListener('keydown', this.handleKeydown.bind(this));
31
+ this.$window.removeEventListener('keydown', this.keyDownHandler);
32
32
  this.mflyModalService.cleanupDOM();
33
33
  }
34
34
  $onInit() {
35
35
  this.hasHeaderTransclusion = this.$transclude.isSlotFilled('header');
36
36
  this.hasFooterTransclusion = this.$transclude.isSlotFilled('footer');
37
- this.$window.addEventListener('keydown', this.handleKeydown.bind(this));
37
+ this.keyDownHandler = (event) => { this.handleKeydown(event); };
38
+ this.$window.addEventListener('keydown', this.keyDownHandler);
38
39
  // Set up an observer for disabledness changes so that our focus trap will update itself.
39
40
  const observer = new MutationObserver(mutations => {
40
41
  mutations.forEach(lodash_1.default.debounce(() => this.calculateFocusableElements(), 50));
@@ -67,12 +68,25 @@ let MflyModalComponentController = class MflyModalComponentController {
67
68
  this.firstFocusable.focus();
68
69
  }, 50);
69
70
  }
70
- dismiss() {
71
+ cancelDismiss() {
72
+ this.dismissConfirmation = undefined;
73
+ }
74
+ confirmDismiss() {
71
75
  if (this.$attrs.modalCloseCallback) {
72
76
  this.modalCloseCallback();
73
77
  }
74
78
  this.mflyModalService.dismiss();
75
79
  }
80
+ dismiss() {
81
+ this.$timeout(() => {
82
+ var _a;
83
+ this.dismissConfirmation = (_a = this.modalConfirmDismissCallback) === null || _a === void 0 ? void 0 : _a.call(this);
84
+ if (this.dismissConfirmation) {
85
+ return;
86
+ }
87
+ this.confirmDismiss();
88
+ });
89
+ }
76
90
  /** While the modal's open, trap focus and handle ESC to close. */
77
91
  handleKeydown(event) {
78
92
  if (event.key === 'Escape') {
@@ -129,6 +143,10 @@ __decorate([
129
143
  decorators_1.Output(),
130
144
  __metadata("design:type", Function)
131
145
  ], MflyModalComponentController.prototype, "modalCloseCallback", void 0);
146
+ __decorate([
147
+ decorators_1.Output('&?'),
148
+ __metadata("design:type", Function)
149
+ ], MflyModalComponentController.prototype, "modalConfirmDismissCallback", void 0);
132
150
  MflyModalComponentController = __decorate([
133
151
  decorators_1.Component({
134
152
  selector: 'mflyModal',
@@ -1 +1 @@
1
- {"version":3,"file":"modal.component.js","sourceRoot":"","sources":["../../src/components/modal/modal.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,8CAAgE;AAChE,oEAA8C;AAY9C,IAAqB,4BAA4B,GAAjD,MAAqB,4BAA4B;IAgBhD,YAC2B,MAAsB,EACpB,QAA6B,EAC7B,QAA4B,EACzB,WAAmC,EACvC,OAA0B,EACjB,gBAAkC;QAL5C,WAAM,GAAN,MAAM,CAAgB;QACpB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,aAAQ,GAAR,QAAQ,CAAoB;QACzB,gBAAW,GAAX,WAAW,CAAwB;QACvC,YAAO,GAAP,OAAO,CAAmB;QACjB,qBAAgB,GAAhB,gBAAgB,CAAkB;IACpE,CAAC;IAEJ,UAAU;QAET,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI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AAC,CAAA;IACjB,WAAA,mBAAM,CAAC,kBAAkB,CAAC,CAAA;iFAA2B,uBAAgB;GA1BnD,4BAA4B,CAqJhD;kBArJoB,4BAA4B"}
@@ -1167,8 +1167,8 @@
1167
1167
  "affectsGlobalScope": false
1168
1168
  },
1169
1169
  "../src/components/modal/modal.component.ts": {
1170
- "version": "f2ba308279700a3ee8f98c1fc7ef682c3ccae362cdceb11774cf399526d3cbec",
1171
- "signature": "96d6e75dfe249910a6b5a0fc5840196bc9abb45548349ae2e70a53ec3fe5db0f",
1170
+ "version": "a802cfbd477d2de84c16dccbeea62d41ec7efbca06a505ca6e13c38763ac4fe9",
1171
+ "signature": "af08585fb7c45f35796455aa816ec1d56d3b3ce95cec3fa9b58d1d4fb9d5746d",
1172
1172
  "affectsGlobalScope": false
1173
1173
  },
1174
1174
  "../src/components/modal/index.ts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediafly/js-ui",
3
- "version": "50.4.4",
3
+ "version": "50.5.0-0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "UI components for Mediafly Angular applications",
6
6
  "repository": {
@@ -17,5 +17,23 @@
17
17
  class="c-modal__close">
18
18
  <span class="c-modal__close__x"></span><span class="sr-only" translate>CLOSE</span>
19
19
  </button>
20
+
21
+ <div
22
+ ng-if="!!$ctrl.dismissConfirmation"
23
+ class="c-modal__backdrop is-visible" tabindex="-1" role="dialog" aria-modal="true">
24
+ <div class="c-modal c-modal__dismiss_confirmation">
25
+ <div class="c-modal__header" ng-if="$ctrl.dismissConfirmation.title">
26
+ {{ $ctrl.dismissConfirmation.title }}
27
+ </div>
28
+ <div class="c-modal__body" ng-if="$ctrl.dismissConfirmation.message">
29
+ {{ $ctrl.dismissConfirmation.message }}
30
+ </div>
31
+ <div class="c-modal__footer">
32
+ <button class="o-button" ng-click="$ctrl.confirmDismiss()">{{ $ctrl.dismissConfirmation.confirmButtonText }}</button>
33
+ <button class="o-button o-button--primary" ng-click="$ctrl.cancelDismiss()">{{ $ctrl.dismissConfirmation.cancelButtonText }}</button>
34
+ </div>
35
+ </div>
36
+ </div>
20
37
  </div>
38
+
21
39
  </div>
@@ -129,3 +129,8 @@
129
129
  .c-modal__close__x::after {
130
130
  transform: rotate(-45deg);
131
131
  }
132
+
133
+ .c-modal__dismiss_confirmation {
134
+ max-width: calc(100% - 50px);
135
+ width: 600px;
136
+ }
@@ -2,6 +2,12 @@ import _ from 'lodash'
2
2
  import { Component, Inject, Input, Output } from '../decorators'
3
3
  import MflyModalService from './modal.service'
4
4
 
5
+ export interface ModalDismissConfirmation {
6
+ cancelButtonText: string
7
+ confirmButtonText: string
8
+ message: string
9
+ title: string
10
+ }
5
11
 
6
12
  @Component({
7
13
  selector: 'mflyModal',
@@ -20,12 +26,16 @@ export default class MflyModalComponentController implements ng.IComponentContro
20
26
  @Input('@') modalId: string | undefined
21
27
 
22
28
  @Output() modalCloseCallback: () => void
29
+ /** A callback that provides an optional "are you sure?" dialog when the modal is dismissed (canceled). Return `undefined` if no confirmation is required. */
30
+ @Output('&?') modalConfirmDismissCallback?: () => ModalDismissConfirmation | undefined
23
31
 
24
- protected hasHeaderTransclusion: boolean
32
+ protected dismissConfirmation: ModalDismissConfirmation | undefined
25
33
  protected hasFooterTransclusion: boolean
34
+ protected hasHeaderTransclusion: boolean
26
35
 
27
36
  private focusableElementsInModal: JQuery
28
37
  private firstFocusable: HTMLElement
38
+ private keyDownHandler: (event: KeyboardEvent) => void
29
39
  private lastFocusable: HTMLElement
30
40
 
31
41
  constructor(
@@ -35,11 +45,11 @@ export default class MflyModalComponentController implements ng.IComponentContro
35
45
  @Inject('$transclude') private $transclude: ng.ITranscludeFunction,
36
46
  @Inject('$window') private $window: ng.IWindowService,
37
47
  @Inject('mflyModalService') private mflyModalService: MflyModalService,
38
- ) {}
48
+ ) { }
39
49
 
40
50
  $onDestroy() {
41
51
 
42
- this.$window.removeEventListener('keydown', this.handleKeydown.bind(this))
52
+ this.$window.removeEventListener('keydown', this.keyDownHandler)
43
53
  this.mflyModalService.cleanupDOM()
44
54
  }
45
55
 
@@ -48,7 +58,8 @@ export default class MflyModalComponentController implements ng.IComponentContro
48
58
  this.hasHeaderTransclusion = this.$transclude.isSlotFilled('header')
49
59
  this.hasFooterTransclusion = this.$transclude.isSlotFilled('footer')
50
60
 
51
- this.$window.addEventListener('keydown', this.handleKeydown.bind(this))
61
+ this.keyDownHandler = (event) => { this.handleKeydown(event) }
62
+ this.$window.addEventListener('keydown', this.keyDownHandler)
52
63
 
53
64
  // Set up an observer for disabledness changes so that our focus trap will update itself.
54
65
  const observer = new MutationObserver(mutations => {
@@ -90,7 +101,12 @@ export default class MflyModalComponentController implements ng.IComponentContro
90
101
  }, 50)
91
102
  }
92
103
 
93
- dismiss(): void {
104
+ protected cancelDismiss(): void {
105
+
106
+ this.dismissConfirmation = undefined
107
+ }
108
+
109
+ protected confirmDismiss(): void {
94
110
 
95
111
  if (this.$attrs.modalCloseCallback) {
96
112
  this.modalCloseCallback()
@@ -98,6 +114,19 @@ export default class MflyModalComponentController implements ng.IComponentContro
98
114
  this.mflyModalService.dismiss()
99
115
  }
100
116
 
117
+ protected dismiss(): void {
118
+
119
+ this.$timeout(() => {
120
+ this.dismissConfirmation = this.modalConfirmDismissCallback?.()
121
+
122
+ if (this.dismissConfirmation) {
123
+ return
124
+ }
125
+
126
+ this.confirmDismiss()
127
+ })
128
+ }
129
+
101
130
  /** While the modal's open, trap focus and handle ESC to close. */
102
131
  private handleKeydown(event: KeyboardEvent): void {
103
132