@mixd-id/web-scaffold 0.1.2301231317 → 0.1.2301231319

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.2301231317",
4
+ "version": "0.1.2301231319",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -27,9 +27,7 @@
27
27
  "dayjs": "^1.11.2",
28
28
  "express": "^4.18.1",
29
29
  "glob": "^8.0.3",
30
- "lodash": "^4.17.21",
31
30
  "lodash-es": "^4.17.21",
32
- "lodash.throttle": "^4.1.1",
33
31
  "nprogress": "^0.2.0",
34
32
  "pinia": "^2.0.14",
35
33
  "prismjs": "^1.28.0",
@@ -123,9 +123,7 @@ export default{
123
123
  })
124
124
  left *= -1
125
125
 
126
- //console.log('`setPosition`', index, left)
127
-
128
- if(noAnimation){
126
+ if(!noAnimation){
129
127
  this.$el.firstElementChild.addEventListener('transitionend', function(){
130
128
  this.classList.remove('transition-carousel')
131
129
  })
@@ -1,8 +1,11 @@
1
1
  <template>
2
- <div :class="$style.img">
2
+ <div :class="computedOuterClass">
3
3
  <img :class="computedClass" :src="actualSrc" ref="img" @click="onClick" :style="imageStyle"/>
4
4
  <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
5
5
  <slot></slot>
6
+ <div :class="$style.isLoading" v-if="isLoading">
7
+ <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>
8
+ </div>
6
9
  </div>
7
10
  </template>
8
11
 
@@ -42,13 +45,20 @@ export default{
42
45
 
43
46
  defaultSrc: {
44
47
  type: String,
45
- default: '/images/no-image.png'
48
+ default: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yMS4xNTkyIDIxLjA4MjhDMjEuNjc5OCAyMC41NDMyIDIyIDE5LjgwOSAyMiAxOVY1QzIyIDMuMzQzMTUgMjAuNjU2OSAyIDE5IDJINUMzLjM0MzE1IDIgMiAzLjM0MzE1IDIgNVYxOUMyIDIwLjY1NjkgMy4zNDMxNSAyMiA1IDIySDE5QzE5LjI5NjIgMjIgMTkuNTgyMyAyMS45NTcxIDE5Ljg1MjUgMjEuODc3MUMxOS44NjU4IDIxLjg3MzIgMTkuODc5IDIxLjg2OTIgMTkuODkyMSAyMS44NjUxQzIwLjI1ODYgMjEuNzUxMSAyMC41OTUgMjEuNTY4NyAyMC44ODYzIDIxLjMzMjlDMjAuODkzNyAyMS4zMjY5IDIwLjkwMSAyMS4zMjEgMjAuOTA4MyAyMS4zMTQ5QzIwLjk4MjQgMjEuMjUzOCAyMS4wNTM1IDIxLjE4OTIgMjEuMTIxMyAyMS4xMjEzQzIxLjEzNDEgMjEuMTA4NiAyMS4xNDY3IDIxLjA5NTcgMjEuMTU5MiAyMS4wODI4Wk0xOSAzLjVINUM0LjE3MTU3IDMuNSAzLjUgNC4xNzE1NyAzLjUgNVYxMi43TDYuMDUyOTIgOS42MzY0OUM3LjIxNTY2IDguMjQxMjEgOS4zNDE3NyA4LjE5MTAyIDEwLjU2OSA5LjUyOTg3TDIwLjE0MTggMTkuOTcyOEMyMC4zNjUyIDE5LjcxMDkgMjAuNSAxOS4zNzEyIDIwLjUgMTlWNUMyMC41IDQuMTcxNTcgMTkuODI4NCAzLjUgMTkgMy41Wk01IDIwLjVDNC4xNzE1NyAyMC41IDMuNSAxOS44Mjg0IDMuNSAxOVYxNS4wNDMxTDcuMjA1MjYgMTAuNTk2OEM3LjcxMzk1IDkuOTg2MzMgOC41OTE0NCA5Ljg5MDgxIDkuMjEzOTUgMTAuMzI0OUM5LjIxOTUxIDEwLjMyODggOS4yMjUwNSAxMC4zMzI3IDkuMjMwNTcgMTAuMzM2N0M5LjMxMzMyIDEwLjM5NjEgOS4zOTE0MSAxMC40NjUgOS40NjMzMiAxMC41NDM1TDE4LjU5MDEgMjAuNUg1WiIgZmlsbD0iYmxhY2siIGZpbGwtb3BhY2l0eT0iLjA4Ii8+CjxjaXJjbGUgY3g9IjE3IiBjeT0iNyIgcj0iMS4yNSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLW9wYWNpdHk9Ii4wOCIgc3Ryb2tlLXdpZHRoPSIxLjUiLz4KPC9zdmc+Cg=="
46
49
  }
47
50
 
48
51
  },
49
52
 
50
53
  computed:{
51
54
 
55
+ computedOuterClass(){
56
+ return [
57
+ this.$style.img
58
+ ]
59
+ .join(' ')
60
+ },
61
+
52
62
  computedClass(){
53
63
  return [
54
64
  this.class
@@ -58,7 +68,8 @@ export default{
58
68
 
59
69
  imageStyle(){
60
70
  return {
61
- ...(this.aspectRatio ? { 'aspect-ratio':this.aspectRatio } : {})
71
+ ...(this.aspectRatio ? { 'aspect-ratio':this.aspectRatio } : {}),
72
+ ...(this.actualSrc ? {} : { visibility:'hidden' })
62
73
  }
63
74
  }
64
75
 
@@ -67,7 +78,9 @@ export default{
67
78
  data(){
68
79
  return {
69
80
  visible: 0,
70
- actualSrc: ''
81
+ isLoading: false,
82
+ actualSrc: null,
83
+ loaded: false
71
84
  }
72
85
  },
73
86
 
@@ -96,8 +109,12 @@ export default{
96
109
  },
97
110
 
98
111
  async loadSrc(){
112
+
113
+ this.loaded = false
114
+
99
115
  if(typeof this.src === 'string') {
100
116
  if (this.src.startsWith('data:image')) {
117
+ this.loaded = true
101
118
  this.actualSrc = this.src
102
119
  }
103
120
  else{
@@ -117,33 +134,52 @@ export default{
117
134
 
118
135
  var img = new Image()
119
136
  img.addEventListener('load', () => {
137
+ this.loaded = true
120
138
  this.actualSrc = img.src
139
+ this.isLoading = false
140
+ })
141
+ img.addEventListener('error', () => {
142
+ this.loaded = true
143
+ this.actualSrc = this.defaultSrc
144
+ this.isLoading = false
121
145
  })
122
- img.addEventListener('error', () => {})
123
146
  img.src = src[screens[b]]
124
-
125
- //this.actualSrc = src[screens[b]]
126
147
  }
127
148
  }
128
149
  }
129
150
  }
130
-
131
151
  else if(this.src instanceof File){
132
152
  var reader = new FileReader();
153
+
133
154
  reader.addEventListener('load', () => {
155
+ this.loaded = true
134
156
  this.actualSrc = reader.result
157
+ this.isLoading = false
135
158
  }, false)
159
+
160
+ reader.addEventListener('error', () => {
161
+ this.loaded = true
162
+ this.actualSrc = this.defaultSrc
163
+ this.isLoading = false
164
+ })
165
+
136
166
  reader.readAsDataURL(this.src)
137
167
  }
138
-
139
168
  }
140
169
 
141
170
  },
142
171
 
143
172
  watch:{
144
173
 
145
- src(){
174
+ src(to){
146
175
  this.loadSrc()
176
+
177
+ window.setTimeout(() => {
178
+ if(!this.loaded){
179
+ this.actualSrc = null
180
+ this.isLoading = true
181
+ }
182
+ }, 200)
147
183
  }
148
184
 
149
185
  }
@@ -154,7 +190,12 @@ export default{
154
190
  <style module>
155
191
 
156
192
  .img{
157
- @apply relative
193
+ @apply relative;
194
+ }
195
+
196
+ .isLoading{
197
+ @apply absolute top-0 left-0 right-0 bottom-0;
198
+ @apply flex items-center justify-center;
158
199
  }
159
200
 
160
201
 
@@ -52,7 +52,7 @@ export default{
52
52
  }
53
53
 
54
54
  .previewModal{
55
- @apply !bg-transparent !w-screen !h-screen !bg-base-300/80;
55
+ @apply !w-screen !h-screen !bg-base-300;
56
56
  max-width: unset !important;
57
57
  max-height: unset !important;
58
58
  }
@@ -179,7 +179,7 @@
179
179
 
180
180
  <script>
181
181
 
182
- import throttle from "lodash.throttle";
182
+ import throttle from "lodash-es/throttle";
183
183
 
184
184
  export default{
185
185
 
@@ -248,6 +248,10 @@ export default{
248
248
 
249
249
  mounted() {
250
250
  this.socket.onAny(this.onHooks)
251
+
252
+ window.addEventListener('focus', () => {
253
+ this.load()
254
+ })
251
255
  },
252
256
 
253
257
  unmounted() {
@@ -180,7 +180,7 @@
180
180
 
181
181
  <script>
182
182
 
183
- import throttle from "lodash.throttle";
183
+ import throttle from "lodash-es/throttle";
184
184
  import {parseBoolean} from "../helper";
185
185
 
186
186
  export default{
@@ -133,9 +133,9 @@ export default{
133
133
  this.$emit('change', e.target.value)
134
134
  },
135
135
 
136
- onBlur(){
136
+ onBlur(e){
137
137
  this.isActive = false
138
- this.$emit('blur')
138
+ this.$emit('blur', e.target.value)
139
139
  },
140
140
 
141
141
  onKeyDown(e){
@@ -21,7 +21,7 @@
21
21
 
22
22
  <script>
23
23
 
24
- import throttle from "lodash.throttle"
24
+ import throttle from "lodash-es/throttle";
25
25
 
26
26
  export default{
27
27
 
@@ -66,7 +66,7 @@
66
66
 
67
67
  <script>
68
68
 
69
- import throttle from "lodash.throttle";
69
+ import throttle from "lodash-es/throttle";
70
70
  import dayjs from "dayjs";
71
71
 
72
72
  const _DEFAULT_COLUMN_WIDTH = '100px'