@policystudio/policy-studio-ui-vue 1.0.30 → 1.0.33

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 (78) hide show
  1. package/.eslintrc.js +36 -35
  2. package/.storybook/preview.js +7 -1
  3. package/README.md +6 -2
  4. package/babel.config.js +1 -1
  5. package/dist/css/psui_styles.css +483 -143
  6. package/package.json +16 -5
  7. package/postcss.config.js +1 -1
  8. package/src/assets/images/multifamily-units.svg +10 -0
  9. package/src/assets/scss/base.scss +2 -0
  10. package/src/assets/scss/components/PsAccordion.scss +28 -11
  11. package/src/assets/scss/components/PsButton.scss +21 -4
  12. package/src/assets/scss/components/PsCardInfos.scss +1 -1
  13. package/src/assets/scss/components/PsCheckbox.scss +4 -5
  14. package/src/assets/scss/components/PsChips.scss +17 -12
  15. package/src/assets/scss/components/PsDataTable.scss +17 -0
  16. package/src/assets/scss/components/PsDialog.scss +5 -2
  17. package/src/assets/scss/components/PsDraggable.scss +64 -0
  18. package/src/assets/scss/components/PsDropdown.scss +9 -24
  19. package/src/assets/scss/components/PsDropdownList.scss +19 -0
  20. package/src/assets/scss/components/PsInput.scss +8 -3
  21. package/src/assets/scss/components/PsInputSelect.scss +6 -3
  22. package/src/assets/scss/components/PsInputTextArea.scss +5 -2
  23. package/src/assets/scss/components/PsRadioButton.scss +5 -5
  24. package/src/assets/scss/components/PsSwitch.scss +4 -4
  25. package/src/assets/scss/components/PsTabHeader.scss +14 -0
  26. package/src/assets/scss/components/PsToast.scss +3 -3
  27. package/src/assets/scss/components/PsToggle.scss +6 -2
  28. package/src/assets/scss/components/PsTooltip.scss +50 -18
  29. package/src/components/accordion/PsAccordion.vue +7 -23
  30. package/src/components/accordion/PsAccordionItem.vue +42 -26
  31. package/src/components/badges-and-tags/PsCardInfos.vue +12 -0
  32. package/src/components/badges-and-tags/PsChartLegend.vue +13 -0
  33. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +7 -0
  34. package/src/components/badges-and-tags/PsCostEffectBar.vue +6 -0
  35. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -1
  36. package/src/components/badges-and-tags/PsMiniTag.vue +6 -0
  37. package/src/components/badges-and-tags/PsProgressBar.vue +17 -9
  38. package/src/components/buttons/PsButton.vue +22 -1
  39. package/src/components/chips/PsChips.vue +33 -12
  40. package/src/components/controls/PsCheckbox.vue +32 -16
  41. package/src/components/controls/PsDraggable.vue +39 -150
  42. package/src/components/controls/PsInlineSelector.vue +30 -0
  43. package/src/components/controls/PsRadioButton.vue +28 -15
  44. package/src/components/controls/PsSwitch.vue +17 -11
  45. package/src/components/controls/PsToggle.vue +33 -12
  46. package/src/components/datatable/PsDataTable.vue +21 -1
  47. package/src/components/datatable/PsDataTableItem.vue +1 -1
  48. package/src/components/forms/PsDropdown.vue +73 -101
  49. package/src/components/forms/PsDropdownList.vue +82 -0
  50. package/src/components/forms/PsInput.vue +28 -1
  51. package/src/components/forms/PsInputSelect.vue +21 -0
  52. package/src/components/forms/PsInputTextArea.vue +54 -41
  53. package/src/components/notifications/PsDialog.vue +15 -0
  54. package/src/components/notifications/PsToast.vue +12 -0
  55. package/src/components/playground/PsScrollBar.vue +248 -0
  56. package/src/components/tabs/PsTabHeader.vue +31 -5
  57. package/src/components/tooltip/PsDialogTooltip.vue +107 -24
  58. package/src/components/tooltip/PsRichTooltip.vue +12 -9
  59. package/src/components/tooltip/PsTooltip.vue +27 -11
  60. package/src/components/ui/PsIcon.vue +30 -0
  61. package/src/index.js +30 -2
  62. package/src/stories/Accordion.stories.js +12 -48
  63. package/src/stories/Button.stories.js +30 -7
  64. package/src/stories/Chips.stories.js +11 -24
  65. package/src/stories/Dropdown.stories.js +81 -14
  66. package/src/stories/Icon.stories.js +21 -0
  67. package/src/stories/InlineSelector.stories.js +1 -1
  68. package/src/stories/Playground.stories.js +16 -0
  69. package/src/stories/Switch.stories.js +8 -2
  70. package/src/stories/Toast.stories.js +16 -16
  71. package/src/stories/Tooltip.stories.js +6 -6
  72. package/src/stories/Typography.stories.mdx +22 -18
  73. package/src/util/GeneralFunctions.js +8 -0
  74. package/src/util/imageLoader.js +1 -1
  75. package/tailwind.config.js +7 -3
  76. package/vetur/attributes.json +1376 -0
  77. package/vetur/tags.json +632 -0
  78. package/src/components/forms/PsDropdownCopy.vue +0 -212
@@ -5,6 +5,7 @@
5
5
  >
6
6
  <input
7
7
  @change="onChange"
8
+ :disabled="disabled"
8
9
  v-if="type != 'button'"
9
10
  :type="type"
10
11
  :id="label"
@@ -12,6 +13,7 @@
12
13
  />
13
14
  <label
14
15
  @click="onClick"
16
+ :disabled="disabled"
15
17
  :for="label"
16
18
  :class="getCssClass"
17
19
  >
@@ -29,44 +31,65 @@
29
31
  </template>
30
32
 
31
33
  <script>
32
- export const type = ["radio", "checkbox", "button"]
34
+ export const type = ['radio', 'checkbox', 'button']
33
35
 
34
36
  export default {
35
- name: "PsChips",
37
+ name: 'PsChips',
36
38
  props: {
39
+ /**
40
+ * It sets the label of the chips button.
41
+ */
37
42
  label: {
38
43
  type: String,
39
- default: "",
44
+ default: '',
40
45
  },
46
+ /**
47
+ * It sets the type of the chips button. eg: radio, checkbox, button.
48
+ */
41
49
  type: {
42
50
  type: String,
43
51
  required: true,
44
52
  default: 'button',
45
- validator: (type) => ["radio", "checkbox", "button"].includes(type)
53
+ validator: (type) => ['radio', 'checkbox', 'button'].includes(type)
46
54
  },
55
+ /**
56
+ * It sets the layout of the chipsbutton. eg: simple, with-icon, rich.
57
+ */
47
58
  layout: {
48
59
  type: String,
49
60
  default: 'simple',
50
61
  validator: (value) => ['simple', 'with-icon', 'rich'].includes(value)
51
62
  },
63
+ /**
64
+ * It sets the text key which will retrieve a icon from Google Fonts. Make sure to get the right description of your icon on https://fonts.google.com/.
65
+ */
52
66
  icon: {
53
67
  type: String,
54
- default: "",
68
+ default: '',
55
69
  },
70
+ /**
71
+ * It sets if the button was checked or not checked.
72
+ */
56
73
  checked: {
57
74
  type: Boolean,
58
75
  default: false
59
76
  },
77
+ /**
78
+ * It disables the chips button.
79
+ */
60
80
  disabled: {
61
81
  type: Boolean,
62
82
  default: false
63
83
  },
84
+ /**
85
+ * It sets if the button is active or not.
86
+ */
64
87
  active: {
65
88
  type: Boolean,
66
89
  default: false
67
90
  },
68
91
  },
69
- emits: ["click", "change"],
92
+ emits: ['click', 'change'],
70
93
  data() {
71
94
  return {
72
95
  isChecked: false,
@@ -84,7 +107,7 @@ export default {
84
107
  let cssClass = ''
85
108
 
86
109
  if (this.checked === true ) {
87
- cssClass = "psui-text-blue-50 psui-bg-blue-20"
110
+ cssClass = 'psui-text-blue-50 psui-bg-blue-20'
88
111
  }
89
112
 
90
113
  return cssClass
@@ -93,17 +116,15 @@ export default {
93
116
  methods: {
94
117
  onClick() {
95
118
  this.isChecked = !this.isChecked
96
- this.$emit("click")
119
+ this.$emit('click')
97
120
  },
98
121
  onChange(event) {
99
-
100
122
  this.isChecked = event.target.checked
101
-
102
123
  this.$emit('update:checked', event.target.checked)
103
- this.$emit("change")
124
+ this.$emit('change', event)
104
125
  },
105
126
  onClose() {
106
- this.$emit("close")
127
+ this.$emit('close')
107
128
  },
108
129
  },
109
130
  }
@@ -3,10 +3,9 @@
3
3
  <input
4
4
  :id="label"
5
5
  type="checkbox"
6
- :value="label"
7
- @change="onChange"
8
- :checked="checked"
9
- :disabled='disabled'
6
+ :value="inputValue"
7
+ v-model="model"
8
+ :disabled="disabled"
10
9
  />
11
10
  <label :for="label" class="psui-el-checkmark"><span>{{ label }}</span></label>
12
11
  </div>
@@ -18,41 +17,58 @@
18
17
  export default {
19
18
  name: 'PsCheckbox',
20
19
  props: {
20
+ /**
21
+ * It sets the label of the checkbox input.
22
+ */
21
23
  label: {
22
24
  type: String,
23
25
  default: '',
24
26
  },
27
+ /**
28
+ * It sets the value which should be monitored.
29
+ */
30
+ inputValue: {
31
+ type: String,
32
+ },
33
+ value:{
34
+ type: Array
35
+ },
36
+ /**
37
+ * It disables the checkbox input.
38
+ */
25
39
  disabled: {
26
40
  type: Boolean,
27
41
  default: false,
28
42
  },
43
+ /**
44
+ * It set the of the checkbox input. eg: big and small.
45
+ */
29
46
  size: {
30
47
  type: String,
31
48
  default: 'big',
32
49
  validator: (value)=> ['big', 'small'].includes(value)
33
50
  },
34
- checked:{
35
- type: Boolean,
36
- },
51
+ /**
52
+ * It set the layout of the checkbox input. eg: default and mixed.
53
+ */
37
54
  layout:{
38
55
  type: String,
39
56
  default: 'default',
40
57
  validator: (value)=> ['default','mixed'].includes(value)
41
58
  }
42
59
  },
43
- emits:['@update:checked', 'value'],
44
60
  computed:{
45
61
  getComponentClass(){
46
62
  return `size-${this.size} layout-${this.layout}`
47
- }
48
- },
49
- methods:{
50
- onChange(event){
51
- if(!this.disabled){
52
- this.$emit('value', event.target.value)
53
- this.$emit('update:checked', event.target.checked)
63
+ },
64
+ model: {
65
+ get(){
66
+ return this.value
67
+ },
68
+ set(value){
69
+ this.$emit('input', value)
54
70
  }
55
- }
71
+ }
56
72
  },
57
73
  }
58
74
  </script>
@@ -1,184 +1,73 @@
1
1
  <template>
2
- <div class="psui-w-full psui-my-4 psui-pr-4 psui-flex psui-flex-wrap psui-justify-start psui-mb-20">
3
- <div class="psui-w-full psui-mb-4 psui-rounded-lg psui-bg-gray-30 psui-p-2"
2
+ <div class="psui-el-draggable">
3
+ <div class="psui-el-draggable-wrapper"
4
4
  v-for="(columnGroup, indexColumnGroup) in getColumns.columnGroups"
5
5
  :key="indexColumnGroup"
6
- :class="{ 'is-dragging-out' : indexColumnGroup == isDraggingOverGroup}"
6
+ :ref="indexColumnGroup"
7
7
  >
8
8
  <!-- COLUMN GROUP -->
9
9
  <div
10
- class="psui-w-full psui-flex psui-justify-between psui-mb-2 psui-rounded-sm psui-items-center psui-px-2 app-draggable-list-item"
10
+ class="psui-el-draggable-title"
11
11
  draggable="true"
12
- @dragstart="dragStartGroup({ indexColumnGroup })"
13
- @dragover="dragOverGroup({ indexColumnGroup })"
14
- @dragend="dragEndGroup"
12
+ @dragstart="onDragStart"
13
+ @dragover="$emit('drag-over', $event)"
14
+ @dragend="onDragEnd"
15
15
  >
16
- <h2 class="psui-w-full psui-text-gray-80 psui-font-bold psui-pl-4 psui-py-2">{{columnGroup.title}}</h2>
17
- <i class='material-icons-round psui-text-gray-40 psui-pr-1 psui-py-2'>drag_indicator</i>
16
+ <h2 >{{columnGroup.title}}</h2>
17
+ <i >drag_indicator</i>
18
18
  </div>
19
19
 
20
- <div class="psui-w-full psui-flex psui-flex-wrap">
20
+ <ul class="psui-el-draggable-list-items-wrapper">
21
21
  <!-- COLUMNS -->
22
- <div class="psui-w-full psui-mb-2 app-draggable-list-item"
22
+ <li
23
23
  v-for="(column, indexColumn) in columnGroup.columns"
24
24
  :key="`edit-columns-column-${indexColumnGroup}-${indexColumn}`"
25
25
  :id="`edit-columns-column-${indexColumnGroup}-${indexColumn}`"
26
26
  >
27
- <div class="psui-select-none psui-w-full psui-py-2 psui-px-3 psui-rounded-sm psui-flex psui-items-center psui-bg-white"
27
+ <div class="psui-el-draggable-item-wrapper"
28
28
  draggable="true"
29
- @dragstart="dragStartColumn({ indexColumnGroup, indexColumn })"
30
- @dragover="dragOverColumn({ indexColumnGroup, indexColumn })"
31
- @dragend="dragEndColumn"
32
- :class="{ 'is-dragging-out' : checkColumnIsDragOver({ indexColumnGroup, indexColumn }) }"
29
+ @dragstart="$emit('drag-start-item',$event)"
30
+ @dragover="$emit('drag-over-item',$event)"
31
+ @dragend="$emit('drag-end-item',$event)"
33
32
  >
34
- <PsCheckbox :inputValue='column' :label='column' @change="toggleColumnIsActive({ studyKey: getColumns.key, indexColumnGroup, indexColumn, columnGroupKey: columnGroup.key})">
35
- </PsCheckbox>
36
-
37
- <!-- <Checkbox
38
- class="psui-whitespace-no-wrap"
39
- :label="column.title"
40
- :value="column.isActive"
41
- @change="toggleColumnIsActive({ studyKey: getColumns.key, indexColumnGroup, indexColumn, columnGroupKey: columnGroup.key})"
42
- ></Checkbox> -->
43
- <div class="psui-w-full psui-flex psui-justify-end">
44
- <i class='material-icons-round psui-text-gray-30'>drag_indicator</i>
33
+ <slot name="item">
34
+ </slot>
35
+ <div class="psui-el-draggable-item-icon">
36
+ <i>drag_indicator</i>
45
37
  </div>
46
38
  </div>
47
- </div>
48
- </div>
39
+ </li>
40
+ </ul>
49
41
  </div>
50
42
  </div>
51
43
  </template>
52
44
 
53
45
  <script>
54
- import PsCheckbox from './PsCheckbox.vue'
55
46
 
56
47
  export default {
57
- name: 'DragAndDropEditColumnsList',
58
- components: { PsCheckbox},
59
- props: ['getColumns', 'module'],
60
- data() {
61
- return {
62
- // Column
63
- isDraggingColumnGroup: -1,
64
- isDraggingOverColumn: -1,
65
- isDraggingColumn: -1,
66
-
67
- // Group
68
- isDraggingGroup: -1,
69
- isDraggingOverGroup: -1,
70
- }
71
- },
72
-
73
- computed: {
74
- getColumnsStateKey() {
75
- return `${this.module}Columns`
76
- },
77
- getMoveColumnStoreMutationName() {
78
- return `${this.module}/moveColumnItem`
79
- },
80
- getMoveColumnGroupStoreMutationName() {
81
- return `${this.module}/moveColumnGroup`
82
- },
83
- getToggleColumnIsActiveStoreMutationName() {
84
- return `${this.module}/toggleColumnIsActive`
85
- }
86
-
87
- },
88
-
89
- methods: {
90
- toggleColumnIsActive({ studyKey, indexColumnGroup, indexColumn, columnGroupKey }) {
91
- this.$store.commit(this.getToggleColumnIsActiveStoreMutationName, { columnsStateKey: this.getColumnsStateKey, studyKey, indexColumnGroup, indexColumn, columnGroupKey })
92
- },
93
-
48
+ name: 'PsDraggable',
49
+ props: {
94
50
  /**
95
- * Drag and drop COLUMN
96
- */
97
- dragStartColumn({ indexColumnGroup, indexColumn }) {
98
- this.isDraggingColumn = indexColumn
99
- this.isDraggingColumnGroup = indexColumnGroup
100
- },
101
- dragEndColumn() {
102
- this.moveItemColumn({
103
- studyKey: this.getColumns.key,
104
- indexColumnGroup: this.isDraggingColumnGroup,
105
- from: this.isDraggingColumn,
106
- to: this.isDraggingOverColumn
107
- })
108
- this.dragLeaveColumn()
109
- this.dragLeaveGroup()
110
- },
111
- dragOverColumn({ indexColumnGroup, indexColumn }) {
112
- if(this.isDraggingColumnGroup != indexColumnGroup) return
113
- this.isDraggingOverColumn = indexColumn
51
+ * It sets the data that will be used.
52
+ */
53
+ getColumns: {
54
+ type: Object,
114
55
  },
115
- checkColumnIsDragOver({indexColumnGroup, indexColumn }) {
116
- return (this.isDraggingColumnGroup == indexColumnGroup && this.isDraggingOverColumn == indexColumn)
117
- },
118
- dragLeaveColumn() {
119
- this.isDraggingColumn = -1
120
- this.isDraggingColumnGroup = -1
121
- this.isDraggingOverColumn = -1
122
- },
123
- moveItemColumn({ studyKey, indexColumnGroup, from, to}) {
124
- this.$store.commit(this.getMoveColumnStoreMutationName, {
125
- columnsStateKey: this.getColumnsStateKey,
126
- studyKey,
127
- indexColumnGroup,
128
- from,
129
- to
130
- })
131
- this.blinkColumns({ indexColumnGroup, to })
132
- this.dragLeaveColumn()
133
- },
134
-
135
- blinkColumns({ indexColumnGroup, to }) {
136
- const colToBlink = document.getElementById(`edit-columns-column-${indexColumnGroup}-${to}`)
137
- if(colToBlink) {
138
- colToBlink.classList.add('blink')
139
- setTimeout(() => colToBlink.classList.remove('blink'), 800)
140
- }
141
- },
142
-
143
56
  /**
144
- * Drag and drop GROUP
145
- */
146
- dragStartGroup({ indexColumnGroup }) {
147
- this.isDraggingGroup = indexColumnGroup
148
- },
149
- dragEndGroup() {
150
- this.moveItemGroup({
151
- studyKey: this.getColumns.key,
152
- from: this.isDraggingGroup,
153
- to: this.isDraggingOverGroup
154
- })
155
- this.dragLeaveGroup()
156
- },
157
- dragOverGroup({ indexColumnGroup }) {
158
- if(this.isDraggingGroup < 0) return
159
- this.isDraggingOverGroup = indexColumnGroup
160
- },
161
- dragLeaveGroup() {
162
- this.isDraggingGroup = -1
163
- this.isDraggingOverGroup = -1
57
+ * It sets the module which will be used to set getters and actions.
58
+ */
59
+ module:{
60
+ type: String
61
+ }
62
+ },
63
+ methods:{
64
+ onDragStart(event){
65
+ this.$emit('drag-start', event)
164
66
  },
165
- moveItemGroup({ studyKey, from, to}) {
166
- this.$store.commit(this.getMoveColumnGroupStoreMutationName, {
167
- columnsStateKey: this.getColumnsStateKey,
168
- studyKey,
169
- from,to
170
- })
67
+
68
+ onDragEnd(event){
69
+ this.$emit('drag-end',event)
171
70
  }
172
-
173
71
  }
174
72
  }
175
73
  </script>
176
- <style scoped>
177
- .app-draggable-list-item {
178
- cursor: grab;
179
- }
180
-
181
- .app-draggable-list-item label {
182
- margin-bottom: 0;
183
- }
184
- </style>
@@ -69,15 +69,27 @@
69
69
  export default {
70
70
  name: 'PsInlineSelector',
71
71
  props: {
72
+ /**
73
+ * It sets the default width of the inline selector.
74
+ */
72
75
  width: {
73
76
  default: 244
74
77
  },
78
+ /**
79
+ * It sets if it should receive focus or not when componented is mounted.
80
+ */
75
81
  focusOnMount: {
76
82
  default: false
77
83
  },
84
+ /**
85
+ * It sets if the component should be scrollable.
86
+ */
78
87
  shouldScroll: {
79
88
  default: false
80
89
  },
90
+ /**
91
+ * It sets the label of the component.
92
+ */
81
93
  label: {
82
94
  type: String,
83
95
  default: 'Type a City or County'
@@ -86,19 +98,31 @@ export default {
86
98
  type: Boolean,
87
99
  default: false
88
100
  },
101
+ /**
102
+ * It sets the jurisdiction selected.
103
+ */
89
104
  jurisdictionSelected: {
90
105
  type: [ Object, Boolean ]
91
106
  },
107
+ /**
108
+ * It gets and set the data that was written.
109
+ */
92
110
  search: {
93
111
  type: String,
94
112
  default: '',
95
113
  required: true
96
114
  },
115
+ /**
116
+ * It provides all the jurisdictions.
117
+ */
97
118
  jurisdictions: {
98
119
  type: Array,
99
120
  default: () => [],
100
121
  required: true
101
122
  },
123
+ /**
124
+ * It is a helper for checking if fetching data was successful.
125
+ */
102
126
  requestFetched: {
103
127
  type: Boolean,
104
128
  },
@@ -110,10 +134,16 @@ export default {
110
134
  type: Number,
111
135
  default: 0,
112
136
  },
137
+ /**
138
+ * It sets if the component is focused or not.
139
+ */
113
140
  isFocused:{
114
141
  type: Boolean,
115
142
  default: false,
116
143
  },
144
+ /**
145
+ * It sets the placeholder of the component.
146
+ */
117
147
  placeholder:{
118
148
  type: String,
119
149
  }
@@ -3,9 +3,8 @@
3
3
  <input
4
4
  :id="label"
5
5
  type="radio"
6
- :value="label"
7
- @change="onChange"
8
- :checked="checked"
6
+ :value="inputValue"
7
+ v-model="model"
9
8
  :disabled='disabled'
10
9
  />
11
10
  <label :for="label" class="psui-el-checkmark"><span>{{ label }}</span></label>
@@ -19,37 +18,51 @@
19
18
  export default {
20
19
  name: 'PsRadioButton',
21
20
  props: {
21
+ /**
22
+ * It sets the label of the radio button.
23
+ */
22
24
  label: {
23
25
  type: String,
24
26
  default: '',
25
27
  },
28
+ /**
29
+ * It's the value of the checkbox
30
+ */
31
+ inputValue:{
32
+ type: String,
33
+ },
34
+ value:{
35
+ type: String
36
+ },
37
+ /**
38
+ * It disables the radio button. All mouse events are disabled.
39
+ */
26
40
  disabled: {
27
41
  type: Boolean,
28
42
  default: false
29
43
  },
44
+ /**
45
+ * It sets the size of the radio button. eg: big and small.
46
+ */
30
47
  size: {
31
48
  type: String,
32
49
  default: 'big',
33
50
  validator: (value) => ['big', 'small'].includes(value)
34
51
  },
35
- checked:{
36
- type: Boolean,
37
- }
38
52
  },
39
- emits:['@update:checked', 'value'],
40
53
  computed: {
41
54
  getComponentClass(){
42
55
  return `size-${this.size}`
56
+ },
57
+ model: {
58
+ get(){
59
+ return this.value
60
+ },
61
+ set(value){
62
+ this.$emit('input', value)
43
63
  }
64
+ }
44
65
  },
45
- methods:{
46
- onChange(event){
47
- if(!this.disabled){
48
- this.$emit('value', event.target.value)
49
- this.$emit('update:checked', event.target.checked)
50
- }
51
- }
52
- }
53
66
  }
54
67
  </script>
55
68
 
@@ -1,9 +1,7 @@
1
1
  <template>
2
- <div class='psui-el-switch' :class="getComponentClass">
3
- <input type="checkbox" :id='label' @change="onChange">
4
- <transition>
5
- <label :for="label" class='psui-el-switch-button' :class="getToggleClass" />
6
- </transition>
2
+ <div class='psui-el-switch' :class="getComponentClass" @click="change()">
3
+ <input type="checkbox" :checked="value" />
4
+ <label class='psui-el-switch-button' :class="[getToggleClass]" />
7
5
  </div>
8
6
  </template>
9
7
 
@@ -13,13 +11,21 @@
13
11
  export default {
14
12
  name: 'PsSwitch',
15
13
  props: {
14
+ /**
15
+ * It sets the label of the switch button.
16
+ */
16
17
  label:{
17
18
  type: String,
18
19
  },
20
+ /**
21
+ * It sets the value of the switch button.
22
+ */
19
23
  value:{
20
24
  type: Boolean,
21
- required: true,
22
25
  },
26
+ /**
27
+ * It sets the size of the switch button. eg: small and big.
28
+ */
23
29
  size:{
24
30
  type: String,
25
31
  default: 'big',
@@ -28,16 +34,16 @@ export default {
28
34
  },
29
35
  computed:{
30
36
  getToggleClass(){
31
- return `toggle-${this.value.toString()}`
37
+ return this.value ? 'toggle-true' : 'toggle-false'
32
38
  },
33
39
  getComponentClass(){
34
40
  return `size-${this.size}`
35
41
  }
36
42
  },
37
- methods:{
38
- onChange(event){
39
- this.value = event.target.checked
40
- this.$emit('update:value', event.target.value)
43
+ methods: {
44
+ change() {
45
+ this.$emit('update:value', !this.value)
46
+ this.$emit('change', !this.value)
41
47
  }
42
48
  }
43
49
  }