@policystudio/policy-studio-ui-vue 1.0.28 → 1.0.31

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 (81) hide show
  1. package/.storybook/preview.js +7 -1
  2. package/README.md +6 -2
  3. package/dist/css/psui_styles.css +1863 -210
  4. package/package.json +15 -5
  5. package/src/assets/scss/base.scss +4 -0
  6. package/src/assets/scss/components/PsAccordion.scss +28 -11
  7. package/src/assets/scss/components/PsButton.scss +39 -18
  8. package/src/assets/scss/components/PsCardInfos.scss +1 -1
  9. package/src/assets/scss/components/PsCheckbox.scss +4 -5
  10. package/src/assets/scss/components/PsChips.scss +13 -8
  11. package/src/assets/scss/components/PsClimateZoneBadge.scss +1 -1
  12. package/src/assets/scss/components/PsCostEffectBar.scss +22 -27
  13. package/src/assets/scss/components/PsDialog.scss +5 -2
  14. package/src/assets/scss/components/PsDotLoader.scss +45 -0
  15. package/src/assets/scss/components/PsDraggable.scss +64 -0
  16. package/src/assets/scss/components/PsDropdown.scss +5 -22
  17. package/src/assets/scss/components/PsDropdownList.scss +19 -0
  18. package/src/assets/scss/components/PsHighlightRippleDot.scss +1 -1
  19. package/src/assets/scss/components/PsInlineSelector.scss +92 -1
  20. package/src/assets/scss/components/PsInput.scss +8 -3
  21. package/src/assets/scss/components/PsInputSelect.scss +75 -30
  22. package/src/assets/scss/components/PsInputTextArea.scss +5 -2
  23. package/src/assets/scss/components/PsMiniTag.scss +36 -0
  24. package/src/assets/scss/components/PsRadioButton.scss +5 -5
  25. package/src/assets/scss/components/PsSwitch.scss +4 -4
  26. package/src/assets/scss/components/PsTabHeader.scss +14 -0
  27. package/src/assets/scss/components/PsToast.scss +3 -3
  28. package/src/assets/scss/components/PsToggle.scss +6 -2
  29. package/src/assets/scss/components/PsTooltip.scss +51 -18
  30. package/src/components/accordion/PsAccordion.vue +7 -23
  31. package/src/components/accordion/PsAccordionItem.vue +41 -25
  32. package/src/components/badges-and-tags/PsCardInfos.vue +12 -0
  33. package/src/components/badges-and-tags/PsChartLegend.vue +13 -0
  34. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +7 -0
  35. package/src/components/badges-and-tags/PsCostEffectBar.vue +6 -1
  36. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +3 -1
  37. package/src/components/badges-and-tags/PsMiniTag.vue +21 -24
  38. package/src/components/badges-and-tags/PsProgressBar.vue +17 -9
  39. package/src/components/buttons/PsButton.vue +27 -2
  40. package/src/components/chips/PsChips.vue +24 -4
  41. package/src/components/controls/PsCheckbox.vue +32 -16
  42. package/src/components/controls/PsDraggable.vue +39 -150
  43. package/src/components/controls/PsInlineSelector.vue +144 -6
  44. package/src/components/controls/PsRadioButton.vue +28 -15
  45. package/src/components/controls/PsSlider.vue +1 -1
  46. package/src/components/controls/PsSwitch.vue +20 -11
  47. package/src/components/controls/PsToggle.vue +33 -12
  48. package/src/components/datatable/PsDataTable.vue +18 -0
  49. package/src/components/forms/PsDropdown.vue +18 -60
  50. package/src/components/forms/PsDropdownList.vue +82 -0
  51. package/src/components/forms/PsInput.vue +28 -1
  52. package/src/components/forms/PsInputSelect.vue +31 -2
  53. package/src/components/forms/PsInputTextArea.vue +53 -40
  54. package/src/components/notifications/PsDialog.vue +15 -0
  55. package/src/components/notifications/PsToast.vue +15 -0
  56. package/src/components/playground/PsScrollBar.vue +15 -0
  57. package/src/components/tabs/PsTabHeader.vue +19 -1
  58. package/src/components/tooltip/PsDialogTooltip.vue +103 -20
  59. package/src/components/tooltip/PsRichTooltip.vue +6 -3
  60. package/src/components/tooltip/PsTooltip.vue +19 -3
  61. package/src/components/ui/PsDotLoader.vue +15 -0
  62. package/src/components/ui/PsIcon.vue +30 -0
  63. package/src/index.js +39 -7
  64. package/src/stories/Accordion.stories.js +12 -48
  65. package/src/stories/Button.stories.js +30 -7
  66. package/src/stories/Chips.stories.js +14 -2
  67. package/src/stories/Colors.stories.mdx +1 -0
  68. package/src/stories/Dropdown.stories.js +36 -13
  69. package/src/stories/InlineSelector.stories.js +3 -1
  70. package/src/stories/InputSelect.stories.js +8 -0
  71. package/src/stories/MiniTag.stories.js +12 -6
  72. package/src/stories/Playground.stories.js +16 -0
  73. package/src/stories/Switch.stories.js +8 -2
  74. package/src/stories/Toast.stories.js +16 -16
  75. package/src/stories/Tooltip.stories.js +6 -6
  76. package/src/stories/Typography.stories.mdx +22 -18
  77. package/src/util/GeneralFunctions.js +8 -0
  78. package/tailwind.config.js +8 -3
  79. package/vetur/attributes.json +1376 -0
  80. package/vetur/tags.json +632 -0
  81. package/src/components/badges-and-tags/PsCostEffectBar.Copy.vue +0 -72
@@ -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>
@@ -1,15 +1,153 @@
1
1
  <template>
2
- <div class="psui-el-inline-selector">
3
- <input type="text">
2
+ <div
3
+ class="psui-el-inline-selector"
4
+ @keydown.up="$emit('keydown-up', $event)"
5
+ @keydown.down="$emit('keydown-down', $event)"
6
+ @keydown.enter="$emit('keydown-enter', $event)"
7
+ @keydown.tab="$emit('keydown-tab',$event)"
8
+ @keydown.esc="$emit('keydown-esc',$event)"
9
+ @mouseleave="$emit('mouse-leave',$event)"
10
+ >
11
+
12
+ <div class='psui-el-inline-selector-input-wrapper'>
13
+ <span> {{ search ? search : placeholder }} </span>
14
+ <input
15
+ ref="input"
16
+ :label="label"
17
+ :placeholder="placeholder"
18
+ @input="$emit('input', $event)"
19
+ @focus="$emit('focus', $event)"
20
+ @blur="$emit('blur', $event)"
21
+ autocomplete="chrome-off"
22
+ autocorrect="off"
23
+ autocapitalize="off"
24
+ spellcheck="false"
25
+ />
26
+ </div>
27
+ <transition
28
+ enter-active-class="transition ease-out duration-100 transform"
29
+ enter-class="opacity-0 scale-95"
30
+ enter-to-class="opacity-100 scale-100"
31
+ leave-active-class="transition ease-in duration-100 transform"
32
+ leave-class="opacity-100 scale-100"
33
+ leave-to-class="opacity-0 scale-95"
34
+ >
35
+ <div
36
+ v-if="search"
37
+ role="menu"
38
+ aria-orientation="vertical"
39
+ class="psui-el-inline-selector-dropdown-wrapper"
40
+ >
41
+ <slot name='loader'></slot>
42
+ <div class="psui-el-inline-selector-dropdown">
43
+ <div v-if="requestFetched && !jurisdictions.length">
44
+ <h3>Hmmmm</h3>
45
+ <p>Please check the spelling and try again</p>
46
+ </div>
47
+ <ul v-else>
48
+ <li
49
+ tabindex="0"
50
+ v-for="(jurisdiction, index) in jurisdictions"
51
+ :key="`dropdown-jurisdiction-${jurisdiction.id}`"
52
+ :id="`jurisdiction-list-item-${index}`"
53
+ @click="$emit('click', $event)"
54
+ @mouseover="('mouse-over', $event)"
55
+ >
56
+ <span >
57
+ <h3>{{jurisdiction.title}}</h3>
58
+ <h3 >{{jurisdiction.type}}</h3>
59
+ </span>
60
+ </li>
61
+ </ul>
62
+ </div>
63
+ </div>
64
+ </transition>
4
65
  </div>
5
66
  </template>
6
67
 
7
68
  <script>
8
69
  export default {
9
-
70
+ name: 'PsInlineSelector',
71
+ props: {
72
+ /**
73
+ * It sets the default width of the inline selector.
74
+ */
75
+ width: {
76
+ default: 244
77
+ },
78
+ /**
79
+ * It sets if it should receive focus or not when componented is mounted.
80
+ */
81
+ focusOnMount: {
82
+ default: false
83
+ },
84
+ /**
85
+ * It sets if the component should be scrollable.
86
+ */
87
+ shouldScroll: {
88
+ default: false
89
+ },
90
+ /**
91
+ * It sets the label of the component.
92
+ */
93
+ label: {
94
+ type: String,
95
+ default: 'Type a City or County'
96
+ },
97
+ selectOnlyFirstClimateZone: {
98
+ type: Boolean,
99
+ default: false
100
+ },
101
+ /**
102
+ * It sets the jurisdiction selected.
103
+ */
104
+ jurisdictionSelected: {
105
+ type: [ Object, Boolean ]
106
+ },
107
+ /**
108
+ * It gets and set the data that was written.
109
+ */
110
+ search: {
111
+ type: String,
112
+ default: '',
113
+ required: true
114
+ },
115
+ /**
116
+ * It provides all the jurisdictions.
117
+ */
118
+ jurisdictions: {
119
+ type: Array,
120
+ default: () => [],
121
+ required: true
122
+ },
123
+ /**
124
+ * It is a helper for checking if fetching data was successful.
125
+ */
126
+ requestFetched: {
127
+ type: Boolean,
128
+ },
129
+ showDropDown:{
130
+ type: Boolean,
131
+ default: true,
132
+ },
133
+ currentSelected:{
134
+ type: Number,
135
+ default: 0,
136
+ },
137
+ /**
138
+ * It sets if the component is focused or not.
139
+ */
140
+ isFocused:{
141
+ type: Boolean,
142
+ default: false,
143
+ },
144
+ /**
145
+ * It sets the placeholder of the component.
146
+ */
147
+ placeholder:{
148
+ type: String,
149
+ }
150
+ }
10
151
  }
11
152
  </script>
12
153
 
13
- <style>
14
-
15
- </style>
@@ -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
 
@@ -81,7 +81,7 @@ export default {
81
81
  }
82
82
  </script>
83
83
 
84
- <style>
84
+ <style scoped>
85
85
  .slider {
86
86
  width: 100%;
87
87
  -webkit-appearance: none;
@@ -1,9 +1,7 @@
1
1
  <template>
2
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>
3
+ <input type="checkbox" :id='label' v-model="getValue">
4
+ <label :for="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',
@@ -32,14 +38,17 @@ export default {
32
38
  },
33
39
  getComponentClass(){
34
40
  return `size-${this.size}`
41
+ },
42
+ getValue:{
43
+ get(){
44
+ return this.value
45
+ },
46
+ set(value){
47
+ this.$emit('input', value)
48
+ this.$emit('change', value)
49
+ }
35
50
  }
36
51
  },
37
- methods:{
38
- onChange(event){
39
- this.value = event.target.checked
40
- this.$emit('update:value', event.target.value)
41
- }
42
- }
43
52
  }
44
53
  </script>
45
54
 
@@ -3,11 +3,11 @@
3
3
  <button
4
4
  type="button"
5
5
  v-for="(item, index) in items"
6
- :key="index"
6
+ :key="getKeyValue(item) + index"
7
7
  @click="selectOption(item)"
8
- :class="{ 'status-active': getSelected === item }"
8
+ :class="{ 'status-active': selected == item }"
9
9
  >
10
- {{ item }}
10
+ {{ getKeyLabel(item) }}
11
11
  </button>
12
12
  </div>
13
13
  </template>
@@ -18,26 +18,47 @@
18
18
  export default {
19
19
  name: 'PsToggle',
20
20
  props: {
21
+ /**
22
+ * It sets the items which will be used to create the toggle tab. See Figma - Controls & Selector for more information.
23
+ */
21
24
  items: {
22
25
  type: Array,
23
26
  required: true
24
27
  },
28
+ /**
29
+ * It sets the value selected.
30
+ */
25
31
  selected: {},
26
- },
27
- computed: {
28
- getSelected() {
29
- if (this.selected) {
30
- return this.selected
31
- } else {
32
- return false
33
- }
32
+ /**
33
+ * It sets the key label of your items if needed.
34
+ */
35
+ keyLabel: {
36
+ type: [String, Function],
37
+ default: 'label'
34
38
  },
39
+ /**
40
+ * It sets the key value of your items if needed.
41
+ */
42
+ keyValue: {
43
+ type: [String, Function],
44
+ default: 'value'
45
+ }
35
46
  },
36
47
  methods: {
37
48
  selectOption(item) {
38
49
  this.$emit('update:selected', item)
39
50
  this.$emit('change', item)
40
- }
51
+ },
52
+ getKeyLabel(item) {
53
+ if(typeof this.keyLabel == 'function') return this.keyLabel(item)
54
+ if(typeof item === 'object') return item[this.keyLabel]
55
+ return item
56
+ },
57
+ getKeyValue(item) {
58
+ if(typeof this.keyValue == 'function') return this.keyValue(item)
59
+ if(typeof item === 'object') return item[this.keyLabel]
60
+ return item
61
+ },
41
62
  }
42
63
  }
43
64
  </script>
@@ -35,6 +35,9 @@ export const alignment = ['center', 'right', 'left']
35
35
  export default {
36
36
  name: 'PsDataTable',
37
37
  props: {
38
+ /**
39
+ * It sets the type of the data table. eg: simple or rich.
40
+ */
38
41
  type: {
39
42
  type: String,
40
43
  required: true,
@@ -42,17 +45,29 @@ export default {
42
45
  return ['simple', 'rich'].indexOf(value) !== -1
43
46
  },
44
47
  },
48
+ /**
49
+ * It sets the values which will be use to render the header.
50
+ */
45
51
  header: {
46
52
  type: Array,
47
53
  required: true,
48
54
  },
55
+ /**
56
+ * It sets the values which will be use to render the body.
57
+ */
49
58
  data: {
50
59
  type: Array,
51
60
  required: true
52
61
  },
62
+ /**
63
+ * It sets the values which will be use to render the footer.
64
+ */
53
65
  footer: {
54
66
  type: Array,
55
67
  },
68
+ /**
69
+ * It sets the alignment of the whole context.
70
+ */
56
71
  align: {
57
72
  type: String,
58
73
  default: 'left',
@@ -60,6 +75,9 @@ export default {
60
75
  return ['center', 'right', 'left'].indexOf(value) !== -1
61
76
  }
62
77
  },
78
+ /**
79
+ * It sets additional styling if needed.
80
+ */
63
81
  cssStyle: {
64
82
  type: String,
65
83
  default: 'psui-text-gray-60'