@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.js
CHANGED
|
@@ -60,6 +60,33 @@ function applyTestHooks(host, component, el, part) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,
|
|
64
|
+
// `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca
|
|
65
|
+
// chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,
|
|
66
|
+
// na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do
|
|
67
|
+
// React e do Vue) não têm setter e ficam como estão.
|
|
68
|
+
/** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */
|
|
69
|
+
function upgradeProperties(element) {
|
|
70
|
+
const target = element;
|
|
71
|
+
for (const name of Object.keys(element)) {
|
|
72
|
+
if (!hasSetter(Object.getPrototypeOf(element), name))
|
|
73
|
+
continue;
|
|
74
|
+
const value = target[name];
|
|
75
|
+
delete target[name];
|
|
76
|
+
target[name] = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,
|
|
80
|
+
// porque o nó já é um HTMLElement antes do registro.
|
|
81
|
+
function hasSetter(prototype, name) {
|
|
82
|
+
for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
|
|
83
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
84
|
+
if (descriptor)
|
|
85
|
+
return typeof descriptor.set === "function";
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
63
90
|
/** Ícone do botão de dispensar (chrome próprio do componente). */
|
|
64
91
|
const CLOSE_SVG$3 = `
|
|
65
92
|
<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">
|
|
@@ -105,6 +132,7 @@ class ArkAlert extends HTMLElementBase {
|
|
|
105
132
|
];
|
|
106
133
|
}
|
|
107
134
|
connectedCallback() {
|
|
135
|
+
upgradeProperties(this);
|
|
108
136
|
if (!this.observer) {
|
|
109
137
|
// Ícone ou ação que chegam depois (frameworks) recebem o hook.
|
|
110
138
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -294,7 +322,8 @@ const PERSON_SVG = `
|
|
|
294
322
|
* carregar, as iniciais de `name` (primeira letra, ou primeira mais última
|
|
295
323
|
* quando há sobrenome); sem nome e sem imagem, um glifo de pessoa decorativo
|
|
296
324
|
* (`aria-hidden`, a menos que o host tenha aria-label próprio). `color` troca
|
|
297
|
-
* o tint primary por uma cor própria (texto na cor, fundo suave)
|
|
325
|
+
* o tint primary por uma cor própria (texto na cor, fundo suave) e
|
|
326
|
+
* `variant="solid"` preenche o fundo com a cor e escreve as iniciais em branco.
|
|
298
327
|
*/
|
|
299
328
|
class ArkAvatar extends HTMLElementBase {
|
|
300
329
|
constructor() {
|
|
@@ -309,9 +338,10 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
309
338
|
this.ownLabel = null;
|
|
310
339
|
}
|
|
311
340
|
static get observedAttributes() {
|
|
312
|
-
return ["name", "src", "size", "shape", "color", "aria-label", "theme", "class", "testid"];
|
|
341
|
+
return ["name", "src", "size", "shape", "color", "variant", "aria-label", "theme", "class", "testid"];
|
|
313
342
|
}
|
|
314
343
|
connectedCallback() {
|
|
344
|
+
upgradeProperties(this);
|
|
315
345
|
if (!this.initialsEl)
|
|
316
346
|
this.render();
|
|
317
347
|
this.updateAppearance();
|
|
@@ -349,6 +379,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
349
379
|
getShape() {
|
|
350
380
|
return (this.getAttribute("shape") || "").toLowerCase() === "square" ? "square" : "circle";
|
|
351
381
|
}
|
|
382
|
+
getVariant() {
|
|
383
|
+
return (this.getAttribute("variant") || "").toLowerCase() === "solid" ? "solid" : "soft";
|
|
384
|
+
}
|
|
352
385
|
render() {
|
|
353
386
|
const initials = document.createElement("span");
|
|
354
387
|
initials.setAttribute("aria-hidden", "true");
|
|
@@ -387,7 +420,7 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
387
420
|
this.imageEl.hidden = failed;
|
|
388
421
|
this.imageEl.className = failed ? "" : "ark:h-full ark:w-full ark:object-cover";
|
|
389
422
|
}
|
|
390
|
-
// Cor própria: texto na cor e fundo
|
|
423
|
+
// Cor própria, como o badge: suave é texto na cor e fundo por color-mix; sólido é fundo na cor e texto branco.
|
|
391
424
|
applyCustomColor() {
|
|
392
425
|
const color = this.getAttribute("color")?.trim();
|
|
393
426
|
if (!color) {
|
|
@@ -395,8 +428,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
395
428
|
this.style.removeProperty("--ark-avatar-fg");
|
|
396
429
|
return;
|
|
397
430
|
}
|
|
398
|
-
this.
|
|
399
|
-
this.style.setProperty("--ark-avatar-
|
|
431
|
+
const solid = this.getVariant() === "solid";
|
|
432
|
+
this.style.setProperty("--ark-avatar-bg", solid ? color : `color-mix(in oklab, ${color} 18%, transparent)`);
|
|
433
|
+
this.style.setProperty("--ark-avatar-fg", solid ? "#fff" : color);
|
|
400
434
|
}
|
|
401
435
|
applyOwnClasses(next) {
|
|
402
436
|
this.syncingClass = true;
|
|
@@ -438,7 +472,9 @@ class ArkAvatar extends HTMLElementBase {
|
|
|
438
472
|
].join(" ");
|
|
439
473
|
const colors = this.getAttribute("color")?.trim()
|
|
440
474
|
? "ark:bg-(--ark-avatar-bg) ark:text-(--ark-avatar-fg)"
|
|
441
|
-
:
|
|
475
|
+
: this.getVariant() === "solid"
|
|
476
|
+
? "ark:bg-primary ark:text-primary-fg"
|
|
477
|
+
: "ark:bg-primary-soft ark:text-primary-soft-fg";
|
|
442
478
|
this.applyOwnClasses([
|
|
443
479
|
"ark:inline-flex ark:shrink-0 ark:items-center ark:justify-center ark:overflow-hidden ark:align-middle ark:font-semibold ark:uppercase ark:leading-none ark:select-none",
|
|
444
480
|
sizing.box,
|
|
@@ -490,6 +526,7 @@ class ArkBadge extends HTMLElementBase {
|
|
|
490
526
|
return ["intent", "variant", "size", "rounded", "color", "theme", "class", "testid"];
|
|
491
527
|
}
|
|
492
528
|
connectedCallback() {
|
|
529
|
+
upgradeProperties(this);
|
|
493
530
|
this.updateAppearance();
|
|
494
531
|
}
|
|
495
532
|
attributeChangedCallback(name) {
|
|
@@ -777,6 +814,7 @@ class ArkButton extends HTMLElementBase {
|
|
|
777
814
|
* Chamado pelo navegador quando o elemento é adicionado ao DOM.
|
|
778
815
|
*/
|
|
779
816
|
connectedCallback() {
|
|
817
|
+
upgradeProperties(this);
|
|
780
818
|
this.updateAppearance();
|
|
781
819
|
}
|
|
782
820
|
/**
|
|
@@ -1301,6 +1339,7 @@ class ArkCalendar extends HTMLElementBase {
|
|
|
1301
1339
|
];
|
|
1302
1340
|
}
|
|
1303
1341
|
connectedCallback() {
|
|
1342
|
+
upgradeProperties(this);
|
|
1304
1343
|
this.locale = this.getLocale();
|
|
1305
1344
|
const parsed = this.parseDate(this.getAttribute("value"));
|
|
1306
1345
|
if (parsed) {
|
|
@@ -1922,6 +1961,7 @@ class ArkCard extends HTMLElementBase {
|
|
|
1922
1961
|
return ["heading", "padding", "rounded", "theme", "class", "testid"];
|
|
1923
1962
|
}
|
|
1924
1963
|
connectedCallback() {
|
|
1964
|
+
upgradeProperties(this);
|
|
1925
1965
|
if (!this.observer) {
|
|
1926
1966
|
// Slots que chegam depois (frameworks) recebem o hook.
|
|
1927
1967
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -2133,6 +2173,7 @@ class ArkCarousel extends HTMLElementBase {
|
|
|
2133
2173
|
this.addEventListener("focusout", this.handleMouseLeave);
|
|
2134
2174
|
}
|
|
2135
2175
|
connectedCallback() {
|
|
2176
|
+
upgradeProperties(this);
|
|
2136
2177
|
this.build();
|
|
2137
2178
|
if (!this.observer) {
|
|
2138
2179
|
this.observer = new MutationObserver((records) => {
|
|
@@ -2500,8 +2541,10 @@ let nextId$1 = 0;
|
|
|
2500
2541
|
* formulário; os dois são controles nativos, então <fieldset disabled> os
|
|
2501
2542
|
* desabilita sem JS. `label` vira um <label for> próprio; sem ele o host
|
|
2502
2543
|
* precisa de aria-label, ou de filhos (texto livre, links), que dão nome à
|
|
2503
|
-
* caixa por aria-labelledby e a alternam ao clique.
|
|
2504
|
-
*
|
|
2544
|
+
* caixa por aria-labelledby e a alternam ao clique. `helper` acrescenta uma
|
|
2545
|
+
* dica abaixo do rótulo, que descreve a caixa por aria-describedby. Os nós
|
|
2546
|
+
* próprios ficam no início do host, marcados data-ark-chrome, antes dos filhos
|
|
2547
|
+
* do usuário.
|
|
2505
2548
|
*/
|
|
2506
2549
|
class ArkCheckbox extends HTMLElementBase {
|
|
2507
2550
|
static get observedAttributes() {
|
|
@@ -2512,6 +2555,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2512
2555
|
"name",
|
|
2513
2556
|
"value",
|
|
2514
2557
|
"label",
|
|
2558
|
+
"helper",
|
|
2515
2559
|
"aria-label",
|
|
2516
2560
|
"size",
|
|
2517
2561
|
"intent",
|
|
@@ -2527,6 +2571,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2527
2571
|
this.boxEl = null;
|
|
2528
2572
|
this.iconEl = null;
|
|
2529
2573
|
this.labelEl = null;
|
|
2574
|
+
this.helperEl = null;
|
|
2530
2575
|
this.inputEl = null;
|
|
2531
2576
|
this.observer = null;
|
|
2532
2577
|
/** Glifo em exibição; a troca depois do primeiro render entra com scale-in. */
|
|
@@ -2556,6 +2601,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2556
2601
|
this.addEventListener("click", this.handleHostClick);
|
|
2557
2602
|
}
|
|
2558
2603
|
connectedCallback() {
|
|
2604
|
+
upgradeProperties(this);
|
|
2559
2605
|
if (!this.boxEl)
|
|
2560
2606
|
this.render();
|
|
2561
2607
|
if (!this.observer) {
|
|
@@ -2680,11 +2726,11 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2680
2726
|
getSizing() {
|
|
2681
2727
|
const size = (this.getAttribute("size") || "md").toLowerCase();
|
|
2682
2728
|
const sizes = {
|
|
2683
|
-
xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs" },
|
|
2684
|
-
sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm" },
|
|
2685
|
-
md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm" },
|
|
2686
|
-
lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base" },
|
|
2687
|
-
xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg" }
|
|
2729
|
+
xs: { box: "ark:h-3.5 ark:w-3.5 ark:p-px", label: "ark:text-xs", helper: "ark:text-2xs" },
|
|
2730
|
+
sm: { box: "ark:h-4 ark:w-4 ark:p-px", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
2731
|
+
md: { box: "ark:h-5 ark:w-5 ark:p-0.5", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
2732
|
+
lg: { box: "ark:h-6 ark:w-6 ark:p-0.5", label: "ark:text-base", helper: "ark:text-sm" },
|
|
2733
|
+
xl: { box: "ark:h-7 ark:w-7 ark:p-1", label: "ark:text-lg", helper: "ark:text-base" }
|
|
2688
2734
|
};
|
|
2689
2735
|
return sizes[size] ?? sizes.md;
|
|
2690
2736
|
}
|
|
@@ -2728,7 +2774,32 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2728
2774
|
}
|
|
2729
2775
|
this.labelEl.htmlFor = this.boxEl?.id ?? "";
|
|
2730
2776
|
this.labelEl.textContent = text;
|
|
2731
|
-
this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
2777
|
+
this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
2778
|
+
}
|
|
2779
|
+
// Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a caixa por aria-describedby.
|
|
2780
|
+
// Com ela o host vira grid (updateAppearance): a caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
2781
|
+
syncHelper(sizing) {
|
|
2782
|
+
if (!this.boxEl)
|
|
2783
|
+
return;
|
|
2784
|
+
const text = this.getAttribute("helper");
|
|
2785
|
+
if (!text) {
|
|
2786
|
+
this.helperEl?.remove();
|
|
2787
|
+
this.helperEl = null;
|
|
2788
|
+
this.boxEl.removeAttribute("aria-describedby");
|
|
2789
|
+
return;
|
|
2790
|
+
}
|
|
2791
|
+
if (!this.helperEl) {
|
|
2792
|
+
const helper = document.createElement("span");
|
|
2793
|
+
helper.setAttribute("data-ark-chrome", "helper");
|
|
2794
|
+
helper.id = `${this.boxEl.id}-helper`;
|
|
2795
|
+
(this.labelEl ?? this.inputEl)?.after(helper);
|
|
2796
|
+
this.helperEl = helper;
|
|
2797
|
+
}
|
|
2798
|
+
if (this.helperEl.textContent !== text)
|
|
2799
|
+
this.helperEl.textContent = text;
|
|
2800
|
+
// order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
|
|
2801
|
+
this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
|
|
2802
|
+
this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
|
|
2732
2803
|
}
|
|
2733
2804
|
// Nome acessível da caixa: o <label for> próprio; senão aria-label; senão os filhos do usuário, via
|
|
2734
2805
|
// aria-labelledby no host (que ganha um id quando falta).
|
|
@@ -2756,6 +2827,16 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2756
2827
|
this.boxEl.removeAttribute("aria-label");
|
|
2757
2828
|
this.boxEl.removeAttribute("aria-labelledby");
|
|
2758
2829
|
}
|
|
2830
|
+
// Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
|
|
2831
|
+
// nós ocultos).
|
|
2832
|
+
if (this.helperEl) {
|
|
2833
|
+
if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
|
|
2834
|
+
this.helperEl.setAttribute("aria-hidden", "true");
|
|
2835
|
+
}
|
|
2836
|
+
else {
|
|
2837
|
+
this.helperEl.removeAttribute("aria-hidden");
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2759
2840
|
}
|
|
2760
2841
|
syncIcon(kind) {
|
|
2761
2842
|
if (!this.iconEl || kind === this.iconKind)
|
|
@@ -2791,11 +2872,20 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2791
2872
|
const checked = this.checked;
|
|
2792
2873
|
const indeterminate = this.indeterminate;
|
|
2793
2874
|
const disabled = this.disabled;
|
|
2875
|
+
// Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
2876
|
+
const layout = this.hasAttribute("helper")
|
|
2877
|
+
? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
|
|
2878
|
+
: "ark:inline-flex ark:gap-2";
|
|
2794
2879
|
// O host dimeriza tudo (caixa e rótulo) quando qualquer controle interno está desabilitado, inclusive
|
|
2795
2880
|
// por <fieldset disabled>.
|
|
2796
|
-
this.applyOwnClasses(
|
|
2881
|
+
this.applyOwnClasses([
|
|
2882
|
+
layout,
|
|
2883
|
+
"ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
|
|
2884
|
+
]
|
|
2885
|
+
.join(" ")
|
|
2886
|
+
.split(" "));
|
|
2797
2887
|
this.boxEl.className = [
|
|
2798
|
-
"ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
2888
|
+
"ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-sm ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
2799
2889
|
palette.ring,
|
|
2800
2890
|
sizing.box,
|
|
2801
2891
|
checked || indeterminate
|
|
@@ -2806,6 +2896,7 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2806
2896
|
this.boxEl.disabled = disabled;
|
|
2807
2897
|
this.syncIcon(indeterminate ? "mixed" : checked ? "check" : "none");
|
|
2808
2898
|
this.syncLabel(sizing);
|
|
2899
|
+
this.syncHelper(sizing);
|
|
2809
2900
|
this.syncName();
|
|
2810
2901
|
this.inputEl.checked = checked;
|
|
2811
2902
|
this.inputEl.indeterminate = indeterminate;
|
|
@@ -2816,6 +2907,8 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2816
2907
|
applyTestHooks(this, "checkbox", this.inputEl, "input");
|
|
2817
2908
|
if (this.labelEl)
|
|
2818
2909
|
applyTestHooks(this, "checkbox", this.labelEl, "label");
|
|
2910
|
+
if (this.helperEl)
|
|
2911
|
+
applyTestHooks(this, "checkbox", this.helperEl, "helper");
|
|
2819
2912
|
}
|
|
2820
2913
|
}
|
|
2821
2914
|
ArkCheckbox.tagName = "ark-checkbox";
|
|
@@ -2854,6 +2947,7 @@ class ArkClock extends HTMLElementBase {
|
|
|
2854
2947
|
return ["value", "seconds", "step-minutes", "hours-format", "lang", "locale-json", "theme", "intent", "testid"];
|
|
2855
2948
|
}
|
|
2856
2949
|
connectedCallback() {
|
|
2950
|
+
upgradeProperties(this);
|
|
2857
2951
|
this.build();
|
|
2858
2952
|
}
|
|
2859
2953
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -3131,6 +3225,7 @@ class ArkColorSwatches extends HTMLElementBase {
|
|
|
3131
3225
|
this.addEventListener("keydown", this.handleKeydown);
|
|
3132
3226
|
}
|
|
3133
3227
|
connectedCallback() {
|
|
3228
|
+
upgradeProperties(this);
|
|
3134
3229
|
this.updateAppearance();
|
|
3135
3230
|
}
|
|
3136
3231
|
attributeChangedCallback(name) {
|
|
@@ -3305,6 +3400,7 @@ class ArkCommandItem extends HTMLElementBase {
|
|
|
3305
3400
|
this.addEventListener("click", this.handleClick);
|
|
3306
3401
|
}
|
|
3307
3402
|
connectedCallback() {
|
|
3403
|
+
upgradeProperties(this);
|
|
3308
3404
|
this.updateAppearance();
|
|
3309
3405
|
}
|
|
3310
3406
|
attributeChangedCallback(name) {
|
|
@@ -3405,7 +3501,9 @@ function normalize(text) {
|
|
|
3405
3501
|
* e um listbox oculto que é dono das opções visíveis por `aria-owns`. Itens
|
|
3406
3502
|
* e cabeçalhos se ordenam por `order` no CSS, então nada é inserido entre os
|
|
3407
3503
|
* filhos. Com `filter` o texto filtra localmente pelo `label` dos itens; em
|
|
3408
|
-
* qualquer caso `ark-query` sai com debounce para busca assíncrona.
|
|
3504
|
+
* qualquer caso `ark-query` sai com debounce para busca assíncrona. Sem opções
|
|
3505
|
+
* visíveis a mensagem é `noResults`; `hint` a troca enquanto o campo está
|
|
3506
|
+
* vazio e `busy` (busca em andamento) a troca por `searching`. O foco
|
|
3409
3507
|
* fica sempre no campo; setas movem a opção ativa (`aria-activedescendant`),
|
|
3410
3508
|
* Enter seleciona, Esc fecha; `hotkey` abre de qualquer lugar da página. A
|
|
3411
3509
|
* página para de rolar enquanto aberta, salvo com `no-scroll-lock`.
|
|
@@ -3419,6 +3517,8 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3419
3517
|
"filter",
|
|
3420
3518
|
"query-delay",
|
|
3421
3519
|
"label",
|
|
3520
|
+
"hint",
|
|
3521
|
+
"busy",
|
|
3422
3522
|
"theme",
|
|
3423
3523
|
"lang",
|
|
3424
3524
|
"locale-json",
|
|
@@ -3545,6 +3645,7 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3545
3645
|
this.addEventListener("ark-select", this.handleItemSelect);
|
|
3546
3646
|
}
|
|
3547
3647
|
connectedCallback() {
|
|
3648
|
+
upgradeProperties(this);
|
|
3548
3649
|
if (!this.inputEl)
|
|
3549
3650
|
this.render();
|
|
3550
3651
|
if (!this.observer) {
|
|
@@ -3583,6 +3684,10 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3583
3684
|
if (!this.isConnected)
|
|
3584
3685
|
return;
|
|
3585
3686
|
if (name === "open") {
|
|
3687
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
3688
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
3689
|
+
if (!this.observer)
|
|
3690
|
+
return;
|
|
3586
3691
|
if (this.hasAttribute("open")) {
|
|
3587
3692
|
this.openNow();
|
|
3588
3693
|
}
|
|
@@ -3615,6 +3720,13 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3615
3720
|
set noScrollLock(value) {
|
|
3616
3721
|
this.toggleAttribute("no-scroll-lock", coerceBooleanAttr(value));
|
|
3617
3722
|
}
|
|
3723
|
+
/** Busca assíncrona em andamento (atributo `busy`): o listbox fica `aria-busy` e, sem opções, aparece `searching`. */
|
|
3724
|
+
get busy() {
|
|
3725
|
+
return this.hasAttribute("busy");
|
|
3726
|
+
}
|
|
3727
|
+
set busy(value) {
|
|
3728
|
+
this.toggleAttribute("busy", coerceBooleanAttr(value));
|
|
3729
|
+
}
|
|
3618
3730
|
/** Texto atual do campo de busca. */
|
|
3619
3731
|
get query() {
|
|
3620
3732
|
return this.inputEl?.value ?? "";
|
|
@@ -3698,15 +3810,31 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3698
3810
|
applyTestHooks(this, "command-palette", header, "group");
|
|
3699
3811
|
});
|
|
3700
3812
|
this.listEl.setAttribute("aria-owns", visible.map((item) => item.id).join(" "));
|
|
3701
|
-
this.
|
|
3702
|
-
const noResults = this.getLocale().noResults;
|
|
3703
|
-
if (this.emptyEl.textContent !== noResults)
|
|
3704
|
-
this.emptyEl.textContent = noResults;
|
|
3813
|
+
this.syncEmpty(visible.length);
|
|
3705
3814
|
const enabled = visible.filter((item) => !item.disabled);
|
|
3706
3815
|
if (!enabled.some((item) => item.id === this.activeId))
|
|
3707
3816
|
this.activeId = enabled[0]?.id ?? null;
|
|
3708
3817
|
this.applyActive(items);
|
|
3709
3818
|
}
|
|
3819
|
+
// Mensagem sem opções visíveis: `searching` com `busy`, o `hint` do app com o campo vazio, senão `noResults`.
|
|
3820
|
+
syncEmpty(visible) {
|
|
3821
|
+
if (!this.listEl || !this.emptyEl)
|
|
3822
|
+
return;
|
|
3823
|
+
const locale = this.getLocale();
|
|
3824
|
+
const busy = this.busy;
|
|
3825
|
+
const hint = this.getAttribute("hint");
|
|
3826
|
+
const text = busy ? locale.searching : hint && this.query.trim() === "" ? hint : locale.noResults;
|
|
3827
|
+
this.emptyEl.hidden = visible > 0;
|
|
3828
|
+
// Só escreve o que mudou: o observer (subtree) veria a troca do nó de texto e sincronizaria em laço.
|
|
3829
|
+
if (this.emptyEl.textContent !== text)
|
|
3830
|
+
this.emptyEl.textContent = text;
|
|
3831
|
+
if (busy) {
|
|
3832
|
+
this.listEl.setAttribute("aria-busy", "true");
|
|
3833
|
+
}
|
|
3834
|
+
else {
|
|
3835
|
+
this.listEl.removeAttribute("aria-busy");
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3710
3838
|
applyActive(items) {
|
|
3711
3839
|
for (const item of items) {
|
|
3712
3840
|
const active = item.id === this.activeId;
|
|
@@ -3867,8 +3995,7 @@ class ArkCommandPalette extends HTMLElementBase {
|
|
|
3867
3995
|
this.inputEl.removeAttribute(attr);
|
|
3868
3996
|
}
|
|
3869
3997
|
}
|
|
3870
|
-
|
|
3871
|
-
this.emptyEl.textContent = locale.noResults;
|
|
3998
|
+
this.syncEmpty(this.visibleItems().length);
|
|
3872
3999
|
applyTestHooks(this, "command-palette", this);
|
|
3873
4000
|
applyTestHooks(this, "command-palette", this.inputEl, "input");
|
|
3874
4001
|
applyTestHooks(this, "command-palette", this.listEl, "list");
|
|
@@ -3918,6 +4045,7 @@ class ArkCopyButton extends ArkButton {
|
|
|
3918
4045
|
this.addEventListener("click", this.handleCopyClick);
|
|
3919
4046
|
}
|
|
3920
4047
|
connectedCallback() {
|
|
4048
|
+
upgradeProperties(this);
|
|
3921
4049
|
if (!this.childObserver) {
|
|
3922
4050
|
// Rótulo do usuário que chega ou sai depois decide se o rótulo próprio aparece.
|
|
3923
4051
|
this.childObserver = new MutationObserver(() => this.updateAppearance());
|
|
@@ -4200,6 +4328,7 @@ class ArkDatepicker extends HTMLElementBase {
|
|
|
4200
4328
|
];
|
|
4201
4329
|
}
|
|
4202
4330
|
connectedCallback() {
|
|
4331
|
+
upgradeProperties(this);
|
|
4203
4332
|
if (!this.hasRendered()) {
|
|
4204
4333
|
this.syncFromValue();
|
|
4205
4334
|
this.render();
|
|
@@ -4779,6 +4908,7 @@ class ArkDialog extends HTMLElementBase {
|
|
|
4779
4908
|
this.addEventListener("keydown", this.handleKeydown);
|
|
4780
4909
|
}
|
|
4781
4910
|
connectedCallback() {
|
|
4911
|
+
upgradeProperties(this);
|
|
4782
4912
|
if (!this.observer) {
|
|
4783
4913
|
// Um footer que chega depois (framework) recebe o hook; o resto do DOM é do usuário.
|
|
4784
4914
|
this.observer = new MutationObserver(() => this.syncFooter());
|
|
@@ -4812,6 +4942,10 @@ class ArkDialog extends HTMLElementBase {
|
|
|
4812
4942
|
if (name === "open") {
|
|
4813
4943
|
const reason = this.pendingReason ?? "api";
|
|
4814
4944
|
this.pendingReason = null;
|
|
4945
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
4946
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
4947
|
+
if (!this.observer)
|
|
4948
|
+
return;
|
|
4815
4949
|
if (this.hasAttribute("open")) {
|
|
4816
4950
|
this.openNow();
|
|
4817
4951
|
}
|
|
@@ -5095,11 +5229,12 @@ function cssLength$1(value) {
|
|
|
5095
5229
|
* página e só anima (o console inferior, um painel lateral fixo). Os filhos
|
|
5096
5230
|
* do usuário são o corpo e ficam onde estão; um filho `slot="footer"` vai ao
|
|
5097
5231
|
* fim por CSS. O cabeçalho (título `h2` de `label` e botão de fechar) é o
|
|
5098
|
-
* primeiro filho, marcado `data-ark-chrome
|
|
5099
|
-
*
|
|
5100
|
-
*
|
|
5101
|
-
*
|
|
5102
|
-
*
|
|
5232
|
+
* primeiro filho, marcado `data-ark-chrome`; um container `slot="actions"`
|
|
5233
|
+
* entra na linha dele por CSS, entre o título e o fechar. `side` escolhe a
|
|
5234
|
+
* borda, a direção do slide (com o easing `sheet`) e a borda desenhada;
|
|
5235
|
+
* `size` é um preset ou um comprimento CSS no eixo da gaveta. `open` é a fonte
|
|
5236
|
+
* da verdade, como no ark-dialog, e em overlay a página para de rolar
|
|
5237
|
+
* enquanto aberta, salvo com `no-scroll-lock`.
|
|
5103
5238
|
*/
|
|
5104
5239
|
class ArkDrawer extends HTMLElementBase {
|
|
5105
5240
|
static get observedAttributes() {
|
|
@@ -5124,6 +5259,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5124
5259
|
this.titleEl = null;
|
|
5125
5260
|
this.closeEl = null;
|
|
5126
5261
|
this.observer = null;
|
|
5262
|
+
/** Mede o filho `slot="actions"`: a largura dele é o espaço que o título deixa livre na linha do cabeçalho. */
|
|
5263
|
+
this.actionsObserver = null;
|
|
5264
|
+
/** O filho `slot="actions"` que o actionsObserver mede. */
|
|
5265
|
+
this.observedActions = null;
|
|
5127
5266
|
this.ownClasses = [];
|
|
5128
5267
|
this.syncingClass = false;
|
|
5129
5268
|
this.state = "closed";
|
|
@@ -5146,8 +5285,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5146
5285
|
this.addEventListener("keydown", this.handleKeydown);
|
|
5147
5286
|
}
|
|
5148
5287
|
connectedCallback() {
|
|
5288
|
+
upgradeProperties(this);
|
|
5149
5289
|
if (!this.observer) {
|
|
5150
|
-
|
|
5290
|
+
// Rodapé e ações que chegam depois (frameworks) ganham o hook; as ações também mudam o cabeçalho.
|
|
5291
|
+
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
5151
5292
|
this.observer.observe(this, { childList: true });
|
|
5152
5293
|
}
|
|
5153
5294
|
this.updateAppearance();
|
|
@@ -5160,6 +5301,9 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5160
5301
|
disconnectedCallback() {
|
|
5161
5302
|
this.observer?.disconnect();
|
|
5162
5303
|
this.observer = null;
|
|
5304
|
+
this.actionsObserver?.disconnect();
|
|
5305
|
+
this.actionsObserver = null;
|
|
5306
|
+
this.observedActions = null;
|
|
5163
5307
|
this.releaseTrap?.();
|
|
5164
5308
|
this.releaseTrap = null;
|
|
5165
5309
|
unlockScroll(this);
|
|
@@ -5177,6 +5321,10 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5177
5321
|
if (name === "open") {
|
|
5178
5322
|
const reason = this.pendingReason ?? "api";
|
|
5179
5323
|
this.pendingReason = null;
|
|
5324
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
|
|
5325
|
+
// reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
|
|
5326
|
+
if (!this.observer)
|
|
5327
|
+
return;
|
|
5180
5328
|
if (this.hasAttribute("open")) {
|
|
5181
5329
|
this.openNow();
|
|
5182
5330
|
}
|
|
@@ -5367,8 +5515,8 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5367
5515
|
.split(/\s+/)
|
|
5368
5516
|
.filter(Boolean);
|
|
5369
5517
|
}
|
|
5370
|
-
syncHeader(label, showClose) {
|
|
5371
|
-
if (!label && !showClose) {
|
|
5518
|
+
syncHeader(label, showClose, withActions) {
|
|
5519
|
+
if (!label && !showClose && !withActions) {
|
|
5372
5520
|
this.headerEl?.remove();
|
|
5373
5521
|
this.headerEl = null;
|
|
5374
5522
|
this.titleEl = null;
|
|
@@ -5381,8 +5529,14 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5381
5529
|
this.prepend(header);
|
|
5382
5530
|
this.headerEl = header;
|
|
5383
5531
|
}
|
|
5384
|
-
|
|
5385
|
-
|
|
5532
|
+
// As ações vêm antes do cabeçalho (order) e ocupam 3rem até o fim da linha do título: ele sobe por cima desse
|
|
5533
|
+
// espaço e guarda ao menos a altura dessa linha.
|
|
5534
|
+
this.headerEl.className = [
|
|
5535
|
+
"ark:sticky ark:top-0 ark:z-10 ark:-mx-6 ark:flex ark:items-start ark:gap-4 ark:bg-surface ark:px-6 ark:pt-6 ark:pb-4",
|
|
5536
|
+
withActions ? "ark:-mt-12 ark:min-h-16" : ""
|
|
5537
|
+
]
|
|
5538
|
+
.join(" ")
|
|
5539
|
+
.trim();
|
|
5386
5540
|
if (label) {
|
|
5387
5541
|
if (!this.titleEl) {
|
|
5388
5542
|
const title = document.createElement("h2");
|
|
@@ -5391,7 +5545,13 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5391
5545
|
this.titleEl = title;
|
|
5392
5546
|
}
|
|
5393
5547
|
this.titleEl.textContent = label;
|
|
5394
|
-
|
|
5548
|
+
// Com ações, o título deixa livre a largura medida delas mais o espaço entre as duas.
|
|
5549
|
+
this.titleEl.className = [
|
|
5550
|
+
"ark:min-w-0 ark:flex-1 ark:text-base ark:leading-6 ark:font-semibold ark:text-fg",
|
|
5551
|
+
withActions ? "ark:me-[calc(var(--ark-drawer-actions-width,0px)+1rem)]" : ""
|
|
5552
|
+
]
|
|
5553
|
+
.join(" ")
|
|
5554
|
+
.trim();
|
|
5395
5555
|
}
|
|
5396
5556
|
else {
|
|
5397
5557
|
this.titleEl?.remove();
|
|
@@ -5422,6 +5582,28 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5422
5582
|
if (footer)
|
|
5423
5583
|
applyTestHooks(this, "drawer", footer, "footer");
|
|
5424
5584
|
}
|
|
5585
|
+
// Passa a medir o filho `slot="actions"` atual (ou nenhum). Sem ResizeObserver (SSR, jsdom) o título não reserva
|
|
5586
|
+
// a largura delas, só o espaço entre os dois.
|
|
5587
|
+
syncActions(actions) {
|
|
5588
|
+
if (actions)
|
|
5589
|
+
applyTestHooks(this, "drawer", actions, "actions");
|
|
5590
|
+
if (actions === this.observedActions)
|
|
5591
|
+
return;
|
|
5592
|
+
this.actionsObserver?.disconnect();
|
|
5593
|
+
this.observedActions = actions;
|
|
5594
|
+
if (!actions) {
|
|
5595
|
+
this.style.removeProperty("--ark-drawer-actions-width");
|
|
5596
|
+
return;
|
|
5597
|
+
}
|
|
5598
|
+
if (typeof ResizeObserver === "undefined")
|
|
5599
|
+
return;
|
|
5600
|
+
if (!this.actionsObserver) {
|
|
5601
|
+
this.actionsObserver = new ResizeObserver(() => {
|
|
5602
|
+
this.style.setProperty("--ark-drawer-actions-width", `${this.observedActions?.offsetWidth ?? 0}px`);
|
|
5603
|
+
});
|
|
5604
|
+
}
|
|
5605
|
+
this.actionsObserver.observe(actions);
|
|
5606
|
+
}
|
|
5425
5607
|
applyOwnClasses(next) {
|
|
5426
5608
|
this.syncingClass = true;
|
|
5427
5609
|
for (const cls of this.ownClasses) {
|
|
@@ -5458,7 +5640,9 @@ class ArkDrawer extends HTMLElementBase {
|
|
|
5458
5640
|
this.setAttribute("tabindex", "-1");
|
|
5459
5641
|
this.setAttribute("data-ark-side", this.side);
|
|
5460
5642
|
this.setAttribute("data-ark-mode", this.mode);
|
|
5461
|
-
this.
|
|
5643
|
+
const actions = this.querySelector(':scope > [slot="actions"]');
|
|
5644
|
+
this.syncHeader(label, !this.hasAttribute("no-close-button"), actions !== null);
|
|
5645
|
+
this.syncActions(actions);
|
|
5462
5646
|
// Nome acessível: o título; sem ele um aria-label do usuário fica.
|
|
5463
5647
|
if (label && this.titleEl) {
|
|
5464
5648
|
this.setAttribute("aria-labelledby", this.titleId);
|
|
@@ -5502,6 +5686,7 @@ class ArkEmpty extends HTMLElementBase {
|
|
|
5502
5686
|
return ["heading", "description", "theme", "class", "testid"];
|
|
5503
5687
|
}
|
|
5504
5688
|
connectedCallback() {
|
|
5689
|
+
upgradeProperties(this);
|
|
5505
5690
|
if (!this.observer) {
|
|
5506
5691
|
// Ícone ou ação que chegam depois (frameworks) recebem o hook.
|
|
5507
5692
|
this.observer = new MutationObserver(() => this.syncSlots());
|
|
@@ -5689,6 +5874,7 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5689
5874
|
];
|
|
5690
5875
|
}
|
|
5691
5876
|
connectedCallback() {
|
|
5877
|
+
upgradeProperties(this);
|
|
5692
5878
|
if (!this.inputEl)
|
|
5693
5879
|
this.render();
|
|
5694
5880
|
this.updateAppearance();
|
|
@@ -6081,6 +6267,7 @@ class ArkInput extends HTMLElementBase {
|
|
|
6081
6267
|
];
|
|
6082
6268
|
}
|
|
6083
6269
|
connectedCallback() {
|
|
6270
|
+
upgradeProperties(this);
|
|
6084
6271
|
if (!this.inputEl) {
|
|
6085
6272
|
this.render();
|
|
6086
6273
|
}
|
|
@@ -6364,6 +6551,7 @@ class ArkKbd extends HTMLElementBase {
|
|
|
6364
6551
|
return ["size", "theme", "class", "testid"];
|
|
6365
6552
|
}
|
|
6366
6553
|
connectedCallback() {
|
|
6554
|
+
upgradeProperties(this);
|
|
6367
6555
|
this.updateAppearance();
|
|
6368
6556
|
}
|
|
6369
6557
|
attributeChangedCallback(name) {
|
|
@@ -6474,7 +6662,9 @@ function cloneRow(row) {
|
|
|
6474
6662
|
* preservados por posição) ou "json" (array com todos os campos). `change`
|
|
6475
6663
|
* publica as linhas a cada edição, inclusive ao sair do modo em massa;
|
|
6476
6664
|
* adicionar e remover anunciam a contagem ao leitor de tela. A célula de
|
|
6477
|
-
* valor é um ark-input
|
|
6665
|
+
* valor é um ark-input; a propriedade `valueField` troca pelo elemento que o
|
|
6666
|
+
* app criar (um campo com autocomplete de `{{variável}}`, por exemplo), exceto
|
|
6667
|
+
* nas linhas secretas, que mantêm o campo de senha.
|
|
6478
6668
|
*/
|
|
6479
6669
|
class ArkKvEditor extends HTMLElementBase {
|
|
6480
6670
|
static get observedAttributes() {
|
|
@@ -6517,6 +6707,10 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6517
6707
|
this.bulkBase = null;
|
|
6518
6708
|
/** Último texto em massa que o próprio componente escreveu, para não sobrescrever o que o usuário digita. */
|
|
6519
6709
|
this.bulkWritten = "";
|
|
6710
|
+
/** Fábrica da célula de valor (`valueField`); sem ela, todo valor é um ark-input. */
|
|
6711
|
+
this.valueFactory = null;
|
|
6712
|
+
/** Células de valor criadas pela fábrica, que não recebem `type`/`reveal` do ark-input. */
|
|
6713
|
+
this.customCells = new WeakSet();
|
|
6520
6714
|
// --- Interação ---
|
|
6521
6715
|
this.handleBulkInput = () => {
|
|
6522
6716
|
if (!this.bulkEl)
|
|
@@ -6539,6 +6733,7 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6539
6733
|
});
|
|
6540
6734
|
}
|
|
6541
6735
|
connectedCallback() {
|
|
6736
|
+
upgradeProperties(this);
|
|
6542
6737
|
if (!this.listEl)
|
|
6543
6738
|
this.render();
|
|
6544
6739
|
this.updateAppearance();
|
|
@@ -6626,6 +6821,20 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6626
6821
|
set secret(value) {
|
|
6627
6822
|
this.toggleAttribute("secret", coerceBooleanAttr(value));
|
|
6628
6823
|
}
|
|
6824
|
+
/**
|
|
6825
|
+
* Fábrica da célula de valor (propriedade JS): o elemento que ela devolve substitui o ark-input da linha, exceto
|
|
6826
|
+
* nas linhas secretas, que mantêm o campo de senha; `null` numa linha mantém o ark-input nela.
|
|
6827
|
+
*/
|
|
6828
|
+
get valueField() {
|
|
6829
|
+
return this.valueFactory;
|
|
6830
|
+
}
|
|
6831
|
+
set valueField(value) {
|
|
6832
|
+
this.valueFactory = typeof value === "function" ? value : null;
|
|
6833
|
+
// As células de valor são recriadas com a fábrica nova.
|
|
6834
|
+
this.resetRows();
|
|
6835
|
+
if (this.isConnected)
|
|
6836
|
+
this.updateAppearance();
|
|
6837
|
+
}
|
|
6629
6838
|
get readonly() {
|
|
6630
6839
|
return this.hasAttribute("readonly");
|
|
6631
6840
|
}
|
|
@@ -6674,6 +6883,10 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6674
6883
|
getLocale() {
|
|
6675
6884
|
return resolveLocale(this.getAttribute("lang") || "en", this.getAttribute("locale-json") || undefined);
|
|
6676
6885
|
}
|
|
6886
|
+
// Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
|
|
6887
|
+
effectiveType(row, types) {
|
|
6888
|
+
return types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
|
|
6889
|
+
}
|
|
6677
6890
|
getSize() {
|
|
6678
6891
|
const size = (this.getAttribute("size") || "").toLowerCase();
|
|
6679
6892
|
return size === "xs" || size === "sm" || size === "lg" || size === "xl" ? size : "md";
|
|
@@ -6816,16 +7029,7 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6816
7029
|
this.emitChange();
|
|
6817
7030
|
});
|
|
6818
7031
|
const key = this.createField(row.id, "key", size);
|
|
6819
|
-
const value = this.
|
|
6820
|
-
// Enter no valor da última linha acrescenta a próxima, como numa tabela.
|
|
6821
|
-
value.addEventListener("keydown", (event) => {
|
|
6822
|
-
if (event.key !== "Enter" || this.readonly)
|
|
6823
|
-
return;
|
|
6824
|
-
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
6825
|
-
return;
|
|
6826
|
-
event.preventDefault();
|
|
6827
|
-
this.add();
|
|
6828
|
-
});
|
|
7032
|
+
const value = this.createValueCell(row, size);
|
|
6829
7033
|
const remove = document.createElement("ark-button");
|
|
6830
7034
|
remove.setAttribute("variant", "ghost");
|
|
6831
7035
|
remove.setAttribute("intent", "neutral");
|
|
@@ -6874,15 +7078,69 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6874
7078
|
el.appendChild(remove);
|
|
6875
7079
|
return el;
|
|
6876
7080
|
}
|
|
7081
|
+
// Célula de valor: com `valueField` e fora das linhas secretas, o elemento da fábrica; senão o ark-input.
|
|
7082
|
+
createValueCell(row, size) {
|
|
7083
|
+
const custom = this.valueFactory && !(this.secret && row.secret === true)
|
|
7084
|
+
? this.valueFactory({ row: { ...row }, type: this.effectiveType(row, this.types) ?? "", size })
|
|
7085
|
+
: null;
|
|
7086
|
+
if (!(custom instanceof HTMLElement)) {
|
|
7087
|
+
const value = this.createField(row.id, "value", size);
|
|
7088
|
+
// Enter no valor da última linha acrescenta a próxima, como numa tabela.
|
|
7089
|
+
value.addEventListener("keydown", (event) => {
|
|
7090
|
+
if (event.key !== "Enter" || this.readonly)
|
|
7091
|
+
return;
|
|
7092
|
+
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
7093
|
+
return;
|
|
7094
|
+
event.preventDefault();
|
|
7095
|
+
this.add();
|
|
7096
|
+
});
|
|
7097
|
+
return value;
|
|
7098
|
+
}
|
|
7099
|
+
const cell = custom;
|
|
7100
|
+
cell.setAttribute("data-ark-field", "value");
|
|
7101
|
+
this.customCells.add(cell);
|
|
7102
|
+
// O campo do app pode emitir `input` antes de atualizar `value` (e `change` depois): só um valor novo conta.
|
|
7103
|
+
const sync = () => {
|
|
7104
|
+
const current = this.model.find((item) => item.id === row.id);
|
|
7105
|
+
const next = cell.value;
|
|
7106
|
+
if (!current || typeof next !== "string" || next === current.value)
|
|
7107
|
+
return;
|
|
7108
|
+
current.value = next;
|
|
7109
|
+
this.emitChange();
|
|
7110
|
+
};
|
|
7111
|
+
cell.addEventListener("input", (event) => {
|
|
7112
|
+
event.stopPropagation();
|
|
7113
|
+
sync();
|
|
7114
|
+
});
|
|
7115
|
+
cell.addEventListener("change", sync);
|
|
7116
|
+
// Enter que o campo não consumiu, ou o `ark-submit` de um campo que consome o Enter, na última linha acrescenta
|
|
7117
|
+
// a próxima.
|
|
7118
|
+
const addNext = (event) => {
|
|
7119
|
+
if (this.readonly || event.defaultPrevented)
|
|
7120
|
+
return;
|
|
7121
|
+
if (this.model[this.model.length - 1]?.id !== row.id)
|
|
7122
|
+
return;
|
|
7123
|
+
if (event.cancelable)
|
|
7124
|
+
event.preventDefault();
|
|
7125
|
+
this.add();
|
|
7126
|
+
};
|
|
7127
|
+
cell.addEventListener("keydown", (event) => {
|
|
7128
|
+
if (event.key === "Enter")
|
|
7129
|
+
addNext(event);
|
|
7130
|
+
});
|
|
7131
|
+
cell.addEventListener("ark-submit", addNext);
|
|
7132
|
+
return cell;
|
|
7133
|
+
}
|
|
7134
|
+
// Filhos diretos da linha: uma célula de valor do app pode ter botões, selects e campos próprios dentro.
|
|
6877
7135
|
rowParts(el) {
|
|
6878
7136
|
return {
|
|
6879
|
-
enabled: el.querySelector("ark-checkbox"),
|
|
6880
|
-
key: el.querySelector('ark-input[data-ark-field="key"]'),
|
|
6881
|
-
value: el.querySelector('
|
|
6882
|
-
secret: this.secret ? el.querySelector("ark-button") : null,
|
|
6883
|
-
type: el.querySelector("ark-select"),
|
|
6884
|
-
description: el.querySelector('ark-input[data-ark-field="description"]'),
|
|
6885
|
-
remove: el.querySelector("ark-button:last-of-type")
|
|
7137
|
+
enabled: el.querySelector(":scope > ark-checkbox"),
|
|
7138
|
+
key: el.querySelector(':scope > ark-input[data-ark-field="key"]'),
|
|
7139
|
+
value: el.querySelector(':scope > [data-ark-field="value"]'),
|
|
7140
|
+
secret: this.secret ? el.querySelector(":scope > ark-button") : null,
|
|
7141
|
+
type: el.querySelector(":scope > ark-select"),
|
|
7142
|
+
description: el.querySelector(':scope > ark-input[data-ark-field="description"]'),
|
|
7143
|
+
remove: el.querySelector(":scope > ark-button:last-of-type")
|
|
6886
7144
|
};
|
|
6887
7145
|
}
|
|
6888
7146
|
// Classes de grid por combinação de colunas (segredo, tipo, descrição): literais completas, para o Tailwind
|
|
@@ -6926,6 +7184,17 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6926
7184
|
if (el !== anchor)
|
|
6927
7185
|
this.listEl.insertBefore(el, anchor);
|
|
6928
7186
|
previous = el;
|
|
7187
|
+
const rowType = this.effectiveType(row, types);
|
|
7188
|
+
const isSecret = withSecret && row.secret === true;
|
|
7189
|
+
// Com `valueField`, segredo e tipo decidem a célula (a fábrica recebe o tipo, o segredo fica no campo de
|
|
7190
|
+
// senha): quando mudam, a célula de valor é recriada. Sem fábrica o ark-input só troca de `type`.
|
|
7191
|
+
if (this.valueFactory) {
|
|
7192
|
+
const valueKey = `${isSecret}|${rowType ?? ""}`;
|
|
7193
|
+
if (el.dataset.arkValueKey !== undefined && el.dataset.arkValueKey !== valueKey) {
|
|
7194
|
+
this.rowParts(el).value.replaceWith(this.createValueCell(row, size));
|
|
7195
|
+
}
|
|
7196
|
+
el.dataset.arkValueKey = valueKey;
|
|
7197
|
+
}
|
|
6929
7198
|
const parts = this.rowParts(el);
|
|
6930
7199
|
el.className = [
|
|
6931
7200
|
"ark:grid ark:items-center ark:gap-2 ark:px-3 ark:py-1.5",
|
|
@@ -6954,12 +7223,12 @@ class ArkKvEditor extends HTMLElementBase {
|
|
|
6954
7223
|
input.toggleAttribute("readonly", readonly);
|
|
6955
7224
|
applyTestHooks(this, "kv-editor", input, name);
|
|
6956
7225
|
}
|
|
6957
|
-
//
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
7226
|
+
// Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto. A célula
|
|
7227
|
+
// da fábrica decide o próprio tipo (recebe `type` no contexto).
|
|
7228
|
+
if (!this.customCells.has(parts.value)) {
|
|
7229
|
+
parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
|
|
7230
|
+
parts.value.toggleAttribute("reveal", isSecret);
|
|
7231
|
+
}
|
|
6963
7232
|
if (parts.secret) {
|
|
6964
7233
|
parts.secret.setAttribute("aria-label", locale.secret);
|
|
6965
7234
|
parts.secret.title = locale.secret;
|
|
@@ -7113,10 +7382,25 @@ const ARK_MARK_PATHS = {
|
|
|
7113
7382
|
triangle: "M12 2 22 21H2Z",
|
|
7114
7383
|
diamond: "M12 1 23 12 12 23 1 12Z",
|
|
7115
7384
|
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",
|
|
7116
|
-
hexagon: "M7 2h10l5 10-5 10H7L2 12Z"
|
|
7385
|
+
hexagon: "M7 2h10l5 10-5 10H7L2 12Z",
|
|
7386
|
+
cross: "M9 2h6v7h7v6h-7v7H9v-7H2V9h7Z",
|
|
7387
|
+
pentagon: "M12 2l10.5 7.6-4 12.3h-13l-4-12.3Z",
|
|
7388
|
+
moon: "M12 2a7.1 7.1 0 0 0 10 10 10 10 0 1 1-10-10Z",
|
|
7389
|
+
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"
|
|
7117
7390
|
};
|
|
7118
|
-
/** As
|
|
7119
|
-
const ARK_MARK_SHAPES = [
|
|
7391
|
+
/** As dez formas, na ordem canônica (a de `shapes="all"` no ark-shape-picker). */
|
|
7392
|
+
const ARK_MARK_SHAPES = [
|
|
7393
|
+
"circle",
|
|
7394
|
+
"square",
|
|
7395
|
+
"triangle",
|
|
7396
|
+
"diamond",
|
|
7397
|
+
"star",
|
|
7398
|
+
"hexagon",
|
|
7399
|
+
"cross",
|
|
7400
|
+
"pentagon",
|
|
7401
|
+
"moon",
|
|
7402
|
+
"asterisk"
|
|
7403
|
+
];
|
|
7120
7404
|
/** Normaliza o valor de `shape`; inválido cai em "circle". */
|
|
7121
7405
|
function normalizeMarkShape(value) {
|
|
7122
7406
|
const shape = (value || "").toLowerCase();
|
|
@@ -7148,6 +7432,7 @@ class ArkMark extends HTMLElementBase {
|
|
|
7148
7432
|
return ["shape", "color", "size", "label", "theme", "class", "testid"];
|
|
7149
7433
|
}
|
|
7150
7434
|
connectedCallback() {
|
|
7435
|
+
upgradeProperties(this);
|
|
7151
7436
|
if (!this.svgEl)
|
|
7152
7437
|
this.render();
|
|
7153
7438
|
this.updateAppearance();
|
|
@@ -7353,6 +7638,7 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7353
7638
|
this.addEventListener("toggle", this.handleToggle);
|
|
7354
7639
|
}
|
|
7355
7640
|
connectedCallback() {
|
|
7641
|
+
upgradeProperties(this);
|
|
7356
7642
|
if (!this.id)
|
|
7357
7643
|
this.id = `ark-menu-${++menuSeq}`;
|
|
7358
7644
|
if (!this.childObserver) {
|
|
@@ -7391,7 +7677,8 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7391
7677
|
return;
|
|
7392
7678
|
}
|
|
7393
7679
|
if (name === "open") {
|
|
7394
|
-
|
|
7680
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
|
|
7681
|
+
if (this.syncingOpen || !this.childObserver)
|
|
7395
7682
|
return;
|
|
7396
7683
|
if (this.hasAttribute("open")) {
|
|
7397
7684
|
this.show();
|
|
@@ -7412,8 +7699,9 @@ class ArkMenu extends HTMLElementBase {
|
|
|
7412
7699
|
}
|
|
7413
7700
|
set open(value) {
|
|
7414
7701
|
const next = coerceBooleanAttr(value);
|
|
7415
|
-
//
|
|
7416
|
-
|
|
7702
|
+
// Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
|
|
7703
|
+
// a reaplica ao conectar): só reflete, e o connectedCallback abre.
|
|
7704
|
+
if (!this.isConnected || !this.childObserver) {
|
|
7417
7705
|
this.toggleAttribute("open", next);
|
|
7418
7706
|
return;
|
|
7419
7707
|
}
|
|
@@ -7663,6 +7951,7 @@ class ArkMenuItem extends HTMLElementBase {
|
|
|
7663
7951
|
this.addEventListener("keydown", this.handleKeydown);
|
|
7664
7952
|
}
|
|
7665
7953
|
connectedCallback() {
|
|
7954
|
+
upgradeProperties(this);
|
|
7666
7955
|
this.updateAppearance();
|
|
7667
7956
|
}
|
|
7668
7957
|
attributeChangedCallback(name) {
|
|
@@ -7887,6 +8176,7 @@ class ArkProgress extends HTMLElementBase {
|
|
|
7887
8176
|
];
|
|
7888
8177
|
}
|
|
7889
8178
|
connectedCallback() {
|
|
8179
|
+
upgradeProperties(this);
|
|
7890
8180
|
if (!this.trackEl)
|
|
7891
8181
|
this.render();
|
|
7892
8182
|
this.updateAppearance();
|
|
@@ -8045,7 +8335,7 @@ let nextId = 0;
|
|
|
8045
8335
|
* silêncio e `change` dispara só no que ganhou a marca; as setas movem o foco
|
|
8046
8336
|
* e marcam, Espaço marca o focado, e um único deles fica na ordem de Tab (o
|
|
8047
8337
|
* marcado, ou o primeiro habilitado). `label`, aria-label e filhos nomeiam a
|
|
8048
|
-
* opção como no ark-checkbox.
|
|
8338
|
+
* opção e `helper` a descreve, como no ark-checkbox.
|
|
8049
8339
|
*/
|
|
8050
8340
|
class ArkRadio extends HTMLElementBase {
|
|
8051
8341
|
static get observedAttributes() {
|
|
@@ -8055,6 +8345,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8055
8345
|
"name",
|
|
8056
8346
|
"value",
|
|
8057
8347
|
"label",
|
|
8348
|
+
"helper",
|
|
8058
8349
|
"aria-label",
|
|
8059
8350
|
"size",
|
|
8060
8351
|
"intent",
|
|
@@ -8070,6 +8361,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8070
8361
|
this.boxEl = null;
|
|
8071
8362
|
this.dotEl = null;
|
|
8072
8363
|
this.labelEl = null;
|
|
8364
|
+
this.helperEl = null;
|
|
8073
8365
|
this.inputEl = null;
|
|
8074
8366
|
this.observer = null;
|
|
8075
8367
|
/** Raiz do grupo no último connect, para ressincronizar os que ficam quando este sai. */
|
|
@@ -8113,6 +8405,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8113
8405
|
this.addEventListener("click", this.handleHostClick);
|
|
8114
8406
|
}
|
|
8115
8407
|
connectedCallback() {
|
|
8408
|
+
upgradeProperties(this);
|
|
8116
8409
|
if (!this.boxEl)
|
|
8117
8410
|
this.render();
|
|
8118
8411
|
if (!this.observer) {
|
|
@@ -8289,11 +8582,11 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8289
8582
|
getSizing() {
|
|
8290
8583
|
const size = (this.getAttribute("size") || "md").toLowerCase();
|
|
8291
8584
|
const sizes = {
|
|
8292
|
-
xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs" },
|
|
8293
|
-
sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm" },
|
|
8294
|
-
md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm" },
|
|
8295
|
-
lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base" },
|
|
8296
|
-
xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg" }
|
|
8585
|
+
xs: { box: "ark:h-3.5 ark:w-3.5", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-xs", helper: "ark:text-2xs" },
|
|
8586
|
+
sm: { box: "ark:h-4 ark:w-4", dot: "ark:h-1.5 ark:w-1.5", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
8587
|
+
md: { box: "ark:h-5 ark:w-5", dot: "ark:h-2 ark:w-2", label: "ark:text-sm", helper: "ark:text-xs" },
|
|
8588
|
+
lg: { box: "ark:h-6 ark:w-6", dot: "ark:h-2.5 ark:w-2.5", label: "ark:text-base", helper: "ark:text-sm" },
|
|
8589
|
+
xl: { box: "ark:h-7 ark:w-7", dot: "ark:h-3 ark:w-3", label: "ark:text-lg", helper: "ark:text-base" }
|
|
8297
8590
|
};
|
|
8298
8591
|
return sizes[size] ?? sizes.md;
|
|
8299
8592
|
}
|
|
@@ -8335,7 +8628,32 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8335
8628
|
}
|
|
8336
8629
|
this.labelEl.htmlFor = this.boxEl?.id ?? "";
|
|
8337
8630
|
this.labelEl.textContent = text;
|
|
8338
|
-
this.labelEl.className = ["ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
8631
|
+
this.labelEl.className = ["ark:col-start-2 ark:cursor-[inherit] ark:select-none ark:text-fg", sizing.label].join(" ");
|
|
8632
|
+
}
|
|
8633
|
+
// Dica própria: um <span> depois do rótulo, só enquanto `helper` existir, que descreve a opção por aria-describedby.
|
|
8634
|
+
// Com ela o host vira grid (updateAppearance): a opção na primeira coluna, rótulo e dica empilhados na segunda.
|
|
8635
|
+
syncHelper(sizing) {
|
|
8636
|
+
if (!this.boxEl)
|
|
8637
|
+
return;
|
|
8638
|
+
const text = this.getAttribute("helper");
|
|
8639
|
+
if (!text) {
|
|
8640
|
+
this.helperEl?.remove();
|
|
8641
|
+
this.helperEl = null;
|
|
8642
|
+
this.boxEl.removeAttribute("aria-describedby");
|
|
8643
|
+
return;
|
|
8644
|
+
}
|
|
8645
|
+
if (!this.helperEl) {
|
|
8646
|
+
const helper = document.createElement("span");
|
|
8647
|
+
helper.setAttribute("data-ark-chrome", "helper");
|
|
8648
|
+
helper.id = `${this.boxEl.id}-helper`;
|
|
8649
|
+
(this.labelEl ?? this.inputEl)?.after(helper);
|
|
8650
|
+
this.helperEl = helper;
|
|
8651
|
+
}
|
|
8652
|
+
if (this.helperEl.textContent !== text)
|
|
8653
|
+
this.helperEl.textContent = text;
|
|
8654
|
+
// order: 1 põe a dica depois do rótulo livre do usuário, que vem depois dos nós próprios.
|
|
8655
|
+
this.helperEl.className = ["ark:col-start-2 ark:order-1 ark:text-fg-muted", sizing.helper].join(" ");
|
|
8656
|
+
this.boxEl.setAttribute("aria-describedby", this.helperEl.id);
|
|
8339
8657
|
}
|
|
8340
8658
|
syncName() {
|
|
8341
8659
|
if (!this.boxEl)
|
|
@@ -8361,6 +8679,16 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8361
8679
|
this.boxEl.removeAttribute("aria-label");
|
|
8362
8680
|
this.boxEl.removeAttribute("aria-labelledby");
|
|
8363
8681
|
}
|
|
8682
|
+
// Nomeada pelo host, a dica entraria no nome: sai da árvore e segue como descrição (aria-describedby alcança
|
|
8683
|
+
// nós ocultos).
|
|
8684
|
+
if (this.helperEl) {
|
|
8685
|
+
if (this.boxEl.getAttribute("aria-labelledby") === this.id) {
|
|
8686
|
+
this.helperEl.setAttribute("aria-hidden", "true");
|
|
8687
|
+
}
|
|
8688
|
+
else {
|
|
8689
|
+
this.helperEl.removeAttribute("aria-hidden");
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8364
8692
|
}
|
|
8365
8693
|
syncDot(checked, sizing) {
|
|
8366
8694
|
if (!this.dotEl)
|
|
@@ -8396,9 +8724,18 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8396
8724
|
const sizing = this.getSizing();
|
|
8397
8725
|
const checked = this.checked;
|
|
8398
8726
|
const disabled = this.disabled;
|
|
8399
|
-
|
|
8727
|
+
// Com `helper` o host é grid: caixa na primeira coluna, rótulo e dica empilhados na segunda.
|
|
8728
|
+
const layout = this.hasAttribute("helper")
|
|
8729
|
+
? "ark:inline-grid ark:grid-cols-[auto_minmax(0,1fr)] ark:gap-x-2 ark:gap-y-0.5"
|
|
8730
|
+
: "ark:inline-flex ark:gap-2";
|
|
8731
|
+
this.applyOwnClasses([
|
|
8732
|
+
layout,
|
|
8733
|
+
"ark:cursor-pointer ark:items-center ark:align-middle ark:has-disabled:cursor-not-allowed ark:has-disabled:opacity-50"
|
|
8734
|
+
]
|
|
8735
|
+
.join(" ")
|
|
8736
|
+
.split(" "));
|
|
8400
8737
|
this.boxEl.className = [
|
|
8401
|
-
"ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
8738
|
+
"ark:col-start-1 ark:row-start-1 ark:inline-flex ark:shrink-0 ark:cursor-pointer ark:items-center ark:justify-center ark:rounded-full ark:border ark:outline-none ark:transition-colors ark:duration-(--ark-duration-quick) ark:ease-(--ark-ease-out) ark:focus-visible:ring-2 ark:focus-visible:ring-offset-2 ark:ring-offset-surface ark:disabled:cursor-not-allowed",
|
|
8402
8739
|
palette.ring,
|
|
8403
8740
|
sizing.box,
|
|
8404
8741
|
checked ? palette.on : "ark:border-border-strong ark:bg-surface ark:text-transparent ark:hover:bg-surface-muted"
|
|
@@ -8407,6 +8744,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8407
8744
|
this.boxEl.disabled = disabled;
|
|
8408
8745
|
this.syncDot(checked, sizing);
|
|
8409
8746
|
this.syncLabel(sizing);
|
|
8747
|
+
this.syncHelper(sizing);
|
|
8410
8748
|
this.syncName();
|
|
8411
8749
|
this.inputEl.checked = checked;
|
|
8412
8750
|
this.inputEl.disabled = disabled;
|
|
@@ -8417,6 +8755,8 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8417
8755
|
applyTestHooks(this, "radio", this.inputEl, "input");
|
|
8418
8756
|
if (this.labelEl)
|
|
8419
8757
|
applyTestHooks(this, "radio", this.labelEl, "label");
|
|
8758
|
+
if (this.helperEl)
|
|
8759
|
+
applyTestHooks(this, "radio", this.helperEl, "helper");
|
|
8420
8760
|
}
|
|
8421
8761
|
}
|
|
8422
8762
|
ArkRadio.tagName = "ark-radio";
|
|
@@ -8538,6 +8878,7 @@ class ArkScheduler extends HTMLElementBase {
|
|
|
8538
8878
|
];
|
|
8539
8879
|
}
|
|
8540
8880
|
connectedCallback() {
|
|
8881
|
+
upgradeProperties(this);
|
|
8541
8882
|
this.locale = this.getLocale();
|
|
8542
8883
|
this.refDate = parseLocalDate(this.getAttribute("date")) || new Date();
|
|
8543
8884
|
this.build();
|
|
@@ -9344,6 +9685,7 @@ class ArkSelect extends HTMLElementBase {
|
|
|
9344
9685
|
];
|
|
9345
9686
|
}
|
|
9346
9687
|
connectedCallback() {
|
|
9688
|
+
upgradeProperties(this);
|
|
9347
9689
|
if (!this.selectEl) {
|
|
9348
9690
|
this.render();
|
|
9349
9691
|
}
|
|
@@ -9599,19 +9941,26 @@ const SHAPE_LABEL = {
|
|
|
9599
9941
|
triangle: "shapeTriangle",
|
|
9600
9942
|
diamond: "shapeDiamond",
|
|
9601
9943
|
star: "shapeStar",
|
|
9602
|
-
hexagon: "shapeHexagon"
|
|
9944
|
+
hexagon: "shapeHexagon",
|
|
9945
|
+
cross: "shapeCross",
|
|
9946
|
+
pentagon: "shapePentagon",
|
|
9947
|
+
moon: "shapeMoon",
|
|
9948
|
+
asterisk: "shapeAsterisk"
|
|
9603
9949
|
};
|
|
9604
9950
|
/**
|
|
9605
9951
|
* Seletor de forma da marca de escopo: o PRÓPRIO host é o `role="radiogroup"`
|
|
9606
|
-
* com
|
|
9607
|
-
* ark-mark desenhado em `color` (a cor atual, para o usuário ver o par
|
|
9608
|
-
* e nomeada pelo nome localizado da forma.
|
|
9609
|
-
* ark-
|
|
9952
|
+
* com uma opção `role="radio"` por forma, renderizada pelo componente, cada
|
|
9953
|
+
* uma um ark-mark desenhado em `color` (a cor atual, para o usuário ver o par
|
|
9954
|
+
* real) e nomeada pelo nome localizado da forma. Sem `shapes` são as dez
|
|
9955
|
+
* formas do ark-mark, na ordem de `ARK_MARK_SHAPES`; `shapes` escolhe quais e
|
|
9956
|
+
* em que ordem. Mesmo teclado do ark-color-swatches. `change` só quando a
|
|
9957
|
+
* seleção muda pelo usuário.
|
|
9610
9958
|
*/
|
|
9611
9959
|
class ArkShapePicker extends HTMLElementBase {
|
|
9612
9960
|
static get observedAttributes() {
|
|
9613
9961
|
return [
|
|
9614
9962
|
"value",
|
|
9963
|
+
"shapes",
|
|
9615
9964
|
"color",
|
|
9616
9965
|
"label",
|
|
9617
9966
|
"aria-label",
|
|
@@ -9629,6 +9978,9 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9629
9978
|
this.ownClasses = [];
|
|
9630
9979
|
this.syncingClass = false;
|
|
9631
9980
|
this.options = [];
|
|
9981
|
+
/** Formas das opções renderizadas, na ordem dos botões. */
|
|
9982
|
+
this.offered = [];
|
|
9983
|
+
this.rendered = false;
|
|
9632
9984
|
this.handleKeydown = (event) => {
|
|
9633
9985
|
if (this.disabled)
|
|
9634
9986
|
return;
|
|
@@ -9657,13 +10009,13 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9657
10009
|
return;
|
|
9658
10010
|
event.preventDefault();
|
|
9659
10011
|
this.options[next].focus();
|
|
9660
|
-
this.select(
|
|
10012
|
+
this.select(this.offered[next]);
|
|
9661
10013
|
};
|
|
9662
10014
|
this.addEventListener("keydown", this.handleKeydown);
|
|
9663
10015
|
}
|
|
9664
10016
|
connectedCallback() {
|
|
9665
|
-
|
|
9666
|
-
|
|
10017
|
+
upgradeProperties(this);
|
|
10018
|
+
this.rendered = true;
|
|
9667
10019
|
this.updateAppearance();
|
|
9668
10020
|
}
|
|
9669
10021
|
attributeChangedCallback(name) {
|
|
@@ -9672,7 +10024,7 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9672
10024
|
this.applyOwnClasses(this.ownClasses);
|
|
9673
10025
|
return;
|
|
9674
10026
|
}
|
|
9675
|
-
if (this.
|
|
10027
|
+
if (!this.rendered || !this.isConnected)
|
|
9676
10028
|
return;
|
|
9677
10029
|
this.updateAppearance();
|
|
9678
10030
|
}
|
|
@@ -9689,19 +10041,41 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9689
10041
|
this.removeAttribute("value");
|
|
9690
10042
|
}
|
|
9691
10043
|
}
|
|
10044
|
+
/** Formas oferecidas, na ordem (atributo `shapes`, separado por vírgula, ou "all"); sem nenhuma válida, as dez. */
|
|
10045
|
+
get shapes() {
|
|
10046
|
+
const raw = (this.getAttribute("shapes") || "").trim().toLowerCase();
|
|
10047
|
+
if (raw === "all")
|
|
10048
|
+
return [...ARK_MARK_SHAPES];
|
|
10049
|
+
const list = [];
|
|
10050
|
+
for (const token of raw.split(",")) {
|
|
10051
|
+
const shape = token.trim();
|
|
10052
|
+
if (ARK_MARK_SHAPES.includes(shape) && !list.includes(shape))
|
|
10053
|
+
list.push(shape);
|
|
10054
|
+
}
|
|
10055
|
+
return list.length > 0 ? list : [...ARK_MARK_SHAPES];
|
|
10056
|
+
}
|
|
10057
|
+
set shapes(value) {
|
|
10058
|
+
const list = Array.isArray(value) ? value.join(",") : value || "";
|
|
10059
|
+
if (list) {
|
|
10060
|
+
this.setAttribute("shapes", list);
|
|
10061
|
+
}
|
|
10062
|
+
else {
|
|
10063
|
+
this.removeAttribute("shapes");
|
|
10064
|
+
}
|
|
10065
|
+
}
|
|
9692
10066
|
get disabled() {
|
|
9693
10067
|
return this.hasAttribute("disabled");
|
|
9694
10068
|
}
|
|
9695
10069
|
set disabled(value) {
|
|
9696
10070
|
this.toggleAttribute("disabled", coerceBooleanAttr(value));
|
|
9697
10071
|
}
|
|
9698
|
-
/** Seleciona uma forma como o usuário faria: muda `value`, foca a opção e emite `change`. */
|
|
10072
|
+
/** Seleciona uma forma oferecida como o usuário faria: muda `value`, foca a opção e emite `change`. */
|
|
9699
10073
|
select(value) {
|
|
9700
10074
|
const shape = normalizeMarkShape(value);
|
|
9701
|
-
if (this.disabled || shape === this.value)
|
|
10075
|
+
if (this.disabled || shape === this.value || !this.shapes.includes(shape))
|
|
9702
10076
|
return;
|
|
9703
10077
|
this.setAttribute("value", shape);
|
|
9704
|
-
this.options[
|
|
10078
|
+
this.options[this.offered.indexOf(shape)]?.focus();
|
|
9705
10079
|
this.dispatchEvent(new CustomEvent("change", { detail: { value: shape }, bubbles: true, composed: true }));
|
|
9706
10080
|
}
|
|
9707
10081
|
getLocale() {
|
|
@@ -9718,8 +10092,15 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9718
10092
|
};
|
|
9719
10093
|
return sizes[size] ?? sizes.md;
|
|
9720
10094
|
}
|
|
9721
|
-
|
|
9722
|
-
|
|
10095
|
+
// Recria as opções só quando a lista oferecida muda (atributo `shapes`); cada botão sabe a própria forma.
|
|
10096
|
+
syncOptions() {
|
|
10097
|
+
const shapes = this.shapes;
|
|
10098
|
+
if (shapes.join(",") === this.offered.join(","))
|
|
10099
|
+
return;
|
|
10100
|
+
for (const option of this.options)
|
|
10101
|
+
option.remove();
|
|
10102
|
+
this.offered = shapes;
|
|
10103
|
+
this.options = shapes.map((shape) => {
|
|
9723
10104
|
const button = document.createElement("button");
|
|
9724
10105
|
button.type = "button";
|
|
9725
10106
|
button.setAttribute("role", "radio");
|
|
@@ -9751,6 +10132,7 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9751
10132
|
const disabled = this.disabled;
|
|
9752
10133
|
const sizing = this.getSizing();
|
|
9753
10134
|
const color = this.getAttribute("color")?.trim() || "";
|
|
10135
|
+
this.syncOptions();
|
|
9754
10136
|
this.setAttribute("role", "radiogroup");
|
|
9755
10137
|
// Só quando muda: aria-label é observado e um set igual reentraria aqui.
|
|
9756
10138
|
const label = this.getAttribute("label");
|
|
@@ -9766,10 +10148,10 @@ class ArkShapePicker extends HTMLElementBase {
|
|
|
9766
10148
|
.join(" ")
|
|
9767
10149
|
.split(" ")
|
|
9768
10150
|
.filter(Boolean));
|
|
9769
|
-
const selectedIndex = value ?
|
|
10151
|
+
const selectedIndex = value ? this.offered.indexOf(value) : -1;
|
|
9770
10152
|
const stop = selectedIndex >= 0 ? selectedIndex : 0;
|
|
9771
10153
|
this.options.forEach((option, index) => {
|
|
9772
|
-
const shape =
|
|
10154
|
+
const shape = this.offered[index];
|
|
9773
10155
|
const selected = index === selectedIndex;
|
|
9774
10156
|
option.setAttribute("aria-label", String(locale[SHAPE_LABEL[shape]]));
|
|
9775
10157
|
option.setAttribute("aria-checked", selected ? "true" : "false");
|
|
@@ -9835,6 +10217,7 @@ class ArkSkeleton extends HTMLElementBase {
|
|
|
9835
10217
|
return ["rows", "animated", "rounded", "color", "ratio", "theme", "class", "testid"];
|
|
9836
10218
|
}
|
|
9837
10219
|
connectedCallback() {
|
|
10220
|
+
upgradeProperties(this);
|
|
9838
10221
|
this.updateAppearance();
|
|
9839
10222
|
}
|
|
9840
10223
|
attributeChangedCallback(name) {
|
|
@@ -9986,6 +10369,7 @@ class ArkSpinner extends HTMLElementBase {
|
|
|
9986
10369
|
return ["size", "intent", "label", "lang", "locale-json", "theme", "class", "testid"];
|
|
9987
10370
|
}
|
|
9988
10371
|
connectedCallback() {
|
|
10372
|
+
upgradeProperties(this);
|
|
9989
10373
|
if (!this.iconEl)
|
|
9990
10374
|
this.render();
|
|
9991
10375
|
this.updateAppearance();
|
|
@@ -10161,6 +10545,7 @@ class ArkSplitPane extends HTMLElementBase {
|
|
|
10161
10545
|
return ["direction", "sizes", "lang", "locale-json", "theme", "class", "testid"];
|
|
10162
10546
|
}
|
|
10163
10547
|
connectedCallback() {
|
|
10548
|
+
upgradeProperties(this);
|
|
10164
10549
|
if (!this.observer) {
|
|
10165
10550
|
// Painéis que entram ou saem mudam o número de alças e a distribuição.
|
|
10166
10551
|
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
@@ -10391,6 +10776,7 @@ class ArkStatusDot extends HTMLElementBase {
|
|
|
10391
10776
|
return ["intent", "label", "size", "theme", "class", "testid"];
|
|
10392
10777
|
}
|
|
10393
10778
|
connectedCallback() {
|
|
10779
|
+
upgradeProperties(this);
|
|
10394
10780
|
this.updateAppearance();
|
|
10395
10781
|
}
|
|
10396
10782
|
attributeChangedCallback(name) {
|
|
@@ -10501,6 +10887,7 @@ class ArkSwitch extends HTMLElementBase {
|
|
|
10501
10887
|
];
|
|
10502
10888
|
}
|
|
10503
10889
|
connectedCallback() {
|
|
10890
|
+
upgradeProperties(this);
|
|
10504
10891
|
if (!this.trackEl) {
|
|
10505
10892
|
this.render();
|
|
10506
10893
|
}
|
|
@@ -10842,6 +11229,7 @@ class ArkTab extends HTMLElementBase {
|
|
|
10842
11229
|
this.addEventListener("keydown", this.handleKeydown);
|
|
10843
11230
|
}
|
|
10844
11231
|
connectedCallback() {
|
|
11232
|
+
upgradeProperties(this);
|
|
10845
11233
|
this.updateAppearance();
|
|
10846
11234
|
}
|
|
10847
11235
|
attributeChangedCallback(name) {
|
|
@@ -11202,6 +11590,7 @@ class ArkTabs extends HTMLElementBase {
|
|
|
11202
11590
|
this.addEventListener("keydown", this.handleKeydown);
|
|
11203
11591
|
}
|
|
11204
11592
|
connectedCallback() {
|
|
11593
|
+
upgradeProperties(this);
|
|
11205
11594
|
if (!this.observer) {
|
|
11206
11595
|
this.observer = new MutationObserver(() => this.syncTabs());
|
|
11207
11596
|
this.observer.observe(this, { childList: true, subtree: true });
|
|
@@ -11403,6 +11792,7 @@ class ArkTextarea extends HTMLElementBase {
|
|
|
11403
11792
|
];
|
|
11404
11793
|
}
|
|
11405
11794
|
connectedCallback() {
|
|
11795
|
+
upgradeProperties(this);
|
|
11406
11796
|
if (!this.textareaEl) {
|
|
11407
11797
|
this.render();
|
|
11408
11798
|
}
|
|
@@ -11600,6 +11990,7 @@ class ArkToaster extends HTMLElementBase {
|
|
|
11600
11990
|
return ["theme", "position", "rich-colors", "close-button", "max-visible", "duration", "lang", "testid"];
|
|
11601
11991
|
}
|
|
11602
11992
|
connectedCallback() {
|
|
11993
|
+
upgradeProperties(this);
|
|
11603
11994
|
this.build();
|
|
11604
11995
|
window.addEventListener("ark-toast", this.handleToast);
|
|
11605
11996
|
window.addEventListener("ark-toast-dismiss", this.handleDismiss);
|
|
@@ -11993,6 +12384,7 @@ class ArkToggle extends HTMLElementBase {
|
|
|
11993
12384
|
this.addEventListener("keyup", this.handleKeyup);
|
|
11994
12385
|
}
|
|
11995
12386
|
connectedCallback() {
|
|
12387
|
+
upgradeProperties(this);
|
|
11996
12388
|
this.updateAppearance();
|
|
11997
12389
|
}
|
|
11998
12390
|
attributeChangedCallback(name) {
|
|
@@ -12198,6 +12590,7 @@ class ArkToggleGroup extends HTMLElementBase {
|
|
|
12198
12590
|
this.addEventListener("change", this.handleToggleChange);
|
|
12199
12591
|
}
|
|
12200
12592
|
connectedCallback() {
|
|
12593
|
+
upgradeProperties(this);
|
|
12201
12594
|
if (!this.observer) {
|
|
12202
12595
|
this.observer = new MutationObserver(() => this.syncToggles());
|
|
12203
12596
|
this.observer.observe(this, { childList: true, subtree: true });
|
|
@@ -12396,6 +12789,7 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12396
12789
|
this.addEventListener("focusout", this.handleFocusOut);
|
|
12397
12790
|
}
|
|
12398
12791
|
connectedCallback() {
|
|
12792
|
+
upgradeProperties(this);
|
|
12399
12793
|
if (!this.observer) {
|
|
12400
12794
|
this.observer = new MutationObserver(() => this.updateAppearance());
|
|
12401
12795
|
this.observer.observe(this, { childList: true });
|
|
@@ -12424,7 +12818,8 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12424
12818
|
if (!this.isConnected)
|
|
12425
12819
|
return;
|
|
12426
12820
|
if (name === "open") {
|
|
12427
|
-
|
|
12821
|
+
// Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
|
|
12822
|
+
if (this.syncingOpen || !this.observer)
|
|
12428
12823
|
return;
|
|
12429
12824
|
if (this.hasAttribute("open")) {
|
|
12430
12825
|
this.show();
|
|
@@ -12444,8 +12839,9 @@ class ArkTooltip extends HTMLElementBase {
|
|
|
12444
12839
|
}
|
|
12445
12840
|
set open(value) {
|
|
12446
12841
|
const next = coerceBooleanAttr(value);
|
|
12447
|
-
//
|
|
12448
|
-
|
|
12842
|
+
// Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
|
|
12843
|
+
// a reaplica ao conectar): só reflete, e o connectedCallback abre.
|
|
12844
|
+
if (!this.isConnected || !this.observer) {
|
|
12449
12845
|
this.toggleAttribute("open", next);
|
|
12450
12846
|
return;
|
|
12451
12847
|
}
|