@pictogrammers/components 0.3.1
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/@types/css.d.ts +4 -0
- package/@types/html.d.ts +4 -0
- package/README.md +49 -0
- package/dist/main.js +3819 -0
- package/dist/pgAnnoy.js +116 -0
- package/dist/pgAvatar.js +136 -0
- package/dist/pgButton.js +116 -0
- package/dist/pgButtonGroup.js +116 -0
- package/dist/pgButtonLink.js +116 -0
- package/dist/pgButtonToggle.js +146 -0
- package/dist/pgCard.js +116 -0
- package/dist/pgCardUser.js +196 -0
- package/dist/pgColor.js +136 -0
- package/dist/pgDatabase.js +236 -0
- package/dist/pgDropdown.js +686 -0
- package/dist/pgGrid.js +126 -0
- package/dist/pgHeader.js +116 -0
- package/dist/pgIcon.js +116 -0
- package/dist/pgInputCheck.js +116 -0
- package/dist/pgInputCheckList.js +126 -0
- package/dist/pgInputFileLocal.js +116 -0
- package/dist/pgInputHexRgb.js +126 -0
- package/dist/pgInputRange.js +116 -0
- package/dist/pgInputSelect.js +116 -0
- package/dist/pgInputText.js +116 -0
- package/dist/pgInputTextIcon.js +176 -0
- package/dist/pgInputUserSelect.js +116 -0
- package/dist/pgListTag.js +136 -0
- package/dist/pgMarkdown.js +346 -0
- package/dist/pgMenuIcon.js +206 -0
- package/dist/pgModalAlert.js +126 -0
- package/dist/pgModification.js +396 -0
- package/dist/pgNav.js +116 -0
- package/dist/pgOverlay.js +96 -0
- package/dist/pgPicker.js +116 -0
- package/dist/pgPreview.js +116 -0
- package/dist/pgScroll.js +266 -0
- package/dist/pgSearch.js +146 -0
- package/dist/pgTab.js +116 -0
- package/dist/pgTabs.js +136 -0
- package/dist/pgToast.js +136 -0
- package/dist/pgToasts.js +136 -0
- package/dist/pgTooltip.js +126 -0
- package/index.html +302 -0
- package/package.json +25 -0
- package/pg/annoy/README.md +18 -0
- package/pg/annoy/__examples__/basic/basic.html +8 -0
- package/pg/annoy/__examples__/basic/basic.ts +11 -0
- package/pg/annoy/annoy.css +238 -0
- package/pg/annoy/annoy.html +59 -0
- package/pg/annoy/annoy.ts +48 -0
- package/pg/annoy/index.ts +3 -0
- package/pg/avatar/README.md +23 -0
- package/pg/avatar/__examples__/basic/basic.html +6 -0
- package/pg/avatar/__examples__/basic/basic.ts +41 -0
- package/pg/avatar/__examples__/basic/constants.ts +1 -0
- package/pg/avatar/avatar.css +45 -0
- package/pg/avatar/avatar.html +8 -0
- package/pg/avatar/avatar.spec.ts +51 -0
- package/pg/avatar/avatar.ts +37 -0
- package/pg/avatar/index.ts +3 -0
- package/pg/button/README.md +51 -0
- package/pg/button/__examples__/basic/basic.html +11 -0
- package/pg/button/__examples__/basic/basic.ts +11 -0
- package/pg/button/__examples__/states/states.html +8 -0
- package/pg/button/__examples__/states/states.ts +20 -0
- package/pg/button/button.css +91 -0
- package/pg/button/button.html +3 -0
- package/pg/button/button.ts +45 -0
- package/pg/button/index.ts +3 -0
- package/pg/buttonGroup/README.md +28 -0
- package/pg/buttonGroup/__examples__/basic/basic.html +12 -0
- package/pg/buttonGroup/__examples__/basic/basic.ts +11 -0
- package/pg/buttonGroup/buttonGroup.css +4 -0
- package/pg/buttonGroup/buttonGroup.html +1 -0
- package/pg/buttonGroup/buttonGroup.spec.ts +30 -0
- package/pg/buttonGroup/buttonGroup.ts +50 -0
- package/pg/buttonGroup/index.ts +3 -0
- package/pg/buttonLink/README.md +51 -0
- package/pg/buttonLink/__examples__/basic/basic.html +17 -0
- package/pg/buttonLink/__examples__/basic/basic.ts +11 -0
- package/pg/buttonLink/buttonLink.css +91 -0
- package/pg/buttonLink/buttonLink.html +3 -0
- package/pg/buttonLink/buttonLink.ts +46 -0
- package/pg/buttonLink/index.ts +3 -0
- package/pg/buttonToggle/README.md +54 -0
- package/pg/buttonToggle/__examples__/basic/basic.html +10 -0
- package/pg/buttonToggle/__examples__/basic/basic.ts +23 -0
- package/pg/buttonToggle/buttonToggle.css +8 -0
- package/pg/buttonToggle/buttonToggle.html +4 -0
- package/pg/buttonToggle/buttonToggle.ts +44 -0
- package/pg/buttonToggle/index.ts +3 -0
- package/pg/card/README.md +21 -0
- package/pg/card/__examples__/basic/basic.html +5 -0
- package/pg/card/__examples__/basic/basic.ts +11 -0
- package/pg/card/card.css +11 -0
- package/pg/card/card.html +3 -0
- package/pg/card/card.spec.ts +30 -0
- package/pg/card/card.ts +13 -0
- package/pg/card/index.ts +3 -0
- package/pg/cardUser/README.md +22 -0
- package/pg/cardUser/__examples__/basic/basic.html +3 -0
- package/pg/cardUser/__examples__/basic/basic.ts +30 -0
- package/pg/cardUser/__examples__/basic/constants.ts +1 -0
- package/pg/cardUser/cardUser.css +67 -0
- package/pg/cardUser/cardUser.html +23 -0
- package/pg/cardUser/cardUser.spec.ts +46 -0
- package/pg/cardUser/cardUser.ts +53 -0
- package/pg/cardUser/index.ts +3 -0
- package/pg/color/README.md +13 -0
- package/pg/color/__examples__/basic/basic.html +4 -0
- package/pg/color/__examples__/basic/basic.ts +20 -0
- package/pg/color/color.css +21 -0
- package/pg/color/color.html +1 -0
- package/pg/color/color.ts +97 -0
- package/pg/color/constants.ts +357 -0
- package/pg/color/index.ts +3 -0
- package/pg/color/utils.ts +27 -0
- package/pg/database/README.md +28 -0
- package/pg/database/__examples__/basic/basic.html +9 -0
- package/pg/database/__examples__/basic/basic.ts +37 -0
- package/pg/database/database.css +0 -0
- package/pg/database/database.html +0 -0
- package/pg/database/database.ts +42 -0
- package/pg/database/index.ts +3 -0
- package/pg/dropdown/README.md +13 -0
- package/pg/dropdown/__examples__/basic/basic.html +14 -0
- package/pg/dropdown/__examples__/basic/basic.ts +11 -0
- package/pg/dropdown/dropdown.css +46 -0
- package/pg/dropdown/dropdown.html +5 -0
- package/pg/dropdown/dropdown.ts +60 -0
- package/pg/dropdown/index.ts +3 -0
- package/pg/grid/README.md +97 -0
- package/pg/grid/__examples__/basic/basic.html +29 -0
- package/pg/grid/__examples__/basic/basic.ts +139 -0
- package/pg/grid/grid.css +68 -0
- package/pg/grid/grid.html +6 -0
- package/pg/grid/grid.spec.ts +66 -0
- package/pg/grid/grid.ts +417 -0
- package/pg/grid/index.ts +3 -0
- package/pg/header/README.md +23 -0
- package/pg/header/__examples__/basic/basic.html +8 -0
- package/pg/header/__examples__/basic/basic.ts +11 -0
- package/pg/header/header.css +42 -0
- package/pg/header/header.html +15 -0
- package/pg/header/header.ts +28 -0
- package/pg/header/index.ts +3 -0
- package/pg/icon/README.md +26 -0
- package/pg/icon/__examples__/basic/basic.html +16 -0
- package/pg/icon/__examples__/basic/basic.ts +34 -0
- package/pg/icon/__examples__/basic/constants.ts +2 -0
- package/pg/icon/icon.css +9 -0
- package/pg/icon/icon.html +3 -0
- package/pg/icon/icon.spec.ts +46 -0
- package/pg/icon/icon.ts +23 -0
- package/pg/icon/index.ts +3 -0
- package/pg/inputCheck/README.md +32 -0
- package/pg/inputCheck/__examples__/basic/basic.html +8 -0
- package/pg/inputCheck/__examples__/basic/basic.ts +23 -0
- package/pg/inputCheck/index.ts +3 -0
- package/pg/inputCheck/inputCheck.css +45 -0
- package/pg/inputCheck/inputCheck.html +6 -0
- package/pg/inputCheck/inputCheck.ts +42 -0
- package/pg/inputCheckList/README.md +35 -0
- package/pg/inputCheckList/__examples__/basic/basic.html +4 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +31 -0
- package/pg/inputCheckList/index.ts +3 -0
- package/pg/inputCheckList/inputCheckList.css +70 -0
- package/pg/inputCheckList/inputCheckList.html +1 -0
- package/pg/inputCheckList/inputCheckList.ts +103 -0
- package/pg/inputCheckList/templates/option.html +8 -0
- package/pg/inputFileLocal/README.md +30 -0
- package/pg/inputFileLocal/__examples__/basic/basic.html +4 -0
- package/pg/inputFileLocal/__examples__/basic/basic.ts +23 -0
- package/pg/inputFileLocal/index.ts +3 -0
- package/pg/inputFileLocal/inputFileLocal.css +80 -0
- package/pg/inputFileLocal/inputFileLocal.html +5 -0
- package/pg/inputFileLocal/inputFileLocal.ts +82 -0
- package/pg/inputHexRgb/README.md +15 -0
- package/pg/inputHexRgb/__examples__/basic/basic.html +4 -0
- package/pg/inputHexRgb/__examples__/basic/basic.ts +23 -0
- package/pg/inputHexRgb/index.ts +3 -0
- package/pg/inputHexRgb/inputHexRgb.css +96 -0
- package/pg/inputHexRgb/inputHexRgb.html +9 -0
- package/pg/inputHexRgb/inputHexRgb.ts +79 -0
- package/pg/inputHexRgb/utils.ts +27 -0
- package/pg/inputRange/README.md +18 -0
- package/pg/inputRange/__examples__/basic/basic.html +9 -0
- package/pg/inputRange/__examples__/basic/basic.ts +30 -0
- package/pg/inputRange/index.ts +3 -0
- package/pg/inputRange/inputRange.css +0 -0
- package/pg/inputRange/inputRange.html +1 -0
- package/pg/inputRange/inputRange.ts +53 -0
- package/pg/inputSelect/README.md +25 -0
- package/pg/inputSelect/__examples__/basic/basic.html +6 -0
- package/pg/inputSelect/__examples__/basic/basic.ts +30 -0
- package/pg/inputSelect/index.ts +3 -0
- package/pg/inputSelect/inputSelect.css +36 -0
- package/pg/inputSelect/inputSelect.html +4 -0
- package/pg/inputSelect/inputSelect.ts +57 -0
- package/pg/inputText/README.md +27 -0
- package/pg/inputText/__examples__/basic/basic.html +9 -0
- package/pg/inputText/__examples__/basic/basic.ts +30 -0
- package/pg/inputText/index.ts +3 -0
- package/pg/inputText/inputText.css +20 -0
- package/pg/inputText/inputText.html +1 -0
- package/pg/inputText/inputText.spec.ts +59 -0
- package/pg/inputText/inputText.ts +59 -0
- package/pg/inputTextIcon/README.md +26 -0
- package/pg/inputTextIcon/index.ts +3 -0
- package/pg/inputTextIcon/inputTextIcon.css +24 -0
- package/pg/inputTextIcon/inputTextIcon.html +4 -0
- package/pg/inputTextIcon/inputTextIcon.spec.ts +44 -0
- package/pg/inputTextIcon/inputTextIcon.ts +26 -0
- package/pg/inputUserSelect/README.md +31 -0
- package/pg/inputUserSelect/__examples__/basic/basic.html +4 -0
- package/pg/inputUserSelect/__examples__/basic/basic.ts +25 -0
- package/pg/inputUserSelect/__examples__/basic/constants.ts +33 -0
- package/pg/inputUserSelect/index.ts +3 -0
- package/pg/inputUserSelect/inputUserSelect.css +174 -0
- package/pg/inputUserSelect/inputUserSelect.html +18 -0
- package/pg/inputUserSelect/inputUserSelect.ts +266 -0
- package/pg/listTag/README.md +26 -0
- package/pg/listTag/__examples__/basic/basic.html +16 -0
- package/pg/listTag/__examples__/basic/basic.ts +53 -0
- package/pg/listTag/__examples__/basic/constants.ts +22 -0
- package/pg/listTag/index.ts +3 -0
- package/pg/listTag/listTag.css +9 -0
- package/pg/listTag/listTag.html +1 -0
- package/pg/listTag/listTag.ts +48 -0
- package/pg/listTag/partials/tag.html +3 -0
- package/pg/markdown/README.md +13 -0
- package/pg/markdown/__examples__/basic/basic.html +3 -0
- package/pg/markdown/__examples__/basic/basic.ts +51 -0
- package/pg/markdown/__examples__/basic/constants.ts +129 -0
- package/pg/markdown/index.ts +5 -0
- package/pg/markdown/markdown.css +760 -0
- package/pg/markdown/markdown.html +1 -0
- package/pg/markdown/markdown.md +123 -0
- package/pg/markdown/markdown.spec.ts +87 -0
- package/pg/markdown/markdown.ts +381 -0
- package/pg/markdown/markdownReplace.ts +7 -0
- package/pg/menuIcon/README.md +13 -0
- package/pg/menuIcon/__examples__/basic/basic.html +3 -0
- package/pg/menuIcon/__examples__/basic/basic.ts +15 -0
- package/pg/menuIcon/index.ts +3 -0
- package/pg/menuIcon/menuIcon.css +168 -0
- package/pg/menuIcon/menuIcon.html +64 -0
- package/pg/menuIcon/menuIcon.ts +271 -0
- package/pg/modalAlert/README.md +17 -0
- package/pg/modalAlert/__examples__/basic/basic.html +4 -0
- package/pg/modalAlert/__examples__/basic/basic.ts +27 -0
- package/pg/modalAlert/index.ts +3 -0
- package/pg/modalAlert/modalAlert.css +43 -0
- package/pg/modalAlert/modalAlert.html +22 -0
- package/pg/modalAlert/modalAlert.ts +45 -0
- package/pg/modification/README.md +34 -0
- package/pg/modification/__examples__/basic/basic.html +8 -0
- package/pg/modification/__examples__/basic/basic.ts +63 -0
- package/pg/modification/__examples__/basic/constants.ts +416 -0
- package/pg/modification/index.ts +3 -0
- package/pg/modification/modification.css +311 -0
- package/pg/modification/modification.html +1 -0
- package/pg/modification/modification.spec.ts +33 -0
- package/pg/modification/modification.ts +201 -0
- package/pg/modification/type/date.html +1 -0
- package/pg/modification/type/iconAliasCreated.html +13 -0
- package/pg/modification/type/iconAliasDeleted.html +13 -0
- package/pg/modification/type/iconAuthorModified.html +13 -0
- package/pg/modification/type/iconCreated.html +13 -0
- package/pg/modification/type/iconDeleted.html +13 -0
- package/pg/modification/type/iconDeprecated.html +13 -0
- package/pg/modification/type/iconDescriptionModified.html +10 -0
- package/pg/modification/type/iconModified.html +14 -0
- package/pg/modification/type/iconRenamed.html +13 -0
- package/pg/modification/type/iconTagCreated.html +13 -0
- package/pg/modification/type/iconTagDeleted.html +13 -0
- package/pg/modification/type/news.html +5 -0
- package/pg/nav/README.md +16 -0
- package/pg/nav/__examples__/basic/basic.html +5 -0
- package/pg/nav/__examples__/basic/basic.ts +11 -0
- package/pg/nav/index.ts +3 -0
- package/pg/nav/nav.css +14 -0
- package/pg/nav/nav.html +16 -0
- package/pg/nav/nav.ts +21 -0
- package/pg/overlay/README.md +37 -0
- package/pg/overlay/__examples__/basic/basic.css +3 -0
- package/pg/overlay/__examples__/basic/basic.html +3 -0
- package/pg/overlay/__examples__/basic/basic.ts +13 -0
- package/pg/overlay/index.ts +3 -0
- package/pg/overlay/overlay.ts +26 -0
- package/pg/picker/README.md +13 -0
- package/pg/picker/index.ts +3 -0
- package/pg/picker/picker.css +56 -0
- package/pg/picker/picker.html +8 -0
- package/pg/picker/picker.ts +66 -0
- package/pg/preview/README.md +19 -0
- package/pg/preview/__examples__/basic/basic.html +11 -0
- package/pg/preview/__examples__/basic/basic.ts +22 -0
- package/pg/preview/index.ts +3 -0
- package/pg/preview/preview.css +34 -0
- package/pg/preview/preview.html +5 -0
- package/pg/preview/preview.ts +38 -0
- package/pg/scroll/README.md +42 -0
- package/pg/scroll/__examples__/basic/basic.css +4 -0
- package/pg/scroll/__examples__/basic/basic.html +11 -0
- package/pg/scroll/__examples__/basic/basic.ts +88 -0
- package/pg/scroll/index.ts +3 -0
- package/pg/scroll/scroll.css +7 -0
- package/pg/scroll/scroll.html +3 -0
- package/pg/scroll/scroll.ts +158 -0
- package/pg/search/README.md +59 -0
- package/pg/search/__examples__/basic/basic.html +3 -0
- package/pg/search/__examples__/basic/basic.ts +29 -0
- package/pg/search/__examples__/basic/constants.ts +3 -0
- package/pg/search/index.ts +3 -0
- package/pg/search/search.css +188 -0
- package/pg/search/search.html +18 -0
- package/pg/search/search.ts +252 -0
- package/pg/search/utils.ts +12 -0
- package/pg/shared/README.md +28 -0
- package/pg/shared/copy.ts +25 -0
- package/pg/shared/database.ts +35 -0
- package/pg/shared/databaseService.ts +230 -0
- package/pg/shared/debounce.ts +12 -0
- package/pg/shared/enums/modificationType.ts +19 -0
- package/pg/shared/filter.ts +14 -0
- package/pg/shared/http.ts +83 -0
- package/pg/shared/iconFilter.spec.ts +61 -0
- package/pg/shared/iconFilter.ts +71 -0
- package/pg/shared/list.ts +34 -0
- package/pg/shared/models/alias.ts +40 -0
- package/pg/shared/models/font.ts +31 -0
- package/pg/shared/models/fontIcon.ts +25 -0
- package/pg/shared/models/fontVersion.ts +22 -0
- package/pg/shared/models/icon.ts +97 -0
- package/pg/shared/models/modification.ts +45 -0
- package/pg/shared/models/style.ts +12 -0
- package/pg/shared/models/tag.ts +37 -0
- package/pg/shared/models/user.ts +35 -0
- package/pg/shared/models/version.ts +20 -0
- package/pg/shared/removeDiacritics.ts +94 -0
- package/pg/shared/toast.ts +47 -0
- package/pg/shared/uuid.ts +6 -0
- package/pg/tab/README.md +18 -0
- package/pg/tab/index.ts +3 -0
- package/pg/tab/tab.css +13 -0
- package/pg/tab/tab.html +3 -0
- package/pg/tab/tab.ts +51 -0
- package/pg/tabs/README.md +31 -0
- package/pg/tabs/__examples__/basic/basic.html +13 -0
- package/pg/tabs/__examples__/basic/basic.ts +11 -0
- package/pg/tabs/index.ts +3 -0
- package/pg/tabs/partials/tab.html +3 -0
- package/pg/tabs/tabs.css +69 -0
- package/pg/tabs/tabs.html +4 -0
- package/pg/tabs/tabs.ts +102 -0
- package/pg/toast/README.md +13 -0
- package/pg/toast/index.ts +3 -0
- package/pg/toast/toast.css +112 -0
- package/pg/toast/toast.html +13 -0
- package/pg/toast/toast.ts +39 -0
- package/pg/toasts/README.md +37 -0
- package/pg/toasts/__examples__/basic/basic.html +11 -0
- package/pg/toasts/__examples__/basic/basic.ts +86 -0
- package/pg/toasts/index.ts +3 -0
- package/pg/toasts/toasts.css +8 -0
- package/pg/toasts/toasts.html +1 -0
- package/pg/toasts/toasts.ts +51 -0
- package/pg/tooltip/README.md +51 -0
- package/pg/tooltip/__examples__/basic/basic.css +38 -0
- package/pg/tooltip/__examples__/basic/basic.html +21 -0
- package/pg/tooltip/__examples__/basic/basic.ts +55 -0
- package/pg/tooltip/addTooltip.ts +31 -0
- package/pg/tooltip/index.ts +20 -0
- package/pg/tooltip/position.ts +15 -0
- package/pg/tooltip/tooltip.css +36 -0
- package/pg/tooltip/tooltip.html +4 -0
- package/pg/tooltip/tooltip.ts +170 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Component, Prop, Part } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import template from './tooltip.html';
|
|
4
|
+
import style from './tooltip.css'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
TOP,
|
|
8
|
+
TOP_START,
|
|
9
|
+
TOP_END,
|
|
10
|
+
RIGHT,
|
|
11
|
+
RIGHT_START,
|
|
12
|
+
RIGHT_END,
|
|
13
|
+
BOTTOM,
|
|
14
|
+
BOTTOM_START,
|
|
15
|
+
BOTTOM_END,
|
|
16
|
+
LEFT,
|
|
17
|
+
LEFT_START,
|
|
18
|
+
LEFT_END
|
|
19
|
+
} from './position';
|
|
20
|
+
|
|
21
|
+
const map = {
|
|
22
|
+
[TOP_START]: (width, height, rect) => {
|
|
23
|
+
return {
|
|
24
|
+
arrowTop: height - 5,
|
|
25
|
+
arrowLeft: rect.width > width
|
|
26
|
+
? Math.floor(width / 2) - 5
|
|
27
|
+
: Math.floor(rect.width / 2) - 5,
|
|
28
|
+
left: rect.left,
|
|
29
|
+
top: rect.top - height - 10
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
[TOP]: (width, height, rect) => {
|
|
33
|
+
return {
|
|
34
|
+
arrowTop: height - 5,
|
|
35
|
+
arrowLeft: Math.floor(width / 2) - 5,
|
|
36
|
+
left: rect.left - Math.floor((width - rect.width) / 2),
|
|
37
|
+
top: rect.top - height - 10
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
[TOP_END]: (width, height, rect) => {
|
|
41
|
+
return {
|
|
42
|
+
arrowTop: height - 5,
|
|
43
|
+
arrowLeft: rect.width > width
|
|
44
|
+
? width - Math.floor(width / 2) - 5
|
|
45
|
+
: width - Math.floor(rect.width / 2) - 5,
|
|
46
|
+
left: rect.left - width + rect.width,
|
|
47
|
+
top: rect.top - height - 10
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
[RIGHT_START]: (width, height, rect) => {
|
|
51
|
+
return {
|
|
52
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
53
|
+
arrowLeft: -5,
|
|
54
|
+
left: rect.left + rect.width + 10,
|
|
55
|
+
top: rect.top
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
[RIGHT]: (width, height, rect) => {
|
|
59
|
+
return {
|
|
60
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
61
|
+
arrowLeft: -5,
|
|
62
|
+
left: rect.left + rect.width + 10,
|
|
63
|
+
top: rect.top + Math.floor(rect.height / 2) - Math.floor(height / 2)
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
[RIGHT_END]: (width, height, rect) => {
|
|
67
|
+
return {
|
|
68
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
69
|
+
arrowLeft: -5,
|
|
70
|
+
left: rect.left + rect.width + 10,
|
|
71
|
+
top: rect.top + rect.height - height
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
[BOTTOM_START]: (width, height, rect) => {
|
|
75
|
+
return {
|
|
76
|
+
arrowTop: -5,
|
|
77
|
+
arrowLeft: rect.width > width
|
|
78
|
+
? Math.floor(width / 2) - 5
|
|
79
|
+
: Math.floor(rect.width / 2) - 5,
|
|
80
|
+
left: rect.left,
|
|
81
|
+
top: rect.top + rect.height + height - 20
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
[BOTTOM]: (width, height, rect) => {
|
|
85
|
+
return {
|
|
86
|
+
arrowTop: -5,
|
|
87
|
+
arrowLeft: Math.floor(width / 2) - 5,
|
|
88
|
+
left: rect.left - Math.floor((width - rect.width) / 2),
|
|
89
|
+
top: rect.top + rect.height + height - 20
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
[BOTTOM_END]: (width, height, rect) => {
|
|
93
|
+
return {
|
|
94
|
+
arrowTop: -5,
|
|
95
|
+
arrowLeft: rect.width > width
|
|
96
|
+
? width - Math.floor(width / 2) - 5
|
|
97
|
+
: width - Math.floor(rect.width / 2) - 5,
|
|
98
|
+
left: rect.left - width + rect.width,
|
|
99
|
+
top: rect.top + rect.height + height - 20
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
[LEFT_START]: (width, height, rect) => {
|
|
103
|
+
return {
|
|
104
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
105
|
+
arrowLeft: width - 5,
|
|
106
|
+
left: rect.left - width - 10,
|
|
107
|
+
top: rect.top
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
[LEFT]: (width, height, rect) => {
|
|
111
|
+
return {
|
|
112
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
113
|
+
arrowLeft: width - 5,
|
|
114
|
+
left: rect.left - width - 10,
|
|
115
|
+
top: rect.top + Math.floor(rect.height / 2) - Math.floor(height / 2)
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
[LEFT_END]: (width, height, rect) => {
|
|
119
|
+
return {
|
|
120
|
+
arrowTop: Math.floor(height / 2) - 5,
|
|
121
|
+
arrowLeft: width - 5,
|
|
122
|
+
left: rect.left - width - 10,
|
|
123
|
+
top: rect.top + rect.height - height
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
selector: 'pg-tooltip',
|
|
130
|
+
style,
|
|
131
|
+
template
|
|
132
|
+
})
|
|
133
|
+
export default class PgTooltip extends HTMLElement {
|
|
134
|
+
@Prop() visible: boolean = false;
|
|
135
|
+
@Prop() rect: any = null;
|
|
136
|
+
@Prop() text: string = '';
|
|
137
|
+
@Prop() position: string = BOTTOM;
|
|
138
|
+
|
|
139
|
+
@Part() $tooltip: HTMLDivElement;
|
|
140
|
+
@Part() $tooltipText: HTMLSpanElement;
|
|
141
|
+
@Part() $tooltipArrow: HTMLDivElement;
|
|
142
|
+
|
|
143
|
+
render(changes) {
|
|
144
|
+
this.$tooltipText.innerText = this.text;
|
|
145
|
+
this.style.position = 'absolute';
|
|
146
|
+
if (changes.visible) {
|
|
147
|
+
this.style.display = this.visible ? 'block' : 'none';
|
|
148
|
+
}
|
|
149
|
+
const {
|
|
150
|
+
width: tooltipWidth,
|
|
151
|
+
height: tooltipHeight
|
|
152
|
+
} = this.$tooltipText.getBoundingClientRect();
|
|
153
|
+
let position = this.position;
|
|
154
|
+
if (!(position in map)) {
|
|
155
|
+
position = BOTTOM;
|
|
156
|
+
}
|
|
157
|
+
if (this.rect) {
|
|
158
|
+
const {
|
|
159
|
+
arrowLeft,
|
|
160
|
+
arrowTop,
|
|
161
|
+
left,
|
|
162
|
+
top
|
|
163
|
+
} = map[position](tooltipWidth, tooltipHeight, this.rect);
|
|
164
|
+
this.style.left = `${left + window.scrollX}px`;
|
|
165
|
+
this.style.top = `${top + window.scrollY}px`;
|
|
166
|
+
this.$tooltipArrow.style.left = `${arrowLeft}px`;
|
|
167
|
+
this.$tooltipArrow.style.top = `${arrowTop}px`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|