@vaadin/form-layout 24.8.4 → 25.0.0-alpha10
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/README.md +0 -23
- package/package.json +14 -15
- package/src/styles/vaadin-form-item-base-styles.d.ts +8 -0
- package/src/styles/vaadin-form-item-base-styles.js +59 -0
- package/src/styles/vaadin-form-item-core-styles.d.ts +8 -0
- package/src/styles/vaadin-form-item-core-styles.js +53 -0
- package/src/{vaadin-form-layout-styles.d.ts → styles/vaadin-form-layout-base-styles.d.ts} +0 -2
- package/src/styles/vaadin-form-layout-base-styles.js +181 -0
- package/src/styles/vaadin-form-layout-core-styles.d.ts +8 -0
- package/src/{vaadin-form-layout-styles.js → styles/vaadin-form-layout-core-styles.js} +9 -78
- package/src/styles/vaadin-form-row-base-styles.d.ts +8 -0
- package/src/styles/vaadin-form-row-base-styles.js +28 -0
- package/src/styles/vaadin-form-row-core-styles.d.ts +8 -0
- package/src/styles/vaadin-form-row-core-styles.js +28 -0
- package/src/vaadin-form-item.js +21 -10
- package/src/vaadin-form-layout-mixin.js +1 -1
- package/src/vaadin-form-layout.js +18 -7
- package/src/vaadin-form-row.js +17 -7
- package/theme/lumo/vaadin-form-item-styles.js +0 -1
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
- package/src/vaadin-lit-form-item.js +0 -48
- package/src/vaadin-lit-form-layout.js +0 -44
- package/src/vaadin-lit-form-row.js +0 -38
- package/theme/lumo/vaadin-lit-form-item.d.ts +0 -2
- package/theme/lumo/vaadin-lit-form-item.js +0 -2
- package/theme/lumo/vaadin-lit-form-layout.d.ts +0 -2
- package/theme/lumo/vaadin-lit-form-layout.js +0 -2
- package/theme/lumo/vaadin-lit-form-row.d.ts +0 -1
- package/theme/lumo/vaadin-lit-form-row.js +0 -1
- package/theme/material/vaadin-form-item-styles.d.ts +0 -2
- package/theme/material/vaadin-form-item-styles.js +0 -28
- package/theme/material/vaadin-form-item.d.ts +0 -2
- package/theme/material/vaadin-form-item.js +0 -2
- package/theme/material/vaadin-form-layout.d.ts +0 -1
- package/theme/material/vaadin-form-layout.js +0 -1
- package/theme/material/vaadin-form-row.d.ts +0 -1
- package/theme/material/vaadin-form-row.js +0 -1
- package/theme/material/vaadin-lit-form-item.d.ts +0 -2
- package/theme/material/vaadin-lit-form-item.js +0 -2
- package/theme/material/vaadin-lit-form-layout.d.ts +0 -1
- package/theme/material/vaadin-lit-form-layout.js +0 -1
- package/theme/material/vaadin-lit-form-row.d.ts +0 -1
- package/theme/material/vaadin-lit-form-row.js +0 -1
- package/vaadin-lit-form-item.d.ts +0 -1
- package/vaadin-lit-form-item.js +0 -2
- package/vaadin-lit-form-layout.d.ts +0 -1
- package/vaadin-lit-form-layout.js +0 -2
- package/vaadin-lit-form-row.d.ts +0 -1
- package/vaadin-lit-form-row.js +0 -2
package/README.md
CHANGED
|
@@ -30,29 +30,6 @@ Once installed, import the component in your application:
|
|
|
30
30
|
import '@vaadin/form-layout';
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
## Themes
|
|
34
|
-
|
|
35
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
36
|
-
The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/form-layout/vaadin-form-layout.js) of the package uses the Lumo theme.
|
|
37
|
-
|
|
38
|
-
To use the Material theme, import the component from the `theme/material` folder:
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
import '@vaadin/form-layout/theme/material/vaadin-form-layout.js';
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
You can also import the Lumo version of the component explicitly:
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import '@vaadin/form-layout/theme/lumo/vaadin-form-layout.js';
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
import '@vaadin/form-layout/src/vaadin-form-layout.js';
|
|
54
|
-
```
|
|
55
|
-
|
|
56
33
|
## Contributing
|
|
57
34
|
|
|
58
35
|
Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/form-layout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -31,30 +33,27 @@
|
|
|
31
33
|
"Vaadin",
|
|
32
34
|
"form-layout",
|
|
33
35
|
"web-components",
|
|
34
|
-
"web-component"
|
|
35
|
-
"polymer"
|
|
36
|
+
"web-component"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@
|
|
40
|
-
"@vaadin/
|
|
41
|
-
"@vaadin/
|
|
42
|
-
"@vaadin/vaadin-
|
|
43
|
-
"@vaadin/vaadin-material-styles": "~24.8.4",
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "~24.8.4",
|
|
40
|
+
"@vaadin/a11y-base": "25.0.0-alpha10",
|
|
41
|
+
"@vaadin/component-base": "25.0.0-alpha10",
|
|
42
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha10",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha10",
|
|
45
44
|
"lit": "^3.0.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@vaadin/chai-plugins": "
|
|
49
|
-
"@vaadin/custom-field": "
|
|
50
|
-
"@vaadin/test-runner-commands": "
|
|
51
|
-
"@vaadin/testing-helpers": "^
|
|
52
|
-
"@vaadin/text-field": "
|
|
47
|
+
"@vaadin/chai-plugins": "25.0.0-alpha10",
|
|
48
|
+
"@vaadin/custom-field": "25.0.0-alpha10",
|
|
49
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha10",
|
|
50
|
+
"@vaadin/testing-helpers": "^2.0.0",
|
|
51
|
+
"@vaadin/text-field": "25.0.0-alpha10",
|
|
53
52
|
"sinon": "^18.0.0"
|
|
54
53
|
},
|
|
55
54
|
"web-types": [
|
|
56
55
|
"web-types.json",
|
|
57
56
|
"web-types.lit.json"
|
|
58
57
|
],
|
|
59
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6cc6c94079e805fa5b2f0af4dbf3b2a7485e57d0"
|
|
60
59
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/component-base/src/style-props.js';
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
|
|
9
|
+
export const formItemStyles = css`
|
|
10
|
+
:host {
|
|
11
|
+
/* By default, when auto-responsive mode is disabled, labels should be displayed beside the fields. */
|
|
12
|
+
--_form-item-labels-above: ' '; /* false */
|
|
13
|
+
--_form-item-labels-aside: initial; /* true */
|
|
14
|
+
|
|
15
|
+
align-items: var(--_form-item-labels-aside, baseline);
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
flex-flow: var(--_form-item-labels-above, column) nowrap;
|
|
18
|
+
justify-self: stretch;
|
|
19
|
+
margin: calc(0.5 * var(--vaadin-form-item-row-spacing, var(--vaadin-form-layout-row-spacing, 1em))) 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([label-position='top']) {
|
|
23
|
+
--_form-item-labels-above: initial; /* true */
|
|
24
|
+
--_form-item-labels-aside: ' '; /* false */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([hidden]) {
|
|
28
|
+
display: none !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part='label'] {
|
|
32
|
+
color: var(--vaadin-form-item-label-color, var(--vaadin-color));
|
|
33
|
+
flex: 0 0 auto;
|
|
34
|
+
font-size: var(--vaadin-form-item-label-font-size, inherit);
|
|
35
|
+
font-weight: var(--vaadin-form-item-label-font-weight, 500);
|
|
36
|
+
line-height: var(--vaadin-form-item-label-line-height, inherit);
|
|
37
|
+
width: var(
|
|
38
|
+
--_form-item-labels-aside,
|
|
39
|
+
var(--vaadin-form-item-label-width, var(--vaadin-form-layout-label-width, 8em))
|
|
40
|
+
);
|
|
41
|
+
word-break: break-word;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#spacing {
|
|
45
|
+
flex: 0 0 auto;
|
|
46
|
+
width: var(--vaadin-form-item-label-spacing, var(--vaadin-form-layout-label-spacing, 1em));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#content {
|
|
50
|
+
flex: 1 1 auto;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#content ::slotted(.full-width) {
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const formItemStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
/* By default, when auto-responsive mode is disabled, labels should be displayed beside the fields. */
|
|
11
|
+
--_form-item-labels-above: ' '; /* false */
|
|
12
|
+
--_form-item-labels-aside: initial; /* true */
|
|
13
|
+
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: var(--_form-item-labels-aside, baseline);
|
|
16
|
+
flex-flow: var(--_form-item-labels-above, column) nowrap;
|
|
17
|
+
justify-self: stretch;
|
|
18
|
+
margin: calc(0.5 * var(--vaadin-form-item-row-spacing, var(--vaadin-form-layout-row-spacing, 1em))) 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host([label-position='top']) {
|
|
22
|
+
--_form-item-labels-above: initial; /* true */
|
|
23
|
+
--_form-item-labels-aside: ' '; /* false */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([hidden]) {
|
|
27
|
+
display: none !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#label {
|
|
31
|
+
width: var(
|
|
32
|
+
--_form-item-labels-aside,
|
|
33
|
+
var(--vaadin-form-item-label-width, var(--vaadin-form-layout-label-width, 8em))
|
|
34
|
+
);
|
|
35
|
+
flex: 0 0 auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#spacing {
|
|
39
|
+
width: var(--vaadin-form-item-label-spacing, var(--vaadin-form-layout-label-spacing, 1em));
|
|
40
|
+
flex: 0 0 auto;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#content {
|
|
44
|
+
flex: 1 1 auto;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#content ::slotted(.full-width) {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
width: 100%;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/component-base/src/style-props.js';
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
|
|
9
|
+
export const formLayoutStyles = css`
|
|
10
|
+
:host {
|
|
11
|
+
/* Default values */
|
|
12
|
+
--vaadin-form-layout-label-spacing: var(--vaadin-gap-container-inline);
|
|
13
|
+
--vaadin-form-layout-label-width: 8em;
|
|
14
|
+
--vaadin-form-layout-column-spacing: calc(var(--vaadin-gap-container-inline) * 2);
|
|
15
|
+
--vaadin-form-layout-row-spacing: calc(var(--vaadin-gap-container-block) * 2);
|
|
16
|
+
|
|
17
|
+
align-self: stretch;
|
|
18
|
+
display: block;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([hidden]) {
|
|
23
|
+
display: none !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host(:not([auto-responsive])) #layout {
|
|
27
|
+
align-items: baseline; /* default \`stretch\` is not appropriate */
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap; /* the items should wrap */
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host(:not([auto-responsive])) #layout ::slotted(*) {
|
|
33
|
+
/* Items should neither grow nor shrink. */
|
|
34
|
+
flex-grow: 0;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
|
|
37
|
+
/* Margins make spacing between the columns */
|
|
38
|
+
margin-inline: calc(0.5 * var(--vaadin-form-layout-column-spacing));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#layout ::slotted(br) {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host([auto-responsive]) {
|
|
46
|
+
/* Column width */
|
|
47
|
+
--_column-width: var(--vaadin-field-default-width, 12em);
|
|
48
|
+
--_column-width-labels-above: var(--_column-width);
|
|
49
|
+
--_column-width-labels-aside: calc(
|
|
50
|
+
var(--_column-width) + var(--vaadin-form-layout-label-width) + var(--vaadin-form-layout-label-spacing)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/* Column gap */
|
|
54
|
+
--_min-total-gap: calc((var(--_min-columns) - 1) * var(--vaadin-form-layout-column-spacing));
|
|
55
|
+
--_max-total-gap: calc((var(--_max-columns) - 1) * var(--vaadin-form-layout-column-spacing));
|
|
56
|
+
|
|
57
|
+
/* Minimum form layout width */
|
|
58
|
+
--_min-width-labels-above: calc(var(--_min-columns) * var(--_column-width-labels-above) + var(--_min-total-gap));
|
|
59
|
+
--_min-width-labels-aside: calc(var(--_min-columns) * var(--_column-width-labels-aside) + var(--_min-total-gap));
|
|
60
|
+
--_min-width: var(--_min-width-labels-above);
|
|
61
|
+
|
|
62
|
+
/* Maximum form layout width */
|
|
63
|
+
--_max-width-labels-above: calc(var(--_max-columns) * var(--_column-width-labels-above) + var(--_max-total-gap));
|
|
64
|
+
--_max-width-labels-aside: calc(var(--_max-columns) * var(--_column-width-labels-aside) + var(--_max-total-gap));
|
|
65
|
+
--_max-width: var(--_max-width-labels-above);
|
|
66
|
+
|
|
67
|
+
display: flex;
|
|
68
|
+
min-width: var(--_min-width);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([auto-responsive]) #layout {
|
|
72
|
+
/* By default, labels should be displayed above the fields */
|
|
73
|
+
--_form-item-labels-above: initial; /* true */
|
|
74
|
+
--_form-item-labels-aside: ' '; /* false */
|
|
75
|
+
|
|
76
|
+
/* CSS grid related properties */
|
|
77
|
+
--_grid-column-width: var(--_column-width-labels-above);
|
|
78
|
+
--_grid-repeat: var(--_grid-column-width);
|
|
79
|
+
|
|
80
|
+
display: grid;
|
|
81
|
+
gap: var(--vaadin-form-layout-row-spacing) var(--vaadin-form-layout-column-spacing);
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
Auto-columns can be created when an item's colspan exceeds the rendered column count.
|
|
85
|
+
By setting auto-columns to 0, we exclude these columns from --_grid-rendered-column-count,
|
|
86
|
+
which is then used to cap the colspan.
|
|
87
|
+
*/
|
|
88
|
+
grid-auto-columns: 0;
|
|
89
|
+
|
|
90
|
+
grid-template-columns: repeat(auto-fill, var(--_grid-repeat));
|
|
91
|
+
justify-items: start;
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
Firefox requires min-width on both :host and #layout to allow the layout
|
|
95
|
+
to shrink below the value specified in the CSS width property above.
|
|
96
|
+
*/
|
|
97
|
+
min-width: var(--_min-width);
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
To prevent the layout from exceeding the column limit defined by --_max-columns,
|
|
101
|
+
its width needs to be constrained:
|
|
102
|
+
|
|
103
|
+
1. "width" is used instead of "max-width" because, together with the default "flex: 0 1 auto",
|
|
104
|
+
it allows the layout to shrink to its minimum width inside <vaadin-horizontal-layout>, which
|
|
105
|
+
wouldn't work otherwise.
|
|
106
|
+
|
|
107
|
+
2. "width" is used instead of "flex-basis" to make the layout expand to the maximum
|
|
108
|
+
number of columns inside <vaadin-overlay>, which creates a new stacking context
|
|
109
|
+
without a predefined width.
|
|
110
|
+
*/
|
|
111
|
+
width: var(--_max-width);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host([auto-responsive]) #layout::before {
|
|
115
|
+
background-position-y: var(--_min-width-labels-aside);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host([auto-responsive]) #layout ::slotted(*) {
|
|
119
|
+
/* Make form items inherit label position from the layout */
|
|
120
|
+
--_form-item-labels-above: inherit;
|
|
121
|
+
--_form-item-labels-aside: inherit;
|
|
122
|
+
|
|
123
|
+
/* By default, place each child on a new row */
|
|
124
|
+
grid-column: 1 / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
125
|
+
|
|
126
|
+
/* Form items do not need margins in auto-responsive mode */
|
|
127
|
+
margin: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:host([auto-responsive][auto-rows]) #layout ::slotted(*) {
|
|
131
|
+
grid-column-start: var(--_grid-colstart, auto);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host([auto-responsive][labels-aside]) {
|
|
135
|
+
--_max-width: var(--_max-width-labels-aside);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:host([auto-responsive][labels-aside]) #layout[fits-labels-aside] {
|
|
139
|
+
--_form-item-labels-above: ' '; /* false */
|
|
140
|
+
--_form-item-labels-aside: initial; /* true */
|
|
141
|
+
--_grid-column-width: var(--_column-width-labels-aside);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:host([auto-responsive][expand-columns]) #layout {
|
|
145
|
+
/*
|
|
146
|
+
The "min" value in minmax ensures that once "maxColumns" is reached, the grid stops adding
|
|
147
|
+
new columns and instead expands the existing ones evenly to fill the available space.
|
|
148
|
+
|
|
149
|
+
The "max" value in minmax allows CSS grid columns to grow and evenly distribute any space
|
|
150
|
+
that remains when there isn't room for an additional column and "maxColumns" hasn't been
|
|
151
|
+
reached yet.
|
|
152
|
+
*/
|
|
153
|
+
--_grid-repeat: minmax(
|
|
154
|
+
max(var(--_grid-column-width), calc((100% - var(--_max-total-gap)) / var(--_max-columns))),
|
|
155
|
+
1fr
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
/* Allow the layout to take up full available width of the parent element. */
|
|
159
|
+
flex-grow: 1;
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
export const formLayoutSlotStyles = css`
|
|
164
|
+
/* Using :where to ensure user styles always take precedence */
|
|
165
|
+
:where(
|
|
166
|
+
vaadin-form-layout[auto-responsive] > *,
|
|
167
|
+
vaadin-form-layout[auto-responsive] vaadin-form-row > *,
|
|
168
|
+
vaadin-form-layout[auto-responsive] vaadin-form-item > *
|
|
169
|
+
) {
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
max-width: 100%;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
:where(
|
|
175
|
+
vaadin-form-layout[auto-responsive][expand-fields] > *,
|
|
176
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-row > *,
|
|
177
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-item > *
|
|
178
|
+
) {
|
|
179
|
+
min-width: 100%;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { css } from '
|
|
6
|
+
import { css } from 'lit';
|
|
7
7
|
|
|
8
8
|
export const formLayoutStyles = css`
|
|
9
9
|
:host {
|
|
@@ -162,88 +162,19 @@ export const formLayoutStyles = css`
|
|
|
162
162
|
export const formLayoutSlotStyles = css`
|
|
163
163
|
/* Using :where to ensure user styles always take precedence */
|
|
164
164
|
:where(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
vaadin-form-layout[auto-responsive] > *,
|
|
166
|
+
vaadin-form-layout[auto-responsive] vaadin-form-row > *,
|
|
167
|
+
vaadin-form-layout[auto-responsive] vaadin-form-item > *
|
|
168
|
+
) {
|
|
169
169
|
box-sizing: border-box;
|
|
170
170
|
max-width: 100%;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
:where(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
vaadin-form-layout[auto-responsive][expand-fields] > *,
|
|
175
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-row > *,
|
|
176
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-item > *
|
|
177
|
+
) {
|
|
178
178
|
min-width: 100%;
|
|
179
179
|
}
|
|
180
180
|
`;
|
|
181
|
-
|
|
182
|
-
export const formRowStyles = css`
|
|
183
|
-
:host {
|
|
184
|
-
display: contents;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
:host([hidden]) {
|
|
188
|
-
display: none !important;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
::slotted(*) {
|
|
192
|
-
/* Make form items inherit label position from the layout */
|
|
193
|
-
--_form-item-labels-above: inherit;
|
|
194
|
-
--_form-item-labels-aside: inherit;
|
|
195
|
-
|
|
196
|
-
grid-column: auto / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
::slotted(:first-child) {
|
|
200
|
-
grid-column-start: 1;
|
|
201
|
-
}
|
|
202
|
-
`;
|
|
203
|
-
|
|
204
|
-
export const formItemStyles = css`
|
|
205
|
-
:host {
|
|
206
|
-
/* By default, when auto-responsive mode is disabled, labels should be displayed beside the fields. */
|
|
207
|
-
--_form-item-labels-above: ' '; /* false */
|
|
208
|
-
--_form-item-labels-aside: initial; /* true */
|
|
209
|
-
|
|
210
|
-
display: inline-flex;
|
|
211
|
-
align-items: var(--_form-item-labels-aside, baseline);
|
|
212
|
-
flex-flow: var(--_form-item-labels-above, column) nowrap;
|
|
213
|
-
justify-self: stretch;
|
|
214
|
-
margin: calc(0.5 * var(--vaadin-form-item-row-spacing, var(--vaadin-form-layout-row-spacing, 1em))) 0;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
:host([label-position='top']) {
|
|
218
|
-
--_form-item-labels-above: initial; /* true */
|
|
219
|
-
--_form-item-labels-aside: ' '; /* false */
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
:host([hidden]) {
|
|
223
|
-
display: none !important;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
#label {
|
|
227
|
-
width: var(
|
|
228
|
-
--_form-item-labels-aside,
|
|
229
|
-
var(--vaadin-form-item-label-width, var(--vaadin-form-layout-label-width, 8em))
|
|
230
|
-
);
|
|
231
|
-
flex: 0 0 auto;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
#spacing {
|
|
235
|
-
width: var(--vaadin-form-item-label-spacing, var(--vaadin-form-layout-label-spacing, 1em));
|
|
236
|
-
flex: 0 0 auto;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
#content {
|
|
240
|
-
flex: 1 1 auto;
|
|
241
|
-
min-width: 0;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
#content ::slotted(.full-width) {
|
|
245
|
-
box-sizing: border-box;
|
|
246
|
-
width: 100%;
|
|
247
|
-
min-width: 0;
|
|
248
|
-
}
|
|
249
|
-
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const formRowStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: contents;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
::slotted(*) {
|
|
18
|
+
/* Make form items inherit label position from the layout */
|
|
19
|
+
--_form-item-labels-above: inherit;
|
|
20
|
+
--_form-item-labels-aside: inherit;
|
|
21
|
+
|
|
22
|
+
grid-column: auto / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
::slotted(:first-child) {
|
|
26
|
+
grid-column-start: 1;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const formRowStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: contents;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
::slotted(*) {
|
|
18
|
+
/* Make form items inherit label position from the layout */
|
|
19
|
+
--_form-item-labels-above: inherit;
|
|
20
|
+
--_form-item-labels-aside: inherit;
|
|
21
|
+
|
|
22
|
+
grid-column: auto / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
::slotted(:first-child) {
|
|
26
|
+
grid-column-start: 1;
|
|
27
|
+
}
|
|
28
|
+
`;
|
package/src/vaadin-form-item.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import {
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
10
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import { formItemStyles } from './styles/vaadin-form-item-core-styles.js';
|
|
9
12
|
import { FormItemMixin } from './vaadin-form-item-mixin.js';
|
|
10
|
-
import { formItemStyles } from './vaadin-form-layout-styles.js';
|
|
11
|
-
|
|
12
|
-
registerStyles('vaadin-form-item', formItemStyles, { moduleId: 'vaadin-form-item-styles' });
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* `<vaadin-form-item>` is a Web Component providing labelled form item wrapper
|
|
@@ -103,20 +103,31 @@ registerStyles('vaadin-form-item', formItemStyles, { moduleId: 'vaadin-form-item
|
|
|
103
103
|
* @mixes FormItemMixin
|
|
104
104
|
* @mixes ThemableMixin
|
|
105
105
|
*/
|
|
106
|
-
class FormItem extends FormItemMixin(ThemableMixin(
|
|
106
|
+
class FormItem extends FormItemMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
107
107
|
static get is() {
|
|
108
108
|
return 'vaadin-form-item';
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
static get
|
|
111
|
+
static get styles() {
|
|
112
|
+
return formItemStyles;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static get lumoInjector() {
|
|
116
|
+
return {
|
|
117
|
+
includeBaseStyles: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** @protected */
|
|
122
|
+
render() {
|
|
112
123
|
return html`
|
|
113
|
-
<div id="label" part="label"
|
|
114
|
-
<slot name="label" id="labelSlot"
|
|
124
|
+
<div id="label" part="label" @click="${this.__onLabelClick}">
|
|
125
|
+
<slot name="label" id="labelSlot" @slotchange="${this.__onLabelSlotChange}"></slot>
|
|
115
126
|
<span part="required-indicator" aria-hidden="true"></span>
|
|
116
127
|
</div>
|
|
117
128
|
<div id="spacing"></div>
|
|
118
129
|
<div id="content">
|
|
119
|
-
<slot id="contentSlot"
|
|
130
|
+
<slot id="contentSlot" @slotchange="${this.__onContentSlotChange}"></slot>
|
|
120
131
|
</div>
|
|
121
132
|
`;
|
|
122
133
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
|
|
7
7
|
import { AutoResponsiveLayout } from './layouts/auto-responsive-layout.js';
|
|
8
8
|
import { ResponsiveStepsLayout } from './layouts/responsive-steps-layout.js';
|
|
9
|
-
import { formLayoutSlotStyles } from './vaadin-form-layout-styles.js';
|
|
9
|
+
import { formLayoutSlotStyles } from './styles/vaadin-form-layout-core-styles.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @polymerMixin
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
|
-
import {
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
11
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
import { formLayoutStyles } from './styles/vaadin-form-layout-core-styles.js';
|
|
10
13
|
import { FormLayoutMixin } from './vaadin-form-layout-mixin.js';
|
|
11
|
-
import { formLayoutStyles } from './vaadin-form-layout-styles.js';
|
|
12
|
-
|
|
13
|
-
registerStyles('vaadin-form-layout', formLayoutStyles, { moduleId: 'vaadin-form-layout-styles' });
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* `<vaadin-form-layout>` is a Web Component providing configurable responsive
|
|
@@ -206,12 +206,23 @@ registerStyles('vaadin-form-layout', formLayoutStyles, { moduleId: 'vaadin-form-
|
|
|
206
206
|
* @mixes ElementMixin
|
|
207
207
|
* @mixes ThemableMixin
|
|
208
208
|
*/
|
|
209
|
-
class FormLayout extends FormLayoutMixin(ThemableMixin(ElementMixin(
|
|
209
|
+
class FormLayout extends FormLayoutMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
210
210
|
static get is() {
|
|
211
211
|
return 'vaadin-form-layout';
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
static get
|
|
214
|
+
static get styles() {
|
|
215
|
+
return formLayoutStyles;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static get lumoInjector() {
|
|
219
|
+
return {
|
|
220
|
+
includeBaseStyles: true,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** @protected */
|
|
225
|
+
render() {
|
|
215
226
|
return html`
|
|
216
227
|
<div id="layout">
|
|
217
228
|
<slot id="slot"></slot>
|
package/src/vaadin-form-row.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
registerStyles('vaadin-form-row', formRowStyles, { moduleId: 'vaadin-form-row-styles' });
|
|
8
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
+
import { formRowStyles } from './styles/vaadin-form-row-core-styles.js';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* `<vaadin-form-row>` is a web component for arranging fields into rows
|
|
@@ -22,12 +21,23 @@ registerStyles('vaadin-form-row', formRowStyles, { moduleId: 'vaadin-form-row-st
|
|
|
22
21
|
* @extends HTMLElement
|
|
23
22
|
* @mixes ThemableMixin
|
|
24
23
|
*/
|
|
25
|
-
class FormRow extends ThemableMixin(
|
|
24
|
+
class FormRow extends ThemableMixin(PolylitMixin(LitElement)) {
|
|
26
25
|
static get is() {
|
|
27
26
|
return 'vaadin-form-row';
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
static get
|
|
29
|
+
static get styles() {
|
|
30
|
+
return formRowStyles;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get lumoInjector() {
|
|
34
|
+
return {
|
|
35
|
+
includeBaseStyles: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @protected */
|
|
40
|
+
render() {
|
|
31
41
|
return html`<slot></slot>`;
|
|
32
42
|
}
|
|
33
43
|
}
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/form-layout",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"name": "vaadin-form-layout",
|
|
32
|
-
"description": "`<vaadin-form-layout>` is a Web Component providing configurable responsive\nlayout for form elements.\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\" value=\"jane.doe@example.com\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\nIt supports any child elements as layout items.\n\nBy default, it makes a layout of two columns if the element width is equal or\nwider than 40em, and a single column layout otherwise.\n\nThe number of columns and the responsive behavior are customizable with\nthe `responsiveSteps` property.\n\n### Spanning Items on Multiple Columns\n\nYou can use `colspan` or `data-colspan` attribute on the items.\nIn the example below, the first text field spans on two columns:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Explicit New Row\n\nUse the `<br>` line break element to wrap the items on a new row:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <br>\n\n <vaadin-form-item>\n <label slot=\"label\">Confirm Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Auto Responsive Mode\n\nTo avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode\nthat automatically creates and adjusts fixed-width columns based on the container's available space.\n\nThe [`columnWidth`](https://cdn.vaadin.com/vaadin-web-components/
|
|
32
|
+
"description": "`<vaadin-form-layout>` is a Web Component providing configurable responsive\nlayout for form elements.\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\" value=\"jane.doe@example.com\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\nIt supports any child elements as layout items.\n\nBy default, it makes a layout of two columns if the element width is equal or\nwider than 40em, and a single column layout otherwise.\n\nThe number of columns and the responsive behavior are customizable with\nthe `responsiveSteps` property.\n\n### Spanning Items on Multiple Columns\n\nYou can use `colspan` or `data-colspan` attribute on the items.\nIn the example below, the first text field spans on two columns:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Explicit New Row\n\nUse the `<br>` line break element to wrap the items on a new row:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <br>\n\n <vaadin-form-item>\n <label slot=\"label\">Confirm Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Auto Responsive Mode\n\nTo avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode\nthat automatically creates and adjusts fixed-width columns based on the container's available space.\n\nThe [`columnWidth`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-columnWidth) and\n[`maxColumns`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-maxColumns) properties define the width of\neach column and the maximum number of columns that the component can create. By default, the component\ncreates up to 10 columns, each with a width of `12em` or the value of the `--vaadin-field-default-width`\nCSS custom property, if defined.\n\nThe auto-responsive mode is disabled by default. To enable it for an individual instance, set the\n`auto-responsive` attribute:\n\n```html\n<vaadin-form-layout auto-responsive>\n <vaadin-text-field label=\"First Name\"></vaadin-text-field>\n <vaadin-text-field label=\"Last Name\"></vaadin-text-field>\n <vaadin-text-area label=\"Address\" colspan=\"2\"></vaadin-text-area>\n</vaadin-form-layout>\n```\n\nYou can also enable it for all instances by enabling the following feature flag\nbefore `<vaadin-form-layout>` elements are added to the DOM:\n\n```js\nwindow.Vaadin.featureFlags.defaultAutoResponsiveFormLayout = true;\n```\n\n#### Organizing Fields into Rows\n\nBy default, each field is placed on a new row. To organize fields into rows, you can either:\n\n1. Manually wrap fields into [`<vaadin-form-row>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-row) elements.\n\n2. Enable the [`autoRows`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-autoRows) property to\n let Form Layout automatically arrange fields in available columns, wrapping to a new\n row when necessary. `<br>` elements can be used to force a new row.\n\nHere is an example of using `<vaadin-form-row>`:\n\n```html\n<vaadin-form-layout auto-responsive>\n <vaadin-form-row>\n <vaadin-text-field label=\"First Name\"></vaadin-text-field>\n <vaadin-text-field label=\"Last Name\"></vaadin-text-field>\n </vaadin-form-row>\n <vaadin-form-row>\n <vaadin-text-area label=\"Address\" colspan=\"2\"></vaadin-text-area>\n </vaadin-form-row>\n</vaadin-form-layout>\n```\n\n#### Expanding Columns and Fields\n\nYou can configure Form Layout to expand columns to evenly fill any remaining space after\nall fixed-width columns have been created.\nTo enable this, set the [`expandColumns`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-expandColumns)\nproperty to `true`.\n\nAlso, Form Layout can stretch fields to make them take up all available space within columns.\nTo enable this, set the [`expandFields`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-expandFields)\nproperty to `true`.\n\n#### Customizing Label Position\n\nBy default, Form Layout displays labels above the fields. To position labels beside fields, you\nneed to wrap each field in a `<vaadin-form-item>` element and define its labels on the wrapper.\nThen, you can enable the [`labelsAside`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-labelsAside)\nproperty:\n\n```html\n<vaadin-form-layout auto-responsive labels-aside>\n <vaadin-form-row>\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <vaadin-text-field></vaadin-text-field>\n </vaadin-form-item>\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <vaadin-text-field></vaadin-text-field>\n </vaadin-form-item>\n </vaadin-form-row>\n <vaadin-form-row>\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <vaadin-text-area></vaadin-text-area>\n </vaadin-form-item>\n </vaadin-form-row>\n</vaadin-form-layout>\n```\n\nWith this, FormLayout will display labels beside fields, falling back to\nthe default position above the fields only when there isn't enough space.\n\n### CSS Properties Reference\n\nThe following custom CSS properties are available on the `<vaadin-form-layout>`\nelement:\n\nCustom CSS property | Description | Default\n---|---|---\n`--vaadin-form-layout-column-spacing` | Length of the spacing between columns | `2em`\n`--vaadin-form-layout-row-spacing` | Length of the spacing between rows | `1em`\n`--vaadin-form-layout-label-width` | Width of the label when labels are displayed aside | `8em`\n`--vaadin-form-layout-label-spacing` | Length of the spacing between the label and the input when labels are displayed aside | `1em`",
|
|
33
33
|
"attributes": [
|
|
34
34
|
{
|
|
35
35
|
"name": "auto-responsive",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/form-layout",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "25.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"name": "vaadin-form-layout",
|
|
25
|
-
"description": "`<vaadin-form-layout>` is a Web Component providing configurable responsive\nlayout for form elements.\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\" value=\"jane.doe@example.com\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\nIt supports any child elements as layout items.\n\nBy default, it makes a layout of two columns if the element width is equal or\nwider than 40em, and a single column layout otherwise.\n\nThe number of columns and the responsive behavior are customizable with\nthe `responsiveSteps` property.\n\n### Spanning Items on Multiple Columns\n\nYou can use `colspan` or `data-colspan` attribute on the items.\nIn the example below, the first text field spans on two columns:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Explicit New Row\n\nUse the `<br>` line break element to wrap the items on a new row:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <br>\n\n <vaadin-form-item>\n <label slot=\"label\">Confirm Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Auto Responsive Mode\n\nTo avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode\nthat automatically creates and adjusts fixed-width columns based on the container's available space.\n\nThe [`columnWidth`](https://cdn.vaadin.com/vaadin-web-components/
|
|
25
|
+
"description": "`<vaadin-form-layout>` is a Web Component providing configurable responsive\nlayout for form elements.\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\" value=\"jane.doe@example.com\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\nIt supports any child elements as layout items.\n\nBy default, it makes a layout of two columns if the element width is equal or\nwider than 40em, and a single column layout otherwise.\n\nThe number of columns and the responsive behavior are customizable with\nthe `responsiveSteps` property.\n\n### Spanning Items on Multiple Columns\n\nYou can use `colspan` or `data-colspan` attribute on the items.\nIn the example below, the first text field spans on two columns:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <input class=\"full-width\" value=\"Jane\">\n </vaadin-form-item>\n\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <input class=\"full-width\" value=\"Doe\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Explicit New Row\n\nUse the `<br>` line break element to wrap the items on a new row:\n\n```html\n<vaadin-form-layout>\n\n <vaadin-form-item>\n <label slot=\"label\">Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n <br>\n\n <vaadin-form-item>\n <label slot=\"label\">Confirm Email</label>\n <input class=\"full-width\">\n </vaadin-form-item>\n\n</vaadin-form-layout>\n```\n\n### Auto Responsive Mode\n\nTo avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode\nthat automatically creates and adjusts fixed-width columns based on the container's available space.\n\nThe [`columnWidth`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-columnWidth) and\n[`maxColumns`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-maxColumns) properties define the width of\neach column and the maximum number of columns that the component can create. By default, the component\ncreates up to 10 columns, each with a width of `12em` or the value of the `--vaadin-field-default-width`\nCSS custom property, if defined.\n\nThe auto-responsive mode is disabled by default. To enable it for an individual instance, set the\n`auto-responsive` attribute:\n\n```html\n<vaadin-form-layout auto-responsive>\n <vaadin-text-field label=\"First Name\"></vaadin-text-field>\n <vaadin-text-field label=\"Last Name\"></vaadin-text-field>\n <vaadin-text-area label=\"Address\" colspan=\"2\"></vaadin-text-area>\n</vaadin-form-layout>\n```\n\nYou can also enable it for all instances by enabling the following feature flag\nbefore `<vaadin-form-layout>` elements are added to the DOM:\n\n```js\nwindow.Vaadin.featureFlags.defaultAutoResponsiveFormLayout = true;\n```\n\n#### Organizing Fields into Rows\n\nBy default, each field is placed on a new row. To organize fields into rows, you can either:\n\n1. Manually wrap fields into [`<vaadin-form-row>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-row) elements.\n\n2. Enable the [`autoRows`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-autoRows) property to\n let Form Layout automatically arrange fields in available columns, wrapping to a new\n row when necessary. `<br>` elements can be used to force a new row.\n\nHere is an example of using `<vaadin-form-row>`:\n\n```html\n<vaadin-form-layout auto-responsive>\n <vaadin-form-row>\n <vaadin-text-field label=\"First Name\"></vaadin-text-field>\n <vaadin-text-field label=\"Last Name\"></vaadin-text-field>\n </vaadin-form-row>\n <vaadin-form-row>\n <vaadin-text-area label=\"Address\" colspan=\"2\"></vaadin-text-area>\n </vaadin-form-row>\n</vaadin-form-layout>\n```\n\n#### Expanding Columns and Fields\n\nYou can configure Form Layout to expand columns to evenly fill any remaining space after\nall fixed-width columns have been created.\nTo enable this, set the [`expandColumns`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-expandColumns)\nproperty to `true`.\n\nAlso, Form Layout can stretch fields to make them take up all available space within columns.\nTo enable this, set the [`expandFields`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-expandFields)\nproperty to `true`.\n\n#### Customizing Label Position\n\nBy default, Form Layout displays labels above the fields. To position labels beside fields, you\nneed to wrap each field in a `<vaadin-form-item>` element and define its labels on the wrapper.\nThen, you can enable the [`labelsAside`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout#property-labelsAside)\nproperty:\n\n```html\n<vaadin-form-layout auto-responsive labels-aside>\n <vaadin-form-row>\n <vaadin-form-item>\n <label slot=\"label\">First Name</label>\n <vaadin-text-field></vaadin-text-field>\n </vaadin-form-item>\n <vaadin-form-item>\n <label slot=\"label\">Last Name</label>\n <vaadin-text-field></vaadin-text-field>\n </vaadin-form-item>\n </vaadin-form-row>\n <vaadin-form-row>\n <vaadin-form-item colspan=\"2\">\n <label slot=\"label\">Address</label>\n <vaadin-text-area></vaadin-text-area>\n </vaadin-form-item>\n </vaadin-form-row>\n</vaadin-form-layout>\n```\n\nWith this, FormLayout will display labels beside fields, falling back to\nthe default position above the fields only when there isn't enough space.\n\n### CSS Properties Reference\n\nThe following custom CSS properties are available on the `<vaadin-form-layout>`\nelement:\n\nCustom CSS property | Description | Default\n---|---|---\n`--vaadin-form-layout-column-spacing` | Length of the spacing between columns | `2em`\n`--vaadin-form-layout-row-spacing` | Length of the spacing between rows | `1em`\n`--vaadin-form-layout-label-width` | Width of the label when labels are displayed aside | `8em`\n`--vaadin-form-layout-label-spacing` | Length of the spacing between the label and the input when labels are displayed aside | `1em`",
|
|
26
26
|
"extension": true,
|
|
27
27
|
"attributes": [
|
|
28
28
|
{
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
-
import { FormItemMixin } from './vaadin-form-item-mixin.js';
|
|
11
|
-
import { formItemStyles } from './vaadin-form-layout-styles.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* LitElement based version of `<vaadin-form-item>` web component.
|
|
15
|
-
*
|
|
16
|
-
* ## Disclaimer
|
|
17
|
-
*
|
|
18
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
19
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
20
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
21
|
-
*/
|
|
22
|
-
class FormItem extends FormItemMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
23
|
-
static get is() {
|
|
24
|
-
return 'vaadin-form-item';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static get styles() {
|
|
28
|
-
return formItemStyles;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** @protected */
|
|
32
|
-
render() {
|
|
33
|
-
return html`
|
|
34
|
-
<div id="label" part="label" @click="${this.__onLabelClick}">
|
|
35
|
-
<slot name="label" id="labelSlot" @slotchange="${this.__onLabelSlotChange}"></slot>
|
|
36
|
-
<span part="required-indicator" aria-hidden="true"></span>
|
|
37
|
-
</div>
|
|
38
|
-
<div id="spacing"></div>
|
|
39
|
-
<div id="content">
|
|
40
|
-
<slot id="contentSlot" @slotchange="${this.__onContentSlotChange}"></slot>
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
defineCustomElement(FormItem);
|
|
47
|
-
|
|
48
|
-
export { FormItem };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
-
import { FormLayoutMixin } from './vaadin-form-layout-mixin.js';
|
|
12
|
-
import { formLayoutStyles } from './vaadin-form-layout-styles.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* LitElement based version of `<vaadin-form-layout>` web component.
|
|
16
|
-
*
|
|
17
|
-
* ## Disclaimer
|
|
18
|
-
*
|
|
19
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
20
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
21
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
22
|
-
*/
|
|
23
|
-
class FormLayout extends FormLayoutMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) {
|
|
24
|
-
static get is() {
|
|
25
|
-
return 'vaadin-form-layout';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return formLayoutStyles;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** @protected */
|
|
33
|
-
render() {
|
|
34
|
-
return html`
|
|
35
|
-
<div id="layout">
|
|
36
|
-
<slot id="slot"></slot>
|
|
37
|
-
</div>
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
defineCustomElement(FormLayout);
|
|
43
|
-
|
|
44
|
-
export { FormLayout };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
|
-
import { formRowStyles } from './vaadin-form-layout-styles.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* LitElement based version of `<vaadin-form-row>` web component.
|
|
14
|
-
*
|
|
15
|
-
* ## Disclaimer
|
|
16
|
-
*
|
|
17
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
18
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
19
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
20
|
-
*/
|
|
21
|
-
class FormRow extends ThemableMixin(PolylitMixin(LitElement)) {
|
|
22
|
-
static get is() {
|
|
23
|
-
return 'vaadin-form-row';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static get styles() {
|
|
27
|
-
return formRowStyles;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** @protected */
|
|
31
|
-
render() {
|
|
32
|
-
return html`<slot></slot>`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
defineCustomElement(FormRow);
|
|
37
|
-
|
|
38
|
-
export { FormRow };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import '@vaadin/vaadin-material-styles/color.js';
|
|
2
|
-
import '@vaadin/vaadin-material-styles/typography.js';
|
|
3
|
-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
|
-
|
|
5
|
-
registerStyles(
|
|
6
|
-
'vaadin-form-item',
|
|
7
|
-
css`
|
|
8
|
-
[part='label'] {
|
|
9
|
-
font-family: var(--material-font-family);
|
|
10
|
-
font-size: var(--material-small-font-size);
|
|
11
|
-
color: var(--material-secondary-text-color);
|
|
12
|
-
line-height: 16px;
|
|
13
|
-
font-weight: 400;
|
|
14
|
-
margin-top: 16px;
|
|
15
|
-
margin-bottom: 8px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
:host([required]) [part='required-indicator']::after {
|
|
19
|
-
content: ' *';
|
|
20
|
-
color: inherit;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
:host([invalid]) [part='label'] {
|
|
24
|
-
color: var(--material-error-text-color);
|
|
25
|
-
}
|
|
26
|
-
`,
|
|
27
|
-
{ moduleId: 'material-form-item' },
|
|
28
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-form-layout.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-form-layout.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-form-row.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-form-row.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-layout.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-layout.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vaadin-form-item.js';
|
package/vaadin-lit-form-item.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vaadin-form-layout.js';
|
package/vaadin-lit-form-row.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './vaadin-form-row.js';
|
package/vaadin-lit-form-row.js
DELETED