cosey 0.4.52 → 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.
Files changed (50) hide show
  1. package/components/components.d.ts +3 -1
  2. package/components/components.js +1 -0
  3. package/components/field/components/checkbox-group/checkbox-group.d.ts +2 -2
  4. package/components/field/components/checkbox-group/checkbox-group.vue.js +8 -3
  5. package/components/field/components/radio-group/radio-group.d.ts +2 -2
  6. package/components/field/components/radio-group/radio-group.vue.js +7 -2
  7. package/components/field/components/remote-select/remote-select.d.ts +16 -0
  8. package/components/field/components/remote-select/remote-select.js +1 -0
  9. package/components/field/components/remote-select/remote-select.vue.d.ts +3 -0
  10. package/components/field/components/remote-select/remote-select.vue.js +32 -0
  11. package/components/field/components/select/select.d.ts +6 -3
  12. package/components/field/components/select/select.js +1 -1
  13. package/components/field/components/select/select.vue.js +21 -9
  14. package/components/field/components/select-v2/select-v2.d.ts +1 -2
  15. package/components/field/components/select-v2/select-v2.js +2 -1
  16. package/components/field/components/select-v2/select-v2.vue.js +11 -5
  17. package/components/field/field.d.ts +3 -0
  18. package/components/field/field.js +44 -42
  19. package/components/form/form-item.vue.js +1 -1
  20. package/components/form-group/form-group.d.ts +2 -2
  21. package/components/form-group/form-group.vue.js +9 -13
  22. package/components/form-group/style/index.js +2 -3
  23. package/components/form-query/form-query.vue.d.ts +2 -2
  24. package/components/form-query/form-query.vue.js +42 -41
  25. package/components/form-query/index.d.ts +6 -6
  26. package/components/form-query/style/index.js +4 -1
  27. package/components/image-card/image-card.vue.js +1 -1
  28. package/components/index.d.ts +1 -0
  29. package/components/index.js +2 -0
  30. package/components/remote-select/index.d.ts +1149 -0
  31. package/components/remote-select/index.js +8 -0
  32. package/components/remote-select/remote-select.d.ts +263 -0
  33. package/components/remote-select/remote-select.js +37 -0
  34. package/components/remote-select/remote-select.vue.d.ts +530 -0
  35. package/components/remote-select/remote-select.vue.js +187 -0
  36. package/components/remote-select/style/index.d.ts +4 -0
  37. package/components/remote-select/style/index.js +33 -0
  38. package/components/table/table-query/table-query.vue.d.ts +3 -3
  39. package/components/table/table.vue.js +5 -5
  40. package/hooks/index.d.ts +1 -0
  41. package/hooks/index.js +1 -0
  42. package/hooks/useProps.d.ts +24 -0
  43. package/hooks/useProps.js +29 -0
  44. package/package.json +1 -1
  45. package/utils/components.d.ts +29 -0
  46. package/utils/components.js +13 -0
  47. package/utils/index.d.ts +1 -0
  48. package/utils/index.js +1 -0
  49. package/components/table/utils.d.ts +0 -6
  50. package/components/table/utils.js +0 -7
@@ -0,0 +1,187 @@
1
+ import { defineComponent, ref, unref, computed, createVNode, mergeProps, nextTick } from 'vue';
2
+ import { remoteSelectEmits, remoteSelectSlots, remoteSelectProps } from './remote-select.js';
3
+ import stdin_default$1 from './style/index.js';
4
+ import { ElSelect, ElPagination, ElOption } from 'element-plus';
5
+ import { reactiveComputed } from '@vueuse/core';
6
+ import { merge, get } from 'lodash-es';
7
+ import { defaultTableConfig } from '../table/table.js';
8
+ import stdin_default$2 from '../table/table-query/table-query.vue.js';
9
+ import { useComponentConfig, useConfig } from '../config-provider/config-provider.js';
10
+ import { useFetch } from '../../hooks/useFetch.js';
11
+ import { createLoading, filterEmptyFormValue } from '../../utils/components.js';
12
+ import { uniqid } from '../../utils/string.js';
13
+ import { isObject, isFunction } from '../../utils/is.js';
14
+ import { useProps } from '../../hooks/useProps.js';
15
+
16
+ var stdin_default = defineComponent({
17
+ name: "RemoteSelect",
18
+ props: remoteSelectProps,
19
+ slots: remoteSelectSlots,
20
+ emits: remoteSelectEmits,
21
+ setup(props, {
22
+ slots,
23
+ emit,
24
+ attrs
25
+ }) {
26
+ const {
27
+ prefixCls
28
+ } = useComponentConfig("remote-select", props);
29
+ const {
30
+ hashId
31
+ } = stdin_default$1(prefixCls);
32
+ const {
33
+ table: tableConfig
34
+ } = useConfig();
35
+ const isFirstFetch = ref(true);
36
+ const tableData = ref([]);
37
+ const tableQueryRef = ref();
38
+ const tableKeys = reactiveComputed(() => {
39
+ return merge({}, defaultTableConfig.keys, unref(tableConfig)?.keys, props.keys);
40
+ });
41
+ const getFetchParams = () => {
42
+ const params = {
43
+ ...filterEmptyFormValue(tableQueryRef.value?.getFieldsValue() || {})
44
+ };
45
+ return filterEmptyFormValue(props.transformParams?.(params) || params);
46
+ };
47
+ const getFullFetchParams = () => {
48
+ return {
49
+ [tableKeys.page]: page.value,
50
+ [tableKeys.pageSize]: pageSize.value,
51
+ ...getFetchParams()
52
+ };
53
+ };
54
+ let loading;
55
+ const {
56
+ isFetching,
57
+ execute
58
+ } = useFetch(() => {
59
+ loading = createLoading(`.${popperId}`);
60
+ const params = getFullFetchParams();
61
+ return props.api?.(params);
62
+ }, {
63
+ immediate: props.immediate,
64
+ onSuccess(res) {
65
+ tableData.value = (tableKeys.list ? get(res, tableKeys.list) : res) || [];
66
+ total.value = +get(res, tableKeys.total) || 0;
67
+ },
68
+ onFinally() {
69
+ isFirstFetch.value = false;
70
+ loading?.close();
71
+ }
72
+ });
73
+ const pagination = reactiveComputed(() => {
74
+ return merge({}, defaultTableConfig.pagination, {
75
+ layout: "prev, pager, next"
76
+ }, unref(tableConfig)?.pagination, isObject(props.pagination) ? props.pagination : null);
77
+ });
78
+ const total = ref(0);
79
+ const page = ref(pagination.currentPage);
80
+ const pageSize = ref(pagination.pageSize);
81
+ const paginationProps = computed(() => {
82
+ if (props.pagination === false) {
83
+ return false;
84
+ }
85
+ return {
86
+ ...pagination,
87
+ total: total.value
88
+ };
89
+ });
90
+ const onPageSizeChange = () => {
91
+ page.value = 1;
92
+ };
93
+ const onPageChange = () => {
94
+ execute();
95
+ };
96
+ const onSubmit = async () => {
97
+ if (!isFetching.value) {
98
+ page.value = 1;
99
+ await execute();
100
+ }
101
+ };
102
+ const onReset = async () => {
103
+ if (!isFetching.value) {
104
+ page.value = 1;
105
+ await execute();
106
+ }
107
+ };
108
+ const onVisibleChange = visible => {
109
+ emit("visibleChange", visible);
110
+ if (visible) {
111
+ if (isFirstFetch.value && !props.immediate) {
112
+ execute();
113
+ }
114
+ nextTick(() => {
115
+ headerRef.value?.querySelector("input")?.focus();
116
+ });
117
+ }
118
+ };
119
+ const headerRef = ref();
120
+ const {
121
+ getLabel,
122
+ getValue,
123
+ getKey
124
+ } = useProps(props);
125
+ const popperId = uniqid();
126
+ return () => {
127
+ return createVNode(ElSelect, mergeProps(props, attrs, {
128
+ "class": `${hashId.value} ${prefixCls.value}`,
129
+ "popper-class": `${hashId.value} ${prefixCls.value}-popper ${popperId}`,
130
+ "onVisible-change": onVisibleChange
131
+ }), {
132
+ ...slots,
133
+ header: props.formProps ? () => {
134
+ return createVNode("div", {
135
+ "ref": headerRef,
136
+ "onKeydown": event => {
137
+ if (event.key === "Enter") {
138
+ event.preventDefault();
139
+ }
140
+ }
141
+ }, [createVNode(stdin_default$2, mergeProps({
142
+ "ref": tableQueryRef,
143
+ "inline": true,
144
+ "grid": false,
145
+ "size": "small",
146
+ "class": `${prefixCls.value}-form`,
147
+ "width": 120
148
+ }, props.formProps, {
149
+ "reset": onReset,
150
+ "submit": onSubmit
151
+ }), null)]);
152
+ } : null,
153
+ default: () => {
154
+ return tableData.value.map((row, index) => {
155
+ const value = getValue(row);
156
+ const label = getLabel(row);
157
+ const key = getKey(value);
158
+ const optionProps = props.optionProps;
159
+ return createVNode(ElOption, mergeProps({
160
+ "key": key,
161
+ "value": value,
162
+ "label": label
163
+ }, isFunction(optionProps) ? optionProps(row, index) : optionProps), {
164
+ default: () => [slots.option ? slots.option({
165
+ option: row,
166
+ index
167
+ }) : null]
168
+ });
169
+ });
170
+ },
171
+ footer: paginationProps.value ? () => createVNode(ElPagination, mergeProps({
172
+ "size": "small"
173
+ }, paginationProps.value, {
174
+ "current-page": page.value,
175
+ "onUpdate:current-page": $event => page.value = $event,
176
+ "page-size": pageSize.value,
177
+ "onUpdate:page-size": $event => pageSize.value = $event,
178
+ "style": "--el-pagination-bg-color: transparent; --el-pagination-button-disabled-bg-color: transparent;",
179
+ "onSize-change": onPageSizeChange,
180
+ "onChange": onPageChange
181
+ }), null) : null
182
+ });
183
+ };
184
+ }
185
+ });
186
+
187
+ export { stdin_default as default };
@@ -0,0 +1,4 @@
1
+ declare const _default: (_prefixCls?: import("vue").ComputedRef<string> | string, themeManager?: import("../../theme/theme-context").ThemeManager) => {
2
+ hashId: import("vue").Ref<string, string>;
3
+ };
4
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { getSimpleStyleHook } from 'cosey/components';
2
+
3
+ var stdin_default = getSimpleStyleHook("RemoteSelect", (token) => {
4
+ const { componentCls } = token;
5
+ return {
6
+ [`${componentCls}`]: {},
7
+ [`${componentCls}-popper`]: {
8
+ display: "flex",
9
+ flexDirection: "column",
10
+ height: 320,
11
+ [`${componentCls}-form`]: {
12
+ ".el-form-item": {
13
+ marginBottom: 0,
14
+ marginRight: 16,
15
+ "&:last-child": {
16
+ marginRight: 0
17
+ }
18
+ }
19
+ },
20
+ ".el-scrollbar": {
21
+ flex: 1
22
+ },
23
+ ".el-select-dropdown__empty": {
24
+ flex: 1,
25
+ display: "flex",
26
+ justifyContent: "center",
27
+ alignItems: "center"
28
+ }
29
+ }
30
+ };
31
+ });
32
+
33
+ export { stdin_default as default };
@@ -306,6 +306,9 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
306
306
  inlineMessage: boolean;
307
307
  showMessage: boolean;
308
308
  colProps: import("../..").ColProps;
309
+ schemes: import("./table-query").TableQueryScheme[];
310
+ minFields: number;
311
+ collapsed: boolean;
309
312
  submitText: string;
310
313
  resetText: string;
311
314
  hideSubmit: boolean;
@@ -317,9 +320,6 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
317
320
  hideRequiredAsterisk: boolean;
318
321
  scrollToError: boolean;
319
322
  scrollIntoViewOptions: boolean | Record<string, any>;
320
- minFields: number;
321
- collapsed: boolean;
322
- schemes: import("./table-query").TableQueryScheme[];
323
323
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
324
324
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
325
325
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, useSlots, unref, computed, ref, useTemplateRef, mergeProps, watch, onMounted, onBeforeUnmount, resolveComponent, resolveDirective, createBlock, openBlock, Teleport, withDirectives, createElementBlock, normalizeStyle, normalizeClass, createCommentVNode, createElementVNode, createVNode, renderSlot, withCtx, createSlots, Fragment, renderList, vShow, normalizeProps, guardReactiveProps } from 'vue';
2
- import { merge, cloneDeep, get } from 'lodash-es';
2
+ import { merge, get, cloneDeep } from 'lodash-es';
3
3
  import { reactiveComputed, reactiveOmit } from '@vueuse/core';
4
4
  import { useNamespace, useZIndex, ElButton, Mousewheel } from 'element-plus';
5
5
  import { tableEmitEvents, tableProps, tableEmitOnEvents, defaultTableConfig, elSlotsName, omittedTableProps, tableExposeKeys } from './table.js';
@@ -8,22 +8,22 @@ import stdin_default$6 from './table-column-editor/table-column-editor.vue.js';
8
8
  import stdin_default$2 from './table-query/table-query.vue.js';
9
9
  import stdin_default$5 from './table-export/table-export.vue.js';
10
10
  import stdin_default$4 from '../icon/icon.vue.js';
11
- import { filterEmptyFormValue } from './utils.js';
12
11
  import stdin_default$1 from './table.style.js';
13
12
  import { hColgroup } from 'element-plus/es/components/table/src/h-helper.mjs';
14
13
  import stdin_default$8 from './table-footer/index.js';
15
14
  import { defaultSummaryMethod } from './table-footer/utils.js';
16
15
  import stdin_default$3 from './table-stats/table-stats.vue.js';
17
- import { uniqid } from '../../utils/string.js';
18
- import { useComponentConfig, useConfig } from '../config-provider/config-provider.js';
19
16
  import { flatColumns } from '../../utils/excel/index.js';
20
- import { useFetch } from '../../hooks/useFetch.js';
21
17
  import { useFullPage } from '../../hooks/useFullPage.js';
22
18
  import { useLocale } from '../../hooks/useLocale.js';
19
+ import { uniqid } from '../../utils/string.js';
20
+ import { useComponentConfig, useConfig } from '../config-provider/config-provider.js';
23
21
  import { addPxUnit } from '../../utils/css.js';
24
22
  import { isNullish, isObject, isFunction } from '../../utils/is.js';
25
23
  import { getVNodeText, createMergedExpose } from '../../utils/vue.js';
24
+ import { useFetch } from '../../hooks/useFetch.js';
26
25
  import { useResizeObserver } from '../../hooks/useResizeObserver.js';
26
+ import { filterEmptyFormValue } from '../../utils/components.js';
27
27
  import { walkTree } from '../../utils/tree.js';
28
28
 
29
29
  const _hoisted_1 = {
package/hooks/index.d.ts CHANGED
@@ -20,3 +20,4 @@ export * from './useTreeCheck';
20
20
  export * from './useOptionalComponent';
21
21
  export * from './useMounted';
22
22
  export * from './useDir';
23
+ export * from './useProps';
package/hooks/index.js CHANGED
@@ -20,3 +20,4 @@ export { treeCheckContextKey, useTreeCheck, useTreeCheckInject } from './useTree
20
20
  export { useOptionalComponent } from './useOptionalComponent.js';
21
21
  export { useMounted } from './useMounted.js';
22
22
  export { useDir } from './useDir.js';
23
+ export { defaultProps, useProps } from './useProps.js';
@@ -0,0 +1,24 @@
1
+ import { MaybeRef } from 'vue';
2
+ export interface Props {
3
+ label?: string;
4
+ value?: string;
5
+ disabled?: string;
6
+ options?: string;
7
+ }
8
+ export declare const defaultProps: Required<Props>;
9
+ export declare function useProps(props: MaybeRef<{
10
+ props?: Props;
11
+ valueKey?: any;
12
+ }>): {
13
+ aliasProps: import("vue").ComputedRef<{
14
+ label: string;
15
+ value: string;
16
+ disabled: string;
17
+ options: string;
18
+ }>;
19
+ getLabel: (option: Record<PropertyKey, any>) => any;
20
+ getValue: (option: Record<PropertyKey, any>) => any;
21
+ getDisabled: (option: Record<PropertyKey, any>) => any;
22
+ getOptions: (option: Record<PropertyKey, any>) => any;
23
+ getKey: (value: any) => any;
24
+ };
@@ -0,0 +1,29 @@
1
+ import { get } from 'lodash-es';
2
+ import { computed, unref } from 'vue';
3
+ import { isObject } from '../utils/is.js';
4
+
5
+ const defaultProps = {
6
+ label: "label",
7
+ value: "value",
8
+ disabled: "disabled",
9
+ options: "options"
10
+ };
11
+ function useProps(props) {
12
+ const aliasProps = computed(() => ({ ...defaultProps, ...unref(props).props }));
13
+ const valueKey = computed(() => unref(props).valueKey);
14
+ const getLabel = (option) => get(option, aliasProps.value.label);
15
+ const getValue = (option) => get(option, aliasProps.value.value);
16
+ const getDisabled = (option) => get(option, aliasProps.value.disabled);
17
+ const getOptions = (option) => get(option, aliasProps.value.options);
18
+ const getKey = (value) => isObject(value) && valueKey.value ? get(value, valueKey.value) : value;
19
+ return {
20
+ aliasProps,
21
+ getLabel,
22
+ getValue,
23
+ getDisabled,
24
+ getOptions,
25
+ getKey
26
+ };
27
+ }
28
+
29
+ export { defaultProps, useProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.4.52",
3
+ "version": "0.5.0",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 发送到服务器之前,过滤掉查询表单中为空的数据,包括空数组和空字符串
3
+ */
4
+ export declare function filterEmptyFormValue(model: Record<string, any>): {
5
+ [k: string]: any;
6
+ };
7
+ export declare function createLoading(selector: string): {
8
+ setText: (text: string) => void;
9
+ removeElLoadingChild: () => void;
10
+ close: () => void;
11
+ handleAfterLeave: () => void;
12
+ vm: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
13
+ $el: HTMLElement;
14
+ originalPosition: import("vue").Ref<string>;
15
+ originalOverflow: import("vue").Ref<string>;
16
+ visible: import("vue").Ref<boolean>;
17
+ parent: import("vue").Ref<import("element-plus").LoadingParentElement>;
18
+ background: import("vue").Ref<string>;
19
+ svg: import("vue").Ref<string>;
20
+ svgViewBox: import("vue").Ref<string>;
21
+ spinner: import("vue").Ref<string | boolean>;
22
+ text: import("vue").Ref<string>;
23
+ fullscreen: import("vue").Ref<boolean>;
24
+ lock: import("vue").Ref<boolean>;
25
+ customClass: import("vue").Ref<string>;
26
+ target: import("vue").Ref<HTMLElement>;
27
+ beforeClose?: import("vue").Ref<(() => boolean) | undefined> | undefined;
28
+ closed?: import("vue").Ref<(() => void) | undefined> | undefined;
29
+ };
@@ -0,0 +1,13 @@
1
+ import { ElLoading } from 'element-plus';
2
+ import { isEmpty } from './is.js';
3
+
4
+ function filterEmptyFormValue(model) {
5
+ return Object.fromEntries(Object.entries(model).filter(([, value]) => !isEmpty(value)));
6
+ }
7
+ function createLoading(selector) {
8
+ return ElLoading.service({
9
+ target: document.querySelector(selector)
10
+ });
11
+ }
12
+
13
+ export { createLoading, filterEmptyFormValue };
package/utils/index.d.ts CHANGED
@@ -19,3 +19,4 @@ export * from './sleep';
19
19
  export * from './tree';
20
20
  export * from './message-box';
21
21
  export * from './env';
22
+ export * from './components';
package/utils/index.js CHANGED
@@ -18,6 +18,7 @@ export { sleep } from './sleep.js';
18
18
  export { arrayToTree, extraTreeToTable, mapTree, mapTreeExtra, walkAncestor, walkTree, walkTreeNode } from './tree.js';
19
19
  export { warningConfirm } from './message-box.js';
20
20
  export { isClient } from './env.js';
21
+ export { createLoading, filterEmptyFormValue } from './components.js';
21
22
  import * as echarts from 'echarts/core';
22
23
  export { echarts };
23
24
  export { bookFormats } from './excel/bookFormats.js';
@@ -1,6 +0,0 @@
1
- /**
2
- * 发送到服务器之前,过滤掉查询表单中为空的数据,包括空数组和空字符串
3
- */
4
- export declare function filterEmptyFormValue(model: Record<string, any>): {
5
- [k: string]: any;
6
- };
@@ -1,7 +0,0 @@
1
- import { isEmpty } from '../../utils/is.js';
2
-
3
- function filterEmptyFormValue(model) {
4
- return Object.fromEntries(Object.entries(model).filter(([, value]) => !isEmpty(value)));
5
- }
6
-
7
- export { filterEmptyFormValue };