@vaadin/checkbox-group 24.1.5 → 24.2.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/checkbox-group",
3
- "version": "24.1.5",
3
+ "version": "24.2.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,22 +36,22 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/a11y-base": "~24.1.5",
40
- "@vaadin/checkbox": "~24.1.5",
41
- "@vaadin/component-base": "~24.1.5",
42
- "@vaadin/field-base": "~24.1.5",
43
- "@vaadin/vaadin-lumo-styles": "~24.1.5",
44
- "@vaadin/vaadin-material-styles": "~24.1.5",
45
- "@vaadin/vaadin-themable-mixin": "~24.1.5"
39
+ "@vaadin/a11y-base": "24.2.0-alpha10",
40
+ "@vaadin/checkbox": "24.2.0-alpha10",
41
+ "@vaadin/component-base": "24.2.0-alpha10",
42
+ "@vaadin/field-base": "24.2.0-alpha10",
43
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha10",
44
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha10",
45
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha10"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/testing-helpers": "^0.4.2",
49
+ "@vaadin/testing-helpers": "^0.5.0",
50
50
  "sinon": "^13.0.2"
51
51
  },
52
52
  "web-types": [
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "2150f0696b9205ed3651033301927516b87cf88f"
56
+ "gitHead": "ca16b5f88b00ae05fb6d7c7e9874525048e389f0"
57
57
  }
@@ -14,6 +14,11 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
14
14
  */
15
15
  export type CheckboxGroupInvalidChangedEvent = CustomEvent<{ value: boolean }>;
16
16
 
17
+ /**
18
+ * Fired when the `dirty` property changes.
19
+ */
20
+ export type CheckboxGroupDirtyChangedEvent = CustomEvent<{ value: boolean }>;
21
+
17
22
  /**
18
23
  * Fired when the `value` property changes.
19
24
  */
@@ -27,6 +32,8 @@ export type CheckboxGroupValidatedEvent = CustomEvent<{ valid: boolean }>;
27
32
  export interface CheckboxGroupCustomEventMap {
28
33
  'invalid-changed': CheckboxGroupInvalidChangedEvent;
29
34
 
35
+ 'dirty-changed': CheckboxGroupDirtyChangedEvent;
36
+
30
37
  'value-changed': CheckboxGroupValueChangedEvent;
31
38
 
32
39
  validated: CheckboxGroupValidatedEvent;
@@ -73,6 +80,7 @@ export interface CheckboxGroupEventMap extends HTMLElementEventMap, CheckboxGrou
73
80
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
74
81
  *
75
82
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
83
+ * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
76
84
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
77
85
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
78
86
  */
@@ -85,6 +93,15 @@ declare class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementM
85
93
  */
86
94
  value: string[];
87
95
 
96
+ /**
97
+ * Whether the field is dirty.
98
+ *
99
+ * The field is automatically marked as dirty once the user triggers
100
+ * a `change` event. Additionally, the field can be manually marked
101
+ * as dirty by setting the property to `true`.
102
+ */
103
+ dirty: boolean;
104
+
88
105
  addEventListener<K extends keyof CheckboxGroupEventMap>(
89
106
  type: K,
90
107
  listener: (this: CheckboxGroup, ev: CheckboxGroupEventMap[K]) => void,
@@ -3,12 +3,12 @@
3
3
  * Copyright (c) 2018 - 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 { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
7
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
7
  import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
8
  import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
10
9
  import { Checkbox } from '@vaadin/checkbox/src/vaadin-checkbox.js';
11
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
+ import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
12
12
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
13
13
  import { FieldMixin } from '@vaadin/field-base/src/field-mixin.js';
14
14
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -139,6 +139,19 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
139
139
  notify: true,
140
140
  observer: '__valueChanged',
141
141
  },
142
+
143
+ /**
144
+ * Whether the field is dirty.
145
+ *
146
+ * The field is automatically marked as dirty once the user triggers
147
+ * a `change` event. Additionally, the field can be manually marked
148
+ * as dirty by setting the property to `true`.
149
+ */
150
+ dirty: {
151
+ type: Boolean,
152
+ value: false,
153
+ notify: true,
154
+ },
142
155
  };
143
156
  }
144
157
 
@@ -147,6 +160,7 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
147
160
 
148
161
  this.__registerCheckbox = this.__registerCheckbox.bind(this);
149
162
  this.__unregisterCheckbox = this.__unregisterCheckbox.bind(this);
163
+ this.__onCheckboxChange = this.__onCheckboxChange.bind(this);
150
164
  this.__onCheckboxCheckedChanged = this.__onCheckboxCheckedChanged.bind(this);
151
165
  }
152
166
 
@@ -169,7 +183,8 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
169
183
  // See https://github.com/vaadin/vaadin-web-components/issues/94
170
184
  this.setAttribute('role', 'group');
171
185
 
172
- this._observer = new FlattenedNodesObserver(this, ({ addedNodes, removedNodes }) => {
186
+ const slot = this.shadowRoot.querySelector('slot:not([name])');
187
+ this._observer = new SlotObserver(slot, ({ addedNodes, removedNodes }) => {
173
188
  const addedCheckboxes = this.__filterCheckboxes(addedNodes);
174
189
  const removedCheckboxes = this.__filterCheckboxes(removedNodes);
175
190
 
@@ -226,6 +241,7 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
226
241
  * @private
227
242
  */
228
243
  __registerCheckbox(checkbox) {
244
+ checkbox.addEventListener('change', this.__onCheckboxChange);
229
245
  checkbox.addEventListener('checked-changed', this.__onCheckboxCheckedChanged);
230
246
 
231
247
  if (this.disabled) {
@@ -246,6 +262,7 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
246
262
  * @private
247
263
  */
248
264
  __unregisterCheckbox(checkbox) {
265
+ checkbox.removeEventListener('change', this.__onCheckboxChange);
249
266
  checkbox.removeEventListener('checked-changed', this.__onCheckboxCheckedChanged);
250
267
 
251
268
  if (checkbox.checked) {
@@ -299,6 +316,11 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
299
316
  }
300
317
  }
301
318
 
319
+ /** @private */
320
+ __onCheckboxChange() {
321
+ this.dirty = true;
322
+ }
323
+
302
324
  /**
303
325
  * @param {!CustomEvent} event
304
326
  * @private
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/checkbox-group",
4
- "version": "24.1.5",
4
+ "version": "24.2.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -98,6 +98,17 @@
98
98
  ]
99
99
  }
100
100
  },
101
+ {
102
+ "name": "dirty",
103
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
104
+ "value": {
105
+ "type": [
106
+ "boolean",
107
+ "null",
108
+ "undefined"
109
+ ]
110
+ }
111
+ },
101
112
  {
102
113
  "name": "theme",
103
114
  "description": "The theme variants to apply to the component.",
@@ -208,6 +219,17 @@
208
219
  "Array.<string>"
209
220
  ]
210
221
  }
222
+ },
223
+ {
224
+ "name": "dirty",
225
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
226
+ "value": {
227
+ "type": [
228
+ "boolean",
229
+ "null",
230
+ "undefined"
231
+ ]
232
+ }
211
233
  }
212
234
  ],
213
235
  "events": [
@@ -219,6 +241,10 @@
219
241
  "name": "value-changed",
220
242
  "description": "Fired when the `value` property changes."
221
243
  },
244
+ {
245
+ "name": "dirty-changed",
246
+ "description": "Fired when the `dirty` property changes."
247
+ },
222
248
  {
223
249
  "name": "invalid-changed",
224
250
  "description": "Fired when the `invalid` property changes."
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/checkbox-group",
4
- "version": "24.1.5",
4
+ "version": "24.2.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -40,6 +40,13 @@
40
40
  "kind": "expression"
41
41
  }
42
42
  },
43
+ {
44
+ "name": "?dirty",
45
+ "description": "Whether the field is dirty.\n\nThe field is automatically marked as dirty once the user triggers\na `change` event. Additionally, the field can be manually marked\nas dirty by setting the property to `true`.",
46
+ "value": {
47
+ "kind": "expression"
48
+ }
49
+ },
43
50
  {
44
51
  "name": ".label",
45
52
  "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
@@ -96,6 +103,13 @@
96
103
  "kind": "expression"
97
104
  }
98
105
  },
106
+ {
107
+ "name": "@dirty-changed",
108
+ "description": "Fired when the `dirty` property changes.",
109
+ "value": {
110
+ "kind": "expression"
111
+ }
112
+ },
99
113
  {
100
114
  "name": "@invalid-changed",
101
115
  "description": "Fired when the `invalid` property changes.",