@avakhula/ui 0.0.341 → 0.0.342

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": "@avakhula/ui",
3
- "version": "0.0.341",
3
+ "version": "0.0.342",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.umd.cjs",
6
6
  "source": "src/index.js",
package/src/App.vue CHANGED
@@ -5,10 +5,45 @@
5
5
  </template>
6
6
  </ib-select>
7
7
 
8
+
9
+ <ib-checkbox-group
10
+ label-text="label"
11
+ info-text="info"
12
+ required
13
+ >
14
+ <ib-radio
15
+ :value="'1'"
16
+ name="connection_id"
17
+ dusk="active-radio-button"
18
+ label="text 1"
19
+ id="1"
20
+ v-model="checked"
21
+ />
22
+ <ib-radio
23
+ :value="'2'"
24
+ name="connection_id"
25
+ dusk="active-radio-button"
26
+ label="text 2"
27
+ id="2"
28
+ v-model="checked"
29
+ />
30
+ <ib-radio
31
+ :value="'3'"
32
+ name="connection_id"
33
+ dusk="active-radio-button"
34
+ label="text 3"
35
+ id="3"
36
+ v-model="checked"
37
+ />
38
+ </ib-checkbox-group>
39
+
8
40
  </template>
9
41
 
10
42
  <script>
11
43
  import IbSelect from "./components/TreeSelect/Select.vue";
44
+ import label from "@/components/Form/Label/Label.vue";
45
+ import {IbCheckboxGroup} from "./index.js";
46
+ import {IbRadio} from "./index.js";
12
47
  const testData1 = [
13
48
  {
14
49
  id: "1",
@@ -125,11 +160,17 @@ const testData1 = [
125
160
  },
126
161
  ];
127
162
  export default {
163
+ computed: {
164
+ label() {
165
+ return label
166
+ }
167
+ },
128
168
  data() {
129
169
  return {
130
170
  opt: testData1,
171
+ checked: '1'
131
172
  }
132
173
  },
133
- components: {IbSelect}
174
+ components: {IbSelect, IbCheckboxGroup, IbRadio}
134
175
  }
135
176
  </script>
@@ -3,19 +3,17 @@
3
3
  role="radio"
4
4
  :class="classes"
5
5
  :for="id"
6
- :aria-checked="checked"
7
- @click.prevent="onClick"
6
+ :aria-checked="isChecked"
8
7
  >
9
8
  <input
10
9
  type="radio"
11
10
  :name="name"
12
11
  :id="id"
13
12
  :value="value"
14
- :checked="checked"
13
+ :checked="isChecked"
15
14
  :disabled="disabled"
16
15
  ref="radio"
17
- @input.stop
18
- @change="onChange"
16
+ @change="checkHandler"
19
17
  />
20
18
  <span class="ib-radio-body" :class="{ 'without-text': !label?.length }">
21
19
  <span class="ib-radio-input"></span>
@@ -29,11 +27,8 @@ import generateUID from "../../../helpers/generateUID";
29
27
 
30
28
  export default {
31
29
  name: "IbRadio",
32
- model: {
33
- prop: "isChecked",
34
- event: "input",
35
- },
36
30
  props: {
31
+ modelValue: '',
37
32
  label: String,
38
33
  error: {
39
34
  type: Boolean,
@@ -52,50 +47,39 @@ export default {
52
47
  type: String,
53
48
  required: true,
54
49
  },
55
- isChecked: {
56
- type: Boolean,
57
- default: false,
58
- },
59
50
  disabled: {
60
51
  type: Boolean,
61
52
  default: false,
62
53
  },
63
54
  },
64
- watch: {
65
- isChecked(value) {
66
- this.checked = value;
67
- },
55
+ emits: ['update:modelValue'],
56
+ data() {
57
+ return {
58
+ checked: false,
59
+ uid: generateUID(),
60
+ };
68
61
  },
69
62
  mounted() {
63
+ this.checked = this.isChecked;
70
64
  this.$globalEvents.$on(`radio:update:${this.name}`, (uid) => {
71
65
  if (this.uid !== uid) {
72
66
  this.checked = false;
73
67
  }
74
68
  });
75
69
  },
76
- data() {
77
- return {
78
- checked: this.isChecked,
79
- uid: generateUID(),
80
- };
70
+ watch: {
71
+ isChecked(val) {
72
+ this.checked = val;
73
+ },
81
74
  },
82
75
  methods: {
83
- onClick() {
76
+ checkHandler($event) {
77
+ this.$emit('update:modelValue', $event.target.value)
84
78
  if (!this.disabled) {
85
79
  this.checked = !this.checked;
86
80
  this.$globalEvents.$emit(`radio:update:${this.name}`, this.uid);
87
- this.$emit("input", this.checked);
88
- this.$emit("change", this.checked);
89
81
  }
90
- },
91
- onChange() {
92
- if (!this.disabled) {
93
- this.checked = !this.checked;
94
- this.$globalEvents.$emit(`radio:update:${this.name}`, this.uid);
95
- this.$emit("change", this.checked);
96
- this.$emit("input", this.checked);
97
- }
98
- },
82
+ }
99
83
  },
100
84
  computed: {
101
85
  classes() {
@@ -106,6 +90,9 @@ export default {
106
90
  "radio-disabled": this.disabled,
107
91
  };
108
92
  },
93
+ isChecked() {
94
+ return this.modelValue === this.value
95
+ }
109
96
  },
110
97
  };
111
98
  </script>