ketekny-ui-kit 1.0.132 → 1.0.133

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ui/kCard.vue +62 -8
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ketekny-ui-kit",
3
3
  "type": "module",
4
- "version": "1.0.132",
4
+ "version": "1.0.133",
5
5
  "description": "A Vue 3 UI component library with Tailwind CSS styling",
6
6
  "main": "index.js",
7
7
  "files": [
package/src/ui/kCard.vue CHANGED
@@ -1,22 +1,44 @@
1
1
  <template>
2
- <article class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
2
+ <article class="self-start overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
3
3
  <header
4
4
  v-if="hasHeader"
5
- class="border-b border-slate-200 px-5 py-4"
5
+ class="flex items-start justify-between gap-3 border-slate-200 px-5 py-4"
6
+ :class="{
7
+ 'border-b': !isCollapsed,
8
+ 'group cursor-pointer select-none transition-colors hover:bg-slate-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand/30': collapsible,
9
+ }"
10
+ :role="collapsible ? 'button' : undefined"
11
+ :tabindex="collapsible ? 0 : undefined"
12
+ :aria-label="collapsible ? (isCollapsed ? 'Expand card body' : 'Collapse card body') : undefined"
13
+ :aria-expanded="collapsible ? !isCollapsed : undefined"
14
+ @click="collapsible && toggleCollapsed()"
15
+ @keydown.enter.prevent="collapsible && toggleCollapsed()"
16
+ @keydown.space.prevent="collapsible && toggleCollapsed()"
6
17
  >
7
- <slot name="header">
8
- <div>
18
+ <div class="min-w-0 flex-1">
19
+ <slot name="header">
9
20
  <p v-if="title" class="text-sm font-semibold text-slate-900">
10
21
  {{ title }}
11
22
  </p>
12
23
  <p v-if="subtitle" :class="title ? 'mt-1 text-sm text-slate-500' : 'text-sm text-slate-500'">
13
24
  {{ subtitle }}
14
25
  </p>
15
- </div>
16
- </slot>
26
+ </slot>
27
+ </div>
28
+
29
+ <span
30
+ v-if="collapsible"
31
+ class="-mr-1 inline-flex size-8 shrink-0 items-center justify-center text-slate-500 transition-colors group-hover:text-slate-700"
32
+ >
33
+ <ChevronDown
34
+ class="size-5 transition-transform duration-200"
35
+ :class="{ 'rotate-180': !isCollapsed }"
36
+ aria-hidden="true"
37
+ />
38
+ </span>
17
39
  </header>
18
40
 
19
- <div class="px-5 py-4">
41
+ <div v-show="!isCollapsed" class="px-5 py-4">
20
42
  <slot />
21
43
  </div>
22
44
 
@@ -30,8 +52,12 @@
30
52
  </template>
31
53
 
32
54
  <script>
55
+ import { ChevronDown } from '@lucide/vue'
56
+
33
57
  export default {
34
58
  name: 'kCard',
59
+ components: { ChevronDown },
60
+ emits: ['update:collapsed', 'toggle'],
35
61
  props: {
36
62
  title: {
37
63
  type: String,
@@ -41,10 +67,38 @@ export default {
41
67
  type: String,
42
68
  default: '',
43
69
  },
70
+ collapsible: {
71
+ type: Boolean,
72
+ default: false,
73
+ },
74
+ collapsed: {
75
+ type: Boolean,
76
+ default: false,
77
+ },
78
+ },
79
+ data() {
80
+ return {
81
+ internalCollapsed: this.collapsed,
82
+ }
44
83
  },
45
84
  computed: {
46
85
  hasHeader() {
47
- return Boolean(this.$slots.header || this.title || this.subtitle)
86
+ return Boolean(this.$slots.header || this.title || this.subtitle || this.collapsible)
87
+ },
88
+ isCollapsed() {
89
+ return this.collapsible && this.internalCollapsed
90
+ },
91
+ },
92
+ watch: {
93
+ collapsed(value) {
94
+ this.internalCollapsed = value
95
+ },
96
+ },
97
+ methods: {
98
+ toggleCollapsed() {
99
+ this.internalCollapsed = !this.internalCollapsed
100
+ this.$emit('update:collapsed', this.internalCollapsed)
101
+ this.$emit('toggle', this.internalCollapsed)
48
102
  },
49
103
  },
50
104
  }