@vaadin/component-base 23.1.0-rc3 → 23.2.0-alpha1

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/component-base",
3
- "version": "23.1.0-rc3",
3
+ "version": "23.2.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.3.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "49c312fbe0228adb559296d45655bbfd4eac6235"
45
+ "gitHead": "f226a2976c270d3d53c824f6e0a740a5d3382d91"
46
46
  }
@@ -5,6 +5,11 @@
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
7
 
8
+ /**
9
+ * @typedef ReactiveController
10
+ * @type {import('lit').ReactiveController}
11
+ */
12
+
8
13
  /**
9
14
  * A mixin for connecting controllers to the element.
10
15
  *
@@ -17,7 +22,7 @@ export const ControllerMixin = dedupingMixin(
17
22
  super();
18
23
 
19
24
  /**
20
- * @type {Set<import('lit').ReactiveController>}
25
+ * @type {Set<ReactiveController>}
21
26
  */
22
27
  this.__controllers = new Set();
23
28
  }
@@ -47,7 +52,7 @@ export const ControllerMixin = dedupingMixin(
47
52
  /**
48
53
  * Registers a controller to participate in the element update cycle.
49
54
  *
50
- * @param {import('lit').ReactiveController} controller
55
+ * @param {ReactiveController} controller
51
56
  * @protected
52
57
  */
53
58
  addController(controller) {
@@ -61,7 +66,7 @@ export const ControllerMixin = dedupingMixin(
61
66
  /**
62
67
  * Removes a controller from the element.
63
68
  *
64
- * @param {import('lit').ReactiveController} controller
69
+ * @param {ReactiveController} controller
65
70
  * @protected
66
71
  */
67
72
  removeController(controller) {
@@ -39,7 +39,7 @@ const registered = new Set();
39
39
  export const ElementMixin = (superClass) =>
40
40
  class VaadinElementMixin extends DirMixin(superClass) {
41
41
  static get version() {
42
- return '23.1.0-rc3';
42
+ return '23.2.0-alpha1';
43
43
  }
44
44
 
45
45
  /** @protected */
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
7
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
7
+ import { generateUniqueId } from './unique-id-utils.js';
8
8
 
9
9
  /**
10
10
  * A controller for providing content to slot element and observing changes.
@@ -20,14 +20,7 @@ export class SlotController extends EventTarget {
20
20
  */
21
21
  static generateId(slotName, host) {
22
22
  const prefix = slotName || 'default';
23
-
24
- // Support dash-case slot names e.g. "error-message"
25
- const field = `${dashToCamelCase(prefix)}Id`;
26
-
27
- // Maintain the unique ID counter for a given prefix.
28
- this[field] = 1 + this[field] || 0;
29
-
30
- return `${prefix}-${host.localName}-${this[field]}`;
23
+ return `${prefix}-${host.localName}-${generateUniqueId()}`;
31
24
  }
32
25
 
33
26
  constructor(host, slotName, slotFactory, slotInitializer) {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * Resets the unique id counter.
9
+ */
10
+ export function resetUniqueId(): void;
11
+
12
+ /**
13
+ * Returns a unique integer id.
14
+ */
15
+ export function generateUniqueId(): number;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ let uniqueId = 0;
8
+
9
+ /**
10
+ * Resets the unique id counter.
11
+ *
12
+ * @return {void}
13
+ */
14
+ export function resetUniqueId() {
15
+ uniqueId = 0;
16
+ }
17
+
18
+ /**
19
+ * Returns a unique integer id.
20
+ *
21
+ * @return {number}
22
+ */
23
+ export function generateUniqueId() {
24
+ // eslint-disable-next-line no-plusplus
25
+ return uniqueId++;
26
+ }