@afeefa/vue-app 0.0.291 → 0.0.293

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.
@@ -1 +1 @@
1
- 0.0.291
1
+ 0.0.293
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.291",
3
+ "version": "0.0.293",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -5,40 +5,38 @@
5
5
  </v-label>
6
6
 
7
7
  <a-row vertical>
8
- <div
9
- v-for="(option, index) in options_"
10
- :key="option.itemValue"
11
- class="draggable-checkbox"
12
- :class="{ 'dragging': draggedIndex === index, 'drag-over': dragOverIndex === index }"
13
- @dragover="onDragOver(index, $event)"
14
- @dragleave="onDragLeave"
15
- @drop="onDrop(index, $event)"
8
+ <draggable
9
+ v-model="options_"
10
+ handle=".drag-handle"
11
+ ghost-class="ghost"
12
+ @end="onDragEnd"
16
13
  >
17
- <div class="checkbox-container">
18
- <div
19
- class="drag-handle"
20
- :draggable="true"
21
- @dragstart="onDragStart(index, $event)"
22
- @dragend="onDragEnd"
23
- >
24
- <a-icon
25
- size="1.5rem"
26
- :icon="{icon: '$dragIcon', color: '#CCCCCC'}"
27
- />
14
+ <div
15
+ v-for="option in options_"
16
+ :key="option.itemValue"
17
+ class="draggable-checkbox"
18
+ >
19
+ <div class="checkbox-container">
20
+ <div class="drag-handle">
21
+ <a-icon
22
+ size="1.5rem"
23
+ :icon="{icon: '$dragIcon', color: '#CCCCCC'}"
24
+ />
25
+ </div>
26
+
27
+ <a-checkbox
28
+ :label="option.itemText"
29
+ :value="isChecked(option.itemValue)"
30
+ hide-details
31
+ @input="checked(option.itemValue, $event)"
32
+ >
33
+ <template #label>
34
+ <div v-html="option.itemText" />
35
+ </template>
36
+ </a-checkbox>
28
37
  </div>
29
-
30
- <a-checkbox
31
- :label="option.itemText"
32
- :value="isChecked(option.itemValue)"
33
- hide-details
34
- @input="checked(option.itemValue, $event)"
35
- >
36
- <template #label>
37
- <div v-html="option.itemText" />
38
- </template>
39
- </a-checkbox>
40
38
  </div>
41
- </div>
39
+ </draggable>
42
40
  </a-row>
43
41
 
44
42
  <div
@@ -53,17 +51,19 @@
53
51
 
54
52
  <script>
55
53
  import { Component, Vue, Watch, Inject } from '@a-vue'
54
+ import draggable from 'vuedraggable'
56
55
 
57
56
  @Component({
58
- props: ['value', 'options', 'validator']
57
+ props: ['value', 'options', 'validator'],
58
+ components: {
59
+ draggable
60
+ }
59
61
  })
60
62
  export default class ACheckboxGroup extends Vue {
61
63
  value_ = []
62
64
  options_ = []
63
65
  errorMessages = []
64
66
  hasError = false
65
- draggedIndex = null
66
- dragOverIndex = null
67
67
 
68
68
  @Inject({ from: 'form', default: null }) form
69
69
 
@@ -130,86 +130,24 @@ export default class ACheckboxGroup extends Vue {
130
130
  return !this.errorMessages.length
131
131
  }
132
132
 
133
- onDragStart (index, event) {
134
- this.draggedIndex = index
135
- event.dataTransfer.effectAllowed = 'move'
136
- event.dataTransfer.setData('text/html', event.target)
137
-
138
- // Set the entire checkbox container as the drag image
139
- const checkboxContainer = event.target.closest('.draggable-checkbox')
140
- if (checkboxContainer) {
141
- event.dataTransfer.setDragImage(checkboxContainer, 0, 0)
142
- }
143
- }
144
-
145
- onDragEnd () {
146
- this.draggedIndex = null
147
- this.dragOverIndex = null
148
-
133
+ onDragEnd (evt) {
149
134
  this.$emit('orderChanged', this.options_)
150
135
  }
151
-
152
- onDragOver (index, event) {
153
- event.preventDefault()
154
- event.stopPropagation()
155
- event.dataTransfer.dropEffect = 'move'
156
- this.dragOverIndex = index
157
- }
158
-
159
- onDragLeave (event) {
160
- // Only clear dragOverIndex if we're actually leaving the draggable-checkbox container
161
- const rect = event.currentTarget.getBoundingClientRect()
162
- const x = event.clientX
163
- const y = event.clientY
164
-
165
- if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) {
166
- this.dragOverIndex = null
167
- }
168
- }
169
-
170
- onDrop (index, event) {
171
- event.preventDefault()
172
-
173
- if (this.draggedIndex !== null && this.draggedIndex !== index) {
174
- // Create a copy of the options array
175
- const newOptions = [...this.options_]
176
-
177
- // Remove the dragged item
178
- const draggedItem = newOptions.splice(this.draggedIndex, 1)[0]
179
-
180
- // Insert it at the new position
181
- newOptions.splice(index, 0, draggedItem)
182
-
183
- // Update the options
184
- this.options_ = newOptions
185
-
186
- // Emit an event to notify parent component about the reorder
187
- this.$emit('reorder', newOptions)
188
- }
189
-
190
- this.draggedIndex = null
191
- this.dragOverIndex = null
192
- }
193
136
  }
194
137
  </script>
195
138
 
196
139
  <style scoped>
197
140
  .draggable-checkbox {
198
141
  transition: all .2s ease;
199
- border-radius: 4px;
200
- padding: 2px;
142
+ padding: 0 5px 0 0;
201
143
  }
202
144
 
203
145
  .draggable-checkbox:hover {
204
146
  background-color: rgba(0, 0, 0, .04);
205
147
  }
206
148
 
207
- .draggable-checkbox.dragging {
149
+ .ghost {
208
150
  opacity: .5;
209
- transform: scale(.95);
210
- }
211
-
212
- .draggable-checkbox.drag-over {
213
151
  background-color: rgba(25, 118, 210, .1);
214
152
  border: 2px dashed rgba(25, 118, 210, .3);
215
153
  }
@@ -221,30 +159,11 @@ export default class ACheckboxGroup extends Vue {
221
159
 
222
160
  .drag-handle {
223
161
  cursor: grab;
224
- color: rgba(0, 0, 0, .54);
225
162
  transition: all .2s ease;
226
- display: flex;
227
- align-items: center;
228
- justify-content: center;
229
- min-width: 20px;
230
163
  height: 20px;
231
164
  }
232
165
 
233
- .drag-handle:hover {
234
- background-color: rgba(0, 0, 0, .08);
235
- color: rgba(0, 0, 0, .87);
236
- }
237
-
238
166
  .drag-handle:active {
239
167
  cursor: grabbing;
240
168
  }
241
-
242
- .draggable-checkbox .v-input--checkbox {
243
- pointer-events: auto;
244
- flex: 1;
245
- }
246
-
247
- .draggable-checkbox .v-input__slot {
248
- cursor: pointer;
249
- }
250
169
  </style>
@@ -1,10 +1,13 @@
1
1
  <template>
2
2
  <div>
3
- <div :class="['menuContainer', {first}]">
3
+ <div
4
+ v-if="countTabs > 1 || !hideSingle"
5
+ :class="['menuContainer', {first}]"
6
+ >
4
7
  <div class="menu">
5
8
  <div
6
9
  v-for="(title, index) in titles"
7
- :key="index"
10
+ :key="title + '-' + index"
8
11
  :class="['label', {selected: index === currentIndex}]"
9
12
  @click="setTab(index)"
10
13
  >
@@ -30,21 +33,33 @@
30
33
  </template>
31
34
 
32
35
  <script>
33
- import { Component, Vue } from '@a-vue'
36
+ import { Component, Vue, Watch } from '@a-vue'
34
37
 
35
38
  @Component({
36
- props: ['beforeChange', {first: false}]
39
+ props: ['beforeChange', {first: false, hideSingle: false}]
37
40
  })
38
41
  export default class ATabs extends Vue {
39
42
  titles = []
40
43
  icons = []
41
44
  currentIndex = 0
45
+ countTabs = 0
42
46
 
43
47
  mounted () {
44
- this.titles = this.$children.map(c => c.title)
45
- this.icons = this.$children.map(c => c.icon)
48
+ this.countTabs = this.getCountTabs()
49
+ }
46
50
 
47
- this.$children[this.currentIndex].show()
51
+ updated () {
52
+ this.countTabs = this.getCountTabs()
53
+ }
54
+
55
+ @Watch('countTabs')
56
+ countTabsChanged (oldt, newt) {
57
+ this.$nextTick(() => {
58
+ this.titles = this.$children.map(c => c.title).filter(t => t)
59
+ this.icons = this.$children.map(c => c.icon).filter(i => i)
60
+
61
+ this.setTab(0)
62
+ })
48
63
  }
49
64
 
50
65
  async setTab (index) {
@@ -56,7 +71,7 @@ export default class ATabs extends Vue {
56
71
  }
57
72
 
58
73
  this.currentIndex = index
59
- const tabs = this.$slots.default.map(s => s.componentInstance)
74
+ const tabs = this.$slots.default.map(s => s.componentInstance).filter(i => i)
60
75
  tabs.forEach((tab, i) => {
61
76
  if (i === this.currentIndex) {
62
77
  tab.show()
@@ -65,6 +80,10 @@ export default class ATabs extends Vue {
65
80
  }
66
81
  })
67
82
  }
83
+
84
+ getCountTabs () {
85
+ return this.$slots.default.filter(s => !!s.tag).length // removed slot has vm.tag === undefined
86
+ }
68
87
  }
69
88
  </script>
70
89
 
@@ -65,6 +65,10 @@ html {
65
65
 
66
66
  .theme--light.v-btn.v-btn--has-bg {
67
67
  background-color: #E9E9E9;
68
+
69
+ &.theme--light.v-btn.v-btn--disabled.v-btn--has-bg {
70
+ background-color: #CCCCCC !important;
71
+ }
68
72
  }
69
73
 
70
74
  .theme--light.v-btn:focus::before {