v-sistec-features 1.24.0 → 1.26.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.
@@ -1,56 +1,22 @@
1
1
  <template>
2
2
  <th :class="class_all">
3
3
  <div :class="{ 'header-ordering': use_ordering }">
4
-
5
- <component
6
- v-if="hasCustomHeader"
7
- :is="col.colHeaderSlot"
8
- v-bind="{ col: props.col, locked: props.locked }"
9
- ></component>
10
-
11
- <template v-else>
12
- <span>
13
- {{ props.header }}
14
- </span>
15
4
 
16
- <component
17
- v-if="col.colHeaderMidleSlot"
18
- :is="col.colHeaderMidleSlot"
19
- v-bind="{ col: props.col, locked: props.locked }"
20
- ></component>
5
+ <component v-if="hasCustomHeader" :is="col.colHeaderSlot"
6
+ v-bind="{ col: props.col, locked: props.locked, OrderingComponent }"></component>
7
+
8
+ <template v-else>
9
+ <div class="d-flex justify-content-between align-items-center">
10
+ <span>
11
+ {{ props.header }}
12
+ </span>
21
13
 
22
- <span v-if="use_ordering" @click="emit('toggleOrderingState')" class="ms-2 cursor-pointer">
23
- <svg v-if="!props.orderings_state || props.orderings_state === 'none'" xmlns="http://www.w3.org/2000/svg"
24
- width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
25
- stroke-linecap="round" stroke-linejoin="round">
26
- <path d="m3 8 4-4 4 4"></path>
27
- <path d="m11 16-4 4-4-4"></path>
28
- <path d="M7 4v16"></path>
29
- <path d="M15 8h6"></path>
30
- <path d="M15 16h6"></path>
31
- <path d="M13 12h8"></path>
32
- </svg>
14
+ <component v-if="col.colHeaderMidleSlot" :is="col.colHeaderMidleSlot"
15
+ v-bind="{ col: props.col, locked: props.locked }"></component>
33
16
 
34
- <svg v-else-if="props.orderings_state === 'decreasing'" xmlns="http://www.w3.org/2000/svg" width="16"
35
- height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
36
- stroke-linejoin="round">
37
- <path d="m3 16 4 4 4-4"></path>
38
- <path d="M7 20V4"></path>
39
- <path d="M11 4h10"></path>
40
- <path d="M11 8h7"></path>
41
- <path d="M11 12h4"></path>
42
- </svg>
17
+ <component :is="OrderingComponent" />
18
+ </div>
43
19
 
44
- <svg v-else-if="props.orderings_state === 'increasing'" xmlns="http://www.w3.org/2000/svg" width="16"
45
- height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
46
- stroke-linejoin="round">
47
- <path d="m3 8 4-4 4 4"></path>
48
- <path d="M7 4v16"></path>
49
- <path d="M11 12h4"></path>
50
- <path d="M11 16h7"></path>
51
- <path d="M11 20h10"></path>
52
- </svg>
53
- </span>
54
20
  </template>
55
21
 
56
22
  </div>
@@ -58,8 +24,8 @@
58
24
  </template>
59
25
 
60
26
  <script setup lang="ts">
61
- import { computed, Comment, Fragment, Text } from 'vue';
62
-
27
+ import { computed, Comment, Fragment, Text, h } from 'vue';
28
+ import VOrderingIcon from './VOrderingIcon.vue';
63
29
  const props = defineProps<{
64
30
  header: string;
65
31
  class_column: string;
@@ -68,7 +34,11 @@ const props = defineProps<{
68
34
  orderings_state: 'none' | 'increasing' | 'decreasing';
69
35
  col: any;
70
36
  }>();
71
-
37
+ const OrderingComponent = () => h(VOrderingIcon, {
38
+ orderings_state: props.orderings_state,
39
+ use_ordering: props.use_ordering,
40
+ onToggle: () => emit('toggleOrderingState')
41
+ });
72
42
  const class_all = computed(() => {
73
43
  return {
74
44
  'header-draggable': !props.locked,
@@ -15,10 +15,9 @@ export function useDataTableFetch<T>(
15
15
  const items = ref<T[]>([]) as Ref<T[]>;
16
16
 
17
17
  const urlReativa = computed(() => {
18
- pagination.value.current_page = props.page_starts_at;
19
18
  return props.endpoint;
20
19
  });
21
-
20
+
22
21
  const default_params = computed<Record<string, any>>(() => ({
23
22
  [props.page_param_name]: pagination.value.current_page + 1,
24
23
  [props.page_size_param_name]: pagination.value.limit_per_page,
@@ -30,9 +29,9 @@ export function useDataTableFetch<T>(
30
29
  const objectOrdering: Record<string, any> = {};
31
30
  for (const col of columns.value) {
32
31
  if (col.use_ordering) {
33
- if (orderings_state.value[col.header] === 'increasing') {
32
+ if (orderings_state.value[col.id] === 'increasing') {
34
33
  objectOrdering[col.param_ordering] = col.increasing_value || 'increasing';
35
- } else if (orderings_state.value[col.header] === 'decreasing') {
34
+ } else if (orderings_state.value[col.id] === 'decreasing') {
36
35
  objectOrdering[col.param_ordering] = col.decreasing_value || 'decreasing';
37
36
  }
38
37
  }
@@ -22,6 +22,12 @@ export interface ColumnConfiguration {
22
22
  decreasing_value: string;
23
23
  increasing_value: string;
24
24
  class_rules?: Record<string, (item: any) => boolean>;
25
+ start_hidden?: boolean;
26
+ // não é prop, é uma propriedade interna do VDataTable para controlar a visibilidade da coluna
27
+ visible?: boolean;
28
+ id: string; // ID único da coluna, gerado internamente pelo VDataTable
29
+ // Chave gerada dinamicamente para salvar e recuperar o estado da coluna no localstorage
30
+ storage_key?: string;
25
31
  }
26
32
 
27
33
  // A API que o VDataTable "fornece" para os filhos
@@ -78,6 +78,9 @@ export interface VDataTableProps {
78
78
  pagination_teleport?: string | HTMLElement | null;
79
79
  search_teleport?: string | HTMLElement | null;
80
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;
81
84
  }
82
85
  export type DataTablePropsWithDefaults = VDataTableProps & {
83
86
  // Strings
@@ -129,6 +132,8 @@ export type DataTablePropsWithDefaults = VDataTableProps & {
129
132
  add_params: Record<string, any> | (() => Record<string, any>);
130
133
  list_filter: any[];
131
134
  custom_loading: any | null;
135
+ storage_id: string;
136
+ use_column_manager: boolean;
132
137
  };
133
138
  export interface ExposedFunctions<T extends Record<string, any>> {
134
139
  execute: () => void;
@@ -144,4 +149,13 @@ export interface ExposedFunctions<T extends Record<string, any>> {
144
149
  expand_item_toggle: (item: any) => void;
145
150
  close_all_expanded_items: () => void;
146
151
  selectAllCheckbox: Ref<HTMLInputElement | null>;
152
+ toggleColumnVisibility: (field: string) => void;
153
+ columns_list: ComputedRef<Array<{
154
+ id: string;
155
+ header: string;
156
+ field: string | null;
157
+ start_hidden: boolean;
158
+ visible: boolean;
159
+ locked: boolean;
160
+ }>>;
147
161
  }