@itfin/components 1.0.42 → 1.0.46
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 +1 -1
- package/src/components/alert/Alert.vue +4 -2
- package/src/components/button/Button.vue +1 -0
- package/src/components/checkbox/Radio.vue +21 -5
- package/src/components/checkbox/RadioGroup.vue +51 -0
- package/src/components/modal/Modal.vue +1 -1
- package/src/components/select/Select.vue +6 -6
- package/src/components/text-field/TextField.vue +1 -0
- package/src/components/text-field/Textarea.vue +1 -0
- package/src/directives/appendToBody.js +27 -10
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
|
|
3
3
|
<div class="alert d-flex gap-2" :class="`alert-${type}`" role="alert">
|
|
4
|
-
<itf-icon :name="iconName" size="
|
|
4
|
+
<itf-icon :name="iconName" size="24" />
|
|
5
5
|
|
|
6
|
-
<
|
|
6
|
+
<slot>
|
|
7
|
+
<span v-html="message"></span>
|
|
8
|
+
</slot>
|
|
7
9
|
</div>
|
|
8
10
|
|
|
9
11
|
</template>
|
|
@@ -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');
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
ref="dropdownMenu"
|
|
94
94
|
:key="`vs${uid}__listbox`"
|
|
95
95
|
v-append-to-body
|
|
96
|
-
class="dropdown-menu vs__dropdown-menu"
|
|
96
|
+
class="dropdown-menu vs__dropdown-menu itf-select__dropdown-menu"
|
|
97
97
|
role="listbox"
|
|
98
98
|
tabindex="-1"
|
|
99
99
|
@mousedown.prevent="onMousedown"
|
|
@@ -193,11 +193,11 @@
|
|
|
193
193
|
background: $dark-input-focus-border-color;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
&__dropdown-menu {
|
|
197
197
|
background-color: $body-bg;
|
|
198
198
|
border: 2px solid $input-focus-border;
|
|
199
|
-
padding-left: 0.125rem;
|
|
200
|
-
padding-right: 0.125rem;
|
|
199
|
+
padding-left: 0.125rem !important;
|
|
200
|
+
padding-right: 0.125rem !important;
|
|
201
201
|
left: -2px;
|
|
202
202
|
right: -2px;
|
|
203
203
|
width: auto;
|
|
@@ -668,7 +668,7 @@ export default {
|
|
|
668
668
|
*/
|
|
669
669
|
appendToBody: {
|
|
670
670
|
type: Boolean,
|
|
671
|
-
default:
|
|
671
|
+
default: true,
|
|
672
672
|
},
|
|
673
673
|
/**
|
|
674
674
|
* When `appendToBody` is true, this function is responsible for
|
|
@@ -729,7 +729,7 @@ export default {
|
|
|
729
729
|
_value: [], // Internal value managed by Vue Select if no `value` prop is passed
|
|
730
730
|
}
|
|
731
731
|
},
|
|
732
|
-
inject: { itemLabel: { default: null } },
|
|
732
|
+
inject: { itemLabel: { default: null }, appendContext: { default: null } },
|
|
733
733
|
computed: {
|
|
734
734
|
/**
|
|
735
735
|
* Determine if the component needs to
|
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
inserted(el, bindings, { context }) {
|
|
3
3
|
if (context.appendToBody) {
|
|
4
|
-
|
|
4
|
+
let {
|
|
5
5
|
height,
|
|
6
6
|
top,
|
|
7
7
|
left,
|
|
8
8
|
width,
|
|
9
|
-
} = context.$refs.toggle.getBoundingClientRect()
|
|
9
|
+
} = context.$refs.toggle.getBoundingClientRect();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const { calculatePosition } = context;
|
|
12
|
+
const { appendContext } = context;
|
|
13
|
+
const rootEl = appendContext && appendContext();
|
|
14
|
+
if (rootEl) {
|
|
15
|
+
let {
|
|
16
|
+
top: parentTop,
|
|
17
|
+
left: parentLeft
|
|
18
|
+
} = rootEl.getBoundingClientRect();
|
|
19
|
+
left -= parentLeft + rootEl.scrollLeft;
|
|
20
|
+
top -= parentTop + rootEl.scrollTop;
|
|
21
|
+
} else {
|
|
22
|
+
let scrollX = window.scrollX || window.pageXOffset
|
|
23
|
+
let scrollY = window.scrollY || window.pageYOffset
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
left += scrollX;
|
|
26
|
+
top += scrollY;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (calculatePosition) {
|
|
30
|
+
el.unbindPosition = calculatePosition(el, context, {
|
|
31
|
+
width: width + 'px',
|
|
32
|
+
left: left + 'px',
|
|
33
|
+
top: (top + height) + 'px',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
19
36
|
|
|
20
|
-
document.body.appendChild(el)
|
|
37
|
+
(rootEl || document.body).appendChild(el)
|
|
21
38
|
}
|
|
22
39
|
},
|
|
23
40
|
|