@policystudio/policy-studio-ui-vue 1.1.90-beta.5 → 1.1.90-beta.51
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,36 +1,33 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="psui-el-bar-chart">
|
|
3
|
-
<p
|
|
3
|
+
<p
|
|
4
4
|
v-if="showNumber"
|
|
5
5
|
class="psui-el-bar-chart-total"
|
|
6
6
|
>
|
|
7
7
|
{{ total }}
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
<div
|
|
10
|
+
<div
|
|
11
11
|
class="psui-el-bar-chart-bar"
|
|
12
|
-
:style="{width: `${fillWidth}%`}"
|
|
12
|
+
:style="{ width: `${fillWidth}%` }"
|
|
13
13
|
/>
|
|
14
14
|
</div>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
default: 50
|
|
32
|
-
},
|
|
17
|
+
<script setup>
|
|
18
|
+
|
|
19
|
+
defineProps({
|
|
20
|
+
showNumber: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: true,
|
|
23
|
+
},
|
|
24
|
+
total: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: '5,0',
|
|
27
|
+
},
|
|
28
|
+
fillWidth: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 50,
|
|
33
31
|
},
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
})
|
|
36
33
|
</script>
|
|
@@ -37,70 +37,66 @@
|
|
|
37
37
|
</table>
|
|
38
38
|
</template>
|
|
39
39
|
|
|
40
|
-
<script>
|
|
41
|
-
|
|
42
|
-
export const alignment = ['center', 'right', 'left']
|
|
40
|
+
<script setup>
|
|
41
|
+
import { computed } from 'vue'
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
type: {
|
|
51
|
-
type: String,
|
|
52
|
-
required: true,
|
|
53
|
-
validator: (value) => {
|
|
54
|
-
return ['simple', 'rich'].indexOf(value) !== -1
|
|
55
|
-
},
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
type: {
|
|
45
|
+
type: String,
|
|
46
|
+
required: true,
|
|
47
|
+
validator: (value) => {
|
|
48
|
+
return ['simple', 'rich'].indexOf(value) !== -1
|
|
56
49
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* It sets the values which will be use to render the footer.
|
|
75
|
-
*/
|
|
76
|
-
footer: {
|
|
77
|
-
type: Array,
|
|
78
|
-
},
|
|
79
|
-
/**
|
|
80
|
-
* It sets the alignment of the whole context.
|
|
81
|
-
*/
|
|
82
|
-
align: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: 'left',
|
|
85
|
-
validator: (value) => {
|
|
86
|
-
return ['center', 'right', 'left'].indexOf(value) !== -1
|
|
87
|
-
}
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* It sets the values which will be use to render the header.
|
|
53
|
+
*/
|
|
54
|
+
header: {
|
|
55
|
+
type: Array,
|
|
56
|
+
required: true,
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* It sets the values which will be use to render the body.
|
|
60
|
+
*/
|
|
61
|
+
data: {
|
|
62
|
+
type: Array,
|
|
63
|
+
default() {
|
|
64
|
+
return []
|
|
88
65
|
},
|
|
89
|
-
/**
|
|
90
|
-
* It sets additional styling if needed.
|
|
91
|
-
*/
|
|
92
|
-
cssStyle: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: 'psui-text-gray-60'
|
|
95
|
-
}
|
|
96
66
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
67
|
+
/**
|
|
68
|
+
* It sets the values which will be use to render the footer.
|
|
69
|
+
*/
|
|
70
|
+
footer: {
|
|
71
|
+
type: Array,
|
|
72
|
+
default: () => [],
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* It sets the alignment of the whole context.
|
|
76
|
+
*/
|
|
77
|
+
align: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'left',
|
|
80
|
+
validator: (value) => {
|
|
81
|
+
return ['center', 'right', 'left'].indexOf(value) !== -1
|
|
102
82
|
},
|
|
103
83
|
},
|
|
104
|
-
|
|
84
|
+
/**
|
|
85
|
+
* It sets additional styling if needed.
|
|
86
|
+
*/
|
|
87
|
+
cssStyle: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: 'psui-text-gray-60',
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const cssAlign = computed(() => {
|
|
94
|
+
if (props.align === 'right') return `psui-text-right ${props.cssStyle}`
|
|
95
|
+
if (props.align === 'center') return `psui-text-center ${props.cssStyle}`
|
|
96
|
+
return `psui-text-left ${props.cssStyle}`
|
|
97
|
+
})
|
|
105
98
|
</script>
|
|
106
|
-
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
/* Please, use the file src/assets/scss/components/PsDataTable.scss */
|
|
102
|
+
</style>
|
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
</span>
|
|
16
16
|
<div
|
|
17
17
|
class="psui-flex psui-items-center"
|
|
18
|
-
:class="
|
|
19
|
-
el[Object.keys(el)[1]] >= 0
|
|
20
|
-
? 'psui-text-green-70'
|
|
21
|
-
: 'psui-text-red-70'
|
|
22
|
-
"
|
|
18
|
+
:class="el[Object.keys(el)[1]] >= 0 ? 'psui-text-green-70' : 'psui-text-red-70'"
|
|
23
19
|
>
|
|
24
20
|
<i
|
|
25
21
|
v-if="el[Object.keys(el)[1]] >= 0"
|
|
@@ -29,37 +25,26 @@
|
|
|
29
25
|
v-else
|
|
30
26
|
class="material-icons"
|
|
31
27
|
>arrow_downward</i>
|
|
32
|
-
<span>
|
|
33
|
-
{{
|
|
34
|
-
(
|
|
35
|
-
(el[Object.keys(el)[1]] / el[Object.keys(el)[0]]) *
|
|
36
|
-
100
|
|
37
|
-
).toFixed(2)
|
|
38
|
-
}}%
|
|
39
|
-
</span>
|
|
28
|
+
<span> {{ ((el[Object.keys(el)[1]] / el[Object.keys(el)[0]]) * 100).toFixed(2) }}% </span>
|
|
40
29
|
</div>
|
|
41
30
|
</div>
|
|
42
|
-
<span class="psui-text-gray-50">{{
|
|
43
|
-
el[Object.keys(el)[0]].toFixed(6)
|
|
44
|
-
}}</span>
|
|
31
|
+
<span class="psui-text-gray-50">{{ el[Object.keys(el)[0]].toFixed(6) }}</span>
|
|
45
32
|
</td>
|
|
46
33
|
</tr>
|
|
47
34
|
</tbody>
|
|
48
35
|
</template>
|
|
49
36
|
|
|
50
|
-
<script>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return []
|
|
59
|
-
},
|
|
37
|
+
<script setup>
|
|
38
|
+
|
|
39
|
+
defineProps({
|
|
40
|
+
data: {
|
|
41
|
+
type: Array,
|
|
42
|
+
required: true,
|
|
43
|
+
default: () => {
|
|
44
|
+
return []
|
|
60
45
|
},
|
|
61
46
|
},
|
|
62
|
-
}
|
|
47
|
+
})
|
|
63
48
|
</script>
|
|
64
49
|
|
|
65
50
|
<style scoped>
|
|
@@ -67,4 +52,4 @@ export default {
|
|
|
67
52
|
font-size: 15px;
|
|
68
53
|
margin-bottom: 2px;
|
|
69
54
|
}
|
|
70
|
-
</style>
|
|
55
|
+
</style>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
3
|
ref="PSDropdown"
|
|
4
|
-
class="psui-el-dropdown-menu"
|
|
5
|
-
:class="{ 'is-open'
|
|
4
|
+
class="psui-el-dropdown-menu"
|
|
5
|
+
:class="{ 'is-open': show.value }"
|
|
6
6
|
v-click-outside="close"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
9
|
ref="PSDropdownTrigger"
|
|
10
10
|
v-if="$slots.dropdownTrigger"
|
|
11
|
-
@click="show && !toggleWhenActive ? '' : toggle()"
|
|
11
|
+
@click="show && !toggleWhenActive ? '' : toggle($event)"
|
|
12
12
|
>
|
|
13
13
|
<slot name="dropdownTrigger" />
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<button
|
|
17
17
|
v-else
|
|
18
|
-
@click="show && !toggleWhenActive ? '' : toggle()"
|
|
18
|
+
@click="show && !toggleWhenActive ? '' : toggle($event)"
|
|
19
19
|
type="button"
|
|
20
|
-
:id="id"
|
|
20
|
+
:id="id.value"
|
|
21
21
|
aria-haspopup="true"
|
|
22
22
|
aria-expanded="true"
|
|
23
23
|
ref="PSDropdownTrigger"
|
|
24
24
|
>
|
|
25
25
|
<slot
|
|
26
|
-
v-if="show && $slots.buttonLabelOnShow"
|
|
26
|
+
v-if="show.value && $slots.buttonLabelOnShow"
|
|
27
27
|
name="buttonLabelOnShow"
|
|
28
28
|
/>
|
|
29
29
|
<slot
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
role="menu"
|
|
37
37
|
class="psui-el-dropdown-menu-dialog-wrapper psui-duration-300"
|
|
38
38
|
aria-orientation="vertical"
|
|
39
|
-
:aria-labelledby="id"
|
|
39
|
+
:aria-labelledby="id.value"
|
|
40
40
|
:style="{ minWidth: minWidthDropDown }"
|
|
41
41
|
>
|
|
42
42
|
<div class="psui-el-dropdown-menu-dialog">
|
|
@@ -46,169 +46,173 @@
|
|
|
46
46
|
</div>
|
|
47
47
|
</template>
|
|
48
48
|
|
|
49
|
-
<script>
|
|
49
|
+
<script setup>
|
|
50
50
|
// Figma - 2.3 Dropdown with category divider https://www.figma.com/file/Tto8hrNlSfuPcwd1pfqogF/%E2%9A%A1%EF%B8%8F-Design-System?node-id=1768%3A64886
|
|
51
51
|
|
|
52
|
-
import {
|
|
53
|
-
randomString,
|
|
54
|
-
getParentScrollableEl,
|
|
55
|
-
} from '../../util/GeneralFunctions'
|
|
52
|
+
import { randomString, getParentScrollableEl } from '../../util/GeneralFunctions.js'
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
import { ref, onBeforeUnmount } from 'vue'
|
|
55
|
+
|
|
56
|
+
defineExpose({
|
|
57
|
+
close:() => close(),
|
|
58
|
+
open:() => open(),
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const props = defineProps({
|
|
60
62
|
/**
|
|
61
|
-
|
|
63
|
+
* It sets a minimun width for the dropdown menu.
|
|
62
64
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* It's a boolean responsible for showing a slot within the html tag button.
|
|
69
|
-
*/
|
|
70
|
-
buttonLabelOnShow: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: false,
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* It's a property responsible for toggling the dropdown menu. default: true.
|
|
76
|
-
*/
|
|
77
|
-
toggleWhenActive: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: true,
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* Disable the toogle on click. default: false.
|
|
83
|
-
*/
|
|
84
|
-
disabled: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
default: false,
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* It sets the vertical and horizontal position.
|
|
90
|
-
*/
|
|
91
|
-
position: {
|
|
92
|
-
type: String,
|
|
93
|
-
validator: (value)=> ['custom'].includes(value)
|
|
94
|
-
},
|
|
65
|
+
minWidthDropDown: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: '240px',
|
|
95
68
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
69
|
+
/**
|
|
70
|
+
* It's a boolean responsible for showing a slot within the html tag button.
|
|
71
|
+
*/
|
|
72
|
+
buttonLabelOnShow: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false,
|
|
103
75
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
76
|
+
/**
|
|
77
|
+
* It's a property responsible for toggling the dropdown menu. default: true.
|
|
78
|
+
*/
|
|
79
|
+
toggleWhenActive: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: true,
|
|
109
82
|
},
|
|
110
|
-
|
|
111
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Disable the toogle on click. default: false.
|
|
85
|
+
*/
|
|
86
|
+
disabled: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
112
89
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.close()
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
watchParentScrolling() {
|
|
124
|
-
this.scrollableParentEl = getParentScrollableEl(this.$refs.PSDropdown)
|
|
125
|
-
if (this.scrollableParentEl) {
|
|
126
|
-
this.scrollableParentEl.addEventListener('scroll', this.updatePosition)
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
unwatchParentScrolling() {
|
|
130
|
-
if (this.scrollableParentEl) {
|
|
131
|
-
this.scrollableParentEl.removeEventListener(
|
|
132
|
-
'scroll',
|
|
133
|
-
this.updatePosition
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
updatePosition() {
|
|
138
|
-
const PSDropdownDialog = this.$refs.PSDropdownDialog
|
|
139
|
-
const PSDropdownTrigger = this.$refs.PSDropdownTrigger
|
|
140
|
-
if (!PSDropdownDialog || !PSDropdownTrigger) return
|
|
141
|
-
|
|
142
|
-
const rectTrigger = PSDropdownTrigger.getBoundingClientRect()
|
|
143
|
-
const rectDialog = PSDropdownDialog.getBoundingClientRect()
|
|
144
|
-
const windowWidth = document.documentElement.clientWidth
|
|
145
|
-
|
|
146
|
-
PSDropdownDialog.style.position = 'fixed'
|
|
147
|
-
PSDropdownDialog.style.top = `${rectTrigger.y + rectTrigger.height}px`
|
|
148
|
-
|
|
149
|
-
PSDropdownDialog.style.minWidth = `${rectTrigger.width}px`
|
|
150
|
-
|
|
151
|
-
if (rectTrigger.x + rectDialog.width + 20 > windowWidth) {
|
|
152
|
-
PSDropdownDialog.style.left = `${
|
|
153
|
-
windowWidth - rectDialog.width - 30
|
|
154
|
-
}px`
|
|
155
|
-
} else {
|
|
156
|
-
PSDropdownDialog.style.left = `${rectTrigger.x}px`
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if(this.position == 'custom') {
|
|
160
|
-
PSDropdownDialog.style.top = `${rectTrigger.y}px`
|
|
161
|
-
PSDropdownDialog.style.left = `${rectTrigger.x + 100}px`
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (rectTrigger.top < 10) {
|
|
165
|
-
this.close()
|
|
166
|
-
console.warn('The dropdown are too close from the top of the page')
|
|
167
|
-
return
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
setTimeout(() => {
|
|
171
|
-
PSDropdownDialog.style.opacity = 1
|
|
172
|
-
}, 10)
|
|
173
|
-
},
|
|
174
|
-
open() {
|
|
175
|
-
this.$emit('open')
|
|
176
|
-
this.show = true
|
|
177
|
-
if(this.$refs.PSDropdownDialog){
|
|
178
|
-
this.$refs.PSDropdownDialog.style.opacity = 0
|
|
179
|
-
this.$refs.PSDropdownDialog.style.display = 'block'
|
|
180
|
-
}
|
|
181
|
-
setTimeout(() => {
|
|
182
|
-
this.updatePosition()
|
|
183
|
-
this.watchParentScrolling()
|
|
184
|
-
document.addEventListener('keyup', this.handleEsc)
|
|
185
|
-
window.addEventListener('resize', this.updatePosition)
|
|
186
|
-
window.addEventListener('click', this.clickOutside)
|
|
187
|
-
}, 10)
|
|
188
|
-
},
|
|
189
|
-
close() {
|
|
190
|
-
if (this.show) {
|
|
191
|
-
this.$emit('close')
|
|
192
|
-
if(this.$refs.PSDropdownDialog){
|
|
193
|
-
this.$refs.PSDropdownDialog.style.display = 'none'
|
|
194
|
-
this.$refs.PSDropdownDialog.style.opacity = 0
|
|
195
|
-
}
|
|
196
|
-
this.show = false
|
|
197
|
-
this.unwatchParentScrolling()
|
|
198
|
-
}
|
|
199
|
-
document.removeEventListener('keyup', this.handleEsc)
|
|
200
|
-
document.removeEventListener('resize', this.updatePosition)
|
|
201
|
-
document.removeEventListener('click', this.clickOutside)
|
|
202
|
-
},
|
|
203
|
-
handleEsc(evt) {
|
|
204
|
-
if (this.show && evt.keyCode === 27) this.close()
|
|
205
|
-
},
|
|
206
|
-
clickOutside(event) {
|
|
207
|
-
if (!this.show) return
|
|
208
|
-
if (!this.$refs.PSDropdown == event.target || !this.$refs.PSDropdown?.contains(event.target)) {
|
|
209
|
-
this.close()
|
|
210
|
-
}
|
|
211
|
-
},
|
|
90
|
+
/**
|
|
91
|
+
* It sets the vertical and horizontal position.
|
|
92
|
+
*/
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, vue/require-default-prop
|
|
94
|
+
position: {
|
|
95
|
+
type: String,
|
|
96
|
+
validator: (value) => ['custom'].includes(value),
|
|
212
97
|
},
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const emit = defineEmits(['open', 'close'])
|
|
101
|
+
|
|
102
|
+
const show = ref(false)
|
|
103
|
+
const id = ref(randomString(8))
|
|
104
|
+
// const marginLeft = ref('-0px')
|
|
105
|
+
const scrollableParentEl = ref(null)
|
|
106
|
+
const PSDropdown = ref(null)
|
|
107
|
+
const PSDropdownDialog = ref(null)
|
|
108
|
+
const PSDropdownTrigger = ref(null)
|
|
109
|
+
|
|
110
|
+
// const getMaxWidth = computed(() => {
|
|
111
|
+
// let bounds = PSDropdown.getBoundingClientRect()
|
|
112
|
+
// return document.documentElement.clientWidth - bounds['left'] - 30
|
|
113
|
+
// })
|
|
114
|
+
|
|
115
|
+
onBeforeUnmount(() => {
|
|
116
|
+
unwatchParentScrolling()
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const toggle = (event) => {
|
|
120
|
+
if (props.disabled) return
|
|
121
|
+
if (!show.value) {
|
|
122
|
+
open()
|
|
123
|
+
} else {
|
|
124
|
+
close()
|
|
125
|
+
}
|
|
126
|
+
event.stopPropagation()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const handleEsc = (evt) => {
|
|
130
|
+
if (show.value && evt.keyCode === 27) close()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const open = () => {
|
|
134
|
+
emit('open')
|
|
135
|
+
show.value = true
|
|
136
|
+
if (PSDropdownDialog.value) {
|
|
137
|
+
PSDropdownDialog.value.style.opacity = 0
|
|
138
|
+
PSDropdownDialog.value.style.display = 'block'
|
|
139
|
+
}
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
updatePosition()
|
|
142
|
+
watchParentScrolling()
|
|
143
|
+
document.addEventListener('keyup', handleEsc)
|
|
144
|
+
window.addEventListener('resize', updatePosition)
|
|
145
|
+
// window.addEventListener('click', clickOutside)
|
|
146
|
+
}, 10)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const close = () => {
|
|
150
|
+
if (show.value == true) {
|
|
151
|
+
emit('close')
|
|
152
|
+
if (PSDropdownDialog.value !== null) {
|
|
153
|
+
PSDropdownDialog.value.style.display = 'none'
|
|
154
|
+
PSDropdownDialog.value.style.opacity = 0
|
|
155
|
+
}
|
|
156
|
+
show.value = false
|
|
157
|
+
unwatchParentScrolling()
|
|
158
|
+
}
|
|
159
|
+
document.removeEventListener('keyup', handleEsc)
|
|
160
|
+
document.removeEventListener('resize', updatePosition)
|
|
161
|
+
// document.removeEventListener('click', clickOutside)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const watchParentScrolling = () => {
|
|
165
|
+
scrollableParentEl.value = getParentScrollableEl(PSDropdown.value)
|
|
166
|
+
if (scrollableParentEl.value) {
|
|
167
|
+
scrollableParentEl.value.addEventListener('scroll', updatePosition)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const unwatchParentScrolling = () => {
|
|
172
|
+
if (scrollableParentEl.value) {
|
|
173
|
+
scrollableParentEl.value.removeEventListener('scroll', updatePosition())
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const updatePosition = () => {
|
|
178
|
+
if (PSDropdownDialog.value === null || PSDropdownTrigger.value === null) return
|
|
179
|
+
|
|
180
|
+
const rectTrigger = PSDropdownTrigger.value.getBoundingClientRect()
|
|
181
|
+
const rectDialog = PSDropdownDialog.value.getBoundingClientRect()
|
|
182
|
+
const windowWidth = document.documentElement.clientWidth
|
|
183
|
+
|
|
184
|
+
PSDropdownDialog.value.style.position = 'fixed'
|
|
185
|
+
PSDropdownDialog.value.style.top = `${rectTrigger.y + rectTrigger.height}px`
|
|
186
|
+
PSDropdownDialog.value.style.minWidth = `${rectTrigger.width}px`
|
|
187
|
+
|
|
188
|
+
if (rectTrigger.x + rectDialog.width + 20 > windowWidth) {
|
|
189
|
+
PSDropdownDialog.value.style.left = `${windowWidth - rectDialog.width - 30}px`
|
|
190
|
+
} else {
|
|
191
|
+
PSDropdownDialog.value.style.left = `${rectTrigger.x}px`
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (props.position == 'custom') {
|
|
195
|
+
PSDropdownDialog.value.style.top = `${rectTrigger.y}px`
|
|
196
|
+
PSDropdownDialog.value.style.left = `${rectTrigger.x + 100}px`
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (rectTrigger.top < 10) {
|
|
200
|
+
close()
|
|
201
|
+
console.warn('The dropdown are too close from the top of the page')
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
if(PSDropdownDialog.value){
|
|
207
|
+
PSDropdownDialog.value.style.opacity = 1
|
|
208
|
+
}
|
|
209
|
+
}, 10)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const clickOutside = (event) => {
|
|
213
|
+
if (!show.value) return
|
|
214
|
+
if (!PSDropdown.value == event.target || !PSDropdown.value?.contains(event.target)) {
|
|
215
|
+
close()
|
|
216
|
+
}
|
|
213
217
|
}
|
|
214
218
|
</script>
|