@dolanske/vui 1.0.4 → 1.1.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/LICENSE +673 -673
- package/README.md +42 -42
- package/dist/components/Accordion/Accordion.vue.d.ts +3 -2
- package/dist/components/Accordion/AccordionGroup.vue.d.ts +5 -2
- package/dist/components/Alert/Alert.vue.d.ts +3 -2
- package/dist/components/Avatar/Avatar.vue.d.ts +3 -2
- package/dist/components/Badge/Badge.vue.d.ts +3 -2
- package/dist/components/Breadcrumbs/BreadcrumbItem.vue.d.ts +3 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.vue.d.ts +3 -2
- package/dist/components/Button/Button.vue.d.ts +3 -2
- package/dist/components/ButtonGroup/ButtonGroup.vue.d.ts +3 -2
- package/dist/components/Calendar/Calendar.vue.d.ts +6 -6
- package/dist/components/Card/Card.vue.d.ts +4 -3
- package/dist/components/Checkbox/Checkbox.vue.d.ts +7 -6
- package/dist/components/CopyClipboard/CopyClipboard.vue.d.ts +2 -1
- package/dist/components/Divider/Divider.vue.d.ts +3 -2
- package/dist/components/Drawer/Drawer.vue.d.ts +10 -9
- package/dist/components/Dropdown/Dropdown.vue.d.ts +66 -3
- package/dist/components/Dropdown/DropdownItem.vue.d.ts +3 -2
- package/dist/components/Dropdown/DropdownTitle.vue.d.ts +6 -6
- package/dist/components/Flex/Flex.vue.d.ts +13 -12
- package/dist/components/Grid/Grid.vue.d.ts +7 -6
- package/dist/components/Input/Color.vue.d.ts +5 -5
- package/dist/components/Input/Counter.vue.d.ts +5 -5
- package/dist/components/Input/Dropzone.vue.d.ts +95 -10
- package/dist/components/Input/File.vue.d.ts +4 -3
- package/dist/components/Input/Input.vue.d.ts +7 -6
- package/dist/components/Input/Password.vue.d.ts +1 -1
- package/dist/components/Input/Textarea.vue.d.ts +7 -6
- package/dist/components/Kbd/Kbd.vue.d.ts +1 -1
- package/dist/components/Kbd/KbdGroup.vue.d.ts +2 -1
- package/dist/components/Modal/Confirm.vue.d.ts +7 -9
- package/dist/components/Modal/Modal.vue.d.ts +16 -13
- package/dist/components/OTP/OTP.vue.d.ts +7 -6
- package/dist/components/OTP/OTPItem.vue.d.ts +1 -1
- package/dist/components/Pagination/Pagination.vue.d.ts +3 -2
- package/dist/components/Popout/Popout.vue.d.ts +3 -2
- package/dist/components/Progress/Progress.vue.d.ts +5 -5
- package/dist/components/Radio/Radio.vue.d.ts +7 -6
- package/dist/components/Radio/RadioGroup.vue.d.ts +7 -6
- package/dist/components/Select/Select.vue.d.ts +4 -8
- package/dist/components/Sheet/Sheet.vue.d.ts +22 -13
- package/dist/components/Sidebar/Sidebar.vue.d.ts +7 -6
- package/dist/components/Skeleton/Skeleton.vue.d.ts +1 -1
- package/dist/components/Spinner/Spinner.vue.d.ts +1 -1
- package/dist/components/Switch/Switch.vue.d.ts +7 -6
- package/dist/components/Table/Cell.vue.d.ts +5 -2
- package/dist/components/Table/Head.vue.d.ts +3 -2
- package/dist/components/Table/Root.vue.d.ts +3 -2
- package/dist/components/Table/table.d.ts +2 -2
- package/dist/components/Tabs/Tab.vue.d.ts +3 -2
- package/dist/components/Tabs/Tabs.vue.d.ts +7 -6
- package/dist/components/Toast/toast.d.ts +6 -6
- package/dist/components/Tooltip/Tooltip.vue.d.ts +2 -1
- package/dist/internal/Backdrop/Backdrop.vue.d.ts +3 -2
- package/dist/vui.css +1 -0
- package/dist/vui.js +8090 -7884
- package/package.json +73 -72
- package/src/App.vue +95 -95
- package/src/components/Accordion/Accordion.vue +91 -91
- package/src/components/Accordion/AccordionGroup.vue +43 -43
- package/src/components/Accordion/accordion.scss +82 -82
- package/src/components/Alert/Alert.vue +59 -59
- package/src/components/Alert/alert.scss +161 -161
- package/src/components/Avatar/Avatar.vue +53 -53
- package/src/components/Avatar/avatar.scss +52 -52
- package/src/components/Badge/Badge.vue +21 -21
- package/src/components/Badge/badge.scss +210 -206
- package/src/components/Breadcrumbs/BreadcrumbItem.vue +26 -26
- package/src/components/Breadcrumbs/Breadcrumbs.vue +30 -30
- package/src/components/Breadcrumbs/breadcrumbs.scss +31 -31
- package/src/components/Button/Button.vue +85 -85
- package/src/components/Button/button.scss +279 -279
- package/src/components/ButtonGroup/ButtonGroup.vue +28 -28
- package/src/components/ButtonGroup/button-group.scss +51 -51
- package/src/components/Calendar/Calendar.vue +66 -66
- package/src/components/Calendar/calendar.scss +83 -83
- package/src/components/Card/Card.vue +48 -48
- package/src/components/Card/card.scss +53 -53
- package/src/components/Checkbox/Checkbox.vue +54 -54
- package/src/components/Checkbox/checkbox.scss +80 -80
- package/src/components/CopyClipboard/CopyClipboard.vue +91 -91
- package/src/components/CopyClipboard/copy-clipboard.scss +25 -25
- package/src/components/Divider/Divider.vue +44 -44
- package/src/components/Divider/divider.scss +35 -35
- package/src/components/Drawer/Drawer.vue +102 -97
- package/src/components/Drawer/drawer.scss +37 -37
- package/src/components/Dropdown/Dropdown.vue +135 -135
- package/src/components/Dropdown/DropdownItem.vue +33 -33
- package/src/components/Dropdown/DropdownTitle.vue +14 -14
- package/src/components/Dropdown/dropdown-item.scss +84 -84
- package/src/components/Dropdown/dropdown.scss +53 -53
- package/src/components/Flex/Flex.vue +113 -113
- package/src/components/Grid/Grid.vue +79 -80
- package/src/components/Input/Color.vue +26 -26
- package/src/components/Input/Counter.vue +66 -66
- package/src/components/Input/Dropzone.vue +65 -65
- package/src/components/Input/File.vue +15 -15
- package/src/components/Input/Input.vue +123 -123
- package/src/components/Input/Password.vue +35 -35
- package/src/components/Input/Textarea.vue +78 -78
- package/src/components/Input/input.scss +302 -302
- package/src/components/Kbd/Kbd.vue +48 -48
- package/src/components/Kbd/KbdGroup.vue +27 -27
- package/src/components/Kbd/kbd.scss +19 -19
- package/src/components/Modal/Confirm.vue +56 -56
- package/src/components/Modal/Modal.vue +103 -99
- package/src/components/Modal/modal.scss +54 -54
- package/src/components/OTP/OTP.vue +133 -133
- package/src/components/OTP/OTPItem.vue +37 -37
- package/src/components/OTP/otp.scss +84 -84
- package/src/components/Pagination/Pagination.vue +77 -77
- package/src/components/Pagination/pagination.ts +78 -78
- package/src/components/Popout/Popout.vue +52 -52
- package/src/components/Popout/popout.scss +15 -15
- package/src/components/Progress/Progress.vue +103 -103
- package/src/components/Progress/progress.scss +47 -47
- package/src/components/Radio/Radio.vue +38 -38
- package/src/components/Radio/RadioGroup.vue +40 -40
- package/src/components/Radio/radio.scss +78 -78
- package/src/components/Select/Select.vue +211 -211
- package/src/components/Select/select.scss +77 -77
- package/src/components/Sheet/Sheet.vue +108 -98
- package/src/components/Sheet/sheet.scss +69 -69
- package/src/components/Sidebar/Sidebar.vue +115 -115
- package/src/components/Sidebar/sidebar.scss +124 -124
- package/src/components/Skeleton/Skeleton.vue +43 -43
- package/src/components/Skeleton/skeleton.scss +14 -14
- package/src/components/Spinner/Spinner.vue +42 -42
- package/src/components/Spinner/spinner.scss +47 -47
- package/src/components/Switch/Switch.vue +31 -31
- package/src/components/Switch/switch.scss +93 -93
- package/src/components/Table/Cell.vue +23 -23
- package/src/components/Table/Head.vue +59 -59
- package/src/components/Table/Root.vue +66 -66
- package/src/components/Table/SelectAll.vue +23 -23
- package/src/components/Table/SelectRow.vue +30 -30
- package/src/components/Table/index.ts +7 -7
- package/src/components/Table/table.scss +154 -154
- package/src/components/Table/table.ts +248 -248
- package/src/components/Tabs/Tab.vue +25 -25
- package/src/components/Tabs/Tabs.vue +90 -90
- package/src/components/Tabs/tabs.scss +87 -87
- package/src/components/Toast/Toasts.vue +52 -52
- package/src/components/Toast/toast.scss +45 -45
- package/src/components/Toast/toast.ts +75 -75
- package/src/components/Tooltip/Tooltip.vue +86 -86
- package/src/components/Tooltip/tooltip.scss +8 -8
- package/src/examples/ExampleAccordions.vue +58 -58
- package/src/examples/ExampleAlerts.vue +78 -78
- package/src/examples/ExampleAvatars.vue +44 -44
- package/src/examples/ExampleBadges.vue +48 -48
- package/src/examples/ExampleBreadcrumbs.vue +46 -46
- package/src/examples/ExampleButtons.vue +140 -140
- package/src/examples/ExampleCalendars.vue +40 -40
- package/src/examples/ExampleCards.vue +94 -94
- package/src/examples/ExampleCheckboxes.vue +123 -123
- package/src/examples/ExampleCopyClipboard.vue +47 -47
- package/src/examples/ExampleDividers.vue +39 -39
- package/src/examples/ExampleDrawers.vue +67 -67
- package/src/examples/ExampleDropdowns.vue +114 -114
- package/src/examples/ExampleFlexGrid.vue +124 -122
- package/src/examples/ExampleInputs.vue +234 -234
- package/src/examples/ExampleKBD.vue +65 -65
- package/src/examples/ExampleModals.vue +143 -143
- package/src/examples/ExamplePalette.vue +159 -159
- package/src/examples/ExamplePopouts.vue +41 -41
- package/src/examples/ExampleSheets.vue +77 -77
- package/src/examples/ExampleSidebars.vue +270 -270
- package/src/examples/ExampleSkeletons.vue +26 -26
- package/src/examples/ExampleSpinners.vue +80 -78
- package/src/examples/ExampleTables.vue +195 -195
- package/src/examples/ExampleTabs.vue +119 -119
- package/src/examples/ExampleToasts.vue +96 -96
- package/src/examples/ExampleTooltips.vue +70 -70
- package/src/examples/shared/ExampleColor.vue +28 -28
- package/src/index.ts +116 -116
- package/src/internal/Backdrop/Backdrop.vue +22 -22
- package/src/internal/Backdrop/backdrop.scss +34 -34
- package/src/main.ts +5 -5
- package/src/shared/helpers.ts +117 -117
- package/src/shared/theme.ts +22 -22
- package/src/shared/types.ts +29 -29
- package/src/style/animation.scss +22 -22
- package/src/style/core.scss +119 -125
- package/src/style/layout.scss +207 -233
- package/src/style/media-query.scss +29 -29
- package/src/style/reset.scss +135 -135
- package/src/style/text.scss +137 -124
- package/src/style/theme.scss +195 -195
- package/src/style/tooltip.scss +146 -146
- package/src/style/typography.scss +415 -415
- package/src/style/utils.scss +36 -36
- package/src/style.scss +1 -1
- package/dist/style.css +0 -1
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
<script setup lang='ts'>
|
|
2
|
-
import { ref, watch } from 'vue'
|
|
3
|
-
import Button from '../components/Button/Button.vue'
|
|
4
|
-
import Checkbox from '../components/Checkbox/Checkbox.vue'
|
|
5
|
-
import Flex from '../components/Flex/Flex.vue'
|
|
6
|
-
import Progress from '../components/Progress/Progress.vue'
|
|
7
|
-
import Spinner from '../components/Spinner/Spinner.vue'
|
|
8
|
-
|
|
9
|
-
const paused = ref(true)
|
|
10
|
-
const progress = ref(25)
|
|
11
|
-
|
|
12
|
-
const fakeProgress = ref(15)
|
|
13
|
-
const showFixed = ref(false)
|
|
14
|
-
const variants = ['s', 'm', 'l'] as const
|
|
15
|
-
|
|
16
|
-
watch(paused, () => fakeProgress.value = 0)
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
<div class="mb-xxl">
|
|
21
|
-
<h3 class="mb-l
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<Button square icon="ph:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
</
|
|
1
|
+
<script setup lang='ts'>
|
|
2
|
+
import { ref, watch } from 'vue'
|
|
3
|
+
import Button from '../components/Button/Button.vue'
|
|
4
|
+
import Checkbox from '../components/Checkbox/Checkbox.vue'
|
|
5
|
+
import Flex from '../components/Flex/Flex.vue'
|
|
6
|
+
import Progress from '../components/Progress/Progress.vue'
|
|
7
|
+
import Spinner from '../components/Spinner/Spinner.vue'
|
|
8
|
+
|
|
9
|
+
const paused = ref(true)
|
|
10
|
+
const progress = ref(25)
|
|
11
|
+
|
|
12
|
+
const fakeProgress = ref(15)
|
|
13
|
+
const showFixed = ref(false)
|
|
14
|
+
const variants = ['s', 'm', 'l'] as const
|
|
15
|
+
|
|
16
|
+
watch(paused, () => fakeProgress.value = 0)
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div class="mb-xxl">
|
|
21
|
+
<h3 class="mb-l">
|
|
22
|
+
<Flex y-center gap="m">
|
|
23
|
+
Loading
|
|
24
|
+
<Button square :icon="paused ? 'ph:play' : 'ph:pause'" size="s" plain @click="paused = !paused" />
|
|
25
|
+
</Flex>
|
|
26
|
+
</h3>
|
|
27
|
+
<table>
|
|
28
|
+
<tbody>
|
|
29
|
+
<tr>
|
|
30
|
+
<th>Spinners</th>
|
|
31
|
+
<td>
|
|
32
|
+
<Flex
|
|
33
|
+
gap="l" :style="{
|
|
34
|
+
'animation-play-state': 'paused',
|
|
35
|
+
}"
|
|
36
|
+
>
|
|
37
|
+
<Spinner
|
|
38
|
+
v-for="size in variants" :key="size" :size :style="{
|
|
39
|
+
'animation-play-state': paused ? 'paused' : 'running',
|
|
40
|
+
}"
|
|
41
|
+
/>
|
|
42
|
+
</Flex>
|
|
43
|
+
</td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr>
|
|
46
|
+
<th>Progress bar</th>
|
|
47
|
+
<td class="w-80">
|
|
48
|
+
<Flex gap="s" y-center>
|
|
49
|
+
<Button square icon="ph:minus" size="s" @click="progress -= 5" />
|
|
50
|
+
<Progress v-model="progress" class="w-full" />
|
|
51
|
+
<Button square icon="ph:plus" size="s" @click="progress += 5" />
|
|
52
|
+
</Flex>
|
|
53
|
+
</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr>
|
|
56
|
+
<th>Progress bar tall</th>
|
|
57
|
+
<td class="w-80">
|
|
58
|
+
<Flex gap="s" y-center>
|
|
59
|
+
<Progress v-model="progress" :height="8" class="w-full" />
|
|
60
|
+
</Flex>
|
|
61
|
+
</td>
|
|
62
|
+
</tr>
|
|
63
|
+
<tr>
|
|
64
|
+
<th>Fake</th>
|
|
65
|
+
<td>
|
|
66
|
+
<Progress v-model="fakeProgress" :fake="!paused" />
|
|
67
|
+
</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<th>Fixed</th>
|
|
71
|
+
<td>
|
|
72
|
+
<Checkbox v-model="showFixed" label="Show fixed progress bar (look up)" />
|
|
73
|
+
|
|
74
|
+
<Progress v-if="showFixed" v-model="fakeProgress" :fake="!paused" fixed />
|
|
75
|
+
</td>
|
|
76
|
+
</tr>
|
|
77
|
+
</tbody>
|
|
78
|
+
</table>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, onBeforeMount, ref } from 'vue'
|
|
3
|
-
import Accordion from '../components/Accordion/Accordion.vue'
|
|
4
|
-
import Divider from '../components/Divider/Divider.vue'
|
|
5
|
-
import { paginate } from '../components/Pagination/pagination'
|
|
6
|
-
import Pagination from '../components/Pagination/Pagination.vue'
|
|
7
|
-
import * as Table from '../components/Table/index'
|
|
8
|
-
import { defineTable } from '../components/Table/table'
|
|
9
|
-
|
|
10
|
-
interface Item {
|
|
11
|
-
'ID Nation': string
|
|
12
|
-
'ID Year': number
|
|
13
|
-
'Nation': string
|
|
14
|
-
'Population': number
|
|
15
|
-
'Slug Nation': string
|
|
16
|
-
'Year': string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface StrippedItem {
|
|
20
|
-
Nation: string
|
|
21
|
-
Population: number
|
|
22
|
-
Year: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const data = ref<StrippedItem[]>([])
|
|
26
|
-
|
|
27
|
-
onBeforeMount(async () => {
|
|
28
|
-
data.value = await fetch('https://datausa.io/api/data?drilldowns=Nation&measures=Population')
|
|
29
|
-
.then(response => response.json())
|
|
30
|
-
.then(({ data }: { data: Item[] }) => {
|
|
31
|
-
return data.map(row => ({
|
|
32
|
-
Nation: row.Nation,
|
|
33
|
-
Population: row.Population,
|
|
34
|
-
Year: row.Year,
|
|
35
|
-
}))
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
rows,
|
|
41
|
-
headers,
|
|
42
|
-
pagination,
|
|
43
|
-
allRows,
|
|
44
|
-
setPage,
|
|
45
|
-
selectedRows,
|
|
46
|
-
} = defineTable(data, {
|
|
47
|
-
pagination: {
|
|
48
|
-
enabled: true,
|
|
49
|
-
perPage: 3,
|
|
50
|
-
},
|
|
51
|
-
select: true,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
// Example
|
|
55
|
-
//
|
|
56
|
-
const testData = ['Jan', 'Andrew', 'Kasper', 'Anton', 'Felix', 'Daniel', 'Gabriel', 'Ayalga', 'Floris']
|
|
57
|
-
const page = ref(1)
|
|
58
|
-
const paginationExample = computed(() => paginate(testData.length, page.value, 2))
|
|
59
|
-
const exampleToRender = computed(() => testData.slice(paginationExample.value.startIndex, paginationExample.value.endIndex + 1))
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<template>
|
|
63
|
-
<div class="mb-xxl">
|
|
64
|
-
<h3 class="mb-l">
|
|
65
|
-
Tables
|
|
66
|
-
</h3>
|
|
67
|
-
|
|
68
|
-
<p class="mb-l">
|
|
69
|
-
This library has two way to define tables. By default, you can use the classic <code>table</code> element and compose simple tables. <br> Or you can go overkill with the <code>{{ `<Table />` }}</code> component, which comes with its own composable function
|
|
70
|
-
</p>
|
|
71
|
-
|
|
72
|
-
<strong class="mb-s block">Simple vertical table</strong>
|
|
73
|
-
|
|
74
|
-
<table class="mb-l">
|
|
75
|
-
<thead>
|
|
76
|
-
<tr>
|
|
77
|
-
<th>One</th>
|
|
78
|
-
<th>Two</th>
|
|
79
|
-
<th>Three</th>
|
|
80
|
-
</tr>
|
|
81
|
-
</thead>
|
|
82
|
-
<tbody>
|
|
83
|
-
<tr>
|
|
84
|
-
<td>First </td>
|
|
85
|
-
<td>Second</td>
|
|
86
|
-
<td>Third</td>
|
|
87
|
-
</tr>
|
|
88
|
-
</tbody>
|
|
89
|
-
</table>
|
|
90
|
-
|
|
91
|
-
<strong class="mb-s block">Simple horizontal table</strong>
|
|
92
|
-
|
|
93
|
-
<table class="mb-xxl">
|
|
94
|
-
<tbody>
|
|
95
|
-
<tr>
|
|
96
|
-
<th>One</th>
|
|
97
|
-
<td>First</td>
|
|
98
|
-
</tr>
|
|
99
|
-
<tr>
|
|
100
|
-
<th>Two</th>
|
|
101
|
-
<td>Second</td>
|
|
102
|
-
</tr>
|
|
103
|
-
<tr>
|
|
104
|
-
<th>Three</th>
|
|
105
|
-
<td>Third</td>
|
|
106
|
-
</tr>
|
|
107
|
-
</tbody>
|
|
108
|
-
</table>
|
|
109
|
-
|
|
110
|
-
<h5 class="mb-s">
|
|
111
|
-
Data table
|
|
112
|
-
</h5>
|
|
113
|
-
|
|
114
|
-
<p class="mb-s">
|
|
115
|
-
This example demonstrates the full capability of the table component. Including column sorting, pagination and row selection.
|
|
116
|
-
</p>
|
|
117
|
-
|
|
118
|
-
<Table.Root separate-cells class="mb-l">
|
|
119
|
-
<template #header>
|
|
120
|
-
<Table.SelectAll />
|
|
121
|
-
<Table.Head v-for="header in headers" :key="header.label" :header sort />
|
|
122
|
-
</template>
|
|
123
|
-
<template #body>
|
|
124
|
-
<tr v-for="row in rows" :key="row.Year">
|
|
125
|
-
<Table.SelectRow :row />
|
|
126
|
-
<Table.Cell>{{ row.Nation }}</Table.Cell>
|
|
127
|
-
<Table.Cell>{{ row.Population }}</Table.Cell>
|
|
128
|
-
<Table.Cell>{{ row.Year }}</Table.Cell>
|
|
129
|
-
</tr>
|
|
130
|
-
</template>
|
|
131
|
-
<template #pagination>
|
|
132
|
-
<Pagination :pagination :first-last="false" @change="setPage" />
|
|
133
|
-
</template>
|
|
134
|
-
</Table.Root>
|
|
135
|
-
|
|
136
|
-
<Accordion :label="`Selected rows (${selectedRows.size})`" class="mb-xl">
|
|
137
|
-
<pre>
|
|
138
|
-
{{ selectedRows }}
|
|
139
|
-
</pre>
|
|
140
|
-
</Accordion>
|
|
141
|
-
|
|
142
|
-
<h5 class="mb-s">
|
|
143
|
-
Variations
|
|
144
|
-
</h5>
|
|
145
|
-
|
|
146
|
-
<div class="typeset mb-xl">
|
|
147
|
-
<ul>
|
|
148
|
-
<li><p><code>separate-rows</code> Adds a border between rows (default: <code>true</code>)</p></li>
|
|
149
|
-
<li><p><code>separate-cells</code> Adds a border between cells (default: <code>false</code>)</p></li>
|
|
150
|
-
<li><p><code>outer-border</code> Adds a border around the entire table component (default: <code>true</code>)</p></li>
|
|
151
|
-
<li><p><code>nowrap</code> Adds ellipsis to text which overflows to keep row size consistent (default: <code>false</code>)</p></li>
|
|
152
|
-
<li><p><code>fixed</code> Keeps all the columns the same size (default: <code>false</code>)</p></li>
|
|
153
|
-
</ul>
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
<div class="container container-s mb-xxl ml-0">
|
|
157
|
-
<Table.Root :outer-border="false" :separate-cells="true" nowrap fixed>
|
|
158
|
-
<template #body>
|
|
159
|
-
<tr v-for="row in allRows" :key="row.Year">
|
|
160
|
-
<Table.Cell>{{ `${row.Nation} ${row.Nation}` }}</Table.Cell>
|
|
161
|
-
<Table.Cell>{{ row.Population }}</Table.Cell>
|
|
162
|
-
<Table.Cell>{{ row.Year }}</Table.Cell>
|
|
163
|
-
</tr>
|
|
164
|
-
</template>
|
|
165
|
-
</Table.Root>
|
|
166
|
-
</div>
|
|
167
|
-
|
|
168
|
-
<h5 class="mb-s">
|
|
169
|
-
Pagination
|
|
170
|
-
</h5>
|
|
171
|
-
|
|
172
|
-
<p class="mb-m">
|
|
173
|
-
Pagination does not need to be used with table only. The calculation of pages is done via an external function and the pagination component accepts all the necesary props to implement it for any kind of dataset and UI
|
|
174
|
-
</p>
|
|
175
|
-
|
|
176
|
-
<p class="mb-m">
|
|
177
|
-
Here we have a list of names and we're gonna paginate through them:<br><br> {{ testData.join(', ') }}
|
|
178
|
-
</p>
|
|
179
|
-
<Pagination :pagination="paginationExample" @change="(num) => page = num" />
|
|
180
|
-
<div class="typeset">
|
|
181
|
-
<ul>
|
|
182
|
-
<li
|
|
183
|
-
v-for="name in exampleToRender"
|
|
184
|
-
:key="name"
|
|
185
|
-
>
|
|
186
|
-
{{ name }}
|
|
187
|
-
</li>
|
|
188
|
-
</ul>
|
|
189
|
-
</div>
|
|
190
|
-
|
|
191
|
-
<Divider :size="40" class="w-40" />
|
|
192
|
-
|
|
193
|
-
<p>The <code>defineTable</code> hook can also be used with other UI components. Not just tables. That's why all the table interactivity is not within the component, but in a hook. It's very flexible and allows custom functionality.</p>
|
|
194
|
-
</div>
|
|
195
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeMount, ref } from 'vue'
|
|
3
|
+
import Accordion from '../components/Accordion/Accordion.vue'
|
|
4
|
+
import Divider from '../components/Divider/Divider.vue'
|
|
5
|
+
import { paginate } from '../components/Pagination/pagination'
|
|
6
|
+
import Pagination from '../components/Pagination/Pagination.vue'
|
|
7
|
+
import * as Table from '../components/Table/index'
|
|
8
|
+
import { defineTable } from '../components/Table/table'
|
|
9
|
+
|
|
10
|
+
interface Item {
|
|
11
|
+
'ID Nation': string
|
|
12
|
+
'ID Year': number
|
|
13
|
+
'Nation': string
|
|
14
|
+
'Population': number
|
|
15
|
+
'Slug Nation': string
|
|
16
|
+
'Year': string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface StrippedItem {
|
|
20
|
+
Nation: string
|
|
21
|
+
Population: number
|
|
22
|
+
Year: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const data = ref<StrippedItem[]>([])
|
|
26
|
+
|
|
27
|
+
onBeforeMount(async () => {
|
|
28
|
+
data.value = await fetch('https://datausa.io/api/data?drilldowns=Nation&measures=Population')
|
|
29
|
+
.then(response => response.json())
|
|
30
|
+
.then(({ data }: { data: Item[] }) => {
|
|
31
|
+
return data.map(row => ({
|
|
32
|
+
Nation: row.Nation,
|
|
33
|
+
Population: row.Population,
|
|
34
|
+
Year: row.Year,
|
|
35
|
+
}))
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
rows,
|
|
41
|
+
headers,
|
|
42
|
+
pagination,
|
|
43
|
+
allRows,
|
|
44
|
+
setPage,
|
|
45
|
+
selectedRows,
|
|
46
|
+
} = defineTable(data, {
|
|
47
|
+
pagination: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
perPage: 3,
|
|
50
|
+
},
|
|
51
|
+
select: true,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
// Example
|
|
55
|
+
//
|
|
56
|
+
const testData = ['Jan', 'Andrew', 'Kasper', 'Anton', 'Felix', 'Daniel', 'Gabriel', 'Ayalga', 'Floris']
|
|
57
|
+
const page = ref(1)
|
|
58
|
+
const paginationExample = computed(() => paginate(testData.length, page.value, 2))
|
|
59
|
+
const exampleToRender = computed(() => testData.slice(paginationExample.value.startIndex, paginationExample.value.endIndex + 1))
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div class="mb-xxl">
|
|
64
|
+
<h3 class="mb-l">
|
|
65
|
+
Tables
|
|
66
|
+
</h3>
|
|
67
|
+
|
|
68
|
+
<p class="mb-l">
|
|
69
|
+
This library has two way to define tables. By default, you can use the classic <code>table</code> element and compose simple tables. <br> Or you can go overkill with the <code>{{ `<Table />` }}</code> component, which comes with its own composable function
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
<strong class="mb-s block">Simple vertical table</strong>
|
|
73
|
+
|
|
74
|
+
<table class="mb-l">
|
|
75
|
+
<thead>
|
|
76
|
+
<tr>
|
|
77
|
+
<th>One</th>
|
|
78
|
+
<th>Two</th>
|
|
79
|
+
<th>Three</th>
|
|
80
|
+
</tr>
|
|
81
|
+
</thead>
|
|
82
|
+
<tbody>
|
|
83
|
+
<tr>
|
|
84
|
+
<td>First </td>
|
|
85
|
+
<td>Second</td>
|
|
86
|
+
<td>Third</td>
|
|
87
|
+
</tr>
|
|
88
|
+
</tbody>
|
|
89
|
+
</table>
|
|
90
|
+
|
|
91
|
+
<strong class="mb-s block">Simple horizontal table</strong>
|
|
92
|
+
|
|
93
|
+
<table class="mb-xxl">
|
|
94
|
+
<tbody>
|
|
95
|
+
<tr>
|
|
96
|
+
<th>One</th>
|
|
97
|
+
<td>First</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<th>Two</th>
|
|
101
|
+
<td>Second</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<th>Three</th>
|
|
105
|
+
<td>Third</td>
|
|
106
|
+
</tr>
|
|
107
|
+
</tbody>
|
|
108
|
+
</table>
|
|
109
|
+
|
|
110
|
+
<h5 class="mb-s">
|
|
111
|
+
Data table
|
|
112
|
+
</h5>
|
|
113
|
+
|
|
114
|
+
<p class="mb-s">
|
|
115
|
+
This example demonstrates the full capability of the table component. Including column sorting, pagination and row selection.
|
|
116
|
+
</p>
|
|
117
|
+
|
|
118
|
+
<Table.Root separate-cells class="mb-l">
|
|
119
|
+
<template #header>
|
|
120
|
+
<Table.SelectAll />
|
|
121
|
+
<Table.Head v-for="header in headers" :key="header.label" :header sort />
|
|
122
|
+
</template>
|
|
123
|
+
<template #body>
|
|
124
|
+
<tr v-for="row in rows" :key="row.Year">
|
|
125
|
+
<Table.SelectRow :row />
|
|
126
|
+
<Table.Cell>{{ row.Nation }}</Table.Cell>
|
|
127
|
+
<Table.Cell>{{ row.Population }}</Table.Cell>
|
|
128
|
+
<Table.Cell>{{ row.Year }}</Table.Cell>
|
|
129
|
+
</tr>
|
|
130
|
+
</template>
|
|
131
|
+
<template #pagination>
|
|
132
|
+
<Pagination :pagination :first-last="false" @change="setPage" />
|
|
133
|
+
</template>
|
|
134
|
+
</Table.Root>
|
|
135
|
+
|
|
136
|
+
<Accordion :label="`Selected rows (${selectedRows.size})`" class="mb-xl">
|
|
137
|
+
<pre>
|
|
138
|
+
{{ selectedRows }}
|
|
139
|
+
</pre>
|
|
140
|
+
</Accordion>
|
|
141
|
+
|
|
142
|
+
<h5 class="mb-s">
|
|
143
|
+
Variations
|
|
144
|
+
</h5>
|
|
145
|
+
|
|
146
|
+
<div class="typeset mb-xl">
|
|
147
|
+
<ul>
|
|
148
|
+
<li><p><code>separate-rows</code> Adds a border between rows (default: <code>true</code>)</p></li>
|
|
149
|
+
<li><p><code>separate-cells</code> Adds a border between cells (default: <code>false</code>)</p></li>
|
|
150
|
+
<li><p><code>outer-border</code> Adds a border around the entire table component (default: <code>true</code>)</p></li>
|
|
151
|
+
<li><p><code>nowrap</code> Adds ellipsis to text which overflows to keep row size consistent (default: <code>false</code>)</p></li>
|
|
152
|
+
<li><p><code>fixed</code> Keeps all the columns the same size (default: <code>false</code>)</p></li>
|
|
153
|
+
</ul>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="container container-s mb-xxl ml-0">
|
|
157
|
+
<Table.Root :outer-border="false" :separate-cells="true" nowrap fixed>
|
|
158
|
+
<template #body>
|
|
159
|
+
<tr v-for="row in allRows" :key="row.Year">
|
|
160
|
+
<Table.Cell>{{ `${row.Nation} ${row.Nation}` }}</Table.Cell>
|
|
161
|
+
<Table.Cell>{{ row.Population }}</Table.Cell>
|
|
162
|
+
<Table.Cell>{{ row.Year }}</Table.Cell>
|
|
163
|
+
</tr>
|
|
164
|
+
</template>
|
|
165
|
+
</Table.Root>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<h5 class="mb-s">
|
|
169
|
+
Pagination
|
|
170
|
+
</h5>
|
|
171
|
+
|
|
172
|
+
<p class="mb-m">
|
|
173
|
+
Pagination does not need to be used with table only. The calculation of pages is done via an external function and the pagination component accepts all the necesary props to implement it for any kind of dataset and UI
|
|
174
|
+
</p>
|
|
175
|
+
|
|
176
|
+
<p class="mb-m">
|
|
177
|
+
Here we have a list of names and we're gonna paginate through them:<br><br> {{ testData.join(', ') }}
|
|
178
|
+
</p>
|
|
179
|
+
<Pagination :pagination="paginationExample" @change="(num) => page = num" />
|
|
180
|
+
<div class="typeset">
|
|
181
|
+
<ul>
|
|
182
|
+
<li
|
|
183
|
+
v-for="name in exampleToRender"
|
|
184
|
+
:key="name"
|
|
185
|
+
>
|
|
186
|
+
{{ name }}
|
|
187
|
+
</li>
|
|
188
|
+
</ul>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<Divider :size="40" class="w-40" />
|
|
192
|
+
|
|
193
|
+
<p>The <code>defineTable</code> hook can also be used with other UI components. Not just tables. That's why all the table interactivity is not within the component, but in a hook. It's very flexible and allows custom functionality.</p>
|
|
194
|
+
</div>
|
|
195
|
+
</template>
|