@policystudio/policy-studio-ui-vue 1.0.15 → 1.0.19
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.
- package/.eslintrc.js +68 -0
- package/.storybook/main.js +2 -1
- package/dist/css/psui_styles.css +70643 -0
- package/package.json +13 -9
- package/src/assets/images/check-checkbox-button.svg +1 -0
- package/src/assets/images/radio-checked-button.svg +1 -0
- package/src/assets/scss/base.scss +29 -2
- package/src/assets/scss/tailwind.css +2233 -2736
- package/src/components/accordion/PsAccordion.vue +36 -0
- package/src/components/accordion/PsAccordionItem.vue +102 -0
- package/src/components/buttons/PsButton.vue +6 -3
- package/src/components/chips/PsChips.vue +146 -0
- package/src/components/controls/PsCheckbox.vue +3 -3
- package/src/components/controls/PsRadioButton.vue +11 -35
- package/src/components/controls/PsSlider.vue +13 -12
- package/src/components/controls/PsSwitch.vue +20 -19
- package/src/components/datatable/PsDataTable.vue +93 -0
- package/src/components/datatable/PsDataTableItem.vue +57 -0
- package/src/components/forms/PsDropdown.vue +196 -0
- package/src/components/forms/PsInput.vue +10 -6
- package/src/components/tabs/PsTabHeader.vue +20 -21
- package/src/components/ui/PsIcon.vue +65 -0
- package/src/index.js +37 -22
- package/src/stories/Accordion.stories.js +35 -0
- package/src/stories/Checkbox.stories.js +15 -8
- package/src/stories/Chips.stories.js +49 -0
- package/src/stories/Colors.stories.mdx +36 -35
- package/src/stories/Datatable.stories.js +43 -0
- package/src/stories/Dropdown.stories.js +34 -0
- package/src/stories/Input.stories.js +1 -0
- package/src/stories/RadioButton.stories.js +21 -5
- package/src/stories/Swith.stories.js +2 -2
- package/src/stories/Toggle.stories.js +24 -0
- package/src/util/GeneralFunctions.js +23 -0
- package/tailwind.config.js +18 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes" class='psui-flex psui-flex-col' >
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export const sizes = ['big', 'medium']
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name:"PsAccordion",
|
|
12
|
+
props: {
|
|
13
|
+
size:{
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'medium',
|
|
16
|
+
required: true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
computed:{
|
|
20
|
+
classes(){
|
|
21
|
+
if( this.size === 'big') return 'big'
|
|
22
|
+
return 'medium'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
<style scoped>
|
|
29
|
+
.medium {
|
|
30
|
+
width: 390px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.big {
|
|
34
|
+
width: 580px;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<div
|
|
4
|
+
@click="toggleTitle"
|
|
5
|
+
:class="cssClass"
|
|
6
|
+
class="
|
|
7
|
+
psui-flex psui-cursor-pointer psui-transition-all psui-justify-between
|
|
8
|
+
"
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
v-if="title"
|
|
12
|
+
:class="display ? 'selected' : ''"
|
|
13
|
+
class="psui-font-bold psui-gray04"
|
|
14
|
+
>
|
|
15
|
+
{{ title }}
|
|
16
|
+
</div>
|
|
17
|
+
<span v-if="!display" class="material-icons">{{ iconClass.closed }}</span>
|
|
18
|
+
<span v-else :class="display ? 'selected' : ''" class="material-icons">{{
|
|
19
|
+
iconClass.open
|
|
20
|
+
}}</span>
|
|
21
|
+
</div>
|
|
22
|
+
<div v-if="display" class="psui-transition-all psui-duration-300">
|
|
23
|
+
<slot></slot>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
export const iconTypes = ["mathsign", "chevron"]
|
|
30
|
+
export const fontCss = ["medium", "big"]
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: "PsAccordionItem",
|
|
34
|
+
props: {
|
|
35
|
+
title: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
iconType: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
default: "chevron",
|
|
43
|
+
},
|
|
44
|
+
fontCss: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "medium",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
display: false,
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
computed: {
|
|
55
|
+
iconClass() {
|
|
56
|
+
if (this.iconType === "chevron") {
|
|
57
|
+
return { closed: "expand_more", open: "expand_less" }
|
|
58
|
+
} else if (this.iconType === "mathsign") {
|
|
59
|
+
return { closed: "add", open: "remove" }
|
|
60
|
+
}
|
|
61
|
+
return ''
|
|
62
|
+
},
|
|
63
|
+
cssClass() {
|
|
64
|
+
if (this.fontCss === "big") return "big"
|
|
65
|
+
return "medium"
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
toggleTitle() {
|
|
70
|
+
this.display = !this.display
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.container {
|
|
78
|
+
border: 1px solid #e6ecf2;
|
|
79
|
+
padding: 16px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
span {
|
|
83
|
+
font-weight: 700;
|
|
84
|
+
color: #e6ecf2;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.selected {
|
|
88
|
+
color: #318fac;
|
|
89
|
+
transition: color 300ms;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.big {
|
|
93
|
+
font-size: 18px;
|
|
94
|
+
line-height: 130%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.medium {
|
|
98
|
+
font-size: 16px;
|
|
99
|
+
line-height: 130%;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
>
|
|
11
11
|
{{ icon }}
|
|
12
12
|
</i>
|
|
13
|
-
<div
|
|
13
|
+
<div
|
|
14
|
+
v-if="label"
|
|
15
|
+
class="psui-flex-grow psui-text-left"
|
|
16
|
+
>{{ label }}
|
|
17
|
+
</div>
|
|
14
18
|
<i
|
|
15
19
|
v-if="iconRight"
|
|
16
20
|
:class="['psui-ml-2', iconClasses]"
|
|
@@ -26,7 +30,6 @@ export default {
|
|
|
26
30
|
props: {
|
|
27
31
|
label: {
|
|
28
32
|
type: String,
|
|
29
|
-
required: true
|
|
30
33
|
},
|
|
31
34
|
outline: {
|
|
32
35
|
type: Boolean,
|
|
@@ -99,7 +102,7 @@ export default {
|
|
|
99
102
|
methods: {
|
|
100
103
|
onClick() {
|
|
101
104
|
if (this.disabled) return false
|
|
102
|
-
this.$emit('click')
|
|
105
|
+
this.$emit('click')
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
108
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
@click="onClick"
|
|
4
|
+
|
|
5
|
+
:for="title"
|
|
6
|
+
|
|
7
|
+
:class="cssClass"
|
|
8
|
+
|
|
9
|
+
class="
|
|
10
|
+
psui-flex
|
|
11
|
+
psui-items-center
|
|
12
|
+
psui-gap-2
|
|
13
|
+
psui-justify-center
|
|
14
|
+
psui-bg-gray-10
|
|
15
|
+
psui-text-gray-60
|
|
16
|
+
psui-rounded-md
|
|
17
|
+
psui-py-1
|
|
18
|
+
psui-px-2
|
|
19
|
+
psui-cursor-pointer
|
|
20
|
+
"
|
|
21
|
+
>
|
|
22
|
+
<input @change="onChange" v-if="type !== 'text'" :type="type" :id="title" />
|
|
23
|
+
<i v-if="icon" class="material-icons">{{ icon }}</i>
|
|
24
|
+
{{ title }}
|
|
25
|
+
<button @click="onClose" v-if="rich" class="psui-flex psui-items-center">
|
|
26
|
+
<i class="material-icons">close</i>
|
|
27
|
+
</button>
|
|
28
|
+
</label>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
export const type = ["text", "radio", "checkbox", "button"]
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
name: "PsChips",
|
|
36
|
+
props: {
|
|
37
|
+
title: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "",
|
|
40
|
+
},
|
|
41
|
+
type: {
|
|
42
|
+
type: String,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
icon: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: "",
|
|
48
|
+
},
|
|
49
|
+
rich: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
emits: ["click", "change"],
|
|
55
|
+
data() {
|
|
56
|
+
return {
|
|
57
|
+
isChecked: false,
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
computed: {
|
|
61
|
+
cssClass() {
|
|
62
|
+
if (this.isChecked === true && this.type === "radio") {
|
|
63
|
+
return "psui-text-blue-50"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.isChecked === true && this.type === "checkbox") {
|
|
67
|
+
return "psui-text-blue-50"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.isChecked === true){
|
|
71
|
+
return "psui-text-blue-50"
|
|
72
|
+
}
|
|
73
|
+
return "psui-text-blue-50"
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
onClick() {
|
|
78
|
+
if (this.disabled) return false
|
|
79
|
+
if (this.type !== "checkbox" || this.type !== "radio") {
|
|
80
|
+
this.isChecked = !this.isChecked
|
|
81
|
+
}
|
|
82
|
+
this.$emit("click")
|
|
83
|
+
},
|
|
84
|
+
onChange(event) {
|
|
85
|
+
this.isChecked = event.target.checked
|
|
86
|
+
this.$emit("change")
|
|
87
|
+
},
|
|
88
|
+
onClose(){
|
|
89
|
+
this.$emit("close")
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<style scoped>
|
|
96
|
+
|
|
97
|
+
input[type="radio"] {
|
|
98
|
+
-webkit-appearance: none;
|
|
99
|
+
-moz-appearance: none;
|
|
100
|
+
appearance: none;
|
|
101
|
+
|
|
102
|
+
display: inline-block;
|
|
103
|
+
width: 16px;
|
|
104
|
+
height: 16px;
|
|
105
|
+
border-radius: 50%;
|
|
106
|
+
border: 1px solid #4b5563;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
input[type="checkbox"] {
|
|
110
|
+
-webkit-appearance: none;
|
|
111
|
+
-moz-appearance: none;
|
|
112
|
+
appearance: none;
|
|
113
|
+
|
|
114
|
+
display: inline-block;
|
|
115
|
+
width: 16px;
|
|
116
|
+
height: 16px;
|
|
117
|
+
border-radius: 25%;
|
|
118
|
+
border: 1px solid #4b5563;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
input[type="radio"]:hover,
|
|
122
|
+
input[type="checkbox"]:hover {
|
|
123
|
+
border-color: #64b5ce;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
input[type="radio"]:checked {
|
|
127
|
+
border-color: #64b5ce;
|
|
128
|
+
background: url('../../assets/images/radio-checked-button.svg') #ffffff no-repeat center;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
input[type="checkbox"]:checked {
|
|
132
|
+
border-color: #64b5ce;
|
|
133
|
+
background: url('../../assets/images/check-checkbox-button.svg') #64b5ce no-repeat center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
label {
|
|
137
|
+
width: fit-content;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
label:hover {
|
|
141
|
+
color: #64b5ce;
|
|
142
|
+
background: #ffffff;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
</style>
|
|
146
|
+
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
},
|
|
26
26
|
checkboxClasses: {
|
|
27
27
|
type: String,
|
|
28
|
-
default: '
|
|
28
|
+
default: ''
|
|
29
29
|
},
|
|
30
30
|
labelClasses: {
|
|
31
31
|
type: String,
|
|
@@ -42,7 +42,7 @@ export default {
|
|
|
42
42
|
computed: {
|
|
43
43
|
model: {
|
|
44
44
|
get() {
|
|
45
|
-
return this.value
|
|
45
|
+
return this.value
|
|
46
46
|
},
|
|
47
47
|
set(newValue) {
|
|
48
48
|
this.$emit('input', newValue)
|
|
@@ -50,7 +50,7 @@ export default {
|
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
classes() {
|
|
53
|
-
return `${this.disabled ? 'psui-border-gray-40': 'psui-border-gray-50'} ${checkboxClasses}`
|
|
53
|
+
return `${this.disabled ? 'psui-border-gray-40': 'psui-border-gray-50'} ${this.checkboxClasses}`
|
|
54
54
|
},
|
|
55
55
|
getSize() {
|
|
56
56
|
return {
|
|
@@ -1,48 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<label
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
name="radio"
|
|
8
|
-
:id="id"
|
|
9
|
-
@change="$emit('change')"
|
|
10
|
-
v-model="childValue"
|
|
11
|
-
/>
|
|
12
|
-
<span class="radio-button"></span>
|
|
13
|
-
</label>
|
|
14
|
-
</div>
|
|
2
|
+
<label class="form-control">
|
|
3
|
+
<span>{{ label }}</span>
|
|
4
|
+
<input type="radio" :value="value" :name="name" v-model="radioButtonValue">
|
|
5
|
+
<span class="radio-button"></span>
|
|
6
|
+
</label>
|
|
15
7
|
</template>
|
|
16
8
|
|
|
17
9
|
<script>
|
|
18
10
|
export default {
|
|
19
11
|
name: 'PsRadioButton',
|
|
20
|
-
props:
|
|
21
|
-
label: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
25
|
-
value: {
|
|
26
|
-
required: true
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
id: ''
|
|
32
|
-
}
|
|
33
|
-
},
|
|
12
|
+
props: ['name', 'label', 'value'],
|
|
34
13
|
computed: {
|
|
35
|
-
|
|
36
|
-
get () {
|
|
14
|
+
radioButtonValue: {
|
|
15
|
+
get: function() {
|
|
37
16
|
return this.value
|
|
38
17
|
},
|
|
39
|
-
set (
|
|
40
|
-
this.$emit(
|
|
18
|
+
set: function() {
|
|
19
|
+
this.$emit("change", this.value)
|
|
41
20
|
}
|
|
42
21
|
}
|
|
43
|
-
},
|
|
44
|
-
mounted() {
|
|
45
|
-
this.id = 'teste'
|
|
46
22
|
}
|
|
47
23
|
}
|
|
48
24
|
</script>
|
|
@@ -92,7 +68,7 @@ export default {
|
|
|
92
68
|
}
|
|
93
69
|
|
|
94
70
|
.form-control .radio-button:after {
|
|
95
|
-
|
|
71
|
+
top: 3px;
|
|
96
72
|
left: 3px;
|
|
97
73
|
width: 10px;
|
|
98
74
|
height: 10px;
|
|
@@ -29,18 +29,6 @@
|
|
|
29
29
|
<script>
|
|
30
30
|
export default {
|
|
31
31
|
name: 'PsSlider',
|
|
32
|
-
computed: {
|
|
33
|
-
positionBubble() {
|
|
34
|
-
if (this.bubble && this.isMounted) {
|
|
35
|
-
return (this.$refs.slider.offsetWidth / this.max) * this.value - 15
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
getValueToScale(value) {
|
|
41
|
-
return 100 * value / this.rangeDistanceMax
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
32
|
props: {
|
|
45
33
|
min: {
|
|
46
34
|
type: Number,
|
|
@@ -75,8 +63,21 @@ export default {
|
|
|
75
63
|
isMounted: false
|
|
76
64
|
}
|
|
77
65
|
},
|
|
66
|
+
computed: {
|
|
67
|
+
positionBubble() {
|
|
68
|
+
if (this.bubble && this.isMounted) {
|
|
69
|
+
return (this.$refs.slider.offsetWidth / this.max) * this.value - 15
|
|
70
|
+
}
|
|
71
|
+
return 0
|
|
72
|
+
}
|
|
73
|
+
},
|
|
78
74
|
mounted() {
|
|
79
75
|
this.isMounted = true
|
|
76
|
+
},
|
|
77
|
+
methods: {
|
|
78
|
+
getValueToScale(value) {
|
|
79
|
+
return 100 * value / this.rangeDistanceMax
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
</script>
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
export const sizes = ['big', 'small']
|
|
14
14
|
export default {
|
|
15
15
|
name: 'PsSwitch',
|
|
16
|
+
props: {
|
|
17
|
+
label: String,
|
|
18
|
+
active: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: false
|
|
21
|
+
},
|
|
22
|
+
disabled: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'big',
|
|
29
|
+
validator: (value) => sizes.indexOf(value) !== -1
|
|
30
|
+
}
|
|
31
|
+
},
|
|
16
32
|
computed: {
|
|
17
33
|
text() {
|
|
18
34
|
if (this.label && this.labelActived) {
|
|
@@ -30,22 +46,6 @@ export default {
|
|
|
30
46
|
return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-6 ps-switch psui-rounded-full'
|
|
31
47
|
}
|
|
32
48
|
},
|
|
33
|
-
props: {
|
|
34
|
-
label: String,
|
|
35
|
-
active: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false
|
|
38
|
-
},
|
|
39
|
-
disabled: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
default: false
|
|
42
|
-
},
|
|
43
|
-
size: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: 'big',
|
|
46
|
-
validator: (value) => sizes.indexOf(value) !== -1
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
49
|
methods: {
|
|
50
50
|
change() {
|
|
51
51
|
if (!this.disabled) {
|
|
@@ -58,9 +58,6 @@ export default {
|
|
|
58
58
|
</script>
|
|
59
59
|
|
|
60
60
|
<style scoped>
|
|
61
|
-
/*
|
|
62
|
-
@TODO - Fix the apply error
|
|
63
|
-
https://www.dropbox.com/s/83vwthcdvdt5t97/Screen%20Shot%202022-01-06%20at%2011.49.00%20AM.png?dl=0
|
|
64
61
|
|
|
65
62
|
.ps-switch {
|
|
66
63
|
width: 46px;
|
|
@@ -68,6 +65,10 @@ export default {
|
|
|
68
65
|
.ps-switch-small {
|
|
69
66
|
width: 30px;
|
|
70
67
|
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
@TODO - Fix the apply error
|
|
71
|
+
https://www.dropbox.com/s/83vwthcdvdt5t97/Screen%20Shot%202022-01-06%20at%2011.49.00%20AM.png?dl=0
|
|
71
72
|
.toggle-bg:after {
|
|
72
73
|
content: '';
|
|
73
74
|
@apply psui-absolute psui-bg-white psui-border-gray-40 psui-rounded-full psui-h-5 psui-w-5 psui-transition;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table" :class="cssAlign">
|
|
3
|
+
<thead v-if="header">
|
|
4
|
+
<th
|
|
5
|
+
v-for="head in header"
|
|
6
|
+
:key="head"
|
|
7
|
+
:class="'psui-text-gray-80 psui-font-bold psui-bg-gray-10 psui-capitalize'"
|
|
8
|
+
>
|
|
9
|
+
{{ head }}
|
|
10
|
+
</th>
|
|
11
|
+
</thead>
|
|
12
|
+
<tbody v-if="type === 'simple'">
|
|
13
|
+
<tr v-for="(dt, index) in data" :key="index">
|
|
14
|
+
<td v-for="(head, cellRow) in header" :key="cellRow">
|
|
15
|
+
{{ data[index][head] }}
|
|
16
|
+
</td>
|
|
17
|
+
</tr>
|
|
18
|
+
</tbody>
|
|
19
|
+
<slot v-else></slot>
|
|
20
|
+
<tfoot v-if="footer">
|
|
21
|
+
<th
|
|
22
|
+
v-for="ft in footer"
|
|
23
|
+
:key="ft"
|
|
24
|
+
:class="'psui-text-gray-80 psui-bg-gray-10'"
|
|
25
|
+
>
|
|
26
|
+
{{ ft }}
|
|
27
|
+
</th>
|
|
28
|
+
</tfoot>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
export const type = ["simple", "rich"]
|
|
34
|
+
export const alignment = ["center", "right", "left"]
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
name: "PsDataTable",
|
|
38
|
+
props: {
|
|
39
|
+
type: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
validator: (value) => {
|
|
43
|
+
return ["simple", "rich"].indexOf(value) !== -1
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
header: {
|
|
47
|
+
type: Array,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
data: {
|
|
51
|
+
type: Array,
|
|
52
|
+
default: () => {
|
|
53
|
+
return []
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
footer: {
|
|
57
|
+
type: Array,
|
|
58
|
+
default: () => {
|
|
59
|
+
return []
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
align: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "left",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
computed: {
|
|
68
|
+
cssAlign() {
|
|
69
|
+
if (this.align === "right") return "psui-text-right"
|
|
70
|
+
if (this.align === "left") return "psui-text-left"
|
|
71
|
+
return "psui-text-center"
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<style>
|
|
78
|
+
.table {
|
|
79
|
+
width: fit-content;
|
|
80
|
+
border: 1px solid #e6ecf2;
|
|
81
|
+
border-radius: 4px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
th,
|
|
85
|
+
td,
|
|
86
|
+
tr {
|
|
87
|
+
height: 40px;
|
|
88
|
+
border: 1px solid #e6ecf2;
|
|
89
|
+
padding: 11px 16px;
|
|
90
|
+
font-weight: 400;
|
|
91
|
+
color: #515e6a;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tbody v-if="data">
|
|
3
|
+
<tr v-for="(dt, index) in data" :key="index">
|
|
4
|
+
<td v-for="(el, elIndex) in dt" :key="elIndex">
|
|
5
|
+
<div class="psui-flex psui-gap-1 psui-items-center">
|
|
6
|
+
<span class="psui-text-gray-80">
|
|
7
|
+
{{ el[Object.keys(el)[1]].toFixed(3) }}
|
|
8
|
+
</span>
|
|
9
|
+
<div
|
|
10
|
+
class="psui-flex psui-items-center"
|
|
11
|
+
:class="
|
|
12
|
+
el[Object.keys(el)[1]] >= 0
|
|
13
|
+
? 'psui-text-green-70'
|
|
14
|
+
: 'psui-text-red-70'
|
|
15
|
+
"
|
|
16
|
+
>
|
|
17
|
+
<i v-if="el[Object.keys(el)[1]] >= 0" class="material-icons">arrow_upward</i>
|
|
18
|
+
<i v-else class="material-icons">arrow_downward</i>
|
|
19
|
+
<span>
|
|
20
|
+
{{
|
|
21
|
+
(
|
|
22
|
+
(el[Object.keys(el)[1]] / el[Object.keys(el)[0]]) *
|
|
23
|
+
100
|
|
24
|
+
).toFixed(2)
|
|
25
|
+
}}%
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<span class="psui-text-gray-50">{{
|
|
30
|
+
el[Object.keys(el)[0]].toFixed(6)
|
|
31
|
+
}}</span>
|
|
32
|
+
</td>
|
|
33
|
+
</tr>
|
|
34
|
+
</tbody>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
export default {
|
|
39
|
+
name: "PsDataTableItem",
|
|
40
|
+
props: {
|
|
41
|
+
data: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: true,
|
|
44
|
+
default: () => {
|
|
45
|
+
return []
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style scoped>
|
|
53
|
+
.material-icons {
|
|
54
|
+
font-size: 15px;
|
|
55
|
+
margin-bottom: 2px;
|
|
56
|
+
}
|
|
57
|
+
</style>
|