Skip to content

Commit 60a633b

Browse files
authored
Merge pull request #936 from Sysvale/bugfix/data-table-slots
Bugfix/data table slots
2 parents 56da1f0 + aa9bfe1 commit 60a633b

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.115.1",
3+
"version": "3.115.2",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",

src/components/DataTable.vue

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,45 @@
66
{{ totalItems }} registros encontrados
77
</div>
88

9-
<!-- @slot Slot para renderização de conteúdo à direita do DataTable header. -->
10-
<div v-if="hasSlots">
9+
<cds-flexbox
10+
gap="3"
11+
align="center"
12+
>
13+
<!-- @slot Slot para renderização de conteúdo à direita do DataTable header. -->
1114
<slot name="right" />
12-
</div>
1315

14-
<div v-else>
1516
<cds-button
17+
v-if="!hideCustomizeButton"
1618
size="sm"
1719
secondary
1820
@button-click="showSideSheet = true"
1921
>
2022
Personalizar tabela
2123
</cds-button>
22-
</div>
24+
</cds-flexbox>
2325
</div>
2426

2527
<cds-table
2628
v-bind="$attrs"
2729
:selection-variant="selectionVariant"
28-
/>
30+
>
31+
<template
32+
v-if="hasHeaderSlot"
33+
#header-item="data"
34+
>
35+
<slot
36+
name="header-item"
37+
:data="data"
38+
/>
39+
</template>
40+
41+
<template #table-item="data">
42+
<slot
43+
name="table-item"
44+
:data="data"
45+
/>
46+
</template>
47+
</cds-table>
2948
</div>
3049

3150
<cds-side-sheet
@@ -97,10 +116,10 @@ import CdsTable from './Table.vue';
97116
import CdsSideSheet from './SideSheet.vue';
98117
import CdsIcon from './Icon.vue';
99118
import CdsFlexbox from './Flexbox.vue';
100-
import { useHasSlots } from '../utils/composables/useHasSlots';
119+
import { useHasSlot } from '../utils/composables/useHasSlot';
101120
import { cloneDeep } from 'lodash';
102121
103-
const hasSlots = useHasSlots();
122+
const hasHeaderSlot = useHasSlot('header-item');
104123
105124
const props = defineProps({
106125
/**
@@ -123,7 +142,14 @@ const props = defineProps({
123142
customFieldsList: {
124143
type: Array,
125144
default: () => [],
126-
}
145+
},
146+
/**
147+
* Especifica se o botão de personalizar tabela deve ser escondido.
148+
*/
149+
hideCustomizeButton: {
150+
type: Boolean,
151+
default: false,
152+
},
127153
});
128154
129155
const emits = defineEmits(['update-fields-list']);

src/stories/components/DataTable.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import DataTable from '../../components/DataTable.vue';
3535
`<cds-data-table
3636
:fields="fields"
3737
:items="items"
38-
:total="100"
38+
:totalItems="100"
3939
/>`
4040
},
4141
}

src/tests/__snapshots__/DataTable.spec.ts.snap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ exports[`DataTable > renders correctly 1`] = `
44
"<div data-v-046d4556="" fields="field1,field2,field3" items="[object Object],[object Object]">
55
<div data-v-046d4556="" class="data-table">
66
<div data-v-046d4556="" class="data-table__header">
7-
<div data-v-046d4556="" class="data-table__items-counter">200 registros encontrados </div><!-- @slot Slot para renderização de conteúdo à direita do DataTable header. -->
8-
<div data-v-046d4556="">
9-
<cds-button-stub data-v-046d4556="" variant="green" size="sm" block="false" text="Lorem ipsum" disabled="false" secondary="true" loading="false"></cds-button-stub>
10-
</div>
7+
<div data-v-046d4556="" class="data-table__items-counter">200 registros encontrados </div>
8+
<cds-flexbox-stub data-v-046d4556="" direction="row" wrap="wrap" gap="3" justify="flex-start" align="center" tag="div"></cds-flexbox-stub>
119
</div>
1210
<cds-table-stub data-v-046d4556="" modelvalue="" items="[object Object],[object Object]" fields="field1,field2,field3" hover="false" allowselection="false" selectionvariant="green" sortable="false" fixedheader="false" sortdesc="false" nowrap="false"></cds-table-stub>
1311
</div>

0 commit comments

Comments
 (0)