@mixd-id/web-scaffold 0.1.240411067 → 0.1.240411069

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.240411067",
4
+ "version": "0.1.240411069",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -64,6 +64,7 @@
64
64
  "glob": "^8.0.3",
65
65
  "lodash": "^4.17.21",
66
66
  "lodash-es": "^4.17.21",
67
+ "marked": "^15.0.12",
67
68
  "md5": "^2.3.0",
68
69
  "mitt": "^3.0.1",
69
70
  "pinia": "^2.0.2",
@@ -4,6 +4,7 @@
4
4
  <TreeViewItem v-for="(item, index) in modelValue"
5
5
  :item="item"
6
6
  :depth="0"
7
+ :items-key="itemsKey"
7
8
  :parent="modelValue"
8
9
  :selected-item="selectedItem"
9
10
  @moveup="moveUp(item)"
@@ -40,7 +41,12 @@ export default{
40
41
 
41
42
  modelValue: Array,
42
43
 
43
- selectedItem: Object
44
+ selectedItem: Object,
45
+
46
+ itemsKey: {
47
+ type: String,
48
+ default: "items"
49
+ }
44
50
 
45
51
  },
46
52
 
@@ -6,7 +6,7 @@
6
6
  @mousedown="mouseDown">
7
7
 
8
8
  <button type="button" class="p-1 w-[18px]"
9
- v-if="Array.isArray((item ?? {}).items) && item.items.length > 0"
9
+ v-if="(item[itemsKey] ?? []).length > 0"
10
10
  @click="childCollapsed = !childCollapsed">
11
11
  <svg v-if="!childCollapsed" width="14" height="14" class="fill-text-300 pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"/></svg>
12
12
  <svg v-else width="14" height="14" class="fill-text-300 pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512"><path d="M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"/></svg>
@@ -18,7 +18,7 @@
18
18
  </div>
19
19
 
20
20
  <div class="flex flex-row items-center">
21
- <button v-if="item && Array.isArray(item.items)"
21
+ <button v-if="item && Array.isArray(item[itemsKey])"
22
22
  type="button"
23
23
  class="p-1"
24
24
  @click="add">
@@ -39,17 +39,18 @@
39
39
 
40
40
  </div>
41
41
  <div ref="container"
42
- v-show="item && Array.isArray(item.items) && !childCollapsed" class="ml-6"
42
+ v-show="item && Array.isArray(item[itemsKey]) && !childCollapsed" class="ml-6"
43
43
  @mousemove.stop=""
44
44
  @mouseout.stop="">
45
- <TreeViewItem v-for="(subItem, index) in item.items"
45
+ <TreeViewItem v-for="(subItem, index) in item[itemsKey]"
46
46
  :item="subItem"
47
- :parent="item.items"
47
+ :parent="item[itemsKey]"
48
48
  :depth="depth + 1"
49
+ :items-key="itemsKey"
49
50
  :selected-item="selectedItem"
50
51
  @moveup="moveUp(subItem)"
51
52
  @movedown="moveDown(subItem)"
52
- @remove="item.items.splice(index, 1); $emit('change')"
53
+ @remove="item[itemsKey].splice(index, 1); $emit('change')"
53
54
  @add="(items) => $emit('add', items)"
54
55
  @duplicate="(parent, item) => $emit('duplicate', parent, item)"
55
56
  @change="$emit('change')">
@@ -90,29 +91,31 @@ export default{
90
91
  default: 1
91
92
  },
92
93
 
93
- depth: Number
94
+ depth: Number,
95
+
96
+ itemsKey: String
94
97
  },
95
98
 
96
99
  methods: {
97
100
 
98
101
  moveDown(item){
99
- const idx = this.item.items.indexOf(item)
100
- if(idx < this.item.items.length - 1){
101
- this.item.items.splice(idx + 1, 0, this.item.items.splice(idx, 1)[0])
102
+ const idx = this.item[this.itemsKey].indexOf(item)
103
+ if(idx < this.item[this.itemsKey].length - 1){
104
+ this.item[this.itemsKey].splice(idx + 1, 0, this.item[this.itemsKey].splice(idx, 1)[0])
102
105
  this.$emit('change')
103
106
  }
104
107
  },
105
108
 
106
109
  moveUp(item){
107
- const idx = this.item.items.indexOf(item)
110
+ const idx = this.item[this.itemsKey].indexOf(item)
108
111
  if(idx - 1 >= 0){
109
- this.item.items.splice(idx - 1, 0, this.item.items.splice(idx, 1)[0])
112
+ this.item[this.itemsKey].splice(idx - 1, 0, this.item[this.itemsKey].splice(idx, 1)[0])
110
113
  this.$emit('change')
111
114
  }
112
115
  },
113
116
 
114
117
  add(){
115
- this.$emit('add', this.item.items)
118
+ this.$emit('add', this.item[this.itemsKey])
116
119
  this.childCollapsed = false
117
120
  },
118
121
 
@@ -239,7 +242,7 @@ export default{
239
242
  if(this.item === dragged.item) return
240
243
 
241
244
  // Drag to own child is not allowed
242
- if(dragged.item.items && dragged.item.items.indexOf(this.item) > -1){
245
+ if(dragged.item[this.itemsKey] && dragged.item[this.itemsKey].indexOf(this.item) > -1){
243
246
  return
244
247
  }
245
248
 
@@ -249,7 +252,7 @@ export default{
249
252
 
250
253
  if(dragged.target !== this.item){
251
254
  const rect = this.$refs.item.getBoundingClientRect()
252
- const hasChildItems = Array.isArray(this.item.items)
255
+ const hasChildItems = Array.isArray(this.item[this.itemsKey])
253
256
 
254
257
  dragged.targetArea = hasChildItems ? [
255
258
  Math.round(rect.y + (rect.height * (2 / 3))),
@@ -286,14 +289,14 @@ export default{
286
289
  else if(dragged.dragArea === 3){
287
290
 
288
291
  // Drag to own parent is not allowed
289
- if(this.item.items && this.item.items.indexOf(dragged.item) > -1){
292
+ if(this.item[this.itemsKey] && this.item[this.itemsKey].indexOf(dragged.item) > -1){
290
293
  return
291
294
  }
292
295
 
293
296
  if(guide1.parentNode)
294
297
  guide1.parentNode.removeChild(guide1)
295
298
  this.$refs.item.classList.add(this.$style.dragInto)
296
- dragged.targetParent = this.item.items
299
+ dragged.targetParent = this.item[this.itemsKey]
297
300
  dragged.refItem = this.$refs.item
298
301
  }
299
302