@policystudio/policy-studio-ui-vue 1.1.90-beta.12 → 1.1.90-beta.17

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 (224) hide show
  1. package/.eslintrc.js +2 -1
  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/package.json +9 -23
  6. package/src/assets/scss/components/PsDataTable.scss +1 -1
  7. package/src/components/accordion/PsAccordionItem.vue +75 -75
  8. package/src/components/badges-and-tags/PsBadgeWithIcon.vue +31 -34
  9. package/src/components/badges-and-tags/PsCardInfos.vue +40 -41
  10. package/src/components/badges-and-tags/PsChartLegend.vue +47 -51
  11. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +14 -19
  12. package/src/components/badges-and-tags/PsCostEffectBar.vue +24 -56
  13. package/src/components/badges-and-tags/PsDateCardInfo.vue +17 -18
  14. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -2
  15. package/src/components/badges-and-tags/PsMiniTag.vue +39 -41
  16. package/src/components/badges-and-tags/PsProgressBar.vue +72 -68
  17. package/src/components/badges-and-tags/PsTagScope.vue +17 -22
  18. package/src/components/badges-and-tags/PsTestimonialCard.vue +20 -26
  19. package/src/components/buttons/PsButton.vue +61 -62
  20. package/src/components/chips/PsChips.vue +98 -101
  21. package/src/components/controls/PsCheckbox.vue +84 -84
  22. package/src/components/controls/PsCheckboxSimple.vue +95 -95
  23. package/src/components/controls/PsDraggable.vue +53 -55
  24. package/src/components/controls/PsInlineSelector.vue +99 -99
  25. package/src/components/controls/PsRadioButton.vue +59 -58
  26. package/src/components/controls/PsRadioButtonSimple.vue +79 -75
  27. package/src/components/controls/PsSlider.vue +185 -176
  28. package/src/components/controls/PsSwitch.vue +51 -52
  29. package/src/components/controls/PsToggle.vue +53 -50
  30. package/src/components/data-graphics/PsBarChart.vue +19 -21
  31. package/src/components/datatable/PsDataTable.vue +56 -60
  32. package/src/components/datatable/PsDataTableItem.vue +14 -28
  33. package/src/components/forms/PsDropdown.vue +164 -162
  34. package/src/components/forms/PsDropdownList.vue +132 -129
  35. package/src/components/forms/PsInput.vue +155 -153
  36. package/src/components/forms/PsInputSelect.vue +91 -92
  37. package/src/components/forms/PsInputTextArea.vue +71 -71
  38. package/src/components/navigations/PsBreadcrumb.vue +26 -34
  39. package/src/components/notifications/PsDialog.vue +57 -56
  40. package/src/components/notifications/PsSimpleAlert.vue +28 -29
  41. package/src/components/notifications/PsToast.vue +40 -39
  42. package/src/components/table-results/PsTableResults.vue +452 -458
  43. package/src/components/table-results/PsTableResultsBody.vue +66 -67
  44. package/src/components/table-results/PsTableResultsHead.vue +62 -56
  45. package/src/components/table-results/PsTableResultsHeadComparison.vue +62 -56
  46. package/src/components/table-results/PsTableResultsHeadFlexible.vue +63 -56
  47. package/src/components/table-results/PsTableResultsRow.vue +55 -56
  48. package/src/components/tabs/PsTabHeader.vue +106 -100
  49. package/src/components/tooltip/PsDialogTooltip.vue +96 -101
  50. package/src/components/tooltip/PsRichTooltip.vue +42 -45
  51. package/src/components/tooltip/PsTooltip.vue +111 -116
  52. package/src/components/ui/PsDotLoader.vue +1 -5
  53. package/src/components/ui/PsIcon.vue +126 -129
  54. package/src/index.ts +57 -71
  55. package/src/tsconfig.json +12 -0
  56. package/src/{shims-vue.d.ts → types/index.d.ts} +0 -5
  57. package/src/util/{GeneralFunctions.ts → GeneralFunctions.js} +0 -3
  58. package/src/util/directives.ts +24 -0
  59. package/src/util/eventBus.js +10 -0
  60. package/src/util/{imageLoader.ts → imageLoader.js} +7 -8
  61. package/tailwind.config.js +1 -1
  62. package/tsconfig.json +15 -17
  63. package/.storybook/PolicyStudio.ts +0 -11
  64. package/.storybook/eventBus.ts +0 -26
  65. package/.storybook/main.ts +0 -21
  66. package/.storybook/manager.ts +0 -7
  67. package/.storybook/preview.ts +0 -17
  68. package/dist/contents/ComparisonData.js +0 -376
  69. package/dist/contents/ComparisonData.js.map +0 -1
  70. package/dist/contents/FlexibleData.js +0 -501
  71. package/dist/contents/FlexibleData.js.map +0 -1
  72. package/dist/contents/ResultsData.js +0 -530
  73. package/dist/contents/ResultsData.js.map +0 -1
  74. package/dist/css/psui_styles.css +0 -4647
  75. package/dist/index.js +0 -114
  76. package/dist/index.js.map +0 -1
  77. package/dist/stories/Accordion.stories.js +0 -56
  78. package/dist/stories/Accordion.stories.js.map +0 -1
  79. package/dist/stories/BadgeWithIcon.stories.js +0 -28
  80. package/dist/stories/BadgeWithIcon.stories.js.map +0 -1
  81. package/dist/stories/BarChart.stories.js +0 -16
  82. package/dist/stories/BarChart.stories.js.map +0 -1
  83. package/dist/stories/Breadcrumb.stories.js +0 -21
  84. package/dist/stories/Breadcrumb.stories.js.map +0 -1
  85. package/dist/stories/Button.stories.js +0 -44
  86. package/dist/stories/Button.stories.js.map +0 -1
  87. package/dist/stories/CardInfos.stories.js +0 -13
  88. package/dist/stories/CardInfos.stories.js.map +0 -1
  89. package/dist/stories/ChartLegend.stories.js +0 -13
  90. package/dist/stories/ChartLegend.stories.js.map +0 -1
  91. package/dist/stories/Checkbox.stories.js +0 -44
  92. package/dist/stories/Checkbox.stories.js.map +0 -1
  93. package/dist/stories/CheckboxSimple.stories.js +0 -48
  94. package/dist/stories/CheckboxSimple.stories.js.map +0 -1
  95. package/dist/stories/Chips.stories.js +0 -27
  96. package/dist/stories/Chips.stories.js.map +0 -1
  97. package/dist/stories/ClimateZoneBadge.stories.js +0 -15
  98. package/dist/stories/ClimateZoneBadge.stories.js.map +0 -1
  99. package/dist/stories/CostEffectBar.stories.js +0 -21
  100. package/dist/stories/CostEffectBar.stories.js.map +0 -1
  101. package/dist/stories/Datatable.stories.js +0 -45
  102. package/dist/stories/Datatable.stories.js.map +0 -1
  103. package/dist/stories/DateCardInfo.stories.js +0 -18
  104. package/dist/stories/DateCardInfo.stories.js.map +0 -1
  105. package/dist/stories/Dialog.stories.js +0 -127
  106. package/dist/stories/Dialog.stories.js.map +0 -1
  107. package/dist/stories/Draggable.stories.js +0 -20
  108. package/dist/stories/Draggable.stories.js.map +0 -1
  109. package/dist/stories/Dropdown.stories.js +0 -98
  110. package/dist/stories/Dropdown.stories.js.map +0 -1
  111. package/dist/stories/DropdownList.stories.js +0 -208
  112. package/dist/stories/DropdownList.stories.js.map +0 -1
  113. package/dist/stories/Header.stories.js +0 -39
  114. package/dist/stories/Header.stories.js.map +0 -1
  115. package/dist/stories/HighlightRippleDot.stories.js +0 -13
  116. package/dist/stories/HighlightRippleDot.stories.js.map +0 -1
  117. package/dist/stories/Icon.stories.js +0 -19
  118. package/dist/stories/Icon.stories.js.map +0 -1
  119. package/dist/stories/InlineSelector.stories.js +0 -16
  120. package/dist/stories/InlineSelector.stories.js.map +0 -1
  121. package/dist/stories/Input.stories.js +0 -235
  122. package/dist/stories/Input.stories.js.map +0 -1
  123. package/dist/stories/InputSelect.stories.js +0 -28
  124. package/dist/stories/InputSelect.stories.js.map +0 -1
  125. package/dist/stories/InputTextArea.stories.js +0 -23
  126. package/dist/stories/InputTextArea.stories.js.map +0 -1
  127. package/dist/stories/MiniTag.stories.js +0 -44
  128. package/dist/stories/MiniTag.stories.js.map +0 -1
  129. package/dist/stories/Playground.stories.js +0 -14
  130. package/dist/stories/Playground.stories.js.map +0 -1
  131. package/dist/stories/ProgressBar.stories.js +0 -21
  132. package/dist/stories/ProgressBar.stories.js.map +0 -1
  133. package/dist/stories/RadioButton.stories.js +0 -36
  134. package/dist/stories/RadioButton.stories.js.map +0 -1
  135. package/dist/stories/RadioButtonSimple.stories.js +0 -40
  136. package/dist/stories/RadioButtonSimple.stories.js.map +0 -1
  137. package/dist/stories/SimpleAlert.stories.js +0 -19
  138. package/dist/stories/SimpleAlert.stories.js.map +0 -1
  139. package/dist/stories/Slider.stories.js +0 -70
  140. package/dist/stories/Slider.stories.js.map +0 -1
  141. package/dist/stories/Switch.stories.js +0 -35
  142. package/dist/stories/Switch.stories.js.map +0 -1
  143. package/dist/stories/TabHeader.stories.js +0 -48
  144. package/dist/stories/TabHeader.stories.js.map +0 -1
  145. package/dist/stories/TableResults.stories.js +0 -717
  146. package/dist/stories/TableResults.stories.js.map +0 -1
  147. package/dist/stories/TagScope.stories.js +0 -16
  148. package/dist/stories/TagScope.stories.js.map +0 -1
  149. package/dist/stories/TestimonialCard.stories.js +0 -24
  150. package/dist/stories/TestimonialCard.stories.js.map +0 -1
  151. package/dist/stories/Toast.stories.js +0 -51
  152. package/dist/stories/Toast.stories.js.map +0 -1
  153. package/dist/stories/Toggle.stories.js +0 -42
  154. package/dist/stories/Toggle.stories.js.map +0 -1
  155. package/dist/stories/Tooltip.stories.js +0 -108
  156. package/dist/stories/Tooltip.stories.js.map +0 -1
  157. package/dist/util/GeneralFunctions.js +0 -29
  158. package/dist/util/GeneralFunctions.js.map +0 -1
  159. package/dist/util/imageLoader.js +0 -52
  160. package/dist/util/imageLoader.js.map +0 -1
  161. package/postcss.config.js +0 -8
  162. package/src/assets/images/multifamily-units.svg +0 -10
  163. package/src/assets/images/policy-studio.svg +0 -15
  164. package/src/components/playground/PsScrollBar.vue +0 -320
  165. package/src/contents/ComparisonData.ts +0 -378
  166. package/src/contents/FlexibleData.ts +0 -502
  167. package/src/contents/ResultsData.ts +0 -531
  168. package/src/stories/Accordion.stories.ts +0 -59
  169. package/src/stories/BadgeWithIcon.stories.ts +0 -31
  170. package/src/stories/BarChart.stories.ts +0 -17
  171. package/src/stories/Breadcrumb.stories.ts +0 -22
  172. package/src/stories/Button.stories.ts +0 -48
  173. package/src/stories/Button.vue +0 -59
  174. package/src/stories/CardInfos.stories.ts +0 -15
  175. package/src/stories/ChartLegend.stories.ts +0 -15
  176. package/src/stories/Checkbox.stories.ts +0 -45
  177. package/src/stories/CheckboxSimple.stories.ts +0 -49
  178. package/src/stories/Chips.stories.ts +0 -33
  179. package/src/stories/ClimateZoneBadge.stories.ts +0 -18
  180. package/src/stories/Colors.mdx +0 -70
  181. package/src/stories/CostEffectBar.stories.ts +0 -24
  182. package/src/stories/Datatable.stories.ts +0 -53
  183. package/src/stories/DateCardInfo.stories.ts +0 -20
  184. package/src/stories/Dialog.stories.ts +0 -131
  185. package/src/stories/Draggable.stories.ts +0 -23
  186. package/src/stories/Dropdown.stories.ts +0 -100
  187. package/src/stories/DropdownList.stories.ts +0 -213
  188. package/src/stories/ElevationSystem.mdx +0 -41
  189. package/src/stories/Header.stories.ts +0 -42
  190. package/src/stories/Header.vue +0 -77
  191. package/src/stories/HighlightRippleDot.stories.ts +0 -16
  192. package/src/stories/Icon.stories.ts +0 -23
  193. package/src/stories/InlineSelector.stories.ts +0 -18
  194. package/src/stories/Input.stories.ts +0 -243
  195. package/src/stories/InputSelect.stories.ts +0 -31
  196. package/src/stories/InputTextArea.stories.ts +0 -25
  197. package/src/stories/Introduction.mdx +0 -211
  198. package/src/stories/MiniTag.stories.ts +0 -59
  199. package/src/stories/Playground.stories.ts +0 -16
  200. package/src/stories/ProgressBar.stories.ts +0 -24
  201. package/src/stories/RadioButton.stories.ts +0 -40
  202. package/src/stories/RadioButtonSimple.stories.ts +0 -43
  203. package/src/stories/SimpleAlert.stories.ts +0 -22
  204. package/src/stories/Slider.stories.ts +0 -79
  205. package/src/stories/Switch.stories.ts +0 -39
  206. package/src/stories/TabHeader.stories.ts +0 -57
  207. package/src/stories/TableResults.stories.ts +0 -728
  208. package/src/stories/TagScope.stories.ts +0 -17
  209. package/src/stories/TestimonialCard.stories.ts +0 -27
  210. package/src/stories/Toast.stories.ts +0 -52
  211. package/src/stories/Toggle.stories.ts +0 -48
  212. package/src/stories/Tooltip.stories.ts +0 -114
  213. package/src/stories/Typography.mdx +0 -212
  214. package/src/stories/assets/code-brackets.svg +0 -1
  215. package/src/stories/assets/colors.svg +0 -1
  216. package/src/stories/assets/comments.svg +0 -1
  217. package/src/stories/assets/direction.svg +0 -1
  218. package/src/stories/assets/flow.svg +0 -1
  219. package/src/stories/assets/plugin.svg +0 -1
  220. package/src/stories/assets/repo.svg +0 -1
  221. package/src/stories/assets/stackalt.svg +0 -1
  222. package/src/stories/button.css +0 -30
  223. package/src/stories/header.css +0 -32
  224. package/webpack.config.js +0 -36
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div
2
+ <div
3
3
  ref="tableWrapper"
4
4
  class="psui-el-table-results-wrapper"
5
5
  :class="`table-${layout}`"
@@ -8,10 +8,7 @@
8
8
  <table
9
9
  ref="table"
10
10
  class="psui-el-table-results"
11
- :class="[
12
- `layout-${layout}`,
13
- { 'is-sticky': isSticky }
14
- ]"
11
+ :class="[`layout-${layout}`, { 'is-sticky': isSticky.value }]"
15
12
  >
16
13
  <slot name="header" />
17
14
 
@@ -22,29 +19,27 @@
22
19
  :class="[
23
20
  getStatusClass(item),
24
21
  {
25
- 'is-disabled' : item.is_disabled,
26
- 'is-first' : item.deep == 0,
27
- 'psui-hidden' : checkRowIsCollapsed(item) || item.not_visible,
28
- 'is-last' : item.is_last,
29
- 'is-active' : selectedRow == item.id,
30
- 'removed-class' : (item.slug == 'removed_measures' || item.is_excluded) && layout == 'flexible',
31
- 'appended-row' : item.is_appended,
22
+ 'is-disabled': item.is_disabled,
23
+ 'is-first': item.deep == 0,
24
+ 'psui-hidden': checkRowIsCollapsed(item) || item.not_visible,
25
+ 'is-last': item.is_last,
26
+ 'is-active': selectedRow == item.id,
27
+ 'removed-class': (item.slug == 'removed_measures' || item.is_excluded) && layout == 'flexible',
28
+ 'appended-row': item.is_appended,
32
29
  },
33
- `${item.type}`
30
+ `${item.type}`,
34
31
  ]"
35
- :id=" item.id"
32
+ :id="item.id"
36
33
  :data-group="item.id"
37
- @mouseenter="onRowHover(index,item,'enter')"
38
- @mouseleave="onRowHover(false,item,'leave')"
34
+ @mouseenter="onRowHover(index, item, 'enter')"
35
+ @mouseleave="onRowHover(false, item, 'leave')"
39
36
  >
40
- <td
41
- :style="item.background_color ? `background-color: ${getBackgroundColor(item.background_color)}; transition: background-color 0.5s ease;` : ''"
42
- >
37
+ <td :style="item.background_color ? `background-color: ${getBackgroundColor(item.background_color)}; transition: background-color 0.5s ease;` : ''">
43
38
  <div class="psui-flex psui-relative">
44
39
  <div
45
40
  v-tooltip="{
46
- classes:'layout-gray-50',
47
- content: item.remove_add_tooltip
41
+ classes: 'layout-gray-50',
42
+ content: item.remove_add_tooltip,
48
43
  }"
49
44
  >
50
45
  <PsIcon
@@ -53,13 +48,13 @@
53
48
  class="psui-flex psui-text-gray-40 pl-4 psui-cursor-pointer leading-none hover:psui-text-blue-60 transition-all"
54
49
  size="15"
55
50
  display="flex"
56
- @click="$emit('removeOrAddButtonChange', item, $event)"
51
+ @click.native="emit('removeOrAddButtonChange', item, $event)"
57
52
  />
58
- </div>
53
+ </div>
59
54
  <div
60
55
  class="psui-flex psui-items-center psui-space-x-3"
61
- :style="{paddingLeft: `${item.deep * 16}px`}"
62
- >
56
+ :style="{ paddingLeft: `${item.deep * 16}px` }"
57
+ >
63
58
  <PsIcon
64
59
  v-if="(!item.last_deep || item.type === 'total') && !item.is_appended"
65
60
  icon="expand_more"
@@ -67,11 +62,12 @@
67
62
  class="actions-button psui-transition psui-transform psui-cursor-pointer"
68
63
  :icon-classes="item.is_disabled ? 'psui-text-gray-40' : getIconClasses(item)"
69
64
  display="flex"
70
- :class="[checkRowIsVisible(item) ? 'psui-rotate-0' : 'psui--rotate-90',
71
- { 'psui--rotate-90': item.is_disabled },
72
- { 'psui-pointer-events-none psui--rotate-90' : item.items.length == 0}
65
+ :class="[
66
+ checkRowIsVisible(item) ? 'psui-rotate-0' : 'psui--rotate-90',
67
+ { 'psui--rotate-90': item.is_disabled },
68
+ { 'psui-pointer-events-none psui--rotate-90': item.items.length == 0 },
73
69
  ]"
74
- @click="onCollapse(item, $event)"
70
+ @click.native="onCollapse(item, $event)"
75
71
  />
76
72
 
77
73
  <div v-if="item.is_appended">
@@ -80,13 +76,13 @@
80
76
  </span>
81
77
  </div>
82
78
 
83
- <div
79
+ <div
84
80
  v-else-if="item.is_disabled || item.tooltip_text"
85
81
  class="psui-inline-flex psui-cursor-default sticky"
86
- :class="{ 'is-last-deep' : item.last_deep }"
82
+ :class="{ 'is-last-deep': item.last_deep }"
87
83
  v-tooltip="getTooltipContent(item)"
88
84
  >
89
- <div class="flex psui-items-center psui-relative ">
85
+ <div class="flex psui-items-center psui-relative">
90
86
  <PsIcon
91
87
  v-if="item.has_blocked_icon"
92
88
  icon="do_disturb_alt"
@@ -105,7 +101,7 @@
105
101
  size="14"
106
102
  class="psui-text-gray-40 psui-opacity-0 psui-transition psui-leading-none psui-cursor-pointer psui-ml-1"
107
103
  display="flex"
108
- @click="$eventBus.$emit('openDescriptionModal', { type: 'helper', slug: `table-results-${item.helper_slug}` })"
104
+ @click.native="$eventBus.$emit('openDescriptionModal', { type: 'helper', slug: `table-results-${item.helper_slug}` })"
109
105
  />
110
106
  </p>
111
107
  </div>
@@ -114,10 +110,7 @@
114
110
  <p
115
111
  v-else
116
112
  class="title opacity-100-childrens-on-hover"
117
- :class="[
118
- { 'psui-font-bold' : item.type == 'total' },
119
- { 'is-last-deep' : item.last_deep }
120
- ]"
113
+ :class="[{ 'psui-font-bold': item.type == 'total' }, { 'is-last-deep': item.last_deep }]"
121
114
  >
122
115
  {{ item.title }}
123
116
 
@@ -125,10 +118,10 @@
125
118
  v-if="item.has_helper"
126
119
  icon="info"
127
120
  size="14"
128
- :class="[{'psui-text-gray-50': item.tooltip_text}, {'psui-text-blue-60': !item.tooltip_text}]"
121
+ :class="[{ 'psui-text-gray-50': item.tooltip_text }, { 'psui-text-blue-60': !item.tooltip_text }]"
129
122
  class="psui-opacity-0 psui-transition psui-leading-none psui-cursor-pointer psui-ml-1"
130
123
  display="flex"
131
- @click="$eventBus.$emit('openDescriptionModal', { type: 'helper', slug: `table-results-${item.helper_slug}` })"
124
+ @click.native="$eventBus.$emit('openDescriptionModal', { type: 'helper', slug: `table-results-${item.helper_slug}` })"
132
125
  />
133
126
  </p>
134
127
 
@@ -140,11 +133,11 @@
140
133
  display="flex"
141
134
  />
142
135
  </div>
143
- <div
136
+ <div
144
137
  class="actions psui-space-x-3 flex justify-between"
145
138
  :style="{ paddingLeft: `${item.deep * 16}px` }"
146
139
  >
147
- <PsRichTooltip
140
+ <PsRichTooltip
148
141
  v-if="shouldShowIcon(item)"
149
142
  position="top"
150
143
  layout="gray"
@@ -158,13 +151,11 @@
158
151
  class="psui-flex psui-text-gray-40 psui-cursor-pointer leading-none hover:psui-text-blue-60 psui-gap-3 psui-px-5 psui-py-1 transition-all"
159
152
  size="18"
160
153
  display="flex"
161
- @click="executeCallback(item)"
154
+ @click.native="executeCallback(item)"
162
155
  />
163
156
  </template>
164
157
  <template #content>
165
- <p
166
- class="psui-font-bold psui-text-gray-80 psui-text-xsmall"
167
- >
158
+ <p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">
168
159
  {{ getText(item) }}
169
160
  </p>
170
161
  </template>
@@ -177,7 +168,7 @@
177
168
  position="custom"
178
169
  >
179
170
  <template #dropdownTrigger>
180
- <PsIcon
171
+ <PsIcon
181
172
  icon="more_horiz"
182
173
  size="18"
183
174
  class="psui-flex psui-text-gray-40 psui-cursor-pointer leading-none hover:psui-text-blue-60 psui-gap-3 psui-px-5 psui-py-1 transition-all"
@@ -195,11 +186,11 @@
195
186
  >
196
187
  <span class="psui-w-auto psui-text-small">{{ action.title }}</span>
197
188
  </li>
198
- </ul>
189
+ </ul>
199
190
  </template>
200
191
  </PsDropdown>
201
192
  </div>
202
- </div>
193
+ </div>
203
194
  </td>
204
195
 
205
196
  <template v-for="(columnGroup, indexColumn) of columnGroups">
@@ -211,12 +202,12 @@
211
202
  :data-test-id="column.key"
212
203
  :class="`column-${column.key}`"
213
204
  >
214
- <div
205
+ <div
215
206
  v-if="layout != 'comparison'"
216
207
  class="psui-space-x-2 psui-show-childrens-on-hover"
217
208
  :class="column.isCenteredContent ? 'psui-justify-center' : 'psui-justify-end'"
218
209
  >
219
- <PsTooltip v-if="isSelectedRow(column,item)">
210
+ <PsTooltip v-if="isSelectedRow(column, item)">
220
211
  <template #trigger>
221
212
  <PsIcon
222
213
  icon="close"
@@ -224,7 +215,7 @@
224
215
  class="psui-cursor-pointer"
225
216
  icon-classes="psui-text-blue-60 psui-leading-none psui-transition"
226
217
  display="flex"
227
- @click="onCloseSelectRow(item,column)"
218
+ @click.native="onCloseSelectRow(item, column)"
228
219
  />
229
220
  </template>
230
221
  <template #content>
@@ -233,8 +224,10 @@
233
224
  </PsTooltip>
234
225
 
235
226
  <PsTooltip
236
- v-else-if="column.hasProjections && !item.is_disabled && item.disable_projection_select !== true && layout != 'flexible' ||
237
- column.hasProjections && item.disable_projection_select != true && item.deep != 0 && layout == 'flexible'"
227
+ v-else-if="
228
+ (column.hasProjections && !item.is_disabled && item.disable_projection_select !== true && layout != 'flexible') ||
229
+ (column.hasProjections && item.disable_projection_select != true && item.deep != 0 && layout == 'flexible')
230
+ "
238
231
  >
239
232
  <template #trigger>
240
233
  <PsIcon
@@ -243,7 +236,7 @@
243
236
  class="psui-cursor-pointer"
244
237
  icon-classes="psui-text-blue-60 psui-opacity-0 psui-leading-none psui-transition"
245
238
  display="flex"
246
- @click="onSelectRow(item, column, $event)"
239
+ @click.native="onSelectRow(item, column, $event)"
247
240
  />
248
241
  </template>
249
242
  <template #content>
@@ -255,9 +248,7 @@
255
248
  v-if="!column.isSwitch"
256
249
  >
257
250
  <template v-if="column.hasScoreHelper">
258
- <PsTooltip
259
- layout="blue"
260
- >
251
+ <PsTooltip layout="blue">
261
252
  <template #trigger>
262
253
  {{ getItemContent(column, item) }}
263
254
  </template>
@@ -287,15 +278,15 @@
287
278
  />
288
279
  <div
289
280
  v-if="column.isSwitch && item.data[column.key] != null"
290
- class="psui-inline-flex"
281
+ class="psui-inline-flex"
291
282
  v-tooltip="{
292
283
  content: item.tooltip_text ? `<p class='psui-text-white psui-text-xsmall psui-font-bold'>${item.tooltip_text}</p>` : false,
293
- classes: 'layout-blue'
284
+ classes: 'layout-blue',
294
285
  }"
295
286
  >
296
287
  <div class="flex psui-items-center psui-relative">
297
288
  <span
298
- v-if="item.has_flag"
289
+ v-if="item.has_flag"
299
290
  class="psui-w-2 psui-h-2 psui-bg-yellow-20 psui-absolute psui--right-2 psui--top-2 psui-rounded-md"
300
291
  />
301
292
  <PsSwitch
@@ -303,26 +294,32 @@
303
294
  :value="item.data[column.key]"
304
295
  :background-color="switchButtonBackgroundColor"
305
296
  class="psui-justify-self-center"
306
- :class="{'psui-pointer-events-none':preventClickOnSwitchButtons}"
297
+ :class="{ 'psui-pointer-events-none': preventClickOnSwitchButtons }"
307
298
  size="small"
308
- @change="$emit('switchButtonItemChanged', item, $event)"
299
+ @change="emit('switchButtonItemChanged', item, $event)"
309
300
  />
310
301
  </div>
311
302
  </div>
312
303
  </div>
313
-
304
+
314
305
  <!-- only comparison layout -->
315
306
  <div v-else>
316
307
  <div class="psui-py-4 psui-px-6">
317
- <PsTagScope
308
+ <PsTagScope
318
309
  v-if="column.renderType && column.renderType == 'tag_scope'"
319
310
  :included="item.data[column.key] == true"
320
311
  />
321
312
 
322
- <PsBarChart
313
+ <PsBarChart
323
314
  v-else-if="item.data[column.key] != 0 && column.renderType && column.renderType == 'bar_chart'"
324
315
  :show-number="item.data[column.key] != 0 ? true : false"
325
- :total="formatFunction ? formatFunction(column.key, item.data[column.key], item.data) == '--' ? 0 : formatFunction(column.key, item.data[column.key], item.data) : item.data[column.key]"
316
+ :total="
317
+ formatFunction
318
+ ? formatFunction(column.key, item.data[column.key], item.data) == '--'
319
+ ? 0
320
+ : formatFunction(column.key, item.data[column.key], item.data)
321
+ : item.data[column.key]
322
+ "
326
323
  :fill-width="getPsBarChartWidth(column.key, item.data[column.key])"
327
324
  />
328
325
 
@@ -343,8 +340,8 @@
343
340
  </div>
344
341
  </template>
345
342
 
346
- <script>
347
- import { eventBus } from '../../../.storybook/eventBus'
343
+ <script setup>
344
+ import eventBus from '../../util/eventBus'
348
345
  import PsRichTooltip from '../tooltip/PsRichTooltip.vue'
349
346
  import PsIcon from '../ui/PsIcon.vue'
350
347
  import PsProgressBar from '../badges-and-tags/PsProgressBar.vue'
@@ -354,415 +351,412 @@ import PsTooltip from '../tooltip/PsTooltip.vue'
354
351
  import PsSwitch from '../controls/PsSwitch.vue'
355
352
  import tailwindConfig from '../../../tailwind.config'
356
353
 
357
- export const tableLayout = ['results', 'comparison', 'flexible']
358
-
359
- export default {
360
- name: 'PsTableResults',
361
- components: {
362
- PsProgressBar,
363
- PsIcon,
364
- PsRichTooltip,
365
- PsTagScope,
366
- PsBarChart,
367
- PsTooltip, PsSwitch
368
- },
369
- props: {
370
- /**
371
- * It sets the layout of the table. eg: results or comparison
372
- */
373
- layout: {
374
- type: String,
375
- default: 'results',
376
- validator: (value) => {
377
- return tableLayout.indexOf(value) !== -1
378
- }
379
- },
380
- /**
381
- * It sets the max-height to table.
382
- */
383
- tableMaxHeight: {
384
- type: String,
385
- default: '540px'
386
- },
387
- /**
388
- * It sets if the lines should start collapsed.
389
- */
390
- showRowsCollapsed: {
391
- type: Boolean,
392
- default: true
393
- },
394
- /**
395
- * It sets the format function to display values.
396
- */
397
- formatFunction: {
398
- type: Function
399
- },
400
- /**
401
- * It sets the disabled texts conditionals.
402
- */
403
- disabledText: {
404
- type: String
405
- },
406
- /**
407
- * It sets the hidden items.
408
- */
409
- hiddenItems: {
410
- type: Array,
411
- default() {
412
- return []
413
- }
414
- },
415
- /**
416
- * It sets the hidden items index.
417
- */
418
- itemsHiddenIndexes: {
419
- type: [Array, undefined],
420
- default: undefined
421
- },
422
- /**
423
- * It sets the values which will be use to render the body.
424
- */
425
- summaryData: {
426
- type: Array,
427
- default() {
428
- return []
429
- }
430
- },
431
- /**
432
- * It sets the values which will be use to render the body.
433
- */
434
- columnGroups: {
435
- type: Array,
436
- default() {
437
- return []
438
- }
439
- },
440
- /**
441
- * It sets the values which will be use to render the body.
442
- */
443
- existingColumnGroup: {
444
- type: Array,
445
- default() {
446
- return []
447
- }
448
- },
449
- /**
450
- * It sets the values which will be use to render the body.
451
- */
452
- rows: {
453
- type: Array,
454
- default() {
455
- return []
456
- }
457
- },
458
- /**
459
- * It sets if rows is collapsible.
460
- */
461
- isCollapsible: {
462
- type: Boolean,
463
- default: true
464
- },
465
- /**
466
- * It sets the level to show opened rows.
467
- */
468
- customLevelOpened: {
469
- type: Number,
470
- default: 1
471
- },
472
- /**
473
- * It sets the values which will be use to render the body.
474
- */
475
- policies: {
476
- type: Array,
477
- default() {
478
- return []
479
- }
480
- },
481
- switchButtonBackgroundColor:{
482
- type:String,
483
- },
484
- preventIsDisabledOnItemsValue:{
485
- type: Boolean,
486
- default: false
487
- },
488
- preventClickOnSwitchButtons:{
489
- type: Boolean,
490
- default: false
491
- }
492
- },
493
- data: () => ({
494
- collapsedRows : [],
495
- isHoveringRow : false,
496
- selectedRow : null,
497
- policyItemSelected: null,
498
- columnSelectedKey : null,
499
- isSticky: false
500
- }),
501
- computed: {
502
- getRows() {
503
- const rows = []
504
- for (let index = 0; index < this.summaryData.length; index++) {
505
- const item = this.summaryData[index]
506
- this.addRow(item, 0, `${index}`, rows)
507
- }
354
+ import { defineProps, ref, computed, watch, onMounted, onBeforeUnmount, defineEmits, getCurrentInstance } from 'vue'
508
355
 
509
- return rows
356
+ const props = defineProps({
357
+ /**
358
+ * It sets the layout of the table. eg: results or comparison
359
+ */
360
+ layout: {
361
+ type: String,
362
+ default: 'results',
363
+ validator: (value) => {
364
+ return ['results', 'comparison', 'flexible'].indexOf(value) !== -1
510
365
  },
511
366
  },
512
- watch: {
513
- getRows: {
514
- deep: true,
515
- immediate: true,
516
- handler: function () {
517
- this.setCollapsedRows()
518
- }
519
- },
520
- itemsHiddenIndexes() {
521
- this.setCollapsedRows()
522
- },
523
- showRowsCollapsed() {
524
- this.setCollapsedRows()
525
- }
367
+ /**
368
+ * It sets the max-height to table.
369
+ */
370
+ tableMaxHeight: {
371
+ type: String,
372
+ default: '540px',
526
373
  },
527
- mounted () {
528
- this.setCollapsedRows()
529
- this.$refs.tableWrapper.addEventListener('scroll', this.handleTableScroll)
530
- eventBus.$on('resetPolicyImpactItemSelected', (item, columnKey = 'forecast_emissions_savings') => {
531
- eventBus.$emit('setPolicyItemSelected', { item, columnSelectedKey: columnKey })
532
- this.selectedRow = null
533
- })
374
+ /**
375
+ * It sets if the lines should start collapsed.
376
+ */
377
+ showRowsCollapsed: {
378
+ type: Boolean,
379
+ default: true,
534
380
  },
535
- beforeUnmount() {
536
- eventBus.$off('resetPolicyImpactItemSelected')
537
- this.$refs.tableWrapper.removeEventListener('scroll', this.handleTableScroll)
381
+ /**
382
+ * It sets the format function to display values.
383
+ */
384
+ formatFunction: {
385
+ type: Function,
386
+ default: () => '',
538
387
  },
539
- methods: {
540
- getHoveringRowColor(item){
541
- return !item.is_disabled && item.deep != 0 ? '#ECF7FB' : item.is_disabled && item.deep != 0 ? '#E6ECF2' : ''
388
+ /**
389
+ * It sets the disabled texts conditionals.
390
+ */
391
+ disabledText: {
392
+ type: String,
393
+ default: '',
394
+ },
395
+ /**
396
+ * It sets the hidden items.
397
+ */
398
+ hiddenItems: {
399
+ type: Array,
400
+ default() {
401
+ return []
542
402
  },
543
- setCollapsedRows() {
544
- let newRowsCollpased = [...(this.itemsHiddenIndexes || [])]
545
-
546
- if ( this.itemsHiddenIndexes && this.layout != 'flexible' ) return
547
-
548
- if ( this.showRowsCollapsed || this.layout == 'flexible' ) {
549
-
550
- this.getRows.forEach(element => {
551
- const matchForAll = Boolean( element?.items?.length && ( this.customLevelOpened == null || element.index.split('-').length > this.customLevelOpened))
552
- const matchForFlexibleLayout = Boolean(element.isCollapsed === true)
553
- if (matchForAll || matchForFlexibleLayout) {
554
- newRowsCollpased.push(element.index)
555
- }
556
- })
557
- }
558
-
559
- // else {
560
- // if ( this.itemsHiddenIndexes ) {
561
- // this.collapsedRows = [...this.itemsHiddenIndexes]
562
- // return
563
- // }
564
-
565
- // if ( this.showRowsCollapsed ) {
566
- // this.getRows.forEach(element => {
567
- // if ( element?.items?.length && ( this.customLevelOpened == null || element.index.split('-').length > this.customLevelOpened)) {
568
- // newRowsCollpased.push(element.index)
569
- // }
570
- // })
571
- // }
572
- // }
573
-
574
- this.collapsedRows = newRowsCollpased
403
+ },
404
+ /**
405
+ * It sets the hidden items index.
406
+ */
407
+ itemsHiddenIndexes: {
408
+ type: [Array, undefined],
409
+ default: undefined,
410
+ },
411
+ /**
412
+ * It sets the values which will be use to render the body.
413
+ */
414
+ summaryData: {
415
+ type: Array,
416
+ default() {
417
+ return []
575
418
  },
576
- getIconClasses(item) {
577
- return this.checkRowIsVisible(item) ? 'psui-text-gray-40' : 'psui-text-blue-60'
419
+ },
420
+ /**
421
+ * It sets the values which will be use to render the body.
422
+ */
423
+ columnGroups: {
424
+ type: Array,
425
+ default() {
426
+ return []
578
427
  },
579
- addRow(item, deep = 0, index, rows) {
580
- item.deep = deep
581
- item.index = index
582
- rows.push(item)
583
- item.last_deep = item.items ? false : true
584
- if (item.items) {
585
- const items_child = [...item.items]
586
- for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
587
- const item_child = items_child[indexChild]
588
- item_child.is_last = indexChild + 1 === items_child.length ? true : false
589
- this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
590
- }
591
- }
428
+ },
429
+ /**
430
+ * It sets the values which will be use to render the body.
431
+ */
432
+ existingColumnGroup: {
433
+ type: Array,
434
+ default() {
435
+ return []
592
436
  },
593
- checkRowIsVisible(item) {
594
- return this.collapsedRows.indexOf(item.index) < 0
437
+ },
438
+ /**
439
+ * It sets the values which will be use to render the body.
440
+ */
441
+ rows: {
442
+ type: Array,
443
+ default() {
444
+ return []
595
445
  },
596
- checkRowIsCollapsed(item) {
597
- let isHidden = false
598
- for (let index = 0; index < this.collapsedRows.length; index++) {
599
- const item_hidden = this.collapsedRows[index]
600
- if (item.index.startsWith(`${item_hidden}-`)) {
601
- isHidden = true
602
- break
603
- }
604
- }
605
- return isHidden
446
+ },
447
+ /**
448
+ * It sets if rows is collapsible.
449
+ */
450
+ isCollapsible: {
451
+ type: Boolean,
452
+ default: true,
453
+ },
454
+ /**
455
+ * It sets the level to show opened rows.
456
+ */
457
+ customLevelOpened: {
458
+ type: Number,
459
+ default: 1,
460
+ },
461
+ /**
462
+ * It sets the values which will be use to render the body.
463
+ */
464
+ policies: {
465
+ type: Array,
466
+ default() {
467
+ return []
606
468
  },
607
- onCollapse(item, $event) {
608
- if(this.itemsHiddenIndexes && this.itemsHiddenIndexes.some(it => it == item.index.toString()) && this.layout == 'flexible') {
609
- return
610
- }
469
+ },
470
+ switchButtonBackgroundColor: {
471
+ type: String,
472
+ default: '',
473
+ },
474
+ preventIsDisabledOnItemsValue: {
475
+ type: Boolean,
476
+ default: false,
477
+ },
478
+ preventClickOnSwitchButtons: {
479
+ type: Boolean,
480
+ default: false,
481
+ },
482
+ })
611
483
 
612
- const index = this.collapsedRows.indexOf(item.index)
613
-
614
- if(index > -1) {
615
- this.collapsedRows.splice(index, 1)
616
- delete item.isCollapsed
617
- } else {
618
- this.collapsedRows.push(item.index)
619
- item.isCollapsed = true
620
- }
621
- this.$forceUpdate()
622
-
623
- this.$emit('collapse-row', this.collapsedRows, $event)
624
- },
625
- onRowHover(index, item, type) {
626
- const parent = document.getElementById(`${item.id}`)
627
- const children = parent?.children
628
-
629
- if (type == 'enter' && item.index != 0 && item.deep != 0 && this.layout == 'flexible') {
630
- for (let i = 0; i < children.length; i++) {
631
- children[i].classList.add('hover-color')
632
- }
633
- } else if(parent) {
634
- parent.querySelectorAll('.hover-color').forEach(child => {
635
- child.classList.remove('hover-color')
636
- })
637
- }
484
+ const emit = defineEmits(['policy-selected', 'collapse-row', 'switchButtonItemChanged', 'removeOrAddButtonChange'])
638
485
 
639
- this.isHoveringRow = index
640
- },
641
- getIgnoreDialogIcon(item){
642
- return !this.shouldShowIcon(item) || item.actions[0].ignoreDialog
643
- },
644
- shouldShowIcon(item) {
645
- if(item?.actions?.length === 1) return true
646
- else return false
647
- },
648
- shouldShowDropdown(item) {
649
- if(item?.actions?.length > 1) return true
650
- else return false
651
- },
652
- getIcon(item) {
653
- if(item?.actions?.length === 1) return item.actions[0].icon
654
- },
655
- getText(item) {
656
- if(item?.actions?.length === 1) return item.actions[0].text
657
- },
658
- getItemContent(column, item) {
659
- if ( column.isSwitch ) return
660
-
661
- if (this.formatFunction && !item.is_disabled || this.preventIsDisabledOnItemsValue) {
662
- return this.formatFunction(column.key, item.data[column.key], item.data, item.study_id)
663
- } else if (item.is_disabled) {
664
- return '--'
665
- } else {
666
- return item.data[column.key]
667
- }
668
- },
669
- executeCallback(item, action) {
670
- if(item?.actions?.length === 1) item.actions[0].callback(item)
671
- else action?.callback(item)
672
-
673
- Object.values(this.$refs).flat(Infinity).forEach(( component => {
674
- if(component?.$options?._componentTag == 'PsDropdown'){
675
- component.close()
676
- }}))
677
- },
678
- getStatusClass(item) {
679
- return this.checkRowIsVisible(item) ? 'opened' : 'closed'
680
- },
681
- onSelectRow(item, column, $event) {
682
- if(this.layout != 'flexible') {
683
- this.selectedRow = item.id
684
- this.policyItemSelected = { ...item }
685
- delete this.policyItemSelected.items
686
- this.columnSelectedKey = column.key
687
- }
688
- this.$emit('policy-selected', { item: item, column: column }, $event)
689
- },
690
- onCloseSelectRow(item, column) {
691
- eventBus.$emit('resetPolicyImpactItemSelected', item, column)
692
- },
693
- isSelectedRow(column,item) {
694
- if(!item.id){
695
- return this.selectedRow === item.id && this.columnSelectedKey == column.key
696
- }
697
- return column.hasProjections && !item.is_disabled && this.selectedRow == item.id && this.columnSelectedKey == column.key
698
- },
699
- getBackgroundColor(value) {
700
- if(value && value.includes('psui-bg-')) {
701
- return tailwindConfig.theme.colors[value.replace('psui-bg-', '')]
702
- }
703
- return value || '#ffffff'
704
- },
705
- getTooltipContent(item) {
706
- let content = {
707
- classes:'layout-gray',
708
- content:''
709
- }
486
+ const collapsedRows = ref([])
487
+ const isHoveringRow = ref(false)
488
+ const selectedRow = ref(null)
489
+ const policyItemSelected = ref(null)
490
+ const columnSelectedKey = ref(null)
491
+ const isSticky = ref(false)
492
+ const tableWrapper = ref(null)
493
+ const instance = getCurrentInstance()
710
494
 
711
- if(item.tooltip_text && this.layout == 'flexible') {
712
- content.classes = 'layout-blue'
713
- content.content = item.tooltip_text
714
- }
715
- else if (item.tooltip_text) {
716
- content.content = `<p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">${item.tooltip_text}</p>`
717
- } else if (item.is_disabled) {
718
- content.content = `<p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">${item.title} buildings are <br>not allowed.</p>`
719
- }
720
- return content
721
- },
495
+ const addRow = (item, deep = 0, index, rows) => {
496
+ item.deep = deep
497
+ item.index = index
498
+ rows.push(item)
499
+ item.last_deep = item.items ? false : true
500
+ if (item.items) {
501
+ const items_child = [...item.items]
502
+ for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
503
+ const item_child = items_child[indexChild]
504
+ item_child.is_last = indexChild + 1 === items_child.length ? true : false
505
+ addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
506
+ }
507
+ }
508
+ }
722
509
 
723
- getPsBarChartWidth(key, value) {
724
- const max = Math.max(...this.getRows.map(item => item.data[key]))
725
- return (value * 100) / max
726
- },
727
- setVerticalStyleWhenScroolingForFlexibleLayout(tableWrapper){
728
- if(tableWrapper.scrollTop > 0 && tableWrapper.classList.contains('table-flexible')) {
729
- tableWrapper.getElementsByTagName('thead')[0].style.boxShadow = '0px 0px 8px rgba(0, 0, 0, 0.04), 0px 2px 5px rgba(0, 0, 0, 0.08)'
730
- } else if(tableWrapper.classList.contains('table-flexible')) {
731
- tableWrapper.getElementsByTagName('thead')[0].style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
732
- }
733
- },
734
- setHorizontalStyleWhenScrollingForFlexibleLayout(tableWrapper){
735
- const firstHeaderElement = tableWrapper.querySelector('thead > tr:first-child > th:first-child')
736
- const secondHeaderElment = tableWrapper.querySelector('thead > tr:not(:first-of-type) > th:nth-child(3)')
737
- const getAllOtherBodyElements = tableWrapper.querySelectorAll( 'tbody > tr > td:nth-child(3)')
738
-
739
- if (tableWrapper.scrollLeft > 0 && tableWrapper.classList.contains('table-flexible')) {
740
- firstHeaderElement.classList.add('pseudo-line')
741
- secondHeaderElment.style.boxShadow = 'inset -1px 0px 0px #D6DDE5'
742
- getAllOtherBodyElements.forEach(element => {
743
- element.style.boxShadow = 'inset -1px 0px 0px #D6DDE5'
744
- })
745
- } else if(tableWrapper.classList.contains('table-flexible')) {
746
- firstHeaderElement.classList.remove('pseudo-line')
747
- secondHeaderElment.style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
748
- getAllOtherBodyElements.forEach(element => {
749
- element.style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
750
- })
751
- }
752
- },
753
- handleTableScroll() {
754
- const tableWrapper = this.$refs.tableWrapper
510
+ const getRows = computed(() => {
511
+ const rows = []
512
+ for (let index = 0; index < props.summaryData.length; index++) {
513
+ const item = props.summaryData[index]
514
+ addRow(item, 0, `${index}`, rows)
515
+ }
516
+ return rows
517
+ })
518
+
519
+ watch(
520
+ () => getRows.value,
521
+ () => {
522
+ setCollapsedRows()
523
+ },
524
+ { deep: true },
525
+ { immediate: true }
526
+ )
527
+
528
+ watch(
529
+ ()=> props.itemsHiddenIndexes,
530
+ () => {
531
+ setCollapsedRows()
532
+ })
533
+
534
+ watch(
535
+ ()=>props.showRowsCollapsed,
536
+ () => {
537
+ setCollapsedRows()
538
+ })
539
+
540
+ onMounted(() => {
541
+ setCollapsedRows()
542
+ tableWrapper.value.addEventListener('scroll', handleTableScroll)
543
+ eventBus.$on('resetPolicyImpactItemSelected', (item, columnKey = 'forecast_emissions_savings') => {
544
+ eventBus.$emit('setPolicyItemSelected', { item, columnSelectedKey: columnKey })
545
+ selectedRow.value = null
546
+ })
547
+ })
755
548
 
756
- this.setVerticalStyleWhenScroolingForFlexibleLayout(tableWrapper)
757
- this.setHorizontalStyleWhenScrollingForFlexibleLayout(tableWrapper)
549
+ onBeforeUnmount(() => {
550
+ eventBus.$off('resetPolicyImpactItemSelected')
551
+ tableWrapper.value.removeEventListener('scroll', handleTableScroll)
552
+ })
758
553
 
759
- if (tableWrapper.scrollLeft > 0) {
760
- this.isSticky = true
761
- } else {
762
- this.isSticky = false
554
+ const setCollapsedRows = () => {
555
+ let newRowsCollpased = [...(props.itemsHiddenIndexes || [])]
556
+
557
+ if (props.itemsHiddenIndexes && props.layout != 'flexible') return
558
+ if (props.showRowsCollapsed || props.layout == 'flexible') {
559
+ getRows.value.forEach((element) => {
560
+ const matchForAll = Boolean(element?.items?.length && (props.customLevelOpened == null || element.index.split('-').length > props.customLevelOpened))
561
+ const matchForFlexibleLayout = Boolean(element.isCollapsed === true)
562
+ if (matchForAll || matchForFlexibleLayout) {
563
+ newRowsCollpased.push(element.index)
763
564
  }
565
+ })
566
+ }
567
+
568
+ collapsedRows.value = newRowsCollpased
569
+ }
570
+
571
+ const getIconClasses = (item) => {
572
+ return checkRowIsVisible(item) ? 'psui-text-gray-40' : 'psui-text-blue-60'
573
+ }
574
+
575
+ const checkRowIsVisible = (item) => {
576
+ return collapsedRows.value.indexOf(item.index) < 0
577
+ }
578
+
579
+ const checkRowIsCollapsed = (item) => {
580
+ let isHidden = false
581
+ for (let index = 0; index < collapsedRows.value.length; index++) {
582
+ const item_hidden = collapsedRows.value[index]
583
+ if (item.index.startsWith(`${item_hidden}-`)) {
584
+ isHidden = true
585
+ break
764
586
  }
765
- },
587
+ }
588
+ return isHidden
589
+ }
590
+
591
+ const onCollapse = (item, $event) => {
592
+ if (props.itemsHiddenIndexes && props.itemsHiddenIndexes.some((it) => it == item.index.toString()) && props.layout == 'flexible') {
593
+ return
594
+ }
595
+ const index = collapsedRows.value.indexOf(item.index)
596
+
597
+ if (index > -1) {
598
+ collapsedRows.value.splice(index, 1)
599
+ delete item.isCollapsed
600
+ } else {
601
+ collapsedRows.value.push(item.index)
602
+ item.isCollapsed = true
603
+ }
604
+ instance?.proxy?.$forceUpdate()
605
+ emit('collapse-row', collapsedRows.value, $event)
606
+ }
607
+
608
+ const onRowHover = (index, item, type) => {
609
+ const parent = document.getElementById(`${item.id}`)
610
+ const children = parent?.children
611
+ if (type == 'enter' && item.index != 0 && item.deep != 0 && props.layout == 'flexible') {
612
+ for (let i = 0; i < children.length; i++) {
613
+ children[i].classList.add('hover-color')
614
+ }
615
+ } else if (parent) {
616
+ parent.querySelectorAll('.hover-color').forEach((child) => {
617
+ child.classList.remove('hover-color')
618
+ })
619
+ }
620
+ isHoveringRow.value = index
621
+ }
622
+
623
+ const getIgnoreDialogIcon = (item) => {
624
+ return !shouldShowIcon(item) || item.actions[0].ignoreDialog
625
+ }
626
+
627
+ const shouldShowIcon = (item) => {
628
+ if (item?.actions?.length === 1) return true
629
+ else return false
630
+ }
631
+
632
+ const shouldShowDropdown = (item) => {
633
+ if (item?.actions?.length > 1) return true
634
+ else return false
635
+ }
636
+
637
+ const getIcon = (item) => {
638
+ if (item?.actions?.length === 1) return item.actions[0].icon
639
+ }
640
+
641
+ const getText = (item) => {
642
+ if (item?.actions?.length === 1) return item.actions[0].text
643
+ }
644
+
645
+ const getItemContent = (column, item) => {
646
+ if (column.isSwitch) return
647
+
648
+ if ((props.formatFunction && !item.is_disabled) || props.preventIsDisabledOnItemsValue) {
649
+ return props.formatFunction(column.key, item.data[column.key], item.data, item.study_id)
650
+ } else if (item.is_disabled) {
651
+ return '--'
652
+ } else {
653
+ return item.data[column.key]
654
+ }
655
+ }
656
+
657
+ const executeCallback = (item, action) => {
658
+ if (item?.actions?.length === 1) item.actions[0].callback(item)
659
+ else action?.callback(item)
660
+ Object.values(instance.proxy.$refs)
661
+ .flat(Infinity)
662
+ .forEach((component) => {
663
+ if (component?.$options?._componentTag == 'PsDropdown') {
664
+ component.close()
665
+ }
666
+ })
667
+ }
668
+
669
+ const getStatusClass = (item) => {
670
+ return checkRowIsVisible(item) ? 'opened' : 'closed'
671
+ }
672
+
673
+ const onSelectRow = (item, column, $event) => {
674
+ if (props.layout != 'flexible') {
675
+ selectedRow.value = item.id
676
+ policyItemSelected.value = { ...item }
677
+ delete policyItemSelected.value.items
678
+ columnSelectedKey.value = column.key
679
+ }
680
+ emit('policy-selected', { item: item, column: column }, $event)
681
+ }
682
+
683
+ const onCloseSelectRow = (item, column) => {
684
+ eventBus.$emit('resetPolicyImpactItemSelected', item, column)
685
+ }
686
+
687
+ const isSelectedRow = (column, item) => {
688
+ if (!item.id) {
689
+ return selectedRow.value === item.id && columnSelectedKey.value == column.key
690
+ }
691
+ return column.hasProjections && !item.is_disabled && selectedRow.value == item.id && columnSelectedKey.value == column.key
692
+ }
693
+
694
+ const getBackgroundColor = (value) => {
695
+ if (value && value.includes('psui-bg-')) {
696
+ return tailwindConfig.theme.colors[value.replace('psui-bg-', '')]
697
+ }
698
+ return value || '#ffffff'
699
+ }
700
+
701
+ const getTooltipContent = (item) => {
702
+ let content = {
703
+ classes: 'layout-gray',
704
+ content: '',
705
+ }
706
+ if (item.tooltip_text && props.layout == 'flexible') {
707
+ content.classes = 'layout-blue'
708
+ content.content = item.tooltip_text
709
+ } else if (item.tooltip_text) {
710
+ content.content = `<p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">${item.tooltip_text}</p>`
711
+ } else if (item.is_disabled) {
712
+ content.content = `<p class="psui-font-bold psui-text-gray-80 psui-text-xsmall">${item.title} buildings are <br>not allowed.</p>`
713
+ }
714
+ return content
715
+ }
716
+
717
+ const getPsBarChartWidth = (key, value) => {
718
+ const max = Math.max(...getRows.value.map((item) => item.data[key]))
719
+ return (value * 100) / max
720
+ }
721
+
722
+ const setVerticalStyleWhenScroolingForFlexibleLayout = (tableWrapper) => {
723
+ if (tableWrapper.scrollTop > 0 && tableWrapper.classList.contains('table-flexible')) {
724
+ tableWrapper.getElementsByTagName('thead')[0].style.boxShadow = '0px 0px 8px rgba(0, 0, 0, 0.04), 0px 2px 5px rgba(0, 0, 0, 0.08)'
725
+ } else if (tableWrapper.classList.contains('table-flexible')) {
726
+ tableWrapper.getElementsByTagName('thead')[0].style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
727
+ }
728
+ }
729
+
730
+ const setHorizontalStyleWhenScrollingForFlexibleLayout = (tableWrapper) => {
731
+ const firstHeaderElement = tableWrapper.querySelector('thead > tr:first-child > th:first-child')
732
+ const secondHeaderElment = tableWrapper.querySelector('thead > tr:not(:first-of-type) > th:nth-child(3)')
733
+ const getAllOtherBodyElements = tableWrapper.querySelectorAll('tbody > tr > td:nth-child(3)')
734
+ if (tableWrapper.scrollLeft > 0 && tableWrapper.classList.contains('table-flexible')) {
735
+ firstHeaderElement.classList.add('pseudo-line')
736
+ secondHeaderElment.style.boxShadow = 'inset -1px 0px 0px #D6DDE5'
737
+ getAllOtherBodyElements.forEach((element) => {
738
+ element.style.boxShadow = 'inset -1px 0px 0px #D6DDE5'
739
+ })
740
+ } else if (tableWrapper.classList.contains('table-flexible')) {
741
+ firstHeaderElement.classList.remove('pseudo-line')
742
+ secondHeaderElment.style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
743
+ getAllOtherBodyElements.forEach((element) => {
744
+ element.style.boxShadow = '0 0 0 rgba(0, 0, 0, 0)'
745
+ })
746
+ }
747
+ }
748
+
749
+ const handleTableScroll = () => {
750
+ setVerticalStyleWhenScroolingForFlexibleLayout(tableWrapper.value)
751
+ setHorizontalStyleWhenScrollingForFlexibleLayout(tableWrapper.value)
752
+ if (tableWrapper.value.scrollLeft > 0) {
753
+ isSticky.value = true
754
+ } else {
755
+ isSticky.value = false
756
+ }
766
757
  }
767
758
  </script>
768
- <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
759
+
760
+ <style>
761
+ /* Please, use the file src/assets/scss/components/PsTableResults.scss */
762
+ </style>