@veritree/ui 0.90.0 → 0.90.1

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.
@@ -44,14 +44,12 @@ export const floatingUiContentMixin = {
44
44
 
45
45
  setTimeout(() => {
46
46
  if (!this.id) {
47
- console.log('No id provided');
48
47
  return;
49
48
  }
50
49
 
51
50
  this.el = document.getElementById(this.id);
52
51
 
53
52
  if (!this.el) {
54
- console.log('Element not found', this.id);
55
53
  return;
56
54
  }
57
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.90.0",
3
+ "version": "0.90.1",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -102,7 +102,6 @@ export default {
102
102
  },
103
103
 
104
104
  setVisible(visible) {
105
- console.log('setVisible', visible);
106
105
  this.visible = visible;
107
106
  },
108
107
  },
@@ -1,17 +1,11 @@
1
1
  <template>
2
2
  <header
3
3
  :id="id"
4
- :class="[
5
- headless
6
- ? 'details-header'
7
- : 'flex cursor-pointer justify-between gap-3 text-body font-semibold',
8
- ]"
9
- :aria-controls="ariaControls"
10
- :aria-expanded="ariaExpanded"
11
- role="button"
12
- tabindex="0"
13
- @click.prevent="toggle"
14
- @keydown.enter="toggle"
4
+ :class="headerClasses"
5
+ v-bind="ariaAttributes"
6
+ @click.prevent="handleClick"
7
+ @keydown.enter.prevent="handleKeydown"
8
+ @keydown.space.prevent="handleKeydown"
15
9
  >
16
10
  <slot></slot>
17
11
  </header>
@@ -24,6 +18,18 @@ export default {
24
18
  inject: ['apiDisclosure', 'apiDetails'],
25
19
 
26
20
  props: {
21
+ /**
22
+ * If true, the header will not toggle visibility of the content.
23
+ * Useful for headers that are purely informational.
24
+ */
25
+ actionless: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
29
+ /**
30
+ * If true, the header will not have any visual styles applied.
31
+ * Useful for headless implementations where you want to style it yourself.
32
+ */
27
33
  headless: {
28
34
  type: Boolean,
29
35
  default: false,
@@ -31,6 +37,30 @@ export default {
31
37
  },
32
38
 
33
39
  computed: {
40
+ headerClasses() {
41
+ if (this.headless) {
42
+ return 'details-header';
43
+ }
44
+
45
+ const classes = ['flex justify-between gap-3 text-body font-semibold'];
46
+ classes.push(this.actionless ? 'cursor-default' : 'cursor-pointer');
47
+
48
+ return classes;
49
+ },
50
+
51
+ ariaAttributes() {
52
+ if (this.actionless) {
53
+ return {};
54
+ }
55
+
56
+ return {
57
+ 'aria-controls': this.ariaControls,
58
+ 'aria-expanded': this.ariaExpanded,
59
+ 'role': 'button',
60
+ 'tabindex': '0',
61
+ };
62
+ },
63
+
34
64
  id() {
35
65
  return this.apiDetails().idSummary;
36
66
  },
@@ -40,7 +70,7 @@ export default {
40
70
  },
41
71
 
42
72
  isVisible() {
43
- return this.apiDetails().isVisible();
73
+ return this.apiDetails().visible;
44
74
  },
45
75
 
46
76
  ariaExpanded() {
@@ -50,8 +80,24 @@ export default {
50
80
 
51
81
  methods: {
52
82
  toggle() {
83
+ if (this.actionless) {
84
+ return;
85
+ }
86
+
53
87
  this.apiDetails().setVisible(!this.isVisible);
54
88
  },
89
+
90
+ handleClick() {
91
+ if (!this.actionless) {
92
+ this.toggle();
93
+ }
94
+ },
95
+
96
+ handleKeydown() {
97
+ if (!this.actionless) {
98
+ this.toggle();
99
+ }
100
+ },
55
101
  },
56
102
  };
57
103
  </script>
@@ -2,7 +2,7 @@
2
2
  <component
3
3
  :is="as"
4
4
  :class="iconClasses"
5
- :aria-expanded="as === 'button' ? expanded : undefined"
5
+ v-bind="ariaAttributes"
6
6
  @click.stop="onClick"
7
7
  @keydown.enter="onClick"
8
8
  @keydown.space.prevent="onClick"
@@ -32,6 +32,17 @@ export default {
32
32
  },
33
33
 
34
34
  computed: {
35
+ ariaAttributes() {
36
+ if (this.as !== 'button') {
37
+ return {};
38
+ }
39
+
40
+ return {
41
+ 'aria-expanded': String(this.expanded),
42
+ 'aria-controls': this.apiDetails().idContent,
43
+ };
44
+ },
45
+
35
46
  iconClasses() {
36
47
  const classes = [];
37
48
 
@@ -40,6 +51,7 @@ export default {
40
51
  } else {
41
52
  classes.push('shrink-0 transition-all');
42
53
  classes.push(this.expanded ? 'rotate-180' : 'rotate-0');
54
+ classes.push(this.as === 'button' ? null : 'pointer-events-none');
43
55
  }
44
56
 
45
57
  return classes.filter(Boolean);