@policystudio/policy-studio-ui-vue 1.0.68 → 1.0.69

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.
@@ -0,0 +1,191 @@
1
+ <template>
2
+ <div class="psui-w-full psui-whitespace-no-wrap psui-flex psui-overflow-auto">
3
+ <table class="psui-el-table-results">
4
+ <slot name="header"></slot>
5
+
6
+ <!-- <slot name="body"></slot> -->
7
+
8
+ <tbody>
9
+ <tr
10
+ v-for="(item, index) in getRows"
11
+ :key="index"
12
+ :class="[
13
+ {
14
+ 'first:psui-font-bold psui-text-gray-80' : item.type == 'total',
15
+ 'psui-text-blue-80' : item.type == 'vintage',
16
+ 'psui-hidden' : checkIndexIsHidden(item),
17
+ 'cell-pb-20 psui-text-red-70' : item.type == 'vintage' && !checkItemIsVisible(item) || item.type == 'study_data' && item.is_last,
18
+ 'is-last' : item.is_last
19
+ },
20
+ `type-${item.type}`
21
+ ]"
22
+ >
23
+ <td>
24
+ <div
25
+ class="actions psui-flex psui-items-center psui-space-x-3"
26
+ :style="{ paddingLeft: `${item.deep * 20}px` }"
27
+ >
28
+ <PsIcon
29
+ v-if="isCollapsible && item.deep > 0 && !item.last_deep || item.type === 'total'"
30
+ :icon="checkItemIsVisible(item) ? 'expand_more' : 'chevron_right'"
31
+ size="24"
32
+ class="psui-cursor-pointer"
33
+ icon-classes="psui-text-gray-40 psui-leading-none psui-transition"
34
+ :style="{ display: 'flex' }"
35
+ @click="$emit('collapse-row', item)"
36
+ />
37
+ <p class="title">{{ item.title }}</p>
38
+ </div>
39
+ </td>
40
+
41
+ <template
42
+ v-for="(columnGroup, indexColumn) of columnGroups"
43
+ >
44
+ <td
45
+ v-for="column of columnGroup.columns"
46
+ :key="indexColumn + '-' + columnGroup.key + '-' + column.key"
47
+ >
48
+ <div class="psui-space-x-2 psui-show-childrens-on-hover">
49
+ <PsIcon
50
+ v-if="column.hasProjections"
51
+ icon="bar_chart"
52
+ size="16"
53
+ class="psui-cursor-pointer"
54
+ icon-classes="psui-text-blue-60 psui-opacity-0 psui-leading-none psui-transition"
55
+ :style="{ display: 'flex' }"
56
+ @click.native="$emit('open-projections', item)"
57
+ />
58
+
59
+ <p>{{ item.data[column.key].toFixed(2) }}</p>
60
+
61
+ <PsProgressBar
62
+ v-if="column.isChart"
63
+ :value="item.data[column.key]"
64
+ />
65
+ </div>
66
+ </td>
67
+ </template>
68
+ </tr>
69
+ </tbody>
70
+
71
+ <!-- <slot name="footer"></slot> -->
72
+ </table>
73
+ </div>
74
+ </template>
75
+
76
+ <script>
77
+ import PsIcon from '../ui/PsIcon.vue'
78
+ import PsProgressBar from '../badges-and-tags/PsProgressBar.vue'
79
+ export default {
80
+ name: 'PsTableResults',
81
+ components: { PsProgressBar, PsIcon },
82
+ props: {
83
+ itemsHiddenIndexes: {
84
+ type: Array,
85
+ default() {
86
+ return []
87
+ }
88
+ },
89
+ /**
90
+ * It sets the values which will be use to render the body.
91
+ */
92
+ summaryData: {
93
+ type: Array,
94
+ default() {
95
+ return []
96
+ }
97
+ },
98
+ /**
99
+ * It sets the values which will be use to render the body.
100
+ */
101
+ columnGroups: {
102
+ type: Array,
103
+ default() {
104
+ return []
105
+ }
106
+ },
107
+ /**
108
+ * It sets the values which will be use to render the body.
109
+ */
110
+ rows: {
111
+ type: Array,
112
+ default() {
113
+ return []
114
+ }
115
+ },
116
+ /**
117
+ * It sets a close button if needed.
118
+ */
119
+ isCollapsible: {
120
+ type: Boolean,
121
+ default: true
122
+ },
123
+ /**
124
+ * It sets additional styling if needed.
125
+ */
126
+ cssStyle: {
127
+ type: String,
128
+ default: 'psui-text-gray-60'
129
+ },
130
+ testValue: {
131
+ type: String,
132
+ default: ''
133
+ }
134
+ },
135
+ computed: {
136
+ cssAlign() {
137
+ if (this.align === 'right') return `psui-text-right ${this.cssStyle}`
138
+ if (this.align === 'center') return `psui-text-center ${this.cssStyle}`
139
+ return `psui-text-left ${this.cssStyle}`
140
+ },
141
+ getRows() {
142
+ const rows = []
143
+ for (let index = 0; index < this.summaryData.length; index++) {
144
+ const item = this.summaryData[index]
145
+ this.addRow(item, 0, `${index}`, rows)
146
+ }
147
+ return rows
148
+ }
149
+ },
150
+ methods: {
151
+ addRow(item, deep = 0, index, rows) {
152
+ item.deep = deep
153
+ item.index = index
154
+ rows.push(item)
155
+ item.last_deep = item.items ? false : true
156
+ if (item.items) {
157
+ const items_child = [...item.items]
158
+ for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
159
+ const item_child = items_child[indexChild]
160
+ item_child.is_last = indexChild + 1 === items_child.length ? true : false
161
+ this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
162
+ }
163
+ }
164
+ },
165
+ checkItemIsVisible(item) {
166
+ return this.itemsHiddenIndexes.indexOf(item) < 0
167
+ },
168
+ checkIndexIsHidden(item) {
169
+ let isHidden = false
170
+ for (let index = 0; index < this.itemsHiddenIndexes.length; index++) {
171
+ const item_hidden = this.itemsHiddenIndexes[index]
172
+ if (item.index.startsWith(`${item_hidden}-`)) {
173
+ isHidden = true
174
+ break
175
+ }
176
+ }
177
+ return isHidden
178
+ },
179
+ onCollapse(item) {
180
+ const index = this.itemsHiddenIndexes.indexOf(item)
181
+ if(index > -1) {
182
+ this.itemsHiddenIndexes.splice(index, 1)
183
+ } else {
184
+ this.itemsHiddenIndexes.push(item)
185
+ }
186
+ this.$emit('click')
187
+ }
188
+ }
189
+ }
190
+ </script>
191
+ <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
@@ -0,0 +1,98 @@
1
+ <template>
2
+ <tbody>
3
+ <tr
4
+ v-for="(row, index) in getRows"
5
+ :key="index"
6
+ >
7
+ <td>
8
+ <p class="title">{{ row.title }}</p>
9
+ </td>
10
+
11
+ <template
12
+ v-for="(columnGroup, indexColumn) of columnGroups"
13
+ >
14
+ <td
15
+ v-for="column of columnGroup.columns"
16
+ :key="indexColumn + '-' + columnGroup.key + '-' + column.key"
17
+ >
18
+ <!-- <pre>{{ column }}</pre> -->
19
+ <p>{{ column.title }}</p>
20
+ </td>
21
+ </template>
22
+ </tr>
23
+ </tbody>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: 'PsTableResultsBody',
29
+ props: {
30
+ /**
31
+ * It sets the values which will be use to render the body.
32
+ */
33
+ summaryData: {
34
+ type: Array,
35
+ default() {
36
+ return []
37
+ }
38
+ },
39
+ /**
40
+ * It sets the values which will be use to render the body.
41
+ */
42
+ columnGroups: {
43
+ type: Array,
44
+ default() {
45
+ return []
46
+ }
47
+ },
48
+ /**
49
+ * It sets the values which will be use to render the body.
50
+ */
51
+ rows: {
52
+ type: Array,
53
+ default() {
54
+ return []
55
+ }
56
+ },
57
+ /**
58
+ * It sets additional styling if needed.
59
+ */
60
+ cssStyle: {
61
+ type: String,
62
+ default: 'psui-text-gray-60'
63
+ }
64
+ },
65
+ computed: {
66
+ cssAlign() {
67
+ if (this.align === 'right') return `psui-text-right ${this.cssStyle}`
68
+ if (this.align === 'center') return `psui-text-center ${this.cssStyle}`
69
+ return `psui-text-left ${this.cssStyle}`
70
+ },
71
+ getRows() {
72
+ const rows = []
73
+ for (let index = 0; index < this.summaryData.length; index++) {
74
+ const item = this.summaryData[index]
75
+ this.addRow(item, 0, `${index}`, rows)
76
+ }
77
+ return rows
78
+ }
79
+ },
80
+ methods: {
81
+ addRow(item, deep = 0, index, rows) {
82
+ item.deep = deep
83
+ item.index = index
84
+ rows.push(item)
85
+ item.last_deep = item.items ? false : true
86
+ if (item.items) {
87
+ const items_child = [...item.items]
88
+ for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
89
+ const item_child = items_child[indexChild]
90
+ item_child.is_last = indexChild + 1 === items_child.length ? true : false
91
+ this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ </script>
98
+ <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
@@ -0,0 +1,109 @@
1
+ <template>
2
+ <thead>
3
+ <tr>
4
+ <th>
5
+ <div>
6
+ <p class="title">Measures & Packages</p>
7
+ </div>
8
+ </th>
9
+
10
+ <th
11
+ v-for="columnGroup of header"
12
+ :key="columnGroup.key"
13
+ :colspan="columnGroup.columns.reduce( (prev, cur) => cur.isActive ? prev + 1 : prev, 0 )"
14
+ >
15
+ <div class="psui-space-x-1 psui-items-center psui-show-childrens-on-hover">
16
+ <p class="title">{{ columnGroup.title }}</p>
17
+ <PsIcon
18
+ icon="info"
19
+ size="18"
20
+ class="psui-cursor-pointer"
21
+ icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
22
+ :style="{ display: 'flex' }"
23
+ @click.native="$emit('click-column-group-helper', columnGroup, $event)"
24
+ />
25
+ </div>
26
+ </th>
27
+ </tr>
28
+
29
+ <tr>
30
+ <th>
31
+ <div>
32
+ <p class="description">Select the measures you want to combine <br />to create your policy.</p>
33
+ </div>
34
+ </th>
35
+
36
+ <template v-for="columnGroup of header">
37
+ <th
38
+ v-for="column of columnGroup.columns"
39
+ :key="`${columnGroup.key}-${column.key}`"
40
+ >
41
+ <div class="psui-flex psui-flex-col">
42
+ <div class="psui-flex psui-flex-row psui-space-x-1 psui-items-center psui-justify-end psui-show-childrens-on-hover psui-mb-px">
43
+ <PsIcon
44
+ v-if="showOrder"
45
+ :icon="orderDirection == 'asc' ? 'arrow_downward' : 'arrow_upward'"
46
+ :type="orderDirection == 'asc' ? 'arrow_upward' : 'arrow_upward'"
47
+ size="16"
48
+ class="psui-cursor-pointer"
49
+ icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
50
+ :style="{ display: 'flex' }"
51
+ @click.native="$emit('click-order-column', column)"
52
+ />
53
+
54
+ <PsIcon
55
+ icon="info"
56
+ size="16"
57
+ class="psui-cursor-pointer"
58
+ icon-classes="psui-text-blue-50 psui-opacity-0 psui-leading-none psui-transition"
59
+ :style="{ display: 'flex' }"
60
+ @click.native="$emit('click-column-helper', column, $event)"
61
+ />
62
+ <p class="title" v-if="column.title">{{ column.title }}</p>
63
+ </div>
64
+ <p class="description" v-if="column.description">{{ column.description }}</p>
65
+ </div>
66
+ </th>
67
+ </template>
68
+ </tr>
69
+ </thead>
70
+ </template>
71
+
72
+ <script>
73
+ import PsIcon from '../ui/PsIcon.vue'
74
+ export default {
75
+ name: 'PsTableResultsHead',
76
+ components: { PsIcon },
77
+ props: {
78
+ /**
79
+ * It sets the values which will be use to render the header.
80
+ */
81
+ header: {
82
+ type: Array,
83
+ required: true,
84
+ default: () => {
85
+ return []
86
+ },
87
+ },
88
+ /**
89
+ * this sets whether sorting will be displayed.
90
+ */
91
+ showOrder: {
92
+ type: Boolean,
93
+ default: false
94
+ }
95
+ },
96
+ computed: {
97
+ columnsSelectedForStudy() {
98
+ return this.$parent.columnsSelectedForStudy
99
+ },
100
+ orderColumn() {
101
+ return this.$parent.orderColumn
102
+ },
103
+ orderDirection() {
104
+ return this.$parent.orderDirection
105
+ },
106
+ }
107
+ }
108
+ </script>
109
+ <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <tbody>
3
+ <tr
4
+ v-for="(row, index) in getRows"
5
+ :key="index"
6
+ >
7
+ <td>
8
+ <p class="title">{{ row.title }}</p>
9
+ </td>
10
+
11
+ <template
12
+ v-for="(columnGroup, indexColumn) of columnGroups"
13
+ >
14
+ <td
15
+ v-for="column of columnGroup.columns"
16
+ :key="indexColumn + '-' + columnGroup.key + '-' + column.key"
17
+ >
18
+ <!-- <pre>{{ column }}</pre> -->
19
+ <p>{{ row.data[column.key] }}</p>
20
+ </td>
21
+ </template>
22
+ </tr>
23
+ </tbody>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: 'PsTableResultsRow',
29
+ props: {
30
+ /**
31
+ * It sets the values which will be use to render the body.
32
+ */
33
+ summaryData: {
34
+ type: Array,
35
+ default() {
36
+ return []
37
+ }
38
+ },
39
+ /**
40
+ * It sets the values which will be use to render the body.
41
+ */
42
+ columnGroups: {
43
+ type: Array,
44
+ default() {
45
+ return []
46
+ }
47
+ },
48
+ /**
49
+ * It sets the values which will be use to render the body.
50
+ */
51
+ rows: {
52
+ type: Array,
53
+ default() {
54
+ return []
55
+ }
56
+ },
57
+ },
58
+ computed: {
59
+ getRows() {
60
+ const rows = []
61
+ for (let index = 0; index < this.summaryData.length; index++) {
62
+ const item = this.summaryData[index]
63
+ this.addRow(item, 0, `${index}`, rows)
64
+ }
65
+ return rows
66
+ }
67
+ },
68
+ methods: {
69
+ addRow(item, deep = 0, index, rows) {
70
+ item.deep = deep
71
+ item.index = index
72
+ rows.push(item)
73
+ item.last_deep = item.items ? false : true
74
+ if (item.items) {
75
+ const items_child = [...item.items]
76
+ for (let indexChild = 0; indexChild < items_child.length; indexChild++) {
77
+ const item_child = items_child[indexChild]
78
+ item_child.is_last = indexChild + 1 === items_child.length ? true : false
79
+ this.addRow(item_child, deep + 1, `${index}-${indexChild}`, rows)
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ </script>
86
+ <style> /* Please, use the file src/assets/scss/components/PsTableResults.scss */ </style>
package/src/index.js CHANGED
@@ -17,6 +17,9 @@ import PsAccordionItem from './components/accordion/PsAccordionItem.vue'
17
17
  import PsChips from './components/chips/PsChips.vue'
18
18
  import PsDataTable from './components/datatable/PsDataTable.vue'
19
19
  import PsDataTableItem from './components/datatable/PsDataTableItem.vue'
20
+ import PsTableResults from './components/table-results/PsTableResults.vue'
21
+ import PsTableResultsHead from './components/table-results/PsTableResultsHead.vue'
22
+ import PsTableResultsBody from './components/table-results/PsTableResultsBody.vue'
20
23
  import PsIcon from './components/ui/PsIcon.vue'
21
24
  import PsDotLoader from './components/ui/PsDotLoader.vue'
22
25
  import PsTooltip from './components/tooltip/PsTooltip.vue'
@@ -30,6 +33,7 @@ import PsScrollBar from './components/playground/PsScrollBar.vue'
30
33
  import PsMiniTag from './components/badges-and-tags/PsMiniTag.vue'
31
34
  import PsCheckboxSimple from './components/controls/PsCheckboxSimple.vue'
32
35
  import PsBadgeWithIcon from './components/badges-and-tags/PsBadgeWithIcon.vue'
36
+ import PsProgressBar from './components/badges-and-tags/PsProgressBar.vue'
33
37
  import PsRadioButtonSimple from './components/controls/PsRadioButtonSimple.vue'
34
38
 
35
39
 
@@ -51,6 +55,9 @@ export default {
51
55
  Vue.component('PsChips', PsChips)
52
56
  Vue.component('PsDataTable', PsDataTable)
53
57
  Vue.component('PsDataTableItem', PsDataTableItem)
58
+ Vue.component('PsTableResults', PsTableResults)
59
+ Vue.component('PsTableResultsHead', PsTableResultsHead)
60
+ Vue.component('PsTableResultsBody', PsTableResultsBody)
54
61
  Vue.component('PsIcon', PsIcon)
55
62
  Vue.component('PsDotLoader', PsDotLoader)
56
63
  Vue.component('PsTooltip', PsTooltip)
@@ -68,6 +75,7 @@ export default {
68
75
  Vue.component('PsMiniTag', PsMiniTag)
69
76
  Vue.component('PsCheckboxSimple', PsCheckboxSimple)
70
77
  Vue.component('PsBadgeWithIcon', PsBadgeWithIcon)
78
+ Vue.component('PsProgressBar', PsProgressBar)
71
79
  Vue.component('PsRadioButtonSimple', PsRadioButtonSimple)
72
80
 
73
81
  Vue.directive('click-outside', {
@@ -104,6 +112,9 @@ export {
104
112
  PsChips,
105
113
  PsDataTable,
106
114
  PsDataTableItem,
115
+ PsTableResults,
116
+ PsTableResultsHead,
117
+ PsTableResultsBody,
107
118
  PsIcon,
108
119
  PsDotLoader,
109
120
  PsTooltip,
@@ -121,6 +132,7 @@ export {
121
132
  PsMiniTag,
122
133
  PsCheckboxSimple,
123
134
  PsBadgeWithIcon,
135
+ PsProgressBar,
124
136
  PsRadioButtonSimple
125
137
  }
126
138
 
@@ -12,7 +12,7 @@ const Template = (args, {argTypes}) => ({
12
12
  <div style='width: 300px; font-family: "Lato", sans-serif; font-size: 12px;'>
13
13
  <PsDraggable v-bind='$props'/>
14
14
  </div>
15
- `
15
+ `
16
16
  })
17
17
 
18
18
  export const Component = Template.bind({})