v-sistec-features 1.14.0 → 1.16.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/v-sistec-features.css +1 -1
- package/dist/vDataPage.d.ts +2 -0
- package/dist/vDataPage.js +52 -50
- package/dist/vDataTable.d.ts +8 -2
- package/dist/vDataTable.js +324 -315
- package/package.json +1 -1
- package/src/DataPageVue/components/VDataPage.vue +4 -2
- package/src/DataPageVue/types/v-data-page.ts +4 -1
- package/src/DatatableVue/components/VColumn.vue +5 -1
- package/src/DatatableVue/components/VDataTable.vue +24 -4
- package/src/DatatableVue/keys.ts +1 -1
package/package.json
CHANGED
|
@@ -110,7 +110,8 @@ const props = withDefaults(defineProps<VDataPageProps>(), {
|
|
|
110
110
|
page_starts_at: 0,
|
|
111
111
|
element_id: '',
|
|
112
112
|
class_loading_container: '',
|
|
113
|
-
watch: () => []
|
|
113
|
+
watch: () => [],
|
|
114
|
+
disable_request: false,
|
|
114
115
|
});
|
|
115
116
|
|
|
116
117
|
|
|
@@ -145,8 +146,9 @@ const pagination = ref<PaginationObject>({
|
|
|
145
146
|
// 3. LÓGICA DA API (useFetch)
|
|
146
147
|
// =======================================================
|
|
147
148
|
const { data: response, pending: pending, error, execute, attempt: _attempt } = props.fetch(props.endpoint, {
|
|
149
|
+
disable_request: () => props.disable_request,
|
|
148
150
|
params: () => {
|
|
149
|
-
|
|
151
|
+
|
|
150
152
|
if (props.deactivate_default_params) {
|
|
151
153
|
if (props.add_params && typeof props.add_params === 'function') {
|
|
152
154
|
return props.add_params();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ref, Component, WatchSource } from 'vue';
|
|
1
|
+
import type { Ref, Component, WatchSource, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
|
|
3
3
|
export interface VDataPageProps {
|
|
4
4
|
/* configuração do useApiFetch */
|
|
@@ -61,6 +61,7 @@ export interface VDataPageProps {
|
|
|
61
61
|
page_starts_at?: number;
|
|
62
62
|
element_id?: string;
|
|
63
63
|
watch?: WatchSource[];
|
|
64
|
+
disable_request?: MaybeRefOrGetter<boolean>;
|
|
64
65
|
}
|
|
65
66
|
export interface PaginationObject {
|
|
66
67
|
current_page: number;
|
|
@@ -78,4 +79,6 @@ export interface ExposedFunctions {
|
|
|
78
79
|
set_filter: (newFilter: string) => void;
|
|
79
80
|
set_page: (newPage: number) => void;
|
|
80
81
|
reSearch: () => void;
|
|
82
|
+
|
|
83
|
+
|
|
81
84
|
}
|
|
@@ -7,7 +7,8 @@ import { inject, onMounted, useSlots, defineSlots } from 'vue';
|
|
|
7
7
|
import { dataTableApiKey } from '../keys';
|
|
8
8
|
|
|
9
9
|
defineSlots<{
|
|
10
|
-
|
|
10
|
+
// props para o slot body
|
|
11
|
+
body?: (props: { item: any }) => any,
|
|
11
12
|
}>();
|
|
12
13
|
interface VColumnProps {
|
|
13
14
|
field?: string | null;
|
|
@@ -27,6 +28,7 @@ interface VColumnProps {
|
|
|
27
28
|
param_ordering?: string;
|
|
28
29
|
decreasing_value?: string;
|
|
29
30
|
increasing_value?: string;
|
|
31
|
+
class_rules?: Record<string, (item: any) => boolean>;
|
|
30
32
|
}
|
|
31
33
|
const props = withDefaults(defineProps<VColumnProps>(), {
|
|
32
34
|
field: null,
|
|
@@ -58,6 +60,7 @@ const props = withDefaults(defineProps<VColumnProps>(), {
|
|
|
58
60
|
param_ordering: '',
|
|
59
61
|
decreasing_value: '',
|
|
60
62
|
increasing_value: '',
|
|
63
|
+
class_rules: () => ({}),
|
|
61
64
|
});
|
|
62
65
|
|
|
63
66
|
const slots = useSlots();
|
|
@@ -107,6 +110,7 @@ onMounted(() => {
|
|
|
107
110
|
param_ordering: props.param_ordering,
|
|
108
111
|
decreasing_value: props.decreasing_value,
|
|
109
112
|
increasing_value: props.increasing_value,
|
|
113
|
+
class_rules: props.class_rules,
|
|
110
114
|
|
|
111
115
|
bodySlot: slots.body,
|
|
112
116
|
...(props.type === 'text' && { limite_text: Number(props.limite_text) }),
|
|
@@ -326,13 +326,13 @@
|
|
|
326
326
|
<td v-for="col in renderedColumns" :key="col.field || col.header" :class="col.class_row">
|
|
327
327
|
<component v-if="col.bodySlot" :is="col.bodySlot" :item="item" :is-selected="isSelected(item)" />
|
|
328
328
|
<span @click="col.click ? col.click(item) : null"
|
|
329
|
-
:class="
|
|
329
|
+
:class="computeClasses(col, item)" v-else-if="col.type === 'text'">
|
|
330
330
|
{{
|
|
331
331
|
limiteText(getSubItem(col.field, item, col.transform_function), col.limite_text ?? null)
|
|
332
332
|
}}</span>
|
|
333
333
|
|
|
334
334
|
<span @click="col.click ? col.click(item) : null" v-else-if="col.type === 'date'"
|
|
335
|
-
:class="
|
|
335
|
+
:class="computeClasses(col, item)">
|
|
336
336
|
<span v-if="col.format === 'complete'">{{ new Date(getSubItem(col.field, item)).toLocaleString()
|
|
337
337
|
}}</span>
|
|
338
338
|
<span v-if="col.format === 'simple'"> {{ new Date(getSubItem(col.field,
|
|
@@ -340,12 +340,12 @@
|
|
|
340
340
|
}} </span>
|
|
341
341
|
</span>
|
|
342
342
|
<div @click="col.click ? col.click(item) : null"
|
|
343
|
-
:class="
|
|
343
|
+
:class="computeClasses(col, item)" v-else-if="col.type === 'html'"
|
|
344
344
|
v-html="getSubItem(col.field, item)">
|
|
345
345
|
</div>
|
|
346
346
|
|
|
347
347
|
<div @click="col.click ? col.click(item) : null"
|
|
348
|
-
:class="
|
|
348
|
+
:class="computeClasses(col, item)" v-else-if="col.type === 'img'">
|
|
349
349
|
|
|
350
350
|
<div v-if="getSubItem(col.field, item)" v-bind="col.deactivate_img_preview ? {
|
|
351
351
|
class: 'container-img'
|
|
@@ -852,6 +852,26 @@ function tradePageEmit(): void {
|
|
|
852
852
|
fetchDataWithDelay();
|
|
853
853
|
|
|
854
854
|
}
|
|
855
|
+
const computeClasses = (col: ColumnConfiguration, item: T) => {
|
|
856
|
+
// Pega a classe estática padrão
|
|
857
|
+
const classes = [col.class_item || ''];
|
|
858
|
+
|
|
859
|
+
// Se a coluna for clicável, adiciona cursor-pointer automaticamente
|
|
860
|
+
if (col.click) {
|
|
861
|
+
classes.push('cursor-pointer');
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Processa as regras dinâmicas (class_rules)
|
|
865
|
+
if (col.class_rules) {
|
|
866
|
+
for (const [className, ruleValidator] of Object.entries(col.class_rules)) {
|
|
867
|
+
if (typeof ruleValidator === 'function' && ruleValidator(item)) {
|
|
868
|
+
classes.push(className);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
return classes.join(' ').trim();
|
|
874
|
+
};
|
|
855
875
|
|
|
856
876
|
defineExpose<ExposedFunctions<T>>({
|
|
857
877
|
execute: fetchDataWithDelay,
|
package/src/DatatableVue/keys.ts
CHANGED