@ac-components/ac-icon-basic 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Renzo Cordova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @ac-components/ac-icon-basic
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Componente fundacional del lote de 5 componentes básicos nuevos: renderiza **un** ícono de un set propio y pequeño del catálogo, por nombre — sin slots, sin eventos. Lo consume `ac-icon-button-basic` como dependencia interna, así que su API pública (`name`/`size`/`a11y-label`) se mantiene estable.
4
+
5
+ ## Instalación
6
+
7
+ ```bash
8
+ pnpm add @ac-components/ac-icon-basic
9
+ ```
10
+
11
+ ```js
12
+ import '@ac-components/ac-icon-basic';
13
+ ```
14
+
15
+ ```html
16
+ <ac-icon-basic name="check"></ac-icon-basic>
17
+ ```
18
+
19
+ ## Propiedades
20
+
21
+ | Propiedad | Atributo | Tipo | Default | Descripción |
22
+ | ----------- | ------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | `name` | `name` | String | `''` | Nombre del ícono (ver whitelist abajo). Un `name` que no matchea ninguno cae a un fallback genérico (un círculo simple) — nunca rompe. |
24
+ | `size` | `size` | String | `'md'` | `sm` (16px) \| `md` (20px) \| `lg` (24px), con validación por whitelist y fallback a `'md'` si no matchea — mismo patrón que `ac-spinner-basic`. |
25
+ | `a11yLabel` | `a11y-label` | String | `''` | Si se define (texto o clave de traducción, pasa por `this.t()`), el ícono deja de ser decorativo: `role="img"` + `aria-label`. Vacío (default) ⇒ `aria-hidden="true"`. |
26
+
27
+ Sin eventos. Sin `ambient` — el color del ícono es siempre `currentColor`, heredado del elemento padre (mismo criterio que los íconos inline de `ac-notification-basic`).
28
+
29
+ ## Set de íconos
30
+
31
+ Whitelist fija de esta primera versión (`viewBox="0 0 24 24"`, `fill="none"`, `stroke="currentColor"`):
32
+
33
+ `check`, `close`, `info`, `success`, `warning`, `danger`, `chevron-down`, `chevron-up`, `chevron-left`, `chevron-right`, `search`, `menu`, `arrow-left`, `arrow-right`.
34
+
35
+ > `info`/`success`/`warning`/`danger` son deliberadamente idénticos a los paths ya usados en `ICON_MAP` de `ac-notification-basic` — misma identidad visual, no una reinterpretación.
36
+
37
+ Un `name` fuera de esta lista (incluido `''`) renderiza el fallback: un círculo simple (`<circle cx="12" cy="12" r="9"/>`), nunca un ícono vacío o roto.
38
+
39
+ ## i18n
40
+
41
+ No tiene ningún texto propio fijo — todo es visual, y `a11yLabel` es un valor que define el consumidor (texto literal o clave de traducción de su propia app). `locales.json` no declara ninguna clave propia.
42
+
43
+ ## Desarrollo
44
+
45
+ ```bash
46
+ pnpm --filter @ac-components/ac-icon-basic component:lint
47
+ pnpm --filter @ac-components/ac-icon-basic component:serve # demo en http://localhost:5173
48
+ pnpm --filter @ac-components/ac-icon-basic component:test
49
+ pnpm --filter @ac-components/ac-icon-basic component:build
50
+ pnpm --filter @ac-components/ac-icon-basic component:test:e2e # funcional (WebdriverIO + Cucumber)
51
+ pnpm --filter @ac-components/ac-icon-basic component:test:e2e:a11y # accesibilidad (axe-core)
52
+ ```
53
+
54
+ > `src/icon-basic.styles.js` se genera a partir de `src/icon-basic.styles.scss` (`component:build:styles`, corre automáticamente antes de `component:serve`/`component:build`/`component:test`) y no se versiona en git. Durante `component:serve` queda además en modo watch: cada guardado de `.scss` lo recompila y Vite recarga el navegador solo, sin reiniciar nada.
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import locales from './locales.json' with { type: 'json' };
2
+ import { registerTranslations } from '@ac-base/ac-intl-mixin';
3
+ import { IconBasic } from './src/icon-basic.js';
4
+
5
+ export { IconBasic } from './src/icon-basic.js';
6
+
7
+ registerTranslations(IconBasic.is, locales);
8
+
9
+ // Auto-registro del componente
10
+ customElements.define(IconBasic.is, IconBasic);
package/locales.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "es-PE": {},
3
+ "en-EN": {},
4
+ "pt-BR": {}
5
+ }
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@ac-components/ac-icon-basic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/RenzoCordovaDev/ac-lit.git",
7
+ "directory": "packages/components/ac-icon-basic"
8
+ },
9
+ "description": "ac-lit basic icon Web Component",
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "main": "index.js",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./locales.json": "./locales.json"
16
+ },
17
+ "files": [
18
+ "/src/",
19
+ "index.js",
20
+ "locales.json"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@ac-base/ac-component-mixin": "^0.1.0",
27
+ "@ac-base/ac-intl-mixin": "^0.1.0"
28
+ },
29
+ "peerDependencies": {
30
+ "lit": "^3.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@ac-base/ac-core": "^0.1.0",
34
+ "@ac-base/ac-demo-content": "^0.1.1",
35
+ "@ac-base/ac-e2e-testing": "^0.1.0",
36
+ "@ac-base/cli": "^0.2.1",
37
+ "@open-wc/testing": "^4.0.0",
38
+ "@web/test-runner": "^0.18.0",
39
+ "concurrently": "^9.1.0",
40
+ "lit": "^3.0.0",
41
+ "sass": "^1.79.4",
42
+ "vite": "^5.4.8"
43
+ },
44
+ "scripts": {
45
+ "component:lint": "eslint .",
46
+ "component:build:styles": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/icon-basic.styles.scss src/icon-basic.styles.js IconBasicStyles",
47
+ "component:build:styles:watch": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/icon-basic.styles.scss src/icon-basic.styles.js IconBasicStyles --watch",
48
+ "component:serve": "pnpm run component:build:styles && concurrently -k -n styles,vite -c blue,green \"pnpm run component:build:styles:watch\" \"vite demo\"",
49
+ "component:build": "pnpm run component:build:styles && vite build",
50
+ "component:preview": "vite preview",
51
+ "component:test": "pnpm run component:build:styles && web-test-runner \"test/**/*.test.js\"",
52
+ "component:test:e2e": "pnpm run component:build && start-server-and-test component:preview http://localhost:4173 component:test:e2e:run",
53
+ "component:test:e2e:run": "wdio run test_e2e/wdio.conf.js",
54
+ "component:test:e2e:a11y": "pnpm run component:build && start-server-and-test component:preview http://localhost:4173 component:test:e2e:a11y:run",
55
+ "component:test:e2e:a11y:run": "wdio run test_e2e/wdio.a11y.conf.js"
56
+ }
6
57
  }
@@ -0,0 +1,107 @@
1
+ import { LitElement, html, svg, nothing } from 'lit';
2
+ import { ComponentMixin, componentBaseStyles } from '@ac-base/ac-component-mixin';
3
+ // Authored in icon-basic.styles.scss, compiled to icon-basic.styles.js by
4
+ // `pnpm run component:build:styles` (@ac-base/cli/scripts/compile-scss-to-lit.cjs). The compiled file
5
+ // is gitignored — run `pnpm install` then `pnpm component:build` or `pnpm component:serve` to generate it.
6
+ import { IconBasicStyles } from './icon-basic.styles.js';
7
+
8
+ const SIZES = new Set(['sm', 'md', 'lg']);
9
+ const DEFAULT_SIZE = 'md';
10
+
11
+ // Set de íconos propio, mínimo, para el catálogo — mismo estilo visual que
12
+ // los íconos inline de ac-notification-basic (ver ICON_MAP/CLOSE_ICON en
13
+ // notification-basic.js): viewBox 24x24, fill none, stroke currentColor
14
+ // (heredado del `<svg>`, no de cada path/circle). `info`/`success`/`warning`/
15
+ // `danger` son deliberadamente idénticos a los de ac-notification-basic (ver
16
+ // docs/CONVENTIONS.md) para mantener consistencia visual exacta, no una
17
+ // reinterpretación.
18
+ //
19
+ // Importante: estos fragmentos van con la función `svg` de lit, NO `html`.
20
+ // Son `<path>`/`<circle>` sueltos, sin su propio `<svg>` envolvente (a
21
+ // diferencia de ICON_MAP/CLOSE_ICON de ac-notification-basic, que sí son un
22
+ // `<svg>` completo cada uno) -- con `html`, lit-html parsea el fragmento en
23
+ // un namespace HTML (nunca ven un `<svg>` ancestro en su propio template),
24
+ // así que el `<path>`/`<circle>` resultante queda en el namespace HTML
25
+ // (`http://www.w3.org/1999/xhtml`), no el de SVG, y el navegador no lo pinta
26
+ // aunque todos sus atributos estén bien -- aunque se inserte después como
27
+ // hijo de un `<svg>` real, los elementos no se re-asignan de namespace al
28
+ // moverse en el DOM. `svg` le dice a lit-html que clone el fragmento con el
29
+ // wrapper de namespace SVG correcto.
30
+ const ICON_MAP = {
31
+ check: svg`<path d="M5 13l4 4L19 7" />`,
32
+ close: svg`<path d="M6 6l12 12M18 6L6 18" />`,
33
+ info: svg`<circle cx="12" cy="12" r="9" /><path d="M12 11v5M12 8v.01" />`,
34
+ success: svg`<circle cx="12" cy="12" r="9" /><path d="M8 12.5l2.5 2.5L16 9.5" />`,
35
+ warning: svg`<path d="M12 4.5l9 15.5H3l9-15.5z" /><path d="M12 10.5v3.5M12 17v.01" />`,
36
+ danger: svg`<circle cx="12" cy="12" r="9" /><path d="M12 7.5v5.5M12 16v.01" />`,
37
+ 'chevron-down': svg`<path d="M6 9l6 6 6-6" />`,
38
+ 'chevron-up': svg`<path d="M6 15l6-6 6 6" />`,
39
+ 'chevron-left': svg`<path d="M15 6l-6 6 6 6" />`,
40
+ 'chevron-right': svg`<path d="M9 6l6 6-6 6" />`,
41
+ search: svg`<circle cx="11" cy="11" r="7" /><path d="M21 21l-4.3-4.3" />`,
42
+ menu: svg`<path d="M4 6h16M4 12h16M4 18h16" />`,
43
+ 'arrow-left': svg`<path d="M19 12H5M11 18l-6-6 6-6" />`,
44
+ 'arrow-right': svg`<path d="M5 12h14M13 6l6 6-6 6" />`,
45
+ };
46
+
47
+ // Fallback para cualquier `name` fuera de la whitelist de arriba — un círculo
48
+ // simple, el ícono nunca queda vacío/roto.
49
+ const FALLBACK_ICON = svg`<circle cx="12" cy="12" r="9" />`;
50
+
51
+ export class IconBasic extends ComponentMixin(LitElement) {
52
+ static get is() {
53
+ return 'ac-icon-basic';
54
+ }
55
+
56
+ // componentBaseStyles primero: fija `font-family` (aunque acá no haya
57
+ // texto propio, es la convención del catálogo, ver docs/CONVENTIONS.md) y
58
+ // el skeleton de `loading` — no lo quites.
59
+ static get styles() {
60
+ return [componentBaseStyles, IconBasicStyles];
61
+ }
62
+
63
+ static get properties() {
64
+ return {
65
+ name: { type: String },
66
+ size: { type: String, reflect: true },
67
+ a11yLabel: { type: String, attribute: 'a11y-label' },
68
+ };
69
+ }
70
+
71
+ constructor() {
72
+ super();
73
+ this.name = '';
74
+ this.size = DEFAULT_SIZE;
75
+ this.a11yLabel = '';
76
+ }
77
+
78
+ get _size() {
79
+ return SIZES.has(this.size) ? this.size : DEFAULT_SIZE;
80
+ }
81
+
82
+ render() {
83
+ const classes = `ac-icon-basic ac-icon-basic--${this._size}`;
84
+ // Decorativo por defecto (sin `a11yLabel`): aria-hidden, igual criterio
85
+ // que ICON_MAP de ac-notification-basic (el texto ya está al lado). Con
86
+ // `a11yLabel` definido deja de ser decorativo: role="img" + aria-label.
87
+ const label = this.a11yLabel ? this.t(this.a11yLabel) : '';
88
+
89
+ return html`
90
+ <svg
91
+ part="icon"
92
+ class=${classes}
93
+ viewBox="0 0 24 24"
94
+ fill="none"
95
+ stroke="currentColor"
96
+ stroke-width="2"
97
+ stroke-linecap="round"
98
+ stroke-linejoin="round"
99
+ role=${label ? 'img' : nothing}
100
+ aria-label=${label ? label : nothing}
101
+ aria-hidden=${label ? nothing : 'true'}
102
+ >
103
+ ${ICON_MAP[this.name] ?? FALLBACK_ICON}
104
+ </svg>
105
+ `;
106
+ }
107
+ }
@@ -0,0 +1,31 @@
1
+ import { css } from 'lit';
2
+
3
+ export const IconBasicStyles = css`
4
+ :host {
5
+ display: inline-flex;
6
+ }
7
+
8
+ :host([hidden]) {
9
+ display: none;
10
+ }
11
+
12
+ .ac-icon-basic {
13
+ display: block;
14
+ flex-shrink: 0;
15
+ }
16
+
17
+ .ac-icon-basic--sm {
18
+ width: 16px;
19
+ height: 16px;
20
+ }
21
+
22
+ .ac-icon-basic--md {
23
+ width: 20px;
24
+ height: 20px;
25
+ }
26
+
27
+ .ac-icon-basic--lg {
28
+ width: 24px;
29
+ height: 24px;
30
+ }
31
+ `;
@@ -0,0 +1,30 @@
1
+ :host {
2
+ display: inline-flex;
3
+ }
4
+
5
+ :host([hidden]) {
6
+ display: none;
7
+ }
8
+
9
+ .ac-icon-basic {
10
+ // Todo el color viene de `currentColor` (heredado del elemento padre) —
11
+ // el componente nunca define su propio color ni usa `ambient`, igual
12
+ // criterio que los íconos inline de ac-notification-basic.
13
+ display: block;
14
+ flex-shrink: 0;
15
+ }
16
+
17
+ .ac-icon-basic--sm {
18
+ width: 16px;
19
+ height: 16px;
20
+ }
21
+
22
+ .ac-icon-basic--md {
23
+ width: 20px;
24
+ height: 20px;
25
+ }
26
+
27
+ .ac-icon-basic--lg {
28
+ width: 24px;
29
+ height: 24px;
30
+ }