toggle-components-library 1.36.1-beta.5 → 1.36.1-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.36.1-beta.5",
3
+ "version": "1.36.1-beta.7",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -46,10 +46,9 @@ export default {
46
46
  ];
47
47
 
48
48
  // pick random number to return random index of colourPalette
49
- const paletteIndex = Math.floor(
50
- (this.cardIndex / this.totalCards) * colorPalette.length
51
- );
52
- return colorPalette[paletteIndex];
49
+ const paletteOrder = (this.cardIndex + 1) % colorPalette.length
50
+ const index = (paletteOrder === 0 ? colorPalette.length : paletteOrder) -1
51
+ return colorPalette[index];
53
52
  }
54
53
  }
55
54
  };
@@ -12,7 +12,7 @@
12
12
  >
13
13
  <slot></slot>
14
14
  </swiper>
15
- <div v-if="carouselPrev && slidesLength > 1"
15
+ <div v-if="carouselPrev && shouldShowArrows"
16
16
  class="toggle-carousel-button toggle-carousel-button--prev"
17
17
  :class="['toggle-carousel-button--' + carouselNavPosition,
18
18
  {'toggle-carousel-button--disabled': prevDisabled},
@@ -20,7 +20,7 @@
20
20
  @click="slidePrev"
21
21
  slot="button-prev"
22
22
  ></div>
23
- <div v-if="carouselNext && slidesLength > 1"
23
+ <div v-if="carouselNext && shouldShowArrows"
24
24
  class="toggle-carousel-button toggle-carousel-button--next"
25
25
  :class="['toggle-carousel-button--' + carouselNavPosition,
26
26
  {'toggle-carousel-button--disabled': nextDisabled},
@@ -44,6 +44,7 @@ export default {
44
44
  prevDisabled: false,
45
45
  nextDisabled: false,
46
46
  slidesLength: 0,
47
+ slidesShownPerView: 0,
47
48
  isEnd: false
48
49
  };
49
50
  },
@@ -104,6 +105,7 @@ export default {
104
105
  },
105
106
  refreshCarousel(){
106
107
  this.slidesLength = this.$refs.swiper.swiperInstance.slides.length;
108
+ this.slidesShownPerView = this.$refs.swiper.swiperInstance.slidesPerViewDynamic()
107
109
  this.onSlideTransition();
108
110
  },
109
111
  onSlideTransition(){
@@ -127,6 +129,11 @@ export default {
127
129
  this.nextDisabled = false;
128
130
  }
129
131
  }
132
+ },
133
+ computed: {
134
+ shouldShowArrows() {
135
+ return this.slidesLength > this.slidesShownPerView
136
+ }
130
137
  }
131
138
  }
132
139
  </script>
@@ -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,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: {
@@ -92,7 +87,6 @@ export default {
92
87
  },
93
88
 
94
89
  created : function(){
95
-
96
90
  },
97
91
  computed: {
98
92
  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,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
  >
@@ -105,9 +103,7 @@ export default {
105
103
  }
106
104
  },
107
105
 
108
- created : function()
109
- {
110
- this.$nextTick(() => this.$refs['input_ele'].focus());
106
+ created : function(){
111
107
  },
112
108
  computed: {
113
109
  inputVal: {
@@ -122,11 +118,6 @@ export default {
122
118
  },
123
119
  methods: {
124
120
 
125
- handleEscPress()
126
- {
127
- this.$emit('bail');
128
- },
129
-
130
121
  /*
131
122
  * Concat message for count characters
132
123
  * @return string
@@ -112,6 +112,10 @@ export default {
112
112
  inverse_trend_impact: {
113
113
  type: Boolean,
114
114
  default: false
115
+ },
116
+ showTrendForAllZeros: {
117
+ type: Boolean,
118
+ default: false
115
119
  }
116
120
  },
117
121
 
@@ -195,7 +199,7 @@ export default {
195
199
 
196
200
  const trendImpactVals = this.sparkLineVal[0].data[0].y || this.sparkLineVal[0].data[0].y === 0 ? this.sparkLineVal[0].data.map(data => data.y) : this.sparkLineVal[0].data;
197
201
 
198
- let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_base);
202
+ let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_base, this.showTrendForAllZeros);
199
203
 
200
204
  if (this.inverse_trend_impact === true && result != false)
201
205
  return result *-1;
@@ -139,10 +139,10 @@ export const charts = {
139
139
  *
140
140
  * @return { {Integer} 1, 0,-1 }
141
141
  */
142
- calcTrendImpact(values, trend_impact_base){
142
+ calcTrendImpact(values, trend_impact_base, show_trend_for_all_zeros){
143
143
 
144
144
  // If all values in the values array are 0 return 0;
145
- if (values.every((val) => val === 0)){
145
+ if (!show_trend_for_all_zeros && values.every((val) => val === 0)){
146
146
  return false;
147
147
  }
148
148
 
@@ -3,56 +3,29 @@
3
3
  <div>
4
4
 
5
5
  <table class="toggle-table">
6
- <thead :class="{'toggle-table-any-search-active': anySearchActive}">
6
+ <thead :class="{'toggle-table-any-search-active': searchActive}">
7
7
  <tr class="toggle-tablee-tr">
8
- <th
9
- scope="col"
10
- :class="['toggle-table-th', {'toggle-table-search-active': tableSearchActive(field), 'toggle-table-searchable':field.filterable}]"
11
- v-for="(field, index) in headers"
12
- :colspan="field.colspan"
8
+ <th
9
+ scope="col"
10
+ :class="['toggle-table-th', {'toggle-table-search-active': tableSearchActive(field), 'toggle-table-searchable':field.filterable}]"
11
+ v-for="(field, index) in headers"
13
12
  :key="index"
14
13
  :style="'width:'+field.width"
15
14
  @click="activateSearch(field)"
16
15
  >
17
- <div class="toggle-table-th-inner" @transitionend="handleTransitionEnd">
18
-
16
+ <div class="toggle-table-th-inner">
19
17
  <span class="toggle-table-th-title">{{field.label}}</span>
20
18
  <span class="toggle-table-close-search" v-on:click.stop @click="closeSearch(field)"></span>
19
+ <ToggleInputText type="text" :ref="field.key+'-input'" v-model="searchModels[field.key]" @input="searchChange(field)"
20
+ v-if="field.type == 'text' && (searchModels[field.key] || editingInput == field.key)" />
21
+ <ToggleInputSelect style="margin-top:2px;" size="small" v-if="field.type == 'select' && (searchModels[field.key] || editingInput == field.key)" :options="field.select_options" v-model="searchModels[field.key]" @input="val=>searchChange(val, field)"/>
21
22
 
22
- <ToggleInputText
23
- v-if="field.type === 'text' && (searchModels[field.key] || editingInput === field.key) && applyFocus"
24
- type="text"
25
- :ref="field.key+'-input'"
26
- v-model="searchModels[field.key]"
27
- @input="searchChange()"
28
- @bail="closeSearch(field)"
29
- />
30
- <ToggleInputSelect
31
- style="margin-top:2px;"
32
- :size="'small'"
33
- v-if="field.type === 'select' && (searchModels[field.key] || editingInput === field.key) && applyFocus"
34
- :options="field.select_options"
35
- v-model="searchModels[field.key]"
36
- @input="searchChange()"
37
- />
38
- <ToggleDateRangePicker
39
- v-if="field.type === 'date_range' && (searchModels[field.key].start || searchModels[field.key].end || editingInput === field.key)"
40
- name="date_range"
41
- v-model="searchModels[field.key]"
42
- @input="searchChange()"
43
- />
23
+ <ToggleDateRangePicker v-if="field.type == 'date' && (searchModels[field.key].start || searchModels[field.key].end || editingInput == field.key)" name="date" v-model="searchModels[field.key]" @input="val=>searchChange(val, field)" />
44
24
  </div>
45
25
  </th>
46
-
26
+
47
27
  </tr>
48
28
  </thead>
49
- <tr class="empty-table" v-if="(items && items.length === 0) && !loading">
50
- <td :colspan="headers.length">
51
- <div class="full">
52
- <div class="empty-area"><p>{{ emptyTableMessage }}</p></div>
53
- </div>
54
- </td>
55
- </tr>
56
29
  <tbody v-if="!$slots.default || !$slots.default.length">
57
30
  <ToggleTableRow v-for="(item, index) in items" :key="index" >
58
31
  <ToggleTableColumn v-for="(column, column_index) in item" :key="column_index">{{column}}</ToggleTableColumn>
@@ -89,34 +62,20 @@ export default {
89
62
  type: [Array]
90
63
  },
91
64
  total:{
92
- type: [Number]
65
+ type: [Number]
93
66
  },
94
67
  per_page:{
95
- type: [Number]
68
+ type: [Number]
96
69
  },
97
70
  page:{
98
71
  type: [Number],
99
72
  default:1
100
- },
101
- loading: {
102
- type: Boolean
103
- },
104
- emptyTableMessage: {
105
- type: String,
106
- default: "No rows returned."
107
- },
108
- searchDebounce: {
109
- type: [Number],
110
- default: 500
111
73
  }
112
- },
74
+ },
113
75
  data : function(){
114
76
  return {
115
77
  editingInput:false,
116
- searchModels:{},
117
- anySearchActive: false,
118
- applyFocus: false,
119
- searchTimeout: null
78
+ searchModels:{}
120
79
  };
121
80
  },
122
81
  computed: {
@@ -138,23 +97,36 @@ export default {
138
97
 
139
98
  headers() {
140
99
  if(!this.fields){
141
- return Object.keys(this.items[0]);
100
+ return Object.keys(this.items[0]);
142
101
  }
143
102
  return this.fields;
144
103
  },
145
104
 
105
+ searchActive() {
106
+ if(this.editingInput) {
107
+ return true;
108
+ }
109
+ for(let col in this.searchModels){
110
+ if(!this.searchModels[col])
111
+ return false;
112
+ if (this.searchModels[col].start !== undefined) {
113
+ return true;
114
+ }
115
+ else if(this.searchModels[col]) return true;
116
+ }
117
+ return false;
118
+ },
119
+
120
+
146
121
  },
147
122
  created : function(){
148
123
 
149
124
  if(this.fields){
150
-
151
125
  for (let i = 0; i < this.fields.length; i++) {
152
- let value = this.fields[i].type == 'date_range' ? this.setInitialDate(i) : (this.fields[i].value ?? '');
153
-
126
+ let value = this.fields[i].type == 'date' ? this.setInitialDate(i) : this.fields[i].value;
154
127
  let field_name = this.fields[i].key;
155
128
  this.$set( this.searchModels, field_name, value )
156
129
  if(value){
157
- this.applyFocus = true;
158
130
  // if date has an initial value set, show it.
159
131
  if(typeof value.start !== 'undefined'){
160
132
  if(value.start.length) this.activateSearch(this.fields[i]);
@@ -165,29 +137,20 @@ export default {
165
137
  this.searchChange();
166
138
  }
167
139
  }
168
-
140
+
169
141
  },
170
142
 
171
143
  beforeDestroy: function () {
144
+ },
145
+ watch:{
146
+
172
147
  },
173
148
  mounted : function ()
174
149
  {
175
150
 
176
151
  },
177
-
152
+
178
153
  methods:{
179
-
180
- handleTransitionEnd(event){
181
- if(event.propertyName === 'height'){
182
- if(this.anySearchActive && !this.applyFocus){
183
- this.applyFocus = true;
184
- }
185
- if(!this.anySearchActive && this.applyFocus){
186
- this.applyFocus = false;
187
- }
188
- }
189
- },
190
-
191
154
  // set initial date
192
155
  setInitialDate(index){
193
156
  let value = this.fields[index].value;
@@ -197,64 +160,36 @@ export default {
197
160
 
198
161
  tableSearchActive(field)
199
162
  {
200
- if(field.type === 'date_range'){
201
- return (this.searchModels[field.key].start || this.searchModels[field.key].end || this.editingInput === field.key);
163
+ if(field.type == 'date'){
164
+ return (this.searchModels[field.key].start || this.searchModels[field.key].end || this.editingInput == field.key);
202
165
  }
203
- return (this.searchModels[field.key] || this.editingInput === field.key);
166
+ return (this.searchModels[field.key] || this.editingInput == field.key);
204
167
 
205
168
  },
206
169
 
207
-
208
- getSearchModelTypeFromKey(key){
209
- for(let i=0; i<this.fields.length; i++){
210
- if(this.fields[i].key === key){
211
- return this.fields[i].type;
212
- }
213
- }
214
- return null;
215
- },
216
-
217
170
  closeSearch(field){
218
-
219
171
  this.editingInput = false;
220
- this.searchModels[field.key] = field.type === 'date_range' ? { start: false, end: false} : '' ;
221
-
222
- // check if any search is active; if not, close/shrink header
223
- let is_active = false;
224
- for(const key in this.searchModels){
225
-
226
- if(this.getSearchModelTypeFromKey(key) === 'date_range'){
227
- if (this.searchModels[key].start || this.searchModels[key].end){
228
- is_active = true;
229
- break;
230
- }
231
- }else if(this.searchModels[key] && this.searchModels[key] !== ''){
232
- is_active = true;
233
- break;
234
- }
235
- }
236
- this.anySearchActive = is_active;
172
+ this.searchModels[field.key] = field.type == 'date' ? { start: false, end: false} : '' ;
237
173
  this.searchChange();
238
174
  },
239
175
 
240
176
  searchChange(){
241
- clearTimeout(this.searchTimeout);
242
- this.searchTimeout = setTimeout(()=>{
243
- this.$emit('search', this.fieldsWithSearch);
244
- },this.searchDebounce);
245
-
177
+ this.$emit('search', this.fieldsWithSearch);
246
178
  },
247
179
 
248
180
  /* activateSearch
249
181
  * When a user clicks a searchable column name, show it as active, and focus the child input field (unless it's already active)
250
182
  */
251
183
  activateSearch(field){
252
- if(!field.filterable || field.readonly) return;
184
+ if(!field.filterable) return;
185
+ if(field.type === 'date'){
186
+ this.datePickerOpen = true;
187
+ }
253
188
  this.editingInput = field.key;
254
- this.anySearchActive = true;
189
+ //this.$nextTick(() => this.$refs[this.editingInput + '-input'].focus())
255
190
  },
256
191
 
257
-
192
+
258
193
 
259
194
  }
260
195
  }