inertia-bootstrap-forms 1.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.
@@ -0,0 +1,9 @@
1
+ <script>
2
+ export default {}
3
+ </script>
4
+
5
+ <template>
6
+ <div class="input-group">
7
+ <slot/>
8
+ </div>
9
+ </template>
@@ -0,0 +1,9 @@
1
+ <script>
2
+ export default {}
3
+ </script>
4
+
5
+ <template>
6
+ <div class="input-group-text">
7
+ <slot/>
8
+ </div>
9
+ </template>
@@ -0,0 +1,64 @@
1
+ <script>
2
+ import InputGroup from '../Bootstrap/InputGroup.vue';
3
+ import InputGroupText from '../Bootstrap/InputGroupText.vue';
4
+ import {inject} from "vue";
5
+
6
+ export default {
7
+ components: {InputGroup, InputGroupText},
8
+ props: {
9
+ name: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ required: Boolean,
14
+ disabled: Boolean,
15
+ readonly: Boolean,
16
+ placeholder: {
17
+ type: String,
18
+ default: 'عدد را وارد کنید'
19
+ },
20
+ unit: {
21
+ type: String,
22
+ default: 'عدد'
23
+ },
24
+ },
25
+ setup(props) {
26
+ let form = inject('form');
27
+
28
+ if (form === undefined) {
29
+ form = {
30
+ errors: {},
31
+ getID(name) {
32
+ }
33
+ };
34
+ }
35
+
36
+ return {form};
37
+ },
38
+ methods: {
39
+ onChange(event) {
40
+ this.form[this.name] = parseFloat(this.$number.toEnglish(event.detail?.unmasked));
41
+ this.$emit('update:modelValue', parseFloat(this.$number.toEnglish(event.detail?.unmasked)));
42
+ }
43
+ }
44
+ }
45
+ </script>
46
+ <template>
47
+ <InputGroup>
48
+ <input
49
+ :name="name"
50
+ :value="form[name]"
51
+ v-maska
52
+ data-maska="###,###,###,###,###,###,###"
53
+ data-maska-reversed
54
+ @maska="onChange"
55
+ :class="{'is-invalid': form.errors[name]}"
56
+ :disabled="disabled || form.processing"
57
+ :readonly="readonly"
58
+ :placeholder="placeholder"
59
+ type="tel"
60
+ class="form-control fanum text-start">
61
+ <InputGroupText class="fanum">{{ unit }}</InputGroupText>
62
+ <slot name="suffix"/>
63
+ </InputGroup>
64
+ </template>
@@ -0,0 +1,100 @@
1
+ <script>
2
+ import TextInput from "./TextInput.vue";
3
+
4
+ export default {
5
+ components: {TextInput},
6
+ props: {
7
+ name: {
8
+ type: String,
9
+ default: 'captcha',
10
+ required: false,
11
+ },
12
+ modelValue: '',
13
+ required: Boolean,
14
+ placeholder: {
15
+ default: 'کد امنیتی روبرو را وارد کنید',
16
+ },
17
+ },
18
+ emits: ['update:modelValue'],
19
+ inject: ['form'],
20
+ watch: {
21
+ 'form.processing': {
22
+ handler: function (val, old) {
23
+ if (val !== old && !val) {
24
+ this.getSrc();
25
+ this.emptyField();
26
+ }
27
+ },
28
+ deep: false,
29
+ immediate: false,
30
+ }
31
+ },
32
+ methods: {
33
+ emptyField() {
34
+ if (this.form) {
35
+ this.form[this.name] = null;
36
+ }
37
+ },
38
+ async getSrc() {
39
+ this.loading = true;
40
+ this.src = '/captcha/default?t=' + Math.random();
41
+
42
+ let _this = this;
43
+ setTimeout(function () {
44
+ _this.loading = false;
45
+ }, 500)
46
+ }
47
+ },
48
+ data() {
49
+ return {
50
+ loading: false,
51
+ src: '/captcha/default?t=' + Math.random(),
52
+ };
53
+ }
54
+ };
55
+
56
+ </script>
57
+ <template>
58
+ <div class="input-group captcha">
59
+ <TextInput
60
+ :name="name"
61
+ class="text-start"
62
+ type="tel"/>
63
+ <img
64
+ :src="src"
65
+ alt="captcha"
66
+ @click="getSrc"
67
+ v-if="!loading"
68
+ class="captcha-holder">
69
+ <div class="placeholder-wave captcha-holder" v-else>
70
+ <div class="placeholder w-100 h-100"></div>
71
+ </div>
72
+ <button
73
+ type="button"
74
+ :disabled="form.processing || loading"
75
+ @click="getSrc"
76
+ class="btn btn-secondary border-0">
77
+ <i class="fal fa-sync-alt align-middle"></i>
78
+ </button>
79
+ </div>
80
+ </template>
81
+ <style>
82
+ .captcha .captcha-holder {
83
+ cursor: pointer;
84
+ width: 82px;
85
+ height: 43px;
86
+ object-fit: contain;
87
+ border-top: 1px solid var(--bs-border-color);
88
+ border-bottom: 1px solid var(--bs-border-color);
89
+ }
90
+
91
+ .input-group-lg.captcha .captcha-holder {
92
+ width: 100px;
93
+ height: auto;
94
+ }
95
+
96
+ .captcha .btn-refresh {
97
+ background-color: var(--bs-body-bg);
98
+ border-color: var(--bs-border-color) !important;
99
+ }
100
+ </style>
@@ -0,0 +1,56 @@
1
+ <script>
2
+ import {inject} from "vue";
3
+
4
+ export default {
5
+ props: {
6
+ name: {
7
+ type: String,
8
+ required: true,
9
+ },
10
+ id: {
11
+ type: String,
12
+ default: '',
13
+ required: false,
14
+ },
15
+ value: {
16
+ type: String,
17
+ default: 'yes',
18
+ required: false,
19
+ },
20
+ type: {
21
+ type: String,
22
+ default: 'checkbox',
23
+ required: false,
24
+ },
25
+ },
26
+ setup(props) {
27
+ let form = inject('form');
28
+
29
+ if (form === undefined) {
30
+ form = {
31
+ errors: {},
32
+ getID(name) {
33
+ }
34
+ };
35
+ }
36
+
37
+ return {form};
38
+ },
39
+ }
40
+ </script>
41
+ <template>
42
+ <div class="form-check">
43
+ <input
44
+ :name="name"
45
+ :id="form.getID(name)+(id || value)"
46
+ v-model="form[this.name]"
47
+ :class="{'is-invalid': form?.errors[name]}"
48
+ :disabled="form?.processing"
49
+ :type="type"
50
+ :value="value"
51
+ class="form-check-input">
52
+ <label class="form-check-label" :for="form.getID(name)+(id || value)">
53
+ <slot/>
54
+ </label>
55
+ </div>
56
+ </template>
@@ -0,0 +1,137 @@
1
+ <script>
2
+ import Vue3PersianDatetimePicker from 'vue3-persian-datetime-picker';
3
+ import Icon from "@/Components/Icon.vue";
4
+ import {inject} from "vue";
5
+
6
+ export default {
7
+ components: {Icon, Vue3PersianDatetimePicker},
8
+ props: {
9
+ name: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ calendar: {
14
+ type: String,
15
+ default: 'date',
16
+ },
17
+ view: {
18
+ type: String,
19
+ default: 'date',
20
+ },
21
+ min: String,
22
+ max: String,
23
+ format: {
24
+ type: String,
25
+ default: 'jYYYY-jMM-jDD',
26
+ },
27
+ inputFormat: {
28
+ type: String,
29
+ default: null,
30
+ },
31
+ placeholder: String,
32
+ },
33
+ emits: ['update:modelValue'],
34
+ setup(props) {
35
+ let form = inject('form');
36
+
37
+ if (form === undefined) {
38
+ form = {
39
+ errors: {},
40
+ getID(name) {
41
+ }
42
+ };
43
+ }
44
+
45
+ return {form};
46
+ },
47
+ methods: {
48
+ clear() {
49
+ if (this.form && this.form[this.name]) this.form[this.name] = null;
50
+ }
51
+ },
52
+ computed: {
53
+ isSsr() {
54
+ return !window || !document;
55
+ },
56
+ },
57
+ data() {
58
+ return {}
59
+ }
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <div class="input-group">
65
+ <input
66
+ :name="name"
67
+ :id="name+'Input'"
68
+ :value="form[name]"
69
+ :placeholder="(placeholder || 'انتخاب تاریخ')"
70
+ :class="{'is-invalid': form.errors[name]}"
71
+ :disabled="form?.processing"
72
+ type="text" class="form-control form-control--datepicker text-start fanum">
73
+ <button
74
+ type="button"
75
+ @click="clear"
76
+ class="input-group-text input-group-datepicker-delete"
77
+ :class="{'input-group-datepicker-delete-show': form[name]}">
78
+ <Icon icon="times" library="fal"></Icon>
79
+ <Icon icon="calendars" library="fal"></Icon>
80
+ </button>
81
+ </div>
82
+ <Vue3PersianDatetimePicker
83
+ :type="calendar"
84
+ :view="view"
85
+ :min="min"
86
+ :max="max"
87
+ v-if="!isSsr"
88
+ jumpminute="15"
89
+ :simple="false"
90
+ :roundminute="true"
91
+ :showNowBtn="true"
92
+ :autoSubmit="true"
93
+ :format="format"
94
+ :inputFormat="(inputFormat ? inputFormat : format)"
95
+ :displayFormat="format"
96
+ v-model="form[name]"
97
+ :custom-input="'#'+name+'Input'"/>
98
+ </template>
99
+ <style>
100
+ .form-control--datepicker {
101
+ direction: rtl;
102
+ }
103
+
104
+ .input-group-datepicker-delete {
105
+ width: 42px;
106
+ text-align: center;
107
+ }
108
+
109
+ .input-group-datepicker-delete .fa-times {
110
+ display: none;
111
+ }
112
+
113
+ .input-group-datepicker-delete-show:hover .fa-times {
114
+ display: block;
115
+ }
116
+
117
+ .input-group-datepicker-delete-show:hover .fa-calendars {
118
+ display: none;
119
+ }
120
+
121
+ .vpd-content {
122
+ color: var(--bs-body-color) !important;
123
+ background-color: var(--bs-body-bg) !important;
124
+ -moz-font-feature-settings: "ss01";
125
+ -webkit-font-feature-settings: "ss01";
126
+ font-feature-settings: "ss01";
127
+ }
128
+
129
+ .vpd-time .vpd-down-arrow-btn, .vpd-time .vpd-up-arrow-btn{
130
+ text-align: center;
131
+ }
132
+
133
+ .vpd-time .vpd-down-arrow-btn svg,
134
+ .vpd-time .vpd-up-arrow-btn svg{
135
+ margin: 0 auto;
136
+ }
137
+ </style>
@@ -0,0 +1,131 @@
1
+ <script>
2
+ import Editor from '@tinymce/tinymce-vue';
3
+ import {inject} from "vue";
4
+
5
+ export default {
6
+ components: {Editor},
7
+ props: {
8
+ name: {
9
+ type: String,
10
+ required: true,
11
+ },
12
+ modelValue: String,
13
+ placeholder: {
14
+ type: String,
15
+ default: 'اینجا بنویسید...',
16
+ },
17
+ invalid: Boolean,
18
+ allowLink: Boolean,
19
+ height: Number,
20
+ useStyle: {
21
+ type: Boolean,
22
+ default: false,
23
+ },
24
+ modules: {
25
+ default: [],
26
+ required: false,
27
+ },
28
+ },
29
+ setup(props) {
30
+ let form = inject('form');
31
+
32
+ if (form === undefined) {
33
+ form = {
34
+ errors: {},
35
+ getID(name) {
36
+ }
37
+ };
38
+ }
39
+
40
+ return {form};
41
+ },
42
+ emits: ['update:modelValue'],
43
+ }
44
+ </script>
45
+
46
+ <template>
47
+ <Editor
48
+ api-key="tbws10u99swxhai03qolxykukvqw99jd4nw9q8z34aocvc4r"
49
+ tinymce-script-src="/js/tinymce/tinymce.min.js"
50
+ v-model="form[name]"
51
+ :init="{
52
+ base_url: '/js/tinymce/',
53
+ disabled: true,
54
+ inline: false,
55
+ toolbar_sticky: true,
56
+ menubar: false,
57
+ branding: false,
58
+ font_formats: true,
59
+ directionality: 'rtl',
60
+ placeholder: placeholder,
61
+ plugins: [
62
+ ...modules,
63
+ 'link',
64
+ 'lists',
65
+ 'directionality',
66
+ 'fullscreen',
67
+ 'wordcount',
68
+ 'table',
69
+ 'autosave',
70
+ 'autoresize',
71
+ ],
72
+ style_formats : [
73
+ {title : 'وسط چین', classes : 'text-center', block: 'div'},
74
+ {title : 'فاصله از بالا و پایین', classes : 'my-3', block: 'div'},
75
+ {title : 'باکس اطلاعات', classes : 'code-box', block: 'span'},
76
+ ],
77
+ setup: function(editor) {
78
+ // editor.on('init', function(e) {
79
+ // editor.setContent(modelValue || '');
80
+ // });
81
+ //
82
+ // editor.on('paste cut reset keyup input focusout', function(e) {
83
+ // // console.log('form', form);
84
+ // // $emit('update:modelValue', editor.getContent());
85
+ // });
86
+ },
87
+ language: 'fa',
88
+ toolbar: (useStyle ? 'styles |' : '') + 'fontsize | bold italic h1 h2 h3 h4 | link | numlist bullist | alignjustify aligncenter | table image link unlink | rtl ltr | pagebreak codesample | fullscreen code',
89
+ fullscreen: true,
90
+ auto_save: true,
91
+ auto_link: true,
92
+ // images_upload_url: 'files/upload',
93
+ // images_upload_handler: this.uploader,
94
+ images_file_types: 'jpeg,jpg,png',
95
+ autoresize_bottom_margin: 50,
96
+ allow_link: !!this.allowLink,
97
+ allow_style: true,
98
+ allow_link_style: false,
99
+ height: this.height || 400,
100
+ min_height: this.height || 400,
101
+ allow_code: false,
102
+ autoresize_on_init: true,
103
+ autosave_ask_before_unload: false,
104
+ autosave_interval: '5s',
105
+ autosave_restore_when_empty: true,
106
+ paste_data_images: false,
107
+ paste_block_drop: false,
108
+ relative_urls: false,
109
+ remove_script_host: false,
110
+ paste_as_text: true,
111
+ valid_elements: 'p,a,b,strong,i,em,h1,h2,h3,h4,h5,ul,ol,li,img,br',
112
+ paste_word_valid_elements: 'p,a,b,strong,i,em,h1,h2,h3,h4,h5,ul,ol,li,img,br',
113
+ paste_tab_spaces: 0,
114
+ default_link_target: '_blank',
115
+ link_assume_external_targets: true,
116
+ link_quicklink: true,
117
+ powerpaste_word_import: 'clean',
118
+ powerpaste_html_import: 'clean',
119
+ auto_refresh_interval: 500,
120
+ convert_urls: false,
121
+ verify_html: false,
122
+ valid_children: '+a[div|h1|h2|h3|h4|h5|h6|p|#text]',
123
+ }"
124
+ />
125
+ </template>
126
+ <style scoped>
127
+ textarea {
128
+ width: 100%;
129
+ min-height: 200px;
130
+ }
131
+ </style>
@@ -0,0 +1,22 @@
1
+ <script>
2
+ import TextInput from "./TextInput.vue";
3
+
4
+ export default {
5
+ components: {
6
+ TextInput
7
+ },
8
+ props: {
9
+ name: {
10
+ type: String,
11
+ default: 'email',
12
+ required: true,
13
+ },
14
+ },
15
+ }
16
+ </script>
17
+ <template>
18
+ <TextInput
19
+ :name="name"
20
+ placeholder="ایمیل خود را وارد کنید"
21
+ type="email"/>
22
+ </template>