inertia-bootstrap-forms 2.1.3 → 2.1.5
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-Bh4eONwE.js → index-CG5nvZ5W.js} +1 -1
- package/dist/{index-BBS5q19R.js → index-D7iOaWCg.js} +287 -265
- package/dist/inertia-bootstrap-forms.es.js +1 -1
- package/dist/inertia-bootstrap-forms.umd.js +5 -5
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/FormContainer.vue +37 -0
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/FormContainer.vue
CHANGED
|
@@ -15,6 +15,10 @@ export default defineComponent({
|
|
|
15
15
|
method: {
|
|
16
16
|
default: 'post'
|
|
17
17
|
},
|
|
18
|
+
autoTab: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: true,
|
|
21
|
+
},
|
|
18
22
|
only: {
|
|
19
23
|
type: Array,
|
|
20
24
|
default: [],
|
|
@@ -90,6 +94,37 @@ export default defineComponent({
|
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
96
|
methods: {
|
|
97
|
+
handleAutoTab(event) {
|
|
98
|
+
if (this.formEl?.dataset.autotab !== 'true') return;
|
|
99
|
+
|
|
100
|
+
const el = event.target;
|
|
101
|
+
if (!['INPUT', 'TEXTAREA'].includes(el.tagName)) return;
|
|
102
|
+
|
|
103
|
+
const maxLength = el.maxLength;
|
|
104
|
+
if (maxLength > 0 && el.value.length >= maxLength) {
|
|
105
|
+
this.focusNextField(el);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
focusNextField(current) {
|
|
109
|
+
const focusable = Array.from(
|
|
110
|
+
this.formEl.querySelectorAll('input, select, textarea')
|
|
111
|
+
).filter(el =>
|
|
112
|
+
!el.disabled &&
|
|
113
|
+
el.tabIndex !== -1 &&
|
|
114
|
+
el.type !== 'hidden' &&
|
|
115
|
+
el.offsetParent !== null
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const index = focusable.indexOf(current);
|
|
119
|
+
const next = focusable[index + 1];
|
|
120
|
+
|
|
121
|
+
if (next) {
|
|
122
|
+
next.focus();
|
|
123
|
+
if (next.tagName !== 'SELECT' && typeof next.select === 'function') {
|
|
124
|
+
next.select();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
93
128
|
reset() {
|
|
94
129
|
this.form.reset();
|
|
95
130
|
},
|
|
@@ -161,6 +196,8 @@ export default defineComponent({
|
|
|
161
196
|
<form ref="formEl"
|
|
162
197
|
:action="url"
|
|
163
198
|
:method="method"
|
|
199
|
+
:data-autotab="autoTab ? 'true' : ''"
|
|
200
|
+
@input="handleAutoTab"
|
|
164
201
|
@submit.prevent="submit"
|
|
165
202
|
@reset="$emit('reset')"
|
|
166
203
|
:class="{'form-processing': form.processing}"
|