@varlet/cli 1.27.20 → 2.0.0-alpha.1663742071515

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 (176) hide show
  1. package/LICENCE +1 -1
  2. package/lib/commands/commitLint.js +1 -1
  3. package/lib/commands/compile.d.ts +5 -3
  4. package/lib/commands/compile.js +2 -2
  5. package/lib/commands/create.d.ts +8 -3
  6. package/lib/commands/create.js +100 -51
  7. package/lib/commands/dev.d.ts +4 -2
  8. package/lib/commands/dev.js +3 -3
  9. package/lib/commands/gen.d.ts +8 -1
  10. package/lib/commands/gen.js +61 -33
  11. package/lib/commands/jest.js +11 -7
  12. package/lib/commands/release.d.ts +4 -2
  13. package/lib/commands/release.js +2 -2
  14. package/lib/commands/test.d.ts +7 -0
  15. package/lib/commands/test.js +26 -0
  16. package/lib/commands/useVite.d.ts +1 -0
  17. package/lib/commands/useVite.js +70 -0
  18. package/lib/commands/vite.d.ts +3 -0
  19. package/lib/commands/vite.js +69 -0
  20. package/lib/compiler/compileModule.js +9 -5
  21. package/lib/compiler/compileSFC.js +14 -11
  22. package/lib/compiler/compileScript.js +4 -12
  23. package/lib/compiler/compileStyle.d.ts +1 -1
  24. package/lib/compiler/compileStyle.js +7 -17
  25. package/lib/compiler/compileTypes.js +4 -7
  26. package/lib/config/jest.config.js +1 -0
  27. package/lib/config/vite.config.js +1 -1
  28. package/lib/config/vitest.config.d.ts +2 -0
  29. package/lib/config/vitest.config.js +28 -0
  30. package/lib/index.js +22 -3
  31. package/lib/shared/constant.js +1 -1
  32. package/lib/shared/logger.d.ts +1 -0
  33. package/lib/shared/logger.js +3 -0
  34. package/package.json +16 -12
  35. package/site/components/button/Button.vue +45 -23
  36. package/site/components/button/button.less +6 -6
  37. package/site/components/button/props.ts +10 -2
  38. package/site/components/cell/Cell.vue +24 -12
  39. package/site/components/cell/cell.less +11 -7
  40. package/site/components/cell/props.ts +2 -2
  41. package/site/components/code-example/CodeExample.vue +17 -23
  42. package/site/components/context/index.ts +4 -0
  43. package/site/components/context/lock.ts +30 -41
  44. package/site/components/icon/Icon.vue +16 -9
  45. package/site/components/loading/Loading.vue +54 -25
  46. package/site/components/loading/loading.less +120 -35
  47. package/site/components/loading/props.ts +7 -2
  48. package/site/components/popup/Popup.tsx +102 -0
  49. package/site/components/popup/index.ts +10 -0
  50. package/site/components/popup/popup.less +125 -0
  51. package/site/components/popup/props.ts +63 -0
  52. package/site/components/progress/Progress.vue +28 -24
  53. package/site/components/progress/progress.less +16 -13
  54. package/site/components/progress/props.ts +1 -1
  55. package/site/components/ripple/index.ts +28 -7
  56. package/site/components/ripple/ripple.less +3 -0
  57. package/site/components/snackbar/Snackbar.vue +10 -7
  58. package/site/components/snackbar/core.vue +37 -22
  59. package/site/components/snackbar/index.tsx +14 -14
  60. package/site/components/snackbar/props.ts +10 -7
  61. package/site/components/utils/components.ts +49 -1
  62. package/site/components/utils/elements.ts +17 -0
  63. package/site/mobile/App.vue +42 -42
  64. package/site/mobile/components/AppHome.vue +1 -1
  65. package/site/mobile/components/app-bar/AppBar.vue +17 -21
  66. package/site/mobile/components/app-bar/appBar.less +2 -1
  67. package/site/mobile/main.ts +6 -2
  68. package/site/pc/Layout.vue +93 -67
  69. package/site/pc/components/AnimationBox.vue +3 -15
  70. package/site/pc/components/AppHeader.vue +110 -97
  71. package/site/pc/components/AppMobile.vue +8 -2
  72. package/site/pc/components/AppSidebar.vue +19 -10
  73. package/site/pc/components/LogoAnimation.vue +29 -31
  74. package/site/pc/floating.ts +3 -3
  75. package/site/pc/main.ts +6 -0
  76. package/site/pc/pages/index/index.less +142 -197
  77. package/site/pc/pages/index/index.vue +65 -80
  78. package/site/pc/pages/index/locale/en-US.ts +1 -5
  79. package/site/pc/pages/index/locale/zh-CN.ts +1 -5
  80. package/site/useProgress.ts +14 -17
  81. package/site/utils.ts +32 -20
  82. package/template/create/__tests__/index.spec.ejs +8 -0
  83. package/template/create/docs/en-US.md +0 -0
  84. package/template/create/docs/zh-CN.md +0 -0
  85. package/template/create/example/index.ejs +15 -0
  86. package/template/create/example/locale/en-US.ts +3 -0
  87. package/{generators/config/i18n/sfc/src/button → template/create}/example/locale/index.ts +0 -0
  88. package/template/create/example/locale/zh-CN.ts +3 -0
  89. package/template/create/index.ejs +12 -0
  90. package/template/create/less.ejs +3 -0
  91. package/template/create/props.ts +1 -0
  92. package/template/create/tsx.ejs +13 -0
  93. package/template/create/vue.ejs +17 -0
  94. package/{generators → template/generators}/base/.prettierignore +0 -0
  95. package/{generators → template/generators}/base/.prettierrc +0 -0
  96. package/{generators → template/generators}/base/README.md +0 -0
  97. package/{generators → template/generators}/base/babel.config.js +0 -0
  98. package/{generators → template/generators}/base/public/highlight.css +0 -0
  99. package/{generators → template/generators}/base/public/logo.svg +0 -0
  100. package/{generators → template/generators}/base/shims/shims-md.d.ts +0 -0
  101. package/{generators → template/generators}/base/shims/shims-vue.d.ts +0 -0
  102. package/{generators → template/generators}/base/tsconfig.json +0 -0
  103. package/{generators → template/generators}/config/default/base/docs/home.zh-CN.md +0 -0
  104. package/{generators → template/generators}/config/default/base/package.json +1 -1
  105. package/{generators → template/generators}/config/default/base/types/basicComponent.d.ts +0 -0
  106. package/{generators → template/generators}/config/default/base/types/button.d.ts +0 -0
  107. package/{generators → template/generators}/config/default/base/types/index.d.ts +0 -0
  108. package/{generators → template/generators}/config/default/base/varlet.config.js +1 -1
  109. package/{generators → template/generators}/config/default/sfc/src/button/Button.vue +6 -6
  110. package/{generators → template/generators}/config/default/sfc/src/button/__tests__/index.spec.js +0 -0
  111. package/{generators/config/default/tsx → template/generators/config/default/sfc}/src/button/button.less +1 -1
  112. package/{generators → template/generators}/config/default/sfc/src/button/docs/zh-CN.md +0 -0
  113. package/{generators → template/generators}/config/default/sfc/src/button/example/BasicUse.vue +0 -0
  114. package/{generators → template/generators}/config/default/sfc/src/button/example/ModifyColor.vue +0 -0
  115. package/{generators → template/generators}/config/default/sfc/src/button/example/index.vue +2 -2
  116. package/{generators → template/generators}/config/default/sfc/src/button/index.ts +0 -0
  117. package/{generators → template/generators}/config/default/tsx/src/button/Button.tsx +11 -13
  118. package/{generators → template/generators}/config/default/tsx/src/button/__tests__/index.spec.js +0 -0
  119. package/{generators/config/i18n → template/generators/config/default}/tsx/src/button/button.less +1 -1
  120. package/{generators → template/generators}/config/default/tsx/src/button/docs/zh-CN.md +0 -0
  121. package/{generators → template/generators}/config/default/tsx/src/button/example/BasicUse.vue +0 -0
  122. package/{generators → template/generators}/config/default/tsx/src/button/example/ModifyColor.vue +0 -0
  123. package/{generators → template/generators}/config/default/tsx/src/button/example/index.vue +2 -2
  124. package/{generators → template/generators}/config/default/tsx/src/button/index.ts +0 -0
  125. package/{generators → template/generators}/config/i18n/base/docs/home.en-US.md +0 -0
  126. package/{generators → template/generators}/config/i18n/base/docs/home.zh-CN.md +0 -0
  127. package/{generators → template/generators}/config/i18n/base/package.json +1 -1
  128. package/{generators → template/generators}/config/i18n/base/types/basicComponent.d.ts +0 -0
  129. package/{generators → template/generators}/config/i18n/base/types/button.d.ts +0 -0
  130. package/{generators → template/generators}/config/i18n/base/types/index.d.ts +0 -0
  131. package/{generators → template/generators}/config/i18n/base/types/locale.d.ts +0 -0
  132. package/{generators → template/generators}/config/i18n/base/varlet.config.js +3 -3
  133. package/{generators → template/generators}/config/i18n/sfc/src/button/Button.vue +7 -7
  134. package/{generators → template/generators}/config/i18n/sfc/src/button/__tests__/index.spec.js +0 -0
  135. package/{generators → template/generators}/config/i18n/sfc/src/button/button.less +1 -1
  136. package/{generators → template/generators}/config/i18n/sfc/src/button/docs/en-US.md +0 -0
  137. package/{generators → template/generators}/config/i18n/sfc/src/button/docs/zh-CN.md +0 -0
  138. package/{generators → template/generators}/config/i18n/sfc/src/button/example/BasicUse.vue +0 -0
  139. package/{generators → template/generators}/config/i18n/sfc/src/button/example/ModifyColor.vue +0 -0
  140. package/{generators → template/generators}/config/i18n/sfc/src/button/example/index.vue +1 -1
  141. package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/en-US.ts +1 -1
  142. package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/index.ts +0 -0
  143. package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/zh-CN.ts +1 -1
  144. package/{generators → template/generators}/config/i18n/sfc/src/button/index.ts +0 -0
  145. package/{generators → template/generators}/config/i18n/sfc/src/locale/__tests__/index.spec.js +0 -0
  146. package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/en-US.md +0 -0
  147. package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/zh-CN.md +0 -0
  148. package/{generators → template/generators}/config/i18n/sfc/src/locale/en-US.d.ts +0 -0
  149. package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/en-US.ts +1 -1
  150. package/{generators → template/generators}/config/i18n/sfc/src/locale/index.ts +0 -0
  151. package/{generators → template/generators}/config/i18n/sfc/src/locale/zh-CN.d.ts +0 -0
  152. package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/zh-CN.ts +1 -1
  153. package/{generators → template/generators}/config/i18n/tsx/src/button/Button.tsx +12 -14
  154. package/{generators → template/generators}/config/i18n/tsx/src/button/__tests__/index.spec.js +0 -0
  155. package/{generators/config/default/sfc → template/generators/config/i18n/tsx}/src/button/button.less +1 -1
  156. package/{generators → template/generators}/config/i18n/tsx/src/button/docs/en-US.md +0 -0
  157. package/{generators → template/generators}/config/i18n/tsx/src/button/docs/zh-CN.md +0 -0
  158. package/{generators → template/generators}/config/i18n/tsx/src/button/example/BasicUse.vue +0 -0
  159. package/{generators → template/generators}/config/i18n/tsx/src/button/example/ModifyColor.vue +0 -0
  160. package/{generators → template/generators}/config/i18n/tsx/src/button/example/index.vue +1 -1
  161. package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/en-US.ts +1 -1
  162. package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -0
  163. package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/zh-CN.ts +1 -1
  164. package/{generators → template/generators}/config/i18n/tsx/src/button/index.ts +0 -0
  165. package/{generators → template/generators}/config/i18n/tsx/src/locale/__tests__/index.spec.js +0 -0
  166. package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/en-US.md +0 -0
  167. package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/zh-CN.md +0 -0
  168. package/{generators → template/generators}/config/i18n/tsx/src/locale/en-US.d.ts +0 -0
  169. package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/en-US.ts +1 -1
  170. package/{generators → template/generators}/config/i18n/tsx/src/locale/index.ts +0 -0
  171. package/{generators → template/generators}/config/i18n/tsx/src/locale/zh-CN.d.ts +0 -0
  172. package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/zh-CN.ts +1 -1
  173. package/varlet.default.config.js +137 -15
  174. package/site/mobile/components/styles/common.less +0 -64
  175. package/site/mobile/components/styles/elevation.less +0 -126
  176. package/site/mobile/components/styles/var.less +0 -27
@@ -1,40 +1,59 @@
1
1
  <template>
2
- <div class="var-site--box var-site-loading">
3
- <div class="var-site-loading__circle" v-if="type === 'circle'">
4
- <span
5
- class="var-site-loading__circle-block"
6
- :style="{
7
- width: radius * 2 + 'px',
8
- height: radius * 2 + 'px',
9
- }"
10
- >
11
- <svg viewBox="25 25 50 50">
12
- <circle cx="50" cy="50" r="20" fill="none"></circle>
13
- </svg>
14
- </span>
2
+ <div :class="n()">
3
+ <div :class="classes(n('content'), [loading, n('content--active')])" v-if="$slots.default">
4
+ <slot />
5
+ <div :class="n('content-mask')" v-if="loading"></div>
15
6
  </div>
7
+ <div :class="classes('var-site--box', n('body'), [$slots.default, n('inside')])" v-if="isShow">
8
+ <div :class="n('circle')" v-if="type === 'circle'">
9
+ <span
10
+ :class="classes(n('circle-block'), n(`circle-block--${size}`))"
11
+ :style="{
12
+ width: multiplySizeUnit(radius, 2),
13
+ height: multiplySizeUnit(radius, 2),
14
+ color,
15
+ }"
16
+ >
17
+ <svg viewBox="25 25 50 50">
18
+ <circle cx="50" cy="50" r="20" fill="none"></circle>
19
+ </svg>
20
+ </span>
21
+ </div>
16
22
 
17
- <template v-for="(nums, key) in loadingTypeDict" :key="key">
18
- <div :class="`var-site-loading__${key} var-site-loading__${key}-${size}`" v-if="type === key">
19
- <div
20
- v-for="num in nums"
21
- :key="num + key"
22
- :style="{ backgroundColor: color }"
23
- :class="`var-site-loading__${key}-item var-site-loading__${key}-item-${size}`"
24
- ></div>
23
+ <template v-for="(nums, key) in loadingTypeDict" :key="key">
24
+ <div :class="classes(n(key), n(`${key}--${size}`))" v-if="type === key">
25
+ <div
26
+ v-for="num in nums"
27
+ :key="num + key"
28
+ :style="{ backgroundColor: color }"
29
+ :class="classes(n(`${key}-item`), n(`${key}-item--${size}`))"
30
+ ></div>
31
+ </div>
32
+ </template>
33
+ <div
34
+ :class="classes(n('description'), n(`description--${size}`))"
35
+ :style="{ color }"
36
+ v-if="$slots.description || description"
37
+ >
38
+ <slot name="description">{{ description }}</slot>
25
39
  </div>
26
- </template>
40
+ </div>
27
41
  </div>
28
42
  </template>
29
43
 
30
44
  <script lang="ts">
31
- import { defineComponent } from 'vue'
45
+ import { computed, defineComponent } from 'vue'
32
46
  import { props } from './props'
47
+ import { createNamespace, call } from '../utils/components'
48
+ import { multiplySizeUnit } from '../utils/elements'
49
+ import type { ComputedRef } from 'vue'
50
+
51
+ const { n, classes } = createNamespace('loading')
33
52
 
34
53
  export default defineComponent({
35
- name: 'VarSiteLoading',
54
+ name: 'VarLoading',
36
55
  props,
37
- setup() {
56
+ setup(props, { slots }) {
38
57
  const loadingTypeDict = {
39
58
  wave: 5,
40
59
  cube: 4,
@@ -42,8 +61,18 @@ export default defineComponent({
42
61
  disappear: 3,
43
62
  }
44
63
 
64
+ const isShow: ComputedRef<boolean> = computed(() => {
65
+ if (!call(slots.default)) return true
66
+
67
+ return props.loading
68
+ })
69
+
45
70
  return {
71
+ n,
72
+ classes,
73
+ multiplySizeUnit,
46
74
  loadingTypeDict,
75
+ isShow,
47
76
  }
48
77
  },
49
78
  })
@@ -1,5 +1,7 @@
1
1
  @import '../styles/var';
2
2
 
3
+ @site-loading-opacity: 0.38;
4
+ @site-loading-desc-margin: 8px 0 0;
3
5
  @site-loading-normal-width: 50px;
4
6
  @site-loading-normal-height: @site-font-size-md + 2;
5
7
 
@@ -12,18 +14,97 @@
12
14
  @site-loading-mini-width: 22px;
13
15
  @site-loading-mini-height: @site-font-size-xs + 2;
14
16
 
17
+ :root {
18
+ --site-loading-opacity: @site-loading-opacity;
19
+ --site-loading-desc-margin: @site-loading-desc-margin;
20
+ }
21
+
15
22
  .var-site-loading {
16
- display: flex;
17
- justify-content: center;
18
- align-items: center;
23
+ position: relative;
24
+
25
+ &__content {
26
+ position: relative;
27
+ transition: opacity 0.3s;
28
+ opacity: 1;
29
+
30
+ &--active {
31
+ opacity: var(--site-loading-opacity);
32
+ }
33
+
34
+ &-mask {
35
+ position: absolute;
36
+ left: 0;
37
+ right: 0;
38
+ top: 0;
39
+ bottom: 0;
40
+ }
41
+ }
42
+
43
+ &__body {
44
+ display: flex;
45
+ justify-content: center;
46
+ align-items: center;
47
+ height: 100%;
48
+ flex-direction: column;
49
+ }
50
+
51
+ &__inside {
52
+ position: absolute;
53
+ left: 50%;
54
+ top: 50%;
55
+ transform: translate(-50%, -50%);
56
+ z-index: 1;
57
+ }
58
+
59
+ &__description {
60
+ color: @site-color-primary;
61
+ margin: var(--site-loading-desc-margin);
62
+
63
+ &--large {
64
+ font-size: @site-font-size-lg;
65
+ }
66
+
67
+ &--normal {
68
+ font-size: @site-font-size-md;
69
+ }
70
+
71
+ &--small {
72
+ font-size: @site-font-size-sm;
73
+ }
74
+
75
+ &--mini {
76
+ font-size: @site-font-size-xs;
77
+ }
78
+ }
19
79
 
20
80
  &__circle {
21
81
  display: flex;
22
82
 
23
83
  &-block {
24
84
  display: inline-block;
85
+ color: @site-color-primary;
25
86
  animation: circle 1.8s linear infinite;
26
87
 
88
+ &--large {
89
+ width: 36px;
90
+ height: 36px;
91
+ }
92
+
93
+ &--normal {
94
+ width: 30px;
95
+ height: 30px;
96
+ }
97
+
98
+ &--small {
99
+ width: 24px;
100
+ height: 24px;
101
+ }
102
+
103
+ &--mini {
104
+ width: 18px;
105
+ height: 18px;
106
+ }
107
+
27
108
  svg {
28
109
  display: block;
29
110
  width: 100%;
@@ -72,22 +153,22 @@
72
153
  align-items: center;
73
154
  justify-content: center;
74
155
 
75
- &-large {
156
+ &--large {
76
157
  width: @site-loading-large-width;
77
158
  height: @site-loading-large-height;
78
159
  }
79
160
 
80
- &-normal {
161
+ &--normal {
81
162
  width: @site-loading-normal-width;
82
163
  height: @site-loading-normal-height;
83
164
  }
84
165
 
85
- &-small {
166
+ &--small {
86
167
  width: @site-loading-small-width;
87
168
  height: @site-loading-small-height;
88
169
  }
89
170
 
90
- &-mini {
171
+ &--mini {
91
172
  width: @site-loading-mini-width;
92
173
  height: @site-loading-mini-height;
93
174
  }
@@ -96,6 +177,7 @@
96
177
  height: 100%;
97
178
  display: inline-block;
98
179
  animation: 1.2s ease-in-out infinite wave;
180
+ background-color: @site-color-primary;
99
181
 
100
182
  &:nth-child(1) {
101
183
  animation-delay: -1.2s;
@@ -119,22 +201,22 @@
119
201
  }
120
202
  }
121
203
 
122
- &-item-large {
204
+ &-item--large {
123
205
  width: @site-loading-wave-size-item-width;
124
206
  margin-left: @site-loading-wave-size-item-margin;
125
207
  }
126
208
 
127
- &-item-normal {
209
+ &-item--normal {
128
210
  width: @site-loading-wave-size-item-width - 1;
129
211
  margin-left: @site-loading-wave-size-item-margin - 1;
130
212
  }
131
213
 
132
- &-item-small {
214
+ &-item--small {
133
215
  width: @site-loading-wave-size-item-width - 2;
134
216
  margin-left: @site-loading-wave-size-item-margin - 2;
135
217
  }
136
218
 
137
- &-item-mini {
219
+ &-item--mini {
138
220
  width: @site-loading-wave-size-item-width - 3;
139
221
  margin-left: @site-loading-wave-size-item-margin - 3;
140
222
  }
@@ -159,22 +241,22 @@
159
241
  display: flex;
160
242
  align-items: center;
161
243
 
162
- &-large {
244
+ &--large {
163
245
  width: @site-loading-large-width;
164
246
  height: @site-loading-large-height;
165
247
  }
166
248
 
167
- &-normal {
249
+ &--normal {
168
250
  width: @site-loading-normal-width;
169
251
  height: @site-loading-normal-height;
170
252
  }
171
253
 
172
- &-small {
254
+ &--small {
173
255
  width: @site-loading-small-width;
174
256
  height: @site-loading-small-height;
175
257
  }
176
258
 
177
- &-mini {
259
+ &--mini {
178
260
  width: @site-loading-mini-width;
179
261
  height: @site-loading-mini-height;
180
262
  }
@@ -183,6 +265,7 @@
183
265
  display: inline-block;
184
266
  transform-origin: right bottom;
185
267
  animation: 1.5s ease infinite cube;
268
+ background-color: @site-color-primary;
186
269
 
187
270
  &:nth-child(1) {
188
271
  animation-delay: 0.2s;
@@ -202,25 +285,25 @@
202
285
  }
203
286
  }
204
287
 
205
- &-item-large {
288
+ &-item--large {
206
289
  height: @site-loading-cube-size-item-height;
207
290
  width: @site-loading-cube-size-item-width;
208
291
  margin-left: @site-loading-cube-size-item-margin;
209
292
  }
210
293
 
211
- &-item-normal {
294
+ &-item--normal {
212
295
  height: @site-loading-cube-size-item-height - 2;
213
296
  width: @site-loading-cube-size-item-width - 2;
214
297
  margin-left: @site-loading-cube-size-item-margin - 1;
215
298
  }
216
299
 
217
- &-item-small {
300
+ &-item--small {
218
301
  height: @site-loading-cube-size-item-height - 4;
219
302
  width: @site-loading-cube-size-item-width - 4;
220
303
  margin-left: @site-loading-cube-size-item-margin - 2;
221
304
  }
222
305
 
223
- &-item-mini {
306
+ &-item--mini {
224
307
  height: @site-loading-cube-size-item-height - 6;
225
308
  width: @site-loading-cube-size-item-width - 6;
226
309
  margin-left: @site-loading-cube-size-item-margin - 3;
@@ -247,28 +330,29 @@
247
330
  justify-content: center;
248
331
  align-items: center;
249
332
 
250
- &-large {
333
+ &--large {
251
334
  width: @site-loading-large-width;
252
335
  height: @site-loading-large-height;
253
336
  }
254
337
 
255
- &-normal {
338
+ &--normal {
256
339
  width: @site-loading-normal-width;
257
340
  height: @site-loading-normal-height;
258
341
  }
259
342
 
260
- &-small {
343
+ &--small {
261
344
  width: @site-loading-small-width;
262
345
  height: @site-loading-small-height;
263
346
  }
264
347
 
265
- &-mini {
348
+ &--mini {
266
349
  width: @site-loading-mini-width;
267
350
  height: @site-loading-mini-height;
268
351
  }
269
352
 
270
353
  &-item {
271
354
  animation: 2s ease-in-out infinite rect;
355
+ background-color: @site-color-primary;
272
356
 
273
357
  &:nth-child(1) {
274
358
  animation-delay: 1.75s;
@@ -303,22 +387,22 @@
303
387
  }
304
388
  }
305
389
 
306
- &-item-large {
390
+ &-item--large {
307
391
  height: @site-loading-rect-size-item-height;
308
392
  width: @site-loading-rect-size-item-width;
309
393
  }
310
394
 
311
- &-item-normal {
395
+ &-item--normal {
312
396
  height: @site-loading-rect-size-item-height * 0.9;
313
397
  width: @site-loading-rect-size-item-width * 0.8;
314
398
  }
315
399
 
316
- &-item-small {
400
+ &-item--small {
317
401
  height: @site-loading-rect-size-item-height * 0.8;
318
402
  width: @site-loading-rect-size-item-width * 0.6;
319
403
  }
320
404
 
321
- &-item-mini {
405
+ &-item--mini {
322
406
  height: @site-loading-rect-size-item-height * 0.7;
323
407
  width: @site-loading-rect-size-item-width * 0.4;
324
408
  }
@@ -351,22 +435,22 @@
351
435
  align-items: center;
352
436
  flex-flow: nowrap;
353
437
 
354
- &-large {
438
+ &--large {
355
439
  width: @site-loading-large-width;
356
440
  height: @site-loading-large-height;
357
441
  }
358
442
 
359
- &-normal {
443
+ &--normal {
360
444
  width: @site-loading-normal-width;
361
445
  height: @site-loading-normal-height;
362
446
  }
363
447
 
364
- &-small {
448
+ &--small {
365
449
  width: @site-loading-small-width;
366
450
  height: @site-loading-small-height;
367
451
  }
368
452
 
369
- &-mini {
453
+ &--mini {
370
454
  width: @site-loading-mini-width;
371
455
  height: @site-loading-mini-height;
372
456
  }
@@ -374,6 +458,7 @@
374
458
  &-item {
375
459
  border-radius: 50%;
376
460
  animation: 0.5s ease-in-out infinite alternate disappear;
461
+ background-color: @site-color-primary;
377
462
 
378
463
  &:nth-child(1) {
379
464
  animation-delay: -0.4s;
@@ -388,22 +473,22 @@
388
473
  }
389
474
  }
390
475
 
391
- &-item-large {
476
+ &-item--large {
392
477
  height: @site-loading-disappear-size-item-height;
393
478
  width: @site-loading-disappear-size-item-width;
394
479
  }
395
480
 
396
- &-item-normal {
481
+ &-item--normal {
397
482
  height: @site-loading-disappear-size-item-height * 0.8;
398
483
  width: @site-loading-disappear-size-item-width * 0.8;
399
484
  }
400
485
 
401
- &-item-small {
486
+ &-item--small {
402
487
  height: @site-loading-disappear-size-item-height * 0.6;
403
488
  width: @site-loading-disappear-size-item-width * 0.6;
404
489
  }
405
490
 
406
- &-item-mini {
491
+ &-item--mini {
407
492
  height: @site-loading-disappear-size-item-height * 0.4;
408
493
  width: @site-loading-disappear-size-item-width * 0.4;
409
494
  }
@@ -21,7 +21,6 @@ export const props = {
21
21
  },
22
22
  radius: {
23
23
  type: [String, Number],
24
- default: 15,
25
24
  },
26
25
  // loading尺寸
27
26
  size: {
@@ -32,6 +31,12 @@ export const props = {
32
31
  // loading颜色
33
32
  color: {
34
33
  type: String,
35
- default: 'currentColor',
34
+ },
35
+ description: {
36
+ type: String,
37
+ },
38
+ loading: {
39
+ type: Boolean,
40
+ default: false,
36
41
  },
37
42
  }
@@ -0,0 +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
+ })
@@ -0,0 +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