@varlet/cli 1.20.0 → 1.21.1-alpha.64

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 (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.en-US.md +11 -0
  3. package/README.md +11 -0
  4. package/generators/sfc/package.json +3 -2
  5. package/generators/sfc/varlet.config.js +5 -0
  6. package/generators/tsx/package.json +3 -2
  7. package/generators/tsx/varlet.config.js +5 -0
  8. package/lib/commands/build.js +19 -15
  9. package/lib/commands/dev.d.ts +3 -2
  10. package/lib/commands/dev.js +23 -34
  11. package/lib/commands/jest.d.ts +3 -3
  12. package/lib/commands/preview.d.ts +1 -0
  13. package/lib/commands/preview.js +65 -0
  14. package/lib/compiler/compileModule.js +7 -14
  15. package/lib/compiler/compileSFC.js +7 -2
  16. package/lib/compiler/compileSiteEntry.d.ts +1 -4
  17. package/lib/compiler/compileSiteEntry.js +10 -20
  18. package/lib/compiler/compileStyle.js +1 -60
  19. package/lib/config/babel.config.js +0 -9
  20. package/lib/config/jest.config.js +1 -1
  21. package/lib/config/jest.lib.mock.d.ts +0 -0
  22. package/lib/config/jest.lib.mock.js +2 -0
  23. package/lib/config/postcss.config.d.ts +4 -1
  24. package/lib/config/postcss.config.js +14 -38
  25. package/lib/config/varlet.config.d.ts +1 -1
  26. package/lib/config/vite.config.d.ts +4 -0
  27. package/lib/config/vite.config.js +128 -0
  28. package/lib/config/webpack.base.config.js +1 -1
  29. package/lib/index.js +7 -2
  30. package/lib/shared/constant.d.ts +2 -8
  31. package/lib/shared/constant.js +3 -9
  32. package/lib/site/components/app-bar/index.d.ts +3 -0
  33. package/lib/site/components/app-bar/index.js +12 -0
  34. package/lib/site/components/app-bar/props.d.ts +21 -0
  35. package/lib/site/components/app-bar/props.js +28 -0
  36. package/lib/site/components/button/index.d.ts +3 -0
  37. package/lib/site/components/button/index.js +12 -0
  38. package/lib/site/components/button/props.d.ts +62 -0
  39. package/lib/site/components/button/props.js +69 -0
  40. package/lib/site/components/cell/index.d.ts +3 -0
  41. package/lib/site/components/cell/index.js +12 -0
  42. package/lib/site/components/cell/props.d.ts +27 -0
  43. package/lib/site/components/cell/props.js +30 -0
  44. package/lib/site/components/context/index.d.ts +15 -0
  45. package/lib/site/components/context/index.js +11 -0
  46. package/lib/site/components/context/lock.d.ts +10 -0
  47. package/lib/site/components/context/lock.js +94 -0
  48. package/lib/site/components/context/zIndex.d.ts +4 -0
  49. package/lib/site/components/context/zIndex.js +19 -0
  50. package/lib/site/components/icon/index.d.ts +3 -0
  51. package/lib/site/components/icon/index.js +12 -0
  52. package/lib/site/components/icon/props.d.ts +23 -0
  53. package/lib/site/components/icon/props.js +25 -0
  54. package/lib/site/components/loading/index.d.ts +3 -0
  55. package/lib/site/components/loading/index.js +12 -0
  56. package/lib/site/components/loading/props.d.ts +26 -0
  57. package/lib/site/components/loading/props.js +34 -0
  58. package/lib/site/components/menu/index.d.ts +3 -0
  59. package/lib/site/components/menu/index.js +12 -0
  60. package/lib/site/components/menu/props.d.ts +40 -0
  61. package/lib/site/components/menu/props.js +43 -0
  62. package/lib/site/components/progress/index.d.ts +3 -0
  63. package/lib/site/components/progress/index.js +12 -0
  64. package/lib/site/components/progress/props.d.ts +43 -0
  65. package/lib/site/components/progress/props.js +57 -0
  66. package/lib/site/components/ripple/index.d.ts +8 -0
  67. package/lib/site/components/ripple/index.js +125 -0
  68. package/lib/site/components/utils/components.d.ts +53 -0
  69. package/lib/site/components/utils/components.js +279 -0
  70. package/lib/site/components/utils/elements.d.ts +30 -0
  71. package/lib/site/components/utils/elements.js +240 -0
  72. package/lib/site/components/utils/shared.d.ts +36 -0
  73. package/lib/site/components/utils/shared.js +181 -0
  74. package/lib/site/mobile/main.d.ts +3 -0
  75. package/lib/site/mobile/main.js +93 -0
  76. package/lib/site/pc/main.d.ts +3 -0
  77. package/lib/site/pc/main.js +69 -0
  78. package/lib/site/useProgress.d.ts +4 -0
  79. package/lib/site/useProgress.js +58 -0
  80. package/lib/site/utils.d.ts +24 -0
  81. package/lib/site/utils.js +133 -0
  82. package/package.json +16 -30
  83. package/site/.DS_Store +0 -0
  84. package/site/components/app-bar/AppBar.vue +45 -0
  85. package/site/components/app-bar/appBar.less +66 -0
  86. package/site/components/app-bar/index.ts +10 -0
  87. package/site/components/app-bar/props.ts +25 -0
  88. package/site/components/button/Button.vue +84 -0
  89. package/site/components/button/button.less +183 -0
  90. package/site/components/button/index.ts +10 -0
  91. package/site/components/button/props.ts +70 -0
  92. package/site/components/cell/Cell.vue +42 -0
  93. package/site/components/cell/cell.less +74 -0
  94. package/site/components/cell/index.ts +10 -0
  95. package/site/components/cell/props.ts +27 -0
  96. package/site/components/context/index.ts +17 -0
  97. package/site/components/context/lock.ts +103 -0
  98. package/site/components/context/zIndex.ts +20 -0
  99. package/site/components/icon/Icon.vue +68 -0
  100. package/site/components/icon/icon.less +25 -0
  101. package/site/components/icon/index.ts +10 -0
  102. package/site/components/icon/props.ts +24 -0
  103. package/site/components/loading/Loading.vue +55 -0
  104. package/site/components/loading/index.ts +10 -0
  105. package/site/components/loading/loading.less +420 -0
  106. package/site/components/loading/props.ts +37 -0
  107. package/site/components/menu/Menu.vue +113 -0
  108. package/site/components/menu/index.ts +10 -0
  109. package/site/components/menu/menu.less +27 -0
  110. package/site/components/menu/props.ts +43 -0
  111. package/site/components/progress/Progress.vue +108 -0
  112. package/site/components/progress/index.ts +10 -0
  113. package/site/components/progress/progress.less +98 -0
  114. package/site/components/progress/props.ts +55 -0
  115. package/site/components/ripple/index.ts +167 -0
  116. package/site/components/ripple/ripple.less +17 -0
  117. package/site/components/styles/common.less +64 -0
  118. package/site/components/styles/elevation.less +126 -0
  119. package/site/components/styles/var.less +27 -0
  120. package/site/components/utils/components.ts +53 -0
  121. package/site/components/utils/elements.ts +83 -0
  122. package/site/components/utils/shared.ts +27 -0
  123. package/site/{pc/index.html → index.html} +6 -4
  124. package/site/mobile/App.vue +20 -18
  125. package/site/mobile/components/AppHome.vue +6 -8
  126. package/site/mobile/main.ts +17 -2
  127. package/site/{mobile/mobile.html → mobile.html} +6 -5
  128. package/site/pc/App.vue +16 -11
  129. package/site/pc/components/AppHeader.vue +15 -13
  130. package/site/pc/components/AppMobile.vue +3 -3
  131. package/site/pc/components/AppSidebar.vue +17 -23
  132. package/site/pc/main.ts +10 -2
  133. package/site/useProgress.ts +11 -9
  134. package/site/utils.ts +14 -3
  135. package/varlet.default.config.js +3 -2
  136. package/generators/sfc/yarn.lock +0 -11231
  137. package/generators/tsx/yarn.lock +0 -11231
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="varlet-site-sidebar var-elevation--3">
3
- <var-cell
3
+ <var-site-cell
4
4
  class="varlet-site-sidebar__item"
5
5
  :class="{
6
6
  'varlet-site-sidebar__item--active': item.doc === menuName,
@@ -17,20 +17,19 @@
17
17
  @click="changeRoute(item)"
18
18
  >
19
19
  <span class="varlet-site-sidebar__item--title" v-if="item.type === menuTypes.TITLE">{{ item.text[language] }}</span>
20
- <span class="varlet-site-sidebar__item--link" v-else>{{ item.text[language] }}</span>
21
- </var-cell>
20
+ <span v-else>{{ item.text[language] }}</span>
21
+ </var-site-cell>
22
22
  </div>
23
23
  </template>
24
24
 
25
25
  <script lang="ts">
26
26
  // @ts-ignore
27
27
  import config from '@config'
28
- import '@varlet/ui/es/styles/elevation.less'
29
28
  import { MenuTypes } from '../../utils'
30
29
  import { reactive, ref } from 'vue'
31
30
  import type { PropType } from 'vue'
32
31
  import type { Menu } from '../App'
33
- import { get } from 'lodash'
32
+ import { get } from 'lodash-es'
34
33
 
35
34
  export default {
36
35
  name: 'AppSidebar',
@@ -68,13 +67,11 @@ export default {
68
67
  </script>
69
68
 
70
69
  <style scoped lang="less">
71
- @import '~@varlet/ui/es/styles/var';
72
-
73
70
  .varlet-site-sidebar {
74
71
  padding: 0 0 15px;
75
- position: sticky;
76
- flex: 0 0 220px;
77
- top: 0;
72
+ position: fixed;
73
+ width: 220px;
74
+ top: 60px;
78
75
  bottom: 0;
79
76
  left: 0;
80
77
  z-index: 1;
@@ -99,28 +96,18 @@ export default {
99
96
  padding: 8px 0 8px;
100
97
  }
101
98
 
102
- &--link {
103
- font-size: 14px;
104
- color: #455a64;
105
- transition: color 0.2s;
106
-
107
- &:hover {
108
- color: var(--site-color-side-bar);
109
- }
110
- }
111
-
112
99
  &--active {
113
100
  position: relative;
114
- background: var(--site-color-side-bar-active-background);
101
+ background: var(--site-config-color-side-bar-active-background);
115
102
 
116
103
  span {
117
- color: var(--site-color-side-bar);
104
+ color: var(--site-config-color-side-bar);
118
105
  }
119
106
 
120
107
  &::before {
121
108
  display: block;
122
109
  content: '';
123
- background: var(--site-color-side-bar);
110
+ background: var(--site-config-color-side-bar);
124
111
  width: 4px;
125
112
  height: 40px;
126
113
  position: absolute;
@@ -131,6 +118,13 @@ export default {
131
118
 
132
119
  &__link {
133
120
  cursor: pointer;
121
+ font-size: 14px;
122
+ color: #455a64;
123
+ transition: color 0.2s;
124
+
125
+ &:hover {
126
+ color: var(--site-config-color-side-bar);
127
+ }
134
128
  }
135
129
 
136
130
  &__title {
package/site/pc/main.ts CHANGED
@@ -4,10 +4,16 @@ import '@varlet/touch-emulator'
4
4
  import routes from '@pc-routes'
5
5
  // @ts-ignore
6
6
  import config from '@config'
7
- import { Cell, Ripple, Icon } from '@varlet/ui'
7
+
8
+ import Icon from '../components/icon'
9
+ import Cell from '../components/cell'
10
+ import Ripple from '../components/ripple'
11
+ import '../components/styles/common.less'
12
+ import '../components/styles/elevation.less'
13
+
8
14
  import { createApp } from 'vue'
9
15
  import { createRouter, createWebHashHistory } from 'vue-router'
10
- import { get } from 'lodash'
16
+ import { get } from 'lodash-es'
11
17
  import { useProgress } from '../useProgress'
12
18
 
13
19
  const defaultLanguage = get(config, 'defaultLanguage')
@@ -63,7 +69,9 @@ Object.defineProperty(window, 'onMobileRouteChange', {
63
69
 
64
70
  createApp(App)
65
71
  .use(router)
72
+ // @ts-ignore
66
73
  .use(Cell)
67
74
  .use(Ripple)
75
+ // @ts-ignore
68
76
  .use(Icon)
69
77
  .mount('#app')
@@ -1,12 +1,16 @@
1
+ import Progress from './components/progress'
1
2
  import { reactive } from 'vue'
2
- import { Progress } from '@varlet/ui'
3
3
  // @ts-ignore
4
4
  import config from '@config'
5
5
  // @ts-ignore
6
- import { mountInstance } from '@varlet/ui/es/utils/components'
7
- import { get } from 'lodash'
6
+ import { mountInstance } from './utils'
7
+ import { get } from 'lodash-es'
8
8
 
9
9
  export function useProgress() {
10
+ let timer: number
11
+ const trackColor = get(config, 'themes.color-progress-track')
12
+ const color = get(config, 'themes.color-progress')
13
+
10
14
  const props = reactive({
11
15
  style: {
12
16
  position: 'fixed',
@@ -15,14 +19,12 @@ export function useProgress() {
15
19
  top: 0,
16
20
  zIndex: 10086,
17
21
  },
18
- trackColor: '#fff',
19
- color: get(config, 'themes.color-progress'),
22
+ trackColor,
23
+ color,
20
24
  lineWidth: 3,
21
25
  value: 0,
22
26
  })
23
27
 
24
- let timer: number
25
-
26
28
  const changeValue = () => {
27
29
  timer = window.setTimeout(() => {
28
30
  if (props.value >= 95) return
@@ -37,13 +39,13 @@ export function useProgress() {
37
39
 
38
40
  const start = () => {
39
41
  props.value = 0
40
- setTimeout(() => (props.color = '#3594d9'), 200)
42
+ setTimeout(() => (props.color = color), 200)
41
43
  changeValue()
42
44
  }
43
45
 
44
46
  const end = () => {
45
47
  props.value = 100
46
- setTimeout(() => (props.color = '#fff'), 300)
48
+ setTimeout(() => (props.color = trackColor), 300)
47
49
  window.clearTimeout(timer)
48
50
  }
49
51
 
package/site/utils.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  import { onMounted, onUnmounted } from 'vue'
2
- import { get } from 'lodash'
3
- import { StyleProvider } from '@varlet/ui'
2
+ import { get } from 'lodash-es'
3
+ import { formatStyleVars } from './components/utils/elements'
4
+
5
+ export * from './components/utils/components'
6
+ export * from './components/utils/elements'
7
+ export * from './components/utils/shared'
8
+
9
+ export type StyleVars = Record<string, string>
10
+
11
+ function StyleProvider(styleVars: StyleVars = {}) {
12
+ const styles: StyleVars = formatStyleVars(styleVars)
13
+ Object.entries(styles).forEach(([key, value]) => document.documentElement.style.setProperty(key, value))
14
+ }
4
15
 
5
16
  export function camelize(str: string): string {
6
17
  return str.replace(/-(\w)/g, (_: any, p: string) => p.toUpperCase())
@@ -94,7 +105,7 @@ export function setThemes(config: Record<string, any>) {
94
105
  Object.keys(themes).forEach((key) => {
95
106
  const theme = themes[key]
96
107
  StyleProvider({
97
- [`--site-${key}`]: theme
108
+ [`--site-config-${key}`]: theme
98
109
  })
99
110
  })
100
111
  }
@@ -49,13 +49,14 @@ module.exports = {
49
49
  'color-link': '#00c48f',
50
50
  'color-type': '#00c48f',
51
51
  'color-progress': '#1d92e9',
52
- 'color-pc-language-active': '#3a7afe',
53
- 'color-pc-language-active-background': '#edf5ff',
52
+ 'color-progress-track': '#fff',
54
53
  'color-side-bar': '#3a7afe',
55
54
  'color-side-bar-active-background': '#3a7afe1a',
56
55
  'color-app-bar': '#3a7afe',
57
56
  'color-mobile-cell-hover': '#3a7afe',
58
57
  'color-mobile-cell-hover-background': '#3a7afe1a',
58
+ 'color-pc-language-active': '#3a7afe',
59
+ 'color-pc-language-active-background': '#edf5ff',
59
60
  'color-mobile-language-active': '#3a7afe',
60
61
  'color-mobile-language-active-background': '#edf5ff',
61
62
  },