@tooark/web-components 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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",
@@ -2464,7 +2503,7 @@ let nextId$1 = 0;
2464
2503
  * caixa por aria-labelledby e a alternam ao clique. Os nós próprios ficam no
2465
2504
  * início do host, marcados data-ark-chrome, antes dos filhos do usuário.
2466
2505
  */
2467
- class ArkCheckbox extends HTMLElement {
2506
+ class ArkCheckbox extends HTMLElementBase {
2468
2507
  static get observedAttributes() {
2469
2508
  return [
2470
2509
  "checked",
@@ -2786,7 +2825,7 @@ ArkCheckbox.tagName = "ark-checkbox";
2786
2825
  * (/segundo), no estilo DigitalClock do MUI. Valor sempre em 24h "HH:mm:ss";
2787
2826
  * `hours-format="12"` só muda a exibição (coluna AM/PM).
2788
2827
  */
2789
- class ArkClock extends HTMLElement {
2828
+ class ArkClock extends HTMLElementBase {
2790
2829
  constructor() {
2791
2830
  super(...arguments);
2792
2831
  this.root = null;
@@ -2812,7 +2851,7 @@ class ArkClock extends HTMLElement {
2812
2851
  };
2813
2852
  }
2814
2853
  static get observedAttributes() {
2815
- 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"];
2816
2855
  }
2817
2856
  connectedCallback() {
2818
2857
  this.build();
@@ -2832,6 +2871,9 @@ class ArkClock extends HTMLElement {
2832
2871
  get value() {
2833
2872
  return this.getAttribute("value") || "";
2834
2873
  }
2874
+ set value(value) {
2875
+ reflectAttr(this, "value", value);
2876
+ }
2835
2877
  getIntent() {
2836
2878
  const intent = (this.getAttribute("intent") || "").toLowerCase();
2837
2879
  if (intent === "primary" ||
@@ -2948,7 +2990,7 @@ class ArkClock extends HTMLElement {
2948
2990
  }
2949
2991
  build() {
2950
2992
  const palette = this.getPalette(this.getIntent());
2951
- const loc = resolveLocale((this.getAttribute("lang") || "en"), undefined);
2993
+ const loc = resolveLocale((this.getAttribute("lang") || "en"), this.getAttribute("locale-json") || undefined);
2952
2994
  this.root?.remove();
2953
2995
  this.columnEls.clear();
2954
2996
  const container = document.createElement("div");
@@ -3042,7 +3084,7 @@ ArkClock.tagName = "ark-clock";
3042
3084
  * movem e selecionam dando a volta, Home/End, Espaço seleciona. `change` só
3043
3085
  * quando a seleção muda pelo usuário.
3044
3086
  */
3045
- class ArkColorSwatches extends HTMLElement {
3087
+ class ArkColorSwatches extends HTMLElementBase {
3046
3088
  static get observedAttributes() {
3047
3089
  return ["value", "colors", "label", "aria-label", "disabled", "size", "theme", "class", "testid"];
3048
3090
  }
@@ -3116,6 +3158,12 @@ class ArkColorSwatches extends HTMLElement {
3116
3158
  }
3117
3159
  }
3118
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
+ }
3119
3167
  this.colorsProperty = Array.isArray(list) ? list : null;
3120
3168
  if (this.isConnected)
3121
3169
  this.updateAppearance();
@@ -3238,7 +3286,7 @@ ArkColorSwatches.tagName = "ark-color-swatches";
3238
3286
  * filtro e do nome (padrão: o texto dos filhos sem slot). A paleta escreve
3239
3287
  * `id`, `hidden`, `aria-selected` e a ordem visual.
3240
3288
  */
3241
- class ArkCommandItem extends HTMLElement {
3289
+ class ArkCommandItem extends HTMLElementBase {
3242
3290
  static get observedAttributes() {
3243
3291
  return ["value", "group", "label", "disabled", "class", "testid"];
3244
3292
  }
@@ -3272,10 +3320,16 @@ class ArkCommandItem extends HTMLElement {
3272
3320
  get value() {
3273
3321
  return this.getAttribute("value") || "";
3274
3322
  }
3323
+ set value(value) {
3324
+ reflectAttr(this, "value", value);
3325
+ }
3275
3326
  /** Seção em que a paleta lista o item; vazio é sem grupo. */
3276
3327
  get group() {
3277
3328
  return (this.getAttribute("group") || "").trim();
3278
3329
  }
3330
+ set group(value) {
3331
+ reflectAttr(this, "group", value);
3332
+ }
3279
3333
  /** Texto usado no filtro e no nome da opção: `label`, senão o texto dos filhos sem slot. */
3280
3334
  get label() {
3281
3335
  const attr = this.getAttribute("label");
@@ -3288,6 +3342,9 @@ class ArkCommandItem extends HTMLElement {
3288
3342
  .replace(/\s+/g, " ")
3289
3343
  .trim();
3290
3344
  }
3345
+ set label(value) {
3346
+ reflectAttr(this, "label", value);
3347
+ }
3291
3348
  get disabled() {
3292
3349
  return this.hasAttribute("disabled");
3293
3350
  }
@@ -3353,7 +3410,7 @@ function normalize(text) {
3353
3410
  * Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
3354
3411
  * página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
3355
3412
  */
3356
- class ArkCommandPalette extends HTMLElement {
3413
+ class ArkCommandPalette extends HTMLElementBase {
3357
3414
  static get observedAttributes() {
3358
3415
  return [
3359
3416
  "open",
@@ -3379,6 +3436,8 @@ class ArkCommandPalette extends HTMLElement {
3379
3436
  this.ownClasses = [];
3380
3437
  this.syncingClass = false;
3381
3438
  this.state = "closed";
3439
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
3440
+ this.openingOnConnect = false;
3382
3441
  this.releaseTrap = null;
3383
3442
  this.queryTimer = null;
3384
3443
  this.activeId = null;
@@ -3491,12 +3550,16 @@ class ArkCommandPalette extends HTMLElement {
3491
3550
  if (!this.observer) {
3492
3551
  // Itens que entram ou saem (busca assíncrona, frameworks) reordenam a lista.
3493
3552
  this.observer = new MutationObserver(() => this.syncItems());
3494
- 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 });
3495
3555
  }
3496
3556
  document.addEventListener("keydown", this.handleHotkey);
3497
3557
  this.updateAppearance();
3498
- if (this.hasAttribute("open"))
3558
+ if (this.hasAttribute("open")) {
3559
+ this.openingOnConnect = true;
3499
3560
  this.openNow();
3561
+ this.openingOnConnect = false;
3562
+ }
3500
3563
  }
3501
3564
  disconnectedCallback() {
3502
3565
  this.observer?.disconnect();
@@ -3576,9 +3639,12 @@ class ArkCommandPalette extends HTMLElement {
3576
3639
  this.removeAttribute("open");
3577
3640
  }
3578
3641
  // --- Itens ---
3579
- /** 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
+ */
3580
3646
  items() {
3581
- 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);
3582
3648
  }
3583
3649
  visibleItems() {
3584
3650
  return this.items().filter((item) => !item.hidden);
@@ -3625,13 +3691,17 @@ class ArkCommandPalette extends HTMLElement {
3625
3691
  }
3626
3692
  groups.forEach((group, index) => {
3627
3693
  const header = this.groupEls[index];
3628
- 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;
3629
3697
  header.style.order = String((index + 1) * 1000);
3630
3698
  applyTestHooks(this, "command-palette", header, "group");
3631
3699
  });
3632
3700
  this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
3633
3701
  this.emptyEl.hidden = visible.length > 0;
3634
- this.emptyEl.textContent = this.getLocale().noResults;
3702
+ const noResults = this.getLocale().noResults;
3703
+ if (this.emptyEl.textContent !== noResults)
3704
+ this.emptyEl.textContent = noResults;
3635
3705
  const enabled = visible.filter((item) => !item.disabled);
3636
3706
  if (!enabled.some((item) => item.id === this.activeId))
3637
3707
  this.activeId = enabled[0]?.id ?? null;
@@ -3694,7 +3764,17 @@ class ArkCommandPalette extends HTMLElement {
3694
3764
  });
3695
3765
  field?.select();
3696
3766
  this.inputEl?.inputElement?.setAttribute("aria-expanded", "true");
3697
- 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();
3698
3778
  }
3699
3779
  closeNow() {
3700
3780
  if (this.state !== "open")
@@ -3787,7 +3867,8 @@ class ArkCommandPalette extends HTMLElement {
3787
3867
  this.inputEl.removeAttribute(attr);
3788
3868
  }
3789
3869
  }
3790
- this.emptyEl.textContent = locale.noResults;
3870
+ if (this.emptyEl.textContent !== locale.noResults)
3871
+ this.emptyEl.textContent = locale.noResults;
3791
3872
  applyTestHooks(this, "command-palette", this);
3792
3873
  applyTestHooks(this, "command-palette", this.inputEl, "input");
3793
3874
  applyTestHooks(this, "command-palette", this.listEl, "list");
@@ -4021,7 +4102,7 @@ const CALENDAR_ATTRS = [
4021
4102
  "events",
4022
4103
  "event-display"
4023
4104
  ];
4024
- 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"];
4025
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>`;
4026
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>`;
4027
4108
  /**
@@ -4039,7 +4120,7 @@ const CLOCK_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="16" heigh
4039
4120
  * core (abre abaixo, vira para cima sem espaço) e animado com `scale` a
4040
4121
  * partir da origem.
4041
4122
  */
4042
- class ArkDatepicker extends HTMLElement {
4123
+ class ArkDatepicker extends HTMLElementBase {
4043
4124
  constructor() {
4044
4125
  super(...arguments);
4045
4126
  this.calendarEl = null;
@@ -4047,6 +4128,8 @@ class ArkDatepicker extends HTMLElement {
4047
4128
  this.inputComp = null;
4048
4129
  this.toggleEl = null;
4049
4130
  this.popupEl = null;
4131
+ /** Calendário e/ou relógio: inline no host ou dentro do popup. */
4132
+ this.panelEl = null;
4050
4133
  /** Para de reposicionar o popup em scroll/resize; só existe enquanto aberto. */
4051
4134
  this.disposePosition = null;
4052
4135
  this.hiddenInputEl = null;
@@ -4162,6 +4245,9 @@ class ArkDatepicker extends HTMLElement {
4162
4245
  get value() {
4163
4246
  return this.getAttribute("value") || "";
4164
4247
  }
4248
+ set value(value) {
4249
+ reflectAttr(this, "value", value);
4250
+ }
4165
4251
  hasRendered() {
4166
4252
  return this.calendarEl !== null || this.clockEl !== null;
4167
4253
  }
@@ -4321,6 +4407,7 @@ class ArkDatepicker extends HTMLElement {
4321
4407
  this.inputComp = null;
4322
4408
  this.toggleEl = null;
4323
4409
  this.popupEl = null;
4410
+ this.panelEl = null;
4324
4411
  this.hiddenInputEl = null;
4325
4412
  }
4326
4413
  forwardAttr(target, name) {
@@ -4363,8 +4450,14 @@ class ArkDatepicker extends HTMLElement {
4363
4450
  }
4364
4451
  render() {
4365
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;
4366
4458
  if (!this.isInputMode()) {
4367
4459
  this.appendChild(panel);
4460
+ this.appendChild(hidden);
4368
4461
  this.applyHooks();
4369
4462
  return;
4370
4463
  }
@@ -4417,8 +4510,6 @@ class ArkDatepicker extends HTMLElement {
4417
4510
  popup.setAttribute("popover", "manual");
4418
4511
  popup.setAttribute("role", "dialog");
4419
4512
  popup.appendChild(panel);
4420
- const hidden = document.createElement("input");
4421
- hidden.type = "hidden";
4422
4513
  wrapper.appendChild(inputComp);
4423
4514
  wrapper.appendChild(popup);
4424
4515
  this.appendChild(wrapper);
@@ -4426,7 +4517,6 @@ class ArkDatepicker extends HTMLElement {
4426
4517
  this.inputComp = inputComp;
4427
4518
  this.toggleEl = toggle;
4428
4519
  this.popupEl = popup;
4429
- this.hiddenInputEl = hidden;
4430
4520
  this.applyHooks();
4431
4521
  }
4432
4522
  applyHooks() {
@@ -4486,10 +4576,21 @@ class ArkDatepicker extends HTMLElement {
4486
4576
  }
4487
4577
  /** Sincroniza aparência/estado do campo com os atributos atuais. */
4488
4578
  syncField() {
4489
- 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)
4490
4592
  return;
4491
4593
  const loc = this.getLocale();
4492
- const disabled = this.hasAttribute("disabled");
4493
4594
  this.forwardAttr(this.inputComp, "theme");
4494
4595
  this.inputComp.setAttribute("placeholder", this.getAttribute("placeholder") || this.getFormat().toLowerCase());
4495
4596
  if (disabled) {
@@ -4505,9 +4606,6 @@ class ArkDatepicker extends HTMLElement {
4505
4606
  this.popupEl.setAttribute("aria-label", loc.openCalendar);
4506
4607
  this.inputComp.inputElement?.setAttribute("aria-haspopup", "dialog");
4507
4608
  this.inputComp.inputElement?.setAttribute("aria-expanded", this.popupOpen ? "true" : "false");
4508
- this.hiddenInputEl.name = this.getAttribute("name") || "";
4509
- this.hiddenInputEl.value = this.getAttribute("value") || "";
4510
- this.hiddenInputEl.disabled = disabled;
4511
4609
  this.updateInputDisplay();
4512
4610
  }
4513
4611
  updateInputDisplay() {
@@ -4633,7 +4731,7 @@ function cssLength$2(value) {
4633
4731
  * navegando por cursor virtual ainda alcança o conteúdo atrás. A página para
4634
4732
  * de rolar enquanto aberto (`lockScroll` de core), salvo com `no-scroll-lock`.
4635
4733
  */
4636
- class ArkDialog extends HTMLElement {
4734
+ class ArkDialog extends HTMLElementBase {
4637
4735
  static get observedAttributes() {
4638
4736
  return [
4639
4737
  "open",
@@ -4660,6 +4758,8 @@ class ArkDialog extends HTMLElement {
4660
4758
  this.syncingClass = false;
4661
4759
  /** Visibilidade real: `open` também cobre a animação de entrada; `closing` é a saída ainda visível. */
4662
4760
  this.state = "closed";
4761
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
4762
+ this.openingOnConnect = false;
4663
4763
  this.releaseTrap = null;
4664
4764
  /** Motivo pedido por `close(reason)`, lido quando o atributo `open` some. */
4665
4765
  this.pendingReason = null;
@@ -4685,8 +4785,11 @@ class ArkDialog extends HTMLElement {
4685
4785
  this.observer.observe(this, { childList: true });
4686
4786
  }
4687
4787
  this.updateAppearance();
4688
- if (this.hasAttribute("open"))
4788
+ if (this.hasAttribute("open")) {
4789
+ this.openingOnConnect = true;
4689
4790
  this.openNow();
4791
+ this.openingOnConnect = false;
4792
+ }
4690
4793
  }
4691
4794
  disconnectedCallback() {
4692
4795
  this.observer?.disconnect();
@@ -4776,7 +4879,17 @@ class ArkDialog extends HTMLElement {
4776
4879
  this.close("backdrop");
4777
4880
  }
4778
4881
  });
4779
- 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();
4780
4893
  }
4781
4894
  closeNow(reason) {
4782
4895
  if (this.state !== "open")
@@ -4988,7 +5101,7 @@ function cssLength$1(value) {
4988
5101
  * verdade, como no ark-dialog, e em overlay a página para de rolar enquanto
4989
5102
  * aberta, salvo com `no-scroll-lock`.
4990
5103
  */
4991
- class ArkDrawer extends HTMLElement {
5104
+ class ArkDrawer extends HTMLElementBase {
4992
5105
  static get observedAttributes() {
4993
5106
  return [
4994
5107
  "open",
@@ -5014,6 +5127,8 @@ class ArkDrawer extends HTMLElement {
5014
5127
  this.ownClasses = [];
5015
5128
  this.syncingClass = false;
5016
5129
  this.state = "closed";
5130
+ /** A abertura em curso veio do connectedCallback: o ark-open espera um microtask. */
5131
+ this.openingOnConnect = false;
5017
5132
  this.releaseTrap = null;
5018
5133
  this.pendingReason = null;
5019
5134
  this.warned = false;
@@ -5036,8 +5151,11 @@ class ArkDrawer extends HTMLElement {
5036
5151
  this.observer.observe(this, { childList: true });
5037
5152
  }
5038
5153
  this.updateAppearance();
5039
- if (this.hasAttribute("open"))
5154
+ if (this.hasAttribute("open")) {
5155
+ this.openingOnConnect = true;
5040
5156
  this.openNow();
5157
+ this.openingOnConnect = false;
5158
+ }
5041
5159
  }
5042
5160
  disconnectedCallback() {
5043
5161
  this.observer?.disconnect();
@@ -5101,10 +5219,16 @@ class ArkDrawer extends HTMLElement {
5101
5219
  const side = (this.getAttribute("side") || "").toLowerCase();
5102
5220
  return side === "left" || side === "top" || side === "bottom" ? side : "right";
5103
5221
  }
5222
+ set side(value) {
5223
+ reflectAttr(this, "side", value);
5224
+ }
5104
5225
  /** `overlay` (popover modal com scrim) ou `inline` (no fluxo, só anima). Padrão: "overlay". */
5105
5226
  get mode() {
5106
5227
  return (this.getAttribute("mode") || "").toLowerCase() === "inline" ? "inline" : "overlay";
5107
5228
  }
5229
+ set mode(value) {
5230
+ reflectAttr(this, "mode", value);
5231
+ }
5108
5232
  /** Abre a gaveta: adiciona `open`, que faz o resto. */
5109
5233
  show() {
5110
5234
  if (!this.open)
@@ -5153,7 +5277,17 @@ class ArkDrawer extends HTMLElement {
5153
5277
  animation.cancel();
5154
5278
  void arkEnter(this, this.preset(), { easing: "sheet" });
5155
5279
  }
5156
- 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();
5157
5291
  }
5158
5292
  closeNow(reason) {
5159
5293
  if (this.state !== "open")
@@ -5355,7 +5489,7 @@ ArkDrawer.tagName = "ark-drawer";
5355
5489
  * `description`, em nós do componente ao fim do host. Filhos sem slot entram
5356
5490
  * entre a descrição e a ação. Não é interativo e não tem role próprio.
5357
5491
  */
5358
- class ArkEmpty extends HTMLElement {
5492
+ class ArkEmpty extends HTMLElementBase {
5359
5493
  constructor() {
5360
5494
  super(...arguments);
5361
5495
  this.ownClasses = [];
@@ -5474,7 +5608,7 @@ const UPLOAD_SVG = `
5474
5608
  * tela. O rótulo aponta para o input (associação nativa) e nomeia o botão
5475
5609
  * junto do próprio texto dele.
5476
5610
  */
5477
- class ArkFileInput extends HTMLElement {
5611
+ class ArkFileInput extends HTMLElementBase {
5478
5612
  constructor() {
5479
5613
  super(...arguments);
5480
5614
  this.inputEl = null;
@@ -5911,7 +6045,7 @@ let arkInputIdCounter = 0;
5911
6045
  * um botão de mostrar/ocultar na ponta direita. Atributos nativos como
5912
6046
  * `maxlength` ou `inputmode` são espelhados no <input> sem interpretação.
5913
6047
  */
5914
- class ArkInput extends HTMLElement {
6048
+ class ArkInput extends HTMLElementBase {
5915
6049
  constructor() {
5916
6050
  super(...arguments);
5917
6051
  this.inputEl = null;
@@ -6220,7 +6354,7 @@ ArkInput.tagName = "ark-input";
6220
6354
  * usuário. Não é interativo e não tem role próprio; para leitores de tela é
6221
6355
  * texto comum, como um <kbd>.
6222
6356
  */
6223
- class ArkKbd extends HTMLElement {
6357
+ class ArkKbd extends HTMLElementBase {
6224
6358
  constructor() {
6225
6359
  super(...arguments);
6226
6360
  this.ownClasses = [];
@@ -6342,7 +6476,7 @@ function cloneRow(row) {
6342
6476
  * adicionar e remover anunciam a contagem ao leitor de tela. A célula de
6343
6477
  * valor é um ark-input comum: autocomplete de variáveis fica no app.
6344
6478
  */
6345
- class ArkKvEditor extends HTMLElement {
6479
+ class ArkKvEditor extends HTMLElementBase {
6346
6480
  static get observedAttributes() {
6347
6481
  return [
6348
6482
  "rows",
@@ -6438,6 +6572,11 @@ class ArkKvEditor extends HTMLElement {
6438
6572
  return this.model.map((row) => ({ ...row }));
6439
6573
  }
6440
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
+ }
6441
6580
  this.model = Array.isArray(value) ? value.map(cloneRow) : [];
6442
6581
  this.resetRows();
6443
6582
  if (this.isConnected)
@@ -6815,9 +6954,11 @@ class ArkKvEditor extends HTMLElement {
6815
6954
  input.toggleAttribute("readonly", readonly);
6816
6955
  applyTestHooks(this, "kv-editor", input, name);
6817
6956
  }
6818
- // 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.
6819
6960
  const isSecret = withSecret && row.secret === true;
6820
- parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[row.type ?? ""] ?? "text"));
6961
+ parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
6821
6962
  parts.value.toggleAttribute("reveal", isSecret);
6822
6963
  if (parts.secret) {
6823
6964
  parts.secret.setAttribute("aria-label", locale.secret);
@@ -6835,9 +6976,8 @@ class ArkKvEditor extends HTMLElement {
6835
6976
  }
6836
6977
  if (parts.type) {
6837
6978
  parts.type.options = types.map((type) => ({ value: type, label: type }));
6838
- const current = row.type && types.includes(row.type) ? row.type : types[0];
6839
- if (parts.type.value !== current)
6840
- parts.type.value = current;
6979
+ if (rowType && parts.type.value !== rowType)
6980
+ parts.type.value = rowType;
6841
6981
  parts.type.setAttribute("aria-label", locale.type);
6842
6982
  parts.type.setAttribute("size", size);
6843
6983
  parts.type.toggleAttribute("disabled", readonly);
@@ -6996,7 +7136,7 @@ function cssLength(value) {
6996
7136
  * nomeado; sem ele é decorativo (`aria-hidden`): o texto ao lado é o que
6997
7137
  * conta.
6998
7138
  */
6999
- class ArkMark extends HTMLElement {
7139
+ class ArkMark extends HTMLElementBase {
7000
7140
  constructor() {
7001
7141
  super(...arguments);
7002
7142
  this.ownClasses = [];
@@ -7101,7 +7241,7 @@ let menuSeq = 0;
7101
7241
  * a saída são transições CSS em components.css, porque o light dismiss de um
7102
7242
  * popover auto não pode ser interceptado por JS para animar antes de esconder.
7103
7243
  */
7104
- class ArkMenu extends HTMLElement {
7244
+ class ArkMenu extends HTMLElementBase {
7105
7245
  static get observedAttributes() {
7106
7246
  return ["for", "open", "align", "direction", "size", "theme", "class", "testid"];
7107
7247
  }
@@ -7272,6 +7412,11 @@ class ArkMenu extends HTMLElement {
7272
7412
  }
7273
7413
  set open(value) {
7274
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
+ }
7275
7420
  if (next) {
7276
7421
  this.show();
7277
7422
  }
@@ -7489,7 +7634,7 @@ const CHECK_SVG$1 = `
7489
7634
  * item. Seleção, foco e teclado são coordenados pelo ark-menu; `size` e
7490
7635
  * `theme` chegam propagados dele.
7491
7636
  */
7492
- class ArkMenuItem extends HTMLElement {
7637
+ class ArkMenuItem extends HTMLElementBase {
7493
7638
  static get observedAttributes() {
7494
7639
  return ["value", "disabled", "intent", "divider", "checked", "static", "size", "theme", "class", "testid"];
7495
7640
  }
@@ -7533,6 +7678,9 @@ class ArkMenuItem extends HTMLElement {
7533
7678
  get value() {
7534
7679
  return this.getAttribute("value") || "";
7535
7680
  }
7681
+ set value(value) {
7682
+ reflectAttr(this, "value", value);
7683
+ }
7536
7684
  get disabled() {
7537
7685
  return this.hasAttribute("disabled");
7538
7686
  }
@@ -7544,6 +7692,11 @@ class ArkMenuItem extends HTMLElement {
7544
7692
  return this.hasAttribute("checked") && this.getAttribute("checked") !== "false";
7545
7693
  }
7546
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
+ }
7547
7700
  this.setAttribute("checked", coerceBooleanAttr(value) ? "" : "false");
7548
7701
  }
7549
7702
  /** Item selecionável (não é divisor nem conteúdo estático). */
@@ -7709,7 +7862,7 @@ ArkMenuItem.tagName = "ark-menu-item";
7709
7862
  * loop, com duração fixa e isento de movimento reduzido, como o spinner: é o
7710
7863
  * único sinal de progresso.
7711
7864
  */
7712
- class ArkProgress extends HTMLElement {
7865
+ class ArkProgress extends HTMLElementBase {
7713
7866
  constructor() {
7714
7867
  super(...arguments);
7715
7868
  this.ownClasses = [];
@@ -7894,7 +8047,7 @@ let nextId = 0;
7894
8047
  * marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
7895
8048
  * opção como no ark-checkbox.
7896
8049
  */
7897
- class ArkRadio extends HTMLElement {
8050
+ class ArkRadio extends HTMLElementBase {
7898
8051
  static get observedAttributes() {
7899
8052
  return [
7900
8053
  "checked",
@@ -8349,7 +8502,7 @@ const DEFAULT_EVENT_MINUTES = 60;
8349
8502
  * eventos são o conteúdo: clicar num evento emite `ark-event-click` e clicar num
8350
8503
  * espaço livre emite `ark-slot-click` (útil para criar um evento).
8351
8504
  */
8352
- class ArkScheduler extends HTMLElement {
8505
+ class ArkScheduler extends HTMLElementBase {
8353
8506
  constructor() {
8354
8507
  super(...arguments);
8355
8508
  this.root = null;
@@ -8358,6 +8511,8 @@ class ArkScheduler extends HTMLElement {
8358
8511
  this.refDate = new Date();
8359
8512
  this.nowTimer = null;
8360
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;
8361
8516
  this.syncingAttr = false;
8362
8517
  /** Linhas de "agora" vivas na tela: reposicionadas sem rebuild a cada minuto. */
8363
8518
  this.nowLines = [];
@@ -8413,6 +8568,12 @@ class ArkScheduler extends HTMLElement {
8413
8568
  return this.eventsProp ?? this.parseEventsAttr();
8414
8569
  }
8415
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
+ }
8416
8577
  this.eventsProp = Array.isArray(list) ? list : null;
8417
8578
  if (this.root)
8418
8579
  this.build();
@@ -8429,6 +8590,9 @@ class ArkScheduler extends HTMLElement {
8429
8590
  get date() {
8430
8591
  return formatISODate(this.refDate);
8431
8592
  }
8593
+ set date(value) {
8594
+ reflectAttr(this, "date", value);
8595
+ }
8432
8596
  parseEventsAttr() {
8433
8597
  const raw = this.getAttribute("events");
8434
8598
  if (!raw)
@@ -8692,8 +8856,8 @@ class ArkScheduler extends HTMLElement {
8692
8856
  applyTestHooks(this, "scheduler", nextBtn, "next");
8693
8857
  const title = document.createElement("h2");
8694
8858
  title.className = `${palette.headerText} ark:ml-1`;
8695
- title.setAttribute("aria-live", "polite");
8696
8859
  title.textContent = this.getTitle();
8860
+ this.announcePeriod(title.textContent);
8697
8861
  applyTestHooks(this, "scheduler", title, "title");
8698
8862
  left.appendChild(todayBtn);
8699
8863
  left.appendChild(prevBtn);
@@ -8727,6 +8891,8 @@ class ArkScheduler extends HTMLElement {
8727
8891
  return;
8728
8892
  this.setAttribute("view", detail.value);
8729
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();
8730
8896
  });
8731
8897
  header.appendChild(left);
8732
8898
  header.appendChild(group);
@@ -8982,6 +9148,7 @@ class ArkScheduler extends HTMLElement {
8982
9148
  this.syncDateAttr();
8983
9149
  this.setAttribute("view", "day");
8984
9150
  this.dispatchEvent(new CustomEvent("ark-view-change", { detail: { view: "day" }, bubbles: true, composed: true }));
9151
+ this.emitRangeChange();
8985
9152
  });
8986
9153
  cell.appendChild(more);
8987
9154
  }
@@ -9073,6 +9240,13 @@ class ArkScheduler extends HTMLElement {
9073
9240
  line.style.top = `${((nowMinutes - hourStart * 60) / totalMinutes) * bodyHeight}px`;
9074
9241
  }
9075
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
+ }
9076
9250
  build() {
9077
9251
  if (!this.locale)
9078
9252
  this.locale = this.getLocale();
@@ -9128,7 +9302,7 @@ let arkSelectIdCounter = 0;
9128
9302
  * propriedade JS), nunca de filhos: o <select> exige os <option> dentro dele
9129
9303
  * e a lib não move filhos do usuário.
9130
9304
  */
9131
- class ArkSelect extends HTMLElement {
9305
+ class ArkSelect extends HTMLElementBase {
9132
9306
  constructor() {
9133
9307
  super(...arguments);
9134
9308
  this.selectEl = null;
@@ -9434,7 +9608,7 @@ const SHAPE_LABEL = {
9434
9608
  * e nomeada pelo nome localizado da forma. Mesmo teclado do
9435
9609
  * ark-color-swatches. `change` só quando a seleção muda pelo usuário.
9436
9610
  */
9437
- class ArkShapePicker extends HTMLElement {
9611
+ class ArkShapePicker extends HTMLElementBase {
9438
9612
  static get observedAttributes() {
9439
9613
  return [
9440
9614
  "value",
@@ -9648,7 +9822,7 @@ const RADIUS = {
9648
9822
  * substitui o skeleton
9649
9823
  * entra com `.ark-animate-fade-in`, sem elemento próprio para isso.
9650
9824
  */
9651
- class ArkSkeleton extends HTMLElement {
9825
+ class ArkSkeleton extends HTMLElementBase {
9652
9826
  constructor() {
9653
9827
  super(...arguments);
9654
9828
  this.ownClasses = [];
@@ -9800,7 +9974,7 @@ const SPINNER_SVG = `
9800
9974
  * string `loading` do idioma). Gira sempre, inclusive sob movimento reduzido:
9801
9975
  * é o único sinal de progresso. Sem `intent` herda a cor do texto ao redor.
9802
9976
  */
9803
- class ArkSpinner extends HTMLElement {
9977
+ class ArkSpinner extends HTMLElementBase {
9804
9978
  constructor() {
9805
9979
  super(...arguments);
9806
9980
  this.ownClasses = [];
@@ -9909,7 +10083,7 @@ const BIG_STEP = 10;
9909
10083
  * reescrito a cada mudança) e `ark-resize` publica os tamanhos; persistir é
9910
10084
  * do app. Nada anima: redimensionar é interação de alta frequência.
9911
10085
  */
9912
- class ArkSplitPane extends HTMLElement {
10086
+ class ArkSplitPane extends HTMLElementBase {
9913
10087
  constructor() {
9914
10088
  super(...arguments);
9915
10089
  this.handles = [];
@@ -10020,7 +10194,8 @@ class ArkSplitPane extends HTMLElement {
10020
10194
  return this.normalizedSizes(this.panels().length);
10021
10195
  }
10022
10196
  set sizes(value) {
10023
- 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(","));
10024
10199
  }
10025
10200
  // --- Painéis e medidas ---
10026
10201
  /** Os filhos do usuário: tudo que não é chrome do componente. */
@@ -10206,7 +10381,7 @@ ArkSplitPane.tagName = "ark-split-pane";
10206
10381
  * (`aria-hidden`), para o texto ao lado ser o que conta. Estático por
10207
10382
  * design: nunca pulsa.
10208
10383
  */
10209
- class ArkStatusDot extends HTMLElement {
10384
+ class ArkStatusDot extends HTMLElementBase {
10210
10385
  constructor() {
10211
10386
  super(...arguments);
10212
10387
  this.ownClasses = [];
@@ -10297,7 +10472,7 @@ const CROSS_SVG = '<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" st
10297
10472
  * submetendo `name`/`value` apenas quando marcado. Tem tabela de proporções
10298
10473
  * própria, em vez da escala de altura dos demais controles.
10299
10474
  */
10300
- class ArkSwitch extends HTMLElement {
10475
+ class ArkSwitch extends HTMLElementBase {
10301
10476
  constructor() {
10302
10477
  super(...arguments);
10303
10478
  this.trackEl = null;
@@ -10602,7 +10777,7 @@ const CLOSE_SVG = `
10602
10777
  * Seleção e roving tabindex são coordenados pelo ark-tabs; `variant`,
10603
10778
  * `size`, `intent`, `theme` e idioma chegam propagados dele.
10604
10779
  */
10605
- class ArkTab extends HTMLElement {
10780
+ class ArkTab extends HTMLElementBase {
10606
10781
  static get observedAttributes() {
10607
10782
  return [
10608
10783
  "value",
@@ -10682,6 +10857,9 @@ class ArkTab extends HTMLElement {
10682
10857
  get value() {
10683
10858
  return this.getAttribute("value") || "";
10684
10859
  }
10860
+ set value(value) {
10861
+ reflectAttr(this, "value", value);
10862
+ }
10685
10863
  /** Aba ativa; o ark-tabs reflete aqui o seu `value`. */
10686
10864
  get selected() {
10687
10865
  return this.hasAttribute("selected");
@@ -10705,6 +10883,9 @@ class ArkTab extends HTMLElement {
10705
10883
  get closable() {
10706
10884
  return this.hasAttribute("closable") && this.getVariant() === "editor";
10707
10885
  }
10886
+ set closable(value) {
10887
+ this.toggleAttribute("closable", coerceBooleanAttr(value));
10888
+ }
10708
10889
  /** Pede a seleção desta aba: emite `change` com o valor, que o ark-tabs consolida. */
10709
10890
  select() {
10710
10891
  if (this.disabled || this.selected)
@@ -10955,7 +11136,7 @@ const PROPAGATED_ATTRS = ["variant", "size", "intent", "rounded", "fill", "theme
10955
11136
  * inserido de uma vez o grupo pode rodar antes de as abas serem upgraded, e
10956
11137
  * uma propriedade escrita antes do upgrade esconderia o accessor da classe.
10957
11138
  */
10958
- class ArkTabs extends HTMLElement {
11139
+ class ArkTabs extends HTMLElementBase {
10959
11140
  static get observedAttributes() {
10960
11141
  return [
10961
11142
  "value",
@@ -11188,7 +11369,7 @@ let arkTextareaIdCounter = 0;
11188
11369
  * (`field-sizing: content` nativo, com fallback por JS), `monospace` e
11189
11370
  * `resize` atendem edição de código e de dados.
11190
11371
  */
11191
- class ArkTextarea extends HTMLElement {
11372
+ class ArkTextarea extends HTMLElementBase {
11192
11373
  constructor() {
11193
11374
  super(...arguments);
11194
11375
  this.textareaEl = null;
@@ -11396,7 +11577,7 @@ ArkTextarea.tagName = "ark-textarea";
11396
11577
  * dialogs e menus, e é reaberta a cada toast novo para voltar ao topo da
11397
11578
  * pilha do top layer quando um overlay abriu depois dela.
11398
11579
  */
11399
- class ArkToaster extends HTMLElement {
11580
+ class ArkToaster extends HTMLElementBase {
11400
11581
  constructor() {
11401
11582
  super(...arguments);
11402
11583
  this.root = null;
@@ -11451,15 +11632,8 @@ class ArkToaster extends HTMLElement {
11451
11632
  this.entered.delete(id);
11452
11633
  }
11453
11634
  this.toasts = [item, ...this.toasts.filter((toast) => toast.id !== id)];
11454
- const maxVisible = this.getMaxVisible();
11455
- if (this.toasts.length > maxVisible) {
11456
- const removed = this.toasts.slice(maxVisible);
11457
- this.toasts = this.toasts.slice(0, maxVisible);
11458
- for (const toast of removed) {
11459
- this.clearTimer(toast.id);
11460
- }
11461
- }
11462
- this.scheduleDismiss(item);
11635
+ // O render agenda o fechamento dos visíveis; o mesmo id recomeça a contagem.
11636
+ this.clearTimer(id);
11463
11637
  this.render();
11464
11638
  // Um overlay aberto depois da pilha ficaria por cima dela: reentrar no top layer a põe acima de novo.
11465
11639
  this.raise();
@@ -11660,7 +11834,17 @@ class ArkToaster extends HTMLElement {
11660
11834
  this.root.className = `${palette.stack} ${this.getPositionClasses(this.getPosition())}`;
11661
11835
  applyTestHooks(this, "toaster", this.root);
11662
11836
  this.syncPopover();
11663
- 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
+ }
11664
11848
  for (const id of this.entered) {
11665
11849
  if (!activeIds.has(id))
11666
11850
  this.entered.delete(id);
@@ -11677,8 +11861,8 @@ class ArkToaster extends HTMLElement {
11677
11861
  }
11678
11862
  // Do mais antigo (fim da pilha) ao mais novo: um card novo entra antes do card do toast seguinte na lista.
11679
11863
  let next = null;
11680
- for (let index = this.toasts.length - 1; index >= 0; index--) {
11681
- const toast = this.toasts[index];
11864
+ for (let index = visible.length - 1; index >= 0; index--) {
11865
+ const toast = visible[index];
11682
11866
  let card = existing.get(toast.id);
11683
11867
  if (!card) {
11684
11868
  card = this.buildCard(toast, palette);
@@ -11769,7 +11953,7 @@ ArkToaster.tagName = "ark-toaster";
11769
11953
  * (classes, role, foco, teclado): os filhos do usuário ficam onde estão.
11770
11954
  * Dentro de um ark-toggle-group vira item de segmented control.
11771
11955
  */
11772
- class ArkToggle extends HTMLElement {
11956
+ class ArkToggle extends HTMLElementBase {
11773
11957
  static get observedAttributes() {
11774
11958
  return ["pressed", "disabled", "size", "intent", "theme", "value", "class", "testid"];
11775
11959
  }
@@ -11836,6 +12020,9 @@ class ArkToggle extends HTMLElement {
11836
12020
  get value() {
11837
12021
  return this.getAttribute("value") || "";
11838
12022
  }
12023
+ set value(value) {
12024
+ reflectAttr(this, "value", value);
12025
+ }
11839
12026
  toggle() {
11840
12027
  if (this.disabled)
11841
12028
  return;
@@ -11964,7 +12151,7 @@ ArkToggle.tagName = "ark-toggle";
11964
12151
  * (`role="group"` + classes): os itens do usuário ficam onde estão, então
11965
12152
  * frameworks podem adicionar/remover toggles livremente.
11966
12153
  */
11967
- class ArkToggleGroup extends HTMLElement {
12154
+ class ArkToggleGroup extends HTMLElementBase {
11968
12155
  static get observedAttributes() {
11969
12156
  return ["value", "multiple", "disabled", "size", "intent", "theme", "class", "testid"];
11970
12157
  }
@@ -12120,6 +12307,8 @@ ArkToggleGroup.tagName = "ark-toggle-group";
12120
12307
 
12121
12308
  /** Contador para o id do balão, que o `aria-describedby` do gatilho referencia. */
12122
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;
12123
12312
  /**
12124
12313
  * Dica de contexto. O host envolve o gatilho do usuário (primeiro filho sem
12125
12314
  * `slot`) sem movê-lo e cria o balão: `role="tooltip"` com `popover="manual"`,
@@ -12129,11 +12318,12 @@ let tooltipSeq = 0;
12129
12318
  * components.css). O gatilho recebe `aria-describedby` do balão e precisa ser
12130
12319
  * focável por conta própria.
12131
12320
  *
12132
- * Abre em hover (depois de `delay`) e em foco (na hora); fecha ao sair, ao
12133
- * 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`
12134
12324
  * de core, com flip quando não cabe. Entrada `fade` quick, sem saída animada.
12135
12325
  */
12136
- class ArkTooltip extends HTMLElement {
12326
+ class ArkTooltip extends HTMLElementBase {
12137
12327
  static get observedAttributes() {
12138
12328
  return ["content", "side", "delay", "open", "theme", "class", "testid"];
12139
12329
  }
@@ -12148,6 +12338,7 @@ class ArkTooltip extends HTMLElement {
12148
12338
  this.bubble = null;
12149
12339
  this.trigger = null;
12150
12340
  this.openTimer = null;
12341
+ this.hideTimer = null;
12151
12342
  this.disposePosition = null;
12152
12343
  this.isOpen = false;
12153
12344
  this.syncingOpen = false;
@@ -12157,12 +12348,14 @@ class ArkTooltip extends HTMLElement {
12157
12348
  this.handlePointerOver = (event) => {
12158
12349
  if (this.isInside(event.relatedTarget))
12159
12350
  return;
12351
+ // Voltou (ao gatilho ou ao balão) dentro da tolerância: a dica fica.
12352
+ this.cancelHide();
12160
12353
  this.scheduleShow();
12161
12354
  };
12162
12355
  this.handlePointerOut = (event) => {
12163
12356
  if (this.isInside(event.relatedTarget))
12164
12357
  return;
12165
- this.hide();
12358
+ this.scheduleHide();
12166
12359
  };
12167
12360
  // Clicar no gatilho dispensa a dica; ela volta só depois de sair e entrar de novo.
12168
12361
  this.handlePointerDown = () => {
@@ -12215,6 +12408,7 @@ class ArkTooltip extends HTMLElement {
12215
12408
  this.observer?.disconnect();
12216
12409
  this.observer = null;
12217
12410
  this.clearTimer();
12411
+ this.cancelHide();
12218
12412
  document.removeEventListener("keydown", this.handleDocumentKeydown, true);
12219
12413
  this.disposePosition?.();
12220
12414
  this.disposePosition = null;
@@ -12250,6 +12444,11 @@ class ArkTooltip extends HTMLElement {
12250
12444
  }
12251
12445
  set open(value) {
12252
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
+ }
12253
12452
  if (next) {
12254
12453
  this.show();
12255
12454
  }
@@ -12274,6 +12473,7 @@ class ArkTooltip extends HTMLElement {
12274
12473
  /** Fecha na hora, sem animação de saída. */
12275
12474
  hide() {
12276
12475
  this.clearTimer();
12476
+ this.cancelHide();
12277
12477
  if (!this.isOpen)
12278
12478
  return;
12279
12479
  this.isOpen = false;
@@ -12317,6 +12517,21 @@ class ArkTooltip extends HTMLElement {
12317
12517
  this.openTimer = null;
12318
12518
  }
12319
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
+ }
12320
12535
  scheduleShow() {
12321
12536
  if (this.isOpen || this.openTimer !== null)
12322
12537
  return;
@@ -12381,7 +12596,6 @@ class ArkTooltip extends HTMLElement {
12381
12596
  if (!this.ownBubble) {
12382
12597
  const bubble = document.createElement("div");
12383
12598
  bubble.setAttribute("data-ark-chrome", "bubble");
12384
- bubble.className = "ark:pointer-events-none";
12385
12599
  this.appendChild(bubble);
12386
12600
  this.ownBubble = bubble;
12387
12601
  }
@@ -12441,6 +12655,9 @@ ArkTooltip.tagName = "ark-tooltip";
12441
12655
  * para garantir que eles estejam disponíveis como elementos personalizados.
12442
12656
  */
12443
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;
12444
12661
  if (!customElements.get(ArkAlert.tagName)) {
12445
12662
  customElements.define(ArkAlert.tagName, ArkAlert);
12446
12663
  }
@@ -12573,5 +12790,5 @@ function registerTooarkComponents() {
12573
12790
  }
12574
12791
  }
12575
12792
 
12576
- 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 };
12577
12794
  //# sourceMappingURL=index.js.map