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

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.12",
3
+ "version": "1.33.0-beta.13",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -38,7 +38,6 @@
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",
42
41
  "vue2-dropzone": "^3.6.0",
43
42
  "vuedraggable": "^2.24.3",
44
43
  "webfontloader": "^1.6.28"
@@ -1,167 +1,158 @@
1
1
  <template>
2
2
 
3
- <div class="toggle-date-container" :class="[{'visible': show}, 'datepicker-trigger',{'toggle-input-is-invalid':isInvalid }, { 'toggle-input-is-disabled': disabled }]">
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>
4
33
 
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>
10
34
  </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>
21
35
  </template>
22
36
 
23
37
  <script>
24
38
 
25
- import { mixins } from '../mixins/mixins'
26
- import moment from 'moment';
27
- import DatePicker from 'vue2-datepicker';
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
+ });
28
58
 
29
59
  export default {
30
- mixins:[mixins],
31
- components:{
32
- DatePicker
33
- },
34
- props: {
35
- set_value: {
36
- type: [Boolean,Date,Object]
37
- },
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
- }
46
- },
47
- // singular date or range between 2 dates
48
- range: {
49
- type: Boolean,
50
- default: false
51
- },
52
- name: {
53
- type: String,
54
- default: "ToggleInputText"
55
- },
56
- label: {
57
- type: String,
58
- required: false
59
- },
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
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
+ }
90
105
  },
91
- maxLength:{
92
- type: Number,
93
- required:false
106
+
107
+ created : function(){
94
108
  },
95
- disabled: {
96
- type: Boolean,
97
- default: false
109
+ data : function(){
110
+ return {
111
+ datePickerOpen: false,
112
+ };
98
113
  },
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,
114
+ watch :{
109
115
 
110
- momentFormat: {
111
- //[optional] Date to String
112
- stringify: (date) => {
113
- return date ? moment(date).format(this.displayFormat) : ''
114
- },
115
- //[optional] String to Date
116
- parse: (value) => {
117
- return value ? moment(value, this.displayFormat).toDate() : null
116
+ datePickerOpen(newVal){
117
+ let state = newVal ? 'open' : 'closed';
118
+ this.$emit('state', state);
118
119
  }
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
- }
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
- }
120
+
146
121
  },
122
+ computed: {
123
+ date() {
124
+ return this.dateRangeView(this.displayValue)
125
+ },
147
126
 
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
- ];
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
+ }
163
140
  },
164
- }
141
+ methods: {
142
+
143
+ clearDate()
144
+ {
145
+ this.displayValue = '';
146
+ },
147
+
148
+ toggleDatePickerState(state){
149
+ this.$nextTick( () => {
150
+ if(typeof state === 'boolean')
151
+ this.datePickerOpen = state;
152
+ else this.datePickerOpen = !this.datePickerOpen;
153
+ });
154
+ },
155
+ }
165
156
  }
166
157
 
167
158
 
@@ -169,88 +160,7 @@ export default {
169
160
 
170
161
  <style lang="scss">
171
162
 
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
- }
163
+
254
164
 
255
165
  </style>
256
166
 
@@ -1,18 +1,18 @@
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 : '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,6 +39,11 @@ import { mixins } from '../mixins/mixins'
39
39
 
40
40
  export default {
41
41
  mixins:[mixins],
42
+ data() {
43
+ return {
44
+ show: false
45
+ }
46
+ },
42
47
  props: {
43
48
  value: {},
44
49
  name: {
@@ -87,6 +92,7 @@ export default {
87
92
  },
88
93
 
89
94
  created : function(){
95
+
90
96
  },
91
97
  computed: {
92
98
  inputVal: {
@@ -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,9 +19,11 @@
19
19
  :maxlength="maxLength"
20
20
  :disabled="disabled"
21
21
  :readonly="readonly"
22
+ :ref="'input_ele'"
23
+ @keyup.esc="handleEscPress"
22
24
  />
23
25
  <label
24
- class="toggle-input-label-error"
26
+ class="toggle-input-label-error"
25
27
  v-if="isInvalid"
26
28
  :for="name ? name : 'ToggleInputText' "
27
29
  >
@@ -103,7 +105,9 @@ export default {
103
105
  }
104
106
  },
105
107
 
106
- created : function(){
108
+ created : function()
109
+ {
110
+ this.$nextTick(() => this.$refs['input_ele'].focus());
107
111
  },
108
112
  computed: {
109
113
  inputVal: {
@@ -118,6 +122,11 @@ export default {
118
122
  },
119
123
  methods: {
120
124
 
125
+ handleEscPress()
126
+ {
127
+ this.$emit('bail');
128
+ },
129
+
121
130
  /*
122
131
  * Concat message for count characters
123
132
  * @return string