@stonecrop/atable 0.13.12 → 0.14.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,105 +0,0 @@
1
- <template>
2
- <tr v-bind="$attrs" ref="rowEl" :tabindex="tabIndex" class="expandable-row">
3
- <td :tabIndex="-1" class="row-index" @click="store.toggleRowExpand(rowIndex)">
4
- {{ rowExpandSymbol }}
5
- </td>
6
- <slot name="row" />
7
- </tr>
8
- <tr v-if="store.display[rowIndex].expanded" ref="rowExpanded" :tabindex="tabIndex" class="expanded-row">
9
- <td :tabIndex="-1" :colspan="store.columns.length + 1" class="expanded-row-content">
10
- <slot name="content" />
11
- </td>
12
- </tr>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { defaultKeypressHandlers, type KeypressHandlers, useKeyboardNav } from '@stonecrop/utilities'
17
- import { computed, useTemplateRef } from 'vue'
18
-
19
- import { createTableStore } from '../stores/table'
20
-
21
- const {
22
- rowIndex,
23
- store,
24
- tabIndex = -1,
25
- addNavigation = defaultKeypressHandlers,
26
- } = defineProps<{
27
- rowIndex: number
28
- store: ReturnType<typeof createTableStore>
29
- tabIndex?: number
30
- addNavigation?: boolean | KeypressHandlers
31
- }>()
32
-
33
- const rowRef = useTemplateRef<HTMLTableRowElement>('rowEl')
34
- // const expandedRowRef = useTemplateRef<HTMLDivElement>('rowExpanded')
35
-
36
- const rowExpandSymbol = computed(() => {
37
- return store.display[rowIndex].expanded ? '▼' : '►'
38
- })
39
-
40
- if (addNavigation) {
41
- const handlers: KeypressHandlers = {
42
- 'keydown.control.g': (event: KeyboardEvent) => {
43
- event.stopPropagation()
44
- event.preventDefault()
45
- store.toggleRowExpand(rowIndex)
46
- },
47
- }
48
-
49
- if (typeof addNavigation === 'object') {
50
- Object.assign(handlers, addNavigation)
51
- }
52
-
53
- useKeyboardNav([
54
- {
55
- selectors: rowRef,
56
- handlers: handlers,
57
- },
58
- ])
59
- }
60
- </script>
61
-
62
- <style>
63
- @import url('@stonecrop/themes/default.css');
64
-
65
- .row-index {
66
- color: var(--sc-header-text-color);
67
- font-weight: bold;
68
- text-align: center;
69
- user-select: none;
70
- width: 2ch;
71
- display: flex;
72
- align-items: center;
73
- justify-content: center;
74
- }
75
-
76
- .expandable-row {
77
- border-top: 1px solid var(--sc-row-border-color);
78
- height: var(--sc-atable-row-height);
79
- }
80
-
81
- .expandable-row > td:first-child {
82
- border-left: 4px solid var(--sc-row-border-color);
83
- }
84
-
85
- .expanded-row {
86
- border-left: 2px solid var(--sc-row-border-color);
87
- }
88
-
89
- .expandable-row:last-child {
90
- border-bottom: 1px solid var(--sc-row-border-color);
91
- }
92
-
93
- .expanded-row-content {
94
- border-top: 1px solid var(--sc-row-border-color);
95
- padding: 1.5rem;
96
- }
97
- </style>
98
-
99
- <style scoped>
100
- .expandable-row.changed-row-gradient:has(td.cell-modified) {
101
- --cell-color-start: color-mix(in srgb, var(--sc-cell-changed-color), #fff 20%);
102
- --cell-color-end: color-mix(in srgb, var(--sc-cell-changed-color), #fff 60%);
103
- background: linear-gradient(90deg, var(--cell-color-start), var(--cell-color-end));
104
- }
105
- </style>