@tooark/web-components 1.3.0 → 1.4.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/dist/index.js CHANGED
@@ -322,7 +322,8 @@ const PERSON_SVG = `
322
322
  * carregar, as iniciais de `name` (primeira letra, ou primeira mais última
323
323
  * quando há sobrenome); sem nome e sem imagem, um glifo de pessoa decorativo
324
324
  * (`aria-hidden`, a menos que o host tenha aria-label próprio). `color` troca
325
- * o tint primary por uma cor própria (texto na cor, fundo suave).
325
+ * o tint primary por uma cor própria (texto na cor, fundo suave) e
326
+ * `variant="solid"` preenche o fundo com a cor e escreve as iniciais em branco.
326
327
  */
327
328
  class ArkAvatar extends HTMLElementBase {
328
329
  constructor() {
@@ -337,7 +338,7 @@ class ArkAvatar extends HTMLElementBase {
337
338
  this.ownLabel = null;
338
339
  }
339
340
  static get observedAttributes() {
340
- return ["name", "src", "size", "shape", "color", "aria-label", "theme", "class", "testid"];
341
+ return ["name", "src", "size", "shape", "color", "variant", "aria-label", "theme", "class", "testid"];
341
342
  }
342
343
  connectedCallback() {
343
344
  upgradeProperties(this);
@@ -378,6 +379,9 @@ class ArkAvatar extends HTMLElementBase {
378
379
  getShape() {
379
380
  return (this.getAttribute("shape") || "").toLowerCase() === "square" ? "square" : "circle";
380
381
  }
382
+ getVariant() {
383
+ return (this.getAttribute("variant") || "").toLowerCase() === "solid" ? "solid" : "soft";
384
+ }
381
385
  render() {
382
386
  const initials = document.createElement("span");
383
387
  initials.setAttribute("aria-hidden", "true");
@@ -416,7 +420,7 @@ class ArkAvatar extends HTMLElementBase {
416
420
  this.imageEl.hidden = failed;
417
421
  this.imageEl.className = failed ? "" : "ark:h-full ark:w-full ark:object-cover";
418
422
  }
419
- // Cor própria: texto na cor e fundo suave por color-mix, como o badge.
423
+ // Cor própria, como o badge: suave é texto na cor e fundo por color-mix; sólido é fundo na cor e texto branco.
420
424
  applyCustomColor() {
421
425
  const color = this.getAttribute("color")?.trim();
422
426
  if (!color) {
@@ -424,8 +428,9 @@ class ArkAvatar extends HTMLElementBase {
424
428
  this.style.removeProperty("--ark-avatar-fg");
425
429
  return;
426
430
  }
427
- this.style.setProperty("--ark-avatar-bg", `color-mix(in oklab, ${color} 18%, transparent)`);
428
- this.style.setProperty("--ark-avatar-fg", color);
431
+ const solid = this.getVariant() === "solid";
432
+ this.style.setProperty("--ark-avatar-bg", solid ? color : `color-mix(in oklab, ${color} 18%, transparent)`);
433
+ this.style.setProperty("--ark-avatar-fg", solid ? "#fff" : color);
429
434
  }
430
435
  applyOwnClasses(next) {
431
436
  this.syncingClass = true;
@@ -467,7 +472,9 @@ class ArkAvatar extends HTMLElementBase {
467
472
  ].join(" ");
468
473
  const colors = this.getAttribute("color")?.trim()
469
474
  ? "ark:bg-(--ark-avatar-bg) ark:text-(--ark-avatar-fg)"
470
- : "ark:bg-primary-soft ark:text-primary-soft-fg";
475
+ : this.getVariant() === "solid"
476
+ ? "ark:bg-primary ark:text-primary-fg"
477
+ : "ark:bg-primary-soft ark:text-primary-soft-fg";
471
478
  this.applyOwnClasses([
472
479
  "ark:inline-flex ark:shrink-0 ark:items-center ark:justify-center ark:overflow-hidden ark:align-middle ark:font-semibold ark:uppercase ark:leading-none ark:select-none",
473
480
  sizing.box,
@@ -2534,8 +2541,10 @@ let nextId$1 = 0;
2534
2541
  * formulário; os dois são controles nativos, então <fieldset disabled> os
2535
2542
  * desabilita sem JS. `label` vira um <label for> próprio; sem ele o host
2536
2543
  * precisa de aria-label, ou de filhos (texto livre, links), que dão nome à
2537
- * caixa por aria-labelledby e a alternam ao clique. Os nós próprios ficam no
2538
- * início do host, marcados data-ark-chrome, antes dos filhos do usuário.
2544
+ * caixa por aria-labelledby e a alternam ao clique. `helper` acrescenta uma
2545
+ * dica abaixo do rótulo, que descreve a caixa por aria-describedby. Os nós
2546
+ * próprios ficam no início do host, marcados data-ark-chrome, antes dos filhos
2547
+ * do usuário.
2539
2548
  */
2540
2549
  class ArkCheckbox extends HTMLElementBase {
2541
2550
  static get observedAttributes() {
@@ -2546,6 +2555,7 @@ class ArkCheckbox extends HTMLElementBase {
2546
2555
  "name",
2547
2556
  "value",
2548
2557
  "label",
2558
+ "helper",
2549
2559
  "aria-label",
2550
2560
  "size",
2551
2561
  "intent",
@@ -2561,6 +2571,7 @@ class ArkCheckbox extends HTMLElementBase {
2561
2571
  this.boxEl = null;
2562
2572
  this.iconEl = null;
2563
2573
  this.labelEl = null;
2574
+ this.helperEl = null;
2564
2575
  this.inputEl = null;
2565
2576
  this.observer = null;
2566
2577
  /** Glifo em exibição; a troca depois do primeiro render entra com scale-in. */
@@ -2715,11 +2726,11 @@ class ArkCheckbox extends HTMLElementBase {
2715
2726
  getSizing() {
2716
2727
  const size = (this.getAttribute("size") || "md").toLowerCase();
2717
2728
  const sizes = {
2718
- xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs" },
2719
- sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm" },
2720
- md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm" },
2721
- lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base" },
2722
- xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg" }
2729
+ xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs", helper: "ark:text-2xs" },
2730
+ sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm", helper: "ark:text-xs" },
2731
+ md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm", helper: "ark:text-xs" },
2732
+ lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base", helper: "ark:text-sm" },
2733
+ xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg", helper: "ark:text-base" }
2723
2734
  };
2724
2735
  return sizes[size] ?? sizes.md;
2725
2736
  }
@@ -2763,7 +2774,32 @@ class ArkCheckbox extends HTMLElementBase {
2763
2774
  }
2764
2775
  this.labelEl.htmlFor = this.boxEl?.id ?? "";
2765
2776
  this.labelEl.textContent = text;
2766
- this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
2777
+ this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
2778
+ }
2779
+ // Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a caixa por aria-describedby.
2780
+ // Com ela o host vira grid (updateAppearance): a caixa na primeira coluna, rótulo e dica empilhados na segunda.
2781
+ syncHelper(sizing) {
2782
+ if (!this.boxEl)
2783
+ return;
2784
+ const text = this.getAttribute("helper");
2785
+ if (!text) {
2786
+ this.helperEl?.remove();
2787
+ this.helperEl = null;
2788
+ this.boxEl.removeAttribute("aria-describedby");
2789
+ return;
2790
+ }
2791
+ if (!this.helperEl) {
2792
+ const helper = document.createElement("span");
2793
+ helper.setAttribute("data-ark-chrome", "helper");
2794
+ helper.id = `${this.boxEl.id}-helper`;
2795
+ (this.labelEl ?? this.inputEl)?.after(helper);
2796
+ this.helperEl = helper;
2797
+ }
2798
+ if (this.helperEl.textContent !== text)
2799
+ this.helperEl.textContent = text;
2800
+ // order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
2801
+ this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
2802
+ this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
2767
2803
  }
2768
2804
  // Nome acessível da caixa: o <label for> próprio; senão aria-label; senão os filhos do usuário, via
2769
2805
  // aria-labelledby no host (que ganha um id quando falta).
@@ -2791,6 +2827,16 @@ class ArkCheckbox extends HTMLElementBase {
2791
2827
  this.boxEl.removeAttribute("aria-label");
2792
2828
  this.boxEl.removeAttribute("aria-labelledby");
2793
2829
  }
2830
+ // Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
2831
+ // nós ocultos).
2832
+ if (this.helperEl) {
2833
+ if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
2834
+ this.helperEl.setAttribute("aria-hidden", "true");
2835
+ }
2836
+ else {
2837
+ this.helperEl.removeAttribute("aria-hidden");
2838
+ }
2839
+ }
2794
2840
  }
2795
2841
  syncIcon(kind) {
2796
2842
  if (!this.iconEl || kind === this.iconKind)
@@ -2826,11 +2872,20 @@ class ArkCheckbox extends HTMLElementBase {
2826
2872
  const checked = this.checked;
2827
2873
  const indeterminate = this.indeterminate;
2828
2874
  const disabled = this.disabled;
2875
+ // Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
2876
+ const layout = this.hasAttribute("helper")
2877
+ ? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
2878
+ : "ark:inline-flex ark:gap-2";
2829
2879
  // O host dimeriza tudo (caixa e rótulo) quando qualquer controle interno está desabilitado, inclusive
2830
2880
  // por <fieldset disabled>.
2831
- this.applyOwnClasses("ark:inline-flex ark:cursor-pointer ark:items-center ark:gap-2 ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50".split(" "));
2881
+ this.applyOwnClasses([
2882
+ layout,
2883
+ "ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
2884
+ ]
2885
+ .join(" ")
2886
+ .split(" "));
2832
2887
  this.boxEl.className = [
2833
- "ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
2888
+ "ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
2834
2889
  palette.ring,
2835
2890
  sizing.box,
2836
2891
  checked || indeterminate
@@ -2841,6 +2896,7 @@ class ArkCheckbox extends HTMLElementBase {
2841
2896
  this.boxEl.disabled = disabled;
2842
2897
  this.syncIcon(indeterminate ? "mixed" : checked ? "check" : "none");
2843
2898
  this.syncLabel(sizing);
2899
+ this.syncHelper(sizing);
2844
2900
  this.syncName();
2845
2901
  this.inputEl.checked = checked;
2846
2902
  this.inputEl.indeterminate = indeterminate;
@@ -2851,6 +2907,8 @@ class ArkCheckbox extends HTMLElementBase {
2851
2907
  applyTestHooks(this, "checkbox", this.inputEl, "input");
2852
2908
  if (this.labelEl)
2853
2909
  applyTestHooks(this, "checkbox", this.labelEl, "label");
2910
+ if (this.helperEl)
2911
+ applyTestHooks(this, "checkbox", this.helperEl, "helper");
2854
2912
  }
2855
2913
  }
2856
2914
  ArkCheckbox.tagName = "ark-checkbox";
@@ -3443,7 +3501,9 @@ function normalize(text) {
3443
3501
  * e um listbox oculto que é dono das opções visíveis por `aria-owns`. Itens
3444
3502
  * e cabeçalhos se ordenam por `order` no CSS, então nada é inserido entre os
3445
3503
  * filhos. Com `filter` o texto filtra localmente pelo `label` dos itens; em
3446
- * qualquer caso `ark-query` sai com debounce para busca assíncrona. O foco
3504
+ * qualquer caso `ark-query` sai com debounce para busca assíncrona. Sem opções
3505
+ * visíveis a mensagem é `noResults`; `hint` a troca enquanto o campo está
3506
+ * vazio e `busy` (busca em andamento) a troca por `searching`. O foco
3447
3507
  * fica sempre no campo; setas movem a opção ativa (`aria-activedescendant`),
3448
3508
  * Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
3449
3509
  * página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
@@ -3457,6 +3517,8 @@ class ArkCommandPalette extends HTMLElementBase {
3457
3517
  "filter",
3458
3518
  "query-delay",
3459
3519
  "label",
3520
+ "hint",
3521
+ "busy",
3460
3522
  "theme",
3461
3523
  "lang",
3462
3524
  "locale-json",
@@ -3658,6 +3720,13 @@ class ArkCommandPalette extends HTMLElementBase {
3658
3720
  set noScrollLock(value) {
3659
3721
  this.toggleAttribute("no-scroll-lock", coerceBooleanAttr(value));
3660
3722
  }
3723
+ /** Busca assíncrona em andamento (atributo `busy`): o listbox fica `aria-busy` e, sem opções, aparece `searching`. */
3724
+ get busy() {
3725
+ return this.hasAttribute("busy");
3726
+ }
3727
+ set busy(value) {
3728
+ this.toggleAttribute("busy", coerceBooleanAttr(value));
3729
+ }
3661
3730
  /** Texto atual do campo de busca. */
3662
3731
  get query() {
3663
3732
  return this.inputEl?.value ?? "";
@@ -3741,15 +3810,31 @@ class ArkCommandPalette extends HTMLElementBase {
3741
3810
  applyTestHooks(this, "command-palette", header, "group");
3742
3811
  });
3743
3812
  this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
3744
- this.emptyEl.hidden = visible.length > 0;
3745
- const noResults = this.getLocale().noResults;
3746
- if (this.emptyEl.textContent !== noResults)
3747
- this.emptyEl.textContent = noResults;
3813
+ this.syncEmpty(visible.length);
3748
3814
  const enabled = visible.filter((item) => !item.disabled);
3749
3815
  if (!enabled.some((item) => item.id === this.activeId))
3750
3816
  this.activeId = enabled[0]?.id ?? null;
3751
3817
  this.applyActive(items);
3752
3818
  }
3819
+ // Mensagem sem opções visíveis: `searching` com `busy`, o `hint` do app com o campo vazio, senão `noResults`.
3820
+ syncEmpty(visible) {
3821
+ if (!this.listEl || !this.emptyEl)
3822
+ return;
3823
+ const locale = this.getLocale();
3824
+ const busy = this.busy;
3825
+ const hint = this.getAttribute("hint");
3826
+ const text = busy ? locale.searching : hint && this.query.trim() === "" ? hint : locale.noResults;
3827
+ this.emptyEl.hidden = visible > 0;
3828
+ // Só escreve o que mudou: o observer (subtree) veria a troca do nó de texto e sincronizaria em laço.
3829
+ if (this.emptyEl.textContent !== text)
3830
+ this.emptyEl.textContent = text;
3831
+ if (busy) {
3832
+ this.listEl.setAttribute("aria-busy", "true");
3833
+ }
3834
+ else {
3835
+ this.listEl.removeAttribute("aria-busy");
3836
+ }
3837
+ }
3753
3838
  applyActive(items) {
3754
3839
  for (const item of items) {
3755
3840
  const active = item.id === this.activeId;
@@ -3910,8 +3995,7 @@ class ArkCommandPalette extends HTMLElementBase {
3910
3995
  this.inputEl.removeAttribute(attr);
3911
3996
  }
3912
3997
  }
3913
- if (this.emptyEl.textContent !== locale.noResults)
3914
- this.emptyEl.textContent = locale.noResults;
3998
+ this.syncEmpty(this.visibleItems().length);
3915
3999
  applyTestHooks(this, "command-palette", this);
3916
4000
  applyTestHooks(this, "command-palette", this.inputEl, "input");
3917
4001
  applyTestHooks(this, "command-palette", this.listEl, "list");
@@ -5145,11 +5229,12 @@ function cssLength$1(value) {
5145
5229
  * página e só anima (o console inferior, um painel lateral fixo). Os filhos
5146
5230
  * do usuário são o corpo e ficam onde estão; um filho `slot="footer"` vai ao
5147
5231
  * fim por CSS. O cabeçalho (título `h2` de `label` e botão de fechar) é o
5148
- * primeiro filho, marcado `data-ark-chrome`. `side` escolhe a borda, a
5149
- * direção do slide (com o easing `sheet`) e a borda desenhada; `size` é um
5150
- * preset ou um comprimento CSS no eixo da gaveta. `open` é a fonte da
5151
- * verdade, como no ark-dialog, e em overlay a página para de rolar enquanto
5152
- * aberta, salvo com `no-scroll-lock`.
5232
+ * primeiro filho, marcado `data-ark-chrome`; um container `slot="actions"`
5233
+ * entra na linha dele por CSS, entre o título e o fechar. `side` escolhe a
5234
+ * borda, a direção do slide (com o easing `sheet`) e a borda desenhada;
5235
+ * `size` é um preset ou um comprimento CSS no eixo da gaveta. `open` é a fonte
5236
+ * da verdade, como no ark-dialog, e em overlay a página para de rolar
5237
+ * enquanto aberta, salvo com `no-scroll-lock`.
5153
5238
  */
5154
5239
  class ArkDrawer extends HTMLElementBase {
5155
5240
  static get observedAttributes() {
@@ -5174,6 +5259,10 @@ class ArkDrawer extends HTMLElementBase {
5174
5259
  this.titleEl = null;
5175
5260
  this.closeEl = null;
5176
5261
  this.observer = null;
5262
+ /** Mede o filho `slot="actions"`: a largura dele é o espaço que o título deixa livre na linha do cabeçalho. */
5263
+ this.actionsObserver = null;
5264
+ /** O filho `slot="actions"` que o actionsObserver mede. */
5265
+ this.observedActions = null;
5177
5266
  this.ownClasses = [];
5178
5267
  this.syncingClass = false;
5179
5268
  this.state = "closed";
@@ -5198,7 +5287,8 @@ class ArkDrawer extends HTMLElementBase {
5198
5287
  connectedCallback() {
5199
5288
  upgradeProperties(this);
5200
5289
  if (!this.observer) {
5201
- this.observer = new MutationObserver(() => this.syncFooter());
5290
+ // Rodapé e ações que chegam depois (frameworks) ganham o hook; as ações também mudam o cabeçalho.
5291
+ this.observer = new MutationObserver(() => this.updateAppearance());
5202
5292
  this.observer.observe(this, { childList: true });
5203
5293
  }
5204
5294
  this.updateAppearance();
@@ -5211,6 +5301,9 @@ class ArkDrawer extends HTMLElementBase {
5211
5301
  disconnectedCallback() {
5212
5302
  this.observer?.disconnect();
5213
5303
  this.observer = null;
5304
+ this.actionsObserver?.disconnect();
5305
+ this.actionsObserver = null;
5306
+ this.observedActions = null;
5214
5307
  this.releaseTrap?.();
5215
5308
  this.releaseTrap = null;
5216
5309
  unlockScroll(this);
@@ -5422,8 +5515,8 @@ class ArkDrawer extends HTMLElementBase {
5422
5515
  .split(/\s+/)
5423
5516
  .filter(Boolean);
5424
5517
  }
5425
- syncHeader(label, showClose) {
5426
- if (!label && !showClose) {
5518
+ syncHeader(label, showClose, withActions) {
5519
+ if (!label && !showClose && !withActions) {
5427
5520
  this.headerEl?.remove();
5428
5521
  this.headerEl = null;
5429
5522
  this.titleEl = null;
@@ -5436,8 +5529,14 @@ class ArkDrawer extends HTMLElementBase {
5436
5529
  this.prepend(header);
5437
5530
  this.headerEl = header;
5438
5531
  }
5439
- this.headerEl.className =
5440
- "ark:sticky ark:top-0 ark:z-10 ark:-mx-6 ark:flex ark:items-start ark:gap-4 ark:bg-surface ark:px-6 ark:pt-6 ark:pb-4";
5532
+ // As ações vêm antes do cabeçalho (order) e ocupam 3rem até o fim da linha do título: ele sobe por cima desse
5533
+ // espaço e guarda ao menos a altura dessa linha.
5534
+ this.headerEl.className = [
5535
+ "ark:sticky ark:top-0 ark:z-10 ark:-mx-6 ark:flex ark:items-start ark:gap-4 ark:bg-surface ark:px-6 ark:pt-6 ark:pb-4",
5536
+ withActions ? "ark:-mt-12 ark:min-h-16" : ""
5537
+ ]
5538
+ .join(" ")
5539
+ .trim();
5441
5540
  if (label) {
5442
5541
  if (!this.titleEl) {
5443
5542
  const title = document.createElement("h2");
@@ -5446,7 +5545,13 @@ class ArkDrawer extends HTMLElementBase {
5446
5545
  this.titleEl = title;
5447
5546
  }
5448
5547
  this.titleEl.textContent = label;
5449
- this.titleEl.className = "ark:min-w-0 ark:flex-1 ark:text-base ark:leading-6 ark:font-semibold ark:text-fg";
5548
+ // Com ações, o título deixa livre a largura medida delas mais o espaço entre as duas.
5549
+ this.titleEl.className = [
5550
+ "ark:min-w-0 ark:flex-1 ark:text-base ark:leading-6 ark:font-semibold ark:text-fg",
5551
+ withActions ? "ark:me-[calc(var(--ark-drawer-actions-width,0px)+1rem)]" : ""
5552
+ ]
5553
+ .join(" ")
5554
+ .trim();
5450
5555
  }
5451
5556
  else {
5452
5557
  this.titleEl?.remove();
@@ -5477,6 +5582,28 @@ class ArkDrawer extends HTMLElementBase {
5477
5582
  if (footer)
5478
5583
  applyTestHooks(this, "drawer", footer, "footer");
5479
5584
  }
5585
+ // Passa a medir o filho `slot="actions"` atual (ou nenhum). Sem ResizeObserver (SSR, jsdom) o título não reserva
5586
+ // a largura delas, só o espaço entre os dois.
5587
+ syncActions(actions) {
5588
+ if (actions)
5589
+ applyTestHooks(this, "drawer", actions, "actions");
5590
+ if (actions === this.observedActions)
5591
+ return;
5592
+ this.actionsObserver?.disconnect();
5593
+ this.observedActions = actions;
5594
+ if (!actions) {
5595
+ this.style.removeProperty("--ark-drawer-actions-width");
5596
+ return;
5597
+ }
5598
+ if (typeof ResizeObserver === "undefined")
5599
+ return;
5600
+ if (!this.actionsObserver) {
5601
+ this.actionsObserver = new ResizeObserver(() => {
5602
+ this.style.setProperty("--ark-drawer-actions-width", `${this.observedActions?.offsetWidth ?? 0}px`);
5603
+ });
5604
+ }
5605
+ this.actionsObserver.observe(actions);
5606
+ }
5480
5607
  applyOwnClasses(next) {
5481
5608
  this.syncingClass = true;
5482
5609
  for (const cls of this.ownClasses) {
@@ -5513,7 +5640,9 @@ class ArkDrawer extends HTMLElementBase {
5513
5640
  this.setAttribute("tabindex", "-1");
5514
5641
  this.setAttribute("data-ark-side", this.side);
5515
5642
  this.setAttribute("data-ark-mode", this.mode);
5516
- this.syncHeader(label, !this.hasAttribute("no-close-button"));
5643
+ const actions = this.querySelector(':scope > [slot="actions"]');
5644
+ this.syncHeader(label, !this.hasAttribute("no-close-button"), actions !== null);
5645
+ this.syncActions(actions);
5517
5646
  // Nome acessível: o título; sem ele um aria-label do usuário fica.
5518
5647
  if (label && this.titleEl) {
5519
5648
  this.setAttribute("aria-labelledby", this.titleId);
@@ -8206,7 +8335,7 @@ let nextId = 0;
8206
8335
  * silêncio e `change` dispara só no que ganhou a marca; as setas movem o foco
8207
8336
  * e marcam, Espaço marca o focado, e um único deles fica na ordem de Tab (o
8208
8337
  * marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
8209
- * opção como no ark-checkbox.
8338
+ * opção e `helper` a descreve, como no ark-checkbox.
8210
8339
  */
8211
8340
  class ArkRadio extends HTMLElementBase {
8212
8341
  static get observedAttributes() {
@@ -8216,6 +8345,7 @@ class ArkRadio extends HTMLElementBase {
8216
8345
  "name",
8217
8346
  "value",
8218
8347
  "label",
8348
+ "helper",
8219
8349
  "aria-label",
8220
8350
  "size",
8221
8351
  "intent",
@@ -8231,6 +8361,7 @@ class ArkRadio extends HTMLElementBase {
8231
8361
  this.boxEl = null;
8232
8362
  this.dotEl = null;
8233
8363
  this.labelEl = null;
8364
+ this.helperEl = null;
8234
8365
  this.inputEl = null;
8235
8366
  this.observer = null;
8236
8367
  /** Raiz do grupo no último connect, para ressincronizar os que ficam quando este sai. */
@@ -8451,11 +8582,11 @@ class ArkRadio extends HTMLElementBase {
8451
8582
  getSizing() {
8452
8583
  const size = (this.getAttribute("size") || "md").toLowerCase();
8453
8584
  const sizes = {
8454
- xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs" },
8455
- sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm" },
8456
- md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm" },
8457
- lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base" },
8458
- xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg" }
8585
+ xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs", helper: "ark:text-2xs" },
8586
+ sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm", helper: "ark:text-xs" },
8587
+ md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm", helper: "ark:text-xs" },
8588
+ lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base", helper: "ark:text-sm" },
8589
+ xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg", helper: "ark:text-base" }
8459
8590
  };
8460
8591
  return sizes[size] ?? sizes.md;
8461
8592
  }
@@ -8497,7 +8628,32 @@ class ArkRadio extends HTMLElementBase {
8497
8628
  }
8498
8629
  this.labelEl.htmlFor = this.boxEl?.id ?? "";
8499
8630
  this.labelEl.textContent = text;
8500
- this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
8631
+ this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
8632
+ }
8633
+ // Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a opção por aria-describedby.
8634
+ // Com ela o host vira grid (updateAppearance): a opção na primeira coluna, rótulo e dica empilhados na segunda.
8635
+ syncHelper(sizing) {
8636
+ if (!this.boxEl)
8637
+ return;
8638
+ const text = this.getAttribute("helper");
8639
+ if (!text) {
8640
+ this.helperEl?.remove();
8641
+ this.helperEl = null;
8642
+ this.boxEl.removeAttribute("aria-describedby");
8643
+ return;
8644
+ }
8645
+ if (!this.helperEl) {
8646
+ const helper = document.createElement("span");
8647
+ helper.setAttribute("data-ark-chrome", "helper");
8648
+ helper.id = `${this.boxEl.id}-helper`;
8649
+ (this.labelEl ?? this.inputEl)?.after(helper);
8650
+ this.helperEl = helper;
8651
+ }
8652
+ if (this.helperEl.textContent !== text)
8653
+ this.helperEl.textContent = text;
8654
+ // order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
8655
+ this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
8656
+ this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
8501
8657
  }
8502
8658
  syncName() {
8503
8659
  if (!this.boxEl)
@@ -8523,6 +8679,16 @@ class ArkRadio extends HTMLElementBase {
8523
8679
  this.boxEl.removeAttribute("aria-label");
8524
8680
  this.boxEl.removeAttribute("aria-labelledby");
8525
8681
  }
8682
+ // Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
8683
+ // nós ocultos).
8684
+ if (this.helperEl) {
8685
+ if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
8686
+ this.helperEl.setAttribute("aria-hidden", "true");
8687
+ }
8688
+ else {
8689
+ this.helperEl.removeAttribute("aria-hidden");
8690
+ }
8691
+ }
8526
8692
  }
8527
8693
  syncDot(checked, sizing) {
8528
8694
  if (!this.dotEl)
@@ -8558,9 +8724,18 @@ class ArkRadio extends HTMLElementBase {
8558
8724
  const sizing = this.getSizing();
8559
8725
  const checked = this.checked;
8560
8726
  const disabled = this.disabled;
8561
- this.applyOwnClasses("ark:inline-flex ark:cursor-pointer ark:items-center ark:gap-2 ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50".split(" "));
8727
+ // Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
8728
+ const layout = this.hasAttribute("helper")
8729
+ ? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
8730
+ : "ark:inline-flex ark:gap-2";
8731
+ this.applyOwnClasses([
8732
+ layout,
8733
+ "ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
8734
+ ]
8735
+ .join(" ")
8736
+ .split(" "));
8562
8737
  this.boxEl.className = [
8563
- "ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
8738
+ "ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
8564
8739
  palette.ring,
8565
8740
  sizing.box,
8566
8741
  checked ? palette.on : "ark:border-border-strong ark:bg-surface ark:text-transparent ark:hover:bg-surface-muted"
@@ -8569,6 +8744,7 @@ class ArkRadio extends HTMLElementBase {
8569
8744
  this.boxEl.disabled = disabled;
8570
8745
  this.syncDot(checked, sizing);
8571
8746
  this.syncLabel(sizing);
8747
+ this.syncHelper(sizing);
8572
8748
  this.syncName();
8573
8749
  this.inputEl.checked = checked;
8574
8750
  this.inputEl.disabled = disabled;
@@ -8579,6 +8755,8 @@ class ArkRadio extends HTMLElementBase {
8579
8755
  applyTestHooks(this, "radio", this.inputEl, "input");
8580
8756
  if (this.labelEl)
8581
8757
  applyTestHooks(this, "radio", this.labelEl, "label");
8758
+ if (this.helperEl)
8759
+ applyTestHooks(this, "radio", this.helperEl, "helper");
8582
8760
  }
8583
8761
  }
8584
8762
  ArkRadio.tagName = "ark-radio";