@vaadin/form-layout 24.7.2 → 24.8.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/package.json +11 -11
- package/src/layouts/abstract-layout.js +85 -0
- package/src/layouts/auto-responsive-layout.js +182 -0
- package/src/layouts/responsive-steps-layout.js +255 -0
- package/src/vaadin-form-item-mixin.js +33 -27
- package/src/vaadin-form-layout-mixin.d.ts +111 -2
- package/src/vaadin-form-layout-mixin.js +188 -201
- package/src/vaadin-form-layout-styles.js +159 -11
- package/src/vaadin-form-layout.d.ts +97 -0
- package/src/vaadin-form-layout.js +95 -0
- package/src/vaadin-form-row.d.ts +24 -0
- package/src/vaadin-form-row.js +37 -0
- package/src/vaadin-lit-form-row.d.ts +6 -0
- package/src/vaadin-lit-form-row.js +38 -0
- package/theme/lumo/vaadin-form-row.d.ts +1 -0
- package/theme/lumo/vaadin-form-row.js +1 -0
- package/theme/lumo/vaadin-lit-form-row.d.ts +1 -0
- package/theme/lumo/vaadin-lit-form-row.js +1 -0
- package/theme/material/vaadin-form-row.d.ts +1 -0
- package/theme/material/vaadin-form-row.js +1 -0
- package/theme/material/vaadin-lit-form-row.d.ts +1 -0
- package/theme/material/vaadin-lit-form-row.js +1 -0
- package/vaadin-form-row.d.ts +1 -0
- package/vaadin-form-row.js +2 -0
- package/vaadin-lit-form-row.d.ts +1 -0
- package/vaadin-lit-form-row.js +2 -0
- package/web-types.json +178 -3
- package/web-types.lit.json +58 -3
|
@@ -22,7 +22,7 @@ export const formLayoutStyles = css`
|
|
|
22
22
|
display: none !important;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
#layout {
|
|
25
|
+
:host(:not([auto-responsive])) #layout {
|
|
26
26
|
display: flex;
|
|
27
27
|
|
|
28
28
|
align-items: baseline; /* default \`stretch\` is not appropriate */
|
|
@@ -30,7 +30,7 @@ export const formLayoutStyles = css`
|
|
|
30
30
|
flex-wrap: wrap; /* the items should wrap */
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
#layout ::slotted(*) {
|
|
33
|
+
:host(:not([auto-responsive])) #layout ::slotted(*) {
|
|
34
34
|
/* Items should neither grow nor shrink. */
|
|
35
35
|
flex-grow: 0;
|
|
36
36
|
flex-shrink: 0;
|
|
@@ -43,19 +43,168 @@ export const formLayoutStyles = css`
|
|
|
43
43
|
#layout ::slotted(br) {
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
:host([auto-responsive]) {
|
|
48
|
+
--_column-width: var(--vaadin-field-default-width, 12em);
|
|
49
|
+
--_column-width-labels-above: var(--_column-width);
|
|
50
|
+
--_column-width-labels-aside: calc(
|
|
51
|
+
var(--_column-width) + var(--vaadin-form-layout-label-width) + var(--vaadin-form-layout-label-spacing)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
display: flex;
|
|
55
|
+
min-width: var(--_column-width-labels-above);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([auto-responsive]) #layout {
|
|
59
|
+
/* By default, labels should be displayed above the fields */
|
|
60
|
+
--_form-item-labels-above: initial; /* true */
|
|
61
|
+
--_form-item-labels-aside: ' '; /* false */
|
|
62
|
+
|
|
63
|
+
/* CSS grid related properties */
|
|
64
|
+
--_grid-column-gap: var(--vaadin-form-layout-column-spacing);
|
|
65
|
+
--_grid-column-width: var(--_column-width-labels-above);
|
|
66
|
+
--_grid-column-max-total-gap: calc((var(--_max-columns) - 1) * var(--_grid-column-gap));
|
|
67
|
+
--_grid-column-max-total-width: calc(var(--_max-columns) * var(--_column-width-labels-above));
|
|
68
|
+
--_grid-repeat: var(--_grid-column-width);
|
|
69
|
+
|
|
70
|
+
display: grid;
|
|
71
|
+
grid-template-columns: repeat(auto-fill, var(--_grid-repeat));
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
Auto-columns can be created when an item's colspan exceeds the rendered column count.
|
|
75
|
+
By setting auto-columns to 0, we exclude these columns from --_grid-rendered-column-count,
|
|
76
|
+
which is then used to cap the colspan.
|
|
77
|
+
*/
|
|
78
|
+
grid-auto-columns: 0;
|
|
79
|
+
|
|
80
|
+
justify-items: start;
|
|
81
|
+
gap: var(--vaadin-form-layout-row-spacing) var(--_grid-column-gap);
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
To prevent the layout from exceeding the column limit defined by --_max-columns,
|
|
85
|
+
its width needs to be constrained:
|
|
86
|
+
|
|
87
|
+
1. "width" is used instead of "max-width" because, together with the default "flex: 0 1 auto",
|
|
88
|
+
it allows the layout to shrink to its minimum width inside <vaadin-horizontal-layout>, which
|
|
89
|
+
wouldn't work otherwise.
|
|
90
|
+
|
|
91
|
+
2. "width" is used instead of "flex-basis" to make the layout expand to the maximum
|
|
92
|
+
number of columns inside <vaadin-overlay>, which creates a new stacking context
|
|
93
|
+
without a predefined width.
|
|
94
|
+
*/
|
|
95
|
+
width: calc(var(--_grid-column-max-total-width) + var(--_grid-column-max-total-gap));
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
Firefox requires min-width on both :host and #layout to allow the layout
|
|
99
|
+
to shrink below the value specified in the CSS width property above.
|
|
100
|
+
*/
|
|
101
|
+
min-width: inherit;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host([auto-responsive]) #layout::before {
|
|
105
|
+
background-position-y: var(--_column-width-labels-aside);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host([auto-responsive]) #layout ::slotted(*) {
|
|
109
|
+
/* Make form items inherit label position from the layout */
|
|
110
|
+
--_form-item-labels-above: inherit;
|
|
111
|
+
--_form-item-labels-aside: inherit;
|
|
112
|
+
|
|
113
|
+
/* By default, place each child on a new row */
|
|
114
|
+
grid-column: 1 / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:host([auto-responsive][auto-rows]) #layout ::slotted(*) {
|
|
118
|
+
grid-column-start: var(--_grid-colstart, auto);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([auto-responsive][labels-aside]) #layout {
|
|
122
|
+
--_grid-column-max-total-width: calc(var(--_max-columns) * var(--_column-width-labels-aside));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([auto-responsive][labels-aside]) #layout[fits-labels-aside] {
|
|
126
|
+
--_form-item-labels-above: ' '; /* false */
|
|
127
|
+
--_form-item-labels-aside: initial; /* true */
|
|
128
|
+
--_grid-column-width: var(--_column-width-labels-aside);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([auto-responsive][expand-columns]) #layout {
|
|
132
|
+
/*
|
|
133
|
+
The "min" value in minmax ensures that once "maxColumns" is reached, the grid stops adding
|
|
134
|
+
new columns and instead expands the existing ones evenly to fill the available space.
|
|
135
|
+
|
|
136
|
+
The "max" value in minmax allows CSS grid columns to grow and evenly distribute any space
|
|
137
|
+
that remains when there isn't room for an additional column and "maxColumns" hasn't been
|
|
138
|
+
reached yet.
|
|
139
|
+
*/
|
|
140
|
+
--_grid-repeat: minmax(
|
|
141
|
+
max(var(--_grid-column-width), calc((100% - var(--_grid-column-max-total-gap)) / var(--_max-columns))),
|
|
142
|
+
1fr
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
/* Allow the layout to take up full available width of the parent element. */
|
|
146
|
+
flex-grow: 1;
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
export const formLayoutSlotStyles = css`
|
|
151
|
+
/* Using :where to ensure user styles always take precedence */
|
|
152
|
+
:where(
|
|
153
|
+
vaadin-form-layout[auto-responsive] > *,
|
|
154
|
+
vaadin-form-layout[auto-responsive] vaadin-form-row > *,
|
|
155
|
+
vaadin-form-layout[auto-responsive] vaadin-form-item > *
|
|
156
|
+
) {
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
max-width: 100%;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:where(
|
|
162
|
+
vaadin-form-layout[auto-responsive][expand-fields] > *,
|
|
163
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-row > *,
|
|
164
|
+
vaadin-form-layout[auto-responsive][expand-fields] vaadin-form-item > *
|
|
165
|
+
) {
|
|
166
|
+
min-width: 100%;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
export const formRowStyles = css`
|
|
171
|
+
:host {
|
|
172
|
+
display: contents;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:host([hidden]) {
|
|
176
|
+
display: none !important;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
::slotted(*) {
|
|
180
|
+
/* Make form items inherit label position from the layout */
|
|
181
|
+
--_form-item-labels-above: inherit;
|
|
182
|
+
--_form-item-labels-aside: inherit;
|
|
183
|
+
|
|
184
|
+
grid-column: auto / span min(var(--_grid-colspan, 1), var(--_grid-rendered-column-count));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
::slotted(:first-child) {
|
|
188
|
+
grid-column-start: 1;
|
|
189
|
+
}
|
|
46
190
|
`;
|
|
47
191
|
|
|
48
192
|
export const formItemStyles = css`
|
|
49
193
|
:host {
|
|
194
|
+
/* By default, when auto-responsive mode is disabled, labels should be displayed beside the fields. */
|
|
195
|
+
--_form-item-labels-above: ' '; /* false */
|
|
196
|
+
--_form-item-labels-aside: initial; /* true */
|
|
197
|
+
|
|
50
198
|
display: inline-flex;
|
|
51
|
-
|
|
52
|
-
|
|
199
|
+
align-items: var(--_form-item-labels-aside, baseline);
|
|
200
|
+
flex-flow: var(--_form-item-labels-above, column) nowrap;
|
|
201
|
+
justify-self: stretch;
|
|
53
202
|
margin: calc(0.5 * var(--vaadin-form-item-row-spacing, var(--vaadin-form-layout-row-spacing, 1em))) 0;
|
|
54
203
|
}
|
|
55
204
|
|
|
56
205
|
:host([label-position='top']) {
|
|
57
|
-
|
|
58
|
-
|
|
206
|
+
--_form-item-labels-above: initial; /* true */
|
|
207
|
+
--_form-item-labels-aside: ' '; /* false */
|
|
59
208
|
}
|
|
60
209
|
|
|
61
210
|
:host([hidden]) {
|
|
@@ -63,14 +212,13 @@ export const formItemStyles = css`
|
|
|
63
212
|
}
|
|
64
213
|
|
|
65
214
|
#label {
|
|
66
|
-
width: var(
|
|
215
|
+
width: var(
|
|
216
|
+
--_form-item-labels-aside,
|
|
217
|
+
var(--vaadin-form-item-label-width, var(--vaadin-form-layout-label-width, 8em))
|
|
218
|
+
);
|
|
67
219
|
flex: 0 0 auto;
|
|
68
220
|
}
|
|
69
221
|
|
|
70
|
-
:host([label-position='top']) #label {
|
|
71
|
-
width: auto;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
222
|
#spacing {
|
|
75
223
|
width: var(--vaadin-form-item-label-spacing, var(--vaadin-form-layout-label-spacing, 1em));
|
|
76
224
|
flex: 0 0 auto;
|
|
@@ -90,6 +90,101 @@ export * from './vaadin-form-layout-mixin.js';
|
|
|
90
90
|
* </vaadin-form-layout>
|
|
91
91
|
* ```
|
|
92
92
|
*
|
|
93
|
+
* ### Auto Responsive Mode
|
|
94
|
+
*
|
|
95
|
+
* To avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode
|
|
96
|
+
* that automatically creates and adjusts fixed-width columns based on the container's available space.
|
|
97
|
+
*
|
|
98
|
+
* The [`columnWidth`](#/elements/vaadin-form-layout#property-columnWidth) and
|
|
99
|
+
* [`maxColumns`](#/elements/vaadin-form-layout#property-maxColumns) properties define the width of
|
|
100
|
+
* each column and the maximum number of columns that the component can create. By default, the component
|
|
101
|
+
* creates up to 10 columns, each with a width of `12em` or the value of the `--vaadin-field-default-width`
|
|
102
|
+
* CSS custom property, if defined.
|
|
103
|
+
*
|
|
104
|
+
* The auto-responsive mode is disabled by default. To enable it for an individual instance, set the
|
|
105
|
+
* `auto-responsive` attribute:
|
|
106
|
+
*
|
|
107
|
+
* ```html
|
|
108
|
+
* <vaadin-form-layout auto-responsive>
|
|
109
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
110
|
+
* <vaadin-text-field label="Last Name"></vaadin-text-field>
|
|
111
|
+
* <vaadin-text-area label="Address" colspan="2"></vaadin-text-area>
|
|
112
|
+
* </vaadin-form-layout>
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* You can also enable it for all instances by enabling the following feature flag
|
|
116
|
+
* before `<vaadin-form-layout>` elements are added to the DOM:
|
|
117
|
+
*
|
|
118
|
+
* ```js
|
|
119
|
+
* window.Vaadin.featureFlags.defaultAutoResponsiveFormLayout = true;
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* #### Organizing Fields into Rows
|
|
123
|
+
*
|
|
124
|
+
* By default, each field is placed on a new row. To organize fields into rows, you can either:
|
|
125
|
+
*
|
|
126
|
+
* 1. Manually wrap fields into [`<vaadin-form-row>`](#/elements/vaadin-form-row) elements.
|
|
127
|
+
*
|
|
128
|
+
* 2. Enable the [`autoRows`](#/elements/vaadin-form-layout#property-autoRows) property to
|
|
129
|
+
* let Form Layout automatically arrange fields in available columns, wrapping to a new
|
|
130
|
+
* row when necessary. `<br>` elements can be used to force a new row.
|
|
131
|
+
*
|
|
132
|
+
* Here is an example of using `<vaadin-form-row>`:
|
|
133
|
+
*
|
|
134
|
+
* ```html
|
|
135
|
+
* <vaadin-form-layout auto-responsive>
|
|
136
|
+
* <vaadin-form-row>
|
|
137
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
138
|
+
* <vaadin-text-field label="Last Name"></vaadin-text-field>
|
|
139
|
+
* </vaadin-form-row>
|
|
140
|
+
* <vaadin-form-row>
|
|
141
|
+
* <vaadin-text-area label="Address" colspan="2"></vaadin-text-area>
|
|
142
|
+
* </vaadin-form-row>
|
|
143
|
+
* </vaadin-form-layout>
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* #### Expanding Columns and Fields
|
|
147
|
+
*
|
|
148
|
+
* You can configure Form Layout to expand columns to evenly fill any remaining space after
|
|
149
|
+
* all fixed-width columns have been created.
|
|
150
|
+
* To enable this, set the [`expandColumns`](#/elements/vaadin-form-layout#property-expandColumns)
|
|
151
|
+
* property to `true`.
|
|
152
|
+
*
|
|
153
|
+
* Also, Form Layout can stretch fields to make them take up all available space within columns.
|
|
154
|
+
* To enable this, set the [`expandFields`](#/elements/vaadin-form-layout#property-expandFields)
|
|
155
|
+
* property to `true`.
|
|
156
|
+
*
|
|
157
|
+
* #### Customizing Label Position
|
|
158
|
+
*
|
|
159
|
+
* By default, Form Layout displays labels above the fields. To position labels beside fields, you
|
|
160
|
+
* need to wrap each field in a `<vaadin-form-item>` element and define its labels on the wrapper.
|
|
161
|
+
* Then, you can enable the [`labelsAside`](#/elements/vaadin-form-layout#property-labelsAside)
|
|
162
|
+
* property:
|
|
163
|
+
*
|
|
164
|
+
* ```html
|
|
165
|
+
* <vaadin-form-layout auto-responsive labels-aside>
|
|
166
|
+
* <vaadin-form-row>
|
|
167
|
+
* <vaadin-form-item>
|
|
168
|
+
* <label slot="label">First Name</label>
|
|
169
|
+
* <vaadin-text-field></vaadin-text-field>
|
|
170
|
+
* </vaadin-form-item>
|
|
171
|
+
* <vaadin-form-item>
|
|
172
|
+
* <label slot="label">Last Name</label>
|
|
173
|
+
* <vaadin-text-field></vaadin-text-field>
|
|
174
|
+
* </vaadin-form-item>
|
|
175
|
+
* </vaadin-form-row>
|
|
176
|
+
* <vaadin-form-row>
|
|
177
|
+
* <vaadin-form-item colspan="2">
|
|
178
|
+
* <label slot="label">Address</label>
|
|
179
|
+
* <vaadin-text-area></vaadin-text-area>
|
|
180
|
+
* </vaadin-form-item>
|
|
181
|
+
* </vaadin-form-row>
|
|
182
|
+
* </vaadin-form-layout>
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* With this, FormLayout will display labels beside fields, falling back to
|
|
186
|
+
* the default position above the fields only when there isn't enough space.
|
|
187
|
+
*
|
|
93
188
|
* ### CSS Properties Reference
|
|
94
189
|
*
|
|
95
190
|
* The following custom CSS properties are available on the `<vaadin-form-layout>`
|
|
@@ -99,6 +194,8 @@ export * from './vaadin-form-layout-mixin.js';
|
|
|
99
194
|
* ---|---|---
|
|
100
195
|
* `--vaadin-form-layout-column-spacing` | Length of the spacing between columns | `2em`
|
|
101
196
|
* `--vaadin-form-layout-row-spacing` | Length of the spacing between rows | `1em`
|
|
197
|
+
* `--vaadin-form-layout-label-width` | Width of the label when labels are displayed aside | `8em`
|
|
198
|
+
* `--vaadin-form-layout-label-spacing` | Length of the spacing between the label and the input when labels are displayed aside | `1em`
|
|
102
199
|
*/
|
|
103
200
|
declare class FormLayout extends FormLayoutMixin(ElementMixin(ThemableMixin(HTMLElement))) {}
|
|
104
201
|
|
|
@@ -93,6 +93,101 @@ registerStyles('vaadin-form-layout', formLayoutStyles, { moduleId: 'vaadin-form-
|
|
|
93
93
|
* </vaadin-form-layout>
|
|
94
94
|
* ```
|
|
95
95
|
*
|
|
96
|
+
* ### Auto Responsive Mode
|
|
97
|
+
*
|
|
98
|
+
* To avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode
|
|
99
|
+
* that automatically creates and adjusts fixed-width columns based on the container's available space.
|
|
100
|
+
*
|
|
101
|
+
* The [`columnWidth`](#/elements/vaadin-form-layout#property-columnWidth) and
|
|
102
|
+
* [`maxColumns`](#/elements/vaadin-form-layout#property-maxColumns) properties define the width of
|
|
103
|
+
* each column and the maximum number of columns that the component can create. By default, the component
|
|
104
|
+
* creates up to 10 columns, each with a width of `12em` or the value of the `--vaadin-field-default-width`
|
|
105
|
+
* CSS custom property, if defined.
|
|
106
|
+
*
|
|
107
|
+
* The auto-responsive mode is disabled by default. To enable it for an individual instance, set the
|
|
108
|
+
* `auto-responsive` attribute:
|
|
109
|
+
*
|
|
110
|
+
* ```html
|
|
111
|
+
* <vaadin-form-layout auto-responsive>
|
|
112
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
113
|
+
* <vaadin-text-field label="Last Name"></vaadin-text-field>
|
|
114
|
+
* <vaadin-text-area label="Address" colspan="2"></vaadin-text-area>
|
|
115
|
+
* </vaadin-form-layout>
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* You can also enable it for all instances by enabling the following feature flag
|
|
119
|
+
* before `<vaadin-form-layout>` elements are added to the DOM:
|
|
120
|
+
*
|
|
121
|
+
* ```js
|
|
122
|
+
* window.Vaadin.featureFlags.defaultAutoResponsiveFormLayout = true;
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* #### Organizing Fields into Rows
|
|
126
|
+
*
|
|
127
|
+
* By default, each field is placed on a new row. To organize fields into rows, you can either:
|
|
128
|
+
*
|
|
129
|
+
* 1. Manually wrap fields into [`<vaadin-form-row>`](#/elements/vaadin-form-row) elements.
|
|
130
|
+
*
|
|
131
|
+
* 2. Enable the [`autoRows`](#/elements/vaadin-form-layout#property-autoRows) property to
|
|
132
|
+
* let Form Layout automatically arrange fields in available columns, wrapping to a new
|
|
133
|
+
* row when necessary. `<br>` elements can be used to force a new row.
|
|
134
|
+
*
|
|
135
|
+
* Here is an example of using `<vaadin-form-row>`:
|
|
136
|
+
*
|
|
137
|
+
* ```html
|
|
138
|
+
* <vaadin-form-layout auto-responsive>
|
|
139
|
+
* <vaadin-form-row>
|
|
140
|
+
* <vaadin-text-field label="First Name"></vaadin-text-field>
|
|
141
|
+
* <vaadin-text-field label="Last Name"></vaadin-text-field>
|
|
142
|
+
* </vaadin-form-row>
|
|
143
|
+
* <vaadin-form-row>
|
|
144
|
+
* <vaadin-text-area label="Address" colspan="2"></vaadin-text-area>
|
|
145
|
+
* </vaadin-form-row>
|
|
146
|
+
* </vaadin-form-layout>
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* #### Expanding Columns and Fields
|
|
150
|
+
*
|
|
151
|
+
* You can configure Form Layout to expand columns to evenly fill any remaining space after
|
|
152
|
+
* all fixed-width columns have been created.
|
|
153
|
+
* To enable this, set the [`expandColumns`](#/elements/vaadin-form-layout#property-expandColumns)
|
|
154
|
+
* property to `true`.
|
|
155
|
+
*
|
|
156
|
+
* Also, Form Layout can stretch fields to make them take up all available space within columns.
|
|
157
|
+
* To enable this, set the [`expandFields`](#/elements/vaadin-form-layout#property-expandFields)
|
|
158
|
+
* property to `true`.
|
|
159
|
+
*
|
|
160
|
+
* #### Customizing Label Position
|
|
161
|
+
*
|
|
162
|
+
* By default, Form Layout displays labels above the fields. To position labels beside fields, you
|
|
163
|
+
* need to wrap each field in a `<vaadin-form-item>` element and define its labels on the wrapper.
|
|
164
|
+
* Then, you can enable the [`labelsAside`](#/elements/vaadin-form-layout#property-labelsAside)
|
|
165
|
+
* property:
|
|
166
|
+
*
|
|
167
|
+
* ```html
|
|
168
|
+
* <vaadin-form-layout auto-responsive labels-aside>
|
|
169
|
+
* <vaadin-form-row>
|
|
170
|
+
* <vaadin-form-item>
|
|
171
|
+
* <label slot="label">First Name</label>
|
|
172
|
+
* <vaadin-text-field></vaadin-text-field>
|
|
173
|
+
* </vaadin-form-item>
|
|
174
|
+
* <vaadin-form-item>
|
|
175
|
+
* <label slot="label">Last Name</label>
|
|
176
|
+
* <vaadin-text-field></vaadin-text-field>
|
|
177
|
+
* </vaadin-form-item>
|
|
178
|
+
* </vaadin-form-row>
|
|
179
|
+
* <vaadin-form-row>
|
|
180
|
+
* <vaadin-form-item colspan="2">
|
|
181
|
+
* <label slot="label">Address</label>
|
|
182
|
+
* <vaadin-text-area></vaadin-text-area>
|
|
183
|
+
* </vaadin-form-item>
|
|
184
|
+
* </vaadin-form-row>
|
|
185
|
+
* </vaadin-form-layout>
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* With this, FormLayout will display labels beside fields, falling back to
|
|
189
|
+
* the default position above the fields only when there isn't enough space.
|
|
190
|
+
*
|
|
96
191
|
* ### CSS Properties Reference
|
|
97
192
|
*
|
|
98
193
|
* The following custom CSS properties are available on the `<vaadin-form-layout>`
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `<vaadin-form-row>` is a web component for arranging fields into rows
|
|
10
|
+
* inside a `<vaadin-form-layout>` that is set to autoResponsive mode.
|
|
11
|
+
*
|
|
12
|
+
* Each `<vaadin-form-row>` always starts on a new row. Fields that exceed
|
|
13
|
+
* the available columns wrap to a new row, which then remains reserved
|
|
14
|
+
* exclusively for the fields of that `<vaadin-form-row>` element.
|
|
15
|
+
*/
|
|
16
|
+
declare class FormRow extends ThemableMixin(HTMLElement) {}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'vaadin-form-row': FormRow;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { FormRow };
|
|
@@ -0,0 +1,37 @@
|
|
|
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, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
+
import { formRowStyles } from './vaadin-form-layout-styles.js';
|
|
10
|
+
|
|
11
|
+
registerStyles('vaadin-form-row', formRowStyles, { moduleId: 'vaadin-form-row-styles' });
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `<vaadin-form-row>` is a web component for arranging fields into rows
|
|
15
|
+
* inside a `<vaadin-form-layout>` that is set to autoResponsive mode.
|
|
16
|
+
*
|
|
17
|
+
* Each `<vaadin-form-row>` always starts on a new row. Fields that exceed
|
|
18
|
+
* the available columns wrap to a new row, which then remains reserved
|
|
19
|
+
* exclusively for the fields of that `<vaadin-form-row>` element.
|
|
20
|
+
*
|
|
21
|
+
* @customElement
|
|
22
|
+
* @extends HTMLElement
|
|
23
|
+
* @mixes ThemableMixin
|
|
24
|
+
*/
|
|
25
|
+
class FormRow extends ThemableMixin(PolymerElement) {
|
|
26
|
+
static get is() {
|
|
27
|
+
return 'vaadin-form-row';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get template() {
|
|
31
|
+
return html`<slot></slot>`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
defineCustomElement(FormRow);
|
|
36
|
+
|
|
37
|
+
export { FormRow };
|
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/vaadin-lit-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/vaadin-form-row.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vaadin-form-row.js';
|