@efds-ui/behavior 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +192 -2
- package/dist/balloon-entry.d.ts +8 -0
- package/dist/balloon-entry.js +1 -0
- package/dist/cep-DWPro2E9.js +154 -0
- package/dist/components/accordion.d.ts +7 -0
- package/dist/components/agenda.d.ts +28 -0
- package/dist/components/alert.d.ts +8 -0
- package/dist/components/avatar.d.ts +15 -0
- package/dist/components/banner.d.ts +10 -0
- package/dist/components/button-busy.d.ts +8 -0
- package/dist/components/cep.d.ts +17 -0
- package/dist/components/combobox.d.ts +13 -0
- package/dist/components/command.d.ts +28 -0
- package/dist/components/conditional.d.ts +19 -0
- package/dist/components/confirm.d.ts +9 -0
- package/dist/components/copy.d.ts +11 -0
- package/dist/components/cropper.d.ts +14 -0
- package/dist/components/datepicker.d.ts +6 -0
- package/dist/components/dialogs.d.ts +35 -0
- package/dist/components/dirty-guard.d.ts +15 -0
- package/dist/components/dropdown.d.ts +9 -0
- package/dist/components/filter-bar.d.ts +24 -0
- package/dist/components/format.d.ts +12 -0
- package/dist/components/gallery.d.ts +11 -0
- package/dist/components/image-shared.d.ts +11 -0
- package/dist/components/image.d.ts +13 -0
- package/dist/components/loader.d.ts +69 -0
- package/dist/components/lookup.d.ts +18 -0
- package/dist/components/mask.d.ts +18 -0
- package/dist/components/modal.d.ts +16 -0
- package/dist/components/notifications.d.ts +16 -0
- package/dist/components/number.d.ts +14 -0
- package/dist/components/otp.d.ts +13 -0
- package/dist/components/page-messages.d.ts +39 -0
- package/dist/components/password.d.ts +11 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/select-readonly.d.ts +8 -0
- package/dist/components/session.d.ts +48 -0
- package/dist/components/sidebar.d.ts +10 -0
- package/dist/components/sortable.d.ts +3 -0
- package/dist/components/status-region.d.ts +1 -0
- package/dist/components/table-export.d.ts +21 -0
- package/dist/components/table-filter.d.ts +9 -0
- package/dist/components/table.d.ts +13 -0
- package/dist/components/tabs.d.ts +8 -0
- package/dist/components/theme-color.d.ts +10 -0
- package/dist/components/timepicker.d.ts +15 -0
- package/dist/components/toast.d.ts +30 -0
- package/dist/components/tooltip.d.ts +13 -0
- package/dist/components/tree.d.ts +12 -0
- package/dist/components/upload.d.ts +10 -0
- package/dist/components/wizard.d.ts +15 -0
- package/dist/config-DFz_FB2q.js +310 -0
- package/dist/core/cep.d.ts +36 -0
- package/dist/core/config.d.ts +303 -0
- package/dist/core/data.d.ts +22 -0
- package/dist/core/date.d.ts +46 -0
- package/dist/core/dom.d.ts +28 -0
- package/dist/core/drag.d.ts +66 -0
- package/dist/core/error-slot.d.ts +14 -0
- package/dist/core/fields.d.ts +53 -0
- package/dist/core/format.d.ts +53 -0
- package/dist/core/mask.d.ts +70 -0
- package/dist/core/position.d.ts +55 -0
- package/dist/core/registry.d.ts +14 -0
- package/dist/core/status.d.ts +10 -0
- package/dist/create-theme-BCnL4ZqE.js +205 -0
- package/dist/cropper-controller-BERlfnDt.js +565 -0
- package/dist/csv-BeXMUO2r.js +19 -0
- package/dist/data-C-IJ0iTV.js +52 -0
- package/dist/eds-behavior-core.js +1 -0
- package/dist/eds-behavior.js +7 -0
- package/dist/export/afm.d.ts +12 -0
- package/dist/export/csv.d.ts +13 -0
- package/dist/export/download.d.ts +4 -0
- package/dist/export/formats/csv.d.ts +6 -0
- package/dist/export/formats/csv.js +8 -0
- package/dist/export/formats/json.d.ts +6 -0
- package/dist/export/formats/json.js +8 -0
- package/dist/export/formats/pdf.d.ts +6 -0
- package/dist/export/formats/pdf.js +8 -0
- package/dist/export/formats/xlsx.d.ts +6 -0
- package/dist/export/formats/xlsx.js +8 -0
- package/dist/export/index.d.ts +16 -0
- package/dist/export/json.d.ts +7 -0
- package/dist/export/model.d.ts +76 -0
- package/dist/export/pdf.d.ts +3 -0
- package/dist/export/types.d.ts +32 -0
- package/dist/export/xlsx.d.ts +23 -0
- package/dist/export/zip.d.ts +9 -0
- package/dist/export-C7NzFSaG.js +20 -0
- package/dist/export-entry.d.ts +10 -0
- package/dist/export-entry.js +8 -0
- package/dist/fields-entry.d.ts +9 -0
- package/dist/fields-entry.js +1 -0
- package/dist/format-DYcDCukc.js +150 -0
- package/dist/format-entry.d.ts +6 -0
- package/dist/format-entry.js +3 -0
- package/dist/iife-boot.d.ts +3 -0
- package/dist/image/canvas.d.ts +49 -0
- package/dist/image/cropper-controller.d.ts +47 -0
- package/dist/image/gallery-logic.d.ts +20 -0
- package/dist/image/math.d.ts +78 -0
- package/dist/image/srcset.d.ts +48 -0
- package/dist/image-entry.d.ts +14 -0
- package/dist/image-entry.js +1 -0
- package/dist/index-core.d.ts +3 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +6147 -0
- package/dist/init-with.d.ts +8 -0
- package/dist/json-DsaGwmbJ.js +13 -0
- package/dist/mask-BIBbLhPB.js +258 -0
- package/dist/mask-entry.d.ts +6 -0
- package/dist/mask-entry.js +1 -0
- package/dist/model-DBuawlqz.js +191 -0
- package/dist/pdf-BevPZal3.js +1143 -0
- package/dist/setup.d.ts +76 -0
- package/dist/theme/create-theme.d.ts +61 -0
- package/dist/theme-entry.d.ts +6 -0
- package/dist/theme-entry.js +1 -0
- package/dist/tooltip-wRy96rs_.js +326 -0
- package/dist/xlsx-6qfA69o5.js +117 -0
- package/package.json +80 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcelo Pantoja
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,193 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @efds-ui/behavior
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Comportamento interativo do efDS.ui em JavaScript puro (zero dependências), para quem usa só HTML: PHP, Java, .NET, Vue, Angular. O visual vem do `@efds-ui/core` (CSS); este pacote liga o que o CSS e a plataforma não entregam: Tabs, Modal/Drawer, Dropdown, Toast, Alert fechável, Button em carregamento (`aria-busy` não ativa por Enter/Espaço), Table (ordenação, seleção e filtro local), Sidebar, Combobox (simples e múltiplo), DatePicker e DateRangePicker (calendário próprio, máscara dd/mm/aaaa), FileUpload (arrastar e soltar, modo formulário e imediato), diálogos rápidos (`alert`, `confirm`, `prompt`) e o PageLoader automático.
|
|
4
|
+
|
|
5
|
+
> **Versão 0.1.0 (primeira publicação).** Licença MIT. A API pode mudar até a 1.0. Documentação: https://efds-ui.com.br
|
|
6
|
+
|
|
7
|
+
## Uso por `<script>` (CDN, PHP, Java, .NET)
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<link rel="stylesheet" href=".../@efds-ui/core/dist/index.css" />
|
|
11
|
+
<script src=".../@efds-ui/behavior/dist/eds-behavior.js" defer></script>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Liga tudo sozinho quando o DOM está pronto e expõe `window.EDS`. Opções na própria tag:
|
|
15
|
+
|
|
16
|
+
| Atributo | Efeito |
|
|
17
|
+
| ------------------------------------- | --------------------------------------------------------------------- |
|
|
18
|
+
| `data-eds-manual` | Não liga sozinho: chame `EDS.init()`. |
|
|
19
|
+
| `data-eds-loader="auto\|manual\|off"` | PageLoader. `auto` (padrão), `manual` (só `start`/`track`), `off`. |
|
|
20
|
+
| `data-eds-loader-title`, `-text` | Textos padrão do loader. |
|
|
21
|
+
| `data-eds-loader-slow-after` | Ms até oferecer "Fechar" / "Continuar aguardando" (padrão 20000). |
|
|
22
|
+
| `data-eds-loader-trigger="all\|user"` | `all` (padrão): todo fetch/XHR; `user`: só os iniciados pelo usuário. |
|
|
23
|
+
| `data-eds-native-alert` | `window.alert` passa a abrir o `EDS.alert` (não bloqueia). |
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
EDS.toast({ variant: 'success', message: 'Pedido salvo.' });
|
|
27
|
+
const done = EDS.loader.start({ title: 'Gerando relatório…' });
|
|
28
|
+
fetch('/relatorio').finally(done);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Diálogos rápidos (alert, confirm, prompt)
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
await EDS.alert('Pedido salvo com sucesso.', 'Pedido', 'success'); // undefined
|
|
35
|
+
if (await EDS.confirm('Excluir o pedido PED-0001?', 'Excluir', 'danger')) {
|
|
36
|
+
/* ... */
|
|
37
|
+
} // boolean
|
|
38
|
+
const nome = await EDS.prompt('Nome do arquivo', 'relatorio', 'Salvar como'); // string | null
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Assinaturas: `alert(texto, título?, tipo?, opções?)`, `confirm(texto, título?, tipo?, opções?)`, `prompt(texto, valorPadrão?, título?, opções?)`. `tipo`: `info` (padrão do alert), `success`, `warning`, `danger`, `question` (padrão do confirm e do prompt). `opções`: `okText`, `cancelText`, `placeholder`, `required`, `inputType` (`text`, `email`, `number`, `password`, `textarea`), `validate(valor)` (devolve a mensagem de erro ou `''`) e `variant` (tipo do prompt). Chamadas simultâneas entram numa fila: um diálogo por vez. Enter confirma, Esc e o clique no fundo cancelam (`danger` não fecha no fundo). O texto vai como texto, nunca como HTML. Textos dos botões em `configure({ messages })`: `dialogOk`, `dialogCancel`, `dialogConfirm`, `dialogRequired`.
|
|
42
|
+
|
|
43
|
+
`window.alert` só é trocado se você pedir (`data-eds-native-alert` na tag ou `init(document, { nativeAlert: true })`; com `data-eds-manual`, use a opção do `init`). Atenção: o `alert` do navegador **bloqueia** e o do efDS.ui não: o código depois do `alert(...)` roda sem esperar o usuário fechar. `confirm` e `prompt` nativos nunca são trocados (são síncronos): use `await EDS.confirm(...)`.
|
|
44
|
+
|
|
45
|
+
### Confirmação declarativa
|
|
46
|
+
|
|
47
|
+
Sem JavaScript seu: `data-eds-confirm` em `button`, `a` ou `form` pergunta antes de agir e só prossegue se o usuário confirmar (o link navega, o botão de envio envia o form com ele como `submitter`, o form é enviado).
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<form
|
|
51
|
+
method="post"
|
|
52
|
+
action="/pedidos/1/excluir"
|
|
53
|
+
data-eds-confirm="Excluir o pedido PED-0001?"
|
|
54
|
+
data-eds-confirm-title="Excluir pedido"
|
|
55
|
+
data-eds-confirm-variant="danger"
|
|
56
|
+
data-eds-confirm-ok="Excluir"
|
|
57
|
+
>
|
|
58
|
+
<button type="submit" class="eds-button eds-button-danger">Excluir</button>
|
|
59
|
+
</form>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Opcionais: `data-eds-confirm-title`, `data-eds-confirm-variant` (`info | success | warning | danger | question`) e `data-eds-confirm-ok`.
|
|
63
|
+
|
|
64
|
+
## Arrastar e soltar (Sortable)
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<div
|
|
68
|
+
class="eds-sortable"
|
|
69
|
+
data-eds-sortable
|
|
70
|
+
data-eds-group="quadro"
|
|
71
|
+
data-eds-name="afazer[]"
|
|
72
|
+
aria-label="A fazer"
|
|
73
|
+
>
|
|
74
|
+
<div class="eds-sortable-item" data-id="t1">
|
|
75
|
+
<button type="button" class="eds-sortable-handle" aria-label="Mover Revisar contrato">…</button>
|
|
76
|
+
<span>Revisar contrato</span>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<script>
|
|
80
|
+
// Evento no contêiner de destino. detail: { id, from, to, fromIndex, toIndex, order }
|
|
81
|
+
document.addEventListener('eds:sortable-change', (e) => e.detail.order && salvar(e.detail.order));
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Contêineres com o mesmo `data-eds-group` trocam itens; `data-eds-orientation="horizontal | grid"` muda as setas; `data-eds-name` gera um `hidden` por item, na ordem. Teclado: Espaço pega e solta, setas movem, Esc cancela. No toque, sem pegador, segure o item 400 ms para arrastar. O resultado sai no evento `eds:sortable-change`.
|
|
86
|
+
|
|
87
|
+
## Árvore (Tree)
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<div
|
|
91
|
+
class="eds-tree"
|
|
92
|
+
data-eds-tree
|
|
93
|
+
data-eds-editable
|
|
94
|
+
data-eds-name="estrutura"
|
|
95
|
+
aria-label="Estrutura"
|
|
96
|
+
>
|
|
97
|
+
<ul role="tree">
|
|
98
|
+
<li role="treeitem" aria-expanded="true" data-id="n1">
|
|
99
|
+
<div class="eds-tree-row">
|
|
100
|
+
<span class="eds-tree-toggle" aria-hidden="true"></span
|
|
101
|
+
><span class="eds-tree-label">Diretoria Fictícia</span>
|
|
102
|
+
</div>
|
|
103
|
+
<ul role="group">
|
|
104
|
+
<li role="treeitem" data-id="n2">
|
|
105
|
+
<div class="eds-tree-row">
|
|
106
|
+
<span class="eds-tree-toggle" aria-hidden="true"></span
|
|
107
|
+
><span class="eds-tree-label">Sede Modelo</span>
|
|
108
|
+
</div>
|
|
109
|
+
</li>
|
|
110
|
+
</ul>
|
|
111
|
+
</li>
|
|
112
|
+
</ul>
|
|
113
|
+
</div>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Navegação pelo padrão APG (setas, Home/End, `*`, digitar a letra). Com `data-eds-editable`: F2 renomeia, Insert/Ctrl+Enter adiciona filho, Shift+Enter irmão, Delete exclui (com "Desfazer" por 8 s), Alt+setas movem, Shift+F10 abre o menu "⋯"; arrastar solta antes, dentro ou depois. `data-eds-source` monta a árvore de um JSON e `data-eds-children-url` carrega filhos sob demanda. Eventos: `eds:tree-change` (traz a estrutura em JSON), `eds:tree-beforechange` (cancelável), `eds:tree-select`, `eds:tree-activate`, `eds:tree-toggle`.
|
|
117
|
+
|
|
118
|
+
## Exportar tabelas (CSV, Excel, JSON, PDF)
|
|
119
|
+
|
|
120
|
+
Gerados no navegador, sem dependência. Botões ou itens de menu apontam para a tabela:
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
class="eds-dropdown-item"
|
|
126
|
+
data-eds-export="xlsx"
|
|
127
|
+
data-eds-export-target="pedidos"
|
|
128
|
+
data-eds-export-filename="pedidos"
|
|
129
|
+
>
|
|
130
|
+
Excel (.xlsx)
|
|
131
|
+
</button>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`data-eds-export="csv|xlsx|json|pdf"`, `-target` (id da tabela), `-filename`, `-title`, `-subtitle` e `-scope="auto|visible|selected|all"`. `th[data-type="text|number|currency|date|percent"]`, `td[data-value]` e `data-eds-export-ignore` descrevem colunas e células. O evento `eds:table-beforeexport` (cancelável) deixa mascarar `detail.data` (CPF, colunas sensíveis) antes de gerar; `eds:table-export` sai depois. Só o que está no DOM é exportado.
|
|
135
|
+
|
|
136
|
+
Sem HTML, os geradores servem a qualquer código: `exportData(data, 'xlsx', { filename })`, `toCsv`, `toJson`, `toXlsx` e `toPdf`. Para importar só eles, sem o `init` nem os demais módulos, use o subcaminho `@efds-ui/behavior/export` (é o que o `@efds-ui/react` faz).
|
|
137
|
+
|
|
138
|
+
## Máscara de entrada
|
|
139
|
+
|
|
140
|
+
`data-eds-mask` num `<input>` formata o valor enquanto se digita. Valor enviado: o que aparece, com a máscara; com `data-eds-mask-unmask`, o campo visível perde o `name` e um hidden com o mesmo `name` leva só os caracteres significativos.
|
|
141
|
+
|
|
142
|
+
```html
|
|
143
|
+
<label class="eds-label" for="cpf">CPF</label>
|
|
144
|
+
<input
|
|
145
|
+
id="cpf"
|
|
146
|
+
class="eds-input"
|
|
147
|
+
name="cpf"
|
|
148
|
+
data-eds-mask="cpf"
|
|
149
|
+
data-eds-mask-unmask
|
|
150
|
+
aria-describedby="cpf-ajuda"
|
|
151
|
+
/>
|
|
152
|
+
<p class="eds-helper" id="cpf-ajuda">Só números. Ex.: 123.456.789-00</p>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Atributo | Efeito |
|
|
156
|
+
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
157
|
+
| `data-eds-mask` | `telefone`, `cpf`, `cnpj` (aceita letras A-Z nas 12 primeiras posições), `cpf-cnpj`, `cep`, `moeda`, `numero` ou um padrão: `0` dígito, `A` letra, `*` letra ou dígito, `\` escapa, o resto é literal (`00.000-AAA`). |
|
|
158
|
+
| `data-eds-mask-unmask` | Hidden com o valor limpo (moeda: `1234.56`). Exige `name`. |
|
|
159
|
+
| `data-eds-mask-decimals` | Moeda e número: casas decimais (0 a 8, padrão 2). |
|
|
160
|
+
| `data-eds-mask-prefix` | Moeda e número: símbolo (padrão `"R$ "` na moeda; vazio é permitido). |
|
|
161
|
+
| `data-eds-mask-negative` | Moeda e número: aceita negativo (a tecla `-` alterna o sinal). |
|
|
162
|
+
|
|
163
|
+
O pacote define `inputmode`, `autocomplete` (telefone: `tel`, CEP: `postal-code`) e `maxlength` (menos na moeda e no número) só quando o autor não os pôs. Evento `eds:mask-change` (`{ value, raw }`). A máscara não valida (dígito verificador, faixa): continue com `required`, `pattern` e o servidor. Dados de exemplo, sempre fictícios (LGPD). Para importar só o núcleo, sem DOM: `import { createMask } from '@efds-ui/behavior/mask'`.
|
|
164
|
+
|
|
165
|
+
## Uso por módulo (Vue, Angular, bundlers)
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { init, toast, loader } from '@efds-ui/behavior';
|
|
169
|
+
|
|
170
|
+
const destroy = init(document.querySelector('#app')!, {
|
|
171
|
+
loader: {
|
|
172
|
+
auto: true,
|
|
173
|
+
delay: 300,
|
|
174
|
+
minVisible: 400,
|
|
175
|
+
slowAfter: 20000,
|
|
176
|
+
trigger: 'all',
|
|
177
|
+
exclude: [/\/api\/poll/],
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
// ao desmontar: destroy();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`init(root, options)` liga o que existe em `root`, observa o que entra e sai depois (htmx, Turbo, Livewire, parciais do servidor) e **não toca em nada fora do `root`**. Também há `initTabs`, `initModal`, `initDropdown`, `initAlert`, `initTable`, `initTableFilter`, `initSidebar`, `initCombobox`, `initDatepicker`, `initUpload`, `initButtonBusy`, `initConfirm`, `initSortable`, `initTree`, `initNativeAlert`, `initToast` e `initLoader` para importar só o que usa (tree shaking).
|
|
184
|
+
|
|
185
|
+
Referência completa (atributos, eventos, opções, configuração do loader): [`docs/architecture/behavior.md`](../../docs/architecture/behavior.md).
|
|
186
|
+
|
|
187
|
+
## O que cada componente espera
|
|
188
|
+
|
|
189
|
+
O markup é o contrato do core (`.eds-*`); o pacote detecta por classes e ARIA. Só acrescenta `data-eds-*` onde o markup não basta: `data-eds-open`, `data-eds-close`, `data-eds-backdrop="static"`, `data-eds-dismiss`, `data-eds-select-all`/`-row`, `data-eds-table-filter`, `data-eds-filter-columns`, `data-eds-filter-ignore`, `data-eds-sidebar-collapse`, `data-eds-source`, `data-eds-min-chars`, `data-eds-free-text`, `data-eds-multiple`, `data-eds-name`, `data-eds-max-selected`, `data-eds-upload`, `data-eds-max-size`, `data-eds-max-files`, `data-eds-upload-url`, `data-eds-upload-field`, `data-eds-confirm` (e `-title`, `-variant`, `-ok`), `data-eds-sortable`, `data-eds-group`, `data-eds-orientation`, `data-eds-editable`, `data-eds-multiselect`, `data-eds-tree`, `data-eds-children-url`, `data-eds-native-alert`, `data-eds-loader`, `data-eds-mask` (e `-unmask`, `-decimals`, `-prefix`, `-negative`).
|
|
190
|
+
|
|
191
|
+
## Scripts
|
|
192
|
+
|
|
193
|
+
`pnpm build` (ESM + `.d.ts` + IIFE) · `pnpm typecheck` · `pnpm test`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entrada `@efds-ui/behavior/balloon`: os comportamentos de Tooltip e Popover como `Behavior`
|
|
3
|
+
* avulsos (sem `init` nem observador), para o `@efds-ui/react` ligar o mesmo código do HTML.
|
|
4
|
+
*/
|
|
5
|
+
export { tooltipBehavior, TOOLTIP_SHOW_DELAY } from './components/tooltip';
|
|
6
|
+
export { popoverBehavior } from './components/popover';
|
|
7
|
+
export type { Behavior } from './core/registry';
|
|
8
|
+
export type { Placement } from './core/position';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as TOOLTIP_SHOW_DELAY, a as popoverBehavior, r as tooltipBehavior } from "./tooltip-wRy96rs_.js";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// src/core/fields.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"length",
|
|
4
|
+
"lower",
|
|
5
|
+
"upper",
|
|
6
|
+
"digit",
|
|
7
|
+
"symbol"
|
|
8
|
+
], t = [
|
|
9
|
+
"senha",
|
|
10
|
+
"password",
|
|
11
|
+
"qwerty",
|
|
12
|
+
"admin",
|
|
13
|
+
"abc123",
|
|
14
|
+
"letmein",
|
|
15
|
+
"mudar"
|
|
16
|
+
];
|
|
17
|
+
function n(e) {
|
|
18
|
+
if (/(.)\1{2,}/.test(e)) return !0;
|
|
19
|
+
let t = e.toLowerCase();
|
|
20
|
+
for (let e = 0; e + 2 < t.length; e++) {
|
|
21
|
+
let n = t.charCodeAt(e), r = t.charCodeAt(e + 1), i = t.charCodeAt(e + 2);
|
|
22
|
+
if (r - n === 1 && i - r === 1 || n - r === 1 && r - i === 1) return !0;
|
|
23
|
+
}
|
|
24
|
+
return !1;
|
|
25
|
+
}
|
|
26
|
+
function r(e, r = 8) {
|
|
27
|
+
let i = Math.max(1, Math.trunc(r) || 8), a = {
|
|
28
|
+
length: e.length >= i,
|
|
29
|
+
lower: /\p{Ll}/u.test(e),
|
|
30
|
+
upper: /\p{Lu}/u.test(e),
|
|
31
|
+
digit: /\d/.test(e),
|
|
32
|
+
symbol: /[^\p{L}\d]/u.test(e)
|
|
33
|
+
};
|
|
34
|
+
if (e === "") return {
|
|
35
|
+
level: 0,
|
|
36
|
+
rules: a
|
|
37
|
+
};
|
|
38
|
+
let o = [
|
|
39
|
+
a.lower,
|
|
40
|
+
a.upper,
|
|
41
|
+
a.digit,
|
|
42
|
+
a.symbol
|
|
43
|
+
].filter(Boolean).length, s = 0;
|
|
44
|
+
e.length >= i && (s += 1), e.length >= Math.max(12, i + 4) && (s += 1), o >= 3 && (s += 1), (o === 4 && e.length >= 10 || e.length >= 16) && (s += 1);
|
|
45
|
+
let c = e.toLowerCase();
|
|
46
|
+
return (n(e) || t.some((e) => c.includes(e))) && --s, e.length < i && (s = Math.min(s, 1)), {
|
|
47
|
+
level: Math.min(4, Math.max(1, s)),
|
|
48
|
+
rules: a
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function i(e, t = "numeric") {
|
|
52
|
+
let n = t === "numeric" ? /\d/ : /[\p{L}\d]/u;
|
|
53
|
+
return [...e].filter((e) => n.test(e)).map((e) => t === "numeric" ? e : e.toUpperCase()).join("");
|
|
54
|
+
}
|
|
55
|
+
function a(e, t, n, r = "numeric") {
|
|
56
|
+
let a = [...i(n, r)], o = [...e], s = Math.max(0, t);
|
|
57
|
+
for (let e of a) {
|
|
58
|
+
if (s >= o.length) break;
|
|
59
|
+
o[s] = e, s += 1;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
cells: o,
|
|
63
|
+
next: Math.min(s, o.length - 1)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function o(e) {
|
|
67
|
+
let t = String(e), n = t.indexOf(".");
|
|
68
|
+
return n < 0 ? 0 : t.length - n - 1;
|
|
69
|
+
}
|
|
70
|
+
function s(e, { min: t, max: n }) {
|
|
71
|
+
let r = e;
|
|
72
|
+
return t !== void 0 && r < t && (r = t), n !== void 0 && r > n && (r = n), r;
|
|
73
|
+
}
|
|
74
|
+
function c(e, t) {
|
|
75
|
+
let n = 10 ** t;
|
|
76
|
+
return Math.round((e + 2 ** -52 * Math.sign(e)) * n) / n;
|
|
77
|
+
}
|
|
78
|
+
function l(e, t, n, r, i) {
|
|
79
|
+
let a = e ?? s(0, r), l = Math.max(i, o(n));
|
|
80
|
+
return e === null && r.min !== void 0 && t > 0 ? c(r.min, l) : c(s(a + t * n, r), l);
|
|
81
|
+
}
|
|
82
|
+
var u = (e, t) => {
|
|
83
|
+
for (let n of t) {
|
|
84
|
+
let t = e[n];
|
|
85
|
+
if (t != null && String(t) !== "") return String(t);
|
|
86
|
+
}
|
|
87
|
+
return "";
|
|
88
|
+
};
|
|
89
|
+
function d(e) {
|
|
90
|
+
if (!e || typeof e != "object") return null;
|
|
91
|
+
let t = e, n = u(t, [
|
|
92
|
+
"code",
|
|
93
|
+
"codigo",
|
|
94
|
+
"id"
|
|
95
|
+
]);
|
|
96
|
+
return n === "" ? null : {
|
|
97
|
+
code: n,
|
|
98
|
+
description: u(t, [
|
|
99
|
+
"description",
|
|
100
|
+
"descricao",
|
|
101
|
+
"nome",
|
|
102
|
+
"name"
|
|
103
|
+
]),
|
|
104
|
+
raw: t
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// src/core/cep.ts
|
|
108
|
+
function f(e) {
|
|
109
|
+
let t = e.replace(/\D/g, "");
|
|
110
|
+
return t.length === 8 ? t : null;
|
|
111
|
+
}
|
|
112
|
+
function p(e, t) {
|
|
113
|
+
return e.includes("{cep}") ? e.replaceAll("{cep}", t) : `${e}${t}`;
|
|
114
|
+
}
|
|
115
|
+
async function m(e, t, n) {
|
|
116
|
+
if (t === "") return {
|
|
117
|
+
status: "error",
|
|
118
|
+
cep: e
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
let r = {
|
|
122
|
+
signal: n,
|
|
123
|
+
headers: { Accept: "application/json" },
|
|
124
|
+
edsLoader: !1
|
|
125
|
+
}, i = await fetch(p(t, e), r);
|
|
126
|
+
if (i.status === 404) return {
|
|
127
|
+
status: "notfound",
|
|
128
|
+
cep: e
|
|
129
|
+
};
|
|
130
|
+
if (!i.ok) return {
|
|
131
|
+
status: "error",
|
|
132
|
+
cep: e
|
|
133
|
+
};
|
|
134
|
+
let a = await i.json();
|
|
135
|
+
return !a || typeof a != "object" ? {
|
|
136
|
+
status: "error",
|
|
137
|
+
cep: e
|
|
138
|
+
} : a.erro === !0 || a.erro === "true" ? {
|
|
139
|
+
status: "notfound",
|
|
140
|
+
cep: e
|
|
141
|
+
} : {
|
|
142
|
+
status: "found",
|
|
143
|
+
cep: e,
|
|
144
|
+
data: a
|
|
145
|
+
};
|
|
146
|
+
} catch (t) {
|
|
147
|
+
if (t instanceof DOMException && t.name === "AbortError") throw t;
|
|
148
|
+
return {
|
|
149
|
+
status: "error",
|
|
150
|
+
cep: e
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export { r as a, a as c, l as d, d as f, e as i, i as l, p as n, s as o, m as r, o as s, f as t, c as u };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Accordion: o `<details>` nativo faz tudo; só o item indisponível precisa de ajuda. Um
|
|
4
|
+
* `summary[aria-disabled="true"]` não alterna (clique, Enter e Espaço chegam como `click`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const accordionBehavior: Behavior;
|
|
7
|
+
export declare function initAccordion(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
export type AgendaTone = 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
3
|
+
/** Evento da agenda. `date` e `end` (inclusive, para vários dias) são `aaaa-mm-dd`. */
|
|
4
|
+
export interface AgendaEvent {
|
|
5
|
+
id?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
date: string;
|
|
8
|
+
end?: string;
|
|
9
|
+
/** `HH:MM`; sem hora, o evento é de dia inteiro. */
|
|
10
|
+
time?: string;
|
|
11
|
+
href?: string;
|
|
12
|
+
tone?: AgendaTone;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Agenda mensal (`.eds-agenda[data-eds-agenda]`): grade de mês como `<table class="eds-agenda-grid">`
|
|
16
|
+
* (cabeçalhos `th scope="col"`, legenda oculta), navegação mês anterior, próximo e hoje (botões
|
|
17
|
+
* `[data-eds-agenda-prev|next|today]`, criados se faltarem), título em `aria-live`, hoje com
|
|
18
|
+
* `aria-current="date"`, eventos como link (com `href`) ou botão e "+N mais" abrindo o Popover.
|
|
19
|
+
* Eventos em `<script type="application/json" data-eds-agenda-events>` ou, a cada mês, de
|
|
20
|
+
* `data-eds-source` (`{from}` e `{to}` em `aaaa-mm-dd` na URL). Mês inicial em `data-eds-agenda-month`
|
|
21
|
+
* (`aaaa-mm`; padrão: o atual), início da semana em `data-eds-week-start` (0 = domingo) e
|
|
22
|
+
* `data-eds-max-events` por dia. Grade escrita pelo servidor e sem dados no cliente: o JS só liga
|
|
23
|
+
* a navegação e avisa (`eds:agenda-month-change`), sem apagar a grade. Eventos:
|
|
24
|
+
* `eds:agenda-month-change` (`detail { year, month, from, to }`, mês de 1 a 12) e
|
|
25
|
+
* `eds:agenda-event-click` (`detail { id, title, date, item }`).
|
|
26
|
+
*/
|
|
27
|
+
export declare const agendaBehavior: Behavior;
|
|
28
|
+
export declare function initAgenda(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Alert fechável: `[data-eds-dismiss]` dentro de `.eds-alert` remove o aviso e move o foco para
|
|
4
|
+
* o elemento lógico seguinte. `eds:alert-dismiss` (cancelável) sai antes; com `preventDefault` o aviso
|
|
5
|
+
* fica.
|
|
6
|
+
*/
|
|
7
|
+
export declare const alertDismissBehavior: Behavior;
|
|
8
|
+
export declare function initAlert(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/** Quantos tons `.eds-avatar-tone-N` o core define. */
|
|
3
|
+
export declare const AVATAR_TONES = 6;
|
|
4
|
+
/** Tom (1 a 6) estável para um nome: o mesmo nome dá sempre a mesma cor, sem acento nem caixa. */
|
|
5
|
+
export declare function avatarTone(name: string): number;
|
|
6
|
+
/** "Ana Souza" -> "AS"; uma palavra só -> as duas primeiras letras; vazio -> "". */
|
|
7
|
+
export declare function avatarInitials(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Avatar (`.eds-avatar`): sem classe `.eds-avatar-tone-N`, escolhe o tom pelo nome (hash entre 6
|
|
10
|
+
* tons com contraste AA) e, se o avatar estiver vazio e houver `data-name`, escreve as iniciais
|
|
11
|
+
* e dá `role="img"` com o nome. O nome vem de `data-name`, do `aria-label` ou do texto. Quem
|
|
12
|
+
* define o tom (classe ou `data-eds-tone`) não é alterado.
|
|
13
|
+
*/
|
|
14
|
+
export declare const avatarBehavior: Behavior;
|
|
15
|
+
export declare function initAvatar(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Banner de sistema (`.eds-banner[data-eds-banner]`). Com botão `[data-eds-banner-close]` (ou
|
|
4
|
+
* `data-eds-dismissible`, que o cria) o banner fecha com `hidden`; o fechamento é lembrado por id
|
|
5
|
+
* (o valor de `data-eds-banner`; `localStorage`, só `1`) e some nas próximas páginas. Desligue a
|
|
6
|
+
* lembrança com `data-eds-banner-remember="off"` (some só até recarregar). Evento
|
|
7
|
+
* `eds:banner-close` (`detail { id }`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const bannerBehavior: Behavior;
|
|
10
|
+
export declare function initBanner(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Botão em carregamento (`.eds-button[aria-busy="true"]`) não ativa: o CSS só barra o mouse
|
|
3
|
+
* (`pointer-events`), então Enter e Espaço ainda gerariam `click`. Ouvintes de captura em `root`
|
|
4
|
+
* cancelam (`preventDefault` + `stopImmediatePropagation`) o `click` e as teclas de ativação.
|
|
5
|
+
* O botão continua focável e sem `disabled` (o foco não se perde); o leitor de tela lê o
|
|
6
|
+
* `aria-busy`. Devolve a limpeza.
|
|
7
|
+
*/
|
|
8
|
+
export declare function initButtonBusy(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* CEP: `input[data-eds-cep]` consulta o endereço quando o CEP fica completo (8 dígitos; use junto
|
|
4
|
+
* com `data-eds-mask="cep"`) e preenche os campos de `data-eds-cep-fill`
|
|
5
|
+
* (`logradouro:#rua,bairro:#bairro,localidade:#cidade,uf:#uf`).
|
|
6
|
+
*
|
|
7
|
+
* **Nenhuma chamada externa por padrão.** O serviço é escolhido pelo autor: `data-eds-cep-url`
|
|
8
|
+
* (por campo) ou `configure({ cepUrl })`, com `{cep}` no lugar dos dígitos (ex.:
|
|
9
|
+
* `https://viacep.com.br/ws/{cep}/json/`). Sem URL, nada acontece. O CEP é um dado pessoal
|
|
10
|
+
* quando ligado a uma pessoa: a escolha do serviço é de quem implanta.
|
|
11
|
+
*
|
|
12
|
+
* Estados: carregando (`aria-busy` no campo e no `.eds-input-group`, e o spinner do grupo: o que o autor escreveu, com `hidden`, ou um criado), não
|
|
13
|
+
* encontrado e falha de rede (`p.eds-error`, esta com "Tentar de novo"). Evento `eds:cep-result`
|
|
14
|
+
* (`{ cep, status: 'found' | 'notfound' | 'error', data? }`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const cepBehavior: Behavior;
|
|
17
|
+
export declare function initCep(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
export interface ComboboxOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Combobox (APG "list autocomplete"): filtro local sem acento/caixa ou fonte remota
|
|
9
|
+
* (`data-eds-source`), popup em `popover="manual"` posicionado por `--_combobox-x/-y/-width`
|
|
10
|
+
* e `data-placement`. Destaque por `aria-activedescendant`; a seleção grava o campo hidden.
|
|
11
|
+
*/
|
|
12
|
+
export declare const comboboxBehavior: Behavior;
|
|
13
|
+
export declare function initCombobox(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/** Item da paleta (da marcação, do JSON ou da fonte remota). */
|
|
3
|
+
export interface CommandItem {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
group?: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
keywords?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** `mod+k`, `ctrl+k`, `/`: o último termo é a tecla; `mod` aceita Ctrl ou Cmd. */
|
|
14
|
+
export declare function matchesShortcut(event: KeyboardEvent, spec: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Paleta de comandos / busca global: `<dialog class="eds-modal eds-command" data-eds-command>`.
|
|
17
|
+
* Abre com Ctrl/Cmd+K (`data-eds-command-shortcut="mod+k"`; `off` desliga) ou por
|
|
18
|
+
* `[data-eds-open]`. Padrão APG combobox com lista: o foco fica no campo, a opção ativa vai em
|
|
19
|
+
* `aria-activedescendant`, setas movem, Enter escolhe, Esc fecha (nativo) e o foco volta a quem
|
|
20
|
+
* abriu. Itens: da própria marcação (`.eds-command-item`, com ícone e atalho do autor), de um
|
|
21
|
+
* `<script type="application/json" data-eds-command-items>` ou remotos (`data-eds-source`, com a
|
|
22
|
+
* busca no fim da URL e `[{value,label,description?,group?,href?,shortcut?}]` de volta).
|
|
23
|
+
* "Recentes" é opcional (`data-eds-command-recent="5"`; só ids em `localStorage`, chave em
|
|
24
|
+
* `data-eds-command-storage`). Evento `eds:command-select` (cancelável): `detail { value, label, href }`;
|
|
25
|
+
* sem cancelar, um item com `href` navega.
|
|
26
|
+
*/
|
|
27
|
+
export declare const commandBehavior: Behavior;
|
|
28
|
+
export declare function initCommand(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Avalia `campo=valor`, `campo!=valor`, `campo` (preenchido ou marcado) e `!campo`. O valor pode
|
|
4
|
+
* ser uma lista `a|b`. Sintaxe inválida ou campo ausente: falso.
|
|
5
|
+
*/
|
|
6
|
+
export declare function evaluateCondition(expression: string, scope: ParentNode): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Campos condicionais, sem script inline (compatível com CSP):
|
|
9
|
+
* - `data-eds-show-if="campo=valor"` mostra o elemento só quando a condição vale. Oculto, ele
|
|
10
|
+
* recebe `hidden` e os campos dentro dele ficam `disabled` (não vão no envio nem validam);
|
|
11
|
+
* - `data-eds-require-if="campo=valor"` torna obrigatórios (`required`) os campos dentro dele
|
|
12
|
+
* (ou ele mesmo) quando a condição vale;
|
|
13
|
+
* - `data-eds-show-if-announce="Texto"` (opcional) anuncia o texto, de forma discreta, quando o
|
|
14
|
+
* bloco aparece depois de uma ação do usuário.
|
|
15
|
+
* O escopo é o formulário do elemento (ou o documento). Evento `eds:conditional-change`
|
|
16
|
+
* (`detail.visible`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const conditionalBehavior: Behavior;
|
|
19
|
+
export declare function initConditional(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirmação declarativa: `data-eds-confirm="Excluir o pedido?"` em `button`, `a` ou `form`
|
|
3
|
+
* intercepta o clique (ou o envio), pergunta com `confirm` e, só se o usuário confirmar,
|
|
4
|
+
* prossegue: o link navega, o botão age (um botão de envio envia o formulário com ele como
|
|
5
|
+
* `submitter`) e o formulário é enviado. Opcionais: `data-eds-confirm-title`,
|
|
6
|
+
* `-variant` (`info|success|warning|danger|question`) e `-ok` (texto do botão principal).
|
|
7
|
+
* Ouvintes de captura em `root`; devolve a limpeza.
|
|
8
|
+
*/
|
|
9
|
+
export declare function initConfirm(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/** Copia `text` para a área de transferência: Clipboard API, com `execCommand` como reserva. */
|
|
3
|
+
export declare function copyText(text: string): Promise<boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Botão de copiar: `data-eds-copy="#alvo"` (valor ou texto do elemento) ou
|
|
6
|
+
* `data-eds-copy-text="literal"`. Troca o rótulo por "Copiado" por 2 s (`data-copied`), anuncia
|
|
7
|
+
* e emite `eds:copy` (`detail.text`) ou `eds:copy-fail`. O texto vem de `data-eds-copy-done`
|
|
8
|
+
* quando o botão traz o seu.
|
|
9
|
+
*/
|
|
10
|
+
export declare const copyBehavior: Behavior;
|
|
11
|
+
export declare function initCopy(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/**
|
|
3
|
+
* Corte de foto (`input[type=file][data-eds-cropper]`): ao escolher uma imagem abre o diálogo
|
|
4
|
+
* "Ajustar foto" (arrastar, ampliar, girar), e "Aplicar" entrega um ARQUIVO PRONTO no `input`
|
|
5
|
+
* (recortado, redimensionado e comprimido no navegador, nada é enviado a lugar nenhum). Depois
|
|
6
|
+
* redispara o `change` (o FileUpload segue o fluxo normal) e atualiza a prévia
|
|
7
|
+
* (`data-eds-cropper-preview`). Arquivo que não é imagem é recusado com erro visível.
|
|
8
|
+
* Atributos: `-size` (maior lado, 256), `-aspect` (largura / altura, 1), `-shape` (`circle` ou
|
|
9
|
+
* `rect`), `-format` (`image/webp`; sem suporte, JPEG), `-quality` (0 a 1, 0,85), `-preview`
|
|
10
|
+
* (seletor do avatar ou da imagem). Eventos no `input`: `eds:cropper-apply`, `eds:cropper-cancel`.
|
|
11
|
+
* Sem JS o `input` envia o arquivo original.
|
|
12
|
+
*/
|
|
13
|
+
export declare const cropperBehavior: Behavior;
|
|
14
|
+
export declare function initCropper(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Behavior } from '../core/registry';
|
|
2
|
+
/** DatePicker (`data-eds-datepicker`): campo com máscara + calendário em diálogo. */
|
|
3
|
+
export declare const datepickerBehavior: Behavior;
|
|
4
|
+
/** DateRangePicker (`data-eds-daterange`): início e fim. */
|
|
5
|
+
export declare const daterangeBehavior: Behavior;
|
|
6
|
+
export declare function initDatepicker(root?: ParentNode): () => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type DialogVariant = 'info' | 'success' | 'warning' | 'danger' | 'question';
|
|
2
|
+
export type DialogInputType = 'text' | 'email' | 'number' | 'password' | 'textarea';
|
|
3
|
+
/** Último argumento opcional de `alert`, `confirm` e `prompt`. */
|
|
4
|
+
export interface DialogOptions {
|
|
5
|
+
/** Padrão: `info` no alert e `question` no confirm e no prompt. */
|
|
6
|
+
variant?: DialogVariant;
|
|
7
|
+
/** Texto do botão principal. Padrão: "OK" (alert, prompt) ou "Confirmar" (confirm). */
|
|
8
|
+
okText?: string;
|
|
9
|
+
/** Texto do botão que cancela. Padrão: "Cancelar". */
|
|
10
|
+
cancelText?: string;
|
|
11
|
+
/** Prompt: dica do campo. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Prompt: exige texto (espaços não contam). */
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Prompt: tipo do campo. Padrão: `text`. */
|
|
16
|
+
inputType?: DialogInputType;
|
|
17
|
+
/** Prompt: devolve a mensagem de erro, ou `''` quando o valor é aceito. */
|
|
18
|
+
validate?: (value: string) => string;
|
|
19
|
+
}
|
|
20
|
+
/** Mostra um aviso com "OK". Resolve (`undefined`) ao fechar. */
|
|
21
|
+
export declare function alert(text: string, title?: string, variant?: DialogVariant, options?: DialogOptions): Promise<void>;
|
|
22
|
+
/** Pergunta com "Cancelar" e "Confirmar". Resolve `true` ao confirmar, `false` ao cancelar. */
|
|
23
|
+
export declare function confirm(text: string, title?: string, variant?: DialogVariant, options?: DialogOptions): Promise<boolean>;
|
|
24
|
+
/** Pede um texto. Resolve a string digitada ou `null` ao cancelar. */
|
|
25
|
+
export declare function prompt(text: string, defaultValue?: string, title?: string, options?: DialogOptions): Promise<string | null>;
|
|
26
|
+
export declare const dialogs: {
|
|
27
|
+
alert: typeof alert;
|
|
28
|
+
confirm: typeof confirm;
|
|
29
|
+
prompt: typeof prompt;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Troca `window.alert` por `EDS.alert` enquanto houver um `init` com `nativeAlert: true`.
|
|
33
|
+
* `confirm` e `prompt` nativos nunca são trocados (são síncronos).
|
|
34
|
+
*/
|
|
35
|
+
export declare function initNativeAlert(): () => void;
|