@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.cjs CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  var core = require('@tooark/core');
4
4
 
5
+ // Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe
6
+ // HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a
7
+ // base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.
8
+ /** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */
9
+ const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
10
+ } : HTMLElement;
11
+
5
12
  const INTENTS = ["primary", "secondary", "success", "warning", "danger", "info", "neutral"];
6
13
  /** Devolve um ArkIntent válido a partir de um atributo, caindo no fallback quando não reconhece. */
7
14
  function normalizeIntent(value, fallback = "primary") {
@@ -74,7 +81,7 @@ const CLOSE_SVG$3 = `
74
81
  * anima a saída (slide-down, quick), emite `ark-dismiss` e esconde o host com
75
82
  * `hidden`; remover é do app, que também pode tirar o `hidden` para reexibir.
76
83
  */
77
- class ArkAlert extends HTMLElement {
84
+ class ArkAlert extends HTMLElementBase {
78
85
  constructor() {
79
86
  super(...arguments);
80
87
  this.ownClasses = [];
@@ -291,7 +298,7 @@ const PERSON_SVG = `
291
298
  * (`aria-hidden`, a menos que o host tenha aria-label próprio). `color` troca
292
299
  * o tint primary por uma cor própria (texto na cor, fundo suave).
293
300
  */
294
- class ArkAvatar extends HTMLElement {
301
+ class ArkAvatar extends HTMLElementBase {
295
302
  constructor() {
296
303
  super(...arguments);
297
304
  this.ownClasses = [];
@@ -475,7 +482,7 @@ ArkAvatar.tagName = "ark-avatar";
475
482
  * hooks): os filhos do usuário, ícone e texto, ficam onde estão. Não é
476
483
  * interativo; um badge clicável é um ark-button pequeno.
477
484
  */
478
- class ArkBadge extends HTMLElement {
485
+ class ArkBadge extends HTMLElementBase {
479
486
  constructor() {
480
487
  super(...arguments);
481
488
  this.ownClasses = [];
@@ -608,6 +615,18 @@ class ArkBadge extends HTMLElement {
608
615
  }
609
616
  ArkBadge.tagName = "ark-badge";
610
617
 
618
+ // Setters de propriedades que espelham um atributo de texto. React 19 e Vue gravam a prop como propriedade quando o
619
+ // elemento já registrado a expõe, então todo getter de atributo observado precisa de um setter que reflita o valor.
620
+ /** Grava `value` no atributo `name`; null/undefined removem o atributo. */
621
+ function reflectAttr(el, name, value) {
622
+ if (value === null || value === undefined) {
623
+ el.removeAttribute(name);
624
+ }
625
+ else {
626
+ el.setAttribute(name, String(value));
627
+ }
628
+ }
629
+
611
630
  /** SVG do spinner de carregamento: usa o preset `.ark-animate-spin` do core, isento de movimento reduzido. */
612
631
  const SPINNER_SVG$1 = `
613
632
  <svg class="ark:h-[1em] ark:w-[1em] ark-animate-spin" viewBox="0 0 24 24" fill="none" aria-hidden="true">
@@ -637,10 +656,10 @@ let arkButtonIdCounter = 0;
637
656
  * donos deles. Com `href`, um `<a>` "esticado" cobre o host, recebe o foco e
638
657
  * é nomeado pelo conteúdo do host (`aria-labelledby`).
639
658
  */
640
- class ArkButton extends HTMLElement {
659
+ class ArkButton extends HTMLElementBase {
641
660
  /**
642
- * Observa os atributos do elemento para reagir a mudanças.
643
- * @returns Uma lista de atributos observados pelo componente.
661
+ * Atributos observados pelo componente, a que ele reage em attributeChangedCallback.
662
+ * @returns Array de nomes de atributos observados.
644
663
  */
645
664
  static get observedAttributes() {
646
665
  return [
@@ -679,7 +698,7 @@ class ArkButton extends HTMLElement {
679
698
  // --- Interação ---
680
699
  /**
681
700
  * Manipula o clique no botão, tratando submissão e reset de formulários.
682
- * @param event Evento de clique no botão.
701
+ * @param event Evento de clique.
683
702
  */
684
703
  this.handleClick = (event) => {
685
704
  // Se o botão é um link ou do tipo "button", não faz nada.
@@ -711,7 +730,7 @@ class ArkButton extends HTMLElement {
711
730
  };
712
731
  /**
713
732
  * Manipula o pressionamento de tecla no botão, tratando Enter e Espaço.
714
- * @param event Evento de teclado no botão.
733
+ * @param event Evento de teclado.
715
734
  */
716
735
  this.handleKeydown = (event) => {
717
736
  // Se o botão é um link, não é o alvo do evento ou está desabilitado, não faz nada.
@@ -730,8 +749,7 @@ class ArkButton extends HTMLElement {
730
749
  };
731
750
  /**
732
751
  * Manipula o keyup no botão, tratando a tecla Espaço.
733
- * @param event Evento de teclado no botão.
734
- * @returns void
752
+ * @param event Evento de teclado.
735
753
  */
736
754
  this.handleKeyup = (event) => {
737
755
  // Se o botão é um link, não é o alvo do evento ou está desabilitado, não faz nada.
@@ -765,7 +783,9 @@ class ArkButton extends HTMLElement {
765
783
  }
766
784
  /**
767
785
  * Chamado pelo navegador quando um atributo observado do elemento é alterado.
768
- * @param name O nome do atributo que foi alterado.
786
+ * @param name Nome do atributo alterado.
787
+ * @param oldValue Valor antigo do atributo.
788
+ * @param newValue Novo valor do atributo.
769
789
  */
770
790
  attributeChangedCallback(name, oldValue, newValue) {
771
791
  // Se o atributo alterado for "class", reaplica apenas as classes próprias do componente.
@@ -865,6 +885,9 @@ class ArkButton extends HTMLElement {
865
885
  const type = this.getAttribute("type");
866
886
  return type === "submit" || type === "reset" ? type : "button";
867
887
  }
888
+ set type(value) {
889
+ reflectAttr(this, "type", value);
890
+ }
868
891
  /**
869
892
  * Formulário ao qual o botão pertence (via ElementInternals).
870
893
  */
@@ -873,8 +896,8 @@ class ArkButton extends HTMLElement {
873
896
  }
874
897
  // --- Estilo ---
875
898
  /**
876
- * Normaliza o valor do intent, garantindo que seja um dos valores válidos.
877
- * @param value Valor do intent.
899
+ * Normaliza o valor do intent, caindo em "primary" quando não é um dos valores válidos.
900
+ * @param value Valor do intent a ser normalizado.
878
901
  * @returns Intent normalizado.
879
902
  */
880
903
  normalizeIntent(value) {
@@ -892,8 +915,8 @@ class ArkButton extends HTMLElement {
892
915
  return "primary";
893
916
  }
894
917
  /**
895
- * Resolve a variante e o intent do botão com base nos atributos.
896
- * @returns Objeto contendo a variante de estilo e o intent.
918
+ * Resolve a variante de estilo e o intent do botão com base nos atributos.
919
+ * @returns Objeto contendo a variante de estilo (`styleVariant`) e o intent (`intent`) do botão.
897
920
  */
898
921
  resolveVariantAndIntent() {
899
922
  const variant = (this.getAttribute("variant") || "primary").toLowerCase();
@@ -911,7 +934,8 @@ class ArkButton extends HTMLElement {
911
934
  variant === "success" ||
912
935
  variant === "warning" ||
913
936
  variant === "danger" ||
914
- variant === "info") {
937
+ variant === "info" ||
938
+ variant === "neutral") {
915
939
  return {
916
940
  styleVariant: "solid",
917
941
  intent: this.normalizeIntent(attrIntent || variant)
@@ -1206,7 +1230,7 @@ ArkButton.formAssociated = true;
1206
1230
  * eventos por dia (`events` + `event-display`). O ark-datepicker embute este
1207
1231
  * componente (modo inline e no popup do modo input).
1208
1232
  */
1209
- class ArkCalendar extends HTMLElement {
1233
+ class ArkCalendar extends HTMLElementBase {
1210
1234
  constructor() {
1211
1235
  super(...arguments);
1212
1236
  this.root = null;
@@ -1219,6 +1243,8 @@ class ArkCalendar extends HTMLElement {
1219
1243
  this.eventsProp = null;
1220
1244
  /** Direção da navegação de mês por clique nas setas: dirige o slide do grid. */
1221
1245
  this.navDirection = null;
1246
+ /** Último período anunciado (título do cabeçalho); o primeiro build só registra, sem anunciar. */
1247
+ this.announcedPeriod = null;
1222
1248
  /** Última seleção feita pelo usuário: recebe um "pop" de entrada. */
1223
1249
  this.justSelectedISO = null;
1224
1250
  /** Navegação por teclado no grid (padrão WAI-ARIA de grade de datas). */
@@ -1312,6 +1338,12 @@ class ArkCalendar extends HTMLElement {
1312
1338
  return this.eventsProp ?? this.parseEventsAttr();
1313
1339
  }
1314
1340
  set events(list) {
1341
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
1342
+ if (typeof list === "string") {
1343
+ this.eventsProp = null;
1344
+ this.setAttribute("events", list);
1345
+ return;
1346
+ }
1315
1347
  this.eventsProp = Array.isArray(list) ? list : null;
1316
1348
  if (this.root)
1317
1349
  this.build();
@@ -1555,6 +1587,13 @@ class ArkCalendar extends HTMLElement {
1555
1587
  }
1556
1588
  return grid;
1557
1589
  }
1590
+ // A troca de período vai ao leitor de tela pelo anunciador do core: um aria-live no título entraria no nome do
1591
+ // controle e, recriado a cada build, nem seria anunciado.
1592
+ announcePeriod(text) {
1593
+ if (this.announcedPeriod !== null && this.announcedPeriod !== text)
1594
+ core.announce(text);
1595
+ this.announcedPeriod = text;
1596
+ }
1558
1597
  build() {
1559
1598
  if (!this.locale)
1560
1599
  this.locale = this.getLocale();
@@ -1630,7 +1669,6 @@ class ArkCalendar extends HTMLElement {
1630
1669
  title.type = "button";
1631
1670
  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}`;
1632
1671
  applyTestHooks(this, "calendar", title, "title");
1633
- title.setAttribute("aria-live", "polite");
1634
1672
  if (this.view === "days") {
1635
1673
  title.textContent = `${loc.months[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;
1636
1674
  }
@@ -1641,6 +1679,7 @@ class ArkCalendar extends HTMLElement {
1641
1679
  const start = this.yearsBlockStart();
1642
1680
  title.textContent = `${start}–${start + 11}`;
1643
1681
  }
1682
+ this.announcePeriod(title.textContent);
1644
1683
  title.addEventListener("click", () => {
1645
1684
  this.view = this.view === "days" ? "months" : this.view === "months" ? "years" : "days";
1646
1685
  this.build();
@@ -1873,7 +1912,7 @@ ArkCalendar.tagName = "ark-calendar";
1873
1912
  * escala o espaçamento interno (padding do host e gap entre as linhas) e
1874
1913
  * `rounded` os cantos. Não é interativo e não tem role próprio.
1875
1914
  */
1876
- class ArkCard extends HTMLElement {
1915
+ class ArkCard extends HTMLElementBase {
1877
1916
  constructor() {
1878
1917
  super(...arguments);
1879
1918
  this.ownClasses = [];
@@ -1983,7 +2022,7 @@ const CHROME_ATTR = "data-ark-chrome";
1983
2022
  * Setas e dots vivem num overlay `position: sticky` (ver components.css).
1984
2023
  * Arrasto com mouse é emulado; touch/trackpad usam a rolagem nativa.
1985
2024
  */
1986
- class ArkCarousel extends HTMLElement {
2025
+ class ArkCarousel extends HTMLElementBase {
1987
2026
  static get observedAttributes() {
1988
2027
  return [
1989
2028
  "theme",
@@ -2012,6 +2051,7 @@ class ArkCarousel extends HTMLElement {
2012
2051
  this.currentIndex = 0;
2013
2052
  this.autoplayId = null;
2014
2053
  this.scrollTimer = null;
2054
+ this.mountFrame = null;
2015
2055
  this.observer = null;
2016
2056
  this.resizeObserver = null;
2017
2057
  this.ownClasses = [];
@@ -2112,14 +2152,21 @@ class ArkCarousel extends HTMLElement {
2112
2152
  });
2113
2153
  this.resizeObserver.observe(this);
2114
2154
  }
2115
- const startIndex = this.normalizeIndex(this.getStartIndex());
2116
- this.currentIndex = startIndex;
2117
- requestAnimationFrame(() => {
2118
- this.goTo(startIndex, { behavior: "auto" });
2155
+ this.currentIndex = this.normalizeIndex(this.getStartIndex());
2156
+ // O offsetLeft dos slides so existe depois do layout, entao o posicionamento inicial espera um frame. Ele parte
2157
+ // do indice ATUAL, nao do start-index: um next()/click no primeiro frame ja mudou o indice e disparou o evento, e
2158
+ // voltar ao inicio aqui deixava a rolagem suave seguir sozinha ate o slide, com um segundo ark-slide-change.
2159
+ this.mountFrame = requestAnimationFrame(() => {
2160
+ this.mountFrame = null;
2161
+ this.goTo(this.currentIndex, { behavior: "auto" });
2119
2162
  this.startAutoplay();
2120
2163
  });
2121
2164
  }
2122
2165
  disconnectedCallback() {
2166
+ if (this.mountFrame !== null) {
2167
+ cancelAnimationFrame(this.mountFrame);
2168
+ this.mountFrame = null;
2169
+ }
2123
2170
  this.stopAutoplay();
2124
2171
  this.observer?.disconnect();
2125
2172
  this.observer = null;
@@ -2458,7 +2505,7 @@ let nextId$1 = 0;
2458
2505
  * caixa por aria-labelledby e a alternam ao clique. Os nós próprios ficam no
2459
2506
  * início do host, marcados data-ark-chrome, antes dos filhos do usuário.
2460
2507
  */
2461
- class ArkCheckbox extends HTMLElement {
2508
+ class ArkCheckbox extends HTMLElementBase {
2462
2509
  static get observedAttributes() {
2463
2510
  return [
2464
2511
  "checked",
@@ -2780,7 +2827,7 @@ ArkCheckbox.tagName = "ark-checkbox";
2780
2827
  * (/segundo), no estilo DigitalClock do MUI. Valor sempre em 24h "HH:mm:ss";
2781
2828
  * `hours-format="12"` só muda a exibição (coluna AM/PM).
2782
2829
  */
2783
- class ArkClock extends HTMLElement {
2830
+ class ArkClock extends HTMLElementBase {
2784
2831
  constructor() {
2785
2832
  super(...arguments);
2786
2833
  this.root = null;
@@ -2806,7 +2853,7 @@ class ArkClock extends HTMLElement {
2806
2853
  };
2807
2854
  }
2808
2855
  static get observedAttributes() {
2809
- return ["value", "seconds", "step-minutes", "hours-format", "lang", "theme", "intent", "testid"];
2856
+ return ["value", "seconds", "step-minutes", "hours-format", "lang", "locale-json", "theme", "intent", "testid"];
2810
2857
  }
2811
2858
  connectedCallback() {
2812
2859
  this.build();
@@ -2826,6 +2873,9 @@ class ArkClock extends HTMLElement {
2826
2873
  get value() {
2827
2874
  return this.getAttribute("value") || "";
2828
2875
  }
2876
+ set value(value) {
2877
+ reflectAttr(this, "value", value);
2878
+ }
2829
2879
  getIntent() {
2830
2880
  const intent = (this.getAttribute("intent") || "").toLowerCase();
2831
2881
  if (intent === "primary" ||
@@ -2942,7 +2992,7 @@ class ArkClock extends HTMLElement {
2942
2992
  }
2943
2993
  build() {
2944
2994
  const palette = this.getPalette(this.getIntent());
2945
- const loc = core.resolveLocale((this.getAttribute("lang") || "en"), undefined);
2995
+ const loc = core.resolveLocale((this.getAttribute("lang") || "en"), this.getAttribute("locale-json") || undefined);
2946
2996
  this.root?.remove();
2947
2997
  this.columnEls.clear();
2948
2998
  const container = document.createElement("div");
@@ -3036,7 +3086,7 @@ ArkClock.tagName = "ark-clock";
3036
3086
  * movem e selecionam dando a volta, Home/End, Espaço seleciona. `change` só
3037
3087
  * quando a seleção muda pelo usuário.
3038
3088
  */
3039
- class ArkColorSwatches extends HTMLElement {
3089
+ class ArkColorSwatches extends HTMLElementBase {
3040
3090
  static get observedAttributes() {
3041
3091
  return ["value", "colors", "label", "aria-label", "disabled", "size", "theme", "class", "testid"];
3042
3092
  }
@@ -3110,6 +3160,12 @@ class ArkColorSwatches extends HTMLElement {
3110
3160
  }
3111
3161
  }
3112
3162
  set colors(list) {
3163
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
3164
+ if (typeof list === "string") {
3165
+ this.colorsProperty = null;
3166
+ this.setAttribute("colors", list);
3167
+ return;
3168
+ }
3113
3169
  this.colorsProperty = Array.isArray(list) ? list : null;
3114
3170
  if (this.isConnected)
3115
3171
  this.updateAppearance();
@@ -3232,7 +3288,7 @@ ArkColorSwatches.tagName = "ark-color-swatches";
3232
3288
  * filtro e do nome (padrão: o texto dos filhos sem slot). A paleta escreve
3233
3289
  * `id`, `hidden`, `aria-selected` e a ordem visual.
3234
3290
  */
3235
- class ArkCommandItem extends HTMLElement {
3291
+ class ArkCommandItem extends HTMLElementBase {
3236
3292
  static get observedAttributes() {
3237
3293
  return ["value", "group", "label", "disabled", "class", "testid"];
3238
3294
  }
@@ -3266,10 +3322,16 @@ class ArkCommandItem extends HTMLElement {
3266
3322
  get value() {
3267
3323
  return this.getAttribute("value") || "";
3268
3324
  }
3325
+ set value(value) {
3326
+ reflectAttr(this, "value", value);
3327
+ }
3269
3328
  /** Seção em que a paleta lista o item; vazio é sem grupo. */
3270
3329
  get group() {
3271
3330
  return (this.getAttribute("group") || "").trim();
3272
3331
  }
3332
+ set group(value) {
3333
+ reflectAttr(this, "group", value);
3334
+ }
3273
3335
  /** Texto usado no filtro e no nome da opção: `label`, senão o texto dos filhos sem slot. */
3274
3336
  get label() {
3275
3337
  const attr = this.getAttribute("label");
@@ -3282,6 +3344,9 @@ class ArkCommandItem extends HTMLElement {
3282
3344
  .replace(/\s+/g, " ")
3283
3345
  .trim();
3284
3346
  }
3347
+ set label(value) {
3348
+ reflectAttr(this, "label", value);
3349
+ }
3285
3350
  get disabled() {
3286
3351
  return this.hasAttribute("disabled");
3287
3352
  }
@@ -3347,7 +3412,7 @@ function normalize(text) {
3347
3412
  * Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
3348
3413
  * página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
3349
3414
  */
3350
- class ArkCommandPalette extends HTMLElement {
3415
+ class ArkCommandPalette extends HTMLElementBase {
3351
3416
  static get observedAttributes() {
3352
3417
  return [
3353
3418
  "open",
@@ -3373,6 +3438,8 @@ class ArkCommandPalette extends HTMLElement {
3373
3438
  this.ownClasses = [];
3374
3439
  this.syncingClass = false;
3375
3440
  this.state = "closed";
3441
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
3442
+ this.openingOnConnect = false;
3376
3443
  this.releaseTrap = null;
3377
3444
  this.queryTimer = null;
3378
3445
  this.activeId = null;
@@ -3485,12 +3552,16 @@ class ArkCommandPalette extends HTMLElement {
3485
3552
  if (!this.observer) {
3486
3553
  // Itens que entram ou saem (busca assíncrona, frameworks) reordenam a lista.
3487
3554
  this.observer = new MutationObserver(() => this.syncItems());
3488
- this.observer.observe(this, { childList: true });
3555
+ // subtree: o item de um wrapper de framework entra dentro do wrapper, não como filho da paleta.
3556
+ this.observer.observe(this, { childList: true, subtree: true });
3489
3557
  }
3490
3558
  document.addEventListener("keydown", this.handleHotkey);
3491
3559
  this.updateAppearance();
3492
- if (this.hasAttribute("open"))
3560
+ if (this.hasAttribute("open")) {
3561
+ this.openingOnConnect = true;
3493
3562
  this.openNow();
3563
+ this.openingOnConnect = false;
3564
+ }
3494
3565
  }
3495
3566
  disconnectedCallback() {
3496
3567
  this.observer?.disconnect();
@@ -3570,9 +3641,12 @@ class ArkCommandPalette extends HTMLElement {
3570
3641
  this.removeAttribute("open");
3571
3642
  }
3572
3643
  // --- Itens ---
3573
- /** Os ark-command-item filhos diretos, na ordem do DOM. */
3644
+ /**
3645
+ * Os ark-command-item desta paleta, na ordem do DOM. Descendentes, não só filhos: um wrapper de framework (o
3646
+ * `<ark-command-item-wrapper>` do Angular) fica entre a paleta e o item. Itens de uma paleta aninhada são dela.
3647
+ */
3574
3648
  items() {
3575
- return Array.from(this.querySelectorAll(":scope > ark-command-item")).filter((el) => el instanceof ArkCommandItem);
3649
+ return Array.from(this.querySelectorAll("ark-command-item")).filter((el) => el instanceof ArkCommandItem && el.closest("ark-command-palette") === this);
3576
3650
  }
3577
3651
  visibleItems() {
3578
3652
  return this.items().filter((item) => !item.hidden);
@@ -3619,13 +3693,17 @@ class ArkCommandPalette extends HTMLElement {
3619
3693
  }
3620
3694
  groups.forEach((group, index) => {
3621
3695
  const header = this.groupEls[index];
3622
- header.textContent = group;
3696
+ // Só escreve o que mudou: o observer (subtree) veria a troca do nó de texto e sincronizaria em laço.
3697
+ if (header.textContent !== group)
3698
+ header.textContent = group;
3623
3699
  header.style.order = String((index + 1) * 1000);
3624
3700
  applyTestHooks(this, "command-palette", header, "group");
3625
3701
  });
3626
3702
  this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
3627
3703
  this.emptyEl.hidden = visible.length > 0;
3628
- this.emptyEl.textContent = this.getLocale().noResults;
3704
+ const noResults = this.getLocale().noResults;
3705
+ if (this.emptyEl.textContent !== noResults)
3706
+ this.emptyEl.textContent = noResults;
3629
3707
  const enabled = visible.filter((item) => !item.disabled);
3630
3708
  if (!enabled.some((item) => item.id === this.activeId))
3631
3709
  this.activeId = enabled[0]?.id ?? null;
@@ -3688,7 +3766,17 @@ class ArkCommandPalette extends HTMLElement {
3688
3766
  });
3689
3767
  field?.select();
3690
3768
  this.inputEl?.inputElement?.setAttribute("aria-expanded", "true");
3691
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
3769
+ const emit = () => {
3770
+ if (this.state === "open")
3771
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
3772
+ };
3773
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
3774
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
3775
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
3776
+ if (this.openingOnConnect)
3777
+ queueMicrotask(emit);
3778
+ else
3779
+ emit();
3692
3780
  }
3693
3781
  closeNow() {
3694
3782
  if (this.state !== "open")
@@ -3781,7 +3869,8 @@ class ArkCommandPalette extends HTMLElement {
3781
3869
  this.inputEl.removeAttribute(attr);
3782
3870
  }
3783
3871
  }
3784
- this.emptyEl.textContent = locale.noResults;
3872
+ if (this.emptyEl.textContent !== locale.noResults)
3873
+ this.emptyEl.textContent = locale.noResults;
3785
3874
  applyTestHooks(this, "command-palette", this);
3786
3875
  applyTestHooks(this, "command-palette", this.inputEl, "input");
3787
3876
  applyTestHooks(this, "command-palette", this.listEl, "list");
@@ -4015,7 +4104,7 @@ const CALENDAR_ATTRS = [
4015
4104
  "events",
4016
4105
  "event-display"
4017
4106
  ];
4018
- const CLOCK_ATTRS = ["lang", "theme", "intent", "seconds", "step-minutes", "hours-format"];
4107
+ const CLOCK_ATTRS = ["lang", "locale-json", "theme", "intent", "seconds", "step-minutes", "hours-format"];
4019
4108
  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>`;
4020
4109
  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>`;
4021
4110
  /**
@@ -4033,7 +4122,7 @@ const CLOCK_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" heigh
4033
4122
  * core (abre abaixo, vira para cima sem espaço) e animado com `scale` a
4034
4123
  * partir da origem.
4035
4124
  */
4036
- class ArkDatepicker extends HTMLElement {
4125
+ class ArkDatepicker extends HTMLElementBase {
4037
4126
  constructor() {
4038
4127
  super(...arguments);
4039
4128
  this.calendarEl = null;
@@ -4041,6 +4130,8 @@ class ArkDatepicker extends HTMLElement {
4041
4130
  this.inputComp = null;
4042
4131
  this.toggleEl = null;
4043
4132
  this.popupEl = null;
4133
+ /** Calendário e/ou relógio: inline no host ou dentro do popup. */
4134
+ this.panelEl = null;
4044
4135
  /** Para de reposicionar o popup em scroll/resize; só existe enquanto aberto. */
4045
4136
  this.disposePosition = null;
4046
4137
  this.hiddenInputEl = null;
@@ -4156,6 +4247,9 @@ class ArkDatepicker extends HTMLElement {
4156
4247
  get value() {
4157
4248
  return this.getAttribute("value") || "";
4158
4249
  }
4250
+ set value(value) {
4251
+ reflectAttr(this, "value", value);
4252
+ }
4159
4253
  hasRendered() {
4160
4254
  return this.calendarEl !== null || this.clockEl !== null;
4161
4255
  }
@@ -4315,6 +4409,7 @@ class ArkDatepicker extends HTMLElement {
4315
4409
  this.inputComp = null;
4316
4410
  this.toggleEl = null;
4317
4411
  this.popupEl = null;
4412
+ this.panelEl = null;
4318
4413
  this.hiddenInputEl = null;
4319
4414
  }
4320
4415
  forwardAttr(target, name) {
@@ -4357,8 +4452,14 @@ class ArkDatepicker extends HTMLElement {
4357
4452
  }
4358
4453
  render() {
4359
4454
  const panel = this.buildPanel();
4455
+ this.panelEl = panel;
4456
+ // O valor vai ao formulário por um input oculto nos dois modos (inline também participa de <form>).
4457
+ const hidden = document.createElement("input");
4458
+ hidden.type = "hidden";
4459
+ this.hiddenInputEl = hidden;
4360
4460
  if (!this.isInputMode()) {
4361
4461
  this.appendChild(panel);
4462
+ this.appendChild(hidden);
4362
4463
  this.applyHooks();
4363
4464
  return;
4364
4465
  }
@@ -4411,8 +4512,6 @@ class ArkDatepicker extends HTMLElement {
4411
4512
  popup.setAttribute("popover", "manual");
4412
4513
  popup.setAttribute("role", "dialog");
4413
4514
  popup.appendChild(panel);
4414
- const hidden = document.createElement("input");
4415
- hidden.type = "hidden";
4416
4515
  wrapper.appendChild(inputComp);
4417
4516
  wrapper.appendChild(popup);
4418
4517
  this.appendChild(wrapper);
@@ -4420,7 +4519,6 @@ class ArkDatepicker extends HTMLElement {
4420
4519
  this.inputComp = inputComp;
4421
4520
  this.toggleEl = toggle;
4422
4521
  this.popupEl = popup;
4423
- this.hiddenInputEl = hidden;
4424
4522
  this.applyHooks();
4425
4523
  }
4426
4524
  applyHooks() {
@@ -4480,10 +4578,21 @@ class ArkDatepicker extends HTMLElement {
4480
4578
  }
4481
4579
  /** Sincroniza aparência/estado do campo com os atributos atuais. */
4482
4580
  syncField() {
4483
- if (!this.isInputMode() || !this.inputComp || !this.toggleEl || !this.hiddenInputEl || !this.popupEl)
4581
+ const disabled = this.hasAttribute("disabled");
4582
+ // Nos dois modos: o input oculto leva nome e valor ao formulário, e `disabled` tira os painéis de interação
4583
+ // (inline eles estão à vista; no modo input o campo e o botão também ficam desabilitados abaixo).
4584
+ if (this.hiddenInputEl) {
4585
+ this.hiddenInputEl.name = this.getAttribute("name") || "";
4586
+ this.hiddenInputEl.value = this.getAttribute("value") || "";
4587
+ this.hiddenInputEl.disabled = disabled;
4588
+ }
4589
+ if (this.panelEl) {
4590
+ this.panelEl.inert = disabled;
4591
+ this.panelEl.classList.toggle("ark:opacity-50", disabled);
4592
+ }
4593
+ if (!this.isInputMode() || !this.inputComp || !this.toggleEl || !this.popupEl)
4484
4594
  return;
4485
4595
  const loc = this.getLocale();
4486
- const disabled = this.hasAttribute("disabled");
4487
4596
  this.forwardAttr(this.inputComp, "theme");
4488
4597
  this.inputComp.setAttribute("placeholder", this.getAttribute("placeholder") || this.getFormat().toLowerCase());
4489
4598
  if (disabled) {
@@ -4499,9 +4608,6 @@ class ArkDatepicker extends HTMLElement {
4499
4608
  this.popupEl.setAttribute("aria-label", loc.openCalendar);
4500
4609
  this.inputComp.inputElement?.setAttribute("aria-haspopup", "dialog");
4501
4610
  this.inputComp.inputElement?.setAttribute("aria-expanded", this.popupOpen ? "true" : "false");
4502
- this.hiddenInputEl.name = this.getAttribute("name") || "";
4503
- this.hiddenInputEl.value = this.getAttribute("value") || "";
4504
- this.hiddenInputEl.disabled = disabled;
4505
4611
  this.updateInputDisplay();
4506
4612
  }
4507
4613
  updateInputDisplay() {
@@ -4627,7 +4733,7 @@ function cssLength$2(value) {
4627
4733
  * navegando por cursor virtual ainda alcança o conteúdo atrás. A página para
4628
4734
  * de rolar enquanto aberto (`lockScroll` de core), salvo com `no-scroll-lock`.
4629
4735
  */
4630
- class ArkDialog extends HTMLElement {
4736
+ class ArkDialog extends HTMLElementBase {
4631
4737
  static get observedAttributes() {
4632
4738
  return [
4633
4739
  "open",
@@ -4654,6 +4760,8 @@ class ArkDialog extends HTMLElement {
4654
4760
  this.syncingClass = false;
4655
4761
  /** Visibilidade real: `open` também cobre a animação de entrada; `closing` é a saída ainda visível. */
4656
4762
  this.state = "closed";
4763
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
4764
+ this.openingOnConnect = false;
4657
4765
  this.releaseTrap = null;
4658
4766
  /** Motivo pedido por `close(reason)`, lido quando o atributo `open` some. */
4659
4767
  this.pendingReason = null;
@@ -4679,8 +4787,11 @@ class ArkDialog extends HTMLElement {
4679
4787
  this.observer.observe(this, { childList: true });
4680
4788
  }
4681
4789
  this.updateAppearance();
4682
- if (this.hasAttribute("open"))
4790
+ if (this.hasAttribute("open")) {
4791
+ this.openingOnConnect = true;
4683
4792
  this.openNow();
4793
+ this.openingOnConnect = false;
4794
+ }
4684
4795
  }
4685
4796
  disconnectedCallback() {
4686
4797
  this.observer?.disconnect();
@@ -4770,7 +4881,17 @@ class ArkDialog extends HTMLElement {
4770
4881
  this.close("backdrop");
4771
4882
  }
4772
4883
  });
4773
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
4884
+ const emit = () => {
4885
+ if (this.state === "open")
4886
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
4887
+ };
4888
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
4889
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
4890
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
4891
+ if (this.openingOnConnect)
4892
+ queueMicrotask(emit);
4893
+ else
4894
+ emit();
4774
4895
  }
4775
4896
  closeNow(reason) {
4776
4897
  if (this.state !== "open")
@@ -4982,7 +5103,7 @@ function cssLength$1(value) {
4982
5103
  * verdade, como no ark-dialog, e em overlay a página para de rolar enquanto
4983
5104
  * aberta, salvo com `no-scroll-lock`.
4984
5105
  */
4985
- class ArkDrawer extends HTMLElement {
5106
+ class ArkDrawer extends HTMLElementBase {
4986
5107
  static get observedAttributes() {
4987
5108
  return [
4988
5109
  "open",
@@ -5008,6 +5129,8 @@ class ArkDrawer extends HTMLElement {
5008
5129
  this.ownClasses = [];
5009
5130
  this.syncingClass = false;
5010
5131
  this.state = "closed";
5132
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
5133
+ this.openingOnConnect = false;
5011
5134
  this.releaseTrap = null;
5012
5135
  this.pendingReason = null;
5013
5136
  this.warned = false;
@@ -5030,8 +5153,11 @@ class ArkDrawer extends HTMLElement {
5030
5153
  this.observer.observe(this, { childList: true });
5031
5154
  }
5032
5155
  this.updateAppearance();
5033
- if (this.hasAttribute("open"))
5156
+ if (this.hasAttribute("open")) {
5157
+ this.openingOnConnect = true;
5034
5158
  this.openNow();
5159
+ this.openingOnConnect = false;
5160
+ }
5035
5161
  }
5036
5162
  disconnectedCallback() {
5037
5163
  this.observer?.disconnect();
@@ -5095,10 +5221,16 @@ class ArkDrawer extends HTMLElement {
5095
5221
  const side = (this.getAttribute("side") || "").toLowerCase();
5096
5222
  return side === "left" || side === "top" || side === "bottom" ? side : "right";
5097
5223
  }
5224
+ set side(value) {
5225
+ reflectAttr(this, "side", value);
5226
+ }
5098
5227
  /** `overlay` (popover modal com scrim) ou `inline` (no fluxo, só anima). Padrão: "overlay". */
5099
5228
  get mode() {
5100
5229
  return (this.getAttribute("mode") || "").toLowerCase() === "inline" ? "inline" : "overlay";
5101
5230
  }
5231
+ set mode(value) {
5232
+ reflectAttr(this, "mode", value);
5233
+ }
5102
5234
  /** Abre a gaveta: adiciona `open`, que faz o resto. */
5103
5235
  show() {
5104
5236
  if (!this.open)
@@ -5147,7 +5279,17 @@ class ArkDrawer extends HTMLElement {
5147
5279
  animation.cancel();
5148
5280
  void core.arkEnter(this, this.preset(), { easing: "sheet" });
5149
5281
  }
5150
- this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
5282
+ const emit = () => {
5283
+ if (this.state === "open")
5284
+ this.dispatchEvent(new CustomEvent("ark-open", { bubbles: true, composed: true }));
5285
+ };
5286
+ // Aberto já ao conectar (open no HTML, hidratação de SSR, framework que grava a prop antes de inserir): o evento
5287
+ // sai num microtask, para chegar a quem se inscreve no mesmo ciclo em que o nó entrou (os wrappers React e
5288
+ // Angular ligam os listeners dos overlays durante a montagem) em vez de disparar antes de alguém escutar.
5289
+ if (this.openingOnConnect)
5290
+ queueMicrotask(emit);
5291
+ else
5292
+ emit();
5151
5293
  }
5152
5294
  closeNow(reason) {
5153
5295
  if (this.state !== "open")
@@ -5349,7 +5491,7 @@ ArkDrawer.tagName = "ark-drawer";
5349
5491
  * `description`, em nós do componente ao fim do host. Filhos sem slot entram
5350
5492
  * entre a descrição e a ação. Não é interativo e não tem role próprio.
5351
5493
  */
5352
- class ArkEmpty extends HTMLElement {
5494
+ class ArkEmpty extends HTMLElementBase {
5353
5495
  constructor() {
5354
5496
  super(...arguments);
5355
5497
  this.ownClasses = [];
@@ -5468,7 +5610,7 @@ const UPLOAD_SVG = `
5468
5610
  * tela. O rótulo aponta para o input (associação nativa) e nomeia o botão
5469
5611
  * junto do próprio texto dele.
5470
5612
  */
5471
- class ArkFileInput extends HTMLElement {
5613
+ class ArkFileInput extends HTMLElementBase {
5472
5614
  constructor() {
5473
5615
  super(...arguments);
5474
5616
  this.inputEl = null;
@@ -5905,7 +6047,7 @@ let arkInputIdCounter = 0;
5905
6047
  * um botão de mostrar/ocultar na ponta direita. Atributos nativos como
5906
6048
  * `maxlength` ou `inputmode` são espelhados no <input> sem interpretação.
5907
6049
  */
5908
- class ArkInput extends HTMLElement {
6050
+ class ArkInput extends HTMLElementBase {
5909
6051
  constructor() {
5910
6052
  super(...arguments);
5911
6053
  this.inputEl = null;
@@ -6214,7 +6356,7 @@ ArkInput.tagName = "ark-input";
6214
6356
  * usuário. Não é interativo e não tem role próprio; para leitores de tela é
6215
6357
  * texto comum, como um <kbd>.
6216
6358
  */
6217
- class ArkKbd extends HTMLElement {
6359
+ class ArkKbd extends HTMLElementBase {
6218
6360
  constructor() {
6219
6361
  super(...arguments);
6220
6362
  this.ownClasses = [];
@@ -6336,7 +6478,7 @@ function cloneRow(row) {
6336
6478
  * adicionar e remover anunciam a contagem ao leitor de tela. A célula de
6337
6479
  * valor é um ark-input comum: autocomplete de variáveis fica no app.
6338
6480
  */
6339
- class ArkKvEditor extends HTMLElement {
6481
+ class ArkKvEditor extends HTMLElementBase {
6340
6482
  static get observedAttributes() {
6341
6483
  return [
6342
6484
  "rows",
@@ -6432,6 +6574,11 @@ class ArkKvEditor extends HTMLElement {
6432
6574
  return this.model.map((row) => ({ ...row }));
6433
6575
  }
6434
6576
  set rows(value) {
6577
+ // Uma string é o JSON do atributo (React 19 e Vue gravam a prop como propriedade): segue o caminho do atributo.
6578
+ if (typeof value === "string") {
6579
+ this.setAttribute("rows", value);
6580
+ return;
6581
+ }
6435
6582
  this.model = Array.isArray(value) ? value.map(cloneRow) : [];
6436
6583
  this.resetRows();
6437
6584
  if (this.isConnected)
@@ -6809,9 +6956,11 @@ class ArkKvEditor extends HTMLElement {
6809
6956
  input.toggleAttribute("readonly", readonly);
6810
6957
  applyTestHooks(this, "kv-editor", input, name);
6811
6958
  }
6812
- // Campo de valor: senha com o olho quando é segredo; senão o tipo da linha (number, date...) ou texto.
6959
+ // Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
6960
+ const rowType = types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
6961
+ // Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto.
6813
6962
  const isSecret = withSecret && row.secret === true;
6814
- parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[row.type ?? ""] ?? "text"));
6963
+ parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
6815
6964
  parts.value.toggleAttribute("reveal", isSecret);
6816
6965
  if (parts.secret) {
6817
6966
  parts.secret.setAttribute("aria-label", locale.secret);
@@ -6829,9 +6978,8 @@ class ArkKvEditor extends HTMLElement {
6829
6978
  }
6830
6979
  if (parts.type) {
6831
6980
  parts.type.options = types.map((type) => ({ value: type, label: type }));
6832
- const current = row.type && types.includes(row.type) ? row.type : types[0];
6833
- if (parts.type.value !== current)
6834
- parts.type.value = current;
6981
+ if (rowType && parts.type.value !== rowType)
6982
+ parts.type.value = rowType;
6835
6983
  parts.type.setAttribute("aria-label", locale.type);
6836
6984
  parts.type.setAttribute("size", size);
6837
6985
  parts.type.toggleAttribute("disabled", readonly);
@@ -6990,7 +7138,7 @@ function cssLength(value) {
6990
7138
  * nomeado; sem ele é decorativo (`aria-hidden`): o texto ao lado é o que
6991
7139
  * conta.
6992
7140
  */
6993
- class ArkMark extends HTMLElement {
7141
+ class ArkMark extends HTMLElementBase {
6994
7142
  constructor() {
6995
7143
  super(...arguments);
6996
7144
  this.ownClasses = [];
@@ -7095,7 +7243,7 @@ let menuSeq = 0;
7095
7243
  * a saída são transições CSS em components.css, porque o light dismiss de um
7096
7244
  * popover auto não pode ser interceptado por JS para animar antes de esconder.
7097
7245
  */
7098
- class ArkMenu extends HTMLElement {
7246
+ class ArkMenu extends HTMLElementBase {
7099
7247
  static get observedAttributes() {
7100
7248
  return ["for", "open", "align", "direction", "size", "theme", "class", "testid"];
7101
7249
  }
@@ -7266,6 +7414,11 @@ class ArkMenu extends HTMLElement {
7266
7414
  }
7267
7415
  set open(value) {
7268
7416
  const next = core.coerceBooleanAttr(value);
7417
+ // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
7418
+ if (!this.isConnected) {
7419
+ this.toggleAttribute("open", next);
7420
+ return;
7421
+ }
7269
7422
  if (next) {
7270
7423
  this.show();
7271
7424
  }
@@ -7483,7 +7636,7 @@ const CHECK_SVG$1 = `
7483
7636
  * item. Seleção, foco e teclado são coordenados pelo ark-menu; `size` e
7484
7637
  * `theme` chegam propagados dele.
7485
7638
  */
7486
- class ArkMenuItem extends HTMLElement {
7639
+ class ArkMenuItem extends HTMLElementBase {
7487
7640
  static get observedAttributes() {
7488
7641
  return ["value", "disabled", "intent", "divider", "checked", "static", "size", "theme", "class", "testid"];
7489
7642
  }
@@ -7527,6 +7680,9 @@ class ArkMenuItem extends HTMLElement {
7527
7680
  get value() {
7528
7681
  return this.getAttribute("value") || "";
7529
7682
  }
7683
+ set value(value) {
7684
+ reflectAttr(this, "value", value);
7685
+ }
7530
7686
  get disabled() {
7531
7687
  return this.hasAttribute("disabled");
7532
7688
  }
@@ -7538,6 +7694,11 @@ class ArkMenuItem extends HTMLElement {
7538
7694
  return this.hasAttribute("checked") && this.getAttribute("checked") !== "false";
7539
7695
  }
7540
7696
  set checked(value) {
7697
+ // Três estados: null/undefined voltam a item comum (React tira a prop assim); false desmarca o checkbox.
7698
+ if (value === null || value === undefined) {
7699
+ this.removeAttribute("checked");
7700
+ return;
7701
+ }
7541
7702
  this.setAttribute("checked", core.coerceBooleanAttr(value) ? "" : "false");
7542
7703
  }
7543
7704
  /** Item selecionável (não é divisor nem conteúdo estático). */
@@ -7703,7 +7864,7 @@ ArkMenuItem.tagName = "ark-menu-item";
7703
7864
  * loop, com duração fixa e isento de movimento reduzido, como o spinner: é o
7704
7865
  * único sinal de progresso.
7705
7866
  */
7706
- class ArkProgress extends HTMLElement {
7867
+ class ArkProgress extends HTMLElementBase {
7707
7868
  constructor() {
7708
7869
  super(...arguments);
7709
7870
  this.ownClasses = [];
@@ -7888,7 +8049,7 @@ let nextId = 0;
7888
8049
  * marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
7889
8050
  * opção como no ark-checkbox.
7890
8051
  */
7891
- class ArkRadio extends HTMLElement {
8052
+ class ArkRadio extends HTMLElementBase {
7892
8053
  static get observedAttributes() {
7893
8054
  return [
7894
8055
  "checked",
@@ -8343,7 +8504,7 @@ const DEFAULT_EVENT_MINUTES = 60;
8343
8504
  * eventos são o conteúdo: clicar num evento emite `ark-event-click` e clicar num
8344
8505
  * espaço livre emite `ark-slot-click` (útil para criar um evento).
8345
8506
  */
8346
- class ArkScheduler extends HTMLElement {
8507
+ class ArkScheduler extends HTMLElementBase {
8347
8508
  constructor() {
8348
8509
  super(...arguments);
8349
8510
  this.root = null;
@@ -8352,6 +8513,8 @@ class ArkScheduler extends HTMLElement {
8352
8513
  this.refDate = new Date();
8353
8514
  this.nowTimer = null;
8354
8515
  this.navDirection = null;
8516
+ /** Último período anunciado (título do cabeçalho); o primeiro build só registra, sem anunciar. */
8517
+ this.announcedPeriod = null;
8355
8518
  this.syncingAttr = false;
8356
8519
  /** Linhas de "agora" vivas na tela: reposicionadas sem rebuild a cada minuto. */
8357
8520
  this.nowLines = [];
@@ -8407,6 +8570,12 @@ class ArkScheduler extends HTMLElement {
8407
8570
  return this.eventsProp ?? this.parseEventsAttr();
8408
8571
  }
8409
8572
  set events(list) {
8573
+ // Frameworks que preferem propriedade a atributo (React 19, Vue) entregam o JSON do wrapper aqui.
8574
+ if (typeof list === "string") {
8575
+ this.eventsProp = null;
8576
+ this.setAttribute("events", list);
8577
+ return;
8578
+ }
8410
8579
  this.eventsProp = Array.isArray(list) ? list : null;
8411
8580
  if (this.root)
8412
8581
  this.build();
@@ -8423,6 +8592,9 @@ class ArkScheduler extends HTMLElement {
8423
8592
  get date() {
8424
8593
  return formatISODate(this.refDate);
8425
8594
  }
8595
+ set date(value) {
8596
+ reflectAttr(this, "date", value);
8597
+ }
8426
8598
  parseEventsAttr() {
8427
8599
  const raw = this.getAttribute("events");
8428
8600
  if (!raw)
@@ -8686,8 +8858,8 @@ class ArkScheduler extends HTMLElement {
8686
8858
  applyTestHooks(this, "scheduler", nextBtn, "next");
8687
8859
  const title = document.createElement("h2");
8688
8860
  title.className = `${palette.headerText} ark:ml-1`;
8689
- title.setAttribute("aria-live", "polite");
8690
8861
  title.textContent = this.getTitle();
8862
+ this.announcePeriod(title.textContent);
8691
8863
  applyTestHooks(this, "scheduler", title, "title");
8692
8864
  left.appendChild(todayBtn);
8693
8865
  left.appendChild(prevBtn);
@@ -8721,6 +8893,8 @@ class ArkScheduler extends HTMLElement {
8721
8893
  return;
8722
8894
  this.setAttribute("view", detail.value);
8723
8895
  this.dispatchEvent(new CustomEvent("ark-view-change", { detail: { view: detail.value }, bubbles: true, composed: true }));
8896
+ // Outra view mostra outro intervalo (a semana vira o mês): quem carrega eventos por período precisa saber.
8897
+ this.emitRangeChange();
8724
8898
  });
8725
8899
  header.appendChild(left);
8726
8900
  header.appendChild(group);
@@ -8976,6 +9150,7 @@ class ArkScheduler extends HTMLElement {
8976
9150
  this.syncDateAttr();
8977
9151
  this.setAttribute("view", "day");
8978
9152
  this.dispatchEvent(new CustomEvent("ark-view-change", { detail: { view: "day" }, bubbles: true, composed: true }));
9153
+ this.emitRangeChange();
8979
9154
  });
8980
9155
  cell.appendChild(more);
8981
9156
  }
@@ -9067,6 +9242,13 @@ class ArkScheduler extends HTMLElement {
9067
9242
  line.style.top = `${((nowMinutes - hourStart * 60) / totalMinutes) * bodyHeight}px`;
9068
9243
  }
9069
9244
  }
9245
+ // A troca de período vai ao leitor de tela pelo anunciador do core: um aria-live no título entraria no nome do
9246
+ // controle e, recriado a cada build, nem seria anunciado.
9247
+ announcePeriod(text) {
9248
+ if (this.announcedPeriod !== null && this.announcedPeriod !== text)
9249
+ core.announce(text);
9250
+ this.announcedPeriod = text;
9251
+ }
9070
9252
  build() {
9071
9253
  if (!this.locale)
9072
9254
  this.locale = this.getLocale();
@@ -9122,7 +9304,7 @@ let arkSelectIdCounter = 0;
9122
9304
  * propriedade JS), nunca de filhos: o <select> exige os <option> dentro dele
9123
9305
  * e a lib não move filhos do usuário.
9124
9306
  */
9125
- class ArkSelect extends HTMLElement {
9307
+ class ArkSelect extends HTMLElementBase {
9126
9308
  constructor() {
9127
9309
  super(...arguments);
9128
9310
  this.selectEl = null;
@@ -9428,7 +9610,7 @@ const SHAPE_LABEL = {
9428
9610
  * e nomeada pelo nome localizado da forma. Mesmo teclado do
9429
9611
  * ark-color-swatches. `change` só quando a seleção muda pelo usuário.
9430
9612
  */
9431
- class ArkShapePicker extends HTMLElement {
9613
+ class ArkShapePicker extends HTMLElementBase {
9432
9614
  static get observedAttributes() {
9433
9615
  return [
9434
9616
  "value",
@@ -9642,7 +9824,7 @@ const RADIUS = {
9642
9824
  * substitui o skeleton
9643
9825
  * entra com `.ark-animate-fade-in`, sem elemento próprio para isso.
9644
9826
  */
9645
- class ArkSkeleton extends HTMLElement {
9827
+ class ArkSkeleton extends HTMLElementBase {
9646
9828
  constructor() {
9647
9829
  super(...arguments);
9648
9830
  this.ownClasses = [];
@@ -9794,7 +9976,7 @@ const SPINNER_SVG = `
9794
9976
  * string `loading` do idioma). Gira sempre, inclusive sob movimento reduzido:
9795
9977
  * é o único sinal de progresso. Sem `intent` herda a cor do texto ao redor.
9796
9978
  */
9797
- class ArkSpinner extends HTMLElement {
9979
+ class ArkSpinner extends HTMLElementBase {
9798
9980
  constructor() {
9799
9981
  super(...arguments);
9800
9982
  this.ownClasses = [];
@@ -9903,7 +10085,7 @@ const BIG_STEP = 10;
9903
10085
  * reescrito a cada mudança) e `ark-resize` publica os tamanhos; persistir é
9904
10086
  * do app. Nada anima: redimensionar é interação de alta frequência.
9905
10087
  */
9906
- class ArkSplitPane extends HTMLElement {
10088
+ class ArkSplitPane extends HTMLElementBase {
9907
10089
  constructor() {
9908
10090
  super(...arguments);
9909
10091
  this.handles = [];
@@ -10014,7 +10196,8 @@ class ArkSplitPane extends HTMLElement {
10014
10196
  return this.normalizedSizes(this.panels().length);
10015
10197
  }
10016
10198
  set sizes(value) {
10017
- this.setAttribute("sizes", value.map((size) => String(size)).join(","));
10199
+ // React 19 e Vue entregam aqui a string do atributo ("30,70") quando a prop vem do wrapper.
10200
+ this.setAttribute("sizes", typeof value === "string" ? value : value.map((size) => String(size)).join(","));
10018
10201
  }
10019
10202
  // --- Painéis e medidas ---
10020
10203
  /** Os filhos do usuário: tudo que não é chrome do componente. */
@@ -10200,7 +10383,7 @@ ArkSplitPane.tagName = "ark-split-pane";
10200
10383
  * (`aria-hidden`), para o texto ao lado ser o que conta. Estático por
10201
10384
  * design: nunca pulsa.
10202
10385
  */
10203
- class ArkStatusDot extends HTMLElement {
10386
+ class ArkStatusDot extends HTMLElementBase {
10204
10387
  constructor() {
10205
10388
  super(...arguments);
10206
10389
  this.ownClasses = [];
@@ -10291,7 +10474,7 @@ const CROSS_SVG = '<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" st
10291
10474
  * submetendo `name`/`value` apenas quando marcado. Tem tabela de proporções
10292
10475
  * própria, em vez da escala de altura dos demais controles.
10293
10476
  */
10294
- class ArkSwitch extends HTMLElement {
10477
+ class ArkSwitch extends HTMLElementBase {
10295
10478
  constructor() {
10296
10479
  super(...arguments);
10297
10480
  this.trackEl = null;
@@ -10596,7 +10779,7 @@ const CLOSE_SVG = `
10596
10779
  * Seleção e roving tabindex são coordenados pelo ark-tabs; `variant`,
10597
10780
  * `size`, `intent`, `theme` e idioma chegam propagados dele.
10598
10781
  */
10599
- class ArkTab extends HTMLElement {
10782
+ class ArkTab extends HTMLElementBase {
10600
10783
  static get observedAttributes() {
10601
10784
  return [
10602
10785
  "value",
@@ -10676,6 +10859,9 @@ class ArkTab extends HTMLElement {
10676
10859
  get value() {
10677
10860
  return this.getAttribute("value") || "";
10678
10861
  }
10862
+ set value(value) {
10863
+ reflectAttr(this, "value", value);
10864
+ }
10679
10865
  /** Aba ativa; o ark-tabs reflete aqui o seu `value`. */
10680
10866
  get selected() {
10681
10867
  return this.hasAttribute("selected");
@@ -10699,6 +10885,9 @@ class ArkTab extends HTMLElement {
10699
10885
  get closable() {
10700
10886
  return this.hasAttribute("closable") && this.getVariant() === "editor";
10701
10887
  }
10888
+ set closable(value) {
10889
+ this.toggleAttribute("closable", core.coerceBooleanAttr(value));
10890
+ }
10702
10891
  /** Pede a seleção desta aba: emite `change` com o valor, que o ark-tabs consolida. */
10703
10892
  select() {
10704
10893
  if (this.disabled || this.selected)
@@ -10949,7 +11138,7 @@ const PROPAGATED_ATTRS = ["variant", "size", "intent", "rounded", "fill", "theme
10949
11138
  * inserido de uma vez o grupo pode rodar antes de as abas serem upgraded, e
10950
11139
  * uma propriedade escrita antes do upgrade esconderia o accessor da classe.
10951
11140
  */
10952
- class ArkTabs extends HTMLElement {
11141
+ class ArkTabs extends HTMLElementBase {
10953
11142
  static get observedAttributes() {
10954
11143
  return [
10955
11144
  "value",
@@ -11182,7 +11371,7 @@ let arkTextareaIdCounter = 0;
11182
11371
  * (`field-sizing: content` nativo, com fallback por JS), `monospace` e
11183
11372
  * `resize` atendem edição de código e de dados.
11184
11373
  */
11185
- class ArkTextarea extends HTMLElement {
11374
+ class ArkTextarea extends HTMLElementBase {
11186
11375
  constructor() {
11187
11376
  super(...arguments);
11188
11377
  this.textareaEl = null;
@@ -11390,7 +11579,7 @@ ArkTextarea.tagName = "ark-textarea";
11390
11579
  * dialogs e menus, e é reaberta a cada toast novo para voltar ao topo da
11391
11580
  * pilha do top layer quando um overlay abriu depois dela.
11392
11581
  */
11393
- class ArkToaster extends HTMLElement {
11582
+ class ArkToaster extends HTMLElementBase {
11394
11583
  constructor() {
11395
11584
  super(...arguments);
11396
11585
  this.root = null;
@@ -11426,6 +11615,9 @@ class ArkToaster extends HTMLElement {
11426
11615
  this.timers.clear();
11427
11616
  }
11428
11617
  attributeChangedCallback() {
11618
+ // Posição, rich-colors, close-button, lang e testid mudam os cards já montados: recria todos (sem reanimar a
11619
+ // entrada, que `entered` lembra).
11620
+ this.root?.replaceChildren();
11429
11621
  this.render();
11430
11622
  }
11431
11623
  toast(options) {
@@ -11436,16 +11628,14 @@ class ArkToaster extends HTMLElement {
11436
11628
  createdAt: Date.now(),
11437
11629
  type: options.type || "default"
11438
11630
  };
11439
- this.toasts = [item, ...this.toasts.filter((toast) => toast.id !== id)];
11440
- const maxVisible = this.getMaxVisible();
11441
- if (this.toasts.length > maxVisible) {
11442
- const removed = this.toasts.slice(maxVisible);
11443
- this.toasts = this.toasts.slice(0, maxVisible);
11444
- for (const toast of removed) {
11445
- this.clearTimer(toast.id);
11446
- }
11631
+ // Mesmo id: o card antigo sai e o toast volta ao topo como um novo.
11632
+ if (this.toasts.some((toast) => toast.id === id)) {
11633
+ this.cardOf(id)?.remove();
11634
+ this.entered.delete(id);
11447
11635
  }
11448
- this.scheduleDismiss(item);
11636
+ this.toasts = [item, ...this.toasts.filter((toast) => toast.id !== id)];
11637
+ // O render agenda o fechamento dos visíveis; o mesmo id recomeça a contagem.
11638
+ this.clearTimer(id);
11449
11639
  this.render();
11450
11640
  // Um overlay aberto depois da pilha ficaria por cima dela: reentrar no top layer a põe acima de novo.
11451
11641
  this.raise();
@@ -11467,7 +11657,7 @@ class ArkToaster extends HTMLElement {
11467
11657
  this.toasts = this.toasts.filter((toast) => toast.id !== id);
11468
11658
  this.render();
11469
11659
  };
11470
- const card = this.root?.querySelector(`[data-toast-id="${id}"]`);
11660
+ const card = this.cardOf(id);
11471
11661
  if (card) {
11472
11662
  this.exiting.add(id);
11473
11663
  core.arkExit(card, this.getExitPreset()).then(finalize);
@@ -11476,6 +11666,9 @@ class ArkToaster extends HTMLElement {
11476
11666
  finalize();
11477
11667
  }
11478
11668
  }
11669
+ cardOf(id) {
11670
+ return this.root?.querySelector(`[data-toast-id="${CSS.escape(id)}"]`) ?? null;
11671
+ }
11479
11672
  getPosition() {
11480
11673
  const position = (this.getAttribute("position") || "bottom-right").toLowerCase();
11481
11674
  if (position === "top-left" ||
@@ -11633,101 +11826,126 @@ class ArkToaster extends HTMLElement {
11633
11826
  }
11634
11827
  this.render();
11635
11828
  }
11829
+ // Incremental: os cards da lista ficam onde estão (recriar um card focado jogaria o foco do teclado no body e
11830
+ // 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
11831
+ // lista vão embora e só os novos são criados, cada um na posição da lista (o mais novo no topo).
11636
11832
  render() {
11637
11833
  if (!this.root)
11638
11834
  return;
11639
- const position = this.getPosition();
11640
- const richColors = this.hasRichColors();
11641
- const closeButton = this.hasCloseButton();
11642
11835
  const palette = this.getPalette();
11643
- this.root.className = `${palette.stack} ${this.getPositionClasses(position)}`;
11644
- this.root.innerHTML = "";
11836
+ this.root.className = `${palette.stack} ${this.getPositionClasses(this.getPosition())}`;
11645
11837
  applyTestHooks(this, "toaster", this.root);
11646
11838
  this.syncPopover();
11647
- const activeIds = new Set(this.toasts.map((toast) => toast.id));
11839
+ // Até max-visible cards; o excedente (os mais antigos) espera na fila com o relógio parado e entra quando um sai.
11840
+ const visible = this.toasts.slice(0, this.getMaxVisible());
11841
+ const activeIds = new Set(visible.map((toast) => toast.id));
11842
+ for (const toast of this.toasts) {
11843
+ if (!activeIds.has(toast.id)) {
11844
+ this.clearTimer(toast.id);
11845
+ }
11846
+ else if (!this.timers.has(toast.id) && !this.exiting.has(toast.id)) {
11847
+ this.scheduleDismiss(toast);
11848
+ }
11849
+ }
11648
11850
  for (const id of this.entered) {
11649
11851
  if (!activeIds.has(id))
11650
11852
  this.entered.delete(id);
11651
11853
  }
11652
- for (const toast of this.toasts) {
11653
- const card = document.createElement("section");
11654
- card.setAttribute("part", "toast");
11655
- card.dataset.toastId = toast.id;
11656
- // Cada card compartilha o hook "toaster-toast"; desambigue via data-toast-id.
11657
- applyTestHooks(this, "toaster", card, "toast");
11658
- card.className = `${palette.toastBase} ${this.getToastTypeClasses(toast.type, richColors)}`.trim();
11659
- const row = document.createElement("div");
11660
- row.className = "ark:flex ark:items-start ark:gap-3";
11661
- const icon = document.createElement("span");
11662
- 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`;
11663
- icon.textContent = this.getToastIcon(toast.type);
11664
- const content = document.createElement("div");
11665
- content.className = "ark:min-w-0 ark:flex-1";
11666
- const title = document.createElement("h4");
11667
- title.className = palette.title;
11668
- applyTestHooks(this, "toaster", title, "toast-title");
11669
- title.textContent = toast.title;
11670
- content.appendChild(title);
11671
- if (toast.description) {
11672
- const description = document.createElement("p");
11673
- description.className = palette.description;
11674
- applyTestHooks(this, "toaster", description, "toast-description");
11675
- description.textContent = toast.description;
11676
- content.appendChild(description);
11677
- }
11678
- row.appendChild(icon);
11679
- row.appendChild(content);
11680
- if (closeButton) {
11681
- const close = document.createElement("button");
11682
- close.type = "button";
11683
- close.className = palette.closeButton;
11684
- applyTestHooks(this, "toaster", close, "toast-close");
11685
- close.textContent = this.getCloseLabel();
11686
- close.addEventListener("click", () => this.dismiss(toast.id));
11687
- row.appendChild(close);
11688
- }
11689
- card.appendChild(row);
11690
- if (toast.actionLabel || toast.cancelLabel) {
11691
- const actions = document.createElement("div");
11692
- actions.className = "ark:mt-3 ark:flex ark:items-center ark:justify-end ark:gap-2";
11693
- if (toast.cancelLabel) {
11694
- const cancel = document.createElement("button");
11695
- cancel.type = "button";
11696
- cancel.className = palette.cancelButton;
11697
- applyTestHooks(this, "toaster", cancel, "toast-cancel");
11698
- cancel.textContent = toast.cancelLabel;
11699
- cancel.addEventListener("click", () => this.dismiss(toast.id));
11700
- actions.appendChild(cancel);
11701
- }
11702
- if (toast.actionLabel) {
11703
- const action = document.createElement("button");
11704
- action.type = "button";
11705
- action.className = palette.actionButton;
11706
- applyTestHooks(this, "toaster", action, "toast-action");
11707
- action.textContent = toast.actionLabel;
11708
- action.addEventListener("click", () => {
11709
- this.dispatchEvent(new CustomEvent("ark-toast-action", {
11710
- detail: { id: toast.id, actionId: toast.actionId || null },
11711
- bubbles: true,
11712
- composed: true
11713
- }));
11714
- this.dismiss(toast.id);
11715
- });
11716
- actions.appendChild(action);
11717
- }
11718
- card.appendChild(actions);
11854
+ const existing = new Map();
11855
+ for (const card of Array.from(this.root.querySelectorAll("[data-toast-id]"))) {
11856
+ const id = card.dataset.toastId ?? "";
11857
+ if (activeIds.has(id)) {
11858
+ existing.set(id, card);
11719
11859
  }
11720
- this.root.appendChild(card);
11721
- if (this.exiting.has(toast.id)) {
11722
- // Re-render durante uma saída em andamento: mantém o card oculto
11723
- card.style.opacity = "0";
11724
- card.style.pointerEvents = "none";
11860
+ else {
11861
+ card.remove();
11725
11862
  }
11726
- else if (!this.entered.has(toast.id)) {
11727
- this.entered.add(toast.id);
11728
- core.arkEnter(card, this.getEnterPreset());
11863
+ }
11864
+ // Do mais antigo (fim da pilha) ao mais novo: um card novo entra antes do card do toast seguinte na lista.
11865
+ let next = null;
11866
+ for (let index = visible.length - 1; index >= 0; index--) {
11867
+ const toast = visible[index];
11868
+ let card = existing.get(toast.id);
11869
+ if (!card) {
11870
+ card = this.buildCard(toast, palette);
11871
+ this.root.insertBefore(card, next);
11872
+ if (!this.entered.has(toast.id)) {
11873
+ this.entered.add(toast.id);
11874
+ core.arkEnter(card, this.getEnterPreset());
11875
+ }
11876
+ }
11877
+ next = card;
11878
+ }
11879
+ }
11880
+ buildCard(toast, palette) {
11881
+ const card = document.createElement("section");
11882
+ card.setAttribute("part", "toast");
11883
+ card.dataset.toastId = toast.id;
11884
+ // Cada card compartilha o hook "toaster-toast"; desambigue via data-toast-id.
11885
+ applyTestHooks(this, "toaster", card, "toast");
11886
+ card.className = `${palette.toastBase} ${this.getToastTypeClasses(toast.type, this.hasRichColors())}`.trim();
11887
+ const row = document.createElement("div");
11888
+ row.className = "ark:flex ark:items-start ark:gap-3";
11889
+ const icon = document.createElement("span");
11890
+ 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`;
11891
+ icon.textContent = this.getToastIcon(toast.type);
11892
+ const content = document.createElement("div");
11893
+ content.className = "ark:min-w-0 ark:flex-1";
11894
+ const title = document.createElement("h4");
11895
+ title.className = palette.title;
11896
+ applyTestHooks(this, "toaster", title, "toast-title");
11897
+ title.textContent = toast.title;
11898
+ content.appendChild(title);
11899
+ if (toast.description) {
11900
+ const description = document.createElement("p");
11901
+ description.className = palette.description;
11902
+ applyTestHooks(this, "toaster", description, "toast-description");
11903
+ description.textContent = toast.description;
11904
+ content.appendChild(description);
11905
+ }
11906
+ row.appendChild(icon);
11907
+ row.appendChild(content);
11908
+ if (this.hasCloseButton()) {
11909
+ const close = document.createElement("button");
11910
+ close.type = "button";
11911
+ close.className = palette.closeButton;
11912
+ applyTestHooks(this, "toaster", close, "toast-close");
11913
+ close.textContent = this.getCloseLabel();
11914
+ close.addEventListener("click", () => this.dismiss(toast.id));
11915
+ row.appendChild(close);
11916
+ }
11917
+ card.appendChild(row);
11918
+ if (toast.actionLabel || toast.cancelLabel) {
11919
+ const actions = document.createElement("div");
11920
+ actions.className = "ark:mt-3 ark:flex ark:items-center ark:justify-end ark:gap-2";
11921
+ if (toast.cancelLabel) {
11922
+ const cancel = document.createElement("button");
11923
+ cancel.type = "button";
11924
+ cancel.className = palette.cancelButton;
11925
+ applyTestHooks(this, "toaster", cancel, "toast-cancel");
11926
+ cancel.textContent = toast.cancelLabel;
11927
+ cancel.addEventListener("click", () => this.dismiss(toast.id));
11928
+ actions.appendChild(cancel);
11929
+ }
11930
+ if (toast.actionLabel) {
11931
+ const action = document.createElement("button");
11932
+ action.type = "button";
11933
+ action.className = palette.actionButton;
11934
+ applyTestHooks(this, "toaster", action, "toast-action");
11935
+ action.textContent = toast.actionLabel;
11936
+ action.addEventListener("click", () => {
11937
+ this.dispatchEvent(new CustomEvent("ark-toast-action", {
11938
+ detail: { id: toast.id, actionId: toast.actionId || null },
11939
+ bubbles: true,
11940
+ composed: true
11941
+ }));
11942
+ this.dismiss(toast.id);
11943
+ });
11944
+ actions.appendChild(action);
11729
11945
  }
11946
+ card.appendChild(actions);
11730
11947
  }
11948
+ return card;
11731
11949
  }
11732
11950
  }
11733
11951
  ArkToaster.tagName = "ark-toaster";
@@ -11737,7 +11955,7 @@ ArkToaster.tagName = "ark-toaster";
11737
11955
  * (classes, role, foco, teclado): os filhos do usuário ficam onde estão.
11738
11956
  * Dentro de um ark-toggle-group vira item de segmented control.
11739
11957
  */
11740
- class ArkToggle extends HTMLElement {
11958
+ class ArkToggle extends HTMLElementBase {
11741
11959
  static get observedAttributes() {
11742
11960
  return ["pressed", "disabled", "size", "intent", "theme", "value", "class", "testid"];
11743
11961
  }
@@ -11804,6 +12022,9 @@ class ArkToggle extends HTMLElement {
11804
12022
  get value() {
11805
12023
  return this.getAttribute("value") || "";
11806
12024
  }
12025
+ set value(value) {
12026
+ reflectAttr(this, "value", value);
12027
+ }
11807
12028
  toggle() {
11808
12029
  if (this.disabled)
11809
12030
  return;
@@ -11932,7 +12153,7 @@ ArkToggle.tagName = "ark-toggle";
11932
12153
  * (`role="group"` + classes): os itens do usuário ficam onde estão, então
11933
12154
  * frameworks podem adicionar/remover toggles livremente.
11934
12155
  */
11935
- class ArkToggleGroup extends HTMLElement {
12156
+ class ArkToggleGroup extends HTMLElementBase {
11936
12157
  static get observedAttributes() {
11937
12158
  return ["value", "multiple", "disabled", "size", "intent", "theme", "class", "testid"];
11938
12159
  }
@@ -12049,8 +12270,11 @@ class ArkToggleGroup extends HTMLElement {
12049
12270
  if (theme)
12050
12271
  toggle.setAttribute("theme", theme);
12051
12272
  if (disabled) {
12052
- toggle.setAttribute("disabled", "");
12053
- toggle.dataset.groupDisabled = "true";
12273
+ // Um item já desabilitado por conta própria não leva a marca do grupo, senão ela apagaria o individual.
12274
+ if (!toggle.hasAttribute("disabled")) {
12275
+ toggle.setAttribute("disabled", "");
12276
+ toggle.dataset.groupDisabled = "true";
12277
+ }
12054
12278
  }
12055
12279
  else if (toggle.dataset.groupDisabled) {
12056
12280
  // Só remove o "disabled" que o próprio grupo aplicou; preserva o individual.
@@ -12085,6 +12309,8 @@ ArkToggleGroup.tagName = "ark-toggle-group";
12085
12309
 
12086
12310
  /** Contador para o id do balão, que o `aria-describedby` do gatilho referencia. */
12087
12311
  let tooltipSeq = 0;
12312
+ /** Tolerância para o ponteiro atravessar o espaço entre gatilho e balão sem fechar a dica. */
12313
+ const HIDE_GRACE_MS = 100;
12088
12314
  /**
12089
12315
  * Dica de contexto. O host envolve o gatilho do usuário (primeiro filho sem
12090
12316
  * `slot`) sem movê-lo e cria o balão: `role="tooltip"` com `popover="manual"`,
@@ -12094,11 +12320,12 @@ let tooltipSeq = 0;
12094
12320
  * components.css). O gatilho recebe `aria-describedby` do balão e precisa ser
12095
12321
  * focável por conta própria.
12096
12322
  *
12097
- * Abre em hover (depois de `delay`) e em foco (na hora); fecha ao sair, ao
12098
- * perder o foco, com Esc e no pointerdown. Posicionado por `positionAnchored`
12323
+ * Abre em hover (depois de `delay`) e em foco (na hora); fecha ao sair (com
12324
+ * uma tolerância para o ponteiro chegar ao balão, que mantém a dica aberta),
12325
+ * ao perder o foco, com Esc e no pointerdown. Posicionado por `positionAnchored`
12099
12326
  * de core, com flip quando não cabe. Entrada `fade` quick, sem saída animada.
12100
12327
  */
12101
- class ArkTooltip extends HTMLElement {
12328
+ class ArkTooltip extends HTMLElementBase {
12102
12329
  static get observedAttributes() {
12103
12330
  return ["content", "side", "delay", "open", "theme", "class", "testid"];
12104
12331
  }
@@ -12113,6 +12340,7 @@ class ArkTooltip extends HTMLElement {
12113
12340
  this.bubble = null;
12114
12341
  this.trigger = null;
12115
12342
  this.openTimer = null;
12343
+ this.hideTimer = null;
12116
12344
  this.disposePosition = null;
12117
12345
  this.isOpen = false;
12118
12346
  this.syncingOpen = false;
@@ -12122,12 +12350,14 @@ class ArkTooltip extends HTMLElement {
12122
12350
  this.handlePointerOver = (event) => {
12123
12351
  if (this.isInside(event.relatedTarget))
12124
12352
  return;
12353
+ // Voltou (ao gatilho ou ao balão) dentro da tolerância: a dica fica.
12354
+ this.cancelHide();
12125
12355
  this.scheduleShow();
12126
12356
  };
12127
12357
  this.handlePointerOut = (event) => {
12128
12358
  if (this.isInside(event.relatedTarget))
12129
12359
  return;
12130
- this.hide();
12360
+ this.scheduleHide();
12131
12361
  };
12132
12362
  // Clicar no gatilho dispensa a dica; ela volta só depois de sair e entrar de novo.
12133
12363
  this.handlePointerDown = () => {
@@ -12180,6 +12410,7 @@ class ArkTooltip extends HTMLElement {
12180
12410
  this.observer?.disconnect();
12181
12411
  this.observer = null;
12182
12412
  this.clearTimer();
12413
+ this.cancelHide();
12183
12414
  document.removeEventListener("keydown", this.handleDocumentKeydown, true);
12184
12415
  this.disposePosition?.();
12185
12416
  this.disposePosition = null;
@@ -12215,6 +12446,11 @@ class ArkTooltip extends HTMLElement {
12215
12446
  }
12216
12447
  set open(value) {
12217
12448
  const next = core.coerceBooleanAttr(value);
12449
+ // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
12450
+ if (!this.isConnected) {
12451
+ this.toggleAttribute("open", next);
12452
+ return;
12453
+ }
12218
12454
  if (next) {
12219
12455
  this.show();
12220
12456
  }
@@ -12239,6 +12475,7 @@ class ArkTooltip extends HTMLElement {
12239
12475
  /** Fecha na hora, sem animação de saída. */
12240
12476
  hide() {
12241
12477
  this.clearTimer();
12478
+ this.cancelHide();
12242
12479
  if (!this.isOpen)
12243
12480
  return;
12244
12481
  this.isOpen = false;
@@ -12282,6 +12519,21 @@ class ArkTooltip extends HTMLElement {
12282
12519
  this.openTimer = null;
12283
12520
  }
12284
12521
  }
12522
+ cancelHide() {
12523
+ if (this.hideTimer !== null) {
12524
+ clearTimeout(this.hideTimer);
12525
+ this.hideTimer = null;
12526
+ }
12527
+ }
12528
+ scheduleHide() {
12529
+ this.clearTimer();
12530
+ if (!this.isOpen || this.hideTimer !== null)
12531
+ return;
12532
+ this.hideTimer = setTimeout(() => {
12533
+ this.hideTimer = null;
12534
+ this.hide();
12535
+ }, HIDE_GRACE_MS);
12536
+ }
12285
12537
  scheduleShow() {
12286
12538
  if (this.isOpen || this.openTimer !== null)
12287
12539
  return;
@@ -12346,7 +12598,6 @@ class ArkTooltip extends HTMLElement {
12346
12598
  if (!this.ownBubble) {
12347
12599
  const bubble = document.createElement("div");
12348
12600
  bubble.setAttribute("data-ark-chrome", "bubble");
12349
- bubble.className = "ark:pointer-events-none";
12350
12601
  this.appendChild(bubble);
12351
12602
  this.ownBubble = bubble;
12352
12603
  }
@@ -12406,6 +12657,9 @@ ArkTooltip.tagName = "ark-tooltip";
12406
12657
  * para garantir que eles estejam disponíveis como elementos personalizados.
12407
12658
  */
12408
12659
  function registerTooarkComponents() {
12660
+ // Fora do navegador (SSR) não há registro de elementos: no-op, e o cliente registra na hidratação.
12661
+ if (typeof customElements === "undefined")
12662
+ return;
12409
12663
  if (!customElements.get(ArkAlert.tagName)) {
12410
12664
  customElements.define(ArkAlert.tagName, ArkAlert);
12411
12665
  }
@@ -12538,20 +12792,41 @@ function registerTooarkComponents() {
12538
12792
  }
12539
12793
  }
12540
12794
 
12795
+ exports.ARK_MARK_PATHS = ARK_MARK_PATHS;
12796
+ exports.ARK_MARK_SHAPES = ARK_MARK_SHAPES;
12797
+ exports.ArkAlert = ArkAlert;
12798
+ exports.ArkAvatar = ArkAvatar;
12541
12799
  exports.ArkBadge = ArkBadge;
12542
12800
  exports.ArkButton = ArkButton;
12543
12801
  exports.ArkCalendar = ArkCalendar;
12802
+ exports.ArkCard = ArkCard;
12544
12803
  exports.ArkCarousel = ArkCarousel;
12804
+ exports.ArkCheckbox = ArkCheckbox;
12545
12805
  exports.ArkClock = ArkClock;
12806
+ exports.ArkColorSwatches = ArkColorSwatches;
12807
+ exports.ArkCommandItem = ArkCommandItem;
12808
+ exports.ArkCommandPalette = ArkCommandPalette;
12809
+ exports.ArkCopyButton = ArkCopyButton;
12546
12810
  exports.ArkDatepicker = ArkDatepicker;
12547
12811
  exports.ArkDialog = ArkDialog;
12812
+ exports.ArkDrawer = ArkDrawer;
12548
12813
  exports.ArkEmpty = ArkEmpty;
12814
+ exports.ArkFileInput = ArkFileInput;
12549
12815
  exports.ArkInput = ArkInput;
12816
+ exports.ArkKbd = ArkKbd;
12817
+ exports.ArkKvEditor = ArkKvEditor;
12818
+ exports.ArkMark = ArkMark;
12550
12819
  exports.ArkMenu = ArkMenu;
12551
12820
  exports.ArkMenuItem = ArkMenuItem;
12821
+ exports.ArkProgress = ArkProgress;
12822
+ exports.ArkRadio = ArkRadio;
12552
12823
  exports.ArkScheduler = ArkScheduler;
12553
12824
  exports.ArkSelect = ArkSelect;
12825
+ exports.ArkShapePicker = ArkShapePicker;
12554
12826
  exports.ArkSkeleton = ArkSkeleton;
12827
+ exports.ArkSpinner = ArkSpinner;
12828
+ exports.ArkSplitPane = ArkSplitPane;
12829
+ exports.ArkStatusDot = ArkStatusDot;
12555
12830
  exports.ArkSwitch = ArkSwitch;
12556
12831
  exports.ArkTab = ArkTab;
12557
12832
  exports.ArkTabs = ArkTabs;
@@ -12560,5 +12835,6 @@ exports.ArkToaster = ArkToaster;
12560
12835
  exports.ArkToggle = ArkToggle;
12561
12836
  exports.ArkToggleGroup = ArkToggleGroup;
12562
12837
  exports.ArkTooltip = ArkTooltip;
12838
+ exports.normalizeMarkShape = normalizeMarkShape;
12563
12839
  exports.registerTooarkComponents = registerTooarkComponents;
12564
12840
  //# sourceMappingURL=index.cjs.map