@ac-components/ac-input-basic 0.1.0 → 0.2.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/README.md +44 -27
- package/locales.json +15 -3
- package/package.json +13 -6
- package/src/input-basic.js +66 -17
- package/src/input-basic.styles.js +30 -0
- package/src/input-basic.styles.scss +30 -0
package/README.md
CHANGED
|
@@ -16,24 +16,26 @@ import '@ac-components/ac-input-basic';
|
|
|
16
16
|
<ac-input-basic label="Nombre" name="name" hint="Como aparece en tu documento."></ac-input-basic>
|
|
17
17
|
<ac-input-basic label="Correo" type="email" error="Ingresa un correo válido."></ac-input-basic>
|
|
18
18
|
<ac-input-basic a11y-label="Buscar" type="search" placeholder="Buscar..."></ac-input-basic>
|
|
19
|
+
<ac-input-basic label="Monto" type="amount" name="amount"></ac-input-basic>
|
|
20
|
+
<ac-input-basic label="Fecha" type="date" name="birth-date"></ac-input-basic>
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
## Propiedades
|
|
22
24
|
|
|
23
|
-
| Propiedad | Atributo | Tipo | Default | Descripción
|
|
24
|
-
| ------------- | ------------- | ------- | ----------- |
|
|
25
|
-
| `label` | `label` | String | `''` | Etiqueta visible. Se pasa por `this.t()`: si es una clave de `locales.json` se traduce, si no se muestra tal cual.
|
|
26
|
-
| `a11yLabel` | `a11y-label` | String | `''` | Nombre accesible cuando **no** hay etiqueta visible (ej. un buscador). Se ignora si hay `label`.
|
|
27
|
-
| `value` | `value` | String | `''` | Valor del campo.
|
|
28
|
-
| `type` | `type` | String | `'text'` | `text`, `email`, `password`, `search`, `tel`, `url` o `number
|
|
29
|
-
| `name` | `name` | String | `''` | Nombre del campo.
|
|
30
|
-
| `placeholder` | `placeholder` | String | `''` | Texto de ejemplo (también pasa por `this.t()`).
|
|
31
|
-
| `hint` | `hint` | String | `''` | Texto de ayuda bajo el campo (también pasa por `this.t()`).
|
|
32
|
-
| `error` | `error` | String | `''` | Mensaje de error. Reemplaza a `hint`, marca el campo con `aria-invalid="true"` y se anuncia con `role="alert"`.
|
|
33
|
-
| `disabled` | `disabled` | Boolean | `false` | Deshabilita el campo.
|
|
34
|
-
| `readonly` | `readonly` | Boolean | `false` | Campo de solo lectura (borde punteado).
|
|
35
|
-
| `required` | `required` | Boolean | `false` | Campo obligatorio; muestra un asterisco decorativo junto a la etiqueta.
|
|
36
|
-
| `ambient` | `ambient` | String | `'primary'` | Color del foco: `primary` o `secondary`. Heredado de `ComponentMixin`.
|
|
25
|
+
| Propiedad | Atributo | Tipo | Default | Descripción |
|
|
26
|
+
| ------------- | ------------- | ------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
27
|
+
| `label` | `label` | String | `''` | Etiqueta visible. Se pasa por `this.t()`: si es una clave de `locales.json` se traduce, si no se muestra tal cual. |
|
|
28
|
+
| `a11yLabel` | `a11y-label` | String | `''` | Nombre accesible cuando **no** hay etiqueta visible (ej. un buscador). Se ignora si hay `label`. |
|
|
29
|
+
| `value` | `value` | String | `''` | Valor del campo. |
|
|
30
|
+
| `type` | `type` | String | `'text'` | Controla el `type` **nativo** del `<input>`: `text`, `email`, `password`, `search`, `tel`, `url` o `number`; cualquier otro valor cae a `text` (lista blanca) — `password`, `search`, `tel` y `url` siguen funcionando exactamente igual que antes, sin ícono. Además, de forma puramente visual y sobre el mismo valor crudo de `type` (capa separada de la lista blanca anterior), `email` y `number` muestran un ícono a la izquierda y un placeholder sugerido automático, y `amount`/`date` hacen lo mismo aunque no sean tipos nativos válidos (el `<input>` real sigue cayendo a `text` para esos dos). Ver "Tipos semánticos (ícono + placeholder)" abajo. |
|
|
31
|
+
| `name` | `name` | String | `''` | Nombre del campo. |
|
|
32
|
+
| `placeholder` | `placeholder` | String | `''` | Texto de ejemplo (también pasa por `this.t()`). Si no se define y `type` tiene un placeholder sugerido (ver abajo), se usa ese; `placeholder` del consumidor siempre tiene prioridad. |
|
|
33
|
+
| `hint` | `hint` | String | `''` | Texto de ayuda bajo el campo (también pasa por `this.t()`). |
|
|
34
|
+
| `error` | `error` | String | `''` | Mensaje de error. Reemplaza a `hint`, marca el campo con `aria-invalid="true"` y se anuncia con `role="alert"`. |
|
|
35
|
+
| `disabled` | `disabled` | Boolean | `false` | Deshabilita el campo. |
|
|
36
|
+
| `readonly` | `readonly` | Boolean | `false` | Campo de solo lectura (borde punteado). |
|
|
37
|
+
| `required` | `required` | Boolean | `false` | Campo obligatorio; muestra un asterisco decorativo junto a la etiqueta. |
|
|
38
|
+
| `ambient` | `ambient` | String | `'primary'` | Color del foco: `primary` o `secondary`. Heredado de `ComponentMixin`. |
|
|
37
39
|
|
|
38
40
|
El método `focus()` lleva el foco al campo interno.
|
|
39
41
|
|
|
@@ -46,15 +48,29 @@ El método `focus()` lleva el foco al campo interno.
|
|
|
46
48
|
|
|
47
49
|
`bubbles` y `composed`.
|
|
48
50
|
|
|
51
|
+
## Tipos semánticos (ícono + placeholder)
|
|
52
|
+
|
|
53
|
+
Además de controlar el `type` nativo del `<input>`, `type` ahora decide también un ícono (`@ac-components/ac-icon-basic`, part `type-icon`) a la izquierda del campo y un placeholder sugerido (clave de `locales.json`, usado solo si el consumidor no definió su propio `placeholder`):
|
|
54
|
+
|
|
55
|
+
| `type` | Ícono | Placeholder sugerido (`es-PE`) | `type` nativo del `<input>` |
|
|
56
|
+
| -------- | ---------- | ------------------------------ | -------------------------------------------- |
|
|
57
|
+
| `amount` | `currency` | `0.00` | `text` (no es un tipo nativo válido) |
|
|
58
|
+
| `date` | `calendar` | `DD/MM/AAAA` | `text` (no es un tipo nativo válido) |
|
|
59
|
+
| `number` | `hash` | `0` | `number` (comportamiento nativo sin cambios) |
|
|
60
|
+
| `email` | `email` | `nombre@dominio.com` | `email` (comportamiento nativo sin cambios) |
|
|
61
|
+
|
|
62
|
+
`password`, `search`, `tel` y `url` no tienen ícono ni placeholder sugerido — siguen funcionando exactamente igual que antes, con su comportamiento nativo intacto. Sin ícono (incluido `text`, el default), el campo se ve exactamente igual que antes de este cambio.
|
|
63
|
+
|
|
49
64
|
## Parts y CSS
|
|
50
65
|
|
|
51
|
-
| Part
|
|
52
|
-
|
|
|
53
|
-
| `root`
|
|
54
|
-
| `label`
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
66
|
+
| Part | Descripción |
|
|
67
|
+
| ----------- | ------------------------------------------------------------------------ |
|
|
68
|
+
| `root` | Contenedor de todo el campo. |
|
|
69
|
+
| `label` | La etiqueta. |
|
|
70
|
+
| `type-icon` | El ícono a la izquierda, solo con los `type` que lo tienen (ver arriba). |
|
|
71
|
+
| `input` | El `<input>` nativo. |
|
|
72
|
+
| `hint` | El texto de ayuda. |
|
|
73
|
+
| `error` | El mensaje de error. |
|
|
58
74
|
|
|
59
75
|
## Accesibilidad
|
|
60
76
|
|
|
@@ -64,16 +80,17 @@ El método `focus()` lleva el foco al campo interno.
|
|
|
64
80
|
|
|
65
81
|
## i18n
|
|
66
82
|
|
|
67
|
-
`locales.json` incluye claves de ejemplo (`input-basic-email-label`, `-placeholder`, `-hint`, `-error`) en `es-PE`, `en-EN` y `pt-BR`.
|
|
83
|
+
`locales.json` incluye claves de ejemplo (`input-basic-email-label`, `-placeholder`, `-hint`, `-error`) y los 4 placeholders sugeridos por tipo semántico (`input-basic-placeholder-amount`, `-date`, `-number`, `-email`) en `es-PE`, `en-EN` y `pt-BR`.
|
|
68
84
|
|
|
69
85
|
## Desarrollo
|
|
70
86
|
|
|
71
87
|
```bash
|
|
72
|
-
|
|
73
|
-
ac component:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
aclit component:lint
|
|
89
|
+
aclit component:serve # o: pnpm --filter @ac-components/ac-input-basic component:serve — demo en http://localhost:5173
|
|
90
|
+
aclit component:test
|
|
91
|
+
aclit component:build
|
|
92
|
+
aclit component:test:e2e # funcional (WebdriverIO + Cucumber)
|
|
93
|
+
aclit component:test:e2e:a11y # accesibilidad (axe-core)
|
|
77
94
|
```
|
|
78
95
|
|
|
79
96
|
> `src/input-basic.styles.js` se genera a partir de `src/input-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/locales.json
CHANGED
|
@@ -3,18 +3,30 @@
|
|
|
3
3
|
"input-basic-email-label": "Correo electrónico",
|
|
4
4
|
"input-basic-email-placeholder": "nombre@empresa.com",
|
|
5
5
|
"input-basic-email-hint": "Usaremos este correo solo para avisarte.",
|
|
6
|
-
"input-basic-email-error": "Ingresa un correo válido."
|
|
6
|
+
"input-basic-email-error": "Ingresa un correo válido.",
|
|
7
|
+
"input-basic-placeholder-amount": "0.00",
|
|
8
|
+
"input-basic-placeholder-date": "DD/MM/AAAA",
|
|
9
|
+
"input-basic-placeholder-number": "0",
|
|
10
|
+
"input-basic-placeholder-email": "nombre@dominio.com"
|
|
7
11
|
},
|
|
8
12
|
"en-EN": {
|
|
9
13
|
"input-basic-email-label": "Email",
|
|
10
14
|
"input-basic-email-placeholder": "name@company.com",
|
|
11
15
|
"input-basic-email-hint": "We will only use this email to notify you.",
|
|
12
|
-
"input-basic-email-error": "Enter a valid email."
|
|
16
|
+
"input-basic-email-error": "Enter a valid email.",
|
|
17
|
+
"input-basic-placeholder-amount": "0.00",
|
|
18
|
+
"input-basic-placeholder-date": "MM/DD/YYYY",
|
|
19
|
+
"input-basic-placeholder-number": "0",
|
|
20
|
+
"input-basic-placeholder-email": "name@domain.com"
|
|
13
21
|
},
|
|
14
22
|
"pt-BR": {
|
|
15
23
|
"input-basic-email-label": "E-mail",
|
|
16
24
|
"input-basic-email-placeholder": "nome@empresa.com",
|
|
17
25
|
"input-basic-email-hint": "Usaremos este e-mail apenas para avisar você.",
|
|
18
|
-
"input-basic-email-error": "Digite um e-mail válido."
|
|
26
|
+
"input-basic-email-error": "Digite um e-mail válido.",
|
|
27
|
+
"input-basic-placeholder-amount": "0,00",
|
|
28
|
+
"input-basic-placeholder-date": "DD/MM/AAAA",
|
|
29
|
+
"input-basic-placeholder-number": "0",
|
|
30
|
+
"input-basic-placeholder-email": "nome@dominio.com"
|
|
19
31
|
}
|
|
20
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-components/ac-input-basic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/RenzoCordovaDev/ac-lit.git",
|
|
7
|
+
"directory": "packages/components/ac-input-basic"
|
|
8
|
+
},
|
|
4
9
|
"description": "ac-lit text input Web Component",
|
|
5
10
|
"license": "MIT",
|
|
6
11
|
"type": "module",
|
|
@@ -18,6 +23,7 @@
|
|
|
18
23
|
"access": "public"
|
|
19
24
|
},
|
|
20
25
|
"dependencies": {
|
|
26
|
+
"@ac-components/ac-icon-basic": "^0.2.0",
|
|
21
27
|
"@ac-base/ac-component-mixin": "^0.1.0",
|
|
22
28
|
"@ac-base/ac-intl-mixin": "^0.1.0"
|
|
23
29
|
},
|
|
@@ -25,18 +31,19 @@
|
|
|
25
31
|
"lit": "^3.0.0"
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
28
|
-
"@ac-base/ac-core": "^0.1.0",
|
|
29
|
-
"@ac-base/ac-demo-content": "^0.1.0",
|
|
30
|
-
"@ac-base/ac-e2e-testing": "^0.1.0",
|
|
31
|
-
"@ac-base/cli": "^0.1.0",
|
|
32
34
|
"@open-wc/testing": "^4.0.0",
|
|
33
35
|
"@web/test-runner": "^0.18.0",
|
|
34
36
|
"concurrently": "^9.1.0",
|
|
35
37
|
"lit": "^3.0.0",
|
|
36
38
|
"sass": "^1.79.4",
|
|
37
|
-
"vite": "^5.4.8"
|
|
39
|
+
"vite": "^5.4.8",
|
|
40
|
+
"@ac-base/ac-demo-content": "^0.4.0",
|
|
41
|
+
"@ac-base/cli": "^0.5.2",
|
|
42
|
+
"@ac-base/ac-e2e-testing": "^0.1.0",
|
|
43
|
+
"@ac-base/ac-core": "^0.1.0"
|
|
38
44
|
},
|
|
39
45
|
"scripts": {
|
|
46
|
+
"component:lint": "eslint .",
|
|
40
47
|
"component:build:styles": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/input-basic.styles.scss src/input-basic.styles.js InputBasicStyles",
|
|
41
48
|
"component:build:styles:watch": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/input-basic.styles.scss src/input-basic.styles.js InputBasicStyles --watch",
|
|
42
49
|
"component:serve": "pnpm run component:build:styles && concurrently -k -n styles,vite -c blue,green \"pnpm run component:build:styles:watch\" \"vite demo\"",
|
package/src/input-basic.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, nothing } from 'lit';
|
|
2
2
|
import { ComponentMixin, componentBaseStyles } from '@ac-base/ac-component-mixin';
|
|
3
|
+
import '@ac-components/ac-icon-basic';
|
|
3
4
|
// Authored in input-basic.styles.scss, compiled to input-basic.styles.js by
|
|
4
5
|
// `pnpm run component:build:styles` (@ac-base/cli/scripts/compile-scss-to-lit.cjs). The compiled file
|
|
5
6
|
// is gitignored — run `pnpm install` then `pnpm component:build` or `pnpm component:serve` to generate it.
|
|
@@ -7,6 +8,20 @@ import { InputBasicStyles } from './input-basic.styles.js';
|
|
|
7
8
|
|
|
8
9
|
const ALLOWED_TYPES = ['text', 'email', 'password', 'search', 'tel', 'url', 'number'];
|
|
9
10
|
|
|
11
|
+
// Capa puramente visual, separada de `ALLOWED_TYPES`/`_type` (el `type`
|
|
12
|
+
// NATIVO del `<input>`, intocado): lee el mismo valor crudo de `this.type`
|
|
13
|
+
// para decidir un ícono a la izquierda y un placeholder sugerido. `amount` y
|
|
14
|
+
// `date` no son tipos nativos válidos (el `<input>` real sigue cayendo a
|
|
15
|
+
// `text` vía `_type`), pero igual muestran ícono/placeholder; `number` y
|
|
16
|
+
// `email` ya eran tipos nativos válidos y ahora también los muestran.
|
|
17
|
+
const TYPE_ICON = { amount: 'currency', date: 'calendar', number: 'hash', email: 'email' };
|
|
18
|
+
const TYPE_PLACEHOLDER_KEY = {
|
|
19
|
+
amount: 'input-basic-placeholder-amount',
|
|
20
|
+
date: 'input-basic-placeholder-date',
|
|
21
|
+
number: 'input-basic-placeholder-number',
|
|
22
|
+
email: 'input-basic-placeholder-email',
|
|
23
|
+
};
|
|
24
|
+
|
|
10
25
|
export class InputBasic extends ComponentMixin(LitElement) {
|
|
11
26
|
static get is() {
|
|
12
27
|
return 'ac-input-basic';
|
|
@@ -52,6 +67,23 @@ export class InputBasic extends ComponentMixin(LitElement) {
|
|
|
52
67
|
return ALLOWED_TYPES.includes(this.type) ? this.type : 'text';
|
|
53
68
|
}
|
|
54
69
|
|
|
70
|
+
// Ícono sugerido según `type` (valor crudo, sin pasar por `_type`/la lista
|
|
71
|
+
// blanca nativa). `null` cuando el tipo no tiene ícono asociado.
|
|
72
|
+
get _typeIcon() {
|
|
73
|
+
return TYPE_ICON[this.type] ?? null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Si el consumidor seteó su propio `placeholder`, ese siempre gana. Si no,
|
|
77
|
+
// y el `type` tiene un placeholder sugerido, se usa ese (traducido vía
|
|
78
|
+
// `this.t()`, igual que el resto de los textos del componente).
|
|
79
|
+
get _placeholder() {
|
|
80
|
+
if (this.placeholder) {
|
|
81
|
+
return this.t(this.placeholder);
|
|
82
|
+
}
|
|
83
|
+
const key = TYPE_PLACEHOLDER_KEY[this.type];
|
|
84
|
+
return key ? this.t(key) : '';
|
|
85
|
+
}
|
|
86
|
+
|
|
55
87
|
get _message() {
|
|
56
88
|
return this.error || this.hint;
|
|
57
89
|
}
|
|
@@ -64,6 +96,11 @@ export class InputBasic extends ComponentMixin(LitElement) {
|
|
|
64
96
|
render() {
|
|
65
97
|
const hasError = Boolean(this.error);
|
|
66
98
|
const classes = `ac-input-basic ac-input--${this.ambient}${hasError ? ' ac-input--invalid' : ''}`;
|
|
99
|
+
const icon = this._typeIcon;
|
|
100
|
+
const placeholder = this._placeholder;
|
|
101
|
+
const wrapperClasses = `ac-input-basic__field-wrapper${
|
|
102
|
+
icon ? ' ac-input-basic__field-wrapper--with-icon' : ''
|
|
103
|
+
}`;
|
|
67
104
|
|
|
68
105
|
return html`
|
|
69
106
|
<div part="root" class=${classes}>
|
|
@@ -78,23 +115,35 @@ export class InputBasic extends ComponentMixin(LitElement) {
|
|
|
78
115
|
</label>`
|
|
79
116
|
: nothing
|
|
80
117
|
}
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
118
|
+
<div class=${wrapperClasses}>
|
|
119
|
+
${
|
|
120
|
+
icon
|
|
121
|
+
? html`<ac-icon-basic
|
|
122
|
+
part="type-icon"
|
|
123
|
+
class="ac-input-basic__icon"
|
|
124
|
+
name=${icon}
|
|
125
|
+
size="sm"
|
|
126
|
+
></ac-icon-basic>`
|
|
127
|
+
: nothing
|
|
128
|
+
}
|
|
129
|
+
<input
|
|
130
|
+
part="input"
|
|
131
|
+
id="field"
|
|
132
|
+
class="ac-input-basic__field"
|
|
133
|
+
type=${this._type}
|
|
134
|
+
name=${this.name}
|
|
135
|
+
.value=${this.value}
|
|
136
|
+
placeholder=${placeholder ? placeholder : nothing}
|
|
137
|
+
aria-label=${!this.label && this.a11yLabel ? this.t(this.a11yLabel) : nothing}
|
|
138
|
+
aria-invalid=${hasError ? 'true' : 'false'}
|
|
139
|
+
aria-describedby=${this._message ? 'message' : nothing}
|
|
140
|
+
?disabled=${this.disabled}
|
|
141
|
+
?readonly=${this.readonly}
|
|
142
|
+
?required=${this.required}
|
|
143
|
+
@input=${this._onInput}
|
|
144
|
+
@change=${this._onChange}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
98
147
|
${
|
|
99
148
|
this._message
|
|
100
149
|
? html`<p
|
|
@@ -41,6 +41,30 @@ export const InputBasicStyles = css`
|
|
|
41
41
|
font-weight: var(--font-weight-medium, 600);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/* Envoltorio del campo: sin ícono se ve exactamente igual que antes (sin
|
|
45
|
+
\`position\`/layout propio, el \`<input>\` ocupa el 100% como siempre). Con
|
|
46
|
+
ícono (\`--with-icon\`), queda \`position: relative\` para anclar el ícono
|
|
47
|
+
absoluto a la izquierda y el campo gana padding-left para no superponerse. */
|
|
48
|
+
.ac-input-basic__field-wrapper {
|
|
49
|
+
display: contents;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ac-input-basic__field-wrapper--with-icon {
|
|
53
|
+
position: relative;
|
|
54
|
+
display: block;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ac-input-basic__icon {
|
|
58
|
+
position: absolute;
|
|
59
|
+
top: 50%;
|
|
60
|
+
left: var(--space-3, 0.75rem);
|
|
61
|
+
transform: translateY(-50%);
|
|
62
|
+
/* Decorativo: el campo ya se identifica por su label/placeholder, el
|
|
63
|
+
ícono nunca debe interceptar clics/foco. */
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
color: var(--color-subtext, #787a80);
|
|
66
|
+
}
|
|
67
|
+
|
|
44
68
|
.ac-input-basic__field {
|
|
45
69
|
box-sizing: border-box;
|
|
46
70
|
width: 100%;
|
|
@@ -58,6 +82,12 @@ export const InputBasicStyles = css`
|
|
|
58
82
|
transition: border-color 120ms ease, box-shadow 120ms ease;
|
|
59
83
|
}
|
|
60
84
|
|
|
85
|
+
.ac-input-basic__field-wrapper--with-icon .ac-input-basic__field {
|
|
86
|
+
/* Espacio a la izquierda del ícono (sm, 16px) + el mismo gap que el padding
|
|
87
|
+
derecho del campo: 0.75rem (borde) + 16px (ícono) + 0.55rem (gap) */
|
|
88
|
+
padding-left: calc(var(--space-3, 0.75rem) + 16px + var(--space-2, 0.55rem));
|
|
89
|
+
}
|
|
90
|
+
|
|
61
91
|
.ac-input-basic__field::placeholder {
|
|
62
92
|
/* Mezcla (no opacity): el contraste se calcula contra el fondo del campo. */
|
|
63
93
|
color: color-mix(in srgb, var(--color-text, #bcbec4) 70%, var(--color-surface, #2b2b2b));
|
|
@@ -38,6 +38,30 @@
|
|
|
38
38
|
font-weight: var(--font-weight-medium, 600);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/* Envoltorio del campo: sin ícono se ve exactamente igual que antes (sin
|
|
42
|
+
`position`/layout propio, el `<input>` ocupa el 100% como siempre). Con
|
|
43
|
+
ícono (`--with-icon`), queda `position: relative` para anclar el ícono
|
|
44
|
+
absoluto a la izquierda y el campo gana padding-left para no superponerse. */
|
|
45
|
+
.ac-input-basic__field-wrapper {
|
|
46
|
+
display: contents;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ac-input-basic__field-wrapper--with-icon {
|
|
50
|
+
position: relative;
|
|
51
|
+
display: block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ac-input-basic__icon {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 50%;
|
|
57
|
+
left: var(--space-3, 0.75rem);
|
|
58
|
+
transform: translateY(-50%);
|
|
59
|
+
/* Decorativo: el campo ya se identifica por su label/placeholder, el
|
|
60
|
+
ícono nunca debe interceptar clics/foco. */
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
color: var(--color-subtext, #787a80);
|
|
63
|
+
}
|
|
64
|
+
|
|
41
65
|
.ac-input-basic__field {
|
|
42
66
|
box-sizing: border-box;
|
|
43
67
|
width: 100%;
|
|
@@ -57,6 +81,12 @@
|
|
|
57
81
|
box-shadow 120ms ease;
|
|
58
82
|
}
|
|
59
83
|
|
|
84
|
+
.ac-input-basic__field-wrapper--with-icon .ac-input-basic__field {
|
|
85
|
+
/* Espacio a la izquierda del ícono (sm, 16px) + el mismo gap que el padding
|
|
86
|
+
derecho del campo: 0.75rem (borde) + 16px (ícono) + 0.55rem (gap) */
|
|
87
|
+
padding-left: calc(var(--space-3, 0.75rem) + 16px + var(--space-2, 0.55rem));
|
|
88
|
+
}
|
|
89
|
+
|
|
60
90
|
.ac-input-basic__field::placeholder {
|
|
61
91
|
/* Mezcla (no opacity): el contraste se calcula contra el fondo del campo. */
|
|
62
92
|
color: color-mix(in srgb, var(--color-text, #bcbec4) 70%, var(--color-surface, #2b2b2b));
|