@bobbykim/manguito-theme 0.18.0 → 0.20.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/LICENSE.md +1 -1
- package/README.md +12 -12
- package/dist/core.cjs +2 -0
- package/dist/core.d.ts +790 -0
- package/dist/core.js +2175 -0
- package/dist/mcl-theme.cjs +1 -0
- package/dist/mcl-theme.d.ts +12 -0
- package/dist/mcl-theme.js +608 -0
- package/package.json +28 -7
- package/CHANGELOG.md +0 -150
- package/index.d.ts +0 -14
- package/index.js +0 -19
- package/index.ts +0 -31
- package/lib/alert/Alert.vue +0 -92
- package/lib/alert/Alert.vue.d.ts +0 -65
- package/lib/collapse/Collapse.vue +0 -118
- package/lib/collapse/Collapse.vue.d.ts +0 -55
- package/lib/composables/index.d.ts +0 -1
- package/lib/composables/index.js +0 -1
- package/lib/composables/index.ts +0 -1
- package/lib/composables/observeVisible.d.ts +0 -6
- package/lib/composables/observeVisible.js +0 -24
- package/lib/composables/observeVisible.ts +0 -30
- package/lib/directives/index.d.ts +0 -6
- package/lib/directives/index.js +0 -186
- package/lib/directives/index.ts +0 -211
- package/lib/directives/index.types.d.ts +0 -14
- package/lib/directives/index.types.js +0 -1
- package/lib/directives/index.types.ts +0 -15
- package/lib/dropdown/DropdownContainer.vue +0 -50
- package/lib/dropdown/DropdownContainer.vue.d.ts +0 -19
- package/lib/dropdown/DropdownContent.vue +0 -69
- package/lib/dropdown/DropdownContent.vue.d.ts +0 -42
- package/lib/dropdown/index.types.d.ts +0 -4
- package/lib/dropdown/index.types.js +0 -1
- package/lib/dropdown/index.types.ts +0 -4
- package/lib/header/HeaderHorizontal.vue +0 -158
- package/lib/header/HeaderHorizontal.vue.d.ts +0 -84
- package/lib/header/HeaderVertical.vue +0 -116
- package/lib/header/HeaderVertical.vue.d.ts +0 -70
- package/lib/header/NavDrawer.vue +0 -121
- package/lib/header/NavDrawer.vue.d.ts +0 -43
- package/lib/header/index.types.d.ts +0 -1
- package/lib/header/index.types.js +0 -1
- package/lib/header/index.types.ts +0 -1
- package/lib/modal/Modal.vue +0 -213
- package/lib/modal/Modal.vue.d.ts +0 -108
- package/lib/sidebar/Sidebar.vue +0 -242
- package/lib/sidebar/Sidebar.vue.d.ts +0 -113
- package/lib/theme/generateClass.d.ts +0 -2
- package/lib/theme/generateClass.js +0 -18
- package/lib/theme/generateClass.ts +0 -25
- package/lib/theme/index.d.ts +0 -95
- package/lib/theme/index.js +0 -642
- package/lib/theme/index.ts +0 -676
- package/lib/theme/theme.d.ts +0 -89
- package/lib/theme/theme.js +0 -851
- package/lib/theme/theme.ts +0 -893
- package/lib/theme/theme.types.d.ts +0 -21
- package/lib/theme/theme.types.js +0 -1
- package/lib/theme/theme.types.ts +0 -68
- package/lib/tooltip/index.d.ts +0 -62
- package/lib/tooltip/index.js +0 -71
- package/lib/tooltip/index.ts +0 -76
- package/themeVariables.cjs +0 -607
- package/tsconfig.json +0 -5
- package/tsconfig.ts.json +0 -9
- package/tsconfig.vue.json +0 -9
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useMutationObserver } from '@vueuse/core'
|
|
2
|
-
import type { Ref } from 'vue'
|
|
3
|
-
|
|
4
|
-
export const observeVisibleAttr = (el: Ref, fn: (...args: any[]) => void) => {
|
|
5
|
-
return useMutationObserver(
|
|
6
|
-
el,
|
|
7
|
-
(mutations) => {
|
|
8
|
-
let changed: boolean = false
|
|
9
|
-
for (let i = 0; i < mutations.length && !changed; i++) {
|
|
10
|
-
const mutation = mutations[i]
|
|
11
|
-
const mutationType = mutation.type
|
|
12
|
-
const mutationAttr = mutation.attributeName
|
|
13
|
-
const mutationTarget = mutation.target
|
|
14
|
-
if (mutationType === 'attributes') {
|
|
15
|
-
changed = true
|
|
16
|
-
} else if (mutationAttr === 'visible') {
|
|
17
|
-
changed = true
|
|
18
|
-
}
|
|
19
|
-
if (changed) {
|
|
20
|
-
const visibleAttr =
|
|
21
|
-
(mutationTarget as HTMLElement).getAttribute('visible') === 'true'
|
|
22
|
-
? true
|
|
23
|
-
: false
|
|
24
|
-
fn(visibleAttr)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{ attributes: true }
|
|
29
|
-
)
|
|
30
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Directive } from 'vue';
|
|
2
|
-
import type { TooltipElementType, TooltipValueType } from './index.types.js';
|
|
3
|
-
export declare const vClickOutside: Directive;
|
|
4
|
-
export declare const vToggle: Directive;
|
|
5
|
-
export declare const vCollapse: Directive;
|
|
6
|
-
export declare const vTooltip: Directive<TooltipElementType, TooltipValueType>;
|
package/lib/directives/index.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { render, createVNode } from 'vue';
|
|
2
|
-
import tooltip from '../tooltip/index.js';
|
|
3
|
-
export const vClickOutside = {
|
|
4
|
-
mounted(el, binding) {
|
|
5
|
-
el.__ClickOutsideHandler = (event) => {
|
|
6
|
-
if (!(el === event.target || el.contains(event.target))) {
|
|
7
|
-
binding.value(event);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
document.body.addEventListener('click', el.__ClickOutsideHandler);
|
|
11
|
-
},
|
|
12
|
-
unmounted(el) {
|
|
13
|
-
document.body.removeEventListener('click', el.__ClickOutsideHandler);
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
export const vToggle = {
|
|
17
|
-
mounted(el, binding) {
|
|
18
|
-
el.__ClickToggleHandler = (e) => {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
const eTarget = e.target;
|
|
21
|
-
let target;
|
|
22
|
-
if (eTarget.tagName === 'A') {
|
|
23
|
-
const targetId = eTarget.getAttribute('href');
|
|
24
|
-
const formattedTargetId = targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId;
|
|
25
|
-
target = document.getElementById(formattedTargetId);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
target = document.getElementById(binding.arg);
|
|
29
|
-
}
|
|
30
|
-
if (!target) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (target.hasAttribute('visible') === false) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const targetAttr = target.getAttribute('visible');
|
|
37
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
38
|
-
target.setAttribute('visible', attrAfterToggle);
|
|
39
|
-
return;
|
|
40
|
-
};
|
|
41
|
-
el.addEventListener('click', el.__ClickToggleHandler);
|
|
42
|
-
},
|
|
43
|
-
unmounted(el) {
|
|
44
|
-
el.removeEventListener('click', el.__ClickToggleHandler);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
export const vCollapse = {
|
|
48
|
-
mounted(el, binding) {
|
|
49
|
-
el.__HandleToggler = (event) => {
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
const eTarget = event.target;
|
|
52
|
-
let target;
|
|
53
|
-
if (eTarget.tagName === 'A') {
|
|
54
|
-
const targetId = eTarget.getAttribute('href');
|
|
55
|
-
const formattedTargetId = targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId;
|
|
56
|
-
target = document.getElementById(formattedTargetId);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
target = document.getElementById(binding.arg);
|
|
60
|
-
}
|
|
61
|
-
if (!target) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (target.hasAttribute('visible') === false) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (!target.hasAttribute('accordion')) {
|
|
68
|
-
// run when it is not accordion component case
|
|
69
|
-
const targetAttr = target.getAttribute('visible');
|
|
70
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
71
|
-
target.setAttribute('visible', attrAfterToggle);
|
|
72
|
-
// target.click()
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const accordionName = target.getAttribute('accordion');
|
|
76
|
-
const accordionList = document.querySelectorAll(`div[accordion="${accordionName}"]`);
|
|
77
|
-
// loop through each accordion items and handle reaction for each case
|
|
78
|
-
for (let i = 0; i < accordionList.length; i++) {
|
|
79
|
-
const isVisible = accordionList[i].getAttribute('visible');
|
|
80
|
-
if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
81
|
-
accordionList[i].setAttribute('visible', 'false');
|
|
82
|
-
// accordionList[i].click()
|
|
83
|
-
}
|
|
84
|
-
if (accordionList[i].id === target.id) {
|
|
85
|
-
const targetAttr = target.getAttribute('visible');
|
|
86
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
87
|
-
target.setAttribute('visible', attrAfterToggle);
|
|
88
|
-
// accordionList[i].click()
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
el.addEventListener('click', el.__HandleToggler);
|
|
93
|
-
},
|
|
94
|
-
unmounted(el) {
|
|
95
|
-
el.removeEventListener('click', el.__HandleToggler);
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
export const vTooltip = {
|
|
99
|
-
mounted(el, binding) {
|
|
100
|
-
el.__HandleTooltip = (el, binding) => {
|
|
101
|
-
// parent element class
|
|
102
|
-
el.classList.add('relative', 'group', 'overflow-visible');
|
|
103
|
-
// handle tooltip text
|
|
104
|
-
let tooltipText;
|
|
105
|
-
if (el.hasAttribute('title')) {
|
|
106
|
-
tooltipText = el.getAttribute('title');
|
|
107
|
-
}
|
|
108
|
-
if (!el.hasAttribute('title') &&
|
|
109
|
-
typeof binding.value !== 'undefined' &&
|
|
110
|
-
typeof binding.value === 'string') {
|
|
111
|
-
tooltipText = binding.value;
|
|
112
|
-
}
|
|
113
|
-
if (!el.hasAttribute('title') &&
|
|
114
|
-
typeof binding.value !== 'undefined' &&
|
|
115
|
-
typeof binding.value !== 'string' &&
|
|
116
|
-
typeof binding.value.title === 'string') {
|
|
117
|
-
tooltipText = binding.value.title;
|
|
118
|
-
}
|
|
119
|
-
// handle tooltip color
|
|
120
|
-
let tooltipColor;
|
|
121
|
-
if (el.hasAttribute('color')) {
|
|
122
|
-
tooltipColor = el.getAttribute('color');
|
|
123
|
-
}
|
|
124
|
-
if (!el.hasAttribute('color') &&
|
|
125
|
-
typeof binding.value !== 'undefined' &&
|
|
126
|
-
typeof binding.value !== 'string' &&
|
|
127
|
-
typeof binding.value.color === 'string') {
|
|
128
|
-
tooltipColor = binding.value.color;
|
|
129
|
-
}
|
|
130
|
-
// handle tooltip text color
|
|
131
|
-
let tooltipTextColor;
|
|
132
|
-
if (el.hasAttribute('text-color')) {
|
|
133
|
-
tooltipTextColor = el.getAttribute('text-color');
|
|
134
|
-
}
|
|
135
|
-
if (!el.hasAttribute('text-color') &&
|
|
136
|
-
typeof binding.value !== 'undefined' &&
|
|
137
|
-
typeof binding.value !== 'string' &&
|
|
138
|
-
typeof binding.value.textColor === 'string') {
|
|
139
|
-
tooltipTextColor = binding.value.textColor;
|
|
140
|
-
}
|
|
141
|
-
// handle tooltip width
|
|
142
|
-
let tooltipWidth;
|
|
143
|
-
if (el.hasAttribute('tooltip-width')) {
|
|
144
|
-
tooltipWidth = el.getAttribute('tooltip-width');
|
|
145
|
-
}
|
|
146
|
-
if (!el.hasAttribute('tooltip-width') &&
|
|
147
|
-
typeof binding.value !== 'undefined' &&
|
|
148
|
-
typeof binding.value !== 'string' &&
|
|
149
|
-
typeof binding.value.width === ('number' || 'string')) {
|
|
150
|
-
tooltipWidth = binding.value.width;
|
|
151
|
-
}
|
|
152
|
-
// handle custom class names
|
|
153
|
-
let tooltipClassName;
|
|
154
|
-
if (typeof binding.value !== 'undefined' &&
|
|
155
|
-
typeof binding.value !== 'string' &&
|
|
156
|
-
typeof binding.value.className === 'string') {
|
|
157
|
-
tooltipClassName = binding.value.className;
|
|
158
|
-
}
|
|
159
|
-
let tooltipDirection;
|
|
160
|
-
const modifierArray = Object.keys(binding.modifiers);
|
|
161
|
-
// handle direction
|
|
162
|
-
if (modifierArray.length > 0) {
|
|
163
|
-
tooltipDirection = modifierArray[0];
|
|
164
|
-
}
|
|
165
|
-
const vnode = createVNode(tooltip, {
|
|
166
|
-
direction: tooltipDirection,
|
|
167
|
-
title: tooltipText,
|
|
168
|
-
color: tooltipColor,
|
|
169
|
-
textColor: tooltipTextColor,
|
|
170
|
-
width: tooltipWidth,
|
|
171
|
-
customClass: tooltipClassName,
|
|
172
|
-
});
|
|
173
|
-
render(vnode, el);
|
|
174
|
-
};
|
|
175
|
-
el.__UnmountTooltip = (el) => {
|
|
176
|
-
render(null, el);
|
|
177
|
-
};
|
|
178
|
-
el.__HandleTooltip(el, binding);
|
|
179
|
-
},
|
|
180
|
-
updated(el, binding) {
|
|
181
|
-
el.__HandleTooltip(el, binding);
|
|
182
|
-
},
|
|
183
|
-
unmounted(el) {
|
|
184
|
-
el.__UnmountTooltip(el);
|
|
185
|
-
},
|
|
186
|
-
};
|
package/lib/directives/index.ts
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { render, createVNode } from 'vue'
|
|
2
|
-
import type { Directive, DirectiveBinding } from 'vue'
|
|
3
|
-
import type { Direction } from '../../index.js'
|
|
4
|
-
import tooltip from '../tooltip/index.js'
|
|
5
|
-
import type { TooltipElementType, TooltipValueType } from './index.types.js'
|
|
6
|
-
|
|
7
|
-
export const vClickOutside: Directive = {
|
|
8
|
-
mounted(el, binding) {
|
|
9
|
-
el.__ClickOutsideHandler = (event: Event) => {
|
|
10
|
-
if (!(el === event.target || el.contains(event.target))) {
|
|
11
|
-
binding.value(event)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
document.body.addEventListener('click', el.__ClickOutsideHandler)
|
|
15
|
-
},
|
|
16
|
-
unmounted(el) {
|
|
17
|
-
document.body.removeEventListener('click', el.__ClickOutsideHandler)
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const vToggle: Directive = {
|
|
22
|
-
mounted(el, binding) {
|
|
23
|
-
el.__ClickToggleHandler = (e: Event): void => {
|
|
24
|
-
e.preventDefault()
|
|
25
|
-
const eTarget = e.target as HTMLElement
|
|
26
|
-
let target: HTMLElement
|
|
27
|
-
if (eTarget.tagName === 'A') {
|
|
28
|
-
const targetId = eTarget.getAttribute('href')
|
|
29
|
-
const formattedTargetId =
|
|
30
|
-
targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId
|
|
31
|
-
target = document.getElementById(formattedTargetId as string)!
|
|
32
|
-
} else {
|
|
33
|
-
target = document.getElementById(binding.arg as string)!
|
|
34
|
-
}
|
|
35
|
-
if (!target) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
if (target.hasAttribute('visible') === false) {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
const targetAttr = target.getAttribute('visible')
|
|
42
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
43
|
-
target.setAttribute('visible', attrAfterToggle)
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
el.addEventListener('click', el.__ClickToggleHandler)
|
|
47
|
-
},
|
|
48
|
-
unmounted(el) {
|
|
49
|
-
el.removeEventListener('click', el.__ClickToggleHandler)
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const vCollapse: Directive = {
|
|
54
|
-
mounted(el, binding) {
|
|
55
|
-
el.__HandleToggler = (event: Event): void => {
|
|
56
|
-
event.preventDefault()
|
|
57
|
-
const eTarget = event.target as HTMLElement
|
|
58
|
-
let target: HTMLElement
|
|
59
|
-
if (eTarget.tagName === 'A') {
|
|
60
|
-
const targetId = eTarget.getAttribute('href')
|
|
61
|
-
const formattedTargetId =
|
|
62
|
-
targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId
|
|
63
|
-
target = document.getElementById(formattedTargetId as string)!
|
|
64
|
-
} else {
|
|
65
|
-
target = document.getElementById(binding.arg as string) as HTMLElement
|
|
66
|
-
}
|
|
67
|
-
if (!target) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
if (target.hasAttribute('visible') === false) {
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
if (!target.hasAttribute('accordion')) {
|
|
74
|
-
// run when it is not accordion component case
|
|
75
|
-
const targetAttr = target.getAttribute('visible')
|
|
76
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
77
|
-
target.setAttribute('visible', attrAfterToggle)
|
|
78
|
-
// target.click()
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
const accordionName = target.getAttribute('accordion')
|
|
82
|
-
const accordionList: NodeListOf<HTMLElement> = document.querySelectorAll(
|
|
83
|
-
`div[accordion="${accordionName}"]`
|
|
84
|
-
)
|
|
85
|
-
// loop through each accordion items and handle reaction for each case
|
|
86
|
-
for (let i = 0; i < accordionList.length; i++) {
|
|
87
|
-
const isVisible = accordionList[i].getAttribute('visible')
|
|
88
|
-
if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
89
|
-
accordionList[i].setAttribute('visible', 'false')
|
|
90
|
-
// accordionList[i].click()
|
|
91
|
-
}
|
|
92
|
-
if (accordionList[i].id === target.id) {
|
|
93
|
-
const targetAttr = target.getAttribute('visible')
|
|
94
|
-
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
95
|
-
target.setAttribute('visible', attrAfterToggle)
|
|
96
|
-
// accordionList[i].click()
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
el.addEventListener('click', el.__HandleToggler)
|
|
101
|
-
},
|
|
102
|
-
unmounted(el) {
|
|
103
|
-
el.removeEventListener('click', el.__HandleToggler)
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export const vTooltip: Directive<TooltipElementType, TooltipValueType> = {
|
|
108
|
-
mounted(el, binding) {
|
|
109
|
-
el.__HandleTooltip = (
|
|
110
|
-
el: HTMLElement,
|
|
111
|
-
binding: DirectiveBinding<TooltipValueType>
|
|
112
|
-
) => {
|
|
113
|
-
// parent element class
|
|
114
|
-
el.classList.add('relative', 'group', 'overflow-visible')
|
|
115
|
-
|
|
116
|
-
// handle tooltip text
|
|
117
|
-
let tooltipText: string | null | undefined
|
|
118
|
-
if (el.hasAttribute('title')) {
|
|
119
|
-
tooltipText = el.getAttribute('title')
|
|
120
|
-
}
|
|
121
|
-
if (
|
|
122
|
-
!el.hasAttribute('title') &&
|
|
123
|
-
typeof binding.value !== 'undefined' &&
|
|
124
|
-
typeof binding.value === 'string'
|
|
125
|
-
) {
|
|
126
|
-
tooltipText = binding.value
|
|
127
|
-
}
|
|
128
|
-
if (
|
|
129
|
-
!el.hasAttribute('title') &&
|
|
130
|
-
typeof binding.value !== 'undefined' &&
|
|
131
|
-
typeof binding.value !== 'string' &&
|
|
132
|
-
typeof binding.value.title === 'string'
|
|
133
|
-
) {
|
|
134
|
-
tooltipText = binding.value.title
|
|
135
|
-
}
|
|
136
|
-
// handle tooltip color
|
|
137
|
-
let tooltipColor: string | null | undefined
|
|
138
|
-
if (el.hasAttribute('color')) {
|
|
139
|
-
tooltipColor = el.getAttribute('color')
|
|
140
|
-
}
|
|
141
|
-
if (
|
|
142
|
-
!el.hasAttribute('color') &&
|
|
143
|
-
typeof binding.value !== 'undefined' &&
|
|
144
|
-
typeof binding.value !== 'string' &&
|
|
145
|
-
typeof binding.value.color === 'string'
|
|
146
|
-
) {
|
|
147
|
-
tooltipColor = binding.value.color
|
|
148
|
-
}
|
|
149
|
-
// handle tooltip text color
|
|
150
|
-
let tooltipTextColor: string | null | undefined
|
|
151
|
-
if (el.hasAttribute('text-color')) {
|
|
152
|
-
tooltipTextColor = el.getAttribute('text-color')
|
|
153
|
-
}
|
|
154
|
-
if (
|
|
155
|
-
!el.hasAttribute('text-color') &&
|
|
156
|
-
typeof binding.value !== 'undefined' &&
|
|
157
|
-
typeof binding.value !== 'string' &&
|
|
158
|
-
typeof binding.value.textColor === 'string'
|
|
159
|
-
) {
|
|
160
|
-
tooltipTextColor = binding.value.textColor
|
|
161
|
-
}
|
|
162
|
-
// handle tooltip width
|
|
163
|
-
let tooltipWidth: string | number | null | undefined
|
|
164
|
-
if (el.hasAttribute('tooltip-width')) {
|
|
165
|
-
tooltipWidth = el.getAttribute('tooltip-width')
|
|
166
|
-
}
|
|
167
|
-
if (
|
|
168
|
-
!el.hasAttribute('tooltip-width') &&
|
|
169
|
-
typeof binding.value !== 'undefined' &&
|
|
170
|
-
typeof binding.value !== 'string' &&
|
|
171
|
-
typeof binding.value.width === ('number' || 'string')
|
|
172
|
-
) {
|
|
173
|
-
tooltipWidth = binding.value.width
|
|
174
|
-
}
|
|
175
|
-
// handle custom class names
|
|
176
|
-
let tooltipClassName: string | undefined
|
|
177
|
-
if (
|
|
178
|
-
typeof binding.value !== 'undefined' &&
|
|
179
|
-
typeof binding.value !== 'string' &&
|
|
180
|
-
typeof binding.value.className === 'string'
|
|
181
|
-
) {
|
|
182
|
-
tooltipClassName = binding.value.className
|
|
183
|
-
}
|
|
184
|
-
let tooltipDirection: Direction | undefined
|
|
185
|
-
const modifierArray: string[] = Object.keys(binding.modifiers)
|
|
186
|
-
// handle direction
|
|
187
|
-
if (modifierArray.length > 0) {
|
|
188
|
-
tooltipDirection = modifierArray[0] as Direction
|
|
189
|
-
}
|
|
190
|
-
const vnode = createVNode(tooltip, {
|
|
191
|
-
direction: tooltipDirection,
|
|
192
|
-
title: tooltipText,
|
|
193
|
-
color: tooltipColor,
|
|
194
|
-
textColor: tooltipTextColor,
|
|
195
|
-
width: tooltipWidth,
|
|
196
|
-
customClass: tooltipClassName,
|
|
197
|
-
})
|
|
198
|
-
render(vnode, el)
|
|
199
|
-
}
|
|
200
|
-
el.__UnmountTooltip = (el: Element) => {
|
|
201
|
-
render(null, el)
|
|
202
|
-
}
|
|
203
|
-
el.__HandleTooltip(el, binding)
|
|
204
|
-
},
|
|
205
|
-
updated(el, binding) {
|
|
206
|
-
el.__HandleTooltip(el, binding)
|
|
207
|
-
},
|
|
208
|
-
unmounted(el) {
|
|
209
|
-
el.__UnmountTooltip(el)
|
|
210
|
-
},
|
|
211
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ColorPalette } from '../../index.js';
|
|
2
|
-
export interface TooltipElementType extends HTMLElement {
|
|
3
|
-
__HandleTooltip: Function;
|
|
4
|
-
__UnmountTooltip: Function;
|
|
5
|
-
}
|
|
6
|
-
interface TooltipValueObjectType {
|
|
7
|
-
title?: string;
|
|
8
|
-
color?: ColorPalette;
|
|
9
|
-
textColor?: ColorPalette;
|
|
10
|
-
width?: number | string;
|
|
11
|
-
className?: string;
|
|
12
|
-
}
|
|
13
|
-
export type TooltipValueType = TooltipValueObjectType | string;
|
|
14
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ColorPalette } from '../../index.js'
|
|
2
|
-
|
|
3
|
-
export interface TooltipElementType extends HTMLElement {
|
|
4
|
-
__HandleTooltip: Function
|
|
5
|
-
__UnmountTooltip: Function
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface TooltipValueObjectType {
|
|
9
|
-
title?: string
|
|
10
|
-
color?: ColorPalette
|
|
11
|
-
textColor?: ColorPalette
|
|
12
|
-
width?: number | string
|
|
13
|
-
className?: string
|
|
14
|
-
}
|
|
15
|
-
export type TooltipValueType = TooltipValueObjectType | string
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onMounted, provide, reactive, ref } from 'vue'
|
|
3
|
-
import { vClickOutside } from '../directives'
|
|
4
|
-
import type { InjectType } from './index.types'
|
|
5
|
-
|
|
6
|
-
const slots = defineSlots<{
|
|
7
|
-
default: any
|
|
8
|
-
toggler: any
|
|
9
|
-
}>()
|
|
10
|
-
const emit = defineEmits<{
|
|
11
|
-
(e: 'click-outside', event: Event): void
|
|
12
|
-
(e: 'toggle', event: Event): void
|
|
13
|
-
}>()
|
|
14
|
-
const dropdownTarget = ref()
|
|
15
|
-
const dropdownState = reactive<InjectType>({
|
|
16
|
-
active: false,
|
|
17
|
-
buttonHeight: 0,
|
|
18
|
-
})
|
|
19
|
-
provide('dropdownState', dropdownState)
|
|
20
|
-
const toggle = (e: Event): void => {
|
|
21
|
-
dropdownState.active = !dropdownState.active
|
|
22
|
-
emit('toggle', e)
|
|
23
|
-
}
|
|
24
|
-
const onClickOutside = (e: Event): void => {
|
|
25
|
-
dropdownState.active = false
|
|
26
|
-
emit('click-outside', e)
|
|
27
|
-
}
|
|
28
|
-
const onEscape = (): void => {
|
|
29
|
-
dropdownState.active = false
|
|
30
|
-
}
|
|
31
|
-
onMounted(() => {
|
|
32
|
-
dropdownState.buttonHeight = dropdownTarget.value.scrollHeight
|
|
33
|
-
})
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<template>
|
|
37
|
-
<div
|
|
38
|
-
class="relative"
|
|
39
|
-
ref="dropdownTarget"
|
|
40
|
-
v-click-outside="onClickOutside"
|
|
41
|
-
@keyup.esc="onEscape"
|
|
42
|
-
>
|
|
43
|
-
<slot
|
|
44
|
-
name="toggler"
|
|
45
|
-
:toggle="toggle"
|
|
46
|
-
:dropdown-state="dropdownState.active"
|
|
47
|
-
/>
|
|
48
|
-
<slot></slot>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
2
|
-
"click-outside": (event: Event) => void;
|
|
3
|
-
toggle: (event: Event) => void;
|
|
4
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
|
5
|
-
onToggle?: ((event: Event) => any) | undefined;
|
|
6
|
-
"onClick-outside"?: ((event: Event) => any) | undefined;
|
|
7
|
-
}, {}, {}>, Readonly<{
|
|
8
|
-
default: any;
|
|
9
|
-
toggler: any;
|
|
10
|
-
}> & {
|
|
11
|
-
default: any;
|
|
12
|
-
toggler: any;
|
|
13
|
-
}>;
|
|
14
|
-
export default _default;
|
|
15
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
16
|
-
new (): {
|
|
17
|
-
$slots: S;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useWindowSize } from '@vueuse/core'
|
|
3
|
-
import { Transition, computed, inject, ref } from 'vue'
|
|
4
|
-
import type { InjectType } from './index.types'
|
|
5
|
-
|
|
6
|
-
withDefaults(
|
|
7
|
-
defineProps<{
|
|
8
|
-
className?: string
|
|
9
|
-
}>(),
|
|
10
|
-
{
|
|
11
|
-
className: '',
|
|
12
|
-
}
|
|
13
|
-
)
|
|
14
|
-
const { height } = useWindowSize()
|
|
15
|
-
const slots = defineSlots<{
|
|
16
|
-
default(props: { itemClick: () => void }): any
|
|
17
|
-
}>()
|
|
18
|
-
const contentRef = ref<HTMLAreaElement>()
|
|
19
|
-
const dropdownState = inject<InjectType>('dropdownState', {
|
|
20
|
-
active: false,
|
|
21
|
-
buttonHeight: 0,
|
|
22
|
-
})
|
|
23
|
-
const active = computed<boolean>(() => {
|
|
24
|
-
return dropdownState.active
|
|
25
|
-
})
|
|
26
|
-
const handleItemClick = () => {
|
|
27
|
-
dropdownState.active = false
|
|
28
|
-
}
|
|
29
|
-
const buttonHeight = computed(() => {
|
|
30
|
-
return { '--button-height': `${dropdownState.buttonHeight}px` }
|
|
31
|
-
})
|
|
32
|
-
const dropdownDirection = computed<string | undefined>(() => {
|
|
33
|
-
if (!dropdownState.active || !contentRef.value) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
if (height.value - contentRef.value.getBoundingClientRect().bottom < 0) {
|
|
37
|
-
return 'dropup-bottom'
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<template>
|
|
43
|
-
<transition name="dropdown-content">
|
|
44
|
-
<div
|
|
45
|
-
v-if="active"
|
|
46
|
-
ref="contentRef"
|
|
47
|
-
class="absolute my-2xs max-w-[14rem] w-max overflow-hidden"
|
|
48
|
-
:class="[dropdownDirection, className]"
|
|
49
|
-
:style="buttonHeight"
|
|
50
|
-
>
|
|
51
|
-
<slot :item-click="handleItemClick" />
|
|
52
|
-
</div>
|
|
53
|
-
</transition>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<style scoped lang="scss">
|
|
57
|
-
.dropup-bottom {
|
|
58
|
-
bottom: var(--button-height);
|
|
59
|
-
}
|
|
60
|
-
.dropdown-content-enter-active,
|
|
61
|
-
.dropdown-content-leave-active {
|
|
62
|
-
transition: all 0.3s;
|
|
63
|
-
}
|
|
64
|
-
.dropdown-content-enter-from,
|
|
65
|
-
.dropdown-content-leave-to {
|
|
66
|
-
opacity: 0;
|
|
67
|
-
transform: translateY(-10px);
|
|
68
|
-
}
|
|
69
|
-
</style>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
className?: string | undefined;
|
|
3
|
-
}>, {
|
|
4
|
-
className: string;
|
|
5
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
-
className?: string | undefined;
|
|
7
|
-
}>, {
|
|
8
|
-
className: string;
|
|
9
|
-
}>>>, {
|
|
10
|
-
className: string;
|
|
11
|
-
}, {}>, Readonly<{
|
|
12
|
-
default(props: {
|
|
13
|
-
itemClick: () => void;
|
|
14
|
-
}): any;
|
|
15
|
-
}> & {
|
|
16
|
-
default(props: {
|
|
17
|
-
itemClick: () => void;
|
|
18
|
-
}): any;
|
|
19
|
-
}>;
|
|
20
|
-
export default _default;
|
|
21
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
22
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
23
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
24
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
25
|
-
} : {
|
|
26
|
-
type: import('vue').PropType<T[K]>;
|
|
27
|
-
required: true;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
type __VLS_WithDefaults<P, D> = {
|
|
31
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
32
|
-
default: D[K];
|
|
33
|
-
}> : P[K];
|
|
34
|
-
};
|
|
35
|
-
type __VLS_Prettify<T> = {
|
|
36
|
-
[K in keyof T]: T[K];
|
|
37
|
-
} & {};
|
|
38
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
39
|
-
new (): {
|
|
40
|
-
$slots: S;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|