@policystudio/policy-studio-ui-vue 1.0.63 → 1.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "Policy Studio UI",
5
5
  "main": "src/index.js",
6
6
  "author": "Policy Studio Team",
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <div
3
+ class='psui-el-radio'
4
+ :class="[getComponentClass, {'disabled':disabled}]"
5
+ v-bind="getComponentAttrs"
6
+ >
7
+ <input
8
+ type="radio"
9
+ :checked="checked"
10
+ :disabled="disabled"
11
+ :name="label"
12
+ :id="getInputId"
13
+ v-bind="inputAttrs"
14
+ @change="$emit('change')"
15
+ />
16
+ <label
17
+ :for="getInputId"
18
+ class="psui-el-checkmark"
19
+ >
20
+ <slot name="content">
21
+ <span>{{ label }}</span>
22
+ </slot>
23
+ </label>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import { randomString } from '../../util/GeneralFunctions'
29
+
30
+ export default {
31
+ name: 'PsRadioButtonSimple',
32
+ props: {
33
+ /**
34
+ * It sets the label of the checkbox input.
35
+ */
36
+ label: {
37
+ type: String,
38
+ },
39
+ /**
40
+ * It disables the checkbox input.
41
+ */
42
+ disabled: {
43
+ type: Boolean,
44
+ default: false,
45
+ },
46
+ /**
47
+ * Sets the input as checked
48
+ */
49
+ checked: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ /**
54
+ * Add html attributes to the element input
55
+ */
56
+ inputAttrs: {
57
+ type: Object,
58
+ default: () => ({})
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
+ },
72
+ inheritAttrs: false,
73
+ computed:{
74
+ getComponentClass(){
75
+ return `size-${this.size}`
76
+ },
77
+ getInputId() {
78
+ if (this?.inputAttrs?.id) {
79
+ return this.inputAttrs.id
80
+ } else if (this?.$attrs?.id) {
81
+ return this.$attrs.id
82
+ } else {
83
+ return randomString(16)
84
+ }
85
+ },
86
+ getComponentAttrs() {
87
+ let componentAttrs = { ... this.$attrs }
88
+ delete componentAttrs.id
89
+ return componentAttrs
90
+ }
91
+ },
92
+ }
93
+ </script>
package/src/index.js CHANGED
@@ -30,6 +30,7 @@ import PsScrollBar from './components/playground/PsScrollBar.vue'
30
30
  import PsMiniTag from './components/badges-and-tags/PsMiniTag.vue'
31
31
  import PsCheckboxSimple from './components/controls/PsCheckboxSimple.vue'
32
32
  import PsBadgeWithIcon from './components/badges-and-tags/PsBadgeWithIcon.vue'
33
+ import PsRadioButtonSimple from './components/controls/PsRadioButtonSimple.vue'
33
34
 
34
35
 
35
36
 
@@ -67,6 +68,7 @@ export default {
67
68
  Vue.component('PsMiniTag', PsMiniTag)
68
69
  Vue.component('PsCheckboxSimple', PsCheckboxSimple)
69
70
  Vue.component('PsBadgeWithIcon', PsBadgeWithIcon)
71
+ Vue.component('PsRadioButtonSimple', PsRadioButtonSimple)
70
72
 
71
73
  Vue.directive('click-outside', {
72
74
  bind: function (el, binding, vnode) {
@@ -118,6 +120,7 @@ export {
118
120
  PsScrollBar,
119
121
  PsMiniTag,
120
122
  PsCheckboxSimple,
121
- PsBadgeWithIcon
123
+ PsBadgeWithIcon,
124
+ PsRadioButtonSimple
122
125
  }
123
126
 
@@ -0,0 +1,43 @@
1
+ import PsRadioButtonSimple from '../components/controls/PsRadioButtonSimple.vue'
2
+
3
+ export default {
4
+ title: 'Components/Inputs V2/RadioButton',
5
+ component: PsRadioButtonSimple,
6
+ }
7
+
8
+ const defaultTemplate = (args, {argTypes}) => ({
9
+ props: Object.keys(argTypes),
10
+ components: { PsRadioButtonSimple },
11
+ data: () => ({
12
+ checkBox1 : true
13
+ }),
14
+ template: `
15
+ <div style='display:flex; gap: 20px;'>
16
+ <div style='display:flex; flex-direction:column; gap:5px;'>
17
+ <p>Resting</p>
18
+ <div style='display: flex; flex-direction:column; gap: 10px;'>
19
+ <PsRadioButtonSimple :checked="radioButton1" @click="radioButton1 = true" label='Label 1' />
20
+ <PsRadioButtonSimple :checked="radioButton2" @click="radioButton2 = true" label='Label 2' size='small' />
21
+ </div>
22
+ </div>
23
+ <div style='display:flex; flex-direction:column; gap:5px;'>
24
+ <p>Active</p>
25
+ <div style='display: flex; flex-direction:column; gap: 10px;'>
26
+ <PsRadioButtonSimple v-bind="$props" label='Label 3' checked />
27
+ <PsRadioButtonSimple v-bind="$props" label='Label 4' checked size='small'/>
28
+ </div>
29
+ </div>
30
+ <div style='display:flex; flex-direction:column; gap:5px;'>
31
+ <p>Disabled</p>
32
+ <div style='display: flex; flex-direction:column; gap: 10px;'>
33
+ <PsRadioButtonSimple v-bind="$props" label='Input via inputAttrs' :inputAttrs="{ id: 'my-input-id' }" disabled/>
34
+ <PsRadioButtonSimple v-bind="$props" label='Input via component id' size='small' id="my-component-id" data-test="test" disabled/>
35
+ <PsRadioButtonSimple v-bind="$props" label='Input fallback' size='small' disabled/>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ `
40
+ })
41
+
42
+ export const Default = defaultTemplate.bind({})
43
+