@grantcodes/ui 2.11.0 → 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,19 @@
|
|
|
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
|
+
|
|
10
|
+
## [2.11.1](https://github.com/grantcodes/ui/compare/ui-v2.11.0...ui-v2.11.1) (2026-05-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **form-field:** reflect label for SSR hydration and replace JS inline detection with CSS :has() ([9bc091b](https://github.com/grantcodes/ui/commit/9bc091bfaf838549479cc32f2ec9408e13eb14e3))
|
|
16
|
+
|
|
3
17
|
## [2.11.0](https://github.com/grantcodes/ui/compare/ui-v2.10.2...ui-v2.11.0) (2026-05-03)
|
|
4
18
|
|
|
5
19
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { html } from "lit/static-html.js";
|
|
3
|
-
import formFieldStyles from "./form-field.css" with { type: "css" };
|
|
4
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
+
import formFieldStyles from "./form-field.css" with { type: "css" };
|
|
5
5
|
import { generateId } from "../../lib/generate-id.js";
|
|
6
6
|
|
|
7
7
|
export class GrantCodesFormField extends LitElement {
|
|
@@ -9,7 +9,8 @@ export class GrantCodesFormField extends LitElement {
|
|
|
9
9
|
static styles = [formFieldStyles];
|
|
10
10
|
|
|
11
11
|
static properties = {
|
|
12
|
-
|
|
12
|
+
label: { type: String, reflect: true },
|
|
13
|
+
direction: { type: String },
|
|
13
14
|
error: { type: String },
|
|
14
15
|
help: { type: String },
|
|
15
16
|
};
|
|
@@ -21,8 +22,13 @@ export class GrantCodesFormField extends LitElement {
|
|
|
21
22
|
this.error = undefined;
|
|
22
23
|
this.help = undefined;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
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";
|
|
26
32
|
|
|
27
33
|
/** @type {NodeListOf<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>} */
|
|
28
34
|
this.inputElements;
|
|
@@ -77,10 +83,6 @@ export class GrantCodesFormField extends LitElement {
|
|
|
77
83
|
input.id = this.id;
|
|
78
84
|
input.setAttribute("aria-describedby", this.ariaDescribedBy);
|
|
79
85
|
|
|
80
|
-
if (input.type === "checkbox" || input.type === "radio") {
|
|
81
|
-
this.inlineInput = true;
|
|
82
|
-
this.requestUpdate();
|
|
83
|
-
}
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
handleLabelClick() {
|
|
@@ -129,24 +131,23 @@ export class GrantCodesFormField extends LitElement {
|
|
|
129
131
|
`;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
render() {
|
|
135
|
+
const wrapperClass = classMap({
|
|
136
|
+
'form-field': true,
|
|
137
|
+
'form-field--horizontal': this.direction === 'horizontal'
|
|
138
|
+
})
|
|
138
139
|
if (this.groupInput) {
|
|
139
140
|
return html`
|
|
140
|
-
<fieldset class=${
|
|
141
|
+
<fieldset class=${wrapperClass}>
|
|
141
142
|
<legend class="form-field__label">${this.label}</legend>
|
|
142
143
|
<slot></slot>
|
|
143
144
|
${this.errorTemplate()}
|
|
144
145
|
</fieldset>
|
|
145
146
|
`;
|
|
146
|
-
|
|
147
|
+
}
|
|
147
148
|
|
|
148
149
|
return html`
|
|
149
|
-
<div class=${
|
|
150
|
+
<div class=${wrapperClass}>
|
|
150
151
|
<label>
|
|
151
152
|
<span class="form-field__label" @click=${this.handleLabelClick}
|
|
152
153
|
>${this.label}</span
|
|
@@ -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
|
`,
|
|
@@ -30,6 +30,18 @@ describe("Form Field Component", () => {
|
|
|
30
30
|
);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
it("should reflect label text for SSR client upgrade", async () => {
|
|
34
|
+
element = await fixture("grantcodes-form-field", {
|
|
35
|
+
label: "Username",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
assert.strictEqual(
|
|
39
|
+
element.getAttribute("label"),
|
|
40
|
+
"Username",
|
|
41
|
+
"Label should be serialized to an attribute for client upgrade",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
33
45
|
it("should display error message when error is set", async () => {
|
|
34
46
|
element = await fixture("grantcodes-form-field", {
|
|
35
47
|
label: "Email",
|