inertia-bootstrap-forms 3.0.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fa.md +86 -6
- package/README.md +95 -8
- package/dist/chunks/UppyInput-Dt8CPfgC.js +210 -0
- package/dist/chunks/UppyInput-ldc834tZ.cjs +1 -0
- package/dist/chunks/_plugin-vue_export-helper-13TPlHFF.js +81 -0
- package/dist/chunks/_plugin-vue_export-helper-BHyUve4F.cjs +1 -0
- package/dist/chunks/http-CDPNmbjF.cjs +1 -0
- package/dist/chunks/http-DV3dRBe5.js +158 -0
- package/dist/country-codes.cjs +1 -0
- package/dist/country-codes.js +245 -0
- package/dist/dropzone.cjs +1 -0
- package/dist/dropzone.js +81 -0
- package/dist/editor.cjs +1 -0
- package/dist/editor.js +52 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +3128 -0
- package/dist/location.cjs +1 -0
- package/dist/location.js +84 -0
- package/dist/persian-date.cjs +1 -0
- package/dist/persian-date.js +73 -0
- package/dist/tel.cjs +1 -0
- package/dist/tel.js +85 -0
- package/dist/uppy-dashboard.cjs +1 -0
- package/dist/uppy-dashboard.js +31 -0
- package/dist/uppy.cjs +1 -0
- package/dist/uppy.js +4 -0
- package/index.d.ts +44 -30
- package/package.json +99 -16
- package/src/CheckboxToggle.vue +1 -1
- package/src/ComboboxInput.vue +495 -496
- package/src/PasswordInput.vue +124 -123
- package/src/StarRatingInput.vue +1 -1
- package/src/UppyDashboardInput.vue +45 -0
- package/src/UppyInput.vue +36 -3
- package/src/VoiceRecorderInput.vue +657 -0
- package/src/entries/country-codes.js +1 -0
- package/src/entries/dropzone.js +1 -0
- package/src/entries/editor.js +1 -0
- package/src/entries/location.js +1 -0
- package/src/entries/persian-date.js +1 -0
- package/src/entries/tel.js +1 -0
- package/src/entries/uppy-dashboard.js +1 -0
- package/src/entries/uppy.js +1 -0
- package/src/index.js +3 -19
- package/types/country-codes.d.ts +1 -0
- package/types/dropzone.d.ts +2 -0
- package/types/editor.d.ts +2 -0
- package/types/location.d.ts +2 -0
- package/types/persian-date.d.ts +2 -0
- package/types/tel.d.ts +2 -0
- package/types/uppy-dashboard.d.ts +12 -0
- package/types/uppy.d.ts +10 -0
- package/dist/inertia-bootstrap-forms.cjs.js +0 -1
- package/dist/inertia-bootstrap-forms.es.js +0 -3536
- package/src/RangeSliderInput.vue +0 -103
- package/src/Select2Input.vue +0 -251
package/README.fa.md
CHANGED
|
@@ -63,19 +63,38 @@
|
|
|
63
63
|
| `@inertiajs/vue3` ≥ 2.0 | `FormContainer` از `useForm()` استفاده میکند |
|
|
64
64
|
| `bootstrap` ^6.0.0-alpha.1 | **CSS** الزامی است. پلاگینهای JS را خود پکیج در صورت نیاز بارگذاری میکند. |
|
|
65
65
|
| `@floating-ui/dom` | وابستگی منوهای Bootstrap 6 (برای Combobox و MultiQuantityInput) |
|
|
66
|
-
| `dropzone` ^6 | فقط برای `DropzoneInput` |
|
|
67
|
-
| `leaflet` | فقط برای `LocationInput` |
|
|
68
66
|
|
|
69
|
-
کتابخانههای جانبی
|
|
67
|
+
**هیچ چیز دیگری همراه این پکیج نصب نمیشود.** کتابخانههای سنگین جانبی *optional peer dependency* هستند؛ فقط اگر کامپوننت مربوطه را استفاده میکنید نصبشان کنید (بخش [کامپوننتهای اختیاری](#کامپوننتهای-اختیاری)).
|
|
70
68
|
|
|
71
69
|
## نصب
|
|
72
70
|
|
|
73
71
|
```bash
|
|
74
72
|
npm install inertia-bootstrap-forms bootstrap@next @floating-ui/dom
|
|
75
|
-
# اختیاری
|
|
76
|
-
npm install dropzone leaflet
|
|
77
73
|
```
|
|
78
74
|
|
|
75
|
+
### کامپوننتهای اختیاری
|
|
76
|
+
|
|
77
|
+
کامپوننتهایی که یک کتابخانهٔ سنگین را پوشش میدهند **entry جداگانه** دارند و کتابخانهشان **optional peer** است. entry اصلی هرگز به آنها اشاره نمیکند، پس اپلیکیشنی که از آنها استفاده نمیکند چیزی اضافه نصب یا bundle نمیکند.
|
|
78
|
+
|
|
79
|
+
| کامپوننت | import از | نصب | CSS برای 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` (Dashboard + دوربین + ضبط صدا) | `inertia-bootstrap-forms/uppy-dashboard` | سه مورد بالا + `npm i @uppy/dashboard@^5.1 @uppy/webcam@^5.1 @uppy/audio@^3.1` | `dist/style.min.css` از `@uppy/dashboard`، `@uppy/webcam` و `@uppy/audio` |
|
|
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` (داده) | `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
|
+
> همهٔ پکیجهای `@uppy/*` را روی یک major نگه دارید (`@uppy/core@5`): پلاگینها فقط با همان نمونهٔ `@uppy/core` که برایش ساخته شدهاند کار میکنند. دستور ساده `npm i @uppy/webcam` جدیدترین major را نصب میکند که به `@uppy/core@6` نیاز دارد.
|
|
97
|
+
|
|
79
98
|
### import استایلها در پروژه شما
|
|
80
99
|
|
|
81
100
|
پکیج هیچ CSS ای ندارد. بوتاسترپ 6 (CSS کامپایلشده یا Sass خودتان) و فقط برای ویجتهایی که استفاده میکنید CSS کتابخانههای جانبی را import کنید:
|
|
@@ -84,6 +103,7 @@ npm install dropzone leaflet
|
|
|
84
103
|
// resources/js/app.js
|
|
85
104
|
import 'bootstrap/dist/css/bootstrap.min.css'; // Bootstrap 6 (الزامی)
|
|
86
105
|
|
|
106
|
+
// فقط برای کامپوننتهای اختیاری که استفاده میکنید — جدول «کامپوننتهای اختیاری» را ببینید
|
|
87
107
|
import 'vue-tel-input/vue-tel-input.css'; // TelInput
|
|
88
108
|
import 'leaflet/dist/leaflet.css'; // LocationInput
|
|
89
109
|
import 'dropzone/dist/basic.css'; // DropzoneInput
|
|
@@ -103,7 +123,7 @@ configureBootstrap({ Combobox, Chips, OtpInput, Range, Menu });
|
|
|
103
123
|
|
|
104
124
|
### ثبت کامپوننتها
|
|
105
125
|
|
|
106
|
-
هر کامپوننتی را که لازم دارید import کنید، یا با نصب پلاگین
|
|
126
|
+
هر کامپوننتی را که لازم دارید import کنید، یا با نصب پلاگین همهٔ کامپوننتهای **داخلی (سبک)** را سراسری ثبت کنید. کامپوننتهای [entryهای اختیاری](#کامپوننتهای-اختیاری) را خودتان ثبت کنید (`app.component('UppyInput', UppyInput)`):
|
|
107
127
|
|
|
108
128
|
```js
|
|
109
129
|
import InertiaBootstrapForms from 'inertia-bootstrap-forms';
|
|
@@ -298,6 +318,9 @@ Slot ها: پیشفرض، `label`، `help`، `error`.
|
|
|
298
318
|
| `search` | `object` | `{ url: null }` | **جستجوی remote**: `{ url, method='POST', param='query', debounce=400, minChars=0, headers, resultsKey='data' }` |
|
|
299
319
|
| `clearable` | `boolean` | `false` | افزودن گزینهای برای پاک کردن انتخاب (تکانتخابی) |
|
|
300
320
|
| `clearText`، `noResultsText`، `loadingText`، `searchPlaceholder`، `selectedText` | `string` | i18n | `selectedText` از `{count}` پشتیبانی میکند |
|
|
321
|
+
| `showSelected` | `boolean` | `false` | فقط چندانتخابی: بهجای شمارنده «N مورد انتخاب شده»، خود گزینههای انتخابشده را نشان بده |
|
|
322
|
+
| `maxVisible` | `number` | `null` | همراه `showSelected`: اگر تعداد انتخابها بیشتر شد شمارنده نشان داده میشود |
|
|
323
|
+
| `selectedSeparator` | `string` | بر اساس زبان | جداکننده بین برچسبهای انتخابشده |
|
|
301
324
|
| `placement` | `string` | `'bottom-start'` | placement کتابخانه Floating UI |
|
|
302
325
|
| `size`، `hideDropdown`، `searchNormalize`، `locale` | | | |
|
|
303
326
|
|
|
@@ -312,6 +335,18 @@ Event ها: `update:modelValue`، `change`، `selected` (گزینه/گزینه
|
|
|
312
335
|
<ComboboxInput name="tags" multiple search-enabled :options="tags" />
|
|
313
336
|
```
|
|
314
337
|
|
|
338
|
+
**Slot ها** — `#option` ظاهر هر گزینه منو و `#selection` ظاهر مقدار نمایشدادهشده روی دکمه را مشخص میکند (هر دو `option`، `label`، `description`، `value` میگیرند؛ `#option` علاوه بر آن `selected` و `disabled`):
|
|
339
|
+
|
|
340
|
+
```vue
|
|
341
|
+
<ComboboxInput name="plan" :options="plans">
|
|
342
|
+
<template #option="{ option, label, description }">
|
|
343
|
+
<span class="d-flex align-items-center gap-2"><Icon :icon="option.icon" /><strong>{{ label }}</strong></span>
|
|
344
|
+
<small class="fg-secondary">{{ description }}</small>
|
|
345
|
+
</template>
|
|
346
|
+
<template #selection="{ option, label }"><Icon :icon="option.icon" /> {{ label }}</template>
|
|
347
|
+
</ComboboxInput>
|
|
348
|
+
```
|
|
349
|
+
|
|
315
350
|
endpoint جستجو `?query=…` را دریافت میکند و باید آرایه JSON (یا `{ data: [] }`) برگرداند. کوکی `XSRF-TOKEN` خودکار ارسال میشود. گزینههای انتخابشده حتی اگر در آخرین نتایج نباشند برچسب خود را حفظ میکنند.
|
|
316
351
|
|
|
317
352
|
### `ChipsInput` (Chips بوتاسترپ 6)
|
|
@@ -370,6 +405,34 @@ Event ها: `update:modelValue`، `change`، `input`، `complete`، `focus`، `b
|
|
|
370
405
|
| `DropzoneInput` | `multiple`، `url`، `options`، `headers`؛ eventها: `ready`، `added`، `success`، `error`، `removed`، `complete` |
|
|
371
406
|
| `UppyInput` | `multiple`، `useXHR`، `XHRConfig`، `url`، `config`، `errorHandler`، `showRestrictionCaption`؛ همه eventهای Uppy دوباره emit میشوند |
|
|
372
407
|
|
|
408
|
+
¹ entry اختیاری — مسیر import و کتابخانهٔ لازم را در [کامپوننتهای اختیاری](#کامپوننتهای-اختیاری) ببینید.
|
|
409
|
+
|
|
410
|
+
#### `UppyDashboardInput` — دوربین و ضبط صدا
|
|
411
|
+
|
|
412
|
+
همان `UppyInput` با رابط Dashboard و پلاگینهای رسمی `@uppy/webcam` و `@uppy/audio`. همهٔ props و eventهای `UppyInput` اینجا هم کار میکنند.
|
|
413
|
+
|
|
414
|
+
```vue
|
|
415
|
+
<script setup>
|
|
416
|
+
import { UppyDashboardInput } from 'inertia-bootstrap-forms/uppy-dashboard';
|
|
417
|
+
</script>
|
|
418
|
+
|
|
419
|
+
<UppyDashboardInput name="media" webcam audio />
|
|
420
|
+
<UppyDashboardInput name="photo" :webcam="{ modes: ['picture'], mirror: true }" />
|
|
421
|
+
<UppyDashboardInput name="voice" :audio="{ showAudioSourceDropdown: true }"
|
|
422
|
+
:config="{ restrictions: { allowedFileTypes: ['audio/*'], maxNumberOfFiles: 1 } }"
|
|
423
|
+
:dashboard-props="{ height: 300 }" />
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
| Prop | توضیح |
|
|
427
|
+
|---|---|
|
|
428
|
+
| `webcam` | `true` یا [گزینههای `@uppy/webcam`](https://uppy.io/docs/webcam/) |
|
|
429
|
+
| `audio` | `true` یا [گزینههای `@uppy/audio`](https://uppy.io/docs/audio/) |
|
|
430
|
+
| `dashboardProps` | گزینههای Dashboard (`height`، `theme`، `note` و …) |
|
|
431
|
+
|
|
432
|
+
دوربین و میکروفون فقط روی **HTTPS** (یا `localhost`) کار میکنند. اگر نوع فایل را محدود میکنید، `image/*`، `video/*` و `audio/*` را در `restrictions.allowedFileTypes` مجاز کنید. فرمت فایل صوتی را مرورگر تعیین میکند.
|
|
433
|
+
|
|
434
|
+
خود `UppyInput` هم برای پلاگینهای سفارشی Uppy، propهای `plugins` (`[{ plugin, options: { id } }]`) و `dashboardComponent` را میپذیرد.
|
|
435
|
+
|
|
373
436
|
---
|
|
374
437
|
|
|
375
438
|
## قرارداد endpoint آپلود
|
|
@@ -444,6 +507,23 @@ const { model, inputId, isInvalid, isDisabled, emitChange } = useField(props, em
|
|
|
444
507
|
| `name` الزامی بود | اختیاری است — برای استفاده مستقل با `v-model` میتوان آن را نداد |
|
|
445
508
|
| پیشنیاز: CSS بوتاسترپ 5 | پیشنیاز: `bootstrap@^6.0.0-alpha.1` و `@floating-ui/dom` |
|
|
446
509
|
|
|
510
|
+
### مهاجرت از نسخه 3 به 4
|
|
511
|
+
|
|
512
|
+
نسخهٔ ۴ پکیج را تا حد ممکن سبک میکند: **جز peerهای خودتان چیزی نصب نمیشود**. کامپوننتهایی که کتابخانهٔ سنگین را پوشش میدهند به entry جداگانه رفتند (و کتابخانههایشان optional peer هستند):
|
|
513
|
+
|
|
514
|
+
```diff
|
|
515
|
+
- import { UppyInput, DropzoneInput, EditorInput, LocationInput, TelInput, PersianDatePickerInput, countryCodes } from 'inertia-bootstrap-forms';
|
|
516
|
+
+ import { UppyInput } from 'inertia-bootstrap-forms/uppy';
|
|
517
|
+
+ import { DropzoneInput } from 'inertia-bootstrap-forms/dropzone';
|
|
518
|
+
+ import { EditorInput } from 'inertia-bootstrap-forms/editor';
|
|
519
|
+
+ import { LocationInput } from 'inertia-bootstrap-forms/location';
|
|
520
|
+
+ import { TelInput } from 'inertia-bootstrap-forms/tel';
|
|
521
|
+
+ import { PersianDatePickerInput } from 'inertia-bootstrap-forms/persian-date';
|
|
522
|
+
+ import { countryCodes } from 'inertia-bootstrap-forms/country-codes';
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
کتابخانهٔ کامپوننتهایی را که استفاده میکنید نصب کنید ([جدول](#کامپوننتهای-اختیاری)). پلاگین سراسری دیگر آنها را ثبت نمیکند. propهای `webcam` و `audio` از `UppyInput` به `UppyDashboardInput` منتقل شدند.
|
|
526
|
+
|
|
447
527
|
## نکات و محدودیتها
|
|
448
528
|
|
|
449
529
|
* بوتاسترپ 6 در حال حاضر در مرحله **alpha** است؛ نام کلاسها و API پلاگینها ممکن است تا انتشار پایدار تغییر کند.
|
package/README.md
CHANGED
|
@@ -61,20 +61,41 @@ Built and maintained by **[Novin Vision](https://novinvision.com)** (نوین و
|
|
|
61
61
|
| `@inertiajs/vue3` ≥ 2.0 | `FormContainer` uses `useForm()` |
|
|
62
62
|
| `bootstrap` ^6.0.0-alpha.1 | **CSS** is required. The JS plugins are imported by this package on demand. |
|
|
63
63
|
| `@floating-ui/dom` | Peer dependency of Bootstrap 6 menus (needed by Combobox / MultiQuantityInput) |
|
|
64
|
-
| `dropzone` ^6 | Only for `DropzoneInput` |
|
|
65
|
-
| `leaflet` | Only for `LocationInput` |
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
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)).
|
|
69
67
|
|
|
70
68
|
## Installation
|
|
71
69
|
|
|
72
70
|
```bash
|
|
73
71
|
npm install inertia-bootstrap-forms bootstrap@next @floating-ui/dom
|
|
74
|
-
# optional
|
|
75
|
-
npm install dropzone leaflet
|
|
76
72
|
```
|
|
77
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
|
+
|
|
78
99
|
### Import the styles in your application
|
|
79
100
|
|
|
80
101
|
The package does not ship any CSS. Import Bootstrap 6 (compiled CSS or your own Sass build) and — only for the
|
|
@@ -84,6 +105,7 @@ widgets you use — the CSS of the third-party libraries:
|
|
|
84
105
|
// resources/js/app.js
|
|
85
106
|
import 'bootstrap/dist/css/bootstrap.min.css'; // Bootstrap 6 (required)
|
|
86
107
|
|
|
108
|
+
// only for the optional components you use — see the table in "Optional components"
|
|
87
109
|
import 'vue-tel-input/vue-tel-input.css'; // TelInput
|
|
88
110
|
import 'leaflet/dist/leaflet.css'; // LocationInput
|
|
89
111
|
import 'dropzone/dist/basic.css'; // DropzoneInput
|
|
@@ -103,7 +125,8 @@ configureBootstrap({ Combobox, Chips, OtpInput, Range, Menu });
|
|
|
103
125
|
|
|
104
126
|
### Registering components
|
|
105
127
|
|
|
106
|
-
Import what you need, or install the plugin to register
|
|
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)`):
|
|
107
130
|
|
|
108
131
|
```js
|
|
109
132
|
import InertiaBootstrapForms from 'inertia-bootstrap-forms';
|
|
@@ -299,6 +322,9 @@ Replaces `Select2Input` (choices.js). `Select2Input` is still exported as an ali
|
|
|
299
322
|
| `search` | `object` | `{ url: null }` | **Remote search**: `{ url, method='POST', param='query', debounce=400, minChars=0, headers, resultsKey='data' }` |
|
|
300
323
|
| `clearable` | `boolean` | `false` | Adds an entry that clears a single select |
|
|
301
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 |
|
|
302
328
|
| `placement` | `string` | `'bottom-start'` | Floating UI placement |
|
|
303
329
|
| `size`, `hideDropdown`, `searchNormalize`, `locale` | | | |
|
|
304
330
|
|
|
@@ -313,6 +339,18 @@ Exposed: `show()`, `hide()`, `toggle()`, `clear()`, `focus()`.
|
|
|
313
339
|
<ComboboxInput name="tags" multiple search-enabled :options="tags" />
|
|
314
340
|
```
|
|
315
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
|
+
|
|
316
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.
|
|
317
355
|
|
|
318
356
|
### `ChipsInput` (Bootstrap 6 Chips)
|
|
@@ -364,13 +402,43 @@ Value: `number`. Events: `update:modelValue`, `change`, `input`, `focus`, `blur`
|
|
|
364
402
|
|---|---|
|
|
365
403
|
| `StarRatingInput` | `maxStars`, `precision` (steps per star), `showValue`, `clearable`, `value`; pointer + keyboard, RTL aware, `role="slider"` |
|
|
366
404
|
| `CaptchaInput` | `url`, `placeholder`, `refreshOnSubmit`, `imageWidth`, `imageHeight`; event `refresh` |
|
|
367
|
-
| `PersianDatePickerInput` | `calendar`, `view`, `min`, `max`, `range`, `format`, `inputFormat`, `pickerOptions`, `inputClass`; events `open`, `close` |
|
|
405
|
+
| `PersianDatePickerInput` ¹ | `calendar`, `view`, `min`, `max`, `range`, `format`, `inputFormat`, `pickerOptions`, `inputClass`; events `open`, `close` |
|
|
368
406
|
| `EditorInput` | TinyMCE: `options`, `height`, `placeholder`, `apiKey`, `tinymceScriptSrc`; event `init` |
|
|
369
407
|
| `LocationInput` | Leaflet: `center`, `zoom`, `height`, `tileUrl`, `attribution`; value `{ lat, lng }`; event `ready` |
|
|
370
408
|
| `FileInput` (`SimpleUploader`) | `multiple`, `endpoint`, `accept`, `headers`, `fieldName`; events `added`, `progress`, `uploaded`, `error`, `removed` |
|
|
371
409
|
| `DropzoneInput` | `multiple`, `url`, `options`, `headers`; events `ready`, `added`, `success`, `error`, `removed`, `complete` |
|
|
372
410
|
| `UppyInput` | `multiple`, `useXHR`, `XHRConfig`, `url`, `config`, `errorHandler`, `showRestrictionCaption`; all Uppy events are re-emitted |
|
|
373
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
|
+
|
|
374
442
|
---
|
|
375
443
|
|
|
376
444
|
## Upload endpoint contract
|
|
@@ -445,6 +513,25 @@ Also exported: `useFormApi()`, `useDisposables()`, `useBsInstance()`, `configure
|
|
|
445
513
|
| `name` was `required` | optional — omit it for standalone `v-model` usage |
|
|
446
514
|
| Peer: Bootstrap 5 CSS | Peer: `bootstrap@^6.0.0-alpha.1`, `@floating-ui/dom` |
|
|
447
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
|
+
|
|
448
535
|
## Notes and known limitations
|
|
449
536
|
|
|
450
537
|
* Bootstrap 6 is currently in **alpha**; class names and plugin APIs may still change before the stable release.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { defineComponent as E, resolveComponent as w, createElementBlock as S, createCommentVNode as O, openBlock as f, createBlock as $, toDisplayString as D, resolveDynamicComponent as L, withCtx as X, renderSlot as J, createVNode as _, defineAsyncComponent as B, shallowRef as V, computed as G, ref as v, onMounted as K, watch as q } from "vue";
|
|
2
|
+
import { _ as Q, f as W, u as Y } from "./_plugin-vue_export-helper-13TPlHFF.js";
|
|
3
|
+
import { u as Z, a as ee, l as j } from "./http-DV3dRBe5.js";
|
|
4
|
+
const le = B(() => import("@uppy/vue").then((e) => e.UppyContextProvider)), oe = B(() => import("@uppy/vue").then((e) => e.FilesList)), ae = B(() => import("@uppy/vue").then((e) => e.Dropzone)), A = ["bytes", "KB", "MB", "GB", "TB"];
|
|
5
|
+
function N(e) {
|
|
6
|
+
let n = 0, d = parseInt(e, 10) || 0;
|
|
7
|
+
for (; d >= 1024 && n < A.length - 1; )
|
|
8
|
+
d /= 1024, n++;
|
|
9
|
+
return `${d.toFixed(d < 10 && n > 0 ? 1 : 0)}${A[n]}`;
|
|
10
|
+
}
|
|
11
|
+
const te = E({
|
|
12
|
+
name: "UppyInput",
|
|
13
|
+
components: { UppyContextProvider: le, FilesList: oe, UppyDropzone: ae },
|
|
14
|
+
emits: [
|
|
15
|
+
"update:modelValue",
|
|
16
|
+
"change",
|
|
17
|
+
"ready",
|
|
18
|
+
"file-added",
|
|
19
|
+
"file-removed",
|
|
20
|
+
"beforeUpload",
|
|
21
|
+
"progress",
|
|
22
|
+
"upload",
|
|
23
|
+
"upload-progress",
|
|
24
|
+
"upload-error",
|
|
25
|
+
"upload-success",
|
|
26
|
+
"upload-pause",
|
|
27
|
+
"complete",
|
|
28
|
+
"error",
|
|
29
|
+
"upload-retry",
|
|
30
|
+
"upload-stalled",
|
|
31
|
+
"retry-all",
|
|
32
|
+
"cancel-all",
|
|
33
|
+
"restriction-failed"
|
|
34
|
+
],
|
|
35
|
+
props: {
|
|
36
|
+
...W,
|
|
37
|
+
multiple: { type: Boolean, default: !1 },
|
|
38
|
+
useXHR: { type: Boolean, default: !0 },
|
|
39
|
+
XHRConfig: { type: Object, default: () => ({}) },
|
|
40
|
+
url: { type: String, default: "/upload" },
|
|
41
|
+
/** Uppy core options. */
|
|
42
|
+
config: { type: Object, default: () => ({}) },
|
|
43
|
+
errorHandler: { type: Function, default: null },
|
|
44
|
+
showRestrictionCaption: { type: Boolean, default: !0 },
|
|
45
|
+
/**
|
|
46
|
+
* Extra Uppy plugins: [{ plugin: Webcam, options: { id: 'Webcam' }, dashboard: true }].
|
|
47
|
+
* Normally filled by <UppyDashboardInput>; every plugin needs an `id` to be listed in the Dashboard.
|
|
48
|
+
*/
|
|
49
|
+
plugins: { type: Array, default: () => [] },
|
|
50
|
+
/** Component that renders the Uppy Dashboard (the default export of '@uppy/vue/dashboard'). Switches the UI to the Dashboard. */
|
|
51
|
+
dashboardComponent: { type: Object, default: null },
|
|
52
|
+
/** Dashboard options: { height, width, theme, note, proudlyDisplayPoweredByUppy, … }. */
|
|
53
|
+
dashboardProps: { type: Object, default: () => ({}) },
|
|
54
|
+
locale: { type: String, default: null }
|
|
55
|
+
},
|
|
56
|
+
setup(e, { emit: n, expose: d }) {
|
|
57
|
+
const s = Y(e, n), { t: r } = Z(() => e.locale), y = ee(), i = V(null), g = G(() => !!e.dashboardComponent), b = v({}), I = v(null), F = v(null), z = v(null), c = v(0);
|
|
58
|
+
let U = !1, P = !1;
|
|
59
|
+
const m = (a) => {
|
|
60
|
+
s.form.value && (s.form.value.uploading = a);
|
|
61
|
+
};
|
|
62
|
+
function k(a) {
|
|
63
|
+
if (e.errorHandler) return e.errorHandler(a);
|
|
64
|
+
a && (z.value = a, y.timeout(() => z.value = null, 3e3));
|
|
65
|
+
}
|
|
66
|
+
function M(a) {
|
|
67
|
+
var h;
|
|
68
|
+
if (!a) return "";
|
|
69
|
+
const o = [];
|
|
70
|
+
return (h = a.allowedFileTypes) != null && h.length && o.push(r("uppy.types", { types: a.allowedFileTypes.map((C) => C.replace(".", "")).join(", ") })), a.maxNumberOfFiles && a.maxNumberOfFiles > 1 && o.push(r("uppy.maxFiles", { count: a.maxNumberOfFiles })), a.minNumberOfFiles && o.push(r("uppy.minFiles", { count: a.minNumberOfFiles })), a.maxFileSize && o.push(r("uppy.maxSize", { size: N(a.maxFileSize) })), a.minFileSize && o.push(r("uppy.minSize", { size: N(a.minFileSize) })), a.maxTotalFileSize && o.push(r("uppy.maxTotal", { size: N(a.maxTotalFileSize) })), o.length ? `${o.join(", ")} ${r("uppy.suffix")}` : "";
|
|
71
|
+
}
|
|
72
|
+
return K(async () => {
|
|
73
|
+
var C, x, T, H;
|
|
74
|
+
const { default: a } = await import("@uppy/core");
|
|
75
|
+
if (y.isDisposed()) return;
|
|
76
|
+
const o = new a({
|
|
77
|
+
id: e.name ?? "uppy",
|
|
78
|
+
autoProceed: !0,
|
|
79
|
+
...e.config,
|
|
80
|
+
restrictions: {
|
|
81
|
+
maxNumberOfFiles: e.multiple ? null : 1,
|
|
82
|
+
...((C = e.config) == null ? void 0 : C.restrictions) || {}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (o.on("upload", () => {
|
|
86
|
+
c.value = o.getFiles().filter((l) => !l.progress.uploadComplete).length, n("upload");
|
|
87
|
+
}), o.on("before-upload", (l) => n("beforeUpload", l)), o.on("upload-success", (l, t) => {
|
|
88
|
+
c.value = Math.max(0, c.value - 1);
|
|
89
|
+
const p = t.body ?? t;
|
|
90
|
+
if (e.multiple) {
|
|
91
|
+
const u = Array.isArray(s.model.value) ? s.model.value : [];
|
|
92
|
+
s.model.value = [...u, p];
|
|
93
|
+
} else
|
|
94
|
+
s.model.value = p;
|
|
95
|
+
s.emitChange(s.model.value), n("upload-success", l, t);
|
|
96
|
+
}), o.on("file-added", (l) => n("file-added", l)), o.on("file-removed", (l) => {
|
|
97
|
+
var p;
|
|
98
|
+
const t = ((p = l.response) == null ? void 0 : p.body) ?? l.response;
|
|
99
|
+
e.multiple && Array.isArray(s.model.value) ? s.model.value = s.model.value.filter((u) => JSON.stringify(u) !== JSON.stringify(t)) : s.model.value = null, s.emitChange(s.model.value), t && !U && !P && fetch(e.url, {
|
|
100
|
+
method: "DELETE",
|
|
101
|
+
headers: j({ "Content-Type": "application/json" }),
|
|
102
|
+
credentials: "same-origin",
|
|
103
|
+
body: JSON.stringify(t)
|
|
104
|
+
}).catch(() => {
|
|
105
|
+
}), n("file-removed", l);
|
|
106
|
+
}), o.on("progress", (l) => {
|
|
107
|
+
l <= 0 ? m(null) : l >= 100 ? m(c.value > 0 ? 99 : null) : m(l), n("progress", l);
|
|
108
|
+
}), o.on("upload-progress", (l, t) => n("upload-progress", l, t)), o.on("upload-pause", (l, t) => n("upload-pause", l, t)), o.on("cancel-all", () => n("cancel-all")), o.on("retry-all", () => n("retry-all")), o.on("upload-stalled", (l, t) => n("upload-stalled", l, t)), o.on("upload-retry", (l) => n("upload-retry", l)), o.on("complete", (l) => {
|
|
109
|
+
c.value = 0, m(null), n("complete", l);
|
|
110
|
+
}), o.on("error", (l) => n("error", l)), o.on("upload-error", (l, t, p) => {
|
|
111
|
+
var R;
|
|
112
|
+
c.value = Math.max(0, c.value - 1);
|
|
113
|
+
let u = t;
|
|
114
|
+
try {
|
|
115
|
+
u = ((R = JSON.parse(p.response)) == null ? void 0 : R.message) ?? t;
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
k((u == null ? void 0 : u.message) ?? u), n("upload-error", l, t, p, u);
|
|
119
|
+
}), o.on("restriction-failed", (l, t) => {
|
|
120
|
+
k(t.message), n("restriction-failed", l, t);
|
|
121
|
+
}), e.useXHR) {
|
|
122
|
+
const { default: l } = await import("@uppy/xhr-upload");
|
|
123
|
+
if (y.isDisposed()) {
|
|
124
|
+
(x = o.destroy) == null || x.call(o);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
o.use(l, {
|
|
128
|
+
method: "POST",
|
|
129
|
+
endpoint: e.url,
|
|
130
|
+
headers: j(),
|
|
131
|
+
...e.XHRConfig
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const h = [];
|
|
135
|
+
e.plugins.forEach((l) => {
|
|
136
|
+
const t = { ...l.options || {} };
|
|
137
|
+
o.use(l.plugin, t), l.dashboard !== !1 && (t.id || l.id) && h.push(t.id || l.id);
|
|
138
|
+
}), y.add(() => {
|
|
139
|
+
var l;
|
|
140
|
+
P = !0, m(null);
|
|
141
|
+
try {
|
|
142
|
+
(l = o.destroy) == null || l.call(o);
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
i.value = null;
|
|
146
|
+
}), e.showRestrictionCaption && (F.value = M((T = o.opts) == null ? void 0 : T.restrictions)), b.value = {
|
|
147
|
+
inline: !0,
|
|
148
|
+
width: "100%",
|
|
149
|
+
height: 350,
|
|
150
|
+
theme: "auto",
|
|
151
|
+
proudlyDisplayPoweredByUppy: !1,
|
|
152
|
+
note: F.value || void 0,
|
|
153
|
+
...e.dashboardProps,
|
|
154
|
+
plugins: [...h, ...((H = e.dashboardProps) == null ? void 0 : H.plugins) || []]
|
|
155
|
+
}, g.value && (F.value = null), i.value = o, n("ready", o);
|
|
156
|
+
}), q(
|
|
157
|
+
() => {
|
|
158
|
+
var a;
|
|
159
|
+
return (a = s.form.value) == null ? void 0 : a.wasSuccessful;
|
|
160
|
+
},
|
|
161
|
+
(a, o) => {
|
|
162
|
+
a === !0 && o === !1 && i.value && (U = !0, i.value.cancelAll(), U = !1, s.model.value = e.multiple ? [] : null);
|
|
163
|
+
}
|
|
164
|
+
), d({ uppy: () => i.value }), { ...s, uppy: i, area: I, caption: F, errorMessage: z, useDashboard: g, dashboardOptions: b };
|
|
165
|
+
}
|
|
166
|
+
}), ne = ["id"], se = {
|
|
167
|
+
key: 0,
|
|
168
|
+
class: "alert theme-danger text-center py-1 mb-2",
|
|
169
|
+
role: "alert"
|
|
170
|
+
}, ue = {
|
|
171
|
+
key: 3,
|
|
172
|
+
class: "uppy-input-area--caption form-text text-center fst-italic"
|
|
173
|
+
}, re = {
|
|
174
|
+
key: 4,
|
|
175
|
+
class: "invalid-feedback d-block"
|
|
176
|
+
};
|
|
177
|
+
function ie(e, n, d, s, r, y) {
|
|
178
|
+
const i = w("FilesList"), g = w("UppyDropzone"), b = w("UppyContextProvider");
|
|
179
|
+
return e.uppy ? (f(), S("div", {
|
|
180
|
+
key: 0,
|
|
181
|
+
ref: "area",
|
|
182
|
+
class: "uppy-input-area",
|
|
183
|
+
id: e.inputId
|
|
184
|
+
}, [
|
|
185
|
+
e.errorMessage ? (f(), S("div", se, D(e.errorMessage), 1)) : O("", !0),
|
|
186
|
+
e.useDashboard ? (f(), $(L(e.dashboardComponent), {
|
|
187
|
+
key: 1,
|
|
188
|
+
uppy: e.uppy,
|
|
189
|
+
props: e.dashboardOptions
|
|
190
|
+
}, null, 8, ["uppy", "props"])) : (f(), $(b, {
|
|
191
|
+
key: 2,
|
|
192
|
+
name: "uu" + (e.name ?? "uppy"),
|
|
193
|
+
uppy: e.uppy
|
|
194
|
+
}, {
|
|
195
|
+
default: X(() => [
|
|
196
|
+
J(e.$slots, "default", { uppy: e.uppy }, () => [
|
|
197
|
+
_(i, { class: "uppy-file-lists" }),
|
|
198
|
+
_(g, { class: "uppy-drop-zone" })
|
|
199
|
+
])
|
|
200
|
+
]),
|
|
201
|
+
_: 3
|
|
202
|
+
}, 8, ["name", "uppy"])),
|
|
203
|
+
e.caption ? (f(), S("div", ue, D(e.caption), 1)) : O("", !0),
|
|
204
|
+
e.isInvalid ? (f(), S("div", re, D(e.error), 1)) : O("", !0)
|
|
205
|
+
], 8, ne)) : O("", !0);
|
|
206
|
+
}
|
|
207
|
+
const ye = /* @__PURE__ */ Q(te, [["render", ie]]);
|
|
208
|
+
export {
|
|
209
|
+
ye as U
|
|
210
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var R=Object.create;var x=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var j=(e,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of _(n))!I.call(e,u)&&u!==i&&x(e,u,{get:()=>n[u],enumerable:!(r=V(n,u))||r.enumerable});return e};var v=(e,n,i)=>(i=e!=null?R($(e)):{},j(n||!e||!e.__esModule?x(i,"default",{value:e,enumerable:!0}):i,e));const l=require("vue"),O=require("./_plugin-vue_export-helper-BHyUve4F.cjs"),B=require("./http-CDPNmbjF.cjs"),M=l.defineAsyncComponent(()=>import("@uppy/vue").then(e=>e.UppyContextProvider)),L=l.defineAsyncComponent(()=>import("@uppy/vue").then(e=>e.FilesList)),X=l.defineAsyncComponent(()=>import("@uppy/vue").then(e=>e.Dropzone)),T=["bytes","KB","MB","GB","TB"];function N(e){let n=0,i=parseInt(e,10)||0;for(;i>=1024&&n<T.length-1;)i/=1024,n++;return`${i.toFixed(i<10&&n>0?1:0)}${T[n]}`}const J=l.defineComponent({name:"UppyInput",components:{UppyContextProvider:M,FilesList:L,UppyDropzone:X},emits:["update:modelValue","change","ready","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"],props:{...O.fieldProps,multiple:{type:Boolean,default:!1},useXHR:{type:Boolean,default:!0},XHRConfig:{type:Object,default:()=>({})},url:{type:String,default:"/upload"},config:{type:Object,default:()=>({})},errorHandler:{type:Function,default:null},showRestrictionCaption:{type:Boolean,default:!0},plugins:{type:Array,default:()=>[]},dashboardComponent:{type:Object,default:null},dashboardProps:{type:Object,default:()=>({})},locale:{type:String,default:null}},setup(e,{emit:n,expose:i}){const r=O.useField(e,n),{t:u}=B.useI18n(()=>e.locale),y=B.useDisposables(),d=l.shallowRef(null),g=l.computed(()=>!!e.dashboardComponent),b=l.ref({}),A=l.ref(null),C=l.ref(null),S=l.ref(null),f=l.ref(0);let k=!1,z=!1;const m=a=>{r.form.value&&(r.form.value.uploading=a)};function U(a){if(e.errorHandler)return e.errorHandler(a);a&&(S.value=a,y.timeout(()=>S.value=null,3e3))}function E(a){var h;if(!a)return"";const t=[];return(h=a.allowedFileTypes)!=null&&h.length&&t.push(u("uppy.types",{types:a.allowedFileTypes.map(F=>F.replace(".","")).join(", ")})),a.maxNumberOfFiles&&a.maxNumberOfFiles>1&&t.push(u("uppy.maxFiles",{count:a.maxNumberOfFiles})),a.minNumberOfFiles&&t.push(u("uppy.minFiles",{count:a.minNumberOfFiles})),a.maxFileSize&&t.push(u("uppy.maxSize",{size:N(a.maxFileSize)})),a.minFileSize&&t.push(u("uppy.minSize",{size:N(a.minFileSize)})),a.maxTotalFileSize&&t.push(u("uppy.maxTotal",{size:N(a.maxTotalFileSize)})),t.length?`${t.join(", ")} ${u("uppy.suffix")}`:""}return l.onMounted(async()=>{var F,w,D,P;const{default:a}=await import("@uppy/core");if(y.isDisposed())return;const t=new a({id:e.name??"uppy",autoProceed:!0,...e.config,restrictions:{maxNumberOfFiles:e.multiple?null:1,...((F=e.config)==null?void 0:F.restrictions)||{}}});if(t.on("upload",()=>{f.value=t.getFiles().filter(o=>!o.progress.uploadComplete).length,n("upload")}),t.on("before-upload",o=>n("beforeUpload",o)),t.on("upload-success",(o,s)=>{f.value=Math.max(0,f.value-1);const c=s.body??s;if(e.multiple){const p=Array.isArray(r.model.value)?r.model.value:[];r.model.value=[...p,c]}else r.model.value=c;r.emitChange(r.model.value),n("upload-success",o,s)}),t.on("file-added",o=>n("file-added",o)),t.on("file-removed",o=>{var c;const s=((c=o.response)==null?void 0:c.body)??o.response;e.multiple&&Array.isArray(r.model.value)?r.model.value=r.model.value.filter(p=>JSON.stringify(p)!==JSON.stringify(s)):r.model.value=null,r.emitChange(r.model.value),s&&!k&&!z&&fetch(e.url,{method:"DELETE",headers:B.laravelHeaders({"Content-Type":"application/json"}),credentials:"same-origin",body:JSON.stringify(s)}).catch(()=>{}),n("file-removed",o)}),t.on("progress",o=>{o<=0?m(null):o>=100?m(f.value>0?99:null):m(o),n("progress",o)}),t.on("upload-progress",(o,s)=>n("upload-progress",o,s)),t.on("upload-pause",(o,s)=>n("upload-pause",o,s)),t.on("cancel-all",()=>n("cancel-all")),t.on("retry-all",()=>n("retry-all")),t.on("upload-stalled",(o,s)=>n("upload-stalled",o,s)),t.on("upload-retry",o=>n("upload-retry",o)),t.on("complete",o=>{f.value=0,m(null),n("complete",o)}),t.on("error",o=>n("error",o)),t.on("upload-error",(o,s,c)=>{var H;f.value=Math.max(0,f.value-1);let p=s;try{p=((H=JSON.parse(c.response))==null?void 0:H.message)??s}catch{}U((p==null?void 0:p.message)??p),n("upload-error",o,s,c,p)}),t.on("restriction-failed",(o,s)=>{U(s.message),n("restriction-failed",o,s)}),e.useXHR){const{default:o}=await import("@uppy/xhr-upload");if(y.isDisposed()){(w=t.destroy)==null||w.call(t);return}t.use(o,{method:"POST",endpoint:e.url,headers:B.laravelHeaders(),...e.XHRConfig})}const h=[];e.plugins.forEach(o=>{const s={...o.options||{}};t.use(o.plugin,s),o.dashboard!==!1&&(s.id||o.id)&&h.push(s.id||o.id)}),y.add(()=>{var o;z=!0,m(null);try{(o=t.destroy)==null||o.call(t)}catch{}d.value=null}),e.showRestrictionCaption&&(C.value=E((D=t.opts)==null?void 0:D.restrictions)),b.value={inline:!0,width:"100%",height:350,theme:"auto",proudlyDisplayPoweredByUppy:!1,note:C.value||void 0,...e.dashboardProps,plugins:[...h,...((P=e.dashboardProps)==null?void 0:P.plugins)||[]]},g.value&&(C.value=null),d.value=t,n("ready",t)}),l.watch(()=>{var a;return(a=r.form.value)==null?void 0:a.wasSuccessful},(a,t)=>{a===!0&&t===!1&&d.value&&(k=!0,d.value.cancelAll(),k=!1,r.model.value=e.multiple?[]:null)}),i({uppy:()=>d.value}),{...r,uppy:d,area:A,caption:C,errorMessage:S,useDashboard:g,dashboardOptions:b}}}),q=["id"],G={key:0,class:"alert theme-danger text-center py-1 mb-2",role:"alert"},K={key:3,class:"uppy-input-area--caption form-text text-center fst-italic"},Q={key:4,class:"invalid-feedback d-block"};function W(e,n,i,r,u,y){const d=l.resolveComponent("FilesList"),g=l.resolveComponent("UppyDropzone"),b=l.resolveComponent("UppyContextProvider");return e.uppy?(l.openBlock(),l.createElementBlock("div",{key:0,ref:"area",class:"uppy-input-area",id:e.inputId},[e.errorMessage?(l.openBlock(),l.createElementBlock("div",G,l.toDisplayString(e.errorMessage),1)):l.createCommentVNode("",!0),e.useDashboard?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.dashboardComponent),{key:1,uppy:e.uppy,props:e.dashboardOptions},null,8,["uppy","props"])):(l.openBlock(),l.createBlock(b,{key:2,name:"uu"+(e.name??"uppy"),uppy:e.uppy},{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default",{uppy:e.uppy},()=>[l.createVNode(d,{class:"uppy-file-lists"}),l.createVNode(g,{class:"uppy-drop-zone"})])]),_:3},8,["name","uppy"])),e.caption?(l.openBlock(),l.createElementBlock("div",K,l.toDisplayString(e.caption),1)):l.createCommentVNode("",!0),e.isInvalid?(l.openBlock(),l.createElementBlock("div",Q,l.toDisplayString(e.error),1)):l.createCommentVNode("",!0)],8,q)):l.createCommentVNode("",!0)}const Y=O._export_sfc(J,[["render",W]]);exports.UppyInput=Y;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as $ from "vue";
|
|
2
|
+
import { inject as c, computed as u, ref as k, watch as B } from "vue";
|
|
3
|
+
let A = 0;
|
|
4
|
+
const j = {
|
|
5
|
+
/** Key of the field inside the FormContainer's v-model object. */
|
|
6
|
+
name: { type: String, default: null },
|
|
7
|
+
/** Standalone v-model (only used when the field is NOT inside a FormContainer). */
|
|
8
|
+
modelValue: { type: null, default: void 0 },
|
|
9
|
+
id: { type: String, default: null },
|
|
10
|
+
disabled: { type: Boolean, default: !1 },
|
|
11
|
+
readonly: { type: Boolean, default: !1 },
|
|
12
|
+
required: { type: Boolean, default: !1 },
|
|
13
|
+
/** Force the invalid state. By default it follows the server-side errors of the form. */
|
|
14
|
+
invalid: { type: Boolean, default: null }
|
|
15
|
+
};
|
|
16
|
+
function q(l, f, t = {}) {
|
|
17
|
+
const i = c("form", null), d = c("group", null), r = c("formField", null), h = c("formApi", null), n = u(() => (i == null ? void 0 : i.value) ?? null), a = u(() => {
|
|
18
|
+
var e;
|
|
19
|
+
return (e = d == null ? void 0 : d.value) != null && e.name ? d.value : null;
|
|
20
|
+
}), o = u(() => !n.value), s = k(
|
|
21
|
+
l.modelValue === void 0 ? t.defaultValue ?? null : l.modelValue
|
|
22
|
+
);
|
|
23
|
+
B(
|
|
24
|
+
() => l.modelValue,
|
|
25
|
+
(e) => {
|
|
26
|
+
o.value && e !== void 0 && (s.value = e);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const V = u({
|
|
30
|
+
get() {
|
|
31
|
+
return o.value ? s.value : a.value ? a.value.getData(l.name) : n.value[l.name];
|
|
32
|
+
},
|
|
33
|
+
set(e) {
|
|
34
|
+
o.value ? s.value = e : a.value ? a.value.setData(l.name, e) : n.value[l.name] = e, f("update:modelValue", e);
|
|
35
|
+
}
|
|
36
|
+
}), I = u(() => {
|
|
37
|
+
const e = [];
|
|
38
|
+
return a.value && (e.push(`${a.value.name}.${a.value.index}.${l.name}`), e.push(`${a.value.name}.${l.name}`)), e.push(l.name), e;
|
|
39
|
+
}), g = u(() => {
|
|
40
|
+
var v;
|
|
41
|
+
const e = (v = n.value) == null ? void 0 : v.errors;
|
|
42
|
+
if (!e) return null;
|
|
43
|
+
for (const m of I.value)
|
|
44
|
+
if (m && e[m] !== void 0) return e[m];
|
|
45
|
+
return null;
|
|
46
|
+
}), b = u(() => l.invalid === !0 || l.invalid === null && g.value !== null), D = u(() => {
|
|
47
|
+
var e;
|
|
48
|
+
return l.disabled || !!((e = n.value) != null && e.processing);
|
|
49
|
+
}), y = $.useId ? $.useId() : `ibf-${++A}`, _ = u(() => {
|
|
50
|
+
var e;
|
|
51
|
+
return l.id ? l.id : r != null && r.id && !t.valued ? r.id : (e = n.value) != null && e.getID && l.name ? n.value.getID({
|
|
52
|
+
name: l.name,
|
|
53
|
+
value: t.valued ? t.valued() : void 0,
|
|
54
|
+
group: a.value
|
|
55
|
+
}) : l.name ? `${l.name}-${y}` : y;
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
form: n,
|
|
59
|
+
group: a,
|
|
60
|
+
standalone: o,
|
|
61
|
+
model: V,
|
|
62
|
+
error: g,
|
|
63
|
+
isInvalid: b,
|
|
64
|
+
isDisabled: D,
|
|
65
|
+
inputId: _,
|
|
66
|
+
emitChange: (e, v) => f("change", e, v),
|
|
67
|
+
formApi: h,
|
|
68
|
+
fieldCtx: r
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const w = (l, f) => {
|
|
72
|
+
const t = l.__vccOpts || l;
|
|
73
|
+
for (const [i, d] of f)
|
|
74
|
+
t[i] = d;
|
|
75
|
+
return t;
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
w as _,
|
|
79
|
+
j as f,
|
|
80
|
+
q as u
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("vue");function D(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const d=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(a,n,d.get?d:{enumerable:!0,get:()=>e[n]})}}return a.default=e,Object.freeze(a)}const y=D(u);let I=0;const O={name:{type:String,default:null},modelValue:{type:null,default:void 0},id:{type:String,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},invalid:{type:Boolean,default:null}};function k(e,a,n={}){const d=u.inject("form",null),c=u.inject("group",null),o=u.inject("formField",null),b=u.inject("formApi",null),i=u.computed(()=>(d==null?void 0:d.value)??null),t=u.computed(()=>{var l;return(l=c==null?void 0:c.value)!=null&&l.name?c.value:null}),r=u.computed(()=>!i.value),s=u.ref(e.modelValue===void 0?n.defaultValue??null:e.modelValue);u.watch(()=>e.modelValue,l=>{r.value&&l!==void 0&&(s.value=l)});const _=u.computed({get(){return r.value?s.value:t.value?t.value.getData(e.name):i.value[e.name]},set(l){r.value?s.value=l:t.value?t.value.setData(e.name,l):i.value[e.name]=l,a("update:modelValue",l)}}),j=u.computed(()=>{const l=[];return t.value&&(l.push(`${t.value.name}.${t.value.index}.${e.name}`),l.push(`${t.value.name}.${e.name}`)),l.push(e.name),l}),v=u.computed(()=>{var f;const l=(f=i.value)==null?void 0:f.errors;if(!l)return null;for(const m of j.value)if(m&&l[m]!==void 0)return l[m];return null}),V=u.computed(()=>e.invalid===!0||e.invalid===null&&v.value!==null),$=u.computed(()=>{var l;return e.disabled||!!((l=i.value)!=null&&l.processing)}),g=y.useId?y.useId():`ibf-${++I}`,h=u.computed(()=>{var l;return e.id?e.id:o!=null&&o.id&&!n.valued?o.id:(l=i.value)!=null&&l.getID&&e.name?i.value.getID({name:e.name,value:n.valued?n.valued():void 0,group:t.value}):e.name?`${e.name}-${g}`:g});return{form:i,group:t,standalone:r,model:_,error:v,isInvalid:V,isDisabled:$,inputId:h,emitChange:(l,f)=>a("change",l,f),formApi:b,fieldCtx:o}}const B=(e,a)=>{const n=e.__vccOpts||e;for(const[d,c]of a)n[d]=c;return n};exports._export_sfc=B;exports.fieldProps=O;exports.useField=k;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("vue"),r=u.reactive({locale:"auto",messages:{en:{"select.placeholder":"Select an option…","select.search":"Type to search…","select.noResults":"No results found","select.loading":"Searching…","select.selectedCount":"{count} selected","select.clear":"— Clear selection —","select.error":"Search failed","submit.default":"Submit","chips.placeholder":"Type and press Enter…","chips.remove":"Remove","email.placeholder":"Enter your email","password.placeholder":"Enter your password","password.show":"Show password","password.hide":"Hide password","mobile.placeholder":"Enter your mobile number","amount.placeholder":"Enter a number","amount.unit":"pcs","quantity.unit":"pcs","quantity.increase":"Increase","quantity.decrease":"Decrease","captcha.placeholder":"Enter the code shown","captcha.refresh":"Refresh code","captcha.alt":"captcha","file.retry":"Retry","file.remove":"Remove","upload.failed":"Upload failed","uppy.types":"Only {types} files","uppy.maxFiles":"up to {count} files","uppy.minFiles":"at least {count} files required","uppy.maxSize":"max {size} per file","uppy.minSize":"min {size} per file","uppy.maxTotal":"max {size} in total","uppy.suffix":"are allowed."},fa:{"select.placeholder":"انتخاب کنید…","select.search":"برای جستجو تایپ کنید…","select.noResults":"نتیجهای یافت نشد","select.loading":"در حال جستجو…","select.selectedCount":"{count} مورد انتخاب شده","select.clear":"— پاک کردن انتخاب —","select.error":"جستجو با خطا مواجه شد","submit.default":"تایید و ثبت اطلاعات","chips.placeholder":"تایپ کنید و Enter بزنید…","chips.remove":"حذف","email.placeholder":"ایمیل خود را وارد کنید","password.placeholder":"گذرواژه خود را وارد کنید","password.show":"نمایش گذرواژه","password.hide":"مخفی کردن گذرواژه","mobile.placeholder":"موبایل خود را وارد کنید","amount.placeholder":"عدد را وارد کنید","amount.unit":"عدد","quantity.unit":"عدد","quantity.increase":"افزایش","quantity.decrease":"کاهش","captcha.placeholder":"کد امنیتی روبرو را وارد کنید","captcha.refresh":"کد جدید","captcha.alt":"کد امنیتی","file.retry":"تلاش مجدد","file.remove":"حذف","upload.failed":"خطا در آپلود","uppy.types":"فقط فایلهای {types}","uppy.maxFiles":"امکان انتخاب حداکثر {count} فایل","uppy.minFiles":"حداقل {count} فایل نیاز است","uppy.maxSize":"با حداکثر حجم {size} برای هر فایل","uppy.minSize":"با حداقل حجم {size} برای هر فایل","uppy.maxTotal":"و مجموع حجم کل حداکثر {size}","uppy.suffix":"مجاز است."}}});function m({locale:s,messages:e}={}){s&&(r.locale=s),e&&Object.keys(e).forEach(a=>{r.messages[a]={...r.messages[a]||{},...e[a]}})}function h(){var s;if(typeof document<"u"){const e=document.documentElement;if((e==null?void 0:e.dir)==="rtl"||(s=e==null?void 0:e.getAttribute("lang"))!=null&&s.startsWith("fa"))return"fa"}return"en"}function f(s=()=>null){const e=u.computed(()=>{const c=s()||r.locale;return c==="auto"?h():c});return{t:(c,i={})=>{let n=(r.messages[e.value]||r.messages.en)[c]??r.messages.en[c]??c;return Object.keys(i).forEach(t=>{n=n.replace(new RegExp(`\\{${t}\\}`,"g"),i[t])}),n},locale:e}}function y(){const s=[];let e=!1;const a=t=>{if(e){try{t()}catch{}return()=>{}}return s.push(t),()=>{const o=s.indexOf(t);o!==-1&&s.splice(o,1)}},c=(t,o,l,d)=>t?(t.addEventListener(o,l,d),a(()=>t.removeEventListener(o,l,d))):()=>{},i=(t,o)=>{const l=setTimeout(t,o);return a(()=>clearTimeout(l)),l},p=()=>{const t=new AbortController;return a(()=>t.abort()),t},n=()=>{for(e=!0;s.length;)try{s.pop()()}catch{}};return u.onBeforeUnmount(n),{add:a,listen:c,timeout:i,abortable:p,dispose:n,isDisposed:()=>e}}function b(s={}){const e={Accept:"application/json","X-Requested-With":"XMLHttpRequest",...s};if(typeof document<"u"){const a=document.cookie.match(/(?:^|;\s*)XSRF-TOKEN=([^;]+)/);a&&!e["X-XSRF-TOKEN"]&&(e["X-XSRF-TOKEN"]=decodeURIComponent(a[1]))}return e}exports.configureI18n=m;exports.laravelHeaders=b;exports.useDisposables=y;exports.useI18n=f;
|