@policystudio/policy-studio-ui-vue 1.1.90-beta.5 → 1.1.90-beta.50

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 (160) hide show
  1. package/.eslintrc.js +2 -8
  2. package/.github/workflows/deploy-storybook.yml +4 -4
  3. package/.nvmrc +1 -0
  4. package/dist/css/psui_styles_output.css +6639 -0
  5. package/dist/index.d.ts +51 -0
  6. package/dist/index.js +106 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/util/GeneralFunctions.d.ts +3 -0
  9. package/dist/util/GeneralFunctions.js +35 -0
  10. package/dist/util/GeneralFunctions.js.map +1 -0
  11. package/dist/util/directives.d.ts +1 -0
  12. package/dist/util/directives.js +22 -0
  13. package/dist/util/directives.js.map +1 -0
  14. package/dist/util/imageLoader.d.ts +6 -0
  15. package/dist/util/imageLoader.js +52 -0
  16. package/dist/util/imageLoader.js.map +1 -0
  17. package/doc/.nvmrc +1 -0
  18. package/{.storybook → doc/.storybook}/main.ts +8 -2
  19. package/{.storybook → doc/.storybook}/preview.ts +2 -3
  20. package/doc/package-lock.json +22653 -0
  21. package/doc/package.json +71 -0
  22. package/{src → doc}/shims-vue.d.ts +0 -5
  23. package/{src → doc/src}/stories/Accordion.stories.ts +2 -3
  24. package/{src → doc/src}/stories/BadgeWithIcon.stories.ts +1 -1
  25. package/{src → doc/src}/stories/BarChart.stories.ts +1 -1
  26. package/{src → doc/src}/stories/Breadcrumb.stories.ts +1 -1
  27. package/doc/src/stories/Button.stories.ts +130 -0
  28. package/{src → doc/src}/stories/CardInfos.stories.ts +1 -1
  29. package/{src → doc/src}/stories/ChartLegend.stories.ts +1 -1
  30. package/{src → doc/src}/stories/Checkbox.stories.ts +1 -1
  31. package/{src → doc/src}/stories/CheckboxSimple.stories.ts +1 -1
  32. package/{src → doc/src}/stories/Chips.stories.ts +1 -4
  33. package/{src → doc/src}/stories/ClimateZoneBadge.stories.ts +2 -1
  34. package/doc/src/stories/Collapse.stories.ts +46 -0
  35. package/{src → doc/src}/stories/CostEffectBar.stories.ts +2 -1
  36. package/{src → doc/src}/stories/Datatable.stories.ts +5 -2
  37. package/{src → doc/src}/stories/DateCardInfo.stories.ts +1 -1
  38. package/{src → doc/src}/stories/Dialog.stories.ts +2 -2
  39. package/{src → doc/src}/stories/Draggable.stories.ts +3 -2
  40. package/{src → doc/src}/stories/Dropdown.stories.ts +4 -3
  41. package/{src → doc/src}/stories/DropdownList.stories.ts +4 -2
  42. package/{src → doc/src}/stories/HighlightRippleDot.stories.ts +3 -2
  43. package/{src → doc/src}/stories/Icon.stories.ts +3 -1
  44. package/{src → doc/src}/stories/InlineSelector.stories.ts +1 -1
  45. package/{src → doc/src}/stories/Input.stories.ts +7 -4
  46. package/{src → doc/src}/stories/InputSelect.stories.ts +3 -2
  47. package/{src → doc/src}/stories/InputTextArea.stories.ts +1 -1
  48. package/{src → doc/src}/stories/MiniTag.stories.ts +9 -2
  49. package/{src → doc/src}/stories/ProgressBar.stories.ts +3 -2
  50. package/{src → doc/src}/stories/RadioButton.stories.ts +2 -2
  51. package/{src → doc/src}/stories/RadioButtonSimple.stories.ts +1 -1
  52. package/{src → doc/src}/stories/SimpleAlert.stories.ts +3 -2
  53. package/{src → doc/src}/stories/Slider.stories.ts +6 -2
  54. package/{src → doc/src}/stories/Switch.stories.ts +2 -2
  55. package/{src → doc/src}/stories/TabHeader.stories.ts +6 -1
  56. package/{src → doc/src}/stories/TableResults.stories.ts +11 -7
  57. package/{src → doc/src}/stories/TagScope.stories.ts +3 -2
  58. package/{src → doc/src}/stories/TestimonialCard.stories.ts +3 -3
  59. package/{src → doc/src}/stories/Toast.stories.ts +2 -2
  60. package/{src → doc/src}/stories/Toggle.stories.ts +6 -3
  61. package/{src → doc/src}/stories/Tooltip.stories.ts +3 -3
  62. package/doc/tsconfig.json +17 -0
  63. package/package.json +13 -28
  64. package/scripts/gulp.js +11 -0
  65. package/src/assets/scss/base.scss +3 -34
  66. package/src/assets/scss/components/PsAccordion.scss +1 -1
  67. package/src/assets/scss/components/PsChips.scss +9 -3
  68. package/src/assets/scss/components/PsCollapse.scss +71 -0
  69. package/src/assets/scss/components/PsDataTable.scss +1 -1
  70. package/src/assets/scss/components/PsDropdownList.scss +1 -1
  71. package/src/assets/scss/components/PsTableResults.scss +28 -1
  72. package/src/assets/scss/components/PsTooltip.scss +2 -1
  73. package/src/components/accordion/PsAccordionItem.vue +88 -74
  74. package/src/components/badges-and-tags/PsBadgeWithIcon.vue +31 -34
  75. package/src/components/badges-and-tags/PsCardInfos.vue +39 -41
  76. package/src/components/badges-and-tags/PsChartLegend.vue +46 -51
  77. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +13 -19
  78. package/src/components/badges-and-tags/PsCostEffectBar.vue +24 -56
  79. package/src/components/badges-and-tags/PsDateCardInfo.vue +17 -18
  80. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -2
  81. package/src/components/badges-and-tags/PsMiniTag.vue +39 -41
  82. package/src/components/badges-and-tags/PsProgressBar.vue +72 -68
  83. package/src/components/badges-and-tags/PsTagScope.vue +17 -22
  84. package/src/components/badges-and-tags/PsTestimonialCard.vue +19 -26
  85. package/src/components/buttons/PsButton.vue +61 -62
  86. package/src/components/chips/PsChips.vue +112 -101
  87. package/src/components/collapse/PsCollapse.vue +124 -0
  88. package/src/components/controls/PsCheckbox.vue +84 -84
  89. package/src/components/controls/PsCheckboxSimple.vue +95 -95
  90. package/src/components/controls/PsDraggable.vue +53 -55
  91. package/src/components/controls/PsInlineSelector.vue +98 -99
  92. package/src/components/controls/PsRadioButton.vue +65 -58
  93. package/src/components/controls/PsRadioButtonSimple.vue +79 -75
  94. package/src/components/controls/PsSlider.vue +185 -176
  95. package/src/components/controls/PsSwitch.vue +51 -52
  96. package/src/components/controls/PsToggle.vue +52 -50
  97. package/src/components/data-graphics/PsBarChart.vue +18 -21
  98. package/src/components/datatable/PsDataTable.vue +56 -60
  99. package/src/components/datatable/PsDataTableItem.vue +13 -28
  100. package/src/components/forms/PsDropdown.vue +166 -162
  101. package/src/components/forms/PsDropdownList.vue +133 -130
  102. package/src/components/forms/PsInput.vue +154 -153
  103. package/src/components/forms/PsInputSelect.vue +91 -92
  104. package/src/components/forms/PsInputTextArea.vue +70 -71
  105. package/src/components/navigations/PsBreadcrumb.vue +25 -34
  106. package/src/components/notifications/PsDialog.vue +57 -56
  107. package/src/components/notifications/PsSimpleAlert.vue +27 -29
  108. package/src/components/notifications/PsToast.vue +40 -39
  109. package/src/components/table-results/PsTableResults.vue +461 -468
  110. package/src/components/table-results/PsTableResultsBody.vue +66 -67
  111. package/src/components/table-results/PsTableResultsHead.vue +70 -67
  112. package/src/components/table-results/PsTableResultsHeadComparison.vue +67 -64
  113. package/src/components/table-results/PsTableResultsHeadFlexible.vue +94 -67
  114. package/src/components/table-results/PsTableResultsRow.vue +55 -56
  115. package/src/components/tabs/PsTabHeader.vue +106 -100
  116. package/src/components/tooltip/PsDialogTooltip.vue +96 -101
  117. package/src/components/tooltip/PsRichTooltip.vue +41 -45
  118. package/src/components/tooltip/PsTooltip.vue +111 -116
  119. package/src/components/ui/PsDotLoader.vue +1 -5
  120. package/src/components/ui/PsIcon.vue +143 -132
  121. package/src/index.ts +60 -67
  122. package/src/tsconfig.json +12 -0
  123. package/src/types/index.d.ts +6 -0
  124. package/src/util/{GeneralFunctions.ts → GeneralFunctions.js} +12 -3
  125. package/src/util/directives.ts +24 -0
  126. package/src/util/{imageLoader.ts → imageLoader.js} +7 -0
  127. package/tailwind.config.js +1 -1
  128. package/tsconfig.json +18 -13
  129. package/.storybook/eventBus.ts +0 -26
  130. package/babel.config.js +0 -17
  131. package/dist/css/psui_styles.css +0 -4647
  132. package/postcss.config.js +0 -8
  133. package/src/components/playground/PsScrollBar.vue +0 -320
  134. package/src/stories/Button.stories.ts +0 -48
  135. package/src/stories/Button.vue +0 -59
  136. package/src/stories/Header.stories.ts +0 -41
  137. package/src/stories/Header.vue +0 -77
  138. package/src/stories/Playground.stories.ts +0 -16
  139. package/src/stories/button.css +0 -30
  140. package/src/stories/header.css +0 -32
  141. package/webpack.config.js +0 -22
  142. /package/{.storybook → doc/.storybook}/PolicyStudio.ts +0 -0
  143. /package/{.storybook → doc/.storybook}/manager.ts +0 -0
  144. /package/{src → doc/src}/assets/images/multifamily-units.svg +0 -0
  145. /package/{src → doc/src}/assets/images/policy-studio.svg +0 -0
  146. /package/{src → doc/src}/contents/ComparisonData.ts +0 -0
  147. /package/{src → doc/src}/contents/FlexibleData.ts +0 -0
  148. /package/{src → doc/src}/contents/ResultsData.ts +0 -0
  149. /package/{src → doc/src}/stories/Colors.mdx +0 -0
  150. /package/{src → doc/src}/stories/ElevationSystem.mdx +0 -0
  151. /package/{src → doc/src}/stories/Introduction.mdx +0 -0
  152. /package/{src → doc/src}/stories/Typography.mdx +0 -0
  153. /package/{src → doc/src}/stories/assets/code-brackets.svg +0 -0
  154. /package/{src → doc/src}/stories/assets/colors.svg +0 -0
  155. /package/{src → doc/src}/stories/assets/comments.svg +0 -0
  156. /package/{src → doc/src}/stories/assets/direction.svg +0 -0
  157. /package/{src → doc/src}/stories/assets/flow.svg +0 -0
  158. /package/{src → doc/src}/stories/assets/plugin.svg +0 -0
  159. /package/{src → doc/src}/stories/assets/repo.svg +0 -0
  160. /package/{src → doc/src}/stories/assets/stackalt.svg +0 -0
@@ -4,19 +4,18 @@
4
4
  <th
5
5
  v-for="columnGroup of header"
6
6
  :key="columnGroup.key"
7
- :colspan="columnGroup.columns.reduce( (prev, cur) => cur.isActive ? prev + 1 : prev, 0 )"
7
+ :colspan="columnGroup.columns.reduce((prev, cur) => (cur.isActive ? prev + 1 : prev), 0)"
8
8
  >
9
9
  <div class="psui-flex psui-space-x-1 psui-items-center psui-show-childrens-on-hover">
10
10
  <p class="title">
11
11
  {{ columnGroup.title }}
12
12
  </p>
13
13
  <PsIcon
14
- icon="info"
15
- size="18"
16
- class="psui-cursor-pointer"
17
- icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
14
+ icon="info_outline"
15
+ size="16"
16
+ class="psui-cursor-pointer psui-text-blue-40 hover:psui-text-blue-60 psui-opacity-0 psui-leading-none psui-transition"
18
17
  :style="{ display: 'flex' }"
19
- @click="$emit('click-column-group-helper', columnGroup, $event)"
18
+ @click="emit('click-column-group-helper', columnGroup, $event)"
20
19
  />
21
20
  </div>
22
21
  </th>
@@ -24,42 +23,63 @@
24
23
 
25
24
  <tr>
26
25
  <template v-for="(columnGroup, columnGroupIndex) of header">
27
- <th
28
- v-for="column of columnGroup.columns"
26
+ <th
27
+ v-for="column of columnGroup.columns"
29
28
  :key="`${columnGroup.key}-${column.key}`"
30
29
  :data-test-id="column.key"
31
30
  >
32
- <div
31
+ <div
33
32
  class="psui-flex psui-flex-col psui-justify-center"
34
33
  :class="columnGroupIndex == 0 ? 'psui-items-center' : 'psui-items-end'"
35
34
  :data-index="columnGroupIndex"
35
+ @mouseleave="emit('column-alert-hide', column, $event, false)"
36
36
  >
37
37
  <div class="psui-show-childrens-on-hover absolute-childrens psui-mb-px">
38
38
  <p
39
39
  class="title"
40
+ :class="{'is-warning-column': !!column.warning}"
40
41
  v-if="column.title"
41
42
  >
42
43
  {{ column.title }}
43
44
  </p>
45
+ <span
46
+ v-if="column.warning"
47
+ class="warning-svg-position"
48
+ @mouseover="emit('column-alert-show', column, $event, true)"
49
+ >
50
+ <span class="cursor-pointer">
51
+ <svg
52
+ width="10"
53
+ height="10"
54
+ viewBox="0 0 10 10"
55
+ fill="none"
56
+ >
57
+ <circle
58
+ cx="5"
59
+ cy="5"
60
+ r="4.5"
61
+ fill="#EDAB3E"
62
+ />
63
+ </svg>
64
+ </span>
65
+ </span>
44
66
 
45
67
  <PsIcon
46
- icon="info"
68
+ icon="info_outline"
47
69
  size="16"
48
- class="psui-cursor-pointer helper"
49
- icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
50
- :style="{ display: 'flex' }"
51
- @click="$emit('click-column-helper', column, $event)"
70
+ class="helper psui-cursor-pointer psui-text-gray-40 hover:psui-text-blue-60 psui-opacity-0 psui-leading-none psui-transition"
71
+ :style="{ display: 'flex', marginTop: '1px' }"
72
+ @click="emit('click-column-helper', column, $event)"
52
73
  />
53
-
74
+
54
75
  <PsIcon
55
76
  v-if="showOrder"
56
77
  :icon="orderDirection == 'asc' ? 'arrow_downward' : 'arrow_upward'"
57
78
  :type="orderDirection == 'asc' ? 'arrow_upward' : 'arrow_upward'"
58
79
  size="16"
59
- class="psui-cursor-pointer helper"
60
- icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
61
- :style="{ display: 'flex' }"
62
- @click="$emit('click-order-column', column)"
80
+ class="helper psui-cursor-pointer psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
81
+ :style="{ display: 'flex', marginTop: '1px' }"
82
+ @click="emit('click-order-column', column)"
63
83
  />
64
84
  </div>
65
85
  <p
@@ -75,55 +95,62 @@
75
95
  </thead>
76
96
  </template>
77
97
 
78
- <script>
98
+ <script setup>
79
99
  import PsIcon from '../ui/PsIcon.vue'
80
- export default {
81
- name: 'PsTableResultsHeadFlexible',
82
- components: { PsIcon },
83
- props: {
84
- /**
85
- * It sets the title for the first column.
86
- */
87
- firstColumnTitle: {
88
- type: String,
89
- default: ''
90
- },
91
- /**
92
- * It sets the description for the first column.
93
- */
94
- firstColumnDescription: {
95
- type: String,
96
- default: ''
97
- },
98
- /**
99
- * It sets the values which will be use to render the header.
100
- */
101
- header: {
102
- type: Array,
103
- required: true,
104
- default: () => {
105
- return []
106
- },
107
- },
108
- /**
109
- * this sets whether sorting will be displayed.
110
- */
111
- showOrder: {
112
- type: Boolean,
113
- default: false
114
- }
100
+
101
+ import { computed, getCurrentInstance } from 'vue'
102
+
103
+ defineProps({
104
+ /**
105
+ * It sets the title for the first column.
106
+ */
107
+ firstColumnTitle: {
108
+ type: String,
109
+ default: '',
115
110
  },
116
- computed: {
117
- columnsSelectedForStudy() {
118
- return this.$parent.columnsSelectedForStudy
119
- },
120
- orderColumn() {
121
- return this.$parent.orderColumn
122
- },
123
- orderDirection() {
124
- return this.$parent.orderDirection
111
+ /**
112
+ * It sets the description for the first column.
113
+ */
114
+ firstColumnDescription: {
115
+ type: String,
116
+ default: '',
117
+ },
118
+ /**
119
+ * It sets the values which will be use to render the header.
120
+ */
121
+ header: {
122
+ type: Array,
123
+ required: true,
124
+ default: () => {
125
+ return []
125
126
  },
126
- }
127
- }
127
+ },
128
+ /**
129
+ * this sets whether sorting will be displayed.
130
+ */
131
+ showOrder: {
132
+ type: Boolean,
133
+ default: false,
134
+ },
135
+ })
136
+
137
+ const emit = defineEmits(['click-column-group-helper', 'click-column-helper', 'click-order-column', 'column-alert-show', 'column-alert-hide'])
138
+
139
+ const parent = getCurrentInstance().proxy.$parent
140
+
141
+ const columnsSelectedForStudy = computed(() => {
142
+ return parent.columnsSelectedForStudy
143
+ })
144
+
145
+ const orderColumn = computed(() => {
146
+ return parent.orderColumn
147
+ })
148
+
149
+ const orderDirection = computed(() => {
150
+ return parent.orderDirection
151
+ })
128
152
  </script>
129
- <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
153
+
154
+ <style>
155
+ /* Please, use the file src/assets/scss/components/PsTableResults.scss */
156
+ </style>
@@ -10,9 +10,7 @@
10
10
  </p>
11
11
  </td>
12
12
 
13
- <template
14
- v-for="(columnGroup, indexColumn) of columnGroups"
15
- >
13
+ <template v-for="(columnGroup, indexColumn) of columnGroups">
16
14
  <td
17
15
  v-for="column of columnGroup.columns"
18
16
  :key="indexColumn + '-' + columnGroup.key + '-' + column.key"
@@ -26,64 +24,65 @@
26
24
  </tbody>
27
25
  </template>
28
26
 
29
- <script>
30
- export default {
31
- name: 'PsTableResultsRow',
32
- props: {
33
- /**
34
- * It sets the values which will be use to render the body.
35
- */
36
- summaryData: {
37
- type: Array,
38
- default() {
39
- return []
40
- }
41
- },
42
- /**
43
- * It sets the values which will be use to render the body.
44
- */
45
- columnGroups: {
46
- type: Array,
47
- default() {
48
- return []
49
- }
27
+ <script setup>
28
+ import { computed } from 'vue'
29
+
30
+ const props = defineProps({
31
+ /**
32
+ * It sets the values which will be use to render the body.
33
+ */
34
+ summaryData: {
35
+ type: Array,
36
+ default() {
37
+ return []
50
38
  },
51
- /**
52
- * It sets the values which will be use to render the body.
53
- */
54
- rows: {
55
- type: Array,
56
- default() {
57
- return []
58
- }
39
+ },
40
+ /**
41
+ * It sets the values which will be use to render the body.
42
+ */
43
+ columnGroups: {
44
+ type: Array,
45
+ default() {
46
+ return []
59
47
  },
60
48
  },
61
- computed: {
62
- getRows() {
63
- const rows = []
64
- for (let index = 0; index < this.summaryData.length; index++) {
65
- const item = this.summaryData[index]
66
- this.addRow(item, 0, `${index}`, rows)
67
- }
68
- return rows
69
- }
49
+ /**
50
+ * It sets the values which will be use to render the body.
51
+ */
52
+ rows: {
53
+ type: Array,
54
+ default() {
55
+ return []
56
+ },
70
57
  },
71
- methods: {
72
- addRow(item, deep = 0, index, rows) {
73
- item.deep = deep
74
- item.index = index
75
- rows.push(item)
76
- item.last_deep = item.items ? false : true
77
- if (item.items) {
78
- const items_child = [...item.items]
79
- for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
80
- const item_child = items_child[indexChild]
81
- item_child.is_last = indexChild + 1 === items_child.length ? true : false
82
- this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
83
- }
84
- }
58
+ })
59
+
60
+ const addRow = (item, deep = 0, index, rows) => {
61
+ item.deep = deep
62
+ item.index = index
63
+ rows.push(item)
64
+ item.last_deep = item.items ? false : true
65
+ if (item.items) {
66
+ const items_child = [...item.items]
67
+ for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
68
+ const item_child = items_child[indexChild]
69
+ item_child.is_last = indexChild + 1 === items_child.length ? true : false
70
+ addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
85
71
  }
86
72
  }
87
73
  }
74
+
75
+ const getRows = computed(() => {
76
+ const rows = []
77
+ for (let index = 0; index < props.summaryData.length; index++) {
78
+ const item = props.summaryData[index]
79
+ addRow(item, 0, `${index}`, rows)
80
+ }
81
+ return rows
82
+ })
83
+
88
84
  </script>
89
- <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
85
+
86
+ <style>
87
+ /* Please, use the file src/assets/scss/components/PsTableResults.scss */
88
+ </style>
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <div
3
- class="psui-el-tab-header"
4
- :class="[getComponentClass, `layout-${layout}`]"
2
+ <div
3
+ class="psui-el-tab-header"
4
+ :class="[getComponentClass, `layout-${layout}`]"
5
5
  role="group"
6
6
  >
7
7
  <template v-for="(item, index) in getItems">
@@ -16,9 +16,9 @@
16
16
  :key="item[keyValue] + index"
17
17
  type="button"
18
18
  @click="selectTab(item)"
19
- :class="getButtonClass(item)"
19
+ :class="getButtonClass(item).value"
20
20
  >
21
- <span>{{ item[keyLabel] }}</span>
21
+ <span>{{ item[keyLabel] }}</span>
22
22
  </button>
23
23
  </template>
24
24
  </PsRichTooltip>
@@ -27,114 +27,120 @@
27
27
  :key="item[keyValue] + index"
28
28
  type="button"
29
29
  @click="selectTab(item)"
30
- :class="getButtonClass(item)"
30
+ :class="getButtonClass(item).value"
31
31
  >
32
- <span>{{ item[keyLabel] }}</span>
32
+ <span>{{ item[keyLabel] }}</span>
33
33
  </button>
34
34
  </slot>
35
35
  </template>
36
36
  </div>
37
37
  </template>
38
38
 
39
- <script>
39
+ <script setup>
40
40
  import PsRichTooltip from '../tooltip/PsRichTooltip.vue'
41
- export default {
42
- name: 'PsTabHeader',
43
- components: { PsRichTooltip },
44
- props: {
45
- /**
46
- * It sets the layout of the tabheader. eg: standard, underline and folder.
47
- */
48
- layout: {
49
- type: String,
50
- default: 'standard',
51
- validator: (value) => ['standard', 'underline', 'folder'].includes(value)
52
- },
53
- /**
54
- * It sets the tabs which will be rendered.
55
- */
56
- items: {
57
- type: Array,
58
- required: true
59
- },
60
- /**
61
- * It sets the key label of the items if needed.
62
- */
63
- keyLabel: {
64
- type: String,
65
- default: 'label'
66
- },
67
- /**
68
- * It sets the key value of the items if needed.
69
- */
70
- keyValue: {
71
- type: String,
72
- default: 'value'
73
- },
74
- /**
75
- * It disabled the tab header. All mouse events are disabled.
76
- */
77
- disabled: {
78
- type: Boolean,
79
- default: false
80
- },
81
- /**
82
- * It sets the tab seleced.
83
- */
84
- selected: {},
41
+ import { computed } from 'vue'
42
+
43
+ const props = defineProps({
44
+ /**
45
+ * It sets the layout of the tabheader. eg: standard, underline and folder.
46
+ */
47
+ layout: {
48
+ type: String,
49
+ default: 'standard',
50
+ validator: (value) => ['standard', 'underline', 'folder'].includes(value),
85
51
  },
86
- computed: {
87
- getComponentClass() {
88
- if (this.disabled) {
89
- return 'status-disabled'
90
- } else {
91
- return 'status-resting'
92
- }
93
- },
94
- getIsObject() {
95
- return typeof this.selected === 'object'
96
- },
97
- getSelected() {
98
- if (this.selected) {
99
- if (typeof this.selected === 'object' && this.selected[this.keyValue] ) {
100
- return this.selected[this.keyValue]
101
- } else {
102
- return this.selected
103
- }
104
- } else {
105
- return false
106
- }
107
- },
108
- getItems() {
109
- if (this.items.length > 0 && typeof this.items[0] !== 'object') {
110
- return this.items.map((item) => {
111
- return {
112
- [this.keyLabel]: item,
113
- [this.keyValue]: item
114
- }
115
- })
116
- } else {
117
- return this.items
118
- }
119
- },
52
+ /**
53
+ * It sets the tabs which will be rendered.
54
+ */
55
+ items: {
56
+ type: Array,
57
+ required: true,
120
58
  },
121
- methods: {
122
- selectTab(item) {
123
- if (item.disabled !== true) {
124
- this.$emit('update:selected', this.getIsObject ? item : item[this.keyValue] )
125
- this.$emit('change', this.getIsObject ? item : item[this.keyValue])
126
- }
127
- },
128
- getButtonClass(item) {
129
- if (item.disabled) {
130
- return ['status-disabled']
131
- } else {
132
- return { 'status-active': this.getSelected === item[this.keyValue], 'status-enabled' : true }
133
- }
59
+ /**
60
+ * It sets the key label of the items if needed.
61
+ */
62
+ keyLabel: {
63
+ type: String,
64
+ default: 'label',
65
+ },
66
+ /**
67
+ * It sets the key value of the items if needed.
68
+ */
69
+ keyValue: {
70
+ type: String,
71
+ default: 'value',
72
+ },
73
+ /**
74
+ * It disabled the tab header. All mouse events are disabled.
75
+ */
76
+ disabled: {
77
+ type: Boolean,
78
+ default: false,
79
+ },
80
+ /**
81
+ * It sets the tab seleced.
82
+ */
83
+ selected: {},
84
+ })
85
+
86
+ const emit = defineEmits(['change', 'update:selected'])
87
+
88
+ const getComponentClass = computed(() => {
89
+ if (props.disabled) {
90
+ return 'status-disabled'
91
+ } else {
92
+ return 'status-resting'
93
+ }
94
+ })
95
+
96
+ const getIsObject = computed(() => {
97
+ return typeof props.selected === 'object'
98
+ })
99
+
100
+ const getSelected = computed(() => {
101
+ if (props.selected) {
102
+ if (typeof props.selected === 'object' && props.selected[props.keyValue]) {
103
+ return props.selected[props.keyValue]
104
+ } else {
105
+ return props.selected
134
106
  }
107
+ } else {
108
+ return false
109
+ }
110
+ })
111
+
112
+ const getItems = computed(() => {
113
+ if (props.items.length > 0 && typeof props.items[0] !== 'object') {
114
+ return props.items.map((item) => {
115
+ return {
116
+ [props.keyLabel]: item,
117
+ [props.keyValue]: item,
118
+ }
119
+ })
120
+ } else {
121
+ return props.items
135
122
  }
123
+ })
136
124
 
125
+ const selectTab = (item) => {
126
+ if (item.disabled !== true) {
127
+ emit('update:selected', getIsObject.value ? item : item[props.keyValue])
128
+ emit('change', getIsObject.value ? item : item[props.keyValue])
129
+ }
137
130
  }
131
+
132
+ const getButtonClass = (item) => {
133
+ return computed(() => {
134
+ if (item.disabled) {
135
+ return ['status-disabled']
136
+ } else {
137
+ return { 'status-active': getSelected.value === item[props.keyValue], 'status-enabled': true }
138
+ }
139
+ })
140
+ }
141
+
138
142
  </script>
139
143
 
140
- <style> /* Please, use the file src/assets/scss/components/PsTabHeader.scss */</style>
144
+ <style>
145
+ /* Please, use the file src/assets/scss/components/PsTabHeader.scss */
146
+ </style>