@varlet/cli 1.23.8 → 1.24.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/generators/{sfc → base}/.gitignore +0 -0
  3. package/generators/{sfc → base}/.husky/commit-msg +0 -0
  4. package/generators/{sfc → base}/.husky/pre-commit +0 -0
  5. package/generators/{tsx → base}/.prettierignore +0 -1
  6. package/generators/{sfc → base}/.prettierrc +0 -0
  7. package/generators/{sfc → base}/README.md +0 -0
  8. package/generators/{sfc → base}/babel.config.js +0 -0
  9. package/generators/{sfc → base}/commitlint.config.js +0 -0
  10. package/generators/{sfc → base}/docs/home.zh-CN.md +0 -0
  11. package/generators/{sfc → base}/package.json +0 -0
  12. package/generators/{sfc → base}/public/highlight.css +0 -0
  13. package/generators/{sfc → base}/public/logo.svg +0 -0
  14. package/generators/{sfc → base}/shims/shims-md.d.ts +0 -0
  15. package/generators/{sfc → base}/shims/shims-vue.d.ts +0 -0
  16. package/generators/{sfc → base}/tsconfig.json +0 -0
  17. package/generators/{sfc → base}/types/basicComponent.d.ts +0 -0
  18. package/generators/{sfc → base}/types/button.d.ts +0 -0
  19. package/generators/{sfc → base}/types/index.d.ts +0 -0
  20. package/generators/{sfc → base}/varlet.config.js +0 -0
  21. package/lib/commands/dev.js +1 -1
  22. package/lib/commands/gen.js +7 -3
  23. package/package.json +4 -4
  24. package/site/components/code-example/CodeExample.vue +107 -0
  25. package/site/components/code-example/codeExample.less +23 -0
  26. package/site/components/code-example/index.ts +10 -0
  27. package/site/components/icon/icon.less +1 -0
  28. package/site/components/loading/props.ts +2 -2
  29. package/site/components/snackbar/Snackbar.vue +38 -0
  30. package/site/components/snackbar/core.vue +117 -0
  31. package/site/components/snackbar/index.tsx +270 -0
  32. package/site/components/snackbar/props.ts +94 -0
  33. package/site/components/snackbar/snackbar.less +135 -0
  34. package/site/components/utils/elements.ts +9 -0
  35. package/site/components/utils/shared.ts +3 -0
  36. package/site/mobile/App.vue +6 -6
  37. package/site/module.d.ts +4 -0
  38. package/site/pc/App.vue +9 -11
  39. package/site/pc/components/AppHeader.vue +8 -9
  40. package/site/pc/components/AppSidebar.vue +6 -6
  41. package/site/pc/main.ts +8 -2
  42. package/site/tsconfig.json +1 -6
  43. package/site/useProgress.ts +6 -2
  44. package/site/utils.ts +4 -3
  45. package/tsconfig.json +0 -2
  46. package/varlet.default.config.js +13 -0
  47. package/generators/sfc/.prettierignore +0 -8
  48. package/generators/tsx/.gitignore +0 -14
  49. package/generators/tsx/.husky/commit-msg +0 -4
  50. package/generators/tsx/.husky/pre-commit +0 -4
  51. package/generators/tsx/.prettierrc +0 -5
  52. package/generators/tsx/README.md +0 -88
  53. package/generators/tsx/babel.config.js +0 -10
  54. package/generators/tsx/commitlint.config.js +0 -3
  55. package/generators/tsx/docs/home.zh-CN.md +0 -11
  56. package/generators/tsx/package.json +0 -98
  57. package/generators/tsx/public/highlight.css +0 -1
  58. package/generators/tsx/public/logo.svg +0 -1
  59. package/generators/tsx/shims/shims-md.d.ts +0 -4
  60. package/generators/tsx/shims/shims-vue.d.ts +0 -6
  61. package/generators/tsx/tsconfig.json +0 -13
  62. package/generators/tsx/types/basicComponent.d.ts +0 -7
  63. package/generators/tsx/types/button.d.ts +0 -12
  64. package/generators/tsx/types/index.d.ts +0 -6
  65. package/generators/tsx/varlet.config.js +0 -106
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.24.0](https://github.com/haoziqaq/varlet/compare/v1.23.11...v1.24.0) (2021-12-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cli/site:** adjust z-index of the sidebar and code toolbar for site ([5b81918](https://github.com/haoziqaq/varlet/commit/5b8191822305e5a485003223d3109a6554b33251))
12
+ * **site:** modify code example style ([bb33910](https://github.com/haoziqaq/varlet/commit/bb3391008bdafbf052b8485b79bb54270ca27771))
13
+ * fix test fail ([78f20ec](https://github.com/haoziqaq/varlet/commit/78f20ec46bea357fd12c1da68b02ce7dc9cc2918))
14
+ * **cli:** fix icon vertical-align ([f015092](https://github.com/haoziqaq/varlet/commit/f0150923b9d33c6f61c9810887ea294015a35621))
15
+ * **site:** add types ([6520984](https://github.com/haoziqaq/varlet/commit/6520984af6eb13b772783540aa72427cf1e4403e))
16
+ * **site:** fix mobile style ([3189225](https://github.com/haoziqaq/varlet/commit/31892257a3611e2c6fa39d01cd0d87d4cc2d5ebb))
17
+
18
+
19
+ ### Features
20
+
21
+ * **cli:** add clipboard and fold tool for site ([5298c99](https://github.com/haoziqaq/varlet/commit/5298c996a6ea890ee29c01c254704f06d157df4c))
22
+
23
+
24
+ ### Reverts
25
+
26
+ * revert fix mobile style ([22d9da9](https://github.com/haoziqaq/varlet/commit/22d9da9beaf88fa1a29394bc07141e5ec3355c42))
27
+
28
+
29
+
30
+
31
+
32
+ ## [1.23.11](https://github.com/haoziqaq/varlet/compare/v1.23.10...v1.23.11) (2021-12-10)
33
+
34
+ **Note:** Version bump only for package @varlet/cli
35
+
36
+
37
+
38
+
39
+
6
40
  ## [1.23.8](https://github.com/haoziqaq/varlet/compare/v1.23.7...v1.23.8) (2021-11-24)
7
41
 
8
42
 
File without changes
File without changes
File without changes
@@ -3,6 +3,5 @@ es/**
3
3
  umd/**
4
4
  site/**
5
5
  public/**
6
- src/*/__tests__/**
7
6
  *.md
8
7
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -99,7 +99,7 @@ function startServer(force) {
99
99
  watcher = chokidar_1.default.watch(constant_1.VARLET_CONFIG);
100
100
  watcher.on('change', function () { return startServer(force); });
101
101
  }
102
- logger_1.default.info((isRestart ? 'Res' : 'S') + "tart successfully!!!");
102
+ logger_1.default.success("\n" + (isRestart ? 'Res' : 'S') + "tart successfully!!!");
103
103
  return [2 /*return*/];
104
104
  }
105
105
  });
@@ -46,7 +46,7 @@ var path_1 = require("path");
46
46
  var fs_extra_1 = require("fs-extra");
47
47
  var constant_1 = require("../shared/constant");
48
48
  function removeFiles(dest) {
49
- var files = ['es', 'umd', 'highlight', 'types/index.d.ts', '.varlet', 'node_modules'];
49
+ var files = ['es', 'lib', 'umd', 'highlight', 'types/index.d.ts', '.varlet', 'node_modules'];
50
50
  files.forEach(function (filename) { return (0, fs_extra_1.removeSync)((0, path_1.resolve)(dest, filename)); });
51
51
  }
52
52
  function syncVersion(name) {
@@ -59,7 +59,7 @@ function syncVersion(name) {
59
59
  }
60
60
  function gen(name) {
61
61
  return __awaiter(this, void 0, void 0, function () {
62
- var dest, ret, choice, generator;
62
+ var dest, ret, choice, generator, base;
63
63
  return __generator(this, function (_a) {
64
64
  switch (_a.label) {
65
65
  case 0:
@@ -79,8 +79,12 @@ function gen(name) {
79
79
  ret = _a.sent();
80
80
  choice = ret['Please select your component library programming style'];
81
81
  generator = (0, path_1.resolve)(constant_1.GENERATORS_DIR, choice);
82
- return [4 /*yield*/, (0, fs_extra_1.copy)(generator, dest)];
82
+ base = (0, path_1.resolve)(constant_1.GENERATORS_DIR, 'base');
83
+ return [4 /*yield*/, (0, fs_extra_1.copy)(base, dest)];
83
84
  case 2:
85
+ _a.sent();
86
+ return [4 /*yield*/, (0, fs_extra_1.copy)(generator, dest)];
87
+ case 3:
84
88
  _a.sent();
85
89
  removeFiles(dest);
86
90
  syncVersion(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.23.8",
3
+ "version": "1.24.0",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -31,7 +31,7 @@
31
31
  "dev": "tsc --watch",
32
32
  "build": "tsc"
33
33
  },
34
- "gitHead": "7962430948d06d391cc52d22f87cb4d304d8c2b5",
34
+ "gitHead": "859769307c762134844c0ddfdb69452631f76d62",
35
35
  "dependencies": {
36
36
  "@babel/core": "^7.14.8",
37
37
  "@babel/preset-env": "^7.14.8",
@@ -40,8 +40,8 @@
40
40
  "@commitlint/config-conventional": "^11.0.0",
41
41
  "@release-it/conventional-changelog": "^3.3.0",
42
42
  "@varlet/eslint-config": "^1.13.0",
43
- "@varlet/icons": "^1.23.0",
44
- "@varlet/markdown-vite-plugin": "^1.22.0",
43
+ "@varlet/icons": "^1.24.0",
44
+ "@varlet/markdown-vite-plugin": "^1.24.0",
45
45
  "@varlet/stylelint-config": "^1.9.0",
46
46
  "@varlet/touch-emulator": "^1.0.1",
47
47
  "@vitejs/plugin-vue": "1.9.2",
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <div class="var-site-code-example">
3
+ <div class="var-site-code-example__toolbar">
4
+ <var-site-button text round @click="toggle" v-if="fold">
5
+ <var-site-icon name="xml" size="18" />
6
+ </var-site-button>
7
+
8
+ <var-site-button
9
+ :id="`clip-trigger-${cid}`"
10
+ :data-clipboard-target="`#clip-target-${cid}`"
11
+ text
12
+ round
13
+ v-if="clipboard"
14
+ >
15
+ <var-site-icon name="content-copy" size="18" />
16
+ </var-site-button>
17
+ </div>
18
+ <div
19
+ :id="`clip-target-${cid}`"
20
+ class="var-site-code-example__code"
21
+ ref="code"
22
+ :style="{
23
+ height: height >= 0 ? `${height}px` : undefined,
24
+ }"
25
+ >
26
+ <slot/>
27
+ </div>
28
+ </div>
29
+ </template>
30
+
31
+ <script lang="ts">
32
+ import Icon from '../icon'
33
+ import Button from '../button'
34
+ import Snackbar from '../snackbar'
35
+ import Clipboard from 'clipboard'
36
+ import config from '@config'
37
+ import { defineComponent, nextTick, ref, onMounted } from 'vue'
38
+ import { doubleRaf } from '../utils/elements'
39
+ import { get } from 'lodash-es'
40
+ import { getPCLocationInfo } from '../../utils'
41
+ import type { Ref } from 'vue'
42
+
43
+ let clipId = 0
44
+ const offset = 10
45
+
46
+ export default defineComponent({
47
+ name: 'VarSiteCodeExample',
48
+ components: {
49
+ [Button.name]: Button,
50
+ [Icon.name]: Icon
51
+ },
52
+ setup() {
53
+ const code: Ref<HTMLElement | null> = ref(null)
54
+ const cid: Ref<number> = ref(clipId++)
55
+ const fold: Ref = ref(get(config, 'pc.fold'))
56
+ const clipboard: Ref = ref(get(config, 'pc.clipboard', {}))
57
+ const height: Ref<number> = ref(fold.value?.defaultFold ? fold.value?.foldHeight : -1)
58
+
59
+ const toggle = async () => {
60
+ const foldHeight = fold.value.foldHeight
61
+
62
+ if (height.value === foldHeight) {
63
+ height.value = -1
64
+ await nextTick()
65
+ const { offsetHeight } = code.value as HTMLElement
66
+
67
+ height.value = foldHeight
68
+ await doubleRaf()
69
+
70
+ if (offsetHeight - foldHeight < offset) {
71
+ Snackbar(get(config, `pc.fold.message.${getPCLocationInfo().language}`))
72
+ height.value = foldHeight
73
+ } else {
74
+ height.value = offsetHeight
75
+ }
76
+ } else {
77
+ const { offsetHeight } = code.value as HTMLElement
78
+
79
+ height.value = offsetHeight
80
+ await doubleRaf()
81
+ height.value = foldHeight
82
+ }
83
+ }
84
+
85
+ onMounted(() => {
86
+ const trigger = new Clipboard(`#clip-trigger-${cid.value}`)
87
+
88
+ trigger.on('success', () => {
89
+ Snackbar.success(clipboard.value[getPCLocationInfo().language])
90
+ })
91
+ })
92
+
93
+ return {
94
+ code,
95
+ height,
96
+ cid,
97
+ fold,
98
+ clipboard,
99
+ toggle
100
+ }
101
+ }
102
+ })
103
+ </script>
104
+
105
+ <style lang="less">
106
+ @import "./codeExample";
107
+ </style>
@@ -0,0 +1,23 @@
1
+ .var-site-code-example {
2
+ margin-top: 12px;
3
+ position: relative;
4
+
5
+ &__toolbar {
6
+ display: flex;
7
+ align-items: center;
8
+ position: absolute;
9
+ z-index: 1;
10
+ right: 10px;
11
+ top: 20px;
12
+
13
+ button {
14
+ color: white !important;
15
+ }
16
+ }
17
+
18
+ &__code {
19
+ transition: all .25s;
20
+ overflow: hidden;
21
+ border-radius: 4px;
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import type { App } from 'vue'
2
+ import CodeExample from './CodeExample.vue'
3
+
4
+ CodeExample.install = function (app: App) {
5
+ app.component(CodeExample.name, CodeExample)
6
+ }
7
+
8
+ export const _CodeExampleComponent = CodeExample
9
+
10
+ export default CodeExample
@@ -12,6 +12,7 @@
12
12
  align-items: center;
13
13
  font-size: var(--site-icon-size);
14
14
  color: inherit;
15
+ vertical-align: bottom;
15
16
 
16
17
  &--shrinking {
17
18
  transform: scale(0);
@@ -1,8 +1,8 @@
1
1
  import type { PropType } from 'vue'
2
2
 
3
- type LoadingType = 'circle' | 'wave' | 'cube' | 'rect' | 'disappear'
3
+ export type LoadingType = 'circle' | 'wave' | 'cube' | 'rect' | 'disappear'
4
4
 
5
- type LoadingSize = 'normal' | 'mini' | 'small' | 'large'
5
+ export type LoadingSize = 'normal' | 'mini' | 'small' | 'large'
6
6
 
7
7
  export function typeValidator(type: string): boolean {
8
8
  return ['circle', 'wave', 'cube', 'rect', 'disappear'].includes(type)
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <teleport :to="teleport" :disabled="disabled">
3
+ <transition name="var-site-snackbar-fade" @after-enter="onOpened" @after-leave="onClosed">
4
+ <var-site-snackbar-core v-bind="$props" class="var-site-snackbar-transition">
5
+ <slot>{{ content }}</slot>
6
+ <template #action>
7
+ <slot name="action" />
8
+ </template>
9
+ </var-site-snackbar-core>
10
+ </transition>
11
+ </teleport>
12
+ </template>
13
+
14
+ <script>
15
+ import VarSiteSnackbarCore from './core'
16
+ import { defineComponent } from 'vue'
17
+ import { useTeleport } from '../utils/components'
18
+ import { props } from './props'
19
+
20
+ export default defineComponent({
21
+ name: 'VarSiteSnackbar',
22
+ components: {
23
+ VarSiteSnackbarCore,
24
+ },
25
+ props,
26
+ setup() {
27
+ const { disabled } = useTeleport()
28
+
29
+ return {
30
+ disabled,
31
+ }
32
+ },
33
+ })
34
+ </script>
35
+
36
+ <style lang="less">
37
+ @import '../styles/common';
38
+ </style>
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <div class="var-site-snackbar" :style="{ pointerEvents: isForbidClick ? 'auto' : 'none', zIndex }" v-show="show">
3
+ <div :class="snackbarClass" :style="{ zIndex }">
4
+ <div class="var-site-snackbar__content" :class="[contentClass]">
5
+ <slot>{{ content }}</slot>
6
+ </div>
7
+ <div class="var-site-snackbar__action">
8
+ <var-site-icon v-if="iconName" :name="iconName" />
9
+ <var-site-loading v-if="type === 'loading'" :type="loadingType" :size="loadingSize" />
10
+ <slot name="action" />
11
+ </div>
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import { defineComponent, watch, ref, onMounted, computed } from 'vue'
18
+ import VarSiteLoading from '../loading'
19
+ import VarSiteIcon from '../icon'
20
+ import { useZIndex } from '../context/zIndex'
21
+ import { props } from './props'
22
+ import { useLock } from '../context/lock'
23
+ import { SNACKBAR_TYPE } from './index'
24
+ import type { Ref, ComputedRef } from 'vue'
25
+ import type { SnackbarType } from './index'
26
+
27
+ const ICON_TYPE_DICT: Record<SnackbarType, string> = {
28
+ success: 'checkbox-marked-circle',
29
+ warning: 'warning',
30
+ info: 'information',
31
+ error: 'error',
32
+ loading: '',
33
+ }
34
+
35
+ export default defineComponent({
36
+ name: 'VarSiteSnackbarCore',
37
+ components: {
38
+ VarSiteLoading,
39
+ VarSiteIcon,
40
+ },
41
+ props,
42
+ setup(props) {
43
+ const timer: Ref = ref(null)
44
+ const { zIndex } = useZIndex(() => props.show, 1)
45
+
46
+ useLock(props, 'show', 'lockScroll')
47
+
48
+ const snackbarClass: ComputedRef<string> = computed(() => {
49
+ const { position, vertical, type } = props
50
+
51
+ const baseClass = `var-site-snackbar__wrapper var-site-snackbar__wrapper-${position} var-site-elevation--4`
52
+ const verticalClass = vertical ? ' var-site-snackbar__vertical' : ''
53
+ const typeClass = type && SNACKBAR_TYPE.includes(type) ? ` var-site-snackbar__wrapper-${type}` : ''
54
+
55
+ return `${baseClass}${verticalClass}${typeClass}`
56
+ })
57
+
58
+ const isForbidClick: ComputedRef<boolean> = computed(() => props.type === 'loading' || props.forbidClick)
59
+
60
+ const iconName: ComputedRef<string> = computed(() => {
61
+ if (!props.type) return ''
62
+
63
+ return ICON_TYPE_DICT[props.type]
64
+ })
65
+
66
+ const updateAfterDuration = () => {
67
+ timer.value = setTimeout(() => {
68
+ props.type !== 'loading' && props['onUpdate:show']?.(false)
69
+ }, props.duration)
70
+ }
71
+
72
+ watch(
73
+ () => props.show,
74
+ (show) => {
75
+ if (show) {
76
+ props.onOpen?.()
77
+ updateAfterDuration()
78
+ } else if (show === false) {
79
+ clearTimeout(timer.value)
80
+ props.onClose?.()
81
+ }
82
+ }
83
+ )
84
+
85
+ watch(
86
+ () => props._update,
87
+ () => {
88
+ clearTimeout(timer.value)
89
+ updateAfterDuration()
90
+ }
91
+ )
92
+
93
+ onMounted(() => {
94
+ if (props.show) {
95
+ props.onOpen?.()
96
+ updateAfterDuration()
97
+ }
98
+ })
99
+
100
+ return {
101
+ zIndex,
102
+ snackbarClass,
103
+ iconName,
104
+ isForbidClick,
105
+ }
106
+ },
107
+ })
108
+ </script>
109
+
110
+ <style lang="less">
111
+ @import '../styles/common';
112
+ @import '../styles/elevation';
113
+ @import '../loading/loading';
114
+ @import '../button/button';
115
+ @import '../icon/icon';
116
+ @import './snackbar';
117
+ </style>