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,1091 +1,1110 @@
1
- <template>
2
- <!-- begin CmdFormElement ---------------------------------------------------------------------------------------- -->
3
- <label v-if="(element === 'input' || element === 'select' || element === 'textarea')" :class="[
4
- 'cmd-form-element',
5
- $attrs.class,
6
- $attrs.required ? validationStatus : null,
7
- {
8
- disabled: $attrs.disabled,
9
- inline: displayLabelInline,
10
- 'stretch-field': stretchField,
11
- 'toggle-switch': toggleSwitch,
12
- colored: colored,
13
- 'has-state': validationStatus
14
- }
15
- ]" :for="htmlId" :title="$attrs.title" ref="label">
16
-
17
- <!-- begin label-text (+ required asterisk) -->
18
- <span v-if="(labelText || $slots.labeltext) && $attrs.type !== 'checkbox' && $attrs.type !== 'radio'"
19
- :class="['label-text', { hidden: !showLabel }]">
20
- <span>
21
- <span v-if="labelText" v-html="labelText"></span>
22
-
23
- <!-- begin slot 'labeltext' -->
24
- <slot v-else name="labeltext" />
25
- <!-- end slot 'labeltext' -->
26
-
27
- <!-- begin required asterisk -->
28
- <sup v-if="$attrs.required != null && $attrs.required !== false" aria-hidden="true">*</sup>
29
- <!-- end required asterisk -->
30
- </span>
31
-
32
- <!-- begin status-icon (linked with tooltip) -->
33
- <button v-if="($attrs.required || inputRequirements.length) && showStatusIcon"
34
- type="button"
35
- class="no-style"
36
- :title="validationTooltip"
37
- :aria-errormessage="tooltipId"
38
- aria-live="assertive"
39
- :popovertarget="'tooltip-target-' + htmlId"
40
- :style="'anchor-name: --tooltip-anchor-' + htmlId"
41
- >
42
- <!-- begin CmdIcon -->
43
- <CmdIcon :iconClass="getStatusIconClass" />
44
- <!-- end CmdIcon -->
45
- </button>
46
- <!-- end status-icon (linked with tooltip) -->
47
-
48
- <!-- begin CmdTooltip -->
49
- <CmdTooltip
50
- ref="tooltip"
51
- :class="['cmd-tooltip-for-form-elements box', validationStatus]"
52
- :id="'tooltip-target-' + htmlId"
53
- :scrollContainer="scrollContainerForTooltip"
54
- :popoverTargetName="'tooltip-target-' + htmlId"
55
- :validationStatus="validationStatus"
56
- :role="validationStatus === 'error' ? 'alert' : 'dialog'"
57
- :toggle-visibility-by-click="true"
58
- :style="'position-anchor: --tooltip-anchor-' + htmlId"
59
- >
60
-
61
- <!-- begin CmdListOfRequirements -->
62
- <CmdListOfRequirements
63
- v-if="cmdListOfRequirementsProperties.showRequirements"
64
- v-bind="cmdListOfRequirementsProperties"
65
- />
66
- <!-- end CmdListOfRequirements -->
67
- </CmdTooltip>
68
- <!-- end CmdTooltip -->
69
- </span>
70
- <!-- end label-text (+ required asterisk) -->
71
-
72
- <!-- begin element 'input' -->
73
- <template v-if="element === 'input'">
74
- <span v-if="$attrs.type !== 'checkbox' && $attrs.type !== 'radio' && $attrs.type !== 'search'"
75
- class="flex-container inner-input-wrapper"><!-- container required to place inner icons correctly -->
76
- <!-- begin CmdIcon (for icon inside field) -->
77
- <CmdIcon v-if="fieldIconClass" class="place-inside" :iconClass="fieldIconClass" />
78
- <!-- end CmdIcon (for icon inside field) -->
79
-
80
- <!-- begin inputfield -->
81
- <template v-if="element === 'input' && $attrs.type !== 'search'">
82
- <input :id="htmlId" :class="inputClass" @focus="tooltip = true" @blur="onBlur" @input="onInput"
83
- @mouseover="datalistFocus" @keyup="checkForCapsLock" @change="$emit('change', $event)"
84
- :autocomplete="autocomplete" :list="datalist ? datalist.id : null"
85
- :value="modelValue"
86
- :minlength="$attrs.type === 'password' ? '8' : null"
87
- :maxlength="getMaxLength()"
88
- ref="input"
89
- v-bind="elementAttributes" />
90
- <!-- begin delete-icon -->
91
- <a v-if="iconDelete?.show && !$attrs.disabled && ($attrs.type === 'text' || $attrs.type === 'email' || $attrs.type === 'phone')"
92
- class="deleteicon" href="#" @click.prevent="deleteInput" :title="iconDelete?.tooltip">
93
- <CmdIcon :iconClass="iconDelete?.iconClass" :type="iconDelete?.iconType" />
94
- </a>
95
- <!-- end delete-icon -->
96
- </template>
97
- <!-- end inputfield -->
98
-
99
- <!-- begin show-password-icon -->
100
- <a v-if="$attrs.type === 'password'" href="#" class="place-inside" @mousedown.prevent="showPassword"
101
- @mouseup.prevent="hidePassword" @mouseleave.prevent="hidePassword" @click.prevent
102
- :title="iconPasswordVisible.tooltip">
103
- <CmdIcon :iconClass="iconPasswordVisible.iconClass" />
104
- </a>
105
- <!-- end show-password-icon -->
106
- </span>
107
-
108
- <!-- begin datalist -->
109
- <template v-if="datalist && datalist.options.length">
110
- <datalist :id="datalist.id">
111
- <option v-for="(option, index) in datalist.options" :key="index" :value="option"></option>
112
- </datalist>
113
- </template>
114
- <!-- end datalist -->
115
-
116
- <!-- begin checkbox and radiobutton -->
117
- <template v-else-if="$attrs.type === 'checkbox' || $attrs.type === 'radio'">
118
- <!-- begin default checkbox/radiobutton -->
119
- <template v-if="!(onLabel && offLabel)">
120
- <input v-bind="elementAttributes" @change="onChange" @blur="onBlur" :checked="isChecked"
121
- :value="inputValue"
122
- :class="[inputClass, validationStatus, toggleSwitchIconClass, { 'replace-input-type': replaceInputType }]"
123
- :id="htmlId" :disabled="$attrs.disabled" :aria-invalid="validationStatus === 'error'" />
124
- <span v-if="labelText || $slots.labeltext" :class="['label-text', { hidden: !showLabel }]">
125
- <span>
126
- <!-- begin labelText for checkbox/radio/toggle-switch (without switch-label) -->
127
- <span v-if="labelText" v-html="labelText"></span>
128
- <!-- end labelText for checkbox/radio/toggle-switch (without switch-label) -->
129
-
130
- <!-- begin slot 'labeltext' -->
131
- <slot v-else name="labeltext" />
132
- <!-- end slot 'labeltext' -->
133
-
134
- <sup v-if="$attrs.required">*</sup>
135
- </span>
136
- </span>
137
- </template>
138
- <!-- end default checkbox/radiobutton -->
139
-
140
- <!-- begin labels for toggle-switch with switch-label -->
141
- <template v-else-if="onLabel && offLabel">
142
- <span class="switch-label-wrapper">
143
- <input v-bind="elementAttributes" @change="onChange" @blur="onBlur" :checked="isChecked"
144
- :value="inputValue" :class="[inputClass, validationStatus]" :id="htmlId"
145
- :disabled="$attrs.disabled" :aria-invalid="validationStatus === 'error'" />
146
- <span class="label-text">{{ onLabel }}</span>
147
- <span class="label-text">{{ offLabel }}</span>
148
- </span>
149
- <!-- begin labelText for checkbox/radio/toggle-switch (with switch-label) -->
150
- <span v-if="labelText" :class="['label-text', { hidden: !showLabel }]">
151
- <span v-html="labelText"></span><sup v-if="$attrs.required">*</sup>
152
- </span>
153
- <!-- end labelText for checkbox/radio/toggle-switch (with switch-label) -->
154
- </template>
155
- <slot v-else></slot>
156
- <!-- end labels for toggle-switch with switch-label -->
157
- </template>
158
- <!-- end checkbox and radiobutton -->
159
- </template>
160
- <!-- end element 'input' -->
161
-
162
- <!-- begin selectbox -->
163
- <select v-if="element === 'select'" v-bind="elementAttributes" :id="htmlId" @blur="onBlur" @change="onChange">
164
- <option v-if="!groupSelectOptionsByInitialLetters" v-for="(option, index) in selectOptions" :key="index"
165
- :value="option.value" :selected="option.value === modelValue">
166
- {{ option.text }}
167
- </option>
168
- <optgroup v-else :label="key" v-for="(options, key) in initialLetters" :key="key">
169
- <option v-for="(option, optionIndex) in options" :key="optionIndex" :value="option.value"
170
- :selected="option.value === modelValue">
171
- {{ option.text }}
172
- </option>
173
- </optgroup>
174
- </select>
175
- <!-- end selectbox -->
176
-
177
- <!-- begin textarea -->
178
- <textarea v-if="element === 'textarea'" v-bind="elementAttributes" :id="htmlId" :value="modelValue"
179
- :maxlength="getMaxLength()" @input="onInput" @focus="tooltip = true"
180
- @blur="onBlur"></textarea><!-- no line-break to avoid empty spaces inside textarea -->
181
- <span v-if="element === 'textarea' && showCharactersTextarea" class="characters-left-wrapper">
182
- <span v-if="textCharactersLeft">{{ textCharactersLeft }}</span>
183
- <span :class="['characters-left', { error: charactersLeft === 0 }]">{{ charactersLeft }}</span>
184
- </span>
185
- <!-- end textarea -->
186
-
187
- <!-- begin searchfield -->
188
- <template v-else-if="element === 'input' && $attrs.type === 'search'">
189
- <span class="inner-input-wrapper flex-container no-gap">
190
- <!-- begin CmdIcon (for icon inside field) -->
191
- <CmdIcon v-if="fieldIconClass" class="place-inside" :iconClass="fieldIconClass" />
192
- <!-- end CmdIcon (for icon inside field) -->
193
- <input v-bind="elementAttributes" :id="htmlId" @input="onInput" :maxlength="getMaxLength()"
194
- :value="modelValue" />
195
- <a v-if="showSearchButton" href="#" :class="['button flex-none', { disabled: $attrs.disabled }]"
196
- :title="iconSearch.tooltip" @click.prevent="executeSearch">
197
- <!-- begin CmdIcon -->
198
- <CmdIcon :iconClass="iconSearch.iconClass" />
199
- <!-- end CmdIcon -->
200
- </a>
201
- <a v-if="iconDelete?.show && !$attrs.disabled" class="deleteicon" href="#" @click.prevent="deleteInput"
202
- :title="iconDelete?.tooltip">
203
- <!-- begin CmdIcon -->
204
- <CmdIcon :iconClass="iconDelete?.iconClass" :type="iconDelete?.iconType" />
205
- <!-- end CmdIcon -->
206
- </a>
207
- </span>
208
- </template>
209
- </label>
210
- <!-- end searchfield -->
211
-
212
- <!-- begin button -->
213
- <button v-else-if="element === 'button'" class="button" v-bind="buttonAttrs" @click="submit">
214
- <!-- begin CmdIcon -->
215
- <CmdIcon
216
- v-if="nativeButton?.icon?.show && (nativeButton?.icon?.position === 'before' || !nativeButton?.icon?.position)"
217
- :iconClass="nativeButton?.icon?.iconClass" :type="nativeButton?.icon?.iconType" />
218
- <!-- end CmdIcon -->
219
- <span v-if="nativeButton?.icon && nativeButton?.text">{{ nativeButton.text }}</span>
220
- <template v-else>
221
- {{ nativeButton.text }}
222
- </template>
223
- <!-- begin CmdIcon -->
224
- <CmdIcon v-if="nativeButton?.icon?.show && nativeButton?.icon?.position === 'after'"
225
- :iconClass="nativeButton?.icon?.iconClass" :type="nativeButton?.icon?.iconType" />
226
- <!-- end CmdIcon -->
227
- </button>
228
- <!-- end button -->
229
- <!-- end CmdFormElement ---------------------------------------------------------------------------------------- -->
230
- </template>
231
-
232
- <script>
233
- // import mixins
234
- import I18n from "../mixins/I18n"
235
- import DefaultMessageProperties from "../mixins/CmdFormElement/DefaultMessageProperties"
236
- import FieldValidation from "../mixins/FieldValidation.js"
237
- import Identifier from "../mixins/Identifier.js"
238
- import Tooltip from "../mixins/Tooltip.js"
239
-
240
- const TYPES_WITHOUT_MAXLENGTH = ["color", "date", "datetime-local", "file", "number", "range"]
241
-
242
- export default {
243
- inheritAttrs: false,
244
- name: "CmdFormElement",
245
- mixins: [
246
- I18n,
247
- DefaultMessageProperties,
248
- FieldValidation,
249
- Identifier,
250
- Tooltip
251
- ],
252
- emits: ["blur", "change", "validation-status-change", "update:modelValue"],
253
- data() {
254
- return {
255
- errorOccurred: 0
256
- }
257
- },
258
- props: {
259
- /**
260
- * set value for v-model (must be named modelValue in vue3 if default v-model should be used)
261
- */
262
- modelValue: {
263
- type: [String, Boolean, Array, Number],
264
- default: ""
265
- },
266
- /**
267
- * group entries of selectbox by first letter of its options
268
- */
269
- groupSelectOptionsByInitialLetters: {
270
- type: Boolean,
271
- default: false
272
- },
273
- /**
274
- * specify a scroll-container which scrolling hides the tooltip
275
- */
276
- scrollContainerForTooltip: {
277
- type: String,
278
- required: false
279
- },
280
- /**
281
- * set type of native form-element
282
- *
283
- * @allowedValues: input, select, textarea, button
284
- */
285
- element: {
286
- type: String,
287
- validator(value) {
288
- return value === "input" ||
289
- value === "select" ||
290
- value === "textarea" ||
291
- value === "button"
292
- },
293
- default() {
294
- return "input"
295
- }
296
- },
297
- /**
298
- * hide label (and asterisk if mandatory)
299
- *
300
- * label may not be removed, because it is required for accessibility
301
- */
302
- showLabel: {
303
- type: Boolean,
304
- default: true
305
- },
306
- /**
307
- * text for label
308
- *
309
- * @requiredForAccessibility: true
310
- * @canContainHtml: true
311
- */
312
- labelText: {
313
- type: String,
314
- required: false
315
- },
316
- /**
317
- * set to activate to use toggle-switch-styling
318
- *
319
- * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
320
- *
321
- * @affectsStyling: true
322
- */
323
- toggleSwitch: {
324
- type: Boolean,
325
- default: false
326
- },
327
- /**
328
- * text for on-label
329
- *
330
- * set to activate switch-label (=label is placed on toggle-switch (not behind))
331
- * toggleSwitch-prop must be set to "true"
332
- * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
333
- */
334
- onLabel: {
335
- type: String,
336
- required: false
337
- },
338
- /**
339
- * text for off-label
340
- *
341
- * set to activate switch-label (=label is placed on toggle-switch (not behind))
342
- * toggleSwitch-prop must be set to "true"
343
- * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
344
- */
345
- offLabel: {
346
- type: String,
347
- required: false
348
- },
349
- /**
350
- * on/off-, yes/no-color-styling
351
- *
352
- * set to true, if checkbox/radio-buttons should have green/checked and red/unchecked color-coding
353
- * toggleSwitch-prop must be set to "true"
354
- * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
355
- *
356
- * @affectsStyling: true
357
- */
358
- colored: {
359
- type: Boolean,
360
- required: false
361
- },
362
- /**
363
- * allow checkbox/radio-buttons to get value from outside
364
- */
365
- inputValue: {
366
- type: [String, Number],
367
- required: false
368
- },
369
- /**
370
- * for replacing native checkboxes/radio-buttons by custom ones (based on frontend-framework)
371
- *
372
- * @affectsStyling: true
373
- */
374
- replaceInputType: {
375
- type: Boolean,
376
- default: false
377
- },
378
- /**
379
- * set an optional class on native form-element (use native class="" on component ot set class on outer-component-element)
380
- *
381
- * may not be named as 'class' because it is a reserved keyword in JavaScript
382
- */
383
- inputClass: {
384
- type: String,
385
- required: false
386
- },
387
- /**
388
- * set if a native datalist should be used
389
- */
390
- datalist: {
391
- type: Object,
392
- required: false
393
- },
394
- /**
395
- * list of options for selectbox
396
- *
397
- * element-property must be 'select'
398
- */
399
- selectOptions: {
400
- type: Array,
401
- required: false
402
- },
403
- /**
404
- * activate if interactive status-icon (to show requirements) should be shown inline with label
405
- */
406
- showStatusIcon: {
407
- type: Boolean,
408
- default: true
409
- },
410
- /**
411
- * native button
412
- */
413
- nativeButton: {
414
- type: Object,
415
- default() {
416
- return {
417
- text: "",
418
- icon: {
419
- show: true,
420
- iconClass: "",
421
- position: "left",
422
- tooltip: ""
423
- }
424
- }
425
- }
426
- },
427
- /**
428
- * set class for inner icon (icon placed 'inside' input/ left of input-text)
429
- *
430
- * element-property must be 'input' and type-property may not be checkbox or radio
431
- */
432
- fieldIconClass: {
433
- type: String,
434
- required: false
435
- },
436
- /**
437
- * activate if label-text should be place inline/left of form-element (and not above)
438
- *
439
- * type-property may not be checkbox or radio
440
- */
441
- displayLabelInline: {
442
- type: Boolean,
443
- required: false
444
- },
445
- /**
446
- * activate if field should be stretch over remaining (horizontal) space if inline
447
- *
448
- * displayLabelInline-property must be activated
449
- */
450
- stretchField: {
451
- type: Boolean,
452
- default: false
453
- },
454
- /**
455
- * set status for label and form-element
456
- *
457
- * @allowedValues: "", error, warning, success, info
458
- *
459
- * @affectsStyling: true
460
- */
461
- status: {
462
- type: String,
463
- required: false,
464
- validator(value) {
465
- return value === "" ||
466
- value === "error" ||
467
- value === "warning" ||
468
- value === "success" ||
469
- value === "info"
470
- }
471
- },
472
- /**
473
- * toggle display of number of used and allowed characters for textarea
474
- *
475
- * type-property must be set to textarea
476
- */
477
- showCharactersTextarea: {
478
- type: Boolean,
479
- default: true
480
- },
481
- /**
482
- * text shown in front of character-count below textarea
483
- *
484
- * type-property must be set to textarea
485
- * showCharactersTextarea-property must be activated
486
- */
487
- textCharactersLeft: {
488
- type: String,
489
- default: "Characters left:"
490
- },
491
- /**
492
- * toggle visibility of search-button (next to search-field)
493
- */
494
- showSearchButton: {
495
- type: Boolean,
496
- default: true
497
- },
498
- /**
499
- * icon to delete search term
500
- *
501
- * element-property must be set to 'input'
502
- * type-property must be set to 'search'
503
- *
504
- */
505
- iconDelete: {
506
- type: Object,
507
- default() {
508
- return {
509
- show: true,
510
- iconClass: "icon-cancel-circle",
511
- tooltip: "Delete term"
512
- }
513
- }
514
- },
515
- /**
516
- * icon to search term
517
- *
518
- * element-property must be set to 'input'
519
- * type-property must be set to 'search'
520
- *
521
- */
522
- iconSearch: {
523
- type: Object,
524
- default() {
525
- return {
526
- show: true,
527
- iconClass: "icon-search",
528
- tooltip: "Search"
529
- }
530
- }
531
- },
532
- /**
533
- * icon for error-validated items in list-of-requirements
534
- *
535
- * element-property must be set to 'input'
536
- * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
537
- *
538
- */
539
- iconHasStateError: {
540
- type: Object,
541
- default() {
542
- return {
543
- show: true,
544
- iconClass: "icon-error-circle",
545
- tooltip: "Error"
546
- }
547
- }
548
- },
549
- /**
550
- * icon for warning-validated items in list-of-requirements
551
- *
552
- * element-property must be set to 'input'
553
- * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
554
- *
555
- */
556
- iconHasStateWarning: {
557
- type: Object,
558
- default() {
559
- return {
560
- show: true,
561
- iconClass: "icon-warning-circle",
562
- tooltip: "Warning"
563
- }
564
- }
565
- },
566
- /**
567
- * icon for success-validated items in list-of-requirements
568
- *
569
- * element-property must be set to 'input'
570
- * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
571
- *
572
- */
573
- iconHasStateSuccess: {
574
- type: Object,
575
- default() {
576
- return {
577
- show: true,
578
- iconClass: "icon-check-circle",
579
- tooltip: "Success"
580
- }
581
- }
582
- },
583
- /**
584
- * icon for info-validated items in list-of-requirements
585
- *
586
- * element-property must be set to 'input'
587
- * showRequirements-sub-property (of CmdListOfRequirements) must be set to 'true'
588
- *
589
- */
590
- iconHasStateInfo: {
591
- type: Object,
592
- default() {
593
- return {
594
- show: true,
595
- iconClass: "icon-info-circle",
596
- tooltip: "Info"
597
- }
598
- }
599
- },
600
- /**
601
- * toggle if toggle-switch shows icons for checked/unchecked-status
602
- */
603
- useIconsForToggleSwitch: {
604
- type: Boolean,
605
- default: false
606
- },
607
- /**
608
- * icon for toggle-switch checked
609
- *
610
- * toggle-switch-property must be activated
611
- * use-icons-for-toggle-switch-property must be activated
612
- */
613
- toggleSwitchCheckedIconClass: {
614
- type: String,
615
- default: "icon-check-circle"
616
- },
617
- /**
618
- * icon for toggle-switch unchecked
619
- *
620
- * toggle-switch-property must be activated
621
- * use-icons-for-toggle-switch-property must be activated
622
- */
623
- toggleSwitchUncheckedIconClass: {
624
- type: String,
625
- default: "icon-cancel-circle"
626
- },
627
- /**
628
- * icon to toggle password-visibility
629
- *
630
- * element-property must be set to 'input'
631
- * type-property must be set to 'password'
632
- *
633
- */
634
- iconPasswordVisible: {
635
- type: Object,
636
- default() {
637
- return {
638
- show: true,
639
- iconClass: "icon-visible",
640
- tooltip: "Show password"
641
- }
642
- }
643
- },
644
- /**
645
- * icon to toggle password-visibility
646
- *
647
- * element-property must be set to 'input'
648
- * type-property must be set to 'password'
649
- *
650
- */
651
- iconPasswordInvisible: {
652
- type: Object,
653
- default() {
654
- return {
655
- show: true,
656
- iconClass: "icon-not-visible"
657
- }
658
- }
659
- },
660
- /**
661
- * properties for CmdListOfRequirements-component
662
- */
663
- cmdListOfRequirements: {
664
- type: Object,
665
- required: false
666
- }
667
- },
668
- computed: {
669
- cmdListOfRequirementsProperties() {
670
- return {
671
- showRequirements: true,
672
- validationTooltip: "",
673
- inputRequirements: [],
674
- inputAttributes: {},
675
- showHeadline: true,
676
- inputModelValue: "",
677
- helplink: {},
678
- labelText: "",
679
- ...this.cmdListOfRequirements
680
- }
681
- },
682
- initialLetters() {
683
- return this.getInitialLetters(this.selectOptions)
684
- },
685
- elementAttributes() {
686
- const commonAttributes = ["name", "required", "readonly", "disabled", "autofocus"]
687
- const attributes = {
688
- input: [...commonAttributes, "type", "minlength", "pattern", "min", "max", "multiple", "step", "autocomplete", "placeholder"],
689
- select: [...commonAttributes, "multiple"],
690
- textarea: [...commonAttributes, "placeholder"]
691
- }
692
- const attrs = {}
693
- if (attributes[this.element]) {
694
- Object.entries(this.$attrs).filter(([name]) => attributes[this.element].includes(name)).forEach(([name, value]) => attrs[name] = value)
695
- }
696
- return attrs
697
- },
698
- buttonAttrs() {
699
- // copy all native attributes
700
- const allAttrs = { ...this.$attrs }
701
-
702
- // check if specific tooltip for icon is set (and add as title-attribute)
703
- if (this.nativeButton.icon?.tooltip) {
704
- allAttrs.title = this.nativeButton.icon?.tooltip
705
- }
706
-
707
- return allAttrs
708
- },
709
- tooltipHeadline() {
710
- return {
711
- text: this.labelText,
712
- level: "5"
713
- }
714
- },
715
- isChecked() {
716
- if (typeof this.modelValue === "boolean") {
717
- return this.modelValue
718
- }
719
- if (typeof this.modelValue === "string") {
720
- return this.modelValue === this.inputValue
721
- }
722
- if (typeof this.modelValue === "number") {
723
- return this.modelValue === this.inputValue
724
- }
725
- if (this.modelValue !== undefined) {
726
- return this.modelValue.includes(this.inputValue)
727
- }
728
- return false
729
- },
730
- charactersLeft() {
731
- return this.getMaxLength() - this.modelValue.length
732
- },
733
- validationTooltip() {
734
- if (!this.useCustomTooltip) {
735
- return this.getValidationMessage
736
- }
737
-
738
- // set default-tooltip if customTooltip is not set
739
- if (this.validationStatus === 'error') {
740
- return this.getMessage("form_element.validation_tooltip.an_error_occurred")
741
- } else if (this.validationStatus === 'success') {
742
- return this.getMessage("form_element.validation_tooltip.information_is_filled_correctly")
743
- } else if (this.capsLockActivated) {
744
- return this.getMessage("form_element.validation_tooltip.caps_lock_is_activated")
745
- }
746
- return this.getMessage("form_element.validation_tooltip.open_field_requirements")
747
- },
748
- autocomplete() {
749
- if (this.$attrs.type !== 'file') {
750
- return this.datalist ? 'off' : 'on'
751
- }
752
- return null
753
- },
754
- // toggle icons for toggle-switch
755
- toggleSwitchIconClass() {
756
- if (this.toggleSwitch && this.useIconsForToggleSwitch && this.toggleSwitchUncheckedIconClass && this.toggleSwitchCheckedIconClass) {
757
- if (this.isChecked) {
758
- return this.toggleSwitchCheckedIconClass
759
- }
760
- return this.toggleSwitchUncheckedIconClass
761
- }
762
- return null
763
- }
764
- },
765
- methods: {
766
- deleteInput() {
767
- this.setFocus()
768
- this.$emit("update:modelValue", '')
769
- },
770
- getInitialLetters(listOfOptions) {
771
- const groupedListOfOptions = {}
772
- // compare the text-keys (in lower case) and sort them
773
- listOfOptions.sort((a, b) => a.text.toLowerCase().localeCompare(b.text.toLowerCase()))
774
-
775
- for (let i = 0; i < listOfOptions.length; i++) {
776
- const initialLetter = listOfOptions[i].text.slice(0, 1)
777
- if (!groupedListOfOptions[initialLetter]) {
778
- groupedListOfOptions[initialLetter] = []
779
- }
780
- groupedListOfOptions[initialLetter].push(listOfOptions[i])
781
- }
782
- return groupedListOfOptions
783
- },
784
- setFocus() {
785
- this.$refs.label.querySelector("input, select, textarea")?.focus()
786
- },
787
- additionalStandardRequirements() {
788
- const requirements = []
789
- // check if field is type "email"
790
- if (this.$attrs.type === "email") {
791
- requirements.push({
792
- message: this.getMessage("form_element.validation_tooltip.is_valid_email"),
793
- valid: () => this.$refs.input?.checkValidity()
794
- })
795
- }
796
- return requirements
797
- },
798
- getDomElement() {
799
- return this.$refs.label
800
- },
801
- // define max-length for different input-types
802
- getMaxLength() {
803
- if (this.$attrs.element === 'textarea') {
804
- return this.$attrs.maxlength > 0 ? this.$attrs.maxlength : 5000
805
- }
806
-
807
- if (!TYPES_WITHOUT_MAXLENGTH.includes(this.$attrs.type)) {
808
- return this.$attrs.maxlength > 0 ? this.$attrs.maxlength : 255
809
- }
810
- return null
811
- },
812
- validateInput(event) {
813
- // check if surrounding form with data-use-validation exists
814
- const useValidation = event.target.closest("form")?.dataset.useValidation === "true"
815
-
816
- if (useValidation) {
817
- // get value from input-element
818
- const value = event.target.value
819
-
820
- // if input is filled, set status to success (expect for checkboxes and radiobuttons)
821
- //if (!["checkbox", "radio"].includes(this.$attrs.type) && value) {
822
- this.validationStatus = "success"
823
- //}
824
-
825
- if (typeof event.target.checkValidity === "function" && !event.target.checkValidity()) {
826
- this.validationStatus = "error"
827
- } else {
828
- if (this.customRequirements) {
829
- // check if customRequirement returns invalid result
830
- const invalidCustomRequirement = this.customRequirements.some(requirement => {
831
- return !requirement.valid(value)
832
- })
833
-
834
- // set validation-status if invalidCustomRequirement returns at least one invalid entry
835
- if (invalidCustomRequirement) {
836
- this.validationStatus = "error"
837
- }
838
- }
839
- }
840
-
841
- this.$emit("validation-status-change", this.validationStatus)
842
- }
843
- },
844
- onBlur(event) {
845
- this.validateInput(event)
846
- this.closeTooltipOnBlur()
847
- this.$emit("blur", event)
848
- },
849
- onInput(event) {
850
- this.validateInput(event)
851
- this.$emit("update:modelValue", event.target.value)
852
- },
853
- onChange(event) {
854
- this.validateInput(event)
855
-
856
- if (typeof this.modelValue === "boolean") {
857
- this.$emit("update:modelValue", event.target.checked)
858
- } else if (typeof this.modelValue === "string") {
859
- this.$emit("update:modelValue", event.target.value)
860
- } else if (this.modelValue !== undefined) {
861
- let values = [...this.modelValue]
862
- if (event.target.checked) {
863
- values.push(event.target.value)
864
- } else {
865
- values = values.filter(value => value !== event.target.value)
866
- }
867
- this.$emit("update:modelValue", values)
868
- }
869
- },
870
- datalistFocus() {
871
- /* corrects focus-bug for datalist in firefox */
872
- if (this.datalist) {
873
- this.$refs.label.focus()
874
- }
875
- },
876
- showPassword() {
877
- // get password-field
878
- const passwordField = this.$refs.input
879
-
880
- // get value of password field (to save it temporary)
881
- const password = passwordField.value
882
-
883
- // toggle input-type to make password visible
884
- passwordField.nextElementSibling.classList.replace(this.iconPasswordVisible.iconClass, this.iconPasswordInvisible.iconClass)
885
- passwordField.setAttribute("type", "text")
886
-
887
- // assign saved password back to field
888
- passwordField.setAttribute("value", password)
889
- },
890
- hidePassword() {
891
- this.$refs.input.nextElementSibling.classList.replace(this.iconPasswordInvisible.iconClass, this.iconPasswordVisible.iconClass)
892
- this.$refs.input.setAttribute("type", "password")
893
- },
894
- executeSearch() {
895
- this.$emit("search", this.value)
896
- },
897
- closeTooltipOnBlur() {
898
- // close tooltip by calling function from CmdTooltipForInputElements using $refs
899
- if (this.$refs.tooltip) {
900
- this.$refs.tooltip.hideTooltip()
901
- }
902
- },
903
- // (submit-)button is clicked
904
- submit(event) {
905
- this.$emit("submit", event)
906
- }
907
- },
908
- watch: {
909
- status: {
910
- handler() {
911
- this.validationStatus = this.status || ""
912
- },
913
- immediate: true
914
- }
915
- }
916
- }
917
- </script>
918
-
919
- <style>
920
- /* begin cmd-form-element ------------------------------------------------------------------------------------------ */
921
- .cmd-form-element {
922
- & input.replace-input-type {
923
- &:checked {
924
- &::after {
925
- top: 0;
926
- }
927
- }
928
- }
929
-
930
- /* icon right aligned in input */
931
- input+.place-inside {
932
- left: auto;
933
- right: .5rem;
934
- color: var(--hyperlink-color);
935
-
936
- span {
937
- color: inherit;
938
- }
939
- }
940
-
941
- .label-text {
942
- :is(a, span)[class*="icon-"] {
943
- top: .09rem;
944
- }
945
- }
946
-
947
- &:has([required]) {
948
- &.has-state,
949
- &+.cmd-tooltip {
950
- &.error {
951
- * {
952
- --status-color: var(--error-color);
953
- }
954
- }
955
-
956
- ::placeholder {
957
- color: var(--status-color);
958
- }
959
-
960
- span {
961
- color: var(--status-color);
962
-
963
- &.place-inside {
964
- color: inherit;
965
- }
966
- }
967
-
968
- &.success {
969
- * {
970
- --status-color: var(--success-color);
971
- --form-input-text-color: var(--success-color);
972
- }
973
-
974
- &:has(input[type="checkbox"], input[type="radio"]) {
975
- * {
976
- --status-color: var(--color-scheme-text-color);
977
- /* overwrite --status-color (success) for chekcboxes and radiobuttons */
978
- }
979
- }
980
- }
981
- }
982
- }
983
-
984
- :is(input[type="checkbox"], input[type="radio"]):checked {
985
- ~.label-text span {
986
- color: var(--hyperlink-color);
987
- }
988
-
989
- &:hover,
990
- &:active,
991
- &:focus {
992
- ~.label-text span {
993
- color: var(--hyperlink-color-highlighted);
994
- }
995
- }
996
- }
997
-
998
- &.inline {
999
- .inner-input-wrapper {
1000
- &>a:not(.button) {
1001
- margin-left: calc(var(--default-margin) / 2);
1002
- }
1003
- }
1004
-
1005
- &.stretch-field {
1006
- .inner-input-wrapper {
1007
- width: 100%;
1008
- }
1009
- }
1010
-
1011
- .label-text {
1012
- [class*="icon-"] {
1013
- top: -.2rem;
1014
- }
1015
- }
1016
- }
1017
-
1018
- .inner-input-wrapper {
1019
- margin: 0;
1020
-
1021
- &:has(.button, button) {
1022
- input {
1023
- border-top-right-radius: 0;
1024
- border-bottom-right-radius: 0;
1025
- }
1026
- }
1027
-
1028
- a.deleteicon {
1029
- position: absolute;
1030
- top: 50%;
1031
- right: 1rem;
1032
- transform: translateY(-50%);
1033
- z-index: 100;
1034
- width: auto;
1035
- /* avoid to be stretched to keep correct position */
1036
-
1037
- /* set styles to avoid overwriting by has-state-colors */
1038
- &.button {
1039
- span {
1040
- color: var(--color-scheme-background);
1041
- }
1042
-
1043
- &:hover,
1044
- &:active,
1045
- &:focus {
1046
- span {
1047
- color: var(--color-scheme-text-color);
1048
- }
1049
- }
1050
- }
1051
- }
1052
-
1053
- a.button {
1054
- right: 0;
1055
- align-self: stretch;
1056
- aspect-ratio: 1 / 1;
1057
-
1058
- /* square */
1059
- &+a {
1060
- right: 5rem;
1061
- }
1062
- }
1063
- }
1064
-
1065
- .place-inside {
1066
- &+input {
1067
- padding-left: calc(var(--default-padding) * 3);
1068
- }
1069
- }
1070
-
1071
- .characters-left-wrapper {
1072
- margin-top: calc(var(--default-margin) / 2);
1073
- display: block;
1074
-
1075
- span:not(:only-child):first-child {
1076
- margin-right: calc(var(--default-margin) / 2);
1077
- color: var(--color-scheme-text-color);
1078
- }
1079
-
1080
- .characters-left {
1081
- color: var(--color-scheme-text-color);
1082
-
1083
- &.error {
1084
- color: var(--error-color);
1085
- }
1086
- }
1087
- }
1088
- }
1089
-
1090
- /* end cmd-form-element------------------------------------------------------------------------------------------ */
1091
- </style>
1
+ <template>
2
+ <!-- begin CmdFormElement ---------------------------------------------------------------------------------------- -->
3
+ <label v-if="(element === 'input' || element === 'select' || element === 'textarea')" :class="[
4
+ 'cmd-form-element',
5
+ $attrs.class,
6
+ $attrs.required ? validationStatus : null,
7
+ {
8
+ disabled: $attrs.disabled,
9
+ inline: displayLabelInline,
10
+ 'stretch-field': stretchField,
11
+ 'toggle-switch': toggleSwitch,
12
+ colored: colored,
13
+ 'has-state': validationStatus
14
+ }
15
+ ]" :for="htmlId" :title="$attrs.title" ref="label">
16
+
17
+ <!-- begin label-text (+ required asterisk) -->
18
+ <span v-if="(labelText || $slots.labeltext) && $attrs.type !== 'checkbox' && $attrs.type !== 'radio'"
19
+ :class="['label-text', { 'visually-hidden': !showLabel }]">
20
+ <span>
21
+ <span v-if="labelText" v-html="labelText"></span>
22
+
23
+ <!-- begin slot 'labeltext' -->
24
+ <slot v-else name="labeltext" />
25
+ <!-- end slot 'labeltext' -->
26
+
27
+ <!-- begin required asterisk -->
28
+ <sup v-if="$attrs.required != null && $attrs.required !== false" aria-hidden="true">*</sup>
29
+ <!-- end required asterisk -->
30
+ </span>
31
+
32
+ <!-- begin status-icon (linked with tooltip) -->
33
+ <!-- (span with role="button" instead of <button>: a <label> must not contain a second labelable control) -->
34
+ <span v-if="($attrs.required || inputRequirements.length) && showStatusIcon"
35
+ role="button"
36
+ tabindex="0"
37
+ class="no-style status-icon-button"
38
+ :aria-label="validationTooltip"
39
+ :title="validationTooltip"
40
+ @click.prevent.stop="toggleStatusTooltip"
41
+ @keydown.enter.prevent.stop="toggleStatusTooltip"
42
+ @keydown.space.prevent.stop="toggleStatusTooltip"
43
+ aria-haspopup="true"
44
+ :style="'anchor-name: --tooltip-anchor-' + htmlId"
45
+ >
46
+ <!-- begin CmdIcon -->
47
+ <CmdIcon :iconClass="getStatusIconClass" />
48
+ <!-- end CmdIcon -->
49
+ </span>
50
+ <!-- end status-icon (linked with tooltip) -->
51
+
52
+ <!-- begin CmdTooltip -->
53
+ <CmdTooltip
54
+ ref="tooltip"
55
+ class="cmd-tooltip-for-form-elements box"
56
+ :id="'tooltip-target-' + htmlId"
57
+ :scrollContainer="scrollContainerForTooltip"
58
+ :popoverTargetName="'tooltip-target-' + htmlId"
59
+ :validationStatus="validationStatus"
60
+ :role="validationStatus === 'error' ? 'alert' : 'dialog'"
61
+ :toggle-visibility-by-click="true"
62
+ :style="'position-anchor: --tooltip-anchor-' + htmlId"
63
+ >
64
+
65
+ <!-- begin CmdListOfRequirements -->
66
+ <CmdListOfRequirements
67
+ v-if="cmdListOfRequirementsProperties.showRequirements"
68
+ v-bind="cmdListOfRequirementsProperties"
69
+ />
70
+ <!-- end CmdListOfRequirements -->
71
+ </CmdTooltip>
72
+ <!-- end CmdTooltip -->
73
+ </span>
74
+ <!-- end label-text (+ required asterisk) -->
75
+
76
+ <!-- begin element 'input' -->
77
+ <template v-if="element === 'input'">
78
+ <span v-if="$attrs.type !== 'checkbox' && $attrs.type !== 'radio' && $attrs.type !== 'search'"
79
+ class="flex-container inner-input-wrapper"><!-- container required to place inner icons correctly -->
80
+ <!-- begin CmdIcon (for icon inside field) -->
81
+ <CmdIcon v-if="fieldIconClass" class="place-inside" :iconClass="fieldIconClass" />
82
+ <!-- end CmdIcon (for icon inside field) -->
83
+
84
+ <!-- begin inputfield -->
85
+ <template v-if="element === 'input' && $attrs.type !== 'search'">
86
+ <input :id="htmlId" :class="inputClass" @focus="tooltip = true" @blur="onBlur" @input="onInput"
87
+ @mouseover="datalistFocus" @keyup="checkForCapsLock" @change="$emit('change', $event)"
88
+ :autocomplete="autocomplete" :list="datalist ? datalist.id : null"
89
+ :value="modelValue"
90
+ :minlength="$attrs.type === 'password' ? '8' : null"
91
+ :maxlength="getMaxLength()"
92
+ ref="input"
93
+ v-bind="elementAttributes" />
94
+ <!-- begin delete-icon -->
95
+ <a v-if="iconDelete?.show && !$attrs.disabled && ($attrs.type === 'text' || $attrs.type === 'email' || $attrs.type === 'tel' || $attrs.type === 'phone')"
96
+ class="deleteicon" href="#" @click.prevent="deleteInput" :title="iconDelete?.tooltip">
97
+ <CmdIcon :iconClass="iconDelete?.iconClass" :type="iconDelete?.iconType" />
98
+ </a>
99
+ <!-- end delete-icon -->
100
+ </template>
101
+ <!-- end inputfield -->
102
+
103
+ <!-- begin show-password-icon -->
104
+ <a v-if="$attrs.type === 'password'" href="#" class="place-inside" @mousedown.prevent="showPassword"
105
+ @mouseup.prevent="hidePassword" @mouseleave.prevent="hidePassword" @click.prevent
106
+ :title="iconPasswordVisible.tooltip">
107
+ <CmdIcon :iconClass="iconPasswordVisible.iconClass" />
108
+ </a>
109
+ <!-- end show-password-icon -->
110
+ </span>
111
+
112
+ <!-- begin datalist -->
113
+ <template v-if="datalist && datalist.options.length">
114
+ <datalist :id="datalist.id">
115
+ <option v-for="(option, index) in datalist.options" :key="index" :value="option"></option>
116
+ </datalist>
117
+ </template>
118
+ <!-- end datalist -->
119
+
120
+ <!-- begin checkbox and radiobutton -->
121
+ <template v-else-if="$attrs.type === 'checkbox' || $attrs.type === 'radio'">
122
+ <!-- begin default checkbox/radiobutton -->
123
+ <template v-if="!(onLabel && offLabel)">
124
+ <input v-bind="elementAttributes" @change="onChange" @blur="onBlur" :checked="isChecked"
125
+ :value="inputValue"
126
+ :class="[inputClass, validationStatus, toggleSwitchIconClass, { 'replace-input-type': replaceInputType }]"
127
+ :id="htmlId" :disabled="$attrs.disabled" :aria-invalid="validationStatus === 'error'" />
128
+ <span v-if="labelText || $slots.labeltext" :class="['label-text', { 'visually-hidden': !showLabel }]">
129
+ <span>
130
+ <!-- begin slot 'labeltext' -->
131
+ <slot name="labeltext">
132
+ <!-- begin labelText for checkbox/radio/toggle-switch (without switch-label) -->
133
+ <span v-html="labelText"></span>
134
+ <!-- end labelText for checkbox/radio/toggle-switch (without switch-label) -->
135
+
136
+ <sup v-if="$attrs.required">*</sup>
137
+ </slot>
138
+ <!-- end slot 'labeltext' -->
139
+ </span>
140
+ </span>
141
+ </template>
142
+ <!-- end default checkbox/radiobutton -->
143
+
144
+ <!-- begin labels for toggle-switch with switch-label -->
145
+ <template v-else-if="onLabel && offLabel">
146
+ <span class="switch-label-wrapper">
147
+ <input v-bind="elementAttributes" @change="onChange" @blur="onBlur" :checked="isChecked"
148
+ :value="inputValue" :class="[inputClass, validationStatus]" :id="htmlId"
149
+ :disabled="$attrs.disabled" :aria-invalid="validationStatus === 'error'" />
150
+ <span class="label-text">{{ onLabel }}</span>
151
+ <span class="label-text">{{ offLabel }}</span>
152
+ </span>
153
+ <!-- begin labelText for checkbox/radio/toggle-switch (with switch-label) -->
154
+ <span v-if="labelText" :class="['label-text', { 'visually-hidden': !showLabel }]">
155
+ <span v-html="labelText"></span><sup v-if="$attrs.required">*</sup>
156
+ </span>
157
+ <!-- end labelText for checkbox/radio/toggle-switch (with switch-label) -->
158
+ </template>
159
+ <!-- end labels for toggle-switch with switch-label -->
160
+ </template>
161
+ <!-- end checkbox and radiobutton -->
162
+ </template>
163
+ <!-- end element 'input' -->
164
+
165
+ <!-- begin selectbox -->
166
+ <select v-if="element === 'select'" v-bind="elementAttributes" :id="htmlId" @blur="onBlur" @change="onChange">
167
+ <option v-if="!groupSelectOptionsByInitialLetters" v-for="(option, index) in selectOptions" :key="index"
168
+ :value="option.value" :selected="option.value === modelValue">
169
+ {{ option.text }}
170
+ </option>
171
+ <optgroup v-else :label="key" v-for="(options, key) in initialLetters" :key="key">
172
+ <option v-for="(option, optionIndex) in options" :key="optionIndex" :value="option.value"
173
+ :selected="option.value === modelValue">
174
+ {{ option.text }}
175
+ </option>
176
+ </optgroup>
177
+ </select>
178
+ <!-- end selectbox -->
179
+
180
+ <!-- begin textarea -->
181
+ <textarea v-if="element === 'textarea'" v-bind="elementAttributes" :id="htmlId" :value="modelValue"
182
+ :maxlength="getMaxLength()" @input="onInput" @focus="tooltip = true"
183
+ @blur="onBlur"></textarea><!-- no line-break to avoid empty spaces inside textarea -->
184
+ <span v-if="element === 'textarea' && showCharactersTextarea" class="characters-left-wrapper">
185
+ <span v-if="textCharactersLeft">{{ textCharactersLeft }}</span>
186
+ <span :class="['characters-left', { error: charactersLeft === 0 }]">{{ charactersLeft }}</span>
187
+ </span>
188
+ <!-- end textarea -->
189
+
190
+ <!-- begin searchfield -->
191
+ <template v-else-if="element === 'input' && $attrs.type === 'search'">
192
+ <span class="inner-input-wrapper flex-container no-gap">
193
+ <!-- begin CmdIcon (for icon inside field) -->
194
+ <CmdIcon v-if="fieldIconClass" class="place-inside" :iconClass="fieldIconClass" />
195
+ <!-- end CmdIcon (for icon inside field) -->
196
+ <input v-bind="elementAttributes" :id="htmlId" @input="onInput" :maxlength="getMaxLength()"
197
+ :value="modelValue" />
198
+ <a v-if="showSearchButton" href="#" :class="['button flex-none', { disabled: $attrs.disabled }]"
199
+ :title="iconSearch.tooltip" @click.prevent="executeSearch">
200
+ <!-- begin CmdIcon -->
201
+ <CmdIcon :iconClass="iconSearch.iconClass" />
202
+ <!-- end CmdIcon -->
203
+ </a>
204
+ <a v-if="iconDelete?.show && !$attrs.disabled" class="deleteicon" href="#" @click.prevent="deleteInput"
205
+ :title="iconDelete?.tooltip">
206
+ <!-- begin CmdIcon -->
207
+ <CmdIcon :iconClass="iconDelete?.iconClass" :type="iconDelete?.iconType" />
208
+ <!-- end CmdIcon -->
209
+ </a>
210
+ </span>
211
+ </template>
212
+ </label>
213
+ <!-- end searchfield -->
214
+
215
+ <!-- begin button -->
216
+ <button v-else-if="element === 'button'" class="button" v-bind="buttonAttrs" @click="submit">
217
+ <!-- begin CmdIcon -->
218
+ <CmdIcon
219
+ v-if="nativeButton?.icon?.show && (nativeButton?.icon?.position === 'before' || !nativeButton?.icon?.position)"
220
+ :iconClass="nativeButton?.icon?.iconClass" :type="nativeButton?.icon?.iconType" />
221
+ <!-- end CmdIcon -->
222
+ <span v-if="nativeButton?.icon && nativeButton?.text">{{ nativeButton.text }}</span>
223
+ <template v-else>
224
+ {{ nativeButton.text }}
225
+ </template>
226
+ <!-- begin CmdIcon -->
227
+ <CmdIcon v-if="nativeButton?.icon?.show && nativeButton?.icon?.position === 'after'"
228
+ :iconClass="nativeButton?.icon?.iconClass" :type="nativeButton?.icon?.iconType" />
229
+ <!-- end CmdIcon -->
230
+ </button>
231
+ <!-- end button -->
232
+ <!-- end CmdFormElement ---------------------------------------------------------------------------------------- -->
233
+ </template>
234
+
235
+ <script>
236
+ // import mixins
237
+ import I18n from "../mixins/I18n"
238
+ import DefaultMessageProperties from "../mixins/CmdFormElement/DefaultMessageProperties"
239
+ import FieldValidation from "../mixins/FieldValidation.js"
240
+ import Identifier from "../mixins/Identifier.js"
241
+ import Tooltip from "../mixins/Tooltip.js"
242
+
243
+ const TYPES_WITHOUT_MAXLENGTH = ["color", "date", "datetime-local", "file", "number", "range"]
244
+
245
+ export default {
246
+ inheritAttrs: false,
247
+ name: "CmdFormElement",
248
+ mixins: [
249
+ I18n,
250
+ DefaultMessageProperties,
251
+ FieldValidation,
252
+ Identifier,
253
+ Tooltip
254
+ ],
255
+ emits: ["blur", "change", "validation-status-change", "update:modelValue"],
256
+ data() {
257
+ return {
258
+ errorOccurred: 0
259
+ }
260
+ },
261
+ props: {
262
+ /**
263
+ * set value for v-model (must be named modelValue in vue3 if default v-model should be used)
264
+ */
265
+ modelValue: {
266
+ type: [String, Boolean, Array, Number],
267
+ default: ""
268
+ },
269
+ /**
270
+ * group entries of selectbox by first letter of its options
271
+ */
272
+ groupSelectOptionsByInitialLetters: {
273
+ type: Boolean,
274
+ default: false
275
+ },
276
+ /**
277
+ * specify a scroll-container which scrolling hides the tooltip
278
+ */
279
+ scrollContainerForTooltip: {
280
+ type: String,
281
+ required: false
282
+ },
283
+ /**
284
+ * set type of native form-element
285
+ *
286
+ * @allowedValues: input, select, textarea, button
287
+ */
288
+ element: {
289
+ type: String,
290
+ validator(value) {
291
+ return value === "input" ||
292
+ value === "select" ||
293
+ value === "textarea" ||
294
+ value === "button"
295
+ },
296
+ default() {
297
+ return "input"
298
+ }
299
+ },
300
+ /**
301
+ * hide label (and asterisk if mandatory)
302
+ *
303
+ * label may not be removed, because it is required for accessibility
304
+ */
305
+ showLabel: {
306
+ type: Boolean,
307
+ default: true
308
+ },
309
+ /**
310
+ * text for label
311
+ *
312
+ * @requiredForAccessibility: true
313
+ * @canContainHtml: true
314
+ */
315
+ labelText: {
316
+ type: String,
317
+ required: false
318
+ },
319
+ /**
320
+ * set to activate to use toggle-switch-styling
321
+ *
322
+ * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
323
+ *
324
+ * @affectsStyling: true
325
+ */
326
+ toggleSwitch: {
327
+ type: Boolean,
328
+ default: false
329
+ },
330
+ /**
331
+ * text for on-label
332
+ *
333
+ * set to activate switch-label (=label is placed on toggle-switch (not behind))
334
+ * toggleSwitch-prop must be set to "true"
335
+ * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
336
+ */
337
+ onLabel: {
338
+ type: String,
339
+ required: false
340
+ },
341
+ /**
342
+ * text for off-label
343
+ *
344
+ * set to activate switch-label (=label is placed on toggle-switch (not behind))
345
+ * toggleSwitch-prop must be set to "true"
346
+ * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
347
+ */
348
+ offLabel: {
349
+ type: String,
350
+ required: false
351
+ },
352
+ /**
353
+ * on/off-, yes/no-color-styling
354
+ *
355
+ * set to true, if checkbox/radio-buttons should have green/checked and red/unchecked color-coding
356
+ * toggleSwitch-prop must be set to "true"
357
+ * element-prop must be set to "input" and type-attribute must be set to "checkbox" or "radio"
358
+ *
359
+ * @affectsStyling: true
360
+ */
361
+ colored: {
362
+ type: Boolean,
363
+ required: false
364
+ },
365
+ /**
366
+ * allow checkbox/radio-buttons to get value from outside
367
+ */
368
+ inputValue: {
369
+ type: [String, Number],
370
+ required: false
371
+ },
372
+ /**
373
+ * for replacing native checkboxes/radio-buttons by custom ones (based on frontend-framework)
374
+ *
375
+ * @affectsStyling: true
376
+ */
377
+ replaceInputType: {
378
+ type: Boolean,
379
+ default: false
380
+ },
381
+ /**
382
+ * set an optional class on native form-element (use native class="" on component ot set class on outer-component-element)
383
+ *
384
+ * may not be named as 'class' because it is a reserved keyword in JavaScript
385
+ */
386
+ inputClass: {
387
+ type: String,
388
+ required: false
389
+ },
390
+ /**
391
+ * set if a native datalist should be used
392
+ */
393
+ datalist: {
394
+ type: Object,
395
+ required: false
396
+ },
397
+ /**
398
+ * list of options for selectbox
399
+ *
400
+ * element-property must be 'select'
401
+ */
402
+ selectOptions: {
403
+ type: Array,
404
+ required: false
405
+ },
406
+ /**
407
+ * activate if interactive status-icon (to show requirements) should be shown inline with label
408
+ */
409
+ showStatusIcon: {
410
+ type: Boolean,
411
+ default: true
412
+ },
413
+ /**
414
+ * native button
415
+ */
416
+ nativeButton: {
417
+ type: Object,
418
+ default() {
419
+ return {
420
+ text: "",
421
+ icon: {
422
+ show: true,
423
+ iconClass: "",
424
+ position: "left",
425
+ tooltip: ""
426
+ }
427
+ }
428
+ }
429
+ },
430
+ /**
431
+ * set class for inner icon (icon placed 'inside' input/ left of input-text)
432
+ *
433
+ * element-property must be 'input' and type-property may not be checkbox or radio
434
+ */
435
+ fieldIconClass: {
436
+ type: String,
437
+ required: false
438
+ },
439
+ /**
440
+ * activate if label-text should be place inline/left of form-element (and not above)
441
+ *
442
+ * type-property may not be checkbox or radio
443
+ */
444
+ displayLabelInline: {
445
+ type: Boolean,
446
+ required: false
447
+ },
448
+ /**
449
+ * activate if field should be stretch over remaining (horizontal) space if inline
450
+ *
451
+ * displayLabelInline-property must be activated
452
+ */
453
+ stretchField: {
454
+ type: Boolean,
455
+ default: false
456
+ },
457
+ /**
458
+ * set status for label and form-element
459
+ *
460
+ * @allowedValues: "", error, warning, success, info
461
+ *
462
+ * @affectsStyling: true
463
+ */
464
+ status: {
465
+ type: String,
466
+ required: false,
467
+ validator(value) {
468
+ return value === "" ||
469
+ value === "error" ||
470
+ value === "warning" ||
471
+ value === "success" ||
472
+ value === "info"
473
+ }
474
+ },
475
+ /**
476
+ * toggle display of number of used and allowed characters for textarea
477
+ *
478
+ * type-property must be set to textarea
479
+ */
480
+ showCharactersTextarea: {
481
+ type: Boolean,
482
+ default: true
483
+ },
484
+ /**
485
+ * text shown in front of character-count below textarea
486
+ *
487
+ * type-property must be set to textarea
488
+ * showCharactersTextarea-property must be activated
489
+ */
490
+ textCharactersLeft: {
491
+ type: String,
492
+ default: "Characters left:"
493
+ },
494
+ /**
495
+ * toggle visibility of search-button (next to search-field)
496
+ */
497
+ showSearchButton: {
498
+ type: Boolean,
499
+ default: true
500
+ },
501
+ /**
502
+ * icon to delete search term
503
+ *
504
+ * element-property must be set to 'input'
505
+ * type-property must be set to 'search'
506
+ *
507
+ */
508
+ iconDelete: {
509
+ type: Object,
510
+ default() {
511
+ return {
512
+ show: true,
513
+ iconClass: "icon-cancel-circle",
514
+ tooltip: "Delete term"
515
+ }
516
+ }
517
+ },
518
+ /**
519
+ * icon to search term
520
+ *
521
+ * element-property must be set to 'input'
522
+ * type-property must be set to 'search'
523
+ *
524
+ */
525
+ iconSearch: {
526
+ type: Object,
527
+ default() {
528
+ return {
529
+ show: true,
530
+ iconClass: "icon-search",
531
+ tooltip: "Search"
532
+ }
533
+ }
534
+ },
535
+ /**
536
+ * icon for error-validated items in list-of-requirements
537
+ *
538
+ * element-property must be set to 'input'
539
+ * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
540
+ *
541
+ */
542
+ iconHasStateError: {
543
+ type: Object,
544
+ default() {
545
+ return {
546
+ show: true,
547
+ iconClass: "icon-error-circle",
548
+ tooltip: "Error"
549
+ }
550
+ }
551
+ },
552
+ /**
553
+ * icon for warning-validated items in list-of-requirements
554
+ *
555
+ * element-property must be set to 'input'
556
+ * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
557
+ *
558
+ */
559
+ iconHasStateWarning: {
560
+ type: Object,
561
+ default() {
562
+ return {
563
+ show: true,
564
+ iconClass: "icon-warning-circle",
565
+ tooltip: "Warning"
566
+ }
567
+ }
568
+ },
569
+ /**
570
+ * icon for success-validated items in list-of-requirements
571
+ *
572
+ * element-property must be set to 'input'
573
+ * showRequirements-subproperty (of CmdListOfRequirements) must be set to 'true'
574
+ *
575
+ */
576
+ iconHasStateSuccess: {
577
+ type: Object,
578
+ default() {
579
+ return {
580
+ show: true,
581
+ iconClass: "icon-check-circle",
582
+ tooltip: "Success"
583
+ }
584
+ }
585
+ },
586
+ /**
587
+ * icon for info-validated items in list-of-requirements
588
+ *
589
+ * element-property must be set to 'input'
590
+ * showRequirements-sub-property (of CmdListOfRequirements) must be set to 'true'
591
+ *
592
+ */
593
+ iconHasStateInfo: {
594
+ type: Object,
595
+ default() {
596
+ return {
597
+ show: true,
598
+ iconClass: "icon-info-circle",
599
+ tooltip: "Info"
600
+ }
601
+ }
602
+ },
603
+ /**
604
+ * toggle if toggle-switch shows icons for checked/unchecked-status
605
+ */
606
+ useIconsForToggleSwitch: {
607
+ type: Boolean,
608
+ default: false
609
+ },
610
+ /**
611
+ * icon for toggle-switch checked
612
+ *
613
+ * toggle-switch-property must be activated
614
+ * use-icons-for-toggle-switch-property must be activated
615
+ */
616
+ toggleSwitchCheckedIconClass: {
617
+ type: String,
618
+ default: "icon-check-circle"
619
+ },
620
+ /**
621
+ * icon for toggle-switch unchecked
622
+ *
623
+ * toggle-switch-property must be activated
624
+ * use-icons-for-toggle-switch-property must be activated
625
+ */
626
+ toggleSwitchUncheckedIconClass: {
627
+ type: String,
628
+ default: "icon-cancel-circle"
629
+ },
630
+ /**
631
+ * icon to toggle password-visibility
632
+ *
633
+ * element-property must be set to 'input'
634
+ * type-property must be set to 'password'
635
+ *
636
+ */
637
+ iconPasswordVisible: {
638
+ type: Object,
639
+ default() {
640
+ return {
641
+ show: true,
642
+ iconClass: "icon-visible",
643
+ tooltip: "Show password"
644
+ }
645
+ }
646
+ },
647
+ /**
648
+ * icon to toggle password-visibility
649
+ *
650
+ * element-property must be set to 'input'
651
+ * type-property must be set to 'password'
652
+ *
653
+ */
654
+ iconPasswordInvisible: {
655
+ type: Object,
656
+ default() {
657
+ return {
658
+ show: true,
659
+ iconClass: "icon-not-visible"
660
+ }
661
+ }
662
+ },
663
+ /**
664
+ * properties for CmdListOfRequirements-component
665
+ */
666
+ cmdListOfRequirements: {
667
+ type: Object,
668
+ required: false
669
+ }
670
+ },
671
+ computed: {
672
+ cmdListOfRequirementsProperties() {
673
+ return {
674
+ showRequirements: true,
675
+ validationTooltip: "",
676
+ inputRequirements: [],
677
+ inputAttributes: {},
678
+ showHeadline: true,
679
+ inputModelValue: "",
680
+ helplink: {},
681
+ labelText: "",
682
+ ...this.cmdListOfRequirements
683
+ }
684
+ },
685
+ initialLetters() {
686
+ return this.getInitialLetters(this.selectOptions)
687
+ },
688
+ elementAttributes() {
689
+ const commonAttributes = ["name", "required", "readonly", "disabled", "autofocus"]
690
+ const attributes = {
691
+ input: [...commonAttributes, "type", "minlength", "pattern", "min", "max", "multiple", "step", "autocomplete", "placeholder"],
692
+ select: [...commonAttributes, "multiple"],
693
+ textarea: [...commonAttributes, "placeholder"]
694
+ }
695
+ const attrs = {}
696
+ if (attributes[this.element]) {
697
+ Object.entries(this.$attrs).filter(([name]) => attributes[this.element].includes(name)).forEach(([name, value]) => attrs[name] = value)
698
+ }
699
+ if (this.element === "input" && !attrs.type) {
700
+ attrs.type = "text" // explicit default
701
+ }
702
+ return attrs
703
+ },
704
+ buttonAttrs() {
705
+ // copy all native attributes
706
+ const allAttrs = { ...this.$attrs }
707
+
708
+ // check if specific tooltip for icon is set (and add as title-attribute)
709
+ if (this.nativeButton.icon?.tooltip) {
710
+ allAttrs.title = this.nativeButton.icon?.tooltip
711
+ }
712
+
713
+ return allAttrs
714
+ },
715
+ tooltipHeadline() {
716
+ return {
717
+ text: this.labelText,
718
+ level: "5"
719
+ }
720
+ },
721
+ isChecked() {
722
+ if (typeof this.modelValue === "boolean") {
723
+ return this.modelValue
724
+ }
725
+ if (typeof this.modelValue === "string") {
726
+ return this.modelValue === this.inputValue
727
+ }
728
+ if (typeof this.modelValue === "number") {
729
+ return this.modelValue === this.inputValue
730
+ }
731
+ if (this.modelValue !== undefined) {
732
+ return this.modelValue.includes(this.inputValue)
733
+ }
734
+ return false
735
+ },
736
+ charactersLeft() {
737
+ return this.getMaxLength() - this.modelValue.length
738
+ },
739
+ validationTooltip() {
740
+ if (!this.useCustomTooltip) {
741
+ return this.getValidationMessage
742
+ }
743
+
744
+ // set default-tooltip if customTooltip is not set
745
+ if (this.validationStatus === 'error') {
746
+ return this.getMessage("form_element.validation_tooltip.an_error_occurred")
747
+ } else if (this.validationStatus === 'success') {
748
+ return this.getMessage("form_element.validation_tooltip.information_is_filled_correctly")
749
+ } else if (this.capsLockActivated) {
750
+ return this.getMessage("form_element.validation_tooltip.caps_lock_is_activated")
751
+ }
752
+ return this.getMessage("form_element.validation_tooltip.open_field_requirements")
753
+ },
754
+ autocomplete() {
755
+ if (this.$attrs.type !== 'file') {
756
+ return this.datalist ? 'off' : 'on'
757
+ }
758
+ return null
759
+ },
760
+ // toggle icons for toggle-switch
761
+ toggleSwitchIconClass() {
762
+ if (this.toggleSwitch && this.useIconsForToggleSwitch && this.toggleSwitchUncheckedIconClass && this.toggleSwitchCheckedIconClass) {
763
+ if (this.isChecked) {
764
+ return this.toggleSwitchCheckedIconClass
765
+ }
766
+ return this.toggleSwitchUncheckedIconClass
767
+ }
768
+ return null
769
+ }
770
+ },
771
+ methods: {
772
+ toggleStatusTooltip() {
773
+ // shows/hides the status-tooltip (popover) by the status-icon (span[role=button])
774
+ this.$refs.tooltip?.$refs.tooltip?.togglePopover()
775
+ },
776
+ deleteInput() {
777
+ this.setFocus()
778
+ this.$emit("update:modelValue", '')
779
+ },
780
+ getInitialLetters(listOfOptions) {
781
+ const groupedListOfOptions = {}
782
+ // compare the text-keys (in lower case) and sort them
783
+ listOfOptions.sort((a, b) => a.text.toLowerCase().localeCompare(b.text.toLowerCase()))
784
+
785
+ for (let i = 0; i < listOfOptions.length; i++) {
786
+ const initialLetter = listOfOptions[i].text.slice(0, 1)
787
+ if (!groupedListOfOptions[initialLetter]) {
788
+ groupedListOfOptions[initialLetter] = []
789
+ }
790
+ groupedListOfOptions[initialLetter].push(listOfOptions[i])
791
+ }
792
+ return groupedListOfOptions
793
+ },
794
+ setFocus() {
795
+ this.$refs.label.querySelector("input, select, textarea")?.focus()
796
+ },
797
+ additionalStandardRequirements() {
798
+ const requirements = []
799
+ // check if field is type "email"
800
+ if (this.$attrs.type === "email") {
801
+ requirements.push({
802
+ message: this.getMessage("form_element.validation_tooltip.is_valid_email"),
803
+ valid: () => this.$refs.input?.checkValidity()
804
+ })
805
+ }
806
+ return requirements
807
+ },
808
+ getDomElement() {
809
+ return this.$refs.label
810
+ },
811
+ // define max-length for different input-types
812
+ getMaxLength() {
813
+ if (this.$attrs.element === 'textarea') {
814
+ return this.$attrs.maxlength > 0 ? this.$attrs.maxlength : 5000
815
+ }
816
+
817
+ if (!TYPES_WITHOUT_MAXLENGTH.includes(this.$attrs.type)) {
818
+ return this.$attrs.maxlength > 0 ? this.$attrs.maxlength : 255
819
+ }
820
+ return null
821
+ },
822
+ validateInput(event) {
823
+ // check if surrounding form with data-use-validation exists
824
+ const useValidation = event.target.closest("form")?.dataset.useValidation === "true"
825
+
826
+ if (useValidation) {
827
+ // get value from input-element
828
+ const value = event.target.value
829
+
830
+ // if input is filled, set status to success (expect for checkboxes and radiobuttons)
831
+ //if (!["checkbox", "radio"].includes(this.$attrs.type) && value) {
832
+ this.validationStatus = "success"
833
+ //}
834
+
835
+ if (typeof event.target.checkValidity === "function" && !event.target.checkValidity()) {
836
+ this.validationStatus = "error"
837
+ } else {
838
+ if (this.customRequirements) {
839
+ // check if customRequirement returns invalid result
840
+ const invalidCustomRequirement = this.customRequirements.some(requirement => {
841
+ return !requirement.valid(value)
842
+ })
843
+
844
+ // set validation-status if invalidCustomRequirement returns at least one invalid entry
845
+ if (invalidCustomRequirement) {
846
+ this.validationStatus = "error"
847
+ }
848
+ }
849
+ }
850
+
851
+ this.$emit("validation-status-change", this.validationStatus)
852
+ }
853
+ },
854
+ onBlur(event) {
855
+ this.validateInput(event)
856
+ this.closeTooltipOnBlur()
857
+ this.$emit("blur", event)
858
+ },
859
+ onInput(event) {
860
+ this.validateInput(event)
861
+ this.$emit("update:modelValue", event.target.value)
862
+ },
863
+ onChange(event) {
864
+ this.validateInput(event)
865
+
866
+ if (typeof this.modelValue === "boolean") {
867
+ this.$emit("update:modelValue", event.target.checked)
868
+ } else if (typeof this.modelValue === "string") {
869
+ this.$emit("update:modelValue", event.target.value)
870
+ } else if (this.modelValue !== undefined) {
871
+ let values = [...this.modelValue]
872
+ if (event.target.checked) {
873
+ values.push(event.target.value)
874
+ } else {
875
+ values = values.filter(value => value !== event.target.value)
876
+ }
877
+ this.$emit("update:modelValue", values)
878
+ }
879
+ },
880
+ datalistFocus() {
881
+ /* corrects focus-bug for datalist in firefox */
882
+ if (this.datalist) {
883
+ this.$refs.label.focus()
884
+ }
885
+ },
886
+ showPassword() {
887
+ // get password-field
888
+ const passwordField = this.$refs.input
889
+
890
+ // get value of password field (to save it temporary)
891
+ const password = passwordField.value
892
+
893
+ // toggle input-type to make password visible
894
+ passwordField.nextElementSibling.classList.replace(this.iconPasswordVisible.iconClass, this.iconPasswordInvisible.iconClass)
895
+ passwordField.setAttribute("type", "text")
896
+
897
+ // assign saved password back to field
898
+ passwordField.setAttribute("value", password)
899
+ },
900
+ hidePassword() {
901
+ this.$refs.input.nextElementSibling.classList.replace(this.iconPasswordInvisible.iconClass, this.iconPasswordVisible.iconClass)
902
+ this.$refs.input.setAttribute("type", "password")
903
+ },
904
+ executeSearch() {
905
+ this.$emit("search", this.value)
906
+ },
907
+ closeTooltipOnBlur() {
908
+ // close tooltip by calling function from CmdTooltipForInputElements using $refs
909
+ if (this.$refs.tooltip) {
910
+ this.$refs.tooltip.hideTooltip()
911
+ }
912
+ },
913
+ // (submit-)button is clicked
914
+ submit(event) {
915
+ this.$emit("submit", event)
916
+ }
917
+ },
918
+ watch: {
919
+ status: {
920
+ handler() {
921
+ this.validationStatus = this.status || ""
922
+ },
923
+ immediate: true
924
+ }
925
+ }
926
+ }
927
+ </script>
928
+
929
+ <style>
930
+ /* begin cmd-form-element ------------------------------------------------------------------------------------------ */
931
+ .cmd-form-element {
932
+ & input.replace-input-type {
933
+ &:checked {
934
+ &::after {
935
+ top: 0;
936
+ }
937
+ }
938
+ }
939
+
940
+ /* icon right aligned in input */
941
+ input+.place-inside {
942
+ left: auto;
943
+ right: .5rem;
944
+ color: var(--hyperlink-color);
945
+
946
+ span {
947
+ color: inherit;
948
+ }
949
+ }
950
+
951
+ .label-text .status-icon-button {
952
+ cursor: pointer;
953
+
954
+ &:focus-visible {
955
+ outline: .2rem solid currentColor;
956
+ outline-offset: .2rem;
957
+ }
958
+ }
959
+
960
+ .label-text {
961
+ :is(a, span)[class*="icon-"] {
962
+ top: .09rem;
963
+ }
964
+ }
965
+
966
+ .toggle-switch {
967
+ .label-text {
968
+ justify-content: center;
969
+ }
970
+ }
971
+
972
+ &:has([required]) {
973
+ &.has-state,
974
+ &+.cmd-tooltip {
975
+ &.error {
976
+ * {
977
+ --status-color: var(--error-color-text);
978
+ }
979
+ }
980
+
981
+ ::placeholder {
982
+ color: var(--status-color);
983
+ }
984
+
985
+ span {
986
+ color: var(--status-color);
987
+
988
+ &.place-inside {
989
+ color: inherit;
990
+ }
991
+ }
992
+
993
+ &.success {
994
+ * {
995
+ --status-color: var(--success-color-text);
996
+ --form-input-text-color: var(--success-color-text);
997
+ }
998
+
999
+ &:has(input[type="checkbox"], input[type="radio"]) {
1000
+ * {
1001
+ --status-color: var(--color-scheme-text-color);
1002
+ /* overwrite --status-color (success) for chekcboxes and radiobuttons */
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ }
1008
+
1009
+ :is(input[type="checkbox"], input[type="radio"]):checked {
1010
+ ~.label-text span {
1011
+ color: var(--hyperlink-color);
1012
+ }
1013
+
1014
+ &:hover,
1015
+ &:active,
1016
+ &:focus {
1017
+ ~.label-text span {
1018
+ color: var(--hyperlink-color-highlighted);
1019
+ }
1020
+ }
1021
+ }
1022
+
1023
+ &.inline {
1024
+ .inner-input-wrapper {
1025
+ &>a:not(.button) {
1026
+ margin-left: calc(var(--default-margin) / 2);
1027
+ }
1028
+ }
1029
+
1030
+ &.stretch-field {
1031
+ .inner-input-wrapper {
1032
+ width: 100%;
1033
+ }
1034
+ }
1035
+
1036
+ .label-text {
1037
+ [class*="icon-"] {
1038
+ top: -.2rem;
1039
+ }
1040
+ }
1041
+ }
1042
+
1043
+ .inner-input-wrapper {
1044
+ margin: 0;
1045
+
1046
+ &:has(.button, button) {
1047
+ input {
1048
+ border-top-right-radius: 0;
1049
+ border-bottom-right-radius: 0;
1050
+ }
1051
+ }
1052
+
1053
+ a.deleteicon {
1054
+ position: absolute;
1055
+ top: 50%;
1056
+ right: 1rem;
1057
+ transform: translateY(-50%);
1058
+ z-index: 100;
1059
+ width: auto;
1060
+ /* avoid to be stretched to keep correct position */
1061
+
1062
+ /* set styles to avoid overwriting by has-state-colors */
1063
+ &.button {
1064
+ span {
1065
+ color: var(--color-scheme-background);
1066
+ }
1067
+
1068
+ &:hover,
1069
+ &:active,
1070
+ &:focus {
1071
+ span {
1072
+ color: var(--color-scheme-text-color);
1073
+ }
1074
+ }
1075
+ }
1076
+ }
1077
+
1078
+ a.button {
1079
+ right: 0;
1080
+ align-self: stretch;
1081
+ aspect-ratio: 1 / 1;
1082
+
1083
+ /* square */
1084
+ &+a {
1085
+ right: 5rem;
1086
+ }
1087
+ }
1088
+ }
1089
+
1090
+ .characters-left-wrapper {
1091
+ margin-top: calc(var(--default-margin) / 2);
1092
+ display: block;
1093
+
1094
+ span:not(:only-child):first-child {
1095
+ margin-right: calc(var(--default-margin) / 2);
1096
+ color: var(--color-scheme-text-color);
1097
+ }
1098
+
1099
+ .characters-left {
1100
+ color: var(--color-scheme-text-color);
1101
+
1102
+ &.error {
1103
+ color: var(--error-color-text);
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+
1109
+ /* end cmd-form-element------------------------------------------------------------------------------------------ */
1110
+ </style>