@1doc/1ds-vue 2.21.0 → 2.23.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1doc/1ds-vue",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "main": "dist/index.umd.js",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -34,7 +34,7 @@
34
34
  "vue": "^3.0.0",
35
35
  "vue-tsc": "^2.0.0",
36
36
  "@1doc/1ds-tokens": "0.9.0",
37
- "@1doc/1ds-core": "2.21.0"
37
+ "@1doc/1ds-core": "2.23.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@1doc/1ds-tokens": ">=0.8.0",
package/src/index.ts CHANGED
@@ -7,6 +7,8 @@ export * from "./utils/toast";
7
7
  export * from "./utils/density";
8
8
  // Paleta de cor categórica (primitivos) do ColorPicker
9
9
  export * from "./utils/paleta-de-cores";
10
+ // Padrões globais do Tooltip (variant e delayDuration), como o setTheme
11
+ export * from "./utils/tooltip";
10
12
  // FontAwesome
11
13
  export { library } from "@fortawesome/fontawesome-svg-core";
12
14
 
@@ -29,6 +31,7 @@ export { default as AttachmentCard } from "./components/AttachmentCard/Attachmen
29
31
  export { default as Avatar } from "./components/Avatar/Avatar.vue";
30
32
  export { default as AvatarGroup } from "./components/Avatar/AvatarGroup.vue";
31
33
  export { default as Badge } from "./components/Badge/Badge.vue";
34
+ export { default as BadgeGroup } from "./components/Badge/BadgeGroup.vue";
32
35
  export { default as BarChart } from "./components/Chart/BarChart.vue";
33
36
  export { default as BottomNavigation } from "./components/BottomNavigation/BottomNavigation.vue";
34
37
  export { default as BottomSheet } from "./components/BottomSheet/BottomSheet.vue";
@@ -36,6 +39,8 @@ export { default as Box } from "./components/Box/Box.vue";
36
39
  export { default as Breadcrumb } from "./components/Breadcrumb/Breadcrumb.vue";
37
40
  export { default as Button } from "./components/Button/Button.vue";
38
41
  export { default as Card } from "./components/Card/Card.vue";
42
+ export { default as CardList } from "./components/CardList/CardList.vue";
43
+ export { default as CardListRow } from "./components/CardList/CardListRow.vue";
39
44
  export { default as Checkbox } from "./components/Checkbox/Checkbox.vue";
40
45
  export { default as Chips } from "./components/Chips/Chips.vue";
41
46
  export { default as ColorPicker } from "./components/ColorPicker/ColorPicker.vue";
@@ -127,6 +132,7 @@ export type * from "./components/AttachmentCard/AttachmentCard.vue";
127
132
  export type * from "./components/Avatar/Avatar.vue";
128
133
  export type * from "./components/Avatar/AvatarGroup.vue";
129
134
  export type * from "./components/Badge/Badge.vue";
135
+ export type * from "./components/Badge/BadgeGroup.vue";
130
136
  export type * from "./components/Chart/BarChart.vue";
131
137
  export type * from "./components/BottomNavigation/BottomNavigation.vue";
132
138
  export type * from "./components/BottomSheet/BottomSheet.vue";
@@ -134,6 +140,8 @@ export type * from "./components/Box/Box.vue";
134
140
  export type * from "./components/Breadcrumb/Breadcrumb.vue";
135
141
  export type * from "./components/Button/Button.vue";
136
142
  export type * from "./components/Card/Card.vue";
143
+ export type * from "./components/CardList/CardList.vue";
144
+ export type * from "./components/CardList/CardListRow.vue";
137
145
  export type * from "./components/Checkbox/Checkbox.vue";
138
146
  export type * from "./components/Chips/Chips.vue";
139
147
  export type * from "./components/ColorPicker/ColorPicker.vue";
@@ -0,0 +1,30 @@
1
+ /** Chips: color e startIcon (slot #start-icon) no Vue GERADO. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
5
+
6
+ let Chips;
7
+
8
+ before(async () => {
9
+ await abrir();
10
+ Chips = await carregar("Chips/Chips.vue");
11
+ });
12
+ after(fechar);
13
+
14
+ test("Chips: color escreve a custom property e a classe; sem color, nada", async () => {
15
+ const comCor = await renderizar(Chips, { label: "Marcador", color: "#7B2CBF" });
16
+ assert.match(comCor, /umds-chip--cor-livre/);
17
+ assert.match(comCor, /--umds-chips-cor:\s*#7B2CBF/);
18
+ const semCor = await renderizar(Chips, { label: "Marcador" });
19
+ assert.doesNotMatch(semCor, /umds-chip--cor-livre|--umds-chips-cor/);
20
+ });
21
+
22
+ test("Chips: startIcon por string vira Icon; slot #start-icon sem a prop também entra", async () => {
23
+ const porProp = await renderizar(Chips, { label: "x", startIcon: ["fas", "tag"], size: "lg" });
24
+ assert.match(porProp, /umds-chip__start/);
25
+ assert.match(porProp, /font-size:\s*14px/);
26
+ const porSlot = await renderizar(Chips, { label: "x" }, { "start-icon": "<b>•</b>" });
27
+ assert.match(porSlot, /umds-chip__start/);
28
+ const sem = await renderizar(Chips, { label: "x" });
29
+ assert.doesNotMatch(sem, /umds-chip__start/);
30
+ });
@@ -0,0 +1,44 @@
1
+ /** Pagination: hasNext, loadingTotal, from/to e o total vindo de totalItems no Vue GERADO. */
2
+ import { test, before, after } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
5
+
6
+ let Pagination;
7
+
8
+ before(async () => {
9
+ await abrir();
10
+ Pagination = await carregar("Pagination/Pagination.vue");
11
+ });
12
+ after(fechar);
13
+
14
+ test("Pagination: sem hasNext e sem total, continua 'de 1' (hasNext ausente não vira false)", async () => {
15
+ const html = await renderizar(Pagination, { page: 1 });
16
+ assert.match(html, /umds-pagination__total">1</);
17
+ });
18
+
19
+ test("Pagination: hasNext some com o 'de N' e libera o próximo", async () => {
20
+ const html = await renderizar(Pagination, { variant: "alternative", page: 2, hasNext: true });
21
+ assert.doesNotMatch(html, /umds-pagination__of/);
22
+ const botoes = html.match(/<button[^>]*>/g);
23
+ assert.equal(botoes.filter((b) => / disabled/.test(b)).length, 0);
24
+ });
25
+
26
+ test("Pagination: só totalItems libera o próximo e a última página mostra 41-45", async () => {
27
+ const primeira = await renderizar(Pagination, { variant: "resumed", page: 1, pageSize: 20, totalItems: 45 });
28
+ assert.equal((primeira.match(/<button[^>]* disabled/g) || []).length, 1); // só o anterior
29
+ const ultima = await renderizar(Pagination, { variant: "resumed", page: 3, pageSize: 20, totalItems: 45 });
30
+ assert.match(ultima, /41-45 de 45/);
31
+ });
32
+
33
+ test("Pagination: loadingTotal põe o Skeleton com aria-busy e rótulo", async () => {
34
+ const html = await renderizar(Pagination, { variant: "resumed", page: 2, hasNext: true, loadingTotal: true });
35
+ assert.match(html, /21-40 de</);
36
+ assert.match(html, /aria-busy="true"/);
37
+ assert.match(html, /umds-skeleton/);
38
+ assert.match(html, /Carregando total/);
39
+ });
40
+
41
+ test("Pagination: from/to vencem o calculado", async () => {
42
+ const html = await renderizar(Pagination, { variant: "resumed", page: 3, hasNext: false, from: 41, to: 45 });
43
+ assert.match(html, /umds-pagination__range">41-45</);
44
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Registro dos tooltips abertos (estado de módulo, compartilhado entre os
3
+ * componentes gerados React e Vue). Uso interno do Tooltip; não sai no index.
4
+ * - Tooltips vizinhos: depois que um fecha, o próximo abre sem espera durante
5
+ * `skipDelayDuration`, e quem percorre uma lista não espera o atraso a cada item.
6
+ * - Tooltips aninhados: quando um descendente abre, o ancestral fecha. Fica
7
+ * um balão só, o de dentro.
8
+ */
9
+ import { getTooltipDefaults } from "./tooltip";
10
+ interface TooltipAberto {
11
+ gatilho: HTMLElement;
12
+ fechar: () => void;
13
+ }
14
+ const abertos: TooltipAberto[] = [];
15
+ let ultimoFechamento = 0;
16
+
17
+ /** Espera efetiva: zero quando outro tooltip está aberto ou acabou de fechar. */
18
+ export const atrasoDoTooltip = (atraso: number): number => {
19
+ if (atraso <= 0) return 0;
20
+ if (abertos.length > 0) return 0;
21
+ if (Date.now() - ultimoFechamento < getTooltipDefaults().skipDelayDuration) return 0;
22
+ return atraso;
23
+ };
24
+
25
+ /** true se um tooltip DENTRO deste gatilho está aberto (o de dentro vence). */
26
+ export const temTooltipDescendenteAberto = (gatilho: HTMLElement): boolean => abertos.some(item => item.gatilho !== gatilho && gatilho.contains(item.gatilho));
27
+
28
+ /** Registra o tooltip aberto e fecha os ancestrais dele. */
29
+ export const registrarTooltipAberto = (gatilho: HTMLElement, fechar: () => void): void => {
30
+ abertos.filter(item => item.gatilho !== gatilho && item.gatilho.contains(gatilho)).forEach(item => item.fechar());
31
+ if (!abertos.some(item => item.gatilho === gatilho)) abertos.push({
32
+ gatilho,
33
+ fechar
34
+ });
35
+ };
36
+
37
+ /** Tira o tooltip do registro (ao fechar ou desmontar). */
38
+ export const removerTooltipAberto = (gatilho: HTMLElement | null): void => {
39
+ if (!gatilho) return;
40
+ const indice = abertos.findIndex(item => item.gatilho === gatilho);
41
+ if (indice === -1) return;
42
+ abertos.splice(indice, 1);
43
+ ultimoFechamento = Date.now();
44
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Padrões globais do Tooltip, para não repetir `variant` e `delayDuration` em
3
+ * cada uso. Chame uma vez na entrada do app, como o `setTheme`:
4
+ *
5
+ * setTooltipDefaults({ variant: "dark", delayDuration: 300 });
6
+ *
7
+ * A prop do Tooltip sempre vence o padrão global.
8
+ *
9
+ * O registro de quem está aberto (vizinhos e aninhados) fica em
10
+ * `tooltip-abertos.ts`, de uso interno (fora do index).
11
+ */
12
+ export type TooltipDefaultVariant = "default" | "dark";
13
+ export interface TooltipDefaults {
14
+ /** Aparência padrão do balão. @default 'default' */
15
+ variant?: TooltipDefaultVariant;
16
+ /** Espera, em ms, entre o hover/foco e o balão abrir. @default 0 */
17
+ delayDuration?: number;
18
+ /** Janela, em ms, em que o próximo tooltip abre sem espera depois de outro fechar. @default 300 */
19
+ skipDelayDuration?: number;
20
+ }
21
+ const padroes: Required<TooltipDefaults> = {
22
+ variant: "default",
23
+ delayDuration: 0,
24
+ skipDelayDuration: 300
25
+ };
26
+
27
+ /** Define os padrões globais do Tooltip. Só muda as chaves passadas. */
28
+ export const setTooltipDefaults = (opcoes: TooltipDefaults): void => {
29
+ if (opcoes.variant !== undefined) padroes.variant = opcoes.variant;
30
+ if (opcoes.delayDuration !== undefined) padroes.delayDuration = opcoes.delayDuration;
31
+ if (opcoes.skipDelayDuration !== undefined) padroes.skipDelayDuration = opcoes.skipDelayDuration;
32
+ };
33
+
34
+ /** Padrões globais atuais do Tooltip. */
35
+ export const getTooltipDefaults = (): Required<TooltipDefaults> => ({
36
+ ...padroes
37
+ })