@policystudio/policy-studio-ui-vue 1.1.90-beta.2 → 1.1.90-beta.21

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 (146) hide show
  1. package/.eslintrc.js +13 -8
  2. package/.github/workflows/deploy-storybook.yml +4 -4
  3. package/.nvmrc +1 -0
  4. package/dist/css/psui_styles_output.css +6986 -0
  5. package/dist/index.d.ts +50 -0
  6. package/dist/index.js +104 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/util/GeneralFunctions.d.ts +3 -0
  9. package/dist/util/GeneralFunctions.js +29 -0
  10. package/dist/util/GeneralFunctions.js.map +1 -0
  11. package/dist/util/directives.d.ts +1 -0
  12. package/dist/util/directives.js +22 -0
  13. package/dist/util/directives.js.map +1 -0
  14. package/dist/util/imageLoader.d.ts +6 -0
  15. package/dist/util/imageLoader.js +52 -0
  16. package/dist/util/imageLoader.js.map +1 -0
  17. package/package.json +24 -37
  18. package/src/App.vue +30 -0
  19. package/src/assets/scss/components/PsDataTable.scss +1 -1
  20. package/src/components/accordion/PsAccordionItem.vue +75 -75
  21. package/src/components/badges-and-tags/PsBadgeWithIcon.vue +31 -33
  22. package/src/components/badges-and-tags/PsCardInfos.vue +39 -41
  23. package/src/components/badges-and-tags/PsChartLegend.vue +46 -51
  24. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +13 -19
  25. package/src/components/badges-and-tags/PsCostEffectBar.vue +24 -56
  26. package/src/components/badges-and-tags/PsDateCardInfo.vue +17 -18
  27. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -2
  28. package/src/components/badges-and-tags/PsMiniTag.vue +39 -41
  29. package/src/components/badges-and-tags/PsProgressBar.vue +72 -68
  30. package/src/components/badges-and-tags/PsTagScope.vue +17 -22
  31. package/src/components/badges-and-tags/PsTestimonialCard.vue +19 -26
  32. package/src/components/buttons/PsButton.vue +88 -111
  33. package/src/components/chips/PsChips.vue +98 -101
  34. package/src/components/controls/PsCheckbox.vue +84 -84
  35. package/src/components/controls/PsCheckboxSimple.vue +95 -95
  36. package/src/components/controls/PsDraggable.vue +53 -55
  37. package/src/components/controls/PsInlineSelector.vue +98 -99
  38. package/src/components/controls/PsRadioButton.vue +59 -58
  39. package/src/components/controls/PsRadioButtonSimple.vue +79 -75
  40. package/src/components/controls/PsSlider.vue +185 -176
  41. package/src/components/controls/PsSwitch.vue +51 -52
  42. package/src/components/controls/PsToggle.vue +52 -50
  43. package/src/components/data-graphics/PsBarChart.vue +18 -21
  44. package/src/components/datatable/PsDataTable.vue +56 -60
  45. package/src/components/datatable/PsDataTableItem.vue +13 -28
  46. package/src/components/forms/PsDropdown.vue +164 -162
  47. package/src/components/forms/PsDropdownList.vue +133 -130
  48. package/src/components/forms/PsInput.vue +154 -153
  49. package/src/components/forms/PsInputSelect.vue +91 -92
  50. package/src/components/forms/PsInputTextArea.vue +71 -71
  51. package/src/components/navigations/PsBreadcrumb.vue +25 -34
  52. package/src/components/notifications/PsDialog.vue +57 -56
  53. package/src/components/notifications/PsSimpleAlert.vue +27 -29
  54. package/src/components/notifications/PsToast.vue +40 -39
  55. package/src/components/table-results/PsTableResults.vue +449 -458
  56. package/src/components/table-results/PsTableResultsBody.vue +66 -67
  57. package/src/components/table-results/PsTableResultsHead.vue +62 -56
  58. package/src/components/table-results/PsTableResultsHeadComparison.vue +62 -56
  59. package/src/components/table-results/PsTableResultsHeadFlexible.vue +63 -56
  60. package/src/components/table-results/PsTableResultsRow.vue +55 -56
  61. package/src/components/tabs/PsTabHeader.vue +106 -100
  62. package/src/components/tooltip/PsDialogTooltip.vue +96 -101
  63. package/src/components/tooltip/PsRichTooltip.vue +41 -45
  64. package/src/components/tooltip/PsTooltip.vue +111 -116
  65. package/src/components/ui/PsDotLoader.vue +1 -5
  66. package/src/components/ui/PsIcon.vue +126 -129
  67. package/src/index.ts +156 -0
  68. package/src/tsconfig.json +12 -0
  69. package/src/types/index.d.ts +6 -0
  70. package/src/util/GeneralFunctions.js +4 -6
  71. package/src/util/directives.ts +24 -0
  72. package/src/util/imageLoader.js +14 -7
  73. package/tailwind.config.js +1 -1
  74. package/tsconfig.json +47 -0
  75. package/.storybook/PolicyStudio.js +0 -10
  76. package/.storybook/eventBus.js +0 -26
  77. package/.storybook/main.js +0 -21
  78. package/.storybook/manager.js +0 -6
  79. package/.storybook/preview.js +0 -17
  80. package/babel.config.js +0 -17
  81. package/dist/css/psui_styles.css +0 -4647
  82. package/postcss.config.js +0 -8
  83. package/src/assets/images/multifamily-units.svg +0 -10
  84. package/src/assets/images/policy-studio.svg +0 -15
  85. package/src/components/playground/PsScrollBar.vue +0 -320
  86. package/src/contents/ComparisonData.js +0 -378
  87. package/src/contents/FlexibleData.js +0 -502
  88. package/src/contents/ResultsData.js +0 -531
  89. package/src/index.js +0 -166
  90. package/src/stories/Accordion.stories.js +0 -59
  91. package/src/stories/BadgeWithIcon.stories.js +0 -31
  92. package/src/stories/BarChart.stories.js +0 -17
  93. package/src/stories/Breadcrumb.stories.js +0 -25
  94. package/src/stories/Button.stories.js +0 -48
  95. package/src/stories/Button.vue +0 -59
  96. package/src/stories/CardInfos.stories.js +0 -16
  97. package/src/stories/ChartLegend.stories.js +0 -16
  98. package/src/stories/Checkbox.stories.js +0 -45
  99. package/src/stories/CheckboxSimple.stories.js +0 -49
  100. package/src/stories/Chips.stories.js +0 -31
  101. package/src/stories/ClimateZoneBadge.stories.js +0 -17
  102. package/src/stories/Colors.mdx +0 -70
  103. package/src/stories/CostEffectBar.stories.js +0 -23
  104. package/src/stories/Datatable.stories.js +0 -50
  105. package/src/stories/DateCardInfo.stories.js +0 -24
  106. package/src/stories/Dialog.stories.js +0 -131
  107. package/src/stories/Draggable.stories.js +0 -22
  108. package/src/stories/Dropdown.stories.js +0 -99
  109. package/src/stories/DropdownList.stories.js +0 -211
  110. package/src/stories/ElevationSystem.mdx +0 -41
  111. package/src/stories/Header.stories.js +0 -41
  112. package/src/stories/Header.vue +0 -77
  113. package/src/stories/HighlightRippleDot.stories.js +0 -15
  114. package/src/stories/Icon.stories.js +0 -21
  115. package/src/stories/InlineSelector.stories.js +0 -18
  116. package/src/stories/Input.stories.js +0 -240
  117. package/src/stories/InputSelect.stories.js +0 -30
  118. package/src/stories/InputTextArea.stories.js +0 -25
  119. package/src/stories/Introduction.mdx +0 -211
  120. package/src/stories/MiniTag.stories.js +0 -52
  121. package/src/stories/Playground.stories.js +0 -16
  122. package/src/stories/ProgressBar.stories.js +0 -23
  123. package/src/stories/RadioButton.stories.js +0 -40
  124. package/src/stories/RadioButtonSimple.stories.js +0 -43
  125. package/src/stories/SimpleAlert.stories.js +0 -21
  126. package/src/stories/Slider.stories.js +0 -75
  127. package/src/stories/Switch.stories.js +0 -39
  128. package/src/stories/TabHeader.stories.js +0 -52
  129. package/src/stories/TableResults.stories.js +0 -724
  130. package/src/stories/TagScope.stories.js +0 -17
  131. package/src/stories/TestimonialCard.stories.js +0 -27
  132. package/src/stories/Toast.stories.js +0 -52
  133. package/src/stories/Toggle.stories.js +0 -45
  134. package/src/stories/Tooltip.stories.js +0 -114
  135. package/src/stories/Typography.mdx +0 -212
  136. package/src/stories/assets/code-brackets.svg +0 -1
  137. package/src/stories/assets/colors.svg +0 -1
  138. package/src/stories/assets/comments.svg +0 -1
  139. package/src/stories/assets/direction.svg +0 -1
  140. package/src/stories/assets/flow.svg +0 -1
  141. package/src/stories/assets/plugin.svg +0 -1
  142. package/src/stories/assets/repo.svg +0 -1
  143. package/src/stories/assets/stackalt.svg +0 -1
  144. package/src/stories/button.css +0 -30
  145. package/src/stories/header.css +0 -32
  146. 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
- export default {
31
- name: 'PsTableResultsRow',
32
- props: {
33
- /**
34
- * It sets the values which will be use to render the body.
35
- */
36
- summaryData: {
37
- type: Array,
38
- default() {
39
- return []
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
- * It sets the values which will be use to render the body.
53
- */
54
- rows: {
55
- type: Array,
56
- default() {
57
- return []
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
- computed: {
62
- getRows() {
63
- const rows = []
64
- for (let index = 0; index < this.summaryData.length; index++) {
65
- const item = this.summaryData[index]
66
- this.addRow(item, 0, `${index}`, rows)
67
- }
68
- return rows
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
- methods: {
72
- addRow(item, deep = 0, index, rows) {
73
- item.deep = deep
74
- item.index = index
75
- rows.push(item)
76
- item.last_deep = item.items ? false : true
77
- if (item.items) {
78
- const items_child = [...item.items]
79
- for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
80
- const item_child = items_child[indexChild]
81
- item_child.is_last = indexChild + 1 === items_child.length ? true : false
82
- this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
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
- <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
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
- export default {
42
- name: 'PsTabHeader',
43
- components: { PsRichTooltip },
44
- props: {
45
- /**
46
- * It sets the layout of the tabheader. eg: standard, underline and folder.
47
- */
48
- layout: {
49
- type: String,
50
- default: 'standard',
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, defineEmits } 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
- computed: {
87
- getComponentClass() {
88
- if (this.disabled) {
89
- return 'status-disabled'
90
- } else {
91
- return 'status-resting'
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
- methods: {
122
- selectTab(item) {
123
- if (item.disabled !== true) {
124
- this.$emit('update:selected', this.getIsObject ? item : item[this.keyValue] )
125
- this.$emit('change', this.getIsObject ? item : item[this.keyValue])
126
- }
127
- },
128
- getButtonClass(item) {
129
- if (item.disabled) {
130
- return ['status-disabled']
131
- } else {
132
- return { 'status-active': this.getSelected === item[this.keyValue], 'status-enabled' : true }
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> /* Please, use the file src/assets/scss/components/PsTabHeader.scss */</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
- export default {
48
- name: 'PsDialogTooltip',
49
- props: {
50
- /**
51
- * It sets the title of the tooltip if needed.
52
- */
53
- title: {
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
- inheritAttrs: true,
87
- emits: ['show', 'click'],
88
- data() {
89
- return {
90
- show: false,
91
- closingTimeout: null,
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
- computed:{
95
- getComponentClass(){
96
- return `layout-${this.layout}`
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
- mounted() {
100
- 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,
101
78
  },
102
- beforeUnmount() {
103
- 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),
104
86
  },
105
- methods: {
106
- open() {
107
- if (this.show || this.ignoreDialog) return
108
- this.$emit('show')
109
- this.show = true
87
+ })
110
88
 
111
- this.$refs.dialog.style.display = 'block'
112
- this.$refs.dialog.style.opacity = 0
89
+ const emit = defineEmits(['show', 'click', 'close'])
113
90
 
114
- setTimeout(() => {
115
- this.updatePosition()
116
- }, 10)
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
- this.$refs.dialog.style.display = 'none'
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
- const rectDialog = dialog.getBoundingClientRect()
131
- const rectTrigger = trigger.getBoundingClientRect()
132
- const windowWidth = document.documentElement.clientWidth
133
- dialog.style.top = `${rectTrigger.y + rectTrigger.height + 8}px`
100
+ onMounted(() => {
101
+ document.addEventListener('resize', updatePosition)
102
+ })
134
103
 
135
- if (rectTrigger.x + rectDialog.width + 20 > windowWidth) {
136
- dialog.style.left = `${windowWidth - rectDialog.width - 30}px`
137
- } else if (rectTrigger.x - Math.abs(rectTrigger.width-rectDialog.width) < 0) {
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
- if(this.position == 'top') {
146
- dialog.style.top = `${rectTrigger.y - rectTrigger.height - 10}px`
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
- setTimeout(() => {
150
- dialog.style.opacity = 100
151
- }, 100)
152
- },
153
- onClick() {
154
- this.$emit('click', this.$event)
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
- export default {
23
- name: 'PsRichTooltip',
24
- components: { PsTooltip },
25
- props: {
26
- /**
27
- * It sets the title of the tooltip if needed.
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>