hr-design-system-handlebars 1.100.3 → 1.100.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v1.100.4 (Fri Sep 13 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - ✨ Email field - DPE 3292 [#1065](https://github.com/mumprod/hr-design-system-handlebars/pull/1065) ([@vascoeduardo](https://github.com/vascoeduardo))
6
+
7
+ #### Authors: 1
8
+
9
+ - Vasco ([@vascoeduardo](https://github.com/vascoeduardo))
10
+
11
+ ---
12
+
1
13
  # v1.100.3 (Wed Sep 11 2024)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -3431,7 +3431,7 @@ article.indexTextDS .indexTextHighlighted .link {
3431
3431
  border-bottom-color: var(--color-secondary-ds);
3432
3432
  }
3433
3433
  .counter-reset {
3434
- counter-reset: cnt1726067254110;
3434
+ counter-reset: cnt1726216106674;
3435
3435
  }
3436
3436
  .hyphens-auto {
3437
3437
  -webkit-hyphens: auto;
@@ -3839,7 +3839,7 @@ article.indexTextDS .indexTextHighlighted .link {
3839
3839
  --tw-ring-color: rgba(255, 255, 255, 0.5);
3840
3840
  }
3841
3841
  .-ordered {
3842
- counter-increment: cnt1726067254110 1;
3842
+ counter-increment: cnt1726216106674 1;
3843
3843
  }
3844
3844
  .-ordered::before {
3845
3845
  position: absolute;
@@ -3855,7 +3855,7 @@ article.indexTextDS .indexTextHighlighted .link {
3855
3855
  letter-spacing: .0125em;
3856
3856
  --tw-text-opacity: 1;
3857
3857
  color: rgba(0, 0, 0, var(--tw-text-opacity));
3858
- content: counter(cnt1726067254110);
3858
+ content: counter(cnt1726216106674);
3859
3859
  }
3860
3860
  /*! ****************************/
3861
3861
  /*! DataPolicy stuff */
@@ -33,6 +33,7 @@
33
33
  {{else if this.type.isText}}
34
34
  {{~> components/forms/input_single_line
35
35
  _type=this.type.asString
36
+ _isEmail=this.type.isEmail
36
37
  _name=this.name
37
38
  _label=this.label
38
39
  _labelClass="hide"
@@ -42,7 +43,8 @@
42
43
  _tabindex=(if this.isHidden "-1")
43
44
  _required=this.isRequired
44
45
  _maxLength=this.maxLength
45
- _errorMessage="Bitte füllen Sie dieses Pflichtfeld aus"
46
+ _errorMandatory="Bitte füllen Sie dieses Pflichtfeld aus"
47
+ _errorEmail="Bitte geben Sie eine gültige E-Mail-Adresse ein."
46
48
  }}
47
49
  {{else if this.type.isSelect}}
48
50
  {{~> modules/forms/select
@@ -1,12 +1,13 @@
1
- <div class="relative flex flex-col w-full mb-5" x-data="{ input{{nextRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
1
+ <div class="relative flex flex-col w-full mb-5"
2
+ x-data="inputHandler">
2
3
  <input class="relative w-full h-12 pt-4 pl-4 text-gray-800 placeholder-transparent bg-white border-blue-500 pr-9 peer border-y focus:border-y-2 border-t-transparent focus:outline-none"
3
- :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-700': !valid && wasFocused && !isFocused }"
4
- x-model="input{{getRandom}}"
4
+ :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }"
5
+ x-model="input{{nextRandom}}"
5
6
  id="input{{getRandom}}"
6
7
  {{#if _required}}
7
8
  @focus="isFocused = true"
8
9
  @blur="wasFocused = true; isFocused=false"
9
- x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false"
10
+ x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false; validateEmail()"
10
11
  {{/if}}
11
12
  type="{{#if _type}}{{_type}}{{/if}}"
12
13
  name="{{#if _name}}{{_name}}{{/if}}"
@@ -37,12 +38,7 @@
37
38
  {{#if _autoSuggestFeature}}
38
39
  data-hr-search-suggest='{"templateUrl":"{{resourceUrl "suche/index~suggest.jsp"}}"}'{{/if}}
39
40
  >
40
- <div class="hidden">
41
- <div>DEBUGG</div>
42
- <div>wasFocused:<span x-text="wasFocused"></span></div>
43
- <div>valid:<span x-text="valid"></span></div>
44
- <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
45
- </div>
41
+
46
42
  <label for="input{{getRandom}}" class="absolute left-[16px] top-px translate-y-0 translate-x-0 scale-75 text-gray-500
47
43
 
48
44
  peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-x-0 peer-placeholder-shown:translate-y-3
@@ -62,20 +58,61 @@
62
58
  </label>
63
59
  {{#if _required}}
64
60
  <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-4">
65
- <div class="hidden w-5 h-5 font-bold" :class="{'hidden': valid || !wasFocused || isFocused }">
61
+ <div class="hidden w-5 h-5 font-bold" :class="{'hidden': hideError() }">
66
62
  {{> components/base/image/icon _icon="info2" _addClass="w-5 h-5 fill-red-700"}}
67
63
  </div>
68
64
  </div>
69
65
  {{/if}}
70
66
  <div class="flex items-end justify-between h-5 font-heading">
71
67
  {{#if _description}}
72
- <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused }"{{/if}}>{{_description}}</div>
68
+ <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': hideDescription() }"{{/if}}>{{_description}}</div>
73
69
  {{/if}}
74
70
  {{#if _required}}
75
- <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused }" >{{_errorMessage}}</div>
71
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': hideError()}" x-text="errorMessage"></div>
76
72
  {{/if}}
77
73
  {{#if _maxLength}}
78
74
  <div class="px-4 ml-auto text-xs text-gray-500"><span x-text="input{{getRandom}}.length">0</span>/{{_maxLength}}</div>
79
75
  {{/if~}}
80
76
  </div>
81
- </div>
77
+ <div class="hidden">
78
+ <b>DEBUGG</b>
79
+ <div>isFocused:<span x-text="isFocused"></span></div>
80
+ <div>wasFocused:<span x-text="wasFocused"></span></div>
81
+ <div>valid:<span x-text="valid"></span></div>
82
+ <div>validEmail:<span x-text="validEmail"></span></div>
83
+ <div>hideDescription:<span x-text="hideDescription"></span></div>
84
+ <div>hideError:<span x-text="hideError"></span></div>
85
+ <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
86
+ <div>input:<span x-text="input{{getRandom}} "></span></div>
87
+ <div>errorMessage:<span x-text="errorMessage"></span></div>
88
+ </div>
89
+ <script>
90
+ function inputHandler() {
91
+ return {
92
+ input{{getRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' ,
93
+ valid: false,
94
+ wasFocused: false,
95
+ isFocused: false,
96
+ {{#if _isEmail}}
97
+ validEmail: false,
98
+ errorMessage(){ return !this.valid ? '{{_errorMandatory}}' : '{{_errorEmail}}'},
99
+ hideDescription() {return (!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused)},
100
+ hideError() {return !this.hideDescription()},
101
+
102
+ validateEmail() {
103
+ var email = this.input{{getRandom}}
104
+ var emailRegex = /^[a-zA-Z0–9._-]+@[a-zA-Z0–9.-]+\.[a-zA-Z]{2,4}$/;
105
+ this.validEmail = emailRegex.test(email);
106
+ //this.validEmail = email.includes('@');
107
+ }
108
+
109
+ {{else}}
110
+
111
+ hideError() {return (this.valid || !this.wasFocused || this.isFocused)},
112
+ hideDescription() {return !this.valid && this.wasFocused && !this.isFocused},
113
+ errorMessage: "{{_errorMandatory}}"
114
+ {{/if}}
115
+ };
116
+ }
117
+ </script>
118
+ </div>
@@ -1,4 +1,5 @@
1
1
  <div class="relative flex flex-col w-full mb-5" x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHtmlContent}}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
2
+ <div class="w-full h-4 bg-white"></div>
2
3
  <textarea
3
4
  x-model="textarea{{getRandom}}"
4
5
  id="textarea{{getRandom}}"
@@ -26,7 +27,7 @@
26
27
  maxlength="{{_maxLength}}"
27
28
  {{/if~}}
28
29
  {{#if _required}}required{{/if}}
29
- class="relative w-full px-4 pt-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"
30
+ 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"
30
31
  :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-500': !valid && wasFocused && !isFocused}"
31
32
  >{{#if _formField.isValid}}
32
33
  {{{_formField.forHtmlContent}}}
@@ -33,6 +33,7 @@
33
33
  {{else if this.type.isText}}
34
34
  {{~> components/forms/input_single_line
35
35
  _type=this.type.asString
36
+ _isEmail=this.type.isEmail
36
37
  _name=this.name
37
38
  _label=this.label
38
39
  _labelClass="hide"
@@ -42,7 +43,8 @@
42
43
  _tabindex=(if this.isHidden "-1")
43
44
  _required=this.isRequired
44
45
  _maxLength=this.maxLength
45
- _errorMessage="Bitte füllen Sie dieses Pflichtfeld aus"
46
+ _errorMandatory="Bitte füllen Sie dieses Pflichtfeld aus"
47
+ _errorEmail="Bitte geben Sie eine gültige E-Mail-Adresse ein."
46
48
  }}
47
49
  {{else if this.type.isSelect}}
48
50
  {{~> modules/forms/select
@@ -1,12 +1,13 @@
1
- <div class="relative flex flex-col w-full mb-5" x-data="{ input{{nextRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
1
+ <div class="relative flex flex-col w-full mb-5"
2
+ x-data="inputHandler">
2
3
  <input class="relative w-full h-12 pt-4 pl-4 text-gray-800 placeholder-transparent bg-white border-blue-500 pr-9 peer border-y focus:border-y-2 border-t-transparent focus:outline-none"
3
- :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-700': !valid && wasFocused && !isFocused }"
4
- x-model="input{{getRandom}}"
4
+ :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }"
5
+ x-model="input{{nextRandom}}"
5
6
  id="input{{getRandom}}"
6
7
  {{#if _required}}
7
8
  @focus="isFocused = true"
8
9
  @blur="wasFocused = true; isFocused=false"
9
- x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false"
10
+ x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false; validateEmail()"
10
11
  {{/if}}
11
12
  type="{{#if _type}}{{_type}}{{/if}}"
12
13
  name="{{#if _name}}{{_name}}{{/if}}"
@@ -37,12 +38,7 @@
37
38
  {{#if _autoSuggestFeature}}
38
39
  data-hr-search-suggest='{"templateUrl":"{{resourceUrl "suche/index~suggest.jsp"}}"}'{{/if}}
39
40
  >
40
- <div class="hidden">
41
- <div>DEBUGG</div>
42
- <div>wasFocused:<span x-text="wasFocused"></span></div>
43
- <div>valid:<span x-text="valid"></span></div>
44
- <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
45
- </div>
41
+
46
42
  <label for="input{{getRandom}}" class="absolute left-[16px] top-px translate-y-0 translate-x-0 scale-75 text-gray-500
47
43
 
48
44
  peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-x-0 peer-placeholder-shown:translate-y-3
@@ -62,20 +58,61 @@
62
58
  </label>
63
59
  {{#if _required}}
64
60
  <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-4">
65
- <div class="hidden w-5 h-5 font-bold" :class="{'hidden': valid || !wasFocused || isFocused }">
61
+ <div class="hidden w-5 h-5 font-bold" :class="{'hidden': hideError() }">
66
62
  {{> components/base/image/icon _icon="info2" _addClass="w-5 h-5 fill-red-700"}}
67
63
  </div>
68
64
  </div>
69
65
  {{/if}}
70
66
  <div class="flex items-end justify-between h-5 font-heading">
71
67
  {{#if _description}}
72
- <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused }"{{/if}}>{{_description}}</div>
68
+ <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': hideDescription() }"{{/if}}>{{_description}}</div>
73
69
  {{/if}}
74
70
  {{#if _required}}
75
- <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused }" >{{_errorMessage}}</div>
71
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': hideError()}" x-text="errorMessage"></div>
76
72
  {{/if}}
77
73
  {{#if _maxLength}}
78
74
  <div class="px-4 ml-auto text-xs text-gray-500"><span x-text="input{{getRandom}}.length">0</span>/{{_maxLength}}</div>
79
75
  {{/if~}}
80
76
  </div>
81
- </div>
77
+ <div class="hidden">
78
+ <b>DEBUGG</b>
79
+ <div>isFocused:<span x-text="isFocused"></span></div>
80
+ <div>wasFocused:<span x-text="wasFocused"></span></div>
81
+ <div>valid:<span x-text="valid"></span></div>
82
+ <div>validEmail:<span x-text="validEmail"></span></div>
83
+ <div>hideDescription:<span x-text="hideDescription"></span></div>
84
+ <div>hideError:<span x-text="hideError"></span></div>
85
+ <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
86
+ <div>input:<span x-text="input{{getRandom}} "></span></div>
87
+ <div>errorMessage:<span x-text="errorMessage"></span></div>
88
+ </div>
89
+ <script>
90
+ function inputHandler() {
91
+ return {
92
+ input{{getRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' ,
93
+ valid: false,
94
+ wasFocused: false,
95
+ isFocused: false,
96
+ {{#if _isEmail}}
97
+ validEmail: false,
98
+ errorMessage(){ return !this.valid ? '{{_errorMandatory}}' : '{{_errorEmail}}'},
99
+ hideDescription() {return (!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused)},
100
+ hideError() {return !this.hideDescription()},
101
+
102
+ validateEmail() {
103
+ var email = this.input{{getRandom}}
104
+ var emailRegex = /^[a-zA-Z0–9._-]+@[a-zA-Z0–9.-]+\.[a-zA-Z]{2,4}$/;
105
+ this.validEmail = emailRegex.test(email);
106
+ //this.validEmail = email.includes('@');
107
+ }
108
+
109
+ {{else}}
110
+
111
+ hideError() {return (this.valid || !this.wasFocused || this.isFocused)},
112
+ hideDescription() {return !this.valid && this.wasFocused && !this.isFocused},
113
+ errorMessage: "{{_errorMandatory}}"
114
+ {{/if}}
115
+ };
116
+ }
117
+ </script>
118
+ </div>
@@ -1,4 +1,5 @@
1
1
  <div class="relative flex flex-col w-full mb-5" x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHtmlContent}}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
2
+ <div class="w-full h-4 bg-white"></div>
2
3
  <textarea
3
4
  x-model="textarea{{getRandom}}"
4
5
  id="textarea{{getRandom}}"
@@ -26,7 +27,7 @@
26
27
  maxlength="{{_maxLength}}"
27
28
  {{/if~}}
28
29
  {{#if _required}}required{{/if}}
29
- class="relative w-full px-4 pt-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"
30
+ 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"
30
31
  :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-500': !valid && wasFocused && !isFocused}"
31
32
  >{{#if _formField.isValid}}
32
33
  {{{_formField.forHtmlContent}}}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "repository": "https://github.com/szuelch/hr-design-system-handlebars",
9
- "version": "1.100.3",
9
+ "version": "1.100.4",
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
12
  "storybook": "storybook dev -p 6006 public",
@@ -0,0 +1,9 @@
1
+ {
2
+ "fields":[
3
+ {
4
+ "@->jsoninclude": "forms/form_fields.inc.json",
5
+ "@->contentpath": "input-email"
6
+ }
7
+ ]
8
+ }
9
+
@@ -41,6 +41,21 @@
41
41
  "isRequired":false,
42
42
  "maxLength":"140"
43
43
  },
44
+ "input-email":
45
+ {
46
+ "type":{
47
+ "isText":true,
48
+ "isEmail":true,
49
+ "asString":"email"
50
+ },
51
+ "name":"email",
52
+ "label":"Email",
53
+ "description":"Das ist der Beschreibungstext von Email",
54
+ "defaultValue":"",
55
+ "isHidden":false,
56
+ "isRequired":true,
57
+ "maxLength":"140"
58
+ },
44
59
  "textarea":
45
60
  {
46
61
  "type":{
@@ -33,6 +33,7 @@
33
33
  {{else if this.type.isText}}
34
34
  {{~> components/forms/input_single_line
35
35
  _type=this.type.asString
36
+ _isEmail=this.type.isEmail
36
37
  _name=this.name
37
38
  _label=this.label
38
39
  _labelClass="hide"
@@ -42,7 +43,8 @@
42
43
  _tabindex=(if this.isHidden "-1")
43
44
  _required=this.isRequired
44
45
  _maxLength=this.maxLength
45
- _errorMessage="Bitte füllen Sie dieses Pflichtfeld aus"
46
+ _errorMandatory="Bitte füllen Sie dieses Pflichtfeld aus"
47
+ _errorEmail="Bitte geben Sie eine gültige E-Mail-Adresse ein."
46
48
  }}
47
49
  {{else if this.type.isSelect}}
48
50
  {{~> modules/forms/select
@@ -0,0 +1 @@
1
+ {"fields":[{"type":{"isText":true,"isEmail":true,"asString":"email"},"name":"email","label":"Email","description":"Das ist der Beschreibungstext von Email","defaultValue":"","isHidden":false,"isRequired":true,"maxLength":"140"}]}
@@ -3,6 +3,7 @@ import inputJson from './fixtures/form_input.json'
3
3
  import inputMandatoryJson from './fixtures/form_input_mandatory.json'
4
4
  import inputPrefilledJson from './fixtures/form_input_prefilled.json'
5
5
  import textareaJson from './fixtures/form_textarea.json'
6
+ import emailJson from './fixtures/form_email.json'
6
7
 
7
8
  const handlebars = require('hrHandlebars')
8
9
 
@@ -65,6 +66,11 @@ export const InputFocused = {
65
66
  },
66
67
  }
67
68
  }
69
+ export const email = {
70
+ render: TemplateInput.bind({}),
71
+ name: 'Email',
72
+ args: emailJson,
73
+ }
68
74
  export const Textarea = {
69
75
  render: TemplateTextarea.bind({}),
70
76
  name: 'Textarea',
@@ -1,12 +1,13 @@
1
- <div class="relative flex flex-col w-full mb-5" x-data="{ input{{nextRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
1
+ <div class="relative flex flex-col w-full mb-5"
2
+ x-data="inputHandler">
2
3
  <input class="relative w-full h-12 pt-4 pl-4 text-gray-800 placeholder-transparent bg-white border-blue-500 pr-9 peer border-y focus:border-y-2 border-t-transparent focus:outline-none"
3
- :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-700': !valid && wasFocused && !isFocused }"
4
- x-model="input{{getRandom}}"
4
+ :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }"
5
+ x-model="input{{nextRandom}}"
5
6
  id="input{{getRandom}}"
6
7
  {{#if _required}}
7
8
  @focus="isFocused = true"
8
9
  @blur="wasFocused = true; isFocused=false"
9
- x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false"
10
+ x-on:keyup ="input{{getRandom}}.length > 0 ? valid = true : valid = false; validateEmail()"
10
11
  {{/if}}
11
12
  type="{{#if _type}}{{_type}}{{/if}}"
12
13
  name="{{#if _name}}{{_name}}{{/if}}"
@@ -37,12 +38,7 @@
37
38
  {{#if _autoSuggestFeature}}
38
39
  data-hr-search-suggest='{"templateUrl":"{{resourceUrl "suche/index~suggest.jsp"}}"}'{{/if}}
39
40
  >
40
- <div class="hidden">
41
- <div>DEBUGG</div>
42
- <div>wasFocused:<span x-text="wasFocused"></span></div>
43
- <div>valid:<span x-text="valid"></span></div>
44
- <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
45
- </div>
41
+
46
42
  <label for="input{{getRandom}}" class="absolute left-[16px] top-px translate-y-0 translate-x-0 scale-75 text-gray-500
47
43
 
48
44
  peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-x-0 peer-placeholder-shown:translate-y-3
@@ -62,20 +58,61 @@
62
58
  </label>
63
59
  {{#if _required}}
64
60
  <div class="absolute top-0 z-10 flex items-center justify-center h-12 right-4">
65
- <div class="hidden w-5 h-5 font-bold" :class="{'hidden': valid || !wasFocused || isFocused }">
61
+ <div class="hidden w-5 h-5 font-bold" :class="{'hidden': hideError() }">
66
62
  {{> components/base/image/icon _icon="info2" _addClass="w-5 h-5 fill-red-700"}}
67
63
  </div>
68
64
  </div>
69
65
  {{/if}}
70
66
  <div class="flex items-end justify-between h-5 font-heading">
71
67
  {{#if _description}}
72
- <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused }"{{/if}}>{{_description}}</div>
68
+ <div class="pl-4 text-xs text-gray-500" {{#if _required}}:class="{'hidden': hideDescription() }"{{/if}}>{{_description}}</div>
73
69
  {{/if}}
74
70
  {{#if _required}}
75
- <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused }" >{{_errorMessage}}</div>
71
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': hideError()}" x-text="errorMessage"></div>
76
72
  {{/if}}
77
73
  {{#if _maxLength}}
78
74
  <div class="px-4 ml-auto text-xs text-gray-500"><span x-text="input{{getRandom}}.length">0</span>/{{_maxLength}}</div>
79
75
  {{/if~}}
80
76
  </div>
81
- </div>
77
+ <div class="hidden">
78
+ <b>DEBUGG</b>
79
+ <div>isFocused:<span x-text="isFocused"></span></div>
80
+ <div>wasFocused:<span x-text="wasFocused"></span></div>
81
+ <div>valid:<span x-text="valid"></span></div>
82
+ <div>validEmail:<span x-text="validEmail"></span></div>
83
+ <div>hideDescription:<span x-text="hideDescription"></span></div>
84
+ <div>hideError:<span x-text="hideError"></span></div>
85
+ <div>input.length:<span x-text="input{{getRandom}}.length "></span></div>
86
+ <div>input:<span x-text="input{{getRandom}} "></span></div>
87
+ <div>errorMessage:<span x-text="errorMessage"></span></div>
88
+ </div>
89
+ <script>
90
+ function inputHandler() {
91
+ return {
92
+ input{{getRandom}}: '{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' ,
93
+ valid: false,
94
+ wasFocused: false,
95
+ isFocused: false,
96
+ {{#if _isEmail}}
97
+ validEmail: false,
98
+ errorMessage(){ return !this.valid ? '{{_errorMandatory}}' : '{{_errorEmail}}'},
99
+ hideDescription() {return (!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused)},
100
+ hideError() {return !this.hideDescription()},
101
+
102
+ validateEmail() {
103
+ var email = this.input{{getRandom}}
104
+ var emailRegex = /^[a-zA-Z0–9._-]+@[a-zA-Z0–9.-]+\.[a-zA-Z]{2,4}$/;
105
+ this.validEmail = emailRegex.test(email);
106
+ //this.validEmail = email.includes('@');
107
+ }
108
+
109
+ {{else}}
110
+
111
+ hideError() {return (this.valid || !this.wasFocused || this.isFocused)},
112
+ hideDescription() {return !this.valid && this.wasFocused && !this.isFocused},
113
+ errorMessage: "{{_errorMandatory}}"
114
+ {{/if}}
115
+ };
116
+ }
117
+ </script>
118
+ </div>
@@ -1,4 +1,5 @@
1
1
  <div class="relative flex flex-col w-full mb-5" x-data="{ textarea{{nextRandom}}: '{{#if _formField.isValid}}{{{_formField.forHtmlContent}}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}' , valid: false, wasFocused: false, isFocused: false}">
2
+ <div class="w-full h-4 bg-white"></div>
2
3
  <textarea
3
4
  x-model="textarea{{getRandom}}"
4
5
  id="textarea{{getRandom}}"
@@ -26,7 +27,7 @@
26
27
  maxlength="{{_maxLength}}"
27
28
  {{/if~}}
28
29
  {{#if _required}}required{{/if}}
29
- class="relative w-full px-4 pt-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"
30
+ 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"
30
31
  :class="{'border-blue-500': valid || !wasFocused || isFocused,'border-red-500': !valid && wasFocused && !isFocused}"
31
32
  >{{#if _formField.isValid}}
32
33
  {{{_formField.forHtmlContent}}}