@vaadin/radio-group 24.3.0-alpha1 → 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/radio-group",
3
- "version": "24.3.0-alpha1",
3
+ "version": "24.3.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,6 +21,10 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
+ "!src/vaadin-lit-radio-button.d.ts",
25
+ "!src/vaadin-lit-radio-button.js",
26
+ "!src/vaadin-lit-radio-group.d.ts",
27
+ "!src/vaadin-lit-radio-group.js",
24
28
  "theme",
25
29
  "vaadin-*.d.ts",
26
30
  "vaadin-*.js",
@@ -37,22 +41,23 @@
37
41
  "polymer"
38
42
  ],
39
43
  "dependencies": {
44
+ "@open-wc/dedupe-mixin": "^1.3.0",
40
45
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.3.0-alpha1",
42
- "@vaadin/component-base": "24.3.0-alpha1",
43
- "@vaadin/field-base": "24.3.0-alpha1",
44
- "@vaadin/vaadin-lumo-styles": "24.3.0-alpha1",
45
- "@vaadin/vaadin-material-styles": "24.3.0-alpha1",
46
- "@vaadin/vaadin-themable-mixin": "24.3.0-alpha1"
46
+ "@vaadin/a11y-base": "24.3.0-alpha10",
47
+ "@vaadin/component-base": "24.3.0-alpha10",
48
+ "@vaadin/field-base": "24.3.0-alpha10",
49
+ "@vaadin/vaadin-lumo-styles": "24.3.0-alpha10",
50
+ "@vaadin/vaadin-material-styles": "24.3.0-alpha10",
51
+ "@vaadin/vaadin-themable-mixin": "24.3.0-alpha10"
47
52
  },
48
53
  "devDependencies": {
49
54
  "@esm-bundle/chai": "^4.3.4",
50
- "@vaadin/testing-helpers": "^0.5.0",
55
+ "@vaadin/testing-helpers": "^0.6.0",
51
56
  "sinon": "^13.0.2"
52
57
  },
53
58
  "web-types": [
54
59
  "web-types.json",
55
60
  "web-types.lit.json"
56
61
  ],
57
- "gitHead": "9ca6f3ca220a777e8eea181a1f5717e39a732240"
62
+ "gitHead": "0271523d93fe5df0425ff64206886614f3c6f401"
58
63
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { ActiveMixinClass } from '@vaadin/a11y-base/src/active-mixin.js';
8
+ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
9
+ import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
10
+ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
11
+ import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
12
+ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
13
+ import type { CheckedMixinClass } from '@vaadin/field-base/src/checked-mixin.js';
14
+ import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
15
+ import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
16
+
17
+ /**
18
+ * Fired when the `checked` property changes.
19
+ */
20
+ export type RadioButtonCheckedChangedEvent = CustomEvent<{ value: boolean }>;
21
+
22
+ export interface RadioButtonCustomEventMap {
23
+ 'checked-changed': RadioButtonCheckedChangedEvent;
24
+ }
25
+
26
+ export interface RadioButtonEventMap extends HTMLElementEventMap, RadioButtonCustomEventMap {}
27
+
28
+ /**
29
+ * A mixin providing common radio-button functionality.
30
+ */
31
+ export declare function RadioButtonMixin<T extends Constructor<HTMLElement>>(
32
+ base: T,
33
+ ): Constructor<ActiveMixinClass> &
34
+ Constructor<CheckedMixinClass> &
35
+ Constructor<DelegateFocusMixinClass> &
36
+ Constructor<DelegateStateMixinClass> &
37
+ Constructor<DisabledMixinClass> &
38
+ Constructor<FocusMixinClass> &
39
+ Constructor<InputMixinClass> &
40
+ Constructor<KeyboardMixinClass> &
41
+ Constructor<LabelMixinClass> &
42
+ Constructor<RadioButtonMixinClass> &
43
+ T;
44
+
45
+ export declare class RadioButtonMixinClass {
46
+ /**
47
+ * The name of the radio button.
48
+ */
49
+ name: string;
50
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { ActiveMixin } from '@vaadin/a11y-base/src/active-mixin.js';
7
+ import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
8
+ import { CheckedMixin } from '@vaadin/field-base/src/checked-mixin.js';
9
+ import { InputController } from '@vaadin/field-base/src/input-controller.js';
10
+ import { LabelMixin } from '@vaadin/field-base/src/label-mixin.js';
11
+ import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
12
+
13
+ /**
14
+ * A mixin providing common radio-button functionality.
15
+ *
16
+ * @polymerMixin
17
+ * @mixes ActiveMixin
18
+ * @mixes CheckedMixin
19
+ * @mixes DelegateFocusMixin
20
+ * @mixes LabelMixin
21
+ */
22
+ export const RadioButtonMixin = (superclass) =>
23
+ class RadioButtonMixinClass extends LabelMixin(CheckedMixin(DelegateFocusMixin(ActiveMixin(superclass)))) {
24
+ static get properties() {
25
+ return {
26
+ /**
27
+ * The name of the radio button.
28
+ *
29
+ * @type {string}
30
+ */
31
+ name: {
32
+ type: String,
33
+ value: '',
34
+ },
35
+ };
36
+ }
37
+
38
+ /** @override */
39
+ static get delegateAttrs() {
40
+ return [...super.delegateAttrs, 'name'];
41
+ }
42
+
43
+ constructor() {
44
+ super();
45
+
46
+ this._setType('radio');
47
+
48
+ // Set the string "on" as the default value for the radio button following the HTML specification:
49
+ // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
50
+ this.value = 'on';
51
+ }
52
+
53
+ /** @protected */
54
+ ready() {
55
+ super.ready();
56
+
57
+ this.addController(
58
+ new InputController(this, (input) => {
59
+ this._setInputElement(input);
60
+ this._setFocusElement(input);
61
+ this.stateTarget = input;
62
+ this.ariaTarget = input;
63
+ }),
64
+ );
65
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
66
+ }
67
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const radioButtonStyles: CSSResult;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 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 '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
+
8
+ export const radioButtonStyles = css`
9
+ :host {
10
+ display: inline-block;
11
+ }
12
+
13
+ :host([hidden]) {
14
+ display: none !important;
15
+ }
16
+
17
+ :host([disabled]) {
18
+ -webkit-tap-highlight-color: transparent;
19
+ }
20
+
21
+ .vaadin-radio-button-container {
22
+ display: grid;
23
+ grid-template-columns: auto 1fr;
24
+ align-items: baseline;
25
+ }
26
+
27
+ [part='radio'],
28
+ ::slotted(input),
29
+ ::slotted(label) {
30
+ grid-row: 1;
31
+ }
32
+
33
+ [part='radio'],
34
+ ::slotted(input) {
35
+ grid-column: 1;
36
+ }
37
+
38
+ [part='radio'] {
39
+ width: var(--vaadin-radio-button-size, 1em);
40
+ height: var(--vaadin-radio-button-size, 1em);
41
+ --_input-border-width: var(--vaadin-input-field-border-width, 0);
42
+ --_input-border-color: var(--vaadin-input-field-border-color, transparent);
43
+ box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
44
+ }
45
+
46
+ [part='radio']::before {
47
+ display: block;
48
+ content: '\\202F';
49
+ line-height: var(--vaadin-radio-button-size, 1em);
50
+ contain: paint;
51
+ }
52
+
53
+ /* visually hidden */
54
+ ::slotted(input) {
55
+ opacity: 0;
56
+ cursor: inherit;
57
+ margin: 0;
58
+ align-self: stretch;
59
+ -webkit-appearance: none;
60
+ width: initial;
61
+ height: initial;
62
+ }
63
+
64
+ @media (forced-colors: active) {
65
+ [part='radio'] {
66
+ outline: 1px solid;
67
+ outline-offset: -1px;
68
+ }
69
+
70
+ :host([focused]) [part='radio'] {
71
+ outline-width: 2px;
72
+ }
73
+
74
+ :host([disabled]) [part='radio'] {
75
+ outline-color: GrayText;
76
+ }
77
+ }
78
+ `;
@@ -3,31 +3,12 @@
3
3
  * Copyright (c) 2017 - 2023 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/a11y-base/src/active-mixin.js';
7
- import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
8
6
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
9
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
- import { CheckedMixin } from '@vaadin/field-base/src/checked-mixin.js';
11
- import { LabelMixin } from '@vaadin/field-base/src/label-mixin.js';
12
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import { type RadioButtonEventMap, RadioButtonMixin } from './vaadin-radio-button-mixin.js';
13
10
 
14
- /**
15
- * Fired when the `checked` property changes.
16
- */
17
- export type RadioButtonCheckedChangedEvent = CustomEvent<{ value: boolean }>;
18
-
19
- /**
20
- * Fired when the `dirty` property changes.
21
- */
22
- export type RadioButtonDirtyChangedEvent = CustomEvent<{ value: boolean }>;
23
-
24
- export interface RadioButtonCustomEventMap {
25
- 'checked-changed': RadioButtonCheckedChangedEvent;
26
-
27
- 'dirty-changed': RadioButtonDirtyChangedEvent;
28
- }
29
-
30
- export interface RadioButtonEventMap extends HTMLElementEventMap, RadioButtonCustomEventMap {}
11
+ export * from './vaadin-radio-button-mixin.js';
31
12
 
32
13
  /**
33
14
  * `<vaadin-radio-button>` is a web component representing a choice in a radio group.
@@ -63,16 +44,8 @@ export interface RadioButtonEventMap extends HTMLElementEventMap, RadioButtonCus
63
44
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
64
45
  *
65
46
  * @fires {CustomEvent} checked-changed - Fired when the `checked` property changes.
66
- * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
67
47
  */
68
- declare class RadioButton extends LabelMixin(
69
- CheckedMixin(DelegateFocusMixin(ActiveMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))))),
70
- ) {
71
- /**
72
- * The name of the radio button.
73
- */
74
- name: string;
75
-
48
+ declare class RadioButton extends RadioButtonMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {
76
49
  addEventListener<K extends keyof RadioButtonEventMap>(
77
50
  type: K,
78
51
  listener: (this: RadioButton, ev: RadioButtonEventMap[K]) => void,
@@ -4,16 +4,14 @@
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/polymer-element.js';
7
- import { ActiveMixin } from '@vaadin/a11y-base/src/active-mixin.js';
8
- import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
9
7
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
10
8
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
11
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
- import { CheckedMixin } from '@vaadin/field-base/src/checked-mixin.js';
13
- import { InputController } from '@vaadin/field-base/src/input-controller.js';
14
- import { LabelMixin } from '@vaadin/field-base/src/label-mixin.js';
15
- import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
16
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
+ import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
+ import { RadioButtonMixin } from './vaadin-radio-button-mixin.js';
12
+ import { radioButtonStyles } from './vaadin-radio-button-styles.js';
13
+
14
+ registerStyles('vaadin-radio-button', radioButtonStyles, { moduleId: 'vaadin-radio-button-styles' });
17
15
 
18
16
  /**
19
17
  * `<vaadin-radio-button>` is a web component representing a choice in a radio group.
@@ -49,93 +47,20 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
49
47
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
50
48
  *
51
49
  * @fires {CustomEvent} checked-changed - Fired when the `checked` property changes.
52
- * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
53
50
  *
54
51
  * @customElement
55
52
  * @extends HTMLElement
56
- * @mixes ControllerMixin
57
53
  * @mixes ThemableMixin
58
54
  * @mixes ElementMixin
59
- * @mixes ActiveMixin
60
- * @mixes CheckedMixin
61
- * @mixes LabelMixin
55
+ * @mixes RadioButtonMixin
62
56
  */
63
- class RadioButton extends LabelMixin(
64
- CheckedMixin(DelegateFocusMixin(ActiveMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))))),
65
- ) {
57
+ class RadioButton extends RadioButtonMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
66
58
  static get is() {
67
59
  return 'vaadin-radio-button';
68
60
  }
69
61
 
70
62
  static get template() {
71
63
  return html`
72
- <style>
73
- :host {
74
- display: inline-block;
75
- }
76
-
77
- :host([hidden]) {
78
- display: none !important;
79
- }
80
-
81
- :host([disabled]) {
82
- -webkit-tap-highlight-color: transparent;
83
- }
84
-
85
- .vaadin-radio-button-container {
86
- display: grid;
87
- grid-template-columns: auto 1fr;
88
- align-items: baseline;
89
- }
90
-
91
- [part='radio'],
92
- ::slotted(input),
93
- ::slotted(label) {
94
- grid-row: 1;
95
- }
96
-
97
- [part='radio'],
98
- ::slotted(input) {
99
- grid-column: 1;
100
- }
101
-
102
- [part='radio'] {
103
- width: var(--vaadin-radio-button-size, 1em);
104
- height: var(--vaadin-radio-button-size, 1em);
105
- --_input-border-width: var(--vaadin-input-field-border-width, 0);
106
- --_input-border-color: var(--vaadin-input-field-border-color, transparent);
107
- box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
108
- }
109
-
110
- [part='radio']::before {
111
- display: block;
112
- content: '\\202F';
113
- line-height: var(--vaadin-radio-button-size, 1em);
114
- contain: paint;
115
- }
116
-
117
- /* visually hidden */
118
- ::slotted(input) {
119
- opacity: 0;
120
- cursor: inherit;
121
- margin: 0;
122
- align-self: stretch;
123
- -webkit-appearance: none;
124
- }
125
-
126
- @media (forced-colors: active) {
127
- [part='radio'] {
128
- outline: 1px solid;
129
- outline-offset: -1px;
130
- }
131
- :host([focused]) [part='radio'] {
132
- outline-width: 2px;
133
- }
134
- :host([disabled]) [part='radio'] {
135
- outline-color: GrayText;
136
- }
137
- }
138
- </style>
139
64
  <div class="vaadin-radio-button-container">
140
65
  <div part="radio" aria-hidden="true"></div>
141
66
  <slot name="input"></slot>
@@ -143,50 +68,6 @@ class RadioButton extends LabelMixin(
143
68
  </div>
144
69
  `;
145
70
  }
146
-
147
- static get properties() {
148
- return {
149
- /**
150
- * The name of the radio button.
151
- *
152
- * @type {string}
153
- */
154
- name: {
155
- type: String,
156
- value: '',
157
- },
158
- };
159
- }
160
-
161
- /** @override */
162
- static get delegateAttrs() {
163
- return [...super.delegateAttrs, 'name'];
164
- }
165
-
166
- constructor() {
167
- super();
168
-
169
- this._setType('radio');
170
-
171
- // Set the string "on" as the default value for the radio button following the HTML specification:
172
- // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
173
- this.value = 'on';
174
- }
175
-
176
- /** @protected */
177
- ready() {
178
- super.ready();
179
-
180
- this.addController(
181
- new InputController(this, (input) => {
182
- this._setInputElement(input);
183
- this._setFocusElement(input);
184
- this.stateTarget = input;
185
- this.ariaTarget = input;
186
- }),
187
- );
188
- this.addController(new LabelledInputController(this.inputElement, this._labelController));
189
- }
190
71
  }
191
72
 
192
73
  defineCustomElement(RadioButton);
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
8
+ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
9
+ import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
10
+ import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
11
+ import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
12
+ import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
13
+ import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
14
+
15
+ /**
16
+ * Fired when the `invalid` property changes.
17
+ */
18
+ export type RadioGroupInvalidChangedEvent = CustomEvent<{ value: boolean }>;
19
+
20
+ /**
21
+ * Fired when the `value` property changes.
22
+ */
23
+ export type RadioGroupValueChangedEvent = CustomEvent<{ value: string }>;
24
+
25
+ /**
26
+ * Fired whenever the field is validated.
27
+ */
28
+ export type RadioGroupValidatedEvent = CustomEvent<{ valid: boolean }>;
29
+
30
+ export interface RadioGroupCustomEventMap {
31
+ 'invalid-changed': RadioGroupInvalidChangedEvent;
32
+
33
+ 'value-changed': RadioGroupValueChangedEvent;
34
+
35
+ validated: RadioGroupValidatedEvent;
36
+ }
37
+
38
+ export interface RadioGroupEventMap extends HTMLElementEventMap, RadioGroupCustomEventMap {}
39
+
40
+ /**
41
+ * A mixin providing common radio-group functionality.
42
+ */
43
+ export declare function RadioGroupMixin<T extends Constructor<HTMLElement>>(
44
+ base: T,
45
+ ): Constructor<ControllerMixinClass> &
46
+ Constructor<DisabledMixinClass> &
47
+ Constructor<FieldMixinClass> &
48
+ Constructor<FocusMixinClass> &
49
+ Constructor<KeyboardMixinClass> &
50
+ Constructor<LabelMixinClass> &
51
+ Constructor<RadioGroupMixinClass> &
52
+ Constructor<ValidateMixinClass> &
53
+ T;
54
+
55
+ export declare class RadioGroupMixinClass {
56
+ /**
57
+ * The value of the radio group.
58
+ */
59
+ value: string | null | undefined;
60
+
61
+ /**
62
+ * When present, the user cannot modify the value of the radio group.
63
+ * The property works similarly to the `disabled` property.
64
+ * While the `disabled` property disables all the radio buttons inside the group,
65
+ * the `readonly` property disables only unchecked ones.
66
+ */
67
+ readonly: boolean;
68
+ }