@vrojs/element-plus 0.0.1

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 (88) hide show
  1. package/package.json +56 -0
  2. package/src/index.ts +13 -0
  3. package/src/locale/index.ts +3 -0
  4. package/src/locale/lang/zh-cn.ts +22 -0
  5. package/src/locale/types.ts +8 -0
  6. package/src/locale/useLocale.ts +42 -0
  7. package/src/style/base.scss +2 -0
  8. package/src/style/css.ts +2 -0
  9. package/src/style/deps.ts +9 -0
  10. package/src/style/index.scss +12 -0
  11. package/src/style/index.ts +2 -0
  12. package/src/utils/datePickerValueFormat.ts +6 -0
  13. package/src/utils/index.ts +2 -0
  14. package/src/vro-el-checkbox-group/README.md +83 -0
  15. package/src/vro-el-checkbox-group/index.ts +16 -0
  16. package/src/vro-el-checkbox-group/style/css.ts +2 -0
  17. package/src/vro-el-checkbox-group/style/deps.ts +2 -0
  18. package/src/vro-el-checkbox-group/style/index.scss +1 -0
  19. package/src/vro-el-checkbox-group/style/index.ts +2 -0
  20. package/src/vro-el-checkbox-group/types.ts +18 -0
  21. package/src/vro-el-checkbox-group/vro-el-checkbox-group.vue +33 -0
  22. package/src/vro-el-config-provider/README.md +65 -0
  23. package/src/vro-el-config-provider/index.ts +16 -0
  24. package/src/vro-el-config-provider/style/css.ts +2 -0
  25. package/src/vro-el-config-provider/style/deps.ts +0 -0
  26. package/src/vro-el-config-provider/style/index.scss +0 -0
  27. package/src/vro-el-config-provider/style/index.ts +2 -0
  28. package/src/vro-el-config-provider/types.ts +18 -0
  29. package/src/vro-el-config-provider/vro-el-config-provider.vue +19 -0
  30. package/src/vro-el-file-upload/README.md +89 -0
  31. package/src/vro-el-file-upload/index.ts +17 -0
  32. package/src/vro-el-file-upload/style/css.ts +2 -0
  33. package/src/vro-el-file-upload/style/deps.ts +2 -0
  34. package/src/vro-el-file-upload/style/index.scss +30 -0
  35. package/src/vro-el-file-upload/style/index.ts +2 -0
  36. package/src/vro-el-file-upload/types.ts +50 -0
  37. package/src/vro-el-file-upload/utils.ts +7 -0
  38. package/src/vro-el-file-upload/vro-el-file-upload.vue +95 -0
  39. package/src/vro-el-icon/README.md +68 -0
  40. package/src/vro-el-icon/index.ts +16 -0
  41. package/src/vro-el-icon/style/css.ts +2 -0
  42. package/src/vro-el-icon/style/deps.ts +1 -0
  43. package/src/vro-el-icon/style/index.scss +1 -0
  44. package/src/vro-el-icon/style/index.ts +2 -0
  45. package/src/vro-el-icon/types.ts +12 -0
  46. package/src/vro-el-icon/vro-el-icon.vue +28 -0
  47. package/src/vro-el-image-upload/README.md +99 -0
  48. package/src/vro-el-image-upload/index.ts +17 -0
  49. package/src/vro-el-image-upload/style/css.ts +2 -0
  50. package/src/vro-el-image-upload/style/deps.ts +4 -0
  51. package/src/vro-el-image-upload/style/index.scss +55 -0
  52. package/src/vro-el-image-upload/style/index.ts +2 -0
  53. package/src/vro-el-image-upload/types.ts +42 -0
  54. package/src/vro-el-image-upload/utils.ts +7 -0
  55. package/src/vro-el-image-upload/vro-el-image-upload.vue +134 -0
  56. package/src/vro-el-schema-form-dialog/README.md +64 -0
  57. package/src/vro-el-schema-form-dialog/function-call.ts +12 -0
  58. package/src/vro-el-schema-form-dialog/index.ts +17 -0
  59. package/src/vro-el-schema-form-dialog/style/css.ts +2 -0
  60. package/src/vro-el-schema-form-dialog/style/deps.ts +0 -0
  61. package/src/vro-el-schema-form-dialog/style/index.scss +1 -0
  62. package/src/vro-el-schema-form-dialog/style/index.ts +2 -0
  63. package/src/vro-el-schema-form-dialog/types.ts +5 -0
  64. package/src/vro-el-schema-form-dialog/vro-el-schema-form-dialog.vue +32 -0
  65. package/src/vro-el-select/README.md +83 -0
  66. package/src/vro-el-select/index.ts +16 -0
  67. package/src/vro-el-select/style/css.ts +2 -0
  68. package/src/vro-el-select/style/deps.ts +2 -0
  69. package/src/vro-el-select/style/index.scss +1 -0
  70. package/src/vro-el-select/style/index.ts +2 -0
  71. package/src/vro-el-select/types.ts +18 -0
  72. package/src/vro-el-select/vro-el-select.vue +33 -0
  73. package/src/vro-el-skeleton/README.md +128 -0
  74. package/src/vro-el-skeleton/index.ts +16 -0
  75. package/src/vro-el-skeleton/style/css.ts +3 -0
  76. package/src/vro-el-skeleton/style/deps.ts +3 -0
  77. package/src/vro-el-skeleton/style/index.scss +24 -0
  78. package/src/vro-el-skeleton/style/index.ts +2 -0
  79. package/src/vro-el-skeleton/types.ts +86 -0
  80. package/src/vro-el-skeleton/vro-el-skeleton.vue +73 -0
  81. package/src/vro-el-with-config/README.md +75 -0
  82. package/src/vro-el-with-config/index.ts +16 -0
  83. package/src/vro-el-with-config/style/css.ts +3 -0
  84. package/src/vro-el-with-config/style/deps.ts +2 -0
  85. package/src/vro-el-with-config/style/index.scss +0 -0
  86. package/src/vro-el-with-config/style/index.ts +2 -0
  87. package/src/vro-el-with-config/types.ts +18 -0
  88. package/src/vro-el-with-config/vro-el-with-config.vue +48 -0
@@ -0,0 +1,64 @@
1
+ # VroElSchemaFormDialog
2
+
3
+ ### 介绍
4
+
5
+ ...
6
+
7
+ ## 代码演示
8
+
9
+ ### 基础用法
10
+
11
+ ## API
12
+
13
+ ### 属性 Props
14
+
15
+ <table>
16
+ <tbody>
17
+ <tr>
18
+ <td>名称</td>
19
+ <td>类型</td>
20
+ <td>默认值</td>
21
+ </tr>
22
+ <tr v-for="(item, key) in vroElSchemaFormDialogProps" :key="key">
23
+ <td>{{ key }}</td>
24
+ <td>{{ parseType(item.type || item) }}</td>
25
+ <td>{{ reserve(item.default, '-') }}</td>
26
+ </tr>
27
+ </tbody>
28
+ </table>
29
+
30
+ ### 插槽 Slots
31
+
32
+ <table>
33
+ <tbody>
34
+ <tr>
35
+ <td>名称</td>
36
+ <td>说明</td>
37
+ </tr>
38
+ <tr>
39
+ <td>xx</td>
40
+ <td>xxx</td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+
45
+ ### 实例方法
46
+
47
+ <table>
48
+ <tbody>
49
+ <tr>
50
+ <td>名称</td>
51
+ <td>说明</td>
52
+ </tr>
53
+ <tr>
54
+ <td>xx</td>
55
+ <td>xxx</td>
56
+ </tr>
57
+ </tbody>
58
+ </table>
59
+
60
+ <script setup lang="ts">
61
+ import { reserve } from '@daysnap/utils'
62
+ import { VroElSchemaFormDialog, vroElSchemaFormDialogProps } from '.'
63
+ import { parseType } from '../utils'
64
+ </script>
@@ -0,0 +1,12 @@
1
+ import { showComponent } from '@vrojs/base'
2
+ import { AppContext } from 'vue'
3
+
4
+ import { VroElSchemaFormDialogProps } from './types'
5
+ import VroElSchemaFormDialog from './vro-el-schema-form-dialog.vue'
6
+
7
+ export function showVroElSchemaFormDialog<T = any>(
8
+ props: Partial<VroElSchemaFormDialogProps>,
9
+ appContext: AppContext | null = null,
10
+ ): Promise<T> {
11
+ return showComponent(VroElSchemaFormDialog, props, appContext)
12
+ }
@@ -0,0 +1,17 @@
1
+ import { withInstall } from '@vrojs/base'
2
+
3
+ import Component from './vro-el-schema-form-dialog.vue'
4
+
5
+ export * from './function-call'
6
+ export * from './types'
7
+
8
+ export const VroElSchemaFormDialog = withInstall<typeof Component>(Component)
9
+ export default VroElSchemaFormDialog
10
+
11
+ export type VroElSchemaFormDialogInstance = InstanceType<typeof VroElSchemaFormDialog>
12
+
13
+ declare module 'vue' {
14
+ export interface GlobalComponents {
15
+ VroElSchemaFormDialog: typeof VroElSchemaFormDialog
16
+ }
17
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/base.scss'
2
+ import './index.scss'
File without changes
@@ -0,0 +1 @@
1
+ .vro-el-schema-form-dialog { }
@@ -0,0 +1,2 @@
1
+ import './deps'
2
+ import './css'
@@ -0,0 +1,5 @@
1
+ import type { ExtractPropTypes } from 'vue'
2
+
3
+ export const vroElSchemaFormDialogProps = {}
4
+
5
+ export type VroElSchemaFormDialogProps = ExtractPropTypes<typeof vroElSchemaFormDialogProps>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <el-dialog v-model="visible" class="vro-el-schema-form-dialog">
3
+ <span>vro-el-schema-form-dialog</span>
4
+ </el-dialog>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { useVisible } from '@vrojs/use'
9
+ import { ref } from 'vue'
10
+
11
+ import { VroElSchemaFormDialogProps, vroElSchemaFormDialogProps } from './types'
12
+
13
+ defineOptions({ name: 'VroElSchemaFormDialog' })
14
+ defineProps(vroElSchemaFormDialogProps)
15
+ const emit = defineEmits(['cancel', 'confirm'])
16
+
17
+ const dynamicProps = ref<any>()
18
+
19
+ const { show, hide, confirm, visible } = useVisible<Partial<VroElSchemaFormDialogProps>, any>({
20
+ showCallback: (options) => {
21
+ dynamicProps.value = options
22
+ },
23
+ hideCallback: (reason) => emit('cancel', reason),
24
+ confirmCallback: (data) => emit('confirm', data),
25
+ })
26
+
27
+ defineExpose({
28
+ show,
29
+ hide,
30
+ confirm,
31
+ })
32
+ </script>
@@ -0,0 +1,83 @@
1
+ # VroElSelect
2
+
3
+ ### 介绍
4
+
5
+ 基于 `ElSelect` 和 `ElOption` 的选项化封装。适合通过 `options` 快速渲染下拉选项,同时保留 Element Plus Select 的原有属性和事件。
6
+
7
+ ## 代码演示
8
+
9
+ ### 基础用法
10
+
11
+ ```html
12
+ <template>
13
+ <vro-el-select v-model="value" :options="options" placeholder="请选择" />
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import { ref } from 'vue'
18
+
19
+ const value = ref('')
20
+ const options = [
21
+ { label: '苹果', value: 'apple' },
22
+ { label: '香蕉', value: 'banana' },
23
+ { label: '橙子', value: 'orange', props: { disabled: true } },
24
+ ]
25
+ </script>
26
+ ```
27
+
28
+ ### 自定义字段名
29
+
30
+ ```html
31
+ <vro-el-select v-model="value" :options="options" label-key="name" value-key="id" />
32
+ ```
33
+
34
+ ## API
35
+
36
+ ### 属性 Props
37
+
38
+ <table>
39
+ <tbody>
40
+ <tr>
41
+ <td>名称</td>
42
+ <td>类型</td>
43
+ <td>默认值</td>
44
+ </tr>
45
+ <tr v-for="(item, key) in vroElSelectProps" :key="key">
46
+ <td>{{ key }}</td>
47
+ <td>{{ parseType(item.type || item) }}</td>
48
+ <td>{{ reserve(item.default, '-') }}</td>
49
+ </tr>
50
+ </tbody>
51
+ </table>
52
+
53
+ ### 插槽 Slots
54
+
55
+ 支持默认插槽,传入后会作为 `ElSelect` 的内容,覆盖 `options` 自动渲染的选项。
56
+
57
+ ### 事件 Events
58
+
59
+ <table>
60
+ <tbody>
61
+ <tr>
62
+ <td>名称</td>
63
+ <td>参数</td>
64
+ <td>说明</td>
65
+ </tr>
66
+ <tr>
67
+ <td>update:modelValue</td>
68
+ <td>value</td>
69
+ <td>选中值变化时触发</td>
70
+ </tr>
71
+ <tr>
72
+ <td>change</td>
73
+ <td>value</td>
74
+ <td>同 Element Plus Select change 事件</td>
75
+ </tr>
76
+ </tbody>
77
+ </table>
78
+
79
+ <script setup lang="ts">
80
+ import { reserve } from '@daysnap/utils'
81
+ import { VroElSelect, vroElSelectProps } from '.'
82
+ import { parseType } from '../utils'
83
+ </script>
@@ -0,0 +1,16 @@
1
+ import { withInstall } from '@vrojs/base'
2
+
3
+ import Component from './vro-el-select.vue'
4
+
5
+ export * from './types'
6
+
7
+ export const VroElSelect = withInstall<typeof Component>(Component)
8
+ export default VroElSelect
9
+
10
+ export type VroElSelectInstance = InstanceType<typeof VroElSelect>
11
+
12
+ declare module 'vue' {
13
+ export interface GlobalComponents {
14
+ VroElSelect: typeof VroElSelect
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/base.scss'
2
+ import './index.scss'
@@ -0,0 +1,2 @@
1
+ import 'element-plus/es/components/option/style/css'
2
+ import 'element-plus/es/components/select/style/css'
@@ -0,0 +1 @@
1
+ .vro-el-select { }
@@ -0,0 +1,2 @@
1
+ import './deps'
2
+ import './css'
@@ -0,0 +1,18 @@
1
+ import { selectProps } from 'element-plus'
2
+ import type { ExtractPropTypes, PropType } from 'vue'
3
+
4
+ export const vroElSelectProps = {
5
+ ...selectProps,
6
+
7
+ options: Array as PropType<any[]>,
8
+ labelKey: {
9
+ type: String,
10
+ default: 'label',
11
+ },
12
+ valueKey: {
13
+ type: String,
14
+ default: 'value',
15
+ },
16
+ }
17
+
18
+ export type VroElSelectProps = ExtractPropTypes<typeof vroElSelectProps>
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <el-select
3
+ v-bind="restProps"
4
+ class="vro-el-select"
5
+ @update:model-value="$emit('update:modelValue', $event)"
6
+ @change="$emit('change', $event)"
7
+ >
8
+ <el-option
9
+ v-for="(option, index) in options"
10
+ v-bind="option.props"
11
+ :key="index"
12
+ :label="option[labelKey || 'label'] ?? option"
13
+ :value="option[valueKey || 'value'] ?? option"
14
+ />
15
+ </el-select>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ import { pick } from '@daysnap/utils'
20
+ import { ElOption, ElSelect, selectProps } from 'element-plus'
21
+ import { computed } from 'vue'
22
+
23
+ import { vroElSelectProps } from './types'
24
+
25
+ defineOptions({ name: 'VroElSelect' })
26
+
27
+ defineEmits(['update:modelValue', 'change'])
28
+ const props = defineProps(vroElSelectProps)
29
+
30
+ const restProps = computed(() => {
31
+ return pick(props, Object.keys(selectProps) as any[])
32
+ })
33
+ </script>
@@ -0,0 +1,128 @@
1
+ # VroElSkeleton
2
+
3
+ ### 介绍
4
+
5
+ 用于统一处理内容区域的加载、错误和空状态。`loading` 时显示 `VroLoading` 加载指示器,`error` 时显示错误结果,`empty` 时显示空状态,其余情况渲染默认内容。
6
+
7
+ ## 代码演示
8
+
9
+ ### 基础用法
10
+
11
+ ```html
12
+ <vro-el-skeleton :loading="loading" :error="error" :empty="empty" @refresh="refresh">
13
+ <div>内容</div>
14
+ </vro-el-skeleton>
15
+ ```
16
+
17
+ ### 自定义状态内容
18
+
19
+ ```html
20
+ <vro-el-skeleton :error="error">
21
+ <template #error="{ refresh }">
22
+ <el-result icon="warning" title="加载失败">
23
+ <template #extra>
24
+ <el-button type="primary" @click="refresh">重试</el-button>
25
+ </template>
26
+ </el-result>
27
+ </template>
28
+ </vro-el-skeleton>
29
+ ```
30
+
31
+ ### 加载样式
32
+
33
+ ```html
34
+ <vro-el-skeleton loading loading-type="spinner" :loading-size="40" loading-color="#409eff" />
35
+ ```
36
+
37
+ ### 国际化文案
38
+
39
+ 默认文案通过 `VroElConfigProvider` 的 `locale` 配置,也可以通过组件属性覆盖。
40
+
41
+ ```html
42
+ <vro-el-config-provider :locale="locale">
43
+ <vro-el-skeleton empty />
44
+ </vro-el-config-provider>
45
+ ```
46
+
47
+ ```ts
48
+ const locale = {
49
+ el: {
50
+ skeleton: {
51
+ emptyDescription: 'No data',
52
+ emptyBtnText: 'Reload',
53
+ errorTitle: 'Something went wrong',
54
+ errorBtnText: 'Retry',
55
+ loadingDescription: 'Loading...',
56
+ },
57
+ },
58
+ }
59
+ ```
60
+
61
+ ## API
62
+
63
+ ### 属性 Props
64
+
65
+ <table>
66
+ <tbody>
67
+ <tr>
68
+ <td>名称</td>
69
+ <td>类型</td>
70
+ <td>默认值</td>
71
+ </tr>
72
+ <tr v-for="(item, key) in vroElSkeletonProps" :key="key">
73
+ <td>{{ key }}</td>
74
+ <td>{{ parseType(item.type || item) }}</td>
75
+ <td>{{ reserve(item.default, '-') }}</td>
76
+ </tr>
77
+ </tbody>
78
+ </table>
79
+
80
+ ### 插槽 Slots
81
+
82
+ <table>
83
+ <tbody>
84
+ <tr>
85
+ <td>名称</td>
86
+ <td>说明</td>
87
+ </tr>
88
+ <tr>
89
+ <td>default</td>
90
+ <td>正常内容</td>
91
+ </tr>
92
+ <tr>
93
+ <td>loading</td>
94
+ <td>自定义加载状态内容</td>
95
+ </tr>
96
+ <tr>
97
+ <td>error</td>
98
+ <td>自定义错误状态内容,参数为 { error, refresh }</td>
99
+ </tr>
100
+ <tr>
101
+ <td>empty</td>
102
+ <td>自定义空状态内容,参数为 { refresh }</td>
103
+ </tr>
104
+ </tbody>
105
+ </table>
106
+
107
+ ### 事件 Events
108
+
109
+ <table>
110
+ <tbody>
111
+ <tr>
112
+ <td>名称</td>
113
+ <td>参数</td>
114
+ <td>说明</td>
115
+ </tr>
116
+ <tr>
117
+ <td>refresh</td>
118
+ <td>-</td>
119
+ <td>点击默认错误或空状态按钮时触发</td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
123
+
124
+ <script setup lang="ts">
125
+ import { reserve } from '@daysnap/utils'
126
+ import { VroElSkeleton, vroElSkeletonProps } from '.'
127
+ import { parseType } from '../utils'
128
+ </script>
@@ -0,0 +1,16 @@
1
+ import { withInstall } from '@vrojs/base'
2
+
3
+ import Component from './vro-el-skeleton.vue'
4
+
5
+ export * from './types'
6
+
7
+ export const VroElSkeleton = withInstall<typeof Component>(Component)
8
+ export default VroElSkeleton
9
+
10
+ export type VroElSkeletonInstance = InstanceType<typeof VroElSkeleton>
11
+
12
+ declare module 'vue' {
13
+ export interface GlobalComponents {
14
+ VroElSkeleton: typeof VroElSkeleton
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ import '../../style/base.scss'
2
+ import '@vrojs/base/src/vro-loading/style/css'
3
+ import './index.scss'
@@ -0,0 +1,3 @@
1
+ import 'element-plus/es/components/button/style/css'
2
+ import 'element-plus/es/components/empty/style/css'
3
+ import 'element-plus/es/components/result/style/css'
@@ -0,0 +1,24 @@
1
+ .vro-el-skeleton {
2
+ width: 100%;
3
+ }
4
+
5
+ .vro-el-skeleton__state {
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ width: 100%;
10
+ min-height: inherit;
11
+ }
12
+
13
+ .vro-el-skeleton__loading {
14
+ flex-direction: column;
15
+ color: var(--el-text-color-secondary);
16
+ }
17
+
18
+ .vro-el-skeleton__description {
19
+ margin: 16px 0 0;
20
+ color: var(--el-text-color-secondary);
21
+ font-size: var(--el-font-size-base);
22
+ line-height: 1.5;
23
+ text-align: center;
24
+ }
@@ -0,0 +1,2 @@
1
+ import './deps'
2
+ import './css'
@@ -0,0 +1,86 @@
1
+ import type { VroLoadingType } from '@vrojs/base'
2
+ import type { ExtractPropTypes, PropType } from 'vue'
3
+
4
+ export const vroElSkeletonProps = {
5
+ /**
6
+ * 是否显示加载状态。
7
+ */
8
+ loading: Boolean,
9
+
10
+ /**
11
+ * 加载图标类型。
12
+ */
13
+ loadingType: {
14
+ type: String as PropType<VroLoadingType>,
15
+ default: 'circular',
16
+ },
17
+
18
+ /**
19
+ * 加载图标尺寸,传入数字时单位为 px。
20
+ */
21
+ loadingSize: {
22
+ type: [String, Number] as PropType<string | number>,
23
+ default: 32,
24
+ },
25
+
26
+ /**
27
+ * 加载图标颜色。
28
+ */
29
+ loadingColor: {
30
+ type: String,
31
+ default: 'currentColor',
32
+ },
33
+
34
+ /**
35
+ * 加载状态描述文案,未传时使用 locale 中的 skeleton.loadingDescription。
36
+ */
37
+ loadingDescription: String,
38
+
39
+ /**
40
+ * 错误信息。传入后会显示错误状态。
41
+ */
42
+ error: [Object, String] as PropType<unknown>,
43
+
44
+ /**
45
+ * 错误状态标题,未传时使用 locale 中的 skeleton.errorTitle。
46
+ */
47
+ errorTitle: String,
48
+
49
+ /**
50
+ * 错误状态按钮文案,未传时使用 locale 中的 skeleton.errorBtnText。
51
+ */
52
+ errorBtnText: String,
53
+
54
+ /**
55
+ * 是否显示空状态。
56
+ */
57
+ empty: Boolean,
58
+
59
+ /**
60
+ * 空状态描述文案,未传时使用 locale 中的 skeleton.emptyDescription。
61
+ */
62
+ emptyDescription: String,
63
+
64
+ /**
65
+ * 是否展示空状态刷新按钮。
66
+ */
67
+ showEmptyBtn: {
68
+ type: Boolean,
69
+ default: true,
70
+ },
71
+
72
+ /**
73
+ * 空状态按钮文案,未传时使用 locale 中的 skeleton.emptyBtnText。
74
+ */
75
+ emptyBtnText: String,
76
+
77
+ /**
78
+ * 状态容器最小高度,传入数字时单位为 px。
79
+ */
80
+ minHeight: {
81
+ type: [String, Number] as PropType<string | number>,
82
+ default: '240px',
83
+ },
84
+ }
85
+
86
+ export type VroElSkeletonProps = ExtractPropTypes<typeof vroElSkeletonProps>
@@ -0,0 +1,73 @@
1
+ <template>
2
+ <div class="vro-el-skeleton" :style="rootStyle">
3
+ <template v-if="loading">
4
+ <slot name="loading">
5
+ <div class="vro-el-skeleton__state vro-el-skeleton__loading">
6
+ <vro-loading :type="loadingType" :size="loadingSize" :color="loadingColor" />
7
+ <p class="vro-el-skeleton__description">
8
+ {{ loadingDescription ?? t('skeleton.loadingDescription') }}
9
+ </p>
10
+ </div>
11
+ </slot>
12
+ </template>
13
+
14
+ <template v-else-if="error">
15
+ <slot name="error" :error="error" :refresh="handleRefresh">
16
+ <div class="vro-el-skeleton__state">
17
+ <el-result
18
+ icon="error"
19
+ :title="errorTitle ?? t('skeleton.errorTitle')"
20
+ :sub-title="formatMessage(error)"
21
+ >
22
+ <template #extra>
23
+ <el-button type="primary" @click="handleRefresh">
24
+ {{ errorBtnText ?? t('skeleton.errorBtnText') }}
25
+ </el-button>
26
+ </template>
27
+ </el-result>
28
+ </div>
29
+ </slot>
30
+ </template>
31
+
32
+ <template v-else-if="empty">
33
+ <slot name="empty" :refresh="handleRefresh">
34
+ <div class="vro-el-skeleton__state">
35
+ <el-empty :description="emptyDescription ?? t('skeleton.emptyDescription')">
36
+ <el-button v-if="showEmptyBtn" type="primary" @click="handleRefresh">
37
+ {{ emptyBtnText ?? t('skeleton.emptyBtnText') }}
38
+ </el-button>
39
+ </el-empty>
40
+ </div>
41
+ </slot>
42
+ </template>
43
+
44
+ <slot v-else></slot>
45
+ </div>
46
+ </template>
47
+
48
+ <script setup lang="ts">
49
+ import { formatMessage } from '@daysnap/utils'
50
+ import { VroLoading } from '@vrojs/base'
51
+ import { ElButton, ElEmpty, ElResult } from 'element-plus'
52
+ import { computed } from 'vue'
53
+
54
+ import { useLocale } from '../locale'
55
+ import { vroElSkeletonProps } from './types'
56
+
57
+ const emit = defineEmits<{
58
+ (event: 'refresh'): void
59
+ }>()
60
+
61
+ defineOptions({ name: 'VroElSkeleton' })
62
+
63
+ const props = defineProps(vroElSkeletonProps)
64
+ const { t } = useLocale()
65
+
66
+ const rootStyle = computed(() => ({
67
+ minHeight: typeof props.minHeight === 'number' ? `${props.minHeight}px` : props.minHeight,
68
+ }))
69
+
70
+ const handleRefresh = () => {
71
+ emit('refresh')
72
+ }
73
+ </script>