@mixd-id/web-scaffold 0.1.230406154 → 0.1.230406156

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.230406154",
4
+ "version": "0.1.230406156",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -2,14 +2,17 @@
2
2
  <div :class="compClass" @click="onClick" @mousemove="onMouseMove" @mousedown="onMouseDown">
3
3
 
4
4
  <slot v-if="$slots['empty'] && status === 0" name="empty" :instance="this"></slot>
5
- <slot v-else-if="$slots['loading'] && status === 1" name="loading" :instance="this"></slot>
5
+
6
+ <slot v-else-if="$slots['loading'] && status === 1" name="loading" :instance="this"></slot>
6
7
  <div v-else-if="!$slots['loading'] && status === 1 && spinnerType === 'spinner'" :class="$style.loading">
7
8
  <svg class="animate-spin aspect-square w-[15%] min-w-[14px] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
8
9
  </div>
10
+
9
11
  <slot v-else-if="$slots['error'] && status === 3" name="error" :instance="this"></slot>
12
+
10
13
  <img v-else :class="computedItemClass" :src="actualSrc" ref="img" />
11
14
 
12
- <slot :instance="this"></slot>
15
+ <slot></slot>
13
16
 
14
17
  <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
15
18
 
@@ -67,7 +70,7 @@ export default{
67
70
 
68
71
  actualSrc(){
69
72
  if(typeof window !== 'undefined'){
70
- return this.mediaSrc[this.$screenPrefix]
73
+ return this.mediaSrc[this.$screenPrefix.value]
71
74
  }
72
75
  },
73
76
 
@@ -117,6 +120,12 @@ export default{
117
120
 
118
121
  methods:{
119
122
 
123
+ reset(){
124
+ this.$refs.file.value = null
125
+ this.status = 0
126
+ this.$emit('change', null, null)
127
+ },
128
+
120
129
  onResize(){
121
130
  this.loadSrc()
122
131
  },
@@ -140,19 +149,18 @@ export default{
140
149
  async loadSrc(){
141
150
 
142
151
  // src: String | Array | File
143
-
144
152
  if(!this.visibled){
145
153
  return
146
154
  }
147
155
 
148
- if(this.$screenPrefix in this.mediaSrc){
156
+ if(this.$screenPrefix.value in this.mediaSrc){
149
157
  return
150
158
  }
151
159
 
152
160
  if(typeof this.src === 'string') {
153
161
 
154
162
  if (this.src.startsWith('data:image')) {
155
- this.mediaSrc[this.$screenPrefix] = this.src
163
+ this.mediaSrc[this.$screenPrefix.value] = this.src
156
164
  this.status = 2
157
165
  }
158
166
  else{
@@ -183,12 +191,12 @@ export default{
183
191
  img.addEventListener('load', () => {
184
192
  if(img.getAttribute('data-src') !== this.src) return
185
193
  this.status = 2
186
- this.mediaSrc[this.$screenPrefix] = img.src
194
+ this.mediaSrc[this.$screenPrefix.value] = img.src
187
195
  })
188
196
  img.addEventListener('error', (err) => {
189
197
  if(img.getAttribute('data-src') !== this.src) return
190
198
  this.status = 3
191
- this.mediaSrc[this.$screenPrefix] = this.defaultSrc
199
+ this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
192
200
  })
193
201
  img.src = imgSrc
194
202
  img.setAttribute('data-src', this.src)
@@ -215,11 +223,11 @@ export default{
215
223
  var img = new Image()
216
224
  img.addEventListener('load', () => {
217
225
  this.status = 2
218
- this.mediaSrc[this.$screenPrefix] = img.src
226
+ this.mediaSrc[this.$screenPrefix.value] = img.src
219
227
  })
220
228
  img.addEventListener('error', (err) => {
221
229
  this.status = 3
222
- this.mediaSrc[this.$screenPrefix] = this.defaultSrc
230
+ this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
223
231
  })
224
232
  img.src = imgSrc
225
233
  this.status = 1
@@ -230,12 +238,12 @@ export default{
230
238
 
231
239
  reader.addEventListener('load', () => {
232
240
  this.status = 2
233
- this.mediaSrc[this.$screenPrefix] = reader.result
241
+ this.mediaSrc[this.$screenPrefix.value] = reader.result
234
242
  }, false)
235
243
 
236
244
  reader.addEventListener('error', () => {
237
245
  this.status = 3
238
- this.mediaSrc[this.$screenPrefix] = this.defaultSrc
246
+ this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
239
247
  })
240
248
 
241
249
  reader.readAsDataURL(this.src)
@@ -15,7 +15,7 @@ import {parseBoolean} from "../utils/helpers.mjs";
15
15
 
16
16
  export default{
17
17
 
18
- emits: [ 'change' ],
18
+ emits: [ 'change', 'update:modelValue' ],
19
19
 
20
20
  props:{
21
21
  name: String,
@@ -3,15 +3,24 @@
3
3
 
4
4
  <div class="flex flex-col gap-1">
5
5
  <label class="flex-1 text-text-400">Src</label>
6
- <Image ref="image"
6
+ <Image :ref="`image${index}`"
7
7
  v-for="(_viewType, index) in viewTypes"
8
8
  v-show="_viewType.value === viewType"
9
9
  :src="imageSrc(item.props.src[index])"
10
- class="w-[120px] bg-text-50 rounded-lg"
10
+ class="w-[120px] min-h-[60px] bg-text-50 rounded-lg"
11
11
  :editable="true"
12
- @click="$refs.image[index].edit()"
13
- @change="(base64, file) => { item.props.src[index] = file; apply() }"
14
- />
12
+ @click="$refs[`image${index}`][0].edit()"
13
+ @change="(base64, file) => { item.props.src[index] = file; apply() }">
14
+ <button type="button" class="absolute top-1 right-1 rounded-full bg-white" v-if="item.props.src[index]"
15
+ @click.stop="$refs[`image${index}`][0].reset()">
16
+ <svg width="19" height="19" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg>
17
+ </button>
18
+ <template #empty>
19
+ <div class="flex items-center justify-center absolute left-0 top-0 right-0 bottom-0">
20
+ <label class="text-text-300">Upload</label>
21
+ </div>
22
+ </template>
23
+ </Image>
15
24
  </div>
16
25
 
17
26
  <div>
@@ -117,8 +117,6 @@
117
117
  <Textbox v-model="context.item[header.key]" />
118
118
  </div>
119
119
 
120
- <pre>{{ context.item }}</pre>
121
-
122
120
  </div>
123
121
  </template>
124
122
  </Modal>
@@ -18,7 +18,7 @@
18
18
  <template #default="{ context }">
19
19
  <div class="flex-1">
20
20
 
21
- <div v-if="tabIndex === 1" class="p-6 grid grid-cols-3 gap-6">
21
+ <div v-if="tabIndex === 1" class="p-6 grid grid-cols-3 gap-4">
22
22
  <button v-for="component in groupedComponents['Components']"
23
23
  type="button"
24
24
  @click="apply(component.type)"
@@ -27,7 +27,7 @@
27
27
  </button>
28
28
  </div>
29
29
 
30
- <div v-if="tabIndex === 2" class="p-6 grid grid-cols-2 gap-6">
30
+ <div v-if="tabIndex === 2" class="p-6 grid grid-cols-3 gap-4">
31
31
  <button v-for="component in groupedComponents['Containers']"
32
32
  type="button"
33
33
  @click="apply(component.type)"
@@ -36,7 +36,7 @@
36
36
  </button>
37
37
  </div>
38
38
 
39
- <div v-if="tabIndex === 3" class="p-6 grid gap-6">
39
+ <div v-if="tabIndex === 3" class="p-6 grid grid-cols-3 gap-4">
40
40
  <button v-for="component in groupedComponents['Widgets']"
41
41
  type="button"
42
42
  @click="apply(component.type)"
@@ -117,7 +117,7 @@ export default{
117
117
  }
118
118
 
119
119
  .compSelectorBtn{
120
- @apply block w-full rounded-lg p-3 text-left;
120
+ @apply block w-full rounded-lg p-3 text-left border-[1px] border-text-50;
121
121
  @apply bg-base-400 hover:bg-base-300 dark:bg-base-400 dark:hover:bg-base-500;
122
122
  }
123
123
 
@@ -154,7 +154,7 @@
154
154
  <div class="flex flex-row gap-2">
155
155
  <label class="flex-1 text-text-400">{{ $t('Header')}}</label>
156
156
  <button type="button" class="text-primary"
157
- @click="$refs.webPageComponentSelector.open({ items:layout.headers })">
157
+ @click="$refs.webPageComponentSelector.open({ items:layout.headers, isLayout:true })">
158
158
  Add Header
159
159
  </button>
160
160
  </div>
@@ -174,7 +174,7 @@
174
174
  <div class="flex flex-row gap-2">
175
175
  <label class="flex-1 text-text-400">{{ $t('Footer')}}</label>
176
176
  <button type="button" class="text-primary"
177
- @click="$refs.webPageComponentSelector.open({ items:layout.footers })">
177
+ @click="$refs.webPageComponentSelector.open({ items:layout.footers, isLayout:true })">
178
178
  Add Footer
179
179
  </button>
180
180
  </div>
@@ -323,12 +323,14 @@
323
323
  <div class="px-4 bg-base-300 pt-2 relative">
324
324
  <Tabs v-model="store.viewType" :items="viewTypes" variant="minimal">
325
325
  <template #tab="{ item }">
326
- <div v-if="item.value === ''" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md"
326
+ <div v-if="item.value === ''" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md overflow-hidden"
327
327
  :class="store.viewType === item.value ? 'bg-base-400 border-text-50' : 'border-transparent'">
328
+ <div v-if="store.viewType === item.value" class="absolute top-0 left-0 right-0 h-[2px] bg-primary"></div>
328
329
  Mobile
329
330
  </div>
330
- <div v-else-if="item.value === 'md:'" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md"
331
+ <div v-else-if="item.value === 'md:'" class="px-6 p-2 border-[1px] border-b-0 relative top-[1px] rounded-t-md overflow-hidden"
331
332
  :class="store.viewType === item.value ? 'bg-base-400 border-text-50' : 'border-transparent'">
333
+ <div v-if="store.viewType === item.value" class="absolute top-0 left-0 right-0 h-[2px] bg-primary"></div>
332
334
  Tablet
333
335
  </div>
334
336
  </template>
@@ -513,7 +515,7 @@ export default{
513
515
 
514
516
  methods: {
515
517
 
516
- addComponent({ type, items }){
518
+ addComponent({ type, items, isLayout }){
517
519
 
518
520
  let obj = this.availableComponents.find((_) => _.type === type)
519
521
  obj = JSON.parse(JSON.stringify(obj))
@@ -529,6 +531,8 @@ export default{
529
531
  this.store.selectedComponent = [ obj.uid ]
530
532
 
531
533
  this.$refs.webPageComponentSelector.close()
534
+
535
+ isLayout ? this.saveLayout() : this.save()
532
536
  },
533
537
 
534
538
  addDatasource(datasource){