comand-component-library 4.3.28 → 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.
Files changed (61) hide show
  1. package/dist/comand-component-library.css +1 -1
  2. package/dist/comand-component-library.js +9587 -9482
  3. package/dist/styles/demopage-only.css +12 -2
  4. package/package.json +47 -46
  5. package/src/ComponentLibrary.vue +2697 -2688
  6. package/src/assets/data/component-structure.json +1 -1
  7. package/src/assets/data/form-elements.json +224 -224
  8. package/src/assets/data/social-networks-page-by-json.json +43 -43
  9. package/src/assets/styles/component-library-global-styles.scss +296 -295
  10. package/src/componentSettingsDataAndControls.vue +1 -18
  11. package/src/components/CmdAccordion.vue +1 -1
  12. package/src/components/CmdAddressData.vue +6 -1
  13. package/src/components/CmdAddressDataItem.vue +6 -1
  14. package/src/components/CmdBasicForm.vue +2 -2
  15. package/src/components/CmdBox.vue +1103 -1092
  16. package/src/components/CmdBoxWrapper.vue +7 -1
  17. package/src/components/CmdBreadcrumbs.vue +2 -2
  18. package/src/components/CmdCodeOutput.vue +1 -1
  19. package/src/components/CmdCookieDisclaimer.vue +480 -480
  20. package/src/components/CmdFakeSelect.vue +930 -916
  21. package/src/components/CmdFlexibleScrollContainer.vue +42 -42
  22. package/src/components/CmdForm.vue +481 -481
  23. package/src/components/CmdFormElement.vue +1110 -1091
  24. package/src/components/CmdFormFilters.vue +146 -146
  25. package/src/components/CmdGoogleMaps.vue +1 -1
  26. package/src/components/CmdHeadline.vue +21 -4
  27. package/src/components/CmdIcon.vue +8 -2
  28. package/src/components/CmdImage.vue +14 -16
  29. package/src/components/CmdImageZoom.vue +9 -8
  30. package/src/components/CmdInputGroup.vue +436 -435
  31. package/src/components/CmdLink.vue +1 -1
  32. package/src/components/CmdList.vue +1 -1
  33. package/src/components/CmdListOfRequirements.vue +192 -192
  34. package/src/components/CmdLoginForm.vue +618 -618
  35. package/src/components/CmdMailToolFilter.vue +217 -217
  36. package/src/components/CmdMainNavigation.vue +581 -572
  37. package/src/components/CmdMultistepFormProgressBar.vue +9 -9
  38. package/src/components/CmdNewsletterSubscription.vue +199 -199
  39. package/src/components/CmdPagination.vue +4 -2
  40. package/src/components/CmdParagraph.vue +10 -4
  41. package/src/components/CmdProgressBar.vue +72 -72
  42. package/src/components/CmdSiteHeader.vue +382 -389
  43. package/src/components/CmdSiteSearch.vue +420 -420
  44. package/src/components/CmdSiteWrapper.vue +12 -5
  45. package/src/components/CmdSlideshow.vue +519 -519
  46. package/src/components/CmdSmartSearch.vue +291 -291
  47. package/src/components/CmdSystemMessage.vue +3 -2
  48. package/src/components/CmdTable.vue +401 -401
  49. package/src/components/CmdTabs.vue +262 -262
  50. package/src/components/CmdTag.vue +1 -1
  51. package/src/components/CmdTextImageBlock.vue +8 -2
  52. package/src/components/CmdThumbnailScroller.vue +0 -7
  53. package/src/components/CmdToggleDarkMode.vue +13 -11
  54. package/src/components/CmdTooltip.vue +305 -301
  55. package/src/components/CmdUploadForm.vue +1299 -1305
  56. package/src/components/CmdWidthLimitationWrapper.vue +1 -1
  57. package/src/components/EditComponentWrapper.vue +5 -5
  58. package/src/index.js +5 -0
  59. package/src/main.js +4 -3
  60. package/src/utils/template.js +57 -0
  61. package/src/assets/styles/template.css +0 -1
@@ -1,916 +1,930 @@
1
- <template>
2
- <!-- begin CmdFakeSelect ---------------------------------------------------------------------------------------- -->
3
- <div
4
- :class="[
5
- validationStatus,
6
- 'cmd-fake-select label',
7
- {
8
- color: type === 'color',
9
- 'has-state': validationStatus && validationStatus !== 'none',
10
- disabled: $attrs.disabled
11
- }
12
- ]"
13
- :title="$attrs.title"
14
- role="listbox"
15
- :aria-labelledby="htmlId"
16
- :aria-required="$attrs.required !== undefined"
17
- ref="fakeselect"
18
- >
19
- <template v-if="showLabel">
20
- <!-- begin label -->
21
- <span class="label-text">
22
- <span :id="htmlId">{{ labelText }}<sup v-if="$attrs.required !== undefined" aria-hidden="true">*</sup>
23
- </span>
24
-
25
- <!-- begin status-icon (linked with tooltip) -->
26
- <button v-if="($attrs.required || inputRequirements.length) && showStatusIcon"
27
- type="button"
28
- class="no-style"
29
- :title="validationTooltip"
30
- :aria-errormessage="tooltipId"
31
- aria-live="assertive"
32
- :popovertarget="'tooltip-target-' + htmlId"
33
- :style="'anchor-name: --tooltip-anchor-' + htmlId"
34
- >
35
- <!-- begin CmdIcon -->
36
- <CmdIcon :iconClass="getStatusIconClass" />
37
- <!-- end CmdIcon -->
38
- </button>
39
- <!-- end status-icon (linked with tooltip) -->
40
-
41
- <!-- begin CmdTooltip -->
42
- <CmdTooltip
43
- ref="tooltip"
44
- :class="['cmd-tooltip-for-form-elements box', validationStatus]"
45
- :id="'tooltip-target-' + htmlId"
46
- :scrollContainer="scrollContainerForTooltip"
47
- :popoverTargetName="'tooltip-target-' + htmlId"
48
- :validationStatus="validationStatus"
49
- :role="validationStatus === 'error' ? 'alert' : 'dialog'"
50
- :toggle-visibility-by-click="true"
51
- :style="'position-anchor: --tooltip-anchor-' + htmlId"
52
- >
53
-
54
- <!-- begin CmdListOfRequirements -->
55
- <CmdListOfRequirements
56
- v-if="cmdListOfRequirementsProperties.showRequirements"
57
- v-bind="cmdListOfRequirementsProperties"
58
- />
59
- <!-- end CmdListOfRequirements -->
60
- </CmdTooltip>
61
- <!-- end CmdTooltip -->
62
- </span>
63
- <!-- end label -->
64
- </template>
65
- <ul :class="{'open': showOptions}" @clickout="closeOptions" :aria-expanded="showOptions">
66
- <li>
67
- <!-- begin default/selected-option -->
68
- <a href="#" @click.prevent="toggleOptions" @blur="onBlur" :title="optionIcon?.tooltip">
69
- <!-- begin show flag -->
70
- <img v-if="type === 'country' && optionCountry"
71
- :src="pathFlag(optionCountry)"
72
- :alt="optionCountry"
73
- :class="['flag', optionCountry]"/>
74
- <!-- end show flag -->
75
-
76
- <!-- begin show color-box -->
77
- <span v-else-if="type === 'color'" :style="'background: ' + optionColor"></span>
78
- <!-- end show color-box -->
79
-
80
- <!-- begin optional icon -->
81
- <!-- begin CmdIcon -->
82
- <CmdIcon v-if="optionIcon?.iconClass" :type="optionIcon?.iconType"
83
- :iconClass="optionIcon?.iconClass"/>
84
- <!-- end CmdIcon -->
85
- <!-- end optional icon -->
86
-
87
- <!-- begin text -->
88
- <span v-if="optionName" class="option-name">{{ optionName }}</span>
89
- <!-- end text -->
90
-
91
- <!-- begin custom dropdown-icon -->
92
- <!-- begin CmdIcon -->
93
- <CmdIcon
94
- v-if="iconDropdown"
95
- :iconClass="iconDropdown.iconClass"
96
- :type="iconDropdown.iconType"
97
- :title="iconDropdown.tooltip"
98
- />
99
- <!-- end CmdIcon -->
100
- <!-- end custom dropdown-icon -->
101
- </a>
102
- <!-- end default/selected-option-->
103
-
104
- <!-- begin default dropdown (incl. optional icon) -->
105
- <ul v-if="type === 'default' && showOptions" role="listbox">
106
- <li v-for="(option, index) in selectData" :key="index" role="option"
107
- :aria-selected="option.value === modelValue">
108
- <!-- begin type 'href' -->
109
- <a v-if="optionLinkType === 'href'"
110
- href="#" @click.prevent="selectOption(option.value)"
111
- :class="{'active' : option.value === modelValue}"
112
- :title="option.tooltip"
113
- >
114
- <!-- begin CmdIcon -->
115
- <CmdIcon v-if="option.iconClass" :iconClass="option.iconClass" :type="option.iconType"/>
116
- <!-- end CmdIcon -->
117
- <span v-if="option.text">{{ option.text }}</span>
118
- </a>
119
- <!-- end type 'href' -->
120
-
121
- <!-- begin type 'router' -->
122
- <router-link v-if="optionLinkType === 'router'" to="#"
123
- @click.prevent="selectOption(option.value)"
124
- :class="{'active' : option.value === modelValue}">
125
- <!-- begin CmdIcon -->
126
- <CmdIcon v-if="option.iconClass" :iconClass="option.iconClass" :type="option.iconType"/>
127
- <!-- end CmdIcon -->
128
- <span>{{ option.text }}</span>
129
- </router-link>
130
- <!-- end type 'router' -->
131
- </li>
132
- </ul>
133
- <!-- end default dropdown (incl. optional icon) -->
134
-
135
- <!-- begin dropdown with checkboxes/countries/colors -->
136
- <ul v-else-if="type !== 'default' && type !== 'content' && showOptions"
137
- :class="{'checkbox-options': type === 'checkboxOptions'}" :aria-expanded="showOptions">
138
- <li v-for="(option, index) in selectData" :key="index">
139
- <!-- begin checkboxes -->
140
- <label v-if="type === 'checkboxOptions'" :for="'option-' + (index + 1)"
141
- :class="{'active' : modelValue.includes(`${option.value}`)}">
142
- <input type="checkbox" :value="option.value" @change="optionSelect"
143
- :checked="compareValues(option.value)" :id="'option-' + (index + 1)"/>
144
- <span>{{ option.text }}</span>
145
- </label>
146
- <!-- end checkboxes -->
147
-
148
- <!-- begin country-flags -->
149
- <a v-else-if="type === 'country'" href="#"
150
- @click.prevent="selectOption(option.value)"
151
- :class="{'active' : option.value === modelValue}">
152
- <img class="flag" :src="pathFlag(option.value)"
153
- :alt="option.text"/>
154
- <span>{{ option.text }}</span>
155
- </a>
156
- <!-- end country-flags -->
157
-
158
- <!-- begin color-boxes -->
159
- <a v-else-if="type === 'color'" href="#" @click.prevent="selectOption(option.value)"
160
- :class="{'active' : option.value === modelValue}">
161
- <span class="color" :style="'background: ' + option.value"></span>
162
- <span>{{ option.text }}</span>
163
- </a>
164
- <!-- end color-boxes -->
165
- </li>
166
-
167
- <!-- begin (de)select all options -->
168
- <li v-if="showSelectAllOptions && type === 'checkboxOptions'" class="select-all-options">
169
- <a href="#" @click.prevent="toggleAllOptions">
170
- <!-- begin CmdIcon -->
171
- <CmdIcon v-if="!allOptionsSelected" :iconClass="iconSelectAllOptions.iconClass"
172
- :type="iconSelectAllOptions.iconType"/>
173
- <CmdIcon v-else :iconClass="iconDeselectAllOptions.iconClass"
174
- :type="iconDeselectAllOptions.iconType"/>
175
- <!-- end CmdIcon -->
176
- <span>{{ selectAllOptionsText }}</span>
177
- </a>
178
- </li>
179
- <!-- end (de)select all options -->
180
- </ul>
181
- <!-- end dropdown with checkboxes/countries/colors -->
182
-
183
- <!-- begin dropdown with slot -->
184
- <template v-else-if="type === 'content' && showOptions" :aria-expanded="showOptions">
185
- <slot></slot>
186
- </template>
187
- <!-- end dropdown with slot -->
188
- </li>
189
- </ul>
190
- </div>
191
- <!-- end CmdFakeSelect ---------------------------------------------------------------------------------------- -->
192
- </template>
193
-
194
- <script>
195
- // import mixins
196
- import I18n from "../mixins/I18n"
197
- import DefaultMessageProperties from "../mixins/CmdFakeSelect/DefaultMessageProperties"
198
- import FieldValidation from "../mixins/FieldValidation"
199
- import Identifier from "../mixins/Identifier"
200
- import Tooltip from "../mixins/Tooltip"
201
- import {createUuid} from "../utils/common.js"
202
-
203
- export default {
204
- name: 'CmdFakeSelect',
205
- inheritAttrs: false,
206
- mixins: [
207
- I18n,
208
- DefaultMessageProperties,
209
- FieldValidation,
210
- Identifier,
211
- Tooltip
212
- ],
213
- emits: ["validation-status-change", "update:modelValue"],
214
- data() {
215
- return {
216
- showOptions: false,
217
- validationStatus: "",
218
- allOptionsSelected: false
219
- }
220
- },
221
- props: {
222
- /**
223
- * name for popover-target (will be set as id for popover and must correspond popovertarget-value of button that opens the popup)
224
- */
225
- tooltipPopoverTargetName: {
226
- type: String,
227
- default: 'tooltip-target-' + createUuid()
228
- },
229
- /**
230
- * specify a scroll-container which scrolling hides the tooltip
231
- */
232
- scrollContainerForTooltip: {
233
- type: String,
234
- required: false
235
- },
236
- /**
237
- * set different default selectbox-types for
238
- *
239
- * @allowedValues: default, color, country, content, checkboxOptions
240
- */
241
- type: {
242
- type: String,
243
- default: "default",
244
- validator(value) {
245
- return value === "default" ||
246
- value === "color" ||
247
- value === "country" ||
248
- value === "content" ||
249
- value === "checkboxOptions"
250
- }
251
- },
252
- /**
253
- * set type of option-links
254
- *
255
- * @allowedValues: href, router
256
- */
257
- optionLinkType: {
258
- type: String,
259
- default: "href",
260
- validator(value) {
261
- return value === "href" ||
262
- value === "router"
263
- }
264
- },
265
- /**
266
- * set default v-model (must be named modelValue in Vue3)
267
- */
268
- modelValue: {
269
- type: [String, Number, Array],
270
- default: ""
271
- },
272
- /**
273
- * list of options to select (incl. displayed names and values)
274
- *
275
- * type-property must be set to "checkboxOptions"
276
- */
277
- selectData: {
278
- type: Array,
279
- required: false
280
- },
281
- /**
282
- * toggles option to (de)select all options in a checkbox-list
283
- *
284
- * type-property must be set to "checkboxOptions"
285
- */
286
- showSelectAllOptions: {
287
- type: Boolean,
288
- default: true
289
- },
290
- /**
291
- * status (i.e. for validation)
292
- *
293
- * @allowedValues: "" , error, warning, success, info
294
- * @affectsStyling: true
295
- */
296
- status: {
297
- type: String,
298
- required: false,
299
- validator(value) {
300
- return value === "" ||
301
- value === "error" ||
302
- value === "warning" ||
303
- value === "success" ||
304
- value === "info"
305
- }
306
- },
307
- /**
308
- * icon for dropdown-icon (i.e. an angle/arrow)
309
- *
310
- * @requiredForAccessibility: partial
311
- * @defaultIcon: icon-chevron-one-stripe-down
312
- */
313
- iconDropdown: {
314
- type: Object,
315
- default() {
316
- return {
317
- iconClass: "icon-chevron-one-stripe-down",
318
- tooltip: "Toggle dropdown visibility",
319
- iconType: "auto"
320
- }
321
- }
322
- },
323
- /**
324
- * label-text for fake-select
325
- *
326
- * @requiredForAccessibility: true
327
- */
328
- labelText: {
329
- type: String,
330
- required: false
331
- },
332
- /**
333
- * toggle label visibility
334
- */
335
- showLabel: {
336
- type: Boolean,
337
- default: true
338
- },
339
- /**
340
- * activate if interactive status-icon (to show requirements) should be shown inline with label
341
- */
342
- showStatusIcon: {
343
- type: Boolean,
344
- default: false
345
- },
346
- /**
347
- * path to flag-files (will be combined with flag isoCode to load svg)
348
- */
349
- pathFlags: {
350
- type: String,
351
- default: "/media/images/flags"
352
- },
353
- /**
354
- * limits drodpwon height of provided value (and lets contentscroll inside)
355
- *
356
- * @allowedValues: "none", "an< height in pixels/rem"
357
- */
358
- dropdownMaxHeight: {
359
- type: String,
360
- default: "20rem"
361
- },
362
- /**
363
- * default text if no option is selected (and first option is not used)
364
- */
365
- textPleaseSelect: {
366
- type: String,
367
- default: "Please select\u2026"
368
- },
369
- /**
370
- * set icon for "select all"-option
371
- */
372
- iconSelectAllOptions: {
373
- type: Object,
374
- default() {
375
- return {
376
- iconClass: "icon-check",
377
- iconType: "auto"
378
- }
379
- }
380
- },
381
- /**
382
- * set icon for "deselect all"-option
383
- */
384
- iconDeselectAllOptions: {
385
- type: Object,
386
- default() {
387
- return {
388
- iconClass: "icon-cancel",
389
- iconType: "auto"
390
- }
391
- }
392
- },
393
- /**
394
- * properties for CmdListOfRequirements-component
395
- */
396
- cmdListOfRequirements: {
397
- type: Object,
398
- required: false
399
- }
400
- },
401
- computed: {
402
- cmdListOfRequirementsProperties() {
403
- return {
404
- showRequirements: true,
405
- validationTooltip: "",
406
- inputRequirements: [],
407
- inputAttributes: {},
408
- showHeadline: true,
409
- inputModelValue: "",
410
- helplink: {},
411
- labelText: "",
412
- ...this.cmdListOfRequirements
413
- }
414
- },
415
- validationTooltip() {
416
- if (!this.useCustomTooltip) {
417
- return this.getValidationMessage
418
- }
419
-
420
- // set default-tooltip if customTooltip is not set
421
- if (this.validationStatus === 'error') {
422
- return this.getMessage("form_element.validation_tooltip.an_error_occurred")
423
- } else if (this.validationStatus === 'success') {
424
- return this.getMessage("form_element.validation_tooltip.information_is_filled_correctly")
425
- }
426
- return this.getMessage("form_element.validation_tooltip.open_field_requirements")
427
- },
428
- // get the displayed option name
429
- optionName() {
430
- // fake a native selectbox
431
- if (this.type !== "checkboxOptions" && this.type !== "content" && this.modelValue) {
432
- const result = this.selectData.find(option => option.value === this.modelValue)
433
-
434
- // if find() returns some data, return this data
435
- if (result) {
436
- return result.text
437
- }
438
- }
439
-
440
- // selectbox with checkbox-options
441
- else if (this.type === "checkboxOptions") {
442
- if (this.modelValue.length === 1) {
443
- return this.selectData.find(option => String(option.value) === String(this.modelValue[0]))?.text
444
- } else if (this.modelValue.length > 1) {
445
- return this.getMessage("fake_select.option.options_selected", this.modelValue.length)
446
- }
447
- } else if (this.selectData?.length) {
448
- // return text of first option nothing is selected (and type !== checkboxOptions && type !== content)
449
- return this.selectData[0].text
450
- }
451
-
452
- // return default text if nothing is selected (and no modelValue exists) (and type !== checkboxOptions && type !== content)
453
- return this.textPleaseSelect
454
- },
455
- // get the displayed icon (only available for default selectbox)
456
- optionIcon() {
457
- if (this.type === "default") {
458
- const selectedOption = this.selectData.find(option => {
459
- return option.value === this.modelValue
460
- })
461
-
462
- return {
463
- iconClass: selectedOption?.iconClass,
464
- tooltip: selectedOption?.tooltip
465
- }
466
- }
467
- return null
468
- },
469
- optionCountry() {
470
- if (this.type === "country") {
471
- return this.modelValue || this.selectData?.[0]?.value
472
- }
473
- return null
474
- },
475
- optionColor() {
476
- if (this.type === "color") {
477
- return this.modelValue || this.selectData?.[0]?.value
478
- }
479
- return null
480
- },
481
- selectAllOptionsText() {
482
- if (Array.isArray(this.modelValue) && this.modelValue.length === this.selectData.length) {
483
- this.allOptionsSelected = true
484
- return this.getMessage("fake_select.linktext.deselect_all_options")
485
- }
486
- this.allOptionsSelected = false
487
- return this.getMessage("fake_select.linktext.select_all_options")
488
- }
489
- },
490
- methods: {
491
- toggleAllOptions() {
492
- this.validationStatus = "success"
493
-
494
- const checkboxValues = []
495
- if (this.modelValue.length === this.selectData.length) {
496
- if (this.$attrs.required) {
497
- this.validationStatus = "error"
498
- }
499
- } else {
500
- for (let i = 0; i < this.selectData.length; i++) {
501
- checkboxValues.push(String(this.selectData[i].value))
502
- }
503
- }
504
-
505
- this.$emit("update:modelValue", checkboxValues)
506
- this.$emit("validation-status-change", this.validationStatus)
507
- },
508
- // toggle options/dropdown
509
- toggleOptions() {
510
- if (this.$attrs.disabled !== 'disabled') {
511
- this.showOptions = !this.showOptions
512
- }
513
- },
514
- // check if array of selected options includes number or string version of value
515
- compareValues(option) {
516
- return this.modelValue.some((item) => {
517
- return item === option || item === String(option)
518
- })
519
- },
520
- // check if an option is selected for default-selectbox
521
- selectOption(optionValue) {
522
- this.validationStatus = "success"
523
- if (this.$attrs.required !== undefined) {
524
- if (!optionValue) {
525
- this.validationStatus = "error"
526
- }
527
- }
528
-
529
- // hide options after selection
530
- this.showOptions = false
531
-
532
- this.$emit("update:modelValue", optionValue)
533
- this.$emit("validation-status-change", this.validationStatus)
534
- },
535
- // check if a checkbox is changed for selectbox with checkboxes
536
- optionSelect(event) {
537
- this.validationStatus = "success"
538
-
539
- let value = [...this.modelValue] // copy array from props
540
- if (event.target.checked) {
541
- value.push(event.target.value) // attention: value will be transformed into string!
542
- } else {
543
- value = value.filter(item => item !== event.target.value && String(item) !== event.target.value)
544
- }
545
- if (this.$attrs.required !== undefined && !value.length) {
546
- this.validationStatus = "error"
547
- }
548
-
549
- this.$emit("update:modelValue", value)
550
- },
551
- // hide options (in dropdown)
552
- closeOptions() {
553
- this.showOptions = false
554
- },
555
- // set path for flag-icons (type-property must be 'country')
556
- pathFlag(isoCode) {
557
- return this.pathFlags + "/flag-" + isoCode + ".svg"
558
- },
559
- // validate on blur
560
- onBlur() {
561
- this.validationStatus = "success"
562
-
563
- if (this.$attrs.required !== undefined && (!this.modelValue || this.modelValue.length === 0)) {
564
- this.validationStatus = "error"
565
- }
566
-
567
- this.$emit("validation-status-change", this.validationStatus)
568
- },
569
- // overwrite requirement-message form fieldValidation.js
570
- getRequirementMessage() {
571
- return this.getMessage("fake_select.headline.an_option_is_selected")
572
- }
573
- },
574
- watch: {
575
- status: {
576
- handler() {
577
- this.validationStatus = this.status
578
- },
579
- immediate: true
580
- },
581
- selectData: {
582
- handler() {
583
- // check if given value by modelValue exists (else pre-select first option)
584
- if (this.type === "default" && this.selectData?.length && !this.selectData.some((option) => option.value === this.modelValue)) {
585
- this.$emit("update:modelValue", this.selectData[0].value)
586
- }
587
- },
588
- immediate: true,
589
- deep: true
590
- }
591
- }
592
- }
593
- </script>
594
-
595
- <style>
596
- /* begin cmd-fake-select ------------------------------------------------------------------------------------------ */
597
- .cmd-fake-select {
598
- align-self: flex-end;
599
- border-radius: var(--form-input-border-radius);
600
-
601
- > span:first-child {
602
- a {
603
- align-self: flex-end;
604
- }
605
- }
606
-
607
- a {
608
- span {
609
- text-decoration: none !important;
610
-
611
- &[class*="icon"]:last-child {
612
- margin-left: auto !important; /* overwrite default settings from frontend-framework */
613
- }
614
- }
615
- }
616
-
617
- > ul {
618
- height: var(--form-input-height);
619
- margin: 0;
620
- display: block;
621
- min-width: 0;
622
- box-shadow: none;
623
- border-radius: var(--form-input-border-radius);
624
-
625
- > li {
626
- height: 100%;
627
- border-radius: var(--form-input-border-radius);
628
-
629
- &:first-child {
630
- > a {
631
- height: inherit;
632
- border: var(--form-input-border);
633
- background: var(--color-scheme-background);
634
- color: var(--color-scheme-text-color);
635
- border-radius: var(--default-border-radius);
636
- box-shadow: var(--form-input-box-shadow);
637
-
638
- img {
639
- flex-shrink: 0;
640
- }
641
-
642
- span, [class*="icon"] {
643
- color: var(--color-scheme-text-color);
644
- }
645
-
646
- .option-name {
647
- text-overflow: ellipsis;
648
- overflow: hidden;
649
- }
650
-
651
- > [class*="icon-"]:last-child {
652
- margin-left: auto !important; /* overwrite default settings from frontend-framework */
653
- font-size: var(--icon-size-small);
654
- }
655
-
656
- &:hover, &:active, &:focus {
657
- background: var(--color-white);
658
- border-color: var(--hyperlink-color);
659
-
660
- span, [class*="icon"] {
661
- color: var(--hyperlink-color);
662
- }
663
- }
664
- }
665
- }
666
-
667
- ul {
668
- max-height: v-bind(dropdownMaxHeight);
669
- overflow-x: hidden;
670
- overflow-y: auto;
671
- }
672
- }
673
-
674
- &.open {
675
- border-bottom-left-radius: 0;
676
- border-bottom-right-radius: 0;
677
-
678
- > li:first-child {
679
- a {
680
- border-bottom-left-radius: 0;
681
- border-bottom-right-radius: 0;
682
- }
683
- }
684
-
685
- ul {
686
- border-bottom-left-radius: var(--border-radius-small);
687
- border-bottom-right-radius: var(--border-radius-small);
688
-
689
- > li {
690
- &:first-child {
691
- > a {
692
- border-color: var(--hyperlink-color);
693
- border-bottom-left-radius: 0;
694
- border-bottom-right-radius: 0;
695
- }
696
- }
697
- }
698
-
699
- > li:last-child {
700
- border-bottom-left-radius: inherit;
701
- border-bottom-right-radius: inherit;
702
-
703
- > a {
704
- border-bottom-left-radius: inherit;
705
- border-bottom-right-radius: inherit;
706
- }
707
- }
708
- }
709
- }
710
- }
711
-
712
- li {
713
- margin-left: 0;
714
- list-style: none;
715
-
716
- a, a:visited {
717
- display: flex;
718
- align-items: center;
719
- gap: var(--gap-small);
720
- width: 100%;
721
- padding: 1rem;
722
- outline: none;
723
- border-bottom: var(--default-border);
724
- text-decoration: none;
725
-
726
- &:hover, &:active, &:focus {
727
- background: var(--hyperlink-color);
728
-
729
- span, [class*="icon"] {
730
- color: var(--color-white);
731
- }
732
- }
733
-
734
- span {
735
- &:first-child, &:nth-child(2) {
736
- border: 0;
737
- }
738
- }
739
-
740
- img {
741
- box-shadow: none;
742
- }
743
-
744
- &.active {
745
- background: var(--color-light-gray);
746
-
747
- span {
748
- color: var(--hyperlink-color);
749
- }
750
-
751
- &:hover, &:active, &:focus {
752
- background: var(--hyperlink-color);
753
-
754
- span, [class*="icon"] {
755
- color: var(--color-white);
756
- }
757
- }
758
- }
759
- }
760
-
761
- label {
762
- display: flex;
763
- }
764
-
765
- span {
766
- white-space: nowrap;
767
- }
768
-
769
- ul {
770
- position: absolute;
771
- list-style: none;
772
- z-index: 10;
773
- min-width: 100%;
774
- margin: 0;
775
- border-bottom-right-radius: var(--default-border-radius);
776
- border-bottom-left-radius: var(--default-border-radius);
777
- background: var(--color-scheme-background);
778
- border: var(--primary-border);
779
-
780
- li {
781
- &:last-child {
782
- a {
783
- border-bottom: 0;
784
- }
785
- }
786
- }
787
-
788
- &.custom-fake-select-content {
789
- padding: var(--default-padding);
790
-
791
- img {
792
- display: block;
793
- }
794
- }
795
-
796
- &.checkbox-options {
797
- li {
798
- padding: calc(var(--default-padding) / 2);
799
-
800
- &.select-all-options {
801
- border-top: var(--primary-border);
802
- padding: 0;
803
- }
804
- }
805
- }
806
- }
807
- }
808
-
809
- /* use additional class in selector to gain high specificity */
810
- &.has-state.label {
811
- &.error * {
812
- --status-color: var(--error-color);
813
- }
814
-
815
- &.success * {
816
- --status-color: var(--success-color);
817
- }
818
-
819
- .label-text {
820
- > span, [class*="icon-"] {
821
- color: var(--status-color);
822
- }
823
- }
824
-
825
- > ul {
826
- > li:first-child {
827
- > a {
828
- text-decoration: none !important;
829
- border-color: var(--status-color);
830
- padding-top: calc(var(--default-padding) - .06rem);
831
- padding-right: calc(var(--default-padding) / 2);
832
- padding-bottom: calc(var(--default-padding) - .06rem);
833
-
834
- > span, [class*="icon-"] {
835
- text-decoration: none !important;
836
- color: var(--status-color);
837
- }
838
-
839
- &:hover, &:active, &:focus {
840
- background: var(--color-scheme-background);
841
-
842
- span {
843
- color: var(--status-color);
844
- }
845
- }
846
- }
847
- }
848
- }
849
- }
850
-
851
- &.error, &.disabled {
852
- a {
853
- &:hover, &:focus, &:active {
854
- img {
855
- &.flag {
856
- border-color: var(--border-color);
857
- }
858
- }
859
- }
860
- }
861
- }
862
-
863
- &.color {
864
- li {
865
- a {
866
- gap: var(--gap-small);
867
-
868
- > span:first-child {
869
- width: 1.5rem;
870
- aspect-ratio: 1/1;
871
- border: var(--default-border);
872
-
873
- &[style=""] {
874
- display: none;
875
- }
876
- }
877
- }
878
- }
879
- }
880
- }
881
- </style>
882
-
883
- <style lang="scss">
884
- @mixin disabled-styles {
885
- color: var(--disabled-color);
886
- border-color: var(--disabled-color);
887
- background: var(--disabled-background);
888
- }
889
-
890
- .cmd-fake-select {
891
- &.disabled {
892
- > ul {
893
- > li {
894
- > a {
895
- @include disabled-styles;
896
-
897
- span {
898
- color: var(--disabled-color);
899
- }
900
-
901
- &:hover, &:active, &:focus {
902
- cursor: not-allowed;
903
- @include disabled-styles;
904
-
905
- span {
906
- color: var(--disabled-color);
907
- }
908
- }
909
- }
910
- }
911
- }
912
- }
913
- }
914
-
915
- /* end cmd-fake-select ------------------------------------------------------------------------------------------ */
916
- </style>
1
+ <template>
2
+ <!-- begin CmdFakeSelect ---------------------------------------------------------------------------------------- -->
3
+ <div
4
+ :class="[
5
+ validationStatus,
6
+ 'cmd-fake-select label',
7
+ {
8
+ color: type === 'color',
9
+ 'has-state': validationStatus && validationStatus !== 'none',
10
+ disabled: $attrs.disabled
11
+ }
12
+ ]"
13
+ :title="$attrs.title"
14
+ role="group"
15
+ :aria-labelledby="showLabel ? htmlId : null"
16
+ ref="fakeselect"
17
+ >
18
+ <template v-if="showLabel">
19
+ <!-- begin label -->
20
+ <span class="label-text">
21
+ <span :id="htmlId">{{ labelText }}<sup v-if="$attrs.required !== undefined" aria-hidden="true">*</sup>
22
+ </span>
23
+
24
+ <!-- begin status-icon (linked with tooltip) -->
25
+ <button v-if="($attrs.required || inputRequirements.length) && showStatusIcon"
26
+ type="button"
27
+ class="no-style"
28
+ :title="validationTooltip"
29
+ :aria-errormessage="tooltipId"
30
+ aria-live="assertive"
31
+ :popovertarget="'tooltip-target-' + htmlId"
32
+ :style="'anchor-name: --tooltip-anchor-' + htmlId"
33
+ >
34
+ <!-- begin CmdIcon -->
35
+ <CmdIcon :iconClass="getStatusIconClass" />
36
+ <!-- end CmdIcon -->
37
+ </button>
38
+ <!-- end status-icon (linked with tooltip) -->
39
+
40
+ <!-- begin CmdTooltip -->
41
+ <CmdTooltip
42
+ ref="tooltip"
43
+ class="cmd-tooltip-for-form-elements box"
44
+ :id="'tooltip-target-' + htmlId"
45
+ :scrollContainer="scrollContainerForTooltip"
46
+ :popoverTargetName="'tooltip-target-' + htmlId"
47
+ :validationStatus="validationStatus"
48
+ :role="validationStatus === 'error' ? 'alert' : 'dialog'"
49
+ :toggle-visibility-by-click="true"
50
+ :style="'position-anchor: --tooltip-anchor-' + htmlId"
51
+ >
52
+
53
+ <!-- begin CmdListOfRequirements -->
54
+ <CmdListOfRequirements
55
+ v-if="cmdListOfRequirementsProperties.showRequirements"
56
+ v-bind="cmdListOfRequirementsProperties"
57
+ />
58
+ <!-- end CmdListOfRequirements -->
59
+ </CmdTooltip>
60
+ <!-- end CmdTooltip -->
61
+ </span>
62
+ <!-- end label -->
63
+ </template>
64
+ <ul :class="{'open': showOptions}" :aria-expanded="showOptions">
65
+ <li>
66
+ <!-- begin default/selected-option -->
67
+ <a href="#" @click.prevent="toggleOptions" @blur="onBlur" :title="optionIcon?.tooltip">
68
+ <!-- begin show flag -->
69
+ <img v-if="type === 'country' && optionCountry"
70
+ :src="pathFlag(optionCountry)"
71
+ :alt="optionCountry"
72
+ :class="['flag', optionCountry]"/>
73
+ <!-- end show flag -->
74
+
75
+ <!-- begin show color-box -->
76
+ <span v-else-if="type === 'color'" :style="'background: ' + optionColor"></span>
77
+ <!-- end show color-box -->
78
+
79
+ <!-- begin optional icon -->
80
+ <!-- begin CmdIcon -->
81
+ <CmdIcon v-if="optionIcon?.iconClass" :type="optionIcon?.iconType"
82
+ :iconClass="optionIcon?.iconClass"/>
83
+ <!-- end CmdIcon -->
84
+ <!-- end optional icon -->
85
+
86
+ <!-- begin text -->
87
+ <span v-if="optionName" class="option-name">{{ optionName }}</span>
88
+ <!-- end text -->
89
+
90
+ <!-- begin custom dropdown-icon -->
91
+ <!-- begin CmdIcon -->
92
+ <CmdIcon
93
+ v-if="iconDropdown"
94
+ :iconClass="iconDropdown.iconClass"
95
+ :type="iconDropdown.iconType"
96
+ :title="iconDropdown.tooltip"
97
+ />
98
+ <!-- end CmdIcon -->
99
+ <!-- end custom dropdown-icon -->
100
+ </a>
101
+ <!-- end default/selected-option-->
102
+
103
+ <!-- begin default dropdown (incl. optional icon) -->
104
+ <ul v-if="type === 'default' && showOptions" role="listbox" :aria-labelledby="showLabel ? htmlId : null" :aria-required="$attrs.required !== undefined">
105
+ <li v-for="(option, index) in selectData" :key="index" role="option"
106
+ :aria-selected="option.value === modelValue">
107
+ <!-- begin type 'href' -->
108
+ <a v-if="optionLinkType === 'href'"
109
+ href="#" @click.prevent="selectOption(option.value)"
110
+ :class="{'active' : option.value === modelValue}"
111
+ :title="option.tooltip"
112
+ >
113
+ <!-- begin CmdIcon -->
114
+ <CmdIcon v-if="option.iconClass" :iconClass="option.iconClass" :type="option.iconType"/>
115
+ <!-- end CmdIcon -->
116
+ <span v-if="option.text">{{ option.text }}</span>
117
+ </a>
118
+ <!-- end type 'href' -->
119
+
120
+ <!-- begin type 'router' -->
121
+ <router-link v-if="optionLinkType === 'router'" to="#"
122
+ @click.prevent="selectOption(option.value)"
123
+ :class="{'active' : option.value === modelValue}">
124
+ <!-- begin CmdIcon -->
125
+ <CmdIcon v-if="option.iconClass" :iconClass="option.iconClass" :type="option.iconType"/>
126
+ <!-- end CmdIcon -->
127
+ <span>{{ option.text }}</span>
128
+ </router-link>
129
+ <!-- end type 'router' -->
130
+ </li>
131
+ </ul>
132
+ <!-- end default dropdown (incl. optional icon) -->
133
+
134
+ <!-- begin dropdown with checkboxes/countries/colors -->
135
+ <ul v-else-if="type !== 'default' && type !== 'content' && showOptions"
136
+ :class="{'checkbox-options': type === 'checkboxOptions'}" :aria-expanded="showOptions">
137
+ <li v-for="(option, index) in selectData" :key="index">
138
+ <!-- begin checkboxes -->
139
+ <label v-if="type === 'checkboxOptions'" :for="'option-' + (index + 1)"
140
+ :class="{'active' : modelValue.includes(`${option.value}`)}">
141
+ <input type="checkbox" :value="option.value" @change="optionSelect"
142
+ :checked="compareValues(option.value)" :id="'option-' + (index + 1)"/>
143
+ <span>{{ option.text }}</span>
144
+ </label>
145
+ <!-- end checkboxes -->
146
+
147
+ <!-- begin country-flags -->
148
+ <a v-else-if="type === 'country'" href="#"
149
+ @click.prevent="selectOption(option.value)"
150
+ :class="{'active' : option.value === modelValue}">
151
+ <img class="flag" :src="pathFlag(option.value)"
152
+ alt=""/>
153
+ <span>{{ option.text }}</span>
154
+ </a>
155
+ <!-- end country-flags -->
156
+
157
+ <!-- begin color-boxes -->
158
+ <a v-else-if="type === 'color'" href="#" @click.prevent="selectOption(option.value)"
159
+ :class="{'active' : option.value === modelValue}">
160
+ <span class="color" :style="'background: ' + option.value"></span>
161
+ <span>{{ option.text }}</span>
162
+ </a>
163
+ <!-- end color-boxes -->
164
+ </li>
165
+
166
+ <!-- begin (de)select all options -->
167
+ <li v-if="showSelectAllOptions && type === 'checkboxOptions'" class="select-all-options">
168
+ <a href="#" @click.prevent="toggleAllOptions">
169
+ <!-- begin CmdIcon -->
170
+ <CmdIcon v-if="!allOptionsSelected" :iconClass="iconSelectAllOptions.iconClass"
171
+ :type="iconSelectAllOptions.iconType"/>
172
+ <CmdIcon v-else :iconClass="iconDeselectAllOptions.iconClass"
173
+ :type="iconDeselectAllOptions.iconType"/>
174
+ <!-- end CmdIcon -->
175
+ <span>{{ selectAllOptionsText }}</span>
176
+ </a>
177
+ </li>
178
+ <!-- end (de)select all options -->
179
+ </ul>
180
+ <!-- end dropdown with checkboxes/countries/colors -->
181
+
182
+ <!-- begin dropdown with slot -->
183
+ <template v-else-if="type === 'content' && showOptions" :aria-expanded="showOptions">
184
+ <slot></slot>
185
+ </template>
186
+ <!-- end dropdown with slot -->
187
+ </li>
188
+ </ul>
189
+ </div>
190
+ <!-- end CmdFakeSelect ---------------------------------------------------------------------------------------- -->
191
+ </template>
192
+
193
+ <script>
194
+ // import mixins
195
+ import I18n from "../mixins/I18n"
196
+ import DefaultMessageProperties from "../mixins/CmdFakeSelect/DefaultMessageProperties"
197
+ import FieldValidation from "../mixins/FieldValidation"
198
+ import Identifier from "../mixins/Identifier"
199
+ import Tooltip from "../mixins/Tooltip"
200
+ import {createUuid} from "../utils/common.js"
201
+
202
+ export default {
203
+ name: 'CmdFakeSelect',
204
+ inheritAttrs: false,
205
+ mixins: [
206
+ I18n,
207
+ DefaultMessageProperties,
208
+ FieldValidation,
209
+ Identifier,
210
+ Tooltip
211
+ ],
212
+ emits: ["validation-status-change", "update:modelValue"],
213
+ mounted() {
214
+ // close options if user clicks outside of the component
215
+ document.addEventListener("click", this.onClickOutside)
216
+ },
217
+ beforeUnmount() {
218
+ document.removeEventListener("click", this.onClickOutside)
219
+ },
220
+ data() {
221
+ return {
222
+ showOptions: false,
223
+ validationStatus: "",
224
+ allOptionsSelected: false
225
+ }
226
+ },
227
+ props: {
228
+ /**
229
+ * name for popover-target (will be set as id for popover and must correspond popovertarget-value of button that opens the popup)
230
+ */
231
+ tooltipPopoverTargetName: {
232
+ type: String,
233
+ default: 'tooltip-target-' + createUuid()
234
+ },
235
+ /**
236
+ * specify a scroll-container which scrolling hides the tooltip
237
+ */
238
+ scrollContainerForTooltip: {
239
+ type: String,
240
+ required: false
241
+ },
242
+ /**
243
+ * set different default selectbox-types for
244
+ *
245
+ * @allowedValues: default, color, country, content, checkboxOptions
246
+ */
247
+ type: {
248
+ type: String,
249
+ default: "default",
250
+ validator(value) {
251
+ return value === "default" ||
252
+ value === "color" ||
253
+ value === "country" ||
254
+ value === "content" ||
255
+ value === "checkboxOptions"
256
+ }
257
+ },
258
+ /**
259
+ * set type of option-links
260
+ *
261
+ * @allowedValues: href, router
262
+ */
263
+ optionLinkType: {
264
+ type: String,
265
+ default: "href",
266
+ validator(value) {
267
+ return value === "href" ||
268
+ value === "router"
269
+ }
270
+ },
271
+ /**
272
+ * set default v-model (must be named modelValue in Vue3)
273
+ */
274
+ modelValue: {
275
+ type: [String, Number, Array],
276
+ default: ""
277
+ },
278
+ /**
279
+ * list of options to select (incl. displayed names and values)
280
+ *
281
+ * type-property must be set to "checkboxOptions"
282
+ */
283
+ selectData: {
284
+ type: Array,
285
+ required: false
286
+ },
287
+ /**
288
+ * toggles option to (de)select all options in a checkbox-list
289
+ *
290
+ * type-property must be set to "checkboxOptions"
291
+ */
292
+ showSelectAllOptions: {
293
+ type: Boolean,
294
+ default: true
295
+ },
296
+ /**
297
+ * status (i.e. for validation)
298
+ *
299
+ * @allowedValues: "" , error, warning, success, info
300
+ * @affectsStyling: true
301
+ */
302
+ status: {
303
+ type: String,
304
+ required: false,
305
+ validator(value) {
306
+ return value === "" ||
307
+ value === "error" ||
308
+ value === "warning" ||
309
+ value === "success" ||
310
+ value === "info"
311
+ }
312
+ },
313
+ /**
314
+ * icon for dropdown-icon (i.e. an angle/arrow)
315
+ *
316
+ * @requiredForAccessibility: partial
317
+ * @defaultIcon: icon-chevron-one-stripe-down
318
+ */
319
+ iconDropdown: {
320
+ type: Object,
321
+ default() {
322
+ return {
323
+ iconClass: "icon-chevron-one-stripe-down",
324
+ tooltip: "Toggle dropdown visibility",
325
+ iconType: "auto"
326
+ }
327
+ }
328
+ },
329
+ /**
330
+ * label-text for fake-select
331
+ *
332
+ * @requiredForAccessibility: true
333
+ */
334
+ labelText: {
335
+ type: String,
336
+ required: false
337
+ },
338
+ /**
339
+ * toggle label visibility
340
+ */
341
+ showLabel: {
342
+ type: Boolean,
343
+ default: true
344
+ },
345
+ /**
346
+ * activate if interactive status-icon (to show requirements) should be shown inline with label
347
+ */
348
+ showStatusIcon: {
349
+ type: Boolean,
350
+ default: false
351
+ },
352
+ /**
353
+ * path to flag-files (will be combined with flag isoCode to load svg)
354
+ */
355
+ pathFlags: {
356
+ type: String,
357
+ default: "/media/images/flags"
358
+ },
359
+ /**
360
+ * limits drodpwon height of provided value (and lets contentscroll inside)
361
+ *
362
+ * @allowedValues: "none", "an< height in pixels/rem"
363
+ */
364
+ dropdownMaxHeight: {
365
+ type: String,
366
+ default: "20rem"
367
+ },
368
+ /**
369
+ * default text if no option is selected (and first option is not used)
370
+ */
371
+ textPleaseSelect: {
372
+ type: String,
373
+ default: "Please select\u2026"
374
+ },
375
+ /**
376
+ * set icon for "select all"-option
377
+ */
378
+ iconSelectAllOptions: {
379
+ type: Object,
380
+ default() {
381
+ return {
382
+ iconClass: "icon-check",
383
+ iconType: "auto"
384
+ }
385
+ }
386
+ },
387
+ /**
388
+ * set icon for "deselect all"-option
389
+ */
390
+ iconDeselectAllOptions: {
391
+ type: Object,
392
+ default() {
393
+ return {
394
+ iconClass: "icon-cancel",
395
+ iconType: "auto"
396
+ }
397
+ }
398
+ },
399
+ /**
400
+ * properties for CmdListOfRequirements-component
401
+ */
402
+ cmdListOfRequirements: {
403
+ type: Object,
404
+ required: false
405
+ }
406
+ },
407
+ computed: {
408
+ cmdListOfRequirementsProperties() {
409
+ return {
410
+ showRequirements: true,
411
+ validationTooltip: "",
412
+ inputRequirements: [],
413
+ inputAttributes: {},
414
+ showHeadline: true,
415
+ inputModelValue: "",
416
+ helplink: {},
417
+ labelText: "",
418
+ ...this.cmdListOfRequirements
419
+ }
420
+ },
421
+ validationTooltip() {
422
+ if (!this.useCustomTooltip) {
423
+ return this.getValidationMessage
424
+ }
425
+
426
+ // set default-tooltip if customTooltip is not set
427
+ if (this.validationStatus === 'error') {
428
+ return this.getMessage("form_element.validation_tooltip.an_error_occurred")
429
+ } else if (this.validationStatus === 'success') {
430
+ return this.getMessage("form_element.validation_tooltip.information_is_filled_correctly")
431
+ }
432
+ return this.getMessage("form_element.validation_tooltip.open_field_requirements")
433
+ },
434
+ // get the displayed option name
435
+ optionName() {
436
+ // fake a native selectbox
437
+ if (this.type !== "checkboxOptions" && this.type !== "content" && this.modelValue) {
438
+ const result = this.selectData.find(option => option.value === this.modelValue)
439
+
440
+ // if find() returns some data, return this data
441
+ if (result) {
442
+ return result.text
443
+ }
444
+ }
445
+
446
+ // selectbox with checkbox-options
447
+ else if (this.type === "checkboxOptions") {
448
+ if (this.modelValue.length === 1) {
449
+ return this.selectData.find(option => String(option.value) === String(this.modelValue[0]))?.text
450
+ } else if (this.modelValue.length > 1) {
451
+ return this.getMessage("fake_select.option.options_selected", this.modelValue.length)
452
+ }
453
+ } else if (this.selectData?.length) {
454
+ // return text of first option nothing is selected (and type !== checkboxOptions && type !== content)
455
+ return this.selectData[0].text
456
+ }
457
+
458
+ // return default text if nothing is selected (and no modelValue exists) (and type !== checkboxOptions && type !== content)
459
+ return this.textPleaseSelect
460
+ },
461
+ // get the displayed icon (only available for default selectbox)
462
+ optionIcon() {
463
+ if (this.type === "default") {
464
+ const selectedOption = this.selectData.find(option => {
465
+ return option.value === this.modelValue
466
+ })
467
+
468
+ return {
469
+ iconClass: selectedOption?.iconClass,
470
+ tooltip: selectedOption?.tooltip
471
+ }
472
+ }
473
+ return null
474
+ },
475
+ optionCountry() {
476
+ if (this.type === "country") {
477
+ return this.modelValue || this.selectData?.[0]?.value
478
+ }
479
+ return null
480
+ },
481
+ optionColor() {
482
+ if (this.type === "color") {
483
+ return this.modelValue || this.selectData?.[0]?.value
484
+ }
485
+ return null
486
+ },
487
+ selectAllOptionsText() {
488
+ if (Array.isArray(this.modelValue) && this.modelValue.length === this.selectData.length) {
489
+ this.allOptionsSelected = true
490
+ return this.getMessage("fake_select.linktext.deselect_all_options")
491
+ }
492
+ this.allOptionsSelected = false
493
+ return this.getMessage("fake_select.linktext.select_all_options")
494
+ }
495
+ },
496
+ methods: {
497
+ toggleAllOptions() {
498
+ this.validationStatus = "success"
499
+
500
+ const checkboxValues = []
501
+ if (this.modelValue.length === this.selectData.length) {
502
+ if (this.$attrs.required) {
503
+ this.validationStatus = "error"
504
+ }
505
+ } else {
506
+ for (let i = 0; i < this.selectData.length; i++) {
507
+ checkboxValues.push(String(this.selectData[i].value))
508
+ }
509
+ }
510
+
511
+ this.$emit("update:modelValue", checkboxValues)
512
+ this.$emit("validation-status-change", this.validationStatus)
513
+ },
514
+ // toggle options/dropdown
515
+ toggleOptions() {
516
+ if (this.$attrs.disabled !== 'disabled') {
517
+ this.showOptions = !this.showOptions
518
+ }
519
+ },
520
+ // check if array of selected options includes number or string version of value
521
+ compareValues(option) {
522
+ return this.modelValue.some((item) => {
523
+ return item === option || item === String(option)
524
+ })
525
+ },
526
+ // check if an option is selected for default-selectbox
527
+ selectOption(optionValue) {
528
+ this.validationStatus = "success"
529
+ if (this.$attrs.required !== undefined) {
530
+ if (!optionValue) {
531
+ this.validationStatus = "error"
532
+ }
533
+ }
534
+
535
+ // hide options after selection
536
+ this.showOptions = false
537
+
538
+ this.$emit("update:modelValue", optionValue)
539
+ this.$emit("validation-status-change", this.validationStatus)
540
+ },
541
+ // check if a checkbox is changed for selectbox with checkboxes
542
+ optionSelect(event) {
543
+ this.validationStatus = "success"
544
+
545
+ let value = [...this.modelValue] // copy array from props
546
+ if (event.target.checked) {
547
+ value.push(event.target.value) // attention: value will be transformed into string!
548
+ } else {
549
+ value = value.filter(item => item !== event.target.value && String(item) !== event.target.value)
550
+ }
551
+ if (this.$attrs.required !== undefined && !value.length) {
552
+ this.validationStatus = "error"
553
+ }
554
+
555
+ this.$emit("update:modelValue", value)
556
+ },
557
+ // hide options (in dropdown)
558
+ closeOptions() {
559
+ this.showOptions = false
560
+ },
561
+ onClickOutside(event) {
562
+ // use the ref (and not $el, which is a comment/text-node if the template starts with a comment), composedPath() is
563
+ // evaluated at dispatch-time (event.target could already be replaced by vue's re-rendering)
564
+ const root = this.$refs.fakeselect
565
+ if (this.showOptions && root && !event.composedPath().includes(root)) {
566
+ this.closeOptions()
567
+ }
568
+ },
569
+ // set path for flag-icons (type-property must be 'country')
570
+ pathFlag(isoCode) {
571
+ return this.pathFlags + "/flag-" + isoCode + ".svg"
572
+ },
573
+ // validate on blur
574
+ onBlur() {
575
+ this.validationStatus = "success"
576
+
577
+ if (this.$attrs.required !== undefined && (!this.modelValue || this.modelValue.length === 0)) {
578
+ this.validationStatus = "error"
579
+ }
580
+
581
+ this.$emit("validation-status-change", this.validationStatus)
582
+ },
583
+ // overwrite requirement-message form fieldValidation.js
584
+ getRequirementMessage() {
585
+ return this.getMessage("fake_select.headline.an_option_is_selected")
586
+ }
587
+ },
588
+ watch: {
589
+ status: {
590
+ handler() {
591
+ this.validationStatus = this.status
592
+ },
593
+ immediate: true
594
+ },
595
+ selectData: {
596
+ handler() {
597
+ // check if given value by modelValue exists (else pre-select first option)
598
+ if (this.type === "default" && this.selectData?.length && !this.selectData.some((option) => option.value === this.modelValue)) {
599
+ this.$emit("update:modelValue", this.selectData[0].value)
600
+ }
601
+ },
602
+ immediate: true,
603
+ deep: true
604
+ }
605
+ }
606
+ }
607
+ </script>
608
+
609
+ <style>
610
+ /* begin cmd-fake-select ------------------------------------------------------------------------------------------ */
611
+ .cmd-fake-select {
612
+ align-self: flex-end;
613
+ border-radius: var(--form-input-border-radius);
614
+
615
+ > span:first-child {
616
+ a {
617
+ align-self: flex-end;
618
+ }
619
+ }
620
+
621
+ a {
622
+ span {
623
+ text-decoration: none !important;
624
+
625
+ &[class*="icon"]:last-child {
626
+ margin-left: auto !important; /* overwrite default settings from frontend-framework */
627
+ }
628
+ }
629
+ }
630
+
631
+ > ul {
632
+ height: var(--form-input-height);
633
+ margin: 0;
634
+ display: block;
635
+ min-width: 0;
636
+ box-shadow: none;
637
+ border-radius: var(--form-input-border-radius);
638
+
639
+ > li {
640
+ height: 100%;
641
+ border-radius: var(--form-input-border-radius);
642
+
643
+ &:first-child {
644
+ > a {
645
+ height: inherit;
646
+ border: var(--form-input-border);
647
+ background: var(--color-scheme-background);
648
+ color: var(--color-scheme-text-color);
649
+ border-radius: var(--default-border-radius);
650
+ box-shadow: var(--form-input-box-shadow);
651
+
652
+ img {
653
+ flex-shrink: 0;
654
+ }
655
+
656
+ span, [class*="icon"] {
657
+ color: var(--color-scheme-text-color);
658
+ }
659
+
660
+ .option-name {
661
+ text-overflow: ellipsis;
662
+ overflow: hidden;
663
+ }
664
+
665
+ > [class*="icon-"]:last-child {
666
+ margin-left: auto !important; /* overwrite default settings from frontend-framework */
667
+ font-size: var(--icon-size-small);
668
+ }
669
+
670
+ &:hover, &:active, &:focus {
671
+ background: var(--color-scheme-background);
672
+ border-color: var(--hyperlink-color);
673
+
674
+ span, [class*="icon"] {
675
+ color: var(--hyperlink-color);
676
+ }
677
+ }
678
+ }
679
+ }
680
+
681
+ ul {
682
+ max-height: v-bind(dropdownMaxHeight);
683
+ overflow-x: hidden;
684
+ overflow-y: auto;
685
+ }
686
+ }
687
+
688
+ &.open {
689
+ border-bottom-left-radius: 0;
690
+ border-bottom-right-radius: 0;
691
+
692
+ > li:first-child {
693
+ a {
694
+ border-bottom-left-radius: 0;
695
+ border-bottom-right-radius: 0;
696
+ }
697
+ }
698
+
699
+ ul {
700
+ border-bottom-left-radius: var(--border-radius-small);
701
+ border-bottom-right-radius: var(--border-radius-small);
702
+
703
+ > li {
704
+ &:first-child {
705
+ > a {
706
+ border-color: var(--hyperlink-color);
707
+ border-bottom-left-radius: 0;
708
+ border-bottom-right-radius: 0;
709
+ }
710
+ }
711
+ }
712
+
713
+ > li:last-child {
714
+ border-bottom-left-radius: inherit;
715
+ border-bottom-right-radius: inherit;
716
+
717
+ > a {
718
+ border-bottom-left-radius: inherit;
719
+ border-bottom-right-radius: inherit;
720
+ }
721
+ }
722
+ }
723
+ }
724
+ }
725
+
726
+ li {
727
+ margin-left: 0;
728
+ list-style: none;
729
+
730
+ a, a:visited {
731
+ display: flex;
732
+ align-items: center;
733
+ gap: var(--gap-small);
734
+ width: 100%;
735
+ padding: 1rem;
736
+ outline: none;
737
+ border-bottom: var(--default-border);
738
+ text-decoration: none;
739
+
740
+ &:hover, &:active, &:focus {
741
+ background: var(--hyperlink-color);
742
+
743
+ span, [class*="icon"] {
744
+ color: var(--hyperlink-color-contrast-text);
745
+ }
746
+ }
747
+
748
+ span {
749
+ &:first-child, &:nth-child(2) {
750
+ border: 0;
751
+ }
752
+ }
753
+
754
+ img {
755
+ box-shadow: none;
756
+ }
757
+
758
+ &.active {
759
+ background: var(--color-light-gray);
760
+
761
+ span {
762
+ color: var(--hyperlink-color);
763
+ }
764
+
765
+ &:hover, &:active, &:focus {
766
+ background: var(--hyperlink-color);
767
+
768
+ span, [class*="icon"] {
769
+ color: var(--hyperlink-color-contrast-text);
770
+ }
771
+ }
772
+ }
773
+ }
774
+
775
+ label {
776
+ display: flex;
777
+ }
778
+
779
+ span {
780
+ white-space: nowrap;
781
+ }
782
+
783
+ ul {
784
+ position: absolute;
785
+ list-style: none;
786
+ z-index: 10;
787
+ min-width: 100%;
788
+ margin: 0;
789
+ border-bottom-right-radius: var(--default-border-radius);
790
+ border-bottom-left-radius: var(--default-border-radius);
791
+ background: var(--color-scheme-background);
792
+ border: var(--primary-border);
793
+
794
+ li {
795
+ &:last-child {
796
+ a {
797
+ border-bottom: 0;
798
+ }
799
+ }
800
+ }
801
+
802
+ &.custom-fake-select-content {
803
+ padding: var(--default-padding);
804
+
805
+ img {
806
+ display: block;
807
+ }
808
+ }
809
+
810
+ &.checkbox-options {
811
+ li {
812
+ padding: calc(var(--default-padding) / 2);
813
+
814
+ &.select-all-options {
815
+ border-top: var(--primary-border);
816
+ padding: 0;
817
+ }
818
+ }
819
+ }
820
+ }
821
+ }
822
+
823
+ /* use additional class in selector to gain high specificity */
824
+ &.has-state.label {
825
+ &.error * {
826
+ --status-color: var(--error-color-text);
827
+ }
828
+
829
+ &.success * {
830
+ --status-color: var(--success-color-text);
831
+ }
832
+
833
+ .label-text {
834
+ > span, [class*="icon-"] {
835
+ color: var(--status-color);
836
+ }
837
+ }
838
+
839
+ > ul {
840
+ > li:first-child {
841
+ > a {
842
+ text-decoration: none !important;
843
+ border-color: var(--status-color);
844
+ padding-top: calc(var(--default-padding) - .06rem);
845
+ padding-right: calc(var(--default-padding) / 2);
846
+ padding-bottom: calc(var(--default-padding) - .06rem);
847
+
848
+ > span, [class*="icon-"] {
849
+ text-decoration: none !important;
850
+ color: var(--status-color);
851
+ }
852
+
853
+ &:hover, &:active, &:focus {
854
+ background: var(--color-scheme-background);
855
+
856
+ span {
857
+ color: var(--status-color);
858
+ }
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+
865
+ &.error, &.disabled {
866
+ a {
867
+ &:hover, &:focus, &:active {
868
+ img {
869
+ &.flag {
870
+ border-color: var(--default-border-color);
871
+ }
872
+ }
873
+ }
874
+ }
875
+ }
876
+
877
+ &.color {
878
+ li {
879
+ a {
880
+ gap: var(--gap-small);
881
+
882
+ > span:first-child {
883
+ width: 1.5rem;
884
+ aspect-ratio: 1/1;
885
+ border: var(--default-border);
886
+
887
+ &[style=""] {
888
+ display: none;
889
+ }
890
+ }
891
+ }
892
+ }
893
+ }
894
+ }
895
+ </style>
896
+
897
+ <style lang="scss">
898
+ @mixin disabled-styles {
899
+ color: var(--disabled-color);
900
+ border-color: var(--disabled-color);
901
+ background: var(--disabled-background);
902
+ }
903
+
904
+ .cmd-fake-select {
905
+ &.disabled {
906
+ > ul {
907
+ > li {
908
+ > a {
909
+ @include disabled-styles;
910
+
911
+ span {
912
+ color: var(--disabled-color);
913
+ }
914
+
915
+ &:hover, &:active, &:focus {
916
+ cursor: not-allowed;
917
+ @include disabled-styles;
918
+
919
+ span {
920
+ color: var(--disabled-color);
921
+ }
922
+ }
923
+ }
924
+ }
925
+ }
926
+ }
927
+ }
928
+
929
+ /* end cmd-fake-select ------------------------------------------------------------------------------------------ */
930
+ </style>