@bobbykim/manguito-theme 0.6.0 → 0.8.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/CHANGELOG.md +12 -0
- package/index.d.ts +13 -0
- package/index.js +30 -0
- package/lib/collapse/Collapse.vue +46 -15
- package/lib/collapse/Collapse.vue.d.ts +46 -0
- package/lib/collapse/index.types.d.ts +3 -0
- package/lib/collapse/index.types.js +1 -0
- package/lib/collapse/index.types.ts +1 -1
- package/lib/composables/index.d.ts +1 -0
- package/lib/composables/index.js +1 -0
- package/lib/composables/index.ts +1 -0
- package/lib/composables/observeVisible.d.ts +1 -0
- package/lib/composables/observeVisible.js +24 -0
- package/lib/composables/observeVisible.ts +24 -0
- package/lib/directives/index.d.ts +6 -0
- package/lib/directives/index.js +215 -0
- package/lib/directives/index.ts +57 -5
- package/lib/directives/index.types.d.ts +14 -0
- package/lib/directives/index.types.js +1 -0
- package/lib/dropdown/DropdownContainer.vue.d.ts +19 -0
- package/lib/dropdown/DropdownContent.vue.d.ts +23 -0
- package/lib/dropdown/index.types.d.ts +4 -0
- package/lib/dropdown/index.types.js +1 -0
- package/lib/modal/Modal.vue +47 -10
- package/lib/modal/Modal.vue.d.ts +112 -0
- package/lib/nav/HamburgerMenu.vue +1 -1
- package/lib/nav/HamburgerMenu.vue.d.ts +44 -0
- package/lib/sidebar/Sidebar.vue +45 -8
- package/lib/sidebar/Sidebar.vue.d.ts +121 -0
- package/lib/tooltip/index.d.ts +62 -0
- package/lib/tooltip/index.js +71 -0
- package/package.json +5 -2
- package/theme/index.d.ts +94 -0
- package/theme/index.js +631 -0
- package/theme/theme.d.ts +88 -0
- package/theme/theme.js +831 -0
- package/theme/theme.types.d.ts +21 -0
- package/theme/theme.types.js +1 -0
- package/tsconfig.json +12 -0
- package/tsconfig.vue.json +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [0.8.0](https://github.com/bobbykim89/manguito-component-library/compare/@bobbykim/manguito-theme@0.7.0...@bobbykim/manguito-theme@0.8.0) (2023-12-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* prerelease run build ([f7a852c](https://github.com/bobbykim89/manguito-component-library/commit/f7a852c9bf12b77481bf5d2f1602e50367d834f8))
|
|
12
|
+
* **tsconfig.json,tsconfig.vue.json:** update tsconfig ([0f21861](https://github.com/bobbykim89/manguito-component-library/commit/0f2186167342314f5d218e789a68c03cf6faa8ff))
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClassType, InputType } from './theme/index.js';
|
|
2
|
+
import DropdownContainer from './lib/dropdown/DropdownContainer.vue';
|
|
3
|
+
import DropdownContent from './lib/dropdown/DropdownContent.vue';
|
|
4
|
+
import Collapse from './lib/collapse/Collapse.vue';
|
|
5
|
+
import Sidebar from './lib/sidebar/Sidebar.vue';
|
|
6
|
+
import Modal from './lib/modal/Modal.vue';
|
|
7
|
+
import HamburgerMenu from './lib/nav/HamburgerMenu.vue';
|
|
8
|
+
declare const generateClass: (type: ClassType, value: InputType) => string;
|
|
9
|
+
export default generateClass;
|
|
10
|
+
export { DropdownContainer, DropdownContent, Collapse, HamburgerMenu, Sidebar, Modal, };
|
|
11
|
+
export * from './lib/directives';
|
|
12
|
+
export * from './theme/theme.types';
|
|
13
|
+
export * from './lib/collapse/index.types';
|
package/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import GenerateMCLClass, { colorType, textType, borderWidthType, scaleType, } from './theme';
|
|
2
|
+
// base components
|
|
3
|
+
import DropdownContainer from './lib/dropdown/DropdownContainer.vue';
|
|
4
|
+
import DropdownContent from './lib/dropdown/DropdownContent.vue';
|
|
5
|
+
import Collapse from './lib/collapse/Collapse.vue';
|
|
6
|
+
import Sidebar from './lib/sidebar/Sidebar.vue';
|
|
7
|
+
import Modal from './lib/modal/Modal.vue';
|
|
8
|
+
import HamburgerMenu from './lib/nav/HamburgerMenu.vue';
|
|
9
|
+
const generateClass = (type, value) => {
|
|
10
|
+
const mclGenerate = new GenerateMCLClass(type, value);
|
|
11
|
+
if (colorType.includes(type)) {
|
|
12
|
+
return mclGenerate.generateColorClass();
|
|
13
|
+
}
|
|
14
|
+
if (textType.includes(type)) {
|
|
15
|
+
return mclGenerate.generateTextClass();
|
|
16
|
+
}
|
|
17
|
+
if (borderWidthType.includes(type)) {
|
|
18
|
+
return mclGenerate.generateBorderWidthClass();
|
|
19
|
+
}
|
|
20
|
+
if (scaleType.includes(type)) {
|
|
21
|
+
return mclGenerate.generateScaleClass();
|
|
22
|
+
}
|
|
23
|
+
// return spacing type if all of above is false
|
|
24
|
+
return mclGenerate.generateSpacingClass();
|
|
25
|
+
};
|
|
26
|
+
export default generateClass;
|
|
27
|
+
export { DropdownContainer, DropdownContent, Collapse, HamburgerMenu, Sidebar, Modal, };
|
|
28
|
+
export * from './lib/directives';
|
|
29
|
+
export * from './theme/theme.types';
|
|
30
|
+
export * from './lib/collapse/index.types';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { ref, watch, Transition } from 'vue'
|
|
3
|
-
import
|
|
2
|
+
import { ref, watch, Transition, onMounted, onBeforeUnmount } from 'vue'
|
|
3
|
+
import { observeVisibleAttr } from '../composables'
|
|
4
|
+
|
|
4
5
|
const props = withDefaults(
|
|
5
6
|
defineProps<{
|
|
6
|
-
collapseId: string
|
|
7
7
|
accordion?: string
|
|
8
8
|
className?: string
|
|
9
9
|
visible?: boolean
|
|
@@ -13,12 +13,24 @@ const props = withDefaults(
|
|
|
13
13
|
visible: false,
|
|
14
14
|
}
|
|
15
15
|
)
|
|
16
|
-
const emit = defineEmits(['
|
|
16
|
+
const emit = defineEmits(['open', 'close'])
|
|
17
|
+
const collapseRef = ref<HTMLElement | undefined>()
|
|
17
18
|
const toggle = ref<boolean>(props.visible)
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
+
const toggleCollapse = (): void => {
|
|
20
21
|
toggle.value = !toggle.value
|
|
21
|
-
|
|
22
|
+
}
|
|
23
|
+
const openCollapse = (): void => {
|
|
24
|
+
toggle.value = true
|
|
25
|
+
}
|
|
26
|
+
const closeCollapse = (): void => {
|
|
27
|
+
toggle.value = false
|
|
28
|
+
}
|
|
29
|
+
const emitOpenEvent = () => {
|
|
30
|
+
emit('open', { visible: true })
|
|
31
|
+
}
|
|
32
|
+
const emitCloseEvent = () => {
|
|
33
|
+
emit('close', { visible: false })
|
|
22
34
|
}
|
|
23
35
|
|
|
24
36
|
/**
|
|
@@ -45,30 +57,49 @@ const onLeave = (el: any) => {
|
|
|
45
57
|
el.style.opacity = '0'
|
|
46
58
|
}
|
|
47
59
|
|
|
60
|
+
// set nutation observer watching `visible` attribute in element
|
|
61
|
+
const handleVisibility = (visible: boolean = false) => {
|
|
62
|
+
toggle.value = visible
|
|
63
|
+
}
|
|
64
|
+
const observer = observeVisibleAttr(handleVisibility)
|
|
65
|
+
|
|
48
66
|
watch(
|
|
49
67
|
() => props.visible,
|
|
50
68
|
(newValue) => {
|
|
51
69
|
toggle.value = newValue
|
|
52
70
|
}
|
|
53
71
|
)
|
|
72
|
+
watch(toggle, (newValue) => {
|
|
73
|
+
if (newValue === true) {
|
|
74
|
+
emitOpenEvent()
|
|
75
|
+
} else if (newValue === false) {
|
|
76
|
+
emitCloseEvent()
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
defineExpose({
|
|
80
|
+
toggle: toggleCollapse,
|
|
81
|
+
close: closeCollapse,
|
|
82
|
+
open: openCollapse,
|
|
83
|
+
})
|
|
84
|
+
onMounted(() => {
|
|
85
|
+
if (collapseRef.value) {
|
|
86
|
+
observer.observe(collapseRef.value, { attributes: true })
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
onBeforeUnmount(() => {
|
|
90
|
+
observer.disconnect()
|
|
91
|
+
})
|
|
54
92
|
</script>
|
|
55
93
|
|
|
56
94
|
<template>
|
|
57
|
-
<div>
|
|
58
|
-
<button
|
|
59
|
-
:id="collapseId"
|
|
60
|
-
@click="handleToggleEvent"
|
|
61
|
-
class="hidden"
|
|
62
|
-
:accordion="accordion"
|
|
63
|
-
:visible="toggle"
|
|
64
|
-
></button>
|
|
95
|
+
<div :accordion="accordion" :visible="toggle" ref="collapseRef">
|
|
65
96
|
<transition
|
|
66
97
|
name="collapse"
|
|
67
98
|
tag="div"
|
|
68
99
|
@enter="onEnter"
|
|
69
100
|
@after-enter="onAfterEnter"
|
|
70
101
|
@leave="onLeave"
|
|
71
|
-
class="overflow-
|
|
102
|
+
class="overflow-y-clip"
|
|
72
103
|
>
|
|
73
104
|
<div v-show="toggle">
|
|
74
105
|
<div :class="[className]">
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
+
visible: {
|
|
3
|
+
type: import("vue").PropType<boolean>;
|
|
4
|
+
default: boolean;
|
|
5
|
+
};
|
|
6
|
+
accordion: {
|
|
7
|
+
type: import("vue").PropType<string>;
|
|
8
|
+
};
|
|
9
|
+
className: {
|
|
10
|
+
type: import("vue").PropType<string>;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
}, {
|
|
14
|
+
toggle: () => void;
|
|
15
|
+
close: () => void;
|
|
16
|
+
open: () => void;
|
|
17
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
open: (...args: any[]) => void;
|
|
19
|
+
close: (...args: any[]) => void;
|
|
20
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
visible: {
|
|
22
|
+
type: import("vue").PropType<boolean>;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
accordion: {
|
|
26
|
+
type: import("vue").PropType<string>;
|
|
27
|
+
};
|
|
28
|
+
className: {
|
|
29
|
+
type: import("vue").PropType<string>;
|
|
30
|
+
default: string;
|
|
31
|
+
};
|
|
32
|
+
}>> & {
|
|
33
|
+
onOpen?: ((...args: any[]) => any) | undefined;
|
|
34
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
visible: boolean;
|
|
37
|
+
className: string;
|
|
38
|
+
}, {}>, {
|
|
39
|
+
default?(_: {}): any;
|
|
40
|
+
}>;
|
|
41
|
+
export default _default;
|
|
42
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
43
|
+
new (): {
|
|
44
|
+
$slots: S;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './observeVisible';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './observeVisible';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './observeVisible'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const observeVisibleAttr: (fn: (...args: any[]) => void) => MutationObserver;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const observeVisibleAttr = (fn) => {
|
|
2
|
+
const observer = new MutationObserver((mutations) => {
|
|
3
|
+
let changed = false;
|
|
4
|
+
for (let i = 0; i < mutations.length && !changed; i++) {
|
|
5
|
+
const mutation = mutations[i];
|
|
6
|
+
const mutationType = mutation.type;
|
|
7
|
+
const mutationAttribute = mutation.attributeName;
|
|
8
|
+
const mutationTarget = mutation.target;
|
|
9
|
+
if (mutationType === 'attributes') {
|
|
10
|
+
changed = true;
|
|
11
|
+
}
|
|
12
|
+
else if (mutationAttribute === 'visible') {
|
|
13
|
+
changed = true;
|
|
14
|
+
}
|
|
15
|
+
if (changed) {
|
|
16
|
+
const visibleAttr = mutationTarget.getAttribute('visible') === 'true'
|
|
17
|
+
? true
|
|
18
|
+
: false;
|
|
19
|
+
fn(visibleAttr);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return observer;
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const observeVisibleAttr = (fn: (...args: any[]) => void) => {
|
|
2
|
+
const observer = new MutationObserver((mutations) => {
|
|
3
|
+
let changed = false
|
|
4
|
+
for (let i = 0; i < mutations.length && !changed; i++) {
|
|
5
|
+
const mutation = mutations[i]
|
|
6
|
+
const mutationType = mutation.type
|
|
7
|
+
const mutationAttribute = mutation.attributeName
|
|
8
|
+
const mutationTarget = mutation.target
|
|
9
|
+
if (mutationType === 'attributes') {
|
|
10
|
+
changed = true
|
|
11
|
+
} else if (mutationAttribute === 'visible') {
|
|
12
|
+
changed = true
|
|
13
|
+
}
|
|
14
|
+
if (changed) {
|
|
15
|
+
const visibleAttr =
|
|
16
|
+
(mutationTarget as HTMLElement).getAttribute('visible') === 'true'
|
|
17
|
+
? true
|
|
18
|
+
: false
|
|
19
|
+
fn(visibleAttr)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
return observer
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Directive } from 'vue';
|
|
2
|
+
import type { TooltipElementType, TooltipValueType } from './index.types';
|
|
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>;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { render, createVNode } from 'vue';
|
|
2
|
+
import tooltip from '../tooltip';
|
|
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
|
+
const eTarget = e.target;
|
|
20
|
+
let target;
|
|
21
|
+
if (eTarget.tagName === 'A') {
|
|
22
|
+
const targetId = eTarget.getAttribute('href');
|
|
23
|
+
const formattedTargetId = (targetId === null || targetId === void 0 ? void 0 : targetId.charAt(0)) === '#' ? targetId.substring(1) : targetId;
|
|
24
|
+
target = document.getElementById(formattedTargetId);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
target = document.getElementById(binding.arg);
|
|
28
|
+
}
|
|
29
|
+
if (!target) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (target.hasAttribute('visible') === false) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const targetAttr = target.getAttribute('visible');
|
|
36
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
37
|
+
target.setAttribute('visible', attrAfterToggle);
|
|
38
|
+
return;
|
|
39
|
+
};
|
|
40
|
+
el.addEventListener('click', el.__ClickToggleHandler);
|
|
41
|
+
},
|
|
42
|
+
unmounted(el) {
|
|
43
|
+
el.removeEventListener('click', el.__ClickToggleHandler);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export const vCollapse = {
|
|
47
|
+
mounted(el, binding) {
|
|
48
|
+
// el.__HandleToggler = (event: Event): void => {
|
|
49
|
+
// const eTarget = event.target as HTMLElement
|
|
50
|
+
// let target: HTMLElement
|
|
51
|
+
// if (eTarget.tagName === 'A') {
|
|
52
|
+
// const targetId = eTarget.getAttribute('href')
|
|
53
|
+
// const formattedTargetId =
|
|
54
|
+
// targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId
|
|
55
|
+
// target = document.getElementById(formattedTargetId as string)!
|
|
56
|
+
// } else {
|
|
57
|
+
// target = document.getElementById(binding.arg as string) as HTMLElement
|
|
58
|
+
// }
|
|
59
|
+
// if (!target.hasAttribute('accordion')) {
|
|
60
|
+
// // run when it is not accordion component case
|
|
61
|
+
// target.click()
|
|
62
|
+
// return
|
|
63
|
+
// }
|
|
64
|
+
// const accordionName = target.getAttribute('accordion')
|
|
65
|
+
// const accordionList: NodeListOf<HTMLElement> = document.querySelectorAll(
|
|
66
|
+
// `button[accordion="${accordionName}"]`
|
|
67
|
+
// )
|
|
68
|
+
// // loop through each accordion items and handle reaction for each case
|
|
69
|
+
// for (let i = 0; i < accordionList.length; i++) {
|
|
70
|
+
// const isVisible = accordionList[i].getAttribute('visible')
|
|
71
|
+
// if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
72
|
+
// accordionList[i].click()
|
|
73
|
+
// }
|
|
74
|
+
// if (accordionList[i].id === target.id) {
|
|
75
|
+
// accordionList[i].click()
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
78
|
+
// }
|
|
79
|
+
el.__HandleToggler = (event) => {
|
|
80
|
+
const eTarget = event.target;
|
|
81
|
+
let target;
|
|
82
|
+
if (eTarget.tagName === 'A') {
|
|
83
|
+
const targetId = eTarget.getAttribute('href');
|
|
84
|
+
const formattedTargetId = (targetId === null || targetId === void 0 ? void 0 : targetId.charAt(0)) === '#' ? targetId.substring(1) : targetId;
|
|
85
|
+
target = document.getElementById(formattedTargetId);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
target = document.getElementById(binding.arg);
|
|
89
|
+
}
|
|
90
|
+
if (!target) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (target.hasAttribute('visible') === false) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!target.hasAttribute('accordion')) {
|
|
97
|
+
// run when it is not accordion component case
|
|
98
|
+
const targetAttr = target.getAttribute('visible');
|
|
99
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
100
|
+
target.setAttribute('visible', attrAfterToggle);
|
|
101
|
+
// target.click()
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const accordionName = target.getAttribute('accordion');
|
|
105
|
+
const accordionList = document.querySelectorAll(`div[accordion="${accordionName}"]`);
|
|
106
|
+
// loop through each accordion items and handle reaction for each case
|
|
107
|
+
for (let i = 0; i < accordionList.length; i++) {
|
|
108
|
+
const isVisible = accordionList[i].getAttribute('visible');
|
|
109
|
+
if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
110
|
+
accordionList[i].setAttribute('visible', 'false');
|
|
111
|
+
// accordionList[i].click()
|
|
112
|
+
}
|
|
113
|
+
if (accordionList[i].id === target.id) {
|
|
114
|
+
const targetAttr = target.getAttribute('visible');
|
|
115
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true';
|
|
116
|
+
target.setAttribute('visible', attrAfterToggle);
|
|
117
|
+
// accordionList[i].click()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
el.addEventListener('click', el.__HandleToggler);
|
|
122
|
+
},
|
|
123
|
+
unmounted(el) {
|
|
124
|
+
el.removeEventListener('click', el.__HandleToggler);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
export const vTooltip = {
|
|
128
|
+
mounted(el, binding) {
|
|
129
|
+
el.__HandleTooltip = (el, binding) => {
|
|
130
|
+
// parent element class
|
|
131
|
+
el.classList.add('relative', 'group', 'overflow-visible');
|
|
132
|
+
// handle tooltip text
|
|
133
|
+
let tooltipText;
|
|
134
|
+
if (el.hasAttribute('title')) {
|
|
135
|
+
tooltipText = el.getAttribute('title');
|
|
136
|
+
}
|
|
137
|
+
if (!el.hasAttribute('title') &&
|
|
138
|
+
typeof binding.value !== 'undefined' &&
|
|
139
|
+
typeof binding.value === 'string') {
|
|
140
|
+
tooltipText = binding.value;
|
|
141
|
+
}
|
|
142
|
+
if (!el.hasAttribute('title') &&
|
|
143
|
+
typeof binding.value !== 'undefined' &&
|
|
144
|
+
typeof binding.value !== 'string' &&
|
|
145
|
+
typeof binding.value.title === 'string') {
|
|
146
|
+
tooltipText = binding.value.title;
|
|
147
|
+
}
|
|
148
|
+
// handle tooltip color
|
|
149
|
+
let tooltipColor;
|
|
150
|
+
if (el.hasAttribute('color')) {
|
|
151
|
+
tooltipColor = el.getAttribute('color');
|
|
152
|
+
}
|
|
153
|
+
if (!el.hasAttribute('color') &&
|
|
154
|
+
typeof binding.value !== 'undefined' &&
|
|
155
|
+
typeof binding.value !== 'string' &&
|
|
156
|
+
typeof binding.value.color === 'string') {
|
|
157
|
+
tooltipColor = binding.value.color;
|
|
158
|
+
}
|
|
159
|
+
// handle tooltip text color
|
|
160
|
+
let tooltipTextColor;
|
|
161
|
+
if (el.hasAttribute('text-color')) {
|
|
162
|
+
tooltipTextColor = el.getAttribute('text-color');
|
|
163
|
+
}
|
|
164
|
+
if (!el.hasAttribute('text-color') &&
|
|
165
|
+
typeof binding.value !== 'undefined' &&
|
|
166
|
+
typeof binding.value !== 'string' &&
|
|
167
|
+
typeof binding.value.textColor === 'string') {
|
|
168
|
+
tooltipTextColor = binding.value.textColor;
|
|
169
|
+
}
|
|
170
|
+
// handle tooltip width
|
|
171
|
+
let tooltipWidth;
|
|
172
|
+
if (el.hasAttribute('width')) {
|
|
173
|
+
tooltipWidth = el.getAttribute('width');
|
|
174
|
+
}
|
|
175
|
+
if (!el.hasAttribute('width') &&
|
|
176
|
+
typeof binding.value !== 'undefined' &&
|
|
177
|
+
typeof binding.value !== 'string' &&
|
|
178
|
+
typeof binding.value.width === ('number' || 'string')) {
|
|
179
|
+
tooltipWidth = binding.value.width;
|
|
180
|
+
}
|
|
181
|
+
// handle custom class names
|
|
182
|
+
let tooltipClassName;
|
|
183
|
+
if (typeof binding.value !== 'undefined' &&
|
|
184
|
+
typeof binding.value !== 'string' &&
|
|
185
|
+
typeof binding.value.className === 'string') {
|
|
186
|
+
tooltipClassName = binding.value.className;
|
|
187
|
+
}
|
|
188
|
+
let tooltipDirection;
|
|
189
|
+
const modifierArray = Object.keys(binding.modifiers);
|
|
190
|
+
// handle direction
|
|
191
|
+
if (modifierArray.length > 0) {
|
|
192
|
+
tooltipDirection = modifierArray[0];
|
|
193
|
+
}
|
|
194
|
+
const vnode = createVNode(tooltip, {
|
|
195
|
+
direction: tooltipDirection,
|
|
196
|
+
title: tooltipText,
|
|
197
|
+
color: tooltipColor,
|
|
198
|
+
textColor: tooltipTextColor,
|
|
199
|
+
width: tooltipWidth,
|
|
200
|
+
customClass: tooltipClassName,
|
|
201
|
+
});
|
|
202
|
+
render(vnode, el);
|
|
203
|
+
};
|
|
204
|
+
el.__UnmountTooltip = (el) => {
|
|
205
|
+
render(null, el);
|
|
206
|
+
};
|
|
207
|
+
el.__HandleTooltip(el, binding);
|
|
208
|
+
},
|
|
209
|
+
updated(el, binding) {
|
|
210
|
+
el.__HandleTooltip(el, binding);
|
|
211
|
+
},
|
|
212
|
+
unmounted(el) {
|
|
213
|
+
el.__UnmountTooltip(el);
|
|
214
|
+
},
|
|
215
|
+
};
|
package/lib/directives/index.ts
CHANGED
|
@@ -31,7 +31,15 @@ export const vToggle: Directive = {
|
|
|
31
31
|
} else {
|
|
32
32
|
target = document.getElementById(binding.arg as string)!
|
|
33
33
|
}
|
|
34
|
-
target
|
|
34
|
+
if (!target) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
if (target.hasAttribute('visible') === false) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
const targetAttr = target.getAttribute('visible')
|
|
41
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
42
|
+
target.setAttribute('visible', attrAfterToggle)
|
|
35
43
|
return
|
|
36
44
|
}
|
|
37
45
|
el.addEventListener('click', el.__ClickToggleHandler)
|
|
@@ -43,6 +51,37 @@ export const vToggle: Directive = {
|
|
|
43
51
|
|
|
44
52
|
export const vCollapse: Directive = {
|
|
45
53
|
mounted(el, binding) {
|
|
54
|
+
// el.__HandleToggler = (event: Event): void => {
|
|
55
|
+
// const eTarget = event.target as HTMLElement
|
|
56
|
+
// let target: HTMLElement
|
|
57
|
+
// if (eTarget.tagName === 'A') {
|
|
58
|
+
// const targetId = eTarget.getAttribute('href')
|
|
59
|
+
// const formattedTargetId =
|
|
60
|
+
// targetId?.charAt(0) === '#' ? targetId.substring(1) : targetId
|
|
61
|
+
// target = document.getElementById(formattedTargetId as string)!
|
|
62
|
+
// } else {
|
|
63
|
+
// target = document.getElementById(binding.arg as string) as HTMLElement
|
|
64
|
+
// }
|
|
65
|
+
// if (!target.hasAttribute('accordion')) {
|
|
66
|
+
// // run when it is not accordion component case
|
|
67
|
+
// target.click()
|
|
68
|
+
// return
|
|
69
|
+
// }
|
|
70
|
+
// const accordionName = target.getAttribute('accordion')
|
|
71
|
+
// const accordionList: NodeListOf<HTMLElement> = document.querySelectorAll(
|
|
72
|
+
// `button[accordion="${accordionName}"]`
|
|
73
|
+
// )
|
|
74
|
+
// // loop through each accordion items and handle reaction for each case
|
|
75
|
+
// for (let i = 0; i < accordionList.length; i++) {
|
|
76
|
+
// const isVisible = accordionList[i].getAttribute('visible')
|
|
77
|
+
// if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
78
|
+
// accordionList[i].click()
|
|
79
|
+
// }
|
|
80
|
+
// if (accordionList[i].id === target.id) {
|
|
81
|
+
// accordionList[i].click()
|
|
82
|
+
// }
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
46
85
|
el.__HandleToggler = (event: Event): void => {
|
|
47
86
|
const eTarget = event.target as HTMLElement
|
|
48
87
|
let target: HTMLElement
|
|
@@ -54,23 +93,36 @@ export const vCollapse: Directive = {
|
|
|
54
93
|
} else {
|
|
55
94
|
target = document.getElementById(binding.arg as string) as HTMLElement
|
|
56
95
|
}
|
|
96
|
+
if (!target) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
if (target.hasAttribute('visible') === false) {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
57
102
|
if (!target.hasAttribute('accordion')) {
|
|
58
103
|
// run when it is not accordion component case
|
|
59
|
-
target.
|
|
104
|
+
const targetAttr = target.getAttribute('visible')
|
|
105
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
106
|
+
target.setAttribute('visible', attrAfterToggle)
|
|
107
|
+
// target.click()
|
|
60
108
|
return
|
|
61
109
|
}
|
|
62
110
|
const accordionName = target.getAttribute('accordion')
|
|
63
111
|
const accordionList: NodeListOf<HTMLElement> = document.querySelectorAll(
|
|
64
|
-
`
|
|
112
|
+
`div[accordion="${accordionName}"]`
|
|
65
113
|
)
|
|
66
114
|
// loop through each accordion items and handle reaction for each case
|
|
67
115
|
for (let i = 0; i < accordionList.length; i++) {
|
|
68
116
|
const isVisible = accordionList[i].getAttribute('visible')
|
|
69
117
|
if (accordionList[i].id !== target.id && isVisible === 'true') {
|
|
70
|
-
accordionList[i].
|
|
118
|
+
accordionList[i].setAttribute('visible', 'false')
|
|
119
|
+
// accordionList[i].click()
|
|
71
120
|
}
|
|
72
121
|
if (accordionList[i].id === target.id) {
|
|
73
|
-
|
|
122
|
+
const targetAttr = target.getAttribute('visible')
|
|
123
|
+
const attrAfterToggle = targetAttr === 'true' ? 'false' : 'true'
|
|
124
|
+
target.setAttribute('visible', attrAfterToggle)
|
|
125
|
+
// accordionList[i].click()
|
|
74
126
|
}
|
|
75
127
|
}
|
|
76
128
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ColorPalette } from '../..';
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
2
|
+
toggle: (...args: any[]) => void;
|
|
3
|
+
"click-outside": (...args: any[]) => void;
|
|
4
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
|
5
|
+
onToggle?: ((...args: any[]) => any) | undefined;
|
|
6
|
+
"onClick-outside"?: ((...args: any[]) => any) | undefined;
|
|
7
|
+
}, {}, {}>, {
|
|
8
|
+
toggler?(_: {
|
|
9
|
+
toggle: (e: Event) => void;
|
|
10
|
+
dropdownState: boolean;
|
|
11
|
+
}): any;
|
|
12
|
+
default?(_: {}): any;
|
|
13
|
+
}>;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
+
className: {
|
|
3
|
+
type: import("vue").PropType<string>;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
className: {
|
|
8
|
+
type: import("vue").PropType<string>;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
}>>, {
|
|
12
|
+
className: string;
|
|
13
|
+
}, {}>, {
|
|
14
|
+
default?(_: {
|
|
15
|
+
itemClick: () => void;
|
|
16
|
+
}): any;
|
|
17
|
+
}>;
|
|
18
|
+
export default _default;
|
|
19
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
20
|
+
new (): {
|
|
21
|
+
$slots: S;
|
|
22
|
+
};
|
|
23
|
+
};
|