@mixd-id/web-scaffold 0.1.230406048 → 0.1.230406050

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.230406048",
4
+ "version": "0.1.230406050",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -110,7 +110,7 @@ export default {
110
110
  return this.close(() => {
111
111
  window.setTimeout(() => {
112
112
  this.open(caller, context)
113
- }, 30)
113
+ }, 66)
114
114
  })
115
115
  }
116
116
 
@@ -129,86 +129,106 @@ export default {
129
129
 
130
130
  if(caller){
131
131
 
132
- this.$nextTick(() => {
133
- const rect = caller.getBoundingClientRect()
134
-
135
- let maxHeight
136
- let top, right, bottom, left
137
- let transformOrigin
138
-
139
- switch(this.position){
140
-
141
- case 'bottom-right':
142
- right = window.innerWidth - (Math.round(rect.x) + rect.width)
143
- top = Math.round(rect.y + rect.height + 8)
144
- maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
145
- transformOrigin = 'top right'
146
- break
147
-
148
- case 'top-left':
149
- maxHeight = Math.round(rect.top - 16)
150
- bottom = window.innerHeight - rect.top + 8
151
- left = Math.round(rect.x)
152
- transformOrigin = 'bottom left'
153
- break
154
-
155
- case 'top-right':
156
- maxHeight = Math.round(rect.top - 16)
157
- bottom = window.innerHeight - rect.top + 8
158
- right = window.innerWidth - (Math.round(rect.x) + rect.width)
159
- transformOrigin = 'bottom right'
160
- break
161
-
162
- default:
163
- left = Math.round(rect.x)
164
- top = Math.round(rect.y + rect.height + 8)
165
- //maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
166
- transformOrigin = 'top left'
167
- break
168
- }
169
-
170
- if(left){
171
- if(left + this.$refs.contextMenu.clientWidth >= (window.innerWidth - 16)){
172
- left = window.innerWidth - (this.$refs.contextMenu.clientWidth + 16)
173
-
174
- if(transformOrigin === 'top left'){
175
- transformOrigin = 'top right'
176
- }
132
+ const media = this.$util.getMediaPrefix(window.innerWidth)
133
+ let maxHeight, transformOrigin
134
+ let top, right, bottom, left
135
+ if([ '*', 'sm' ].includes(media)){
136
+ this.$nextTick(() => {
137
+ const rect = caller.getBoundingClientRect()
138
+
139
+ top = Math.round(rect.y + rect.height + 10)
140
+ transformOrigin = 'top left'
141
+ maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
142
+ Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 30
143
+
144
+ this.computedStyle = {
145
+ left: '10px',
146
+ right: '10px',
147
+ top: top ? top + 'px' : top,
148
+ maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
149
+ transformOrigin: transformOrigin
177
150
  }
178
- }
179
151
 
180
- if(top){
181
- if(top + this.$refs.contextMenu.clientHeight >= (window.innerHeight - 16)){
182
- top = window.innerHeight - (this.$refs.contextMenu.clientHeight + 16)
152
+ this.onOpen()
153
+ })
154
+ }
155
+ else{
156
+ this.$nextTick(() => {
157
+ const rect = caller.getBoundingClientRect()
158
+
159
+ switch(this.position){
160
+
161
+ case 'bottom-right':
162
+ right = window.innerWidth - (Math.round(rect.x) + rect.width)
163
+ top = Math.round(rect.y + rect.height + 8)
164
+ maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
165
+ transformOrigin = 'top right'
166
+ break
183
167
 
184
- if(transformOrigin === 'top left'){
168
+ case 'top-left':
169
+ maxHeight = Math.round(rect.top - 16)
170
+ bottom = window.innerHeight - rect.top + 8
171
+ left = Math.round(rect.x)
185
172
  transformOrigin = 'bottom left'
186
- }
187
- else if(transformOrigin === 'top right'){
173
+ break
174
+
175
+ case 'top-right':
176
+ maxHeight = Math.round(rect.top - 16)
177
+ bottom = window.innerHeight - rect.top + 8
178
+ right = window.innerWidth - (Math.round(rect.x) + rect.width)
188
179
  transformOrigin = 'bottom right'
189
- }
180
+ break
181
+
182
+ default:
183
+ left = Math.round(rect.x)
184
+ top = Math.round(rect.y + rect.height + 8)
185
+ //maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
186
+ transformOrigin = 'top left'
187
+ break
190
188
  }
191
189
 
192
- if(top < 0){
193
- top = 0
190
+ if(left){
191
+ if(left + this.$refs.contextMenu.clientWidth >= (window.innerWidth - 16)){
192
+ left = window.innerWidth - (this.$refs.contextMenu.clientWidth + 16)
193
+
194
+ if(transformOrigin === 'top left'){
195
+ transformOrigin = 'top right'
196
+ }
197
+ }
194
198
  }
195
- }
196
199
 
197
- maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
198
- Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 24
200
+ if(top){
201
+ if(top + this.$refs.contextMenu.clientHeight >= (window.innerHeight - 16)){
202
+ top = window.innerHeight - (this.$refs.contextMenu.clientHeight + 16)
203
+
204
+ if(transformOrigin === 'top left'){
205
+ transformOrigin = 'bottom left'
206
+ }
207
+ else if(transformOrigin === 'top right'){
208
+ transformOrigin = 'bottom right'
209
+ }
210
+ }
211
+
212
+ if(top < 0){
213
+ top = 0
214
+ }
215
+ }
199
216
 
200
- this.computedStyle = {
201
- left: left ? left + 'px' : left,
202
- right: right ? right + 'px' : right,
203
- top: top ? top + 'px' : top,
204
- bottom: bottom ? bottom + 'px' : bottom,
205
- maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
206
- transformOrigin: transformOrigin
207
- }
217
+ maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
218
+ Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 24
208
219
 
209
- this.onOpen()
210
- })
220
+ this.computedStyle = {
221
+ left: left ? left + 'px' : left,
222
+ right: right ? right + 'px' : right,
223
+ top: top ? top + 'px' : top,
224
+ bottom: bottom ? bottom + 'px' : bottom,
225
+ maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
226
+ transformOrigin: transformOrigin
227
+ }
211
228
 
229
+ this.onOpen()
230
+ })
231
+ }
212
232
  }
213
233
  else{
214
234
  console.error('Undefined caller for context menu')
@@ -230,11 +250,25 @@ export default {
230
250
  this.computedStyle = null
231
251
  this.isOpen = false
232
252
  this.$emit('dismiss')
233
- if(fn) fn()
253
+ if(typeof fn === 'function') fn()
234
254
  }
235
255
  this.$refs.contextMenu.removeEventListener('transitionend', transitionEnd)
236
256
  this.$refs.contextMenu.addEventListener('transitionend', transitionEnd)
237
257
  this.$refs.contextMenu.classList.remove(this.$style.active)
258
+ },
259
+
260
+ toggle(caller, context){
261
+
262
+ if(this.isOpen){
263
+ this.close()
264
+ }
265
+ else{
266
+ this.open(caller, context)
267
+ }
268
+ },
269
+
270
+ opened(){
271
+ return this.isOpen
238
272
  }
239
273
 
240
274
  }
@@ -250,12 +284,29 @@ export default {
250
284
  @apply border-[1px] border-text-50 shadow-2xl whitespace-nowrap;
251
285
  transition: all 150ms cubic-bezier(0.25, 1, 0.5, 1);
252
286
  opacity: 0;
253
- transform: scale(.3);
287
+ transform: translate3d(0, -10px, 0);
254
288
  }
255
289
 
256
290
  .active{
257
291
  opacity: 1;
258
- transform: scale(1);
292
+ transform: translate3d(0, 0, 0);
293
+ }
294
+
295
+ @media screen(md){
296
+
297
+ .contextMenu{
298
+ @apply fixed z-20 bg-base-50 backdrop-blur-md min-w-[150px] overflow-y-auto rounded-lg;
299
+ @apply border-[1px] border-text-50 shadow-2xl whitespace-nowrap;
300
+ transition: all 150ms cubic-bezier(0.25, 1, 0.5, 1);
301
+ opacity: 0;
302
+ transform: scale(.1);
303
+ }
304
+
305
+ .active{
306
+ opacity: 1;
307
+ transform: scale(1);
308
+ }
309
+
259
310
  }
260
311
 
261
- </style>
312
+ </style>
@@ -150,7 +150,7 @@ export default {
150
150
  <style module>
151
151
 
152
152
  .dropdown{
153
- @apply h-[var(--h-cp)];
153
+ @apply min-h-[var(--h-cp)];
154
154
  @apply flex items-center rounded-lg overflow-hidden cursor-pointer relative;
155
155
  @apply border-[1px] border-text-200 bg-base-50 hover:border-text-300;
156
156
  }
@@ -195,4 +195,4 @@ export default {
195
195
  @apply border-red-500
196
196
  }
197
197
 
198
- </style>
198
+ </style>
@@ -0,0 +1,95 @@
1
+ <template>
2
+ <div :style="computedStyle" :class="computedClass">
3
+ <div :style="lineStyle"></div>
4
+ <div :style="lineStyle"></div>
5
+ <div :style="lineStyle"></div>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+
11
+ export default {
12
+
13
+ props: {
14
+
15
+ width: {
16
+ type: String,
17
+ required: true
18
+ },
19
+
20
+ height: {
21
+ type: String,
22
+ required: true
23
+ },
24
+
25
+ color: String,
26
+
27
+ state: {
28
+ type: Number,
29
+ default: 1
30
+ }
31
+
32
+ },
33
+
34
+ computed: {
35
+
36
+ computedClass(){
37
+ return [
38
+ this.$style.comp,
39
+ this.state === 2 ? this.$style.active : ''
40
+ ]
41
+ .join(' ')
42
+ },
43
+
44
+ computedStyle(){
45
+ return {
46
+ height: parseInt(this.height) + 'px',
47
+ width: parseInt(this.width) + 'px'
48
+ }
49
+ },
50
+
51
+ lineStyle(){
52
+ return {
53
+ backgroundColor: this.color
54
+ }
55
+ }
56
+
57
+ }
58
+
59
+ }
60
+
61
+ </script>
62
+
63
+ <style module>
64
+
65
+ .comp{
66
+ @apply relative flex justify-center items-center;
67
+ }
68
+ .comp>*{
69
+ transition: all 400ms cubic-bezier(0.25, 1, 0.5, 1);
70
+ }
71
+
72
+ .comp>*:nth-child(1){
73
+ @apply absolute top-0 left-0 right-0 h-[2px] rounded-sm;
74
+ }
75
+ .comp>*:nth-child(2){
76
+ @apply w-full h-[2px] rounded-sm ml-[5px];
77
+ }
78
+ .comp>*:nth-child(3){
79
+ @apply absolute bottom-0 left-[5px] right-0 h-[2px] rounded-sm;
80
+ }
81
+
82
+ .comp.active>*:nth-child(1){
83
+ transform: rotate(-45deg);
84
+ transform-origin: 100% 0;
85
+ }
86
+ .comp.active>*:nth-child(2){
87
+ @apply opacity-0;
88
+ }
89
+ .comp.active>*:nth-child(3){
90
+ @apply left-0;
91
+ transform: rotate(45deg);
92
+ transform-origin: 100% 100%;
93
+ }
94
+
95
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div :style="computedStyle" :class="computedClass">
3
+ <div :style="lineStyle"></div>
4
+ <div :style="lineStyle"></div>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+
10
+ export default {
11
+
12
+ props: {
13
+
14
+ width: {
15
+ type: String,
16
+ required: true
17
+ },
18
+
19
+ height: {
20
+ type: String,
21
+ required: true
22
+ },
23
+
24
+ color: String,
25
+
26
+ state: {
27
+ type: Number,
28
+ default: 1
29
+ }
30
+
31
+ },
32
+
33
+ computed: {
34
+
35
+ computedClass(){
36
+ return [
37
+ this.$style.comp,
38
+ this.state === 2 ? this.$style.active : ''
39
+ ]
40
+ .join(' ')
41
+ },
42
+
43
+ computedStyle(){
44
+ return {
45
+ height: parseInt(this.height) + 'px',
46
+ width: parseInt(this.width) + 'px'
47
+ }
48
+ },
49
+
50
+ lineStyle(){
51
+ return {
52
+ backgroundColor: this.color
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ }
59
+
60
+ </script>
61
+
62
+ <style module>
63
+
64
+ .comp{
65
+ @apply relative flex justify-center items-center;
66
+ }
67
+ .comp>*{
68
+ transition: all 400ms cubic-bezier(0.25, 1, 0.5, 1);
69
+ }
70
+
71
+ .comp>*:nth-child(1){
72
+ @apply absolute top-[3px] left-0 right-0 h-[2px] rounded-sm;
73
+ }
74
+ .comp>*:nth-child(2){
75
+ @apply absolute bottom-[3px] left-0 right-0 h-[2px] rounded-sm;
76
+ }
77
+
78
+ .comp.active>*:nth-child(1){
79
+ transform: rotate(45deg);
80
+ transform-origin: 50% 50%;
81
+ top: 50%;
82
+ }
83
+ .comp.active>*:nth-child(2){
84
+ transform: rotate(-45deg);
85
+ transform-origin: 50% 50%;
86
+ top: 50%;
87
+ }
88
+
89
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div :style="computedStyle" :class="computedClass">
3
+ <div :style="lineStyle"></div>
4
+ <div :style="lineStyle"></div>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+
10
+ export default{
11
+
12
+ props: {
13
+
14
+ width: {
15
+ type: String,
16
+ required: true
17
+ },
18
+
19
+ height: {
20
+ type: String,
21
+ required: true
22
+ },
23
+
24
+ color: String,
25
+
26
+ state: {
27
+ type: Number,
28
+ default: 1
29
+ }
30
+
31
+ },
32
+
33
+ computed: {
34
+
35
+ computedClass() {
36
+ return [
37
+ this.$style.comp,
38
+ this.state === 2 ? this.$style.active : ''
39
+ ]
40
+ .join(' ')
41
+ },
42
+
43
+ computedStyle() {
44
+ return {
45
+ height: parseInt(this.height) + 'px',
46
+ width: parseInt(this.width) + 'px'
47
+ }
48
+ },
49
+
50
+ lineStyle(){
51
+ return {
52
+ backgroundColor: this.color
53
+ }
54
+ }
55
+
56
+ }
57
+ }
58
+
59
+ </script>
60
+
61
+ <style module>
62
+
63
+ .comp{
64
+ @apply inline-block relative;
65
+ }
66
+ .comp>*{
67
+ transition: all 400ms cubic-bezier(0.25, 1, 0.5, 1);
68
+ }
69
+
70
+ .comp>*:first-child{
71
+ @apply absolute top-0 bottom-0 w-[2px];
72
+ left: 50%;
73
+ transform: translate3d(-50%, 0, 0);
74
+ }
75
+ .comp>*:last-child{
76
+ @apply absolute left-0 right-0 h-[2px];
77
+ top: 50%;
78
+ transform: translate3d(0, -50%, 0);
79
+ }
80
+
81
+ .comp.active>*:first-child{
82
+ transform: rotate(-90deg);
83
+ transform-origin: 50% 50%;
84
+ }
85
+ .comp.active>*:last-child{
86
+ opacity: 0;
87
+ }
88
+
89
+ </style>
@@ -133,17 +133,22 @@ export default{
133
133
  if(window.innerWidth > b && screens[b] in src){
134
134
  var img = new Image()
135
135
  img.addEventListener('load', () => {
136
+ if(img.getAttribute('data-src') !== this.src) return
136
137
  this.status = 2
137
138
  this.actualSrc = img.src
138
139
  })
139
- img.addEventListener('error', () => {
140
+ img.addEventListener('error', (err) => {
141
+ if(img.getAttribute('data-src') !== this.src) return
140
142
  this.status = 3
141
143
  this.actualSrc = this.defaultSrc
142
144
  })
143
145
  img.src = src[screens[b]]
146
+ img.setAttribute('data-src', this.src)
144
147
  this.status = 1
148
+ break
145
149
  }
146
150
  }
151
+
147
152
  }
148
153
  }
149
154
  else if(this.src instanceof File){
@@ -207,4 +212,4 @@ export default{
207
212
  @apply bg-text-200 animate-pulse;
208
213
  }
209
214
 
210
- </style>
215
+ </style>
@@ -2,7 +2,7 @@
2
2
  <div :class="$style.comp" v-if="configLoaded">
3
3
 
4
4
  <slot v-if="$slots.head" name="head"></slot>
5
- <div v-else class="flex flex-row items-center gap-4 px-6 md:px-0 p-4">
5
+ <div v-else class="flex flex-row items-center gap-4 px-6 md:px-0 py-4 md:py-0">
6
6
  <div class="flex-1 flex flex-row gap-4">
7
7
  <button type="button" ref="presetSelectorBtn"
8
8
  class="flex-1 md:flex-none flex flex-row gap-1 items-center text-left md:ml-2"
@@ -60,7 +60,7 @@
60
60
  </Textbox>
61
61
  </div>
62
62
 
63
- <div v-if="mediaPrefix === 'sm'" class="px-6 py-4">
63
+ <div v-if="mediaPrefix === 'sm'" class="px-6 py-4 border-b-[1px] border-text-50">
64
64
  <Textbox :placeholder="$t('Search...')" :clearable="true" @clear="clearSearch" v-model="preset.search"
65
65
  @keyup.enter="load" :class="$style.searchBox">
66
66
  <template #start>
@@ -296,7 +296,10 @@ export default{
296
296
  return this.socketEmit2(this.configStoreObj.src,
297
297
  { key:this.configStoreObj.name ?? 'ListView' })
298
298
  .then((config) => {
299
- Object.assign(this.config, config ?? {})
299
+ if(config && Array.isArray(config.columns)){
300
+ Object.assign(this.config, config ?? {})
301
+ }
302
+
300
303
  this.configLoaded = true
301
304
  this.$nextTick(() => this.calcMediaPrefix())
302
305
  })
@@ -562,7 +565,7 @@ export default{
562
565
  <style module>
563
566
 
564
567
  .comp{
565
- @apply flex-1 flex flex-col divide-y md:divide-none divide-text-50;
568
+ @apply flex-1 flex flex-col md:gap-4;
566
569
  }
567
570
 
568
571
  .header{
@@ -212,7 +212,6 @@ export default{
212
212
  .spacer{
213
213
  will-change: auto;
214
214
  position: relative;
215
- @apply divide-y divide-text-50;
216
215
  }
217
216
 
218
217
  .item:hover{
@@ -400,7 +400,7 @@ export default{
400
400
 
401
401
  .comp{
402
402
  @apply flex flex-col overflow-hidden;
403
- @apply border-[1px] border-text-50 rounded-sm bg-base-500;
403
+ @apply border-[1px] border-text-50 rounded-sm;
404
404
  }
405
405
 
406
406
  .comp>*:last-child{
@@ -408,7 +408,7 @@ export default{
408
408
  }
409
409
 
410
410
  .header{
411
- @apply border-b-[1px] border-text-50 bg-base-500;
411
+ @apply border-b-[1px] border-text-50;
412
412
  }
413
413
 
414
414
  .headerCol{
@@ -420,7 +420,6 @@ export default{
420
420
  overflow: hidden;
421
421
  will-change: auto;
422
422
  min-width: 100%;
423
- @apply bg-base-500;
424
423
  }
425
424
 
426
425
  .spacer{
package/src/index.js CHANGED
@@ -12,6 +12,14 @@ const uniqid = () => {
12
12
  return _UNIQID++
13
13
  }
14
14
 
15
+ const mediaBreakpoints = {
16
+ 640: 'sm',
17
+ 768: 'md',
18
+ 1024: 'lg',
19
+ 1280: 'xl',
20
+ 1536: '2xl',
21
+ }
22
+
15
23
  const download = (url, as) => {
16
24
  const downloader = document.createElement('a')
17
25
  downloader.setAttribute('href', url)
@@ -181,6 +189,18 @@ const util = {
181
189
  break
182
190
  }
183
191
  })
192
+ },
193
+
194
+ getMediaPrefix(width){
195
+
196
+ let prefix = '*'
197
+ for(let breakpoint in mediaBreakpoints){
198
+ if(width > breakpoint){
199
+ prefix = mediaBreakpoints[breakpoint]
200
+ }
201
+ }
202
+
203
+ return prefix
184
204
  }
185
205
 
186
206
  }
@@ -224,6 +244,9 @@ export default{
224
244
  app.component('HTMLEditor', defineAsyncComponent(() => import("./components/HTMLEditor.vue")))
225
245
  app.component('Ahref', defineAsyncComponent(() => import("./components/Ahref.vue")))
226
246
  app.component('Switch', defineAsyncComponent(() => import("./components/Switch.vue")))
247
+ app.component('IconMenu', defineAsyncComponent(() => import("./components/IconMenu.vue")))
248
+ app.component('IconMenu2', defineAsyncComponent(() => import("./components/IconMenu2.vue")))
249
+ app.component('IconPlus', defineAsyncComponent(() => import("./components/IconPlus.vue")))
227
250
  app.component('Image', defineAsyncComponent(() => import("./components/Image.vue")))
228
251
  app.component('Image360', defineAsyncComponent(() => import("./components/Image360.vue")))
229
252
  app.component('ImagePreview', defineAsyncComponent(() => import("./components/ImagePreview.vue")))
@@ -92,7 +92,9 @@ const plugin = Plugin(function({ addBase, config, theme }) {
92
92
  '@media screen and (orientation: portrait)': {
93
93
  'body': {
94
94
  'fontSize': '16px',
95
- }
95
+ },
96
+
97
+ "input, input[type='text'], input[type='number'], textarea, select, option": { fontSize:"16px" }
96
98
  },
97
99
 
98
100
  '::-webkit-scrollbar': {
@@ -137,7 +139,6 @@ const plugin = Plugin(function({ addBase, config, theme }) {
137
139
 
138
140
  '.flex-1': { minHeight: "0px", minWidth: "0px" }
139
141
 
140
-
141
142
  })
142
143
 
143
144
  }, {