@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
@@ -0,0 +1,124 @@
1
+ <template>
2
+ <div
3
+ class="psui-el-collapse"
4
+ :class="{ 'status-opened': isOpen, 'disabled': disabled }"
5
+ >
6
+ <div
7
+ class="psui-el-collapse-item-header"
8
+ @click="toggle"
9
+ >
10
+ <i
11
+ class="psui-el-collapse-item-icon psui-icon"
12
+ :class="{'psui-rotate-90':isOpen}"
13
+ >chevron_right</i>
14
+ <slot
15
+ name="header"
16
+ :is-open="isOpen"
17
+ >
18
+ <div
19
+ class="psui-el-collapse-item-header-wrapper"
20
+
21
+ v-if="!hasCustomHeader"
22
+ >
23
+ <span
24
+ v-if="title"
25
+ class="psui-el-collapse-item-title"
26
+ :class="[
27
+ { 'disabled': disabled },
28
+ ]"
29
+ >
30
+ {{ title }}
31
+ </span>
32
+ <div class="psui-el-collapse-item-header-action">
33
+ <slot name="header-action" />
34
+ </div>
35
+ </div>
36
+ </slot>
37
+ </div>
38
+ <transition
39
+ name="collapse-fade"
40
+ @enter="start"
41
+ @after-enter="end"
42
+ @before-leave="start"
43
+ @after-leave="end"
44
+ >
45
+ <div
46
+ v-if="isOpen"
47
+ class="psui-el-collapse-item-content"
48
+ >
49
+ <slot name="content" />
50
+ </div>
51
+ </transition>
52
+ </div>
53
+ </template>
54
+
55
+ <script setup>
56
+ import { ref, computed } from 'vue'
57
+
58
+ const localOpened = ref(null)
59
+
60
+ const props = defineProps({
61
+ /**
62
+ * It sets the title of the accordion item.
63
+ */
64
+ title: {
65
+ type: String,
66
+ default: '',
67
+ },
68
+ /**
69
+ * It sets the status of the accordion item when mounted.
70
+ */
71
+ opened: {
72
+ type: [Boolean],
73
+ default: false,
74
+ },
75
+ /**
76
+ * It sets the text key to get the svg icon in Google Fonts. Make sure to get the correct description of your icon on https://fonts.google.com/.
77
+ */
78
+ icon: {
79
+ type: String,
80
+ default: '',
81
+ },
82
+ /**
83
+ * It sets if it has a custom header.
84
+ */
85
+ hasCustomHeader: {
86
+ type: Boolean,
87
+ default: false,
88
+ },
89
+ /**
90
+ * It sets the disabled status.
91
+ */
92
+ disabled: {
93
+ type: Boolean,
94
+ default: false,
95
+ },
96
+ })
97
+
98
+ const isOpen = computed(() => {
99
+ return localOpened.value !== null ? localOpened.value : props.opened
100
+ })
101
+
102
+ const toggle = () => {
103
+ if (localOpened.value === null) {
104
+ localOpened.value = !props.opened
105
+ } else {
106
+ localOpened.value = !localOpened.value
107
+ }
108
+ }
109
+ const start = (el) => {
110
+ el.style.height = el.scrollHeight + 'px'
111
+ el.style.padding = el.srcollPaddingBottom + 'px'
112
+ }
113
+ const end = (el) => {
114
+ el.style.height = ''
115
+ el.style.padding = ''
116
+ }
117
+ </script>
118
+
119
+ <style>
120
+ /* Please, use the file src/assets/scss/components/PsCollapse.scss */
121
+ </style>
122
+
123
+
124
+
@@ -1,97 +1,100 @@
1
1
  <template>
2
- <div class='psui-el-checkbox' :class="[getComponentClass, {'disabled':disabled}]" >
3
- <input
4
- :id="getInputId"
5
- type="checkbox"
2
+ <div
3
+ class="psui-el-checkbox"
4
+ :class="[getComponentClass, { disabled: disabled }]"
5
+ >
6
+ <input
7
+ :id="getInputId"
8
+ type="checkbox"
6
9
  :value="inputValue"
7
10
  v-model="model"
8
- :disabled="disabled"
9
- />
10
- <label
11
- :for="getInputId"
11
+ :disabled="disabled"
12
+ >
13
+ <label
14
+ :for="getInputId"
12
15
  class="psui-el-checkmark"
13
16
  :class="[labelClasses, 'psui-el-checkmark']"
14
17
  >
15
18
  <span>{{ label }}</span>
16
- </label>
19
+ </label>
17
20
  </div>
18
21
  </template>
19
22
 
20
- <script>
21
- //FIGMA CONTROLS & SELECTORS https://www.figma.com/file/Tto8hrNlSfuPcwd1pfqogF/%E2%9A%A1%EF%B8%8F-Design-System?node-id=1768%3A64852
22
- import { randomString } from '../../util/GeneralFunctions'
23
+ <script setup>
24
+ import { computed } from 'vue'
25
+ import { randomString } from '../../util/GeneralFunctions.js'
26
+
27
+ const props = defineProps({
28
+ /**
29
+ * It sets the label of the checkbox input.
30
+ */
31
+ label: {
32
+ type: String,
33
+ default: '',
34
+ },
35
+ /**
36
+ * It sets the label classes.
37
+ */
38
+ labelClasses: {
39
+ type: String,
40
+ default: '',
41
+ },
42
+ /**
43
+ * It sets the value which should be monitored.
44
+ */
45
+ inputValue: {
46
+ type: [String, Boolean],
47
+ default: '',
48
+ },
49
+ value: {
50
+ type: [Array, Boolean],
51
+ default: false,
52
+ },
53
+ /**
54
+ * It disables the checkbox input.
55
+ */
56
+ disabled: {
57
+ type: Boolean,
58
+ default: false,
59
+ },
60
+ /**
61
+ * It set the of the checkbox input. eg: big and small.
62
+ */
63
+ size: {
64
+ type: String,
65
+ default: 'big',
66
+ validator: (value) => ['big', 'small'].includes(value),
67
+ },
68
+ /**
69
+ * It set the layout of the checkbox input. eg: default and mixed.
70
+ */
71
+ layout: {
72
+ type: String,
73
+ default: 'default',
74
+ validator: (value) => ['default', 'mixed'].includes(value),
75
+ },
76
+ })
77
+
78
+ const emit = defineEmits(['input'])
79
+
80
+ const getInputId = computed(() => {
81
+ if (props.inputAttrs?.id) {
82
+ return props.inputAttrs.id
83
+ } else if (props.$attrs?.id) {
84
+ return props.$attrs.id
85
+ } else {
86
+ return randomString(16)
87
+ }
88
+ })
89
+
90
+ const getComponentClass = computed(() => `size-${props.size} layout-${props.layout}`)
23
91
 
24
- export default {
25
- name: 'PsCheckbox',
26
- props: {
27
- /**
28
- * It sets the label of the checkbox input.
29
- */
30
- label: {
31
- type: String,
32
- default: '',
33
- },
34
- /**
35
- * It sets the label classes.
36
- */
37
- labelClasses: {
38
- type: String,
39
- default: ''
40
- },
41
- /**
42
- * It sets the value which should be monitored.
43
- */
44
- inputValue: {
45
- type: [String, Boolean],
46
- },
47
- value:{
48
- type: [Array, Boolean]
49
- },
50
- /**
51
- * It disables the checkbox input.
52
- */
53
- disabled: {
54
- type: Boolean,
55
- default: false,
56
- },
57
- /**
58
- * It set the of the checkbox input. eg: big and small.
59
- */
60
- size: {
61
- type: String,
62
- default: 'big',
63
- validator: (value)=> ['big', 'small'].includes(value)
64
- },
65
- /**
66
- * It set the layout of the checkbox input. eg: default and mixed.
67
- */
68
- layout:{
69
- type: String,
70
- default: 'default',
71
- validator: (value)=> ['default','mixed'].includes(value)
72
- }
92
+ const model = computed({
93
+ get() {
94
+ return props.value
73
95
  },
74
- computed:{
75
- getComponentClass(){
76
- return `size-${this.size} layout-${this.layout}`
77
- },
78
- getInputId() {
79
- if (this?.inputAttrs?.id) {
80
- return this.inputAttrs.id
81
- } else if (this?.$attrs?.id) {
82
- return this.$attrs.id
83
- } else {
84
- return randomString(16)
85
- }
86
- },
87
- model: {
88
- get(){
89
- return this.value
90
- },
91
- set(value){
92
- this.$emit('input', value)
93
- }
94
- }
96
+ set(newValue) {
97
+ emit('input', newValue)
95
98
  },
96
- }
99
+ })
97
100
  </script>
@@ -1,45 +1,45 @@
1
1
  <template>
2
- <div
2
+ <div
3
3
  v-if="withPrevent"
4
- class='psui-el-checkbox'
5
- :class="[getComponentClass, {'disabled':disabled}]"
4
+ class="psui-el-checkbox"
5
+ :class="[getComponentClass, { disabled: disabled }]"
6
6
  v-bind="getComponentAttrs"
7
- @click.prevent="$emit('click', $event)"
7
+ @click.prevent="emit('click', $event)"
8
8
  >
9
- <input
10
- type="checkbox"
11
- :checked="checked"
9
+ <input
10
+ type="checkbox"
11
+ :checked="checked"
12
12
  :disabled="disabled"
13
13
  :name="label"
14
14
  :id="getInputId"
15
15
  v-bind="inputAttrs"
16
- @change="$emit('change', $event)"
17
- />
18
- <label
16
+ @change="emit('change', $event)"
17
+ >
18
+ <label
19
19
  :for="getInputId"
20
20
  class="psui-el-checkmark"
21
21
  >
22
22
  <slot name="content">
23
23
  <span>{{ label }}</span>
24
24
  </slot>
25
- </label>
25
+ </label>
26
26
  </div>
27
- <div
27
+ <div
28
28
  v-else
29
- class='psui-el-checkbox'
30
- :class="[getComponentClass, {'disabled':disabled}]"
29
+ class="psui-el-checkbox"
30
+ :class="[getComponentClass, { disabled: disabled }]"
31
31
  v-bind="getComponentAttrs"
32
32
  >
33
- <input
34
- type="checkbox"
35
- :checked="checked"
33
+ <input
34
+ type="checkbox"
35
+ :checked="checked"
36
36
  :disabled="disabled"
37
37
  :name="label"
38
38
  :id="getInputId"
39
39
  v-bind="inputAttrs"
40
- @change="$emit('change', $event)"
41
- />
42
- <label
40
+ @change="emit('change', $event)"
41
+ >
42
+ <label
43
43
  :for="getInputId"
44
44
  class="psui-el-checkmark"
45
45
  :title="showLabelTitle ? label : ''"
@@ -47,89 +47,89 @@
47
47
  <slot name="content">
48
48
  <span>{{ label }}</span>
49
49
  </slot>
50
- </label>
50
+ </label>
51
51
  </div>
52
52
  </template>
53
53
 
54
- <script>
54
+ <script setup>
55
55
  //FIGMA CONTROLS & SELECTORS https://www.figma.com/file/Tto8hrNlSfuPcwd1pfqogF/%E2%9A%A1%EF%B8%8F-Design-System?node-id=1768%3A64852
56
- import { randomString } from '../../util/GeneralFunctions'
56
+ import { randomString } from '../../util/GeneralFunctions.js'
57
+ import { computed, useAttrs } from 'vue'
57
58
 
58
- export default {
59
- name: 'PsCheckboxSimple',
60
- props: {
61
- /**
62
- * It sets the label of the checkbox input.
63
- */
64
- label: {
65
- type: String,
66
- },
67
- /**
68
- * It disables the checkbox input.
69
- */
70
- withPrevent: {
71
- type: Boolean,
72
- default: false,
73
- },
59
+ const emit = defineEmits(['change', 'click'])
74
60
 
75
- disabled: {
76
- type: Boolean,
77
- default: false,
78
- },
79
- /**
80
- * Sets the input as checked
81
- */
82
- checked: {
83
- type: Boolean,
84
- default: false
85
- },
86
- /**
87
- * Add html attributes to the element input
88
- */
89
- inputAttrs: {
90
- type: Object,
91
- default: () => ({})
92
- },
93
- /**
94
- * It set the of the checkbox input. eg: big and small.
95
- */
96
- size: {
97
- type: String,
98
- default: 'big',
99
- validator: (value)=> ['big', 'small'].includes(value)
100
- },
101
- /**
102
- * It set the layout of the checkbox input. eg: default and mixed.
103
- */
104
- layout:{
105
- type: String,
106
- default: 'default',
107
- validator: (value)=> ['default','mixed'].includes(value)
108
- },
109
- showLabelTitle: {
110
- type: Boolean,
111
- default: true
112
- }
61
+ const props = defineProps({
62
+ label: {
63
+ type: String,
64
+ default: '',
65
+ },
66
+ /**
67
+ * It disables the checkbox input.
68
+ */
69
+ withPrevent: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
73
+
74
+ disabled: {
75
+ type: Boolean,
76
+ default: false,
77
+ },
78
+ /**
79
+ * Sets the input as checked
80
+ */
81
+ checked: {
82
+ type: Boolean,
83
+ default: false,
84
+ },
85
+ /**
86
+ * Add html attributes to the element input
87
+ */
88
+ inputAttrs: {
89
+ type: Object,
90
+ default: () => ({}),
113
91
  },
114
- inheritAttrs: false,
115
- computed:{
116
- getComponentClass(){
117
- return `size-${this.size} layout-${this.layout}`
118
- },
119
- getInputId() {
120
- if (this?.inputAttrs?.id) {
121
- return this.inputAttrs.id
122
- } else if (this?.$attrs?.id) {
123
- return this.$attrs.id
124
- } else {
125
- return randomString(16)
126
- }
127
- },
128
- getComponentAttrs() {
129
- let componentAttrs = { ... this.$attrs }
130
- delete componentAttrs.id
131
- return componentAttrs
132
- }
92
+ /**
93
+ * It set the of the checkbox input. eg: big and small.
94
+ */
95
+ size: {
96
+ type: String,
97
+ default: 'big',
98
+ validator: (value) => ['big', 'small'].includes(value),
133
99
  },
134
- }
100
+ /**
101
+ * It set the layout of the checkbox input. eg: default and mixed.
102
+ */
103
+ layout: {
104
+ type: String,
105
+ default: 'default',
106
+ validator: (value) => ['default', 'mixed'].includes(value),
107
+ },
108
+ showLabelTitle: {
109
+ type: Boolean,
110
+ default: true,
111
+ },
112
+ })
113
+ const attrs = useAttrs()
114
+
115
+ const getComponentClass = computed(() => {
116
+ return `size-${props.size} layout-${props.layout}`
117
+ })
118
+
119
+
120
+ const getInputId = computed(() => {
121
+ if (props?.inputAttrs?.id) {
122
+ return props.inputAttrs.id
123
+ } else if (attrs?.id) {
124
+ return attrs.id
125
+ } else {
126
+ return randomString(16)
127
+ }
128
+ })
129
+
130
+ const getComponentAttrs = computed(() => {
131
+ let componentAttrs = { ...attrs }
132
+ delete componentAttrs.id
133
+ return componentAttrs
134
+ })
135
135
  </script>