xrk-components 0.3.3 → 0.3.4

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.
@@ -1,5 +1,8 @@
1
1
  import { Component, DefineComponent } from 'vue';
2
2
  export declare type BaseButtonProps = {
3
+ /**
4
+ * 自定义方法 , 用于事件同步执行,使用这个的时候,可以不用使用 @click onClick
5
+ */
3
6
  click?: (...preload: Array<any>) => Promise<any> | void | any;
4
7
  loading?: boolean;
5
8
  loadingIcon?: string | Component;
@@ -20,7 +20,13 @@ export declare type BaseDatePickerProps = {
20
20
  prefixIcon?: string | Component;
21
21
  clearIcon?: string | Component;
22
22
  validateEvent?: boolean;
23
+ /**
24
+ * 一个用来判断该日期是否被禁用的函数,接受一个 Date 对象作为参数。 应该返回一个 Boolean 值。
25
+ */
23
26
  disabledDate?: (date: Date, startDt: Date | null) => boolean;
27
+ /**
28
+ * 设置快捷选项,需要传入数组对象
29
+ */
24
30
  shortcuts?: Array<{
25
31
  text: string;
26
32
  value: Date | (() => void);
@@ -32,7 +32,13 @@ export interface BaseInputProps {
32
32
  tabindex?: string | number;
33
33
  validateEvent?: boolean;
34
34
  inputStyle?: CSSProperties;
35
+ /**
36
+ * 输入时处理输入值
37
+ */
35
38
  inputRewrite?: (value: string | number) => string | Promise<string>;
39
+ /**
40
+ * 发生改变时处理输入值
41
+ */
36
42
  changeRewrite?: (value: string | number) => string | Promise<string>;
37
43
  onBlur?: (events: Event) => void;
38
44
  onFocus?: (events: Event) => void;
@@ -13,6 +13,9 @@ export declare type BaseRadioGroupProps = {
13
13
  textColor?: string;
14
14
  fill?: string;
15
15
  disabled?: boolean;
16
+ /**
17
+ * 选中前,执行done可以完成选中状态
18
+ */
16
19
  checkBefore?: (activeValue: any, done: Function) => void;
17
20
  onChange?: (activeValue: any) => void;
18
21
  };
@@ -23,6 +26,9 @@ export declare type BaseRadioProps = {
23
26
  label?: string | number | boolean;
24
27
  disabled?: boolean;
25
28
  border?: boolean;
29
+ /**
30
+ * 选中前,执行done可以完成选中状态
31
+ */
26
32
  checkBefore?: (activeValue: any, done: Function) => void;
27
33
  onChange?: (activeValue: any) => void;
28
34
  };
@@ -7,32 +7,92 @@ export declare type SelectOptionType = {
7
7
  };
8
8
  export declare type SelectValueType = string | number | boolean | SelectOptionType | null | undefined;
9
9
  export interface BaseSelectProps {
10
+ /**
11
+ * 初始化组件时 执行 remoteMethod 方法
12
+ */
10
13
  init?: boolean;
14
+ /**
15
+ * 使用远程搜索
16
+ */
11
17
  filterUseRemote?: boolean;
18
+ /**
19
+ * 下拉选项
20
+ */
12
21
  options?: Array<SelectOptionType>;
22
+ /**
23
+ * 是否分组
24
+ */
13
25
  group?: boolean;
14
26
  labelKey?: string;
15
27
  valueKey?: string;
16
28
  optionsKey?: string;
29
+ /**
30
+ * 选中项绑定值
31
+ */
17
32
  modelValue?: SelectValueType | Array<string | number | boolean | SelectOptionType | null | undefined>;
33
+ /**
34
+ * 是否多选
35
+ */
18
36
  multiple?: boolean;
37
+ /**
38
+ * 是否禁用
39
+ */
19
40
  disabled?: boolean;
41
+ /**
42
+ * 输入框尺寸
43
+ */
20
44
  size?: 'large' | 'default' | 'small';
45
+ /**
46
+ * 是否可以清空选项
47
+ */
21
48
  clearable?: boolean;
49
+ /**
50
+ * 多选时是否将选中值按文字的形式展示
51
+ */
22
52
  collapseTags?: boolean;
53
+ /**
54
+ * 当鼠标悬停于折叠标签的文本时,是否显示所有选中的标签。 要使用此属性,collapse-tags属性必须设定为 true
55
+ */
23
56
  collapseTagsTooltip?: boolean;
57
+ /**
58
+ * multiple 属性设置为 true 时,代表多选场景下用户最多可以选择的项目数, 为 0 则不限制
59
+ */
24
60
  multipleLimit?: number;
61
+ /**
62
+ * 占位文字
63
+ */
25
64
  placeholder?: string;
65
+ /**
66
+ * Select 组件是否可筛选
67
+ */
26
68
  filterable?: boolean;
69
+ /**
70
+ * 是否允许用户创建新条目, 只有当 filterable 设置为 true 时才会生效。
71
+ */
27
72
  allowCreate?: boolean;
73
+ /**
74
+ * 下拉框的宽度是否与输入框相同
75
+ */
28
76
  fitInputWidth?: boolean;
29
77
  /**
30
78
  * 自定义筛选方法
31
79
  */
32
80
  filterMethod?: (searchVal: string) => Array<SelectValueType>;
81
+ /**
82
+ * 远程方法
83
+ */
33
84
  remoteMethod?: (searchVal?: string) => any;
85
+ /**
86
+ * 从服务器加载内容时显示的文本
87
+ */
34
88
  loadingText?: string;
89
+ /**
90
+ * 搜索条件无匹配时显示的文字,也可以使用 empty 插槽设置
91
+ */
35
92
  noMatchText?: string;
93
+ /**
94
+ * 无选项时显示的文字,也可以使用 empty 插槽设置自定义内容
95
+ */
36
96
  noDataText?: string;
37
97
  onChange?: (value: SelectValueType, SelectOption: Array<SelectOptionType>) => void;
38
98
  onRemoveTag?: (value: SelectValueType) => void;
@@ -73,29 +73,59 @@ export declare type BaseTableColumnProps = {
73
73
  headerAlign?: 'left' | 'right' | 'center';
74
74
  className?: string;
75
75
  labelClassName?: string;
76
+ /**
77
+ * 最多显示多少行,超出时省略号,默认 1 ; 如果使用了render配置,则失效
78
+ */
76
79
  textLineClamp?: number;
80
+ /**
81
+ * 自定义列头
82
+ */
77
83
  renderHeader?: (info: {
78
84
  column: TableColumnCtx<any>;
79
85
  index: number;
86
+ /**
87
+ * 全选属性,当列的type = "_selection"时有效
88
+ */
80
89
  selectionInfo?: {
90
+ /**
91
+ * 全选/取消全选
92
+ */
81
93
  toggleCheckAll?: () => void;
94
+ /**
95
+ * 是否全部选中
96
+ */
82
97
  checkboxAllChecked: ComputedRef<boolean>;
98
+ /**
99
+ * 是否部分选中
100
+ */
83
101
  checkboxAllIndeterminate: ComputedRef<boolean>;
102
+ /**
103
+ * 是否选择中
104
+ */
84
105
  selectionAllLoading: Ref<boolean>;
85
106
  };
86
107
  }) => JSX.Element;
108
+ /**
109
+ * 格式化数据
110
+ */
87
111
  formatter?: (info: {
88
112
  row: Record<string, any>;
89
113
  cellValue: any;
90
114
  column: TableColumnCtx<any>;
91
115
  index: number;
92
116
  }) => any;
117
+ /**
118
+ * 自定义cell内容
119
+ */
93
120
  render?: (info: {
94
121
  row: Record<string, any>;
95
122
  cellValue: any;
96
123
  column: TableColumnCtx<any>;
97
124
  index: number;
98
125
  }) => JSX.Element;
126
+ /**
127
+ * 禁用每列的selection
128
+ */
99
129
  selectionDisabled?: ((row: any) => boolean) | boolean;
100
130
  selectionRows?: Map<number | string, any>;
101
131
  hasSelectionRow?: (rowId: any) => boolean;
@@ -103,9 +133,24 @@ export declare type BaseTableColumnProps = {
103
133
  removeSelectionRow?: (rowId: any) => void;
104
134
  getSelectionRows?: () => Array<any>;
105
135
  clearSelectionRows?: () => void;
136
+ /**
137
+ * 点击表头全选框 ,选中前
138
+ */
106
139
  selectionAllBefore?: (done: Function) => Promise<void> | void;
140
+ /**
141
+ * 点击多选框 ,选中前
142
+ */
107
143
  selectionAddBefore?: (row: any, done: Function) => Promise<void> | void;
144
+ /**
145
+ * 点击多选框 ,选中后
146
+ */
108
147
  selectionAddAfter?: (row: any) => Promise<void> | void;
148
+ /**
149
+ * 点击多选框 ,移除前
150
+ */
109
151
  selectionRemoveBefore?: (row: any, done: Function) => Promise<void> | void;
152
+ /**
153
+ * 点击多选框 ,移除后
154
+ */
110
155
  selectionRemoveAfter?: (row: any) => Promise<void> | void;
111
156
  };
@@ -9,6 +9,10 @@ export declare type BaseToolTipProps = {
9
9
  placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
10
10
  content?: string | number;
11
11
  style?: StyleValue | undefined;
12
+ /**
13
+ * trigger = hover 时有效
14
+ * 内容超出才显示toolTip , 默认内容不超出也会触发展示
15
+ */
12
16
  overShow?: boolean;
13
17
  };
14
18
  export declare const BaseToolTip: DefineComponent<BaseToolTipProps, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<BaseToolTipProps>, {}>;
@@ -6,4 +6,22 @@ export declare type XrkSearchProps = {
6
6
  resetBtn?: ResetBtnType;
7
7
  otherComponents?: Array<ComponentRender>;
8
8
  };
9
+ export declare type XrkSearchRef = {
10
+ /**
11
+ * 设置指定搜索项
12
+ */
13
+ setSearchValue: (key: string | number, value: any) => void;
14
+ /**
15
+ * 获取搜索组件所有搜索项
16
+ */
17
+ getSearchValue: () => Record<string, any>;
18
+ /**
19
+ * 执行等同于点击搜索按钮
20
+ */
21
+ handleSearchClick: () => void | Promise<void>;
22
+ /**
23
+ * 执行等同于点击重置按钮
24
+ */
25
+ handleResetClick: () => void | Promise<void>;
26
+ };
9
27
  export declare const XrkSearch: DefineComponent<XrkSearchProps, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<XrkSearchProps>, {}>;
@@ -5,9 +5,18 @@ import { BaseSelectProps, SelectOptionType, SelectValueType } from '../../../bas
5
5
  import { FormItemRule } from 'element-plus';
6
6
  declare type AnyObject = Record<string, any>;
7
7
  export declare type BaseSelectListener = {
8
+ /**
9
+ * 下拉选值
10
+ */
8
11
  onChange?: (value: SelectValueType, selectOptions: Array<SelectOptionType>, searchValue: AnyObject) => void;
9
12
  onRemoveTag?: (value: SelectValueType, searchValue: AnyObject) => void;
13
+ /**
14
+ * 下拉框显示/隐藏时
15
+ */
10
16
  onVisibleChange?: (visibleStatus: boolean, searchValue: AnyObject) => void;
17
+ /**
18
+ * 清除时候
19
+ */
11
20
  onClear?: (searchValue: AnyObject) => void;
12
21
  };
13
22
  export declare type BaseInputListener = {
@@ -19,8 +28,17 @@ export declare type BaseInputListener = {
19
28
  onClear?: (searchValue: AnyObject) => void;
20
29
  };
21
30
  export declare type BaseDatePickerListener = {
31
+ /**
32
+ * 选择时间
33
+ */
22
34
  onChange?: (value: any, searchValue: AnyObject) => void;
35
+ /**
36
+ * 下拉框显示/隐藏时
37
+ */
23
38
  onVisibleChange?: (visibleStatus: boolean, searchValue: AnyObject) => void;
39
+ /**
40
+ * 范围选择,选择了第一个时间
41
+ */
24
42
  onCalendarChange?: (val: [Date, Date | null], searchValue: AnyObject) => void;
25
43
  };
26
44
  export interface ComponentsType {
@@ -29,27 +47,50 @@ export interface ComponentsType {
29
47
  datePicker: Component;
30
48
  }
31
49
  export declare type SerachColumnBaseType<T, S> = {
50
+ prop: string;
32
51
  type?: keyof ComponentsType;
33
52
  label?: string;
34
53
  style?: CSSProperties;
35
54
  defaultValue?: any;
36
- prop: string;
37
55
  rules?: FormItemRule | Array<FormItemRule>;
56
+ /**
57
+ * 是否禁用
58
+ */
38
59
  disabled?: boolean | ((searchValue: AnyObject) => Promise<boolean> | boolean);
39
60
  config?: T;
40
61
  listener?: S;
41
62
  };
42
63
  export declare type SerachColumnType = SerachColumnBaseType<BaseInputProps | BaseSelectProps | BaseDatePickerProps, BaseInputListener | BaseSelectListener | BaseDatePickerListener>;
64
+ /**
65
+ * 搜索按钮配置
66
+ * 点击时,执行顺序 beforeSearch -> emit.search -> afterSearch
67
+ */
43
68
  export declare type SearchBtnType = {
44
69
  text?: string;
45
70
  show?: boolean;
71
+ /**
72
+ * 搜索前
73
+ */
46
74
  beforeSearch?: (searchValue: AnyObject) => AnyObject | Promise<AnyObject>;
75
+ /**
76
+ * 搜索后
77
+ */
47
78
  afterSearch?: (searchValue: AnyObject) => void | AnyObject | Promise<AnyObject>;
48
79
  };
80
+ /**
81
+ * 重置按钮配置
82
+ * 点击时,执行顺序 清空组件内的值 -> beforeReset -> emit.search -> afterReset
83
+ */
49
84
  export declare type ResetBtnType = {
50
85
  text?: string;
51
86
  show?: boolean;
87
+ /**
88
+ * 重置前
89
+ */
52
90
  beforeReset?: (searchValue: AnyObject) => AnyObject | Promise<AnyObject>;
91
+ /**
92
+ * 重置后
93
+ */
53
94
  afterReset?: (searchValue: AnyObject) => void | AnyObject | Promise<AnyObject>;
54
95
  };
55
96
  export interface ComponentRender {
@@ -1,3 +1,37 @@
1
1
  import { DefineComponent } from 'vue';
2
2
  import { XrkTableProps } from './types/type';
3
+ export declare type XrkTableRef = {
4
+ /**
5
+ * 获取当前表格选择的所有数据
6
+ */
7
+ getSelectionRows: () => any[];
8
+ /**
9
+ * 当前表格增加选中项
10
+ */
11
+ addSelectionRow: (rowId: string | number, row: any) => void;
12
+ /**
13
+ * 移除当前表格指定选中项
14
+ */
15
+ removeSelectionRow: (rowId: string | number) => void;
16
+ /**
17
+ * 移除当前表格所有选中项
18
+ */
19
+ clearSelectionRows: () => void;
20
+ /**
21
+ * 设置指定搜索项
22
+ */
23
+ setSearchValue: (key: string | number, value: any) => void;
24
+ /**
25
+ * 获取搜索组件所有搜索项
26
+ */
27
+ getSearchValue: () => Record<string, any>;
28
+ /**
29
+ * 刷新当前页,可传入自定义参数(只会作用与这次列表获取,相同变量会被search组件设置的值覆盖)
30
+ */
31
+ initCurrentList: (customQuery?: Record<string, any>) => void;
32
+ /**
33
+ * 回到第一页,并刷新列表,可传入自定义参数(只会作用与这次列表获取,相同变量会被search组件设置的值覆盖)
34
+ */
35
+ initList: (customQuery?: Record<string, any>) => void;
36
+ };
3
37
  export declare const XrkTable: DefineComponent<XrkTableProps, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<XrkTableProps>, {}>;
@@ -1,21 +1,65 @@
1
1
  import { BaseTableColumnProps } from '../../../base/table/types/type';
2
2
  import { ComponentRender, ResetBtnType, SearchBtnType, SerachColumnType } from '../../search/types/type';
3
3
  export declare type XrkTableProps = {
4
+ /**
5
+ * 是否立即执行getListAjax,默认是 (执行时机:onMounted)
6
+ */
4
7
  requestNow?: boolean;
5
- getListAjax: (...args: any) => Promise<any> | any;
8
+ /**
9
+ * 获取表格数据
10
+ */
11
+ getListAjax: (query?: Record<string, any>) => Promise<any> | any;
12
+ /**
13
+ * 搜索项配置
14
+ */
6
15
  searchConfig: {
16
+ /**
17
+ * 搜索项
18
+ */
7
19
  searchColumns: Array<SerachColumnType>;
20
+ /**
21
+ * 搜索按钮配置
22
+ * 点击时,执行顺序 beforeSearch -> emit.search -> afterSearch
23
+ */
8
24
  searchBtn?: SearchBtnType;
25
+ /**
26
+ * 重置按钮配置
27
+ * 点击时,执行顺序 清空组件内的值 -> beforeReset -> emit.search -> afterReset
28
+ */
9
29
  resetBtn?: ResetBtnType;
30
+ /**
31
+ * 其他组件
32
+ */
10
33
  othertComponents?: Array<ComponentRender>;
11
34
  };
35
+ /**
36
+ * 表格配置
37
+ */
12
38
  tableConfig: {
39
+ /**
40
+ * 表格列 Array<BaseTableColumnProps>
41
+ */
13
42
  tableColumns: Array<BaseTableColumnProps>;
14
43
  };
44
+ /**
45
+ * 分页器配置
46
+ */
15
47
  paginationConfig?: {
48
+ /**
49
+ * 当前页key,默认pageNo
50
+ */
16
51
  pageNoKey?: string;
52
+ /**
53
+ * 每页数量key,默认pageSize
54
+ */
17
55
  pageSizeKey?: string;
56
+ /**
57
+ * 每页条数,默认60 , 范围[15,60,100]
58
+ */
18
59
  paginationPageSize?: number;
60
+ /**
61
+ * 当前页码,默认1
62
+ */
19
63
  paginationCurrentPage?: number;
20
64
  };
21
65
  };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "xrk-components",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "",
5
5
  "main": "lib/index.esm.js",
6
6
  "typings": "lib/packages/index.d.ts",
7
7
  "scripts": {
8
+ "dev": "webpack-dev-server --hot --progress --config webpack.conf.js",
8
9
  "build:esm-bundle": "rollup --config rollup.config.js"
9
10
  },
10
11
  "keywords": [],
@@ -14,12 +15,15 @@
14
15
  "@babel/core": "^7.18.6",
15
16
  "@rollup/plugin-babel": "^5.3.1",
16
17
  "@rollup/plugin-commonjs": "^22.0.1",
18
+ "@rollup/plugin-json": "^4.1.0",
17
19
  "@rollup/plugin-node-resolve": "^13.3.0",
18
20
  "@vue/babel-plugin-jsx": "^1.1.1",
19
21
  "@vue/cli-plugin-babel": "^5.0.7",
20
22
  "@vue/compiler-sfc": "^3.2.37",
21
23
  "acorn-jsx": "^5.3.2",
22
24
  "autoprefixer": "^10.4.7",
25
+ "css-loader": "^6.7.1",
26
+ "html-webpack-plugin": "^5.5.0",
23
27
  "rollup": "^2.75.7",
24
28
  "rollup-plugin-babel": "^4.4.0",
25
29
  "rollup-plugin-clear": "^2.0.7",
@@ -28,8 +32,13 @@
28
32
  "rollup-plugin-vue": "^6.0.0",
29
33
  "sass": "^1.53.0",
30
34
  "sass-loader": "^13.0.2",
35
+ "style-loader": "^3.3.1",
36
+ "ts-loader": "^9.3.1",
31
37
  "typescript": "^4.7.4",
32
- "vue-loader": "^17.0.0"
38
+ "vue-loader": "^17.0.0",
39
+ "webpack": "^5.73.0",
40
+ "webpack-cli": "^4.10.0",
41
+ "webpack-dev-server": "^4.9.3"
33
42
  },
34
43
  "dependencies": {
35
44
  "element-plus": "^2.2.8",
package/tsconfig.json CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  "jsx": "preserve",
12
12
  "moduleResolution": "node",
13
+ "resolveJsonModule": true,
13
14
  "declaration": true,
14
15
  "suppressImplicitAnyIndexErrors": true,
15
16
  "skipLibCheck": true
@@ -18,6 +19,9 @@
18
19
  "packages/**/*.ts",
19
20
  "packages/**/*.tsx",
20
21
  "packages/**/*.vue",
22
+ "example/**/*.ts",
23
+ "example/**/*.tsx",
24
+ "example/**/*.vue",
21
25
  "typings/**/*.ts"
22
26
  ],
23
27
  "exclude": ["node_modules", "@type/**/*.d.ts"]