inertia-bootstrap-forms 3.0.2 → 4.0.0
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/README.fa.md +86 -6
- package/README.md +95 -8
- package/dist/chunks/UppyInput-Dt8CPfgC.js +210 -0
- package/dist/chunks/UppyInput-ldc834tZ.cjs +1 -0
- package/dist/chunks/_plugin-vue_export-helper-13TPlHFF.js +81 -0
- package/dist/chunks/_plugin-vue_export-helper-BHyUve4F.cjs +1 -0
- package/dist/chunks/http-CDPNmbjF.cjs +1 -0
- package/dist/chunks/http-DV3dRBe5.js +158 -0
- package/dist/country-codes.cjs +1 -0
- package/dist/country-codes.js +245 -0
- package/dist/dropzone.cjs +1 -0
- package/dist/dropzone.js +81 -0
- package/dist/editor.cjs +1 -0
- package/dist/editor.js +52 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +3128 -0
- package/dist/location.cjs +1 -0
- package/dist/location.js +84 -0
- package/dist/persian-date.cjs +1 -0
- package/dist/persian-date.js +73 -0
- package/dist/tel.cjs +1 -0
- package/dist/tel.js +85 -0
- package/dist/uppy-dashboard.cjs +1 -0
- package/dist/uppy-dashboard.js +31 -0
- package/dist/uppy.cjs +1 -0
- package/dist/uppy.js +4 -0
- package/index.d.ts +44 -30
- package/package.json +99 -16
- package/src/CheckboxToggle.vue +1 -1
- package/src/ComboboxInput.vue +495 -496
- package/src/PasswordInput.vue +124 -123
- package/src/StarRatingInput.vue +1 -1
- package/src/UppyDashboardInput.vue +45 -0
- package/src/UppyInput.vue +36 -3
- package/src/VoiceRecorderInput.vue +657 -0
- package/src/entries/country-codes.js +1 -0
- package/src/entries/dropzone.js +1 -0
- package/src/entries/editor.js +1 -0
- package/src/entries/location.js +1 -0
- package/src/entries/persian-date.js +1 -0
- package/src/entries/tel.js +1 -0
- package/src/entries/uppy-dashboard.js +1 -0
- package/src/entries/uppy.js +1 -0
- package/src/index.js +3 -19
- package/types/country-codes.d.ts +1 -0
- package/types/dropzone.d.ts +2 -0
- package/types/editor.d.ts +2 -0
- package/types/location.d.ts +2 -0
- package/types/persian-date.d.ts +2 -0
- package/types/tel.d.ts +2 -0
- package/types/uppy-dashboard.d.ts +12 -0
- package/types/uppy.d.ts +10 -0
- package/dist/inertia-bootstrap-forms.cjs.js +0 -1
- package/dist/inertia-bootstrap-forms.es.js +0 -3536
- package/src/RangeSliderInput.vue +0 -103
- package/src/Select2Input.vue +0 -251
package/src/RangeSliderInput.vue
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {computed, defineComponent, inject} from 'vue';
|
|
3
|
-
|
|
4
|
-
export default defineComponent({
|
|
5
|
-
emits: ['update:modelValue', 'change'],
|
|
6
|
-
props: {
|
|
7
|
-
name: {
|
|
8
|
-
type: String,
|
|
9
|
-
default: null,
|
|
10
|
-
},
|
|
11
|
-
modelValue: {
|
|
12
|
-
type: Number,
|
|
13
|
-
default: 0
|
|
14
|
-
},
|
|
15
|
-
value: {
|
|
16
|
-
type: Number,
|
|
17
|
-
default: 0
|
|
18
|
-
},
|
|
19
|
-
min: {
|
|
20
|
-
type: Number,
|
|
21
|
-
default: 1
|
|
22
|
-
},
|
|
23
|
-
max: {
|
|
24
|
-
type: Number,
|
|
25
|
-
default: 100
|
|
26
|
-
},
|
|
27
|
-
step: {
|
|
28
|
-
type: Number,
|
|
29
|
-
default: 1
|
|
30
|
-
},
|
|
31
|
-
readonly: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false
|
|
34
|
-
},
|
|
35
|
-
range: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false
|
|
38
|
-
},
|
|
39
|
-
options: {
|
|
40
|
-
type: Object,
|
|
41
|
-
default: {}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
setup(props) {
|
|
45
|
-
let form = inject('form', {
|
|
46
|
-
errors: {},
|
|
47
|
-
getID(name) {
|
|
48
|
-
return name;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
let group = inject('group', {});
|
|
52
|
-
|
|
53
|
-
const modelValue = computed({
|
|
54
|
-
get() {
|
|
55
|
-
return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
|
|
56
|
-
},
|
|
57
|
-
set(value) {
|
|
58
|
-
if (group?.value?.name) {
|
|
59
|
-
group.value.setData(props.name, value);
|
|
60
|
-
} else {
|
|
61
|
-
form.value[props.name] = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return {modelValue, form, group};
|
|
67
|
-
},
|
|
68
|
-
methods: {},
|
|
69
|
-
mounted() {
|
|
70
|
-
import('svelte-range-slider-pips').then(({ default: RangeSlider }) => {
|
|
71
|
-
let _this = this
|
|
72
|
-
this.rangeSliderEn = new RangeSlider({
|
|
73
|
-
target: this.$refs.rangeSliderEl,
|
|
74
|
-
props: {
|
|
75
|
-
values: this.modelValue,
|
|
76
|
-
pips: true,
|
|
77
|
-
// ... بقیه props
|
|
78
|
-
min: this.min || null,
|
|
79
|
-
max: this.max || null,
|
|
80
|
-
...this.options,
|
|
81
|
-
}
|
|
82
|
-
}).$on('change', function (e) {
|
|
83
|
-
_this.$emit('change', e)
|
|
84
|
-
const value = _this.range ? e.detail?.values : e.detail?.value
|
|
85
|
-
_this.modelValue = value
|
|
86
|
-
_this.$emit('update:modelValue', value)
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
},
|
|
90
|
-
beforeUnmount() {
|
|
91
|
-
},
|
|
92
|
-
data() {
|
|
93
|
-
return {
|
|
94
|
-
rangeSliderEn: null
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
</script>
|
|
99
|
-
<template>
|
|
100
|
-
<div class="range-input" ref="rangeSliderEl" dir="ltr">
|
|
101
|
-
<input v-model="modelValue" type="hidden">
|
|
102
|
-
</div>
|
|
103
|
-
</template>
|
package/src/Select2Input.vue
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import './css/from-select.scss';
|
|
3
|
-
import {computed, defineComponent, inject} from "vue";
|
|
4
|
-
|
|
5
|
-
export default defineComponent({
|
|
6
|
-
emits: ['update:modelValue', 'search', 'searching', 'change', 'selected'],
|
|
7
|
-
props: {
|
|
8
|
-
name: {
|
|
9
|
-
type: String,
|
|
10
|
-
required: true,
|
|
11
|
-
},
|
|
12
|
-
modelValue: '',
|
|
13
|
-
label: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: null,
|
|
16
|
-
},
|
|
17
|
-
key: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: null,
|
|
20
|
-
},
|
|
21
|
-
placeholder: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: 'Click to choice',
|
|
24
|
-
},
|
|
25
|
-
searchPlaceholder: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'Type for search...',
|
|
28
|
-
},
|
|
29
|
-
multiple: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: false,
|
|
32
|
-
},
|
|
33
|
-
required: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
config: {
|
|
38
|
-
type: Object,
|
|
39
|
-
default: {},
|
|
40
|
-
},
|
|
41
|
-
locale: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: 'en',
|
|
44
|
-
},
|
|
45
|
-
options: Array,
|
|
46
|
-
searchEnabled: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false
|
|
49
|
-
},
|
|
50
|
-
hideDropdown: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
search: {
|
|
55
|
-
type: Object,
|
|
56
|
-
default: {
|
|
57
|
-
url: null,
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
setup(props) {
|
|
62
|
-
let form = inject('form', {
|
|
63
|
-
errors: {},
|
|
64
|
-
getID(name) {
|
|
65
|
-
return name;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
let group = inject('group', {});
|
|
69
|
-
|
|
70
|
-
const modelValue = computed({
|
|
71
|
-
get() {
|
|
72
|
-
return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
|
|
73
|
-
},
|
|
74
|
-
set(value) {
|
|
75
|
-
if (group?.value?.name) {
|
|
76
|
-
group.value.setData(props.name, value);
|
|
77
|
-
} else {
|
|
78
|
-
form.value[props.name] = value;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return {modelValue, form, group};
|
|
84
|
-
},
|
|
85
|
-
computed: {
|
|
86
|
-
selectedValue() {
|
|
87
|
-
if (!this.multiple) {
|
|
88
|
-
return this.modelValue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return (this.modelValue && typeof this.modelValue == 'object') ? Object.values(this.modelValue) : (this.modelValue ? [this.modelValue] : null)
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
watch: {
|
|
95
|
-
'options': {
|
|
96
|
-
handler: function (val, old) {
|
|
97
|
-
setTimeout(() => this.init(), 300);
|
|
98
|
-
},
|
|
99
|
-
deep: true
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
methods: {
|
|
103
|
-
getKeyFromItem(item) {
|
|
104
|
-
return ((this.key ? item[this.key] : item?.id ?? item?.name ?? item?.label ?? item?.value) ?? item)?.toString();
|
|
105
|
-
},
|
|
106
|
-
getLabelFromItem(item) {
|
|
107
|
-
return ((this.label ? item[this.label] : item?.name ?? item?.label ?? item?.value) ?? item)
|
|
108
|
-
},
|
|
109
|
-
selected(item) {
|
|
110
|
-
if (this.multiple) {
|
|
111
|
-
return (this.selectedValue || []).includes(this.getKeyFromItem(item));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return (this.getKeyFromItem(item)) === this.modelValue?.toString()
|
|
115
|
-
},
|
|
116
|
-
init() {
|
|
117
|
-
if (!this.ChoicesClass) return
|
|
118
|
-
|
|
119
|
-
if (this.choices) {
|
|
120
|
-
this.destroy();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (typeof window !== 'undefined' && this.locale === 'en' && document.dir === 'rtl') {
|
|
124
|
-
this.currentLocale = 'fa';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.choices = new this.ChoicesClass(this.$refs.input, {
|
|
128
|
-
searchEnabled: (this.searchEnabled || !!this.search?.url),
|
|
129
|
-
searchChoices: (this.searchEnabled && !this.search?.url),
|
|
130
|
-
removeItemButton: true,
|
|
131
|
-
placeholderValue: this.placeholder,
|
|
132
|
-
searchPlaceholderValue: this.placeholder,
|
|
133
|
-
shouldSort: false,
|
|
134
|
-
itemSelectText: null,
|
|
135
|
-
...this.localeTranslates[this.currentLocale],
|
|
136
|
-
...this.config
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
this.$refs.input.addEventListener('search', this.searchHandle);
|
|
140
|
-
},
|
|
141
|
-
destroy() {
|
|
142
|
-
this.$refs.input.removeEventListener('search', this.searchHandle);
|
|
143
|
-
this.choices?.destroy();
|
|
144
|
-
},
|
|
145
|
-
searchHandle(event) {
|
|
146
|
-
this.$emit('search', event)
|
|
147
|
-
clearTimeout(this.searchDebounceTimer);
|
|
148
|
-
|
|
149
|
-
this.showLoading();
|
|
150
|
-
|
|
151
|
-
this.searchDebounceTimer = setTimeout(() => {
|
|
152
|
-
this.doSearch(event.detail.value);
|
|
153
|
-
}, 400);
|
|
154
|
-
},
|
|
155
|
-
async showLoading() {
|
|
156
|
-
this.loading = true;
|
|
157
|
-
await this.choices.setChoices(
|
|
158
|
-
[{value: '', label: this.localeTranslates[this.currentLocale]['searchingPlaceholder'] || 'Searching...', disabled: true}],
|
|
159
|
-
'value',
|
|
160
|
-
'label',
|
|
161
|
-
true // replaceChoices
|
|
162
|
-
);
|
|
163
|
-
},
|
|
164
|
-
async doSearch(searchTerm) {
|
|
165
|
-
this.$emit('searching', searchTerm)
|
|
166
|
-
if (!this.search?.url) return;
|
|
167
|
-
|
|
168
|
-
if (this.searchController) {
|
|
169
|
-
this.searchController.abort();
|
|
170
|
-
}
|
|
171
|
-
this.searchController = new AbortController();
|
|
172
|
-
|
|
173
|
-
try {
|
|
174
|
-
const res = await fetch(this.search.url + '?query=' + encodeURIComponent(searchTerm), {
|
|
175
|
-
method: 'POST',
|
|
176
|
-
signal: this.searchController.signal,
|
|
177
|
-
});
|
|
178
|
-
const data = await res.json();
|
|
179
|
-
|
|
180
|
-
await this.choices.setChoices(
|
|
181
|
-
data.map(item => ({
|
|
182
|
-
value: this.getKeyFromItem(item),
|
|
183
|
-
label: this.getLabelFromItem(item),
|
|
184
|
-
})),
|
|
185
|
-
'value',
|
|
186
|
-
'label',
|
|
187
|
-
true
|
|
188
|
-
);
|
|
189
|
-
this.loading = false;
|
|
190
|
-
} catch (err) {
|
|
191
|
-
if (err.name !== 'AbortError') {
|
|
192
|
-
this.loading = false;
|
|
193
|
-
console.error(err);
|
|
194
|
-
await this.choices.setChoices([], 'value', 'label', true);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
mounted() {
|
|
200
|
-
import('choices.js').then(({ default: Choices }) => {
|
|
201
|
-
this.ChoicesClass = Choices
|
|
202
|
-
this.init()
|
|
203
|
-
})
|
|
204
|
-
},
|
|
205
|
-
beforeUnmount() {
|
|
206
|
-
this.destroy()
|
|
207
|
-
},
|
|
208
|
-
data() {
|
|
209
|
-
return {
|
|
210
|
-
ChoicesClass: null,
|
|
211
|
-
choices: null,
|
|
212
|
-
loading: false,
|
|
213
|
-
searchDebounceTimer: null,
|
|
214
|
-
searchController: null,
|
|
215
|
-
currentLocale: this.locale,
|
|
216
|
-
localeTranslates: {
|
|
217
|
-
'fa': {
|
|
218
|
-
placeholderValue: 'انتخاب کنید...',
|
|
219
|
-
searchPlaceholderValue: 'برای جستجو تایپ کنید...',
|
|
220
|
-
searchingPlaceholder: 'در حال جستجو...',
|
|
221
|
-
loadingText: 'در حال جستجو...',
|
|
222
|
-
noResultsText: 'نتیجه ای یافت نشد',
|
|
223
|
-
noChoicesText: 'گزینه ای وجود ندارد',
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
</script>
|
|
230
|
-
<template>
|
|
231
|
-
<div class="select2-controller" :class="{
|
|
232
|
-
'is-invalid': form.errors[name],
|
|
233
|
-
'select2-dropdown-hidden': hideDropdown === true
|
|
234
|
-
}">
|
|
235
|
-
<select
|
|
236
|
-
v-bind="$props"
|
|
237
|
-
:name="name"
|
|
238
|
-
:id="name"
|
|
239
|
-
v-model="modelValue"
|
|
240
|
-
class="form-control-select"
|
|
241
|
-
:class="{
|
|
242
|
-
'form-control-select--loading': loading,
|
|
243
|
-
'is-invalid': form.errors[name]
|
|
244
|
-
}"
|
|
245
|
-
ref="input">
|
|
246
|
-
<option :value="getKeyFromItem(item)" v-for="(item, index) in options" :selected="selected(item)">
|
|
247
|
-
{{ getLabelFromItem(item) }}
|
|
248
|
-
</option>
|
|
249
|
-
</select>
|
|
250
|
-
</div>
|
|
251
|
-
</template>
|