@tooark/web-components 1.4.0 → 1.6.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 +3 -3
- package/README.pt-BR.md +3 -3
- package/dist/index.cjs +198 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +198 -21
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ Declare the page's `color-scheme` to pick the theme (`light`, `dark` or `light d
|
|
|
88
88
|
- `ark-dialog` — Modal dialog on the Popover API (top layer, `::backdrop` scrim, no portal): the host is the panel, your children are the body, `slot="footer"` is the footer; header from `label`, focus trap, Esc/scrim, `sm`–`xl` or `full`.
|
|
89
89
|
- `ark-drawer` — Drawer anchored to an edge: `overlay` (Popover API, scrim, focus trap, Esc) or `inline` (in the page flow, e.g. a bottom console); `side`, `size` preset or CSS length, header from `label` with a `slot="actions"` row, `slot="footer"`, slide with the `sheet` easing. Emits `ark-open`/`ark-close`.
|
|
90
90
|
- `ark-empty` — Empty state: dashed box with a dimmed `slot="icon"`, `heading` (h3), `description` and an optional `slot="action"` button; children stay in place, ordered by CSS.
|
|
91
|
-
- `ark-file-input` — File field with the `ark-input` grid (label, helper/error): hidden native `<input type="file">` for forms, drop zone with `dragover` highlight, keyboard-accessible choose button, list of selected names, `accept`/`multiple
|
|
91
|
+
- `ark-file-input` — File field with the `ark-input` grid (label, helper/error): hidden native `<input type="file">` for forms, drop zone with `dragover` highlight, keyboard-accessible choose button, list of selected names, `accept`/`multiple`, `directory` for a whole folder. Emits `change` with the files and announces them.
|
|
92
92
|
- `ark-input` — Standardized text field: label, helper/error with aria, prefix/suffix via `slot`, password `reveal`, native attributes passed through, sizes, intents, `rounded`.
|
|
93
93
|
- `ark-kbd` — Keyboard key: the host is the key (mono, border, `surface-muted`, bottom edge) around your text; `size`.
|
|
94
94
|
- `ark-kv-editor` — Key/value editor: rows `{ id, key, value, enabled }` (JS property) to enable, edit, delete and add, optional `types`/`secret`/`description` columns, bulk mode as `key:value` lines or JSON, opt-in `valueField` for a value cell of your own. Composes other ark-\* controls. Emits `change`, `ark-add`, `ark-delete`.
|
|
@@ -186,8 +186,8 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
|
|
|
186
186
|
|
|
187
187
|
| Package | Version | Description |
|
|
188
188
|
| ---------------------------------------------------------------- | ------- | ---------------------------------------------------------------- |
|
|
189
|
-
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.
|
|
190
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.
|
|
189
|
+
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.0 | Types, i18n, toast/announce services, motion and overlay helpers |
|
|
190
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.0 | Design tokens (colors, sizes, motion) and primitive types |
|
|
191
191
|
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
|
|
192
192
|
|
|
193
193
|
---
|
package/README.pt-BR.md
CHANGED
|
@@ -88,7 +88,7 @@ Declare o `color-scheme` da página para escolher o tema (`light`, `dark` ou `li
|
|
|
88
88
|
- `ark-dialog` — Diálogo modal sobre a Popover API (top layer, scrim por `::backdrop`, sem portal): o host é o painel, seus filhos são o corpo, `slot="footer"` é o rodapé; cabeçalho de `label`, focus trap, Esc/scrim, `sm`–`xl` ou `full`.
|
|
89
89
|
- `ark-drawer` — Gaveta ancorada numa borda: `overlay` (Popover API, scrim, focus trap, Esc) ou `inline` (no fluxo da página, ex.: console inferior); `side`, `size` preset ou comprimento CSS, cabeçalho de `label` com a linha `slot="actions"`, `slot="footer"`, slide com o easing `sheet`. Emite `ark-open`/`ark-close`.
|
|
90
90
|
- `ark-empty` — Estado vazio: caixa tracejada com `slot="icon"` apagado, `heading` (h3), `description` e um botão opcional em `slot="action"`; os filhos ficam no lugar, ordenados por CSS.
|
|
91
|
-
- `ark-file-input` — Campo de arquivo com a grid do `ark-input` (label, helper/erro): `<input type="file">` nativo oculto para o formulário, zona de soltar com realce em `dragover`, botão de escolher acessível por teclado, lista dos nomes escolhidos, `accept`/`multiple
|
|
91
|
+
- `ark-file-input` — Campo de arquivo com a grid do `ark-input` (label, helper/erro): `<input type="file">` nativo oculto para o formulário, zona de soltar com realce em `dragover`, botão de escolher acessível por teclado, lista dos nomes escolhidos, `accept`/`multiple`, `directory` para uma pasta inteira. Emite `change` com os arquivos e os anuncia.
|
|
92
92
|
- `ark-input` — Campo de texto padronizado: label, helper/erro com aria, prefixo/sufixo via `slot`, `reveal` de senha, atributos nativos repassados, tamanhos, intents, `rounded`.
|
|
93
93
|
- `ark-kbd` — Tecla de atalho: o host é a tecla (mono, borda, `surface-muted`, aresta inferior) em volta do seu texto; `size`.
|
|
94
94
|
- `ark-kv-editor` — Editor chave/valor: linhas `{ id, key, value, enabled }` (propriedade JS) com ativar, editar, remover, adicionar, colunas opcionais `types`/`secret`/`description`, modo em massa em linhas `chave:valor` ou JSON, `valueField` opcional para uma célula de valor sua. Compõe outros controles ark-\*. Emite `change`, `ark-add`, `ark-delete`.
|
|
@@ -186,8 +186,8 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
|
|
|
186
186
|
|
|
187
187
|
| Pacote | Versão | Descrição |
|
|
188
188
|
| ---------------------------------------------------------------- | ------ | -------------------------------------------------------------------- |
|
|
189
|
-
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.
|
|
190
|
-
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.
|
|
189
|
+
| [`@tooark/core`](https://www.npmjs.com/package/@tooark/core) | ^1.6.0 | Tipos, i18n, serviços de toast/announce, motion e helpers de overlay |
|
|
190
|
+
| [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.6.0 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
|
|
191
191
|
| [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
|
|
192
192
|
|
|
193
193
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -2754,7 +2754,8 @@ class ArkCheckbox extends HTMLElementBase {
|
|
|
2754
2754
|
input.tabIndex = -1;
|
|
2755
2755
|
input.setAttribute("aria-hidden", "true");
|
|
2756
2756
|
input.setAttribute("data-ark-chrome", "input");
|
|
2757
|
-
// No início do host: a caixa antes do rótulo na ordem de leitura; o input oculto não conta.
|
|
2757
|
+
// No início do host: a caixa antes do rótulo na ordem de leitura; o input oculto não conta. A caixa vem antes
|
|
2758
|
+
// do input porque um <label> do app em volta do host rotula o primeiro controle rotulável dentro dele.
|
|
2758
2759
|
this.prepend(box, input);
|
|
2759
2760
|
this.boxEl = box;
|
|
2760
2761
|
this.iconEl = icon;
|
|
@@ -5793,7 +5794,10 @@ const UPLOAD_SVG = `
|
|
|
5793
5794
|
* seletor nativo e soltar arquivos na zona alimenta o mesmo input. Toda
|
|
5794
5795
|
* mudança emite `change` com os arquivos e anuncia os nomes ao leitor de
|
|
5795
5796
|
* tela. O rótulo aponta para o input (associação nativa) e nomeia o botão
|
|
5796
|
-
* junto do próprio texto dele.
|
|
5797
|
+
* junto do próprio texto dele. Com `directory` o campo escolhe uma pasta: o
|
|
5798
|
+
* seletor abre em modo pasta, uma pasta solta é lida até o fim, a lista vira
|
|
5799
|
+
* um resumo e `change` leva também o caminho de cada arquivo. Sem ele, uma
|
|
5800
|
+
* pasta solta é recusada com aviso.
|
|
5797
5801
|
*/
|
|
5798
5802
|
class ArkFileInput extends HTMLElementBase {
|
|
5799
5803
|
constructor() {
|
|
@@ -5807,14 +5811,18 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5807
5811
|
this.messageEl = null;
|
|
5808
5812
|
/** Profundidade de dragenter/dragleave, porque eles disparam também nos filhos da zona. */
|
|
5809
5813
|
this.dragDepth = 0;
|
|
5814
|
+
/** O último drop trouxe uma pasta que o campo não aceita: a lista mostra o aviso até a próxima seleção. */
|
|
5815
|
+
this.folderRejected = false;
|
|
5816
|
+
/** Caminho de cada arquivo vindo de um drop em modo pasta, na ordem de `files`; nulo quando veio do seletor. */
|
|
5817
|
+
this.droppedPaths = null;
|
|
5818
|
+
/** Conta as seleções: a leitura assíncrona de uma pasta solta só é publicada se nada veio depois dela. */
|
|
5819
|
+
this.selectionSeq = 0;
|
|
5810
5820
|
// --- Interação ---
|
|
5811
5821
|
// O change nativo do input oculto não sobe ao host: quem escuta no host recebe só o CustomEvent com detail.
|
|
5812
5822
|
this.handleChange = (event) => {
|
|
5813
|
-
event
|
|
5814
|
-
this.
|
|
5815
|
-
|
|
5816
|
-
core.announce(files.length ? files.map((file) => file.name).join(", ") : this.getLocale().noFile);
|
|
5817
|
-
this.dispatchEvent(new CustomEvent("change", { detail: { files }, bubbles: true, composed: true }));
|
|
5823
|
+
event.stopPropagation();
|
|
5824
|
+
this.resetSelection();
|
|
5825
|
+
this.publish();
|
|
5818
5826
|
};
|
|
5819
5827
|
this.handleDragEnter = (event) => {
|
|
5820
5828
|
if (this.isDisabled())
|
|
@@ -5837,28 +5845,46 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5837
5845
|
if (this.dragDepth === 0)
|
|
5838
5846
|
this.setDragover(false);
|
|
5839
5847
|
};
|
|
5840
|
-
// Soltar alimenta o mesmo input (FileList é atribuível): só o primeiro arquivo sem `multiple`.
|
|
5848
|
+
// Soltar alimenta o mesmo input (FileList é atribuível): só o primeiro arquivo sem `multiple`. Uma pasta não é um
|
|
5849
|
+
// arquivo (o navegador a entrega como um File vazio, que não dá para ler): sem `directory` fica de fora, com aviso
|
|
5850
|
+
// na lista e anúncio; com ele é lida até o fim.
|
|
5841
5851
|
this.handleDrop = (event) => {
|
|
5842
5852
|
if (this.isDisabled())
|
|
5843
5853
|
return;
|
|
5844
5854
|
event.preventDefault();
|
|
5845
5855
|
this.dragDepth = 0;
|
|
5846
5856
|
this.setDragover(false);
|
|
5847
|
-
|
|
5848
|
-
|
|
5857
|
+
if (!event.dataTransfer || !this.inputEl)
|
|
5858
|
+
return;
|
|
5859
|
+
const { files, folders } = ArkFileInput.readDrop(event.dataTransfer);
|
|
5860
|
+
if (files.length === 0 && folders.length === 0)
|
|
5861
|
+
return;
|
|
5862
|
+
if (this.directory) {
|
|
5863
|
+
void this.selectDropped(files, folders);
|
|
5849
5864
|
return;
|
|
5865
|
+
}
|
|
5866
|
+
if (files.length === 0) {
|
|
5867
|
+
// Só pastas: a seleção fica como estava e não há `change`.
|
|
5868
|
+
this.folderRejected = true;
|
|
5869
|
+
this.syncList();
|
|
5870
|
+
core.announce(this.getLocale().foldersNotAccepted);
|
|
5871
|
+
return;
|
|
5872
|
+
}
|
|
5873
|
+
this.resetSelection();
|
|
5874
|
+
this.folderRejected = folders.length > 0;
|
|
5850
5875
|
const transfer = new DataTransfer();
|
|
5851
|
-
const count = this.multiple ?
|
|
5876
|
+
const count = this.multiple ? files.length : 1;
|
|
5852
5877
|
for (let index = 0; index < count; index += 1)
|
|
5853
|
-
transfer.items.add(
|
|
5878
|
+
transfer.items.add(files[index]);
|
|
5854
5879
|
this.inputEl.files = transfer.files;
|
|
5855
|
-
this.
|
|
5880
|
+
this.publish();
|
|
5856
5881
|
};
|
|
5857
5882
|
}
|
|
5858
5883
|
static get observedAttributes() {
|
|
5859
5884
|
return [
|
|
5860
5885
|
"accept",
|
|
5861
5886
|
"multiple",
|
|
5887
|
+
"directory",
|
|
5862
5888
|
"label",
|
|
5863
5889
|
"helper",
|
|
5864
5890
|
"error",
|
|
@@ -5894,6 +5920,21 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5894
5920
|
get files() {
|
|
5895
5921
|
return Array.from(this.inputEl?.files ?? []);
|
|
5896
5922
|
}
|
|
5923
|
+
/**
|
|
5924
|
+
* Caminho de cada arquivo de `files`, na mesma ordem, a partir da pasta escolhida ou solta (`pasta/sub/a.txt`);
|
|
5925
|
+
* o nome do arquivo quando ele não veio de uma pasta.
|
|
5926
|
+
*/
|
|
5927
|
+
get paths() {
|
|
5928
|
+
const dropped = this.droppedPaths;
|
|
5929
|
+
return this.files.map((file, index) => dropped?.[index] ?? (file.webkitRelativePath || file.name));
|
|
5930
|
+
}
|
|
5931
|
+
/** Escolhe uma pasta inteira: o seletor abre em modo pasta e a zona lê as pastas soltas. Padrão: desligado. */
|
|
5932
|
+
get directory() {
|
|
5933
|
+
return this.hasAttribute("directory");
|
|
5934
|
+
}
|
|
5935
|
+
set directory(value) {
|
|
5936
|
+
this.toggleAttribute("directory", core.coerceBooleanAttr(value));
|
|
5937
|
+
}
|
|
5897
5938
|
get multiple() {
|
|
5898
5939
|
return this.hasAttribute("multiple");
|
|
5899
5940
|
}
|
|
@@ -5911,6 +5952,7 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5911
5952
|
if (!this.inputEl)
|
|
5912
5953
|
return;
|
|
5913
5954
|
this.inputEl.value = "";
|
|
5955
|
+
this.resetSelection();
|
|
5914
5956
|
this.syncList();
|
|
5915
5957
|
}
|
|
5916
5958
|
focus(options) {
|
|
@@ -5923,6 +5965,106 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
5923
5965
|
isDisabled() {
|
|
5924
5966
|
return this.buttonEl ? this.buttonEl.matches(":disabled") : this.disabled;
|
|
5925
5967
|
}
|
|
5968
|
+
// Uma seleção nova (seletor, drop ou clear) descarta o aviso, os caminhos do drop anterior e a leitura em curso.
|
|
5969
|
+
resetSelection() {
|
|
5970
|
+
this.folderRejected = false;
|
|
5971
|
+
this.droppedPaths = null;
|
|
5972
|
+
this.selectionSeq += 1;
|
|
5973
|
+
}
|
|
5974
|
+
// Lista, anúncio e `change` da seleção atual do input. Em modo pasta o anúncio é o resumo e `detail` leva os
|
|
5975
|
+
// caminhos; fora dele o detail é só `{ files }`, como sempre foi.
|
|
5976
|
+
publish() {
|
|
5977
|
+
this.syncList();
|
|
5978
|
+
const files = this.files;
|
|
5979
|
+
const locale = this.getLocale();
|
|
5980
|
+
if (this.directory) {
|
|
5981
|
+
const summary = this.summarize(locale);
|
|
5982
|
+
core.announce(files.length ? [summary.folder, summary.count].filter(Boolean).join(", ") : locale.noFolder);
|
|
5983
|
+
const detail = { files, paths: this.paths };
|
|
5984
|
+
this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
|
|
5985
|
+
return;
|
|
5986
|
+
}
|
|
5987
|
+
const selection = files.length ? files.map((file) => file.name).join(", ") : locale.noFile;
|
|
5988
|
+
core.announce(this.folderRejected ? `${selection}. ${locale.foldersNotAccepted}` : selection);
|
|
5989
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { files }, bubbles: true, composed: true }));
|
|
5990
|
+
}
|
|
5991
|
+
// Resumo da seleção em modo pasta: o nome da pasta, quando todos os caminhos saem da mesma, a contagem e o tamanho.
|
|
5992
|
+
summarize(locale) {
|
|
5993
|
+
const files = this.files;
|
|
5994
|
+
const roots = new Set(this.paths.map((path) => (path.includes("/") ? path.slice(0, path.indexOf("/")) : "")));
|
|
5995
|
+
const [root = ""] = roots;
|
|
5996
|
+
return {
|
|
5997
|
+
folder: roots.size === 1 ? root : "",
|
|
5998
|
+
count: locale.fileCount.replace("{count}", String(files.length)),
|
|
5999
|
+
size: files.reduce((total, file) => total + file.size, 0)
|
|
6000
|
+
};
|
|
6001
|
+
}
|
|
6002
|
+
// Separa arquivos e pastas de um drop. A pasta só se distingue pela entrada (webkitGetAsEntry), que existe só
|
|
6003
|
+
// durante o evento; sem a API, ou num DataTransfer montado por código, tudo é arquivo.
|
|
6004
|
+
static readDrop(transfer) {
|
|
6005
|
+
const files = [];
|
|
6006
|
+
const folders = [];
|
|
6007
|
+
const items = Array.from(transfer.items ?? []);
|
|
6008
|
+
if (items.length === 0)
|
|
6009
|
+
return { files: Array.from(transfer.files ?? []), folders };
|
|
6010
|
+
for (const item of items) {
|
|
6011
|
+
if (item.kind !== "file")
|
|
6012
|
+
continue;
|
|
6013
|
+
const entry = typeof item.webkitGetAsEntry === "function" ? item.webkitGetAsEntry() : null;
|
|
6014
|
+
if (entry?.isDirectory) {
|
|
6015
|
+
folders.push(entry);
|
|
6016
|
+
continue;
|
|
6017
|
+
}
|
|
6018
|
+
const file = item.getAsFile();
|
|
6019
|
+
if (file)
|
|
6020
|
+
files.push(file);
|
|
6021
|
+
}
|
|
6022
|
+
return { files, folders };
|
|
6023
|
+
}
|
|
6024
|
+
// Lê uma pasta solta até o fim, descendo nas subpastas. readEntries devolve lotes (100 no Chromium), então é
|
|
6025
|
+
// chamado até vir vazio; uma entrada que falha ao ler fica de fora sem derrubar o resto.
|
|
6026
|
+
static async readFolder(folder, prefix, found) {
|
|
6027
|
+
const reader = folder.createReader();
|
|
6028
|
+
for (;;) {
|
|
6029
|
+
const batch = await new Promise((resolve) => {
|
|
6030
|
+
reader.readEntries(resolve, () => resolve([]));
|
|
6031
|
+
});
|
|
6032
|
+
if (batch.length === 0)
|
|
6033
|
+
return;
|
|
6034
|
+
for (const entry of batch) {
|
|
6035
|
+
const path = `${prefix}${entry.name}`;
|
|
6036
|
+
if (entry.isDirectory) {
|
|
6037
|
+
await ArkFileInput.readFolder(entry, `${path}/`, found);
|
|
6038
|
+
}
|
|
6039
|
+
else if (entry.isFile) {
|
|
6040
|
+
const file = await new Promise((resolve) => {
|
|
6041
|
+
entry.file(resolve, () => resolve(null));
|
|
6042
|
+
});
|
|
6043
|
+
if (file)
|
|
6044
|
+
found.push({ file, path });
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6049
|
+
// Drop em modo pasta: as pastas são lidas até o fim e tudo vai para o input, cada arquivo de pasta com o caminho a
|
|
6050
|
+
// partir do nome dela (como o webkitRelativePath do seletor) e os arquivos soltos junto com o próprio nome.
|
|
6051
|
+
async selectDropped(files, folders) {
|
|
6052
|
+
this.resetSelection();
|
|
6053
|
+
const seq = this.selectionSeq;
|
|
6054
|
+
const found = files.map((file) => ({ file, path: file.name }));
|
|
6055
|
+
for (const folder of folders)
|
|
6056
|
+
await ArkFileInput.readFolder(folder, `${folder.name}/`, found);
|
|
6057
|
+
// Outra seleção chegou enquanto a pasta era lida: esta não vale mais.
|
|
6058
|
+
if (seq !== this.selectionSeq || !this.inputEl)
|
|
6059
|
+
return;
|
|
6060
|
+
found.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
6061
|
+
const transfer = new DataTransfer();
|
|
6062
|
+
for (const entry of found)
|
|
6063
|
+
transfer.items.add(entry.file);
|
|
6064
|
+
this.inputEl.files = transfer.files;
|
|
6065
|
+
this.droppedPaths = found.map((entry) => entry.path);
|
|
6066
|
+
this.publish();
|
|
6067
|
+
}
|
|
5926
6068
|
setDragover(active) {
|
|
5927
6069
|
if (this.hasAttribute("data-ark-dragover") === active)
|
|
5928
6070
|
return;
|
|
@@ -6053,21 +6195,43 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
6053
6195
|
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
6054
6196
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
6055
6197
|
}
|
|
6056
|
-
// Lista dos nomes (com o tamanho) ou a string noFile.
|
|
6198
|
+
// Lista dos nomes (com o tamanho) ou a string noFile; por último, o aviso da pasta recusada. Em modo pasta a
|
|
6199
|
+
// seleção pode ter centenas de arquivos, então a lista é uma linha só: a pasta, a contagem e o tamanho total.
|
|
6057
6200
|
syncList() {
|
|
6058
6201
|
if (!this.listEl)
|
|
6059
6202
|
return;
|
|
6060
6203
|
const files = this.files;
|
|
6204
|
+
const locale = this.getLocale();
|
|
6205
|
+
const directory = this.directory;
|
|
6061
6206
|
const text = this.getSizing().text;
|
|
6062
6207
|
this.listEl.textContent = "";
|
|
6208
|
+
// max-w-full: centrada na zona, a lista teria a largura do nome mais longo e o truncate dos itens nunca cortaria.
|
|
6063
6209
|
this.listEl.className = [
|
|
6064
|
-
"ark:m-0 ark:flex ark:list-none ark:flex-col ark:items-center ark:gap-0.5 ark:p-0",
|
|
6210
|
+
"ark:m-0 ark:flex ark:max-w-full ark:list-none ark:flex-col ark:items-center ark:gap-0.5 ark:p-0",
|
|
6065
6211
|
text
|
|
6066
6212
|
].join(" ");
|
|
6067
6213
|
if (files.length === 0) {
|
|
6068
6214
|
const item = document.createElement("li");
|
|
6069
6215
|
item.className = "ark:text-fg-muted";
|
|
6070
|
-
item.textContent =
|
|
6216
|
+
item.textContent = directory ? locale.noFolder : locale.noFile;
|
|
6217
|
+
this.listEl.appendChild(item);
|
|
6218
|
+
}
|
|
6219
|
+
else if (directory) {
|
|
6220
|
+
const summary = this.summarize(locale);
|
|
6221
|
+
const item = document.createElement("li");
|
|
6222
|
+
item.setAttribute("data-ark-chrome", "summary");
|
|
6223
|
+
item.className = "ark:inline-flex ark:max-w-full ark:items-baseline ark:gap-1.5 ark:text-fg";
|
|
6224
|
+
if (summary.folder) {
|
|
6225
|
+
const name = document.createElement("span");
|
|
6226
|
+
name.className = "ark:truncate";
|
|
6227
|
+
name.textContent = summary.folder;
|
|
6228
|
+
item.appendChild(name);
|
|
6229
|
+
}
|
|
6230
|
+
const total = document.createElement("span");
|
|
6231
|
+
total.className = summary.folder ? "ark:shrink-0 ark:text-xs ark:text-fg-muted" : "ark:shrink-0";
|
|
6232
|
+
total.textContent = `${summary.count} · ${ArkFileInput.formatSize(summary.size)}`;
|
|
6233
|
+
item.appendChild(total);
|
|
6234
|
+
applyTestHooks(this, "file-input", item, "summary");
|
|
6071
6235
|
this.listEl.appendChild(item);
|
|
6072
6236
|
return;
|
|
6073
6237
|
}
|
|
@@ -6085,6 +6249,13 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
6085
6249
|
applyTestHooks(this, "file-input", item, "item");
|
|
6086
6250
|
this.listEl.appendChild(item);
|
|
6087
6251
|
}
|
|
6252
|
+
if (this.folderRejected) {
|
|
6253
|
+
const item = document.createElement("li");
|
|
6254
|
+
item.className = "ark:text-danger-soft-fg";
|
|
6255
|
+
item.textContent = locale.foldersNotAccepted;
|
|
6256
|
+
applyTestHooks(this, "file-input", item, "rejected");
|
|
6257
|
+
this.listEl.appendChild(item);
|
|
6258
|
+
}
|
|
6088
6259
|
}
|
|
6089
6260
|
updateAppearance() {
|
|
6090
6261
|
if (!this.inputEl ||
|
|
@@ -6101,10 +6272,14 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
6101
6272
|
const palette = this.getPalette(intent);
|
|
6102
6273
|
const sizing = this.getSizing();
|
|
6103
6274
|
const disabled = this.disabled;
|
|
6275
|
+
const directory = this.directory;
|
|
6104
6276
|
const error = this.hasAttribute("error") || this.hasAttribute("error-message");
|
|
6105
6277
|
const dragover = this.hasAttribute("data-ark-dragover");
|
|
6106
6278
|
this.inputEl.name = this.getAttribute("name") || "";
|
|
6107
|
-
|
|
6279
|
+
// Com `directory` o seletor abre em modo pasta. Onde o navegador não tem esse modo (mobile mais antigo) o atributo
|
|
6280
|
+
// não faz nada e sobra o seletor de arquivos: `multiple` deixa escolher os arquivos da pasta de uma vez.
|
|
6281
|
+
this.inputEl.multiple = this.multiple || directory;
|
|
6282
|
+
this.inputEl.toggleAttribute("webkitdirectory", directory);
|
|
6108
6283
|
this.inputEl.required = this.hasAttribute("required");
|
|
6109
6284
|
this.inputEl.disabled = disabled;
|
|
6110
6285
|
const accept = this.getAttribute("accept");
|
|
@@ -6144,13 +6319,14 @@ class ArkFileInput extends HTMLElementBase {
|
|
|
6144
6319
|
palette.ring
|
|
6145
6320
|
].join(" ");
|
|
6146
6321
|
this.buttonEl.disabled = disabled;
|
|
6147
|
-
|
|
6322
|
+
const choose = directory ? locale.chooseFolder : locale.chooseFile;
|
|
6323
|
+
if (this.buttonEl.getAttribute("data-ark-label") !== choose) {
|
|
6148
6324
|
this.buttonEl.innerHTML = `${UPLOAD_SVG}<span></span>`;
|
|
6149
|
-
this.buttonEl.lastElementChild.textContent =
|
|
6150
|
-
this.buttonEl.setAttribute("data-ark-label",
|
|
6325
|
+
this.buttonEl.lastElementChild.textContent = choose;
|
|
6326
|
+
this.buttonEl.setAttribute("data-ark-label", choose);
|
|
6151
6327
|
}
|
|
6152
6328
|
this.hintEl.className = ["ark:text-fg-muted", sizing.text].join(" ");
|
|
6153
|
-
this.hintEl.textContent = locale.dropHint;
|
|
6329
|
+
this.hintEl.textContent = directory ? locale.dropFolderHint : locale.dropHint;
|
|
6154
6330
|
this.syncList();
|
|
6155
6331
|
// Label: associação nativa com o input; o botão é nomeado pelo rótulo mais o próprio texto.
|
|
6156
6332
|
const labelText = this.getAttribute("label") || "";
|
|
@@ -8610,6 +8786,7 @@ class ArkRadio extends HTMLElementBase {
|
|
|
8610
8786
|
input.tabIndex = -1;
|
|
8611
8787
|
input.setAttribute("aria-hidden", "true");
|
|
8612
8788
|
input.setAttribute("data-ark-chrome", "input");
|
|
8789
|
+
// A opção vem antes do input: um <label> do app em volta do host rotula o primeiro controle rotulável.
|
|
8613
8790
|
this.prepend(box, input);
|
|
8614
8791
|
this.boxEl = box;
|
|
8615
8792
|
this.dotEl = dot;
|