inertia-bootstrap-forms 2.1.13 → 2.1.15
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-BUI1upO5.js → index-BCa8dkmY.js} +740 -670
- package/dist/{index-D8G-rRkA.js → index-lLet6E62.js} +1 -1
- package/dist/inertia-bootstrap-forms.es.js +13 -12
- package/dist/inertia-bootstrap-forms.umd.js +6 -6
- package/dist/style.css +1 -1
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/SwitchInput.vue +83 -0
- package/src/index.js +2 -0
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import CaptchaInput from './src/CaptchaInput.vue';
|
|
|
6
6
|
import CheckboxButtonInput from './src/CheckboxButtonInput.vue';
|
|
7
7
|
import CheckboxInput from './src/CheckboxInput.vue';
|
|
8
8
|
import CheckboxToggle from './src/CheckboxToggle.vue';
|
|
9
|
+
import SwitchInput from './src/SwitchInput.vue';
|
|
9
10
|
import EditorInput from './src/EditorInput.vue';
|
|
10
11
|
import EmailInput from './src/EmailInput.vue';
|
|
11
12
|
import FileInput from './src/FileInput.vue';
|
|
@@ -37,6 +38,7 @@ export {
|
|
|
37
38
|
CheckboxButtonInput,
|
|
38
39
|
CheckboxInput,
|
|
39
40
|
CheckboxToggle,
|
|
41
|
+
SwitchInput,
|
|
40
42
|
countryCodes,
|
|
41
43
|
EditorInput,
|
|
42
44
|
EmailInput,
|
|
@@ -125,6 +127,7 @@ export const CheckboxButtonInput: DefineComponent<{
|
|
|
125
127
|
}, {}, any>;
|
|
126
128
|
export const CheckboxInput: DefineComponent<{}, {}, any>;
|
|
127
129
|
export const CheckboxToggle: DefineComponent<{}, {}, any>;
|
|
130
|
+
export const SwitchInput: DefineComponent<{}, {}, any>;
|
|
128
131
|
export const countryCodes: any;
|
|
129
132
|
export const EditorInput: DefineComponent<{
|
|
130
133
|
name: {
|
|
@@ -442,6 +445,7 @@ declare const Vue3FormComponents: {
|
|
|
442
445
|
CheckboxButtonInput: typeof CheckboxButtonInput;
|
|
443
446
|
CheckboxInput: typeof CheckboxInput;
|
|
444
447
|
CheckboxToggle: typeof CheckboxToggle;
|
|
448
|
+
SwitchInput: typeof SwitchInput;
|
|
445
449
|
DropzoneInput: typeof DropzoneInput;
|
|
446
450
|
countryCodes: typeof countryCodes;
|
|
447
451
|
EditorInput: typeof EditorInput;
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {computed, defineComponent, inject} from "vue";
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
name: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
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
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
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', {});
|
|
43
|
+
|
|
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
|
+
});
|
|
56
|
+
|
|
57
|
+
return {modelValue, form, group};
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
</script>
|
|
61
|
+
<template>
|
|
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>
|
|
77
|
+
</template>
|
|
78
|
+
<style>
|
|
79
|
+
.form-check,
|
|
80
|
+
.form-check label {
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import CaptchaInput from "./CaptchaInput.vue";
|
|
|
3
3
|
import CheckboxButtonInput from "./CheckboxButtonInput.vue";
|
|
4
4
|
import CheckboxInput from "./CheckboxInput.vue";
|
|
5
5
|
import CheckboxToggle from "./CheckboxToggle.vue";
|
|
6
|
+
import SwitchInput from "./SwitchInput.vue";
|
|
6
7
|
import PersianDatePickerInput from "./PersianDatePickerInput.vue";
|
|
7
8
|
import EditorInput from "./EditorInput.vue";
|
|
8
9
|
import FileInput from "./FileInput.vue";
|
|
@@ -33,6 +34,7 @@ export {
|
|
|
33
34
|
CheckboxButtonInput,
|
|
34
35
|
CheckboxInput,
|
|
35
36
|
CheckboxToggle,
|
|
37
|
+
SwitchInput,
|
|
36
38
|
FileInput,
|
|
37
39
|
EmailInput,
|
|
38
40
|
PersianDatePickerInput,
|