@grantcodes/ui 2.11.1 → 2.11.2
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,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.11.2](https://github.com/grantcodes/ui/compare/ui-v2.11.1...ui-v2.11.2) (2026-05-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **ui:** add horizontal property to form field ([1a0bbfa](https://github.com/grantcodes/ui/commit/1a0bbfa1ed69e341c5e43ee0678bcb9d0f0469a7))
|
|
9
|
+
|
|
3
10
|
## [2.11.1](https://github.com/grantcodes/ui/compare/ui-v2.11.0...ui-v2.11.1) (2026-05-03)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { html } from "lit/static-html.js";
|
|
3
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
3
4
|
import formFieldStyles from "./form-field.css" with { type: "css" };
|
|
4
5
|
import { generateId } from "../../lib/generate-id.js";
|
|
5
6
|
|
|
@@ -8,7 +9,8 @@ export class GrantCodesFormField extends LitElement {
|
|
|
8
9
|
static styles = [formFieldStyles];
|
|
9
10
|
|
|
10
11
|
static properties = {
|
|
11
|
-
|
|
12
|
+
label: { type: String, reflect: true },
|
|
13
|
+
direction: { type: String },
|
|
12
14
|
error: { type: String },
|
|
13
15
|
help: { type: String },
|
|
14
16
|
};
|
|
@@ -20,7 +22,13 @@ export class GrantCodesFormField extends LitElement {
|
|
|
20
22
|
this.error = undefined;
|
|
21
23
|
this.help = undefined;
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
this.groupInput = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Direction of the field. Generally want horizontal for checkboxes and radios.
|
|
29
|
+
* @type {'vertical' | 'horizontal'}
|
|
30
|
+
*/
|
|
31
|
+
this.direction = "vertical";
|
|
24
32
|
|
|
25
33
|
/** @type {NodeListOf<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>} */
|
|
26
34
|
this.inputElements;
|
|
@@ -123,19 +131,23 @@ export class GrantCodesFormField extends LitElement {
|
|
|
123
131
|
`;
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
|
|
134
|
+
render() {
|
|
135
|
+
const wrapperClass = classMap({
|
|
136
|
+
'form-field': true,
|
|
137
|
+
'form-field--horizontal': this.direction === 'horizontal'
|
|
138
|
+
})
|
|
127
139
|
if (this.groupInput) {
|
|
128
140
|
return html`
|
|
129
|
-
<fieldset class
|
|
141
|
+
<fieldset class=${wrapperClass}>
|
|
130
142
|
<legend class="form-field__label">${this.label}</legend>
|
|
131
143
|
<slot></slot>
|
|
132
144
|
${this.errorTemplate()}
|
|
133
145
|
</fieldset>
|
|
134
146
|
`;
|
|
135
|
-
|
|
147
|
+
}
|
|
136
148
|
|
|
137
149
|
return html`
|
|
138
|
-
<div class
|
|
150
|
+
<div class=${wrapperClass}>
|
|
139
151
|
<label>
|
|
140
152
|
<span class="form-field__label" @click=${this.handleLabelClick}
|
|
141
153
|
>${this.label}</span
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
gap: inherit;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
.form-field--horizontal label {
|
|
24
24
|
flex-direction: row-reverse;
|
|
25
25
|
align-items: center;
|
|
26
26
|
justify-content: flex-end;
|
|
27
|
+
gap: var(--g-theme-spacing-sm);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
.form-field__label {
|
|
@@ -42,7 +42,7 @@ export const FormFieldWithHelp = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export const FormFieldWithSelect = {
|
|
45
|
-
|
|
45
|
+
args: {
|
|
46
46
|
slot: html`
|
|
47
47
|
<select>
|
|
48
48
|
<option value="1">Option 1</option>
|
|
@@ -60,13 +60,15 @@ export const FormFieldWithTextArea = {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const FormFieldWithCheckbox = {
|
|
63
|
-
|
|
63
|
+
args: {
|
|
64
|
+
direction: 'horizontal',
|
|
64
65
|
slot: html`<input type="checkbox" value="1" name="name" />`,
|
|
65
66
|
},
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
export const FormFieldWithRadio = {
|
|
69
|
-
|
|
70
|
+
args: {
|
|
71
|
+
direction: 'horizontal',
|
|
70
72
|
slot: html`<input type="radio" />`,
|
|
71
73
|
},
|
|
72
74
|
};
|
|
@@ -74,13 +76,13 @@ export const FormFieldWithRadio = {
|
|
|
74
76
|
export const FormFieldWithRadioGroup = {
|
|
75
77
|
args: {
|
|
76
78
|
slot: html`
|
|
77
|
-
<grantcodes-form-field label="Radio number 1">
|
|
79
|
+
<grantcodes-form-field label="Radio number 1" direction="horizontal">
|
|
78
80
|
<input type="radio" name="radio-group" value="1" />
|
|
79
81
|
</grantcodes-form-field>
|
|
80
|
-
<grantcodes-form-field label="Radio number 2">
|
|
82
|
+
<grantcodes-form-field label="Radio number 2" direction="horizontal">
|
|
81
83
|
<input type="radio" name="radio-group" value="2" />
|
|
82
84
|
</grantcodes-form-field>
|
|
83
|
-
<grantcodes-form-field label="Radio number 3">
|
|
85
|
+
<grantcodes-form-field label="Radio number 3" direction="horizontal">
|
|
84
86
|
<input type="radio" name="radio-group" value="3" />
|
|
85
87
|
</grantcodes-form-field>
|
|
86
88
|
`,
|
|
@@ -90,13 +92,13 @@ export const FormFieldWithRadioGroup = {
|
|
|
90
92
|
export const FormFieldWithCheckboxGroup = {
|
|
91
93
|
args: {
|
|
92
94
|
slot: html`
|
|
93
|
-
<grantcodes-form-field label="Checkbox number 1"
|
|
95
|
+
<grantcodes-form-field label="Checkbox number 1" direction="horizontal"
|
|
94
96
|
><input type="checkbox"
|
|
95
97
|
/></grantcodes-form-field>
|
|
96
|
-
<grantcodes-form-field label="Checkbox number 2"
|
|
98
|
+
<grantcodes-form-field label="Checkbox number 2" direction="horizontal"
|
|
97
99
|
><input type="checkbox"
|
|
98
100
|
/></grantcodes-form-field>
|
|
99
|
-
<grantcodes-form-field label="Checkbox number 3"
|
|
101
|
+
<grantcodes-form-field label="Checkbox number 3" direction="horizontal"
|
|
100
102
|
><input type="checkbox"
|
|
101
103
|
/></grantcodes-form-field>
|
|
102
104
|
`,
|