@tooark/web-components 1.0.0 → 1.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/dist/index.js CHANGED
@@ -1,5 +1,12 @@
1
1
  import { coerceBooleanAttr, arkExit, resolveLocale, announce, arkEnter, prefersReducedMotion, unlockScroll, openPopover, trapFocus, closePopover, positionAnchored, focusableElements, isPopoverOpen } from '@tooark/core';
2
2
 
3
+ // Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe
4
+ // HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a
5
+ // base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.
6
+ /** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */
7
+ const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
8
+ } : HTMLElement;
9
+
3
10
  const INTENTS = ["primary", "secondary", "success", "warning", "danger", "info", "neutral"];
4
11
  /** Devolve um ArkIntent válido a partir de um atributo, caindo no fallback quando não reconhece. */
5
12
  function normalizeIntent(value, fallback = "primary") {
@@ -72,7 +79,7 @@ const CLOSE_SVG$3 = `
72
79
  * anima a saída (slide-down, quick), emite `ark-dismiss` e esconde o host com
73
80
  * `hidden`; remover é do app, que também pode tirar o `hidden` para reexibir.
74
81
  */
75
- class ArkAlert extends HTMLElement {
82
+ class ArkAlert extends HTMLElementBase {
76
83
  constructor() {
77
84
  super(...arguments);
78
85
  this.ownClasses = [];
@@ -289,7 +296,7 @@ const PERSON_SVG = `
289
296
  * (`aria-hidden`, a menos que o host tenha aria-label próprio). `color` troca
290
297
  * o tint primary por uma cor própria (texto na cor, fundo suave).
291
298
  */
292
- class ArkAvatar extends HTMLElement {
299
+ class ArkAvatar extends HTMLElementBase {
293
300
  constructor() {
294
301
  super(...arguments);
295
302
  this.ownClasses = [];
@@ -473,7 +480,7 @@ ArkAvatar.tagName = "ark-avatar";
473
480
  * hooks): os filhos do usuário, ícone e texto, ficam onde estão. Não é
474
481
  * interativo; um badge clicável é um ark-button pequeno.
475
482
  */
476
- class ArkBadge extends HTMLElement {
483
+ class ArkBadge extends HTMLElementBase {
477
484
  constructor() {
478
485
  super(...arguments);
479
486
  this.ownClasses = [];
@@ -606,6 +613,18 @@ class ArkBadge extends HTMLElement {
606
613
  }
607
614
  ArkBadge.tagName = "ark-badge";
608
615
 
616
+ // Setters de propriedades que espelham um atributo de texto. React 19 e Vue gravam a prop como propriedade quando o
617
+ // elemento já registrado a expõe, então todo getter de atributo observado precisa de um setter que reflita o valor.
618
+ /** Grava `value` no atributo `name`; null/undefined removem o atributo. */
619
+ function reflectAttr(el, name, value) {
620
+ if (value === null || value === undefined) {
621
+ el.removeAttribute(name);
622
+ }
623
+ else {
624
+ el.setAttribute(name, String(value));
625
+ }
626
+ }
627
+
609
628
  /** SVG do spinner de carregamento: usa o preset `.ark-animate-spin` do core, isento de movimento reduzido. */
610
629
  const SPINNER_SVG$1 = `
611
630
  <svg class="ark:h-[1em] ark:w-[1em] ark-animate-spin" viewBox="0 0 24 24" fill="none" aria-hidden="true">
@@ -635,10 +654,10 @@ let arkButtonIdCounter = 0;
635
654
  * donos deles. Com `href`, um `<a>` "esticado" cobre o host, recebe o foco e
636
655
  * é nomeado pelo conteúdo do host (`aria-labelledby`).
637
656
  */
638
- class ArkButton extends HTMLElement {
657
+ class ArkButton extends HTMLElementBase {
639
658
  /**
640
- * Observa os atributos do elemento para reagir a mudanças.
641
- * @returns Uma lista de atributos observados pelo componente.
659
+ * Atributos observados pelo componente, a que ele reage em attributeChangedCallback.
660
+ * @returns Array de nomes de atributos observados.
642
661
  */
643
662
  static get observedAttributes() {
644
663
  return [
@@ -677,7 +696,7 @@ class ArkButton extends HTMLElement {
677
696
  // --- Interação ---
678
697
  /**
679
698
  * Manipula o clique no botão, tratando submissão e reset de formulários.
680
- * @param event Evento de clique no botão.
699
+ * @param event Evento de clique.
681
700
  */
682
701
  this.handleClick = (event) => {
683
702
  // Se o botão é um link ou do tipo "button", não faz nada.
@@ -709,7 +728,7 @@ class ArkButton extends HTMLElement {
709
728
  };
710
729
  /**
711
730
  * Manipula o pressionamento de tecla no botão, tratando Enter e Espaço.
712
- * @param event Evento de teclado no botão.
731
+ * @param event Evento de teclado.
713
732
  */
714
733
  this.handleKeydown = (event) => {
715
734
  // Se o botão é um link, não é o alvo do evento ou está desabilitado, não faz nada.
@@ -728,8 +747,7 @@ class ArkButton extends HTMLElement {
728
747
  };
729
748
  /**
730
749
  * Manipula o keyup no botão, tratando a tecla Espaço.
731
- * @param event Evento de teclado no botão.
732
- * @returns void
750
+ * @param event Evento de teclado.
733
751
  */
734
752
  this.handleKeyup = (event) => {
735
753
  // Se o botão é um link, não é o alvo do evento ou está desabilitado, não faz nada.
@@ -763,7 +781,9 @@ class ArkButton extends HTMLElement {
763
781
  }
764
782
  /**
765
783
  * Chamado pelo navegador quando um atributo observado do elemento é alterado.
766
- * @param name O nome do atributo que foi alterado.
784
+ * @param name Nome do atributo alterado.
785
+ * @param oldValue Valor antigo do atributo.
786
+ * @param newValue Novo valor do atributo.
767
787
  */
768
788
  attributeChangedCallback(name, oldValue, newValue) {
769
789
  // Se o atributo alterado for "class", reaplica apenas as classes próprias do componente.
@@ -863,6 +883,9 @@ class ArkButton extends HTMLElement {
863
883
  const type = this.getAttribute("type");
864
884
  return type === "submit" || type === "reset" ? type : "button";
865
885
  }
886
+ set type(value) {
887
+ reflectAttr(this, "type", value);
888
+ }
866
889
  /**
867
890
  * Formulário ao qual o botão pertence (via ElementInternals).
868
891
  */
@@ -871,8 +894,8 @@ class ArkButton extends HTMLElement {
871
894
  }
872
895
  // --- Estilo ---
873
896
  /**
874
- * Normaliza o valor do intent, garantindo que seja um dos valores válidos.
875
- * @param value Valor do intent.
897
+ * Normaliza o valor do intent, caindo em "primary" quando não é um dos valores válidos.
898
+ * @param value Valor do intent a ser normalizado.
876
899
  * @returns Intent normalizado.
877
900
  */
878
901
  normalizeIntent(value) {
@@ -890,8 +913,8 @@ class ArkButton extends HTMLElement {
890
913
  return "primary";
891
914
  }
892
915
  /**
893
- * Resolve a variante e o intent do botão com base nos atributos.
894
- * @returns Objeto contendo a variante de estilo e o intent.
916
+ * Resolve a variante de estilo e o intent do botão com base nos atributos.
917
+ * @returns Objeto contendo a variante de estilo (`styleVariant`) e o intent (`intent`) do botão.
895
918
  */
896
919
  resolveVariantAndIntent() {
897
920
  const variant = (this.getAttribute("variant") || "primary").toLowerCase();
@@ -909,7 +932,8 @@ class ArkButton extends HTMLElement {
909
932
  variant === "success" ||
910
933
  variant === "warning" ||
911
934
  variant === "danger" ||
912
- variant === "info") {
935
+ variant === "info" ||
936
+ variant === "neutral") {
913
937
  return {
914
938
  styleVariant: "solid",
915
939
  intent: this.normalizeIntent(attrIntent || variant)
@@ -1204,7 +1228,7 @@ ArkButton.formAssociated = true;
1204
1228
  * eventos por dia (`events` + `event-display`). O ark-datepicker embute este
1205
1229
  * componente (modo inline e no popup do modo input).
1206
1230
  */
1207
- class ArkCalendar extends HTMLElement {
1231
+ class ArkCalendar extends HTMLElementBase {
1208
1232
  constructor() {
1209
1233
  super(...arguments);
1210
1234
  this.root = null;
@@ -1217,6 +1241,8 @@ class ArkCalendar extends HTMLElement {
1217
1241
  this.eventsProp = null;
1218
1242
  /** Direção da navegação de mês por clique nas setas: dirige o slide do grid. */
1219
1243
  this.navDirection = null;
1244
+ /** Último período anunciado (título do cabeçalho); o primeiro build só registra, sem anunciar. */
1245
+ this.announcedPeriod = null;
1220
1246
  /** Última seleção feita pelo usuário: recebe um "pop" de entrada. */
1221
1247
  this.justSelectedISO = null;
1222
1248
  /** Navegação por teclado no grid (padrão WAI-ARIA de grade de datas). */
@@ -1310,6 +1336,12 @@ class ArkCalendar extends HTMLElement {
1310
1336
  return this.eventsProp ?? this.parseEventsAttr();
1311
1337
  }
1312
1338
  set events(list) {
1339
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
1340
+ if (typeof list === "string") {
1341
+ this.eventsProp = null;
1342
+ this.setAttribute("events", list);
1343
+ return;
1344
+ }
1313
1345
  this.eventsProp = Array.isArray(list) ? list : null;
1314
1346
  if (this.root)
1315
1347
  this.build();
@@ -1553,6 +1585,13 @@ class ArkCalendar extends HTMLElement {
1553
1585
  }
1554
1586
  return grid;
1555
1587
  }
1588
+ // A troca de período vai ao leitor de tela pelo anunciador do core: um aria-live no título entraria no nome do
1589
+ // controle e, recriado a cada build, nem seria anunciado.
1590
+ announcePeriod(text) {
1591
+ if (this.announcedPeriod !== null && this.announcedPeriod !== text)
1592
+ announce(text);
1593
+ this.announcedPeriod = text;
1594
+ }
1556
1595
  build() {
1557
1596
  if (!this.locale)
1558
1597
  this.locale = this.getLocale();
@@ -1628,7 +1667,6 @@ class ArkCalendar extends HTMLElement {
1628
1667
  title.type = "button";
1629
1668
  title.className = `${palette.headerText} ark:rounded ark:px-2 ark:py-0.5 ark:transition ark:hover:opacity-75 ark:focus:outline-none ark:focus:ring-2 ${palette.focusRing}`;
1630
1669
  applyTestHooks(this, "calendar", title, "title");
1631
- title.setAttribute("aria-live", "polite");
1632
1670
  if (this.view === "days") {
1633
1671
  title.textContent = `${loc.months[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;
1634
1672
  }
@@ -1639,6 +1677,7 @@ class ArkCalendar extends HTMLElement {
1639
1677
  const start = this.yearsBlockStart();
1640
1678
  title.textContent = `${start}–${start + 11}`;
1641
1679
  }
1680
+ this.announcePeriod(title.textContent);
1642
1681
  title.addEventListener("click", () => {
1643
1682
  this.view = this.view === "days" ? "months" : this.view === "months" ? "years" : "days";
1644
1683
  this.build();
@@ -1871,7 +1910,7 @@ ArkCalendar.tagName = "ark-calendar";
1871
1910
  * escala o espaçamento interno (padding do host e gap entre as linhas) e
1872
1911
  * `rounded` os cantos. Não é interativo e não tem role próprio.
1873
1912
  */
1874
- class ArkCard extends HTMLElement {
1913
+ class ArkCard extends HTMLElementBase {
1875
1914
  constructor() {
1876
1915
  super(...arguments);
1877
1916
  this.ownClasses = [];
@@ -1981,7 +2020,7 @@ const CHROME_ATTR = "data-ark-chrome";
1981
2020
  * Setas e dots vivem num overlay `position: sticky` (ver components.css).
1982
2021
  * Arrasto com mouse é emulado; touch/trackpad usam a rolagem nativa.
1983
2022
  */
1984
- class ArkCarousel extends HTMLElement {
2023
+ class ArkCarousel extends HTMLElementBase {
1985
2024
  static get observedAttributes() {
1986
2025
  return [
1987
2026
  "theme",
@@ -2010,6 +2049,7 @@ class ArkCarousel extends HTMLElement {
2010
2049
  this.currentIndex = 0;
2011
2050
  this.autoplayId = null;
2012
2051
  this.scrollTimer = null;
2052
+ this.mountFrame = null;
2013
2053
  this.observer = null;
2014
2054
  this.resizeObserver = null;
2015
2055
  this.ownClasses = [];
@@ -2110,14 +2150,21 @@ class ArkCarousel extends HTMLElement {
2110
2150
  });
2111
2151
  this.resizeObserver.observe(this);
2112
2152
  }
2113
- const startIndex = this.normalizeIndex(this.getStartIndex());
2114
- this.currentIndex = startIndex;
2115
- requestAnimationFrame(() => {
2116
- this.goTo(startIndex, { behavior: "auto" });
2153
+ this.currentIndex = this.normalizeIndex(this.getStartIndex());
2154
+ // O offsetLeft dos slides so existe depois do layout, entao o posicionamento inicial espera um frame. Ele parte
2155
+ // do indice ATUAL, nao do start-index: um next()/click no primeiro frame ja mudou o indice e disparou o evento, e
2156
+ // voltar ao inicio aqui deixava a rolagem suave seguir sozinha ate o slide, com um segundo ark-slide-change.
2157
+ this.mountFrame = requestAnimationFrame(() => {
2158
+ this.mountFrame = null;
2159
+ this.goTo(this.currentIndex, { behavior: "auto" });
2117
2160
  this.startAutoplay();
2118
2161
  });
2119
2162
  }
2120
2163
  disconnectedCallback() {
2164
+ if (this.mountFrame !== null) {
2165
+ cancelAnimationFrame(this.mountFrame);
2166
+ this.mountFrame = null;
2167
+ }
2121
2168
  this.stopAutoplay();
2122
2169
  this.observer?.disconnect();
2123
2170
  this.observer = null;
@@ -2456,7 +2503,7 @@ let nextId$1 = 0;
2456
2503
  * caixa por aria-labelledby e a alternam ao clique. Os nós próprios ficam no
2457
2504
  * início do host, marcados data-ark-chrome, antes dos filhos do usuário.
2458
2505
  */
2459
- class ArkCheckbox extends HTMLElement {
2506
+ class ArkCheckbox extends HTMLElementBase {
2460
2507
  static get observedAttributes() {
2461
2508
  return [
2462
2509
  "checked",
@@ -2778,7 +2825,7 @@ ArkCheckbox.tagName = "ark-checkbox";
2778
2825
  * (/segundo), no estilo DigitalClock do MUI. Valor sempre em 24h "HH:mm:ss";
2779
2826
  * `hours-format="12"` só muda a exibição (coluna AM/PM).
2780
2827
  */
2781
- class ArkClock extends HTMLElement {
2828
+ class ArkClock extends HTMLElementBase {
2782
2829
  constructor() {
2783
2830
  super(...arguments);
2784
2831
  this.root = null;
@@ -2804,7 +2851,7 @@ class ArkClock extends HTMLElement {
2804
2851
  };
2805
2852
  }
2806
2853
  static get observedAttributes() {
2807
- return ["value", "seconds", "step-minutes", "hours-format", "lang", "theme", "intent", "testid"];
2854
+ return ["value", "seconds", "step-minutes", "hours-format", "lang", "locale-json", "theme", "intent", "testid"];
2808
2855
  }
2809
2856
  connectedCallback() {
2810
2857
  this.build();
@@ -2824,6 +2871,9 @@ class ArkClock extends HTMLElement {
2824
2871
  get value() {
2825
2872
  return this.getAttribute("value") || "";
2826
2873
  }
2874
+ set value(value) {
2875
+ reflectAttr(this, "value", value);
2876
+ }
2827
2877
  getIntent() {
2828
2878
  const intent = (this.getAttribute("intent") || "").toLowerCase();
2829
2879
  if (intent === "primary" ||
@@ -2940,7 +2990,7 @@ class ArkClock extends HTMLElement {
2940
2990
  }
2941
2991
  build() {
2942
2992
  const palette = this.getPalette(this.getIntent());
2943
- const loc = resolveLocale((this.getAttribute("lang") || "en"), undefined);
2993
+ const loc = resolveLocale((this.getAttribute("lang") || "en"), this.getAttribute("locale-json") || undefined);
2944
2994
  this.root?.remove();
2945
2995
  this.columnEls.clear();
2946
2996
  const container = document.createElement("div");
@@ -3034,7 +3084,7 @@ ArkClock.tagName = "ark-clock";
3034
3084
  * movem e selecionam dando a volta, Home/End, Espaço seleciona. `change` só
3035
3085
  * quando a seleção muda pelo usuário.
3036
3086
  */
3037
- class ArkColorSwatches extends HTMLElement {
3087
+ class ArkColorSwatches extends HTMLElementBase {
3038
3088
  static get observedAttributes() {
3039
3089
  return ["value", "colors", "label", "aria-label", "disabled", "size", "theme", "class", "testid"];
3040
3090
  }
@@ -3108,6 +3158,12 @@ class ArkColorSwatches extends HTMLElement {
3108
3158
  }
3109
3159
  }
3110
3160
  set colors(list) {
3161
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
3162
+ if (typeof list === "string") {
3163
+ this.colorsProperty = null;
3164
+ this.setAttribute("colors", list);
3165
+ return;
3166
+ }
3111
3167
  this.colorsProperty = Array.isArray(list) ? list : null;
3112
3168
  if (this.isConnected)
3113
3169
  this.updateAppearance();
@@ -3230,7 +3286,7 @@ ArkColorSwatches.tagName = "ark-color-swatches";
3230
3286
  * filtro e do nome (padrão: o texto dos filhos sem slot). A paleta escreve
3231
3287
  * `id`, `hidden`, `aria-selected` e a ordem visual.
3232
3288
  */
3233
- class ArkCommandItem extends HTMLElement {
3289
+ class ArkCommandItem extends HTMLElementBase {
3234
3290
  static get observedAttributes() {
3235
3291
  return ["value", "group", "label", "disabled", "class", "testid"];
3236
3292
  }
@@ -3264,10 +3320,16 @@ class ArkCommandItem extends HTMLElement {
3264
3320
  get value() {
3265
3321
  return this.getAttribute("value") || "";
3266
3322
  }
3323
+ set value(value) {
3324
+ reflectAttr(this, "value", value);
3325
+ }
3267
3326
  /** Seção em que a paleta lista o item; vazio é sem grupo. */
3268
3327
  get group() {
3269
3328
  return (this.getAttribute("group") || "").trim();
3270
3329
  }
3330
+ set group(value) {
3331
+ reflectAttr(this, "group", value);
3332
+ }
3271
3333
  /** Texto usado no filtro e no nome da opção: `label`, senão o texto dos filhos sem slot. */
3272
3334
  get label() {
3273
3335
  const attr = this.getAttribute("label");
@@ -3280,6 +3342,9 @@ class ArkCommandItem extends HTMLElement {
3280
3342
  .replace(/\s+/g, " ")
3281
3343
  .trim();
3282
3344
  }
3345
+ set label(value) {
3346
+ reflectAttr(this, "label", value);
3347
+ }
3283
3348
  get disabled() {
3284
3349
  return this.hasAttribute("disabled");
3285
3350
  }
@@ -3345,7 +3410,7 @@ function normalize(text) {
3345
3410
  * Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
3346
3411
  * página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
3347
3412
  */
3348
- class ArkCommandPalette extends HTMLElement {
3413
+ class ArkCommandPalette extends HTMLElementBase {
3349
3414
  static get observedAttributes() {
3350
3415
  return [
3351
3416
  "open",
@@ -3371,6 +3436,8 @@ class ArkCommandPalette extends HTMLElement {
3371
3436
  this.ownClasses = [];
3372
3437
  this.syncingClass = false;
3373
3438
  this.state = "closed";
3439
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
3440
+ this.openingOnConnect = false;
3374
3441
  this.releaseTrap = null;
3375
3442
  this.queryTimer = null;
3376
3443
  this.activeId = null;
@@ -3483,12 +3550,16 @@ class ArkCommandPalette extends HTMLElement {
3483
3550
  if (!this.observer) {
3484
3551
  // Itens que entram ou saem (busca assíncrona, frameworks) reordenam a lista.
3485
3552
  this.observer = new MutationObserver(() => this.syncItems());
3486
- this.observer.observe(this, { childList: true });
3553
+ // subtree: o item de um wrapper de framework entra dentro do wrapper, não como filho da paleta.
3554
+ this.observer.observe(this, { childList: true, subtree: true });
3487
3555
  }
3488
3556
  document.addEventListener("keydown", this.handleHotkey);
3489
3557
  this.updateAppearance();
3490
- if (this.hasAttribute("open"))
3558
+ if (this.hasAttribute("open")) {
3559
+ this.openingOnConnect = true;
3491
3560
  this.openNow();
3561
+ this.openingOnConnect = false;
3562
+ }
3492
3563
  }
3493
3564
  disconnectedCallback() {
3494
3565
  this.observer?.disconnect();
@@ -3568,9 +3639,12 @@ class ArkCommandPalette extends HTMLElement {
3568
3639
  this.removeAttribute("open");
3569
3640
  }
3570
3641
  // --- Itens ---
3571
- /** Os ark-command-item filhos diretos, na ordem do DOM. */
3642
+ /**
3643
+ * Os ark-command-item desta paleta, na ordem do DOM. Descendentes, não só filhos: um wrapper de framework (o
3644
+ * `<ark-command-item-wrapper>` do Angular) fica entre a paleta e o item. Itens de uma paleta aninhada são dela.
3645
+ */
3572
3646
  items() {
3573
- return Array.from(this.querySelectorAll(":scope > ark-command-item")).filter((el) => el instanceof ArkCommandItem);
3647
+ return Array.from(this.querySelectorAll("ark-command-item")).filter((el) => el instanceof ArkCommandItem && el.closest("ark-command-palette") === this);
3574
3648
  }
3575
3649
  visibleItems() {
3576
3650
  return this.items().filter((item) => !item.hidden);
@@ -3617,13 +3691,17 @@ class ArkCommandPalette extends HTMLElement {
3617
3691
  }
3618
3692
  groups.forEach((group, index) => {
3619
3693
  const header = this.groupEls[index];
3620
- header.textContent = group;
3694
+ // Só escreve o que mudou: o observer (subtree) veria a troca do nó de texto e sincronizaria em laço.
3695
+ if (header.textContent !== group)
3696
+ header.textContent = group;
3621
3697
  header.style.order = String((index + 1) * 1000);
3622
3698
  applyTestHooks(this, "command-palette", header, "group");
3623
3699
  });
3624
3700
  this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
3625
3701
  this.emptyEl.hidden = visible.length > 0;
3626
- this.emptyEl.textContent = this.getLocale().noResults;
3702
+ const noResults = this.getLocale().noResults;
3703
+ if (this.emptyEl.textContent !== noResults)
3704
+ this.emptyEl.textContent = noResults;
3627
3705
  const enabled = visible.filter((item) => !item.disabled);
3628
3706
  if (!enabled.some((item) => item.id === this.activeId))
3629
3707
  this.activeId = enabled[0]?.id ?? null;
@@ -3686,7 +3764,17 @@ class ArkCommandPalette extends HTMLElement {
3686
3764
  });
3687
3765
  field?.select();
3688
3766
  this.inputEl?.inputElement?.setAttribute("aria-expanded", "true");
3689
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
3767
+ const emit = () => {
3768
+ if (this.state === "open")
3769
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
3770
+ };
3771
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
3772
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
3773
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
3774
+ if (this.openingOnConnect)
3775
+ queueMicrotask(emit);
3776
+ else
3777
+ emit();
3690
3778
  }
3691
3779
  closeNow() {
3692
3780
  if (this.state !== "open")
@@ -3779,7 +3867,8 @@ class ArkCommandPalette extends HTMLElement {
3779
3867
  this.inputEl.removeAttribute(attr);
3780
3868
  }
3781
3869
  }
3782
- this.emptyEl.textContent = locale.noResults;
3870
+ if (this.emptyEl.textContent !== locale.noResults)
3871
+ this.emptyEl.textContent = locale.noResults;
3783
3872
  applyTestHooks(this, "command-palette", this);
3784
3873
  applyTestHooks(this, "command-palette", this.inputEl, "input");
3785
3874
  applyTestHooks(this, "command-palette", this.listEl, "list");
@@ -4013,7 +4102,7 @@ const CALENDAR_ATTRS = [
4013
4102
  "events",
4014
4103
  "event-display"
4015
4104
  ];
4016
- const CLOCK_ATTRS = ["lang", "theme", "intent", "seconds", "step-minutes", "hours-format"];
4105
+ const CLOCK_ATTRS = ["lang", "locale-json", "theme", "intent", "seconds", "step-minutes", "hours-format"];
4017
4106
  const CALENDAR_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>`;
4018
4107
  const CLOCK_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`;
4019
4108
  /**
@@ -4031,7 +4120,7 @@ const CLOCK_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" heigh
4031
4120
  * core (abre abaixo, vira para cima sem espaço) e animado com `scale` a
4032
4121
  * partir da origem.
4033
4122
  */
4034
- class ArkDatepicker extends HTMLElement {
4123
+ class ArkDatepicker extends HTMLElementBase {
4035
4124
  constructor() {
4036
4125
  super(...arguments);
4037
4126
  this.calendarEl = null;
@@ -4039,6 +4128,8 @@ class ArkDatepicker extends HTMLElement {
4039
4128
  this.inputComp = null;
4040
4129
  this.toggleEl = null;
4041
4130
  this.popupEl = null;
4131
+ /** Calendário e/ou relógio: inline no host ou dentro do popup. */
4132
+ this.panelEl = null;
4042
4133
  /** Para de reposicionar o popup em scroll/resize; só existe enquanto aberto. */
4043
4134
  this.disposePosition = null;
4044
4135
  this.hiddenInputEl = null;
@@ -4154,6 +4245,9 @@ class ArkDatepicker extends HTMLElement {
4154
4245
  get value() {
4155
4246
  return this.getAttribute("value") || "";
4156
4247
  }
4248
+ set value(value) {
4249
+ reflectAttr(this, "value", value);
4250
+ }
4157
4251
  hasRendered() {
4158
4252
  return this.calendarEl !== null || this.clockEl !== null;
4159
4253
  }
@@ -4313,6 +4407,7 @@ class ArkDatepicker extends HTMLElement {
4313
4407
  this.inputComp = null;
4314
4408
  this.toggleEl = null;
4315
4409
  this.popupEl = null;
4410
+ this.panelEl = null;
4316
4411
  this.hiddenInputEl = null;
4317
4412
  }
4318
4413
  forwardAttr(target, name) {
@@ -4355,8 +4450,14 @@ class ArkDatepicker extends HTMLElement {
4355
4450
  }
4356
4451
  render() {
4357
4452
  const panel = this.buildPanel();
4453
+ this.panelEl = panel;
4454
+ // O valor vai ao formulário por um input oculto nos dois modos (inline também participa de <form>).
4455
+ const hidden = document.createElement("input");
4456
+ hidden.type = "hidden";
4457
+ this.hiddenInputEl = hidden;
4358
4458
  if (!this.isInputMode()) {
4359
4459
  this.appendChild(panel);
4460
+ this.appendChild(hidden);
4360
4461
  this.applyHooks();
4361
4462
  return;
4362
4463
  }
@@ -4409,8 +4510,6 @@ class ArkDatepicker extends HTMLElement {
4409
4510
  popup.setAttribute("popover", "manual");
4410
4511
  popup.setAttribute("role", "dialog");
4411
4512
  popup.appendChild(panel);
4412
- const hidden = document.createElement("input");
4413
- hidden.type = "hidden";
4414
4513
  wrapper.appendChild(inputComp);
4415
4514
  wrapper.appendChild(popup);
4416
4515
  this.appendChild(wrapper);
@@ -4418,7 +4517,6 @@ class ArkDatepicker extends HTMLElement {
4418
4517
  this.inputComp = inputComp;
4419
4518
  this.toggleEl = toggle;
4420
4519
  this.popupEl = popup;
4421
- this.hiddenInputEl = hidden;
4422
4520
  this.applyHooks();
4423
4521
  }
4424
4522
  applyHooks() {
@@ -4478,10 +4576,21 @@ class ArkDatepicker extends HTMLElement {
4478
4576
  }
4479
4577
  /** Sincroniza aparência/estado do campo com os atributos atuais. */
4480
4578
  syncField() {
4481
- if (!this.isInputMode() || !this.inputComp || !this.toggleEl || !this.hiddenInputEl || !this.popupEl)
4579
+ const disabled = this.hasAttribute("disabled");
4580
+ // Nos dois modos: o input oculto leva nome e valor ao formulário, e `disabled` tira os painéis de interação
4581
+ // (inline eles estão à vista; no modo input o campo e o botão também ficam desabilitados abaixo).
4582
+ if (this.hiddenInputEl) {
4583
+ this.hiddenInputEl.name = this.getAttribute("name") || "";
4584
+ this.hiddenInputEl.value = this.getAttribute("value") || "";
4585
+ this.hiddenInputEl.disabled = disabled;
4586
+ }
4587
+ if (this.panelEl) {
4588
+ this.panelEl.inert = disabled;
4589
+ this.panelEl.classList.toggle("ark:opacity-50", disabled);
4590
+ }
4591
+ if (!this.isInputMode() || !this.inputComp || !this.toggleEl || !this.popupEl)
4482
4592
  return;
4483
4593
  const loc = this.getLocale();
4484
- const disabled = this.hasAttribute("disabled");
4485
4594
  this.forwardAttr(this.inputComp, "theme");
4486
4595
  this.inputComp.setAttribute("placeholder", this.getAttribute("placeholder") || this.getFormat().toLowerCase());
4487
4596
  if (disabled) {
@@ -4497,9 +4606,6 @@ class ArkDatepicker extends HTMLElement {
4497
4606
  this.popupEl.setAttribute("aria-label", loc.openCalendar);
4498
4607
  this.inputComp.inputElement?.setAttribute("aria-haspopup", "dialog");
4499
4608
  this.inputComp.inputElement?.setAttribute("aria-expanded", this.popupOpen ? "true" : "false");
4500
- this.hiddenInputEl.name = this.getAttribute("name") || "";
4501
- this.hiddenInputEl.value = this.getAttribute("value") || "";
4502
- this.hiddenInputEl.disabled = disabled;
4503
4609
  this.updateInputDisplay();
4504
4610
  }
4505
4611
  updateInputDisplay() {
@@ -4625,7 +4731,7 @@ function cssLength$2(value) {
4625
4731
  * navegando por cursor virtual ainda alcança o conteúdo atrás. A página para
4626
4732
  * de rolar enquanto aberto (`lockScroll` de core), salvo com `no-scroll-lock`.
4627
4733
  */
4628
- class ArkDialog extends HTMLElement {
4734
+ class ArkDialog extends HTMLElementBase {
4629
4735
  static get observedAttributes() {
4630
4736
  return [
4631
4737
  "open",
@@ -4652,6 +4758,8 @@ class ArkDialog extends HTMLElement {
4652
4758
  this.syncingClass = false;
4653
4759
  /** Visibilidade real: `open` também cobre a animação de entrada; `closing` é a saída ainda visível. */
4654
4760
  this.state = "closed";
4761
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
4762
+ this.openingOnConnect = false;
4655
4763
  this.releaseTrap = null;
4656
4764
  /** Motivo pedido por `close(reason)`, lido quando o atributo `open` some. */
4657
4765
  this.pendingReason = null;
@@ -4677,8 +4785,11 @@ class ArkDialog extends HTMLElement {
4677
4785
  this.observer.observe(this, { childList: true });
4678
4786
  }
4679
4787
  this.updateAppearance();
4680
- if (this.hasAttribute("open"))
4788
+ if (this.hasAttribute("open")) {
4789
+ this.openingOnConnect = true;
4681
4790
  this.openNow();
4791
+ this.openingOnConnect = false;
4792
+ }
4682
4793
  }
4683
4794
  disconnectedCallback() {
4684
4795
  this.observer?.disconnect();
@@ -4768,7 +4879,17 @@ class ArkDialog extends HTMLElement {
4768
4879
  this.close("backdrop");
4769
4880
  }
4770
4881
  });
4771
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
4882
+ const emit = () => {
4883
+ if (this.state === "open")
4884
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
4885
+ };
4886
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
4887
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
4888
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
4889
+ if (this.openingOnConnect)
4890
+ queueMicrotask(emit);
4891
+ else
4892
+ emit();
4772
4893
  }
4773
4894
  closeNow(reason) {
4774
4895
  if (this.state !== "open")
@@ -4980,7 +5101,7 @@ function cssLength$1(value) {
4980
5101
  * verdade, como no ark-dialog, e em overlay a página para de rolar enquanto
4981
5102
  * aberta, salvo com `no-scroll-lock`.
4982
5103
  */
4983
- class ArkDrawer extends HTMLElement {
5104
+ class ArkDrawer extends HTMLElementBase {
4984
5105
  static get observedAttributes() {
4985
5106
  return [
4986
5107
  "open",
@@ -5006,6 +5127,8 @@ class ArkDrawer extends HTMLElement {
5006
5127
  this.ownClasses = [];
5007
5128
  this.syncingClass = false;
5008
5129
  this.state = "closed";
5130
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
5131
+ this.openingOnConnect = false;
5009
5132
  this.releaseTrap = null;
5010
5133
  this.pendingReason = null;
5011
5134
  this.warned = false;
@@ -5028,8 +5151,11 @@ class ArkDrawer extends HTMLElement {
5028
5151
  this.observer.observe(this, { childList: true });
5029
5152
  }
5030
5153
  this.updateAppearance();
5031
- if (this.hasAttribute("open"))
5154
+ if (this.hasAttribute("open")) {
5155
+ this.openingOnConnect = true;
5032
5156
  this.openNow();
5157
+ this.openingOnConnect = false;
5158
+ }
5033
5159
  }
5034
5160
  disconnectedCallback() {
5035
5161
  this.observer?.disconnect();
@@ -5093,10 +5219,16 @@ class ArkDrawer extends HTMLElement {
5093
5219
  const side = (this.getAttribute("side") || "").toLowerCase();
5094
5220
  return side === "left" || side === "top" || side === "bottom" ? side : "right";
5095
5221
  }
5222
+ set side(value) {
5223
+ reflectAttr(this, "side", value);
5224
+ }
5096
5225
  /** `overlay` (popover modal com scrim) ou `inline` (no fluxo, só anima). Padrão: "overlay". */
5097
5226
  get mode() {
5098
5227
  return (this.getAttribute("mode") || "").toLowerCase() === "inline" ? "inline" : "overlay";
5099
5228
  }
5229
+ set mode(value) {
5230
+ reflectAttr(this, "mode", value);
5231
+ }
5100
5232
  /** Abre a gaveta: adiciona `open`, que faz o resto. */
5101
5233
  show() {
5102
5234
  if (!this.open)
@@ -5145,7 +5277,17 @@ class ArkDrawer extends HTMLElement {
5145
5277
  animation.cancel();
5146
5278
  void arkEnter(this, this.preset(), { easing: "sheet" });
5147
5279
  }
5148
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
5280
+ const emit = () => {
5281
+ if (this.state === "open")
5282
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
5283
+ };
5284
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
5285
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
5286
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
5287
+ if (this.openingOnConnect)
5288
+ queueMicrotask(emit);
5289
+ else
5290
+ emit();
5149
5291
  }
5150
5292
  closeNow(reason) {
5151
5293
  if (this.state !== "open")
@@ -5347,7 +5489,7 @@ ArkDrawer.tagName = "ark-drawer";
5347
5489
  * `description`, em nós do componente ao fim do host. Filhos sem slot entram
5348
5490
  * entre a descrição e a ação. Não é interativo e não tem role próprio.
5349
5491
  */
5350
- class ArkEmpty extends HTMLElement {
5492
+ class ArkEmpty extends HTMLElementBase {
5351
5493
  constructor() {
5352
5494
  super(...arguments);
5353
5495
  this.ownClasses = [];
@@ -5466,7 +5608,7 @@ const UPLOAD_SVG = `
5466
5608
  * tela. O rótulo aponta para o input (associação nativa) e nomeia o botão
5467
5609
  * junto do próprio texto dele.
5468
5610
  */
5469
- class ArkFileInput extends HTMLElement {
5611
+ class ArkFileInput extends HTMLElementBase {
5470
5612
  constructor() {
5471
5613
  super(...arguments);
5472
5614
  this.inputEl = null;
@@ -5903,7 +6045,7 @@ let arkInputIdCounter = 0;
5903
6045
  * um botão de mostrar/ocultar na ponta direita. Atributos nativos como
5904
6046
  * `maxlength` ou `inputmode` são espelhados no <input> sem interpretação.
5905
6047
  */
5906
- class ArkInput extends HTMLElement {
6048
+ class ArkInput extends HTMLElementBase {
5907
6049
  constructor() {
5908
6050
  super(...arguments);
5909
6051
  this.inputEl = null;
@@ -6212,7 +6354,7 @@ ArkInput.tagName = "ark-input";
6212
6354
  * usuário. Não é interativo e não tem role próprio; para leitores de tela é
6213
6355
  * texto comum, como um <kbd>.
6214
6356
  */
6215
- class ArkKbd extends HTMLElement {
6357
+ class ArkKbd extends HTMLElementBase {
6216
6358
  constructor() {
6217
6359
  super(...arguments);
6218
6360
  this.ownClasses = [];
@@ -6334,7 +6476,7 @@ function cloneRow(row) {
6334
6476
  * adicionar e remover anunciam a contagem ao leitor de tela. A célula de
6335
6477
  * valor é um ark-input comum: autocomplete de variáveis fica no app.
6336
6478
  */
6337
- class ArkKvEditor extends HTMLElement {
6479
+ class ArkKvEditor extends HTMLElementBase {
6338
6480
  static get observedAttributes() {
6339
6481
  return [
6340
6482
  "rows",
@@ -6430,6 +6572,11 @@ class ArkKvEditor extends HTMLElement {
6430
6572
  return this.model.map((row) => ({ ...row }));
6431
6573
  }
6432
6574
  set rows(value) {
6575
+ // Uma string é o JSON do atributo (React 19 e Vue gravam a prop como propriedade): segue o caminho do atributo.
6576
+ if (typeof value === "string") {
6577
+ this.setAttribute("rows", value);
6578
+ return;
6579
+ }
6433
6580
  this.model = Array.isArray(value) ? value.map(cloneRow) : [];
6434
6581
  this.resetRows();
6435
6582
  if (this.isConnected)
@@ -6807,9 +6954,11 @@ class ArkKvEditor extends HTMLElement {
6807
6954
  input.toggleAttribute("readonly", readonly);
6808
6955
  applyTestHooks(this, "kv-editor", input, name);
6809
6956
  }
6810
- // Campo de valor: senha com o olho quando é segredo; senão o tipo da linha (number, date...) ou texto.
6957
+ // Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
6958
+ const rowType = types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
6959
+ // Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto.
6811
6960
  const isSecret = withSecret && row.secret === true;
6812
- parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[row.type ?? ""] ?? "text"));
6961
+ parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
6813
6962
  parts.value.toggleAttribute("reveal", isSecret);
6814
6963
  if (parts.secret) {
6815
6964
  parts.secret.setAttribute("aria-label", locale.secret);
@@ -6827,9 +6976,8 @@ class ArkKvEditor extends HTMLElement {
6827
6976
  }
6828
6977
  if (parts.type) {
6829
6978
  parts.type.options = types.map((type) => ({ value: type, label: type }));
6830
- const current = row.type && types.includes(row.type) ? row.type : types[0];
6831
- if (parts.type.value !== current)
6832
- parts.type.value = current;
6979
+ if (rowType && parts.type.value !== rowType)
6980
+ parts.type.value = rowType;
6833
6981
  parts.type.setAttribute("aria-label", locale.type);
6834
6982
  parts.type.setAttribute("size", size);
6835
6983
  parts.type.toggleAttribute("disabled", readonly);
@@ -6988,7 +7136,7 @@ function cssLength(value) {
6988
7136
  * nomeado; sem ele é decorativo (`aria-hidden`): o texto ao lado é o que
6989
7137
  * conta.
6990
7138
  */
6991
- class ArkMark extends HTMLElement {
7139
+ class ArkMark extends HTMLElementBase {
6992
7140
  constructor() {
6993
7141
  super(...arguments);
6994
7142
  this.ownClasses = [];
@@ -7093,7 +7241,7 @@ let menuSeq = 0;
7093
7241
  * a saída são transições CSS em components.css, porque o light dismiss de um
7094
7242
  * popover auto não pode ser interceptado por JS para animar antes de esconder.
7095
7243
  */
7096
- class ArkMenu extends HTMLElement {
7244
+ class ArkMenu extends HTMLElementBase {
7097
7245
  static get observedAttributes() {
7098
7246
  return ["for", "open", "align", "direction", "size", "theme", "class", "testid"];
7099
7247
  }
@@ -7264,6 +7412,11 @@ class ArkMenu extends HTMLElement {
7264
7412
  }
7265
7413
  set open(value) {
7266
7414
  const next = coerceBooleanAttr(value);
7415
+ // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
7416
+ if (!this.isConnected) {
7417
+ this.toggleAttribute("open", next);
7418
+ return;
7419
+ }
7267
7420
  if (next) {
7268
7421
  this.show();
7269
7422
  }
@@ -7481,7 +7634,7 @@ const CHECK_SVG$1 = `
7481
7634
  * item. Seleção, foco e teclado são coordenados pelo ark-menu; `size` e
7482
7635
  * `theme` chegam propagados dele.
7483
7636
  */
7484
- class ArkMenuItem extends HTMLElement {
7637
+ class ArkMenuItem extends HTMLElementBase {
7485
7638
  static get observedAttributes() {
7486
7639
  return ["value", "disabled", "intent", "divider", "checked", "static", "size", "theme", "class", "testid"];
7487
7640
  }
@@ -7525,6 +7678,9 @@ class ArkMenuItem extends HTMLElement {
7525
7678
  get value() {
7526
7679
  return this.getAttribute("value") || "";
7527
7680
  }
7681
+ set value(value) {
7682
+ reflectAttr(this, "value", value);
7683
+ }
7528
7684
  get disabled() {
7529
7685
  return this.hasAttribute("disabled");
7530
7686
  }
@@ -7536,6 +7692,11 @@ class ArkMenuItem extends HTMLElement {
7536
7692
  return this.hasAttribute("checked") && this.getAttribute("checked") !== "false";
7537
7693
  }
7538
7694
  set checked(value) {
7695
+ // Três estados: null/undefined voltam a item comum (React tira a prop assim); false desmarca o checkbox.
7696
+ if (value === null || value === undefined) {
7697
+ this.removeAttribute("checked");
7698
+ return;
7699
+ }
7539
7700
  this.setAttribute("checked", coerceBooleanAttr(value) ? "" : "false");
7540
7701
  }
7541
7702
  /** Item selecionável (não é divisor nem conteúdo estático). */
@@ -7701,7 +7862,7 @@ ArkMenuItem.tagName = "ark-menu-item";
7701
7862
  * loop, com duração fixa e isento de movimento reduzido, como o spinner: é o
7702
7863
  * único sinal de progresso.
7703
7864
  */
7704
- class ArkProgress extends HTMLElement {
7865
+ class ArkProgress extends HTMLElementBase {
7705
7866
  constructor() {
7706
7867
  super(...arguments);
7707
7868
  this.ownClasses = [];
@@ -7886,7 +8047,7 @@ let nextId = 0;
7886
8047
  * marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
7887
8048
  * opção como no ark-checkbox.
7888
8049
  */
7889
- class ArkRadio extends HTMLElement {
8050
+ class ArkRadio extends HTMLElementBase {
7890
8051
  static get observedAttributes() {
7891
8052
  return [
7892
8053
  "checked",
@@ -8341,7 +8502,7 @@ const DEFAULT_EVENT_MINUTES = 60;
8341
8502
  * eventos são o conteúdo: clicar num evento emite `ark-event-click` e clicar num
8342
8503
  * espaço livre emite `ark-slot-click` (útil para criar um evento).
8343
8504
  */
8344
- class ArkScheduler extends HTMLElement {
8505
+ class ArkScheduler extends HTMLElementBase {
8345
8506
  constructor() {
8346
8507
  super(...arguments);
8347
8508
  this.root = null;
@@ -8350,6 +8511,8 @@ class ArkScheduler extends HTMLElement {
8350
8511
  this.refDate = new Date();
8351
8512
  this.nowTimer = null;
8352
8513
  this.navDirection = null;
8514
+ /** Último período anunciado (título do cabeçalho); o primeiro build só registra, sem anunciar. */
8515
+ this.announcedPeriod = null;
8353
8516
  this.syncingAttr = false;
8354
8517
  /** Linhas de "agora" vivas na tela: reposicionadas sem rebuild a cada minuto. */
8355
8518
  this.nowLines = [];
@@ -8405,6 +8568,12 @@ class ArkScheduler extends HTMLElement {
8405
8568
  return this.eventsProp ?? this.parseEventsAttr();
8406
8569
  }
8407
8570
  set events(list) {
8571
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
8572
+ if (typeof list === "string") {
8573
+ this.eventsProp = null;
8574
+ this.setAttribute("events", list);
8575
+ return;
8576
+ }
8408
8577
  this.eventsProp = Array.isArray(list) ? list : null;
8409
8578
  if (this.root)
8410
8579
  this.build();
@@ -8421,6 +8590,9 @@ class ArkScheduler extends HTMLElement {
8421
8590
  get date() {
8422
8591
  return formatISODate(this.refDate);
8423
8592
  }
8593
+ set date(value) {
8594
+ reflectAttr(this, "date", value);
8595
+ }
8424
8596
  parseEventsAttr() {
8425
8597
  const raw = this.getAttribute("events");
8426
8598
  if (!raw)
@@ -8684,8 +8856,8 @@ class ArkScheduler extends HTMLElement {
8684
8856
  applyTestHooks(this, "scheduler", nextBtn, "next");
8685
8857
  const title = document.createElement("h2");
8686
8858
  title.className = `${palette.headerText} ark:ml-1`;
8687
- title.setAttribute("aria-live", "polite");
8688
8859
  title.textContent = this.getTitle();
8860
+ this.announcePeriod(title.textContent);
8689
8861
  applyTestHooks(this, "scheduler", title, "title");
8690
8862
  left.appendChild(todayBtn);
8691
8863
  left.appendChild(prevBtn);
@@ -8719,6 +8891,8 @@ class ArkScheduler extends HTMLElement {
8719
8891
  return;
8720
8892
  this.setAttribute("view", detail.value);
8721
8893
  this.dispatchEvent(new CustomEvent("ark-view-change", { detail: { view: detail.value }, bubbles: true, composed: true }));
8894
+ // Outra view mostra outro intervalo (a semana vira o mês): quem carrega eventos por período precisa saber.
8895
+ this.emitRangeChange();
8722
8896
  });
8723
8897
  header.appendChild(left);
8724
8898
  header.appendChild(group);
@@ -8974,6 +9148,7 @@ class ArkScheduler extends HTMLElement {
8974
9148
  this.syncDateAttr();
8975
9149
  this.setAttribute("view", "day");
8976
9150
  this.dispatchEvent(new CustomEvent("ark-view-change", { detail: { view: "day" }, bubbles: true, composed: true }));
9151
+ this.emitRangeChange();
8977
9152
  });
8978
9153
  cell.appendChild(more);
8979
9154
  }
@@ -9065,6 +9240,13 @@ class ArkScheduler extends HTMLElement {
9065
9240
  line.style.top = `${((nowMinutes - hourStart * 60) / totalMinutes) * bodyHeight}px`;
9066
9241
  }
9067
9242
  }
9243
+ // A troca de período vai ao leitor de tela pelo anunciador do core: um aria-live no título entraria no nome do
9244
+ // controle e, recriado a cada build, nem seria anunciado.
9245
+ announcePeriod(text) {
9246
+ if (this.announcedPeriod !== null && this.announcedPeriod !== text)
9247
+ announce(text);
9248
+ this.announcedPeriod = text;
9249
+ }
9068
9250
  build() {
9069
9251
  if (!this.locale)
9070
9252
  this.locale = this.getLocale();
@@ -9120,7 +9302,7 @@ let arkSelectIdCounter = 0;
9120
9302
  * propriedade JS), nunca de filhos: o <select> exige os <option> dentro dele
9121
9303
  * e a lib não move filhos do usuário.
9122
9304
  */
9123
- class ArkSelect extends HTMLElement {
9305
+ class ArkSelect extends HTMLElementBase {
9124
9306
  constructor() {
9125
9307
  super(...arguments);
9126
9308
  this.selectEl = null;
@@ -9426,7 +9608,7 @@ const SHAPE_LABEL = {
9426
9608
  * e nomeada pelo nome localizado da forma. Mesmo teclado do
9427
9609
  * ark-color-swatches. `change` só quando a seleção muda pelo usuário.
9428
9610
  */
9429
- class ArkShapePicker extends HTMLElement {
9611
+ class ArkShapePicker extends HTMLElementBase {
9430
9612
  static get observedAttributes() {
9431
9613
  return [
9432
9614
  "value",
@@ -9640,7 +9822,7 @@ const RADIUS = {
9640
9822
  * substitui o skeleton
9641
9823
  * entra com `.ark-animate-fade-in`, sem elemento próprio para isso.
9642
9824
  */
9643
- class ArkSkeleton extends HTMLElement {
9825
+ class ArkSkeleton extends HTMLElementBase {
9644
9826
  constructor() {
9645
9827
  super(...arguments);
9646
9828
  this.ownClasses = [];
@@ -9792,7 +9974,7 @@ const SPINNER_SVG = `
9792
9974
  * string `loading` do idioma). Gira sempre, inclusive sob movimento reduzido:
9793
9975
  * é o único sinal de progresso. Sem `intent` herda a cor do texto ao redor.
9794
9976
  */
9795
- class ArkSpinner extends HTMLElement {
9977
+ class ArkSpinner extends HTMLElementBase {
9796
9978
  constructor() {
9797
9979
  super(...arguments);
9798
9980
  this.ownClasses = [];
@@ -9901,7 +10083,7 @@ const BIG_STEP = 10;
9901
10083
  * reescrito a cada mudança) e `ark-resize` publica os tamanhos; persistir é
9902
10084
  * do app. Nada anima: redimensionar é interação de alta frequência.
9903
10085
  */
9904
- class ArkSplitPane extends HTMLElement {
10086
+ class ArkSplitPane extends HTMLElementBase {
9905
10087
  constructor() {
9906
10088
  super(...arguments);
9907
10089
  this.handles = [];
@@ -10012,7 +10194,8 @@ class ArkSplitPane extends HTMLElement {
10012
10194
  return this.normalizedSizes(this.panels().length);
10013
10195
  }
10014
10196
  set sizes(value) {
10015
- this.setAttribute("sizes", value.map((size) => String(size)).join(","));
10197
+ // React 19 e Vue entregam aqui a string do atributo ("30,70") quando a prop vem do wrapper.
10198
+ this.setAttribute("sizes", typeof value === "string" ? value : value.map((size) => String(size)).join(","));
10016
10199
  }
10017
10200
  // --- Painéis e medidas ---
10018
10201
  /** Os filhos do usuário: tudo que não é chrome do componente. */
@@ -10198,7 +10381,7 @@ ArkSplitPane.tagName = "ark-split-pane";
10198
10381
  * (`aria-hidden`), para o texto ao lado ser o que conta. Estático por
10199
10382
  * design: nunca pulsa.
10200
10383
  */
10201
- class ArkStatusDot extends HTMLElement {
10384
+ class ArkStatusDot extends HTMLElementBase {
10202
10385
  constructor() {
10203
10386
  super(...arguments);
10204
10387
  this.ownClasses = [];
@@ -10289,7 +10472,7 @@ const CROSS_SVG = '<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" st
10289
10472
  * submetendo `name`/`value` apenas quando marcado. Tem tabela de proporções
10290
10473
  * própria, em vez da escala de altura dos demais controles.
10291
10474
  */
10292
- class ArkSwitch extends HTMLElement {
10475
+ class ArkSwitch extends HTMLElementBase {
10293
10476
  constructor() {
10294
10477
  super(...arguments);
10295
10478
  this.trackEl = null;
@@ -10594,7 +10777,7 @@ const CLOSE_SVG = `
10594
10777
  * Seleção e roving tabindex são coordenados pelo ark-tabs; `variant`,
10595
10778
  * `size`, `intent`, `theme` e idioma chegam propagados dele.
10596
10779
  */
10597
- class ArkTab extends HTMLElement {
10780
+ class ArkTab extends HTMLElementBase {
10598
10781
  static get observedAttributes() {
10599
10782
  return [
10600
10783
  "value",
@@ -10674,6 +10857,9 @@ class ArkTab extends HTMLElement {
10674
10857
  get value() {
10675
10858
  return this.getAttribute("value") || "";
10676
10859
  }
10860
+ set value(value) {
10861
+ reflectAttr(this, "value", value);
10862
+ }
10677
10863
  /** Aba ativa; o ark-tabs reflete aqui o seu `value`. */
10678
10864
  get selected() {
10679
10865
  return this.hasAttribute("selected");
@@ -10697,6 +10883,9 @@ class ArkTab extends HTMLElement {
10697
10883
  get closable() {
10698
10884
  return this.hasAttribute("closable") && this.getVariant() === "editor";
10699
10885
  }
10886
+ set closable(value) {
10887
+ this.toggleAttribute("closable", coerceBooleanAttr(value));
10888
+ }
10700
10889
  /** Pede a seleção desta aba: emite `change` com o valor, que o ark-tabs consolida. */
10701
10890
  select() {
10702
10891
  if (this.disabled || this.selected)
@@ -10947,7 +11136,7 @@ const PROPAGATED_ATTRS = ["variant", "size", "intent", "rounded", "fill", "theme
10947
11136
  * inserido de uma vez o grupo pode rodar antes de as abas serem upgraded, e
10948
11137
  * uma propriedade escrita antes do upgrade esconderia o accessor da classe.
10949
11138
  */
10950
- class ArkTabs extends HTMLElement {
11139
+ class ArkTabs extends HTMLElementBase {
10951
11140
  static get observedAttributes() {
10952
11141
  return [
10953
11142
  "value",
@@ -11180,7 +11369,7 @@ let arkTextareaIdCounter = 0;
11180
11369
  * (`field-sizing: content` nativo, com fallback por JS), `monospace` e
11181
11370
  * `resize` atendem edição de código e de dados.
11182
11371
  */
11183
- class ArkTextarea extends HTMLElement {
11372
+ class ArkTextarea extends HTMLElementBase {
11184
11373
  constructor() {
11185
11374
  super(...arguments);
11186
11375
  this.textareaEl = null;
@@ -11388,7 +11577,7 @@ ArkTextarea.tagName = "ark-textarea";
11388
11577
  * dialogs e menus, e é reaberta a cada toast novo para voltar ao topo da
11389
11578
  * pilha do top layer quando um overlay abriu depois dela.
11390
11579
  */
11391
- class ArkToaster extends HTMLElement {
11580
+ class ArkToaster extends HTMLElementBase {
11392
11581
  constructor() {
11393
11582
  super(...arguments);
11394
11583
  this.root = null;
@@ -11424,6 +11613,9 @@ class ArkToaster extends HTMLElement {
11424
11613
  this.timers.clear();
11425
11614
  }
11426
11615
  attributeChangedCallback() {
11616
+ // Posição, rich-colors, close-button, lang e testid mudam os cards já montados: recria todos (sem reanimar a
11617
+ // entrada, que `entered` lembra).
11618
+ this.root?.replaceChildren();
11427
11619
  this.render();
11428
11620
  }
11429
11621
  toast(options) {
@@ -11434,16 +11626,14 @@ class ArkToaster extends HTMLElement {
11434
11626
  createdAt: Date.now(),
11435
11627
  type: options.type || "default"
11436
11628
  };
11437
- this.toasts = [item, ...this.toasts.filter((toast) => toast.id !== id)];
11438
- const maxVisible = this.getMaxVisible();
11439
- if (this.toasts.length > maxVisible) {
11440
- const removed = this.toasts.slice(maxVisible);
11441
- this.toasts = this.toasts.slice(0, maxVisible);
11442
- for (const toast of removed) {
11443
- this.clearTimer(toast.id);
11444
- }
11629
+ // Mesmo id: o card antigo sai e o toast volta ao topo como um novo.
11630
+ if (this.toasts.some((toast) => toast.id === id)) {
11631
+ this.cardOf(id)?.remove();
11632
+ this.entered.delete(id);
11445
11633
  }
11446
- this.scheduleDismiss(item);
11634
+ this.toasts = [item, ...this.toasts.filter((toast) => toast.id !== id)];
11635
+ // O render agenda o fechamento dos visíveis; o mesmo id recomeça a contagem.
11636
+ this.clearTimer(id);
11447
11637
  this.render();
11448
11638
  // Um overlay aberto depois da pilha ficaria por cima dela: reentrar no top layer a põe acima de novo.
11449
11639
  this.raise();
@@ -11465,7 +11655,7 @@ class ArkToaster extends HTMLElement {
11465
11655
  this.toasts = this.toasts.filter((toast) => toast.id !== id);
11466
11656
  this.render();
11467
11657
  };
11468
- const card = this.root?.querySelector(`[data-toast-id="${id}"]`);
11658
+ const card = this.cardOf(id);
11469
11659
  if (card) {
11470
11660
  this.exiting.add(id);
11471
11661
  arkExit(card, this.getExitPreset()).then(finalize);
@@ -11474,6 +11664,9 @@ class ArkToaster extends HTMLElement {
11474
11664
  finalize();
11475
11665
  }
11476
11666
  }
11667
+ cardOf(id) {
11668
+ return this.root?.querySelector(`[data-toast-id="${CSS.escape(id)}"]`) ?? null;
11669
+ }
11477
11670
  getPosition() {
11478
11671
  const position = (this.getAttribute("position") || "bottom-right").toLowerCase();
11479
11672
  if (position === "top-left" ||
@@ -11631,101 +11824,126 @@ class ArkToaster extends HTMLElement {
11631
11824
  }
11632
11825
  this.render();
11633
11826
  }
11827
+ // Incremental: os cards da lista ficam onde estão (recriar um card focado jogaria o foco do teclado no body e
11828
+ // o leitor de tela perderia o toast que estava lendo, e um card em saída perderia a animação), os que saíram da
11829
+ // lista vão embora e só os novos são criados, cada um na posição da lista (o mais novo no topo).
11634
11830
  render() {
11635
11831
  if (!this.root)
11636
11832
  return;
11637
- const position = this.getPosition();
11638
- const richColors = this.hasRichColors();
11639
- const closeButton = this.hasCloseButton();
11640
11833
  const palette = this.getPalette();
11641
- this.root.className = `${palette.stack} ${this.getPositionClasses(position)}`;
11642
- this.root.innerHTML = "";
11834
+ this.root.className = `${palette.stack} ${this.getPositionClasses(this.getPosition())}`;
11643
11835
  applyTestHooks(this, "toaster", this.root);
11644
11836
  this.syncPopover();
11645
- const activeIds = new Set(this.toasts.map((toast) => toast.id));
11837
+ // Até max-visible cards; o excedente (os mais antigos) espera na fila com o relógio parado e entra quando um sai.
11838
+ const visible = this.toasts.slice(0, this.getMaxVisible());
11839
+ const activeIds = new Set(visible.map((toast) => toast.id));
11840
+ for (const toast of this.toasts) {
11841
+ if (!activeIds.has(toast.id)) {
11842
+ this.clearTimer(toast.id);
11843
+ }
11844
+ else if (!this.timers.has(toast.id) && !this.exiting.has(toast.id)) {
11845
+ this.scheduleDismiss(toast);
11846
+ }
11847
+ }
11646
11848
  for (const id of this.entered) {
11647
11849
  if (!activeIds.has(id))
11648
11850
  this.entered.delete(id);
11649
11851
  }
11650
- for (const toast of this.toasts) {
11651
- const card = document.createElement("section");
11652
- card.setAttribute("part", "toast");
11653
- card.dataset.toastId = toast.id;
11654
- // Cada card compartilha o hook "toaster-toast"; desambigue via data-toast-id.
11655
- applyTestHooks(this, "toaster", card, "toast");
11656
- card.className = `${palette.toastBase} ${this.getToastTypeClasses(toast.type, richColors)}`.trim();
11657
- const row = document.createElement("div");
11658
- row.className = "ark:flex ark:items-start ark:gap-3";
11659
- const icon = document.createElement("span");
11660
- icon.className = `${palette.icon} ark:mt-0.5 ark:inline-flex ark:h-5 ark:w-5 ark:items-center ark:justify-center ark:rounded-full ark:border ark:border-current/20`;
11661
- icon.textContent = this.getToastIcon(toast.type);
11662
- const content = document.createElement("div");
11663
- content.className = "ark:min-w-0 ark:flex-1";
11664
- const title = document.createElement("h4");
11665
- title.className = palette.title;
11666
- applyTestHooks(this, "toaster", title, "toast-title");
11667
- title.textContent = toast.title;
11668
- content.appendChild(title);
11669
- if (toast.description) {
11670
- const description = document.createElement("p");
11671
- description.className = palette.description;
11672
- applyTestHooks(this, "toaster", description, "toast-description");
11673
- description.textContent = toast.description;
11674
- content.appendChild(description);
11675
- }
11676
- row.appendChild(icon);
11677
- row.appendChild(content);
11678
- if (closeButton) {
11679
- const close = document.createElement("button");
11680
- close.type = "button";
11681
- close.className = palette.closeButton;
11682
- applyTestHooks(this, "toaster", close, "toast-close");
11683
- close.textContent = this.getCloseLabel();
11684
- close.addEventListener("click", () => this.dismiss(toast.id));
11685
- row.appendChild(close);
11686
- }
11687
- card.appendChild(row);
11688
- if (toast.actionLabel || toast.cancelLabel) {
11689
- const actions = document.createElement("div");
11690
- actions.className = "ark:mt-3 ark:flex ark:items-center ark:justify-end ark:gap-2";
11691
- if (toast.cancelLabel) {
11692
- const cancel = document.createElement("button");
11693
- cancel.type = "button";
11694
- cancel.className = palette.cancelButton;
11695
- applyTestHooks(this, "toaster", cancel, "toast-cancel");
11696
- cancel.textContent = toast.cancelLabel;
11697
- cancel.addEventListener("click", () => this.dismiss(toast.id));
11698
- actions.appendChild(cancel);
11699
- }
11700
- if (toast.actionLabel) {
11701
- const action = document.createElement("button");
11702
- action.type = "button";
11703
- action.className = palette.actionButton;
11704
- applyTestHooks(this, "toaster", action, "toast-action");
11705
- action.textContent = toast.actionLabel;
11706
- action.addEventListener("click", () => {
11707
- this.dispatchEvent(new CustomEvent("ark-toast-action", {
11708
- detail: { id: toast.id, actionId: toast.actionId || null },
11709
- bubbles: true,
11710
- composed: true
11711
- }));
11712
- this.dismiss(toast.id);
11713
- });
11714
- actions.appendChild(action);
11715
- }
11716
- card.appendChild(actions);
11852
+ const existing = new Map();
11853
+ for (const card of Array.from(this.root.querySelectorAll("[data-toast-id]"))) {
11854
+ const id = card.dataset.toastId ?? "";
11855
+ if (activeIds.has(id)) {
11856
+ existing.set(id, card);
11717
11857
  }
11718
- this.root.appendChild(card);
11719
- if (this.exiting.has(toast.id)) {
11720
- // Re-render durante uma saída em andamento: mantém o card oculto
11721
- card.style.opacity = "0";
11722
- card.style.pointerEvents = "none";
11858
+ else {
11859
+ card.remove();
11723
11860
  }
11724
- else if (!this.entered.has(toast.id)) {
11725
- this.entered.add(toast.id);
11726
- arkEnter(card, this.getEnterPreset());
11861
+ }
11862
+ // Do mais antigo (fim da pilha) ao mais novo: um card novo entra antes do card do toast seguinte na lista.
11863
+ let next = null;
11864
+ for (let index = visible.length - 1; index >= 0; index--) {
11865
+ const toast = visible[index];
11866
+ let card = existing.get(toast.id);
11867
+ if (!card) {
11868
+ card = this.buildCard(toast, palette);
11869
+ this.root.insertBefore(card, next);
11870
+ if (!this.entered.has(toast.id)) {
11871
+ this.entered.add(toast.id);
11872
+ arkEnter(card, this.getEnterPreset());
11873
+ }
11874
+ }
11875
+ next = card;
11876
+ }
11877
+ }
11878
+ buildCard(toast, palette) {
11879
+ const card = document.createElement("section");
11880
+ card.setAttribute("part", "toast");
11881
+ card.dataset.toastId = toast.id;
11882
+ // Cada card compartilha o hook "toaster-toast"; desambigue via data-toast-id.
11883
+ applyTestHooks(this, "toaster", card, "toast");
11884
+ card.className = `${palette.toastBase} ${this.getToastTypeClasses(toast.type, this.hasRichColors())}`.trim();
11885
+ const row = document.createElement("div");
11886
+ row.className = "ark:flex ark:items-start ark:gap-3";
11887
+ const icon = document.createElement("span");
11888
+ icon.className = `${palette.icon} ark:mt-0.5 ark:inline-flex ark:h-5 ark:w-5 ark:items-center ark:justify-center ark:rounded-full ark:border ark:border-current/20`;
11889
+ icon.textContent = this.getToastIcon(toast.type);
11890
+ const content = document.createElement("div");
11891
+ content.className = "ark:min-w-0 ark:flex-1";
11892
+ const title = document.createElement("h4");
11893
+ title.className = palette.title;
11894
+ applyTestHooks(this, "toaster", title, "toast-title");
11895
+ title.textContent = toast.title;
11896
+ content.appendChild(title);
11897
+ if (toast.description) {
11898
+ const description = document.createElement("p");
11899
+ description.className = palette.description;
11900
+ applyTestHooks(this, "toaster", description, "toast-description");
11901
+ description.textContent = toast.description;
11902
+ content.appendChild(description);
11903
+ }
11904
+ row.appendChild(icon);
11905
+ row.appendChild(content);
11906
+ if (this.hasCloseButton()) {
11907
+ const close = document.createElement("button");
11908
+ close.type = "button";
11909
+ close.className = palette.closeButton;
11910
+ applyTestHooks(this, "toaster", close, "toast-close");
11911
+ close.textContent = this.getCloseLabel();
11912
+ close.addEventListener("click", () => this.dismiss(toast.id));
11913
+ row.appendChild(close);
11914
+ }
11915
+ card.appendChild(row);
11916
+ if (toast.actionLabel || toast.cancelLabel) {
11917
+ const actions = document.createElement("div");
11918
+ actions.className = "ark:mt-3 ark:flex ark:items-center ark:justify-end ark:gap-2";
11919
+ if (toast.cancelLabel) {
11920
+ const cancel = document.createElement("button");
11921
+ cancel.type = "button";
11922
+ cancel.className = palette.cancelButton;
11923
+ applyTestHooks(this, "toaster", cancel, "toast-cancel");
11924
+ cancel.textContent = toast.cancelLabel;
11925
+ cancel.addEventListener("click", () => this.dismiss(toast.id));
11926
+ actions.appendChild(cancel);
11927
+ }
11928
+ if (toast.actionLabel) {
11929
+ const action = document.createElement("button");
11930
+ action.type = "button";
11931
+ action.className = palette.actionButton;
11932
+ applyTestHooks(this, "toaster", action, "toast-action");
11933
+ action.textContent = toast.actionLabel;
11934
+ action.addEventListener("click", () => {
11935
+ this.dispatchEvent(new CustomEvent("ark-toast-action", {
11936
+ detail: { id: toast.id, actionId: toast.actionId || null },
11937
+ bubbles: true,
11938
+ composed: true
11939
+ }));
11940
+ this.dismiss(toast.id);
11941
+ });
11942
+ actions.appendChild(action);
11727
11943
  }
11944
+ card.appendChild(actions);
11728
11945
  }
11946
+ return card;
11729
11947
  }
11730
11948
  }
11731
11949
  ArkToaster.tagName = "ark-toaster";
@@ -11735,7 +11953,7 @@ ArkToaster.tagName = "ark-toaster";
11735
11953
  * (classes, role, foco, teclado): os filhos do usuário ficam onde estão.
11736
11954
  * Dentro de um ark-toggle-group vira item de segmented control.
11737
11955
  */
11738
- class ArkToggle extends HTMLElement {
11956
+ class ArkToggle extends HTMLElementBase {
11739
11957
  static get observedAttributes() {
11740
11958
  return ["pressed", "disabled", "size", "intent", "theme", "value", "class", "testid"];
11741
11959
  }
@@ -11802,6 +12020,9 @@ class ArkToggle extends HTMLElement {
11802
12020
  get value() {
11803
12021
  return this.getAttribute("value") || "";
11804
12022
  }
12023
+ set value(value) {
12024
+ reflectAttr(this, "value", value);
12025
+ }
11805
12026
  toggle() {
11806
12027
  if (this.disabled)
11807
12028
  return;
@@ -11930,7 +12151,7 @@ ArkToggle.tagName = "ark-toggle";
11930
12151
  * (`role="group"` + classes): os itens do usuário ficam onde estão, então
11931
12152
  * frameworks podem adicionar/remover toggles livremente.
11932
12153
  */
11933
- class ArkToggleGroup extends HTMLElement {
12154
+ class ArkToggleGroup extends HTMLElementBase {
11934
12155
  static get observedAttributes() {
11935
12156
  return ["value", "multiple", "disabled", "size", "intent", "theme", "class", "testid"];
11936
12157
  }
@@ -12047,8 +12268,11 @@ class ArkToggleGroup extends HTMLElement {
12047
12268
  if (theme)
12048
12269
  toggle.setAttribute("theme", theme);
12049
12270
  if (disabled) {
12050
- toggle.setAttribute("disabled", "");
12051
- toggle.dataset.groupDisabled = "true";
12271
+ // Um item já desabilitado por conta própria não leva a marca do grupo, senão ela apagaria o individual.
12272
+ if (!toggle.hasAttribute("disabled")) {
12273
+ toggle.setAttribute("disabled", "");
12274
+ toggle.dataset.groupDisabled = "true";
12275
+ }
12052
12276
  }
12053
12277
  else if (toggle.dataset.groupDisabled) {
12054
12278
  // Só remove o "disabled" que o próprio grupo aplicou; preserva o individual.
@@ -12083,6 +12307,8 @@ ArkToggleGroup.tagName = "ark-toggle-group";
12083
12307
 
12084
12308
  /** Contador para o id do balão, que o `aria-describedby` do gatilho referencia. */
12085
12309
  let tooltipSeq = 0;
12310
+ /** Tolerância para o ponteiro atravessar o espaço entre gatilho e balão sem fechar a dica. */
12311
+ const HIDE_GRACE_MS = 100;
12086
12312
  /**
12087
12313
  * Dica de contexto. O host envolve o gatilho do usuário (primeiro filho sem
12088
12314
  * `slot`) sem movê-lo e cria o balão: `role="tooltip"` com `popover="manual"`,
@@ -12092,11 +12318,12 @@ let tooltipSeq = 0;
12092
12318
  * components.css). O gatilho recebe `aria-describedby` do balão e precisa ser
12093
12319
  * focável por conta própria.
12094
12320
  *
12095
- * Abre em hover (depois de `delay`) e em foco (na hora); fecha ao sair, ao
12096
- * perder o foco, com Esc e no pointerdown. Posicionado por `positionAnchored`
12321
+ * Abre em hover (depois de `delay`) e em foco (na hora); fecha ao sair (com
12322
+ * uma tolerância para o ponteiro chegar ao balão, que mantém a dica aberta),
12323
+ * ao perder o foco, com Esc e no pointerdown. Posicionado por `positionAnchored`
12097
12324
  * de core, com flip quando não cabe. Entrada `fade` quick, sem saída animada.
12098
12325
  */
12099
- class ArkTooltip extends HTMLElement {
12326
+ class ArkTooltip extends HTMLElementBase {
12100
12327
  static get observedAttributes() {
12101
12328
  return ["content", "side", "delay", "open", "theme", "class", "testid"];
12102
12329
  }
@@ -12111,6 +12338,7 @@ class ArkTooltip extends HTMLElement {
12111
12338
  this.bubble = null;
12112
12339
  this.trigger = null;
12113
12340
  this.openTimer = null;
12341
+ this.hideTimer = null;
12114
12342
  this.disposePosition = null;
12115
12343
  this.isOpen = false;
12116
12344
  this.syncingOpen = false;
@@ -12120,12 +12348,14 @@ class ArkTooltip extends HTMLElement {
12120
12348
  this.handlePointerOver = (event) => {
12121
12349
  if (this.isInside(event.relatedTarget))
12122
12350
  return;
12351
+ // Voltou (ao gatilho ou ao balão) dentro da tolerância: a dica fica.
12352
+ this.cancelHide();
12123
12353
  this.scheduleShow();
12124
12354
  };
12125
12355
  this.handlePointerOut = (event) => {
12126
12356
  if (this.isInside(event.relatedTarget))
12127
12357
  return;
12128
- this.hide();
12358
+ this.scheduleHide();
12129
12359
  };
12130
12360
  // Clicar no gatilho dispensa a dica; ela volta só depois de sair e entrar de novo.
12131
12361
  this.handlePointerDown = () => {
@@ -12178,6 +12408,7 @@ class ArkTooltip extends HTMLElement {
12178
12408
  this.observer?.disconnect();
12179
12409
  this.observer = null;
12180
12410
  this.clearTimer();
12411
+ this.cancelHide();
12181
12412
  document.removeEventListener("keydown", this.handleDocumentKeydown, true);
12182
12413
  this.disposePosition?.();
12183
12414
  this.disposePosition = null;
@@ -12213,6 +12444,11 @@ class ArkTooltip extends HTMLElement {
12213
12444
  }
12214
12445
  set open(value) {
12215
12446
  const next = coerceBooleanAttr(value);
12447
+ // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
12448
+ if (!this.isConnected) {
12449
+ this.toggleAttribute("open", next);
12450
+ return;
12451
+ }
12216
12452
  if (next) {
12217
12453
  this.show();
12218
12454
  }
@@ -12237,6 +12473,7 @@ class ArkTooltip extends HTMLElement {
12237
12473
  /** Fecha na hora, sem animação de saída. */
12238
12474
  hide() {
12239
12475
  this.clearTimer();
12476
+ this.cancelHide();
12240
12477
  if (!this.isOpen)
12241
12478
  return;
12242
12479
  this.isOpen = false;
@@ -12280,6 +12517,21 @@ class ArkTooltip extends HTMLElement {
12280
12517
  this.openTimer = null;
12281
12518
  }
12282
12519
  }
12520
+ cancelHide() {
12521
+ if (this.hideTimer !== null) {
12522
+ clearTimeout(this.hideTimer);
12523
+ this.hideTimer = null;
12524
+ }
12525
+ }
12526
+ scheduleHide() {
12527
+ this.clearTimer();
12528
+ if (!this.isOpen || this.hideTimer !== null)
12529
+ return;
12530
+ this.hideTimer = setTimeout(() => {
12531
+ this.hideTimer = null;
12532
+ this.hide();
12533
+ }, HIDE_GRACE_MS);
12534
+ }
12283
12535
  scheduleShow() {
12284
12536
  if (this.isOpen || this.openTimer !== null)
12285
12537
  return;
@@ -12344,7 +12596,6 @@ class ArkTooltip extends HTMLElement {
12344
12596
  if (!this.ownBubble) {
12345
12597
  const bubble = document.createElement("div");
12346
12598
  bubble.setAttribute("data-ark-chrome", "bubble");
12347
- bubble.className = "ark:pointer-events-none";
12348
12599
  this.appendChild(bubble);
12349
12600
  this.ownBubble = bubble;
12350
12601
  }
@@ -12404,6 +12655,9 @@ ArkTooltip.tagName = "ark-tooltip";
12404
12655
  * para garantir que eles estejam disponíveis como elementos personalizados.
12405
12656
  */
12406
12657
  function registerTooarkComponents() {
12658
+ // Fora do navegador (SSR) não há registro de elementos: no-op, e o cliente registra na hidratação.
12659
+ if (typeof customElements === "undefined")
12660
+ return;
12407
12661
  if (!customElements.get(ArkAlert.tagName)) {
12408
12662
  customElements.define(ArkAlert.tagName, ArkAlert);
12409
12663
  }
@@ -12536,5 +12790,5 @@ function registerTooarkComponents() {
12536
12790
  }
12537
12791
  }
12538
12792
 
12539
- export { ArkBadge, ArkButton, ArkCalendar, ArkCarousel, ArkClock, ArkDatepicker, ArkDialog, ArkEmpty, ArkInput, ArkMenu, ArkMenuItem, ArkScheduler, ArkSelect, ArkSkeleton, ArkSwitch, ArkTab, ArkTabs, ArkTextarea, ArkToaster, ArkToggle, ArkToggleGroup, ArkTooltip, registerTooarkComponents };
12793
+ export { ARK_MARK_PATHS, ARK_MARK_SHAPES, ArkAlert, ArkAvatar, ArkBadge, ArkButton, ArkCalendar, ArkCard, ArkCarousel, ArkCheckbox, ArkClock, ArkColorSwatches, ArkCommandItem, ArkCommandPalette, ArkCopyButton, ArkDatepicker, ArkDialog, ArkDrawer, ArkEmpty, ArkFileInput, ArkInput, ArkKbd, ArkKvEditor, ArkMark, ArkMenu, ArkMenuItem, ArkProgress, ArkRadio, ArkScheduler, ArkSelect, ArkShapePicker, ArkSkeleton, ArkSpinner, ArkSplitPane, ArkStatusDot, ArkSwitch, ArkTab, ArkTabs, ArkTextarea, ArkToaster, ArkToggle, ArkToggleGroup, ArkTooltip, normalizeMarkShape, registerTooarkComponents };
12540
12794
  //# sourceMappingURL=index.js.map