inertia-bootstrap-forms 1.0.101 → 1.0.103

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.
Files changed (3) hide show
  1. package/README.md +852 -39
  2. package/index.d.ts +29 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,46 +1,859 @@
1
- # InertiaJS Form Components for Laravel
2
-
3
- If you're using InertiaJS in Laravel and are tired of creating repetitive forms and numerous components, we've created this package for ourselves and decided to share it with you. Everything is easily usable through Vue.
4
-
5
- ## Example:
6
-
7
- ```vue
8
- <FormContainer v-model="formData">
9
- <div class="row g-3">
10
- <div class="col-12 col-sm-6">
11
- <FormLabel>Name</FormLabel>
12
- <TextInput name="name" />
13
- </div>
14
- <div class="col-12 col-sm-3">
15
- <FormLabel>Alias</FormLabel>
16
- <TextInput name="slug"/>
17
- </div>
18
- <div class="col-12 col-sm-3">
19
- <FormLabel>Status</FormLabel>
20
- <Select2Input name="status" :options="[
21
- { id: 'active', name: 'Active' },
22
- { id: 'disable', name: 'Disabled' },
23
- { id: 'draft', name: 'Draft' }
24
- ]"/>
25
- </div>
26
- <div class="col-12 col-sm-6">
27
- <FormLabel>New Image</FormLabel>
28
- <FileInput name="new_thumbnail" />
29
- </div>
30
- <div class="col-12">
31
- <FormLabel>Description</FormLabel>
32
- <EditorInput name="description" />
33
- </div>
34
- <div class="col-12 text-end">
35
- <SubmitButton />
36
- </div>
1
+ # inertia-bootstrap-forms
2
+
3
+ A Vue 3 component library for building Bootstrap‑styled forms inside **Laravel + Inertia.js** applications. Every input component binds itself automatically to an [Inertia `useForm`](https://inertiajs.com/forms) instance through a `<FormContainer>` wrapper, so you stop wiring up `v-model`, error classes, and field names by hand for every form.
4
+
5
+ This package has been developed and maintained by **[Novin Vision](https://novinvision.com)** (شرکت **[نوین ویژن](https://novinvision.com)**), a team specialized in **[طراحی سایت](https://novinvision.com)** and **[web design](https://novinvision.com)**.
6
+
7
+ # About Us
8
+
9
+ Novin Vision focuses on building modern and practical web solutions for businesses and developers who want a reliable digital presence. The approach is simple: clean design, solid development, and results that can be used in real projects without complexity.
10
+
11
+ If you want to learn more or get in touch, you can visit:
12
+ https://novinvision.com
13
+
14
+ ## License
15
+
16
+ The use of this package is completely free. You are allowed to use it in personal and commercial projects without any restriction or payment.
17
+
18
+ ---
19
+
20
+ Built and maintained by **Novin Vision**
21
+ ```vue
22
+ <FormContainer v-model="formData" url="/products">
23
+ <div class="row g-3">
24
+ <div class="col-12 col-sm-6">
25
+ <FormLabel>Name</FormLabel>
26
+ <TextInput name="name" />
37
27
  </div>
28
+ <div class="col-12 col-sm-3">
29
+ <FormLabel>Alias</FormLabel>
30
+ <TextInput name="slug" />
31
+ </div>
32
+ <div class="col-12 col-sm-3">
33
+ <FormLabel>Status</FormLabel>
34
+ <Select2Input name="status" :options="[
35
+ { id: 'active', name: 'Active' },
36
+ { id: 'disable', name: 'Disabled' },
37
+ { id: 'draft', name: 'Draft' }
38
+ ]" />
39
+ </div>
40
+ <div class="col-12 col-sm-6">
41
+ <FormLabel>New Image</FormLabel>
42
+ <FileInput name="new_thumbnail" />
43
+ </div>
44
+ <div class="col-12">
45
+ <FormLabel>Description</FormLabel>
46
+ <EditorInput name="description" />
47
+ </div>
48
+ <div class="col-12 text-end">
49
+ <SubmitButton />
50
+ </div>
51
+ </div>
52
+ </FormContainer>
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Table of Contents
58
+
59
+ 1. [Requirements](#requirements)
60
+ 2. [Installation](#installation)
61
+ 3. [Global Setup (required helpers)](#global-setup-required-helpers)
62
+ 4. [Core Concepts](#core-concepts)
63
+ 5. [Component Reference](#component-reference)
64
+ - [FormContainer](#formcontainer)
65
+ - [FormLabel](#formlabel)
66
+ - [GroupControl](#groupcontrol)
67
+ - [TextInput](#textinput)
68
+ - [TextAreaInput](#textareainput)
69
+ - [EmailInput](#emailinput)
70
+ - [PasswordInput](#passwordinput)
71
+ - [MobileInput](#mobileinput)
72
+ - [TelInput](#telinput)
73
+ - [AmountInput](#amountinput)
74
+ - [QuantityInput](#quantityinput)
75
+ - [MultiQuantityInput](#multiquantityinput)
76
+ - [CheckboxInput](#checkboxinput)
77
+ - [CheckboxButtonInput](#checkboxbuttoninput)
78
+ - [CheckboxToggle](#checkboxtoggle)
79
+ - [Select2Input](#select2input)
80
+ - [PersianDatePickerInput](#persiandatepickerinput)
81
+ - [RangeSliderInput](#rangesliderinput)
82
+ - [StarRatingInput](#starratinginput)
83
+ - [CaptchaInput](#captchainput)
84
+ - [EditorInput](#editorinput)
85
+ - [LocationInput](#locationinput)
86
+ - [FileInput](#fileinput)
87
+ - [SimpleUploader](#simpleuploader)
88
+ - [DropzoneInput](#dropzoneinput)
89
+ - [UppyInput](#uppyinput)
90
+ - [SubmitButton](#submitbutton)
91
+ 6. [Upload Endpoint Contract (backend)](#upload-endpoint-contract-backend)
92
+ 7. [Styling & Theming](#styling--theming)
93
+ 8. [TypeScript](#typescript)
94
+ 9. [Known Limitations](#known-limitations)
95
+
96
+ ---
97
+
98
+ ## Requirements
99
+
100
+ The package itself only ships the Vue components (plus a few smaller libraries that are already bundled into `dist/`). The following must exist in the **host** application:
101
+
102
+ | Requirement | Why |
103
+ |---|---|
104
+ | Vue `^3.0` | The components are plain Vue 3 SFCs. |
105
+ | `@inertiajs/vue3` `>2.0` | `FormContainer` calls Inertia's `useForm()` internally. |
106
+ | Bootstrap 5 CSS (`.form-control`, `.btn`, `.input-group`, `.form-check`, CSS variables like `--bs-*`, etc.) | All markup/classes assume Bootstrap 5 is loaded. |
107
+ | `dropzone` `^6.0.0-beta.2` | Only needed if you use `<DropzoneInput>`. |
108
+ | `@tinymce/tinymce-vue` | Only needed if you use `<EditorInput>` (TinyMCE). |
109
+ | `@vue-leaflet/vue-leaflet` + `leaflet` | Only needed if you use `<LocationInput>`. |
110
+ | `vue-tel-input` | Only needed if you use `<TelInput>`. |
111
+ | `vue3-persian-datetime-picker` | Only needed if you use `<PersianDatePickerInput>`. |
112
+ | `maska` | Only needed if you use `<AmountInput>` or `<QuantityInput>` (number masking). |
113
+ | `axios` available globally as `window.axios` | Used internally by `<FileInput>`. Laravel's default `resources/js/bootstrap.js` already does this (`window.axios = require('axios')`). |
114
+
115
+ The following libraries are **already bundled inside `dist/`** and do **not** need to be installed separately: `vue3-bootstrap-components`, `choices.js`, `svelte-range-slider-pips`, `@uppy/core`, `@uppy/vue`, `@uppy/xhr-upload`.
116
+
117
+ ---
118
+
119
+ ## Installation
120
+
121
+ ### 1. Install the package
122
+
123
+ This package isn't necessarily on the public npm registry, so install it however it was distributed to you:
124
+
125
+ ```bash
126
+ # from a private/internal npm registry
127
+ npm install inertia-bootstrap-forms
128
+
129
+ # from a Git repository
130
+ npm install git+https://github.com/novinvision/inertia-bootstrap-forms.git
131
+
132
+ # from a local folder or tarball
133
+ npm install file:../path/to/inertia-bootstrap-forms
134
+ ```
135
+
136
+ ### 2. Install the peer libraries you actually need
137
+
138
+ You don't have to install all of them — only the ones backing the components you use:
139
+
140
+ ```bash
141
+ npm install @inertiajs/vue3 dropzone @tinymce/tinymce-vue \
142
+ @vue-leaflet/vue-leaflet leaflet vue-tel-input \
143
+ vue3-persian-datetime-picker maska
144
+ ```
145
+
146
+ ### 3. Import the package styles
147
+
148
+ ```js
149
+ // resources/js/app.js
150
+ import 'inertia-bootstrap-forms/dist/style.css';
151
+ ```
152
+
153
+ ### 4. Register the components
154
+
155
+ You can either import components individually (recommended, keeps the bundle small):
156
+
157
+ ```vue
158
+ <script setup>
159
+ import { FormContainer, FormLabel, TextInput, SubmitButton } from 'inertia-bootstrap-forms';
160
+ </script>
161
+ ```
162
+
163
+ …or register everything globally once, in `app.js`:
164
+
165
+ ```js
166
+ import { createApp, h } from 'vue';
167
+ import { createInertiaApp } from '@inertiajs/vue3';
168
+ import * as InertiaBootstrapForms from 'inertia-bootstrap-forms';
169
+ import 'inertia-bootstrap-forms/dist/style.css';
170
+
171
+ createInertiaApp({
172
+ resolve: name => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
173
+ setup({ el, App, props, plugin }) {
174
+ const app = createApp({ render: () => h(App, props) }).use(plugin);
175
+
176
+ Object.entries(InertiaBootstrapForms).forEach(([name, component]) => {
177
+ if (name !== 'default') app.component(name, component);
178
+ });
179
+
180
+ app.mount(el);
181
+ },
182
+ });
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Global Setup (required helpers)
188
+
189
+ Two components (`AmountInput`, `QuantityInput`) rely on globals that this package does **not** provide. You need to register them yourself in `app.js` before those components will work.
190
+
191
+ ### `v-maska` directive
192
+
193
+ `AmountInput` and `QuantityInput` use `v-maska` (from the [`maska`](https://www.npmjs.com/package/maska) package) to format numbers with thousand separators while typing.
194
+
195
+ ```bash
196
+ npm install maska
197
+ ```
198
+
199
+ ```js
200
+ import { vMaska } from 'maska/vue';
201
+
202
+ app.directive('maska', vMaska);
203
+ ```
204
+
205
+ You can use any version/config of `maska` you like — the components only depend on the directive name (`v-maska`) and the `@maska` event payload (`event.detail.unmasked`), so feel free to follow Maska's own documentation for advanced masking options.
206
+
207
+ ### `$number` global helper
208
+
209
+ The same two components call `this.$number.toEnglish(...)` to convert localized (Persian/Arabic-Indic) digits typed by the user into plain English digits before storing them in the form. This helper is **not bundled** — you need to provide it as a global property. A minimal implementation that mirrors the digit conversion already used internally by `FormContainer` on submit:
210
+
211
+ ```js
212
+ // resources/js/plugins/number.js
213
+ const persianDigits = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'];
214
+ const arabicDigits = ['٠','١','٢','٣','٤','٥','٦','٧','٨','٩'];
215
+
216
+ export default {
217
+ install(app) {
218
+ app.config.globalProperties.$number = {
219
+ toEnglish(value) {
220
+ if (value === null || value === undefined) return value;
221
+ let str = value.toString();
222
+ persianDigits.forEach((d, i) => { str = str.replaceAll(d, i); });
223
+ arabicDigits.forEach((d, i) => { str = str.replaceAll(d, i); });
224
+ return str.replaceAll(',', '');
225
+ }
226
+ };
227
+ }
228
+ };
229
+ ```
230
+
231
+ ```js
232
+ import NumberPlugin from './plugins/number';
233
+ app.use(NumberPlugin);
234
+ ```
235
+
236
+ If you don't use `AmountInput` or `QuantityInput`, you can skip this section entirely.
237
+
238
+ ### Optional: Font Awesome
239
+
240
+ `CaptchaInput` renders a refresh icon using a Font Awesome class (`fal fa-sync-alt`, Pro "light" style). If you don't load Font Awesome Pro, the button still works — you just won't see the icon. Swap in your own icon via the component's markup if needed.
241
+
242
+ ---
243
+
244
+ ## Core Concepts
245
+
246
+ ### `FormContainer` and the injected `form`
247
+
248
+ `<FormContainer>` wraps Inertia's `useForm()` and `provide()`s it to every descendant via Vue's `provide`/`inject`. All the field components below `inject` this `form` object and read/write `form[name]` automatically — that's the entire trick behind not having to wire `v-model` on every field yourself.
249
+
250
+ ```vue
251
+ <FormContainer v-model="formData" url="/login" method="post" reset-on-success>
252
+ <TextInput name="email" />
253
+ <PasswordInput name="password" />
254
+ <SubmitButton />
38
255
  </FormContainer>
39
256
  ```
40
257
 
41
- This package simplifies form creation and management in your InertiaJS and Laravel applications, reducing redundancy and improving development efficiency.
258
+ `FormContainer` props:
259
+
260
+ | Prop | Type | Default | Description |
261
+ |---|---|---|---|
262
+ | `url` | String | `''` | Endpoint the form submits to. |
263
+ | `method` | String | `'post'` | HTTP method passed to Inertia's `form.submit()`. |
264
+ | `only` | Array | `[]` | Inertia partial-reload `only` option. |
265
+ | `modelValue` | Object | `{}` | Initial data for the form (also works with `v-model`). |
266
+ | `options` | Object | `{}` | Extra fields merged into the Inertia form state (e.g. defaults that aren't real inputs). |
267
+ | `resetOnSuccess` | Boolean | `false` | Calls `form.reset()` automatically after a successful submit. |
268
+ | `submitHandler` | Function | `null` | If provided, this function is called instead of the default Inertia submit flow — useful for custom submit logic (e.g. confirmation modals). |
269
+
270
+ Events: `submit`, `reset`, `onStart`, `onFinish`, `onSuccess`, `onError`, `change`, `update:modelValue`.
271
+
272
+ Slots:
273
+ - default — scoped with `{ form, submit }`, the actual form fields.
274
+ - `errors` — override the default error `<Alert>` block.
275
+ - `message` — override the default success `<Alert>` block (shown when the backend response includes a `message` prop).
276
+
277
+ Exposed methods (via template ref): `submit()`, `reset()`.
278
+
279
+ Notable built-in behavior: on submit, `FormContainer` converts any Persian/Arabic-Indic digits present in the form's values to plain English digits before sending the request — handy for numeric fields typed with a Persian keyboard.
280
+
281
+ ### Field naming & binding
282
+
283
+ Every field component takes a `name` prop. As long as it lives inside a `<FormContainer>` (or any component that injects a `form`), it automatically reads/writes `form[name]` — no manual `v-model` needed:
284
+
285
+ ```vue
286
+ <TextInput name="title" />
287
+ <!-- equivalent to manually doing -->
288
+ <input v-model="form.title" name="title" class="form-control">
289
+ ```
290
+
291
+ Validation errors are read from `form.errors[name]` and applied as Bootstrap's `is-invalid` class automatically.
292
+
293
+ ### Grouped / repeated fields — `GroupControl`
294
+
295
+ `<GroupControl name="...">` lets a *block* of fields write into a nested/indexed slice of the form data instead of the top level — useful for repeating rows (e.g. multiple bid items, multiple contacts, etc.).
296
+
297
+ Each `<GroupControl>` instance figures out its own index (`groupID`) based on its position among sibling `.form-control-group` blocks, so the typical pattern is to repeat the **whole** `<GroupControl>` with `v-for`:
298
+
299
+ ```vue
300
+ <div v-for="(row, index) in rows" :key="index">
301
+ <GroupControl name="bids">
302
+ <TextInput name="title" />
303
+ <AmountInput name="price" />
304
+ </GroupControl>
305
+ </div>
306
+ ```
307
+
308
+ This produces `form.bids[0].title`, `form.bids[0].price`, `form.bids[1].title`, etc.
309
+
310
+ `MultiQuantityInput` (documented below) uses a single `GroupControl` to collect a *map* of quantities (`form.tickets.adult`, `form.tickets.child`, …) instead of a repeated list — see its own example for that variant.
311
+
312
+ ### Validation & error display
313
+
314
+ `FormContainer` renders a default Bootstrap `Alert` listing every message in `form.errors` (replaceable via the `errors` slot), and every field adds `is-invalid` automatically when `form.errors[name]` exists. You don't need to render error text per-field unless you want to — Bootstrap will show `.invalid-feedback` siblings if you add them yourself.
315
+
316
+ ### Element IDs
317
+
318
+ `form.getID(field)` (available on the injected `form`) builds a unique, collision-free `id` attribute for fields, taking the surrounding `<FormContainer>` id and any `GroupControl` into account. Components that render a real `<label for="">`/`<input id="">` pair (e.g. `TextInput`, `CheckboxInput`) use this automatically.
319
+
320
+ ---
321
+
322
+ ## Component Reference
323
+
324
+ ### FormContainer
325
+
326
+ See [Core Concepts](#formcontainer-and-the-injected-form) above for the full prop/event/slot table.
327
+
328
+ ### FormLabel
329
+
330
+ Simple `<label>` wrapper that appends a red `*` when `required` is set.
331
+
332
+ ```vue
333
+ <FormLabel required>Email address</FormLabel>
334
+ ```
335
+
336
+ | Prop | Type | Default |
337
+ |---|---|---|
338
+ | `required` | Boolean | `false` |
339
+
340
+ Slot: default — label text.
341
+
342
+ ### GroupControl
343
+
344
+ See [Grouped / repeated fields](#grouped--repeated-fields--groupcontrol) above.
345
+
346
+ | Prop | Type | Required |
347
+ |---|---|---|
348
+ | `name` | String | yes |
349
+
350
+ ### TextInput
351
+
352
+ The base text field. Most other "shortcut" inputs (`EmailInput`, `PasswordInput`, `MobileInput`) are thin wrappers around this component.
353
+
354
+ ```vue
355
+ <TextInput name="full_name" />
356
+ ```
357
+
358
+ | Prop | Type | Required |
359
+ |---|---|---|
360
+ | `name` | String | yes |
361
+
362
+ Renders a plain `<input type="text" class="form-control">` bound to `form[name]`.
363
+
364
+ ### TextAreaInput
365
+
366
+ Same binding pattern as `TextInput`, renders a `<textarea class="form-control">`.
367
+
368
+ ```vue
369
+ <TextAreaInput name="description" />
370
+ ```
371
+
372
+ | Prop | Type | Required |
373
+ |---|---|---|
374
+ | `name` | String | yes |
375
+
376
+ ### EmailInput
377
+
378
+ Thin wrapper around `TextInput` (`type="email"`, Persian placeholder "ایمیل خود را وارد کنید").
379
+
380
+ ```vue
381
+ <EmailInput name="email" />
382
+ ```
383
+
384
+ > **Note:** see [Known Limitations](#known-limitations) — the `name` prop on this specific wrapper is not declared correctly in the current source, so passing a custom `name` may not bind to the form data as expected. If that affects you, use `<TextInput name="..." type="email" />` directly instead.
385
+
386
+ ### PasswordInput
387
+
388
+ Thin wrapper around `TextInput` (`type="password"`, Persian placeholder "گذرواژه خود را وارد کنید").
389
+
390
+ ```vue
391
+ <PasswordInput name="password" />
392
+ ```
393
+
394
+ | Prop | Type | Default |
395
+ |---|---|---|
396
+ | `name` | String | `'password'` |
397
+
398
+ ### MobileInput
399
+
400
+ Thin wrapper around `TextInput` (`type="tel"`, Persian placeholder "موبایل خود را وارد کنید").
401
+
402
+ ```vue
403
+ <MobileInput name="mobile" />
404
+ ```
405
+
406
+ | Prop | Type | Default |
407
+ |---|---|---|
408
+ | `name` | String | `'mobile'` |
409
+
410
+ ### TelInput
411
+
412
+ Full international phone input powered by the **external package `vue-tel-input`**. Defaults to Iran (`ir`) with a preferred-country list (`ir`, `us`, `tr`, `ca`) and a searchable country dropdown.
413
+
414
+ ```vue
415
+ <TelInput name="phone" placeholder="912 345 6789" />
416
+ ```
417
+
418
+ | Prop | Type | Default |
419
+ |---|---|---|
420
+ | `name` | String | `'email'` (see [Known Limitations](#known-limitations)) |
421
+ | `placeHolder` | String | `'000 000 0000'` |
422
+
423
+ Since this wraps `vue-tel-input`, all of that package's own configuration (locales, validation rules, dial-code formatting, flags, styling, etc.) can be controlled by following [vue-tel-input's documentation](https://www.npmjs.com/package/vue-tel-input) and adjusting the source if you need options beyond what's hard-coded here (`mode`, `defaultCountry`, `preferredCountries`, `dropdownOptions`).
424
+
425
+ ### AmountInput
426
+
427
+ Numeric input with thousands-separator masking (via **external package `maska`** — see [Global Setup](#v-maska-directive)) and a trailing unit label.
428
+
429
+ ```vue
430
+ <AmountInput name="price" unit="تومان" />
431
+ ```
432
+
433
+ | Prop | Type | Default |
434
+ |---|---|---|
435
+ | `name` | String | required |
436
+ | `required` | Boolean | `false` |
437
+ | `disabled` | Boolean | `false` |
438
+ | `readonly` | Boolean | `false` |
439
+ | `placeholder` | String | `'عدد را وارد کنید'` |
440
+ | `unit` | String | `'عدد'` |
441
+
442
+ Slot: `suffix` — extra content appended after the unit label (inside the Bootstrap `InputGroup`).
443
+
444
+ Requires the `v-maska` directive and `$number.toEnglish()` global helper — see [Global Setup](#global-setup-required-helpers).
445
+
446
+ ### QuantityInput
447
+
448
+ Stepper-style numeric input (`+` / `-` buttons) with the same masking as `AmountInput`.
449
+
450
+ ```vue
451
+ <QuantityInput name="qty" :min="1" :max="10" unit="عدد" />
452
+ ```
453
+
454
+ | Prop | Type | Default |
455
+ |---|---|---|
456
+ | `name` | String | required |
457
+ | `required` | Boolean | `false` |
458
+ | `disabled` | Boolean | `false` |
459
+ | `readonly` | Boolean | `false` |
460
+ | `unit` | String | `'عدد'` |
461
+ | `min` | Number | `0` |
462
+ | `max` | Number | `null` |
463
+
464
+ Slot: `suffix`.
465
+
466
+ Also requires the `v-maska` directive and `$number.toEnglish()` — see [Global Setup](#global-setup-required-helpers).
467
+
468
+ ### MultiQuantityInput
469
+
470
+ A dropdown of multiple `QuantityInput` rows (e.g. "2 adults, 1 child") that collapses into a single summary button. Internally wraps its options in one `GroupControl`, so the result is stored as a map: `form[name][optionKey]`.
471
+
472
+ ```vue
473
+ <MultiQuantityInput
474
+ name="tickets"
475
+ unit="نفر"
476
+ :options="[
477
+ { name: 'بزرگسال', min: 1, max: 10 }, // key: 0
478
+ { name: 'کودک', min: 0, max: 10 }, // key: 1
479
+ ]"
480
+ />
481
+ ```
482
+
483
+ | Prop | Type | Default | Description |
484
+ |---|---|---|---|
485
+ | `name` | String | required | |
486
+ | `options` | Array | required | Each item can be a plain string or `{ name, min, max }`. The array index becomes the data key. |
487
+ | `required` | Boolean | `false` | |
488
+ | `disabled` | Boolean | `false` | |
489
+ | `readonly` | Boolean | `false` | |
490
+ | `max` | Number | `null` | Fallback max applied to options without their own `max`. |
491
+ | `totalMax` | Number | `null` | (declared, not currently enforced in the template logic) |
492
+ | `min` | Number | `0` | Fallback min applied to options without their own `min`. |
493
+ | `totalMin` | Number | `null` | (declared, not currently enforced in the template logic) |
494
+ | `unit` | String | `'Number'` | Label shown on the collapsed summary button. |
495
+
496
+ ### CheckboxInput
497
+
498
+ Single checkbox/radio bound through the same `form`/`group` injection pattern as text fields.
499
+
500
+ ```vue
501
+ <CheckboxInput name="accept_terms" value="yes">I agree to the terms</CheckboxInput>
502
+ ```
503
+
504
+ | Prop | Type | Default |
505
+ |---|---|---|
506
+ | `name` | String | required |
507
+ | `id` | String | `''` |
508
+ | `value` | String / Number | `'yes'` |
509
+ | `type` | String | `'checkbox'` (can be set to `'radio'`) |
510
+
511
+ Event: `change`. Slot: default — label text.
512
+
513
+ To build a checkbox/radio **group**, repeat the component with the same `name` and different `value`s; bind the initial form value to an array for multi-select checkboxes, or a scalar for radios.
514
+
515
+ ### CheckboxButtonInput
516
+
517
+ Same idea as `CheckboxInput` but styled as a Bootstrap "button checkbox/radio" (`.btn-check` + label) instead of a native checkbox UI.
518
+
519
+ ```vue
520
+ <CheckboxButtonInput name="plan" value="monthly">Monthly</CheckboxButtonInput>
521
+ <CheckboxButtonInput name="plan" value="yearly">Yearly</CheckboxButtonInput>
522
+ ```
523
+
524
+ | Prop | Type | Default |
525
+ |---|---|---|
526
+ | `name` | String | required |
527
+ | `id` | String | `''` |
528
+ | `value` | String | `'yes'` |
529
+ | `type` | String | `'radio'` |
530
+
531
+ Event: `change`. Wrap the rendered `<label>` in your own `.btn-group`/`.btn` classes for the typical Bootstrap button-group look.
532
+
533
+ ### CheckboxToggle
534
+
535
+ A larger, card-style toggle (background highlight when checked) — good for plan pickers, add-on selectors, etc.
536
+
537
+ ```vue
538
+ <CheckboxToggle name="addons" value="extra_luggage">Extra luggage</CheckboxToggle>
539
+ ```
540
+
541
+ | Prop | Type | Default |
542
+ |---|---|---|
543
+ | `name` | String | required |
544
+ | `id` | String | `''` |
545
+ | `value` | String / Number | `'yes'` |
546
+ | `type` | String | `'checkbox'` |
547
+ | `hideInput` | Boolean | `false` — visually hides the native input while keeping the toggle clickable. |
548
+
549
+ Event: `change`.
550
+
551
+ ### Select2Input
552
+
553
+ Searchable dropdown powered by the **external package `choices.js`**, with optional remote/async search.
554
+
555
+ ```vue
556
+ <Select2Input
557
+ name="category_id"
558
+ :options="categories"
559
+ label="title"
560
+ placeholder="Select a category"
561
+ search-enabled
562
+ />
563
+
564
+ <!-- Remote search -->
565
+ <Select2Input
566
+ name="user_id"
567
+ :search="{ url: '/api/users/search' }"
568
+ placeholder="Search a user..."
569
+ />
570
+ ```
571
+
572
+ | Prop | Type | Default | Description |
573
+ |---|---|---|---|
574
+ | `name` | String | required | |
575
+ | `options` | Array | — | Array of objects (or plain strings/numbers). |
576
+ | `label` | String | `null` | Object field used as the display label. Falls back to `name` / `label` / `value`. |
577
+ | `placeholder` | String | `'Click to choice'` | |
578
+ | `searchPlaceholder` | String | `'Type for search...'` | |
579
+ | `multiple` | Boolean | `false` | |
580
+ | `required` | Boolean | `false` | |
581
+ | `config` | Object | `{}` | Merged into `choices.js`'s own config — use this for any Choices.js option not exposed above. |
582
+ | `locale` | String | `'en'` | Set to `'fa'` (or rely on auto-detection from `document.dir === 'rtl'`) for built-in Persian UI strings. |
583
+ | `searchEnabled` | Boolean | `false` | Enables local in-list searching. Automatically `true` when `search.url` is set. |
584
+ | `hideDropdown` | Boolean | `false` | |
585
+ | `search` | Object | `{ url: null }` | When `url` is set, typing triggers a debounced `POST` request (`?query=...`) and replaces the option list with the JSON response. |
586
+
587
+ Events: `update:modelValue`, `search`, `searching`, `change`, `selected`.
588
+
589
+ > **Note:** the prop named `key` (meant to pick which object field is used as the option *value*) cannot actually be set from a template, because Vue reserves `:key` for its own list-rendering mechanism. The default value-resolution (`id` → `name` → `label` → `value`) is used instead. See [Known Limitations](#known-limitations).
590
+
591
+ Since this wraps Choices.js, any configuration option supported by that library can be passed through the `config` prop — see [Choices.js documentation](https://github.com/Choices-js/Choices) for the full list (custom templates, callback hooks, RTL, etc.).
592
+
593
+ ### PersianDatePickerInput
594
+
595
+ Persian (Jalali) date/time picker powered by the **external package `vue3-persian-datetime-picker`**.
596
+
597
+ ```vue
598
+ <PersianDatePickerInput name="birth_date" />
599
+ <PersianDatePickerInput name="appointment" calendar="datetime" view="datetime" range />
600
+ ```
601
+
602
+ | Prop | Type | Default |
603
+ |---|---|---|
604
+ | `name` | String | required |
605
+ | `calendar` | String | `'date'` |
606
+ | `view` | String | `'date'` |
607
+ | `min` | String | — |
608
+ | `max` | String | — |
609
+ | `range` | Boolean | `false` |
610
+ | `locale` | String | `'fa'` |
611
+ | `format` | String | `'jYYYY-jMM-jDD'` |
612
+ | `inputFormat` | String | `null` (falls back to `format`) |
613
+ | `placeholder` | String | `'انتخاب تاریخ'` |
614
+
615
+ Event: `change`. Method exposed: `clear()`.
616
+
617
+ Any option supported by `vue3-persian-datetime-picker` itself (Gregorian mode, time steps, custom themes, etc.) can be used by following [that package's own documentation](https://www.npmjs.com/package/vue3-persian-datetime-picker) and extending the source where needed.
618
+
619
+ ### RangeSliderInput
620
+
621
+ Slider input powered by the **external package `svelte-range-slider-pips`**.
622
+
623
+ ```vue
624
+ <RangeSliderInput name="budget" :min="0" :max="1000" :step="10" />
625
+ <RangeSliderInput name="price_range" :min="0" :max="1000" range />
626
+ ```
627
+
628
+ | Prop | Type | Default |
629
+ |---|---|---|
630
+ | `name` | String | `null` |
631
+ | `modelValue` | Number | `0` |
632
+ | `min` | Number | `1` |
633
+ | `max` | Number | `100` |
634
+ | `step` | Number | `1` |
635
+ | `readonly` | Boolean | `false` |
636
+ | `range` | Boolean | `false` — emits `[min, max]` instead of a single value. |
637
+ | `options` | Object | `{}` | Passed straight through to `svelte-range-slider-pips` — use this for pips formatting, colors, springs, etc. See [that package's docs](https://github.com/simeydotme/svelte-range-slider-pips) for everything it supports. |
638
+
639
+ Events: `update:modelValue`, `change`.
640
+
641
+ ### StarRatingInput
642
+
643
+ Hover/click star rating, no external dependency.
644
+
645
+ ```vue
646
+ <StarRatingInput name="rating" :max-stars="5" />
647
+ ```
648
+
649
+ | Prop | Type | Default |
650
+ |---|---|---|
651
+ | `name` | String | `null` |
652
+ | `modelValue` | Number | `0` |
653
+ | `maxStars` | Number | `5` |
654
+ | `precision` | Number | `2` |
655
+ | `showValue` | Boolean | `true` |
656
+ | `readonly` | Boolean | `false` |
657
+
658
+ Event: `update:modelValue`.
659
+
660
+ ### CaptchaInput
661
+
662
+ Image captcha field with a refresh button. Expects a backend endpoint that returns a captcha **image** for `GET` and re-rolls automatically whenever the form finishes processing (e.g. after a failed submit).
663
+
664
+ ```vue
665
+ <CaptchaInput url="/captcha/default" />
666
+ ```
667
+
668
+ | Prop | Type | Default |
669
+ |---|---|---|
670
+ | `name` | String | `'captcha'` |
671
+ | `url` | String | `'/captcha/default'` |
672
+ | `required` | Boolean | `false` |
673
+ | `placeholder` | String | `'کد امنیتی روبرو را وارد کنید'` |
674
+
675
+ Must be used inside a `<FormContainer>` (it injects `form` directly, without a fallback). A Persian comment in the source notes a ready-to-pair Laravel captcha endpoint is expected at `url`.
676
+
677
+ ### EditorInput
678
+
679
+ Rich-text editor powered by the **external package `@tinymce/tinymce-vue`** (TinyMCE).
680
+
681
+ ```vue
682
+ <EditorInput name="body" :options="{ height: 400 }" />
683
+ ```
684
+
685
+ | Prop | Type | Default |
686
+ |---|---|---|
687
+ | `name` | String | required |
688
+ | `placeholder` | String | `''` |
689
+ | `disabled` | Boolean | `false` |
690
+ | `options` | Object | `{}` — merged into TinyMCE's own `init` config. |
691
+
692
+ Event: `update:modelValue`. Exposed: `editor()` — returns the underlying TinyMCE editor instance.
693
+
694
+ TinyMCE typically needs either a hosted script/API key or a self-hosted bundle — refer to [TinyMCE's Vue integration docs](https://www.tiny.cloud/docs/tinymce/latest/vue-cloud/) for licensing/configuration details and pass any extra option (toolbar, plugins, content_css, license_key, etc.) through the `options` prop.
695
+
696
+ ### LocationInput
697
+
698
+ Interactive map picker (click or drag a marker) powered by **external packages `@vue-leaflet/vue-leaflet` and `leaflet`**, using OpenStreetMap tiles.
699
+
700
+ ```vue
701
+ <LocationInput name="location" />
702
+ ```
703
+
704
+ | Prop | Type | Default |
705
+ |---|---|---|
706
+ | `name` | String | `'location'` |
707
+ | `disabled` | Boolean / String | `false` |
708
+ | `readonly` | Boolean / String | `false` |
709
+ | `modelValue` | Object | `{ lat, lng }` |
710
+
711
+ Event: `update:modelValue`. Stores `{ lat, lng }` into `form[name]`.
712
+
713
+ Since this wraps Vue-Leaflet, any Leaflet/Vue-Leaflet feature (custom tile providers, zoom controls, extra layers) can be added by following [Vue-Leaflet's documentation](https://vue-leaflet.github.io/vue-leaflet/) and extending the component's `<l-map>` template if you need more than a single draggable marker.
714
+
715
+ ### FileInput
716
+
717
+ Single/multiple file uploader using `axios` (global `window.axios`) with a per-file progress bar, retry, and delete.
718
+
719
+ ```vue
720
+ <FileInput name="avatar" endpoint="/upload" />
721
+ <FileInput name="gallery" endpoint="/upload" multiple />
722
+ ```
723
+
724
+ | Prop | Type | Default |
725
+ |---|---|---|
726
+ | `name` | String | required |
727
+ | `multiple` | Boolean | `false` |
728
+ | `endpoint` | String | `'/upload'` |
729
+
730
+ Event: `update:modelValue`. See [Upload Endpoint Contract](#upload-endpoint-contract-backend).
731
+
732
+ ### SimpleUploader
733
+
734
+ Functionally identical to `FileInput`, but uses the native `fetch` API instead of `axios` — use this one if you don't have `window.axios` configured globally.
735
+
736
+ ```vue
737
+ <SimpleUploader name="avatar" endpoint="/upload" />
738
+ ```
739
+
740
+ | Prop | Type | Default |
741
+ |---|---|---|
742
+ | `name` | String | required |
743
+ | `multiple` | Boolean | `false` |
744
+ | `endpoint` | String | `'/upload'` |
745
+
746
+ ### DropzoneInput
747
+
748
+ Drag-and-drop uploader powered by the **external package `dropzone`** (Dropzone.js).
749
+
750
+ ```vue
751
+ <DropzoneInput name="documents" url="/upload" multiple :options="{ maxFiles: 5 }" />
752
+ ```
753
+
754
+ | Prop | Type | Default |
755
+ |---|---|---|
756
+ | `name` | String | required |
757
+ | `multiple` | Boolean | `false` |
758
+ | `url` | String | `'/upload'` |
759
+ | `options` | Object | `{}` — merged into Dropzone's own constructor options. |
760
+
761
+ Event: `update:modelValue`.
762
+
763
+ Since this wraps Dropzone.js directly, any Dropzone option (`acceptedFiles`, `maxFilesize`, `dictDefaultMessage`, thumbnails, custom previews, etc.) can be passed through the `options` prop — see [Dropzone.js's documentation](https://docs.dropzone.dev/) for the full list.
764
+
765
+ ### UppyInput
766
+
767
+ The most feature-rich uploader, powered by the **external package family `@uppy/core`, `@uppy/vue`, `@uppy/xhr-upload`** (the latter two are bundled; `@uppy/audio`, `@uppy/dashboard`, `@uppy/drag-drop`, and `@uppy/locales` are listed as dependencies for you to opt into via the slot below).
768
+
769
+ Default usage renders Uppy's built-in `Dropzone` + `FilesList`:
770
+
771
+ ```vue
772
+ <UppyInput
773
+ name="attachments"
774
+ url="/upload"
775
+ multiple
776
+ :config="{ restrictions: { maxFileSize: 5 * 1024 * 1024, allowedFileTypes: ['.jpg', '.png', '.pdf'] } }"
777
+ />
778
+ ```
779
+
780
+ | Prop | Type | Default | Description |
781
+ |---|---|---|---|
782
+ | `name` | String | required | |
783
+ | `multiple` | Boolean | `false` | |
784
+ | `useXHR` | Boolean | `true` | Automatically registers `@uppy/xhr-upload` pointed at `url`. Set `false` if you want to register your own uploader plugin (e.g. AWS S3, Tus) on the exposed `uppy` instance instead. |
785
+ | `XHRConfig` | Object | `{}` | Merged into `@uppy/xhr-upload`'s own config (headers, formData, fieldName, etc.). |
786
+ | `url` | String | `'/upload'` | |
787
+ | `config` | Object | `{}` | Merged into Uppy's core constructor options (`id`, `autoProceed`, `restrictions`, `locale`, etc.). |
788
+ | `errorHandler` | Function | `null` | Custom error display/handling instead of the built-in inline error banner. |
789
+ | `showRestrictionCaption` | Boolean | `true` | Shows an auto-generated Persian caption describing the configured file-size/type/count restrictions. |
790
+
791
+ Events: `update:modelValue`, `file-added`, `file-removed`, `beforeUpload`, `progress`, `upload`, `upload-progress`, `upload-error`, `upload-success`, `upload-pause`, `complete`, `error`, `upload-retry`, `upload-stalled`, `retry-all`, `cancel-all`, `restriction-failed`.
792
+
793
+ Slot: default — scoped with `{ uppy }`, the raw Uppy instance, letting you completely replace the default Dropzone/FilesList UI with your own, or register extra Uppy plugins:
794
+
795
+ ```vue
796
+ <UppyInput name="cover" url="/upload" v-slot="{ uppy }">
797
+ <!-- bring your own plugins, e.g. @uppy/dashboard, @uppy/audio, @uppy/drag-drop -->
798
+ </UppyInput>
799
+ ```
800
+
801
+ Because the file restriction caption, error banners, and the `Dropzone`/`FilesList` building blocks all come straight from Uppy, refer to [Uppy's documentation](https://uppy.io/docs/uppy/) for every available core/plugin option (restrictions, locales, custom plugins like Dashboard/Audio/Webcam/DragDrop, etc.) — anything supported there can be passed through `config`, `XHRConfig`, or registered manually on the exposed `uppy` instance.
802
+
803
+ ### SubmitButton
804
+
805
+ Submit button wired to the injected `form`'s `processing`/`uploading` state, showing a spinner automatically.
806
+
807
+ ```vue
808
+ <SubmitButton />
809
+ <SubmitButton>Save changes</SubmitButton>
810
+ ```
811
+
812
+ | Prop | Type | Default |
813
+ |---|---|---|
814
+ | `disabled` | Boolean | `false` |
815
+
816
+ Slots:
817
+ - default — scoped with `{ form }`. Defaults to "تایید و ثبت اطلاعات" (Persian for "Confirm and submit").
818
+ - `progress` — scoped, defaults to an upload percentage (`form.uploading`%) while a file upload is in progress.
819
+
820
+ Must be used inside a `<FormContainer>` (injects `form` directly).
821
+
822
+ ---
823
+
824
+ ## Upload Endpoint Contract (backend)
825
+
826
+ `FileInput`, `SimpleUploader`, `DropzoneInput`, and `UppyInput` all expect a similar JSON contract from your backend:
827
+
828
+ - **Upload (`POST` to the configured endpoint/url):** respond with JSON describing the stored file. At minimum a `path` field, e.g. `{ "path": "uploads/abc123.jpg" }`. (`DropzoneInput` also accepts the raw response if there's no `.data` wrapper; `UppyInput` reads from `response.body`.)
829
+ - **Delete (`DELETE` to the same endpoint/url):** the components send the stored file's data (e.g. `{ "path": "..." }`) as the request body so the backend can remove it from storage.
830
+
831
+ The original package README points to a companion Laravel package, **`novinvision/simple-uploader`**, for implementing this endpoint server-side — use it if it's available to you, or implement an equivalent controller.
832
+
833
+ ---
834
+
835
+ ## Styling & Theming
836
+
837
+ All components are plain Bootstrap 5 markup/classes (`.form-control`, `.input-group`, `.form-check`, `.btn`, etc.) plus a handful of custom classes (`.form-check-toggle`, `.star-rating`, `.multi-quantity-input`, `.file-input-uploader`, `.uppy-input-area`, …) shipped in `dist/style.css`. Most custom styling reads Bootstrap CSS variables (`--bs-primary`, `--bs-border-radius`, `--bs-body-bg`, etc.), so if your project already themes Bootstrap via CSS variables, these components will inherit that theme automatically. Persian/Farsi numeral display uses a `.fanum` utility class throughout — make sure your global stylesheet defines the font-feature/font-family rules you want for it (it's used as a styling hook, not generated by this package).
838
+
839
+ ---
840
+
841
+ ## TypeScript
842
+
843
+ Type declarations are provided in `index.d.ts` (most components are typed loosely as `DefineComponent<{}, {}, any>` except for the ones with richer prop/event typing: `CheckboxButtonInput`, `EditorInput`, `UppyInput`, `FormContainer`, `LocationInput`, `Select2Input`, `SubmitButton`, `RangeSliderInput`). Import as usual:
844
+
845
+ ```ts
846
+ import { TextInput, FormContainer } from 'inertia-bootstrap-forms';
847
+ ```
848
+
849
+ ---
42
850
 
43
- If you need to upload files using the `FileInput` component in Laravel and manage them server-side, use our prepared package:
851
+ ## Known Limitations
44
852
 
45
- **novinvision/simple-uploader**
853
+ A few quirks in the current source worth knowing about before you rely on certain props:
46
854
 
855
+ - **`EmailInput`'s `name` prop:** the component's `props` block doesn't actually declare a `name` prop (it declares an unrelated `FileInput` prop instead), so passing a custom `name="..."` may not bind correctly to the form. If you need a non-default field name for an email field, use `<TextInput name="..." type="email" placeholder="..." />` directly.
856
+ - **`TelInput`'s default `name`:** defaults to `'email'` rather than something like `'mobile'`/`'phone'` — always pass an explicit `name` prop to avoid surprises.
857
+ - **`Select2Input`'s `key` prop:** intended to let you choose which object field is used as an option's value, but it can't actually be set from a template, since Vue reserves `:key` for its own list-rendering/diffing mechanism. In practice, value resolution always falls back to `id` → `name` → `label` → `value` (or the `label` prop, for the display text).
858
+ - **`MultiQuantityInput`'s `totalMax`/`totalMin` props:** declared, but not currently enforced anywhere in the component's logic — treat them as reserved for future use rather than working constraints.
859
+ - Several components are typed `DefineComponent<{}, {}, any>` in `index.d.ts`, i.e. without real prop typing — rely on this README (or the `.vue` source) rather than IDE autocomplete for the full prop list of those components.
package/index.d.ts CHANGED
@@ -269,7 +269,35 @@ export const LocationInput: DefineComponent<{
269
269
  export const MobileInput: DefineComponent<{}, {}, any>;
270
270
  export const MultiQuantityInput: DefineComponent<{}, {}, any>;
271
271
  export const PasswordInput: DefineComponent<{}, {}, any>;
272
- export const PersianDatePickerInput: DefineComponent<{}, {}, any>;
272
+ export const PersianDatePickerInput: DefineComponent<{
273
+ name: {
274
+ type: String,
275
+ required: true,
276
+ },
277
+ calendar: {
278
+ type: String,
279
+ default: 'date',
280
+ },
281
+ view: {
282
+ type: String,
283
+ default: 'date',
284
+ },
285
+ min: String,
286
+ max: String,
287
+ range: Boolean,
288
+ locale: {
289
+ default: 'fa',
290
+ },
291
+ format: {
292
+ type: String,
293
+ default: 'jYYYY-jMM-jDD',
294
+ },
295
+ inputFormat: {
296
+ type: String,
297
+ default: null,
298
+ },
299
+ placeholder: String,
300
+ }, {}, any>;
273
301
  export const QuantityInput: DefineComponent<{}, {}, any>;
274
302
  export const Select2Input: DefineComponent<{
275
303
  name: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inertia-bootstrap-forms",
3
- "version": "1.0.101",
3
+ "version": "1.0.103",
4
4
  "description": "Create bootstrap forms with inertia and twitter bootstrap",
5
5
  "main": "dist/inertia-bootstrap-forms.cjs.js",
6
6
  "module": "dist/inertia-bootstrap-forms.es.js",