@mixd-id/web-scaffold 0.1.230406165 → 0.1.230406167

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.230406165",
4
+ "version": "0.1.230406167",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
 
18
18
  <div :class="$style.details" v-if="message">
19
- <p class="text-center break-all whitespace-pre-line">{{ message }}</p>
19
+ <p class="text-center break-words">{{ message }}</p>
20
20
  </div>
21
21
 
22
22
  <div :class="$style.details" v-if="details">
@@ -1,18 +1,17 @@
1
1
  <template>
2
- <div :class="compClass" @click="onClick" @mousemove="onMouseMove" @mousedown="onMouseDown">
2
+ <div :class="$style.comp" @click="onClick" @mousemove="onMouseMove" @mousedown="onMouseDown">
3
3
 
4
- <slot v-if="$slots['empty'] && status === 0" name="empty" :instance="this"></slot>
4
+ <slot v-if="status === 0" name="empty" :instance="this"></slot>
5
5
 
6
- <slot v-else-if="$slots['loading'] && status === 1" name="loading" :instance="this"></slot>
7
- <div v-else-if="!$slots['loading'] && status === 1 && spinnerType === 'spinner'" :class="$style.loading">
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>
9
- </div>
6
+ <slot v-else-if="status === 1" name="loading">
7
+ <div :class="$style.loading + (spinnerType === 'shimmer' ? ' ' + $style.shimmer : '')">
8
+ <svg v-if="spinnerType !== 'shimmer'" 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>
9
+ </div>
10
+ </slot>
10
11
 
11
- <slot v-else-if="$slots['error'] && status === 3" name="error" :instance="this"></slot>
12
+ <img v-else-if="status === 2" :class="computedItemClass" :src="actualSrc" ref="img" />
12
13
 
13
- <img v-else :class="computedItemClass" :src="actualSrc" ref="img" />
14
-
15
- <slot></slot>
14
+ <slot v-else-if="status === 3" name="error" :instance="this"></slot>
16
15
 
17
16
  <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
18
17
 
@@ -68,22 +67,6 @@ export default{
68
67
 
69
68
  computed:{
70
69
 
71
- actualSrc(){
72
- if(typeof window !== 'undefined'){
73
- return this.mediaSrc[this.$screenPrefix.value]
74
- }
75
- },
76
-
77
- compClass(){
78
- return [
79
- this.$style.comp,
80
- this.status === 1 && this.spinnerType === 'shimmer' && !this.$slots['loading'] ?
81
- this.$style.shimmer : ''
82
- ]
83
- .filter(_=>_)
84
- .join(' ')
85
- },
86
-
87
70
  computedItemClass(){
88
71
  return [
89
72
  this.$style.img,
@@ -99,14 +82,14 @@ export default{
99
82
  return {
100
83
  status: 0, // 0:empty, 1:loading, 2:image, 3:error
101
84
  moved: false,
102
- mediaSrc: {},
103
- visibled: false
85
+ isVisible: false,
86
+ actualSrc: null,
104
87
  }
105
88
  },
106
89
 
107
90
  mounted(){
108
91
  this.$observe.once(this.$el, () => {
109
- this.visibled = true
92
+ this.isVisible = true
110
93
  this.loadSrc()
111
94
  })
112
95
 
@@ -126,10 +109,6 @@ export default{
126
109
  this.$emit('change', null, null)
127
110
  },
128
111
 
129
- onResize(){
130
- this.loadSrc()
131
- },
132
-
133
112
  onChange(e){
134
113
  if(e.target.files.length > 0){
135
114
  var reader = new FileReader();
@@ -140,6 +119,10 @@ export default{
140
119
  }
141
120
  },
142
121
 
122
+ onResize(){
123
+ this.loadSrc()
124
+ },
125
+
143
126
  edit(){
144
127
  if(this.$refs.file){
145
128
  this.$refs.file.click()
@@ -148,19 +131,14 @@ export default{
148
131
 
149
132
  async loadSrc(){
150
133
 
151
- // src: String | Array | File
152
- if(!this.visibled){
153
- return
154
- }
155
-
156
- if(this.$screenPrefix.value in this.mediaSrc){
134
+ if(!this.isVisible){
157
135
  return
158
136
  }
159
137
 
160
138
  if(typeof this.src === 'string') {
161
139
 
162
140
  if (this.src.startsWith('data:image')) {
163
- this.mediaSrc[this.$screenPrefix.value] = this.src
141
+ this.actualSrc = this.src
164
142
  this.status = 2
165
143
  }
166
144
  else{
@@ -191,12 +169,12 @@ export default{
191
169
  img.addEventListener('load', () => {
192
170
  if(img.getAttribute('data-src') !== this.src) return
193
171
  this.status = 2
194
- this.mediaSrc[this.$screenPrefix.value] = img.src
172
+ this.actualSrc = img.src
195
173
  })
196
174
  img.addEventListener('error', (err) => {
197
175
  if(img.getAttribute('data-src') !== this.src) return
198
176
  this.status = 3
199
- this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
177
+ this.actualSrc = this.defaultSrc
200
178
  })
201
179
  img.src = imgSrc
202
180
  img.setAttribute('data-src', this.src)
@@ -223,11 +201,11 @@ export default{
223
201
  var img = new Image()
224
202
  img.addEventListener('load', () => {
225
203
  this.status = 2
226
- this.mediaSrc[this.$screenPrefix.value] = img.src
204
+ this.actualSrc = img.src
227
205
  })
228
206
  img.addEventListener('error', (err) => {
229
207
  this.status = 3
230
- this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
208
+ this.actualSrc = this.defaultSrc
231
209
  })
232
210
  img.src = imgSrc
233
211
  this.status = 1
@@ -238,12 +216,12 @@ export default{
238
216
 
239
217
  reader.addEventListener('load', () => {
240
218
  this.status = 2
241
- this.mediaSrc[this.$screenPrefix.value] = reader.result
219
+ this.actualSrc = reader.result
242
220
  }, false)
243
221
 
244
222
  reader.addEventListener('error', () => {
245
223
  this.status = 3
246
- this.mediaSrc[this.$screenPrefix.value] = this.defaultSrc
224
+ this.actualSrc = this.defaultSrc
247
225
  })
248
226
 
249
227
  reader.readAsDataURL(this.src)
@@ -269,15 +247,10 @@ export default{
269
247
 
270
248
  watch:{
271
249
 
272
- src(to){
273
- this.mediaSrc = {}
250
+ src(){
274
251
  this.loadSrc()
275
252
  },
276
253
 
277
- "isMobile.value"(to){
278
- this.loadSrc()
279
- }
280
-
281
254
  }
282
255
  }
283
256
 
@@ -409,6 +409,9 @@ export default{
409
409
  onHooks(model, event, items){
410
410
 
411
411
  if(model === this.subscriptionObj.model && Array.isArray(items)){
412
+ if(this.$isDebugMode)
413
+ console.log('onHooks', model, event, items)
414
+
412
415
  switch(event){
413
416
 
414
417
  case 'create':
package/src/index.js CHANGED
@@ -321,6 +321,8 @@ export default{
321
321
  })
322
322
  })
323
323
 
324
+ const privateVars = {}
325
+
324
326
  app.config.globalProperties.uniqid = uniqid
325
327
  app.config.globalProperties.$download = download
326
328
  app.config.globalProperties.$preload = preload
@@ -332,6 +334,15 @@ export default{
332
334
  app.config.globalProperties.warn = consoleWarn
333
335
  app.config.globalProperties.info = consoleInfo
334
336
 
337
+ app.config.globalProperties.$isDev = () => import.meta.env.DEV
338
+
339
+ app.config.globalProperties.$isDebugMode = () => {
340
+ if(!('isDebugMode' in privateVars)){
341
+ privateVars.isDebugMode = location.search.indexOf('debug-mode') >= 0 || import.meta.env.DEV
342
+ }
343
+ return privateVars.isDebugMode
344
+ }
345
+
335
346
  app.component('Ahref', defineAsyncComponent(() => import("./components/Ahref.vue")))
336
347
  app.component('Alert', defineAsyncComponent(() => import("./components/Alert.vue")))
337
348
  app.component('Article', defineAsyncComponent(() => import("./components/Article.vue")))
@@ -366,6 +366,24 @@ const createComponentInstance = function(component){
366
366
  return component
367
367
  }
368
368
 
369
+ const deepObjectContainsObject = (outerObject, innerObject) => {
370
+ for (const key in innerObject) {
371
+ if (innerObject.hasOwnProperty(key)) {
372
+ if (typeof innerObject[key] === 'object' && typeof outerObject[key] === 'object') {
373
+ // If both properties are objects, recursively check them
374
+ if (!deepObjectContainsObject(outerObject[key], innerObject[key])) {
375
+ return false; // Nested objects do not match
376
+ }
377
+ } else {
378
+ if (outerObject[key] !== innerObject[key]) {
379
+ return false; // Property in innerObject doesn't exist in outerObject or values don't match
380
+ }
381
+ }
382
+ }
383
+ }
384
+ return true; // All properties and values in innerObject exist in outerObject
385
+ }
386
+
369
387
 
370
388
  module.exports = {
371
389
  ceil,
@@ -389,4 +407,5 @@ module.exports = {
389
407
  generateStylesheet,
390
408
  hexToRgb,
391
409
  createComponentInstance,
410
+ deepObjectContainsObject,
392
411
  }
@@ -3,7 +3,8 @@
3
3
 
4
4
  <div>
5
5
  <strong class="text-text-400">Layout</strong>
6
- <div class="grid grid-cols-4 gap-4 mt-4">
6
+ <div class="h-[1px] bg-text-100 mt-2 mb-4"></div>
7
+ <div class="grid grid-cols-4 gap-4">
7
8
 
8
9
  <div class="col-span-2">
9
10
  <label :class="$style.label">Aspect Ratio</label>
@@ -156,12 +157,11 @@
156
157
  </div>
157
158
  </div>
158
159
 
159
- <div class="h-[1px] bg-text-100 my-4"></div>
160
-
161
160
  <div v-for="(_, idx) in viewTypes"
162
161
  v-show="viewType === _.value">
163
162
  <strong class="text-text-400">Spacing</strong>
164
- <div class="grid grid-cols-2 gap-4 mt-4">
163
+ <div class="h-[1px] bg-text-100 mt-2 mb-4"></div>
164
+ <div class="grid grid-cols-2 gap-4">
165
165
  <div>
166
166
  <label :class="$style.label">Padding</label>
167
167
  <PaddingSetting v-model="padding[idx]"
@@ -179,13 +179,11 @@
179
179
  </div>
180
180
  </div>
181
181
 
182
- <div class="h-[1px] bg-text-100 my-4"></div>
183
-
184
182
  <div>
185
183
  <strong class="text-text-400">Sizing</strong>
184
+ <div class="h-[1px] bg-text-100 mt-2 mb-4"></div>
186
185
  <div v-for="(_, idx) in viewTypes"
187
- v-show="viewType === _.value"
188
- class="mt-4">
186
+ v-show="viewType === _.value">
189
187
  <div class="grid grid-cols-2 gap-4">
190
188
 
191
189
  <div class="col-span-2 mt-1 grid grid-cols-3 gap-4">
@@ -338,11 +336,10 @@
338
336
  </div>
339
337
  </div>
340
338
 
341
- <div class="h-[1px] bg-text-100 my-4"></div>
342
-
343
339
  <div>
344
340
  <strong class="text-text-400">Grid</strong>
345
- <div class="grid grid-cols-2 gap-4 mt-4">
341
+ <div class="h-[1px] bg-text-100 mt-2 mb-4"></div>
342
+ <div class="grid grid-cols-2 gap-4">
346
343
  <div>
347
344
  <label class="flex-1 text-text-400">Column Span</label>
348
345
  <Dropdown v-for="(_viewType, index) in viewTypes"
@@ -367,11 +364,12 @@
367
364
  </div>
368
365
  </div>
369
366
 
370
- <div class="h-[1px] bg-text-100 my-4"></div>
371
-
372
367
  <div class="flex flex-col gap-4">
373
368
 
374
- <strong class="flex-1 text-text-400 mb-4">Background</strong>
369
+ <div>
370
+ <strong class="flex-1 text-text-400">Background</strong>
371
+ <div class="h-[1px] bg-text-100 mt-2"></div>
372
+ </div>
375
373
 
376
374
  <div class="flex flex-row gap-4">
377
375
  <label class="flex-1 text-text-400">Color</label>
@@ -458,11 +456,12 @@
458
456
 
459
457
  </div>
460
458
 
461
- <div class="h-[1px] bg-text-100 my-4"></div>
462
-
463
459
  <div class="flex flex-col gap-4">
464
460
 
465
- <strong class="flex-1 text-text-400 mb-4">Border</strong>
461
+ <div>
462
+ <strong class="flex-1 text-text-400 mb-4">Border</strong>
463
+ <div class="h-[1px] bg-text-100 mt-2"></div>
464
+ </div>
466
465
 
467
466
  <div class="flex flex-row items-center gap-4">
468
467
  <label class="flex-1 text-text-400">Width</label>
@@ -527,12 +526,10 @@
527
526
 
528
527
  </div>
529
528
 
530
- <div class="h-[1px] bg-text-100 my-4"></div>
531
-
532
529
  <div>
533
- <strong class="flex-1 text-text-400">Effects</strong>
534
-
535
- <div class="grid grid-cols-2 gap-4 mt-4">
530
+ <strong class="flex-1 text-text-400">Effects</strong>
531
+ <div class="h-[1px] bg-text-100 mt-2 mb-4"></div>
532
+ <div class="grid grid-cols-2 gap-4">
536
533
 
537
534
  <div>
538
535
  <label :class="$style.label">Opacity</label>
@@ -821,7 +818,7 @@ export default{
821
818
  <style module>
822
819
 
823
820
  .comp{
824
- @apply flex flex-col gap-4;
821
+ @apply flex flex-col gap-6;
825
822
  }
826
823
 
827
824
  .label{
@@ -1,18 +1,31 @@
1
1
  <template>
2
- <div :class="$style.comp">
3
-
4
- <div>
5
- <div class="flex flex-row gap-2">
6
- <label class="text-text-400 flex-1">Logo</label>
7
- <button type="button" class="text-primary" @click="$refs.image.edit()">Change</button>
8
- </div>
9
- <div class="mt-1">
10
- <div :class="$style.imageBg">
11
- <Image ref="image" :src="logoSrc" class="w-[100px] min-h-[48px]" :editable="true" @click="$refs.image.edit()"
12
- @change="setImage" />
13
- </div>
14
- </div>
15
- </div>
2
+ <div class="flex flex-col gap-6">
3
+
4
+ <div v-if="viewType === ''" class="flex flex-col gap-4">
5
+
6
+ <div class="flex flex-col gap-1">
7
+ <label class="flex-1 text-text-400">Model</label>
8
+ <Dropdown v-model="item.props.variant"
9
+ @change="$emit('change')">
10
+ <option value="Header1">Model 1</option>
11
+ <option value="Header2">Model 2</option>
12
+ </Dropdown>
13
+ </div>
14
+
15
+ <div>
16
+ <div class="flex flex-row gap-2">
17
+ <label class="text-text-400 flex-1">Logo</label>
18
+ <button type="button" class="text-primary" @click="$refs.image.edit()">Change</button>
19
+ </div>
20
+ <div class="mt-1">
21
+ <div :class="$style.imageBg">
22
+ <Image ref="image" :src="logoSrc" class="w-[100px] min-h-[48px]" :editable="true" @click="$refs.image.edit()"
23
+ @change="setImage" />
24
+ </div>
25
+ </div>
26
+ </div>
27
+
28
+ </div>
16
29
 
17
30
  <ComponentSetting :item="item"
18
31
  :view-type="viewType"
@@ -70,10 +83,6 @@ export default{
70
83
 
71
84
  <style module>
72
85
 
73
- .comp{
74
-
75
- }
76
-
77
86
  .imageBg{
78
87
  @apply p-2 bg-white;
79
88
  background-image: radial-gradient(rgba(var(--primary-500)) 1px, transparent 1px);