@varlet/cli 2.0.0-alpha.1663499244572 → 2.0.0-alpha.1664031123039
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/LICENCE +21 -21
- package/README.en-US.md +401 -401
- package/README.md +396 -396
- package/lib/commands/build.d.ts +1 -1
- package/lib/commands/build.js +67 -18
- package/lib/commands/changelog.d.ts +6 -6
- package/lib/commands/changelog.js +27 -26
- package/lib/commands/commitLint.d.ts +1 -1
- package/lib/commands/commitLint.js +21 -50
- package/lib/commands/compile.d.ts +7 -7
- package/lib/commands/compile.js +119 -43
- package/lib/commands/create.d.ts +8 -8
- package/lib/commands/create.js +166 -90
- package/lib/commands/dev.d.ts +5 -5
- package/lib/commands/dev.js +123 -44
- package/lib/commands/gen.d.ts +8 -8
- package/lib/commands/gen.js +135 -85
- package/lib/commands/jest.d.ts +8 -0
- package/lib/commands/jest.js +85 -0
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +123 -48
- package/lib/commands/preview.d.ts +1 -1
- package/lib/commands/preview.js +74 -23
- package/lib/commands/release.d.ts +5 -5
- package/lib/commands/release.js +270 -132
- package/lib/commands/vite.d.ts +3 -3
- package/lib/commands/vite.js +69 -20
- package/lib/compiler/compileModule.d.ts +5 -5
- package/lib/compiler/compileModule.js +190 -79
- package/lib/compiler/compileSFC.d.ts +2 -2
- package/lib/compiler/compileSFC.js +135 -86
- package/lib/compiler/compileScript.d.ts +17 -17
- package/lib/compiler/compileScript.js +194 -152
- package/lib/compiler/compileSiteEntry.d.ts +13 -13
- package/lib/compiler/compileSiteEntry.js +237 -140
- package/lib/compiler/compileStyle.d.ts +11 -11
- package/lib/compiler/compileStyle.js +91 -43
- package/lib/compiler/compileTemplateHighlight.d.ts +10 -10
- package/lib/compiler/compileTemplateHighlight.js +193 -145
- package/lib/compiler/compileTypes.d.ts +2 -2
- package/lib/compiler/compileTypes.js +85 -49
- package/lib/config/babel.config.d.ts +2 -2
- package/lib/config/babel.config.js +31 -30
- package/lib/config/babel.sfc.transform.d.ts +1 -1
- package/lib/config/babel.sfc.transform.js +18 -18
- package/lib/config/jest.config.d.ts +1 -0
- package/lib/config/jest.config.js +37 -0
- package/lib/config/jest.media.mock.d.ts +0 -0
- package/lib/config/jest.media.mock.js +2 -0
- package/lib/config/jest.style.mock.d.ts +0 -0
- package/lib/config/jest.style.mock.js +2 -0
- package/lib/config/varlet.config.d.ts +1 -1
- package/lib/config/varlet.config.js +24 -23
- package/lib/config/vite.config.d.ts +5 -5
- package/lib/config/vite.config.js +162 -157
- package/lib/index.d.ts +2 -2
- package/lib/index.js +102 -84
- package/lib/shared/constant.d.ts +43 -44
- package/lib/shared/constant.js +50 -51
- package/lib/shared/fsUtils.d.ts +12 -12
- package/lib/shared/fsUtils.js +108 -61
- package/lib/shared/logger.d.ts +8 -8
- package/lib/shared/logger.js +23 -23
- package/package.json +11 -11
- package/preset.js +3 -3
- package/site/components/button/Button.vue +106 -106
- package/site/components/button/button.less +183 -183
- package/site/components/button/index.ts +10 -10
- package/site/components/button/props.ts +78 -78
- package/site/components/cell/Cell.vue +54 -54
- package/site/components/cell/cell.less +78 -78
- package/site/components/cell/index.ts +10 -10
- package/site/components/cell/props.ts +27 -27
- package/site/components/code-example/CodeExample.vue +137 -137
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/index.ts +21 -21
- package/site/components/context/lock.ts +92 -92
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/Icon.vue +75 -75
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/Loading.vue +84 -84
- package/site/components/loading/index.ts +10 -10
- package/site/components/loading/loading.less +505 -505
- package/site/components/loading/props.ts +42 -42
- package/site/components/popup/Popup.tsx +102 -102
- package/site/components/popup/index.ts +10 -10
- package/site/components/popup/popup.less +125 -125
- package/site/components/popup/props.ts +63 -63
- package/site/components/progress/Progress.vue +112 -112
- package/site/components/progress/index.ts +10 -10
- package/site/components/progress/progress.less +101 -101
- package/site/components/progress/props.ts +55 -55
- package/site/components/ripple/index.ts +188 -188
- package/site/components/ripple/ripple.less +20 -20
- package/site/components/snackbar/Snackbar.vue +41 -41
- package/site/components/snackbar/core.vue +132 -132
- package/site/components/snackbar/index.tsx +270 -270
- package/site/components/snackbar/props.ts +97 -97
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/components/utils/components.ts +117 -117
- package/site/components/utils/elements.ts +102 -102
- package/site/index.html +49 -49
- package/site/mobile/App.vue +291 -291
- package/site/mobile/components/AppHome.vue +134 -134
- package/site/mobile/components/AppType.vue +22 -22
- package/site/mobile/components/app-bar/AppBar.vue +65 -65
- package/site/mobile/components/app-bar/appBar.less +57 -57
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile/main.ts +78 -78
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/pc/App.vue +43 -43
- package/site/pc/Layout.vue +423 -423
- package/site/pc/components/AnimationBox.vue +33 -33
- package/site/pc/components/AppHeader.vue +368 -368
- package/site/pc/components/AppMobile.vue +60 -60
- package/site/pc/components/AppSidebar.vue +143 -143
- package/site/pc/components/LogoAnimation.vue +117 -117
- package/site/pc/floating.ts +9 -9
- package/site/pc/main.ts +100 -100
- package/site/pc/pages/index/index.less +176 -176
- package/site/pc/pages/index/index.vue +130 -130
- package/site/pc/pages/index/locale/en-US.ts +1 -1
- package/site/pc/pages/index/locale/zh-CN.ts +1 -1
- package/site/tsconfig.json +11 -11
- package/site/useProgress.ts +72 -72
- package/site/utils.ts +165 -167
- package/template/create/{tsx.ejs → [ComponentName].tsx.ejs} +13 -13
- package/template/create/{vue.ejs → [ComponentName].vue.ejs} +17 -17
- package/template/create/{less.ejs → [componentName].less.ejs} +3 -3
- package/template/create/__tests__/{index.spec.ejs → index.spec.js.ejs} +13 -8
- package/template/create/example/{index.ejs → index.vue.ejs} +15 -15
- package/template/create/example/locale/en-US.ts +3 -3
- package/template/create/example/locale/index.ts +23 -23
- package/template/create/example/locale/zh-CN.ts +3 -3
- package/template/create/{index.ejs → index.ts.ejs} +11 -12
- package/template/create/props.ts +1 -1
- package/template/generators/base/.prettierignore +14 -9
- package/template/generators/base/.prettierrc +5 -5
- package/template/generators/base/README.md +82 -82
- package/template/generators/base/babel.config.js +10 -10
- package/template/generators/base/public/logo.svg +30 -1
- package/template/generators/base/shims/shims-md.d.ts +4 -4
- package/template/generators/base/shims/shims-vue.d.ts +6 -6
- package/template/generators/base/tsconfig.json +13 -13
- package/template/generators/config/default/base/docs/home.zh-CN.md +2 -10
- package/template/generators/config/default/base/package.json +112 -105
- package/template/generators/config/default/base/types/basicComponent.d.ts +7 -7
- package/template/generators/config/default/base/types/button.d.ts +12 -12
- package/template/generators/config/default/base/types/index.d.ts +6 -6
- package/template/generators/config/default/base/varlet.config.js +45 -110
- package/template/generators/config/default/sfc/src/button/Button.vue +31 -30
- package/template/generators/config/default/sfc/src/button/__tests__/index.spec.js +7 -7
- package/template/generators/config/default/sfc/src/button/button.less +14 -14
- package/template/generators/config/default/sfc/src/button/docs/zh-CN.md +38 -47
- package/template/generators/config/default/sfc/src/button/example/BasicUse.vue +7 -7
- package/template/generators/config/default/sfc/src/button/example/ModifyColor.vue +7 -7
- package/template/generators/config/default/sfc/src/button/example/index.vue +12 -13
- package/template/generators/config/default/sfc/src/button/index.ts +10 -10
- package/template/generators/config/default/tsx/src/button/Button.tsx +29 -29
- package/template/generators/config/default/tsx/src/button/__tests__/index.spec.js +7 -7
- package/template/generators/config/default/tsx/src/button/button.less +14 -14
- package/template/generators/config/default/tsx/src/button/docs/zh-CN.md +38 -47
- package/template/generators/config/default/tsx/src/button/example/BasicUse.vue +7 -7
- package/template/generators/config/default/tsx/src/button/example/ModifyColor.vue +7 -7
- package/template/generators/config/default/tsx/src/button/example/index.vue +12 -13
- package/template/generators/config/default/tsx/src/button/index.ts +10 -10
- package/template/generators/config/i18n/base/docs/home.en-US.md +3 -11
- package/template/generators/config/i18n/base/docs/home.zh-CN.md +2 -10
- package/template/generators/config/i18n/base/package.json +112 -105
- package/template/generators/config/i18n/base/types/basicComponent.d.ts +7 -7
- package/template/generators/config/i18n/base/types/button.d.ts +12 -12
- package/template/generators/config/i18n/base/types/index.d.ts +7 -7
- package/template/generators/config/i18n/base/types/locale.d.ts +24 -24
- package/template/generators/config/i18n/base/varlet.config.js +47 -122
- package/template/generators/config/i18n/sfc/src/button/Button.vue +37 -36
- package/template/generators/config/i18n/sfc/src/button/__tests__/index.spec.js +7 -7
- package/template/generators/config/i18n/sfc/src/button/button.less +14 -14
- package/template/generators/config/i18n/sfc/src/button/docs/en-US.md +38 -34
- package/template/generators/config/i18n/sfc/src/button/docs/zh-CN.md +38 -34
- package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +11 -11
- package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +11 -11
- package/template/generators/config/i18n/sfc/src/button/example/index.vue +16 -13
- package/template/generators/config/i18n/sfc/src/button/example/locale/en-US.ts +5 -5
- package/template/generators/config/i18n/sfc/src/button/example/locale/index.ts +23 -23
- package/template/generators/config/i18n/sfc/src/button/example/locale/zh-CN.ts +5 -5
- package/template/generators/config/i18n/sfc/src/button/index.ts +10 -10
- package/template/generators/config/i18n/sfc/src/locale/__tests__/index.spec.js +51 -51
- package/template/generators/config/i18n/sfc/src/locale/docs/en-US.md +26 -26
- package/template/generators/config/i18n/sfc/src/locale/docs/zh-CN.md +25 -25
- package/template/generators/config/i18n/sfc/src/locale/en-US.d.ts +5 -5
- package/template/generators/config/i18n/sfc/src/locale/en-US.ts +7 -7
- package/template/generators/config/i18n/sfc/src/locale/index.ts +67 -67
- package/template/generators/config/i18n/sfc/src/locale/zh-CN.d.ts +5 -5
- package/template/generators/config/i18n/sfc/src/locale/zh-CN.ts +7 -7
- package/template/generators/config/i18n/tsx/src/button/Button.tsx +31 -33
- package/template/generators/config/i18n/tsx/src/button/__tests__/index.spec.js +7 -7
- package/template/generators/config/i18n/tsx/src/button/button.less +14 -14
- package/template/generators/config/i18n/tsx/src/button/docs/en-US.md +38 -34
- package/template/generators/config/i18n/tsx/src/button/docs/zh-CN.md +38 -34
- package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +11 -11
- package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +11 -11
- package/template/generators/config/i18n/tsx/src/button/example/index.vue +15 -13
- package/template/generators/config/i18n/tsx/src/button/example/locale/en-US.ts +5 -5
- package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -23
- package/template/generators/config/i18n/tsx/src/button/example/locale/zh-CN.ts +5 -5
- package/template/generators/config/i18n/tsx/src/button/index.ts +10 -10
- package/template/generators/config/i18n/tsx/src/locale/__tests__/index.spec.js +51 -51
- package/template/generators/config/i18n/tsx/src/locale/docs/en-US.md +26 -26
- package/template/generators/config/i18n/tsx/src/locale/docs/zh-CN.md +25 -25
- package/template/generators/config/i18n/tsx/src/locale/en-US.d.ts +5 -5
- package/template/generators/config/i18n/tsx/src/locale/en-US.ts +7 -7
- package/template/generators/config/i18n/tsx/src/locale/index.ts +67 -67
- package/template/generators/config/i18n/tsx/src/locale/zh-CN.d.ts +5 -5
- package/template/generators/config/i18n/tsx/src/locale/zh-CN.ts +7 -7
- package/tsconfig.json +14 -15
- package/varlet.default.config.js +3 -3
- package/lib/commands/test.d.ts +0 -7
- package/lib/commands/test.js +0 -26
- package/lib/config/vitest.config.d.ts +0 -2
- package/lib/config/vitest.config.js +0 -28
- package/template/generators/base/public/highlight.css +0 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type { PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
export type LoadingType = 'circle' | 'wave' | 'cube' | 'rect' | 'disappear'
|
|
4
|
-
|
|
5
|
-
export type LoadingSize = 'normal' | 'mini' | 'small' | 'large'
|
|
6
|
-
|
|
7
|
-
export function typeValidator(type: string): boolean {
|
|
8
|
-
return ['circle', 'wave', 'cube', 'rect', 'disappear'].includes(type)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function sizeValidator(size: string): boolean {
|
|
12
|
-
return ['normal', 'mini', 'small', 'large'].includes(size)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const props = {
|
|
16
|
-
// loading类型
|
|
17
|
-
type: {
|
|
18
|
-
type: String as PropType<LoadingType>,
|
|
19
|
-
default: 'circle',
|
|
20
|
-
validator: typeValidator,
|
|
21
|
-
},
|
|
22
|
-
radius: {
|
|
23
|
-
type: [String, Number],
|
|
24
|
-
},
|
|
25
|
-
// loading尺寸
|
|
26
|
-
size: {
|
|
27
|
-
type: String as PropType<LoadingSize>,
|
|
28
|
-
default: 'normal',
|
|
29
|
-
validator: sizeValidator,
|
|
30
|
-
},
|
|
31
|
-
// loading颜色
|
|
32
|
-
color: {
|
|
33
|
-
type: String,
|
|
34
|
-
},
|
|
35
|
-
description: {
|
|
36
|
-
type: String,
|
|
37
|
-
},
|
|
38
|
-
loading: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
}
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
export type LoadingType = 'circle' | 'wave' | 'cube' | 'rect' | 'disappear'
|
|
4
|
+
|
|
5
|
+
export type LoadingSize = 'normal' | 'mini' | 'small' | 'large'
|
|
6
|
+
|
|
7
|
+
export function typeValidator(type: string): boolean {
|
|
8
|
+
return ['circle', 'wave', 'cube', 'rect', 'disappear'].includes(type)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function sizeValidator(size: string): boolean {
|
|
12
|
+
return ['normal', 'mini', 'small', 'large'].includes(size)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const props = {
|
|
16
|
+
// loading类型
|
|
17
|
+
type: {
|
|
18
|
+
type: String as PropType<LoadingType>,
|
|
19
|
+
default: 'circle',
|
|
20
|
+
validator: typeValidator,
|
|
21
|
+
},
|
|
22
|
+
radius: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
},
|
|
25
|
+
// loading尺寸
|
|
26
|
+
size: {
|
|
27
|
+
type: String as PropType<LoadingSize>,
|
|
28
|
+
default: 'normal',
|
|
29
|
+
validator: sizeValidator,
|
|
30
|
+
},
|
|
31
|
+
// loading颜色
|
|
32
|
+
color: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
description: {
|
|
36
|
+
type: String,
|
|
37
|
+
},
|
|
38
|
+
loading: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
}
|
|
@@ -1,102 +1,102 @@
|
|
|
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
|
+
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,10 +1,10 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
2
|
-
import Popup from './Popup'
|
|
3
|
-
|
|
4
|
-
Popup.install = function (app: App) {
|
|
5
|
-
app.component(Popup.name, Popup)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const _PopupComponent = Popup
|
|
9
|
-
|
|
10
|
-
export default Popup
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import Popup from './Popup'
|
|
3
|
+
|
|
4
|
+
Popup.install = function (app: App) {
|
|
5
|
+
app.component(Popup.name, Popup)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const _PopupComponent = Popup
|
|
9
|
+
|
|
10
|
+
export default Popup
|
|
@@ -1,125 +1,125 @@
|
|
|
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
|
+
@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 +1,63 @@
|
|
|
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
|
+
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
|
+
}
|