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

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.
@@ -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
  }
@@ -1,5 +1,23 @@
1
1
  <template>
2
- <tr class="toggle-tablee-tr" @click="$emit('click')" >
2
+ <tr :class="['toggle-tablee-tr',{'tr-disabled':disabled }]" @click="handleClick" >
3
3
  <slot></slot>
4
4
  </tr>
5
- </template>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ props: {
10
+ disabled: {
11
+ type: Boolean,
12
+ default: false
13
+ }
14
+ },
15
+ methods: {
16
+ handleClick() {
17
+ if(!this.disabled) {
18
+ this.$emit('click')
19
+ }
20
+ }
21
+ }
22
+ }
23
+ </script>
package/src/index.js CHANGED
@@ -4,7 +4,6 @@ import ToggleInputText from "./components/forms/ToggleInputText.vue";
4
4
  import ToggleInputEditableText from "./components/forms/ToggleInputEditableText.vue";
5
5
  import ToggleInputWebsite from "./components/forms/ToggleInputWebsite.vue";
6
6
  import ToggleDatePicker from "./components/forms/ToggleDatePicker.vue";
7
- import ToggleDateRangePicker from "./components/forms/ToggleDateRangePicker.vue";
8
7
  import ToggleInputSelect from "./components/forms/ToggleInputSelect.vue";
9
8
  import ToggleInputPercentage from "./components/forms/ToggleInputPercentage.vue";
10
9
  import ToggleInputCurrency from "./components/forms/ToggleInputCurrency.vue";
@@ -104,14 +103,13 @@ const Components = {
104
103
  ToggleInputEditableText,
105
104
  ToggleInputWebsite,
106
105
  ToggleDatePicker,
107
- ToggleDateRangePicker,
108
106
  ToggleInputSelect,
109
107
  ToggleInputPercentage,
110
108
  ToggleInputCurrency,
111
109
  ToggleInputRadioButtons,
112
110
  ToggleInputTextArea,
113
111
  ToggleInputCheckboxContainer,
114
- ToggleInputCheckbox,
112
+ ToggleInputCheckbox,
115
113
  ToggleInputCheckboxInline,
116
114
  ToggleFillLoader,
117
115
  ToggleProgressLoader,
@@ -25,6 +25,10 @@
25
25
  background-color: $booster-tickets-colour-med;
26
26
  }
27
27
 
28
+ &.feedback{
29
+ background-color: $booster-feedback-colour-med;
30
+ }
31
+
28
32
  &.test{
29
33
  background-color: $booster-test-colour-light;
30
34
  }
@@ -72,6 +76,13 @@
72
76
  background-color: rgba($booster-tickets-colour-light, 0.8);
73
77
  }
74
78
 
79
+ &.feedback{
80
+ background-color: rgba($booster-feedback-colour-dark, 0.2);
81
+ &:hover{
82
+ background-color: rgba($booster-feedback-colour-dark, 0.25);
83
+ }
84
+ }
85
+
75
86
  &.test{
76
87
  background-color: rgba($booster-test-colour-med, 0.8);
77
88
  &:hover{
@@ -79,10 +90,12 @@
79
90
  }
80
91
  }
81
92
 
82
- .plus{
83
- margin: auto;
84
- padding-right: 0.5rem;
85
- padding-left: 0.6rem;
93
+ .plus {
94
+ margin: 0 0.2rem;
95
+ padding-left: 0.6rem;
96
+ }
97
+ .toggle-booster-button-button-text {
98
+ padding-left: 0.5rem;
86
99
  }
87
100
  }
88
101
 
@@ -165,6 +178,10 @@ margin:1rem
165
178
  background-color: $booster-tickets-colour-med;
166
179
  }
167
180
 
181
+ &.feedback{
182
+ background-color: $booster-feedback-colour-med;
183
+ }
184
+
168
185
  &.test{
169
186
  background-color: $booster-test-colour-light;
170
187
  }
@@ -202,3 +219,37 @@ margin:1rem
202
219
 
203
220
  }
204
221
 
222
+ .toggle-booster-button-disabled {
223
+ opacity: 0.3;
224
+ }
225
+
226
+ /* Tooltip container */
227
+ .toggle-booster-button-tooltip-container {
228
+ position: relative;
229
+ display: flex;
230
+ justify-content: center;
231
+ }
232
+
233
+ /* Tooltip text */
234
+ .toggle-booster-button-tooltip-container .toggle-booster-button-tooltip-text {
235
+ visibility: hidden;
236
+ width: 120px;
237
+ height: fit-content;
238
+ background-color: black;
239
+ color: #fff;
240
+ text-align: center;
241
+ padding: 5px;
242
+ border-radius: 6px;
243
+ position: absolute;
244
+ z-index: 999;
245
+ top: 100%;
246
+ }
247
+
248
+ .toggle-booster-button-tooltip-text {
249
+ font-family: $toggle-font-family;
250
+ padding: 10px;
251
+ }
252
+
253
+ .toggle-booster-button-tooltip-container:hover .toggle-booster-button-tooltip-text {
254
+ visibility: visible;
255
+ }
@@ -427,3 +427,83 @@
427
427
  transition: all 0.2s ease-in-out;
428
428
  }
429
429
  }
430
+
431
+ .toggle-button-booster-badge {
432
+ display: flex;
433
+ align-items: center;
434
+ padding: 0.2rem 0.2rem 0.2rem 1rem !important;
435
+ }
436
+
437
+ .shimmer {
438
+ color: grey;
439
+ display: inline-block;
440
+ mask: linear-gradient(-60deg, #000 30%, #0005, #000 70%) right/400% 100%;
441
+ background-repeat: no-repeat;
442
+ animation: shimmer 4s infinite;
443
+ }
444
+
445
+ .toggle-button-booster-image-badge {
446
+ width: 6rem;
447
+ height: 2rem;
448
+ display: flex;
449
+ align-items: center;
450
+ justify-content: center;
451
+ border-radius: 4px;
452
+ margin: 0 0 0 20px;
453
+ padding: 0px 8px 0px 8px;
454
+ width: 6rem;
455
+ height: 1.8rem;
456
+ .toggle-button-booster-image {
457
+ width: 100%;
458
+ height: 100%;
459
+ }
460
+ &.toggle-button-loading {
461
+ opacity: 0
462
+ }
463
+ &.toggle-button-disabled {
464
+ opacity: 0.3;
465
+ }
466
+ }
467
+
468
+ /* Tooltip container */
469
+ .toggle-button-tooltip-container {
470
+ position: relative;
471
+ justify-content: center;
472
+ display: flex;
473
+ }
474
+
475
+ /* Tooltip text */
476
+ .toggle-button-tooltip-container .toggle-button-tooltip-text {
477
+ visibility: hidden;
478
+ width: 120px;
479
+ height: fit-content;
480
+ background-color: black;
481
+ color: #fff;
482
+ text-align: center;
483
+ padding: 5px;
484
+ border-radius: 6px;
485
+ position: absolute;
486
+ z-index: 999;
487
+ top: 100%;
488
+ }
489
+
490
+ .toggle-button-tooltip-text {
491
+ font-family: $toggle-font-family;
492
+ }
493
+
494
+ .toggle-button-tooltip-container:hover .toggle-button-tooltip-text {
495
+ visibility: visible;
496
+ }
497
+
498
+ // Shimmer animation for booster badge
499
+ @keyframes shimmer {
500
+ 0% {
501
+ mask-position: right;
502
+ }
503
+ 30% {
504
+ mask-position: left;
505
+ }
506
+ 100% {
507
+ mask-position: left;
508
+ }
509
+ }