toggle-components-library 1.33.0-beta.11 → 1.33.0-beta.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toggle-components-library",
3
- "version": "1.33.0-beta.11",
3
+ "version": "1.33.0-beta.12",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -38,6 +38,7 @@
38
38
  "vue-moment": "^4.1.0",
39
39
  "vue-multiselect": "^2.0.8",
40
40
  "vue-router": "^3.6.4",
41
+ "vue2-datepicker": "^3.11.1",
41
42
  "vue2-dropzone": "^3.6.0",
42
43
  "vuedraggable": "^2.24.3",
43
44
  "webfontloader": "^1.6.28"
@@ -1,158 +1,167 @@
1
1
  <template>
2
2
 
3
- <div class="toggle-date-container" :class="['datepicker-trigger',{'toggle-input-is-invalid':isInvalid }]">
4
-
5
-
6
- <label class="toggle-input-label">{{label}}</label>
7
-
8
- <div class="toggle-date-input-container">
9
- <div class="toggle-date-input-calendar-icon">
10
- <input type="text" class="toggle-input" :name="name" ref="date-input" :id="'toggle-date-input'+_uid" :value="date" v-on:keypress="$event.preventDefault()">
11
- </div>
12
- <button type="button" class="toggle-clear" v-on:click="clearDate" v-if="displayValue"></button>
13
- </div>
14
-
15
- <AirbnbStyleDatepicker
16
- :trigger-element-id="'toggle-date-input'+_uid"
17
- :trigger="datePickerOpen"
18
- :mode="'single'"
19
- :date-one="displayValue"
20
- @date-one-selected="val => { displayValue = val}"
21
- @closed="toggleDatePickerState(false)"
22
- @cancelled="toggleDatePickerState(false)"
23
- :monthsToShow="1"
24
- :showShortcutsMenuTrigger="false"
25
- />
26
- <label
27
- class="toggle-input-label-error"
28
- v-if="isInvalid"
29
- :for="name ? name : 'ToggleInputText' "
30
- >
31
- {{ errorMessage }}
32
- </label>
3
+ <div class="toggle-date-container" :class="[{'visible': show}, 'datepicker-trigger',{'toggle-input-is-invalid':isInvalid }, { 'toggle-input-is-disabled': disabled }]">
33
4
 
5
+ <label class="toggle-input-label">{{label}}</label>
6
+
7
+ <div :class="['toggle-date-input-container', 'toggle-date-input-container-' + size, {'toggle-date-input-disabled': disabled} ]">
8
+ <date-picker v-model="inputVal" prefix-class="toggle-mxdatepicker" :formatter="momentFormat" :range="range" :type="type" :disabled="disabled">
9
+ </date-picker>
34
10
  </div>
11
+
12
+ <label
13
+ class="toggle-input-label-error"
14
+ v-if="isInvalid"
15
+ :for="name ? name : 'ToggleInputText' "
16
+ >
17
+ {{ errorMessage }}
18
+ </label>
19
+
20
+ </div>
35
21
  </template>
36
22
 
37
23
  <script>
38
24
 
39
- import Vue from "vue";
40
- import { mixins } from '../mixins/mixins'
41
- import 'vue-airbnb-style-datepicker/dist/vue-airbnb-style-datepicker.min.css'
42
- import AirbnbStyleDatepicker from 'vue-airbnb-style-datepicker';
43
- import variables from '../../sass/includes/_as_variables.scss';
44
-
45
- Vue.use(AirbnbStyleDatepicker, {
46
- colors: {
47
- selected : variables.toggleblue,
48
- inRange : variables.togglelightblue,
49
- selectedText : variables.togglewhite,
50
- text : variables.toggleinputcolour,
51
- inRangeBorder: variables.togglewhite,
52
- disabled : variables.togglewhite,
53
- },
54
- texts: {
55
- apply: 'Done'
56
- },
57
- });
25
+ import { mixins } from '../mixins/mixins'
26
+ import moment from 'moment';
27
+ import DatePicker from 'vue2-datepicker';
58
28
 
59
29
  export default {
60
- mixins:[mixins],
61
- components:{},
62
- props: {
63
- value: {
64
- type: [Boolean,Date]
65
- },
66
-
67
- name: {
68
- type: String,
69
- default: "ToggleInputText"
70
- },
71
- label: {
72
- type: String,
73
- required: false
74
- },
75
- placeholder: {
76
- type: String,
77
- required: false
78
- },
79
- autocomplete: {
80
- type: Boolean,
81
- default: true
82
- },
83
- size: {
84
- type: String,
85
- validator: function (value) {
86
- return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
87
- }
88
- },
89
- required: {
90
- type: Boolean,
91
- default: false
92
- },
93
- isInvalid: {
94
- type: Boolean,
95
- default: false
96
- },
97
- errorMessage: {
98
- type: String,
99
- required: false
100
- },
101
- maxLength:{
102
- type: Number,
103
- required:false
104
- }
30
+ mixins:[mixins],
31
+ components:{
32
+ DatePicker
33
+ },
34
+ props: {
35
+ set_value: {
36
+ type: [Boolean,Date,Object]
105
37
  },
106
-
107
- created : function(){
38
+ value: {},
39
+ // datepicker mode, see: https://www.npmjs.com/package/vue2-datepicker#props
40
+ type: {
41
+ type: String,
42
+ required: true,
43
+ validator: function (value) {
44
+ return ['date', 'datetime', 'year', 'month', 'time', 'week'].indexOf(value) !== -1
45
+ }
108
46
  },
109
- data : function(){
110
- return {
111
- datePickerOpen: false,
112
- };
47
+ // singular date or range between 2 dates
48
+ range: {
49
+ type: Boolean,
50
+ default: false
113
51
  },
114
- watch :{
115
-
116
- datePickerOpen(newVal){
117
- let state = newVal ? 'open' : 'closed';
118
- this.$emit('state', state);
119
- }
120
-
52
+ name: {
53
+ type: String,
54
+ default: "ToggleInputText"
121
55
  },
122
- computed: {
123
- date() {
124
- return this.dateRangeView(this.displayValue)
125
- },
126
-
127
- // plugin only accepts MM/DD/YYYY, so change this so that it excepts and outputs JS dates
128
- displayValue: {
129
- get: function() {
130
- return this.formatDate(this.value)
131
- },
132
- set: function(modifiedValue) {
133
- if(modifiedValue){
134
- modifiedValue = new Date(new Date(modifiedValue+' 00:00:00').toISOString());
135
- }
136
- else modifiedValue = false;
137
- this.$emit('input', modifiedValue);
138
- }
139
- }
56
+ label: {
57
+ type: String,
58
+ required: false
140
59
  },
141
- methods: {
142
-
143
- clearDate()
144
- {
145
- this.displayValue = '';
146
- },
60
+ placeholder: {
61
+ type: String,
62
+ required: false
63
+ },
64
+ autocomplete: {
65
+ type: Boolean,
66
+ default: true
67
+ },
68
+ size: {
69
+ type: String,
70
+ validator: function (value) {
71
+ return ['small', 'medium'].indexOf(value) !== -1
72
+ },
73
+ default: 'medium'
74
+ },
75
+ displayFormat: {
76
+ type: String,
77
+ default: 'DD/MM/Y'
78
+ },
79
+ required: {
80
+ type: Boolean,
81
+ default: false
82
+ },
83
+ isInvalid: {
84
+ type: Boolean,
85
+ default: false
86
+ },
87
+ errorMessage: {
88
+ type: String,
89
+ required: false
90
+ },
91
+ maxLength:{
92
+ type: Number,
93
+ required:false
94
+ },
95
+ disabled: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ // in toggle-table context, if search bar height expand transition has finished
100
+ searchIsOpen: {
101
+ type: Boolean,
102
+ required: false,
103
+ default: null
104
+ }
105
+ },
106
+ data : function(){
107
+ return {
108
+ show: false,
147
109
 
148
- toggleDatePickerState(state){
149
- this.$nextTick( () => {
150
- if(typeof state === 'boolean')
151
- this.datePickerOpen = state;
152
- else this.datePickerOpen = !this.datePickerOpen;
153
- });
110
+ momentFormat: {
111
+ //[optional] Date to String
112
+ stringify: (date) => {
113
+ return date ? moment(date).format(this.displayFormat) : ''
154
114
  },
115
+ //[optional] String to Date
116
+ parse: (value) => {
117
+ return value ? moment(value, this.displayFormat).toDate() : null
118
+ }
119
+ }
120
+ };
121
+ },
122
+ created : function(){
123
+ // in table mode, has search bar expand transition finished?
124
+ if(this.searchIsOpen === null || this.searchIsOpen){
125
+ this.show = true;
126
+ }
127
+
128
+ },
129
+ watch :{
130
+ // search bar expand transition / if in table context
131
+ searchIsOpen(new_value){
132
+ if(new_value){
133
+ this.show = true;
134
+ }
155
135
  }
136
+ },
137
+ computed: {
138
+
139
+ inputVal: {
140
+ get: function (){
141
+ return this.convertRangeObject(this.value);
142
+ },
143
+ set: function (value){
144
+ this.$emit('input', this.convertRangeObject(value));
145
+ }
146
+ },
147
+
148
+ },
149
+ methods: {
150
+ // convert singular date to range. Plugin uses array with 2 values / parents in Toggle dash expect object with start & end keys
151
+ convertRangeObject(input)
152
+ {
153
+ if(!this.range){
154
+ return input
155
+ }
156
+ return Array.isArray(input) ? {
157
+ start: input[0],
158
+ end: input[1]
159
+ } : [
160
+ input.start,
161
+ input.end
162
+ ];
163
+ },
164
+ }
156
165
  }
157
166
 
158
167
 
@@ -160,7 +169,88 @@ export default {
160
169
 
161
170
  <style lang="scss">
162
171
 
163
-
172
+ $namespace: 'toggle-mxdatepicker';
173
+
174
+ @import '~vue2-datepicker/scss/index.scss';
175
+
176
+ .toggle-date-container {
177
+ display: none;
178
+ &.visible {
179
+ display: block;
180
+ }
181
+ }
182
+
183
+ .toggle-mxdatepicker-datepicker, .toggle-mxdatepicker-datepicker-range {
184
+ width: 100%;
185
+ }
186
+ .toggle-mxdatepicker-input {
187
+ padding: 0.5rem 3.5rem 0.5rem 1rem;
188
+ background-color: #F4F6F7 !important;
189
+ height: 2.8rem;
190
+ width: 100%;
191
+ box-shadow: none;
192
+ border: 0;
193
+ color: #354b64 !important;
194
+ font-weight: bold !important;
195
+ font-size: 1.2rem !important;
196
+ }
197
+
198
+ i.toggle-mxdatepicker-icon-clear {
199
+ display: flex;
200
+ align-items: center;
201
+ justify-content: center;
202
+ width: 1.5rem;
203
+ height: 1.5rem;
204
+ &:after{
205
+ cursor: pointer;
206
+ content: url('../../assets/icons/delete.svg');
207
+ width: 1.5rem;
208
+ height: 1.5rem;
209
+ position: absolute;
210
+ pointer-events: none;
211
+ z-index: 2;
212
+ }
213
+ }
214
+
215
+ i.toggle-mxdatepicker-icon-calendar {
216
+ display: flex;
217
+ align-items: center;
218
+ justify-content: center;
219
+ width: 1.5rem;
220
+ height: 1.5rem;
221
+ &:after{
222
+ cursor: pointer;
223
+ content: url("../../assets/icons/calendar.svg");
224
+ width: 1.5rem;
225
+ height: 1.5rem;
226
+ position: absolute;
227
+ pointer-events: none;
228
+ z-index: 2;
229
+ }
230
+ }
231
+
232
+ .toggle-date-input-container-small {
233
+ .toggle-mxdatepicker-input {
234
+ background-color: transparent;
235
+ margin-top: 11px;
236
+ padding: 1px 1.65rem 1px 3px;
237
+ font-size: 0.9rem !important;
238
+ height: 1.5rem;
239
+ }
240
+ i.toggle-mxdatepicker-icon-calendar, i.toggle-mxdatepicker-icon-clear {
241
+ margin-top: 6px;
242
+ width: 1em;
243
+ height: 1em;
244
+ &:after{
245
+ width: 1rem;
246
+ height: 1rem;
247
+ }
248
+ }
249
+ }
250
+
251
+ .toggle-mxdatepicker-calendar-content {
252
+ height: auto;
253
+ }
164
254
 
165
255
  </style>
166
256
 
@@ -1,18 +1,18 @@
1
1
  <template>
2
2
 
3
- <div v-if="show" class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled}" v-on:click="focusClosestInput">
4
- <label
3
+ <div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled}" v-on:click="focusClosestInput">
4
+ <label
5
5
  v-if="label"
6
- :for="name ? name : 'ToggleInputSelect' "
6
+ :for="name ? name : 'ToggleInputSelect' "
7
7
  class="toggle-input-label"
8
- > {{ label }}
8
+ > {{ label }}
9
9
  </label>
10
10
 
11
11
  <div class="toggle-input-select-container">
12
- <select
13
- :name="name ? name : 'ToggleInputSelect' "
12
+ <select
13
+ :name="name ? name : 'ToggleInputSelect' "
14
14
  :class="[ 'toggle-input-select', size]"
15
- v-model="inputVal"
15
+ v-model="inputVal"
16
16
  :autocomplete="autocomplete ? 'on' : 'off' "
17
17
  :required="required"
18
18
  :disabled="disabled"
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
 
26
26
  <label
27
- class="toggle-input-label-error"
27
+ class="toggle-input-label-error"
28
28
  v-if="isInvalid"
29
29
  :for="name ? name : 'ToggleInputText' "
30
30
  >
@@ -39,11 +39,6 @@ import { mixins } from '../mixins/mixins'
39
39
 
40
40
  export default {
41
41
  mixins:[mixins],
42
- data() {
43
- return {
44
- show: false
45
- }
46
- },
47
42
  props: {
48
43
  value: {},
49
44
  name: {
@@ -88,19 +83,10 @@ export default {
88
83
  type: Boolean,
89
84
  required: false,
90
85
  default: false
91
- },
92
- // in toggle-table context, if search bar height expand transition has finished
93
- applyFocus: {
94
- type: Boolean,
95
- required: false,
96
- default: null
97
86
  }
98
87
  },
99
88
 
100
89
  created : function(){
101
- if(this.applyFocus === null || this.applyFocus){
102
- this.show = true;
103
- }
104
90
  },
105
91
  computed: {
106
92
  inputVal: {
@@ -126,11 +112,6 @@ export default {
126
112
  options(options) {
127
113
  if (options.filter( option => option.value == this.inputVal).length == 0)
128
114
  this.inputVal = "";
129
- },
130
- applyFocus(new_value){
131
- if(new_value){
132
- this.show = true;
133
- }
134
115
  }
135
116
  }
136
117
  }
@@ -1,16 +1,16 @@
1
1
  <template>
2
2
 
3
3
  <div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid, 'toggle-input-is-disabled':disabled}" v-on:click="focusClosestInput">
4
- <label
4
+ <label
5
5
  v-if="label"
6
- :for="name ? name : 'InputText' "
6
+ :for="name ? name : 'InputText' "
7
7
  class="toggle-input-label"
8
- > {{ label }}
8
+ > {{ label }}
9
9
  </label>
10
10
  <span class="toggle-input-counter" v-if="maxLength">{{messageLength(inputVal, maxLength)}}</span>
11
11
  <input
12
12
  :type="type"
13
- :name="name ? name : 'ToggleInputText' "
13
+ :name="name ? name : 'ToggleInputText' "
14
14
  :class="[ 'toggle-input', size]"
15
15
  :placeholder="placeholder ? placeholder : '' "
16
16
  :autocomplete="autocomplete ? 'on' : 'off' "
@@ -19,11 +19,9 @@
19
19
  :maxlength="maxLength"
20
20
  :disabled="disabled"
21
21
  :readonly="readonly"
22
- :ref="'input_ele'"
23
- @keyup.esc="handleEscPress"
24
22
  />
25
23
  <label
26
- class="toggle-input-label-error"
24
+ class="toggle-input-label-error"
27
25
  v-if="isInvalid"
28
26
  :for="name ? name : 'ToggleInputText' "
29
27
  >
@@ -102,26 +100,10 @@ export default {
102
100
  type: Boolean,
103
101
  required: false,
104
102
  default: false
105
- },
106
- // in toggle-table context, if search bar height expand transition has finished
107
- applyFocus: {
108
- type: Boolean,
109
- required: false
110
103
  }
111
104
  },
112
105
 
113
- created : function()
114
- {
115
- if(this.applyFocus){
116
- this.$nextTick(() => this.$refs['input_ele'].focus());
117
- }
118
- },
119
- watch: {
120
- applyFocus(new_value){
121
- if(new_value){
122
- this.$nextTick(() => this.$refs['input_ele'].focus());
123
- }
124
- }
106
+ created : function(){
125
107
  },
126
108
  computed: {
127
109
  inputVal: {
@@ -136,11 +118,6 @@ export default {
136
118
  },
137
119
  methods: {
138
120
 
139
- handleEscPress()
140
- {
141
- this.$emit('bail');
142
- },
143
-
144
121
  /*
145
122
  * Concat message for count characters
146
123
  * @return string