@vaadin/input-container 24.2.0-dev.f254716fe → 24.3.0-alpha2

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.0-dev.f254716fe",
3
+ "version": "24.3.0-alpha2",
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.0-dev.f254716fe",
36
- "@vaadin/vaadin-lumo-styles": "24.2.0-dev.f254716fe",
37
- "@vaadin/vaadin-material-styles": "24.2.0-dev.f254716fe",
38
- "@vaadin/vaadin-themable-mixin": "24.2.0-dev.f254716fe"
36
+ "@vaadin/component-base": "24.3.0-alpha2",
37
+ "@vaadin/vaadin-lumo-styles": "24.3.0-alpha2",
38
+ "@vaadin/vaadin-material-styles": "24.3.0-alpha2",
39
+ "@vaadin/vaadin-themable-mixin": "24.3.0-alpha2"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@esm-bundle/chai": "^4.3.4",
42
- "@vaadin/icon": "24.2.0-dev.f254716fe",
43
- "@vaadin/icons": "24.2.0-dev.f254716fe",
44
- "@vaadin/testing-helpers": "^0.4.3",
43
+ "@vaadin/icon": "24.3.0-alpha2",
44
+ "@vaadin/icons": "24.3.0-alpha2",
45
+ "@vaadin/testing-helpers": "^0.5.0",
45
46
  "sinon": "^13.0.2"
46
47
  },
47
- "gitHead": "da54950b9f8c14c6451ede0d426e16a489c7fb9b"
48
+ "gitHead": "0fd437292fa2a2f65e29b424d2456909ad2d684b"
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
+ `;
@@ -4,138 +4,33 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
7
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
8
- 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';
9
12
 
10
- export class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
13
+ registerStyles('vaadin-input-container', inputContainerStyles, { moduleId: 'vaadin-input-container-styles' });
14
+
15
+ /**
16
+ * @customElement
17
+ * @extends HTMLElement
18
+ * @mixes ThemableMixin
19
+ * @mixes DirMixin
20
+ * @mixes InputContainerMixin
21
+ */
22
+ export class InputContainer extends InputContainerMixin(ThemableMixin(DirMixin(PolymerElement))) {
11
23
  static get is() {
12
24
  return 'vaadin-input-container';
13
25
  }
14
26
 
15
27
  static get template() {
16
28
  return html`
17
- <style>
18
- :host {
19
- display: flex;
20
- align-items: center;
21
- flex: 0 1 auto;
22
- border-radius:
23
- /* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
24
- var(--vaadin-input-field-top-start-radius, var(--__border-radius))
25
- var(--vaadin-input-field-top-end-radius, var(--__border-radius))
26
- var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
27
- var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
28
- --_border-radius: var(--vaadin-input-field-border-radius, 0px);
29
- --_input-border-width: var(--vaadin-input-field-border-width, 0);
30
- --_input-border-color: var(--vaadin-input-field-border-color, transparent);
31
- box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
32
- }
33
-
34
- :host([dir='rtl']) {
35
- border-radius:
36
- /* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
37
- var(--vaadin-input-field-top-end-radius, var(--_border-radius))
38
- var(--vaadin-input-field-top-start-radius, var(--_border-radius))
39
- var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
40
- var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
41
- }
42
-
43
- :host([hidden]) {
44
- display: none !important;
45
- }
46
-
47
- /* Reset the native input styles */
48
- ::slotted(input) {
49
- -webkit-appearance: none;
50
- -moz-appearance: none;
51
- flex: auto;
52
- white-space: nowrap;
53
- overflow: hidden;
54
- width: 100%;
55
- height: 100%;
56
- outline: none;
57
- margin: 0;
58
- padding: 0;
59
- border: 0;
60
- border-radius: 0;
61
- min-width: 0;
62
- font: inherit;
63
- line-height: normal;
64
- color: inherit;
65
- background-color: transparent;
66
- /* Disable default invalid style in Firefox */
67
- box-shadow: none;
68
- }
69
-
70
- ::slotted(*) {
71
- flex: none;
72
- }
73
-
74
- ::slotted(:is(input, textarea))::placeholder {
75
- /* Use ::slotted(input:placeholder-shown) in themes to style the placeholder. */
76
- /* because ::slotted(...)::placeholder does not work in Safari. */
77
- font: inherit;
78
- color: inherit;
79
- /* Override default opacity in Firefox */
80
- opacity: 1;
81
- }
82
- </style>
83
29
  <slot name="prefix"></slot>
84
30
  <slot></slot>
85
31
  <slot name="suffix"></slot>
86
32
  `;
87
33
  }
88
-
89
- static get properties() {
90
- return {
91
- /**
92
- * If true, the user cannot interact with this element.
93
- */
94
- disabled: {
95
- type: Boolean,
96
- reflectToAttribute: true,
97
- },
98
-
99
- /**
100
- * Set to true to make this element read-only.
101
- */
102
- readonly: {
103
- type: Boolean,
104
- reflectToAttribute: true,
105
- },
106
-
107
- /**
108
- * Set to true when the element is invalid.
109
- */
110
- invalid: {
111
- type: Boolean,
112
- reflectToAttribute: true,
113
- },
114
- };
115
- }
116
-
117
- /** @protected */
118
- ready() {
119
- super.ready();
120
-
121
- this.addEventListener('pointerdown', (event) => {
122
- if (event.target === this) {
123
- // Prevent direct clicks to the input container from blurring the input
124
- event.preventDefault();
125
- }
126
- });
127
-
128
- this.addEventListener('click', (event) => {
129
- if (event.target === this) {
130
- // The vaadin-input-container element was directly clicked,
131
- // focus any focusable child element from the default slot
132
- this.shadowRoot
133
- .querySelector('slot:not([name])')
134
- .assignedNodes({ flatten: true })
135
- .forEach((node) => node.focus && node.focus());
136
- }
137
- });
138
- }
139
34
  }
140
35
 
141
- customElements.define(InputContainer.is, InputContainer);
36
+ defineCustomElement(InputContainer);