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.
- package/CHANGELOG.md +25 -0
- package/dist/assets/index.css +64 -7
- package/dist/assets/js/alpine.js +1 -0
- package/dist/assets/js/components/forms/inputHandler.alpine.js +13 -8
- package/dist/assets/js/components/forms/selectHandler.alpine.js +15 -0
- package/dist/views/components/forms/choice.hbs +97 -0
- package/dist/views/components/forms/fields.hbs +3 -1
- package/dist/views/components/forms/input.hbs +1 -1
- package/dist/views/components/forms/select.hbs +62 -22
- package/dist/views_static/components/forms/choice.hbs +97 -0
- package/dist/views_static/components/forms/fields.hbs +3 -1
- package/dist/views_static/components/forms/input.hbs +1 -1
- package/dist/views_static/components/forms/select.hbs +62 -22
- package/package.json +1 -1
- package/src/assets/css/custom-utilities.css +17 -0
- package/src/assets/fixtures/forms/form_checkbox.json +18 -0
- package/src/assets/fixtures/forms/form_fields.inc.json +127 -87
- package/src/assets/fixtures/forms/form_select.json +15 -5
- package/src/assets/js/alpine.js +1 -0
- package/src/stories/views/components/forms/choice.hbs +97 -0
- package/src/stories/views/components/forms/fields.hbs +3 -1
- package/src/stories/views/components/forms/fixtures/form_checkbox.json +1 -0
- package/src/stories/views/components/forms/fixtures/form_select.json +1 -1
- package/src/stories/views/components/forms/form.mdx +1 -1
- package/src/stories/views/components/forms/form_checkbox.stories.js +34 -0
- package/src/stories/views/components/forms/form_select.stories.js +34 -0
- package/src/stories/views/components/forms/{form.stories.js → form_textfields.stories.js} +0 -7
- package/src/stories/views/components/forms/input.hbs +1 -1
- package/src/stories/views/components/forms/inputHandler.alpine.js +13 -8
- package/src/stories/views/components/forms/select.hbs +62 -22
- 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}}',
|
|
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,
|
|
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(
|
|
10
|
+
if( type == "email"){
|
|
10
11
|
return !this.valid ? errorMandatory : errorEmail
|
|
11
|
-
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
12
14
|
return errorMandatory
|
|
13
15
|
}
|
|
14
16
|
},
|
|
15
|
-
hideDescription() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 "
|
|
2
|
-
|
|
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() }"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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="
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
}
|