toggle-components-library 1.10.1
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.md +24 -0
- package/babel.config.js +5 -0
- package/dist/demo.html +10 -0
- package/dist/img/add_circle.7c6b29c6.svg +29 -0
- package/dist/img/arrow-left-blue-hover.5b0a1e54.svg +32 -0
- package/dist/img/arrow-left-blue.1e5404dd.svg +32 -0
- package/dist/img/arrow-right-blue-hover.b800a882.svg +32 -0
- package/dist/img/arrow-right-blue.fbc83729.svg +32 -0
- package/dist/img/arrow_down.787e1a8b.svg +28 -0
- package/dist/img/calendar.16f176cd.svg +37 -0
- package/dist/img/card.e1735960.svg +9 -0
- package/dist/img/checkbox_blank.907b325c.svg +6 -0
- package/dist/img/checkbox_checked.3e2d399f.svg +9 -0
- package/dist/img/checkbox_hover.e99ab40c.svg +3 -0
- package/dist/img/checkbox_inactive.b94b6c81.svg +9 -0
- package/dist/img/circle_blank.ab1622db.svg +24 -0
- package/dist/img/clipboard.e483ded3.svg +12 -0
- package/dist/img/delete-grey.cf15dcd1.svg +29 -0
- package/dist/img/delete.ee71bb54.svg +29 -0
- package/dist/img/drag_drop.0c778868.svg +14 -0
- package/dist/img/draggable.7493006c.svg +1 -0
- package/dist/img/edit_circle.4f3826d3.svg +34 -0
- package/dist/img/edit_circle_grey.0c96938c.svg +34 -0
- package/dist/img/email.078e944d.svg +7 -0
- package/dist/img/file.f4fb9e5d.svg +9 -0
- package/dist/img/graph.7f2e3985.svg +16 -0
- package/dist/img/grey_cross.2ac5fda1.svg +15 -0
- package/dist/img/info.4b233da4.svg +29 -0
- package/dist/img/megaphone.73161a8a.svg +19 -0
- package/dist/img/orders.51f8963f.svg +29 -0
- package/dist/img/search.db8f673f.svg +25 -0
- package/dist/img/tick-grey.b6d7b16c.svg +12 -0
- package/dist/img/tick.97f35963.svg +12 -0
- package/dist/img/tick_circle.417fd97d.svg +28 -0
- package/dist/img/tick_circle_grey.92b7e747.svg +32 -0
- package/dist/img/upload.9b0f1f1c.svg +30 -0
- package/dist/toggle-components-library.common.js +17714 -0
- package/dist/toggle-components-library.common.js.map +1 -0
- package/dist/toggle-components-library.css +1 -0
- package/dist/toggle-components-library.umd.js +17724 -0
- package/dist/toggle-components-library.umd.js.map +1 -0
- package/dist/toggle-components-library.umd.min.js +9 -0
- package/dist/toggle-components-library.umd.min.js.map +1 -0
- package/package-lock.json +20271 -0
- package/package.json +78 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/assets/ProximaNova-Regular.otf +0 -0
- package/src/assets/icons/add_circle.svg +29 -0
- package/src/assets/icons/arrow-left-blue-hover.svg +32 -0
- package/src/assets/icons/arrow-left-blue.svg +32 -0
- package/src/assets/icons/arrow-right-blue-hover.svg +32 -0
- package/src/assets/icons/arrow-right-blue.svg +32 -0
- package/src/assets/icons/arrow_down.svg +28 -0
- package/src/assets/icons/calendar.svg +37 -0
- package/src/assets/icons/card.svg +9 -0
- package/src/assets/icons/checkbox_blank.svg +6 -0
- package/src/assets/icons/checkbox_checked.svg +9 -0
- package/src/assets/icons/checkbox_hover.svg +3 -0
- package/src/assets/icons/checkbox_inactive.svg +9 -0
- package/src/assets/icons/circle_blank.svg +24 -0
- package/src/assets/icons/clipboard.svg +12 -0
- package/src/assets/icons/delete-grey.svg +29 -0
- package/src/assets/icons/delete.svg +29 -0
- package/src/assets/icons/drag.svg +15 -0
- package/src/assets/icons/drag_drop.svg +14 -0
- package/src/assets/icons/draggable.svg +1 -0
- package/src/assets/icons/draggable.textClipping +0 -0
- package/src/assets/icons/edit_circle.svg +34 -0
- package/src/assets/icons/edit_circle_grey.svg +34 -0
- package/src/assets/icons/email.svg +7 -0
- package/src/assets/icons/file.svg +9 -0
- package/src/assets/icons/graph.svg +16 -0
- package/src/assets/icons/grey_cross.svg +15 -0
- package/src/assets/icons/info.svg +29 -0
- package/src/assets/icons/megaphone.svg +19 -0
- package/src/assets/icons/orders.svg +29 -0
- package/src/assets/icons/search.svg +25 -0
- package/src/assets/icons/tick-grey.svg +12 -0
- package/src/assets/icons/tick.svg +12 -0
- package/src/assets/icons/tick_circle.svg +28 -0
- package/src/assets/icons/tick_circle_grey.svg +32 -0
- package/src/assets/icons/upload.svg +30 -0
- package/src/assets/img/airship.svg +42 -0
- package/src/assets/img/toggle.svg +1 -0
- package/src/assets/logo.png +0 -0
- package/src/components/badges/ToggleBadge.vue +23 -0
- package/src/components/breadcrumb/ToggleBreadCrumb.vue +43 -0
- package/src/components/buttons/ToggleButton.vue +88 -0
- package/src/components/buttons/ToggleFeatureButton.vue +68 -0
- package/src/components/elements/ToggleLineBreak.vue +9 -0
- package/src/components/forms/ToggleColourPicker.vue +192 -0
- package/src/components/forms/ToggleDatePicker.vue +168 -0
- package/src/components/forms/ToggleDateRangePicker.vue +208 -0
- package/src/components/forms/ToggleInputCheckbox.vue +74 -0
- package/src/components/forms/ToggleInputCheckboxContainer.vue +65 -0
- package/src/components/forms/ToggleInputCheckboxInline.vue +74 -0
- package/src/components/forms/ToggleInputCrudField.vue +95 -0
- package/src/components/forms/ToggleInputCurrency.vue +198 -0
- package/src/components/forms/ToggleInputFile.vue +101 -0
- package/src/components/forms/ToggleInputGrid.vue +409 -0
- package/src/components/forms/ToggleInputGroup.vue +48 -0
- package/src/components/forms/ToggleInputImage.vue +168 -0
- package/src/components/forms/ToggleInputNumber.vue +164 -0
- package/src/components/forms/ToggleInputPercentage.vue +142 -0
- package/src/components/forms/ToggleInputRadioButtonGroup.vue +81 -0
- package/src/components/forms/ToggleInputRadioButtons.vue +136 -0
- package/src/components/forms/ToggleInputSearch.vue +235 -0
- package/src/components/forms/ToggleInputSelect.vue +109 -0
- package/src/components/forms/ToggleInputText.vue +130 -0
- package/src/components/forms/ToggleInputTextArea.vue +123 -0
- package/src/components/forms/ToggleInputWebsite.vue +163 -0
- package/src/components/forms/ToggleInternationalPhoneInputSelect.vue +166 -0
- package/src/components/loaders/ToggleFillLoader.vue +34 -0
- package/src/components/mixins/mixins.js +48 -0
- package/src/components/modals/ToggleModal.vue +83 -0
- package/src/components/navs/sidenav/ToggleSideNav.vue +45 -0
- package/src/components/navs/sidenav/ToggleSideNavItem.vue +32 -0
- package/src/components/navs/sidenav/ToggleSideSubNav.vue +24 -0
- package/src/components/notifications/ToggleNotifications.vue +93 -0
- package/src/components/tables/TogglePagination.vue +114 -0
- package/src/components/tables/ToggleTable.vue +178 -0
- package/src/components/tables/ToggleTableColumn.vue +3 -0
- package/src/components/tables/ToggleTableRow.vue +5 -0
- package/src/components/text/ToggleHeaderTextLarge.vue +3 -0
- package/src/components/text/ToggleHelperTextSmall.vue +3 -0
- package/src/components/text/ToggleInfoText.vue +3 -0
- package/src/components/text/ToggleTextClipboardCopy.vue +51 -0
- package/src/index.js +105 -0
- package/src/sass/includes/_as_animations.scss +8 -0
- package/src/sass/includes/_as_badges.scss +27 -0
- package/src/sass/includes/_as_breadcrumb.scss +39 -0
- package/src/sass/includes/_as_buttons.scss +235 -0
- package/src/sass/includes/_as_elements.scss +3 -0
- package/src/sass/includes/_as_fonts.scss +12 -0
- package/src/sass/includes/_as_globals.scss +1 -0
- package/src/sass/includes/_as_gridbuilder.scss +136 -0
- package/src/sass/includes/_as_inputs.scss +900 -0
- package/src/sass/includes/_as_loader.scss +37 -0
- package/src/sass/includes/_as_loaders.scss +41 -0
- package/src/sass/includes/_as_modals.scss +83 -0
- package/src/sass/includes/_as_navs.scss +120 -0
- package/src/sass/includes/_as_notifications.scss +30 -0
- package/src/sass/includes/_as_sizes.scss +4 -0
- package/src/sass/includes/_as_table.scss +276 -0
- package/src/sass/includes/_as_text.scss +73 -0
- package/src/sass/includes/_as_variables.scss +49 -0
- package/src/sass/main.scss +20 -0
- package/vue.config.js +8 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid }" v-on:click="focusClosestInput">
|
|
7
|
+
<label
|
|
8
|
+
v-if="label"
|
|
9
|
+
:for="name ? name : 'ToggleInputNumber' "
|
|
10
|
+
class="toggle-input-label"
|
|
11
|
+
> {{ label }}
|
|
12
|
+
</label>
|
|
13
|
+
<input
|
|
14
|
+
:name="name ? name : 'ToggleInputNumber' "
|
|
15
|
+
:class="[ 'toggle-input', size]"
|
|
16
|
+
:placeholder="placeholder ? placeholder : '' "
|
|
17
|
+
:autocomplete="autocomplete ? 'on' : 'off' "
|
|
18
|
+
:required="required"
|
|
19
|
+
v-model="inputVal"
|
|
20
|
+
@blur="isInputActive = false"
|
|
21
|
+
@focus="isInputActive = true"
|
|
22
|
+
:pattern="pattern"
|
|
23
|
+
/>
|
|
24
|
+
<label
|
|
25
|
+
class="toggle-input-label-error"
|
|
26
|
+
v-if="isInvalid"
|
|
27
|
+
:for="name ? name : 'ToggleInputNumber' "
|
|
28
|
+
>
|
|
29
|
+
{{ errorMessage }}
|
|
30
|
+
</label>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
|
|
36
|
+
import { mixins } from '../mixins/mixins'
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
mixins:[mixins],
|
|
40
|
+
props: {
|
|
41
|
+
value: {
|
|
42
|
+
type: [Number, String]
|
|
43
|
+
},
|
|
44
|
+
name: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "ToggleInputNumber"
|
|
47
|
+
},
|
|
48
|
+
label: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
inlineLabel: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
placeholder: {
|
|
57
|
+
type: String,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
autocomplete: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
64
|
+
size: {
|
|
65
|
+
type: String,
|
|
66
|
+
validator: function (value) {
|
|
67
|
+
return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
required: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
74
|
+
isInvalid: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
errorMessage: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false
|
|
81
|
+
},
|
|
82
|
+
currencySymbol:{
|
|
83
|
+
type: String,
|
|
84
|
+
default: '£'
|
|
85
|
+
},
|
|
86
|
+
currencyDenomination:{
|
|
87
|
+
type:Number,
|
|
88
|
+
default:100
|
|
89
|
+
},
|
|
90
|
+
pattern: {
|
|
91
|
+
type:String,
|
|
92
|
+
default:"\\d*"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
created : function(){
|
|
97
|
+
},
|
|
98
|
+
data : function(){
|
|
99
|
+
return {
|
|
100
|
+
isInputActive: false
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
computed: {
|
|
104
|
+
inputVal: {
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
get: function() {
|
|
108
|
+
if (this.isInputActive) {
|
|
109
|
+
// Cursor is inside the input field. unformat display value for user
|
|
110
|
+
return this.value;
|
|
111
|
+
} else {
|
|
112
|
+
// User is not modifying now. Format display value for user interface
|
|
113
|
+
if(this.value === '')
|
|
114
|
+
return '';
|
|
115
|
+
|
|
116
|
+
return this.value + ( this.inlineLabel ? ' ' + this.inlineLabel : '');
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
set: function(modifiedValue) {
|
|
120
|
+
|
|
121
|
+
if(modifiedValue === ''){
|
|
122
|
+
this.$emit('input', modifiedValue);
|
|
123
|
+
}else{
|
|
124
|
+
|
|
125
|
+
let newValue = parseFloat(modifiedValue)
|
|
126
|
+
// Ensure that it is not NaN
|
|
127
|
+
|
|
128
|
+
if (isNaN(newValue))
|
|
129
|
+
newValue = 0;
|
|
130
|
+
|
|
131
|
+
this.$emit('input', newValue);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
methods: {
|
|
141
|
+
|
|
142
|
+
/*
|
|
143
|
+
* Concat message for count characters
|
|
144
|
+
* @return string
|
|
145
|
+
*/
|
|
146
|
+
messageLength(count, maxLenght)
|
|
147
|
+
{
|
|
148
|
+
let mcount = count ? count.length : 0;
|
|
149
|
+
return mcount+' / '+maxLenght;
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
onFocus() {
|
|
153
|
+
this.$emit('onFocus');
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
onBlur(){
|
|
157
|
+
this.$emit('onBlur');
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
</script>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
<div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid }" v-on:click="focusClosestInput">
|
|
4
|
+
|
|
5
|
+
<label
|
|
6
|
+
v-if="label"
|
|
7
|
+
:for="name ? name : 'InputText' "
|
|
8
|
+
class="toggle-input-label"
|
|
9
|
+
> {{ label }}
|
|
10
|
+
</label>
|
|
11
|
+
<input
|
|
12
|
+
:name="name ? name : 'ToggleInputPercentage' "
|
|
13
|
+
:class="[ 'toggle-input', size]"
|
|
14
|
+
:placeholder="placeholder ? placeholder : '' "
|
|
15
|
+
:autocomplete="autocomplete ? 'on' : 'off' "
|
|
16
|
+
:required="required"
|
|
17
|
+
v-model="inputVal"
|
|
18
|
+
@blur="isInputActive = false"
|
|
19
|
+
@focus="isInputActive = true"
|
|
20
|
+
/>
|
|
21
|
+
<label
|
|
22
|
+
class="toggle-input-label-error"
|
|
23
|
+
v-if="isInvalid"
|
|
24
|
+
:for="name ? name : 'ToggleInputText' "
|
|
25
|
+
>
|
|
26
|
+
{{ errorMessage }}
|
|
27
|
+
</label>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
|
|
33
|
+
import { mixins } from '../mixins/mixins'
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
mixins:[mixins],
|
|
39
|
+
props: {
|
|
40
|
+
value: {
|
|
41
|
+
type: [Number]
|
|
42
|
+
},
|
|
43
|
+
name: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "ToggleInputPercentage"
|
|
46
|
+
},
|
|
47
|
+
label: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: false
|
|
50
|
+
},
|
|
51
|
+
placeholder: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
autocomplete: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
size: {
|
|
60
|
+
type: String,
|
|
61
|
+
validator: function (value) {
|
|
62
|
+
return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
required: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
},
|
|
69
|
+
isInvalid: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
},
|
|
73
|
+
errorMessage: {
|
|
74
|
+
type: String,
|
|
75
|
+
required: false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
created : function(){
|
|
80
|
+
},
|
|
81
|
+
data : function(){
|
|
82
|
+
return {
|
|
83
|
+
isInputActive: false
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
watch :{
|
|
87
|
+
|
|
88
|
+
inputVal(newVal){
|
|
89
|
+
if(newVal > 100){
|
|
90
|
+
this.inputVal = '100';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
},
|
|
95
|
+
computed: {
|
|
96
|
+
inputVal: {
|
|
97
|
+
|
|
98
|
+
get: function() {
|
|
99
|
+
if (this.isInputActive) {
|
|
100
|
+
// Cursor is inside the input field. unformat display value for user
|
|
101
|
+
return this.value.toString()
|
|
102
|
+
} else {
|
|
103
|
+
// User is not modifying now. Format display value for user interface
|
|
104
|
+
return this.value + '%';
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
set: function(modifiedValue) {
|
|
108
|
+
// Recalculate value after ignoring "%" and "," in user input
|
|
109
|
+
let newValue = parseFloat(modifiedValue.replace(/[^\d.]/g, ""));
|
|
110
|
+
if(newValue)
|
|
111
|
+
newValue = parseInt(newValue);
|
|
112
|
+
else
|
|
113
|
+
newValue = 0;
|
|
114
|
+
|
|
115
|
+
this.$emit('input', newValue);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
methods: {
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* Concat message for count characters
|
|
123
|
+
* @return string
|
|
124
|
+
*/
|
|
125
|
+
messageLength(count, maxLenght)
|
|
126
|
+
{
|
|
127
|
+
let mcount = count ? count.length : 0;
|
|
128
|
+
return mcount+' / '+maxLenght;
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
onFocus() {
|
|
132
|
+
this.$emit('onFocus');
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
onBlur(){
|
|
136
|
+
this.$emit('onBlur');
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<div class="toggle-input-container margin-bottom-0" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled }" v-on:click="focusClosestInput">
|
|
6
|
+
<label
|
|
7
|
+
v-if="label"
|
|
8
|
+
:for="name ? name : 'InputText' "
|
|
9
|
+
class="toggle-input-label"
|
|
10
|
+
> {{ label }}
|
|
11
|
+
</label>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<div class="toggle-input-radio-group-container">
|
|
16
|
+
<slot></slot>
|
|
17
|
+
<label
|
|
18
|
+
class="toggle-input-label-error"
|
|
19
|
+
v-if="isInvalid"
|
|
20
|
+
:for="name ? name : 'ToggleInputText' "
|
|
21
|
+
>
|
|
22
|
+
{{ errorMessage }}
|
|
23
|
+
</label>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
|
|
33
|
+
import { mixins } from '../mixins/mixins'
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
mixins:[mixins],
|
|
37
|
+
props: {
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
name: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "ToggleInputText"
|
|
43
|
+
},
|
|
44
|
+
label: {
|
|
45
|
+
type: String,
|
|
46
|
+
required: false
|
|
47
|
+
},
|
|
48
|
+
isInvalid: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
errorMessage: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
disabled: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
created : function(){
|
|
63
|
+
},
|
|
64
|
+
computed: {
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
|
|
70
|
+
onFocus() {
|
|
71
|
+
this.$emit('onFocus');
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
onBlur(){
|
|
75
|
+
this.$emit('onBlur');
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
</script>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<div ref="toggle-input-container" class="toggle-input-container margin-bottom-0" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled }" v-on:click="focusClosestInput">
|
|
6
|
+
<label
|
|
7
|
+
v-if="label && !inGroup"
|
|
8
|
+
:for="name ? name : 'InputText' "
|
|
9
|
+
class="toggle-input-label"
|
|
10
|
+
> {{ label }}
|
|
11
|
+
</label>
|
|
12
|
+
|
|
13
|
+
<ToggleInputCheckbox v-model="checkboxModel" :label="label" label_style="" v-if="inGroup" />
|
|
14
|
+
|
|
15
|
+
<div class="toggle-input-radio-container" v-if="!inGroup || (inGroup && checkboxModel)">
|
|
16
|
+
<label class="toggle-input-radio" v-for="(option, key) in options" v-bind:key="key">
|
|
17
|
+
<input type="radio" :value="option.value" :name="name ? name : 'ToggleInputRadio' " v-model="inputVal" :disabled="disabled" />
|
|
18
|
+
<div>
|
|
19
|
+
<span class="toggle-input-radio-check-element "></span>
|
|
20
|
+
<span :class="[ 'toggle-input-radio-label', option.style ]" >{{option.label}}</span>
|
|
21
|
+
<span v-if="option.label_image"><img class="toggle-input-radio-button-img" :style="{width:option.label_image.width,height:option.label_image.height}" :src="option.label_image.url"/></span>
|
|
22
|
+
</div>
|
|
23
|
+
</label>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<label
|
|
27
|
+
class="toggle-input-label-error"
|
|
28
|
+
v-if="isInvalid"
|
|
29
|
+
:for="name ? name : 'ToggleInputText' "
|
|
30
|
+
>
|
|
31
|
+
{{ errorMessage }}
|
|
32
|
+
</label>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
|
|
38
|
+
import { mixins } from '../mixins/mixins'
|
|
39
|
+
import ToggleInputCheckbox from '../forms/ToggleInputCheckbox.vue';
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
mixins:[mixins],
|
|
43
|
+
components: {
|
|
44
|
+
ToggleInputCheckbox: ToggleInputCheckbox
|
|
45
|
+
},
|
|
46
|
+
props: {
|
|
47
|
+
value: {
|
|
48
|
+
type: [String, Number, Boolean]
|
|
49
|
+
},
|
|
50
|
+
options: {
|
|
51
|
+
type: Array,
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
name: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: "ToggleInputText"
|
|
57
|
+
},
|
|
58
|
+
label: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: false
|
|
61
|
+
},
|
|
62
|
+
isInvalid: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
errorMessage: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: false
|
|
69
|
+
},
|
|
70
|
+
disabled: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
mounted : function(){
|
|
77
|
+
this.inGroup = this.$refs["toggle-input-container"].parentElement.classList.contains('toggle-input-radio-group-container');
|
|
78
|
+
},
|
|
79
|
+
data : function(){
|
|
80
|
+
return {
|
|
81
|
+
previousValue: '',
|
|
82
|
+
checkboxModel: this.value ? true : false,
|
|
83
|
+
inGroup: false
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
computed: {
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
inputVal: {
|
|
90
|
+
get: function (){
|
|
91
|
+
return this.value;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
set: function (value){
|
|
95
|
+
this.$emit('input', value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
},
|
|
101
|
+
watch :{
|
|
102
|
+
|
|
103
|
+
inputVal(newVal)
|
|
104
|
+
{
|
|
105
|
+
if(newVal != '')
|
|
106
|
+
this.checkboxModel = true;
|
|
107
|
+
|
|
108
|
+
this.previousValue = newVal;
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
checkboxModel(newVal){
|
|
112
|
+
if(!newVal)
|
|
113
|
+
this.inputVal = '';
|
|
114
|
+
/*else if(this.inputVal == ''){
|
|
115
|
+
this.$nextTick( () => {
|
|
116
|
+
this.checkboxModel = false;
|
|
117
|
+
});
|
|
118
|
+
}*/
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
},
|
|
123
|
+
methods: {
|
|
124
|
+
|
|
125
|
+
onFocus() {
|
|
126
|
+
this.$emit('onFocus');
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
onBlur(){
|
|
130
|
+
this.$emit('onBlur');
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
</script>
|