hr-design-system-handlebars 1.101.3 → 1.102.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 (31) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/assets/index.css +64 -7
  3. package/dist/assets/js/alpine.js +1 -0
  4. package/dist/assets/js/components/forms/inputHandler.alpine.js +13 -8
  5. package/dist/assets/js/components/forms/selectHandler.alpine.js +15 -0
  6. package/dist/views/components/forms/choice.hbs +97 -0
  7. package/dist/views/components/forms/fields.hbs +3 -1
  8. package/dist/views/components/forms/input.hbs +1 -1
  9. package/dist/views/components/forms/select.hbs +62 -22
  10. package/dist/views_static/components/forms/choice.hbs +97 -0
  11. package/dist/views_static/components/forms/fields.hbs +3 -1
  12. package/dist/views_static/components/forms/input.hbs +1 -1
  13. package/dist/views_static/components/forms/select.hbs +62 -22
  14. package/package.json +1 -1
  15. package/src/assets/css/custom-utilities.css +17 -0
  16. package/src/assets/fixtures/forms/form_checkbox.json +18 -0
  17. package/src/assets/fixtures/forms/form_fields.inc.json +127 -87
  18. package/src/assets/fixtures/forms/form_select.json +15 -5
  19. package/src/assets/js/alpine.js +1 -0
  20. package/src/stories/views/components/forms/choice.hbs +97 -0
  21. package/src/stories/views/components/forms/fields.hbs +3 -1
  22. package/src/stories/views/components/forms/fixtures/form_checkbox.json +1 -0
  23. package/src/stories/views/components/forms/fixtures/form_select.json +1 -1
  24. package/src/stories/views/components/forms/form.mdx +1 -1
  25. package/src/stories/views/components/forms/form_checkbox.stories.js +34 -0
  26. package/src/stories/views/components/forms/form_select.stories.js +34 -0
  27. package/src/stories/views/components/forms/{form.stories.js → form_textfields.stories.js} +0 -7
  28. package/src/stories/views/components/forms/input.hbs +1 -1
  29. package/src/stories/views/components/forms/inputHandler.alpine.js +13 -8
  30. package/src/stories/views/components/forms/select.hbs +62 -22
  31. package/src/stories/views/components/forms/selectHandler.alpine.js +15 -0
@@ -1,6 +1,6 @@
1
1
  <div class="relative flex flex-col w-full mb-5 {{_wrapperClass}}"
2
2
  ax-load
3
- x-data="inputHandler('input{{nextRandom}}','{{_errorMandatory}}','{{_errorEmail}}',{{#if _isEmail}}true{{else}}false{{/if}},'{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}')"
3
+ x-data="inputHandler('input{{nextRandom}}','{{_errorMandatory}}',{{#if _isEmail}}'email'{{else}}'{{_type}}'{{/if}},'{{_errorEmail}}','{{#if _formField.forHtmlAttribute}}{{_formField.forHtmlAttribute}}{{else}}{{#if _value}}{{_value}}{{else}}{{_defaultValue}}{{/if}}{{/if}}')"
4
4
  x-ignore
5
5
  >
6
6
  <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"
@@ -1,22 +1,27 @@
1
- export default function inputHandler(element, errorMandatory, errorEmail, isEmail = false, prefilledText = '') {
1
+ export default function inputHandler(element, errorMandatory, type, errorEmail, prefilledText = '') {
2
2
  return {
3
3
  [element]: prefilledText,
4
4
  valid: false,
5
5
  wasFocused: false,
6
6
  isFocused: false,
7
7
  validEmail: false,
8
+ isChecked: false,
8
9
  errorMessage() {
9
- if( Boolean(isEmail)){
10
+ if( type == "email"){
10
11
  return !this.valid ? errorMandatory : errorEmail
11
- } else {
12
+ }
13
+ else {
12
14
  return errorMandatory
13
15
  }
14
16
  },
15
- hideDescription() {
16
- if( Boolean(isEmail)){
17
- return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused))
18
- } else {
19
- return Boolean(!this.valid && this.wasFocused && !this.isFocused)
17
+ hideDescription() {
18
+ switch (type) {
19
+ case "email":
20
+ return Boolean((!this.valid && this.wasFocused && !this.isFocused) || (!this.validEmail && this.wasFocused && !this.isFocused));
21
+ case "checkbox":
22
+ return Boolean(!this.valid && this.wasFocused && !this.isFocused && !this.isChecked);
23
+ default:
24
+ return Boolean(!this.valid && this.wasFocused && !this.isFocused);
20
25
  }
21
26
  },
22
27
  hideError() {
@@ -1,30 +1,70 @@
1
- <div class="relative flex flex-col w-full mb-5 " ax-load=""
2
- x-data="inputHandler('select9339','Bitte wählen Sie eine Option aus', false, '')">
1
+ <div class="relative flex flex-col w-full mb-5 "
2
+ ax-load
3
+ x-data="selectHandler('select{{nextRandom}}')"
4
+ x-ignore
5
+ >
3
6
  <select
4
- class="relative w-full h-12 pt-4 pl-4 text-gray-800 border-blue-500 appearance-none bg- pr-9 peer border-y focus:border-y-2 border-t-transparent focus:outline-none"
5
- :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }" x-model="select9339"
6
- id="select9339" name="options" title="Wählen Sie eine Option" aria-label="Wählen Sie eine Option" >
7
- <option value="" selected></option>
8
- <option value="1">Option 1</option>
9
- <option value="2">Option 2</option>
10
- <option value="3">Option 3</option>
7
+ class="relative w-full h-12 pt-4 pl-4 text-gray-800 bg-white border-blue-500 appearance-none bg- pr-9 peer border-y focus:border-y-2 border-t-transparent focus:outline-none"
8
+ :class="{'border-blue-500': hideError(),'border-red-700': hideDescription() }"
9
+ x-model="select{{getRandom}}"
10
+ id="select{{getRandom}}"
11
+ title="{{#if _locaKey}}{{loca _locaKey}}{{else}}{{#if _Label}}{{_label}}{{#if _required}}*{{/if}}{{/if}}{{/if}}"
12
+ name="{{#if _name}}{{_name}}{{/if}}"
13
+ {{#if _required}}required{{/if}}
14
+ {{#if _required}}
15
+ @focus="isFocused = true;"
16
+ @blur="wasFocused = true; isFocused=false"
17
+ x-on:change ="select{{getRandom}}.value != '' ? valid = true : valid = false;"
18
+ {{/if}}
19
+ >
20
+ <option class="text-white bg-gray-400" value=""{{#if _required}} disabled{{/if}} selected>
21
+ {{#if _locaKey}}
22
+ {{loca _locaKey}}{{#if _required}}*{{/if}}
23
+ {{else}}
24
+ {{#if _label}}
25
+ {{_label}}{{#if _required}}*{{/if}}
26
+ {{/if}}
27
+ {{/if}}
28
+ </option>
29
+ {{#if _options}}
30
+ {{~#each _options~}}
31
+ <option class="text-black" value="{{this.id}}" {{#if this.isSelected}}selected{{/if}}>{{this.name}}</option>
32
+ {{~/each~}}
33
+ {{else}}
34
+ {{#each _items}}
35
+ <option class="text-black" value="{{this.value}}" {{#if this.selected}}selected{{/if}}>{{this.label}}</option>
36
+ {{/each}}
37
+ {{/if}}
11
38
  </select>
12
- <label for="select9339"
39
+ <label for="select{{getRandom}}"
13
40
  class="absolute pointer-events-none left-[16px] top-0 translate-y-3 translate-x-0 scale-100 text-gray-500
14
-
15
41
  peer-focus:text-blue-500 peer-focus:scale-75 peer-focus:translate-y-0 peer-focus:top-px
16
-
17
-
18
-
19
42
  origin-top-left transform transition-transform
20
- ">
21
-
22
- Wen möchten Sie erreichen?*
43
+ ">
44
+ {{_label}}{{#if _required}}*{{/if}}
23
45
  </label>
24
- <!-- Optional custom dropdown arrow icon -->
25
- <div class="absolute transform -translate-y-1/2 pointer-events-none right-3 top-1/2">
26
- <svg class="w-4 h-4 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
27
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
28
- </svg>
46
+ <div class="flex items-end justify-between h-5 font-heading">
47
+ {{#if _description}}
48
+ <div class="pl-4 text-xs text-gray-500 min-h- " {{#if _required}}:class="{'hidden': !valid && wasFocused && !isFocused}"{{/if}}>{{_description}}</div>
49
+ {{/if}}
50
+ {{#if _required}}
51
+ <div class="hidden pl-4 text-xs text-red-700" :class="{'hidden': valid || !wasFocused || isFocused}" >{{_errorMessage}}</div>
52
+ {{/if}}
29
53
  </div>
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">
55
+ {{> components/base/image/icon _icon="arrow-down" _addClass="w-3 h-3 fill-blue-500 dark:fill-text-dark "}}
56
+ </div>
57
+ <div class="hidden">
58
+ <div class="px-4 py-2 font-bold text-white bg-red-500 rounded-t">
59
+ DEBUG
60
+ </div>
61
+ <div class="px-4 py-3 text-red-700 bg-red-100 border border-t-0 border-red-400 rounded-b">
62
+ <div>isFocused:<span x-text="isFocused" class="font-bold" :class="isFocused ? 'text-green-800' : 'text-red-700'"></span></div>
63
+ <div>wasFocused:<span x-text="wasFocused" class="font-bold" :class="wasFocused ? 'text-green-800' : 'text-red-700'"></span></div>
64
+ <div>valid:<span x-text="valid" class="font-bold" :class="valid ? 'text-green-800' : 'text-red-700'"></span></div>
65
+ <div>hideDescription:<span x-text="hideDescription()" class="font-bold" :class="hideDescription() ? 'text-green-800' : 'text-red-700'"></span></div>
66
+ <div>hideError:<span x-text="hideError()" class="font-bold" :class="hideError() ? 'text-green-800' : 'text-red-700'"></span></div>
67
+ <div>select:<span x-text="select{{getRandom}}" class="font-bold" ></span></div>
68
+ </div>
69
+ </div>
30
70
  </div>
@@ -0,0 +1,15 @@
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
+ }