@veritree/ui 0.72.1 → 0.74.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/mixins/floating-ui-item.js +4 -4
- package/mixins/form-control.js +9 -9
- package/package.json +6 -4
- package/src/components/Button/VTButton.vue +1 -1
- package/src/components/Listbox/VTListboxItem.vue +2 -2
- package/src/components/Listbox/VTListboxTrigger.vue +2 -13
- package/src/components/Listbox/VTListboxTriggerHighlight.vue +67 -85
- package/src/components/Popover/VTPopoverItem.vue +40 -22
- package/src/components/Popover/VTPopoverViewport.vue +33 -0
|
@@ -39,8 +39,8 @@ export const floatingUiItemMixin = {
|
|
|
39
39
|
? `${this.componentName}--disabled`
|
|
40
40
|
: null
|
|
41
41
|
: this.disabled
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
? 'pointer-events-none opacity-75'
|
|
43
|
+
: null,
|
|
44
44
|
// selected state styles
|
|
45
45
|
this.headless
|
|
46
46
|
? this.selected
|
|
@@ -49,8 +49,8 @@ export const floatingUiItemMixin = {
|
|
|
49
49
|
: `${this.componentName}--selected`
|
|
50
50
|
: null
|
|
51
51
|
: this.selected
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
? 'bg-gray-200'
|
|
53
|
+
: null,
|
|
54
54
|
];
|
|
55
55
|
},
|
|
56
56
|
},
|
package/mixins/form-control.js
CHANGED
|
@@ -53,7 +53,7 @@ export const formControlMixin = {
|
|
|
53
53
|
blur: (event) => {
|
|
54
54
|
this.$emit('blur', event);
|
|
55
55
|
},
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
57
|
);
|
|
58
58
|
},
|
|
59
59
|
|
|
@@ -78,18 +78,18 @@ export const formControlStyleMixin = {
|
|
|
78
78
|
this.headless
|
|
79
79
|
? `${this.name}--${this.variant}`
|
|
80
80
|
: this.isError
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
? 'border-error-300'
|
|
82
|
+
: this.isSuccess
|
|
83
|
+
? 'border-success-300'
|
|
84
|
+
: 'border-gray-300',
|
|
85
85
|
// height styles
|
|
86
86
|
this.headless
|
|
87
87
|
? null
|
|
88
88
|
: this.name === 'textarea'
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
? 'min-h-10' // limit it because input type number height can be different from other input types
|
|
90
|
+
: this.size === 'small'
|
|
91
|
+
? 'h-8 text-sm'
|
|
92
|
+
: 'h-10 text-base',
|
|
93
93
|
// disabled styles
|
|
94
94
|
this.disabled
|
|
95
95
|
? this.headless
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritree/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "veritree ui library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"repository": "https://github.com/tentree-org/veritree-ui.git",
|
|
8
8
|
"author": "cyroveritree <cyro@veritree.com>",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"registry": "https://registry.npmjs.org"
|
|
11
|
+
},
|
|
9
12
|
"scripts": {
|
|
10
13
|
"test": "vitest",
|
|
11
14
|
"coverage": "vitest run --coverage",
|
|
@@ -34,6 +37,5 @@
|
|
|
34
37
|
"engines": {
|
|
35
38
|
"npm": ">=8.0.0",
|
|
36
39
|
"node": ">=18.0.0"
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
? 'button'
|
|
13
13
|
: isIcon
|
|
14
14
|
? 'relative inline-flex items-center justify-center rounded-full [&_svg]:max-h-full [&_svg]:max-w-full'
|
|
15
|
-
: 'relative inline-flex rounded border border-solid px-4 text-sm font-
|
|
15
|
+
: 'relative inline-flex rounded border border-solid px-4 text-sm font-medium leading-none no-underline transition-all',
|
|
16
16
|
// variant styles
|
|
17
17
|
headless
|
|
18
18
|
? `button--${variant}`
|
|
@@ -88,7 +88,7 @@ export default {
|
|
|
88
88
|
checked() {
|
|
89
89
|
if (this.multiple) {
|
|
90
90
|
return this.apiListbox().valueComputed.some(
|
|
91
|
-
(value) => JSON.stringify(this.value) === JSON.stringify(value)
|
|
91
|
+
(value) => JSON.stringify(this.value) === JSON.stringify(value),
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -164,7 +164,7 @@ export default {
|
|
|
164
164
|
* with any of the items to get its index value
|
|
165
165
|
*/
|
|
166
166
|
const newItemSelectedIndex = this.items.findIndex((item) =>
|
|
167
|
-
item.text.toLowerCase().includes(this.search.toLowerCase())
|
|
167
|
+
item.text.toLowerCase().includes(this.search.toLowerCase()),
|
|
168
168
|
);
|
|
169
169
|
|
|
170
170
|
/**
|
|
@@ -11,17 +11,6 @@
|
|
|
11
11
|
@keydown.up.prevent="onKeyDownOrUp"
|
|
12
12
|
@keydown.esc.stop="onKeyEsc"
|
|
13
13
|
>
|
|
14
|
-
<!-- <template v-if="hasBadge">
|
|
15
|
-
<span
|
|
16
|
-
:class="[
|
|
17
|
-
headless
|
|
18
|
-
? 'listbox-button__badge'
|
|
19
|
-
: 'absolute -right-2 -top-2 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
|
-
</template> -->
|
|
25
14
|
<span :class="[headless ? 'listbox-button__text' : 'truncate text-left']">
|
|
26
15
|
<slot></slot>
|
|
27
16
|
</span>
|
|
@@ -171,8 +160,8 @@ export default {
|
|
|
171
160
|
keyCode === 'ArrowDown'
|
|
172
161
|
? 'firstMenuItem'
|
|
173
162
|
: keyCode === 'ArrowUp'
|
|
174
|
-
|
|
175
|
-
|
|
163
|
+
? 'lastMenuItem'
|
|
164
|
+
: null;
|
|
176
165
|
|
|
177
166
|
// settimeout here is delaying the focusing the element
|
|
178
167
|
// since it is not rendered yet. All items will only
|
|
@@ -9,39 +9,21 @@
|
|
|
9
9
|
? 'listbox-highlight--active'
|
|
10
10
|
: null
|
|
11
11
|
: isActive
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
? '[&>*]:border-gray-700'
|
|
13
|
+
: null,
|
|
14
14
|
]"
|
|
15
15
|
>
|
|
16
16
|
<slot />
|
|
17
17
|
</div>
|
|
18
|
-
<Portal>
|
|
19
|
-
<span
|
|
20
|
-
:id="counterId"
|
|
21
|
-
v-show="isBadgeVisible"
|
|
22
|
-
:class="[
|
|
23
|
-
headless
|
|
24
|
-
? 'listbox-highlight__badge'
|
|
25
|
-
: 'absolute z-40 grid h-5 min-w-[20px] place-content-center rounded-full bg-gray-800 text-xs font-medium text-white',
|
|
26
|
-
]"
|
|
27
|
-
>
|
|
28
|
-
{{ computedValueLength }}
|
|
29
|
-
</span>
|
|
30
|
-
</Portal>
|
|
31
18
|
</div>
|
|
32
19
|
</template>
|
|
33
20
|
|
|
34
21
|
<script>
|
|
35
|
-
import { Portal } from '@linusborg/vue-simple-portal';
|
|
36
22
|
import { computePosition, offset, autoUpdate } from '@floating-ui/dom';
|
|
37
23
|
|
|
38
24
|
export default {
|
|
39
25
|
name: 'VTListboxHighlight',
|
|
40
26
|
|
|
41
|
-
components: {
|
|
42
|
-
Portal,
|
|
43
|
-
},
|
|
44
|
-
|
|
45
27
|
inject: ['apiListbox'],
|
|
46
28
|
|
|
47
29
|
props: {
|
|
@@ -153,72 +135,72 @@ export default {
|
|
|
153
135
|
: this.defaultValue !== this.computedValue;
|
|
154
136
|
},
|
|
155
137
|
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
isBadgeVisible() {
|
|
166
|
-
|
|
167
|
-
},
|
|
138
|
+
// /**
|
|
139
|
+
// * Checks if the badge should be visible for the listbox item.
|
|
140
|
+
// *
|
|
141
|
+
// * @property
|
|
142
|
+
// * @name isBadgeVisible
|
|
143
|
+
// * @memberof VTListboxTriggerHighlight
|
|
144
|
+
// * @description Checks if the badge should be visible for the listbox item.
|
|
145
|
+
// * @returns {boolean} True if the badge should be visible, false otherwise.
|
|
146
|
+
// */
|
|
147
|
+
// isBadgeVisible() {
|
|
148
|
+
// return this.isValueAnArray && this.isActive;
|
|
149
|
+
// },
|
|
168
150
|
},
|
|
169
151
|
|
|
170
|
-
mounted() {
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
methods: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
},
|
|
152
|
+
// mounted() {
|
|
153
|
+
// this.$nextTick(() => this.positionFloatingContent());
|
|
154
|
+
// },
|
|
155
|
+
|
|
156
|
+
// methods: {
|
|
157
|
+
// /**
|
|
158
|
+
// * Positions the floating content relative to a specified trigger element.
|
|
159
|
+
// *
|
|
160
|
+
// * @function
|
|
161
|
+
// * @name positionFloatingContent
|
|
162
|
+
// * @description Calculates and updates the position of the floating content
|
|
163
|
+
// * based on the position of the reference element.
|
|
164
|
+
// * @returns {void}
|
|
165
|
+
// */
|
|
166
|
+
// positionFloatingContent() {
|
|
167
|
+
// /**
|
|
168
|
+
// * The reference element that triggers the positioning of the floating content.
|
|
169
|
+
// * @type {HTMLElement}
|
|
170
|
+
// */
|
|
171
|
+
// const referenceElement = document.getElementById(this.highlightId);
|
|
172
|
+
|
|
173
|
+
// /**
|
|
174
|
+
// * The floating element whose position needs to be updated.
|
|
175
|
+
// * @type {HTMLElement}
|
|
176
|
+
// */
|
|
177
|
+
// const floatingElement = document.getElementById(this.counterId);
|
|
178
|
+
|
|
179
|
+
// /**
|
|
180
|
+
// * Callback function to update the position of the floating element
|
|
181
|
+
// * using the autoUpdate and computePosition utilities.
|
|
182
|
+
// * @type {Function}
|
|
183
|
+
// */
|
|
184
|
+
// const updatePositionCallback = () => {
|
|
185
|
+
// computePosition(referenceElement, floatingElement, {
|
|
186
|
+
// placement: 'top-end',
|
|
187
|
+
// middleware: [
|
|
188
|
+
// offset({
|
|
189
|
+
// alignmentAxis: -10,
|
|
190
|
+
// mainAxis: -10,
|
|
191
|
+
// }),
|
|
192
|
+
// ],
|
|
193
|
+
// }).then(({ x, y }) => {
|
|
194
|
+
// Object.assign(floatingElement.style, {
|
|
195
|
+
// left: `${x}px`,
|
|
196
|
+
// top: `${y}px`,
|
|
197
|
+
// });
|
|
198
|
+
// });
|
|
199
|
+
// };
|
|
200
|
+
|
|
201
|
+
// // Call the autoUpdate function with the specified elements and callback.
|
|
202
|
+
// autoUpdate(referenceElement, floatingElement, updatePositionCallback);
|
|
203
|
+
// },
|
|
204
|
+
// },
|
|
223
205
|
};
|
|
224
206
|
</script>
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="as"
|
|
4
|
-
:class="[
|
|
5
|
-
// default styles
|
|
6
|
-
headless
|
|
7
|
-
? 'popover-item'
|
|
8
|
-
: 'relative z-10 -mx-3 flex items-center gap-2 px-3 py-2 text-inherit no-underline hover:bg-secondary-200/10',
|
|
9
|
-
]"
|
|
10
|
-
@click="onClick"
|
|
11
|
-
>
|
|
2
|
+
<component :is="as" :class="classComputed">
|
|
12
3
|
<slot></slot>
|
|
13
4
|
</component>
|
|
14
5
|
</template>
|
|
@@ -32,27 +23,54 @@ export default {
|
|
|
32
23
|
type: [String, Object],
|
|
33
24
|
default: null,
|
|
34
25
|
},
|
|
26
|
+
as: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'div',
|
|
29
|
+
},
|
|
35
30
|
},
|
|
36
31
|
|
|
37
32
|
computed: {
|
|
38
|
-
|
|
39
|
-
return
|
|
33
|
+
classComputed() {
|
|
34
|
+
return [
|
|
35
|
+
// default styles
|
|
36
|
+
this.headless
|
|
37
|
+
? `${this.componentName}`
|
|
38
|
+
: 'relative z-10 text-sm flex items-center gap-2 px-3 py-2 text-inherit no-underline cursor-pointer',
|
|
39
|
+
// disabled state styles
|
|
40
|
+
this.headless
|
|
41
|
+
? this.disabled
|
|
42
|
+
? `${this.componentName}--disabled`
|
|
43
|
+
: null
|
|
44
|
+
: this.disabled
|
|
45
|
+
? 'pointer-events-none opacity-75'
|
|
46
|
+
: null,
|
|
47
|
+
// selected state styles
|
|
48
|
+
// this.headless
|
|
49
|
+
// ? this.selected
|
|
50
|
+
// ? this.multiple
|
|
51
|
+
// ? null
|
|
52
|
+
// : `${this.componentName}--selected`
|
|
53
|
+
// : null
|
|
54
|
+
// : this.selected
|
|
55
|
+
// ? 'bg-gray-200'
|
|
56
|
+
// : null,
|
|
57
|
+
];
|
|
40
58
|
},
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
60
|
+
// tag() {
|
|
61
|
+
// if(this.href) {
|
|
45
62
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
// }
|
|
64
|
+
|
|
65
|
+
// return this.href ? 'a' : this.to ? 'NuxtLink' : 'button';
|
|
66
|
+
// },
|
|
49
67
|
},
|
|
50
68
|
|
|
51
69
|
methods: {
|
|
52
|
-
onClick() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
70
|
+
// onClick() {
|
|
71
|
+
// if (this.href || this.to) return;
|
|
72
|
+
// this.$emit('click');
|
|
73
|
+
// },
|
|
56
74
|
},
|
|
57
75
|
};
|
|
58
76
|
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="id"
|
|
4
|
+
:class="[
|
|
5
|
+
headless
|
|
6
|
+
? 'listbox-viewport'
|
|
7
|
+
: '-mx-3 max-h-[200px] w-auto overflow-y-auto scroll-auto',
|
|
8
|
+
]"
|
|
9
|
+
>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'VTListboxViewport',
|
|
17
|
+
|
|
18
|
+
inject: ['apiPopover'],
|
|
19
|
+
|
|
20
|
+
props: {
|
|
21
|
+
headless: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
computed: {
|
|
28
|
+
id() {
|
|
29
|
+
return `popover-viewport-${this.apiPopover().id}`;
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
</script>
|