inertia-bootstrap-forms 2.1.8 → 2.1.9
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-NrWiSABD.js → index-DoTxaxaI.js} +746 -655
- package/dist/{index-CsHj65jU.js → index-ibVkvWa2.js} +1 -1
- package/dist/inertia-bootstrap-forms.es.js +14 -13
- package/dist/inertia-bootstrap-forms.umd.js +6 -6
- package/dist/style.css +1 -1
- package/index.d.ts +18 -0
- package/package.json +1 -1
- package/src/AmountInput.vue +1 -1
- package/src/FileInput.vue +5 -1
- package/src/FormContainer.vue +39 -3
- package/src/FormLabel.vue +21 -10
- package/src/MobileInput.vue +1 -1
- package/src/OTPInput.vue +84 -0
- package/src/TelInput.vue +1 -1
- package/src/index.js +2 -0
package/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import SubmitButton from './src/SubmitButton.vue';
|
|
|
26
26
|
import TelInput from './src/TelInput.vue';
|
|
27
27
|
import TextAreaInput from './src/TextAreaInput.vue';
|
|
28
28
|
import TextInput from './src/TextInput.vue';
|
|
29
|
+
import OTPInput from './src/OTPInput.vue';
|
|
29
30
|
import DropzoneInput from './src/DropzoneInput.vue';
|
|
30
31
|
import { countryCodes } from './src/countryCodes';
|
|
31
32
|
|
|
@@ -58,6 +59,7 @@ export {
|
|
|
58
59
|
TelInput,
|
|
59
60
|
TextAreaInput,
|
|
60
61
|
TextInput,
|
|
62
|
+
OTPInput,
|
|
61
63
|
Quantity,
|
|
62
64
|
File,
|
|
63
65
|
};
|
|
@@ -91,6 +93,7 @@ const Vue3FormComponents = {
|
|
|
91
93
|
TelInput,
|
|
92
94
|
TextAreaInput,
|
|
93
95
|
TextInput,
|
|
96
|
+
OTPInput,
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
export default Vue3FormComponents;
|
|
@@ -379,6 +382,20 @@ export const SubmitButton: DefineComponent<{
|
|
|
379
382
|
export const TelInput: DefineComponent<{}, {}, any>;
|
|
380
383
|
export const TextAreaInput: DefineComponent<{}, {}, any>;
|
|
381
384
|
export const TextInput: DefineComponent<{}, {}, any>;
|
|
385
|
+
export const OTPInput: DefineComponent<{
|
|
386
|
+
name: {
|
|
387
|
+
type: String,
|
|
388
|
+
required: true,
|
|
389
|
+
},
|
|
390
|
+
maxLength: {
|
|
391
|
+
type: Number,
|
|
392
|
+
default: 5,
|
|
393
|
+
},
|
|
394
|
+
placeholder: {
|
|
395
|
+
type: String,
|
|
396
|
+
default: '',
|
|
397
|
+
},
|
|
398
|
+
}, {}, any>;
|
|
382
399
|
export const RangeSliderInput: DefineComponent<{
|
|
383
400
|
name: {
|
|
384
401
|
type: String,
|
|
@@ -446,6 +463,7 @@ declare const Vue3FormComponents: {
|
|
|
446
463
|
TelInput: typeof TelInput;
|
|
447
464
|
TextAreaInput: typeof TextAreaInput;
|
|
448
465
|
TextInput: typeof TextInput;
|
|
466
|
+
OTPInput: typeof OTPInput;
|
|
449
467
|
Quantity: typeof QuantityInput;
|
|
450
468
|
RangeSliderInput: typeof RangeSliderInput;
|
|
451
469
|
};
|
package/package.json
CHANGED
package/src/AmountInput.vue
CHANGED
|
@@ -79,7 +79,7 @@ export default defineComponent({
|
|
|
79
79
|
:readonly="readonly"
|
|
80
80
|
:placeholder="placeholder"
|
|
81
81
|
type="tel"
|
|
82
|
-
class="form-control fanum
|
|
82
|
+
class="form-control fanum">
|
|
83
83
|
<InputGroupText class="fanum">{{ unit }}</InputGroupText>
|
|
84
84
|
<slot name="suffix"/>
|
|
85
85
|
</InputGroup>
|
package/src/FileInput.vue
CHANGED
|
@@ -31,7 +31,10 @@ export default defineComponent({
|
|
|
31
31
|
return {form};
|
|
32
32
|
},
|
|
33
33
|
computed: {
|
|
34
|
-
|
|
34
|
+
inputID() {
|
|
35
|
+
return this.form?.getID(this);
|
|
36
|
+
},
|
|
37
|
+
allFiles() {
|
|
35
38
|
return this.files
|
|
36
39
|
},
|
|
37
40
|
},
|
|
@@ -110,6 +113,7 @@ export default defineComponent({
|
|
|
110
113
|
<input
|
|
111
114
|
ref="input"
|
|
112
115
|
:name="name"
|
|
116
|
+
:id="inputID"
|
|
113
117
|
:class="{'is-invalid': form?.errors[name] !== undefined}"
|
|
114
118
|
:disabled="form?.processing"
|
|
115
119
|
type="file"
|
package/src/FormContainer.vue
CHANGED
|
@@ -55,11 +55,38 @@ export default defineComponent({
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
form.getID = function (el) {
|
|
58
|
+
|
|
59
|
+
const output = [];
|
|
60
|
+
|
|
61
|
+
if(formEl.value?.id) {
|
|
62
|
+
output.push(formEl.value?.id)
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
if (typeof el === String) {
|
|
59
|
-
|
|
66
|
+
output.push(el);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (el.group && (el.group.name || el.group.groupID)) {
|
|
70
|
+
console.log(el.group);
|
|
71
|
+
|
|
72
|
+
if(el.group.name){
|
|
73
|
+
output.push(el.group.name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if(el.group.groupID){
|
|
77
|
+
output.push(el.group.groupID);
|
|
78
|
+
}
|
|
60
79
|
}
|
|
61
80
|
|
|
62
|
-
|
|
81
|
+
if (el.name) {
|
|
82
|
+
output.push(el.name);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (el.value) {
|
|
86
|
+
output.push(el.value);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return output.join('-');
|
|
63
90
|
};
|
|
64
91
|
|
|
65
92
|
return {form, formData, formEl};
|
|
@@ -105,6 +132,15 @@ export default defineComponent({
|
|
|
105
132
|
this.focusNextField(el);
|
|
106
133
|
}
|
|
107
134
|
},
|
|
135
|
+
handleAutoSubmitLength(event) {
|
|
136
|
+
const el = event.target;
|
|
137
|
+
if (!['INPUT', 'TEXTAREA'].includes(el.tagName)) return;
|
|
138
|
+
|
|
139
|
+
const autoSubmitLength = parseInt(el.dataset.autoSubmitLength, 10);
|
|
140
|
+
if (!isNaN(autoSubmitLength) && el.value.length >= autoSubmitLength) {
|
|
141
|
+
this.submit();
|
|
142
|
+
}
|
|
143
|
+
},
|
|
108
144
|
focusNextField(current) {
|
|
109
145
|
const focusable = Array.from(
|
|
110
146
|
this.formEl.querySelectorAll('input, select, textarea')
|
|
@@ -197,7 +233,7 @@ export default defineComponent({
|
|
|
197
233
|
:action="url"
|
|
198
234
|
:method="method"
|
|
199
235
|
:data-autotab="autoTab ? 'true' : ''"
|
|
200
|
-
@input="handleAutoTab"
|
|
236
|
+
@input="(event) => { handleAutoTab(event); handleAutoSubmitLength(event) }"
|
|
201
237
|
@submit.prevent="submit"
|
|
202
238
|
@reset="$emit('reset')"
|
|
203
239
|
:class="{'form-processing': form.processing}"
|
package/src/FormLabel.vue
CHANGED
|
@@ -2,22 +2,33 @@
|
|
|
2
2
|
import {defineComponent} from "vue";
|
|
3
3
|
|
|
4
4
|
export default defineComponent({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
props: {
|
|
6
|
+
default: false,
|
|
7
|
+
required: false,
|
|
8
|
+
},
|
|
9
|
+
emits: ['update:modelValue'],
|
|
10
|
+
mounted() {
|
|
11
|
+
const sibling = this.$el.nextElementSibling;
|
|
12
|
+
if (sibling) {
|
|
13
|
+
this.forId = sibling.id || sibling.querySelector('[id]')?.id || null;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
forId: null,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
10
21
|
})
|
|
11
22
|
</script>
|
|
12
23
|
|
|
13
24
|
<template>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
<label class="mb-2 d-block" :for="forId">
|
|
26
|
+
<slot/>
|
|
27
|
+
<span class="text-danger" v-if="required">*</span>
|
|
28
|
+
</label>
|
|
18
29
|
</template>
|
|
19
30
|
<style scoped>
|
|
20
31
|
label {
|
|
21
|
-
|
|
32
|
+
cursor: pointer;
|
|
22
33
|
}
|
|
23
34
|
</style>
|
package/src/MobileInput.vue
CHANGED
package/src/OTPInput.vue
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {computed, inject, defineComponent, defineEmits, watch} from "vue";
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: {
|
|
6
|
+
name: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
maxLength: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: 5,
|
|
13
|
+
},
|
|
14
|
+
placeholder: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: '',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
computed: {
|
|
20
|
+
inputID() {
|
|
21
|
+
return this.form.getID(this);
|
|
22
|
+
},
|
|
23
|
+
placeholderLines() {
|
|
24
|
+
if (this.placeholder) {
|
|
25
|
+
return this.placeholder;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return '_'.repeat(this.maxLength);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
},
|
|
32
|
+
setup(props) {
|
|
33
|
+
const emits = defineEmits(['completed'])
|
|
34
|
+
|
|
35
|
+
let form = inject('form', {
|
|
36
|
+
errors: {},
|
|
37
|
+
getID(name) {
|
|
38
|
+
return name;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
let group = inject('group', {});
|
|
42
|
+
|
|
43
|
+
const modelValue = computed({
|
|
44
|
+
get() {
|
|
45
|
+
return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
|
|
46
|
+
},
|
|
47
|
+
set(value) {
|
|
48
|
+
if (group?.value?.name) {
|
|
49
|
+
group.value.setData(props.name, value);
|
|
50
|
+
} else {
|
|
51
|
+
form.value[props.name] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
watch(modelValue, (value) => {
|
|
57
|
+
if (value && value.length >= props.maxLength) {
|
|
58
|
+
emits('completed', value)
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return {modelValue, form, group};
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
</script>
|
|
66
|
+
<template>
|
|
67
|
+
<input
|
|
68
|
+
:name="name"
|
|
69
|
+
:id="inputID"
|
|
70
|
+
v-model="modelValue"
|
|
71
|
+
:class="{'is-invalid': form?.errors[name] !== undefined}"
|
|
72
|
+
:disabled="form?.processing"
|
|
73
|
+
:placeholder="placeholderLines"
|
|
74
|
+
:maxlength="maxLength"
|
|
75
|
+
:data-auto-submit-length="maxLength"
|
|
76
|
+
type="tel"
|
|
77
|
+
class="form-control form-control-otp fanum">
|
|
78
|
+
</template>
|
|
79
|
+
<style>
|
|
80
|
+
.form-control-otp {
|
|
81
|
+
letter-spacing: 1rem;
|
|
82
|
+
text-align: center;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
package/src/TelInput.vue
CHANGED
|
@@ -65,7 +65,7 @@ export default defineComponent({
|
|
|
65
65
|
placeholder: placeHolder
|
|
66
66
|
}"
|
|
67
67
|
v-model="defaultValue"
|
|
68
|
-
:styleClasses="'form-control' + ((valid === false || form?.errors[name] !== undefined) ? ' is-invalid' : '')"/>
|
|
68
|
+
:styleClasses="'form-control form-control-tel fanum ' + ((valid === false || form?.errors[name] !== undefined) ? ' is-invalid' : '')"/>
|
|
69
69
|
</div>
|
|
70
70
|
</template>
|
|
71
71
|
<style>
|
package/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import SubmitButton from "./SubmitButton.vue";
|
|
|
21
21
|
import TelInput from "./TelInput.vue";
|
|
22
22
|
import TextAreaInput from "./TextAreaInput.vue";
|
|
23
23
|
import TextInput from "./TextInput.vue";
|
|
24
|
+
import OTPInput from "./OTPInput.vue";
|
|
24
25
|
import DropzoneInput from "./DropzoneInput.vue";
|
|
25
26
|
import SimpleUploader from "./SimpleUploader.vue";
|
|
26
27
|
import RangeSliderInput from "./RangeSliderInput.vue";
|
|
@@ -54,4 +55,5 @@ export {
|
|
|
54
55
|
TelInput,
|
|
55
56
|
TextAreaInput,
|
|
56
57
|
TextInput,
|
|
58
|
+
OTPInput,
|
|
57
59
|
}
|