@policystudio/policy-studio-ui-vue 1.1.89 → 1.1.90-access.0

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 (170) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +75 -67
  3. package/.github/workflows/deploy-storybook.yml +5 -5
  4. package/.nvmrc +1 -0
  5. package/dist/css/psui_styles_output.css +6617 -0
  6. package/dist/index.d.ts +51 -0
  7. package/dist/index.js +106 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/util/GeneralFunctions.d.ts +3 -0
  10. package/dist/util/GeneralFunctions.js +35 -0
  11. package/dist/util/GeneralFunctions.js.map +1 -0
  12. package/dist/util/directives.d.ts +1 -0
  13. package/dist/util/directives.js +22 -0
  14. package/dist/util/directives.js.map +1 -0
  15. package/dist/util/imageLoader.d.ts +6 -0
  16. package/dist/util/imageLoader.js +52 -0
  17. package/dist/util/imageLoader.js.map +1 -0
  18. package/doc/.nvmrc +1 -0
  19. package/doc/.storybook/PolicyStudio.ts +11 -0
  20. package/doc/.storybook/main.ts +27 -0
  21. package/doc/.storybook/manager.ts +7 -0
  22. package/{.storybook/preview.js → doc/.storybook/preview.ts} +2 -3
  23. package/doc/package-lock.json +22653 -0
  24. package/doc/package.json +71 -0
  25. package/doc/shims-vue.d.ts +6 -0
  26. package/{src/stories/Accordion.stories.js → doc/src/stories/Accordion.stories.ts} +4 -5
  27. package/{src/stories/BadgeWithIcon.stories.js → doc/src/stories/BadgeWithIcon.stories.ts} +2 -2
  28. package/{src/stories/BarChart.stories.js → doc/src/stories/BarChart.stories.ts} +2 -2
  29. package/{src/stories/Breadcrumb.stories.js → doc/src/stories/Breadcrumb.stories.ts} +2 -5
  30. package/{src/stories/Button.stories.js → doc/src/stories/Button.stories.ts} +130 -130
  31. package/{src/stories/CardInfos.stories.js → doc/src/stories/CardInfos.stories.ts} +2 -3
  32. package/{src/stories/ChartLegend.stories.js → doc/src/stories/ChartLegend.stories.ts} +2 -3
  33. package/{src/stories/Checkbox.stories.js → doc/src/stories/Checkbox.stories.ts} +2 -2
  34. package/{src/stories/CheckboxSimple.stories.js → doc/src/stories/CheckboxSimple.stories.ts} +2 -2
  35. package/{src/stories/Chips.stories.js → doc/src/stories/Chips.stories.ts} +22 -23
  36. package/{src/stories/ClimateZoneBadge.stories.js → doc/src/stories/ClimateZoneBadge.stories.ts} +3 -2
  37. package/doc/src/stories/Collapse.stories.ts +46 -0
  38. package/{src/stories/CostEffectBar.stories.js → doc/src/stories/CostEffectBar.stories.ts} +3 -2
  39. package/{src/stories/Datatable.stories.js → doc/src/stories/Datatable.stories.ts} +7 -4
  40. package/{src/stories/DateCardInfo.stories.js → doc/src/stories/DateCardInfo.stories.ts} +2 -6
  41. package/{src/stories/Dialog.stories.js → doc/src/stories/Dialog.stories.ts} +2 -2
  42. package/{src/stories/Draggable.stories.js → doc/src/stories/Draggable.stories.ts} +3 -2
  43. package/{src/stories/Dropdown.stories.js → doc/src/stories/Dropdown.stories.ts} +4 -3
  44. package/{src/stories/DropdownList.stories.js → doc/src/stories/DropdownList.stories.ts} +4 -2
  45. package/{src/stories/ElevationSystem.stories.mdx → doc/src/stories/ElevationSystem.mdx} +1 -1
  46. package/{src/stories/HighlightRippleDot.stories.js → doc/src/stories/HighlightRippleDot.stories.ts} +3 -2
  47. package/{src/stories/Icon.stories.js → doc/src/stories/Icon.stories.ts} +3 -1
  48. package/{src/stories/InlineSelector.stories.js → doc/src/stories/InlineSelector.stories.ts} +2 -2
  49. package/{src/stories/Input.stories.js → doc/src/stories/Input.stories.ts} +7 -4
  50. package/{src/stories/InputSelect.stories.js → doc/src/stories/InputSelect.stories.ts} +3 -2
  51. package/{src/stories/InputTextArea.stories.js → doc/src/stories/InputTextArea.stories.ts} +2 -2
  52. package/{src/stories/Introduction.stories.mdx → doc/src/stories/Introduction.mdx} +101 -101
  53. package/{src/stories/MiniTag.stories.js → doc/src/stories/MiniTag.stories.ts} +9 -2
  54. package/{src/stories/ProgressBar.stories.js → doc/src/stories/ProgressBar.stories.ts} +3 -2
  55. package/{src/stories/RadioButton.stories.js → doc/src/stories/RadioButton.stories.ts} +2 -2
  56. package/{src/stories/RadioButtonSimple.stories.js → doc/src/stories/RadioButtonSimple.stories.ts} +2 -2
  57. package/{src/stories/SimpleAlert.stories.js → doc/src/stories/SimpleAlert.stories.ts} +3 -2
  58. package/{src/stories/Slider.stories.js → doc/src/stories/Slider.stories.ts} +6 -2
  59. package/{src/stories/Switch.stories.js → doc/src/stories/Switch.stories.ts} +2 -2
  60. package/{src/stories/TabHeader.stories.js → doc/src/stories/TabHeader.stories.ts} +6 -1
  61. package/{src/stories/TableResults.stories.js → doc/src/stories/TableResults.stories.ts} +11 -7
  62. package/{src/stories/TagScope.stories.js → doc/src/stories/TagScope.stories.ts} +3 -2
  63. package/{src/stories/TestimonialCard.stories.js → doc/src/stories/TestimonialCard.stories.ts} +3 -3
  64. package/{src/stories/Toast.stories.js → doc/src/stories/Toast.stories.ts} +2 -2
  65. package/{src/stories/Toggle.stories.js → doc/src/stories/Toggle.stories.ts} +7 -4
  66. package/{src/stories/Tooltip.stories.js → doc/src/stories/Tooltip.stories.ts} +6 -6
  67. package/{src/stories/Typography.stories.mdx → doc/src/stories/Typography.mdx} +107 -105
  68. package/doc/tsconfig.json +17 -0
  69. package/package.json +43 -39
  70. package/scripts/gulp.js +11 -0
  71. package/scripts/kill-port.sh +12 -0
  72. package/src/App.vue +30 -0
  73. package/src/assets/scss/base.scss +3 -30
  74. package/src/assets/scss/components/PsAccordion.scss +2 -2
  75. package/src/assets/scss/components/PsButton.scss +7 -1
  76. package/src/assets/scss/components/PsChips.scss +12 -7
  77. package/src/assets/scss/components/PsCollapse.scss +71 -0
  78. package/src/assets/scss/components/PsCostEffectBar.scss +4 -4
  79. package/src/assets/scss/components/PsDataTable.scss +1 -1
  80. package/src/assets/scss/components/PsDateCardInfo.scss +4 -5
  81. package/src/assets/scss/components/PsDialog.scss +7 -0
  82. package/src/assets/scss/components/PsDropdownList.scss +1 -1
  83. package/src/assets/scss/components/PsInput.scss +9 -0
  84. package/src/assets/scss/components/PsProgressBar.scss +4 -4
  85. package/src/assets/scss/components/PsTabHeader.scss +57 -2
  86. package/src/assets/scss/components/PsTableResults.scss +51 -82
  87. package/src/assets/scss/components/PsTestimonialCard.scss +1 -1
  88. package/src/assets/scss/components/PsTooltip.scss +149 -145
  89. package/src/components/accordion/PsAccordion.vue +20 -21
  90. package/src/components/accordion/PsAccordionItem.vue +121 -81
  91. package/src/components/badges-and-tags/PsBadgeWithIcon.vue +37 -36
  92. package/src/components/badges-and-tags/PsCardInfos.vue +40 -40
  93. package/src/components/badges-and-tags/PsChartLegend.vue +50 -41
  94. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +13 -19
  95. package/src/components/badges-and-tags/PsCostEffectBar.vue +28 -61
  96. package/src/components/badges-and-tags/PsDateCardInfo.vue +17 -18
  97. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +4 -3
  98. package/src/components/badges-and-tags/PsMiniTag.vue +39 -41
  99. package/src/components/badges-and-tags/PsProgressBar.vue +72 -68
  100. package/src/components/badges-and-tags/PsTagScope.vue +17 -22
  101. package/src/components/badges-and-tags/PsTestimonialCard.vue +25 -30
  102. package/src/components/buttons/PsButton.vue +90 -98
  103. package/src/components/chips/PsChips.vue +118 -103
  104. package/src/components/collapse/PsCollapse.vue +124 -0
  105. package/src/components/controls/PsCheckbox.vue +86 -83
  106. package/src/components/controls/PsCheckboxSimple.vue +97 -97
  107. package/src/components/controls/PsDraggable.vue +100 -99
  108. package/src/components/controls/PsInlineSelector.vue +111 -113
  109. package/src/components/controls/PsRadioButton.vue +72 -60
  110. package/src/components/controls/PsRadioButtonSimple.vue +81 -77
  111. package/src/components/controls/PsSlider.vue +190 -181
  112. package/src/components/controls/PsSwitch.vue +63 -54
  113. package/src/components/controls/PsToggle.vue +62 -57
  114. package/src/components/data-graphics/PsBarChart.vue +22 -23
  115. package/src/components/datatable/PsDataTable.vue +70 -65
  116. package/src/components/datatable/PsDataTableItem.vue +30 -32
  117. package/src/components/forms/PsDropdown.vue +173 -166
  118. package/src/components/forms/PsDropdownList.vue +133 -130
  119. package/src/components/forms/PsInput.vue +163 -146
  120. package/src/components/forms/PsInputSelect.vue +121 -100
  121. package/src/components/forms/PsInputTextArea.vue +84 -74
  122. package/src/components/navigations/PsBreadcrumb.vue +25 -34
  123. package/src/components/notifications/PsDialog.vue +67 -60
  124. package/src/components/notifications/PsSimpleAlert.vue +47 -37
  125. package/src/components/notifications/PsToast.vue +48 -42
  126. package/src/components/table-results/PsTableResults.vue +527 -504
  127. package/src/components/table-results/PsTableResultsBody.vue +69 -68
  128. package/src/components/table-results/PsTableResultsHead.vue +108 -69
  129. package/src/components/table-results/PsTableResultsHeadComparison.vue +88 -69
  130. package/src/components/table-results/PsTableResultsHeadFlexible.vue +112 -72
  131. package/src/components/table-results/PsTableResultsRow.vue +61 -58
  132. package/src/components/tabs/PsTabHeader.vue +138 -116
  133. package/src/components/tooltip/PsDialogTooltip.vue +112 -107
  134. package/src/components/tooltip/PsRichTooltip.vue +46 -43
  135. package/src/components/tooltip/PsTooltip.vue +126 -122
  136. package/src/components/ui/PsDotLoader.vue +6 -10
  137. package/src/components/ui/PsIcon.vue +149 -134
  138. package/src/index.ts +159 -0
  139. package/src/tsconfig.json +12 -0
  140. package/src/types/index.d.ts +6 -0
  141. package/src/util/GeneralFunctions.js +16 -7
  142. package/src/util/directives.ts +24 -0
  143. package/src/util/imageLoader.js +14 -7
  144. package/tailwind.config.js +12 -3
  145. package/tsconfig.json +47 -0
  146. package/.storybook/PolicyStudio.js +0 -10
  147. package/.storybook/eventBus.js +0 -3
  148. package/.storybook/main.js +0 -25
  149. package/.storybook/manager.js +0 -6
  150. package/babel.config.js +0 -3
  151. package/backup-package-lock.json +0 -37194
  152. package/dist/css/psui_styles.css +0 -110965
  153. package/postcss.config.js +0 -8
  154. package/src/components/playground/PsScrollBar.vue +0 -248
  155. package/src/index.js +0 -167
  156. package/src/stories/Playground.stories.js +0 -16
  157. /package/{src → doc/src}/assets/images/multifamily-units.svg +0 -0
  158. /package/{src → doc/src}/assets/images/policy-studio.svg +0 -0
  159. /package/{src/contents/ComparisonData.js → doc/src/contents/ComparisonData.ts} +0 -0
  160. /package/{src/contents/FlexibleData.js → doc/src/contents/FlexibleData.ts} +0 -0
  161. /package/{src/contents/ResultsData.js → doc/src/contents/ResultsData.ts} +0 -0
  162. /package/{src/stories/Colors.stories.mdx → doc/src/stories/Colors.mdx} +0 -0
  163. /package/{src → doc/src}/stories/assets/code-brackets.svg +0 -0
  164. /package/{src → doc/src}/stories/assets/colors.svg +0 -0
  165. /package/{src → doc/src}/stories/assets/comments.svg +0 -0
  166. /package/{src → doc/src}/stories/assets/direction.svg +0 -0
  167. /package/{src → doc/src}/stories/assets/flow.svg +0 -0
  168. /package/{src → doc/src}/stories/assets/plugin.svg +0 -0
  169. /package/{src → doc/src}/stories/assets/repo.svg +0 -0
  170. /package/{src → doc/src}/stories/assets/stackalt.svg +0 -0
@@ -1,22 +1,27 @@
1
1
  <template>
2
- <div class="psui-el-input" :class="[getComponentClass, `layout-${layout}`]" >
3
-
2
+ <div
3
+ class="psui-el-input"
4
+ :class="[getComponentClass, `layout-${layout}`]"
5
+ >
4
6
  <label v-if="label"> {{ label }} </label>
5
7
 
6
- <div
8
+ <div
7
9
  class="psui-el-input-wrapper"
8
- @mouseenter="$emit('mouseenter',$event)"
9
- @mouseleave="$emit('mouseleave',$event)"
10
+ @mouseenter="emit('mouseenter', $event)"
11
+ @mouseleave="emit('mouseleave', $event)"
10
12
  >
11
- <div v-if="$slots.prepend" class="psui-el-input-prepend">
12
- <slot name="prepend"></slot>
13
+ <div
14
+ v-if="$slots.prepend"
15
+ class="psui-el-input-prepend"
16
+ >
17
+ <slot name="prepend" />
13
18
  </div>
14
- <PsRichTooltip
19
+ <PsRichTooltip
15
20
  class="psui-w-full"
16
21
  css-class="psui-w-48"
17
22
  :ignore-dialog="!showTooltip"
18
23
  >
19
- <template v-slot:trigger>
24
+ <template #trigger>
20
25
  <input
21
26
  :title="title"
22
27
  :type="type"
@@ -28,162 +33,174 @@
28
33
  :max="maxValue"
29
34
  @focus="onInputFocus"
30
35
  @blur="onInputBlur"
31
- @input="$emit('input', $event)"
32
- @keydown="$emit('keydown', $event)"
33
- @change="$emit('change', $event)"
36
+ @input="emit('input', $event)"
37
+ @keydown="emit('keydown', $event)"
38
+ @change="emit('change', $event)"
34
39
  v-bind="getAttrs"
35
- :class="{ 'focus': isFocus }"
36
- />
40
+ :class="{ focus: isFocus }"
41
+ >
37
42
  </template>
38
- <template v-slot:content>
43
+ <template #content>
39
44
  <div class="text-left">
40
45
  {{ tooltipText }}
41
46
  </div>
42
47
  </template>
43
48
  </PsRichTooltip>
44
- <div v-if="$slots.append || hasError" class="psui-el-input-append">
45
- <span v-if="hasError" class="material-icons psui-text-red-20 material-icons-sharp">error</span>
46
- <slot v-else name="append"></slot>
49
+ <div
50
+ v-if="$slots.append || hasError"
51
+ class="psui-el-input-append"
52
+ >
53
+ <span
54
+ v-if="hasError"
55
+ class="material-icons psui-text-red-20 material-icons-sharp"
56
+ >error</span>
57
+ <slot
58
+ name="append"
59
+ />
47
60
  </div>
48
61
  </div>
49
62
 
50
- <p v-if="hint || (hasError && typeof hasError === 'string')" class="psui-el-input-hint">
63
+ <p
64
+ v-if="hint || (hasError && typeof hasError === 'string')"
65
+ class="psui-el-input-hint"
66
+ >
51
67
  {{ typeof hasError === 'string' ? hasError : hint }}
52
68
  </p>
53
-
54
- </div>
69
+ </div>
55
70
  </template>
56
71
 
57
- <script>
72
+ <script setup>
58
73
  import PsRichTooltip from '../tooltip/PsRichTooltip.vue'
74
+ import { ref, computed, useAttrs } from 'vue'
59
75
 
60
- export default {
61
- name: 'PsInput',
62
- components: {
63
- PsRichTooltip,
76
+ const props = defineProps({
77
+ /**
78
+ * It set the title and also its tooltip default behavior
79
+ */
80
+ title: {
81
+ type: String,
82
+ default: '',
83
+ },
84
+ /**
85
+ * It sets the type of your button. default: text.
86
+ */
87
+ type: {
88
+ type: String,
89
+ default: 'text',
90
+ },
91
+ /**
92
+ * It sets a placeholder for your button if needed.
93
+ */
94
+ placeholder: {
95
+ type: String,
96
+ default: '',
97
+ },
98
+ /**
99
+ * It sets the label of the input if needed.
100
+ */
101
+ label: {
102
+ type: String,
103
+ default: '',
104
+ },
105
+ /**
106
+ * It sets a text below the input. See Figma Text fileds & Forms.
107
+ */
108
+ hint: {
109
+ type: String,
110
+ default: '',
111
+ },
112
+ /**
113
+ * It sets the layout of your button. eg: mini and default.
114
+ */
115
+ layout: {
116
+ type: String,
117
+ default: 'default',
118
+ validator: (value) => ['default', 'mini'].includes(value),
119
+ },
120
+ /**
121
+ * It sets the value of the button.
122
+ */
123
+ value: {
124
+ required: true,
125
+ },
126
+ /**
127
+ * It disables the input. All mouse events are disabled.
128
+ */
129
+ disabled: {
130
+ type: Boolean,
131
+ default: false,
132
+ },
133
+ /**
134
+ * It sets if the input found any error.
135
+ */
136
+ hasError: {
137
+ type: [String, Boolean],
138
+ default: false,
139
+ },
140
+ /**
141
+ * It sets a active css class based on a boolean property.
142
+ */
143
+ active: {
144
+ type: Boolean,
145
+ default: false,
64
146
  },
65
- props: {
66
- /**
67
- * It set the title and also its tooltip default behavior
68
- */
69
- title: {
70
- type: String,
71
- default: ''
72
- },
73
- /**
74
- * It sets the type of your button. default: text.
75
- */
76
- type: {
77
- type: String,
78
- default: 'text'
79
- },
80
- /**
81
- * It sets a placeholder for your button if needed.
82
- */
83
- placeholder: {
84
- type: String
85
- },
86
- /**
87
- * It sets the label of the input if needed.
88
- */
89
- label: {
90
- type: String
91
- },
92
- /**
93
- * It sets a text below the input. See Figma Text fileds & Forms.
94
- */
95
- hint: {
96
- type: String
97
- },
98
- /**
99
- * It sets the layout of your button. eg: mini and default.
100
- */
101
- layout: {
102
- type: String,
103
- default: 'default',
104
- validator: (value) => ['default', 'mini'].includes(value)
105
- },
106
- /**
107
- * It sets the value of the button.
108
- */
109
- value: {
110
- required: true,
111
- },
112
- /**
113
- * It disables the input. All mouse events are disabled.
114
- */
115
- disabled: {
116
- type: Boolean,
117
- default: false
118
- },
119
- /**
120
- * It sets if the input found any error.
121
- */
122
- hasError: {
123
- type: [String, Boolean],
124
- default: false
125
- },
126
- /**
127
- * It sets a active css class based on a boolean property.
128
- */
129
- active: {
130
- type: Boolean,
131
- default: false
132
- },
133
- minValue: {
134
- type: null
135
- },
136
- maxValue: {
137
- type: null
138
- },
139
- step:{
140
- type: null
141
- },
142
- showTooltip: {
143
- type: Boolean,
144
- default: false,
145
- },
146
- tooltipText: {
147
- type: String,
148
- default: '',
149
- },
150
- },
151
- data: () => ({
152
- isFocus: false,
153
- }),
154
- computed: {
155
- getAttrs() {
156
- const defaultAttrs = {
157
- autocapitalize: 'sentences',
158
- autocomplete: 'chrome-off',
159
- autocorrect: 'off',
160
- spellcheck: 'spellcheck'
161
- }
162
- return { ...defaultAttrs, ...this.$attrs }
163
- },
164
- getComponentClass() {
165
- if (this.disabled) {
166
- return 'status-disabled'
167
- } else if (this.hasError) {
168
- return 'status-error'
169
- } else if (this.isFocus || this.isTyping || this.active ) {
170
- return 'status-active'
171
- } else {
172
- return 'status-resting'
173
- }
174
- },
147
+ minValue: {
148
+ type: null,
175
149
  },
176
- methods: {
177
- onInputFocus($event) {
178
- this.isFocus = true
179
- this.$emit('focus', $event)
180
- },
181
- onInputBlur($event) {
182
- this.isFocus = false
183
- this.$emit('blur', $event)
184
- },
150
+ maxValue: {
151
+ type: null,
152
+ },
153
+ step: {
154
+ type: null,
155
+ },
156
+ showTooltip: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ tooltipText: {
161
+ type: String,
162
+ default: '',
163
+ },
164
+ })
165
+
166
+ const emit = defineEmits(['focus', 'blur', 'mouseenter', 'mouseleave', 'input', 'keydown', 'change'])
167
+
168
+ const isFocus = ref(false)
169
+ const attrs = useAttrs()
170
+
171
+ const getAttrs = computed(() => {
172
+ const defaultAttrs = {
173
+ autocapitalize: 'sentences',
174
+ autocomplete: 'chrome-off',
175
+ autocorrect: 'off',
176
+ spellcheck: 'spellcheck',
177
+ }
178
+ return { ...defaultAttrs, ...attrs }
179
+ })
180
+
181
+ const getComponentClass = computed(() => {
182
+ if (props.disabled) {
183
+ return 'status-disabled'
184
+ } else if (props.hasError) {
185
+ return 'status-error'
186
+ } else if (isFocus.value || props.active) {
187
+ return 'status-active'
188
+ } else {
189
+ return 'status-resting'
185
190
  }
191
+ })
192
+
193
+ const onInputFocus = ($event) => {
194
+ isFocus.value = true
195
+ emit('focus', $event)
196
+ }
197
+
198
+ const onInputBlur = ($event) => {
199
+ isFocus.value = false
200
+ emit('blur', $event)
186
201
  }
187
202
  </script>
188
203
 
189
- <style> /* Please, use the file src/assets/scss/components/PsInput.scss */</style>
204
+ <style>
205
+ /* Please, use the file src/assets/scss/components/PsInput.scss */
206
+ </style>
@@ -1,111 +1,132 @@
1
1
  <template>
2
- <div class="psui-el-input-select" :class="[getComponentClass, {'selected':selectedClass}, {'disabled':disabled}]">
3
- <label :for='label' v-if="label" >{{ label }}</label>
2
+ <div
3
+ class="psui-el-input-select"
4
+ :class="[getComponentClass, { selected: selectedClass }, { disabled: disabled }]"
5
+ >
6
+ <label
7
+ :for="label"
8
+ v-if="label"
9
+ >{{ label }}</label>
4
10
  <div class="psui-el-input-select-wrapper">
5
- <select
6
- :name="label"
7
- :id="label"
8
- v-model="childValue"
9
- >
10
- <option value='' disabled>Select</option>
11
- <option v-for="item in getItems" :value="item[keyValue]" :key="item[keyValue]">{{ item[keyLabel] }}</option>
12
- </select>
11
+ <select
12
+ :name="label"
13
+ :id="label"
14
+ v-model="childValue"
15
+ >
16
+ <option
17
+ value=""
18
+ disabled
19
+ >
20
+ Select
21
+ </option>
22
+ <option
23
+ v-for="item in getItems"
24
+ :value="item[keyValue]"
25
+ :key="item[keyValue]"
26
+ >
27
+ {{ item[keyLabel] }}
28
+ </option>
29
+ </select>
13
30
  </div>
14
- <p v-if="optionalLabel && !disabled && layout !== 'mini'" class="psui-el-input-helper">{{ optionalLabel }}</p>
31
+ <p
32
+ v-if="optionalLabel && !disabled && layout !== 'mini'"
33
+ class="psui-el-input-helper"
34
+ >
35
+ {{ optionalLabel }}
36
+ </p>
15
37
  </div>
16
38
  </template>
17
39
 
18
- <script>
40
+ <script setup>
41
+ import { ref, computed } from 'vue'
19
42
 
20
- export default {
21
- name: 'PsInputSelect',
22
- props: {
23
- /**
24
- * It sets the items which will be rendered within the select input.
25
- */
26
- items: {
27
- required: true
28
- },
29
- value: {
30
- default: '',
31
- required: true
32
- },
33
- /**
34
- * It sets the value label of the select input if needed.
35
- */
36
- label: {
37
- default: ''
38
- },
39
- /**
40
- * It sets a o optional label below the select input.
41
- */
42
- optionalLabel:{
43
- default:''
44
- },
45
- /**
46
- * It sets the key label of your items if needed.
47
- */
48
- keyLabel: {
49
- default: 'label'
50
- },
51
- /**
52
- * It sets the key value of yout items if needed.
53
- */
54
- keyValue: {
55
- default: 'value'
56
- },
57
- /**
58
- * It disables the select input. All mouse events are disabled.
59
- */
60
- disabled: {
61
- type: Boolean,
62
- default: false
63
- },
64
- /**
65
- * It sets the layout of the select input. eg: default and mini.
66
- */
67
- layout:{
68
- type: String,
69
- default: 'default',
70
- validator: (value) => ['default','mini'].includes(value)
71
- }
43
+ const props = defineProps({
44
+ /**
45
+ * It sets the items which will be rendered within the select input.
46
+ */
47
+ items: {
48
+ required: true,
72
49
  },
73
- data(){
74
- return {
75
- selectedClass: false,
76
- }
50
+ value: {
51
+ default: '',
52
+ required: true,
77
53
  },
78
- computed: {
79
- getComponentClass(){
80
- return `layout-${this.layout}`
81
- },
82
- childValue: {
83
- get() {
84
- return this.value
85
- },
86
- set(value) {
87
- if(this.isString) return this.$emit('input', value)
88
- const finded = find(this.items, { [this.keyValue]: value })
89
- this.$emit('input', value)
90
- this.$emit('change', finded)
91
- this.selectedClass = true
92
- }
93
- },
94
- isString() {
95
- return this.items.length > 0 && typeof this.items[0] === 'string'
96
- },
97
- getItems() {
98
- if (this.items.length > 0 && typeof this.items[0] === 'string') {
99
- return this.items.map((item) => {
100
- return {
101
- [this.keyLabel]: item,
102
- [this.keyValue]: item,
103
- }
104
- })
105
- } else {
106
- return this.items
107
- }
108
- },
54
+ /**
55
+ * It sets the value label of the select input if needed.
56
+ */
57
+ label: {
58
+ default: '',
59
+ },
60
+ /**
61
+ * It sets a o optional label below the select input.
62
+ */
63
+ optionalLabel: {
64
+ default: '',
65
+ },
66
+ /**
67
+ * It sets the key label of your items if needed.
68
+ */
69
+ keyLabel: {
70
+ default: 'label',
71
+ },
72
+ /**
73
+ * It sets the key value of yout items if needed.
74
+ */
75
+ keyValue: {
76
+ default: 'value',
77
+ },
78
+ /**
79
+ * It disables the select input. All mouse events are disabled.
80
+ */
81
+ disabled: {
82
+ type: Boolean,
83
+ default: false,
84
+ },
85
+ /**
86
+ * It sets the layout of the select input. eg: default and mini.
87
+ */
88
+ layout: {
89
+ type: String,
90
+ default: 'default',
91
+ validator: (value) => ['default', 'mini'].includes(value),
109
92
  },
110
- }
93
+ })
94
+
95
+ const emit = defineEmits('input', 'change')
96
+
97
+ const selectedClass = ref(false)
98
+
99
+ const getComponentClass = computed(() => {
100
+ return `layout-${props.layout}`
101
+ })
102
+
103
+ const childValue = computed({
104
+ get() {
105
+ return props.value
106
+ },
107
+ set(value) {
108
+ if (isString.value) return emit('input', value)
109
+ const finded = find(props.items, { [props.keyValue]: value })
110
+ emit('input', value)
111
+ emit('change', finded)
112
+ selectedClass.value = true
113
+ },
114
+ })
115
+
116
+ const isString = computed(() => {
117
+ return props.items.length > 0 && typeof props.items[0] === 'string'
118
+ })
119
+
120
+ const getItems = computed(() => {
121
+ if (props.items.length > 0 && typeof props.items[0] === 'string') {
122
+ return props.items.map((item) => {
123
+ return {
124
+ [props.keyLabel]: item,
125
+ [props.keyValue]: item,
126
+ }
127
+ })
128
+ } else {
129
+ return props.items
130
+ }
131
+ })
111
132
  </script>