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