@spectrum-web-components/icon 0.10.0 → 0.11.1
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/custom-elements.json +1 -1
- package/package.json +5 -5
- package/src/Icon.d.ts +1 -1
- package/src/Icon.js +5 -3
- package/src/Icon.js.map +1 -1
- package/src/IconBase.d.ts +1 -1
- package/src/IconBase.js +2 -1
- package/src/IconBase.js.map +1 -1
package/custom-elements.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@spectrum-web-components/icon",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.1",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
@@ -44,17 +44,17 @@
|
|
44
44
|
"lit-html"
|
45
45
|
],
|
46
46
|
"dependencies": {
|
47
|
-
"@spectrum-web-components/base": "^0.
|
48
|
-
"@spectrum-web-components/iconset": "^0.
|
47
|
+
"@spectrum-web-components/base": "^0.5.1",
|
48
|
+
"@spectrum-web-components/iconset": "^0.6.1",
|
49
49
|
"tslib": "^2.0.0"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
|
-
"@spectrum-css/icon": "^3.0.
|
52
|
+
"@spectrum-css/icon": "^3.0.10"
|
53
53
|
},
|
54
54
|
"types": "./src/index.d.ts",
|
55
55
|
"customElements": "custom-elements.json",
|
56
56
|
"sideEffects": [
|
57
57
|
"./sp-*.js"
|
58
58
|
],
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b"
|
60
60
|
}
|
package/src/Icon.d.ts
CHANGED
package/src/Icon.js
CHANGED
@@ -10,7 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
10
10
|
governing permissions and limitations under the License.
|
11
11
|
*/
|
12
12
|
import { __decorate } from "tslib";
|
13
|
-
import { html
|
13
|
+
import { html } from '@spectrum-web-components/base';
|
14
|
+
import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
|
15
|
+
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
|
14
16
|
import { IconsetRegistry } from '@spectrum-web-components/iconset/src/iconset-registry.js';
|
15
17
|
import { IconBase } from './IconBase.js';
|
16
18
|
/**
|
@@ -89,8 +91,8 @@ export class Icon extends IconBase {
|
|
89
91
|
}
|
90
92
|
return { iconset: iconsetName, icon: iconName };
|
91
93
|
}
|
92
|
-
async
|
93
|
-
const complete = (await super.
|
94
|
+
async getUpdateComplete() {
|
95
|
+
const complete = (await super.getUpdateComplete());
|
94
96
|
await this.updateIconPromise;
|
95
97
|
return complete;
|
96
98
|
}
|
package/src/Icon.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["Icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["Icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAE3F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,QAAQ;IAAlC;;QAmCY,oBAAe,GAAG,CAAC,KAAkB,EAAQ,EAAE;YACnD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACZ,OAAO;aACV;YACD,0CAA0C;YAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,IA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Q,EAAE;iCACS;AAGpB;IADC,QAAQ,EAAE;kCACU;AAGrB;IADC,KAAK,CAAC,YAAY,CAAC;2CACgB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport { IconsetRegistry } from '@spectrum-web-components/iconset/src/iconset-registry.js';\n\nimport { IconBase } from './IconBase.js';\n\n/**\n * @element sp-icon\n */\nexport class Icon extends IconBase {\n @property()\n public src?: string;\n\n @property()\n public name?: string;\n\n @query('#container')\n private iconContainer?: HTMLElement;\n\n private updateIconPromise?: Promise<void>;\n\n public connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('sp-iconset-added', this.iconsetListener);\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('sp-iconset-added', this.iconsetListener);\n }\n\n public firstUpdated(): void {\n this.updateIconPromise = this.updateIcon();\n }\n\n public attributeChangedCallback(\n name: string,\n old: string,\n value: string\n ): void {\n super.attributeChangedCallback(name, old, value);\n this.updateIconPromise = this.updateIcon(); // any of our attributes change, update our icon\n }\n\n private iconsetListener = (event: CustomEvent): void => {\n if (!this.name) {\n return;\n }\n // parse the icon name to get iconset name\n const icon = this.parseIcon(this.name);\n if (event.detail.name === icon.iconset) {\n this.updateIconPromise = this.updateIcon();\n }\n };\n\n protected render(): TemplateResult {\n if (this.name) {\n return html`\n <div id=\"container\"></div>\n `;\n } else if (this.src) {\n return html`\n <img src=\"${this.src}\" alt=${ifDefined(this.label)} />\n `;\n }\n return super.render();\n }\n\n private async updateIcon(): Promise<void> {\n if (this.updateIconPromise) {\n await this.updateIconPromise;\n }\n if (!this.name) {\n return Promise.resolve();\n }\n // parse the icon name to get iconset name\n const icon = this.parseIcon(this.name);\n // try to retrieve the iconset\n const iconset = IconsetRegistry.getInstance().getIconset(icon.iconset);\n if (!iconset) {\n // we can stop here as there's nothing to be done till we get the iconset\n return Promise.resolve();\n }\n if (!this.iconContainer) {\n return Promise.resolve();\n }\n this.iconContainer.innerHTML = '';\n return iconset.applyIconToElement(\n this.iconContainer,\n icon.icon,\n this.size || '',\n this.label ? this.label : ''\n );\n }\n\n private parseIcon(icon: string): { iconset: string; icon: string } {\n const iconParts = icon.split(':');\n let iconsetName = 'default';\n let iconName = icon;\n if (iconParts.length > 1) {\n iconsetName = iconParts[0];\n iconName = iconParts[1];\n }\n return { iconset: iconsetName, icon: iconName };\n }\n\n protected async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.updateIconPromise;\n return complete;\n }\n}\n"]}
|
package/src/IconBase.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
2
2
|
export declare class IconBase extends SpectrumElement {
|
3
3
|
static get styles(): CSSResultArray;
|
4
4
|
label?: string;
|
package/src/IconBase.js
CHANGED
@@ -10,7 +10,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
10
10
|
governing permissions and limitations under the License.
|
11
11
|
*/
|
12
12
|
import { __decorate } from "tslib";
|
13
|
-
import { html, SpectrumElement,
|
13
|
+
import { html, SpectrumElement, } from '@spectrum-web-components/base';
|
14
|
+
import { property } from '@spectrum-web-components/base/src/decorators.js';
|
14
15
|
import iconStyles from './icon.css.js';
|
15
16
|
export class IconBase extends SpectrumElement {
|
16
17
|
static get styles() {
|
package/src/IconBase.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"IconBase.js","sourceRoot":"","sources":["IconBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,
|
1
|
+
{"version":3,"file":"IconBase.js","sourceRoot":"","sources":["IconBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,EACJ,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAE3E,OAAO,UAAU,MAAM,eAAe,CAAC;AAEvC,MAAM,OAAO,QAAS,SAAQ,eAAe;IAClC,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;IAQS,MAAM;QACZ,OAAO,IAAI,CAAA;;SAEV,CAAC;IACN,CAAC;CACJ;AAVG;IADC,QAAQ,EAAE;uCACW;AAGtB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCACiB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport iconStyles from './icon.css.js';\n\nexport class IconBase extends SpectrumElement {\n public static get styles(): CSSResultArray {\n return [iconStyles];\n }\n\n @property()\n public label?: string;\n\n @property({ reflect: true })\n public size?: 's' | 'm' | 'l' | 'xl' | 'xxl';\n\n protected render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n}\n"]}
|