@vaadin/icon 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/icon",
3
- "version": "23.1.0-rc3",
3
+ "version": "23.2.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/component-base": "23.1.0-rc3",
37
- "@vaadin/vaadin-lumo-styles": "23.1.0-rc3",
38
- "@vaadin/vaadin-themable-mixin": "23.1.0-rc3",
36
+ "@vaadin/component-base": "23.2.0-alpha1",
37
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha1",
38
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha1",
39
39
  "lit": "^2.0.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@vaadin/testing-helpers": "^0.3.2"
43
43
  },
44
- "gitHead": "49c312fbe0228adb559296d45655bbfd4eac6235"
44
+ "gitHead": "f226a2976c270d3d53c824f6e0a740a5d3382d91"
45
45
  }
@@ -83,7 +83,7 @@ class Icon extends ThemableMixin(ElementMixin(PolymerElement)) {
83
83
  version="1.1"
84
84
  xmlns="http://www.w3.org/2000/svg"
85
85
  xmlns:xlink="http://www.w3.org/1999/xlink"
86
- viewBox="[[__computeViewBox(size)]]"
86
+ viewBox="[[__computeViewBox(size, __viewBox)]]"
87
87
  preserveAspectRatio="xMidYMid meet"
88
88
  aria-hidden="true"
89
89
  ></svg>
@@ -128,6 +128,9 @@ class Icon extends ThemableMixin(ElementMixin(PolymerElement)) {
128
128
 
129
129
  /** @private */
130
130
  __svgElement: Object,
131
+
132
+ /** @private */
133
+ __viewBox: String,
131
134
  };
132
135
  }
133
136
 
@@ -163,11 +166,13 @@ class Icon extends ThemableMixin(ElementMixin(PolymerElement)) {
163
166
  }
164
167
  }
165
168
 
169
+ /** @protected */
166
170
  connectedCallback() {
167
171
  super.connectedCallback();
168
172
  document.addEventListener('vaadin-iconset-registered', this.__onIconsetRegistered);
169
173
  }
170
174
 
175
+ /** @protected */
171
176
  disconnectedCallback() {
172
177
  super.disconnectedCallback();
173
178
  document.removeEventListener('vaadin-iconset-registered', this.__onIconsetRegistered);
@@ -179,7 +184,10 @@ class Icon extends ThemableMixin(ElementMixin(PolymerElement)) {
179
184
  this.__checkDeprecatedIcon(icon);
180
185
  const iconsetName = this.__getIconsetName(icon);
181
186
  const iconset = Iconset.getIconset(iconsetName);
182
- const { svg, size } = iconset.applyIcon(icon);
187
+ const { svg, size, viewBox } = iconset.applyIcon(icon);
188
+ if (viewBox) {
189
+ this.__viewBox = viewBox;
190
+ }
183
191
  if (size !== this.size) {
184
192
  this.size = size;
185
193
  }
@@ -213,8 +221,8 @@ class Icon extends ThemableMixin(ElementMixin(PolymerElement)) {
213
221
  }
214
222
 
215
223
  /** @private */
216
- __computeViewBox(size) {
217
- return `0 0 ${size} ${size}`;
224
+ __computeViewBox(size, viewBox) {
225
+ return viewBox || `0 0 ${size} ${size}`;
218
226
  }
219
227
  }
220
228
 
@@ -35,7 +35,7 @@ declare class Iconset extends ElementMixin(HTMLElement) {
35
35
  * Produce SVGTemplateResult for the element matching `name` in this
36
36
  * iconset, or `undefined` if there is no matching element.
37
37
  */
38
- applyIcon(name: string): { svg: IconSvgLiteral; size: number };
38
+ applyIcon(name: string): { svg: IconSvgLiteral; size: number; viewBox: string | null };
39
39
  }
40
40
 
41
41
  declare global {
@@ -82,7 +82,12 @@ class Iconset extends ElementMixin(PolymerElement) {
82
82
  // Create the icon map on-demand, since the iconset itself has no discrete
83
83
  // signal to know when it's children are fully parsed
84
84
  this._icons = this._icons || this.__createIconMap();
85
- return { svg: cloneSvgNode(this._icons[this.__getIconId(name)]), size: this.size };
85
+ const icon = this._icons[this.__getIconId(name)];
86
+ return {
87
+ svg: cloneSvgNode(icon),
88
+ size: this.size,
89
+ viewBox: icon ? icon.getAttribute('viewBox') : null,
90
+ };
86
91
  }
87
92
 
88
93
  /**