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