@dile/iconlib 1.3.1 → 1.3.2

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.
@@ -0,0 +1,3 @@
1
+ import { DileIconlib } from "./src/DileIconlib.js";
2
+
3
+ customElements.define('dile-iconlib', DileIconlib);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/iconlib",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Icon Component Library based on popular libraries",
5
5
  "keywords": [
6
6
  "UI",
@@ -25,5 +25,5 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
- "gitHead": "e123ebdc49cb479a03e4b5689ddc6fbfb4ab39b1"
28
+ "gitHead": "b0bd29089239ea51db02bce9486c36bb2a4e84d7"
29
29
  }
@@ -1,4 +1,4 @@
1
- import { lucideIconStyles as iconStyles } from "./lucideIconStyles.js";
1
+ import { iconStyles } from "./iconStyles.js";
2
2
 
3
3
  export class DileBaseIcon extends HTMLElement {
4
4
  constructor() {
@@ -1,38 +1,8 @@
1
- import { iconStylesNamedIcons } from "../src/lucideIconStyles.js";
2
1
  import '../fontawesome-icons/dot-circle.js';
2
+ import { DileIconWrapperBase } from "./DileIconWrapperBase.js";
3
3
 
4
- export class DileFontawesomeIcon extends HTMLElement {
4
+ export class DileFontawesomeIcon extends DileIconWrapperBase {
5
5
  constructor() {
6
- super();
7
- this.attachShadow({ mode: 'open' });
8
- this.shadowRoot.adoptedStyleSheets = [iconStylesNamedIcons];
9
- this.icon = "dot-circle";
10
- this.rounded = false;
11
- this.render();
12
-
13
- }
14
-
15
- render() {
16
- this.shadowRoot.innerHTML = `
17
- <dile-fontawesome-icon-${this.icon} ${this.rounded ? 'rounded': ''} class="flex"></dile-fontawesome-icon-${this.icon}>
18
- `;
19
- }
20
-
21
- static get observedAttributes() {
22
- return ['icon', 'rounded'];
23
- }
24
-
25
- attributeChangedCallback(name, oldValue, newValue) {
26
- if (name === 'icon' && newValue !== null) {
27
- this.icon = newValue;
28
- this.render();
29
- }
30
- if (name === 'rounded' && newValue !== null) {
31
- this.rounded = true;
32
- this.render();
33
- } else {
34
- this.rounded = false;
35
- this.render();
36
- }
6
+ super('dot-circle', 'fontawesome');
37
7
  }
38
8
  }
@@ -0,0 +1,39 @@
1
+ import { iconStylesNamedIcons } from "./iconStyles.js";
2
+
3
+ export class DileIconWrapperBase extends HTMLElement {
4
+ constructor(defaultIcon = '', family = null) {
5
+ super();
6
+ this.attachShadow({ mode: 'open' });
7
+ this.shadowRoot.adoptedStyleSheets = [iconStylesNamedIcons];
8
+ this.icon = defaultIcon;
9
+ this.family = family;
10
+ this.rounded = false;
11
+ this.render();
12
+ }
13
+
14
+ getTagName() {
15
+ return this.icon ? `dile-${this.family}-icon-${this.icon}` : null;
16
+ }
17
+
18
+ render() {
19
+ const tag = this.getTagName();
20
+ this.shadowRoot.innerHTML = tag
21
+ ? `<${tag} ${this.rounded ? 'rounded' : ''} class="flex"></${tag}>`
22
+ : '';
23
+ }
24
+
25
+ static get observedAttributes() {
26
+ return ['icon', 'rounded'];
27
+ }
28
+
29
+ attributeChangedCallback(name, oldValue, newValue) {
30
+ if (name === 'icon' && newValue !== null) {
31
+ this.icon = newValue;
32
+ this.render();
33
+ }
34
+ if (name === 'rounded') {
35
+ this.rounded = newValue !== null;
36
+ this.render();
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,26 @@
1
+ import '../lucide-icons/dot.js';
2
+ import { DileIconWrapperBase } from "./DileIconWrapperBase.js";
3
+
4
+ const KNOWN_FAMILIES = ['lucide', 'material', 'fontawesome'];
5
+
6
+ export class DileIconlib extends DileIconWrapperBase {
7
+ constructor() {
8
+ super('lucide.dot'); // único default (no uno por familia); ya viene en formato "familia.nombre"
9
+ }
10
+
11
+ getTagName() {
12
+ if (!this.icon) return null;
13
+ const dotIndex = this.icon.indexOf('.');
14
+ if (dotIndex === -1) {
15
+ console.warn(`dile-iconlib: icon="${this.icon}" no tiene el formato "familia.nombre", ej. "lucide.home".`);
16
+ return null;
17
+ }
18
+ const family = this.icon.slice(0, dotIndex);
19
+ const name = this.icon.slice(dotIndex + 1);
20
+ if (!name) return null;
21
+ if (!KNOWN_FAMILIES.includes(family)) {
22
+ console.warn(`dile-iconlib: familia desconocida "${family}". Esperado: ${KNOWN_FAMILIES.join(', ')}.`);
23
+ }
24
+ return `dile-${family}-icon-${name}`;
25
+ }
26
+ }
@@ -1,35 +1,8 @@
1
- import { iconStylesNamedIcons } from "./lucideIconStyles.js";
2
1
  import '../lucide-icons/dot.js';
2
+ import { DileIconWrapperBase } from "./DileIconWrapperBase.js";
3
3
 
4
- export class DileLucideIcon extends HTMLElement {
4
+ export class DileLucideIcon extends DileIconWrapperBase {
5
5
  constructor() {
6
- super();
7
- this.attachShadow({ mode: 'open' });
8
- this.shadowRoot.adoptedStyleSheets = [iconStylesNamedIcons];
9
- this.icon = "dot";
10
- this.rounded = false;
11
- this.render();
12
-
13
- }
14
-
15
- render() {
16
- this.shadowRoot.innerHTML = `
17
- <dile-lucide-icon-${this.icon} ${this.rounded ? 'rounded': ''} class="flex"></dile-lucide-icon-${this.icon}>
18
- `;
19
- }
20
-
21
- static get observedAttributes() {
22
- return ['icon', 'rounded'];
23
- }
24
-
25
- attributeChangedCallback(name, oldValue, newValue) {
26
- if (name === 'icon' && newValue !== null) {
27
- this.icon = newValue;
28
- this.render();
29
- }
30
- if (name === 'rounded') {
31
- this.rounded = newValue !== null;
32
- this.render();
33
- }
6
+ super('dot', 'lucide');
34
7
  }
35
- }
8
+ }
@@ -1,38 +1,8 @@
1
- import { iconStylesNamedIcons } from "./lucideIconStyles.js";
2
1
  import '../material/home.js';
2
+ import { DileIconWrapperBase } from "./DileIconWrapperBase.js";
3
3
 
4
- export class DileMaterialIcon extends HTMLElement {
4
+ export class DileMaterialIcon extends DileIconWrapperBase {
5
5
  constructor() {
6
- super();
7
- this.attachShadow({ mode: 'open' });
8
- this.shadowRoot.adoptedStyleSheets = [iconStylesNamedIcons];
9
- this.icon = "home";
10
- this.rounded = false;
11
- this.render();
12
-
13
- }
14
-
15
- render() {
16
- this.shadowRoot.innerHTML = `
17
- <dile-material-icon-${this.icon} ${this.rounded ? 'rounded': ''} class="flex"></dile-material-icon-${this.icon}>
18
- `;
19
- }
20
-
21
- static get observedAttributes() {
22
- return ['icon', 'rounded'];
23
- }
24
-
25
- attributeChangedCallback(name, oldValue, newValue) {
26
- if (name === 'icon' && newValue !== null) {
27
- this.icon = newValue;
28
- this.render();
29
- }
30
- if (name === 'rounded' && newValue !== null) {
31
- this.rounded = true;
32
- this.render();
33
- } else {
34
- this.rounded = false;
35
- this.render();
36
- }
6
+ super('circle', 'material');
37
7
  }
38
8
  }
@@ -1,5 +1,5 @@
1
- export const lucideIconStyles = new CSSStyleSheet();
2
- lucideIconStyles.replaceSync(`
1
+ export const iconStyles = new CSSStyleSheet();
2
+ iconStyles.replaceSync(`
3
3
  :host {
4
4
  display: inline-block;
5
5
  transition-duration: var(--dile-icon-transition-duration, 0.3s);