xrk-components 0.3.0 → 0.3.3

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 (62) hide show
  1. package/lib/index.css +7 -2
  2. package/lib/index.esm.js +107 -46
  3. package/lib/index.umd.js +107 -46
  4. package/lib/packages/base/button/index.d.ts +1 -1
  5. package/lib/packages/base/dialog/dialog.d.ts +11 -0
  6. package/lib/packages/base/dialog/index.d.ts +4 -3
  7. package/lib/packages/base/select/index.d.ts +4 -1
  8. package/lib/packages/xrk/table/table.d.ts +0 -13
  9. package/lib/packages/xrk/table/types/type.d.ts +2 -2
  10. package/package.json +1 -1
  11. package/packages/base/button/button.vue +0 -83
  12. package/packages/base/button/index.ts +0 -26
  13. package/packages/base/checkbox/checkbox-button.vue +0 -54
  14. package/packages/base/checkbox/checkbox-group.vue +0 -85
  15. package/packages/base/checkbox/checkbox.vue +0 -85
  16. package/packages/base/checkbox/index.ts +0 -62
  17. package/packages/base/date-picker/date-picker.vue +0 -144
  18. package/packages/base/date-picker/index.ts +0 -52
  19. package/packages/base/dialog/dialog.vue +0 -214
  20. package/packages/base/dialog/index.ts +0 -57
  21. package/packages/base/form/form-item.vue +0 -57
  22. package/packages/base/form/form.vue +0 -70
  23. package/packages/base/form/index.ts +0 -39
  24. package/packages/base/input/index.ts +0 -50
  25. package/packages/base/input/input.vue +0 -175
  26. package/packages/base/pagination/index.ts +0 -30
  27. package/packages/base/pagination/pagination.vue +0 -160
  28. package/packages/base/radio/index.ts +0 -49
  29. package/packages/base/radio/radio-button.vue +0 -46
  30. package/packages/base/radio/radio-group.vue +0 -77
  31. package/packages/base/radio/radio.vue +0 -74
  32. package/packages/base/select/index.ts +0 -62
  33. package/packages/base/select/select.vue +0 -258
  34. package/packages/base/switch/index.ts +0 -26
  35. package/packages/base/switch/switch.vue +0 -103
  36. package/packages/base/table/hooks/use-table.ts +0 -15
  37. package/packages/base/table/index.ts +0 -16
  38. package/packages/base/table/store/index.ts +0 -35
  39. package/packages/base/table/table-column.vue +0 -351
  40. package/packages/base/table/table.vue +0 -168
  41. package/packages/base/table/types/type.ts +0 -123
  42. package/packages/base/tag/index.ts +0 -52
  43. package/packages/base/tag/tag-group.vue +0 -182
  44. package/packages/base/tag/tag.vue +0 -54
  45. package/packages/base/tool-tip/index.ts +0 -30
  46. package/packages/base/tool-tip/tool-tip.vue +0 -108
  47. package/packages/components.ts +0 -33
  48. package/packages/functions.ts +0 -16
  49. package/packages/index.ts +0 -30
  50. package/packages/types.ts +0 -54
  51. package/packages/xrk/search/hooks/use-search.ts +0 -96
  52. package/packages/xrk/search/index.ts +0 -22
  53. package/packages/xrk/search/search.vue +0 -197
  54. package/packages/xrk/search/types/type.ts +0 -95
  55. package/packages/xrk/table/hooks/use-table.tsx +0 -34
  56. package/packages/xrk/table/index.ts +0 -10
  57. package/packages/xrk/table/table.vue +0 -218
  58. package/packages/xrk/table/types/type.ts +0 -31
  59. package/rollup.config.js +0 -59
  60. package/styles/element/index.scss +0 -5
  61. package/styles/element/mixin.scss +0 -40
  62. package/tools/check.ts +0 -9
@@ -1,258 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-21 11:16:27
4
- -->
5
- <template>
6
- <el-select
7
- v-model="selectValue"
8
- :placeholder="placeholder"
9
- :multiple="multiple"
10
- :disabled="disabled"
11
- :size="size"
12
- :clearable="clearable"
13
- :collapseTags="collapseTags"
14
- :collapseTagsTooltip="collapseTagsTooltip"
15
- :multipleLimit="multipleLimit"
16
- :filterable="_filterable"
17
- :allowCreate="allowCreate"
18
- :filterMethod="_filterMethod"
19
- :loading="loading"
20
- :remoteMethod="remoteMethod"
21
- :loadingText="loadingText"
22
- :noMatchText="noMatchText"
23
- :noDataText="noDataText"
24
- :fitInputWidth="fitInputWidth"
25
- @change="handleChange"
26
- @visible-change="handleVisibleChange"
27
- @remove-tag="handleRemoveTag"
28
- @clear="handleClear"
29
- >
30
- <template v-if="group">
31
- <el-option-group
32
- v-for="group in _options"
33
- :key="_Reflect.get(group, labelKey)"
34
- :label="_Reflect.get(group, labelKey)"
35
- >
36
- <el-option
37
- class="option"
38
- v-for="item in _Reflect.get(group, optionsKey) || []"
39
- :key="item[valueKey]"
40
- :label="item[labelKey]"
41
- :value="item[valueKey]"
42
- >
43
- <base-tool-tip
44
- :content="item[labelKey]"
45
- :hideAfter="0"
46
- :enterable="false"
47
- transition="none"
48
- :disabled="toolTipDisabled"
49
- :overShow="true"
50
- >
51
- <span>{{ item[labelKey] }}</span>
52
- </base-tool-tip>
53
- </el-option>
54
- </el-option-group>
55
- </template>
56
- <template v-else>
57
- <el-option
58
- class="option"
59
- v-for="item in _options"
60
- :key="_Reflect.get(item, labelKey)"
61
- :label="_Reflect.get(item, labelKey)"
62
- :value="_Reflect.get(item, valueKey)"
63
- >
64
- <base-tool-tip
65
- :content="_Reflect.get(item, labelKey)"
66
- :hideAfter="0"
67
- :enterable="false"
68
- transition="none"
69
- :disabled="toolTipDisabled"
70
- :overShow="true"
71
- >
72
- {{ _Reflect.get(item, labelKey) }}
73
- </base-tool-tip>
74
- </el-option>
75
- </template>
76
- </el-select>
77
- </template>
78
-
79
- <script lang="tsx">
80
- export default {
81
- name: 'base-select'
82
- };
83
- </script>
84
-
85
- <script lang="tsx" setup>
86
- import { ElSelect, ElOption, ElOptionGroup } from 'element-plus';
87
- import { BaseToolTip } from '../tool-tip';
88
- import { ref, watch, computed, withDefaults, Ref } from 'vue';
89
- import { base } from 'xrk-tools';
90
- import { isFunction } from '../../../tools/check';
91
- import { SelectOptionType, SelectValueType, BaseSelectProps } from '.';
92
-
93
- const _Reflect = Reflect;
94
-
95
- const _props = withDefaults(
96
- defineProps<{
97
- init?: boolean; // 初始化组件时 执行 remoteMethod 方法
98
- filterUseRemote?: boolean; // 使用远程搜索
99
- options?: any; // 下拉选项
100
- group?: boolean; // 是否分组
101
- labelKey?: string;
102
- valueKey?: string;
103
- optionsKey?: string;
104
-
105
- modelValue?: any; // 选中项绑定值
106
- multiple?: boolean; // 是否多选
107
- disabled?: boolean; // 是否禁用
108
- size?: 'large' | 'default' | 'small'; // 输入框尺寸
109
- clearable?: boolean; // 是否可以清空选项
110
- collapseTags?: boolean; // 多选时是否将选中值按文字的形式展示
111
- collapseTagsTooltip?: boolean; // 当鼠标悬停于折叠标签的文本时,是否显示所有选中的标签。 要使用此属性,collapse-tags属性必须设定为 true
112
- multipleLimit?: number; // multiple 属性设置为 true 时,代表多选场景下用户最多可以选择的项目数, 为 0 则不限制
113
- placeholder?: string; // 占位文字
114
- filterable?: boolean; // Select 组件是否可筛选
115
- allowCreate?: boolean; // 是否允许用户创建新条目, 只有当 filterable 设置为 true 时才会生效。
116
- fitInputWidth?: boolean; // 下拉框的宽度是否与输入框相同
117
- filterMethod?: (searchVal: string) => Array<SelectValueType>; // 自定义筛选方法
118
-
119
- remoteMethod?: Function; // 远程方法
120
- loadingText?: string; // 从服务器加载内容时显示的文本
121
- noMatchText?: string; // 搜索条件无匹配时显示的文字,也可以使用 empty 插槽设置
122
- noDataText?: string; // 无选项时显示的文字,也可以使用 empty 插槽设置自定义内容
123
- }>(),
124
- {
125
- init: false,
126
- filterUseRemote: false,
127
- fitInputWidth: true,
128
- labelKey: 'label',
129
- valueKey: 'value',
130
- optionsKey: 'options',
131
- loadingText: '加载中',
132
- noMatchText: '暂无数据',
133
- noDataText: '暂无数据'
134
- }
135
- );
136
-
137
- interface _BaseSelectProps extends BaseSelectProps {
138
- valueKey: string;
139
- }
140
-
141
- const props = _props as Readonly<_BaseSelectProps>;
142
-
143
- const setOptionsData = async (val?: string) => {
144
- if (isFunction(props.remoteMethod)) {
145
- try {
146
- loading.value = true;
147
- const data = await props.remoteMethod?.(val);
148
- loading.value = false;
149
- // 避免多次请求接口 接口响应先后顺序不一致导致数据错乱
150
- _options.value = Array.isArray(data)
151
- ? data.filter(i => !val || `${i[props.valueKey]}`.indexOf(val) > -1)
152
- : [];
153
- } catch (error) {
154
- loading.value = false;
155
- console.error(error);
156
- }
157
- }
158
- };
159
-
160
- const _filterable = computed(
161
- () => props.filterable || isFunction(props.remoteMethod)
162
- );
163
- const debounceSetOptionsData = base.debounce(setOptionsData, 600);
164
- const _filterMethod = (
165
- props.filterUseRemote
166
- ? (val: string) => {
167
- loading.value = true;
168
- debounceSetOptionsData(val);
169
- }
170
- : undefined
171
- ) as Function | undefined;
172
-
173
- const toolTipDisabled = ref<boolean>(true);
174
- const loading = ref<boolean>(false);
175
- const _options = ref<typeof props.options>(props.options);
176
- const selectValue = ref<typeof props.modelValue>(
177
- props.multiple && props.modelValue && !Array.isArray(props.modelValue)
178
- ? [props.modelValue]
179
- : props.modelValue
180
- ) as Ref<any>;
181
- // 父组件值发生改变时,同步selectValue
182
- watch(
183
- () => props.modelValue,
184
- newV => {
185
- selectValue.value = newV as SelectValueType;
186
- }
187
- );
188
-
189
- const emits = defineEmits<{
190
- (event: 'update:modelValue', value: SelectValueType): void;
191
- (
192
- event: 'change',
193
- value: SelectValueType,
194
- SelectOption: Array<SelectOptionType>
195
- ): void;
196
- (event: 'remove-tag', value: SelectValueType): void;
197
- (event: 'visible-change', visibleStatus: boolean): void;
198
- (event: 'clear'): void;
199
- }>();
200
-
201
- const getSelectOptions = (
202
- options: Array<SelectOptionType>,
203
- selectValue: SelectValueType | Array<SelectValueType>
204
- ) => {
205
- return options.reduce((pre: typeof options, option: SelectOptionType) => {
206
- if (
207
- Array.isArray(selectValue)
208
- ? selectValue.includes(Reflect.get(option, props.valueKey))
209
- : Reflect.get(option, props.valueKey) == selectValue
210
- ) {
211
- pre.push(option);
212
- }
213
- if (Array.isArray(option.options)) {
214
- pre.push(...getSelectOptions(option.options, selectValue));
215
- }
216
- return pre;
217
- }, []);
218
- };
219
-
220
- const handleChange = (value: SelectValueType) => {
221
- emits('update:modelValue', value);
222
- emits(
223
- 'change',
224
- value,
225
- Array.isArray(_options.value) ? getSelectOptions(_options.value, value) : []
226
- );
227
- };
228
- const handleVisibleChange = (visibleStatus: boolean) => {
229
- toolTipDisabled.value = !visibleStatus;
230
- if (visibleStatus) {
231
- setOptionsData();
232
- }
233
- emits('visible-change', visibleStatus);
234
- };
235
- const handleClear = () => {
236
- emits('clear');
237
- };
238
- const handleRemoveTag = (value: SelectValueType) => {
239
- emits('remove-tag', value);
240
- };
241
-
242
- if (props.init) {
243
- setOptionsData();
244
- }
245
- </script>
246
-
247
- <style lang="scss" scoped>
248
- @import '../../../styles/element/mixin.scss';
249
- .option {
250
- padding-right: 18px;
251
- ::v-deep {
252
- .xrk-tooltip__trigger {
253
- @include line_clamp(1);
254
- word-break: break-all;
255
- }
256
- }
257
- }
258
- </style>
@@ -1,26 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-07-01 11:19:18
4
- */
5
- import { Component, DefineComponent } from 'vue';
6
-
7
- import _BaseSwitch from './switch.vue';
8
-
9
- export type BaseSwitchProps = {
10
- modelValue?: boolean | string | number;
11
- disabled?: boolean;
12
- loading?: boolean;
13
- size?: 'large' | 'default' | 'small';
14
- width?: number;
15
- activeIcon?: string | Component;
16
- activeText?: string;
17
- activeValue?: boolean | string | number;
18
- inactiveIcon?: string | Component;
19
- inactiveText?: string;
20
- inactiveValue?: boolean | string | number;
21
- beforeChange?: () => Promise<any> | boolean;
22
-
23
- onChange?: (value: boolean | string | number) => void;
24
- };
25
-
26
- export const BaseSwitch = _BaseSwitch as DefineComponent<BaseSwitchProps>;
@@ -1,103 +0,0 @@
1
- <!--
2
- * @Description:
3
- * @Date: 2022-06-28 13:56:17
4
- -->
5
- <template>
6
- <el-switch
7
- class="base-switch"
8
- v-model="_switchValue"
9
- :disabled="disabled"
10
- :loading="_loading"
11
- :size="size"
12
- :width="width"
13
- :activeIcon="activeIcon"
14
- :activeText="activeText"
15
- :activeValue="activeValue"
16
- :inactiveIcon="inactiveIcon"
17
- :inactiveText="inactiveText"
18
- :inactiveValue="inactiveValue"
19
- :beforeChange="_beforeChange"
20
- @change="handleChange"
21
- ></el-switch>
22
- </template>
23
-
24
- <script lang="tsx">
25
- export default {
26
- name: 'base-switch'
27
- };
28
- </script>
29
-
30
- <script lang="tsx" setup>
31
- import { ElSwitch } from 'element-plus';
32
- import { withDefaults, Component, ref, watch } from 'vue';
33
- import { isFunction } from '../../../tools/check';
34
- import { BaseSwitchProps } from '.';
35
- const _props = withDefaults(
36
- defineProps<{
37
- modelValue?: boolean | string | number;
38
- disabled?: boolean;
39
- loading?: boolean;
40
- size?: 'large' | 'default' | 'small';
41
- width?: number;
42
- activeIcon?: any;
43
- activeText?: string;
44
- activeValue?: boolean | string | number;
45
- inactiveIcon?: any;
46
- inactiveText?: string;
47
- inactiveValue?: boolean | string | number;
48
- beforeChange?: () => Promise<any> | boolean;
49
- }>(),
50
- {
51
- activeValue: true,
52
- inactiveValue: false
53
- }
54
- );
55
-
56
- const props = _props as Readonly<BaseSwitchProps>;
57
-
58
- const emits = defineEmits<{
59
- (event: 'update:modelValue', value: typeof props.modelValue): void;
60
- (event: 'change', value: typeof props.modelValue): void;
61
- }>();
62
-
63
- const _loading = ref<boolean | undefined>(props.loading);
64
-
65
- const _switchValue = ref<typeof props.modelValue>(props.modelValue);
66
- // 父组件值发生改变时,同步_switchValue
67
- watch(
68
- () => props.modelValue,
69
- newV => {
70
- _switchValue.value = newV;
71
- }
72
- );
73
- const _beforeChange = (async () => {
74
- try {
75
- _loading.value = true;
76
- if (isFunction(props.beforeChange)) {
77
- await props.beforeChange?.();
78
- }
79
- _loading.value = false;
80
- return true;
81
- } catch (error) {
82
- console.error('switch change fail', error);
83
- _loading.value = false;
84
- return false;
85
- }
86
- }) as typeof props.beforeChange;
87
-
88
- const handleChange = (val: typeof props.modelValue) => {
89
- _switchValue.value = val;
90
- emits('update:modelValue', val);
91
- emits('change', val);
92
- };
93
- </script>
94
-
95
- <style lang="scss" scoped>
96
- .base-switch {
97
- ::v-deep {
98
- .el-icon {
99
- z-index: 1;
100
- }
101
- }
102
- }
103
- </style>
@@ -1,15 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-07-01 15:57:35
4
- */
5
- import { BaseTableColumnProps } from '../types/type';
6
-
7
- export const useTableColumn = (
8
- props: BaseTableColumnProps
9
- ): BaseTableColumnProps => {
10
- return {
11
- minWidth: '120px',
12
- width: props.type === 'index' ? '90px' : '',
13
- ...props
14
- };
15
- };
@@ -1,16 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-07-01 14:34:57
4
- */
5
- import { Component, CSSProperties, DefineComponent } from 'vue';
6
-
7
- import _BaseTable from './table.vue';
8
- import _BaseTableColumn from './table-column.vue';
9
- import { BaseTableColumnProps, BaseTableProps } from './types/type';
10
- import { useTableColumn as _useTableColumn } from './hooks/use-table';
11
-
12
- export const BaseTable = _BaseTable as DefineComponent<BaseTableProps>;
13
- export const BaseTableColumn =
14
- _BaseTableColumn as DefineComponent<BaseTableColumnProps>;
15
-
16
- export const useTableColumn = _useTableColumn;
@@ -1,35 +0,0 @@
1
- /*
2
- * @Description:
3
- * @Date: 2022-03-14 19:18:12
4
- */
5
-
6
- import { reactive } from 'vue';
7
-
8
- export const useTableSetup = () => {
9
- const info = reactive<{ selectionRows: Map<number | string, any> }>({
10
- selectionRows: new Map()
11
- });
12
-
13
- return {
14
- selectionRows: info.selectionRows,
15
- hasSelectionRow: (rowId: number | string) => {
16
- return info.selectionRows.has(rowId);
17
- },
18
- addSelectionRow: (rowId: number | string, row: any) => {
19
- info.selectionRows.set(rowId, row);
20
- },
21
- removeSelectionRow: (rowId: number | string) => {
22
- info.selectionRows.delete(rowId);
23
- },
24
- getSelectionRows: () => {
25
- const arr: Array<any> = [];
26
- info.selectionRows.forEach(value => {
27
- arr.push(value);
28
- });
29
- return arr;
30
- },
31
- clearSelectionRows: () => {
32
- info.selectionRows.clear();
33
- }
34
- };
35
- };