@policystudio/policy-studio-ui-vue 1.1.90-beta.5 → 1.1.90-beta.50
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/.eslintrc.js +2 -8
- package/.github/workflows/deploy-storybook.yml +4 -4
- package/.nvmrc +1 -0
- package/dist/css/psui_styles_output.css +6639 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/util/GeneralFunctions.d.ts +3 -0
- package/dist/util/GeneralFunctions.js +35 -0
- package/dist/util/GeneralFunctions.js.map +1 -0
- package/dist/util/directives.d.ts +1 -0
- package/dist/util/directives.js +22 -0
- package/dist/util/directives.js.map +1 -0
- package/dist/util/imageLoader.d.ts +6 -0
- package/dist/util/imageLoader.js +52 -0
- package/dist/util/imageLoader.js.map +1 -0
- package/doc/.nvmrc +1 -0
- package/{.storybook → doc/.storybook}/main.ts +8 -2
- package/{.storybook → doc/.storybook}/preview.ts +2 -3
- package/doc/package-lock.json +22653 -0
- package/doc/package.json +71 -0
- package/{src → doc}/shims-vue.d.ts +0 -5
- package/{src → doc/src}/stories/Accordion.stories.ts +2 -3
- package/{src → doc/src}/stories/BadgeWithIcon.stories.ts +1 -1
- package/{src → doc/src}/stories/BarChart.stories.ts +1 -1
- package/{src → doc/src}/stories/Breadcrumb.stories.ts +1 -1
- package/doc/src/stories/Button.stories.ts +130 -0
- package/{src → doc/src}/stories/CardInfos.stories.ts +1 -1
- package/{src → doc/src}/stories/ChartLegend.stories.ts +1 -1
- package/{src → doc/src}/stories/Checkbox.stories.ts +1 -1
- package/{src → doc/src}/stories/CheckboxSimple.stories.ts +1 -1
- package/{src → doc/src}/stories/Chips.stories.ts +1 -4
- package/{src → doc/src}/stories/ClimateZoneBadge.stories.ts +2 -1
- package/doc/src/stories/Collapse.stories.ts +46 -0
- package/{src → doc/src}/stories/CostEffectBar.stories.ts +2 -1
- package/{src → doc/src}/stories/Datatable.stories.ts +5 -2
- package/{src → doc/src}/stories/DateCardInfo.stories.ts +1 -1
- package/{src → doc/src}/stories/Dialog.stories.ts +2 -2
- package/{src → doc/src}/stories/Draggable.stories.ts +3 -2
- package/{src → doc/src}/stories/Dropdown.stories.ts +4 -3
- package/{src → doc/src}/stories/DropdownList.stories.ts +4 -2
- package/{src → doc/src}/stories/HighlightRippleDot.stories.ts +3 -2
- package/{src → doc/src}/stories/Icon.stories.ts +3 -1
- package/{src → doc/src}/stories/InlineSelector.stories.ts +1 -1
- package/{src → doc/src}/stories/Input.stories.ts +7 -4
- package/{src → doc/src}/stories/InputSelect.stories.ts +3 -2
- package/{src → doc/src}/stories/InputTextArea.stories.ts +1 -1
- package/{src → doc/src}/stories/MiniTag.stories.ts +9 -2
- package/{src → doc/src}/stories/ProgressBar.stories.ts +3 -2
- package/{src → doc/src}/stories/RadioButton.stories.ts +2 -2
- package/{src → doc/src}/stories/RadioButtonSimple.stories.ts +1 -1
- package/{src → doc/src}/stories/SimpleAlert.stories.ts +3 -2
- package/{src → doc/src}/stories/Slider.stories.ts +6 -2
- package/{src → doc/src}/stories/Switch.stories.ts +2 -2
- package/{src → doc/src}/stories/TabHeader.stories.ts +6 -1
- package/{src → doc/src}/stories/TableResults.stories.ts +11 -7
- package/{src → doc/src}/stories/TagScope.stories.ts +3 -2
- package/{src → doc/src}/stories/TestimonialCard.stories.ts +3 -3
- package/{src → doc/src}/stories/Toast.stories.ts +2 -2
- package/{src → doc/src}/stories/Toggle.stories.ts +6 -3
- package/{src → doc/src}/stories/Tooltip.stories.ts +3 -3
- package/doc/tsconfig.json +17 -0
- package/package.json +13 -28
- package/scripts/gulp.js +11 -0
- package/src/assets/scss/base.scss +3 -34
- package/src/assets/scss/components/PsAccordion.scss +1 -1
- package/src/assets/scss/components/PsChips.scss +9 -3
- package/src/assets/scss/components/PsCollapse.scss +71 -0
- package/src/assets/scss/components/PsDataTable.scss +1 -1
- package/src/assets/scss/components/PsDropdownList.scss +1 -1
- package/src/assets/scss/components/PsTableResults.scss +28 -1
- package/src/assets/scss/components/PsTooltip.scss +2 -1
- package/src/components/accordion/PsAccordionItem.vue +88 -74
- package/src/components/badges-and-tags/PsBadgeWithIcon.vue +31 -34
- package/src/components/badges-and-tags/PsCardInfos.vue +39 -41
- package/src/components/badges-and-tags/PsChartLegend.vue +46 -51
- package/src/components/badges-and-tags/PsClimateZoneBadge.vue +13 -19
- package/src/components/badges-and-tags/PsCostEffectBar.vue +24 -56
- package/src/components/badges-and-tags/PsDateCardInfo.vue +17 -18
- package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -2
- package/src/components/badges-and-tags/PsMiniTag.vue +39 -41
- package/src/components/badges-and-tags/PsProgressBar.vue +72 -68
- package/src/components/badges-and-tags/PsTagScope.vue +17 -22
- package/src/components/badges-and-tags/PsTestimonialCard.vue +19 -26
- package/src/components/buttons/PsButton.vue +61 -62
- package/src/components/chips/PsChips.vue +112 -101
- package/src/components/collapse/PsCollapse.vue +124 -0
- package/src/components/controls/PsCheckbox.vue +84 -84
- package/src/components/controls/PsCheckboxSimple.vue +95 -95
- package/src/components/controls/PsDraggable.vue +53 -55
- package/src/components/controls/PsInlineSelector.vue +98 -99
- package/src/components/controls/PsRadioButton.vue +65 -58
- package/src/components/controls/PsRadioButtonSimple.vue +79 -75
- package/src/components/controls/PsSlider.vue +185 -176
- package/src/components/controls/PsSwitch.vue +51 -52
- package/src/components/controls/PsToggle.vue +52 -50
- package/src/components/data-graphics/PsBarChart.vue +18 -21
- package/src/components/datatable/PsDataTable.vue +56 -60
- package/src/components/datatable/PsDataTableItem.vue +13 -28
- package/src/components/forms/PsDropdown.vue +166 -162
- package/src/components/forms/PsDropdownList.vue +133 -130
- package/src/components/forms/PsInput.vue +154 -153
- package/src/components/forms/PsInputSelect.vue +91 -92
- package/src/components/forms/PsInputTextArea.vue +70 -71
- package/src/components/navigations/PsBreadcrumb.vue +25 -34
- package/src/components/notifications/PsDialog.vue +57 -56
- package/src/components/notifications/PsSimpleAlert.vue +27 -29
- package/src/components/notifications/PsToast.vue +40 -39
- package/src/components/table-results/PsTableResults.vue +461 -468
- package/src/components/table-results/PsTableResultsBody.vue +66 -67
- package/src/components/table-results/PsTableResultsHead.vue +70 -67
- package/src/components/table-results/PsTableResultsHeadComparison.vue +67 -64
- package/src/components/table-results/PsTableResultsHeadFlexible.vue +94 -67
- package/src/components/table-results/PsTableResultsRow.vue +55 -56
- package/src/components/tabs/PsTabHeader.vue +106 -100
- package/src/components/tooltip/PsDialogTooltip.vue +96 -101
- package/src/components/tooltip/PsRichTooltip.vue +41 -45
- package/src/components/tooltip/PsTooltip.vue +111 -116
- package/src/components/ui/PsDotLoader.vue +1 -5
- package/src/components/ui/PsIcon.vue +143 -132
- package/src/index.ts +60 -67
- package/src/tsconfig.json +12 -0
- package/src/types/index.d.ts +6 -0
- package/src/util/{GeneralFunctions.ts → GeneralFunctions.js} +12 -3
- package/src/util/directives.ts +24 -0
- package/src/util/{imageLoader.ts → imageLoader.js} +7 -0
- package/tailwind.config.js +1 -1
- package/tsconfig.json +18 -13
- package/.storybook/eventBus.ts +0 -26
- package/babel.config.js +0 -17
- package/dist/css/psui_styles.css +0 -4647
- package/postcss.config.js +0 -8
- package/src/components/playground/PsScrollBar.vue +0 -320
- package/src/stories/Button.stories.ts +0 -48
- package/src/stories/Button.vue +0 -59
- package/src/stories/Header.stories.ts +0 -41
- package/src/stories/Header.vue +0 -77
- package/src/stories/Playground.stories.ts +0 -16
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/webpack.config.js +0 -22
- /package/{.storybook → doc/.storybook}/PolicyStudio.ts +0 -0
- /package/{.storybook → doc/.storybook}/manager.ts +0 -0
- /package/{src → doc/src}/assets/images/multifamily-units.svg +0 -0
- /package/{src → doc/src}/assets/images/policy-studio.svg +0 -0
- /package/{src → doc/src}/contents/ComparisonData.ts +0 -0
- /package/{src → doc/src}/contents/FlexibleData.ts +0 -0
- /package/{src → doc/src}/contents/ResultsData.ts +0 -0
- /package/{src → doc/src}/stories/Colors.mdx +0 -0
- /package/{src → doc/src}/stories/ElevationSystem.mdx +0 -0
- /package/{src → doc/src}/stories/Introduction.mdx +0 -0
- /package/{src → doc/src}/stories/Typography.mdx +0 -0
- /package/{src → doc/src}/stories/assets/code-brackets.svg +0 -0
- /package/{src → doc/src}/stories/assets/colors.svg +0 -0
- /package/{src → doc/src}/stories/assets/comments.svg +0 -0
- /package/{src → doc/src}/stories/assets/direction.svg +0 -0
- /package/{src → doc/src}/stories/assets/flow.svg +0 -0
- /package/{src → doc/src}/stories/assets/plugin.svg +0 -0
- /package/{src → doc/src}/stories/assets/repo.svg +0 -0
- /package/{src → doc/src}/stories/assets/stackalt.svg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
@mouseenter="open"
|
|
4
|
-
v-click-outside="close"
|
|
4
|
+
v-click-outside="close()"
|
|
5
5
|
ref="tooltip"
|
|
6
6
|
class="psui-el-tooltip"
|
|
7
7
|
>
|
|
@@ -42,118 +42,113 @@
|
|
|
42
42
|
</div>
|
|
43
43
|
</template>
|
|
44
44
|
|
|
45
|
-
<script>
|
|
45
|
+
<script setup>
|
|
46
|
+
import { computed, ref, onMounted, onBeforeUnmount } from 'vue'
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
type: String,
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* It sets the label of the button within the tooltip if needed.
|
|
58
|
-
*/
|
|
59
|
-
buttonText: {
|
|
60
|
-
type: String,
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* It sets the layout of the tooltip. eg: white, dark and color.
|
|
64
|
-
*/
|
|
65
|
-
layout: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: 'white',
|
|
68
|
-
validator: (value) => ['white', 'dark', 'color'].includes(value),
|
|
69
|
-
},
|
|
70
|
-
/**
|
|
71
|
-
* It sets a additional styling if needed.
|
|
72
|
-
*/
|
|
73
|
-
cssClass: {
|
|
74
|
-
type: String,
|
|
75
|
-
required: false,
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* It sets the vertical position.
|
|
79
|
-
*/
|
|
80
|
-
position:{
|
|
81
|
-
type: String,
|
|
82
|
-
default: 'bottom',
|
|
83
|
-
validator: (value)=> ['bottom','top'].includes(value)
|
|
84
|
-
}
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
/**
|
|
50
|
+
* It sets the title of the tooltip if needed.
|
|
51
|
+
*/
|
|
52
|
+
title: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '',
|
|
85
55
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
56
|
+
/**
|
|
57
|
+
* It sets the label of the button within the tooltip if needed.
|
|
58
|
+
*/
|
|
59
|
+
buttonText: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: '',
|
|
93
62
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
/**
|
|
64
|
+
* It sets the layout of the tooltip. eg: white, dark and color.
|
|
65
|
+
*/
|
|
66
|
+
layout: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'white',
|
|
69
|
+
validator: (value) => ['white', 'dark', 'color'].includes(value),
|
|
98
70
|
},
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
/**
|
|
72
|
+
* It sets a additional styling if needed.
|
|
73
|
+
*/
|
|
74
|
+
cssClass: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: '',
|
|
77
|
+
required: false,
|
|
101
78
|
},
|
|
102
|
-
|
|
103
|
-
|
|
79
|
+
/**
|
|
80
|
+
* It sets the vertical position.
|
|
81
|
+
*/
|
|
82
|
+
position: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: 'bottom',
|
|
85
|
+
validator: (value) => ['bottom', 'top'].includes(value),
|
|
104
86
|
},
|
|
105
|
-
|
|
106
|
-
open() {
|
|
107
|
-
if (this.show || this.ignoreDialog) return
|
|
108
|
-
this.$emit('show')
|
|
109
|
-
this.show = true
|
|
87
|
+
})
|
|
110
88
|
|
|
111
|
-
|
|
112
|
-
this.$refs.dialog.style.opacity = 0
|
|
89
|
+
const emit = defineEmits(['show', 'click', 'close'])
|
|
113
90
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
close() {
|
|
119
|
-
if (this.show && this.$refs.dialog) {
|
|
120
|
-
this.$emit('close')
|
|
121
|
-
this.show = false
|
|
91
|
+
const show = ref(false)
|
|
92
|
+
// const closingTimeout = ref(null)
|
|
93
|
+
const dialog = ref(null)
|
|
94
|
+
const tooltiptrigger = ref(null)
|
|
122
95
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
updatePosition() {
|
|
127
|
-
const dialog = this.$refs.dialog
|
|
128
|
-
const trigger = this.$refs.tooltiptrigger
|
|
96
|
+
const getComponentClass = computed(() => {
|
|
97
|
+
return `layout-${props.layout}`
|
|
98
|
+
})
|
|
129
99
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
dialog.style.top = `${rectTrigger.y + rectTrigger.height + 8}px`
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
document.addEventListener('resize', updatePosition)
|
|
102
|
+
})
|
|
134
103
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
dialog.style.left = `${rectTrigger.x + 10}px`
|
|
139
|
-
} else if (rectDialog.width >= rectTrigger.width){
|
|
140
|
-
dialog.style.left = `${rectTrigger.x - ((rectDialog.width - rectTrigger.width)/2)}px`
|
|
141
|
-
} else {
|
|
142
|
-
dialog.style.left = `${rectTrigger.x + ((rectTrigger.width - rectDialog.width)/2)}px`
|
|
143
|
-
}
|
|
104
|
+
onBeforeUnmount(() => {
|
|
105
|
+
document.removeEventListener('resize', updatePosition)
|
|
106
|
+
})
|
|
144
107
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
const open = () => {
|
|
109
|
+
if (show.value || props.ignoreDialog) return
|
|
110
|
+
emit('show')
|
|
111
|
+
show.value = true
|
|
112
|
+
dialog.value.style.display = 'block'
|
|
113
|
+
dialog.value.style.opacity = 0
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
updatePosition()
|
|
116
|
+
}, 10)
|
|
117
|
+
}
|
|
148
118
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
},
|
|
119
|
+
const close = () => {
|
|
120
|
+
if (show.value && dialog.value) {
|
|
121
|
+
emit('close')
|
|
122
|
+
show.value = false
|
|
123
|
+
dialog.value.style.display = 'none'
|
|
124
|
+
}
|
|
157
125
|
}
|
|
158
|
-
</script>
|
|
159
126
|
|
|
127
|
+
const updatePosition = () => {
|
|
128
|
+
const dialogPosition = dialog.value
|
|
129
|
+
const trigger = tooltiptrigger.value
|
|
130
|
+
const rectDialog = dialogPosition.getBoundingClientRect()
|
|
131
|
+
const rectTrigger = trigger.getBoundingClientRect()
|
|
132
|
+
const windowWidth = document.documentElement.clientWidth
|
|
133
|
+
dialogPosition.style.top = `${rectTrigger.y + rectTrigger.height + 8}px`
|
|
134
|
+
if (rectTrigger.x + rectDialog.width + 20 > windowWidth) {
|
|
135
|
+
dialogPosition.style.left = `${windowWidth - rectDialog.width - 30}px`
|
|
136
|
+
} else if (rectTrigger.x - Math.abs(rectTrigger.width - rectDialog.width) < 0) {
|
|
137
|
+
dialogPosition.style.left = `${rectTrigger.x + 10}px`
|
|
138
|
+
} else if (rectDialog.width >= rectTrigger.width) {
|
|
139
|
+
dialogPosition.style.left = `${rectTrigger.x - (rectDialog.width - rectTrigger.width) / 2}px`
|
|
140
|
+
} else {
|
|
141
|
+
dialogPosition.style.left = `${rectTrigger.x + (rectTrigger.width - rectDialog.width) / 2}px`
|
|
142
|
+
}
|
|
143
|
+
if (props.position == 'top') {
|
|
144
|
+
dialogPosition.style.top = `${rectTrigger.y - rectTrigger.height - 10}px`
|
|
145
|
+
}
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
dialogPosition.style.opacity = 100
|
|
148
|
+
}, 100)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const onClick = ($event) => {
|
|
152
|
+
emit('click', $event)
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<PsTooltip
|
|
3
|
-
:layout="layout"
|
|
4
|
-
:title="title"
|
|
5
|
-
:css-class="cssClass"
|
|
6
|
-
:position="position"
|
|
7
|
-
:ignore-dialog="ignoreDialog"
|
|
8
|
-
:custom-position="customPosition"
|
|
2
|
+
<PsTooltip
|
|
3
|
+
:layout="layout"
|
|
4
|
+
:title="title"
|
|
5
|
+
:css-class="cssClass"
|
|
6
|
+
:position="position"
|
|
7
|
+
:ignore-dialog="ignoreDialog"
|
|
8
|
+
:custom-position="customPosition"
|
|
9
9
|
>
|
|
10
10
|
<template #trigger>
|
|
11
11
|
<slot name="trigger" />
|
|
@@ -16,45 +16,41 @@
|
|
|
16
16
|
</PsTooltip>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script>
|
|
19
|
+
<script setup>
|
|
20
20
|
import PsTooltip from '../tooltip/PsTooltip.vue'
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
title: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: '',
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* It sets the layout of the tooltip. eg: gray, red and blue.
|
|
35
|
-
*/
|
|
36
|
-
layout: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: 'gray',
|
|
39
|
-
validator: (type) => ['gray', 'red', 'blue'].includes(type),
|
|
40
|
-
},
|
|
41
|
-
cssClass: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: '',
|
|
44
|
-
},
|
|
45
|
-
position: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: 'bottom',
|
|
48
|
-
validator: (value)=> ['bottom', 'top', 'custom'].includes(value)
|
|
49
|
-
},
|
|
50
|
-
ignoreDialog: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
customPosition: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: '',
|
|
57
|
-
}
|
|
22
|
+
defineProps({
|
|
23
|
+
/**
|
|
24
|
+
* It sets the title of the tooltip if needed.
|
|
25
|
+
*/
|
|
26
|
+
title: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '',
|
|
58
29
|
},
|
|
59
|
-
|
|
30
|
+
/**
|
|
31
|
+
* It sets the layout of the tooltip. eg: gray, red and blue.
|
|
32
|
+
*/
|
|
33
|
+
layout: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'gray',
|
|
36
|
+
validator: (type) => ['gray', 'red', 'blue'].includes(type),
|
|
37
|
+
},
|
|
38
|
+
cssClass: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: '',
|
|
41
|
+
},
|
|
42
|
+
position: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: 'bottom',
|
|
45
|
+
validator: (value) => ['bottom', 'top', 'custom'].includes(value),
|
|
46
|
+
},
|
|
47
|
+
ignoreDialog: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
customPosition: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: '',
|
|
54
|
+
},
|
|
55
|
+
})
|
|
60
56
|
</script>
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="
|
|
2
|
+
<div
|
|
3
|
+
ref="PsTooltip"
|
|
4
4
|
class="psui-el-tooltip"
|
|
5
|
-
@mouseenter="open"
|
|
6
|
-
@mouseleave="close"
|
|
5
|
+
@mouseenter="open"
|
|
6
|
+
@mouseleave="close"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
ref="
|
|
9
|
+
ref="PsTooltipTrigger"
|
|
10
10
|
class="psui-el-tooltip-trigger"
|
|
11
11
|
>
|
|
12
12
|
<slot name="trigger" />
|
|
13
13
|
</div>
|
|
14
14
|
|
|
15
|
-
<div
|
|
16
|
-
class="psui-el-tooltip-wrapper"
|
|
17
|
-
>
|
|
15
|
+
<div class="psui-el-tooltip-wrapper">
|
|
18
16
|
<div
|
|
19
17
|
role="menu"
|
|
20
|
-
ref="
|
|
18
|
+
ref="PsTooltipDialog"
|
|
21
19
|
class="psui-el-tooltip-dialog"
|
|
22
20
|
:class="cssClass"
|
|
23
21
|
>
|
|
@@ -41,125 +39,122 @@
|
|
|
41
39
|
</div>
|
|
42
40
|
</template>
|
|
43
41
|
|
|
44
|
-
<script>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* It disables the dialog section.
|
|
56
|
-
*/
|
|
57
|
-
ignoreDialog: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: false,
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* It sets the layout of the tooltip if needed. Usefull when using rich or dialog tooltip.
|
|
63
|
-
*/
|
|
64
|
-
layout: {
|
|
65
|
-
type: String,
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* It sets a additional styling if needed.
|
|
69
|
-
*/
|
|
70
|
-
cssClass: {
|
|
71
|
-
type: String,
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* It sets the vertical position.
|
|
75
|
-
*/
|
|
76
|
-
position: {
|
|
77
|
-
type: String,
|
|
78
|
-
default: 'bottom',
|
|
79
|
-
validator: (value)=> ['bottom','top', 'custom'].includes(value)
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* It sets the custom positions.
|
|
83
|
-
*/
|
|
84
|
-
customPosition: {
|
|
85
|
-
type: String,
|
|
86
|
-
default: '',
|
|
87
|
-
}
|
|
42
|
+
<script setup>
|
|
43
|
+
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
|
44
|
+
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
/**
|
|
47
|
+
* It sets the title of the tooltip if needed.
|
|
48
|
+
*/
|
|
49
|
+
title: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '',
|
|
88
52
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
53
|
+
/**
|
|
54
|
+
* It disables the dialog section.
|
|
55
|
+
*/
|
|
56
|
+
ignoreDialog: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
96
59
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
60
|
+
/**
|
|
61
|
+
* It sets the layout of the tooltip if needed. Usefull when using rich or dialog tooltip.
|
|
62
|
+
*/
|
|
63
|
+
layout: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: '',
|
|
101
66
|
},
|
|
102
|
-
|
|
103
|
-
|
|
67
|
+
/**
|
|
68
|
+
* It sets a additional styling if needed.
|
|
69
|
+
*/
|
|
70
|
+
cssClass: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: '',
|
|
104
73
|
},
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
/**
|
|
75
|
+
* It sets the vertical position.
|
|
76
|
+
*/
|
|
77
|
+
position: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'bottom',
|
|
80
|
+
validator: (value) => ['bottom', 'top', 'custom'].includes(value),
|
|
107
81
|
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
82
|
+
/**
|
|
83
|
+
* It sets the custom positions.
|
|
84
|
+
*/
|
|
85
|
+
customPosition: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: '',
|
|
88
|
+
},
|
|
89
|
+
})
|
|
116
90
|
|
|
117
|
-
|
|
118
|
-
this.updatePosition()
|
|
119
|
-
}, 10)
|
|
120
|
-
},
|
|
121
|
-
close() {
|
|
122
|
-
if (this.show && this.$refs.dialog) {
|
|
123
|
-
this.$emit('close')
|
|
124
|
-
this.show = false
|
|
91
|
+
const emit = defineEmits(['show', 'close'])
|
|
125
92
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const trigger = this.$refs.tooltiptrigger
|
|
93
|
+
const show = ref(false)
|
|
94
|
+
// const closingTimeout = ref(null)
|
|
95
|
+
const PsTooltip = ref(null)
|
|
96
|
+
const PsTooltipTrigger = ref(null)
|
|
97
|
+
const PsTooltipDialog = ref(null)
|
|
132
98
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
99
|
+
const getComponentClass = computed(() => {
|
|
100
|
+
return `layout-${props.layout}`
|
|
101
|
+
})
|
|
136
102
|
|
|
137
|
-
|
|
103
|
+
onMounted(() => {
|
|
104
|
+
document.addEventListener('resize', updatePosition)
|
|
105
|
+
})
|
|
138
106
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
dialog.style.left = `${rectTrigger.x + 10}px`
|
|
143
|
-
} else if (rectDialog.width >= rectTrigger.width && this.position != 'custom') {
|
|
144
|
-
dialog.style.left = `${rectTrigger.x - ((rectDialog.width - rectTrigger.width)/2)}px`
|
|
145
|
-
} else {
|
|
146
|
-
dialog.style.left = `${rectTrigger.x + ((rectTrigger.width - rectDialog.width)/2)}px`
|
|
147
|
-
}
|
|
107
|
+
onBeforeUnmount(() => {
|
|
108
|
+
document.removeEventListener('resize', updatePosition)
|
|
109
|
+
})
|
|
148
110
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
111
|
+
const open = () => {
|
|
112
|
+
if (show.value || props.ignoreDialog) return
|
|
113
|
+
emit('show')
|
|
114
|
+
show.value = true
|
|
115
|
+
const dialog = PsTooltipDialog.value
|
|
116
|
+
dialog.style.display = 'block'
|
|
117
|
+
dialog.style.opacity = 0
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
updatePosition()
|
|
120
|
+
}, 10)
|
|
121
|
+
}
|
|
152
122
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
123
|
+
const close = () => {
|
|
124
|
+
const dialog = PsTooltipDialog.value
|
|
125
|
+
if (show.value && dialog) {
|
|
126
|
+
emit('close')
|
|
127
|
+
show.value = false
|
|
128
|
+
dialog.style.display = 'none'
|
|
129
|
+
}
|
|
130
|
+
}
|
|
158
131
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
const updatePosition = () => {
|
|
133
|
+
const dialog = PsTooltipDialog.value
|
|
134
|
+
const trigger = PsTooltipTrigger.value
|
|
135
|
+
const rectDialog = dialog?.getBoundingClientRect()
|
|
136
|
+
const rectTrigger = trigger?.getBoundingClientRect()
|
|
137
|
+
const windowWidth = document.documentElement.clientWidth
|
|
138
|
+
if(dialog) dialog.style.top = `${rectTrigger.y + rectTrigger.height + 8}px`
|
|
139
|
+
if (rectTrigger && rectTrigger.x + rectDialog.width + 20 > windowWidth) {
|
|
140
|
+
dialog.style.left = `${windowWidth - rectDialog.width - 30}px`
|
|
141
|
+
} else if (rectTrigger && rectTrigger.x - rectDialog.width < 0) {
|
|
142
|
+
dialog.style.left = `${rectTrigger.x + 10}px`
|
|
143
|
+
} else if (rectTrigger && rectDialog.width >= rectTrigger.width && props.position != 'custom') {
|
|
144
|
+
dialog.style.left = `${rectTrigger.x - (rectDialog.width - rectTrigger.width) / 2}px`
|
|
145
|
+
} else if(dialog) {
|
|
146
|
+
dialog.style.left = `${rectTrigger.x + (rectTrigger.width - rectDialog.width) / 2}px`
|
|
147
|
+
}
|
|
148
|
+
if (props.position == 'top') {
|
|
149
|
+
dialog.style.top = `${rectTrigger.y - rectDialog.height - 10}px`
|
|
150
|
+
}
|
|
151
|
+
if (props.position == 'custom') {
|
|
152
|
+
dialog.style = props.customPosition
|
|
153
|
+
dialog.style.display = 'block'
|
|
154
|
+
dialog.style.position = 'absolute'
|
|
155
|
+
}
|
|
156
|
+
setTimeout(() => {
|
|
157
|
+
if(dialog) dialog.style.opacity = 100
|
|
158
|
+
}, 100)
|
|
164
159
|
}
|
|
165
160
|
</script>
|