@veritree/ui 0.59.0 → 0.61.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.
@@ -69,8 +69,6 @@ export const formControlStyleMixin = {
69
69
  ? 'border-error-300'
70
70
  : this.isSuccess
71
71
  ? 'border-success-300'
72
- : this.isOutline
73
- ? 'border-gray-700'
74
72
  : 'border-gray-300',
75
73
  // height styles
76
74
  this.headless
@@ -86,11 +84,5 @@ export const formControlStyleMixin = {
86
84
  : null,
87
85
  ];
88
86
  },
89
-
90
- // not all places as form control is used needs outline,
91
- // so this is here mostly as a placeholder
92
- isOutline() {
93
- return null
94
- }
95
87
  },
96
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.59.0",
3
+ "version": "0.61.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="{ listbox: headless }">
2
+ <div :class="[headless ? 'listbox' : null]">
3
3
  <slot></slot>
4
4
  </div>
5
5
  </template>
@@ -11,7 +11,7 @@
11
11
  @keydown.up.prevent="onKeyDownOrUp"
12
12
  @keydown.esc.stop="onKeyEsc"
13
13
  >
14
- <template v-if="hasBadge">
14
+ <!-- <template v-if="hasBadge">
15
15
  <span
16
16
  :class="[
17
17
  headless
@@ -21,7 +21,7 @@
21
21
  >
22
22
  {{ valueLength }}
23
23
  </span>
24
- </template>
24
+ </template> -->
25
25
  <span :class="[headless ? 'listbox-button__text' : 'truncate text-left']">
26
26
  <slot></slot>
27
27
  </span>
@@ -86,21 +86,21 @@ export default {
86
86
  return this.items[this.items.length - 1];
87
87
  },
88
88
 
89
- valueLength() {
90
- if (this.multiple) {
91
- return this.apiListbox().valueComputed.length;
92
- }
89
+ // valueLength() {
90
+ // if (this.multiple) {
91
+ // return this.apiListbox().valueComputed.length;
92
+ // }
93
93
 
94
- return 0;
95
- },
94
+ // return 0;
95
+ // },
96
96
 
97
- hasBadge() {
98
- return this.valueLength > 0;
99
- },
97
+ // hasBadge() {
98
+ // return this.valueLength > 0;
99
+ // },
100
100
 
101
- isOutline() {
102
- return this.valueLength > 0;
103
- },
101
+ // isOutline() {
102
+ // return this.valueLength > 0;
103
+ // },
104
104
  },
105
105
 
106
106
  mounted() {
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ headless ? 'listbox-highlight' : 'relative',
5
+ headless
6
+ ? isActive
7
+ ? 'listbox-highlight--active'
8
+ : null
9
+ : isActive
10
+ ? '[&>*]:border-gray-700'
11
+ : null,
12
+ ]"
13
+ >
14
+ <span
15
+ v-show="isBadgeVisible"
16
+ :class="[
17
+ headless
18
+ ? 'listbox-highlight__badge'
19
+ : 'absolute -right-2 -top-2 z-10 grid h-5 min-w-[20px] place-content-center rounded-full bg-gray-800 text-xs font-medium text-white',
20
+ ]"
21
+ >
22
+ {{ valueLength }}
23
+ </span>
24
+ <slot />
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ export default {
30
+ name: 'VTListboxHighlight',
31
+
32
+ inject: ['apiListbox'],
33
+
34
+ props: {
35
+ /**
36
+ * Determines whether the button will use its default atomic style (tailwind) or its default class
37
+ * @type {boolean}
38
+ * @values
39
+ * - true: The button will have no default style and can be fully customized with a custom class
40
+ * - false: The button will use its default atomic style (tailwind) and can be further customized with additional classes
41
+ * @default null
42
+ */
43
+ headless: {
44
+ type: Boolean,
45
+ default: false,
46
+ },
47
+ /**
48
+ * The default value for the listbox item, used to determine its initial state.
49
+ * @type {string|null}
50
+ * @default null
51
+ */
52
+ defaultValue: {
53
+ type: String,
54
+ default: null,
55
+ },
56
+ },
57
+
58
+ computed: {
59
+ // Computes the current value of the listbox item.
60
+ value() {
61
+ return this.apiListbox().valueComputed;
62
+ },
63
+
64
+ // Checks if the computed value is an array.
65
+ isValueAnArray() {
66
+ return Array.isArray(this.value);
67
+ },
68
+
69
+ // Computes the length of the value, considering whether it's an array or a single value.
70
+ valueLength() {
71
+ return this.isValueAnArray ? this.value.length : this.value ? 1 : 0;
72
+ },
73
+
74
+ // Determines if the listbox item is active based on its value and default value.
75
+ isActive() {
76
+ return this.isValueAnArray
77
+ ? this.valueLength > 0
78
+ : this.defaultValue !== this.value;
79
+ },
80
+
81
+ // Checks if the badge should be visible for the listbox item.
82
+ isBadgeVisible() {
83
+ return this.isValueAnArray && this.isActive;
84
+ },
85
+ },
86
+ };
87
+ </script>