@varlet/cli 2.15.1 → 2.16.0-alpha.1693852004525
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/lib/node/config/varlet.config.js +2 -1
- package/lib/node/config/varlet.default.config.js +264 -7
- package/package.json +8 -7
- package/site/mobile/App.vue +25 -22
- package/site/mobile/{components/AppHome.vue → AppHome.vue} +6 -6
- package/site/mobile/main.ts +6 -21
- package/site/pc/App.vue +0 -5
- package/site/pc/Layout.vue +24 -28
- package/site/pc/components/AppHeader.vue +123 -122
- package/site/pc/components/AppMobile.vue +9 -2
- package/site/pc/components/AppSidebar.vue +18 -17
- package/site/{components → pc/components}/code-example/CodeExample.vue +8 -15
- package/site/pc/main.ts +6 -23
- package/site/pc/pages/index/index.vue +316 -47
- package/site/types.ts +6 -0
- package/template/generators/base/package.json +1 -0
- package/site/components/button/Button.vue +0 -106
- package/site/components/button/button.less +0 -183
- package/site/components/button/index.ts +0 -10
- package/site/components/button/props.ts +0 -78
- package/site/components/cell/Cell.vue +0 -54
- package/site/components/cell/cell.less +0 -78
- package/site/components/cell/index.ts +0 -10
- package/site/components/cell/props.ts +0 -27
- package/site/components/context/index.ts +0 -21
- package/site/components/context/lock.ts +0 -92
- package/site/components/context/zIndex.ts +0 -20
- package/site/components/icon/Icon.vue +0 -75
- package/site/components/icon/icon.less +0 -38
- package/site/components/icon/index.ts +0 -10
- package/site/components/icon/props.ts +0 -24
- package/site/components/loading/Loading.vue +0 -84
- package/site/components/loading/index.ts +0 -10
- package/site/components/loading/loading.less +0 -505
- package/site/components/loading/props.ts +0 -42
- package/site/components/popup/Popup.tsx +0 -102
- package/site/components/popup/index.ts +0 -10
- package/site/components/popup/popup.less +0 -125
- package/site/components/popup/props.ts +0 -63
- package/site/components/ripple/index.ts +0 -188
- package/site/components/ripple/ripple.less +0 -20
- package/site/components/snackbar/Snackbar.vue +0 -41
- package/site/components/snackbar/core.vue +0 -132
- package/site/components/snackbar/index.tsx +0 -270
- package/site/components/snackbar/props.ts +0 -97
- package/site/components/snackbar/snackbar.less +0 -135
- package/site/components/styles/common.less +0 -64
- package/site/components/styles/elevation.less +0 -126
- package/site/components/styles/var.less +0 -27
- package/site/components/utils/components.ts +0 -114
- package/site/components/utils/elements.ts +0 -104
- package/site/mobile/components/app-bar/AppBar.vue +0 -65
- package/site/mobile/components/app-bar/appBar.less +0 -57
- package/site/mobile/components/app-bar/index.ts +0 -10
- package/site/mobile/components/app-bar/props.ts +0 -25
- package/site/pc/components/AnimationBox.vue +0 -62
- package/site/pc/components/LogoAnimation.vue +0 -119
- package/site/pc/pages/index/index.less +0 -204
- /package/site/{components → pc/components}/code-example/codeExample.less +0 -0
- /package/site/{components → pc/components}/code-example/index.ts +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { defineComponent, watch, Transition, Teleport } from 'vue'
|
|
2
|
-
import { props } from './props'
|
|
3
|
-
import { useLock } from '../context/lock'
|
|
4
|
-
import { useZIndex } from '../context/zIndex'
|
|
5
|
-
import { useRouteListener, useTeleport, createNamespace } from '../utils/components'
|
|
6
|
-
|
|
7
|
-
import '../styles/common.less'
|
|
8
|
-
import './popup.less'
|
|
9
|
-
|
|
10
|
-
const { n, classes } = createNamespace('popup')
|
|
11
|
-
|
|
12
|
-
export default defineComponent({
|
|
13
|
-
name: 'VarPopup',
|
|
14
|
-
inheritAttrs: false,
|
|
15
|
-
props,
|
|
16
|
-
setup(props, { slots, attrs }) {
|
|
17
|
-
const { zIndex } = useZIndex(() => props.show, 3)
|
|
18
|
-
const { disabled } = useTeleport()
|
|
19
|
-
|
|
20
|
-
const hidePopup = () => {
|
|
21
|
-
const { closeOnClickOverlay, onClickOverlay } = props
|
|
22
|
-
|
|
23
|
-
onClickOverlay?.()
|
|
24
|
-
|
|
25
|
-
if (!closeOnClickOverlay) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
props['onUpdate:show']?.(false)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
useLock(
|
|
33
|
-
() => props.show,
|
|
34
|
-
() => props.lockScroll
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
watch(
|
|
38
|
-
() => props.show,
|
|
39
|
-
(newValue: boolean) => {
|
|
40
|
-
const { onOpen, onClose } = props
|
|
41
|
-
newValue ? onOpen?.() : onClose?.()
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
// internal for Dialog
|
|
46
|
-
useRouteListener(() => props.onRouteChange?.())
|
|
47
|
-
|
|
48
|
-
const renderOverlay = () => {
|
|
49
|
-
const { overlayClass = '', overlayStyle } = props
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div
|
|
53
|
-
class={classes(n('overlay'), overlayClass)}
|
|
54
|
-
style={{
|
|
55
|
-
zIndex: zIndex.value - 1,
|
|
56
|
-
...overlayStyle,
|
|
57
|
-
}}
|
|
58
|
-
onClick={hidePopup}
|
|
59
|
-
/>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const renderContent = () => {
|
|
64
|
-
return (
|
|
65
|
-
<div
|
|
66
|
-
class={classes(n('content'), 'var-site-elevation--3', n(`--${props.position}`))}
|
|
67
|
-
style={{ zIndex: zIndex.value }}
|
|
68
|
-
{...attrs}
|
|
69
|
-
>
|
|
70
|
-
{slots.default?.()}
|
|
71
|
-
</div>
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const renderPopup = () => {
|
|
76
|
-
const { onOpened, onClosed, show, overlay, transition, position } = props
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<Transition name="var-site-fade" onAfterEnter={onOpened} onAfterLeave={onClosed}>
|
|
80
|
-
<div class={classes('var-site--box', n())} style={{ zIndex: zIndex.value - 2 }} v-show={show}>
|
|
81
|
-
{overlay && renderOverlay()}
|
|
82
|
-
<Transition name={transition || `var-site-pop-${position}`}>{show && renderContent()}</Transition>
|
|
83
|
-
</div>
|
|
84
|
-
</Transition>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return () => {
|
|
89
|
-
const { teleport } = props
|
|
90
|
-
|
|
91
|
-
if (teleport) {
|
|
92
|
-
return (
|
|
93
|
-
<Teleport to={teleport} disabled={disabled.value}>
|
|
94
|
-
{renderPopup()}
|
|
95
|
-
</Teleport>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return renderPopup()
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
})
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
@site-popup-overlay-background-color: rgba(0, 0, 0, 0.6);
|
|
2
|
-
@site-popup-content-background-color: #fff;
|
|
3
|
-
|
|
4
|
-
:root {
|
|
5
|
-
--site-popup-overlay-background-color: @site-popup-overlay-background-color;
|
|
6
|
-
--site-popup-content-background-color: @site-popup-content-background-color;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.var-site {
|
|
10
|
-
&-fade-enter-from,
|
|
11
|
-
&-fade-leave-to {
|
|
12
|
-
opacity: 0;
|
|
13
|
-
}
|
|
14
|
-
&-fade-enter-active,
|
|
15
|
-
&-fade-leave-active {
|
|
16
|
-
transition: opacity 0.25s;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
&-pop-center-enter-from,
|
|
20
|
-
&-pop-center-leave-to {
|
|
21
|
-
transform: scale(0.3);
|
|
22
|
-
}
|
|
23
|
-
&-pop-center-enter-active,
|
|
24
|
-
&-pop-center-leave-active {
|
|
25
|
-
transition: all 0.25s;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&-pop-bottom-enter-from,
|
|
29
|
-
&-pop-bottom-leave-to {
|
|
30
|
-
transform: translateY(100%);
|
|
31
|
-
}
|
|
32
|
-
&-pop-bottom-enter-active,
|
|
33
|
-
&-pop-bottom-leave-active {
|
|
34
|
-
transition: all 0.25s;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&-pop-top-enter-from,
|
|
38
|
-
&-pop-top-leave-to {
|
|
39
|
-
transform: translateY(-100%);
|
|
40
|
-
}
|
|
41
|
-
&-pop-top-enter-active,
|
|
42
|
-
&-pop-top-leave-active {
|
|
43
|
-
transition: all 0.25s;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&-pop-left-enter-from,
|
|
47
|
-
&-pop-left-leave-to {
|
|
48
|
-
transform: translateX(-100%);
|
|
49
|
-
}
|
|
50
|
-
&-pop-left-enter-active,
|
|
51
|
-
&-pop-left-leave-active {
|
|
52
|
-
transition: all 0.25s;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&-pop-right-enter-from,
|
|
56
|
-
&-pop-right-leave-to {
|
|
57
|
-
transform: translateX(100%);
|
|
58
|
-
}
|
|
59
|
-
&-pop-right-enter-active,
|
|
60
|
-
&-pop-right-leave-active {
|
|
61
|
-
transition: all 0.25s;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.var-site-popup {
|
|
66
|
-
display: flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
align-items: center;
|
|
69
|
-
position: fixed;
|
|
70
|
-
top: 0;
|
|
71
|
-
right: 0;
|
|
72
|
-
bottom: 0;
|
|
73
|
-
left: 0;
|
|
74
|
-
|
|
75
|
-
&__overlay {
|
|
76
|
-
display: flex;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
align-items: center;
|
|
79
|
-
position: fixed;
|
|
80
|
-
top: 0;
|
|
81
|
-
right: 0;
|
|
82
|
-
bottom: 0;
|
|
83
|
-
left: 0;
|
|
84
|
-
background-color: var(--site-popup-overlay-background-color);
|
|
85
|
-
transition: all 0.25s;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&__content {
|
|
89
|
-
overflow: auto;
|
|
90
|
-
background-color: var(--site-popup-content-background-color);
|
|
91
|
-
transition: all 0.25s;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&--center {
|
|
95
|
-
position: relative;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&--bottom {
|
|
99
|
-
min-width: 100%;
|
|
100
|
-
position: absolute;
|
|
101
|
-
left: 0;
|
|
102
|
-
bottom: 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--top {
|
|
106
|
-
min-width: 100%;
|
|
107
|
-
position: absolute;
|
|
108
|
-
left: 0;
|
|
109
|
-
top: 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&--left {
|
|
113
|
-
min-height: 100%;
|
|
114
|
-
position: absolute;
|
|
115
|
-
left: 0;
|
|
116
|
-
top: 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
&--right {
|
|
120
|
-
min-height: 100%;
|
|
121
|
-
position: absolute;
|
|
122
|
-
right: 0;
|
|
123
|
-
top: 0;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { PropType, TeleportProps } from 'vue'
|
|
2
|
-
|
|
3
|
-
function positionValidator(position: string): boolean {
|
|
4
|
-
return ['top', 'bottom', 'right', 'left', 'center'].includes(position)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const props = {
|
|
8
|
-
show: {
|
|
9
|
-
type: Boolean,
|
|
10
|
-
default: false,
|
|
11
|
-
},
|
|
12
|
-
position: {
|
|
13
|
-
type: String as PropType<'top' | 'bottom' | 'right' | 'left' | 'center'>,
|
|
14
|
-
default: 'center',
|
|
15
|
-
validator: positionValidator,
|
|
16
|
-
},
|
|
17
|
-
transition: {
|
|
18
|
-
type: String,
|
|
19
|
-
},
|
|
20
|
-
overlay: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: true,
|
|
23
|
-
},
|
|
24
|
-
overlayClass: {
|
|
25
|
-
type: String,
|
|
26
|
-
},
|
|
27
|
-
overlayStyle: {
|
|
28
|
-
type: Object,
|
|
29
|
-
},
|
|
30
|
-
lockScroll: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
default: true,
|
|
33
|
-
},
|
|
34
|
-
closeOnClickOverlay: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
default: true,
|
|
37
|
-
},
|
|
38
|
-
teleport: {
|
|
39
|
-
type: String as PropType<TeleportProps['to']>,
|
|
40
|
-
},
|
|
41
|
-
onOpen: {
|
|
42
|
-
type: Function as PropType<() => void>,
|
|
43
|
-
},
|
|
44
|
-
onOpened: {
|
|
45
|
-
type: Function as PropType<() => void>,
|
|
46
|
-
},
|
|
47
|
-
onClose: {
|
|
48
|
-
type: Function as PropType<() => void>,
|
|
49
|
-
},
|
|
50
|
-
onClosed: {
|
|
51
|
-
type: Function as PropType<() => void>,
|
|
52
|
-
},
|
|
53
|
-
onClickOverlay: {
|
|
54
|
-
type: Function as PropType<() => void>,
|
|
55
|
-
},
|
|
56
|
-
// internal for Dialog
|
|
57
|
-
onRouteChange: {
|
|
58
|
-
type: Function as PropType<() => void>,
|
|
59
|
-
},
|
|
60
|
-
'onUpdate:show': {
|
|
61
|
-
type: Function as PropType<(show: boolean) => void>,
|
|
62
|
-
},
|
|
63
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import context from '../context'
|
|
2
|
-
import './ripple.less'
|
|
3
|
-
import '../styles/common.less'
|
|
4
|
-
import { supportTouch } from '../utils/elements'
|
|
5
|
-
import { createNamespace } from '../utils/components'
|
|
6
|
-
import type { Directive, Plugin, App } from 'vue'
|
|
7
|
-
import type { DirectiveBinding } from '@vue/runtime-core'
|
|
8
|
-
|
|
9
|
-
const { n } = createNamespace('ripple')
|
|
10
|
-
|
|
11
|
-
interface RippleStyles {
|
|
12
|
-
x: number
|
|
13
|
-
y: number
|
|
14
|
-
centerX: number
|
|
15
|
-
centerY: number
|
|
16
|
-
size: number
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface RippleOptions {
|
|
20
|
-
removeRipple: any
|
|
21
|
-
touchmoveForbid: boolean
|
|
22
|
-
color?: string
|
|
23
|
-
disabled?: boolean
|
|
24
|
-
tasker?: number | null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface RippleHTMLElement extends HTMLElement {
|
|
28
|
-
_ripple?: RippleOptions
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const ANIMATION_DURATION = 250
|
|
32
|
-
|
|
33
|
-
function setStyles(element: RippleHTMLElement) {
|
|
34
|
-
const { zIndex, position } = window.getComputedStyle(element)
|
|
35
|
-
|
|
36
|
-
element.style.overflow = 'hidden'
|
|
37
|
-
element.style.overflowX = 'hidden'
|
|
38
|
-
element.style.overflowY = 'hidden'
|
|
39
|
-
position === 'static' && (element.style.position = 'relative')
|
|
40
|
-
zIndex === 'auto' && (element.style.zIndex = '1')
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function computeRippleStyles(element: RippleHTMLElement, event: TouchEvent): RippleStyles {
|
|
44
|
-
const { top, left }: DOMRect = element.getBoundingClientRect()
|
|
45
|
-
const { clientWidth, clientHeight } = element
|
|
46
|
-
|
|
47
|
-
const radius: number = Math.sqrt(clientWidth ** 2 + clientHeight ** 2) / 2
|
|
48
|
-
const size: number = radius * 2
|
|
49
|
-
|
|
50
|
-
const localX: number = event.touches[0].clientX - left
|
|
51
|
-
const localY: number = event.touches[0].clientY - top
|
|
52
|
-
|
|
53
|
-
const centerX: number = (clientWidth - radius * 2) / 2
|
|
54
|
-
const centerY: number = (clientHeight - radius * 2) / 2
|
|
55
|
-
|
|
56
|
-
const x: number = localX - radius
|
|
57
|
-
const y: number = localY - radius
|
|
58
|
-
|
|
59
|
-
return { x, y, centerX, centerY, size }
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function createRipple(this: RippleHTMLElement, event: TouchEvent) {
|
|
63
|
-
const _ripple = this._ripple as RippleOptions
|
|
64
|
-
_ripple.removeRipple()
|
|
65
|
-
|
|
66
|
-
if (_ripple.disabled || _ripple.tasker) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const task = () => {
|
|
71
|
-
_ripple.tasker = null
|
|
72
|
-
|
|
73
|
-
const { x, y, centerX, centerY, size }: RippleStyles = computeRippleStyles(this, event)
|
|
74
|
-
const ripple: RippleHTMLElement = document.createElement('div')
|
|
75
|
-
ripple.classList.add(n())
|
|
76
|
-
ripple.style.opacity = `0`
|
|
77
|
-
ripple.style.transform = `translate(${x}px, ${y}px) scale3d(.3, .3, .3)`
|
|
78
|
-
ripple.style.width = `${size}px`
|
|
79
|
-
ripple.style.height = `${size}px`
|
|
80
|
-
_ripple.color && (ripple.style.backgroundColor = _ripple.color)
|
|
81
|
-
ripple.dataset.createdAt = String(performance.now())
|
|
82
|
-
|
|
83
|
-
setStyles(this)
|
|
84
|
-
|
|
85
|
-
this.appendChild(ripple)
|
|
86
|
-
|
|
87
|
-
window.setTimeout(() => {
|
|
88
|
-
ripple.style.transform = `translate(${centerX}px, ${centerY}px) scale3d(1, 1, 1)`
|
|
89
|
-
ripple.style.opacity = `.25`
|
|
90
|
-
}, 20)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
_ripple.tasker = window.setTimeout(task, 60)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function removeRipple(this: RippleHTMLElement) {
|
|
97
|
-
const _ripple = this._ripple as RippleOptions
|
|
98
|
-
|
|
99
|
-
const task = () => {
|
|
100
|
-
const ripples: NodeListOf<RippleHTMLElement> = this.querySelectorAll(`.${n()}`)
|
|
101
|
-
if (!ripples.length) {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const lastRipple: RippleHTMLElement = ripples[ripples.length - 1]
|
|
106
|
-
const delay: number = ANIMATION_DURATION - performance.now() + Number(lastRipple.dataset.createdAt)
|
|
107
|
-
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
lastRipple.style.opacity = `0`
|
|
110
|
-
|
|
111
|
-
setTimeout(() => lastRipple.parentNode?.removeChild(lastRipple), ANIMATION_DURATION)
|
|
112
|
-
}, delay)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_ripple.tasker ? setTimeout(task, 60) : task()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function forbidRippleTask(this: RippleHTMLElement) {
|
|
119
|
-
const _ripple = this._ripple as RippleOptions
|
|
120
|
-
|
|
121
|
-
if (!supportTouch()) {
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!_ripple.touchmoveForbid) {
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
_ripple.tasker && window.clearTimeout(_ripple.tasker)
|
|
130
|
-
_ripple.tasker = null
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function mounted(el: RippleHTMLElement, binding: DirectiveBinding<RippleOptions>) {
|
|
134
|
-
el._ripple = {
|
|
135
|
-
tasker: null,
|
|
136
|
-
...(binding.value ?? {}),
|
|
137
|
-
touchmoveForbid: binding.value?.touchmoveForbid ?? context.touchmoveForbid,
|
|
138
|
-
removeRipple: removeRipple.bind(el),
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
el.addEventListener('touchstart', createRipple, { passive: true })
|
|
142
|
-
el.addEventListener('touchmove', forbidRippleTask, { passive: true })
|
|
143
|
-
el.addEventListener('dragstart', removeRipple, { passive: true })
|
|
144
|
-
document.addEventListener('touchend', el._ripple.removeRipple, { passive: true })
|
|
145
|
-
document.addEventListener('touchcancel', el._ripple.removeRipple, { passive: true })
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function unmounted(el: RippleHTMLElement) {
|
|
149
|
-
el.removeEventListener('touchstart', createRipple)
|
|
150
|
-
el.removeEventListener('touchmove', forbidRippleTask)
|
|
151
|
-
el.removeEventListener('dragstart', removeRipple)
|
|
152
|
-
document.removeEventListener('touchend', el._ripple!.removeRipple)
|
|
153
|
-
document.removeEventListener('touchcancel', el._ripple!.removeRipple)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function updated(el: RippleHTMLElement, binding: DirectiveBinding<RippleOptions>) {
|
|
157
|
-
const newBinding = {
|
|
158
|
-
touchmoveForbid: binding.value?.touchmoveForbid ?? context.touchmoveForbid,
|
|
159
|
-
color: binding.value?.color,
|
|
160
|
-
disabled: binding.value?.disabled,
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const diff =
|
|
164
|
-
newBinding.touchmoveForbid !== el._ripple?.touchmoveForbid ||
|
|
165
|
-
newBinding.color !== el._ripple?.color ||
|
|
166
|
-
newBinding.disabled !== el._ripple?.disabled
|
|
167
|
-
|
|
168
|
-
if (diff) {
|
|
169
|
-
el._ripple = {
|
|
170
|
-
tasker: newBinding.disabled ? null : el._ripple?.tasker,
|
|
171
|
-
removeRipple: el._ripple?.removeRipple,
|
|
172
|
-
...newBinding,
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const Ripple: Directive & Plugin = {
|
|
178
|
-
mounted,
|
|
179
|
-
unmounted,
|
|
180
|
-
updated,
|
|
181
|
-
install(app: App) {
|
|
182
|
-
app.directive('ripple', this)
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export const _RippleComponent = Ripple
|
|
187
|
-
|
|
188
|
-
export default Ripple
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
@site-ripple-cubic-bezier: cubic-bezier(0.68, 0.01, 0.62, 0.6);
|
|
2
|
-
@site-ripple-color: currentColor;
|
|
3
|
-
|
|
4
|
-
:root {
|
|
5
|
-
--site-ripple-cubic-bezier: @site-ripple-cubic-bezier;
|
|
6
|
-
--site-ripple-color: @site-ripple-color;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.var-site-ripple {
|
|
10
|
-
position: absolute;
|
|
11
|
-
transition: transform 0.2s var(--site-ripple-cubic-bezier), opacity 0.14s linear;
|
|
12
|
-
top: 0;
|
|
13
|
-
left: 0;
|
|
14
|
-
border-radius: 50%;
|
|
15
|
-
opacity: 0;
|
|
16
|
-
will-change: transform, opacity;
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
z-index: 100;
|
|
19
|
-
background-color: var(--site-ripple-color);
|
|
20
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<teleport :to="teleport" :disabled="disabled">
|
|
3
|
-
<transition :name="`${n()}-fade`" @after-enter="onOpened" @after-leave="onClosed">
|
|
4
|
-
<var-snackbar-core v-bind="$props" :class="n('transition')">
|
|
5
|
-
<slot>{{ content }}</slot>
|
|
6
|
-
<template #action>
|
|
7
|
-
<slot name="action" />
|
|
8
|
-
</template>
|
|
9
|
-
</var-snackbar-core>
|
|
10
|
-
</transition>
|
|
11
|
-
</teleport>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script>
|
|
15
|
-
import { defineComponent } from 'vue'
|
|
16
|
-
import VarSnackbarCore from './core'
|
|
17
|
-
import { createNamespace, useTeleport } from '../utils/components'
|
|
18
|
-
import { props } from './props'
|
|
19
|
-
|
|
20
|
-
const { n } = createNamespace('snackbar')
|
|
21
|
-
|
|
22
|
-
export default defineComponent({
|
|
23
|
-
name: 'VarSnackbar',
|
|
24
|
-
components: {
|
|
25
|
-
VarSnackbarCore,
|
|
26
|
-
},
|
|
27
|
-
props,
|
|
28
|
-
setup() {
|
|
29
|
-
const { disabled } = useTeleport()
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
n,
|
|
33
|
-
disabled,
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<style lang="less">
|
|
40
|
-
@import '../styles/common';
|
|
41
|
-
</style>
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="n()" :style="{ pointerEvents: isForbidClick ? 'auto' : 'none', zIndex }" v-show="show">
|
|
3
|
-
<div
|
|
4
|
-
:class="
|
|
5
|
-
classes(
|
|
6
|
-
n('wrapper'),
|
|
7
|
-
n(`wrapper-${position}`),
|
|
8
|
-
'var-site-elevation--4',
|
|
9
|
-
[vertical, n('vertical')],
|
|
10
|
-
[type && SNACKBAR_TYPE.includes(type), n(`wrapper-${type}`)]
|
|
11
|
-
)
|
|
12
|
-
"
|
|
13
|
-
:style="{ zIndex }"
|
|
14
|
-
>
|
|
15
|
-
<div :class="[n('content'), contentClass]">
|
|
16
|
-
<slot>{{ content }}</slot>
|
|
17
|
-
</div>
|
|
18
|
-
<div :class="n('action')">
|
|
19
|
-
<var-icon v-if="iconName" :name="iconName" />
|
|
20
|
-
<var-loading
|
|
21
|
-
v-if="type === 'loading'"
|
|
22
|
-
:type="loadingType"
|
|
23
|
-
:size="loadingSize"
|
|
24
|
-
:color="loadingColor"
|
|
25
|
-
:radius="loadingRadius"
|
|
26
|
-
/>
|
|
27
|
-
<slot name="action" />
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script lang="ts">
|
|
34
|
-
import { defineComponent, watch, ref, onMounted, computed } from 'vue'
|
|
35
|
-
import VarLoading from '../loading'
|
|
36
|
-
import VarIcon from '../icon'
|
|
37
|
-
import { useZIndex } from '../context/zIndex'
|
|
38
|
-
import { props } from './props'
|
|
39
|
-
import { useLock } from '../context/lock'
|
|
40
|
-
import { SNACKBAR_TYPE } from './index'
|
|
41
|
-
import type { Ref, ComputedRef } from 'vue'
|
|
42
|
-
import type { SnackbarType } from './index'
|
|
43
|
-
import { createNamespace } from '../utils/components'
|
|
44
|
-
|
|
45
|
-
const { n, classes } = createNamespace('snackbar')
|
|
46
|
-
|
|
47
|
-
const ICON_TYPE_DICT: Record<SnackbarType, string> = {
|
|
48
|
-
success: 'checkbox-marked-circle',
|
|
49
|
-
warning: 'warning',
|
|
50
|
-
info: 'information',
|
|
51
|
-
error: 'error',
|
|
52
|
-
loading: '',
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default defineComponent({
|
|
56
|
-
name: 'VarSiteSnackbarCore',
|
|
57
|
-
components: {
|
|
58
|
-
VarLoading,
|
|
59
|
-
VarIcon,
|
|
60
|
-
},
|
|
61
|
-
props,
|
|
62
|
-
setup(props) {
|
|
63
|
-
const timer: Ref = ref(null)
|
|
64
|
-
const { zIndex } = useZIndex(() => props.show, 1)
|
|
65
|
-
|
|
66
|
-
useLock(
|
|
67
|
-
() => props.show,
|
|
68
|
-
() => props.lockScroll
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
const isForbidClick: ComputedRef<boolean> = computed(() => props.type === 'loading' || props.forbidClick)
|
|
72
|
-
|
|
73
|
-
const iconName: ComputedRef<string> = computed(() => {
|
|
74
|
-
if (!props.type) return ''
|
|
75
|
-
|
|
76
|
-
return ICON_TYPE_DICT[props.type]
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const updateAfterDuration = () => {
|
|
80
|
-
timer.value = setTimeout(() => {
|
|
81
|
-
props.type !== 'loading' && props['onUpdate:show']?.(false)
|
|
82
|
-
}, props.duration)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
watch(
|
|
86
|
-
() => props.show,
|
|
87
|
-
(show) => {
|
|
88
|
-
if (show) {
|
|
89
|
-
props.onOpen?.()
|
|
90
|
-
updateAfterDuration()
|
|
91
|
-
} else if (show === false) {
|
|
92
|
-
clearTimeout(timer.value)
|
|
93
|
-
props.onClose?.()
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
watch(
|
|
99
|
-
() => props._update,
|
|
100
|
-
() => {
|
|
101
|
-
clearTimeout(timer.value)
|
|
102
|
-
updateAfterDuration()
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
onMounted(() => {
|
|
107
|
-
if (props.show) {
|
|
108
|
-
props.onOpen?.()
|
|
109
|
-
updateAfterDuration()
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
SNACKBAR_TYPE,
|
|
115
|
-
n,
|
|
116
|
-
classes,
|
|
117
|
-
zIndex,
|
|
118
|
-
iconName,
|
|
119
|
-
isForbidClick,
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
})
|
|
123
|
-
</script>
|
|
124
|
-
|
|
125
|
-
<style lang="less">
|
|
126
|
-
@import '../styles/common';
|
|
127
|
-
@import '../styles/elevation';
|
|
128
|
-
@import '../loading/loading';
|
|
129
|
-
@import '../button/button';
|
|
130
|
-
@import '../icon/icon';
|
|
131
|
-
@import './snackbar';
|
|
132
|
-
</style>
|