inertia-bootstrap-forms 2.1.14 → 2.1.16
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/dist/{index-lLet6E62.js → index-BA2VhUGJ.js} +1 -1
- package/dist/{index-BCa8dkmY.js → index-CmHdWNDI.js} +288 -282
- package/dist/inertia-bootstrap-forms.es.js +1 -1
- package/dist/inertia-bootstrap-forms.umd.js +5 -5
- package/package.json +1 -1
- package/src/CheckboxToggle.vue +1 -1
- package/src/Select2Input.vue +1 -1
- package/src/SwitchInput.vue +66 -62
package/package.json
CHANGED
package/src/CheckboxToggle.vue
CHANGED
|
@@ -32,7 +32,7 @@ export default defineComponent({
|
|
|
32
32
|
return this.form.getID(this) + (this.value || '');
|
|
33
33
|
},
|
|
34
34
|
selectedValue(){
|
|
35
|
-
return (typeof this.modelValue == 'object') ? Object.values(this.modelValue) : (this.modelValue ? [this.modelValue] : null)
|
|
35
|
+
return (this.modelValue && typeof this.modelValue == 'object') ? Object.values(this.modelValue) : (this.modelValue ? [this.modelValue] : null)
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
setup(props) {
|
package/src/Select2Input.vue
CHANGED
|
@@ -88,7 +88,7 @@ export default defineComponent({
|
|
|
88
88
|
return this.modelValue;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
return (typeof this.modelValue == 'object') ? Object.values(this.modelValue) : (this.modelValue ? [this.modelValue] : null)
|
|
91
|
+
return (this.modelValue && typeof this.modelValue == 'object') ? Object.values(this.modelValue) : (this.modelValue ? [this.modelValue] : null)
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
watch: {
|
package/src/SwitchInput.vue
CHANGED
|
@@ -2,78 +2,82 @@
|
|
|
2
2
|
import {computed, defineComponent, inject} from "vue";
|
|
3
3
|
|
|
4
4
|
export default defineComponent({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
id: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: '',
|
|
13
|
-
required: false,
|
|
14
|
-
},
|
|
15
|
-
value: {
|
|
16
|
-
type: [String, Number],
|
|
17
|
-
default: null,
|
|
18
|
-
required: false,
|
|
19
|
-
},
|
|
20
|
-
type: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: 'checkbox',
|
|
23
|
-
required: false,
|
|
24
|
-
},
|
|
5
|
+
props: {
|
|
6
|
+
name: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
25
9
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
id: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '',
|
|
13
|
+
required: false,
|
|
14
|
+
},
|
|
15
|
+
value: {
|
|
16
|
+
type: [String, Number],
|
|
17
|
+
default: null,
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false,
|
|
30
23
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
type: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'checkbox',
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
computed: {
|
|
31
|
+
inputID() {
|
|
32
|
+
return this.form.getID(this);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setup(props) {
|
|
36
|
+
let form = inject('form', {
|
|
37
|
+
errors: {},
|
|
38
|
+
getID(name) {
|
|
39
|
+
return name;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
let group = inject('group', {});
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
const modelValue = computed({
|
|
45
|
+
get() {
|
|
46
|
+
return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
|
|
47
|
+
},
|
|
48
|
+
set(value) {
|
|
49
|
+
if (group?.value?.name) {
|
|
50
|
+
group.value.setData(props.name, value);
|
|
51
|
+
} else {
|
|
52
|
+
form.value[props.name] = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
return {modelValue, form, group};
|
|
58
|
+
},
|
|
55
59
|
})
|
|
56
60
|
</script>
|
|
57
61
|
<template>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
<div class="form-check form-switch" :class="{'disabled': disabled}">
|
|
63
|
+
<input
|
|
64
|
+
:name="name"
|
|
65
|
+
:id="inputID"
|
|
66
|
+
v-model="modelValue"
|
|
67
|
+
:class="{'is-invalid': form?.errors[name]}"
|
|
68
|
+
:disabled="form?.processing || disabled"
|
|
69
|
+
:type="type"
|
|
70
|
+
:value="value"
|
|
71
|
+
@change="e => $emit('change', e)"
|
|
72
|
+
class="form-check-input">
|
|
73
|
+
<label class="form-check-label" :for="inputID">
|
|
74
|
+
<slot/>
|
|
75
|
+
</label>
|
|
76
|
+
</div>
|
|
73
77
|
</template>
|
|
74
78
|
<style>
|
|
75
79
|
.form-check,
|
|
76
80
|
.form-check label {
|
|
77
|
-
|
|
81
|
+
cursor: pointer;
|
|
78
82
|
}
|
|
79
83
|
</style>
|