v-sistec-features 1.26.3 → 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 +936 -942
- 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 +38 -118
- 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
package/package.json
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
<a v-if="item_use.includes(2)" href="#" class="btn dropdown-toggle" data-bs-toggle="dropdown"
|
|
4
|
+
<a @click.prevent v-if="item_use.includes(2)" href="#" class="btn dropdown-toggle" data-bs-toggle="dropdown"
|
|
5
5
|
title="Pesquisas Prédefinidas">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
stroke-linejoin="round">
|
|
9
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
10
|
-
<path
|
|
11
|
-
d="M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z">
|
|
12
|
-
</path>
|
|
13
|
-
</svg>
|
|
6
|
+
<!-- filter -->
|
|
7
|
+
<component :is="icons.search.filter" />
|
|
14
8
|
</a>
|
|
15
9
|
<div class="input-icon">
|
|
16
10
|
<input type="text" class="form-control ms-1" id="inputSearchVDataTable" v-model="modelSearch"
|
|
17
11
|
@keyup.enter="searchEnter" :placeholder="placeholder_search">
|
|
18
12
|
|
|
19
13
|
<span v-if="modelSearch" @click="cleanSearch()" class=" inputClose" title="Limpar pesquisa">
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class="icon icon-tabler icons-tabler-outline icon-tabler-x">
|
|
23
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
24
|
-
<path d="M18 6l-12 12" />
|
|
25
|
-
<path d="M6 6l12 12" />
|
|
26
|
-
</svg>
|
|
14
|
+
<!-- clear -->
|
|
15
|
+
<component :is="icons.search.clear" />
|
|
27
16
|
</span>
|
|
28
17
|
<span v-else class="input-icon-addon">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
32
|
-
<path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path>
|
|
33
|
-
<path d="M21 21l-6 -6"></path>
|
|
34
|
-
</svg>
|
|
18
|
+
<!-- lupa -->
|
|
19
|
+
<component :is="icons.search.loupe" />
|
|
35
20
|
</span>
|
|
36
21
|
</div>
|
|
37
22
|
<div v-if="item_use.includes(2)" class="dropdown-menu">
|
|
@@ -58,6 +43,9 @@
|
|
|
58
43
|
</template>
|
|
59
44
|
<script setup lang="ts">
|
|
60
45
|
import { computed, watch } from 'vue';
|
|
46
|
+
import {buildIcons} from '@/utils/svgFactory'
|
|
47
|
+
import { svgs } from '@/DatatableVue/style/svgs'
|
|
48
|
+
const icons = buildIcons(svgs)
|
|
61
49
|
interface SearchProps {
|
|
62
50
|
search: string;
|
|
63
51
|
filter?: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="use_column_manager" :class="[
|
|
3
|
+
{ 'dropdown d-inline-block ms-2': !disable_class_column_manager_default },
|
|
4
|
+
class_column_manager_dropdown
|
|
5
|
+
]">
|
|
6
|
+
<button :class="[
|
|
7
|
+
{ 'btn dropdown-toggle': !disable_class_column_manager_default },
|
|
8
|
+
class_column_manager_button
|
|
9
|
+
]" type="button" data-bs-toggle="dropdown" aria-expanded="false" title="Gerenciar Colunas visíveis">
|
|
10
|
+
<component :is="icons.column_manager" />
|
|
11
|
+
</button>
|
|
12
|
+
<div class="dropdown-menu dropdown-menu-end p-3 shadow-sm" :class="[
|
|
13
|
+
{ 'dropdown-menu dropdown-menu-end p-3 shadow-sm': !disable_class_column_manager_default },
|
|
14
|
+
class_column_manager_dropdown_menu
|
|
15
|
+
]" style="min-width: 220px; z-index: 1050;">
|
|
16
|
+
<h6 class="dropdown-header text-uppercase fw-bold mb-2">Exibir Colunas</h6>
|
|
17
|
+
<div class="d-flex flex-column gap-2">
|
|
18
|
+
<label v-for="coluna in columns_list" :key="coluna.id" class="form-check cursor-pointer m-0">
|
|
19
|
+
<input class="form-check-input" type="checkbox" :checked="coluna.visible" :disabled="coluna.locked"
|
|
20
|
+
@change="toggleColumnVisibility(coluna.id)">
|
|
21
|
+
<span class="form-check-label user-select-none">{{ coluna.header }}</span>
|
|
22
|
+
</label>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
</template>
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { buildIcons } from '@/utils/svgFactory'
|
|
30
|
+
import { svgs } from '@/DatatableVue/style/svgs'
|
|
31
|
+
const icons = buildIcons(svgs)
|
|
32
|
+
|
|
33
|
+
interface SearchProps {
|
|
34
|
+
columns_list?: any[];
|
|
35
|
+
use_column_manager?: boolean;
|
|
36
|
+
toggleColumnVisibility?: (columnId: string) => void;
|
|
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
|
+
withDefaults(defineProps<SearchProps>(), {
|
|
43
|
+
columns_list: () => [],
|
|
44
|
+
use_column_manager: false,
|
|
45
|
+
toggleColumnVisibility: () => { },
|
|
46
|
+
class_column_manager_dropdown: '',
|
|
47
|
+
class_column_manager_dropdown_menu: '',
|
|
48
|
+
class_column_manager_button: '',
|
|
49
|
+
disable_class_column_manager_default: false
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</script>
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
</slot>
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
<div class="dropdown d-flex">
|
|
25
|
+
<Teleport v-if="isMounted" :to="options.search_teleport || 'body'" :disabled="!options.search_teleport">
|
|
25
26
|
<Search v-if="!options.disable_search" v-model:search="pagination.search"
|
|
26
27
|
v-model:filter="pagination.filter" :list_filter="options.list_filter" :item_use="item_use"
|
|
27
28
|
@search="reSearch" :deactivate_search_on_clear="options.deactivate_search_on_clear"
|
|
@@ -36,17 +37,19 @@
|
|
|
36
37
|
</slot>
|
|
37
38
|
</template>
|
|
38
39
|
</Search>
|
|
40
|
+
</Teleport>
|
|
41
|
+
<Teleport v-if="isMounted" :to="options.column_manager_teleport || 'body'" :disabled="!options.column_manager_teleport">
|
|
42
|
+
<VColumnManager :use_column_manager="options.use_column_manager" :columns_list="columns_list"
|
|
43
|
+
:toggleColumnVisibility="toggleColumnVisibility"
|
|
44
|
+
:disable_class_column_manager_default="options.disable_class_column_manager_default"
|
|
45
|
+
>
|
|
46
|
+
</VColumnManager>
|
|
47
|
+
</Teleport>
|
|
48
|
+
<Teleport v-if="isMounted" :to="options.extra_actions_teleport || 'body'" :disabled="!options.extra_actions_teleport">
|
|
49
|
+
<slot name="extra-actions"></slot>
|
|
50
|
+
</Teleport>
|
|
51
|
+
</div>
|
|
39
52
|
|
|
40
|
-
<VExtraActions :use_column_manager="options.use_column_manager" :columns_list="columns_list"
|
|
41
|
-
:toggleColumnVisibility="toggleColumnVisibility">
|
|
42
|
-
<template #extra-actions>
|
|
43
|
-
<slot name="extra-actions">
|
|
44
|
-
</slot>
|
|
45
|
-
</template>
|
|
46
|
-
</VExtraActions>
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
</Teleport>
|
|
50
53
|
</div>
|
|
51
54
|
<slot name="item-selected-info" :selected_items="selected_items" :clearSelection="() => selected_items = []">
|
|
52
55
|
<div v-if="(options.use_checkbox && selected_items.length > 0) && !options.deactivate_selected_info"
|
|
@@ -55,17 +58,9 @@
|
|
|
55
58
|
class="badge bg-azure text-azure-fg">{{
|
|
56
59
|
selected_items.length }}</span></h4>
|
|
57
60
|
<a class=" cursor-pointer " @click="selected_items = []">
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
62
|
-
<path d="M4 7l16 0" />
|
|
63
|
-
<path d="M10 11l0 6" />
|
|
64
|
-
<path d="M14 11l0 6" />
|
|
65
|
-
<path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" />
|
|
66
|
-
<path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" />
|
|
67
|
-
</svg>
|
|
68
|
-
Limpar Seleção</a>
|
|
61
|
+
<component :is="icons.checkbox.clear" />
|
|
62
|
+
Limpar Seleção
|
|
63
|
+
</a>
|
|
69
64
|
</div>
|
|
70
65
|
</slot>
|
|
71
66
|
|
|
@@ -134,24 +129,11 @@
|
|
|
134
129
|
:class="{ 'is-expanded': is_item_expanded(item) }" @click="expand_item_toggle(item)">
|
|
135
130
|
|
|
136
131
|
<template v-if="options.type_button_expand === 'arrow'">
|
|
137
|
-
<
|
|
138
|
-
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
139
|
-
stroke-linejoin="round"
|
|
140
|
-
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right icon-transition-arrow">
|
|
141
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
142
|
-
<path d="M9 6l6 6l-6 6" />
|
|
143
|
-
</svg>
|
|
144
|
-
|
|
132
|
+
<component :is="icons.expand.arrow" />
|
|
145
133
|
</template>
|
|
146
134
|
|
|
147
135
|
<template v-else>
|
|
148
|
-
<
|
|
149
|
-
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
150
|
-
stroke-linejoin="round" class="icon icon-transition-plus">
|
|
151
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
152
|
-
<path d="M12 5l0 14" class="vertical-line" />
|
|
153
|
-
<path d="M5 12l14 0" />
|
|
154
|
-
</svg>
|
|
136
|
+
<component :is="icons.expand.plus" />
|
|
155
137
|
</template>
|
|
156
138
|
|
|
157
139
|
</button>
|
|
@@ -242,7 +224,7 @@
|
|
|
242
224
|
</div>
|
|
243
225
|
</div>
|
|
244
226
|
</div>
|
|
245
|
-
<Teleport :to="options.pagination_teleport || 'body'" :disabled="!options.pagination_teleport">
|
|
227
|
+
<Teleport v-if="isMounted" :to="options.pagination_teleport || 'body'" :disabled="!options.pagination_teleport">
|
|
246
228
|
<slot name="pagination" :pagination="pagination" :tradePage="fetchDataWithDelay" :error="error">
|
|
247
229
|
<div v-if="!error && pagination.count > 0" class="px-3" :class="options.class_pagination">
|
|
248
230
|
<PaginationDatatable :page_starts_at="options.page_starts_at" :filtering="true" :pagination="pagination"
|
|
@@ -260,22 +242,28 @@
|
|
|
260
242
|
|
|
261
243
|
<script setup lang="ts" generic="T extends Record<string, any>">
|
|
262
244
|
import type { VDataTableProps, ExposedFunctions, PaginationObject } from '../types/v-data-table.ts';
|
|
263
|
-
import { readonly, ref, provide, computed, watch, nextTick,
|
|
264
|
-
import { DATA_TABLE_CONFIG } from '@/config/datatableConfig'
|
|
245
|
+
import { readonly, ref, provide, computed, watch, nextTick, onMounted } from 'vue';
|
|
265
246
|
import PaginationDatatable from '@/Pagination/Pagination.vue';
|
|
266
247
|
import Search from './SearchDatatable.vue';
|
|
267
|
-
import
|
|
248
|
+
import VColumnManager from './VColumnManager.vue';
|
|
268
249
|
import { useImagePreview } from '../composables/useImagePreview';
|
|
269
250
|
import { dataTableApiKey, type ColumnConfiguration } from '../keys';
|
|
270
251
|
import draggable from 'vuedraggable';
|
|
271
252
|
import { useExpandedItem } from '../composables/useExpandedItem';
|
|
272
253
|
import { useDataTableFetch } from '../composables/useDataTableFetch';
|
|
273
|
-
import { useCheckBox } from '../composables/useCheckBox
|
|
254
|
+
import { useCheckBox } from '../composables/useCheckBox';
|
|
255
|
+
import { useDataTableConfig } from '../composables/useDataTableConfig';
|
|
274
256
|
import VDataTableLoading from './VDataTableLoading.vue';
|
|
275
257
|
import VThDataTable from './VThDataTable.vue';
|
|
258
|
+
import { buildIcons } from '@/utils/svgFactory'
|
|
259
|
+
import { svgs } from '@/DatatableVue/style/svgs'
|
|
260
|
+
const icons = buildIcons(svgs)
|
|
261
|
+
/*
|
|
262
|
+
Variável responsável por indicar se o componente já foi totalmente montado no DOM.
|
|
263
|
+
Por que é usada: Impede que o componente Teleport tente enviar elementos para uma div que ainda não foi renderizada, evitando quebras na aplicação.
|
|
264
|
+
*/
|
|
265
|
+
const isMounted = ref(false);
|
|
276
266
|
|
|
277
|
-
|
|
278
|
-
const globalConfig = inject(DATA_TABLE_CONFIG, {});
|
|
279
267
|
const {
|
|
280
268
|
isHovering,
|
|
281
269
|
previewSrc,
|
|
@@ -285,80 +273,11 @@ const {
|
|
|
285
273
|
handleMouseLeave
|
|
286
274
|
} = useImagePreview();
|
|
287
275
|
|
|
276
|
+
// Apenas define as props! O que não for passado será undefined, ativando a cascata
|
|
277
|
+
const props = defineProps<VDataTableProps>();
|
|
278
|
+
// mescla a prop com o padrão e o global definido pelo usuario
|
|
279
|
+
const { options } = useDataTableConfig(props);
|
|
288
280
|
|
|
289
|
-
// =======================================================
|
|
290
|
-
// 1. DEFINIÇÃO DE PROPS COM VALORES PADRÃO
|
|
291
|
-
// =======================================================
|
|
292
|
-
const props = withDefaults(defineProps<VDataTableProps>(), {
|
|
293
|
-
fetch_name: '',
|
|
294
|
-
custom_loading: null,
|
|
295
|
-
deactivate_default_params: false,
|
|
296
|
-
|
|
297
|
-
add_params: () => ({}),
|
|
298
|
-
list_filter: () => [],
|
|
299
|
-
|
|
300
|
-
use_checkbox: false,
|
|
301
|
-
|
|
302
|
-
deactivate_selected_info: false,
|
|
303
|
-
immediate: true,
|
|
304
|
-
deactivate_search_on_clear: false,
|
|
305
|
-
use_expandable_items: false,
|
|
306
|
-
close_expanded_item_on_expand_new: false,
|
|
307
|
-
scroll_to_expanded_item: false,
|
|
308
|
-
type_animation_expand: 'expand',
|
|
309
|
-
deactivate_animation_expand: false,
|
|
310
|
-
type_button_expand: 'arrow',
|
|
311
|
-
deactivate_search_empty: false,
|
|
312
|
-
disable_request: false,
|
|
313
|
-
disable_search: false,
|
|
314
|
-
pagination_teleport: null,
|
|
315
|
-
search_teleport: null,
|
|
316
|
-
show_header_when_empty: false,
|
|
317
|
-
storage_id: '',
|
|
318
|
-
use_column_manager: false,
|
|
319
|
-
});
|
|
320
|
-
const options = computed(() => {
|
|
321
|
-
return {
|
|
322
|
-
// Primeiro, espelha todas as props originais.
|
|
323
|
-
...props,
|
|
324
|
-
|
|
325
|
-
// Agora SOBRESCREVEMOS as propriedades que precisam de lógica Global/Default
|
|
326
|
-
// (Prioridade para Prop, mas aceita Global)
|
|
327
|
-
|
|
328
|
-
// === TEXTOS ===
|
|
329
|
-
first_text_page_size: props.first_text_page_size ?? globalConfig.first_text_page_size ?? 'Mostrar',
|
|
330
|
-
second_text_page_size: props.second_text_page_size ?? globalConfig.second_text_page_size ?? 'registros',
|
|
331
|
-
placeholder_search: props.placeholder_search ?? globalConfig.placeholder_search ?? 'Buscar...',
|
|
332
|
-
|
|
333
|
-
// === CLASSES ===
|
|
334
|
-
class_table: props.class_table || globalConfig.class_table || '',
|
|
335
|
-
class_pagination: props.class_pagination || globalConfig.class_pagination || '',
|
|
336
|
-
class_container: props.class_container || globalConfig.class_container || '',
|
|
337
|
-
class_content: props.class_content || globalConfig.class_content || '',
|
|
338
|
-
class_filters: props.class_filters || globalConfig.class_filters || '',
|
|
339
|
-
class_page_size: props.class_page_size || globalConfig.class_page_size || '',
|
|
340
|
-
|
|
341
|
-
// === CONFIGURAÇÃO DE API ===
|
|
342
|
-
filter_param_name: props.filter_param_name ?? globalConfig.filter_param_name ?? 'filter',
|
|
343
|
-
search_param_name: props.search_param_name ?? globalConfig.search_param_name ?? 'search',
|
|
344
|
-
page_param_name: props.page_param_name ?? globalConfig.page_param_name ?? 'page',
|
|
345
|
-
page_size_param_name: props.page_size_param_name ?? globalConfig.page_size_param_name ?? 'page_size',
|
|
346
|
-
page_starts_at: props.page_starts_at ?? globalConfig.page_starts_at ?? 0,
|
|
347
|
-
item_key: props.item_key ?? globalConfig.item_key ?? 'id',
|
|
348
|
-
data_key: props.data_key ?? globalConfig.data_key ?? 'results',
|
|
349
|
-
total_key: props.total_key ?? globalConfig.total_key ?? 'count',
|
|
350
|
-
|
|
351
|
-
// === COMPORTAMENTO ===
|
|
352
|
-
limit_per_page: props.limit_per_page ?? globalConfig.limit_per_page ?? 5,
|
|
353
|
-
type_loading: props.type_loading ?? globalConfig.type_loading ?? 'placeholder',
|
|
354
|
-
min_loading_delay: props.min_loading_delay ?? globalConfig.min_loading_delay ?? 600,
|
|
355
|
-
retry_attempts: props.retry_attempts ?? globalConfig.retry_attempts ?? 3,
|
|
356
|
-
retry_delay: props.retry_delay ?? globalConfig.retry_delay ?? 2000,
|
|
357
|
-
show_header_when_empty: props.show_header_when_empty ?? globalConfig.show_header_when_empty ?? false,
|
|
358
|
-
storage_id: props.storage_id ?? globalConfig.storage_id ?? '',
|
|
359
|
-
use_column_manager: props.use_column_manager ?? globalConfig.use_column_manager ?? false,
|
|
360
|
-
};
|
|
361
|
-
});
|
|
362
281
|
const emit = defineEmits(['tradePage', 'beforeFetch', 'afterFetch', 'clickedClearSearch']);
|
|
363
282
|
|
|
364
283
|
// =======================================================
|
|
@@ -741,6 +660,7 @@ defineExpose<ExposedFunctions<T>>({
|
|
|
741
660
|
});
|
|
742
661
|
|
|
743
662
|
onMounted(() => {
|
|
663
|
+
isMounted.value = true;
|
|
744
664
|
if (options.value.immediate) {
|
|
745
665
|
nextTick(() => {
|
|
746
666
|
reSearch();
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span v-if="use_ordering" @click="emit('toggle')" class="cursor-pointer">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<path d="m3 8 4-4 4 4"></path>
|
|
7
|
-
<path d="m11 16-4 4-4-4"></path>
|
|
8
|
-
<path d="M7 4v16"></path>
|
|
9
|
-
<path d="M15 8h6"></path>
|
|
10
|
-
<path d="M15 16h6"></path>
|
|
11
|
-
<path d="M13 12h8"></path>
|
|
12
|
-
</svg>
|
|
13
|
-
|
|
14
|
-
<svg v-else-if="props.orderings_state === 'decreasing'" xmlns="http://www.w3.org/2000/svg" width="16"
|
|
15
|
-
height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
16
|
-
stroke-linejoin="round">
|
|
17
|
-
<path d="m3 16 4 4 4-4"></path>
|
|
18
|
-
<path d="M7 20V4"></path>
|
|
19
|
-
<path d="M11 4h10"></path>
|
|
20
|
-
<path d="M11 8h7"></path>
|
|
21
|
-
<path d="M11 12h4"></path>
|
|
22
|
-
</svg>
|
|
23
|
-
|
|
24
|
-
<svg v-else-if="props.orderings_state === 'increasing'" xmlns="http://www.w3.org/2000/svg" width="16"
|
|
25
|
-
height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
26
|
-
stroke-linejoin="round">
|
|
27
|
-
<path d="m3 8 4-4 4 4"></path>
|
|
28
|
-
<path d="M7 4v16"></path>
|
|
29
|
-
<path d="M11 12h4"></path>
|
|
30
|
-
<path d="M11 16h7"></path>
|
|
31
|
-
<path d="M11 20h10"></path>
|
|
32
|
-
</svg>
|
|
3
|
+
<component v-if="!props.orderings_state || props.orderings_state === 'none'" :is="icons.ordering.default" />
|
|
4
|
+
<component v-else-if="props.orderings_state === 'decreasing'" :is="icons.ordering.decreasing" />
|
|
5
|
+
<component v-else-if="props.orderings_state === 'increasing'" :is="icons.ordering.increasing" />
|
|
33
6
|
</span>
|
|
34
7
|
</template>
|
|
35
8
|
|
|
@@ -39,6 +12,10 @@
|
|
|
39
12
|
Componente interno de uso exclusivo do VDataTable para renderizar o ícone de ordenação.
|
|
40
13
|
========
|
|
41
14
|
*/
|
|
15
|
+
import { buildIcons } from '@/utils/svgFactory'
|
|
16
|
+
import { svgs } from '@/DatatableVue/style/svgs'
|
|
17
|
+
const icons = buildIcons(svgs)
|
|
18
|
+
|
|
42
19
|
const props = defineProps<{
|
|
43
20
|
orderings_state?: 'none' | 'increasing' | 'decreasing';
|
|
44
21
|
use_ordering?: boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
========
|
|
3
|
+
Responsável por mesclar as propriedades recebidas pelo componente VDataTable com a configuração global da aplicação.
|
|
4
|
+
========
|
|
5
|
+
*/
|
|
6
|
+
import { computed, inject } from 'vue';
|
|
7
|
+
import { DATA_TABLE_CONFIG } from '@/DatatableVue/config/datatableConfig';
|
|
8
|
+
import type { VDataTableProps, DataTablePropsWithDefaults } from '../types/v-data-table';
|
|
9
|
+
import { defaultDataTableConfig } from '@/DatatableVue/config/datatableDefaults';
|
|
10
|
+
/*
|
|
11
|
+
Função que gera as opções finais da tabela.
|
|
12
|
+
Recebe: As propriedades (props) originais do componente.
|
|
13
|
+
Devolve: Um objeto reativo (computed) com todas as propriedades mescladas com os valores globais.
|
|
14
|
+
Por que é usada: Limpa o componente principal, isolando a lógica de fallback de configurações e facilitando a manutenção de novas propriedades.
|
|
15
|
+
*/
|
|
16
|
+
export function useDataTableConfig(props: VDataTableProps) {
|
|
17
|
+
const globalConfig = inject(DATA_TABLE_CONFIG, {});
|
|
18
|
+
|
|
19
|
+
const options = computed<DataTablePropsWithDefaults>(() => {
|
|
20
|
+
// 1. Filtramos as props do componente para remover tudo que for "undefined".
|
|
21
|
+
// Se não fizermos isso, uma prop undefined vai esmagar a configuração global na hora de mesclar.
|
|
22
|
+
const propsPassadasPeloUsuario = Object.fromEntries(
|
|
23
|
+
Object.entries(props).filter(([_, valor]) => valor !== undefined)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// 2. O Merge Dinâmico!
|
|
27
|
+
// A ordem importa! O que vem por último sobrescreve o anterior.
|
|
28
|
+
// (Prop > Global > Default)
|
|
29
|
+
return {
|
|
30
|
+
...defaultDataTableConfig, // 1º Camada: Prioridade Mínima (Valores Padrão)
|
|
31
|
+
...globalConfig, // 2º Camada: Prioridade Média (Valores Globais definidos por quem usa o plugin)
|
|
32
|
+
...propsPassadasPeloUsuario // 3º Camada: Prioridade Máxima (O que o dev digitou na tela)
|
|
33
|
+
} as DataTablePropsWithDefaults;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return { options };
|
|
37
|
+
}
|
|
@@ -5,4 +5,4 @@ import type { VDataTableProps } from '@/DatatableVue/types/v-data-table';
|
|
|
5
5
|
export type DataTableGlobalConfig = Partial<VDataTableProps>;
|
|
6
6
|
|
|
7
7
|
// A chave para o provide/inject
|
|
8
|
-
export const DATA_TABLE_CONFIG: InjectionKey<DataTableGlobalConfig> = Symbol('DataTableConfig');
|
|
8
|
+
export const DATA_TABLE_CONFIG: InjectionKey<DataTableGlobalConfig> = Symbol('DataTableConfig');
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { VDataTableProps } from '@/DatatableVue/types/v-data-table';
|
|
2
|
+
//o Partial para dizer que no global não precisamos passar TUDO
|
|
3
|
+
export type DataTableGlobalConfig = Partial<VDataTableProps>;
|
|
4
|
+
/**
|
|
5
|
+
* nesse arquivo todas as props que não são obrigatórias ou seja que tem ?: definidas
|
|
6
|
+
* no typescript, são definidas aqui com valores default
|
|
7
|
+
* **/
|
|
8
|
+
export const defaultDataTableConfig: DataTableGlobalConfig = {
|
|
9
|
+
// Configurações de API
|
|
10
|
+
|
|
11
|
+
fetch_name: '',
|
|
12
|
+
custom_loading: null,
|
|
13
|
+
deactivate_default_params: false,
|
|
14
|
+
|
|
15
|
+
add_params: {},
|
|
16
|
+
list_filter: [],
|
|
17
|
+
|
|
18
|
+
use_checkbox: false,
|
|
19
|
+
|
|
20
|
+
deactivate_selected_info: false,
|
|
21
|
+
immediate: true,
|
|
22
|
+
deactivate_search_on_clear: false,
|
|
23
|
+
use_expandable_items: false,
|
|
24
|
+
close_expanded_item_on_expand_new: false,
|
|
25
|
+
scroll_to_expanded_item: false,
|
|
26
|
+
type_animation_expand: 'expand',
|
|
27
|
+
deactivate_animation_expand: false,
|
|
28
|
+
type_button_expand: 'arrow',
|
|
29
|
+
deactivate_search_empty: false,
|
|
30
|
+
disable_request: false,
|
|
31
|
+
disable_search: false,
|
|
32
|
+
pagination_teleport: null,
|
|
33
|
+
search_teleport: null,
|
|
34
|
+
extra_actions_teleport: null,
|
|
35
|
+
column_manager_teleport: null,
|
|
36
|
+
|
|
37
|
+
// Classes Estruturais Base
|
|
38
|
+
class_column_manager_dropdown: '',
|
|
39
|
+
class_column_manager_dropdown_menu: '',
|
|
40
|
+
class_column_manager_button: '',
|
|
41
|
+
disable_class_column_manager_default: false,
|
|
42
|
+
|
|
43
|
+
// === TEXTOS ===
|
|
44
|
+
first_text_page_size: 'Mostrar',
|
|
45
|
+
second_text_page_size: 'registros',
|
|
46
|
+
placeholder_search: 'Buscar...',
|
|
47
|
+
|
|
48
|
+
// === CLASSES ===
|
|
49
|
+
class_table: '',
|
|
50
|
+
class_pagination: '',
|
|
51
|
+
class_container: '',
|
|
52
|
+
class_content: '',
|
|
53
|
+
class_filters: '',
|
|
54
|
+
class_page_size: '',
|
|
55
|
+
|
|
56
|
+
// === CONFIGURAÇÃO DE API ===
|
|
57
|
+
filter_param_name: 'filter',
|
|
58
|
+
search_param_name: 'search',
|
|
59
|
+
page_param_name: 'page',
|
|
60
|
+
page_size_param_name: 'page_size',
|
|
61
|
+
page_starts_at: 0,
|
|
62
|
+
item_key: 'id',
|
|
63
|
+
data_key: 'results',
|
|
64
|
+
total_key: 'count',
|
|
65
|
+
|
|
66
|
+
// === COMPORTAMENTO ===
|
|
67
|
+
limit_per_page: 5,
|
|
68
|
+
type_loading: 'placeholder',
|
|
69
|
+
min_loading_delay: 600,
|
|
70
|
+
retry_attempts: 3,
|
|
71
|
+
retry_delay: 2000,
|
|
72
|
+
show_header_when_empty: false,
|
|
73
|
+
storage_id: '',
|
|
74
|
+
use_column_manager: false,
|
|
75
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
========
|
|
3
|
+
Arquivo responsável por armazenar as strings brutas de todos os SVGs utilizados pelo sistema.
|
|
4
|
+
Ele exporta um objeto contendo as marcações XML dos ícones para serem processados pela fábrica de componentes.
|
|
5
|
+
========
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { SvgSource } from '@/utils/svgFactory';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
Objeto que armazena as strings dos ícones SVG.
|
|
12
|
+
Por que é usada: Centraliza os ícones do sistema. Usa o operador 'satisfies' para garantir a integridade estrutural sem perder o autocompletar das chaves literais (search, filter, etc) na tipagem estrita.
|
|
13
|
+
*/
|
|
14
|
+
export const svgs = {
|
|
15
|
+
search: {
|
|
16
|
+
filter: `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-filter" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"> </path> </svg>`,
|
|
17
|
+
clear: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-x"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M18 6l-12 12" /> <path d="M6 6l12 12" /> </svg>`,
|
|
18
|
+
loupe: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path> <path d="M21 21l-6 -6"></path> </svg>`,
|
|
19
|
+
},
|
|
20
|
+
checkbox: {
|
|
21
|
+
clear :` <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-trash"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M4 7l16 0" /> <path d="M10 11l0 6" /> <path d="M14 11l0 6" /> <path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /> <path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" /> </svg> `,
|
|
22
|
+
},
|
|
23
|
+
expand: {
|
|
24
|
+
arrow: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right icon-transition-arrow"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 6l6 6l-6 6" /></svg>`,
|
|
25
|
+
plus: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-transition-plus"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 5l0 14" class="vertical-line" /><path d="M5 12l14 0" /></svg>`,
|
|
26
|
+
},
|
|
27
|
+
ordering: {
|
|
28
|
+
default: ` <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m3 8 4-4 4 4"></path> <path d="m11 16-4 4-4-4"></path> <path d="M7 4v16"></path> <path d="M15 8h6"></path> <path d="M15 16h6"></path> <path d="M13 12h8"></path> </svg> `,
|
|
29
|
+
decreasing:` <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m3 16 4 4 4-4"></path> <path d="M7 20V4"></path> <path d="M11 4h10"></path> <path d="M11 8h7"></path> <path d="M11 12h4"></path> </svg> `,
|
|
30
|
+
increasing:` <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="m3 8 4-4 4 4"></path> <path d="M7 4v16"></path> <path d="M11 12h4"></path> <path d="M11 16h7"></path> <path d="M11 20h10"></path> </svg> </span> `,
|
|
31
|
+
},
|
|
32
|
+
column_manager: ` <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-columns" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M4 6l5.5 0" /> <path d="M4 10l5.5 0" /> <path d="M4 14l5.5 0" /> <path d="M4 18l5.5 0" /> <path d="M14.5 6l5.5 0" /> <path d="M14.5 10l5.5 0" /> <path d="M14.5 14l5.5 0" /> <path d="M14.5 18l5.5 0" /> </svg> `,
|
|
33
|
+
} satisfies SvgSource;
|