inertia-bootstrap-forms 4.0.4 → 4.0.6

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.md CHANGED
@@ -1,554 +1,554 @@
1
- # inertia-bootstrap-forms
2
-
3
- > **English** · [فارسی](./README.fa.md)
4
-
5
- Bootstrap **6** form components for **Vue 3 + Inertia.js** (Laravel). Every field binds itself to one
6
- [Inertia `useForm`](https://inertiajs.com/forms) instance through a `<FormContainer>`, and the value of **every field
7
- lives in the container's single `v-model`** — no per-field `v-model`, error classes or ids to wire by hand.
8
-
9
- ```vue
10
- <FormContainer v-model="formData" url="/tickets">
11
- <FormField name="priority" label="Priority">
12
- <ComboboxInput name="priority" :options="priorities" />
13
- </FormField>
14
-
15
- <SubmitButton>
16
- Save
17
- <Icon icon="arrow-left" class="align-middle ms-1" />
18
- </SubmitButton>
19
- </FormContainer>
20
- ```
21
-
22
- Built and maintained by **[Novin Vision](https://novinvision.com)** (نوین ویژن). Free for personal and commercial use (MIT).
23
-
24
- > **v3 is a rewrite for Bootstrap 6.** Bootstrap 5 projects should stay on `inertia-bootstrap-forms@2`.
25
- > See [Migrating from v2](#migrating-from-v2).
26
-
27
- ---
28
-
29
- ## Table of contents
30
-
31
- 1. [What's new in v3](#whats-new-in-v3)
32
- 2. [Requirements](#requirements)
33
- 3. [Installation](#installation)
34
- 4. [Core concepts](#core-concepts)
35
- 5. [Component reference](#component-reference)
36
- 6. [Upload endpoint contract](#upload-endpoint-contract)
37
- 7. [Internationalisation](#internationalisation)
38
- 8. [Lifecycle, SSR and cleanup](#lifecycle-ssr-and-cleanup)
39
- 9. [Composables](#composables)
40
- 10. [Migrating from v2](#migrating-from-v2)
41
- 11. [Notes and known limitations](#notes-and-known-limitations)
42
- 12. [Development](#development)
43
-
44
- ---
45
-
46
- ## What's new in v3
47
-
48
- - Rewritten for **Bootstrap 6** markup: `.check` / `.radio` / `.switch`, `.form-field`, `.btn-solid.theme-*`, `.menu`, `.alert.theme-*`, `.form-ghost`, …
49
- - **New components:** `ComboboxInput` (replaces `Select2Input` / choices.js), `ChipsInput`, `OTPInput` (Bootstrap OTP), `RangeInput`, `FormAdornInput`, `FormField`.
50
- - **Zero styles shipped.** No CSS file, no `<style>` blocks. Import Bootstrap 6 in your app.
51
- - Every field emits Vue events (`update:modelValue`, `change`, plus component specific ones) and exposes all the props it needs.
52
- - Bootstrap JavaScript plugins (Combobox, Chips, OTP, Range, Menu) are loaded lazily **on mount** and **disposed on unmount**. Listeners, timers, XHR requests, Dropzone and Uppy instances are released too.
53
- - SSR-safe: nothing touches `window` / `document` at import time or during server rendering.
54
- - No more hidden global requirements (`window.axios`, `maska`, `vue3-bootstrap-components`, FontAwesome).
55
-
56
- ## Requirements
57
-
58
- | Requirement | Notes |
59
- |---|---|
60
- | `vue` ≥ 3.3 | |
61
- | `@inertiajs/vue3` ≥ 2.0 | `FormContainer` uses `useForm()` |
62
- | `bootstrap` ^6.0.0-alpha.1 | **CSS** is required. The JS plugins are imported by this package on demand. |
63
- | `@floating-ui/dom` | Peer dependency of Bootstrap 6 menus (needed by Combobox / MultiQuantityInput) |
64
-
65
- **Nothing else is installed with this package.** Heavy third-party widgets are *optional peer dependencies*: install
66
- them only when you use the matching component (see [Optional components](#optional-components)).
67
-
68
- ## Installation
69
-
70
- ```bash
71
- npm install inertia-bootstrap-forms bootstrap@next @floating-ui/dom
72
- ```
73
-
74
- ### Optional components
75
-
76
- Components that wrap a heavy library live in their **own entry point** and the library is an **optional peer
77
- dependency**. The main entry never references them, so apps that do not use them install and bundle nothing extra.
78
-
79
- | Component | Import from | Install | CSS to import |
80
- |---|---|---|---|
81
- | `UppyInput` ¹ | `inertia-bootstrap-forms/uppy` | `npm i @uppy/core@^5.2 @uppy/vue@^3.2 @uppy/xhr-upload@^5.1` | `@uppy/vue/css/style.css` |
82
- | `UppyDashboardInput` (Uppy Dashboard + camera + voice recorder) | `inertia-bootstrap-forms/uppy-dashboard` | the three above + `npm i @uppy/dashboard@^5.1 @uppy/webcam@^5.1 @uppy/audio@^3.1` | `@uppy/dashboard`, `@uppy/webcam`, `@uppy/audio` → `dist/style.min.css` |
83
- | `DropzoneInput` ¹ | `inertia-bootstrap-forms/dropzone` | `npm i dropzone@^6.0.0-beta.2` | `dropzone/dist/basic.css`, `dropzone/dist/dropzone.css` |
84
- | `EditorInput` ¹ | `inertia-bootstrap-forms/editor` | `npm i @tinymce/tinymce-vue` (+ TinyMCE) | — |
85
- | `LocationInput` ¹ | `inertia-bootstrap-forms/location` | `npm i leaflet @vue-leaflet/vue-leaflet` | `leaflet/dist/leaflet.css` |
86
- | `TelInput` ¹ | `inertia-bootstrap-forms/tel` | `npm i vue-tel-input` | `vue-tel-input/vue-tel-input.css` |
87
- | `PersianDatePickerInput` | `inertia-bootstrap-forms/persian-date` | `npm i vue3-persian-datetime-picker` | — |
88
- | `countryCodes` (data) | `inertia-bootstrap-forms/country-codes` | — | — |
89
-
90
- ```js
91
- import { FormContainer, TextInput, ComboboxInput } from 'inertia-bootstrap-forms';
92
- import { UppyInput } from 'inertia-bootstrap-forms/uppy';
93
- import { TelInput } from 'inertia-bootstrap-forms/tel';
94
- ```
95
-
96
- > Keep all `@uppy/*` packages on the same major line (`@uppy/core@5`): plugins only work with the `@uppy/core`
97
- > instance they were built for. A bare `npm i @uppy/webcam` installs the newest major, which needs `@uppy/core@6`.
98
-
99
- ### Import the styles in your application
100
-
101
- The package does not ship any CSS. Import Bootstrap 6 (compiled CSS or your own Sass build) and — only for the
102
- widgets you use — the CSS of the third-party libraries:
103
-
104
- ```js
105
- // resources/js/app.js
106
- import 'bootstrap/dist/css/bootstrap.min.css'; // Bootstrap 6 (required)
107
-
108
- // only for the optional components you use — see the table in "Optional components"
109
- import 'vue-tel-input/vue-tel-input.css'; // TelInput
110
- import 'leaflet/dist/leaflet.css'; // LocationInput
111
- import 'dropzone/dist/basic.css'; // DropzoneInput
112
- import 'dropzone/dist/dropzone.css'; // DropzoneInput
113
- import '@uppy/vue/css/style.css'; // UppyInput
114
- ```
115
-
116
- You do **not** need to import Bootstrap's JavaScript: the plugins used by the components are loaded by the package.
117
- If your application already bundles Bootstrap and you want a single copy, hand the classes over:
118
-
119
- ```js
120
- import { Combobox, Chips, OtpInput, Range, Menu } from 'bootstrap';
121
- import { configureBootstrap } from 'inertia-bootstrap-forms';
122
-
123
- configureBootstrap({ Combobox, Chips, OtpInput, Range, Menu });
124
- ```
125
-
126
- ### Registering components
127
-
128
- Import what you need, or install the plugin to register all **built-in (light)** components globally. Components from the
129
- [optional entries](#optional-components) are registered by you (`app.component('UppyInput', UppyInput)`):
130
-
131
- ```js
132
- import InertiaBootstrapForms from 'inertia-bootstrap-forms';
133
-
134
- createInertiaApp({
135
- setup({ el, App, props, plugin }) {
136
- createApp({ render: () => h(App, props) })
137
- .use(plugin)
138
- .use(InertiaBootstrapForms, { locale: 'en' }) // options are optional
139
- .mount(el);
140
- },
141
- });
142
- ```
143
-
144
- ## Core concepts
145
-
146
- ### One `v-model` for the whole form
147
-
148
- ```vue
149
- <script setup>
150
- import { ref } from 'vue';
151
- import { FormContainer, TextInput, ComboboxInput, SwitchInput, SubmitButton } from 'inertia-bootstrap-forms';
152
-
153
- const formData = ref({ name: '', status: 'draft', published: false });
154
- </script>
155
-
156
- <template>
157
- <FormContainer v-model="formData" url="/products" @success="onSaved">
158
- <TextInput name="name" />
159
- <ComboboxInput name="status" :options="['draft', 'active']" />
160
- <SwitchInput name="published" label="Published" />
161
- <SubmitButton />
162
- </FormContainer>
163
- </template>
164
- ```
165
-
166
- * `name` is the key inside `formData`. The object does **not** have to declare every field up front: keys that are missing are added to `formData` as soon as the field is used, and they are submitted and reset with the rest. Typing into a field updates `formData`; changing `formData` from the outside updates the fields.
167
- * Server-side validation errors (`form.errors`) are matched by `name` and turn the control `.is-invalid`.
168
- * Fields are disabled while the form is `processing`.
169
- * Persian / Arabic digits are converted to English digits before submit (`:normalize-digits="false"` to disable). `File` objects are never touched.
170
- * Values are still **not limited to the container**: a field used *outside* a `FormContainer` works with its own `v-model`.
171
-
172
- ```vue
173
- <TextInput v-model="title" /> <!-- standalone -->
174
- ```
175
-
176
- ### Events
177
-
178
- Every component declares its emits:
179
-
180
- | Event | Payload | Emitted by |
181
- |---|---|---|
182
- | `update:modelValue` | `value` | all fields |
183
- | `change` | `value, event?` | all fields |
184
- | `input` | `value, event` | text-like fields, OTP, range |
185
- | `focus` / `blur` | `event` | text-like fields, checkbox family, range, chips |
186
- | component specific | see [reference](#component-reference) | combobox, chips, OTP, uploaders … |
187
-
188
- Native listeners that are not declared (`@keydown`, `@paste`, …) fall through to the underlying `<input>` on single-root
189
- components (`TextInput`, `TextAreaInput`, `EmailInput`, `MobileInput`, `PasswordInput`, `FormAdornInput`).
190
-
191
- ### Props shared by every field
192
-
193
- | Prop | Type | Description |
194
- |---|---|---|
195
- | `name` | `string` | Key in the form's v-model (also used for error lookup) |
196
- | `modelValue` | any | Standalone `v-model` (ignored inside a `FormContainer`) |
197
- | `id` | `string` | Override the generated id (auto-linked to `FormField` labels) |
198
- | `disabled` | `boolean` | Disable the control |
199
- | `readonly` | `boolean` | Read-only (or non-interactive for controls without native readonly) |
200
- | `required` | `boolean` | Native `required` |
201
- | `invalid` | `boolean` | Force invalid state; default follows server errors |
202
-
203
- ### Grouped / repeated values
204
-
205
- ```vue
206
- <GroupControl name="items" :index="0">
207
- <TextInput name="title" /> <!-- items[0].title -->
208
- <QuantityInput name="qty" /> <!-- items[0].qty -->
209
- </GroupControl>
210
- ```
211
-
212
- `index` is optional — without it the position among sibling `.form-control-group` elements is used. Error keys such as
213
- `items.0.title` are resolved automatically.
214
-
215
- ---
216
-
217
- ## Component reference
218
-
219
- ### Form structure
220
-
221
- #### `FormContainer`
222
-
223
- | Prop | Type | Default | Description |
224
- |---|---|---|---|
225
- | `modelValue` | `object` | `{}` | The form data (`v-model`) |
226
- | `url` | `string` | `''` | Submit URL |
227
- | `method` | `string` | `'post'` | HTTP method |
228
- | `only` | `string[]` | `[]` | Inertia `only` option |
229
- | `options` | `object` | `{}` | Extra fields that are not part of `modelValue` |
230
- | `visitOptions` | `object` | `{}` | Extra Inertia visit options (`preserveScroll`, `headers`, callbacks…) |
231
- | `autoTab` | `boolean` | `true` | Focus next field when `maxlength` is reached |
232
- | `resetOnSuccess` | `boolean` | `false` | Reset the form after a successful submit |
233
- | `submitHandler` | `(event, form) => any` | `null` | Replace the default submit |
234
- | `normalizeDigits` | `boolean` | `true` | Persian/Arabic → English digits on submit |
235
- | `validate` | `boolean` | `false` | Enable Bootstrap 6 client-side validation (`data-bs-validate`) |
236
- | `htmlMessages` | `boolean` | `false` | Render server messages as HTML (trusted content only) |
237
- | `hideAlerts` | `boolean` | `false` | Hide the built-in error / success alerts |
238
-
239
- Events: `update:modelValue`, `change`, `submit`, `reset`, `before`, `start`, `progress`, `success`, `error`, `cancel`, `finish`
240
- (legacy `onStart`, `onFinish`, `onSuccess`, `onError` are still emitted).
241
- Slots: default `{ form, submit, reset }`, `errors { errors, form }`, `message { message }`.
242
- Exposed: `submit()`, `reset()`, `form`, `el`.
243
-
244
- A `message` prop returned by the server in the Inertia page props is shown as a success alert.
245
-
246
- #### `FormField`
247
-
248
- Bootstrap 6 `.form-field`: label + control + help + validation feedback. The generated `id` is injected into the child control and the label.
249
-
250
- | Prop | Description |
251
- |---|---|
252
- | `name` | Field key — used to read the server error |
253
- | `label`, `help` | Texts |
254
- | `error` | Override the error text |
255
- | `required` | Adds the required mark to the label |
256
- | `id` | Override the generated id |
257
-
258
- Slots: default, `label`, `help`, `error`.
259
-
260
- ```vue
261
- <FormField name="email" label="Email" help="We never share it" required>
262
- <EmailInput name="email" />
263
- </FormField>
264
- ```
265
-
266
- #### `FormLabel`, `GroupControl`, `SubmitButton`
267
-
268
- * `FormLabel` – `for`, `required`. Detects its control automatically inside `FormField` or from the next element.
269
- * `GroupControl` – `name` (required), `index`.
270
- * `SubmitButton` – `variant` (`solid`), `theme` (`primary`), `loading`, `disabled`, `locale`. Renders `class="btn-solid theme-primary"`; pass `:variant="null"` to bring your own classes. Shows a spinner while `form.processing` / `form.uploading`. Emits `click`. Slots: default, `progress`.
271
-
272
- ### Text-like inputs
273
-
274
- | Component | Extra props | Notes |
275
- |---|---|---|
276
- | `TextInput` | `type`, `placeholder`, `size` (`sm`/`lg`) | `.form-control` |
277
- | `TextAreaInput` | `rows`, `placeholder`, `size` | |
278
- | `EmailInput` | `placeholder`, `locale` | `type="email"`; all `TextInput` props forwarded |
279
- | `MobileInput` | `placeholder`, `locale` | `type="tel"` |
280
- | `PasswordInput` | `placeholder`, `toggle`, `locale` | `toggle` adds a show / hide button (form-adorn); event `toggle` |
281
- | `TelInput` | `placeholder`, `defaultCountry` (`ir`), `preferredCountries`, `mode`, `validCharactersOnly`, `validate`, `dropdownOptions`, `inputOptions` | `vue-tel-input`; stores the international number; events `validate`, `country-changed` |
282
- | `FormAdornInput` | `type`, `placeholder`, `startText`, `endText`, `size` | Bootstrap 6 `.form-adorn`. Slots `start`, `end` |
283
- | `AmountInput` | `placeholder`, `unit`, `min`, `max`, `size`, `locale` | Integer with thousands separators, stores a `number` |
284
- | `QuantityInput` | `min` (0), `max`, `step` (1), `unit`, `locale` | Stepper; events `increment`, `decrement` |
285
- | `MultiQuantityInput` | `options`, `min`, `max`, `totalMin`, `totalMax`, `unit`, `placement`, `locale` | Bootstrap Menu with one stepper per option; value `{ 0: 2, 1: 1 }` |
286
-
287
- ```vue
288
- <FormAdornInput name="website" start-text="https://">
289
- <template #end><span class="form-adorn-icon"><svg …/></span></template>
290
- </FormAdornInput>
291
- ```
292
-
293
- ### Choice inputs
294
-
295
- | Component | Extra props |
296
- |---|---|
297
- | `CheckboxInput` | `type` (`checkbox`/`radio`), `value`, `trueValue`, `falseValue`, `checked`, `indeterminate`, `label` |
298
- | `SwitchInput` | `value`, `trueValue`, `falseValue`, `checked`, `label` |
299
- | `CheckboxButtonInput` | `type` (`radio`), `value`, `variant` (`outline`), `theme` (`primary`), `checked` — Bootstrap `.btn-check` |
300
- | `CheckboxToggle` | `type`, `value`, `checked`, `hideInput` — selectable card (`.form-field-card`) |
301
-
302
- Model rules follow Vue's native `v-model`: an **array** model collects the checked `value`s, a **radio** stores the selected `value`, a single checkbox stores `trueValue` / `falseValue` (default `true` / `false`).
303
-
304
- ```vue
305
- <CheckboxInput name="roles" value="admin" label="Admin" />
306
- <CheckboxInput name="roles" value="editor" label="Editor" /> <!-- roles: ['admin','editor'] -->
307
- <CheckboxInput name="plan" type="radio" value="pro" label="Pro" />
308
- ```
309
-
310
- ### `ComboboxInput` (Bootstrap 6 Combobox)
311
-
312
- Replaces `Select2Input` (choices.js). `Select2Input` is still exported as an alias.
313
-
314
- | Prop | Type | Default | Description |
315
- |---|---|---|---|
316
- | `options` | `Array` | `[]` | Strings, numbers or objects `{ id \| value, name \| label, description, disabled }` |
317
- | `valueKey` / `labelKey` | `string` | auto | Property names of option objects (`label` is a legacy alias of `labelKey`) |
318
- | `descriptionKey` | `string` | `'description'` | Secondary text of an option |
319
- | `multiple` | `boolean` | `false` | Multiple selection (array model) |
320
- | `placeholder` | `string` | i18n | |
321
- | `searchEnabled` | `boolean` | `false` | Client-side search box |
322
- | `search` | `object` | `{ url: null }` | **Remote search**: `{ url, method='POST', param='query', debounce=400, minChars=0, headers, resultsKey='data' }` |
323
- | `clearable` | `boolean` | `false` | Adds an entry that clears a single select |
324
- | `clearText`, `noResultsText`, `loadingText`, `searchPlaceholder`, `selectedText` | `string` | i18n | `selectedText` supports `{count}` |
325
- | `showSelected` | `boolean` | `false` | Multiple only: show the chosen options instead of the "N selected" counter |
326
- | `maxVisible` | `number` | `null` | With `showSelected`: above this many chosen options the counter is shown |
327
- | `selectedSeparator` | `string` | locale | Separator between the chosen labels |
328
- | `placement` | `string` | `'bottom-start'` | Floating UI placement |
329
- | `size`, `hideDropdown`, `searchNormalize`, `locale` | | | |
330
-
331
- Events: `update:modelValue`, `change`, `selected` (option(s)), `clear`, `search`, `search-success`, `search-error`, `show`, `shown`, `hide`, `hidden`.
332
- Exposed: `show()`, `hide()`, `toggle()`, `clear()`, `focus()`.
333
-
334
- ```vue
335
- <ComboboxInput name="priority" :options="[{ id: 1, name: 'Low' }, { id: 2, name: 'High', description: 'Answered first' }]" clearable />
336
-
337
- <ComboboxInput name="customer" :search="{ url: '/api/customers', debounce: 300 }" /> <!-- remote -->
338
-
339
- <ComboboxInput name="tags" multiple search-enabled :options="tags" />
340
- ```
341
-
342
- **Slots** — `#option` formats every menu item, `#selection` formats the value shown in the toggle (both receive `option`, `label`, `description`, `value`; `#option` also `selected`, `disabled`):
343
-
344
- ```vue
345
- <ComboboxInput name="plan" :options="plans">
346
- <template #option="{ option, label, description }">
347
- <span class="d-flex align-items-center gap-2"><Icon :icon="option.icon" /><strong>{{ label }}</strong></span>
348
- <small class="fg-secondary">{{ description }}</small>
349
- </template>
350
- <template #selection="{ option, label }"><Icon :icon="option.icon" /> {{ label }}</template>
351
- </ComboboxInput>
352
- ```
353
-
354
- The remote endpoint receives `?query=…` and must answer with a JSON array (or `{ data: [] }`). The `X-XSRF-TOKEN` cookie is forwarded automatically. Selected options always keep their label even when they are not part of the latest results.
355
-
356
- ### `ChipsInput` (Bootstrap 6 Chips)
357
-
358
- Value: array of strings.
359
-
360
- | Prop | Default | Description |
361
- |---|---|---|
362
- | `placeholder` | i18n | |
363
- | `separator` | `','` | Splits typed / pasted text. `null` disables |
364
- | `allowDuplicates` | `false` | |
365
- | `maxChips` | `null` | |
366
- | `dismissible` | `true` | Remove button on chips |
367
- | `dismissIcon` | `null` | Custom remove icon markup |
368
- | `createOnBlur` | `true` | |
369
- | `validator` | `null` | `(value) => boolean`; rejected values emit `rejected` |
370
-
371
- Events: `update:modelValue`, `change`, `add`, `remove`, `select`, `rejected`, `focus`, `blur`. Exposed: `add()`, `remove()`, `clear()`, `focus()`.
372
-
373
- ### `OTPInput` (Bootstrap 6 OTP)
374
-
375
- | Prop | Default | Description |
376
- |---|---|---|
377
- | `length` (`maxLength` legacy) | `6` | Number of characters |
378
- | `type` | `'numeric'` | `numeric` \| `alphanumeric` \| `alpha` |
379
- | `mask` | `false` | Show `•` |
380
- | `groups` | `null` | e.g. `[3, 3]` |
381
- | `separator` | `'·'` | |
382
- | `autoSubmit` | `false` | Submit the `FormContainer` when the code is complete |
383
- | `autofocus` | `false` | |
384
-
385
- Events: `update:modelValue`, `change`, `input`, `complete`, `focus`, `blur`. Exposed: `focus()`, `clear()`.
386
- A single real input backs the slots, so SMS / password-manager autofill keeps working.
387
-
388
- ### `RangeInput` (Bootstrap 6 Range)
389
-
390
- | Prop | Default | Description |
391
- |---|---|---|
392
- | `min` / `max` / `step` | `0` / `100` / `1` | |
393
- | `bubble` | `false` | Value bubble above the thumb |
394
- | `formatter` | `null` | `(value) => string` for bubble and tick labels |
395
- | `ticks` | `[]` | `[0, 50, 100]` or `[{ value, label }]` |
396
-
397
- Value: `number`. Events: `update:modelValue`, `change`, `input`, `focus`, `blur`. `RangeSliderInput` is an alias.
398
-
399
- ### Other inputs
400
-
401
- | Component | Highlights |
402
- |---|---|
403
- | `StarRatingInput` | `maxStars`, `precision` (steps per star), `showValue`, `clearable`, `value`; pointer + keyboard, RTL aware, `role="slider"` |
404
- | `CaptchaInput` | `url`, `placeholder`, `refreshOnSubmit`, `imageWidth`, `imageHeight`; event `refresh` |
405
- | `PersianDatePickerInput` ¹ | `calendar`, `view`, `min`, `max`, `range`, `format`, `inputFormat`, `pickerOptions`, `inputClass`; events `open`, `close` |
406
- | `EditorInput` | TinyMCE: `options`, `height`, `placeholder`, `apiKey`, `tinymceScriptSrc`; event `init` |
407
- | `LocationInput` | Leaflet: `center`, `zoom`, `height`, `tileUrl`, `attribution`; value `{ lat, lng }`; event `ready` |
408
- | `FileInput` (`SimpleUploader`) | `multiple`, `endpoint`, `accept`, `headers`, `fieldName`; events `added`, `progress`, `uploaded`, `error`, `removed` |
409
- | `DropzoneInput` | `multiple`, `url`, `options`, `headers`; events `ready`, `added`, `success`, `error`, `removed`, `complete` |
410
- | `UppyInput` | `multiple`, `useXHR`, `XHRConfig`, `url`, `config`, `errorHandler`, `showRestrictionCaption`; all Uppy events are re-emitted |
411
-
412
- ¹ Optional entry — see [Optional components](#optional-components) for the import path and the library to install.
413
-
414
- #### `UppyDashboardInput` — camera and voice recorder
415
-
416
- `UppyInput` with the Uppy Dashboard UI and the official `@uppy/webcam` / `@uppy/audio` plugins. All `UppyInput`
417
- props and events work as well.
418
-
419
- ```vue
420
- <script setup>
421
- import { UppyDashboardInput } from 'inertia-bootstrap-forms/uppy-dashboard';
422
- </script>
423
-
424
- <UppyDashboardInput name="media" webcam audio />
425
- <UppyDashboardInput name="photo" :webcam="{ modes: ['picture'], mirror: true }" />
426
- <UppyDashboardInput name="voice" :audio="{ showAudioSourceDropdown: true }"
427
- :config="{ restrictions: { allowedFileTypes: ['audio/*'], maxNumberOfFiles: 1 } }"
428
- :dashboard-props="{ height: 300 }" />
429
- ```
430
-
431
- | Prop | Description |
432
- |---|---|
433
- | `webcam` | `true` or [`@uppy/webcam` options](https://uppy.io/docs/webcam/) |
434
- | `audio` | `true` or [`@uppy/audio` options](https://uppy.io/docs/audio/) |
435
- | `dashboardProps` | Uppy Dashboard options (`height`, `theme`, `note`, …) |
436
-
437
- Camera and microphone need **HTTPS** (or `localhost`). Remember to allow `image/*`, `video/*` and `audio/*` in
438
- `restrictions.allowedFileTypes` when you restrict file types. The recorded audio format depends on the browser.
439
-
440
- `UppyInput` itself also accepts `plugins` (`[{ plugin, options: { id } }]`) and `dashboardComponent` for custom Uppy plugins.
441
-
442
- ---
443
-
444
- ## Upload endpoint contract
445
-
446
- `FileInput`, `DropzoneInput` and `UppyInput` talk to the same endpoint shape:
447
-
448
- * `POST {url}` — multipart field `file` → JSON `{ "data": { "path": "tmp/abc.jpg" } }` (or `{ "path": … }`).
449
- * `DELETE {url}` — body is the stored `path` (`FileInput`, `DropzoneInput`) or the JSON response (`UppyInput`).
450
-
451
- `FileInput` stores the `path` string(s); `DropzoneInput` / `UppyInput` store the response object(s). `form.uploading` holds the upload progress, so `SubmitButton` is disabled until uploads finish.
452
-
453
- ## Internationalisation
454
-
455
- Built-in dictionaries: `en` and `fa`. The default `locale: 'auto'` picks `fa` when the page is RTL (`dir="rtl"` / `lang="fa"`) and `en` otherwise.
456
- Set the locale globally to avoid any SSR / hydration difference:
457
-
458
- ```js
459
- import { configureI18n } from 'inertia-bootstrap-forms';
460
-
461
- configureI18n({ locale: 'fa' });
462
- configureI18n({ messages: { fa: { 'select.noResults': 'موردی نیست' } } });
463
- ```
464
-
465
- Any component with texts also accepts a `locale` prop and explicit text props (`placeholder`, `noResultsText`, …).
466
-
467
- ## Lifecycle, SSR and cleanup
468
-
469
- * Bootstrap plugins are created in `onMounted` through `useBsInstance()` and disposed in `onBeforeUnmount`; re-created automatically when a prop that is only read at construction time changes (`multiple`, `ticks`, `length`, …).
470
- * Plugins are imported lazily with `import('bootstrap/js/dist/<plugin>.js')` — bundlers code-split them.
471
- * `useDisposables()` tracks listeners, timers, `AbortController`s, XHRs, Dropzone and Uppy instances and releases them on unmount (also when the component unmounts while a plugin is still loading).
472
- * Server rendering outputs the static markup; widgets that need the DOM (Combobox, Chips, OTP, Range, Leaflet, date picker, …) start after hydration.
473
-
474
- ## Composables
475
-
476
- Build your own fields with the same plumbing:
477
-
478
- ```vue
479
- <script setup>
480
- import { fieldProps, useField } from 'inertia-bootstrap-forms';
481
-
482
- const props = defineProps({ ...fieldProps, color: String });
483
- const emit = defineEmits(['update:modelValue', 'change']);
484
- const { model, inputId, isInvalid, isDisabled, emitChange } = useField(props, emit);
485
- </script>
486
-
487
- <template>
488
- <input type="color" v-model="model" :id="inputId" :disabled="isDisabled" :class="{ 'is-invalid': isInvalid }" @change="emitChange(model, $event)" />
489
- </template>
490
- ```
491
-
492
- Also exported: `useFormApi()`, `useDisposables()`, `useBsInstance()`, `configureBootstrap()`, `configureI18n()`, `toEnglishDigits()`, `countryCodes`.
493
-
494
- ---
495
-
496
- ## Migrating from v2
497
-
498
- | v2 | v3 |
499
- |---|---|
500
- | Bootstrap 5 classes (`.form-check`, `.btn-primary`, …) | Bootstrap 6 (`.check`, `.btn-solid.theme-primary`, …). `.btn-primary` does not exist in Bootstrap 6: `SubmitButton` now renders `btn-solid theme-primary` by itself — use the `variant` / `theme` props instead of `class="btn btn-primary"` |
501
- | `import 'inertia-bootstrap-forms/dist/style.css'` | **Removed** — no CSS is shipped. Import Bootstrap 6 + third-party CSS yourself |
502
- | `Select2Input` (choices.js) | `ComboboxInput`; `Select2Input` remains as an alias. The choices.js `config` object is gone — use the documented props. Option field names are set with `valueKey` / `labelKey` (`label` still works as a legacy alias) |
503
- | Select value always a string | Select value keeps the option's original type (a numeric `id` stays a number) |
504
- | `RangeSliderInput` (dual thumb, svelte-range-slider-pips) | `RangeInput` (single thumb, Bootstrap 6). Dual range is not supported by Bootstrap 6 |
505
- | `OTPInput` default length `5` | default `6`; pass `:length="5"` to keep the old size. Fires `complete`; use `auto-submit` instead of `data-auto-submit-length` |
506
- | `CheckboxInput` `change` event passes the DOM event | `change(value, event)` for every field |
507
- | `StarRatingInput` stored `"3.5"` strings | stores numbers |
508
- | `FormContainer` rendered server messages with `v-html` | text by default, `html-messages` to opt in |
509
- | `FormContainer` emitted extra helper methods inside the data | emits only the form data |
510
- | `FileInput` needed `window.axios` | uses `XMLHttpRequest` + `fetch`, forwards the `XSRF-TOKEN` cookie |
511
- | `AmountInput` / `QuantityInput` needed `maska` | built in (Persian digits supported) |
512
- | `vue3-bootstrap-components`, `choices.js`, `svelte-range-slider-pips` bundled | removed |
513
- | `name` was `required` | optional — omit it for standalone `v-model` usage |
514
- | Peer: Bootstrap 5 CSS | Peer: `bootstrap@^6.0.0-alpha.1`, `@floating-ui/dom` |
515
-
516
- ### Migrating from v3 to v4
517
-
518
- v4 makes the package as light as possible: **nothing but your own peers is installed**. The components that wrap heavy
519
- libraries moved to their own entry points (and their libraries are optional peers):
520
-
521
- ```diff
522
- - import { UppyInput, DropzoneInput, EditorInput, LocationInput, TelInput, PersianDatePickerInput, countryCodes } from 'inertia-bootstrap-forms';
523
- + import { UppyInput } from 'inertia-bootstrap-forms/uppy';
524
- + import { DropzoneInput } from 'inertia-bootstrap-forms/dropzone';
525
- + import { EditorInput } from 'inertia-bootstrap-forms/editor';
526
- + import { LocationInput } from 'inertia-bootstrap-forms/location';
527
- + import { TelInput } from 'inertia-bootstrap-forms/tel';
528
- + import { PersianDatePickerInput } from 'inertia-bootstrap-forms/persian-date';
529
- + import { countryCodes } from 'inertia-bootstrap-forms/country-codes';
530
- ```
531
-
532
- Install the libraries of the components you use ([table](#optional-components)). The global plugin no longer registers them.
533
- `UppyInput`'s `webcam` / `audio` props moved to `UppyDashboardInput`.
534
-
535
- ## Notes and known limitations
536
-
537
- * Bootstrap 6 is currently in **alpha**; class names and plugin APIs may still change before the stable release.
538
- * Bootstrap 6 Combobox creates a `Menu` on the same toggle element, which makes Bootstrap log *"Bootstrap doesn't allow more than one instance per element"* to the console. This message comes from Bootstrap itself; the component works normally.
539
- * Bootstrap 6's own Datepicker has no Jalali calendar, so `PersianDatePickerInput` keeps `vue3-persian-datetime-picker`. Theme it with CSS variables in your app.
540
- * `LocationInput` in RTL pages: Leaflet panes need `left: auto; right: 0` — add that rule in your own CSS if the map renders offset.
541
- * `AmountInput` / `QuantityInput` handle integers.
542
- * `data-bs-toggle` attributes on the Combobox / Menu toggles are required for Bootstrap's data-API click handling and are rendered by the components.
543
-
544
- ## Development
545
-
546
- ```bash
547
- npm install
548
- npm test # vitest + jsdom (components, Bootstrap plugin lifecycle, SSR)
549
- npm run build # vite library build → dist/
550
- ```
551
-
552
- ---
553
-
554
- Built and maintained by **[Novin Vision](https://novinvision.com)** · MIT license
1
+ # inertia-bootstrap-forms
2
+
3
+ > **English** · [فارسی](./README.fa.md)
4
+
5
+ Bootstrap **6** form components for **Vue 3 + Inertia.js** (Laravel). Every field binds itself to one
6
+ [Inertia `useForm`](https://inertiajs.com/forms) instance through a `<FormContainer>`, and the value of **every field
7
+ lives in the container's single `v-model`** — no per-field `v-model`, error classes or ids to wire by hand.
8
+
9
+ ```vue
10
+ <FormContainer v-model="formData" url="/tickets">
11
+ <FormField name="priority" label="Priority">
12
+ <ComboboxInput name="priority" :options="priorities" />
13
+ </FormField>
14
+
15
+ <SubmitButton>
16
+ Save
17
+ <Icon icon="arrow-left" class="align-middle ms-1" />
18
+ </SubmitButton>
19
+ </FormContainer>
20
+ ```
21
+
22
+ Built and maintained by **[Novin Vision](https://novinvision.com)** (نوین ویژن). Free for personal and commercial use (MIT).
23
+
24
+ > **v3 is a rewrite for Bootstrap 6.** Bootstrap 5 projects should stay on `inertia-bootstrap-forms@2`.
25
+ > See [Migrating from v2](#migrating-from-v2).
26
+
27
+ ---
28
+
29
+ ## Table of contents
30
+
31
+ 1. [What's new in v3](#whats-new-in-v3)
32
+ 2. [Requirements](#requirements)
33
+ 3. [Installation](#installation)
34
+ 4. [Core concepts](#core-concepts)
35
+ 5. [Component reference](#component-reference)
36
+ 6. [Upload endpoint contract](#upload-endpoint-contract)
37
+ 7. [Internationalisation](#internationalisation)
38
+ 8. [Lifecycle, SSR and cleanup](#lifecycle-ssr-and-cleanup)
39
+ 9. [Composables](#composables)
40
+ 10. [Migrating from v2](#migrating-from-v2)
41
+ 11. [Notes and known limitations](#notes-and-known-limitations)
42
+ 12. [Development](#development)
43
+
44
+ ---
45
+
46
+ ## What's new in v3
47
+
48
+ - Rewritten for **Bootstrap 6** markup: `.check` / `.radio` / `.switch`, `.form-field`, `.btn-solid.theme-*`, `.menu`, `.alert.theme-*`, `.form-ghost`, …
49
+ - **New components:** `ComboboxInput` (replaces `Select2Input` / choices.js), `ChipsInput`, `OTPInput` (Bootstrap OTP), `RangeInput`, `FormAdornInput`, `FormField`.
50
+ - **Zero styles shipped.** No CSS file, no `<style>` blocks. Import Bootstrap 6 in your app.
51
+ - Every field emits Vue events (`update:modelValue`, `change`, plus component specific ones) and exposes all the props it needs.
52
+ - Bootstrap JavaScript plugins (Combobox, Chips, OTP, Range, Menu) are loaded lazily **on mount** and **disposed on unmount**. Listeners, timers, XHR requests, Dropzone and Uppy instances are released too.
53
+ - SSR-safe: nothing touches `window` / `document` at import time or during server rendering.
54
+ - No more hidden global requirements (`window.axios`, `maska`, `vue3-bootstrap-components`, FontAwesome).
55
+
56
+ ## Requirements
57
+
58
+ | Requirement | Notes |
59
+ |---|---|
60
+ | `vue` ≥ 3.3 | |
61
+ | `@inertiajs/vue3` ≥ 2.0 | `FormContainer` uses `useForm()` |
62
+ | `bootstrap` ^6.0.0-alpha.1 | **CSS** is required. The JS plugins are imported by this package on demand. |
63
+ | `@floating-ui/dom` | Peer dependency of Bootstrap 6 menus (needed by Combobox / MultiQuantityInput) |
64
+
65
+ **Nothing else is installed with this package.** Heavy third-party widgets are *optional peer dependencies*: install
66
+ them only when you use the matching component (see [Optional components](#optional-components)).
67
+
68
+ ## Installation
69
+
70
+ ```bash
71
+ npm install inertia-bootstrap-forms bootstrap@next @floating-ui/dom
72
+ ```
73
+
74
+ ### Optional components
75
+
76
+ Components that wrap a heavy library live in their **own entry point** and the library is an **optional peer
77
+ dependency**. The main entry never references them, so apps that do not use them install and bundle nothing extra.
78
+
79
+ | Component | Import from | Install | CSS to import |
80
+ |---|---|---|---|
81
+ | `UppyInput` ¹ | `inertia-bootstrap-forms/uppy` | `npm i @uppy/core@^5.2 @uppy/vue@^3.2 @uppy/xhr-upload@^5.1` | `@uppy/vue/css/style.css` |
82
+ | `UppyDashboardInput` (Uppy Dashboard + camera + voice recorder) | `inertia-bootstrap-forms/uppy-dashboard` | the three above + `npm i @uppy/dashboard@^5.1 @uppy/webcam@^5.1 @uppy/audio@^3.1` | `@uppy/dashboard`, `@uppy/webcam`, `@uppy/audio` → `dist/style.min.css` |
83
+ | `DropzoneInput` ¹ | `inertia-bootstrap-forms/dropzone` | `npm i dropzone@^6.0.0-beta.2` | `dropzone/dist/basic.css`, `dropzone/dist/dropzone.css` |
84
+ | `EditorInput` ¹ | `inertia-bootstrap-forms/editor` | `npm i @tinymce/tinymce-vue` (+ TinyMCE) | — |
85
+ | `LocationInput` ¹ | `inertia-bootstrap-forms/location` | `npm i leaflet @vue-leaflet/vue-leaflet` | `leaflet/dist/leaflet.css` |
86
+ | `TelInput` ¹ | `inertia-bootstrap-forms/tel` | `npm i vue-tel-input` | `vue-tel-input/vue-tel-input.css` |
87
+ | `PersianDatePickerInput` | `inertia-bootstrap-forms/persian-date` | `npm i vue3-persian-datetime-picker` | — |
88
+ | `countryCodes` (data) | `inertia-bootstrap-forms/country-codes` | — | — |
89
+
90
+ ```js
91
+ import { FormContainer, TextInput, ComboboxInput } from 'inertia-bootstrap-forms';
92
+ import { UppyInput } from 'inertia-bootstrap-forms/uppy';
93
+ import { TelInput } from 'inertia-bootstrap-forms/tel';
94
+ ```
95
+
96
+ > Keep all `@uppy/*` packages on the same major line (`@uppy/core@5`): plugins only work with the `@uppy/core`
97
+ > instance they were built for. A bare `npm i @uppy/webcam` installs the newest major, which needs `@uppy/core@6`.
98
+
99
+ ### Import the styles in your application
100
+
101
+ The package does not ship any CSS. Import Bootstrap 6 (compiled CSS or your own Sass build) and — only for the
102
+ widgets you use — the CSS of the third-party libraries:
103
+
104
+ ```js
105
+ // resources/js/app.js
106
+ import 'bootstrap/dist/css/bootstrap.min.css'; // Bootstrap 6 (required)
107
+
108
+ // only for the optional components you use — see the table in "Optional components"
109
+ import 'vue-tel-input/vue-tel-input.css'; // TelInput
110
+ import 'leaflet/dist/leaflet.css'; // LocationInput
111
+ import 'dropzone/dist/basic.css'; // DropzoneInput
112
+ import 'dropzone/dist/dropzone.css'; // DropzoneInput
113
+ import '@uppy/vue/css/style.css'; // UppyInput
114
+ ```
115
+
116
+ You do **not** need to import Bootstrap's JavaScript: the plugins used by the components are loaded by the package.
117
+ If your application already bundles Bootstrap and you want a single copy, hand the classes over:
118
+
119
+ ```js
120
+ import { Combobox, Chips, OtpInput, Range, Menu } from 'bootstrap';
121
+ import { configureBootstrap } from 'inertia-bootstrap-forms';
122
+
123
+ configureBootstrap({ Combobox, Chips, OtpInput, Range, Menu });
124
+ ```
125
+
126
+ ### Registering components
127
+
128
+ Import what you need, or install the plugin to register all **built-in (light)** components globally. Components from the
129
+ [optional entries](#optional-components) are registered by you (`app.component('UppyInput', UppyInput)`):
130
+
131
+ ```js
132
+ import InertiaBootstrapForms from 'inertia-bootstrap-forms';
133
+
134
+ createInertiaApp({
135
+ setup({ el, App, props, plugin }) {
136
+ createApp({ render: () => h(App, props) })
137
+ .use(plugin)
138
+ .use(InertiaBootstrapForms, { locale: 'en' }) // options are optional
139
+ .mount(el);
140
+ },
141
+ });
142
+ ```
143
+
144
+ ## Core concepts
145
+
146
+ ### One `v-model` for the whole form
147
+
148
+ ```vue
149
+ <script setup>
150
+ import { ref } from 'vue';
151
+ import { FormContainer, TextInput, ComboboxInput, SwitchInput, SubmitButton } from 'inertia-bootstrap-forms';
152
+
153
+ const formData = ref({ name: '', status: 'draft', published: false });
154
+ </script>
155
+
156
+ <template>
157
+ <FormContainer v-model="formData" url="/products" @success="onSaved">
158
+ <TextInput name="name" />
159
+ <ComboboxInput name="status" :options="['draft', 'active']" />
160
+ <SwitchInput name="published" label="Published" />
161
+ <SubmitButton />
162
+ </FormContainer>
163
+ </template>
164
+ ```
165
+
166
+ * `name` is the key inside `formData`. The object does **not** have to declare every field up front: keys that are missing are added to `formData` as soon as the field is used, and they are submitted and reset with the rest. Typing into a field updates `formData`; changing `formData` from the outside updates the fields.
167
+ * Server-side validation errors (`form.errors`) are matched by `name` and turn the control `.is-invalid`.
168
+ * Fields are disabled while the form is `processing`.
169
+ * Persian / Arabic digits are converted to English digits before submit (`:normalize-digits="false"` to disable). `File` objects are never touched.
170
+ * Values are still **not limited to the container**: a field used *outside* a `FormContainer` works with its own `v-model`.
171
+
172
+ ```vue
173
+ <TextInput v-model="title" /> <!-- standalone -->
174
+ ```
175
+
176
+ ### Events
177
+
178
+ Every component declares its emits:
179
+
180
+ | Event | Payload | Emitted by |
181
+ |---|---|---|
182
+ | `update:modelValue` | `value` | all fields |
183
+ | `change` | `value, event?` | all fields |
184
+ | `input` | `value, event` | text-like fields, OTP, range |
185
+ | `focus` / `blur` | `event` | text-like fields, checkbox family, range, chips |
186
+ | component specific | see [reference](#component-reference) | combobox, chips, OTP, uploaders … |
187
+
188
+ Native listeners that are not declared (`@keydown`, `@paste`, …) fall through to the underlying `<input>` on single-root
189
+ components (`TextInput`, `TextAreaInput`, `EmailInput`, `MobileInput`, `PasswordInput`, `FormAdornInput`).
190
+
191
+ ### Props shared by every field
192
+
193
+ | Prop | Type | Description |
194
+ |---|---|---|
195
+ | `name` | `string` | Key in the form's v-model (also used for error lookup) |
196
+ | `modelValue` | any | Standalone `v-model` (ignored inside a `FormContainer`) |
197
+ | `id` | `string` | Override the generated id (auto-linked to `FormField` labels) |
198
+ | `disabled` | `boolean` | Disable the control |
199
+ | `readonly` | `boolean` | Read-only (or non-interactive for controls without native readonly) |
200
+ | `required` | `boolean` | Native `required` |
201
+ | `invalid` | `boolean` | Force invalid state; default follows server errors |
202
+
203
+ ### Grouped / repeated values
204
+
205
+ ```vue
206
+ <GroupControl name="items" :index="0">
207
+ <TextInput name="title" /> <!-- items[0].title -->
208
+ <QuantityInput name="qty" /> <!-- items[0].qty -->
209
+ </GroupControl>
210
+ ```
211
+
212
+ `index` is optional — without it the position among sibling `.form-control-group` elements is used. Error keys such as
213
+ `items.0.title` are resolved automatically.
214
+
215
+ ---
216
+
217
+ ## Component reference
218
+
219
+ ### Form structure
220
+
221
+ #### `FormContainer`
222
+
223
+ | Prop | Type | Default | Description |
224
+ |---|---|---|---|
225
+ | `modelValue` | `object` | `{}` | The form data (`v-model`) |
226
+ | `url` | `string` | `''` | Submit URL |
227
+ | `method` | `string` | `'post'` | HTTP method |
228
+ | `only` | `string[]` | `[]` | Inertia `only` option |
229
+ | `options` | `object` | `{}` | Extra fields that are not part of `modelValue` |
230
+ | `visitOptions` | `object` | `{}` | Extra Inertia visit options (`preserveScroll`, `headers`, callbacks…) |
231
+ | `autoTab` | `boolean` | `true` | Focus next field when `maxlength` is reached |
232
+ | `resetOnSuccess` | `boolean` | `false` | Reset the form after a successful submit |
233
+ | `submitHandler` | `(event, form) => any` | `null` | Replace the default submit |
234
+ | `normalizeDigits` | `boolean` | `true` | Persian/Arabic → English digits on submit |
235
+ | `validate` | `boolean` | `false` | Enable Bootstrap 6 client-side validation (`data-bs-validate`) |
236
+ | `htmlMessages` | `boolean` | `false` | Render server messages as HTML (trusted content only) |
237
+ | `hideAlerts` | `boolean` | `false` | Hide the built-in error / success alerts |
238
+
239
+ Events: `update:modelValue`, `change`, `submit`, `reset`, `before`, `start`, `progress`, `success`, `error`, `cancel`, `finish`
240
+ (legacy `onStart`, `onFinish`, `onSuccess`, `onError` are still emitted).
241
+ Slots: default `{ form, submit, reset }`, `errors { errors, form }`, `message { message }`.
242
+ Exposed: `submit()`, `reset()`, `form`, `el`.
243
+
244
+ A `message` prop returned by the server in the Inertia page props is shown as a success alert.
245
+
246
+ #### `FormField`
247
+
248
+ Bootstrap 6 `.form-field`: label + control + help + validation feedback. The generated `id` is injected into the child control and the label.
249
+
250
+ | Prop | Description |
251
+ |---|---|
252
+ | `name` | Field key — used to read the server error |
253
+ | `label`, `help` | Texts |
254
+ | `error` | Override the error text |
255
+ | `required` | Adds the required mark to the label |
256
+ | `id` | Override the generated id |
257
+
258
+ Slots: default, `label`, `help`, `error`.
259
+
260
+ ```vue
261
+ <FormField name="email" label="Email" help="We never share it" required>
262
+ <EmailInput name="email" />
263
+ </FormField>
264
+ ```
265
+
266
+ #### `FormLabel`, `GroupControl`, `SubmitButton`
267
+
268
+ * `FormLabel` – `for`, `required`. Detects its control automatically inside `FormField` or from the next element.
269
+ * `GroupControl` – `name` (required), `index`.
270
+ * `SubmitButton` – `variant` (`solid`), `theme` (`primary`), `loading`, `disabled`, `locale`. Renders `class="btn-solid theme-primary"`; pass `:variant="null"` to bring your own classes. Shows a spinner while `form.processing` / `form.uploading`. Emits `click`. Slots: default, `progress`.
271
+
272
+ ### Text-like inputs
273
+
274
+ | Component | Extra props | Notes |
275
+ |---|---|---|
276
+ | `TextInput` | `type`, `placeholder`, `size` (`sm`/`lg`) | `.form-control` |
277
+ | `TextAreaInput` | `rows`, `placeholder`, `size` | |
278
+ | `EmailInput` | `placeholder`, `locale` | `type="email"`; all `TextInput` props forwarded |
279
+ | `MobileInput` | `placeholder`, `locale` | `type="tel"` |
280
+ | `PasswordInput` | `placeholder`, `toggle`, `locale` | `toggle` adds a show / hide button (form-adorn); event `toggle` |
281
+ | `TelInput` | `placeholder`, `defaultCountry` (`ir`), `preferredCountries`, `mode`, `validCharactersOnly`, `validate`, `dropdownOptions`, `inputOptions` | `vue-tel-input`; stores the international number; events `validate`, `country-changed` |
282
+ | `FormAdornInput` | `type`, `placeholder`, `startText`, `endText`, `size` | Bootstrap 6 `.form-adorn`. Slots `start`, `end` |
283
+ | `AmountInput` | `placeholder`, `unit`, `min`, `max`, `size`, `locale` | Integer with thousands separators, stores a `number` |
284
+ | `QuantityInput` | `min` (0), `max`, `step` (1), `unit`, `locale` | Stepper; events `increment`, `decrement` |
285
+ | `MultiQuantityInput` | `options`, `min`, `max`, `totalMin`, `totalMax`, `unit`, `placement`, `locale` | Bootstrap Menu with one stepper per option; value `{ 0: 2, 1: 1 }` |
286
+
287
+ ```vue
288
+ <FormAdornInput name="website" start-text="https://">
289
+ <template #end><span class="form-adorn-icon"><svg …/></span></template>
290
+ </FormAdornInput>
291
+ ```
292
+
293
+ ### Choice inputs
294
+
295
+ | Component | Extra props |
296
+ |---|---|
297
+ | `CheckboxInput` | `type` (`checkbox`/`radio`), `value`, `trueValue`, `falseValue`, `checked`, `indeterminate`, `label` |
298
+ | `SwitchInput` | `value`, `trueValue`, `falseValue`, `checked`, `label` |
299
+ | `CheckboxButtonInput` | `type` (`radio`), `value`, `variant` (`outline`), `theme` (`primary`), `checked` — Bootstrap `.btn-check` |
300
+ | `CheckboxToggle` | `type`, `value`, `checked`, `hideInput` — selectable card (`.form-field-card`) |
301
+
302
+ Model rules follow Vue's native `v-model`: an **array** model collects the checked `value`s, a **radio** stores the selected `value`, a single checkbox stores `trueValue` / `falseValue` (default `true` / `false`).
303
+
304
+ ```vue
305
+ <CheckboxInput name="roles" value="admin" label="Admin" />
306
+ <CheckboxInput name="roles" value="editor" label="Editor" /> <!-- roles: ['admin','editor'] -->
307
+ <CheckboxInput name="plan" type="radio" value="pro" label="Pro" />
308
+ ```
309
+
310
+ ### `ComboboxInput` (Bootstrap 6 Combobox)
311
+
312
+ Replaces `Select2Input` (choices.js). `Select2Input` is still exported as an alias.
313
+
314
+ | Prop | Type | Default | Description |
315
+ |---|---|---|---|
316
+ | `options` | `Array` | `[]` | Strings, numbers or objects `{ id \| value, name \| label, description, disabled }` |
317
+ | `valueKey` / `labelKey` | `string` | auto | Property names of option objects (`label` is a legacy alias of `labelKey`) |
318
+ | `descriptionKey` | `string` | `'description'` | Secondary text of an option |
319
+ | `multiple` | `boolean` | `false` | Multiple selection (array model) |
320
+ | `placeholder` | `string` | i18n | |
321
+ | `searchEnabled` | `boolean` | `false` | Client-side search box |
322
+ | `search` | `object` | `{ url: null }` | **Remote search**: `{ url, method='POST', param='query', debounce=400, minChars=0, headers, resultsKey='data' }` |
323
+ | `clearable` | `boolean` | `false` | Adds an entry that clears a single select |
324
+ | `clearText`, `noResultsText`, `loadingText`, `searchPlaceholder`, `selectedText` | `string` | i18n | `selectedText` supports `{count}` |
325
+ | `showSelected` | `boolean` | `false` | Multiple only: show the chosen options instead of the "N selected" counter |
326
+ | `maxVisible` | `number` | `null` | With `showSelected`: above this many chosen options the counter is shown |
327
+ | `selectedSeparator` | `string` | locale | Separator between the chosen labels |
328
+ | `placement` | `string` | `'bottom-start'` | Floating UI placement |
329
+ | `size`, `hideDropdown`, `searchNormalize`, `locale` | | | |
330
+
331
+ Events: `update:modelValue`, `change`, `selected` (option(s)), `clear`, `search`, `search-success`, `search-error`, `show`, `shown`, `hide`, `hidden`.
332
+ Exposed: `show()`, `hide()`, `toggle()`, `clear()`, `focus()`.
333
+
334
+ ```vue
335
+ <ComboboxInput name="priority" :options="[{ id: 1, name: 'Low' }, { id: 2, name: 'High', description: 'Answered first' }]" clearable />
336
+
337
+ <ComboboxInput name="customer" :search="{ url: '/api/customers', debounce: 300 }" /> <!-- remote -->
338
+
339
+ <ComboboxInput name="tags" multiple search-enabled :options="tags" />
340
+ ```
341
+
342
+ **Slots** — `#option` formats every menu item, `#selection` formats the value shown in the toggle (both receive `option`, `label`, `description`, `value`; `#option` also `selected`, `disabled`):
343
+
344
+ ```vue
345
+ <ComboboxInput name="plan" :options="plans">
346
+ <template #option="{ option, label, description }">
347
+ <span class="d-flex align-items-center gap-2"><Icon :icon="option.icon" /><strong>{{ label }}</strong></span>
348
+ <small class="fg-secondary">{{ description }}</small>
349
+ </template>
350
+ <template #selection="{ option, label }"><Icon :icon="option.icon" /> {{ label }}</template>
351
+ </ComboboxInput>
352
+ ```
353
+
354
+ The remote endpoint receives `?query=…` and must answer with a JSON array (or `{ data: [] }`). The `X-XSRF-TOKEN` cookie is forwarded automatically. Selected options always keep their label even when they are not part of the latest results.
355
+
356
+ ### `ChipsInput` (Bootstrap 6 Chips)
357
+
358
+ Value: array of strings.
359
+
360
+ | Prop | Default | Description |
361
+ |---|---|---|
362
+ | `placeholder` | i18n | |
363
+ | `separator` | `','` | Splits typed / pasted text. `null` disables |
364
+ | `allowDuplicates` | `false` | |
365
+ | `maxChips` | `null` | |
366
+ | `dismissible` | `true` | Remove button on chips |
367
+ | `dismissIcon` | `null` | Custom remove icon markup |
368
+ | `createOnBlur` | `true` | |
369
+ | `validator` | `null` | `(value) => boolean`; rejected values emit `rejected` |
370
+
371
+ Events: `update:modelValue`, `change`, `add`, `remove`, `select`, `rejected`, `focus`, `blur`. Exposed: `add()`, `remove()`, `clear()`, `focus()`.
372
+
373
+ ### `OTPInput` (Bootstrap 6 OTP)
374
+
375
+ | Prop | Default | Description |
376
+ |---|---|---|
377
+ | `length` (`maxLength` legacy) | `6` | Number of characters |
378
+ | `type` | `'numeric'` | `numeric` \| `alphanumeric` \| `alpha` |
379
+ | `mask` | `false` | Show `•` |
380
+ | `groups` | `null` | e.g. `[3, 3]` |
381
+ | `separator` | `'·'` | |
382
+ | `autoSubmit` | `false` | Submit the `FormContainer` when the code is complete |
383
+ | `autofocus` | `false` | |
384
+
385
+ Events: `update:modelValue`, `change`, `input`, `complete`, `focus`, `blur`. Exposed: `focus()`, `clear()`.
386
+ A single real input backs the slots, so SMS / password-manager autofill keeps working.
387
+
388
+ ### `RangeInput` (Bootstrap 6 Range)
389
+
390
+ | Prop | Default | Description |
391
+ |---|---|---|
392
+ | `min` / `max` / `step` | `0` / `100` / `1` | |
393
+ | `bubble` | `false` | Value bubble above the thumb |
394
+ | `formatter` | `null` | `(value) => string` for bubble and tick labels |
395
+ | `ticks` | `[]` | `[0, 50, 100]` or `[{ value, label }]` |
396
+
397
+ Value: `number`. Events: `update:modelValue`, `change`, `input`, `focus`, `blur`. `RangeSliderInput` is an alias.
398
+
399
+ ### Other inputs
400
+
401
+ | Component | Highlights |
402
+ |---|---|
403
+ | `StarRatingInput` | `maxStars`, `precision` (steps per star), `showValue`, `clearable`, `value`; pointer + keyboard, RTL aware, `role="slider"` |
404
+ | `CaptchaInput` | `url`, `placeholder`, `refreshOnSubmit`, `imageWidth`, `imageHeight`; event `refresh` |
405
+ | `PersianDatePickerInput` ¹ | `calendar`, `view`, `min`, `max`, `range`, `format`, `inputFormat`, `pickerOptions`, `inputClass`; events `open`, `close` |
406
+ | `EditorInput` | TinyMCE: `options`, `height`, `placeholder`, `apiKey`, `tinymceScriptSrc`; event `init` |
407
+ | `LocationInput` | Leaflet: `center`, `zoom`, `height`, `tileUrl`, `attribution`; value `{ lat, lng }`; event `ready` |
408
+ | `FileInput` (`SimpleUploader`) | `multiple`, `endpoint`, `accept`, `headers`, `fieldName`; events `added`, `progress`, `uploaded`, `error`, `removed` |
409
+ | `DropzoneInput` | `multiple`, `url`, `options`, `headers`; events `ready`, `added`, `success`, `error`, `removed`, `complete` |
410
+ | `UppyInput` | `multiple`, `useXHR`, `XHRConfig`, `url`, `config`, `errorHandler`, `showRestrictionCaption`; all Uppy events are re-emitted |
411
+
412
+ ¹ Optional entry — see [Optional components](#optional-components) for the import path and the library to install.
413
+
414
+ #### `UppyDashboardInput` — camera and voice recorder
415
+
416
+ `UppyInput` with the Uppy Dashboard UI and the official `@uppy/webcam` / `@uppy/audio` plugins. All `UppyInput`
417
+ props and events work as well.
418
+
419
+ ```vue
420
+ <script setup>
421
+ import { UppyDashboardInput } from 'inertia-bootstrap-forms/uppy-dashboard';
422
+ </script>
423
+
424
+ <UppyDashboardInput name="media" webcam audio />
425
+ <UppyDashboardInput name="photo" :webcam="{ modes: ['picture'], mirror: true }" />
426
+ <UppyDashboardInput name="voice" :audio="{ showAudioSourceDropdown: true }"
427
+ :config="{ restrictions: { allowedFileTypes: ['audio/*'], maxNumberOfFiles: 1 } }"
428
+ :dashboard-props="{ height: 300 }" />
429
+ ```
430
+
431
+ | Prop | Description |
432
+ |---|---|
433
+ | `webcam` | `true` or [`@uppy/webcam` options](https://uppy.io/docs/webcam/) |
434
+ | `audio` | `true` or [`@uppy/audio` options](https://uppy.io/docs/audio/) |
435
+ | `dashboardProps` | Uppy Dashboard options (`height`, `theme`, `note`, …) |
436
+
437
+ Camera and microphone need **HTTPS** (or `localhost`). Remember to allow `image/*`, `video/*` and `audio/*` in
438
+ `restrictions.allowedFileTypes` when you restrict file types. The recorded audio format depends on the browser.
439
+
440
+ `UppyInput` itself also accepts `plugins` (`[{ plugin, options: { id } }]`) and `dashboardComponent` for custom Uppy plugins.
441
+
442
+ ---
443
+
444
+ ## Upload endpoint contract
445
+
446
+ `FileInput`, `DropzoneInput` and `UppyInput` talk to the same endpoint shape:
447
+
448
+ * `POST {url}` — multipart field `file` → JSON `{ "data": { "path": "tmp/abc.jpg" } }` (or `{ "path": … }`).
449
+ * `DELETE {url}` — body is the stored `path` (`FileInput`, `DropzoneInput`) or the JSON response (`UppyInput`).
450
+
451
+ `FileInput` stores the `path` string(s); `DropzoneInput` / `UppyInput` store the response object(s). `form.uploading` holds the upload progress, so `SubmitButton` is disabled until uploads finish.
452
+
453
+ ## Internationalisation
454
+
455
+ Built-in dictionaries: `en` and `fa`. The default `locale: 'auto'` picks `fa` when the page is RTL (`dir="rtl"` / `lang="fa"`) and `en` otherwise.
456
+ Set the locale globally to avoid any SSR / hydration difference:
457
+
458
+ ```js
459
+ import { configureI18n } from 'inertia-bootstrap-forms';
460
+
461
+ configureI18n({ locale: 'fa' });
462
+ configureI18n({ messages: { fa: { 'select.noResults': 'موردی نیست' } } });
463
+ ```
464
+
465
+ Any component with texts also accepts a `locale` prop and explicit text props (`placeholder`, `noResultsText`, …).
466
+
467
+ ## Lifecycle, SSR and cleanup
468
+
469
+ * Bootstrap plugins are created in `onMounted` through `useBsInstance()` and disposed in `onBeforeUnmount`; re-created automatically when a prop that is only read at construction time changes (`multiple`, `ticks`, `length`, …).
470
+ * Plugins are imported lazily with `import('bootstrap/js/dist/<plugin>.js')` — bundlers code-split them.
471
+ * `useDisposables()` tracks listeners, timers, `AbortController`s, XHRs, Dropzone and Uppy instances and releases them on unmount (also when the component unmounts while a plugin is still loading).
472
+ * Server rendering outputs the static markup; widgets that need the DOM (Combobox, Chips, OTP, Range, Leaflet, date picker, …) start after hydration.
473
+
474
+ ## Composables
475
+
476
+ Build your own fields with the same plumbing:
477
+
478
+ ```vue
479
+ <script setup>
480
+ import { fieldProps, useField } from 'inertia-bootstrap-forms';
481
+
482
+ const props = defineProps({ ...fieldProps, color: String });
483
+ const emit = defineEmits(['update:modelValue', 'change']);
484
+ const { model, inputId, isInvalid, isDisabled, emitChange } = useField(props, emit);
485
+ </script>
486
+
487
+ <template>
488
+ <input type="color" v-model="model" :id="inputId" :disabled="isDisabled" :class="{ 'is-invalid': isInvalid }" @change="emitChange(model, $event)" />
489
+ </template>
490
+ ```
491
+
492
+ Also exported: `useFormApi()`, `useDisposables()`, `useBsInstance()`, `configureBootstrap()`, `configureI18n()`, `toEnglishDigits()`, `countryCodes`.
493
+
494
+ ---
495
+
496
+ ## Migrating from v2
497
+
498
+ | v2 | v3 |
499
+ |---|---|
500
+ | Bootstrap 5 classes (`.form-check`, `.btn-primary`, …) | Bootstrap 6 (`.check`, `.btn-solid.theme-primary`, …). `.btn-primary` does not exist in Bootstrap 6: `SubmitButton` now renders `btn-solid theme-primary` by itself — use the `variant` / `theme` props instead of `class="btn btn-primary"` |
501
+ | `import 'inertia-bootstrap-forms/dist/style.css'` | **Removed** — no CSS is shipped. Import Bootstrap 6 + third-party CSS yourself |
502
+ | `Select2Input` (choices.js) | `ComboboxInput`; `Select2Input` remains as an alias. The choices.js `config` object is gone — use the documented props. Option field names are set with `valueKey` / `labelKey` (`label` still works as a legacy alias) |
503
+ | Select value always a string | Select value keeps the option's original type (a numeric `id` stays a number) |
504
+ | `RangeSliderInput` (dual thumb, svelte-range-slider-pips) | `RangeInput` (single thumb, Bootstrap 6). Dual range is not supported by Bootstrap 6 |
505
+ | `OTPInput` default length `5` | default `6`; pass `:length="5"` to keep the old size. Fires `complete`; use `auto-submit` instead of `data-auto-submit-length` |
506
+ | `CheckboxInput` `change` event passes the DOM event | `change(value, event)` for every field |
507
+ | `StarRatingInput` stored `"3.5"` strings | stores numbers |
508
+ | `FormContainer` rendered server messages with `v-html` | text by default, `html-messages` to opt in |
509
+ | `FormContainer` emitted extra helper methods inside the data | emits only the form data |
510
+ | `FileInput` needed `window.axios` | uses `XMLHttpRequest` + `fetch`, forwards the `XSRF-TOKEN` cookie |
511
+ | `AmountInput` / `QuantityInput` needed `maska` | built in (Persian digits supported) |
512
+ | `vue3-bootstrap-components`, `choices.js`, `svelte-range-slider-pips` bundled | removed |
513
+ | `name` was `required` | optional — omit it for standalone `v-model` usage |
514
+ | Peer: Bootstrap 5 CSS | Peer: `bootstrap@^6.0.0-alpha.1`, `@floating-ui/dom` |
515
+
516
+ ### Migrating from v3 to v4
517
+
518
+ v4 makes the package as light as possible: **nothing but your own peers is installed**. The components that wrap heavy
519
+ libraries moved to their own entry points (and their libraries are optional peers):
520
+
521
+ ```diff
522
+ - import { UppyInput, DropzoneInput, EditorInput, LocationInput, TelInput, PersianDatePickerInput, countryCodes } from 'inertia-bootstrap-forms';
523
+ + import { UppyInput } from 'inertia-bootstrap-forms/uppy';
524
+ + import { DropzoneInput } from 'inertia-bootstrap-forms/dropzone';
525
+ + import { EditorInput } from 'inertia-bootstrap-forms/editor';
526
+ + import { LocationInput } from 'inertia-bootstrap-forms/location';
527
+ + import { TelInput } from 'inertia-bootstrap-forms/tel';
528
+ + import { PersianDatePickerInput } from 'inertia-bootstrap-forms/persian-date';
529
+ + import { countryCodes } from 'inertia-bootstrap-forms/country-codes';
530
+ ```
531
+
532
+ Install the libraries of the components you use ([table](#optional-components)). The global plugin no longer registers them.
533
+ `UppyInput`'s `webcam` / `audio` props moved to `UppyDashboardInput`.
534
+
535
+ ## Notes and known limitations
536
+
537
+ * Bootstrap 6 is currently in **alpha**; class names and plugin APIs may still change before the stable release.
538
+ * Bootstrap 6 Combobox creates a `Menu` on the same toggle element, which makes Bootstrap log *"Bootstrap doesn't allow more than one instance per element"* to the console. This message comes from Bootstrap itself; the component works normally.
539
+ * Bootstrap 6's own Datepicker has no Jalali calendar, so `PersianDatePickerInput` keeps `vue3-persian-datetime-picker`. Theme it with CSS variables in your app.
540
+ * `LocationInput` in RTL pages: Leaflet panes need `left: auto; right: 0` — add that rule in your own CSS if the map renders offset.
541
+ * `AmountInput` / `QuantityInput` handle integers.
542
+ * `data-bs-toggle` attributes on the Combobox / Menu toggles are required for Bootstrap's data-API click handling and are rendered by the components.
543
+
544
+ ## Development
545
+
546
+ ```bash
547
+ npm install
548
+ npm test # vitest + jsdom (components, Bootstrap plugin lifecycle, SSR)
549
+ npm run build # vite library build → dist/
550
+ ```
551
+
552
+ ---
553
+
554
+ Built and maintained by **[Novin Vision](https://novinvision.com)** · MIT license