@vaadin/input-container 24.2.3 → 24.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/input-container",
3
- "version": "24.2.3",
3
+ "version": "24.3.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,6 +21,7 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
+ "!src/vaadin-lit-input-container.js",
24
25
  "theme",
25
26
  "vaadin-*.d.ts",
26
27
  "vaadin-*.js"
@@ -32,17 +33,17 @@
32
33
  ],
33
34
  "dependencies": {
34
35
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "~24.2.3",
36
- "@vaadin/vaadin-lumo-styles": "~24.2.3",
37
- "@vaadin/vaadin-material-styles": "~24.2.3",
38
- "@vaadin/vaadin-themable-mixin": "~24.2.3"
36
+ "@vaadin/component-base": "24.3.0-alpha10",
37
+ "@vaadin/vaadin-lumo-styles": "24.3.0-alpha10",
38
+ "@vaadin/vaadin-material-styles": "24.3.0-alpha10",
39
+ "@vaadin/vaadin-themable-mixin": "24.3.0-alpha10"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@esm-bundle/chai": "^4.3.4",
42
- "@vaadin/icon": "~24.2.3",
43
- "@vaadin/icons": "~24.2.3",
44
- "@vaadin/testing-helpers": "^0.5.0",
43
+ "@vaadin/icon": "24.3.0-alpha10",
44
+ "@vaadin/icons": "24.3.0-alpha10",
45
+ "@vaadin/testing-helpers": "^0.6.0",
45
46
  "sinon": "^13.0.2"
46
47
  },
47
- "gitHead": "72e557e765e72559e9c6a525e257d185ad186dc5"
48
+ "gitHead": "0271523d93fe5df0425ff64206886614f3c6f401"
48
49
  }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * @polymerMixin
9
+ */
10
+ export const InputContainerMixin = (superClass) =>
11
+ class InputContainerMixinClass extends superClass {
12
+ static get properties() {
13
+ return {
14
+ /**
15
+ * If true, the user cannot interact with this element.
16
+ */
17
+ disabled: {
18
+ type: Boolean,
19
+ reflectToAttribute: true,
20
+ },
21
+
22
+ /**
23
+ * Set to true to make this element read-only.
24
+ */
25
+ readonly: {
26
+ type: Boolean,
27
+ reflectToAttribute: true,
28
+ },
29
+
30
+ /**
31
+ * Set to true when the element is invalid.
32
+ */
33
+ invalid: {
34
+ type: Boolean,
35
+ reflectToAttribute: true,
36
+ },
37
+ };
38
+ }
39
+
40
+ /** @protected */
41
+ ready() {
42
+ super.ready();
43
+
44
+ this.addEventListener('pointerdown', (event) => {
45
+ if (event.target === this) {
46
+ // Prevent direct clicks to the input container from blurring the input
47
+ event.preventDefault();
48
+ }
49
+ });
50
+
51
+ this.addEventListener('click', (event) => {
52
+ if (event.target === this) {
53
+ // The vaadin-input-container element was directly clicked,
54
+ // focus any focusable child element from the default slot
55
+ this.shadowRoot
56
+ .querySelector('slot:not([name])')
57
+ .assignedNodes({ flatten: true })
58
+ .forEach((node) => node.focus && node.focus());
59
+ }
60
+ });
61
+ }
62
+ };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 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 inputContainerStyles = css`
9
+ :host {
10
+ display: flex;
11
+ align-items: center;
12
+ flex: 0 1 auto;
13
+ border-radius:
14
+ /* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
15
+ var(--vaadin-input-field-top-start-radius, var(--__border-radius))
16
+ var(--vaadin-input-field-top-end-radius, var(--__border-radius))
17
+ var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
18
+ var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
19
+ --_border-radius: var(--vaadin-input-field-border-radius, 0);
20
+ --_input-border-width: var(--vaadin-input-field-border-width, 0);
21
+ --_input-border-color: var(--vaadin-input-field-border-color, transparent);
22
+ box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
23
+ }
24
+
25
+ :host([dir='rtl']) {
26
+ border-radius:
27
+ /* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
28
+ var(--vaadin-input-field-top-end-radius, var(--_border-radius))
29
+ var(--vaadin-input-field-top-start-radius, var(--_border-radius))
30
+ var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
31
+ var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
32
+ }
33
+
34
+ :host([hidden]) {
35
+ display: none !important;
36
+ }
37
+
38
+ /* Reset the native input styles */
39
+ ::slotted(input) {
40
+ -webkit-appearance: none;
41
+ -moz-appearance: none;
42
+ flex: auto;
43
+ white-space: nowrap;
44
+ overflow: hidden;
45
+ width: 100%;
46
+ height: 100%;
47
+ outline: none;
48
+ margin: 0;
49
+ padding: 0;
50
+ border: 0;
51
+ border-radius: 0;
52
+ min-width: 0;
53
+ font: inherit;
54
+ line-height: normal;
55
+ color: inherit;
56
+ background-color: transparent;
57
+ /* Disable default invalid style in Firefox */
58
+ box-shadow: none;
59
+ }
60
+
61
+ ::slotted(*) {
62
+ flex: none;
63
+ }
64
+
65
+ ::slotted(:is(input, textarea))::placeholder {
66
+ /* Use ::slotted(input:placeholder-shown) in themes to style the placeholder. */
67
+ /* because ::slotted(...)::placeholder does not work in Safari. */
68
+ font: inherit;
69
+ color: inherit;
70
+ /* Override default opacity in Firefox */
71
+ opacity: 1;
72
+ }
73
+ `;
@@ -6,143 +6,31 @@
6
6
  import { html, PolymerElement } from '@polymer/polymer';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
+ import { InputContainerMixin } from './vaadin-input-container-mixin.js';
11
+ import { inputContainerStyles } from './vaadin-input-container-styles.js';
12
+
13
+ registerStyles('vaadin-input-container', inputContainerStyles, { moduleId: 'vaadin-input-container-styles' });
10
14
 
11
15
  /**
12
16
  * @customElement
13
17
  * @extends HTMLElement
14
18
  * @mixes ThemableMixin
15
19
  * @mixes DirMixin
20
+ * @mixes InputContainerMixin
16
21
  */
17
- export class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
22
+ export class InputContainer extends InputContainerMixin(ThemableMixin(DirMixin(PolymerElement))) {
18
23
  static get is() {
19
24
  return 'vaadin-input-container';
20
25
  }
21
26
 
22
27
  static get template() {
23
28
  return html`
24
- <style>
25
- :host {
26
- display: flex;
27
- align-items: center;
28
- flex: 0 1 auto;
29
- border-radius:
30
- /* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
31
- var(--vaadin-input-field-top-start-radius, var(--__border-radius))
32
- var(--vaadin-input-field-top-end-radius, var(--__border-radius))
33
- var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
34
- var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
35
- --_border-radius: var(--vaadin-input-field-border-radius, 0px);
36
- --_input-border-width: var(--vaadin-input-field-border-width, 0);
37
- --_input-border-color: var(--vaadin-input-field-border-color, transparent);
38
- box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
39
- }
40
-
41
- :host([dir='rtl']) {
42
- border-radius:
43
- /* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
44
- var(--vaadin-input-field-top-end-radius, var(--_border-radius))
45
- var(--vaadin-input-field-top-start-radius, var(--_border-radius))
46
- var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
47
- var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
48
- }
49
-
50
- :host([hidden]) {
51
- display: none !important;
52
- }
53
-
54
- /* Reset the native input styles */
55
- ::slotted(input) {
56
- -webkit-appearance: none;
57
- -moz-appearance: none;
58
- flex: auto;
59
- white-space: nowrap;
60
- overflow: hidden;
61
- width: 100%;
62
- height: 100%;
63
- outline: none;
64
- margin: 0;
65
- padding: 0;
66
- border: 0;
67
- border-radius: 0;
68
- min-width: 0;
69
- font: inherit;
70
- line-height: normal;
71
- color: inherit;
72
- background-color: transparent;
73
- /* Disable default invalid style in Firefox */
74
- box-shadow: none;
75
- }
76
-
77
- ::slotted(*) {
78
- flex: none;
79
- }
80
-
81
- ::slotted(:is(input, textarea))::placeholder {
82
- /* Use ::slotted(input:placeholder-shown) in themes to style the placeholder. */
83
- /* because ::slotted(...)::placeholder does not work in Safari. */
84
- font: inherit;
85
- color: inherit;
86
- /* Override default opacity in Firefox */
87
- opacity: 1;
88
- }
89
- </style>
90
29
  <slot name="prefix"></slot>
91
30
  <slot></slot>
92
31
  <slot name="suffix"></slot>
93
32
  `;
94
33
  }
95
-
96
- static get properties() {
97
- return {
98
- /**
99
- * If true, the user cannot interact with this element.
100
- */
101
- disabled: {
102
- type: Boolean,
103
- reflectToAttribute: true,
104
- },
105
-
106
- /**
107
- * Set to true to make this element read-only.
108
- */
109
- readonly: {
110
- type: Boolean,
111
- reflectToAttribute: true,
112
- },
113
-
114
- /**
115
- * Set to true when the element is invalid.
116
- */
117
- invalid: {
118
- type: Boolean,
119
- reflectToAttribute: true,
120
- },
121
- };
122
- }
123
-
124
- /** @protected */
125
- ready() {
126
- super.ready();
127
-
128
- this.addEventListener('pointerdown', (event) => {
129
- if (event.target === this) {
130
- // Prevent direct clicks to the input container from blurring the input
131
- event.preventDefault();
132
- }
133
- });
134
-
135
- this.addEventListener('click', (event) => {
136
- if (event.target === this) {
137
- // The vaadin-input-container element was directly clicked,
138
- // focus any focusable child element from the default slot
139
- this.shadowRoot
140
- .querySelector('slot:not([name])')
141
- .assignedNodes({ flatten: true })
142
- .forEach((node) => node.focus && node.focus());
143
- }
144
- });
145
- }
146
34
  }
147
35
 
148
36
  defineCustomElement(InputContainer);
@@ -8,7 +8,7 @@ registerStyles(
8
8
  'vaadin-input-container',
9
9
  css`
10
10
  :host {
11
- background-color: var(--lumo-contrast-10pct);
11
+ background: var(--_background);
12
12
  padding: 0 calc(0.375em + var(--_input-container-radius) / 4 - 1px);
13
13
  font-weight: 500;
14
14
  line-height: 1;
@@ -23,8 +23,14 @@ registerStyles(
23
23
  var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius));
24
24
  /* Fallback */
25
25
  --_input-container-radius: var(--vaadin-input-field-border-radius, var(--lumo-border-radius-m));
26
- /* Default field border color */
26
+ /* Default values */
27
+ --_background: var(--vaadin-input-field-background, var(--lumo-contrast-10pct));
28
+ --_hover-highlight: var(--vaadin-input-field-hover-highlight, var(--lumo-contrast-50pct));
27
29
  --_input-border-color: var(--vaadin-input-field-border-color, var(--lumo-contrast-50pct));
30
+ --_icon-color: var(--vaadin-input-field-icon-color, var(--lumo-contrast-60pct));
31
+ --_icon-size: var(--vaadin-input-field-icon-size, var(--lumo-icon-size-m));
32
+ --_invalid-background: var(--vaadin-input-field-invalid-background, var(--lumo-error-color-10pct));
33
+ --_invalid-hover-highlight: var(--vaadin-input-field-invalid-hover-highlight, var(--lumo-error-color-50pct));
28
34
  }
29
35
 
30
36
  :host([dir='rtl']) {
@@ -43,7 +49,7 @@ registerStyles(
43
49
  inset: 0;
44
50
  border-radius: inherit;
45
51
  pointer-events: none;
46
- background-color: var(--lumo-contrast-50pct);
52
+ background: var(--_hover-highlight);
47
53
  opacity: 0;
48
54
  transition: transform 0.15s, opacity 0.2s;
49
55
  transform-origin: 100% 0;
@@ -68,7 +74,7 @@ registerStyles(
68
74
  :host([readonly])::after {
69
75
  background-color: transparent;
70
76
  opacity: 1;
71
- border: 1px dashed var(--lumo-contrast-30pct);
77
+ border: var(--vaadin-input-field-readonly-border, 1px dashed var(--lumo-contrast-30pct));
72
78
  }
73
79
 
74
80
  /* Disabled */
@@ -83,18 +89,18 @@ registerStyles(
83
89
 
84
90
  /* Invalid */
85
91
  :host([invalid]) {
86
- background-color: var(--lumo-error-color-10pct);
92
+ background: var(--_invalid-background);
87
93
  }
88
94
 
89
95
  :host([invalid])::after {
90
- background-color: var(--lumo-error-color-50pct);
96
+ background: var(--_invalid-hover-highlight);
91
97
  }
92
98
 
93
99
  /* Slotted icons */
94
100
  ::slotted(vaadin-icon) {
95
- color: var(--lumo-contrast-60pct);
96
- width: var(--lumo-icon-size-m);
97
- height: var(--lumo-icon-size-m);
101
+ color: var(--_icon-color);
102
+ width: var(--_icon-size);
103
+ height: var(--_icon-size);
98
104
  }
99
105
 
100
106
  /* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */