inertia-bootstrap-forms 1.0.34 → 1.0.36

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/index.d.ts CHANGED
@@ -1,4 +1,100 @@
1
- // index.d.ts
1
+ import { defineComponent } from 'vue';
2
+
3
+ // Import کامپوننت‌ها
4
+ import AmountInput from './src/AmountInput.vue';
5
+ import CaptchaInput from './src/CaptchaInput.vue';
6
+ import CheckboxButtonInput from './src/CheckboxButtonInput.vue';
7
+ import CheckboxInput from './src/CheckboxInput.vue';
8
+ import CheckboxToggle from './src/CheckboxToggle.vue';
9
+ import EditorInput from './src/EditorInput.vue';
10
+ import EmailInput from './src/EmailInput.vue';
11
+ import FileInput from './src/FileInput.vue';
12
+ import SimpleUploader from './src/SimpleUploader.vue';
13
+ import FormContainer from './src/FormContainer.vue';
14
+ import FormLabel from './src/FormLabel.vue';
15
+ import GroupControl from './src/GroupControl.vue';
16
+ import LocationInput from './src/LocationInput.vue';
17
+ import MobileInput from './src/MobileInput.vue';
18
+ import MultiQuantityInput from './src/MultiQuantityInput.vue';
19
+ import PasswordInput from './src/PasswordInput.vue';
20
+ import PersianDatePickerInput from './src/PersianDatePickerInput.vue';
21
+ import QuantityInput from './src/QuantityInput.vue';
22
+ import SecondarySubmitButton from './src/SecondarySubmitButton.vue';
23
+ import Select2Input from './src/Select2Input.vue';
24
+ import StarRatingInput from './src/StarRatingInput.vue';
25
+ import SubmitButton from './src/SubmitButton.vue';
26
+ import TelInput from './src/TelInput.vue';
27
+ import TextAreaInput from './src/TextAreaInput.vue';
28
+ import TextInput from './src/TextInput.vue';
29
+ import DropzoneInput from './src/DropzoneInput.vue';
30
+ import { countryCodes } from './src/countryCodes';
31
+
32
+ // Export تکی
33
+ export {
34
+ AmountInput,
35
+ CaptchaInput,
36
+ CheckboxButtonInput,
37
+ CheckboxInput,
38
+ CheckboxToggle,
39
+ countryCodes,
40
+ EditorInput,
41
+ EmailInput,
42
+ DropzoneInput,
43
+ FileInput,
44
+ SimpleUploader,
45
+ FormContainer,
46
+ FormLabel,
47
+ GroupControl,
48
+ LocationInput,
49
+ MobileInput,
50
+ MultiQuantityInput,
51
+ PasswordInput,
52
+ PersianDatePickerInput,
53
+ QuantityInput,
54
+ SecondarySubmitButton,
55
+ Select2Input,
56
+ StarRatingInput,
57
+ SubmitButton,
58
+ TelInput,
59
+ TextAreaInput,
60
+ TextInput,
61
+ Quantity,
62
+ File,
63
+ };
64
+
65
+ // Export پیش‌فرض برای import * as
66
+ const Vue3FormComponents = {
67
+ AmountInput,
68
+ CaptchaInput,
69
+ CheckboxButtonInput,
70
+ CheckboxInput,
71
+ CheckboxToggle,
72
+ countryCodes,
73
+ EditorInput,
74
+ DropzoneInput,
75
+ EmailInput,
76
+ FileInput,
77
+ SimpleUploader,
78
+ FormContainer,
79
+ FormLabel,
80
+ GroupControl,
81
+ LocationInput,
82
+ MobileInput,
83
+ MultiQuantityInput,
84
+ PasswordInput,
85
+ PersianDatePickerInput,
86
+ QuantityInput,
87
+ SecondarySubmitButton,
88
+ Select2Input,
89
+ StarRatingInput,
90
+ SubmitButton,
91
+ TelInput,
92
+ TextAreaInput,
93
+ TextInput,
94
+ };
95
+
96
+ export default Vue3FormComponents;
97
+
2
98
  import { DefineComponent } from 'vue';
3
99
 
4
100
  export const AmountInput: DefineComponent<{}, {}, any>;
@@ -9,10 +105,9 @@ export const CheckboxToggle: DefineComponent<{}, {}, any>;
9
105
  export const countryCodes: any;
10
106
  export const EditorInput: DefineComponent<{}, {}, any>;
11
107
  export const EmailInput: DefineComponent<{}, {}, any>;
12
- export const FileInput: DefineComponent<{
13
-
14
- }, {}, any>;
15
- export const FileUploader: DefineComponent<{}, {}, any>;
108
+ export const DropzoneInput: DefineComponent<{}, {}, any>;
109
+ export const FileInput: DefineComponent<{}, {}, any>;
110
+ export const SimpleUploader: DefineComponent<{}, {}, any>;
16
111
  export const FormContainer: DefineComponent<{}, {}, any>;
17
112
  export const FormLabel: DefineComponent<{}, {}, any>;
18
113
  export const GroupControl: DefineComponent<{}, {}, any>;
@@ -30,18 +125,19 @@ export const TelInput: DefineComponent<{}, {}, any>;
30
125
  export const TextAreaInput: DefineComponent<{}, {}, any>;
31
126
  export const TextInput: DefineComponent<{}, {}, any>;
32
127
 
33
- // این قسمت برای اینکه import * as ... هم ساپورت بشه
128
+ // Export پیش‌فرض
34
129
  declare const Vue3FormComponents: {
35
130
  AmountInput: typeof AmountInput;
36
131
  CaptchaInput: typeof CaptchaInput;
37
132
  CheckboxButtonInput: typeof CheckboxButtonInput;
38
133
  CheckboxInput: typeof CheckboxInput;
39
134
  CheckboxToggle: typeof CheckboxToggle;
135
+ DropzoneInput: typeof DropzoneInput;
40
136
  countryCodes: typeof countryCodes;
41
137
  EditorInput: typeof EditorInput;
42
138
  EmailInput: typeof EmailInput;
43
139
  FileInput: typeof FileInput;
44
- FileUploader: typeof FileUploader;
140
+ SimpleUploader: typeof SimpleUploader;
45
141
  FormContainer: typeof FormContainer;
46
142
  FormLabel: typeof FormLabel;
47
143
  GroupControl: typeof GroupControl;
@@ -58,6 +154,7 @@ declare const Vue3FormComponents: {
58
154
  TelInput: typeof TelInput;
59
155
  TextAreaInput: typeof TextAreaInput;
60
156
  TextInput: typeof TextInput;
157
+ Quantity: typeof QuantityInput;
61
158
  };
62
159
 
63
160
  export default Vue3FormComponents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inertia-bootstrap-forms",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
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",
@@ -46,10 +46,12 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@inertiajs/vue3": ">2.0",
49
+ "dropzone": "^6.0.0-beta.2",
49
50
  "vue": "^3.0"
50
51
  },
51
52
  "devDependencies": {
52
53
  "sass-embedded": "^1.89.2",
54
+ "dropzone": "^6.0.0-beta.2",
53
55
  "vite": "^5"
54
56
  },
55
57
  "bugs": {
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import {InputGroup, InputGroupText} from 'vue3-bootstrap-components';
3
- import {inject} from "vue";
3
+ import {defineComponent, inject} from "vue";
4
4
 
5
- export default {
5
+ export default defineComponent({
6
6
  components: {InputGroup, InputGroupText},
7
7
  props: {
8
8
  name: {
@@ -40,7 +40,7 @@ export default {
40
40
  this.$emit('update:modelValue', parseFloat(this.$number.toEnglish(event.detail?.unmasked)));
41
41
  }
42
42
  }
43
- }
43
+ })
44
44
  </script>
45
45
  <template>
46
46
  <InputGroup>
@@ -1,7 +1,8 @@
1
1
  <script>
2
2
  import TextInput from "./TextInput.vue";
3
+ import {defineComponent} from "vue";
3
4
 
4
- export default {
5
+ export default defineComponent({
5
6
  components: {TextInput},
6
7
  props: {
7
8
  name: {
@@ -56,7 +57,7 @@ export default {
56
57
  src: this.url + Math.random(),
57
58
  };
58
59
  }
59
- };
60
+ });
60
61
 
61
62
  </script>
62
63
  <template>
@@ -1,7 +1,7 @@
1
1
  <script>
2
- import {inject} from "vue";
2
+ import {defineComponent, inject} from "vue";
3
3
 
4
- export default {
4
+ export default defineComponent({
5
5
  emits: ['change'],
6
6
  props: {
7
7
  name: {
@@ -43,7 +43,7 @@ export default {
43
43
 
44
44
  return {form};
45
45
  },
46
- }
46
+ })
47
47
  </script>
48
48
  <template>
49
49
  <label class="btn-label" :for="form.getID(name)+(id || value)" :class="{'active': (form[name] === value || form[name] === true)}">
@@ -1,7 +1,7 @@
1
1
  <script>
2
- import {computed, inject} from "vue";
2
+ import {computed, defineComponent, inject} from "vue";
3
3
 
4
- export default {
4
+ export default defineComponent({
5
5
  props: {
6
6
  name: {
7
7
  type: String,
@@ -52,7 +52,7 @@ export default {
52
52
 
53
53
  return {modelValue, form, group};
54
54
  },
55
- }
55
+ })
56
56
  </script>
57
57
  <template>
58
58
  <div class="form-check">
@@ -1,7 +1,7 @@
1
1
  <script>
2
- import {computed, inject} from "vue";
2
+ import {computed, defineComponent, inject} from "vue";
3
3
 
4
- export default {
4
+ export default defineComponent({
5
5
  props: {
6
6
  name: {
7
7
  type: String,
@@ -59,7 +59,7 @@ export default {
59
59
 
60
60
  return {modelValue, form, group};
61
61
  },
62
- }
62
+ })
63
63
  </script>
64
64
  <template>
65
65
  <label class="form-check-toggle" :class="{'form-check-toggle--active': (selectedValue || []).includes(value)}" :for="inputID">
@@ -0,0 +1,108 @@
1
+ <script setup>
2
+ import { computed, inject, ref, onMounted } from "vue";
3
+ import Dropzone from "dropzone";
4
+ import "dropzone/dist/basic.css";
5
+ import "dropzone/dist/dropzone.css";
6
+
7
+ const props = defineProps({
8
+ name: {
9
+ type: String,
10
+ required: true,
11
+ },
12
+ multiple: {
13
+ type: Boolean,
14
+ default: false,
15
+ },
16
+ modelValue: String,
17
+ url: { type: String, default: "/upload" },
18
+ options: { type: Object, default: () => ({}) },
19
+ });
20
+ const emit = defineEmits(["update:modelValue"]);
21
+
22
+ const form = inject("form", {
23
+ value: {},
24
+ errors: {},
25
+ getID: n => n,
26
+ });
27
+
28
+ const group = inject("group", null);
29
+
30
+ const dz = ref(null);
31
+ const dropzone = ref(null);
32
+
33
+ const modelValue = computed({
34
+ get() {
35
+ return group?.value?.name
36
+ ? group.value.getData(props.name)
37
+ : form.value[props.name];
38
+ },
39
+ set(val) {
40
+ if (group?.value?.name) {
41
+ group.value.setData(props.name, val);
42
+ } else {
43
+ form.value[props.name] = val;
44
+ }
45
+ emit("update:modelValue", val);
46
+ }
47
+ });
48
+
49
+ onMounted(() => {
50
+ dropzone.value = new Dropzone(dz.value, {
51
+ url: props.url,
52
+ addRemoveLinks: true,
53
+ maxFiles: props.multiple ? null : 1,
54
+ ...props.options,
55
+ });
56
+
57
+ dropzone.value.on("error", (file, response) => {
58
+ let message = "خطا در آپلود";
59
+
60
+ if (typeof response === "string") {
61
+ message = response;
62
+ }
63
+
64
+ if (response?.message) {
65
+ message = response.message;
66
+ }
67
+
68
+ file.previewElement.classList.add("dz-error");
69
+ const err = file.previewElement.querySelector("[data-dz-errormessage]");
70
+ if (err) err.textContent = message;
71
+ });
72
+
73
+ dropzone.value.on("success", (file, response) => {
74
+ const result = response.data ?? response;
75
+
76
+ if(props.multiple){
77
+ modelValue.value = [...(modelValue.value || []), result];
78
+ }else{
79
+ modelValue.value = result;
80
+ }
81
+ });
82
+
83
+ dropzone.value.on("removedfile", async (file) => {
84
+ let data = file.xhr.response;
85
+ if (!data) return;
86
+
87
+ try {
88
+ data = JSON.parse(data);
89
+ modelValue.value = (modelValue.value || []).filter(f => f.path !== data.path);
90
+
91
+ await fetch(props.url, {
92
+ method: "DELETE",
93
+ headers: {
94
+ "Content-Type": "application/json",
95
+ 'Accept': 'application/json',
96
+ },
97
+ body: data.path
98
+ });
99
+ } catch (e) {
100
+ console.error("حذف فایل در سرور با خطا مواجه شد", e);
101
+ }
102
+ });
103
+ });
104
+ </script>
105
+
106
+ <template>
107
+ <div class="inertia-dropzone-input dropzone" ref="dz"></div>
108
+ </template>
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import Editor from '@tinymce/tinymce-vue';
3
- import {computed, inject} from "vue";
3
+ import {computed, defineComponent, inject} from "vue";
4
4
 
5
- export default {
5
+ export default defineComponent({
6
6
  components: {Editor},
7
7
  props: {
8
8
  name: {
@@ -51,7 +51,7 @@ export default {
51
51
  return {modelValue, form, group};
52
52
  },
53
53
  emits: ['update:modelValue'],
54
- }
54
+ })
55
55
  </script>
56
56
 
57
57
  <template>
@@ -1,7 +1,8 @@
1
1
  <script>
2
2
  import TextInput from "./TextInput.vue";
3
+ import {defineComponent} from "vue";
3
4
 
4
- export default {
5
+ export default defineComponent({
5
6
  components: {
6
7
  TextInput
7
8
  },
@@ -12,7 +13,7 @@ export default {
12
13
  required: true,
13
14
  },
14
15
  },
15
- }
16
+ })
16
17
  </script>
17
18
  <template>
18
19
  <TextInput
package/src/FileInput.vue CHANGED
@@ -1,7 +1,7 @@
1
1
  <script>
2
- import {inject} from "vue";
2
+ import {defineComponent, inject} from "vue";
3
3
 
4
- export default {
4
+ export default defineComponent({
5
5
  props: {
6
6
  modelValue: '',
7
7
  name: {
@@ -99,7 +99,7 @@ export default {
99
99
  files: [],
100
100
  }
101
101
  }
102
- }
102
+ })
103
103
  </script>
104
104
  <template>
105
105
  <div class="file-input-uploader">
@@ -1,9 +1,9 @@
1
1
  <script>
2
2
  import {useForm} from "@inertiajs/vue3";
3
- import {computed, reactive, toRef} from "vue";
3
+ import {computed, defineComponent, reactive, toRef} from "vue";
4
4
  import {Alert} from "vue3-bootstrap-components";
5
5
 
6
- export default {
6
+ export default defineComponent({
7
7
  components: {Alert},
8
8
  emits: ['submit', 'reset', 'onStart', 'onFinish', 'onSuccess', 'change'],
9
9
  props: {
@@ -133,7 +133,7 @@ export default {
133
133
  }
134
134
  },
135
135
  expose: ['submit', 'reset'],
136
- }
136
+ })
137
137
 
138
138
  </script>
139
139
 
package/src/FormLabel.vue CHANGED
@@ -1,11 +1,13 @@
1
1
  <script>
2
- export default {
2
+ import {defineComponent} from "vue";
3
+
4
+ export default defineComponent({
3
5
  props: {
4
6
  default: false,
5
7
  required: false,
6
8
  },
7
9
  emits: ['update:modelValue'],
8
- }
10
+ })
9
11
  </script>
10
12
 
11
13
  <template>
@@ -1,7 +1,7 @@
1
1
  <script>
2
- import {computed, inject} from "vue";
2
+ import {computed, defineComponent, inject} from "vue";
3
3
 
4
- export default {
4
+ export default defineComponent({
5
5
  props: {
6
6
  name: {
7
7
  type: String,
@@ -58,7 +58,7 @@ export default {
58
58
  groupID: '0',
59
59
  };
60
60
  }
61
- }
61
+ })
62
62
  </script>
63
63
  <template>
64
64
  <div class="form-control-group" :data-group-id="groupID" ref="groupEl">
@@ -1,9 +1,10 @@
1
1
  <script>
2
2
  import "leaflet/dist/leaflet.css";
3
+ import "./css/location.scss";
3
4
  import {LMap, LTileLayer, LMarker} from "@vue-leaflet/vue-leaflet";
4
- import {inject} from "vue";
5
+ import {defineComponent, inject} from "vue";
5
6
 
6
- export default {
7
+ export default defineComponent({
7
8
  name: 'LocationInput',
8
9
  components: {
9
10
  LMap, LTileLayer, LMarker
@@ -60,7 +61,7 @@ export default {
60
61
  };
61
62
  },
62
63
 
63
- }
64
+ })
64
65
  </script>
65
66
  <template>
66
67
  <div class="location-map-container"
@@ -75,50 +76,3 @@ export default {
75
76
  </l-map>
76
77
  </div>
77
78
  </template>
78
- <style>
79
- .location-map-container {
80
- position: relative;
81
- width: 100%;
82
- height: 300px;
83
- overflow: hidden;
84
- border-radius: var(--bs-border-radius);
85
- }
86
-
87
- .location-map-container.is-invalid {
88
- border: 1px solid var(--bs-form-invalid-border-color);
89
- }
90
-
91
- .location-map-container[disabled],
92
- .location-map-container.disabled:before {
93
- content: "";
94
- background-color: rgba(var(--bs-light-rgb), 0.4);
95
- display: block;
96
- position: absolute;
97
- top: 0;
98
- right: 0;
99
- left: 0;
100
- bottom: 0;
101
- z-index: 9999;
102
- }
103
-
104
- .location-map-container {
105
- .leaflet-pane,
106
- .leaflet-tile,
107
- .leaflet-marker-icon,
108
- .leaflet-marker-shadow,
109
- .leaflet-tile-container,
110
- .leaflet-pane > svg,
111
- .leaflet-pane > canvas,
112
- .leaflet-zoom-box,
113
- .leaflet-image-layer,
114
- .leaflet-layer {
115
- left: auto;
116
- right: 0;
117
- }
118
-
119
- .leaflet-control-attribution.leaflet-control {
120
- display: none;
121
- }
122
- }
123
-
124
- </style>
@@ -1,7 +1,8 @@
1
1
  <script>
2
2
  import TextInput from "./TextInput.vue";
3
+ import {defineComponent} from "vue";
3
4
 
4
- export default {
5
+ export default defineComponent({
5
6
  components: {
6
7
  TextInput
7
8
  },
@@ -12,7 +13,7 @@ export default {
12
13
  required: true,
13
14
  },
14
15
  },
15
- }
16
+ })
16
17
  </script>
17
18
  <template>
18
19
  <TextInput
@@ -1,10 +1,10 @@
1
1
  <script>
2
2
  import {Dropdown, DropdownToggle, DropdownMenu, InputGroup, InputGroupText} from 'vue3-bootstrap-components';
3
- import {computed, inject} from "vue";
3
+ import {computed, defineComponent, inject} from "vue";
4
4
  import QuantityInput from "./QuantityInput.vue";
5
5
  import GroupControl from "./GroupControl.vue";
6
6
 
7
- export default {
7
+ export default defineComponent({
8
8
  components: {GroupControl, QuantityInput, InputGroup, InputGroupText, Dropdown, DropdownToggle, DropdownMenu},
9
9
  props: {
10
10
  name: {
@@ -97,7 +97,7 @@ export default {
97
97
  showDropdown : false,
98
98
  }
99
99
  }
100
- }
100
+ })
101
101
  </script>
102
102
  <template>
103
103
  <div ref="input" class="multi-quantity-input fanum">
@@ -1,7 +1,8 @@
1
1
  <script>
2
2
  import TextInput from "./TextInput.vue";
3
+ import {defineComponent} from "vue";
3
4
 
4
- export default {
5
+ export default defineComponent({
5
6
  components: {
6
7
  TextInput
7
8
  },
@@ -12,7 +13,7 @@ export default {
12
13
  required: true,
13
14
  },
14
15
  },
15
- }
16
+ })
16
17
  </script>
17
18
  <template>
18
19
  <TextInput
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import Vue3PersianDatetimePicker from 'vue3-persian-datetime-picker';
3
- import {computed, inject} from "vue";
3
+ import {computed, defineComponent, inject} from "vue";
4
4
 
5
- export default {
5
+ export default defineComponent({
6
6
  components: {Vue3PersianDatetimePicker},
7
7
  props: {
8
8
  name: {
@@ -74,7 +74,7 @@ export default {
74
74
  data() {
75
75
  return {}
76
76
  }
77
- }
77
+ })
78
78
  </script>
79
79
 
80
80
  <template>
@@ -1,8 +1,8 @@
1
1
  <script>
2
2
  import {InputGroup, InputGroupText} from 'vue3-bootstrap-components';
3
- import {computed, inject} from "vue";
3
+ import {computed, defineComponent, inject} from "vue";
4
4
 
5
- export default {
5
+ export default defineComponent({
6
6
  components: {InputGroup, InputGroupText},
7
7
  props: {
8
8
  name: {
@@ -80,7 +80,7 @@ export default {
80
80
  data() {
81
81
  return {}
82
82
  }
83
- }
83
+ })
84
84
  </script>
85
85
  <template>
86
86
  <InputGroup class="input-group-quantity">
@@ -1,13 +1,14 @@
1
1
  <script>
2
2
  import {Spinner} from "vue3-bootstrap-components";
3
+ import {defineComponent} from "vue";
3
4
 
4
- export default {
5
+ export default defineComponent({
5
6
  components: {
6
7
  Spinner
7
8
  },
8
9
  inject: ['form'],
9
10
  props: {},
10
- }
11
+ })
11
12
  </script>
12
13
  <template>
13
14
  <button