@wyfex/ivue 0.3.0 → 0.5.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.
@@ -8,32 +8,6 @@ import type { LogType } from '@/hooks/useLog'
8
8
  */
9
9
  export type Props = ExtractPropTypes<typeof componentProps>
10
10
 
11
- /**
12
- * injectProps接口
13
- */
14
- export interface InjectProps {
15
- /**
16
- * 语言
17
- */
18
- language?: string
19
- /**
20
- * 主题模式
21
- */
22
- themeMode?: string
23
- /**
24
- * 字典属性
25
- */
26
- dictProps?: DictProps
27
- /**
28
- * 上传配置
29
- */
30
- uploadConfig?: Record<string, any>
31
- /**
32
- * 扩展配置
33
- */
34
- extConfig?: { adaptive?: { extraHeight?: number } }
35
- }
36
-
37
11
  /**
38
12
  * 调试接口
39
13
  */
@@ -0,0 +1,86 @@
1
+ import type { PropType } from 'vue'
2
+ import type { RenderConfig } from '@/types'
3
+
4
+ /**
5
+ * 组件props
6
+ */
7
+ export default {
8
+ /**
9
+ * 双向绑定数据源
10
+ */
11
+ modelValue: {
12
+ type: [String, Number, Array],
13
+ default: ''
14
+ },
15
+ /**
16
+ * 是否使用渲染器 默认否
17
+ */
18
+ useRender: {
19
+ type: [Boolean, Object] as PropType<boolean | RenderConfig>,
20
+ default: false
21
+ },
22
+ /**
23
+ * 显示类型
24
+ */
25
+ type: {
26
+ type: String,
27
+ default: 'date',
28
+ validator: (val: string) =>
29
+ [
30
+ 'year',
31
+ 'years',
32
+ 'month',
33
+ 'months',
34
+ 'date',
35
+ 'dates',
36
+ 'datetime',
37
+ 'week',
38
+ 'datetimerange',
39
+ 'daterange',
40
+ 'monthrange',
41
+ 'yearrange'
42
+ ].includes(val)
43
+ },
44
+ /**
45
+ * 范围选择时开始日期的占位内容
46
+ */
47
+ startPlaceholder: {
48
+ type: String,
49
+ default: '开始日期'
50
+ },
51
+ /**
52
+ * 范围选择时结束日期的占位内容
53
+ */
54
+ endPlaceholder: {
55
+ type: String,
56
+ default: '结束日期'
57
+ },
58
+ /**
59
+ * 选择范围时的分隔符
60
+ */
61
+ rangeSeparator: {
62
+ type: String,
63
+ default: '至'
64
+ },
65
+ /**
66
+ * 显示在输入框中的格式
67
+ */
68
+ format: {
69
+ type: String,
70
+ default: undefined // 默认undefined 通过dateFormatComputed进行默认赋值
71
+ },
72
+ /**
73
+ * value-format
74
+ */
75
+ valueFormat: {
76
+ type: String,
77
+ default: undefined // 默认undefined 通过dateFormatComputed进行默认赋值
78
+ },
79
+ /**
80
+ * placeholder 默认请选择
81
+ */
82
+ placeholder: {
83
+ type: String,
84
+ default: '请选择'
85
+ }
86
+ }
@@ -0,0 +1,15 @@
1
+ import type { ExtractPropTypes } from 'vue'
2
+ import componentProps from './props'
3
+
4
+ /**
5
+ * props类型
6
+ */
7
+ export type Props = ExtractPropTypes<typeof componentProps>
8
+
9
+ /**
10
+ * emits接口
11
+ */
12
+ export interface Emits {
13
+ // 更新value值
14
+ (e: 'update:modelValue', value: string | number | any[]): void
15
+ }
@@ -0,0 +1,87 @@
1
+ import type { PropType } from 'vue'
2
+ import type { ConfigColumn } from './types'
3
+ import type { DictMap, DictProps } from '@/types'
4
+ import type { RenderConfig } from '@/types'
5
+
6
+ /**
7
+ * 组件props
8
+ */
9
+ export default {
10
+ /**
11
+ * 配置项 必传
12
+ */
13
+ configs: {
14
+ type: Array as PropType<ConfigColumn[]>,
15
+ required: true
16
+ },
17
+ /**
18
+ * 表单模型 必传
19
+ */
20
+ formModel: {
21
+ type: Object as PropType<Record<string, any>>,
22
+ required: true
23
+ },
24
+ /**
25
+ * 是否使用渲染器 默认否
26
+ */
27
+ useRender: {
28
+ type: [Boolean, Object] as PropType<boolean | RenderConfig>,
29
+ default: false
30
+ },
31
+ /**
32
+ * 字典映射 数据结构为{ configs[][label | useDict | useDict.data]: Array<{ label: string, value: any }> }
33
+ */
34
+ dictMap: {
35
+ type: Object as PropType<DictMap>,
36
+ default: () => ({})
37
+ },
38
+ /**
39
+ * 字典属性 默认为{ value: 'value', label: 'label', children: 'children' },可通过全局配置进行设置,为适配全局配置此处不再设置默认值
40
+ */
41
+ dictProps: {
42
+ type: Object as PropType<DictProps>,
43
+ default: () => ({})
44
+ },
45
+ /**
46
+ * 一行 Descriptions Item 的数量 默认2
47
+ */
48
+ column: {
49
+ type: Number,
50
+ default: 2
51
+ },
52
+ /**
53
+ * 是否带有边框 默认是
54
+ */
55
+ border: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ /**
60
+ * 每一列的标签宽度
61
+ */
62
+ labelWidth: {
63
+ type: [String, Number],
64
+ default: '25%'
65
+ },
66
+ /**
67
+ * 是否让标题居中并且header具有背景色 默认否
68
+ */
69
+ useTitleCenterWithBg: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ /**
74
+ * 标签包裹类名
75
+ */
76
+ labelClass: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ /**
81
+ * 默认内容包裹类名
82
+ */
83
+ defaultClass: {
84
+ type: String,
85
+ default: ''
86
+ }
87
+ }
@@ -0,0 +1,38 @@
1
+ import type { Component, ExtractPropTypes } from 'vue'
2
+ import type { EditAttrs, RenderConfig, UseDict } from '@/types'
3
+ import componentProps from './props'
4
+
5
+ /**
6
+ * props类型
7
+ */
8
+ export type Props = ExtractPropTypes<typeof componentProps>
9
+
10
+ /**
11
+ * emits接口
12
+ */
13
+ export interface Emits {
14
+ // dictKeys事件
15
+ (e: 'onDictKeys', value?: string[]): void
16
+ }
17
+
18
+ /**
19
+ * 组件配置接口
20
+ */
21
+ export interface ComponentConfig {
22
+ is: Component
23
+ attrs?: EditAttrs
24
+ }
25
+
26
+ /**
27
+ * 配置列接口
28
+ */
29
+ export interface ConfigColumn {
30
+ label: string
31
+ prop: string
32
+ span?: number
33
+ useDict?: boolean | string | UseDict
34
+ defaultClass?: string
35
+ slot?: boolean | string
36
+ componentConfig?: ComponentConfig
37
+ renderConfig?: RenderConfig
38
+ }
@@ -1,10 +1,73 @@
1
1
  import type { Component, VNode } from 'vue'
2
2
 
3
+ // ==================================== 渲染器相关接口 start ====================================
3
4
  /**
4
5
  * 渲染器内容类型
5
6
  */
6
7
  export type RenderContent = string | number | boolean | VNode | Component
7
8
 
9
+ /**
10
+ * 渲染器配置接口
11
+ */
12
+ export interface RenderConfig {
13
+ // 内容
14
+ content?: RenderContent
15
+ // 样式类名
16
+ class?: string
17
+ // 内联样式
18
+ style?: string
19
+ // 内联样式字段
20
+ styleField?: string
21
+ // 单位
22
+ unit?: string
23
+ }
24
+ // ==================================== 渲染器相关接口 end ====================================
25
+
26
+ // ==================================== 字典相关接口 start ====================================
27
+ /**
28
+ * 字典属性接口 共用于其它props配置属性
29
+ */
30
+ export interface DictProps {
31
+ // 指定选项label为选项对象的某个属性值
32
+ label: string
33
+ // 指定选项value为选项对象的某个属性值
34
+ value: string
35
+ // 指定选项children为选项对象的某个属性值
36
+ children: string
37
+ }
38
+
39
+ /**
40
+ * 字典映射接口
41
+ */
42
+ export interface DictMap {
43
+ // 形如:{ 性别: [{ label: '男', value: 1 },{ label: '女', value: 2 }] }
44
+ [key: string]: Array<{ label: string; value: string | number | boolean }>
45
+ }
46
+
47
+ /**
48
+ * 使用字典接口
49
+ */
50
+ export interface UseDict {
51
+ // 字典数据 可为字符串、对象、字符串数组、数字数组、对象数组,如为string则为dictMap的key
52
+ data?:
53
+ | string
54
+ | Record<string, any>
55
+ | string[]
56
+ | number[]
57
+ | Record<string, any>[]
58
+ // 字典属性
59
+ props?: DictProps
60
+ // 字典类名
61
+ class?: string
62
+ // 内联样式
63
+ inlineStyle?: string
64
+ // 字典样式字段
65
+ styleField?: string
66
+ // 字典分割符 默认为逗号(,)
67
+ separator?: string
68
+ }
69
+ // ==================================== 字典相关接口 start ====================================
70
+
8
71
  /**
9
72
  * 上传配置接口
10
73
  */
@@ -37,16 +100,34 @@ export interface GlobalConfig {
37
100
  finalUploadConfig: UploadConfig
38
101
  }
39
102
 
40
- // ==================================== 字典相关接口 ====================================
103
+ /**
104
+ * input事件名称类型
105
+ */
106
+ export type InputEventName = 'nonNegativeDecimal'
41
107
 
42
108
  /**
43
- * 字典属性接口 共用于其它props配置属性
109
+ * input事件接口
44
110
  */
45
- export interface DictProps {
46
- // 指定选项label为选项对象的某个属性值
47
- label: string
48
- // 指定选项value为选项对象的某个属性值
49
- value: string
50
- // 指定选项children为选项对象的某个属性值
51
- children: string
111
+ export interface InputEvent {
112
+ name: InputEventName
113
+ digits?: number
114
+ cb?: Function
115
+ }
116
+
117
+ /**
118
+ * 编辑配置属性接口
119
+ */
120
+ export interface EditAttrs {
121
+ // 是否追加label到placeholder后面 默认是,不需要可显式设置appendLabelToPlaceholder为false
122
+ appendLabelToPlaceholder?: boolean
123
+ // UseElSelect等组件的options
124
+ options?: Record<string, any>[]
125
+ // UseElSelect等组件的props
126
+ props?: DictProps
127
+ // change事件
128
+ changeEvent?: Function
129
+ // focus事件
130
+ focusEvent?: Function
131
+ // input事件
132
+ inputEvent?: Function | InputEventName | InputEvent
52
133
  }
@@ -1,9 +0,0 @@
1
- import { InjectProps, Props } from './types';
2
- export declare const useProvideGlobalConfig: (props: Props) => void;
3
- export declare const useInjectGlobalConfig: (injectProps: InjectProps) => {
4
- finalLanguage: string;
5
- finalThemeMode: string;
6
- finalDictProps: import('../../../types').DictProps;
7
- finalTableExtraHeight: number;
8
- finalUploadConfig: Record<string, any>;
9
- };