@mixd-id/web-scaffold 0.1.2301231342 → 0.1.2301231343

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.2301231342",
4
+ "version": "0.1.2301231343",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -38,7 +38,6 @@
38
38
  "nprogress": "^0.2.0",
39
39
  "pinia": "^2.0.14",
40
40
  "prismjs": "^1.28.0",
41
- "sequelize": "^6.29.0",
42
41
  "serve-static": "^1.15.0",
43
42
  "tailwindcss": "^3.2.4",
44
43
  "vue": "^3.2.25",
@@ -48,6 +47,7 @@
48
47
  "@vitejs/plugin-vue": "^2.2.0",
49
48
  "autoprefixer": "^10.4.4",
50
49
  "postcss": "^8.4.12",
50
+ "sequelize": "^6.29.0",
51
51
  "vite": "^2.8.0"
52
52
  },
53
53
  "description": "This scaffold based on express vitejs vuejs",
@@ -86,7 +86,7 @@ export default{
86
86
  @apply h-[var(--h-cp)];
87
87
  @apply relative flex items-center justify-center;
88
88
  @apply whitespace-nowrap text-ellipsis overflow-hidden;
89
- @apply rounded-md;
89
+ @apply rounded-lg;
90
90
  }
91
91
  .button>*:first-child{
92
92
  @apply flex items-center justify-center
@@ -2,7 +2,7 @@
2
2
  <Teleport to=".Y29u">
3
3
  <div v-if="!!(computedState)" :class="$style.contextMenu" :style="computedStyle" ref="contextMenu">
4
4
  <div :class="bodyClass">
5
- <slot></slot>
5
+ <slot name="default" :context="context"></slot>
6
6
  </div>
7
7
  </div>
8
8
  </Teleport>
@@ -50,7 +50,8 @@ export default {
50
50
  data(){
51
51
  return {
52
52
  computedStyle: null,
53
- isOpen: false
53
+ isOpen: false,
54
+ context: null
54
55
  }
55
56
  },
56
57
 
@@ -105,7 +106,7 @@ export default {
105
106
  this.$refs.contextMenu.classList.remove(this.$style.active)
106
107
  },
107
108
 
108
- open(caller){
109
+ open(caller, context){
109
110
 
110
111
  if(caller){
111
112
  this.isOpen = true
@@ -118,6 +119,8 @@ export default {
118
119
  caller = caller.$el ? caller.$el :
119
120
  caller instanceof HTMLElement ? caller : null
120
121
 
122
+ this.context = context
123
+
121
124
  if(caller){
122
125
 
123
126
  this.$nextTick(() => {
@@ -1,13 +1,18 @@
1
1
  <template>
2
- <div :class="computedOuterClass">
3
- <slot v-if="editable && $slots['edit-area']" name="edit-area"></slot>
4
- <div v-else-if="editable" :class="$style.editArea" @click="edit"></div>
5
- <img :class="computedClass" :src="actualSrc" ref="img" :style="imageStyle"/>
6
- <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
7
- <slot></slot>
8
- <div :class="$style.loading" v-if="loading && spinnerType === 'spinner'">
9
- <svg class="animate-spin aspect-square w-[15%] 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>
2
+ <div :class="outerClass">
3
+
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>
6
+ <div v-else-if="!$slots['loading'] && status === 1 && spinnerType === 'spinner'" :class="$style.loading">
7
+ <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>
10
8
  </div>
9
+ <slot v-else-if="$slots['error'] && status === 3" name="error" :instance="this"></slot>
10
+ <img v-else :class="computedClass" :src="actualSrc" ref="img" />
11
+
12
+ <slot :instance="this"></slot>
13
+
14
+ <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
15
+
11
16
  </div>
12
17
  </template>
13
18
 
@@ -30,17 +35,11 @@ export default{
30
35
 
31
36
  class: String,
32
37
 
33
- outerClass: String,
34
-
35
38
  editable:{
36
39
  type: [ Boolean, String ],
37
40
  default: false
38
41
  },
39
42
 
40
- aspectRatio: {
41
- type: String
42
- },
43
-
44
43
  src:{
45
44
  type: [ String, Object ]
46
45
  },
@@ -59,36 +58,30 @@ export default{
59
58
 
60
59
  computed:{
61
60
 
62
- computedOuterClass(){
61
+ outerClass(){
63
62
  return [
64
- this.$style.img,
65
- this.outerClass,
66
- this.loading && this.spinnerType === 'shimmer' ? this.$style.shimmer : ''
63
+ this.$style.comp,
64
+ this.class,
65
+ this.status === 1 && this.spinnerType === 'shimmer' && !this.$slots['loading'] ?
66
+ this.$style.shimmer : ''
67
67
  ]
68
68
  .join(' ')
69
69
  },
70
70
 
71
71
  computedClass(){
72
72
  return [
73
+ this.$style.img,
73
74
  this.class
74
75
  ]
75
76
  .join(' ')
76
- },
77
-
78
- imageStyle(){
79
- return {
80
- ...(this.aspectRatio ? { 'aspect-ratio':this.aspectRatio } : {}),
81
- ...(this.actualSrc ? {} : { visibility:'hidden' })
82
- }
83
77
  }
84
78
 
85
79
  },
86
80
 
87
81
  data(){
88
82
  return {
89
- loading: false,
90
- actualSrc: null,
91
- loaded: false
83
+ status: 0, // 0:empty, 1:loading, 2:image, 3:error
84
+ actualSrc: 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
92
85
  }
93
86
  },
94
87
 
@@ -119,9 +112,9 @@ export default{
119
112
  async loadSrc(){
120
113
 
121
114
  if(typeof this.src === 'string') {
122
- if (!this.loaded && this.src.startsWith('data:image')) {
123
- this.loaded = true
115
+ if (this.src.startsWith('data:image')) {
124
116
  this.actualSrc = this.src
117
+ this.status = 2
125
118
  }
126
119
  else{
127
120
  const src = {}
@@ -140,38 +133,34 @@ export default{
140
133
 
141
134
  var img = new Image()
142
135
  img.addEventListener('load', () => {
143
- this.loaded = true
136
+ this.status = 2
144
137
  this.actualSrc = img.src
145
- this.loading = false
146
138
  })
147
139
  img.addEventListener('error', () => {
148
- this.loaded = true
140
+ this.status = 3
149
141
  this.actualSrc = this.defaultSrc
150
- this.loading = false
151
142
  })
152
143
  img.src = src[screens[b]]
153
- this.loading = true
144
+ this.status = 1
154
145
  }
155
146
  }
156
147
  }
157
148
  }
158
- else if(!this.loaded && this.src instanceof File){
149
+ else if(this.src instanceof File){
159
150
  var reader = new FileReader();
160
151
 
161
152
  reader.addEventListener('load', () => {
162
- this.loaded = true
153
+ this.status = 2
163
154
  this.actualSrc = reader.result
164
- this.loading = false
165
155
  }, false)
166
156
 
167
157
  reader.addEventListener('error', () => {
168
- this.loaded = true
158
+ this.status = 3
169
159
  this.actualSrc = this.defaultSrc
170
- this.loading = false
171
160
  })
172
161
 
173
162
  reader.readAsDataURL(this.src)
174
- this.loading = true
163
+ this.status = 1
175
164
  }
176
165
  }
177
166
 
@@ -180,7 +169,6 @@ export default{
180
169
  watch:{
181
170
 
182
171
  src(to){
183
- this.loaded = false
184
172
  this.loadSrc()
185
173
  },
186
174
 
@@ -195,10 +183,14 @@ export default{
195
183
 
196
184
  <style module>
197
185
 
198
- .img{
186
+ .comp{
199
187
  @apply relative;
200
188
  }
201
189
 
190
+ .img{
191
+ @apply object-contain;
192
+ }
193
+
202
194
  .editArea{
203
195
  @apply absolute top-0 left-0 right-0 bottom-0;
204
196
  }
@@ -209,8 +201,7 @@ export default{
209
201
  }
210
202
 
211
203
  .shimmer{
212
- @apply bg-text-100 animate-pulse;
204
+ @apply bg-text-200 animate-pulse;
213
205
  }
214
206
 
215
-
216
207
  </style>