inertia-bootstrap-forms 2.1.13 → 2.1.14

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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inertia-bootstrap-forms",
3
- "version": "2.1.13",
3
+ "version": "2.1.14",
4
4
  "description": "Create bootstrap forms with inertia and twitter bootstrap",
5
5
  "main": "dist/inertia-bootstrap-forms.cjs.js",
6
6
  "module": "dist/inertia-bootstrap-forms.es.js",
@@ -0,0 +1,79 @@
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
+ type: {
21
+ type: String,
22
+ default: 'checkbox',
23
+ required: false,
24
+ },
25
+ },
26
+ computed: {
27
+ inputID() {
28
+ return this.form.getID(this);
29
+ }
30
+ },
31
+ setup(props) {
32
+ let form = inject('form', {
33
+ errors: {},
34
+ getID(name) {
35
+ return name;
36
+ }
37
+ });
38
+ let group = inject('group', {});
39
+
40
+ const modelValue = computed({
41
+ get() {
42
+ return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
43
+ },
44
+ set(value) {
45
+ if (group?.value?.name) {
46
+ group.value.setData(props.name, value);
47
+ } else {
48
+ form.value[props.name] = value;
49
+ }
50
+ }
51
+ });
52
+
53
+ return {modelValue, form, group};
54
+ },
55
+ })
56
+ </script>
57
+ <template>
58
+ <div class="form-check form-switch">
59
+ <input
60
+ :name="name"
61
+ :id="inputID"
62
+ v-model="modelValue"
63
+ :class="{'is-invalid': form?.errors[name]}"
64
+ :disabled="form?.processing"
65
+ :type="type"
66
+ :value="value"
67
+ @change="e => $emit('change', e)"
68
+ class="form-check-input">
69
+ <label class="form-check-label" :for="inputID">
70
+ <slot/>
71
+ </label>
72
+ </div>
73
+ </template>
74
+ <style>
75
+ .form-check,
76
+ .form-check label {
77
+ cursor: pointer;
78
+ }
79
+ </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,