@policystudio/policy-studio-ui-vue 1.1.90-beta.2 → 1.1.90-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.1.90-beta.2",
3
+ "version": "1.1.90-beta.3",
4
4
  "description": "Policy Studio UI",
5
5
  "main": "src/index.js",
6
6
  "author": "Policy Studio Team",
@@ -6,127 +6,105 @@
6
6
  class="psui-el-button"
7
7
  :class="[getComponentClass, {'hover': isHover}, {'disabled': disabled || loading }]"
8
8
  >
9
- <svg
9
+ <svg
10
10
  v-if="loading"
11
11
  class="psui-animate-spin psui-mr-3 psui-h-5 psui-w-5 psui-text-black"
12
12
  :class="`${iconPosition == 'left' ? 'psui-mr-3' : 'psui-ml-3 psui--mr-1'}`"
13
- xmlns="http://www.w3.org/2000/svg"
14
- fill="none"
15
- viewBox="0 0 24 24"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ fill="none"
15
+ viewBox="0 0 24 24"
16
16
  >
17
- <circle
18
- class="psui-opacity-25"
19
- cx="12"
20
- cy="12"
21
- r="10"
22
- stroke="currentColor"
23
- stroke-width="4"
17
+ <circle
18
+ class="psui-opacity-25"
19
+ cx="12"
20
+ cy="12"
21
+ r="10"
22
+ stroke="currentColor"
23
+ stroke-width="4"
24
24
  />
25
- <path
26
- class="psui-opacity-75"
27
- fill="currentColor"
28
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
25
+ <path
26
+ class="psui-opacity-75"
27
+ fill="currentColor"
28
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
29
29
  />
30
30
  </svg>
31
- <i
32
- v-else-if="icon"
33
- :class="iconClass"
34
- class="material-icons-round"
31
+ <i
32
+ v-else-if="icon"
33
+ :class="iconClass"
34
+ class="material-icons-round"
35
35
  >{{ icon }}</i>
36
36
  <span v-if="label">{{ label }}</span>
37
37
  </button>
38
38
  </template>
39
39
 
40
- <script>
41
- export default {
42
- props: {
43
- /**
44
- * It set de label of the button when component is rendered.
45
- */
40
+ <script setup>
41
+ import { computed, ref } from 'vue'
42
+
43
+ const isHover = ref(false)
44
+
45
+ const emit = defineEmits(['click'])
46
+
47
+ const props = defineProps({
46
48
  label: {
47
49
  type: String,
50
+ default: ''
48
51
  },
49
- /**
50
- * It set the layout of the button. eg: solid, outline, ghost, onlytext and caution.
51
- */
52
- layout: {
52
+ layout:{
53
53
  type: String,
54
54
  default: 'solid',
55
55
  validator: (value) => ['solid','outline','ghost','onlytext','caution'].includes(value)
56
56
  },
57
- /**
58
- * It sets the text key which will retrieve a icon from Google Fonts. Make sure to get the correct description of your icon on https://fonts.google.com/.
59
- */
60
57
  icon: {
61
58
  type: String,
59
+ default: ''
62
60
  },
63
- /**
64
- * It sets the position of the icon. eg: left or right.
65
- */
66
- iconPosition:{
61
+ iconPosition: {
67
62
  type: String,
68
63
  default: 'left',
69
64
  validator: (value) => ['left','right'].includes(value)
70
65
  },
71
- /**
72
- * It sets the size of the icon. eg: small, medium and big.
73
- */
74
66
  size: {
75
- type: String,
76
- default: 'big',
77
- validator: (value) => ['small','medium','big'].includes(value)
78
- },
79
- /**
80
- * It disable the button. All mouse event are disabled.
81
- */
82
- disabled: {
83
- type: Boolean,
84
- default: false
85
- },
86
- /**
87
- * It disable and add a spin icon to the button. All mouse event are disabled.
88
- */
89
- loading: {
90
- type: Boolean,
91
- default: false
92
- },
93
- /**
94
- * It set any further css style that might be needed.
95
- */
96
- iconClass:{
97
- type: String
98
- }
99
- },
100
- data(){
101
- return {
102
- isHover: false,
103
- }
104
- },
105
- computed: {
106
- getComponentClass(){
107
- if(this.icon){
108
- return `layout-${this.layout} size-${this.size} icon-${this.iconPosition}`
109
- } else {
110
- return `layout-${this.layout} size-${this.size}`
111
- }
112
- },
113
- },
114
- methods: {
115
- onClick() {
116
- if (this.disabled) return
117
- this.$emit('click')
118
- },
119
- onMouseEnter(){
120
- if(!this.disabled){
121
- this.isHover = true
122
- }
123
- },
124
- onMouseLeave(){
125
- if(!this.disabled){
126
- this.isHover = false
127
- }
67
+ type: String,
68
+ default: 'big',
69
+ validator: (value) => ['small','medium','big'].includes(value)
70
+ },
71
+ disabled: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ loading: {
76
+ type: Boolean,
77
+ default: false
78
+ },
79
+ iconClass:{
80
+ type: String,
81
+ default: ''
82
+ }
83
+ })
84
+
85
+ const getComponentClass = computed(()=>{
86
+ if(props.icon){
87
+ return `layout-${props.layout} size-${props.size} icon-${props.iconPosition}`
88
+ } else {
89
+ return `layout-${props.layout} size-${props.size}`
90
+ }
91
+ })
92
+
93
+ const onClick = () => {
94
+ if (props.disabled) return
95
+ emit('click')
96
+ }
97
+ const onMouseEnter = () => {
98
+ if(!this.disabled){
99
+ isHover.value = true
100
+ }
101
+ }
102
+
103
+ const onMouseLeave = () => {
104
+ if(!this.disabled){
105
+ isHover.value = false
128
106
  }
129
107
  }
130
- }
108
+
131
109
  </script>
132
110