@spectrum-web-components/iconset 1.1.0-beta.20 → 1.1.0-beta.21

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/iconset",
3
- "version": "1.1.0-beta.20",
3
+ "version": "1.1.0-beta.21",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -60,7 +60,7 @@
60
60
  "lit-html"
61
61
  ],
62
62
  "dependencies": {
63
- "@spectrum-web-components/base": "^1.1.0-beta.20"
63
+ "@spectrum-web-components/base": "^1.1.0-beta.21"
64
64
  },
65
65
  "types": "./src/index.d.ts",
66
66
  "customElements": "custom-elements.json",
@@ -71,5 +71,5 @@
71
71
  "./stories/iconsList.json",
72
72
  "./**/*.dev.js"
73
73
  ],
74
- "gitHead": "e816f4df8eec536b8b5f30f027fd35748f62daf3"
74
+ "gitHead": "ad9ae8ce3792bdcf6fc50998e839840f334d1e72"
75
75
  }
@@ -67,6 +67,7 @@ export let IconsDemo = class extends SpectrumElement {
67
67
  this.size = "m";
68
68
  this.search = "";
69
69
  this.icons = [];
70
+ this.filteredIcons = [];
70
71
  this.unsubscribeSystemContext = null;
71
72
  this.spectrumVersion = 1;
72
73
  this.iconset = [];
@@ -76,7 +77,6 @@ export let IconsDemo = class extends SpectrumElement {
76
77
  }
77
78
  async connectedCallback() {
78
79
  super.connectedCallback();
79
- this.requestSystemContext();
80
80
  window.addEventListener("sp-iconset-added", this.handleIconSetAdded);
81
81
  }
82
82
  disconnectedCallback() {
@@ -87,23 +87,32 @@ export let IconsDemo = class extends SpectrumElement {
87
87
  this.unsubscribeSystemContext = null;
88
88
  }
89
89
  }
90
- requestSystemContext() {
91
- this.dispatchEvent(
92
- new CustomEvent("sp-system-context", {
93
- detail: {
94
- callback: (system, unsubscribe) => {
95
- this.spectrumVersion = system === "spectrum-two" ? 2 : 1;
96
- this.unsubscribeSystemContext = unsubscribe;
97
- }
98
- },
99
- bubbles: true,
100
- composed: true
101
- })
102
- );
90
+ filterIconsBySpectrumVersion() {
91
+ const iconVersion = this.spectrumVersion === 2 ? "s2" : "s1";
92
+ let filteredIcons = this.icons;
93
+ if (this.name === "workflow") {
94
+ filteredIcons = filteredIcons.filter((icon) => {
95
+ const iconName = icon.name.replace(/\s/g, "").toLowerCase();
96
+ return iconsList[iconVersion].includes(iconName);
97
+ });
98
+ }
99
+ const iconSet = /* @__PURE__ */ new Set();
100
+ filteredIcons = filteredIcons.filter((icon) => {
101
+ if (iconSet.has(icon.name)) {
102
+ return false;
103
+ }
104
+ iconSet.add(icon.name);
105
+ return true;
106
+ });
107
+ this.filteredIcons = filteredIcons;
103
108
  }
104
109
  update(changes) {
105
110
  if (changes.has(systemResolverUpdatedSymbol)) {
106
111
  this.spectrumVersion = this.systemResolver.system === "spectrum-two" ? 2 : 1;
112
+ this.filterIconsBySpectrumVersion();
113
+ }
114
+ if (changes.has("icons")) {
115
+ this.filterIconsBySpectrumVersion();
107
116
  }
108
117
  super.update(changes);
109
118
  }
@@ -190,16 +199,9 @@ export let IconsDemo = class extends SpectrumElement {
190
199
  this.updateSearch(event);
191
200
  }
192
201
  renderSearch() {
193
- let matchingIcons = this.search ? this.icons.filter(
202
+ const matchingIcons = this.search ? this.filteredIcons.filter(
194
203
  (icon) => icon.name.toLowerCase().includes(this.search.toLowerCase())
195
- ) : this.icons;
196
- const iconVersion = this.spectrumVersion === 2 ? "s2" : "s1";
197
- if (this.name === "workflow") {
198
- matchingIcons = matchingIcons.filter((icon) => {
199
- const iconName = icon.name.replace(/\s/g, "").toLowerCase();
200
- return iconsList[iconVersion].includes(iconName);
201
- });
202
- }
204
+ ) : this.filteredIcons;
203
205
  return html`
204
206
  <div class="search" part="search">
205
207
  <sp-field-label for="search">Spectrum icons:</sp-field-label>
@@ -213,8 +215,8 @@ export let IconsDemo = class extends SpectrumElement {
213
215
  autocomplete="off"
214
216
  >
215
217
  <sp-help-text slot="help-text">
216
- Showing ${matchingIcons.length} of ${this.icons.length}
217
- available icons.
218
+ Showing ${matchingIcons.length} of
219
+ ${this.filteredIcons.length} available icons.
218
220
  </sp-help-text>
219
221
  </sp-search>
220
222
  </div>
@@ -237,7 +239,7 @@ export let IconsDemo = class extends SpectrumElement {
237
239
  }
238
240
  render() {
239
241
  return html`
240
- ${this.icons.length ? this.renderSearch() : html`
242
+ ${this.filteredIcons.length ? this.renderSearch() : html`
241
243
  <slot></slot>
242
244
  `}
243
245
  ${this.iconset.map(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["icons-demo.ts"],
4
- "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*/\nimport { IconsetAddedDetail } from '@spectrum-web-components/iconset';\nimport {\n css,\n CSSResultGroup,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n customElement,\n property,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Search } from '@spectrum-web-components/search';\nimport '@spectrum-web-components/search/sp-search.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport bodyStyles from '@spectrum-web-components/styles/body.js';\nimport '@spectrum-web-components/icon/sp-icon.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\n\nimport iconsList from './iconsList.json' assert { type: 'json' };\n\nimport {\n SystemResolutionController,\n systemResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js';\n\nimport type { SystemVariant } from '@spectrum-web-components/theme';\n\n@customElement('delayed-ready')\nexport class DelayedReady extends SpectrumElement {\n _delayedReady!: Promise<void>;\n _resolveDelayedReady!: () => void;\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this._delayedReady = new Promise(\n (res) => (this._resolveDelayedReady = res)\n );\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this._delayedReady;\n return complete;\n }\n\n public handleSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (target.assignedElements({ flatten: true }).length) {\n requestAnimationFrame(() => {\n this._resolveDelayedReady();\n });\n }\n }\n}\n\n@customElement('icons-demo')\nexport class IconsDemo extends SpectrumElement {\n @property()\n public name = 'ui';\n\n @property()\n public package = '';\n\n @property()\n public size = 'm';\n\n @property()\n public search = '';\n\n @property({ attribute: false })\n public icons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private unsubscribeSystemContext: (() => void) | null = null;\n\n @state()\n public spectrumVersion = 1;\n\n private iconset: string[] = [];\n public constructor() {\n super();\n this.iconset = [];\n this.handleIconSetAdded = this.handleIconSetAdded.bind(this);\n }\n\n public override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.requestSystemContext();\n window.addEventListener('sp-iconset-added', this.handleIconSetAdded);\n }\n public override disconnectedCallback(): void {\n window.removeEventListener('sp-iconset-added', this.handleIconSetAdded);\n super.disconnectedCallback();\n if (this.unsubscribeSystemContext) {\n this.unsubscribeSystemContext();\n this.unsubscribeSystemContext = null;\n }\n }\n\n private requestSystemContext(): void {\n this.dispatchEvent(\n new CustomEvent('sp-system-context', {\n detail: {\n callback: (\n system: SystemVariant,\n unsubscribe: () => void\n ) => {\n this.spectrumVersion =\n system === 'spectrum-two' ? 2 : 1;\n this.unsubscribeSystemContext = unsubscribe;\n },\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n private systemResolver = new SystemResolutionController(this);\n\n protected override update(changes: PropertyValues): void {\n if (changes.has(systemResolverUpdatedSymbol)) {\n this.spectrumVersion =\n this.systemResolver.system === 'spectrum-two' ? 2 : 1;\n }\n\n super.update(changes);\n }\n\n public handleIconSetAdded(event: CustomEvent<IconsetAddedDetail>): void {\n const { iconset } = event.detail;\n this.iconset = iconset.getIconList();\n this.requestUpdate();\n }\n public static override get styles(): CSSResultGroup {\n return [\n ...bodyStyles,\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 20px;\n align-items: flex-start;\n }\n .icon {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n border-radius: var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n );\n }\n :host([package]) .icon {\n cursor: pointer;\n }\n sp-icon {\n margin-bottom: 10px;\n }\n .search {\n grid-column-start: 1;\n grid-column-end: -1;\n }\n .icon[tabindex]:focus {\n outline: none;\n }\n .icon[tabindex]:focus-visible {\n outline: var(--spectrum-alias-focus-ring-size) solid\n var(--spectrum-alias-focus-ring-color);\n outline-offset: calc(\n var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n ) * 2\n );\n }\n `,\n ];\n }\n private handleKeydown(event: KeyboardEvent, tag: string): void {\n const { code } = event;\n if (code !== 'Enter' && code !== 'NumpadEnter' && code !== 'Space') {\n return;\n }\n event.preventDefault();\n this.shouldCopy(tag);\n }\n\n private shouldCopy(tag: string): void {\n if (!this.package) return;\n const conditionedTag = tag.slice(1, tag.length - 1);\n const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;\n this.dispatchEvent(\n new CustomEvent('copy-text', {\n bubbles: true,\n composed: true,\n detail: {\n message: 'Import statement copied to clipboard!',\n text: importURL,\n },\n })\n );\n }\n private updateSearch(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.search = event.target.value;\n }\n private submit(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.updateSearch(event);\n }\n private renderSearch(): TemplateResult {\n let matchingIcons = this.search\n ? this.icons.filter((icon) =>\n icon.name.toLowerCase().includes(this.search.toLowerCase())\n )\n : this.icons;\n\n const iconVersion = this.spectrumVersion === 2 ? 's2' : 's1';\n // Filter out icons that are not in the current version for workflow icons\n if (this.name === 'workflow') {\n matchingIcons = matchingIcons.filter((icon) => {\n const iconName = icon.name.replace(/\\s/g, '').toLowerCase();\n return iconsList[iconVersion].includes(iconName);\n });\n }\n\n return html`\n <div class=\"search\" part=\"search\">\n <sp-field-label for=\"search\">Spectrum icons:</sp-field-label>\n <sp-search\n id=\"search\"\n @keydown=${this.updateSearch}\n @input=${this.updateSearch}\n @submit=${this.submit}\n .value=${this.search}\n label=\"Search for icons\"\n autocomplete=\"off\"\n >\n <sp-help-text slot=\"help-text\">\n Showing ${matchingIcons.length} of ${this.icons.length}\n available icons.\n </sp-help-text>\n </sp-search>\n </div>\n ${matchingIcons.map((icon) => {\n return html`\n <bdo\n class=\"icon\"\n part=\"icon\"\n dir=\"ltr\"\n class=\"icon\"\n @click=${() => this.shouldCopy(icon.tag)}\n @keydown=${(event: KeyboardEvent) =>\n this.handleKeydown(event, icon.tag)}\n tabindex=${ifDefined(this.package ? '0' : undefined)}\n >\n ${icon.story(this.size)} ${icon.tag}\n </bdo>\n `;\n })}\n `;\n }\n protected override render(): TemplateResult {\n return html`\n ${this.icons.length\n ? this.renderSearch()\n : html`\n <slot></slot>\n `}\n ${this.iconset.map(\n (icon) => html`\n <bdo class=\"icon\" dir=\"ltr\">\n <sp-icon\n size=\"xl\"\n name=${`${this.name}:${icon}`}\n ></sp-icon>\n ${icon}\n </bdo>\n `\n )}\n `;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AACP,OAAO,gBAAgB;AACvB,OAAO;AACP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,GAAG,CAAC;AAAA,mCAC7B,CAAC,UACR,KAAK,cAAc,OAAO,KAAK,GAAG,CAAC;AAAA,mCAC5B,UAAU,KAAK,UAAU,MAAM,MAAS,CAAC;AAAA;AAAA,0BAElD,KAAK,MAAM,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG;AAAA;AAAA;AAAA,IAG/C,CAAC,CAAC;AAAA;AAAA,EAEV;AAAA,EACmB,SAAyB;AACxC,WAAO;AAAA,cACD,KAAK,MAAM,SACP,KAAK,aAAa,IAClB;AAAA;AAAA,mBAEC;AAAA,cACL,KAAK,QAAQ;AAAA,MACX,CAAC,SAAS;AAAA;AAAA;AAAA;AAAA,mCAIS,GAAG,KAAK,IAAI,IAAI,IAAI,EAAE;AAAA;AAAA,0BAE/B,IAAI;AAAA;AAAA;AAAA,IAGlB,CAAC;AAAA;AAAA,EAET;AACJ;AApOW;AAAA,EADN,SAAS;AAAA,GADD,UAEF;AAGA;AAAA,EADN,SAAS;AAAA,GAJD,UAKF;AAGA;AAAA,EADN,SAAS;AAAA,GAPD,UAQF;AAGA;AAAA,EADN,SAAS;AAAA,GAVD,UAWF;AAGA;AAAA,EADN,SAAS,EAAE,WAAW,MAAM,CAAC;AAAA,GAbrB,UAcF;AASA;AAAA,EADN,MAAM;AAAA,GAtBE,UAuBF;AAvBE,YAAN;AAAA,EADN,cAAc,YAAY;AAAA,GACd;",
4
+ "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*/\nimport { IconsetAddedDetail } from '@spectrum-web-components/iconset';\nimport {\n css,\n CSSResultGroup,\n html,\n PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n customElement,\n property,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Search } from '@spectrum-web-components/search';\nimport '@spectrum-web-components/search/sp-search.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport bodyStyles from '@spectrum-web-components/styles/body.js';\nimport '@spectrum-web-components/icon/sp-icon.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\n\nimport iconsList from './iconsList.json' assert { type: 'json' };\n\nimport {\n SystemResolutionController,\n systemResolverUpdatedSymbol,\n} from '@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js';\n\n@customElement('delayed-ready')\nexport class DelayedReady extends SpectrumElement {\n _delayedReady!: Promise<void>;\n _resolveDelayedReady!: () => void;\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this._delayedReady = new Promise(\n (res) => (this._resolveDelayedReady = res)\n );\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this._delayedReady;\n return complete;\n }\n\n public handleSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (target.assignedElements({ flatten: true }).length) {\n requestAnimationFrame(() => {\n this._resolveDelayedReady();\n });\n }\n }\n}\n\n@customElement('icons-demo')\nexport class IconsDemo extends SpectrumElement {\n @property()\n public name = 'ui';\n\n @property()\n public package = '';\n\n @property()\n public size = 'm';\n\n @property()\n public search = '';\n\n @property({ attribute: false })\n public icons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private filteredIcons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private unsubscribeSystemContext: (() => void) | null = null;\n\n @state()\n public spectrumVersion = 1;\n\n private iconset: string[] = [];\n public constructor() {\n super();\n this.iconset = [];\n this.handleIconSetAdded = this.handleIconSetAdded.bind(this);\n }\n\n public override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n window.addEventListener('sp-iconset-added', this.handleIconSetAdded);\n }\n public override disconnectedCallback(): void {\n window.removeEventListener('sp-iconset-added', this.handleIconSetAdded);\n super.disconnectedCallback();\n if (this.unsubscribeSystemContext) {\n this.unsubscribeSystemContext();\n this.unsubscribeSystemContext = null;\n }\n }\n\n private filterIconsBySpectrumVersion(): void {\n const iconVersion = this.spectrumVersion === 2 ? 's2' : 's1';\n let filteredIcons = this.icons;\n // Filter out icons that are not in the current version for workflow icons\n if (this.name === 'workflow') {\n filteredIcons = filteredIcons.filter((icon) => {\n const iconName = icon.name.replace(/\\s/g, '').toLowerCase();\n return iconsList[iconVersion].includes(iconName);\n });\n }\n\n // Use a Set to remove duplicates that may get added because of the same icon name in both versions\n const iconSet = new Set();\n filteredIcons = filteredIcons.filter((icon) => {\n if (iconSet.has(icon.name)) {\n return false;\n }\n iconSet.add(icon.name);\n return true;\n });\n\n this.filteredIcons = filteredIcons;\n }\n\n private systemResolver = new SystemResolutionController(this);\n\n protected override update(changes: PropertyValues): void {\n if (changes.has(systemResolverUpdatedSymbol)) {\n this.spectrumVersion =\n this.systemResolver.system === 'spectrum-two' ? 2 : 1;\n this.filterIconsBySpectrumVersion();\n }\n\n if (changes.has('icons')) {\n this.filterIconsBySpectrumVersion();\n }\n\n super.update(changes);\n }\n\n public handleIconSetAdded(event: CustomEvent<IconsetAddedDetail>): void {\n const { iconset } = event.detail;\n this.iconset = iconset.getIconList();\n this.requestUpdate();\n }\n public static override get styles(): CSSResultGroup {\n return [\n ...bodyStyles,\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 20px;\n align-items: flex-start;\n }\n .icon {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n border-radius: var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n );\n }\n :host([package]) .icon {\n cursor: pointer;\n }\n sp-icon {\n margin-bottom: 10px;\n }\n .search {\n grid-column-start: 1;\n grid-column-end: -1;\n }\n .icon[tabindex]:focus {\n outline: none;\n }\n .icon[tabindex]:focus-visible {\n outline: var(--spectrum-alias-focus-ring-size) solid\n var(--spectrum-alias-focus-ring-color);\n outline-offset: calc(\n var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n ) * 2\n );\n }\n `,\n ];\n }\n private handleKeydown(event: KeyboardEvent, tag: string): void {\n const { code } = event;\n if (code !== 'Enter' && code !== 'NumpadEnter' && code !== 'Space') {\n return;\n }\n event.preventDefault();\n this.shouldCopy(tag);\n }\n\n private shouldCopy(tag: string): void {\n if (!this.package) return;\n const conditionedTag = tag.slice(1, tag.length - 1);\n const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;\n this.dispatchEvent(\n new CustomEvent('copy-text', {\n bubbles: true,\n composed: true,\n detail: {\n message: 'Import statement copied to clipboard!',\n text: importURL,\n },\n })\n );\n }\n private updateSearch(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.search = event.target.value;\n }\n private submit(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.updateSearch(event);\n }\n private renderSearch(): TemplateResult {\n const matchingIcons = this.search\n ? this.filteredIcons.filter((icon) =>\n icon.name.toLowerCase().includes(this.search.toLowerCase())\n )\n : this.filteredIcons;\n\n return html`\n <div class=\"search\" part=\"search\">\n <sp-field-label for=\"search\">Spectrum icons:</sp-field-label>\n <sp-search\n id=\"search\"\n @keydown=${this.updateSearch}\n @input=${this.updateSearch}\n @submit=${this.submit}\n .value=${this.search}\n label=\"Search for icons\"\n autocomplete=\"off\"\n >\n <sp-help-text slot=\"help-text\">\n Showing ${matchingIcons.length} of\n ${this.filteredIcons.length} available icons.\n </sp-help-text>\n </sp-search>\n </div>\n ${matchingIcons.map((icon) => {\n return html`\n <bdo\n class=\"icon\"\n part=\"icon\"\n dir=\"ltr\"\n class=\"icon\"\n @click=${() => this.shouldCopy(icon.tag)}\n @keydown=${(event: KeyboardEvent) =>\n this.handleKeydown(event, icon.tag)}\n tabindex=${ifDefined(this.package ? '0' : undefined)}\n >\n ${icon.story(this.size)} ${icon.tag}\n </bdo>\n `;\n })}\n `;\n }\n protected override render(): TemplateResult {\n return html`\n ${this.filteredIcons.length\n ? this.renderSearch()\n : html`\n <slot></slot>\n `}\n ${this.iconset.map(\n (icon) => html`\n <bdo class=\"icon\" dir=\"ltr\">\n <sp-icon\n size=\"xl\"\n name=${`${this.name}:${icon}`}\n ></sp-icon>\n ${icon}\n </bdo>\n `\n )}\n `;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AACP,OAAO,gBAAgB;AACvB,OAAO;AACP,OAAO;AAEP,OAAO,eAAe;AAEtB;AAAA,EACI;AAAA,EACA;AAAA,OACG;AAGA,WAAM,eAAN,cAA2B,gBAAgB;AAAA,EAI3B,SAAyB;AACxC,WAAO;AAAA,gCACiB,KAAK,gBAAgB;AAAA;AAAA,EAEjD;AAAA,EAEmB,eAAqB;AACpC,SAAK,gBAAgB,IAAI;AAAA,MACrB,CAAC,QAAS,KAAK,uBAAuB;AAAA,IAC1C;AAAA,EACJ;AAAA,EAEA,MAAyB,oBAAsC;AAC3D,UAAM,WAAY,MAAM,MAAM,kBAAkB;AAChD,UAAM,KAAK;AACX,WAAO;AAAA,EACX;AAAA,EAEO,iBAAiB;AAAA,IACpB;AAAA,EACJ,GAA8C;AAC1C,QAAI,OAAO,iBAAiB,EAAE,SAAS,KAAK,CAAC,EAAE,QAAQ;AACnD,4BAAsB,MAAM;AACxB,aAAK,qBAAqB;AAAA,MAC9B,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;AA/Ba,eAAN;AAAA,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