inertia-bootstrap-forms 1.0.4 → 1.0.7
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/package.json +3 -3
- package/src/MultiQuantityInput.vue +113 -49
- package/src/QuantityInput.vue +102 -79
- package/src/index.js +51 -0
- package/index.js +0 -49
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inertia-bootstrap-forms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Create bootstrap forms with inertia and twitter bootstrap",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "index.js",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"module": "src/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -1,68 +1,132 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {Dropdown, DropdownToggle, DropdownMenu, InputGroup, InputGroupText} from 'vue3-bootstrap-components';
|
|
3
|
-
import {inject} from "vue";
|
|
3
|
+
import {computed, inject} from "vue";
|
|
4
|
+
import QuantityInput from "./QuantityInput.vue";
|
|
5
|
+
import GroupControl from "./GroupControl.vue";
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
required: Boolean,
|
|
13
|
-
disabled: Boolean,
|
|
14
|
-
readonly: Boolean,
|
|
15
|
-
unit: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'عدد'
|
|
18
|
-
},
|
|
8
|
+
components: {GroupControl, QuantityInput, InputGroup, InputGroupText, Dropdown, DropdownToggle, DropdownMenu},
|
|
9
|
+
props: {
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
19
13
|
},
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
required: Boolean,
|
|
15
|
+
disabled: Boolean,
|
|
16
|
+
readonly: Boolean,
|
|
17
|
+
options: {
|
|
18
|
+
type: Array,
|
|
19
|
+
default: [],
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
max: {
|
|
23
|
+
type: Number,
|
|
24
|
+
},
|
|
25
|
+
totalMax: {
|
|
26
|
+
type: Number,
|
|
27
|
+
},
|
|
28
|
+
min: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 1,
|
|
31
|
+
},
|
|
32
|
+
totalMin: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: 1,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
setup(props) {
|
|
38
|
+
let form = inject('form');
|
|
39
|
+
let group = inject('group', {});
|
|
22
40
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
};
|
|
41
|
+
if (form === undefined) {
|
|
42
|
+
form = {
|
|
43
|
+
errors: {},
|
|
44
|
+
getID(name) {
|
|
29
45
|
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
if (!form[props.name]) {
|
|
50
|
+
form[props.name] = 1;
|
|
51
|
+
}
|
|
34
52
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!this.max || (this.max < this.form[this.name])) {
|
|
45
|
-
this.form[this.name]++;
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
decrement() {
|
|
49
|
-
if ((!this.min || (this.min < this.form[this.name])) && this.form[this.name] > 1) {
|
|
50
|
-
this.form[this.name]--;
|
|
51
|
-
}
|
|
53
|
+
const modelValue = computed({
|
|
54
|
+
get() {
|
|
55
|
+
return (group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name];
|
|
56
|
+
},
|
|
57
|
+
set(value) {
|
|
58
|
+
if (group?.value?.name) {
|
|
59
|
+
group.value.setData(props.name, value);
|
|
60
|
+
} else {
|
|
61
|
+
form.value[props.name] = value;
|
|
52
62
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return {modelValue, form};
|
|
67
|
+
},
|
|
68
|
+
methods: {},
|
|
69
|
+
data() {
|
|
70
|
+
return {}
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
</script>
|
|
59
74
|
<template>
|
|
60
|
-
<Dropdown>
|
|
61
|
-
<DropdownToggle>
|
|
75
|
+
<Dropdown class="multi-quantity-input">
|
|
76
|
+
<DropdownToggle class="form-control" data-bs-auto-close="outside">
|
|
77
|
+
asdsa
|
|
78
|
+
</DropdownToggle>
|
|
62
79
|
<DropdownMenu>
|
|
63
|
-
|
|
80
|
+
<GroupControl :name="name">
|
|
81
|
+
<div class="row align-items-center justify-content-between" v-for="(item, key) in options">
|
|
82
|
+
<div class="col-auto">
|
|
83
|
+
{{ item?.name || item }}
|
|
84
|
+
</div>
|
|
85
|
+
<div class="col-auto">
|
|
86
|
+
<QuantityInput :name="key" :min="(item.min || min)" :max="(item.max || max)"/>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</GroupControl>
|
|
64
90
|
</DropdownMenu>
|
|
65
91
|
</Dropdown>
|
|
66
92
|
</template>
|
|
67
93
|
<style>
|
|
94
|
+
.multi-quantity-input .dropdown-menu {
|
|
95
|
+
width: 100%;
|
|
96
|
+
padding: 10px 15px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.multi-quantity-input .input-group {
|
|
100
|
+
align-items: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.multi-quantity-input .input-group .input-group-text {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.multi-quantity-input .input-group .form-control {
|
|
108
|
+
width: 50px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.multi-quantity-input .input-group .btn {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-content: center;
|
|
114
|
+
align-items: center;
|
|
115
|
+
width: 25px;
|
|
116
|
+
height: 25px;
|
|
117
|
+
border-radius: 50% !important;
|
|
118
|
+
padding: 5px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.multi-quantity-input .input-group .btn,
|
|
122
|
+
.multi-quantity-input .input-group .btn:active,
|
|
123
|
+
.multi-quantity-input .input-group .btn:focus {
|
|
124
|
+
background-color: var(--bs-primary, #de0021);
|
|
125
|
+
color: #ffffff;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.multi-quantity-input .input-group .btn svg,
|
|
129
|
+
.multi-quantity-input .input-group .btn svg path {
|
|
130
|
+
fill: #ffffff;
|
|
131
|
+
}
|
|
68
132
|
</style>
|
package/src/QuantityInput.vue
CHANGED
|
@@ -1,106 +1,129 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {InputGroup, InputGroupText} from 'vue3-bootstrap-components';
|
|
3
|
-
import {inject} from "vue";
|
|
3
|
+
import {computed, inject} from "vue";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
required: Boolean,
|
|
13
|
-
disabled: Boolean,
|
|
14
|
-
readonly: Boolean,
|
|
15
|
-
unit: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'عدد'
|
|
18
|
-
},
|
|
6
|
+
components: {InputGroup, InputGroupText},
|
|
7
|
+
props: {
|
|
8
|
+
name: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true,
|
|
19
11
|
},
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
required: Boolean,
|
|
13
|
+
disabled: Boolean,
|
|
14
|
+
readonly: Boolean,
|
|
15
|
+
unit: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'عدد'
|
|
18
|
+
},
|
|
19
|
+
min: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 1
|
|
22
|
+
},
|
|
23
|
+
max: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 1
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
setup(props) {
|
|
29
|
+
let form = inject('form');
|
|
30
|
+
let group = inject('group', {});
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
};
|
|
32
|
+
if (form === undefined) {
|
|
33
|
+
form = {
|
|
34
|
+
errors: {},
|
|
35
|
+
getID(name) {
|
|
29
36
|
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
if (!form[props.name]) {
|
|
41
|
+
form[props.name] = 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const modelValue = computed({
|
|
45
|
+
get() {
|
|
46
|
+
return ((group.value && form.value[group.value.name]) ? group.value?.getData(props.name) : form.value[props.name]);
|
|
47
|
+
},
|
|
48
|
+
set(value) {
|
|
49
|
+
if (group?.value?.name) {
|
|
50
|
+
group.value.setData(props.name, value);
|
|
51
|
+
} else {
|
|
52
|
+
form.value[props.name] = value;
|
|
33
53
|
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
34
56
|
|
|
35
|
-
|
|
57
|
+
return {modelValue, group, form};
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
onChange(event) {
|
|
61
|
+
let value = parseFloat(this.$number.toEnglish(event.detail?.unmasked)) || 1;
|
|
62
|
+
this.$emit('update:modelValue', value);
|
|
63
|
+
this.modelValue = value;
|
|
36
64
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.$emit('update:modelValue', value);
|
|
42
|
-
},
|
|
43
|
-
increment() {
|
|
44
|
-
if (!this.max || (this.max < this.form[this.name])) {
|
|
45
|
-
this.form[this.name]++;
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
decrement() {
|
|
49
|
-
if ((!this.min || (this.min < this.form[this.name])) && this.form[this.name] > 1) {
|
|
50
|
-
this.form[this.name]--;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
65
|
+
increment() {
|
|
66
|
+
if (!this.max || (this.max < this.modelValue)) {
|
|
67
|
+
this.modelValue = this.modelValue + 1;
|
|
68
|
+
}
|
|
53
69
|
},
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
decrement() {
|
|
71
|
+
if ((!this.min || (this.min < this.modelValue)) && this.modelValue > 1) {
|
|
72
|
+
this.modelValue = this.modelValue - 1;
|
|
73
|
+
}
|
|
56
74
|
}
|
|
75
|
+
},
|
|
76
|
+
data() {
|
|
77
|
+
return {}
|
|
78
|
+
}
|
|
57
79
|
}
|
|
58
80
|
</script>
|
|
59
81
|
<template>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
<InputGroup class="input-group-quantity">
|
|
83
|
+
<button @click="increment" type="button" class="btn">
|
|
84
|
+
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
85
|
+
<path
|
|
86
|
+
d="M13 3C13 2.44772 12.5523 2 12 2C11.4477 2 11 2.44772 11 3V11H3C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13H11V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V13H21C21.5523 13 22 12.5523 22 12C22 11.4477 21.5523 11 21 11H13V3Z"
|
|
87
|
+
fill="#0F0F0F"/>
|
|
88
|
+
</svg>
|
|
89
|
+
</button>
|
|
90
|
+
<input
|
|
91
|
+
:name="name"
|
|
92
|
+
:value="this.modelValue"
|
|
93
|
+
v-maska
|
|
94
|
+
data-maska="###,###,###,###,###,###,###"
|
|
95
|
+
data-maska-reversed
|
|
96
|
+
@maska="onChange"
|
|
97
|
+
:class="{'is-invalid': form.errors[name]}"
|
|
98
|
+
:disabled="disabled || form.processing"
|
|
99
|
+
:readonly="readonly"
|
|
100
|
+
type="tel"
|
|
101
|
+
class="form-control fanum text-center">
|
|
102
|
+
<button @click="decrement" type="button" class="btn">
|
|
103
|
+
<svg width="800px" height="800px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="none">
|
|
104
|
+
<path fill="#000000" fill-rule="evenodd" d="M18 10a1 1 0 01-1 1H3a1 1 0 110-2h14a1 1 0 011 1z"/>
|
|
105
|
+
</svg>
|
|
106
|
+
</button>
|
|
107
|
+
<InputGroupText class="fanum">{{ unit }}</InputGroupText>
|
|
108
|
+
<slot name="suffix"/>
|
|
109
|
+
</InputGroup>
|
|
87
110
|
</template>
|
|
88
111
|
<style>
|
|
89
112
|
|
|
90
113
|
.input-group-quantity .input-group-text,
|
|
91
|
-
.input-group-quantity .btn{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
.input-group-quantity .btn {
|
|
115
|
+
background-color: var(--bs-body-bg);
|
|
116
|
+
--bs-btn-hover-bg: var(--bs-secondary-bg);
|
|
117
|
+
--bs-btn-active-bg: var(--bs-secondary-bg);
|
|
95
118
|
}
|
|
96
119
|
|
|
97
|
-
.input-group-quantity input.form-control{
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
.input-group-quantity input.form-control {
|
|
121
|
+
border: 0 !important;
|
|
122
|
+
box-shadow: none !important;
|
|
100
123
|
}
|
|
101
124
|
|
|
102
125
|
.input-group-quantity .btn svg {
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
width: 14px;
|
|
127
|
+
height: 14px;
|
|
105
128
|
}
|
|
106
129
|
</style>
|
package/src/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import AmountInput from "./AmountInput.vue";
|
|
2
|
+
import CaptchaInput from "./CaptchaInput.vue";
|
|
3
|
+
import CheckboxButtonInput from "./CheckboxButtonInput.vue";
|
|
4
|
+
import CheckboxInput from "./CheckboxInput.vue";
|
|
5
|
+
import CheckboxToggle from "./CheckboxToggle.vue";
|
|
6
|
+
import PersianDatePickerInput from "./PersianDatePickerInput.vue";
|
|
7
|
+
import EditorInput from "./EditorInput.vue";
|
|
8
|
+
import FileInput from "./FileInput.vue";
|
|
9
|
+
import EmailInput from "./EmailInput.vue";
|
|
10
|
+
import GroupControl from "./GroupControl.vue";
|
|
11
|
+
import FormContainer from "./FormContainer.vue";
|
|
12
|
+
import FormLabel from "./FormLabel.vue";
|
|
13
|
+
import locationInput from "./locationInput.vue";
|
|
14
|
+
import MobileInput from "./MobileInput.vue";
|
|
15
|
+
import PasswordInput from "./PasswordInput.vue";
|
|
16
|
+
import QuantityInput from "./QuantityInput.vue";
|
|
17
|
+
import MultiQuantityInput from "./MultiQuantityInput.vue";
|
|
18
|
+
import SecondarySubmitButton from "./SecondarySubmitButton.vue";
|
|
19
|
+
import Select2Input from "./Select2Input.vue";
|
|
20
|
+
import StarRatingInput from "./StarRatingInput.vue";
|
|
21
|
+
import SubmitButton from "./SubmitButton.vue";
|
|
22
|
+
import TelInput from "./TelInput.vue";
|
|
23
|
+
import TextAreaInput from "./TextAreaInput.vue";
|
|
24
|
+
import TextInput from "./TextInput.vue";
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
AmountInput,
|
|
28
|
+
CaptchaInput,
|
|
29
|
+
CheckboxButtonInput,
|
|
30
|
+
CheckboxInput,
|
|
31
|
+
CheckboxToggle,
|
|
32
|
+
FileInput,
|
|
33
|
+
EmailInput,
|
|
34
|
+
PersianDatePickerInput,
|
|
35
|
+
EditorInput,
|
|
36
|
+
GroupControl,
|
|
37
|
+
FormContainer,
|
|
38
|
+
locationInput,
|
|
39
|
+
MobileInput,
|
|
40
|
+
PasswordInput,
|
|
41
|
+
QuantityInput,
|
|
42
|
+
MultiQuantityInput,
|
|
43
|
+
SubmitButton,
|
|
44
|
+
SecondarySubmitButton,
|
|
45
|
+
StarRatingInput,
|
|
46
|
+
Select2Input,
|
|
47
|
+
FormLabel,
|
|
48
|
+
TelInput,
|
|
49
|
+
TextAreaInput,
|
|
50
|
+
TextInput,
|
|
51
|
+
}
|
package/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import AmountInput from "./src/AmountInput.vue";
|
|
2
|
-
import CaptchaInput from "./src/CaptchaInput.vue";
|
|
3
|
-
import CheckboxButtonInput from "./src/CheckboxButtonInput.vue";
|
|
4
|
-
import CheckboxInput from "./src/CheckboxInput.vue";
|
|
5
|
-
import CheckboxToggle from "./src/CheckboxToggle.vue";
|
|
6
|
-
import PersianDatePickerInput from "./src/PersianDatePickerInput.vue";
|
|
7
|
-
import EditorInput from "./src/EditorInput.vue";
|
|
8
|
-
import FileInput from "./src/FileInput.vue";
|
|
9
|
-
import EmailInput from "./src/EmailInput.vue";
|
|
10
|
-
import GroupControl from "./src/GroupControl.vue";
|
|
11
|
-
import FormContainer from "./src/FormContainer.vue";
|
|
12
|
-
import FormLabel from "./src/FormLabel.vue";
|
|
13
|
-
import locationInput from "./src/locationInput.vue";
|
|
14
|
-
import MobileInput from "./src/MobileInput.vue";
|
|
15
|
-
import PasswordInput from "./src/PasswordInput.vue";
|
|
16
|
-
import QuantityInput from "./src/QuantityInput.vue";
|
|
17
|
-
import SecondarySubmitButton from "./src/SecondarySubmitButton.vue";
|
|
18
|
-
import Select2Input from "./src/Select2Input.vue";
|
|
19
|
-
import StarRatingInput from "./src/StarRatingInput.vue";
|
|
20
|
-
import SubmitButton from "./src/SubmitButton.vue";
|
|
21
|
-
import TelInput from "./src/TelInput.vue";
|
|
22
|
-
import TextAreaInput from "./src/TextAreaInput.vue";
|
|
23
|
-
import TextInput from "./src/TextInput.vue";
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
AmountInput,
|
|
27
|
-
CaptchaInput,
|
|
28
|
-
CheckboxButtonInput,
|
|
29
|
-
CheckboxInput,
|
|
30
|
-
CheckboxToggle,
|
|
31
|
-
FileInput,
|
|
32
|
-
EmailInput,
|
|
33
|
-
PersianDatePickerInput,
|
|
34
|
-
EditorInput,
|
|
35
|
-
GroupControl,
|
|
36
|
-
FormContainer,
|
|
37
|
-
locationInput,
|
|
38
|
-
MobileInput,
|
|
39
|
-
PasswordInput,
|
|
40
|
-
QuantityInput,
|
|
41
|
-
SubmitButton,
|
|
42
|
-
SecondarySubmitButton,
|
|
43
|
-
StarRatingInput,
|
|
44
|
-
Select2Input,
|
|
45
|
-
FormLabel,
|
|
46
|
-
TelInput,
|
|
47
|
-
TextAreaInput,
|
|
48
|
-
TextInput,
|
|
49
|
-
}
|