ct-component-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 (87) hide show
  1. package/README.md +3 -0
  2. package/package.json +37 -0
  3. package/packages/components/button/index.js +9 -0
  4. package/packages/components/button/src/button.vue +172 -0
  5. package/packages/components/cascader/index.js +8 -0
  6. package/packages/components/cascader/src/cascader.vue +224 -0
  7. package/packages/components/cascader/src/ct-cascader.vue +261 -0
  8. package/packages/components/cascader/src/index.js +51 -0
  9. package/packages/components/checkbox/index.js +8 -0
  10. package/packages/components/checkbox/src/checkbox.vue +48 -0
  11. package/packages/components/checkbox/src/index.js +13 -0
  12. package/packages/components/date-picker/index.js +9 -0
  13. package/packages/components/date-picker/src/clear-icon.vue +3 -0
  14. package/packages/components/date-picker/src/date-icon.vue +3 -0
  15. package/packages/components/date-picker/src/date-picker.vue +77 -0
  16. package/packages/components/date-picker/src/index.js +34 -0
  17. package/packages/components/dialog/index.js +9 -0
  18. package/packages/components/dialog/src/dialog.vue +104 -0
  19. package/packages/components/empty/index.js +9 -0
  20. package/packages/components/empty/src/empty.vue +98 -0
  21. package/packages/components/index.js +71 -0
  22. package/packages/components/input/index.js +8 -0
  23. package/packages/components/input/src/index.js +14 -0
  24. package/packages/components/input/src/input.vue +107 -0
  25. package/packages/components/input-range/index.js +8 -0
  26. package/packages/components/input-range/src/index.js +30 -0
  27. package/packages/components/input-range/src/input-range.vue +234 -0
  28. package/packages/components/menu/index.js +8 -0
  29. package/packages/components/menu/src/assets/plus_line.svg +1 -0
  30. package/packages/components/menu/src/item.vue +47 -0
  31. package/packages/components/menu/src/link.vue +29 -0
  32. package/packages/components/menu/src/logo.vue +26 -0
  33. package/packages/components/menu/src/menu-item.vue +104 -0
  34. package/packages/components/menu/src/menu.vue +192 -0
  35. package/packages/components/menu/src/utils/index.js +5 -0
  36. package/packages/components/message/icon/ErrorIcon.vue +25 -0
  37. package/packages/components/message/icon/InfoIcon.vue +25 -0
  38. package/packages/components/message/icon/SuccessIcon.vue +25 -0
  39. package/packages/components/message/icon/WarningIcon.vue +25 -0
  40. package/packages/components/message/index.js +9 -0
  41. package/packages/components/message/src/method.js +55 -0
  42. package/packages/components/message-box/index.js +8 -0
  43. package/packages/components/message-box/src/message-box.vue +108 -0
  44. package/packages/components/pagination/index.js +8 -0
  45. package/packages/components/pagination/src/pagination.vue +37 -0
  46. package/packages/components/radio/index.js +8 -0
  47. package/packages/components/radio/src/index.js +13 -0
  48. package/packages/components/radio/src/radio.vue +48 -0
  49. package/packages/components/search-box/index.js +25 -0
  50. package/packages/components/search-box/src/index.js +30 -0
  51. package/packages/components/search-box/src/search-box.vue +240 -0
  52. package/packages/components/search-box/src/slot.vue +5 -0
  53. package/packages/components/select/index.js +8 -0
  54. package/packages/components/select/src/arrow-down.vue +3 -0
  55. package/packages/components/select/src/clear-icon.vue +3 -0
  56. package/packages/components/select/src/empty.vue +14 -0
  57. package/packages/components/select/src/index.js +52 -0
  58. package/packages/components/select/src/select.vue +331 -0
  59. package/packages/components/table/index.js +8 -0
  60. package/packages/components/table/src/TableSort.vue +179 -0
  61. package/packages/components/table/src/index.js +47 -0
  62. package/packages/components/table/src/table.vue +249 -0
  63. package/packages/components/tabs/index.js +8 -0
  64. package/packages/components/tabs/src/tabs.vue +226 -0
  65. package/packages/components/year-select/index.js +8 -0
  66. package/packages/components/year-select/src/index.js +45 -0
  67. package/packages/components/year-select/src/year-select.vue +274 -0
  68. package/packages/constants/aria.ts +17 -0
  69. package/packages/constants/index.ts +1 -0
  70. package/packages/directives/click-outside/index.ts +118 -0
  71. package/packages/directives/index.js +1 -0
  72. package/packages/echarts/bar/index.js +64 -0
  73. package/packages/echarts/base.js +96 -0
  74. package/packages/echarts/line/index.js +107 -0
  75. package/packages/hooks/index.js +6 -0
  76. package/packages/hooks/use-buried/index.js +47 -0
  77. package/packages/hooks/use-checked-all/index.js +37 -0
  78. package/packages/hooks/use-echarts/index.js +2 -0
  79. package/packages/hooks/use-echarts/use-bar/index.js +67 -0
  80. package/packages/hooks/use-echarts/use-line/index.js +83 -0
  81. package/packages/hooks/use-namespace/index.js +66 -0
  82. package/packages/hooks/use-search-component/index.js +29 -0
  83. package/packages/style/element.less +600 -0
  84. package/packages/style/init.less +114 -0
  85. package/packages/utils/index.js +2 -0
  86. package/packages/utils/operate.js +78 -0
  87. package/packages/utils/types.js +35 -0
@@ -0,0 +1,47 @@
1
+
2
+ export const buriedParamsKey = 'changeBuriedParams'
3
+ import { isFunction, isObject } from '../../utils';
4
+ import { watch } from 'vue';
5
+ export const useBuriedParams = (props, emitApp, options) => {
6
+ const emitKey = buriedParamsKey;
7
+ const { label, param } = (props || {});
8
+
9
+ const get = (content) => {
10
+ const params = {
11
+ label,
12
+ value: param,
13
+ content
14
+ }
15
+ if (options && isFunction(options.getContent)) {
16
+ params.content = options.getContent(params.content)
17
+ }
18
+ return params
19
+ }
20
+ const emit = (content) => {
21
+ if (isFunction(emitApp)) {
22
+ const params = get(content);
23
+ if (params.label) {
24
+ emitApp(emitKey, params)
25
+ }
26
+ }
27
+ }
28
+
29
+ const _emitBuriedParams = () => {
30
+ // 发送埋点数据
31
+ props.buried && emit(props.modelValue);
32
+ };
33
+ watch(
34
+ () => props.modelValue,
35
+ (newValue) => {
36
+ _emitBuriedParams();
37
+ },
38
+ {
39
+ immediate: true,
40
+ }
41
+ );
42
+ return {
43
+ get,
44
+ emit,
45
+ emitKey,
46
+ }
47
+ }
@@ -0,0 +1,37 @@
1
+ import { computed } from "vue"
2
+ import { isArray, isObject } from '../../utils';
3
+
4
+ export const useCheckedAll = (list, selects, options = {}) => {
5
+ const { key = 'value' } = (isObject(options) ? options : {})
6
+ const listKeys = computed(() => {
7
+ if (isArray(list.value)) return list.value.map(item => item[key])
8
+ return []
9
+ })
10
+
11
+ const checkedAll = computed({
12
+ get() {
13
+ if (isArray(list.value) && isArray(selects.value) && list.value.length && selects.value.length) {
14
+ if (list.value.length > selects.value.length) {
15
+ return false;
16
+ } else {
17
+ return listKeys.value.every(item => selects.value.includes(item))
18
+ return selects.value.every(item => listKeys.value.includes(item))
19
+ }
20
+ } else {
21
+ return false
22
+ }
23
+ },
24
+ set(newValue) {
25
+ if (!newValue) {
26
+ // 去掉全选
27
+ selects.value = selects.value.filter(item => !listKeys.value.includes(item))
28
+ } else {
29
+ // 全选
30
+ selects.value = selects.value.concat(listKeys.value.filter(item => !selects.value.includes(item)))
31
+ }
32
+ }
33
+ })
34
+ return {
35
+ checkedAll
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./use-line";
2
+ export * from "./use-bar";
@@ -0,0 +1,67 @@
1
+ import { ref, watch, inject } from "vue";
2
+ import { baseBarOption, seriesItem } from "../../../echarts/bar";
3
+ import { copyObj, getOpacityColor, objectMerge } from "../../../utils";
4
+
5
+ /**
6
+ *
7
+ * @param {string} type -柱状图的类型,目前只有basic基本柱状图
8
+ * @param {Object} option -用户想要进行灵活配置所传入的参数
9
+ * @param {Array} data - 图表数据
10
+ */
11
+ export const useBarEcharts = (type, option, data) => {
12
+ const themeColor = inject('themeColor', null); //获取系统主题
13
+ const barOption = ref(copyObj(baseBarOption));
14
+ const itemTemplate = ref({});
15
+
16
+ //判断折线图图表类型,确定seriesItem格式
17
+ if (type == 'basic') {
18
+ itemTemplate.value = copyObj(seriesItem);
19
+ }
20
+ function initColor() {
21
+ barOption.value.color.splice(0, 1, themeColor);//调整调色板第一个主题色
22
+ }
23
+ if (themeColor) {
24
+ initColor();
25
+ }
26
+ function update(data) {
27
+ //数据更新方式
28
+ if (data.length == 0) {
29
+ console.log('用户没有传入图表数据,请在hooks外处理');
30
+ return;
31
+ }
32
+ if (data.length > 1) {
33
+ barOption.value.legend.data = data.map((item) => item.name);
34
+ }
35
+ barOption.value.series.splice(0);
36
+ data.forEach((item, index) => {
37
+ let row = copyObj(itemTemplate.value);
38
+ let colorBoard = barOption.value.color;
39
+ row.itemStyle.borderColor.colorStops = [
40
+ {
41
+ offset: 0,
42
+ color: getOpacityColor(colorBoard[index % colorBoard.length], '0.5')
43
+ },
44
+ {
45
+ offset: 1,
46
+ color: getOpacityColor(colorBoard[index % colorBoard.length], '1')
47
+ }
48
+ ]
49
+ row.data = item.data;
50
+ row.name = item.name;
51
+ row.label.show = item.showLabel ? true : false;
52
+ row.emphasis.label.show = item.showLabel ? true : false;
53
+ barOption.value.series.push(row);
54
+ })
55
+ }
56
+ watch(() => data, (val) => {
57
+ update(val);
58
+ },
59
+ { deep: true, immediate: true }
60
+ );
61
+ // 灵活配置并入option
62
+ objectMerge(barOption.value, option);
63
+ return {
64
+ barOption,
65
+ itemTemplate
66
+ }
67
+ }
@@ -0,0 +1,83 @@
1
+ import { ref, watch, inject } from "vue";
2
+ import {
3
+ baseLineOption, seriesItem, areaSeriesItem
4
+ } from "../../../echarts/line";
5
+ import { copyObj, getOpacityColor, objectMerge } from "../../../utils";
6
+ /**
7
+ *
8
+ * @param {string} type - 折线图的类型 basic-基础折线图 area-面积折线图
9
+ * @param {Object} option -用户想要进行灵活配置所传入的参数
10
+ * @param {Array} data - 图表数据
11
+ */
12
+ export const useLineEcharts = (type, option, data) => {
13
+ const themeColor = inject('themeColor', null); //获取系统主题
14
+ const lineOption = ref(copyObj(baseLineOption));
15
+ const itemTemplate = ref({});
16
+
17
+ //判断折线图图表类型,确定seriesItem格式
18
+ if (type == 'basic') {
19
+ itemTemplate.value = copyObj(seriesItem);
20
+ } else if (type == 'area') {
21
+ itemTemplate.value = copyObj(areaSeriesItem);
22
+ }
23
+ function initColor() {
24
+ lineOption.value.color.splice(0, 1, themeColor);//调整调色板第一个主题色
25
+ }
26
+ if (themeColor) {
27
+ initColor();
28
+ }
29
+
30
+ function update(data) {
31
+ //数据更新方式
32
+ if (data.length == 0) {
33
+ console.log('用户没有传入图表数据,请在hooks外处理');
34
+ return;
35
+ }
36
+ if (data.length > 1) {
37
+ lineOption.value.legend.data = data.map((item) => item.name);
38
+ }
39
+ lineOption.value.series.splice(0);
40
+ data.forEach((item, index) => {
41
+ let row = copyObj(itemTemplate.value);
42
+ row.name = item.name;
43
+ row.data = item.data;
44
+ row.smooth = item.smooth ? true : false;
45
+ row.label = {
46
+ show: item.showLabel ? true : false
47
+ }
48
+ row.emphasis.label = {
49
+ show: item.showLabel ? true : false,
50
+ fontWeight: 600,
51
+ color: 'inherit'
52
+ }
53
+ if (type == 'area') {
54
+ //更新面积折线图面积颜色
55
+ let colorBoard = lineOption.value.color;
56
+ row.areaStyle.color.colorStops = [
57
+ {
58
+ offset: 0,
59
+ color: getOpacityColor(colorBoard[index % colorBoard.length], '0.22')
60
+ },
61
+ {
62
+ offset: 1,
63
+ color: getOpacityColor(colorBoard[index % colorBoard.length], '0')
64
+ }
65
+ ]
66
+ }
67
+ lineOption.value.series.push(row);
68
+ })
69
+ }
70
+ watch(() => data, (val) => {
71
+ update(val);
72
+ },
73
+ { deep: true, immediate: true }
74
+ );
75
+ // 灵活配置并入option
76
+ objectMerge(lineOption.value, option);
77
+ return {
78
+ lineOption,
79
+ itemTemplate
80
+ }
81
+ }
82
+
83
+
@@ -0,0 +1,66 @@
1
+
2
+ export const defaultNamespace = 'ct'
3
+ /**
4
+ * 处理生成BEM命名规则的类名
5
+ * @param options BEM字段配置项
6
+ * @returns BEM命名规则的类名
7
+ */
8
+ const _bem = (options = {}) => {
9
+ let cls = `${defaultNamespace}`;
10
+ if (options.block) cls += `-${options.block}`;
11
+ if (options.blockSuffix) cls += `-${options.blockSuffix}`;
12
+ if (options.element) cls += `__${options.element}`;
13
+ if (options.modifier) cls += `--${options.modifier}`;
14
+ return cls
15
+ }
16
+ const statePrefix = 'is-'
17
+
18
+ /**
19
+ * 采用BEM命名的hooks
20
+ * @param block BEM的B,模块名
21
+ * @returns
22
+ */
23
+ export const useNamespace = (block) => {
24
+ const options = { block }; //默认的BEM配置
25
+
26
+ // 给BEM的B赋值,取使用hook时传入的block
27
+ const b = () => _bem(options);
28
+ // 给BEM的E赋值
29
+ const e = (element) => element ? _bem({ ...options, element, }) : '';
30
+ // 给BEM的M赋值
31
+ const m = (modifier) => modifier ? _bem({ ...options, modifier, }) : '';
32
+ // 给BEM的BE赋值
33
+ const be = (blockSuffix, element) =>
34
+ blockSuffix && element
35
+ ? _bem({ ...options, blockSuffix, element })
36
+ : '';
37
+ // 给BEM的EM赋值
38
+ const em = (element, modifier) =>
39
+ element && modifier
40
+ ? _bem({ ...options, element, modifier })
41
+ : '';
42
+ // 给BEM的BM赋值,这里的B是block的后缀名
43
+ const bm = (blockSuffix, modifier) =>
44
+ blockSuffix && modifier
45
+ ? _bem({ ...options, blockSuffix, modifier })
46
+ : '';
47
+ // 给BEM的BM赋值,这里的B是block的后缀名
48
+ const bem = (blockSuffix, element, modifier) =>
49
+ blockSuffix && element && modifier
50
+ ? _bem({ ...options, blockSuffix, element, modifier })
51
+ : '';
52
+ const is = (name, ...args) => {
53
+ const state = args.length >= 1 ? !!args[0] : true
54
+ return name && state ? `${statePrefix}${name}` : ''
55
+ }
56
+ return {
57
+ b,
58
+ e,
59
+ m,
60
+ be,
61
+ em,
62
+ bm,
63
+ bem,
64
+ is
65
+ }
66
+ }
@@ -0,0 +1,29 @@
1
+
2
+
3
+ export const searchComponentProps = {
4
+ param: String,
5
+ label: String,
6
+ rawAttr: {
7
+ type: Object,
8
+ default() {
9
+ return {};
10
+ },
11
+ },
12
+ cbs: {
13
+ type: Object,
14
+ default() {
15
+ return {};
16
+ },
17
+ },
18
+ buried: {
19
+ type: Boolean,
20
+ default: true,
21
+ },
22
+ }
23
+
24
+ export const useSearchComponent = () => {
25
+
26
+ return {
27
+ props: searchComponentProps,
28
+ }
29
+ }