@eturnity/eturnity_reusable_components 7.4.2 → 7.4.3-EPDM-9694.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.4.2",
3
+ "version": "7.4.3-EPDM-9694.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -23,7 +23,7 @@
23
23
  v-if="infoTextMessage"
24
24
  :text="infoTextMessage"
25
25
  borderColor="#ccc"
26
- :size="fontSize ? fontSize : '16px'"
26
+ :size="infoTextSize"
27
27
  :alignText="infoTextAlign"
28
28
  />
29
29
  </label-wrapper>
@@ -394,6 +394,10 @@ export default {
394
394
  required: false,
395
395
  default: true
396
396
  },
397
+ infoTextSize: {
398
+ required: false,
399
+ default: '14px'
400
+ },
397
401
  dataId: {
398
402
  type: String,
399
403
  default: ''
@@ -3,7 +3,6 @@
3
3
  :position="position"
4
4
  :isOpen="isOpen"
5
5
  :class="{ visible: isOpen, hidden: !isOpen }"
6
- @click.native="onOutsideClose()"
7
6
  :backdrop="backdrop"
8
7
  >
9
8
  <modal-container @click.stop>
@@ -21,10 +20,13 @@
21
20
  </template>
22
21
 
23
22
  <script>
23
+ // Rules: (as defined in https://e-turnity.atlassian.net/browse/EPDM-9694)
24
+ // 1. On clicking the “escape” key, close the modal onCloseModal()
25
+ // 2. Always prevent outside close
24
26
  // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
25
27
  // This is a more flexible modal box, where the parent can decide how the body of the modal looks
26
28
  // To use:
27
- // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
29
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true">
28
30
  // <div>Data....</div>
29
31
  // </modal>
30
32
 
@@ -118,10 +120,6 @@ export default {
118
120
  required: true,
119
121
  default: false
120
122
  },
121
- preventOutsideClose: {
122
- required: false,
123
- default: false
124
- },
125
123
  isLoading: {
126
124
  required: false,
127
125
  default: false
@@ -139,20 +137,27 @@ export default {
139
137
  default: 'fixed'
140
138
  }
141
139
  },
140
+ beforeDestroy() {
141
+ window.removeEventListener('keydown', this.handleKeyDown)
142
+ },
142
143
  methods: {
143
144
  onCloseModal() {
144
145
  this.$emit('on-close')
145
146
  },
146
- onOutsideClose() {
147
- // If true, then only allow closing to come from clicking the X or wherever the onCloseModal is called
148
- if (!this.preventOutsideClose) {
149
- this.$emit('on-close')
147
+ handleKeyDown({ key }) {
148
+ if (key === 'Escape') {
149
+ this.onCloseModal()
150
150
  }
151
151
  }
152
152
  },
153
153
  watch: {
154
- isOpen: function (newVal) {
155
- document.body.style.overflow = newVal ? 'hidden' : ''
154
+ isOpen: function (isOpen) {
155
+ document.body.style.overflow = isOpen ? 'hidden' : ''
156
+ if (isOpen) {
157
+ window.addEventListener('keydown', this.handleKeyDown)
158
+ } else {
159
+ window.removeEventListener('keydown', this.handleKeyDown)
160
+ }
156
161
  }
157
162
  }
158
163
  }