@policystudio/policy-studio-ui-vue 1.1.90-beta.3 → 1.1.90-beta.30
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 +13 -8
- package/.github/workflows/deploy-storybook.yml +4 -4
- package/.nvmrc +1 -0
- package/dist/css/psui_styles_output.css +6994 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +104 -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/package.json +24 -37
- package/src/App.vue +30 -0
- package/src/assets/scss/components/PsDataTable.scss +1 -1
- package/src/assets/scss/components/PsDropdownList.scss +1 -1
- package/src/components/accordion/PsAccordionItem.vue +88 -74
- package/src/components/badges-and-tags/PsBadgeWithIcon.vue +31 -33
- 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 +60 -61
- package/src/components/chips/PsChips.vue +98 -101
- 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 +59 -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 +165 -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 +456 -466
- package/src/components/table-results/PsTableResultsBody.vue +66 -67
- package/src/components/table-results/PsTableResultsHead.vue +67 -61
- package/src/components/table-results/PsTableResultsHeadComparison.vue +62 -56
- package/src/components/table-results/PsTableResultsHeadFlexible.vue +68 -61
- 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 +131 -129
- package/src/index.ts +156 -0
- package/src/tsconfig.json +12 -0
- package/src/types/index.d.ts +6 -0
- package/src/util/GeneralFunctions.js +16 -7
- package/src/util/directives.ts +24 -0
- package/src/util/imageLoader.js +14 -7
- package/tailwind.config.js +1 -1
- package/tsconfig.json +47 -0
- package/.storybook/PolicyStudio.js +0 -10
- package/.storybook/eventBus.js +0 -26
- package/.storybook/main.js +0 -21
- package/.storybook/manager.js +0 -6
- package/.storybook/preview.js +0 -17
- package/babel.config.js +0 -17
- package/dist/css/psui_styles.css +0 -4647
- package/postcss.config.js +0 -8
- package/src/assets/images/multifamily-units.svg +0 -10
- package/src/assets/images/policy-studio.svg +0 -15
- package/src/components/playground/PsScrollBar.vue +0 -320
- package/src/contents/ComparisonData.js +0 -378
- package/src/contents/FlexibleData.js +0 -502
- package/src/contents/ResultsData.js +0 -531
- package/src/index.js +0 -166
- package/src/stories/Accordion.stories.js +0 -59
- package/src/stories/BadgeWithIcon.stories.js +0 -31
- package/src/stories/BarChart.stories.js +0 -17
- package/src/stories/Breadcrumb.stories.js +0 -25
- package/src/stories/Button.stories.js +0 -48
- package/src/stories/Button.vue +0 -59
- package/src/stories/CardInfos.stories.js +0 -16
- package/src/stories/ChartLegend.stories.js +0 -16
- package/src/stories/Checkbox.stories.js +0 -45
- package/src/stories/CheckboxSimple.stories.js +0 -49
- package/src/stories/Chips.stories.js +0 -31
- package/src/stories/ClimateZoneBadge.stories.js +0 -17
- package/src/stories/Colors.mdx +0 -70
- package/src/stories/CostEffectBar.stories.js +0 -23
- package/src/stories/Datatable.stories.js +0 -50
- package/src/stories/DateCardInfo.stories.js +0 -24
- package/src/stories/Dialog.stories.js +0 -131
- package/src/stories/Draggable.stories.js +0 -22
- package/src/stories/Dropdown.stories.js +0 -99
- package/src/stories/DropdownList.stories.js +0 -211
- package/src/stories/ElevationSystem.mdx +0 -41
- package/src/stories/Header.stories.js +0 -41
- package/src/stories/Header.vue +0 -77
- package/src/stories/HighlightRippleDot.stories.js +0 -15
- package/src/stories/Icon.stories.js +0 -21
- package/src/stories/InlineSelector.stories.js +0 -18
- package/src/stories/Input.stories.js +0 -240
- package/src/stories/InputSelect.stories.js +0 -30
- package/src/stories/InputTextArea.stories.js +0 -25
- package/src/stories/Introduction.mdx +0 -211
- package/src/stories/MiniTag.stories.js +0 -52
- package/src/stories/Playground.stories.js +0 -16
- package/src/stories/ProgressBar.stories.js +0 -23
- package/src/stories/RadioButton.stories.js +0 -40
- package/src/stories/RadioButtonSimple.stories.js +0 -43
- package/src/stories/SimpleAlert.stories.js +0 -21
- package/src/stories/Slider.stories.js +0 -75
- package/src/stories/Switch.stories.js +0 -39
- package/src/stories/TabHeader.stories.js +0 -52
- package/src/stories/TableResults.stories.js +0 -724
- package/src/stories/TagScope.stories.js +0 -17
- package/src/stories/TestimonialCard.stories.js +0 -27
- package/src/stories/Toast.stories.js +0 -52
- package/src/stories/Toggle.stories.js +0 -45
- package/src/stories/Tooltip.stories.js +0 -114
- package/src/stories/Typography.mdx +0 -212
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/webpack.config.js +0 -22
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
</p>
|
|
11
11
|
</td>
|
|
12
12
|
|
|
13
|
-
<template
|
|
14
|
-
v-for="(columnGroup, indexColumn) of columnGroups"
|
|
15
|
-
>
|
|
13
|
+
<template v-for="(columnGroup, indexColumn) of columnGroups">
|
|
16
14
|
<td
|
|
17
15
|
v-for="column of columnGroup.columns"
|
|
18
16
|
:key="indexColumn + '-' + columnGroup.key + '-' + column.key"
|
|
@@ -26,64 +24,65 @@
|
|
|
26
24
|
</tbody>
|
|
27
25
|
</template>
|
|
28
26
|
|
|
29
|
-
<script>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* It sets the values which will be use to render the body.
|
|
44
|
-
*/
|
|
45
|
-
columnGroups: {
|
|
46
|
-
type: Array,
|
|
47
|
-
default() {
|
|
48
|
-
return []
|
|
49
|
-
}
|
|
27
|
+
<script setup>
|
|
28
|
+
import { computed } from 'vue'
|
|
29
|
+
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
/**
|
|
32
|
+
* It sets the values which will be use to render the body.
|
|
33
|
+
*/
|
|
34
|
+
summaryData: {
|
|
35
|
+
type: Array,
|
|
36
|
+
default() {
|
|
37
|
+
return []
|
|
50
38
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* It sets the values which will be use to render the body.
|
|
42
|
+
*/
|
|
43
|
+
columnGroups: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default() {
|
|
46
|
+
return []
|
|
59
47
|
},
|
|
60
48
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
49
|
+
/**
|
|
50
|
+
* It sets the values which will be use to render the body.
|
|
51
|
+
*/
|
|
52
|
+
rows: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default() {
|
|
55
|
+
return []
|
|
56
|
+
},
|
|
70
57
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const addRow = (item, deep = 0, index, rows) => {
|
|
61
|
+
item.deep = deep
|
|
62
|
+
item.index = index
|
|
63
|
+
rows.push(item)
|
|
64
|
+
item.last_deep = item.items ? false : true
|
|
65
|
+
if (item.items) {
|
|
66
|
+
const items_child = [...item.items]
|
|
67
|
+
for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
|
|
68
|
+
const item_child = items_child[indexChild]
|
|
69
|
+
item_child.is_last = indexChild + 1 === items_child.length ? true : false
|
|
70
|
+
addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
|
|
85
71
|
}
|
|
86
72
|
}
|
|
87
73
|
}
|
|
74
|
+
|
|
75
|
+
const getRows = computed(() => {
|
|
76
|
+
const rows = []
|
|
77
|
+
for (let index = 0; index < props.summaryData.length; index++) {
|
|
78
|
+
const item = props.summaryData[index]
|
|
79
|
+
addRow(item, 0, `${index}`, rows)
|
|
80
|
+
}
|
|
81
|
+
return rows
|
|
82
|
+
})
|
|
83
|
+
|
|
88
84
|
</script>
|
|
89
|
-
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
/* Please, use the file src/assets/scss/components/PsTableResults.scss */
|
|
88
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="psui-el-tab-header"
|
|
4
|
-
:class="[getComponentClass, `layout-${layout}`]"
|
|
2
|
+
<div
|
|
3
|
+
class="psui-el-tab-header"
|
|
4
|
+
:class="[getComponentClass, `layout-${layout}`]"
|
|
5
5
|
role="group"
|
|
6
6
|
>
|
|
7
7
|
<template v-for="(item, index) in getItems">
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
:key="item[keyValue] + index"
|
|
17
17
|
type="button"
|
|
18
18
|
@click="selectTab(item)"
|
|
19
|
-
:class="getButtonClass(item)"
|
|
19
|
+
:class="getButtonClass(item).value"
|
|
20
20
|
>
|
|
21
|
-
<span>{{ item[keyLabel] }}</span>
|
|
21
|
+
<span>{{ item[keyLabel] }}</span>
|
|
22
22
|
</button>
|
|
23
23
|
</template>
|
|
24
24
|
</PsRichTooltip>
|
|
@@ -27,114 +27,120 @@
|
|
|
27
27
|
:key="item[keyValue] + index"
|
|
28
28
|
type="button"
|
|
29
29
|
@click="selectTab(item)"
|
|
30
|
-
:class="getButtonClass(item)"
|
|
30
|
+
:class="getButtonClass(item).value"
|
|
31
31
|
>
|
|
32
|
-
<span>{{ item[keyLabel] }}</span>
|
|
32
|
+
<span>{{ item[keyLabel] }}</span>
|
|
33
33
|
</button>
|
|
34
34
|
</slot>
|
|
35
35
|
</template>
|
|
36
36
|
</div>
|
|
37
37
|
</template>
|
|
38
38
|
|
|
39
|
-
<script>
|
|
39
|
+
<script setup>
|
|
40
40
|
import PsRichTooltip from '../tooltip/PsRichTooltip.vue'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
validator: (value) => ['standard', 'underline', 'folder'].includes(value)
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* It sets the tabs which will be rendered.
|
|
55
|
-
*/
|
|
56
|
-
items: {
|
|
57
|
-
type: Array,
|
|
58
|
-
required: true
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* It sets the key label of the items if needed.
|
|
62
|
-
*/
|
|
63
|
-
keyLabel: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: 'label'
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* It sets the key value of the items if needed.
|
|
69
|
-
*/
|
|
70
|
-
keyValue: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: 'value'
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* It disabled the tab header. All mouse events are disabled.
|
|
76
|
-
*/
|
|
77
|
-
disabled: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: false
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* It sets the tab seleced.
|
|
83
|
-
*/
|
|
84
|
-
selected: {},
|
|
41
|
+
import { computed } from 'vue'
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
/**
|
|
45
|
+
* It sets the layout of the tabheader. eg: standard, underline and folder.
|
|
46
|
+
*/
|
|
47
|
+
layout: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'standard',
|
|
50
|
+
validator: (value) => ['standard', 'underline', 'folder'].includes(value),
|
|
85
51
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
getIsObject() {
|
|
95
|
-
return typeof this.selected === 'object'
|
|
96
|
-
},
|
|
97
|
-
getSelected() {
|
|
98
|
-
if (this.selected) {
|
|
99
|
-
if (typeof this.selected === 'object' && this.selected[this.keyValue] ) {
|
|
100
|
-
return this.selected[this.keyValue]
|
|
101
|
-
} else {
|
|
102
|
-
return this.selected
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
return false
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
getItems() {
|
|
109
|
-
if (this.items.length > 0 && typeof this.items[0] !== 'object') {
|
|
110
|
-
return this.items.map((item) => {
|
|
111
|
-
return {
|
|
112
|
-
[this.keyLabel]: item,
|
|
113
|
-
[this.keyValue]: item
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
} else {
|
|
117
|
-
return this.items
|
|
118
|
-
}
|
|
119
|
-
},
|
|
52
|
+
/**
|
|
53
|
+
* It sets the tabs which will be rendered.
|
|
54
|
+
*/
|
|
55
|
+
items: {
|
|
56
|
+
type: Array,
|
|
57
|
+
required: true,
|
|
120
58
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
59
|
+
/**
|
|
60
|
+
* It sets the key label of the items if needed.
|
|
61
|
+
*/
|
|
62
|
+
keyLabel: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: 'label',
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* It sets the key value of the items if needed.
|
|
68
|
+
*/
|
|
69
|
+
keyValue: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'value',
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* It disabled the tab header. All mouse events are disabled.
|
|
75
|
+
*/
|
|
76
|
+
disabled: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false,
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* It sets the tab seleced.
|
|
82
|
+
*/
|
|
83
|
+
selected: {},
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const emit = defineEmits(['change', 'update:selected'])
|
|
87
|
+
|
|
88
|
+
const getComponentClass = computed(() => {
|
|
89
|
+
if (props.disabled) {
|
|
90
|
+
return 'status-disabled'
|
|
91
|
+
} else {
|
|
92
|
+
return 'status-resting'
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const getIsObject = computed(() => {
|
|
97
|
+
return typeof props.selected === 'object'
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const getSelected = computed(() => {
|
|
101
|
+
if (props.selected) {
|
|
102
|
+
if (typeof props.selected === 'object' && props.selected[props.keyValue]) {
|
|
103
|
+
return props.selected[props.keyValue]
|
|
104
|
+
} else {
|
|
105
|
+
return props.selected
|
|
134
106
|
}
|
|
107
|
+
} else {
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
const getItems = computed(() => {
|
|
113
|
+
if (props.items.length > 0 && typeof props.items[0] !== 'object') {
|
|
114
|
+
return props.items.map((item) => {
|
|
115
|
+
return {
|
|
116
|
+
[props.keyLabel]: item,
|
|
117
|
+
[props.keyValue]: item,
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
} else {
|
|
121
|
+
return props.items
|
|
135
122
|
}
|
|
123
|
+
})
|
|
136
124
|
|
|
125
|
+
const selectTab = (item) => {
|
|
126
|
+
if (item.disabled !== true) {
|
|
127
|
+
emit('update:selected', getIsObject.value ? item : item[props.keyValue])
|
|
128
|
+
emit('change', getIsObject.value ? item : item[props.keyValue])
|
|
129
|
+
}
|
|
137
130
|
}
|
|
131
|
+
|
|
132
|
+
const getButtonClass = (item) => {
|
|
133
|
+
return computed(() => {
|
|
134
|
+
if (item.disabled) {
|
|
135
|
+
return ['status-disabled']
|
|
136
|
+
} else {
|
|
137
|
+
return { 'status-active': getSelected.value === item[props.keyValue], 'status-enabled': true }
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
138
142
|
</script>
|
|
139
143
|
|
|
140
|
-
<style>
|
|
144
|
+
<style>
|
|
145
|
+
/* Please, use the file src/assets/scss/components/PsTabHeader.scss */
|
|
146
|
+
</style>
|
|
@@ -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>
|