@mixd-id/web-scaffold 0.1.230406049 → 0.1.230406051
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 +1 -1
- package/src/components/ContextMenu.vue +124 -73
- package/src/components/Dropdown.vue +2 -2
- package/src/components/IconMenu2.vue +89 -0
- package/src/components/ListView.vue +2 -2
- package/src/components/Modal.vue +4 -1
- package/src/index.js +29 -12
- package/src/themes/default/index.js +5 -1
package/package.json
CHANGED
|
@@ -110,7 +110,7 @@ export default {
|
|
|
110
110
|
return this.close(() => {
|
|
111
111
|
window.setTimeout(() => {
|
|
112
112
|
this.open(caller, context)
|
|
113
|
-
},
|
|
113
|
+
}, 66)
|
|
114
114
|
})
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -129,86 +129,106 @@ export default {
|
|
|
129
129
|
|
|
130
130
|
if(caller){
|
|
131
131
|
|
|
132
|
-
this.$
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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.calculateMediaPrefix(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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
193
|
-
|
|
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
|
-
|
|
198
|
-
|
|
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
|
-
|
|
201
|
-
|
|
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
|
-
|
|
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:
|
|
287
|
+
transform: translate3d(0, -10px, 0);
|
|
254
288
|
}
|
|
255
289
|
|
|
256
290
|
.active{
|
|
257
291
|
opacity: 1;
|
|
258
|
-
transform:
|
|
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,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>
|
|
@@ -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
|
|
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"
|
|
@@ -565,7 +565,7 @@ export default{
|
|
|
565
565
|
<style module>
|
|
566
566
|
|
|
567
567
|
.comp{
|
|
568
|
-
@apply flex-1 flex flex-col;
|
|
568
|
+
@apply flex-1 flex flex-col md:gap-4;
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
.header{
|
package/src/components/Modal.vue
CHANGED
|
@@ -63,7 +63,10 @@ export default{
|
|
|
63
63
|
class:{ type: String, default: '' },
|
|
64
64
|
dismissable: undefined,
|
|
65
65
|
height: String,
|
|
66
|
-
position:
|
|
66
|
+
position: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'bottom'
|
|
69
|
+
},
|
|
67
70
|
state: [ Number, Boolean, String ],
|
|
68
71
|
transition: { type: String, default: 'slideup' },
|
|
69
72
|
width: String,
|
package/src/index.js
CHANGED
|
@@ -2,16 +2,19 @@ import {defineAsyncComponent, ref} from "vue"
|
|
|
2
2
|
import {observeInit} from './utils/helpers.mjs'
|
|
3
3
|
import throttle from "lodash/throttle"
|
|
4
4
|
|
|
5
|
-
const calculateIsMobile = () => {
|
|
6
|
-
if(typeof window === 'undefined') return false
|
|
7
|
-
return window.innerWidth < window.innerHeight && window.innerWidth <= 800
|
|
8
|
-
}
|
|
9
|
-
|
|
10
5
|
let _UNIQID = 0
|
|
11
6
|
const uniqid = () => {
|
|
12
7
|
return _UNIQID++
|
|
13
8
|
}
|
|
14
9
|
|
|
10
|
+
const mediaBreakpoints = {
|
|
11
|
+
640: 'sm',
|
|
12
|
+
768: 'md',
|
|
13
|
+
1024: 'lg',
|
|
14
|
+
1280: 'xl',
|
|
15
|
+
1536: '2xl',
|
|
16
|
+
}
|
|
17
|
+
|
|
15
18
|
const download = (url, as) => {
|
|
16
19
|
const downloader = document.createElement('a')
|
|
17
20
|
downloader.setAttribute('href', url)
|
|
@@ -181,7 +184,21 @@ const util = {
|
|
|
181
184
|
break
|
|
182
185
|
}
|
|
183
186
|
})
|
|
184
|
-
}
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
calculateMediaPrefix(width){
|
|
190
|
+
|
|
191
|
+
let prefix = '*'
|
|
192
|
+
for(let breakpoint in mediaBreakpoints){
|
|
193
|
+
if(width > breakpoint){
|
|
194
|
+
prefix = mediaBreakpoints[breakpoint]
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return prefix
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
uniqid
|
|
185
202
|
|
|
186
203
|
}
|
|
187
204
|
|
|
@@ -189,18 +206,17 @@ export default{
|
|
|
189
206
|
|
|
190
207
|
install: (app, options) => {
|
|
191
208
|
|
|
192
|
-
let isMobile = ref(calculateIsMobile())
|
|
193
|
-
|
|
194
209
|
if(typeof window !== 'undefined' && 'IntersectionObserver' in window) {
|
|
195
210
|
app.config.globalProperties.$observe = observeInit()
|
|
196
211
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
212
|
+
app.config.globalProperties.$screenPrefix = ref(util.calculateMediaPrefix(window.innerWidth))
|
|
213
|
+
const onWindowResize = throttle(() => {
|
|
214
|
+
app.config.globalProperties.$screenPrefix.value = util.calculateMediaPrefix(window.innerWidth)
|
|
215
|
+
}, 500, { leading:true })
|
|
216
|
+
window.addEventListener('resize', onWindowResize)
|
|
200
217
|
}
|
|
201
218
|
|
|
202
219
|
app.config.globalProperties.uniqid = uniqid
|
|
203
|
-
app.config.globalProperties.isMobile = isMobile
|
|
204
220
|
app.config.globalProperties.$download = download
|
|
205
221
|
app.config.globalProperties.$preload = preload
|
|
206
222
|
app.config.globalProperties.$popPreloads = popPreloads
|
|
@@ -225,6 +241,7 @@ export default{
|
|
|
225
241
|
app.component('Ahref', defineAsyncComponent(() => import("./components/Ahref.vue")))
|
|
226
242
|
app.component('Switch', defineAsyncComponent(() => import("./components/Switch.vue")))
|
|
227
243
|
app.component('IconMenu', defineAsyncComponent(() => import("./components/IconMenu.vue")))
|
|
244
|
+
app.component('IconMenu2', defineAsyncComponent(() => import("./components/IconMenu2.vue")))
|
|
228
245
|
app.component('IconPlus', defineAsyncComponent(() => import("./components/IconPlus.vue")))
|
|
229
246
|
app.component('Image', defineAsyncComponent(() => import("./components/Image.vue")))
|
|
230
247
|
app.component('Image360', defineAsyncComponent(() => import("./components/Image360.vue")))
|
|
@@ -10,6 +10,10 @@ const plugin = Plugin(function({ addBase, config, theme }) {
|
|
|
10
10
|
'fontSize': '13px'
|
|
11
11
|
},
|
|
12
12
|
|
|
13
|
+
'html, body': {
|
|
14
|
+
'height': '100%'
|
|
15
|
+
},
|
|
16
|
+
|
|
13
17
|
'html, .html': {
|
|
14
18
|
|
|
15
19
|
"--h-cp-sm": '2rem',
|
|
@@ -94,7 +98,7 @@ const plugin = Plugin(function({ addBase, config, theme }) {
|
|
|
94
98
|
'fontSize': '16px',
|
|
95
99
|
},
|
|
96
100
|
|
|
97
|
-
"input, input[type='text'], input[type='number'], textarea": { fontSize:"16px" }
|
|
101
|
+
"input, input[type='text'], input[type='number'], textarea, select, option": { fontSize:"16px" }
|
|
98
102
|
},
|
|
99
103
|
|
|
100
104
|
'::-webkit-scrollbar': {
|