@tooark/web-components 1.6.0 → 1.6.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/README.md +4 -4
- package/README.pt-BR.md +4 -4
- package/dist/index.cjs +72 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +72 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ Declare the page's `color-scheme` to pick the theme (`light`, `dark` or `light d
|
|
|
74
74
|
- `ark-alert` — Alert/banner: the host is the box in the intent's soft color, your children are the message (free text or elements), `slot="icon"` left, `slot="action"` right, `heading`, `dismissible` with animated exit, `live` region (`status`/`alert`).
|
|
75
75
|
- `ark-avatar` — Avatar (`role="img"` named by `name`): initials from `name`, `src` image that falls back to the initials on load error, `size`, `shape` circle/square, custom `color`, `variant` soft/solid.
|
|
76
76
|
- `ark-badge` — Short status/category label: intents, `soft`/`solid`/`outline`, `xs`–`md`, `rounded`, custom `color` via `color-mix`. The host is the badge; icon and text stay as its children.
|
|
77
|
-
- `ark-button` — Intents, sizes, style variants (solid/outline/ghost), `rounded` (up to `full`), `loading`/`icon-only`/`full-width` states, `status` feedback (success/error glyph + announcement), link mode (`href`).
|
|
77
|
+
- `ark-button` — Intents, sizes, style variants (solid/outline/ghost), `rounded` (up to `full`), `loading`/`icon-only`/`full-width` states, `status` feedback (success/error glyph + announcement), link mode (`href`), forms (`type="submit"` is the form's default button, so Enter in its text fields submits).
|
|
78
78
|
- `ark-calendar` — Inline month grid (MUI DateCalendar-style): localized, WAI-ARIA keyboard navigation, motion, month/year views from the title and colored events (`dots`/`count`/`list`).
|
|
79
79
|
- `ark-card` — Card: the host is the box (`surface`, `border`, `rounded`) and a grid: `heading` (h2) or `slot="header"` with `slot="actions"` on the top row, unslotted children as the body, `slot="footer"` last with a divider; `padding` none–lg.
|
|
80
80
|
- `ark-carousel` — Native CSS scroll snap (touch/trackpad scroll natively, mouse drag emulated), autoplay, loop, dots and arrows. Slides stay as your direct children.
|
|
@@ -84,7 +84,7 @@ Declare the page's `color-scheme` to pick the theme (`light`, `dark` or `light d
|
|
|
84
84
|
- `ark-command-item` — Command palette item (the host is the `role="option"`): free children, `slot="trailing"` for a shortcut, `value`, `group`, `label` (filter text), `disabled`. Emits `ark-select`.
|
|
85
85
|
- `ark-command-palette` — Command palette on the Popover API: search field (an `ark-input` of its own), `ark-command-item` children grouped and filtered (`filter`) or searched by the app (`ark-query`), arrows + Enter, `hotkey` (`/`, `mod+k`), `hint` and `busy` for the empty message. Emits `ark-select`, `ark-query`, `ark-open`, `ark-close`.
|
|
86
86
|
- `ark-copy-button` — Copy button: extends `ark-button` (same variants, sizes, `icon-only`, forms, hooks); copies `value` or the `for` element, swaps the icon for a check and the text/`title` for "copied" for `feedback-ms`, announces it. Emits `ark-copy`.
|
|
87
|
-
- `ark-datepicker` — Date/time picker composing `ark-input` + `ark-calendar` + `ark-clock`: `mode` datetime (default)/date/time, inline or `input` mode with field + popup, localized formatting, typed input parsing, forms.
|
|
87
|
+
- `ark-datepicker` — Date/time picker composing `ark-input` + `ark-calendar` + `ark-clock`: `mode` datetime (default)/date/time, inline or `input` mode with field + popup, localized formatting, typed input parsing, forms (Enter in the field submits once the popup is closed).
|
|
88
88
|
- `ark-dialog` — Modal dialog on the Popover API (top layer, `::backdrop` scrim, no portal): the host is the panel, your children are the body, `slot="footer"` is the footer; header from `label`, focus trap, Esc/scrim, `sm`–`xl` or `full`.
|
|
89
89
|
- `ark-drawer` — Drawer anchored to an edge: `overlay` (Popover API, scrim, focus trap, Esc) or `inline` (in the page flow, e.g. a bottom console); `side`, `size` preset or CSS length, header from `label` with a `slot="actions"` row, `slot="footer"`, slide with the `sheet` easing. Emits `ark-open`/`ark-close`.
|
|
90
90
|
- `ark-empty` — Empty state: dashed box with a dimmed `slot="icon"`, `heading` (h3), `description` and an optional `slot="action"` button; children stay in place, ordered by CSS.
|
|
@@ -186,8 +186,8 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
|
|
|
186
186
|
|
|
187
187
|
| Package | Version | Description |
|
|
188
188
|
| ---------------------------------------------------------------- | ------- | ---------------------------------------------------------------- |
|
|
189
|
-
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.
|
|
190
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.
|
|
189
|
+
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.1 | Types, i18n, toast/announce services, motion and overlay helpers |
|
|
190
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.1 | Design tokens (colors, sizes, motion) and primitive types |
|
|
191
191
|
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
|
|
192
192
|
|
|
193
193
|
---
|
package/README.pt-BR.md
CHANGED
|
@@ -74,7 +74,7 @@ Declare o `color-scheme` da página para escolher o tema (`light`, `dark` ou `li
|
|
|
74
74
|
- `ark-alert` — Alerta/banner: o host é a caixa na cor suave do intent, os filhos são a mensagem (texto livre ou elementos), `slot="icon"` à esquerda, `slot="action"` à direita, `heading`, `dismissible` com saída animada, `live` region (`status`/`alert`).
|
|
75
75
|
- `ark-avatar` — Avatar (`role="img"` nomeado por `name`): iniciais de `name`, imagem `src` que cai para as iniciais em erro de carga, `size`, `shape` circle/square, `color` própria, `variant` soft/solid.
|
|
76
76
|
- `ark-badge` — Rótulo curto de status/categoria: intents, `soft`/`solid`/`outline`, `xs`–`md`, `rounded`, `color` própria via `color-mix`. O host é o badge; ícone e texto ficam como filhos.
|
|
77
|
-
- `ark-button` — Intents, tamanhos, variantes (solid/outline/ghost), `rounded` (até `full`), estados `loading`/`icon-only`/`full-width`, feedback `status` (glifo de sucesso/erro + anúncio)
|
|
77
|
+
- `ark-button` — Intents, tamanhos, variantes (solid/outline/ghost), `rounded` (até `full`), estados `loading`/`icon-only`/`full-width`, feedback `status` (glifo de sucesso/erro + anúncio), modo link (`href`) e formulário (`type="submit"` é o botão padrão do formulário, então Enter nos campos de texto envia).
|
|
78
78
|
- `ark-calendar` — Grid de mês inline (no estilo do DateCalendar do MUI): localizado, teclado WAI-ARIA, motion, views de mês/ano no título e eventos com cor (`dots`/`count`/`list`).
|
|
79
79
|
- `ark-card` — Cartão: o host é a caixa (`surface`, `border`, `rounded`) e uma grid: `heading` (h2) ou `slot="header"` com `slot="actions"` na linha de cima, filhos sem slot como corpo, `slot="footer"` por último com divisor; `padding` none–lg.
|
|
80
80
|
- `ark-carousel` — CSS scroll snap nativo (touch/trackpad rolam nativamente, arrasto com mouse emulado), autoplay, loop, dots e setas. Os slides continuam sendo seus filhos diretos.
|
|
@@ -84,7 +84,7 @@ Declare o `color-scheme` da página para escolher o tema (`light`, `dark` ou `li
|
|
|
84
84
|
- `ark-command-item` — Item da paleta de comandos (o host é o `role="option"`): filhos livres, `slot="trailing"` para o atalho, `value`, `group`, `label` (texto do filtro), `disabled`. Emite `ark-select`.
|
|
85
85
|
- `ark-command-palette` — Paleta de comandos sobre a Popover API: campo de busca (um `ark-input` próprio), filhos `ark-command-item` agrupados e filtrados (`filter`) ou buscados pelo app (`ark-query`), setas + Enter, `hotkey` (`/`, `mod+k`), `hint` e `busy` para a mensagem de vazio. Emite `ark-select`, `ark-query`, `ark-open`, `ark-close`.
|
|
86
86
|
- `ark-copy-button` — Botão de copiar: estende o `ark-button` (mesmas variantes, tamanhos, `icon-only`, formulário, hooks); copia `value` ou o elemento de `for`, troca o ícone por um check e o texto/`title` por "copiado" durante `feedback-ms`, anuncia. Emite `ark-copy`.
|
|
87
|
-
- `ark-datepicker` — Seletor de data/hora que compõe `ark-input` + `ark-calendar` + `ark-clock`: `mode` datetime (padrão)/date/time, inline ou modo `input` com campo + popup, formatação localizada, parse da digitação, formulário.
|
|
87
|
+
- `ark-datepicker` — Seletor de data/hora que compõe `ark-input` + `ark-calendar` + `ark-clock`: `mode` datetime (padrão)/date/time, inline ou modo `input` com campo + popup, formatação localizada, parse da digitação, formulário (Enter no campo envia com o popup fechado).
|
|
88
88
|
- `ark-dialog` — Diálogo modal sobre a Popover API (top layer, scrim por `::backdrop`, sem portal): o host é o painel, seus filhos são o corpo, `slot="footer"` é o rodapé; cabeçalho de `label`, focus trap, Esc/scrim, `sm`–`xl` ou `full`.
|
|
89
89
|
- `ark-drawer` — Gaveta ancorada numa borda: `overlay` (Popover API, scrim, focus trap, Esc) ou `inline` (no fluxo da página, ex.: console inferior); `side`, `size` preset ou comprimento CSS, cabeçalho de `label` com a linha `slot="actions"`, `slot="footer"`, slide com o easing `sheet`. Emite `ark-open`/`ark-close`.
|
|
90
90
|
- `ark-empty` — Estado vazio: caixa tracejada com `slot="icon"` apagado, `heading` (h3), `description` e um botão opcional em `slot="action"`; os filhos ficam no lugar, ordenados por CSS.
|
|
@@ -186,8 +186,8 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
|
|
|
186
186
|
|
|
187
187
|
| Pacote | Versão | Descrição |
|
|
188
188
|
| ---------------------------------------------------------------- | ------ | -------------------------------------------------------------------- |
|
|
189
|
-
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.
|
|
190
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.
|
|
189
|
+
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.1 | Tipos, i18n, serviços de toast/announce, motion e helpers de overlay |
|
|
190
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.1 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
|
|
191
191
|
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
|
|
192
192
|
|
|
193
193
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -683,12 +683,28 @@ const STATUS_SVG = {
|
|
|
683
683
|
</svg>`
|
|
684
684
|
};
|
|
685
685
|
let arkButtonIdCounter = 0;
|
|
686
|
+
/** Tipos de `<input>` em que o Enter submete o formulário (os campos que bloqueiam a submissão implícita no HTML). */
|
|
687
|
+
const IMPLICIT_SUBMIT_TYPES = new Set([
|
|
688
|
+
"text",
|
|
689
|
+
"search",
|
|
690
|
+
"email",
|
|
691
|
+
"url",
|
|
692
|
+
"tel",
|
|
693
|
+
"password",
|
|
694
|
+
"number",
|
|
695
|
+
"date",
|
|
696
|
+
"month",
|
|
697
|
+
"week",
|
|
698
|
+
"time",
|
|
699
|
+
"datetime-local"
|
|
700
|
+
]);
|
|
686
701
|
/**
|
|
687
702
|
* Botão da família Ark.
|
|
688
703
|
*
|
|
689
704
|
* O PRÓPRIO host é o controle: recebe as classes, `role="button"`, foco,
|
|
690
705
|
* teclado (Enter/Espaço) e participa de formulários via ElementInternals
|
|
691
|
-
* (`type="submit"`/`"reset"
|
|
706
|
+
* (`type="submit"`/`"reset"`; o primeiro de submit é o botão padrão do Enter
|
|
707
|
+
* nos campos do formulário). Nenhum filho do usuário é movido ou envolvido,
|
|
692
708
|
* então frameworks que gerenciam os filhos (React, Vue, Angular) continuam
|
|
693
709
|
* donos deles. Com `href`, um `<a>` "esticado" cobre o host, recebe o foco e
|
|
694
710
|
* é nomeado pelo conteúdo do host (`aria-labelledby`).
|
|
@@ -817,6 +833,7 @@ class ArkButton extends HTMLElementBase {
|
|
|
817
833
|
*/
|
|
818
834
|
connectedCallback() {
|
|
819
835
|
upgradeProperties(this);
|
|
836
|
+
ArkButton.installImplicitSubmit();
|
|
820
837
|
this.updateAppearance();
|
|
821
838
|
}
|
|
822
839
|
/**
|
|
@@ -932,6 +949,30 @@ class ArkButton extends HTMLElementBase {
|
|
|
932
949
|
get form() {
|
|
933
950
|
return this.internals?.form ?? this.closest("form");
|
|
934
951
|
}
|
|
952
|
+
// O navegador só reconhece como botão padrão do formulário um botão de submit nativo; um elemento form-associated
|
|
953
|
+
// nunca entra na submissão implícita, e um formulário com dois campos (login) não enviava no Enter. Fase de bolha:
|
|
954
|
+
// o Enter que um componente ou o app já cancelou fica com eles.
|
|
955
|
+
static installImplicitSubmit() {
|
|
956
|
+
if (ArkButton.implicitSubmitInstalled)
|
|
957
|
+
return;
|
|
958
|
+
ArkButton.implicitSubmitInstalled = true;
|
|
959
|
+
document.addEventListener("keydown", ArkButton.handleImplicitSubmit);
|
|
960
|
+
}
|
|
961
|
+
/** Primeiro `ark-button` de submit do formulário, ou nenhum quando há um submit nativo (o navegador já o clica). */
|
|
962
|
+
static defaultButton(form) {
|
|
963
|
+
const elements = Array.from(form.elements);
|
|
964
|
+
// `form.elements` não lista o <input type="image">, que também é botão padrão.
|
|
965
|
+
const hasNativeSubmit = form.querySelector('input[type="image" i]') !== null ||
|
|
966
|
+
elements.some((el) => (el instanceof HTMLButtonElement && el.type === "submit") ||
|
|
967
|
+
(el instanceof HTMLInputElement && (el.type === "submit" || el.type === "image")));
|
|
968
|
+
if (hasNativeSubmit)
|
|
969
|
+
return null;
|
|
970
|
+
for (const el of elements) {
|
|
971
|
+
if (el instanceof ArkButton && el.type === "submit" && !el.hasAttribute("href"))
|
|
972
|
+
return el;
|
|
973
|
+
}
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
935
976
|
// --- Estilo ---
|
|
936
977
|
/**
|
|
937
978
|
* Normaliza o valor do intent, caindo em "primary" quando não é um dos valores válidos.
|
|
@@ -1261,6 +1302,26 @@ class ArkButton extends HTMLElementBase {
|
|
|
1261
1302
|
// `string`, e não o literal, para subclasses (ark-copy-button) redeclararem o próprio tag.
|
|
1262
1303
|
ArkButton.tagName = "ark-button";
|
|
1263
1304
|
ArkButton.formAssociated = true;
|
|
1305
|
+
/** Listener único de Enter no documento, instalado pelo primeiro botão conectado. */
|
|
1306
|
+
ArkButton.implicitSubmitInstalled = false;
|
|
1307
|
+
/** Enter num campo de texto do formulário clica o primeiro `ark-button` de submit, como o botão padrão nativo. */
|
|
1308
|
+
ArkButton.handleImplicitSubmit = (event) => {
|
|
1309
|
+
if (event.key !== "Enter" || event.defaultPrevented || event.isComposing)
|
|
1310
|
+
return;
|
|
1311
|
+
if (event.ctrlKey || event.metaKey || event.altKey)
|
|
1312
|
+
return;
|
|
1313
|
+
const field = event.composedPath()[0];
|
|
1314
|
+
if (!(field instanceof HTMLInputElement) || !IMPLICIT_SUBMIT_TYPES.has(field.type) || !field.form)
|
|
1315
|
+
return;
|
|
1316
|
+
const button = ArkButton.defaultButton(field.form);
|
|
1317
|
+
if (!button)
|
|
1318
|
+
return;
|
|
1319
|
+
// Sem o preventDefault, um formulário de campo único ainda seria submetido pelo navegador: dois envios.
|
|
1320
|
+
event.preventDefault();
|
|
1321
|
+
// Botão padrão desabilitado (ou carregando) bloqueia a submissão implícita, como no nativo.
|
|
1322
|
+
if (!button.isDisabled())
|
|
1323
|
+
button.click();
|
|
1324
|
+
};
|
|
1264
1325
|
|
|
1265
1326
|
/**
|
|
1266
1327
|
* Grid de mês inline para seleção de data — equivalente ao DateCalendar do MUI.
|
|
@@ -4625,8 +4686,10 @@ class ArkDatepicker extends HTMLElementBase {
|
|
|
4625
4686
|
if (event.target?.tagName !== "INPUT")
|
|
4626
4687
|
return;
|
|
4627
4688
|
if (event.key === "Enter") {
|
|
4628
|
-
|
|
4629
|
-
|
|
4689
|
+
// Enter confirma o texto digitado. Com o popup fechado e o texto aceito, segue para o formulário (submissão
|
|
4690
|
+
// implícita), como num <input type="date">; texto inválido volta ao último valor e não submete.
|
|
4691
|
+
if (!this.commitTyped() || this.popupOpen)
|
|
4692
|
+
event.preventDefault();
|
|
4630
4693
|
}
|
|
4631
4694
|
else if (event.key === "ArrowDown") {
|
|
4632
4695
|
event.preventDefault();
|
|
@@ -4764,10 +4827,11 @@ class ArkDatepicker extends HTMLElementBase {
|
|
|
4764
4827
|
composed: true
|
|
4765
4828
|
}));
|
|
4766
4829
|
}
|
|
4830
|
+
/** Aplica o texto digitado no campo; `false` quando ele era inválido e o campo voltou ao último valor válido. */
|
|
4767
4831
|
commitTyped() {
|
|
4768
4832
|
const input = this.inputComp?.inputElement;
|
|
4769
4833
|
if (!input)
|
|
4770
|
-
return;
|
|
4834
|
+
return true;
|
|
4771
4835
|
const text = input.value.trim();
|
|
4772
4836
|
const currentValue = this.getAttribute("value") || "";
|
|
4773
4837
|
if (!text) {
|
|
@@ -4777,22 +4841,23 @@ class ArkDatepicker extends HTMLElementBase {
|
|
|
4777
4841
|
this.pushValueToChildren();
|
|
4778
4842
|
this.emitChange();
|
|
4779
4843
|
}
|
|
4780
|
-
return;
|
|
4844
|
+
return true;
|
|
4781
4845
|
}
|
|
4782
4846
|
const parsed = this.parseDisplay(text);
|
|
4783
4847
|
if (!parsed) {
|
|
4784
4848
|
// Entrada inválida: reverte para o último valor válido.
|
|
4785
4849
|
this.updateInputDisplay();
|
|
4786
|
-
return;
|
|
4850
|
+
return false;
|
|
4787
4851
|
}
|
|
4788
4852
|
this.dateISO = parsed.dateISO ?? this.dateISO;
|
|
4789
4853
|
this.timeISO = parsed.timeISO ?? this.timeISO;
|
|
4790
4854
|
if (this.composeValue() === currentValue) {
|
|
4791
4855
|
this.updateInputDisplay();
|
|
4792
|
-
return;
|
|
4856
|
+
return true;
|
|
4793
4857
|
}
|
|
4794
4858
|
this.pushValueToChildren();
|
|
4795
4859
|
this.emitChange();
|
|
4860
|
+
return true;
|
|
4796
4861
|
}
|
|
4797
4862
|
// --- Popup ---
|
|
4798
4863
|
focusPanel() {
|