@policystudio/policy-studio-ui-vue 1.1.88 → 1.1.90-access.0

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