inertia-bootstrap-forms 3.0.1 → 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 +7 -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 -3529
- package/src/RangeSliderInput.vue +0 -103
- package/src/Select2Input.vue +0 -251
package/src/PasswordInput.vue
CHANGED
|
@@ -7,8 +7,8 @@ import { useBsInstance } from './composables/useBsInstance.js';
|
|
|
7
7
|
import { useI18n } from './i18n.js';
|
|
8
8
|
|
|
9
9
|
const STRENGTH_MESSAGES = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
en: { weak: 'Weak', fair: 'Fair', good: 'Good', strong: 'Strong' },
|
|
11
|
+
fa: { weak: 'ضعیف', fair: 'متوسط', good: 'خوب', strong: 'قوی' },
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -19,139 +19,140 @@ const STRENGTH_MESSAGES = {
|
|
|
19
19
|
* Every other prop / listener (placeholder, size, autocomplete, @change, …) is forwarded to the input.
|
|
20
20
|
*/
|
|
21
21
|
export default defineComponent({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
name: 'PasswordInput',
|
|
23
|
+
components: { TextInput, FormAdornInput },
|
|
24
|
+
inheritAttrs: false,
|
|
25
|
+
emits: ['toggle', 'strength'],
|
|
26
|
+
props: {
|
|
27
|
+
...fieldProps,
|
|
28
|
+
name: { type: String, default: 'password' },
|
|
29
|
+
placeholder: { type: String, default: null },
|
|
30
|
+
/** Show a "reveal password" button. */
|
|
31
|
+
toggle: { type: Boolean, default: false },
|
|
32
|
+
/** Show the password strength meter. */
|
|
33
|
+
strength: { type: Boolean, default: false },
|
|
34
|
+
/** Show the text feedback ("Weak", "Strong", …) under the meter. */
|
|
35
|
+
strengthText: { type: Boolean, default: true },
|
|
36
|
+
/** Override the labels: { weak, fair, good, strong }. */
|
|
37
|
+
strengthMessages: { type: Object, default: null },
|
|
38
|
+
/** Bootstrap Strength options: { minLength, thresholds: [2, 4, 6], weights, scorer(password) => number }. */
|
|
39
|
+
strengthOptions: { type: Object, default: () => ({}) },
|
|
40
|
+
size: { type: String, default: null },
|
|
41
|
+
locale: { type: String, default: null },
|
|
42
|
+
},
|
|
43
|
+
setup(props, { emit, expose }) {
|
|
44
|
+
const { t, locale } = useI18n(() => props.locale);
|
|
45
|
+
// read-only access to the value (so the meter follows form resets / external changes)
|
|
46
|
+
const field = useField(props, () => {});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const root = ref(null);
|
|
49
|
+
const meter = ref(null);
|
|
50
|
+
const visible = ref(false);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const messages = computed(() => ({
|
|
53
|
+
...(STRENGTH_MESSAGES[locale.value] || STRENGTH_MESSAGES.en),
|
|
54
|
+
...(props.strengthMessages || {}),
|
|
55
|
+
}));
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let offs = [];
|
|
63
|
-
const { instance, create } = useBsInstance(
|
|
64
|
-
'Strength',
|
|
65
|
-
() => (props.strength ? meter.value : null),
|
|
66
|
-
() => ({
|
|
67
|
-
...props.strengthOptions,
|
|
68
|
-
input: root.value?.querySelector('input'),
|
|
69
|
-
messages: messages.value,
|
|
70
|
-
}),
|
|
71
|
-
{
|
|
72
|
-
onCreate(inst, el) {
|
|
73
|
-
const handler = (e) => emit('strength', e.strength ?? null, e.score ?? 0);
|
|
74
|
-
el.addEventListener('strengthChange.bs.strength', handler);
|
|
75
|
-
offs.push(() => el.removeEventListener('strengthChange.bs.strength', handler));
|
|
76
|
-
},
|
|
77
|
-
onDestroy() {
|
|
78
|
-
offs.forEach((off) => off());
|
|
79
|
-
offs = [];
|
|
80
|
-
},
|
|
57
|
+
function toggleVisible() {
|
|
58
|
+
visible.value = !visible.value;
|
|
59
|
+
emit('toggle', visible.value);
|
|
81
60
|
}
|
|
82
|
-
);
|
|
83
61
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
62
|
+
let offs = [];
|
|
63
|
+
const { instance, create } = useBsInstance(
|
|
64
|
+
'Strength',
|
|
65
|
+
() => (props.strength ? meter.value : null),
|
|
66
|
+
() => ({
|
|
67
|
+
...props.strengthOptions,
|
|
68
|
+
input: root.value?.querySelector('input'),
|
|
69
|
+
messages: messages.value,
|
|
70
|
+
}),
|
|
71
|
+
{
|
|
72
|
+
onCreate(inst, el) {
|
|
73
|
+
const handler = (e) => emit('strength', e.strength ?? null, e.score ?? 0);
|
|
74
|
+
el.addEventListener('strengthChange.bs.strength', handler);
|
|
75
|
+
offs.push(() => el.removeEventListener('strengthChange.bs.strength', handler));
|
|
76
|
+
},
|
|
77
|
+
onDestroy() {
|
|
78
|
+
offs.forEach((off) => off());
|
|
79
|
+
offs = [];
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// the plugin only listens to typing: re-evaluate when the value changes from the outside (reset, server data)
|
|
85
|
+
watch(
|
|
86
|
+
() => field.model.value,
|
|
87
|
+
() => nextTick(() => instance.value?.evaluate())
|
|
88
|
+
);
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
// things the plugin reads when it is created
|
|
91
|
+
watch(
|
|
92
|
+
() => [props.strength, props.toggle, props.strengthText, messages.value, props.strengthOptions],
|
|
93
|
+
async () => {
|
|
94
|
+
await nextTick();
|
|
95
|
+
if (props.strength) create();
|
|
96
|
+
},
|
|
97
|
+
{ deep: true }
|
|
98
|
+
);
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
expose({ strength: () => instance.value?.getStrength?.() ?? null });
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
// props that are forwarded to the real input component
|
|
103
|
+
const forwarded = computed(() => ({
|
|
104
|
+
name: props.name,
|
|
105
|
+
modelValue: props.modelValue,
|
|
106
|
+
id: props.id,
|
|
107
|
+
disabled: props.disabled,
|
|
108
|
+
readonly: props.readonly,
|
|
109
|
+
required: props.required,
|
|
110
|
+
invalid: props.invalid,
|
|
111
|
+
size: props.size,
|
|
112
|
+
placeholder: props.placeholder ?? t('password.placeholder'),
|
|
113
|
+
}));
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
return { t, root, meter, visible, toggleVisible, forwarded };
|
|
116
|
+
},
|
|
117
117
|
});
|
|
118
118
|
</script>
|
|
119
119
|
|
|
120
120
|
<template>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
>
|
|
128
|
-
<template #end>
|
|
129
|
-
<button
|
|
130
|
-
type="button"
|
|
131
|
-
class="btn-text theme-secondary btn-icon"
|
|
132
|
-
:aria-label="visible ? t('password.hide') : t('password.show')"
|
|
133
|
-
:aria-pressed="visible"
|
|
134
|
-
@click="toggleVisible"
|
|
121
|
+
<div ref="root" class="password-input">
|
|
122
|
+
<FormAdornInput
|
|
123
|
+
v-if="toggle"
|
|
124
|
+
v-bind="{ ...$attrs, ...forwarded }"
|
|
125
|
+
:type="visible ? 'text' : 'password'"
|
|
126
|
+
autocomplete="current-password"
|
|
135
127
|
>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
128
|
+
<template #end>
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
class="btn-text theme-secondary btn-icon"
|
|
132
|
+
:aria-label="visible ? t('password.hide') : t('password.show')"
|
|
133
|
+
:aria-pressed="visible"
|
|
134
|
+
@click="toggleVisible"
|
|
135
|
+
>
|
|
136
|
+
<svg v-if="!visible" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
137
|
+
<path d="M1 8s2.5-4.5 7-4.5S15 8 15 8s-2.5 4.5-7 4.5S1 8 1 8Z" /><circle cx="8" cy="8" r="2" />
|
|
138
|
+
</svg>
|
|
139
|
+
<svg v-else width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
140
|
+
<path d="M2 2l12 12M6.6 3.7A7 7 0 0 1 8 3.5C12.5 3.5 15 8 15 8a11 11 0 0 1-2.2 2.6M4 5.4A11 11 0 0 0 1 8s2.5 4.5 7 4.5c1 0 1.9-.2 2.7-.6" />
|
|
141
|
+
</svg>
|
|
142
|
+
</button>
|
|
143
|
+
</template>
|
|
144
|
+
</FormAdornInput>
|
|
145
|
+
<TextInput v-else v-bind="{ ...$attrs, ...forwarded }" type="password" autocomplete="current-password" />
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
</
|
|
147
|
+
<template v-if="strength">
|
|
148
|
+
<!-- Bootstrap's Strength plugin owns the classes / text of these elements, Vue only renders them once -->
|
|
149
|
+
<div ref="meter" class="strength" aria-hidden="true">
|
|
150
|
+
<div class="strength-segment"></div>
|
|
151
|
+
<div class="strength-segment"></div>
|
|
152
|
+
<div class="strength-segment"></div>
|
|
153
|
+
<div class="strength-segment"></div>
|
|
154
|
+
</div>
|
|
155
|
+
<div v-if="strengthText" class="strength-text" aria-live="polite"></div>
|
|
156
|
+
</template>
|
|
157
|
+
</div>
|
|
158
|
+
</template>
|
package/src/StarRatingInput.vue
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { computed, defineComponent, h } from 'vue';
|
|
3
|
+
import Audio from '@uppy/audio';
|
|
4
|
+
import Webcam from '@uppy/webcam';
|
|
5
|
+
import Dashboard from '@uppy/vue/dashboard';
|
|
6
|
+
import UppyInput from './UppyInput.vue';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* UppyInput with the Uppy Dashboard UI and optional camera / voice recorder.
|
|
10
|
+
* Every UppyInput prop and event works here too.
|
|
11
|
+
*
|
|
12
|
+
* Needs: @uppy/dashboard, @uppy/webcam, @uppy/audio (+ their CSS).
|
|
13
|
+
*/
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: 'UppyDashboardInput',
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: {
|
|
18
|
+
/** Camera: true or @uppy/webcam options, e.g. { modes: ['picture'], mirror: true }. Needs HTTPS / localhost. */
|
|
19
|
+
webcam: { type: [Boolean, Object], default: false },
|
|
20
|
+
/** Voice recorder: true or @uppy/audio options, e.g. { showAudioSourceDropdown: true }. Needs HTTPS / localhost. */
|
|
21
|
+
audio: { type: [Boolean, Object], default: false },
|
|
22
|
+
/** Dashboard options: { height, width, theme, note, … }. */
|
|
23
|
+
dashboardProps: { type: Object, default: () => ({}) },
|
|
24
|
+
},
|
|
25
|
+
setup(props, { attrs, slots }) {
|
|
26
|
+
const plugins = computed(() => {
|
|
27
|
+
const list = [];
|
|
28
|
+
if (props.webcam) {
|
|
29
|
+
list.push({ plugin: Webcam, options: { id: 'Webcam', ...(typeof props.webcam === 'object' ? props.webcam : {}) } });
|
|
30
|
+
}
|
|
31
|
+
if (props.audio) {
|
|
32
|
+
list.push({ plugin: Audio, options: { id: 'Audio', ...(typeof props.audio === 'object' ? props.audio : {}) } });
|
|
33
|
+
}
|
|
34
|
+
return list;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return () =>
|
|
38
|
+
h(
|
|
39
|
+
UppyInput,
|
|
40
|
+
{ ...attrs, plugins: plugins.value, dashboardComponent: Dashboard, dashboardProps: props.dashboardProps },
|
|
41
|
+
slots
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
</script>
|
package/src/UppyInput.vue
CHANGED
|
@@ -42,6 +42,15 @@ export default defineComponent({
|
|
|
42
42
|
config: { type: Object, default: () => ({}) },
|
|
43
43
|
errorHandler: { type: Function, default: null },
|
|
44
44
|
showRestrictionCaption: { type: Boolean, default: true },
|
|
45
|
+
/**
|
|
46
|
+
* Extra Uppy plugins: [{ plugin: Webcam, options: { id: 'Webcam' }, dashboard: true }].
|
|
47
|
+
* Normally filled by <UppyDashboardInput>; every plugin needs an `id` to be listed in the Dashboard.
|
|
48
|
+
*/
|
|
49
|
+
plugins: { type: Array, default: () => [] },
|
|
50
|
+
/** Component that renders the Uppy Dashboard (the default export of '@uppy/vue/dashboard'). Switches the UI to the Dashboard. */
|
|
51
|
+
dashboardComponent: { type: Object, default: null },
|
|
52
|
+
/** Dashboard options: { height, width, theme, note, proudlyDisplayPoweredByUppy, … }. */
|
|
53
|
+
dashboardProps: { type: Object, default: () => ({}) },
|
|
45
54
|
locale: { type: String, default: null },
|
|
46
55
|
},
|
|
47
56
|
setup(props, { emit, expose }) {
|
|
@@ -50,6 +59,8 @@ export default defineComponent({
|
|
|
50
59
|
const d = useDisposables();
|
|
51
60
|
|
|
52
61
|
const uppy = shallowRef(null);
|
|
62
|
+
const useDashboard = computed(() => !!props.dashboardComponent);
|
|
63
|
+
const dashboardOptions = ref({});
|
|
53
64
|
const area = ref(null);
|
|
54
65
|
const caption = ref(null);
|
|
55
66
|
const errorMessage = ref(null);
|
|
@@ -190,6 +201,14 @@ export default defineComponent({
|
|
|
190
201
|
});
|
|
191
202
|
}
|
|
192
203
|
|
|
204
|
+
// Extra plugins (Webcam, Audio, …) are registered first, the Dashboard then picks them up by id
|
|
205
|
+
const dashboardPlugins = [];
|
|
206
|
+
props.plugins.forEach((item) => {
|
|
207
|
+
const options = { ...(item.options || {}) };
|
|
208
|
+
instance.use(item.plugin, options);
|
|
209
|
+
if (item.dashboard !== false && (options.id || item.id)) dashboardPlugins.push(options.id || item.id);
|
|
210
|
+
});
|
|
211
|
+
|
|
193
212
|
d.add(() => {
|
|
194
213
|
unmounting = true;
|
|
195
214
|
setUploading(null);
|
|
@@ -197,8 +216,21 @@ export default defineComponent({
|
|
|
197
216
|
uppy.value = null;
|
|
198
217
|
});
|
|
199
218
|
|
|
200
|
-
uppy.value = instance;
|
|
201
219
|
if (props.showRestrictionCaption) caption.value = buildCaption(instance.opts?.restrictions);
|
|
220
|
+
|
|
221
|
+
dashboardOptions.value = {
|
|
222
|
+
inline: true,
|
|
223
|
+
width: '100%',
|
|
224
|
+
height: 350,
|
|
225
|
+
theme: 'auto',
|
|
226
|
+
proudlyDisplayPoweredByUppy: false,
|
|
227
|
+
note: caption.value || undefined,
|
|
228
|
+
...props.dashboardProps,
|
|
229
|
+
plugins: [...dashboardPlugins, ...(props.dashboardProps?.plugins || [])],
|
|
230
|
+
};
|
|
231
|
+
if (useDashboard.value) caption.value = null; // the Dashboard prints the note itself
|
|
232
|
+
|
|
233
|
+
uppy.value = instance;
|
|
202
234
|
emit('ready', instance);
|
|
203
235
|
});
|
|
204
236
|
|
|
@@ -217,7 +249,7 @@ export default defineComponent({
|
|
|
217
249
|
|
|
218
250
|
expose({ uppy: () => uppy.value });
|
|
219
251
|
|
|
220
|
-
return { ...field, uppy, area, caption, errorMessage };
|
|
252
|
+
return { ...field, uppy, area, caption, errorMessage, useDashboard, dashboardOptions };
|
|
221
253
|
},
|
|
222
254
|
});
|
|
223
255
|
</script>
|
|
@@ -225,7 +257,8 @@ export default defineComponent({
|
|
|
225
257
|
<template>
|
|
226
258
|
<div v-if="uppy" ref="area" class="uppy-input-area" :id="inputId">
|
|
227
259
|
<div v-if="errorMessage" class="alert theme-danger text-center py-1 mb-2" role="alert">{{ errorMessage }}</div>
|
|
228
|
-
<
|
|
260
|
+
<component :is="dashboardComponent" v-if="useDashboard" :uppy="uppy" :props="dashboardOptions" />
|
|
261
|
+
<UppyContextProvider v-else :name="'uu' + (name ?? 'uppy')" :uppy="uppy">
|
|
229
262
|
<slot :uppy="uppy">
|
|
230
263
|
<FilesList class="uppy-file-lists" />
|
|
231
264
|
<UppyDropzone class="uppy-drop-zone" />
|