hr-design-system-handlebars 1.105.0 → 1.105.1

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 (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/handlebars/helpers/handlebar-helpers.js +24 -0
  3. package/dist/assets/index.css +25 -30
  4. package/dist/assets/js/alpine.js +4 -1
  5. package/dist/assets/js/components/forms/contactForm.alpine.js +36 -0
  6. package/dist/assets/js/components/forms/inputHandler.alpine.js +18 -12
  7. package/dist/views/components/forms/choice.hbs +2 -2
  8. package/dist/views/components/forms/fields.hbs +6 -2
  9. package/dist/views/components/forms/input.hbs +33 -20
  10. package/dist/views/components/forms/select.hbs +3 -8
  11. package/dist/views/components/forms/textarea.hbs +11 -8
  12. package/dist/views/components/forms/webform.hbs +23 -45
  13. package/dist/views/components/site_header/brand_navigation/brand_navigation_item.hbs +1 -1
  14. package/dist/views/components/site_header/section_navigation/section_navigation_item.hbs +1 -1
  15. package/dist/views/components/site_header/service_navigation/service_navigation_item.hbs +1 -1
  16. package/dist/views_static/components/forms/choice.hbs +2 -2
  17. package/dist/views_static/components/forms/fields.hbs +6 -2
  18. package/dist/views_static/components/forms/input.hbs +33 -20
  19. package/dist/views_static/components/forms/select.hbs +3 -8
  20. package/dist/views_static/components/forms/textarea.hbs +11 -8
  21. package/dist/views_static/components/forms/webform.hbs +23 -45
  22. package/dist/views_static/components/site_header/brand_navigation/brand_navigation_item.hbs +1 -1
  23. package/dist/views_static/components/site_header/section_navigation/section_navigation_item.hbs +1 -1
  24. package/dist/views_static/components/site_header/service_navigation/service_navigation_item.hbs +1 -1
  25. package/package.json +1 -1
  26. package/src/assets/fixtures/content/copytext/copytext_webform.json +60 -0
  27. package/src/assets/js/alpine.js +4 -1
  28. package/src/stories/views/components/content/copytext/fixtures/copytext_webform.json +1 -1
  29. package/src/stories/views/components/forms/choice.hbs +2 -2
  30. package/src/stories/views/components/forms/contactForm.alpine.js +36 -0
  31. package/src/stories/views/components/forms/fields.hbs +6 -2
  32. package/src/stories/views/components/forms/input.hbs +33 -20
  33. package/src/stories/views/components/forms/inputHandler.alpine.js +18 -12
  34. package/src/stories/views/components/forms/select.hbs +3 -8
  35. package/src/stories/views/components/forms/textarea.hbs +11 -8
  36. package/src/stories/views/components/forms/webform.hbs +23 -45
  37. package/src/stories/views/components/site_header/brand_navigation/brand_navigation_item.hbs +1 -1
  38. package/src/stories/views/components/site_header/section_navigation/section_navigation_item.hbs +1 -1
  39. package/src/stories/views/components/site_header/service_navigation/service_navigation_item.hbs +1 -1
  40. package/dist/assets/js/components/forms/selectHandler.alpine.js +0 -15
  41. package/src/stories/views/components/forms/selectHandler.alpine.js +0 -15
@@ -1,14 +1,16 @@
1
- export default function inputHandler(element, errorMandatory, type, errorEmail, prefilledText = '') {
1
+ export default function inputHandler(element, formId, errorMandatory, type, errorEmail, prefilledText = '') {
2
2
  return {
3
3
  [element]: prefilledText,
4
- valid: true,
4
+ valid: false,
5
5
  wasFocused: false,
6
6
  isFocused: false,
7
- validEmail: false,
8
7
  isChecked: false,
8
+ typeMismatch: true,
9
+ valueMissing: true,
10
+
9
11
  errorMessage() {
10
12
  if( type == "email"){
11
- return !this.valid ? errorMandatory : errorEmail
13
+ return this.valueMissing ? errorMandatory : errorEmail
12
14
  }
13
15
  else {
14
16
  return errorMandatory
@@ -17,19 +19,23 @@ export default function inputHandler(element, errorMandatory, type, errorEmail,
17
19
  hideDescription() {
18
20
  switch (type) {
19
21
  case "email":
20
- return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused));
22
+ return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (this.typeMismatch && this.wasFocused && !this.isFocused) || (!this.valid && !this.isFocused && this.$store.forms.submissionAttempted[formId]));
21
23
  case "checkbox":
22
- return Boolean(!this.valid && this.wasFocused && !this.isFocused && !this.isChecked);
24
+ return Boolean(!this.valid && this.wasFocused && !this.isFocused && !this.isChecked || (!this.valid && !this.isFocused && this.$store.forms.submissionAttempted[formId]));
25
+ case "select":
26
+ return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (!this.valid && !this.isFocused && this.$store.forms.submissionAttempted[formId]))
23
27
  default:
24
- return Boolean(!this.valid && this.wasFocused && !this.isFocused);
28
+ return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (!this.valid && !this.isFocused && this.$store.forms.submissionAttempted[formId]));
25
29
  }
26
30
  },
27
31
  hideError() {
28
- return Boolean(!this.hideDescription())
32
+ return Boolean(!this.hideDescription())
29
33
  },
30
- validateEmail() {
31
- var emailRegex = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
32
- this.validEmail = emailRegex.test( this[element]);
33
- }
34
+ validateField() {
35
+ var field = document.getElementById(element)
36
+ this.typeMismatch = field.validity.typeMismatch;
37
+ this.valueMissing = field.validity.valueMissing;
38
+ this.valid = field.checkValidity()
39
+ }
34
40
  };
35
41
  }
@@ -1,6 +1,6 @@
1
1
  <div class="relative flex flex-col w-full mb-5 "
2
2
  ax-load
3
- x-data="selectHandler('select{{nextRandom}}')"
3
+ x-data="inputHandler('select{{nextRandom}}', '{{_formId}}','select')"
4
4
  x-ignore
5
5
  >
6
6
  <select
@@ -43,17 +43,12 @@
43
43
  ">
44
44
  {{_label}}{{#if _required}}*{{/if}}
45
45
  </label>
46
- {{#if _required}}
47
- <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-14">
48
- {{> components/forms/error_icon _xclass="{'hidden': hideError() }"}}
49
- </div>
50
- {{/if}}
51
46
  <div class="flex items-end justify-between h-5 font-heading">
52
47
  {{#if _description}}
53
- <div class="pl-4 text-xs text-gray-500 " {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused}"{{/if}}>{{_description}}</div>
48
+ <div class="pl-4 text-xs text-gray-500 " :class="{'hidden': hideDescription()}">{{_description}}</div>
54
49
  {{/if}}
55
50
  {{#if _required}}
56
- <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused}" >{{_errorMessage}}</div>
51
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': hideError()}" >{{_errorMessage}}</div>
57
52
  {{/if}}
58
53
  </div>
59
54
  <div class="absolute right-0 p-4 py-3 transform border-l peer-focus:border-r peer-focus:border-l-0 pointer-events-none top-1.5 peer-focus:rotate-180">
@@ -1,6 +1,9 @@
1
1
  <div class="relative flex flex-col w-full mb-5"
2
- x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHtmlContent}}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: true, wasFocused: false, isFocused: false}"
3
- :class="{'animate-shake': !valid && wasFocused && !isFocused }">
2
+ ax-load
3
+ x-data="inputHandler('textarea{{nextRandom}}','{{_formId}}','{{_errorMandatory}}','textarea','','{{#if _formField.isValid}}{{{_formField.forHtmlContent}}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}')"
4
+ x-init="validateField()"
5
+ x-ignore
6
+ >
4
7
  <div class="w-full h-4 bg-white"></div>
5
8
  <textarea
6
9
  x-model="textarea{{getRandom}}"
@@ -33,7 +36,7 @@ x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHt
33
36
  {{#if _required}}required{{/if}}
34
37
  class="relative w-full px-4 pb-px text-gray-800 placeholder-transparent bg-white border-blue-500 min-h-12 peer border-y focus:border-b-2 focus:pb-0 border-t-transparent focus:outline-none"
35
38
  {{#if _required}}
36
- :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-500': !valid && wasFocused && !isFocused}"
39
+ :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }"
37
40
  {{/if}}
38
41
  >{{~#if _formField.isValid~}}
39
42
  {{{_formField.forHtmlContent}}}
@@ -57,16 +60,16 @@ x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHt
57
60
  {{/if}}
58
61
  </label>
59
62
  {{#if _required}}
60
- <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-4">
61
- {{> components/forms/error_icon _xclass="{'hidden': valid || !wasFocused || isFocused }"}}
62
- </div>
63
+ <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-4">
64
+ {{> components/forms/error_icon _xclass="{'hidden': hideError() }"}}
65
+ </div>
63
66
  {{/if}}
64
67
  <div class="flex items-end justify-between h-5 font-heading">
65
68
  {{#if _description}}
66
- <div class="pl-4 text-xs text-gray-500 min-h- " {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused}"{{/if}}>{{_description}}</div>
69
+ <div class="pl-4 text-xs text-gray-500" :class="{'hidden': hideDescription() }">{{_description}}</div>
67
70
  {{/if}}
68
71
  {{#if _required}}
69
- <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused}" >{{_errorMessage}}</div>
72
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': hideError()}" >{{_errorMessage}}</div>
70
73
  {{/if}}
71
74
  {{#if _maxLength}}
72
75
  <div class="px-4 ml-auto text-xs text-gray-500"><span x-text="textarea{{getRandom}}.length">0</span>/{{_maxLength}}</div>
@@ -6,59 +6,37 @@
6
6
  {{this.title}}
7
7
  </h3>
8
8
 
9
- <form x-data="contactForm()"
10
-
9
+ <form
10
+ x-ref="form{{nextRandom}}"
11
+ ax-load
12
+ x-data="contactForm('form{{getRandom}}')"
13
+ x-init="formInit()"
14
+ x-ignore
15
+
11
16
  @submit.prevent="submitData"
12
- x-ref="contactFormRef"
17
+ id="form{{getRandom}}"
13
18
  class="relative flex flex-col justify-center overflow-hidden group"
14
- id="form--{{nextRandom}}"
15
19
  action="{{this.url}}"
16
20
  method="post"
17
21
  enctype="{{if this.isMultipart 'multipart/form-data' 'application/x-www-form-urlencoded'}}"
18
- accept-charset="utf-8" >
19
- {{> components/forms/fields }}
22
+ accept-charset="utf-8"
23
+
24
+ >
25
+
26
+ <div class="">
27
+ <div class="px-4 py-2 font-bold text-white bg-red-500 rounded-t">
28
+ DEBUG
29
+ </div>
30
+ <div class="px-4 py-3 text-red-700 bg-red-100 border border-t-0 border-red-400 rounded-b">
31
+ <div>submissionAttempted[form{{getRandom}}]:<span x-text="getSubmissionAttempted()" class="font-bold" :class="getSubmissionAttempted() ? 'text-green-800' : 'text-red-700'"></span></div>
32
+ </div>
33
+ </div>
34
+ {{> components/forms/fields _formId=(joinStrings 'form' (getRandom)) }}
20
35
 
21
36
  {{> components/forms/controls }}
22
- </form>
23
- <script>
24
- function contactForm() {
25
- return {
26
- formData: {
27
- name: '',
28
- email: '',
29
- message: ''
30
- },
31
- clickHandler() {
32
- console.log('check for Error ');
33
- const form = this.$refs.contactFormRef;
34
- const formData = new FormData(form);
35
- const fields = Array.from(form.elements); // Array of all form fields
36
37
 
37
- // Loop through each field, focus it, blur it, and serialize the data
38
- fields.forEach((field) => {
39
- if (field.type !== 'submit') { // Skip the submit button
40
- field.focus(); // Focus the field
41
- field.blur(); // Immediately unfocus (blur) the field
42
- }
43
- });
44
- if(form.reportValidity()){
45
- this.submitData();
46
- }
47
-
48
- },
49
- submitData() {
50
- const formData = new FormData(this.$refs.contactFormRef);
51
- // Convert the FormData to a serialized string
52
- const serializedData = Array.from(formData.entries())
53
- .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
54
- .join('&');
55
-
56
- // Log the serialized form data
57
- console.log('DATA: ' + serializedData);
58
- }
59
- }
60
- }
61
- </script>
38
+ </form>
39
+
62
40
  {{/components/forms/backgroundBox }}
63
41
  {{~else~}}
64
42
  {{> content/webform/components/webform _addClass="print:hidden copytext__clearBox marginTrailer--m"}}
@@ -1,3 +1,3 @@
1
- <li class="sb-brand-navigation-item h-8 {{#if @first }}-ml-3 {{/if}}{{#if this.selected}} h-10 md:h-8 font-bold text-brandnav-pseudo {{/if}}cursor-pointer inline-block lg:hover:underline active:font-bold active:text-primary">
1
+ <li class="sb-brand-navigation-item h-8 {{#if @first }}-ml-3 {{/if}}{{#if this.selected}} h-10 md:h-8 font-bold text-brandnav-pseudo {{/if}}cursor-pointer inline-block hover:lg:underline active:font-bold active:text-primary">
2
2
  <a class="{{if (isUserConsentNeeded (resourceUrl "index.html" _site=this.site)) 'js-user-consent-needed ' ''}}link-focus-inset leading-[34px] items-center flex-col px-3 {{#if this.selected }}relative {{/if}}md:flex-row js-load w-max flex justify-center {{#if this.selected}} -currentBrand {{/if}}" aria-label="{{this.name}}" href="{{resourceUrl "index.html" _site=this.site}}"{{#if this.extern}} target="_blank" rel="noopener noreferrer"{{/if}} data-hr-click-tracking='{"settings": [{"type": "uxNavigation", "secondLevelId": 1, "clickLabel": "Brandnavigation::{{this.text}}-Link geklickt"}]}'>{{this.text}}</a>
3
3
  </li>
@@ -2,7 +2,7 @@
2
2
  <li x-data="dropdown"
3
3
  @click.outside="dropped = false"
4
4
  @close-servicemenu.window="dropped = false"
5
- :class="dropped ? 'border-b-0 lg:bg-white lg:text-primary ' : ' lg:hover:underline'"
5
+ :class="dropped ? 'border-b-0 lg:bg-white lg:text-primary ' : ' hover:lg:underline'"
6
6
  class="flex flex-wrap justify-start order-2 w-full list-none transition-[max-height] md:transition-none duration-1000 ease-out border-b border-navigation-border-color text-navigation-text sb-section-navigation-item first:lg:-ml-4 md:pl-0 lg:last:pr-8 lg:first:pl-0 first:font-normal last:border-b-0 lg:border-0 lg:w-auto bg-navigation-bg lg:rounded-t">
7
7
 
8
8
  {{#if this.isCluster ~}}
@@ -8,7 +8,7 @@
8
8
  @close-servicemenu.window="dropped = false; $store.serviceNavIsOpen = false"
9
9
  x-data="dropdown"
10
10
  id="{{getRandom}}"
11
- class="js-load flex flex-col items-center justify-center h-full px-4 text-left lg:justify-start lg:px-3 lg:pt-1 lg:hover:underline lg:relative lg:rounded-t lg:border-0 lg:left-0 text-navigation-icons link-focus-inset {{#if this.selected}}-currentService{{/if}}"
11
+ class="js-load flex flex-col items-center justify-center h-full px-4 text-left lg:justify-start lg:px-3 lg:pt-1 hover:lg:underline lg:relative lg:rounded-t lg:border-0 lg:left-0 text-navigation-icons link-focus-inset {{#if this.selected}}-currentService{{/if}}"
12
12
 
13
13
  :class="dropped ? 'bg-white fill-current text-primary lg:border-0 lg:underline' : ''"
14
14
  aria-owns="flyout-{{getRandom}}"
@@ -1,15 +0,0 @@
1
- export default function selectHandler(element) {
2
- return {
3
- [element]: '',
4
- valid: false,
5
- wasFocused: false,
6
- isFocused: false,
7
- validEmail: false,
8
- hideDescription() {
9
- return Boolean(!this.valid && this.wasFocused && !this.isFocused)
10
- },
11
- hideError() {
12
- return Boolean(!this.hideDescription())
13
- }
14
- };
15
- }
@@ -1,15 +0,0 @@
1
- export default function selectHandler(element) {
2
- return {
3
- [element]: '',
4
- valid: false,
5
- wasFocused: false,
6
- isFocused: false,
7
- validEmail: false,
8
- hideDescription() {
9
- return Boolean(!this.valid && this.wasFocused && !this.isFocused)
10
- },
11
- hideError() {
12
- return Boolean(!this.hideDescription())
13
- }
14
- };
15
- }