@itfin/components 1.0.42 → 1.0.43
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,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
3
|
<div class="itf-radio form-check" :class="{ 'itf-radio__large': large, 'itf-radio__medium': medium }">
|
|
4
|
-
<input class="form-check-input" :id="id" type="radio" :name="
|
|
4
|
+
<input class="form-check-input" :id="id" type="radio" :name="radioName" v-model="isChecked" :value="true" :disabled="disabled" />
|
|
5
5
|
<label :for="id" slot="label" class="form-check-label">
|
|
6
6
|
{{label}}
|
|
7
7
|
<slot name="icon"></slot>
|
|
@@ -49,17 +49,17 @@ import { Vue, Component, Prop, Model, Inject } from 'vue-property-decorator';
|
|
|
49
49
|
let globalRadioId = 0;
|
|
50
50
|
|
|
51
51
|
export default @Component({
|
|
52
|
-
name: '
|
|
52
|
+
name: 'itfRadio',
|
|
53
53
|
components: {
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
|
-
class
|
|
57
|
-
@Inject({ default: null })
|
|
56
|
+
class itfRadio extends Vue {
|
|
57
|
+
@Inject({ default: null }) radioGroup;
|
|
58
58
|
|
|
59
59
|
@Model('input') checked;
|
|
60
60
|
@Prop(String) label;
|
|
61
61
|
@Prop() value;
|
|
62
|
-
@Prop({ type: String
|
|
62
|
+
@Prop({ type: String }) name;
|
|
63
63
|
|
|
64
64
|
@Prop(Boolean) disabled;
|
|
65
65
|
@Prop(Boolean) medium;
|
|
@@ -72,11 +72,27 @@ class itfCheckbox extends Vue {
|
|
|
72
72
|
this.id = `radio${globalRadioId}`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
get radioName() {
|
|
76
|
+
if (this.radioGroup) {
|
|
77
|
+
return this.radioGroup.getGroupName();
|
|
78
|
+
}
|
|
79
|
+
if (!this.name) {
|
|
80
|
+
throw new Error('Name for radio should be not empty');
|
|
81
|
+
}
|
|
82
|
+
return this.name;
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
set isChecked(val) {
|
|
86
|
+
if (this.radioGroup) {
|
|
87
|
+
this.radioGroup.onToggleOption(this.value, val);
|
|
88
|
+
}
|
|
76
89
|
this.$emit('input', this.value);
|
|
77
90
|
}
|
|
78
91
|
|
|
79
92
|
get isChecked() {
|
|
93
|
+
if (this.radioGroup) {
|
|
94
|
+
return this.radioGroup.isChecked(this.value);
|
|
95
|
+
}
|
|
80
96
|
if (this.itemKey) {
|
|
81
97
|
if (!this.checked || !this.value) {
|
|
82
98
|
return false;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<fieldset>
|
|
4
|
+
<slot />
|
|
5
|
+
</fieldset>
|
|
6
|
+
|
|
7
|
+
</template>
|
|
8
|
+
<style>
|
|
9
|
+
|
|
10
|
+
</style>
|
|
11
|
+
<script>
|
|
12
|
+
import { Vue, Component, Prop, Model, Provide } from 'vue-property-decorator';
|
|
13
|
+
|
|
14
|
+
let globalRadioGroupId = 0;
|
|
15
|
+
|
|
16
|
+
export default @Component({
|
|
17
|
+
name: 'itfRadioGroup'
|
|
18
|
+
})
|
|
19
|
+
class itfRadioGroup extends Vue {
|
|
20
|
+
@Provide() radioGroup = this;
|
|
21
|
+
|
|
22
|
+
@Model('input', { default: null }) value;
|
|
23
|
+
|
|
24
|
+
@Prop(Boolean) disabled;
|
|
25
|
+
|
|
26
|
+
@Prop(String) itemKey;
|
|
27
|
+
|
|
28
|
+
@Prop(Number) max;
|
|
29
|
+
|
|
30
|
+
created() {
|
|
31
|
+
globalRadioGroupId += 1;
|
|
32
|
+
this.id = `radio-group-${globalRadioGroupId}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getGroupName() {
|
|
36
|
+
return this.id;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onToggleOption(value, isChecked) {
|
|
40
|
+
this.$emit('input', value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
isChecked(value) {
|
|
44
|
+
return this.value === value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isDisabled() {
|
|
48
|
+
return this.disabled;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
@@ -124,7 +124,7 @@ class itfModal extends Vue {
|
|
|
124
124
|
}
|
|
125
125
|
if (this.appendToBody && this.$el instanceof Node && this.$el.parentNode) {
|
|
126
126
|
this.$el.parentNode.removeChild(this.$el);
|
|
127
|
-
const elContext = (
|
|
127
|
+
const elContext = document.getElementById('app') || document.body; // @todo getElementById remove when cleanup vuetify
|
|
128
128
|
elContext.appendChild(this.$el);
|
|
129
129
|
}
|
|
130
130
|
const { default: Modal } = await import('bootstrap/js/src/modal.js');
|