@vaadin/button 22.0.0-alpha5 → 22.0.0-alpha9

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,44 +1,46 @@
1
1
  {
2
2
  "name": "@vaadin/button",
3
- "version": "22.0.0-alpha5",
3
+ "version": "22.0.0-alpha9",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "vaadin-button",
8
+ "license": "Apache-2.0",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/button"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/components",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/vaadin-button/issues"
18
+ },
5
19
  "main": "vaadin-button.js",
6
20
  "module": "vaadin-button.js",
7
- "repository": "vaadin/web-components",
21
+ "files": [
22
+ "src",
23
+ "theme",
24
+ "vaadin-*.d.ts",
25
+ "vaadin-*.js"
26
+ ],
8
27
  "keywords": [
9
28
  "Vaadin",
10
29
  "button",
11
30
  "web-components",
12
31
  "web-component"
13
32
  ],
14
- "author": "Vaadin Ltd",
15
- "license": "Apache-2.0",
16
- "bugs": {
17
- "url": "https://github.com/vaadin/vaadin-button/issues"
18
- },
19
- "homepage": "https://vaadin.com/components",
20
- "files": [
21
- "vaadin-*.d.ts",
22
- "vaadin-*.js",
23
- "src",
24
- "theme"
25
- ],
26
33
  "dependencies": {
27
34
  "@polymer/polymer": "^3.0.0",
28
- "@vaadin/field-base": "^22.0.0-alpha5",
29
- "@vaadin/vaadin-control-state-mixin": "^22.0.0-alpha5",
30
- "@vaadin/vaadin-element-mixin": "^22.0.0-alpha5",
31
- "@vaadin/vaadin-lumo-styles": "^22.0.0-alpha5",
32
- "@vaadin/vaadin-material-styles": "^22.0.0-alpha5",
33
- "@vaadin/vaadin-themable-mixin": "^22.0.0-alpha5"
35
+ "@vaadin/component-base": "22.0.0-alpha9",
36
+ "@vaadin/vaadin-lumo-styles": "22.0.0-alpha9",
37
+ "@vaadin/vaadin-material-styles": "22.0.0-alpha9",
38
+ "@vaadin/vaadin-themable-mixin": "22.0.0-alpha9"
34
39
  },
35
40
  "devDependencies": {
36
41
  "@esm-bundle/chai": "^4.3.4",
37
- "@vaadin/testing-helpers": "^0.2.1",
42
+ "@vaadin/testing-helpers": "^0.3.0",
38
43
  "sinon": "^9.2.4"
39
44
  },
40
- "publishConfig": {
41
- "access": "public"
42
- },
43
- "gitHead": "012f658db6f81375be8889f63ee15e3f660fe9ec"
45
+ "gitHead": "6e8c899dc65918f97e3c0acb2076122c4b2ef274"
44
46
  }
@@ -3,10 +3,11 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
7
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
+ import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
9
+ import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
6
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
8
- import { ActiveMixin } from '@vaadin/field-base/src/active-mixin.js';
9
- import { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-control-state-mixin.js';
10
11
 
11
12
  /**
12
13
  * `<vaadin-button>` is an accessible and customizable button that allows users to perform actions.
@@ -36,7 +37,7 @@ import { ControlStateMixin } from '@vaadin/vaadin-control-state-mixin/vaadin-con
36
37
  *
37
38
  * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
38
39
  */
39
- declare class Button extends ControlStateMixin(ActiveMixin(ElementMixin(ThemableMixin(HTMLElement)))) {}
40
+ declare class Button extends ActiveMixin(TabindexMixin(FocusMixin(ElementMixin(ThemableMixin(HTMLElement))))) {}
40
41
 
41
42
  declare global {
42
43
  interface HTMLElementTagNameMap {
@@ -4,11 +4,11 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
7
+ import { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
8
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
+ import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
10
+ import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
7
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
- import { ElementMixin } from '@vaadin/vaadin-element-mixin/vaadin-element-mixin.js';
9
- import { TabindexMixin } from '@vaadin/field-base/src/tabindex-mixin.js';
10
- import { ActiveMixin } from '@vaadin/field-base/src/active-mixin.js';
11
- import { FocusMixin } from '@vaadin/field-base/src/focus-mixin.js';
12
12
 
13
13
  /**
14
14
  * `<vaadin-button>` is an accessible and customizable button that allows users to perform actions.
@@ -157,6 +157,8 @@ class Button extends ActiveMixin(TabindexMixin(FocusMixin(ElementMixin(ThemableM
157
157
  super._onKeyDown(event);
158
158
 
159
159
  if (this._activeKeys.includes(event.key)) {
160
+ event.preventDefault();
161
+
160
162
  // `DisabledMixin` overrides the standard `click()` method
161
163
  // so that it doesn't fire the `click` event when the element is disabled.
162
164
  this.click();
@@ -48,13 +48,6 @@ const button = css`
48
48
  --lumo-button-size: var(--lumo-size-l);
49
49
  }
50
50
 
51
- /* This needs to be the last selector for it to take priority */
52
- :host([disabled][disabled]) {
53
- pointer-events: none;
54
- color: var(--lumo-disabled-text-color);
55
- background-color: var(--lumo-contrast-5pct);
56
- }
57
-
58
51
  /* For interaction states */
59
52
  :host::before,
60
53
  :host::after {
@@ -75,14 +68,9 @@ const button = css`
75
68
 
76
69
  /* Hover */
77
70
 
78
- :host(:hover)::before {
79
- opacity: 0.05;
80
- }
81
-
82
- /* Disable hover for touch devices */
83
- @media (pointer: coarse) {
84
- :host(:not([active]):hover)::before {
85
- opacity: 0;
71
+ @media (any-hover: hover) {
72
+ :host(:hover)::before {
73
+ opacity: 0.02;
86
74
  }
87
75
  }
88
76
 
@@ -94,7 +82,7 @@ const button = css`
94
82
  }
95
83
 
96
84
  :host([active])::before {
97
- opacity: 0.1;
85
+ opacity: 0.05;
98
86
  transition-duration: 0s;
99
87
  }
100
88
 
@@ -110,34 +98,24 @@ const button = css`
110
98
  box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
111
99
  }
112
100
 
101
+ :host([theme~='primary'][focus-ring]) {
102
+ box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
103
+ }
104
+
113
105
  /* Types (primary, tertiary, tertiary-inline */
114
106
 
115
107
  :host([theme~='tertiary']),
116
108
  :host([theme~='tertiary-inline']) {
117
109
  background-color: transparent !important;
118
- transition: opacity 0.2s;
119
110
  min-width: 0;
120
111
  }
121
112
 
122
- :host([theme~='tertiary'])::before,
123
- :host([theme~='tertiary-inline'])::before {
124
- display: none;
125
- }
126
-
127
113
  :host([theme~='tertiary']) {
128
114
  padding: 0 calc(var(--lumo-button-size) / 6);
129
115
  }
130
116
 
131
- @media (hover: hover) {
132
- :host([theme*='tertiary']:not([active]):hover) {
133
- opacity: 0.8;
134
- }
135
- }
136
-
137
- :host([theme~='tertiary'][active]),
138
- :host([theme~='tertiary-inline'][active]) {
139
- opacity: 0.5;
140
- transition-duration: 0s;
117
+ :host([theme~='tertiary-inline'])::before {
118
+ display: none;
141
119
  }
142
120
 
143
121
  :host([theme~='tertiary-inline']) {
@@ -161,27 +139,18 @@ const button = css`
161
139
  min-width: calc(var(--lumo-button-size) * 2.5);
162
140
  }
163
141
 
164
- :host([theme~='primary'][disabled]) {
165
- background-color: var(--lumo-primary-color-50pct);
166
- color: var(--lumo-primary-contrast-color);
142
+ :host([theme~='primary'])::before {
143
+ background-color: black;
167
144
  }
168
145
 
169
- :host([theme~='primary']:hover)::before {
170
- opacity: 0.1;
146
+ @media (any-hover: hover) {
147
+ :host([theme~='primary']:hover)::before {
148
+ opacity: 0.05;
149
+ }
171
150
  }
172
151
 
173
152
  :host([theme~='primary'][active])::before {
174
- background-color: var(--lumo-shade-20pct);
175
- }
176
-
177
- @media (pointer: coarse) {
178
- :host([theme~='primary'][active])::before {
179
- background-color: var(--lumo-shade-60pct);
180
- }
181
-
182
- :host([theme~='primary']:not([active]):hover)::before {
183
- opacity: 0;
184
- }
153
+ opacity: 0.1;
185
154
  }
186
155
 
187
156
  :host([theme~='primary'][active])::after {
@@ -199,10 +168,6 @@ const button = css`
199
168
  color: var(--lumo-success-contrast-color);
200
169
  }
201
170
 
202
- :host([theme~='success'][theme~='primary'][disabled]) {
203
- background-color: var(--lumo-success-color-50pct);
204
- }
205
-
206
171
  :host([theme~='error']) {
207
172
  color: var(--lumo-error-text-color);
208
173
  }
@@ -212,10 +177,6 @@ const button = css`
212
177
  color: var(--lumo-error-contrast-color);
213
178
  }
214
179
 
215
- :host([theme~='error'][theme~='primary'][disabled]) {
216
- background-color: var(--lumo-error-color-50pct);
217
- }
218
-
219
180
  :host([theme~='contrast']) {
220
181
  color: var(--lumo-contrast);
221
182
  }
@@ -225,8 +186,20 @@ const button = css`
225
186
  color: var(--lumo-base-color);
226
187
  }
227
188
 
228
- :host([theme~='contrast'][theme~='primary'][disabled]) {
229
- background-color: var(--lumo-contrast-50pct);
189
+ /* Disabled state. Keep selectors after other color variants. */
190
+
191
+ :host([disabled]) {
192
+ pointer-events: none;
193
+ color: var(--lumo-disabled-text-color);
194
+ }
195
+
196
+ :host([theme~='primary'][disabled]) {
197
+ background-color: var(--lumo-contrast-30pct);
198
+ color: var(--lumo-base-color);
199
+ }
200
+
201
+ :host([theme~='primary'][disabled]) [part] {
202
+ opacity: 0.7;
230
203
  }
231
204
 
232
205
  /* Icons */