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,48 @@
1
+ <template>
2
+ <el-radio-group :class="[ns.b()]" v-model="showValue" ref="radioRef">
3
+ <el-radio
4
+ :class="[ns.e('item')]"
5
+ v-for="item in optionList"
6
+ :key="item.value"
7
+ :label="item.value"
8
+ :disabled="item.disabled"
9
+ >{{ item.label }}</el-radio
10
+ >
11
+ </el-radio-group>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { computed, onMounted, ref } from "vue";
16
+ import { useNamespace, useBuriedParams } from "../../../hooks";
17
+ import { radioEmits, radioProps } from "./index";
18
+ const props = defineProps(radioProps);
19
+ const emit = defineEmits(radioEmits);
20
+
21
+ const ns = useNamespace("radio");
22
+ const radioRef = ref(null);
23
+ const showValue = computed({
24
+ get() {
25
+ return props.modelValue;
26
+ },
27
+ set(newValue) {
28
+ emit("update:modelValue", newValue);
29
+ },
30
+ });
31
+ const optionList = computed(() => {
32
+ return props.options;
33
+ });
34
+
35
+ useBuriedParams(props, emit, {
36
+ getContent: (value) => {
37
+ const item = optionList.value.find((item) => item.value === value);
38
+ return item ? item.label : "";
39
+ },
40
+ });
41
+
42
+ defineExpose({
43
+ ref: radioRef,
44
+ });
45
+ onMounted(() => {});
46
+ </script>
47
+ <style lang='less'>
48
+ </style>
@@ -0,0 +1,25 @@
1
+ import CtSearchBox from './src/search-box.vue';
2
+
3
+ import CtInput from '../input';
4
+ import CtSelect from '../select';
5
+ import CtDatePicker from '../date-picker';
6
+ import CtCascader from '../cascader';
7
+ import CtYearSelect from '../year-select';
8
+
9
+ export const searchComponents = {
10
+ CtInput,
11
+ CtSelect,
12
+ CtDatePicker,
13
+ CtCascader,
14
+ CtYearSelect
15
+ }
16
+
17
+ /* istanbul ignore next */
18
+ CtSearchBox.install = function (Vue) {
19
+ Vue.component('CtSearchBox', CtSearchBox);
20
+ // for (const key in searchComponents) {
21
+ // Vue.component(key, searchComponents[key]);
22
+ // }
23
+ };
24
+
25
+ export default CtSearchBox;
@@ -0,0 +1,30 @@
1
+
2
+ export const searchBoxEmits = [
3
+ "update:modelValue",
4
+ 'update:searchParams',
5
+ 'update:searchParamsCurrent',
6
+ 'doSearch',
7
+ 'doReset'
8
+ ];
9
+ export const searchBoxProps = {
10
+ modelValue: Object,
11
+ rowNumber: {
12
+ type: Number,
13
+ default: 5,
14
+ },
15
+ searchList: {
16
+ type: Array,
17
+ default: () => {
18
+ return []
19
+ }
20
+ },
21
+ outerBorder: {
22
+ type: Boolean,
23
+ default: true,
24
+ },
25
+ haveReset: Boolean,
26
+ searchBtnName: {
27
+ type: String,
28
+ default: '查询'
29
+ }
30
+ }
@@ -0,0 +1,240 @@
1
+ <template>
2
+ <div :class="[ns.b()]">
3
+ <div :class="[ns.e('container')]">
4
+ <div :class="[ns.e('list')]">
5
+ <div
6
+ v-for="(item, index) in searchList"
7
+ :class="[
8
+ ns.e('item'),
9
+ ...getComponentClass(item),
10
+ ns.is('outer-border', outerBorder),
11
+ ]"
12
+ :key="item.param || index"
13
+ :style="{ ...getComponentStyle(item) }"
14
+ >
15
+ <slot v-bind="getComponentSlotScope(item)">
16
+ <slot
17
+ name="item-before"
18
+ v-bind="getComponentSlotScope(item)"
19
+ ></slot>
20
+ <span
21
+ :class="[
22
+ ns.e('item-label'),
23
+ ns.is('required', item.required),
24
+ ns.is('outer-border', outerBorder),
25
+ ]"
26
+ >
27
+ <span>{{ item.label }}</span>
28
+ <span :class="[ns.is('required')]" v-if="!outerBorder">:</span>
29
+ </span>
30
+ <div :class="[ns.e('item-component')]">
31
+ <slot
32
+ :name="item.componentName || item.param"
33
+ v-bind="getComponentSlotScope(item)"
34
+ >
35
+ <component
36
+ :is="getComponent(item.type)"
37
+ v-model="searchParamsCurrent[item.param]"
38
+ v-bind="getComponentProps(item)"
39
+ >
40
+ </component>
41
+ </slot>
42
+ </div>
43
+ <slot name="item-after" v-bind="getComponentSlotScope(item)"></slot>
44
+ </slot>
45
+ </div>
46
+ <div :class="[ns.e('buttons')]">
47
+ <slot name="solt-search">
48
+ <ct-button type="border-plain" @click="resetData" v-if="haveReset"
49
+ >重置</ct-button
50
+ >
51
+ <ct-button type="border" @click="doSearch">{{
52
+ searchBtnName
53
+ }}</ct-button>
54
+ </slot>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </template>
60
+
61
+ <script setup>
62
+ import { computed, inject, onMounted, ref, watch } from "vue";
63
+ import { searchBoxEmits, searchBoxProps } from "./index";
64
+ import { useNamespace, buriedParamsKey } from "../../../hooks";
65
+ import { isObject, isString, isArray, toFirstUpperCase } from "../../../utils";
66
+ import { searchComponents } from "../index";
67
+ const userDefinedSearchComponent = inject("$userDefinedSearchComponent", {});
68
+ const searchBoxConfig = inject("$searchBoxConfig", {});
69
+ const props = defineProps(searchBoxProps);
70
+ const emit = defineEmits(searchBoxEmits);
71
+
72
+ const ns = useNamespace("search-box");
73
+
74
+ const searchParamsCurrent = ref({});
75
+ watch(searchParamsCurrent, (newVal) => {
76
+ emit("update:searchParamsCurrent", newVal);
77
+ });
78
+ watch(
79
+ () => props.modelValue,
80
+ (newValue) => {
81
+ searchParamsCurrent.value = newValue || {};
82
+ },
83
+ { immediate: true }
84
+ );
85
+
86
+ const getComponentClass = (item) => {
87
+ const classList = [];
88
+ if (item.componentClass) {
89
+ const cla = item.componentClass;
90
+ if (isString(cla)) classList.push(cla);
91
+ if (isArray(cla)) classList.push(...cla);
92
+ }
93
+ return classList;
94
+ };
95
+ const getComponentStyle = (item) => {
96
+ const style = {};
97
+ if (item.componentStyle) {
98
+ const sty = item.componentStyle;
99
+ if (isObject(sty)) Object.assign(style, sty);
100
+ }
101
+ return style;
102
+ };
103
+ const componentAll = computed(() => {
104
+ const { CtInput, CtSelect, CtDatePicker, CtCascader, CtYearSelect } =
105
+ searchComponents;
106
+ const componentMap = {
107
+ 0: CtInput,
108
+ 1: CtSelect,
109
+ 2: CtCascader,
110
+ 4: CtDatePicker,
111
+ 12: CtYearSelect,
112
+ 13: "div",
113
+ ...userDefinedSearchComponent,
114
+ };
115
+ return componentMap;
116
+ });
117
+ const handleBuriedParams = (params) => {
118
+ console.log(params);
119
+ };
120
+ const getComponentProps = (item) => {
121
+ const bpKey = toFirstUpperCase(buriedParamsKey);
122
+ // const
123
+ return {
124
+ param: item.param,
125
+ label: item.label,
126
+ options: item.list,
127
+ placeholder: item.placeholder,
128
+ multiple: item.multiple,
129
+ clearable: item.clearable,
130
+ disabled: item.disabled,
131
+ range: item.range,
132
+ mapObj: item.mapObj,
133
+ name: item.param, //用作插槽名
134
+
135
+ ["on" + bpKey]: handleBuriedParams,
136
+ };
137
+ };
138
+ const getComponent = (type) => {
139
+ return isObject(type) ? type : componentAll.value[type] || type;
140
+ };
141
+ const getComponentSlotScope = (item) => {
142
+ return isObject(item) ? item : {};
143
+ };
144
+
145
+ const haveReset = computed(() => {
146
+ return props.haveReset;
147
+ });
148
+ const resetData = () => {
149
+ const keys = Object.keys(searchParamsCurrent.value);
150
+ keys.forEach((key) => {
151
+ const oldValue = searchParamsCurrent.value[key];
152
+ searchParamsCurrent.value[key] = Array.isArray(oldValue) ? [] : "";
153
+ });
154
+ emit("doReset");
155
+ };
156
+ const doSearch = () => {
157
+ emit("update:searchParams", searchParamsCurrent);
158
+ emit("doSearch", searchParamsCurrent.value);
159
+ };
160
+
161
+ defineExpose({
162
+ searchParamsCurrent,
163
+ componentAll: componentAll.value,
164
+ getComponent,
165
+ });
166
+ onMounted(() => {});
167
+ </script>
168
+ <style lang='less'>
169
+ .ct-search-box {
170
+ --ct-search-box-item-margin-right: 16px;
171
+ --ct-search-box-item-margin-top: 14px;
172
+ .el-input {
173
+ --ct-input-default-width: auto;
174
+ }
175
+ &__list {
176
+ display: flex;
177
+ align-items: center;
178
+ flex-wrap: wrap;
179
+ margin-right: calc(-1 * var(--ct-search-box-item-margin-right));
180
+ margin-top: calc(-1 * var(--ct-search-box-item-margin-top));
181
+ > * {
182
+ margin-right: var(--ct-search-box-item-margin-right);
183
+ margin-top: var(--ct-search-box-item-margin-top);
184
+ }
185
+ }
186
+ &__item {
187
+ display: flex;
188
+ align-items: center;
189
+ width: calc(
190
+ (100% - v-bind(rowNumber) * var(--ct-search-box-item-margin-right)) /
191
+ v-bind(rowNumber)
192
+ );
193
+ --ct-search-box-item-component-width: 100%;
194
+ &.is-outer-border {
195
+ --ct-font-size: 13px;
196
+ --ct-search-box-border-color: var(--ct-border-color);
197
+ --ct-search-box-inner-border-color: transparent;
198
+ font-size: var(--ct-font-size);
199
+ height: 36px;
200
+ padding-left: 14px;
201
+ box-shadow: 0 0 0 1px var(--ct-search-box-border-color);
202
+ border-radius: var(--ct-border-radius);
203
+ &:hover {
204
+ --ct-search-box-border-color: var(--ct-color-grey-transition);
205
+ }
206
+ &:focus-within {
207
+ --ct-search-box-border-color: var(--ct-color-primary);
208
+ }
209
+ .el-input__wrapper {
210
+ --el-select-input-focus-border-color: var(
211
+ --ct-search-box-inner-border-color
212
+ );
213
+ box-shadow: 0 0 0 1px var(--ct-search-box-inner-border-color) !important;
214
+ }
215
+ }
216
+ &-label {
217
+ line-height: 1;
218
+ &.is-outer-border {
219
+ color: var(--ct-color-grey-sub);
220
+ }
221
+ }
222
+ &-component {
223
+ flex: 1;
224
+ > * {
225
+ width: var(--ct-search-box-item-component-width) !important;
226
+ }
227
+ }
228
+ }
229
+ &__buttons {
230
+ margin-left: auto;
231
+ button {
232
+ width: 96px;
233
+ padding: 0;
234
+ height: 34px;
235
+ line-height: 34px;
236
+ border-radius: 4px;
237
+ }
238
+ }
239
+ }
240
+ </style>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div>
3
+ <slot></slot>
4
+ </div>
5
+ </template>
@@ -0,0 +1,8 @@
1
+ import CtSelect from './src/select.vue';
2
+
3
+ /* istanbul ignore next */
4
+ CtSelect.install = function (Vue) {
5
+ Vue.component('CtSelect', CtSelect);
6
+ };
7
+
8
+ export default CtSelect;
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <ct-icon name="arrow-down_line"></ct-icon>
3
+ </template>
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <ct-icon name="close_line"></ct-icon>
3
+ </template>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <div class="ct-select__empty">
3
+ <span>{{ text }}</span>
4
+ </div>
5
+ </template>
6
+
7
+ <script setup>
8
+ defineProps({
9
+ text: {
10
+ type: String,
11
+ default: "暂无数据",
12
+ },
13
+ });
14
+ </script>
@@ -0,0 +1,52 @@
1
+ import { buriedParamsKey, searchComponentProps } from '../../../hooks';
2
+ import arrowDown from './arrow-down.vue';
3
+ import clearIcon from './clear-icon.vue';
4
+
5
+ export const selectEmits = ["update:modelValue", buriedParamsKey];
6
+ export const selectProps = {
7
+ ...searchComponentProps,
8
+ modelValue: [String, Number, Array],
9
+ multiple: Boolean,
10
+ options: {
11
+ type: Array,
12
+ default() {
13
+ return []
14
+ }
15
+ },
16
+ filterable: Boolean,
17
+ api: String,
18
+ serviceMethod: String,
19
+ serviceParams: Object,
20
+ mapObj: {
21
+ type: Object,
22
+ default() {
23
+ return {}
24
+ }
25
+ },
26
+ selectAllText: {
27
+ type: String,
28
+ default: '全部'
29
+ },
30
+ connectors: {
31
+ type: String,
32
+ default: '、'
33
+ },
34
+ fitInputWidth: {
35
+ type: Boolean,
36
+ default: true,
37
+ },
38
+ clearIcon: {
39
+ type: [String, Object],
40
+ default() {
41
+ return clearIcon
42
+ }
43
+ },
44
+ suffixIcon: {
45
+ type: [String, Object],
46
+ default() {
47
+ return arrowDown
48
+ }
49
+ },
50
+ noMatchText: String,
51
+ noDataText: String,
52
+ }