@tooark/web-components 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -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());
@@ -314,6 +342,7 @@ class ArkAvatar extends HTMLElementBase {
314
342
  return ["name", "src", "size", "shape", "color", "aria-label", "theme", "class", "testid"];
315
343
  }
316
344
  connectedCallback() {
345
+ upgradeProperties(this);
317
346
  if (!this.initialsEl)
318
347
  this.render();
319
348
  this.updateAppearance();
@@ -492,6 +521,7 @@ class ArkBadge extends HTMLElementBase {
492
521
  return ["intent", "variant", "size", "rounded", "color", "theme", "class", "testid"];
493
522
  }
494
523
  connectedCallback() {
524
+ upgradeProperties(this);
495
525
  this.updateAppearance();
496
526
  }
497
527
  attributeChangedCallback(name) {
@@ -779,6 +809,7 @@ class ArkButton extends HTMLElementBase {
779
809
  * Chamado pelo navegador quando o elemento é adicionado ao DOM.
780
810
  */
781
811
  connectedCallback() {
812
+ upgradeProperties(this);
782
813
  this.updateAppearance();
783
814
  }
784
815
  /**
@@ -1303,6 +1334,7 @@ class ArkCalendar extends HTMLElementBase {
1303
1334
  ];
1304
1335
  }
1305
1336
  connectedCallback() {
1337
+ upgradeProperties(this);
1306
1338
  this.locale = this.getLocale();
1307
1339
  const parsed = this.parseDate(this.getAttribute("value"));
1308
1340
  if (parsed) {
@@ -1924,6 +1956,7 @@ class ArkCard extends HTMLElementBase {
1924
1956
  return ["heading", "padding", "rounded", "theme", "class", "testid"];
1925
1957
  }
1926
1958
  connectedCallback() {
1959
+ upgradeProperties(this);
1927
1960
  if (!this.observer) {
1928
1961
  // Slots que chegam depois (frameworks) recebem o hook.
1929
1962
  this.observer = new MutationObserver(() => this.syncSlots());
@@ -2135,6 +2168,7 @@ class ArkCarousel extends HTMLElementBase {
2135
2168
  this.addEventListener("focusout", this.handleMouseLeave);
2136
2169
  }
2137
2170
  connectedCallback() {
2171
+ upgradeProperties(this);
2138
2172
  this.build();
2139
2173
  if (!this.observer) {
2140
2174
  this.observer = new MutationObserver((records) => {
@@ -2558,6 +2592,7 @@ class ArkCheckbox extends HTMLElementBase {
2558
2592
  this.addEventListener("click", this.handleHostClick);
2559
2593
  }
2560
2594
  connectedCallback() {
2595
+ upgradeProperties(this);
2561
2596
  if (!this.boxEl)
2562
2597
  this.render();
2563
2598
  if (!this.observer) {
@@ -2856,6 +2891,7 @@ class ArkClock extends HTMLElementBase {
2856
2891
  return ["value", "seconds", "step-minutes", "hours-format", "lang", "locale-json", "theme", "intent", "testid"];
2857
2892
  }
2858
2893
  connectedCallback() {
2894
+ upgradeProperties(this);
2859
2895
  this.build();
2860
2896
  }
2861
2897
  attributeChangedCallback(name, oldValue, newValue) {
@@ -3133,6 +3169,7 @@ class ArkColorSwatches extends HTMLElementBase {
3133
3169
  this.addEventListener("keydown", this.handleKeydown);
3134
3170
  }
3135
3171
  connectedCallback() {
3172
+ upgradeProperties(this);
3136
3173
  this.updateAppearance();
3137
3174
  }
3138
3175
  attributeChangedCallback(name) {
@@ -3307,6 +3344,7 @@ class ArkCommandItem extends HTMLElementBase {
3307
3344
  this.addEventListener("click", this.handleClick);
3308
3345
  }
3309
3346
  connectedCallback() {
3347
+ upgradeProperties(this);
3310
3348
  this.updateAppearance();
3311
3349
  }
3312
3350
  attributeChangedCallback(name) {
@@ -3547,6 +3585,7 @@ class ArkCommandPalette extends HTMLElementBase {
3547
3585
  this.addEventListener("ark-select", this.handleItemSelect);
3548
3586
  }
3549
3587
  connectedCallback() {
3588
+ upgradeProperties(this);
3550
3589
  if (!this.inputEl)
3551
3590
  this.render();
3552
3591
  if (!this.observer) {
@@ -3585,6 +3624,10 @@ class ArkCommandPalette extends HTMLElementBase {
3585
3624
  if (!this.isConnected)
3586
3625
  return;
3587
3626
  if (name === "open") {
3627
+ // Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
3628
+ // reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
3629
+ if (!this.observer)
3630
+ return;
3588
3631
  if (this.hasAttribute("open")) {
3589
3632
  this.openNow();
3590
3633
  }
@@ -3920,6 +3963,7 @@ class ArkCopyButton extends ArkButton {
3920
3963
  this.addEventListener("click", this.handleCopyClick);
3921
3964
  }
3922
3965
  connectedCallback() {
3966
+ upgradeProperties(this);
3923
3967
  if (!this.childObserver) {
3924
3968
  // Rótulo do usuário que chega ou sai depois decide se o rótulo próprio aparece.
3925
3969
  this.childObserver = new MutationObserver(() => this.updateAppearance());
@@ -4202,6 +4246,7 @@ class ArkDatepicker extends HTMLElementBase {
4202
4246
  ];
4203
4247
  }
4204
4248
  connectedCallback() {
4249
+ upgradeProperties(this);
4205
4250
  if (!this.hasRendered()) {
4206
4251
  this.syncFromValue();
4207
4252
  this.render();
@@ -4781,6 +4826,7 @@ class ArkDialog extends HTMLElementBase {
4781
4826
  this.addEventListener("keydown", this.handleKeydown);
4782
4827
  }
4783
4828
  connectedCallback() {
4829
+ upgradeProperties(this);
4784
4830
  if (!this.observer) {
4785
4831
  // Um footer que chega depois (framework) recebe o hook; o resto do DOM é do usuário.
4786
4832
  this.observer = new MutationObserver(() => this.syncFooter());
@@ -4814,6 +4860,10 @@ class ArkDialog extends HTMLElementBase {
4814
4860
  if (name === "open") {
4815
4861
  const reason = this.pendingReason ?? "api";
4816
4862
  this.pendingReason = null;
4863
+ // Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
4864
+ // reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
4865
+ if (!this.observer)
4866
+ return;
4817
4867
  if (this.hasAttribute("open")) {
4818
4868
  this.openNow();
4819
4869
  }
@@ -5148,6 +5198,7 @@ class ArkDrawer extends HTMLElementBase {
5148
5198
  this.addEventListener("keydown", this.handleKeydown);
5149
5199
  }
5150
5200
  connectedCallback() {
5201
+ upgradeProperties(this);
5151
5202
  if (!this.observer) {
5152
5203
  this.observer = new MutationObserver(() => this.syncFooter());
5153
5204
  this.observer.observe(this, { childList: true });
@@ -5179,6 +5230,10 @@ class ArkDrawer extends HTMLElementBase {
5179
5230
  if (name === "open") {
5180
5231
  const reason = this.pendingReason ?? "api";
5181
5232
  this.pendingReason = null;
5233
+ // Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM, hidratação de SSR, prop
5234
+ // reaplicada ao conectar): quem abre é ele, com o ark-open no microtask.
5235
+ if (!this.observer)
5236
+ return;
5182
5237
  if (this.hasAttribute("open")) {
5183
5238
  this.openNow();
5184
5239
  }
@@ -5504,6 +5559,7 @@ class ArkEmpty extends HTMLElementBase {
5504
5559
  return ["heading", "description", "theme", "class", "testid"];
5505
5560
  }
5506
5561
  connectedCallback() {
5562
+ upgradeProperties(this);
5507
5563
  if (!this.observer) {
5508
5564
  // Ícone ou ação que chegam depois (frameworks) recebem o hook.
5509
5565
  this.observer = new MutationObserver(() => this.syncSlots());
@@ -5691,6 +5747,7 @@ class ArkFileInput extends HTMLElementBase {
5691
5747
  ];
5692
5748
  }
5693
5749
  connectedCallback() {
5750
+ upgradeProperties(this);
5694
5751
  if (!this.inputEl)
5695
5752
  this.render();
5696
5753
  this.updateAppearance();
@@ -6083,6 +6140,7 @@ class ArkInput extends HTMLElementBase {
6083
6140
  ];
6084
6141
  }
6085
6142
  connectedCallback() {
6143
+ upgradeProperties(this);
6086
6144
  if (!this.inputEl) {
6087
6145
  this.render();
6088
6146
  }
@@ -6366,6 +6424,7 @@ class ArkKbd extends HTMLElementBase {
6366
6424
  return ["size", "theme", "class", "testid"];
6367
6425
  }
6368
6426
  connectedCallback() {
6427
+ upgradeProperties(this);
6369
6428
  this.updateAppearance();
6370
6429
  }
6371
6430
  attributeChangedCallback(name) {
@@ -6476,7 +6535,9 @@ function cloneRow(row) {
6476
6535
  * preservados por posição) ou "json" (array com todos os campos). `change`
6477
6536
  * publica as linhas a cada edição, inclusive ao sair do modo em massa;
6478
6537
  * adicionar e remover anunciam a contagem ao leitor de tela. A célula de
6479
- * valor é um ark-input comum: autocomplete de variáveis fica no app.
6538
+ * valor é um ark-input; a propriedade `valueField` troca pelo elemento que o
6539
+ * app criar (um campo com autocomplete de `{{variável}}`, por exemplo), exceto
6540
+ * nas linhas secretas, que mantêm o campo de senha.
6480
6541
  */
6481
6542
  class ArkKvEditor extends HTMLElementBase {
6482
6543
  static get observedAttributes() {
@@ -6519,6 +6580,10 @@ class ArkKvEditor extends HTMLElementBase {
6519
6580
  this.bulkBase = null;
6520
6581
  /** Último texto em massa que o próprio componente escreveu, para não sobrescrever o que o usuário digita. */
6521
6582
  this.bulkWritten = "";
6583
+ /** Fábrica da célula de valor (`valueField`); sem ela, todo valor é um ark-input. */
6584
+ this.valueFactory = null;
6585
+ /** Células de valor criadas pela fábrica, que não recebem `type`/`reveal` do ark-input. */
6586
+ this.customCells = new WeakSet();
6522
6587
  // --- Interação ---
6523
6588
  this.handleBulkInput = () => {
6524
6589
  if (!this.bulkEl)
@@ -6541,6 +6606,7 @@ class ArkKvEditor extends HTMLElementBase {
6541
6606
  });
6542
6607
  }
6543
6608
  connectedCallback() {
6609
+ upgradeProperties(this);
6544
6610
  if (!this.listEl)
6545
6611
  this.render();
6546
6612
  this.updateAppearance();
@@ -6628,6 +6694,20 @@ class ArkKvEditor extends HTMLElementBase {
6628
6694
  set secret(value) {
6629
6695
  this.toggleAttribute("secret", core.coerceBooleanAttr(value));
6630
6696
  }
6697
+ /**
6698
+ * Fábrica da célula de valor (propriedade JS): o elemento que ela devolve substitui o ark-input da linha, exceto
6699
+ * nas linhas secretas, que mantêm o campo de senha; `null` numa linha mantém o ark-input nela.
6700
+ */
6701
+ get valueField() {
6702
+ return this.valueFactory;
6703
+ }
6704
+ set valueField(value) {
6705
+ this.valueFactory = typeof value === "function" ? value : null;
6706
+ // As células de valor são recriadas com a fábrica nova.
6707
+ this.resetRows();
6708
+ if (this.isConnected)
6709
+ this.updateAppearance();
6710
+ }
6631
6711
  get readonly() {
6632
6712
  return this.hasAttribute("readonly");
6633
6713
  }
@@ -6676,6 +6756,10 @@ class ArkKvEditor extends HTMLElementBase {
6676
6756
  getLocale() {
6677
6757
  return core.resolveLocale(this.getAttribute("lang") || "en", this.getAttribute("locale-json") || undefined);
6678
6758
  }
6759
+ // Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
6760
+ effectiveType(row, types) {
6761
+ return types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
6762
+ }
6679
6763
  getSize() {
6680
6764
  const size = (this.getAttribute("size") || "").toLowerCase();
6681
6765
  return size === "xs" || size === "sm" || size === "lg" || size === "xl" ? size : "md";
@@ -6818,16 +6902,7 @@ class ArkKvEditor extends HTMLElementBase {
6818
6902
  this.emitChange();
6819
6903
  });
6820
6904
  const key = this.createField(row.id, "key", size);
6821
- const value = this.createField(row.id, "value", size);
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
- });
6905
+ const value = this.createValueCell(row, size);
6831
6906
  const remove = document.createElement("ark-button");
6832
6907
  remove.setAttribute("variant", "ghost");
6833
6908
  remove.setAttribute("intent", "neutral");
@@ -6876,15 +6951,69 @@ class ArkKvEditor extends HTMLElementBase {
6876
6951
  el.appendChild(remove);
6877
6952
  return el;
6878
6953
  }
6954
+ // Célula de valor: com `valueField` e fora das linhas secretas, o elemento da fábrica; senão o ark-input.
6955
+ createValueCell(row, size) {
6956
+ const custom = this.valueFactory && !(this.secret && row.secret === true)
6957
+ ? this.valueFactory({ row: { ...row }, type: this.effectiveType(row, this.types) ?? "", size })
6958
+ : null;
6959
+ if (!(custom instanceof HTMLElement)) {
6960
+ const value = this.createField(row.id, "value", size);
6961
+ // Enter no valor da última linha acrescenta a próxima, como numa tabela.
6962
+ value.addEventListener("keydown", (event) => {
6963
+ if (event.key !== "Enter" || this.readonly)
6964
+ return;
6965
+ if (this.model[this.model.length - 1]?.id !== row.id)
6966
+ return;
6967
+ event.preventDefault();
6968
+ this.add();
6969
+ });
6970
+ return value;
6971
+ }
6972
+ const cell = custom;
6973
+ cell.setAttribute("data-ark-field", "value");
6974
+ this.customCells.add(cell);
6975
+ // O campo do app pode emitir `input` antes de atualizar `value` (e `change` depois): só um valor novo conta.
6976
+ const sync = () => {
6977
+ const current = this.model.find((item) => item.id === row.id);
6978
+ const next = cell.value;
6979
+ if (!current || typeof next !== "string" || next === current.value)
6980
+ return;
6981
+ current.value = next;
6982
+ this.emitChange();
6983
+ };
6984
+ cell.addEventListener("input", (event) => {
6985
+ event.stopPropagation();
6986
+ sync();
6987
+ });
6988
+ cell.addEventListener("change", sync);
6989
+ // Enter que o campo não consumiu, ou o `ark-submit` de um campo que consome o Enter, na última linha acrescenta
6990
+ // a próxima.
6991
+ const addNext = (event) => {
6992
+ if (this.readonly || event.defaultPrevented)
6993
+ return;
6994
+ if (this.model[this.model.length - 1]?.id !== row.id)
6995
+ return;
6996
+ if (event.cancelable)
6997
+ event.preventDefault();
6998
+ this.add();
6999
+ };
7000
+ cell.addEventListener("keydown", (event) => {
7001
+ if (event.key === "Enter")
7002
+ addNext(event);
7003
+ });
7004
+ cell.addEventListener("ark-submit", addNext);
7005
+ return cell;
7006
+ }
7007
+ // Filhos diretos da linha: uma célula de valor do app pode ter botões, selects e campos próprios dentro.
6879
7008
  rowParts(el) {
6880
7009
  return {
6881
- enabled: el.querySelector("ark-checkbox"),
6882
- key: el.querySelector('ark-input[data-ark-field="key"]'),
6883
- value: el.querySelector('ark-input[data-ark-field="value"]'),
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")
7010
+ enabled: el.querySelector(":scope > ark-checkbox"),
7011
+ key: el.querySelector(':scope > ark-input[data-ark-field="key"]'),
7012
+ value: el.querySelector(':scope > [data-ark-field="value"]'),
7013
+ secret: this.secret ? el.querySelector(":scope > ark-button") : null,
7014
+ type: el.querySelector(":scope > ark-select"),
7015
+ description: el.querySelector(':scope > ark-input[data-ark-field="description"]'),
7016
+ remove: el.querySelector(":scope > ark-button:last-of-type")
6888
7017
  };
6889
7018
  }
6890
7019
  // Classes de grid por combinação de colunas (segredo, tipo, descrição): literais completas, para o Tailwind
@@ -6928,6 +7057,17 @@ class ArkKvEditor extends HTMLElementBase {
6928
7057
  if (el !== anchor)
6929
7058
  this.listEl.insertBefore(el, anchor);
6930
7059
  previous = el;
7060
+ const rowType = this.effectiveType(row, types);
7061
+ const isSecret = withSecret && row.secret === true;
7062
+ // Com `valueField`, segredo e tipo decidem a célula (a fábrica recebe o tipo, o segredo fica no campo de
7063
+ // senha): quando mudam, a célula de valor é recriada. Sem fábrica o ark-input só troca de `type`.
7064
+ if (this.valueFactory) {
7065
+ const valueKey = `${isSecret}|${rowType ?? ""}`;
7066
+ if (el.dataset.arkValueKey !== undefined && el.dataset.arkValueKey !== valueKey) {
7067
+ this.rowParts(el).value.replaceWith(this.createValueCell(row, size));
7068
+ }
7069
+ el.dataset.arkValueKey = valueKey;
7070
+ }
6931
7071
  const parts = this.rowParts(el);
6932
7072
  el.className = [
6933
7073
  "ark:grid ark:items-center ark:gap-2 ark:px-3 ark:py-1.5",
@@ -6956,12 +7096,12 @@ class ArkKvEditor extends HTMLElementBase {
6956
7096
  input.toggleAttribute("readonly", readonly);
6957
7097
  applyTestHooks(this, "kv-editor", input, name);
6958
7098
  }
6959
- // Tipo efetivo: com a coluna de tipos, o que o select mostra (o da linha se está na lista, senão o primeiro).
6960
- const rowType = types.length > 0 ? (row.type && types.includes(row.type) ? row.type : types[0]) : row.type;
6961
- // Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto.
6962
- const isSecret = withSecret && row.secret === true;
6963
- parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
6964
- parts.value.toggleAttribute("reveal", isSecret);
7099
+ // Campo de valor: senha com o olho quando é segredo; senão o tipo efetivo (number, date...) ou texto. A célula
7100
+ // da fábrica decide o próprio tipo (recebe `type` no contexto).
7101
+ if (!this.customCells.has(parts.value)) {
7102
+ parts.value.setAttribute("type", isSecret ? "password" : (VALUE_INPUT_TYPES[rowType ?? ""] ?? "text"));
7103
+ parts.value.toggleAttribute("reveal", isSecret);
7104
+ }
6965
7105
  if (parts.secret) {
6966
7106
  parts.secret.setAttribute("aria-label", locale.secret);
6967
7107
  parts.secret.title = locale.secret;
@@ -7115,10 +7255,25 @@ const ARK_MARK_PATHS = {
7115
7255
  triangle: "M12 2 22 21H2Z",
7116
7256
  diamond: "M12 1 23 12 12 23 1 12Z",
7117
7257
  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"
7258
+ hexagon: "M7 2h10l5 10-5 10H7L2 12Z",
7259
+ cross: "M9 2h6v7h7v6h-7v7H9v-7H2V9h7Z",
7260
+ pentagon: "M12 2l10.5 7.6-4 12.3h-13l-4-12.3Z",
7261
+ moon: "M12 2a7.1 7.1 0 0 0 10 10 10 10 0 1 1-10-10Z",
7262
+ 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
7263
  };
7120
- /** As seis formas, na ordem em que o ark-shape-picker as oferece. */
7121
- const ARK_MARK_SHAPES = ["circle", "square", "triangle", "diamond", "star", "hexagon"];
7264
+ /** As dez formas, na ordem canônica (a de `shapes="all"` no ark-shape-picker). */
7265
+ const ARK_MARK_SHAPES = [
7266
+ "circle",
7267
+ "square",
7268
+ "triangle",
7269
+ "diamond",
7270
+ "star",
7271
+ "hexagon",
7272
+ "cross",
7273
+ "pentagon",
7274
+ "moon",
7275
+ "asterisk"
7276
+ ];
7122
7277
  /** Normaliza o valor de `shape`; inválido cai em "circle". */
7123
7278
  function normalizeMarkShape(value) {
7124
7279
  const shape = (value || "").toLowerCase();
@@ -7150,6 +7305,7 @@ class ArkMark extends HTMLElementBase {
7150
7305
  return ["shape", "color", "size", "label", "theme", "class", "testid"];
7151
7306
  }
7152
7307
  connectedCallback() {
7308
+ upgradeProperties(this);
7153
7309
  if (!this.svgEl)
7154
7310
  this.render();
7155
7311
  this.updateAppearance();
@@ -7355,6 +7511,7 @@ class ArkMenu extends HTMLElementBase {
7355
7511
  this.addEventListener("toggle", this.handleToggle);
7356
7512
  }
7357
7513
  connectedCallback() {
7514
+ upgradeProperties(this);
7358
7515
  if (!this.id)
7359
7516
  this.id = `ark-menu-${++menuSeq}`;
7360
7517
  if (!this.childObserver) {
@@ -7393,7 +7550,8 @@ class ArkMenu extends HTMLElementBase {
7393
7550
  return;
7394
7551
  }
7395
7552
  if (name === "open") {
7396
- if (this.syncingOpen)
7553
+ // Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
7554
+ if (this.syncingOpen || !this.childObserver)
7397
7555
  return;
7398
7556
  if (this.hasAttribute("open")) {
7399
7557
  this.show();
@@ -7414,8 +7572,9 @@ class ArkMenu extends HTMLElementBase {
7414
7572
  }
7415
7573
  set open(value) {
7416
7574
  const next = core.coerceBooleanAttr(value);
7417
- // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
7418
- if (!this.isConnected) {
7575
+ // Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
7576
+ // a reaplica ao conectar): só reflete, e o connectedCallback abre.
7577
+ if (!this.isConnected || !this.childObserver) {
7419
7578
  this.toggleAttribute("open", next);
7420
7579
  return;
7421
7580
  }
@@ -7665,6 +7824,7 @@ class ArkMenuItem extends HTMLElementBase {
7665
7824
  this.addEventListener("keydown", this.handleKeydown);
7666
7825
  }
7667
7826
  connectedCallback() {
7827
+ upgradeProperties(this);
7668
7828
  this.updateAppearance();
7669
7829
  }
7670
7830
  attributeChangedCallback(name) {
@@ -7889,6 +8049,7 @@ class ArkProgress extends HTMLElementBase {
7889
8049
  ];
7890
8050
  }
7891
8051
  connectedCallback() {
8052
+ upgradeProperties(this);
7892
8053
  if (!this.trackEl)
7893
8054
  this.render();
7894
8055
  this.updateAppearance();
@@ -8115,6 +8276,7 @@ class ArkRadio extends HTMLElementBase {
8115
8276
  this.addEventListener("click", this.handleHostClick);
8116
8277
  }
8117
8278
  connectedCallback() {
8279
+ upgradeProperties(this);
8118
8280
  if (!this.boxEl)
8119
8281
  this.render();
8120
8282
  if (!this.observer) {
@@ -8540,6 +8702,7 @@ class ArkScheduler extends HTMLElementBase {
8540
8702
  ];
8541
8703
  }
8542
8704
  connectedCallback() {
8705
+ upgradeProperties(this);
8543
8706
  this.locale = this.getLocale();
8544
8707
  this.refDate = parseLocalDate(this.getAttribute("date")) || new Date();
8545
8708
  this.build();
@@ -9346,6 +9509,7 @@ class ArkSelect extends HTMLElementBase {
9346
9509
  ];
9347
9510
  }
9348
9511
  connectedCallback() {
9512
+ upgradeProperties(this);
9349
9513
  if (!this.selectEl) {
9350
9514
  this.render();
9351
9515
  }
@@ -9601,19 +9765,26 @@ const SHAPE_LABEL = {
9601
9765
  triangle: "shapeTriangle",
9602
9766
  diamond: "shapeDiamond",
9603
9767
  star: "shapeStar",
9604
- hexagon: "shapeHexagon"
9768
+ hexagon: "shapeHexagon",
9769
+ cross: "shapeCross",
9770
+ pentagon: "shapePentagon",
9771
+ moon: "shapeMoon",
9772
+ asterisk: "shapeAsterisk"
9605
9773
  };
9606
9774
  /**
9607
9775
  * Seletor de forma da marca de escopo: o PRÓPRIO host é o `role="radiogroup"`
9608
- * com seis opções `role="radio"` renderizadas pelo componente, cada uma um
9609
- * ark-mark desenhado em `color` (a cor atual, para o usuário ver o par real)
9610
- * e nomeada pelo nome localizado da forma. Mesmo teclado do
9611
- * ark-color-swatches. `change` só quando a seleção muda pelo usuário.
9776
+ * com uma opção `role="radio"` por forma, renderizada pelo componente, cada
9777
+ * uma um ark-mark desenhado em `color` (a cor atual, para o usuário ver o par
9778
+ * real) e nomeada pelo nome localizado da forma. Sem `shapes` são as dez
9779
+ * formas do ark-mark, na ordem de `ARK_MARK_SHAPES`; `shapes` escolhe quais e
9780
+ * em que ordem. Mesmo teclado do ark-color-swatches. `change` só quando a
9781
+ * seleção muda pelo usuário.
9612
9782
  */
9613
9783
  class ArkShapePicker extends HTMLElementBase {
9614
9784
  static get observedAttributes() {
9615
9785
  return [
9616
9786
  "value",
9787
+ "shapes",
9617
9788
  "color",
9618
9789
  "label",
9619
9790
  "aria-label",
@@ -9631,6 +9802,9 @@ class ArkShapePicker extends HTMLElementBase {
9631
9802
  this.ownClasses = [];
9632
9803
  this.syncingClass = false;
9633
9804
  this.options = [];
9805
+ /** Formas das opções renderizadas, na ordem dos botões. */
9806
+ this.offered = [];
9807
+ this.rendered = false;
9634
9808
  this.handleKeydown = (event) => {
9635
9809
  if (this.disabled)
9636
9810
  return;
@@ -9659,13 +9833,13 @@ class ArkShapePicker extends HTMLElementBase {
9659
9833
  return;
9660
9834
  event.preventDefault();
9661
9835
  this.options[next].focus();
9662
- this.select(ARK_MARK_SHAPES[next]);
9836
+ this.select(this.offered[next]);
9663
9837
  };
9664
9838
  this.addEventListener("keydown", this.handleKeydown);
9665
9839
  }
9666
9840
  connectedCallback() {
9667
- if (this.options.length === 0)
9668
- this.render();
9841
+ upgradeProperties(this);
9842
+ this.rendered = true;
9669
9843
  this.updateAppearance();
9670
9844
  }
9671
9845
  attributeChangedCallback(name) {
@@ -9674,7 +9848,7 @@ class ArkShapePicker extends HTMLElementBase {
9674
9848
  this.applyOwnClasses(this.ownClasses);
9675
9849
  return;
9676
9850
  }
9677
- if (this.options.length === 0 || !this.isConnected)
9851
+ if (!this.rendered || !this.isConnected)
9678
9852
  return;
9679
9853
  this.updateAppearance();
9680
9854
  }
@@ -9691,19 +9865,41 @@ class ArkShapePicker extends HTMLElementBase {
9691
9865
  this.removeAttribute("value");
9692
9866
  }
9693
9867
  }
9868
+ /** Formas oferecidas, na ordem (atributo `shapes`, separado por vírgula, ou "all"); sem nenhuma válida, as dez. */
9869
+ get shapes() {
9870
+ const raw = (this.getAttribute("shapes") || "").trim().toLowerCase();
9871
+ if (raw === "all")
9872
+ return [...ARK_MARK_SHAPES];
9873
+ const list = [];
9874
+ for (const token of raw.split(",")) {
9875
+ const shape = token.trim();
9876
+ if (ARK_MARK_SHAPES.includes(shape) && !list.includes(shape))
9877
+ list.push(shape);
9878
+ }
9879
+ return list.length > 0 ? list : [...ARK_MARK_SHAPES];
9880
+ }
9881
+ set shapes(value) {
9882
+ const list = Array.isArray(value) ? value.join(",") : value || "";
9883
+ if (list) {
9884
+ this.setAttribute("shapes", list);
9885
+ }
9886
+ else {
9887
+ this.removeAttribute("shapes");
9888
+ }
9889
+ }
9694
9890
  get disabled() {
9695
9891
  return this.hasAttribute("disabled");
9696
9892
  }
9697
9893
  set disabled(value) {
9698
9894
  this.toggleAttribute("disabled", core.coerceBooleanAttr(value));
9699
9895
  }
9700
- /** Seleciona uma forma como o usuário faria: muda `value`, foca a opção e emite `change`. */
9896
+ /** Seleciona uma forma oferecida como o usuário faria: muda `value`, foca a opção e emite `change`. */
9701
9897
  select(value) {
9702
9898
  const shape = normalizeMarkShape(value);
9703
- if (this.disabled || shape === this.value)
9899
+ if (this.disabled || shape === this.value || !this.shapes.includes(shape))
9704
9900
  return;
9705
9901
  this.setAttribute("value", shape);
9706
- this.options[ARK_MARK_SHAPES.indexOf(shape)]?.focus();
9902
+ this.options[this.offered.indexOf(shape)]?.focus();
9707
9903
  this.dispatchEvent(new CustomEvent("change", { detail: { value: shape }, bubbles: true, composed: true }));
9708
9904
  }
9709
9905
  getLocale() {
@@ -9720,8 +9916,15 @@ class ArkShapePicker extends HTMLElementBase {
9720
9916
  };
9721
9917
  return sizes[size] ?? sizes.md;
9722
9918
  }
9723
- render() {
9724
- this.options = ARK_MARK_SHAPES.map((shape) => {
9919
+ // Recria as opções só quando a lista oferecida muda (atributo `shapes`); cada botão sabe a própria forma.
9920
+ syncOptions() {
9921
+ const shapes = this.shapes;
9922
+ if (shapes.join(",") === this.offered.join(","))
9923
+ return;
9924
+ for (const option of this.options)
9925
+ option.remove();
9926
+ this.offered = shapes;
9927
+ this.options = shapes.map((shape) => {
9725
9928
  const button = document.createElement("button");
9726
9929
  button.type = "button";
9727
9930
  button.setAttribute("role", "radio");
@@ -9753,6 +9956,7 @@ class ArkShapePicker extends HTMLElementBase {
9753
9956
  const disabled = this.disabled;
9754
9957
  const sizing = this.getSizing();
9755
9958
  const color = this.getAttribute("color")?.trim() || "";
9959
+ this.syncOptions();
9756
9960
  this.setAttribute("role", "radiogroup");
9757
9961
  // Só quando muda: aria-label é observado e um set igual reentraria aqui.
9758
9962
  const label = this.getAttribute("label");
@@ -9768,10 +9972,10 @@ class ArkShapePicker extends HTMLElementBase {
9768
9972
  .join(" ")
9769
9973
  .split(" ")
9770
9974
  .filter(Boolean));
9771
- const selectedIndex = value ? ARK_MARK_SHAPES.indexOf(value) : -1;
9975
+ const selectedIndex = value ? this.offered.indexOf(value) : -1;
9772
9976
  const stop = selectedIndex >= 0 ? selectedIndex : 0;
9773
9977
  this.options.forEach((option, index) => {
9774
- const shape = ARK_MARK_SHAPES[index];
9978
+ const shape = this.offered[index];
9775
9979
  const selected = index === selectedIndex;
9776
9980
  option.setAttribute("aria-label", String(locale[SHAPE_LABEL[shape]]));
9777
9981
  option.setAttribute("aria-checked", selected ? "true" : "false");
@@ -9837,6 +10041,7 @@ class ArkSkeleton extends HTMLElementBase {
9837
10041
  return ["rows", "animated", "rounded", "color", "ratio", "theme", "class", "testid"];
9838
10042
  }
9839
10043
  connectedCallback() {
10044
+ upgradeProperties(this);
9840
10045
  this.updateAppearance();
9841
10046
  }
9842
10047
  attributeChangedCallback(name) {
@@ -9988,6 +10193,7 @@ class ArkSpinner extends HTMLElementBase {
9988
10193
  return ["size", "intent", "label", "lang", "locale-json", "theme", "class", "testid"];
9989
10194
  }
9990
10195
  connectedCallback() {
10196
+ upgradeProperties(this);
9991
10197
  if (!this.iconEl)
9992
10198
  this.render();
9993
10199
  this.updateAppearance();
@@ -10163,6 +10369,7 @@ class ArkSplitPane extends HTMLElementBase {
10163
10369
  return ["direction", "sizes", "lang", "locale-json", "theme", "class", "testid"];
10164
10370
  }
10165
10371
  connectedCallback() {
10372
+ upgradeProperties(this);
10166
10373
  if (!this.observer) {
10167
10374
  // Painéis que entram ou saem mudam o número de alças e a distribuição.
10168
10375
  this.observer = new MutationObserver(() => this.updateAppearance());
@@ -10393,6 +10600,7 @@ class ArkStatusDot extends HTMLElementBase {
10393
10600
  return ["intent", "label", "size", "theme", "class", "testid"];
10394
10601
  }
10395
10602
  connectedCallback() {
10603
+ upgradeProperties(this);
10396
10604
  this.updateAppearance();
10397
10605
  }
10398
10606
  attributeChangedCallback(name) {
@@ -10503,6 +10711,7 @@ class ArkSwitch extends HTMLElementBase {
10503
10711
  ];
10504
10712
  }
10505
10713
  connectedCallback() {
10714
+ upgradeProperties(this);
10506
10715
  if (!this.trackEl) {
10507
10716
  this.render();
10508
10717
  }
@@ -10844,6 +11053,7 @@ class ArkTab extends HTMLElementBase {
10844
11053
  this.addEventListener("keydown", this.handleKeydown);
10845
11054
  }
10846
11055
  connectedCallback() {
11056
+ upgradeProperties(this);
10847
11057
  this.updateAppearance();
10848
11058
  }
10849
11059
  attributeChangedCallback(name) {
@@ -11204,6 +11414,7 @@ class ArkTabs extends HTMLElementBase {
11204
11414
  this.addEventListener("keydown", this.handleKeydown);
11205
11415
  }
11206
11416
  connectedCallback() {
11417
+ upgradeProperties(this);
11207
11418
  if (!this.observer) {
11208
11419
  this.observer = new MutationObserver(() => this.syncTabs());
11209
11420
  this.observer.observe(this, { childList: true, subtree: true });
@@ -11405,6 +11616,7 @@ class ArkTextarea extends HTMLElementBase {
11405
11616
  ];
11406
11617
  }
11407
11618
  connectedCallback() {
11619
+ upgradeProperties(this);
11408
11620
  if (!this.textareaEl) {
11409
11621
  this.render();
11410
11622
  }
@@ -11602,6 +11814,7 @@ class ArkToaster extends HTMLElementBase {
11602
11814
  return ["theme", "position", "rich-colors", "close-button", "max-visible", "duration", "lang", "testid"];
11603
11815
  }
11604
11816
  connectedCallback() {
11817
+ upgradeProperties(this);
11605
11818
  this.build();
11606
11819
  window.addEventListener("ark-toast", this.handleToast);
11607
11820
  window.addEventListener("ark-toast-dismiss", this.handleDismiss);
@@ -11995,6 +12208,7 @@ class ArkToggle extends HTMLElementBase {
11995
12208
  this.addEventListener("keyup", this.handleKeyup);
11996
12209
  }
11997
12210
  connectedCallback() {
12211
+ upgradeProperties(this);
11998
12212
  this.updateAppearance();
11999
12213
  }
12000
12214
  attributeChangedCallback(name) {
@@ -12200,6 +12414,7 @@ class ArkToggleGroup extends HTMLElementBase {
12200
12414
  this.addEventListener("change", this.handleToggleChange);
12201
12415
  }
12202
12416
  connectedCallback() {
12417
+ upgradeProperties(this);
12203
12418
  if (!this.observer) {
12204
12419
  this.observer = new MutationObserver(() => this.syncToggles());
12205
12420
  this.observer.observe(this, { childList: true, subtree: true });
@@ -12398,6 +12613,7 @@ class ArkTooltip extends HTMLElementBase {
12398
12613
  this.addEventListener("focusout", this.handleFocusOut);
12399
12614
  }
12400
12615
  connectedCallback() {
12616
+ upgradeProperties(this);
12401
12617
  if (!this.observer) {
12402
12618
  this.observer = new MutationObserver(() => this.updateAppearance());
12403
12619
  this.observer.observe(this, { childList: true });
@@ -12426,7 +12642,8 @@ class ArkTooltip extends HTMLElementBase {
12426
12642
  if (!this.isConnected)
12427
12643
  return;
12428
12644
  if (name === "open") {
12429
- if (this.syncingOpen)
12645
+ // Sem o observer o connectedCallback ainda não rodou (upgrade de uma tag já no DOM): quem abre é ele.
12646
+ if (this.syncingOpen || !this.observer)
12430
12647
  return;
12431
12648
  if (this.hasAttribute("open")) {
12432
12649
  this.show();
@@ -12446,8 +12663,9 @@ class ArkTooltip extends HTMLElementBase {
12446
12663
  }
12447
12664
  set open(value) {
12448
12665
  const next = core.coerceBooleanAttr(value);
12449
- // Desconectado (React 19 e Vue gravam a prop antes de inserir o nó): só reflete; o connectedCallback abre.
12450
- if (!this.isConnected) {
12666
+ // Antes do connectedCallback (React 19 e Vue gravam a prop antes de inserir o nó; o upgrade de uma tag já no DOM
12667
+ // a reaplica ao conectar): só reflete, e o connectedCallback abre.
12668
+ if (!this.isConnected || !this.observer) {
12451
12669
  this.toggleAttribute("open", next);
12452
12670
  return;
12453
12671
  }