@vaadin/field-base 25.3.0-rc1 → 25.4.0-alpha1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/field-base",
3
- "version": "25.3.0-rc1",
3
+ "version": "25.4.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,17 +32,17 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@open-wc/dedupe-mixin": "^1.3.0",
35
- "@vaadin/a11y-base": "25.3.0-rc1",
36
- "@vaadin/component-base": "25.3.0-rc1",
35
+ "@vaadin/a11y-base": "25.4.0-alpha1",
36
+ "@vaadin/component-base": "25.4.0-alpha1",
37
37
  "lit": "^3.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@vaadin/chai-plugins": "25.3.0-rc1",
41
- "@vaadin/input-container": "25.3.0-rc1",
42
- "@vaadin/test-runner-commands": "25.3.0-rc1",
40
+ "@vaadin/chai-plugins": "25.4.0-alpha1",
41
+ "@vaadin/input-container": "25.4.0-alpha1",
42
+ "@vaadin/test-runner-commands": "25.4.0-alpha1",
43
43
  "@vaadin/testing-helpers": "^2.0.0",
44
44
  "sinon": "^22.0.0"
45
45
  },
46
46
  "customElements": "custom-elements.json",
47
- "gitHead": "d4809590b2f61bd607e376ab3dec84f4bfb059a7"
47
+ "gitHead": "be38ec1866e96508f3f4591f95c949ef55903a34"
48
48
  }
@@ -76,4 +76,11 @@ export declare class InputControlMixinClass {
76
76
  * The text usually displayed in a tooltip popup when the mouse is over the field.
77
77
  */
78
78
  title: string;
79
+
80
+ /**
81
+ * Returns true when pasted, dropped or inserted text passes `allowedCharPattern`.
82
+ * Only called while the pattern is set. Override to accept text that the raw
83
+ * pattern test would reject.
84
+ */
85
+ protected _shouldAcceptText(text: string): boolean;
79
86
  }
@@ -186,6 +186,18 @@ export const InputControlMixin = (superclass) =>
186
186
  });
187
187
  }
188
188
 
189
+ /**
190
+ * Returns true when pasted, dropped or inserted text passes `allowedCharPattern`.
191
+ * Only called while the pattern is set. Override to accept text that the raw
192
+ * pattern test would reject.
193
+ * @param {string} text
194
+ * @return {boolean}
195
+ * @protected
196
+ */
197
+ _shouldAcceptText(text) {
198
+ return this.__allowedTextRegExp.test(text);
199
+ }
200
+
189
201
  /** @private */
190
202
  __shouldAcceptKey(event) {
191
203
  return (
@@ -201,7 +213,7 @@ export const InputControlMixin = (superclass) =>
201
213
  _onPaste(e) {
202
214
  if (this.allowedCharPattern) {
203
215
  const pastedText = e.clipboardData.getData('text');
204
- if (!this.__allowedTextRegExp.test(pastedText)) {
216
+ if (!this._shouldAcceptText(pastedText)) {
205
217
  e.preventDefault();
206
218
  this._markInputPrevented();
207
219
  }
@@ -212,7 +224,7 @@ export const InputControlMixin = (superclass) =>
212
224
  _onDrop(e) {
213
225
  if (this.allowedCharPattern) {
214
226
  const draggedText = e.dataTransfer.getData('text');
215
- if (!this.__allowedTextRegExp.test(draggedText)) {
227
+ if (!this._shouldAcceptText(draggedText)) {
216
228
  e.preventDefault();
217
229
  this._markInputPrevented();
218
230
  }
@@ -225,7 +237,7 @@ export const InputControlMixin = (superclass) =>
225
237
  // but it is still experimental technology so we can't rely on it. It's used here just as an additional check,
226
238
  // because it seems to be the only way to detect and prevent specific keys on mobile devices.
227
239
  // See https://github.com/vaadin/vaadin-text-field/issues/429
228
- if (this.allowedCharPattern && e.data && !this.__allowedTextRegExp.test(e.data)) {
240
+ if (this.allowedCharPattern && e.data && !this._shouldAcceptText(e.data)) {
229
241
  e.preventDefault();
230
242
  this._markInputPrevented();
231
243
  }
@@ -24,6 +24,10 @@ export const checkable = (part, propName = part) => css`
24
24
  column-gap: 0;
25
25
  }
26
26
 
27
+ :host([data-form-layout-has-labels-aside]) {
28
+ padding-inline-start: calc(var(--vaadin-form-layout-label-width) + var(--vaadin-form-layout-label-spacing));
29
+ }
30
+
27
31
  [part='${unsafeCSS(part)}'],
28
32
  ::slotted(input),
29
33
  [part='label'],
@@ -64,6 +68,7 @@ export const checkable = (part, propName = part) => css`
64
68
  /* Baseline vertical alignment */
65
69
  :host::before {
66
70
  grid-row: 1;
71
+ grid-column: 1;
67
72
  margin: 0;
68
73
  padding: 0;
69
74
  border: 0;
@@ -6,3 +6,5 @@
6
6
  import type { CSSResult } from 'lit';
7
7
 
8
8
  export const field: CSSResult;
9
+
10
+ export const fieldLabelAside: CSSResult;
@@ -14,15 +14,19 @@ export const field = css`
14
14
  --_has-helper: ;
15
15
  --_no-error: initial;
16
16
  --_has-error: ;
17
+ --_rows-after-input: ;
17
18
  --_gap: var(--vaadin-input-field-container-gap, var(--vaadin-gap-xs));
18
19
  --_gap-s: round(var(--_gap) / 3, 2px);
19
20
  display: inline-grid;
20
21
  grid-template:
21
- 'label' auto var(--_helper-above-field, 'helper' auto) 'baseline' 0 'input' 1fr var(
22
- --_helper-below-field,
23
- 'helper' auto
24
- )
25
- 'error' auto / 100%;
22
+ ' label' auto
23
+ var(--_helper-above-field, 'helper' auto)
24
+ ' baseline' 0
25
+ ' input' 1fr
26
+ var(--_rows-after-input)
27
+ var(--_helper-below-field, 'helper' auto)
28
+ ' error' auto
29
+ / 100%;
26
30
  height: fit-content;
27
31
  outline: none;
28
32
  cursor: default;
@@ -52,7 +56,7 @@ export const field = css`
52
56
  /* Baseline alignment guide */
53
57
  :host::before {
54
58
  content: '\\2003' / '';
55
- grid-column: 1;
59
+ grid-column: baseline;
56
60
  grid-row: 1 / baseline;
57
61
  align-self: end;
58
62
  font-size: var(--vaadin-input-field-value-font-size, inherit);
@@ -195,3 +199,39 @@ export const field = css`
195
199
  }
196
200
  }
197
201
  `;
202
+
203
+ export const fieldLabelAside = css`
204
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) {
205
+ --_label-aside-width: 0px;
206
+ --_label-aside-gap: 0px;
207
+
208
+ grid-template:
209
+ var(--_helper-above-field, '. helper' auto)
210
+ ' . baseline' 0
211
+ ' label input' 1fr
212
+ var(--_rows-after-input)
213
+ var(--_helper-below-field, 'label helper' auto)
214
+ ' label error' auto
215
+ / var(--_label-aside-width) minmax(0, 1fr);
216
+ column-gap: var(--_label-aside-gap);
217
+ }
218
+
219
+ :host(:is([theme~='label-aside'][has-label], [data-form-layout-has-labels-aside])) {
220
+ --_label-aside-width: var(--vaadin-input-field-label-aside-width, auto);
221
+ --_label-aside-gap: var(--vaadin-input-field-label-aside-gap, 1em);
222
+ }
223
+
224
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) [part='label'] {
225
+ width: auto;
226
+ min-width: auto;
227
+ align-self: baseline;
228
+ margin-bottom: 0;
229
+ text-align: var(--vaadin-input-field-label-aside-text-align, inherit);
230
+ }
231
+
232
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) [part='input-field'],
233
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) [part='group-field'],
234
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) [part='input-fields'] {
235
+ align-self: baseline;
236
+ }
237
+ `;
@@ -26,4 +26,9 @@ export const group = css`
26
26
  padding-block: var(--vaadin-padding-block-container);
27
27
  border-block: var(--vaadin-input-field-border-width, 1px) solid transparent;
28
28
  }
29
+
30
+ :host(:is([theme~='label-aside'], [data-form-layout-has-labels-aside])) [part='group-field'] {
31
+ padding-block-start: var(--vaadin-padding-block-container);
32
+ border-block-start: var(--vaadin-input-field-border-width, 1px) solid transparent;
33
+ }
29
34
  `;
@@ -4,6 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { button } from './button-base-styles.js';
7
- import { field } from './field-base-styles.js';
7
+ import { field, fieldLabelAside } from './field-base-styles.js';
8
8
 
9
- export const inputFieldShared = [field, button];
9
+ export const inputFieldShared = [field, fieldLabelAside, button];