@veritree/ui 0.19.2-2 → 0.19.2-20
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-content.js +102 -0
- package/mixins/floating-ui-item.js +219 -0
- package/mixins/floating-ui.js +74 -0
- package/mixins/form-control-icon.js +53 -0
- package/mixins/form-control.js +73 -0
- package/package.json +7 -3
- package/src/components/Avatar/VTAvatar.vue +32 -29
- package/src/components/Button/VTButton.vue +9 -5
- package/src/components/Dialog/VTDialog.vue +6 -11
- package/src/components/Dialog/VTDialogClose.vue +9 -9
- package/src/components/Dialog/VTDialogContent.vue +9 -9
- package/src/components/Dialog/VTDialogFooter.vue +5 -5
- package/src/components/Dialog/VTDialogHeader.vue +8 -8
- package/src/components/Dialog/VTDialogMain.vue +8 -8
- package/src/components/Dialog/VTDialogOverlay.vue +8 -8
- package/src/components/Dialog/VTDialogTitle.vue +4 -4
- package/src/components/Disclosure/VTDisclosureContent.vue +1 -1
- package/src/components/Disclosure/VTDisclosureDetails.vue +2 -2
- package/src/components/Disclosure/VTDisclosureHeader.vue +1 -1
- package/src/components/Disclosure/VTDisclosureIcon.vue +1 -1
- package/src/components/Drawer/VTDrawer.vue +14 -16
- package/src/components/Drawer/VTDrawerClose.vue +9 -9
- package/src/components/Drawer/VTDrawerContent.vue +8 -8
- package/src/components/Drawer/VTDrawerFooter.vue +3 -3
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +27 -29
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +27 -70
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +8 -5
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +14 -123
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +3 -3
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +96 -121
- package/src/components/Form/VTFormFeedback.vue +33 -22
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +40 -0
- package/src/components/Form/VTInputIcon.vue +35 -0
- package/src/components/Form/VTInputPassword.vue +55 -0
- package/src/components/Form/VTTextarea.vue +22 -0
- package/src/components/Listbox/VTListbox.vue +26 -45
- package/src/components/Listbox/VTListboxContent.vue +24 -116
- package/src/components/Listbox/VTListboxItem.vue +10 -182
- package/src/components/Listbox/VTListboxLabel.vue +0 -10
- package/src/components/Listbox/VTListboxList.vue +24 -33
- package/src/components/Listbox/VTListboxSearch.vue +30 -29
- package/src/components/Listbox/VTListboxTrigger.vue +71 -88
- package/src/components/Popover/VTPopover.vue +24 -30
- package/src/components/Popover/VTPopoverContent.vue +24 -59
- package/src/components/Popover/VTPopoverDivider.vue +4 -11
- package/src/components/Popover/VTPopoverItem.vue +21 -14
- package/src/components/Popover/VTPopoverTrigger.vue +126 -21
- package/src/components/Tabs/VTTab.vue +10 -11
- package/src/components/Tabs/VTTabGroup.vue +9 -7
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +58 -0
- package/package-lock.json +0 -13
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import FloatingUi from '../src/components/Utils/FloatingUi.vue';
|
|
2
|
+
|
|
3
|
+
export const floatingUiContentMixin = {
|
|
4
|
+
components: {
|
|
5
|
+
FloatingUi,
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
props: {
|
|
9
|
+
headless: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
floatingUiClass: {
|
|
14
|
+
type: [String, Function],
|
|
15
|
+
default: null,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
el: null,
|
|
22
|
+
isMousemove: false,
|
|
23
|
+
visible: false,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
mounted() {
|
|
28
|
+
document.addEventListener('click', (e) => this.onDocumentClick(e));
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
destroyed() {
|
|
32
|
+
document.removeEventListener('click', this.onDocumentClick);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
methods: {
|
|
36
|
+
show() {
|
|
37
|
+
if (this.visible) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.visible = true;
|
|
42
|
+
|
|
43
|
+
this.$nextTick(() => {
|
|
44
|
+
this.component.setActive();
|
|
45
|
+
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
this.el = document.getElementById(this.id);
|
|
48
|
+
this.$emit('shown');
|
|
49
|
+
}, 100);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
hide() {
|
|
54
|
+
if (!this.visible) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.visible = false;
|
|
59
|
+
|
|
60
|
+
this.$nextTick(() => {
|
|
61
|
+
this.component.clearActive();
|
|
62
|
+
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
this.el = document.getElementById(this.id);
|
|
65
|
+
this.$emit('hidden');
|
|
66
|
+
}, 100);
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
onDocumentClick(e) {
|
|
71
|
+
if (!e) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
|
|
77
|
+
if (this.visible && !this.el.contains(e.target)) {
|
|
78
|
+
this.componentTrigger.cancel();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// Mousemove instead of mouseover to support keyboard navigation.
|
|
83
|
+
// The problem with mouseover is that when scrolling (scrollIntoView),
|
|
84
|
+
// mouseover event gets triggered.
|
|
85
|
+
setMousemove() {
|
|
86
|
+
this.isMousemove = true;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
unsetMousemove() {
|
|
90
|
+
this.isMousemove = false;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
getMousemove() {
|
|
94
|
+
return this.isMousemove;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
//
|
|
98
|
+
setActiveDescedant(id) {
|
|
99
|
+
this.activeDescedant = id;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
export const floatingUiItemMixin = {
|
|
2
|
+
props: {
|
|
3
|
+
headless: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
default: false,
|
|
6
|
+
},
|
|
7
|
+
disabled: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
computed: {
|
|
14
|
+
id() {
|
|
15
|
+
return `${this.componentName}-${this.apiInjected().id}-${this.index}`;
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
items() {
|
|
19
|
+
return this.apiInjected().items;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
el() {
|
|
23
|
+
return this.$el;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
componentContent() {
|
|
27
|
+
return this.apiInjected().componentContent;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
componentTrigger() {
|
|
31
|
+
return this.apiInjected().componentTrigger;
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
classComputed() {
|
|
35
|
+
return [
|
|
36
|
+
// default styles
|
|
37
|
+
this.headless
|
|
38
|
+
? `${this.componentName}`
|
|
39
|
+
: 'relative z-10 flex items-center gap-2 px-3 py-2 text-inherit no-underline',
|
|
40
|
+
// disabled state styles
|
|
41
|
+
this.headless
|
|
42
|
+
? this.disabled
|
|
43
|
+
? `${this.componentName}--disabled`
|
|
44
|
+
: null
|
|
45
|
+
: this.disabled
|
|
46
|
+
? 'pointer-events-none opacity-75'
|
|
47
|
+
: null,
|
|
48
|
+
// selected state styles
|
|
49
|
+
this.headless
|
|
50
|
+
? this.selected
|
|
51
|
+
? `${this.componentName}--selected`
|
|
52
|
+
: null
|
|
53
|
+
: this.selected
|
|
54
|
+
? 'bg-secondary-200/10'
|
|
55
|
+
: null,
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
data() {
|
|
61
|
+
return {
|
|
62
|
+
index: null,
|
|
63
|
+
selected: false,
|
|
64
|
+
tabIndex: 0,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
watch: {
|
|
69
|
+
selected(newValue) {
|
|
70
|
+
if (!newValue || !this.componentContent) return;
|
|
71
|
+
|
|
72
|
+
this.componentContent.setActiveDescedant(this.id);
|
|
73
|
+
|
|
74
|
+
const isMousemove = this.componentContent.getMousemove();
|
|
75
|
+
|
|
76
|
+
if (!isMousemove) {
|
|
77
|
+
this.el.scrollIntoView({ block: 'nearest' });
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
mounted() {
|
|
83
|
+
this.init();
|
|
84
|
+
this.addMouseEventListeners();
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
beforeUnmount() {
|
|
88
|
+
this.apiInjected().unregisterItem(this.id);
|
|
89
|
+
this.removeMouseEventListeners();
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
methods: {
|
|
93
|
+
init() {
|
|
94
|
+
this.index = this.items.length;
|
|
95
|
+
|
|
96
|
+
const item = {
|
|
97
|
+
id: this.id,
|
|
98
|
+
select: this.select,
|
|
99
|
+
unselect: this.unselect,
|
|
100
|
+
focus: this.focus,
|
|
101
|
+
onClick: this.onClick,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
this.apiInjected().registerItem(item);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
addMouseEventListeners() {
|
|
108
|
+
this.el.addEventListener('mousemove', this.onMousemove);
|
|
109
|
+
this.el.addEventListener('mouseleave', this.onMouseleave);
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
removeMouseEventListeners() {
|
|
113
|
+
this.el.removeEventListener('mousemove', this.onMousemove);
|
|
114
|
+
this.el.removeEventListener('mouseleave', this.onMouseleave);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
select() {
|
|
118
|
+
this.selected = true;
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
unselect() {
|
|
122
|
+
this.selected = false;
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
focus() {
|
|
126
|
+
if (!this.el) return;
|
|
127
|
+
|
|
128
|
+
this.tabIndex = -1;
|
|
129
|
+
this.selected = true;
|
|
130
|
+
this.el.focus();
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
focusFirstItem() {
|
|
134
|
+
this.setFocusToItem(0);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
focusLastItem() {
|
|
138
|
+
this.setFocusToItem(this.items.length - 1);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Focus the previous item in the menu.
|
|
143
|
+
* If is the first item, jump to the last item.
|
|
144
|
+
*/
|
|
145
|
+
focusPreviousItem() {
|
|
146
|
+
const isLast = this.index === this.items.length - 1;
|
|
147
|
+
const goToIndex = isLast ? 0 : this.index + 1;
|
|
148
|
+
|
|
149
|
+
this.setFocusToItem(goToIndex);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Focus the next item in the menu.
|
|
154
|
+
* If is the last item, jump to the first item.
|
|
155
|
+
*/
|
|
156
|
+
focusNextItem() {
|
|
157
|
+
const isFirst = this.index === 0;
|
|
158
|
+
const goToIndex = isFirst ? this.items.length - 1 : this.index - 1;
|
|
159
|
+
|
|
160
|
+
this.setFocusToItem(goToIndex);
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Focus item by remove its tabindex and calling
|
|
165
|
+
* focus to the element.
|
|
166
|
+
*
|
|
167
|
+
* @param {Number, String} goToIndex
|
|
168
|
+
*/
|
|
169
|
+
setFocusToItem(goToIndex) {
|
|
170
|
+
this.tabIndex = 0;
|
|
171
|
+
this.selected = false;
|
|
172
|
+
|
|
173
|
+
// set all selected to false
|
|
174
|
+
this.items.forEach((item) => item.unselect());
|
|
175
|
+
|
|
176
|
+
// focus item
|
|
177
|
+
this.items[goToIndex].focus();
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
leaveMenu() {
|
|
181
|
+
if (this.componentTrigger) {
|
|
182
|
+
this.componentTrigger.cancel();
|
|
183
|
+
this.componentTrigger.focus();
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
onClick() {
|
|
188
|
+
if (this.disabled) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.value !== undefined
|
|
193
|
+
? this.apiInjected().emit(this.value)
|
|
194
|
+
: this.$emit('click');
|
|
195
|
+
|
|
196
|
+
this.$nextTick(() => this.leaveMenu());
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
onKeyEsc() {
|
|
200
|
+
this.leaveMenu();
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
onMousemove() {
|
|
204
|
+
if (this.selected) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
this.items.forEach((item) => item.unselect());
|
|
209
|
+
|
|
210
|
+
this.select();
|
|
211
|
+
this.componentContent.setMousemove();
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
onMouseleave() {
|
|
215
|
+
this.unselect();
|
|
216
|
+
this.componentContent.unsetMousemove();
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { computePosition, flip, shift, offset, size } from '@floating-ui/dom';
|
|
2
|
+
|
|
3
|
+
export const floatingUiMixin = {
|
|
4
|
+
props: {
|
|
5
|
+
placement: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: 'bottom-start',
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
component: null,
|
|
14
|
+
componentTrigger: null,
|
|
15
|
+
componentContent: null,
|
|
16
|
+
active: false,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
watch: {
|
|
21
|
+
active(newVal) {
|
|
22
|
+
if (newVal) this.$nextTick(() => this.positionContentToTrigger());
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
mounted() {
|
|
27
|
+
this.component = {
|
|
28
|
+
setActive: this.setActive,
|
|
29
|
+
clearActive: this.clearActive,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
methods: {
|
|
34
|
+
setActive() {
|
|
35
|
+
this.active = true;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
clearActive() {
|
|
39
|
+
this.active = null;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
positionContentToTrigger() {
|
|
43
|
+
const trigger = document.getElementById(this.componentTrigger.id);
|
|
44
|
+
const content = document.getElementById(this.componentContent.id);
|
|
45
|
+
|
|
46
|
+
computePosition(trigger, content, {
|
|
47
|
+
placement: this.placement,
|
|
48
|
+
middleware: [
|
|
49
|
+
offset(6),
|
|
50
|
+
flip(),
|
|
51
|
+
shift({ padding: 5 }),
|
|
52
|
+
size({
|
|
53
|
+
apply({ rects }) {
|
|
54
|
+
// the min width to floating uis should be 200
|
|
55
|
+
// since less than that can look not as nice
|
|
56
|
+
const minWidthLimit = 200;
|
|
57
|
+
const width = rects.reference.width;
|
|
58
|
+
const minWidth = width < minWidthLimit ? minWidthLimit : width;
|
|
59
|
+
|
|
60
|
+
Object.assign(content.style, {
|
|
61
|
+
minWidth: `${minWidth}px`,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
}).then(({ x, y }) => {
|
|
67
|
+
Object.assign(content.style, {
|
|
68
|
+
left: `${x}px`,
|
|
69
|
+
top: `${y}px`,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { formControlMixin, formControlStyleMixin } from '../mixins/form-control';
|
|
2
|
+
|
|
3
|
+
export const formControlIconMixin = {
|
|
4
|
+
inheritAttrs: false,
|
|
5
|
+
|
|
6
|
+
mixins: [formControlMixin, formControlStyleMixin],
|
|
7
|
+
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'input',
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
computed: {
|
|
15
|
+
isLeft() {
|
|
16
|
+
return this.iconPlacement === 'left';
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
isRight() {
|
|
20
|
+
return this.iconPlacement === 'right';
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
classComputedWrapper() {
|
|
24
|
+
return [
|
|
25
|
+
this.headless ? 'form-control-wrapper' : 'relative',
|
|
26
|
+
// placement styles
|
|
27
|
+
this.headless
|
|
28
|
+
? `form-control-icon--${this.placement}`
|
|
29
|
+
: this.isLeft
|
|
30
|
+
? '[&_input]:pl-9'
|
|
31
|
+
: this.isRight
|
|
32
|
+
? '[&_input]:pr-9'
|
|
33
|
+
: null,
|
|
34
|
+
];
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
classComputedWrapperIcon() {
|
|
38
|
+
return [
|
|
39
|
+
this.headless
|
|
40
|
+
? 'form-control-wrapper__icon'
|
|
41
|
+
: `absolute top-0 bottom-0 flex w-9 justify-center items-center text-gray-400`,
|
|
42
|
+
// placement styles
|
|
43
|
+
this.headless
|
|
44
|
+
? null
|
|
45
|
+
: this.isLeft
|
|
46
|
+
? 'left-0'
|
|
47
|
+
: this.isRight
|
|
48
|
+
? 'right-0'
|
|
49
|
+
: null,
|
|
50
|
+
];
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const formControlMixin = {
|
|
2
|
+
props: {
|
|
3
|
+
disabled: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
default: false,
|
|
6
|
+
},
|
|
7
|
+
headless: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: [String, Number, Object, Array],
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
variant: {
|
|
16
|
+
type: [String, Object, Function],
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
computed: {
|
|
22
|
+
attrsComputed() {
|
|
23
|
+
// `Object.assign` merges objects together to form a new object
|
|
24
|
+
return Object.assign(
|
|
25
|
+
{},
|
|
26
|
+
// We add all the listeners from the parent
|
|
27
|
+
this.$attrs,
|
|
28
|
+
// Then we can add custom listeners or override the
|
|
29
|
+
// behavior of some listeners.
|
|
30
|
+
{
|
|
31
|
+
// This ensures that the component works with v-model
|
|
32
|
+
onInput: (event) => {
|
|
33
|
+
// if (this.lazy) return;
|
|
34
|
+
this.$emit('update:modelValue', event.target.value);
|
|
35
|
+
},
|
|
36
|
+
onBlur: (event) => {
|
|
37
|
+
this.$emit('blur', event);
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
isError() {
|
|
46
|
+
return this.variant === 'error';
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const formControlStyleMixin = {
|
|
52
|
+
computed: {
|
|
53
|
+
classComputed() {
|
|
54
|
+
return [
|
|
55
|
+
this.headless
|
|
56
|
+
? `${this.name}`
|
|
57
|
+
: 'leading-0 flex outline-none w-full max-w-full appearance-none items-center justify-between rounded border border-solid px-3 py-2 font-inherit text-base text-inherit file:hidden focus:border-secondary-200 appearance-none',
|
|
58
|
+
// variant styles
|
|
59
|
+
this.headless
|
|
60
|
+
? `${this.name}--${this.variant}`
|
|
61
|
+
: this.isError
|
|
62
|
+
? 'border-error-300'
|
|
63
|
+
: 'border-gray-300',
|
|
64
|
+
// height styles
|
|
65
|
+
this.headless
|
|
66
|
+
? null
|
|
67
|
+
: this.name === 'textarea'
|
|
68
|
+
? 'min-h-10' // limit it because input type number height can be different from other input types
|
|
69
|
+
: 'h-12 md:h-10',
|
|
70
|
+
];
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritree/ui",
|
|
3
|
-
"version": "0.19.2-
|
|
3
|
+
"version": "0.19.2-20",
|
|
4
4
|
"description": "veritree ui library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
14
|
+
"@floating-ui/dom": "^1.0.4",
|
|
15
|
+
"@veritree/icons": "^0.45.1"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@nuxt/kit": "^3.0.0
|
|
18
|
+
"@nuxt/kit": "^3.0.0",
|
|
19
|
+
"prettier": "^2.7.1",
|
|
20
|
+
"prettier-plugin-tailwindcss": "^0.1.13",
|
|
21
|
+
"tailwindcss": "^3.2.4"
|
|
18
22
|
}
|
|
19
23
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
:class="[
|
|
4
|
+
// default styles
|
|
5
|
+
headless
|
|
6
|
+
? 'avatar'
|
|
7
|
+
: 'flex items-center justify-center overflow-hidden rounded-full bg-white border border-solid',
|
|
8
|
+
// variant styles
|
|
9
|
+
headless ? `avatar--${variant}` : null,
|
|
10
|
+
// sizes styles
|
|
11
|
+
headless
|
|
12
|
+
? `avatar--${size}`
|
|
13
|
+
: isSmall
|
|
14
|
+
? 'h-8 w-8'
|
|
15
|
+
: isLarge
|
|
16
|
+
? 'h-10 w-10'
|
|
17
|
+
: null,
|
|
18
|
+
]"
|
|
12
19
|
>
|
|
13
20
|
<slot></slot>
|
|
14
21
|
</div>
|
|
@@ -18,32 +25,28 @@
|
|
|
18
25
|
export default {
|
|
19
26
|
name: 'VTAvatar',
|
|
20
27
|
|
|
21
|
-
provide() {
|
|
22
|
-
return {
|
|
23
|
-
api: () => {
|
|
24
|
-
const { dark: isDark, headless: isHeadless, light: isLight } = this;
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
isDark,
|
|
28
|
-
isHeadless,
|
|
29
|
-
isLight,
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
|
|
35
28
|
props: {
|
|
36
29
|
headless: {
|
|
37
30
|
type: Boolean,
|
|
38
31
|
default: false,
|
|
39
32
|
},
|
|
40
|
-
|
|
41
|
-
type:
|
|
42
|
-
default:
|
|
33
|
+
variant: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'primary',
|
|
43
36
|
},
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
default:
|
|
37
|
+
size: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: 'large',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
computed: {
|
|
44
|
+
isLarge() {
|
|
45
|
+
return this.size === 'large';
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
isSmall() {
|
|
49
|
+
return this.size === 'small';
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
52
|
};
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
headless
|
|
17
17
|
? `button--${variant}`
|
|
18
18
|
: isPrimary
|
|
19
|
-
? '
|
|
19
|
+
? 'bg-secondary-400 hover:bg-secondary-500 active:bg-secondary-600 border-transparent text-white disabled:bg-gray-200 disabled:text-gray-400'
|
|
20
20
|
: isSecondary
|
|
21
21
|
? 'border-gray-400 bg-white text-gray-700 hover:bg-gray-100 active:bg-gray-200 disabled:border-gray-300 disabled:text-gray-400'
|
|
22
22
|
: isTertiary
|
|
23
|
-
? '
|
|
23
|
+
? 'text-secondary-400 hover:text-secondary-500 active:text-secondary-500 border-transparent disabled:text-gray-400'
|
|
24
24
|
: isIcon
|
|
25
25
|
? 'text-primary-100 focus-within:bg-gray-200 hover:bg-gray-200 active:bg-gray-300'
|
|
26
26
|
: null,
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
: isLarge
|
|
31
31
|
? isIcon
|
|
32
32
|
? 'h-8 w-8'
|
|
33
|
-
: 'h-10'
|
|
33
|
+
: 'h-12 sm:h-10'
|
|
34
34
|
: isSmall
|
|
35
35
|
? isIcon
|
|
36
36
|
? 'h-6 w-6 p-1'
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
<VTSpinner v-if="busy" class="absolute inset-0 m-auto" />
|
|
42
42
|
<span
|
|
43
43
|
:class="[
|
|
44
|
-
headless ? null : 'inline-flex items-center gap-2 self-center
|
|
44
|
+
headless ? null : 'mx-auto inline-flex items-center gap-2 self-center',
|
|
45
45
|
headless && busy ? 'button--busy' : busy ? 'invisible' : null,
|
|
46
46
|
]"
|
|
47
47
|
>
|
|
@@ -115,7 +115,11 @@ export default {
|
|
|
115
115
|
},
|
|
116
116
|
|
|
117
117
|
tag() {
|
|
118
|
-
return this.$attrs.href
|
|
118
|
+
return this.$attrs.href
|
|
119
|
+
? 'a'
|
|
120
|
+
: this.to
|
|
121
|
+
? resolveComponent('NuxtLink')
|
|
122
|
+
: 'button';
|
|
119
123
|
},
|
|
120
124
|
|
|
121
125
|
type() {
|