@weni/unnnic-system 3.29.0 → 3.31.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/index.d.ts +324 -8
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +9081 -8937
- package/dist/unnnic.umd.js +31 -31
- package/package.json +1 -1
- package/src/components/InputDatePicker/InputDatePicker.vue +9 -1
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +43 -1
- package/src/components/Table/Table.vue +21 -2
- package/src/components/Table/TableRow.vue +28 -3
- package/src/components/index.ts +13 -0
- package/src/components/ui/table/Table.vue +29 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCell.vue +28 -0
- package/src/components/ui/table/TableHead.vue +27 -0
- package/src/components/ui/table/TableHeader.vue +24 -0
- package/src/components/ui/table/TableRow.vue +51 -0
- package/src/components/ui/table/index.ts +6 -0
- package/src/stories/InputDatePicker.stories.js +50 -0
- package/src/stories/Table.stories.js +75 -2
package/package.json
CHANGED
|
@@ -42,13 +42,17 @@
|
|
|
42
42
|
@change="emitSelectDate"
|
|
43
43
|
@submit="changeDate"
|
|
44
44
|
/>
|
|
45
|
+
|
|
46
|
+
<UnnnicPopoverFooter v-if="hasFooterSlot">
|
|
47
|
+
<slot name="footer" />
|
|
48
|
+
</UnnnicPopoverFooter>
|
|
45
49
|
</UnnnicPopoverContent>
|
|
46
50
|
</UnnnicPopover>
|
|
47
51
|
</div>
|
|
48
52
|
</template>
|
|
49
53
|
|
|
50
54
|
<script setup lang="ts">
|
|
51
|
-
import { computed, ref } from 'vue';
|
|
55
|
+
import { computed, ref, useSlots } from 'vue';
|
|
52
56
|
import moment from 'moment';
|
|
53
57
|
|
|
54
58
|
import UnnnicInput from '../Input/Input.vue';
|
|
@@ -56,6 +60,7 @@ import UnnnicDatePicker from '../DatePicker/DatePicker.vue';
|
|
|
56
60
|
import {
|
|
57
61
|
Popover as UnnnicPopover,
|
|
58
62
|
PopoverContent as UnnnicPopoverContent,
|
|
63
|
+
PopoverFooter as UnnnicPopoverFooter,
|
|
59
64
|
PopoverTrigger as UnnnicPopoverTrigger,
|
|
60
65
|
} from '../ui/popover';
|
|
61
66
|
|
|
@@ -63,6 +68,9 @@ defineOptions({
|
|
|
63
68
|
name: 'UnnnicInputDatePicker',
|
|
64
69
|
});
|
|
65
70
|
|
|
71
|
+
const slots = useSlots();
|
|
72
|
+
const hasFooterSlot = computed(() => Boolean(slots.footer));
|
|
73
|
+
|
|
66
74
|
type DateRangeValue = {
|
|
67
75
|
start: string | null;
|
|
68
76
|
end: string | null;
|
|
@@ -3,7 +3,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
|
|
4
4
|
import InputDatePicker from '../InputDatePicker.vue';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const inlineSlot = { template: '<div><slot /></div>' };
|
|
7
|
+
const portalStubs = {
|
|
8
|
+
PopoverPortal: inlineSlot,
|
|
9
|
+
PopoverContent: inlineSlot,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const factory = (props = {}, { slots = {}, stubs = {} } = {}) =>
|
|
7
13
|
mount(InputDatePicker, {
|
|
8
14
|
props: {
|
|
9
15
|
modelValue: {
|
|
@@ -12,7 +18,11 @@ const factory = (props = {}) =>
|
|
|
12
18
|
},
|
|
13
19
|
...props,
|
|
14
20
|
},
|
|
21
|
+
slots,
|
|
15
22
|
attachTo: document.body,
|
|
23
|
+
global: {
|
|
24
|
+
stubs,
|
|
25
|
+
},
|
|
16
26
|
});
|
|
17
27
|
|
|
18
28
|
describe('InputDatePicker.vue', () => {
|
|
@@ -163,4 +173,36 @@ describe('InputDatePicker.vue', () => {
|
|
|
163
173
|
|
|
164
174
|
rightWrapper.unmount();
|
|
165
175
|
});
|
|
176
|
+
|
|
177
|
+
it('does not render PopoverFooter when the footer slot is empty', async () => {
|
|
178
|
+
wrapper.vm.isPopoverOpen = true;
|
|
179
|
+
await wrapper.vm.$nextTick();
|
|
180
|
+
|
|
181
|
+
expect(
|
|
182
|
+
wrapper.findComponent({ name: 'UnnnicPopoverFooter' }).exists(),
|
|
183
|
+
).toBe(false);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('renders the footer slot content inside PopoverFooter', async () => {
|
|
187
|
+
const withFooter = factory(
|
|
188
|
+
{},
|
|
189
|
+
{
|
|
190
|
+
slots: {
|
|
191
|
+
footer: '<p data-testid="custom-footer">Archive notice</p>',
|
|
192
|
+
},
|
|
193
|
+
stubs: portalStubs,
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
withFooter.vm.isPopoverOpen = true;
|
|
198
|
+
await withFooter.vm.$nextTick();
|
|
199
|
+
|
|
200
|
+
const footer = withFooter.findComponent({ name: 'UnnnicPopoverFooter' });
|
|
201
|
+
const customFooter = withFooter.find('[data-testid="custom-footer"]');
|
|
202
|
+
|
|
203
|
+
expect(footer.exists()).toBe(true);
|
|
204
|
+
expect(customFooter.text()).toBe('Archive notice');
|
|
205
|
+
|
|
206
|
+
withFooter.unmount();
|
|
207
|
+
});
|
|
166
208
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<UiTable v-if="version === '2'">
|
|
3
|
+
<slot />
|
|
4
|
+
</UiTable>
|
|
5
|
+
|
|
2
6
|
<div
|
|
3
|
-
v-
|
|
7
|
+
v-else
|
|
4
8
|
class="unnnic-table"
|
|
5
9
|
>
|
|
6
10
|
<div class="header">
|
|
@@ -28,15 +32,30 @@
|
|
|
28
32
|
</template>
|
|
29
33
|
|
|
30
34
|
<script>
|
|
35
|
+
import { computed } from 'vue';
|
|
36
|
+
import { Table as UiTable } from '@/components/ui/table';
|
|
37
|
+
|
|
31
38
|
export default {
|
|
32
39
|
name: 'UnnnicTable',
|
|
33
40
|
|
|
34
|
-
components: {
|
|
41
|
+
components: {
|
|
42
|
+
UiTable,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
provide() {
|
|
46
|
+
return {
|
|
47
|
+
unnnicTableVersion: computed(() => this.version),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
35
50
|
|
|
36
51
|
props: {
|
|
37
52
|
items: {
|
|
38
53
|
type: Array,
|
|
39
54
|
},
|
|
55
|
+
version: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: '1',
|
|
58
|
+
},
|
|
40
59
|
},
|
|
41
60
|
|
|
42
61
|
data() {
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<UiTableRow
|
|
3
|
+
v-if="isVersion2"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
>
|
|
6
|
+
<slot />
|
|
7
|
+
</UiTableRow>
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
v-else
|
|
11
|
+
class="table-row"
|
|
12
|
+
v-bind="$attrs"
|
|
13
|
+
>
|
|
3
14
|
<template
|
|
4
15
|
v-for="(header, index) in headers"
|
|
5
16
|
:key="header.id"
|
|
@@ -26,17 +37,31 @@
|
|
|
26
37
|
</template>
|
|
27
38
|
|
|
28
39
|
<script>
|
|
40
|
+
import { computed, inject, unref } from 'vue';
|
|
41
|
+
import UiTableRow from '@/components/ui/table/TableRow.vue';
|
|
42
|
+
|
|
29
43
|
export default {
|
|
30
44
|
name: 'UnnnicTableRow',
|
|
31
45
|
|
|
46
|
+
components: {
|
|
47
|
+
UiTableRow,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
inheritAttrs: false,
|
|
51
|
+
|
|
32
52
|
props: {
|
|
33
53
|
headers: {
|
|
34
54
|
type: Array,
|
|
35
55
|
},
|
|
36
56
|
},
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
|
|
58
|
+
setup() {
|
|
59
|
+
const tableVersion = inject('unnnicTableVersion', '1');
|
|
60
|
+
const isVersion2 = computed(() => unref(tableVersion) === '2');
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
isVersion2,
|
|
64
|
+
};
|
|
40
65
|
},
|
|
41
66
|
};
|
|
42
67
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import sidebar from './Sidebar/index.vue';
|
|
|
10
10
|
import sidebarItem from './Sidebar/SidebarItem.vue';
|
|
11
11
|
import table from './Table/Table.vue';
|
|
12
12
|
import tableRow from './Table/TableRow.vue';
|
|
13
|
+
import { TableBody, TableCell, TableHead, TableHeader } from './ui/table';
|
|
13
14
|
import dropdown from './Dropdown/Dropdown.vue';
|
|
14
15
|
import dropdownItem from './Dropdown/DropdownItem.vue';
|
|
15
16
|
import avatarIcon from './AvatarIcon/AvatarIcon.vue';
|
|
@@ -138,6 +139,10 @@ export const components: ComponentsMap = {
|
|
|
138
139
|
unnnicSidebarItem: sidebarItem,
|
|
139
140
|
unnnicTable: table,
|
|
140
141
|
unnnicTableRow: tableRow,
|
|
142
|
+
unnnicTableBody: TableBody,
|
|
143
|
+
unnnicTableCell: TableCell,
|
|
144
|
+
unnnicTableHead: TableHead,
|
|
145
|
+
unnnicTableHeader: TableHeader,
|
|
141
146
|
unnnicAvatarIcon: avatarIcon,
|
|
142
147
|
unnnicIcon: icon,
|
|
143
148
|
unnnicIconSvg: icon,
|
|
@@ -261,6 +266,10 @@ export const unnnicSidebar = sidebar;
|
|
|
261
266
|
export const unnnicSidebarItem = sidebarItem;
|
|
262
267
|
export const unnnicTable = table;
|
|
263
268
|
export const unnnicTableRow = tableRow;
|
|
269
|
+
export const unnnicTableBody = TableBody;
|
|
270
|
+
export const unnnicTableCell = TableCell;
|
|
271
|
+
export const unnnicTableHead = TableHead;
|
|
272
|
+
export const unnnicTableHeader = TableHeader;
|
|
264
273
|
export const unnnicDropdown = dropdown as VueComponent;
|
|
265
274
|
export const unnnicDropdownItem = dropdownItem;
|
|
266
275
|
export const unnnicAvatarIcon = avatarIcon;
|
|
@@ -383,6 +392,10 @@ export const UnnnicSidebar = sidebar;
|
|
|
383
392
|
export const UnnnicSidebarItem = sidebarItem;
|
|
384
393
|
export const UnnnicTable = table;
|
|
385
394
|
export const UnnnicTableRow = tableRow;
|
|
395
|
+
export const UnnnicTableBody = TableBody;
|
|
396
|
+
export const UnnnicTableCell = TableCell;
|
|
397
|
+
export const UnnnicTableHead = TableHead;
|
|
398
|
+
export const UnnnicTableHeader = TableHeader;
|
|
386
399
|
export const UnnnicDropdown = dropdown as VueComponent;
|
|
387
400
|
export const UnnnicDropdownItem = dropdownItem;
|
|
388
401
|
export const UnnnicAvatarIcon = avatarIcon;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="relative w-full overflow-auto">
|
|
12
|
+
<table :class="cn('unnnic-table', props.class)">
|
|
13
|
+
<slot />
|
|
14
|
+
</table>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<style lang="scss" scoped>
|
|
19
|
+
@use '@/assets/scss/unnnic' as *;
|
|
20
|
+
|
|
21
|
+
.unnnic-table {
|
|
22
|
+
border-collapse: collapse;
|
|
23
|
+
width: 100%;
|
|
24
|
+
caption-side: bottom;
|
|
25
|
+
|
|
26
|
+
@include unnnic-font-body;
|
|
27
|
+
color: $unnnic-color-fg-base;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<tbody :class="cn(props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</tbody>
|
|
14
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<td :class="cn('unnnic-table-cell', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</td>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-cell {
|
|
20
|
+
vertical-align: middle;
|
|
21
|
+
|
|
22
|
+
padding: $unnnic-space-4 0;
|
|
23
|
+
|
|
24
|
+
&:not(:last-child) {
|
|
25
|
+
padding-right: $unnnic-space-4;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<th :class="cn('unnnic-table-head', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</th>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-head {
|
|
20
|
+
@include unnnic-font-caption-1;
|
|
21
|
+
color: $unnnic-color-fg-base;
|
|
22
|
+
text-align: left;
|
|
23
|
+
align-items: center;
|
|
24
|
+
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<thead :class="cn('unnnic-table-header', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</thead>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-header {
|
|
20
|
+
* {
|
|
21
|
+
padding-bottom: $unnnic-space-2;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { computed, useAttrs } from 'vue';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
class?: HTMLAttributes['class'];
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const attrs = useAttrs();
|
|
11
|
+
|
|
12
|
+
const isClickable = computed(() => Boolean(attrs.onClick));
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<tr
|
|
17
|
+
:tabindex="isClickable ? 0 : undefined"
|
|
18
|
+
:class="
|
|
19
|
+
cn(
|
|
20
|
+
'unnnic-table-row',
|
|
21
|
+
'transition-colors data-[state=selected]:bg-muted',
|
|
22
|
+
isClickable && 'cursor-pointer',
|
|
23
|
+
props.class,
|
|
24
|
+
)
|
|
25
|
+
"
|
|
26
|
+
@keydown.enter="isClickable && $emit('click', $event)"
|
|
27
|
+
@keydown.space.prevent="isClickable && $emit('click', $event)"
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</tr>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<style lang="scss" scoped>
|
|
34
|
+
@use '@/assets/scss/unnnic' as *;
|
|
35
|
+
|
|
36
|
+
.unnnic-table-row {
|
|
37
|
+
& > :first-child {
|
|
38
|
+
padding-left: $unnnic-space-3;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
& > :last-child {
|
|
42
|
+
padding-right: $unnnic-space-3;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
border-bottom: 1px solid $unnnic-color-border-base;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
background-color: $unnnic-color-bg-soft;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Table } from './Table.vue';
|
|
2
|
+
export { default as TableBody } from './TableBody.vue';
|
|
3
|
+
export { default as TableCell } from './TableCell.vue';
|
|
4
|
+
export { default as TableHead } from './TableHead.vue';
|
|
5
|
+
export { default as TableHeader } from './TableHeader.vue';
|
|
6
|
+
export { default as TableRow } from './TableRow.vue';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import UnnnicInputDatePicker from '../components/InputDatePicker/InputDatePicker.vue';
|
|
2
|
+
import UnnnicDisclaimer from '../components/Disclaimer/Disclaimer.vue';
|
|
2
3
|
import moment from 'moment';
|
|
3
4
|
export default {
|
|
4
5
|
title: 'Form/InputDatePicker',
|
|
@@ -103,3 +104,52 @@ export const WithDisableShowOverwrittenValue = {
|
|
|
103
104
|
disableShowOverwrittenValue: true,
|
|
104
105
|
},
|
|
105
106
|
};
|
|
107
|
+
|
|
108
|
+
export const WithFooter = {
|
|
109
|
+
args: {
|
|
110
|
+
size: 'sm',
|
|
111
|
+
next: true,
|
|
112
|
+
iconPosition: 'right',
|
|
113
|
+
fillW: true,
|
|
114
|
+
maxDate: moment().format('YYYY-MM-DD'),
|
|
115
|
+
minDate: moment().subtract(89, 'days').format('YYYY-MM-DD'),
|
|
116
|
+
options: [
|
|
117
|
+
{ name: 'Last 7 days', id: 'last-7-days' },
|
|
118
|
+
{ name: 'Last 14 days', id: 'last-14-days' },
|
|
119
|
+
{ name: 'Last 30 days', id: 'last-30-days' },
|
|
120
|
+
{ name: 'Last 90 days', id: 'last-90-days' },
|
|
121
|
+
{ name: 'Current month', id: 'current-month' },
|
|
122
|
+
{ name: 'Custom', id: 'custom' },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
render: (args) => ({
|
|
126
|
+
components: {
|
|
127
|
+
UnnnicInputDatePicker,
|
|
128
|
+
UnnnicDisclaimer,
|
|
129
|
+
},
|
|
130
|
+
setup() {
|
|
131
|
+
return { args };
|
|
132
|
+
},
|
|
133
|
+
data() {
|
|
134
|
+
return {
|
|
135
|
+
dates: {
|
|
136
|
+
start: null,
|
|
137
|
+
end: null,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
template: `
|
|
142
|
+
<div style="max-width: 200px">
|
|
143
|
+
<pre>v-model: {{ dates }}</pre>
|
|
144
|
+
<UnnnicInputDatePicker v-bind="args" v-model="dates">
|
|
145
|
+
<template #footer>
|
|
146
|
+
<UnnnicDisclaimer
|
|
147
|
+
type="neutral"
|
|
148
|
+
description="Conversations older than 90 days are archived and can't be shown. To access them, contact support."
|
|
149
|
+
/>
|
|
150
|
+
</template>
|
|
151
|
+
</UnnnicInputDatePicker>
|
|
152
|
+
</div>
|
|
153
|
+
`,
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
@@ -2,11 +2,24 @@ import unnnicTable from '../components/Table/Table.vue';
|
|
|
2
2
|
import unnnicTableRow from '../components/Table/TableRow.vue';
|
|
3
3
|
import unnnicButton from '../components/Button/Button.vue';
|
|
4
4
|
import unnnicCheckbox from '../components/Checkbox/Checkbox.vue';
|
|
5
|
+
import {
|
|
6
|
+
TableHeader,
|
|
7
|
+
TableBody,
|
|
8
|
+
TableHead,
|
|
9
|
+
TableCell,
|
|
10
|
+
} from '@/components/ui/table';
|
|
11
|
+
import UnnnicTag from '@/components/Tag/Tag.vue';
|
|
12
|
+
import { action } from 'storybook/actions';
|
|
5
13
|
|
|
6
14
|
export default {
|
|
7
15
|
title: 'example/Table',
|
|
8
16
|
component: unnnicTable,
|
|
9
|
-
argTypes: {
|
|
17
|
+
argTypes: {
|
|
18
|
+
version: {
|
|
19
|
+
control: { type: 'select' },
|
|
20
|
+
options: ['1', '2'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
10
23
|
};
|
|
11
24
|
|
|
12
25
|
const Template = (args, { argTypes }) => ({
|
|
@@ -21,6 +34,7 @@ const Template = (args, { argTypes }) => ({
|
|
|
21
34
|
<div>
|
|
22
35
|
<unnnic-table
|
|
23
36
|
v-bind="$props"
|
|
37
|
+
version="1"
|
|
24
38
|
:items="table.items"
|
|
25
39
|
:style="{ maxHeight: '280px', maxWidth: '800px', }"
|
|
26
40
|
>
|
|
@@ -142,4 +156,63 @@ const Template = (args, { argTypes }) => ({
|
|
|
142
156
|
});
|
|
143
157
|
|
|
144
158
|
export const Default = Template.bind({});
|
|
145
|
-
Default.args = {
|
|
159
|
+
Default.args = {
|
|
160
|
+
version: '1',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const Version2 = {
|
|
164
|
+
render: () => ({
|
|
165
|
+
components: {
|
|
166
|
+
unnnicTable,
|
|
167
|
+
unnnicTableRow,
|
|
168
|
+
TableHeader,
|
|
169
|
+
TableBody,
|
|
170
|
+
TableHead,
|
|
171
|
+
TableCell,
|
|
172
|
+
UnnnicTag,
|
|
173
|
+
},
|
|
174
|
+
setup() {
|
|
175
|
+
return {
|
|
176
|
+
onRowClick: action('click'),
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
template: `
|
|
180
|
+
<unnnic-table version="2">
|
|
181
|
+
<TableHeader>
|
|
182
|
+
<unnnic-table-row>
|
|
183
|
+
<TableHead>
|
|
184
|
+
Invoice
|
|
185
|
+
</TableHead>
|
|
186
|
+
<TableHead>Status</TableHead>
|
|
187
|
+
<TableHead>Method</TableHead>
|
|
188
|
+
<TableHead>
|
|
189
|
+
Amount
|
|
190
|
+
</TableHead>
|
|
191
|
+
</unnnic-table-row>
|
|
192
|
+
</TableHeader>
|
|
193
|
+
<TableBody>
|
|
194
|
+
<unnnic-table-row>
|
|
195
|
+
<TableCell>
|
|
196
|
+
INV001
|
|
197
|
+
</TableCell>
|
|
198
|
+
<TableCell><UnnnicTag scheme="green" text="Paid" /></TableCell>
|
|
199
|
+
<TableCell>Credit Card</TableCell>
|
|
200
|
+
<TableCell>
|
|
201
|
+
$250.00
|
|
202
|
+
</TableCell>
|
|
203
|
+
</unnnic-table-row>
|
|
204
|
+
<unnnic-table-row @click="onRowClick">
|
|
205
|
+
<TableCell>
|
|
206
|
+
INV002
|
|
207
|
+
</TableCell>
|
|
208
|
+
<TableCell><UnnnicTag scheme="red" text="Pending" /></TableCell>
|
|
209
|
+
<TableCell>Bank Transfer</TableCell>
|
|
210
|
+
<TableCell>
|
|
211
|
+
$199.00
|
|
212
|
+
</TableCell>
|
|
213
|
+
</unnnic-table-row>
|
|
214
|
+
</TableBody>
|
|
215
|
+
</unnnic-table>
|
|
216
|
+
`,
|
|
217
|
+
}),
|
|
218
|
+
};
|