v-sistec-features 1.26.4 → 1.27.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/core.d.ts +86 -40
- package/dist/index.d.ts +95 -49
- package/dist/v-sistec-features.css +1 -1
- package/dist/vDataTable.d.ts +95 -49
- package/dist/vDataTable.js +948 -956
- package/package.json +1 -1
- package/src/DatatableVue/components/SearchDatatable.vue +10 -22
- package/src/DatatableVue/components/VColumnManager.vue +53 -0
- package/src/DatatableVue/components/VDataTable.vue +32 -117
- package/src/DatatableVue/components/VOrderingIcon.vue +7 -30
- package/src/DatatableVue/composables/useDataTableConfig.ts +37 -0
- package/src/{config → DatatableVue/config}/datatableConfig.ts +1 -1
- package/src/DatatableVue/config/datatableDefaults.ts +75 -0
- package/src/DatatableVue/style/svgs.ts +33 -0
- package/src/DatatableVue/types/v-data-table.ts +125 -45
- package/src/core/plugin.ts +1 -1
- package/src/utils/svgFactory.ts +99 -0
- package/src/DatatableVue/components/VExtraActions.vue +0 -47
|
@@ -2,48 +2,81 @@ import type { Ref, ComputedRef, Component, MaybeRefOrGetter } from 'vue';
|
|
|
2
2
|
import type { PaginationObject } from '../keys';
|
|
3
3
|
|
|
4
4
|
export type { PaginationObject } from '../keys';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Tipagem para configurações de API.
|
|
9
|
+
Por que é usada: Isola as propriedades responsáveis por buscar e interpretar os dados do backend.
|
|
10
|
+
*/
|
|
11
|
+
export interface ApiProps {
|
|
6
12
|
/* configuração do useApiFetch */
|
|
7
13
|
fetch: Function;
|
|
8
|
-
fetch_name?: string;
|
|
9
14
|
endpoint: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/* retira os params default da requisição */
|
|
15
|
-
deactivate_default_params?: boolean;
|
|
15
|
+
fetch_name?: string;
|
|
16
|
+
/* usado para pegar os dados do useApiFetch */
|
|
17
|
+
data_key?: string;
|
|
18
|
+
total_key?: string;
|
|
16
19
|
/* nomes dos parâmetros para passar para o backend */
|
|
17
20
|
filter_param_name?: string;
|
|
18
21
|
search_param_name?: string;
|
|
19
22
|
page_param_name?: string;
|
|
20
23
|
page_size_param_name?: string;
|
|
21
|
-
add_params?:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/* filtros que irão ser usados */
|
|
28
|
-
list_filter?: any[];
|
|
29
|
-
/* mudar o que está escrito no select de mudança de items_per_page*/
|
|
30
|
-
first_text_page_size?: string;
|
|
31
|
-
second_text_page_size?: string;
|
|
32
|
-
|
|
24
|
+
add_params?: Record<string, any> | (() => Record<string, any>);
|
|
25
|
+
/* retira os params default da requisição */
|
|
26
|
+
deactivate_default_params?: boolean;
|
|
27
|
+
disable_request?: MaybeRefOrGetter<boolean>;
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/**
|
|
31
|
+
* =====================================================
|
|
32
|
+
* Tipagem para classes CSS.
|
|
33
|
+
* Por que é usada: Agrupa as opções de estilização estrutural do datatable.
|
|
34
|
+
* =====================================================
|
|
35
|
+
* **/
|
|
36
|
+
export interface ColumnManagerClass{
|
|
37
|
+
class_column_manager_dropdown?: string;
|
|
38
|
+
class_column_manager_dropdown_menu?: string;
|
|
39
|
+
class_column_manager_button?: string;
|
|
40
|
+
disable_class_column_manager_default?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface PaginationClass{
|
|
43
|
+
class_pagination?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface BodyClass{
|
|
36
46
|
class_content?: string;
|
|
37
47
|
class_container?: string;
|
|
38
|
-
|
|
48
|
+
}
|
|
49
|
+
export interface TableClass{
|
|
50
|
+
class_table?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface FiltersClass{
|
|
39
53
|
class_filters?: string;
|
|
40
54
|
class_page_size?: string;
|
|
55
|
+
}
|
|
56
|
+
/*
|
|
57
|
+
Tipagem para classes CSS.
|
|
58
|
+
Por que é usada: Agrupa as opções de estilização estrutural do datatable.
|
|
59
|
+
*/
|
|
60
|
+
export type ClassProps = (
|
|
61
|
+
ColumnManagerClass &
|
|
62
|
+
PaginationClass &
|
|
63
|
+
BodyClass &
|
|
64
|
+
TableClass &
|
|
65
|
+
FiltersClass
|
|
66
|
+
);
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
/*
|
|
69
|
+
Tipagem para o comportamento principal.
|
|
70
|
+
Por que é usada: Controla limites, tempos de carregamento, armazenamento de estado e identificadores.
|
|
71
|
+
*/
|
|
72
|
+
export interface BehaviorProps {
|
|
73
|
+
limit_per_page?: number;
|
|
74
|
+
page_starts_at?: number;
|
|
75
|
+
/*
|
|
43
76
|
* tempo mínimo em ms para mostrar o loading para evitar telas piscando
|
|
44
77
|
*/
|
|
45
78
|
min_loading_delay?: number;
|
|
46
|
-
|
|
79
|
+
/*
|
|
47
80
|
- Número de tentativas automáticas em caso de falha.
|
|
48
81
|
- 1 significa que a requisição será feita apenas uma vez, sem retentativas.
|
|
49
82
|
- Valor padrão é 3.
|
|
@@ -51,37 +84,84 @@ export interface VDataTableProps {
|
|
|
51
84
|
retry_attempts?: number;
|
|
52
85
|
// Atraso em milissegundos entre cada tentativa
|
|
53
86
|
retry_delay?: number;
|
|
87
|
+
immediate?: boolean;
|
|
88
|
+
// Propriedade para ativar a persistência de configuração da tabela no localstorage
|
|
89
|
+
storage_id?: string;
|
|
90
|
+
use_column_manager?: boolean;
|
|
91
|
+
show_header_when_empty?: boolean;
|
|
92
|
+
// Define qual propriedade do item será usada como chave única para a seleção.
|
|
93
|
+
item_key?: string;
|
|
94
|
+
/* tipos de loading pré-definidos*/
|
|
95
|
+
type_loading?: 'placeholder' | 'spiner-table' | 'spiner';
|
|
96
|
+
/*recebe um component para loading*/
|
|
97
|
+
custom_loading?: Component | null;
|
|
98
|
+
}
|
|
54
99
|
|
|
100
|
+
/*
|
|
101
|
+
Tipagem para regras de busca.
|
|
102
|
+
Por que é usada: Define propriedades dos filtros, placeholders e teleports de pesquisa.
|
|
103
|
+
*/
|
|
104
|
+
export interface SearchProps {
|
|
105
|
+
/* filtros que irão ser usados */
|
|
106
|
+
list_filter?: any[];
|
|
107
|
+
placeholder_search?: string;
|
|
108
|
+
disable_search?: boolean;
|
|
109
|
+
deactivate_search_empty?: boolean;
|
|
110
|
+
deactivate_search_on_clear?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/*
|
|
113
|
+
Tipagem para regras de paginação.
|
|
114
|
+
Por que é usada: Define os textos exibidos e o local de renderização da paginação.
|
|
115
|
+
*/
|
|
116
|
+
export interface PaginationProps {
|
|
117
|
+
first_text_page_size?: string;
|
|
118
|
+
second_text_page_size?: string;
|
|
119
|
+
}
|
|
120
|
+
/*
|
|
121
|
+
Tipagem para regras de movimentação de itens
|
|
122
|
+
*/
|
|
123
|
+
export interface TeleportsProps {
|
|
124
|
+
/*teleports para o search e para a paginação*/
|
|
125
|
+
search_teleport?: string | HTMLElement | null;
|
|
126
|
+
// Aceita string (seletor) OU HTMLElement (ref direto) OU null
|
|
127
|
+
pagination_teleport?: string | HTMLElement | null;
|
|
128
|
+
extra_actions_teleport?: string | HTMLElement | null;
|
|
129
|
+
column_manager_teleport?: string | HTMLElement | null;
|
|
130
|
+
}
|
|
131
|
+
/*
|
|
132
|
+
Tipagem para recursos extras.
|
|
133
|
+
Por que é usada: Habilita checkboxes e itens expansíveis na tabela.
|
|
134
|
+
*/
|
|
135
|
+
export interface ExtraFeaturesProps {
|
|
55
136
|
// Ativa a funcionalidade de seleção com checkboxes
|
|
56
137
|
use_checkbox?: boolean;
|
|
138
|
+
deactivate_selected_info?: boolean;
|
|
57
139
|
use_expandable_items?: boolean;
|
|
58
140
|
close_expanded_item_on_expand_new?: boolean;
|
|
59
141
|
scroll_to_expanded_item?: boolean;
|
|
60
|
-
|
|
61
142
|
type_animation_expand?: 'fade' | 'expand' | 'none';
|
|
62
143
|
deactivate_animation_expand?: boolean;
|
|
63
144
|
type_button_expand?: 'arrow' | 'plus';
|
|
64
|
-
|
|
145
|
+
}
|
|
65
146
|
|
|
66
|
-
|
|
67
|
-
|
|
147
|
+
/*
|
|
148
|
+
Tipagem consolidada de propriedades do VDataTable.
|
|
149
|
+
Por que é usada: Une todas as categorias lógicas através de interseção, fornecendo uma interface plana para o Vue, preservando a retrocompatibilidade com versões anteriores da aplicação.
|
|
150
|
+
*/
|
|
151
|
+
export type VDataTableProps = (
|
|
152
|
+
ApiProps &
|
|
153
|
+
ClassProps &
|
|
154
|
+
BehaviorProps &
|
|
155
|
+
SearchProps &
|
|
156
|
+
PaginationProps &
|
|
157
|
+
ExtraFeaturesProps &
|
|
158
|
+
TeleportsProps
|
|
159
|
+
);
|
|
68
160
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
placeholder_search?: string;
|
|
74
|
-
deactivate_search_on_clear?: boolean;
|
|
75
|
-
disable_search?: boolean;
|
|
76
|
-
disable_request?: MaybeRefOrGetter<boolean>;
|
|
77
|
-
// Aceita string (seletor) OU HTMLElement (ref direto) OU null
|
|
78
|
-
pagination_teleport?: string | HTMLElement | null;
|
|
79
|
-
search_teleport?: string | HTMLElement | null;
|
|
80
|
-
show_header_when_empty?: boolean;
|
|
81
|
-
// Propriedade para ativar a persistência de configuração da tabela no localstorage
|
|
82
|
-
storage_id?: string;
|
|
83
|
-
use_column_manager?: boolean;
|
|
84
|
-
}
|
|
161
|
+
/*
|
|
162
|
+
Tipagem consolidada de propriedades do VDataTable com valores padrão.
|
|
163
|
+
Por que é usada: Fornece uma interface completa para o Vue, incluindo todas as propriedades obrigatórias e opcionais, com valores padrão definidos.
|
|
164
|
+
*/
|
|
85
165
|
export type DataTablePropsWithDefaults = VDataTableProps & {
|
|
86
166
|
// Strings
|
|
87
167
|
fetch_name: string;
|
package/src/core/plugin.ts
CHANGED
|
@@ -29,7 +29,7 @@ import '../assets/v-required-style.css'
|
|
|
29
29
|
import Toast, { type PluginOptions as ToastPluginOptions } from "vue-toastification";
|
|
30
30
|
import "vue-toastification/dist/index.css";
|
|
31
31
|
|
|
32
|
-
import { DATA_TABLE_CONFIG, type DataTableGlobalConfig } from '@/config/datatableConfig';
|
|
32
|
+
import { DATA_TABLE_CONFIG, type DataTableGlobalConfig } from '@/DatatableVue/config/datatableConfig';
|
|
33
33
|
export interface SistecOptions {
|
|
34
34
|
dataTable?: DataTableGlobalConfig; // Configurações opcionais da tabela
|
|
35
35
|
toast?: ToastPluginOptions; // Configurações opcionais do Toast
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*
|
|
2
|
+
========
|
|
3
|
+
Arquivo responsável por converter strings de SVGs puros em componentes funcionais do Vue.
|
|
4
|
+
Ele recebe um objeto aninhado contendo strings de SVGs e retorna um espelho desse objeto, mas com as strings substituídas por componentes renderizáveis, preservando classes e atributos dinâmicos, com tipagem genérica mapeada.
|
|
5
|
+
========
|
|
6
|
+
*/
|
|
7
|
+
import { h } from 'vue';
|
|
8
|
+
import type { FunctionalComponent, VNode } from 'vue';
|
|
9
|
+
|
|
10
|
+
const parser = new DOMParser();
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Tipo que define a estrutura base de entrada.
|
|
14
|
+
Por que é usada: Garante que o objeto passado siga o padrão de chaves contendo strings ou outros objetos.
|
|
15
|
+
*/
|
|
16
|
+
export type SvgSource = {
|
|
17
|
+
[key: string]: string | SvgSource;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
Tipo genérico recursivo que espelha a estrutura exata do objeto de entrada.
|
|
22
|
+
Por que é usada: Mapeia as chaves literais (como 'search', 'filter') do objeto de origem para que o TypeScript saiba exatamente quais propriedades existem, evitando o erro de propriedades indefinidas.
|
|
23
|
+
*/
|
|
24
|
+
export type IconTree<T> = {
|
|
25
|
+
[K in keyof T]: T[K] extends string
|
|
26
|
+
? FunctionalComponent
|
|
27
|
+
: T[K] extends object
|
|
28
|
+
? IconTree<T[K]>
|
|
29
|
+
: never;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Função que converte uma string de SVG em um componente Vue.
|
|
34
|
+
Recebe: Uma string (stringSvg) contendo a marcação XML do SVG.
|
|
35
|
+
Devolve: Um componente funcional do Vue que renderiza o SVG.
|
|
36
|
+
Por que é usada: Permite que SVGs brutos sejam usados diretamente no template do Vue com suporte a atributos dinâmicos.
|
|
37
|
+
*/
|
|
38
|
+
const stringParaComponente = (stringSvg: string): FunctionalComponent => {
|
|
39
|
+
const doc = parser.parseFromString(stringSvg, 'image/svg+xml');
|
|
40
|
+
const root = doc.documentElement;
|
|
41
|
+
|
|
42
|
+
if (root.tagName.toLowerCase() !== 'svg') {
|
|
43
|
+
return () => h('span', {
|
|
44
|
+
style: {
|
|
45
|
+
backgroundColor: 'red',
|
|
46
|
+
color: 'white',
|
|
47
|
+
padding: '2px 4px',
|
|
48
|
+
textAlign: 'center',
|
|
49
|
+
}
|
|
50
|
+
}, 'Icon Error');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const atributosPadrao: Record<string, string> = {};
|
|
54
|
+
for (const attr of root.attributes) {
|
|
55
|
+
atributosPadrao[attr.name] = attr.value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const conteudoInterno = root.innerHTML;
|
|
59
|
+
|
|
60
|
+
return (props: any, { attrs }: any): VNode => {
|
|
61
|
+
const classeOriginal = atributosPadrao.class || '';
|
|
62
|
+
const classeRecebida = (attrs.class as string) || '';
|
|
63
|
+
|
|
64
|
+
const classeCombinada = [classeOriginal, classeRecebida].filter(Boolean).join(' ');
|
|
65
|
+
|
|
66
|
+
const { class: _, ...restoPadrao } = atributosPadrao;
|
|
67
|
+
const { class: __, ...restoAttrs } = attrs;
|
|
68
|
+
|
|
69
|
+
return h('svg', {
|
|
70
|
+
...restoPadrao,
|
|
71
|
+
...props,
|
|
72
|
+
...restoAttrs,
|
|
73
|
+
class: classeCombinada,
|
|
74
|
+
innerHTML: conteudoInterno
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
Função que constrói a árvore de componentes de ícones dinamicamente.
|
|
81
|
+
Recebe: Um objeto genérico (objetoOrigem) contendo as strings de SVGs organizadas.
|
|
82
|
+
Devolve: Um objeto com a mesmíssima estrutura da entrada (inferida pelo TypeScript), contendo os componentes funcionais do Vue.
|
|
83
|
+
Por que é usada: Processa um dicionário de ícones garantindo o autocompletar exato de cada chave no editor.
|
|
84
|
+
*/
|
|
85
|
+
export const buildIcons = <T extends Record<string, any>>(objetoOrigem: T): IconTree<T> => {
|
|
86
|
+
const resultado: any = {};
|
|
87
|
+
|
|
88
|
+
for (const chave in objetoOrigem) {
|
|
89
|
+
const valor = objetoOrigem[chave];
|
|
90
|
+
|
|
91
|
+
if (typeof valor === 'string') {
|
|
92
|
+
resultado[chave] = stringParaComponente(valor);
|
|
93
|
+
} else if (typeof valor === 'object' && valor !== null) {
|
|
94
|
+
resultado[chave] = buildIcons(valor);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return resultado as IconTree<T>;
|
|
99
|
+
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-if="use_column_manager" class="dropdown d-inline-block ms-2">
|
|
3
|
-
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"
|
|
4
|
-
title="Gerenciar Colunas visíveis">
|
|
5
|
-
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-columns" width="24" height="24"
|
|
6
|
-
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
|
|
7
|
-
stroke-linejoin="round">
|
|
8
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
9
|
-
<path d="M4 6l5.5 0" />
|
|
10
|
-
<path d="M4 10l5.5 0" />
|
|
11
|
-
<path d="M4 14l5.5 0" />
|
|
12
|
-
<path d="M4 18l5.5 0" />
|
|
13
|
-
<path d="M14.5 6l5.5 0" />
|
|
14
|
-
<path d="M14.5 10l5.5 0" />
|
|
15
|
-
<path d="M14.5 14l5.5 0" />
|
|
16
|
-
<path d="M14.5 18l5.5 0" />
|
|
17
|
-
</svg>
|
|
18
|
-
</button>
|
|
19
|
-
<div class="dropdown-menu dropdown-menu-end p-3 shadow-sm" style="min-width: 220px; z-index: 1050;">
|
|
20
|
-
<h6 class="dropdown-header text-uppercase fw-bold mb-2">Exibir Colunas</h6>
|
|
21
|
-
<div class="d-flex flex-column gap-2">
|
|
22
|
-
<label v-for="coluna in columns_list" :key="coluna.id" class="form-check cursor-pointer m-0">
|
|
23
|
-
<input class="form-check-input" type="checkbox" :checked="coluna.visible" :disabled="coluna.locked"
|
|
24
|
-
@change="toggleColumnVisibility(coluna.id)">
|
|
25
|
-
<span class="form-check-label user-select-none">{{ coluna.header }}</span>
|
|
26
|
-
</label>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
<slot name="extra-actions">
|
|
31
|
-
|
|
32
|
-
</slot>
|
|
33
|
-
</template>
|
|
34
|
-
<script setup lang="ts">
|
|
35
|
-
interface SearchProps {
|
|
36
|
-
columns_list?: any[];
|
|
37
|
-
use_column_manager?: boolean;
|
|
38
|
-
toggleColumnVisibility?: (columnId: string) => void;
|
|
39
|
-
}
|
|
40
|
-
withDefaults(defineProps<SearchProps>(), {
|
|
41
|
-
columns_list: () => [],
|
|
42
|
-
use_column_manager: false,
|
|
43
|
-
toggleColumnVisibility: () => { }
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
</script>
|