picocrank 1.1.2 → 1.2.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/package.json +3 -3
- package/vue/components/Sidebar.vue +5 -3
- package/vue/components/Table.vue +22 -14
- package/vue/examples/TableExample.vue +15 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "picocrank",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A set of zero dependency Vue components built on the Femtocrank global CSS theme.",
|
|
5
5
|
"main": "vite.config.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"@hugeicons/core-free-icons": "^1.0.16",
|
|
20
20
|
"@hugeicons/vue": "^1.0.3",
|
|
21
21
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
22
|
-
"femtocrank": "^2.3.
|
|
22
|
+
"femtocrank": "^2.3.1",
|
|
23
23
|
"unplugin-vue-components": "^29.0.0",
|
|
24
24
|
"vite": "^7.1.3",
|
|
25
|
-
"vue": "^3.5.
|
|
25
|
+
"vue": "^3.5.19",
|
|
26
26
|
"vue-router": "^4.5.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -151,6 +151,10 @@ defineExpose({
|
|
|
151
151
|
|
|
152
152
|
<style scoped>
|
|
153
153
|
|
|
154
|
+
h2 {
|
|
155
|
+
padding: .75em;
|
|
156
|
+
}
|
|
157
|
+
|
|
154
158
|
.active {
|
|
155
159
|
text-decoration: underline;
|
|
156
160
|
}
|
|
@@ -164,10 +168,8 @@ li {
|
|
|
164
168
|
display: flex;
|
|
165
169
|
align-items: center;
|
|
166
170
|
gap: 0.75rem;
|
|
167
|
-
padding:
|
|
171
|
+
padding: .75em;
|
|
168
172
|
color: #333;
|
|
169
|
-
transition: background-color 0.2s ease;
|
|
170
|
-
border-left: 3px solid transparent;
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
.navigation-links a:hover,
|
package/vue/components/Table.vue
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<table class = "row-hover">
|
|
3
3
|
<thead>
|
|
4
|
-
<th v-for="(header, index) in visibleHeaders" :key="index" @click="toggleSort(header)" :class="{ sortable: header.sortable }">
|
|
5
|
-
{{ header.label }}
|
|
4
|
+
<th v-for="(header, index) in visibleHeaders" :key="index" @click="toggleSort(header)" :class="{ sortable: header.sortable }" :style="{ width: header.width || 'auto' }">
|
|
5
|
+
{{ header.label || header.key }}
|
|
6
6
|
|
|
7
7
|
<span v-if="header.sortable" style:= "width: 1.5em; display: inline-block; text-align: center;">
|
|
8
8
|
<span v-if="sortBy === header.key">
|
|
@@ -16,15 +16,18 @@
|
|
|
16
16
|
<tr v-if="pagedItems.length === 0">
|
|
17
17
|
<td :colspan="visibleHeaders.length">No items found</td>
|
|
18
18
|
</tr>
|
|
19
|
-
<tr v-else v-for="(
|
|
19
|
+
<tr v-else v-for="(row, index) in pagedItems" :key="index">
|
|
20
20
|
<td v-for="(header, index) in visibleHeaders" :key="index" :class="{ hidden: header.hidden }">
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
<component
|
|
22
|
+
v-if="slotFor(header.key)"
|
|
23
|
+
:is="slotFor(header.key)"
|
|
24
|
+
:class="{ hidden: header.hidden }"
|
|
25
|
+
:row="row"
|
|
26
|
+
:value="row[header.key]"
|
|
27
|
+
:key="index"
|
|
28
|
+
/>
|
|
26
29
|
<span v-else>
|
|
27
|
-
{{
|
|
30
|
+
{{ row[header.key] }}
|
|
28
31
|
</span>
|
|
29
32
|
</td>
|
|
30
33
|
</tr>
|
|
@@ -36,7 +39,7 @@
|
|
|
36
39
|
</template>
|
|
37
40
|
|
|
38
41
|
<script setup>
|
|
39
|
-
import { ref, computed, onMounted, watch } from 'vue';
|
|
42
|
+
import { ref, computed, onMounted, watch, useSlots } from 'vue';
|
|
40
43
|
import Pagination from './Pagination.vue';
|
|
41
44
|
|
|
42
45
|
const sortBy = ref(null);
|
|
@@ -55,6 +58,14 @@
|
|
|
55
58
|
},
|
|
56
59
|
});
|
|
57
60
|
|
|
61
|
+
const slots = useSlots()
|
|
62
|
+
|
|
63
|
+
function slotFor(key) {
|
|
64
|
+
let s = slots[`cell-${key}`];
|
|
65
|
+
|
|
66
|
+
return s || slots.cell || null;
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
const items = computed(() => {
|
|
59
70
|
const arr = [...props.data];
|
|
60
71
|
|
|
@@ -100,10 +111,7 @@
|
|
|
100
111
|
const totalPages = computed(() => Math.ceil(total.value / pageSize.value));
|
|
101
112
|
|
|
102
113
|
const visibleHeaders = computed(() => {
|
|
103
|
-
return props.headers.
|
|
104
|
-
...header,
|
|
105
|
-
hidden: header.hidden === true,
|
|
106
|
-
}));
|
|
114
|
+
return props.headers.filter(h => !h.hidden);
|
|
107
115
|
});
|
|
108
116
|
|
|
109
117
|
function toggleSort(header) {
|
|
@@ -12,6 +12,17 @@
|
|
|
12
12
|
:data = "data"
|
|
13
13
|
:headers = "headers"
|
|
14
14
|
>
|
|
15
|
+
<template #cell-name="{ row, value }">
|
|
16
|
+
<router-link :to="{ name: 'ViewItem', params: { id: row.name } }">
|
|
17
|
+
{{ value }}
|
|
18
|
+
</router-link>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<template #cell-city="{ row, value }">
|
|
22
|
+
<span class = "subtle">
|
|
23
|
+
{{ value }}
|
|
24
|
+
</span>
|
|
25
|
+
</template>
|
|
15
26
|
</Table>
|
|
16
27
|
</Section>
|
|
17
28
|
</template>
|
|
@@ -20,24 +31,16 @@
|
|
|
20
31
|
import { ref, onMounted } from 'vue'
|
|
21
32
|
|
|
22
33
|
const headers = ref([
|
|
23
|
-
{ key: "name", label: "Name", sortable: true, hidden:
|
|
24
|
-
{ key: "age", label: "Age", sortable: false
|
|
25
|
-
{ key: "city", label: "City", sortable: true,
|
|
34
|
+
{ key: "name", label: "Name", sortable: true, hidden: false, width: "20%" },
|
|
35
|
+
{ key: "age", label: "Age", sortable: false },
|
|
36
|
+
{ key: "city", label: "City", sortable: true, width: "200px" },
|
|
26
37
|
])
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
function getLink(row) {
|
|
30
|
-
return {
|
|
31
|
-
name: "ViewItem",
|
|
32
|
-
params: { id: row.name.toLowerCase() }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
39
|
const data = ref([])
|
|
37
40
|
|
|
38
41
|
onMounted(() => {
|
|
39
42
|
data.value = [
|
|
40
|
-
{ name: "Alice", age: 30, city: "New York" },
|
|
43
|
+
{ name: "Alice", age: 30, city: "New York", foo: "bar" },
|
|
41
44
|
{ name: "Bob", age: 25, city: "Los Angeles" },
|
|
42
45
|
{ name: "Charlie", age: 35, city: "Chicago" },
|
|
43
46
|
{ name: "David", age: 28, city: "Houston" },
|