@tooark/web-components 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -11
- package/README.pt-BR.md +33 -11
- package/dist/index.cjs +489 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -19
- package/dist/index.d.ts +61 -19
- package/dist/index.js +489 -93
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -62,6 +62,33 @@ function applyTestHooks(host, component, el, part) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,
|
|
66
|
+
// `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca
|
|
67
|
+
// chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,
|
|
68
|
+
// na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do
|
|
69
|
+
// React e do Vue) não têm setter e ficam como estão.
|
|
70
|
+
/** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */
|
|
71
|
+
function upgradeProperties(element) {
|
|
72
|
+
const target = element;
|
|
73
|
+
for (const name of Object.keys(element)) {
|
|
74
|
+
if (!hasSetter(Object.getPrototypeOf(element), name))
|
|
75
|
+
continue;
|
|
76
|
+
const value = target[name];
|
|
77
|
+
delete target[name];
|
|
78
|
+
target[name] = value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,
|
|
82
|
+
// porque o nó já é um HTMLElement antes do registro.
|
|
83
|
+
function hasSetter(prototype, name) {
|
|
84
|
+
for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
|
|
85
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
86
|
+
if (descriptor)
|
|
87
|
+
return typeof descriptor.set === "function";
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
65
92
|
/** Ícone do botão de dispensar (chrome próprio do componente). */
|
|
66
93
|
const CLOSE_SVG$3 = `
|
|
67
94
|
<svg class="ark:h-full ark:w-full" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" aria-hidden="true">
|
|
@@ -107,6 +134,7 @@ class ArkAlert extends HTMLElementBase {
|
|
|
107
134
|
];
|
|
108
135
|
}
|
|
109
136
|
connectedCallback() {
|
|
137
|
+
upgradeProperties(this);
|
|
110
138
|
if (!this.observer) {
|
|
111
139
|
// Ícone ou ação que chegam depois (frameworks) recebem o hook.
|
|
112
140
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -296,7 +324,8 @@ const PERSON_SVG = `
|
|
|
296
324
|
* carregar, as iniciais de `name` (primeira letra, ou primeira mais última
|
|
297
325
|
* quando há sobrenome); sem nome e sem imagem, um glifo de pessoa decorativo
|
|
298
326
|
* (`aria-hidden`, a menos que o host tenha aria-label próprio). `color` troca
|
|
299
|
-
* o tint primary por uma cor própria (texto na cor, fundo suave)
|
|
327
|
+
* o tint primary por uma cor própria (texto na cor, fundo suave) e
|
|
328
|
+
* `variant="solid"` preenche o fundo com a cor e escreve as iniciais em branco.
|
|
300
329
|
*/
|
|
301
330
|
class ArkAvatar extends HTMLElementBase {
|
|
302
331
|
constructor() {
|
|
@@ -311,9 +340,10 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
311
340
|
this.ownLabel = null;
|
|
312
341
|
}
|
|
313
342
|
static get observedAttributes() {
|
|
314
|
-
return ["name", "src", "size", "shape", "color", "aria-label", "theme", "class", "testid"];
|
|
343
|
+
return ["name", "src", "size", "shape", "color", "variant", "aria-label", "theme", "class", "testid"];
|
|
315
344
|
}
|
|
316
345
|
connectedCallback() {
|
|
346
|
+
upgradeProperties(this);
|
|
317
347
|
if (!this.initialsEl)
|
|
318
348
|
this.render();
|
|
319
349
|
this.updateAppearance();
|
|
@@ -351,6 +381,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
351
381
|
getShape() {
|
|
352
382
|
return (this.getAttribute("shape") || "").toLowerCase() === "square" ? "square" : "circle";
|
|
353
383
|
}
|
|
384
|
+
getVariant() {
|
|
385
|
+
return (this.getAttribute("variant") || "").toLowerCase() === "solid" ? "solid" : "soft";
|
|
386
|
+
}
|
|
354
387
|
render() {
|
|
355
388
|
const initials = document.createElement("span");
|
|
356
389
|
initials.setAttribute("aria-hidden", "true");
|
|
@@ -389,7 +422,7 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
389
422
|
this.imageEl.hidden = failed;
|
|
390
423
|
this.imageEl.className = failed ? "" : "ark:h-full ark:w-full ark:object-cover";
|
|
391
424
|
}
|
|
392
|
-
// Cor própria: texto na cor e fundo
|
|
425
|
+
// Cor própria, como o badge: suave é texto na cor e fundo por color-mix; sólido é fundo na cor e texto branco.
|
|
393
426
|
applyCustomColor() {
|
|
394
427
|
const color = this.getAttribute("color")?.trim();
|
|
395
428
|
if (!color) {
|
|
@@ -397,8 +430,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
397
430
|
this.style.removeProperty("--ark-avatar-fg");
|
|
398
431
|
return;
|
|
399
432
|
}
|
|
400
|
-
this.
|
|
401
|
-
this.style.setProperty("--ark-avatar-
|
|
433
|
+
const solid = this.getVariant() === "solid";
|
|
434
|
+
this.style.setProperty("--ark-avatar-bg", solid ? color : `color-mix(in oklab, ${color} 18%, transparent)`);
|
|
435
|
+
this.style.setProperty("--ark-avatar-fg", solid ? "#fff" : color);
|
|
402
436
|
}
|
|
403
437
|
applyOwnClasses(next) {
|
|
404
438
|
this.syncingClass = true;
|
|
@@ -440,7 +474,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
440
474
|
].join(" ");
|
|
441
475
|
const colors = this.getAttribute("color")?.trim()
|
|
442
476
|
? "ark:bg-(--ark-avatar-bg) ark:text-(--ark-avatar-fg)"
|
|
443
|
-
:
|
|
477
|
+
: this.getVariant() === "solid"
|
|
478
|
+
? "ark:bg-primary ark:text-primary-fg"
|
|
479
|
+
: "ark:bg-primary-soft ark:text-primary-soft-fg";
|
|
444
480
|
this.applyOwnClasses([
|
|
445
481
|
"ark:inline-flex ark:shrink-0 ark:items-center ark:justify-center ark:overflow-hidden ark:align-middle ark:font-semibold ark:uppercase ark:leading-none ark:select-none",
|
|
446
482
|
sizing.box,
|
|
@@ -492,6 +528,7 @@ class ArkBadge extends HTMLElementBase {
|
|
|
492
528
|
return ["intent", "variant", "size", "rounded", "color", "theme", "class", "testid"];
|
|
493
529
|
}
|
|
494
530
|
connectedCallback() {
|
|
531
|
+
upgradeProperties(this);
|
|
495
532
|
this.updateAppearance();
|
|
496
533
|
}
|
|
497
534
|
attributeChangedCallback(name) {
|
|
@@ -779,6 +816,7 @@ class ArkButton extends HTMLElementBase {
|
|
|
779
816
|
* Chamado pelo navegador quando o elemento é adicionado ao DOM.
|
|
780
817
|
*/
|
|
781
818
|
connectedCallback() {
|
|
819
|
+
upgradeProperties(this);
|
|
782
820
|
this.updateAppearance();
|
|
783
821
|
}
|
|
784
822
|
/**
|
|
@@ -1303,6 +1341,7 @@ class ArkCalendar extends HTMLElementBase {
|
|
|
1303
1341
|
];
|
|
1304
1342
|
}
|
|
1305
1343
|
connectedCallback() {
|
|
1344
|
+
upgradeProperties(this);
|
|
1306
1345
|
this.locale = this.getLocale();
|
|
1307
1346
|
const parsed = this.parseDate(this.getAttribute("value"));
|
|
1308
1347
|
if (parsed) {
|
|
@@ -1924,6 +1963,7 @@ class ArkCard extends HTMLElementBase {
|
|
|
1924
1963
|
return ["heading", "padding", "rounded", "theme", "class", "testid"];
|
|
1925
1964
|
}
|
|
1926
1965
|
connectedCallback() {
|
|
1966
|
+
upgradeProperties(this);
|
|
1927
1967
|
if (!this.observer) {
|
|
1928
1968
|
// Slots que chegam depois (frameworks) recebem o hook.
|
|
1929
1969
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -2135,6 +2175,7 @@ class ArkCarousel extends HTMLElementBase {
|
|
|
2135
2175
|
this.addEventListener("focusout", this.handleMouseLeave);
|
|
2136
2176
|
}
|
|
2137
2177
|
connectedCallback() {
|
|
2178
|
+
upgradeProperties(this);
|
|
2138
2179
|
this.build();
|
|
2139
2180
|
if (!this.observer) {
|
|
2140
2181
|
this.observer = new MutationObserver((records) => {
|
|
@@ -2502,8 +2543,10 @@ let nextId$1 = 0;
|
|
|
2502
2543
|
* formulário; os dois são controles nativos, então <fieldset disabled> os
|
|
2503
2544
|
* desabilita sem JS. `label` vira um <label for> próprio; sem ele o host
|
|
2504
2545
|
* precisa de aria-label, ou de filhos (texto livre, links), que dão nome à
|
|
2505
|
-
* caixa por aria-labelledby e a alternam ao clique.
|
|
2506
|
-
*
|
|
2546
|
+
* caixa por aria-labelledby e a alternam ao clique. `helper` acrescenta uma
|
|
2547
|
+
* dica abaixo do rótulo, que descreve a caixa por aria-describedby. Os nós
|
|
2548
|
+
* próprios ficam no início do host, marcados data-ark-chrome, antes dos filhos
|
|
2549
|
+
* do usuário.
|
|
2507
2550
|
*/
|
|
2508
2551
|
class ArkCheckbox extends HTMLElementBase {
|
|
2509
2552
|
static get observedAttributes() {
|
|
@@ -2514,6 +2557,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2514
2557
|
"name",
|
|
2515
2558
|
"value",
|
|
2516
2559
|
"label",
|
|
2560
|
+
"helper",
|
|
2517
2561
|
"aria-label",
|
|
2518
2562
|
"size",
|
|
2519
2563
|
"intent",
|
|
@@ -2529,6 +2573,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2529
2573
|
this.boxEl = null;
|
|
2530
2574
|
this.iconEl = null;
|
|
2531
2575
|
this.labelEl = null;
|
|
2576
|
+
this.helperEl = null;
|
|
2532
2577
|
this.inputEl = null;
|
|
2533
2578
|
this.observer = null;
|
|
2534
2579
|
/** Glifo em exibição; a troca depois do primeiro render entra com scale-in. */
|
|
@@ -2558,6 +2603,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2558
2603
|
this.addEventListener("click", this.handleHostClick);
|
|
2559
2604
|
}
|
|
2560
2605
|
connectedCallback() {
|
|
2606
|
+
upgradeProperties(this);
|
|
2561
2607
|
if (!this.boxEl)
|
|
2562
2608
|
this.render();
|
|
2563
2609
|
if (!this.observer) {
|
|
@@ -2682,11 +2728,11 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2682
2728
|
getSizing() {
|
|
2683
2729
|
const size = (this.getAttribute("size") || "md").toLowerCase();
|
|
2684
2730
|
const sizes = {
|
|
2685
|
-
xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs" },
|
|
2686
|
-
sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm" },
|
|
2687
|
-
md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm" },
|
|
2688
|
-
lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base" },
|
|
2689
|
-
xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg" }
|
|
2731
|
+
xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs", helper: "ark:text-2xs" },
|
|
2732
|
+
sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
2733
|
+
md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
2734
|
+
lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base", helper: "ark:text-sm" },
|
|
2735
|
+
xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg", helper: "ark:text-base" }
|
|
2690
2736
|
};
|
|
2691
2737
|
return sizes[size] ?? sizes.md;
|
|
2692
2738
|
}
|
|
@@ -2730,7 +2776,32 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2730
2776
|
}
|
|
2731
2777
|
this.labelEl.htmlFor = this.boxEl?.id ?? "";
|
|
2732
2778
|
this.labelEl.textContent = text;
|
|
2733
|
-
this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
2779
|
+
this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
2780
|
+
}
|
|
2781
|
+
// Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a caixa por aria-describedby.
|
|
2782
|
+
// Com ela o host vira grid (updateAppearance): a caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
2783
|
+
syncHelper(sizing) {
|
|
2784
|
+
if (!this.boxEl)
|
|
2785
|
+
return;
|
|
2786
|
+
const text = this.getAttribute("helper");
|
|
2787
|
+
if (!text) {
|
|
2788
|
+
this.helperEl?.remove();
|
|
2789
|
+
this.helperEl = null;
|
|
2790
|
+
this.boxEl.removeAttribute("aria-describedby");
|
|
2791
|
+
return;
|
|
2792
|
+
}
|
|
2793
|
+
if (!this.helperEl) {
|
|
2794
|
+
const helper = document.createElement("span");
|
|
2795
|
+
helper.setAttribute("data-ark-chrome", "helper");
|
|
2796
|
+
helper.id = `${this.boxEl.id}-helper`;
|
|
2797
|
+
(this.labelEl ?? this.inputEl)?.after(helper);
|
|
2798
|
+
this.helperEl = helper;
|
|
2799
|
+
}
|
|
2800
|
+
if (this.helperEl.textContent !== text)
|
|
2801
|
+
this.helperEl.textContent = text;
|
|
2802
|
+
// order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
|
|
2803
|
+
this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
|
|
2804
|
+
this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
|
|
2734
2805
|
}
|
|
2735
2806
|
// Nome acessível da caixa: o <label for> próprio; senão aria-label; senão os filhos do usuário, via
|
|
2736
2807
|
// aria-labelledby no host (que ganha um id quando falta).
|
|
@@ -2758,6 +2829,16 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2758
2829
|
this.boxEl.removeAttribute("aria-label");
|
|
2759
2830
|
this.boxEl.removeAttribute("aria-labelledby");
|
|
2760
2831
|
}
|
|
2832
|
+
// Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
|
|
2833
|
+
// nós ocultos).
|
|
2834
|
+
if (this.helperEl) {
|
|
2835
|
+
if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
|
|
2836
|
+
this.helperEl.setAttribute("aria-hidden", "true");
|
|
2837
|
+
}
|
|
2838
|
+
else {
|
|
2839
|
+
this.helperEl.removeAttribute("aria-hidden");
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2761
2842
|
}
|
|
2762
2843
|
syncIcon(kind) {
|
|
2763
2844
|
if (!this.iconEl || kind === this.iconKind)
|
|
@@ -2793,11 +2874,20 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2793
2874
|
const checked = this.checked;
|
|
2794
2875
|
const indeterminate = this.indeterminate;
|
|
2795
2876
|
const disabled = this.disabled;
|
|
2877
|
+
// Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
2878
|
+
const layout = this.hasAttribute("helper")
|
|
2879
|
+
? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
|
|
2880
|
+
: "ark:inline-flex ark:gap-2";
|
|
2796
2881
|
// O host dimeriza tudo (caixa e rótulo) quando qualquer controle interno está desabilitado, inclusive
|
|
2797
2882
|
// por <fieldset disabled>.
|
|
2798
|
-
this.applyOwnClasses(
|
|
2883
|
+
this.applyOwnClasses([
|
|
2884
|
+
layout,
|
|
2885
|
+
"ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
|
|
2886
|
+
]
|
|
2887
|
+
.join(" ")
|
|
2888
|
+
.split(" "));
|
|
2799
2889
|
this.boxEl.className = [
|
|
2800
|
-
"ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
2890
|
+
"ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
2801
2891
|
palette.ring,
|
|
2802
2892
|
sizing.box,
|
|
2803
2893
|
checked || indeterminate
|
|
@@ -2808,6 +2898,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2808
2898
|
this.boxEl.disabled = disabled;
|
|
2809
2899
|
this.syncIcon(indeterminate ? "mixed" : checked ? "check" : "none");
|
|
2810
2900
|
this.syncLabel(sizing);
|
|
2901
|
+
this.syncHelper(sizing);
|
|
2811
2902
|
this.syncName();
|
|
2812
2903
|
this.inputEl.checked = checked;
|
|
2813
2904
|
this.inputEl.indeterminate = indeterminate;
|
|
@@ -2818,6 +2909,8 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2818
2909
|
applyTestHooks(this, "checkbox", this.inputEl, "input");
|
|
2819
2910
|
if (this.labelEl)
|
|
2820
2911
|
applyTestHooks(this, "checkbox", this.labelEl, "label");
|
|
2912
|
+
if (this.helperEl)
|
|
2913
|
+
applyTestHooks(this, "checkbox", this.helperEl, "helper");
|
|
2821
2914
|
}
|
|
2822
2915
|
}
|
|
2823
2916
|
ArkCheckbox.tagName = "ark-checkbox";
|
|
@@ -2856,6 +2949,7 @@ class ArkClock extends HTMLElementBase {
|
|
|
2856
2949
|
return ["value", "seconds", "step-minutes", "hours-format", "lang", "locale-json", "theme", "intent", "testid"];
|
|
2857
2950
|
}
|
|
2858
2951
|
connectedCallback() {
|
|
2952
|
+
upgradeProperties(this);
|
|
2859
2953
|
this.build();
|
|
2860
2954
|
}
|
|
2861
2955
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -3133,6 +3227,7 @@ class ArkColorSwatches extends HTMLElementBase {
|
|
|
3133
3227
|
this.addEventListener("keydown", this.handleKeydown);
|
|
3134
3228
|
}
|
|
3135
3229
|
connectedCallback() {
|
|
3230
|
+
upgradeProperties(this);
|
|
3136
3231
|
this.updateAppearance();
|
|
3137
3232
|
}
|
|
3138
3233
|
attributeChangedCallback(name) {
|
|
@@ -3307,6 +3402,7 @@ class ArkCommandItem extends HTMLElementBase {
|
|
|
3307
3402
|
this.addEventListener("click", this.handleClick);
|
|
3308
3403
|
}
|
|
3309
3404
|
connectedCallback() {
|
|
3405
|
+
upgradeProperties(this);
|
|
3310
3406
|
this.updateAppearance();
|
|
3311
3407
|
}
|
|
3312
3408
|
attributeChangedCallback(name) {
|
|
@@ -3407,7 +3503,9 @@ function normalize(text) {
|
|
|
3407
3503
|
* e um listbox oculto que é dono das opções visíveis por `aria-owns`. Itens
|
|
3408
3504
|
* e cabeçalhos se ordenam por `order` no CSS, então nada é inserido entre os
|
|
3409
3505
|
* filhos. Com `filter` o texto filtra localmente pelo `label` dos itens; em
|
|
3410
|
-
* qualquer caso `ark-query` sai com debounce para busca assíncrona.
|
|
3506
|
+
* qualquer caso `ark-query` sai com debounce para busca assíncrona. Sem opções
|
|
3507
|
+
* visíveis a mensagem é `noResults`; `hint` a troca enquanto o campo está
|
|
3508
|
+
* vazio e `busy` (busca em andamento) a troca por `searching`. O foco
|
|
3411
3509
|
* fica sempre no campo; setas movem a opção ativa (`aria-activedescendant`),
|
|
3412
3510
|
* Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
|
|
3413
3511
|
* página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
|
|
@@ -3421,6 +3519,8 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3421
3519
|
"filter",
|
|
3422
3520
|
"query-delay",
|
|
3423
3521
|
"label",
|
|
3522
|
+
"hint",
|
|
3523
|
+
"busy",
|
|
3424
3524
|
"theme",
|
|
3425
3525
|
"lang",
|
|
3426
3526
|
"locale-json",
|
|
@@ -3547,6 +3647,7 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3547
3647
|
this.addEventListener("ark-select", this.handleItemSelect);
|
|
3548
3648
|
}
|
|
3549
3649
|
connectedCallback() {
|
|
3650
|
+
upgradeProperties(this);
|
|
3550
3651
|
if (!this.inputEl)
|
|
3551
3652
|
this.render();
|
|
3552
3653
|
if (!this.observer) {
|
|
@@ -3585,6 +3686,10 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3585
3686
|
if (!this.isConnected)
|
|
3586
3687
|
return;
|
|
3587
3688
|
if (name === "open") {
|
|
3689
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
3690
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
3691
|
+
if (!this.observer)
|
|
3692
|
+
return;
|
|
3588
3693
|
if (this.hasAttribute("open")) {
|
|
3589
3694
|
this.openNow();
|
|
3590
3695
|
}
|
|
@@ -3617,6 +3722,13 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3617
3722
|
set noScrollLock(value) {
|
|
3618
3723
|
this.toggleAttribute("no-scroll-lock", core.coerceBooleanAttr(value));
|
|
3619
3724
|
}
|
|
3725
|
+
/** Busca assíncrona em andamento (atributo `busy`): o listbox fica `aria-busy` e, sem opções, aparece `searching`. */
|
|
3726
|
+
get busy() {
|
|
3727
|
+
return this.hasAttribute("busy");
|
|
3728
|
+
}
|
|
3729
|
+
set busy(value) {
|
|
3730
|
+
this.toggleAttribute("busy", core.coerceBooleanAttr(value));
|
|
3731
|
+
}
|
|
3620
3732
|
/** Texto atual do campo de busca. */
|
|
3621
3733
|
get query() {
|
|
3622
3734
|
return this.inputEl?.value ?? "";
|
|
@@ -3700,15 +3812,31 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3700
3812
|
applyTestHooks(this, "command-palette", header, "group");
|
|
3701
3813
|
});
|
|
3702
3814
|
this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
|
|
3703
|
-
this.
|
|
3704
|
-
const noResults = this.getLocale().noResults;
|
|
3705
|
-
if (this.emptyEl.textContent !== noResults)
|
|
3706
|
-
this.emptyEl.textContent = noResults;
|
|
3815
|
+
this.syncEmpty(visible.length);
|
|
3707
3816
|
const enabled = visible.filter((item) => !item.disabled);
|
|
3708
3817
|
if (!enabled.some((item) => item.id === this.activeId))
|
|
3709
3818
|
this.activeId = enabled[0]?.id ?? null;
|
|
3710
3819
|
this.applyActive(items);
|
|
3711
3820
|
}
|
|
3821
|
+
// Mensagem sem opções visíveis: `searching` com `busy`, o `hint` do app com o campo vazio, senão `noResults`.
|
|
3822
|
+
syncEmpty(visible) {
|
|
3823
|
+
if (!this.listEl || !this.emptyEl)
|
|
3824
|
+
return;
|
|
3825
|
+
const locale = this.getLocale();
|
|
3826
|
+
const busy = this.busy;
|
|
3827
|
+
const hint = this.getAttribute("hint");
|
|
3828
|
+
const text = busy ? locale.searching : hint && this.query.trim() === "" ? hint : locale.noResults;
|
|
3829
|
+
this.emptyEl.hidden = visible > 0;
|
|
3830
|
+
// Só escreve o que mudou: o observer (subtree) veria a troca do nó de texto e sincronizaria em laço.
|
|
3831
|
+
if (this.emptyEl.textContent !== text)
|
|
3832
|
+
this.emptyEl.textContent = text;
|
|
3833
|
+
if (busy) {
|
|
3834
|
+
this.listEl.setAttribute("aria-busy", "true");
|
|
3835
|
+
}
|
|
3836
|
+
else {
|
|
3837
|
+
this.listEl.removeAttribute("aria-busy");
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3712
3840
|
applyActive(items) {
|
|
3713
3841
|
for (const item of items) {
|
|
3714
3842
|
const active = item.id === this.activeId;
|
|
@@ -3869,8 +3997,7 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3869
3997
|
this.inputEl.removeAttribute(attr);
|
|
3870
3998
|
}
|
|
3871
3999
|
}
|
|
3872
|
-
|
|
3873
|
-
this.emptyEl.textContent = locale.noResults;
|
|
4000
|
+
this.syncEmpty(this.visibleItems().length);
|
|
3874
4001
|
applyTestHooks(this, "command-palette", this);
|
|
3875
4002
|
applyTestHooks(this, "command-palette", this.inputEl, "input");
|
|
3876
4003
|
applyTestHooks(this, "command-palette", this.listEl, "list");
|
|
@@ -3920,6 +4047,7 @@ class ArkCopyButton extends ArkButton {
|
|
|
3920
4047
|
this.addEventListener("click", this.handleCopyClick);
|
|
3921
4048
|
}
|
|
3922
4049
|
connectedCallback() {
|
|
4050
|
+
upgradeProperties(this);
|
|
3923
4051
|
if (!this.childObserver) {
|
|
3924
4052
|
// Rótulo do usuário que chega ou sai depois decide se o rótulo próprio aparece.
|
|
3925
4053
|
this.childObserver = new MutationObserver(() => this.updateAppearance());
|
|
@@ -4202,6 +4330,7 @@ class ArkDatepicker extends HTMLElementBase {
|
|
|
4202
4330
|
];
|
|
4203
4331
|
}
|
|
4204
4332
|
connectedCallback() {
|
|
4333
|
+
upgradeProperties(this);
|
|
4205
4334
|
if (!this.hasRendered()) {
|
|
4206
4335
|
this.syncFromValue();
|
|
4207
4336
|
this.render();
|
|
@@ -4781,6 +4910,7 @@ class ArkDialog extends HTMLElementBase {
|
|
|
4781
4910
|
this.addEventListener("keydown", this.handleKeydown);
|
|
4782
4911
|
}
|
|
4783
4912
|
connectedCallback() {
|
|
4913
|
+
upgradeProperties(this);
|
|
4784
4914
|
if (!this.observer) {
|
|
4785
4915
|
// Um footer que chega depois (framework) recebe o hook; o resto do DOM é do usuário.
|
|
4786
4916
|
this.observer = new MutationObserver(() => this.syncFooter());
|
|
@@ -4814,6 +4944,10 @@ class ArkDialog extends HTMLElementBase {
|
|
|
4814
4944
|
if (name === "open") {
|
|
4815
4945
|
const reason = this.pendingReason ?? "api";
|
|
4816
4946
|
this.pendingReason = null;
|
|
4947
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
4948
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
4949
|
+
if (!this.observer)
|
|
4950
|
+
return;
|
|
4817
4951
|
if (this.hasAttribute("open")) {
|
|
4818
4952
|
this.openNow();
|
|
4819
4953
|
}
|
|
@@ -5097,11 +5231,12 @@ function cssLength$1(value) {
|
|
|
5097
5231
|
* página e só anima (o console inferior, um painel lateral fixo). Os filhos
|
|
5098
5232
|
* do usuário são o corpo e ficam onde estão; um filho `slot="footer"` vai ao
|
|
5099
5233
|
* fim por CSS. O cabeçalho (título `h2` de `label` e botão de fechar) é o
|
|
5100
|
-
* primeiro filho, marcado `data-ark-chrome
|
|
5101
|
-
*
|
|
5102
|
-
*
|
|
5103
|
-
*
|
|
5104
|
-
*
|
|
5234
|
+
* primeiro filho, marcado `data-ark-chrome`; um container `slot="actions"`
|
|
5235
|
+
* entra na linha dele por CSS, entre o título e o fechar. `side` escolhe a
|
|
5236
|
+
* borda, a direção do slide (com o easing `sheet`) e a borda desenhada;
|
|
5237
|
+
* `size` é um preset ou um comprimento CSS no eixo da gaveta. `open` é a fonte
|
|
5238
|
+
* da verdade, como no ark-dialog, e em overlay a página para de rolar
|
|
5239
|
+
* enquanto aberta, salvo com `no-scroll-lock`.
|
|
5105
5240
|
*/
|
|
5106
5241
|
class ArkDrawer extends HTMLElementBase {
|
|
5107
5242
|
static get observedAttributes() {
|
|
@@ -5126,6 +5261,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5126
5261
|
this.titleEl = null;
|
|
5127
5262
|
this.closeEl = null;
|
|
5128
5263
|
this.observer = null;
|
|
5264
|
+
/** Mede o filho `slot="actions"`: a largura dele é o espaço que o título deixa livre na linha do cabeçalho. */
|
|
5265
|
+
this.actionsObserver = null;
|
|
5266
|
+
/** O filho `slot="actions"` que o actionsObserver mede. */
|
|
5267
|
+
this.observedActions = null;
|
|
5129
5268
|
this.ownClasses = [];
|
|
5130
5269
|
this.syncingClass = false;
|
|
5131
5270
|
this.state = "closed";
|
|
@@ -5148,8 +5287,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5148
5287
|
this.addEventListener("keydown", this.handleKeydown);
|
|
5149
5288
|
}
|
|
5150
5289
|
connectedCallback() {
|
|
5290
|
+
upgradeProperties(this);
|
|
5151
5291
|
if (!this.observer) {
|
|
5152
|
-
|
|
5292
|
+
// Rodapé e ações que chegam depois (frameworks) ganham o hook; as ações também mudam o cabeçalho.
|
|
5293
|
+
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
5153
5294
|
this.observer.observe(this, { childList: true });
|
|
5154
5295
|
}
|
|
5155
5296
|
this.updateAppearance();
|
|
@@ -5162,6 +5303,9 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5162
5303
|
disconnectedCallback() {
|
|
5163
5304
|
this.observer?.disconnect();
|
|
5164
5305
|
this.observer = null;
|
|
5306
|
+
this.actionsObserver?.disconnect();
|
|
5307
|
+
this.actionsObserver = null;
|
|
5308
|
+
this.observedActions = null;
|
|
5165
5309
|
this.releaseTrap?.();
|
|
5166
5310
|
this.releaseTrap = null;
|
|
5167
5311
|
core.unlockScroll(this);
|
|
@@ -5179,6 +5323,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5179
5323
|
if (name === "open") {
|
|
5180
5324
|
const reason = this.pendingReason ?? "api";
|
|
5181
5325
|
this.pendingReason = null;
|
|
5326
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
5327
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
5328
|
+
if (!this.observer)
|
|
5329
|
+
return;
|
|
5182
5330
|
if (this.hasAttribute("open")) {
|
|
5183
5331
|
this.openNow();
|
|
5184
5332
|
}
|
|
@@ -5369,8 +5517,8 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5369
5517
|
.split(/\s+/)
|
|
5370
5518
|
.filter(Boolean);
|
|
5371
5519
|
}
|
|
5372
|
-
syncHeader(label, showClose) {
|
|
5373
|
-
if (!label && !showClose) {
|
|
5520
|
+
syncHeader(label, showClose, withActions) {
|
|
5521
|
+
if (!label && !showClose && !withActions) {
|
|
5374
5522
|
this.headerEl?.remove();
|
|
5375
5523
|
this.headerEl = null;
|
|
5376
5524
|
this.titleEl = null;
|
|
@@ -5383,8 +5531,14 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5383
5531
|
this.prepend(header);
|
|
5384
5532
|
this.headerEl = header;
|
|
5385
5533
|
}
|
|
5386
|
-
|
|
5387
|
-
|
|
5534
|
+
// As ações vêm antes do cabeçalho (order) e ocupam 3rem até o fim da linha do título: ele sobe por cima desse
|
|
5535
|
+
// espaço e guarda ao menos a altura dessa linha.
|
|
5536
|
+
this.headerEl.className = [
|
|
5537
|
+
"ark:sticky ark:top-0 ark:z-10 ark:-mx-6 ark:flex ark:items-start ark:gap-4 ark:bg-surface ark:px-6 ark:pt-6 ark:pb-4",
|
|
5538
|
+
withActions ? "ark:-mt-12 ark:min-h-16" : ""
|
|
5539
|
+
]
|
|
5540
|
+
.join(" ")
|
|
5541
|
+
.trim();
|
|
5388
5542
|
if (label) {
|
|
5389
5543
|
if (!this.titleEl) {
|
|
5390
5544
|
const title = document.createElement("h2");
|
|
@@ -5393,7 +5547,13 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5393
5547
|
this.titleEl = title;
|
|
5394
5548
|
}
|
|
5395
5549
|
this.titleEl.textContent = label;
|
|
5396
|
-
|
|
5550
|
+
// Com ações, o título deixa livre a largura medida delas mais o espaço entre as duas.
|
|
5551
|
+
this.titleEl.className = [
|
|
5552
|
+
"ark:min-w-0 ark:flex-1 ark:text-base ark:leading-6 ark:font-semibold ark:text-fg",
|
|
5553
|
+
withActions ? "ark:me-[calc(var(--ark-drawer-actions-width,0px)+1rem)]" : ""
|
|
5554
|
+
]
|
|
5555
|
+
.join(" ")
|
|
5556
|
+
.trim();
|
|
5397
5557
|
}
|
|
5398
5558
|
else {
|
|
5399
5559
|
this.titleEl?.remove();
|
|
@@ -5424,6 +5584,28 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5424
5584
|
if (footer)
|
|
5425
5585
|
applyTestHooks(this, "drawer", footer, "footer");
|
|
5426
5586
|
}
|
|
5587
|
+
// Passa a medir o filho `slot="actions"` atual (ou nenhum). Sem ResizeObserver (SSR, jsdom) o título não reserva
|
|
5588
|
+
// a largura delas, só o espaço entre os dois.
|
|
5589
|
+
syncActions(actions) {
|
|
5590
|
+
if (actions)
|
|
5591
|
+
applyTestHooks(this, "drawer", actions, "actions");
|
|
5592
|
+
if (actions === this.observedActions)
|
|
5593
|
+
return;
|
|
5594
|
+
this.actionsObserver?.disconnect();
|
|
5595
|
+
this.observedActions = actions;
|
|
5596
|
+
if (!actions) {
|
|
5597
|
+
this.style.removeProperty("--ark-drawer-actions-width");
|
|
5598
|
+
return;
|
|
5599
|
+
}
|
|
5600
|
+
if (typeof ResizeObserver === "undefined")
|
|
5601
|
+
return;
|
|
5602
|
+
if (!this.actionsObserver) {
|
|
5603
|
+
this.actionsObserver = new ResizeObserver(() => {
|
|
5604
|
+
this.style.setProperty("--ark-drawer-actions-width", `${this.observedActions?.offsetWidth ?? 0}px`);
|
|
5605
|
+
});
|
|
5606
|
+
}
|
|
5607
|
+
this.actionsObserver.observe(actions);
|
|
5608
|
+
}
|
|
5427
5609
|
applyOwnClasses(next) {
|
|
5428
5610
|
this.syncingClass = true;
|
|
5429
5611
|
for (const cls of this.ownClasses) {
|
|
@@ -5460,7 +5642,9 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5460
5642
|
this.setAttribute("tabindex", "-1");
|
|
5461
5643
|
this.setAttribute("data-ark-side", this.side);
|
|
5462
5644
|
this.setAttribute("data-ark-mode", this.mode);
|
|
5463
|
-
this.
|
|
5645
|
+
const actions = this.querySelector(':scope > [slot="actions"]');
|
|
5646
|
+
this.syncHeader(label, !this.hasAttribute("no-close-button"), actions !== null);
|
|
5647
|
+
this.syncActions(actions);
|
|
5464
5648
|
// Nome acessível: o título; sem ele um aria-label do usuário fica.
|
|
5465
5649
|
if (label && this.titleEl) {
|
|
5466
5650
|
this.setAttribute("aria-labelledby", this.titleId);
|
|
@@ -5504,6 +5688,7 @@ class ArkEmpty extends HTMLElementBase {
|
|
|
5504
5688
|
return ["heading", "description", "theme", "class", "testid"];
|
|
5505
5689
|
}
|
|
5506
5690
|
connectedCallback() {
|
|
5691
|
+
upgradeProperties(this);
|
|
5507
5692
|
if (!this.observer) {
|
|
5508
5693
|
// Ícone ou ação que chegam depois (frameworks) recebem o hook.
|
|
5509
5694
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -5691,6 +5876,7 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5691
5876
|
];
|
|
5692
5877
|
}
|
|
5693
5878
|
connectedCallback() {
|
|
5879
|
+
upgradeProperties(this);
|
|
5694
5880
|
if (!this.inputEl)
|
|
5695
5881
|
this.render();
|
|
5696
5882
|
this.updateAppearance();
|
|
@@ -6083,6 +6269,7 @@ class ArkInput extends HTMLElementBase {
|
|
|
6083
6269
|
];
|
|
6084
6270
|
}
|
|
6085
6271
|
connectedCallback() {
|
|
6272
|
+
upgradeProperties(this);
|
|
6086
6273
|
if (!this.inputEl) {
|
|
6087
6274
|
this.render();
|
|
6088
6275
|
}
|
|
@@ -6366,6 +6553,7 @@ class ArkKbd extends HTMLElementBase {
|
|
|
6366
6553
|
return ["size", "theme", "class", "testid"];
|
|
6367
6554
|
}
|
|
6368
6555
|
connectedCallback() {
|
|
6556
|
+
upgradeProperties(this);
|
|
6369
6557
|
this.updateAppearance();
|
|
6370
6558
|
}
|
|
6371
6559
|
attributeChangedCallback(name) {
|
|
@@ -6476,7 +6664,9 @@ function cloneRow(row) {
|
|
|
6476
6664
|
* preservados por posição) ou "json" (array com todos os campos). `change`
|
|
6477
6665
|
* publica as linhas a cada edição, inclusive ao sair do modo em massa;
|
|
6478
6666
|
* adicionar e remover anunciam a contagem ao leitor de tela. A célula de
|
|
6479
|
-
* valor é um ark-input
|
|
6667
|
+
* valor é um ark-input; a propriedade `valueField` troca pelo elemento que o
|
|
6668
|
+
* app criar (um campo com autocomplete de `{{variável}}`, por exemplo), exceto
|
|
6669
|
+
* nas linhas secretas, que mantêm o campo de senha.
|
|
6480
6670
|
*/
|
|
6481
6671
|
class ArkKvEditor extends HTMLElementBase {
|
|
6482
6672
|
static get observedAttributes() {
|
|
@@ -6519,6 +6709,10 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6519
6709
|
this.bulkBase = null;
|
|
6520
6710
|
/** Último texto em massa que o próprio componente escreveu, para não sobrescrever o que o usuário digita. */
|
|
6521
6711
|
this.bulkWritten = "";
|
|
6712
|
+
/** Fábrica da célula de valor (`valueField`); sem ela, todo valor é um ark-input. */
|
|
6713
|
+
this.valueFactory = null;
|
|
6714
|
+
/** Células de valor criadas pela fábrica, que não recebem `type`/`reveal` do ark-input. */
|
|
6715
|
+
this.customCells = new WeakSet();
|
|
6522
6716
|
// --- Interação ---
|
|
6523
6717
|
this.handleBulkInput = () => {
|
|
6524
6718
|
if (!this.bulkEl)
|
|
@@ -6541,6 +6735,7 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6541
6735
|
});
|
|
6542
6736
|
}
|
|
6543
6737
|
connectedCallback() {
|
|
6738
|
+
upgradeProperties(this);
|
|
6544
6739
|
if (!this.listEl)
|
|
6545
6740
|
this.render();
|
|
6546
6741
|
this.updateAppearance();
|
|
@@ -6628,6 +6823,20 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6628
6823
|
set secret(value) {
|
|
6629
6824
|
this.toggleAttribute("secret", core.coerceBooleanAttr(value));
|
|
6630
6825
|
}
|
|
6826
|
+
/**
|
|
6827
|
+
* Fábrica da célula de valor (propriedade JS): o elemento que ela devolve substitui o ark-input da linha, exceto
|
|
6828
|
+
* nas linhas secretas, que mantêm o campo de senha; `null` numa linha mantém o ark-input nela.
|
|
6829
|
+
*/
|
|
6830
|
+
get valueField() {
|
|
6831
|
+
return this.valueFactory;
|
|
6832
|
+
}
|
|
6833
|
+
set valueField(value) {
|
|
6834
|
+
this.valueFactory = typeof value === "function" ? value : null;
|
|
6835
|
+
// As células de valor são recriadas com a fábrica nova.
|
|
6836
|
+
this.resetRows();
|
|
6837
|
+
if (this.isConnected)
|
|
6838
|
+
this.updateAppearance();
|
|
6839
|
+
}
|
|
6631
6840
|
get readonly() {
|
|
6632
6841
|
return this.hasAttribute("readonly");
|
|
6633
6842
|
}
|
|
@@ -6676,6 +6885,10 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6676
6885
|
getLocale() {
|
|
6677
6886
|
return core.resolveLocale(this.getAttribute("lang") || "en", this.getAttribute("locale-json") || undefined);
|
|
6678
6887
|
}
|
|
6888
|
+
// Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
|
|
6889
|
+
effectiveType(row, types) {
|
|
6890
|
+
return types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
|
|
6891
|
+
}
|
|
6679
6892
|
getSize() {
|
|
6680
6893
|
const size = (this.getAttribute("size") || "").toLowerCase();
|
|
6681
6894
|
return size === "xs" || size === "sm" || size === "lg" || size === "xl" ? size : "md";
|
|
@@ -6818,16 +7031,7 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6818
7031
|
this.emitChange();
|
|
6819
7032
|
});
|
|
6820
7033
|
const key = this.createField(row.id, "key", size);
|
|
6821
|
-
const value = this.
|
|
6822
|
-
// Enter no valor da última linha acrescenta a próxima, como numa tabela.
|
|
6823
|
-
value.addEventListener("keydown", (event) => {
|
|
6824
|
-
if (event.key !== "Enter" || this.readonly)
|
|
6825
|
-
return;
|
|
6826
|
-
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
6827
|
-
return;
|
|
6828
|
-
event.preventDefault();
|
|
6829
|
-
this.add();
|
|
6830
|
-
});
|
|
7034
|
+
const value = this.createValueCell(row, size);
|
|
6831
7035
|
const remove = document.createElement("ark-button");
|
|
6832
7036
|
remove.setAttribute("variant", "ghost");
|
|
6833
7037
|
remove.setAttribute("intent", "neutral");
|
|
@@ -6876,15 +7080,69 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6876
7080
|
el.appendChild(remove);
|
|
6877
7081
|
return el;
|
|
6878
7082
|
}
|
|
7083
|
+
// Célula de valor: com `valueField` e fora das linhas secretas, o elemento da fábrica; senão o ark-input.
|
|
7084
|
+
createValueCell(row, size) {
|
|
7085
|
+
const custom = this.valueFactory && !(this.secret && row.secret === true)
|
|
7086
|
+
? this.valueFactory({ row: { ...row }, type: this.effectiveType(row, this.types) ?? "", size })
|
|
7087
|
+
: null;
|
|
7088
|
+
if (!(custom instanceof HTMLElement)) {
|
|
7089
|
+
const value = this.createField(row.id, "value", size);
|
|
7090
|
+
// Enter no valor da última linha acrescenta a próxima, como numa tabela.
|
|
7091
|
+
value.addEventListener("keydown", (event) => {
|
|
7092
|
+
if (event.key !== "Enter" || this.readonly)
|
|
7093
|
+
return;
|
|
7094
|
+
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
7095
|
+
return;
|
|
7096
|
+
event.preventDefault();
|
|
7097
|
+
this.add();
|
|
7098
|
+
});
|
|
7099
|
+
return value;
|
|
7100
|
+
}
|
|
7101
|
+
const cell = custom;
|
|
7102
|
+
cell.setAttribute("data-ark-field", "value");
|
|
7103
|
+
this.customCells.add(cell);
|
|
7104
|
+
// O campo do app pode emitir `input` antes de atualizar `value` (e `change` depois): só um valor novo conta.
|
|
7105
|
+
const sync = () => {
|
|
7106
|
+
const current = this.model.find((item) => item.id === row.id);
|
|
7107
|
+
const next = cell.value;
|
|
7108
|
+
if (!current || typeof next !== "string" || next === current.value)
|
|
7109
|
+
return;
|
|
7110
|
+
current.value = next;
|
|
7111
|
+
this.emitChange();
|
|
7112
|
+
};
|
|
7113
|
+
cell.addEventListener("input", (event) => {
|
|
7114
|
+
event.stopPropagation();
|
|
7115
|
+
sync();
|
|
7116
|
+
});
|
|
7117
|
+
cell.addEventListener("change", sync);
|
|
7118
|
+
// Enter que o campo não consumiu, ou o `ark-submit` de um campo que consome o Enter, na última linha acrescenta
|
|
7119
|
+
// a próxima.
|
|
7120
|
+
const addNext = (event) => {
|
|
7121
|
+
if (this.readonly || event.defaultPrevented)
|
|
7122
|
+
return;
|
|
7123
|
+
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
7124
|
+
return;
|
|
7125
|
+
if (event.cancelable)
|
|
7126
|
+
event.preventDefault();
|
|
7127
|
+
this.add();
|
|
7128
|
+
};
|
|
7129
|
+
cell.addEventListener("keydown", (event) => {
|
|
7130
|
+
if (event.key === "Enter")
|
|
7131
|
+
addNext(event);
|
|
7132
|
+
});
|
|
7133
|
+
cell.addEventListener("ark-submit", addNext);
|
|
7134
|
+
return cell;
|
|
7135
|
+
}
|
|
7136
|
+
// Filhos diretos da linha: uma célula de valor do app pode ter botões, selects e campos próprios dentro.
|
|
6879
7137
|
rowParts(el) {
|
|
6880
7138
|
return {
|
|
6881
|
-
enabled: el.querySelector("ark-checkbox"),
|
|
6882
|
-
key: el.querySelector('ark-input[data-ark-field="key"]'),
|
|
6883
|
-
value: el.querySelector('
|
|
6884
|
-
secret: this.secret ? el.querySelector("ark-button") : null,
|
|
6885
|
-
type: el.querySelector("ark-select"),
|
|
6886
|
-
description: el.querySelector('ark-input[data-ark-field="description"]'),
|
|
6887
|
-
remove: el.querySelector("ark-button:last-of-type")
|
|
7139
|
+
enabled: el.querySelector(":scope > ark-checkbox"),
|
|
7140
|
+
key: el.querySelector(':scope > ark-input[data-ark-field="key"]'),
|
|
7141
|
+
value: el.querySelector(':scope > [data-ark-field="value"]'),
|
|
7142
|
+
secret: this.secret ? el.querySelector(":scope > ark-button") : null,
|
|
7143
|
+
type: el.querySelector(":scope > ark-select"),
|
|
7144
|
+
description: el.querySelector(':scope > ark-input[data-ark-field="description"]'),
|
|
7145
|
+
remove: el.querySelector(":scope > ark-button:last-of-type")
|
|
6888
7146
|
};
|
|
6889
7147
|
}
|
|
6890
7148
|
// Classes de grid por combinação de colunas (segredo, tipo, descrição): literais completas, para o Tailwind
|
|
@@ -6928,6 +7186,17 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6928
7186
|
if (el !== anchor)
|
|
6929
7187
|
this.listEl.insertBefore(el, anchor);
|
|
6930
7188
|
previous = el;
|
|
7189
|
+
const rowType = this.effectiveType(row, types);
|
|
7190
|
+
const isSecret = withSecret && row.secret === true;
|
|
7191
|
+
// Com `valueField`, segredo e tipo decidem a célula (a fábrica recebe o tipo, o segredo fica no campo de
|
|
7192
|
+
// senha): quando mudam, a célula de valor é recriada. Sem fábrica o ark-input só troca de `type`.
|
|
7193
|
+
if (this.valueFactory) {
|
|
7194
|
+
const valueKey = `${isSecret}|${rowType ?? ""}`;
|
|
7195
|
+
if (el.dataset.arkValueKey !== undefined && el.dataset.arkValueKey !== valueKey) {
|
|
7196
|
+
this.rowParts(el).value.replaceWith(this.createValueCell(row, size));
|
|
7197
|
+
}
|
|
7198
|
+
el.dataset.arkValueKey = valueKey;
|
|
7199
|
+
}
|
|
6931
7200
|
const parts = this.rowParts(el);
|
|
6932
7201
|
el.className = [
|
|
6933
7202
|
"ark:grid ark:items-center ark:gap-2 ark:px-3 ark:py-1.5",
|
|
@@ -6956,12 +7225,12 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6956
7225
|
input.toggleAttribute("readonly", readonly);
|
|
6957
7226
|
applyTestHooks(this, "kv-editor", input, name);
|
|
6958
7227
|
}
|
|
6959
|
-
//
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
7228
|
+
// Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto. A célula
|
|
7229
|
+
// da fábrica decide o próprio tipo (recebe `type` no contexto).
|
|
7230
|
+
if (!this.customCells.has(parts.value)) {
|
|
7231
|
+
parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
|
|
7232
|
+
parts.value.toggleAttribute("reveal", isSecret);
|
|
7233
|
+
}
|
|
6965
7234
|
if (parts.secret) {
|
|
6966
7235
|
parts.secret.setAttribute("aria-label", locale.secret);
|
|
6967
7236
|
parts.secret.title = locale.secret;
|
|
@@ -7115,10 +7384,25 @@ const ARK_MARK_PATHS = {
|
|
|
7115
7384
|
triangle: "M12 2 22 21H2Z",
|
|
7116
7385
|
diamond: "M12 1 23 12 12 23 1 12Z",
|
|
7117
7386
|
star: "M12 1.5 15.2 8.6 23 9.6l-5.7 5.3 1.5 7.6L12 18.8 5.2 22.5l1.5-7.6L1 9.6l7.8-1Z",
|
|
7118
|
-
hexagon: "M7 2h10l5 10-5 10H7L2 12Z"
|
|
7387
|
+
hexagon: "M7 2h10l5 10-5 10H7L2 12Z",
|
|
7388
|
+
cross: "M9 2h6v7h7v6h-7v7H9v-7H2V9h7Z",
|
|
7389
|
+
pentagon: "M12 2l10.5 7.6-4 12.3h-13l-4-12.3Z",
|
|
7390
|
+
moon: "M12 2a7.1 7.1 0 0 0 10 10 10 10 0 1 1-10-10Z",
|
|
7391
|
+
asterisk: "M9.9 1.5h4.2v6.86l5.94-3.43 2.1 3.64L16.2 12l5.94 3.43-2.1 3.64-5.94-3.43v6.86H9.9v-6.86l-5.94 3.43-2.1-3.64L7.8 12 1.86 8.57l2.1-3.64 5.94 3.43Z"
|
|
7119
7392
|
};
|
|
7120
|
-
/** As
|
|
7121
|
-
const ARK_MARK_SHAPES = [
|
|
7393
|
+
/** As dez formas, na ordem canônica (a de `shapes="all"` no ark-shape-picker). */
|
|
7394
|
+
const ARK_MARK_SHAPES = [
|
|
7395
|
+
"circle",
|
|
7396
|
+
"square",
|
|
7397
|
+
"triangle",
|
|
7398
|
+
"diamond",
|
|
7399
|
+
"star",
|
|
7400
|
+
"hexagon",
|
|
7401
|
+
"cross",
|
|
7402
|
+
"pentagon",
|
|
7403
|
+
"moon",
|
|
7404
|
+
"asterisk"
|
|
7405
|
+
];
|
|
7122
7406
|
/** Normaliza o valor de `shape`; inválido cai em "circle". */
|
|
7123
7407
|
function normalizeMarkShape(value) {
|
|
7124
7408
|
const shape = (value || "").toLowerCase();
|
|
@@ -7150,6 +7434,7 @@ class ArkMark extends HTMLElementBase {
|
|
|
7150
7434
|
return ["shape", "color", "size", "label", "theme", "class", "testid"];
|
|
7151
7435
|
}
|
|
7152
7436
|
connectedCallback() {
|
|
7437
|
+
upgradeProperties(this);
|
|
7153
7438
|
if (!this.svgEl)
|
|
7154
7439
|
this.render();
|
|
7155
7440
|
this.updateAppearance();
|
|
@@ -7355,6 +7640,7 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7355
7640
|
this.addEventListener("toggle", this.handleToggle);
|
|
7356
7641
|
}
|
|
7357
7642
|
connectedCallback() {
|
|
7643
|
+
upgradeProperties(this);
|
|
7358
7644
|
if (!this.id)
|
|
7359
7645
|
this.id = `ark-menu-${++menuSeq}`;
|
|
7360
7646
|
if (!this.childObserver) {
|
|
@@ -7393,7 +7679,8 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7393
7679
|
return;
|
|
7394
7680
|
}
|
|
7395
7681
|
if (name === "open") {
|
|
7396
|
-
|
|
7682
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
|
|
7683
|
+
if (this.syncingOpen || !this.childObserver)
|
|
7397
7684
|
return;
|
|
7398
7685
|
if (this.hasAttribute("open")) {
|
|
7399
7686
|
this.show();
|
|
@@ -7414,8 +7701,9 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7414
7701
|
}
|
|
7415
7702
|
set open(value) {
|
|
7416
7703
|
const next = core.coerceBooleanAttr(value);
|
|
7417
|
-
//
|
|
7418
|
-
|
|
7704
|
+
// Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
|
|
7705
|
+
// a reaplica ao conectar): só reflete, e o connectedCallback abre.
|
|
7706
|
+
if (!this.isConnected || !this.childObserver) {
|
|
7419
7707
|
this.toggleAttribute("open", next);
|
|
7420
7708
|
return;
|
|
7421
7709
|
}
|
|
@@ -7665,6 +7953,7 @@ class ArkMenuItem extends HTMLElementBase {
|
|
|
7665
7953
|
this.addEventListener("keydown", this.handleKeydown);
|
|
7666
7954
|
}
|
|
7667
7955
|
connectedCallback() {
|
|
7956
|
+
upgradeProperties(this);
|
|
7668
7957
|
this.updateAppearance();
|
|
7669
7958
|
}
|
|
7670
7959
|
attributeChangedCallback(name) {
|
|
@@ -7889,6 +8178,7 @@ class ArkProgress extends HTMLElementBase {
|
|
|
7889
8178
|
];
|
|
7890
8179
|
}
|
|
7891
8180
|
connectedCallback() {
|
|
8181
|
+
upgradeProperties(this);
|
|
7892
8182
|
if (!this.trackEl)
|
|
7893
8183
|
this.render();
|
|
7894
8184
|
this.updateAppearance();
|
|
@@ -8047,7 +8337,7 @@ let nextId = 0;
|
|
|
8047
8337
|
* silêncio e `change` dispara só no que ganhou a marca; as setas movem o foco
|
|
8048
8338
|
* e marcam, Espaço marca o focado, e um único deles fica na ordem de Tab (o
|
|
8049
8339
|
* marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
|
|
8050
|
-
* opção como no ark-checkbox.
|
|
8340
|
+
* opção e `helper` a descreve, como no ark-checkbox.
|
|
8051
8341
|
*/
|
|
8052
8342
|
class ArkRadio extends HTMLElementBase {
|
|
8053
8343
|
static get observedAttributes() {
|
|
@@ -8057,6 +8347,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8057
8347
|
"name",
|
|
8058
8348
|
"value",
|
|
8059
8349
|
"label",
|
|
8350
|
+
"helper",
|
|
8060
8351
|
"aria-label",
|
|
8061
8352
|
"size",
|
|
8062
8353
|
"intent",
|
|
@@ -8072,6 +8363,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8072
8363
|
this.boxEl = null;
|
|
8073
8364
|
this.dotEl = null;
|
|
8074
8365
|
this.labelEl = null;
|
|
8366
|
+
this.helperEl = null;
|
|
8075
8367
|
this.inputEl = null;
|
|
8076
8368
|
this.observer = null;
|
|
8077
8369
|
/** Raiz do grupo no último connect, para ressincronizar os que ficam quando este sai. */
|
|
@@ -8115,6 +8407,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8115
8407
|
this.addEventListener("click", this.handleHostClick);
|
|
8116
8408
|
}
|
|
8117
8409
|
connectedCallback() {
|
|
8410
|
+
upgradeProperties(this);
|
|
8118
8411
|
if (!this.boxEl)
|
|
8119
8412
|
this.render();
|
|
8120
8413
|
if (!this.observer) {
|
|
@@ -8291,11 +8584,11 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8291
8584
|
getSizing() {
|
|
8292
8585
|
const size = (this.getAttribute("size") || "md").toLowerCase();
|
|
8293
8586
|
const sizes = {
|
|
8294
|
-
xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs" },
|
|
8295
|
-
sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm" },
|
|
8296
|
-
md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm" },
|
|
8297
|
-
lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base" },
|
|
8298
|
-
xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg" }
|
|
8587
|
+
xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs", helper: "ark:text-2xs" },
|
|
8588
|
+
sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
8589
|
+
md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
8590
|
+
lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base", helper: "ark:text-sm" },
|
|
8591
|
+
xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg", helper: "ark:text-base" }
|
|
8299
8592
|
};
|
|
8300
8593
|
return sizes[size] ?? sizes.md;
|
|
8301
8594
|
}
|
|
@@ -8337,7 +8630,32 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8337
8630
|
}
|
|
8338
8631
|
this.labelEl.htmlFor = this.boxEl?.id ?? "";
|
|
8339
8632
|
this.labelEl.textContent = text;
|
|
8340
|
-
this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
8633
|
+
this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
8634
|
+
}
|
|
8635
|
+
// Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a opção por aria-describedby.
|
|
8636
|
+
// Com ela o host vira grid (updateAppearance): a opção na primeira coluna, rótulo e dica empilhados na segunda.
|
|
8637
|
+
syncHelper(sizing) {
|
|
8638
|
+
if (!this.boxEl)
|
|
8639
|
+
return;
|
|
8640
|
+
const text = this.getAttribute("helper");
|
|
8641
|
+
if (!text) {
|
|
8642
|
+
this.helperEl?.remove();
|
|
8643
|
+
this.helperEl = null;
|
|
8644
|
+
this.boxEl.removeAttribute("aria-describedby");
|
|
8645
|
+
return;
|
|
8646
|
+
}
|
|
8647
|
+
if (!this.helperEl) {
|
|
8648
|
+
const helper = document.createElement("span");
|
|
8649
|
+
helper.setAttribute("data-ark-chrome", "helper");
|
|
8650
|
+
helper.id = `${this.boxEl.id}-helper`;
|
|
8651
|
+
(this.labelEl ?? this.inputEl)?.after(helper);
|
|
8652
|
+
this.helperEl = helper;
|
|
8653
|
+
}
|
|
8654
|
+
if (this.helperEl.textContent !== text)
|
|
8655
|
+
this.helperEl.textContent = text;
|
|
8656
|
+
// order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
|
|
8657
|
+
this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
|
|
8658
|
+
this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
|
|
8341
8659
|
}
|
|
8342
8660
|
syncName() {
|
|
8343
8661
|
if (!this.boxEl)
|
|
@@ -8363,6 +8681,16 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8363
8681
|
this.boxEl.removeAttribute("aria-label");
|
|
8364
8682
|
this.boxEl.removeAttribute("aria-labelledby");
|
|
8365
8683
|
}
|
|
8684
|
+
// Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
|
|
8685
|
+
// nós ocultos).
|
|
8686
|
+
if (this.helperEl) {
|
|
8687
|
+
if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
|
|
8688
|
+
this.helperEl.setAttribute("aria-hidden", "true");
|
|
8689
|
+
}
|
|
8690
|
+
else {
|
|
8691
|
+
this.helperEl.removeAttribute("aria-hidden");
|
|
8692
|
+
}
|
|
8693
|
+
}
|
|
8366
8694
|
}
|
|
8367
8695
|
syncDot(checked, sizing) {
|
|
8368
8696
|
if (!this.dotEl)
|
|
@@ -8398,9 +8726,18 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8398
8726
|
const sizing = this.getSizing();
|
|
8399
8727
|
const checked = this.checked;
|
|
8400
8728
|
const disabled = this.disabled;
|
|
8401
|
-
|
|
8729
|
+
// Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
8730
|
+
const layout = this.hasAttribute("helper")
|
|
8731
|
+
? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
|
|
8732
|
+
: "ark:inline-flex ark:gap-2";
|
|
8733
|
+
this.applyOwnClasses([
|
|
8734
|
+
layout,
|
|
8735
|
+
"ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
|
|
8736
|
+
]
|
|
8737
|
+
.join(" ")
|
|
8738
|
+
.split(" "));
|
|
8402
8739
|
this.boxEl.className = [
|
|
8403
|
-
"ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
8740
|
+
"ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
8404
8741
|
palette.ring,
|
|
8405
8742
|
sizing.box,
|
|
8406
8743
|
checked ? palette.on : "ark:border-border-strong ark:bg-surface ark:text-transparent ark:hover:bg-surface-muted"
|
|
@@ -8409,6 +8746,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8409
8746
|
this.boxEl.disabled = disabled;
|
|
8410
8747
|
this.syncDot(checked, sizing);
|
|
8411
8748
|
this.syncLabel(sizing);
|
|
8749
|
+
this.syncHelper(sizing);
|
|
8412
8750
|
this.syncName();
|
|
8413
8751
|
this.inputEl.checked = checked;
|
|
8414
8752
|
this.inputEl.disabled = disabled;
|
|
@@ -8419,6 +8757,8 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8419
8757
|
applyTestHooks(this, "radio", this.inputEl, "input");
|
|
8420
8758
|
if (this.labelEl)
|
|
8421
8759
|
applyTestHooks(this, "radio", this.labelEl, "label");
|
|
8760
|
+
if (this.helperEl)
|
|
8761
|
+
applyTestHooks(this, "radio", this.helperEl, "helper");
|
|
8422
8762
|
}
|
|
8423
8763
|
}
|
|
8424
8764
|
ArkRadio.tagName = "ark-radio";
|
|
@@ -8540,6 +8880,7 @@ class ArkScheduler extends HTMLElementBase {
|
|
|
8540
8880
|
];
|
|
8541
8881
|
}
|
|
8542
8882
|
connectedCallback() {
|
|
8883
|
+
upgradeProperties(this);
|
|
8543
8884
|
this.locale = this.getLocale();
|
|
8544
8885
|
this.refDate = parseLocalDate(this.getAttribute("date")) || new Date();
|
|
8545
8886
|
this.build();
|
|
@@ -9346,6 +9687,7 @@ class ArkSelect extends HTMLElementBase {
|
|
|
9346
9687
|
];
|
|
9347
9688
|
}
|
|
9348
9689
|
connectedCallback() {
|
|
9690
|
+
upgradeProperties(this);
|
|
9349
9691
|
if (!this.selectEl) {
|
|
9350
9692
|
this.render();
|
|
9351
9693
|
}
|
|
@@ -9601,19 +9943,26 @@ const SHAPE_LABEL = {
|
|
|
9601
9943
|
triangle: "shapeTriangle",
|
|
9602
9944
|
diamond: "shapeDiamond",
|
|
9603
9945
|
star: "shapeStar",
|
|
9604
|
-
hexagon: "shapeHexagon"
|
|
9946
|
+
hexagon: "shapeHexagon",
|
|
9947
|
+
cross: "shapeCross",
|
|
9948
|
+
pentagon: "shapePentagon",
|
|
9949
|
+
moon: "shapeMoon",
|
|
9950
|
+
asterisk: "shapeAsterisk"
|
|
9605
9951
|
};
|
|
9606
9952
|
/**
|
|
9607
9953
|
* Seletor de forma da marca de escopo: o PRÓPRIO host é o `role="radiogroup"`
|
|
9608
|
-
* com
|
|
9609
|
-
* ark-mark desenhado em `color` (a cor atual, para o usuário ver o par
|
|
9610
|
-
* e nomeada pelo nome localizado da forma.
|
|
9611
|
-
* ark-
|
|
9954
|
+
* com uma opção `role="radio"` por forma, renderizada pelo componente, cada
|
|
9955
|
+
* uma um ark-mark desenhado em `color` (a cor atual, para o usuário ver o par
|
|
9956
|
+
* real) e nomeada pelo nome localizado da forma. Sem `shapes` são as dez
|
|
9957
|
+
* formas do ark-mark, na ordem de `ARK_MARK_SHAPES`; `shapes` escolhe quais e
|
|
9958
|
+
* em que ordem. Mesmo teclado do ark-color-swatches. `change` só quando a
|
|
9959
|
+
* seleção muda pelo usuário.
|
|
9612
9960
|
*/
|
|
9613
9961
|
class ArkShapePicker extends HTMLElementBase {
|
|
9614
9962
|
static get observedAttributes() {
|
|
9615
9963
|
return [
|
|
9616
9964
|
"value",
|
|
9965
|
+
"shapes",
|
|
9617
9966
|
"color",
|
|
9618
9967
|
"label",
|
|
9619
9968
|
"aria-label",
|
|
@@ -9631,6 +9980,9 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9631
9980
|
this.ownClasses = [];
|
|
9632
9981
|
this.syncingClass = false;
|
|
9633
9982
|
this.options = [];
|
|
9983
|
+
/** Formas das opções renderizadas, na ordem dos botões. */
|
|
9984
|
+
this.offered = [];
|
|
9985
|
+
this.rendered = false;
|
|
9634
9986
|
this.handleKeydown = (event) => {
|
|
9635
9987
|
if (this.disabled)
|
|
9636
9988
|
return;
|
|
@@ -9659,13 +10011,13 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9659
10011
|
return;
|
|
9660
10012
|
event.preventDefault();
|
|
9661
10013
|
this.options[next].focus();
|
|
9662
|
-
this.select(
|
|
10014
|
+
this.select(this.offered[next]);
|
|
9663
10015
|
};
|
|
9664
10016
|
this.addEventListener("keydown", this.handleKeydown);
|
|
9665
10017
|
}
|
|
9666
10018
|
connectedCallback() {
|
|
9667
|
-
|
|
9668
|
-
|
|
10019
|
+
upgradeProperties(this);
|
|
10020
|
+
this.rendered = true;
|
|
9669
10021
|
this.updateAppearance();
|
|
9670
10022
|
}
|
|
9671
10023
|
attributeChangedCallback(name) {
|
|
@@ -9674,7 +10026,7 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9674
10026
|
this.applyOwnClasses(this.ownClasses);
|
|
9675
10027
|
return;
|
|
9676
10028
|
}
|
|
9677
|
-
if (this.
|
|
10029
|
+
if (!this.rendered || !this.isConnected)
|
|
9678
10030
|
return;
|
|
9679
10031
|
this.updateAppearance();
|
|
9680
10032
|
}
|
|
@@ -9691,19 +10043,41 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9691
10043
|
this.removeAttribute("value");
|
|
9692
10044
|
}
|
|
9693
10045
|
}
|
|
10046
|
+
/** Formas oferecidas, na ordem (atributo `shapes`, separado por vírgula, ou "all"); sem nenhuma válida, as dez. */
|
|
10047
|
+
get shapes() {
|
|
10048
|
+
const raw = (this.getAttribute("shapes") || "").trim().toLowerCase();
|
|
10049
|
+
if (raw === "all")
|
|
10050
|
+
return [...ARK_MARK_SHAPES];
|
|
10051
|
+
const list = [];
|
|
10052
|
+
for (const token of raw.split(",")) {
|
|
10053
|
+
const shape = token.trim();
|
|
10054
|
+
if (ARK_MARK_SHAPES.includes(shape) && !list.includes(shape))
|
|
10055
|
+
list.push(shape);
|
|
10056
|
+
}
|
|
10057
|
+
return list.length > 0 ? list : [...ARK_MARK_SHAPES];
|
|
10058
|
+
}
|
|
10059
|
+
set shapes(value) {
|
|
10060
|
+
const list = Array.isArray(value) ? value.join(",") : value || "";
|
|
10061
|
+
if (list) {
|
|
10062
|
+
this.setAttribute("shapes", list);
|
|
10063
|
+
}
|
|
10064
|
+
else {
|
|
10065
|
+
this.removeAttribute("shapes");
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
9694
10068
|
get disabled() {
|
|
9695
10069
|
return this.hasAttribute("disabled");
|
|
9696
10070
|
}
|
|
9697
10071
|
set disabled(value) {
|
|
9698
10072
|
this.toggleAttribute("disabled", core.coerceBooleanAttr(value));
|
|
9699
10073
|
}
|
|
9700
|
-
/** Seleciona uma forma como o usuário faria: muda `value`, foca a opção e emite `change`. */
|
|
10074
|
+
/** Seleciona uma forma oferecida como o usuário faria: muda `value`, foca a opção e emite `change`. */
|
|
9701
10075
|
select(value) {
|
|
9702
10076
|
const shape = normalizeMarkShape(value);
|
|
9703
|
-
if (this.disabled || shape === this.value)
|
|
10077
|
+
if (this.disabled || shape === this.value || !this.shapes.includes(shape))
|
|
9704
10078
|
return;
|
|
9705
10079
|
this.setAttribute("value", shape);
|
|
9706
|
-
this.options[
|
|
10080
|
+
this.options[this.offered.indexOf(shape)]?.focus();
|
|
9707
10081
|
this.dispatchEvent(new CustomEvent("change", { detail: { value: shape }, bubbles: true, composed: true }));
|
|
9708
10082
|
}
|
|
9709
10083
|
getLocale() {
|
|
@@ -9720,8 +10094,15 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9720
10094
|
};
|
|
9721
10095
|
return sizes[size] ?? sizes.md;
|
|
9722
10096
|
}
|
|
9723
|
-
|
|
9724
|
-
|
|
10097
|
+
// Recria as opções só quando a lista oferecida muda (atributo `shapes`); cada botão sabe a própria forma.
|
|
10098
|
+
syncOptions() {
|
|
10099
|
+
const shapes = this.shapes;
|
|
10100
|
+
if (shapes.join(",") === this.offered.join(","))
|
|
10101
|
+
return;
|
|
10102
|
+
for (const option of this.options)
|
|
10103
|
+
option.remove();
|
|
10104
|
+
this.offered = shapes;
|
|
10105
|
+
this.options = shapes.map((shape) => {
|
|
9725
10106
|
const button = document.createElement("button");
|
|
9726
10107
|
button.type = "button";
|
|
9727
10108
|
button.setAttribute("role", "radio");
|
|
@@ -9753,6 +10134,7 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9753
10134
|
const disabled = this.disabled;
|
|
9754
10135
|
const sizing = this.getSizing();
|
|
9755
10136
|
const color = this.getAttribute("color")?.trim() || "";
|
|
10137
|
+
this.syncOptions();
|
|
9756
10138
|
this.setAttribute("role", "radiogroup");
|
|
9757
10139
|
// Só quando muda: aria-label é observado e um set igual reentraria aqui.
|
|
9758
10140
|
const label = this.getAttribute("label");
|
|
@@ -9768,10 +10150,10 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9768
10150
|
.join(" ")
|
|
9769
10151
|
.split(" ")
|
|
9770
10152
|
.filter(Boolean));
|
|
9771
|
-
const selectedIndex = value ?
|
|
10153
|
+
const selectedIndex = value ? this.offered.indexOf(value) : -1;
|
|
9772
10154
|
const stop = selectedIndex >= 0 ? selectedIndex : 0;
|
|
9773
10155
|
this.options.forEach((option, index) => {
|
|
9774
|
-
const shape =
|
|
10156
|
+
const shape = this.offered[index];
|
|
9775
10157
|
const selected = index === selectedIndex;
|
|
9776
10158
|
option.setAttribute("aria-label", String(locale[SHAPE_LABEL[shape]]));
|
|
9777
10159
|
option.setAttribute("aria-checked", selected ? "true" : "false");
|
|
@@ -9837,6 +10219,7 @@ class ArkSkeleton extends HTMLElementBase {
|
|
|
9837
10219
|
return ["rows", "animated", "rounded", "color", "ratio", "theme", "class", "testid"];
|
|
9838
10220
|
}
|
|
9839
10221
|
connectedCallback() {
|
|
10222
|
+
upgradeProperties(this);
|
|
9840
10223
|
this.updateAppearance();
|
|
9841
10224
|
}
|
|
9842
10225
|
attributeChangedCallback(name) {
|
|
@@ -9988,6 +10371,7 @@ class ArkSpinner extends HTMLElementBase {
|
|
|
9988
10371
|
return ["size", "intent", "label", "lang", "locale-json", "theme", "class", "testid"];
|
|
9989
10372
|
}
|
|
9990
10373
|
connectedCallback() {
|
|
10374
|
+
upgradeProperties(this);
|
|
9991
10375
|
if (!this.iconEl)
|
|
9992
10376
|
this.render();
|
|
9993
10377
|
this.updateAppearance();
|
|
@@ -10163,6 +10547,7 @@ class ArkSplitPane extends HTMLElementBase {
|
|
|
10163
10547
|
return ["direction", "sizes", "lang", "locale-json", "theme", "class", "testid"];
|
|
10164
10548
|
}
|
|
10165
10549
|
connectedCallback() {
|
|
10550
|
+
upgradeProperties(this);
|
|
10166
10551
|
if (!this.observer) {
|
|
10167
10552
|
// Painéis que entram ou saem mudam o número de alças e a distribuição.
|
|
10168
10553
|
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
@@ -10393,6 +10778,7 @@ class ArkStatusDot extends HTMLElementBase {
|
|
|
10393
10778
|
return ["intent", "label", "size", "theme", "class", "testid"];
|
|
10394
10779
|
}
|
|
10395
10780
|
connectedCallback() {
|
|
10781
|
+
upgradeProperties(this);
|
|
10396
10782
|
this.updateAppearance();
|
|
10397
10783
|
}
|
|
10398
10784
|
attributeChangedCallback(name) {
|
|
@@ -10503,6 +10889,7 @@ class ArkSwitch extends HTMLElementBase {
|
|
|
10503
10889
|
];
|
|
10504
10890
|
}
|
|
10505
10891
|
connectedCallback() {
|
|
10892
|
+
upgradeProperties(this);
|
|
10506
10893
|
if (!this.trackEl) {
|
|
10507
10894
|
this.render();
|
|
10508
10895
|
}
|
|
@@ -10844,6 +11231,7 @@ class ArkTab extends HTMLElementBase {
|
|
|
10844
11231
|
this.addEventListener("keydown", this.handleKeydown);
|
|
10845
11232
|
}
|
|
10846
11233
|
connectedCallback() {
|
|
11234
|
+
upgradeProperties(this);
|
|
10847
11235
|
this.updateAppearance();
|
|
10848
11236
|
}
|
|
10849
11237
|
attributeChangedCallback(name) {
|
|
@@ -11204,6 +11592,7 @@ class ArkTabs extends HTMLElementBase {
|
|
|
11204
11592
|
this.addEventListener("keydown", this.handleKeydown);
|
|
11205
11593
|
}
|
|
11206
11594
|
connectedCallback() {
|
|
11595
|
+
upgradeProperties(this);
|
|
11207
11596
|
if (!this.observer) {
|
|
11208
11597
|
this.observer = new MutationObserver(() => this.syncTabs());
|
|
11209
11598
|
this.observer.observe(this, { childList: true, subtree: true });
|
|
@@ -11405,6 +11794,7 @@ class ArkTextarea extends HTMLElementBase {
|
|
|
11405
11794
|
];
|
|
11406
11795
|
}
|
|
11407
11796
|
connectedCallback() {
|
|
11797
|
+
upgradeProperties(this);
|
|
11408
11798
|
if (!this.textareaEl) {
|
|
11409
11799
|
this.render();
|
|
11410
11800
|
}
|
|
@@ -11602,6 +11992,7 @@ class ArkToaster extends HTMLElementBase {
|
|
|
11602
11992
|
return ["theme", "position", "rich-colors", "close-button", "max-visible", "duration", "lang", "testid"];
|
|
11603
11993
|
}
|
|
11604
11994
|
connectedCallback() {
|
|
11995
|
+
upgradeProperties(this);
|
|
11605
11996
|
this.build();
|
|
11606
11997
|
window.addEventListener("ark-toast", this.handleToast);
|
|
11607
11998
|
window.addEventListener("ark-toast-dismiss", this.handleDismiss);
|
|
@@ -11995,6 +12386,7 @@ class ArkToggle extends HTMLElementBase {
|
|
|
11995
12386
|
this.addEventListener("keyup", this.handleKeyup);
|
|
11996
12387
|
}
|
|
11997
12388
|
connectedCallback() {
|
|
12389
|
+
upgradeProperties(this);
|
|
11998
12390
|
this.updateAppearance();
|
|
11999
12391
|
}
|
|
12000
12392
|
attributeChangedCallback(name) {
|
|
@@ -12200,6 +12592,7 @@ class ArkToggleGroup extends HTMLElementBase {
|
|
|
12200
12592
|
this.addEventListener("change", this.handleToggleChange);
|
|
12201
12593
|
}
|
|
12202
12594
|
connectedCallback() {
|
|
12595
|
+
upgradeProperties(this);
|
|
12203
12596
|
if (!this.observer) {
|
|
12204
12597
|
this.observer = new MutationObserver(() => this.syncToggles());
|
|
12205
12598
|
this.observer.observe(this, { childList: true, subtree: true });
|
|
@@ -12398,6 +12791,7 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12398
12791
|
this.addEventListener("focusout", this.handleFocusOut);
|
|
12399
12792
|
}
|
|
12400
12793
|
connectedCallback() {
|
|
12794
|
+
upgradeProperties(this);
|
|
12401
12795
|
if (!this.observer) {
|
|
12402
12796
|
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
12403
12797
|
this.observer.observe(this, { childList: true });
|
|
@@ -12426,7 +12820,8 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12426
12820
|
if (!this.isConnected)
|
|
12427
12821
|
return;
|
|
12428
12822
|
if (name === "open") {
|
|
12429
|
-
|
|
12823
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
|
|
12824
|
+
if (this.syncingOpen || !this.observer)
|
|
12430
12825
|
return;
|
|
12431
12826
|
if (this.hasAttribute("open")) {
|
|
12432
12827
|
this.show();
|
|
@@ -12446,8 +12841,9 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12446
12841
|
}
|
|
12447
12842
|
set open(value) {
|
|
12448
12843
|
const next = core.coerceBooleanAttr(value);
|
|
12449
|
-
//
|
|
12450
|
-
|
|
12844
|
+
// Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
|
|
12845
|
+
// a reaplica ao conectar): só reflete, e o connectedCallback abre.
|
|
12846
|
+
if (!this.isConnected || !this.observer) {
|
|
12451
12847
|
this.toggleAttribute("open", next);
|
|
12452
12848
|
return;
|
|
12453
12849
|
}
|