v-sistec-features 1.15.0 → 1.17.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/iframeCommunicator.js +1 -1
- package/dist/index.js +1 -1
- package/dist/useThemeFromParent-iwlNh_Mm.js +31 -0
- package/dist/v-sistec-features.css +1 -1
- package/dist/vDataTable.d.ts +8 -2
- package/dist/vDataTable.js +324 -315
- package/package.json +1 -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/src/iframeCommunicator/useThemeFromParent.ts +39 -23
- package/dist/useThemeFromParent-Bk-du0-V.js +0 -29
package/package.json
CHANGED
|
@@ -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
|
@@ -1,32 +1,48 @@
|
|
|
1
1
|
import { useIframeCommunicator } from './useIframeCommunicator';
|
|
2
|
-
import { onMounted } from 'vue';
|
|
2
|
+
import { onMounted, ref } from 'vue';
|
|
3
3
|
|
|
4
|
-
function handleThemeMessage(event: MessageEvent) {
|
|
5
|
-
if (event.data.type === 'setTheme') {
|
|
6
|
-
document.documentElement.setAttribute('data-bs-theme', event.data.theme);
|
|
7
|
-
}
|
|
8
|
-
if (event.data.type === 'setThemePrimary') {
|
|
9
|
-
document.documentElement.setAttribute('data-bs-theme-primary', event.data.themePrimary);
|
|
10
|
-
}
|
|
11
|
-
if (event.data.type === 'setThemeBase') {
|
|
12
|
-
document.documentElement.setAttribute('data-bs-theme-base', event.data.themeBase);
|
|
13
|
-
}
|
|
14
|
-
if (event.data.type === 'reload') {
|
|
15
|
-
location.reload();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
4
|
|
|
19
5
|
/**
|
|
20
6
|
* Um composable "tudo-em-um" que configura a comunicação de temas com a janela pai.
|
|
21
7
|
* para usar, bastar importar e chamar useTheme() na raiz do component app do iframe
|
|
22
8
|
*/
|
|
23
9
|
export function useTheme() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
|
|
11
|
+
// Usa o composable genérico, passando o handler de temas, assim ele já configura
|
|
12
|
+
// o listener e o que é feito quando receber uma mensagem do pai referente a tema
|
|
13
|
+
const theme = ref('light');
|
|
14
|
+
const themePalette = ref('slate');
|
|
15
|
+
const themePrimary = ref('');
|
|
16
|
+
|
|
17
|
+
function handleThemeMessage(event: MessageEvent) {
|
|
18
|
+
const data = event.data;
|
|
19
|
+
|
|
20
|
+
// Validação básica para evitar erros se data for nulo
|
|
21
|
+
if (!data) return;
|
|
22
|
+
|
|
23
|
+
if (data.type === 'setTheme') {
|
|
24
|
+
document.documentElement.setAttribute('data-bs-theme', data.theme);
|
|
25
|
+
theme.value = data.theme;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (data.type === 'setThemePrimary') {
|
|
29
|
+
document.documentElement.setAttribute('data-bs-theme-primary', data.themePrimary);
|
|
30
|
+
themePrimary.value = data.themePrimary;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (data.type === 'setThemeBase') {
|
|
34
|
+
document.documentElement.setAttribute('data-bs-theme-base', data.themeBase);
|
|
35
|
+
themePalette.value = data.themeBase;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (data.type === 'reload') {
|
|
39
|
+
location.reload();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const { sendMessage } = useIframeCommunicator(handleThemeMessage);
|
|
43
|
+
|
|
44
|
+
// passa uma mensagem para o pai avisando que o iframe está pronto para receber temas
|
|
45
|
+
onMounted(() => {
|
|
46
|
+
sendMessage({ type: 'iframeReady' });
|
|
47
|
+
});
|
|
32
48
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ref as o, onMounted as a, onUnmounted as d, readonly as r } from "vue";
|
|
2
|
-
function i(e) {
|
|
3
|
-
const t = o(window.parent !== window);
|
|
4
|
-
function m(n, s = "*") {
|
|
5
|
-
t.value && window.parent.postMessage(n, s);
|
|
6
|
-
}
|
|
7
|
-
return a(() => {
|
|
8
|
-
e && window.addEventListener("message", e);
|
|
9
|
-
}), d(() => {
|
|
10
|
-
e && window.removeEventListener("message", e);
|
|
11
|
-
}), {
|
|
12
|
-
isInIframe: r(t),
|
|
13
|
-
// readonly para evitar modificação externa
|
|
14
|
-
sendMessage: m
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function u(e) {
|
|
18
|
-
e.data.type === "setTheme" && document.documentElement.setAttribute("data-bs-theme", e.data.theme), e.data.type === "setThemePrimary" && document.documentElement.setAttribute("data-bs-theme-primary", e.data.themePrimary), e.data.type === "setThemeBase" && document.documentElement.setAttribute("data-bs-theme-base", e.data.themeBase), e.data.type === "reload" && location.reload();
|
|
19
|
-
}
|
|
20
|
-
function h() {
|
|
21
|
-
const { sendMessage: e } = i(u);
|
|
22
|
-
a(() => {
|
|
23
|
-
e({ type: "iframeReady" });
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
h as a,
|
|
28
|
-
i as u
|
|
29
|
-
};
|