comand-component-library 4.3.15 → 4.3.16

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,36 +1,28 @@
1
1
  <template>
2
2
  <!-- begin CmdTooltip ---------------------------------------------------------------------------------------- -->
3
- <div v-if="tooltipVisibility" :class="['cmd-tooltip', validationStatus]" popover ref="tooltip" role="tooltip" :id="popoverTargetName">
4
- <div v-if="cmdHeadline || iconClose.show" class="headline-wrapper">
5
- <!-- begin CmdHeadline -->
6
- <CmdHeadline
7
- v-if="cmdHeadline"
8
- v-bind="cmdHeadline"
9
- />
10
- <!-- end CmdHeadline -->
3
+ <div :class="['cmd-tooltip', validationStatus]" popover="manual" ref="tooltip" role="tooltip"
4
+ :id="popoverTargetName" @mouseenter="handleTooltipEnter" @mouseleave="handleTooltipLeave"
5
+ :style="'position-anchor:' + positionAnchor"
6
+ >
7
+ <!-- begin CmdHeadline -->
8
+ <CmdHeadline v-if="cmdHeadline" v-bind="cmdHeadline" />
9
+ <!-- end CmdHeadline -->
11
10
 
12
- <!-- begin icon to close tooltip -->
13
- <button
14
- v-if="iconClose.show && toggleVisibilityByClick"
15
- type="button"
16
- class="close-tooltip no-style"
17
- popovertargetaction="hide"
18
- :popovertarget="popoverTargetName"
19
- :title="iconClose.tooltip"
20
- >
21
- <!-- begin CmdIcon -->
22
- <CmdIcon :iconClass="iconClose.iconClass" :type="iconClose.iconType"/>
23
- <!-- end CmdIcon -->
24
- </button>
25
- <!-- end icon to close tooltip -->
26
- </div>
11
+ <!-- begin icon to close tooltip -->
12
+ <button v-if="showCloseIcon" type="button" class="close-tooltip no-style"
13
+ popovertargetaction="hide" :popovertarget="popoverTargetName" :title="iconClose.tooltip">
14
+ <!-- begin CmdIcon -->
15
+ <CmdIcon :iconClass="iconClose.iconClass" :type="iconClose.iconType" />
16
+ <!-- end CmdIcon -->
17
+ </button>
18
+ <!-- end icon to close tooltip -->
27
19
 
28
20
  <!-- begin slot-content -->
29
21
  <slot>
30
- {{ tooltipText }}
22
+ <div v-html="tooltipText"></div>
31
23
  </slot>
32
24
  <!-- end slot-content -->
33
- <!-- end CmdTooltip ---------------------------------------------------------------------------------------- -->
25
+ <!-- end CmdTooltip ---------------------------------------------------------------------------------------- -->
34
26
  </div>
35
27
  </template>
36
28
 
@@ -39,9 +31,8 @@ export default {
39
31
  name: "CmdTooltip",
40
32
  data() {
41
33
  return {
42
- tooltipVisibility: false,
43
- pointerX: 0,
44
- pointerY: 0
34
+ triggerElement: null,
35
+ tooltipVisibility: false
45
36
  }
46
37
  },
47
38
  inject: {
@@ -52,19 +43,20 @@ export default {
52
43
  props: {
53
44
  /**
54
45
  * name for popover-target (will be set as id for popover and must correspond popovertarget-value of button that opens the popup)
46
+ *
47
+ * @requiered-for-accessibility
55
48
  */
56
49
  popoverTargetName: {
57
50
  type: String,
58
- required: true
59
- },
51
+ required: false
52
+ },
60
53
  /**
61
- * properties for CmdHeadline-component
54
+ * positionAnchor
62
55
  */
63
- cmdHeadline: {
64
- type: Object,
65
- default() {
66
- }
67
- },
56
+ positionAnchor: {
57
+ type: String,
58
+ required: false
59
+ },
68
60
  /**
69
61
  * text shown as tooltip
70
62
  */
@@ -75,11 +67,26 @@ export default {
75
67
  /**
76
68
  * delay (in milliseconds) until tooltip will be shown
77
69
  *
70
+ * only works on hover/leave
71
+ *
78
72
  * toggleVisibilityByClick-property must be false
79
73
  */
80
74
  delayToShowTooltip: {
81
75
  type: Number,
82
76
  default: 0
77
+ },
78
+ /**
79
+ * delay (in milliseconds) until tooltip will be hidden
80
+ *
81
+ * only works on hover/leave
82
+ *
83
+ * toggleVisibilityByClick-property must be false
84
+ *
85
+ * minimum should be set to 100 to avoid flickering while user moves mouse over tooltip itself
86
+ */
87
+ delayToHideTooltip: {
88
+ type: Number,
89
+ default: 100
83
90
  },
84
91
  /**
85
92
  * id of related input-element
@@ -121,7 +128,7 @@ export default {
121
128
  default() {
122
129
  return {
123
130
  show: true,
124
- iconClass: "icon-cancel",
131
+ iconClass: "icon-cancel-circle",
125
132
  tooltip: "Close this tooltip!"
126
133
  }
127
134
  }
@@ -129,106 +136,86 @@ export default {
129
136
  /**
130
137
  * enable toggling tooltip-visibility by click
131
138
  */
132
- toggleVisibilityByClick: {
139
+ showCloseIcon: {
133
140
  type: Boolean,
134
141
  default: false
142
+ },
143
+ /**
144
+ * properties for CmdHeadline-component
145
+ */
146
+ cmdHeadline: {
147
+ type: Object,
148
+ requiured: false
135
149
  }
136
150
  },
137
151
  mounted() {
138
- /*
139
- if (this.relatedId) {
140
- const relatedElement = document.getElementById(this.relatedId)
141
-
142
- if (relatedElement) {
143
- const scrollContainerSelector = this.injectScrollContainer || this.scrollContainer
152
+ // provide the container the tooltip scrolls in (and should react to)
153
+ const scrollContainerSelector = this.injectScrollContainer || this.scrollContainer
144
154
 
145
- if (scrollContainerSelector) {
146
- const scrollContainerElement = document.querySelector(scrollContainerSelector)
155
+ if (scrollContainerSelector) {
156
+ const scrollContainerElement = document.querySelector(scrollContainerSelector)
147
157
 
148
- if(scrollContainerElement) {
149
- scrollContainerElement.addEventListener("scroll", this.hideTooltip) // avoid fixed tooltip on scroll
150
- } else {
151
- console.warn( "'CmdTooltip-Component': Element accessed by " + scrollContainerSelector + " does not exist! Please provide selector for an existing element!")
152
- }
158
+ if (scrollContainerElement) {
159
+ scrollContainerElement.addEventListener("scroll", this.hideTooltip) // avoid fixed tooltip on scroll
160
+ } else {
161
+ console.warn("'CmdTooltip-Component': Element accessed by " + scrollContainerSelector + " does not exist! Please provide selector for an existing element!")
162
+ }
163
+ }
153
164
 
154
- document.addEventListener("keyup", this.hideTooltipOnEsc) // close tooltip by using "escape"-key
155
- }
165
+ if(this.relatedId) {
166
+ // get eleemnt that triggers the tooltip
167
+ this.triggerElement = document.getElementById(this.relatedId)
168
+ if (!this.triggerElement) return
169
+
170
+ // add event listeners
171
+ this.triggerElement.addEventListener("mouseenter", this.handleTriggerEnter)
172
+ this.triggerElement.addEventListener("mouseleave", this.handleTriggerLeave)
173
+ }
174
+ },
175
+ beforeUnmount() {
176
+ if(this.relatedId) {
177
+ if (!this.triggerElement) return
156
178
 
157
- if (this.toggleVisibilityByClick) {
158
- relatedElement.addEventListener("click", this.toggleTooltipVisibility)
159
- } else {
160
- relatedElement.addEventListener("mouseenter", this.showTooltip)
161
- relatedElement.addEventListener("mouseleave", this.hideTooltip)
162
- }
163
- }
179
+ this.triggerElement.removeEventListener("mouseenter", this.handleTriggerEnter)
180
+ this.triggerElement.removeEventListener("mouseleave", this.handleTriggerLeave)
164
181
  }
165
- */
182
+
166
183
  },
167
184
  methods: {
168
- toggleTooltipVisibility(event) {
169
- this.getPointerPosition(event)
170
- this.tooltipVisibility = !this.tooltipVisibility
185
+ showTooltip() {
186
+ // use native method on element to show popover/tooltip
187
+ this.$refs.tooltip.showPopover()
171
188
  },
172
- showTooltip(event) {
173
- // if delay is set
174
- if (this.delayToShowTooltip > 0) {
175
- setTimeout(() => {
176
- this.toggleVisibility(event)
177
- }, this.delayToShowTooltip)
178
- } else {
179
- this.toggleVisibility(event)
180
- }
189
+ hideTooltip() {
190
+ // use native method on element to close popover/tooltip
191
+ this.$refs.tooltip.hidePopover()
181
192
  },
182
- toggleVisibility(event) {
183
- if (!this.toggleVisibilityByClick) {
184
- this.tooltipVisibility = true
185
- }
186
- this.getPointerPosition(event)
193
+ handleTriggerEnter() {
194
+ // small delay prevents flicker when moving to tooltip
195
+ setTimeout(() => {
196
+ if (!this.tooltipVisibility) {
197
+ this.showTooltip()
198
+ }
199
+ }, this.delayToShowTooltip)
187
200
  },
188
- hideTooltipOnEsc(event) {
189
- if (this.allowEscapeKey) {
190
- if (event.key === 'Escape' || event.key === 'Esc') {
201
+ handleTriggerLeave() {
202
+ // small delay prevents flicker when moving to tooltip
203
+ setTimeout(() => {
204
+ if (!this.tooltipVisibility) {
191
205
  this.hideTooltip()
192
206
  }
193
- }
207
+ }, this.delayToHideTooltip)
194
208
  },
195
- hideTooltip() {
196
- this.tooltipVisibility = false
209
+ handleTooltipEnter() {
210
+ this.tooltipVisibility = true
197
211
  },
198
- getPointerPosition(event) {
199
- this.pointerX = event.clientX
200
- this.pointerY = event.clientY
212
+ handleTooltipLeave() {
213
+ this.tooltipVisibility = false
214
+ this.$refs.tooltip.hidePopover()
201
215
  }
202
216
  },
203
217
  unmounted() {
204
- if (this.relatedId) {
205
- const relatedElement = document.getElementById(this.relatedId)
206
-
207
- if (relatedElement) {
208
- document.removeEventListener("scroll", this.hideTooltip)
209
- document.removeEventListener("keyup", this.hideTooltipOnEsc)
210
-
211
- if (this.toggleVisibilityByClick) {
212
- relatedElement.removeEventListener("click", this.toggleTooltipVisibility)
213
- } else {
214
- relatedElement.removeEventListener("mouseenter", this.showTooltip)
215
- relatedElement.removeEventListener("mouseleave", this.showTooltip)
216
- }
217
- }
218
- }
219
- },
220
- watch: {
221
- /*
222
- tooltipVisibility() {
223
- if (this.tooltipVisibility) {
224
- this.$nextTick(() => {
225
- const verticalOffset = 25
226
- // this.$refs.tooltip.addEventListener("keyup", this.hideTooltip)
227
- this.$refs.tooltip.style.left = (this.pointerX / 10) + "rem"
228
- this.$refs.tooltip.style.top = ((this.pointerY + verticalOffset) / 10) + "rem"
229
- })
230
- }
231
- }*/
218
+ document.removeEventListener("scroll", this.hideTooltip)
232
219
  }
233
220
  }
234
221
  </script>
@@ -246,10 +233,11 @@ export default {
246
233
  border-color: hsl(220, 2%, 25%);
247
234
  border-right-color: hsl(240, 1%, 81%);
248
235
  border-bottom-color: hsl(240, 1%, 81%);
249
- display: flex;
250
- flex-direction: column;
251
236
 
252
- &.error, &.warning, &.success, &.info {
237
+ &.error,
238
+ &.warning,
239
+ &.success,
240
+ &.info {
253
241
  border-color: var(--status-color);
254
242
  }
255
243
 
@@ -272,7 +260,7 @@ export default {
272
260
  .headline-wrapper {
273
261
  display: flex;
274
262
 
275
- > a {
263
+ >button {
276
264
  margin-left: auto !important;
277
265
 
278
266
  [class*="icon-"] {
@@ -280,7 +268,9 @@ export default {
280
268
  font-size: var(--font-size-small);
281
269
  color: var(--hyperlink-color);
282
270
 
283
- &:hover, &:active, &:focus {
271
+ &:hover,
272
+ &:active,
273
+ &:focus {
284
274
  color: var(--hyperlink-color-highlighted);
285
275
  }
286
276
  }
@@ -5,8 +5,8 @@
5
5
  <section v-if="useInnerSection" :class="setInnerClass" :id="anchorId">
6
6
  <!-- begin cmd-headline -->
7
7
  <CmdHeadline
8
- v-if="cmdHeadline"
9
- v-bind="cmdHeadline"
8
+ v-if="cmdHeadline?.headlineText"
9
+ v-bind="cmdHeadlineProperties"
10
10
  />
11
11
  <!-- end cmd-headline -->
12
12
 
@@ -112,7 +112,7 @@ export default {
112
112
  /**
113
113
  * properties for CmdHeadline-component
114
114
  *
115
- * @requiredForAccessibilty
115
+ * @requiredForAccessibilty: true
116
116
  */
117
117
  cmdHeadline: {
118
118
  type: Object,
@@ -120,6 +120,12 @@ export default {
120
120
  }
121
121
  },
122
122
  computed: {
123
+ cmdHeadlineProperties() {
124
+ return {
125
+ headlineLevel: 2,
126
+ ...this.cmdHeadline
127
+ }
128
+ },
123
129
  setInnerClass() {
124
130
  if (this.useFullDeviceWidth) {
125
131
  return "full-width"
package/src/index.js CHANGED
@@ -53,7 +53,6 @@ export { default as CmdTextImageBlock } from '@/components/CmdTextImageBlock.vue
53
53
  export { default as CmdThumbnailScroller } from '@/components/CmdThumbnailScroller.vue'
54
54
  export { default as CmdToggleDarkMode } from '@/components/CmdToggleDarkMode.vue'
55
55
  export { default as CmdTooltip } from '@/components/CmdTooltip.vue'
56
- export { default as CmdTooltipForFormElements } from '@/components/CmdTooltipForFormElements.vue'
57
56
  export { default as CmdUploadForm } from '@/components/CmdUploadForm.vue'
58
57
  export { default as CmdWidthLimitationWrapper } from '@/components/CmdWidthLimitationWrapper.vue'
59
58
  export { default as EditComponentWrapper } from '@/components/EditComponentWrapper.vue'
@@ -14,6 +14,13 @@ export default {
14
14
  GlobalDefaultMessageProperties
15
15
  ],
16
16
  props: {
17
+ /**
18
+ *
19
+ */
20
+ useCustomTooltip: {
21
+ type: Boolean,
22
+ default: true
23
+ },
17
24
  /**
18
25
  * validation message shown on clicking the status-icon of a form-element with state
19
26
  */
@@ -1,113 +0,0 @@
1
- <template>
2
- <!-- begin CmdTooltipForFormElements ---------------------------------------------------------------------------------------- -->
3
- <!-- begin CmdTooltip -->
4
- <CmdTooltip
5
- ref="tooltip"
6
- class="cmd-tooltip-for-form-elements box"
7
- :class="validationStatus"
8
- :relatedId="relatedId"
9
- :scrollContainer="scrollContainerForTooltip"
10
- :popoverTargetName="popoverTargetName"
11
- :toggle-visibility-by-click="true">
12
-
13
- <!-- begin CmdListOfRequirements -->
14
- <CmdListOfRequirements
15
- v-if="cmdListOfRequirementsProperties.showRequirements"
16
- v-bind="cmdListOfRequirementsProperties"
17
- />
18
- <!-- end CmdListOfRequirements -->
19
- </CmdTooltip>
20
- <!-- end CmdTooltip -->
21
- <!-- end CmdTooltipForFormElements ---------------------------------------------------------------------------------------- -->
22
- </template>
23
-
24
- <script>
25
- export default {
26
- name: "CmdTooltipForFormElements",
27
- props: {
28
- /**
29
- * name for popover-target (will be set as id for popover and must correspond popovertarget-value of button that opens the popup)
30
- */
31
- popoverTargetName: {
32
- type: String
33
- },
34
- /**
35
- * specify a scroll-container which scrolling hides the tooltip
36
- */
37
- scrollContainerForTooltip: {
38
- type: String,
39
- required: false
40
- },
41
- /**
42
- * related-id for CmdTooltip-component
43
- */
44
- relatedId: {
45
- type: String,
46
- default: ""
47
- },
48
- /**
49
- * validation-status for CmdTooltip-component
50
- *
51
- * @allowedValues: "", error, warning, success, info
52
- *
53
- * @affectsStyling: true
54
- */
55
- validationStatus: {
56
- type: String,
57
- default: "",
58
- validator(value) {
59
- return value === "" ||
60
- value === "error" ||
61
- value === "warning" ||
62
- value === "success" ||
63
- value === "info"
64
- }
65
- },
66
- /**
67
- * properties for CmdListOfRequirements-component
68
- */
69
- cmdListOfRequirements: {
70
- type: Object,
71
- required: false
72
- }
73
- },
74
- computed: {
75
- cmdListOfRequirementsProperties() {
76
- return {
77
- showRequirements: true,
78
- validationTooltip: "",
79
- inputRequirements: [],
80
- inputAttributes: {},
81
- showHeadline: true,
82
- inputModelValue: "",
83
- helplink: {},
84
- labelText: "",
85
- ...this.cmdListOfRequirements
86
- }
87
- }
88
- },
89
- methods: {
90
- hideTooltip() {
91
- // close tooltip by calling function from CmdTooltip using $refs
92
- this.$refs.tooltip.hideTooltip()
93
- }
94
- }
95
- }
96
- </script>
97
-
98
- <style>
99
- /* begin cmd-tooltip-for-form-elements ---------------------------------------------------------------------------------------- */
100
- .cmd-tooltip-for-form-elements {
101
- .headline-wrapper {
102
- a[class*="icon-"], a:has([class*="icon-"]) {
103
- margin-left: auto;
104
-
105
- &:hover, &:active, &:focus {
106
- background: none;
107
- }
108
- }
109
- }
110
- }
111
-
112
- /* end cmd-tooltip-for-form-elements ---------------------------------------------------------------------------------------- */
113
- </style>